Skip to content

Commit d28443b

Browse files
committed
Added Types
1 parent 8c09b8b commit d28443b

File tree

5 files changed

+42
-43
lines changed

5 files changed

+42
-43
lines changed

includes/MslsAdmin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function __call( $method, $args ) {
133133
*
134134
* @return bool
135135
*/
136-
public function has_problems() {
136+
public function has_problems(): bool {
137137
$message = '';
138138

139139
if ( $this->options->is_empty() ) {
@@ -161,7 +161,7 @@ public function has_problems() {
161161
/**
162162
* Render the options-page
163163
*/
164-
public function render() {
164+
public function render(): void {
165165
printf(
166166
'<div class="wrap"><div class="icon32" id="icon-options-general"><br/></div><h1>%s</h1>%s<br class="clear"/><form action="options.php" method="post"><p>%s</p>',
167167
__( 'Multisite Language Switcher Options', 'multisite-language-switcher' ),

includes/MslsBlog.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare( strict_types=1 );
22

33
namespace lloc\Msls;
44

@@ -12,27 +12,30 @@ class MslsBlog {
1212

1313
/**
1414
* WordPress generates such an object
15+
*
1516
* @var \StdClass
1617
*/
1718
private $obj;
1819

1920
/**
20-
* Language-code eg. de_DE
21+
* Language-code e.g. "de_DE", or "en_US", or "it_IT"
22+
*
2123
* @var string
2224
*/
23-
private $language;
25+
private string $language;
2426

2527
/**
26-
* Description eg. Deutsch
28+
* Description e.g. "Deutsch", or "English", or "Italiano"
29+
*
2730
* @var string
2831
*/
29-
private $description;
32+
private string $description;
3033

3134
/**
3235
* Constructor
3336
*
3437
* @param ?\StdClass $obj
35-
* @param string $description
38+
* @param string $description
3639
*/
3740
public function __construct( $obj, $description ) {
3841
if ( is_object( $obj ) ) {
@@ -60,6 +63,7 @@ final public function __get( $key ) {
6063
* Gets the description stored in this object
6164
*
6265
* The method returns the stored language if the description is empty.
66+
*
6367
* @return string
6468
*/
6569
public function get_description(): string {
@@ -76,9 +80,11 @@ public function get_description(): string {
7680
public function get_title( string $icon_type = 'flag' ): string {
7781
$icon = ( new MslsAdminIcon( null ) )->set_language( $this->language )->set_icon_type( $icon_type );
7882

79-
return sprintf( '%1$s %2$s',
83+
return sprintf(
84+
'%1$s %2$s',
8085
$this->obj->blogname,
81-
'<span class="msls-icon-wrapper flag">' . $icon->get_icon() . '</span>' );
86+
'<span class="msls-icon-wrapper flag">' . $icon->get_icon() . '</span>'
87+
);
8288
}
8389

8490
/**
@@ -128,8 +134,10 @@ protected function get_permalink( $options ) {
128134

129135
switch_to_blog( $this->obj->userblog_id );
130136

131-
if ( is_object( $options ) && method_exists( $options,
132-
'has_value' ) && ( $is_home || $options->has_value( $this->get_language() ) ) ) {
137+
if ( is_object( $options ) && method_exists(
138+
$options,
139+
'has_value'
140+
) && ( $is_home || $options->has_value( $this->get_language() ) ) ) {
133141
$url = apply_filters( 'mlsl_blog_get_permalink', $options->get_permalink( $this->get_language() ), $this );
134142
}
135143

@@ -200,5 +208,4 @@ public function get_blavatar(): string {
200208

201209
return $blavatar_html;
202210
}
203-
204211
}

includes/MslsBlogCollection.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
<?php
2-
/**
3-
* MslsBlogCollection
4-
*
5-
* @author Dennis Ploetner <[email protected]>
6-
* @since 0.9.8
7-
*/
1+
<?php declare( strict_types=1 );
82

93
namespace lloc\Msls;
104

includes/MslsOptionsPost.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
<?php
2-
/**
3-
* MslsOptionsPost
4-
* @author Dennis Ploetner <[email protected]>
5-
* @since 0.9.8
6-
*/
72

83
namespace lloc\Msls;
94

105
/**
116
* Post options
7+
*
128
* @package Msls
139
*/
1410
class MslsOptionsPost extends MslsOptions {
1511

1612
/**
1713
* Separator
14+
*
1815
* @var string
1916
*/
2017
protected $sep = '_';
2118

2219
/**
2320
* Autoload
21+
*
2422
* @var string
2523
*/
2624
protected $autoload = 'no';
@@ -51,7 +49,7 @@ public function get_postlink( $language ) {
5149
$blog_id = msls_blog_collection()->get_blog_id( $language );
5250
if ( $current_site->blog_id != $blog_id ) {
5351
$option = get_blog_option( $blog_id, 'msls' );
54-
//error_log( print_r( $option, true ) );
52+
// error_log( print_r( $option, true ) );
5553
}
5654

5755
return apply_filters( 'check_url', get_permalink( $post ), $this );
@@ -65,5 +63,4 @@ public function get_postlink( $language ) {
6563
public function get_current_link(): string {
6664
return (string) get_permalink( $this->get_arg( 0, 0 ) );
6765
}
68-
6966
}

includes/MslsPostTag.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<?php
1+
<?php declare( strict_types=1 );
2+
23
/**
34
* MslsPostTag
45
*
56
* @author Dennis Ploetner <[email protected]>
6-
* @since 0.9.8
77
*/
88

99
namespace lloc\Msls;
@@ -29,12 +29,12 @@ public static function suggest() {
2929
filter_input( INPUT_POST, 'blog_id', FILTER_SANITIZE_NUMBER_INT )
3030
);
3131

32-
$args = [
32+
$args = array(
3333
'orderby' => 'name',
3434
'order' => 'ASC',
3535
'number' => 10,
3636
'hide_empty' => 0,
37-
];
37+
);
3838

3939
if ( filter_has_var( INPUT_POST, 's' ) ) {
4040
$args['search'] = sanitize_text_field(
@@ -81,15 +81,15 @@ public static function suggest() {
8181
public static function init() {
8282
$options = msls_options();
8383
$collection = msls_blog_collection();
84-
$class = $options->activate_autocomplete ? MslsPostTag::class : MslsPostTagClassic::class;
84+
$class = $options->activate_autocomplete ? self::class : MslsPostTagClassic::class;
8585
$obj = new $class( $options, $collection );
8686

8787
$taxonomy = MslsContentTypes::create()->acl_request();
8888
if ( '' != $taxonomy ) {
89-
add_action( "{$taxonomy}_add_form_fields", [ $obj, 'add_input' ] );
90-
add_action( "{$taxonomy}_edit_form_fields", [ $obj, 'edit_input' ], 10, 2 );
91-
add_action( "edited_{$taxonomy}", [ $obj, 'set' ] );
92-
add_action( "create_{$taxonomy}", [ $obj, 'set' ] );
89+
add_action( "{$taxonomy}_add_form_fields", array( $obj, 'add_input' ) );
90+
add_action( "{$taxonomy}_edit_form_fields", array( $obj, 'edit_input' ), 10, 2 );
91+
add_action( "edited_{$taxonomy}", array( $obj, 'set' ) );
92+
add_action( "create_{$taxonomy}", array( $obj, 'set' ) );
9393
}
9494

9595
return $obj;
@@ -118,7 +118,7 @@ public function add_input( string $taxonomy ): void {
118118
* Add the input fields to the edit-screen of the taxonomies
119119
*
120120
* @param \WP_Term $tag
121-
* @param string $taxonomy
121+
* @param string $taxonomy
122122
*/
123123
public function edit_input( \WP_Term $tag, string $taxonomy ): void {
124124
$title_format = '<tr>
@@ -148,8 +148,8 @@ public function edit_input( \WP_Term $tag, string $taxonomy ): void {
148148
* Returns true if the blogcollection is not empty
149149
*
150150
* @param ?\WP_Term $tag
151-
* @param string $title_format
152-
* @param string $item_format
151+
* @param string $title_format
152+
* @param string $item_format
153153
*
154154
* @return boolean
155155
*/
@@ -160,7 +160,7 @@ public function the_input( ?\WP_Term $tag, string $title_format, string $item_fo
160160
return false;
161161
}
162162

163-
$count ++;
163+
++$count;
164164

165165
$blogs = $this->collection->get();
166166
if ( $blogs ) {
@@ -258,8 +258,9 @@ public function maybe_set_linked_term( MslsOptionsTax $mydata ) {
258258
* @return string
259259
*/
260260
protected function get_select_title(): string {
261-
return apply_filters( 'msls_term_select_title',
262-
__( 'Multisite Language Switcher', 'multisite-language-switcher' ) );
261+
return apply_filters(
262+
'msls_term_select_title',
263+
__( 'Multisite Language Switcher', 'multisite-language-switcher' )
264+
);
263265
}
264-
265266
}

0 commit comments

Comments
 (0)