create_lock example

return false;
            }

            // Check to see if the lock is still valid. If it is, bail.             if ( $lock_result > ( time() - $release_timeout ) ) {
                return false;
            }

            // There must exist an expired lock, clear it and re-gain it.             WP_Upgrader::release_lock( $lock_name );

            return WP_Upgrader::create_lock( $lock_name$release_timeout );
        }

        // Update the lock, as by this point we've definitely got a lock, just need to fire the actions.         update_option( $lock_optiontime() );

        return true;
    }

    /** * Releases an upgrader lock. * * @since 4.5.0 * * @see WP_Upgrader::create_lock() * * @param string $lock_name The name of this unique lock. * @return bool True if the lock was successfully released. False on failure. */

    public function run() {
        if ( $this->is_disabled() ) {
            return;
        }

        if ( ! is_main_network() || ! is_main_site() ) {
            return;
        }

        if ( ! WP_Upgrader::create_lock( 'auto_updater' ) ) {
            return;
        }

        // Don't automatically run these things, as we'll handle it ourselves.         remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
        remove_action( 'upgrader_process_complete', 'wp_version_check' );
        remove_action( 'upgrader_process_complete', 'wp_update_plugins' );
        remove_action( 'upgrader_process_complete', 'wp_update_themes' );

        // Next, plugins.         wp_update_plugins(); // Check for plugin updates.
$to_download = 'partial';
        } elseif ( $current->packages->new_bundled && version_compare( $wp_version$current->new_bundled, '<' )
            && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
            $to_download = 'new_bundled';
        } elseif ( $current->packages->no_content ) {
            $to_download = 'no_content';
        } else {
            $to_download = 'full';
        }

        // Lock to prevent multiple Core Updates occurring.         $lock = WP_Upgrader::create_lock( 'core_updater', 15 * MINUTE_IN_SECONDS );
        if ( ! $lock ) {
            return new WP_Error( 'locked', $this->strings['locked'] );
        }

        $download = $this->download_package( $current->packages->$to_download, true );

        /* * Allow for signature soft-fail. * WARNING: This may be removed in the future. */
        if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) {
            
Home | Imprint | This part of the site doesn't use cookies.