Plugin Directory


Ignore:
Timestamp:
05/22/2024 03:36:52 PM (20 months ago)
Author:
realloc
Message:

Update to version 2.7.1 from GitHub

Location:
multisite-language-switcher
Files:
38 edited
1 copied

Legend:

Unmodified
Added
Removed
  • multisite-language-switcher/tags/2.7.1/MultisiteLanguageSwitcher.php

    r3088911 r3091013  
    88 *
    99 * Plugin Name: Multisite Language Switcher
    10  * Version: 2.7.0
     10 * Version: 2.7.1
    1111 * Plugin URI: http://msls.co/
    1212 * Description: A simple but powerful plugin that will help you to manage the relations of your contents in a multilingual multisite-installation.
     
    4141 */
    4242if ( ! defined( 'MSLS_PLUGIN_VERSION' ) ) {
    43     define( 'MSLS_PLUGIN_VERSION', '2.7.0' );
     43    define( 'MSLS_PLUGIN_VERSION', '2.7.1' );
    4444    define( 'MSLS_PLUGIN_PATH', plugin_basename( __FILE__ ) );
    4545    define( 'MSLS_PLUGIN__FILE__', __FILE__ );
  • multisite-language-switcher/tags/2.7.1/includes/MslsAdmin.php

    r3088911 r3091013  
    5050             *
    5151             * @since 2.0
    52              *
    5352             */
    5453            $caps = apply_filters( 'msls_admin_caps', 'manage_options' );
    5554            if ( current_user_can( $caps ) ) {
    5655                $title = __( 'Multisite Language Switcher', 'multisite-language-switcher' );
    57                 add_options_page( $title, $title, 'manage_options', $obj->get_menu_slug(), [ $obj, 'render' ] );
    58 
    59                 add_action( 'admin_init', [ $obj, 'register' ] );
    60                 add_action( 'admin_notices', [ $obj, 'has_problems' ] );
    61 
    62                 add_filter( 'msls_admin_validate', [ $obj, 'set_blog_language' ] );
     56                add_options_page( $title, $title, 'manage_options', $obj->get_menu_slug(), array( $obj, 'render' ) );
     57
     58                add_action( 'admin_init', array( $obj, 'register' ) );
     59                add_action( 'admin_notices', array( $obj, 'has_problems' ) );
     60
     61                add_filter( 'msls_admin_validate', array( $obj, 'set_blog_language' ) );
    6362            }
    6463        }
     
    8988     *
    9089     * @param string $method
    91      * @param mixed $args
     90     * @param mixed  $args
    9291     *
    9392     * @return mixed
     
    9796
    9897        if ( is_array( $parts ) && 'rewrite' === $parts[0] ) {
    99             return $this->render_rewrite( $parts[1] );
    100         }
    101 
    102         $checkboxes = [
    103             'activate_autocomplete'   => __( 'Activate experimental autocomplete inputs',
    104                 'multisite-language-switcher' ),
    105             'activate_content_import' => __( 'Activate the content import functionality',
    106                 'multisite-language-switcher' ),
     98            $this->render_rewrite( $parts[1] );
     99            return;
     100        }
     101
     102        $checkboxes = array(
     103            'activate_autocomplete'   => __(
     104                'Activate experimental autocomplete inputs',
     105                'multisite-language-switcher'
     106            ),
     107            'activate_content_import' => __(
     108                'Activate the content import functionality',
     109                'multisite-language-switcher'
     110            ),
    107111            'sort_by_description'     => __( 'Sort languages by description', 'multisite-language-switcher' ),
    108112            'exclude_current_blog'    => __( 'Exclude this blog from output', 'multisite-language-switcher' ),
     
    110114            'output_current_blog'     => __( 'Display link to the current language', 'multisite-language-switcher' ),
    111115            'content_filter'          => __( 'Add hint for available translations', 'multisite-language-switcher' ),
    112         ];
    113 
    114         if ( isset ( $checkboxes[ $method ] ) ) {
    115             echo ( new Group() )->add( new Checkbox( $method, $this->options->$method ) )->add( new Label( $method,
    116                 $checkboxes[ $method ] ) )->render();
     116        );
     117
     118        if ( isset( $checkboxes[ $method ] ) ) {
     119            echo ( new Group() )->add( new Checkbox( $method, $this->options->$method ) )->add(
     120                new Label(
     121                    $method,
     122                    $checkboxes[ $method ]
     123                )
     124            )->render();
    117125        } else {
    118126            $value = ! empty( $this->options->$method ) ? $this->options->$method : '';
     
    123131    /**
    124132     * There is something wrong? Here comes the message...
     133     *
    125134     * @return bool
    126135     */
    127     public function has_problems() {
     136    public function has_problems(): bool {
    128137        $message = '';
    129138
    130139        if ( $this->options->is_empty() ) {
    131140            $message = sprintf(
    132                 __( 'Multisite Language Switcher is almost ready. You must <a href="%s">complete the configuration process</a>.',
    133                     'multisite-language-switcher' ),
     141                __(
     142                    'Multisite Language Switcher is almost ready. You must <a href="%s">complete the configuration process</a>.',
     143                    'multisite-language-switcher'
     144                ),
    134145                esc_url( admin_url( $this->get_options_page_link() ) )
    135146            );
    136147        } elseif ( 1 == count( $this->options->get_available_languages() ) ) {
    137148            $message = sprintf(
    138                 __( 'There are no language files installed. You can <a href="%s">manually install some language files</a> or you could use a <a href="%s">plugin</a> to download these files automatically.',
    139                     'multisite-language-switcher' ),
     149                __(
     150                    'There are no language files installed. You can <a href="%1$s">manually install some language files</a> or you could use a <a href="%2$s">plugin</a> to download these files automatically.',
     151                    'multisite-language-switcher'
     152                ),
    140153                esc_url( 'http://codex.wordpress.org/Installing_WordPress_in_Your_Language#Manually_Installing_Language_Files' ),
    141154                esc_url( 'http://wordpress.org/plugins/wp-native-dashboard/' )
     
    149162     * Render the options-page
    150163     */
    151     public function render() {
     164    public function render(): void {
    152165        printf(
    153166            '<div class="wrap"><div class="icon32" id="icon-options-general"><br/></div><h1>%s</h1>%s<br class="clear"/><form action="options.php" method="post"><p>%s</p>',
    154167            __( 'Multisite Language Switcher Options', 'multisite-language-switcher' ),
    155168            $this->subsubsub(),
    156             __( 'To achieve maximum flexibility, you have to configure each blog separately.',
    157                 'multisite-language-switcher' )
     169            __(
     170                'To achieve maximum flexibility, you have to configure each blog separately.',
     171                'multisite-language-switcher'
     172            )
    158173        );
    159174
     
    163178        printf(
    164179            '<p class="submit"><input name="Submit" type="submit" class="button button-primary" value="%s" /></p></form></div>',
    165             ( $this->options->is_empty() ? __( 'Configure', 'multisite-language-switcher' ) : __( 'Update',
    166                 'multisite-language-switcher' ) )
     180            ( $this->options->is_empty() ? __( 'Configure', 'multisite-language-switcher' ) : __(
     181                'Update',
     182                'multisite-language-switcher'
     183            ) )
    167184        );
    168185    }
     
    171188    /**
    172189     * Create a submenu which contains links to all blogs of the current user
     190     *
    173191     * @return string
    174192     */
     
    176194        $icon_type = $this->options->get_icon_type();
    177195
    178         $arr = [];
     196        $arr = array();
    179197        foreach ( $this->collection->get_plugin_active_blogs() as $blog ) {
    180198            $admin_url = get_admin_url( $blog->userblog_id, $this->get_options_page_link() );
     
    184202        }
    185203
    186         return empty( $arr ) ? '' : sprintf( '<ul class="subsubsub"><li>%s</li></ul>',
    187             implode( ' | </li><li>', $arr ) );
     204        return empty( $arr ) ? '' : sprintf(
     205            '<ul class="subsubsub"><li>%s</li></ul>',
     206            implode( ' | </li><li>', $arr )
     207        );
    188208    }
    189209
     
    194214     */
    195215    public function register() {
    196         register_setting( 'msls', 'msls', [ $this, 'validate' ] );
    197 
    198         $sections = [
     216        register_setting( 'msls', 'msls', array( $this, 'validate' ) );
     217
     218        $sections = array(
    199219            'language_section' => __( 'Language Settings', 'multisite-language-switcher' ),
    200220            'main_section'     => __( 'Main Settings', 'multisite-language-switcher' ),
    201221            'advanced_section' => __( 'Advanced Settings', 'multisite-language-switcher' ),
    202         ];
     222        );
    203223
    204224        global $wp_rewrite;
     
    208228
    209229        foreach ( $sections as $id => $title ) {
    210             add_settings_section( $id, $title, [ $this, $id ], __CLASS__ );
     230            add_settings_section( $id, $title, array( $this, $id ), __CLASS__ );
    211231        }
    212232
     
    217237         *
    218238         * @since 1.0
    219          *
    220239         */
    221240        do_action( 'msls_admin_register', __CLASS__ );
     
    230249     */
    231250    public function language_section(): int {
    232         $map = [ 'blog_language' => __( 'Blog Language', 'multisite-language-switcher' ) ];
     251        $map = array( 'blog_language' => __( 'Blog Language', 'multisite-language-switcher' ) );
    233252
    234253        return $this->add_settings_fields( $map, 'language_section' );
     
    243262     */
    244263    public function main_section(): int {
    245         $map = [
     264        $map = array(
    246265            'display'               => __( 'Display', 'multisite-language-switcher' ),
    247266            'admin_display'         => __( 'Admin Display', 'multisite-language-switcher' ),
     
    256275            'content_filter'        => __( 'Available translations hint', 'multisite-language-switcher' ),
    257276            'content_priority'      => __( 'Hint priority', 'multisite-language-switcher' ),
    258         ];
     277        );
    259278
    260279        return $this->add_settings_fields( $map, 'main_section' );
     
    269288     */
    270289    public function advanced_section(): int {
    271         $map = [
     290        $map = array(
    272291            'activate_autocomplete'   => __( 'Autocomplete', 'multisite-language-switcher' ),
    273292            'image_url'               => __( 'Custom URL for flag-images', 'multisite-language-switcher' ),
     
    275294            'exclude_current_blog'    => __( 'Exclude blog', 'multisite-language-switcher' ),
    276295            'activate_content_import' => __( 'Content import', 'multisite-language-switcher' ),
    277         ];
     296        );
    278297
    279298        return $this->add_settings_fields( $map, 'advanced_section' );
     
    288307     */
    289308    public function rewrites_section(): int {
    290         $map = [];
    291         foreach ( get_post_types( [ 'public' => true ], 'objects' ) as $key => $object ) {
    292             $map["rewrite_{$key}"] = sprintf( __( '%s Slug', 'multisite-language-switcher' ), $object->label );
     309        $map = array();
     310        foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $key => $object ) {
     311            $map[ "rewrite_{$key}" ] = sprintf( __( '%s Slug', 'multisite-language-switcher' ), $object->label );
    293312        }
    294313
     
    297316
    298317    /**
    299      * @param array $map
     318     * @param array  $map
    300319     * @param string $section
    301320     *
     
    304323    protected function add_settings_fields( array $map, string $section ): int {
    305324        foreach ( $map as $id => $title ) {
    306             add_settings_field( $id, $title, [ $this, $id ], __CLASS__, $section, [ 'label_for' => $id ] );
     325            add_settings_field( $id, $title, array( $this, $id ), __CLASS__, $section, array( 'label_for' => $id ) );
    307326        }
    308327
     
    314333         *
    315334         * @since 2.4.4
    316          *
    317335         */
    318336        do_action( "msls_admin_{$section}", __CLASS__, $section );
     
    342360     */
    343361    public function admin_display() {
    344         echo ( new Select( 'admin_display',
     362        echo ( new Select(
     363            'admin_display',
    345364            array(
    346365                'flag'  => __( 'Flag', 'multisite-language-switcher' ),
    347                 'label' => __( 'Label', 'multisite-language-switcher' )
     366                'label' => __( 'Label', 'multisite-language-switcher' ),
    348367            ),
    349             $this->options->admin_display ) )->render();
     368            $this->options->admin_display
     369        ) )->render();
    350370    }
    351371
     
    354374     */
    355375    public function reference_user() {
    356         $users = [];
    357 
    358         foreach ( ( array ) apply_filters( 'msls_reference_users', $this->collection->get_users() ) as $user ) {
     376        $users = array();
     377
     378        foreach ( (array) apply_filters( 'msls_reference_users', $this->collection->get_users() ) as $user ) {
    359379            $users[ $user->ID ] = $user->user_nicename;
    360380        }
     
    364384
    365385            $message = sprintf(
    366                 __( 'Multisite Language Switcher: Collection for reference user has been truncated because it exceeded the maximum of %s users. Please, use the hook "msls_reference_users" to filter the result before!',
    367                     'multisite-language-switcher' ),
     386                __(
     387                    'Multisite Language Switcher: Collection for reference user has been truncated because it exceeded the maximum of %s users. Please, use the hook "msls_reference_users" to filter the result before!',
     388                    'multisite-language-switcher'
     389                ),
    368390                self::MAX_REFERENCE_USERS
    369391            );
     
    391413     */
    392414    public function content_priority() {
    393         $temp     = array_merge( range( 1, 10 ), [ 20, 50, 100 ] );
     415        $temp     = array_merge( range( 1, 10 ), array( 20, 50, 100 ) );
    394416        $arr      = array_combine( $temp, $temp );
    395417        $selected = empty( $this->options->content_priority ) ? 10 : $this->options->content_priority;
     
    430452         *
    431453         * @since 1.0
    432          *
    433454         */
    434455        $arr = (array) apply_filters( 'msls_admin_validate', $arr );
     
    458479        return $arr;
    459480    }
    460 
    461481}
  • multisite-language-switcher/tags/2.7.1/includes/MslsAdminIcon.php

    r3079846 r3091013  
    11<?php
    2 /**
    3  * MslsAdminIcon
    4  * @author Dennis Ploetner <re@lloc.de>
    5  * @since 0.9.8
    6  */
    72
    83namespace lloc\Msls;
     
    138/**
    149 * Handles the icon links in the backend
     10 *
    1511 * @package Msls
    1612 */
     
    122118    public function set_path(): MslsAdminIcon {
    123119        if ( 'post' != $this->type ) {
    124             $query_vars = [ 'post_type' => $this->type ];
     120            $query_vars = array( 'post_type' => $this->type );
    125121            $this->path = add_query_arg( $query_vars, $this->path );
    126122        }
     
    210206    public function get_a(): string {
    211207        if ( empty( $this->href ) ) {
    212             $title = sprintf( __( 'Create a new translation in the %s-blog', 'multisite-language-switcher' ),
    213                 $this->language );
     208            $title = sprintf(
     209                __( 'Create a new translation in the %s-blog', 'multisite-language-switcher' ),
     210                $this->language
     211            );
    214212            $href  = $this->get_edit_new();
    215213        } else {
    216             $title = sprintf( __( 'Edit the translation in the %s-blog', 'multisite-language-switcher' ),
    217                 $this->language );
     214            $title = sprintf(
     215                __( 'Edit the translation in the %s-blog', 'multisite-language-switcher' ),
     216                $this->language
     217            );
    218218            $href  = $this->href;
    219219        }
     
    233233
    234234        switch ( $this->icon_type ) {
    235             case MslsAdminIcon::TYPE_FLAG:
    236                 $icon = sprintf( '<span class="flag-icon %s">%s</span>',
     235            case self::TYPE_FLAG:
     236                $icon = sprintf(
     237                    '<span class="flag-icon %s">%s</span>',
    237238                    ( new IconSvg() )->get( $this->language ),
    238239                    $this->language
    239240                );
    240241                break;
    241             case MslsAdminIcon::TYPE_LABEL:
    242                 $icon = sprintf( '<span class="language-badge %s">%s</span>',
     242            case self::TYPE_LABEL:
     243                $icon = sprintf(
     244                    '<span class="language-badge %s">%s</span>',
    243245                    $this->language,
    244246                    ( new IconLabel() )->get( $this->language )
     
    246248                break;
    247249            default:
    248                 $icon = sprintf( '<span class="dashicons %s"></span>',
    249                     empty( $this->href ) ? 'dashicons-plus' : 'dashicons-edit' );
     250                $icon = sprintf(
     251                    '<span class="dashicons %s"></span>',
     252                    empty( $this->href ) ? 'dashicons-plus' : 'dashicons-edit'
     253                );
    250254        }
    251255
     
    262266
    263267        if ( null !== $this->id && null !== $this->origin_language ) {
    264             $path = add_query_arg( [ 'msls_id' => $this->id, 'msls_lang' => $this->origin_language ], $this->path );
     268            $path = add_query_arg(
     269                array(
     270                    'msls_id'   => $this->id,
     271                    'msls_lang' => $this->origin_language,
     272                ),
     273                $this->path
     274            );
    265275        }
    266276
     
    276286        return get_admin_url( get_current_blog_id(), $path );
    277287    }
    278 
    279288}
  • multisite-language-switcher/tags/2.7.1/includes/MslsAdminIconTaxonomy.php

    r3088911 r3091013  
    11<?php
    2 /**
    3  * MslsAdminIconTaxonomy
    4  * @author Dennis Ploetner <re@lloc.de>
    5  * @since 0.9.8
    6  */
    72
    83namespace lloc\Msls;
     
    105/**
    116 * Handles backend icons for taxonomies
     7 *
    128 * @package Msls
    139 */
     
    1612    /**
    1713     * Path
     14     *
    1815     * @var string
    1916     */
     
    2926     */
    3027    public function set_href( int $id ): MslsAdminIcon {
    31         $object_type = MslsTaxonomy::instance()->get_post_type();
     28        $object_type = MslsTaxonomy::instance()->get_post_type();
    3229
    3330        $this->href = get_edit_term_link( $id, $this->type, $object_type );
     
    4037     *
    4138     * @return MslsAdminIconTaxonomy
    42      *
    4339     */
    4440    public function set_path(): MslsAdminIcon {
    45         $args      = [ 'taxonomy' => $this->type ];
     41        $args      = array( 'taxonomy' => $this->type );
    4642        $post_type = MslsTaxonomy::instance()->get_post_type();
    4743
    48         $post_type !== '' && $args['post_type'] = $post_type;
     44        $post_type !== '' && $args['post_type'] = $post_type;
    4945
    5046        $this->path = add_query_arg( $args, $this->path );
     
    5248        return $this;
    5349    }
    54 
    5550}
  • multisite-language-switcher/tags/2.7.1/includes/MslsBlog.php

    r3079846 r3091013  
    1 <?php
     1<?php declare( strict_types=1 );
    22
    33namespace lloc\Msls;
     
    1313    /**
    1414     * WordPress generates such an object
     15     *
    1516     * @var \StdClass
    1617     */
     
    1819
    1920    /**
    20      * Language-code eg. de_DE
     21     * Language-code e.g. "de_DE", or "en_US", or "it_IT"
     22     *
    2123     * @var string
    2224     */
    23     private $language;
    24 
    25     /**
    26      * Description eg. Deutsch
     25    private string $language;
     26
     27    /**
     28     * Description e.g. "Deutsch", or "English", or "Italiano"
     29     *
    2730     * @var string
    2831     */
    29     private $description;
     32    private string $description;
    3033
    3134    /**
     
    3336     *
    3437     * @param ?\StdClass $obj
    35      * @param string $description
     38     * @param string     $description
    3639     */
    3740    public function __construct( $obj, $description ) {
     
    6164     *
    6265     * The method returns the stored language if the description is empty.
     66     *
    6367     * @return string
    6468     */
     
    7781        $icon = ( new MslsAdminIcon( null ) )->set_language( $this->language )->set_icon_type( $icon_type );
    7882
    79         return sprintf( '%1$s %2$s',
     83        return sprintf(
     84            '%1$s %2$s',
    8085            $this->obj->blogname,
    81             '<span class="msls-icon-wrapper flag">' . $icon->get_icon() . '</span>' );
     86            '<span class="msls-icon-wrapper flag">' . $icon->get_icon() . '</span>'
     87        );
    8288    }
    8389
     
    129135        switch_to_blog( $this->obj->userblog_id );
    130136
    131         if ( is_object( $options ) && method_exists( $options,
    132                 'has_value' ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) {
     137        if ( is_object( $options ) && method_exists(
     138            $options,
     139            'has_value'
     140        ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) {
    133141            $url = apply_filters( 'mlsl_blog_get_permalink', $options->get_permalink( $this->get_language() ), $this );
    134142        }
     
    201209        return $blavatar_html;
    202210    }
    203 
    204211}
  • multisite-language-switcher/tags/2.7.1/includes/MslsBlogCollection.php

    r3088911 r3091013  
    1 <?php
    2 /**
    3  * MslsBlogCollection
    4  * @author Dennis Ploetner <re@lloc.de>
    5  * @since 0.9.8
    6  */
     1<?php declare( strict_types=1 );
    72
    83namespace lloc\Msls;
     
    1712    /**
    1813     * ID of the current blog
     14     *
    1915     * @var int
    2016     */
     
    2319    /**
    2420     * True if the current blog should be in the output
     21     *
    2522     * @var bool
    2623     */
     
    2926    /**
    3027     * Collection of MslsBlog-objects
     28     *
    3129     * @var MslsBlog[]
    3230     */
    33     private $objects = [];
     31    private $objects = array();
    3432
    3533    /**
    3634     * Order output by language or description
     35     *
    3736     * @var string
    3837     */
     
    4140    /**
    4241     * Active plugins in the whole network
     42     *
    4343     * @var array
    4444     */
     
    4747    /**
    4848     * Container for hreflang-mapping
     49     *
    4950     * @var array
    5051     */
    51     private $hreflangmap = [];
     52    private $hreflangmap = array();
    5253
    5354    /**
     
    5657    public function __construct() {
    5758        if ( ! has_filter( 'msls_blog_collection_description' ) ) {
    58             add_filter( 'msls_blog_collection_description', [ $this, 'get_configured_blog_description' ], 10, 2 );
     59            add_filter( 'msls_blog_collection_description', array( $this, 'get_configured_blog_description' ), 10, 2 );
    5960        }
    6061
     
    7374             *
    7475             * @since 0.9.8
    75              *
    7676             */
    7777            $blogs_collection = (array) apply_filters(
     
    9898                }
    9999            }
    100             uasort( $this->objects, [ MslsBlog::class, $this->objects_order ] );
     100            uasort( $this->objects, array( MslsBlog::class, $this->objects_order ) );
    101101        }
    102102    }
     
    105105     * Returns the description of a configured blog or false if it is not configured
    106106     *
    107      * @param int $blog_id
     107     * @param int         $blog_id
    108108     * @param string|bool $description
    109109     *
     
    133133     */
    134134    public function get_blogs_of_reference_user( MslsOptions $options ) {
    135         $reference_user = $options->has_value( 'reference_user' ) ? $options->reference_user : current( $this->get_users( 'ID',
    136             1 ) );
     135        $reference_user = $options->has_value( 'reference_user' ) ? $options->reference_user : current(
     136            $this->get_users(
     137                'ID',
     138                1
     139            )
     140        );
    137141        $blogs          = get_blogs_of_user( $reference_user );
    138142
     
    185189    /**
    186190     * Get the id of the current blog
     191     *
    187192     * @return int
    188193     */
     
    213218    /**
    214219     * Gets current blog as object
     220     *
    215221     * @return MslsBlog|null
    216222     */
     
    221227    /**
    222228     * Gets an array with all blog-objects
     229     *
    223230     * @return MslsBlog[]
    224231     */
     
    236243    public function is_plugin_active( $blog_id ) {
    237244        if ( ! is_array( $this->active_plugins ) ) {
    238             $this->active_plugins = get_site_option( 'active_sitewide_plugins', [] );
     245            $this->active_plugins = get_site_option( 'active_sitewide_plugins', array() );
    239246        }
    240247
     
    244251        }
    245252
    246         $plugins = get_blog_option( $blog_id, 'active_plugins', [] );
     253        $plugins = get_blog_option( $blog_id, 'active_plugins', array() );
    247254
    248255        return in_array( $path, $plugins );
     
    251258    /**
    252259     * Gets only blogs where the plugin is active
     260     *
    253261     * @return array
    254262     */
    255263    public function get_plugin_active_blogs() {
    256         $arr = [];
     264        $arr = array();
    257265
    258266        foreach ( $this->get_objects() as $blog ) {
     
    267275    /**
    268276     * Gets an array of all - but not the current - blog-objects
     277     *
    269278     * @return MslsBlog[]
    270279     */
     
    286295     * @return MslsBlog[]
    287296     */
    288     public function get_filtered( $filter = false ) {
    289         if ( ! $filter && $this->current_blog_output ) {
    290             return $this->get_objects();
    291         }
    292 
    293         return $this->get();
     297    public function get_filtered( bool $filter = false ): array {
     298        return ! $filter && $this->current_blog_output ? $this->get_objects() : $this->get();
    294299    }
    295300
     
    297302     * Gets the registered users of the current blog
    298303     *
    299      * @param string $fields
     304     * @param string     $fields
    300305     * @param int|string $number
    301306     *
     
    303308     */
    304309    public function get_users( $fields = 'all', $number = '' ) {
    305         $args = [
     310        $args = array(
    306311            'blog_id'     => $this->current_blog_id,
    307312            'orderby'     => 'registered',
     
    309314            'number'      => $number,
    310315            'count_total' => false,
    311         ];
     316        );
    312317
    313318        $args = (array) apply_filters( 'msls_get_users', $args );
     
    319324     * Returns a specific blog language.
    320325     *
    321      * @param int $blog_id
     326     * @param int    $blog_id
    322327     * @param string $default
    323328     *
     
    329334        }
    330335
    331         $language = ( string ) get_blog_option( $blog_id, 'WPLANG' );
     336        $language = (string) get_blog_option( $blog_id, 'WPLANG' );
    332337
    333338        return '' !== $language ? $language : $default;
    334339    }
    335 
    336340}
  • multisite-language-switcher/tags/2.7.1/includes/MslsOptions.php

    r3088911 r3091013  
    22/**
    33 * MslsOptions
     4 *
    45 * @author Dennis Ploetner <re@lloc.de>
    56 * @since 0.9.8
     
    1213/**
    1314 * General options class
     15 *
    1416 * @package Msls
    1517 * @property bool $activate_autocomplete
     
    3032    /**
    3133     * Args
     34     *
    3235     * @var array
    3336     */
     
    3639    /**
    3740     * Name
     41     *
    3842     * @var string
    3943     */
     
    4246    /**
    4347     * Exists
     48     *
    4449     * @var bool
    4550     */
     
    4853    /**
    4954     * Separator
     55     *
    5056     * @var string
    5157     */
     
    5460    /**
    5561     * Autoload
     62     *
    5663     * @var string
    5764     */
     
    6067    /**
    6168     * Available languages
    62      * @var array
    63      */
    64     private $available_languages;
     69     *
     70     * @var array<string, string>
     71     */
     72    private array $available_languages;
    6573
    6674    /**
    6775     * Rewrite with front
     76     *
    6877     * @var bool
    6978     */
     
    100109        }
    101110
    102         add_filter( 'check_url', [ $options, 'check_for_blog_slug' ], 10, 2 );
     111        add_filter( 'msls_get_postlink', array( $options, 'check_for_blog_slug' ), 10, 2 );
    103112
    104113        return $options;
     
    107116    /**
    108117     * Determines if the current page is the main page (front page, search, 404).
    109     *
    110     * @return boolean
     118    *
     119    * @return boolean
    111120     */
    112121    public static function is_main_page() {
     
    116125    /**
    117126     * Determines if the current page is a category, tag or taxonomy page.
    118     *
     127    *
    119128     * @return boolean
    120129     */
     
    125134    /**
    126135     * Determines if the current page is an archive page for a date, author, or any other post type.
    127     *
     136    *
    128137     * @return boolean
    129138     */
     
    143152    /**
    144153     * Gets an element of arg by index
    145     *
    146      * The returned value will either be cast to the type of `$retval` or, if nothing is set at this index, it will be the value of `$retval`.
    147      *
    148      * @param int $idx
    149      * @param mixed $val
     154    *
     155     * The returned value will either be cast to the type of `$default` or, if nothing is set at this index, it will be the value of `$default`.
     156     *
     157     * @param int   $index
     158     * @param mixed $default
    150159     *
    151160     * @return mixed
    152161     */
    153     public function get_arg( $idx, $val = null ) {
    154         $arg = isset( $this->args[ $idx ] ) ? $this->args[ $idx ] : $val;
    155         settype( $arg, gettype( $val ) );
     162    public function get_arg( int $index, $default = null ) {
     163        $arg = $this->args[ $index ] ?? $default;
     164
     165        settype( $arg, gettype( $default ) );
    156166
    157167        return $arg;
     
    177187    /**
    178188     * Delete
     189     *
    179190     * @codeCoverageIgnore
    180191     */
     
    201212         * Mapping for us language code
    202213         */
    203         $map = [ 'us' => 'en_US', 'en' => 'en_US' ];
     214        $map = array(
     215            'us' => 'en_US',
     216            'en' => 'en_US',
     217        );
    204218        foreach ( $map as $old => $new ) {
    205219            if ( isset( $arr[ $old ] ) ) {
     
    230244         *
    231245         * @since 0.9.8
    232          *
    233246         */
    234247        $postlink = (string) apply_filters(
     
    254267    /**
    255268     * Get the queried taxonomy
     269     *
    256270     * @return string
    257271     */
     
    262276    /**
    263277     * Get current link
     278     *
    264279     * @return string
    265280     */
     
    270285    /**
    271286     * Is excluded
     287     *
    272288     * @return bool
    273289     */
     
    278294    /**
    279295     * Is content
     296     *
    280297     * @return bool
    281298     */
     
    286303    /**
    287304     * Get order
     305     *
    288306     * @return string
    289307     */
     
    306324     * Returns slug for a post type
    307325     *
     326     * @todo This method is not used anywhere in the codebase. Should it be removed?
     327     *
    308328     * @param string $post_type
    309329     *
    310330     * @return string
    311331     */
    312     public function get_slug( $post_type ) {
     332    public function get_slug( string $post_type ): string {
    313333        $key = "rewrite_{$post_type}";
    314334
    315         error_log( $key );
    316 
    317         return isset( $this->$key ) ? $this->$key : '';
     335        return $this->$key ?? '';
    318336    }
    319337
     
    335353     */
    336354    public function get_flag_url( $language ) {
    337         if ( ! is_admin() && isset( $this->image_url ) ) {
    338             $url = $this->__get( 'image_url' );
    339         } else {
    340             $url = $this->get_url( 'flags' );
    341         }
     355        $url = ! is_admin() && isset( $this->image_url ) ? $this->__get( 'image_url' ) : $this->get_url( 'flags' );
    342356
    343357        /**
     
    347361         *
    348362         * @since 0.9.9
    349          *
    350363         */
    351364        $url = (string) apply_filters( 'msls_options_get_flag_url', $url );
     
    360373         *
    361374         * @since 1.0.3
    362          *
    363375         */
    364376        $icon = (string) apply_filters( 'msls_options_get_flag_icon', $icon, $language );
     
    376388    public function get_available_languages() {
    377389        if ( empty( $this->available_languages ) ) {
    378             $this->available_languages = [
     390            $this->available_languages = array(
    379391                'en_US' => __( 'American English', 'multisite-language-switcher' ),
    380             ];
     392            );
    381393
    382394            foreach ( get_available_languages() as $code ) {
     
    390402             *
    391403             * @since 1.0
    392              *
    393404             */
    394405            $this->available_languages = (array) apply_filters(
     
    404415     * The 'blog'-slug-problem :/
    405416     *
    406      * @param string $url
     417     * @param string      $url
    407418     * @param MslsOptions $options
    408419     *
     
    444455        return MslsAdminIcon::TYPE_LABEL === $this->admin_display ? MslsAdminIcon::TYPE_LABEL : MslsAdminIcon::TYPE_FLAG;
    445456    }
    446 
    447457}
  • multisite-language-switcher/tags/2.7.1/includes/MslsOptionsPost.php

    r3079846 r3091013  
    1 <?php
    2 /**
    3  * MslsOptionsPost
    4  * @author Dennis Ploetner <re@lloc.de>
    5  * @since 0.9.8
    6  */
     1<?php declare( strict_types=1 );
    72
    83namespace lloc\Msls;
     
    105/**
    116 * Post options
     7 *
    128 * @package Msls
    139 */
     
    1612    /**
    1713     * Separator
     14     *
    1815     * @var string
    1916     */
     
    2219    /**
    2320     * Autoload
     21     *
    2422     * @var string
    2523     */
     
    4846        }
    4947
    50         global $current_site;
    51         $blog_id = msls_blog_collection()->get_blog_id( $language );
    52         if ( $current_site->blog_id != $blog_id ) {
    53             $option = get_blog_option( $blog_id, 'msls' );
    54             //error_log( print_r( $option, true ) );
    55         }
     48        $post_link = get_permalink( $post );
    5649
    57         return apply_filters( 'check_url', get_permalink( $post ), $this );
     50        $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' );
     51
     52        return apply_filters( 'msls_get_postlink', $post_link, $this );
    5853    }
    5954
     
    6661        return (string) get_permalink( $this->get_arg( 0, 0 ) );
    6762    }
    68 
    6963}
  • multisite-language-switcher/tags/2.7.1/includes/MslsOptionsQuery.php

    r3079846 r3091013  
    22/**
    33 * MslsOptionsQuery
     4 *
    45 * @author Dennis Ploetner <re@lloc.de>
    56 * @since 0.9.8
     
    1718    /**
    1819     * Rewrite with front
     20     *
    1921     * @var bool
    2022     */
     
    6264    public function get_postlink( $language ) {
    6365        if ( $this->has_value( $language ) ) {
    64             $link = $this->get_current_link();
    65             if ( ! empty( $link ) ) {
    66                 return apply_filters( 'check_url', $link, $this );
     66            $post_link = $this->get_current_link();
     67            if ( ! empty( $post_link ) ) {
     68                $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' );
     69
     70                return apply_filters( 'msls_get_postlink', $post_link, $this );
    6771            }
    6872        }
     
    7074        return '';
    7175    }
    72 
    7376}
  • multisite-language-switcher/tags/2.7.1/includes/MslsOptionsQueryAuthor.php

    r3079846 r3091013  
    22/**
    33 * MslsOptionsQueryAuthor
     4 *
    45 * @author Dennis Ploetner <re@lloc.de>
    56 * @since 0.9.8
     
    1617
    1718    /**
    18      * Check if the array has an non empty item which has $language as a key
     19     * Check if the array has a non-empty item which has $language as a key
    1920     *
    2021     * @param string $language
     
    4546        return get_author_posts_url( $this->get_arg( 0, 0 ) );
    4647    }
    47 
    4848}
  • multisite-language-switcher/tags/2.7.1/includes/MslsOptionsQueryPostType.php

    r3079846 r3091013  
    22/**
    33 * MslsOptionsQueryPostType
     4 *
    45 * @author Dennis Ploetner <re@lloc.de>
    56 * @since 0.9.8
     
    1617
    1718    /**
    18      * Check if the array has an non empty item which has $language as a key
     19     * Check if the array has a non-empty item which has $language as a key
    1920     *
    2021     * @param string $language
     
    3839        return (string) get_post_type_archive_link( $this->get_arg( 0, '' ) );
    3940    }
    40 
    4141}
  • multisite-language-switcher/tags/2.7.1/includes/MslsOptionsQueryYear.php

    r1990702 r3091013  
    22/**
    33 * MslsOptionsQueryYear
     4 *
    45 * @author Dennis Ploetner <re@lloc.de>
    56 * @since 0.9.8
     
    1617
    1718    /**
    18      * Check if the array has an non empty item which has $language as a key
     19     * Check if the array has a non-empty item which has $language as a key
    1920     *
    2021     * @param string $language
     
    4546        return get_year_link( $this->get_arg( 0, 0 ) );
    4647    }
    47 
    4848}
  • multisite-language-switcher/tags/2.7.1/includes/MslsOptionsTax.php

    r3079846 r3091013  
    22/**
    33 * MslsOptionsTax
     4 *
    45 * @author Dennis Ploetner <re@lloc.de>
    56 * @since 0.9.8
     
    1011/**
    1112 * Taxonomy options
     13 *
    1214 * @package Msls
    1315 */
     
    1618    /**
    1719     * Separator
     20     *
    1821     * @var string
    1922     */
     
    2225    /**
    2326     * Autoload
     27     *
    2428     * @var string
    2529     */
     
    5963
    6064        if ( $req ) {
    61             add_filter( 'check_url', [ $options, 'check_base' ], 9, 2 );
     65            add_filter( 'msls_get_postlink', array( $options, 'check_base' ), 9, 2 );
    6266        } else {
    6367            global $wp_rewrite;
     
    7175    /**
    7276     * Get the queried taxonomy
     77     *
    7378     * @return string
    7479     */
     
    9398     */
    9499    public function get_postlink( $language ) {
    95         $url = '';
     100        $post_link = '';
    96101
    97102        if ( $this->has_value( $language ) ) {
    98             $url = $this->get_term_link( (int) $this->__get( $language ) );
     103            $post_link = $this->get_term_link( (int) $this->__get( $language ) );
    99104        }
    100105
    101         return apply_filters( 'check_url', $url, $this );
     106        $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' );
     107
     108        return apply_filters( 'msls_get_postlink', $post_link, $this );
    102109    }
    103110
    104111    /**
    105112     * Get current link
     113     *
    106114     * @return string
    107115     */
     
    130138        return '';
    131139    }
    132 
    133140}
  • multisite-language-switcher/tags/2.7.1/includes/MslsPlugin.php

    r3088911 r3091013  
    250250     */
    251251    public function admin_bar_init() {
    252         if ( is_admin_bar_showing() && is_super_admin() ) {
     252        if ( is_admin_bar_showing() ) {
    253253            add_action( 'admin_bar_menu', array( __CLASS__, 'update_adminbar' ), 999 );
    254254
  • multisite-language-switcher/tags/2.7.1/includes/MslsPostTag.php

    r3088911 r3091013  
    1 <?php
     1<?php declare( strict_types=1 );
     2
    23/**
    34 * MslsPostTag
    45 *
    56 * @author Dennis Ploetner <re@lloc.de>
    6  * @since 0.9.8
    77 */
    88
     
    3030            );
    3131
    32             $args = [
     32            $args = array(
    3333                'orderby'    => 'name',
    3434                'order'      => 'ASC',
    3535                'number'     => 10,
    3636                'hide_empty' => 0,
    37             ];
     37            );
    3838
    3939            if ( filter_has_var( INPUT_POST, 's' ) ) {
     
    8282        $options    = msls_options();
    8383        $collection = msls_blog_collection();
    84         $class      = $options->activate_autocomplete ? MslsPostTag::class : MslsPostTagClassic::class;
     84        $class      = $options->activate_autocomplete ? self::class : MslsPostTagClassic::class;
    8585        $obj        = new $class( $options, $collection );
    8686
    8787        $taxonomy = MslsContentTypes::create()->acl_request();
    8888        if ( '' != $taxonomy ) {
    89             add_action( "{$taxonomy}_add_form_fields", [ $obj, 'add_input' ] );
    90             add_action( "{$taxonomy}_edit_form_fields", [ $obj, 'edit_input' ], 10, 2 );
    91             add_action( "edited_{$taxonomy}", [ $obj, 'set' ] );
    92             add_action( "create_{$taxonomy}", [ $obj, 'set' ] );
     89            add_action( "{$taxonomy}_add_form_fields", array( $obj, 'add_input' ) );
     90            add_action( "{$taxonomy}_edit_form_fields", array( $obj, 'edit_input' ), 10, 2 );
     91            add_action( "edited_{$taxonomy}", array( $obj, 'set' ) );
     92            add_action( "create_{$taxonomy}", array( $obj, 'set' ) );
    9393        }
    9494
     
    119119     *
    120120     * @param \WP_Term $tag
    121      * @param string $taxonomy
     121     * @param string   $taxonomy
    122122     */
    123123    public function edit_input( \WP_Term $tag, string $taxonomy ): void {
     
    149149     *
    150150     * @param ?\WP_Term $tag
    151      * @param string $title_format
    152      * @param string $item_format
     151     * @param string    $title_format
     152     * @param string    $item_format
    153153     *
    154154     * @return boolean
     
    161161        }
    162162
    163         $count ++;
     163        ++$count;
    164164
    165165        $blogs = $this->collection->get();
     
    259259     */
    260260    protected function get_select_title(): string {
    261         return apply_filters( 'msls_term_select_title',
    262             __( 'Multisite Language Switcher', 'multisite-language-switcher' ) );
    263     }
    264 
     261        return apply_filters(
     262            'msls_term_select_title',
     263            __( 'Multisite Language Switcher', 'multisite-language-switcher' )
     264        );
     265    }
    265266}
  • multisite-language-switcher/tags/2.7.1/js/msls-widget-block/block.json

    r3088911 r3091013  
    66  "category": "widgets",
    77  "name": "lloc/msls-widget-block",
    8   "version": "2.7.0",
     8  "version": "2.7.1",
    99  "description": "Review the settings for the Multisite Language Switcher plugin, as the block utilizes the API function `the_msls()` for its output.",
    1010  "example": {},
  • multisite-language-switcher/tags/2.7.1/readme.txt

    r3088911 r3091013  
    77Tested up to: 6.5
    88Requires PHP: 7.4
    9 Stable tag: 2.7.0
     9Stable tag: 2.7.1
    1010License: GPLv2 or later
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • multisite-language-switcher/tags/2.7.1/src/msls-widget-block/block.json

    r3088911 r3091013  
    66  "category": "widgets",
    77  "name": "lloc/msls-widget-block",
    8   "version": "2.7.0",
     8  "version": "2.7.1",
    99  "description": "Review the settings for the Multisite Language Switcher plugin, as the block utilizes the API function `the_msls()` for its output.",
    1010  "example": {},
  • multisite-language-switcher/tags/2.7.1/vendor/composer/installed.php

    r3088911 r3091013  
    22    'root' => array(
    33        'name' => 'lloc/multisite-language-switcher',
    4         'pretty_version' => '2.7.0',
    5         'version' => '2.7.0.0',
    6         'reference' => '285b0950c35bcc2fd315e7b7aa6f40e0810c61a7',
     4        'pretty_version' => '2.7.1',
     5        'version' => '2.7.1.0',
     6        'reference' => 'b23adfc6d10fd90ab4f52d3744f94ae2432de916',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    2121        ),
    2222        'lloc/multisite-language-switcher' => array(
    23             'pretty_version' => '2.7.0',
    24             'version' => '2.7.0.0',
    25             'reference' => '285b0950c35bcc2fd315e7b7aa6f40e0810c61a7',
     23            'pretty_version' => '2.7.1',
     24            'version' => '2.7.1.0',
     25            'reference' => 'b23adfc6d10fd90ab4f52d3744f94ae2432de916',
    2626            'type' => 'wordpress-plugin',
    2727            'install_path' => __DIR__ . '/../../',
  • multisite-language-switcher/trunk/MultisiteLanguageSwitcher.php

    r3088911 r3091013  
    88 *
    99 * Plugin Name: Multisite Language Switcher
    10  * Version: 2.7.0
     10 * Version: 2.7.1
    1111 * Plugin URI: http://msls.co/
    1212 * Description: A simple but powerful plugin that will help you to manage the relations of your contents in a multilingual multisite-installation.
     
    4141 */
    4242if ( ! defined( 'MSLS_PLUGIN_VERSION' ) ) {
    43     define( 'MSLS_PLUGIN_VERSION', '2.7.0' );
     43    define( 'MSLS_PLUGIN_VERSION', '2.7.1' );
    4444    define( 'MSLS_PLUGIN_PATH', plugin_basename( __FILE__ ) );
    4545    define( 'MSLS_PLUGIN__FILE__', __FILE__ );
  • multisite-language-switcher/trunk/includes/MslsAdmin.php

    r3088911 r3091013  
    5050             *
    5151             * @since 2.0
    52              *
    5352             */
    5453            $caps = apply_filters( 'msls_admin_caps', 'manage_options' );
    5554            if ( current_user_can( $caps ) ) {
    5655                $title = __( 'Multisite Language Switcher', 'multisite-language-switcher' );
    57                 add_options_page( $title, $title, 'manage_options', $obj->get_menu_slug(), [ $obj, 'render' ] );
    58 
    59                 add_action( 'admin_init', [ $obj, 'register' ] );
    60                 add_action( 'admin_notices', [ $obj, 'has_problems' ] );
    61 
    62                 add_filter( 'msls_admin_validate', [ $obj, 'set_blog_language' ] );
     56                add_options_page( $title, $title, 'manage_options', $obj->get_menu_slug(), array( $obj, 'render' ) );
     57
     58                add_action( 'admin_init', array( $obj, 'register' ) );
     59                add_action( 'admin_notices', array( $obj, 'has_problems' ) );
     60
     61                add_filter( 'msls_admin_validate', array( $obj, 'set_blog_language' ) );
    6362            }
    6463        }
     
    8988     *
    9089     * @param string $method
    91      * @param mixed $args
     90     * @param mixed  $args
    9291     *
    9392     * @return mixed
     
    9796
    9897        if ( is_array( $parts ) && 'rewrite' === $parts[0] ) {
    99             return $this->render_rewrite( $parts[1] );
    100         }
    101 
    102         $checkboxes = [
    103             'activate_autocomplete'   => __( 'Activate experimental autocomplete inputs',
    104                 'multisite-language-switcher' ),
    105             'activate_content_import' => __( 'Activate the content import functionality',
    106                 'multisite-language-switcher' ),
     98            $this->render_rewrite( $parts[1] );
     99            return;
     100        }
     101
     102        $checkboxes = array(
     103            'activate_autocomplete'   => __(
     104                'Activate experimental autocomplete inputs',
     105                'multisite-language-switcher'
     106            ),
     107            'activate_content_import' => __(
     108                'Activate the content import functionality',
     109                'multisite-language-switcher'
     110            ),
    107111            'sort_by_description'     => __( 'Sort languages by description', 'multisite-language-switcher' ),
    108112            'exclude_current_blog'    => __( 'Exclude this blog from output', 'multisite-language-switcher' ),
     
    110114            'output_current_blog'     => __( 'Display link to the current language', 'multisite-language-switcher' ),
    111115            'content_filter'          => __( 'Add hint for available translations', 'multisite-language-switcher' ),
    112         ];
    113 
    114         if ( isset ( $checkboxes[ $method ] ) ) {
    115             echo ( new Group() )->add( new Checkbox( $method, $this->options->$method ) )->add( new Label( $method,
    116                 $checkboxes[ $method ] ) )->render();
     116        );
     117
     118        if ( isset( $checkboxes[ $method ] ) ) {
     119            echo ( new Group() )->add( new Checkbox( $method, $this->options->$method ) )->add(
     120                new Label(
     121                    $method,
     122                    $checkboxes[ $method ]
     123                )
     124            )->render();
    117125        } else {
    118126            $value = ! empty( $this->options->$method ) ? $this->options->$method : '';
     
    123131    /**
    124132     * There is something wrong? Here comes the message...
     133     *
    125134     * @return bool
    126135     */
    127     public function has_problems() {
     136    public function has_problems(): bool {
    128137        $message = '';
    129138
    130139        if ( $this->options->is_empty() ) {
    131140            $message = sprintf(
    132                 __( 'Multisite Language Switcher is almost ready. You must <a href="%s">complete the configuration process</a>.',
    133                     'multisite-language-switcher' ),
     141                __(
     142                    'Multisite Language Switcher is almost ready. You must <a href="%s">complete the configuration process</a>.',
     143                    'multisite-language-switcher'
     144                ),
    134145                esc_url( admin_url( $this->get_options_page_link() ) )
    135146            );
    136147        } elseif ( 1 == count( $this->options->get_available_languages() ) ) {
    137148            $message = sprintf(
    138                 __( 'There are no language files installed. You can <a href="%s">manually install some language files</a> or you could use a <a href="%s">plugin</a> to download these files automatically.',
    139                     'multisite-language-switcher' ),
     149                __(
     150                    'There are no language files installed. You can <a href="%1$s">manually install some language files</a> or you could use a <a href="%2$s">plugin</a> to download these files automatically.',
     151                    'multisite-language-switcher'
     152                ),
    140153                esc_url( 'http://codex.wordpress.org/Installing_WordPress_in_Your_Language#Manually_Installing_Language_Files' ),
    141154                esc_url( 'http://wordpress.org/plugins/wp-native-dashboard/' )
     
    149162     * Render the options-page
    150163     */
    151     public function render() {
     164    public function render(): void {
    152165        printf(
    153166            '<div class="wrap"><div class="icon32" id="icon-options-general"><br/></div><h1>%s</h1>%s<br class="clear"/><form action="options.php" method="post"><p>%s</p>',
    154167            __( 'Multisite Language Switcher Options', 'multisite-language-switcher' ),
    155168            $this->subsubsub(),
    156             __( 'To achieve maximum flexibility, you have to configure each blog separately.',
    157                 'multisite-language-switcher' )
     169            __(
     170                'To achieve maximum flexibility, you have to configure each blog separately.',
     171                'multisite-language-switcher'
     172            )
    158173        );
    159174
     
    163178        printf(
    164179            '<p class="submit"><input name="Submit" type="submit" class="button button-primary" value="%s" /></p></form></div>',
    165             ( $this->options->is_empty() ? __( 'Configure', 'multisite-language-switcher' ) : __( 'Update',
    166                 'multisite-language-switcher' ) )
     180            ( $this->options->is_empty() ? __( 'Configure', 'multisite-language-switcher' ) : __(
     181                'Update',
     182                'multisite-language-switcher'
     183            ) )
    167184        );
    168185    }
     
    171188    /**
    172189     * Create a submenu which contains links to all blogs of the current user
     190     *
    173191     * @return string
    174192     */
     
    176194        $icon_type = $this->options->get_icon_type();
    177195
    178         $arr = [];
     196        $arr = array();
    179197        foreach ( $this->collection->get_plugin_active_blogs() as $blog ) {
    180198            $admin_url = get_admin_url( $blog->userblog_id, $this->get_options_page_link() );
     
    184202        }
    185203
    186         return empty( $arr ) ? '' : sprintf( '<ul class="subsubsub"><li>%s</li></ul>',
    187             implode( ' | </li><li>', $arr ) );
     204        return empty( $arr ) ? '' : sprintf(
     205            '<ul class="subsubsub"><li>%s</li></ul>',
     206            implode( ' | </li><li>', $arr )
     207        );
    188208    }
    189209
     
    194214     */
    195215    public function register() {
    196         register_setting( 'msls', 'msls', [ $this, 'validate' ] );
    197 
    198         $sections = [
     216        register_setting( 'msls', 'msls', array( $this, 'validate' ) );
     217
     218        $sections = array(
    199219            'language_section' => __( 'Language Settings', 'multisite-language-switcher' ),
    200220            'main_section'     => __( 'Main Settings', 'multisite-language-switcher' ),
    201221            'advanced_section' => __( 'Advanced Settings', 'multisite-language-switcher' ),
    202         ];
     222        );
    203223
    204224        global $wp_rewrite;
     
    208228
    209229        foreach ( $sections as $id => $title ) {
    210             add_settings_section( $id, $title, [ $this, $id ], __CLASS__ );
     230            add_settings_section( $id, $title, array( $this, $id ), __CLASS__ );
    211231        }
    212232
     
    217237         *
    218238         * @since 1.0
    219          *
    220239         */
    221240        do_action( 'msls_admin_register', __CLASS__ );
     
    230249     */
    231250    public function language_section(): int {
    232         $map = [ 'blog_language' => __( 'Blog Language', 'multisite-language-switcher' ) ];
     251        $map = array( 'blog_language' => __( 'Blog Language', 'multisite-language-switcher' ) );
    233252
    234253        return $this->add_settings_fields( $map, 'language_section' );
     
    243262     */
    244263    public function main_section(): int {
    245         $map = [
     264        $map = array(
    246265            'display'               => __( 'Display', 'multisite-language-switcher' ),
    247266            'admin_display'         => __( 'Admin Display', 'multisite-language-switcher' ),
     
    256275            'content_filter'        => __( 'Available translations hint', 'multisite-language-switcher' ),
    257276            'content_priority'      => __( 'Hint priority', 'multisite-language-switcher' ),
    258         ];
     277        );
    259278
    260279        return $this->add_settings_fields( $map, 'main_section' );
     
    269288     */
    270289    public function advanced_section(): int {
    271         $map = [
     290        $map = array(
    272291            'activate_autocomplete'   => __( 'Autocomplete', 'multisite-language-switcher' ),
    273292            'image_url'               => __( 'Custom URL for flag-images', 'multisite-language-switcher' ),
     
    275294            'exclude_current_blog'    => __( 'Exclude blog', 'multisite-language-switcher' ),
    276295            'activate_content_import' => __( 'Content import', 'multisite-language-switcher' ),
    277         ];
     296        );
    278297
    279298        return $this->add_settings_fields( $map, 'advanced_section' );
     
    288307     */
    289308    public function rewrites_section(): int {
    290         $map = [];
    291         foreach ( get_post_types( [ 'public' => true ], 'objects' ) as $key => $object ) {
    292             $map["rewrite_{$key}"] = sprintf( __( '%s Slug', 'multisite-language-switcher' ), $object->label );
     309        $map = array();
     310        foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $key => $object ) {
     311            $map[ "rewrite_{$key}" ] = sprintf( __( '%s Slug', 'multisite-language-switcher' ), $object->label );
    293312        }
    294313
     
    297316
    298317    /**
    299      * @param array $map
     318     * @param array  $map
    300319     * @param string $section
    301320     *
     
    304323    protected function add_settings_fields( array $map, string $section ): int {
    305324        foreach ( $map as $id => $title ) {
    306             add_settings_field( $id, $title, [ $this, $id ], __CLASS__, $section, [ 'label_for' => $id ] );
     325            add_settings_field( $id, $title, array( $this, $id ), __CLASS__, $section, array( 'label_for' => $id ) );
    307326        }
    308327
     
    314333         *
    315334         * @since 2.4.4
    316          *
    317335         */
    318336        do_action( "msls_admin_{$section}", __CLASS__, $section );
     
    342360     */
    343361    public function admin_display() {
    344         echo ( new Select( 'admin_display',
     362        echo ( new Select(
     363            'admin_display',
    345364            array(
    346365                'flag'  => __( 'Flag', 'multisite-language-switcher' ),
    347                 'label' => __( 'Label', 'multisite-language-switcher' )
     366                'label' => __( 'Label', 'multisite-language-switcher' ),
    348367            ),
    349             $this->options->admin_display ) )->render();
     368            $this->options->admin_display
     369        ) )->render();
    350370    }
    351371
     
    354374     */
    355375    public function reference_user() {
    356         $users = [];
    357 
    358         foreach ( ( array ) apply_filters( 'msls_reference_users', $this->collection->get_users() ) as $user ) {
     376        $users = array();
     377
     378        foreach ( (array) apply_filters( 'msls_reference_users', $this->collection->get_users() ) as $user ) {
    359379            $users[ $user->ID ] = $user->user_nicename;
    360380        }
     
    364384
    365385            $message = sprintf(
    366                 __( 'Multisite Language Switcher: Collection for reference user has been truncated because it exceeded the maximum of %s users. Please, use the hook "msls_reference_users" to filter the result before!',
    367                     'multisite-language-switcher' ),
     386                __(
     387                    'Multisite Language Switcher: Collection for reference user has been truncated because it exceeded the maximum of %s users. Please, use the hook "msls_reference_users" to filter the result before!',
     388                    'multisite-language-switcher'
     389                ),
    368390                self::MAX_REFERENCE_USERS
    369391            );
     
    391413     */
    392414    public function content_priority() {
    393         $temp     = array_merge( range( 1, 10 ), [ 20, 50, 100 ] );
     415        $temp     = array_merge( range( 1, 10 ), array( 20, 50, 100 ) );
    394416        $arr      = array_combine( $temp, $temp );
    395417        $selected = empty( $this->options->content_priority ) ? 10 : $this->options->content_priority;
     
    430452         *
    431453         * @since 1.0
    432          *
    433454         */
    434455        $arr = (array) apply_filters( 'msls_admin_validate', $arr );
     
    458479        return $arr;
    459480    }
    460 
    461481}
  • multisite-language-switcher/trunk/includes/MslsAdminIcon.php

    r3079846 r3091013  
    11<?php
    2 /**
    3  * MslsAdminIcon
    4  * @author Dennis Ploetner <re@lloc.de>
    5  * @since 0.9.8
    6  */
    72
    83namespace lloc\Msls;
     
    138/**
    149 * Handles the icon links in the backend
     10 *
    1511 * @package Msls
    1612 */
     
    122118    public function set_path(): MslsAdminIcon {
    123119        if ( 'post' != $this->type ) {
    124             $query_vars = [ 'post_type' => $this->type ];
     120            $query_vars = array( 'post_type' => $this->type );
    125121            $this->path = add_query_arg( $query_vars, $this->path );
    126122        }
     
    210206    public function get_a(): string {
    211207        if ( empty( $this->href ) ) {
    212             $title = sprintf( __( 'Create a new translation in the %s-blog', 'multisite-language-switcher' ),
    213                 $this->language );
     208            $title = sprintf(
     209                __( 'Create a new translation in the %s-blog', 'multisite-language-switcher' ),
     210                $this->language
     211            );
    214212            $href  = $this->get_edit_new();
    215213        } else {
    216             $title = sprintf( __( 'Edit the translation in the %s-blog', 'multisite-language-switcher' ),
    217                 $this->language );
     214            $title = sprintf(
     215                __( 'Edit the translation in the %s-blog', 'multisite-language-switcher' ),
     216                $this->language
     217            );
    218218            $href  = $this->href;
    219219        }
     
    233233
    234234        switch ( $this->icon_type ) {
    235             case MslsAdminIcon::TYPE_FLAG:
    236                 $icon = sprintf( '<span class="flag-icon %s">%s</span>',
     235            case self::TYPE_FLAG:
     236                $icon = sprintf(
     237                    '<span class="flag-icon %s">%s</span>',
    237238                    ( new IconSvg() )->get( $this->language ),
    238239                    $this->language
    239240                );
    240241                break;
    241             case MslsAdminIcon::TYPE_LABEL:
    242                 $icon = sprintf( '<span class="language-badge %s">%s</span>',
     242            case self::TYPE_LABEL:
     243                $icon = sprintf(
     244                    '<span class="language-badge %s">%s</span>',
    243245                    $this->language,
    244246                    ( new IconLabel() )->get( $this->language )
     
    246248                break;
    247249            default:
    248                 $icon = sprintf( '<span class="dashicons %s"></span>',
    249                     empty( $this->href ) ? 'dashicons-plus' : 'dashicons-edit' );
     250                $icon = sprintf(
     251                    '<span class="dashicons %s"></span>',
     252                    empty( $this->href ) ? 'dashicons-plus' : 'dashicons-edit'
     253                );
    250254        }
    251255
     
    262266
    263267        if ( null !== $this->id && null !== $this->origin_language ) {
    264             $path = add_query_arg( [ 'msls_id' => $this->id, 'msls_lang' => $this->origin_language ], $this->path );
     268            $path = add_query_arg(
     269                array(
     270                    'msls_id'   => $this->id,
     271                    'msls_lang' => $this->origin_language,
     272                ),
     273                $this->path
     274            );
    265275        }
    266276
     
    276286        return get_admin_url( get_current_blog_id(), $path );
    277287    }
    278 
    279288}
  • multisite-language-switcher/trunk/includes/MslsAdminIconTaxonomy.php

    r3088911 r3091013  
    11<?php
    2 /**
    3  * MslsAdminIconTaxonomy
    4  * @author Dennis Ploetner <re@lloc.de>
    5  * @since 0.9.8
    6  */
    72
    83namespace lloc\Msls;
     
    105/**
    116 * Handles backend icons for taxonomies
     7 *
    128 * @package Msls
    139 */
     
    1612    /**
    1713     * Path
     14     *
    1815     * @var string
    1916     */
     
    2926     */
    3027    public function set_href( int $id ): MslsAdminIcon {
    31         $object_type = MslsTaxonomy::instance()->get_post_type();
     28        $object_type = MslsTaxonomy::instance()->get_post_type();
    3229
    3330        $this->href = get_edit_term_link( $id, $this->type, $object_type );
     
    4037     *
    4138     * @return MslsAdminIconTaxonomy
    42      *
    4339     */
    4440    public function set_path(): MslsAdminIcon {
    45         $args      = [ 'taxonomy' => $this->type ];
     41        $args      = array( 'taxonomy' => $this->type );
    4642        $post_type = MslsTaxonomy::instance()->get_post_type();
    4743
    48         $post_type !== '' && $args['post_type'] = $post_type;
     44        $post_type !== '' && $args['post_type'] = $post_type;
    4945
    5046        $this->path = add_query_arg( $args, $this->path );
     
    5248        return $this;
    5349    }
    54 
    5550}
  • multisite-language-switcher/trunk/includes/MslsBlog.php

    r3079846 r3091013  
    1 <?php
     1<?php declare( strict_types=1 );
    22
    33namespace lloc\Msls;
     
    1313    /**
    1414     * WordPress generates such an object
     15     *
    1516     * @var \StdClass
    1617     */
     
    1819
    1920    /**
    20      * Language-code eg. de_DE
     21     * Language-code e.g. "de_DE", or "en_US", or "it_IT"
     22     *
    2123     * @var string
    2224     */
    23     private $language;
    24 
    25     /**
    26      * Description eg. Deutsch
     25    private string $language;
     26
     27    /**
     28     * Description e.g. "Deutsch", or "English", or "Italiano"
     29     *
    2730     * @var string
    2831     */
    29     private $description;
     32    private string $description;
    3033
    3134    /**
     
    3336     *
    3437     * @param ?\StdClass $obj
    35      * @param string $description
     38     * @param string     $description
    3639     */
    3740    public function __construct( $obj, $description ) {
     
    6164     *
    6265     * The method returns the stored language if the description is empty.
     66     *
    6367     * @return string
    6468     */
     
    7781        $icon = ( new MslsAdminIcon( null ) )->set_language( $this->language )->set_icon_type( $icon_type );
    7882
    79         return sprintf( '%1$s %2$s',
     83        return sprintf(
     84            '%1$s %2$s',
    8085            $this->obj->blogname,
    81             '<span class="msls-icon-wrapper flag">' . $icon->get_icon() . '</span>' );
     86            '<span class="msls-icon-wrapper flag">' . $icon->get_icon() . '</span>'
     87        );
    8288    }
    8389
     
    129135        switch_to_blog( $this->obj->userblog_id );
    130136
    131         if ( is_object( $options ) && method_exists( $options,
    132                 'has_value' ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) {
     137        if ( is_object( $options ) && method_exists(
     138            $options,
     139            'has_value'
     140        ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) {
    133141            $url = apply_filters( 'mlsl_blog_get_permalink', $options->get_permalink( $this->get_language() ), $this );
    134142        }
     
    201209        return $blavatar_html;
    202210    }
    203 
    204211}
  • multisite-language-switcher/trunk/includes/MslsBlogCollection.php

    r3088911 r3091013  
    1 <?php
    2 /**
    3  * MslsBlogCollection
    4  * @author Dennis Ploetner <re@lloc.de>
    5  * @since 0.9.8
    6  */
     1<?php declare( strict_types=1 );
    72
    83namespace lloc\Msls;
     
    1712    /**
    1813     * ID of the current blog
     14     *
    1915     * @var int
    2016     */
     
    2319    /**
    2420     * True if the current blog should be in the output
     21     *
    2522     * @var bool
    2623     */
     
    2926    /**
    3027     * Collection of MslsBlog-objects
     28     *
    3129     * @var MslsBlog[]
    3230     */
    33     private $objects = [];
     31    private $objects = array();
    3432
    3533    /**
    3634     * Order output by language or description
     35     *
    3736     * @var string
    3837     */
     
    4140    /**
    4241     * Active plugins in the whole network
     42     *
    4343     * @var array
    4444     */
     
    4747    /**
    4848     * Container for hreflang-mapping
     49     *
    4950     * @var array
    5051     */
    51     private $hreflangmap = [];
     52    private $hreflangmap = array();
    5253
    5354    /**
     
    5657    public function __construct() {
    5758        if ( ! has_filter( 'msls_blog_collection_description' ) ) {
    58             add_filter( 'msls_blog_collection_description', [ $this, 'get_configured_blog_description' ], 10, 2 );
     59            add_filter( 'msls_blog_collection_description', array( $this, 'get_configured_blog_description' ), 10, 2 );
    5960        }
    6061
     
    7374             *
    7475             * @since 0.9.8
    75              *
    7676             */
    7777            $blogs_collection = (array) apply_filters(
     
    9898                }
    9999            }
    100             uasort( $this->objects, [ MslsBlog::class, $this->objects_order ] );
     100            uasort( $this->objects, array( MslsBlog::class, $this->objects_order ) );
    101101        }
    102102    }
     
    105105     * Returns the description of a configured blog or false if it is not configured
    106106     *
    107      * @param int $blog_id
     107     * @param int         $blog_id
    108108     * @param string|bool $description
    109109     *
     
    133133     */
    134134    public function get_blogs_of_reference_user( MslsOptions $options ) {
    135         $reference_user = $options->has_value( 'reference_user' ) ? $options->reference_user : current( $this->get_users( 'ID',
    136             1 ) );
     135        $reference_user = $options->has_value( 'reference_user' ) ? $options->reference_user : current(
     136            $this->get_users(
     137                'ID',
     138                1
     139            )
     140        );
    137141        $blogs          = get_blogs_of_user( $reference_user );
    138142
     
    185189    /**
    186190     * Get the id of the current blog
     191     *
    187192     * @return int
    188193     */
     
    213218    /**
    214219     * Gets current blog as object
     220     *
    215221     * @return MslsBlog|null
    216222     */
     
    221227    /**
    222228     * Gets an array with all blog-objects
     229     *
    223230     * @return MslsBlog[]
    224231     */
     
    236243    public function is_plugin_active( $blog_id ) {
    237244        if ( ! is_array( $this->active_plugins ) ) {
    238             $this->active_plugins = get_site_option( 'active_sitewide_plugins', [] );
     245            $this->active_plugins = get_site_option( 'active_sitewide_plugins', array() );
    239246        }
    240247
     
    244251        }
    245252
    246         $plugins = get_blog_option( $blog_id, 'active_plugins', [] );
     253        $plugins = get_blog_option( $blog_id, 'active_plugins', array() );
    247254
    248255        return in_array( $path, $plugins );
     
    251258    /**
    252259     * Gets only blogs where the plugin is active
     260     *
    253261     * @return array
    254262     */
    255263    public function get_plugin_active_blogs() {
    256         $arr = [];
     264        $arr = array();
    257265
    258266        foreach ( $this->get_objects() as $blog ) {
     
    267275    /**
    268276     * Gets an array of all - but not the current - blog-objects
     277     *
    269278     * @return MslsBlog[]
    270279     */
     
    286295     * @return MslsBlog[]
    287296     */
    288     public function get_filtered( $filter = false ) {
    289         if ( ! $filter && $this->current_blog_output ) {
    290             return $this->get_objects();
    291         }
    292 
    293         return $this->get();
     297    public function get_filtered( bool $filter = false ): array {
     298        return ! $filter && $this->current_blog_output ? $this->get_objects() : $this->get();
    294299    }
    295300
     
    297302     * Gets the registered users of the current blog
    298303     *
    299      * @param string $fields
     304     * @param string     $fields
    300305     * @param int|string $number
    301306     *
     
    303308     */
    304309    public function get_users( $fields = 'all', $number = '' ) {
    305         $args = [
     310        $args = array(
    306311            'blog_id'     => $this->current_blog_id,
    307312            'orderby'     => 'registered',
     
    309314            'number'      => $number,
    310315            'count_total' => false,
    311         ];
     316        );
    312317
    313318        $args = (array) apply_filters( 'msls_get_users', $args );
     
    319324     * Returns a specific blog language.
    320325     *
    321      * @param int $blog_id
     326     * @param int    $blog_id
    322327     * @param string $default
    323328     *
     
    329334        }
    330335
    331         $language = ( string ) get_blog_option( $blog_id, 'WPLANG' );
     336        $language = (string) get_blog_option( $blog_id, 'WPLANG' );
    332337
    333338        return '' !== $language ? $language : $default;
    334339    }
    335 
    336340}
  • multisite-language-switcher/trunk/includes/MslsOptions.php

    r3088911 r3091013  
    22/**
    33 * MslsOptions
     4 *
    45 * @author Dennis Ploetner <re@lloc.de>
    56 * @since 0.9.8
     
    1213/**
    1314 * General options class
     15 *
    1416 * @package Msls
    1517 * @property bool $activate_autocomplete
     
    3032    /**
    3133     * Args
     34     *
    3235     * @var array
    3336     */
     
    3639    /**
    3740     * Name
     41     *
    3842     * @var string
    3943     */
     
    4246    /**
    4347     * Exists
     48     *
    4449     * @var bool
    4550     */
     
    4853    /**
    4954     * Separator
     55     *
    5056     * @var string
    5157     */
     
    5460    /**
    5561     * Autoload
     62     *
    5663     * @var string
    5764     */
     
    6067    /**
    6168     * Available languages
    62      * @var array
    63      */
    64     private $available_languages;
     69     *
     70     * @var array<string, string>
     71     */
     72    private array $available_languages;
    6573
    6674    /**
    6775     * Rewrite with front
     76     *
    6877     * @var bool
    6978     */
     
    100109        }
    101110
    102         add_filter( 'check_url', [ $options, 'check_for_blog_slug' ], 10, 2 );
     111        add_filter( 'msls_get_postlink', array( $options, 'check_for_blog_slug' ), 10, 2 );
    103112
    104113        return $options;
     
    107116    /**
    108117     * Determines if the current page is the main page (front page, search, 404).
    109     *
    110     * @return boolean
     118    *
     119    * @return boolean
    111120     */
    112121    public static function is_main_page() {
     
    116125    /**
    117126     * Determines if the current page is a category, tag or taxonomy page.
    118     *
     127    *
    119128     * @return boolean
    120129     */
     
    125134    /**
    126135     * Determines if the current page is an archive page for a date, author, or any other post type.
    127     *
     136    *
    128137     * @return boolean
    129138     */
     
    143152    /**
    144153     * Gets an element of arg by index
    145     *
    146      * The returned value will either be cast to the type of `$retval` or, if nothing is set at this index, it will be the value of `$retval`.
    147      *
    148      * @param int $idx
    149      * @param mixed $val
     154    *
     155     * The returned value will either be cast to the type of `$default` or, if nothing is set at this index, it will be the value of `$default`.
     156     *
     157     * @param int   $index
     158     * @param mixed $default
    150159     *
    151160     * @return mixed
    152161     */
    153     public function get_arg( $idx, $val = null ) {
    154         $arg = isset( $this->args[ $idx ] ) ? $this->args[ $idx ] : $val;
    155         settype( $arg, gettype( $val ) );
     162    public function get_arg( int $index, $default = null ) {
     163        $arg = $this->args[ $index ] ?? $default;
     164
     165        settype( $arg, gettype( $default ) );
    156166
    157167        return $arg;
     
    177187    /**
    178188     * Delete
     189     *
    179190     * @codeCoverageIgnore
    180191     */
     
    201212         * Mapping for us language code
    202213         */
    203         $map = [ 'us' => 'en_US', 'en' => 'en_US' ];
     214        $map = array(
     215            'us' => 'en_US',
     216            'en' => 'en_US',
     217        );
    204218        foreach ( $map as $old => $new ) {
    205219            if ( isset( $arr[ $old ] ) ) {
     
    230244         *
    231245         * @since 0.9.8
    232          *
    233246         */
    234247        $postlink = (string) apply_filters(
     
    254267    /**
    255268     * Get the queried taxonomy
     269     *
    256270     * @return string
    257271     */
     
    262276    /**
    263277     * Get current link
     278     *
    264279     * @return string
    265280     */
     
    270285    /**
    271286     * Is excluded
     287     *
    272288     * @return bool
    273289     */
     
    278294    /**
    279295     * Is content
     296     *
    280297     * @return bool
    281298     */
     
    286303    /**
    287304     * Get order
     305     *
    288306     * @return string
    289307     */
     
    306324     * Returns slug for a post type
    307325     *
     326     * @todo This method is not used anywhere in the codebase. Should it be removed?
     327     *
    308328     * @param string $post_type
    309329     *
    310330     * @return string
    311331     */
    312     public function get_slug( $post_type ) {
     332    public function get_slug( string $post_type ): string {
    313333        $key = "rewrite_{$post_type}";
    314334
    315         error_log( $key );
    316 
    317         return isset( $this->$key ) ? $this->$key : '';
     335        return $this->$key ?? '';
    318336    }
    319337
     
    335353     */
    336354    public function get_flag_url( $language ) {
    337         if ( ! is_admin() && isset( $this->image_url ) ) {
    338             $url = $this->__get( 'image_url' );
    339         } else {
    340             $url = $this->get_url( 'flags' );
    341         }
     355        $url = ! is_admin() && isset( $this->image_url ) ? $this->__get( 'image_url' ) : $this->get_url( 'flags' );
    342356
    343357        /**
     
    347361         *
    348362         * @since 0.9.9
    349          *
    350363         */
    351364        $url = (string) apply_filters( 'msls_options_get_flag_url', $url );
     
    360373         *
    361374         * @since 1.0.3
    362          *
    363375         */
    364376        $icon = (string) apply_filters( 'msls_options_get_flag_icon', $icon, $language );
     
    376388    public function get_available_languages() {
    377389        if ( empty( $this->available_languages ) ) {
    378             $this->available_languages = [
     390            $this->available_languages = array(
    379391                'en_US' => __( 'American English', 'multisite-language-switcher' ),
    380             ];
     392            );
    381393
    382394            foreach ( get_available_languages() as $code ) {
     
    390402             *
    391403             * @since 1.0
    392              *
    393404             */
    394405            $this->available_languages = (array) apply_filters(
     
    404415     * The 'blog'-slug-problem :/
    405416     *
    406      * @param string $url
     417     * @param string      $url
    407418     * @param MslsOptions $options
    408419     *
     
    444455        return MslsAdminIcon::TYPE_LABEL === $this->admin_display ? MslsAdminIcon::TYPE_LABEL : MslsAdminIcon::TYPE_FLAG;
    445456    }
    446 
    447457}
  • multisite-language-switcher/trunk/includes/MslsOptionsPost.php

    r3079846 r3091013  
    1 <?php
    2 /**
    3  * MslsOptionsPost
    4  * @author Dennis Ploetner <re@lloc.de>
    5  * @since 0.9.8
    6  */
     1<?php declare( strict_types=1 );
    72
    83namespace lloc\Msls;
     
    105/**
    116 * Post options
     7 *
    128 * @package Msls
    139 */
     
    1612    /**
    1713     * Separator
     14     *
    1815     * @var string
    1916     */
     
    2219    /**
    2320     * Autoload
     21     *
    2422     * @var string
    2523     */
     
    4846        }
    4947
    50         global $current_site;
    51         $blog_id = msls_blog_collection()->get_blog_id( $language );
    52         if ( $current_site->blog_id != $blog_id ) {
    53             $option = get_blog_option( $blog_id, 'msls' );
    54             //error_log( print_r( $option, true ) );
    55         }
     48        $post_link = get_permalink( $post );
    5649
    57         return apply_filters( 'check_url', get_permalink( $post ), $this );
     50        $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' );
     51
     52        return apply_filters( 'msls_get_postlink', $post_link, $this );
    5853    }
    5954
     
    6661        return (string) get_permalink( $this->get_arg( 0, 0 ) );
    6762    }
    68 
    6963}
  • multisite-language-switcher/trunk/includes/MslsOptionsQuery.php

    r3079846 r3091013  
    22/**
    33 * MslsOptionsQuery
     4 *
    45 * @author Dennis Ploetner <re@lloc.de>
    56 * @since 0.9.8
     
    1718    /**
    1819     * Rewrite with front
     20     *
    1921     * @var bool
    2022     */
     
    6264    public function get_postlink( $language ) {
    6365        if ( $this->has_value( $language ) ) {
    64             $link = $this->get_current_link();
    65             if ( ! empty( $link ) ) {
    66                 return apply_filters( 'check_url', $link, $this );
     66            $post_link = $this->get_current_link();
     67            if ( ! empty( $post_link ) ) {
     68                $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' );
     69
     70                return apply_filters( 'msls_get_postlink', $post_link, $this );
    6771            }
    6872        }
     
    7074        return '';
    7175    }
    72 
    7376}
  • multisite-language-switcher/trunk/includes/MslsOptionsQueryAuthor.php

    r3079846 r3091013  
    22/**
    33 * MslsOptionsQueryAuthor
     4 *
    45 * @author Dennis Ploetner <re@lloc.de>
    56 * @since 0.9.8
     
    1617
    1718    /**
    18      * Check if the array has an non empty item which has $language as a key
     19     * Check if the array has a non-empty item which has $language as a key
    1920     *
    2021     * @param string $language
     
    4546        return get_author_posts_url( $this->get_arg( 0, 0 ) );
    4647    }
    47 
    4848}
  • multisite-language-switcher/trunk/includes/MslsOptionsQueryPostType.php

    r3079846 r3091013  
    22/**
    33 * MslsOptionsQueryPostType
     4 *
    45 * @author Dennis Ploetner <re@lloc.de>
    56 * @since 0.9.8
     
    1617
    1718    /**
    18      * Check if the array has an non empty item which has $language as a key
     19     * Check if the array has a non-empty item which has $language as a key
    1920     *
    2021     * @param string $language
     
    3839        return (string) get_post_type_archive_link( $this->get_arg( 0, '' ) );
    3940    }
    40 
    4141}
  • multisite-language-switcher/trunk/includes/MslsOptionsQueryYear.php

    r1990702 r3091013  
    22/**
    33 * MslsOptionsQueryYear
     4 *
    45 * @author Dennis Ploetner <re@lloc.de>
    56 * @since 0.9.8
     
    1617
    1718    /**
    18      * Check if the array has an non empty item which has $language as a key
     19     * Check if the array has a non-empty item which has $language as a key
    1920     *
    2021     * @param string $language
     
    4546        return get_year_link( $this->get_arg( 0, 0 ) );
    4647    }
    47 
    4848}
  • multisite-language-switcher/trunk/includes/MslsOptionsTax.php

    r3079846 r3091013  
    22/**
    33 * MslsOptionsTax
     4 *
    45 * @author Dennis Ploetner <re@lloc.de>
    56 * @since 0.9.8
     
    1011/**
    1112 * Taxonomy options
     13 *
    1214 * @package Msls
    1315 */
     
    1618    /**
    1719     * Separator
     20     *
    1821     * @var string
    1922     */
     
    2225    /**
    2326     * Autoload
     27     *
    2428     * @var string
    2529     */
     
    5963
    6064        if ( $req ) {
    61             add_filter( 'check_url', [ $options, 'check_base' ], 9, 2 );
     65            add_filter( 'msls_get_postlink', array( $options, 'check_base' ), 9, 2 );
    6266        } else {
    6367            global $wp_rewrite;
     
    7175    /**
    7276     * Get the queried taxonomy
     77     *
    7378     * @return string
    7479     */
     
    9398     */
    9499    public function get_postlink( $language ) {
    95         $url = '';
     100        $post_link = '';
    96101
    97102        if ( $this->has_value( $language ) ) {
    98             $url = $this->get_term_link( (int) $this->__get( $language ) );
     103            $post_link = $this->get_term_link( (int) $this->__get( $language ) );
    99104        }
    100105
    101         return apply_filters( 'check_url', $url, $this );
     106        $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' );
     107
     108        return apply_filters( 'msls_get_postlink', $post_link, $this );
    102109    }
    103110
    104111    /**
    105112     * Get current link
     113     *
    106114     * @return string
    107115     */
     
    130138        return '';
    131139    }
    132 
    133140}
  • multisite-language-switcher/trunk/includes/MslsPlugin.php

    r3088911 r3091013  
    250250     */
    251251    public function admin_bar_init() {
    252         if ( is_admin_bar_showing() && is_super_admin() ) {
     252        if ( is_admin_bar_showing() ) {
    253253            add_action( 'admin_bar_menu', array( __CLASS__, 'update_adminbar' ), 999 );
    254254
  • multisite-language-switcher/trunk/includes/MslsPostTag.php

    r3088911 r3091013  
    1 <?php
     1<?php declare( strict_types=1 );
     2
    23/**
    34 * MslsPostTag
    45 *
    56 * @author Dennis Ploetner <re@lloc.de>
    6  * @since 0.9.8
    77 */
    88
     
    3030            );
    3131
    32             $args = [
     32            $args = array(
    3333                'orderby'    => 'name',
    3434                'order'      => 'ASC',
    3535                'number'     => 10,
    3636                'hide_empty' => 0,
    37             ];
     37            );
    3838
    3939            if ( filter_has_var( INPUT_POST, 's' ) ) {
     
    8282        $options    = msls_options();
    8383        $collection = msls_blog_collection();
    84         $class      = $options->activate_autocomplete ? MslsPostTag::class : MslsPostTagClassic::class;
     84        $class      = $options->activate_autocomplete ? self::class : MslsPostTagClassic::class;
    8585        $obj        = new $class( $options, $collection );
    8686
    8787        $taxonomy = MslsContentTypes::create()->acl_request();
    8888        if ( '' != $taxonomy ) {
    89             add_action( "{$taxonomy}_add_form_fields", [ $obj, 'add_input' ] );
    90             add_action( "{$taxonomy}_edit_form_fields", [ $obj, 'edit_input' ], 10, 2 );
    91             add_action( "edited_{$taxonomy}", [ $obj, 'set' ] );
    92             add_action( "create_{$taxonomy}", [ $obj, 'set' ] );
     89            add_action( "{$taxonomy}_add_form_fields", array( $obj, 'add_input' ) );
     90            add_action( "{$taxonomy}_edit_form_fields", array( $obj, 'edit_input' ), 10, 2 );
     91            add_action( "edited_{$taxonomy}", array( $obj, 'set' ) );
     92            add_action( "create_{$taxonomy}", array( $obj, 'set' ) );
    9393        }
    9494
     
    119119     *
    120120     * @param \WP_Term $tag
    121      * @param string $taxonomy
     121     * @param string   $taxonomy
    122122     */
    123123    public function edit_input( \WP_Term $tag, string $taxonomy ): void {
     
    149149     *
    150150     * @param ?\WP_Term $tag
    151      * @param string $title_format
    152      * @param string $item_format
     151     * @param string    $title_format
     152     * @param string    $item_format
    153153     *
    154154     * @return boolean
     
    161161        }
    162162
    163         $count ++;
     163        ++$count;
    164164
    165165        $blogs = $this->collection->get();
     
    259259     */
    260260    protected function get_select_title(): string {
    261         return apply_filters( 'msls_term_select_title',
    262             __( 'Multisite Language Switcher', 'multisite-language-switcher' ) );
    263     }
    264 
     261        return apply_filters(
     262            'msls_term_select_title',
     263            __( 'Multisite Language Switcher', 'multisite-language-switcher' )
     264        );
     265    }
    265266}
  • multisite-language-switcher/trunk/js/msls-widget-block/block.json

    r3088911 r3091013  
    66  "category": "widgets",
    77  "name": "lloc/msls-widget-block",
    8   "version": "2.7.0",
     8  "version": "2.7.1",
    99  "description": "Review the settings for the Multisite Language Switcher plugin, as the block utilizes the API function `the_msls()` for its output.",
    1010  "example": {},
  • multisite-language-switcher/trunk/readme.txt

    r3088911 r3091013  
    77Tested up to: 6.5
    88Requires PHP: 7.4
    9 Stable tag: 2.7.0
     9Stable tag: 2.7.1
    1010License: GPLv2 or later
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • multisite-language-switcher/trunk/src/msls-widget-block/block.json

    r3088911 r3091013  
    66  "category": "widgets",
    77  "name": "lloc/msls-widget-block",
    8   "version": "2.7.0",
     8  "version": "2.7.1",
    99  "description": "Review the settings for the Multisite Language Switcher plugin, as the block utilizes the API function `the_msls()` for its output.",
    1010  "example": {},
  • multisite-language-switcher/trunk/vendor/composer/installed.php

    r3088911 r3091013  
    22    'root' => array(
    33        'name' => 'lloc/multisite-language-switcher',
    4         'pretty_version' => '2.7.0',
    5         'version' => '2.7.0.0',
    6         'reference' => '285b0950c35bcc2fd315e7b7aa6f40e0810c61a7',
     4        'pretty_version' => '2.7.1',
     5        'version' => '2.7.1.0',
     6        'reference' => 'b23adfc6d10fd90ab4f52d3744f94ae2432de916',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    2121        ),
    2222        'lloc/multisite-language-switcher' => array(
    23             'pretty_version' => '2.7.0',
    24             'version' => '2.7.0.0',
    25             'reference' => '285b0950c35bcc2fd315e7b7aa6f40e0810c61a7',
     23            'pretty_version' => '2.7.1',
     24            'version' => '2.7.1.0',
     25            'reference' => 'b23adfc6d10fd90ab4f52d3744f94ae2432de916',
    2626            'type' => 'wordpress-plugin',
    2727            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.