Skip to content

Commit 8aee872

Browse files
authored
Merge pull request #372 from lloc/raise-coverage
Raise coverage
2 parents 7744cae + ef65f15 commit 8aee872

File tree

14 files changed

+132
-41
lines changed

14 files changed

+132
-41
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.9.2
2+
3+
14
## 2.9.1
25

36
- Suggest Field in Post Editor Metabox: This feature allows you to input either numeric or alphanumeric values. If you enter a number, it’s treated as a Post ID. If you enter text, the field will suggest posts with matching titles.

MultisiteLanguageSwitcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @wordpress-plugin
88
*
99
* Plugin Name: Multisite Language Switcher
10-
* Version: 2.9.1
10+
* Version: 2.9.2
1111
* Plugin URI: http://msls.co/
1212
* Description: A simple but powerful plugin that will help you to manage the relations of your contents in a multilingual multisite-installation.
1313
* Author: Dennis Ploetner
@@ -40,7 +40,7 @@
4040
* @author Dennis Ploetner <re@lloc.de>
4141
*/
4242
if ( ! defined( 'MSLS_PLUGIN_VERSION' ) ) {
43-
define( 'MSLS_PLUGIN_VERSION', '2.9.1' );
43+
define( 'MSLS_PLUGIN_VERSION', '2.9.2' );
4444
define( 'MSLS_PLUGIN_PATH', plugin_basename( __FILE__ ) );
4545
define( 'MSLS_PLUGIN__FILE__', __FILE__ );
4646

includes/ContentImport/AttachmentPathFinder.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ class AttachmentPathFinder extends MslsRegistryInstance {
88

99
const LINKED = '_msls_linked';
1010

11-
public function filter_srcset( array $sources, $sizeArray, $imageSrc, $imageMeta, $attachmentId ) {
11+
/**
12+
* @param array $sources
13+
* @param mixed $sizeArray
14+
* @param string $imageSrc
15+
* @param mixed $imageMeta
16+
* @param int $attachmentId
17+
* @return array
18+
*/
19+
public function filter_srcset( array $sources, $sizeArray, $imageSrc, $imageMeta, $attachmentId ): array {
1220
if ( ! $msls_imported = $this->has_import_data( $attachmentId ) ) {
1321
return $sources;
1422
}
@@ -32,6 +40,10 @@ public function filter_srcset( array $sources, $sizeArray, $imageSrc, $imageMeta
3240
return $sources;
3341
}
3442

43+
/**
44+
* @param int $attachment_id
45+
* @return array|false
46+
*/
3547
protected function has_import_data( $attachment_id ) {
3648
if ( empty( $attachment_id ) ) {
3749
return false;
@@ -53,6 +65,11 @@ protected function has_import_data( $attachment_id ) {
5365
return $msls_imported;
5466
}
5567

68+
/**
69+
* @param string $url
70+
* @param int $attachment_id
71+
* @return string
72+
*/
5673
public function filter_attachment_url( $url, $attachment_id ) {
5774
if ( ! $msls_imported = $this->has_import_data( $attachment_id ) ) {
5875
return $url;
@@ -68,7 +85,7 @@ public function filter_attachment_url( $url, $attachment_id ) {
6885
}
6986

7087
/**
71-
* @param int $attachment_id
88+
* @param int $attachment_id
7289
* @param array $msls_imported
7390
*
7491
* @return \WP_Post|false
@@ -84,4 +101,4 @@ protected function get_source_post( $attachment_id, $msls_imported ) {
84101

85102
return $source_post;
86103
}
87-
}
104+
}

includes/ContentImport/ContentImporter.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function get_logger() {
6363
/**
6464
* @param \lloc\Msls\ContentImport\ImportLogger $logger
6565
*/
66-
public function set_logger( $logger ) {
66+
public function set_logger( $logger ): void {
6767
$this->logger = $logger;
6868
}
6969

@@ -77,7 +77,7 @@ public function get_relations() {
7777
/**
7878
* @param \lloc\Msls\ContentImport\Relations $relations
7979
*/
80-
public function set_relations( $relations ) {
80+
public function set_relations( $relations ): void {
8181
$this->relations = $relations;
8282
}
8383

@@ -179,6 +179,11 @@ public function parse_sources() {
179179
return array_map( 'intval', $import_data );
180180
}
181181

182+
/**
183+
* @param int $blog_id
184+
*
185+
* @return int
186+
*/
182187
protected function get_the_blog_post_ID( $blog_id ) {
183188
switch_to_blog( $blog_id );
184189

@@ -331,9 +336,9 @@ public function import_content( ImportCoordinates $import_coordinates, array $po
331336
}
332337

333338
/**
334-
* @param array $data
339+
* @param int $blog_id
335340
* @param int $post_id
336-
*
341+
* @param array $data
337342
* @return array
338343
*/
339344
protected function update_inserted_blog_post_data( $blog_id, $post_id, array $data ) {
@@ -346,6 +351,11 @@ protected function update_inserted_blog_post_data( $blog_id, $post_id, array $da
346351
return $data;
347352
}
348353

354+
/**
355+
* @param int $dest_blog_id
356+
* @param int $post_id
357+
* @return void
358+
*/
349359
protected function redirect_to_blog_post( $dest_blog_id, $post_id ) {
350360
switch_to_blog( $dest_blog_id );
351361
$edit_post_link = html_entity_decode( get_edit_post_link( $post_id ) );

includes/ContentImport/ImportCoordinates.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ImportCoordinates {
4444
* @var array An array keeping track of which importer (slug) should be used for
4545
* a specific import type, shape [ <import-type> => <slug> ]
4646
*/
47-
public $importers = [];
47+
public $importers = array();
4848

4949
/**
5050
* Validates the coordinates.
@@ -88,11 +88,11 @@ public function get_importer_for( $importer_type ) {
8888
/**
8989
* Parses the importers from request superglobals.
9090
*/
91-
public function parse_importers_from_request() {
91+
public function parse_importers_from_request(): void {
9292
// bitmask
9393
$source = isset( $_REQUEST[ self::IMPORTERS_GLOBAL_KEY ] ) * 100
94-
+ isset( $_POST[ self::IMPORTERS_GLOBAL_KEY ] ) * 10
95-
+ isset( $_GET[ self::IMPORTERS_GLOBAL_KEY ] );
94+
+ isset( $_POST[ self::IMPORTERS_GLOBAL_KEY ] ) * 10
95+
+ isset( $_GET[ self::IMPORTERS_GLOBAL_KEY ] );
9696

9797
switch ( $source ) {
9898
case 100:
@@ -114,7 +114,7 @@ public function parse_importers_from_request() {
114114

115115
$importers = isset( $source[ self::IMPORTERS_GLOBAL_KEY ] ) && is_array( $source[ self::IMPORTERS_GLOBAL_KEY ] )
116116
? $source[ self::IMPORTERS_GLOBAL_KEY ]
117-
: [];
117+
: array();
118118

119119
foreach ( $importers as $importer_type => $slug ) {
120120
$this->set_importer_for( $importer_type, $slug );
@@ -127,7 +127,7 @@ public function parse_importers_from_request() {
127127
* @param string $importer_type
128128
* @param string $slug
129129
*/
130-
public function set_importer_for( $importer_type, $slug ) {
130+
public function set_importer_for( $importer_type, $slug ): void {
131131
$this->importers[ $importer_type ] = $slug;
132132
}
133133
}

includes/ContentImport/ImportLogger.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,16 @@ public function get_data(): array {
5151
* Saves the log or prints it some place.
5252
*/
5353
public function save(): void {
54-
$log_writer = $default_log_writer = AdminNoticeLogger::instance();
55-
$log_writer->set_import_coordinates( $this->import_coordinates );
54+
$default_log_writer = AdminNoticeLogger::instance();
55+
$default_log_writer->set_import_coordinates( $this->import_coordinates );
5656

5757
/**
5858
* Filters the log class or object that should be used to write the log to the destination.
5959
*
60-
* @param LogWriter $log_writer
60+
* @param mixed $default_log_writer
6161
* @param ImportCoordinates $import_coordinates
6262
*/
63-
$log_writer = apply_filters( 'msls_content_import_log_writer', $log_writer, $this->import_coordinates );
64-
63+
$log_writer = apply_filters( 'msls_content_import_log_writer', $default_log_writer, $this->import_coordinates );
6564
if ( empty( $log_writer ) ) {
6665
// we assume that was done on purpose to prevent logging
6766
return;
@@ -106,6 +105,12 @@ protected function log( $where, $what, $root = 'info' ): void {
106105
$this->data[ $root ] = array_merge_recursive( $this->data[ $root ], $data );
107106
}
108107

108+
/**
109+
* @param array $path
110+
* @param mixed $what
111+
*
112+
* @return array
113+
*/
109114
protected function build_nested_array( $path, $what = '' ): array {
110115
$json = '{"'
111116
. implode( '":{"', $path )
@@ -124,11 +129,11 @@ protected function build_nested_array( $path, $what = '' ): array {
124129
}
125130

126131
/**
127-
* @param $where
132+
* @param string $where
128133
*
129134
* @return array
130135
*/
131-
protected function build_path( $where ): array {
136+
protected function build_path( string $where ): array {
132137
$where_path = explode( $this->levels_delimiter, $where );
133138

134139
return $where_path;
@@ -165,6 +170,7 @@ public function log_success( $where, $what ): void {
165170
/**
166171
* Logs some generic information.
167172
*
173+
* @param string $key
168174
* @param string $message
169175
*/
170176
public function log_information( $key, $message ): void {

includes/ContentImport/Importers/ImportersBaseFactory.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function make( ImportCoordinates $import_coordinates ) {
3434
*
3535
* Returning an Importer instance here will force the class to return that.
3636
*
37-
* @param $importer Importer
37+
* @param ?Importer $importer
3838
* @param ImportCoordinates $import_coordinates
3939
*/
4040
$importer = apply_filters( "msls_content_import_{$type}_importer", null, $import_coordinates );
@@ -81,21 +81,25 @@ public function details() {
8181
* @return string
8282
*/
8383
public function selected() {
84-
$selected = array_keys( $this->importers_map )[0];
8584
$slug = static::TYPE;
85+
$selected = array_keys( $this->importers_map )[0];
86+
$instance = $this;
8687

8788
/**
8889
* Filters the selected importer that among the available ones.
8990
*
9091
* @param string $selected The selected importer slug.
91-
* @param ImportersFactory $this
92+
* @param ImportersFactory $instance
9293
*/
93-
$selected = apply_filters( "msls_content_import_{$slug}_selected", $selected, $this );
94+
$selected = apply_filters( "msls_content_import_{$slug}_selected", $selected, $instance );
9495

9596
return $selected;
9697
}
9798

98-
protected function importers_info() {
99+
/**
100+
* @return array<string, \stdClass>
101+
*/
102+
protected function importers_info(): array {
99103
return array_combine(
100104
array_keys( $this->importers_map ),
101105
array_map(

includes/ContentImport/Importers/PostFields/Duplicating.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace lloc\Msls\ContentImport\Importers\PostFields;
44

5+
use lloc\Msls\ContentImport\ImportCoordinates;
56
use lloc\Msls\ContentImport\Importers\BaseImporter;
67
use lloc\Msls\ContentImport\Importers\WithRequestPostAttributes;
78

@@ -23,11 +24,11 @@ class Duplicating extends BaseImporter {
2324
* @return \stdClass
2425
*/
2526
public static function info() {
26-
return (object) [
27+
return (object) array(
2728
'slug' => static::TYPE,
2829
'name' => __( 'Duplicating', 'multisite-language-switcher' ),
29-
'description' => __( 'Copies the source post fields to the destination.', 'multisite-language-switcher' )
30-
];
30+
'description' => __( 'Copies the source post fields to the destination.', 'multisite-language-switcher' ),
31+
);
3132
}
3233

3334
public function import( array $data ) {
@@ -39,11 +40,11 @@ public function import( array $data ) {
3940
foreach ( $this->filter_fields() as $field ) {
4041
$value = $source_post->{$field};
4142
$data[ $field ] = $value;
42-
$this->logger->log_success( 'post-field/added', [ $field => $value ] );
43+
$this->logger->log_success( 'post-field/added', array( $field => $value ) );
4344
}
4445

4546
if ( ! doing_action( 'wp_insert_post_data' ) ) {
46-
$postarr = array_merge( $data, [ 'ID' => $this->import_coordinates->dest_post_id ] );
47+
$postarr = array_merge( $data, array( 'ID' => $this->import_coordinates->dest_post_id ) );
4748
wp_insert_post( $postarr );
4849
}
4950

includes/MslsRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static function get_config( string $name ): array {
2020
public static function has_var( string $name, ?int $input_type = null ): bool {
2121
if ( null === $input_type ) {
2222
try {
23-
list($input_type, ) = self::get_config( $name );
23+
list( $input_type, ) = self::get_config( $name );
2424
} catch ( \InvalidArgumentException $e ) {
2525
return false;
2626
}

js/msls-widget-block/block.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"icon": "translation",
66
"category": "widgets",
77
"name": "lloc/msls-widget-block",
8-
"version": "2.9.1",
8+
"version": "2.9.2",
99
"description": "Review the settings for the Multisite Language Switcher plugin, as the block utilizes the API function `the_msls()` for its output.",
1010
"example": {},
1111
"supports": {

0 commit comments

Comments
 (0)