This file contains 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 | |
/** | |
* gets the current post type in the WordPress Admin | |
*/ | |
function get_current_post_type() { | |
global $post, $typenow, $current_screen; | |
//we have a post so we can just get the post type from that | |
if ( $post && $post->post_type ) | |
return $post->post_type; |
This file contains 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 | |
// Apply filter | |
add_filter('body_class', 'multisite_body_classes'); | |
function multisite_body_classes($classes) { | |
$id = get_current_blog_id(); | |
$slug = strtolower(str_replace(' ', '-', trim(get_bloginfo('name')))); | |
$classes[] = sanitize_title('site-'.$slug); | |
return $classes; | |
} |
This file contains 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
/* Get Latest post from all blogs */ | |
function recent_mu_posts( $howMany = 10 ) { | |
global $wpdb; | |
global $table_prefix; | |
// get an array of the table names that our posts will be in | |
// we do this by first getting all of our blog ids and then forming the name of the | |
// table and putting it into an array | |
$rows = $wpdb->get_results( "SELECT blog_id from $wpdb->blogs WHERE | |
public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0';" ); |
This file contains 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 | |
$posts = multisite_latest_post( array( | |
"how_many"=>10, | |
"how_long_days"=>30, | |
"how_many_words"=>50, | |
"more_text"=>"[...]", | |
"remove_html"=>true, | |
"sort_by"=>"post_date", | |
// if paginating: | |
"paginate"=>true, |
This file contains 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 | |
// See full article here http://www.wpriders.com/snippets/multisite-create-page-on-all-sites/ | |
$args = array( | |
'post_content' => $page_content, | |
'post_name' => $page_slug, | |
'post_title' => $page_title, | |
'post_status' => 'publish', | |
'post_type' => 'page' | |
); | |
$post_id = wp_insert_post( $args, true ); |
This file contains 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 | |
/* | |
Plugin Name: Show Multisite IDs | |
Plugin URI: http://ninnypants.com | |
Description: Adds table column to show site ID | |
Version: 1.0 | |
Author: ninnypants | |
Author URI: http://ninnypants.com | |
License: GPL2 |
This file contains 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 | |
// There are three options (that I know of) for automatically enabling a plugin | |
// in new sites. | |
// 1. Move the plugin from wp-content/plugins/ to wp-content/mu-plugins/ (MU = | |
// Must Use). But then it cannot be deactivated for any site. | |
// 2. Click "Network Activate" instead of "Activate" to enable it for all sites. | |
// I didn't want to use this though because I didn't want to affect existing |
This file contains 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 | |
//This is a quick and dirty script to see which WordPress plugins aren't being used by ANY of the sites in a multisite network. | |
/** Load WordPress Bootstrap */ | |
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' ); | |
if ( ! function_exists( 'get_plugins' ) ) { | |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
} |
This file contains 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 | |
/* | |
Plugin Name: Multisite Cross Post | |
Description: Cross post content between a WP multisite installation | |
Author: Andrew Norcross | |
Version: 0.1 | |
Author URI: http://andrewnorcross.com | |
*/ | |
class RKV_Multi_CrossPost { |