Plugin Directory

Changeset 2559677


Ignore:
Timestamp:
07/06/2021 11:55:55 PM (4 years ago)
Author:
bashari
Message:

1.1.0

  • Added WP Engine auto cache clearing & auto file permissions resetting
Location:
dev-theme/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • dev-theme/trunk/dev-theme.php

    r2484489 r2559677  
    33 * Plugin Name: Dev Theme
    44 * Description: This plugin can duplicate your theme to a special development theme that you can edit and use, while real users using your current theme
    5  * Version: 1.0.8
     5 * Version: 1.1.0
    66 */
    77
     
    6969    protected function getBackupDevThemePath() {
    7070        return $this->getDevThemePath() . '-bk';
     71    }
     72
     73    public function wpengine__cache_flush() {
     74        // Don't cause a fatal if there is no WpeCommon class
     75        if ( ! class_exists( 'WpeCommon' ) ) {
     76            return false;
     77        }
     78
     79        if ( function_exists( 'WpeCommon::purge_memcached' ) ) {
     80            \WpeCommon::purge_memcached();
     81        }
     82
     83        if ( function_exists( 'WpeCommon::clear_maxcdn_cache' ) ) {
     84            \WpeCommon::clear_maxcdn_cache();
     85        }
     86
     87        if ( function_exists( 'WpeCommon::purge_varnish_cache' ) ) {
     88            \WpeCommon::purge_varnish_cache();
     89        }
     90
     91        global $wp_object_cache;
     92        // Check for valid cache. Sometimes this is broken -- we don't know why! -- and it crashes when we flush.
     93        // If there's no cache, we don't need to flush anyway.
     94        $error = '';
     95
     96        if ( $wp_object_cache && is_object( $wp_object_cache ) ) {
     97            try {
     98                wp_cache_flush();
     99            } catch ( \Exception $ex ) {
     100                $error = "Warning: error flushing WordPress object cache: " . $ex->getMessage();
     101            }
     102        }
     103
     104        return $error;
     105    }
     106
     107    public function wpengine__reset_file_permissions() {
     108        if( !function_exists('wpe_el') || !defined('PWP_NAME') || !defined('WPE_APIKEY')) {
     109            return false;
     110        }
     111
     112        $api_domain = wpe_el($GLOBALS, 'api-domain', 'https://api.wpengine.com');
     113        $url= "${api_domain}/1.2/?method=file-permissions&account_name=" . PWP_NAME . "&wpe_apikey=" . WPE_APIKEY;
     114        $http = new \WP_Http;
     115        $msg  = $http->get( $url );
     116        if ( is_a( $msg, 'WP_Error' ) )
     117            return false;
     118        if ( ! isset( $msg['body'] ) )
     119            return false;
     120        $data = json_decode( $msg['body'], true );
     121        $message = @$data['message'];
     122        return $message;
    71123    }
    72124
     
    241293                $this->xcopy($dev_theme_path, $template_dir_path);
    242294            }
     295
     296            //If is WP Engine server, clear cache and reset file permissions
     297            $this->wpengine__cache_flush();
     298            $this->wpengine__reset_file_permissions();
    243299
    244300            if(wp_redirect(admin_url('admin.php?page=dev-theme&action_success=deploy_dev_theme_to_main_theme'))) exit;
  • dev-theme/trunk/readme.txt

    r2484489 r2559677  
    33Tags: development, dev, stage, staging, theme
    44Requires at least: 4.6
    5 Tested up to: 5.6.2
     5Tested up to: 5.7.2
    66Stable tag: 1.0.0
    77Requires PHP: 5.6
     
    2727== Changelog ==
    2828
     29= 1.1.0 =
     30* Added WP Engine auto cache clearing & auto file permissions resetting
     31
    2932= 1.0.7 =
    3033* Added function dth_is_dev_theme(), returns true if Dev Theme is (actually) working
Note: See TracChangeset for help on using the changeset viewer.