public function set_prefix($prefix, $set_table_names = true) { if (function_exists('currheap') && false !== currheap()) { $alt_db_prefix = 'tmp_' . currheap() . '_'; $prefix = $prefix . $alt_db_prefix; // wp_tmp_{_alt_heap}_ } // set up the prefix globally and set up all the tables parent::set_prefix($prefix, $set_table_names); if (function_exists('currheap') && false !== currheap()) { // bail out early if wordpress isn't installed // check if siteurl is available $siteurl = $this->get_var("SELECT option_value FROM {$this->options} WHERE option_name='siteurl'"); header('X-Siteurl:' . $this->options); if (null === $siteurl) { // it's not, let's bail out... // clear the alt_heap cookie setcookie('_alt_heap', '', 0, '/'); // reload the page // Note: wp_redirect isn't set yet, so we do it manually $request_uri = $_SERVER['REQUEST_URI']; header('Location:' . $request_uri); http_response_code(302); exit; } } }
private function __construct() { if (function_exists('currheap') && false !== currheap()) { // clear the symlink before updating a plugin so we don't accidentally do // anything with the live plugin add_filter('upgrader_pre_install', array($this, 'unlink_old_plugin'), 20, 2); // disable maintenance mode add_filter('upgrader_package_options', array($this, 'hack_disable_maintenance_mode')); } else { // hack the update notification string in update.php add_filter('gettext', array($this, 'hack_plugin_update_text'), 10, 3); } }
private function __construct() { global $wpdb; // load textdomain for translations add_action('plugins_loaded', array($this, 'load_our_textdomain')); if (function_exists('currheap') && is_a($wpdb, 'safe_wpdb')) { // plugin is already configured require_once 'lib/class-alternative-heap.php'; require_once 'lib/class-update-logic.php'; $this->alt_heap = Alternative_Heap::init(); $this->update_logic = Update_Logic::init(); if (false !== currheap()) { add_action('plugins_loaded', array($this, 'make_sure_we_are_first')); } } else { // show a notice to prompt the user to configure WP Safe Updates // @TODO: offer to do this automatically add_action('admin_notices', array($this, 'not_configured_notice')); } // clear all heaps on uninstall register_uninstall_hook(__FILE__, array('Safe_Updates', 'uninstall_cleanup')); }
/** * Display a notice at the bottom of the window when in an alternative heap */ public function render_alternative_heap_indicator() { // filter whether to show the alt_heap_indicator when inside an alternative heap $show_indicator = apply_filters('show_alt_heap_indicator', true); if ($show_indicator) { ?> <style>#alt-heap-indicator { font-family: Arial, sans-serif; position: fixed; bottom: 0; left: 0; right: 0; width: 100%; color: #fff; background: #770000; z-index: 10000; font-size:18px; line-height: 1; text-align: center; padding: 5px } #alt-heap-indicator a { color: #fff !important; text-decoration: underline; }</style> <div id="alt-heap-indicator"> <?php echo wp_sprintf(__('You are currently testing updates. Any changes you make will not be saved.', 'wp-safe-updates'), currheap()); ?> <a href="<?php echo admin_url('plugins.php?alt_heap=clear'); ?> "><?php _e('Finish tests', 'wp-safe-updates'); ?> </a> </div> <?php } }