| 1 |
<?php // (C) Copyright Bobbing Wide 2011-2014 |
| 2 |
|
| 3 |
/** |
| 4 |
* Implement "oik_add_shortcodes" action for oik |
| 5 |
* |
| 6 |
* Deferred registration of shortcodes until they're actually needed |
| 7 |
*/ |
| 8 |
function bw_oik_lazy_add_shortcodes() { |
| 9 |
//bw_add_shortcode_event( "bw_wtf"); |
| 10 |
//bw_add_shortcode_event( "bw_wtf", NULL, "the_title", "bw_strip_tags" ); |
| 11 |
//bw_add_shortcode_file( "bw_wtf", oik_path( "shortcodes/oik-wtf.php" ) ); |
| 12 |
bw_add_shortcode( "bw_wtf", "bw_wtf", oik_path( "shortcodes/oik-wtf.php" ), false ); |
| 13 |
|
| 14 |
//bw_add_shortcode_event( 'bw_directions', 'bw_directions', 'the_content,widget_text' ); |
| 15 |
//bw_add_shortcode_file( 'bw_directions', oik_path( "shortcodes/oik-geo.php" ) ); |
| 16 |
bw_add_shortcode( 'bw_directions', 'bw_directions', oik_path( "shortcodes/oik-geo.php" ), false ); |
| 17 |
|
| 18 |
bw_add_shortcode( 'bw', 'bw' ); |
| 19 |
//bw_add_shortcode_event( "bw", "bw" ); |
| 20 |
//bw_add_shortcode_event( "bw", "bw", 'the_title', 'bw_admin_strip_tags' ); |
| 21 |
|
| 22 |
//bw_add_shortcode_event( 'oik', 'bw_oik' ); |
| 23 |
//bw_add_shortcode_event( "oik", "bw_oik", 'the_title', 'bw_admin_strip_tags' ); |
| 24 |
bw_add_shortcode( "oik", "bw_oik" ); |
| 25 |
|
| 26 |
bw_add_shortcode( 'bw_address', 'bw_address', oik_path( "shortcodes/oik-address.php" ), false ); |
| 27 |
|
| 28 |
bw_add_shortcode( 'bw_mailto', 'bw_mailto', oik_path( "shortcodes/oik-email.php" ), false ); |
| 29 |
bw_add_shortcode( 'bw_email', 'bw_email', oik_path( "shortcodes/oik-email.php" ), false ); |
| 30 |
|
| 31 |
bw_add_shortcode( 'bw_geo', 'bw_geo', oik_path( "shortcodes/oik-geo.php"), false ); |
| 32 |
bw_add_shortcode( 'bw_telephone', 'bw_telephone', oik_path( "shortcodes/oik-phone.php" ) ); |
| 33 |
bw_add_shortcode( 'bw_fax', 'bw_fax', oik_path( "shortcodes/oik-phone.php" ) ); |
| 34 |
bw_add_shortcode( 'bw_mobile', 'bw_mobile', oik_path( "shortcodes/oik-phone.php" ) ); |
| 35 |
bw_add_shortcode( 'bw_skype', 'bw_skype', oik_path( "shortcodes/oik-phone.php" ) ); |
| 36 |
bw_add_shortcode( 'bw_tel', 'bw_tel', oik_path( "shortcodes/oik-phone.php" ) ); |
| 37 |
bw_add_shortcode( 'bw_mob', 'bw_mob', oik_path( "shortcodes/oik-phone.php" ) ); |
| 38 |
bw_add_shortcode( 'bw_wpadmin', 'bw_wpadmin', oik_path( "shortcodes/oik-domain.php" ), false ); |
| 39 |
bw_add_shortcode( 'bw_domain', 'bw_domain', oik_path( "shortcodes/oik-domain.php" ) ); |
| 40 |
bw_add_shortcode( 'bw_show_googlemap', 'bw_show_googlemap', oik_path( "shortcodes/oik-googlemap.php" ), false ); |
| 41 |
bw_add_shortcode( 'bw_contact', 'bw_contact', oik_path( "shortcodes/oik-company.php" ) ); |
| 42 |
bw_add_shortcode( 'bw_company', 'bw_company', oik_path( "shortcodes/oik-company.php" ) ); |
| 43 |
bw_add_shortcode( 'bw_business', 'bw_business', oik_path( "shortcodes/oik-company.php" ) ); |
| 44 |
bw_add_shortcode( 'bw_formal', 'bw_formal', oik_path( "shortcodes/oik-company.php" ) ); |
| 45 |
bw_add_shortcode( 'bw_slogan', 'bw_slogan', oik_path( "shortcodes/oik-company.php" ) ); |
| 46 |
bw_add_shortcode( 'bw_alt_slogan', 'bw_alt_slogan', oik_path( "shortcodes/oik-company.php" ) ); |
| 47 |
bw_add_shortcode( 'bw_admin', 'bw_admin_sc', oik_path( "shortcodes/oik-company.php" ) ); |
| 48 |
|
| 49 |
bw_add_shortcode( 'bw_twitter', 'bw_twitter', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 50 |
bw_add_shortcode( 'bw_facebook', 'bw_facebook', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 51 |
bw_add_shortcode( 'bw_linkedin', 'bw_linkedin', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 52 |
bw_add_shortcode( 'bw_youtube', 'bw_youtube', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 53 |
bw_add_shortcode( 'bw_flickr', 'bw_flickr', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 54 |
bw_add_shortcode( 'bw_picasa', 'bw_picasa', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 55 |
bw_add_shortcode( 'bw_googleplus', 'bw_google_plus', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 56 |
bw_add_shortcode( 'bw_google_plus', 'bw_google_plus', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 57 |
bw_add_shortcode( 'bw_google-plus', 'bw_google_plus', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 58 |
bw_add_shortcode( 'bw_google', 'bw_google_plus', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 59 |
bw_add_shortcode( 'bw_instagram', 'bw_instagram', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 60 |
bw_add_shortcode( 'bw_pinterest', 'bw_pinterest', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 61 |
|
| 62 |
bw_add_shortcode( 'bw_follow_me', 'bw_follow_me', oik_path( "shortcodes/oik-follow.php" ), false ); |
| 63 |
|
| 64 |
bw_add_shortcode( 'clear', 'bw_clear' ); |
| 65 |
|
| 66 |
|
| 67 |
//bw_add_shortcode_event( 'bw_logo', 'bw_logo', 'the_content,widget_text,settings_page_bw_email_signature' ); |
| 68 |
//bw_add_shortcode_file( "bw_logo", oik_path( "shortcodes/oik-logo.php" ) ); |
| 69 |
bw_add_shortcode( 'bw_logo', 'bw_logo', oik_path( "shortcodes/oik-logo.php" ), false ); |
| 70 |
|
| 71 |
//bw_add_shortcode_event( 'bw_qrcode', 'bw_qrcode', 'the_content,widget_text,settings_page_bw_email_signature'); |
| 72 |
//bw_add_shortcode_file( 'bw_qrcode', oik_path( "shortcodes/oik-qrcode.php" ) ); |
| 73 |
bw_add_shortcode( 'bw_qrcode', 'bw_qrcode', oik_path( "shortcodes/oik-qrcode.php" ), false ); |
| 74 |
|
| 75 |
// Include [div]/[sdiv], [ediv] and [sediv] |
| 76 |
bw_add_shortcode( 'div', 'bw_sdiv' ); |
| 77 |
bw_add_shortcode( 'sdiv', 'bw_sdiv' ); |
| 78 |
bw_add_shortcode( 'ediv', 'bw_ediv' ); |
| 79 |
bw_add_shortcode( 'sediv', 'bw_sediv' ); |
| 80 |
|
| 81 |
bw_add_shortcode( 'bw_emergency', 'bw_emergency', oik_path( "shortcodes/oik-phone.php" ) ); |
| 82 |
bw_add_shortcode( 'bw_abbr', 'bw_abbr' ); |
| 83 |
bw_add_shortcode( 'bw_acronym', 'bw_acronym' ); |
| 84 |
bw_add_shortcode( 'bw_blockquote', 'bw_blockquote' ); |
| 85 |
bw_add_shortcode( 'bw_cite', 'bw_cite' ); |
| 86 |
bw_add_shortcode( 'bw_copyright', 'bw_copyright' ); |
| 87 |
bw_add_shortcode( 'stag', 'bw_stag' ); |
| 88 |
bw_add_shortcode( 'etag', 'bw_etag' ); |
| 89 |
|
| 90 |
|
| 91 |
/* We shouldn't let any of these expand in titles */ |
| 92 |
bw_add_shortcode( "bw_tree", "bw_tree", oik_path("shortcodes/oik-tree.php"), false ); |
| 93 |
bw_add_shortcode( "bw_posts", "bw_posts", oik_path("shortcodes/oik-posts.php"), false ); |
| 94 |
bw_add_shortcode( 'bw_pages', 'bw_pages', oik_path("shortcodes/oik-pages.php"), false ); |
| 95 |
bw_add_shortcode( 'bw_list', 'bw_list', oik_path("shortcodes/oik-list.php"), false ); |
| 96 |
bw_add_shortcode( 'bw_bookmarks', 'bw_bookmarks', oik_path("shortcodes/oik-bookmarks.php"), false ); |
| 97 |
bw_add_shortcode( 'bw_attachments', 'bw_attachments', oik_path("shortcodes/oik-attachments.php"), false ); |
| 98 |
bw_add_shortcode( 'bw_pdf', 'bw_pdf', oik_path("shortcodes/oik-attachments.php"), false ); |
| 99 |
bw_add_shortcode( 'bw_images', 'bw_images', oik_path("shortcodes/oik-attachments.php"), false ); |
| 100 |
bw_add_shortcode( 'bw_portfolio', 'bw_portfolio', oik_path("shortcodes/oik-attachments.php"), false ); |
| 101 |
bw_add_shortcode( 'bw_thumbs', 'bw_thumbs', oik_path("shortcodes/oik-thumbs.php"), false ); |
| 102 |
|
| 103 |
bw_add_shortcode( 'bw_button', 'bw_button_shortcodes', oik_path("shortcodes/oik-button.php"), false ); |
| 104 |
bw_add_shortcode( 'bw_contact_button', 'bw_contact_button', oik_path("shortcodes/oik-button.php"), false ); |
| 105 |
|
| 106 |
bw_add_shortcode( 'bw_block', 'bw_block', oik_path("shortcodes/oik-blocks.php"), false ); |
| 107 |
bw_add_shortcode( 'bw_eblock', 'bw_eblock', oik_path("shortcodes/oik-blocks.php"), false ); |
| 108 |
bw_add_shortcode( 'paypal', 'bw_pp_shortcodes', oik_path( "shortcodes/oik-paypal.php"), false ); |
| 109 |
|
| 110 |
/* Allow the NextGEN slideshow to be used in widgets as well as in context |
| 111 |
*/ |
| 112 |
bw_add_shortcode_event( 'ngslideshow', 'NextGEN_shortcodes::show_slideshow', 'the_content,widget_text' ); |
| 113 |
// bw_add_shortcode_file ( 'ngslideshow', oik_path( "shortcodes/oik-slideshows.php") ); |
| 114 |
|
| 115 |
bw_add_shortcode( 'gpslides', 'bw_gp_slideshow', oik_path( "shortcodes/oik-slideshows.php"), false ); |
| 116 |
|
| 117 |
/* Shortcodes for each of the more useful APIs */ |
| 118 |
bw_add_shortcode( 'bwtron', 'bw_trace_on', oik_path( "shortcodes/oik-trace.php") , false ); |
| 119 |
bw_add_shortcode( 'bwtroff', 'bw_trace_off', oik_path( "shortcodes/oik-trace.php") , false ); |
| 120 |
bw_add_shortcode( 'bwtrace', 'bw_trace_button', oik_path( "shortcodes/oik-trace.php") , false ); |
| 121 |
|
| 122 |
add_action( "bw_sc_help", "bw_sc_help" ); |
| 123 |
add_action( "bw_sc_syntax", "bw_sc_syntax" ); |
| 124 |
add_action( "bw_sc_example", "bw_sc_example"); |
| 125 |
add_action( "bw_sc_snippet", "bw_sc_snippet" ); |
| 126 |
|
| 127 |
bw_add_shortcode_file( 'portfolio_slideshow', oik_path( "shortcodes/oik-slideshows.php"), false ); |
| 128 |
bw_add_shortcode_file( 'nggallery', oik_path( "shortcodes/oik-galleries.php" ) ); |
| 129 |
|
| 130 |
bw_add_shortcode( "bw_power", "bw_power", oik_path( "shortcodes/oik-power.php" ) ); |
| 131 |
bw_add_shortcode( 'bw_editcss', 'bw_editcss', oik_path("shortcodes/oik-bob-bing-wide.php"), false ); |
| 132 |
bw_add_shortcode( "bw_table", "bw_table", oik_path("shortcodes/oik-table.php"), false ); |
| 133 |
|
| 134 |
// New shortcodes for oik v2.0 |
| 135 |
bw_add_shortcode( "bw_parent", "bw_parent", oik_path( "shortcodes/oik-parent.php" ), false ); |
| 136 |
bw_add_shortcode( "bw_iframe", "bw_iframe", oik_path( "shortcodes/oik-iframe.php" ), false ); |
| 137 |
bw_add_shortcode( "bw_jq", "bwsc_jquery", oik_path( "shortcodes/oik-jquery.php" ), false ); |
| 138 |
bw_add_shortcode( "bw_accordion", "bw_accordion", oik_path( "shortcodes/oik-accordion.php" ), false ); |
| 139 |
bw_add_shortcode( "bw_tabs", "bw_tabs", oik_path( "shortcodes/oik-tabs.php" ), false ); |
| 140 |
bw_add_shortcode( "bw_login", "bw_login_shortcode", oik_path( "shortcodes/oik-login.php" ), false ); |
| 141 |
bw_add_shortcode( "bw_loginout", "bw_loginout_shortcode", oik_path( "shortcodes/oik-login.php" ), false ); |
| 142 |
bw_add_shortcode( "bw_register", "bw_register_shortcode", oik_path( "shortcodes/oik-login.php" ), false ); |
| 143 |
bw_add_shortcode( "bw_link", "bw_link", oik_path( "shortcodes/oik-link.php" ), false ); |
| 144 |
bw_add_shortcode( "bw_contact_form", "bw_contact_form", oik_path( "shortcodes/oik-contact-form.php" ), false ); |
| 145 |
|
| 146 |
|
| 147 |
bw_add_shortcode( "bw_countdown", "bw_countdown", oik_path( "shortcodes/oik-countdown.php" ), false ); |
| 148 |
/* New shortcode for oik v2.0.2 / v2.1 */ |
| 149 |
bw_add_shortcode( "bw_cycle", "bw_cycle", oik_path( "shortcodes/oik-cycle.php" ), false ); |
| 150 |
/* New shortcode for oik v2.3 */ |
| 151 |
bw_add_shortcode( "bw_count", "bw_count", oik_path( "shortcodes/oik-count.php" ) ); |
| 152 |
|
| 153 |
|
| 154 |
bw_add_shortcode( "bw_navi", "bw_navi", oik_path( "shortcodes/oik-navi.php" ), false ); |
| 155 |
|
| 156 |
add_filter( "oik_shortcode_result", "oik_navi_shortcode_result", 10, 4 ); |
| 157 |
add_filter( "oik_shortcode_atts", "oik_navi_shortcode_atts", 10, 3 ); |
| 158 |
|
| 159 |
} |
| 160 |
|
| 161 |
/** |
| 162 |
* Implement "oik_shortcode_atts" filter for pagination |
| 163 |
* |
| 164 |
* If the shortcode parameters includes "posts_per_page" then we need to consider pagination |
| 165 |
* This means that need to be able to access the WP_Query instance used to retrieve posts |
| 166 |
* So we have to create some 'slightly hidden' entries in the $atts array. |
| 167 |
* |
| 168 |
* 'bwscid' - the shortcode identifier |
| 169 |
* 'paged' - instructs WP_Query to access a particular page |
| 170 |
* 'bw_query' - the new instance of WP_Query to be used to perform the DB access |
| 171 |
* |
| 172 |
* |
| 173 |
* @param array $atts - shortcode parameters to filter |
| 174 |
* @param string $content - content of enclosed shortcode |
| 175 |
* @param string $tag - shortcode name |
| 176 |
* @return array - the filtered atts array |
| 177 |
*/ |
| 178 |
function oik_navi_shortcode_atts( $atts=null, $content=null, $tag=null ) { |
| 179 |
$posts_per_page = bw_array_get( $atts, "posts_per_page", null ); |
| 180 |
if ( $posts_per_page ) { |
| 181 |
oik_require( "shortcodes/oik-navi.php" ); |
| 182 |
$bwscid = bw_get_shortcode_id( true ); |
| 183 |
$page = bw_check_paged_shortcode( $bwscid ); |
| 184 |
$atts['bwscid'] = $bwscid; |
| 185 |
$atts['paged'] = $page; |
| 186 |
if ( !is_numeric( $posts_per_page ) ) { |
| 187 |
$atts['posts_per_page'] = get_option( "posts_per_page" ); |
| 188 |
} |
| 189 |
$atts['bw_query'] = new WP_Query(); |
| 190 |
} |
| 191 |
return( $atts ); |
| 192 |
} |
| 193 |
|
| 194 |
/** |
| 195 |
* Implement "oik_shortcode_result" for pagination |
| 196 |
* |
| 197 |
* @param string $result - the result of the shortcode expansion so far |
| 198 |
* @param array $atts - shortcode parameters - including our amendments |
| 199 |
* @param string $content - future use |
| 200 |
* @param string $tag - future use |
| 201 |
* @return string - the modified result |
| 202 |
* |
| 203 |
*/ |
| 204 |
function oik_navi_shortcode_result( $result=null, $atts=null, $content=null, $tag=null ) { |
| 205 |
$posts_per_page = bw_array_get( $atts, "posts_per_page", null ); |
| 206 |
if ( $posts_per_page ) { |
| 207 |
oik_require( "shortcodes/oik-navi.php" ); // belt and braces |
| 208 |
oik_navi_s2eofn_from_query( $atts ); |
| 209 |
$prepend = bw_ret(); |
| 210 |
$result = $prepend . $result; |
| 211 |
oik_navi_lazy_paginate_links( $atts ); |
| 212 |
$result .= bw_ret(); |
| 213 |
} |
| 214 |
return( $result ); |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
|