Skip to content

Commit

Permalink
Corrects composer.json
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstandiford committed Nov 23, 2021
1 parent 3498de0 commit 2c96ba5
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 47 deletions.
11 changes: 11 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Underpin\Abstracts\Underpin;
use Underpin\Factories\Observers\Loader;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

// Add this loader.
Underpin::attach( 'setup', new Loader( 'styles', [ 'class' => 'Underpin\Styles\Loaders\Styles' ] ) );
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"underpin/underpin": "^2.0"
},
"autoload": {
"psr-4": {"Underpin\\Styles\\": "lib/"},
"files": [
"styles.php"
"bootstrap.php"
]
}
}
15 changes: 8 additions & 7 deletions lib/abstracts/Style.php → lib/Abstracts/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.',
Expand Down Expand Up @@ -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.',
Expand All @@ -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.',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php


namespace Underpin_Styles\Factories;
namespace Underpin\Styles\Factories;


use Underpin\Abstracts\Observer;
use Underpin\Abstracts\Storage;
use Underpin_Styles\Abstracts\Style;
use function Underpin\underpin;
use Underpin\Loaders\Logger;
use Underpin\Styles\Abstracts\Style;


if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand All @@ -22,9 +23,9 @@ public function update( $instance, Storage $args ) {
if ( $instance instanceof Style ) {
add_action( 'admin_enqueue_script', [ $instance, 'enqueue' ] );
} else {
underpin()->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',
] );
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php


namespace Underpin_Styles\Factories;
namespace Underpin\Styles\Factories;


use Underpin\Abstracts\Observer;
use Underpin\Abstracts\Storage;
use Underpin_Styles\Abstracts\Style;
use function Underpin\underpin;
use Underpin\Loaders\Logger;
use Underpin\Styles\Abstracts\Style;


if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand All @@ -22,9 +23,9 @@ public function update( $instance, Storage $args ) {
if ( $instance instanceof Style ) {
add_action( 'wp_enqueue_scripts', [ $instance, 'enqueue' ] );
} else {
underpin()->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',
] );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions lib/loaders/Styles.php → lib/Loaders/Styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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.',
Expand Down
21 changes: 0 additions & 21 deletions styles.php

This file was deleted.

0 comments on commit 2c96ba5

Please sign in to comment.