1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
<?php
class Papi_Option_Store extends Papi_Core_Meta_Store {
protected $type = 'option';
public function __construct( $id = 0 ) {
$this->id = 0;
}
public function get_property( $slug, $child_slug = '' ) {
$entry_type_id = papi_get_qs( 'page' );
if ( empty( $entry_type_id ) ) {
$property = null;
$entry_types = papi_get_all_entry_types( [
'types' => 'option'
] );
foreach ( $entry_types as $entry_type ) {
if ( $property = $entry_type->get_property( $slug, $child_slug ) ) {
break;
}
}
if ( is_null( $property ) ) {
return;
}
return $property;
}
$entry_type = papi_get_entry_type_by_id( $entry_type_id );
if ( $entry_type instanceof Papi_Option_Type === false ) {
return;
}
if ( $property = $entry_type->get_property( $slug, $child_slug ) ) {
return $this->prepare_property( $property );
}
}
public function valid() {
return $this->id === 0;
}
}