From 3075f8a23bed0a1e98fec6dc1497cf552b84ed07 Mon Sep 17 00:00:00 2001 From: Alex Standiford Date: Sun, 21 Nov 2021 19:05:59 -0600 Subject: [PATCH 1/3] Compat for Underpin 2.0.0 --- roles.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/roles.php b/roles.php index 4f9bc50..ce78661 100644 --- a/roles.php +++ b/roles.php @@ -1,14 +1,22 @@ get( $file, $class )->loaders()->add( 'roles', [ - 'instance' => 'Underpin_Roles\Abstracts\Role', - 'default' => 'Underpin_Roles\Factories\Role_Instance', - ] ); -}, 10, 2 ); \ No newline at end of file +Underpin::attach( 'setup', new \Underpin\Factories\Observer( 'roles', [ + 'update' => function ( Underpin $plugin, $args ) { + require_once( plugin_dir_path( __FILE__ ) . 'Role.php' ); + require_once( plugin_dir_path( __FILE__ ) . 'Role_Instance.php' ); + $plugin->loaders()->add( 'roles', [ + 'name' => 'Roles', + 'description' => 'Handles setting custom roles in WordPress', + 'instance' => 'Underpin_Roles\Abstracts\Role', + 'default' => 'Underpin_Roles\Factories\Role_Instance', + ] ); + }, + ] ) +); \ No newline at end of file From 45c2b30b32535b39c85636d81a4e06052e4c9e92 Mon Sep 17 00:00:00 2001 From: Alex Standiford Date: Mon, 22 Nov 2021 06:37:13 -0600 Subject: [PATCH 2/3] Corrects composer.json --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 963315d..d229f25 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,9 @@ "email": "a@alexstandiford.com" } ], + "require": { + "underpin/underpin": "^2.0" + }, "autoload": { "files": [ "roles.php" From 53caf230d01358bdd70a0cc71efada4f8bf6ee73 Mon Sep 17 00:00:00 2001 From: Alex Standiford Date: Tue, 23 Nov 2021 08:21:53 -0600 Subject: [PATCH 3/3] Corrects composer.json --- bootstrap.php | 15 +++++++++++++ composer.json | 3 ++- Role.php => lib/Abstracts/Role.php | 2 +- .../Factories/Role_Instance.php | 4 ++-- roles.php | 22 ------------------- 5 files changed, 20 insertions(+), 26 deletions(-) create mode 100644 bootstrap.php rename Role.php => lib/Abstracts/Role.php (94%) rename Role_Instance.php => lib/Factories/Role_Instance.php (75%) delete mode 100644 roles.php diff --git a/bootstrap.php b/bootstrap.php new file mode 100644 index 0000000..4a26038 --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,15 @@ + 'Roles', + 'description' => 'Handles setting custom roles in WordPress', + 'instance' => 'Underpin\Roles\Abstracts\Role', + 'default' => 'Underpin\Roles\Factories\Role_Instance', +] ) ); \ No newline at end of file diff --git a/composer.json b/composer.json index d229f25..5384e1d 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,9 @@ "underpin/underpin": "^2.0" }, "autoload": { + "psr-4": {"Underpin\\Roles\\": "lib/"}, "files": [ - "roles.php" + "bootstrap.php" ] } } diff --git a/Role.php b/lib/Abstracts/Role.php similarity index 94% rename from Role.php rename to lib/Abstracts/Role.php index dcb8ddc..931f848 100644 --- a/Role.php +++ b/lib/Abstracts/Role.php @@ -6,7 +6,7 @@ * @package Underpin\Abstracts */ -namespace Underpin_Roles\Abstracts; +namespace Underpin\Roles\Abstracts; use Underpin\Traits\Feature_Extension; diff --git a/Role_Instance.php b/lib/Factories/Role_Instance.php similarity index 75% rename from Role_Instance.php rename to lib/Factories/Role_Instance.php index b29dc13..3ce6455 100644 --- a/Role_Instance.php +++ b/lib/Factories/Role_Instance.php @@ -1,10 +1,10 @@ function ( Underpin $plugin, $args ) { - require_once( plugin_dir_path( __FILE__ ) . 'Role.php' ); - require_once( plugin_dir_path( __FILE__ ) . 'Role_Instance.php' ); - $plugin->loaders()->add( 'roles', [ - 'name' => 'Roles', - 'description' => 'Handles setting custom roles in WordPress', - 'instance' => 'Underpin_Roles\Abstracts\Role', - 'default' => 'Underpin_Roles\Factories\Role_Instance', - ] ); - }, - ] ) -); \ No newline at end of file