shortcodes.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * Shortcode: Display a List of Child Pages For a Parent Page
  4. *
  5. * Code: [wpb_childpages]
  6. *
  7. * or <?php wittyplex_list_child_pages(); ?>
  8. *
  9. **/
  10. function wittyplex_list_child_pages() {
  11. global $post;
  12. if ( is_page() && $post->post_parent )
  13. $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
  14. else
  15. $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
  16. if ( $childpages ) {
  17. $string = '<ul class="child-page-menu">' . $childpages . '</ul>';
  18. }
  19. return $string;
  20. }
  21. add_shortcode('list_childpages', 'wittyplex_list_child_pages');
  22. /**
  23. * Shortcode: Display Buttons
  24. *
  25. * Code: [button style="large yellow" icon="fa-file-text-o" width="200px" link="http://www.google.com" title="Link Title"]
  26. *
  27. * or <?php wittyplex_adding_custom_button(); ?>
  28. *
  29. **/
  30. function wittyplex_adding_custom_button($atts, $content = null) {
  31. extract(shortcode_atts(array(
  32. 'title' => 'Button Title',
  33. 'link' => '#',
  34. 'style' => 'normal yallow',
  35. 'width' => 'inherit',
  36. 'icon' => ' ',
  37. ), $atts));
  38. return '<div style="width: '.$width.' " class="buttons '.$style.'">
  39. <i class="'.$icon.'"></i> <a href="'.$link.'">'.$title.'</a></div>';
  40. }
  41. add_shortcode('button', 'wittyplex_adding_custom_button');
  42. /**
  43. * Shortcode: Display Texts
  44. *
  45. * Code: [content style="normal gray" size="12px" font="Raleway" text="Text here"]
  46. *
  47. * or <?php wittyplex_adding_custom_text_style(); ?>
  48. *
  49. **/
  50. function wittyplex_adding_custom_text_style($atts, $content = null) {
  51. extract(shortcode_atts(array(
  52. 'text' => 'Button Title',
  53. 'style' => 'gray',
  54. 'size' => 'inherit',
  55. 'font' => 'inherit',
  56. ), $atts));
  57. return '<div style="font-size: '.$size.'; font-family: '.$font.'" class="contents '.$style.'">'.$text.' </div>';
  58. }
  59. add_shortcode('content', 'wittyplex_adding_custom_text_style');
  60. /**
  61. * Shortcode: Display SVG Buttons
  62. *
  63. * Code: [svg_button text1="Click to" text2="Contact Us" text1_size="14px" text2_size="23px" text1_style="gray" text2_style="yellow" link="http://www.google.com" target="_blank"]
  64. *
  65. * or <?php wittyplex_adding_custom_svg_button(); ?>
  66. *
  67. **/
  68. function wittyplex_adding_custom_svg_button($atts, $content = null) {
  69. extract(shortcode_atts(array(
  70. 'text1' => 'Click to',
  71. 'text2' => 'Contact Us',
  72. 'text1_size' => '16px',
  73. 'text2_size' => '23px',
  74. 'text1_style' => 'gray',
  75. 'text2_style' => 'yellow',
  76. 'link' => '#',
  77. 'target' => '_self',
  78. ), $atts));
  79. return '<div class="svg-button">
  80. <div class="svg-inner">
  81. <a href="'.$link.'" target="'.$target.'">
  82. <div class="svg-text">
  83. <p style="font-size:'.$text1_size.'" class="'.$text1_style.'">'.$text1.'</h6>
  84. <p style="font-size:'.$text2_size.'" class="'.$text2_style.'">'.$text2.'</h2>
  85. </div>
  86. </a>
  87. </div>
  88. <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 220 220" xml:space="preserve">
  89. <g class="svg-crl">
  90. <path d="M191.149,84.762c2.522,7.978,3.895,16.462,3.921,25.26c0.137,46.757-37.794,84.909-84.551,85.045
  91. c-46.757,0.137-84.909-37.792-85.045-84.55C25.36,72.148,50.89,39.592,85.889,29.064l-1.4-4.752
  92. c-37.057,11.134-64.09,45.598-63.972,86.22c0.145,49.49,40.524,89.634,90.014,89.49s89.636-40.524,89.491-90.014
  93. c-0.027-9.321-1.485-18.31-4.159-26.762L191.149,84.762z"/>
  94. <path d="M162.626,32.8c24.754,16.782,41.091,45.1,41.184,77.197c0.151,51.579-41.688,93.663-93.267,93.814
  95. c-51.579,0.151-93.663-41.688-93.814-93.267c-0.064-22.071,7.577-42.389,20.363-58.441l-3.868-3.091
  96. c-13.468,16.904-21.517,38.302-21.449,61.546c0.159,54.31,44.473,98.366,98.783,98.207c54.31-0.159,98.366-44.473,98.207-98.783
  97. c-0.099-33.793-17.298-63.608-43.357-81.28L162.626,32.8z"/>
  98. <path d="M108.855,7.987c0.373-0.005,0.742-0.031,1.116-0.032c56.417-0.165,102.451,45.599,102.616,102.016
  99. s-45.601,102.451-102.018,102.616C54.152,212.752,8.12,166.986,7.955,110.569c-0.044-15.218,3.278-29.667,9.224-42.677
  100. l-4.512-2.044C6.435,79.486,2.954,94.632,3,110.584c0.173,59.15,48.433,107.131,107.583,106.958
  101. c59.15-0.173,107.131-48.435,106.958-107.585S169.106,2.828,109.957,3c-0.388,0.001-0.77,0.027-1.156,0.033L108.855,7.987z"/>
  102. </g>
  103. </svg>
  104. </div>';
  105. }
  106. add_shortcode('svg_button', 'wittyplex_adding_custom_svg_button');