VersionPress\Initialization\WpdbReplacer::isReplaced PHP Method

isReplaced() public static method

public static isReplaced ( )
    public static function isReplaced()
    {
        $firstLine = fgets(fopen(ABSPATH . WPINC . '/wp-db.php', 'r'));
        return Strings::contains($firstLine, self::$vpFirstLineComment);
    }

Usage Example

示例#1
0
/**
 * Most of the actual deactivation work is done here. Called either as a response
 * to the user confirming the deactivation on `?page=versionpress/admin/deactivate.php`
 * or is called directly from vp_deactivate() if the confirmation screen was not necessary.
 */
function vp_admin_post_confirm_deactivation()
{
    //nonce verification is performed according to 'deactivate-plugin_versionpress/versionpress.php'
    // as a standard deactivation token for which nonce is generated
    if (!defined('WP_CLI')) {
        vp_verify_nonce('deactivate-plugin_versionpress/versionpress.php');
        vp_check_permissions();
    }
    define('VP_DEACTIVATING', true);
    if (WpdbReplacer::isReplaced()) {
        WpdbReplacer::restoreOriginal();
    }
    if (file_exists(VERSIONPRESS_ACTIVATION_FILE)) {
        FileSystem::remove(VERSIONPRESS_ACTIVATION_FILE);
    }
    $filesChangedByDeactivation = [["type" => "path", "path" => VP_VPDB_DIR . "/*"], ["type" => "path", "path" => ABSPATH . WPINC . "/wp-db.php"], ["type" => "path", "path" => ABSPATH . WPINC . "/wp-db.php.original"], ["type" => "path", "path" => ABSPATH . "/.gitattributes"]];
    vp_force_action('versionpress', 'deactivate', null, [], $filesChangedByDeactivation);
    MergeDriverInstaller::uninstallMergeDriver(VP_PROJECT_ROOT, VERSIONPRESS_PLUGIN_DIR, VP_VPDB_DIR);
    deactivate_plugins("versionpress/versionpress.php", true);
    if (defined('WP_ADMIN')) {
        wp_safe_redirect(admin_url("plugins.php"));
        exit;
    }
}
All Usage Examples Of VersionPress\Initialization\WpdbReplacer::isReplaced