Example #1
0
 function wp_schedule_update_global_counts()
 {
     if (!is_main_network() || !is_main_site()) {
         return;
     }
     if (!wp_next_scheduled('update_global_counts') && !wp_installing()) {
         wp_schedule_event(time(), 'twicedaily', 'update_global_counts');
     }
 }
Example #2
0
 /**
  * Gets the cache folder for Bladerunner.
  */
 public static function path()
 {
     $result = wp_upload_dir()['basedir'];
     if (is_multisite() && !(is_main_network() && is_main_site() && defined('MULTISITE'))) {
         $result = realpath($result . '/../..');
     }
     $result .= '/.cache';
     $result = realpath($result);
     return apply_filters('bladerunner/cache/path', $result);
 }
Example #3
0
/**
 * Attach SSO functions into WordPress.
 */
function bootstrap()
{
    // We never need this for the main network
    if (is_main_network()) {
        return;
    }
    add_filter('mercator.sso.main_domain_network', __NAMESPACE__ . '\\get_main_network');
    add_filter('mercator.sso.is_main_domain', __NAMESPACE__ . '\\correct_for_subdomain_networks', 10, 3);
    add_filter('mercator.sso.main_site_for_actions', __NAMESPACE__ . '\\set_main_site_for_actions');
    add_action('muplugins_loaded', __NAMESPACE__ . '\\initialize_cookie_domain', 11);
}
Example #4
0
 public static function delete_transients()
 {
     global $_wp_using_ext_object_cache;
     if ($_wp_using_ext_object_cache) {
         return 0;
     }
     global $wpdb;
     $records = 0;
     // Delete transients from options table
     $records .= self::delete_transients_single_site();
     // Delete transients from multisite, if configured as such
     if (is_multisite() && is_main_network()) {
         $records .= self::delete_transients_multisite();
     }
     return $records;
 }
 function delete_file($file_name)
 {
     $url_parts = parse_url($file_name);
     if (false !== stripos($url_parts['path'], constant('LOCAL_UPLOADS'))) {
         $file_uri = substr($url_parts['path'], stripos($url_parts['path'], constant('LOCAL_UPLOADS')) + strlen(constant('LOCAL_UPLOADS')));
     } else {
         $file_uri = '/' . $url_parts['path'];
     }
     $headers = array('X-Client-Site-ID: ' . constant('FILES_CLIENT_SITE_ID'), 'X-Access-Token: ' . constant('FILES_ACCESS_TOKEN'));
     $service_url = $this->get_files_service_hostname() . '/' . $this->get_upload_path();
     if (is_multisite() && !(is_main_network() && is_main_site())) {
         $service_url .= '/sites/' . get_current_blog_id();
     }
     $ch = curl_init($service_url . $file_uri);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_TIMEOUT, 10);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_exec($ch);
     $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     curl_close($ch);
     if (200 != $http_code) {
         error_log(sprintf(__('Error deleting the file from the remote servers: Code %d'), $http_code));
         return;
     }
     // We successfully deleted the file, purge the file from the caches
     $invalidation_url = get_site_url() . '/' . $this->get_upload_path();
     if (is_multisite() && !(is_main_network() && is_main_site())) {
         $invalidation_url .= '/sites/' . get_current_blog_id();
     }
     $invalidation_url .= $file_uri;
     $this->purge_file_cache($invalidation_url, 'PURGE');
 }
Example #6
0
/**
 * Determine if global tables should be upgraded.
 *
 * This function performs a series of checks to ensure the environment allows
 * for the safe upgrading of global WordPress database tables. It is necessary
 * because global tables will commonly grow to millions of rows on large
 * installations, and the ability to control their upgrade routines can be
 * critical to the operation of large networks.
 *
 * In a future iteration, this function may use `wp_is_large_network()` to more-
 * intelligently prevent global table upgrades. Until then, we make sure
 * WordPress is on the main site of the main network, to avoid running queries
 * more than once in multi-site or multi-network environments.
 *
 * @since 4.3.0
 *
 * @return bool Whether to run the upgrade routines on global tables.
 */
function wp_should_upgrade_global_tables()
{
    // Return false early if explicitly not upgrading
    if (defined('DO_NOT_UPGRADE_GLOBAL_TABLES')) {
        return false;
    }
    // Assume global tables should be upgraded
    $should_upgrade = true;
    // Set to false if not on main network (does not matter if not multi-network)
    if (!is_main_network()) {
        $should_upgrade = false;
    }
    // Set to false if not on main site of current network (does not matter if not multi-site)
    if (!is_main_site()) {
        $should_upgrade = false;
    }
    /**
     * Filter if upgrade routines should be run on global tables.
     *
     * @param bool $should_upgrade Whether to run the upgrade routines on global tables.
     */
    return apply_filters('wp_should_upgrade_global_tables', $should_upgrade);
}
 /**
  * Get the prefix path for the files. Ignores WP media library
  * year month subdirectory setting and just uses S3 setting
  *
  * @param string $time
  *
  * @return string
  */
 function get_dynamic_prefix($time = null)
 {
     $prefix = '';
     $subdir = '';
     // If multisite (and if not the main site in a post-MU network)
     if (is_multisite() && !(is_main_network() && is_main_site() && defined('MULTISITE'))) {
         if (!get_site_option('ms_files_rewriting')) {
             /*
              * If ms-files rewriting is disabled (networks created post-3.5), it is fairly
              * straightforward: Append sites/%d if we're not on the main site (for post-MU
              * networks). (The extra directory prevents a four-digit ID from conflicting with
              * a year-based directory for the main site. But if a MU-era network has disabled
              * ms-files rewriting manually, they don't need the extra directory, as they never
              * had wp-content/uploads for the main site.)
              */
             if (defined('MULTISITE')) {
                 $prefix = '/sites/' . get_current_blog_id();
             } else {
                 $prefix = '/' . get_current_blog_id();
             }
         } elseif (defined('UPLOADS') && !ms_is_switched()) {
             /*
              * Handle the old-form ms-files.php rewriting if the network still has that enabled.
              * When ms-files rewriting is enabled, then we only listen to UPLOADS when:
              * 1) We are not on the main site in a post-MU network, as wp-content/uploads is used
              *    there, and
              * 2) We are not switched, as ms_upload_constants() hardcodes these constants to reflect
              *    the original blog ID.
              *
              * Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute.
              * (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as
              * as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files
              * rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
              */
             if (defined('BLOGUPLOADDIR')) {
                 $prefix = untrailingslashit(BLOGUPLOADDIR);
             } else {
                 $prefix = ABSPATH . UPLOADS;
             }
         }
     }
     if ($this->get_setting('use-yearmonth-folders')) {
         $subdir = $this->get_year_month_directory_name($time);
         $prefix .= $subdir;
     }
     // support legacy MS installs (<3.5 since upgraded) for subsites
     if (is_multisite() && !(is_main_network() && is_main_site()) && false === strpos($prefix, 'sites/')) {
         $details = get_blog_details(get_current_blog_id());
         $legacy_ms_prefix = 'sites/' . $details->blog_id . '/';
         $legacy_ms_prefix = apply_filters('as3cf_legacy_ms_subsite_prefix', $legacy_ms_prefix, $details);
         $prefix = '/' . trailingslashit(ltrim($legacy_ms_prefix, '/')) . ltrim($subdir, '/');
     }
     return $prefix;
 }
function sp_get_upload_info()
{
    $siteurl = get_option('siteurl');
    $upload_path = trim(get_option('upload_path'));
    if (empty($upload_path) || 'wp-content/uploads' == $upload_path) {
        $dir = WP_CONTENT_DIR . '/uploads';
    } elseif (0 !== strpos($upload_path, ABSPATH)) {
        # $dir is absolute, $upload_path is (maybe) relative to ABSPATH
        $dir = path_join(ABSPATH, $upload_path);
    } else {
        $dir = $upload_path;
    }
    if (!($url = get_option('upload_url_path'))) {
        if (empty($upload_path) || 'wp-content/uploads' == $upload_path || $upload_path == $dir) {
            $url = WP_CONTENT_URL . '/uploads';
        } else {
            $url = trailingslashit($siteurl) . $upload_path;
        }
    }
    /*
     * Honor the value of UPLOADS. This happens as long as ms-files rewriting is disabled.
     * We also sometimes obey UPLOADS when rewriting is enabled -- see the next block.
     */
    if (defined('UPLOADS') && !(is_multisite() && get_site_option('ms_files_rewriting'))) {
        $dir = ABSPATH . UPLOADS;
        $url = trailingslashit($siteurl) . UPLOADS;
    }
    # If multisite (and if not the main site in a post-MU network)
    if (is_multisite() && !(is_main_network() && is_main_site() && defined('MULTISITE'))) {
        if (!get_site_option('ms_files_rewriting')) {
            /*
             * If ms-files rewriting is disabled (networks created post-3.5), it is fairly
             * straightforward: Append sites/%d if we're not on the main site (for post-MU
             * networks). (The extra directory prevents a four-digit ID from conflicting with
             * a year-based directory for the main site. But if a MU-era network has disabled
             * ms-files rewriting manually, they don't need the extra directory, as they never
             * had wp-content/uploads for the main site.)
             */
            if (defined('MULTISITE')) {
                $ms_dir = '/sites/' . get_current_blog_id();
            } else {
                $ms_dir = '/' . get_current_blog_id();
            }
            $dir .= $ms_dir;
            $url .= $ms_dir;
        } elseif (defined('UPLOADS') && !ms_is_switched()) {
            /*
             * Handle the old-form ms-files.php rewriting if the network still has that enabled.
             * When ms-files rewriting is enabled, then we only listen to UPLOADS when:
             * 1) We are not on the main site in a post-MU network, as wp-content/uploads is used
             *    there, and
             * 2) We are not switched, as ms_upload_constants() hardcodes these constants to reflect
             *    the original blog ID.
             *
             * Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute.
             * (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as
             * as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files
             * rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
             */
            if (defined('BLOGUPLOADDIR')) {
                $dir = untrailingslashit(BLOGUPLOADDIR);
            } else {
                $dir = ABSPATH . UPLOADS;
            }
            $url = trailingslashit($siteurl) . 'files';
        }
    }
    $uploads = array('basedir' => $dir, 'baseurl' => $url);
    return $uploads;
}
Example #9
0
/**
 * Get an array containing the current upload directory's path and url.
 *
 * Checks the 'upload_path' option, which should be from the web root folder,
 * and if it isn't empty it will be used. If it is empty, then the path will be
 * 'WP_CONTENT_DIR/uploads'. If the 'UPLOADS' constant is defined, then it will
 * override the 'upload_path' option and 'WP_CONTENT_DIR/uploads' path.
 *
 * The upload URL path is set either by the 'upload_url_path' option or by using
 * the 'WP_CONTENT_URL' constant and appending '/uploads' to the path.
 *
 * If the 'uploads_use_yearmonth_folders' is set to true (checkbox if checked in
 * the administration settings panel), then the time will be used. The format
 * will be year first and then month.
 *
 * If the path couldn't be created, then an error will be returned with the key
 * 'error' containing the error message. The error suggests that the parent
 * directory is not writable by the server.
 *
 * On success, the returned array will have many indices:
 * 'path' - base directory and sub directory or full path to upload directory.
 * 'url' - base url and sub directory or absolute URL to upload directory.
 * 'subdir' - sub directory if uploads use year/month folders option is on.
 * 'basedir' - path without subdir.
 * 'baseurl' - URL path without subdir.
 * 'error' - set to false.
 *
 * @since 2.0.0
 *
 * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
 * @return array See above for description.
 */
function wp_upload_dir($time = null)
{
    $siteurl = get_option('siteurl');
    $upload_path = trim(get_option('upload_path'));
    if (empty($upload_path) || 'wp-content/uploads' == $upload_path) {
        $dir = WP_CONTENT_DIR . '/uploads';
    } elseif (0 !== strpos($upload_path, ABSPATH)) {
        // $dir is absolute, $upload_path is (maybe) relative to ABSPATH
        $dir = path_join(ABSPATH, $upload_path);
    } else {
        $dir = $upload_path;
    }
    if (!($url = get_option('upload_url_path'))) {
        if (empty($upload_path) || 'wp-content/uploads' == $upload_path || $upload_path == $dir) {
            $url = WP_CONTENT_URL . '/uploads';
        } else {
            $url = trailingslashit($siteurl) . $upload_path;
        }
    }
    /*
     * Honor the value of UPLOADS. This happens as long as ms-files rewriting is disabled.
     * We also sometimes obey UPLOADS when rewriting is enabled -- see the next block.
     */
    if (defined('UPLOADS') && !(is_multisite() && get_site_option('ms_files_rewriting'))) {
        $dir = ABSPATH . UPLOADS;
        $url = trailingslashit($siteurl) . UPLOADS;
    }
    // If multisite (and if not the main site in a post-MU network)
    if (is_multisite() && !(is_main_network() && is_main_site() && defined('MULTISITE'))) {
        if (!get_site_option('ms_files_rewriting')) {
            /*
             * If ms-files rewriting is disabled (networks created post-3.5), it is fairly
             * straightforward: Append sites/%d if we're not on the main site (for post-MU
             * networks). (The extra directory prevents a four-digit ID from conflicting with
             * a year-based directory for the main site. But if a MU-era network has disabled
             * ms-files rewriting manually, they don't need the extra directory, as they never
             * had wp-content/uploads for the main site.)
             */
            if (defined('MULTISITE')) {
                $ms_dir = '/sites/' . get_current_blog_id();
            } else {
                $ms_dir = '/' . get_current_blog_id();
            }
            $dir .= $ms_dir;
            $url .= $ms_dir;
        } elseif (defined('UPLOADS') && !ms_is_switched()) {
            /*
             * Handle the old-form ms-files.php rewriting if the network still has that enabled.
             * When ms-files rewriting is enabled, then we only listen to UPLOADS when:
             * 1) We are not on the main site in a post-MU network, as wp-content/uploads is used
             *    there, and
             * 2) We are not switched, as ms_upload_constants() hardcodes these constants to reflect
             *    the original blog ID.
             *
             * Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute.
             * (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as
             * as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files
             * rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
             */
            if (defined('BLOGUPLOADDIR')) {
                $dir = untrailingslashit(BLOGUPLOADDIR);
            } else {
                $dir = ABSPATH . UPLOADS;
            }
            $url = trailingslashit($siteurl) . 'files';
        }
    }
    $basedir = $dir;
    $baseurl = $url;
    $subdir = '';
    if (get_option('uploads_use_yearmonth_folders')) {
        // Generate the yearly and monthly dirs
        if (!$time) {
            $time = current_time('mysql');
        }
        $y = substr($time, 0, 4);
        $m = substr($time, 5, 2);
        $subdir = "/{$y}/{$m}";
    }
    $dir .= $subdir;
    $url .= $subdir;
    /**
     * Filter the uploads directory data.
     *
     * @since 2.0.0
     *
     * @param array $uploads Array of upload directory data with keys of 'path',
     *                       'url', 'subdir, 'basedir', and 'error'.
     */
    $uploads = apply_filters('upload_dir', array('path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $basedir, 'baseurl' => $baseurl, 'error' => false));
    // Make sure we have an uploads directory.
    if (!wp_mkdir_p($uploads['path'])) {
        if (0 === strpos($uploads['basedir'], ABSPATH)) {
            $error_path = str_replace(ABSPATH, '', $uploads['basedir']) . $uploads['subdir'];
        } else {
            $error_path = basename($uploads['basedir']) . $uploads['subdir'];
        }
        $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), $error_path);
        $uploads['error'] = $message;
    }
    return $uploads;
}
 /**
  * Kicks off the background update process, looping through all pending updates.
  *
  * @since 3.7.0
  */
 public function run()
 {
     global $wpdb, $wp_version;
     if ($this->is_disabled()) {
         return;
     }
     if (!is_main_network() || !is_main_site()) {
         return;
     }
     $lock_name = 'auto_updater.lock';
     // Try to lock
     $lock_result = $wpdb->query($wpdb->prepare("INSERT IGNORE INTO `{$wpdb->options}` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time()));
     if (!$lock_result) {
         $lock_result = get_option($lock_name);
         // If we couldn't create a lock, and there isn't a lock, bail
         if (!$lock_result) {
             return;
         }
         // Check to see if the lock is still valid
         if ($lock_result > time() - HOUR_IN_SECONDS) {
             return;
         }
     }
     // Update the lock, as by this point we've definitely got a lock, just need to fire the actions
     update_option($lock_name, time());
     // Don't automatically run these thins, as we'll handle it ourselves
     remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
     remove_action('upgrader_process_complete', 'wp_version_check');
     remove_action('upgrader_process_complete', 'wp_update_plugins');
     remove_action('upgrader_process_complete', 'wp_update_themes');
     // Next, Plugins
     wp_update_plugins();
     // Check for Plugin updates
     $plugin_updates = get_site_transient('update_plugins');
     if ($plugin_updates && !empty($plugin_updates->response)) {
         foreach ($plugin_updates->response as $plugin) {
             $this->update('plugin', $plugin);
         }
         // Force refresh of plugin update information
         wp_clean_plugins_cache();
     }
     // Next, those themes we all love
     wp_update_themes();
     // Check for Theme updates
     $theme_updates = get_site_transient('update_themes');
     if ($theme_updates && !empty($theme_updates->response)) {
         foreach ($theme_updates->response as $theme) {
             $this->update('theme', (object) $theme);
         }
         // Force refresh of theme update information
         wp_clean_themes_cache();
     }
     // Next, Process any core update
     wp_version_check();
     // Check for Core updates
     $core_update = find_core_auto_update();
     if ($core_update) {
         $this->update('core', $core_update);
     }
     // Clean up, and check for any pending translations
     // (Core_Upgrader checks for core updates)
     $theme_stats = array();
     if (isset($this->update_results['theme'])) {
         foreach ($this->update_results['theme'] as $upgrade) {
             $theme_stats[$upgrade->item->theme] = true === $upgrade->result;
         }
     }
     wp_update_themes($theme_stats);
     // Check for Theme updates
     $plugin_stats = array();
     if (isset($this->update_results['plugin'])) {
         foreach ($this->update_results['plugin'] as $upgrade) {
             $plugin_stats[$upgrade->item->plugin] = true === $upgrade->result;
         }
     }
     wp_update_plugins($plugin_stats);
     // Check for Plugin updates
     // Finally, Process any new translations
     $language_updates = wp_get_translation_updates();
     if ($language_updates) {
         foreach ($language_updates as $update) {
             $this->update('translation', $update);
         }
         // Clear existing caches
         wp_clean_update_cache();
         wp_version_check();
         // check for Core updates
         wp_update_themes();
         // Check for Theme updates
         wp_update_plugins();
         // Check for Plugin updates
     }
     // Send debugging email to all development installs.
     if (!empty($this->update_results)) {
         $development_version = false !== strpos($wp_version, '-');
         /**
          * Filter whether to send a debugging email for each automatic background update.
          *
          * @since 3.7.0
          *
          * @param bool $development_version By default, emails are sent if the
          *                                  install is a development version.
          *                                  Return false to avoid the email.
          */
         if (apply_filters('automatic_updates_send_debug_email', $development_version)) {
             $this->send_debug_email();
         }
         if (!empty($this->update_results['core'])) {
             $this->after_core_update($this->update_results['core'][0]);
         }
         /**
          * Fires after all automatic updates have run.
          *
          * @since 3.8.0
          *
          * @param array $update_results The results of all attempted updates.
          */
         do_action('automatic_updates_complete', $this->update_results);
     }
     // Clear the lock
     delete_option($lock_name);
 }
 /**
  * Can the current user delete this network?
  *
  * @since 2.0.0
  *
  * @param WP_Network $network
  *
  * @return boolean
  */
 private function can_delete($network)
 {
     // Bail if main network
     if (is_main_network($network->id)) {
         return false;
     }
     // Can't delete current network
     if (get_current_network_id() === $network->id) {
         return false;
     }
     // Bail if user cannot delete network
     if (!current_user_can('delete_network', $network->id)) {
         return false;
     }
     // Assume true (if you're already on this screen)
     return true;
 }
Example #12
0
	/**
	 * Add Custom messages in admin footer
	 *
	 */
	function psts_note() {
		global $current_screen;
		//Add for sites screen
		if ( is_main_network() && 'sites-network' == $current_screen->base ) {
			?>
			<p><strong>&#42 </strong>
			=> <?php _e( "The original Level doesn't exist, it might have been removed.", 'psts' ); ?></p><?php
		}
	}
Example #13
0
 public function pluginRun()
 {
     @ini_set('memory_limit', '256M');
     require_once Xpandbuddy::$pathName . '/library/Cron.php';
     require_once Xpandbuddy::$pathName . '/library/Sender.php';
     //dropbox
     add_action('wp_ajax_get_authorization_code', array('Xpandbuddy_Sender', 'getAuthorizationCode'));
     add_action('wp_ajax_get_google_code', array('Xpandbuddy_Sender', 'getGoogleCode'));
     add_action('wp_ajax_get_google_token', array('Xpandbuddy_Sender', 'getGoogleToken'));
     add_action('wp_ajax_get_access_token', array('Xpandbuddy_Sender', 'getAccessToken'));
     add_action('wp_ajax_check_backup_size', array('Xpandbuddy', 'checkBackupSize'));
     add_action('wp_ajax_activate_multiusers', array('Xpandbuddy', 'activateMultiusers'));
     add_action('wp_ajax_submit_clone', array('Xpandbuddy', 'runStepByStepBackup'));
     add_action('wp_ajax_send_backup', array('Xpandbuddy_Sender', 'sendBackupFileAction'));
     add_action('wp_ajax_set_start_date', array('Xpandbuddy', 'setStartDate'));
     add_action('wp_ajax_get_local_dirs', array('Xpandbuddy_Sender', 'ajaxGetDirsTree'));
     add_action('wp_ajax_ftp_connect', array('Xpandbuddy_Sender', 'getFtpConnect'));
     if (is_admin() && isset($_GET['page']) && strpos($_GET['page'], 'xpandbuddy') !== false && isset($_GET['code'])) {
         echo 'This is Authorization Code: ' . $_GET['code'];
         exit;
     }
     //end dropbox
     /*/ Update plugin {
     		global $wp_filter;
     		$priority=30;
     		if( isset( $wp_filter['plugins_api'] ) ){
     			foreach( array_keys( $wp_filter['plugins_api'] ) as $_priority ){
     				if( $_priority >= $priority ){
     					$priority=$_priority+1;
     				}
     			}
     		}
     		add_filter('pre_set_site_transient_update_plugins', array( 'Xpandbuddy', 'updatePlugin' ) );
     		add_filter('plugins_api', array( 'Xpandbuddy', 'pluginApiCall' ), $priority, 3);
     		self::pluginUpdateCall();
     		// } Update plugin */
     require_once Xpandbuddy::$pathName . '/library/Options.php';
     $_arrayOptions = Xpandbuddy_Options::get();
     if (!isset($_arrayOptions['homeurl_hash']) || $_arrayOptions['homeurl_hash'] != md5(home_url())) {
         add_action('init', array('Xpandbuddy', 'updateRewrite'));
         $_arrayOptions['homeurl_hash'] = md5(home_url());
         Xpandbuddy_Options::set($_arrayOptions);
     }
     self::getJson();
     if (is_multisite()) {
         if (isset($_arrayOptions['flg_active_miltisite']) && $_arrayOptions['flg_active_miltisite'] == true && is_main_network()) {
             add_action('admin_menu', array('Xpandbuddy', 'registerMenu'));
         }
         if (is_main_network()) {
             add_action('network_admin_menu', array('Xpandbuddy', 'registerMenu'));
         }
         //echo get_current_blog_id()." ".(int)is_main_site()." ".(int)is_main_network();
     } else {
         add_action('admin_menu', array('Xpandbuddy', 'registerMenu'));
     }
     // WP-CRON {
     add_filter('cron_schedules', array('Xpandbuddy_Cron', 'schedules'));
     if (!wp_next_scheduled('blogcloncron_event')) {
         wp_schedule_event(time(), 'blogcloncron_update', 'blogcloncron_event');
     }
     add_action('blogcloncron_event', array('Xpandbuddy_Cron', 'run'));
     // }
     if (!is_admin() || is_admin() && (isset($_GET['page']) && strpos($_GET['page'], 'xpandbuddy') === false || !isset($_GET['page']))) {
         return;
     }
     add_action('init', array('Xpandbuddy', 'disableEmojis'));
     self::get();
     if (!isset(self::$_options['db_version'])) {
         self::install();
     } else {
         self::updateDb();
     }
     add_action('admin_enqueue_scripts', array('Xpandbuddy', 'initialize'));
 }
Example #14
0
/**
 * Runs before the schema is upgraded.
 *
 * @since 2.9.0
 */
function pre_schema_upgrade()
{
    global $wp_current_db_version, $wpdb;
    // Unused in Project Nami.
    // To be removed.
    // Multisite schema upgrades.
    if ($wp_current_db_version < 25448 && is_multisite() && !defined('DO_NOT_UPGRADE_GLOBAL_TABLES') && is_main_network()) {
        // Upgrade verions prior to 3.7
        if ($wp_current_db_version < 25179) {
            // New primary key for signups.
            $wpdb->query("ALTER TABLE {$wpdb->signups} ADD signup_id INT NOT NULL IDENTITY(1,1)");
        }
    }
    if ($wp_current_db_version < 30133) {
        // dbDelta() can recreate but can't drop the index.
        $wpdb->query("ALTER TABLE {$wpdb->terms} DROP INDEX slug");
    }
}
 /**
  * Get the prefix path for the files
  *
  * @param string $time
  *
  * @return string
  */
 function get_dynamic_prefix($time = null)
 {
     $prefix = '';
     if ($this->get_setting('use-yearmonth-folders')) {
         $uploads = wp_upload_dir($time);
         $prefix = str_replace($this->get_base_upload_path(), '', $uploads['path']);
     }
     // support legacy MS installs (<3.5 since upgraded) for subsites
     if (is_multisite() && !(is_main_network() && is_main_site()) && false === strpos($prefix, 'sites/')) {
         $details = get_blog_details(get_current_blog_id());
         $legacy_ms_prefix = 'sites/' . $details->blog_id . '/';
         $legacy_ms_prefix = apply_filters('as3cf_legacy_ms_subsite_prefix', $legacy_ms_prefix, $details);
         $prefix = '/' . trailingslashit(ltrim($legacy_ms_prefix, '/')) . ltrim($prefix, '/');
     }
     return $prefix;
 }
 static function get_possible_failures()
 {
     $result = array();
     // Lets check some reasons why it might not be working as expected
     include_once ABSPATH . '/wp-admin/includes/admin.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
     $upgrader = new WP_Automatic_Updater();
     if ($upgrader->is_disabled()) {
         $result[] = 'autoupdates-disabled';
     }
     if (!is_main_site()) {
         $result[] = 'is-not-main-site';
     }
     if (!is_main_network()) {
         $result[] = 'is-not-main-network';
     }
     if ($upgrader->is_vcs_checkout(ABSPATH)) {
         $result[] = 'site-on-vcs';
     }
     if ($upgrader->is_vcs_checkout(WP_PLUGIN_DIR)) {
         $result[] = 'plugin-directory-on-vcs';
     }
     if ($upgrader->is_vcs_checkout(WP_CONTENT_DIR)) {
         $result[] = 'content-directory-on-vcs';
     }
     $lock = get_option('auto_updater.lock');
     if ($lock > time() - HOUR_IN_SECONDS) {
         $result[] = 'lock-is-set';
     }
     $skin = new Automatic_Upgrader_Skin();
     include_once ABSPATH . 'wp-admin/includes/file.php';
     include_once ABSPATH . 'wp-admin/includes/template.php';
     if (!$skin->request_filesystem_credentials(false, ABSPATH, false)) {
         $result[] = 'no-system-write-access';
     }
     if (!$skin->request_filesystem_credentials(false, WP_PLUGIN_DIR, false)) {
         $result[] = 'no-plugin-directory-write-access';
     }
     if (!$skin->request_filesystem_credentials(false, WP_CONTENT_DIR, false)) {
         $result[] = 'no-wp-content-directory-write-access';
     }
     return $result;
 }
Example #17
0
/**
 * Executes network-level upgrade routines.
 *
 * @since 0.0.1
 *
 * @global int   $hq_current_db_version
 * @global hqdb  $hqdb
 */
function upgrade_network()
{
    global $hq_current_db_version, $hqdb;
    // Always.
    if (is_main_network()) {
        /*
         * Deletes all expired transients. The multi-table delete syntax is used
         * to delete the transient record from table a, and the corresponding
         * transient_timeout record from table b.
         */
        $time = time();
        $sql = "DELETE a, b FROM {$hqdb->sitemeta} a, {$hqdb->sitemeta} b\n\t\t\tWHERE a.meta_key LIKE %s\n\t\t\tAND a.meta_key NOT LIKE %s\n\t\t\tAND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )\n\t\t\tAND b.meta_value < %d";
        $hqdb->query($hqdb->prepare($sql, $hqdb->esc_like('_site_transient_') . '%', $hqdb->esc_like('_site_transient_timeout_') . '%', $time));
    }
    // 2.8.
    if ($hq_current_db_version < 11549) {
        $hqmu_sitewide_plugins = get_site_option('hqmu_sitewide_plugins');
        $active_sitewide_plugins = get_site_option('active_sitewide_plugins');
        if ($hqmu_sitewide_plugins) {
            if (!$active_sitewide_plugins) {
                $sitewide_plugins = (array) $hqmu_sitewide_plugins;
            } else {
                $sitewide_plugins = array_merge((array) $active_sitewide_plugins, (array) $hqmu_sitewide_plugins);
            }
            update_site_option('active_sitewide_plugins', $sitewide_plugins);
        }
        delete_site_option('hqmu_sitewide_plugins');
        delete_site_option('deactivated_sitewide_plugins');
        $start = 0;
        while ($rows = $hqdb->get_results("SELECT meta_key, meta_value FROM {$hqdb->sitemeta} ORDER BY meta_id LIMIT {$start}, 20")) {
            foreach ($rows as $row) {
                $value = $row->meta_value;
                if (!@unserialize($value)) {
                    $value = stripslashes($value);
                }
                if ($value !== $row->meta_value) {
                    update_site_option($row->meta_key, $value);
                }
            }
            $start += 20;
        }
    }
    // 3.0
    if ($hq_current_db_version < 13576) {
        update_site_option('global_terms_enabled', '1');
    }
    // 3.3
    if ($hq_current_db_version < 19390) {
        update_site_option('initial_db_version', $hq_current_db_version);
    }
    if ($hq_current_db_version < 19470) {
        if (false === get_site_option('active_sitewide_plugins')) {
            update_site_option('active_sitewide_plugins', array());
        }
    }
    // 3.4
    if ($hq_current_db_version < 20148) {
        // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
        $allowedthemes = get_site_option('allowedthemes');
        $allowed_themes = get_site_option('allowed_themes');
        if (false === $allowedthemes && is_array($allowed_themes) && $allowed_themes) {
            $converted = array();
            $themes = hq_get_themes();
            foreach ($themes as $stylesheet => $theme_data) {
                if (isset($allowed_themes[$theme_data->get('Name')])) {
                    $converted[$stylesheet] = true;
                }
            }
            update_site_option('allowedthemes', $converted);
            delete_site_option('allowed_themes');
        }
    }
    // 3.5
    if ($hq_current_db_version < 21823) {
        update_site_option('ms_files_rewriting', '1');
    }
    // 3.5.2
    if ($hq_current_db_version < 24448) {
        $illegal_names = get_site_option('illegal_names');
        if (is_array($illegal_names) && count($illegal_names) === 1) {
            $illegal_name = reset($illegal_names);
            $illegal_names = explode(' ', $illegal_name);
            update_site_option('illegal_names', $illegal_names);
        }
    }
    // 4.2
    if ($hq_current_db_version < 31351 && $hqdb->charset === 'utf8mb4') {
        if (hq_should_upgrade_global_tables()) {
            $hqdb->query("ALTER TABLE {$hqdb->usermeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
            $hqdb->query("ALTER TABLE {$hqdb->site} DROP INDEX domain, ADD INDEX domain(domain(140),path(51))");
            $hqdb->query("ALTER TABLE {$hqdb->sitemeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
            $hqdb->query("ALTER TABLE {$hqdb->signups} DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))");
            $tables = $hqdb->tables('global');
            // sitecategories may not exist.
            //TODO: Goyo
            //if ( ! $hqdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) {
            unset($tables['sitecategories']);
            //}
            foreach ($tables as $table) {
                maybe_convert_table_to_utf8mb4($table);
            }
        }
    }
    // 4.3
    if ($hq_current_db_version < 33055 && 'utf8mb4' === $hqdb->charset) {
        if (hq_should_upgrade_global_tables()) {
            $upgrade = false;
            $indexes = $hqdb->get_results("SHOW INDEXES FROM {$hqdb->signups}");
            foreach ($indexes as $index) {
                if ('domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part) {
                    $upgrade = true;
                    break;
                }
            }
            if ($upgrade) {
                $hqdb->query("ALTER TABLE {$hqdb->signups} DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))");
            }
            $tables = $hqdb->tables('global');
            // sitecategories may not exist.
            //TODO: Goyo
            //if ( ! $hqdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) {
            unset($tables['sitecategories']);
            //}
            foreach ($tables as $table) {
                maybe_convert_table_to_utf8mb4($table);
            }
        }
    }
}
/**
 * Runs before the schema is upgraded.
 *
 * @since 2.9.0
 */
function pre_schema_upgrade()
{
    global $wp_current_db_version, $wpdb;
    // Upgrade versions prior to 2.9
    if ($wp_current_db_version < 11557) {
        // Delete duplicate options. Keep the option with the highest option_id.
        $wpdb->query("DELETE o1 FROM {$wpdb->options} AS o1 JOIN {$wpdb->options} AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id");
        // Drop the old primary key and add the new.
        $wpdb->query("ALTER TABLE {$wpdb->options} DROP PRIMARY KEY, ADD PRIMARY KEY(option_id)");
        // Drop the old option_name index. dbDelta() doesn't do the drop.
        $wpdb->query("ALTER TABLE {$wpdb->options} DROP INDEX option_name");
    }
    // Multisite schema upgrades.
    if ($wp_current_db_version < 25448 && is_multisite() && !defined('DO_NOT_UPGRADE_GLOBAL_TABLES') && is_main_network()) {
        // Upgrade verions prior to 3.7
        if ($wp_current_db_version < 25179) {
            // New primary key for signups.
            $wpdb->query("ALTER TABLE {$wpdb->signups} ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
            $wpdb->query("ALTER TABLE {$wpdb->signups} DROP INDEX domain");
        }
        if ($wp_current_db_version < 25448) {
            // Convert archived from enum to tinyint.
            $wpdb->query("ALTER TABLE {$wpdb->blogs} CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'");
            $wpdb->query("ALTER TABLE {$wpdb->blogs} CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0");
        }
    }
}
 /**
  * Kicks off the background update process, looping through all pending updates.
  *
  * @since 3.7.0
  * @access public
  *
  * @global wpdb   $wpdb
  * @global string $wp_version
  */
 public function run()
 {
     global $wpdb, $wp_version;
     if ($this->is_disabled()) {
         return;
     }
     if (!is_main_network() || !is_main_site()) {
         return;
     }
     if (!$this->create_lock('auto_updater')) {
         return;
     }
     // Don't automatically run these thins, as we'll handle it ourselves
     remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
     remove_action('upgrader_process_complete', 'wp_version_check');
     remove_action('upgrader_process_complete', 'wp_update_plugins');
     remove_action('upgrader_process_complete', 'wp_update_themes');
     // Next, Plugins
     wp_update_plugins();
     // Check for Plugin updates
     $plugin_updates = get_site_transient('update_plugins');
     if ($plugin_updates && !empty($plugin_updates->response)) {
         foreach ($plugin_updates->response as $plugin) {
             $this->update('plugin', $plugin);
         }
         // Force refresh of plugin update information
         wp_clean_plugins_cache();
     }
     // Next, those themes we all love
     wp_update_themes();
     // Check for Theme updates
     $theme_updates = get_site_transient('update_themes');
     if ($theme_updates && !empty($theme_updates->response)) {
         foreach ($theme_updates->response as $theme) {
             $this->update('theme', (object) $theme);
         }
         // Force refresh of theme update information
         wp_clean_themes_cache();
     }
     // Next, Process any core update
     wp_version_check();
     // Check for Core updates
     $core_update = find_core_auto_update();
     if ($core_update) {
         $this->update('core', $core_update);
     }
     // Clean up, and check for any pending translations
     // (Core_Upgrader checks for core updates)
     $theme_stats = array();
     if (isset($this->update_results['theme'])) {
         foreach ($this->update_results['theme'] as $upgrade) {
             $theme_stats[$upgrade->item->theme] = true === $upgrade->result;
         }
     }
     wp_update_themes($theme_stats);
     // Check for Theme updates
     $plugin_stats = array();
     if (isset($this->update_results['plugin'])) {
         foreach ($this->update_results['plugin'] as $upgrade) {
             $plugin_stats[$upgrade->item->plugin] = true === $upgrade->result;
         }
     }
     wp_update_plugins($plugin_stats);
     // Check for Plugin updates
     // Finally, Process any new translations
     $language_updates = wp_get_translation_updates();
     if ($language_updates) {
         foreach ($language_updates as $update) {
             $this->update('translation', $update);
         }
         // Clear existing caches
         wp_clean_update_cache();
         wp_version_check();
         // check for Core updates
         wp_update_themes();
         // Check for Theme updates
         wp_update_plugins();
         // Check for Plugin updates
     }
     // Send debugging email to all development installs.
     if (!empty($this->update_results)) {
         $development_version = false !== strpos($wp_version, '-');
         /**
          * Filter whether to send a debugging email for each automatic background update.
          *
          * @since 3.7.0
          *
          * @param bool $development_version By default, emails are sent if the
          *                                  install is a development version.
          *                                  Return false to avoid the email.
          */
         if (apply_filters('automatic_updates_send_debug_email', $development_version)) {
             $this->send_debug_email();
         }
         if (!empty($this->update_results['core'])) {
             $this->after_core_update($this->update_results['core'][0]);
         }
         /**
          * Fires after all automatic updates have run.
          *
          * @since 3.8.0
          *
          * @param array $update_results The results of all attempted updates.
          */
         do_action('automatic_updates_complete', $this->update_results);
     }
     $this->release_lock('auto_updater');
 }
Example #20
0
/**
 * Create WordPress options and set the default values.
 *
 * @since 1.5.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 * @global int  $wp_db_version
 * @global int  $wp_current_db_version
 */
function populate_options()
{
    global $wpdb, $wp_db_version, $wp_current_db_version;
    $guessurl = wp_guess_url();
    /**
     * Fires before creating WordPress options and populating their default values.
     *
     * @since 2.6.0
     */
    do_action('populate_options');
    if (ini_get('safe_mode')) {
        // Safe mode can break mkdir() so use a flat structure by default.
        $uploads_use_yearmonth_folders = 0;
    } else {
        $uploads_use_yearmonth_folders = 1;
    }
    // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme.
    $stylesheet = $template = WP_DEFAULT_THEME;
    $theme = wp_get_theme(WP_DEFAULT_THEME);
    if (!$theme->exists()) {
        $theme = WP_Theme::get_core_default_theme();
    }
    // If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do.
    if ($theme) {
        $stylesheet = $theme->get_stylesheet();
        $template = $theme->get_template();
    }
    $timezone_string = '';
    $gmt_offset = 0;
    /* translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14)
    	   or a valid timezone string (America/New_York). See http://us3.php.net/manual/en/timezones.php
    	   for all timezone strings supported by PHP.
    	*/
    $offset_or_tz = _x('0', 'default GMT offset or timezone string');
    if (is_numeric($offset_or_tz)) {
        $gmt_offset = $offset_or_tz;
    } elseif ($offset_or_tz && in_array($offset_or_tz, timezone_identifiers_list())) {
        $timezone_string = $offset_or_tz;
    }
    $options = array('siteurl' => $guessurl, 'home' => $guessurl, 'blogname' => __('My Site'), 'blogdescription' => __('Just another WordPress site'), 'users_can_register' => 0, 'admin_email' => '*****@*****.**', 'start_of_week' => _x('1', 'start of week'), 'use_balanceTags' => 0, 'use_smilies' => 1, 'require_name_email' => 1, 'comments_notify' => 1, 'posts_per_rss' => 10, 'rss_use_excerpt' => 0, 'mailserver_url' => 'mail.example.com', 'mailserver_login' => '*****@*****.**', 'mailserver_pass' => 'password', 'mailserver_port' => 110, 'default_category' => 1, 'default_comment_status' => 'closed', 'default_ping_status' => 'closed', 'default_pingback_flag' => 0, 'posts_per_page' => 10, 'date_format' => __('Y/m/d'), 'time_format' => __('H:i'), 'links_updated_date_format' => __('Y/m/d H:i'), 'comment_moderation' => 0, 'moderation_notify' => 1, 'permalink_structure' => '', 'hack_file' => 0, 'blog_charset' => 'UTF-8', 'moderation_keys' => '', 'active_plugins' => array(), 'category_base' => '', 'ping_sites' => 'http://rpc.pingomatic.com/', 'comment_max_links' => 2, 'gmt_offset' => $gmt_offset, 'default_email_category' => 1, 'recently_edited' => '', 'template' => $template, 'stylesheet' => $stylesheet, 'comment_whitelist' => 1, 'blacklist_keys' => '', 'comment_registration' => 0, 'html_type' => 'text/html', 'use_trackback' => 0, 'default_role' => 'subscriber', 'db_version' => $wp_db_version, 'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders, 'upload_path' => '', 'blog_public' => '1', 'default_link_category' => 2, 'show_on_front' => 'page', 'tag_base' => '', 'show_avatars' => '1', 'avatar_rating' => 'G', 'upload_url_path' => '', 'thumbnail_size_w' => 150, 'thumbnail_size_h' => 150, 'thumbnail_crop' => 1, 'medium_size_w' => 300, 'medium_size_h' => 300, 'avatar_default' => 'mystery', 'large_size_w' => 1024, 'large_size_h' => 1024, 'image_default_link_type' => 'none', 'image_default_size' => '', 'image_default_align' => '', 'close_comments_for_old_posts' => 0, 'close_comments_days_old' => 14, 'thread_comments' => 1, 'thread_comments_depth' => 5, 'page_comments' => 0, 'comments_per_page' => 50, 'default_comments_page' => 'newest', 'comment_order' => 'asc', 'sticky_posts' => array(), 'widget_categories' => array(), 'widget_text' => array(), 'widget_rss' => array(), 'uninstall_plugins' => array(), 'timezone_string' => $timezone_string, 'page_for_posts' => 0, 'page_on_front' => 2, 'default_post_format' => 0, 'link_manager_enabled' => 0, 'finished_splitting_shared_terms' => 1, 'site_icon' => 0, 'medium_large_size_w' => 768, 'medium_large_size_h' => 0);
    // 3.3
    if (!is_multisite()) {
        $options['initial_db_version'] = !empty($wp_current_db_version) && $wp_current_db_version < $wp_db_version ? $wp_current_db_version : $wp_db_version;
    }
    // 3.0 multisite
    if (is_multisite()) {
        /* translators: blog tagline */
        $options['blogdescription'] = sprintf(__('Just another %s site'), get_current_site()->site_name);
        $options['permalink_structure'] = '/%year%/%monthnum%/%day%/%postname%/';
    }
    // Set autoload to no for these options
    $fat_options = array('moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins');
    $keys = "'" . implode("', '", array_keys($options)) . "'";
    $existing_options = $wpdb->get_col("SELECT option_name FROM {$wpdb->options} WHERE option_name in ( {$keys} )");
    $insert = '';
    foreach ($options as $option => $value) {
        if (in_array($option, $existing_options)) {
            continue;
        }
        if (in_array($option, $fat_options)) {
            $autoload = 'no';
        } else {
            $autoload = 'yes';
        }
        if (is_array($value)) {
            $value = serialize($value);
        }
        if (!empty($insert)) {
            $insert .= ', ';
        }
        $insert .= $wpdb->prepare("(%s, %s, %s)", $option, $value, $autoload);
    }
    if (!empty($insert)) {
        $wpdb->query("INSERT INTO {$wpdb->options} (option_name, option_value, autoload) VALUES " . $insert);
    }
    // In case it is set, but blank, update "home".
    if (!__get_option('home')) {
        update_option('home', $guessurl);
    }
    // Delete unused options.
    $unusedoptions = array('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'links_recently_updated_time', 'links_recently_updated_prepend', 'links_recently_updated_append', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', 'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app', 'embed_autourls', 'default_post_edit_rows', 'gzipcompression', 'advanced_edit');
    foreach ($unusedoptions as $option) {
        delete_option($option);
    }
    // Delete obsolete magpie stuff.
    $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?\$'");
    /*
     * Deletes all expired transients. The multi-table delete syntax is used
     * to delete the transient record from table a, and the corresponding
     * transient_timeout record from table b.
     */
    $time = time();
    $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\tWHERE a.option_name LIKE %s\n\t\tAND a.option_name NOT LIKE %s\n\t\tAND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )\n\t\tAND b.option_value < %d";
    $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_transient_') . '%', $wpdb->esc_like('_transient_timeout_') . '%', $time));
    if (is_main_site() && is_main_network()) {
        $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\t\tWHERE a.option_name LIKE %s\n\t\t\tAND a.option_name NOT LIKE %s\n\t\t\tAND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )\n\t\t\tAND b.option_value < %d";
        $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_') . '%', $wpdb->esc_like('_site_transient_timeout_') . '%', $time));
    }
}
Example #21
0
/**
 * Adds the Global Setup screen to the network administration menu if necessary.
 *
 * If it was in Core, that would happen directly in `wp-admin/network/menu.php`.
 *
 * @since 1.0.0
 * @access private
 */
function _ga_add_global_setup_menu_item()
{
    if (is_multinetwork() && !is_main_network()) {
        //TODO: add Delete Network screen
    }
    if (defined('WP_ALLOW_MULTINETWORK') && WP_ALLOW_MULTINETWORK && !is_multinetwork()) {
        add_submenu_page('settings.php', __('Global Setup', 'global-admin'), __('Global Setup', 'global-admin'), 'manage_networks', GA_PATH . 'global-admin/wp-admin/network/global.php');
    }
}