Changeset 1128314
- Timestamp:
- 04/05/2015 07:54:58 PM (11 years ago)
- Location:
- sort-my-sites/trunk
- Files:
-
- 2 edited
-
admin/class-sort-my-sites-admin.php (modified) (2 diffs)
-
sort-my-sites.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sort-my-sites/trunk/admin/class-sort-my-sites-admin.php
r1104265 r1128314 13 13 $this->options = $this->plugin->get_options(); 14 14 15 add_action( 'admin_init', array( $this, 'setup' ) ); 15 16 add_action( 'wpmu_options', array( $this, 'add_network_options' ) ); 17 add_action( 'update_wpmu_options', array( $this, 'save_network_settings' ) ); 18 19 add_filter( 'screen_settings', array( $this, 'show_screen_options' ), 10, 2 ); 20 add_filter( 'set-screen-option', array( $this, 'set_screen_options' ), 11, 3 ); 16 21 17 22 } … … 25 30 return self::$instance; 26 31 } 32 27 33 34 function set_screen_options($status, $option, $value) { 35 if ( 'sort_my_sites_options' == $option ) { 36 $value = $_POST['sort-my-sites_options']; 37 } 38 return $value; 39 } 28 40 29 public function setup(){41 function show_screen_options( $status, $args ) { 30 42 31 add_action( 'wpmu_options', array( $this, 'add_network_options' ) ); 32 add_action( 'update_wpmu_options', array( $this, 'save_network_settings' ) ); 43 $return = $status; 33 44 45 if ( $args->base == 'my-sites' ) { 46 47 $button = get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); 48 49 $return .= " 50 <fieldset> 51 <legend>Sort Options</legend> 52 <div class='metabox-prefs'> 53 <div><input type='hidden' name='wp_screen_options[option]' value='" . $this->plugin_slug . "_options' /></div> 54 <div><input type='hidden' name='wp_screen_options[value]' value='yes' /></div> 55 <div class='custom_fields'> 56 <label for='order_by'>Order By:</label> 57 <select name='" . $this->plugin_slug . "_options[order_by]' id='order_by'>"; 58 59 foreach($this->options['order_options'] as $option => $title){ 60 $return .= "<option value='" . $option ."' ". selected( $this->options['order_by'], $option, false ) ." >". $title ."</option>"; 61 } 62 63 $return .="</select> 64 <label for='case_sensitive'><input type='checkbox' value='1' name='" . $this->plugin_slug . "_options[case_sensitive]' id='case_sensitive' ". checked( true, $this->options["case_sensitive" ], false ) ." /> Case Sensitive</label> 65 <label for='primary_at_top'><input type='checkbox' value='1' name='" . $this->plugin_slug . "_options[primary_at_top]' id='primary_at_top' ". checked( true, $this->options["primary_at_top" ], false ) ." /> Keep primary site at the top</label> 66 </div> 67 </div> 68 </fieldset> 69 <br class='clear'> 70 $button"; 71 } 72 73 return $return; 34 74 } 35 75 -
sort-my-sites/trunk/sort-my-sites.php
r1104265 r1128314 6 6 Author: Tryon Eggleston 7 7 Author URI: https://github.com/tryonegg/ 8 Version: 1. 08 Version: 1.1 9 9 Network: true 10 10 */ … … 15 15 16 16 class sort_my_sites { 17 const VERSION = 1 ;17 const VERSION = 1.1; 18 18 protected $plugin_slug = 'sort-my-sites'; 19 19 protected static $instance = null; … … 43 43 private function __construct() { 44 44 45 if(is_multisite()){45 add_filter( 'get_blogs_of_user', array( $this, 'sort_sites' ) ); 46 46 47 $this->options['case_sensitive'] = get_site_option( $this->plugin_slug . "_case_sensitive", $this->options['case_sensitive'] ); 48 $this->options['primary_at_top'] = get_site_option( $this->plugin_slug . "_primary_at_top", $this->options['primary_at_top'] ); 49 $this->options['order_by'] = get_site_option( $this->plugin_slug . "_order_by", $this->options['order_by'] ); 50 51 add_filter( 'get_blogs_of_user', array( $this, 'sort_sites' ) ); 52 } 47 $this->options['case_sensitive'] = $this->get_option('case_sensitive'); 48 $this->options['primary_at_top'] = $this->get_option('primary_at_top'); 49 $this->options['order_by'] = $this->get_option('order_by'); 53 50 54 51 } … … 62 59 return self::$instance; 63 60 } 61 62 63 /** 64 * Gets the most relevant option setting 65 * @param string 66 */ 67 public function get_option( $option ){ 68 69 $useroptions = get_user_meta( get_current_user_id(), 'sort_my_sites_options', true); 70 71 if( $useroptions ){ 72 if( isset( $useroptions[$option] ) ){ 73 return $useroptions[$option]; 74 } else { 75 return false; 76 } 77 } else { 78 return get_site_option( $this->plugin_slug . "_" . $option, $this->options[ $option ] ); 79 } 80 81 } 82 64 83 65 84 /** … … 115 134 116 135 } 117 add_action( 'plugins_loaded', array( 'sort_my_sites', 'get_instance' ) );118 136 119 if ( is_admin() && is_multisite() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ){137 if( is_multisite() ){ 120 138 121 require_once( plugin_dir_path( __FILE__ ) . 'admin/class-sort-my-sites-admin.php' ); 122 add_action( 'plugins_loaded', array( 'sort_my_sites_admin', 'get_instance' ) ); 139 add_action( 'plugins_loaded', array( 'sort_my_sites', 'get_instance' ) ); 140 141 if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { 142 143 require_once( plugin_dir_path( __FILE__ ) . 'admin/class-sort-my-sites-admin.php' ); 144 add_action( 'plugins_loaded', array( 'sort_my_sites_admin', 'get_instance' ) ); 145 146 } 123 147 124 148 }
Note: See TracChangeset
for help on using the changeset viewer.