wp_doing_cron example

function get_core_checksums( $version$locale ) {
    $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), '', '&' );
    $url      = $http_url;

    $ssl = wp_http_supports( array( 'ssl' ) );

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

    $options = array(
        'timeout' => wp_doing_cron() ? 30 : 3,
    );

    $response = wp_remote_get( $url$options );

    if ( $ssl && is_wp_error( $response ) ) {
        trigger_error(
            sprintf(
                /* translators: %s: Support forums URL. */
                __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
                __( 'https://wordpress.org/support/forums/' )
            ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
            

    public function deactivate_plugin_before_upgrade( $response$plugin ) {

        if ( is_wp_error( $response ) ) { // Bypass.             return $response;
        }

        // When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it.         if ( wp_doing_cron() ) {
            return $response;
        }

        $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
        if ( empty( $plugin ) ) {
            return new WP_Error( 'bad_request', $this->strings['bad_request'] );
        }

        if ( is_plugin_active( $plugin ) ) {
            // Deactivate the plugin silently, Prevent deactivation hooks from running.             deactivate_plugins( $plugin, true );
        }
 elseif ( '.' !== $dirname ) {
            // Path to a file.             $needed_dirs[] = $to . untrailingslashit( $dirname );
        }
    }

    /* * disk_free_space() could return false. Assume that any falsey value is an error. * A disk that has zero free bytes has bigger problems. * Require we have enough space to unzip the file and copy its contents, with a 10% buffer. */
    if ( wp_doing_cron() ) {
        $available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR ) : false;

        if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
            return new WP_Error(
                'disk_full_unzip_file',
                __( 'Could not copy files. You may have run out of disk space.' ),
                compact( 'uncompressed_size', 'available_space' )
            );
        }
    }

    
$query['channel'] = WP_AUTO_UPDATE_CORE;
    }

    $url      = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, '', '&' );
    $http_url = $url;
    $ssl      = wp_http_supports( array( 'ssl' ) );

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

    $doing_cron = wp_doing_cron();

    $options = array(
        'timeout'    => $doing_cron ? 30 : 3,
        'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
        'headers'    => array(
            'wp_install' => $wp_install,
            'wp_blog'    => home_url( '/' ),
        ),
        'body'       => $post_body,
    );

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