Astra_Ext_White_Label_Markup::settings_save()
Save Settings
Description
Source
File: classes/class-astra-ext-white-label-markup.php
public function settings_save() {
if ( isset( $_POST['ast-white-label-nonce'] ) && wp_verify_nonce( $_POST['ast-white-label-nonce'], 'white-label' ) ) {
$url = $_SERVER['HTTP_REFERER'];
$stored_settings = self::get_white_labels();
$input_settings = array();
$new_settings = array();
if ( isset( $_POST['ast_white_label'] ) ) {
$input_settings = $_POST['ast_white_label'];
// Loop through the input and sanitize each of the values.
foreach ( $input_settings as $key => $val ) {
if ( is_array( $val ) ) {
foreach ( $val as $k => $v ) {
$new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( stripslashes( $v ) ) : '';
}
} else {
$new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( stripslashes( $val ) ) : '';
}
}
}
$new_settings = wp_parse_args( $new_settings, $stored_settings );
if ( ! isset( $new_settings['astra-agency']['hide_branding'] ) ) {
$new_settings['astra-agency']['hide_branding'] = false;
} else {
$url = str_replace( 'white-label', 'general', $url );
}
Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_white_label', $new_settings, true );
// Change the theme page slug only if the value if added by user.
$theme_whitelabelled_name = self::get_whitelabel_string( 'astra', 'name', false );
if ( false !== $theme_whitelabelled_name && ! empty( $theme_whitelabelled_name ) ) {
$url = remove_query_arg( 'page', $url );
$url = add_query_arg( 'page', $this->astra_whitelabelled_slug( $theme_whitelabelled_name ), $url );
}
$query = array(
'message' => 'saved',
);
$redirect_to = add_query_arg( $query, $url );
// Flush rewrite rules on publish action of custom layout.
flush_rewrite_rules();
wp_safe_redirect( $redirect_to );
exit;
}
}
Expand full source code Collapse full source code View on Trac