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