Skip to content

Commit 8322c95

Browse files
author
hsehszroc
committed
added template content files
1 parent f80451a commit 8322c95

File tree

3 files changed

+461
-0
lines changed

3 files changed

+461
-0
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?php
2+
/**
3+
* Template file to display content on hooks & filters tab
4+
*
5+
* @since 1.0
6+
*
7+
* @package tws-core
8+
* @subpackage framework
9+
* @category template
10+
*
11+
* -----------------------------------
12+
* DEVELOPED-MAINTAINED-SUPPPORTED BY
13+
* -----------------------------------
14+
* ███║ ███╗ ████████████████
15+
* ███║ ███║ ═════════██████╗
16+
* ███║ ███║ ╔══█████═╝
17+
* ████████████║ ╚═█████
18+
* ███║═════███║ █████╗
19+
* ███║ ███║ █████═╝
20+
* ███║ ███║ ████████████████╗
21+
* ╚═╝ ╚═╝ ═══════════════╝
22+
*/
23+
namespace TheWebSolver\Plugin\Core\Framework;
24+
25+
// exit if file is accessed directly
26+
if( ! defined( 'ABSPATH' ) ) exit;
27+
28+
?>
29+
<div id="hzfex_hooks_filters">
30+
<div class="hooks_head">
31+
<h2>Modify/Extend plugin with WordPress Hooks and Filters.</h2>
32+
<p>The main plugin files have various action and filter hooks that you can use to modify it's output.</p>
33+
<p>Check different files that use hooks and filters to know more.</p>
34+
</div>
35+
<div class="hooks_content callback_content_wrapper">
36+
<hr>
37+
<div class="component_class">
38+
<h4>Available in file: <code><pre>setting/setting-component.php</pre></code></h4>
39+
<ul>
40+
<li class="filter">
41+
<p><b>Filter Hook:</b>Force change all submenu page user capability at once</p>
42+
<small><em>This can be useful for forcing all submenu pages accessible to users that have a particular capability instead of changing `cap` value from each child-class.</em></small>
43+
<p>Paramter passed: <b>$cap -> user capability</b></p>
44+
<code>hzfex_set_setting_page_capability</code>
45+
</li>
46+
<li class="filter">
47+
<p><b>Filter Hook:</b>Force change menu slug for all child-class submenu pages at once</p>
48+
<small><em>Useful if want to get all child-class to have same main menu even though it had different menu set.</em></small>
49+
<p>Paramter passed: <b>$menu -> main menu slug</b></p>
50+
<code>hzfex_set_setting_main_menu_slug</code>
51+
</li>
52+
<li class="action">
53+
<p><b>Action Hook:</b>After successful hooking as submenu page</p>
54+
<small><em>This hook is present just after <code>admin_menu</code> hook. Use it as you need.</em></small>
55+
<p>Paramter passed: <b>$class -> child-class object -|- $page -> child-class submenu page array args</b></p>
56+
<code>hzfex_setting_framework_loaded</code>
57+
</li>
58+
<li class="action">
59+
<p><b>Action Hook:</b>After successful loading of each submenu page</p>
60+
<small><em>This hook is present just after <code>load-{submenu_page}</code> hook. Accessible to only child-class pages and not available globally.</em></small>
61+
<br><code>hzfex_setting_framework_page_loaded</code>
62+
</li>
63+
<li class="filter">
64+
<p><b>Filter Hook:</b>Display section tabs if page has a single section?</p>
65+
<small><em>This hook controls whether or not to show section tabs if page has only one section. <br>Hint: This page has four section tabs.</em></small>
66+
<p>Paramter passed: <b>$show -> boolean: default is false</b></p>
67+
<code>hzfex_show_setting_sections_nav_if_single</code>
68+
</li>
69+
<li class="filter">
70+
<p><b>Filter Hook:</b>Modify setting page navigation links</p>
71+
<small><em>This hook can let you modify page navigation links on left. (maybe use it to add other admin page link, or even external links).</em></small>
72+
<p>Paramter passed: <b>$nav -> array of navigation links data</b></p>
73+
<code>hzfex_set_setting_page_nav_links</code>
74+
</li>
75+
<li class="filter">
76+
<p><b>Filter Hook:</b>Modify setting page head image</p>
77+
<small><em>This hook can let you modify header image (currently set to <b>big white gear image</b> on green background).</em></small>
78+
<p>Paramter passed: <b>$head_image -> URL link to head image</b></p>
79+
<code>hzfex_set_setting_page_head_image</code>
80+
</li>
81+
<li class="filter">
82+
<p><b>Filter Hook:</b>Modify setting zpage head title</p>
83+
<small><em>This hook can let you modify header title (currently set to <b>TWS Setting Framework</b> below big white gear image).</em></small>
84+
<p>Paramter passed: <b>$head_title -> title that will be displayed in <code><?= htmlspecialchars( '<h1>' ); ?></code> tag</b></p>
85+
<code>hzfex_set_setting_head_title</code>
86+
</li>
87+
<li class="action">
88+
<p><b>Action Hook:</b>Add contents before page head</p>
89+
<small><em>This hook is present above the setting page head. Use it as you need.</em></small>
90+
<br><code>hzfex_before_setting_page_head</code>
91+
</li>
92+
<li class="action">
93+
<p><b>Action Hook:</b>Add contents after page head</p>
94+
<small><em>This hook is present below the setting page head. Use it as you need.</em></small>
95+
<br><code>hzfex_after_setting_page_head</code>
96+
</li>
97+
<li class="action">
98+
<p><b>Action Hook:</b>Add contents before page navigation</p>
99+
<small><em>This hook is present above the setting page navigation. Use it as you need.</em></small>
100+
<br><code>hzfex_before_setting_page_nav</code>
101+
</li>
102+
<li class="action">
103+
<p><b>Action Hook:</b>Add contents after page navigation</p>
104+
<small><em>This hook is present below the setting page navigation. Use it as you need.</em></small>
105+
<br><code>hzfex_after_setting_page_nav</code>
106+
</li>
107+
<li class="filter">
108+
<p><b>Filter Hook:</b>Extend each setting section fields <small><em>(not the recommended way)</em></small></p>
109+
<small><em>Highly recommended to add all fields from child-class <b>protected function sections()</b>. Use this filter only to add new fields to already an existing section added by others, just in case.</em></small>
110+
<p>Paramter passed: <b>$section_fields -> array of section fields that belong to particular $section_id</b></p>
111+
<code>hzfex_setting_<b>{$section_id}</b>_fields</code>
112+
</li>
113+
</ul>
114+
</div>
115+
<hr>
116+
<div class="api_class">
117+
<h4>Available in file: <code><pre>setting/setting-api.php</pre></code></h4>
118+
<ul>
119+
<li class="action">
120+
<p><b>Action Hook:</b>Content before form fields</p>
121+
<small><em>This hook is present below section callback and above the section title. Use it as you need.</em></small>
122+
<p>Paramter passed: <b>$section -> array of $section data</b></p>
123+
<code>hzfex_before_<b>{$section['id']}</b>_fields</code>
124+
</li>
125+
<li class="action">
126+
<p><b>Action Hook:</b>Content after form fields</p>
127+
<small><em>This hook is present below the section form fields and above the submit button. Use it as you need.</em></small>
128+
<p>Paramter passed: <b>$section -> array of $section data</b></p>
129+
<code>hzfex_after_<b>{$section['id']}</b>_fields</code>
130+
</li>
131+
</ul>
132+
</div>
133+
</div>
134+
</div>
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
<?php
2+
/**
3+
* Template file to display content on recommendations tab
4+
*
5+
* @since 1.0
6+
*
7+
* @package tws-core
8+
* @subpackage framework
9+
* @category template
10+
*
11+
* -----------------------------------
12+
* DEVELOPED-MAINTAINED-SUPPPORTED BY
13+
* -----------------------------------
14+
* ███║ ███╗ ████████████████
15+
* ███║ ███║ ═════════██████╗
16+
* ███║ ███║ ╔══█████═╝
17+
* ████████████║ ╚═█████
18+
* ███║═════███║ █████╗
19+
* ███║ ███║ █████═╝
20+
* ███║ ███║ ████████████████╗
21+
* ╚═╝ ╚═╝ ═══════════════╝
22+
*/
23+
namespace TheWebSolver\Plugin\Core\Framework;
24+
25+
// exit if file is accessed directly
26+
if( ! defined( 'ABSPATH' ) ) exit;
27+
28+
$anchor = '
29+
"commentAnchors.tags.list": [
30+
31+
{
32+
"tag": "ANCHOR",
33+
"iconColor": "default",
34+
"highlightColor": "#A8C023",
35+
"scope": "workspace"
36+
},
37+
{
38+
"tag": "TODO",
39+
"iconColor": "#ff0303",
40+
"highlightColor": "#ff0303",
41+
"scope": "workspace"
42+
},
43+
{
44+
"tag": "FIXME",
45+
"iconColor": "#952694",
46+
"highlightColor": "#952694",
47+
"scope": "workspace"
48+
},
49+
{
50+
"tag": "STUB",
51+
"iconColor": "purple",
52+
"highlightColor": "#BA68C8",
53+
"scope": "file"
54+
},
55+
{
56+
"tag": "NOTE",
57+
"iconColor": "#FFB300",
58+
"highlightColor": "#FFB300",
59+
"scope": "workspace"
60+
},
61+
{
62+
"tag": "DEBUG",
63+
"iconColor": "#FFB300",
64+
"highlightColor": "#FFB300",
65+
"scope": "workspace"
66+
},
67+
{
68+
"tag": "REVIEW",
69+
"iconColor": "#237625",
70+
"highlightColor": "#237625",
71+
"scope": "workspace"
72+
},
73+
{
74+
"tag": "SECTION",
75+
"iconColor": "blurple",
76+
"highlightColor": "#896afc",
77+
"scope": "workspace",
78+
"isRegion": true
79+
},
80+
{
81+
"tag": "TEMPLATE",
82+
"iconColor": "#01579b",
83+
"highlightColor": "#01579b",
84+
"scope": "workspace",
85+
},
86+
{
87+
"tag": "WPHOOK",
88+
"iconColor": "#14dcc9",
89+
"highlightColor": "#14dcc9",
90+
"scope": "workspace",
91+
}
92+
]
93+
';
94+
95+
//Declare the custom function for formatting
96+
function pretty_print($json_data) {
97+
98+
//Initialize variable for adding space
99+
$space = 0;
100+
$flag = false;
101+
102+
//Using <pre> tag to format alignment and font
103+
echo '<pre style="line-height:1em;display:block;padding:10px;margin: 10px auto;border-radius:5px;background:rgba(213, 0, 0, 0.1);">';
104+
105+
//loop for iterating the full json data
106+
for($counter=0; $counter<strlen($json_data); $counter++)
107+
{
108+
109+
//Checking ending second and third brackets
110+
if ( $json_data[$counter] == '}' || $json_data[$counter] == ']' )
111+
{
112+
$space--;
113+
echo "\n";
114+
echo str_repeat(' ', ($space*2));
115+
}
116+
117+
118+
//Checking for double quote(“) and comma (,)
119+
if ( $json_data[$counter] == '"' && ($json_data[$counter-1] == ',' ||
120+
$json_data[$counter-2] == ',') )
121+
{
122+
echo "\n";
123+
echo str_repeat(' ', ($space*2));
124+
}
125+
if ( $json_data[$counter] == '"' && !$flag )
126+
{
127+
if ( $json_data[$counter-1] == ':' || $json_data[$counter-2] == ':' )
128+
129+
//Add formatting for question and answer
130+
echo '<span style="color:var(--primary);font-weight:bold">';
131+
else
132+
133+
//Add formatting for answer options
134+
echo '<span style="color:var(--secondary);">';
135+
}
136+
echo $json_data[$counter];
137+
//Checking conditions for adding closing span tag
138+
if ( $json_data[$counter] == '"' && $flag )
139+
echo '</span>';
140+
if ( $json_data[$counter] == '"' )
141+
$flag = !$flag;
142+
143+
//Checking starting second and third brackets
144+
if ( $json_data[$counter] == '{' || $json_data[$counter] == '[' )
145+
{
146+
$space++;
147+
echo "\n";
148+
echo str_repeat(' ', ($space*2));
149+
}
150+
}
151+
echo '</pre>';
152+
}
153+
154+
?>
155+
156+
<div id="hzfex_recommendations">
157+
<div class="recommend_head">
158+
<h2>Recommended setup to use this plugin.</h2>
159+
<p>This plugin can be best coded using the following recommended setup.</p>
160+
</div>
161+
<div class="recommend_content callback_content_wrapper">
162+
<hr>
163+
<div class="setup_environment">
164+
<h4>Setup environment for coding: <code><pre>Visual Studio Code</pre></code></h4>
165+
<ul>
166+
<li class="filter">
167+
<p><b>Extension: WordPress Snippets -></b> Snippet for every WordPress function, class and constant</p>
168+
<small><em>Use the extension <a href="https://github.com/jason-pomerleau/vscode-wordpress-toolbox" target="_blank">WordPress Snippets</a> to view every WordPress function, class and constant. Easy auto-completion with type hints and tab stops in all the right places.</em></small>
169+
</li>
170+
<li class="filter">
171+
<p><b>Extension: PHP Intelephense -></b>PHP code intelligence for Visual Studio Code</p>
172+
<small><em>Use the extension <a href="https://github.com/bmewburn/vscode-intelephense" target="_blank">PHP Intelephense</a> as Intelephense is a high performance PHP language server packed full of essential features for productive PHP development.</em></small>
173+
</li>
174+
<li class="filter">
175+
<p><b>Font: Fira Code -></b>Free monospaced font with programming ligatures</p>
176+
<small><em>Use the font <a href="https://github.com/tonsky/FiraCode" target="_blank">Fira Code</a> as a better coding font that supports Programming Ligatures. Download and install to your OS and then use as VS Code font family.</em></small>
177+
</li>
178+
<li class="filter">
179+
<p><b>Extension: Comment Anchors -></b> View all available anchor tags in a file/workspace</p>
180+
<small><em>Use the extension <a href="https://github.com/ExodiusStudios/vscode-comment-anchors" target="_blank">Comment Anchors</a> to view TODO | NOTE | WPHOOK | DEBUG, etc. anchors so that you can find and navigate to different sections of files in this plugin easily. Follow the steps of this extension's readme file on the github page on how to add new anchor tags.</em><br>Then, add following lines on Visual Studio code settings (in JSON Format):</small>
181+
<?= pretty_print( $anchor ); ?>
182+
</li>
183+
</ul>
184+
</div>
185+
<hr>
186+
<div class="wordpress_environment">
187+
<h4>Setup environment for WordPresss: <code><pre>Plugins</pre></code></h4>
188+
<ul>
189+
<li class="action">
190+
<p><b>Plugin: Show Hooks -></b> View all action/filter hooks availble on WordPress</p>
191+
<small><em>Use the plugin <a href="https://wordpress.org/plugins/show-hooks" target="_blank">Show Hooks</a> to see all existing hooks as well as hooks added by this plugin.</em></small>
192+
</li>
193+
</ul>
194+
</div>
195+
</div>
196+
</div>

0 commit comments

Comments
 (0)