Skip to content

Commit 97005f9

Browse files
committed
New API function msls_options()
1 parent 1af2415 commit 97005f9

16 files changed

Lines changed: 74 additions & 67 deletions

MultisiteLanguageSwitcher.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3131
*/
3232

33-
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
33+
if ( file_exists(__DIR__ . '/vendor/autoload.php' ) ) {
3434
require __DIR__ . '/vendor/autoload.php';
3535
}
3636

@@ -128,8 +128,8 @@ function get_msls_permalink( string $locale, string $default = '' ): string {
128128
}
129129

130130
/**
131-
* Gets a blog by locale
132-
*
131+
* Looks for the MslsBlog instance for a specific locale
132+
*
133133
* @param string $locale
134134
*
135135
* @return \lloc\Msls\MslsBlog|null
@@ -147,4 +147,12 @@ function msls_blog_collection(): \lloc\Msls\MslsBlogCollection {
147147
return \lloc\Msls\MslsBlogCollection::instance();
148148
}
149149

150+
/**
151+
* Gets the MslsOptions instance
152+
*
153+
* @return \lloc\Msls\MslsOptions
154+
*/
155+
function msls_options(): \lloc\Msls\MslsOptions {
156+
return \lloc\Msls\MslsOptions::instance();
157+
}
150158
}

includes/ContentImport/Service.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Service extends MslsRegistryInstance {
2121
* @return bool Whether the content import functionality support classes where hooked or not.
2222
*/
2323
public function register() {
24-
if ( ! MslsOptions::instance()->activate_content_import ) {
24+
if ( ! msls_options()->activate_content_import ) {
2525
return false;
2626
}
2727

includes/MslsAdmin.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ class MslsAdmin extends MslsMain {
3737
*/
3838
public static function init() {
3939
if ( ! ( $obj = MslsRegistry::get_object( __CLASS__ ) ) ) {
40-
$options = MslsOptions::instance();
4140
$collection = msls_blog_collection();
4241

43-
$obj = new static( $options, $collection );
42+
$obj = new static( msls_options(), $collection );
4443

4544
MslsRegistry::set_object( __CLASS__, $obj );
4645

includes/MslsBlogCollection.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace lloc\Msls;
99

10-
use const Patchwork\CodeManipulation\Actions\RedefinitionOfNew\publicizeConstructors;
11-
1210
/**
1311
* Collection of blog-objects
1412
*
@@ -62,7 +60,7 @@ public function __construct() {
6260

6361
$this->current_blog_id = get_current_blog_id();
6462

65-
$options = MslsOptions::instance();
63+
$options = msls_options();
6664

6765
$this->current_blog_output = isset( $options->output_current_blog );
6866
$this->objects_order = $options->get_order();

includes/MslsCustomColumn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MslsCustomColumn extends MslsMain {
2222
* @return MslsCustomColumn
2323
*/
2424
public static function init() {
25-
$options = MslsOptions::instance();
25+
$options = msls_options();
2626
$collection = msls_blog_collection();
2727
$obj = new static( $options, $collection );
2828

includes/MslsCustomColumnTaxonomy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MslsCustomColumnTaxonomy extends MslsCustomColumn {
2222
* @return MslsCustomColumnTaxonomy
2323
*/
2424
public static function init() {
25-
$options = MslsOptions::instance();
25+
$options = msls_options();
2626
$collection = msls_blog_collection();
2727
$obj = new static( $options, $collection );
2828

includes/MslsCustomFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MslsCustomFilter extends MslsMain {
2222
* @return MslsCustomFilter
2323
*/
2424
public static function init() {
25-
$options = MslsOptions::instance();
25+
$options = msls_options();
2626
$collection = msls_blog_collection();
2727
$obj = new static( $options, $collection );
2828

includes/MslsMain.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ public function __construct( MslsOptions $options, MslsBlogCollection $collectio
4747
* @return static
4848
*/
4949
public static function init() {
50-
$options = MslsOptions::instance();
51-
$collection = msls_blog_collection();
52-
53-
return new static( $options, $collection );
50+
return new static( msls_options(), msls_blog_collection() );
5451
}
5552

5653
/**

includes/MslsMetaBox.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?php
1+
<?php declare( strict_types=1 );
2+
23
/**
34
* MslsMetaBox
45
* @author Dennis Ploetner <re@lloc.de>
@@ -82,7 +83,6 @@ public static function get_suggested_fields( $json, $args ) {
8283
*
8384
*/
8485
$my_query->post = apply_filters( 'msls_meta_box_suggest_post', $my_query->post );
85-
8686
if ( is_object( $my_query->post ) ) {
8787
$json->add( get_the_ID(), get_the_title() );
8888
}
@@ -102,9 +102,8 @@ public static function get_suggested_fields( $json, $args ) {
102102
* @return MslsMetaBox
103103
*/
104104
public static function init() {
105-
$options = MslsOptions::instance();
106-
$collection = msls_blog_collection();
107-
$obj = new static( $options, $collection );
105+
$options = msls_options();
106+
$obj = new static( $options, msls_blog_collection() );
108107

109108
if ( ! $options->is_excluded() ) {
110109
add_action( 'add_meta_boxes', [ $obj, 'add' ] );
@@ -129,7 +128,7 @@ public function add() {
129128
[
130129
$this,
131130
(
132-
MslsOptions::instance()->activate_autocomplete ?
131+
msls_options()->activate_autocomplete ?
133132
'render_input' :
134133
'render_select'
135134
),
@@ -139,7 +138,7 @@ public function add() {
139138
'high'
140139
);
141140

142-
if ( MslsOptions::instance()->activate_content_import ) {
141+
if ( msls_options()->activate_content_import ) {
143142
add_meta_box(
144143
'msls-content-import',
145144
apply_filters(
@@ -252,7 +251,7 @@ public function render_select() {
252251
*
253252
* @return string
254253
*/
255-
public function render_options( $type, $msls_id ) {
254+
public function render_options( $type, $msls_id ): string {
256255
$options = [];
257256

258257
$my_query = new \WP_Query( [

includes/MslsOptions.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,26 @@ public static function create( $id = 0 ) {
105105
}
106106

107107
/**
108-
* Checks if the current page is a home, front or 404 page
109-
* @return boolean
108+
* Determines if the current page is the main page (front page, search, 404).
109+
*
110+
* @return boolean
110111
*/
111112
public static function is_main_page() {
112113
return is_front_page() || is_search() || is_404();
113114
}
114115

115116
/**
116-
* Checks if the current page is a category, tag or any other tax archive
117+
* Determines if the current page is a category, tag or taxonomy page.
118+
*
117119
* @return boolean
118120
*/
119121
public static function is_tax_page() {
120122
return is_category() || is_tag() || is_tax();
121123
}
122124

123125
/**
124-
* Checks if the current page is a date, author any other post_type archive
126+
* Determines if the current page is an archive page for a date, author, or any other post type.
127+
*
125128
* @return boolean
126129
*/
127130
public static function is_query_page() {
@@ -139,8 +142,8 @@ public function __construct() {
139142

140143
/**
141144
* Gets an element of arg by index
142-
* The returning value is casted to the type of $retval or will be the
143-
* value of $retval if nothing is set at this index.
145+
*
146+
* The returned value will either be cast to the type of `$retval` or, if nothing is set at this index, it will be the value of `$retval`.
144147
*
145148
* @param int $idx
146149
* @param mixed $val

0 commit comments

Comments
 (0)