diff --git a/composer.json b/composer.json index 9966ce13264ed5f2c626b507cd51ee1cc38eeb71..3f5823609ab22cd55dff4bc179d7ba1fa39ed7db 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 19bafd9be73f7ca8f4d6fe7f8b8ba45eb3c37d0c..fb1495ad62b30858b40f12ca9171edb7a6f0fb4e 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 d05c133606fc4f20ce613b12a8dc9a6116d10650..3028fc116a80e119b7ae4c15ae9816d4b7fc11ad 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 635b530773c3aa430451fdc447ebcf66844c58bc..5a4d25830102403018e5c02b034d77261b056dce 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(); /**