Skip to content
Snippets Groups Projects
Commit 285a13c8 authored by Dyszczo's avatar Dyszczo
Browse files

Merge branch 'feature/hookable-object' into 'master'

AbstractPlugin should be as simple as possible and do not modified!!

See merge request !9
parents 9f14f5e5 6745d062
No related branches found
No related tags found
1 merge request!9AbstractPlugin should be as simple as possible and do not modified!!
Pipeline #7139 failed
...@@ -3,12 +3,17 @@ ...@@ -3,12 +3,17 @@
namespace WPDesk\PluginBuilder\Plugin; namespace WPDesk\PluginBuilder\Plugin;
/** /**
* Base plugin class for WP Desk plugins * Base plugin class for WP Desk plugins.
* *
* @author Grzegorz * *************************************************************
* * Important! This class should be not modified! *
* * This class is loaded at startup from first loaded plugin! *
* *************************************************************
*
* @author Grzegorz, Dyszczo
* *
*/ */
abstract class AbstractPlugin implements \WPDesk_Translable, HookableCollection { abstract class AbstractPlugin implements \WPDesk_Translable {
/** @var \WPDesk_Plugin_Info */ /** @var \WPDesk_Plugin_Info */
protected $plugin_info; protected $plugin_info;
...@@ -25,11 +30,6 @@ abstract class AbstractPlugin implements \WPDesk_Translable, HookableCollection ...@@ -25,11 +30,6 @@ abstract class AbstractPlugin implements \WPDesk_Translable, HookableCollection
/** @var string */ /** @var string */
protected $settings_url; protected $settings_url;
/**
* @var array[Hookable]
*/
private $hookable_objects = array();
/** /**
* AbstractPlugin constructor. * AbstractPlugin constructor.
* *
...@@ -40,33 +40,19 @@ abstract class AbstractPlugin implements \WPDesk_Translable, HookableCollection ...@@ -40,33 +40,19 @@ abstract class AbstractPlugin implements \WPDesk_Translable, HookableCollection
$this->plugin_namespace = strtolower( $plugin_info->get_plugin_dir() ); $this->plugin_namespace = strtolower( $plugin_info->get_plugin_dir() );
} }
/**
* Init.
*/
public function init() { public function init() {
$this->init_base_variables(); $this->init_base_variables();
$this->hooks();
} }
public function init_base_variables() { public function init_base_variables() {
$this->plugin_url = plugin_dir_url( $this->plugin_info->get_plugin_dir() ); $this->plugin_url = plugin_dir_url( $this->plugin_info->get_plugin_dir() );
} }
/**
* Add hookable object.
*
* @param Hookable|HookablePluginDependant $hookable_object Hookable object.
*/
public function add_hookable( $hookable_object ) {
if ( $hookable_object instanceof HookablePluginDependant ) {
$hookable_object->set_plugin( $this );
}
$this->hookable_objects[] = $hookable_object;
}
/** /**
* @return void * @return void
*/ */
public function hooks() { protected function hooks() {
add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
add_action( 'wp_enqueue_scripts', [ $this, 'wp_enqueue_scripts' ] ); add_action( 'wp_enqueue_scripts', [ $this, 'wp_enqueue_scripts' ] );
...@@ -76,10 +62,6 @@ abstract class AbstractPlugin implements \WPDesk_Translable, HookableCollection ...@@ -76,10 +62,6 @@ abstract class AbstractPlugin implements \WPDesk_Translable, HookableCollection
$this, $this,
'links_filter' 'links_filter'
] ); ] );
/** @var Hookable $hookable_object */
foreach ( $this->hookable_objects as $hookable_object ) {
$hookable_object->hooks();
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment