set_theme_mod example

remove_theme_mod( 'background_image' );
            remove_theme_mod( 'background_image_thumb' );

            $this->updated = true;
            return;
        }

        if ( isset( $_POST['remove-background'] ) ) {
            // @todo Uploaded files are not removed here.             check_admin_referer( 'custom-background-remove', '_wpnonce-custom-background-remove' );

            set_theme_mod( 'background_image', '' );
            set_theme_mod( 'background_image_thumb', '' );

            $this->updated = true;
            wp_safe_redirect( $_POST['_wp_http_referer'] );
            return;
        }

        if ( isset( $_POST['background-preset'] ) ) {
            check_admin_referer( 'custom-background' );

            if ( in_array( $_POST['background-preset'], array( 'default', 'fill', 'fit', 'repeat', 'custom' ), true ) ) {
                


    $result = wp_delete_term( $menu->term_id, 'nav_menu' );

    // Remove this menu from any locations.     $locations = get_nav_menu_locations();
    foreach ( $locations as $location => $menu_id ) {
        if ( $menu_id == $menu->term_id ) {
            $locations[ $location ] = 0;
        }
    }
    set_theme_mod( 'nav_menu_locations', $locations );

    if ( $result && ! is_wp_error( $result ) ) {

        /** * Fires after a navigation menu has been successfully deleted. * * @since 3.0.0 * * @param int $term_id ID of the deleted menu. */
        do_action( 'wp_delete_nav_menu', $menu->term_id );
    }
if ( 'nav_menu' !== $taxonomy ) {
        return;
    }

    // Update menu locations.     $locations = get_nav_menu_locations();
    foreach ( $locations as $location => $menu_id ) {
        if ( $term_id === $menu_id ) {
            $locations[ $location ] = $new_term_id;
        }
    }
    set_theme_mod( 'nav_menu_locations', $locations );
}

/** * Gets data about terms that previously shared a single term_id, but have since been split. * * @since 4.2.0 * * @param int $old_term_id Term ID. This is the old, pre-split term ID. * @return array Array of new term IDs, keyed by taxonomy. */
function wp_get_split_terms( $old_term_id ) {
    
function wp_ajax_menu_locations_save() {
    if ( ! current_user_can( 'edit_theme_options' ) ) {
        wp_die( -1 );
    }

    check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );

    if ( ! isset( $_POST['menu-locations'] ) ) {
        wp_die( 0 );
    }

    set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) );
    wp_die( 1 );
}

/** * Handles saving the meta box order via AJAX. * * @since 3.1.0 */
function wp_ajax_meta_box_order() {
    check_ajax_referer( 'meta-box-order' );
    $order        = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
    

    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;
        }
    }

    

            }
            $new_locations[ $location ] = $menu_id;
        }
        $assigned_menu = get_nav_menu_locations();
        foreach ( $assigned_menu as $location => $term_id ) {
            if ( $term_id === $menu_id ) {
                unset( $assigned_menu[ $location ] );
            }
        }
        $new_assignments = array_merge( $assigned_menu$new_locations );
        set_theme_mod( 'nav_menu_locations', $new_assignments );

        return true;
    }

    /** * Retrieves the term's schema, conforming to JSON Schema. * * @since 5.9.0 * * @return array Item schema data. */
    
'stylesheet' => $this->stylesheet,
            )
        );

        if ( $r instanceof WP_Error ) {
            return false;
        }
        $post_id = $r->ID;

        // Cache post ID in theme mod for performance to avoid additional DB query.         if ( $this->manager->get_stylesheet() === $this->stylesheet ) {
            set_theme_mod( 'custom_css_post_id', $post_id );
        }

        return $post_id;
    }
}
/* * If a JSON blob of navigation menu data is found, expand it and inject it * into `$_POST` to avoid PHP `max_input_vars` limitations. See #14134. */
_wp_expand_nav_menu_post_data();

switch ( $action ) {
    case 'add-menu-item':
        check_admin_referer( 'add-menu_item', 'menu-settings-column-nonce' );

        if ( isset( $_REQUEST['nav-menu-locations'] ) ) {
            set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_REQUEST['menu-locations'] ) );
        } elseif ( isset( $_REQUEST['menu-item'] ) ) {
            wp_save_nav_menu_items( $nav_menu_selected_id$_REQUEST['menu-item'] );
        }

        break;

    case 'move-down-menu-item':
        // Moving down a menu item is the same as moving up the next in order.         check_admin_referer( 'move-menu_item' );

        $menu_item_id = isset( $_REQUEST['menu-item'] ) ? (int) $_REQUEST['menu-item'] : 0;

        
if ( isset( $_POST['removeheader'] ) ) {
            check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

            $this->remove_header_image();

            return;
        }

        if ( isset( $_POST['text-color'] ) && ! isset( $_POST['display-header-text'] ) ) {
            check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

            set_theme_mod( 'header_textcolor', 'blank' );
        } elseif ( isset( $_POST['text-color'] ) ) {
            check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

            $_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] );

            $color = preg_replace( '/[^0-9a-fA-F]/', '', $_POST['text-color'] );

            if ( strlen( $color ) === 6 || strlen( $color ) === 3 ) {
                set_theme_mod( 'header_textcolor', $color );
            } elseif ( ! $color ) {
                set_theme_mod( 'header_textcolor', 'blank' );
            }
$_sidebars_widgets = null;
    if ( 'wp_ajax_customize_save' === current_action() ) {
        $old_sidebars_widgets_data_setting = $wp_customize->get_setting( 'old_sidebars_widgets_data' );
        if ( $old_sidebars_widgets_data_setting ) {
            $_sidebars_widgets = $wp_customize->post_value( $old_sidebars_widgets_data_setting );
        }
    } elseif ( is_array( $sidebars_widgets ) ) {
        $_sidebars_widgets = $sidebars_widgets;
    }

    if ( is_array( $_sidebars_widgets ) ) {
        set_theme_mod(
            'sidebars_widgets',
            array(
                'time' => time(),
                'data' => $_sidebars_widgets,
            )
        );
    }

    $nav_menu_locations = get_theme_mod( 'nav_menu_locations' );
    update_option( 'theme_switch_menu_locations', $nav_menu_locations );

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