Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base functionality of the modified date control plugin #4

Merged
merged 18 commits into from
Aug 7, 2024
Merged
Prev Previous commit
Next Next commit
Moving to a feature and adding a hookable feature class
srtfisher committed Aug 2, 2024
commit 86e800d306efd551f0ea1ff08a62b2cec5e25553
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -16,7 +16,8 @@
],
"require": {
"php": "^8.1",
"alleyinteractive/composer-wordpress-autoloader": "^1.0"
"alleyinteractive/composer-wordpress-autoloader": "^1.0",
"alleyinteractive/wp-type-extensions": "^2.2"
},
"require-dev": {
"alleyinteractive/alley-coding-standards": "^2.0",
28 changes: 28 additions & 0 deletions src/class-hookable-feature.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Hookable_Feature class file
*
* @package wp-modified-date-control
*/

namespace Alley\WP\Modified_Date_Control;

use Alley\WP\Types\Feature;
use Mantle\Support\Traits\Hookable;

/**
* Feature class that when booted will setup the hooks for the feature via the
* "Hookable" trait.
*
* @link https://mantle.alley.com/docs/features/support/hookable
*/
abstract class Hookable_Feature implements Feature {
use Hookable;

/**
* Boot the feature.
*/
public function boot(): void {
$this->register_hooks();
}
}
18 changes: 3 additions & 15 deletions src/class-manager.php → src/class-modified-date-feature.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
<?php
/**
* Manager class file
* Modified_Date_Feature class file
*
* @package wp-modified-date-control
*/

namespace Alley\WP\Modified_Date_Control;

use Mantle\Support\Attributes\Filter;
use Mantle\Support\Traits\Hookable;
use Mantle\Support\Traits\Singleton;
use WP_REST_Request;

/**
* Modified Date Control functionality.
* Modified Date Control Feature
*/
class Manager {
use Hookable;
use Singleton;

class Modified_Date_Feature extends Hookable_Feature {
/**
* REST Request from the dispatcher.
*
* @var WP_REST_Request|null
*/
protected ?WP_REST_Request $rest_request = null;

/**
* Constructor.
*/
protected function __construct() {
$this->register_hooks();
}

/**
* Listen for REST requests to update the modified date.
*
11 changes: 6 additions & 5 deletions wp-modified-date-control.php
Original file line number Diff line number Diff line change
@@ -6,17 +6,18 @@
* Version: 0.0.0
* Author: Sean Fisher
* Author URI: https://github.com/alleyinteractive/wp-modified-date-control
* Requires at least: 5.9
* Tested up to: 6.2
* Requires at least: 6.0
* Tested up to: 6.6
*
* Text Domain: wp-modified-date-control
* Domain Path: /languages/
*
* @package wp-modified-date-control
*/

namespace Alley\WP\Modified_Date_Control;

use Alley\WP\Features\Group;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@@ -58,5 +59,5 @@ function () {
// Load the plugin's assets.
load_scripts();

// Load the plugin's manager.
Manager::instance();
// Load the plugin's features.
( new Group( new Modified_Date_Feature() ) )->boot();