From 47f95762228a6c30c58de7d966881293e0ed86ab Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Tue, 25 Sep 2018 20:07:12 +0200 Subject: [PATCH] init --- composer.json | 9 +++++---- src/Notice/AjaxHandler.php | 13 ++++++++++++- src/Notice/DismissibleNotice.php | 20 +++++++++++++++----- src/Notice/Notice.php | 10 +++++----- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 9966ce1..3f58236 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "wpdesk/wp-builder", + "name": "wpdesk/wp-notice", "authors": [ { "name": "GROla", @@ -8,8 +8,9 @@ ], "require": { "php": ">=5.5", - "wpdesk/wp-basic-requirements": "dev-master" - }, + "wpdesk/wp-basic-requirements": "dev-master", + "wpdesk/wp-builder": "dev-master" + }, "require-dev": { "phpunit/phpunit": "<7", "wp-coding-standards/wpcs": "^0.14.1", @@ -19,7 +20,7 @@ "wimg/php-compatibility": "^8" }, "autoload": { - "psr-4": {"WPDesk\\PluginBuilder\\": "src/"} + "psr-4": {"WPDesk\\Notice\\": "src/"} }, "autoload-dev": { }, diff --git a/src/Notice/AjaxHandler.php b/src/Notice/AjaxHandler.php index 19bafd9..fb1495a 100644 --- a/src/Notice/AjaxHandler.php +++ b/src/Notice/AjaxHandler.php @@ -2,15 +2,26 @@ namespace WPDesk\Notice; +use WPDesk\PluginBuilder\Plugin\HookablePluginDependant; +use WPDesk\PluginBuilder\Plugin\PluginAccess; + /** * Class Notice. * * @package WPDesk\Notice */ -class AjaxHandler +class AjaxHandler implements HookablePluginDependant { + use PluginAccess; + /** + * Hooks. + */ + public function hooks() + { + add_action(); + } } diff --git a/src/Notice/DismissibleNotice.php b/src/Notice/DismissibleNotice.php index d05c133..3028fc1 100644 --- a/src/Notice/DismissibleNotice.php +++ b/src/Notice/DismissibleNotice.php @@ -10,10 +10,10 @@ namespace WPDesk\Notice; class DismissibleNotice extends Notice { - /** - * @var string - */ - private $noticeDismissOptionName; + /** + * @var string + */ + private $noticeDismissOptionName; /** * WPDesk_Flexible_Shipping_Notice constructor. @@ -28,7 +28,17 @@ class DismissibleNotice extends Notice $this->noticeDismissOptionName = $noticeContent; } - protected + /** + * Get attributes as string. + * + * @return string + */ + protected function getAttributesAsString() + { + $attributesAsString = parent::getAttributesAsString(); + $attributesAsString .= sprintf('data-dismiss-option="%1$s"', esc_attr($this->noticeDismissOptionName)); + return $attributesAsString; + } } diff --git a/src/Notice/Notice.php b/src/Notice/Notice.php index 635b530..5a4d258 100644 --- a/src/Notice/Notice.php +++ b/src/Notice/Notice.php @@ -36,11 +36,11 @@ class Notice */ protected $isDismissible; - /** - * Attributes. - * - * @var string[] - */ + /** + * Attributes. + * + * @var string[] + */ protected $attributes = array(); /** -- GitLab