Plugin Directory

Changeset 1604369


Ignore:
Timestamp:
02/27/2017 09:50:17 AM (9 years ago)
Author:
Asumaru
Message:

0.2

  • po/mo files updated.
  • Language column on the Table of Sites in network added.
  • Language flags in Admin-Bar displayed.
  • Malfunction of WPLANG in the setting-general supported.
Location:
msls-gouping/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • msls-gouping/trunk/asm-MSLS-Grouping.php

    r1594566 r1604369  
    55Description: You can multilingualize by 'Multisite Language Switcher' with grouping the sites of the plural same languages.
    66Author: Asumaru Corp.
    7 Version: 0.1
     7Version: 0.2
    88Author URI: http://asumaru.com/
    99Created: 2017.01.01
  • msls-gouping/trunk/inc/asm-MSLS-Grouping.php

    r1594566 r1604369  
    55Description: You can multilingualize by 'Multisite Language Switcher' with grouping the sites of the plural same languages.
    66Author: Asumaru Corp.
    7 Version: 0.1
     7Version: 0.2
    88Author URI: http://asumaru.com/
    99Created: 2017.01.01
     10Updated: 2017.03.01
    1011
    1112*/
    1213
     14/**
     15 * Global variable. Orignal text domain.
     16 *
     17 * @since 0.1
     18**/
    1319$asm_textdomain = 'asm-msls-grouping';
    1420
    15 
    1621/**
    17     @class : Base Class
     22 * Core class.
     23 *
     24 * @since 0.1
    1825**/
    1926class asm_MSLS_Grouping_Class{
    2027
    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(
    2454        'atts'  => array(
    2555            'name'  => '',
     
    2757        ),
    2858        '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'." ),
    3060        ),
    3161        'sc_args'   => array(
     
    4777',
    4878    );
    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(){
    62114        add_action( 'init', array( &$this, 'init'), 20);
    63115
    64116        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
    69120        add_action( 'plugins_loaded', array( &$this, 'load_plugin_textdomain' ), 20);
    70121
    71         // Regist Widget
    72122        add_action( 'widgets_init', create_function('', 'return register_widget("asm_SameLangSites_Widget");') );
    73123
    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(){
    83137        return $this->asm_MSLS_Grouping_Class();
    84138    }
    85139
    86140    /**
    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){
    93150        if( method_exists( $this, $name)){
    94151            return call_user_func_array( array( &$this, $name), $args);
     
    108165
    109166    /**
    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(){
    115173        if( class_exists( 'MslsOptions' ) ){
    116174            $this->cache['MslsOptions'] = new MslsOptions();
     
    123181
    124182    /**
    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(){
    130189        global $asm_textdomain;
    131190        if( function_exists( 'add_settings_field' ) ){
     
    135194        add_action( 'wpmu_options', array( &$this, 'wpmu_options' ), 20 );
    136195        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(){
    153213        global $asm_textdomain;
    154214        $dir = dirname( __FILE__);
     
    163223    }
    164224
    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 ){
    166235        global $asm_textdomain;
    167236        $res = $locale;
     
    170239
    171240    /**
    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(){
    177247        foreach( (array) $this->defaults['site_options'] as $akey => $aval ){
    178248            if( $_POST[$akey] === null || $_POST[$akey] === false ){
     
    188258
    189259    /**
    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;
    195267        foreach( (array) $this->defaults['site_options'] as $akey => $aval ){
    196268            switch( $aval[1] ){
     
    215287
    216288    /**
    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(){
    222295        global $asm_textdomain;
    223296        echo $this->render_input( 'group_key', '40' );
     
    227300    }
    228301
    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
    234309     */
    235310    public function render_checkbox( $key ) {
     311        if( ! is_scalar( $key ) ) return '';
    236312        if( ! is_object( $this->cache['MslsOptions'] )
    237313        || ! is_callable( array( $this->cache['MslsOptions'] , 'instance' ) ) ){
    238             return;
    239         }
     314            return '';
     315        }
     316        $MslsOptions = MslsOptions::instance();
     317        if( ! isset( $MslsOptions->$key ) ) return '';
    240318        return sprintf(
    241319            '<input type="checkbox" id="%1$s" name="msls[%1$s]" value="1" %2$s/>',
    242320            $key,
    243             checked( 1, MslsOptions::instance()->$key, false )
     321            checked( 1, $MslsOptions->$key, false )
    244322        );
    245323    }
    246324
    247325    /**
    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
    252333     */
    253334    public function render_input( $key, $size = '30' ) {
     335        if( ! is_scalar( $key ) || empty( $key ) ) return '';
    254336        if( ! is_object( $this->cache['MslsOptions'] )
    255337        || ! is_callable( array( $this->cache['MslsOptions'] , 'instance' ) ) ){
    256             return;
    257         }
     338            return '';
     339        }
     340        $MslsOptions = MslsOptions::instance();
     341        if( ! isset( $MslsOptions->$key ) ) return '';
    258342        return sprintf(
    259343            '<input id="%1$s" name="msls[%1$s]" value="%2$s" size="%3$s"/>',
    260344            $key,
    261             esc_attr( MslsOptions::instance()->$key ),
     345            esc_attr( $MslsOptions->$key ),
    262346            $size
    263347        );
     
    265349
    266350    /**
    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
    272358     */
    273359    public function render_select( $key, array $arr, $selected = '' ) {
     360        if( ! is_scalar( $key ) || empty( $key ) ) return '';
    274361        $options = array();
    275362
     
    285372        if( ! is_object( $this->cache['MslsOptions'] )
    286373        || ! is_callable( array( $this->cache['MslsOptions'] , 'instance' ) ) ){
    287             return;
    288         }
     374            return '';
     375        }
     376        $MslsOptions = MslsOptions::instance();
     377        if( ! isset( $MslsOptions->$key ) ) return '';
    289378        return sprintf(
    290379            '<select id="%1$s" name="msls[%1$s]">%2$s</select>',
     
    295384
    296385    /**
    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() ){
    302394        $res = $blogs_collection;
    303395        if( function_exists( 'get_current_blog_id' ) ){
     
    319411
    320412        $lang = get_option( 'WPLANG' );
    321         $lang = empty( $lang ) ? $this->emptyLang : $lang;
     413        $lang = empty( $lang ) ? $this->emptyLang[0] : $lang;
    322414        $langs = array();
    323415
     
    334426            $aGroup_key = empty( $aOptions['group_key'] ) ? $this->noGroup : $aOptions['group_key'];
    335427            $aLang = get_blog_option( $aBlog_id, 'WPLANG' );
    336             $aLang = empty( $aLang ) ? $this->emptyLang : $aLang;
     428            $aLang = empty( $aLang ) ? $this->emptyLang[0] : $aLang;
    337429
    338430            if( empty( $this->cache['blogs'] ) ) $this->cache['blogs'] = array();
     
    354446
    355447    /**
    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 = ''){
    362457        $res = null;
    363458
     
    372467        $blog_id = $current_blog['blog_id'];
    373468        $lang = $current_blog['language'];
     469        $lang = empty( $lang ) ? $this->emptyLang[0] : $lang;
    374470        $group_key = $current_blog['group_key'];
    375471        $grpstr = $current_blog['group_str'];
     
    398494        }
    399495        $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        }
    400504
    401505        $args['raw'] = is_scalar( $args['raw'] ) ? strtolower( trim( $args['raw'] ) ) : (bool) $args['raw'];
     
    412516                    $bval = str_replace( "%id%", $akey, $bval );
    413517                    $bval = str_replace( "%lang%", $lang, $bval );
     518                    $bval = str_replace( "%flag_url%", $flag_url, $bval );
    414519                    $bval = str_replace( "%group%", $grpstr, $bval );
    415520                    $ali = str_replace( "%{$bkey}%", $bval, $ali );
     
    430535    }
    431536
     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 */
     560table.sites th.column-language ,
     561table.sites td.column-language {
     562    width : 15%;
     563}
     564table.sites .column-language .attantion {
     565    color : red;
     566EOS;
     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
     592EOS;
     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
     606EOS;
     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">
     677EOS;
     678            $grpSpan = empty( $group_key ) ? '' : <<<EOS
     679<span class="language-group">{$group_key}</span>
     680EOS;
     681            $grpSpan = empty( $grpSpan ) ? '' : <<<EOS
     682
     683<p class="blog-groupkey">({$grpSpan})</p>
     684
     685EOS;
     686            $noMsls = ! empty( $msls ) ? '' : __( "'Multisite Language Switcher' is unestablished.", $asm_textdomain );
     687            $noMsls = empty( $noMsls ) ? '' : <<<EOS
     688<p class="attantion">{$noMsls}</p>
     689
     690EOS;
     691            $tags = <<<EOS
     692<p class="blog-Languages">{$flagImg}<span class="language-name">{$langName}</span></p>{$grpSpan}{$noMsls}
     693
     694EOS;
     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}]"
     723EOS;
     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
     739EOS;
     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}
     746EOS;
     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}
     757EOS;
     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    }
     778EOS;
     779    }
     780
    432781}
    433782
     
    437786
    438787/**
    439  * @class Same Language Sites Widgets
    440  */
     788 * Same Language Sites Widgets Class.
     789 *
     790 * @since 0.1
     791 * @see WP_Widget
     792**/
    441793class asm_SameLangSites_Widget extends WP_Widget {
    442794
     795    /**
     796     * Form defaults.
     797     *
     798     * @since 0.1
     799     * @var array
     800     * @access private
     801     */
    443802    private $form_defs = array(
    444803            'title' => '',
     
    446805
    447806    /**
    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
    451811     */
    452812    public function __construct() {
     
    463823
    464824    /**
    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.
    470833     */
    471834    public function widget( $args, $instance ) {
     
    495858
    496859    /**
    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.
    502869     */
    503870    public function update( $new_instance, $old_instance ) {
     
    515882
    516883    /**
    517      * Outputs the settings form for the Archives widget.
     884     * Outputs the settings form for the Same Language Sites widget.
    518885     *
    519886     * @since 2.8.0
     
    521888     *
    522889     * @param array $instance Current settings.
    523         @function : Outputs the settings form for the Archives widget.
    524         @param : $instance Current settings.
    525         @return : void
    526890     */
    527891    public function form( $instance ) {
  • msls-gouping/trunk/languages/asm-msls-grouping-ja.po

    r1594566 r1604369  
    33"Project-Id-Version: asm-MSLS-Grouping\n"
    44"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"
    66"Last-Translator: Asumaru <[email protected]>\n"
    77"Language-Team: \n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 1.8.11\n"
     12"X-Generator: Poedit 1.8.12\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=1; plural=0;\n"
     
    2020"X-Poedit-SearchPath-1: inc\n"
    2121
    22 #: inc/asm-MSLS-Grouping.php:132
     22#: inc/asm-MSLS-Grouping.php:133 inc/asm-MSLS-Grouping.php:513
    2323msgid "Group Key"
    2424msgstr "グループキー"
    2525
    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
    4727msgid ""
    4828"(*) If there is some blogs with the same language, you define \"Group Key\" "
     
    5232"キー」を定義します。"
    5333
    54 #: inc/asm-MSLS-Grouping.php:456
     34#: inc/asm-MSLS-Grouping.php:434
     35msgid "Language"
     36msgstr "言語"
     37
     38#: inc/asm-MSLS-Grouping.php:521
     39msgid "'Multisite Language Switcher' is unestablished."
     40msgstr "マルチサイト言語スイッチャーは未設定です。"
     41
     42#: inc/asm-MSLS-Grouping.php:564
    5543msgid "Same Language Sites List"
    5644msgstr "同一言語サイト一覧"
    5745
    58 #: inc/asm-MSLS-Grouping.php:459 inc/asm-MSLS-Grouping.php:476
     46#: inc/asm-MSLS-Grouping.php:567 inc/asm-MSLS-Grouping.php:584
    5947msgid "Same Language Sites"
    6048msgstr "同一言語サイト"
    6149
    62 #: inc/asm-MSLS-Grouping.php:535
     50#: inc/asm-MSLS-Grouping.php:643
    6351msgid "Title:"
    6452msgstr "タイトル:"
    6553
    66 #: inc/asm-MSLS-Grouping.php:537
     54#: inc/asm-MSLS-Grouping.php:645
    6755msgid "Template:"
    6856msgstr "テンプレート:"
     57
     58#: inc/dictionary.php:8
     59msgid "Allow Duplicate Languages"
     60msgstr "言語の重複の許可"
     61
     62#: inc/dictionary.php:9
     63msgid ""
     64"You allow for the same language to repeat in 'Multisite Language Switcher'."
     65msgstr "マルチサイト言語スイッチャーで重複した言語の繰り返しを許可します。"
     66
     67#: inc/dictionary.php:10
     68msgid "MSLS Gouping"
     69msgstr "マルチサイト言語スイッチャー グルーピング"
     70
     71#: inc/dictionary.php:11
     72msgid "Asumaru"
     73msgstr "あすまる"
     74
     75#: inc/dictionary.php:12
     76msgid "Asumaru Corp."
     77msgstr "(株)あすまる"
     78
     79#: inc/dictionary.php:13
     80msgid ""
     81"You can multilingualize by 'Multisite Language Switcher' with grouping the "
     82"sites of the plural same languages."
     83msgstr ""
     84"複数の同じ言語のサイトをグループ分けすることで、「Multisite Language "
     85"Switcher」を使って多言語化できます。"
  • msls-gouping/trunk/languages/asm-msls-grouping-ja_JP.po

    r1594566 r1604369  
    22msgstr ""
    33"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"
    66"Last-Translator: Asumaru <[email protected]>\n"
    77"Language-Team: \n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 1.8.11\n"
     12"X-Generator: Poedit 1.8.12\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=1; plural=0;\n"
     
    2020"X-Poedit-SearchPath-1: inc\n"
    2121
    22 #: inc/asm-MSLS-Grouping.php:132
     22#: inc/asm-MSLS-Grouping.php:133 inc/asm-MSLS-Grouping.php:513
    2323msgid "Group Key"
    2424msgstr "グループキー"
    2525
    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
    4727msgid ""
    4828"(*) If there is some blogs with the same language, you define \"Group Key\" "
     
    5232"キー」を定義します。"
    5333
    54 #: inc/asm-MSLS-Grouping.php:456
     34#: inc/asm-MSLS-Grouping.php:434
     35msgid "Language"
     36msgstr "言語"
     37
     38#: inc/asm-MSLS-Grouping.php:521
     39msgid "'Multisite Language Switcher' is unestablished."
     40msgstr "マルチサイト言語スイッチャーは未設定です。"
     41
     42#: inc/asm-MSLS-Grouping.php:564
    5543msgid "Same Language Sites List"
    5644msgstr "同一言語サイト一覧"
    5745
    58 #: inc/asm-MSLS-Grouping.php:459 inc/asm-MSLS-Grouping.php:476
     46#: inc/asm-MSLS-Grouping.php:567 inc/asm-MSLS-Grouping.php:584
    5947msgid "Same Language Sites"
    6048msgstr "同一言語サイト"
    6149
    62 #: inc/asm-MSLS-Grouping.php:535
     50#: inc/asm-MSLS-Grouping.php:643
    6351msgid "Title:"
    6452msgstr "タイトル:"
    6553
    66 #: inc/asm-MSLS-Grouping.php:537
     54#: inc/asm-MSLS-Grouping.php:645
    6755msgid "Template:"
    6856msgstr "テンプレート:"
     57
     58#: inc/dictionary.php:8
     59msgid "Allow Duplicate Languages"
     60msgstr "言語の重複の許可"
     61
     62#: inc/dictionary.php:9
     63msgid ""
     64"You allow for the same language to repeat in 'Multisite Language Switcher'."
     65msgstr "マルチサイト言語スイッチャーで重複した言語の繰り返しを許可します。"
     66
     67#: inc/dictionary.php:10
     68msgid "MSLS Gouping"
     69msgstr "マルチサイト言語スイッチャー グルーピング"
     70
     71#: inc/dictionary.php:11
     72msgid "Asumaru"
     73msgstr "あすまる"
     74
     75#: inc/dictionary.php:12
     76msgid "Asumaru Corp."
     77msgstr "(株)あすまる"
     78
     79#: inc/dictionary.php:13
     80msgid ""
     81"You can multilingualize by 'Multisite Language Switcher' with grouping the "
     82"sites of the plural same languages."
     83msgstr ""
     84"複数の同じ言語のサイトをグループ分けすることで、「Multisite Language "
     85"Switcher」を使って多言語化できます。"
  • msls-gouping/trunk/languages/asm-msls-grouping.pot

    r1594566 r1604369  
    33msgstr ""
    44"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"
    66"PO-Revision-Date: 2017-02-11 17:12+0900\n"
    77"Last-Translator: Asumaru <[email protected]>\n"
     
    1111"Content-Type: text/plain; charset=UTF-8\n"
    1212"Content-Transfer-Encoding: 8bit\n"
    13 "X-Generator: Poedit 1.8.11\n"
     13"X-Generator: Poedit 1.8.12\n"
    1414"X-Poedit-Basepath: ..\n"
    1515"Plural-Forms: nplurals=2; plural=(n != 1);\n"
     
    2020"X-Poedit-SearchPath-1: inc\n"
    2121
    22 #: inc/asm-MSLS-Grouping.php:132
     22#: inc/asm-MSLS-Grouping.php:133 inc/asm-MSLS-Grouping.php:513
    2323msgid "Group Key"
    2424msgstr ""
    2525
    26 #: inc/asm-MSLS-Grouping.php:141
     26#: inc/asm-MSLS-Grouping.php:222
     27msgid "(*) If there is some blogs with the same language, you define \"Group Key\" to same blog-set."
     28msgstr ""
     29
     30#: inc/asm-MSLS-Grouping.php:434
     31msgid "Language"
     32msgstr ""
     33
     34#: inc/asm-MSLS-Grouping.php:521
     35msgid "'Multisite Language Switcher' is unestablished."
     36msgstr ""
     37
     38#: inc/asm-MSLS-Grouping.php:564
     39msgid "Same Language Sites List"
     40msgstr ""
     41
     42#: inc/asm-MSLS-Grouping.php:567 inc/asm-MSLS-Grouping.php:584
     43msgid "Same Language Sites"
     44msgstr ""
     45
     46#: inc/asm-MSLS-Grouping.php:643
     47msgid "Title:"
     48msgstr ""
     49
     50#: inc/asm-MSLS-Grouping.php:645
     51msgid "Template:"
     52msgstr ""
     53
     54#: inc/dictionary.php:8
     55msgid "Allow Duplicate Languages"
     56msgstr ""
     57
     58#: inc/dictionary.php:9
     59msgid "You allow for the same language to repeat in 'Multisite Language Switcher'."
     60msgstr ""
     61
     62#: inc/dictionary.php:10
    2763msgid "MSLS Gouping"
    2864msgstr ""
    2965
    30 #: inc/asm-MSLS-Grouping.php:142
     66#: inc/dictionary.php:11
    3167msgid "Asumaru"
    3268msgstr ""
    3369
    34 #: inc/asm-MSLS-Grouping.php:143
     70#: inc/dictionary.php:12
    3571msgid "Asumaru Corp."
    3672msgstr ""
    3773
    38 #: inc/asm-MSLS-Grouping.php:144
     74#: inc/dictionary.php:13
    3975msgid ""
    4076"You can multilingualize by 'Multisite Language Switcher' with grouping the sites of the plural "
    4177"same languages."
    4278msgstr ""
    43 
    44 #: inc/asm-MSLS-Grouping.php:225
    45 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:456
    49 msgid "Same Language Sites List"
    50 msgstr ""
    51 
    52 #: inc/asm-MSLS-Grouping.php:459 inc/asm-MSLS-Grouping.php:476
    53 msgid "Same Language Sites"
    54 msgstr ""
    55 
    56 #: inc/asm-MSLS-Grouping.php:535
    57 msgid "Title:"
    58 msgstr ""
    59 
    60 #: inc/asm-MSLS-Grouping.php:537
    61 msgid "Template:"
    62 msgstr ""
  • msls-gouping/trunk/languages/default.pot

    r1594566 r1604369  
    33msgstr ""
    44"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"
    66"PO-Revision-Date: 2017-02-11 17:12+0900\n"
    77"Last-Translator: Asumaru <[email protected]>\n"
     
    1111"Content-Type: text/plain; charset=UTF-8\n"
    1212"Content-Transfer-Encoding: 8bit\n"
    13 "X-Generator: Poedit 1.8.11\n"
     13"X-Generator: Poedit 1.8.12\n"
    1414"X-Poedit-Basepath: ..\n"
    1515"Plural-Forms: nplurals=2; plural=(n != 1);\n"
     
    2020"X-Poedit-SearchPath-1: inc\n"
    2121
    22 #: inc/asm-MSLS-Grouping.php:132
     22#: inc/asm-MSLS-Grouping.php:133 inc/asm-MSLS-Grouping.php:513
    2323msgid "Group Key"
    2424msgstr ""
    2525
    26 #: inc/asm-MSLS-Grouping.php:141
     26#: inc/asm-MSLS-Grouping.php:222
     27msgid "(*) If there is some blogs with the same language, you define \"Group Key\" to same blog-set."
     28msgstr ""
     29
     30#: inc/asm-MSLS-Grouping.php:434
     31msgid "Language"
     32msgstr ""
     33
     34#: inc/asm-MSLS-Grouping.php:521
     35msgid "'Multisite Language Switcher' is unestablished."
     36msgstr ""
     37
     38#: inc/asm-MSLS-Grouping.php:564
     39msgid "Same Language Sites List"
     40msgstr ""
     41
     42#: inc/asm-MSLS-Grouping.php:567 inc/asm-MSLS-Grouping.php:584
     43msgid "Same Language Sites"
     44msgstr ""
     45
     46#: inc/asm-MSLS-Grouping.php:643
     47msgid "Title:"
     48msgstr ""
     49
     50#: inc/asm-MSLS-Grouping.php:645
     51msgid "Template:"
     52msgstr ""
     53
     54#: inc/dictionary.php:8
     55msgid "Allow Duplicate Languages"
     56msgstr ""
     57
     58#: inc/dictionary.php:9
     59msgid "You allow for the same language to repeat in 'Multisite Language Switcher'."
     60msgstr ""
     61
     62#: inc/dictionary.php:10
    2763msgid "MSLS Gouping"
    2864msgstr ""
    2965
    30 #: inc/asm-MSLS-Grouping.php:142
     66#: inc/dictionary.php:11
    3167msgid "Asumaru"
    3268msgstr ""
    3369
    34 #: inc/asm-MSLS-Grouping.php:143
     70#: inc/dictionary.php:12
    3571msgid "Asumaru Corp."
    3672msgstr ""
    3773
    38 #: inc/asm-MSLS-Grouping.php:144
     74#: inc/dictionary.php:13
    3975msgid ""
    4076"You can multilingualize by 'Multisite Language Switcher' with grouping the sites of the plural "
    4177"same languages."
    4278msgstr ""
    43 
    44 #: inc/asm-MSLS-Grouping.php:225
    45 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:456
    49 msgid "Same Language Sites List"
    50 msgstr ""
    51 
    52 #: inc/asm-MSLS-Grouping.php:459 inc/asm-MSLS-Grouping.php:476
    53 msgid "Same Language Sites"
    54 msgstr ""
    55 
    56 #: inc/asm-MSLS-Grouping.php:535
    57 msgid "Title:"
    58 msgstr ""
    59 
    60 #: inc/asm-MSLS-Grouping.php:537
    61 msgid "Template:"
    62 msgstr ""
  • msls-gouping/trunk/readme.txt

    r1596208 r1604369  
    1 === Plugin Name ===
     1=== MSLS Grouping ===
    22Contributors: Asumaru
    3 Donate link: http://asumaru.com/
    4 Tags: multilingual, multisite, language, switcher, international, localization, i18n, grouping
     3Donate link: http://asumaru.com/business/wp-plugins/asm-msls-grouping/
     4Tags: multilingual, multisite, language, switcher, international, localization, i18n, grouping, flag, WPLANG
    55Requires at least: 4.6
    66Tested up to: 4.7.2
    7 Stable tag: 0.1
     7Stable tag: 0.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1919* Site A (Japanese)  example-site.com/jp/
    2020* 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/
    2222* 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/
    2424
    2525"Multisite Language Switcher" cannot tell the difference between site A, site B and site C.
     
    3737* Site A (English)  => Site B (English), Site C (English)
    3838* Site B (Japanese) => Site A (Japanese), Site C (Japanese)
     39
     40And, it provide "Language" column on the Table of Sites in network.
     41
     42And, it provide "Language Flag" in Admin-Bar.
    3943
    4044== Installation ==
     
    5963* %after_item% : Suffix of the list item.
    6064
     65= How do you not come to display language column on the Table of Sites in network? =
     66You 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? =
     70You 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? =
     74You must add the following cord to functions.php in the theme.
     75> add_filter( 'asm_force_WPLANG.options_general', create_function( '', 'return false;' ) );
     76
    6177== Screenshots ==
    6278
     
    75917. e.g. Japanese Site.
    7692
     938. Language flags in Admin-Bar.
     94
    7795== Changelog ==
    7896
     
    8098* created 2017.01.01.
    8199
     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
    82106== Upgrade Notice ==
    83107
Note: See TracChangeset for help on using the changeset viewer.