/inc/core/shortcodes.php

  1. <?php 
  2. class Su_Shortcodes { 
  3. static $tabs = array(); 
  4. static $tab_count = 0; 
  5.  
  6. function __construct() {} 
  7.  
  8. public static function heading( $atts = null, $content = null ) { 
  9. $atts = shortcode_atts( array( 
  10. 'style' => 'default',  
  11. 'size' => 13,  
  12. 'align' => 'center',  
  13. 'margin' => '20',  
  14. 'class' => '' 
  15. ), $atts, 'heading' ); 
  16. su_query_asset( 'css', 'su-content-shortcodes' ); 
  17. do_action( 'su/shortcode/heading', $atts ); 
  18. return '<div class="su-heading su-heading-style-' . $atts['style'] . ' su-heading-align-' . $atts['align'] . su_ecssc( $atts ) . '" style="font-size:' . intval( $atts['size'] ) . 'px;margin-bottom:' . $atts['margin'] . 'px"><div class="su-heading-inner">' . do_shortcode( $content ) . '</div></div>'; 
  19.  
  20. public static function tabs( $atts = null, $content = null ) { 
  21. $atts = shortcode_atts( array( 
  22. 'active' => 1,  
  23. 'vertical' => 'no',  
  24. 'style' => 'default', // 3.x 
  25. 'class' => '' 
  26. ), $atts, 'tabs' ); 
  27. if ( $atts['style'] === '3' ) $atts['vertical'] = 'yes'; 
  28. do_shortcode( $content ); 
  29. $return = ''; 
  30. $tabs = $panes = array(); 
  31. if ( is_array( self::$tabs ) ) { 
  32. if ( self::$tab_count < $atts['active'] ) $atts['active'] = self::$tab_count; 
  33. foreach ( self::$tabs as $tab ) { 
  34. $tabs[] = '<span class="' . su_ecssc( $tab ) . $tab['disabled'] . '"' . $tab['anchor'] . $tab['url'] . $tab['target'] . '>' . su_scattr( $tab['title'] ) . '</span>'; 
  35. $panes[] = '<div class="su-tabs-pane su-clearfix' . su_ecssc( $tab ) . '">' . $tab['content'] . '</div>'; 
  36. $atts['vertical'] = ( $atts['vertical'] === 'yes' ) ? ' su-tabs-vertical' : ''; 
  37. $return = '<div class="su-tabs su-tabs-style-' . $atts['style'] . $atts['vertical'] . su_ecssc( $atts ) . '" data-active="' . (string) $atts['active'] . '"><div class="su-tabs-nav">' . implode( '', $tabs ) . '</div><div class="su-tabs-panes">' . implode( "\n", $panes ) . '</div></div>'; 
  38. // Reset tabs 
  39. self::$tabs = array(); 
  40. self::$tab_count = 0; 
  41. su_query_asset( 'css', 'su-box-shortcodes' ); 
  42. su_query_asset( 'js', 'jquery' ); 
  43. su_query_asset( 'js', 'su-other-shortcodes' ); 
  44. do_action( 'su/shortcode/tabs', $atts ); 
  45. return $return; 
  46.  
  47. public static function tab( $atts = null, $content = null ) { 
  48. $atts = shortcode_atts( array( 
  49. 'title' => __( 'Tab title', 'su' ),  
  50. 'disabled' => 'no',  
  51. 'anchor' => '',  
  52. 'url' => '',  
  53. 'target' => 'blank',  
  54. 'class' => '' 
  55. ), $atts, 'tab' ); 
  56. $x = self::$tab_count; 
  57. self::$tabs[$x] = array( 
  58. 'title' => $atts['title'],  
  59. 'content' => do_shortcode( $content ),  
  60. 'disabled' => ( $atts['disabled'] === 'yes' ) ? ' su-tabs-disabled' : '',  
  61. 'anchor' => ( $atts['anchor'] ) ? ' data-anchor="' . str_replace( array( ' ', '#' ), '', sanitize_text_field( $atts['anchor'] ) ) . '"' : '',  
  62. 'url' => ' data-url="' . $atts['url'] . '"',  
  63. 'target' => ' data-target="' . $atts['target'] . '"',  
  64. 'class' => $atts['class'] 
  65. ); 
  66. self::$tab_count++; 
  67. do_action( 'su/shortcode/tab', $atts ); 
  68.  
  69. public static function spoiler( $atts = null, $content = null ) { 
  70. $atts = shortcode_atts( array( 
  71. 'title' => __( 'Spoiler title', 'su' ),  
  72. 'open' => 'no',  
  73. 'style' => 'default',  
  74. 'icon' => 'plus',  
  75. 'anchor' => '',  
  76. 'class' => '' 
  77. ), $atts, 'spoiler' ); 
  78. $atts['style'] = str_replace( array( '1', '2' ), array( 'default', 'fancy' ), $atts['style'] ); 
  79. $atts['anchor'] = ( $atts['anchor'] ) ? ' data-anchor="' . str_replace( array( ' ', '#' ), '', sanitize_text_field( $atts['anchor'] ) ) . '"' : ''; 
  80. if ( $atts['open'] !== 'yes' ) $atts['class'] .= ' su-spoiler-closed'; 
  81. su_query_asset( 'css', 'font-awesome' ); 
  82. su_query_asset( 'css', 'su-box-shortcodes' ); 
  83. su_query_asset( 'js', 'jquery' ); 
  84. su_query_asset( 'js', 'su-other-shortcodes' ); 
  85. do_action( 'su/shortcode/spoiler', $atts ); 
  86. return '<div class="su-spoiler su-spoiler-style-' . $atts['style'] . ' su-spoiler-icon-' . $atts['icon'] . su_ecssc( $atts ) . '"' . $atts['anchor'] . '><div class="su-spoiler-title"><span class="su-spoiler-icon"></span>' . su_scattr( $atts['title'] ) . '</div><div class="su-spoiler-content su-clearfix" style="display:none">' . su_do_shortcode( $content, 's' ) . '</div></div>'; 
  87.  
  88. public static function accordion( $atts = null, $content = null ) { 
  89. $atts = shortcode_atts( array( 'class' => '' ), $atts, 'accordion' ); 
  90. do_action( 'su/shortcode/accordion', $atts ); 
  91. return '<div class="su-accordion' . su_ecssc( $atts ) . '">' . do_shortcode( $content ) . '</div>'; 
  92.  
  93. public static function divider( $atts = null, $content = null ) { 
  94. $atts = shortcode_atts( array( 
  95. 'top' => 'yes',  
  96. 'text' => __( 'Go to top', 'su' ),  
  97. 'style' => 'default',  
  98. 'divider_color' => '#999999',  
  99. 'link_color' => '#999999',  
  100. 'size' => '3',  
  101. 'margin' => '15',  
  102. 'class' => '' 
  103. ), $atts, 'divider' ); 
  104. // Prepare TOP link 
  105. $top = ( $atts['top'] === 'yes' ) ? '<a href="#" style="color:' . $atts['link_color'] . '">' . su_scattr( $atts['text'] ) . '</a>' : ''; 
  106. su_query_asset( 'css', 'su-content-shortcodes' ); 
  107. return '<div class="su-divider su-divider-style-' . $atts['style'] . su_ecssc( $atts ) . '" style="margin:' . $atts['margin'] . 'px 0;border-width:' . $atts['size'] . 'px;border-color:' . $atts['divider_color'] . '">' . $top . '</div>'; 
  108.  
  109. public static function spacer( $atts = null, $content = null ) { 
  110. $atts = shortcode_atts( array( 
  111. 'size' => '20',  
  112. 'class' => '' 
  113. ), $atts, 'spacer' ); 
  114. su_query_asset( 'css', 'su-content-shortcodes' ); 
  115. return '<div class="su-spacer' . su_ecssc( $atts ) . '" style="height:' . (string) $atts['size'] . 'px"></div>'; 
  116.  
  117. public static function highlight( $atts = null, $content = null ) { 
  118. $atts = shortcode_atts( array( 
  119. 'background' => '#ddff99',  
  120. 'bg' => null, // 3.x 
  121. 'color' => '#000000',  
  122. 'class' => '' 
  123. ), $atts, 'highlight' ); 
  124. if ( $atts['bg'] !== null ) $atts['background'] = $atts['bg']; 
  125. su_query_asset( 'css', 'su-content-shortcodes' ); 
  126. return '<span class="su-highlight' . su_ecssc( $atts ) . '" style="background:' . $atts['background'] . ';color:' . $atts['color'] . '"> ' . do_shortcode( $content ) . ' </span>'; 
  127.  
  128. public static function label( $atts = null, $content = null ) { 
  129. $atts = shortcode_atts( array( 
  130. 'type' => 'default',  
  131. 'style' => null, // 3.x 
  132. 'class' => '' 
  133. ), $atts, 'label' ); 
  134. if ( $atts['style'] !== null ) $atts['type'] = $atts['style']; 
  135. su_query_asset( 'css', 'su-content-shortcodes' ); 
  136. return '<span class="su-label su-label-type-' . $atts['type'] . su_ecssc( $atts ) . '">' . do_shortcode( $content ) . '</span>'; 
  137.  
  138. public static function quote( $atts = null, $content = null ) { 
  139. $atts = shortcode_atts( array( 
  140. 'style' => 'default',  
  141. 'cite' => false,  
  142. 'url' => false,  
  143. 'class' => '' 
  144. ), $atts, 'quote' ); 
  145. $cite_link = ( $atts['url'] && $atts['cite'] ) ? '<a href="' . $atts['url'] . '" target="_blank">' . $atts['cite'] . '</a>' 
  146. : $atts['cite']; 
  147. $cite = ( $atts['cite'] ) ? '<span class="su-quote-cite">' . $cite_link . '</span>' : ''; 
  148. $cite_class = ( $atts['cite'] ) ? ' su-quote-has-cite' : ''; 
  149. su_query_asset( 'css', 'su-box-shortcodes' ); 
  150. do_action( 'su/shortcode/quote', $atts ); 
  151. return '<div class="su-quote su-quote-style-' . $atts['style'] . $cite_class . su_ecssc( $atts ) . '"><div class="su-quote-inner su-clearfix">' . do_shortcode( $content ) . su_scattr( $cite ) . '</div></div>'; 
  152.  
  153. public static function pullquote( $atts = null, $content = null ) { 
  154. $atts = shortcode_atts( array( 
  155. 'align' => 'left',  
  156. 'class' => '' 
  157. ), $atts, 'pullquote' ); 
  158. su_query_asset( 'css', 'su-box-shortcodes' ); 
  159. return '<div class="su-pullquote su-pullquote-align-' . $atts['align'] . su_ecssc( $atts ) . '">' . do_shortcode( $content ) . '</div>'; 
  160.  
  161. public static function dropcap( $atts = null, $content = null ) { 
  162. $atts = shortcode_atts( array( 
  163. 'style' => 'default',  
  164. 'size' => 3,  
  165. 'class' => '' 
  166. ), $atts, 'dropcap' ); 
  167. $atts['style'] = str_replace( array( '1', '2', '3' ), array( 'default', 'light', 'default' ), $atts['style'] ); // 3.x 
  168. // Calculate font-size 
  169. $em = $atts['size'] * 0.5 . 'em'; 
  170. su_query_asset( 'css', 'su-content-shortcodes' ); 
  171. return '<span class="su-dropcap su-dropcap-style-' . $atts['style'] . su_ecssc( $atts ) . '" style="font-size:' . $em . '">' . do_shortcode( $content ) . '</span>'; 
  172.  
  173. public static function frame( $atts = null, $content = null ) { 
  174. $atts = shortcode_atts( array( 
  175. 'style' => 'default',  
  176. 'align' => 'left',  
  177. 'class' => '' 
  178. ), $atts, 'frame' ); 
  179. su_query_asset( 'css', 'su-content-shortcodes' ); 
  180. su_query_asset( 'js', 'su-other-shortcodes' ); 
  181. return '<span class="su-frame su-frame-align-' . $atts['align'] . ' su-frame-style-' . $atts['style'] . su_ecssc( $atts ) . '"><span class="su-frame-inner">' . do_shortcode( $content ) . '</span></span>'; 
  182.  
  183. public static function row( $atts = null, $content = null ) { 
  184. $atts = shortcode_atts( array( 'class' => '' ), $atts ); 
  185. return '<div class="su-row' . su_ecssc( $atts ) . '">' . su_do_shortcode( $content, 'r' ) . '</div>'; 
  186.  
  187. public static function column( $atts = null, $content = null ) { 
  188. $atts = shortcode_atts( array( 
  189. 'size' => '1/2',  
  190. 'center' => 'no',  
  191. 'last' => null,  
  192. 'class' => '' 
  193. ), $atts, 'column' ); 
  194. if ( $atts['last'] !== null && $atts['last'] == '1' ) $atts['class'] .= ' su-column-last'; 
  195. if ( $atts['center'] === 'yes' ) $atts['class'] .= ' su-column-centered'; 
  196. su_query_asset( 'css', 'su-box-shortcodes' ); 
  197. return '<div class="su-column su-column-size-' . str_replace( '/', '-', $atts['size'] ) . su_ecssc( $atts ) . '"><div class="su-column-inner su-clearfix">' . su_do_shortcode( $content, 'c' ) . '</div></div>'; 
  198.  
  199. public static function su_list( $atts = null, $content = null ) { 
  200. $atts = shortcode_atts( array( 
  201. 'icon' => 'icon: star',  
  202. 'icon_color' => '#333',  
  203. 'style' => null,  
  204. 'class' => '' 
  205. ), $atts, 'list' ); 
  206. // Backward compatibility // 4.2.3+ 
  207. if ( $atts['style'] !== null ) { 
  208. switch ( $atts['style'] ) { 
  209. case 'star': 
  210. $atts['icon'] = 'icon: star'; 
  211. $atts['icon_color'] = '#ffd647'; 
  212. break; 
  213. case 'arrow': 
  214. $atts['icon'] = 'icon: arrow-right'; 
  215. $atts['icon_color'] = '#00d1ce'; 
  216. break; 
  217. case 'check': 
  218. $atts['icon'] = 'icon: check'; 
  219. $atts['icon_color'] = '#17bf20'; 
  220. break; 
  221. case 'cross': 
  222. $atts['icon'] = 'icon: remove'; 
  223. $atts['icon_color'] = '#ff142b'; 
  224. break; 
  225. case 'thumbs': 
  226. $atts['icon'] = 'icon: thumbs-o-up'; 
  227. $atts['icon_color'] = '#8a8a8a'; 
  228. break; 
  229. case 'link': 
  230. $atts['icon'] = 'icon: external-link'; 
  231. $atts['icon_color'] = '#5c5c5c'; 
  232. break; 
  233. case 'gear': 
  234. $atts['icon'] = 'icon: cog'; 
  235. $atts['icon_color'] = '#ccc'; 
  236. break; 
  237. case 'time': 
  238. $atts['icon'] = 'icon: time'; 
  239. $atts['icon_color'] = '#a8a8a8'; 
  240. break; 
  241. case 'note': 
  242. $atts['icon'] = 'icon: edit'; 
  243. $atts['icon_color'] = '#f7d02c'; 
  244. break; 
  245. case 'plus': 
  246. $atts['icon'] = 'icon: plus-sign'; 
  247. $atts['icon_color'] = '#61dc3c'; 
  248. break; 
  249. case 'guard': 
  250. $atts['icon'] = 'icon: shield'; 
  251. $atts['icon_color'] = '#1bbe08'; 
  252. break; 
  253. case 'event': 
  254. $atts['icon'] = 'icon: bullhorn'; 
  255. $atts['icon_color'] = '#ff4c42'; 
  256. break; 
  257. case 'idea': 
  258. $atts['icon'] = 'icon: sun'; 
  259. $atts['icon_color'] = '#ffd880'; 
  260. break; 
  261. case 'settings': 
  262. $atts['icon'] = 'icon: cogs'; 
  263. $atts['icon_color'] = '#8a8a8a'; 
  264. break; 
  265. case 'twitter': 
  266. $atts['icon'] = 'icon: twitter-sign'; 
  267. $atts['icon_color'] = '#00ced6'; 
  268. break; 
  269. if ( strpos( $atts['icon'], 'icon:' ) !== false ) { 
  270. $atts['icon'] = '<i class="fa fa-' . trim( str_replace( 'icon:', '', $atts['icon'] ) ) . '" style="color:' . $atts['icon_color'] . '"></i>'; 
  271. su_query_asset( 'css', 'font-awesome' ); 
  272. else $atts['icon'] = '<img src="' . $atts['icon'] . '" alt="" />'; 
  273. su_query_asset( 'css', 'su-content-shortcodes' ); 
  274. return '<div class="su-list su-list-style-' . $atts['style'] . su_ecssc( $atts ) . '">' . str_replace( '<li>', '<li>' . $atts['icon'] . ' ', su_do_shortcode( $content, 'l' ) ) . '</div>'; 
  275.  
  276. public static function button( $atts = null, $content = null ) { 
  277. $atts = shortcode_atts( array( 
  278. 'url' => get_option( 'home' ),  
  279. 'link' => null, // 3.x 
  280. 'target' => 'self',  
  281. 'style' => 'default',  
  282. 'background' => '#2D89EF',  
  283. 'color' => '#FFFFFF',  
  284. 'dark' => null, // 3.x 
  285. 'size' => 3,  
  286. 'wide' => 'no',  
  287. 'center' => 'no',  
  288. 'radius' => 'auto',  
  289. 'icon' => false,  
  290. 'icon_color' => '#FFFFFF',  
  291. 'ts_color' => null, // Dep. 4.3.2 
  292. 'ts_pos' => null, // Dep. 4.3.2 
  293. 'text_shadow' => 'none',  
  294. 'desc' => '',  
  295. 'onclick' => '',  
  296. 'rel' => '',  
  297. 'class' => '' 
  298. ), $atts, 'button' ); 
  299.  
  300. if ( $atts['link'] !== null ) $atts['url'] = $atts['link']; 
  301. if ( $atts['dark'] !== null ) { 
  302. $atts['background'] = $atts['color']; 
  303. $atts['color'] = ( $atts['dark'] ) ? '#000' : '#fff'; 
  304. if ( is_numeric( $atts['style'] ) ) $atts['style'] = str_replace( array( '1', '2', '3', '4', '5' ), array( 'default', 'glass', 'bubbles', 'noise', 'stroked' ), $atts['style'] ); // 3.x 
  305. // Prepare vars 
  306. $a_css = array(); 
  307. $span_css = array(); 
  308. $img_css = array(); 
  309. $small_css = array(); 
  310. $radius = '0px'; 
  311. $before = $after = ''; 
  312. // Text shadow values 
  313. $shadows = array( 
  314. 'none' => '0 0',  
  315. 'top' => '0 -1px',  
  316. 'right' => '1px 0',  
  317. 'bottom' => '0 1px',  
  318. 'left' => '-1px 0',  
  319. 'top-right' => '1px -1px',  
  320. 'top-left' => '-1px -1px',  
  321. 'bottom-right' => '1px 1px',  
  322. 'bottom-left' => '-1px 1px' 
  323. ); 
  324. // Common styles for button 
  325. $styles = array( 
  326. 'size' => round( ( $atts['size'] + 7 ) * 1.3 ),  
  327. 'ts_color' => ( $atts['ts_color'] === 'light' ) ? su_hex_shift( $atts['background'], 'lighter', 50 ) : su_hex_shift( $atts['background'], 'darker', 40 ),  
  328. 'ts_pos' => ( $atts['ts_pos'] !== null ) ? $shadows[$atts['ts_pos']] : $shadows['none'] 
  329. ); 
  330. // Calculate border-radius 
  331. if ( $atts['radius'] == 'auto' ) $radius = round( $atts['size'] + 2 ) . 'px'; 
  332. elseif ( $atts['radius'] == 'round' ) $radius = round( ( ( $atts['size'] * 2 ) + 2 ) * 2 + $styles['size'] ) . 'px'; 
  333. elseif ( is_numeric( $atts['radius'] ) ) $radius = intval( $atts['radius'] ) . 'px'; 
  334. // CSS rules for <a> tag 
  335. $a_rules = array( 
  336. 'color' => $atts['color'],  
  337. 'background-color' => $atts['background'],  
  338. 'border-color' => su_hex_shift( $atts['background'], 'darker', 20 ),  
  339. 'border-radius' => $radius,  
  340. '-moz-border-radius' => $radius,  
  341. '-webkit-border-radius' => $radius 
  342. ); 
  343. // CSS rules for <span> tag 
  344. $span_rules = array( 
  345. 'color' => $atts['color'],  
  346. 'padding' => ( $atts['icon'] ) ? round( ( $atts['size'] ) / 2 + 4 ) . 'px ' . round( $atts['size'] * 2 + 10 ) . 'px' : '0px ' . round( $atts['size'] * 2 + 10 ) . 'px',  
  347. 'font-size' => $styles['size'] . 'px',  
  348. 'line-height' => ( $atts['icon'] ) ? round( $styles['size'] * 1.5 ) . 'px' : round( $styles['size'] * 2 ) . 'px',  
  349. 'border-color' => su_hex_shift( $atts['background'], 'lighter', 30 ),  
  350. 'border-radius' => $radius,  
  351. '-moz-border-radius' => $radius,  
  352. '-webkit-border-radius' => $radius,  
  353. 'text-shadow' => $styles['ts_pos'] . ' 1px ' . $styles['ts_color'],  
  354. '-moz-text-shadow' => $styles['ts_pos'] . ' 1px ' . $styles['ts_color'],  
  355. '-webkit-text-shadow' => $styles['ts_pos'] . ' 1px ' . $styles['ts_color'] 
  356. ); 
  357. // Apply new text-shadow value 
  358. if ( $atts['ts_color'] === null && $atts['ts_pos'] === null ) { 
  359. $span_rules['text-shadow'] = $atts['text_shadow']; 
  360. $span_rules['-moz-text-shadow'] = $atts['text_shadow']; 
  361. $span_rules['-webkit-text-shadow'] = $atts['text_shadow']; 
  362. // CSS rules for <img> tag 
  363. $img_rules = array( 
  364. 'width' => round( $styles['size'] * 1.5 ) . 'px',  
  365. 'height' => round( $styles['size'] * 1.5 ) . 'px' 
  366. ); 
  367. // CSS rules for <small> tag 
  368. $small_rules = array( 
  369. 'padding-bottom' => round( ( $atts['size'] ) / 2 + 4 ) . 'px',  
  370. 'color' => $atts['color'] 
  371. ); 
  372. // Create style attr value for <a> tag 
  373. foreach ( $a_rules as $a_rule => $a_value ) $a_css[] = $a_rule . ':' . $a_value; 
  374. // Create style attr value for <span> tag 
  375. foreach ( $span_rules as $span_rule => $span_value ) $span_css[] = $span_rule . ':' . $span_value; 
  376. // Create style attr value for <img> tag 
  377. foreach ( $img_rules as $img_rule => $img_value ) $img_css[] = $img_rule . ':' . $img_value; 
  378. // Create style attr value for <img> tag 
  379. foreach ( $small_rules as $small_rule => $small_value ) $small_css[] = $small_rule . ':' . $small_value; 
  380. // Prepare button classes 
  381. $classes = array( 'su-button', 'su-button-style-' . $atts['style'] ); 
  382. // Additional classes 
  383. if ( $atts['class'] ) $classes[] = $atts['class']; 
  384. // Wide class 
  385. if ( $atts['wide'] === 'yes' ) $classes[] = 'su-button-wide'; 
  386. // Prepare icon 
  387. if ( $atts['icon'] ) { 
  388. if ( strpos( $atts['icon'], 'icon:' ) !== false ) { 
  389. $icon = '<i class="fa fa-' . trim( str_replace( 'icon:', '', $atts['icon'] ) ) . '" style="font-size:' . $styles['size'] . 'px;color:' . $atts['icon_color'] . '"></i>'; 
  390. su_query_asset( 'css', 'font-awesome' ); 
  391. else $icon = '<img src="' . $atts['icon'] . '" alt="' . esc_attr( $content ) . '" style="' . implode( $img_css, ';' ) . '" />'; 
  392. else $icon = ''; 
  393. // Prepare <small> with description 
  394. $desc = ( $atts['desc'] ) ? '<small style="' . implode( $small_css, ';' ) . '">' . su_scattr( $atts['desc'] ) . '</small>' : ''; 
  395. // Wrap with div if button centered 
  396. if ( $atts['center'] === 'yes' ) { 
  397. $before .= '<div class="su-button-center">'; 
  398. $after .= '</div>'; 
  399. // Replace icon marker in content,  
  400. // add float-icon class to rearrange margins 
  401. if ( strpos( $content, '%icon%' ) !== false ) { 
  402. $content = str_replace( '%icon%', $icon, $content ); 
  403. $classes[] = 'su-button-float-icon'; 
  404. // Button text has no icon marker, append icon to begin of the text 
  405. else $content = $icon . ' ' . $content; 
  406. // Prepare onclick action 
  407. $atts['onclick'] = ( $atts['onclick'] ) ? ' onClick="' . $atts['onclick'] . '"' : ''; 
  408. // Prepare rel attribute 
  409. $atts['rel'] = ( $atts['rel'] ) ? ' rel="' . $atts['rel'] . '"' : ''; 
  410. su_query_asset( 'css', 'su-content-shortcodes' ); 
  411. return $before . '<a href="' . su_scattr( $atts['url'] ) . '" class="' . implode( $classes, ' ' ) . '" style="' . implode( $a_css, ';' ) . '" target="_' . $atts['target'] . '"' . $atts['onclick'] . $atts['rel'] . '><span style="' . implode( $span_css, ';' ) . '">' . do_shortcode( $content ) . $desc . '</span></a>' . $after; 
  412.  
  413. public static function service( $atts = null, $content = null ) { 
  414. $atts = shortcode_atts( array( 
  415. 'title' => __( 'Service title', 'su' ),  
  416. 'icon' => plugins_url( 'assets/images/service.png', SU_PLUGIN_FILE ),  
  417. 'icon_color' => '#333',  
  418. 'size' => 32,  
  419. 'class' => '' 
  420. ), $atts, 'service' ); 
  421. // RTL 
  422. $rtl = ( is_rtl() ) ? 'right' : 'left'; 
  423. // Built-in icon 
  424. if ( strpos( $atts['icon'], 'icon:' ) !== false ) { 
  425. $atts['icon'] = '<i class="fa fa-' . trim( str_replace( 'icon:', '', $atts['icon'] ) ) . '" style="font-size:' . $atts['size'] . 'px;color:' . $atts['icon_color'] . '"></i>'; 
  426. su_query_asset( 'css', 'font-awesome' ); 
  427. // Uploaded icon 
  428. else { 
  429. $atts['icon'] = '<img src="' . $atts['icon'] . '" width="' . $atts['size'] . '" height="' . $atts['size'] . '" alt="' . $atts['title'] . '" />'; 
  430. su_query_asset( 'css', 'su-box-shortcodes' ); 
  431. return '<div class="su-service' . su_ecssc( $atts ) . '"><div class="su-service-title" style="padding-' . $rtl . ':' . round( $atts['size'] + 14 ) . 'px;min-height:' . $atts['size'] . 'px;line-height:' . $atts['size'] . 'px">' . $atts['icon'] . ' ' . su_scattr( $atts['title'] ) . '</div><div class="su-service-content su-clearfix" style="padding-' . $rtl . ':' . round( $atts['size'] + 14 ) . 'px">' . do_shortcode( $content ) . '</div></div>'; 
  432.  
  433. public static function box( $atts = null, $content = null ) { 
  434. $atts = shortcode_atts( array( 
  435. 'title' => __( 'This is box title', 'su' ),  
  436. 'style' => 'default',  
  437. 'box_color' => '#333333',  
  438. 'title_color' => '#FFFFFF',  
  439. 'color' => null, // 3.x 
  440. 'radius' => '3',  
  441. 'class' => '' 
  442. ), $atts, 'box' ); 
  443. if ( $atts['color'] !== null ) $atts['box_color'] = $atts['color']; 
  444. // Prepare border-radius 
  445. $radius = ( $atts['radius'] != '0' ) ? 'border-radius:' . $atts['radius'] . 'px;-moz-border-radius:' . $atts['radius'] . 'px;-webkit-border-radius:' . $atts['radius'] . 'px;' : ''; 
  446. $title_radius = ( $atts['radius'] != '0' ) ? $atts['radius'] - 1 : ''; 
  447. $title_radius = ( $title_radius ) ? '-webkit-border-top-left-radius:' . $title_radius . 'px;-webkit-border-top-right-radius:' . $title_radius . 'px;-moz-border-radius-topleft:' . $title_radius . 'px;-moz-border-radius-topright:' . $title_radius . 'px;border-top-left-radius:' . $title_radius . 'px;border-top-right-radius:' . $title_radius . 'px;' : ''; 
  448. su_query_asset( 'css', 'su-box-shortcodes' ); 
  449. // Return result 
  450. return '<div class="su-box su-box-style-' . $atts['style'] . su_ecssc( $atts ) . '" style="border-color:' . su_hex_shift( $atts['box_color'], 'darker', 20 ) . ';' . $radius . '"><div class="su-box-title" style="background-color:' . $atts['box_color'] . ';color:' . $atts['title_color'] . ';' . $title_radius . '">' . su_scattr( $atts['title'] ) . '</div><div class="su-box-content su-clearfix">' . su_do_shortcode( $content, 'b' ) . '</div></div>'; 
  451.  
  452. public static function note( $atts = null, $content = null ) { 
  453. $atts = shortcode_atts( array( 
  454. 'note_color' => '#FFFF66',  
  455. 'text_color' => '#333333',  
  456. 'background' => null, // 3.x 
  457. 'color' => null, // 3.x 
  458. 'radius' => '3',  
  459. 'class' => '' 
  460. ), $atts, 'note' ); 
  461. if ( $atts['color'] !== null ) $atts['note_color'] = $atts['color']; 
  462. if ( $atts['background'] !== null ) $atts['note_color'] = $atts['background']; 
  463. // Prepare border-radius 
  464. $radius = ( $atts['radius'] != '0' ) ? 'border-radius:' . $atts['radius'] . 'px;-moz-border-radius:' . $atts['radius'] . 'px;-webkit-border-radius:' . $atts['radius'] . 'px;' : ''; 
  465. su_query_asset( 'css', 'su-box-shortcodes' ); 
  466. return '<div class="su-note' . su_ecssc( $atts ) . '" style="border-color:' . su_hex_shift( $atts['note_color'], 'darker', 10 ) . ';' . $radius . '"><div class="su-note-inner su-clearfix" style="background-color:' . $atts['note_color'] . ';border-color:' . su_hex_shift( $atts['note_color'], 'lighter', 80 ) . ';color:' . $atts['text_color'] . ';' . $radius . '">' . su_do_shortcode( $content, 'n' ) . '</div></div>'; 
  467.  
  468. public static function expand( $atts = null, $content = null ) { 
  469. $atts = shortcode_atts( array( 
  470. 'more_text' => __( 'Show more', 'su' ),  
  471. 'less_text' => __( 'Show less', 'su' ),  
  472. 'height' => '100',  
  473. 'hide_less' => 'no',  
  474. 'text_color' => '#333333',  
  475. 'link_color' => '#0088FF',  
  476. 'link_style' => 'default',  
  477. 'link_align' => 'left',  
  478. 'more_icon' => '',  
  479. 'less_icon' => '',  
  480. 'class' => '' 
  481. ), $atts, 'expand' ); 
  482. // Prepare more icon 
  483. $more_icon = ( $atts['more_icon'] ) ? Su_Tools::icon( $atts['more_icon'] ) : ''; 
  484. $less_icon = ( $atts['less_icon'] ) ? Su_Tools::icon( $atts['less_icon'] ) : ''; 
  485. if ( $more_icon || $less_icon ) su_query_asset( 'css', 'font-awesome' ); 
  486. // Prepare less link 
  487. $less = ( $atts['hide_less'] !== 'yes' ) ? '<div class="su-expand-link su-expand-link-less" style="text-align:' . $atts['link_align'] . '"><a href="javascript:;" style="color:' . $atts['link_color'] . ';border-color:' . $atts['link_color'] . '">' . $less_icon . '<span style="border-color:' . $atts['link_color'] . '">' . $atts['less_text'] . '</span></a></div>' : ''; 
  488. su_query_asset( 'css', 'su-box-shortcodes' ); 
  489. su_query_asset( 'js', 'su-other-shortcodes' ); 
  490. return '<div class="su-expand su-expand-collapsed su-expand-link-style-' . $atts['link_style'] . su_ecssc( $atts ) . '" data-height="' . $atts['height'] . '"><div class="su-expand-content" style="color:' . $atts['text_color'] . ';max-height:' . intval( $atts['height'] ) . 'px;overflow:hidden">' . do_shortcode( $content ) . '</div><div class="su-expand-link su-expand-link-more" style="text-align:' . $atts['link_align'] . '"><a href="javascript:;" style="color:' . $atts['link_color'] . ';border-color:' . $atts['link_color'] . '">' . $more_icon . '<span style="border-color:' . $atts['link_color'] . '">' . $atts['more_text'] . '</span></a></div>' . $less . '</div>'; 
  491.  
  492. public static function lightbox( $atts = null, $content = null ) { 
  493. $atts = shortcode_atts( array( 
  494. 'src' => false,  
  495. 'type' => 'iframe',  
  496. 'class' => '' 
  497. ), $atts, 'lightbox' ); 
  498. if ( !$atts['src'] ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct source', 'su' ) ); 
  499. su_query_asset( 'css', 'magnific-popup' ); 
  500. su_query_asset( 'js', 'jquery' ); 
  501. su_query_asset( 'js', 'magnific-popup' ); 
  502. su_query_asset( 'js', 'su-other-shortcodes' ); 
  503. return '<span class="su-lightbox' . su_ecssc( $atts ) . '" data-mfp-src="' . su_scattr( $atts['src'] ) . '" data-mfp-type="' . $atts['type'] . '">' . do_shortcode( $content ) . '</span>'; 
  504.  
  505. public static function lightbox_content( $atts = null, $content = null ) { 
  506. $atts = shortcode_atts( array( 
  507. 'id' => '',  
  508. 'width' => '50%',  
  509. 'margin' => '40',  
  510. 'padding' => '40',  
  511. 'text_align' => 'center',  
  512. 'background' => '#FFFFFF',  
  513. 'color' => '#333333',  
  514. 'shadow' => '0px 0px 15px #333333',  
  515. 'class' => '' 
  516. ), $atts, 'lightbox_content' ); 
  517. su_query_asset( 'css', 'su-box-shortcodes' ); 
  518. if ( !$atts['id'] ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct ID for this block. You should use same ID as in the Content source field (when inserting lightbox shortcode)', 'su' ) ); 
  519. $return = '<div class="su-lightbox-content ' . su_ecssc( $atts ) . '" id="' . trim( $atts['id'], '#' ) . '" style="display:none;width:' . $atts['width'] . ';margin-top:' . $atts['margin'] . 'px;margin-bottom:' . $atts['margin'] . 'px;padding:' . $atts['padding'] . 'px;background-color:' . $atts['background'] . ';color:' . $atts['color'] . ';box-shadow:' . $atts['shadow'] . ';text-align:' . $atts['text_align'] . '">' . do_shortcode( $content ) . '</div>'; 
  520. if ( did_action( 'su/generator/preview/before' ) ) return '<div class="su-lightbox-content-preview">' . $return . '</div>'; 
  521. else return $return; 
  522.  
  523. public static function tooltip( $atts = null, $content = null ) { 
  524. $atts = shortcode_atts( array( 
  525. 'style' => 'yellow',  
  526. 'position' => 'north',  
  527. 'shadow' => 'no',  
  528. 'rounded' => 'no',  
  529. 'size' => 'default',  
  530. 'title' => '',  
  531. 'content' => __( 'Tooltip text', 'su' ),  
  532. 'behavior' => 'hover',  
  533. 'close' => 'no',  
  534. 'class' => '' 
  535. ), $atts, 'tooltip' ); 
  536. // Prepare style 
  537. $atts['style'] = ( in_array( $atts['style'], array( 'light', 'dark', 'green', 'red', 'blue', 'youtube', 'tipsy', 'bootstrap', 'jtools', 'tipped', 'cluetip' ) ) ) ? $atts['style'] : 'plain'; 
  538. // Position 
  539. $atts['position'] = str_replace( array( 'top', 'right', 'bottom', 'left' ), array( 'north', 'east', 'south', 'west' ), $atts['position'] ); 
  540. $position = array( 
  541. 'my' => str_replace( array( 'north', 'east', 'south', 'west' ), array( 'bottom center', 'center left', 'top center', 'center right' ), $atts['position'] ),  
  542. 'at' => str_replace( array( 'north', 'east', 'south', 'west' ), array( 'top center', 'center right', 'bottom center', 'center left' ), $atts['position'] ) 
  543. ); 
  544. // Prepare classes 
  545. $classes = array( 'su-qtip qtip-' . $atts['style'] ); 
  546. $classes[] = 'su-qtip-size-' . $atts['size']; 
  547. if ( $atts['shadow'] === 'yes' ) $classes[] = 'qtip-shadow'; 
  548. if ( $atts['rounded'] === 'yes' ) $classes[] = 'qtip-rounded'; 
  549. // Query assets 
  550. su_query_asset( 'css', 'qtip' ); 
  551. su_query_asset( 'css', 'su-other-shortcodes' ); 
  552. su_query_asset( 'js', 'jquery' ); 
  553. su_query_asset( 'js', 'qtip' ); 
  554. su_query_asset( 'js', 'su-other-shortcodes' ); 
  555. return '<span class="su-tooltip' . su_ecssc( $atts ) . '" data-close="' . $atts['close'] . '" data-behavior="' . $atts['behavior'] . '" data-my="' . $position['my'] . '" data-at="' . $position['at'] . '" data-classes="' . implode( ' ', $classes ) . '" data-title="' . $atts['title'] . '" title="' . esc_attr( $atts['content'] ) . '">' . do_shortcode( $content ) . '</span>'; 
  556.  
  557. public static function su_private( $atts = null, $content = null ) { 
  558. $atts = shortcode_atts( array( 'class' => '' ), $atts, 'private' ); 
  559. su_query_asset( 'css', 'su-other-shortcodes' ); 
  560. return ( current_user_can( 'publish_posts' ) ) ? '<div class="su-private' . su_ecssc( $atts ) . '"><div class="su-private-shell">' . do_shortcode( $content ) . '</div></div>' : ''; 
  561.  
  562. public static function media( $atts = null, $content = null ) { 
  563. // Check YouTube video 
  564. if ( strpos( $atts['url'], 'youtu' ) !== false ) return Su_Shortcodes::youtube( $atts ); 
  565. // Check Vimeo video 
  566. elseif ( strpos( $atts['url'], 'vimeo' ) !== false ) return Su_Shortcodes::vimeo( $atts ); 
  567. // Image 
  568. else return '<img src="' . $atts['url'] . '" width="' . $atts['width'] . '" height="' . $atts['height'] . '" style="max-width:100%" />'; 
  569.  
  570. public static function youtube( $atts = null, $content = null ) { 
  571. // Prepare data 
  572. $return = array(); 
  573. $atts = shortcode_atts( array( 
  574. 'url' => false,  
  575. 'width' => 600,  
  576. 'height' => 400,  
  577. 'autoplay' => 'no',  
  578. 'responsive' => 'yes',  
  579. 'class' => '' 
  580. ), $atts, 'youtube' ); 
  581. if ( !$atts['url'] ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  582. $atts['url'] = su_scattr( $atts['url'] ); 
  583. $id = ( preg_match( '%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $atts['url'], $match ) ) ? $match[1] : false; 
  584. // Check that url is specified 
  585. if ( !$id ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  586. // Prepare autoplay 
  587. $autoplay = ( $atts['autoplay'] === 'yes' ) ? '?autoplay=1' : ''; 
  588. // Create player 
  589. $return[] = '<div class="su-youtube su-responsive-media-' . $atts['responsive'] . su_ecssc( $atts ) . '">'; 
  590. $return[] = '<iframe width="' . $atts['width'] . '" height="' . $atts['height'] . '" src="http://www.youtube.com/embed/' . $id . $autoplay . '" frameborder="0" allowfullscreen="true"></iframe>'; 
  591. $return[] = '</div>'; 
  592. su_query_asset( 'css', 'su-media-shortcodes' ); 
  593. // Return result 
  594. return implode( '', $return ); 
  595.  
  596. public static function youtube_advanced( $atts = null, $content = null ) { 
  597. // Prepare data 
  598. $return = array(); 
  599. $params = array(); 
  600. $atts = shortcode_atts( array( 
  601. 'url' => false,  
  602. 'width' => 600,  
  603. 'height' => 400,  
  604. 'responsive' => 'yes',  
  605. 'autohide' => 'alt',  
  606. 'autoplay' => 'no',  
  607. 'controls' => 'yes',  
  608. 'fs' => 'yes',  
  609. 'loop' => 'no',  
  610. 'modestbranding' => 'no',  
  611. 'playlist' => '',  
  612. 'rel' => 'yes',  
  613. 'showinfo' => 'yes',  
  614. 'theme' => 'dark',  
  615. 'https' => 'no',  
  616. 'wmode' => '',  
  617. 'class' => '' 
  618. ), $atts, 'youtube_advanced' ); 
  619. if ( !$atts['url'] ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  620. $atts['url'] = su_scattr( $atts['url'] ); 
  621. $id = ( preg_match( '%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $atts['url'], $match ) ) ? $match[1] : false; 
  622. // Check that url is specified 
  623. if ( !$id ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  624. // Prepare params 
  625. foreach ( array( 'autohide', 'autoplay', 'controls', 'fs', 'loop', 'modestbranding', 'playlist', 'rel', 'showinfo', 'theme', 'wmode' ) as $param ) $params[$param] = str_replace( array( 'no', 'yes', 'alt' ), array( '0', '1', '2' ), $atts[$param] ); 
  626. // Correct loop 
  627. if ( $params['loop'] === '1' && $params['playlist'] === '' ) $params['playlist'] = $id; 
  628. // Prepare protocol 
  629. $protocol = ( $atts['https'] === 'yes' ) ? 'https' : 'http'; 
  630. // Prepare player parameters 
  631. $params = http_build_query( $params ); 
  632. // Create player 
  633. $return[] = '<div class="su-youtube su-responsive-media-' . $atts['responsive'] . su_ecssc( $atts ) . '">'; 
  634. $return[] = '<iframe width="' . $atts['width'] . '" height="' . $atts['height'] . '" src="' . $protocol . '://www.youtube.com/embed/' . $id . '?' . $params . '" frameborder="0" allowfullscreen="true"></iframe>'; 
  635. $return[] = '</div>'; 
  636. su_query_asset( 'css', 'su-media-shortcodes' ); 
  637. // Return result 
  638. return implode( '', $return ); 
  639.  
  640. public static function vimeo( $atts = null, $content = null ) { 
  641. // Prepare data 
  642. $return = array(); 
  643. $atts = shortcode_atts( array( 
  644. 'url' => false,  
  645. 'width' => 600,  
  646. 'height' => 400,  
  647. 'autoplay' => 'no',  
  648. 'responsive' => 'yes',  
  649. 'class' => '' 
  650. ), $atts, 'vimeo' ); 
  651. if ( !$atts['url'] ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  652. $atts['url'] = su_scattr( $atts['url'] ); 
  653. $id = ( preg_match( '~(?:<iframe [^>]*src=")?(?:https?:\/\/(?:[\w]+\.)*vimeo\.com(?:[\/\w]*\/videos?)?\/([0-9]+)[^\s]*)"?(?:[^>]*></iframe>)?(?:<p>.*</p>)?~ix', $atts['url'], $match ) ) ? $match[1] : false; 
  654. // Check that url is specified 
  655. if ( !$id ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  656. // Prepare autoplay 
  657. $autoplay = ( $atts['autoplay'] === 'yes' ) ? '&autoplay=1' : ''; 
  658. // Create player 
  659. $return[] = '<div class="su-vimeo su-responsive-media-' . $atts['responsive'] . su_ecssc( $atts ) . '">'; 
  660. $return[] = '<iframe width="' . $atts['width'] . '" height="' . $atts['height'] . '" src="//player.vimeo.com/video/' . $id . '?title=0&byline=0&portrait=0&color=ffffff' . $autoplay . '" frameborder="0" allowfullscreen="true"></iframe>'; 
  661. $return[] = '</div>'; 
  662. su_query_asset( 'css', 'su-media-shortcodes' ); 
  663. // Return result 
  664. return implode( '', $return ); 
  665.  
  666. public static function screenr( $atts = null, $content = null ) { 
  667. // Prepare data 
  668. $return = array(); 
  669. $atts = shortcode_atts( array( 
  670. 'url' => false,  
  671. 'width' => 600,  
  672. 'height' => 400,  
  673. 'responsive' => 'yes',  
  674. 'class' => '' 
  675. ), $atts, 'screenr' ); 
  676. if ( !$atts['url'] ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  677. $atts['url'] = su_scattr( $atts['url'] ); 
  678. $id = ( preg_match( '~(?:<iframe [^>]*src=")?(?:https?:\/\/(?:[\w]+\.)*screenr\.com(?:[\/\w]*\/videos?)?\/([a-zA-Z0-9]+)[^\s]*)"?(?:[^>]*></iframe>)?(?:<p>.*</p>)?~ix', $atts['url'], $match ) ) ? $match[1] : false; 
  679. // Check that url is specified 
  680. if ( !$id ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  681. // Create player 
  682. $return[] = '<div class="su-screenr su-responsive-media-' . $atts['responsive'] . su_ecssc( $atts ) . '">'; 
  683. $return[] = '<iframe width="' . $atts['width'] . '" height="' . $atts['height'] . '" src="http://screenr.com/embed/' . $id . '" frameborder="0" allowfullscreen="true"></iframe>'; 
  684. $return[] = '</div>'; 
  685. su_query_asset( 'css', 'su-media-shortcodes' ); 
  686. // Return result 
  687. return implode( '', $return ); 
  688.  
  689. public static function dailymotion( $atts = null, $content = null ) { 
  690. // Prepare data 
  691. $return = array(); 
  692. $atts = shortcode_atts( array( 
  693. 'url' => false,  
  694. 'width' => 600,  
  695. 'height' => 400,  
  696. 'responsive' => 'yes',  
  697. 'autoplay' => 'no',  
  698. 'background' => '#FFC300',  
  699. 'foreground' => '#F7FFFD',  
  700. 'highlight' => '#171D1B',  
  701. 'logo' => 'yes',  
  702. 'quality' => '380',  
  703. 'related' => 'yes',  
  704. 'info' => 'yes',  
  705. 'class' => '' 
  706. ), $atts, 'dailymotion' ); 
  707. if ( !$atts['url'] ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  708. $atts['url'] = su_scattr( $atts['url'] ); 
  709. $id = strtok( basename( $atts['url'] ), '_' ); 
  710. // Check that url is specified 
  711. if ( !$id ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  712. // Prepare params 
  713. $params = array(); 
  714. foreach ( array( 'autoplay', 'background', 'foreground', 'highlight', 'logo', 'quality', 'related', 'info' ) as $param ) 
  715. $params[] = $param . '=' . str_replace( array( 'yes', 'no', '#' ), array( '1', '0', '' ), $atts[$param] ); 
  716. // Create player 
  717. $return[] = '<div class="su-dailymotion su-responsive-media-' . $atts['responsive'] . su_ecssc( $atts ) . '">'; 
  718. $return[] = '<iframe width="' . $atts['width'] . '" height="' . $atts['height'] . '" src="http://www.dailymotion.com/embed/video/' . $id . '?' . implode( '&', $params ) . '" frameborder="0" allowfullscreen="true"></iframe>'; 
  719. $return[] = '</div>'; 
  720. su_query_asset( 'css', 'su-media-shortcodes' ); 
  721. // Return result 
  722. return implode( '', $return ); 
  723.  
  724. public static function audio( $atts = null, $content = null ) { 
  725. $atts = shortcode_atts( array( 
  726. 'url' => false,  
  727. 'width' => 'auto',  
  728. 'title' => '',  
  729. 'autoplay' => 'no',  
  730. 'loop' => 'no',  
  731. 'class' => '' 
  732. ), $atts, 'audio' ); 
  733. if ( !$atts['url'] ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  734. $atts['url'] = su_scattr( $atts['url'] ); 
  735. // Generate unique ID 
  736. $id = uniqid( 'su_audio_player_' ); 
  737. // Prepare width 
  738. $width = ( $atts['width'] !== 'auto' ) ? 'max-width:' . $atts['width'] : ''; 
  739. // Check that url is specified 
  740. if ( !$atts['url'] ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  741. su_query_asset( 'css', 'su-players-shortcodes' ); 
  742. su_query_asset( 'js', 'jquery' ); 
  743. su_query_asset( 'js', 'jplayer' ); 
  744. su_query_asset( 'js', 'su-players-shortcodes' ); 
  745. su_query_asset( 'js', 'su-players-shortcodes' ); 
  746. // Create player 
  747. return '<div class="su-audio' . su_ecssc( $atts ) . '" data-id="' . $id . '" data-audio="' . $atts['url'] . '" data-swf="' . plugins_url( 'assets/other/Jplayer.swf', SU_PLUGIN_FILE ) . '" data-autoplay="' . $atts['autoplay'] . '" data-loop="' . $atts['loop'] . '" style="' . $width . '"><div id="' . $id . '" class="jp-jplayer"></div><div id="' . $id . '_container" class="jp-audio"><div class="jp-type-single"><div class="jp-gui jp-interface"><div class="jp-controls"><span class="jp-play"></span><span class="jp-pause"></span><span class="jp-stop"></span><span class="jp-mute"></span><span class="jp-unmute"></span><span class="jp-volume-max"></span></div><div class="jp-progress"><div class="jp-seek-bar"><div class="jp-play-bar"></div></div></div><div class="jp-volume-bar"><div class="jp-volume-bar-value"></div></div><div class="jp-current-time"></div><div class="jp-duration"></div></div><div class="jp-title">' . $atts['title'] . '</div></div></div></div>'; 
  748.  
  749. public static function video( $atts = null, $content = null ) { 
  750. $atts = shortcode_atts( array( 
  751. 'url' => false,  
  752. 'poster' => false,  
  753. 'title' => '',  
  754. 'width' => 600,  
  755. 'height' => 300,  
  756. 'controls' => 'yes',  
  757. 'autoplay' => 'no',  
  758. 'loop' => 'no',  
  759. 'class' => '' 
  760. ), $atts, 'video' ); 
  761. if ( !$atts['url'] ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  762. $atts['url'] = su_scattr( $atts['url'] ); 
  763. // Generate unique ID 
  764. $id = uniqid( 'su_video_player_' ); 
  765. // Check that url is specified 
  766. if ( !$atts['url'] ) return Su_Tools::error( __FUNCTION__, __( 'please specify correct url', 'su' ) ); 
  767. // Prepare title 
  768. $title = ( $atts['title'] ) ? '<div class="jp-title">' . $atts['title'] . '</div>' : ''; 
  769. su_query_asset( 'css', 'su-players-shortcodes' ); 
  770. su_query_asset( 'js', 'jquery' ); 
  771. su_query_asset( 'js', 'jplayer' ); 
  772. su_query_asset( 'js', 'su-players-shortcodes' ); 
  773. // Create player 
  774. return '<div style="width:' . $atts['width'] . 'px"><div id="' . $id . '" class="su-video jp-video su-video-controls-' . $atts['controls'] . su_ecssc( $atts ) . '" data-id="' . $id . '" data-video="' . $atts['url'] . '" data-swf="' . plugins_url( 'assets/other/Jplayer.swf', SU_PLUGIN_FILE ) . '" data-autoplay="' . $atts['autoplay'] . '" data-loop="' . $atts['loop'] . '" data-poster="' . $atts['poster'] . '"><div id="' . $id . '_player" class="jp-jplayer" style="width:' . $atts['width'] . 'px;height:' . $atts['height'] . 'px"></div>' . $title . '<div class="jp-start jp-play"></div><div class="jp-gui"><div class="jp-interface"><div class="jp-progress"><div class="jp-seek-bar"><div class="jp-play-bar"></div></div></div><div class="jp-current-time"></div><div class="jp-duration"></div><div class="jp-controls-holder"><span class="jp-play"></span><span class="jp-pause"></span><span class="jp-mute"></span><span class="jp-unmute"></span><span class="jp-full-screen"></span><span class="jp-restore-screen"></span><div class="jp-volume-bar"><div class="jp-volume-bar-value"></div></div></div></div></div></div></div>'; 
  775.  
  776. public static function table( $atts = null, $content = null ) { 
  777. $atts = shortcode_atts( array( 
  778. 'url' => false,  
  779. 'class' => '' 
  780. ), $atts, 'table' ); 
  781. $return = '<div class="su-table' . su_ecssc( $atts ) . '">'; 
  782. $return .= ( $atts['url'] ) ? su_parse_csv( $atts['url'] ) : do_shortcode( $content ); 
  783. $return .= '</div>'; 
  784. su_query_asset( 'css', 'su-content-shortcodes' ); 
  785. su_query_asset( 'js', 'jquery' ); 
  786. su_query_asset( 'js', 'su-other-shortcodes' ); 
  787. return $return; 
  788.  
  789. public static function permalink( $atts = null, $content = null ) { 
  790. $atts = shortcode_atts( array( 
  791. 'id' => 1,  
  792. 'p' => null, // 3.x 
  793. 'target' => 'self',  
  794. 'class' => '' 
  795. ), $atts, 'permalink' ); 
  796. if ( $atts['p'] !== null ) $atts['id'] = $atts['p']; 
  797. $atts['id'] = su_scattr( $atts['id'] ); 
  798. // Prepare link text 
  799. $text = ( $content ) ? $content : get_the_title( $atts['id'] ); 
  800. return '<a href="' . get_permalink( $atts['id'] ) . '" class="' . su_ecssc( $atts ) . '" title="' . $text . '" target="_' . $atts['target'] . '">' . $text . '</a>'; 
  801.  
  802. public static function members( $atts = null, $content = null ) { 
  803. $atts = shortcode_atts( array( 
  804. 'message' => __( 'This content is for registered users only. Please %login%.', 'su' ),  
  805. 'color' => '#ffcc00',  
  806. 'style' => null, // 3.x 
  807. 'login_text' => __( 'login', 'su' ),  
  808. 'login_url' => wp_login_url(),  
  809. 'login' => null, // 3.x 
  810. 'class' => '' 
  811. ), $atts, 'members' ); 
  812. if ( $atts['style'] !== null ) $atts['color'] = str_replace( array( '0', '1', '2' ), array( '#fff', '#FFFF29', '#1F9AFF' ), $atts['style'] ); 
  813. // Check feed 
  814. if ( is_feed() ) return; 
  815. // Check authorization 
  816. if ( !is_user_logged_in() ) { 
  817. if ( $atts['login'] !== null && $atts['login'] == '0' ) return; // 3.x 
  818. // Prepare login link 
  819. $login = '<a href="' . esc_attr( $atts['login_url'] ) . '">' . $atts['login_text'] . '</a>'; 
  820. su_query_asset( 'css', 'su-other-shortcodes' ); 
  821. return '<div class="su-members' . su_ecssc( $atts ) . '" style="background-color:' . su_hex_shift( $atts['color'], 'lighter', 50 ) . ';border-color:' .su_hex_shift( $atts['color'], 'darker', 20 ) . ';color:' .su_hex_shift( $atts['color'], 'darker', 60 ) . '">' . str_replace( '%login%', $login, su_scattr( $atts['message'] ) ) . '</div>'; 
  822. // Return original content 
  823. else return do_shortcode( $content ); 
  824.  
  825. public static function guests( $atts = null, $content = null ) { 
  826. $atts = shortcode_atts( array( 'class' => '' ), $atts, 'guests' ); 
  827. $return = ''; 
  828. if ( !is_user_logged_in() && !is_null( $content ) ) { 
  829. su_query_asset( 'css', 'su-other-shortcodes' ); 
  830. $return = '<div class="su-guests' . su_ecssc( $atts ) . '">' . do_shortcode( $content ) . '</div>'; 
  831. return $return; 
  832.  
  833. public static function feed( $atts = null, $content = null ) { 
  834. $atts = shortcode_atts( array( 
  835. 'url' => get_bloginfo_rss( 'rss2_url' ),  
  836. 'limit' => 3,  
  837. 'class' => '' 
  838. ), $atts, 'feed' ); 
  839. if ( !function_exists( 'wp_rss' ) ) include_once ABSPATH . WPINC . '/rss.php'; 
  840. ob_start(); 
  841. echo '<div class="su-feed' . su_ecssc( $atts ) . '">'; 
  842. wp_rss( $atts['url'], $atts['limit'] ); 
  843. echo '</div>'; 
  844. $return = ob_get_contents(); 
  845. ob_end_clean(); 
  846. return $return; 
  847.  
  848. public static function subpages( $atts = null, $content = null ) { 
  849. $atts = shortcode_atts( array( 
  850. 'depth' => 1,  
  851. 'p' => false,  
  852. 'class' => '' 
  853. ), $atts, 'subpages' ); 
  854. global $post; 
  855. $child_of = ( $atts['p'] ) ? $atts['p'] : get_the_ID(); 
  856. $return = wp_list_pages( array( 
  857. 'title_li' => '',  
  858. 'echo' => 0,  
  859. 'child_of' => $child_of,  
  860. 'depth' => $atts['depth'] 
  861. ) ); 
  862. return ( $return ) ? '<ul class="su-subpages' . su_ecssc( $atts ) . '">' . $return . '</ul>' : false; 
  863.  
  864. public static function siblings( $atts = null, $content = null ) { 
  865. $atts = shortcode_atts( array( 'depth' => 1, 'class' => '' ), $atts, 'siblings' ); 
  866. global $post; 
  867. $return = wp_list_pages( array( 'title_li' => '',  
  868. 'echo' => 0,  
  869. 'child_of' => $post->post_parent,  
  870. 'depth' => $atts['depth'],  
  871. 'exclude' => $post->ID ) ); 
  872. return ( $return ) ? '<ul class="su-siblings' . su_ecssc( $atts ) . '">' . $return . '</ul>' : false; 
  873.  
  874. public static function menu( $atts = null, $content = null ) { 
  875. $atts = shortcode_atts( array( 
  876. 'name' => false,  
  877. 'class' => '' 
  878. ), $atts, 'menu' ); 
  879. $return = wp_nav_menu( array( 
  880. 'echo' => false,  
  881. 'menu' => $atts['name'],  
  882. 'container' => false,  
  883. 'fallback_cb' => array( __CLASS__, 'menu_fb' ),  
  884. 'items_wrap' => '<ul id="%1$s" class="%2$s' . su_ecssc( $atts ) . '">%3$s</ul>' 
  885. ) ); 
  886. return ( $atts['name'] ) ? $return : false; 
  887.  
  888. public static function menu_fb() { 
  889. return __( 'This menu doesn\'t exists, or has no elements', 'su' ); 
  890.  
  891. public static function document( $atts = null, $content = null ) { 
  892. $atts = shortcode_atts( array( 
  893. 'url' => '',  
  894. 'file' => null, // 3.x 
  895. 'width' => 600,  
  896. 'height' => 400,  
  897. 'responsive' => 'yes',  
  898. 'class' => '' 
  899. ), $atts, 'document' ); 
  900. if ( $atts['file'] !== null ) $atts['url'] = $atts['file']; 
  901. su_query_asset( 'css', 'su-media-shortcodes' ); 
  902. return '<div class="su-document su-responsive-media-' . $atts['responsive'] . '"><iframe src="http://docs.google.com/viewer?embedded=true&url=' . $atts['url'] . '" width="' . $atts['width'] . '" height="' . $atts['height'] . '" class="su-document' . su_ecssc( $atts ) . '"></iframe></div>'; 
  903.  
  904. public static function gmap( $atts = null, $content = null ) { 
  905. $atts = shortcode_atts( array( 
  906. 'width' => 600,  
  907. 'height' => 400,  
  908. 'responsive' => 'yes',  
  909. 'address' => 'New York',  
  910. 'class' => '' 
  911. ), $atts, 'gmap' ); 
  912. su_query_asset( 'css', 'su-media-shortcodes' ); 
  913. return '<div class="su-gmap su-responsive-media-' . $atts['responsive'] . su_ecssc( $atts ) . '"><iframe width="' . $atts['width'] . '" height="' . $atts['height'] . '" src="http://maps.google.com/maps?q=' . urlencode( su_scattr( $atts['address'] ) ) . '&output=embed"></iframe></div>'; 
  914.  
  915. public static function slider( $atts = null, $content = null ) { 
  916. $return = ''; 
  917. $atts = shortcode_atts( array( 
  918. 'source' => 'none',  
  919. 'limit' => 20,  
  920. 'gallery' => null, // Dep. 4.3.2 
  921. 'link' => 'none',  
  922. 'target' => 'self',  
  923. 'width' => 600,  
  924. 'height' => 300,  
  925. 'responsive' => 'yes',  
  926. 'title' => 'yes',  
  927. 'centered' => 'yes',  
  928. 'arrows' => 'yes',  
  929. 'pages' => 'yes',  
  930. 'mousewheel' => 'yes',  
  931. 'autoplay' => 3000,  
  932. 'speed' => 600,  
  933. 'class' => '' 
  934. ), $atts, 'slider' ); 
  935. // Get slides 
  936. $slides = (array) Su_Tools::get_slides( $atts ); 
  937. // Loop slides 
  938. if ( count( $slides ) ) { 
  939. // Prepare unique ID 
  940. $id = uniqid( 'su_slider_' ); 
  941. // Links target 
  942. $target = ( $atts['target'] === 'yes' || $atts['target'] === 'blank' ) ? ' target="_blank"' : ''; 
  943. // Centered class 
  944. $centered = ( $atts['centered'] === 'yes' ) ? ' su-slider-centered' : ''; 
  945. // Wheel control 
  946. $mousewheel = ( $atts['mousewheel'] === 'yes' ) ? 'true' : 'false'; 
  947. // Prepare width and height 
  948. $size = ( $atts['responsive'] === 'yes' ) ? 'width:100%' : 'width:' . intval( $atts['width'] ) . 'px;height:' . intval( $atts['height'] ) . 'px'; 
  949. // Add lightbox class 
  950. if ( $atts['link'] === 'lightbox' ) $atts['class'] .= ' su-lightbox-gallery'; 
  951. // Open slider 
  952. $return .= '<div id="' . $id . '" class="su-slider' . $centered . ' su-slider-pages-' . $atts['pages'] . ' su-slider-responsive-' . $atts['responsive'] . su_ecssc( $atts ) . '" style="' . $size . '" data-autoplay="' . $atts['autoplay'] . '" data-speed="' . $atts['speed'] . '" data-mousewheel="' . $mousewheel . '"><div class="su-slider-slides">'; 
  953. // Create slides 
  954. foreach ( $slides as $slide ) { 
  955. // Crop the image 
  956. $image = su_image_resize( $slide['image'], $atts['width'], $atts['height'] ); 
  957. // Prepare slide title 
  958. $title = ( $atts['title'] === 'yes' && $slide['title'] ) ? '<span class="su-slider-slide-title">' . stripslashes( $slide['title'] ) . '</span>' : ''; 
  959. // Open slide 
  960. $return .= '<div class="su-slider-slide">'; 
  961. // Slide content with link 
  962. if ( $slide['link'] ) $return .= '<a href="' . $slide['link'] . '"' . $target . '><img src="' . $image['url'] . '" alt="' . esc_attr( $slide['title'] ) . '" />' . $title . '</a>'; 
  963. // Slide content without link 
  964. else $return .= '<a><img src="' . $image['url'] . '" alt="' . esc_attr( $slide['title'] ) . '" />' . $title . '</a>'; 
  965. // Close slide 
  966. $return .= '</div>'; 
  967. // Close slide
  968. $return .= '</div>'; 
  969. // Open nav section 
  970. $return .= '<div class="su-slider-nav">'; 
  971. // Append direction nav 
  972. if ( $atts['arrows'] === 'yes' ) $return .= '<div class="su-slider-direction"><span class="su-slider-prev"></span><span class="su-slider-next"></span></div>'; 
  973. // Append pagination nav 
  974. $return .= '<div class="su-slider-pagination"></div>'; 
  975. // Close nav section 
  976. $return .= '</div>'; 
  977. // Close slide
  978. $return .= '</div>'; 
  979. // Add lightbox assets 
  980. if ( $atts['link'] === 'lightbox' ) { 
  981. su_query_asset( 'css', 'magnific-popup' ); 
  982. su_query_asset( 'js', 'magnific-popup' ); 
  983. su_query_asset( 'css', 'su-galleries-shortcodes' ); 
  984. su_query_asset( 'js', 'jquery' ); 
  985. su_query_asset( 'js', 'swiper' ); 
  986. su_query_asset( 'js', 'su-galleries-shortcodes' ); 
  987. // Slides not found 
  988. else $return = Su_Tools::error( __FUNCTION__, __( 'images not found', 'su' ) ); 
  989. return $return; 
  990.  
  991. public static function carousel( $atts = null, $content = null ) { 
  992. $return = ''; 
  993. $atts = shortcode_atts( array( 
  994. 'source' => 'none',  
  995. 'limit' => 20,  
  996. 'gallery' => null, // Dep. 4.3.2 
  997. 'link' => 'none',  
  998. 'target' => 'self',  
  999. 'width' => 600,  
  1000. 'height' => 100,  
  1001. 'responsive' => 'yes',  
  1002. 'items' => 3,  
  1003. 'scroll' => 1,  
  1004. 'title' => 'yes',  
  1005. 'centered' => 'yes',  
  1006. 'arrows' => 'yes',  
  1007. 'pages' => 'no',  
  1008. 'mousewheel' => 'yes',  
  1009. 'autoplay' => 3000,  
  1010. 'speed' => 600,  
  1011. 'class' => '' 
  1012. ), $atts, 'carousel' ); 
  1013. // Get slides 
  1014. $slides = (array) Su_Tools::get_slides( $atts ); 
  1015. // Loop slides 
  1016. if ( count( $slides ) ) { 
  1017. // Prepare unique ID 
  1018. $id = uniqid( 'su_carousel_' ); 
  1019. // Links target 
  1020. $target = ( $atts['target'] === 'yes' || $atts['target'] === 'blank' ) ? ' target="_blank"' : ''; 
  1021. // Centered class 
  1022. $centered = ( $atts['centered'] === 'yes' ) ? ' su-carousel-centered' : ''; 
  1023. // Wheel control 
  1024. $mousewheel = ( $atts['mousewheel'] === 'yes' ) ? 'true' : 'false'; 
  1025. // Prepare width and height 
  1026. $size = ( $atts['responsive'] === 'yes' ) ? 'width:100%' : 'width:' . intval( $atts['width'] ) . 'px;height:' . intval( $atts['height'] ) . 'px'; 
  1027. // Add lightbox class 
  1028. if ( $atts['link'] === 'lightbox' ) $atts['class'] .= ' su-lightbox-gallery'; 
  1029. // Open slider 
  1030. $return .= '<div id="' . $id . '" class="su-carousel' . $centered . ' su-carousel-pages-' . $atts['pages'] . ' su-carousel-responsive-' . $atts['responsive'] . su_ecssc( $atts ) . '" style="' . $size . '" data-autoplay="' . $atts['autoplay'] . '" data-speed="' . $atts['speed'] . '" data-mousewheel="' . $mousewheel . '" data-items="' . $atts['items'] . '" data-scroll="' . $atts['scroll'] . '"><div class="su-carousel-slides">'; 
  1031. // Create slides 
  1032. foreach ( (array) $slides as $slide ) { 
  1033. // Crop the image 
  1034. $image = su_image_resize( $slide['image'], round( $atts['width'] / $atts['items'] ), $atts['height'] ); 
  1035. // Prepare slide title 
  1036. $title = ( $atts['title'] === 'yes' && $slide['title'] ) ? '<span class="su-carousel-slide-title">' . stripslashes( $slide['title'] ) . '</span>' : ''; 
  1037. // Open slide 
  1038. $return .= '<div class="su-carousel-slide">'; 
  1039. // Slide content with link 
  1040. if ( $slide['link'] ) $return .= '<a href="' . $slide['link'] . '"' . $target . '><img src="' . $image['url'] . '" alt="' . esc_attr( $slide['title'] ) . '" />' . $title . '</a>'; 
  1041. // Slide content without link 
  1042. else $return .= '<a><img src="' . $image['url'] . '" alt="' . esc_attr( $slide['title'] ) . '" />' . $title . '</a>'; 
  1043. // Close slide 
  1044. $return .= '</div>'; 
  1045. // Close slide
  1046. $return .= '</div>'; 
  1047. // Open nav section 
  1048. $return .= '<div class="su-carousel-nav">'; 
  1049. // Append direction nav 
  1050. if ( $atts['arrows'] === 'yes' 
  1051. ) $return .= '<div class="su-carousel-direction"><span class="su-carousel-prev"></span><span class="su-carousel-next"></span></div>'; 
  1052. // Append pagination nav 
  1053. $return .= '<div class="su-carousel-pagination"></div>'; 
  1054. // Close nav section 
  1055. $return .= '</div>'; 
  1056. // Close slide
  1057. $return .= '</div>'; 
  1058. // Add lightbox assets 
  1059. if ( $atts['link'] === 'lightbox' ) { 
  1060. su_query_asset( 'css', 'magnific-popup' ); 
  1061. su_query_asset( 'js', 'magnific-popup' ); 
  1062. su_query_asset( 'css', 'su-galleries-shortcodes' ); 
  1063. su_query_asset( 'js', 'jquery' ); 
  1064. su_query_asset( 'js', 'swiper' ); 
  1065. su_query_asset( 'js', 'su-galleries-shortcodes' ); 
  1066. // Slides not found 
  1067. else $return = Su_Tools::error( __FUNCTION__, __( 'images not found', 'su' ) ); 
  1068. return $return; 
  1069.  
  1070. public static function custom_gallery( $atts = null, $content = null ) { 
  1071. $return = ''; 
  1072. $atts = shortcode_atts( array( 
  1073. 'source' => 'none',  
  1074. 'limit' => 20,  
  1075. 'gallery' => null, // Dep. 4.4.0 
  1076. 'link' => 'none',  
  1077. 'width' => 90,  
  1078. 'height' => 90,  
  1079. 'title' => 'hover',  
  1080. 'target' => 'self',  
  1081. 'class' => '' 
  1082. ), $atts, 'custom_gallery' ); 
  1083. $slides = (array) Su_Tools::get_slides( $atts ); 
  1084. // Loop slides 
  1085. if ( count( $slides ) ) { 
  1086. // Prepare links target 
  1087. $atts['target'] = ( $atts['target'] === 'yes' || $atts['target'] === 'blank' ) ? ' target="_blank"' : ''; 
  1088. // Add lightbox class 
  1089. if ( $atts['link'] === 'lightbox' ) $atts['class'] .= ' su-lightbox-gallery'; 
  1090. // Open gallery 
  1091. $return = '<div class="su-custom-gallery su-custom-gallery-title-' . $atts['title'] . su_ecssc( $atts ) . '">'; 
  1092. // Create slides 
  1093. foreach ( $slides as $slide ) { 
  1094. // Crop image 
  1095. $image = su_image_resize( $slide['image'], $atts['width'], $atts['height'] ); 
  1096. // Prepare slide title 
  1097. $title = ( $slide['title'] ) ? '<span class="su-custom-gallery-title">' . stripslashes( $slide['title'] ) . '</span>' : ''; 
  1098. // Open slide 
  1099. $return .= '<div class="su-custom-gallery-slide">'; 
  1100. // Slide content with link 
  1101. if ( $slide['link'] ) $return .= '<a href="' . $slide['link'] . '"' . $atts['target'] . '><img src="' . $image['url'] . '" alt="' . esc_attr( $slide['title'] ) . '" width="' . $atts['width'] . '" height="' . $atts['height'] . '" />' . $title . '</a>'; 
  1102. // Slide content without link 
  1103. else $return .= '<a><img src="' . $image['url'] . '" alt="' . esc_attr( $slide['title'] ) . '" width="' . $atts['width'] . '" height="' . $atts['height'] . '" />' . $title . '</a>'; 
  1104. // Close slide 
  1105. $return .= '</div>'; 
  1106. // Clear floats 
  1107. $return .= '<div class="su-clear"></div>'; 
  1108. // Close gallery 
  1109. $return .= '</div>'; 
  1110. // Add lightbox assets 
  1111. if ( $atts['link'] === 'lightbox' ) { 
  1112. su_query_asset( 'css', 'magnific-popup' ); 
  1113. su_query_asset( 'js', 'jquery' ); 
  1114. su_query_asset( 'js', 'magnific-popup' ); 
  1115. su_query_asset( 'js', 'su-galleries-shortcodes' ); 
  1116. su_query_asset( 'css', 'su-galleries-shortcodes' ); 
  1117. // Slides not found 
  1118. else $return = Su_Tools::error( __FUNCTION__, __( 'images not found', 'su' ) ); 
  1119. return $return; 
  1120.  
  1121. public static function posts( $atts = null, $content = null ) { 
  1122. // Prepare error var 
  1123. $error = null; 
  1124. // Parse attributes 
  1125. $atts = shortcode_atts( array( 
  1126. 'template' => 'templates/default-loop.php',  
  1127. 'id' => false,  
  1128. 'posts_per_page' => get_option( 'posts_per_page' ),  
  1129. 'post_type' => 'post',  
  1130. 'taxonomy' => 'category',  
  1131. 'tax_term' => false,  
  1132. 'tax_operator' => 'IN',  
  1133. 'author' => '',  
  1134. 'tag' => '',  
  1135. 'meta_key' => '',  
  1136. 'offset' => 0,  
  1137. 'order' => 'DESC',  
  1138. 'orderby' => 'date',  
  1139. 'post_parent' => false,  
  1140. 'post_status' => 'publish',  
  1141. 'ignore_sticky_posts' => 'no' 
  1142. ), $atts, 'posts' ); 
  1143.  
  1144. $original_atts = $atts; 
  1145.  
  1146. $author = sanitize_text_field( $atts['author'] ); 
  1147. $id = $atts['id']; // Sanitized later as an array of integers 
  1148. $ignore_sticky_posts = (bool) ( $atts['ignore_sticky_posts'] === 'yes' ) ? true : false; 
  1149. $meta_key = sanitize_text_field( $atts['meta_key'] ); 
  1150. $offset = intval( $atts['offset'] ); 
  1151. $order = sanitize_key( $atts['order'] ); 
  1152. $orderby = sanitize_key( $atts['orderby'] ); 
  1153. $post_parent = $atts['post_parent']; 
  1154. $post_status = $atts['post_status']; 
  1155. $post_type = sanitize_text_field( $atts['post_type'] ); 
  1156. $posts_per_page = intval( $atts['posts_per_page'] ); 
  1157. $tag = sanitize_text_field( $atts['tag'] ); 
  1158. $tax_operator = $atts['tax_operator']; 
  1159. $tax_term = sanitize_text_field( $atts['tax_term'] ); 
  1160. $taxonomy = sanitize_key( $atts['taxonomy'] ); 
  1161. // Set up initial query for post 
  1162. $args = array( 
  1163. 'category_name' => '',  
  1164. 'order' => $order,  
  1165. 'orderby' => $orderby,  
  1166. 'post_type' => explode( ', ', $post_type ),  
  1167. 'posts_per_page' => $posts_per_page,  
  1168. 'tag' => $tag 
  1169. ); 
  1170. // Ignore Sticky Posts 
  1171. if ( $ignore_sticky_posts ) $args['ignore_sticky_posts'] = true; 
  1172. // Meta key (for ordering) 
  1173. if ( !empty( $meta_key ) ) $args['meta_key'] = $meta_key; 
  1174. // If Post IDs 
  1175. if ( $id ) { 
  1176. $posts_in = array_map( 'intval', explode( ', ', $id ) ); 
  1177. $args['post__in'] = $posts_in; 
  1178. // Post Author 
  1179. if ( !empty( $author ) ) $args['author'] = $author; 
  1180. // Offset 
  1181. if ( !empty( $offset ) ) $args['offset'] = $offset; 
  1182. // Post Status 
  1183. $post_status = explode( ', ', $post_status ); 
  1184. $validated = array(); 
  1185. $available = array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash', 'any' ); 
  1186. foreach ( $post_status as $unvalidated ) { 
  1187. if ( in_array( $unvalidated, $available ) ) $validated[] = $unvalidated; 
  1188. if ( !empty( $validated ) ) $args['post_status'] = $validated; 
  1189. // If taxonomy attributes, create a taxonomy query 
  1190. if ( !empty( $taxonomy ) && !empty( $tax_term ) ) { 
  1191. // Term string to array 
  1192. $tax_term = explode( ', ', $tax_term ); 
  1193. // Validate operator 
  1194. if ( !in_array( $tax_operator, array( 'IN', 'NOT IN', 'AND' ) ) ) $tax_operator = 'IN'; 
  1195. $tax_args = array( 'tax_query' => array( array( 
  1196. 'taxonomy' => $taxonomy,  
  1197. 'field' => ( is_numeric( $tax_term[0] ) ) ? 'id' : 'slug',  
  1198. 'terms' => $tax_term,  
  1199. 'operator' => $tax_operator ) ) ); 
  1200. // Check for multiple taxonomy queries 
  1201. $count = 2; 
  1202. $more_tax_queries = false; 
  1203. while ( isset( $original_atts['taxonomy_' . $count] ) && !empty( $original_atts['taxonomy_' . $count] ) && 
  1204. isset( $original_atts['tax_' . $count . '_term'] ) && 
  1205. !empty( $original_atts['tax_' . $count . '_term'] ) ) { 
  1206. // Sanitize values 
  1207. $more_tax_queries = true; 
  1208. $taxonomy = sanitize_key( $original_atts['taxonomy_' . $count] ); 
  1209. $terms = explode( ', ', sanitize_text_field( $original_atts['tax_' . $count . '_term'] ) ); 
  1210. $tax_operator = isset( $original_atts['tax_' . $count . '_operator'] ) ? $original_atts[ 
  1211. 'tax_' . $count . '_operator'] : 'IN'; 
  1212. $tax_operator = in_array( $tax_operator, array( 'IN', 'NOT IN', 'AND' ) ) ? $tax_operator : 'IN'; 
  1213. $tax_args['tax_query'][] = array( 'taxonomy' => $taxonomy,  
  1214. 'field' => 'slug',  
  1215. 'terms' => $terms,  
  1216. 'operator' => $tax_operator ); 
  1217. $count++; 
  1218. if ( $more_tax_queries ): 
  1219. $tax_relation = 'AND'; 
  1220. if ( isset( $original_atts['tax_relation'] ) && 
  1221. in_array( $original_atts['tax_relation'], array( 'AND', 'OR' ) ) 
  1222. ) $tax_relation = $original_atts['tax_relation']; 
  1223. $args['tax_query']['relation'] = $tax_relation; 
  1224. endif; 
  1225. $args = array_merge( $args, $tax_args ); 
  1226.  
  1227. // If post parent attribute, set up parent 
  1228. if ( $post_parent ) { 
  1229. if ( 'current' == $post_parent ) { 
  1230. global $post; 
  1231. $post_parent = $post->ID; 
  1232. $args['post_parent'] = intval( $post_parent ); 
  1233. // Save original posts 
  1234. global $posts; 
  1235. $original_posts = $posts; 
  1236. // Query posts 
  1237. $posts = new WP_Query( $args ); 
  1238. // Buffer output 
  1239. ob_start(); 
  1240. // Search for template in stylesheet directory 
  1241. if ( file_exists( STYLESHEETPATH . '/' . $atts['template'] ) ) load_template( STYLESHEETPATH . '/' . $atts['template'], false ); 
  1242. // Search for template in theme directory 
  1243. elseif ( file_exists( TEMPLATEPATH . '/' . $atts['template'] ) ) load_template( TEMPLATEPATH . '/' . $atts['template'], false ); 
  1244. // Search for template in plugin directory 
  1245. elseif ( path_join( dirname( SU_PLUGIN_FILE ), $atts['template'] ) ) load_template( path_join( dirname( SU_PLUGIN_FILE ), $atts['template'] ), false ); 
  1246. // Template not found 
  1247. else echo Su_Tools::error( __FUNCTION__, __( 'template not found', 'su' ) ); 
  1248. $output = ob_get_contents(); 
  1249. ob_end_clean(); 
  1250. // Return original posts 
  1251. $posts = $original_posts; 
  1252. // Reset the query 
  1253. wp_reset_postdata(); 
  1254. su_query_asset( 'css', 'su-other-shortcodes' ); 
  1255. return $output; 
  1256.  
  1257. public static function dummy_text( $atts = null, $content = null ) { 
  1258. $atts = shortcode_atts( array( 
  1259. 'amount' => 1,  
  1260. 'what' => 'paras',  
  1261. 'cache' => 'yes',  
  1262. 'class' => '' 
  1263. ), $atts, 'dummy_text' ); 
  1264. $transient = 'su/cache/dummy_text/' . sanitize_text_field( $atts['what'] ) . '/' . intval( $atts['amount'] ); 
  1265. $return = get_transient( $transient ); 
  1266. if ( $return && $atts['cache'] === 'yes' && SU_ENABLE_CACHE ) return $return; 
  1267. else { 
  1268. $xml = simplexml_load_file( 'http://www.lipsum.com/feed/xml?amount=' . $atts['amount'] . '&what=' . $atts['what'] . '&start=0' ); 
  1269. $return = '<div class="su-dummy-text' . su_ecssc( $atts ) . '">' . wpautop( str_replace( "\n", "\n\n", $xml->lipsum ) ) . '</div>'; 
  1270. set_transient( $transient, $return, 60*60*24*30 ); 
  1271. return $return; 
  1272.  
  1273. public static function dummy_image( $atts = null, $content = null ) { 
  1274. $atts = shortcode_atts( array( 
  1275. 'width' => 500,  
  1276. 'height' => 300,  
  1277. 'theme' => 'any',  
  1278. 'class' => '' 
  1279. ), $atts, 'dummy_image' ); 
  1280. $url = 'http://lorempixel.com/' . $atts['width'] . '/' . $atts['height'] . '/'; 
  1281. if ( $atts['theme'] !== 'any' ) $url .= $atts['theme'] . '/' . rand( 0, 10 ) . '/'; 
  1282. return '<img src="' . $url . '" alt="' . __( 'Dummy image', 'su' ) . '" width="' . $atts['width'] . '" height="' . $atts['height'] . '" class="su-dummy-image' . su_ecssc( $atts ) . '" />'; 
  1283.  
  1284. public static function animate( $atts = null, $content = null ) { 
  1285. $atts = shortcode_atts( array( 
  1286. 'type' => 'bounceIn',  
  1287. 'duration' => 1,  
  1288. 'delay' => 0,  
  1289. 'inline' => 'no',  
  1290. 'class' => '' 
  1291. ), $atts, 'animate' ); 
  1292. $tag = ( $atts['inline'] === 'yes' ) ? 'span' : 'div'; 
  1293. $time = '-webkit-animation-duration:' . $atts['duration'] . 's;-webkit-animation-delay:' . $atts['delay'] . 's;animation-duration:' . $atts['duration'] . 's;animation-delay:' . $atts['delay'] . 's;'; 
  1294. $return = '<' . $tag . ' class="su-animate' . su_ecssc( $atts ) . '" style="visibility:hidden;' . $time . '" data-animation="' . $atts['type'] . '" data-duration="' . $atts['duration'] . '" data-delay="' . $atts['delay'] . '">' . do_shortcode( $content ) . '</' . $tag . '>'; 
  1295. su_query_asset( 'css', 'animate' ); 
  1296. su_query_asset( 'js', 'jquery' ); 
  1297. su_query_asset( 'js', 'inview' ); 
  1298. su_query_asset( 'js', 'su-other-shortcodes' ); 
  1299. return $return; 
  1300.  
  1301. public static function meta( $atts = null, $content = null ) { 
  1302. $atts = shortcode_atts( array( 
  1303. 'key' => '',  
  1304. 'default' => '',  
  1305. 'before' => '',  
  1306. 'after' => '',  
  1307. 'post_id' => '',  
  1308. 'filter' => '' 
  1309. ), $atts, 'meta' ); 
  1310. // Define current post ID 
  1311. if ( !$atts['post_id'] ) $atts['post_id'] = get_the_ID(); 
  1312. // Check post ID 
  1313. if ( !is_numeric( $atts['post_id'] ) || $atts['post_id'] < 1 ) return sprintf( '<p class="su-error">Meta: %s</p>', __( 'post ID is incorrect', 'su' ) ); 
  1314. // Check key name 
  1315. if ( !$atts['key'] ) return sprintf( '<p class="su-error">Meta: %s</p>', __( 'please specify meta key name', 'su' ) ); 
  1316. // Get the meta 
  1317. $meta = get_post_meta( $atts['post_id'], $atts['key'], true ); 
  1318. // Set default value if meta is empty 
  1319. if ( !$meta ) $meta = $atts['default']; 
  1320. // Apply cutom filter 
  1321. if ( $atts['filter'] && function_exists( $atts['filter'] ) ) $meta = call_user_func( $atts['filter'], $meta ); 
  1322. // Return result 
  1323. return ( $meta ) ? $atts['before'] . $meta . $atts['after'] : ''; 
  1324.  
  1325. public static function user( $atts = null, $content = null ) { 
  1326. $atts = shortcode_atts( array( 
  1327. 'field' => 'display_name',  
  1328. 'default' => '',  
  1329. 'before' => '',  
  1330. 'after' => '',  
  1331. 'user_id' => '',  
  1332. 'filter' => '' 
  1333. ), $atts, 'user' ); 
  1334. // Check for password requests 
  1335. if ( $atts['field'] === 'user_pass' ) return sprintf( '<p class="su-error">User: %s</p>', __( 'password field is not allowed', 'su' ) ); 
  1336. // Define current user ID 
  1337. if ( !$atts['user_id'] ) $atts['user_id'] = get_current_user_id(); 
  1338. // Check user ID 
  1339. if ( !is_numeric( $atts['user_id'] ) || $atts['user_id'] < 1 ) return sprintf( '<p class="su-error">User: %s</p>', __( 'user ID is incorrect', 'su' ) ); 
  1340. // Get user data 
  1341. $user = get_user_by( 'id', $atts['user_id'] ); 
  1342. // Get user data if user was found 
  1343. $user = ( $user && isset( $user->data->$atts['field'] ) ) ? $user->data->$atts['field'] : $atts['default']; 
  1344. // Apply cutom filter 
  1345. if ( $atts['filter'] && function_exists( $atts['filter'] ) ) $user = call_user_func( $atts['filter'], $user ); 
  1346. // Return result 
  1347. return ( $user ) ? $atts['before'] . $user . $atts['after'] : ''; 
  1348.  
  1349. public static function post( $atts = null, $content = null ) { 
  1350. $atts = shortcode_atts( array( 
  1351. 'field' => 'post_title',  
  1352. 'default' => '',  
  1353. 'before' => '',  
  1354. 'after' => '',  
  1355. 'post_id' => '',  
  1356. 'filter' => '' 
  1357. ), $atts, 'post' ); 
  1358. // Define current post ID 
  1359. if ( !$atts['post_id'] ) $atts['post_id'] = get_the_ID(); 
  1360. // Check post ID 
  1361. if ( !is_numeric( $atts['post_id'] ) || $atts['post_id'] < 1 ) return sprintf( '<p class="su-error">Post: %s</p>', __( 'post ID is incorrect', 'su' ) ); 
  1362. // Get the post 
  1363. $post = get_post( $atts['post_id'] ); 
  1364. // Set default value if meta is empty 
  1365. $post = ( empty( $post ) || empty( $post->$atts['field'] ) ) ? $atts['default'] : $post->$atts['field']; 
  1366. // Apply cutom filter 
  1367. if ( $atts['filter'] && function_exists( $atts['filter'] ) ) $post = call_user_func( $atts['filter'], $post ); 
  1368. // Return result 
  1369. return ( $post ) ? $atts['before'] . $post . $atts['after'] : ''; 
  1370.  
  1371. // public static function post_terms( $atts = null, $content = null ) { 
  1372. // $atts = shortcode_atts( array( 
  1373. // 'post_id' => '',  
  1374. // 'taxonomy' => 'category',  
  1375. // 'limit' => '5',  
  1376. // 'links' => '',  
  1377. // 'format' => '' 
  1378. // ), $atts, 'post_terms' ); 
  1379. // // Define current post ID 
  1380. // if ( !$atts['post_id'] ) $atts['post_id'] = get_the_ID(); 
  1381. // // Check post ID 
  1382. // if ( !is_numeric( $atts['post_id'] ) || $atts['post_id'] < 1 ) return sprintf( '<p class="su-error">Post terms: %s</p>', __( 'post ID is incorrect', 'su' ) ); 
  1383. // } 
  1384.  
  1385. public static function template( $atts = null, $content = null ) { 
  1386. $atts = shortcode_atts( array( 
  1387. 'name' => '' 
  1388. ), $atts, 'template' ); 
  1389. // Check template name 
  1390. if ( !$atts['name'] ) return sprintf( '<p class="su-error">Template: %s</p>', __( 'please specify template name', 'su' ) ); 
  1391. // Get template output 
  1392. ob_start(); 
  1393. get_template_part( str_replace( '.php', '', $atts['name'] ) ); 
  1394. $output = ob_get_contents(); 
  1395. ob_end_clean(); 
  1396. // Return result 
  1397. return $output; 
  1398.  
  1399. public static function qrcode( $atts = null, $content = null ) { 
  1400. $atts = shortcode_atts( array( 
  1401. 'data' => '',  
  1402. 'title' => '',  
  1403. 'size' => 200,  
  1404. 'margin' => 0,  
  1405. 'align' => 'none',  
  1406. 'link' => '',  
  1407. 'target' => 'blank',  
  1408. 'color' => '#000000',  
  1409. 'background' => '#ffffff',  
  1410. 'class' => '' 
  1411. ), $atts, 'qrcode' ); 
  1412. // Check the data 
  1413. if ( !$atts['data'] ) return 'QR code: ' . __( 'please specify the data', 'su' ); 
  1414. // Prepare link 
  1415. $href = ( $atts['link'] ) ? ' href="' . $atts['link'] . '"' : ''; 
  1416. // Prepare clickable class 
  1417. if ( $atts['link'] ) $atts['class'] .= ' su-qrcode-clickable'; 
  1418. // Prepare title 
  1419. $atts['title'] = esc_attr( $atts['title'] ); 
  1420. // Query assets 
  1421. su_query_asset( 'css', 'su-content-shortcodes' ); 
  1422. // Return result 
  1423. return '<span class="su-qrcode su-qrcode-align-' . $atts['align'] . su_ecssc( $atts ) . '"><a' . $href . ' target="_' . $atts['target'] . '" title="' . $atts['title'] . '"><img src="https://api.qrserver.com/v1/create-qr-code/?data=' . urlencode( $atts['data'] ) . '&size=' . $atts['size'] . 'x' . $atts['size'] . '&format=png&margin=' . $atts['margin'] . '&color=' . su_hex2rgb( $atts['color'] ) . '&bgcolor=' . su_hex2rgb( $atts['background'] ) . '" alt="' . $atts['title'] . '" /></a></span>'; 
  1424.  
  1425. public static function scheduler( $atts = null, $content = null ) { 
  1426. $atts = shortcode_atts( array( 
  1427. 'time' => 'all',  
  1428. 'days_week' => 'all',  
  1429. 'days_month' => 'all',  
  1430. 'months' => 'all',  
  1431. 'years' => 'all',  
  1432. 'alt' => '' 
  1433. ), $atts, 'scheduler' ); 
  1434. // Check time 
  1435. if ( $atts['time'] !== 'all' ) { 
  1436. // Get current time 
  1437. $now = current_time( 'timestamp', 0 ); 
  1438. // Sanitize 
  1439. $atts['time'] = preg_replace( "/[^0-9-, :]/", '', $atts['time'] ); 
  1440. // Loop time ranges 
  1441. foreach( explode( ', ', $atts['time'] ) as $range ) { 
  1442. // Check for range symbol 
  1443. if ( strpos( $range, '-' ) === false ) return Su_Tools::error( __FUNCTION__, sprintf( __( 'Incorrect time range (%s). Please use - (minus) symbol to specify time range. Example: 14:00 - 18:00', 'su' ), $range ) ); 
  1444. // Split begin/end time 
  1445. $time = explode( '-', $range ); 
  1446. // Add minutes 
  1447. if ( strpos( $time[0], ':' ) === false ) $time[0] .= ':00'; 
  1448. if ( strpos( $time[1], ':' ) === false ) $time[1] .= ':00'; 
  1449. // Parse begin/end time 
  1450. $time[0] = strtotime( $time[0] ); 
  1451. $time[1] = strtotime( $time[1] ); 
  1452. // Check time 
  1453. if ( $now < $time[0] || $now > $time[1] ) return $atts['alt']; 
  1454. // Check day of the week 
  1455. if ( $atts['days_week'] !== 'all' ) { 
  1456. // Get current day of the week 
  1457. $today = date( 'w', current_time( 'timestamp', 0 ) ); 
  1458. // Sanitize input 
  1459. $atts['days_week'] = preg_replace( "/[^0-9-, ]/", '', $atts['days_week'] ); 
  1460. // Parse days range 
  1461. $days = Su_Tools::range( $atts['days_week'] ); 
  1462. // Check current day 
  1463. if ( !in_array( $today, $days ) ) return $atts['alt']; 
  1464. // Check day of the month 
  1465. if ( $atts['days_month'] !== 'all' ) { 
  1466. // Get current day of the month 
  1467. $today = date( 'j', current_time( 'timestamp', 0 ) ); 
  1468. // Sanitize input 
  1469. $atts['days_month'] = preg_replace( "/[^0-9-, ]/", '', $atts['days_month'] ); 
  1470. // Parse days range 
  1471. $days = Su_Tools::range( $atts['days_month'] ); 
  1472. // Check current day 
  1473. if ( !in_array( $today, $days ) ) return $atts['alt']; 
  1474. // Check month 
  1475. if ( $atts['months'] !== 'all' ) { 
  1476. // Get current month 
  1477. $now = date( 'n', current_time( 'timestamp', 0 ) ); 
  1478. // Sanitize input 
  1479. $atts['months'] = preg_replace( "/[^0-9-, ]/", '', $atts['months'] ); 
  1480. // Parse months range 
  1481. $months = Su_Tools::range( $atts['months'] ); 
  1482. // Check current month 
  1483. if ( !in_array( $now, $months ) ) return $atts['alt']; 
  1484. // Check year 
  1485. if ( $atts['years'] !== 'all' ) { 
  1486. // Get current year 
  1487. $now = date( 'Y', current_time( 'timestamp', 0 ) ); 
  1488. // Sanitize input 
  1489. $atts['years'] = preg_replace( "/[^0-9-, ]/", '', $atts['years'] ); 
  1490. // Parse years range 
  1491. $years = Su_Tools::range( $atts['years'] ); 
  1492. // Check current year 
  1493. if ( !in_array( $now, $years ) ) return $atts['alt']; 
  1494. // Return result (all check passed) 
  1495. return do_shortcode( $content ); 
  1496.  
  1497.  
  1498. new Su_Shortcodes; 
  1499.  
  1500. class Shortcodes_Ultimate_Shortcodes extends Su_Shortcodes { 
  1501. function __construct() { 
  1502. parent::__construct(); 
.