WordPress.org

Plugin Directory

Changeset 603355


Ignore:
Timestamp:
09/24/12 23:11:56 (19 months ago)
Author:
phill_brown
Message:

1.2 code

Location:
menu-rules/trunk
Files:
9 added
7 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • menu-rules/trunk/admin/admin.php

    r521950 r603355  
    44class Menu_Rules_Admin { 
    55 
    6     static $meta_box; 
     6    static $meta_box_conditions; 
     7    static $meta_box_reactions; 
    78 
    89    // On plugins loaded 
     
    1718 
    1819        add_action( 'admin_print_styles-post.php', __CLASS__ . '::styles' ); 
     20        add_action( 'admin_print_styles-post-new.php', __CLASS__ . '::styles' ); 
     21 
    1922        add_action( 'admin_print_scripts-post.php', __CLASS__ . '::scripts' ); 
     23        add_action( 'admin_print_scripts-post-new.php', __CLASS__ . '::scripts' ); 
    2024    } 
    2125 
     
    2428 
    2529        // 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(); 
    2835    } 
    2936 
    30     // When stylesheets are outputted on post.php 
     37    // When Stylesheets are outputted on post.php 
    3138    static function styles() { 
    3239 
     
    3441        if ( ! isset( $GLOBALS['post_type_object'] ) || $GLOBALS['post_type_object']->name != Menu_Rules::get_var( 'post_type' ) ) return; 
    3542 
    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(); 
    3844    } 
    3945 
     
    4854    } 
    4955 
     56    // When the post type is registered 
     57    // TODO: decouple this from Menu_Rules::init 
    5058    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' ); 
    5263    } 
    5364} 
  • menu-rules/trunk/libs/pb-framework/forms.php

    r536937 r603355  
    100100    // Generates a table row 
    101101    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 ) ); 
    103103    } 
    104104 
     
    127127    // Wraps the given content in a <table> 
    128128    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"; 
    130130 
    131131        return $output; 
     
    133133 
    134134    // 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; 
    137149    } 
    138150 
     
    223235            if ( empty( $value ) || empty( $title ) ) 
    224236                continue; 
    225              
     237 
    226238            $checkbox_args = array( 
    227239                'type' => 'radio', 
     
    262274        // Fancy JavaScript form library 
    263275        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 ); 
    267279 
    268280            // Class JS will pickup on 
  • menu-rules/trunk/libs/pb-framework/meta-box.php

    r536937 r603355  
    11<?php 
    22 
    3 // TODO: if and when WordPress moves to PHP5.3 requirement, implent the singleton pattern 
    43abstract class PB_Meta_Box { 
    54 
     
    1716 
    1817    // 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    } 
    2021 
    2122    // Save data 
     
    5657    } 
    5758 
     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 
    5868    // Get all fields in a grouped hierarchical list 
    5969    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        } 
    6175    } 
    6276 
     
    88102    protected function get_field_def( $name ) { 
    89103        $all_fields = $this->get_fields_flat(); 
    90         //print_r($all_fields); 
    91104        return isset( $all_fields[$name] ) ? $all_fields[$name] : false; 
    92105    } 
     106 
     107    // Add a group of fields 
     108    protected function add_field_group( $name, $fields ) { 
     109        $this->fields[$name] = $fields; 
     110    } 
    93111} 
  • menu-rules/trunk/readme.txt

    r561716 r603355  
    4747== Changelog == 
    4848 
     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 
    4961= 1.1 = 
    50 * Added new 'force inactive parent' rule 
     62* Added new *force inactive parent* rule 
    5163* Changed behaviour to one rule per item 
    5264* Minor enhancements to PB Framework 
Note: See TracChangeset for help on using the changeset viewer.