Changeset 2559677
- Timestamp:
- 07/06/2021 11:55:55 PM (4 years ago)
- Location:
- dev-theme/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
dev-theme/trunk/dev-theme.php
r2484489 r2559677 3 3 * Plugin Name: Dev Theme 4 4 * 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.85 * Version: 1.1.0 6 6 */ 7 7 … … 69 69 protected function getBackupDevThemePath() { 70 70 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; 71 123 } 72 124 … … 241 293 $this->xcopy($dev_theme_path, $template_dir_path); 242 294 } 295 296 //If is WP Engine server, clear cache and reset file permissions 297 $this->wpengine__cache_flush(); 298 $this->wpengine__reset_file_permissions(); 243 299 244 300 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 3 3 Tags: development, dev, stage, staging, theme 4 4 Requires at least: 4.6 5 Tested up to: 5. 6.25 Tested up to: 5.7.2 6 6 Stable tag: 1.0.0 7 7 Requires PHP: 5.6 … … 27 27 == Changelog == 28 28 29 = 1.1.0 = 30 * Added WP Engine auto cache clearing & auto file permissions resetting 31 29 32 = 1.0.7 = 30 33 * Added function dth_is_dev_theme(), returns true if Dev Theme is (actually) working
Note: See TracChangeset
for help on using the changeset viewer.