Plugin Directory

Changeset 774732


Ignore:
Timestamp:
09/18/2013 03:27:22 PM (12 years ago)
Author:
Bit51
Message:

Various fixes. Now for new .pot

Location:
multi-site-site-list-shortcode/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • multi-site-site-list-shortcode/trunk/inc/admin.php

    r514240 r774732  
    11<?php
    22
    3 if (!class_exists('mssls_admin')) {
     3if ( !class_exists( 'mssls_admin' ) ) {
    44
    55    class mssls_admin extends bit51_mssls {
    6        
     6
    77        /**
    88         * Initialize admin function
     
    1010        function __construct() {
    1111            global $blog_id;
    12            
    13             if ($blog_id == 1) {
    14            
     12
     13            if ( $blog_id == 1 ) {
     14
    1515                //add scripts and css
    16                 add_action('admin_print_scripts', array(&$this, 'config_page_scripts'));
    17                 add_action('admin_print_styles', array(&$this, 'config_page_styles'));
    18            
     16                add_action( 'admin_print_scripts', array( $this, 'config_page_scripts' ) );
     17                add_action( 'admin_print_styles', array( $this, 'config_page_styles' ) );
     18
    1919                //add menu items
    20                 add_action('admin_menu', array(&$this, 'register_settings_page'));
    21            
     20                add_action( 'admin_menu', array( $this, 'register_settings_page' ) );
     21
    2222                //add settings
    23                 add_action('admin_init', array(&$this, 'register_settings'));
    24            
     23                add_action( 'admin_init', array( $this, 'register_settings' ) );
     24
    2525                //add action link
    26                 add_filter('plugin_action_links', array(&$this, 'add_action_link'), 10, 2);
    27            
     26                add_filter( 'plugin_action_links', array( $this, 'add_action_link' ), 10, 2 );
     27
    2828                //add donation reminder
    29                 add_action('admin_init', array(&$this, 'ask'));
    30            
     29                add_action( 'admin_init', array( $this, 'ask' ) );
     30
    3131            }
    3232        }
    33    
     33
    3434        /**
    3535         * Register page settings
    3636         */
    3737        function register_settings_page() {
    38             add_options_page(__($this->pluginname, $this->hook), __($this->pluginname, $this->hook), $this->accesslvl, $this->hook, array(&$this,'mssls_admin_init'));
    39         }   
    40        
     38            add_options_page( __( $this->pluginname, 'multi_site_site_list_shortcode' ), __( $this->pluginname, 'multi_site_site_list_shortcode' ), $this->accesslvl, 'multi_site_site_list_shortcode', array( $this, 'mssls_admin_init' ) );
     39        }
     40
    4141        /**
    4242         * Register admin page main content
     
    4444         */
    4545        function mssls_admin_init() {
    46             $this->admin_page($this->pluginname . ' ' . __('Options', $this->hook),
     46            $this->admin_page( $this->pluginname . ' ' . __( 'Options', 'multi_site_site_list_shortcode' ),
    4747                array(
    48                     array(__('Instructions', $this->hook), 'install_instructions'), //primary admin page content
    49                     array(__('General Options', $this->hook), 'general_options'), //primary admin page content
    50                     array(__('Exclude Sites', $this->hook), 'exclude_options') //choose sites to be excluded from view
     48                    array( __( 'Instructions', 'multi_site_site_list_shortcode' ), 'install_instructions' ), //primary admin page content
     49                    array( __( 'General Options', 'multi_site_site_list_shortcode' ), 'general_options' ), //primary admin page content
     50                    array( __( 'Exclude Sites', 'multi_site_site_list_shortcode' ), 'exclude_options' ) //choose sites to be excluded from view
    5151                )
    5252            );
    5353        }
    54        
     54
    5555        /**
    5656         * Create instructions block
     
    5858        function install_instructions() {
    5959            ?>
    60             <p><?php echo __('Set your options below and then enter the shortcode', $this->hook) . ' <strong><em>[site-list]</em></strong> ' . __('where you would like your site list to appear (you can even enter it in a text widget).', $this->hook); ?></p>
    61             <p><?php echo __('You can overwrite the settings below to make it easier to use the shortcode in multiple locations. Here are the options:', $this->hook); ?></p>
     60            <p><?php echo __( 'Set your options below and then enter the shortcode', 'multi_site_site_list_shortcode' ) . ' <strong><em>[site-list]</em></strong> ' . __( 'where you would like your site list to appear (you can even enter it in a text widget).', 'multi_site_site_list_shortcode' ); ?></p>
     61            <p><?php echo __( 'You can overwrite the settings below to make it easier to use the shortcode in multiple locations. Here are the options:', 'multi_site_site_list_shortcode' ); ?></p>
    6262            <ul>
    63                 <li><?php echo __('sort: alpha for alphabetically (anything else will sort by created date).', $this->hook); ?></li>
    64                 <li><?php echo __('limit: set a new limit (or 0 for no limit).', $this->hook); ?></li>
    65                 <li><?php echo __('newwin: 1 to open links in a new window, 0 to open them in a current window.', $this->hook); ?></li>
    66                 <li><?php echo __('showtag: 1 to show site description (tagline), 0 to hide it.', $this->hook); ?></li>
     63                <li><?php echo __( 'sort: alpha for alphabetically (anything else will sort by created date).', 'multi_site_site_list_shortcode' ); ?></li>
     64                <li><?php echo __( 'limit: set a new limit (or 0 for no limit).', 'multi_site_site_list_shortcode' ); ?></li>
     65                <li><?php echo __( 'newwin: 1 to open links in a new window, 0 to open them in a current window.', 'multi_site_site_list_shortcode' ); ?></li>
     66                <li><?php echo __( 'showtag: 1 to show site description (tagline), 0 to hide it.', 'multi_site_site_list_shortcode' ); ?></li>
    6767            </ul>
    68             <p><?php echo __('example: to sort alphabetically and show site descriptions you can overwrite the default options below using the following tag', $this->hook); ?><br /><em><strong>[site-list sort=alpha showtag=1]</strong></em></p>
    69             <?php
    70         }
    71        
     68            <p><?php echo __( 'example: to sort alphabetically and show site descriptions you can overwrite the default options below using the following tag', 'multi_site_site_list_shortcode' ); ?>
     69                <br/><em><strong>[site-list sort=alpha showtag=1]</strong></em></p>
     70        <?php
     71        }
     72
    7273        /**
    7374         * Create admin page main content
     
    7677            ?>
    7778            <form method="post" action="options.php">
    78             <?php settings_fields('bit51_mssls_options'); //use main settings group ?>
    79             <?php $options = get_option($this->primarysettings); //use settings fields ?>
     79                <?php settings_fields( 'bit51_mssls_options' ); //use main settings group ?>
     80                <?php $options = get_option( $this->primarysettings ); //use settings fields ?>
    8081                <table class="form-table">
    8182                    <tr valign="top">
    8283                        <th scope="row">
    83                             <label for "sortby"><?php _e('Sort By', $this->hook); ?></label>
    84                         </th>
    85                         <td>
    86                             <input name="bit51_mssls[sortby]" id="sortby" value="0" type="radio" <?php checked('0', $options['sortby']); ?> /> <?php _e('Alphabetically', $this->hook); ?><br />
    87                             <input name="bit51_mssls[sortby]" id="sortby" value="1" type="radio" <?php checked('1', $options['sortby']); ?> /> <?php _e('Site Creation Date', $this->hook); ?>
    88                         </td>
    89                     </tr>
    90                     <tr valign="top">
    91                         <th scope="row">
    92                             <label for "showtag"><?php _e('Show Taglines', $this->hook); ?></label>
    93                         </th>
    94                         <td>
    95                             <input name="bit51_mssls[showtag]" id="sortby" value="0" type="radio" <?php checked('0', $options['showtag']); ?> /> <?php _e('No', $this->hook); ?><br />
    96                             <input name="bit51_mssls[showtag]" id="sortby" value="1" type="radio" <?php checked('1', $options['showtag']); ?> /> <?php _e('Yes', $this->hook); ?>
    97                         </td>
    98                     </tr>
    99                     <tr valign="top">
    100                         <th scope="row">
    101                             <label for "openin"><?php _e('Link Target', $this->hook); ?></label>
    102                         </th>
    103                         <td>
    104                             <input name="bit51_mssls[openin]" id="openin" value="0" type="radio" <?php checked('0', $options['openin']); ?> /> <?php _e('Same Window', $this->hook); ?><br />
    105                             <input name="bit51_mssls[openin]" id="openin" value="1" type="radio" <?php checked('1', $options['openin']); ?> /> <?php _e('New Window', $this->hook); ?>
    106                         </td>
    107                     </tr>
    108                     <tr valign="top">
    109                         <th scope="row">
    110                             <label for "limit"><?php _e('Limit Output', $this->hook); ?></label>
    111                         </th>
    112                         <td>
    113                             <input name="bit51_mssls[limit]" id="limit" value="<?php echo $options['limit']; ?>" type="text" /> <br />
    114                             <p><?php _e('Limit the number of sites displayed. This is useful if using the shortcode in a text widget. Set 0 for no limit.', $this->hook); ?></p>
    115                         </td>
    116                     </tr>
    117                     <tr valign="top">
    118                         <th scope="row">
    119                             <label for "openin"><?php _e('Exclude Sites', $this->hook); ?></label>
     84                            <label for "sortby"><?php _e( 'Sort By', 'multi_site_site_list_shortcode' ); ?></label>
     85                        </th>
     86                        <td>
     87                            <input name="bit51_mssls[sortby]" id="sortby" value="0"
     88                                   type="radio" <?php checked( '0', $options['sortby'] ); ?> /> <?php _e( 'Alphabetically', 'multi_site_site_list_shortcode' ); ?>
     89                            <br/>
     90                            <input name="bit51_mssls[sortby]" id="sortby" value="1"
     91                                   type="radio" <?php checked( '1', $options['sortby'] ); ?> /> <?php _e( 'Site Creation Date', 'multi_site_site_list_shortcode' ); ?>
     92                        </td>
     93                    </tr>
     94                    <tr valign="top">
     95                        <th scope="row">
     96                            <label for "showtag"><?php _e( 'Show Taglines', 'multi_site_site_list_shortcode' ); ?></label>
     97                        </th>
     98                        <td>
     99                            <input name="bit51_mssls[showtag]" id="sortby" value="0"
     100                                   type="radio" <?php checked( '0', $options['showtag'] ); ?> /> <?php _e( 'No', 'multi_site_site_list_shortcode' ); ?>
     101                            <br/>
     102                            <input name="bit51_mssls[showtag]" id="sortby" value="1"
     103                                   type="radio" <?php checked( '1', $options['showtag'] ); ?> /> <?php _e( 'Yes', 'multi_site_site_list_shortcode' ); ?>
     104                        </td>
     105                    </tr>
     106                    <tr valign="top">
     107                        <th scope="row">
     108                            <label for "openin"><?php _e( 'Link Target', 'multi_site_site_list_shortcode' ); ?></label>
     109                        </th>
     110                        <td>
     111                            <input name="bit51_mssls[openin]" id="openin" value="0"
     112                                   type="radio" <?php checked( '0', $options['openin'] ); ?> /> <?php _e( 'Same Window', 'multi_site_site_list_shortcode' ); ?>
     113                            <br/>
     114                            <input name="bit51_mssls[openin]" id="openin" value="1"
     115                                   type="radio" <?php checked( '1', $options['openin'] ); ?> /> <?php _e( 'New Window', 'multi_site_site_list_shortcode' ); ?>
     116                        </td>
     117                    </tr>
     118                    <tr valign="top">
     119                        <th scope="row">
     120                            <label for "limit"><?php _e( 'Limit Output', 'multi_site_site_list_shortcode' ); ?></label>
     121                        </th>
     122                        <td>
     123                            <input name="bit51_mssls[limit]" id="limit" value="<?php echo $options['limit']; ?>"
     124                                   type="text"/> <br/>
     125
     126                            <p><?php _e( 'Limit the number of sites displayed. This is useful if using the shortcode in a text widget. Set 0 for no limit.', 'multi_site_site_list_shortcode' ); ?></p>
     127                        </td>
     128                    </tr>
     129                    <tr valign="top">
     130                        <th scope="row">
     131                            <label for "openin"><?php _e( 'Exclude Sites', 'multi_site_site_list_shortcode' ); ?></label>
    120132                        </th>
    121133                        <td>
    122134                            <?php
    123                                 global $wpdb;
    124                                 global $table_prefix;
    125                                 $options = get_option($this->primarysettings);
    126                                
    127                                 //get list of all blogs not marked mature, archived, or spam
    128                                 $blogs = $wpdb->get_col("SELECT blog_id FROM `" . $wpdb->blogs . "` WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' ORDER BY blog_id DESC");
    129                                
    130                                 //make sure there are still blogs left
    131                                 if ($blogs) {
    132                                    
    133                                     foreach ($blogs as $blog) {
    134                                         if ($blog == '1') { //set correct table for primary blog
    135                                             $table =  $wpdb->base_prefix . 'options';
    136                                         } else {
    137                                             $table = $wpdb->base_prefix . $blog . '_options';
    138                                         }
    139                                        
    140                                         if (is_array($options['excluded'])) {//get array of excluded blog id's
    141                                             $excluded = $options['excluded'];
    142                                         } else {
    143                                             $excluded = unserialize($options['excluded']);
    144                                         }
    145                                        
    146                                         if (is_array($excluded) && in_array($blog, $excluded)) { //to check or not to check
    147                                             $checked = "checked";
    148                                         } else {
    149                                             $checked = "";
    150                                         }
    151                                            
    152                                         $sitedetails = $wpdb->get_results('SELECT option_value FROM `' . $table . '` WHERE option_name IN (\'siteurl\',\'blogname\') ORDER BY option_name DESC'); //get site details
    153                                        
    154                                         if($sitedetails) { //as long as blog exists display it with a checkbox
    155                                             echo '<input type="checkbox" ' . $checked . ' name="bit51_mssls[excluded' . $blog . ']" value="' . $blog . '" id="' . $blog . '" /> <a href="' . $sitedetails[0]->option_value . '">' . $sitedetails[1]->option_value . '</a><br />';
    156                                         }
     135                            global $wpdb;
     136                            global $table_prefix;
     137                            $options = get_option( $this->primarysettings );
     138
     139                            //get list of all blogs not marked mature, archived, or spam
     140                            $blogs = $wpdb->get_col( "SELECT blog_id FROM `" . $wpdb->blogs . "` WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' ORDER BY blog_id DESC" );
     141
     142                            //make sure there are still blogs left
     143                            if ( $blogs ) {
     144
     145                                foreach ( $blogs as $blog ) {
     146                                    if ( $blog == '1' ) { //set correct table for primary blog
     147                                        $table = $wpdb->base_prefix . 'options';
     148                                    } else {
     149                                        $table = $wpdb->base_prefix . $blog . '_options';
     150                                    }
     151
     152                                    if ( is_array( $options['excluded'] ) ) { //get array of excluded blog id's
     153                                        $excluded = $options['excluded'];
     154                                    } else {
     155                                        $excluded = unserialize( $options['excluded'] );
     156                                    }
     157
     158                                    if ( is_array( $excluded ) && in_array( $blog, $excluded ) ) { //to check or not to check
     159                                        $checked = "checked";
     160                                    } else {
     161                                        $checked = "";
     162                                    }
     163
     164                                    $sitedetails = $wpdb->get_results( 'SELECT option_value FROM `' . $table . '` WHERE option_name IN (\'siteurl\',\'blogname\') ORDER BY option_name DESC' ); //get site details
     165
     166                                    if ( $sitedetails ) { //as long as blog exists display it with a checkbox
     167                                        echo '<input type="checkbox" ' . $checked . ' name="bit51_mssls[excluded' . $blog . ']" value="' . $blog . '" id="' . $blog . '" /> <a href="' . $sitedetails[0]->option_value . '">' . $sitedetails[1]->option_value . '</a><br />';
    157168                                    }
    158169                                }
     170                            }
    159171                            ?>
    160                             <p><?php _e('Put a checkmark below next to the sites you would like to remove from your site list.', &$this->hook); ?></p>
     172                            <p><?php _e( 'Put a checkmark below next to the sites you would like to remove from your site list.', 'multi_site_site_list_shortcode' ); ?></p>
    161173                        </td>
    162174                    </tr>
    163175                </table>
    164                 <p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
     176                <p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ) ?>"/>
     177                </p>
    165178            </form>
    166             <?php
    167         }
    168        
     179        <?php
     180        }
     181
    169182        /**
    170183         * Validate input
    171184         */
    172         function mssls_val_options($input) {
     185        function mssls_val_options( $input ) {
    173186            $exclude = array(); //create exclude array
    174            
     187
    175188            //if we're dealing with one of the exclude fields add the value to the exclude array
    176             foreach ($input as $field => $value) {
    177                 if ($field != 'sortby' && $field != 'openin' && $field != 'showtag' && $field != 'limit') {
    178                     unset($input[$field]);
    179                     $exclude[] = $value;
    180                 }
    181             }
    182            
    183             $input['excluded'] = serialize($exclude); //convert array to string and add to $input
    184            
    185             //process non-exclude fields
    186             $input['sortby'] = ($input['sortby'] == 1 ? 1 : 0);
    187             $input['openin'] = ($input['openin'] == 1 ? 1 : 0);
    188             $input['showtag'] = ($input['showtag'] == 1 ? 1 : 0);
    189             $input['limit'] = intval($input['limit']);
    190            
    191             return $input;
     189            foreach ( $input as $field => $value ) {
     190                if ( $field != 'sortby' && $field != 'openin' && $field != 'showtag' && $field != 'limit' ) {
     191                    unset( $input[$field] );
     192                    $exclude[] = $value;
     193                }
     194            }
     195
     196            $input['excluded'] = serialize( $exclude ); //convert array to string and add to $input
     197
     198            //process non-exclude fields
     199            $input['sortby'] = ( $input['sortby'] == 1 ? 1 : 0 );
     200            $input['openin'] = ( $input['openin'] == 1 ? 1 : 0 );
     201            $input['showtag'] = ( $input['showtag'] == 1 ? 1 : 0 );
     202            $input['limit'] = intval( $input['limit'] );
     203
     204            return $input;
    192205        }
    193206    }
  • multi-site-site-list-shortcode/trunk/inc/setup.php

    r500734 r774732  
    11<?php
    22
    3 if (!class_exists('mssls_setup')) {
     3if ( !class_exists( 'mssls_setup' ) ) {
    44
    55    class mssls_setup extends bit51_mssls {
     
    88         * Verify case is set correctly and continue or die
    99         */
    10         function __construct($case = false) {
    11    
    12             if (!$case) {
    13                 die('error');
     10        function __construct( $case = false ) {
     11
     12            if ( !$case ) {
     13                die( 'error' );
    1414            }
    1515
    16             switch($case) {
     16            switch ( $case ) {
    1717                case 'activate': //active plugin
    1818                    $this->activate_execute();
     
    3333         */
    3434        function on_activate() {
    35             new mssls_setup('activate');
     35            new mssls_setup( 'activate' );
    3636        }
    3737
     
    4040         */
    4141        function on_deactivate() {
    42    
     42
    4343            $devel = false; //set to true to uninstall for development
    44        
    45             if ($devel) {
     44
     45            if ( $devel ) {
    4646                $case = 'uninstall';
    4747            } else {
     
    4949            }
    5050
    51             new mssls_setup($case);
     51            new mssls_setup( $case );
    5252        }
    5353
     
    5656         */
    5757        function on_uninstall() {
    58             if ( __FILE__ != WP_UNINSTALL_PLUGIN) { //verify they actually clicked uninstall
     58            if ( __FILE__ != WP_UNINSTALL_PLUGIN ) { //verify they actually clicked uninstall
    5959                return;
    6060            }
    6161
    62             new mssls_setup('uninstall');
     62            new mssls_setup( 'uninstall' );
    6363        }
    6464
     
    6868        function activate_execute() {
    6969            $this->default_settings(); //verify and set default options
    70            
    71             $options = get_option($this->plugindata);
    72            
     70
     71            $options = get_option( $this->plugindata );
     72
    7373            //update if version numbers don't match
    74             if (isset($options['version']) && $options['version'] != $this->pluginversion) {
     74            if ( isset( $options['version'] ) && $options['version'] != $this->pluginversion ) {
    7575                $this->update_execute();
    7676            }
    77            
     77
    7878            $options['version'] = $this->pluginversion; //set new version number
    79            
     79
    8080            //remove no support nag if it's been more than six months
    81             if (!isset($options['activatestamp']) || $options['activatestamp'] < (time() - 15552000)) {
    82                 if (isset($options['no-nag'])) {
    83                     unset($options['no-nag']);
     81            if ( !isset( $options['activatestamp'] ) || $options['activatestamp'] < ( time() - 15552000 ) ) {
     82                if ( isset( $options['no-nag'] ) ) {
     83                    unset( $options['no-nag'] );
    8484                }
    85                
     85
    8686                //set activate timestamp to today (they'll be notified again in a month)
    8787                $options['activatestamp'] = time();
    8888            }
    89            
    90             update_option($this->plugindata, $options); //save new plugin data
     89
     90            update_option( $this->plugindata, $options ); //save new plugin data
    9191        }
    92        
     92
    9393        /**
    9494         * Execute update functions
     
    107107         */
    108108        function uninstall_execute() {
    109        
     109
    110110            //remove all settings
    111             foreach($this->settings as $settings) {
    112                 foreach ($settings as $setting => $option) {
    113                     delete_option($setting);
     111            foreach ( $this->settings as $settings ) {
     112                foreach ( $settings as $setting => $option ) {
     113                    delete_option( $setting );
    114114                }
    115115            }
    116            
     116
    117117            //delete plugin information (version, etc)
    118             delete_option($this->plugindata);
     118            delete_option( $this->plugindata );
    119119        }
    120120    }
  • multi-site-site-list-shortcode/trunk/lib/bit51/bit51.php

    r700792 r774732  
    77 */
    88
    9 if ( ! class_exists( 'Bit51' ) ) {
     9if ( !class_exists( 'Bit51' ) ) {
    1010
    1111    abstract class Bit51 {
    12    
     12
    1313        var $feed = 'http://bit51.com/feed'; //current address of Bit51.com feed
    14    
     14
    1515        /**
    1616         * Register admin javascripts (only for plugin admin page)
     
    1818         **/
    1919        function config_page_scripts() {
    20        
     20
    2121            //make sure we're on the appropriate page
    22             if ( isset( $_GET['page'] ) && strpos( $_GET['page'], $this->hook ) !== false ) {
    23            
     22            if ( isset( $_GET['page'] ) && strpos( $_GET['page'], 'multi_site_site_list_shortcode' ) !== false ) {
     23
    2424                wp_enqueue_script( 'postbox' );
    2525                wp_enqueue_script( 'dashboard' );
    2626                wp_enqueue_script( 'thickbox' );
    2727                wp_enqueue_script( 'media-upload' );
    28                
    29             }
    30            
    31         }
    32        
     28
     29            }
     30
     31        }
     32
    3333        /**
    3434         * Register admin css styles (only for plugin admin page)
     
    3636         **/
    3737        function config_page_styles() {
    38        
     38
    3939            //make sure we're on the appropriate page
    40             if ( isset( $_GET['page'] ) && strpos( $_GET['page'], $this->hook ) !== false ) {
    41            
     40            if ( isset( $_GET['page'] ) && strpos( $_GET['page'], 'multi_site_site_list_shortcode' ) !== false ) {
     41
    4242                wp_enqueue_style( 'dashboard' );
    4343                wp_enqueue_style( 'thickbox' );
    4444                wp_enqueue_style( 'global' );
    4545                wp_enqueue_style( 'wp-admin' );
    46                 wp_enqueue_style( 'bit51-css', plugin_dir_url( $this->pluginbase, __FILE__ ). 'lib/bit51/bit51.css' );
    47                
    48             }
    49            
    50         }
    51        
     46                wp_enqueue_style( 'bit51-css', plugin_dir_url( $this->pluginbase, __FILE__ ) . 'lib/bit51/bit51.css' );
     47
     48            }
     49
     50        }
     51
    5252        /**
    5353         * Register all settings groups
     
    5757         **/
    5858        function register_settings() {
    59            
     59
    6060            foreach ( $this->settings as $group => $settings ) { //look at each main group
    61            
     61
    6262                foreach ( $settings as $setting => $option ) { //look at each option set
    63                
     63
    6464                    if ( isset( $option['callback'] ) ) { //if callback is defined register with callback
    65                    
     65
    6666                        register_setting( $group, $setting, array( $this, $option['callback'] ) );
    67                        
     67
    6868                    } else { //register without callback
    69                    
     69
    7070                        register_setting( $group, $setting );
    71                        
    72                     }
    73                    
    74                 }
    75                
    76             }
    77            
    78         }
    79        
     71
     72                    }
     73
     74                }
     75
     76            }
     77
     78        }
     79
    8080        /**
    8181         * Add action link to plugin page
    82          * 
     82         *
    8383         * Adds plugin settings link to plugin page in WordPress admin area.
    8484         *
     
    9090        function add_action_link( $links, $file ) {
    9191            static $this_plugin;
    92            
     92
    9393            if ( empty( $this_plugin ) ) {
    9494                $this_plugin = $this->pluginbase;
    9595            }
    96            
     96
    9797            if ( $file == $this_plugin ) {
    98                 $settings_link = '<a href="' . $this->plugin_options_url() . '">' . __( 'Settings', $this->hook ) . '</a>';
     98                $settings_link = '<a href="' . $this->plugin_options_url() . '">' . __( 'Settings', 'multi_site_site_list_shortcode' ) . '</a>';
    9999                array_unshift( $links, $settings_link );
    100100            }
    101            
     101
    102102            return $links;
    103103        }
    104        
     104
    105105        /**
    106106         * Return URL of options page
     
    110110         **/
    111111        function plugin_options_url() {
    112        
    113             return admin_url('options-general.php?page=' . $this->hook);
    114            
    115         }
    116        
     112
     113            return admin_url( 'options-general.php?page=' . 'multi_site_site_list_shortcode' );
     114
     115        }
     116
    117117        /**
    118118         * Setup and call admin messages
     
    124124         **/
    125125        function showmessages( $errors ) {
    126            
     126
    127127            global $savemessages; //use global to transfer to add_action callback
    128            
     128
    129129            $savemessages = ''; //initialize so we can get multiple error messages (if needed)
    130            
    131             if ( function_exists( 'apc_store' ) ) { 
     130
     131            if ( function_exists( 'apc_store' ) ) {
    132132                apc_clear_cache(); //Let's clear APC (if it exists) when big stuff is saved.
    133133            }
    134            
     134
    135135            if ( is_wp_error( $errors ) ) { //see if object is even an error
    136            
     136
    137137                $errors = $errors->get_error_messages(); //get all errors if it is
    138                
     138
    139139                foreach ( $errors as $error => $string ) {
    140140                    $savemessages .= '<div id="message" class="error"><p>' . $string . '</p></div>';
    141141                }
    142                            
     142
    143143            } else { //no errors so display settings saved message
    144            
     144
    145145                $savemessages .= '<div id="message" class="updated"><p><strong>' . $errors . '</strong></p></div>';
    146                
    147             }
    148            
     146
     147            }
     148
    149149            //register appropriate message actions
    150             add_action('admin_notices', array(&$this, 'dispmessage'));
    151             add_action('network_admin_notices', array(&$this, 'dispmessage'));
    152            
    153         }
    154        
     150            add_action( 'admin_notices', array( $this, 'dispmessage' ) );
     151            add_action( 'network_admin_notices', array( $this, 'dispmessage' ) );
     152
     153        }
     154
    155155        /**
    156156         * Set all default settings
     
    160160         **/
    161161        function default_settings() {
    162        
     162
    163163            foreach ( $this->settings as $settings ) {
    164            
     164
    165165                foreach ( $settings as $setting => $defaults ) {
    166                
     166
    167167                    $options = get_option( $setting ); //Get the option if it already exists
    168                    
     168
    169169                    //set missing options
    170170                    foreach ( $defaults as $option => $value ) {
    171                    
     171
    172172                        if ( $option != 'callback' && !isset( $options[$option] ) ) {
    173173                            $options[$option] = $value;
    174174                        }
    175                        
    176                     }
    177                    
     175
     176                    }
     177
    178178                    //remove obsolete options
    179179                    foreach ( $options as $option => $value ) {
    180                    
    181                         if ( ! isset( $defaults[$option] ) && $option != 'version' ) {
    182                             unset( $options[$option] ); 
     180
     181                        if ( !isset( $defaults[$option] ) && $option != 'version' ) {
     182                            unset( $options[$option] );
    183183                        }
    184                        
    185                     }
    186                    
     184
     185                    }
     186
    187187                    update_option( $setting, $options ); //save new options
    188188                }
    189                
    190             }
    191            
     189
     190            }
     191
    192192            return $options;
    193            
    194         }
    195        
     193
     194        }
     195
    196196        /**
    197197         * Echos admin messages
    198          * 
     198         *
    199199         * Takes care of echoing admin message when appropriate action is called
    200200         *
    201201         **/
    202202        function dispmessage() {
    203        
     203
    204204            global $savemessages;
    205            
     205
    206206            echo $savemessages;
    207            
    208             unset($savemessages); //delete any saved messages
    209            
    210         }
    211        
     207
     208            unset( $savemessages ); //delete any saved messages
     209
     210        }
     211
    212212        /**
    213213         * Setup postbox
     
    222222            ?>
    223223            <div id="<?php echo $id; ?>" class="postbox">
    224                 <div class="handlediv" title="Click to toggle"><br /></div>
     224                <div class="handlediv" title="Click to toggle"><br/></div>
    225225                <h3 class="hndle"><span><?php echo $title; ?></span></h3>
     226
    226227                <div class="inside">
    227                     <?php 
    228                         //execute content if it's a function or just echo it
    229                         if ( ! strstr( $content, ' ' ) && method_exists( $this, $content ) ) {
    230                        
    231                             $this->$content();
    232                            
    233                         } else {
    234                        
    235                             echo $content;
    236                            
    237                         }
     228                    <?php
     229                    //execute content if it's a function or just echo it
     230                    if ( !strstr( $content, ' ' ) && method_exists( $this, $content ) ) {
     231
     232                        $this->$content();
     233
     234                    } else {
     235
     236                        echo $content;
     237
     238                    }
    238239                    ?>
    239240                </div>
    240241            </div>
    241             <?php
     242        <?php
    242243        }
    243244
     
    249250            echo '<div id="icon-themes" class="icon32"><br></div>';
    250251            echo '<h2 class="nav-tab-wrapper">';
    251             foreach( $tabs as $location => $tabname ){
     252            foreach ( $tabs as $location => $tabname ) {
    252253                if ( is_array( $tabname ) ) {
    253254                    $class = ( $location == $current ) ? ' nav-tab-active' : '';
    254                     echo '<a class="nav-tab' . $class. '" href="?page=' . $tabname[1] . '&tab='. $location . '">' . $tabname[0] . '</a>';
     255                    echo '<a class="nav-tab' . $class . '" href="?page=' . $tabname[1] . '&tab=' . $location . '">' . $tabname[0] . '</a>';
    255256                } else {
    256257                    $class = ( $location == $current ) ? ' nav-tab-active' : '';
    257                     echo '<a class="nav-tab' . $class. '" href="?page=' . $location . '">' . $tabname . '</a>';
     258                    echo '<a class="nav-tab' . $class . '" href="?page=' . $location . '">' . $tabname . '</a>';
    258259                }
    259260            }
    260261            echo '</h2>';
    261262        }
    262        
     263
    263264        /**
    264265         * Setup main admin page box
     
    280281
    281282            ?>
    282                 <div class="wrap">
    283                     <?php if ( $icon == '' ) { ?>
    284                         <a href="http://bit51.com/"><div id="bit51-icon" style="background: url(<?php echo plugin_dir_url( $this->pluginbase, __FILE__ ); ?>lib/bit51/images/bit51.png) no-repeat;" class="icon32"><br /></div></a>
    285                     <?php } else { ?>
    286                         <a href="http://bit51.com/"><div id="bit51-icon" style="background: url(<?php echo $icon; ?>) no-repeat;" class="icon32"><br /></div></a>
    287                     <?php } ?>
    288                     <h2><?php _e( $title, $this->hook ) ?></h2>
    289                     <?php
    290                         if ( $tabs != NULL ) {
    291                             if ( isset ( $_GET['tab'] ) ) {
    292                                 $this->admin_tabs( $tabs, filter_var( $_GET['tab'], FILTER_SANITIZE_STRING ), false );
    293                             } elseif( isset( $_GET['page'] ) ) {
    294                                 $this->admin_tabs( $tabs, filter_var( $_GET['page'], FILTER_SANITIZE_STRING ) );
    295                             } else {
    296                                 $this->admin_tabs( $tabs );
     283            <div class="wrap">
     284                <?php if ( $icon == '' ) { ?>
     285                    <a href="http://bit51.com/">
     286                        <div id="bit51-icon"
     287                             style="background: url(<?php echo plugin_dir_url( $this->pluginbase, __FILE__ ); ?>lib/bit51/images/bit51.png) no-repeat;"
     288                             class="icon32"><br/></div>
     289                    </a>
     290                <?php } else { ?>
     291                    <a href="http://bit51.com/">
     292                        <div id="bit51-icon" style="background: url(<?php echo $icon; ?>) no-repeat;" class="icon32">
     293                            <br/></div>
     294                    </a>
     295                <?php } ?>
     296                <h2><?php _e( $title, 'multi_site_site_list_shortcode' ) ?></h2>
     297                <?php
     298                if ( $tabs != NULL ) {
     299                    if ( isset ( $_GET['tab'] ) ) {
     300                        $this->admin_tabs( $tabs, filter_var( $_GET['tab'], FILTER_SANITIZE_STRING ), false );
     301                    } elseif ( isset( $_GET['page'] ) ) {
     302                        $this->admin_tabs( $tabs, filter_var( $_GET['page'], FILTER_SANITIZE_STRING ) );
     303                    } else {
     304                        $this->admin_tabs( $tabs );
     305                    }
     306                }
     307                ?>
     308                <div class="postbox-container" style="width:65%;">
     309                    <div class="metabox-holder">
     310                        <div class="meta-box-sortables">
     311                            <?php
     312                            foreach ( $boxes as $content ) {
     313                                $this->postbox( 'adminform', $content[0], $content[1] );
    297314                            }
    298                         }
    299                     ?>
    300                     <div class="postbox-container" style="width:65%;">
    301                         <div class="metabox-holder">   
    302                             <div class="meta-box-sortables">
    303                                 <?php
    304                                     foreach ( $boxes as $content ) {
    305                                         $this->postbox( 'adminform', $content[0], $content[1] );
    306                                     }
    307                                 ?>
    308                             </div>
    309                         </div>
    310                     </div>
    311                     <div class="postbox-container side" style="width:20%;">
    312                         <div class="metabox-holder">   
    313                             <div class="meta-box-sortables">
    314                                 <?php
    315                                     $this->donate();
    316                                     $this->support();
    317                                     $this->news();
    318                                     $this->social();
    319                                 ?>
    320                             </div>
     315                            ?>
    321316                        </div>
    322317                    </div>
    323318                </div>
    324             <?php
    325         }
    326        
     319                <div class="postbox-container side" style="width:20%;">
     320                    <div class="metabox-holder">
     321                        <div class="meta-box-sortables">
     322                            <?php
     323                            $this->donate();
     324                            $this->support();
     325                            $this->news();
     326                            $this->social();
     327                            ?>
     328                        </div>
     329                    </div>
     330                </div>
     331            </div>
     332        <?php
     333        }
     334
    327335        /**
    328336         * Display tech support information
     
    332340         **/
    333341        function support() {
    334        
    335             $content = __('If you need help getting this plugin or have found a bug please visit the <a href="' . $this->supportpage . '" target="_blank">support forums</a>.', $this->hook);
    336            
    337             $this->postbox( 'bit51support', __( 'Need Help?', $this->hook ), $content ); //execute as postbox
    338            
    339         }
    340        
     342
     343            $content = __( 'If you need help getting this plugin or have found a bug please visit the <a href="' . $this->supportpage . '" target="_blank">support forums</a>.', 'multi_site_site_list_shortcode' );
     344
     345            $this->postbox( 'bit51support', __( 'Need Help?', 'multi_site_site_list_shortcode' ), $content ); //execute as postbox
     346
     347        }
     348
    341349        /**
    342350         * Display Bit51's latest posts
     
    346354         **/
    347355        function news() {
    348        
     356
    349357            include_once( ABSPATH . WPINC . '/feed.php' ); //load WordPress feed info
    350            
     358
    351359            $feed = fetch_feed( $this->feed ); //get the feed
    352360
    353             if ( ! isset( $feed->errors ) ) {
     361            if ( !isset( $feed->errors ) ) {
    354362
    355363                $feeditems = $feed->get_items( 0, $feed->get_item_quantity( 5 ) ); //narrow feed to last 5 items
    356            
     364
    357365                $content = '<ul>'; //start list
    358            
    359                 if ( ! $feeditems ) {
    360            
    361                     $content .= '<li class="bit51">' . __( 'No news items, feed might be broken...', $this->hook ) . '</li>';
    362                
     366
     367                if ( !$feeditems ) {
     368
     369                    $content .= '<li class="bit51">' . __( 'No news items, feed might be broken...', 'multi_site_site_list_shortcode' ) . '</li>';
     370
    363371                } else {
    364            
     372
    365373                    foreach ( $feeditems as $item ) {
    366                        
     374
    367375                        $url = preg_replace( '/#.*/', '', esc_url( $item->get_permalink(), $protocolls = null, 'display' ) );
    368                        
    369                         $content .= '<li class="bit51"><a class="rsswidget" href="' . $url . '" target="_blank">'. esc_html( $item->get_title() ) .'</a></li>';
    370                        
    371                     }
    372                    
    373                 }   
    374                                    
     376
     377                        $content .= '<li class="bit51"><a class="rsswidget" href="' . $url . '" target="_blank">' . esc_html( $item->get_title() ) . '</a></li>';
     378
     379                    }
     380
     381                }
     382
    375383                $content .= '</ul>'; //end list
    376384
    377385            } else {
    378                 $content = __( 'It appears as if the feed is currently down. Please try again later', $this->hook );
    379             }
    380            
    381             $this->postbox( 'bit51posts' , __( 'The Latest from Bit51', $this->hook ), $content ); //set up postbox
    382            
    383         }
    384        
     386                $content = __( 'It appears as if the feed is currently down. Please try again later', 'multi_site_site_list_shortcode' );
     387            }
     388
     389            $this->postbox( 'bit51posts', __( 'The Latest from Bit51', 'multi_site_site_list_shortcode' ), $content ); //set up postbox
     390
     391        }
     392
    385393        /**
    386394         * Display donate box
     
    390398         **/
    391399        function donate() {
    392        
    393             $content = __( 'Have you found this plugin useful? Please help support it\'s continued development with a donation of $20, $50, or even $100.', $this->hook );
    394            
     400
     401            $content = __( 'Have you found this plugin useful? Please help support it\'s continued development with a donation of $20, $50, or even $100.', 'multi_site_site_list_shortcode' );
     402
    395403            $content .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="' . $this->paypalcode . '"><input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"></form>';
    396            
    397             $content .= '<p>' . __( 'Short on funds?', $this->hook ) . '</p>';
    398            
     404
     405            $content .= '<p>' . __( 'Short on funds?', 'multi_site_site_list_shortcode' ) . '</p>';
     406
    399407            $content .= '<ul>';
    400            
    401             $content .= '<li><a href="' . $this->wppage . '" target="_blank">' . __( 'Rate', $this->hook ) . ' ' . $this->pluginname . __( ' 5★\'s on WordPress.org', $this->hook ) . '</a></li>';
    402            
    403             $content .= '<li>' . __( 'Talk about it on your site and link back to the ', $this->hook ) . '<a href="' . $this->homepage . '" target="_blank">' . __( 'plugin page.', $this->hook ) . '</a></li>';
    404            
    405             $content .= '<li><a href="http://twitter.com/home?status=' . urlencode( 'I use ' . $this->pluginname . ' for WordPress by @bit51 and you should too - ' . $this->homepage ) . '" target="_blank">' . __( 'Tweet about it. ', $this->hook ) . '</a></li>';
    406            
     408
     409            $content .= '<li><a href="' . $this->wppage . '" target="_blank">' . __( 'Rate', 'multi_site_site_list_shortcode' ) . ' ' . $this->pluginname . __( ' 5★\'s on WordPress.org', 'multi_site_site_list_shortcode' ) . '</a></li>';
     410
     411            $content .= '<li>' . __( 'Talk about it on your site and link back to the ', 'multi_site_site_list_shortcode' ) . '<a href="' . $this->homepage . '" target="_blank">' . __( 'plugin page.', 'multi_site_site_list_shortcode' ) . '</a></li>';
     412
     413            $content .= '<li><a href="http://twitter.com/home?status=' . urlencode( 'I use ' . $this->pluginname . ' for WordPress by @bit51 and you should too - ' . $this->homepage ) . '" target="_blank">' . __( 'Tweet about it. ', 'multi_site_site_list_shortcode' ) . '</a></li>';
     414
    407415            $content .= '</ul>';
    408            
    409             $this->postbox( 'donate', __( 'Support This Plugin' , $this->hook ), $content ); //setup the postbox
    410            
    411         }
    412        
     416
     417            $this->postbox( 'donate', __( 'Support This Plugin', 'multi_site_site_list_shortcode' ), $content ); //setup the postbox
     418
     419        }
     420
    413421        /**
    414422         * Display social links
     
    418426         **/
    419427        function social() {
    420        
     428
    421429            $content = '<ul>';
    422            
    423             $content .= '<li class="facebook"><a href="https://www.facebook.com/bit51" target="_blank">' . __( 'Like Bit51 on Facebook', $this->hook ) . '</a></li>';
    424            
    425             $content .= '<li class="twitter"><a href="http://twitter.com/Bit51" target="_blank">' . __( 'Follow Bit51 on Twitter', $this->hook ) . '</a></li>';
    426            
    427             $content .= '<li class="google"><a href="https://plus.google.com/104513012839087985497" target="_blank">' . __( 'Circle Bit51 on Google+', $this->hook ) . '</a></li>';
    428            
    429             $content .= '<li class="subscribe"><a href="http://bit51.com/subscribe" target="_blank">' . __( 'Subscribe with RSS or Email', $this->hook ) . '</a></li>';
    430            
     430
     431            $content .= '<li class="facebook"><a href="https://www.facebook.com/bit51" target="_blank">' . __( 'Like Bit51 on Facebook', 'multi_site_site_list_shortcode' ) . '</a></li>';
     432
     433            $content .= '<li class="twitter"><a href="http://twitter.com/Bit51" target="_blank">' . __( 'Follow Bit51 on Twitter', 'multi_site_site_list_shortcode' ) . '</a></li>';
     434
     435            $content .= '<li class="google"><a href="https://plus.google.com/104513012839087985497" target="_blank">' . __( 'Circle Bit51 on Google+', 'multi_site_site_list_shortcode' ) . '</a></li>';
     436
     437            $content .= '<li class="subscribe"><a href="http://bit51.com/subscribe" target="_blank">' . __( 'Subscribe with RSS or Email', 'multi_site_site_list_shortcode' ) . '</a></li>';
     438
    431439            $content .= '</ul>';
    432            
    433             $this->postbox( 'bit51social', __( 'Bit51 on the Web', $this->hook ), $content ); //setup the postbox
    434            
    435         }
    436        
     440
     441            $this->postbox( 'bit51social', __( 'Bit51 on the Web', 'multi_site_site_list_shortcode' ), $content ); //setup the postbox
     442
     443        }
     444
    437445        /**
    438446         * Display (and hide) donation reminder
     
    442450         **/
    443451        function ask() {
    444        
     452
    445453            global $blog_id; //get the current blog id
    446            
    447             if ( is_multisite() && ( $blog_id != 1 || ! current_user_can( 'manage_network_options' ) ) ) { //only display to network admin if in multisite
     454
     455            if ( is_multisite() && ( $blog_id != 1 || !current_user_can( 'manage_network_options' ) ) ) { //only display to network admin if in multisite
    448456                return;
    449457            }
    450            
     458
    451459            $options = get_option( $this->plugindata );
    452            
     460
    453461            //this is called at a strange point in WP so we need to bring in some data
    454462            global $plugname;
     
    458466            $plughook = $this->hook;
    459467            $plugopts = $this->plugin_options_url();
    460            
     468
    461469            //display the notifcation if they haven't turned it off and they've been using the plugin at least 30 days
    462             if ( ! isset( $options['no-nag'] ) && $options['activatestamp'] < ( current_time( 'timestamp' ) - 2952000 ) ) {
    463            
    464                 if ( ! function_exists( 'bit51_plugin_donate_notice' ) ) {
    465            
    466                     function bit51_plugin_donate_notice(){
    467                
     470            if ( !isset( $options['no-nag'] ) && $options['activatestamp'] < ( current_time( 'timestamp' ) - 2952000 ) ) {
     471
     472                if ( !function_exists( 'bit51_plugin_donate_notice' ) ) {
     473
     474                    function bit51_plugin_donate_notice() {
     475
    468476                        global $plugname;
    469477                        global $plughook;
    470478                        global $plugopts;
    471                    
    472                         echo '<div class="updated">
    473                        <p>' . __( 'It looks like you\'ve been enjoying', $plughook ) . ' ' . $plugname . ' ' . __( 'for at least 30 days. Would you consider a small donation to help support continued development of the plugin?', $plughook ) . '</p> <p><input type="button" class="button " value="' . __( 'Support This Plugin', $plughook ) . '" onclick="document.location.href=\'?bit51_lets_donate=yes&_wpnonce=' .  wp_create_nonce('bit51-nag') . '\';">  <input type="button" class="button " value="' . __('Rate it 5★\'s', $plughook) . '" onclick="document.location.href=\'?bit51_lets_rate=yes&_wpnonce=' .  wp_create_nonce( 'bit51-nag' ) . '\';">  <input type="button" class="button " value="' . __( 'Tell Your Followers', $plughook ) . '" onclick="document.location.href=\'?bit51_lets_tweet=yes&_wpnonce=' .  wp_create_nonce( 'bit51-nag' ) . '\';">  <input type="button" class="button " value="' . __( 'Don\'t Bug Me Again', $plughook ) . '" onclick="document.location.href=\'?bit51_donate_nag=off&_wpnonce=' . wp_create_nonce( 'bit51-nag' ) . '\';"></p>
     479
     480                        echo '<div class="updated">
     481                       <p>' . __( 'It looks like you\'ve been enjoying', $plughook ) . ' ' . $plugname . ' ' . __( 'for at least 30 days. Would you consider a small donation to help support continued development of the plugin?', $plughook ) . '</p> <p><input type="button" class="button " value="' . __( 'Support This Plugin', $plughook ) . '" onclick="document.location.href=\'?bit51_lets_donate=yes&_wpnonce=' . wp_create_nonce( 'bit51-nag' ) . '\';">  <input type="button" class="button " value="' . __( 'Rate it 5★\'s', $plughook ) . '" onclick="document.location.href=\'?bit51_lets_rate=yes&_wpnonce=' . wp_create_nonce( 'bit51-nag' ) . '\';">  <input type="button" class="button " value="' . __( 'Tell Your Followers', $plughook ) . '" onclick="document.location.href=\'?bit51_lets_tweet=yes&_wpnonce=' . wp_create_nonce( 'bit51-nag' ) . '\';">  <input type="button" class="button " value="' . __( 'Don\'t Bug Me Again', $plughook ) . '" onclick="document.location.href=\'?bit51_donate_nag=off&_wpnonce=' . wp_create_nonce( 'bit51-nag' ) . '\';"></p>
    474482                        </div>';
    475                    
    476                     }
    477                
    478                 }
    479                
     483
     484                    }
     485
     486                }
     487
    480488                add_action( 'admin_notices', 'bit51_plugin_donate_notice' ); //register notification
    481                
    482             }
    483            
     489
     490            }
     491
    484492            //if they've clicked a button hide the notice
    485493            if ( ( isset( $_GET['bit51_donate_nag'] ) || isset( $_GET['bit51_lets_rate'] ) || isset( $_GET['bit51_lets_tweet'] ) || isset( $_GET['bit51_lets_donate'] ) ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'bit51-nag' ) ) {
    486            
     494
    487495                $options = get_option( $this->plugindata );
    488496                $options['no-nag'] = 1;
    489                 update_option( $this->plugindata,$options );
     497                update_option( $this->plugindata, $options );
    490498                remove_action( 'admin_notices', 'bit51_plugin_donate_notice' );
    491                
     499
    492500                //take the user to paypal if they've clicked donate
    493501                if ( isset( $_GET['bit51_lets_donate'] ) ) {
    494502                    wp_redirect( 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=' . $this->paypalcode, '302' );
    495503                }
    496                
     504
    497505                //Go to the WordPress page to let them rate it.
    498506                if ( isset( $_GET['bit51_lets_rate'] ) ) {
    499507                    wp_redirect( $this->wppage, '302' );
    500508                }
    501                
     509
    502510                //Compose a Tweet
    503511                if ( isset( $_GET['bit51_lets_tweet'] ) ) {
    504                     wp_redirect( 'http://twitter.com/home?status=' . urlencode( 'I use ' . $this->pluginname . ' for WordPress by @bit51 and you should too - ' . $this->homepage ) , '302' );
    505                 }
    506                
    507             }
    508            
    509         }
    510        
     512                    wp_redirect( 'http://twitter.com/home?status=' . urlencode( 'I use ' . $this->pluginname . ' for WordPress by @bit51 and you should too - ' . $this->homepage ), '302' );
     513                }
     514
     515            }
     516
     517        }
     518
    511519    }
    512    
     520
    513521}
  • multi-site-site-list-shortcode/trunk/multi-site-site-list-shortcode.php

    r700792 r774732  
    44    Plugin URI: http://bit51.com/software/multi-site-site-list-shortcode/
    55    Description: Displays the site list with a shortcode for network installations.
    6     Version: 5.4.1
     6    Version: Dev
    77    Domain Path: /languages
    88    Author: Bit51
    99    Author URI: http://bit51.com
    1010    License: GPLv2
    11     Copyright 2012  Bit51.com  (email : [email protected])
     11    Copyright 2013  Bit51  (email : [email protected])
    1212*/
    1313
    1414//load the text domain
    15 load_plugin_textdomain('multi_site_site_list_shortcode', false, dirname(plugin_basename( __FILE__ )) . '/languages');
     15load_plugin_textdomain( 'multi_site_site_list_shortcode', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
    1616
    1717//Require common Bit51 library
    18 require_once(plugin_dir_path(__FILE__) . 'lib/bit51/bit51.php');
     18require_once( plugin_dir_path( __FILE__ ) . 'lib/bit51/bit51.php' );
    1919
    20 if (!class_exists('bit51_mssls')) {
     20if ( !class_exists( 'bit51_mssls' ) ) {
    2121
    2222    class bit51_mssls extends Bit51 {
    23    
    24         public $pluginversion   = '5.4.1'; //current plugin version
    25    
     23
     24        public $pluginversion = '5.4.1'; //current plugin version
     25
    2626        //important plugin information
    27         public $hook            = 'multi_site_site_list_shortcode';
    28         public $pluginbase      = 'multi-site-site-list-shortcode/multi-site-site-list-shortcode.php';
    29         public $pluginname      = 'Multi-Site Site List Shortcode';
    30         public $homepage        = 'http://bit51.com/software/multi-site-site-list-shortcode/';
    31         public $supportpage     = 'http://wordpress.org/support/plugin/multi-site-site-list-shortcode';
    32         public $wppage          = 'http://wordpress.org/extend/plugins/multi-site-site-list-shortcode/';
    33         public $accesslvl       = 'manage_network_options';
    34         public $paypalcode      = '7GDQDFENDBDAA';
    35         public $plugindata      = 'bit51_mssls_data';
    36         public $primarysettings = 'bit51_mssls';
    37         public $settings        = array(
    38             'bit51_mssls_options'   => array(
    39                 'bit51_mssls'           => array(
    40                     'callback'              => 'mssls_val_options',
    41                     'sortby'                => '0',
    42                     'openin'                => '0',
    43                     'limit'                 => '0',
    44                     'showtag'               => '0',
    45                     'excluded'              => array()
     27        public $hook = 'multi_site_site_list_shortcode';
     28        public $pluginbase = 'multi-site-site-list-shortcode/multi-site-site-list-shortcode.php';
     29        public $pluginname = 'Multi-Site Site List Shortcode';
     30        public $homepage = 'http://bit51.com/software/multi-site-site-list-shortcode/';
     31        public $supportpage = 'http://wordpress.org/support/plugin/multi-site-site-list-shortcode';
     32        public $wppage = 'http://wordpress.org/extend/plugins/multi-site-site-list-shortcode/';
     33        public $accesslvl = 'manage_network_options';
     34        public $paypalcode = '7GDQDFENDBDAA';
     35        public $plugindata = 'bit51_mssls_data';
     36        public $primarysettings = 'bit51_mssls';
     37        public $settings = array(
     38            'bit51_mssls_options' => array(
     39                'bit51_mssls' => array(
     40                    'callback' => 'mssls_val_options',
     41                    'sortby' => '0',
     42                    'openin' => '0',
     43                    'limit' => '0',
     44                    'showtag' => '0',
     45                    'excluded' => array()
    4646                )
    4747            )
     
    4949
    5050        /**
    51          * Register the shortcode in instantiation 
     51         * Register the shortcode in instantiation
    5252         */
    5353        function __construct() {
    54        
     54
    5555            //set path information
    56             define('MSSLS_PP', plugin_dir_path(__FILE__));
    57             define('MSSLS_PU', plugin_dir_url(__FILE__));
    58        
     56            define( 'MSSLS_PP', plugin_dir_path( __FILE__ ) );
     57            define( 'MSSLS_PU', plugin_dir_url( __FILE__ ) );
     58
    5959            //require admin page
    60             require_once(plugin_dir_path(__FILE__) . 'inc/admin.php');
    61             new mssls_admin($this);
    62            
     60            require_once( plugin_dir_path( __FILE__ ) . 'inc/admin.php' );
     61            new mssls_admin( $this );
     62
    6363            //require setup information
    64             require_once(plugin_dir_path(__FILE__) . 'inc/setup.php');
    65             register_activation_hook( __FILE__, array('mssls_setup', 'on_activate'));
    66             register_deactivation_hook( __FILE__, array('mssls_setup', 'on_deactivate'));
    67             register_uninstall_hook( __FILE__, array('mssls_setup', 'on_uninstall'));
    68            
    69             add_shortcode('site-list', array(&$this, 'display_site_list'));
    70             if (!is_admin()) {
    71                 add_filter('widget_text', 'do_shortcode');
     64            require_once( plugin_dir_path( __FILE__ ) . 'inc/setup.php' );
     65            register_activation_hook( __FILE__, array( 'mssls_setup', 'on_activate' ) );
     66            register_deactivation_hook( __FILE__, array( 'mssls_setup', 'on_deactivate' ) );
     67            register_uninstall_hook( __FILE__, array( 'mssls_setup', 'on_uninstall' ) );
     68
     69            add_shortcode( 'site-list', array( $this, 'display_site_list' ) );
     70            if ( !is_admin() ) {
     71                add_filter( 'widget_text', 'do_shortcode' );
    7272            }
    7373        }
    74        
     74
    7575        /**
    7676         * Create site list
    7777         */
    78         function display_site_list($attr) {
     78        function display_site_list( $attr ) {
    7979            global $wpdb;
    8080            global $table_prefix;
    8181            $output = '';
    82            
     82
    8383            //this is a workaround for lack of settings api with multi-site
    84             $options = $wpdb->get_results('SELECT option_value FROM `' . $wpdb->base_prefix . 'options` WHERE option_name IN (\'' . $this->primarysettings . '\') ORDER BY option_name DESC');
    85            
     84            $options = $wpdb->get_results( 'SELECT option_value FROM `' . $wpdb->base_prefix . 'options` WHERE option_name IN (\'' . $this->primarysettings . '\') ORDER BY option_name DESC' );
     85
    8686            //convert options to array so we can use it like normal
    87             $options = unserialize($options[0]->option_value);
    88            
     87            $options = unserialize( $options[0]->option_value );
     88
    8989            //get blog list
    90             $blogs = $wpdb->get_col("SELECT blog_id FROM `" . $wpdb->blogs . "` WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' ORDER BY blog_id DESC");
    91            
     90            $blogs = $wpdb->get_col( "SELECT blog_id FROM `" . $wpdb->blogs . "` WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' ORDER BY blog_id DESC" );
     91
    9292            //make sure there are blogs
    93             if ($blogs) {
    94            
     93            if ( $blogs ) {
     94
    9595                $output .= '<div id="mssls"><ul>'; //assign a div to make styling easier
    9696                $siteArray = array(); //initial array of sites to display
    97                
    98                 foreach ($blogs as $blog) {
    99                     if ($blog == '1') { //get blog options from the right table (blog 1 needs a special tablename)
    100                         $table =  $wpdb->base_prefix . 'options';
     97
     98                foreach ( $blogs as $blog ) {
     99                    if ( $blog == '1' ) { //get blog options from the right table (blog 1 needs a special tablename)
     100                        $table = $wpdb->base_prefix . 'options';
    101101                    } else {
    102102                        $table = $wpdb->base_prefix . $blog . '_options';
    103103                    }
    104                    
    105                     if (is_array($options['excluded'])) {//get array of excluded blog id's
    106                         $excluded = $options['excluded']; 
     104
     105                    if ( is_array( $options['excluded'] ) ) { //get array of excluded blog id's
     106                        $excluded = $options['excluded'];
    107107                    } else {
    108                         $excluded = unserialize($options['excluded']);
     108                        $excluded = unserialize( $options['excluded'] );
    109109                    }
    110                        
    111                     $sitedetails = $wpdb->get_results('SELECT option_value FROM `' . $table . '` WHERE option_name IN (\'siteurl\',\'blogname\',\'blogdescription\') ORDER BY option_name DESC'); //get blog details
    112                    
    113                     if (isset($attr['sort'])) {
    114                         if (strtolower($attr['sort']) == 'alpha') {
     110
     111                    $sitedetails = $wpdb->get_results( 'SELECT option_value FROM `' . $table . '` WHERE option_name IN (\'siteurl\',\'blogname\',\'blogdescription\') ORDER BY option_name DESC' ); //get blog details
     112
     113                    if ( isset( $attr['sort'] ) ) {
     114                        if ( strtolower( $attr['sort'] ) == 'alpha' ) {
    115115                            $sortby = 0;
    116116                        } else {
     
    120120                        $sortby = $options['sortby'];
    121121                    }
    122                    
    123                     if($sitedetails && !in_array($blog, $excluded)) { //if the blog exists and isn't on the exclusion list add it to array
    124                         if ($sortby == 0) { //proper array construction depending on sort
     122
     123                    if ( $sitedetails && !in_array( $blog, $excluded ) ) { //if the blog exists and isn't on the exclusion list add it to array
     124                        if ( $sortby == 0 ) { //proper array construction depending on sort
    125125                            $siteArray[$sitedetails[1]->option_value]['url'] = $sitedetails[0]->option_value;
    126126                            $siteArray[$sitedetails[1]->option_value]['id'] = $blog;
     
    133133                    }
    134134                }
    135                
    136                 ksort($siteArray); //sort array
    137                
     135
     136                ksort( $siteArray ); //sort array
     137
    138138            }
    139            
     139
    140140            //create link target if necessary
    141            
    142             if (isset($attr['newwin'])) {
     141
     142            if ( isset( $attr['newwin'] ) ) {
    143143                $openin = $attr['newwin'];
    144144            } else {
    145145                $openin = $options['openin'];
    146146            }
    147            
    148             if ($openin == 1) {
     147
     148            if ( $openin == 1 ) {
    149149                $target = ' target="_blank" ';
    150150            } else {
    151151                $target = ' ';
    152152            }
    153            
     153
    154154            $count = 0;
    155            
     155
    156156            //add sites to output string
    157             foreach ($siteArray as $site => $value) {
    158            
    159                 if(isset($attr['limit'])) {
     157            foreach ( $siteArray as $site => $value ) {
     158
     159                if ( isset( $attr['limit'] ) ) {
    160160                    $limit = $attr['limit'];
    161161                } else {
    162162                    $limit = $options['limit'];
    163163                }
    164            
    165                 if ($count < $limit || $limit == 0) {
    166                
    167                     if (isset($attr['showtag'])) {
     164
     165                if ( $count < $limit || $limit == 0 ) {
     166
     167                    if ( isset( $attr['showtag'] ) ) {
    168168                        $showtag = $attr['showtag'];
    169169                    } else {
    170170                        $showtag = $options['showtag'];
    171171                    }
    172            
    173                     if ($showtag == 1 && strlen($value['desc']) > 0) {
     172
     173                    if ( $showtag == 1 && strlen( $value['desc'] ) > 0 ) {
    174174                        $desc = '<br /><p>' . $value['desc'] . '</p>';
    175175                    } else {
    176176                        $desc = '';
    177177                    }
    178            
    179                     if ($sortby == 0) {
    180                         $output .= '<li><a href="' .  $value['url'] . '"' . $target  . '>' . $site . '</a>' . $desc . '</li>';
     178
     179                    if ( $sortby == 0 ) {
     180                        $output .= '<li><a href="' . $value['url'] . '"' . $target . '>' . $site . '</a>' . $desc . '</li>';
    181181                    } else {
    182                         $output .= '<li><a href="' .  $value['url'] . '"' . $target  . '>' . $value['title'] . '</a>' . $desc . '</li>';
     182                        $output .= '<li><a href="' . $value['url'] . '"' . $target . '>' . $value['title'] . '</a>' . $desc . '</li>';
    183183                    }
    184                    
     184
    185185                    $count++;
    186                
     186
    187187                } else {
    188188                    break;
    189                 }       
     189                }
    190190            }
    191            
     191
    192192            return $output . '</ul></div>';
    193            
     193
    194194        }
    195195    }
  • multi-site-site-list-shortcode/trunk/readme.txt

    r700792 r774732  
    11
    22=== Multi-Site Site List Shortcode ===
    3 Contributors: Bit51
     3Contributors: Bit51, ChrisWiegman
    44Donate link: http://bit51.com/software/multi-site-site-list-shortcode/
    55Tags: Multisite, index, site list
    66Requires at least: 3.0
    7 Tested up to: 3.5.1
     7Tested up to: 3.6.1
    88Stable tag: 5.4.1
    99
     
    3232
    3333== Changelog ==
     34
     35= Dev =
     36* Remove pass by reference (should now work with PHP 5.4)
     37* Reformat for better WordPress code standards
     38* Stop using dynamic text domain
     39* Works with WordPress 3.6.1
     40* Updated .pot file
    3441
    3542= 5.4.1 =
Note: See TracChangeset for help on using the changeset viewer.