Plugin Directory

Changeset 2128696


Ignore:
Timestamp:
07/25/2019 08:08:46 PM (7 years ago)
Author:
computercourage
Message:

update to version 1.0.4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • custom-wp-update-message/trunk/custom-wp-update-message.php

    r1227659 r2128696  
    33 * Plugin Name:  Custom WP Update Message
    44 * Description:  This plugin allows you to edit the WordPress update message shown when a new version of WordPress is available.  This plugin is targeted toward web developers who want to provide support to their clients when updates are available.  You can enter your contact information, and a personalized message.  You can also determine which types of users see the message and which do not.
    5  * Version:      1.0.3
     5 * Version:      1.0.4
    66 * Author:       Computer Courage
    77 * Author URI:   http://www.computercourage.com
     
    5050        );
    5151       
    52         foreach($fields as $key => $label) {
    53             add_settings_field(
    54                 'ccmwcu_' . $key,
    55                 $label,
    56                 array( __CLASS__, 'settings_field' ),
    57                 self::$pageslug,
    58                 self::$settingsname,
    59                 array( 'key' => $key ) 
    60             );
     52        if(is_countable($fields) && count($fields)){
     53            foreach($fields as $key => $label) {
     54                add_settings_field(
     55                    'ccmwcu_' . $key,
     56                    $label,
     57                    array( __CLASS__, 'settings_field' ),
     58                    self::$pageslug,
     59                    self::$settingsname,
     60                    array( 'key' => $key ) 
     61                );
     62            }
    6163        }
    6264
     
    7476            if( $key == 'users' ) {
    7577                $user_roles = self::get_user_roles();
    76                 foreach($user_roles as $urkey => $ur) {
    77                     echo "<input type='checkbox' name='" . self::$settingsname . "[" . $key . "][]' value='" . $urkey . "' id='" . self::$settingsname . "_" . $urkey . "'";
    78                     if( is_array($val) && in_array($urkey, $val) ) echo ' checked';
    79                     if( isset($ur['capabilities']['update_core']) ) echo ' checked disabled';
    80                     echo "> <label for='" . self::$settingsname . "_" . $urkey . "'>" . $ur['name'] . "</label><br />";
     78                if(is_countable($user_roles) && count($user_roles)){
     79                    foreach($user_roles as $urkey => $ur) {
     80                        echo "<input type='checkbox' name='" . self::$settingsname . "[" . $key . "][]' value='" . $urkey . "' id='" . self::$settingsname . "_" . $urkey . "'";
     81                        if( is_array($val) && in_array($urkey, $val) ) echo ' checked';
     82                        if( isset($ur['capabilities']['update_core']) ) echo ' checked disabled';
     83                        echo "> <label for='" . self::$settingsname . "_" . $urkey . "'>" . $ur['name'] . "</label><br />";
     84                    }
    8185                }
    8286           
     
    8892   
    8993    public static function validate_field($input) {
    90         foreach($input as $key => $in) {
    91             if( is_array($in) ) {
    92                 $in = array_map( array( __CLASS__, 'clean_input' ), $in );
     94        if(is_countable($input) && count($input)){
     95            foreach($input as $key => $in) {
     96                if( is_array($in) ) {
     97                    $in = array_map( array( __CLASS__, 'clean_input' ), $in );
     98                   
     99                } else {
     100                    $in = self::clean_input($in);
     101                }
    93102               
    94             } else {
    95                 $in = self::clean_input($in);
    96             }
    97            
    98             $input[$key] = $in;
     103                $input[$key] = $in;
     104            }
    99105        }
    100106       
     
    205211        $users = $ccmwcu_options['users'] ? $ccmwcu_options['users'] : '';
    206212        $users = maybe_unserialize($users);
    207         foreach($users as $user_role) {
    208             if( current_user_can($user_role) ) return true;
    209         }   
     213        if(is_countable($users) && count($users)){
     214            foreach($users as $user_role) {
     215                if( current_user_can($user_role) ) return true;
     216            }
     217        }
    210218        return false;
    211219    }
Note: See TracChangeset for help on using the changeset viewer.