', $arr ) );
}
/**
@@ -323,7 +342,12 @@ public function display() {
* Shows the select-form-field 'admin_display'
*/
public function admin_display() {
- echo ( new Select( 'admin_display', array( 'flag' => __( 'Flag', 'multisite-language-switcher' ), 'label' => __( 'Label', 'multisite-language-switcher' ) ), $this->options->admin_display ) )->render();
+ echo ( new Select( 'admin_display',
+ array(
+ 'flag' => __( 'Flag', 'multisite-language-switcher' ),
+ 'label' => __( 'Label', 'multisite-language-switcher' )
+ ),
+ $this->options->admin_display ) )->render();
}
/**
@@ -340,7 +364,8 @@ public function reference_user() {
$users = array_slice( $users, 0, self::MAX_REFERENCE_USERS, true );
$message = sprintf(
- __( 'Multisite Language Switcher: Collection for reference user has been truncated because it exceeded the maximum of %s users. Please, use the hook "msls_reference_users" to filter the result before!', 'multisite-language-switcher' ),
+ __( 'Multisite Language Switcher: Collection for reference user has been truncated because it exceeded the maximum of %s users. Please, use the hook "msls_reference_users" to filter the result before!',
+ 'multisite-language-switcher' ),
self::MAX_REFERENCE_USERS
);
trigger_error( $message );
diff --git a/includes/MslsAdminIcon.php b/includes/MslsAdminIcon.php
index 53df54eb..e2615daa 100644
--- a/includes/MslsAdminIcon.php
+++ b/includes/MslsAdminIcon.php
@@ -63,7 +63,7 @@ class MslsAdminIcon {
*/
protected $id;
- const TYPE_FLAG = 'flag';
+ const TYPE_FLAG = 'flag';
const TYPE_LABEL = 'label';
@@ -209,10 +209,12 @@ public function get_img(): string {
*/
public function get_a(): string {
if ( empty( $this->href ) ) {
- $title = sprintf( __( 'Create a new translation in the %s-blog', 'multisite-language-switcher' ), $this->language );
+ $title = sprintf( __( 'Create a new translation in the %s-blog', 'multisite-language-switcher' ),
+ $this->language );
$href = $this->get_edit_new();
} else {
- $title = sprintf( __( 'Edit the translation in the %s-blog', 'multisite-language-switcher' ), $this->language );
+ $title = sprintf( __( 'Edit the translation in the %s-blog', 'multisite-language-switcher' ),
+ $this->language );
$href = $this->href;
}
@@ -243,7 +245,8 @@ public function get_icon(): string {
);
break;
default:
- $icon = sprintf( '', empty( $this->href ) ? 'dashicons-plus' : 'dashicons-edit' );
+ $icon = sprintf( '',
+ empty( $this->href ) ? 'dashicons-plus' : 'dashicons-edit' );
}
return $icon;
diff --git a/includes/MslsBlog.php b/includes/MslsBlog.php
index cb49c76f..e2da1976 100644
--- a/includes/MslsBlog.php
+++ b/includes/MslsBlog.php
@@ -31,7 +31,7 @@ class MslsBlog {
/**
* Constructor
*
- * @param \StdClass $obj
+ * @param ?\StdClass $obj
* @param string $description
*/
public function __construct( $obj, $description ) {
@@ -76,7 +76,9 @@ public function get_description(): string {
public function get_title( string $icon_type = 'flag' ): string {
$icon = ( new MslsAdminIcon( null ) )->set_language( $this->language )->set_icon_type( $icon_type );
- return sprintf( '%1$s %2$s', $this->obj->blogname, '' . $icon->get_icon() . '' );
+ return sprintf( '%1$s %2$s',
+ $this->obj->blogname,
+ '' . $icon->get_icon() . '' );
}
/**
@@ -126,7 +128,8 @@ protected function get_permalink( $options ) {
switch_to_blog( $this->obj->userblog_id );
- if ( is_object( $options ) && method_exists( $options, 'has_value' ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) {
+ if ( is_object( $options ) && method_exists( $options,
+ 'has_value' ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) {
$url = apply_filters( 'mlsl_blog_get_permalink', $options->get_permalink( $this->get_language() ), $this );
}
diff --git a/includes/MslsBlogCollection.php b/includes/MslsBlogCollection.php
index 7b747370..f7a338a3 100644
--- a/includes/MslsBlogCollection.php
+++ b/includes/MslsBlogCollection.php
@@ -70,9 +70,11 @@ public function __construct() {
if ( ! $options->is_excluded() ) {
/**
* Returns custom filtered blogs of the blogs_collection
- * @since 0.9.8
*
* @param array $blogs_collection
+ *
+ * @since 0.9.8
+ *
*/
$blogs_collection = (array) apply_filters(
'msls_blog_collection_construct',
@@ -132,7 +134,8 @@ public static function get_configured_blog_description( $blog_id, $description =
* @return array
*/
public function get_blogs_of_reference_user( MslsOptions $options ) {
- $reference_user = $options->has_value( 'reference_user' ) ? $options->reference_user : current( $this->get_users( 'ID', 1 ) );
+ $reference_user = $options->has_value( 'reference_user' ) ? $options->reference_user : current( $this->get_users( 'ID',
+ 1 ) );
$blogs = get_blogs_of_user( $reference_user );
/**
@@ -302,10 +305,10 @@ public function get_filtered( $filter = false ) {
*/
public function get_users( $fields = 'all', $number = '' ) {
$args = [
- 'blog_id' => $this->current_blog_id,
- 'orderby' => 'registered',
- 'fields' => $fields,
- 'number' => $number,
+ 'blog_id' => $this->current_blog_id,
+ 'orderby' => 'registered',
+ 'fields' => $fields,
+ 'number' => $number,
'count_total' => false,
];
diff --git a/includes/MslsCustomColumn.php b/includes/MslsCustomColumn.php
index 7bde5555..3ba41679 100644
--- a/includes/MslsCustomColumn.php
+++ b/includes/MslsCustomColumn.php
@@ -41,7 +41,9 @@ public static function init() {
/**
* Table header
+ *
* @param array $columns
+ *
* @return array
*/
public function th( $columns ) {
@@ -53,10 +55,10 @@ public function th( $columns ) {
$icon = new MslsAdminIcon( null );
$icon->set_language( $language );
- if( $this->options->admin_display === 'label' ) {
+ if ( $this->options->admin_display === 'label' ) {
$icon->set_icon_type( 'label' );
} else {
- $icon->set_icon_type( 'flag' );
+ $icon->set_icon_type( 'flag' );
}
if ( $post_id = get_the_ID() ) {
@@ -103,9 +105,9 @@ public function td( $column_name, $item_id ) {
if ( $mydata->has_value( $language ) ) {
$icon->set_href( $mydata->$language );
}
-
+
echo '';
- echo $icon->get_a();
+ echo $icon->get_a();
echo '';
restore_current_blog();
diff --git a/includes/MslsCustomColumnTaxonomy.php b/includes/MslsCustomColumnTaxonomy.php
index 7f83657b..60976556 100644
--- a/includes/MslsCustomColumnTaxonomy.php
+++ b/includes/MslsCustomColumnTaxonomy.php
@@ -8,7 +8,7 @@
namespace lloc\Msls;
/**
- * Handling of existing/not existing translations in the backend
+ * Handling of existing/not existing translations in the backend
* listings of various taxonomies
* @package Msls
*/
@@ -30,8 +30,8 @@ public static function init() {
$taxonomy = MslsTaxonomy::instance()->get_request();
if ( ! empty( $taxonomy ) ) {
- add_filter( "manage_edit-{$taxonomy}_columns" , [ $obj, 'th' ] );
- add_action( "manage_{$taxonomy}_custom_column" , [ $obj, 'column_default' ], -100, 3 );
+ add_filter( "manage_edit-{$taxonomy}_columns", [ $obj, 'th' ] );
+ add_action( "manage_{$taxonomy}_custom_column", [ $obj, 'column_default' ], - 100, 3 );
add_action( "delete_{$taxonomy}", [ $obj, 'delete' ] );
}
}
diff --git a/includes/MslsCustomFilter.php b/includes/MslsCustomFilter.php
index 1b38fb8b..ffc3ed16 100644
--- a/includes/MslsCustomFilter.php
+++ b/includes/MslsCustomFilter.php
@@ -22,9 +22,9 @@ class MslsCustomFilter extends MslsMain {
* @return MslsCustomFilter
*/
public static function init() {
- $options = MslsOptions::instance();
+ $options = MslsOptions::instance();
$collection = msls_blog_collection();
- $obj = new static( $options, $collection );
+ $obj = new static( $options, $collection );
if ( ! $options->is_excluded() ) {
$post_type = MslsPostType::instance()->get_request();
@@ -57,7 +57,8 @@ public function add_filter() {
'',
$blog->userblog_id,
selected( $id, $blog->userblog_id, false ),
- sprintf( __( 'Not translated in the %s-blog', 'multisite-language-switcher' ), $blog->get_description() )
+ sprintf( __( 'Not translated in the %s-blog', 'multisite-language-switcher' ),
+ $blog->get_description() )
);
}
echo '';
diff --git a/includes/MslsGetSet.php b/includes/MslsGetSet.php
index 95914ee0..c6f0b0ff 100644
--- a/includes/MslsGetSet.php
+++ b/includes/MslsGetSet.php
@@ -40,6 +40,7 @@ public function __set( $key, $value ) {
* Overloads the get method.
*
* @param string $key
+ *
* @return mixed
*/
public function __get( $key ) {
@@ -50,6 +51,7 @@ public function __get( $key ) {
* Overloads the isset method.
*
* @param string $key
+ *
* @return bool
*/
public function __isset( $key ) {
@@ -93,6 +95,7 @@ public function reset() {
* which is the same but in my opinion a little bit ugly.
*
* @param string $key
+ *
* @return bool
*/
public function has_value( $key ) {
diff --git a/includes/MslsJson.php b/includes/MslsJson.php
index aaebafc8..aa33a5c3 100644
--- a/includes/MslsJson.php
+++ b/includes/MslsJson.php
@@ -18,17 +18,17 @@ class MslsJson {
* Container
* @var array
*/
- protected $arr = [];
+ protected array $arr = [];
- /**
+ /** MslsLanguageArray
* Adds a value label pair to the internal class container
*
- * @param int $value
+ * @param ?int $value
* @param string $label
*
* @return MslsJson
*/
- public function add( $value, $label ) {
+ public function add( ?int $value, string $label ) {
$this->arr[] = [
'value' => intval( $value ),
'label' => strval( $label ),
diff --git a/includes/MslsLanguageArray.php b/includes/MslsLanguageArray.php
index a52a484c..e205fac3 100644
--- a/includes/MslsLanguageArray.php
+++ b/includes/MslsLanguageArray.php
@@ -22,6 +22,7 @@ class MslsLanguageArray {
/**
* Constructor
+ *
* @param array $arr
*/
public function __construct( array $arr = [] ) {
@@ -34,8 +35,10 @@ public function __construct( array $arr = [] ) {
* Set a key-value-pair
* - $key must be a string of length >= 2
* - $value must be an integer > 0
+ *
* @param string $key
* @param mixed $value
+ *
* @return MslsLanguageArray
*/
public function set( $key, $value ) {
@@ -43,13 +46,16 @@ public function set( $key, $value ) {
if ( 2 <= strlen( $key ) && 0 < $value ) {
$this->arr[ $key ] = $value;
}
+
return $this;
}
/**
* Get the value of the element with the specified key
+ *
* @param string $key
+ *
* @return int
*/
public function get_val( $key ) {
@@ -58,7 +64,9 @@ public function get_val( $key ) {
/**
* Get the filtered array without the specified element
+ *
* @param string $key
+ *
* @return array
*/
public function get_arr( $key = '' ) {
@@ -66,6 +74,7 @@ public function get_arr( $key = '' ) {
if ( isset( $arr[ $key ] ) ) {
unset( $arr[ $key ] );
}
+
return $arr;
}
diff --git a/includes/MslsLink.php b/includes/MslsLink.php
index 6bfbc486..8daf8682 100644
--- a/includes/MslsLink.php
+++ b/includes/MslsLink.php
@@ -75,11 +75,12 @@ public static function create( $display ) {
if ( has_filter( 'msls_link_create' ) ) {
/**
* Returns custom MslsLink-Object
- * @since 0.9.9
*
* @param int $display
*
* @return MslsLink
+ * @since 0.9.9
+ *
*/
$obj = apply_filters( 'msls_link_create', $display );
if ( is_subclass_of( $obj, __CLASS__ ) ) {
diff --git a/includes/MslsMain.php b/includes/MslsMain.php
index 7bff4583..f73440d4 100644
--- a/includes/MslsMain.php
+++ b/includes/MslsMain.php
@@ -100,6 +100,7 @@ public function get_input_array( $object_id ) {
/**
* Prepare input key/value-pair
+ *
* @param $key
* @param $value
*
@@ -159,10 +160,12 @@ protected function save( $object_id, $class ) {
if ( has_action( 'msls_main_save' ) ) {
/**
* Calls completely customized save-routine
- * @since 0.9.9
*
* @param int $object_id
* @param string Classname
+ *
+ * @since 0.9.9
+ *
*/
do_action( 'msls_main_save', $object_id, $class );
diff --git a/includes/MslsMetaBox.php b/includes/MslsMetaBox.php
index 004b17d9..aaef7703 100644
--- a/includes/MslsMetaBox.php
+++ b/includes/MslsMetaBox.php
@@ -143,7 +143,7 @@ public function add() {
add_meta_box(
'msls-content-import',
apply_filters(
- 'msls_metabox_post_import_title',
+ 'msls_metabox_post_import_title',
__( 'Multisite Language Switcher - Import content', 'multisite-language-switcher' )
),
[
@@ -187,7 +187,7 @@ public function render_select() {
$icon = MslsAdminIcon::create()->set_language( $language )->set_icon_type( $iconType );
if ( $mydata->has_value( $language ) ) {
- $icon->set_href( $mydata->$language );
+ $icon->set_href( $mydata->$language );
}
$selects = '';
@@ -240,7 +240,8 @@ public function render_select() {
} else {
printf(
'
%s
',
- __( 'You should define at least another blog in a different language in order to have some benefit from this plugin!', 'multisite-language-switcher' )
+ __( 'You should define at least another blog in a different language in order to have some benefit from this plugin!',
+ 'multisite-language-switcher' )
);
}
}
@@ -279,7 +280,10 @@ public function render_options( $type, $msls_id ) {
* @return string
*/
public function render_option( $post_id, $msls_id ) {
- return sprintf( '', $post_id, selected( $post_id, $msls_id, false ), get_the_title( $post_id ) );
+ return sprintf( '',
+ $post_id,
+ selected( $post_id, $msls_id, false ),
+ get_the_title( $post_id ) );
}
/**
@@ -308,9 +312,9 @@ public function render_input( $echo = true ) {
$language = $blog->get_language();
$icon = MslsAdminIcon::create()
- ->set_language( $language );
+ ->set_language( $language );
- if( $this->options->admin_display === 'label' ) {
+ if ( $this->options->admin_display === 'label' ) {
$icon->set_icon_type( 'label' );
} else {
$icon->set_icon_type( 'flag' );
@@ -353,7 +357,8 @@ public function render_input( $echo = true ) {
} else {
printf(
'
%s
',
- __( 'You should define at least another blog in a different language in order to have some benefit from this plugin!', 'multisite-language-switcher' )
+ __( 'You should define at least another blog in a different language in order to have some benefit from this plugin!',
+ 'multisite-language-switcher' )
);
}
}
diff --git a/includes/MslsOptions.php b/includes/MslsOptions.php
index 66b81f0c..f0fc5bfa 100644
--- a/includes/MslsOptions.php
+++ b/includes/MslsOptions.php
@@ -221,10 +221,12 @@ public function set( $arr ) {
public function get_permalink( $language ) {
/**
* Filters the url by language
- * @since 0.9.8
*
* @param string $postlink
* @param string $language
+ *
+ * @since 0.9.8
+ *
*/
$postlink = (string) apply_filters(
'msls_options_get_permalink',
@@ -283,7 +285,7 @@ public function is_content_filter() {
* @return string
*/
public function get_order() {
- return isset( $this->sort_by_description ) ? 'description' : 'language';
+ return isset( $this->sort_by_description ) ? 'description' : 'language';
}
/**
@@ -299,6 +301,7 @@ public function get_url( $dir ) {
/**
* Returns slug for a post type
+ *
* @param string $post_type
*
* @return string
@@ -307,7 +310,7 @@ public function get_slug( $post_type ) {
$key = "rewrite_{$post_type}";
error_log( $key );
-
+
return isset( $this->$key ) ? $this->$key : '';
}
@@ -336,9 +339,11 @@ public function get_flag_url( $language ) {
/**
* Override the path to the flag-icons
- * @since 0.9.9
*
* @param string $url
+ *
+ * @since 0.9.9
+ *
*/
$url = (string) apply_filters( 'msls_options_get_flag_url', $url );
@@ -346,10 +351,12 @@ public function get_flag_url( $language ) {
/**
* Use your own filename for the flag-icon
- * @since 1.0.3
*
* @param string $icon
* @param string $language
+ *
+ * @since 1.0.3
+ *
*/
$icon = (string) apply_filters( 'msls_options_get_flag_icon', $icon, $language );
@@ -359,9 +366,9 @@ public function get_flag_url( $language ) {
/**
* Get all available languages
*
- * @uses get_available_languages
- * @uses format_code_lang
* @return array
+ * @uses format_code_lang
+ * @uses get_available_languages
*/
public function get_available_languages() {
if ( empty( $this->available_languages ) ) {
@@ -375,9 +382,11 @@ public function get_available_languages() {
/**
* Returns custom filtered available languages
- * @since 1.0
*
* @param array $available_languages
+ *
+ * @since 1.0
+ *
*/
$this->available_languages = (array) apply_filters(
'msls_options_get_available_languages',
diff --git a/includes/MslsOptionsPost.php b/includes/MslsOptionsPost.php
index 54746a45..342506ec 100644
--- a/includes/MslsOptionsPost.php
+++ b/includes/MslsOptionsPost.php
@@ -27,7 +27,9 @@ class MslsOptionsPost extends MslsOptions {
/**
* Get postlink
+ *
* @param string $language
+ *
* @return string
*/
public function get_postlink( $language ) {
diff --git a/includes/MslsOptionsQuery.php b/includes/MslsOptionsQuery.php
index 8ec870a9..8e3c6771 100644
--- a/includes/MslsOptionsQuery.php
+++ b/includes/MslsOptionsQuery.php
@@ -36,21 +36,17 @@ public static function create( $id = 0 ) {
get_query_var( 'monthnum' ),
get_query_var( 'day' )
);
- }
- elseif ( is_month() ) {
- $query = new MslsOptionsQueryMonth(
+ } elseif ( is_month() ) {
+ $query = new MslsOptionsQueryMonth(
get_query_var( 'year' ),
get_query_var( 'monthnum' )
);
- }
- elseif ( is_year() ) {
- $query = new MslsOptionsQueryYear( get_query_var( 'year' ) );
- }
- elseif ( is_author() ) {
- $query = new MslsOptionsQueryAuthor( get_queried_object_id() );
- }
- elseif ( is_post_type_archive() ) {
- $query = new MslsOptionsQueryPostType( get_query_var( 'post_type' ) );
+ } elseif ( is_year() ) {
+ $query = new MslsOptionsQueryYear( get_query_var( 'year' ) );
+ } elseif ( is_author() ) {
+ $query = new MslsOptionsQueryAuthor( get_queried_object_id() );
+ } elseif ( is_post_type_archive() ) {
+ $query = new MslsOptionsQueryPostType( get_query_var( 'post_type' ) );
}
return $query;
@@ -60,6 +56,7 @@ public static function create( $id = 0 ) {
* Get postlink
*
* @param string $language
+ *
* @return string
*/
public function get_postlink( $language ) {
diff --git a/includes/MslsOptionsQueryAuthor.php b/includes/MslsOptionsQueryAuthor.php
index bc51335d..dfa0320b 100644
--- a/includes/MslsOptionsQueryAuthor.php
+++ b/includes/MslsOptionsQueryAuthor.php
@@ -18,6 +18,7 @@ class MslsOptionsQueryAuthor extends MslsOptionsQuery {
* Check if the array has an non empty item which has $language as a key
*
* @param string $language
+ *
* @return bool
*/
public function has_value( $language ) {
@@ -31,6 +32,7 @@ public function has_value( $language ) {
)
);
}
+
return (bool) $this->arr[ $language ];
}
diff --git a/includes/MslsOptionsQueryDay.php b/includes/MslsOptionsQueryDay.php
index ffbdb50e..e26a702d 100644
--- a/includes/MslsOptionsQueryDay.php
+++ b/includes/MslsOptionsQueryDay.php
@@ -18,20 +18,24 @@ class MslsOptionsQueryDay extends MslsOptionsQuery {
* Check if the array has an non empty item which has $language as a key
*
* @param string $language
+ *
* @return bool
*/
public function has_value( $language ) {
if ( ! isset( $this->arr[ $language ] ) ) {
- $date = new \DateTime();
+ $date = new \DateTime();
$cache = MslsSqlCacher::init( __CLASS__ )->set_params( $this->args );
$this->arr[ $language ] = $cache->get_var(
$cache->prepare(
"SELECT count(ID) FROM {$cache->posts} WHERE DATE(post_date) = %s AND post_status = 'publish'",
- $date->setDate( $this->get_arg( 0, 0 ), $this->get_arg( 1, 0 ), $this->get_arg( 2, 0 ) )->format( 'Y-m-d' )
+ $date->setDate( $this->get_arg( 0, 0 ),
+ $this->get_arg( 1, 0 ),
+ $this->get_arg( 2, 0 ) )->format( 'Y-m-d' )
)
);
}
+
return (bool) $this->arr[ $language ];
}
diff --git a/includes/MslsOptionsQueryMonth.php b/includes/MslsOptionsQueryMonth.php
index cf48de86..51a73cd3 100644
--- a/includes/MslsOptionsQueryMonth.php
+++ b/includes/MslsOptionsQueryMonth.php
@@ -18,6 +18,7 @@ class MslsOptionsQueryMonth extends MslsOptionsQuery {
* Check if the array has an non empty item which has $language as a key
*
* @param string $language
+ *
* @return bool
*/
public function has_value( $language ) {
@@ -32,6 +33,7 @@ public function has_value( $language ) {
)
);
}
+
return (bool) $this->arr[ $language ];
}
diff --git a/includes/MslsOptionsQueryPostType.php b/includes/MslsOptionsQueryPostType.php
index 33c9c185..e26fd859 100644
--- a/includes/MslsOptionsQueryPostType.php
+++ b/includes/MslsOptionsQueryPostType.php
@@ -18,12 +18,14 @@ class MslsOptionsQueryPostType extends MslsOptionsQuery {
* Check if the array has an non empty item which has $language as a key
*
* @param string $language
+ *
* @return bool
*/
public function has_value( $language ) {
if ( ! isset( $this->arr[ $language ] ) ) {
$this->arr[ $language ] = get_post_type_object( $this->get_arg( 0, '' ) );
}
+
return (bool) $this->arr[ $language ];
}
diff --git a/includes/MslsOptionsTax.php b/includes/MslsOptionsTax.php
index e86a297a..a2117a77 100644
--- a/includes/MslsOptionsTax.php
+++ b/includes/MslsOptionsTax.php
@@ -77,8 +77,7 @@ public function get_tax_query() {
if ( class_exists( 'WooCommerce' ) && is_woocommerce() && isset( $wp_query->tax_query->queries[1]['taxonomy'] ) ) {
return $wp_query->tax_query->queries[1]['taxonomy'];
- }
- elseif ( isset( $wp_query->tax_query->queries[0]['taxonomy'] ) ) {
+ } elseif ( isset( $wp_query->tax_query->queries[0]['taxonomy'] ) ) {
return $wp_query->tax_query->queries[0]['taxonomy'];
}
diff --git a/includes/MslsOptionsTaxTerm.php b/includes/MslsOptionsTaxTerm.php
index 475c6c62..163b5e8f 100644
--- a/includes/MslsOptionsTaxTerm.php
+++ b/includes/MslsOptionsTaxTerm.php
@@ -36,6 +36,7 @@ class MslsOptionsTaxTerm extends MslsOptionsTax {
*
* @param string $url
* @param MslsOptions $options
+ *
* @return string
*/
public function check_base( $url, $options ) {
diff --git a/includes/MslsOutput.php b/includes/MslsOutput.php
index 8bc44994..5f8a97f1 100644
--- a/includes/MslsOutput.php
+++ b/includes/MslsOutput.php
@@ -122,12 +122,12 @@ public function get_alternate_links() {
}
if ( 1 === count( $arr ) ) {
- return apply_filters( 'mlsl_output_get_alternate_links_default', $default );
+ return apply_filters( 'mlsl_output_get_alternate_links_default', $default );
}
$arr = (array) apply_filters( 'mlsl_output_get_alternate_links_arr', $arr );
- return implode( PHP_EOL, $arr );
+ return implode( PHP_EOL, $arr );
}
/**
diff --git a/includes/MslsPlugin.php b/includes/MslsPlugin.php
index 13ab4322..42c8a5fc 100644
--- a/includes/MslsPlugin.php
+++ b/includes/MslsPlugin.php
@@ -92,7 +92,9 @@ public static function init() {
} else {
add_action( 'admin_notices', function () {
$href = 'https://wordpress.org/support/article/create-a-network/';
- $msg = sprintf( __( 'The Multisite Language Switcher needs the activation of the multisite-feature for working properly. Please read this post if you don\'t know the meaning.', 'multisite-language-switcher' ), $href );
+ $msg = sprintf( __( 'The Multisite Language Switcher needs the activation of the multisite-feature for working properly. Please read this post if you don\'t know the meaning.',
+ 'multisite-language-switcher' ),
+ $href );
self::message_handler( $msg );
} );
@@ -221,15 +223,18 @@ public function block_init() {
global $pagenow;
- $toLoad = [ 'wp-blocks', 'wp-element', 'wp-components' ];
- if ( $pagenow === 'widgets.php' ) $toLoad[] = 'wp-edit-widgets';
- else $toLoad[] = 'wp-editor';
+ $toLoad = [ 'wp-blocks', 'wp-element', 'wp-components' ];
+ if ( $pagenow === 'widgets.php' ) {
+ $toLoad[] = 'wp-edit-widgets';
+ } else {
+ $toLoad[] = 'wp-editor';
+ }
- wp_register_script(
- $handle,
- self::plugins_url( 'js/msls-widget-block.js' ),
- $toLoad
- );
+ wp_register_script(
+ $handle,
+ self::plugins_url( 'js/msls-widget-block.js' ),
+ $toLoad
+ );
register_block_type( 'lloc/msls-widget-block', [
'attributes' => [ 'title' => [ 'type' => 'string' ] ],
@@ -277,7 +282,10 @@ public function custom_enqueue() {
wp_enqueue_style( 'msls-flags', self::plugins_url( 'css-flags/css/flag-icon.min.css' ), [], $ver );
if ( $this->options->activate_autocomplete ) {
- wp_enqueue_script( 'msls-autocomplete', self::plugins_url( "js/msls{$postfix}.js" ), [ 'jquery-ui-autocomplete' ], $ver );
+ wp_enqueue_script( 'msls-autocomplete',
+ self::plugins_url( "js/msls{$postfix}.js" ),
+ [ 'jquery-ui-autocomplete' ],
+ $ver );
return true;
}
diff --git a/includes/MslsPostTag.php b/includes/MslsPostTag.php
index f6fce2f2..1d77333a 100644
--- a/includes/MslsPostTag.php
+++ b/includes/MslsPostTag.php
@@ -52,7 +52,6 @@ public static function suggest() {
$args = (array) apply_filters( 'msls_post_tag_suggest_args', $args );
foreach ( get_terms( sanitize_text_field( filter_input( INPUT_POST, 'post_type' ) ), $args ) as $term ) {
-
/**
* Manipulates the term object before using it
*
@@ -259,7 +258,8 @@ public function maybe_set_linked_term( MslsOptionsTax $mydata ) {
* @return string
*/
protected function get_select_title(): string {
- return apply_filters( 'msls_term_select_title', __( 'Multisite Language Switcher', 'multisite-language-switcher' ) );
+ return apply_filters( 'msls_term_select_title',
+ __( 'Multisite Language Switcher', 'multisite-language-switcher' ) );
}
}
diff --git a/includes/MslsPostType.php b/includes/MslsPostType.php
index d9c6abd4..ba677c5f 100644
--- a/includes/MslsPostType.php
+++ b/includes/MslsPostType.php
@@ -22,9 +22,9 @@ public function __construct() {
}
/**
+ * @return string[]
* @uses get_post_types
*
- * @return string[]
*/
public static function get(): array {
$types = array_merge(
diff --git a/includes/MslsSqlCacher.php b/includes/MslsSqlCacher.php
index 1db5454b..43ecbb31 100644
--- a/includes/MslsSqlCacher.php
+++ b/includes/MslsSqlCacher.php
@@ -61,11 +61,11 @@ public function __construct( \wpdb $db, string $caller ) {
/**
* Factory
*
- * @uses \WPDB $wpdb
- *
* @param string $caller
*
* @return MslsSqlCacher
+ * @uses \WPDB $wpdb
+ *
*/
public static function init( string $caller ): self {
global $wpdb;
diff --git a/includes/MslsTaxonomy.php b/includes/MslsTaxonomy.php
index 0120f7c7..394eb906 100644
--- a/includes/MslsTaxonomy.php
+++ b/includes/MslsTaxonomy.php
@@ -24,13 +24,13 @@ class MslsTaxonomy extends MslsContentTypes {
* Constructor
*/
public function __construct() {
- $this->types = self::get();
+ $this->types = self::get();
$this->request = $this->get_request();
}
/**
- * @uses get_taxonomies
* @return string[]
+ * @uses get_taxonomies
*/
public static function get(): array {
$types = array_merge(
diff --git a/includes/MslsWidget.php b/includes/MslsWidget.php
index 660648ce..65835df3 100644
--- a/includes/MslsWidget.php
+++ b/includes/MslsWidget.php
@@ -19,7 +19,8 @@ class MslsWidget extends \WP_Widget {
* Constructor
*/
public function __construct() {
- $name = apply_filters('msls_widget_title', __( 'Multisite Language Switcher', 'multisite-language-switcher' ) );
+ $name = apply_filters( 'msls_widget_title',
+ __( 'Multisite Language Switcher', 'multisite-language-switcher' ) );
parent::__construct( $this->id_base, $name, [ 'show_instance_in_rest' => true ] );
}
@@ -50,7 +51,7 @@ public function widget( $args, $instance ) {
$content = MslsOutput::init()->__toString();
if ( '' === $content ) {
- $text = __( 'No available translations found', 'multisite-language-switcher' );
+ $text = __( 'No available translations found', 'multisite-language-switcher' );
$content = apply_filters( 'msls_widget_alternative_content', $text );
}
diff --git a/phpunit.xml b/phpunit.xml
index 08aacf4b..6de4cafe 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,5 +1,5 @@
-
+./includes/
@@ -10,6 +10,6 @@
- ./tests/
+ ./tests/
diff --git a/tests/Component/Icon/test-iconpng.php b/tests/Component/Icon/TestIconPng.php
similarity index 73%
rename from tests/Component/Icon/test-iconpng.php
rename to tests/Component/Icon/TestIconPng.php
index 8153b55a..8bcc4db2 100644
--- a/tests/Component/Icon/test-iconpng.php
+++ b/tests/Component/Icon/TestIconPng.php
@@ -1,14 +1,14 @@
justReturn( dirname( __DIR__, 3 ) . '/' );
$obj = new IconPng();
diff --git a/tests/Component/Icon/test-iconsvg.php b/tests/Component/Icon/TestIconSvg.php
similarity index 73%
rename from tests/Component/Icon/test-iconsvg.php
rename to tests/Component/Icon/TestIconSvg.php
index 79267f14..c2fa27f9 100644
--- a/tests/Component/Icon/test-iconsvg.php
+++ b/tests/Component/Icon/TestIconSvg.php
@@ -1,14 +1,15 @@
justReturn( dirname( __DIR__, 3 ) . '/' );
$obj = new IconSvg();
diff --git a/tests/Map/TestHrefLang.php b/tests/Map/TestHrefLang.php
new file mode 100644
index 00000000..ba0a7586
--- /dev/null
+++ b/tests/Map/TestHrefLang.php
@@ -0,0 +1,61 @@
+ 'de',
+ 'de_DE_formal' => 'de',
+ 'fr_FR' => 'fr',
+ 'es_ES' => 'es',
+ 'cat' => 'cat',
+ 'en_US' => 'en',
+ 'en_GB' => 'en',
+ ];
+
+ foreach ( $map as $locale => $alpha2 ) {
+ $blog = \Mockery::mock( MslsBlog::class );
+ $blog->shouldReceive( [
+ 'get_alpha2' => $alpha2,
+ 'get_language' => $locale,
+ ] );
+
+ $blogs[] = $blog;
+ }
+
+ $collection = \Mockery::mock( MslsBlogCollection::class );
+ $collection->shouldReceive( 'get_objects' )->andReturn( $blogs );
+
+ $this->test = new HrefLang( $collection );
+ }
+
+ public function test_get(): void {
+ $this->assertEquals( 'de-DE', $this->test->get( 'de_DE' ) );
+ $this->assertEquals( 'de-DE', $this->test->get( 'de_DE_formal' ) );
+ $this->assertEquals( 'fr', $this->test->get( 'fr_FR' ) );
+ $this->assertEquals( 'es', $this->test->get( 'es_ES' ) );
+ $this->assertEquals( 'cat', $this->test->get( 'cat' ) );
+ $this->assertEquals( 'en-GB', $this->test->get( 'en_GB' ) );
+ $this->assertEquals( 'en-US', $this->test->get( 'en_US' ) );
+ }
+
+ public function test_get_has_filter(): void {
+ Functions\when( 'has_filter' )->justReturn( true );
+ Filters\expectApplied( 'msls_head_hreflang' )->once()->with( 'en_US' )->andReturn( 'en-US' );
+
+ $this->assertEquals( 'en-US', $this->test->get( 'en_US' ) );
+ }
+
+}
diff --git a/tests/Map/test-hreflang.php b/tests/Map/test-hreflang.php
deleted file mode 100644
index b9026bdf..00000000
--- a/tests/Map/test-hreflang.php
+++ /dev/null
@@ -1,62 +0,0 @@
- 'de',
- 'de_DE_formal' => 'de',
- 'fr_FR' => 'fr',
- 'es_ES' => 'es',
- 'cat' => 'cat',
- 'en_US' => 'en',
- 'en_GB' => 'en',
- ];
-
- foreach ( $map as $locale => $alpha2 ) {
- $blog = \Mockery::mock( MslsBlog::class );
- $blog->shouldReceive( [
- 'get_alpha2' => $alpha2,
- 'get_language' => $locale,
- ] );
-
- $blogs[] = $blog;
- }
-
- $collection = \Mockery::mock( MslsBlogCollection::class );
- $collection->shouldReceive( 'get_objects' )->andReturn( $blogs );
-
- return new HrefLang( $collection );
- }
-
- public function test_get() {
- $obj = $this->get_sut();
-
- $this->assertEquals( 'de-DE', $obj->get( 'de_DE' ) );
- $this->assertEquals( 'de-DE', $obj->get( 'de_DE_formal' ) );
- $this->assertEquals( 'fr', $obj->get( 'fr_FR' ) );
- $this->assertEquals( 'es', $obj->get( 'es_ES' ) );
- $this->assertEquals( 'cat', $obj->get( 'cat' ) );
- $this->assertEquals( 'en-GB', $obj->get( 'en_GB' ) );
- $this->assertEquals( 'en-US', $obj->get( 'en_US' ) );
- }
-
- public function test_get_has_filter() {
- $obj = $this->get_sut();
-
- Functions\when( 'has_filter' )->justReturn( true );
- Filters\expectApplied('msls_head_hreflang')->once()->with( 'en_US')->andReturn( 'en-US' );
-
- $this->assertEquals( 'en-US', $obj->get( 'en_US' ) );
- }
-
-}
diff --git a/tests/bootstrap.php b/tests/MslsUnitTestCase.php
similarity index 93%
rename from tests/bootstrap.php
rename to tests/MslsUnitTestCase.php
index 0d54b4de..761d456b 100644
--- a/tests/bootstrap.php
+++ b/tests/MslsUnitTestCase.php
@@ -6,7 +6,7 @@
use Brain\Monkey;
use Brain\Monkey\Functions;
-class Msls_UnitTestCase extends TestCase {
+class MslsUnitTestCase extends TestCase {
/**
* Instance of the class to test
diff --git a/tests/test-mslsadmin.php b/tests/TestMslsAdmin.php
similarity index 57%
rename from tests/test-mslsadmin.php
rename to tests/TestMslsAdmin.php
index ee40cd27..83d774bb 100644
--- a/tests/test-mslsadmin.php
+++ b/tests/TestMslsAdmin.php
@@ -9,9 +9,9 @@
use lloc\Msls\MslsOptions;
use lloc\Msls\MslsBlogCollection;
-class WP_Test_MslsAdmin extends Msls_UnitTestCase {
+class TestMslsAdmin extends MslsUnitTestCase {
- public function get_sut( $users = [] ) {
+ public function get_sut( array $users = [] ): MslsAdmin {
Functions\when( 'get_option' )->justReturn( [] );
Functions\when( 'update_option' )->justReturn( true );
Functions\when( 'get_current_blog_id' )->justReturn( 1 );
@@ -57,7 +57,7 @@ public function get_sut( $users = [] ) {
return new MslsAdmin( $options, $collection );
}
- function test_has_problems_no_problem() {
+ public function test_has_problems_no_problem(): void {
$options = \Mockery::mock( MslsOptions::class );
$options->shouldReceive( 'get_available_languages' )->andReturns( [ 'de_DE', 'it_IT' ] );
@@ -69,7 +69,7 @@ function test_has_problems_no_problem() {
$this->assertFalse( $obj->has_problems() );
}
- function test_has_problems_one_language() {
+ public function test_has_problems_one_language(): void {
$options = \Mockery::mock( MslsOptions::class );
$options->shouldReceive( 'get_available_languages' )->andReturns( [ 'de_DE', ] );
@@ -83,7 +83,7 @@ function test_has_problems_one_language() {
$this->assertTrue( $obj->has_problems() );
}
- function test_has_problems_is_empty() {
+ public function test_has_problems_is_empty(): void {
Functions\when( 'get_option' )->justReturn( [] );
Functions\when( 'get_current_blog_id' )->justReturn( 1 );
Functions\when( 'admin_url' )->justReturn( '' );
@@ -100,41 +100,48 @@ function test_has_problems_is_empty() {
$this->assertTrue( $obj->has_problems() );
}
- public function test_subsubsub() {
+ public function test_subsubsub(): void {
$obj = $this->get_sut();
- $this->assertEquals( '