Advertisement
towfiqi

shortcodes.php

May 9th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.56 KB | None | 0 0
  1. <?php
  2.  
  3. /**Shortcode Support in Text Widget **/
  4. add_filter('widget_text', 'do_shortcode');
  5.  
  6. /**optimizer SHORTCODES **/
  7.  
  8. /**Success Alert **/
  9. /**USAGE: [success]Your info success message[/success]**/
  10. function layersc_scs( $atts, $content = null ) {
  11. extract(shortcode_atts(array('class' => '',), $atts));
  12.  
  13. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  14.  
  15. return '<div class="lts_scs '.$class.' '.$nonedit.'">'.do_shortcode($content).'</div>';
  16. }
  17. add_shortcode( 'success', 'layersc_scs' );
  18.  
  19.  
  20. /**Info Alert **/
  21. /**USAGE: [info]Your info alert message[/info]**/
  22. function layersc_info( $atts, $content = null ) {
  23. extract(shortcode_atts(array('class' => '',), $atts));
  24.  
  25. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  26.  
  27. return '<div class="lts_info '.$class.' '.$nonedit.'">'.do_shortcode($content).'</div>';
  28. }
  29. add_shortcode( 'info', 'layersc_info' );
  30.  
  31.  
  32. /**Warning Alert **/
  33. /**USAGE: [warning]Your warning alert message[/warning]**/
  34. function layersc_wng( $atts, $content = null ) {
  35. extract(shortcode_atts(array('class' => '',), $atts));
  36.  
  37. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  38.  
  39. return '<div class="lts_wng '.$class.' '.$nonedit.'">'.do_shortcode($content).'</div>';
  40. }
  41. add_shortcode( 'warning', 'layersc_wng' );
  42.  
  43.  
  44.  
  45. /**Error Alert **/
  46. /**USAGE: [error]Your error alert message[/error]**/
  47. function layersc_err( $atts, $content = null ) {
  48. extract(shortcode_atts(array('class' => '',), $atts));
  49.  
  50. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  51.  
  52. return '<div class="lts_err '.$class.' '.$nonedit.'">'.do_shortcode($content).'</div>';
  53. }
  54. add_shortcode( 'error', 'layersc_err' );
  55.  
  56.  
  57.  
  58. /**Quote Shortcode **/
  59. /**USAGE: [quote]Your Quote[/quote]**/
  60. function layersc_quote( $atts, $content = null ) {
  61. extract(shortcode_atts(array(
  62. 'author' => '',
  63. 'source' => '',
  64. 'class'=> '',
  65. ), $atts));
  66. $authord ='';
  67. if($author !== ''){
  68. $authord = '-'.$author;
  69. }
  70.  
  71. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  72.  
  73.  
  74. return '<div class="lts_quote_wrap '.$class.' '.$nonedit.'"><div class="lts_quote">'.do_shortcode($content).'</div><div class="lts_quote_author"><a target="_blank" href="'.$source.'">'.$authord.'</a></div></div>';
  75. }
  76. add_shortcode( 'quote', 'layersc_quote' );
  77.  
  78.  
  79. /**Divider Shortcode **/
  80. /**USAGE: [divider]**/
  81. function layersc_divider( $atts, $content = null ) {
  82. extract(shortcode_atts(array(
  83. 'style' => 'solid',
  84. 'height' => '1px',
  85. 'color' => '#eeeeee',
  86. 'class'=> '',
  87. ), $atts));
  88.  
  89.  
  90. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  91.  
  92. return '<div class="ast_divide '.$class.' '.$nonedit.'" style="clear:both;border-bottom: '.$height.' '.$style.' '.$color.'; width:100%; height:2px; margin:15px 0;"></div>';
  93. }
  94. add_shortcode( 'divider', 'layersc_divider' );
  95.  
  96.  
  97. /**Title Divider Shortcode **/
  98. /**USAGE: [tdivider style="fa-stop" color="#333"]**/
  99. function layersc_tdivider( $atts, $content = null ) {
  100. extract(shortcode_atts(array(
  101. 'style' => 'fa-stop', //fa-stop, underline, fa-star, fa-times, fa-bolt, fa-asterisk, fa-chevron-down, fa-heart, fa-plus, fa-bookmark, fa-circle-o, fa-th-large, fa-minus, fa-cog, fa-reorder, fa-diamond, fa-gg, fa-houzz, fa-rocket
  102. 'color' => '#333',
  103. 'class'=> '',
  104. ), $atts));
  105. if($style == 'underline'){ $underline= 'title_underline';}else{$underline='';}
  106.  
  107.  
  108. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  109. //line breaks added to fix the customizer issue
  110. return '<div class="optimizer_divider '.$class .$underline.' '.$nonedit.'">
  111. <span class="div_left" style="background:'.$color.'">
  112. </span>
  113. <span class="div_middle" style="color:'.$color.'">
  114. <i class="fa '.$style.'"> </i>
  115. </span>
  116. <span class="div_right" style="background:'.$color.'">
  117. </span>
  118. </div>';
  119. }
  120. add_shortcode( 'tdivider', 'layersc_tdivider' );
  121.  
  122.  
  123. /**Slider Shortcode **/
  124. /**USAGE: [slider]**/
  125. function layersc_slider( $atts, $content = null ) {
  126. extract(shortcode_atts(array(
  127. 'effect' => 'slide',
  128. 'pausetime' => '3000',
  129. 'autoplay' => 'true',
  130. 'navigation' => 'true',
  131. 'class'=> '',
  132. ), $atts));
  133.  
  134. if($autoplay == 'true'){
  135. $autoplayd = 'manualAdvance:false';
  136. }else{
  137. $autoplayd = '';
  138. }
  139.  
  140.  
  141. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  142.  
  143. $content= preg_replace('<<br />>', '', $content);
  144. return '<div class="ast_slide_wrap '.$class.' '.$nonedit.'"><div class="ast_slider">'.$content.'</div></div><script>jQuery(window).bind("load", function(){jQuery(".ast_slider").nivoSlider({ effect :"'.$effect.'", pauseTime: '.$pausetime.', directionNav: '.$navigation.', '.$autoplayd.'}); });</script>';
  145. }
  146. add_shortcode( 'slider', 'layersc_slider' );
  147.  
  148.  
  149.  
  150. /**FACEBOOK LIKE BUTTON **/
  151. /**USAGE: [fblike]**/
  152. function layersc_facelike( $atts, $content = null) {
  153. extract(shortcode_atts(array(
  154. 'layout' => 'standard', //standard, box_count, button_count
  155. 'action' => 'like', //like, recommend
  156. 'share' => 'true',
  157. ), $atts));
  158.  
  159. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  160.  
  161. return '<div id="fb-root"></div>
  162. <script>(function(d, s, id) {
  163. var js, fjs = d.getElementsByTagName(s)[0];
  164. if (d.getElementById(id)) return;
  165. js = d.createElement(s); js.id = id;
  166. js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3";
  167. fjs.parentNode.insertBefore(js, fjs);
  168. }(document, "script", "facebook-jssdk"));</script>
  169.  
  170. <div class="fb-like '.$nonedit.'" data-href="'.urlencode(get_permalink()).'" data-layout="'.$layout.'" data-action="'.$action.'" data-show-faces="false" data-share="'.$share.'"></div>
  171. ';
  172.  
  173. }
  174. add_shortcode('fblike', 'layersc_facelike');
  175.  
  176.  
  177. /**TWITTER TWEET BUTTON **/
  178. /**USAGE: [tweet]**/
  179. function layersc_tweet( $atts, $content = null) {
  180. extract(shortcode_atts(array(
  181. 'size' => 'standard', //standard, big
  182. 'via' => '',
  183. 'count' => 'true',
  184. 'count_type' => 'horizontal' //horizontal, vertical
  185. ), $atts));
  186.  
  187. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  188.  
  189. if($size == 'big'){
  190. $size ='data-size="large"';
  191. }else{
  192. $size ='';
  193. }
  194.  
  195. if($via !== ''){
  196. $via ='data-via="'.$via.'"';
  197. }else{
  198. $via ='';
  199. }
  200.  
  201. if($count == 'true'){
  202. $count ='';
  203. }else{
  204. $count ='data-count="none"';
  205. }
  206.  
  207. if($count_type == 'vertical'){
  208. $count_type ='data-count="vertical"';
  209. }else{
  210. $count_type ='';
  211. }
  212.  
  213. return '<a '.$nonedit.' href="https://twitter.com/share" class="twitter-share-button" '.$via.' '.$count.' '.$size.' '.$count_type.'>Tweet</a>
  214. <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?"http":"https";if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document, "script", "twitter-wjs");</script>';
  215. }
  216. add_shortcode('tweet', 'layersc_tweet');
  217.  
  218.  
  219. /**Pinterest BUTTON **/
  220. /**USAGE: [pinit]**/
  221. function layersc_pinit( $atts, $content = null) {
  222. extract(shortcode_atts(array(
  223. 'size' => 'standard', //standard, big
  224. 'style' => 'red', //red, white, gray
  225. ), $atts));
  226.  
  227. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  228.  
  229. if($size == 'big'){
  230. $size ='data-pin-height="28"';
  231. }else{
  232. $size ='';
  233. }
  234.  
  235. if($style == 'red'){
  236. $style ='data-pin-color="red"';
  237. }elseif($style == 'white'){
  238. $style ='data-pin-color="white"';
  239. }else{
  240. $style ='';
  241. }
  242.  
  243. return '<a class="'.$nonedit.'" href="//pinterest.com/pin/create/button/" data-pin-do="buttonBookmark" '.$size.' '.$style.'><img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" /></a><script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>';
  244. }
  245. add_shortcode('pinit', 'layersc_pinit');
  246.  
  247. /**Google Plus BUTTON **/
  248. /**USAGE: [gplus]**/
  249. function layersc_gplus( $atts, $content = null) {
  250. extract(shortcode_atts(array(
  251. 'size' => 'small', //small, medium, large
  252. 'style' => 'inline', //inline, bubble, none
  253. ), $atts));
  254.  
  255. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  256.  
  257. if($size == 'small'){
  258. $size ='data-size="small"';
  259. }elseif($size == 'large'){
  260. $size ='data-size="tall"';
  261. }else{
  262. $size ='';
  263. }
  264. $annotation ='';
  265. if($style == 'none'){
  266. $annotation ='data-annotation="none"';
  267. }elseif($style == 'inline'){
  268. $annotation ='data-annotation="inline"';
  269. }
  270. if($style == 'inline'){
  271. $width = 'width:185px;';
  272. }else{
  273. $width = 'width:75px;';
  274. }
  275. return '<div style="'.$width.' display: inline-block;" class="gplus_wrap gplus_'.$style.' '.$nonedit.'"><div class="g-plusone" '.$size.' '.$annotation.'></div></div><script type="text/javascript">
  276. (function() {
  277. var po = document.createElement(\'script\'); po.type = \'text/javascript\'; po.async = true;
  278. po.src = \'https://apis.google.com/js/plusone.js\';
  279. var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s);
  280. })();
  281. </script>';
  282. }
  283. add_shortcode('gplus', 'layersc_gplus');
  284.  
  285.  
  286.  
  287. /**List Style **/
  288. /**USAGE:
  289. [list]
  290. your list items created within the editor.
  291. [/list]
  292. **/
  293. function layersc_list_func($atts, $content) {
  294. //extract short code attr
  295. extract(shortcode_atts(array(
  296. 'bullet_color' => '#999999',
  297. 'style' => 'list1',
  298. 'class' => ''
  299. ), $atts));
  300.  
  301.  
  302. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  303.  
  304. $return_html = '<div class="lts_list '.$style.' '.$class.' '.$nonedit.'" data-list-color="'.$bullet_color.'">'.$content.'</div>';
  305.  
  306. return $return_html;
  307. }
  308. add_shortcode('list', 'layersc_list_func');
  309.  
  310.  
  311. /**Youtube Video Shortcode **/
  312. /**USAGE: [youtube width="640" height="385" video_id="EhkHFenJ3rM"]
  313. **/
  314. if(class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'shortcodes' ) ){
  315. }else{
  316. function layersc_youtube_func($atts, $content) {
  317.  
  318. //extract short code attr
  319. extract(shortcode_atts(array(
  320. 'width' => '100%',
  321. 'height' => '100%',
  322. 'autoplay' => 'true',
  323. 'class' => '',
  324. ), $atts));
  325.  
  326.  
  327. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  328.  
  329.  
  330. $content = strip_tags($content);
  331. if (($pos = strpos($content, "list=")) !== FALSE) {
  332. $listid = substr($content, $pos+5);
  333. $content ='//www.youtube.com/embed/videoseries?list='. $listid;
  334. }else{
  335. $content =str_replace('http://www.youtube.com/watch?v=', '//www.youtube.com/embed/', $content);
  336. $content =str_replace('https://www.youtube.com/watch?v=', '//www.youtube.com/embed/', $content);
  337. $content =str_replace('https://youtube.com/watch?v=', '//www.youtube.com/embed/', $content);
  338. $content =str_replace('https://youtu.be/', '//www.youtube.com/embed/', $content);
  339. $content =str_replace('https://www.youtu.be/', '//www.youtube.com/embed/', $content);
  340. $content =str_replace('https://www.youtu.be/', '//www.youtube.com/embed/', $content);
  341. }
  342. if ($autoplay == 'true'){
  343. $autoplay= '?autoplay=1';
  344. }elseif ($autoplay == 'false'){
  345. $autoplay= '';
  346. }
  347. $node = 'iframe';
  348.  
  349. $return_html = '<div style="clear:both;"></div><div class="ast_vid '.$class.' '.$nonedit.'"><div class="responsive-container"><'.$node.' class="vid_iframe" style=" width: '.$width.'; height: '.$height.';" src="'.$content.''.$autoplay.'" allowfullscreen></'.$node.'></div></div>';
  350.  
  351. return $return_html;
  352. }
  353. add_shortcode('youtube', 'layersc_youtube_func');
  354.  
  355.  
  356. }
  357.  
  358. /**Vimeo Video Shortcode **/
  359. /**USAGE: [vimeo width="640" height="385" video_id="11770385"]
  360. / Might have issue with some servers
  361. **/
  362. if(class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'shortcodes' ) ){
  363. }else{
  364. function layersc_vimeo_func($atts, $content) {
  365.  
  366. //extract short code attr
  367. extract(shortcode_atts(array(
  368. 'width' => '100%',
  369. 'height' => '100%',
  370. 'autoplay' => 'true',
  371. 'class' => '',
  372. ), $atts));
  373.  
  374. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  375.  
  376. $content = strip_tags($content);
  377. $content =str_replace('http://vimeo.com/', '//player.vimeo.com/video/', $content);
  378. $content =str_replace('https://vimeo.com/', '//player.vimeo.com/video/', $content);
  379. if ($autoplay == 'true'){
  380. $autoplay= 1;
  381. }elseif ($autoplay == 'false'){
  382. $autoplay= 0;
  383. }
  384. $node = 'iframe';
  385.  
  386. $return_html = '<div style="clear:both;"></div><div class="ast_vid '.$class.' '.$nonedit.'"><div class="responsive-container"><'.$node.' class="vid_iframe" style=" width: '.$width.'; height: '.$height.';" src="'.$content.'?title=1&amp;byline=0&amp;portrait=0&amp;color=00adef&amp;autoplay='.$autoplay.'"></'.$node.'></div></div>';
  387.  
  388. return $return_html;
  389. }
  390. add_shortcode('vimeo', 'layersc_vimeo_func');
  391. }
  392.  
  393. /**Flickr Gallery **/
  394. /**USAGE:
  395. [flickr id="" type=""]
  396. **/
  397. function layersc_flickr_func( $atts, $content = null) {
  398. //extract short code attr
  399. extract(shortcode_atts(array(
  400. 'id' => '', //use http://idgettr.com/ to get you flickr userid
  401. 'count' => '9',
  402. 'photo_size'=> 'n', //n, q, s
  403. 'key'=> '',
  404. 'photoset'=> '',
  405. 'class' => '',
  406. ), $atts));
  407.  
  408. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  409.  
  410. if(!empty($photoset)) {
  411. $setid = $photoset;
  412. $setname='photosets';
  413. $setidname='photoset_id';
  414. $fetchname='photoset';
  415. }else{
  416. $setid = $id;
  417. $setname='people';
  418. $setidname='user_id';
  419. $fetchname='photos';
  420. }
  421.  
  422.  
  423. $return_html = '<div id="flickr_badge_wrapper" class="clearfix flckr_'.$photo_size.' '.$class.' '.$nonedit.'">
  424. <script type="text/javascript">
  425. (function($){
  426. var setID = "'.$setid.'";
  427. var apiKey = "'.$key.'";
  428. var itemsPerPage = '.$count.'; // Max is 500
  429. $.getJSON("https://api.flickr.com/services/rest/?&method=flickr.'.$setname.'.getPhotos&api_key=" + apiKey + "&'.$setidname.'=" + setID + "&per_page=" + itemsPerPage + "&format=json&jsoncallback=?", function(data){
  430.  
  431. var htmlOutput = "<ul class=\'pd_flick_gallery\'>";
  432. //loop through the results
  433. $.each(data.'.$fetchname.'.photo, function(i,item){
  434. // URLs
  435. var photoURL = "http://farm" + item.farm + ".static.flickr.com/" + item.server + "/" + item.id + "_" + item.secret + "_'.$photo_size.'.jpg";
  436. var linkURL = "http://farm" + item.farm + ".static.flickr.com/" + item.server + "/" + item.id + "_" + item.secret + "_b.jpg";
  437.  
  438. htmlOutput += \'<li><a href="\' + linkURL + \'" target="_blank">\';
  439. htmlOutput += \'<img title="\' + item.title + \'" src="\' + photoURL;
  440. htmlOutput += \'" alt="\' + item.title + \'" />\';
  441. htmlOutput += \'</a></li>\';
  442. });
  443. htmlOutput += "</ul><div style=\'clear:both;\'></div>";
  444.  
  445. // Assign result to a unique container
  446. $("#flickr_badge_wrapper").html(htmlOutput);
  447. $(".pd_flick_gallery li").magnificPopup({ // the containers for all your galleries
  448. delegate: "a", // the selector for gallery item
  449. type: "image",
  450. gallery: {
  451. enabled:true
  452. }
  453. });
  454. });
  455. })(jQuery);
  456. </script>
  457. </div>';
  458.  
  459. return $return_html;
  460. }
  461. add_shortcode('flickr', 'layersc_flickr_func');
  462.  
  463.  
  464.  
  465.  
  466. /**2 columns **/
  467. /**USAGE: [col2]your text[/col2]
  468. **/
  469. function layersc_col2_func( $atts, $content = null ) {
  470. extract(shortcode_atts(array('class' => '','width' => '',), $atts));
  471.  
  472.  
  473. if(is_customize_preview()){
  474. $nonedit = 'inline_shortcode';
  475. $short = 'contenteditable="true" data-shortcode="[col2 width=&quot;'.$width.'&quot;]'.str_replace('"', '&quot;', do_shortcode($content)).'[/col2]"';
  476.  
  477. }else{
  478. $nonedit = ''; $short = '';
  479. }
  480.  
  481. return '<div class="col2 shortcol '.$class.' '.$nonedit.'" data-width="'.$width.'" '.$short.'>'.do_shortcode($content).'</div>';
  482. }
  483. add_shortcode( 'col2', 'layersc_col2_func' );
  484.  
  485.  
  486. /**3 columns **/
  487. /**USAGE: [col3]your text[/col3]
  488. **/
  489. function layersc_col3_func( $atts, $content = null ) {
  490. extract(shortcode_atts(array('class' => '','width' => '',), $atts));
  491.  
  492. if(is_customize_preview()){
  493. $nonedit = 'inline_shortcode';
  494. $short = 'contenteditable="true" data-shortcode="[col3 width=&quot;'.$width.'&quot;]'.str_replace('"', '&quot;', do_shortcode($content)).'[/col3]"';
  495.  
  496. }else{
  497. $nonedit = ''; $short = '';
  498. }
  499.  
  500. return '<div class="col3 shortcol '.$class.' '.$nonedit.'" data-width="'.$width.'" '.$short.'>'.do_shortcode($content).'</div>';
  501. }
  502. add_shortcode( 'col3', 'layersc_col3_func' );
  503.  
  504.  
  505.  
  506. /**4 columns **/
  507. /**USAGE: [col4]your text[/col4]
  508. **/
  509. function layersc_col4_func( $atts, $content = null ) {
  510. extract(shortcode_atts(array('class' => '','width' => '',), $atts));
  511.  
  512. if(is_customize_preview()){
  513. $nonedit = 'inline_shortcode';
  514. $short = 'contenteditable="true" data-shortcode="[col4 width=&quot;'.$width.'&quot;]'.str_replace('"', '&quot;', do_shortcode($content)).'[/col4]"';
  515.  
  516. }else{
  517. $nonedit = ''; $short = '';
  518. }
  519.  
  520. return '<div class="col4 shortcol '.$class.' '.$nonedit.'" data-width="'.$width.'" '.$short.'>'.do_shortcode($content).'</div>';
  521. }
  522. add_shortcode( 'col4', 'layersc_col4_func' );
  523.  
  524. /**5 columns **/
  525. /**USAGE: [col5]your text[/col5]
  526. **/
  527. function layersc_col5_func( $atts, $content = null ) {
  528. extract(shortcode_atts(array('class' => '','width' => '',), $atts));
  529.  
  530. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  531.  
  532. return '<div class="col5 shortcol '.$class.' '.$nonedit.'" data-width="'.$width.'">'.do_shortcode($content).'</div>';
  533. }
  534. add_shortcode( 'col5', 'layersc_col5_func' );
  535.  
  536.  
  537. /**Tabs **/
  538. /**USAGE: [tabs titles="Tab One, Tab Two"][tab]your content[/tab][tab]your content[/tab][/tabs]
  539. **/
  540. function layersc_tabs($atts, $content = null) {
  541. extract(shortcode_atts(array(
  542. "titles" => '',
  543. "style" => '', //default, circualr, minimal, capsule
  544. "active_color"=>'#119BFF',
  545. "class" => '',
  546. ), $atts));
  547.  
  548. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  549.  
  550.  
  551. $titlearr=explode(',',$titles);
  552. $html='<div class="tabs-container lts_tabs tabs_'.$style.' '.$class.' '.$nonedit.'" data-active-color="'.$active_color.'"><ul class="tabs ">';
  553. foreach($titlearr as $title){
  554.  
  555. $html.='<li class="tabli lts_tabtitle"><a href="#" class="tabtrigger">'.$title.'</a></li>';
  556.  
  557. }
  558. $html.='</ul><div class="lts_tab">'.do_shortcode($content).'</div></div><div style="clear:both"></div>';
  559. return $html;
  560. }
  561. add_shortcode('tabs', 'layersc_tabs');
  562.  
  563. function layersc_tab($atts, $content = null) {
  564.  
  565. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  566.  
  567. return '<div class="lts_tab_child '.$nonedit.'">'.do_shortcode($content).'</div>';
  568. }
  569. add_shortcode('tab', 'layersc_tab');
  570.  
  571. /**Toggles **/
  572. /**USAGE: [toggle title="ToggleMe"]your content[/toggle]
  573. **/
  574. function layersc_toggle($atts, $content = null) {
  575. extract(shortcode_atts(array(
  576. "title" => '',
  577. "class" => '',
  578. ), $atts));
  579. $titlearr=explode(',',$title);
  580. $html='<div class="lts_toggle '.$class.'"><div class="trigger_wrap">';
  581. foreach($titlearr as $title){
  582. $html.='<a class="trigger"><i class="fa fa-plus"></i> '.$title.'</a></div>';
  583. }
  584. $html.='<div class="lts_toggle_content" style="display:none;">'.do_shortcode($content).'<div style="clear:both"></div></div></div>';
  585. return $html;
  586. }
  587. add_shortcode('toggle', 'layersc_toggle');
  588.  
  589.  
  590.  
  591. /**Custom Button Shortcode **/
  592. /**USAGE: [button class="violet"][/button]
  593. **/
  594. function layersc_button_func($atts, $content = null) {
  595.  
  596. //extract short code attr
  597. extract(shortcode_atts(array(
  598. 'text'=> '',
  599. 'url' => 'http://www.google.com',
  600. 'background_color' => '#2dcb73' ,
  601. 'text_color' => '#ffffff',
  602. 'style' => 'lt_flat', //lt_flat, lt_hollow, lt_circular
  603. 'size' => 'default', //default, large, small
  604. 'icon'=>'',
  605. 'onclick'=>'',
  606. 'open_new_window' => true,
  607. 'rounded' => 'false',
  608. 'class' => '',
  609. ), $atts));
  610.  
  611. $roundeds =''; $open_new_windows =''; $icons =''; $shortwindow =''; $shortround ='';
  612. if ($rounded == 'true'){
  613. $roundeds= 'lt_rounded';
  614. $shortround ='true';
  615. }
  616. if ($rounded == 'false'){
  617. $roundeds= '';
  618. }
  619.  
  620. if ($icon !== ''){
  621. $icons = '<i class="fa '.$icon.'"></i> ';
  622. }
  623. if ($open_new_window == 'true'){
  624. $open_new_windows= 'target="_blank"';
  625. $shortwindow ='true';
  626. }
  627. if ($open_new_window == 'false'){
  628. $open_new_windows= '';
  629. }
  630.  
  631. if ($onclick !== ''){
  632. $onclick = 'onclick='.$onclick .'';
  633. }
  634.  
  635. if(is_customize_preview()){
  636. $nonedit = 'inline_shortcode';
  637. $short = 'data-shortcode="[button text=&quot;'.$text.'&quot; url=&quot;'.$url.'&quot; background_color=&quot;'.$background_color.'&quot; text_color=&quot;'.$text_color.'&quot; style=&quot;'.$style.'&quot; size=&quot;'.$size.'&quot; icon=&quot;'.$icon.'&quot; open_new_window=&quot;'.$shortwindow.'&quot; rounded=&quot;'.$shortround.'&quot;]"';
  638. $inline = 'data-btn-text="'.$text.'" data-btn-url="'.$url.'" data-btn-bg="'.$background_color.'" data-btn-color="'.$text_color.'" data-btn-style="'.$style.'" data-btn-size="'.$size.'" data-btn-icon="'.$icon.'" data-btn-window="'.$shortwindow.'" data-btn-rounded="'.$shortround.'" data-btn-class="'.$class.'" ';
  639. $href ='';
  640. }else{
  641. $nonedit = ''; $inline ='';$short = '';
  642.  
  643. $href = 'href="'.$url.'"';
  644. }
  645.  
  646.  
  647. $return_html = '<a class="lts_button lts_button_sc lts_button_'.$size.' '.$roundeds.' '.$style.' '.$class.' '.$nonedit.'" '.$open_new_windows.' style="background:'.$background_color.';color:'.$text_color.';border-color:'.$background_color.';" '.$href.' '.$short.' '.$inline.' '.$onclick.'>'.$icons .$text.'</a>';
  648.  
  649. return $return_html;
  650. }
  651.  
  652. add_shortcode('button', 'layersc_button_func');
  653.  
  654.  
  655. /**Call to Action Shortcode **/
  656. /**USAGE: [callaction url=""][/button]
  657. **/
  658. function layersc_callaction_func($atts, $content = null) {
  659.  
  660. //extract short code attr
  661. extract(shortcode_atts(array(
  662. 'button_url' => 'http://www.google.com',
  663. 'button_text' => 'My Button',
  664. 'button_background_color' => '#e64429',
  665. 'button_text_color' => '#ffffff' ,
  666. 'background_color' => '#2dcb73' ,
  667. 'text_color' => '#ffffff',
  668. 'rounded'=> '',
  669. 'class' => '',
  670. ), $atts));
  671.  
  672. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  673.  
  674. if($rounded == 'true'){
  675. $rounded = ' lt_rounded';
  676. }else{
  677. $rounded = '';
  678. }
  679.  
  680. $return_html = '<div style="background:'.$background_color.';color:'.$text_color.'!important;" class="ast_shrt_action'.$rounded.' '.$class.' '.$nonedit.'"><div class="act_left">'.$content.'</div><div class="act_right"><a class="'.$rounded.'" style="background:'.$button_background_color.';color:'.$button_text_color.'!important;" href="'.$button_url.'">'.$button_text.'</a></div></div><div style="clear:both"></div>';
  681.  
  682. return $return_html;
  683. }
  684.  
  685. add_shortcode('callaction', 'layersc_callaction_func');
  686.  
  687. /**Table Shortcode **/
  688. /**USAGE: [table]
  689. **/
  690. function layersc_table_func( $atts ) {
  691. extract( shortcode_atts( array(
  692. 'cols' => 'none',
  693. 'data' => 'none',
  694. 'class' => '',
  695. ), $atts ) );
  696.  
  697. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  698.  
  699. $cols = explode(',',$cols);
  700. $data = explode(',',$data);
  701. $total = count($cols);
  702. $output = "";
  703. $output .= '<table class="ast_table '.$class.' '.$nonedit.'"><tr class="th">';
  704. foreach($cols as $col):
  705. $output .= '<td>'.$col.'</td>';
  706. endforeach;
  707. $output .= '</tr><tr>';
  708. $counter = 1;
  709. foreach($data as $datum):
  710. $output .= '<td>'.$datum.'</td>';
  711. if($counter%$total==0):
  712. $output .= '</tr>';
  713. endif;
  714. $counter++;
  715. endforeach;
  716. $output .= '</table>';
  717. return $output;
  718. }
  719. add_shortcode( 'table', 'layersc_table_func' );
  720.  
  721.  
  722.  
  723. /**Featured Image SHORTCODE **/
  724. /** [featimage align="left"]**/
  725. function layersc_featimage($atts) {
  726.  
  727. //extract short code attr
  728. extract(shortcode_atts(array('align' => 'alignleft', 'size'=>'full', 'class' => '',), $atts));
  729.  
  730. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  731.  
  732. if (has_post_thumbnail() ) {
  733. $image_id = get_post_thumbnail_id();
  734. $image_url = wp_get_attachment_image_src($image_id, $size);
  735. $image_url = $image_url[0];
  736. $result = '<div class="'.$class.' '.$nonedit.'" style="width:100%;"><img src="'.$image_url.'" class="'.$align.'" /><div style="clear:both"></div></div>';
  737. return $result;
  738. }
  739. return;
  740. }
  741.  
  742. add_shortcode('featimage', 'layersc_featimage');
  743.  
  744.  
  745. /**ToolTip **/
  746. /**USAGE: [tooltip]Your Tooltip text here[/tooltip]**/
  747. function layersc_tooltip( $atts, $content = null ) {
  748. extract(shortcode_atts(array('tipcontent' => '', 'class' => '',), $atts));
  749.  
  750. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  751.  
  752. return '<span class="tooltip lts_tooltip '.$class.' '.$nonedit.'" title="'.$tipcontent.'">'.do_shortcode($content).'</span>';
  753. }
  754. add_shortcode( 'tooltip', 'layersc_tooltip' );
  755.  
  756.  
  757. /**Drop Cap **/
  758. /**USAGE: [drop_cap]Your Drop Cap text here[/drop_cap]**/
  759. function layersc_dropcap( $atts, $content = null ) {
  760. extract(shortcode_atts(array('color' => '#fff' , 'background' => '#2dcb73', 'class' => '',), $atts));
  761.  
  762. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  763.  
  764. return '<span style="color:'.$color.';background:'.$background.';" class="lts_dropcap '.$class.' '.$nonedit.'">'.do_shortcode($content).'</span>';
  765. }
  766. add_shortcode( 'drop_cap', 'layersc_dropcap' );
  767.  
  768.  
  769. /**PROGRESS BAR **/
  770. /**USAGE: [progress percent="40"]**/
  771. function layersc_progress( $atts, $content = null ) {
  772. extract(shortcode_atts(array(
  773. 'title' => '' ,
  774. 'percent' => '70' ,
  775. 'style' => 'bold' , //bold, thin, circular
  776. 'color' => '#fff' ,
  777. 'background' => '#2dcb73',
  778. 'rounded'=> "false",
  779. 'stripes'=> "true",
  780. 'class' => '',
  781. ), $atts));
  782.  
  783. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  784.  
  785. if($rounded == "true"){
  786. $rounded = 'progress_rounded';
  787. }else{
  788. $rounded = '';
  789. }
  790.  
  791. if($stripes == "true"){
  792. $stripes = ' progress_stripes';
  793. }else{
  794. $stripes = '';
  795. }
  796.  
  797. if(!empty($title)){$title = '<div class="progress_title">'.do_shortcode($title).'</div>'; }else{ $title = ''; }
  798.  
  799. if($style == "circular"){ $circular = '<div class="circle_progress" data-progress="'.($percent/100).'" data-background="'.$background.'"><strong>'.$percent.'%</strong></div>'.$title;}else{ $circular = '';}
  800.  
  801. return '<div class="progressbar_wrap progress_'.$style.' '.$nonedit.'">'.$title.'<div class="lts_progress '.$rounded. $stripes.' '.$class.'"><span>'.$percent.'%</span><div class="lts_progress_wrap"><div title="'.$percent.'%" class="lts_progress_inner tooltip" style="width:'.$percent.'%;color:'.$color.';background-color:'.$background.';"></div></div></div>'.$circular.'</div>';
  802.  
  803.  
  804. }
  805. add_shortcode( 'progress', 'layersc_progress' );
  806.  
  807. /**Section SHORTCODE **/
  808. /**USAGE: [section]Your Content[/section]**/
  809. function layersc_section( $atts, $content = null ) {
  810. extract(shortcode_atts(array('background_image' => '', 'text_color' => '#666666','background_color' => '#eeeeee','class'=> '',), $atts));
  811.  
  812. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  813.  
  814. if(!empty($background_image)){
  815. $background_image= 'background-image:url('.$background_image.')';
  816. }
  817. return '<div style="background-color:'.$background_color.'; color:'.$text_color.';'.$background_image.'" class="lts_section '.$class.' '.$nonedit.'"><div class="lts_section_body">'.do_shortcode($content).'</div></div>';
  818. }
  819. add_shortcode( 'section', 'layersc_section' );
  820.  
  821.  
  822. /**Block Shortcode **/
  823. /**USAGE: [block width="full" background="#ffffff" text_color="#555" shadow="true"]Your Content[/block]**/
  824. function layersc_block( $atts, $content = null ) {
  825. extract(shortcode_atts(array(
  826. 'text_color' => '#999999',
  827. 'background' => '#ffffff',
  828. 'shadow'=> false,
  829. 'rounded'=> false,
  830. 'class'=> '',
  831. ), $atts));
  832.  
  833. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  834.  
  835. if($shadow !==''){
  836. $shadow = '';
  837. }else{
  838. $shadow = 'lt_shadow';
  839. }
  840.  
  841. if($rounded =='true'){
  842. $rounded = 'lt_rounded';
  843. }else{
  844. $rounded = '';
  845. }
  846.  
  847. return '<div class="lts_block '.$shadow.' '.$rounded.' '.$class.' '.$nonedit.'" style="background:'.$background.';color:'.$text_color.';">'.do_shortcode($content).'</div>';
  848. }
  849. add_shortcode( 'block', 'layersc_block' );
  850.  
  851. function layersc_blocks( $atts, $content = null ) {
  852. extract(shortcode_atts(array(
  853. 'layout' => 'layout1',
  854. 'class'=> '',
  855. ), $atts));
  856.  
  857. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  858.  
  859. return '<div class="lts_blocks lts_blocks_'.$layout.' '.$class.' '.$nonedit.'">'.do_shortcode($content).'</div>';
  860. }
  861. add_shortcode( 'blocks', 'layersc_blocks' );
  862.  
  863.  
  864.  
  865. /**PANEL SHORTCODE **/
  866. /**USAGE: [panel title="Your Panel Title"]Your Content[/panel]**/
  867. function layersc_panel( $atts, $content = null ) {
  868. extract(shortcode_atts(array('title' => '', 'text_color' => '#ffffff','background_color' => '#428bca','class'=> '',), $atts));
  869.  
  870. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  871.  
  872. return '<div style="border-color:'.$background_color.'" class="lts_panel '.$class.' '.$nonedit.'"><h3 style="background-color:'.$background_color.';color:'.$text_color.'">'.$title.'</h3><div class="lts_panel_body">'.do_shortcode($content).'<div style="clear:both"></div></div></div>';
  873. }
  874. add_shortcode( 'panel', 'layersc_panel' );
  875.  
  876.  
  877.  
  878. /**ABOUT AUTHOR SHORTCODE **/
  879. /**USAGE: [author name="Jane Doe" image="" facebook="" twitter="" google="" linkedin="" website=""]Author bio[/author]**/
  880. function layersc_author( $atts, $content = null ) {
  881. extract(shortcode_atts(array(
  882. 'name' => '',
  883. 'name_text_color' => '#428bca',
  884. 'background' => '',
  885. 'image' => '',
  886. 'facebook' => '',
  887. 'twitter' => '',
  888. 'google' => '',
  889. 'linkedin' => '',
  890. 'website' => '',
  891. 'class' => '',
  892. ), $atts));
  893.  
  894. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  895.  
  896. if($image !==''){$image ='<div class="author_image"><img src="'.$image.'" alt="'.$name.'" title="'.$name.'" /></div>'; }else{ $image =''; }
  897.  
  898. if($facebook !==''){ $facebook ='<a href="'.esc_url($facebook).'"><i class="fa fa-facebook-square"></i></a>'; }else{ $facebook =''; }
  899. if($twitter !==''){ $twitter ='<a href="'.esc_url($twitter).'"><i class="fa fa-twitter-square"></i></a>'; }else{ $twitter =''; }
  900. if($google !==''){ $google ='<a href="'.esc_url($google).'"><i class="fa fa-google-plus-square"></i></a>'; }else{ $google =''; }
  901. if($linkedin !==''){ $linkedin ='<a href="'.esc_url($linkedin).'"><i class="fa fa-linkedin-square"></i></a>'; }else{ $linkedin =''; }
  902. if($website !==''){ $website ='<a href="'.esc_url($website).'"><i class="fa fa-globe"></i></a>'; }else{ $website =''; }
  903.  
  904. return '
  905. <div class="lts_author '.$class.' '.$nonedit.'" style="background:'.$background.'">
  906. '.$image.'
  907. <div class="author_content">
  908. <h5 style="color:'.$name_text_color.'">'.$name.'</h5>
  909. <div class="lts_author_body">'.do_shortcode($content).'
  910. <p class="athor_social">'.$facebook. $twitter .$google .$linkedin .$website.'</p>
  911. </div>
  912. </div>
  913. </div>';
  914. }
  915. add_shortcode( 'author', 'layersc_author' );
  916.  
  917.  
  918. /**CAROUSEL SHORTCODE **/
  919. /**USAGE: [carousel border_style="thick"][carousel_item]Your HTML Content Here[/carousel_item][/carousel]**/
  920. function layersc_carousel( $atts, $content = null ) {
  921. extract(shortcode_atts(array(
  922. 'style' => 'default', //default or thick_border
  923. 'background' => '#ffffff',
  924. 'button_color'=> '#eeeeee;',
  925. 'text_color' => '#999999',
  926. 'class' => '',
  927. ), $atts));
  928.  
  929. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  930.  
  931. return '
  932. <div class="looper slide lts_looper lts_'.$style.' '.$class.' '.$nonedit.'" data-looper="go" data-interval="6000" data-buttoncolor="'.$button_color.'" style="background:'.$background.';color:'.$text_color.'">
  933. <div class="looper-inner">
  934. '.do_shortcode($content).'
  935. </div>
  936. <nav>
  937. <ul class="looper-nav"></ul>
  938. </nav>
  939. </div>
  940. ';
  941. }
  942. add_shortcode( 'carousel', 'layersc_carousel' );
  943.  
  944. function layersc_carousel_item( $atts, $content = null ) {
  945.  
  946. return '<div class="item">'.do_shortcode($content).'</div>';
  947. }
  948. add_shortcode( 'carousel_item', 'layersc_carousel_item' );
  949.  
  950.  
  951. /**Section SHORTCODE **/
  952. /**USAGE: [search label="Search" text_color="#ffffff" background_color="#333333"]**/
  953. function layersc_searchform( $atts, $content = null ) {
  954. extract(shortcode_atts(array('label' => 'Search', 'text_color' => '#666666','background_color' => '#eeeeee','class'=> '',), $atts));
  955.  
  956. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  957.  
  958. return '<form role="search" method="get" class="lts_search-form '.$class.' '.$nonedit.'" action="'.home_url( '/' ).'">
  959. <input type="search" class="search-field" placeholder="'.$label.'" value="'.get_search_query().'" name="s" />
  960. <input type="submit" class="search-submit" value="'.$label.'" style="color:'.$text_color.';background:'.$background_color.';"/></form>';
  961.  
  962. }
  963. add_shortcode( 'searchform', 'layersc_searchform' );
  964.  
  965.  
  966.  
  967. /**PRICING SHORTCODE **/
  968. /**USAGE: [pricing background="#ffffff" text_color="#999" button_color="#8ab71b"][pricebox]Your HTML Content Here[/pricebox][/pricing]**/
  969. function layersc_pricing( $atts, $content = null ) {
  970. extract(shortcode_atts(array(
  971. 'background' => '#ffffff',
  972. 'text_color' => '#999999',
  973. 'button_bg_color' => '#8ab71b',
  974. 'button_text_color' => '#ffffff',
  975. 'style' => '1',
  976. 'class' => '',
  977. ), $atts));
  978.  
  979. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  980.  
  981. return '
  982. <div class="lts_pricing '.$class.' '.$nonedit.' pricing_style'.$style.'" style="color:'.$text_color.'" data-button-bg="'.$button_bg_color.'" data-button-txt="'.$button_text_color.'" data-price-bg="'.$background.'" data-price-txt="'.$text_color.'">
  983. '.do_shortcode($content).'
  984. </div>
  985. ';
  986. }
  987. add_shortcode( 'pricing', 'layersc_pricing' );
  988.  
  989. function layersc_pricebox( $atts, $content = null ) {
  990. extract(shortcode_atts(array(
  991. 'name' => 'Package1',
  992. 'price' => '$30',
  993. 'price_label'=> 'month',
  994. 'description' => '',
  995. 'features'=>'',
  996. 'button_text'=>'Signup',
  997. 'button_link'=>'',
  998. 'featured'=> '',
  999. ), $atts));
  1000.  
  1001. if($price_label !==''){
  1002. $price_label = '<span class="price_label">/'.$price_label.'</span>';
  1003. }else{
  1004. $price_label = '';
  1005. }
  1006.  
  1007. if($featured !==''){
  1008. $featured = '<span class="feat_wrap"><span class="pricebox_featured">'.$featured.'</span></span>';
  1009. }else{
  1010. $featured = '';
  1011. }
  1012.  
  1013. if($name !==''){
  1014. return '
  1015. <div class="pricebox"><div class="pricebox_inner">
  1016. '.$featured.'
  1017. <div class="price_head">
  1018. <h3>'.$name.'</h3>
  1019. <span class="price_ammount">'.$price.'</span>'.$price_label.'
  1020. <p class="price_desc">'.do_shortcode($description).'</p>
  1021. </div>
  1022. <div class="price_body">'.do_shortcode($features).'</div>
  1023. <div class="price_footer"><a href="'.$button_link.'" class="price_button">'.$button_text.'</a></div>
  1024. </div></div>';
  1025. }
  1026. }
  1027. add_shortcode( 'pricebox', 'layersc_pricebox' );
  1028.  
  1029. /**Lightbox Shortcode **/
  1030. /**USAGE: [lightbox button_text="Check This Out"] Your content that you want to display in a lightbox [/lightbox]
  1031. **/
  1032. function layersc_lightbox_func($atts, $content) {
  1033.  
  1034. //extract short code attr
  1035. extract(shortcode_atts(array(
  1036. 'button_text' => '',
  1037. 'button_text_color' => '',
  1038. 'button_text_bg' => '',
  1039. 'button_font_size' => '',
  1040. 'button_style' => 'lt_flat', //lt_flat, lt_hollow, lt_circular
  1041. 'button_size' => 'medium', //medium, large, small
  1042. 'rounded'=>'true',
  1043. 'image'=>'',
  1044. 'class' => '',
  1045. ), $atts));
  1046.  
  1047. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  1048.  
  1049. if ($button_text_color !== ''){
  1050. $button_text_color= 'color:'.$button_text_color.';';
  1051. }
  1052. if ($button_text_bg !== ''){
  1053. $button_text_bg= 'background:'.$button_text_bg.';';
  1054. }
  1055. if ($button_font_size !== ''){
  1056. $button_font_size= 'font-size:'.$button_font_size.';';
  1057. }
  1058. if ($rounded == 'true'){
  1059. $rounded= 'lt_rounded';
  1060. }else{
  1061. $rounded= '';
  1062. }
  1063. $hasimg = '';
  1064. if (!empty($image)){
  1065. $button_text = '<img src="'.$image.'" />';
  1066. $hasimg = 'ltbximg';
  1067. }
  1068.  
  1069.  
  1070.  
  1071. $return_html = '<span style="'.$button_text_color. $button_text_bg .$button_font_size.'" class="lts_lightbox_bttn lt_animate '.$rounded.' '.$button_style.' '.'lts_button_'.$button_size.' '.$class.' '.$nonedit.' '.$hasimg.'">'.$button_text.'</span><div style="display:none" class="lts_lightbox_content">'.do_shortcode($content).'</div>';
  1072.  
  1073.  
  1074. return $return_html;
  1075. }
  1076. add_shortcode('lightbox', 'layersc_lightbox_func');
  1077.  
  1078.  
  1079.  
  1080.  
  1081. /**MAP SHORTCODE **/
  1082. /**USAGE: [map latitude="53.359286" longitude="-2.040904" text="This Text Appears when you hover over the bubble"]**/
  1083. function layersc_map( $atts, $content = null ) {
  1084. global $optimizer;
  1085. if(!empty($optimizer['map_api'])){ $mapkey = 'https://maps.googleapis.com/maps/api/js?key='.$optimizer['map_api'].''; }else{ $mapkey = 'https://maps.googleapis.com/maps/api/js?sensor=false';}
  1086.  
  1087. wp_enqueue_script('optimizer_map',get_template_directory_uri().'/assets/js/map-styles.js', array('jquery'),'1.0', true);
  1088. wp_enqueue_script('optimizer_googlemaps', $mapkey, array('jquery'),'1.0', true);
  1089. extract(shortcode_atts(array(
  1090. 'latitude' => '53.359286' ,
  1091. 'longitude' => '-2.040904',
  1092. 'text' => 'Your Location Details.',
  1093. 'height' => '300px',
  1094. 'class' => '',
  1095. ), $atts));
  1096.  
  1097. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  1098.  
  1099. return '<div class="lts_map_wrap '.$class.' '.$nonedit.'" style="height:'.$height.'"><div data-map-lat="'.$latitude.'" data-map-long="'.$longitude.'" data-map-text="'.$text.'" class="lts_map"></div></div>';
  1100.  
  1101. }
  1102. add_shortcode( 'map', 'layersc_map' );
  1103.  
  1104.  
  1105. /**ICON SHORTCODE **/
  1106. /**USAGE: [icon type="fa-star" color="#999999" size="20px"]**/
  1107. function layersc_icon( $atts, $content = null ) {
  1108. extract(shortcode_atts(array(
  1109. 'type' => 'fa-star',
  1110. 'color'=> '',
  1111. 'size'=> '',
  1112. 'style'=> '', //plain, circle_thin, circle_thick, circle_color, square_thin, square_thick, square_color
  1113. 'link'=> '',
  1114. 'new_window'=> 'true',
  1115. 'class' => '',
  1116. ), $atts));
  1117.  
  1118. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  1119.  
  1120. $widthheight = '';
  1121. $bgcolor = '';
  1122. $linkstart = '';
  1123. $linkend = '';
  1124.  
  1125. if ( $style !== '' || $style !== 'plain'){
  1126. $widthheight = 'width:'.$size.';height:'.$size.';';
  1127. }
  1128.  
  1129. if($style == 'circle_color' || $style == 'square_color'){
  1130. $bgcolor = 'background:'.$color.';';
  1131. }
  1132. if ( $link !== '' ){
  1133. if($new_window == 'true'){
  1134. $linkstart = '<a target="_blank" href="'.esc_url($link ).'">';
  1135. }else{
  1136. $linkstart = '<a href="'.esc_url($link ).'">';
  1137. }
  1138. $linkend = '</a>';
  1139. }
  1140.  
  1141.  
  1142. return ''.$linkstart.'<i style="color:'.$color.';font-size:'.$size.';'.$widthheight.' '.$bgcolor.'" class="fa '.$type.' '.$class.' icon_style_'.$style.' '.$nonedit.'"></i>'.$linkend.'';
  1143. }
  1144. add_shortcode( 'icon', 'layersc_icon' );
  1145.  
  1146. /**CUSTOM HEADLINE SHORTCODE **/
  1147. /**USAGE: [headline type="type1"][/headline]**/
  1148. function layersc_headline( $atts, $content = null ) {
  1149. extract(shortcode_atts(array(
  1150. 'type' => 'type1',
  1151. 'color'=> '#999999',
  1152. 'text'=> '',
  1153. 'size' => 'h2',
  1154. 'class' => '',
  1155. ), $atts));
  1156.  
  1157. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  1158.  
  1159. return '<'.$size.' class="lts_headline_parent lts_headline_'.$type.' '.$class.' '.$nonedit.'"><span style="color:'.$color.';" class="lts_headline headline_'.$type.'">'.do_shortcode($content).'</span></'.$size.'>';
  1160. }
  1161. add_shortcode( 'headline', 'layersc_headline' );
  1162.  
  1163.  
  1164.  
  1165. /**
  1166. * @package Display Posts
  1167. * @version 2.4
  1168. * @author Bill Erickson <bill@billerickson.net>
  1169. * @copyright Copyright (c) 2011, Bill Erickson
  1170. * @link http://www.billerickson.net/shortcode-to-display-posts/
  1171. * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  1172. */
  1173.  
  1174. // Create the shortcode
  1175. add_shortcode( 'display-posts', 'optimizer_display_posts_shortcode' );
  1176. function optimizer_display_posts_shortcode( $atts ) {
  1177.  
  1178. // Original Attributes, for filters
  1179. $original_atts = $atts;
  1180.  
  1181. // Pull in shortcode attributes and set defaults
  1182. $atts = shortcode_atts( array(
  1183. 'title' => '',
  1184. 'author' => '',
  1185. 'category' => '',
  1186. 'layout' => 'layout1',
  1187. 'date_format' => 'F jS, Y ',
  1188. 'display_posts_off' => false,
  1189. 'exclude_current' => true,
  1190. 'id' => false,
  1191. 'ignore_sticky_posts' => false,
  1192. 'image_size' => 'large',
  1193. 'include_title' => true,
  1194. 'include_author' => false,
  1195. 'include_content' => false,
  1196. 'include_date' => false,
  1197. 'include_excerpt' => true,
  1198. 'meta_key' => '',
  1199. 'meta_value' => '',
  1200. 'no_posts_message' => '',
  1201. 'offset' => 0,
  1202. 'order' => 'DESC',
  1203. 'orderby' => 'date',
  1204. 'post_parent' => false,
  1205. 'post_status' => 'publish',
  1206. 'post_type' => 'post',
  1207. 'posts_per_page' => '10',
  1208. 'tag' => '',
  1209. 'tax_operator' => 'IN',
  1210. 'tax_term' => false,
  1211. 'taxonomy' => false,
  1212. 'wrapper' => 'div',
  1213. 'wrapper_class' => 'display-posts-listing',
  1214. 'class' => '',
  1215. 'wrapper_id' => false,
  1216. ), $atts, 'display-posts' );
  1217.  
  1218.  
  1219. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  1220.  
  1221. // End early if shortcode should be turned off
  1222. if( $atts['display_posts_off'] )
  1223. return;
  1224.  
  1225. $shortcode_title = sanitize_text_field( $atts['title'] );
  1226. $author = sanitize_text_field( $atts['author'] );
  1227. $category = sanitize_text_field( $atts['category'] );
  1228. $layout = sanitize_text_field( $atts['layout'] );
  1229. $date_format = sanitize_text_field( $atts['date_format'] );
  1230. $exclude_current = optimizer_display_posts_bool( $atts['exclude_current'] );
  1231. $id = $atts['id']; // Sanitized later as an array of integers
  1232. $ignore_sticky_posts = optimizer_display_posts_bool( $atts['ignore_sticky_posts'] );
  1233. $image_size = sanitize_key( $atts['image_size'] );
  1234. $include_title = optimizer_display_posts_bool( $atts['include_title'] );
  1235. $include_author = optimizer_display_posts_bool( $atts['include_author'] );
  1236. $include_content = optimizer_display_posts_bool( $atts['include_content'] );
  1237. $include_date = optimizer_display_posts_bool( $atts['include_date'] );
  1238. $include_excerpt = optimizer_display_posts_bool( $atts['include_excerpt'] );
  1239. $meta_key = sanitize_text_field( $atts['meta_key'] );
  1240. $meta_value = sanitize_text_field( $atts['meta_value'] );
  1241. $no_posts_message = sanitize_text_field( $atts['no_posts_message'] );
  1242. $offset = intval( $atts['offset'] );
  1243. $order = sanitize_key( $atts['order'] );
  1244. $orderby = sanitize_key( $atts['orderby'] );
  1245. $post_parent = $atts['post_parent']; // Validated later, after check for 'current'
  1246. $post_status = $atts['post_status']; // Validated later as one of a few values
  1247. $post_type = sanitize_text_field( $atts['post_type'] );
  1248. $posts_per_page = intval( $atts['posts_per_page'] );
  1249. $tag = sanitize_text_field( $atts['tag'] );
  1250. $tax_operator = $atts['tax_operator']; // Validated later as one of a few values
  1251. $tax_term = sanitize_text_field( $atts['tax_term'] );
  1252. $taxonomy = sanitize_key( $atts['taxonomy'] );
  1253. $wrapper = sanitize_text_field( $atts['wrapper'] );
  1254. $wrapper_class = sanitize_html_class( $atts['wrapper_class'] );
  1255. $class = sanitize_html_class( $atts['class'] );
  1256.  
  1257. if( !empty( $wrapper_class ) )
  1258. $wrapper_class = ' class="' . $wrapper_class . ' lts_'.$layout.' '.$class.'"';
  1259. $wrapper_id = sanitize_html_class( $atts['wrapper_id'] );
  1260. if( !empty( $wrapper_id ) )
  1261. $wrapper_id = ' id="' . $wrapper_id . '"';
  1262.  
  1263. //If Category null display empty\
  1264. if($category =='null'){
  1265. $category='';
  1266. }
  1267. //If tag null display empty\
  1268. if($tag =='null'){
  1269. $tag='';
  1270. }
  1271. //If post_type null display empty\
  1272. if($post_type =='null'){
  1273. $post_type='';
  1274. }
  1275.  
  1276. // Set up initial query for post
  1277. $args = array(
  1278. 'category_name' => $category,
  1279. 'order' => $order,
  1280. 'orderby' => $orderby,
  1281. 'post_type' => explode( ',', $post_type ),
  1282. 'posts_per_page' => $posts_per_page,
  1283. 'tag' => $tag,
  1284. );
  1285.  
  1286.  
  1287.  
  1288. // Ignore Sticky Posts
  1289. if( $ignore_sticky_posts )
  1290. $args['ignore_sticky_posts'] = true;
  1291.  
  1292. // Meta key (for ordering)
  1293. if( !empty( $meta_key ) )
  1294. $args['meta_key'] = $meta_key;
  1295.  
  1296. // Meta value (for simple meta queries)
  1297. if( !empty( $meta_value ) )
  1298. $args['meta_value'] = $meta_value;
  1299.  
  1300. // If Post IDs
  1301. if( $id ) {
  1302. $posts_in = array_map( 'intval', explode( ',', $id ) );
  1303. $args['post__in'] = $posts_in;
  1304. }
  1305.  
  1306. // If Exclude Current
  1307. if( $exclude_current )
  1308. $args['post__not_in'] = array( get_the_ID() );
  1309.  
  1310. // Post Author
  1311. if( !empty( $author ) )
  1312. $args['author_name'] = $author;
  1313.  
  1314. // Offset
  1315. if( !empty( $offset ) )
  1316. $args['offset'] = $offset;
  1317.  
  1318. // Post Status
  1319. $post_status = explode( ', ', $post_status );
  1320. $validated = array();
  1321. $available = array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash', 'any' );
  1322. foreach ( $post_status as $unvalidated )
  1323. if ( in_array( $unvalidated, $available ) )
  1324. $validated[] = $unvalidated;
  1325. if( !empty( $validated ) )
  1326. $args['post_status'] = $validated;
  1327.  
  1328.  
  1329. // If taxonomy attributes, create a taxonomy query
  1330. if ( !empty( $taxonomy ) && !empty( $tax_term ) ) {
  1331.  
  1332. // Term string to array
  1333. $tax_term = explode( ', ', $tax_term );
  1334.  
  1335. // Validate operator
  1336. if( !in_array( $tax_operator, array( 'IN', 'NOT IN', 'AND' ) ) )
  1337. $tax_operator = 'IN';
  1338.  
  1339. $tax_args = array(
  1340. 'tax_query' => array(
  1341. array(
  1342. 'taxonomy' => $taxonomy,
  1343. 'field' => 'slug',
  1344. 'terms' => $tax_term,
  1345. 'operator' => $tax_operator
  1346. )
  1347. )
  1348. );
  1349.  
  1350. // Check for multiple taxonomy queries
  1351. $count = 2;
  1352. $more_tax_queries = false;
  1353. while(
  1354. isset( $original_atts['taxonomy_' . $count] ) && !empty( $original_atts['taxonomy_' . $count] ) &&
  1355. isset( $original_atts['tax_' . $count . '_term'] ) && !empty( $original_atts['tax_' . $count . '_term'] )
  1356. ):
  1357.  
  1358. // Sanitize values
  1359. $more_tax_queries = true;
  1360. $taxonomy = sanitize_key( $original_atts['taxonomy_' . $count] );
  1361. $terms = explode( ', ', sanitize_text_field( $original_atts['tax_' . $count . '_term'] ) );
  1362. $tax_operator = isset( $original_atts['tax_' . $count . '_operator'] ) ? $original_atts['tax_' . $count . '_operator'] : 'IN';
  1363. $tax_operator = in_array( $tax_operator, array( 'IN', 'NOT IN', 'AND' ) ) ? $tax_operator : 'IN';
  1364.  
  1365. $tax_args['tax_query'][] = array(
  1366. 'taxonomy' => $taxonomy,
  1367. 'field' => 'slug',
  1368. 'terms' => $terms,
  1369. 'operator' => $tax_operator
  1370. );
  1371.  
  1372. $count++;
  1373.  
  1374. endwhile;
  1375.  
  1376. if( $more_tax_queries ):
  1377. $tax_relation = 'AND';
  1378. if( isset( $original_atts['tax_relation'] ) && in_array( $original_atts['tax_relation'], array( 'AND', 'OR' ) ) )
  1379. $tax_relation = $original_atts['tax_relation'];
  1380. $args['tax_query']['relation'] = $tax_relation;
  1381. endif;
  1382.  
  1383. $args = array_merge( $args, $tax_args );
  1384. }
  1385.  
  1386. // If post parent attribute, set up parent
  1387. if( $post_parent ) {
  1388. if( 'current' == $post_parent ) {
  1389. global $post;
  1390. $post_parent = get_the_ID();
  1391. }
  1392. $args['post_parent'] = intval( $post_parent );
  1393. }
  1394.  
  1395. // Set up html elements used to wrap the posts.
  1396. // Default is ul/li, but can also be ol/li and div/div
  1397. $wrapper_options = array( 'ul', 'ol', 'div' );
  1398. if( ! in_array( $wrapper, $wrapper_options ) )
  1399. $wrapper = 'ul';
  1400. $inner_wrapper = 'div' == $wrapper ? 'div' : 'li';
  1401.  
  1402.  
  1403. $listing = new WP_Query( apply_filters( 'display_posts_shortcode_args', $args, $original_atts ) );
  1404. if ( ! $listing->have_posts() )
  1405. return apply_filters( 'display_posts_shortcode_no_results', wpautop( $no_posts_message ) );
  1406.  
  1407. $inner = '';
  1408. $cats = '';
  1409. while ( $listing->have_posts() ): $listing->the_post(); global $post;
  1410.  
  1411. $image = $date = $author = $excerpt = $content = '';
  1412.  
  1413. if ( $include_title )
  1414. if( $layout == 'layout1'){
  1415. $title = '<h2 class="lt_animate"><a class="title" href="' . apply_filters( 'the_permalink', get_permalink() ) .'">'. get_the_title() .'</a></h2>';
  1416. }else{
  1417. $title = '<h2 class="lt_animate"><a class="title" href="' . apply_filters( 'the_permalink', get_permalink() ) .'">' . get_the_title().'</a></h2>';
  1418. }
  1419.  
  1420. if( $layout !== 'layout5'){
  1421. if ( $image_size && has_post_thumbnail() )
  1422. $image = '<div class="img_wrap"><div class="icon_wrap animated fadeInUp"><a href="' . get_permalink() . '"><i class="fa fa-plus"></i></a></div><a class="image" href="' . get_permalink() . '">' . get_the_post_thumbnail( get_the_ID(), $image_size ) . '</a></div>';
  1423.  
  1424. if ( !has_post_thumbnail() && optimizer_first_image() !== '')
  1425. $image = '<div class="img_wrap"><a href="' . get_permalink() . '"><i class="optimizer_plus">+</i></a><a class="image" href="' . get_permalink() . '"><img src="' . optimizer_first_image('large'). '" /></a></div>';
  1426.  
  1427. if ( $image_size && !has_post_thumbnail() && optimizer_first_image() == '')
  1428. $image = '<div class="img_wrap"><a href="' . get_permalink() . '"><i class="optimizer_plus">+</i></a><a class="image" href="' . get_permalink() . '"><img src="' . optimizer_placeholder_image(). '" width="500" height="350" /></a></div>';
  1429. }
  1430.  
  1431. if( $layout == 'layout4' || $layout == 'layout5' )
  1432. $date = ' <span class="lt_date"><i class="fa-calendar"></i> ' . get_the_date( $date_format ) . '</span>';
  1433.  
  1434. if( $layout == 'layout4' || $layout == 'layout5' )
  1435. $author = apply_filters( 'display_posts_shortcode_author', ' <span class="lt_author"><i class="fa-user"></i> ' . get_the_author() . '</span>' );
  1436.  
  1437. if( $layout == 'layout4' || $layout == 'layout5' )
  1438. $cats = apply_filters( 'display_posts_shortcode_author', ' <div class="lt_cats"><i class="fa-th-list"></i> ' . get_the_category_list() . '</div>' );
  1439.  
  1440. if ( $include_excerpt )
  1441. if($layout == 'layout2' || $layout == 'layout3'){
  1442. $excerpt = '<span class="excerpt">' . wp_trim_words( strip_shortcodes($post->post_content), 18) . '</span>';
  1443. }
  1444. if($layout == 'layout4'){
  1445. $excerpt = '<span class="excerpt">' . wp_trim_words( strip_shortcodes($post->post_content), 55). '</span><div class="blog_mo"><a href="' . get_permalink() . '">'.__('+ Read More', 'optimizer').'</a></div>';
  1446. }
  1447.  
  1448. if( $include_content || $layout == 'layout5' ) {
  1449. add_filter( 'shortcode_atts_display-posts', 'optimizer_display_posts_off', 10, 3 );
  1450. $content = '<div class="lt_content">' . apply_filters( 'the_content', get_the_content() ) . '</div>';
  1451. remove_filter( 'shortcode_atts_display-posts', 'optimizer_display_posts_off', 10, 3 );
  1452. }
  1453.  
  1454. $class = array( 'listing-item' );
  1455. $class = sanitize_html_class( apply_filters( 'display_posts_shortcode_post_class', $class, $post, $listing, $original_atts ) );
  1456. $output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">'. $image . $title . $date . $author . $cats . $excerpt . $content . '</' . $inner_wrapper . '>';
  1457.  
  1458. // If post is set to private, only show to logged in users
  1459. if( 'private' == get_post_status( get_the_ID() ) && !current_user_can( 'read_private_posts' ) )
  1460. $output = '';
  1461.  
  1462. $inner .= apply_filters( 'display_posts_shortcode_output', $output, $original_atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class );
  1463.  
  1464. endwhile; wp_reset_postdata();
  1465.  
  1466. $open = apply_filters( 'display_posts_shortcode_wrapper_open', '<' . $wrapper . $wrapper_class . $wrapper_id . '>', $original_atts );
  1467. $close = apply_filters( 'display_posts_shortcode_wrapper_close', '</' . $wrapper . '>', $original_atts );
  1468.  
  1469. $return = $open;
  1470.  
  1471. if( $shortcode_title ) {
  1472.  
  1473. $title_tag = apply_filters( 'display_posts_shortcode_title_tag', 'h2', $original_atts );
  1474.  
  1475. $return .= '<' . $title_tag . ' class="display-posts-title">' . $shortcode_title . '</' . $title_tag . '>' . "\n";
  1476. }
  1477.  
  1478. $return .= $inner . $close;
  1479.  
  1480. return $return;
  1481. }
  1482.  
  1483.  
  1484. /**
  1485. * Turn off display posts shortcode
  1486. * If display full post content, any uses of [display-posts] are disabled
  1487. *
  1488. * @param array $out, returned shortcode values
  1489. * @param array $pairs, list of supported attributes and their defaults
  1490. * @param array $atts, original shortcode attributes
  1491. * @return array $out
  1492. */
  1493. function optimizer_display_posts_off( $out, $pairs, $atts ) {
  1494. $out['display_posts_off'] = apply_filters( 'display_posts_shortcode_inception_override', true );
  1495. return $out;
  1496. }
  1497.  
  1498. /**
  1499. * Convert string to boolean
  1500. * because (bool) "false" == true
  1501. *
  1502. */
  1503. function optimizer_display_posts_bool( $value ) {
  1504. return !empty( $value ) && 'true' == $value ? true : false;
  1505. }
  1506.  
  1507. /**Call to Action Shortcode **/
  1508. /**USAGE: [callaction url=""][/button]
  1509. **/
  1510. function optmizersc_breadcrumbs($atts, $content = null) {
  1511.  
  1512. extract(shortcode_atts(array(
  1513. 'align' => 'center',
  1514. 'home'=> __('Home','optimizer'),
  1515. 'class' => '',
  1516. ), $atts));
  1517.  
  1518. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  1519.  
  1520. $return_html = '<div class="breadcrumbs_shortcode bread_align_'.$align.' '.$class.' '.$nonedit.'">'.breadcrumb_trail(array( 'show_browse'=> false,'echo'=> false, 'labels' => array('home' => $home ) )).'</div>';
  1521.  
  1522. return $return_html;
  1523. }
  1524.  
  1525. add_shortcode('breadcrumbs', 'optmizersc_breadcrumbs');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement