PageRenderTime 49ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/strappress/includes/sp-shortcodes.php

https://github.com/bfay/maniacal-kitten
PHP | 662 lines | 490 code | 140 blank | 32 comment | 20 complexity | 7019d01dd037bb0e086f4372173ecdb8 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-3.0, LGPL-2.1
  1. <?php
  2. //Buttons
  3. function sp_buttons( $atts, $content = null ) {
  4. extract(shortcode_atts(array(
  5. 'link' => '#',
  6. 'style' => '',
  7. 'block' => '',
  8. 'target' => '',
  9. 'size' => '',
  10. 'poptitle' => '',
  11. 'popcontent' => '',
  12. ), $atts));
  13. $content = sp_content_helper($content);
  14. $target = ($target == 'blank') ? 'target="_blank"' : '';
  15. $block = ($block == 'yes') ? "btn-block " : '';
  16. $size = ($size <> '') ? "btn-$size " : '';
  17. $style = ($style <> '') ? "btn-$style" : '';
  18. $poptitle = ($poptitle <> '') ? "rel='popover' data-original-title='$poptitle'" : '';
  19. $popcontent = ($popcontent <> '') ? "data-content='$popcontent'" : '';
  20. $out = '<a ' . $poptitle . '' . $popcontent . '' . $target. ' class="btn ' . $size . '' . $block . '' . $style. '" href="' .$link. '">' .do_shortcode($content). '</a>';
  21. return $out;
  22. }
  23. add_shortcode('button', 'sp_buttons');
  24. //Button Group
  25. function sp_buttong( $atts, $content = null ) {
  26. $content = sp_content_helper($content);
  27. $output = '
  28. <div class="btn-group">
  29. '.do_shortcode($content).'
  30. </div>';
  31. return $output;
  32. }
  33. add_shortcode('buttongroup', 'sp_buttong');
  34. //Button Dropdown
  35. function sp_buttondd( $atts, $content = null ) {
  36. extract(shortcode_atts(array(
  37. 'label' => '',
  38. 'style' => '',
  39. 'block' => '',
  40. 'size' => '',
  41. 'istyle' => '',
  42. 'isize' => '',
  43. ), $atts));
  44. $content = sp_content_helper($content);
  45. $style = ($style <> '') ? "btn-$style" : '';
  46. $block = ($block == 'yes') ? "btn-block " : '';
  47. $size = ($size <> '') ? "btn-$size " : '';
  48. $isize = ($isize <> '') ? "icon-$isize" : '';
  49. $istyle = ($istyle <> '') ? "icon-$istyle" : '';
  50. $output = '
  51. <div class="btn-group">
  52. <a class="btn ' . $size . '' . $block . '' . $style. ' dropdown-toggle" data-toggle="dropdown" href="#"><i class="' . $istyle . ' ' . $isize. '"></i> ' .$label. ' <span class="caret"></span></a>
  53. <ul class="dropdown-menu">
  54. '.do_shortcode($content).'
  55. </ul>
  56. </div>';
  57. return $output;
  58. }
  59. add_shortcode('buttondd', 'sp_buttondd');
  60. //Button Split Dropdown
  61. function sp_buttonsplit( $atts, $content = null ) {
  62. extract(shortcode_atts(array(
  63. 'label' => '',
  64. 'style' => '',
  65. 'size' => '',
  66. 'block' => '',
  67. 'link' => '',
  68. 'target' => '',
  69. 'istyle' => '',
  70. 'isize' => '',
  71. ), $atts));
  72. $content = sp_content_helper($content);
  73. $style = ($style <> '') ? "btn-$style" : '';
  74. $size = ($size <> '') ? "btn-$size " : '';
  75. $block = ($block == 'yes') ? "btn-block " : '';
  76. $target = ($target == 'blank') ? 'target="_blank"' : '';
  77. $isize = ($isize <> '') ? "icon-$isize" : '';
  78. $istyle = ($istyle <> '') ? "icon-$istyle" : '';
  79. $output = '
  80. <div class="btn-group">
  81. <a ' . $target. ' class="btn ' . $size . '' . $block . '' . $style. '" href="'. $link .'"><i class="' . $istyle . ' ' . $isize. '"></i> ' .$label. ' </a><a class="btn ' . $size . '' . $style. ' dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
  82. <ul class="dropdown-menu">
  83. '.do_shortcode($content).'
  84. </ul>
  85. </div>';
  86. return $output;
  87. }
  88. add_shortcode('buttonsplit', 'sp_buttonsplit');
  89. //Button Dropdown Link
  90. function sp_ddlink( $atts, $content = null ) {
  91. extract(shortcode_atts(array(
  92. 'link' => '',
  93. 'target' => '',
  94. ), $atts));
  95. $content = sp_content_helper($content);
  96. $target = ($target == 'blank') ? 'target="_blank"' : '';
  97. $output = '
  98. <li><a ' . $target. ' href="'. $link .'">'.do_shortcode($content).'</a></li>';
  99. return $output;
  100. }
  101. add_shortcode('ddlink', 'sp_ddlink');
  102. //Dropdown Divider
  103. function sp_divider( $atts, $content = null ) {
  104. $output = '
  105. <li class="divider"></li>';
  106. return $output;
  107. }
  108. add_shortcode('divider', 'sp_divider');
  109. //Carousel
  110. function sp_carousel( $atts, $content = null ) {
  111. extract(shortcode_atts(array(
  112. 'name' => '',
  113. ), $atts));
  114. $content = sp_content_helper($content);
  115. $output = '
  116. <div id="'.$name.'" class="carousel">
  117. <div class="carousel-inner">
  118. '.do_shortcode($content).'
  119. </div>
  120. <a class="carousel-control left" href="#'.$name.'" data-slide="prev">&lsaquo;</a>
  121. <a class="carousel-control right" href="#'.$name.'" data-slide="next">&rsaquo;</a>
  122. </div>';
  123. return $output;
  124. }
  125. add_shortcode('carousel', 'sp_carousel');
  126. //Single Carousel Image
  127. function sp_cimage( $atts, $content = null ) {
  128. extract(shortcode_atts(array(
  129. 'first' => '',
  130. 'title' => '',
  131. 'link' => '',
  132. 'caption' => '',
  133. ), $atts));
  134. $content = sp_content_helper($content);
  135. $first = ($first == 'yes') ? 'active' : '';
  136. $content = ($content <> '') ? "<div class='carousel-caption'><h4>$title</h4><p>$content</p></div></div>" : '';
  137. $out = '<div class="item ' .$first. '"><img src="' .$link. '">' .do_shortcode($content).'';
  138. return $out;
  139. }
  140. add_shortcode('cimage', 'sp_cimage');
  141. //Accordion
  142. function sp_accordion( $atts, $content = null ) {
  143. extract(shortcode_atts(array(
  144. 'name' => '',
  145. ), $atts));
  146. $content = sp_content_helper($content);
  147. $output = '
  148. <div id="'.$name.'" class="accordion">
  149. '.do_shortcode($content).'
  150. </div>';
  151. return $output;
  152. }
  153. add_shortcode('accordion', 'sp_accordion');
  154. //Accordion Content
  155. function sp_caccordion( $atts, $content = null ) {
  156. extract(shortcode_atts(array(
  157. 'name' => '',
  158. 'heading' => '',
  159. 'number' => '',
  160. 'open' => '',
  161. ), $atts));
  162. $content = sp_content_helper($content);
  163. $open = ($open == 'yes') ? 'in' : '';
  164. $output = '
  165. <div class="accordion-group">
  166. <div class="accordion-heading">
  167. <a class="accordion-toggle" data-toggle="collapse" data-parent="#'.$name.'" href="#collapse'.$number.'">'. $heading .'</a>
  168. </div>
  169. <div id="collapse'.$number.'" class="accordion-body collapse ' .$open. '">
  170. <div class="accordion-inner">
  171. '.do_shortcode($content).'
  172. </div>
  173. </div>
  174. </div>
  175. ';
  176. return $output;
  177. }
  178. add_shortcode('caccordion', 'sp_caccordion');
  179. //Tabs
  180. function sp_tabs( $atts, $content = null ) {
  181. extract(shortcode_atts(array(
  182. 'location' => '',
  183. ), $atts));
  184. $content = sp_content_helper($content);
  185. $output = '
  186. <div class="tabbable ' .$location. '">
  187. '.do_shortcode($content).'
  188. </div>';
  189. return $output;
  190. }
  191. add_shortcode('tabs', 'sp_tabs');
  192. //Tab Title Section
  193. function sp_titlesection( $atts, $content = null ) {
  194. extract(shortcode_atts(array(
  195. 'type' => '',
  196. ), $atts));
  197. $content = sp_content_helper($content);
  198. $output = '
  199. <ul class="nav nav-' .$type. '">
  200. '.do_shortcode($content).'
  201. </ul>';
  202. return $output;
  203. }
  204. add_shortcode('titlesection', 'sp_titlesection');
  205. //Tab Titles
  206. function sp_tabtitle( $atts, $content = null ) {
  207. extract(shortcode_atts(array(
  208. 'active' => '',
  209. 'number' => '',
  210. ), $atts));
  211. $content = sp_content_helper($content);
  212. $active = ($active == 'yes') ? "class='active'" : '';
  213. $output = '
  214. <li ' .$active. '><a href="#' .$number. '" data-toggle="tab">'.do_shortcode($content).'</a></li>';
  215. return $output;
  216. }
  217. add_shortcode('tabtitle', 'sp_tabtitle');
  218. //Tab Title Section
  219. function sp_contentsection( $atts, $content = null ) {
  220. $content = sp_content_helper($content);
  221. $output = '
  222. <div class="tab-content">
  223. '.do_shortcode($content).'
  224. </div>';
  225. return $output;
  226. }
  227. add_shortcode('contentsection', 'sp_contentsection');
  228. //Tab Content
  229. function sp_tabcontent( $atts, $content = null ) {
  230. extract(shortcode_atts(array(
  231. 'active' => '',
  232. 'number' => '',
  233. ), $atts));
  234. $content = sp_content_helper($content);
  235. $active = ($active == 'yes') ? "active" : '';
  236. $output = '
  237. <div class="tab-pane ' .$active. '" id="' .$number. '">
  238. <p>'.do_shortcode($content).'</p>
  239. </div>';
  240. return $output;
  241. }
  242. add_shortcode('tabcontent', 'sp_tabcontent');
  243. //Icons
  244. function sp_icons( $atts, $content = null ) {
  245. extract(shortcode_atts(array(
  246. 'style' => '',
  247. 'size' => '',
  248. ), $atts));
  249. $size = ($size <> '') ? "icon-$size" : '';
  250. $out = '<i class="icon-' . $style . ' ' . $size. '"></i>';
  251. return $out;
  252. }
  253. add_shortcode('icon', 'sp_icons');
  254. //Heading
  255. function sp_heading( $atts, $content = null ) {
  256. extract(shortcode_atts(array(
  257. 'size' => '',
  258. 'small' => '',
  259. ), $atts));
  260. $small = ($small <> '') ? "<small>$small</small>" : '';
  261. $out = '<h'. $size . '>'.do_shortcode($content). ''. $small .'</h'. $size . '>';
  262. return $out;
  263. }
  264. add_shortcode('heading', 'sp_heading');
  265. //Code
  266. function sp_codes( $atts, $content = null ) {
  267. extract(shortcode_atts(array(
  268. 'scroll' => '',
  269. ), $atts));
  270. $scroll = ($scroll == 'yes') ? 'class="pre-scrollable"' : '';
  271. $out = '<pre ' . $scroll . '>'.do_shortcode($content). '</pre>';
  272. return $out;
  273. }
  274. add_shortcode('codes', 'sp_codes');
  275. //Single line of Code
  276. function sp_code( $atts, $content = null ) {
  277. return '<code>'.$content.'</code>';
  278. }
  279. add_shortcode('code', 'sp_code');
  280. //Labels
  281. function sp_labels( $atts, $content = null ) {
  282. extract(shortcode_atts(array(
  283. 'style' => '',
  284. ), $atts));
  285. $out = '<span class="label label-' . $style . '">' .do_shortcode($content). '</span>';
  286. return $out;
  287. }
  288. add_shortcode('label', 'sp_labels');
  289. //Badges
  290. function sp_badges( $atts, $content = null ) {
  291. extract(shortcode_atts(array(
  292. 'style' => '',
  293. ), $atts));
  294. $out = '<span class="badge badge-' . $style . '">' .do_shortcode($content). '</span>';
  295. return $out;
  296. }
  297. add_shortcode('badge', 'sp_badges');
  298. //Progress Bars
  299. function sp_bars( $atts, $content = null ) {
  300. extract(shortcode_atts(array(
  301. 'width' => '',
  302. 'strip' => '',
  303. 'animate' => '',
  304. 'style' => '',
  305. ), $atts));
  306. $strip = ($strip == 'yes') ? 'progress-striped' : '';
  307. $animate = ($animate == 'yes') ? 'active' : '';
  308. $style = ($style <> '') ? "progress-$style" : '';
  309. $out = '<div class="progress ' . $style . ' ' . $strip . ' ' . $animate . '"><div class="bar" style="width:' . $width . '%">' .do_shortcode($content). '</div></div>';
  310. return $out;
  311. }
  312. add_shortcode('bar', 'sp_bars');
  313. //Stacked Progress Bars Container
  314. function sp_bars_cont( $atts, $content = null ) {
  315. extract(shortcode_atts(array(
  316. 'width' => '',
  317. 'strip' => '',
  318. 'animate' => '',
  319. 'style' => '',
  320. ), $atts));
  321. $strip = ($strip == 'yes') ? 'progress-striped' : '';
  322. $animate = ($animate == 'yes') ? 'active' : '';
  323. $style = ($style <> '') ? "progress-$style" : '';
  324. $out = '<div class="progress ' . $style . ' ' . $strip . ' ' . $animate . '">' .do_shortcode($content). '</div>';
  325. return $out;
  326. }
  327. add_shortcode('barc', 'sp_bars_cont');
  328. //Single Progress Bars
  329. function sp_bars_single( $atts, $content = null ) {
  330. extract(shortcode_atts(array(
  331. 'width' => '',
  332. 'style' => '',
  333. ), $atts));
  334. $style = ($style <> '') ? "bar-$style" : '';
  335. $out = '<div class="bar ' . $style .' " style="width:' . $width . '%">' .do_shortcode($content). '</div>';
  336. return $out;
  337. }
  338. add_shortcode('sbar', 'sp_bars_single');
  339. //Well
  340. function sp_well( $atts, $content = null ) {
  341. return '<div class="well">'.$content.'</div>';
  342. }
  343. add_shortcode('well', 'sp_well');
  344. //Alerts
  345. function sp_alerts( $atts, $content = null ) {
  346. extract(shortcode_atts(array(
  347. 'type' => '',
  348. 'heading' => '',
  349. ), $atts));
  350. $type = ($type <> '') ? "alert-$type" : '';
  351. $heading = ($heading <> '') ? "<h4 class='alert-heading'>$heading</h4>" : '';
  352. $out = '<div class="alert alert-block ' . $type .'"><a class="close" data-dismiss="alert">×</a>' . $heading . '<p>' .do_shortcode($content). '</p></div>';
  353. return $out;
  354. }
  355. add_shortcode('alert', 'sp_alerts');
  356. //Tooltips
  357. function sp_tooltips( $atts, $content = null ) {
  358. extract(shortcode_atts(array(
  359. 'tip' => '',
  360. ), $atts));
  361. $out = '<a href="#" rel="tooltip" title="' . $tip .'">' .do_shortcode($content). '</a>';
  362. return $out;
  363. }
  364. add_shortcode('tooltip', 'sp_tooltips');
  365. //Popovers
  366. function sp_popovers( $atts, $content = null ) {
  367. extract(shortcode_atts(array(
  368. 'title' => '',
  369. 'content' => '',
  370. ), $atts));
  371. $out = '<a href="#" rel="popover" title="' . $title .'" data-content="' . $content . '">' .do_shortcode($content). '</a>';
  372. return $out;
  373. }
  374. add_shortcode('popover', 'sp_popovers');
  375. //Table
  376. function sp_table( $atts ) {
  377. extract( shortcode_atts( array(
  378. 'cols' => 'none',
  379. 'data' => 'none',
  380. 'strip' => '',
  381. 'style' => '',
  382. 'border' => '',
  383. 'condense' => '',
  384. ), $atts ) );
  385. $strip = ($strip == 'yes') ? 'table-striped' : '';
  386. $border = ($border == 'yes') ? 'table-bordered' : '';
  387. $condense = ($condense == 'yes') ? 'table-condensed' : '';
  388. $cols = explode(',',$cols);
  389. $data = explode(',',$data);
  390. $total = count($cols);
  391. $output = '<table class="table ' . $strip . ' ' . $border . ' ' . $condense . '"><tr>';
  392. foreach($cols as $col):
  393. $output .= '<th>'. $col . '</th>';
  394. endforeach;
  395. $output .= '</tr><tr>';
  396. $counter = 1;
  397. foreach($data as $datum):
  398. $output .= '<td>'. $datum .'</td>';
  399. if($counter%$total==0):
  400. $output .= '</tr>';
  401. endif;
  402. $counter++;
  403. endforeach;
  404. $output .= '</table>';
  405. return $output;
  406. }
  407. add_shortcode( 'table', 'sp_table' );
  408. //Columns
  409. function sp_one_third( $atts, $content = null ) {
  410. return '<div class="one_third">' . do_shortcode($content) . '</div>';
  411. }
  412. add_shortcode('one_third', 'sp_one_third');
  413. function sp_one_third_last( $atts, $content = null ) {
  414. return '<div class="one_third last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
  415. }
  416. add_shortcode('one_third_last', 'sp_one_third_last');
  417. function sp_two_third( $atts, $content = null ) {
  418. return '<div class="two_third">' . do_shortcode($content) . '</div>';
  419. }
  420. add_shortcode('two_third', 'sp_two_third');
  421. function sp_two_third_last( $atts, $content = null ) {
  422. return '<div class="two_third last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
  423. }
  424. add_shortcode('two_third_last', 'sp_two_third_last');
  425. function sp_one_half( $atts, $content = null ) {
  426. return '<div class="one_half">' . do_shortcode($content) . '</div>';
  427. }
  428. add_shortcode('one_half', 'sp_one_half');
  429. function sp_one_half_last( $atts, $content = null ) {
  430. return '<div class="one_half last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
  431. }
  432. add_shortcode('one_half_last', 'sp_one_half_last');
  433. function sp_one_fourth( $atts, $content = null ) {
  434. return '<div class="one_fourth">' . do_shortcode($content) . '</div>';
  435. }
  436. add_shortcode('one_fourth', 'sp_one_fourth');
  437. function sp_one_fourth_last( $atts, $content = null ) {
  438. return '<div class="one_fourth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
  439. }
  440. add_shortcode('one_fourth_last', 'sp_one_fourth_last');
  441. function sp_three_fourth( $atts, $content = null ) {
  442. return '<div class="three_fourth">' . do_shortcode($content) . '</div>';
  443. }
  444. add_shortcode('three_fourth', 'sp_three_fourth');
  445. function sp_three_fourth_last( $atts, $content = null ) {
  446. return '<div class="three_fourth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
  447. }
  448. add_shortcode('three_fourth_last', 'sp_three_fourth_last');
  449. function sp_one_fifth( $atts, $content = null ) {
  450. return '<div class="one_fifth">' . do_shortcode($content) . '</div>';
  451. }
  452. add_shortcode('one_fifth', 'sp_one_fifth');
  453. function sp_one_fifth_last( $atts, $content = null ) {
  454. return '<div class="one_fifth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
  455. }
  456. add_shortcode('one_fifth_last', 'sp_one_fifth_last');
  457. function sp_two_fifth( $atts, $content = null ) {
  458. return '<div class="two_fifth">' . do_shortcode($content) . '</div>';
  459. }
  460. add_shortcode('two_fifth', 'sp_two_fifth');
  461. function sp_two_fifth_last( $atts, $content = null ) {
  462. return '<div class="two_fifth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
  463. }
  464. add_shortcode('two_fifth_last', 'sp_two_fifth_last');
  465. function sp_three_fifth( $atts, $content = null ) {
  466. return '<div class="three_fifth">' . do_shortcode($content) . '</div>';
  467. }
  468. add_shortcode('three_fifth', 'sp_three_fifth');
  469. function sp_three_fifth_last( $atts, $content = null ) {
  470. return '<div class="three_fifth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
  471. }
  472. add_shortcode('three_fifth_last', 'sp_three_fifth_last');
  473. function sp_four_fifth( $atts, $content = null ) {
  474. return '<div class="four_fifth">' . do_shortcode($content) . '</div>';
  475. }
  476. add_shortcode('four_fifth', 'sp_four_fifth');
  477. function sp_four_fifth_last( $atts, $content = null ) {
  478. return '<div class="four_fifth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
  479. }
  480. add_shortcode('four_fifth_last', 'sp_four_fifth_last');
  481. function sp_one_sixth( $atts, $content = null ) {
  482. return '<div class="one_sixth">' . do_shortcode($content) . '</div>';
  483. }
  484. add_shortcode('one_sixth', 'sp_one_sixth');
  485. function sp_one_sixth_last( $atts, $content = null ) {
  486. return '<div class="one_sixth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
  487. }
  488. add_shortcode('one_sixth_last', 'sp_one_sixth_last');
  489. function sp_five_sixth( $atts, $content = null ) {
  490. return '<div class="five_sixth">' . do_shortcode($content) . '</div>';
  491. }
  492. add_shortcode('five_sixth', 'sp_five_sixth');
  493. function sp_five_sixth_last( $atts, $content = null ) {
  494. return '<div class="five_sixth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
  495. }
  496. add_shortcode('five_sixth_last', 'sp_five_sixth_last');
  497. function sp_delete_htmltags($content,$paragraph_tag=false,$br_tag=false){
  498. #$content = preg_replace('#<\/p>(\s)*<p>$|^<\/p>(\s)*<p>#', '', trim($content));
  499. $content = preg_replace('#^<\/p>|^<br \/>|<p>$#', '', $content);
  500. $content = preg_replace('#<br \/>#', '', $content);
  501. if ( $paragraph_tag ) $content = preg_replace('#<p>|</p>#', '', $content);
  502. return trim($content);
  503. }
  504. function sp_content_helper($content,$paragraph_tag=false,$br_tag=false){
  505. return sp_delete_htmltags( do_shortcode(shortcode_unautop($content)), $paragraph_tag, $br_tag );
  506. }
  507. function custom_login_logo() {
  508. echo '<style type="text/css">
  509. h1 a { background-image:url('.get_bloginfo('template_directory').'/images/logo.png) !important; }
  510. </style>';
  511. }
  512. add_action('login_head', 'custom_login_logo');
  513. add_filter( 'login_headerurl', 'my_custom_login_url' );
  514. function my_custom_login_url($url) {
  515. return 'http://bragthemes.com';
  516. }
  517. //widget support
  518. add_filter('widget_text', 'do_shortcode')
  519. ?>