Changeset 774732
- Timestamp:
- 09/18/2013 03:27:22 PM (12 years ago)
- Location:
- multi-site-site-list-shortcode/trunk
- Files:
-
- 5 edited
-
inc/admin.php (modified) (5 diffs)
-
inc/setup.php (modified) (8 diffs)
-
lib/bit51/bit51.php (modified) (17 diffs)
-
multi-site-site-list-shortcode.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
multi-site-site-list-shortcode/trunk/inc/admin.php
r514240 r774732 1 1 <?php 2 2 3 if ( !class_exists('mssls_admin')) {3 if ( !class_exists( 'mssls_admin' ) ) { 4 4 5 5 class mssls_admin extends bit51_mssls { 6 6 7 7 /** 8 8 * Initialize admin function … … 10 10 function __construct() { 11 11 global $blog_id; 12 13 if ( $blog_id == 1) {14 12 13 if ( $blog_id == 1 ) { 14 15 15 //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 19 19 //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 22 22 //add settings 23 add_action( 'admin_init', array(&$this, 'register_settings'));24 23 add_action( 'admin_init', array( $this, 'register_settings' ) ); 24 25 25 //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 28 28 //add donation reminder 29 add_action( 'admin_init', array(&$this, 'ask'));30 29 add_action( 'admin_init', array( $this, 'ask' ) ); 30 31 31 } 32 32 } 33 33 34 34 /** 35 35 * Register page settings 36 36 */ 37 37 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 41 41 /** 42 42 * Register admin page main content … … 44 44 */ 45 45 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' ), 47 47 array( 48 array( __('Instructions', $this->hook), 'install_instructions'), //primary admin page content49 array( __('General Options', $this->hook), 'general_options'), //primary admin page content50 array( __('Exclude Sites', $this->hook), 'exclude_options') //choose sites to be excluded from view48 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 51 51 ) 52 52 ); 53 53 } 54 54 55 55 /** 56 56 * Create instructions block … … 58 58 function install_instructions() { 59 59 ?> 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> 62 62 <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> 67 67 </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 72 73 /** 73 74 * Create admin page main content … … 76 77 ?> 77 78 <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 ?> 80 81 <table class="form-table"> 81 82 <tr valign="top"> 82 83 <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> 120 132 </th> 121 133 <td> 122 134 <?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 />'; 157 168 } 158 169 } 170 } 159 171 ?> 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> 161 173 </td> 162 174 </tr> 163 175 </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> 165 178 </form> 166 <?php167 } 168 179 <?php 180 } 181 169 182 /** 170 183 * Validate input 171 184 */ 172 function mssls_val_options( $input) {185 function mssls_val_options( $input ) { 173 186 $exclude = array(); //create exclude array 174 187 175 188 //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 $input184 185 //process non-exclude fields186 $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; 192 205 } 193 206 } -
multi-site-site-list-shortcode/trunk/inc/setup.php
r500734 r774732 1 1 <?php 2 2 3 if ( !class_exists('mssls_setup')) {3 if ( !class_exists( 'mssls_setup' ) ) { 4 4 5 5 class mssls_setup extends bit51_mssls { … … 8 8 * Verify case is set correctly and continue or die 9 9 */ 10 function __construct( $case = false) {11 12 if ( !$case) {13 die( 'error');10 function __construct( $case = false ) { 11 12 if ( !$case ) { 13 die( 'error' ); 14 14 } 15 15 16 switch ($case) {16 switch ( $case ) { 17 17 case 'activate': //active plugin 18 18 $this->activate_execute(); … … 33 33 */ 34 34 function on_activate() { 35 new mssls_setup( 'activate');35 new mssls_setup( 'activate' ); 36 36 } 37 37 … … 40 40 */ 41 41 function on_deactivate() { 42 42 43 43 $devel = false; //set to true to uninstall for development 44 45 if ( $devel) {44 45 if ( $devel ) { 46 46 $case = 'uninstall'; 47 47 } else { … … 49 49 } 50 50 51 new mssls_setup( $case);51 new mssls_setup( $case ); 52 52 } 53 53 … … 56 56 */ 57 57 function on_uninstall() { 58 if ( __FILE__ != WP_UNINSTALL_PLUGIN ) { //verify they actually clicked uninstall58 if ( __FILE__ != WP_UNINSTALL_PLUGIN ) { //verify they actually clicked uninstall 59 59 return; 60 60 } 61 61 62 new mssls_setup( 'uninstall');62 new mssls_setup( 'uninstall' ); 63 63 } 64 64 … … 68 68 function activate_execute() { 69 69 $this->default_settings(); //verify and set default options 70 71 $options = get_option( $this->plugindata);72 70 71 $options = get_option( $this->plugindata ); 72 73 73 //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 ) { 75 75 $this->update_execute(); 76 76 } 77 77 78 78 $options['version'] = $this->pluginversion; //set new version number 79 79 80 80 //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'] ); 84 84 } 85 85 86 86 //set activate timestamp to today (they'll be notified again in a month) 87 87 $options['activatestamp'] = time(); 88 88 } 89 90 update_option( $this->plugindata, $options); //save new plugin data89 90 update_option( $this->plugindata, $options ); //save new plugin data 91 91 } 92 92 93 93 /** 94 94 * Execute update functions … … 107 107 */ 108 108 function uninstall_execute() { 109 109 110 110 //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 ); 114 114 } 115 115 } 116 116 117 117 //delete plugin information (version, etc) 118 delete_option( $this->plugindata);118 delete_option( $this->plugindata ); 119 119 } 120 120 } -
multi-site-site-list-shortcode/trunk/lib/bit51/bit51.php
r700792 r774732 7 7 */ 8 8 9 if ( ! class_exists( 'Bit51' ) ) {9 if ( !class_exists( 'Bit51' ) ) { 10 10 11 11 abstract class Bit51 { 12 12 13 13 var $feed = 'http://bit51.com/feed'; //current address of Bit51.com feed 14 14 15 15 /** 16 16 * Register admin javascripts (only for plugin admin page) … … 18 18 **/ 19 19 function config_page_scripts() { 20 20 21 21 //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 24 24 wp_enqueue_script( 'postbox' ); 25 25 wp_enqueue_script( 'dashboard' ); 26 26 wp_enqueue_script( 'thickbox' ); 27 27 wp_enqueue_script( 'media-upload' ); 28 29 } 30 31 } 32 28 29 } 30 31 } 32 33 33 /** 34 34 * Register admin css styles (only for plugin admin page) … … 36 36 **/ 37 37 function config_page_styles() { 38 38 39 39 //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 42 42 wp_enqueue_style( 'dashboard' ); 43 43 wp_enqueue_style( 'thickbox' ); 44 44 wp_enqueue_style( 'global' ); 45 45 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 52 52 /** 53 53 * Register all settings groups … … 57 57 **/ 58 58 function register_settings() { 59 59 60 60 foreach ( $this->settings as $group => $settings ) { //look at each main group 61 61 62 62 foreach ( $settings as $setting => $option ) { //look at each option set 63 63 64 64 if ( isset( $option['callback'] ) ) { //if callback is defined register with callback 65 65 66 66 register_setting( $group, $setting, array( $this, $option['callback'] ) ); 67 67 68 68 } else { //register without callback 69 69 70 70 register_setting( $group, $setting ); 71 72 } 73 74 }75 76 } 77 78 } 79 71 72 } 73 74 } 75 76 } 77 78 } 79 80 80 /** 81 81 * Add action link to plugin page 82 * 82 * 83 83 * Adds plugin settings link to plugin page in WordPress admin area. 84 84 * … … 90 90 function add_action_link( $links, $file ) { 91 91 static $this_plugin; 92 92 93 93 if ( empty( $this_plugin ) ) { 94 94 $this_plugin = $this->pluginbase; 95 95 } 96 96 97 97 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>'; 99 99 array_unshift( $links, $settings_link ); 100 100 } 101 101 102 102 return $links; 103 103 } 104 104 105 105 /** 106 106 * Return URL of options page … … 110 110 **/ 111 111 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 117 117 /** 118 118 * Setup and call admin messages … … 124 124 **/ 125 125 function showmessages( $errors ) { 126 126 127 127 global $savemessages; //use global to transfer to add_action callback 128 128 129 129 $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' ) ) { 132 132 apc_clear_cache(); //Let's clear APC (if it exists) when big stuff is saved. 133 133 } 134 134 135 135 if ( is_wp_error( $errors ) ) { //see if object is even an error 136 136 137 137 $errors = $errors->get_error_messages(); //get all errors if it is 138 138 139 139 foreach ( $errors as $error => $string ) { 140 140 $savemessages .= '<div id="message" class="error"><p>' . $string . '</p></div>'; 141 141 } 142 142 143 143 } else { //no errors so display settings saved message 144 144 145 145 $savemessages .= '<div id="message" class="updated"><p><strong>' . $errors . '</strong></p></div>'; 146 147 } 148 146 147 } 148 149 149 //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 155 155 /** 156 156 * Set all default settings … … 160 160 **/ 161 161 function default_settings() { 162 162 163 163 foreach ( $this->settings as $settings ) { 164 164 165 165 foreach ( $settings as $setting => $defaults ) { 166 166 167 167 $options = get_option( $setting ); //Get the option if it already exists 168 168 169 169 //set missing options 170 170 foreach ( $defaults as $option => $value ) { 171 171 172 172 if ( $option != 'callback' && !isset( $options[$option] ) ) { 173 173 $options[$option] = $value; 174 174 } 175 176 } 177 175 176 } 177 178 178 //remove obsolete options 179 179 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] ); 183 183 } 184 185 } 186 184 185 } 186 187 187 update_option( $setting, $options ); //save new options 188 188 } 189 190 } 191 189 190 } 191 192 192 return $options; 193 194 } 195 193 194 } 195 196 196 /** 197 197 * Echos admin messages 198 * 198 * 199 199 * Takes care of echoing admin message when appropriate action is called 200 200 * 201 201 **/ 202 202 function dispmessage() { 203 203 204 204 global $savemessages; 205 205 206 206 echo $savemessages; 207 208 unset( $savemessages); //delete any saved messages209 210 } 211 207 208 unset( $savemessages ); //delete any saved messages 209 210 } 211 212 212 /** 213 213 * Setup postbox … … 222 222 ?> 223 223 <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> 225 225 <h3 class="hndle"><span><?php echo $title; ?></span></h3> 226 226 227 <div class="inside"> 227 <?php 228 //execute content if it's a function or just echo it229 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 } 238 239 ?> 239 240 </div> 240 241 </div> 241 <?php242 <?php 242 243 } 243 244 … … 249 250 echo '<div id="icon-themes" class="icon32"><br></div>'; 250 251 echo '<h2 class="nav-tab-wrapper">'; 251 foreach ( $tabs as $location => $tabname ){252 foreach ( $tabs as $location => $tabname ) { 252 253 if ( is_array( $tabname ) ) { 253 254 $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>'; 255 256 } else { 256 257 $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>'; 258 259 } 259 260 } 260 261 echo '</h2>'; 261 262 } 262 263 263 264 /** 264 265 * Setup main admin page box … … 280 281 281 282 ?> 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] ); 297 314 } 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 ?> 321 316 </div> 322 317 </div> 323 318 </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 327 335 /** 328 336 * Display tech support information … … 332 340 **/ 333 341 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 postbox338 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 341 349 /** 342 350 * Display Bit51's latest posts … … 346 354 **/ 347 355 function news() { 348 356 349 357 include_once( ABSPATH . WPINC . '/feed.php' ); //load WordPress feed info 350 358 351 359 $feed = fetch_feed( $this->feed ); //get the feed 352 360 353 if ( ! isset( $feed->errors ) ) {361 if ( !isset( $feed->errors ) ) { 354 362 355 363 $feeditems = $feed->get_items( 0, $feed->get_item_quantity( 5 ) ); //narrow feed to last 5 items 356 364 357 365 $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 363 371 } else { 364 372 365 373 foreach ( $feeditems as $item ) { 366 374 367 375 $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 375 383 $content .= '</ul>'; //end list 376 384 377 385 } 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 postbox382 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 385 393 /** 386 394 * Display donate box … … 390 398 **/ 391 399 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 395 403 $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 399 407 $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 407 415 $content .= '</ul>'; 408 409 $this->postbox( 'donate', __( 'Support This Plugin' , $this->hook), $content ); //setup the postbox410 411 } 412 416 417 $this->postbox( 'donate', __( 'Support This Plugin', 'multi_site_site_list_shortcode' ), $content ); //setup the postbox 418 419 } 420 413 421 /** 414 422 * Display social links … … 418 426 **/ 419 427 function social() { 420 428 421 429 $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 431 439 $content .= '</ul>'; 432 433 $this->postbox( 'bit51social', __( 'Bit51 on the Web', $this->hook), $content ); //setup the postbox434 435 } 436 440 441 $this->postbox( 'bit51social', __( 'Bit51 on the Web', 'multi_site_site_list_shortcode' ), $content ); //setup the postbox 442 443 } 444 437 445 /** 438 446 * Display (and hide) donation reminder … … 442 450 **/ 443 451 function ask() { 444 452 445 453 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 multisite454 455 if ( is_multisite() && ( $blog_id != 1 || !current_user_can( 'manage_network_options' ) ) ) { //only display to network admin if in multisite 448 456 return; 449 457 } 450 458 451 459 $options = get_option( $this->plugindata ); 452 460 453 461 //this is called at a strange point in WP so we need to bring in some data 454 462 global $plugname; … … 458 466 $plughook = $this->hook; 459 467 $plugopts = $this->plugin_options_url(); 460 468 461 469 //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 468 476 global $plugname; 469 477 global $plughook; 470 478 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> 474 482 </div>'; 475 476 } 477 478 } 479 483 484 } 485 486 } 487 480 488 add_action( 'admin_notices', 'bit51_plugin_donate_notice' ); //register notification 481 482 } 483 489 490 } 491 484 492 //if they've clicked a button hide the notice 485 493 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 487 495 $options = get_option( $this->plugindata ); 488 496 $options['no-nag'] = 1; 489 update_option( $this->plugindata, $options );497 update_option( $this->plugindata, $options ); 490 498 remove_action( 'admin_notices', 'bit51_plugin_donate_notice' ); 491 499 492 500 //take the user to paypal if they've clicked donate 493 501 if ( isset( $_GET['bit51_lets_donate'] ) ) { 494 502 wp_redirect( 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=' . $this->paypalcode, '302' ); 495 503 } 496 504 497 505 //Go to the WordPress page to let them rate it. 498 506 if ( isset( $_GET['bit51_lets_rate'] ) ) { 499 507 wp_redirect( $this->wppage, '302' ); 500 508 } 501 509 502 510 //Compose a Tweet 503 511 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 511 519 } 512 520 513 521 } -
multi-site-site-list-shortcode/trunk/multi-site-site-list-shortcode.php
r700792 r774732 4 4 Plugin URI: http://bit51.com/software/multi-site-site-list-shortcode/ 5 5 Description: Displays the site list with a shortcode for network installations. 6 Version: 5.4.16 Version: Dev 7 7 Domain Path: /languages 8 8 Author: Bit51 9 9 Author URI: http://bit51.com 10 10 License: GPLv2 11 Copyright 201 2 Bit51.com(email : [email protected])11 Copyright 2013 Bit51 (email : [email protected]) 12 12 */ 13 13 14 14 //load the text domain 15 load_plugin_textdomain( 'multi_site_site_list_shortcode', false, dirname(plugin_basename( __FILE__ )) . '/languages');15 load_plugin_textdomain( 'multi_site_site_list_shortcode', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 16 16 17 17 //Require common Bit51 library 18 require_once( plugin_dir_path(__FILE__) . 'lib/bit51/bit51.php');18 require_once( plugin_dir_path( __FILE__ ) . 'lib/bit51/bit51.php' ); 19 19 20 if ( !class_exists('bit51_mssls')) {20 if ( !class_exists( 'bit51_mssls' ) ) { 21 21 22 22 class bit51_mssls extends Bit51 { 23 24 public $pluginversion = '5.4.1'; //current plugin version25 23 24 public $pluginversion = '5.4.1'; //current plugin version 25 26 26 //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() 46 46 ) 47 47 ) … … 49 49 50 50 /** 51 * Register the shortcode in instantiation 51 * Register the shortcode in instantiation 52 52 */ 53 53 function __construct() { 54 54 55 55 //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 59 59 //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 63 63 //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' ); 72 72 } 73 73 } 74 74 75 75 /** 76 76 * Create site list 77 77 */ 78 function display_site_list( $attr) {78 function display_site_list( $attr ) { 79 79 global $wpdb; 80 80 global $table_prefix; 81 81 $output = ''; 82 82 83 83 //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 86 86 //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 89 89 //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 92 92 //make sure there are blogs 93 if ( $blogs) {94 93 if ( $blogs ) { 94 95 95 $output .= '<div id="mssls"><ul>'; //assign a div to make styling easier 96 96 $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'; 101 101 } else { 102 102 $table = $wpdb->base_prefix . $blog . '_options'; 103 103 } 104 105 if ( is_array($options['excluded'])) {//get array of excluded blog id's106 $excluded = $options['excluded']; 104 105 if ( is_array( $options['excluded'] ) ) { //get array of excluded blog id's 106 $excluded = $options['excluded']; 107 107 } else { 108 $excluded = unserialize( $options['excluded']);108 $excluded = unserialize( $options['excluded'] ); 109 109 } 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 details112 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' ) { 115 115 $sortby = 0; 116 116 } else { … … 120 120 $sortby = $options['sortby']; 121 121 } 122 123 if ($sitedetails && !in_array($blog, $excluded)) { //if the blog exists and isn't on the exclusion list add it to array124 if ( $sortby == 0) { //proper array construction depending on sort122 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 125 125 $siteArray[$sitedetails[1]->option_value]['url'] = $sitedetails[0]->option_value; 126 126 $siteArray[$sitedetails[1]->option_value]['id'] = $blog; … … 133 133 } 134 134 } 135 136 ksort( $siteArray); //sort array137 135 136 ksort( $siteArray ); //sort array 137 138 138 } 139 139 140 140 //create link target if necessary 141 142 if ( isset($attr['newwin'])) {141 142 if ( isset( $attr['newwin'] ) ) { 143 143 $openin = $attr['newwin']; 144 144 } else { 145 145 $openin = $options['openin']; 146 146 } 147 148 if ( $openin == 1) {147 148 if ( $openin == 1 ) { 149 149 $target = ' target="_blank" '; 150 150 } else { 151 151 $target = ' '; 152 152 } 153 153 154 154 $count = 0; 155 155 156 156 //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'] ) ) { 160 160 $limit = $attr['limit']; 161 161 } else { 162 162 $limit = $options['limit']; 163 163 } 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'] ) ) { 168 168 $showtag = $attr['showtag']; 169 169 } else { 170 170 $showtag = $options['showtag']; 171 171 } 172 173 if ( $showtag == 1 && strlen($value['desc']) > 0) {172 173 if ( $showtag == 1 && strlen( $value['desc'] ) > 0 ) { 174 174 $desc = '<br /><p>' . $value['desc'] . '</p>'; 175 175 } else { 176 176 $desc = ''; 177 177 } 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>'; 181 181 } 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>'; 183 183 } 184 184 185 185 $count++; 186 186 187 187 } else { 188 188 break; 189 } 189 } 190 190 } 191 191 192 192 return $output . '</ul></div>'; 193 193 194 194 } 195 195 } -
multi-site-site-list-shortcode/trunk/readme.txt
r700792 r774732 1 1 2 2 === Multi-Site Site List Shortcode === 3 Contributors: Bit51 3 Contributors: Bit51, ChrisWiegman 4 4 Donate link: http://bit51.com/software/multi-site-site-list-shortcode/ 5 5 Tags: Multisite, index, site list 6 6 Requires at least: 3.0 7 Tested up to: 3. 5.17 Tested up to: 3.6.1 8 8 Stable tag: 5.4.1 9 9 … … 32 32 33 33 == 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 34 41 35 42 = 5.4.1 =
Note: See TracChangeset
for help on using the changeset viewer.