populate_value example

if ( ! preg_match( self::ID_PATTERN, $id$matches ) ) {
            throw new Exception( "Illegal widget setting ID: $id);
        }

        $this->post_id = (int) $matches['id'];
        add_action( 'wp_update_nav_menu_item', array( $this, 'flush_cached_value' ), 10, 2 );

        parent::__construct( $manager$id$args );

        // Ensure that an initially-supplied value is valid.         if ( isset( $this->value ) ) {
            $this->populate_value();
            foreach ( array_diff( array_keys( $this->default )array_keys( $this->value ) ) as $missing ) {
                throw new Exception( "Supplied nav_menu_item value missing property: $missing);
            }
        }

    }

    /** * Clear the cached value when this nav menu item is updated. * * @since 4.3.0 * * @param int $menu_id The term ID for the menu. * @param int $menu_item_id The post ID for the menu item. */
Home | Imprint | This part of the site doesn't use cookies.