Changeset 603355
- Timestamp:
- 09/24/2012 11:11:56 PM (14 years ago)
- Location:
- menu-rules/trunk
- Files:
-
- 9 added
- 7 deleted
- 4 edited
-
admin/admin.php (modified) (5 diffs)
-
admin/meta-box-conditions.php (added)
-
admin/meta-box-reactions.php (added)
-
admin/meta-box.php (deleted)
-
assets (deleted)
-
libs/pb-framework/assets/css/chosen.css (deleted)
-
libs/pb-framework/assets/css/meta-box.css (added)
-
libs/pb-framework/assets/img (deleted)
-
libs/pb-framework/assets/js/chosen.jquery.js (deleted)
-
libs/pb-framework/assets/js/chosen.jquery.min.js (deleted)
-
libs/pb-framework/assets/js/init-chosen.js (added)
-
libs/pb-framework/assets/js/script.js (deleted)
-
libs/pb-framework/assets/vendor (added)
-
libs/pb-framework/assets/vendor/chosen (added)
-
libs/pb-framework/assets/vendor/chosen/chosen-sprite.png (added)
-
libs/pb-framework/assets/vendor/chosen/chosen.css (added)
-
libs/pb-framework/assets/vendor/chosen/chosen.jquery.min.js (added)
-
libs/pb-framework/forms.php (modified) (5 diffs)
-
libs/pb-framework/meta-box.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
menu-rules/trunk/admin/admin.php
r521950 r603355 4 4 class Menu_Rules_Admin { 5 5 6 static $meta_box; 6 static $meta_box_conditions; 7 static $meta_box_reactions; 7 8 8 9 // On plugins loaded … … 17 18 18 19 add_action( 'admin_print_styles-post.php', __CLASS__ . '::styles' ); 20 add_action( 'admin_print_styles-post-new.php', __CLASS__ . '::styles' ); 21 19 22 add_action( 'admin_print_scripts-post.php', __CLASS__ . '::scripts' ); 23 add_action( 'admin_print_scripts-post-new.php', __CLASS__ . '::scripts' ); 20 24 } 21 25 … … 24 28 25 29 // Load meta box object here so the save handler is added earlier in the request but after plugins_loaded so menu items are loaded 26 require dirname( __FILE__ ) . '/meta-box.php'; 27 self::$meta_box = new Menu_Rules_Meta_Box(); 30 require dirname( __FILE__ ) . '/meta-box-conditions.php'; 31 self::$meta_box_conditions = new Menu_Rules_Meta_Box_Conditions(); 32 33 require dirname( __FILE__ ) . '/meta-box-reactions.php'; 34 self::$meta_box_reactions = new Menu_Rules_Meta_Box_Reactions(); 28 35 } 29 36 30 // When stylesheets are outputted on post.php37 // When Stylesheets are outputted on post.php 31 38 static function styles() { 32 39 … … 34 41 if ( ! isset( $GLOBALS['post_type_object'] ) || $GLOBALS['post_type_object']->name != Menu_Rules::get_var( 'post_type' ) ) return; 35 42 36 // Queue admin stylesheet# 37 wp_enqueue_style( 'menu_rules_admin', plugins_url( '/assets/css/admin.css', dirname( __FILE__ ) ) ); 43 self::$meta_box_reactions->styles(); 38 44 } 39 45 … … 48 54 } 49 55 56 // When the post type is registered 57 // TODO: decouple this from Menu_Rules::init 50 58 static function register_meta_boxes() { 51 add_meta_box( 'menu-rules', __('Menu Rules'), array( &Menu_Rules_Admin::$meta_box, 'display' ), Menu_Rules::get_var( 'post_type' ), 'normal' ); 59 60 add_meta_box( 'menu-rules-conditions', __('Conditions'), array( &Menu_Rules_Admin::$meta_box_conditions, 'display' ), Menu_Rules::get_var( 'post_type' ), 'normal' ); 61 62 add_meta_box( 'menu-rules-reactions', __('Reactions'), array( &Menu_Rules_Admin::$meta_box_reactions, 'display' ), Menu_Rules::get_var( 'post_type' ), 'normal' ); 52 63 } 53 64 } -
menu-rules/trunk/libs/pb-framework/forms.php
r536937 r603355 100 100 // Generates a table row 101 101 static function table_row( $args, $formdata = NULL ) { 102 return self::row_wrap( $args ['title'], self::input( $args, $formdata ) );102 return self::row_wrap( $args, self::input( $args, $formdata ) ); 103 103 } 104 104 … … 127 127 // Wraps the given content in a <table> 128 128 static function table_wrap( $content ) { 129 $output = "\n<table class='form-table '>\n" . $content . "\n</table>\n";129 $output = "\n<table class='form-table pb-framework-table'>\n" . $content . "\n</table>\n"; 130 130 131 131 return $output; … … 133 133 134 134 // Wraps the given content in a <tr><td> 135 static function row_wrap( $title, $content ) { 136 return "\n<tr>\n\t<th scope='row'>" . $title . "</th>\n\t<td>\n\t\t" . $content . "\t</td>\n\n</tr>"; 135 static function row_wrap( $args, $content ) { 136 $output = '<tr><th scope="row"><label for="' . $args['name'] . '">' . $args['title'] . '</label>'; 137 138 // Description below the label 139 if ( isset( $args['description'] ) ) $output .= $args['description']; 140 141 $output .= '</th><td>' . $content; 142 143 // Footer text below the field 144 if ( isset( $args['footer'] ) ) $output .= $args['footer']; 145 146 $output .= '</td></tr>'; 147 148 return $output; 137 149 } 138 150 … … 223 235 if ( empty( $value ) || empty( $title ) ) 224 236 continue; 225 237 226 238 $checkbox_args = array( 227 239 'type' => 'radio', … … 262 274 // Fancy JavaScript form library 263 275 if ( $use_js ) { 264 wp_enqueue_style( 'pb _chosen', plugins_url( '/assets/css/chosen.css', __FILE__ ) );265 wp_enqueue_script( 'pb _chosen', plugins_url( '/assets/js/chosen.jquery.min.js', __FILE__ ), array( 'jquery' ), false, true );266 wp_enqueue_script( 'pb ', plugins_url( '/assets/js/script.js', __FILE__ ), array( 'pb_chosen' ), false, true );276 wp_enqueue_style( 'pb-vendor-chosen', plugins_url( '/assets/vendor/chosen/chosen.css', __FILE__ ) ); 277 wp_enqueue_script( 'pb-vendor-chosen', plugins_url( '/assets/vendor/chosen/chosen.jquery.min.js', __FILE__ ), array( 'jquery' ), false, true ); 278 wp_enqueue_script( 'pb-chosen-init', plugins_url( '/assets/js/init-chosen.js', __FILE__ ), array( 'pb-vendor-chosen' ), false, true ); 267 279 268 280 // Class JS will pickup on -
menu-rules/trunk/libs/pb-framework/meta-box.php
r536937 r603355 1 1 <?php 2 2 3 // TODO: if and when WordPress moves to PHP5.3 requirement, implent the singleton pattern4 3 abstract class PB_Meta_Box { 5 4 … … 17 16 18 17 // Display meta box 19 abstract function display( $post ); 18 function display( $post ) { 19 foreach ( $this->get_fields() as $field_group ) echo PB_Forms::table( $field_group, get_post_custom( $post->ID ) ); 20 } 20 21 21 22 // Save data … … 56 57 } 57 58 59 // Register Stylesheets 60 function styles() { 61 wp_enqueue_style( 'pb-meta-box', plugins_url( '/assets/css/meta-box.css', __FILE__ ) ); 62 } 63 64 // Register JavaScript 65 function scripts() { 66 } 67 58 68 // Get all fields in a grouped hierarchical list 59 69 protected function get_fields( $group = '' ) { 60 return $group && isset( $this->fields[$group] ) ? $this->fields[$group] : $this->fields; 70 if ( $group ) { 71 return isset( $this->fields[$group] ) ? $this->fields[$group] : array(); 72 } else { 73 return $this->fields; 74 } 61 75 } 62 76 … … 88 102 protected function get_field_def( $name ) { 89 103 $all_fields = $this->get_fields_flat(); 90 //print_r($all_fields);91 104 return isset( $all_fields[$name] ) ? $all_fields[$name] : false; 92 105 } 106 107 // Add a group of fields 108 protected function add_field_group( $name, $fields ) { 109 $this->fields[$name] = $fields; 110 } 93 111 } -
menu-rules/trunk/readme.txt
r561716 r603355 47 47 == Changelog == 48 48 49 = 1.2 = 50 * Conditions and Reactions divided into 2 meta boxes to improve usability 51 * Theme improvements 52 * Added *description* and *footer* options to PB Framework forms 53 * Moved plugin meta box styles into PB Framework 54 * Added default meta box display in PB Framework 55 * Added field setter for PB Framework meta box class 56 * Bugfix where frontend assets weren't being loaded when on a new menu rule 57 * Bugfix in meta box get_fields() 58 59 **Note:** Some stylesheets and Javascript files have had their handles changed. 60 49 61 = 1.1 = 50 * Added new 'force inactive parent'rule62 * Added new *force inactive parent* rule 51 63 * Changed behaviour to one rule per item 52 64 * Minor enhancements to PB Framework
Note: See TracChangeset
for help on using the changeset viewer.