display-conditions
5 years ago
front
5 years ago
helpers
5 years ago
metas
5 years ago
palettes
5 years ago
provider
5 years ago
providers
5 years ago
templates
5 years ago
update
5 years ago
class-hustle-admin-page-abstract.php
5 years ago
class-hustle-condition-factory.php
6 years ago
class-hustle-dashboard-admin.php
5 years ago
class-hustle-data.php
5 years ago
class-hustle-db.php
6 years ago
class-hustle-module-admin.php
5 years ago
class-hustle-module-collection.php
5 years ago
class-hustle-module-decorator.php
5 years ago
class-hustle-module-page-abstract.php
5 years ago
class-hustle-notifications.php
5 years ago
class-hustle-settings-admin.php
5 years ago
class-hustle-upsell-page.php
5 years ago
class-hustle-wp-dashboard-page.php
5 years ago
hustle-collection.php
6 years ago
hustle-deletion.php
5 years ago
hustle-embedded-admin.php
6 years ago
hustle-entries-admin.php
5 years ago
hustle-entry-model.php
5 years ago
hustle-general-data-protection.php
6 years ago
hustle-init.php
5 years ago
hustle-mail.php
5 years ago
hustle-meta.php
5 years ago
hustle-migration.php
5 years ago
hustle-model.php
5 years ago
hustle-module-model.php
5 years ago
hustle-module-widget-legacy.php
5 years ago
hustle-module-widget.php
5 years ago
hustle-modules-common-admin-ajax.php
5 years ago
hustle-popup-admin.php
6 years ago
hustle-providers-admin.php
5 years ago
hustle-providers.php
6 years ago
hustle-settings-admin-ajax.php
5 years ago
hustle-settings-page.php
5 years ago
hustle-slidein-admin.php
6 years ago
hustle-sshare-admin.php
5 years ago
hustle-sshare-model.php
5 years ago
hustle-tracking-model.php
5 years ago
opt-in-geo.php
5 years ago
opt-in-utils.php
5 years ago
opt-in-wpmudev-api.php
6 years ago
hustle-meta.php
62 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Abstract Hustle_Meta class. |
| 4 | * Extended by each handler of the modules' metas. |
| 5 | * |
| 6 | * When creating a new meta property: |
| 7 | * -Booleans properties must be '0' and '1', as strings. Make sure they're also stored in this way when saving. |
| 8 | */ |
| 9 | abstract class Hustle_Meta { |
| 10 | |
| 11 | protected $data; |
| 12 | |
| 13 | /** |
| 14 | * Current module. |
| 15 | * |
| 16 | * @since unknown |
| 17 | * @var Hustle_Model |
| 18 | */ |
| 19 | protected $module; |
| 20 | |
| 21 | protected $defaults = array(); |
| 22 | |
| 23 | public function __construct( array $data, Hustle_Model $model ) { |
| 24 | $this->data = $data; |
| 25 | $this->module = $model; |
| 26 | $this->defaults = apply_filters( 'hustle_meta_get_defaults', $this->get_defaults(), $this, $model, $data ); |
| 27 | } |
| 28 | |
| 29 | public function to_array() { |
| 30 | |
| 31 | $defaults = $this->get_defaults(); |
| 32 | if ( $defaults ) { |
| 33 | if ( isset( $defaults['form_elements'] ) && ! empty( $this->data['form_elements'] ) ) { |
| 34 | unset( $defaults['form_elements'] ); |
| 35 | } |
| 36 | |
| 37 | return array_replace_recursive( $defaults, $this->data ); |
| 38 | } |
| 39 | |
| 40 | return $this->data; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Return an array with the default values. |
| 45 | * Can be overridden to return an array of default values |
| 46 | * without restricting to static values. |
| 47 | * |
| 48 | * @since 4.0 |
| 49 | * |
| 50 | * @return array|false |
| 51 | */ |
| 52 | public function get_defaults() { |
| 53 | |
| 54 | if ( isset( $this->defaults ) && is_array( $this->defaults ) ) { |
| 55 | return $this->defaults; |
| 56 | } |
| 57 | |
| 58 | return false; |
| 59 | } |
| 60 | |
| 61 | } |
| 62 |