Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions MultisiteLanguageSwitcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
define( 'MSLS_PLUGIN_PATH', plugin_basename( __FILE__ ) );
define( 'MSLS_PLUGIN__FILE__', __FILE__ );

require_once __DIR__ . '/includes/aliases.php';
require_once __DIR__ . '/includes/deprectated.php';

/**
Expand Down Expand Up @@ -93,7 +94,7 @@ function msls_the_switcher( array $arr = array() ): void {
* @return string
*/
function msls_get_flag_url( string $locale ): string {
return ( new \lloc\Msls\MslsOptions() )->get_flag_url( $locale );
return ( new \lloc\Msls\Options\Options() )->get_flag_url( $locale );
}

/**
Expand Down Expand Up @@ -123,7 +124,7 @@ function msls_get_permalink( string $locale, string $preset = '' ): string {
$blog = msls_blog( $locale );

if ( $blog ) {
$options = \lloc\Msls\MslsOptions::create();
$options = \lloc\Msls\Options\Options::create();
$url = $blog->get_url( $options );
}

Expand Down Expand Up @@ -151,12 +152,12 @@ function msls_blog_collection(): \lloc\Msls\MslsBlogCollection {
}

/**
* Gets the MslsOptions instance
* Gets the Options instance
*
* @return \lloc\Msls\MslsOptions
* @return \lloc\Msls\Options\Options
*/
function msls_options(): \lloc\Msls\MslsOptions {
return \lloc\Msls\MslsOptions::instance();
function msls_options(): \lloc\Msls\Options\Options {
return \lloc\Msls\Options\Options::instance();
}

/**
Expand Down Expand Up @@ -196,17 +197,18 @@ function msls_output(): \lloc\Msls\MslsOutput {
}

/**
* Retrieves the MslsOptionsPost instance.
* Retrieves the OptionsPost instance.
*
* @param int $id
* @return \lloc\Msls\MslsOptionsPost
*
* @return \lloc\Msls\Options\Post\Post
*/
function msls_get_post( int $id ): \lloc\Msls\MslsOptionsPost {
return new \lloc\Msls\MslsOptionsPost( $id );
function msls_get_post( int $id ): \lloc\Msls\Options\Post\Post {
return new \lloc\Msls\Options\Post\Post( $id );
}

/**
* Retrieves the MslsOptionsTax instance.
* Retrieves the OptionsTax instance.
*
* Determines the current query based on conditional tags:
* - is_category
Expand All @@ -217,11 +219,11 @@ function msls_get_post( int $id ): \lloc\Msls\MslsOptionsPost {
* @return \lloc\Msls\OptionsTaxInterface
*/
function msls_get_tax( int $id ): \lloc\Msls\OptionsTaxInterface {
return \lloc\Msls\MslsOptionsTax::create( $id );
return \lloc\Msls\Options\Tax\Tax::create( $id );
}

/**
* Retrieves the MslsOptionsQuery instance.
* Retrieves the OptionsQuery instance.
*
* Determines the current query based on conditional tags:
* - is_day
Expand All @@ -230,10 +232,10 @@ function msls_get_tax( int $id ): \lloc\Msls\OptionsTaxInterface {
* - is_author
* - is_post_type_archive
*
* @return ?\lloc\Msls\MslsOptionsQuery
* @return ?\lloc\Msls\Options\Query\Query
*/
function msls_get_query(): ?\lloc\Msls\MslsOptionsQuery {
return \lloc\Msls\MslsOptionsQuery::create();
function msls_get_query(): ?\lloc\Msls\Options\Query\Query {
return \lloc\Msls\Options\Query\Query::create();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"flags-svg": "php bin/flags-svg.php > assets/css-flags/flags.php",
"git-release": "bin/git-release.sh",
"phpcs": "phpcs -p ./*.php includes/ --standard=vendor/phpcompatibility/php-compatibility/PHPCompatibility --runtime-set testVersion 7.4-",
"phpstan": "vendor/bin/phpstan analyze --memory-limit=1G",
"phpstan": "vendor/bin/phpstan analyze --memory-limit=2G",
"phpunit": "@php vendor/bin/phpunit",
"phpunit:clover": "@php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-clover tests/coverage.xml",
"phpunit:html": "@php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-html tests/coverage",
Expand Down
4 changes: 2 additions & 2 deletions includes/ContentImport/ContentImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
use lloc\Msls\ContentImport\Importers\WithRequestPostAttributes;
use lloc\Msls\MslsBlogCollection;
use lloc\Msls\MslsMain;
use lloc\Msls\MslsOptionsPost;
use lloc\Msls\MslsRegistryInstance;
use lloc\Msls\MslsRequest;
use lloc\Msls\Options\Post\Post;

/**
* Class ContentImporter
Expand Down Expand Up @@ -333,7 +333,7 @@ public function import_content( ImportCoordinates $import_coordinates, array $po
$source_post_id = $import_coordinates->source_post_id;
$dest_lang = $import_coordinates->dest_lang;
$dest_post_id = $import_coordinates->dest_post_id;
$relations->should_create( MslsOptionsPost::create( $source_post_id ), $dest_lang, $dest_post_id );
$relations->should_create( Post::create( $source_post_id ), $dest_lang, $dest_post_id );

foreach ( $importers as $key => $importer ) {
if ( ! $importer instanceof Importer ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

use lloc\Msls\ContentImport\ImportCoordinates;
use lloc\Msls\ContentImport\Importers\BaseImporter;
use lloc\Msls\MslsOptionsTax;
use lloc\Msls\MslsOptionsTaxTerm;
use lloc\Msls\Options\Tax\Term;
use lloc\Msls\OptionsTaxInterface;

/**
Expand Down Expand Up @@ -63,7 +62,7 @@ public function import( array $data ) {
$source_terms_ids = wp_list_pluck( $source_terms, 'term_id' );
$msls_terms = array_combine(
$source_terms_ids,
array_map( array( MslsOptionsTaxTerm::class, 'create' ), $source_terms_ids )
array_map( array( Term::class, 'create' ), $source_terms_ids )
);

switch_to_blog( $this->import_coordinates->dest_blog_id );
Expand Down
6 changes: 3 additions & 3 deletions includes/ContentImport/MetaBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use lloc\Msls\ContentImport\Importers\Map;
use lloc\Msls\MslsBlogCollection;
use lloc\Msls\MslsFields;
use lloc\Msls\MslsOptionsPost;
use lloc\Msls\MslsPlugin;
use lloc\Msls\MslsRegistryInstance;
use lloc\Msls\MslsRequest;
use lloc\Msls\Options\Post\Post;

class MetaBox extends MslsRegistryInstance {

Expand All @@ -28,8 +28,8 @@ public function render(): void {
return;
}

$mydata = new MslsOptionsPost( $post->ID );
$languages = MslsOptionsPost::instance()->get_available_languages();
$mydata = new Post( $post->ID );
$languages = Post::instance()->get_available_languages();
$current = MslsBlogCollection::get_blog_language( get_current_blog_id() );
$languages = array_diff_key( $languages, array( $current => $current ) );
$input_lang = MslsRequest::get( MslsFields::FIELD_MSLS_LANG, null );
Expand Down
8 changes: 4 additions & 4 deletions includes/ContentImport/Relations.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace lloc\Msls\ContentImport;

use lloc\Msls\MslsOptions;
use lloc\Msls\Options\Options;
use lloc\Msls\OptionsInterface;
use lloc\Msls\OptionsTaxInterface;

Expand Down Expand Up @@ -72,7 +72,7 @@ protected function create_source_to_local(): void {
switch_to_blog( $this->import_coordinates->source_blog_id );

foreach ( $this->to_create as $relation ) {
/** @var MslsOptions $option */
/** @var Options $option */
list( $option, $lang, $id ) = $relation;
$option->save( array( $lang => $id ) );
$source_id = $option->get_arg( 0, $id );
Expand Down Expand Up @@ -106,13 +106,13 @@ protected function create_local_to_source(): void {
continue;
}

if ( ! $source_option instanceof MslsOptions ) {
if ( ! $source_option instanceof Options ) {
continue;
}

$option_class = get_class( $source_option );
$local_option = $option_class::create( $local_id );
if ( $local_option instanceof MslsOptions ) {
if ( $local_option instanceof Options ) {
$local_option->save( array( $this->import_coordinates->source_lang => $source_id ) );
}
}
Expand Down
6 changes: 4 additions & 2 deletions includes/MslsAdminBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
exit;
}

use lloc\Msls\Options\Options;

class MslsAdminBar {

/**
Expand All @@ -19,10 +21,10 @@ class MslsAdminBar {
protected MslsBlogCollection $blog_collection;

/**
* @param MslsOptions $options
* @param Options $options
* @param MslsBlogCollection $blog_collection
*/
public function __construct( MslsOptions $options, MslsBlogCollection $blog_collection ) {
public function __construct( Options $options, MslsBlogCollection $blog_collection ) {
$this->icon_type = $options->get_icon_type();
$this->blog_collection = $blog_collection;
}
Expand Down
8 changes: 5 additions & 3 deletions includes/MslsBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

namespace lloc\Msls;

use lloc\Msls\Options\Options;

class MslsBlock {

/**
* The options instance.
*
* @var MslsOptions
* @var Options
*/
protected MslsOptions $options;
protected Options $options;

public function __construct( MslsOptions $options ) {
public function __construct( Options $options ) {
$this->options = $options;
}

Expand Down
6 changes: 4 additions & 2 deletions includes/MslsBlogCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
exit;
}

use lloc\Msls\Options\Options;

/**
* Collection of blog-objects
*
Expand Down Expand Up @@ -128,11 +130,11 @@ public static function get_configured_blog_description( int $blog_id, $descripti
* The first available user of the blog will be used if there is no
* refrence user configured
*
* @param MslsOptions $options
* @param Options $options
*
* @return object[]|\stdClass[]
*/
public function get_blogs_of_reference_user( MslsOptions $options ) {
public function get_blogs_of_reference_user( Options $options ) {
$reference_user = $options->has_value( 'reference_user' ) ?
$options->reference_user :
current( $this->get_users( 'ID', 1 ) );
Expand Down
8 changes: 5 additions & 3 deletions includes/MslsContentFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
exit;
}

use lloc\Msls\Options\Options;

class MslsContentFilter {

/**
* The options instance.
*
* @var MslsOptions
* @var Options
*/
protected MslsOptions $options;
protected Options $options;

public function __construct( MslsOptions $options ) {
public function __construct( Options $options ) {
$this->options = $options;
}

Expand Down
3 changes: 2 additions & 1 deletion includes/MslsCustomColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
}

use lloc\Msls\Component\Component;
use lloc\Msls\Options\Options;

/**
* Handling of existing/not existing translations in the backend listings of
Expand Down Expand Up @@ -80,7 +81,7 @@ public function td( $column_name, $item_id ): void {
$blogs = $this->collection->get();
$origin_language = MslsBlogCollection::get_blog_language();
if ( $blogs ) {
$mydata = MslsOptions::create( $item_id );
$mydata = Options::create( $item_id );
foreach ( $blogs as $blog ) {
switch_to_blog( $blog->userblog_id );

Expand Down
4 changes: 3 additions & 1 deletion includes/MslsCustomColumnTaxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
exit;
}

use lloc\Msls\Options\Tax\Tax;

/**
* Handling of existing/not existing translations in the backend
* listings of various taxonomies
Expand Down Expand Up @@ -43,6 +45,6 @@ public function column_default( $deprecated, $column_name, $item_id ): void {
* @param int $object_id
*/
public function delete( $object_id ): void {
$this->save( $object_id, MslsOptionsTax::class );
$this->save( $object_id, Tax::class );
}
}
14 changes: 8 additions & 6 deletions includes/MslsMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace lloc\Msls;

use lloc\Msls\Component\Component;
use lloc\Msls\Options\Options;
use lloc\Msls\Options\Post\Post;

/**
* Abstraction for the hook classes
Expand All @@ -16,7 +18,7 @@ class MslsMain {
/**
* Instance of options
*
* @var MslsOptions
* @var Options
*/
protected $options;

Expand All @@ -30,10 +32,10 @@ class MslsMain {
/**
* Constructor
*
* @param MslsOptions $options
* @param Options $options
* @param MslsBlogCollection $collection
*/
final public function __construct( MslsOptions $options, MslsBlogCollection $collection ) {
final public function __construct( Options $options, MslsBlogCollection $collection ) {
$this->options = $options;
$this->collection = $collection;
}
Expand Down Expand Up @@ -119,14 +121,14 @@ public function verify_nonce(): bool {
* @codeCoverageIgnore
*/
public function delete( $object_id ): void {
$this->save( $object_id, MslsOptionsPost::class );
$this->save( $object_id, Post::class );
}

/**
* Save
*
* @param int $object_id
* @param class-string<MslsOptions> $class_name
* @param int $object_id
* @param class-string<Options> $class_name
*
* @codeCoverageIgnore
*/
Expand Down
Loading
Loading