Advertisement
towfiqi

shortcodes.php

Jun 24th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.64 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. $rel = '?rel=0';
  343. if ($autoplay == 'true'){
  344. $autoplay= '?autoplay=1';
  345. $rel = '&rel=0';
  346. }elseif ($autoplay == 'false'){
  347. $autoplay= '';
  348. }
  349. $node = 'iframe';
  350.  
  351. $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.''.$rel.'" allowfullscreen></'.$node.'></div></div>';
  352.  
  353. return $return_html;
  354. }
  355. add_shortcode('youtube', 'layersc_youtube_func');
  356.  
  357.  
  358. }
  359.  
  360. /**Vimeo Video Shortcode **/
  361. /**USAGE: [vimeo width="640" height="385" video_id="11770385"]
  362. / Might have issue with some servers
  363. **/
  364. if(class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'shortcodes' ) ){
  365. }else{
  366. function layersc_vimeo_func($atts, $content) {
  367.  
  368. //extract short code attr
  369. extract(shortcode_atts(array(
  370. 'width' => '100%',
  371. 'height' => '100%',
  372. 'autoplay' => 'true',
  373. 'class' => '',
  374. ), $atts));
  375.  
  376. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  377.  
  378. $content = strip_tags($content);
  379. $content =str_replace('http://vimeo.com/', '//player.vimeo.com/video/', $content);
  380. $content =str_replace('https://vimeo.com/', '//player.vimeo.com/video/', $content);
  381. if ($autoplay == 'true'){
  382. $autoplay= 1;
  383. }elseif ($autoplay == 'false'){
  384. $autoplay= 0;
  385. }
  386. $node = 'iframe';
  387.  
  388. $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>';
  389.  
  390. return $return_html;
  391. }
  392. add_shortcode('vimeo', 'layersc_vimeo_func');
  393. }
  394.  
  395. /**Flickr Gallery **/
  396. /**USAGE:
  397. [flickr id="" type=""]
  398. **/
  399. function layersc_flickr_func( $atts, $content = null) {
  400. //extract short code attr
  401. extract(shortcode_atts(array(
  402. 'id' => '', //use http://idgettr.com/ to get you flickr userid
  403. 'count' => '9',
  404. 'photo_size'=> 'n', //n, q, s
  405. 'key'=> '',
  406. 'photoset'=> '',
  407. 'class' => '',
  408. ), $atts));
  409.  
  410. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  411.  
  412. if(!empty($photoset)) {
  413. $setid = $photoset;
  414. $setname='photosets';
  415. $setidname='photoset_id';
  416. $fetchname='photoset';
  417. }else{
  418. $setid = $id;
  419. $setname='people';
  420. $setidname='user_id';
  421. $fetchname='photos';
  422. }
  423.  
  424.  
  425. $return_html = '<div id="flickr_badge_wrapper" class="clearfix flckr_'.$photo_size.' '.$class.' '.$nonedit.'">
  426. <script type="text/javascript">
  427. (function($){
  428. var setID = "'.$setid.'";
  429. var apiKey = "'.$key.'";
  430. var itemsPerPage = '.$count.'; // Max is 500
  431. $.getJSON("https://api.flickr.com/services/rest/?&method=flickr.'.$setname.'.getPhotos&api_key=" + apiKey + "&'.$setidname.'=" + setID + "&per_page=" + itemsPerPage + "&format=json&jsoncallback=?", function(data){
  432.  
  433. var htmlOutput = "<ul class=\'pd_flick_gallery\'>";
  434. //loop through the results
  435. $.each(data.'.$fetchname.'.photo, function(i,item){
  436. // URLs
  437. var photoURL = "http://farm" + item.farm + ".static.flickr.com/" + item.server + "/" + item.id + "_" + item.secret + "_'.$photo_size.'.jpg";
  438. var linkURL = "http://farm" + item.farm + ".static.flickr.com/" + item.server + "/" + item.id + "_" + item.secret + "_b.jpg";
  439.  
  440. htmlOutput += \'<li><a href="\' + linkURL + \'" target="_blank">\';
  441. htmlOutput += \'<img title="\' + item.title + \'" src="\' + photoURL;
  442. htmlOutput += \'" alt="\' + item.title + \'" />\';
  443. htmlOutput += \'</a></li>\';
  444. });
  445. htmlOutput += "</ul><div style=\'clear:both;\'></div>";
  446.  
  447. // Assign result to a unique container
  448. $("#flickr_badge_wrapper").html(htmlOutput);
  449. $(".pd_flick_gallery li").magnificPopup({ // the containers for all your galleries
  450. delegate: "a", // the selector for gallery item
  451. type: "image",
  452. gallery: {
  453. enabled:true
  454. }
  455. });
  456. });
  457. })(jQuery);
  458. </script>
  459. </div>';
  460.  
  461. return $return_html;
  462. }
  463. add_shortcode('flickr', 'layersc_flickr_func');
  464.  
  465.  
  466.  
  467.  
  468. /**2 columns **/
  469. /**USAGE: [col2]your text[/col2]
  470. **/
  471. function layersc_col2_func( $atts, $content = null ) {
  472. extract(shortcode_atts(array('class' => '','width' => '',), $atts));
  473.  
  474.  
  475. if(is_customize_preview()){
  476. $nonedit = 'inline_shortcode';
  477. $short = 'contenteditable="true" data-shortcode="[col2 width=&quot;'.$width.'&quot;]'.str_replace('"', '&quot;', do_shortcode($content)).'[/col2]"';
  478.  
  479. }else{
  480. $nonedit = ''; $short = '';
  481. }
  482.  
  483. return '<div class="col2 shortcol '.$class.' '.$nonedit.'" data-width="'.$width.'" '.$short.'>'.do_shortcode($content).'</div>';
  484. }
  485. add_shortcode( 'col2', 'layersc_col2_func' );
  486.  
  487.  
  488. /**3 columns **/
  489. /**USAGE: [col3]your text[/col3]
  490. **/
  491. function layersc_col3_func( $atts, $content = null ) {
  492. extract(shortcode_atts(array('class' => '','width' => '',), $atts));
  493.  
  494. if(is_customize_preview()){
  495. $nonedit = 'inline_shortcode';
  496. $short = 'contenteditable="true" data-shortcode="[col3 width=&quot;'.$width.'&quot;]'.str_replace('"', '&quot;', do_shortcode($content)).'[/col3]"';
  497.  
  498. }else{
  499. $nonedit = ''; $short = '';
  500. }
  501.  
  502. return '<div class="col3 shortcol '.$class.' '.$nonedit.'" data-width="'.$width.'" '.$short.'>'.do_shortcode($content).'</div>';
  503. }
  504. add_shortcode( 'col3', 'layersc_col3_func' );
  505.  
  506.  
  507.  
  508. /**4 columns **/
  509. /**USAGE: [col4]your text[/col4]
  510. **/
  511. function layersc_col4_func( $atts, $content = null ) {
  512. extract(shortcode_atts(array('class' => '','width' => '',), $atts));
  513.  
  514. if(is_customize_preview()){
  515. $nonedit = 'inline_shortcode';
  516. $short = 'contenteditable="true" data-shortcode="[col4 width=&quot;'.$width.'&quot;]'.str_replace('"', '&quot;', do_shortcode($content)).'[/col4]"';
  517.  
  518. }else{
  519. $nonedit = ''; $short = '';
  520. }
  521.  
  522. return '<div class="col4 shortcol '.$class.' '.$nonedit.'" data-width="'.$width.'" '.$short.'>'.do_shortcode($content).'</div>';
  523. }
  524. add_shortcode( 'col4', 'layersc_col4_func' );
  525.  
  526. /**5 columns **/
  527. /**USAGE: [col5]your text[/col5]
  528. **/
  529. function layersc_col5_func( $atts, $content = null ) {
  530. extract(shortcode_atts(array('class' => '','width' => '',), $atts));
  531.  
  532. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  533.  
  534. return '<div class="col5 shortcol '.$class.' '.$nonedit.'" data-width="'.$width.'">'.do_shortcode($content).'</div>';
  535. }
  536. add_shortcode( 'col5', 'layersc_col5_func' );
  537.  
  538.  
  539. /**Tabs **/
  540. /**USAGE: [tabs titles="Tab One, Tab Two"][tab]your content[/tab][tab]your content[/tab][/tabs]
  541. **/
  542. function layersc_tabs($atts, $content = null) {
  543. extract(shortcode_atts(array(
  544. "titles" => '',
  545. "style" => '', //default, circualr, minimal, capsule
  546. "active_color"=>'#119BFF',
  547. "class" => '',
  548. ), $atts));
  549.  
  550. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  551.  
  552.  
  553. $titlearr=explode(',',$titles);
  554. $html='<div class="tabs-container lts_tabs tabs_'.$style.' '.$class.' '.$nonedit.'" data-active-color="'.$active_color.'"><ul class="tabs ">';
  555. foreach($titlearr as $title){
  556.  
  557. $html.='<li class="tabli lts_tabtitle"><a href="#" class="tabtrigger">'.$title.'</a></li>';
  558.  
  559. }
  560. $html.='</ul><div class="lts_tab">'.do_shortcode($content).'</div></div><div style="clear:both"></div>';
  561. return $html;
  562. }
  563. add_shortcode('tabs', 'layersc_tabs');
  564.  
  565. function layersc_tab($atts, $content = null) {
  566.  
  567. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  568.  
  569. return '<div class="lts_tab_child '.$nonedit.'">'.do_shortcode($content).'</div>';
  570. }
  571. add_shortcode('tab', 'layersc_tab');
  572.  
  573. /**Toggles **/
  574. /**USAGE: [toggle title="ToggleMe"]your content[/toggle]
  575. **/
  576. function layersc_toggle($atts, $content = null) {
  577. extract(shortcode_atts(array(
  578. "title" => '',
  579. "id" => '',
  580. "class" => '',
  581. ), $atts));
  582. $titlearr=explode(',',$title);
  583. $html='<div class="lts_toggle '.$class.'" id="'.$id.'"><div class="trigger_wrap">';
  584. foreach($titlearr as $title){
  585. $html.='<a class="trigger"><i class="fa fa-plus"></i> '.$title.'</a></div>';
  586. }
  587. $html.='<div class="lts_toggle_content" style="display:none;">'.do_shortcode($content).'<div style="clear:both"></div></div></div>';
  588. return $html;
  589. }
  590. add_shortcode('toggle', 'layersc_toggle');
  591.  
  592.  
  593.  
  594. /**Custom Button Shortcode **/
  595. /**USAGE: [button class="violet"][/button]
  596. **/
  597. function layersc_button_func($atts, $content = null) {
  598.  
  599. //extract short code attr
  600. extract(shortcode_atts(array(
  601. 'text'=> '',
  602. 'url' => 'http://www.google.com',
  603. 'background_color' => '#2dcb73' ,
  604. 'text_color' => '#ffffff',
  605. 'style' => 'lt_flat', //lt_flat, lt_hollow, lt_circular
  606. 'size' => 'default', //default, large, small
  607. 'icon'=>'',
  608. 'onclick'=>'',
  609. 'open_new_window' => true,
  610. 'rounded' => 'false',
  611. 'class' => '',
  612. ), $atts));
  613.  
  614. $roundeds =''; $open_new_windows =''; $icons =''; $shortwindow =''; $shortround ='';
  615. if ($rounded == 'true'){
  616. $roundeds= 'lt_rounded';
  617. $shortround ='true';
  618. }
  619. if ($rounded == 'false'){
  620. $roundeds= '';
  621. }
  622.  
  623. if ($icon !== ''){
  624. $icons = '<i class="fa '.$icon.'"></i> ';
  625. }
  626. if ($open_new_window == 'true'){
  627. $open_new_windows= 'target="_blank"';
  628. $shortwindow ='true';
  629. }
  630. if ($open_new_window == 'false'){
  631. $open_new_windows= '';
  632. }
  633.  
  634. if ($onclick !== ''){
  635. $onclick = 'onclick='.$onclick .'';
  636. }
  637.  
  638. if(is_customize_preview()){
  639. $nonedit = 'inline_shortcode';
  640. $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;]"';
  641. $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.'" ';
  642. $href ='';
  643. }else{
  644. $nonedit = ''; $inline ='';$short = '';
  645.  
  646. $href = 'href="'.$url.'"';
  647. }
  648.  
  649.  
  650. $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>';
  651.  
  652. return $return_html;
  653. }
  654.  
  655. add_shortcode('button', 'layersc_button_func');
  656.  
  657.  
  658. /**Call to Action Shortcode **/
  659. /**USAGE: [callaction url=""][/button]
  660. **/
  661. function layersc_callaction_func($atts, $content = null) {
  662.  
  663. //extract short code attr
  664. extract(shortcode_atts(array(
  665. 'button_url' => 'http://www.google.com',
  666. 'button_text' => 'My Button',
  667. 'button_background_color' => '#e64429',
  668. 'button_text_color' => '#ffffff' ,
  669. 'background_color' => '#2dcb73' ,
  670. 'text_color' => '#ffffff',
  671. 'rounded'=> '',
  672. 'class' => '',
  673. ), $atts));
  674.  
  675. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  676.  
  677. if($rounded == 'true'){
  678. $rounded = ' lt_rounded';
  679. }else{
  680. $rounded = '';
  681. }
  682.  
  683. $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>';
  684.  
  685. return $return_html;
  686. }
  687.  
  688. add_shortcode('callaction', 'layersc_callaction_func');
  689.  
  690. /**Table Shortcode **/
  691. /**USAGE: [table]
  692. **/
  693. function layersc_table_func( $atts ) {
  694. extract( shortcode_atts( array(
  695. 'cols' => 'none',
  696. 'data' => 'none',
  697. 'class' => '',
  698. ), $atts ) );
  699.  
  700. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  701.  
  702. $cols = explode(',',$cols);
  703. $data = explode(',',$data);
  704. $total = count($cols);
  705. $output = "";
  706. $output .= '<table class="ast_table '.$class.' '.$nonedit.'"><tr class="th">';
  707. foreach($cols as $col):
  708. $output .= '<td>'.$col.'</td>';
  709. endforeach;
  710. $output .= '</tr><tr>';
  711. $counter = 1;
  712. foreach($data as $datum):
  713. $output .= '<td>'.$datum.'</td>';
  714. if($counter%$total==0):
  715. $output .= '</tr>';
  716. endif;
  717. $counter++;
  718. endforeach;
  719. $output .= '</table>';
  720. return $output;
  721. }
  722. add_shortcode( 'table', 'layersc_table_func' );
  723.  
  724.  
  725.  
  726. /**Featured Image SHORTCODE **/
  727. /** [featimage align="left"]**/
  728. function layersc_featimage($atts) {
  729.  
  730. //extract short code attr
  731. extract(shortcode_atts(array('align' => 'alignleft', 'size'=>'full', 'class' => '',), $atts));
  732.  
  733. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  734.  
  735. if (has_post_thumbnail() ) {
  736. $image_id = get_post_thumbnail_id();
  737. $image_url = wp_get_attachment_image_src($image_id, $size);
  738. $image_url = $image_url[0];
  739. $result = '<div class="'.$class.' '.$nonedit.'" style="width:100%;"><img src="'.$image_url.'" class="'.$align.'" /><div style="clear:both"></div></div>';
  740. return $result;
  741. }
  742. return;
  743. }
  744.  
  745. add_shortcode('featimage', 'layersc_featimage');
  746.  
  747.  
  748. /**ToolTip **/
  749. /**USAGE: [tooltip]Your Tooltip text here[/tooltip]**/
  750. function layersc_tooltip( $atts, $content = null ) {
  751. extract(shortcode_atts(array('tipcontent' => '', 'class' => '',), $atts));
  752.  
  753. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  754.  
  755. return '<span class="tooltip lts_tooltip '.$class.' '.$nonedit.'" title="'.$tipcontent.'">'.do_shortcode($content).'</span>';
  756. }
  757. add_shortcode( 'tooltip', 'layersc_tooltip' );
  758.  
  759.  
  760. /**Drop Cap **/
  761. /**USAGE: [drop_cap]Your Drop Cap text here[/drop_cap]**/
  762. function layersc_dropcap( $atts, $content = null ) {
  763. extract(shortcode_atts(array('color' => '#fff' , 'background' => '#2dcb73', 'class' => '',), $atts));
  764.  
  765. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  766.  
  767. return '<span style="color:'.$color.';background:'.$background.';" class="lts_dropcap '.$class.' '.$nonedit.'">'.do_shortcode($content).'</span>';
  768. }
  769. add_shortcode( 'drop_cap', 'layersc_dropcap' );
  770.  
  771.  
  772. /**PROGRESS BAR **/
  773. /**USAGE: [progress percent="40"]**/
  774. function layersc_progress( $atts, $content = null ) {
  775. extract(shortcode_atts(array(
  776. 'title' => '' ,
  777. 'percent' => '70' ,
  778. 'style' => 'bold' , //bold, thin, circular
  779. 'color' => '#fff' ,
  780. 'background' => '#2dcb73',
  781. 'rounded'=> "false",
  782. 'stripes'=> "true",
  783. 'class' => '',
  784. ), $atts));
  785.  
  786. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  787.  
  788. if($rounded == "true"){
  789. $rounded = 'progress_rounded';
  790. }else{
  791. $rounded = '';
  792. }
  793.  
  794. if($stripes == "true"){
  795. $stripes = ' progress_stripes';
  796. }else{
  797. $stripes = '';
  798. }
  799.  
  800. if(!empty($title)){$title = '<div class="progress_title">'.do_shortcode($title).'</div>'; }else{ $title = ''; }
  801.  
  802. if($style == "circular"){ $circular = '<div class="circle_progress" data-progress="'.($percent/100).'" data-background="'.$background.'"><strong>'.$percent.'%</strong></div>'.$title;}else{ $circular = '';}
  803.  
  804. 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>';
  805.  
  806.  
  807. }
  808. add_shortcode( 'progress', 'layersc_progress' );
  809.  
  810. /**Section SHORTCODE **/
  811. /**USAGE: [section]Your Content[/section]**/
  812. function layersc_section( $atts, $content = null ) {
  813. extract(shortcode_atts(array('background_image' => '', 'text_color' => '#666666','background_color' => '#eeeeee','class'=> '',), $atts));
  814.  
  815. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  816.  
  817. if(!empty($background_image)){
  818. $background_image= 'background-image:url('.$background_image.')';
  819. }
  820. 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>';
  821. }
  822. add_shortcode( 'section', 'layersc_section' );
  823.  
  824.  
  825. /**Block Shortcode **/
  826. /**USAGE: [block width="full" background="#ffffff" text_color="#555" shadow="true"]Your Content[/block]**/
  827. function layersc_block( $atts, $content = null ) {
  828. extract(shortcode_atts(array(
  829. 'text_color' => '#999999',
  830. 'background' => '#ffffff',
  831. 'shadow'=> false,
  832. 'rounded'=> false,
  833. 'class'=> '',
  834. ), $atts));
  835.  
  836. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  837.  
  838. if($shadow !==''){
  839. $shadow = '';
  840. }else{
  841. $shadow = 'lt_shadow';
  842. }
  843.  
  844. if($rounded =='true'){
  845. $rounded = 'lt_rounded';
  846. }else{
  847. $rounded = '';
  848. }
  849.  
  850. return '<div class="lts_block '.$shadow.' '.$rounded.' '.$class.' '.$nonedit.'" style="background:'.$background.';color:'.$text_color.';">'.do_shortcode($content).'</div>';
  851. }
  852. add_shortcode( 'block', 'layersc_block' );
  853.  
  854. function layersc_blocks( $atts, $content = null ) {
  855. extract(shortcode_atts(array(
  856. 'layout' => 'layout1',
  857. 'class'=> '',
  858. ), $atts));
  859.  
  860. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  861.  
  862. return '<div class="lts_blocks lts_blocks_'.$layout.' '.$class.' '.$nonedit.'">'.do_shortcode($content).'</div>';
  863. }
  864. add_shortcode( 'blocks', 'layersc_blocks' );
  865.  
  866.  
  867.  
  868. /**PANEL SHORTCODE **/
  869. /**USAGE: [panel title="Your Panel Title"]Your Content[/panel]**/
  870. function layersc_panel( $atts, $content = null ) {
  871. extract(shortcode_atts(array('title' => '', 'text_color' => '#ffffff','background_color' => '#428bca','class'=> '',), $atts));
  872.  
  873. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  874.  
  875. 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>';
  876. }
  877. add_shortcode( 'panel', 'layersc_panel' );
  878.  
  879.  
  880.  
  881. /**ABOUT AUTHOR SHORTCODE **/
  882. /**USAGE: [author name="Jane Doe" image="" facebook="" twitter="" google="" linkedin="" website=""]Author bio[/author]**/
  883. function layersc_author( $atts, $content = null ) {
  884. extract(shortcode_atts(array(
  885. 'name' => '',
  886. 'name_text_color' => '#428bca',
  887. 'background' => '',
  888. 'image' => '',
  889. 'facebook' => '',
  890. 'twitter' => '',
  891. 'google' => '',
  892. 'linkedin' => '',
  893. 'website' => '',
  894. 'class' => '',
  895. ), $atts));
  896.  
  897. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  898.  
  899. if($image !==''){$image ='<div class="author_image"><img src="'.$image.'" alt="'.$name.'" title="'.$name.'" /></div>'; }else{ $image =''; }
  900.  
  901. if($facebook !==''){ $facebook ='<a href="'.esc_url($facebook).'"><i class="fa fa-facebook-square"></i></a>'; }else{ $facebook =''; }
  902. if($twitter !==''){ $twitter ='<a href="'.esc_url($twitter).'"><i class="fa fa-twitter-square"></i></a>'; }else{ $twitter =''; }
  903. if($google !==''){ $google ='<a href="'.esc_url($google).'"><i class="fa fa-google-plus-square"></i></a>'; }else{ $google =''; }
  904. if($linkedin !==''){ $linkedin ='<a href="'.esc_url($linkedin).'"><i class="fa fa-linkedin-square"></i></a>'; }else{ $linkedin =''; }
  905. if($website !==''){ $website ='<a href="'.esc_url($website).'"><i class="fa fa-globe"></i></a>'; }else{ $website =''; }
  906.  
  907. return '
  908. <div class="lts_author '.$class.' '.$nonedit.'" style="background:'.$background.'">
  909. '.$image.'
  910. <div class="author_content">
  911. <h5 style="color:'.$name_text_color.'">'.$name.'</h5>
  912. <div class="lts_author_body">'.do_shortcode($content).'
  913. <p class="athor_social">'.$facebook. $twitter .$google .$linkedin .$website.'</p>
  914. </div>
  915. </div>
  916. </div>';
  917. }
  918. add_shortcode( 'author', 'layersc_author' );
  919.  
  920.  
  921. /**CAROUSEL SHORTCODE **/
  922. /**USAGE: [carousel border_style="thick"][carousel_item]Your HTML Content Here[/carousel_item][/carousel]**/
  923. function layersc_carousel( $atts, $content = null ) {
  924. extract(shortcode_atts(array(
  925. 'style' => 'default', //default or thick_border
  926. 'background' => '#ffffff',
  927. 'button_color'=> '#eeeeee;',
  928. 'text_color' => '#999999',
  929. 'class' => '',
  930. ), $atts));
  931.  
  932. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  933.  
  934. return '
  935. <div class="looper slide lts_looper lts_'.$style.' '.$class.' '.$nonedit.'" data-looper="go" data-interval="4000" data-buttoncolor="'.$button_color.'" style="background:'.$background.';color:'.$text_color.'">
  936. <div class="looper-inner">
  937. '.do_shortcode($content).'
  938. </div>
  939. <nav>
  940. <ul class="looper-nav"></ul>
  941. </nav>
  942. </div>
  943. ';
  944. }
  945. add_shortcode( 'carousel', 'layersc_carousel' );
  946.  
  947. function layersc_carousel_item( $atts, $content = null ) {
  948.  
  949. return '<div class="item">'.do_shortcode($content).'</div>';
  950. }
  951. add_shortcode( 'carousel_item', 'layersc_carousel_item' );
  952.  
  953.  
  954. /**Section SHORTCODE **/
  955. /**USAGE: [search label="Search" text_color="#ffffff" background_color="#333333"]**/
  956. function layersc_searchform( $atts, $content = null ) {
  957. extract(shortcode_atts(array('label' => 'Search', 'text_color' => '#666666','background_color' => '#eeeeee','class'=> '',), $atts));
  958.  
  959. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  960.  
  961. return '<form role="search" method="get" class="lts_search-form '.$class.' '.$nonedit.'" action="'.home_url( '/' ).'">
  962. <input type="search" class="search-field" placeholder="'.$label.'" value="'.get_search_query().'" name="s" />
  963. <input type="submit" class="search-submit" value="'.$label.'" style="color:'.$text_color.';background:'.$background_color.';"/></form>';
  964.  
  965. }
  966. add_shortcode( 'searchform', 'layersc_searchform' );
  967.  
  968.  
  969.  
  970. /**PRICING SHORTCODE **/
  971. /**USAGE: [pricing background="#ffffff" text_color="#999" button_color="#8ab71b"][pricebox]Your HTML Content Here[/pricebox][/pricing]**/
  972. function layersc_pricing( $atts, $content = null ) {
  973. extract(shortcode_atts(array(
  974. 'background' => '#ffffff',
  975. 'text_color' => '#999999',
  976. 'button_bg_color' => '#8ab71b',
  977. 'button_text_color' => '#ffffff',
  978. 'style' => '1',
  979. 'class' => '',
  980. ), $atts));
  981.  
  982. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  983.  
  984. return '
  985. <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.'">
  986. '.do_shortcode($content).'
  987. </div>
  988. ';
  989. }
  990. add_shortcode( 'pricing', 'layersc_pricing' );
  991.  
  992. function layersc_pricebox( $atts, $content = null ) {
  993. extract(shortcode_atts(array(
  994. 'name' => 'Package1',
  995. 'price' => '$30',
  996. 'price_label'=> 'month',
  997. 'description' => '',
  998. 'features'=>'',
  999. 'button_text'=>'Signup',
  1000. 'button_link'=>'',
  1001. 'featured'=> '',
  1002. ), $atts));
  1003.  
  1004. if($price_label !==''){
  1005. $price_label = '<span class="price_label">/'.$price_label.'</span>';
  1006. }else{
  1007. $price_label = '';
  1008. }
  1009.  
  1010. if($featured !==''){
  1011. $featured = '<span class="feat_wrap"><span class="pricebox_featured">'.$featured.'</span></span>';
  1012. }else{
  1013. $featured = '';
  1014. }
  1015.  
  1016. if($name !==''){
  1017. return '
  1018. <div class="pricebox"><div class="pricebox_inner">
  1019. '.$featured.'
  1020. <div class="price_head">
  1021. <h3>'.$name.'</h3>
  1022. <span class="price_ammount">'.$price.'</span>'.$price_label.'
  1023. <p class="price_desc">'.do_shortcode($description).'</p>
  1024. </div>
  1025. <div class="price_body">'.do_shortcode($features).'</div>
  1026. <div class="price_footer"><a href="'.$button_link.'" class="price_button">'.$button_text.'</a></div>
  1027. </div></div>';
  1028. }
  1029. }
  1030. add_shortcode( 'pricebox', 'layersc_pricebox' );
  1031.  
  1032. /**Lightbox Shortcode **/
  1033. /**USAGE: [lightbox button_text="Check This Out"] Your content that you want to display in a lightbox [/lightbox]
  1034. **/
  1035. function layersc_lightbox_func($atts, $content) {
  1036.  
  1037. //extract short code attr
  1038. extract(shortcode_atts(array(
  1039. 'button_text' => '',
  1040. 'button_text_color' => '',
  1041. 'button_text_bg' => '',
  1042. 'button_font_size' => '',
  1043. 'button_style' => 'lt_flat', //lt_flat, lt_hollow, lt_circular
  1044. 'button_size' => 'medium', //medium, large, small
  1045. 'rounded'=>'true',
  1046. 'image'=>'',
  1047. 'class' => '',
  1048. ), $atts));
  1049.  
  1050. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  1051.  
  1052. if ($button_text_color !== ''){
  1053. $button_text_color= 'color:'.$button_text_color.';';
  1054. }
  1055. if ($button_text_bg !== ''){
  1056. $button_text_bg= 'background:'.$button_text_bg.';';
  1057. }
  1058. if ($button_font_size !== ''){
  1059. $button_font_size= 'font-size:'.$button_font_size.';';
  1060. }
  1061. if ($rounded == 'true'){
  1062. $rounded= 'lt_rounded';
  1063. }else{
  1064. $rounded= '';
  1065. }
  1066. $hasimg = '';
  1067. if (!empty($image)){
  1068. $button_text = '<img src="'.$image.'" />';
  1069. $hasimg = 'ltbximg';
  1070. }
  1071.  
  1072.  
  1073.  
  1074. $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>';
  1075.  
  1076.  
  1077. return $return_html;
  1078. }
  1079. add_shortcode('lightbox', 'layersc_lightbox_func');
  1080.  
  1081.  
  1082.  
  1083.  
  1084. /**MAP SHORTCODE **/
  1085. /**USAGE: [map latitude="53.359286" longitude="-2.040904" text="This Text Appears when you hover over the bubble"]**/
  1086. function layersc_map( $atts, $content = null ) {
  1087. global $optimizer;
  1088. 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';}
  1089.  
  1090. wp_enqueue_script('optimizer_map',get_template_directory_uri().'/assets/js/map-styles.js', array('jquery'),'1.0', true);
  1091. wp_enqueue_script('optimizer_googlemaps', $mapkey, array('jquery'),'1.0', true);
  1092. extract(shortcode_atts(array(
  1093. 'latitude' => '53.359286' ,
  1094. 'longitude' => '-2.040904',
  1095. 'text' => 'Your Location Details.',
  1096. 'height' => '300px',
  1097. 'class' => '',
  1098. ), $atts));
  1099.  
  1100. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  1101.  
  1102. 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>';
  1103.  
  1104. }
  1105. add_shortcode( 'map', 'layersc_map' );
  1106.  
  1107.  
  1108. /**ICON SHORTCODE **/
  1109. /**USAGE: [icon type="fa-star" color="#999999" size="20px"]**/
  1110. function layersc_icon( $atts, $content = null ) {
  1111. extract(shortcode_atts(array(
  1112. 'type' => 'fa-star',
  1113. 'color'=> '',
  1114. 'size'=> '',
  1115. 'style'=> '', //plain, circle_thin, circle_thick, circle_color, square_thin, square_thick, square_color
  1116. 'link'=> '',
  1117. 'new_window'=> 'true',
  1118. 'class' => '',
  1119. ), $atts));
  1120.  
  1121. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  1122.  
  1123. $widthheight = '';
  1124. $bgcolor = '';
  1125. $linkstart = '';
  1126. $linkend = '';
  1127.  
  1128. if ( $style !== '' || $style !== 'plain'){
  1129. $widthheight = 'width:'.$size.';height:'.$size.';';
  1130. }
  1131.  
  1132. if($style == 'circle_color' || $style == 'square_color'){
  1133. $bgcolor = 'background:'.$color.';';
  1134. }
  1135. if ( $link !== '' ){
  1136. if($new_window == 'true'){
  1137. $linkstart = '<a target="_blank" href="'.esc_url($link ).'">';
  1138. }else{
  1139. $linkstart = '<a href="'.esc_url($link ).'">';
  1140. }
  1141. $linkend = '</a>';
  1142. }
  1143.  
  1144.  
  1145. return ''.$linkstart.'<i style="color:'.$color.';font-size:'.$size.';'.$widthheight.' '.$bgcolor.'" class="fa '.$type.' '.$class.' icon_style_'.$style.' '.$nonedit.'"></i>'.$linkend.'';
  1146. }
  1147. add_shortcode( 'icon', 'layersc_icon' );
  1148.  
  1149. /**CUSTOM HEADLINE SHORTCODE **/
  1150. /**USAGE: [headline type="type1"][/headline]**/
  1151. function layersc_headline( $atts, $content = null ) {
  1152. extract(shortcode_atts(array(
  1153. 'type' => 'type1',
  1154. 'color'=> '#999999',
  1155. 'text'=> '',
  1156. 'size' => 'h2',
  1157. 'class' => '',
  1158. ), $atts));
  1159.  
  1160. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  1161.  
  1162. 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.'>';
  1163. }
  1164. add_shortcode( 'headline', 'layersc_headline' );
  1165.  
  1166.  
  1167.  
  1168. /**
  1169. * @package Display Posts
  1170. * @version 2.4
  1171. * @author Bill Erickson <bill@billerickson.net>
  1172. * @copyright Copyright (c) 2011, Bill Erickson
  1173. * @link http://www.billerickson.net/shortcode-to-display-posts/
  1174. * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  1175. */
  1176.  
  1177. // Create the shortcode
  1178. add_shortcode( 'display-posts', 'optimizer_display_posts_shortcode' );
  1179. function optimizer_display_posts_shortcode( $atts ) {
  1180.  
  1181. // Original Attributes, for filters
  1182. $original_atts = $atts;
  1183.  
  1184. // Pull in shortcode attributes and set defaults
  1185. $atts = shortcode_atts( array(
  1186. 'title' => '',
  1187. 'author' => '',
  1188. 'category' => '',
  1189. 'layout' => 'layout1',
  1190. 'date_format' => 'F jS, Y ',
  1191. 'display_posts_off' => false,
  1192. 'exclude_current' => true,
  1193. 'id' => false,
  1194. 'ignore_sticky_posts' => false,
  1195. 'image_size' => 'large',
  1196. 'include_title' => true,
  1197. 'include_author' => false,
  1198. 'include_content' => false,
  1199. 'include_date' => false,
  1200. 'include_excerpt' => true,
  1201. 'meta_key' => '',
  1202. 'meta_value' => '',
  1203. 'no_posts_message' => '',
  1204. 'offset' => 0,
  1205. 'order' => 'DESC',
  1206. 'orderby' => 'date',
  1207. 'post_parent' => false,
  1208. 'post_status' => 'publish',
  1209. 'post_type' => 'post',
  1210. 'posts_per_page' => '10',
  1211. 'tag' => '',
  1212. 'tax_operator' => 'IN',
  1213. 'tax_term' => false,
  1214. 'taxonomy' => false,
  1215. 'wrapper' => 'div',
  1216. 'wrapper_class' => 'display-posts-listing',
  1217. 'class' => '',
  1218. 'wrapper_id' => false,
  1219. ), $atts, 'display-posts' );
  1220.  
  1221.  
  1222. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  1223.  
  1224. // End early if shortcode should be turned off
  1225. if( $atts['display_posts_off'] )
  1226. return;
  1227.  
  1228. $shortcode_title = sanitize_text_field( $atts['title'] );
  1229. $author = sanitize_text_field( $atts['author'] );
  1230. $category = sanitize_text_field( $atts['category'] );
  1231. $layout = sanitize_text_field( $atts['layout'] );
  1232. $date_format = sanitize_text_field( $atts['date_format'] );
  1233. $exclude_current = optimizer_display_posts_bool( $atts['exclude_current'] );
  1234. $id = $atts['id']; // Sanitized later as an array of integers
  1235. $ignore_sticky_posts = optimizer_display_posts_bool( $atts['ignore_sticky_posts'] );
  1236. $image_size = sanitize_key( $atts['image_size'] );
  1237. $include_title = optimizer_display_posts_bool( $atts['include_title'] );
  1238. $include_author = optimizer_display_posts_bool( $atts['include_author'] );
  1239. $include_content = optimizer_display_posts_bool( $atts['include_content'] );
  1240. $include_date = optimizer_display_posts_bool( $atts['include_date'] );
  1241. $include_excerpt = optimizer_display_posts_bool( $atts['include_excerpt'] );
  1242. $meta_key = sanitize_text_field( $atts['meta_key'] );
  1243. $meta_value = sanitize_text_field( $atts['meta_value'] );
  1244. $no_posts_message = sanitize_text_field( $atts['no_posts_message'] );
  1245. $offset = intval( $atts['offset'] );
  1246. $order = sanitize_key( $atts['order'] );
  1247. $orderby = sanitize_key( $atts['orderby'] );
  1248. $post_parent = $atts['post_parent']; // Validated later, after check for 'current'
  1249. $post_status = $atts['post_status']; // Validated later as one of a few values
  1250. $post_type = sanitize_text_field( $atts['post_type'] );
  1251. $posts_per_page = intval( $atts['posts_per_page'] );
  1252. $tag = sanitize_text_field( $atts['tag'] );
  1253. $tax_operator = $atts['tax_operator']; // Validated later as one of a few values
  1254. $tax_term = sanitize_text_field( $atts['tax_term'] );
  1255. $taxonomy = sanitize_key( $atts['taxonomy'] );
  1256. $wrapper = sanitize_text_field( $atts['wrapper'] );
  1257. $wrapper_class = sanitize_html_class( $atts['wrapper_class'] );
  1258. $class = sanitize_html_class( $atts['class'] );
  1259.  
  1260. if( !empty( $wrapper_class ) )
  1261. $wrapper_class = ' class="' . $wrapper_class . ' lts_'.$layout.' '.$class.'"';
  1262. $wrapper_id = sanitize_html_class( $atts['wrapper_id'] );
  1263. if( !empty( $wrapper_id ) )
  1264. $wrapper_id = ' id="' . $wrapper_id . '"';
  1265.  
  1266. //If Category null display empty\
  1267. if($category =='null'){
  1268. $category='';
  1269. }
  1270. //If tag null display empty\
  1271. if($tag =='null'){
  1272. $tag='';
  1273. }
  1274. //If post_type null display empty\
  1275. if($post_type =='null'){
  1276. $post_type='';
  1277. }
  1278.  
  1279. // Set up initial query for post
  1280. $args = array(
  1281. 'category_name' => $category,
  1282. 'order' => $order,
  1283. 'orderby' => $orderby,
  1284. 'post_type' => explode( ',', $post_type ),
  1285. 'posts_per_page' => $posts_per_page,
  1286. 'tag' => $tag,
  1287. );
  1288.  
  1289.  
  1290.  
  1291. // Ignore Sticky Posts
  1292. if( $ignore_sticky_posts )
  1293. $args['ignore_sticky_posts'] = true;
  1294.  
  1295. // Meta key (for ordering)
  1296. if( !empty( $meta_key ) )
  1297. $args['meta_key'] = $meta_key;
  1298.  
  1299. // Meta value (for simple meta queries)
  1300. if( !empty( $meta_value ) )
  1301. $args['meta_value'] = $meta_value;
  1302.  
  1303. // If Post IDs
  1304. if( $id ) {
  1305. $posts_in = array_map( 'intval', explode( ',', $id ) );
  1306. $args['post__in'] = $posts_in;
  1307. }
  1308.  
  1309. // If Exclude Current
  1310. if( $exclude_current )
  1311. $args['post__not_in'] = array( get_the_ID() );
  1312.  
  1313. // Post Author
  1314. if( !empty( $author ) )
  1315. $args['author_name'] = $author;
  1316.  
  1317. // Offset
  1318. if( !empty( $offset ) )
  1319. $args['offset'] = $offset;
  1320.  
  1321. // Post Status
  1322. $post_status = explode( ', ', $post_status );
  1323. $validated = array();
  1324. $available = array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash', 'any' );
  1325. foreach ( $post_status as $unvalidated )
  1326. if ( in_array( $unvalidated, $available ) )
  1327. $validated[] = $unvalidated;
  1328. if( !empty( $validated ) )
  1329. $args['post_status'] = $validated;
  1330.  
  1331.  
  1332. // If taxonomy attributes, create a taxonomy query
  1333. if ( !empty( $taxonomy ) && !empty( $tax_term ) ) {
  1334.  
  1335. // Term string to array
  1336. $tax_term = explode( ', ', $tax_term );
  1337.  
  1338. // Validate operator
  1339. if( !in_array( $tax_operator, array( 'IN', 'NOT IN', 'AND' ) ) )
  1340. $tax_operator = 'IN';
  1341.  
  1342. $tax_args = array(
  1343. 'tax_query' => array(
  1344. array(
  1345. 'taxonomy' => $taxonomy,
  1346. 'field' => 'slug',
  1347. 'terms' => $tax_term,
  1348. 'operator' => $tax_operator
  1349. )
  1350. )
  1351. );
  1352.  
  1353. // Check for multiple taxonomy queries
  1354. $count = 2;
  1355. $more_tax_queries = false;
  1356. while(
  1357. isset( $original_atts['taxonomy_' . $count] ) && !empty( $original_atts['taxonomy_' . $count] ) &&
  1358. isset( $original_atts['tax_' . $count . '_term'] ) && !empty( $original_atts['tax_' . $count . '_term'] )
  1359. ):
  1360.  
  1361. // Sanitize values
  1362. $more_tax_queries = true;
  1363. $taxonomy = sanitize_key( $original_atts['taxonomy_' . $count] );
  1364. $terms = explode( ', ', sanitize_text_field( $original_atts['tax_' . $count . '_term'] ) );
  1365. $tax_operator = isset( $original_atts['tax_' . $count . '_operator'] ) ? $original_atts['tax_' . $count . '_operator'] : 'IN';
  1366. $tax_operator = in_array( $tax_operator, array( 'IN', 'NOT IN', 'AND' ) ) ? $tax_operator : 'IN';
  1367.  
  1368. $tax_args['tax_query'][] = array(
  1369. 'taxonomy' => $taxonomy,
  1370. 'field' => 'slug',
  1371. 'terms' => $terms,
  1372. 'operator' => $tax_operator
  1373. );
  1374.  
  1375. $count++;
  1376.  
  1377. endwhile;
  1378.  
  1379. if( $more_tax_queries ):
  1380. $tax_relation = 'AND';
  1381. if( isset( $original_atts['tax_relation'] ) && in_array( $original_atts['tax_relation'], array( 'AND', 'OR' ) ) )
  1382. $tax_relation = $original_atts['tax_relation'];
  1383. $args['tax_query']['relation'] = $tax_relation;
  1384. endif;
  1385.  
  1386. $args = array_merge( $args, $tax_args );
  1387. }
  1388.  
  1389. // If post parent attribute, set up parent
  1390. if( $post_parent ) {
  1391. if( 'current' == $post_parent ) {
  1392. global $post;
  1393. $post_parent = get_the_ID();
  1394. }
  1395. $args['post_parent'] = intval( $post_parent );
  1396. }
  1397.  
  1398. // Set up html elements used to wrap the posts.
  1399. // Default is ul/li, but can also be ol/li and div/div
  1400. $wrapper_options = array( 'ul', 'ol', 'div' );
  1401. if( ! in_array( $wrapper, $wrapper_options ) )
  1402. $wrapper = 'ul';
  1403. $inner_wrapper = 'div' == $wrapper ? 'div' : 'li';
  1404.  
  1405.  
  1406. $listing = new WP_Query( apply_filters( 'display_posts_shortcode_args', $args, $original_atts ) );
  1407. if ( ! $listing->have_posts() )
  1408. return apply_filters( 'display_posts_shortcode_no_results', wpautop( $no_posts_message ) );
  1409.  
  1410. $inner = '';
  1411. $cats = '';
  1412. while ( $listing->have_posts() ): $listing->the_post(); global $post;
  1413.  
  1414. $image = $date = $author = $excerpt = $content = '';
  1415.  
  1416. if ( $include_title )
  1417. if( $layout == 'layout1'){
  1418. $title = '<h2 class="lt_animate"><a class="title" href="' . apply_filters( 'the_permalink', get_permalink() ) .'">'. get_the_title() .'</a></h2>';
  1419. }else{
  1420. $title = '<h2 class="lt_animate"><a class="title" href="' . apply_filters( 'the_permalink', get_permalink() ) .'">' . get_the_title().'</a></h2>';
  1421. }
  1422.  
  1423. if( $layout !== 'layout5'){
  1424. if ( $image_size && has_post_thumbnail() )
  1425. $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>';
  1426.  
  1427. if ( !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_first_image('large'). '" /></a></div>';
  1429.  
  1430. if ( $image_size && !has_post_thumbnail() && optimizer_first_image() == '')
  1431. $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>';
  1432. }
  1433.  
  1434. if( $layout == 'layout4' || $layout == 'layout5' )
  1435. $date = ' <span class="lt_date"><i class="fa-calendar"></i> ' . get_the_date( $date_format ) . '</span>';
  1436.  
  1437. if( $layout == 'layout4' || $layout == 'layout5' )
  1438. $author = apply_filters( 'display_posts_shortcode_author', ' <span class="lt_author"><i class="fa-user"></i> ' . get_the_author() . '</span>' );
  1439.  
  1440. if( $layout == 'layout4' || $layout == 'layout5' )
  1441. $cats = apply_filters( 'display_posts_shortcode_author', ' <div class="lt_cats"><i class="fa-th-list"></i> ' . get_the_category_list() . '</div>' );
  1442.  
  1443. if ( $include_excerpt )
  1444. if($layout == 'layout2' || $layout == 'layout3'){
  1445. $excerpt = '<span class="excerpt">' . wp_trim_words( strip_shortcodes($post->post_content), 18) . '</span>';
  1446. }
  1447. if($layout == 'layout4'){
  1448. $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>';
  1449. }
  1450.  
  1451. if( $include_content || $layout == 'layout5' ) {
  1452. add_filter( 'shortcode_atts_display-posts', 'optimizer_display_posts_off', 10, 3 );
  1453. $content = '<div class="lt_content">' . apply_filters( 'the_content', get_the_content() ) . '</div>';
  1454. remove_filter( 'shortcode_atts_display-posts', 'optimizer_display_posts_off', 10, 3 );
  1455. }
  1456.  
  1457. $class = array( 'listing-item' );
  1458. $class = sanitize_html_class( apply_filters( 'display_posts_shortcode_post_class', $class, $post, $listing, $original_atts ) );
  1459. $output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">'. $image . $title . $date . $author . $cats . $excerpt . $content . '</' . $inner_wrapper . '>';
  1460.  
  1461. // If post is set to private, only show to logged in users
  1462. if( 'private' == get_post_status( get_the_ID() ) && !current_user_can( 'read_private_posts' ) )
  1463. $output = '';
  1464.  
  1465. $inner .= apply_filters( 'display_posts_shortcode_output', $output, $original_atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class );
  1466.  
  1467. endwhile; wp_reset_postdata();
  1468.  
  1469. $open = apply_filters( 'display_posts_shortcode_wrapper_open', '<' . $wrapper . $wrapper_class . $wrapper_id . '>', $original_atts );
  1470. $close = apply_filters( 'display_posts_shortcode_wrapper_close', '</' . $wrapper . '>', $original_atts );
  1471.  
  1472. $return = $open;
  1473.  
  1474. if( $shortcode_title ) {
  1475.  
  1476. $title_tag = apply_filters( 'display_posts_shortcode_title_tag', 'h2', $original_atts );
  1477.  
  1478. $return .= '<' . $title_tag . ' class="display-posts-title">' . $shortcode_title . '</' . $title_tag . '>' . "\n";
  1479. }
  1480.  
  1481. $return .= $inner . $close;
  1482.  
  1483. return $return;
  1484. }
  1485.  
  1486.  
  1487. /**
  1488. * Turn off display posts shortcode
  1489. * If display full post content, any uses of [display-posts] are disabled
  1490. *
  1491. * @param array $out, returned shortcode values
  1492. * @param array $pairs, list of supported attributes and their defaults
  1493. * @param array $atts, original shortcode attributes
  1494. * @return array $out
  1495. */
  1496. function optimizer_display_posts_off( $out, $pairs, $atts ) {
  1497. $out['display_posts_off'] = apply_filters( 'display_posts_shortcode_inception_override', true );
  1498. return $out;
  1499. }
  1500.  
  1501. /**
  1502. * Convert string to boolean
  1503. * because (bool) "false" == true
  1504. *
  1505. */
  1506. function optimizer_display_posts_bool( $value ) {
  1507. return !empty( $value ) && 'true' == $value ? true : false;
  1508. }
  1509.  
  1510. /**Call to Action Shortcode **/
  1511. /**USAGE: [callaction url=""][/button]
  1512. **/
  1513. function optmizersc_breadcrumbs($atts, $content = null) {
  1514.  
  1515. extract(shortcode_atts(array(
  1516. 'align' => 'center',
  1517. 'home'=> __('Home','optimizer'),
  1518. 'class' => '',
  1519. ), $atts));
  1520.  
  1521. if(is_customize_preview()){ $nonedit = 'mceNonEditable blockshortcode';}else{$nonedit = '';}
  1522.  
  1523. $return_html = '<div class="breadcrumbs_shortcode bread_align_'.$align.' '.$class.' '.$nonedit.'">'.breadcrumb_trail(array( 'show_browse'=> false,'echo'=> false, 'labels' => array('home' => $home ) )).'</div>';
  1524.  
  1525. return $return_html;
  1526. }
  1527.  
  1528. add_shortcode('breadcrumbs', 'optmizersc_breadcrumbs');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement