Plugin Directory

Changeset 3409411


Ignore:
Timestamp:
12/03/2025 11:46:29 AM (4 months ago)
Author:
realloc
Message:

Update to version 2.10.0 from GitHub

Location:
multisite-language-switcher
Files:
1590 added
10 deleted
130 edited
1 copied

Legend:

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

    r3287198 r3409411  
    33 * Multisite Language Switcher Plugin
    44 *
    5  * @copyright Copyright (C) 2011-2022, Dennis Ploetner, re@lloc.de
    6  * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 or later
    7  * @wordpress-plugin
    8  *
    95 * Plugin Name: Multisite Language Switcher
    10  * Version: 2.9.6
     6 * Version: 2.10.0
    117 * Plugin URI: http://msls.co/
    128 * Description: A simple but powerful plugin that will help you to manage the relations of your contents in a multilingual multisite-installation.
     
    2925 * along with this program; if not, write to the Free Software
    3026 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     27 *
     28 * @copyright Copyright (C) 2011-2022, Dennis Ploetner, re@lloc.de
     29 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 or later
     30 * @wordpress-plugin
     31 * @package msls
    3132 */
    3233
     
    4142 */
    4243if ( ! defined( 'MSLS_PLUGIN_VERSION' ) ) {
    43     define( 'MSLS_PLUGIN_VERSION', '2.9.6' );
     44    define( 'MSLS_PLUGIN_VERSION', '2.10.0' );
    4445    define( 'MSLS_PLUGIN_PATH', plugin_basename( __FILE__ ) );
    4546    define( 'MSLS_PLUGIN__FILE__', __FILE__ );
    4647
     48    require_once __DIR__ . '/includes/deprectated.php';
     49
    4750    /**
    4851     * Get the output for using the links to the translations in your code
    4952     *
    5053     * @package Msls
    51      *
    5254     * @param mixed $attr
    53      *
    54      * @return string
    55      */
    56     function get_the_msls( $attr ): string {
     55     * @return string
     56     */
     57    function msls_get_switcher( $attr ): string {
    5758        $arr = is_array( $attr ) ? $attr : array();
    5859        $obj = apply_filters( 'msls_get_output', null );
     
    7677     * @param string[] $arr
    7778     */
    78     function the_msls( array $arr = array() ): void {
    79         // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    80         echo get_the_msls( $arr );
     79    function msls_the_switcher( array $arr = array() ): void {
     80        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     81        echo msls_get_switcher( $arr );
    8182    }
    8283
     
    8889     * @return string
    8990     */
    90     function get_msls_flag_url( string $locale ): string {
     91    function msls_get_flag_url( string $locale ): string {
    9192        return ( new \lloc\Msls\MslsOptions() )->get_flag_url( $locale );
    9293    }
     
    9697     *
    9798     * @param string $locale
    98      *
    99      * @return string
    100      */
    101     function get_msls_blog_description( string $locale, string $default = '' ): string {
     99     * @param string $preset
     100     *
     101     * @return string
     102     */
     103    function msls_get_blog_description( string $locale, string $preset = '' ): string {
    102104        $blog = msls_blog( $locale );
    103105
    104         return $blog ? $blog->get_description() : $default;
     106        return $blog ? $blog->get_description() : $preset;
    105107    }
    106108
     
    109111     *
    110112     * @param string $locale
    111      * @param string $default
    112      *
    113      * @return string
    114      */
    115     function get_msls_permalink( string $locale, string $default = '' ): string {
     113     * @param string $preset
     114     *
     115     * @return string
     116     */
     117    function msls_get_permalink( string $locale, string $preset = '' ): string {
    116118        $url  = null;
    117119        $blog = msls_blog( $locale );
     
    122124        }
    123125
    124         return $url ?? $default;
     126        return $url ?? $preset;
    125127    }
    126128
     
    236238     * @return void
    237239     */
    238     if ( ! function_exists( '__return_void' ) ) {
    239         function __return_void(): void {
    240         }
     240    function msls_return_void(): void {
    241241    }
    242242
  • multisite-language-switcher/tags/2.10.0/includes/Component/Icon.php

    r3167915 r3409411  
    1919     */
    2020    public function __construct() {
    21         if ( $this->get_include() ) {
    22             $this->map = include $this->get_include();
    23         }
     21        $filePath = $this->get_include();
     22
     23        $this->map = ! is_null( $filePath ) && is_readable( $filePath ) ? require $filePath : array();
    2424    }
    2525
     
    3232     */
    3333    protected function maybe( string $language, string $prefix = '', string $postfix = '' ): string {
    34         if ( 5 == strlen( $language ) ) {
     34        if ( 5 === strlen( $language ) ) {
    3535            $language = strtolower( substr( $language, - 2 ) );
    3636        }
     
    4040
    4141    /**
    42      * @return string
     42     * @return ?string
    4343     */
    44     abstract protected function get_include(): string;
     44    protected function get_include(): ?string {
     45        return null;
     46    }
    4547
    4648    /**
  • multisite-language-switcher/tags/2.10.0/includes/Component/Icon/IconLabel.php

    r3287198 r3409411  
    1313
    1414    /**
    15      * @return string
    16      */
    17     protected function get_include(): string {
    18         return '';
    19     }
    20 
    21     /**
    2215     * @param string $language
    2316     *
  • multisite-language-switcher/tags/2.10.0/includes/Component/Icon/IconPng.php

    r3167915 r3409411  
    1313final class IconPng extends Icon {
    1414
    15     const FLAGS_FILE = 'flags/flags.php';
     15    const FLAGS_FILE = 'assets/flags/flags.php';
    1616
    1717    /**
  • multisite-language-switcher/tags/2.10.0/includes/Component/Icon/IconSvg.php

    r3167915 r3409411  
    1313final class IconSvg extends Icon {
    1414
    15     const FLAGS_FILE = 'css-flags/flags.php';
     15    const FLAGS_FILE = 'assets/css-flags/flags.php';
    1616
    1717    /**
  • multisite-language-switcher/tags/2.10.0/includes/Component/Input/Select.php

    r3167915 r3409411  
    2020
    2121    /**
    22      * @param string  $key Name and ID of the form-element
    23      * @param mixed[] $arr Options as associative array
    24      * @param ?string $selected Values which should be selected
     22     * @param string  $key Name and ID of the form-element.
     23     * @param mixed[] $arr Options as an associative array.
     24     * @param ?string $selected Values which should be selected.
    2525     */
    2626    public function __construct( string $key, array $arr, ?string $selected = null ) {
  • multisite-language-switcher/tags/2.10.0/includes/Component/Input/Text.php

    r3199861 r3409411  
    3333     * @param string|null $value
    3434     * @param int         $size
    35      * @param bool        $readonly
     35     * @param bool        $read_only
    3636     */
    37     public function __construct( string $key, ?string $value, int $size = self::DEFAULT_SIZE, bool $readonly = false ) {
     37    public function __construct( string $key, ?string $value, int $size = self::DEFAULT_SIZE, bool $read_only = false ) {
    3838        $this->key      = $key;
    3939        $this->value    = $value;
    4040        $this->size     = $size;
    41         $this->readonly = $readonly ? ' readonly="readonly"' : '';
     41        $this->readonly = $read_only ? ' readonly="readonly"' : '';
    4242    }
    4343
  • multisite-language-switcher/tags/2.10.0/includes/Component/Wrapper.php

    r3167915 r3409411  
    55final class Wrapper extends Component {
    66
     7    /**
     8     * @var string
     9     */
    710    protected string $element;
    811
     12    /**
     13     * @var string
     14     */
    915    protected string $content;
    1016
  • multisite-language-switcher/tags/2.10.0/includes/ContentImport/AttachmentPathFinder.php

    r3287198 r3409411  
    1111    /**
    1212     * @param array<string, array<string, mixed>> $sources
    13      * @param mixed                               $sizeArray
    14      * @param string                              $imageSrc
    15      * @param mixed                               $imageMeta
    16      * @param int                                 $attachmentId
     13     * @param mixed                               $size_array
     14     * @param string                              $image_src
     15     * @param mixed                               $image_meta
     16     * @param int                                 $attachment_id
    1717     *
    1818     * @return array<string, mixed>
    1919     */
    20     public function filter_srcset( array $sources, $sizeArray, $imageSrc, $imageMeta, $attachmentId ): array {
    21         if ( ! $msls_imported = $this->has_import_data( $attachmentId ) ) {
     20    public function filter_srcset( array $sources, $size_array, $image_src, $image_meta, $attachment_id ): array {
     21        $msls_imported = $this->has_import_data( $attachment_id );
     22        if ( ! $msls_imported ) {
    2223            return $sources;
    2324        }
     
    2829        }
    2930
    30         $extension           = '.' . pathinfo( $source_post->guid, PATHINFO_EXTENSION );
    31         $pattern             = '/(-[\\d]+x[\\d]+)*' . preg_quote( $extension, '/' ) . '$/';
    32         $srcWithoutExtension = preg_replace( $pattern, '', $imageSrc );
     31        $extension             = '.' . pathinfo( $source_post->guid, PATHINFO_EXTENSION );
     32        $pattern               = '/(-[\\d]+x[\\d]+)*' . preg_quote( $extension, '/' ) . '$/';
     33        $src_without_extension = preg_replace( $pattern, '', $image_src );
    3334
    3435        foreach ( $sources as $key => &$value ) {
    3536            preg_match( $pattern, $value['url'], $matches );
    3637            $w_and_h      = ! empty( $matches[1] ) ? $matches[1] : '';
    37             $value['url'] = $srcWithoutExtension . $w_and_h . $extension;
     38            $value['url'] = $src_without_extension . $w_and_h . $extension;
    3839        }
    3940
     
    7273     */
    7374    public function filter_attachment_url( $url, $attachment_id ) {
    74         if ( ! $msls_imported = $this->has_import_data( $attachment_id ) ) {
     75        $msls_imported = $this->has_import_data( $attachment_id );
     76        if ( ! $msls_imported ) {
    7577            return $url;
    7678        }
  • multisite-language-switcher/tags/2.10.0/includes/ContentImport/ContentImporter.php

    r3287198 r3409411  
    2222    use WithRequestPostAttributes;
    2323
     24    const MSLS_BEFORE_IMPORT_ACTION = 'msls_content_import_before_import';
     25
     26    const MSLS_AFTER_IMPORT_ACTION = 'msls_content_import_after_import';
     27
    2428    /**
    2529     * @var MslsMain
    2630     */
    27     protected $main;
     31    protected MslsMain $main;
     32
     33    /**
     34     * @var ImportLogger|null
     35     */
    2836    protected ?ImportLogger $logger = null;
     37
     38    /**
     39     * @var Relations|null
     40     */
    2941    protected ?Relations $relations = null;
    3042
     
    3244     * @var bool Whether the class should handle requests or not.
    3345     */
    34     protected $handle = true;
     46    protected bool $handle = true;
    3547
    3648    /**
    3749     * @var int The ID of the post the class created while handling the request, if any.
    3850     */
    39     protected $has_created_post = 0;
     51    protected int $has_created_post = 0;
    4052
    4153    /**
     
    4557     */
    4658    public function __construct( ?MslsMain $main = null ) {
    47         $this->main = $main ?: MslsMain::create();
    48     }
    49 
    50     /**
    51      * @return \lloc\Msls\ContentImport\ImportLogger
    52      */
    53     public function get_logger() {
     59        $this->main = ! is_null( $main ) ? $main : MslsMain::create();
     60    }
     61
     62    /**
     63     * @return ?ImportLogger
     64     */
     65    public function get_logger(): ?ImportLogger {
    5466        return $this->logger;
    5567    }
    5668
    5769    /**
    58      * @param \lloc\Msls\ContentImport\ImportLogger $logger
    59      */
    60     public function set_logger( $logger ): void {
     70     * @param ImportLogger $logger
     71     */
     72    public function set_logger( ImportLogger $logger ): void {
    6173        $this->logger = $logger;
    6274    }
    6375
    6476    /**
    65      * @return \lloc\Msls\ContentImport\Relations
    66      */
    67     public function get_relations() {
     77     * @return ?Relations
     78     */
     79    public function get_relations(): ?Relations {
    6880        return $this->relations;
    6981    }
    7082
    7183    /**
    72      * @param \lloc\Msls\ContentImport\Relations $relations
    73      */
    74     public function set_relations( $relations ): void {
     84     * @param Relations $relations
     85     */
     86    public function set_relations( Relations $relations ): void {
    7587        $this->relations = $relations;
    7688    }
     
    8496     */
    8597    public function handle_import( array $data = array() ) {
    86         if ( ! $this->pre_flight_check() || false === $sources = $this->parse_sources() ) {
     98        $sources = $this->parse_sources();
     99        if ( ! $this->pre_flight_check() || false === $sources ) {
    87100            return $data;
    88101        }
     
    90103        list( $source_blog_id, $source_post_id ) = $sources;
    91104
    92         if ( $source_blog_id === get_current_blog_id() ) {
     105        if ( get_current_blog_id() === $source_blog_id ) {
    93106            return $data;
    94107        }
     
    148161        }
    149162
     163        // phpcs:ignore WordPress.Security.NonceVerification.Missing
    150164        if ( ! isset( $_POST['msls_import'] ) ) {
    151165            return false;
     
    225239        $this->handle( true );
    226240
    227         $this->has_created_post = $post_id ?: false;
     241        $this->has_created_post = $post_id > 0 ? $post_id : false;
    228242
    229243        restore_current_blog();
     
    240254        $this->handle = $handle;
    241255
    242         // also prevent MSLS from saving
     256        // Also, prevent MSLS from saving.
    243257        if ( false === $handle ) {
    244             add_action( 'msls_main_save', '__return_void' );
     258            add_action( 'msls_main_save', 'msls_return_void' );
    245259        } else {
    246             remove_action( 'msls_main_save', '__return_void' );
     260            remove_action( 'msls_main_save', 'msls_return_void' );
    247261        }
    248262    }
     
    268282         * @param ImportCoordinates $import_coordinates
    269283         */
    270         do_action( 'msls_content_import_before_import', $import_coordinates );
     284        do_action( self::MSLS_BEFORE_IMPORT_ACTION, $import_coordinates );
    271285
    272286        /**
     
    329343         * @since TBD
    330344         */
    331         do_action( 'msls_content_import_after_import', $import_coordinates, $this->logger, $this->relations );
     345        do_action( self::MSLS_AFTER_IMPORT_ACTION, $import_coordinates, $this->logger, $this->relations );
    332346
    333347        /**
     
    356370    protected function update_inserted_blog_post_data( $blog_id, $post_id, array $data ) {
    357371        $data['ID']          = $post_id;
    358         $data['post_status'] = empty( $data['post_status'] ) || $data['post_status'] === 'auto-draft'
     372        $data['post_status'] = empty( $data['post_status'] ) || 'auto-draft' === $data['post_status']
    359373            ? 'draft'
    360374            : $data['post_status'];
     
    372386        switch_to_blog( $dest_blog_id );
    373387        $edit_post_link = html_entity_decode( get_edit_post_link( $post_id ) );
    374         wp_redirect( $edit_post_link );
     388        wp_safe_redirect( $edit_post_link );
    375389        die();
    376390    }
     
    382396     * the context of a content import as it will be populated.
    383397     *
    384      * @param bool $empty
     398     * @param bool $is_empty
    385399     *
    386400     * @return bool
    387401     */
    388     public function filter_empty( $empty ) {
     402    public function filter_empty( $is_empty ) {
    389403        if ( ! $this->main->verify_nonce() ) {
    390             return $empty;
    391         }
    392 
     404            return $is_empty;
     405        }
     406
     407        // phpcs:ignore WordPress.Security.NonceVerification.Missing
    393408        if ( ! isset( $_POST['msls_import'] ) ) {
    394             return $empty;
     409            return $is_empty;
    395410        }
    396411
  • multisite-language-switcher/tags/2.10.0/includes/ContentImport/ImportCoordinates.php

    r3287198 r3409411  
    6565        }
    6666
    67         if ( $this->source_lang !== MslsBlogCollection::get_blog_language( $this->source_blog_id ) ) {
     67        if ( MslsBlogCollection::get_blog_language( $this->source_blog_id ) !== $this->source_lang ) {
    6868            return false;
    6969        }
    70         if ( $this->dest_lang !== MslsBlogCollection::get_blog_language( $this->dest_blog_id ) ) {
     70        if ( MslsBlogCollection::get_blog_language( $this->dest_blog_id ) !== $this->dest_lang ) {
    7171            return false;
    7272        }
  • multisite-language-switcher/tags/2.10.0/includes/ContentImport/ImportLogger.php

    r3287198 r3409411  
    88class ImportLogger {
    99
     10    /**
     11     * @var string
     12     */
    1013    protected string $levels_delimiter = '/';
    1114
     
    6366        $log_writer = apply_filters( 'msls_content_import_log_writer', $default_log_writer, $this->import_coordinates );
    6467        if ( empty( $log_writer ) ) {
    65             // we assume that was done on purpose to prevent logging
     68            // We assume that was done on purpose to prevent logging.
    6669            return;
    6770        }
     
    7275
    7376        if ( ! $log_writer instanceof LogWriter ) {
    74             // something is fishy, let's use the default one
     77            // Something is fishy, let's use the default one.
    7578            $log_writer = $default_log_writer;
    7679        }
  • multisite-language-switcher/tags/2.10.0/includes/ContentImport/Importers/BaseImporter.php

    r3287198 r3409411  
    2727     * BaseImporter constructor.
    2828     *
     29     * @param ImportCoordinates $import_coordinates
    2930     * @param ImportLogger|null $logger
    3031     * @param Relations|null    $relations
     
    3637    ) {
    3738        $this->import_coordinates = $import_coordinates;
    38         $this->logger             = $logger ?: new ImportLogger( $this->import_coordinates );
    39         $this->relations          = $relations ?: new Relations( $this->import_coordinates );
     39        $this->logger             = ! is_null( $logger ) ? $logger : new ImportLogger( $this->import_coordinates );
     40        $this->relations          = ! is_null( $relations ) ? $relations : new Relations( $this->import_coordinates );
    4041    }
    4142
  • multisite-language-switcher/tags/2.10.0/includes/ContentImport/Importers/ImportersBaseFactory.php

    r3199861 r3409411  
    2020
    2121    /**
     22     * Creates an Importer instance based on the provided ImportCoordinates.
     23     *
     24     * @param ImportCoordinates $import_coordinates The coordinates for the import operation.
     25     *
    2226     * @return Importer
     27     *
     28     * @throws \RuntimeException If the TYPE constant is not defined in the child class.
    2329     */
    2430    public function make( ImportCoordinates $import_coordinates ) {
    2531        if ( static::TYPE === self::TYPE ) {
    26             // this is a developer-land exception, no need to localize it
     32            // This is a developer-land exception, no need to localize it.
    2733            throw new \RuntimeException( 'Importers factories should define their own type' );
    2834        }
     
    5460
    5561        $first = count( $map ) > 0 ? reset( $map ) : null;
    56         $slug  = $import_coordinates->get_importer_for( $type ) ?: $first;
     62        $slug  = $import_coordinates->get_importer_for( $type );
    5763
    58         // if there is some incoherence return the null-doing base importer
     64        if ( is_null( $slug ) ) {
     65            $slug = $first;
     66        }
     67
     68        // If there is some incoherence, return the null-doing base importer.
    5969        $class = ! empty( $slug ) && isset( $map[ $slug ] ) ? $map[ $slug ] : BaseImporter::class;
    6070
  • multisite-language-switcher/tags/2.10.0/includes/ContentImport/Importers/PostThumbnail/Linking.php

    r3199861 r3409411  
    6161        switch_to_blog( $this->import_coordinates->dest_blog_id );
    6262
    63         if ( $source_post_thumbnail_attachment instanceof \WP_Post ) {
    64             // in some instances the folder sep. `/` might be duplicated, we de-duplicate it
    65             array_walk(
    66                 $source_upload_dir,
    67                 function ( &$entry ) {
    68                     $entry = str_replace( '//', '/', $entry );
    69                 }
    70             );
    71             $source_uploads_dir         = untrailingslashit(
    72                 str_replace(
    73                     $source_upload_dir['subdir'],
    74                     '',
    75                     $source_upload_dir['path']
    76                 )
    77             );
    78             $source_post_thumbnail_file = $source_uploads_dir . '/' . $source_post_thumbnail_meta['_wp_attached_file'];
     63        // In some instances, the folder sep. `/` might be duplicated, we de-duplicate it.
     64        array_walk(
     65            $source_upload_dir,
     66            function ( &$entry ) {
     67                $entry = str_replace( '//', '/', $entry );
     68            }
     69        );
     70        $source_uploads_dir         = untrailingslashit(
     71            str_replace(
     72                $source_upload_dir['subdir'],
     73                '',
     74                $source_upload_dir['path']
     75            )
     76        );
     77        $source_post_thumbnail_file = $source_uploads_dir . '/' . $source_post_thumbnail_meta['_wp_attached_file'];
    7978
    80             // Check the type of file. We'll use this as the 'post_mime_type'.
    81             $filetype = wp_check_filetype( basename( $source_post_thumbnail_file ), null );
     79        // Check the type of file. We'll use this as the 'post_mime_type'.
     80        $filetype = wp_check_filetype( basename( $source_post_thumbnail_file ), null );
    8281
    83             // Prepare an array of post data for the attachment.
    84             $attachment = array(
    85                 'guid'           => $source_post_thumbnail_attachment->guid,
    86                 'post_mime_type' => $filetype['type'],
    87                 'post_title'     => preg_replace( '/\.[^.]+$/', '', basename( $source_post_thumbnail_file ) ),
    88                 'post_content'   => '',
    89                 'post_status'    => 'inherit',
     82        // Prepare an array of post data for the attachment.
     83        $attachment = array(
     84            'guid'           => $source_post_thumbnail_attachment->guid,
     85            'post_mime_type' => $filetype['type'],
     86            'post_title'     => preg_replace( '/\.[^.]+$/', '', basename( $source_post_thumbnail_file ) ),
     87            'post_content'   => '',
     88            'post_status'    => 'inherit',
     89        );
     90
     91        $found = get_posts(
     92            array(
     93                'post_type' => 'attachment',
     94                'title'     => $attachment['post_title'],
     95            )
     96        );
     97        if ( isset( $found[0]->ID ) ) {
     98            $dest_post_thumbnail_id = $found[0]->ID;
     99            $this->logger->log_success( 'post-thumbnail/existing', $dest_post_thumbnail_id );
     100        } else {
     101            // Insert the attachment.
     102            $dest_post_thumbnail_id = wp_insert_attachment(
     103                $attachment,
     104                $source_post_thumbnail_file,
     105                $dest_post_id
    90106            );
    91107
    92             $existing_criteria = array(
    93                 'post_type' => 'attachment',
    94                 'title'     => $attachment['post_title'],
    95             );
     108            if ( empty( $dest_post_thumbnail_id ) ) {
     109                $this->logger->log_error( 'post-thumbnail/created', $dest_post_thumbnail_id );
     110            } else {
     111                $this->logger->log_success( 'post-thumbnail/created', $dest_post_thumbnail_id );
     112            }
    96113
    97             $found = get_posts( $existing_criteria );
     114            // The `_wp_attached_file` meta has been set before, so we skip it.
     115            unset( $source_post_thumbnail_meta['_wp_attached_file'] );
    98116
    99             if ( $found && $found[0] instanceof \WP_Post ) {
    100                 $dest_post_thumbnail_id = $found[0]->ID;
    101                 $this->logger->log_success( 'post-thumbnail/existing', $dest_post_thumbnail_id );
    102             } else {
    103                 // Insert the attachment.
    104                 $dest_post_thumbnail_id = wp_insert_attachment(
    105                     $attachment,
    106                     $source_post_thumbnail_file,
    107                     $dest_post_id
    108                 );
    109 
    110                 if ( empty( $dest_post_thumbnail_id ) ) {
    111                     $this->logger->log_error( 'post-thumbnail/created', $dest_post_thumbnail_id );
    112                 } else {
    113                     $this->logger->log_success( 'post-thumbnail/created', $dest_post_thumbnail_id );
    114                 }
    115 
    116                 // the `_wp_attached_file` meta has been set before, so we skip it
    117                 unset( $source_post_thumbnail_meta['_wp_attached_file'] );
    118 
    119                 foreach ( $source_post_thumbnail_meta as $key => $value ) {
    120                     add_post_meta( $dest_post_thumbnail_id, $key, $value, true );
    121                 }
     117            foreach ( $source_post_thumbnail_meta as $key => $value ) {
     118                add_post_meta( $dest_post_thumbnail_id, $key, $value, true );
    122119            }
    123120
  • multisite-language-switcher/tags/2.10.0/includes/ContentImport/Importers/Terms/ShallowDuplicating.php

    r3287198 r3409411  
    8080
    8181            if ( is_array( $added ) && ! count( array_filter( $added ) ) ) {
    82                 // while we think the term translation exists it might not, let's create it
     82                // While we think the term translation exists it might not, let's create it.
    8383                $dest_term_id = $this->create_local_term( $term, $msls_term, $dest_lang );
    8484
     
    8787                }
    8888
    89                 // and try again
     89                // And try again.
    9090                $added = $this->update_object_terms( $dest_post_id, $dest_term_id, $term->taxonomy );
    9191            }
  • multisite-language-switcher/tags/2.10.0/includes/ContentImport/Importers/WithRequestPostAttributes.php

    r3167915 r3409411  
    2424     * Returns the post type read from `$_REQUEST['post_type']` if any, or a default post type.
    2525     *
    26      * @param string $default The default post type to return if none is specified in the `$_REQUEST` super-global.
     26     * @param string $preset The default post type to return if none is specified in the `$_REQUEST` super-global.
    2727     *
    2828     * @return string Either the post type read from the `$_REQUEST` super-global, or the default value.
    29 \    *
    3029     */
    31     protected function read_post_type_from_request( $default = 'post' ) {
    32         $request = MslsRequest::get_request( array( 'post_type' ), $default );
     30    protected function read_post_type_from_request( $preset = 'post' ) {
     31        $request = MslsRequest::get_request( array( 'post_type' ), $preset );
    3332
    3433        return $request['post_type'];
  • multisite-language-switcher/tags/2.10.0/includes/ContentImport/LogWriters/AdminNoticeLogger.php

    r3199861 r3409411  
    99class AdminNoticeLogger extends MslsRegistryInstance implements LogWriter {
    1010
     11    /**
     12     * The transient where the last import log will be stored.
     13     *
     14     * @var string
     15     */
    1116    protected string $transient = 'msls_last_import_log';
    1217
     
    138143     * Shows the last log that was written.
    139144     *
    140      * @param bool $echo
     145     * @param bool $output
    141146     *
    142147     * @return ?string
    143148     */
    144     public function show_last_log( $echo = true ): ?string {
    145         if ( ! ( $html = get_transient( $this->transient ) ) ) {
     149    public function show_last_log( $output = true ): ?string {
     150        $html = get_transient( $this->transient );
     151        if ( ! $html ) {
    146152            return null;
    147153        }
    148154
    149         if ( $echo ) {
     155        if ( $output ) {
    150156            echo wp_kses( $html, Component::get_allowed_html() );
    151157        }
    152158
    153         // we've shown it, no reason to keep it
     159        // We've shown it, no reason to keep it.
    154160        delete_transient( $this->transient );
    155161
  • multisite-language-switcher/tags/2.10.0/includes/ContentImport/MetaBox.php

    r3199861 r3409411  
    103103            array(
    104104                'modal'    => true,
    105                 'width'    => 770, // meh, just a guess on *most* devices
     105                'width'    => 770, // Meh, just a guess on *most* devices.
    106106                'height'   => 770,
    107107                'inlineId' => 'msls-import-dialog-' . str_replace( '|', '-', $data['msls_import'] ),
     
    121121
    122122    /**
    123      * @param bool                 $echo
     123     * @param bool                 $output
    124124     * @param array<string, mixed> $data
    125125     *
    126126     * @return string
    127127     */
    128     protected function inline_thickbox_html( $echo = true, array $data = array() ): string {
     128    protected function inline_thickbox_html( $output = true, array $data = array() ): string {
    129129        if ( ! isset( $data['msls_import'] ) ) {
    130130            return '';
     
    187187        $html = ob_get_clean();
    188188
    189         if ( $echo ) {
     189        if ( $output ) {
    190190            echo wp_kses( $html, Component::get_allowed_html() );
    191191        }
  • multisite-language-switcher/tags/2.10.0/includes/ContentImport/Service.php

    r3167915 r3409411  
    6161        add_filter(
    6262            'wp_insert_post_empty_content',
    63             function ( $empty ) {
    64                 return ContentImporter::instance()->filter_empty( $empty );
     63            function ( $bare ) {
     64                return ContentImporter::instance()->filter_empty( $bare );
    6565            }
    6666        );
     
    7575        add_filter(
    7676            'wp_calculate_image_srcset',
    77             function ( $sources, $sizeArray, $imageSrc, $imageMeta, $attachmentId ) {
     77            function ( $sources, $size_array, $image_src, $image_meta, $attachment_id ) {
    7878                return AttachmentPathFinder::instance()->filter_srcset(
    7979                    $sources,
    80                     $sizeArray,
    81                     $imageSrc,
    82                     $imageMeta,
    83                     $attachmentId
     80                    $size_array,
     81                    $image_src,
     82                    $image_meta,
     83                    $attachment_id
    8484                );
    8585            },
  • multisite-language-switcher/tags/2.10.0/includes/Map/HrefLang.php

    r3287198 r3409411  
    1111 */
    1212class HrefLang {
     13
     14    const MSLS_HEAD_HREFLANG_HOOK = 'msls_head_hreflang';
    1315
    1416    /**
     
    2729
    2830        foreach ( $map as $alpha2 => $languages ) {
    29             if ( 1 == count( $languages ) ) {
     31            if ( 1 === count( $languages ) ) {
    3032                $this->map[ $languages[0] ] = $alpha2;
    3133            } else {
     
    6567         * @since 0.9.9
    6668         */
    67         return (string) apply_filters( 'msls_head_hreflang', $language );
     69        return (string) apply_filters( self::MSLS_HEAD_HREFLANG_HOOK, $language );
    6870    }
    6971}
  • multisite-language-switcher/tags/2.10.0/includes/MslsAdmin.php

    r3287198 r3409411  
    2727final class MslsAdmin extends MslsMain {
    2828
     29    const MSLS_REGISTER_ACTION = 'msls_admin_register';
     30
     31    const MSLS_ACTION_PREFIX = 'msls_admin_';
     32
     33    /**
     34     * Maximum number of users in the reference user select box
     35     *
     36     * @var int
     37     */
    2938    public const MAX_REFERENCE_USERS = 100;
    3039
     
    8796    public function __call( $method, $args ) {
    8897        $parts = explode( '_', $method, 2 );
    89         if ( count( $parts ) > 0 && 'rewrite' === $parts[0] ) {
     98        if ( 2 === count( $parts ) && 'rewrite' === $parts[0] ) {
    9099            $this->render_rewrite( $parts[1] );
    91100            return;
     
    136145            );
    137146            $message = sprintf( $format, esc_url( admin_url( $this->get_options_page_link() ) ) );
    138         } elseif ( 1 == count( $this->options->get_available_languages() ) ) {
     147        } elseif ( 1 === count( $this->options->get_available_languages() ) ) {
    139148            /* translators: %1$s: URL to a page at WordPress.orgs */
    140149            $format  = __(
     
    188197        foreach ( $this->collection->get_plugin_active_blogs() as $blog ) {
    189198            $admin_url = get_admin_url( $blog->userblog_id, $this->get_options_page_link() );
    190             $current   = $blog->userblog_id == $this->collection->get_current_blog_id() ? ' class="current"' : '';
     199            $current   = $blog->userblog_id === $this->collection->get_current_blog_id() ? ' class="current"' : '';
    191200
    192201            $arr[] = sprintf( '<a href="%1$s"%2$s>%3$s</a>', $admin_url, $current, $blog->get_title( $icon_type ) );
     
    227236         * @since 1.0
    228237         */
    229         do_action( 'msls_admin_register', __CLASS__ );
     238        do_action( self::MSLS_REGISTER_ACTION, __CLASS__ );
    230239    }
    231240
     
    326335         * @since 2.4.4
    327336         */
    328         do_action( "msls_admin_{$section}", __CLASS__, $section );
     337        do_action( self::MSLS_ACTION_PREFIX . $section, __CLASS__, $section );
    329338
    330339        return count( $map );
     
    385394            );
    386395
    387             // phpcs:ignore WordPress.Security.EscapeOutput
    388             trigger_error( sprintf( esc_html( $format ), strval( self::MAX_REFERENCE_USERS ) ) );
     396            // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
     397            trigger_error( esc_html( sprintf( $format, strval( self::MAX_REFERENCE_USERS ) ) ) );
    389398        }
    390399
     
    435444     * Validates input before saving it
    436445     *
    437      * @param array<string, mixed> $arr Values of the submitted form
     446     * @param array<string, mixed> $arr Values of the submitted form.
    438447     *
    439448     * @return array<string, mixed>
  • multisite-language-switcher/tags/2.10.0/includes/MslsAdminBar.php

    r3287198 r3409411  
    55class MslsAdminBar {
    66
     7    /**
     8     * @var string
     9     */
    710    protected string $icon_type;
    811
     12    /**
     13     * @var MslsBlogCollection
     14     */
    915    protected MslsBlogCollection $blog_collection;
    1016
     17    /**
     18     * @param MslsOptions        $options
     19     * @param MslsBlogCollection $blog_collection
     20     */
    1121    public function __construct( MslsOptions $options, MslsBlogCollection $blog_collection ) {
    1222        $this->icon_type       = $options->get_icon_type();
     
    1424    }
    1525
     26    /**
     27     * @return void
     28     */
    1629    public static function init(): void {
    1730        $obj = new MslsAdminBar( msls_options(), msls_blog_collection() );
     
    2437    /**
    2538     * Callback that updates the admin bar with the blog information
     39     *
     40     * @param \WP_Admin_Bar $wp_admin_bar
     41     *
     42     * @return void
    2643     */
    2744    public function update_admin_bar( \WP_Admin_Bar $wp_admin_bar ): void {
     
    4057    /**
    4158     * Adds node information to an existing node
     59     *
     60     * @param \WP_Admin_Bar $wp_admin_bar
     61     * @param string        $node_id
     62     * @param string        $title
     63     *
     64     * @return bool
    4265     */
    4366    public function add_node( \WP_Admin_Bar $wp_admin_bar, string $node_id, string $title ): bool {
     
    6184     *
    6285     * It uses a blavatar icon as prefix if $blavatar is set to true
     86     *
     87     * @param MslsBlog|null $blog
     88     * @param bool          $blavatar
     89     *
     90     * @return string|null
    6391     */
    6492    protected function get_title( ?MslsBlog $blog, bool $blavatar = false ): ?string {
  • multisite-language-switcher/tags/2.10.0/includes/MslsAdminIcon.php

    r3287198 r3409411  
    117117     */
    118118    public function set_path(): MslsAdminIcon {
    119         if ( 'post' != $this->type ) {
     119        if ( 'post' !== $this->type ) {
    120120            $query_vars = array( 'post_type' => $this->type );
    121121            $this->path = add_query_arg( $query_vars, $this->path );
  • multisite-language-switcher/tags/2.10.0/includes/MslsAdminIconTaxonomy.php

    r3287198 r3409411  
    4242        $post_type = MslsTaxonomy::instance()->get_post_type();
    4343
    44         $post_type !== '' && $args['post_type'] = $post_type;
     44        if ( '' !== $post_type ) {
     45            $args['post_type'] = $post_type;
     46        }
    4547
    4648        $this->path = add_query_arg( $args, $this->path );
  • multisite-language-switcher/tags/2.10.0/includes/MslsBlock.php

    r3287198 r3409411  
    55class MslsBlock {
    66
     7    /**
     8     * The options instance.
     9     *
     10     * @var MslsOptions
     11     */
    712    protected MslsOptions $options;
    813
     
    3035        }
    3136
    32         register_block_type( MslsPlugin::plugin_dir_path( 'js/msls-widget-block' ) );
     37        register_block_type( MslsPlugin::plugin_dir_path( 'assets/js/msls-widget-block' ) );
    3338
    3439        return true;
  • multisite-language-switcher/tags/2.10.0/includes/MslsBlog.php

    r3287198 r3409411  
    1111class MslsBlog {
    1212
     13    const MSLS_GET_PERMALINK_HOOK = 'msls_blog_get_permalink';
     14
     15    const WP_ADMIN_BAR_SHOW_SITE_ICONS_HOOK = 'wp_admin_bar_show_site_icons';
     16
    1317    /**
    1418     * WordPress generates such an object
     
    9195     * Gets the language stored in this object
    9296     *
    93      * @param string $default
    94      *
    95      * @return string
    96      */
    97     public function get_language( $default = 'en_US' ) {
    98         return empty( $this->language ) ? $default : $this->language;
     97     * @param string $preset
     98     *
     99     * @return string
     100     */
     101    public function get_language( $preset = 'en_US' ) {
     102        return empty( $this->language ) ? $preset : $this->language;
    99103    }
    100104
     
    116120     */
    117121    public function get_url( $options ) {
    118         if ( $this->obj->userblog_id == msls_blog_collection()->get_current_blog_id() ) {
     122        if ( msls_blog_collection()->get_current_blog_id() === $this->obj->userblog_id ) {
    119123            return $options->get_current_link();
    120124        }
     
    128132     * @return ?string
    129133     */
    130     protected function get_permalink( $options ) {
     134    protected function get_permalink( OptionsInterface $options ) {
    131135        $url = null;
    132136
     
    135139        switch_to_blog( $this->obj->userblog_id );
    136140
    137         if ( is_object( $options ) && method_exists(
    138             $options,
    139             'has_value'
    140         ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) {
    141             $url = apply_filters( 'mlsl_blog_get_permalink', $options->get_permalink( $this->get_language() ), $this );
     141        if ( $is_home || $options->has_value( $this->get_language() ) ) {
     142            $url = apply_filters( self::MSLS_GET_PERMALINK_HOOK, $options->get_permalink( $this->get_language() ), $this );
    142143        }
    143144
     
    155156     * @return int
    156157     */
    157     public static function _cmp( $a, $b ) {
    158         if ( $a == $b ) {
     158    public static function internal_cmp( $a, $b ) {
     159        if ( $a === $b ) {
    159160            return 0;
    160161        }
     
    172173     */
    173174    public static function language( MslsBlog $a, MslsBlog $b ) {
    174         return self::_cmp( $a->get_language(), $b->get_language() );
     175        return self::internal_cmp( $a->get_language(), $b->get_language() );
    175176    }
    176177
     
    184185     */
    185186    public static function description( MslsBlog $a, MslsBlog $b ) {
    186         return self::_cmp( $a->get_description(), $b->get_description() );
     187        return self::internal_cmp( $a->get_description(), $b->get_description() );
    187188    }
    188189
     
    192193    public function get_blavatar(): string {
    193194        $blavatar_html   = '<div class="blavatar"></div>';
    194         $show_site_icons = apply_filters( 'wp_admin_bar_show_site_icons', true );
     195        $show_site_icons = apply_filters( self::WP_ADMIN_BAR_SHOW_SITE_ICONS_HOOK, true );
    195196
    196197        switch_to_blog( $this->obj->userblog_id );
  • multisite-language-switcher/tags/2.10.0/includes/MslsBlogCollection.php

    r3287198 r3409411  
    7575            foreach ( $blogs_collection as $blog ) {
    7676                $description = false;
    77                 if ( $blog->userblog_id == $this->current_blog_id ) {
     77                if ( $blog->userblog_id === $this->current_blog_id ) {
    7878                    $description = $options->description;
    7979                } elseif ( ! $this->is_plugin_active( $blog->userblog_id ) ) {
     
    153153
    154154        foreach ( $this->get_objects() as $item ) {
    155             if ( $language == $item->get_language() ) {
     155            if ( $language === $item->get_language() ) {
    156156                $blog = $item;
    157157                break;
     
    253253        $plugins = get_blog_option( $blog_id, 'active_plugins', array() );
    254254
    255         return in_array( $path, $plugins );
     255        return in_array( $path, $plugins, true );
    256256    }
    257257
     
    325325     *
    326326     * @param int    $blog_id
    327      * @param string $default
     327     * @param string $preset
    328328     *
    329329     * @return string
    330330     */
    331     public static function get_blog_language( $blog_id = null, $default = 'en_US' ) {
     331    public static function get_blog_language( $blog_id = null, $preset = 'en_US' ) {
    332332        if ( null === $blog_id ) {
    333333            $blog_id = get_current_blog_id();
     
    336336        $language = (string) get_blog_option( $blog_id, 'WPLANG' );
    337337
    338         return '' !== $language ? $language : $default;
     338        return '' !== $language ? $language : $preset;
    339339    }
    340340}
  • multisite-language-switcher/tags/2.10.0/includes/MslsCli.php

    r3287198 r3409411  
    2929     *  $ wp msls blog <locale>
    3030     *
    31      * @param string[]              $args
    32      * @param array<string, string> $assoc_args
     31     * @param string[] $args
     32     *
    3333     * @return void
    3434     */
    35     public function blog( $args, $assoc_args ): void {
     35    public function blog( $args ): void {
    3636        list( $locale ) = $args;
    3737        $blog           = msls_blog( $locale );
  • multisite-language-switcher/tags/2.10.0/includes/MslsContentFilter.php

    r3287198 r3409411  
    55class MslsContentFilter {
    66
     7    /**
     8     * The options instance.
     9     *
     10     * @var MslsOptions
     11     */
    712    protected MslsOptions $options;
    813
     
    7176        }
    7277
    73         if ( 1 == count( $links ) ) {
     78        if ( 1 === count( $links ) ) {
    7479            return $links[0];
    7580        }
  • multisite-language-switcher/tags/2.10.0/includes/MslsContentTypes.php

    r3287198 r3409411  
    3232        $_request = MslsRequest::get_request( array( 'taxonomy' ) );
    3333
    34         return '' != $_request['taxonomy'] ? MslsTaxonomy::instance() : MslsPostType::instance();
     34        return '' !== $_request['taxonomy'] ? MslsTaxonomy::instance() : MslsPostType::instance();
    3535    }
    3636
  • multisite-language-switcher/tags/2.10.0/includes/MslsCustomColumn.php

    r3287198 r3409411  
    4848                $language  = $blog->get_language();
    4949                $icon_type = $this->options->get_icon_type();
     50                $icon      = ( new MslsAdminIcon() )->set_language( $language )->set_icon_type( $icon_type );
    5051
    51                 $icon = ( new MslsAdminIcon() )->set_language( $language )->set_icon_type( $icon_type );
    52 
    53                 if ( $post_id = get_the_ID() ) {
     52                $post_id = get_the_ID();
     53                if ( false !== $post_id ) {
    5454                    $icon->set_id( $post_id );
    5555                    $icon->set_origin_language( 'it_IT' );
     
    7373     */
    7474    public function td( $column_name, $item_id ): void {
    75         if ( 'mslscol' == $column_name ) {
     75        if ( 'mslscol' === $column_name ) {
    7676            $blogs           = $this->collection->get();
    7777            $origin_language = MslsBlogCollection::get_blog_language();
  • multisite-language-switcher/tags/2.10.0/includes/MslsCustomFilter.php

    r3287198 r3409411  
    7979        $sql_cache = MslsSqlCacher::create( __CLASS__, __METHOD__ );
    8080
    81         // load post we need to exclude (they already have a translation) from search query
     81        // Load post we need to exclude (they already have a translation) from search query.
    8282        $query->query_vars['post__not_in'] = ( new TranslatedPostIdQuery( $sql_cache ) )( $blog->get_language() );
    8383
  • multisite-language-switcher/tags/2.10.0/includes/MslsLink.php

    r3287198 r3409411  
    1818
    1919    /**
    20      * Gets all link types as array with "id => name"-items
     20     * Gets all link types as an array with "id => name"-items
    2121     *
    2222     * @return string[]
     
    7474             * @param LinkInterface $obj
    7575             * @param int $display
    76              *
    77              * @return LinkInterface
    7876             */
    7977            $obj = apply_filters( 'msls_link_create', $obj, $display );
    80             if ( $obj instanceof LinkInterface ) {
    81                 return $obj;
    82             }
    8378        }
    8479
  • multisite-language-switcher/tags/2.10.0/includes/MslsMain.php

    r3287198 r3409411  
    1111 */
    1212class MslsMain {
     13
     14    const MSLS_SAVE_ACTION = 'msls_main_save';
    1315
    1416    /**
     
    4951        if ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ) {
    5052            if ( is_array( $message ) || is_object( $message ) ) {
     53                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
    5154                $message = print_r( $message, true );
    5255            }
    5356
     57            // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
    5458            error_log( 'MSLS Debug: ' . $message );
    5559        }
     
    128132     */
    129133    protected function save( $object_id, $class_name ): void {
    130         if ( has_action( 'msls_main_save' ) ) {
     134        if ( has_action( self::MSLS_SAVE_ACTION ) ) {
    131135            /**
    132136             * Calls completely customized save-routine
     
    137141             * @since 0.9.9
    138142             */
    139             do_action( 'msls_main_save', $object_id, $class_name );
     143            do_action( self::MSLS_SAVE_ACTION, $object_id, $class_name );
    140144
    141145            return;
     
    153157        $temp     = $options->get_arr();
    154158
    155         if ( 0 != $msla->get_val( $language ) ) {
     159        if ( 0 !== $msla->get_val( $language ) ) {
    156160            $options->save( $msla->get_arr( $language ) );
    157161        } else {
     
    165169            $larr_id  = $msla->get_val( $language );
    166170
    167             if ( 0 != $larr_id ) {
     171            if ( 0 !== $larr_id ) {
    168172                $options = new $class_name( $larr_id );
    169173                $options->save( $msla->get_arr( $language ) );
  • multisite-language-switcher/tags/2.10.0/includes/MslsMetaBox.php

    r3287198 r3409411  
    66use lloc\Msls\Component\Wrapper;
    77use lloc\Msls\ContentImport\MetaBox as ContentImportMetaBox;
     8use WP_Post;
    89
    910/**
     
    7677    public static function get_suggested_fields( MslsJson $json, array $args ): MslsJson {
    7778        /**
    78          * Overrides the query-args for the suggest fields in the MetaBox
     79         * Overrides the query-args for the 'suggest' fields in the MetaBox
    7980         *
    8081         * @param array $args<string, mixed>
     
    8889             * Manipulates the WP_Post object before using it
    8990             *
    90              * @param \WP_Post $post
     91             * @param WP_Post $post
    9192             *
    9293             * @since 0.9.9
    9394             */
    9495            $post = apply_filters( 'msls_meta_box_suggest_post', $post );
    95             if ( is_object( $post ) ) {
    96                 $json->add( $post->ID, get_the_title( $post ) );
    97             }
     96
     97            $json->add( $post->ID, get_the_title( $post ) );
    9898        }
    9999
     
    226226            echo ( new Wrapper( 'ul', $lis ) )->render();
    227227
     228            // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
    228229            $post = $temp;
    229230        } else {
     
    304305                $icon_type = $this->options->get_icon_type();
    305306                $icon      = MslsAdminIcon::create()->set_language( $language )->set_icon_type( $icon_type );
    306 
    307                 $value = $title = '';
     307                $value     = '';
     308                $title     = '';
     309
    308310                if ( $my_data->has_value( $language ) ) {
    309311                    $icon->set_href( (int) $my_data->$language );
     
    334336            );
    335337
     338            // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
    336339            $post = $temp;
    337340        } else {
  • multisite-language-switcher/tags/2.10.0/includes/MslsOptions.php

    r3287198 r3409411  
    2929class MslsOptions extends MslsGetSet implements OptionsInterface {
    3030
     31    const MSLS_GET_POSTLINK_HOOK = 'msls_get_postlink';
     32
    3133    public const PREFIX    = 'msls';
    3234    public const SEPARATOR = '';
    3335
     36    /**
     37     * The name of the option in the database
     38     *
     39     * @var string
     40     */
    3441    protected string $name;
    35     protected bool $exists   = false;
     42
     43    /**
     44     * Indicates whether the option exists in the database
     45     *
     46     * @var bool
     47     */
     48    protected bool $exists = false;
     49
     50    /**
     51     * Autoload option
     52     *
     53     * @var bool
     54     */
    3655    protected bool $autoload = true;
    3756
     
    83102        }
    84103
    85         add_filter( 'msls_get_postlink', array( $options, 'check_for_blog_slug' ), 10, 2 );
     104        add_filter( self::MSLS_GET_POSTLINK_HOOK, array( $options, 'check_for_blog_slug' ), 10, 2 );
    86105
    87106        return $options;
     
    134153     *
    135154     * @param int   $index
    136      * @param mixed $default
     155     * @param mixed $preset
    137156     *
    138157     * @return mixed
    139158     */
    140     public function get_arg( int $index, $default = null ) {
    141         $arg = $this->args[ $index ] ?? $default;
    142 
    143         settype( $arg, gettype( $default ) );
     159    public function get_arg( int $index, $preset = null ) {
     160        $arg = $this->args[ $index ] ?? $preset;
     161
     162        settype( $arg, gettype( $preset ) );
    144163
    145164        return $arg;
     
    211230        );
    212231
    213         return '' != $postlink ? $postlink : home_url( '/' );
     232        return '' !== $postlink ? $postlink : home_url( '/' );
    214233    }
    215234
     
    311330     */
    312331    public function get_flag_url( $language ) {
    313         $url = ! is_admin() && isset( $this->image_url ) ? $this->__get( 'image_url' ) : $this->get_url( 'flags' );
     332        $url = ! is_admin() && isset( $this->image_url ) ? $this->__get( 'image_url' ) : $this->get_url( 'assets/flags' );
    314333
    315334        /**
  • multisite-language-switcher/tags/2.10.0/includes/MslsOptionsPost.php

    r3167915 r3409411  
    1212    public const SEPARATOR = '_';
    1313
     14    /**
     15     * @var bool
     16     */
    1417    protected bool $autoload = false;
    1518
     
    2730
    2831        $post = get_post( (int) $this->__get( $language ) );
    29         if ( is_null( $post ) || 'publish' != $post->post_status ) {
     32        if ( is_null( $post ) || 'publish' !== $post->post_status ) {
    3033            return '';
    3134        }
     
    3841        $post_link = get_permalink( $post );
    3942
    40         $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' );
     43        $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', MslsOptions::MSLS_GET_POSTLINK_HOOK );
    4144
    42         return apply_filters( 'msls_get_postlink', $post_link, $this );
     45        return apply_filters( MslsOptions::MSLS_GET_POSTLINK_HOOK, $post_link, $this );
    4346    }
    4447
  • multisite-language-switcher/tags/2.10.0/includes/MslsOptionsQuery.php

    r3287198 r3409411  
    1717    public ?bool $with_front = true;
    1818
     19    /**
     20     * @var MslsSqlCacher
     21     */
    1922    protected MslsSqlCacher $sql_cache;
    2023
     
    3538     * Factory method
    3639     *
    37      * @param int $id This parameter is unused here
     40     * @param int $id This parameter is unused here.
    3841     *
    3942     * @return ?MslsOptionsQuery
     
    7275            $post_link = $this->get_current_link();
    7376            if ( ! empty( $post_link ) ) {
    74                 $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' );
     77                $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', MslsOptions::MSLS_GET_POSTLINK_HOOK );
    7578
    76                 return apply_filters( 'msls_get_postlink', $post_link, $this );
     79                return apply_filters( MslsOptions::MSLS_GET_POSTLINK_HOOK, $post_link, $this );
    7780            }
    7881        }
  • multisite-language-switcher/tags/2.10.0/includes/MslsOptionsQueryAuthor.php

    r3287198 r3409411  
    1212class MslsOptionsQueryAuthor extends MslsOptionsQuery {
    1313
     14    /**
     15     * The author ID for which the posts count is queried.
     16     *
     17     * @var int
     18     */
    1419    protected int $author_id;
    1520
  • multisite-language-switcher/tags/2.10.0/includes/MslsOptionsQueryDay.php

    r3287198 r3409411  
    1212class MslsOptionsQueryDay extends MslsOptionsQuery {
    1313
     14    /**
     15     * @var int
     16     */
    1417    protected int $year;
    1518
     19    /**
     20     * @var int
     21     */
    1622    protected int $monthnum;
     23
     24    /**
     25     * @var int
     26     */
    1727    protected int $day;
    1828
  • multisite-language-switcher/tags/2.10.0/includes/MslsOptionsQueryMonth.php

    r3287198 r3409411  
    1212class MslsOptionsQueryMonth extends MslsOptionsQuery {
    1313
     14    /**
     15     * @var int
     16     */
    1417    protected int $year;
    1518
     19    /**
     20     * @var int
     21     */
    1622    protected int $monthnum;
    1723
  • multisite-language-switcher/tags/2.10.0/includes/MslsOptionsQueryPostType.php

    r3287198 r3409411  
    1010class MslsOptionsQueryPostType extends MslsOptionsQuery {
    1111
     12    /**
     13     * The post type for which the options are queried.
     14     *
     15     * @var string
     16     */
    1217    protected string $post_type;
    1318
  • multisite-language-switcher/tags/2.10.0/includes/MslsOptionsQueryYear.php

    r3287198 r3409411  
    1212class MslsOptionsQueryYear extends MslsOptionsQuery {
    1313
     14    /**
     15     * The year for which the posts count is queried.
     16     *
     17     * @var int
     18     */
    1419    protected int $year;
    1520
     21    /**
     22     * Constructor.
     23     *
     24     * @param MslsSqlCacher $sql_cache The SQL Cacher instance.
     25     */
    1626    public function __construct( MslsSqlCacher $sql_cache ) {
    1727        parent::__construct( $sql_cache );
     
    2030    }
    2131
     32    /**
     33     * Get the parameters for this query.
     34     *
     35     * @return array<string, mixed>
     36     */
    2237    public static function get_params(): array {
    2338        return array(
  • multisite-language-switcher/tags/2.10.0/includes/MslsOptionsTax.php

    r3287198 r3409411  
    1212    public const SEPARATOR = '_term_';
    1313
     14    /**
     15     * @var bool
     16     */
    1417    protected bool $autoload = false;
    1518
     
    8992        }
    9093
    91         $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' );
     94        $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', MslsOptions::MSLS_GET_POSTLINK_HOOK );
    9295
    93         return apply_filters( 'msls_get_postlink', $post_link, $this );
     96        return apply_filters( MslsOptions::MSLS_GET_POSTLINK_HOOK, $post_link, $this );
    9497    }
    9598
  • multisite-language-switcher/tags/2.10.0/includes/MslsOptionsTaxTerm.php

    r3287198 r3409411  
    2222
    2323    public function handle_rewrite(): OptionsTaxInterface {
    24         add_filter( 'msls_get_postlink', array( $this, 'check_base' ), 9, 2 );
     24        add_filter( MslsOptions::MSLS_GET_POSTLINK_HOOK, array( $this, 'check_base' ), 9, 2 );
    2525
    2626        return $this;
     
    4444        $base_option  = self::get_base_option();
    4545
    46         if ( $base_defined != $base_option ) {
     46        if ( $base_defined !== $base_option ) {
    4747            $search  = '/' . $base_defined . '/';
    4848            $replace = '/' . $base_option . '/';
     
    7070
    7171    public static function get_base_option(): string {
    72         $base_option = get_option( static::BASE_OPTION, '' );
    73 
    74         return $base_option ?: static::BASE_DEFINED;
     72        return get_option( static::BASE_OPTION, static::BASE_DEFINED );
    7573    }
    7674}
  • multisite-language-switcher/tags/2.10.0/includes/MslsOutput.php

    r3287198 r3409411  
    1111 */
    1212class MslsOutput extends MslsMain {
     13
     14    const MSLS_ALTERNATE_LINKS_HOOK = 'msls_output_get_alternate_links';
     15
     16    const MSLS_ALTERNATE_LINKS_ARR_HOOK = 'msls_output_get_alternate_links_arr';
     17
     18    const MSLS_ALTERNATE_LINKS_DEFAULT_HOOK = 'msls_output_get_alternate_links_default';
     19
     20    const MSLS_GET_HOOK = 'msls_output_get';
     21
     22    const MSLS_NO_TRANSLATION_FOUND_HOOK = 'msls_output_no_translation_found';
     23
     24    const MSLS_GET_TAGS_HOOK = 'msls_output_get_tags';
     25
    1326
    1427    public static function init(): object {
     
    6477                }
    6578
    66                 if ( has_filter( 'msls_output_get' ) ) {
     79                if ( has_filter( self::MSLS_GET_HOOK ) ) {
    6780                    /**
    6881                     * Returns HTML-link for an item of the output-arr
     
    7487                     * @since 0.9.8
    7588                     */
    76                     $arr[] = (string) apply_filters( 'msls_output_get', $url, $link, $is_current_blog );
     89                    $arr[] = (string) apply_filters( self::MSLS_GET_HOOK, $url, $link, $is_current_blog );
    7790                } else {
    7891                    $arr[] = sprintf(
     
    8093                        $url,
    8194                        $link->txt,
    82                         $is_current_blog ? ' class="current_language"' : '',
     95                        $is_current_blog ? ' class="current_language" aria-current="page"' : '',
    8396                        $link
    8497                    );
     
    96109     */
    97110    public function get_alternate_links() {
    98         $blogs   = msls_blog_collection();
    99         $hlObj  = new HrefLang( $blogs );
    100         $options = MslsOptions::create();
    101         $arr     = array();
    102         $default = '';
     111        $blogs     = msls_blog_collection();
     112        $href_lang = new HrefLang( $blogs );
     113        $options   = MslsOptions::create();
     114        $arr       = array();
     115        $default   = '';
    103116
    104117        foreach ( $blogs->get_objects() as $blog ) {
    105             $url = apply_filters( 'mlsl_output_get_alternate_links', $blog->get_url( $options ), $blog );
     118            $url = apply_filters( self::MSLS_ALTERNATE_LINKS_HOOK, $blog->get_url( $options ), $blog );
    106119            if ( is_null( $url ) ) {
    107120                continue;
    108121            }
    109122
    110             $hreflang = $hlObj->get( $blog->get_language() );
     123            $hreflang = $href_lang->get( $blog->get_language() );
    111124            $format   = '<link rel="alternate" href="%1$s" hreflang="%2$s" />';
    112125
     
    119132
    120133        if ( 1 === count( $arr ) ) {
    121             return apply_filters( 'mlsl_output_get_alternate_links_default', $default );
    122         }
    123 
    124         $arr = (array) apply_filters( 'mlsl_output_get_alternate_links_arr', $arr );
     134            return apply_filters( self::MSLS_ALTERNATE_LINKS_DEFAULT_HOOK, $default );
     135        }
     136
     137        $arr = (array) apply_filters( self::MSLS_ALTERNATE_LINKS_ARR_HOOK, $arr );
    125138
    126139        return implode( PHP_EOL, $arr );
     
    135148        $arr = $this->get( $this->options->display, false, isset( $this->options->only_with_translation ) );
    136149        if ( empty( $arr ) ) {
    137             return apply_filters( 'msls_output_no_translation_found', '' );
     150            return apply_filters( self::MSLS_NO_TRANSLATION_FOUND_HOOK, '' );
    138151        }
    139152
     
    166179             * @since 1.0
    167180             */
    168             $this->tags = (array) apply_filters( 'msls_output_get_tags', $this->tags );
     181            $this->tags = (array) apply_filters( self::MSLS_GET_TAGS_HOOK, $this->tags );
    169182        }
    170183
     
    199212        }
    200213
    201         return MslsOptions::class != get_class( $thing ) && ! $thing->has_value( $language ) && $exists;
     214        return MslsOptions::class !== get_class( $thing ) && ! $thing->has_value( $language ) && $exists;
    202215    }
    203216}
  • multisite-language-switcher/tags/2.10.0/includes/MslsPlugin.php

    r3287198 r3409411  
    3434    public static function init(): void {
    3535        $obj = new self( msls_options() );
    36 
    37         add_action( 'init', array( $obj, 'init_i18n_support' ) );
    3836
    3937        register_activation_hook( self::file(), array( __CLASS__, 'activate' ) );
     
    115113
    116114        $ver    = defined( 'MSLS_PLUGIN_VERSION' ) ? constant( 'MSLS_PLUGIN_VERSION' ) : false;
    117         $folder = defined( 'SCRIPT_DEBUG' ) && constant( 'SCRIPT_DEBUG' ) ? 'src' : 'js';
    118 
    119         wp_enqueue_style( 'msls-styles', self::plugins_url( 'css/msls.css' ), array(), $ver );
    120         wp_enqueue_style( 'msls-flags', self::plugins_url( 'css-flags/css/flag-icon.min.css' ), array(), $ver );
     115        $folder = defined( 'SCRIPT_DEBUG' ) && constant( 'SCRIPT_DEBUG' ) ? 'src' : 'assets/js';
     116
     117        wp_enqueue_style( 'msls-styles', self::plugins_url( 'assets/css/msls.css' ), array(), $ver );
     118        wp_enqueue_style( 'msls-flags', self::plugins_url( 'assets/css-flags/css/flag-icon.min.css' ), array(), $ver );
    121119
    122120        if ( $this->options->activate_autocomplete ) {
     
    168166    public static function path(): string {
    169167        return defined( 'MSLS_PLUGIN_PATH' ) ? constant( 'MSLS_PLUGIN_PATH' ) : '';
    170     }
    171 
    172     /**
    173      * Load textdomain
    174      *
    175      * The method should be executed always on init because we have some translatable string in the frontend too.
    176      */
    177     public function init_i18n_support(): void {
    178         load_plugin_textdomain( 'multisite-language-switcher', false, self::dirname( '/languages/' ) );
    179168    }
    180169
  • multisite-language-switcher/tags/2.10.0/includes/MslsPostTag.php

    r3287198 r3409411  
    11<?php declare( strict_types=1 );
    2 
    3 /**
    4  * MslsPostTag
    5  *
    6  * @author Dennis Ploetner <re@lloc.de>
    7  */
    82
    93namespace lloc\Msls;
     
    1812class MslsPostTag extends MslsMain {
    1913
    20     const EDIT_ACTION = 'msls_post_tag_edit_input';
    21     const ADD_ACTION  = 'msls_post_tag_add_input';
     14    const MSLS_EDIT_INPUT_ACTION = 'msls_post_tag_edit_input';
     15    const MSLS_ADD_INPUT_ACTION  = 'msls_post_tag_add_input';
    2216
    2317    /**
     
    8579
    8680        $taxonomy = msls_content_types()->acl_request();
    87         if ( '' != $taxonomy ) {
     81        if ( '' !== $taxonomy ) {
    8882            add_action( "{$taxonomy}_add_form_fields", array( $obj, 'add_input' ) );
    8983            add_action( "{$taxonomy}_edit_form_fields", array( $obj, 'edit_input' ), 10, 2 );
     
    9993     */
    10094    public function add_input( string $taxonomy ): void {
    101         if ( did_action( self::ADD_ACTION ) ) {
     95        if ( did_action( self::MSLS_ADD_INPUT_ACTION ) ) {
    10296            return;
    10397        }
     
    115109        echo '</div>';
    116110
    117         do_action( self::ADD_ACTION, $taxonomy );
     111        do_action( self::MSLS_ADD_INPUT_ACTION, $taxonomy );
    118112    }
    119113
     
    125119     */
    126120    public function edit_input( \WP_Term $tag, string $taxonomy ): void {
    127         if ( did_action( self::EDIT_ACTION ) ) {
     121        if ( did_action( self::MSLS_EDIT_INPUT_ACTION ) ) {
    128122            return;
    129123        }
     
    149143        $this->the_input( $tag, $title_format, $item_format );
    150144
    151         do_action( self::EDIT_ACTION, $tag, $taxonomy );
     145        do_action( self::MSLS_EDIT_INPUT_ACTION, $tag, $taxonomy );
    152146    }
    153147
     
    185179                $icon_type = $this->options->get_icon_type();
    186180                $icon      = MslsAdminIcon::create()->set_language( $language )->set_icon_type( $icon_type );
    187 
    188                 $value = $title = '';
     181                $value     = '';
     182                $title     = '';
     183
    189184                if ( $mydata->has_value( $language ) ) {
    190185                    $term = get_term( $mydata->$language, $type );
  • multisite-language-switcher/tags/2.10.0/includes/MslsPostTagClassic.php

    r3287198 r3409411  
    1212class MslsPostTagClassic extends MslsPostTag {
    1313
    14     const EDIT_ACTION = 'msls_post_tag_classic_edit_input';
    15     const ADD_ACTION  = 'msls_post_tag_classic_add_input';
     14    const MSLS_EDIT_INPUT_ACTION = 'msls_post_tag_classic_edit_input';
     15    const MSLS_ADD_INPUT_ACTION  = 'msls_post_tag_classic_add_input';
    1616
    1717    /**
     
    2121     */
    2222    public function add_input( string $taxonomy ): void {
    23         if ( did_action( self::ADD_ACTION ) ) {
     23        if ( did_action( self::MSLS_ADD_INPUT_ACTION ) ) {
    2424            return;
    2525        }
     
    3737        echo '</div>';
    3838
    39         do_action( self::ADD_ACTION, $taxonomy );
     39        do_action( self::MSLS_ADD_INPUT_ACTION, $taxonomy );
    4040    }
    4141
     
    4747     */
    4848    public function edit_input( \WP_Term $tag, string $taxonomy ): void {
    49         if ( did_action( self::EDIT_ACTION ) ) {
     49        if ( did_action( self::MSLS_EDIT_INPUT_ACTION ) ) {
    5050            return;
    5151        }
     
    6969        $this->the_input( $tag, $title_format, $item_format );
    7070
    71         do_action( self::EDIT_ACTION, $tag, $taxonomy );
     71        do_action( self::MSLS_EDIT_INPUT_ACTION, $tag, $taxonomy );
    7272    }
    7373
  • multisite-language-switcher/tags/2.10.0/includes/MslsPostType.php

    r3287198 r3409411  
    2424    public static function get(): array {
    2525        $types = array_merge(
    26             array( 'post', 'page' ), // we don't need attachment, revision or nav_menu_item here
     26            array( 'post', 'page' ), // We don't need attachment, revision or nav_menu_item here.
    2727            get_post_types(
    2828                array(
     
    4343        $post_type = ! empty( $request['post_type'] ) ? esc_attr( $request['post_type'] ) : 'post';
    4444
    45         return in_array( $post_type, $this->get() ) ? $post_type : '';
     45        return in_array( $post_type, $this->get(), true ) ? $post_type : '';
    4646    }
    4747
  • multisite-language-switcher/tags/2.10.0/includes/MslsRegistry.php

    r3287198 r3409411  
    5151     */
    5252    public static function instance(): self {
    53         if ( self::$instance === null ) {
     53        if ( null === self::$instance ) {
    5454            self::$instance = new self();
    5555        }
  • multisite-language-switcher/tags/2.10.0/includes/MslsRegistryInstance.php

    r3287198 r3409411  
    1717    public static function instance() {
    1818        $class = get_called_class();
     19        $obj   = MslsRegistry::get_object( $class );
    1920
    20         if ( ! ( $obj = MslsRegistry::get_object( $class ) ) ) {
     21        if ( ! $obj ) {
    2122            $obj = new $class();
    2223
  • multisite-language-switcher/tags/2.10.0/includes/MslsRequest.php

    r3287198 r3409411  
    66
    77    /**
     8     * @param string $name
     9     *
    810     * @return array<int, int>
     11     *
     12     * @throws \InvalidArgumentException No field with the given name exists.
    913     */
    1014    public static function get_config( string $name ): array {
     
    3135
    3236    /**
    33      * @return mixed
     37     * @param string   $var_name
     38     * @param int|null $input_type
     39     *
     40     * @return ?mixed
    3441     */
    3542    public static function get_var( string $var_name, ?int $input_type = null ) {
     
    5057    /**
    5158     * @param string $name
    52      * @param mixed  $default
     59     * @param mixed  $preset
    5360     *
    5461     * @return mixed
    5562     */
    56     public static function get( string $name, $default ) {
    57         return self::has_var( $name ) ? self::get_var( $name ) : $default;
     63    public static function get( string $name, $preset ) {
     64        return self::has_var( $name ) ? self::get_var( $name ) : $preset;
    5865    }
    5966
     
    7986     *
    8087     * @param string[] $keys
    81      * @param mixed    $default
     88     * @param mixed    $preset
    8289     *
    8390     * @return array<string, mixed>
    8491     */
    85     public static function get_request( array $keys, $default = '' ): array {
     92    public static function get_request( array $keys, $preset = '' ): array {
    8693        $values = array();
    8794
    8895        foreach ( $keys as $key ) {
    8996            list( , $filter ) = self::get_config( $key );
    90             $values[ $key ]   = $default;
     97            $values[ $key ]   = $preset;
    9198
    9299            if ( filter_has_var( INPUT_POST, $key ) ) {
  • multisite-language-switcher/tags/2.10.0/includes/MslsShortCode.php

    r3287198 r3409411  
    77    public static function init(): void {
    88        add_shortcode( 'sc_msls_widget', array( __CLASS__, 'render_widget' ) );
    9         add_shortcode( 'sc_msls', 'get_the_msls' );
     9        add_shortcode( 'sc_msls', 'msls_get_switcher' );
    1010    }
    1111
  • multisite-language-switcher/tags/2.10.0/includes/MslsSqlCacher.php

    r3287198 r3409411  
    2323
    2424    /**
    25      * Cache group
     25     * Cache group for the SQL cacher
    2626     */
    2727    const CACHE_GROUP = 'msls-cache-group';
    2828
    2929    /**
    30      * Database object
     30     * @var \wpdb
    3131     */
    3232    protected \wpdb $db;
    3333
    3434    /**
    35      * Key for the cached result-set
     35     * @var string
    3636     */
    3737    protected string $cache_key;
     
    3939    /**
    4040     * Expiration time for the cache in seconds
     41     *
     42     * @var int
    4143     */
    4244    protected int $expire;
     
    4446    /**
    4547     * Constructor
     48     *
     49     * @param \wpdb  $db        The WordPress database object.
     50     * @param string $cache_key The cache key to use for storing results.
     51     * @param int    $expire    The expiration time for the cache in seconds. Default is 0 (no expiration).
    4652     */
    4753    public function __construct( \wpdb $db, string $cache_key, int $expire = 0 ) {
     
    7177     * Magic __get
    7278     *
     79     * @param string $name
     80     *
    7381     * @return mixed
    7482     */
     
    8694     */
    8795    public function __call( string $method, array $args ) {
    88         if ( 'get_' != substr( $method, 0, 4 ) ) {
     96        if ( 'get_' !== substr( $method, 0, 4 ) ) {
    8997            return call_user_func_array( array( $this->db, $method ), $args );
    9098        }
  • multisite-language-switcher/tags/2.10.0/includes/MslsTaxonomy.php

    r3287198 r3409411  
    3131    public static function get(): array {
    3232        $types = array_merge(
    33             array( 'category', 'post_tag' ), // no 'post_link' here
     33            array( 'category', 'post_tag' ), // No 'post_link' here.
    3434            get_taxonomies(
    3535                array(
  • multisite-language-switcher/tags/2.10.0/includes/MslsWidget.php

    r3287198 r3409411  
    1111 */
    1212class MslsWidget extends \WP_Widget {
     13
     14    const MSLS_ALTERNATIVE_CONTENT_HOOK = 'msls_widget_alternative_content';
    1315
    1416    public const ID_BASE = 'mslswidget';
     
    5456        if ( '' === $content ) {
    5557            $text    = __( 'No available translations found', 'multisite-language-switcher' );
    56             $content = apply_filters( 'msls_widget_alternative_content', $text );
     58            $content = apply_filters( self::MSLS_ALTERNATIVE_CONTENT_HOOK, $text );
    5759        }
    5860
  • multisite-language-switcher/tags/2.10.0/includes/Query/AbstractQuery.php

    r3287198 r3409411  
    1212abstract class AbstractQuery {
    1313
     14    /**
     15     * The SQL Cacher instance.
     16     *
     17     * @var MslsSqlCacher
     18     */
    1419    protected MslsSqlCacher $sql_cache;
    1520
     21    /**
     22     * Constructor.
     23     *
     24     * @param MslsSqlCacher $sql_cache The SQL Cacher instance.
     25     */
    1626    public function __construct( MslsSqlCacher $sql_cache ) {
    1727        $this->sql_cache = $sql_cache;
  • multisite-language-switcher/tags/2.10.0/includes/Query/TranslatedPostIdQuery.php

    r3287198 r3409411  
    1010class TranslatedPostIdQuery extends AbstractQuery {
    1111
    12 
    1312    /**
     13     * @param string $language
     14     *
    1415     * @return int[]
    1516     */
  • multisite-language-switcher/tags/2.10.0/includes/index.php

    r3287198 r3409411  
    11<?php
    2 // Silence is golden.
     2/**
     3 * Silence is golden.
     4 *
     5 * @package msls
     6 */
  • multisite-language-switcher/tags/2.10.0/index.php

    r3287198 r3409411  
    11<?php
    2 // Silence is golden.
     2/**
     3 * Silence is golden.
     4 *
     5 * @package msls
     6 */
  • multisite-language-switcher/tags/2.10.0/languages/index.php

    r3287198 r3409411  
    11<?php
    2 // Silence is golden.
     2/**
     3 * Silence is golden.
     4 *
     5 * @package msls
     6 */
  • multisite-language-switcher/tags/2.10.0/vendor/composer/installed.php

    r3287198 r3409411  
    22    'root' => array(
    33        'name' => 'lloc/multisite-language-switcher',
    4         'pretty_version' => '2.9.6',
    5         'version' => '2.9.6.0',
    6         'reference' => '720656eb12e8c4f5bb5271f2365374e2e18349b4',
     4        'pretty_version' => '2.10.0',
     5        'version' => '2.10.0.0',
     6        'reference' => '897c7ea2766f60104e532f9183a1eccbbba090ac',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    2121        ),
    2222        'lloc/multisite-language-switcher' => array(
    23             'pretty_version' => '2.9.6',
    24             'version' => '2.9.6.0',
    25             'reference' => '720656eb12e8c4f5bb5271f2365374e2e18349b4',
     23            'pretty_version' => '2.10.0',
     24            'version' => '2.10.0.0',
     25            'reference' => '897c7ea2766f60104e532f9183a1eccbbba090ac',
    2626            'type' => 'wordpress-plugin',
    2727            'install_path' => __DIR__ . '/../../',
  • multisite-language-switcher/tags/2.10.0/vendor/composer/platform_check.php

    r3002259 r3409411  
    2020        }
    2121    }
    22     trigger_error(
    23         'Composer detected issues in your platform: ' . implode(' ', $issues),
    24         E_USER_ERROR
     22    throw new \RuntimeException(
     23        'Composer detected issues in your platform: ' . implode(' ', $issues)
    2524    );
    2625}
  • multisite-language-switcher/trunk/MultisiteLanguageSwitcher.php

    r3287198 r3409411  
    33 * Multisite Language Switcher Plugin
    44 *
    5  * @copyright Copyright (C) 2011-2022, Dennis Ploetner, re@lloc.de
    6  * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 or later
    7  * @wordpress-plugin
    8  *
    95 * Plugin Name: Multisite Language Switcher
    10  * Version: 2.9.6
     6 * Version: 2.10.0
    117 * Plugin URI: http://msls.co/
    128 * Description: A simple but powerful plugin that will help you to manage the relations of your contents in a multilingual multisite-installation.
     
    2925 * along with this program; if not, write to the Free Software
    3026 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     27 *
     28 * @copyright Copyright (C) 2011-2022, Dennis Ploetner, re@lloc.de
     29 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 or later
     30 * @wordpress-plugin
     31 * @package msls
    3132 */
    3233
     
    4142 */
    4243if ( ! defined( 'MSLS_PLUGIN_VERSION' ) ) {
    43     define( 'MSLS_PLUGIN_VERSION', '2.9.6' );
     44    define( 'MSLS_PLUGIN_VERSION', '2.10.0' );
    4445    define( 'MSLS_PLUGIN_PATH', plugin_basename( __FILE__ ) );
    4546    define( 'MSLS_PLUGIN__FILE__', __FILE__ );
    4647
     48    require_once __DIR__ . '/includes/deprectated.php';
     49
    4750    /**
    4851     * Get the output for using the links to the translations in your code
    4952     *
    5053     * @package Msls
    51      *
    5254     * @param mixed $attr
    53      *
    54      * @return string
    55      */
    56     function get_the_msls( $attr ): string {
     55     * @return string
     56     */
     57    function msls_get_switcher( $attr ): string {
    5758        $arr = is_array( $attr ) ? $attr : array();
    5859        $obj = apply_filters( 'msls_get_output', null );
     
    7677     * @param string[] $arr
    7778     */
    78     function the_msls( array $arr = array() ): void {
    79         // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    80         echo get_the_msls( $arr );
     79    function msls_the_switcher( array $arr = array() ): void {
     80        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     81        echo msls_get_switcher( $arr );
    8182    }
    8283
     
    8889     * @return string
    8990     */
    90     function get_msls_flag_url( string $locale ): string {
     91    function msls_get_flag_url( string $locale ): string {
    9192        return ( new \lloc\Msls\MslsOptions() )->get_flag_url( $locale );
    9293    }
     
    9697     *
    9798     * @param string $locale
    98      *
    99      * @return string
    100      */
    101     function get_msls_blog_description( string $locale, string $default = '' ): string {
     99     * @param string $preset
     100     *
     101     * @return string
     102     */
     103    function msls_get_blog_description( string $locale, string $preset = '' ): string {
    102104        $blog = msls_blog( $locale );
    103105
    104         return $blog ? $blog->get_description() : $default;
     106        return $blog ? $blog->get_description() : $preset;
    105107    }
    106108
     
    109111     *
    110112     * @param string $locale
    111      * @param string $default
    112      *
    113      * @return string
    114      */
    115     function get_msls_permalink( string $locale, string $default = '' ): string {
     113     * @param string $preset
     114     *
     115     * @return string
     116     */
     117    function msls_get_permalink( string $locale, string $preset = '' ): string {
    116118        $url  = null;
    117119        $blog = msls_blog( $locale );
     
    122124        }
    123125
    124         return $url ?? $default;
     126        return $url ?? $preset;
    125127    }
    126128
     
    236238     * @return void
    237239     */
    238     if ( ! function_exists( '__return_void' ) ) {
    239         function __return_void(): void {
    240         }
     240    function msls_return_void(): void {
    241241    }
    242242
  • multisite-language-switcher/trunk/includes/Component/Icon.php

    r3167915 r3409411  
    1919     */
    2020    public function __construct() {
    21         if ( $this->get_include() ) {
    22             $this->map = include $this->get_include();
    23         }
     21        $filePath = $this->get_include();
     22
     23        $this->map = ! is_null( $filePath ) && is_readable( $filePath ) ? require $filePath : array();
    2424    }
    2525
     
    3232     */
    3333    protected function maybe( string $language, string $prefix = '', string $postfix = '' ): string {
    34         if ( 5 == strlen( $language ) ) {
     34        if ( 5 === strlen( $language ) ) {
    3535            $language = strtolower( substr( $language, - 2 ) );
    3636        }
     
    4040
    4141    /**
    42      * @return string
     42     * @return ?string
    4343     */
    44     abstract protected function get_include(): string;
     44    protected function get_include(): ?string {
     45        return null;
     46    }
    4547
    4648    /**
  • multisite-language-switcher/trunk/includes/Component/Icon/IconLabel.php

    r3287198 r3409411  
    1313
    1414    /**
    15      * @return string
    16      */
    17     protected function get_include(): string {
    18         return '';
    19     }
    20 
    21     /**
    2215     * @param string $language
    2316     *
  • multisite-language-switcher/trunk/includes/Component/Icon/IconPng.php

    r3167915 r3409411  
    1313final class IconPng extends Icon {
    1414
    15     const FLAGS_FILE = 'flags/flags.php';
     15    const FLAGS_FILE = 'assets/flags/flags.php';
    1616
    1717    /**
  • multisite-language-switcher/trunk/includes/Component/Icon/IconSvg.php

    r3167915 r3409411  
    1313final class IconSvg extends Icon {
    1414
    15     const FLAGS_FILE = 'css-flags/flags.php';
     15    const FLAGS_FILE = 'assets/css-flags/flags.php';
    1616
    1717    /**
  • multisite-language-switcher/trunk/includes/Component/Input/Select.php

    r3167915 r3409411  
    2020
    2121    /**
    22      * @param string  $key Name and ID of the form-element
    23      * @param mixed[] $arr Options as associative array
    24      * @param ?string $selected Values which should be selected
     22     * @param string  $key Name and ID of the form-element.
     23     * @param mixed[] $arr Options as an associative array.
     24     * @param ?string $selected Values which should be selected.
    2525     */
    2626    public function __construct( string $key, array $arr, ?string $selected = null ) {
  • multisite-language-switcher/trunk/includes/Component/Input/Text.php

    r3199861 r3409411  
    3333     * @param string|null $value
    3434     * @param int         $size
    35      * @param bool        $readonly
     35     * @param bool        $read_only
    3636     */
    37     public function __construct( string $key, ?string $value, int $size = self::DEFAULT_SIZE, bool $readonly = false ) {
     37    public function __construct( string $key, ?string $value, int $size = self::DEFAULT_SIZE, bool $read_only = false ) {
    3838        $this->key      = $key;
    3939        $this->value    = $value;
    4040        $this->size     = $size;
    41         $this->readonly = $readonly ? ' readonly="readonly"' : '';
     41        $this->readonly = $read_only ? ' readonly="readonly"' : '';
    4242    }
    4343
  • multisite-language-switcher/trunk/includes/Component/Wrapper.php

    r3167915 r3409411  
    55final class Wrapper extends Component {
    66
     7    /**
     8     * @var string
     9     */
    710    protected string $element;
    811
     12    /**
     13     * @var string
     14     */
    915    protected string $content;
    1016
  • multisite-language-switcher/trunk/includes/ContentImport/AttachmentPathFinder.php

    r3287198 r3409411  
    1111    /**
    1212     * @param array<string, array<string, mixed>> $sources
    13      * @param mixed                               $sizeArray
    14      * @param string                              $imageSrc
    15      * @param mixed                               $imageMeta
    16      * @param int                                 $attachmentId
     13     * @param mixed                               $size_array
     14     * @param string                              $image_src
     15     * @param mixed                               $image_meta
     16     * @param int                                 $attachment_id
    1717     *
    1818     * @return array<string, mixed>
    1919     */
    20     public function filter_srcset( array $sources, $sizeArray, $imageSrc, $imageMeta, $attachmentId ): array {
    21         if ( ! $msls_imported = $this->has_import_data( $attachmentId ) ) {
     20    public function filter_srcset( array $sources, $size_array, $image_src, $image_meta, $attachment_id ): array {
     21        $msls_imported = $this->has_import_data( $attachment_id );
     22        if ( ! $msls_imported ) {
    2223            return $sources;
    2324        }
     
    2829        }
    2930
    30         $extension           = '.' . pathinfo( $source_post->guid, PATHINFO_EXTENSION );
    31         $pattern             = '/(-[\\d]+x[\\d]+)*' . preg_quote( $extension, '/' ) . '$/';
    32         $srcWithoutExtension = preg_replace( $pattern, '', $imageSrc );
     31        $extension             = '.' . pathinfo( $source_post->guid, PATHINFO_EXTENSION );
     32        $pattern               = '/(-[\\d]+x[\\d]+)*' . preg_quote( $extension, '/' ) . '$/';
     33        $src_without_extension = preg_replace( $pattern, '', $image_src );
    3334
    3435        foreach ( $sources as $key => &$value ) {
    3536            preg_match( $pattern, $value['url'], $matches );
    3637            $w_and_h      = ! empty( $matches[1] ) ? $matches[1] : '';
    37             $value['url'] = $srcWithoutExtension . $w_and_h . $extension;
     38            $value['url'] = $src_without_extension . $w_and_h . $extension;
    3839        }
    3940
     
    7273     */
    7374    public function filter_attachment_url( $url, $attachment_id ) {
    74         if ( ! $msls_imported = $this->has_import_data( $attachment_id ) ) {
     75        $msls_imported = $this->has_import_data( $attachment_id );
     76        if ( ! $msls_imported ) {
    7577            return $url;
    7678        }
  • multisite-language-switcher/trunk/includes/ContentImport/ContentImporter.php

    r3287198 r3409411  
    2222    use WithRequestPostAttributes;
    2323
     24    const MSLS_BEFORE_IMPORT_ACTION = 'msls_content_import_before_import';
     25
     26    const MSLS_AFTER_IMPORT_ACTION = 'msls_content_import_after_import';
     27
    2428    /**
    2529     * @var MslsMain
    2630     */
    27     protected $main;
     31    protected MslsMain $main;
     32
     33    /**
     34     * @var ImportLogger|null
     35     */
    2836    protected ?ImportLogger $logger = null;
     37
     38    /**
     39     * @var Relations|null
     40     */
    2941    protected ?Relations $relations = null;
    3042
     
    3244     * @var bool Whether the class should handle requests or not.
    3345     */
    34     protected $handle = true;
     46    protected bool $handle = true;
    3547
    3648    /**
    3749     * @var int The ID of the post the class created while handling the request, if any.
    3850     */
    39     protected $has_created_post = 0;
     51    protected int $has_created_post = 0;
    4052
    4153    /**
     
    4557     */
    4658    public function __construct( ?MslsMain $main = null ) {
    47         $this->main = $main ?: MslsMain::create();
    48     }
    49 
    50     /**
    51      * @return \lloc\Msls\ContentImport\ImportLogger
    52      */
    53     public function get_logger() {
     59        $this->main = ! is_null( $main ) ? $main : MslsMain::create();
     60    }
     61
     62    /**
     63     * @return ?ImportLogger
     64     */
     65    public function get_logger(): ?ImportLogger {
    5466        return $this->logger;
    5567    }
    5668
    5769    /**
    58      * @param \lloc\Msls\ContentImport\ImportLogger $logger
    59      */
    60     public function set_logger( $logger ): void {
     70     * @param ImportLogger $logger
     71     */
     72    public function set_logger( ImportLogger $logger ): void {
    6173        $this->logger = $logger;
    6274    }
    6375
    6476    /**
    65      * @return \lloc\Msls\ContentImport\Relations
    66      */
    67     public function get_relations() {
     77     * @return ?Relations
     78     */
     79    public function get_relations(): ?Relations {
    6880        return $this->relations;
    6981    }
    7082
    7183    /**
    72      * @param \lloc\Msls\ContentImport\Relations $relations
    73      */
    74     public function set_relations( $relations ): void {
     84     * @param Relations $relations
     85     */
     86    public function set_relations( Relations $relations ): void {
    7587        $this->relations = $relations;
    7688    }
     
    8496     */
    8597    public function handle_import( array $data = array() ) {
    86         if ( ! $this->pre_flight_check() || false === $sources = $this->parse_sources() ) {
     98        $sources = $this->parse_sources();
     99        if ( ! $this->pre_flight_check() || false === $sources ) {
    87100            return $data;
    88101        }
     
    90103        list( $source_blog_id, $source_post_id ) = $sources;
    91104
    92         if ( $source_blog_id === get_current_blog_id() ) {
     105        if ( get_current_blog_id() === $source_blog_id ) {
    93106            return $data;
    94107        }
     
    148161        }
    149162
     163        // phpcs:ignore WordPress.Security.NonceVerification.Missing
    150164        if ( ! isset( $_POST['msls_import'] ) ) {
    151165            return false;
     
    225239        $this->handle( true );
    226240
    227         $this->has_created_post = $post_id ?: false;
     241        $this->has_created_post = $post_id > 0 ? $post_id : false;
    228242
    229243        restore_current_blog();
     
    240254        $this->handle = $handle;
    241255
    242         // also prevent MSLS from saving
     256        // Also, prevent MSLS from saving.
    243257        if ( false === $handle ) {
    244             add_action( 'msls_main_save', '__return_void' );
     258            add_action( 'msls_main_save', 'msls_return_void' );
    245259        } else {
    246             remove_action( 'msls_main_save', '__return_void' );
     260            remove_action( 'msls_main_save', 'msls_return_void' );
    247261        }
    248262    }
     
    268282         * @param ImportCoordinates $import_coordinates
    269283         */
    270         do_action( 'msls_content_import_before_import', $import_coordinates );
     284        do_action( self::MSLS_BEFORE_IMPORT_ACTION, $import_coordinates );
    271285
    272286        /**
     
    329343         * @since TBD
    330344         */
    331         do_action( 'msls_content_import_after_import', $import_coordinates, $this->logger, $this->relations );
     345        do_action( self::MSLS_AFTER_IMPORT_ACTION, $import_coordinates, $this->logger, $this->relations );
    332346
    333347        /**
     
    356370    protected function update_inserted_blog_post_data( $blog_id, $post_id, array $data ) {
    357371        $data['ID']          = $post_id;
    358         $data['post_status'] = empty( $data['post_status'] ) || $data['post_status'] === 'auto-draft'
     372        $data['post_status'] = empty( $data['post_status'] ) || 'auto-draft' === $data['post_status']
    359373            ? 'draft'
    360374            : $data['post_status'];
     
    372386        switch_to_blog( $dest_blog_id );
    373387        $edit_post_link = html_entity_decode( get_edit_post_link( $post_id ) );
    374         wp_redirect( $edit_post_link );
     388        wp_safe_redirect( $edit_post_link );
    375389        die();
    376390    }
     
    382396     * the context of a content import as it will be populated.
    383397     *
    384      * @param bool $empty
     398     * @param bool $is_empty
    385399     *
    386400     * @return bool
    387401     */
    388     public function filter_empty( $empty ) {
     402    public function filter_empty( $is_empty ) {
    389403        if ( ! $this->main->verify_nonce() ) {
    390             return $empty;
    391         }
    392 
     404            return $is_empty;
     405        }
     406
     407        // phpcs:ignore WordPress.Security.NonceVerification.Missing
    393408        if ( ! isset( $_POST['msls_import'] ) ) {
    394             return $empty;
     409            return $is_empty;
    395410        }
    396411
  • multisite-language-switcher/trunk/includes/ContentImport/ImportCoordinates.php

    r3287198 r3409411  
    6565        }
    6666
    67         if ( $this->source_lang !== MslsBlogCollection::get_blog_language( $this->source_blog_id ) ) {
     67        if ( MslsBlogCollection::get_blog_language( $this->source_blog_id ) !== $this->source_lang ) {
    6868            return false;
    6969        }
    70         if ( $this->dest_lang !== MslsBlogCollection::get_blog_language( $this->dest_blog_id ) ) {
     70        if ( MslsBlogCollection::get_blog_language( $this->dest_blog_id ) !== $this->dest_lang ) {
    7171            return false;
    7272        }
  • multisite-language-switcher/trunk/includes/ContentImport/ImportLogger.php

    r3287198 r3409411  
    88class ImportLogger {
    99
     10    /**
     11     * @var string
     12     */
    1013    protected string $levels_delimiter = '/';
    1114
     
    6366        $log_writer = apply_filters( 'msls_content_import_log_writer', $default_log_writer, $this->import_coordinates );
    6467        if ( empty( $log_writer ) ) {
    65             // we assume that was done on purpose to prevent logging
     68            // We assume that was done on purpose to prevent logging.
    6669            return;
    6770        }
     
    7275
    7376        if ( ! $log_writer instanceof LogWriter ) {
    74             // something is fishy, let's use the default one
     77            // Something is fishy, let's use the default one.
    7578            $log_writer = $default_log_writer;
    7679        }
  • multisite-language-switcher/trunk/includes/ContentImport/Importers/BaseImporter.php

    r3287198 r3409411  
    2727     * BaseImporter constructor.
    2828     *
     29     * @param ImportCoordinates $import_coordinates
    2930     * @param ImportLogger|null $logger
    3031     * @param Relations|null    $relations
     
    3637    ) {
    3738        $this->import_coordinates = $import_coordinates;
    38         $this->logger             = $logger ?: new ImportLogger( $this->import_coordinates );
    39         $this->relations          = $relations ?: new Relations( $this->import_coordinates );
     39        $this->logger             = ! is_null( $logger ) ? $logger : new ImportLogger( $this->import_coordinates );
     40        $this->relations          = ! is_null( $relations ) ? $relations : new Relations( $this->import_coordinates );
    4041    }
    4142
  • multisite-language-switcher/trunk/includes/ContentImport/Importers/ImportersBaseFactory.php

    r3199861 r3409411  
    2020
    2121    /**
     22     * Creates an Importer instance based on the provided ImportCoordinates.
     23     *
     24     * @param ImportCoordinates $import_coordinates The coordinates for the import operation.
     25     *
    2226     * @return Importer
     27     *
     28     * @throws \RuntimeException If the TYPE constant is not defined in the child class.
    2329     */
    2430    public function make( ImportCoordinates $import_coordinates ) {
    2531        if ( static::TYPE === self::TYPE ) {
    26             // this is a developer-land exception, no need to localize it
     32            // This is a developer-land exception, no need to localize it.
    2733            throw new \RuntimeException( 'Importers factories should define their own type' );
    2834        }
     
    5460
    5561        $first = count( $map ) > 0 ? reset( $map ) : null;
    56         $slug  = $import_coordinates->get_importer_for( $type ) ?: $first;
     62        $slug  = $import_coordinates->get_importer_for( $type );
    5763
    58         // if there is some incoherence return the null-doing base importer
     64        if ( is_null( $slug ) ) {
     65            $slug = $first;
     66        }
     67
     68        // If there is some incoherence, return the null-doing base importer.
    5969        $class = ! empty( $slug ) && isset( $map[ $slug ] ) ? $map[ $slug ] : BaseImporter::class;
    6070
  • multisite-language-switcher/trunk/includes/ContentImport/Importers/PostThumbnail/Linking.php

    r3199861 r3409411  
    6161        switch_to_blog( $this->import_coordinates->dest_blog_id );
    6262
    63         if ( $source_post_thumbnail_attachment instanceof \WP_Post ) {
    64             // in some instances the folder sep. `/` might be duplicated, we de-duplicate it
    65             array_walk(
    66                 $source_upload_dir,
    67                 function ( &$entry ) {
    68                     $entry = str_replace( '//', '/', $entry );
    69                 }
    70             );
    71             $source_uploads_dir         = untrailingslashit(
    72                 str_replace(
    73                     $source_upload_dir['subdir'],
    74                     '',
    75                     $source_upload_dir['path']
    76                 )
    77             );
    78             $source_post_thumbnail_file = $source_uploads_dir . '/' . $source_post_thumbnail_meta['_wp_attached_file'];
     63        // In some instances, the folder sep. `/` might be duplicated, we de-duplicate it.
     64        array_walk(
     65            $source_upload_dir,
     66            function ( &$entry ) {
     67                $entry = str_replace( '//', '/', $entry );
     68            }
     69        );
     70        $source_uploads_dir         = untrailingslashit(
     71            str_replace(
     72                $source_upload_dir['subdir'],
     73                '',
     74                $source_upload_dir['path']
     75            )
     76        );
     77        $source_post_thumbnail_file = $source_uploads_dir . '/' . $source_post_thumbnail_meta['_wp_attached_file'];
    7978
    80             // Check the type of file. We'll use this as the 'post_mime_type'.
    81             $filetype = wp_check_filetype( basename( $source_post_thumbnail_file ), null );
     79        // Check the type of file. We'll use this as the 'post_mime_type'.
     80        $filetype = wp_check_filetype( basename( $source_post_thumbnail_file ), null );
    8281
    83             // Prepare an array of post data for the attachment.
    84             $attachment = array(
    85                 'guid'           => $source_post_thumbnail_attachment->guid,
    86                 'post_mime_type' => $filetype['type'],
    87                 'post_title'     => preg_replace( '/\.[^.]+$/', '', basename( $source_post_thumbnail_file ) ),
    88                 'post_content'   => '',
    89                 'post_status'    => 'inherit',
     82        // Prepare an array of post data for the attachment.
     83        $attachment = array(
     84            'guid'           => $source_post_thumbnail_attachment->guid,
     85            'post_mime_type' => $filetype['type'],
     86            'post_title'     => preg_replace( '/\.[^.]+$/', '', basename( $source_post_thumbnail_file ) ),
     87            'post_content'   => '',
     88            'post_status'    => 'inherit',
     89        );
     90
     91        $found = get_posts(
     92            array(
     93                'post_type' => 'attachment',
     94                'title'     => $attachment['post_title'],
     95            )
     96        );
     97        if ( isset( $found[0]->ID ) ) {
     98            $dest_post_thumbnail_id = $found[0]->ID;
     99            $this->logger->log_success( 'post-thumbnail/existing', $dest_post_thumbnail_id );
     100        } else {
     101            // Insert the attachment.
     102            $dest_post_thumbnail_id = wp_insert_attachment(
     103                $attachment,
     104                $source_post_thumbnail_file,
     105                $dest_post_id
    90106            );
    91107
    92             $existing_criteria = array(
    93                 'post_type' => 'attachment',
    94                 'title'     => $attachment['post_title'],
    95             );
     108            if ( empty( $dest_post_thumbnail_id ) ) {
     109                $this->logger->log_error( 'post-thumbnail/created', $dest_post_thumbnail_id );
     110            } else {
     111                $this->logger->log_success( 'post-thumbnail/created', $dest_post_thumbnail_id );
     112            }
    96113
    97             $found = get_posts( $existing_criteria );
     114            // The `_wp_attached_file` meta has been set before, so we skip it.
     115            unset( $source_post_thumbnail_meta['_wp_attached_file'] );
    98116
    99             if ( $found && $found[0] instanceof \WP_Post ) {
    100                 $dest_post_thumbnail_id = $found[0]->ID;
    101                 $this->logger->log_success( 'post-thumbnail/existing', $dest_post_thumbnail_id );
    102             } else {
    103                 // Insert the attachment.
    104                 $dest_post_thumbnail_id = wp_insert_attachment(
    105                     $attachment,
    106                     $source_post_thumbnail_file,
    107                     $dest_post_id
    108                 );
    109 
    110                 if ( empty( $dest_post_thumbnail_id ) ) {
    111                     $this->logger->log_error( 'post-thumbnail/created', $dest_post_thumbnail_id );
    112                 } else {
    113                     $this->logger->log_success( 'post-thumbnail/created', $dest_post_thumbnail_id );
    114                 }
    115 
    116                 // the `_wp_attached_file` meta has been set before, so we skip it
    117                 unset( $source_post_thumbnail_meta['_wp_attached_file'] );
    118 
    119                 foreach ( $source_post_thumbnail_meta as $key => $value ) {
    120                     add_post_meta( $dest_post_thumbnail_id, $key, $value, true );
    121                 }
     117            foreach ( $source_post_thumbnail_meta as $key => $value ) {
     118                add_post_meta( $dest_post_thumbnail_id, $key, $value, true );
    122119            }
    123120
  • multisite-language-switcher/trunk/includes/ContentImport/Importers/Terms/ShallowDuplicating.php

    r3287198 r3409411  
    8080
    8181            if ( is_array( $added ) && ! count( array_filter( $added ) ) ) {
    82                 // while we think the term translation exists it might not, let's create it
     82                // While we think the term translation exists it might not, let's create it.
    8383                $dest_term_id = $this->create_local_term( $term, $msls_term, $dest_lang );
    8484
     
    8787                }
    8888
    89                 // and try again
     89                // And try again.
    9090                $added = $this->update_object_terms( $dest_post_id, $dest_term_id, $term->taxonomy );
    9191            }
  • multisite-language-switcher/trunk/includes/ContentImport/Importers/WithRequestPostAttributes.php

    r3167915 r3409411  
    2424     * Returns the post type read from `$_REQUEST['post_type']` if any, or a default post type.
    2525     *
    26      * @param string $default The default post type to return if none is specified in the `$_REQUEST` super-global.
     26     * @param string $preset The default post type to return if none is specified in the `$_REQUEST` super-global.
    2727     *
    2828     * @return string Either the post type read from the `$_REQUEST` super-global, or the default value.
    29 \    *
    3029     */
    31     protected function read_post_type_from_request( $default = 'post' ) {
    32         $request = MslsRequest::get_request( array( 'post_type' ), $default );
     30    protected function read_post_type_from_request( $preset = 'post' ) {
     31        $request = MslsRequest::get_request( array( 'post_type' ), $preset );
    3332
    3433        return $request['post_type'];
  • multisite-language-switcher/trunk/includes/ContentImport/LogWriters/AdminNoticeLogger.php

    r3199861 r3409411  
    99class AdminNoticeLogger extends MslsRegistryInstance implements LogWriter {
    1010
     11    /**
     12     * The transient where the last import log will be stored.
     13     *
     14     * @var string
     15     */
    1116    protected string $transient = 'msls_last_import_log';
    1217
     
    138143     * Shows the last log that was written.
    139144     *
    140      * @param bool $echo
     145     * @param bool $output
    141146     *
    142147     * @return ?string
    143148     */
    144     public function show_last_log( $echo = true ): ?string {
    145         if ( ! ( $html = get_transient( $this->transient ) ) ) {
     149    public function show_last_log( $output = true ): ?string {
     150        $html = get_transient( $this->transient );
     151        if ( ! $html ) {
    146152            return null;
    147153        }
    148154
    149         if ( $echo ) {
     155        if ( $output ) {
    150156            echo wp_kses( $html, Component::get_allowed_html() );
    151157        }
    152158
    153         // we've shown it, no reason to keep it
     159        // We've shown it, no reason to keep it.
    154160        delete_transient( $this->transient );
    155161
  • multisite-language-switcher/trunk/includes/ContentImport/MetaBox.php

    r3199861 r3409411  
    103103            array(
    104104                'modal'    => true,
    105                 'width'    => 770, // meh, just a guess on *most* devices
     105                'width'    => 770, // Meh, just a guess on *most* devices.
    106106                'height'   => 770,
    107107                'inlineId' => 'msls-import-dialog-' . str_replace( '|', '-', $data['msls_import'] ),
     
    121121
    122122    /**
    123      * @param bool                 $echo
     123     * @param bool                 $output
    124124     * @param array<string, mixed> $data
    125125     *
    126126     * @return string
    127127     */
    128     protected function inline_thickbox_html( $echo = true, array $data = array() ): string {
     128    protected function inline_thickbox_html( $output = true, array $data = array() ): string {
    129129        if ( ! isset( $data['msls_import'] ) ) {
    130130            return '';
     
    187187        $html = ob_get_clean();
    188188
    189         if ( $echo ) {
     189        if ( $output ) {
    190190            echo wp_kses( $html, Component::get_allowed_html() );
    191191        }
  • multisite-language-switcher/trunk/includes/ContentImport/Service.php

    r3167915 r3409411  
    6161        add_filter(
    6262            'wp_insert_post_empty_content',
    63             function ( $empty ) {
    64                 return ContentImporter::instance()->filter_empty( $empty );
     63            function ( $bare ) {
     64                return ContentImporter::instance()->filter_empty( $bare );
    6565            }
    6666        );
     
    7575        add_filter(
    7676            'wp_calculate_image_srcset',
    77             function ( $sources, $sizeArray, $imageSrc, $imageMeta, $attachmentId ) {
     77            function ( $sources, $size_array, $image_src, $image_meta, $attachment_id ) {
    7878                return AttachmentPathFinder::instance()->filter_srcset(
    7979                    $sources,
    80                     $sizeArray,
    81                     $imageSrc,
    82                     $imageMeta,
    83                     $attachmentId
     80                    $size_array,
     81                    $image_src,
     82                    $image_meta,
     83                    $attachment_id
    8484                );
    8585            },
  • multisite-language-switcher/trunk/includes/Map/HrefLang.php

    r3287198 r3409411  
    1111 */
    1212class HrefLang {
     13
     14    const MSLS_HEAD_HREFLANG_HOOK = 'msls_head_hreflang';
    1315
    1416    /**
     
    2729
    2830        foreach ( $map as $alpha2 => $languages ) {
    29             if ( 1 == count( $languages ) ) {
     31            if ( 1 === count( $languages ) ) {
    3032                $this->map[ $languages[0] ] = $alpha2;
    3133            } else {
     
    6567         * @since 0.9.9
    6668         */
    67         return (string) apply_filters( 'msls_head_hreflang', $language );
     69        return (string) apply_filters( self::MSLS_HEAD_HREFLANG_HOOK, $language );
    6870    }
    6971}
  • multisite-language-switcher/trunk/includes/MslsAdmin.php

    r3287198 r3409411  
    2727final class MslsAdmin extends MslsMain {
    2828
     29    const MSLS_REGISTER_ACTION = 'msls_admin_register';
     30
     31    const MSLS_ACTION_PREFIX = 'msls_admin_';
     32
     33    /**
     34     * Maximum number of users in the reference user select box
     35     *
     36     * @var int
     37     */
    2938    public const MAX_REFERENCE_USERS = 100;
    3039
     
    8796    public function __call( $method, $args ) {
    8897        $parts = explode( '_', $method, 2 );
    89         if ( count( $parts ) > 0 && 'rewrite' === $parts[0] ) {
     98        if ( 2 === count( $parts ) && 'rewrite' === $parts[0] ) {
    9099            $this->render_rewrite( $parts[1] );
    91100            return;
     
    136145            );
    137146            $message = sprintf( $format, esc_url( admin_url( $this->get_options_page_link() ) ) );
    138         } elseif ( 1 == count( $this->options->get_available_languages() ) ) {
     147        } elseif ( 1 === count( $this->options->get_available_languages() ) ) {
    139148            /* translators: %1$s: URL to a page at WordPress.orgs */
    140149            $format  = __(
     
    188197        foreach ( $this->collection->get_plugin_active_blogs() as $blog ) {
    189198            $admin_url = get_admin_url( $blog->userblog_id, $this->get_options_page_link() );
    190             $current   = $blog->userblog_id == $this->collection->get_current_blog_id() ? ' class="current"' : '';
     199            $current   = $blog->userblog_id === $this->collection->get_current_blog_id() ? ' class="current"' : '';
    191200
    192201            $arr[] = sprintf( '<a href="%1$s"%2$s>%3$s</a>', $admin_url, $current, $blog->get_title( $icon_type ) );
     
    227236         * @since 1.0
    228237         */
    229         do_action( 'msls_admin_register', __CLASS__ );
     238        do_action( self::MSLS_REGISTER_ACTION, __CLASS__ );
    230239    }
    231240
     
    326335         * @since 2.4.4
    327336         */
    328         do_action( "msls_admin_{$section}", __CLASS__, $section );
     337        do_action( self::MSLS_ACTION_PREFIX . $section, __CLASS__, $section );
    329338
    330339        return count( $map );
     
    385394            );
    386395
    387             // phpcs:ignore WordPress.Security.EscapeOutput
    388             trigger_error( sprintf( esc_html( $format ), strval( self::MAX_REFERENCE_USERS ) ) );
     396            // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
     397            trigger_error( esc_html( sprintf( $format, strval( self::MAX_REFERENCE_USERS ) ) ) );
    389398        }
    390399
     
    435444     * Validates input before saving it
    436445     *
    437      * @param array<string, mixed> $arr Values of the submitted form
     446     * @param array<string, mixed> $arr Values of the submitted form.
    438447     *
    439448     * @return array<string, mixed>
  • multisite-language-switcher/trunk/includes/MslsAdminBar.php

    r3287198 r3409411  
    55class MslsAdminBar {
    66
     7    /**
     8     * @var string
     9     */
    710    protected string $icon_type;
    811
     12    /**
     13     * @var MslsBlogCollection
     14     */
    915    protected MslsBlogCollection $blog_collection;
    1016
     17    /**
     18     * @param MslsOptions        $options
     19     * @param MslsBlogCollection $blog_collection
     20     */
    1121    public function __construct( MslsOptions $options, MslsBlogCollection $blog_collection ) {
    1222        $this->icon_type       = $options->get_icon_type();
     
    1424    }
    1525
     26    /**
     27     * @return void
     28     */
    1629    public static function init(): void {
    1730        $obj = new MslsAdminBar( msls_options(), msls_blog_collection() );
     
    2437    /**
    2538     * Callback that updates the admin bar with the blog information
     39     *
     40     * @param \WP_Admin_Bar $wp_admin_bar
     41     *
     42     * @return void
    2643     */
    2744    public function update_admin_bar( \WP_Admin_Bar $wp_admin_bar ): void {
     
    4057    /**
    4158     * Adds node information to an existing node
     59     *
     60     * @param \WP_Admin_Bar $wp_admin_bar
     61     * @param string        $node_id
     62     * @param string        $title
     63     *
     64     * @return bool
    4265     */
    4366    public function add_node( \WP_Admin_Bar $wp_admin_bar, string $node_id, string $title ): bool {
     
    6184     *
    6285     * It uses a blavatar icon as prefix if $blavatar is set to true
     86     *
     87     * @param MslsBlog|null $blog
     88     * @param bool          $blavatar
     89     *
     90     * @return string|null
    6391     */
    6492    protected function get_title( ?MslsBlog $blog, bool $blavatar = false ): ?string {
  • multisite-language-switcher/trunk/includes/MslsAdminIcon.php

    r3287198 r3409411  
    117117     */
    118118    public function set_path(): MslsAdminIcon {
    119         if ( 'post' != $this->type ) {
     119        if ( 'post' !== $this->type ) {
    120120            $query_vars = array( 'post_type' => $this->type );
    121121            $this->path = add_query_arg( $query_vars, $this->path );
  • multisite-language-switcher/trunk/includes/MslsAdminIconTaxonomy.php

    r3287198 r3409411  
    4242        $post_type = MslsTaxonomy::instance()->get_post_type();
    4343
    44         $post_type !== '' && $args['post_type'] = $post_type;
     44        if ( '' !== $post_type ) {
     45            $args['post_type'] = $post_type;
     46        }
    4547
    4648        $this->path = add_query_arg( $args, $this->path );
  • multisite-language-switcher/trunk/includes/MslsBlock.php

    r3287198 r3409411  
    55class MslsBlock {
    66
     7    /**
     8     * The options instance.
     9     *
     10     * @var MslsOptions
     11     */
    712    protected MslsOptions $options;
    813
     
    3035        }
    3136
    32         register_block_type( MslsPlugin::plugin_dir_path( 'js/msls-widget-block' ) );
     37        register_block_type( MslsPlugin::plugin_dir_path( 'assets/js/msls-widget-block' ) );
    3338
    3439        return true;
  • multisite-language-switcher/trunk/includes/MslsBlog.php

    r3287198 r3409411  
    1111class MslsBlog {
    1212
     13    const MSLS_GET_PERMALINK_HOOK = 'msls_blog_get_permalink';
     14
     15    const WP_ADMIN_BAR_SHOW_SITE_ICONS_HOOK = 'wp_admin_bar_show_site_icons';
     16
    1317    /**
    1418     * WordPress generates such an object
     
    9195     * Gets the language stored in this object
    9296     *
    93      * @param string $default
    94      *
    95      * @return string
    96      */
    97     public function get_language( $default = 'en_US' ) {
    98         return empty( $this->language ) ? $default : $this->language;
     97     * @param string $preset
     98     *
     99     * @return string
     100     */
     101    public function get_language( $preset = 'en_US' ) {
     102        return empty( $this->language ) ? $preset : $this->language;
    99103    }
    100104
     
    116120     */
    117121    public function get_url( $options ) {
    118         if ( $this->obj->userblog_id == msls_blog_collection()->get_current_blog_id() ) {
     122        if ( msls_blog_collection()->get_current_blog_id() === $this->obj->userblog_id ) {
    119123            return $options->get_current_link();
    120124        }
     
    128132     * @return ?string
    129133     */
    130     protected function get_permalink( $options ) {
     134    protected function get_permalink( OptionsInterface $options ) {
    131135        $url = null;
    132136
     
    135139        switch_to_blog( $this->obj->userblog_id );
    136140
    137         if ( is_object( $options ) && method_exists(
    138             $options,
    139             'has_value'
    140         ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) {
    141             $url = apply_filters( 'mlsl_blog_get_permalink', $options->get_permalink( $this->get_language() ), $this );
     141        if ( $is_home || $options->has_value( $this->get_language() ) ) {
     142            $url = apply_filters( self::MSLS_GET_PERMALINK_HOOK, $options->get_permalink( $this->get_language() ), $this );
    142143        }
    143144
     
    155156     * @return int
    156157     */
    157     public static function _cmp( $a, $b ) {
    158         if ( $a == $b ) {
     158    public static function internal_cmp( $a, $b ) {
     159        if ( $a === $b ) {
    159160            return 0;
    160161        }
     
    172173     */
    173174    public static function language( MslsBlog $a, MslsBlog $b ) {
    174         return self::_cmp( $a->get_language(), $b->get_language() );
     175        return self::internal_cmp( $a->get_language(), $b->get_language() );
    175176    }
    176177
     
    184185     */
    185186    public static function description( MslsBlog $a, MslsBlog $b ) {
    186         return self::_cmp( $a->get_description(), $b->get_description() );
     187        return self::internal_cmp( $a->get_description(), $b->get_description() );
    187188    }
    188189
     
    192193    public function get_blavatar(): string {
    193194        $blavatar_html   = '<div class="blavatar"></div>';
    194         $show_site_icons = apply_filters( 'wp_admin_bar_show_site_icons', true );
     195        $show_site_icons = apply_filters( self::WP_ADMIN_BAR_SHOW_SITE_ICONS_HOOK, true );
    195196
    196197        switch_to_blog( $this->obj->userblog_id );
  • multisite-language-switcher/trunk/includes/MslsBlogCollection.php

    r3287198 r3409411  
    7575            foreach ( $blogs_collection as $blog ) {
    7676                $description = false;
    77                 if ( $blog->userblog_id == $this->current_blog_id ) {
     77                if ( $blog->userblog_id === $this->current_blog_id ) {
    7878                    $description = $options->description;
    7979                } elseif ( ! $this->is_plugin_active( $blog->userblog_id ) ) {
     
    153153
    154154        foreach ( $this->get_objects() as $item ) {
    155             if ( $language == $item->get_language() ) {
     155            if ( $language === $item->get_language() ) {
    156156                $blog = $item;
    157157                break;
     
    253253        $plugins = get_blog_option( $blog_id, 'active_plugins', array() );
    254254
    255         return in_array( $path, $plugins );
     255        return in_array( $path, $plugins, true );
    256256    }
    257257
     
    325325     *
    326326     * @param int    $blog_id
    327      * @param string $default
     327     * @param string $preset
    328328     *
    329329     * @return string
    330330     */
    331     public static function get_blog_language( $blog_id = null, $default = 'en_US' ) {
     331    public static function get_blog_language( $blog_id = null, $preset = 'en_US' ) {
    332332        if ( null === $blog_id ) {
    333333            $blog_id = get_current_blog_id();
     
    336336        $language = (string) get_blog_option( $blog_id, 'WPLANG' );
    337337
    338         return '' !== $language ? $language : $default;
     338        return '' !== $language ? $language : $preset;
    339339    }
    340340}
  • multisite-language-switcher/trunk/includes/MslsCli.php

    r3287198 r3409411  
    2929     *  $ wp msls blog <locale>
    3030     *
    31      * @param string[]              $args
    32      * @param array<string, string> $assoc_args
     31     * @param string[] $args
     32     *
    3333     * @return void
    3434     */
    35     public function blog( $args, $assoc_args ): void {
     35    public function blog( $args ): void {
    3636        list( $locale ) = $args;
    3737        $blog           = msls_blog( $locale );
  • multisite-language-switcher/trunk/includes/MslsContentFilter.php

    r3287198 r3409411  
    55class MslsContentFilter {
    66
     7    /**
     8     * The options instance.
     9     *
     10     * @var MslsOptions
     11     */
    712    protected MslsOptions $options;
    813
     
    7176        }
    7277
    73         if ( 1 == count( $links ) ) {
     78        if ( 1 === count( $links ) ) {
    7479            return $links[0];
    7580        }
  • multisite-language-switcher/trunk/includes/MslsContentTypes.php

    r3287198 r3409411  
    3232        $_request = MslsRequest::get_request( array( 'taxonomy' ) );
    3333
    34         return '' != $_request['taxonomy'] ? MslsTaxonomy::instance() : MslsPostType::instance();
     34        return '' !== $_request['taxonomy'] ? MslsTaxonomy::instance() : MslsPostType::instance();
    3535    }
    3636
  • multisite-language-switcher/trunk/includes/MslsCustomColumn.php

    r3287198 r3409411  
    4848                $language  = $blog->get_language();
    4949                $icon_type = $this->options->get_icon_type();
     50                $icon      = ( new MslsAdminIcon() )->set_language( $language )->set_icon_type( $icon_type );
    5051
    51                 $icon = ( new MslsAdminIcon() )->set_language( $language )->set_icon_type( $icon_type );
    52 
    53                 if ( $post_id = get_the_ID() ) {
     52                $post_id = get_the_ID();
     53                if ( false !== $post_id ) {
    5454                    $icon->set_id( $post_id );
    5555                    $icon->set_origin_language( 'it_IT' );
     
    7373     */
    7474    public function td( $column_name, $item_id ): void {
    75         if ( 'mslscol' == $column_name ) {
     75        if ( 'mslscol' === $column_name ) {
    7676            $blogs           = $this->collection->get();
    7777            $origin_language = MslsBlogCollection::get_blog_language();
  • multisite-language-switcher/trunk/includes/MslsCustomFilter.php

    r3287198 r3409411  
    7979        $sql_cache = MslsSqlCacher::create( __CLASS__, __METHOD__ );
    8080
    81         // load post we need to exclude (they already have a translation) from search query
     81        // Load post we need to exclude (they already have a translation) from search query.
    8282        $query->query_vars['post__not_in'] = ( new TranslatedPostIdQuery( $sql_cache ) )( $blog->get_language() );
    8383
  • multisite-language-switcher/trunk/includes/MslsLink.php

    r3287198 r3409411  
    1818
    1919    /**
    20      * Gets all link types as array with "id => name"-items
     20     * Gets all link types as an array with "id => name"-items
    2121     *
    2222     * @return string[]
     
    7474             * @param LinkInterface $obj
    7575             * @param int $display
    76              *
    77              * @return LinkInterface
    7876             */
    7977            $obj = apply_filters( 'msls_link_create', $obj, $display );
    80             if ( $obj instanceof LinkInterface ) {
    81                 return $obj;
    82             }
    8378        }
    8479
  • multisite-language-switcher/trunk/includes/MslsMain.php

    r3287198 r3409411  
    1111 */
    1212class MslsMain {
     13
     14    const MSLS_SAVE_ACTION = 'msls_main_save';
    1315
    1416    /**
     
    4951        if ( defined( 'WP_DEBUG' ) && WP_DEBUG === true ) {
    5052            if ( is_array( $message ) || is_object( $message ) ) {
     53                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
    5154                $message = print_r( $message, true );
    5255            }
    5356
     57            // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
    5458            error_log( 'MSLS Debug: ' . $message );
    5559        }
     
    128132     */
    129133    protected function save( $object_id, $class_name ): void {
    130         if ( has_action( 'msls_main_save' ) ) {
     134        if ( has_action( self::MSLS_SAVE_ACTION ) ) {
    131135            /**
    132136             * Calls completely customized save-routine
     
    137141             * @since 0.9.9
    138142             */
    139             do_action( 'msls_main_save', $object_id, $class_name );
     143            do_action( self::MSLS_SAVE_ACTION, $object_id, $class_name );
    140144
    141145            return;
     
    153157        $temp     = $options->get_arr();
    154158
    155         if ( 0 != $msla->get_val( $language ) ) {
     159        if ( 0 !== $msla->get_val( $language ) ) {
    156160            $options->save( $msla->get_arr( $language ) );
    157161        } else {
     
    165169            $larr_id  = $msla->get_val( $language );
    166170
    167             if ( 0 != $larr_id ) {
     171            if ( 0 !== $larr_id ) {
    168172                $options = new $class_name( $larr_id );
    169173                $options->save( $msla->get_arr( $language ) );
  • multisite-language-switcher/trunk/includes/MslsMetaBox.php

    r3287198 r3409411  
    66use lloc\Msls\Component\Wrapper;
    77use lloc\Msls\ContentImport\MetaBox as ContentImportMetaBox;
     8use WP_Post;
    89
    910/**
     
    7677    public static function get_suggested_fields( MslsJson $json, array $args ): MslsJson {
    7778        /**
    78          * Overrides the query-args for the suggest fields in the MetaBox
     79         * Overrides the query-args for the 'suggest' fields in the MetaBox
    7980         *
    8081         * @param array $args<string, mixed>
     
    8889             * Manipulates the WP_Post object before using it
    8990             *
    90              * @param \WP_Post $post
     91             * @param WP_Post $post
    9192             *
    9293             * @since 0.9.9
    9394             */
    9495            $post = apply_filters( 'msls_meta_box_suggest_post', $post );
    95             if ( is_object( $post ) ) {
    96                 $json->add( $post->ID, get_the_title( $post ) );
    97             }
     96
     97            $json->add( $post->ID, get_the_title( $post ) );
    9898        }
    9999
     
    226226            echo ( new Wrapper( 'ul', $lis ) )->render();
    227227
     228            // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
    228229            $post = $temp;
    229230        } else {
     
    304305                $icon_type = $this->options->get_icon_type();
    305306                $icon      = MslsAdminIcon::create()->set_language( $language )->set_icon_type( $icon_type );
    306 
    307                 $value = $title = '';
     307                $value     = '';
     308                $title     = '';
     309
    308310                if ( $my_data->has_value( $language ) ) {
    309311                    $icon->set_href( (int) $my_data->$language );
     
    334336            );
    335337
     338            // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
    336339            $post = $temp;
    337340        } else {
  • multisite-language-switcher/trunk/includes/MslsOptions.php

    r3287198 r3409411  
    2929class MslsOptions extends MslsGetSet implements OptionsInterface {
    3030
     31    const MSLS_GET_POSTLINK_HOOK = 'msls_get_postlink';
     32
    3133    public const PREFIX    = 'msls';
    3234    public const SEPARATOR = '';
    3335
     36    /**
     37     * The name of the option in the database
     38     *
     39     * @var string
     40     */
    3441    protected string $name;
    35     protected bool $exists   = false;
     42
     43    /**
     44     * Indicates whether the option exists in the database
     45     *
     46     * @var bool
     47     */
     48    protected bool $exists = false;
     49
     50    /**
     51     * Autoload option
     52     *
     53     * @var bool
     54     */
    3655    protected bool $autoload = true;
    3756
     
    83102        }
    84103
    85         add_filter( 'msls_get_postlink', array( $options, 'check_for_blog_slug' ), 10, 2 );
     104        add_filter( self::MSLS_GET_POSTLINK_HOOK, array( $options, 'check_for_blog_slug' ), 10, 2 );
    86105
    87106        return $options;
     
    134153     *
    135154     * @param int   $index
    136      * @param mixed $default
     155     * @param mixed $preset
    137156     *
    138157     * @return mixed
    139158     */
    140     public function get_arg( int $index, $default = null ) {
    141         $arg = $this->args[ $index ] ?? $default;
    142 
    143         settype( $arg, gettype( $default ) );
     159    public function get_arg( int $index, $preset = null ) {
     160        $arg = $this->args[ $index ] ?? $preset;
     161
     162        settype( $arg, gettype( $preset ) );
    144163
    145164        return $arg;
     
    211230        );
    212231
    213         return '' != $postlink ? $postlink : home_url( '/' );
     232        return '' !== $postlink ? $postlink : home_url( '/' );
    214233    }
    215234
     
    311330     */
    312331    public function get_flag_url( $language ) {
    313         $url = ! is_admin() && isset( $this->image_url ) ? $this->__get( 'image_url' ) : $this->get_url( 'flags' );
     332        $url = ! is_admin() && isset( $this->image_url ) ? $this->__get( 'image_url' ) : $this->get_url( 'assets/flags' );
    314333
    315334        /**
  • multisite-language-switcher/trunk/includes/MslsOptionsPost.php

    r3167915 r3409411  
    1212    public const SEPARATOR = '_';
    1313
     14    /**
     15     * @var bool
     16     */
    1417    protected bool $autoload = false;
    1518
     
    2730
    2831        $post = get_post( (int) $this->__get( $language ) );
    29         if ( is_null( $post ) || 'publish' != $post->post_status ) {
     32        if ( is_null( $post ) || 'publish' !== $post->post_status ) {
    3033            return '';
    3134        }
     
    3841        $post_link = get_permalink( $post );
    3942
    40         $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' );
     43        $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', MslsOptions::MSLS_GET_POSTLINK_HOOK );
    4144
    42         return apply_filters( 'msls_get_postlink', $post_link, $this );
     45        return apply_filters( MslsOptions::MSLS_GET_POSTLINK_HOOK, $post_link, $this );
    4346    }
    4447
  • multisite-language-switcher/trunk/includes/MslsOptionsQuery.php

    r3287198 r3409411  
    1717    public ?bool $with_front = true;
    1818
     19    /**
     20     * @var MslsSqlCacher
     21     */
    1922    protected MslsSqlCacher $sql_cache;
    2023
     
    3538     * Factory method
    3639     *
    37      * @param int $id This parameter is unused here
     40     * @param int $id This parameter is unused here.
    3841     *
    3942     * @return ?MslsOptionsQuery
     
    7275            $post_link = $this->get_current_link();
    7376            if ( ! empty( $post_link ) ) {
    74                 $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' );
     77                $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', MslsOptions::MSLS_GET_POSTLINK_HOOK );
    7578
    76                 return apply_filters( 'msls_get_postlink', $post_link, $this );
     79                return apply_filters( MslsOptions::MSLS_GET_POSTLINK_HOOK, $post_link, $this );
    7780            }
    7881        }
  • multisite-language-switcher/trunk/includes/MslsOptionsQueryAuthor.php

    r3287198 r3409411  
    1212class MslsOptionsQueryAuthor extends MslsOptionsQuery {
    1313
     14    /**
     15     * The author ID for which the posts count is queried.
     16     *
     17     * @var int
     18     */
    1419    protected int $author_id;
    1520
  • multisite-language-switcher/trunk/includes/MslsOptionsQueryDay.php

    r3287198 r3409411  
    1212class MslsOptionsQueryDay extends MslsOptionsQuery {
    1313
     14    /**
     15     * @var int
     16     */
    1417    protected int $year;
    1518
     19    /**
     20     * @var int
     21     */
    1622    protected int $monthnum;
     23
     24    /**
     25     * @var int
     26     */
    1727    protected int $day;
    1828
  • multisite-language-switcher/trunk/includes/MslsOptionsQueryMonth.php

    r3287198 r3409411  
    1212class MslsOptionsQueryMonth extends MslsOptionsQuery {
    1313
     14    /**
     15     * @var int
     16     */
    1417    protected int $year;
    1518
     19    /**
     20     * @var int
     21     */
    1622    protected int $monthnum;
    1723
  • multisite-language-switcher/trunk/includes/MslsOptionsQueryPostType.php

    r3287198 r3409411  
    1010class MslsOptionsQueryPostType extends MslsOptionsQuery {
    1111
     12    /**
     13     * The post type for which the options are queried.
     14     *
     15     * @var string
     16     */
    1217    protected string $post_type;
    1318
  • multisite-language-switcher/trunk/includes/MslsOptionsQueryYear.php

    r3287198 r3409411  
    1212class MslsOptionsQueryYear extends MslsOptionsQuery {
    1313
     14    /**
     15     * The year for which the posts count is queried.
     16     *
     17     * @var int
     18     */
    1419    protected int $year;
    1520
     21    /**
     22     * Constructor.
     23     *
     24     * @param MslsSqlCacher $sql_cache The SQL Cacher instance.
     25     */
    1626    public function __construct( MslsSqlCacher $sql_cache ) {
    1727        parent::__construct( $sql_cache );
     
    2030    }
    2131
     32    /**
     33     * Get the parameters for this query.
     34     *
     35     * @return array<string, mixed>
     36     */
    2237    public static function get_params(): array {
    2338        return array(
  • multisite-language-switcher/trunk/includes/MslsOptionsTax.php

    r3287198 r3409411  
    1212    public const SEPARATOR = '_term_';
    1313
     14    /**
     15     * @var bool
     16     */
    1417    protected bool $autoload = false;
    1518
     
    8992        }
    9093
    91         $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', 'msls_get_postlink' );
     94        $post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', MslsOptions::MSLS_GET_POSTLINK_HOOK );
    9295
    93         return apply_filters( 'msls_get_postlink', $post_link, $this );
     96        return apply_filters( MslsOptions::MSLS_GET_POSTLINK_HOOK, $post_link, $this );
    9497    }
    9598
  • multisite-language-switcher/trunk/includes/MslsOptionsTaxTerm.php

    r3287198 r3409411  
    2222
    2323    public function handle_rewrite(): OptionsTaxInterface {
    24         add_filter( 'msls_get_postlink', array( $this, 'check_base' ), 9, 2 );
     24        add_filter( MslsOptions::MSLS_GET_POSTLINK_HOOK, array( $this, 'check_base' ), 9, 2 );
    2525
    2626        return $this;
     
    4444        $base_option  = self::get_base_option();
    4545
    46         if ( $base_defined != $base_option ) {
     46        if ( $base_defined !== $base_option ) {
    4747            $search  = '/' . $base_defined . '/';
    4848            $replace = '/' . $base_option . '/';
     
    7070
    7171    public static function get_base_option(): string {
    72         $base_option = get_option( static::BASE_OPTION, '' );
    73 
    74         return $base_option ?: static::BASE_DEFINED;
     72        return get_option( static::BASE_OPTION, static::BASE_DEFINED );
    7573    }
    7674}
  • multisite-language-switcher/trunk/includes/MslsOutput.php

    r3287198 r3409411  
    1111 */
    1212class MslsOutput extends MslsMain {
     13
     14    const MSLS_ALTERNATE_LINKS_HOOK = 'msls_output_get_alternate_links';
     15
     16    const MSLS_ALTERNATE_LINKS_ARR_HOOK = 'msls_output_get_alternate_links_arr';
     17
     18    const MSLS_ALTERNATE_LINKS_DEFAULT_HOOK = 'msls_output_get_alternate_links_default';
     19
     20    const MSLS_GET_HOOK = 'msls_output_get';
     21
     22    const MSLS_NO_TRANSLATION_FOUND_HOOK = 'msls_output_no_translation_found';
     23
     24    const MSLS_GET_TAGS_HOOK = 'msls_output_get_tags';
     25
    1326
    1427    public static function init(): object {
     
    6477                }
    6578
    66                 if ( has_filter( 'msls_output_get' ) ) {
     79                if ( has_filter( self::MSLS_GET_HOOK ) ) {
    6780                    /**
    6881                     * Returns HTML-link for an item of the output-arr
     
    7487                     * @since 0.9.8
    7588                     */
    76                     $arr[] = (string) apply_filters( 'msls_output_get', $url, $link, $is_current_blog );
     89                    $arr[] = (string) apply_filters( self::MSLS_GET_HOOK, $url, $link, $is_current_blog );
    7790                } else {
    7891                    $arr[] = sprintf(
     
    8093                        $url,
    8194                        $link->txt,
    82                         $is_current_blog ? ' class="current_language"' : '',
     95                        $is_current_blog ? ' class="current_language" aria-current="page"' : '',
    8396                        $link
    8497                    );
     
    96109     */
    97110    public function get_alternate_links() {
    98         $blogs   = msls_blog_collection();
    99         $hlObj  = new HrefLang( $blogs );
    100         $options = MslsOptions::create();
    101         $arr     = array();
    102         $default = '';
     111        $blogs     = msls_blog_collection();
     112        $href_lang = new HrefLang( $blogs );
     113        $options   = MslsOptions::create();
     114        $arr       = array();
     115        $default   = '';
    103116
    104117        foreach ( $blogs->get_objects() as $blog ) {
    105             $url = apply_filters( 'mlsl_output_get_alternate_links', $blog->get_url( $options ), $blog );
     118            $url = apply_filters( self::MSLS_ALTERNATE_LINKS_HOOK, $blog->get_url( $options ), $blog );
    106119            if ( is_null( $url ) ) {
    107120                continue;
    108121            }
    109122
    110             $hreflang = $hlObj->get( $blog->get_language() );
     123            $hreflang = $href_lang->get( $blog->get_language() );
    111124            $format   = '<link rel="alternate" href="%1$s" hreflang="%2$s" />';
    112125
     
    119132
    120133        if ( 1 === count( $arr ) ) {
    121             return apply_filters( 'mlsl_output_get_alternate_links_default', $default );
    122         }
    123 
    124         $arr = (array) apply_filters( 'mlsl_output_get_alternate_links_arr', $arr );
     134            return apply_filters( self::MSLS_ALTERNATE_LINKS_DEFAULT_HOOK, $default );
     135        }
     136
     137        $arr = (array) apply_filters( self::MSLS_ALTERNATE_LINKS_ARR_HOOK, $arr );
    125138
    126139        return implode( PHP_EOL, $arr );
     
    135148        $arr = $this->get( $this->options->display, false, isset( $this->options->only_with_translation ) );
    136149        if ( empty( $arr ) ) {
    137             return apply_filters( 'msls_output_no_translation_found', '' );
     150            return apply_filters( self::MSLS_NO_TRANSLATION_FOUND_HOOK, '' );
    138151        }
    139152
     
    166179             * @since 1.0
    167180             */
    168             $this->tags = (array) apply_filters( 'msls_output_get_tags', $this->tags );
     181            $this->tags = (array) apply_filters( self::MSLS_GET_TAGS_HOOK, $this->tags );
    169182        }
    170183
     
    199212        }
    200213
    201         return MslsOptions::class != get_class( $thing ) && ! $thing->has_value( $language ) && $exists;
     214        return MslsOptions::class !== get_class( $thing ) && ! $thing->has_value( $language ) && $exists;
    202215    }
    203216}
  • multisite-language-switcher/trunk/includes/MslsPlugin.php

    r3287198 r3409411  
    3434    public static function init(): void {
    3535        $obj = new self( msls_options() );
    36 
    37         add_action( 'init', array( $obj, 'init_i18n_support' ) );
    3836
    3937        register_activation_hook( self::file(), array( __CLASS__, 'activate' ) );
     
    115113
    116114        $ver    = defined( 'MSLS_PLUGIN_VERSION' ) ? constant( 'MSLS_PLUGIN_VERSION' ) : false;
    117         $folder = defined( 'SCRIPT_DEBUG' ) && constant( 'SCRIPT_DEBUG' ) ? 'src' : 'js';
    118 
    119         wp_enqueue_style( 'msls-styles', self::plugins_url( 'css/msls.css' ), array(), $ver );
    120         wp_enqueue_style( 'msls-flags', self::plugins_url( 'css-flags/css/flag-icon.min.css' ), array(), $ver );
     115        $folder = defined( 'SCRIPT_DEBUG' ) && constant( 'SCRIPT_DEBUG' ) ? 'src' : 'assets/js';
     116
     117        wp_enqueue_style( 'msls-styles', self::plugins_url( 'assets/css/msls.css' ), array(), $ver );
     118        wp_enqueue_style( 'msls-flags', self::plugins_url( 'assets/css-flags/css/flag-icon.min.css' ), array(), $ver );
    121119
    122120        if ( $this->options->activate_autocomplete ) {
     
    168166    public static function path(): string {
    169167        return defined( 'MSLS_PLUGIN_PATH' ) ? constant( 'MSLS_PLUGIN_PATH' ) : '';
    170     }
    171 
    172     /**
    173      * Load textdomain
    174      *
    175      * The method should be executed always on init because we have some translatable string in the frontend too.
    176      */
    177     public function init_i18n_support(): void {
    178         load_plugin_textdomain( 'multisite-language-switcher', false, self::dirname( '/languages/' ) );
    179168    }
    180169
  • multisite-language-switcher/trunk/includes/MslsPostTag.php

    r3287198 r3409411  
    11<?php declare( strict_types=1 );
    2 
    3 /**
    4  * MslsPostTag
    5  *
    6  * @author Dennis Ploetner <re@lloc.de>
    7  */
    82
    93namespace lloc\Msls;
     
    1812class MslsPostTag extends MslsMain {
    1913
    20     const EDIT_ACTION = 'msls_post_tag_edit_input';
    21     const ADD_ACTION  = 'msls_post_tag_add_input';
     14    const MSLS_EDIT_INPUT_ACTION = 'msls_post_tag_edit_input';
     15    const MSLS_ADD_INPUT_ACTION  = 'msls_post_tag_add_input';
    2216
    2317    /**
     
    8579
    8680        $taxonomy = msls_content_types()->acl_request();
    87         if ( '' != $taxonomy ) {
     81        if ( '' !== $taxonomy ) {
    8882            add_action( "{$taxonomy}_add_form_fields", array( $obj, 'add_input' ) );
    8983            add_action( "{$taxonomy}_edit_form_fields", array( $obj, 'edit_input' ), 10, 2 );
     
    9993     */
    10094    public function add_input( string $taxonomy ): void {
    101         if ( did_action( self::ADD_ACTION ) ) {
     95        if ( did_action( self::MSLS_ADD_INPUT_ACTION ) ) {
    10296            return;
    10397        }
     
    115109        echo '</div>';
    116110
    117         do_action( self::ADD_ACTION, $taxonomy );
     111        do_action( self::MSLS_ADD_INPUT_ACTION, $taxonomy );
    118112    }
    119113
     
    125119     */
    126120    public function edit_input( \WP_Term $tag, string $taxonomy ): void {
    127         if ( did_action( self::EDIT_ACTION ) ) {
     121        if ( did_action( self::MSLS_EDIT_INPUT_ACTION ) ) {
    128122            return;
    129123        }
     
    149143        $this->the_input( $tag, $title_format, $item_format );
    150144
    151         do_action( self::EDIT_ACTION, $tag, $taxonomy );
     145        do_action( self::MSLS_EDIT_INPUT_ACTION, $tag, $taxonomy );
    152146    }
    153147
     
    185179                $icon_type = $this->options->get_icon_type();
    186180                $icon      = MslsAdminIcon::create()->set_language( $language )->set_icon_type( $icon_type );
    187 
    188                 $value = $title = '';
     181                $value     = '';
     182                $title     = '';
     183
    189184                if ( $mydata->has_value( $language ) ) {
    190185                    $term = get_term( $mydata->$language, $type );
  • multisite-language-switcher/trunk/includes/MslsPostTagClassic.php

    r3287198 r3409411  
    1212class MslsPostTagClassic extends MslsPostTag {
    1313
    14     const EDIT_ACTION = 'msls_post_tag_classic_edit_input';
    15     const ADD_ACTION  = 'msls_post_tag_classic_add_input';
     14    const MSLS_EDIT_INPUT_ACTION = 'msls_post_tag_classic_edit_input';
     15    const MSLS_ADD_INPUT_ACTION  = 'msls_post_tag_classic_add_input';
    1616
    1717    /**
     
    2121     */
    2222    public function add_input( string $taxonomy ): void {
    23         if ( did_action( self::ADD_ACTION ) ) {
     23        if ( did_action( self::MSLS_ADD_INPUT_ACTION ) ) {
    2424            return;
    2525        }
     
    3737        echo '</div>';
    3838
    39         do_action( self::ADD_ACTION, $taxonomy );
     39        do_action( self::MSLS_ADD_INPUT_ACTION, $taxonomy );
    4040    }
    4141
     
    4747     */
    4848    public function edit_input( \WP_Term $tag, string $taxonomy ): void {
    49         if ( did_action( self::EDIT_ACTION ) ) {
     49        if ( did_action( self::MSLS_EDIT_INPUT_ACTION ) ) {
    5050            return;
    5151        }
     
    6969        $this->the_input( $tag, $title_format, $item_format );
    7070
    71         do_action( self::EDIT_ACTION, $tag, $taxonomy );
     71        do_action( self::MSLS_EDIT_INPUT_ACTION, $tag, $taxonomy );
    7272    }
    7373
  • multisite-language-switcher/trunk/includes/MslsPostType.php

    r3287198 r3409411  
    2424    public static function get(): array {
    2525        $types = array_merge(
    26             array( 'post', 'page' ), // we don't need attachment, revision or nav_menu_item here
     26            array( 'post', 'page' ), // We don't need attachment, revision or nav_menu_item here.
    2727            get_post_types(
    2828                array(
     
    4343        $post_type = ! empty( $request['post_type'] ) ? esc_attr( $request['post_type'] ) : 'post';
    4444
    45         return in_array( $post_type, $this->get() ) ? $post_type : '';
     45        return in_array( $post_type, $this->get(), true ) ? $post_type : '';
    4646    }
    4747
  • multisite-language-switcher/trunk/includes/MslsRegistry.php

    r3287198 r3409411  
    5151     */
    5252    public static function instance(): self {
    53         if ( self::$instance === null ) {
     53        if ( null === self::$instance ) {
    5454            self::$instance = new self();
    5555        }
  • multisite-language-switcher/trunk/includes/MslsRegistryInstance.php

    r3287198 r3409411  
    1717    public static function instance() {
    1818        $class = get_called_class();
     19        $obj   = MslsRegistry::get_object( $class );
    1920
    20         if ( ! ( $obj = MslsRegistry::get_object( $class ) ) ) {
     21        if ( ! $obj ) {
    2122            $obj = new $class();
    2223
  • multisite-language-switcher/trunk/includes/MslsRequest.php

    r3287198 r3409411  
    66
    77    /**
     8     * @param string $name
     9     *
    810     * @return array<int, int>
     11     *
     12     * @throws \InvalidArgumentException No field with the given name exists.
    913     */
    1014    public static function get_config( string $name ): array {
     
    3135
    3236    /**
    33      * @return mixed
     37     * @param string   $var_name
     38     * @param int|null $input_type
     39     *
     40     * @return ?mixed
    3441     */
    3542    public static function get_var( string $var_name, ?int $input_type = null ) {
     
    5057    /**
    5158     * @param string $name
    52      * @param mixed  $default
     59     * @param mixed  $preset
    5360     *
    5461     * @return mixed
    5562     */
    56     public static function get( string $name, $default ) {
    57         return self::has_var( $name ) ? self::get_var( $name ) : $default;
     63    public static function get( string $name, $preset ) {
     64        return self::has_var( $name ) ? self::get_var( $name ) : $preset;
    5865    }
    5966
     
    7986     *
    8087     * @param string[] $keys
    81      * @param mixed    $default
     88     * @param mixed    $preset
    8289     *
    8390     * @return array<string, mixed>
    8491     */
    85     public static function get_request( array $keys, $default = '' ): array {
     92    public static function get_request( array $keys, $preset = '' ): array {
    8693        $values = array();
    8794
    8895        foreach ( $keys as $key ) {
    8996            list( , $filter ) = self::get_config( $key );
    90             $values[ $key ]   = $default;
     97            $values[ $key ]   = $preset;
    9198
    9299            if ( filter_has_var( INPUT_POST, $key ) ) {
  • multisite-language-switcher/trunk/includes/MslsShortCode.php

    r3287198 r3409411  
    77    public static function init(): void {
    88        add_shortcode( 'sc_msls_widget', array( __CLASS__, 'render_widget' ) );
    9         add_shortcode( 'sc_msls', 'get_the_msls' );
     9        add_shortcode( 'sc_msls', 'msls_get_switcher' );
    1010    }
    1111
  • multisite-language-switcher/trunk/includes/MslsSqlCacher.php

    r3287198 r3409411  
    2323
    2424    /**
    25      * Cache group
     25     * Cache group for the SQL cacher
    2626     */
    2727    const CACHE_GROUP = 'msls-cache-group';
    2828
    2929    /**
    30      * Database object
     30     * @var \wpdb
    3131     */
    3232    protected \wpdb $db;
    3333
    3434    /**
    35      * Key for the cached result-set
     35     * @var string
    3636     */
    3737    protected string $cache_key;
     
    3939    /**
    4040     * Expiration time for the cache in seconds
     41     *
     42     * @var int
    4143     */
    4244    protected int $expire;
     
    4446    /**
    4547     * Constructor
     48     *
     49     * @param \wpdb  $db        The WordPress database object.
     50     * @param string $cache_key The cache key to use for storing results.
     51     * @param int    $expire    The expiration time for the cache in seconds. Default is 0 (no expiration).
    4652     */
    4753    public function __construct( \wpdb $db, string $cache_key, int $expire = 0 ) {
     
    7177     * Magic __get
    7278     *
     79     * @param string $name
     80     *
    7381     * @return mixed
    7482     */
     
    8694     */
    8795    public function __call( string $method, array $args ) {
    88         if ( 'get_' != substr( $method, 0, 4 ) ) {
     96        if ( 'get_' !== substr( $method, 0, 4 ) ) {
    8997            return call_user_func_array( array( $this->db, $method ), $args );
    9098        }
  • multisite-language-switcher/trunk/includes/MslsTaxonomy.php

    r3287198 r3409411  
    3131    public static function get(): array {
    3232        $types = array_merge(
    33             array( 'category', 'post_tag' ), // no 'post_link' here
     33            array( 'category', 'post_tag' ), // No 'post_link' here.
    3434            get_taxonomies(
    3535                array(
  • multisite-language-switcher/trunk/includes/MslsWidget.php

    r3287198 r3409411  
    1111 */
    1212class MslsWidget extends \WP_Widget {
     13
     14    const MSLS_ALTERNATIVE_CONTENT_HOOK = 'msls_widget_alternative_content';
    1315
    1416    public const ID_BASE = 'mslswidget';
     
    5456        if ( '' === $content ) {
    5557            $text    = __( 'No available translations found', 'multisite-language-switcher' );
    56             $content = apply_filters( 'msls_widget_alternative_content', $text );
     58            $content = apply_filters( self::MSLS_ALTERNATIVE_CONTENT_HOOK, $text );
    5759        }
    5860
  • multisite-language-switcher/trunk/includes/Query/AbstractQuery.php

    r3287198 r3409411  
    1212abstract class AbstractQuery {
    1313
     14    /**
     15     * The SQL Cacher instance.
     16     *
     17     * @var MslsSqlCacher
     18     */
    1419    protected MslsSqlCacher $sql_cache;
    1520
     21    /**
     22     * Constructor.
     23     *
     24     * @param MslsSqlCacher $sql_cache The SQL Cacher instance.
     25     */
    1626    public function __construct( MslsSqlCacher $sql_cache ) {
    1727        $this->sql_cache = $sql_cache;
  • multisite-language-switcher/trunk/includes/Query/TranslatedPostIdQuery.php

    r3287198 r3409411  
    1010class TranslatedPostIdQuery extends AbstractQuery {
    1111
    12 
    1312    /**
     13     * @param string $language
     14     *
    1415     * @return int[]
    1516     */
  • multisite-language-switcher/trunk/includes/index.php

    r3287198 r3409411  
    11<?php
    2 // Silence is golden.
     2/**
     3 * Silence is golden.
     4 *
     5 * @package msls
     6 */
  • multisite-language-switcher/trunk/index.php

    r3287198 r3409411  
    11<?php
    2 // Silence is golden.
     2/**
     3 * Silence is golden.
     4 *
     5 * @package msls
     6 */
  • multisite-language-switcher/trunk/languages/index.php

    r3287198 r3409411  
    11<?php
    2 // Silence is golden.
     2/**
     3 * Silence is golden.
     4 *
     5 * @package msls
     6 */
  • multisite-language-switcher/trunk/vendor/composer/installed.php

    r3287198 r3409411  
    22    'root' => array(
    33        'name' => 'lloc/multisite-language-switcher',
    4         'pretty_version' => '2.9.6',
    5         'version' => '2.9.6.0',
    6         'reference' => '720656eb12e8c4f5bb5271f2365374e2e18349b4',
     4        'pretty_version' => '2.10.0',
     5        'version' => '2.10.0.0',
     6        'reference' => '897c7ea2766f60104e532f9183a1eccbbba090ac',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    2121        ),
    2222        'lloc/multisite-language-switcher' => array(
    23             'pretty_version' => '2.9.6',
    24             'version' => '2.9.6.0',
    25             'reference' => '720656eb12e8c4f5bb5271f2365374e2e18349b4',
     23            'pretty_version' => '2.10.0',
     24            'version' => '2.10.0.0',
     25            'reference' => '897c7ea2766f60104e532f9183a1eccbbba090ac',
    2626            'type' => 'wordpress-plugin',
    2727            'install_path' => __DIR__ . '/../../',
  • multisite-language-switcher/trunk/vendor/composer/platform_check.php

    r3002259 r3409411  
    2020        }
    2121    }
    22     trigger_error(
    23         'Composer detected issues in your platform: ' . implode(' ', $issues),
    24         E_USER_ERROR
     22    throw new \RuntimeException(
     23        'Composer detected issues in your platform: ' . implode(' ', $issues)
    2524    );
    2625}
Note: See TracChangeset for help on using the changeset viewer.