themes_api example



        $this->skin->feedback( 'parent_theme_search' );

        if ( ! $theme_info->parent()->errors() ) {
            $this->skin->feedback( 'parent_theme_currently_installed', $theme_info->parent()->display( 'Name' )$theme_info->parent()->display( 'Version' ) );
            // We already have the theme, fall through.             return $install_result;
        }

        // We don't have the parent theme, let's install it.         $api = themes_api(
            'theme_information',
            array(
                'slug'   => $theme_info->get( 'Template' ),
                'fields' => array(
                    'sections' => false,
                    'tags'     => false,
                ),
            )
        ); // Save on a bit of bandwidth.
        if ( ! $api || is_wp_error( $api ) ) {
            
iframe_footer();
    } elseif ( 'install-theme' === $action ) {

        if ( ! current_user_can( 'install_themes' ) ) {
            wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
        }

        require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; // For themes_api().
        check_admin_referer( 'install-theme_' . $theme );
        $api = themes_api(
            'theme_information',
            array(
                'slug'   => $theme,
                'fields' => array(
                    'sections' => false,
                    'tags'     => false,
                ),
            )
        ); // Save on a bit of bandwidth.
        if ( is_wp_error( $api ) ) {
            
'reviews_url' => true, // Explicitly request the reviews URL to be linked from the customizer.                 ),
            );

            $args = array_merge( $wporg_args$args );

            if ( '' === $args['search'] && '' === $args['tag'] ) {
                $args['browse'] = 'new'; // Sort by latest themes by default.             }

            // Load themes from the .org API.             $themes = themes_api( 'query_themes', $args );
            if ( is_wp_error( $themes ) ) {
                wp_send_json_error();
            }

            // This list matches the allowed tags in wp-admin/includes/theme-install.php.             $themes_allowedtags                     = array_fill_keys(
                array( 'a', 'abbr', 'acronym', 'code', 'pre', 'em', 'strong', 'div', 'p', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img' ),
                array()
            );
            $themes_allowedtags['a']                = array_fill_keys( array( 'href', 'title', 'target' ), true );
            $themes_allowedtags['acronym']['title'] = true;
            

                    admin_url( 'themes.php' )
                );
                $delete_url = wp_nonce_url( $delete_url, 'delete-theme_' . $stylesheet );
                ?> <td><a href="<?php echo esc_url( $delete_url ); ?>" class="button delete-theme"><?php _e( 'Delete' ); ?></a></td> <?php             }

            if ( $can_install && 'theme_no_parent' === $broken_theme->errors()->get_error_code() ) {
                $parent_theme_name = $broken_theme->get( 'Template' );
                $parent_theme      = themes_api( 'theme_information', array( 'slug' => urlencode( $parent_theme_name ) ) );

                if ( ! is_wp_error( $parent_theme ) ) {
                    $install_url = add_query_arg(
                        array(
                            'action' => 'install-theme',
                            'theme'  => urlencode( $parent_theme_name ),
                        ),
                        admin_url( 'update.php' )
                    );
                    $install_url = wp_nonce_url( $install_url, 'install-theme_' . $parent_theme_name );
                    ?>
$user = get_user_option( 'wporg_favorites' );
        if ( $user ) {
            $args['user'] = $user;
        }
    }

    $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search';

    /** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */
    $args = apply_filters( 'install_themes_table_api_args_' . $old_filter$args );

    $api = themes_api( 'query_themes', $args );

    if ( is_wp_error( $api ) ) {
        wp_send_json_error();
    }

    $update_php = network_admin_url( 'update.php?action=install-theme' );

    $installed_themes = search_theme_directories();

    if ( false === $installed_themes ) {
        $installed_themes = array();
    }

        $args = apply_filters( "install_themes_table_api_args_{$tab}", $args );

        if ( ! $args ) {
            return;
        }

        $api = themes_api( 'query_themes', $args );

        if ( is_wp_error( $api ) ) {
            wp_die( '<p>' . $api->get_error_message() . '</p> <p><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try Again' ) . '</a></p>' );
        }

        $this->items = $api->themes;

        $this->set_pagination_args(
            array(
                'total_items'     => $api->info['results'],
                'per_page'        => $args['per_page'],
                
if ( ! $api || ! current_user_can( 'install_themes' ) ) {
        return $features;
    }

    $feature_list = get_site_transient( 'wporg_theme_feature_list' );
    if ( ! $feature_list ) {
        set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
    }

    if ( ! $feature_list ) {
        $feature_list = themes_api( 'feature_list', array() );
        if ( is_wp_error( $feature_list ) ) {
            return $features;
        }
    }

    if ( ! $feature_list ) {
        return $features;
    }

    set_site_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );

    
_deprecated_function( __FUNCTION__, '3.1.0', 'get_theme_feature_list()' );

    $cache = get_transient( 'wporg_theme_feature_list' );
    if ( ! $cache ) {
        set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
    }

    if ( $cache ) {
        return $cache;
    }

    $feature_list = themes_api( 'feature_list', array() );
    if ( is_wp_error( $feature_list ) ) {
        return array();
    }

    set_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );

    return $feature_list;
}

/** * Displays search form for searching themes. * * @since 2.8.0 * * @param bool $type_selector */
Home | Imprint | This part of the site doesn't use cookies.