sanitize_option example



    wp_send_json_error();
}

/** * Handles formatting a date via AJAX. * * @since 3.1.0 */
function wp_ajax_date_format() {
    wp_die( date_i18n( sanitize_option( 'date_format', wp_unslash( $_POST['date'] ) ) ) );
}

/** * Handles formatting a time via AJAX. * * @since 3.1.0 */
function wp_ajax_time_format() {
    wp_die( date_i18n( sanitize_option( 'time_format', wp_unslash( $_POST['date'] ) ) ) );
}


        );
        return update_option( $deprecated_keys[ $option ]$value$autoload );
    }

    wp_protect_special_option( $option );

    if ( is_object( $value ) ) {
        $value = clone $value;
    }

    $value     = sanitize_option( $option$value );
    $old_value = get_option( $option );

    /** * Filters a specific option before its value is (maybe) serialized and updated. * * The dynamic portion of the hook name, `$option`, refers to the option name. * * @since 2.6.0 * @since 4.4.0 The `$option` parameter was added. * * @param mixed $value The new, unserialized option value. * @param mixed $old_value The old option value. * @param string $option Option name. */

function get_settings_errors( $setting = '', $sanitize = false ) {
    global $wp_settings_errors;

    /* * If $sanitize is true, manually re-run the sanitization for this option * This allows the $sanitize_callback from register_setting() to run, adding * any settings errors you want to show by default. */
    if ( $sanitize ) {
        sanitize_option( $settingget_option( $setting ) );
    }

    // If settings were passed back from options.php then use them.     if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
        $wp_settings_errors = array_merge( (array) $wp_settings_errorsget_transient( 'settings_errors' ) );
        delete_transient( 'settings_errors' );
    }

    // Check global in case errors have been added on this pageload.     if ( empty( $wp_settings_errors ) ) {
        return array();
    }
if ( ! empty( $permalink_structure ) ) {
            $permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );

            if ( $index_php_prefix && $blog_prefix ) {
                $permalink_structure = $index_php_prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure );
            } else {
                $permalink_structure = $blog_prefix . $permalink_structure;
            }
        }

        $permalink_structure = sanitize_option( 'permalink_structure', $permalink_structure );

        $wp_rewrite->set_permalink_structure( $permalink_structure );

        $structure_updated = true;
    }

    if ( isset( $_POST['category_base'] ) ) {
        $category_base = $_POST['category_base'];

        if ( ! empty( $category_base ) ) {
            $category_base = $blog_prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
        }
Home | Imprint | This part of the site doesn't use cookies.