Skip to content

Commit cb2e2e7

Browse files
author
hsehszroc
committed
added child-class Without_Fields file
1 parent 1ca6b31 commit cb2e2e7

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

templates/without-fields.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/**
3+
* Submenu page with menu title as "Welcome" under main menu "The Web Solver"
4+
*
5+
* @since 1.0
6+
*
7+
* @package tws-core
8+
* @subpackage framework
9+
* @category wordpress-setting-api
10+
*
11+
* -----------------------------------
12+
* DEVELOPED-MAINTAINED-SUPPPORTED BY
13+
* -----------------------------------
14+
* ███║ ███╗ ████████████████
15+
* ███║ ███║ ═════════██████╗
16+
* ███║ ███║ ╔══█████═╝
17+
* ████████████║ ╚═█████
18+
* ███║═════███║ █████╗
19+
* ███║ ███║ █████═╝
20+
* ███║ ███║ ████████████████╗
21+
* ╚═╝ ╚═╝ ═══════════════╝
22+
*/
23+
24+
namespace TheWebSolver\Plugin\Core\Framework;
25+
26+
// Exit if accessed directly
27+
if ( ! defined( 'ABSPATH' ) ) exit;
28+
29+
final class Without_Fields extends Setting_Component {
30+
31+
/** Constructor */
32+
public function __construct() {
33+
parent::__construct(
34+
[
35+
__CLASS__ => [
36+
'menu_slug' => '', // uses default if not set
37+
'page_title' => __( 'Welcome', 'tws-core' ),
38+
'menu_title' => __( 'Welcome', 'tws-core' ),
39+
'cap' => 'read', // wordpress user capability to view page and edit/update page section fields
40+
'slug' =>'tws_without_fields_page', // submenu page slug
41+
'icon' => HZFEX_Setting_Framework_Url . 'assets/graphics/files-icon.svg', // icon that displays on before page navigation title (files icon before page title Welcome)
42+
]
43+
]
44+
);
45+
}
46+
47+
protected function sections() {
48+
$sections = [
49+
'welcome' => [
50+
'title' => __( 'Getting Started', 'tws-core' ),
51+
'tab_title' => __( 'Getting Started', 'tws-core' ),
52+
'desc' => 'Some description',
53+
'callback' => [ $this, 'welcome_callback' ], // callback can be used this way
54+
],
55+
'hooks' => [
56+
'title' => __( 'Hooks/Filters', 'tws-core' ),
57+
'tab_title' => __( 'Hooks & Filters', 'tws-core' ),
58+
'callback' => function() { if( file_exists( HZFEX_Setting_Framework_Path. 'templates/contents/hooks-filters.php' ) ) include_once HZFEX_Setting_Framework_Path. 'templates/contents/hooks-filters.php'; }, // callback can be used this way also
59+
],
60+
'recommendation' => [
61+
'title' => __( 'Recommendation', 'tws-core' ),
62+
'tab_title' => __( 'Recommended Setup', 'tws-core' ),
63+
'callback' => function() { if( file_exists( HZFEX_Setting_Framework_Path . 'templates/contents/recommendations.php' ) ) include_once HZFEX_Setting_Framework_Path . 'templates/contents/recommendations.php'; },
64+
],
65+
'tws_mixed_section' => [
66+
'title' => __( 'This title is only visible when fields are set.', 'tws-core' ), // only shows when "fields" are set.
67+
'tab_title' => __( 'Ready to Go?', 'tws-core' ),
68+
'desc' => sprintf( '<div>%1$s</div><div><small><em>%2$s <code>templates/with-fields.php</code></em></small></div>',
69+
__( 'This description is only visible when fields are set.', 'tws-core' ),
70+
__( 'Enabling the switch below (actually it is a checkbox field type with style customization) will instantiate another child class on file', 'tws-core' ),
71+
), // only shows when "fields" are set.
72+
'callback' => function() { echo 'This is just a callback like other three section tabs in this page.'; },
73+
'fields' => [
74+
'tws_enable_fields' => [
75+
'label' => __( 'Enable another child-class?', 'tws-core' ),
76+
'desc' => __( 'You should definitely enable this to test other types of input fields.', 'tws-core' ),
77+
'type' => 'checkbox',
78+
'class' => 'hz_switcher_control',
79+
'default' => 'off'
80+
],
81+
],
82+
],
83+
];
84+
85+
return $sections;
86+
}
87+
88+
public function welcome_callback() {
89+
if( file_exists( HZFEX_Setting_Framework_Path. 'templates/contents/welcome.php' ) ) include_once HZFEX_Setting_Framework_Path. 'templates/contents/welcome.php';
90+
}
91+
}
92+
93+
// initialize this submenu page.
94+
new Without_Fields();

0 commit comments

Comments
 (0)