Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-builder
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-builder
Commits
c37630e4
Commit
c37630e4
authored
6 years ago
by
Grzegorz Rola
Browse files
Options
Downloads
Patches
Plain Diff
AbstractPlugin should be as simple as possible and do not modified!!
parent
dbe8965d
No related branches found
No related tags found
1 merge request
!9
AbstractPlugin should be as simple as possible and do not modified!!
Pipeline
#7092
failed
6 years ago
Stage: tools
Stage: tests
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/AbstractPlugin.php
+10
-28
10 additions, 28 deletions
src/Plugin/AbstractPlugin.php
with
10 additions
and
28 deletions
src/Plugin/AbstractPlugin.php
+
10
−
28
View file @
c37630e4
...
@@ -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, Dysczo
*
*
*/
*/
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
*/
*/
p
ublic
function
hooks
()
{
p
rotected
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
();
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment