This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Sync key options with blog meta | |
* | |
* @package Blog_Meta_Sync | |
* @author Jonathan Harris <[email protected]> | |
* @license GPL-2.0+ | |
* @link http://www.jonathandavidharris.co.uk/ | |
* @copyright 2017 Spacedmonkey | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Sync key options with blog meta | |
* | |
* @package Blog_Meta_Sync | |
* @author Jonathan Harris <[email protected]> | |
* @license GPL-2.0+ | |
* @link http://www.jonathandavidharris.co.uk/ | |
* @copyright 2017 Spacedmonkey | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'stylesheet', | |
'show_on_front', | |
'blog_charset', | |
'template', | |
'WPLANG', | |
'cron', | |
'blogname', | |
'siteurl', | |
'post_count', | |
'home', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Loop through all options and save in the blog meta table | |
*/ | |
class Blog_Meta_Migration extends WP_CLI_Command { | |
/** | |
* Loop through all options and save in the blog meta table | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( ! is_multisite() ){ | |
return; | |
} | |
function pre_get_option( $value, $option ){ | |
$blog_id = get_current_blog_id(); | |
$meta = get_blog_meta( $blog_id, $option, true ); | |
if( false != $meta ){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function pre_get_posts( $wp_query ) { | |
$this->cache_queries = apply_filters( 'use_enhanced_post_cache', true, $wp_query ); | |
if( $this->cache_queries ){ | |
if ( $wp_query->is_404() ) { | |
$page_variable = array( 'error_404' ); | |
} else { | |
$page_variable = $wp_query->query_vars; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sql = "LIMIT 10"; | |
$cache_key = md5($sql); | |
$post_ids = wp_cache_get( $cache_key, 'keystone_redirects' ); | |
if( false === $post_ids ){ | |
$post_ids = $wpdb->get_col( $sql ); | |
$cache_time = (count($post_ids) > 0 ) ? MINUTE_IN_SECONDS : DAY_IN_SECONDS; | |
wp_cache_set( $cache_key, $post_ids, 'keystone_redirects', $cache_time ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( count( $domains ) > 1 && count( $paths ) > 1 ) { | |
$sql = "SELECT * FROM $wpdb->blogs WHERE domain IN ($search_domains) AND path IN ($search_paths) ORDER BY CHAR_LENGTH(domain) DESC, CHAR_LENGTH(path) DESC LIMIT 1"; | |
} elseif ( count( $domains ) > 1 ) { | |
$sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE path = %s", $paths[0] ); | |
$sql .= " AND domain IN ($search_domains) ORDER BY CHAR_LENGTH(domain) DESC LIMIT 1"; | |
} elseif ( count( $paths ) > 1 ) { | |
$sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $domains[0] ); | |
$sql .= " AND path IN ($search_paths) ORDER BY CHAR_LENGTH(path) DESC LIMIT 1"; | |
} else { | |
$sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $domains[0], $paths[0] ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Red_Item { | |
private $id = null; | |
private $created; | |
private $referrer; | |
private $url = null; | |
private $regex = false; | |
private $action_data = null; | |
private $action_code = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /path/to/root | |
for url in $(wp site list --field=domain) | |
do | |
echo ${url} | |
wp --url=${url} option update db_version 30133 | |
echo | |
done | |
wp --url=${url} core update-db --network |