/wp-content/themes/bridge/plugins/js_composer/js_composer/include/params/default_params.php

https://gitlab.com/juanito.abelo/nlmobile · PHP · 341 lines · 180 code · 23 blank · 138 comment · 19 complexity · fecbb9f303d57311c6ab39b62b99ad59 MD5 · raw file

  1. <?php
  2. /**
  3. * WPBakery Visual Composer shortcode default attributes functions for rendering.
  4. *
  5. * @package WPBakeryVisualComposer
  6. * @since 4.4
  7. */
  8. /**
  9. * Textfield shortcode attribute type generator.
  10. *
  11. * @param $settings
  12. * @param $value
  13. *
  14. * @since 4.4
  15. * @return string - html string.
  16. */
  17. function vc_textfield_form_field( $settings, $value ) {
  18. $value = __( $value, "js_composer" );
  19. $value = htmlspecialchars( $value );
  20. //$value = $param_value;
  21. return '<input name="' . $settings['param_name']
  22. . '" class="wpb_vc_param_value wpb-textinput '
  23. . $settings['param_name'] . ' ' . $settings['type']
  24. . '" type="text" value="' . $value . '"/>';
  25. }
  26. /**
  27. * Dropdown(select with options) shortcode attribute type generator.
  28. *
  29. * @param $settings
  30. * @param $value
  31. *
  32. * @since 4.4
  33. * @return string - html string.
  34. */
  35. function vc_dropdown_form_field( $settings, $value ) {
  36. $output = '';
  37. $css_option = vc_get_dropdown_option( $settings, $value );
  38. $output .= '<select name="'
  39. . $settings['param_name']
  40. . '" class="wpb_vc_param_value wpb-input wpb-select '
  41. . $settings['param_name']
  42. . ' ' . $settings['type']
  43. . ' ' . $css_option
  44. . '" data-option="' . $css_option . '">';
  45. if ( is_array( $value ) ) {
  46. $value = isset( $value['value'] ) ? $value['value'] : array_shift( $value );
  47. }
  48. foreach ( $settings['value'] as $index => $data ) {
  49. if ( is_numeric( $index ) && ( is_string( $data ) || is_numeric( $data ) ) ) {
  50. $option_label = $data;
  51. $option_value = $data;
  52. } elseif ( is_numeric( $index ) && is_array( $data ) ) {
  53. $option_label = isset( $data['label'] ) ? $data['label'] : array_pop( $data );
  54. $option_value = isset( $data['value'] ) ? $data['value'] : array_pop( $data );
  55. } else {
  56. $option_value = $data;
  57. $option_label = $index;
  58. }
  59. $option_label = __( $option_label, "js_composer" );
  60. //$val = strtolower(str_replace(array(" "), array("_"), $val));
  61. //$val = strtolower(str_replace(array(" "), array("_"), $val)); //issue #464 github
  62. $selected = '';
  63. if ( $value !== '' && (string) $option_value === (string) $value ) {
  64. $selected = ' selected="selected"';
  65. }
  66. $output .= '<option class="' . $option_value . '" value="' . $option_value . '"' . $selected . '>'
  67. . htmlspecialchars( $option_label ) . '</option>';
  68. }
  69. $output .= '</select>';
  70. return $output;
  71. }
  72. /**
  73. * Checkbox shortcode attribute type generator.
  74. *
  75. * @param $settings
  76. * @param string $value
  77. *
  78. * @since 4.4
  79. * @return string - html string.
  80. */
  81. function vc_checkbox_form_field( $settings, $value ) {
  82. $output = '';
  83. if ( is_array( $value ) ) {
  84. $value = ''; // fix #1239
  85. }
  86. $current_value = strlen( $value ) > 0 ? explode( ",", $value ) : array();
  87. $values = is_array( $settings['value'] ) ? $settings['value'] : array();
  88. foreach ( $values as $label => $v ) {
  89. $checked = count( $current_value ) > 0 && in_array( $v, $current_value ) ? ' checked="checked"' : '';
  90. $output .= ' <label class="vc_checkbox-label"><input id="'
  91. . $settings['param_name'] . '-' . $v . '" value="'
  92. . $v . '" class="wpb_vc_param_value '
  93. . $settings['param_name'] . ' ' . $settings['type'] . '" type="checkbox" name="'
  94. . $settings['param_name'] . '"'
  95. . $checked . '> ' . __( $label, "js_composer" ) . '</label>';
  96. }
  97. return $output;
  98. }
  99. /**
  100. * Checkbox shortcode attribute type generator.
  101. *
  102. * @param $settings
  103. * @param $value
  104. *
  105. * @since 4.4
  106. * @return string - html string.
  107. */
  108. function vc_posttypes_form_field( $settings, $value ) {
  109. $output = '';
  110. $args = array(
  111. 'public' => true
  112. );
  113. $post_types = get_post_types( $args );
  114. foreach ( $post_types as $post_type ) {
  115. $checked = "";
  116. if ( $post_type != 'attachment' ) {
  117. if ( in_array( $post_type, explode( ",", $value ) ) ) {
  118. $checked = ' checked="checked"';
  119. }
  120. $output .= ' <label class="vc_checkbox-label"><input id="'
  121. . $settings['param_name'] . '-' . $post_type . '" value="'
  122. . $post_type . '" class="wpb_vc_param_value '
  123. . $settings['param_name']
  124. . ' ' . $settings['type']
  125. . '" type="checkbox" name="'
  126. . $settings['param_name'] . '"' . $checked . '> '
  127. . $post_type . '</label>';
  128. }
  129. }
  130. return $output;
  131. }
  132. /**
  133. * Taxonomies shortcode attribute type generator.
  134. *
  135. * @param $settings
  136. * @param $value
  137. *
  138. * @since 4.4
  139. * @return string - html string.
  140. */
  141. function vc_taxonomies_form_field( $settings, $value ) {
  142. $output = '';
  143. $post_types = get_post_types( array( 'public' => false, 'name' => 'attachment' ), 'names', 'NOT' );
  144. foreach ( $post_types as $type ) {
  145. $taxonomies = get_object_taxonomies( $type, '' );
  146. foreach ( $taxonomies as $tax ) {
  147. $checked = "";
  148. if ( in_array( $tax->name, explode( ",", $value ) ) ) {
  149. $checked = ' checked="checked"';
  150. }
  151. $output .= ' <label class="vc_checkbox-label" data-post-type="'
  152. . $type . '"><input id="'
  153. . $settings['param_name'] . '-' . $tax->name
  154. . '" value="' . $tax->name
  155. . '" data-post-type="' . $type
  156. . '" class="wpb_vc_param_value '
  157. . $settings['param_name']
  158. . ' ' . $settings['type']
  159. . '" type="checkbox" name="' . $settings['param_name'] . '"' . $checked . '> '
  160. . $tax->label . '</label>';
  161. }
  162. }
  163. return $output;
  164. }
  165. /**
  166. * @deprecated
  167. *
  168. * @param $settings
  169. * @param $value
  170. *
  171. * @since 4.4
  172. * @return string
  173. */
  174. function vc_taxomonies_form_field( $settings, $value ) {
  175. return vc_taxonomies_form_field( $settings, $value );
  176. }
  177. /**
  178. * Exploded textarea shortcode attribute type generator.
  179. *
  180. * Data saved and coma-separated values are merged with line breaks and returned in a textarea.
  181. *
  182. * @param $settings
  183. * @param $value
  184. *
  185. * @since 4.4
  186. * @return string - html string.
  187. */
  188. function vc_exploded_textarea_form_field( $settings, $value ) {
  189. $value = str_replace( ",", "\n", $value );
  190. return '<textarea name="'
  191. . $settings['param_name'] . '" class="wpb_vc_param_value wpb-textarea '
  192. . $settings['param_name'] . ' ' . $settings['type'] . '">' . $value . '</textarea>';
  193. }
  194. /**
  195. * Textarea raw html shortcode attribute type generator.
  196. *
  197. * This attribute type allows safely add custom html to your post/page.
  198. *
  199. * @param $settings
  200. * @param $value
  201. *
  202. * @since 4.4
  203. * @return string - html string.
  204. */
  205. function vc_textarea_raw_html_form_field( $settings, $value ) {
  206. return '<textarea name="'
  207. . $settings['param_name'] . '" class="wpb_vc_param_value wpb-textarea_raw_html '
  208. . $settings['param_name'] . ' ' . $settings['type'] . '" rows="16">'
  209. . htmlentities( rawurldecode( base64_decode( $value ) ), ENT_COMPAT, 'UTF-8' ) . '</textarea>';
  210. }
  211. /**
  212. * Safe Textarea shortcode attribute type generator.
  213. *
  214. * @param $settings
  215. * @param $value
  216. *
  217. * @since 4.4
  218. * @return string - html string.
  219. */
  220. function vc_textarea_safe_form_field( $settings, $value ) {
  221. return '<textarea name="'
  222. . $settings['param_name'] . '" class="wpb_vc_param_value wpb-textarea_raw_html '
  223. . $settings['param_name'] . ' ' . $settings['type'] . '">'
  224. . vc_value_from_safe( $value, true ) . '</textarea>';
  225. }
  226. /**
  227. * Textarea shortcode attribute type generator.
  228. *
  229. * @param $settings
  230. * @param $value
  231. *
  232. * @since 4.4
  233. * @return string - html string.
  234. */
  235. function vc_textarea_form_field( $settings, $value ) {
  236. $value = __( $value, "js_composer" );
  237. return '<textarea name="' .
  238. $settings['param_name'] . '" class="wpb_vc_param_value wpb-textarea '
  239. . $settings['param_name'] . ' ' . $settings['type'] . '">' . $value . '</textarea>';
  240. }
  241. /**
  242. * Attach images shortcode attribute type generator.
  243. *
  244. * @param $settings
  245. * @param $value
  246. *
  247. * @since 4.4
  248. *
  249. * @param $tag
  250. * @param bool $single
  251. *
  252. * @return string - html string.
  253. */
  254. function vc_attach_images_form_field( $settings, $value, $tag, $single = false ) {
  255. $output = '';
  256. $param_value = wpb_removeNotExistingImgIDs( $value );
  257. $output .= '<input type="hidden" class="wpb_vc_param_value gallery_widget_attached_images_ids '
  258. . $settings['param_name'] . ' '
  259. . $settings['type'] . '" name="' . $settings['param_name'] . '" value="' . $value . '"/>';
  260. $output .= '<div class="gallery_widget_attached_images">';
  261. $output .= '<ul class="gallery_widget_attached_images_list">';
  262. $output .= ( $param_value != '' ) ? fieldAttachedImages( explode( ",", $value ) ) : '';
  263. $output .= '</ul>';
  264. $output .= '</div>';
  265. $output .= '<div class="gallery_widget_site_images">';
  266. // $param_line .= siteAttachedImages(explode(",", $param_value));
  267. $output .= '</div>';
  268. if ( $single === true ) {
  269. $output .= '<a class="gallery_widget_add_images" href="#" use-single="true" title="'
  270. . __( 'Add image', "js_composer" ) . '">' . __( 'Add image', "js_composer" ) . '</a>'; //class: button
  271. } else {
  272. $output .= '<a class="gallery_widget_add_images" href="#" title="'
  273. . __( 'Add images', "js_composer" ) . '">' . __( 'Add images', "js_composer" ) . '</a>'; //class: button
  274. }
  275. //$param_line .= '<div class="wpb_clear"></div>';
  276. return $output;
  277. }
  278. /**
  279. * Attach image shortcode attribute type generator.
  280. *
  281. * @param $settings
  282. * @param $value
  283. *
  284. * @param $tag
  285. *
  286. * @since 4.4
  287. * @return string - html string.
  288. */
  289. function vc_attach_image_form_field( $settings, $value, $tag ) {
  290. return vc_attach_images_form_field( $settings, $value, $tag, true );
  291. }
  292. /**
  293. * Widgetised sidebars shortcode attribute type generator.
  294. *
  295. * @param $settings
  296. * @param $value
  297. *
  298. * @since 4.4
  299. * @return string - html string.
  300. */
  301. function vc_widgetised_sidebars_form_field( $settings, $value ) {
  302. $output = '';
  303. $sidebars = $GLOBALS['wp_registered_sidebars'];
  304. $output .= '<select name="' . $settings['param_name']
  305. . '" class="wpb_vc_param_value dropdown wpb-input wpb-select '
  306. . $settings['param_name'] . ' '
  307. . $settings['type'] . '">';
  308. foreach ( $sidebars as $sidebar ) {
  309. $selected = '';
  310. if ( $sidebar["id"] == $value ) {
  311. $selected = ' selected="selected"';
  312. }
  313. $sidebar_name = __( $sidebar["name"], "js_composer" );
  314. $output .= '<option value="' . $sidebar["id"] . '"' . $selected . '>' . $sidebar_name . '</option>';
  315. }
  316. $output .= '</select>';
  317. return $output;
  318. }