Changeset 1708022
- Timestamp:
- 08/03/2017 08:01:30 PM (9 years ago)
- Location:
- wp-safe-updates
- Files:
-
- 2 added
- 18 edited
- 1 copied
-
tags/1.2 (copied) (copied from wp-safe-updates/trunk)
-
tags/1.2/db.php (modified) (1 diff)
-
tags/1.2/lib/class-alternative-heap.php (modified) (11 diffs)
-
tags/1.2/package-lock.json (added)
-
tags/1.2/readme.md (modified) (2 diffs)
-
tags/1.2/readme.txt (modified) (2 diffs)
-
tags/1.2/vendor/autoload.php (modified) (1 diff)
-
tags/1.2/vendor/composer/ClassLoader.php (modified) (5 diffs)
-
tags/1.2/vendor/composer/LICENSE (modified) (1 diff)
-
tags/1.2/vendor/composer/autoload_real.php (modified) (1 diff)
-
tags/1.2/wp-safe-updates.php (modified) (5 diffs)
-
trunk/db.php (modified) (1 diff)
-
trunk/lib/class-alternative-heap.php (modified) (11 diffs)
-
trunk/package-lock.json (added)
-
trunk/readme.md (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/ClassLoader.php (modified) (5 diffs)
-
trunk/vendor/composer/LICENSE (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (1 diff)
-
trunk/wp-safe-updates.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-safe-updates/tags/1.2/db.php
r1451001 r1708022 1 1 <?php 2 3 function currheap() { 4 return isset( $_COOKIE['_alt_heap'] ) && ! empty( $_COOKIE['_alt_heap'] ) ? preg_replace('/[^a-z0-9_]/', '', strtolower( $_COOKIE['_alt_heap'] ) ) : false; 5 } 6 7 defined( 'WP_CONTENT_DIR' ) || define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/wp-content' ); 8 defined( 'WP_CONTENT_URL' ) || define( 'WP_CONTENT_URL', '/wp-content' ); 9 if ( false !== currheap() ) { 10 defined( 'WP_PLUGIN_DIR' ) || define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins_tmp_' . currheap() ); 11 defined( 'WP_PLUGIN_URL' ) || define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins_tmp_' . currheap() ); 12 defined( 'PLUGINDIR' ) || define( 'PLUGINDIR', 'wp-content/plugins_tmp_' . currheap() ); 13 } 2 14 3 15 /** -
wp-safe-updates/tags/1.2/lib/class-alternative-heap.php
r1507338 r1708022 24 24 add_action('admin_footer', array( $this, 'render_alternative_heap_indicator' ) ); 25 25 add_action('wp_footer', array( $this, 'render_alternative_heap_indicator' ) ); 26 add_action('login_footer', array( $this, 'render_alternative_heap_indicator' ) ); 26 27 } 27 28 } … … 54 55 $alt_heap = $query_vars['alt_heap']; 55 56 56 if( $alt_heap === 'clear' ) { 57 if ( $alt_heap === 'clean' ) { 58 // this means we want to clean the alt heap temp files and tables 59 $this->delete_alt_plugins_dirs( $_COOKIE['_alt_heap'] ); 60 $this->delete_tmp_wp_tables( $_COOKIE['_alt_heap'] ); 61 62 // and then clear the cookie 63 $alt_heap = ''; 64 } 65 66 if( $alt_heap === 'clear' || $alt_heap === 'exit' ) { 57 67 // this means we want to clear the heap cookie 58 68 // equivalent to empty ?alt_heap= 59 69 $alt_heap = ''; 60 70 } 71 61 72 62 73 // not in a heap yet and GET alt_heap is defined and current user has plugin install privileges … … 84 95 $request_uri .= empty( $query_string ) ? '' : '?' . $query_string; 85 96 97 // flush caches for this just in case 98 wp_cache_flush(); 99 86 100 // redirect to requested page, but with alt heap this time 87 101 wp_redirect( $request_uri ); … … 102 116 103 117 /** 118 * Derives the original db prefix from an alt heap prefix 119 */ 120 public static function derive_orig_prefix( $alt_prefix ) { 121 $offset = strpos( $alt_prefix, 'tmp_' ) ? strpos( $alt_prefix, 'tmp_' ) : strlen( $alt_prefix ); 122 $orig_prefix = substr( $alt_prefix, 0, $offset ); 123 124 // fall back to wp_ if all else fails 125 if( empty( $orig_prefix ) ) { 126 return 'wp_'; 127 } 128 return $orig_prefix; 129 } 130 131 /** 104 132 * Returns the plugins dir suffix for an alternative heap 105 133 */ … … 118 146 public static function get_wp_tables() { 119 147 global $wpdb; 120 $tables = $wpdb->get_results( $wpdb->prepare( "SHOW TABLES LIKE %s;", str_replace( '_', '\_', $wpdb->prefix) . '%' ), ARRAY_N ); 148 $orig_prefix = isset( $_COOKIE['_alt_heap'] ) ? self::derive_orig_prefix( $wpdb->prefix ) : $wpdb->prefix; 149 $tables = $wpdb->get_results( $wpdb->prepare( "SHOW TABLES LIKE %s;", str_replace( '_', '\_', $orig_prefix ) . '%' ), ARRAY_N ); 121 150 $tables = array_map( 'reset', $tables ); 122 151 … … 133 162 public static function get_tmp_wp_tables( $alt_heap = "" ) { 134 163 global $wpdb; 135 $tables = $wpdb->get_results( $wpdb->prepare( "SHOW TABLES LIKE %s;", str_replace( '_', '\_', self::get_alt_prefix( $alt_heap ) ) . '%' ), ARRAY_N ); 164 // alt prefix will already be $wpdb->prefix if currently in a heap 165 $alt_prefix = isset( $_COOKIE['_alt_heap'] ) ? $wpdb->prefix : self::get_alt_prefix( $alt_heap ); 166 $tables = $wpdb->get_results( $wpdb->prepare( "SHOW TABLES LIKE %s;", str_replace( '_', '\_', $alt_prefix ) . '%' ), ARRAY_N ); 136 167 $tables = array_map( 'reset', $tables ); 137 168 return $tables; … … 257 288 $dirs = array(); 258 289 if( ! empty( $alt_heap ) ) { 259 // return $alt_heap dir if defined 260 $dirs[] = WP_PLUGIN_DIR . self::get_alt_suffix( $alt_heap ); 261 262 // return false if no the alt heap dir doesn't exist 290 $suffix = self::get_alt_suffix( $alt_heap ); 291 292 // WP_PLUGIN_DIR will be the alt heap dir if in an alt heap 293 if ( strpos( WP_PLUGIN_DIR, $suffix ) ) { 294 $dirs[] = WP_PLUGIN_DIR; 295 } else { 296 $dirs[] = WP_PLUGIN_DIR . self::get_alt_suffix( $alt_heap ); 297 } 298 299 // return false if the alt heap dir doesn't exist 263 300 if( ! file_exists( $dirs[0] ) ) { 264 301 return false; … … 266 303 } 267 304 else { 268 // otherwise j sut return all alt plugin dirs305 // otherwise just return all alt plugin dirs 269 306 $iterator = new DirectoryIterator( dirname( WP_PLUGIN_DIR ) ); 270 307 foreach( $iterator as $node ) { … … 275 312 } 276 313 } 314 277 315 return $dirs; 278 316 } … … 282 320 */ 283 321 public function delete_alt_plugins_dirs( $alt_heap = "" ) { 284 $orig_plugins_dir = WP_PLUGIN_DIR; 322 $suffix = self::get_alt_suffix( $alt_heap ); 323 $orig_plugins_dir = str_replace( $suffix, '', WP_PLUGIN_DIR ); 285 324 $alt_dirs_to_delete = self::get_alt_plugins_dirs( $alt_heap ); 286 325 … … 320 359 <div id="alt-heap-indicator"> 321 360 <?php echo wp_sprintf( __('You are currently testing updates. Any changes you make will not be saved.', 'wp-safe-updates'), currheap() ); ?> 322 <a href="<?php echo admin_url('plugins.php?alt_heap=clea r'); ?>"><?php _e('Finish tests', 'wp-safe-updates'); ?></a>361 <a href="<?php echo admin_url('plugins.php?alt_heap=clean'); ?>"><?php _e('Finish tests', 'wp-safe-updates'); ?></a> 323 362 </div> 324 363 <?php -
wp-safe-updates/tags/1.2/readme.md
r1454344 r1708022 1 # WP Safe Updates .1 # WP Safe Updates 2 2 [](https://packagist.org/packages/anttiviljami/wp-safe-updates) [](https://packagist.org/packages/anttiviljami/wp-safe-updates) [](https://packagist.org/packages/anttiviljami/wp-safe-updates) [](https://packagist.org/packages/anttiviljami/wp-safe-updates) 3 3 … … 51 51 3. Activate the plugin 52 52 53 ## Configuration54 55 First copy the `db.php` file from this plugin to your `wp-content` directory.56 57 Then just paste these lines to your `wp-config.php`.58 ```php59 /**60 * WordPress Safe Updates required configuration61 */62 function currheap() {63 return isset( $_COOKIE['_alt_heap'] ) && ! empty( $_COOKIE['_alt_heap'] ) ? preg_replace('/[^a-z0-9_]/', '', strtolower( $_COOKIE['_alt_heap'] ) ) : false;64 }65 defined( 'WP_CONTENT_DIR' ) || define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/wp-content' );66 defined( 'WP_CONTENT_URL' ) || define( 'WP_CONTENT_URL', '/wp-content' );67 if ( false !== currheap() ) {68 defined( 'WP_PLUGIN_DIR' ) || define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins_tmp_' . currheap() );69 defined( 'WP_PLUGIN_URL' ) || define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins_tmp_' . currheap() );70 defined( 'PLUGINDIR' ) || define( 'PLUGINDIR', 'wp-content/plugins_tmp_' . currheap() );71 }72 ```73 -
wp-safe-updates/tags/1.2/readme.txt
r1507338 r1708022 5 5 Requires at least: 4.5 6 6 Tested up to: 4.6.1 7 Stable tag: 1. 17 Stable tag: 1.2 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 27 27 https://github.com/anttiviljami/wp-safe-updates 28 28 29 == Installation ==30 31 Install and activate the plugin via wp-admin.32 33 Then copy the `db.php` file from this plugin to your `wp-content` directory.34 35 Finally, paste these lines to your `wp-config.php`.36 37 `/**38 * WordPress Safe Updates required configuration39 */40 function currheap() {41 return isset( $_COOKIE['_alt_heap'] ) && ! empty( $_COOKIE['_alt_heap'] ) ? preg_replace('/[^a-z0-9_]/', '', strtolower( $_COOKIE['_alt_heap'] ) ) : false;42 }43 defined( 'WP_CONTENT_DIR' ) || define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/wp-content' );44 defined( 'WP_CONTENT_URL' ) || define( 'WP_CONTENT_URL', '/wp-content' );45 if ( false !== currheap() ) {46 defined( 'WP_PLUGIN_DIR' ) || define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins_tmp_' . currheap() );47 defined( 'WP_PLUGIN_URL' ) || define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins_tmp_' . currheap() );48 defined( 'PLUGINDIR' ) || define( 'PLUGINDIR', 'wp-content/plugins_tmp_' . currheap() );49 }`50 51 29 == Frequently Asked Questions == 52 30 -
wp-safe-updates/tags/1.2/vendor/autoload.php
r1451001 r1708022 3 3 // autoload.php @generated by Composer 4 4 5 require_once __DIR__ . '/composer ' . '/autoload_real.php';5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 7 return ComposerAutoloaderInit6b6b80b301d3663ac27b1b7644fe5e53::getLoader(); -
wp-safe-updates/tags/1.2/vendor/composer/ClassLoader.php
r1451001 r1708022 54 54 private $useIncludePath = false; 55 55 private $classMap = array(); 56 57 56 private $classMapAuthoritative = false; 57 private $missingClasses = array(); 58 private $apcuPrefix; 58 59 59 60 public function getPrefixes() … … 273 274 274 275 /** 276 * APCu prefix to use to cache found/not-found classes, if the extension is enabled. 277 * 278 * @param string|null $apcuPrefix 279 */ 280 public function setApcuPrefix($apcuPrefix) 281 { 282 $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; 283 } 284 285 /** 286 * The APCu prefix in use, or null if APCu caching is not enabled. 287 * 288 * @return string|null 289 */ 290 public function getApcuPrefix() 291 { 292 return $this->apcuPrefix; 293 } 294 295 /** 275 296 * Registers this instance as an autoloader. 276 297 * … … 314 335 public function findFile($class) 315 336 { 316 // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731317 if ('\\' == $class[0]) {318 $class = substr($class, 1);319 }320 321 337 // class map lookup 322 338 if (isset($this->classMap[$class])) { 323 339 return $this->classMap[$class]; 324 340 } 325 if ($this->classMapAuthoritative ) {341 if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { 326 342 return false; 327 343 } 344 if (null !== $this->apcuPrefix) { 345 $file = apcu_fetch($this->apcuPrefix.$class, $hit); 346 if ($hit) { 347 return $file; 348 } 349 } 328 350 329 351 $file = $this->findFileWithExtension($class, '.php'); 330 352 331 353 // Search for Hack files if we are running on HHVM 332 if ( $file === null&& defined('HHVM_VERSION')) {354 if (false === $file && defined('HHVM_VERSION')) { 333 355 $file = $this->findFileWithExtension($class, '.hh'); 334 356 } 335 357 336 if ($file === null) { 358 if (null !== $this->apcuPrefix) { 359 apcu_add($this->apcuPrefix.$class, $file); 360 } 361 362 if (false === $file) { 337 363 // Remember that this class does not exist. 338 return $this->classMap[$class] = false;364 $this->missingClasses[$class] = true; 339 365 } 340 366 … … 349 375 $first = $class[0]; 350 376 if (isset($this->prefixLengthsPsr4[$first])) { 351 foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { 352 if (0 === strpos($class, $prefix)) { 353 foreach ($this->prefixDirsPsr4[$prefix] as $dir) { 377 $subPath = $class; 378 while (false !== $lastPos = strrpos($subPath, '\\')) { 379 $subPath = substr($subPath, 0, $lastPos); 380 $search = $subPath.'\\'; 381 if (isset($this->prefixDirsPsr4[$search])) { 382 foreach ($this->prefixDirsPsr4[$search] as $dir) { 383 $length = $this->prefixLengthsPsr4[$first][$search]; 354 384 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { 355 385 return $file; … … 400 430 return $file; 401 431 } 432 433 return false; 402 434 } 403 435 } -
wp-safe-updates/tags/1.2/vendor/composer/LICENSE
r1451001 r1708022 1 1 2 Copyright (c) 2016Nils Adermann, Jordi Boggiano2 Copyright (c) Nils Adermann, Jordi Boggiano 3 3 4 4 Permission is hereby granted, free of charge, to any person obtaining a copy -
wp-safe-updates/tags/1.2/vendor/composer/autoload_real.php
r1451001 r1708022 24 24 spl_autoload_unregister(array('ComposerAutoloaderInit6b6b80b301d3663ac27b1b7644fe5e53', 'loadClassLoader')); 25 25 26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') ;26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); 27 27 if ($useStaticLoader) { 28 28 require_once __DIR__ . '/autoload_static.php'; -
wp-safe-updates/tags/1.2/wp-safe-updates.php
r1507338 r1708022 4 4 * Plugin URI: https://github.com/anttiviljami/wp-safe-updates 5 5 * Description: Test WordPress plugin updates safely before applying them on the live site. 6 * Version: 1. 16 * Version: 1.2 7 7 * Author: @anttiviljami 8 8 * Author URI: https://github.com/anttiviljami … … 34 34 public $alt_heap; 35 35 public $update_logic; 36 37 public static $dropin_target = WP_CONTENT_DIR . '/db.php'; 38 public static $dropin_file = __DIR__ . '/db.php'; 36 39 37 40 public static function init() { … … 66 69 } 67 70 68 // clear all heaps on uninstall 71 // configure custom dropin file 72 register_activation_hook( __FILE__, array( 'Safe_Updates', 'install_custom_dropin' ) ); 73 74 // clear all heaps on uninstall and clean up files 69 75 register_uninstall_hook( __FILE__, array( 'Safe_Updates', 'uninstall_cleanup' ) ); 70 76 } … … 92 98 <div class="notice notice-warning is-dismissible"> 93 99 <?php $configure_action = 'https://wordpress.org/plugins/wp-safe-updates/installation/'; ?> 94 <p><?php echo wp_sprintf( __('WP Safe Updates is not yet active. Please <a href="%s" target="_blank">configure</a> it.', 'wp-safe-updates'), $configure_action ); ?> <button type="button" class="notice-dismiss"></button></p>100 <p><?php echo wp_sprintf( __('WP Safe Updates is not yet active. Please copy the <pre>db.php</pre> file inside this plugin to your wp-content directory.', 'wp-safe-updates'), $configure_action ); ?> <button type="button" class="notice-dismiss"></button></p> 95 101 </div> 96 102 <?php 97 103 } 98 104 105 106 /** 107 * Configure our custom db.php dropin 108 */ 109 public static function install_custom_dropin() { 110 if ( ! file_exists( self::$dropin_target ) ) { 111 error_log('Copying ' . self::$dropin_file . ' -> ' . self::$dropin_target); 112 @copy( self::$dropin_file, self::$dropin_target ); 113 } 114 } 99 115 100 116 /** … … 110 126 // Deleting all tmp tables... 111 127 $alt_heap->delete_tmp_wp_tables(); 128 129 if ( file_exists( self::$dropin_target ) && hash_file( 'md5', self::$dropin_target ) === hash_file( 'md5', self::$dropin_file )) { 130 @unlink( self::$dropin_target ); 131 } 112 132 } 113 114 133 115 134 /** -
wp-safe-updates/trunk/db.php
r1451001 r1708022 1 1 <?php 2 3 function currheap() { 4 return isset( $_COOKIE['_alt_heap'] ) && ! empty( $_COOKIE['_alt_heap'] ) ? preg_replace('/[^a-z0-9_]/', '', strtolower( $_COOKIE['_alt_heap'] ) ) : false; 5 } 6 7 defined( 'WP_CONTENT_DIR' ) || define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/wp-content' ); 8 defined( 'WP_CONTENT_URL' ) || define( 'WP_CONTENT_URL', '/wp-content' ); 9 if ( false !== currheap() ) { 10 defined( 'WP_PLUGIN_DIR' ) || define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins_tmp_' . currheap() ); 11 defined( 'WP_PLUGIN_URL' ) || define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins_tmp_' . currheap() ); 12 defined( 'PLUGINDIR' ) || define( 'PLUGINDIR', 'wp-content/plugins_tmp_' . currheap() ); 13 } 2 14 3 15 /** -
wp-safe-updates/trunk/lib/class-alternative-heap.php
r1507338 r1708022 24 24 add_action('admin_footer', array( $this, 'render_alternative_heap_indicator' ) ); 25 25 add_action('wp_footer', array( $this, 'render_alternative_heap_indicator' ) ); 26 add_action('login_footer', array( $this, 'render_alternative_heap_indicator' ) ); 26 27 } 27 28 } … … 54 55 $alt_heap = $query_vars['alt_heap']; 55 56 56 if( $alt_heap === 'clear' ) { 57 if ( $alt_heap === 'clean' ) { 58 // this means we want to clean the alt heap temp files and tables 59 $this->delete_alt_plugins_dirs( $_COOKIE['_alt_heap'] ); 60 $this->delete_tmp_wp_tables( $_COOKIE['_alt_heap'] ); 61 62 // and then clear the cookie 63 $alt_heap = ''; 64 } 65 66 if( $alt_heap === 'clear' || $alt_heap === 'exit' ) { 57 67 // this means we want to clear the heap cookie 58 68 // equivalent to empty ?alt_heap= 59 69 $alt_heap = ''; 60 70 } 71 61 72 62 73 // not in a heap yet and GET alt_heap is defined and current user has plugin install privileges … … 84 95 $request_uri .= empty( $query_string ) ? '' : '?' . $query_string; 85 96 97 // flush caches for this just in case 98 wp_cache_flush(); 99 86 100 // redirect to requested page, but with alt heap this time 87 101 wp_redirect( $request_uri ); … … 102 116 103 117 /** 118 * Derives the original db prefix from an alt heap prefix 119 */ 120 public static function derive_orig_prefix( $alt_prefix ) { 121 $offset = strpos( $alt_prefix, 'tmp_' ) ? strpos( $alt_prefix, 'tmp_' ) : strlen( $alt_prefix ); 122 $orig_prefix = substr( $alt_prefix, 0, $offset ); 123 124 // fall back to wp_ if all else fails 125 if( empty( $orig_prefix ) ) { 126 return 'wp_'; 127 } 128 return $orig_prefix; 129 } 130 131 /** 104 132 * Returns the plugins dir suffix for an alternative heap 105 133 */ … … 118 146 public static function get_wp_tables() { 119 147 global $wpdb; 120 $tables = $wpdb->get_results( $wpdb->prepare( "SHOW TABLES LIKE %s;", str_replace( '_', '\_', $wpdb->prefix) . '%' ), ARRAY_N ); 148 $orig_prefix = isset( $_COOKIE['_alt_heap'] ) ? self::derive_orig_prefix( $wpdb->prefix ) : $wpdb->prefix; 149 $tables = $wpdb->get_results( $wpdb->prepare( "SHOW TABLES LIKE %s;", str_replace( '_', '\_', $orig_prefix ) . '%' ), ARRAY_N ); 121 150 $tables = array_map( 'reset', $tables ); 122 151 … … 133 162 public static function get_tmp_wp_tables( $alt_heap = "" ) { 134 163 global $wpdb; 135 $tables = $wpdb->get_results( $wpdb->prepare( "SHOW TABLES LIKE %s;", str_replace( '_', '\_', self::get_alt_prefix( $alt_heap ) ) . '%' ), ARRAY_N ); 164 // alt prefix will already be $wpdb->prefix if currently in a heap 165 $alt_prefix = isset( $_COOKIE['_alt_heap'] ) ? $wpdb->prefix : self::get_alt_prefix( $alt_heap ); 166 $tables = $wpdb->get_results( $wpdb->prepare( "SHOW TABLES LIKE %s;", str_replace( '_', '\_', $alt_prefix ) . '%' ), ARRAY_N ); 136 167 $tables = array_map( 'reset', $tables ); 137 168 return $tables; … … 257 288 $dirs = array(); 258 289 if( ! empty( $alt_heap ) ) { 259 // return $alt_heap dir if defined 260 $dirs[] = WP_PLUGIN_DIR . self::get_alt_suffix( $alt_heap ); 261 262 // return false if no the alt heap dir doesn't exist 290 $suffix = self::get_alt_suffix( $alt_heap ); 291 292 // WP_PLUGIN_DIR will be the alt heap dir if in an alt heap 293 if ( strpos( WP_PLUGIN_DIR, $suffix ) ) { 294 $dirs[] = WP_PLUGIN_DIR; 295 } else { 296 $dirs[] = WP_PLUGIN_DIR . self::get_alt_suffix( $alt_heap ); 297 } 298 299 // return false if the alt heap dir doesn't exist 263 300 if( ! file_exists( $dirs[0] ) ) { 264 301 return false; … … 266 303 } 267 304 else { 268 // otherwise j sut return all alt plugin dirs305 // otherwise just return all alt plugin dirs 269 306 $iterator = new DirectoryIterator( dirname( WP_PLUGIN_DIR ) ); 270 307 foreach( $iterator as $node ) { … … 275 312 } 276 313 } 314 277 315 return $dirs; 278 316 } … … 282 320 */ 283 321 public function delete_alt_plugins_dirs( $alt_heap = "" ) { 284 $orig_plugins_dir = WP_PLUGIN_DIR; 322 $suffix = self::get_alt_suffix( $alt_heap ); 323 $orig_plugins_dir = str_replace( $suffix, '', WP_PLUGIN_DIR ); 285 324 $alt_dirs_to_delete = self::get_alt_plugins_dirs( $alt_heap ); 286 325 … … 320 359 <div id="alt-heap-indicator"> 321 360 <?php echo wp_sprintf( __('You are currently testing updates. Any changes you make will not be saved.', 'wp-safe-updates'), currheap() ); ?> 322 <a href="<?php echo admin_url('plugins.php?alt_heap=clea r'); ?>"><?php _e('Finish tests', 'wp-safe-updates'); ?></a>361 <a href="<?php echo admin_url('plugins.php?alt_heap=clean'); ?>"><?php _e('Finish tests', 'wp-safe-updates'); ?></a> 323 362 </div> 324 363 <?php -
wp-safe-updates/trunk/readme.md
r1454344 r1708022 1 # WP Safe Updates .1 # WP Safe Updates 2 2 [](https://packagist.org/packages/anttiviljami/wp-safe-updates) [](https://packagist.org/packages/anttiviljami/wp-safe-updates) [](https://packagist.org/packages/anttiviljami/wp-safe-updates) [](https://packagist.org/packages/anttiviljami/wp-safe-updates) 3 3 … … 51 51 3. Activate the plugin 52 52 53 ## Configuration54 55 First copy the `db.php` file from this plugin to your `wp-content` directory.56 57 Then just paste these lines to your `wp-config.php`.58 ```php59 /**60 * WordPress Safe Updates required configuration61 */62 function currheap() {63 return isset( $_COOKIE['_alt_heap'] ) && ! empty( $_COOKIE['_alt_heap'] ) ? preg_replace('/[^a-z0-9_]/', '', strtolower( $_COOKIE['_alt_heap'] ) ) : false;64 }65 defined( 'WP_CONTENT_DIR' ) || define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/wp-content' );66 defined( 'WP_CONTENT_URL' ) || define( 'WP_CONTENT_URL', '/wp-content' );67 if ( false !== currheap() ) {68 defined( 'WP_PLUGIN_DIR' ) || define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins_tmp_' . currheap() );69 defined( 'WP_PLUGIN_URL' ) || define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins_tmp_' . currheap() );70 defined( 'PLUGINDIR' ) || define( 'PLUGINDIR', 'wp-content/plugins_tmp_' . currheap() );71 }72 ```73 -
wp-safe-updates/trunk/readme.txt
r1507338 r1708022 5 5 Requires at least: 4.5 6 6 Tested up to: 4.6.1 7 Stable tag: 1. 17 Stable tag: 1.2 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 27 27 https://github.com/anttiviljami/wp-safe-updates 28 28 29 == Installation ==30 31 Install and activate the plugin via wp-admin.32 33 Then copy the `db.php` file from this plugin to your `wp-content` directory.34 35 Finally, paste these lines to your `wp-config.php`.36 37 `/**38 * WordPress Safe Updates required configuration39 */40 function currheap() {41 return isset( $_COOKIE['_alt_heap'] ) && ! empty( $_COOKIE['_alt_heap'] ) ? preg_replace('/[^a-z0-9_]/', '', strtolower( $_COOKIE['_alt_heap'] ) ) : false;42 }43 defined( 'WP_CONTENT_DIR' ) || define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/wp-content' );44 defined( 'WP_CONTENT_URL' ) || define( 'WP_CONTENT_URL', '/wp-content' );45 if ( false !== currheap() ) {46 defined( 'WP_PLUGIN_DIR' ) || define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins_tmp_' . currheap() );47 defined( 'WP_PLUGIN_URL' ) || define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins_tmp_' . currheap() );48 defined( 'PLUGINDIR' ) || define( 'PLUGINDIR', 'wp-content/plugins_tmp_' . currheap() );49 }`50 51 29 == Frequently Asked Questions == 52 30 -
wp-safe-updates/trunk/vendor/autoload.php
r1451001 r1708022 3 3 // autoload.php @generated by Composer 4 4 5 require_once __DIR__ . '/composer ' . '/autoload_real.php';5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 7 return ComposerAutoloaderInit6b6b80b301d3663ac27b1b7644fe5e53::getLoader(); -
wp-safe-updates/trunk/vendor/composer/ClassLoader.php
r1451001 r1708022 54 54 private $useIncludePath = false; 55 55 private $classMap = array(); 56 57 56 private $classMapAuthoritative = false; 57 private $missingClasses = array(); 58 private $apcuPrefix; 58 59 59 60 public function getPrefixes() … … 273 274 274 275 /** 276 * APCu prefix to use to cache found/not-found classes, if the extension is enabled. 277 * 278 * @param string|null $apcuPrefix 279 */ 280 public function setApcuPrefix($apcuPrefix) 281 { 282 $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; 283 } 284 285 /** 286 * The APCu prefix in use, or null if APCu caching is not enabled. 287 * 288 * @return string|null 289 */ 290 public function getApcuPrefix() 291 { 292 return $this->apcuPrefix; 293 } 294 295 /** 275 296 * Registers this instance as an autoloader. 276 297 * … … 314 335 public function findFile($class) 315 336 { 316 // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731317 if ('\\' == $class[0]) {318 $class = substr($class, 1);319 }320 321 337 // class map lookup 322 338 if (isset($this->classMap[$class])) { 323 339 return $this->classMap[$class]; 324 340 } 325 if ($this->classMapAuthoritative ) {341 if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { 326 342 return false; 327 343 } 344 if (null !== $this->apcuPrefix) { 345 $file = apcu_fetch($this->apcuPrefix.$class, $hit); 346 if ($hit) { 347 return $file; 348 } 349 } 328 350 329 351 $file = $this->findFileWithExtension($class, '.php'); 330 352 331 353 // Search for Hack files if we are running on HHVM 332 if ( $file === null&& defined('HHVM_VERSION')) {354 if (false === $file && defined('HHVM_VERSION')) { 333 355 $file = $this->findFileWithExtension($class, '.hh'); 334 356 } 335 357 336 if ($file === null) { 358 if (null !== $this->apcuPrefix) { 359 apcu_add($this->apcuPrefix.$class, $file); 360 } 361 362 if (false === $file) { 337 363 // Remember that this class does not exist. 338 return $this->classMap[$class] = false;364 $this->missingClasses[$class] = true; 339 365 } 340 366 … … 349 375 $first = $class[0]; 350 376 if (isset($this->prefixLengthsPsr4[$first])) { 351 foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { 352 if (0 === strpos($class, $prefix)) { 353 foreach ($this->prefixDirsPsr4[$prefix] as $dir) { 377 $subPath = $class; 378 while (false !== $lastPos = strrpos($subPath, '\\')) { 379 $subPath = substr($subPath, 0, $lastPos); 380 $search = $subPath.'\\'; 381 if (isset($this->prefixDirsPsr4[$search])) { 382 foreach ($this->prefixDirsPsr4[$search] as $dir) { 383 $length = $this->prefixLengthsPsr4[$first][$search]; 354 384 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { 355 385 return $file; … … 400 430 return $file; 401 431 } 432 433 return false; 402 434 } 403 435 } -
wp-safe-updates/trunk/vendor/composer/LICENSE
r1451001 r1708022 1 1 2 Copyright (c) 2016Nils Adermann, Jordi Boggiano2 Copyright (c) Nils Adermann, Jordi Boggiano 3 3 4 4 Permission is hereby granted, free of charge, to any person obtaining a copy -
wp-safe-updates/trunk/vendor/composer/autoload_real.php
r1451001 r1708022 24 24 spl_autoload_unregister(array('ComposerAutoloaderInit6b6b80b301d3663ac27b1b7644fe5e53', 'loadClassLoader')); 25 25 26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') ;26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); 27 27 if ($useStaticLoader) { 28 28 require_once __DIR__ . '/autoload_static.php'; -
wp-safe-updates/trunk/wp-safe-updates.php
r1507338 r1708022 4 4 * Plugin URI: https://github.com/anttiviljami/wp-safe-updates 5 5 * Description: Test WordPress plugin updates safely before applying them on the live site. 6 * Version: 1. 16 * Version: 1.2 7 7 * Author: @anttiviljami 8 8 * Author URI: https://github.com/anttiviljami … … 34 34 public $alt_heap; 35 35 public $update_logic; 36 37 public static $dropin_target = WP_CONTENT_DIR . '/db.php'; 38 public static $dropin_file = __DIR__ . '/db.php'; 36 39 37 40 public static function init() { … … 66 69 } 67 70 68 // clear all heaps on uninstall 71 // configure custom dropin file 72 register_activation_hook( __FILE__, array( 'Safe_Updates', 'install_custom_dropin' ) ); 73 74 // clear all heaps on uninstall and clean up files 69 75 register_uninstall_hook( __FILE__, array( 'Safe_Updates', 'uninstall_cleanup' ) ); 70 76 } … … 92 98 <div class="notice notice-warning is-dismissible"> 93 99 <?php $configure_action = 'https://wordpress.org/plugins/wp-safe-updates/installation/'; ?> 94 <p><?php echo wp_sprintf( __('WP Safe Updates is not yet active. Please <a href="%s" target="_blank">configure</a> it.', 'wp-safe-updates'), $configure_action ); ?> <button type="button" class="notice-dismiss"></button></p>100 <p><?php echo wp_sprintf( __('WP Safe Updates is not yet active. Please copy the <pre>db.php</pre> file inside this plugin to your wp-content directory.', 'wp-safe-updates'), $configure_action ); ?> <button type="button" class="notice-dismiss"></button></p> 95 101 </div> 96 102 <?php 97 103 } 98 104 105 106 /** 107 * Configure our custom db.php dropin 108 */ 109 public static function install_custom_dropin() { 110 if ( ! file_exists( self::$dropin_target ) ) { 111 error_log('Copying ' . self::$dropin_file . ' -> ' . self::$dropin_target); 112 @copy( self::$dropin_file, self::$dropin_target ); 113 } 114 } 99 115 100 116 /** … … 110 126 // Deleting all tmp tables... 111 127 $alt_heap->delete_tmp_wp_tables(); 128 129 if ( file_exists( self::$dropin_target ) && hash_file( 'md5', self::$dropin_target ) === hash_file( 'md5', self::$dropin_file )) { 130 @unlink( self::$dropin_target ); 131 } 112 132 } 113 114 133 115 134 /**
Note: See TracChangeset
for help on using the changeset viewer.