PodsComponent

The base component class, all components should extend this.

Defined (1)

The class is defined in the following location(s).

/classes/PodsComponent.php  
  1. class PodsComponent { 
  2.  
  3. /** 
  4. * Do things like register/enqueue scripts and stylesheets 
  5. * @return \PodsComponent 
  6. * @since 2.0 
  7. */ 
  8. public function __construct () { 
  9.  
  10.  
  11. /** 
  12. * Add options and set defaults for component settings, shows in admin area 
  13. * @return array $options 
  14. * @since 2.0 
  15. public function options () { 
  16. $options = array( 
  17. 'option_name' => array( 
  18. 'label' => 'Option Label',  
  19. 'depends-on' => array( 'another_option' => 'specific-value' ),  
  20. 'default' => 'default-value',  
  21. 'type' => 'field_type',  
  22. 'data' => array( 
  23. 'value1' => 'Label 1',  
  24.   
  25. // Group your options together 
  26. 'Option Group' => array( 
  27. 'gvalue1' => 'Option Label 1',  
  28. 'gvalue2' => 'Option Label 2' 
  29. ),  
  30.   
  31. // below is only if the option_name above is the "{$fieldtype}_format_type" 
  32. 'value2' => array( 
  33. 'label' => 'Label 2',  
  34. 'regex' => '[a-zA-Z]' // Uses JS regex validation for the value saved if this option selected 
  35. ),  
  36.   
  37. // below is only for a boolean group 
  38. 'group' => array( 
  39. 'option_boolean1' => array( 
  40. 'label' => 'Option boolean 1?',  
  41. 'default' => 1,  
  42. 'type' => 'boolean' 
  43. ),  
  44. 'option_boolean2' => array( 
  45. 'label' => 'Option boolean 2?',  
  46. 'default' => 0,  
  47. 'type' => 'boolean' 
  48. ); 
  49.   
  50. return $options; 
  51. */ 
  52.  
  53. /** 
  54. * Handler to run code based on $options 
  55. * @param $options 
  56. * @since 2.0 
  57. */ 
  58. public function handler ( $options ) { 
  59. // run code based on $options set 
  60.  
  61. /** 
  62. * Build admin area 
  63. * @param $options 
  64. * @since 2.0 
  65. public function admin ( $options ) { 
  66. // run code based on $options set 
  67. */