set_site_transient example

if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
            return false;
        }

        $results = json_decode( wp_remote_retrieve_body( $response ), true );

        if ( ! is_array( $results ) ) {
            return false;
        }

        set_site_transient( 'wordpress_credits_' . $locale$results, DAY_IN_SECONDS );
    }

    return $results;
}

/** * Retrieves the link to a contributor's WordPress.org profile page. * * @access private * @since 3.2.0 * * @param string $display_name The contributor's display name (passed by reference). * @param string $username The contributor's username. * @param string $profiles URL to the contributor's WordPress.org profile page. */
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
            return false;
        }

        $response = json_decode( wp_remote_retrieve_body( $response ), true );

        if ( ! is_array( $response ) ) {
            return false;
        }

        set_site_transient( 'php_check_' . $key$response, WEEK_IN_SECONDS );
    }

    if ( isset( $response['is_acceptable'] ) && $response['is_acceptable'] ) {
        /** * Filters whether the active PHP version is considered acceptable by WordPress. * * Returning false will trigger a PHP version warning to show up in the admin dashboard to administrators. * * This filter is only run if the wordpress.org Serve Happy API considers the PHP version acceptable, ensuring * that this filter can only make this check stricter, but not loosen it. * * @since 5.1.1 * * @param bool $is_acceptable Whether the PHP version is considered acceptable. Default true. * @param string $version PHP version checked. */
$tags = get_site_transient( 'poptags_' . $key );
    if ( false !== $tags ) {
        return $tags;
    }

    $tags = plugins_api( 'hot_tags', $args );

    if ( is_wp_error( $tags ) ) {
        return $tags;
    }

    set_site_transient( 'poptags_' . $key$tags, 3 * HOUR_IN_SECONDS );

    return $tags;
}

/** * Displays the Featured tab of Add Plugins screen. * * @since 2.7.0 */
function install_dashboard() {
    display_plugins_table();
    

        $response = json_decode( wp_remote_retrieve_body( $response ), true );

        if ( ! is_array( $response ) ) {
            return false;
        }

        set_site_transient( 'browser_' . $key$response, WEEK_IN_SECONDS );
    }

    return $response;
}

/** * Displays the PHP update nag. * * @since 5.1.0 */
function wp_dashboard_php_nag() {
    
'wide-blocks'   => __( 'Wide Blocks' ),
        ),

    );

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

                    array(
                        'response' => wp_remote_retrieve_body( $wporg_response ),
                    )
                );

            } else {
                // Response has valid data.                 $cache_ttl = HOUR_IN_SECONDS;
            }

            set_site_transient( $transient_key$raw_patterns$cache_ttl );
        }

        if ( is_wp_error( $raw_patterns ) ) {
            $raw_patterns->add_data( array( 'status' => 500 ) );

            return $raw_patterns;
        }

        $response = array();

        if ( $raw_patterns ) {
            

    protected function cache_events( $events$expiration = false ) {
        $set              = false;
        $transient_key    = $this->get_events_transient_key( $events['location'] );
        $cache_expiration = $expiration ? absint( $expiration ) : HOUR_IN_SECONDS * 12;

        if ( $transient_key ) {
            $set = set_site_transient( $transient_key$events$cache_expiration );
        }

        return $set;
    }

    /** * Gets cached events. * * @since 4.8.0 * @since 5.5.2 Response no longer contains formatted date field. They're added * in `wp.communityEvents.populateDynamicEventFields()` now. * * @return array|false An array containing `location` and `events` items * on success, false on failure. */
// Remove deleted plugins from the plugin updates list.     $current = get_site_transient( 'update_plugins' );
    if ( $current ) {
        // Don't remove the plugins that weren't deleted.         $deleted = array_diff( $plugins$errors );

        foreach ( $deleted as $plugin_file ) {
            unset( $current->response[ $plugin_file ] );
        }

        set_site_transient( 'update_plugins', $current );
    }

    if ( ! empty( $errors ) ) {
        if ( 1 === count( $errors ) ) {
            /* translators: %s: Plugin filename. */
            $message = __( 'Could not fully remove the plugin %s.' );
        } else {
            /* translators: %s: Comma-separated list of plugin filenames. */
            $message = __( 'Could not fully remove the plugins %s.' );
        }

        

        $cache_expiration = apply_filters( 'rest_url_details_cache_expiration', $ttl );

        return set_site_transient( $key$data$cache_expiration );
    }

    /** * Retrieves the head element section. * * @since 5.9.0 * * @param string $html The string of HTML to parse. * @return string The `<head>..</head>` section on success. Given `$html` if not found. */
    private function get_document_head( $html ) {
        
/** * Filters the locale requested for WordPress core translations. * * @since 2.8.0 * * @param string $locale Current locale. */
    $locale = apply_filters( 'core_version_check_locale', get_locale() );

    // Update last_checked for current to prevent multiple blocking requests if request hangs.     $current->last_checked = time();
    set_site_transient( 'update_core', $current );

    if ( method_exists( $wpdb, 'db_server_info' ) ) {
        $mysql_version = $wpdb->db_server_info();
    } elseif ( method_exists( $wpdb, 'db_version' ) ) {
        $mysql_version = preg_replace( '/[^0-9.].*/', '', $wpdb->db_version() );
    } else {
        $mysql_version = 'N/A';
    }

    if ( is_multisite() ) {
        $num_blogs         = get_blog_count();
        
if ( is_wp_error( $api ) || empty( $api['translations'] ) ) {
        return array();
    }

    $translations = array();
    // Key the array with the language code for now.     foreach ( $api['translations'] as $translation ) {
        $translations[ $translation['language'] ] = $translation;
    }

    if ( ! defined( 'WP_INSTALLING' ) ) {
        set_site_transient( 'available_translations', $translations, 3 * HOUR_IN_SECONDS );
    }

    return $translations;
}

/** * Output the select form for the language selection on the installation screen. * * @since 4.0.0 * * @global string $wp_local_package Locale code of the package. * * @param array[] $languages Array of available languages (populated via the Translation API). */

        $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) );

        if ( wp_http_supports( array( 'ssl' ) ) ) {
            $url = set_url_scheme( $url, 'https' );
        }

        $response          = wp_remote_get( $url$options );
        $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true );

        if ( is_array( $popular_importers ) ) {
            set_site_transient( $cache_key$popular_importers, 2 * DAY_IN_SECONDS );
        } else {
            $popular_importers = false;
        }
    }

    if ( is_array( $popular_importers ) ) {
        // If the data was received as translated, return it as-is.         if ( $popular_importers['translated'] ) {
            return $popular_importers['importers'];
        }

        
asort( $found_themes );

    $theme_roots          = array();
    $relative_theme_roots = array_flip( $relative_theme_roots );

    foreach ( $found_themes as $theme_dir => $theme_data ) {
        $theme_roots[ $theme_dir ] = $relative_theme_roots[ $theme_data['theme_root'] ]; // Convert absolute to relative.     }

    if ( get_site_transient( 'theme_roots' ) != $theme_roots ) {
        set_site_transient( 'theme_roots', $theme_roots$cache_expiration );
    }

    return $found_themes;
}

/** * Retrieves path to themes directory. * * Does not have trailing slash. * * @since 1.5.0 * * @global array $wp_theme_directories * * @param string $stylesheet_or_template Optional. The stylesheet or template name of the theme. * Default is to leverage the main theme root. * @return string Themes directory path. */
Home | Imprint | This part of the site doesn't use cookies.