diff --git a/bootstrap.php b/bootstrap.php new file mode 100644 index 0000000..bd9edfd --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,11 @@ + 'Underpin\Styles\Loaders\Styles' ] ) ); \ No newline at end of file diff --git a/composer.json b/composer.json index a17b174..f4b39cb 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,9 @@ "underpin/underpin": "^2.0" }, "autoload": { + "psr-4": {"Underpin\\Styles\\": "lib/"}, "files": [ - "styles.php" + "bootstrap.php" ] } } diff --git a/lib/abstracts/Style.php b/lib/Abstracts/Style.php similarity index 95% rename from lib/abstracts/Style.php rename to lib/Abstracts/Style.php index 82666ce..875a6bc 100644 --- a/lib/abstracts/Style.php +++ b/lib/Abstracts/Style.php @@ -7,12 +7,13 @@ */ -namespace Underpin_Styles\Abstracts; +namespace Underpin\Styles\Abstracts; +use Underpin\Loaders\Logger; use Underpin\Traits\Feature_Extension; use Underpin\Traits\With_Middleware; use WP_Error; -use function Underpin\underpin; + if ( ! defined( 'ABSPATH' ) ) { exit; @@ -101,7 +102,7 @@ public function __construct() { $file = wp_parse_args( require( $this->ver ), [ 'dependencies' => [], 'version' => '' ] ); $this->ver = $file['version']; } else { - underpin()->logger()->log( + Logger::log( 'error', 'dependencies_file_not_found', 'A dependency file was specified, but it could not be found.', @@ -171,14 +172,14 @@ public function register() { $registered = wp_register_style( $this->handle, $this->src, $this->deps, $this->ver, $this->in_footer ); if ( false === $registered ) { - underpin()->logger()->log( + Logger::log( 'error', 'style_was_not_registered', 'The style ' . $this->handle . ' failed to register. That is all I know, unfortunately.', ['ref' => $this->handle] ); } else { - underpin()->logger()->log( + Logger::log( 'notice', 'style_was_registered', 'The style ' . $this->handle . ' registered successfully.', @@ -198,14 +199,14 @@ public function enqueue() { // Confirm it was enqueued. if ( wp_style_is( $this->handle ) ) { - underpin()->logger()->log( + Logger::log( 'notice', 'style_was_enqueued', 'The style ' . $this->handle . ' has been enqueued.', ['ref' => $this->handle] ); } else { - underpin()->logger()->log( + Logger::log( 'error', 'style_failed_to_enqueue', 'The style ' . $this->handle . ' failed to enqueue.', diff --git a/lib/factories/Enqueue_Admin_Style.php b/lib/Factories/Enqueue_Admin_Style.php similarity index 61% rename from lib/factories/Enqueue_Admin_Style.php rename to lib/Factories/Enqueue_Admin_Style.php index 0a5124d..f71e91f 100644 --- a/lib/factories/Enqueue_Admin_Style.php +++ b/lib/Factories/Enqueue_Admin_Style.php @@ -1,13 +1,14 @@ logger()->log( 'warning', 'rest_middleware_action_failed_to_run', 'Middleware action failed to run. Rest_Middleware expects to run on a Script loader.', [ + Logger::log( 'warning', 'rest_middleware_action_failed_to_run', 'Middleware action failed to run. Rest_Middleware expects to run on a Script loader.', [ 'loader' => get_class( $instance ), - 'expects' => 'Underpin_Scripts\Abstracts\Script', + 'expects' => 'Underpin\Scripts\Abstracts\Script', ] ); } } diff --git a/lib/factories/Enqueue_Style.php b/lib/Factories/Enqueue_Style.php similarity index 60% rename from lib/factories/Enqueue_Style.php rename to lib/Factories/Enqueue_Style.php index 03ae9b8..756a094 100644 --- a/lib/factories/Enqueue_Style.php +++ b/lib/Factories/Enqueue_Style.php @@ -1,13 +1,14 @@ logger()->log( 'warning', 'rest_middleware_action_failed_to_run', 'Middleware action failed to run. Rest_Middleware expects to run on a Script loader.', [ + Logger::log( 'warning', 'rest_middleware_action_failed_to_run', 'Middleware action failed to run. Rest_Middleware expects to run on a Script loader.', [ 'loader' => get_class( $instance ), - 'expects' => 'Underpin_Scripts\Abstracts\Script', + 'expects' => 'Underpin\Scripts\Abstracts\Script', ] ); } } diff --git a/lib/factories/Style_Instance.php b/lib/Factories/Style_Instance.php similarity index 86% rename from lib/factories/Style_Instance.php rename to lib/Factories/Style_Instance.php index 3d60894..d48f357 100644 --- a/lib/factories/Style_Instance.php +++ b/lib/Factories/Style_Instance.php @@ -7,11 +7,11 @@ */ -namespace Underpin_Styles\Factories; +namespace Underpin\Styles\Factories; use Underpin\Traits\Instance_Setter; -use Underpin_Styles\Abstracts\Style; +use Underpin\Styles\Abstracts\Style; if ( ! defined( 'ABSPATH' ) ) { exit; diff --git a/lib/loaders/Styles.php b/lib/Loaders/Styles.php similarity index 83% rename from lib/loaders/Styles.php rename to lib/Loaders/Styles.php index b647d95..9a94f27 100644 --- a/lib/loaders/Styles.php +++ b/lib/Loaders/Styles.php @@ -7,12 +7,12 @@ */ -namespace Underpin_Styles\Loaders; +namespace Underpin\Styles\Loaders; use Underpin\Abstracts\Registries\Object_Registry; -use Underpin_Styles\Abstracts\Style; +use Underpin\Loaders\Logger; +use Underpin\Styles\Abstracts\Style; use WP_Error; -use function Underpin\underpin; if ( ! defined( 'ABSPATH' ) ) { exit; @@ -30,9 +30,9 @@ class Styles extends Object_Registry { /** * @inheritDoc */ - protected $abstraction_class = '\Underpin_Styles\Abstracts\Style'; + protected $abstraction_class = '\Underpin\Styles\Abstracts\Style'; - protected $default_factory = '\Underpin_Styles\Factories\Style_Instance'; + protected $default_factory = '\Underpin\Styles\Factories\Style_Instance'; /** * @inheritDoc @@ -65,7 +65,7 @@ public function enqueue( $handle ) { return true; } else { - return underpin()->logger()->log_as_error( + return Logger::log_as_error( 'error', 'style_not_enqueued', 'The specified style could not be enqueued because it has not been registered.', diff --git a/styles.php b/styles.php deleted file mode 100644 index 0b94da6..0000000 --- a/styles.php +++ /dev/null @@ -1,21 +0,0 @@ - function ( Underpin $plugin, $args ) { - require_once( plugin_dir_path( __FILE__ ) . 'lib/abstracts/Style.php' ); - require_once( plugin_dir_path( __FILE__ ) . 'lib/loaders/Styles.php' ); - require_once( plugin_dir_path( __FILE__ ) . 'lib/factories/Style_Instance.php' ); - require_once( plugin_dir_path( __FILE__ ) . 'lib/factories/Enqueue_Admin_Style.php' ); - require_once( plugin_dir_path( __FILE__ ) . 'lib/factories/Enqueue_Style.php' ); - $plugin->loaders()->add( 'styles', [ - 'class' => 'Underpin_Styles\Loaders\Styles', - ] ); - }, -] ) ); \ No newline at end of file