Forked from krogsgard/pull-shortcode-from-main-site.php
Last active
August 29, 2015 14:11
-
-
Save hiphopsmurf/12192235d8b834dd6dd3 to your computer and use it in GitHub Desktop.
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: Krogsgard enable main site forms and audio | |
* Plugin URI: http://infomedia.com/ | |
* Description: enables a user to use audio and form shortcodes from the main site in sub sites with a wrapper shortcode | |
* Version: 0.1 | |
* Author: Brian Krogsgard | |
* Author URI: http://krogsgard.com/ | |
* Network: true | |
*/ | |
/* | |
* you need to active the 'blubrry powerpress' plugin and 'audio file manager' plugin for the audio shortcode, and gravity forms for the form shortcode | |
* they are already installed, just need activating on each subsite you want to use these wrapper shortcodes | |
* | |
* This plugin goes in the mu-plugins folder | |
* theoretically, this could be abstracted to any shortcode | |
*/ | |
add_shortcode( 'krogs-main-form', 'krogs_get_main_site_form' ); | |
add_shortcode( 'krogs-main-audio', 'krogs_get_main_site_audio' ); | |
/* | |
* @requires Gravity form activation in main site | |
* | |
* Can add other attributes if necessary | |
*/ | |
function krogs_get_main_site_form( $atts ) { | |
extract(shortcode_atts(array( | |
'id' => 1, | |
'title' => true | |
), $atts)); | |
$maincontent = ''; | |
if ( ! is_main_site() ) { | |
global $switched; | |
switch_to_blog(1); | |
$maincontent = do_shortcode('[gravityform id="' . $id .'" title="' . $title . '"]'); | |
restore_current_blog(); | |
} | |
return $maincontent; | |
} | |
/* | |
* @requires Blubrry powerpress and our Audio CPT plugin to be active | |
* | |
* Can add other attributes if necessary | |
*/ | |
function krogs_get_main_site_audio( $atts ) { | |
extract(shortcode_atts(array( | |
'category' => false, | |
'posts_per_page' => 10, | |
), $atts)); | |
$maincontent = ''; | |
if ( ! is_main_site() ) { | |
global $switched; | |
switch_to_blog(1); | |
$maincontent = do_shortcode('[audio-list posts_per_page="' . $posts_per_page . '" audio_category="' . $category . '"]'); | |
restore_current_blog(); | |
} | |
return $maincontent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment