/shared/shortcodes/shortcodes/column.php

https://github.com/deltafactory/landing-pages · PHP · 170 lines · 136 code · 14 blank · 20 comment · 14 complexity · c22fb5a56f9005133d8580b621519ea1 MD5 · raw file

  1. <?php
  2. /**
  3. * Columns Shortcode
  4. */
  5. /* Shortcode generator config
  6. * ----------------------------------------------------- */
  7. $shortcodes_config['columns'] = array(
  8. 'no_preview' => true,
  9. 'options' => array(
  10. 'gutter' => array(
  11. 'name' => __('Gutter Width', 'leads'),
  12. 'desc' => __('A space between the columns.', 'leads'),
  13. 'type' => 'select',
  14. 'options' => array(
  15. '20' => '20px',
  16. '30' => '30px'
  17. ),
  18. 'std' => ''
  19. ),
  20. 'set' => array(
  21. 'name' => __('Column Set', 'leads'),
  22. 'desc' => __('Select the set.', 'leads'),
  23. 'type' => 'select',
  24. 'options' => array(
  25. '[one_full]Content goes here[/one_full]' => '1/1',
  26. '[one_half]Content goes here[/one_half][one_half]Content goes here[/one_half]' => '1/2 + 1/2',
  27. '[one_third]Content goes here[/one_third][one_third]Content goes here[/one_third][one_third]Content goes here[/one_third]' => '1/3 + 1/3 + 1/3',
  28. '[two_third]Content goes here[/two_third][one_third]Content goes here[/one_third]' => '2/3 + 1/3',
  29. '[one_fourth]Content goes here[/one_fourth][one_fourth]Content goes here[/one_fourth][one_fourth]Content goes here[/one_fourth][one_fourth]Content goes here[/one_fourth]' => '1/4 + 1/4 + 1/4 + 1/4',
  30. '[one_half]Content goes here[/one_half][one_fourth]Content goes here[/one_fourth][one_fourth]Content goes here[/one_fourth]' => '1/2 + 1/4 + 1/4',
  31. '[three_fourth]Content goes here[/three_fourth][one_fourth]Content goes here[/one_fourth]' => '3/4 + 1/4',
  32. '[one_fifth]Content goes here[/one_fifth][one_fifth]Content goes here[/one_fifth][one_fifth]Content goes here[/one_fifth][one_fifth]Content goes here[/one_fifth][one_fifth]Content goes here[/one_fifth]' => '1/5 + 1/5 + 1/5 + 1/5 + 1/5',
  33. '[two_fifth]Content goes here[/two_fifth][one_fifth]Content goes here[/one_fifth][one_fifth]Content goes here[/one_fifth][one_fifth]Content goes here[/one_fifth]' => '2/5 + 1/5 + 1/5 + 1/5',
  34. '[three_fifth]Content goes here[/three_fifth][one_fifth]Content goes here[/one_fifth][one_fifth]Content goes here[/one_fifth]' => '3/5 + 1/5 + 1/5',
  35. '[four_fifth]Content goes here[/four_fifth][one_fifth]Content goes here[/one_fifth]' => '4/5 + 1/5',
  36. ),
  37. 'std' => ''
  38. )
  39. ),
  40. 'shortcode' => '[columns gutter="{{gutter}}"]{{set}}[/columns]',
  41. 'popup_title' => 'Insert Column Shortcode'
  42. );
  43. /* Page builder module config
  44. * ----------------------------------------------------- */
  45. $freshbuilder_modules['column'] = array(
  46. 'name' => __('Column', 'leads'),
  47. 'size' => 'one_fifth',
  48. 'options' => array(
  49. 'content' => array(
  50. 'name' => __('Column Content', 'leads'),
  51. 'desc' => __('Enter the column content', 'leads'),
  52. 'type' => 'textarea',
  53. 'std' => '',
  54. 'class' => 'wide',
  55. 'is_content' => '1'
  56. )
  57. )
  58. );
  59. /* Add shortcode
  60. * ----------------------------------------------------- */
  61. /* Columns Wrap */
  62. if (!function_exists('inbound_shortcode_columns')) {
  63. function inbound_shortcode_columns( $atts, $content = null ) {
  64. extract(shortcode_atts(array(
  65. 'gutter' => '20'
  66. ), $atts));
  67. if( $gutter == '30') {
  68. $gutter = 'inbound-row_30';
  69. } else {
  70. $gutter = 'inbound-row';
  71. }
  72. $content = preg_replace('/<br class=\'inbr\'.*\/>/', '', $content); // remove editor br tags
  73. return '<div class="'. $gutter .'">' . do_shortcode($content) . '</div>';
  74. }
  75. }
  76. add_shortcode('columns', 'inbound_shortcode_columns');
  77. /* Full column */
  78. if (!function_exists('inbound_shortcode_full_columns')) {
  79. function inbound_shortcode_full_columns( $atts, $content = null ) {
  80. $content = preg_replace('/<br class="inbr".\/>/', '', $content); // remove editor br tags
  81. return '<div class="inbound-grid full">' . do_shortcode($content) . '</div>';
  82. }
  83. }
  84. add_shortcode('one_full', 'inbound_shortcode_full_columns');
  85. /* One Half */
  86. if (!function_exists('inbound_shortcode_one_half_columns')) {
  87. function inbound_shortcode_one_half_columns( $atts, $content = null ) {
  88. $content = preg_replace('/<br class="inbr".\/>/', '', $content); // remove editor br tags
  89. return '<div class="inbound-grid one-half">' . do_shortcode($content) . '</div>';
  90. }
  91. }
  92. add_shortcode('one_half', 'inbound_shortcode_one_half_columns');
  93. /* One Third */
  94. if (!function_exists('inbound_shortcode_one_third_columns')) {
  95. function inbound_shortcode_one_third_columns( $atts, $content = null ) {
  96. $content = preg_replace('/<br class="inbr".\/>/', '', $content); // remove editor br tags
  97. return '<div class="inbound-grid one-third">' . do_shortcode($content) . '</div>';
  98. }
  99. }
  100. add_shortcode('one_third', 'inbound_shortcode_one_third_columns');
  101. /* Two Third */
  102. if (!function_exists('inbound_shortcode_two_third_columns')) {
  103. function inbound_shortcode_two_third_columns( $atts, $content = null ) {
  104. $content = preg_replace('/<br class="inbr".\/>/', '', $content); // remove editor br tags
  105. return '<div class="inbound-grid two-third">' . do_shortcode($content) . '</div>';
  106. }
  107. }
  108. add_shortcode('two_third', 'inbound_shortcode_two_third_columns');
  109. /* One Fourth */
  110. if (!function_exists('inbound_shortcode_one_fourth_columns')) {
  111. function inbound_shortcode_one_fourth_columns( $atts, $content = null ) {
  112. $content = preg_replace('/<br class="inbr".\/>/', '', $content); // remove editor br tags
  113. return '<div class="inbound-grid one-fourth">' . do_shortcode($content) . '</div>';
  114. }
  115. }
  116. add_shortcode('one_fourth', 'inbound_shortcode_one_fourth_columns');
  117. /* Three Fourth */
  118. if (!function_exists('inbound_shortcode_three_fourth_columns')) {
  119. function inbound_shortcode_three_fourth_columns( $atts, $content = null ) {
  120. $content = preg_replace('/<br class="inbr".\/>/', '', $content); // remove editor br tags
  121. return '<div class="inbound-grid three-fourth">' . do_shortcode($content) . '</div>';
  122. }
  123. }
  124. add_shortcode('three_fourth', 'inbound_shortcode_three_fourth_columns');
  125. /* One Fifth */
  126. if (!function_exists('inbound_shortcode_one_fifth_columns')) {
  127. function inbound_shortcode_one_fifth_columns( $atts, $content = null ) {
  128. $content = preg_replace('/<br class="inbr".\/>/', '', $content); // remove editor br tags
  129. return '<div class="inbound-grid one-fifth">' . do_shortcode($content) . '</div>';
  130. }
  131. }
  132. add_shortcode('one_fifth', 'inbound_shortcode_one_fifth_columns');
  133. /* Two Fifth */
  134. if (!function_exists('inbound_shortcode_two_fifth_columns')) {
  135. function inbound_shortcode_two_fifth_columns( $atts, $content = null ) {
  136. $content = preg_replace('/<br class="inbr".\/>/', '', $content); // remove editor br tags
  137. return '<div class="inbound-inbound-grid two-fifth">' . do_shortcode($content) . '</div>';
  138. }
  139. }
  140. add_shortcode('two_fifth', 'inbound_shortcode_two_fifth_columns');
  141. /* Three Fifth */
  142. if (!function_exists('inbound_shortcode_three_fifth_columns')) {
  143. function inbound_shortcode_three_fifth_columns( $atts, $content = null ) {
  144. $content = preg_replace('/<br class="inbr".\/>/', '', $content); // remove editor br tags
  145. return '<div class="inbound-inbound-grid three-fifth">' . do_shortcode($content) . '</div>';
  146. }
  147. }
  148. add_shortcode('three_fifth', 'inbound_shortcode_three_fifth_columns');
  149. /* Four Fifth */
  150. if (!function_exists('inbound_shortcode_four_fifth_columns')) {
  151. function inbound_shortcode_four_fifth_columns( $atts, $content = null ) {
  152. $content = preg_replace('/<br class="inbr".\/>/', '', $content); // remove editor br tags
  153. return '<div class="inbound-inbound-grid three-four">' . do_shortcode($content) . '</div>';
  154. }
  155. }
  156. add_shortcode('three_four', 'inbound_shortcode_four_fifth_columns');