update_option example

$taxonomy_object = new WP_Taxonomy( $taxonomy$object_type$args );
    $taxonomy_object->add_rewrite_rules();

    $wp_taxonomies[ $taxonomy ] = $taxonomy_object;

    $taxonomy_object->add_hooks();

    // Add default term.     if ( ! empty( $taxonomy_object->default_term ) ) {
        $term = term_exists( $taxonomy_object->default_term['name']$taxonomy );
        if ( $term ) {
            update_option( 'default_term_' . $taxonomy_object->name, $term['term_id'] );
        } else {
            $term = wp_insert_term(
                $taxonomy_object->default_term['name'],
                $taxonomy,
                array(
                    'slug'        => sanitize_title( $taxonomy_object->default_term['slug'] ),
                    'description' => $taxonomy_object->default_term['description'],
                )
            );

            // Update `term_id` in options.
if ( is_wp_error( rest_validate_value_from_schema( get_option( $args['option_name'], false )$args['schema'] ) ) ) {
                    return new WP_Error(
                        'rest_invalid_stored_value',
                        /* translators: %s: Property name. */
                        sprintf( __( 'The %s property has an invalid stored value, and cannot be updated to null.' )$name ),
                        array( 'status' => 500 )
                    );
                }

                delete_option( $args['option_name'] );
            } else {
                update_option( $args['option_name']$request[ $name ] );
            }
        }

        return $this->get_item( $request );
    }

    /** * Retrieves all of the registered options for the Settings API. * * @since 4.7.0 * * @return array Array of registered options. */
'plugin_name'         => 'Gutenberg',
            'version_deactivated' => GUTENBERG_VERSION,
            'version_compatible'  => '14.1',
        );
        if ( is_plugin_active_for_network( 'gutenberg/gutenberg.php' ) ) {
            $deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins', array() );
            $deactivated_plugins = array_merge( $deactivated_plugins$deactivated_gutenberg );
            update_site_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
        } else {
            $deactivated_plugins = get_option( 'wp_force_deactivated_plugins', array() );
            $deactivated_plugins = array_merge( $deactivated_plugins$deactivated_gutenberg );
            update_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
        }
        deactivate_plugins( array( 'gutenberg/gutenberg.php' ), true );
    }
}


// Handle admin email change requests. if ( ! empty( $_GET['adminhash'] ) ) {
    $new_admin_details = get_option( 'adminhash' );
    $redirect          = 'options-general.php?updated=false';

    if ( is_array( $new_admin_details )
        && hash_equals( $new_admin_details['hash']$_GET['adminhash'] )
        && ! empty( $new_admin_details['newemail'] )
    ) {
        update_option( 'admin_email', $new_admin_details['newemail'] );
        delete_option( 'adminhash' );
        delete_option( 'new_admin_email' );
        $redirect = 'options-general.php?updated=true';
    }

    wp_redirect( admin_url( $redirect ) );
    exit;
} elseif ( ! empty( $_GET['dismiss'] ) && 'new_admin_email' === $_GET['dismiss'] ) {
    check_admin_referer( 'dismiss-' . get_current_blog_id() . '-new_admin_email' );
    delete_option( 'adminhash' );
    delete_option( 'new_admin_email' );
    

        $email = apply_filters( 'auto_plugin_theme_update_email', $email$type$successful_updates$failed_updates );

        $result = wp_mail( $email['to']wp_specialchars_decode( $email['subject'] )$email['body']$email['headers'] );

        if ( $result ) {
            update_option( 'auto_plugin_theme_update_emails', $past_failure_emails );
        }
    }

    /** * Prepares and sends an email of a full log of background update results, useful for debugging and geekery. * * @since 3.7.0 */
    protected function send_debug_email() {
        $update_count = 0;
        foreach ( $this->update_results as $type => $updates ) {
            
if ( isset( $deprecated_keys[ $option ] ) && ! wp_installing() ) {
        _deprecated_argument(
            __FUNCTION__,
            '5.5.0',
            sprintf(
                /* translators: 1: Deprecated option key, 2: New option key. */
                __( 'The "%1$s" option key has been renamed to "%2$s".' ),
                $option,
                $deprecated_keys[ $option ]
            )
        );
        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 );

    
            $stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
        }

        unset(
            $stored_credentials['password'],
            $stored_credentials['port'],
            $stored_credentials['private_key'],
            $stored_credentials['public_key']
        );

        if ( ! wp_installing() ) {
            update_option( 'ftp_credentials', $stored_credentials );
        }

        return $credentials;
    }

    $hostname        = isset( $credentials['hostname'] ) ? $credentials['hostname'] : '';
    $username        = isset( $credentials['username'] ) ? $credentials['username'] : '';
    $public_key      = isset( $credentials['public_key'] ) ? $credentials['public_key'] : '';
    $private_key     = isset( $credentials['private_key'] ) ? $credentials['private_key'] : '';
    $port            = isset( $credentials['port'] ) ? $credentials['port'] : '';
    $connection_type = isset( $credentials['connection_type'] ) ? $credentials['connection_type'] : '';

    

    public function maybe_send_recovery_mode_email( $rate_limit$error$extension ) {

        $last_sent = get_option( self::RATE_LIMIT_OPTION );

        if ( ! $last_sent || time() > $last_sent + $rate_limit ) {
            if ( ! update_option( self::RATE_LIMIT_OPTION, time() ) ) {
                return new WP_Error( 'storage_error', __( 'Could not update the email last sent time.' ) );
            }

            $sent = $this->send_recovery_mode_email( $rate_limit$error$extension );

            if ( $sent ) {
                return true;
            }

            return new WP_Error(
                'email_failed',
                


        $insert .= $wpdb->prepare( '(%s, %s, %s)', $option$value$autoload );
    }

    if ( ! empty( $insert ) ) {
        $wpdb->query( "INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared     }

    // In case it is set, but blank, update "home".     if ( ! __get_option( 'home' ) ) {
        update_option( 'home', $guessurl );
    }

    // Delete unused options.     $unusedoptions = array(
        'blodotgsping_url',
        'bodyterminator',
        'emailtestonly',
        'phoneemail_separator',
        'smilies_directory',
        'subjectprefix',
        'use_bbcode',
        

                $referer = apply_filters( "handle_network_bulk_actions-{$screen}", $referer$action$themes$id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores             } else {
                $action = 'error';
                $n      = 'none';
            }
    }

    update_option( 'allowedthemes', $allowed_themes );
    restore_current_blog();

    wp_safe_redirect(
        add_query_arg(
            array(
                'id'    => $id,
                $action => $n,
            ),
            $referer
        )
    );
    
update_blog_details( $id$blog_data );

    // Maybe update home and siteurl options.     $new_details = get_site( $id );

    $old_home_url    = trailingslashit( esc_url( get_option( 'home' ) ) );
    $old_home_parsed = parse_url( $old_home_url );

    if ( $old_home_parsed['host'] === $existing_details->domain && $old_home_parsed['path'] === $existing_details->path ) {
        $new_home_url = untrailingslashit( sanitize_url( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
        update_option( 'home', $new_home_url );
    }

    $old_site_url    = trailingslashit( esc_url( get_option( 'siteurl' ) ) );
    $old_site_parsed = parse_url( $old_site_url );

    if ( $old_site_parsed['host'] === $existing_details->domain && $old_site_parsed['path'] === $existing_details->path ) {
        $new_site_url = untrailingslashit( sanitize_url( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
        update_option( 'siteurl', $new_site_url );
    }

    restore_current_blog();
    

    protected function set_root_value( $value ) {
        $id_base = $this->id_data['base'];
        if ( 'option' === $this->type ) {
            $autoload = true;
            if ( isset( self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] ) ) {
                $autoload = self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'];
            }
            return update_option( $id_base$value$autoload );
        } elseif ( 'theme_mod' === $this->type ) {
            set_theme_mod( $id_base$value );
            return true;
        } else {
            /* * Any WP_Customize_Setting subclass implementing aggregate multidimensional * will need to override this method to obtain the data from the appropriate * location. */
            return false;
        }
    }
check_admin_referer( 'edit-site' );

    switch_to_blog( $id );

    $skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form.     foreach ( (array) $_POST['option'] as $key => $val ) {
        $key = wp_unslash( $key );
        $val = wp_unslash( $val );
        if ( 0 === $key || is_array( $val ) || in_array( $key$skip_options, true ) ) {
            continue; // Avoids "0 is a protected WP option and may not be modified" error when editing blog options.         }
        update_option( $key$val );
    }

    /** * Fires after the site options are updated. * * @since 3.0.0 * @since 4.4.0 Added `$id` parameter. * * @param int $id The ID of the site being updated. */
    do_action( 'wpmu_update_blog_options', $id );

    
$option_names = array();
        foreach ( $options as $o_name => $o_value ) {
            $option_names[] = $o_name;
            if ( ! array_key_exists( $o_name$this->blog_options ) ) {
                continue;
            }

            if ( true == $this->blog_options[ $o_name ]['readonly'] ) {
                continue;
            }

            update_option( $this->blog_options[ $o_name ]['option']wp_unslash( $o_value ) );
        }

        // Now return the updated values.         return $this->_getOptions( $option_names );
    }

    /** * Retrieves a media item by ID. * * @since 3.1.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $0 Blog ID (unused). * @type string $1 Username. * @type string $2 Password. * @type int $3 Attachment ID. * } * @return array|IXR_Error Associative array contains: * - 'date_created_gmt' * - 'parent' * - 'link' * - 'thumbnail' * - 'title' * - 'caption' * - 'description' * - 'metadata' */

function wp_ajax_wp_compression_test() {
    if ( ! current_user_can( 'manage_options' ) ) {
        wp_die( -1 );
    }

    if ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) ) {
        // Use `update_option()` on single site to mark the option for autoloading.         if ( is_multisite() ) {
            update_site_option( 'can_compress_scripts', 0 );
        } else {
            update_option( 'can_compress_scripts', 0, 'yes' );
        }
        wp_die( 0 );
    }

    if ( isset( $_GET['test'] ) ) {
        header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
        header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
        header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
        header( 'Content-Type: application/javascript; charset=UTF-8' );
        $force_gzip = ( defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP );
        $test_str   = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."';

        
Home | Imprint | This part of the site doesn't use cookies.