wp_is_auto_update_forced_for_item example

$filter_payload = array(
                'theme'        => $key,
                'new_version'  => '',
                'url'          => '',
                'package'      => '',
                'requires'     => '',
                'requires_php' => '',
            );

            $filter_payload = (object) array_merge( $filter_payloadarray_intersect_key( $theme_data$filter_payload ) );

            $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, $filter_payload );

            if ( ! is_null( $auto_update_forced ) ) {
                $theme->auto_update_forced = $auto_update_forced;
            }

            if ( $this->show_autoupdates ) {
                $enabled = in_array( $key$auto_updates, true ) && $theme->update_supported;
                if ( isset( $theme->auto_update_forced ) ) {
                    $enabled = (bool) $theme->auto_update_forced;
                }

                

            $auto_update_filter_payload = (object) array(
                'theme'        => $slug,
                'new_version'  => $theme->get( 'Version' ),
                'url'          => '',
                'package'      => '',
                'requires'     => $theme->get( 'RequiresWP' ),
                'requires_php' => $theme->get( 'RequiresPHP' ),
            );
        }

        $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, $auto_update_filter_payload );

        $prepared_themes[ $slug ] = array(
            'id'             => $slug,
            'name'           => $theme->display( 'Name' ),
            'screenshot'     => array( $theme->get_screenshot() ), // @todo Multiple screenshots.             'description'    => $theme->display( 'Description' ),
            'author'         => $theme->display( 'Author', false, true ),
            'authorAndUri'   => $theme->display( 'Author' ),
            'tags'           => $theme->display( 'Tags' ),
            'version'        => $theme->get( 'Version' ),
            'compatibleWP'   => is_wp_version_compatible( $theme->get( 'RequiresWP' ) ),
            
'package'       => '',
                'icons'         => array(),
                'banners'       => array(),
                'banners_rtl'   => array(),
                'tested'        => '',
                'requires_php'  => '',
                'compatibility' => new stdClass(),
            );

            $filter_payload = (object) wp_parse_args( $plugin_data$filter_payload );

            $auto_update_forced = wp_is_auto_update_forced_for_item( 'plugin', null, $filter_payload );

            if ( ! is_null( $auto_update_forced ) ) {
                $plugin_data['auto-update-forced'] = $auto_update_forced;
            }

            $plugins['all'][ $plugin_file ] = $plugin_data;
            // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade.             if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
                $plugins['upgrade'][ $plugin_file ] = $plugin_data;
            }

            


        $mock_theme = (object) array(
            'theme'        => 'a-fake-theme',
            'new_version'  => '9.9',
            'url'          => 'https://wordpress.org/themes/a-fake-theme/',
            'package'      => 'https://downloads.wordpress.org/theme/a-fake-theme.9.9.zip',
            'requires'     => '5.0.0',
            'requires_php' => '5.6.20',
        );

        $test_plugins_enabled = wp_is_auto_update_forced_for_item( 'plugin', true, $mock_plugin );
        $test_themes_enabled  = wp_is_auto_update_forced_for_item( 'theme', true, $mock_theme );

        $ui_enabled_for_plugins = wp_is_auto_update_enabled_for_type( 'plugin' );
        $ui_enabled_for_themes  = wp_is_auto_update_enabled_for_type( 'theme' );
        $plugin_filter_present  = has_filter( 'auto_update_plugin' );
        $theme_filter_present   = has_filter( 'auto_update_theme' );

        if ( ( ! $test_plugins_enabled && $ui_enabled_for_plugins )
            || ( ! $test_themes_enabled && $ui_enabled_for_themes )
        ) {
            return (object) array(
                
'package'       => '',
                        'icons'         => array(),
                        'banners'       => array(),
                        'banners_rtl'   => array(),
                        'tested'        => '',
                        'requires_php'  => '',
                        'compatibility' => new stdClass(),
                    );
                    $item = wp_parse_args( $plugin$item );
                }

                $auto_update_forced = wp_is_auto_update_forced_for_item( 'plugin', null, (object) $item );

                if ( ! is_null( $auto_update_forced ) ) {
                    $enabled = $auto_update_forced;
                } else {
                    $enabled = in_array( $plugin_path$auto_updates, true );
                }

                if ( $enabled ) {
                    $auto_updates_string = __( 'Auto-updates enabled' );
                } else {
                    $auto_updates_string = __( 'Auto-updates disabled' );
                }
Home | Imprint | This part of the site doesn't use cookies.