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
27f8c40c
Commit
27f8c40c
authored
6 years ago
by
Grzegorz Rola
Browse files
Options
Downloads
Patches
Plain Diff
Added Template trait.
parent
57f32a5f
No related branches found
No related tags found
1 merge request
!12
Feature/plugin activation
Pipeline
#7286
failed
6 years ago
Stage: tools
Stage: tests
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/BuildDirector/LegacyBuildDirector.php
+1
-1
1 addition, 1 deletion
src/BuildDirector/LegacyBuildDirector.php
src/Plugin/Template.php
+61
-0
61 additions, 0 deletions
src/Plugin/Template.php
with
62 additions
and
1 deletion
src/BuildDirector/LegacyBuildDirector.php
+
1
−
1
View file @
27f8c40c
...
...
@@ -27,7 +27,7 @@ class LegacyBuildDirector {
}
/**
* Returns built plugin
* Returns built plugin
PluginAccess.php
*
* @return AbstractPlugin
*/
...
...
This diff is collapsed.
Click to expand it.
src/Plugin/Template.php
0 → 100644
+
61
−
0
View file @
27f8c40c
<?php
namespace
WPDesk\PluginBuilder\Plugin
;
trait
Template
{
/**
* Plugin path.
*
* @var string
*/
public
$plugin_path
;
/**
* Template path.
*
* @var string
*/
public
$template_path
;
/**
* Init base variables for plugin
*/
public
function
init_template_base_variables
()
{
$this
->
plugin_path
=
$this
->
plugin_info
->
get_plugin_dir
();
$this
->
template_path
=
$this
->
plugin_info
->
get_text_domain
();
}
/**
* Renders end returns selected template
*
* @param string $name Name of the template.
* @param string $path Additional inner path to the template.
* @param array $args args Accessible from template.
*
* @return string
*/
public
function
load_template
(
$name
,
$path
=
''
,
$args
=
array
()
)
{
$plugin_template_path
=
trailingslashit
(
$this
->
plugin_path
)
.
'templates/'
;
// Look within passed path within the theme - this is priority.
$template
=
locate_template
(
array
(
trailingslashit
(
$this
->
get_template_path
()
)
.
trailingslashit
(
$path
)
.
$name
.
'.php'
,
)
);
if
(
!
$template
)
{
$template
=
$plugin_template_path
.
trailingslashit
(
$path
)
.
$name
.
'.php'
;
}
extract
(
$args
);
ob_start
();
include
(
$template
);
return
ob_get_clean
();
}
}
\ No newline at end of file
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