/** * 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(); }
/** * Display information about high and low tides obtained from the NOAA Tides and Currents website * * e.g. * ` * Threemile Cut entrance, Darien River GA * May 18,2012 * 02:10 AM 0.7 Low Tide * 07:50 AM 6.6 High Tide * 02:11 PM 0.2 Low Tide * 08:07 PM 7.8 High Tide * ` * * @param array $atts- shortcode parameters * @return string Result of shortcode * * * */ function us_tides($atts = NULL) { $station = bw_array_get($atts, "station", "8423745"); $link = bw_array_get($atts, "link", "y"); $link = bw_validate_torf($link); $date_format = bw_array_get($atts, "date_format", "M d,Y"); $response = us_load_xml_file($station); if ($response) { $stationname = $response->stationname; $state = $response->state; $text = "Tide times and heights for:"; $text .= " "; $text .= $stationname; $text .= " "; $text .= $state; if ($link) { alink("stationname", "http://tidesandcurrents.noaa.gov/noaatidepredictions/NOAATidesFacade.jsp?Stationid={$station}", $text); } else { p($text, "stationname"); } p(bw_format_date(null, $date_format)); $today = bw_format_date(null, "Y/m/d"); foreach ($response->data->item as $item) { if ($item->date == $today) { us_format_item($item); } } } 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(); }
/** * Implement [29608] shortcode. * * Displays a form which you can use to enter content * and see the results of 'the_content' filtering before and * after the implementation of a fix for TRAC 29608 * * Output * * - input area * - information area for shortcode expansion options * - output area showing pre 29608 output - i.e. the original 'expected' output * - output area displaying post 29608 output - the new 'expected' output * - output area showing how pre 29608 output formats * - output area showing how post 29608 output format * * If there are differences * - output area showing the hexadecimal dump of the original output * - output area showing the hexadecimal dump of the new output * * Notes: Since the intended logic for TRAC 29608 is to perform autop processing after shortcode expansion * rather than before, and since this code is being run as a shortcode * then the whole of this output would normally be affected by the filters that run subsequently. * This makes a mockery of the processing. * We call trac_29608_disable_remaining_filters() to prevent this from happening. * */ function trac_29608($atts = null, $content = null, $tag = null) { $value = bw_array_get($_REQUEST, "input_29608", "Code is poetry"); define('WP_INSTALLING', true); $pre_29608_result = trac_pre_29608($value); $post_29608_result = trac_post_29608($value); h3("Results"); $match = trac_29608_compare($pre_29608_result, $post_29608_result); e(bw_do_shortcode("[div class=w50p5]")); $version = bw_wp(array("v")); h3($version); trac_29608_input($pre_29608_result); ediv(); //sdiv( "w50p0" ); e(bw_do_shortcode("[div class=w50p0]")); h3("autopia"); trac_29608_input($post_29608_result); ediv(); sediv("cleared"); e("<hr />"); e(bw_do_shortcode("[div class=w50p0]")); trac_29608_display($pre_29608_result); ediv(); e(bw_do_shortcode("[div class=w50p0]")); trac_29608_display($post_29608_result); ediv(); sediv("cleared"); //if ( !$match ) { h3("Hex dump"); trac_29608_dump($pre_29608_result); trac_29608_dump($post_29608_result); //} h3("Performance comparison"); trac_29608_perf($value); $bw_ret = bw_ret(); trac_29608_form($value); $bw_ret_form = bw_ret(); $bw_ret = $bw_ret_form . $bw_ret; trac_29608_disable_remaining_filters(); bw_trace2($bw_ret, "bw_ret", false); return $bw_ret; }