Plugin Directory

Changeset 894373


Ignore:
Timestamp:
04/16/2014 03:58:23 PM (12 years ago)
Author:
OneManOneLaptop
Message:

fix for php5.4 array type error

Location:
flux/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • flux/trunk/flux.php

    r755031 r894373  
    88 * Author URI: http://github.com/onemanonelaptop
    99 */
    10  
     10
    1111/* Copyright 2011 Rob Holmes ( email: rob@onemanonelaptop.com )
    1212
     
    2525   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2626*/
    27  
     27
    2828add_action( 'plugins_loaded', 'flux' );
    2929/**
    3030 * Runs on plugins_loaded action and defines the required classes
    3131 * after the classes are defined the flux action is fired, this is where child
    32  * plugins define their functionality 
     32 * plugins define their functionality
    3333 */
    3434if (!function_exists('flux')) {
  • flux/trunk/plugin.php

    r755030 r894373  
    2020    /**
    2121    * The Plugin Class
    22     */ 
     22    */
    2323    class Plugin {
    2424
     
    7474
    7575        var $debug_messages = array();
    76        
     76
    7777        /**
    7878        * Constructor
     
    121121
    122122                // Save the custom post fields with the post data
    123                 add_action('save_post', array(&$this,'diy_save_post')); 
     123                add_action('save_post', array(&$this,'diy_save_post'));
    124124
    125125                // Register the scripts and styles needed for metaboxes and fields
     
    132132
    133133            // Setup the ajax callback for autocomplete widget
    134             add_action('wp_ajax_suggest_action_' . $this->slug, array(&$this,'diy_suggest_posts_callback'));   
    135             add_action('wp_ajax_attachments_action', array(&$this,'diy_suggest_attachments')); 
    136             add_action('wp_ajax_save_attachment_action', array(&$this,'diy_save_attachment')); 
     134            add_action('wp_ajax_suggest_action_' . $this->slug, array(&$this,'diy_suggest_posts_callback'));
     135            add_action('wp_ajax_attachments_action', array(&$this,'diy_suggest_attachments'));
     136            add_action('wp_ajax_save_attachment_action', array(&$this,'diy_save_attachment'));
    137137
    138138            // add_action('wp_ajax_suggest_action', array(&$this,'diy_suggest_users_callback'));
     
    142142        } // end function
    143143
    144        
    145                
     144
     145
    146146      /*
    147147       * Usage for a custom post type named 'movies':
     
    163163      }
    164164
    165        
     165
    166166        /**
    167167        * Validate callback when saving a plugins options
    168         * 
     168        *
    169169        * @param    array   $data   The form post data
    170170        * @return   array   The validated data
     
    194194                    if (isset($metabox['#post_types']) && is_array($metabox['#post_types'])) {
    195195                        foreach ($metabox['#post_types'] as $post_type) {
    196                             // Add the metabox   
    197                             add_meta_box( 
    198                                 $key, 
     196                            // Add the metabox
     197                            add_meta_box(
     198                                $key,
    199199                                $metabox['#title'],
    200200                                array(&$this,'render_metabox_fields'),
    201                                 $post_type, 
     201                                $post_type,
    202202                                $metabox['#context'],
    203                                 'core', 
     203                                'core',
    204204                                $key
    205205                            );
    206                         } 
     206                        }
    207207                    } // end if
    208208
     
    250250         */
    251251        function render_metabox_fields($post,$args) {
    252            
     252
    253253            // sotre the metabox id (array key)
    254254            $key = $args['args'];
     
    264264                $this->apply_defaults($values);
    265265            }
    266            
     266
    267267            // print any visibility options form the metabox definition
    268268            print $this->metabox_visibility($key);
    269269            // print any positioning options form the metabox definition
    270270            print $this->metabox_positioning($key);
    271  
     271
    272272            // retrieve the form
    273273            $newform = new Form($this->forms[$key]);
     
    279279         * Called when a settings filed does not yet exist for a page's metabox
    280280         * Use the form definition to biuld an array of values and save the
    281          * setting 
     281         * setting
    282282         */
    283283        function apply_defaults(&$values) {
    284284
    285             // go through each element recurisvely   
     285            // go through each element recurisvely
    286286            foreach($values as $key => $value) {
    287              
     287
    288288                // special treatement for multi groups
    289289                if ($key == '#type') {
     
    299299                            } // if
    300300                        } // foreach
    301                      
     301
    302302                    } // if
    303303                } // if
     
    312312                    unset($values['#default_value']);
    313313                   //  $values = $save;
    314                    
    315                  
     314
     315
    316316                } else {
    317                    
     317
    318318                    unset($values[$key]);
    319319                }
    320                
     320
    321321            }
    322322            return $values;
    323323        } // function
    324        
     324
    325325        /**
    326326         * Allow metaboxes to be fixed in certain positions
     
    343343
    344344        /**
    345          * Insert a div into a metabox to indiate its visibility settings 
     345         * Insert a div into a metabox to indiate its visibility settings
    346346         * Used by jquery to disable/enable visiblity settings
    347347         * @param string $id Array key of the metabox
    348          * @return string 
     348         * @return string
    349349         */
    350350        function metabox_visibility($id) {
     
    363363         * Recursively create options pages from the pages array
    364364         *
    365          * @since   0.0.9
    366          * @access  public
     365         * @since   0.0.9
     366         * @access  public
    367367         */
    368368        public function diy_register_pages() {
     
    378378            global $admin_page_hooks;
    379379            foreach ($elements as $key => $page) {
     380
     381                if (is_array( $page) && isset( $page['#type'])) {
     382
     383
     384
    380385                if ($page['#type'] == 'menu') {
    381386                    $elements[$key]['#hook'] =  add_menu_page(  __($page['#title']), __($page['#link_text']), 'manage_options', $key, array(&$this,'diy_render_options_page' ));
    382                
    383                    
    384                    
     387
     388
     389
    385390                    }
    386                
     391
    387392                // Add theme pages
    388393                if ($page['#type'] == 'theme') {
     
    398403                if ($page['#type'] == 'options') {
    399404                    // Set the callback
    400                     if (empty($elements[$key]['#callback'])) { 
     405                    if (empty($elements[$key]['#callback'])) {
    401406                        $elements[$key]['#callback'] =  'diy_render_options_page';
    402407                    }
    403                     if ($elements['#parent']) { 
     408                    if ($elements['#parent']) {
    404409                        // allow a link destination, custom callback
    405                         if (isset($elements[$key]['#destination'])) { 
     410                        if (isset($elements[$key]['#destination'])) {
    406411
    407412                            $elements[$key]['#hook'] = add_submenu_page( $elements['#parent'], __($page['#title']), __($page['#link_text']), 'manage_options',    $elements[$key]['#destination'] ,'' );
    408413                        } else {
    409414                            $elements[$key]['#hook'] = add_submenu_page( $elements['#parent'], __($page['#title']), __($page['#link_text']), 'manage_options',  $key,  array($this, 'diy_render_options_page')  );
    410                    
    411                            
     415
     416
    412417                            }
    413418                    } else {
     
    422427
    423428                }
     429            }
    424430
    425431                // recursively register any nested pages
     
    431437                }
    432438
     439
    433440            } // end foreach
    434441        } // function
     
    438445         * Runs only on an options page load hook and enables the scripts needed for metaboxes
    439446         *
    440          * @since   0.0.1
    441          * @access  public
     447         * @since   0.0.1
     448         * @access  public
    442449         */
    443450        function diy_enqueue_settings_page_scripts() {
     
    450457         * Add a settings link to the plugin list page
    451458         *
    452          * @since   0.0.1
    453          * @param   string  $file       the filename of the plugin currently being rendered on the installed plugins page
    454          * @param   array   $links      an array of the current registered links in html format
    455          * @return  array
    456          * @access  public
     459         * @since   0.0.1
     460         * @param   string  $file       the filename of the plugin currently being rendered on the installed plugins page
     461         * @param   array   $links      an array of the current registered links in html format
     462         * @return  array
     463         * @access  public
    457464         */
    458465        function diy_add_settings_link($links, $file) {
     
    470477         * On the plugin page make sure there are two columns
    471478         *
    472          * @since   0.0.1
    473          * @access  public
     479         * @since   0.0.1
     480         * @access  public
    474481         * @param   int $columns
    475482         * @param   string  $screen
     
    478485        function diy_settings_page_columns($columns, $screen) {
    479486            global $current_screen;
    480        
     487
    481488            if ($screen == $current_screen->id) {
    482489                $columns[$screen] = 2;
     
    489496        * Create the options page form
    490497        *
    491         * @since    0.0.1
    492         * @access   public
     498        * @since    0.0.1
     499        * @access   public
    493500        */
    494501        public function diy_render_options_page() {
     
    498505            if (isset($this->pages[$current_screen->parent_file]) && is_array($this->pages[$current_screen->parent_file][$current_page])) {
    499506                $page = $this->pages[$current_screen->parent_file][$current_page];
    500              
     507
    501508            } else {
    502509                $page = $this->pages[$current_page];
    503              
    504             }
    505            
    506            
     510
     511            }
     512
     513
    507514            // @todo escape
    508515
     
    511518            ?>
    512519            <div class="wrap">
    513                 <?php 
     520                <?php
    514521                // Output a custom settings page icon
    515522                if (!empty($page['#icon'])) {
     
    528535                    <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
    529536                        <div id="side-info-column" class="inner-sidebar">
    530                                 <?php   
    531                              
     537                                <?php
     538
    532539                                do_meta_boxes( $page['#hook'], 'side', $data = array());  ?>
    533540                        </div>
    534541                        <div id="post-body" class="has-sidebar">
    535542                            <div id="post-body-content" class="has-sidebar-content">
    536                                 <?php 
     543                                <?php
    537544                                do_meta_boxes( $page['#hook'], 'normal', $data = array()); ?>
    538545                                <br/>
    539546                                <p>
    540                                     <input type="submit" value="Save Changes" class="button-primary" name="Submit"/>   
     547                                    <input type="submit" value="Save Changes" class="button-primary" name="Submit"/>
    541548                                </p>
    542549                            </div>
    543550                        </div>
    544                         <br class="clear"/>             
    545                     </div> 
     551                        <br class="clear"/>
     552                    </div>
    546553                </form>
    547554            </div>
     
    554561        * Register the admin scripts
    555562        *
    556         * @since    0.0.1
    557         * @access   public
     563        * @since    0.0.1
     564        * @access   public
    558565        */
    559566        function diy_scripts_and_styles() {
     
    566573            // if admin.js exists in the child plugin include it
    567574            if (file_exists($this->diy_path . 'admin.js')) {
    568            
     575
    569576                wp_register_script('diy' ,$this->diy_url . 'admin.js',  array('jquery','jquery-ui-sortable','jquery-ui-sortable','media-upload','thickbox','editor'));
    570577            }
     
    572579            // if admin.css exists in the child plugin include it
    573580            if (file_exists($this->diy_path . 'admin.css')) {
    574                  
     581
    575582                wp_register_style('diy' ,$this->diy_url . 'admin.css');
    576583            }
     
    591598            // only load the google map if we have used one
    592599            wp_register_script('gmap','http://maps.google.com/maps/api/js?sensor=false');
    593            
    594            
     600
     601
    595602            // Add custom scripts and styles to the plugin/theme page only
    596603            add_action('admin_print_scripts-widgets.php', array(&$this, 'diy_admin_scripts'));
    597604            add_action('admin_print_styles-widgets.php', array(&$this,  'diy_admin_styles'));
    598605
    599        
     606
    600607            // Add custom scripts and styles to the post editor pages
    601608            add_action('admin_print_scripts-post.php', array(&$this, 'diy_admin_scripts'));
    602609            add_action('admin_print_scripts-post-new.php',array(&$this,  'diy_admin_scripts'));
    603610            add_action('admin_print_styles-post.php', array(&$this, 'diy_admin_styles'));
    604             add_action('admin_print_styles-post-new.php',array(&$this,  'diy_admin_styles'));   
     611            add_action('admin_print_styles-post-new.php',array(&$this,  'diy_admin_styles'));
    605612
    606613        } // function
     
    609616        * Add custom styles to this plugins options page only
    610617        *
    611         * @since    0.0.1
    612         * @access   public
     618        * @since    0.0.1
     619        * @access   public
    613620        */
    614621        function diy_admin_styles() {
     
    624631            // Allow cropping
    625632            wp_enqueue_script('jcrop');
    626                    
     633
    627634        } // function
    628635
     
    630637        * Add scripts globally to all post.php and post-new.php admin screens
    631638        *
    632         * @since    0.0.1
    633         * @access   public
     639        * @since    0.0.1
     640        * @access   public
    634641        */
    635642        function diy_admin_scripts() {
     
    637644            wp_enqueue_script('diy');
    638645            // Color picker
    639             wp_enqueue_script('farbtastic'); 
     646            wp_enqueue_script('farbtastic');
    640647            // Allow Jquery Chosen
    641648            wp_enqueue_script('suggest');
     
    646653        } // function
    647654
    648      
     655
    649656        /**
    650657        * Ajax callback function to return list of attachments
     
    652659        * @since    0.0.8
    653660        * @access   public
    654         */ 
     661        */
    655662        function diy_save_attachment() {
    656663            // If the upload field has a file in it
     
    668675
    669676                    // Options array for the wp_handle_upload function. 'test_upload' => false
    670                     $upload_overrides = array( 'test_form' => false ); 
     677                    $upload_overrides = array( 'test_form' => false );
    671678
    672679                    // Handle the upload using WP's wp_handle_upload function. Takes the posted file and an options array
     
    731738        } // function
    732739
    733        
     740
    734741        function diy_suggest_attachments() {
    735742            $args = array(
     
    738745                );
    739746
    740            
     747
    741748
    742749                $the_query = new WP_Query($args);
     
    747754                endwhile;
    748755        }
    749        
     756
    750757
    751758        /**
     
    755762        * @access   public
    756763        * @todo    split this out into many functions for each type of suggestion i.e. users by role, attachments by extension
    757         */ 
     764        */
    758765        function diy_suggest_posts_callback() {
    759766            global $wpdb;
    760767
    761768            $group =  $wpdb->escape($_GET['group']);
    762             $field =  $wpdb->escape($_GET['field']);   
     769            $field =  $wpdb->escape($_GET['field']);
    763770            $in =  $wpdb->escape($_GET['q']);
    764771
     
    775782
    776783            $custom_args = $this->forms;
    777            
    778        
    779            
     784
     785
     786
    780787            foreach ($parts as $part) {
    781788                if (!is_numeric($part)) {
    782789                   $custom_args = $custom_args[$part];
    783790                }
    784                
     791
    785792            }
    786793            $custom_args = $custom_args['#wp_query'];
     
    824831        * Modify the query WHERE clause when performing a suggest ajax request
    825832        *
    826         * @since    0.0.2
    827         * @access   public
    828         */ 
     833        * @since    0.0.2
     834        * @access   public
     835        */
    829836        function diy_modify_posts_where( $where, &$wp_query ) {
    830837            global $wpdb;
     
    841848         * @since    0.0.8
    842849         * @access   public
    843          */ 
     850         */
    844851        function diy_modify_posts_where_url( $where, &$wp_query ) {
    845852            global $wpdb;
     
    852859
    853860
    854    
     861
    855862
    856863        /**
    857864         *  Save the post meta box field data
    858865         *
    859          * @since   0.0.1
    860          * @access  public
     866         * @since   0.0.1
     867         * @access  public
    861868         * @param    string  $post_id    The post id we are saving
    862          */ 
     869         */
    863870        function diy_save_post( $post_id ) {
    864871            global $post, $new_meta_boxes;
     
    952959        /**
    953960        * Never actually gets called as render_metabox_fields handles it
    954         */ 
     961        */
    955962        function settings_field_callback($args) { } // end function
    956963
     
    962969              return;
    963970            }
    964             // go through each element recurisvely   
     971            // go through each element recurisvely
    965972            foreach($values as $key => $value) {
    966973                // if it is an array then carry on recursivley
    967                 if (is_array($values[$key])) { 
    968                     self::suggest_fix($values[$key]); 
    969                 } else { 
     974                if (is_array($values[$key])) {
     975                    self::suggest_fix($values[$key]);
     976                } else {
    970977                    // if the [# string is found in the data
    971978                    if (strlen(strstr($values[$key],'[#'))>0) {
    972                         // extract it [# ] 
     979                        // extract it [# ]
    973980                        preg_match('/.*\[#(.*)\]/', $values[$key], $matches);
    974981                        $values[$key] =  $matches[1];
     
    982989                    // if the [* string is found in the data
    983990                    if (strlen(strstr($values[$key],'[*'))>0) {
    984                         // extract it [* ] 
     991                        // extract it [* ]
    985992                        preg_match('/.*\[\*(.*)\]/', $values[$key], $matches);
    986993                        $values[$key] =  $matches[1];
     
    9971004        /**
    9981005        * Save the forms array
    999         * @param array $forms 
     1006        * @param array $forms
    10001007        */
    10011008        function forms($forms) {
     
    10061013        /**
    10071014        * Save the pages array
    1008         * @param array $pages 
     1015        * @param array $pages
    10091016        */
    10101017        function pages($pages) {
Note: See TracChangeset for help on using the changeset viewer.