/** * Implement [bw_blog] shortcode to select the blog to be used in subsequent shortcodes * * We might eexpect that if the blog was invalid then switch_to_blog() would fail. * But it doesn't, so we need to check. * * * @param array $atts - expected to either contain "blog" or uses the index 0 values * @param string $content - not expected * @param string $tag - the shortcode used * @return string - nothing is generated directly by this shortcode */ function bw_blog($atts = null, $content = null, $tag = null) { if (is_multisite()) { $blog = bw_array_get_from($atts, "blog,0", null); if ($blog) { $details = get_blog_details($blog, false); if ($details) { switch_to_blog($blog); } else { e("Invalid blog {$blog}"); } } else { restore_current_blog(); } } else { bw_trace2("Shortcode not effective in a non-multisite implementation"); } return bw_ret(); }
/** * Implement [bw_blogs] shortcode to list the blogs on the multisite * * @param array $atts - expected to either contain "blogs" or uses the index 0 values * @param string $content - content to expand for each blog * @param string $tag - the shortcode used * @return string - nothing is generated directly by this shortcode */ function bw_blogs($atts = null, $content = null, $tag = null) { if (is_multisite()) { $blogs = bw_array_get_from($atts, "blogs,0", null); if ($blogs) { $blogs = bw_as_array($blogs); } else { $blogs = bw_get_blog_list(); } bw_display_blogs($blogs, $atts, $content); } else { bw_trace2("bw_blogs shortcode not effective in a non-multisite implementation"); } return bw_ret(); }