cli
3 years ago
fields
2 years ago
widgets
3 years ago
Pods.php
2 years ago
PodsAPI.php
2 years ago
PodsAdmin.php
2 years ago
PodsArray.php
2 years ago
PodsComponent.php
8 years ago
PodsComponents.php
3 years ago
PodsData.php
2 years ago
PodsField.php
2 years ago
PodsForm.php
2 years ago
PodsI18n.php
4 years ago
PodsInit.php
2 years ago
PodsMeta.php
2 years ago
PodsMigrate.php
3 years ago
PodsRESTFields.php
2 years ago
PodsRESTHandlers.php
3 years ago
PodsTermSplitting.php
3 years ago
PodsUI.php
2 years ago
PodsView.php
2 years ago
PodsComponent.php
102 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The base component class, all components should extend this. |
| 5 | * |
| 6 | * @package Pods |
| 7 | */ |
| 8 | class PodsComponent { |
| 9 | |
| 10 | /** |
| 11 | * Setup initial component class. |
| 12 | * |
| 13 | * @since 2.0.0 |
| 14 | */ |
| 15 | public function __construct() { |
| 16 | |
| 17 | $this->init(); |
| 18 | |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Do things like register/enqueue scripts and stylesheets. |
| 23 | * |
| 24 | * @since 2.7.2 |
| 25 | */ |
| 26 | public function init() { |
| 27 | |
| 28 | |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Add options and set defaults for component settings, shows in admin area |
| 33 | * |
| 34 | * @return array $options |
| 35 | * |
| 36 | * @since 2.0.0 |
| 37 | * public function options () { |
| 38 | * $options = array( |
| 39 | * 'option_name' => array( |
| 40 | * 'label' => 'Option Label', |
| 41 | * 'depends-on' => array( 'another_option' => 'specific-value' ), |
| 42 | * 'default' => 'default-value', |
| 43 | * 'type' => 'field_type', |
| 44 | * 'data' => array( |
| 45 | * 'value1' => 'Label 1', |
| 46 | * |
| 47 | * // Group your options together |
| 48 | * 'Option Group' => array( |
| 49 | * 'gvalue1' => 'Option Label 1', |
| 50 | * 'gvalue2' => 'Option Label 2' |
| 51 | * ), |
| 52 | * |
| 53 | * // below is only if the option_name above is the "{$fieldtype}_format_type" |
| 54 | * 'value2' => array( |
| 55 | * 'label' => 'Label 2', |
| 56 | * 'regex' => '[a-zA-Z]' // Uses JS regex validation for the value saved if this option selected |
| 57 | * ) |
| 58 | * ), |
| 59 | * |
| 60 | * // below is only for a boolean group |
| 61 | * 'group' => array( |
| 62 | * 'option_boolean1' => array( |
| 63 | * 'label' => 'Option boolean 1?', |
| 64 | * 'default' => 1, |
| 65 | * 'type' => 'boolean' |
| 66 | * ), |
| 67 | * 'option_boolean2' => array( |
| 68 | * 'label' => 'Option boolean 2?', |
| 69 | * 'default' => 0, |
| 70 | * 'type' => 'boolean' |
| 71 | * ) |
| 72 | * ) |
| 73 | * ) |
| 74 | * ); |
| 75 | * |
| 76 | * return $options; |
| 77 | * } |
| 78 | */ |
| 79 | |
| 80 | /** |
| 81 | * Handler to run code based on $options |
| 82 | * |
| 83 | * @param array $options Component options. |
| 84 | * |
| 85 | * @since 2.0.0 |
| 86 | */ |
| 87 | public function handler( $options ) { |
| 88 | // run code based on $options set |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Build admin area |
| 93 | * |
| 94 | * @param array $options Component options. |
| 95 | * |
| 96 | * @since 2.0.0 |
| 97 | * public function admin ( $options ) { |
| 98 | * // run code based on $options set |
| 99 | * } |
| 100 | */ |
| 101 | } |
| 102 |