diff --git a/composer.json b/composer.json index 3975fe42..b87a9eb2 100644 --- a/composer.json +++ b/composer.json @@ -109,10 +109,6 @@ "gravity/gravityforms": "2.9.0.2", "humanmade/s3-uploads": "^3.0", "johnbillion/extended-cpts": "^5.0", - "moderntribe/square1-post-type": "^4.2", - "moderntribe/square1-settings": "^4.2", - "moderntribe/square1-taxonomy": "^4.2", - "moderntribe/square1-utils": "^4.2", "moderntribe/tribe-glomar": "dev-main", "php-di/php-di": "^6.0", "vinkla/extended-acf": "^13.6", diff --git a/composer.lock b/composer.lock index 956084de..1276d67d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "69c9aa45efae44f5f2736781d0ba0626", + "content-hash": "f360e1ce4b6d57f35b63550a0cdedb5e", "packages": [ { "name": "aws/aws-crt-php", @@ -62,16 +62,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.332.0", + "version": "3.334.1", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "3b4972a465b66fe3da461a3febdcc363954a0969" + "reference": "3938b3467f64a30fed7ee1762a6785f808a5ae4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3b4972a465b66fe3da461a3febdcc363954a0969", - "reference": "3b4972a465b66fe3da461a3febdcc363954a0969", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3938b3467f64a30fed7ee1762a6785f808a5ae4d", + "reference": "3938b3467f64a30fed7ee1762a6785f808a5ae4d", "shasum": "" }, "require": { @@ -154,9 +154,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.332.0" + "source": "https://github.com/aws/aws-sdk-php/tree/3.334.1" }, - "time": "2024-12-02T03:48:16+00:00" + "time": "2024-12-05T01:17:41+00:00" }, { "name": "block-editor-custom-alignments/block-editor-custom-alignments", @@ -2233,244 +2233,6 @@ }, "time": "2024-07-23T14:00:32+00:00" }, - { - "name": "moderntribe/square1-container", - "version": "4.2.0", - "source": { - "type": "git", - "url": "https://github.com/moderntribe/square1-container.git", - "reference": "9e17bcd5f94ab37928d820be92ea22a6c03dbd16" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/moderntribe/square1-container/zipball/9e17bcd5f94ab37928d820be92ea22a6c03dbd16", - "reference": "9e17bcd5f94ab37928d820be92ea22a6c03dbd16", - "shasum": "" - }, - "require": { - "php": ">=7.4", - "php-di/php-di": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Tribe\\Libs\\Container\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0-only" - ], - "description": "A dependency injection container wrapper for square one", - "support": { - "issues": "https://github.com/moderntribe/square1-container/issues", - "source": "https://github.com/moderntribe/square1-container/tree/4.2.0" - }, - "time": "2022-08-17T21:54:37+00:00" - }, - { - "name": "moderntribe/square1-object-meta", - "version": "4.2.0", - "source": { - "type": "git", - "url": "https://github.com/moderntribe/square1-object-meta.git", - "reference": "5e2f61084392dd3084f3570f4f37d3004d04375e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/moderntribe/square1-object-meta/zipball/5e2f61084392dd3084f3570f4f37d3004d04375e", - "reference": "5e2f61084392dd3084f3570f4f37d3004d04375e", - "shasum": "" - }, - "require": { - "moderntribe/square1-container": "^4.2", - "php": ">=7.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Tribe\\Libs\\Object_Meta\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0-only" - ], - "description": "Provides object meta wrappers for square one", - "support": { - "issues": "https://github.com/moderntribe/square1-object-meta/issues", - "source": "https://github.com/moderntribe/square1-object-meta/tree/4.2.0" - }, - "time": "2022-10-25T16:44:11+00:00" - }, - { - "name": "moderntribe/square1-post-type", - "version": "4.2.0", - "source": { - "type": "git", - "url": "https://github.com/moderntribe/square1-post-type.git", - "reference": "abf08f9375ec3846768a4a81cae3ed82565be66e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/moderntribe/square1-post-type/zipball/abf08f9375ec3846768a4a81cae3ed82565be66e", - "reference": "abf08f9375ec3846768a4a81cae3ed82565be66e", - "shasum": "" - }, - "require": { - "moderntribe/square1-object-meta": "^4.2", - "php": ">=7.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Tribe\\Libs\\Post_Type\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0-only" - ], - "description": "Post type utilities for square one", - "support": { - "issues": "https://github.com/moderntribe/square1-post-type/issues", - "source": "https://github.com/moderntribe/square1-post-type/tree/4.2.0" - }, - "time": "2022-10-25T16:44:16+00:00" - }, - { - "name": "moderntribe/square1-settings", - "version": "4.2.0", - "source": { - "type": "git", - "url": "https://github.com/moderntribe/square1-settings.git", - "reference": "127d9303bc0a53d9cafd23fd107abac29130e601" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/moderntribe/square1-settings/zipball/127d9303bc0a53d9cafd23fd107abac29130e601", - "reference": "127d9303bc0a53d9cafd23fd107abac29130e601", - "shasum": "" - }, - "require": { - "php": ">=7.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Tribe\\Libs\\Settings\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0-only" - ], - "description": "Settings page utilities for square one", - "support": { - "issues": "https://github.com/moderntribe/square1-settings/issues", - "source": "https://github.com/moderntribe/square1-settings/tree/4.2.0" - }, - "time": "2022-08-17T21:54:37+00:00" - }, - { - "name": "moderntribe/square1-taxonomy", - "version": "4.2.0", - "source": { - "type": "git", - "url": "https://github.com/moderntribe/square1-taxonomy.git", - "reference": "03f7ccbaa6fd8148e8f00b39b4869b8aad845739" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/moderntribe/square1-taxonomy/zipball/03f7ccbaa6fd8148e8f00b39b4869b8aad845739", - "reference": "03f7ccbaa6fd8148e8f00b39b4869b8aad845739", - "shasum": "" - }, - "require": { - "moderntribe/square1-object-meta": "^4.2", - "php": ">=7.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Tribe\\Libs\\Taxonomy\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0-only" - ], - "description": "Taxonomy utilities for square one", - "support": { - "issues": "https://github.com/moderntribe/square1-taxonomy/issues", - "source": "https://github.com/moderntribe/square1-taxonomy/tree/4.2.0" - }, - "time": "2022-10-25T16:44:14+00:00" - }, - { - "name": "moderntribe/square1-utils", - "version": "4.2.0", - "source": { - "type": "git", - "url": "https://github.com/moderntribe/square1-utils.git", - "reference": "43de86e04ac7fd4f2a694ebee05dc65fa5d58730" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/moderntribe/square1-utils/zipball/43de86e04ac7fd4f2a694ebee05dc65fa5d58730", - "reference": "43de86e04ac7fd4f2a694ebee05dc65fa5d58730", - "shasum": "" - }, - "require": { - "php": ">=7.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Tribe\\Libs\\Utils\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0-only" - ], - "description": "Utilities for square one", - "support": { - "issues": "https://github.com/moderntribe/square1-utils/issues", - "source": "https://github.com/moderntribe/square1-utils/tree/4.2.0" - }, - "time": "2022-08-17T21:54:37+00:00" - }, { "name": "moderntribe/tribe-glomar", "version": "dev-main", @@ -7089,25 +6851,25 @@ }, { "name": "behat/gherkin", - "version": "v4.10.0", + "version": "v4.11.0", "source": { "type": "git", "url": "https://github.com/Behat/Gherkin.git", - "reference": "cbb83c4c435dd8d05a161f2a5ae322e61b2f4db6" + "reference": "32821a17b12620951e755b5d49328a6421a5b5b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Behat/Gherkin/zipball/cbb83c4c435dd8d05a161f2a5ae322e61b2f4db6", - "reference": "cbb83c4c435dd8d05a161f2a5ae322e61b2f4db6", + "url": "https://api.github.com/repos/Behat/Gherkin/zipball/32821a17b12620951e755b5d49328a6421a5b5b5", + "reference": "32821a17b12620951e755b5d49328a6421a5b5b5", "shasum": "" }, "require": { - "php": "~7.2|~8.0" + "php": "8.1.* || 8.2.* || 8.3.* || 8.4.*" }, "require-dev": { "cucumber/cucumber": "dev-gherkin-24.1.0", - "phpunit/phpunit": "~8|~9", - "symfony/yaml": "~3|~4|~5|~6|~7" + "phpunit/phpunit": "^9.6", + "symfony/yaml": "^5.4 || ^6.4 || ^7.0" }, "suggest": { "symfony/yaml": "If you want to parse features, represented in YAML files" @@ -7146,9 +6908,9 @@ ], "support": { "issues": "https://github.com/Behat/Gherkin/issues", - "source": "https://github.com/Behat/Gherkin/tree/v4.10.0" + "source": "https://github.com/Behat/Gherkin/tree/v4.11.0" }, - "time": "2024-10-19T14:46:06+00:00" + "time": "2024-12-06T10:07:25+00:00" }, { "name": "bordoni/phpass", @@ -10149,16 +9911,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.21", + "version": "9.6.22", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa" + "reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", - "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f80235cb4d3caa59ae09be3adf1ded27521d1a9c", + "reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c", "shasum": "" }, "require": { @@ -10169,7 +9931,7 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.12.0", + "myclabs/deep-copy": "^1.12.1", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=7.3", @@ -10232,7 +9994,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.21" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.22" }, "funding": [ { @@ -10248,7 +10010,7 @@ "type": "tidelift" } ], - "time": "2024-09-19T10:50:18+00:00" + "time": "2024-12-05T13:48:26+00:00" }, { "name": "psr/clock", diff --git a/tests/wpunit/BlockBaseWpUnitTest.php b/tests/wpunit/BlockBaseWpUnitTest.php index e892006a..b5b0a3d9 100644 --- a/tests/wpunit/BlockBaseWpUnitTest.php +++ b/tests/wpunit/BlockBaseWpUnitTest.php @@ -4,12 +4,20 @@ class BlockBaseWpUnitTest extends \Codeception\TestCase\WPTestCase { use \Tribe\Plugin\Assets\Traits\Assets; + protected bool $is_local_built = false; + public function setUp(): void { parent::setUp(); $block_dir = get_template_directory() . '/dist/blocks/core/button'; $editor_asset = $block_dir . '/editor.asset.php'; - mkdir( $block_dir, 0777, true ); + + // If you have blocks dist built do not create it + if ( ! is_dir( $block_dir ) ) { + mkdir( $block_dir, 0777, true ); + } else { + $this->is_local_built = true; + } $editor_asset_content = file_get_contents( __DIR__ . '/../_data/editor_asset_test.php' ); $file_handler = fopen( $editor_asset, 'w' ); @@ -31,6 +39,9 @@ protected function tearDown(): void { $block_dir = get_template_directory() . '/dist/blocks/core/button'; $editor_asset = $block_dir . '/editor.asset.php'; + if ( $this->is_local_built ) { + return; + } unlink( $editor_asset ); rmdir( $block_dir ); } diff --git a/wp-content/plugins/core/src/Assets/Assets_Subscriber.php b/wp-content/plugins/core/src/Assets/Assets_Subscriber.php index e5bad004..8fa30b49 100644 --- a/wp-content/plugins/core/src/Assets/Assets_Subscriber.php +++ b/wp-content/plugins/core/src/Assets/Assets_Subscriber.php @@ -2,7 +2,7 @@ namespace Tribe\Plugin\Assets; -use Tribe\Libs\Container\Abstract_Subscriber; +use Tribe\Plugin\Core\Abstract_Subscriber; class Assets_Subscriber extends Abstract_Subscriber { diff --git a/wp-content/plugins/core/src/Blocks/Blocks_Definer.php b/wp-content/plugins/core/src/Blocks/Blocks_Definer.php index df6e5c00..ccd64dd9 100644 --- a/wp-content/plugins/core/src/Blocks/Blocks_Definer.php +++ b/wp-content/plugins/core/src/Blocks/Blocks_Definer.php @@ -3,8 +3,8 @@ namespace Tribe\Plugin\Blocks; use DI; -use Tribe\Libs\Container\Definer_Interface; use Tribe\Plugin\Blocks\Filters\Contracts\Filter_Factory; +use Tribe\Plugin\Core\Interfaces\Definer_Interface; use Tribe\Theme\bindings\Post_Permalink; use Tribe\Theme\bindings\Post_Type_Name; use Tribe\Theme\bindings\Query_Results_Count; diff --git a/wp-content/plugins/core/src/Blocks/Blocks_Subscriber.php b/wp-content/plugins/core/src/Blocks/Blocks_Subscriber.php index 1c168390..7354860c 100644 --- a/wp-content/plugins/core/src/Blocks/Blocks_Subscriber.php +++ b/wp-content/plugins/core/src/Blocks/Blocks_Subscriber.php @@ -2,11 +2,11 @@ namespace Tribe\Plugin\Blocks; -use Tribe\Libs\Container\Abstract_Subscriber; use Tribe\Plugin\Blocks\Bindings\Binding_Registrar; use Tribe\Plugin\Blocks\Filters\Contracts\Filter_Factory; use Tribe\Plugin\Blocks\Patterns\Pattern_Category; use Tribe\Plugin\Blocks\Patterns\Pattern_Registrar; +use Tribe\Plugin\Core\Abstract_Subscriber; use Tribe\Plugin\Theme_Config\Theme_Support; class Blocks_Subscriber extends Abstract_Subscriber { diff --git a/wp-content/plugins/core/src/Core.php b/wp-content/plugins/core/src/Core.php index 14d7623e..7f8acf70 100644 --- a/wp-content/plugins/core/src/Core.php +++ b/wp-content/plugins/core/src/Core.php @@ -14,7 +14,6 @@ class Core { * @var string[] Names of classes implementing Definer_Interface. */ private array $definers = [ - \Tribe\Libs\Settings\Settings_Definer::class, Blocks\Blocks_Definer::class, Object_Meta\Meta_Definer::class, Settings\Settings_Definer::class, @@ -24,7 +23,7 @@ class Core { * @var string[] Names of classes extending Abstract_Subscriber. */ private array $subscribers = [ - \Tribe\Libs\Settings\Settings_Subscriber::class, + Settings\Settings_Subscriber::class, Assets\Assets_Subscriber::class, Blocks\Blocks_Subscriber::class, Integrations\Integrations_Subscriber::class, diff --git a/wp-content/plugins/core/src/Core/Abstract_Subscriber.php b/wp-content/plugins/core/src/Core/Abstract_Subscriber.php new file mode 100644 index 00000000..ecf869b9 --- /dev/null +++ b/wp-content/plugins/core/src/Core/Abstract_Subscriber.php @@ -0,0 +1,19 @@ +container = $container; + } + +} diff --git a/wp-content/plugins/core/src/Core/Interfaces/Definer_Interface.php b/wp-content/plugins/core/src/Core/Interfaces/Definer_Interface.php new file mode 100644 index 00000000..2a35fc5b --- /dev/null +++ b/wp-content/plugins/core/src/Core/Interfaces/Definer_Interface.php @@ -0,0 +1,9 @@ +get_meta_boxes() ); + } + + /** + * Hooks the meta box handler class to the required filters/actions if needed. + */ + public function hook(): void { + add_filter( Meta_Box_Handler_Interface::INSTANCE_FILTER, function () { + return $this; + } ); + } + +} diff --git a/wp-content/plugins/core/src/Post_Types/Meta_Box_Handlers/CMB2.php b/wp-content/plugins/core/src/Post_Types/Meta_Box_Handlers/CMB2.php new file mode 100644 index 00000000..b142e854 --- /dev/null +++ b/wp-content/plugins/core/src/Post_Types/Meta_Box_Handlers/CMB2.php @@ -0,0 +1,39 @@ +config = $config; + } + + /** + * Hooks the meta box handler class to the required filters/actions if needed. + */ + public function hook(): void { + add_filter( Meta_Box_Handler_Interface::INSTANCE_FILTER, function () { + return $this; + } ); + + $config = $this->config; + + add_filter( 'cmb2_meta_boxes', static function ( $meta_boxes ) use ( $config ) { + $post_type_meta_boxes = $config->get_meta_boxes(); + $post_type_meta_boxes = apply_filters( "tribe_{$config->post_type()}_meta_boxes", $post_type_meta_boxes ); + $meta_boxes = array_merge( $meta_boxes, $post_type_meta_boxes ); + + return $meta_boxes; + } ); + } + +} diff --git a/wp-content/plugins/core/src/Post_Types/Meta_Box_Handlers/Meta_Box_Handler_Interface.php b/wp-content/plugins/core/src/Post_Types/Meta_Box_Handlers/Meta_Box_Handler_Interface.php new file mode 100644 index 00000000..22522741 --- /dev/null +++ b/wp-content/plugins/core/src/Post_Types/Meta_Box_Handlers/Meta_Box_Handler_Interface.php @@ -0,0 +1,23 @@ +post_id = $post_id; + } + + /** + * Get an instance of the Post_Object corresponding + * to the \WP_Post with the given $post_id + * + * @param int $post_id The ID of an existing post + */ + public static function factory( int $post_id ): self { + return new self( $post_id ); + } + + /** + * Get the value for the given meta key corresponding + * to this post. + * + * @param string $key + */ + public function get_meta( string $key ): mixed { + return get_post_meta( $this->post_id, $key, true ); + } + + public function __get( mixed $key ): mixed { + return $this->get_meta( $key ); + } + +} diff --git a/wp-content/plugins/core/src/Post_Types/Post_Type_Config.php b/wp-content/plugins/core/src/Post_Types/Post_Type_Config.php new file mode 100644 index 00000000..927a0b93 --- /dev/null +++ b/wp-content/plugins/core/src/Post_Types/Post_Type_Config.php @@ -0,0 +1,77 @@ +post_type = $post_type; + } + + /** + * Hook into WordPress to register the post type + */ + public function register(): void { + Post_Type_Registration::register( $this, apply_filters( Meta_Box_Handler_Interface::INSTANCE_FILTER, null ) ); + } + + /** + * @return string The ID of the post type + */ + public function post_type(): string { + return $this->post_type; + } + + /** + * Get the metabox configuration for the post type + * + * @see \CMB2 + */ + public function get_meta_boxes(): array { + return []; + } + + /** + * Get the ACF metabox configuration for the post type + * + * @return array An array of field group configurations + * (i.e., an array of arrays). + * + * @see acf_add_local_field_group() + */ + public function get_acf_fields(): array { + return []; + } + +} diff --git a/wp-content/plugins/core/src/Post_Types/Post_Type_Registration.php b/wp-content/plugins/core/src/Post_Types/Post_Type_Registration.php new file mode 100644 index 00000000..d63f9a87 --- /dev/null +++ b/wp-content/plugins/core/src/Post_Types/Post_Type_Registration.php @@ -0,0 +1,69 @@ +post_type() ) ) { + throw new \RuntimeException( 'Invalid configuration. Specify a post type.' ); + } + + $args = $config->get_args(); + $labels = empty( $args['labels'] ) ? [] : $args['labels']; + //allow adding more than 3 labels to get_labels + $args['labels'] = wp_parse_args( $labels, $config->get_labels() ); + register_extended_post_type( $config->post_type(), $args, $config->get_labels() ); + + + // The meta box handler is supposed to handle any hooking, meta box and field registration... + if ( $meta_box_handler !== null ) { + $meta_box_handler->register_meta_boxes( $config ); + } else { + // ...otherwise we'll cover the bases with CMB2 and ACF + add_filter( 'cmb2_meta_boxes', static function ( $meta_boxes ) use ( $config ) { + $post_type_meta_boxes = $config->get_meta_boxes(); + $post_type_meta_boxes = apply_filters( "tribe_{$config->post_type()}_meta_boxes", $post_type_meta_boxes ); + $meta_boxes = array_merge( $meta_boxes, $post_type_meta_boxes ); + + return $meta_boxes; + } ); + + // acf fires `acf/include_fields` too early to use a callback here, at init:5 + if ( function_exists( 'acf_add_local_field_group' ) ) { + $meta_boxes = $config->get_acf_fields(); + foreach ( $meta_boxes as $box ) { + acf_add_local_field_group( $box ); + } + } + } + }; + } + +} diff --git a/wp-content/plugins/core/src/Post_Types/Post_Type_Subscriber.php b/wp-content/plugins/core/src/Post_Types/Post_Type_Subscriber.php new file mode 100644 index 00000000..a2872524 --- /dev/null +++ b/wp-content/plugins/core/src/Post_Types/Post_Type_Subscriber.php @@ -0,0 +1,24 @@ + + */ + protected $config_class; + + public function register(): void { + if ( ! $this->config_class ) { + return; + } + + add_action( 'init', function (): void { + $this->container->get( $this->config_class )->register(); + }, 0, 0 ); + } + +} diff --git a/wp-content/plugins/core/src/Post_Types/Training/Config.php b/wp-content/plugins/core/src/Post_Types/Training/Config.php index ecfad1d8..5f94ac2b 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Config.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Config.php @@ -2,12 +2,11 @@ namespace Tribe\Plugin\Post_Types\Training; -use Tribe\Libs\Post_Type\Post_Type_Config; +use Tribe\Plugin\Post_Types\Post_Type_Config; class Config extends Post_Type_Config { - // phpcs:ignore SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint - protected $post_type = Training::NAME; + protected string $post_type = Training::NAME; public function get_args(): array { return [ diff --git a/wp-content/plugins/core/src/Post_Types/Training/Training.php b/wp-content/plugins/core/src/Post_Types/Training/Training.php index e7f0c564..8913b673 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Training.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Training.php @@ -2,7 +2,7 @@ namespace Tribe\Plugin\Post_Types\Training; -use Tribe\Libs\Post_Type\Post_Object; +use Tribe\Plugin\Post_Types\Post_Object; class Training extends Post_Object { diff --git a/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php b/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php index 554d4487..1b6cc6d3 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Training_Subscriber.php @@ -2,7 +2,7 @@ namespace Tribe\Plugin\Post_Types\Training; -use Tribe\Libs\Post_Type\Post_Type_Subscriber; +use Tribe\Plugin\Post_Types\Post_Type_Subscriber; class Training_Subscriber extends Post_Type_Subscriber { diff --git a/wp-content/plugins/core/src/Settings/Base_Settings.php b/wp-content/plugins/core/src/Settings/Base_Settings.php new file mode 100644 index 00000000..d462d323 --- /dev/null +++ b/wp-content/plugins/core/src/Settings/Base_Settings.php @@ -0,0 +1,56 @@ +set_slug(); + } + + /** + * @param int $priority + */ + public function hook( int $priority = 10 ): void { + add_action( 'init', [ $this, 'register_settings' ], $priority, 0 ); + } + + /** + * Generates a unique-ish slug for this settings screen + */ + protected function set_slug(): void { + $this->slug = sanitize_title( $this->get_parent_slug() . '-' . $this->get_title() ); + } + +} diff --git a/wp-content/plugins/core/src/Settings/Settings_Definer.php b/wp-content/plugins/core/src/Settings/Settings_Definer.php index 6ffe8f89..d11f4d7b 100644 --- a/wp-content/plugins/core/src/Settings/Settings_Definer.php +++ b/wp-content/plugins/core/src/Settings/Settings_Definer.php @@ -3,14 +3,16 @@ namespace Tribe\Plugin\Settings; use DI; -use Tribe\Libs\Container\Definer_Interface; +use Tribe\Plugin\Core\Interfaces\Definer_Interface; class Settings_Definer implements Definer_Interface { + public const PAGES = 'libs.settings.pages'; + public function define(): array { return [ // add the settings screens to the global array - \Tribe\Libs\Settings\Settings_Definer::PAGES => DI\add( [ + self::PAGES => DI\add( [ DI\get( Login_Settings::class ), ] ), ]; diff --git a/wp-content/plugins/core/src/Settings/Settings_Sub_Page.php b/wp-content/plugins/core/src/Settings/Settings_Sub_Page.php index 6bfe0a3d..bd66a85f 100644 --- a/wp-content/plugins/core/src/Settings/Settings_Sub_Page.php +++ b/wp-content/plugins/core/src/Settings/Settings_Sub_Page.php @@ -3,7 +3,6 @@ namespace Tribe\Plugin\Settings; use Extended\ACF\Location; -use Tribe\Libs\Settings\Base_Settings; abstract class Settings_Sub_Page extends Base_Settings { @@ -35,12 +34,9 @@ public function get_slug(): string { * Get setting value * * @param string $key - * @param null $default - * - * @return mixed + * @param mixed $default */ - // phpcs:ignore SlevomatCodingStandard.TypeHints - public function get_setting( $key, $default = null ) { + public function get_setting( string $key, mixed $default = null ): mixed { $value = get_field( $key, 'option' ); return ! empty( $value ) ? $value : $default; diff --git a/wp-content/plugins/core/src/Settings/Settings_Subscriber.php b/wp-content/plugins/core/src/Settings/Settings_Subscriber.php new file mode 100644 index 00000000..5dbb299e --- /dev/null +++ b/wp-content/plugins/core/src/Settings/Settings_Subscriber.php @@ -0,0 +1,17 @@ +container->get( Settings_Definer::PAGES ) as $page ) { + $page->hook(); + } + }, 0, 0 ); + } + +} diff --git a/wp-content/plugins/core/src/Theme_Config/Theme_Config_Subscriber.php b/wp-content/plugins/core/src/Theme_Config/Theme_Config_Subscriber.php index 4df18971..c9215fcf 100644 --- a/wp-content/plugins/core/src/Theme_Config/Theme_Config_Subscriber.php +++ b/wp-content/plugins/core/src/Theme_Config/Theme_Config_Subscriber.php @@ -2,7 +2,7 @@ namespace Tribe\Plugin\Theme_Config; -use Tribe\Libs\Container\Abstract_Subscriber; +use Tribe\Plugin\Core\Abstract_Subscriber; use Tribe\Plugin\Menus\Menu_Registrar; class Theme_Config_Subscriber extends Abstract_Subscriber {