Skip to content

Commit 583eb0b

Browse files
committed
Restructuring reloaded
1 parent eeff4d7 commit 583eb0b

101 files changed

Lines changed: 941 additions & 759 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

MultisiteLanguageSwitcher.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,23 @@ function msls_get_permalink( string $locale, string $preset = '' ): string {
132132
}
133133

134134
/**
135-
* Looks for the MslsBlog instance for a specific locale
135+
* Looks for the Blog instance for a specific locale
136136
*
137137
* @param string $locale
138138
*
139-
* @return \lloc\Msls\MslsBlog|null
139+
* @return \lloc\Msls\Blog\Blog|null
140140
*/
141-
function msls_blog( string $locale ): ?\lloc\Msls\MslsBlog {
141+
function msls_blog( string $locale ): ?\lloc\Msls\Blog\Blog {
142142
return msls_blog_collection()->get_blog( $locale );
143143
}
144144

145145
/**
146-
* Gets the MslsBlogCollection instance
146+
* Gets the Blog Collection instance
147147
*
148-
* @return \lloc\Msls\MslsBlogCollection
148+
* @return \lloc\Msls\Blog\Collection
149149
*/
150-
function msls_blog_collection(): \lloc\Msls\MslsBlogCollection {
151-
return \lloc\Msls\MslsBlogCollection::instance();
150+
function msls_blog_collection(): \lloc\Msls\Blog\Collection {
151+
return \lloc\Msls\Blog\Collection::instance();
152152
}
153153

154154
/**
@@ -188,12 +188,12 @@ function msls_taxonomy(): \lloc\Msls\ContentTypes\Taxonomy {
188188
}
189189

190190
/**
191-
* Gets the MslsOutput instance
191+
* Gets the Output instance
192192
*
193-
* @return \lloc\Msls\MslsOutput
193+
* @return \lloc\Msls\Frontend\Output
194194
*/
195-
function msls_output(): \lloc\Msls\MslsOutput {
196-
return \lloc\Msls\MslsOutput::create();
195+
function msls_output(): \lloc\Msls\Frontend\Output {
196+
return \lloc\Msls\Frontend\Output::create();
197197
}
198198

199199
/**
@@ -216,9 +216,9 @@ function msls_get_post( int $id ): \lloc\Msls\Options\Post\Post {
216216
* - is_tax
217217
*
218218
* @param int $id
219-
* @return \lloc\Msls\OptionsTaxInterface
219+
* @return \lloc\Msls\Options\Tax\OptionsTaxInterface
220220
*/
221-
function msls_get_tax( int $id ): \lloc\Msls\OptionsTaxInterface {
221+
function msls_get_tax( int $id ): \lloc\Msls\Options\Tax\OptionsTaxInterface {
222222
return \lloc\Msls\Options\Tax\Tax::create( $id );
223223
}
224224

@@ -247,5 +247,5 @@ function msls_return_void(): void {
247247
}
248248

249249
lloc\Msls\MslsPlugin::init();
250-
lloc\Msls\MslsCli::init();
250+
lloc\Msls\Cli\Cli::init();
251251
}
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php declare( strict_types=1 );
22

3-
namespace lloc\Msls;
3+
namespace lloc\Msls\Admin;
44

55
if ( ! defined( 'ABSPATH' ) ) {
66
exit;
@@ -12,6 +12,9 @@
1212
use lloc\Msls\Component\Input\Select;
1313
use lloc\Msls\Component\Input\Text;
1414
use lloc\Msls\Link\Link;
15+
use lloc\Msls\MslsMain;
16+
use lloc\Msls\MslsPlugin;
17+
use lloc\Msls\Registry\Registry;
1518
use WP_Post_Type;
1619

1720
/**
@@ -31,7 +34,7 @@
3134
*
3235
* @package Msls
3336
*/
34-
final class MslsAdmin extends MslsMain {
37+
final class Admin extends MslsMain {
3538

3639
const MSLS_REGISTER_ACTION = 'msls_admin_register';
3740

@@ -48,11 +51,11 @@ final class MslsAdmin extends MslsMain {
4851
* @codeCoverageIgnore
4952
*/
5053
public static function init(): void {
51-
$obj = MslsRegistry::get_object( __CLASS__ );
54+
$obj = Registry::get_object( __CLASS__ );
5255
if ( ! $obj ) {
5356
$obj = new self( msls_options(), msls_blog_collection() );
5457

55-
MslsRegistry::set_object( __CLASS__, $obj );
58+
Registry::set_object( __CLASS__, $obj );
5659

5760
/**
5861
* Override the capabilities needed for the plugin's settings
@@ -386,8 +389,8 @@ public function admin_display(): void {
386389
$select = new Select(
387390
'admin_display',
388391
array(
389-
MslsAdminIcon::TYPE_FLAG => __( 'Flag', 'multisite-language-switcher' ),
390-
MslsAdminIcon::TYPE_LABEL => __( 'Label', 'multisite-language-switcher' ),
392+
Icon::TYPE_FLAG => __( 'Flag', 'multisite-language-switcher' ),
393+
Icon::TYPE_LABEL => __( 'Label', 'multisite-language-switcher' ),
391394
),
392395
$this->options->get_icon_type()
393396
);
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
<?php declare( strict_types=1 );
22

3-
namespace lloc\Msls;
3+
namespace lloc\Msls\Admin;
44

55
if ( ! defined( 'ABSPATH' ) ) {
66
exit;
77
}
88

9+
use lloc\Msls\Blog\Blog;
10+
use lloc\Msls\Blog\Collection;
911
use lloc\Msls\Options\Options;
1012

11-
class MslsAdminBar {
13+
class Bar {
1214

1315
/**
1416
* @var string
1517
*/
1618
protected string $icon_type;
1719

1820
/**
19-
* @var MslsBlogCollection
21+
* @var Collection
2022
*/
21-
protected MslsBlogCollection $blog_collection;
23+
protected Collection $blog_collection;
2224

2325
/**
24-
* @param Options $options
25-
* @param MslsBlogCollection $blog_collection
26+
* @param Options $options
27+
* @param Collection $blog_collection
2628
*/
27-
public function __construct( Options $options, MslsBlogCollection $blog_collection ) {
29+
public function __construct( Options $options, Collection $blog_collection ) {
2830
$this->icon_type = $options->get_icon_type();
2931
$this->blog_collection = $blog_collection;
3032
}
@@ -33,7 +35,7 @@ public function __construct( Options $options, MslsBlogCollection $blog_collecti
3335
* @return void
3436
*/
3537
public static function init(): void {
36-
$obj = new MslsAdminBar( msls_options(), msls_blog_collection() );
38+
$obj = new Bar( msls_options(), msls_blog_collection() );
3739

3840
if ( is_admin_bar_showing() ) {
3941
add_action( 'admin_bar_menu', array( $obj, 'update_admin_bar' ), 999 );
@@ -90,12 +92,12 @@ public function add_node( \WP_Admin_Bar $wp_admin_bar, string $node_id, string $
9092
*
9193
* It uses a blavatar icon as prefix if $blavatar is set to true
9294
*
93-
* @param MslsBlog|null $blog
94-
* @param bool $blavatar
95+
* @param Blog|null $blog
96+
* @param bool $blavatar
9597
*
9698
* @return string|null
9799
*/
98-
protected function get_title( ?MslsBlog $blog, bool $blavatar = false ): ?string {
100+
protected function get_title( ?Blog $blog, bool $blavatar = false ): ?string {
99101
if ( is_null( $blog ) ) {
100102
return $blog;
101103
}
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php declare( strict_types=1 );
22

3-
namespace lloc\Msls;
3+
namespace lloc\Msls\Admin;
44

55
if ( ! defined( 'ABSPATH' ) ) {
66
exit;
77
}
88

9+
use lloc\Msls\Blog\Collection;
910
use lloc\Msls\Component\Component;
11+
use lloc\Msls\MslsMain;
1012
use lloc\Msls\Options\Options;
1113

1214
/**
@@ -15,7 +17,7 @@
1517
*
1618
* @package Msls
1719
*/
18-
class MslsCustomColumn extends MslsMain {
20+
class CustomColumn extends MslsMain {
1921

2022
public static function init(): void {
2123
$options = msls_options();
@@ -52,7 +54,7 @@ public function th( array $columns ) {
5254
foreach ( $blogs as $blog ) {
5355
$language = $blog->get_language();
5456
$icon_type = $this->options->get_icon_type();
55-
$icon = ( new MslsAdminIcon() )->set_language( $language )->set_icon_type( $icon_type );
57+
$icon = ( new Icon() )->set_language( $language )->set_icon_type( $icon_type );
5658

5759
$post_id = get_the_ID();
5860
if ( false !== $post_id ) {
@@ -79,15 +81,15 @@ public function th( array $columns ) {
7981
public function td( $column_name, $item_id ): void {
8082
if ( 'mslscol' === $column_name ) {
8183
$blogs = $this->collection->get();
82-
$origin_language = MslsBlogCollection::get_blog_language();
84+
$origin_language = Collection::get_blog_language();
8385
if ( $blogs ) {
8486
$mydata = Options::create( $item_id );
8587
foreach ( $blogs as $blog ) {
8688
switch_to_blog( $blog->userblog_id );
8789

8890
$language = $blog->get_language();
8991

90-
$icon = MslsAdminIcon::create();
92+
$icon = Icon::create();
9193
$icon->set_language( $language );
9294
$icon->set_id( $item_id );
9395
$icon->set_origin_language( $origin_language );
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php declare( strict_types=1 );
22

3-
namespace lloc\Msls;
3+
namespace lloc\Msls\Admin;
44

55
if ( ! defined( 'ABSPATH' ) ) {
66
exit;
@@ -14,7 +14,7 @@
1414
*
1515
* @package Msls
1616
*/
17-
final class MslsCustomColumnTaxonomy extends MslsCustomColumn {
17+
final class CustomColumnTaxonomy extends CustomColumn {
1818

1919
protected function add_hooks(): void {
2020
if ( $this->options->is_excluded() ) {
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
<?php declare( strict_types=1 );
22

3-
namespace lloc\Msls;
3+
namespace lloc\Msls\Admin;
44

55
if ( ! defined( 'ABSPATH' ) ) {
66
exit;
77
}
88

99
use lloc\Msls\Component\Input\Select;
10-
use lloc\Msls\Query\TranslatedPostIdQuery;
10+
use lloc\Msls\MslsFields;
11+
use lloc\Msls\MslsMain;
12+
use lloc\Msls\MslsRequest;
13+
use lloc\Msls\Db\SqlCacher;
14+
use lloc\Msls\Db\Query\TranslatedPostIdQuery;
1115

1216
/**
1317
* Adding custom filter to posts/pages table.
1418
*
1519
* @package Msls
1620
*/
17-
final class MslsCustomFilter extends MslsMain {
21+
final class CustomFilter extends MslsMain {
1822

1923
/**
2024
* @codeCoverageIgnore
@@ -80,7 +84,7 @@ public function execute_filter( \WP_Query $query ) {
8084
return false;
8185
}
8286

83-
$sql_cache = MslsSqlCacher::create( __CLASS__, __METHOD__ );
87+
$sql_cache = SqlCacher::create( __CLASS__, __METHOD__ );
8488

8589
// Load post we need to exclude (they already have a translation) from search query.
8690
$query->query_vars['post__not_in'] = ( new TranslatedPostIdQuery( $sql_cache ) )( $blog->get_language() );
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php declare( strict_types=1 );
22

3-
namespace lloc\Msls;
3+
namespace lloc\Msls\Admin;
44

55
use lloc\Msls\Component\Component;
66
use lloc\Msls\Component\Icon\IconSvg;
@@ -11,7 +11,7 @@
1111
*
1212
* @package Msls
1313
*/
14-
class MslsAdminIcon {
14+
class Icon {
1515

1616
protected string $icon_type = 'action';
1717
protected string $language = '';
@@ -40,7 +40,7 @@ public function __toString(): string {
4040
}
4141

4242
/**
43-
* @return MslsAdminIcon|MslsAdminIconTaxonomy
43+
* @return Icon|IconTaxonomy
4444
*/
4545
public static function create( ?string $type = null ) {
4646
$obj = msls_content_types();
@@ -49,13 +49,13 @@ public static function create( ?string $type = null ) {
4949
$type = $obj->get_request();
5050
}
5151

52-
return $obj->is_taxonomy() ? new MslsAdminIconTaxonomy( $type ) : new MslsAdminIcon( $type );
52+
return $obj->is_taxonomy() ? new IconTaxonomy( $type ) : new Icon( $type );
5353
}
5454

5555
/**
5656
* Set the icon path
5757
*/
58-
public function set_icon_type( string $icon_type ): MslsAdminIcon {
58+
public function set_icon_type( string $icon_type ): Icon {
5959
$this->icon_type = $icon_type;
6060

6161
return $this;
@@ -64,7 +64,7 @@ public function set_icon_type( string $icon_type ): MslsAdminIcon {
6464
/**
6565
* Set the path by type
6666
*/
67-
public function set_path(): MslsAdminIcon {
67+
public function set_path(): Icon {
6868
if ( 'post' !== $this->type ) {
6969
$query_vars = array( 'post_type' => $this->type );
7070
$this->path = add_query_arg( $query_vars, $this->path );
@@ -73,19 +73,19 @@ public function set_path(): MslsAdminIcon {
7373
return $this;
7474
}
7575

76-
public function set_language( string $language ): MslsAdminIcon {
76+
public function set_language( string $language ): Icon {
7777
$this->language = $language;
7878

7979
return $this;
8080
}
8181

82-
public function set_src( string $src ): MslsAdminIcon {
82+
public function set_src( string $src ): Icon {
8383
$this->src = $src;
8484

8585
return $this;
8686
}
8787

88-
public function set_href( int $id ): MslsAdminIcon {
88+
public function set_href( int $id ): Icon {
8989
$this->href = get_edit_post_link( $id ) ?? '';
9090

9191
return $this;
@@ -94,7 +94,7 @@ public function set_href( int $id ): MslsAdminIcon {
9494
/**
9595
* Sets the id of the object this icon is for
9696
*/
97-
public function set_id( int $id ): MslsAdminIcon {
97+
public function set_id( int $id ): Icon {
9898
$this->id = $id;
9999

100100
return $this;
@@ -103,7 +103,7 @@ public function set_id( int $id ): MslsAdminIcon {
103103
/**
104104
* Sets the origin language for this icon
105105
*/
106-
public function set_origin_language( string $origin_language ): MslsAdminIcon {
106+
public function set_origin_language( string $origin_language ): Icon {
107107
$this->origin_language = $origin_language;
108108

109109
return $this;

0 commit comments

Comments
 (0)