Changeset 640080
- Timestamp:
- 12/16/2012 04:41:13 PM (13 years ago)
- Location:
- context-manager
- Files:
-
- 53 added
- 5 edited
-
assets/screenshot-2.png (added)
-
tags/1.1 (added)
-
tags/1.1/admin (added)
-
tags/1.1/admin/admin.php (added)
-
tags/1.1/admin/meta-box-conditions.php (added)
-
tags/1.1/admin/meta-box-reactions.php (added)
-
tags/1.1/libs (added)
-
tags/1.1/libs/pb-framework (added)
-
tags/1.1/libs/pb-framework/assets (added)
-
tags/1.1/libs/pb-framework/assets/css (added)
-
tags/1.1/libs/pb-framework/assets/css/meta-box.css (added)
-
tags/1.1/libs/pb-framework/assets/js (added)
-
tags/1.1/libs/pb-framework/assets/js/init-chosen.js (added)
-
tags/1.1/libs/pb-framework/assets/js/tabs.js (added)
-
tags/1.1/libs/pb-framework/assets/vendor (added)
-
tags/1.1/libs/pb-framework/assets/vendor/chosen (added)
-
tags/1.1/libs/pb-framework/assets/vendor/chosen/chosen-sprite.png (added)
-
tags/1.1/libs/pb-framework/assets/vendor/chosen/chosen.css (added)
-
tags/1.1/libs/pb-framework/assets/vendor/chosen/chosen.jquery.min.js (added)
-
tags/1.1/libs/pb-framework/base.php (added)
-
tags/1.1/libs/pb-framework/forms.php (added)
-
tags/1.1/libs/pb-framework/meta-box2.php (added)
-
tags/1.1/libs/scb-framework (added)
-
tags/1.1/libs/scb-framework/example.php (added)
-
tags/1.1/libs/scb-framework/plugin.php (added)
-
tags/1.1/libs/scb-framework/readme.txt (added)
-
tags/1.1/libs/scb-framework/scb (added)
-
tags/1.1/libs/scb-framework/scb-debug.php (added)
-
tags/1.1/libs/scb-framework/scb-info.php (added)
-
tags/1.1/libs/scb-framework/scb-load.php (added)
-
tags/1.1/libs/scb-framework/scb/AdminPage.php (added)
-
tags/1.1/libs/scb-framework/scb/BoxesPage.php (added)
-
tags/1.1/libs/scb-framework/scb/Cron.php (added)
-
tags/1.1/libs/scb-framework/scb/Forms.php (added)
-
tags/1.1/libs/scb-framework/scb/Hooks.php (added)
-
tags/1.1/libs/scb-framework/scb/Options.php (added)
-
tags/1.1/libs/scb-framework/scb/Table.php (added)
-
tags/1.1/libs/scb-framework/scb/Util.php (added)
-
tags/1.1/libs/scb-framework/scb/Widget.php (added)
-
tags/1.1/libs/scb-framework/scb/load.php (added)
-
tags/1.1/plugin.php (added)
-
tags/1.1/reactions (added)
-
tags/1.1/reactions/assets.php (added)
-
tags/1.1/reactions/base.php (added)
-
tags/1.1/reactions/body_class.php (added)
-
tags/1.1/reactions/menu (added)
-
tags/1.1/reactions/menu.php (added)
-
tags/1.1/reactions/menu/active-parent.php (added)
-
tags/1.1/reactions/menu/child-page.php (added)
-
tags/1.1/reactions/menu/inactive-parent.php (added)
-
tags/1.1/reactions/widgets.php (added)
-
tags/1.1/readme.txt (added)
-
trunk/plugin.php (modified) (5 diffs)
-
trunk/reactions/assets.php (added)
-
trunk/reactions/base.php (modified) (2 diffs)
-
trunk/reactions/menu.php (modified) (2 diffs)
-
trunk/reactions/widgets.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
context-manager/trunk/plugin.php
r640003 r640080 2 2 /* 3 3 Plugin Name: Context Manager 4 Description: Context-based rules for menus, widgets and the body class.4 Description: Make your site react to users' context by changing your theme's CSS and JavaScript files, navigation menus, sidebars and the HTML body tag. 5 5 Author: Phill Brown 6 6 Author URI: http://pbweb.co.uk 7 Version: 1. 0.27 Version: 1.1 8 8 9 9 Copyright 2012 Phill Brown (email: wp@pbweb.co.uk) … … 39 39 // Setup reactions 40 40 require_once dirname( __FILE__ ) . '/reactions/base.php'; 41 foreach ( array( ' Menu', 'Widgets', 'Body_Class' ) as $reaction ) {41 foreach ( array( 'Assets', 'Menu', 'Widgets', 'Body_Class' ) as $reaction ) { 42 42 43 43 // Include reaction … … 46 46 // Instantiate reactions 47 47 $class_name = 'Context_Manager_Reaction_' . $reaction; 48 $reactions[ $class_name ] = new $class_name( &$this );48 $reactions[ $class_name ] = new $class_name( $this ); 49 49 } 50 50 … … 55 55 if ( is_admin() ) { 56 56 require_once dirname( __FILE__ ) . '/admin/admin.php'; 57 $admin = new Context_Manager_Admin( &$this );57 $admin = new Context_Manager_Admin( $this ); 58 58 } 59 59 … … 75 75 $this->meta_boxes = array( 76 76 'conditions' => new Context_Manager_Meta_Box_Conditions(), 77 'reactions' => new Context_Manager_Meta_Box_Reactions( &$this ),77 'reactions' => new Context_Manager_Meta_Box_Reactions( $this ), 78 78 ); 79 79 -
context-manager/trunk/reactions/base.php
r640002 r640080 23 23 24 24 // No form registered 25 if ( ! $this->form( ) ) return;25 if ( ! $this->form( false ) ) return; 26 26 27 27 // Setup meta query conditions 28 28 $meta_queries = array(); 29 foreach( $this->form( ) as $field_name => $field_data ) {29 foreach( $this->form( false ) as $field_name => $field_data ) { 30 30 $meta_queries[] = array( 31 31 'key' => $this->field_prefix() . $field_name, … … 34 34 ); 35 35 } 36 36 37 37 // Get context rules 38 38 return get_posts( array( 39 39 'post_type' => $this->plugin->post_type, 40 40 'numberposts' => -1, 41 'meta_query' => array_merge( array( ' condition' => 'OR' ), $meta_queries ),41 'meta_query' => array_merge( array( 'relation' => 'OR' ), $meta_queries ), 42 42 ) ); 43 43 } -
context-manager/trunk/reactions/menu.php
r639694 r640080 54 54 'rules' => array( 55 55 'title' => __( 'Apply this rule:' , 'context-manager' ), 56 'type' => ' radio',56 'type' => 'select', 57 57 'value' => array_combine( 58 58 array_keys( $this->handlers ), … … 110 110 111 111 // Let the menu handler do the magic 112 call_user_func ( array( $this->handlers[ $applied_handler ], 'handler' ), $context_rule_data, &$this);112 call_user_func_array( array( $this->handlers[ $applied_handler ], 'handler' ), array( $context_rule_data, &$this ) ); 113 113 } 114 114 } -
context-manager/trunk/reactions/widgets.php
r640003 r640080 11 11 } 12 12 13 function form( ) {13 function form( $preprocess = true ) { 14 14 15 15 // Hack to stop wp_get_sidebars_widgets() getting in an infinite loop 16 if ( ! $this->form_skip_get_values ) {16 if ( $preprocess ) { 17 17 // Map widgets and sidebars 18 18 foreach( wp_get_sidebars_widgets() as $sidebar_id => $sidebar_widgets ) { … … 53 53 function hide_widgets( $sidebars_widgets ) { 54 54 55 // As we're calling wp_get_sidebars_widgets() in form() - we need a hack to stop PHP getting into an infinite loop56 $this->form_skip_get_values = true;57 55 if ( ! $context_rules = $this->get_rules() ) return $sidebars_widgets; 58 $this->form_skip_get_values = false;59 60 56 foreach ( $context_rules as $context_rule ) { 61 57 if ( ! $this->plugin->conditions_match( $context_rule ) ) continue; -
context-manager/trunk/readme.txt
r640003 r640080 2 2 Contributors: phill_brown 3 3 Donate link: http://pbweb.co.uk/donate 4 Tags: context, rules, widget logic, menu rules, body class, widgets, parent menu, active menu4 Tags: context, wp_enqueue_styles, wp_enqueue_scripts, rules, widget logic, menu rules, body class, widgets, parent menu, active menu 5 5 Requires at least: 3.2 6 6 Tested up to: 3.5 7 Stable tag: 1. 0.27 Stable tag: 1.1 8 8 9 Make your site react to contextual conditions using a point and click interface9 Make your site react to users' context by changing your theme's CSS and JavaScript files, navigation menus, sidebars and the HTML body tag. 10 10 11 11 == Description == 12 12 13 Context Manager lets you apply your own context rules and reactions to the menu system, your theme's sidebars and the HTML body tag. 13 Context Manager makes your site behave differently depending on the current user's context. Using the simple point-and-click admin pages, there are four different ways your site can react: 14 15 1. Include and exclude CSS and JavaScript files 16 1. Changing the behaviour of menu items 17 1. Hiding widgets in sidebars 18 1. Adding extra classes to the `<body>` tag. 14 19 15 20 The plugin supersedes [Menu Rules](http://wordpress.org/extend/plugins/menu-rules/) … … 21 26 A user visits 'shop' and the menu item becomes 'active', but when they click through to an individual product, the menu item loses its state. The user becomes lost. 22 27 23 On the product page, there are irrelevant widgets that distract the user from making a purchase.24 25 The whole shop section requires its own colour scheme, but there's no common class that ties all the pages together.26 27 Context Manager can fix all of these things.28 29 28 1. [Install](http://wordpress.org/extend/plugins/context-manager/installation/) the Context Manager plugin 30 29 1. Add a new context rule … … 33 32 1. Choose *Emulate current page as a child but do not create a menu item.* as the menu rule 34 33 1. Find your products page in the menu dropdown 35 1. Hide irrelevant widgets under the *widgets* reaction36 1. Enter a meaningful class name in the *body class* reaction37 1. Hit publish38 34 39 See a [screenshot](http://wordpress.org/extend/plugins/context-manager/screenshots/) of the above setup. 35 On the product page, there are irrelevant widgets that distract the user from making a purchase. 36 37 * Hide irrelevant widgets under the *widgets* reaction 38 39 The whole shop section requires its own colour scheme, but there's no common class that ties all the pages together. 40 41 * Enter `shop-section` class name in the *body class* reaction. Or alternatively, register another stylesheet using [`wp_register_style()`](http://codex.wordpress.org/Function_Reference/wp_register_style) in you theme's `functions.php`. 42 * Create 43 44 Remember to click publish when you're ready to save. 45 46 Have a look at [screenshots](http://wordpress.org/extend/plugins/context-manager/screenshots/) to see the above setup in action. 40 47 41 48 = Support = … … 53 60 54 61 1. An example setup for a products section in a online shop 62 2. CSS and JavaScript reactions 55 63 56 64 == Changelog == 65 66 = 1.1 = 67 * [Added]: Assets reaction 68 * [Bugfix]: get_rules() using incorrect meta_query parameter 69 * [Bugfix]: PHP 5.4 fatal errors 57 70 58 71 = 1.0.2 =
Note: See TracChangeset
for help on using the changeset viewer.