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