setup_menu_tabs(); $this->render_page($title); } /** * Render the menu page * * @param string $title - the page title * * @return void */ protected function render_page($title) { $current_tab = $this->get_current_tab(); ?>

render_tabs($current_tab); ?>
menu_tabs[$current_tab]['render_callback']); ?>
'; foreach ($this->menu_tabs as $tab_key => $tab_info) { $active = $current_tab == $tab_key ? 'nav-tab-active' : ''; echo '' . esc_html($tab_info['title']) . ''; } echo ''; } /** * Get valid current tab slug. * * @return string - current valid tab slug or empty string */ protected function get_current_tab() { if (is_array($this->menu_tabs) && !empty($this->menu_tabs)) { $tab_keys = array_keys($this->menu_tabs); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- PCP warning. No nonce available. if (empty($_GET['tab'])) { return $tab_keys[0]; } else { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- PCP warning. No nonce available. $current_tab = sanitize_text_field(wp_unslash($_GET['tab'])); return in_array($current_tab, $tab_keys) ? $current_tab : $tab_keys[0]; } } else { return ''; } } /** * This function checks to see if there is a display condition for the tab and if so runs it otherwise it returns true to display the tab * * @param array $tab_info - the tab information array contains keys like title, render_callback and display_condition_callback * * @return boolean - true if the tab should be displayed or false to hide it */ protected function should_display_tab($tab_info) { return AIOWPSecurity_Utility::apply_callback_filter($tab_info, 'display_condition_callback'); } /** * Shows postbox for settings menu * * @param string $id - css ID for postbox * @param string $title - title of the postbox section * @param string $content - the content of the postbox **/ protected function postbox_toggle($id, $title, $content) { //Always send string with translation markers in it ?>

'; $message .= esc_html__('The settings have been successfully updated.', 'all-in-one-wp-security-and-firewall'); $message .= '

'; if ($return_instead_of_echo) return $message; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Variable contains escaped HTML. echo $message; } /** * Render settings successfully updated message * * @param bool $return_instead_of_echo - This is used for when the function needs to return the message * * @return string|void */ public static function show_msg_settings_updated_st($return_instead_of_echo = false) { $message = '

'; $message .= esc_html__('The settings have been successfully updated.', 'all-in-one-wp-security-and-firewall'); $message .= '

'; if ($return_instead_of_echo) return $message; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Variable contains escaped HTML. echo $message; } /** * Renders record(s) successfully deleted message at top of page. * * @param bool $return_instead_of_echo - This is used for when the function needs to return the message * @return mixed */ public static function show_msg_record_deleted_st($return_instead_of_echo = false) { return AIOWPSecurity_Admin_Menu::show_msg_updated_st(__('The selected record(s) has been deleted successfully.', 'all-in-one-wp-security-and-firewall'), $return_instead_of_echo); } /** * Renders record(s) unsuccessfully deleted message at top of page. * * @param bool $return_instead_of_echo - This is used for when the function needs to return the message * @return mixed */ public static function show_msg_record_not_deleted_st($return_instead_of_echo = false) { return AIOWPSecurity_Admin_Menu::show_msg_error_st(__('The selected record(s) have failed to delete.', 'all-in-one-wp-security-and-firewall'), $return_instead_of_echo); } /** * Render successfully updated message * * @param string $msg - This contains the message to show * @param bool $return_instead_of_echo - This is used for when the function needs to return the message * * @return string|void */ public function show_msg_updated($msg, $return_instead_of_echo = false) { $message = '

'; $message .= wp_kses_post($msg); $message .= '

'; if ($return_instead_of_echo) return $message; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Variable contains escaped HTML. echo $message; } /** * Render successfully updated message * * @param string $msg - This contains the message to show * @param bool $return_instead_of_echo - This is used for when the function needs to return the message * * @return string|void */ public static function show_msg_updated_st($msg, $return_instead_of_echo = false) { $message = '

'; $message .= wp_kses_post($msg); $message .= '

'; if ($return_instead_of_echo) return $message; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Variable contains escaped HTML. echo $message; } /** * Render error message * * @param string $error_msg - This contains the message to show * @param bool $return_instead_of_echo - This is used for when the function needs to return the message * * @return string|void */ public function show_msg_error($error_msg, $return_instead_of_echo = false) { $message = '

'; $message .= wp_kses_post($error_msg); $message .= '

'; if ($return_instead_of_echo) return $message; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Variable contains escaped HTML. echo $message; } /** * Render error message * * @param string $error_msg - This contains the message to show * @param bool $return_instead_of_echo - This is used for when the function needs to return the message * * @return string|void */ public static function show_msg_error_st($error_msg, $return_instead_of_echo = false) { $message = '

'; $message .= wp_kses_post($error_msg); $message .= '

'; if ($return_instead_of_echo) return $message; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Variable contains escaped HTML. echo $message; } protected function start_buffer() { ob_start(); } protected function end_buffer_and_collect() { $output = ob_get_contents(); ob_end_clean(); return $output; } }