Guest User

Untitled

a guest
Jul 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2.  
  3. // START COPYING HERE...
  4.  
  5. /**
  6. * Populate predefined CSS classes dropdown selector.
  7. *
  8. * Requires Beaver Builder v2.1.4 and newer!
  9. *
  10. * @param array $field An array of setup data for the field.
  11. * @param string $field_key The field name/key.
  12. */
  13. function beaver_builder_css_class_dropdown( $field, $field_key ) {
  14.  
  15. // Processing
  16.  
  17. if ( 'class' == $field_key ) {
  18. $field['options'] = array(
  19.  
  20. '' => esc_html__( '- Choose from predefined classes -', 'textdomain' ),
  21.  
  22. // Optgroup 1
  23.  
  24. 'optgroup-id-1' => array(
  25. 'label' => esc_html__( 'Optgroup 1 title:', 'textdomain' ),
  26. 'options' => array(
  27. 'my-class-1' => esc_html__( 'My custom class 1', 'textdomain' ),
  28. 'my-class-2' => esc_html__( 'My custom class 1', 'textdomain' ),
  29. ),
  30. ),
  31.  
  32. // Optgroup 2
  33.  
  34. 'optgroup-id-2' => array(
  35. 'label' => esc_html__( 'Optgroup 2 title:', 'textdomain' ),
  36. 'options' => array(
  37. 'my-class-3' => esc_html__( 'My custom class 3', 'textdomain' ),
  38. ),
  39. ),
  40.  
  41. );
  42. }
  43.  
  44.  
  45. // Output
  46.  
  47. return $field;
  48.  
  49. } // /beaver_builder_css_class_dropdown
  50.  
  51. add_filter( 'fl_builder_field_js_config', 'beaver_builder_css_class_dropdown', 10, 2 );
  52.  
  53. // ...STOP COPYING HERE. NOW YOU CAN INSERT THE CODE INTO YOUR PHP FILE.
Add Comment
Please, Sign In to add comment