Changeset 1604369
- Timestamp:
- 02/27/2017 09:50:17 AM (9 years ago)
- Location:
- msls-gouping/trunk
- Files:
-
- 9 edited
-
asm-MSLS-Grouping.php (modified) (1 diff)
-
inc/asm-MSLS-Grouping.php (modified) (27 diffs)
-
languages/asm-msls-grouping-ja.mo (modified) (previous)
-
languages/asm-msls-grouping-ja.po (modified) (4 diffs)
-
languages/asm-msls-grouping-ja_JP.mo (modified) (previous)
-
languages/asm-msls-grouping-ja_JP.po (modified) (4 diffs)
-
languages/asm-msls-grouping.pot (modified) (3 diffs)
-
languages/default.pot (modified) (3 diffs)
-
readme.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
msls-gouping/trunk/asm-MSLS-Grouping.php
r1594566 r1604369 5 5 Description: You can multilingualize by 'Multisite Language Switcher' with grouping the sites of the plural same languages. 6 6 Author: Asumaru Corp. 7 Version: 0. 17 Version: 0.2 8 8 Author URI: http://asumaru.com/ 9 9 Created: 2017.01.01 -
msls-gouping/trunk/inc/asm-MSLS-Grouping.php
r1594566 r1604369 5 5 Description: You can multilingualize by 'Multisite Language Switcher' with grouping the sites of the plural same languages. 6 6 Author: Asumaru Corp. 7 Version: 0. 17 Version: 0.2 8 8 Author URI: http://asumaru.com/ 9 9 Created: 2017.01.01 10 Updated: 2017.03.01 10 11 11 12 */ 12 13 14 /** 15 * Global variable. Orignal text domain. 16 * 17 * @since 0.1 18 **/ 13 19 $asm_textdomain = 'asm-msls-grouping'; 14 20 15 16 21 /** 17 @class : Base Class 22 * Core class. 23 * 24 * @since 0.1 18 25 **/ 19 26 class asm_MSLS_Grouping_Class{ 20 27 21 var $funcs = array(); 22 var $cache = array(); 23 var $defaults = array( 28 /** 29 * Any functions. 30 * 31 * @since 0.1 32 * @var array 33 * @access private 34 */ 35 private $funcs = array(); 36 37 /** 38 * Variable caching. 39 * 40 * @since 0.1 41 * @var array 42 * @access private 43 */ 44 private $cache = array(); 45 46 /** 47 * Variable defaults. 48 * 49 * @since 0.1 50 * @var array 51 * @access public 52 */ 53 public $defaults = array( 24 54 'atts' => array( 25 55 'name' => '', … … 27 57 ), 28 58 'site_options' => array( 29 'allow_duplicate_languages' => array( false, 'checkbox', 'Allow Duplicate Languages', 'You allow for the same language to repeat in "Multisite Language Switcher".'),59 'allow_duplicate_languages' => array( false, 'checkbox', "Allow Duplicate Languages", "You allow for the same language to repeat in 'Multisite Language Switcher'." ), 30 60 ), 31 61 'sc_args' => array( … … 47 77 ', 48 78 ); 49 var $noGroup = '-- no group --'; 50 var $emptyLang = 'us'; 51 var $allow_duplicate_languages = false; 52 53 54 /** 55 @function : Constractor for PHP 4 56 @param : void 57 @return : void 58 */ 59 function asm_MSLS_Grouping_Class(){ 60 61 // Initialize 79 80 /** 81 * Default strings for no groupkey. 82 * 83 * @since 0.1 84 * @var string 85 * @access public 86 */ 87 public $noGroup = '-- no group --'; 88 89 /** 90 * Default locale and language. 91 * 92 * @since 0.1 93 * @var array 94 * @access public 95 */ 96 public $emptyLang = array( 'us', 'en_US' ); 97 98 /** 99 * Default boolean to allow duplicate languages. 100 * 101 * @since 0.1 102 * @var bool 103 * @access public 104 */ 105 public $allow_duplicate_languages = false; 106 107 /** 108 * Constractor for PHP 4 109 * 110 * @since 0.1 111 * @access public 112 */ 113 public function asm_MSLS_Grouping_Class(){ 62 114 add_action( 'init', array( &$this, 'init'), 20); 63 115 64 116 if( is_admin() ){ 65 add_action( 'admin_init', array( &$this, 'admin_init' ), 20 ); 66 } 67 68 // i10n 117 add_action( 'admin_init', array( &$this, 'admin_init' ), 20 ); 118 } 119 69 120 add_action( 'plugins_loaded', array( &$this, 'load_plugin_textdomain' ), 20); 70 121 71 // Regist Widget72 122 add_action( 'widgets_init', create_function('', 'return register_widget("asm_SameLangSites_Widget");') ); 73 123 74 } 75 76 77 /** 78 @function : Constractor 79 @param : void 80 @return : void 81 **/ 82 function __construct(){ 124 if( apply_filters( 'asm_language-flugs.admin-bar', true ) ){ 125 add_action( 'admin_bar_menu', array( &$this, 'admin_bar_menu' ), 20, 20); 126 } 127 128 } 129 130 /** 131 * Constractor 132 * 133 * @since 0.1 134 * @access public 135 */ 136 public function __construct(){ 83 137 return $this->asm_MSLS_Grouping_Class(); 84 138 } 85 139 86 140 /** 87 @function : call method in this class. 88 @param : $name function name 89 @param : $args argments 90 @return : (mixed) resalt/null 91 **/ 92 function __call( $name, $args){ 141 * Call method in this class. 142 * 143 * @since 0.1 144 * @param string $name Calling function name. 145 * @param mix $args Calling function arguments. 146 * @return mix function result. 147 * @access public 148 */ 149 public function __call( $name, $args){ 93 150 if( method_exists( $this, $name)){ 94 151 return call_user_func_array( array( &$this, $name), $args); … … 108 165 109 166 /** 110 @function : Action Hook. Init 111 @param : void 112 @return : void 113 **/ 114 function init(){ 167 * Action Hook. WP Initialize. 168 * 169 * @since 0.1 170 * @access public 171 */ 172 public function init(){ 115 173 if( class_exists( 'MslsOptions' ) ){ 116 174 $this->cache['MslsOptions'] = new MslsOptions(); … … 123 181 124 182 /** 125 @function : Action Hook. Admin Init 126 @param : void 127 @return : void 128 **/ 129 function admin_init(){ 183 * Action Hook. WP-Admin Initialize. 184 * 185 * @since 0.1 186 * @access public 187 */ 188 public function admin_init(){ 130 189 global $asm_textdomain; 131 190 if( function_exists( 'add_settings_field' ) ){ … … 135 194 add_action( 'wpmu_options', array( &$this, 'wpmu_options' ), 20 ); 136 195 add_filter( 'plugin_locale', array( &$this, 'plugin_locale' ), 20, 10 ); 137 } 138 139 function _description(){ 140 global $asm_textdomain; 141 __( "MSLS Gouping", $asm_textdomain ); 142 __( "Asumaru", $asm_textdomain ); 143 __( "Asumaru Corp.", $asm_textdomain ); 144 __( "You can multilingualize by 'Multisite Language Switcher' with grouping the sites of the plural same languages.", $asm_textdomain ); 145 } 146 147 /** 148 @function : Set text domain 149 @param : void 150 @return : void 151 **/ 152 function load_plugin_textdomain() { // l10n 196 if( apply_filters( 'asm_language-column.blogs.network', true ) ){ 197 add_filter( 'wpmu_blogs_columns', array( &$this, 'wpmu_blogs_columns' ), 20, 20 ); 198 add_action( 'manage_sites_custom_column', array( &$this, 'manage_sites_custom_column' ), 20, 20 ); 199 } 200 if( apply_filters( 'asm_force_WPLANG.options_general', true ) ){ 201 add_action( 'load-options-general.php', array( &$this, 'load_options_general' ), 20, 20 ); 202 } 203 add_action( 'admin_print_footer_scripts', array( &$this, 'admin_print_footer_scripts' ), 20, 20 ); 204 } 205 206 /** 207 * Action Hook. Text domain. 208 * 209 * @since 0.1 210 * @access public 211 */ 212 public function load_plugin_textdomain(){ 153 213 global $asm_textdomain; 154 214 $dir = dirname( __FILE__); … … 163 223 } 164 224 165 function plugin_locale( $locale, $domain = null ){ 225 /** 226 * Filter Hook. Plugin locale. 227 * 228 * @since 0.1 229 * @param string $locale original locale. 230 * @param string $domain text domain. 231 * @return string locale. 232 * @access public 233 */ 234 public function plugin_locale( $locale, $domain = null ){ 166 235 global $asm_textdomain; 167 236 $res = $locale; … … 170 239 171 240 /** 172 @function : Update site option. 173 @param : void 174 @return : void 175 **/ 176 function update_wpmu_options(){ 241 * Action Hook. Update site option. 242 * 243 * @since 0.1 244 * @access public 245 */ 246 public function update_wpmu_options(){ 177 247 foreach( (array) $this->defaults['site_options'] as $akey => $aval ){ 178 248 if( $_POST[$akey] === null || $_POST[$akey] === false ){ … … 188 258 189 259 /** 190 @function : Add in site option form. 191 @param : void 192 @return : void 193 **/ 194 function wpmu_options(){ 260 * Action Hook. Add in site option form. 261 * 262 * @since 0.1 263 * @access public 264 */ 265 public function wpmu_options(){ 266 global $asm_textdomain; 195 267 foreach( (array) $this->defaults['site_options'] as $akey => $aval ){ 196 268 switch( $aval[1] ){ … … 215 287 216 288 /** 217 @function : Display input-tag 'group_key'. 218 @param : void 219 @return : void 220 **/ 221 function group_key(){ 289 * Setting field 'group key'. 290 * 291 * @since 0.1 292 * @access public 293 */ 294 public function group_key(){ 222 295 global $asm_textdomain; 223 296 echo $this->render_input( 'group_key', '40' ); … … 227 300 } 228 301 229 230 /** 231 @function : Render form-element (checkbox) 232 @param : $key Name and ID of the form-element 233 @return : string 302 /** 303 * Render form-element (checkbox) 304 * 305 * @since 0.1 306 * @param string $key MslsOptions property name. 307 * @return string checkbox tag. 308 * @access public 234 309 */ 235 310 public function render_checkbox( $key ) { 311 if( ! is_scalar( $key ) ) return ''; 236 312 if( ! is_object( $this->cache['MslsOptions'] ) 237 313 || ! is_callable( array( $this->cache['MslsOptions'] , 'instance' ) ) ){ 238 return; 239 } 314 return ''; 315 } 316 $MslsOptions = MslsOptions::instance(); 317 if( ! isset( $MslsOptions->$key ) ) return ''; 240 318 return sprintf( 241 319 '<input type="checkbox" id="%1$s" name="msls[%1$s]" value="1" %2$s/>', 242 320 $key, 243 checked( 1, MslsOptions::instance()->$key, false )321 checked( 1, $MslsOptions->$key, false ) 244 322 ); 245 323 } 246 324 247 325 /** 248 @function : Render form-element (text-input) 249 @param : $key Name and ID of the form-element 250 @param : $size Size-attribute of the input-field 251 @return : string 326 * Render form-element (text-input) 327 * 328 * @since 0.1 329 * @param string $key MslsOptions property. 330 * @param init $size limit text size. 331 * @return string text-input tag. 332 * @access public 252 333 */ 253 334 public function render_input( $key, $size = '30' ) { 335 if( ! is_scalar( $key ) || empty( $key ) ) return ''; 254 336 if( ! is_object( $this->cache['MslsOptions'] ) 255 337 || ! is_callable( array( $this->cache['MslsOptions'] , 'instance' ) ) ){ 256 return; 257 } 338 return ''; 339 } 340 $MslsOptions = MslsOptions::instance(); 341 if( ! isset( $MslsOptions->$key ) ) return ''; 258 342 return sprintf( 259 343 '<input id="%1$s" name="msls[%1$s]" value="%2$s" size="%3$s"/>', 260 344 $key, 261 esc_attr( MslsOptions::instance()->$key ),345 esc_attr( $MslsOptions->$key ), 262 346 $size 263 347 ); … … 265 349 266 350 /** 267 @function : Render form-element (select) 268 @param : $key Name and ID of the form-element 269 @param : $arr Options as associative array 270 @param : $selected Values which should be selected 271 @return : string 351 * Render form-element (select) 352 * 353 * @since 0.1 354 * @param string $key MslsOptions property. 355 * @param array $arr option values and descriptions. 356 * @return string select and option tag. 357 * @access public 272 358 */ 273 359 public function render_select( $key, array $arr, $selected = '' ) { 360 if( ! is_scalar( $key ) || empty( $key ) ) return ''; 274 361 $options = array(); 275 362 … … 285 372 if( ! is_object( $this->cache['MslsOptions'] ) 286 373 || ! is_callable( array( $this->cache['MslsOptions'] , 'instance' ) ) ){ 287 return; 288 } 374 return ''; 375 } 376 $MslsOptions = MslsOptions::instance(); 377 if( ! isset( $MslsOptions->$key ) ) return ''; 289 378 return sprintf( 290 379 '<select id="%1$s" name="msls[%1$s]">%2$s</select>', … … 295 384 296 385 /** 297 @function : Filter Hook. MSLS Collection of blog-objects. 298 @param : $blogs_collection Collection of blog-objects 299 @return : array 300 */ 301 function msls_blog_collection_construct( $blogs_collection = array() ){ 386 * Filter Hook. MSLS Collection to group blog-objects. 387 * 388 * @since 0.1 389 * @param array $blogs_collection Collection of blog-objects. 390 * @return array Collection to group blog-objects. 391 * @access public 392 */ 393 public function msls_blog_collection_construct( $blogs_collection = array() ){ 302 394 $res = $blogs_collection; 303 395 if( function_exists( 'get_current_blog_id' ) ){ … … 319 411 320 412 $lang = get_option( 'WPLANG' ); 321 $lang = empty( $lang ) ? $this->emptyLang : $lang;413 $lang = empty( $lang ) ? $this->emptyLang[0] : $lang; 322 414 $langs = array(); 323 415 … … 334 426 $aGroup_key = empty( $aOptions['group_key'] ) ? $this->noGroup : $aOptions['group_key']; 335 427 $aLang = get_blog_option( $aBlog_id, 'WPLANG' ); 336 $aLang = empty( $aLang ) ? $this->emptyLang : $aLang;428 $aLang = empty( $aLang ) ? $this->emptyLang[0] : $aLang; 337 429 338 430 if( empty( $this->cache['blogs'] ) ) $this->cache['blogs'] = array(); … … 354 446 355 447 /** 356 @function : Get Same language Sites. 357 @param : $atts Option Array. 358 @param : $template HTML tag Template. 359 @return : HTML Tags or Array. 360 */ 361 function get_SameLangSites( $atts = '', $template = ''){ 448 * Get Same language Sites. 449 * 450 * @since 0.1 451 * @param mix $atts Option Array. 452 * @param string $template HTML tag Template. 453 * @return string HTML Tags or Array. 454 * @access public 455 */ 456 public function get_SameLangSites( $atts = '', $template = ''){ 362 457 $res = null; 363 458 … … 372 467 $blog_id = $current_blog['blog_id']; 373 468 $lang = $current_blog['language']; 469 $lang = empty( $lang ) ? $this->emptyLang[0] : $lang; 374 470 $group_key = $current_blog['group_key']; 375 471 $grpstr = $current_blog['group_str']; … … 398 494 } 399 495 $res = $Siblings = apply_filters( 'asm_SameLangSites_array', (array) $Siblings ); 496 497 $mslsOptions = null; 498 if( class_exists( 'MslsOptions' ) && is_callable( 'MslsOptions::instance' ) ){ 499 $mslsOptions = MslsOptions::instance(); 500 if( is_object( $mslsOptions ) && is_callable( array( $mslsOptions, 'get_flag_url' ) ) ){ 501 $flag_url = $mslsOptions->get_flag_url( $lang ); 502 } 503 } 400 504 401 505 $args['raw'] = is_scalar( $args['raw'] ) ? strtolower( trim( $args['raw'] ) ) : (bool) $args['raw']; … … 412 516 $bval = str_replace( "%id%", $akey, $bval ); 413 517 $bval = str_replace( "%lang%", $lang, $bval ); 518 $bval = str_replace( "%flag_url%", $flag_url, $bval ); 414 519 $bval = str_replace( "%group%", $grpstr, $bval ); 415 520 $ali = str_replace( "%{$bkey}%", $bval, $ali ); … … 430 535 } 431 536 537 /** 538 * Filter Hook. Blogs Columns to add 'Language' column in sites table. 539 * 540 * @since 0.2 541 * @param array $sites_columns Columns in WP_MS_Sites_List_Table. 542 * @return array columns. 543 * @access public 544 */ 545 public function wpmu_blogs_columns( $sites_columns = array() ){ 546 global $asm_textdomain; 547 $res = array(); 548 $arr = (array) $sites_columns; 549 $addkey = 'language'; 550 $addName = __( "Language", $asm_textdomain ) . ' (' . __( "Group Key", $asm_textdomain ) . ')'; 551 reset( $arr ); 552 if( empty( $arr[ $addkey ] ) ){ 553 foreach( $arr as $akey => $aval ){ 554 $res[$akey] = $aval; 555 if( $akey == 'blogname' ){ 556 $res[ $addkey ] = $addName; 557 if( empty( $this->cache['addCSS'] ) ) $this->cache['addCSS'] = array(); 558 $this->cache['addCSS'][$addkey] = <<<EOS 559 /* Language Column in Sites List */ 560 table.sites th.column-language , 561 table.sites td.column-language { 562 width : 15%; 563 } 564 table.sites .column-language .attantion { 565 color : red; 566 EOS; 567 } 568 } 569 } 570 571 return $res; 572 } 573 574 /** 575 * Action Hook. Admin print fotter scripts. 576 * 577 * @since 0.2 578 * @access public 579 */ 580 public function admin_print_footer_scripts(){ 581 if( ! empty( $this->cache['addScripts'] ) && is_array( $this->cache['addScripts'] ) ){ 582 $scripts = ''; 583 foreach( $this->cache['addScripts'] as $akey => $aval ){ 584 $scripts .= $aval . "\n"; 585 } 586 $scripts = trim( $scripts ); 587 $style = <<<EOS 588 <script type="text/javascript"> 589 {$scripts} 590 </script> 591 592 EOS; 593 echo $style; 594 } 595 if( ! empty( $this->cache['addCSS'] ) && is_array( $this->cache['addCSS'] ) ){ 596 $css = ''; 597 foreach( $this->cache['addCSS'] as $akey => $aval ){ 598 $css .= $aval . "\n"; 599 } 600 $css = trim( $css ); 601 $style = <<<EOS 602 <style type="text/css"> 603 {$css} 604 </style> 605 606 EOS; 607 echo $style; 608 } 609 } 610 611 /** 612 * Get current blog language. 613 * 614 * @since 0.2 615 * @param init $blog_id Blog ID. 616 * @return array blog locale adn group key, language name, language flag url. 617 * @access public 618 */ 619 public function get_current_blog_language( $blog_id = 0 ){ 620 global $asm_textdomain; 621 622 $blog_id = (int) $blog_id; 623 if ( empty( $blog_id ) ) 624 $blog_id = get_current_blog_id(); 625 if ( get_current_blog_id() == $blog_id ){ 626 $locale = get_option('WPLANG'); 627 $msls = get_option('msls'); 628 } 629 else 630 { 631 switch_to_blog( $blog_id ); 632 $locale = get_option('WPLANG'); 633 $msls = get_option('msls'); 634 restore_current_blog(); 635 } 636 637 $locale = empty( $locale ) ? $this->emptyLang[1] : $locale; 638 $msls = empty( $msls ) ? array() : (array) $msls; 639 $group_key = $msls['group_key']; 640 $group_key = $group_key == $this->noGroup ? '' : $group_key; 641 $langName = empty( $msls['description'] ) ? $locale : $msls['description']; 642 $flag_url = ''; 643 if( class_exists( 'MslsOptions' ) && is_callable( 'MslsOptions::instance' ) ){ 644 $mslsOptions = MslsOptions::instance(); 645 if( is_callable( array( $mslsOptions, 'get_flag_url' ) ) ){ 646 $flag_url = MslsOptions::instance()->get_flag_url( $locale ); 647 } 648 } 649 $options = compact( 'locale', 'group_key', 'langName', 'flag_url', 'msls' ); 650 return apply_filters( 651 "asm_get_current_blog_language", 652 $options, 653 $blog_id 654 ); 655 } 656 657 /** 658 * Action Hook. 'Language' column on manage_sites_custom_column. 659 * 660 * @since 0.2 661 * @param string $column_name current column name. 662 * @param string $blog_id Blog ID. 663 * @access public 664 */ 665 public function manage_sites_custom_column( $column_name = '', $blog_id = 0 ){ 666 global $asm_textdomain; 667 $Colmuns = array( 'language' ); 668 if( ! in_array( $column_name, $Colmuns ) ){ 669 return; 670 } 671 if( $column_name == 'language' ){ 672 $options = $this->get_current_blog_language( $blog_id ); 673 extract( $options ); 674 675 $flagImg = empty( $flag_url ) ? '' : <<<EOS 676 <img alt="{$locale}" src="{$flag_url}" class="language-flag"> 677 EOS; 678 $grpSpan = empty( $group_key ) ? '' : <<<EOS 679 <span class="language-group">{$group_key}</span> 680 EOS; 681 $grpSpan = empty( $grpSpan ) ? '' : <<<EOS 682 683 <p class="blog-groupkey">({$grpSpan})</p> 684 685 EOS; 686 $noMsls = ! empty( $msls ) ? '' : __( "'Multisite Language Switcher' is unestablished.", $asm_textdomain ); 687 $noMsls = empty( $noMsls ) ? '' : <<<EOS 688 <p class="attantion">{$noMsls}</p> 689 690 EOS; 691 $tags = <<<EOS 692 <p class="blog-Languages">{$flagImg}<span class="language-name">{$langName}</span></p>{$grpSpan}{$noMsls} 693 694 EOS; 695 $columnTitle = ucfirst( $column_name ); 696 echo apply_filters( 697 "asm_{$columnTitle}Column", 698 $tags, 699 $column_name, 700 $blog_id, 701 $options 702 ); 703 } 704 705 } 706 707 /** 708 * Action Hook. Language Flags on admin_bar_menu. 709 * 710 * Add CSS and Javascripts to show language flugs on Admin-Bar. 711 * 712 * @since 0.2 713 * @param object $wp_admin_bar WP Admin-bar. 714 * @access public 715 */ 716 public function admin_bar_menu( $wp_admin_bar ){ 717 global $asm_textdomain; 718 $options = $this->get_current_blog_language(); 719 extract( $options ); 720 721 $grpSpan = empty( $group_key ) ? '' : <<<EOS 722 " [{$group_key}]" 723 EOS; 724 725 if( empty( $this->cache['addCSS'] ) ) $this->cache['addCSS'] = array(); 726 727 $flags = array(); 728 foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { 729 $aOptions = $this->get_current_blog_language( $blog->userblog_id ); 730 $aBlogID = "blog-{$blog->userblog_id}"; 731 $linkID = "#wp-admin-bar-{$aBlogID}"; 732 $flags[$aOptions['locale']] = $aOptions['flag_url']; 733 $gkClass = empty( $aOptions['group_key'] ) ? '' : urlencode( $aOptions['group_key'] ); 734 735 $this->cache['addScripts'][$aBlogID] = <<<EOS 736 jQuery("{$linkID}").addClass("blog-language-{$aOptions['locale']}"); 737 if( "{$gkClass}" != "" ) jQuery("{$linkID}").addClass("blog-group-{$gkClass}"); 738 739 EOS; 740 } 741 foreach ( $flags as $akey => $aval ) { 742 $this->cache['addCSS']['lang-' . $akey] = <<<EOS 743 #wpadminbar .quicklinks li.blog-language-{$akey} .blavatar::before { 744 content: url({$aval}); 745 } 746 EOS; 747 } 748 749 if( ! is_network_admin() ){ 750 $this->cache['addCSS']['site-name'] = <<<EOS 751 .wp-admin #wpadminbar #wp-admin-bar-site-name > .ab-item::before , 752 #wpadminbar #wp-admin-bar-site-name > .ab-item::before { 753 content: url({$flag_url}){$grpSpan}; 754 margin: 0.25em 0.25em 0.1em 0; 755 font-size: 1em; 756 } 757 EOS; 758 } 759 } 760 761 /** 762 * Action Hook. Deficient cancellation on Options General. 763 * 764 * @since 0.2 765 * @param object $wp_admin_bar WP Admin-bar. 766 * @access public 767 */ 768 public function load_options_general(){ 769 $lang = get_option( 'WPLANG' ); 770 $this->cache['addScripts']['options_general'] = <<<EOS 771 if( jQuery("select#WPLANG option:selected").val() == "{$lang}" ){ 772 } 773 else 774 if(jQuery("select#WPLANG option").is("[data-installed][value='{$lang}']")){ 775 jQuery("select#WPLANG option:selected").removeAttr("selected"); 776 jQuery("select#WPLANG option[data-installed][value='{$lang}']").attr("selected","selected"); 777 } 778 EOS; 779 } 780 432 781 } 433 782 … … 437 786 438 787 /** 439 * @class Same Language Sites Widgets 440 */ 788 * Same Language Sites Widgets Class. 789 * 790 * @since 0.1 791 * @see WP_Widget 792 **/ 441 793 class asm_SameLangSites_Widget extends WP_Widget { 442 794 795 /** 796 * Form defaults. 797 * 798 * @since 0.1 799 * @var array 800 * @access private 801 */ 443 802 private $form_defs = array( 444 803 'title' => '', … … 446 805 447 806 /** 448 @function : Sets up a new Archives widget instance. 449 @param : void 450 @return : void 807 * Sets up a new Same Language Sites widget instance. 808 * 809 * @since 0.1 810 * @access public 451 811 */ 452 812 public function __construct() { … … 463 823 464 824 /** 465 @function : Outputs the content for the current Archives widget instance. 466 @param : $args Display arguments including 'before_title', 'after_title', 467 'before_widget', and 'after_widget'. 468 @param : $instance Settings for the current Archives widget instance. 469 @return : void 825 * Outputs the content for the current Same Language Sites widget instance. 826 * 827 * @since 0.1 828 * @access public 829 * 830 * @param array $args Display arguments including 'before_title', 'after_title', 831 * 'before_widget', and 'after_widget'. 832 * @param array $instance Settings for the current Same Language Sites widget instance. 470 833 */ 471 834 public function widget( $args, $instance ) { … … 495 858 496 859 /** 497 @function : Handles updating settings for the current Archives widget instance. 498 @param : $new_instance New settings for this instance as input by the user via 499 WP_Widget_Archives::form(). 500 @param : $old_instance Old settings for this instance. 501 @return : array Updated settings to save. 860 * Handles updating settings for the current Same Language Sites widget instance. 861 * 862 * @since 0.1 863 * @access public 864 * 865 * @param array $new_instance New settings for this instance as input by the user via 866 * asm_SameLangSites_Widget::form(). 867 * @param array $old_instance Old settings for this instance. 868 * @return array Updated settings to save. 502 869 */ 503 870 public function update( $new_instance, $old_instance ) { … … 515 882 516 883 /** 517 * Outputs the settings form for the Archives widget.884 * Outputs the settings form for the Same Language Sites widget. 518 885 * 519 886 * @since 2.8.0 … … 521 888 * 522 889 * @param array $instance Current settings. 523 @function : Outputs the settings form for the Archives widget.524 @param : $instance Current settings.525 @return : void526 890 */ 527 891 public function form( $instance ) { -
msls-gouping/trunk/languages/asm-msls-grouping-ja.po
r1594566 r1604369 3 3 "Project-Id-Version: asm-MSLS-Grouping\n" 4 4 "POT-Creation-Date: 2017-02-11 21:03+0900\n" 5 "PO-Revision-Date: 2017-02- 11 21:04+0900\n"5 "PO-Revision-Date: 2017-02-24 20:34+0900\n" 6 6 "Last-Translator: Asumaru <[email protected]>\n" 7 7 "Language-Team: \n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 1.8.1 1\n"12 "X-Generator: Poedit 1.8.12\n" 13 13 "X-Poedit-Basepath: ..\n" 14 14 "Plural-Forms: nplurals=1; plural=0;\n" … … 20 20 "X-Poedit-SearchPath-1: inc\n" 21 21 22 #: inc/asm-MSLS-Grouping.php:13 222 #: inc/asm-MSLS-Grouping.php:133 inc/asm-MSLS-Grouping.php:513 23 23 msgid "Group Key" 24 24 msgstr "グループキー" 25 25 26 #: inc/asm-MSLS-Grouping.php:141 27 msgid "MSLS Gouping" 28 msgstr "マルチサイト言語スイッチャー グルーピング" 29 30 #: inc/asm-MSLS-Grouping.php:142 31 msgid "Asumaru" 32 msgstr "あすまる" 33 34 #: inc/asm-MSLS-Grouping.php:143 35 msgid "Asumaru Corp." 36 msgstr "(株)あすまる" 37 38 #: inc/asm-MSLS-Grouping.php:144 39 msgid "" 40 "You can multilingualize by 'Multisite Language Switcher' with grouping the " 41 "sites of the plural same languages." 42 msgstr "" 43 "複数の同じ言語のサイトをグループ分けすることで、「Multisite Language " 44 "Switcher」を使って多言語化できます。" 45 46 #: inc/asm-MSLS-Grouping.php:225 26 #: inc/asm-MSLS-Grouping.php:222 47 27 msgid "" 48 28 "(*) If there is some blogs with the same language, you define \"Group Key\" " … … 52 32 "キー」を定義します。" 53 33 54 #: inc/asm-MSLS-Grouping.php:456 34 #: inc/asm-MSLS-Grouping.php:434 35 msgid "Language" 36 msgstr "言語" 37 38 #: inc/asm-MSLS-Grouping.php:521 39 msgid "'Multisite Language Switcher' is unestablished." 40 msgstr "マルチサイト言語スイッチャーは未設定です。" 41 42 #: inc/asm-MSLS-Grouping.php:564 55 43 msgid "Same Language Sites List" 56 44 msgstr "同一言語サイト一覧" 57 45 58 #: inc/asm-MSLS-Grouping.php: 459 inc/asm-MSLS-Grouping.php:47646 #: inc/asm-MSLS-Grouping.php:567 inc/asm-MSLS-Grouping.php:584 59 47 msgid "Same Language Sites" 60 48 msgstr "同一言語サイト" 61 49 62 #: inc/asm-MSLS-Grouping.php: 53550 #: inc/asm-MSLS-Grouping.php:643 63 51 msgid "Title:" 64 52 msgstr "タイトル:" 65 53 66 #: inc/asm-MSLS-Grouping.php: 53754 #: inc/asm-MSLS-Grouping.php:645 67 55 msgid "Template:" 68 56 msgstr "テンプレート:" 57 58 #: inc/dictionary.php:8 59 msgid "Allow Duplicate Languages" 60 msgstr "言語の重複の許可" 61 62 #: inc/dictionary.php:9 63 msgid "" 64 "You allow for the same language to repeat in 'Multisite Language Switcher'." 65 msgstr "マルチサイト言語スイッチャーで重複した言語の繰り返しを許可します。" 66 67 #: inc/dictionary.php:10 68 msgid "MSLS Gouping" 69 msgstr "マルチサイト言語スイッチャー グルーピング" 70 71 #: inc/dictionary.php:11 72 msgid "Asumaru" 73 msgstr "あすまる" 74 75 #: inc/dictionary.php:12 76 msgid "Asumaru Corp." 77 msgstr "(株)あすまる" 78 79 #: inc/dictionary.php:13 80 msgid "" 81 "You can multilingualize by 'Multisite Language Switcher' with grouping the " 82 "sites of the plural same languages." 83 msgstr "" 84 "複数の同じ言語のサイトをグループ分けすることで、「Multisite Language " 85 "Switcher」を使って多言語化できます。" -
msls-gouping/trunk/languages/asm-msls-grouping-ja_JP.po
r1594566 r1604369 2 2 msgstr "" 3 3 "Project-Id-Version: asm-MSLS-Grouping\n" 4 "POT-Creation-Date: 2017-02- 11 21:05+0900\n"5 "PO-Revision-Date: 2017-02- 11 21:05+0900\n"4 "POT-Creation-Date: 2017-02-24 20:29+0900\n" 5 "PO-Revision-Date: 2017-02-24 20:32+0900\n" 6 6 "Last-Translator: Asumaru <[email protected]>\n" 7 7 "Language-Team: \n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 1.8.1 1\n"12 "X-Generator: Poedit 1.8.12\n" 13 13 "X-Poedit-Basepath: ..\n" 14 14 "Plural-Forms: nplurals=1; plural=0;\n" … … 20 20 "X-Poedit-SearchPath-1: inc\n" 21 21 22 #: inc/asm-MSLS-Grouping.php:13 222 #: inc/asm-MSLS-Grouping.php:133 inc/asm-MSLS-Grouping.php:513 23 23 msgid "Group Key" 24 24 msgstr "グループキー" 25 25 26 #: inc/asm-MSLS-Grouping.php:141 27 msgid "MSLS Gouping" 28 msgstr "マルチサイト言語スイッチャー グルーピング" 29 30 #: inc/asm-MSLS-Grouping.php:142 31 msgid "Asumaru" 32 msgstr "あすまる" 33 34 #: inc/asm-MSLS-Grouping.php:143 35 msgid "Asumaru Corp." 36 msgstr "(株)あすまる" 37 38 #: inc/asm-MSLS-Grouping.php:144 39 msgid "" 40 "You can multilingualize by 'Multisite Language Switcher' with grouping the " 41 "sites of the plural same languages." 42 msgstr "" 43 "複数の同じ言語のサイトをグループ分けすることで、「Multisite Language " 44 "Switcher」を使って多言語化できます。" 45 46 #: inc/asm-MSLS-Grouping.php:225 26 #: inc/asm-MSLS-Grouping.php:222 47 27 msgid "" 48 28 "(*) If there is some blogs with the same language, you define \"Group Key\" " … … 52 32 "キー」を定義します。" 53 33 54 #: inc/asm-MSLS-Grouping.php:456 34 #: inc/asm-MSLS-Grouping.php:434 35 msgid "Language" 36 msgstr "言語" 37 38 #: inc/asm-MSLS-Grouping.php:521 39 msgid "'Multisite Language Switcher' is unestablished." 40 msgstr "マルチサイト言語スイッチャーは未設定です。" 41 42 #: inc/asm-MSLS-Grouping.php:564 55 43 msgid "Same Language Sites List" 56 44 msgstr "同一言語サイト一覧" 57 45 58 #: inc/asm-MSLS-Grouping.php: 459 inc/asm-MSLS-Grouping.php:47646 #: inc/asm-MSLS-Grouping.php:567 inc/asm-MSLS-Grouping.php:584 59 47 msgid "Same Language Sites" 60 48 msgstr "同一言語サイト" 61 49 62 #: inc/asm-MSLS-Grouping.php: 53550 #: inc/asm-MSLS-Grouping.php:643 63 51 msgid "Title:" 64 52 msgstr "タイトル:" 65 53 66 #: inc/asm-MSLS-Grouping.php: 53754 #: inc/asm-MSLS-Grouping.php:645 67 55 msgid "Template:" 68 56 msgstr "テンプレート:" 57 58 #: inc/dictionary.php:8 59 msgid "Allow Duplicate Languages" 60 msgstr "言語の重複の許可" 61 62 #: inc/dictionary.php:9 63 msgid "" 64 "You allow for the same language to repeat in 'Multisite Language Switcher'." 65 msgstr "マルチサイト言語スイッチャーで重複した言語の繰り返しを許可します。" 66 67 #: inc/dictionary.php:10 68 msgid "MSLS Gouping" 69 msgstr "マルチサイト言語スイッチャー グルーピング" 70 71 #: inc/dictionary.php:11 72 msgid "Asumaru" 73 msgstr "あすまる" 74 75 #: inc/dictionary.php:12 76 msgid "Asumaru Corp." 77 msgstr "(株)あすまる" 78 79 #: inc/dictionary.php:13 80 msgid "" 81 "You can multilingualize by 'Multisite Language Switcher' with grouping the " 82 "sites of the plural same languages." 83 msgstr "" 84 "複数の同じ言語のサイトをグループ分けすることで、「Multisite Language " 85 "Switcher」を使って多言語化できます。" -
msls-gouping/trunk/languages/asm-msls-grouping.pot
r1594566 r1604369 3 3 msgstr "" 4 4 "Project-Id-Version: asm-MSLS-Grouping\n" 5 "POT-Creation-Date: 2017-02- 11 21:03+0900\n"5 "POT-Creation-Date: 2017-02-24 20:27+0900\n" 6 6 "PO-Revision-Date: 2017-02-11 17:12+0900\n" 7 7 "Last-Translator: Asumaru <[email protected]>\n" … … 11 11 "Content-Type: text/plain; charset=UTF-8\n" 12 12 "Content-Transfer-Encoding: 8bit\n" 13 "X-Generator: Poedit 1.8.1 1\n"13 "X-Generator: Poedit 1.8.12\n" 14 14 "X-Poedit-Basepath: ..\n" 15 15 "Plural-Forms: nplurals=2; plural=(n != 1);\n" … … 20 20 "X-Poedit-SearchPath-1: inc\n" 21 21 22 #: inc/asm-MSLS-Grouping.php:13 222 #: inc/asm-MSLS-Grouping.php:133 inc/asm-MSLS-Grouping.php:513 23 23 msgid "Group Key" 24 24 msgstr "" 25 25 26 #: inc/asm-MSLS-Grouping.php:141 26 #: inc/asm-MSLS-Grouping.php:222 27 msgid "(*) If there is some blogs with the same language, you define \"Group Key\" to same blog-set." 28 msgstr "" 29 30 #: inc/asm-MSLS-Grouping.php:434 31 msgid "Language" 32 msgstr "" 33 34 #: inc/asm-MSLS-Grouping.php:521 35 msgid "'Multisite Language Switcher' is unestablished." 36 msgstr "" 37 38 #: inc/asm-MSLS-Grouping.php:564 39 msgid "Same Language Sites List" 40 msgstr "" 41 42 #: inc/asm-MSLS-Grouping.php:567 inc/asm-MSLS-Grouping.php:584 43 msgid "Same Language Sites" 44 msgstr "" 45 46 #: inc/asm-MSLS-Grouping.php:643 47 msgid "Title:" 48 msgstr "" 49 50 #: inc/asm-MSLS-Grouping.php:645 51 msgid "Template:" 52 msgstr "" 53 54 #: inc/dictionary.php:8 55 msgid "Allow Duplicate Languages" 56 msgstr "" 57 58 #: inc/dictionary.php:9 59 msgid "You allow for the same language to repeat in 'Multisite Language Switcher'." 60 msgstr "" 61 62 #: inc/dictionary.php:10 27 63 msgid "MSLS Gouping" 28 64 msgstr "" 29 65 30 #: inc/ asm-MSLS-Grouping.php:14266 #: inc/dictionary.php:11 31 67 msgid "Asumaru" 32 68 msgstr "" 33 69 34 #: inc/ asm-MSLS-Grouping.php:14370 #: inc/dictionary.php:12 35 71 msgid "Asumaru Corp." 36 72 msgstr "" 37 73 38 #: inc/ asm-MSLS-Grouping.php:14474 #: inc/dictionary.php:13 39 75 msgid "" 40 76 "You can multilingualize by 'Multisite Language Switcher' with grouping the sites of the plural " 41 77 "same languages." 42 78 msgstr "" 43 44 #: inc/asm-MSLS-Grouping.php:22545 msgid "(*) If there is some blogs with the same language, you define \"Group Key\" to same blog-set."46 msgstr ""47 48 #: inc/asm-MSLS-Grouping.php:45649 msgid "Same Language Sites List"50 msgstr ""51 52 #: inc/asm-MSLS-Grouping.php:459 inc/asm-MSLS-Grouping.php:47653 msgid "Same Language Sites"54 msgstr ""55 56 #: inc/asm-MSLS-Grouping.php:53557 msgid "Title:"58 msgstr ""59 60 #: inc/asm-MSLS-Grouping.php:53761 msgid "Template:"62 msgstr "" -
msls-gouping/trunk/languages/default.pot
r1594566 r1604369 3 3 msgstr "" 4 4 "Project-Id-Version: asm-MSLS-Grouping\n" 5 "POT-Creation-Date: 2017-02- 11 21:02+0900\n"5 "POT-Creation-Date: 2017-02-24 20:26+0900\n" 6 6 "PO-Revision-Date: 2017-02-11 17:12+0900\n" 7 7 "Last-Translator: Asumaru <[email protected]>\n" … … 11 11 "Content-Type: text/plain; charset=UTF-8\n" 12 12 "Content-Transfer-Encoding: 8bit\n" 13 "X-Generator: Poedit 1.8.1 1\n"13 "X-Generator: Poedit 1.8.12\n" 14 14 "X-Poedit-Basepath: ..\n" 15 15 "Plural-Forms: nplurals=2; plural=(n != 1);\n" … … 20 20 "X-Poedit-SearchPath-1: inc\n" 21 21 22 #: inc/asm-MSLS-Grouping.php:13 222 #: inc/asm-MSLS-Grouping.php:133 inc/asm-MSLS-Grouping.php:513 23 23 msgid "Group Key" 24 24 msgstr "" 25 25 26 #: inc/asm-MSLS-Grouping.php:141 26 #: inc/asm-MSLS-Grouping.php:222 27 msgid "(*) If there is some blogs with the same language, you define \"Group Key\" to same blog-set." 28 msgstr "" 29 30 #: inc/asm-MSLS-Grouping.php:434 31 msgid "Language" 32 msgstr "" 33 34 #: inc/asm-MSLS-Grouping.php:521 35 msgid "'Multisite Language Switcher' is unestablished." 36 msgstr "" 37 38 #: inc/asm-MSLS-Grouping.php:564 39 msgid "Same Language Sites List" 40 msgstr "" 41 42 #: inc/asm-MSLS-Grouping.php:567 inc/asm-MSLS-Grouping.php:584 43 msgid "Same Language Sites" 44 msgstr "" 45 46 #: inc/asm-MSLS-Grouping.php:643 47 msgid "Title:" 48 msgstr "" 49 50 #: inc/asm-MSLS-Grouping.php:645 51 msgid "Template:" 52 msgstr "" 53 54 #: inc/dictionary.php:8 55 msgid "Allow Duplicate Languages" 56 msgstr "" 57 58 #: inc/dictionary.php:9 59 msgid "You allow for the same language to repeat in 'Multisite Language Switcher'." 60 msgstr "" 61 62 #: inc/dictionary.php:10 27 63 msgid "MSLS Gouping" 28 64 msgstr "" 29 65 30 #: inc/ asm-MSLS-Grouping.php:14266 #: inc/dictionary.php:11 31 67 msgid "Asumaru" 32 68 msgstr "" 33 69 34 #: inc/ asm-MSLS-Grouping.php:14370 #: inc/dictionary.php:12 35 71 msgid "Asumaru Corp." 36 72 msgstr "" 37 73 38 #: inc/ asm-MSLS-Grouping.php:14474 #: inc/dictionary.php:13 39 75 msgid "" 40 76 "You can multilingualize by 'Multisite Language Switcher' with grouping the sites of the plural " 41 77 "same languages." 42 78 msgstr "" 43 44 #: inc/asm-MSLS-Grouping.php:22545 msgid "(*) If there is some blogs with the same language, you define \"Group Key\" to same blog-set."46 msgstr ""47 48 #: inc/asm-MSLS-Grouping.php:45649 msgid "Same Language Sites List"50 msgstr ""51 52 #: inc/asm-MSLS-Grouping.php:459 inc/asm-MSLS-Grouping.php:47653 msgid "Same Language Sites"54 msgstr ""55 56 #: inc/asm-MSLS-Grouping.php:53557 msgid "Title:"58 msgstr ""59 60 #: inc/asm-MSLS-Grouping.php:53761 msgid "Template:"62 msgstr "" -
msls-gouping/trunk/readme.txt
r1596208 r1604369 1 === Plugin Name===1 === MSLS Grouping === 2 2 Contributors: Asumaru 3 Donate link: http://asumaru.com/ 4 Tags: multilingual, multisite, language, switcher, international, localization, i18n, grouping 3 Donate link: http://asumaru.com/business/wp-plugins/asm-msls-grouping/ 4 Tags: multilingual, multisite, language, switcher, international, localization, i18n, grouping, flag, WPLANG 5 5 Requires at least: 4.6 6 6 Tested up to: 4.7.2 7 Stable tag: 0. 17 Stable tag: 0.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 19 19 * Site A (Japanese) example-site.com/jp/ 20 20 * Site B (English) example-site.com/siteB/ 21 * Site B (Japanese) example-site.com/siteB -jp/21 * Site B (Japanese) example-site.com/siteB/jp/ 22 22 * Site C (English) example-site.com/siteC/ 23 * Site C (Japanese) example-site.com/siteC -jp/23 * Site C (Japanese) example-site.com/siteC/jp/ 24 24 25 25 "Multisite Language Switcher" cannot tell the difference between site A, site B and site C. … … 37 37 * Site A (English) => Site B (English), Site C (English) 38 38 * Site B (Japanese) => Site A (Japanese), Site C (Japanese) 39 40 And, it provide "Language" column on the Table of Sites in network. 41 42 And, it provide "Language Flag" in Admin-Bar. 39 43 40 44 == Installation == … … 59 63 * %after_item% : Suffix of the list item. 60 64 65 = How do you not come to display language column on the Table of Sites in network? = 66 You must add the following cord to functions.php in the theme. 67 > add_filter( 'asm_language-column.blogs.network', create_function( '', 'return false;' ) ); 68 69 = How do you not come to display language flags? = 70 You must add the following cord to functions.php in the theme. 71 > add_filter( 'asm_language-flags.admin-bar', create_function( '', 'return false;' ) ); 72 73 = How do you not come to force WPLANG in the setting-general? = 74 You must add the following cord to functions.php in the theme. 75 > add_filter( 'asm_force_WPLANG.options_general', create_function( '', 'return false;' ) ); 76 61 77 == Screenshots == 62 78 … … 75 91 7. e.g. Japanese Site. 76 92 93 8. Language flags in Admin-Bar. 94 77 95 == Changelog == 78 96 … … 80 98 * created 2017.01.01. 81 99 100 = 0.2 = 101 * po/mo files updated. 102 * Language column on the Table of Sites in network added. 103 * Language flags in Admin-Bar displayed. 104 * Malfunction of WPLANG in the setting-general supported. 105 82 106 == Upgrade Notice == 83 107
Note: See TracChangeset
for help on using the changeset viewer.