← Back
Editing: setting-page-functions.php
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Get current setting tab. * * @since 4.19.1 Unslash and sanitize the tab name. * @since 1.8 * @return string */ function give_get_current_setting_tab() { // Get current setting page. $current_setting_page = give_get_current_setting_page(); /** * Filter the default tab for current setting page. * * @since 1.8 * * @param string */ $default_current_tab = apply_filters( "give_default_setting_tab_{$current_setting_page}", 'general' ); // Get current tab. // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only tab param; it only selects which settings screen to show and saves nothing. $current_tab = empty( $_GET['tab'] ) ? $default_current_tab : urldecode( sanitize_text_field( wp_unslash( $_GET['tab'] ) ) ); // Output. return $current_tab; } /** * Get current setting section. * * @since 4.19.1 Unslash and sanitize the section name. * @since 1.8 * @return string */ function give_get_current_setting_section() { // Get current tab. $current_tab = give_get_current_setting_tab(); /** * Filter the default section for current setting page tab. * * @since 1.8 * * @param string */ $default_current_section = apply_filters( "give_default_setting_tab_section_{$current_tab}", '' ); // Get current section. // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only section param; it only selects which settings screen to show and saves nothing. $current_section = empty( $_REQUEST['section'] ) ? $default_current_section : urldecode( sanitize_text_field( wp_unslash( $_REQUEST['section'] ) ) ); // Output. return $current_section; } /** * Get current setting page. * * @since 4.19.1 Unslash and sanitize the page name. * @since 1.8 * @return string */ function give_get_current_setting_page() { // Get current page. // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only page param; it only selects which settings screen to show and saves nothing. $setting_page = ! empty( $_GET['page'] ) ? urldecode( sanitize_text_field( wp_unslash( $_GET['page'] ) ) ) : ''; // Output. return $setting_page; } /** * This function will fetch all the groups of a current section. * * @since 2.5.5 * * @return array */ function give_get_settings_groups() { $current_section = give_get_current_setting_section(); return apply_filters( 'give_get_groups_' . $current_section, array() ); }
Save File
Cancel