diff --git a/includes/MslsAdminIcon.php b/includes/MslsAdminIcon.php index bfec183a..be11fc7a 100644 --- a/includes/MslsAdminIcon.php +++ b/includes/MslsAdminIcon.php @@ -15,6 +15,7 @@ * @package Msls */ class MslsAdminIcon { + /** * IconType * @var string @@ -69,6 +70,10 @@ class MslsAdminIcon { */ protected $id; + const TYPE_FLAG = 'flag'; + + const TYPE_LABEL = 'label'; + /** * Constructor * @@ -228,7 +233,7 @@ public function get_a(): string { */ public function get_icon(): string { if ( 'flag' === $this->iconType ) { - return ! is_string( $this->language ) ? '' : sprintf( '%s', + return sprintf( '%s', ( new IconSvg() )->get( $this->language ), $this->language ); diff --git a/includes/MslsCustomColumn.php b/includes/MslsCustomColumn.php index 6bfbc545..a4d92d7d 100644 --- a/includes/MslsCustomColumn.php +++ b/includes/MslsCustomColumn.php @@ -47,7 +47,7 @@ public static function init() { public function th( $columns ) { $blogs = $this->collection->get(); if ( $blogs ) { - $html; + $html = ''; foreach ( $blogs as $blog ) { $language = $blog->get_language(); diff --git a/includes/MslsMetaBox.php b/includes/MslsMetaBox.php index 9dcd7da7..fdba68c7 100644 --- a/includes/MslsMetaBox.php +++ b/includes/MslsMetaBox.php @@ -183,13 +183,8 @@ public function render_select() { switch_to_blog( $blog->userblog_id ); $language = $blog->get_language(); - $icon = MslsAdminIcon::create()->set_language( $language ); - - if ( $this->options->admin_display === 'label' ) { - $icon->set_icon_type( 'label' ); - } else { - $icon->set_icon_type( 'flag' ); - } + $iconType = MslsAdminIcon::TYPE_FLAG === $this->options->admin_display ? MslsAdminIcon::TYPE_FLAG : MslsAdminIcon::TYPE_LABEL; + $icon = MslsAdminIcon::create()->set_language( $language )->set_icon_type( $iconType ); if ( $mydata->has_value( $language ) ) { $icon->set_href( $mydata->$language ); diff --git a/includes/MslsOptions.php b/includes/MslsOptions.php index 140929f9..0abff15c 100644 --- a/includes/MslsOptions.php +++ b/includes/MslsOptions.php @@ -14,6 +14,7 @@ * @package Msls * @property bool $activate_autocomplete * @property int $display + * @property string $admin_display * @property int $reference_user * @property int $content_priority * @property string $admin_language diff --git a/tests/test-mslsadmin.php b/tests/test-mslsadmin.php index 21203e6b..47ec188c 100644 --- a/tests/test-mslsadmin.php +++ b/tests/test-mslsadmin.php @@ -309,7 +309,7 @@ function test_main_section() { Functions\when( 'add_settings_field' )->returnArg(); - $this->assertEquals( 11, $obj->main_section() ); + $this->assertEquals( 12, $obj->main_section() ); } function test_advanced_section() { diff --git a/tests/test-mslsblog.php b/tests/test-mslsblog.php index 2efc333d..75fa0840 100644 --- a/tests/test-mslsblog.php +++ b/tests/test-mslsblog.php @@ -12,6 +12,7 @@ class WP_Test_MslsBlog extends Msls_UnitTestCase { */ function test___get_method() { Functions\expect( 'get_blog_option' )->once()->andReturn( 'it_IT' ); + $blog = new \stdClass(); $blog->userblog_id = 1; $blog->blogname = 'Test'; diff --git a/tests/test-mslscustomcolumn.php b/tests/test-mslscustomcolumn.php index a1721841..8aaf9da8 100644 --- a/tests/test-mslscustomcolumn.php +++ b/tests/test-mslscustomcolumn.php @@ -16,7 +16,7 @@ function test_th() { $options = \Mockery::mock( MslsOptions::class ); $obj = new MslsCustomColumn( $options, $this->getBlogsCollection() ); - $expected = [ 'mslscol' => 'de_DE en_US' ]; + $expected = [ 'mslscol' => 'de_DEen_US' ]; $this->assertEquals( $expected, $obj->th( [] ) ); }