| 1 |
<?php |
| 2 |
/** |
| 3 |
* Page Structure in Admin Panel |
| 4 |
* |
| 5 |
* @version 1.2 |
| 6 |
* @package Any |
| 7 |
* @category Page Structure in Admin Panel |
| 8 |
* @author wpdevelop |
| 9 |
* |
| 10 |
* @web-site https://wpbookingcalendar.com/ |
| 11 |
* @email info@wpbookingcalendar.com |
| 12 |
* |
| 13 |
* @modified 2024-12-23, 2015-11-02 |
| 14 |
*/ |
| 15 |
|
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit; // Exit, if accessed directly. |
| 18 |
} |
| 19 |
|
| 20 |
// UI Parts. |
| 21 |
require_once WPBC_PLUGIN_DIR . '/includes/ui_settings/elements/ui_el__dropdown_menu.php'; |
| 22 |
require_once WPBC_PLUGIN_DIR . '/includes/ui_settings/elements/ui_el__a.php'; |
| 23 |
require_once WPBC_PLUGIN_DIR . '/includes/ui_settings/elements/ui_el__divider.php'; |
| 24 |
require_once WPBC_PLUGIN_DIR . '/includes/ui_settings/parts/ui__nav_top.php'; |
| 25 |
require_once WPBC_PLUGIN_DIR . '/includes/ui_settings/parts/ui__nav_vert.php'; |
| 26 |
require_once WPBC_PLUGIN_DIR . '/includes/ui_settings/parts/ui__nav_horis.php'; |
| 27 |
require_once WPBC_PLUGIN_DIR . '/includes/ui_settings/parts/ui__timeline_toolbar.php'; |
| 28 |
|
| 29 |
|
| 30 |
// FixIn: 11.0.0.1. |
| 31 |
|
| 32 |
/** |
| 33 |
* Define Settings Page Structure |
| 34 |
*/ |
| 35 |
class WPBC_Settings_Page_Parts { |
| 36 |
|
| 37 |
private $page_structure_obj; |
| 38 |
private $active_page; |
| 39 |
private $active_tab; |
| 40 |
private $active_subtab; |
| 41 |
|
| 42 |
/** |
| 43 |
* Constructor. |
| 44 |
* |
| 45 |
* @param array $template_params_arr - array( |
| 46 |
* 'active_page' => $page_tag, |
| 47 |
* 'active_tab' => $active_page_tab, |
| 48 |
* 'active_subtab' => $active_page_subtab, |
| 49 |
* 'page_structure_obj' => $this, |
| 50 |
* ). |
| 51 |
*/ |
| 52 |
public function __construct( $template_params_arr ) { |
| 53 |
|
| 54 |
$this->active_page = $template_params_arr['active_page']; |
| 55 |
$this->active_tab = $template_params_arr['active_tab']; |
| 56 |
$this->active_subtab = $template_params_arr['active_subtab']; |
| 57 |
$this->page_structure_obj = $template_params_arr['page_structure_obj']; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
/** |
| 62 |
* Show Template Header |
| 63 |
* |
| 64 |
* @return void |
| 65 |
*/ |
| 66 |
public function template_header() { |
| 67 |
|
| 68 |
$tabs_arr = $this->page_structure_obj->get_nav_tabs(); |
| 69 |
$current_page_params_arr = $this->page_structure_obj->get_current_page_params(); |
| 70 |
|
| 71 |
// ------------------------------------------------------------------------------------------------------------- |
| 72 |
// 'Left Sidebar' - By default it shoud be ''. Other options: '', 'min', 'compact', 'max'. |
| 73 |
// ------------------------------------------------------------------------------------------------------------- |
| 74 |
$left_navigation__default_view_mode = strval( $this->page_structure_obj->get_left_navigation_default_view_mode() ); |
| 75 |
$left_navigation__is_user_mode_enabled = $this->page_structure_obj->is_left_navigation_user_mode_enabled(); |
| 76 |
|
| 77 |
if ( ! empty( $left_navigation__default_view_mode ) ) { |
| 78 |
if ( 'none' === $left_navigation__default_view_mode ) { |
| 79 |
echo '<script type="text/javascript"> jQuery( document ).ready( function () { if ( "function" === typeof wpbc_admin_ui__sidebar_left__do_hide ) { wpbc_admin_ui__sidebar_left__do_hide(); } } ); </script>'; |
| 80 |
} |
| 81 |
if ( 'min' === $left_navigation__default_view_mode ) { |
| 82 |
echo '<script type="text/javascript"> jQuery( document ).ready( function () { if ( "function" === typeof wpbc_admin_ui__sidebar_left__do_min ) { wpbc_admin_ui__sidebar_left__do_min(); } } ); </script>'; |
| 83 |
} |
| 84 |
if ( 'compact' === $left_navigation__default_view_mode ) { |
| 85 |
echo '<script type="text/javascript"> jQuery( document ).ready( function () { if ( "function" === typeof wpbc_admin_ui__sidebar_left__do_compact ) { wpbc_admin_ui__sidebar_left__do_compact(); } } ); </script>'; |
| 86 |
} |
| 87 |
if ( 'max' === $left_navigation__default_view_mode ) { |
| 88 |
echo '<script type="text/javascript"> jQuery( document ).ready( function () { if ( "function" === typeof wpbc_admin_ui__sidebar_left__do_max ) { wpbc_admin_ui__sidebar_left__do_max(); } } ); </script>'; |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
// ------------------------------------------------------------------------------------------------------------- |
| 93 |
// 'Right Sidebar' - By default it shoud be ''. Other options: '', 'min', 'compact', 'max'. |
| 94 |
// ------------------------------------------------------------------------------------------------------------- |
| 95 |
$right_vertical_sidebar__is_show = $this->page_structure_obj->is_use_option__in_subtabs_or_tabs( 'right_vertical_sidebar__is_show' ); |
| 96 |
$right_vertical_sidebar__default_view_mode = strval( $this->page_structure_obj->is_use_option__in_subtabs_or_tabs( 'right_vertical_sidebar__default_view_mode' ) ); |
| 97 |
$right_vertical_sidebar__default_view_mode = ( ! empty( $right_vertical_sidebar__default_view_mode ) ) ? $right_vertical_sidebar__default_view_mode . '_right' : $right_vertical_sidebar__default_view_mode; |
| 98 |
|
| 99 |
if ( ! empty( $right_vertical_sidebar__default_view_mode ) ) { |
| 100 |
if ( 'none_right' === $right_vertical_sidebar__default_view_mode ) { |
| 101 |
echo '<script type="text/javascript"> jQuery( document ).ready( function () { if ( "function" === typeof wpbc_admin_ui__sidebar_right__do_hide ) { wpbc_admin_ui__sidebar_right__do_hide(); } } ); </script>'; |
| 102 |
} |
| 103 |
if ( 'min_right' === $right_vertical_sidebar__default_view_mode ) { |
| 104 |
echo '<script type="text/javascript"> jQuery( document ).ready( function () { if ( "function" === typeof wpbc_admin_ui__sidebar_right__do_min ) { wpbc_admin_ui__sidebar_right__do_min(); } } ); </script>'; |
| 105 |
} |
| 106 |
if ( 'compact_right' === $right_vertical_sidebar__default_view_mode ) { |
| 107 |
echo '<script type="text/javascript"> jQuery( document ).ready( function () { if ( "function" === typeof wpbc_admin_ui__sidebar_right__do_compact ) { wpbc_admin_ui__sidebar_right__do_compact(); } } ); </script>'; |
| 108 |
} |
| 109 |
if ( 'max_right' === $right_vertical_sidebar__default_view_mode ) { |
| 110 |
echo '<script type="text/javascript"> jQuery( document ).ready( function () { if ( "function" === typeof wpbc_admin_ui__sidebar_right__do_max ) { wpbc_admin_ui__sidebar_right__do_max(); } } ); </script>'; |
| 111 |
} |
| 112 |
} |
| 113 |
// ------------------------------------------------------------------------------------------------------------- |
| 114 |
|
| 115 |
|
| 116 |
// Top wrapper for admin pages. |
| 117 |
echo '<div class="wpbc_admin wpbc_page' . |
| 118 |
( ( $right_vertical_sidebar__is_show ) ? ' right_vertical_sidebar_displayed ' : '' ) . |
| 119 |
' wpbc_admin_page__tab__' . esc_attr( $this->active_tab ) . |
| 120 |
' wpbc_admin_page__subtab__' . esc_attr( $this->active_subtab ) . |
| 121 |
'">'; |
| 122 |
|
| 123 |
wpbc_ui__top_nav( |
| 124 |
array( |
| 125 |
'page_tag' => $this->active_page, |
| 126 |
'active_page_tab' => $this->active_tab, |
| 127 |
'active_page_subtab' => $this->active_subtab, |
| 128 |
'is_full_screen_user_mode_enabled' => $this->page_structure_obj->is_full_screen_user_mode_enabled(), |
| 129 |
) |
| 130 |
); |
| 131 |
|
| 132 |
// Fires Before showing settings Content page ( for example in setup Wizard for show_top_right_wizard_button ). |
| 133 |
do_action( 'wpbc_after_wpbc_page_top__header_tabs', $this->active_page, $this->active_tab, $this->active_subtab ); |
| 134 |
|
| 135 |
echo '<div class="wpbc_settings_page_wrapper ' . |
| 136 |
esc_attr( $left_navigation__default_view_mode ) . ' ' . |
| 137 |
esc_attr( $right_vertical_sidebar__default_view_mode ) . |
| 138 |
'" data-wpbc-left-sidebar-user-mode="' . esc_attr( $left_navigation__is_user_mode_enabled ? '1' : '0' ) . '">'; |
| 139 |
|
| 140 |
if ( $left_navigation__is_user_mode_enabled ) { |
| 141 |
$user_cust_option = 'left_sidebar_view_mode'; |
| 142 |
$nonce_action = $user_cust_option . '_nonce_act'; |
| 143 |
|
| 144 |
echo '<span id="wpbc_left_sidebar_view_mode_saver" style="display:none;"' . |
| 145 |
' data-wpbc-u-save-name="' . esc_attr( $user_cust_option ) . '"' . |
| 146 |
' data-wpbc-u-save-value="' . esc_attr( $left_navigation__default_view_mode ) . '"' . |
| 147 |
' data-wpbc-u-save-nonce="' . esc_attr( wp_create_nonce( $nonce_action ) ) . '"' . |
| 148 |
' data-wpbc-u-save-user-id="' . esc_attr( wpbc_get_current_user_id() ) . '"' . |
| 149 |
' data-wpbc-u-save-action="' . esc_attr( $nonce_action ) . '"' . |
| 150 |
'></span>'; |
| 151 |
} |
| 152 |
|
| 153 |
// Left vertical menu. |
| 154 |
wpbc_ui__left_vertical_nav( |
| 155 |
array( |
| 156 |
'active_page' => $this->active_page, // wpbc-settings. |
| 157 |
'active_tab' => $this->active_tab, // calendar_appearance. |
| 158 |
'active_subtab' => $this->active_subtab, // calendar_appearance_skin. |
| 159 |
'page_nav_tabs' => $this->page_structure_obj->get_nav_tabs(), |
| 160 |
) |
| 161 |
); |
| 162 |
|
| 163 |
?> |
| 164 |
<div class="wpbc_settings_page_content"> |
| 165 |
<div id="<?php echo esc_attr( $this->active_page ); ?>-admin-page" class="wrap wpbc_page wpbc_page_tab__<?php echo esc_attr( $this->active_tab ); ?> wpbc_page_subtab__<?php echo esc_attr( $this->active_subtab ); ?>"> |
| 166 |
<div class="wpbc_admin_message"></div> |
| 167 |
<div class="wpbc_admin_page"> |
| 168 |
<div id="ajax_working"></div> |
| 169 |
<div class="clear wpbc_header_margin" style="height:0px;"></div> |
| 170 |
<div id="ajax_respond" class="ajax_respond" style="display:none;"></div> |
| 171 |
<div class="clear"></div> |
| 172 |
<?php |
| 173 |
|
| 174 |
$is_show_top_path = method_exists( $this->page_structure_obj, 'is_top_path_enabled' ) |
| 175 |
? $this->page_structure_obj->is_top_path_enabled() |
| 176 |
: $this->page_structure_obj->is_use_option__in_subtabs_or_tabs( 'is_show_top_path' ); |
| 177 |
if ( $is_show_top_path ) { |
| 178 |
wpbc_ui_settings__top_path( $this->page_structure_obj ); |
| 179 |
} |
| 180 |
|
| 181 |
$is_show_top_navigation = $this->page_structure_obj->is_use_option__in_subtabs_or_tabs( 'is_show_top_navigation' ); |
| 182 |
if ( $is_show_top_navigation ) { |
| 183 |
// Top horisonal menu. |
| 184 |
wpbc_ui__top_horisontal_nav( |
| 185 |
array( |
| 186 |
'active_page' => $this->active_page, // wpbc-settings. |
| 187 |
'active_tab' => $this->active_tab, // calendar_appearance. |
| 188 |
'active_subtab' => $this->active_subtab, // calendar_appearance_skin. |
| 189 |
'page_nav_tabs' => $this->page_structure_obj->get_nav_tabs(), |
| 190 |
) |
| 191 |
); |
| 192 |
} |
| 193 |
|
| 194 |
$this->show_title_and_description(); |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
/** |
| 199 |
* Show Template Footer |
| 200 |
* |
| 201 |
* @return void |
| 202 |
*/ |
| 203 |
public function template_footer() { |
| 204 |
|
| 205 |
echo '</div><!-- wpbc_admin_page -->'; |
| 206 |
echo '</div><!-- wpbc_page -->'; |
| 207 |
echo '</div><!-- .wpbc_settings_page_content -->'; |
| 208 |
|
| 209 |
// Right vertical sidebar. |
| 210 |
$right_vertical_sidebar__is_show = $this->page_structure_obj->is_use_option__in_subtabs_or_tabs( 'right_vertical_sidebar__is_show' ); |
| 211 |
if ( $right_vertical_sidebar__is_show ) { |
| 212 |
|
| 213 |
wpbc_ui__right_vertical_sidebar( |
| 214 |
array( |
| 215 |
'active_page' => $this->active_page, // wpbc-settings. |
| 216 |
'active_tab' => $this->active_tab, // calendar_appearance. |
| 217 |
'active_subtab' => $this->active_subtab, // calendar_appearance_skin. |
| 218 |
'page_nav_tabs' => $this->page_structure_obj->get_nav_tabs(), |
| 219 |
) |
| 220 |
); |
| 221 |
|
| 222 |
$right_vertical_sidebar_compact__is_show = $this->page_structure_obj->is_use_option__in_subtabs_or_tabs( 'right_vertical_sidebar_compact__is_show' ); |
| 223 |
if ( $right_vertical_sidebar_compact__is_show ) { |
| 224 |
wpbc_ui__right_vertical_sidebar_compact( |
| 225 |
array( |
| 226 |
'active_page' => $this->active_page, // wpbc-settings. |
| 227 |
'active_tab' => $this->active_tab, // calendar_appearance. |
| 228 |
'active_subtab' => $this->active_subtab, // calendar_appearance_skin. |
| 229 |
'page_nav_tabs' => $this->page_structure_obj->get_nav_tabs(), |
| 230 |
) |
| 231 |
); |
| 232 |
} |
| 233 |
} |
| 234 |
|
| 235 |
echo '</div><!-- .wpbc_settings_page_wrapper -->'; |
| 236 |
echo '</div><!-- .wpbc_admin -->'; |
| 237 |
|
| 238 |
|
| 239 |
/** |
| 240 |
* == Full Screen Mode Checking == Defined in -> public function add_loading_classes( $classes ) . |
| 241 |
* |
| 242 |
* If defined full screen ( checked by exists .wpbc_admin_full_screen in body), |
| 243 |
* then this code, remove the 'wp-toolbar' class from html tag |
| 244 |
* and set correct 'full screen' or 'normal' buttons in the rop right side! |
| 245 |
*/ |
| 246 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 247 |
echo '<script type="text/javascript">' . wpbc_jq_ready_start() . 'if ( "function" === typeof wpbc_check_full_screen_mode ) { wpbc_check_full_screen_mode(); }' . wpbc_jq_ready_end() . '</script>'; |
| 248 |
} |
| 249 |
|
| 250 |
|
| 251 |
/** |
| 252 |
* Show Header Title and Description |
| 253 |
* |
| 254 |
* @return void |
| 255 |
*/ |
| 256 |
private function show_title_and_description() { |
| 257 |
|
| 258 |
$current_page_params_arr = $this->page_structure_obj->get_current_page_params(); |
| 259 |
|
| 260 |
if ( |
| 261 |
( ! empty( $current_page_params_arr['subtab'] ) ) && |
| 262 |
( ! empty( $current_page_params_arr['subtab']['tag'] ) ) && |
| 263 |
( $current_page_params_arr['subtab']['tag'] === $this->active_subtab ) |
| 264 |
) { // Active: Subtab. |
| 265 |
// Header - Title. |
| 266 |
if ( isset( $current_page_params_arr['subtab']['page_title'] ) ) { |
| 267 |
$this->show_title( $current_page_params_arr['subtab']['page_title'] ); |
| 268 |
} |
| 269 |
// Header - Title Description. |
| 270 |
if ( isset( $current_page_params_arr['subtab']['page_description'] ) ) { |
| 271 |
$this->show_title_description( $current_page_params_arr['subtab']['page_description'] ); |
| 272 |
} elseif ( isset( $current_page_params_arr['subtab']['hint'] ) ) { |
| 273 |
$this->show_title_description( $current_page_params_arr['subtab']['hint'] ); |
| 274 |
} |
| 275 |
} elseif ( ! empty( $current_page_params_arr['tab'] ) ) { // Active: Main tab. |
| 276 |
// Header - Title. |
| 277 |
if ( isset( $current_page_params_arr['tab']['page_title'] ) ) { |
| 278 |
$this->show_title( $current_page_params_arr['tab']['page_title'] ); |
| 279 |
} |
| 280 |
if ( isset( $current_page_params_arr['tab']['page_description'] ) ) { |
| 281 |
$this->show_title_description( $current_page_params_arr['tab']['page_description'] ); |
| 282 |
} elseif ( isset( $current_page_params_arr['tab']['hint'] ) ) { |
| 283 |
$this->show_title_description( $current_page_params_arr['tab']['hint'] ); |
| 284 |
} |
| 285 |
} |
| 286 |
} |
| 287 |
|
| 288 |
|
| 289 |
/** |
| 290 |
* Show Title |
| 291 |
* |
| 292 |
* @param string $value - title of the page. |
| 293 |
* |
| 294 |
* @return void |
| 295 |
*/ |
| 296 |
private function show_title( $value ) { |
| 297 |
if ( ! empty( $value ) ) { |
| 298 |
echo '<h1 class="wpbc_settings_page_header_title">' . wp_kses_post( $value ) . '</h1>'; |
| 299 |
} |
| 300 |
} |
| 301 |
|
| 302 |
|
| 303 |
/** |
| 304 |
* Show Title Description |
| 305 |
* |
| 306 |
* @param string|array $value - Title Description of the page. |
| 307 |
* |
| 308 |
* @return void |
| 309 |
*/ |
| 310 |
private function show_title_description( $value ) { |
| 311 |
|
| 312 |
if ( ! empty( $value ) ) { |
| 313 |
if ( is_array( $value ) ) { |
| 314 |
|
| 315 |
if ( ! empty( $value['title'] ) ) { |
| 316 |
echo '<p class="wpbc_settings_page_header_title_description">' . wp_kses_post( $value['title'] ) . '</p>'; |
| 317 |
} |
| 318 |
} else { |
| 319 |
echo '<p class="wpbc_settings_page_header_title_description">' . wp_kses_post( $value ) . '</p>'; |
| 320 |
} |
| 321 |
} |
| 322 |
} |
| 323 |
} |
| 324 |
|