@@ -7,21 +7,21 @@ |
||
| 7 | 7 | |
| 8 | 8 | class FieldDefinitionFactory { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * @var $schema Schema |
|
| 12 | - */ |
|
| 13 | - private $schema; |
|
| 10 | + /** |
|
| 11 | + * @var $schema Schema |
|
| 12 | + */ |
|
| 13 | + private $schema; |
|
| 14 | 14 | |
| 15 | - public function __construct( $schema ) { |
|
| 16 | - $this->schema = $schema; |
|
| 17 | - } |
|
| 15 | + public function __construct( $schema ) { |
|
| 16 | + $this->schema = $schema; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | - public function get_field_definition() { |
|
| 21 | - $context = $this->schema->get(); |
|
| 22 | - // For now we are registering all the pods. |
|
| 23 | - return new AllPodsDefiniton( $context ); |
|
| 24 | - } |
|
| 20 | + public function get_field_definition() { |
|
| 21 | + $context = $this->schema->get(); |
|
| 22 | + // For now we are registering all the pods. |
|
| 23 | + return new AllPodsDefiniton( $context ); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | private $schema; |
| 14 | 14 | |
| 15 | - public function __construct( $schema ) { |
|
| 15 | + public function __construct($schema) { |
|
| 16 | 16 | $this->schema = $schema; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | public function get_field_definition() { |
| 21 | 21 | $context = $this->schema->get(); |
| 22 | 22 | // For now we are registering all the pods. |
| 23 | - return new AllPodsDefiniton( $context ); |
|
| 23 | + return new AllPodsDefiniton($context); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface FieldDefinition { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * Register the fields for the provided context in constructor. |
|
| 9 | - * @return void |
|
| 10 | - */ |
|
| 11 | - public function register(); |
|
| 7 | + /** |
|
| 8 | + * Register the fields for the provided context in constructor. |
|
| 9 | + * @return void |
|
| 10 | + */ |
|
| 11 | + public function register(); |
|
| 12 | 12 | |
| 13 | 13 | } |
| 14 | 14 | |
@@ -11,27 +11,27 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class AllPodsDefiniton extends AbstractFieldDefiniton { |
| 13 | 13 | |
| 14 | - public function register() { |
|
| 14 | + public function register() { |
|
| 15 | 15 | |
| 16 | - add_action( 'init', array( $this, 'register_on_all_valid_post_types' ) ); |
|
| 17 | - add_action( 'setup_theme', array( $this, 'register_on_all_supported_taxonomies' ) ); |
|
| 18 | - } |
|
| 16 | + add_action( 'init', array( $this, 'register_on_all_valid_post_types' ) ); |
|
| 17 | + add_action( 'setup_theme', array( $this, 'register_on_all_supported_taxonomies' ) ); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | 20 | |
| 21 | - public function register_on_all_supported_taxonomies() { |
|
| 22 | - $taxonomies = Terms_Compat::get_public_taxonomies(); |
|
| 23 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 24 | - $this->register_pod( $taxonomy, 'taxonomy', $this->context ); |
|
| 21 | + public function register_on_all_supported_taxonomies() { |
|
| 22 | + $taxonomies = Terms_Compat::get_public_taxonomies(); |
|
| 23 | + foreach ( $taxonomies as $taxonomy ) { |
|
| 24 | + $this->register_pod( $taxonomy, 'taxonomy', $this->context ); |
|
| 25 | 25 | |
| 26 | - } |
|
| 27 | - } |
|
| 26 | + } |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function register_on_all_valid_post_types() { |
|
| 30 | - $supported_types = \Wordlift_Entity_Service::valid_entity_post_types(); |
|
| 31 | - foreach ( $supported_types as $supported_type ) { |
|
| 32 | - $this->register_pod( $supported_type, 'post_type', $this->context ); |
|
| 33 | - } |
|
| 34 | - } |
|
| 29 | + public function register_on_all_valid_post_types() { |
|
| 30 | + $supported_types = \Wordlift_Entity_Service::valid_entity_post_types(); |
|
| 31 | + foreach ( $supported_types as $supported_type ) { |
|
| 32 | + $this->register_pod( $supported_type, 'post_type', $this->context ); |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -13,23 +13,23 @@ |
||
| 13 | 13 | |
| 14 | 14 | public function register() { |
| 15 | 15 | |
| 16 | - add_action( 'init', array( $this, 'register_on_all_valid_post_types' ) ); |
|
| 17 | - add_action( 'setup_theme', array( $this, 'register_on_all_supported_taxonomies' ) ); |
|
| 16 | + add_action('init', array($this, 'register_on_all_valid_post_types')); |
|
| 17 | + add_action('setup_theme', array($this, 'register_on_all_supported_taxonomies')); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | public function register_on_all_supported_taxonomies() { |
| 22 | 22 | $taxonomies = Terms_Compat::get_public_taxonomies(); |
| 23 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 24 | - $this->register_pod( $taxonomy, 'taxonomy', $this->context ); |
|
| 23 | + foreach ($taxonomies as $taxonomy) { |
|
| 24 | + $this->register_pod($taxonomy, 'taxonomy', $this->context); |
|
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function register_on_all_valid_post_types() { |
| 30 | 30 | $supported_types = \Wordlift_Entity_Service::valid_entity_post_types(); |
| 31 | - foreach ( $supported_types as $supported_type ) { |
|
| 32 | - $this->register_pod( $supported_type, 'post_type', $this->context ); |
|
| 31 | + foreach ($supported_types as $supported_type) { |
|
| 32 | + $this->register_pod($supported_type, 'post_type', $this->context); |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
@@ -4,82 +4,82 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Schema { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * @return Context |
|
| 9 | - */ |
|
| 10 | - public function get() { |
|
| 11 | - // we need to identify the context to filter the results. |
|
| 12 | - |
|
| 13 | - $identifier = isset( $_REQUEST['post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['post'] ) ) : ''; |
|
| 14 | - |
|
| 15 | - if ( $identifier ) { |
|
| 16 | - // If post identifier, get schema. |
|
| 17 | - return new Context( Context::POST, $identifier, $this->get_fields_for_post( $identifier ) ); |
|
| 18 | - } |
|
| 19 | - |
|
| 20 | - $identifier = isset( $_REQUEST['tag_ID'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tag_ID'] ) ) : ''; |
|
| 21 | - |
|
| 22 | - if ( $identifier ) { |
|
| 23 | - // If post identifier, get schema. |
|
| 24 | - return new Context( Context::TERM, $identifier, $this->get_fields_for_term( $identifier ) ); |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 28 | - return new Context( Context::UNKNOWN, null, null ); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - return new Context( Context::ADMIN_AJAX, null, $this->get_all_fields() ); |
|
| 32 | - |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @return Schema_Field_Group[] |
|
| 37 | - */ |
|
| 38 | - private function get_fields_for_post( $identifier ) { |
|
| 39 | - $types = \Wordlift_Entity_Type_Service::get_instance()->get_names( $identifier ); |
|
| 40 | - $schema_classes = \Wordlift_Schema_Service::get_instance(); |
|
| 41 | - |
|
| 42 | - return array_map( |
|
| 43 | - function ( $schema_type ) use ( $schema_classes ) { |
|
| 44 | - $data = $schema_classes->get_schema( strtolower( $schema_type ) ); |
|
| 45 | - |
|
| 46 | - return new Schema_Field_Group( $schema_type, $data['custom_fields'] ); |
|
| 47 | - }, |
|
| 48 | - $types |
|
| 49 | - ); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @return Schema_Field_Group[] |
|
| 54 | - */ |
|
| 55 | - private function get_fields_for_term( $identifier ) { |
|
| 56 | - $term_entity_types = get_term_meta( (int) $identifier, \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 57 | - $schema_classes = \Wordlift_Schema_Service::get_instance(); |
|
| 58 | - |
|
| 59 | - return array_map( |
|
| 60 | - function ( $schema_type ) use ( $schema_classes ) { |
|
| 61 | - $data = $schema_classes->get_schema( strtolower( $schema_type ) ); |
|
| 62 | - |
|
| 63 | - return new Schema_Field_Group( $schema_type, $data['custom_fields'] ); |
|
| 64 | - }, |
|
| 65 | - $term_entity_types |
|
| 66 | - ); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - private function get_all_fields() { |
|
| 70 | - $schema_classes = \Wordlift_Schema_Service::get_instance(); |
|
| 71 | - $all_schema_slugs = $schema_classes->get_all_schema_slugs(); |
|
| 72 | - |
|
| 73 | - return array_filter( |
|
| 74 | - array_map( |
|
| 75 | - function ( $schema_type ) use ( $schema_classes ) { |
|
| 76 | - $data = $schema_classes->get_schema( strtolower( $schema_type ) ); |
|
| 77 | - return new Schema_Field_Group( $schema_type, $data['custom_fields'] ); |
|
| 78 | - }, |
|
| 79 | - $all_schema_slugs |
|
| 80 | - ) |
|
| 81 | - ); |
|
| 82 | - } |
|
| 7 | + /** |
|
| 8 | + * @return Context |
|
| 9 | + */ |
|
| 10 | + public function get() { |
|
| 11 | + // we need to identify the context to filter the results. |
|
| 12 | + |
|
| 13 | + $identifier = isset( $_REQUEST['post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['post'] ) ) : ''; |
|
| 14 | + |
|
| 15 | + if ( $identifier ) { |
|
| 16 | + // If post identifier, get schema. |
|
| 17 | + return new Context( Context::POST, $identifier, $this->get_fields_for_post( $identifier ) ); |
|
| 18 | + } |
|
| 19 | + |
|
| 20 | + $identifier = isset( $_REQUEST['tag_ID'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tag_ID'] ) ) : ''; |
|
| 21 | + |
|
| 22 | + if ( $identifier ) { |
|
| 23 | + // If post identifier, get schema. |
|
| 24 | + return new Context( Context::TERM, $identifier, $this->get_fields_for_term( $identifier ) ); |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 28 | + return new Context( Context::UNKNOWN, null, null ); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + return new Context( Context::ADMIN_AJAX, null, $this->get_all_fields() ); |
|
| 32 | + |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @return Schema_Field_Group[] |
|
| 37 | + */ |
|
| 38 | + private function get_fields_for_post( $identifier ) { |
|
| 39 | + $types = \Wordlift_Entity_Type_Service::get_instance()->get_names( $identifier ); |
|
| 40 | + $schema_classes = \Wordlift_Schema_Service::get_instance(); |
|
| 41 | + |
|
| 42 | + return array_map( |
|
| 43 | + function ( $schema_type ) use ( $schema_classes ) { |
|
| 44 | + $data = $schema_classes->get_schema( strtolower( $schema_type ) ); |
|
| 45 | + |
|
| 46 | + return new Schema_Field_Group( $schema_type, $data['custom_fields'] ); |
|
| 47 | + }, |
|
| 48 | + $types |
|
| 49 | + ); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @return Schema_Field_Group[] |
|
| 54 | + */ |
|
| 55 | + private function get_fields_for_term( $identifier ) { |
|
| 56 | + $term_entity_types = get_term_meta( (int) $identifier, \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 57 | + $schema_classes = \Wordlift_Schema_Service::get_instance(); |
|
| 58 | + |
|
| 59 | + return array_map( |
|
| 60 | + function ( $schema_type ) use ( $schema_classes ) { |
|
| 61 | + $data = $schema_classes->get_schema( strtolower( $schema_type ) ); |
|
| 62 | + |
|
| 63 | + return new Schema_Field_Group( $schema_type, $data['custom_fields'] ); |
|
| 64 | + }, |
|
| 65 | + $term_entity_types |
|
| 66 | + ); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + private function get_all_fields() { |
|
| 70 | + $schema_classes = \Wordlift_Schema_Service::get_instance(); |
|
| 71 | + $all_schema_slugs = $schema_classes->get_all_schema_slugs(); |
|
| 72 | + |
|
| 73 | + return array_filter( |
|
| 74 | + array_map( |
|
| 75 | + function ( $schema_type ) use ( $schema_classes ) { |
|
| 76 | + $data = $schema_classes->get_schema( strtolower( $schema_type ) ); |
|
| 77 | + return new Schema_Field_Group( $schema_type, $data['custom_fields'] ); |
|
| 78 | + }, |
|
| 79 | + $all_schema_slugs |
|
| 80 | + ) |
|
| 81 | + ); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | } |
@@ -10,40 +10,40 @@ discard block |
||
| 10 | 10 | public function get() { |
| 11 | 11 | // we need to identify the context to filter the results. |
| 12 | 12 | |
| 13 | - $identifier = isset( $_REQUEST['post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['post'] ) ) : ''; |
|
| 13 | + $identifier = isset($_REQUEST['post']) ? sanitize_text_field(wp_unslash($_REQUEST['post'])) : ''; |
|
| 14 | 14 | |
| 15 | - if ( $identifier ) { |
|
| 15 | + if ($identifier) { |
|
| 16 | 16 | // If post identifier, get schema. |
| 17 | - return new Context( Context::POST, $identifier, $this->get_fields_for_post( $identifier ) ); |
|
| 17 | + return new Context(Context::POST, $identifier, $this->get_fields_for_post($identifier)); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - $identifier = isset( $_REQUEST['tag_ID'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tag_ID'] ) ) : ''; |
|
| 20 | + $identifier = isset($_REQUEST['tag_ID']) ? sanitize_text_field(wp_unslash($_REQUEST['tag_ID'])) : ''; |
|
| 21 | 21 | |
| 22 | - if ( $identifier ) { |
|
| 22 | + if ($identifier) { |
|
| 23 | 23 | // If post identifier, get schema. |
| 24 | - return new Context( Context::TERM, $identifier, $this->get_fields_for_term( $identifier ) ); |
|
| 24 | + return new Context(Context::TERM, $identifier, $this->get_fields_for_term($identifier)); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 28 | - return new Context( Context::UNKNOWN, null, null ); |
|
| 27 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 28 | + return new Context(Context::UNKNOWN, null, null); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - return new Context( Context::ADMIN_AJAX, null, $this->get_all_fields() ); |
|
| 31 | + return new Context(Context::ADMIN_AJAX, null, $this->get_all_fields()); |
|
| 32 | 32 | |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * @return Schema_Field_Group[] |
| 37 | 37 | */ |
| 38 | - private function get_fields_for_post( $identifier ) { |
|
| 39 | - $types = \Wordlift_Entity_Type_Service::get_instance()->get_names( $identifier ); |
|
| 38 | + private function get_fields_for_post($identifier) { |
|
| 39 | + $types = \Wordlift_Entity_Type_Service::get_instance()->get_names($identifier); |
|
| 40 | 40 | $schema_classes = \Wordlift_Schema_Service::get_instance(); |
| 41 | 41 | |
| 42 | 42 | return array_map( |
| 43 | - function ( $schema_type ) use ( $schema_classes ) { |
|
| 44 | - $data = $schema_classes->get_schema( strtolower( $schema_type ) ); |
|
| 43 | + function($schema_type) use ($schema_classes) { |
|
| 44 | + $data = $schema_classes->get_schema(strtolower($schema_type)); |
|
| 45 | 45 | |
| 46 | - return new Schema_Field_Group( $schema_type, $data['custom_fields'] ); |
|
| 46 | + return new Schema_Field_Group($schema_type, $data['custom_fields']); |
|
| 47 | 47 | }, |
| 48 | 48 | $types |
| 49 | 49 | ); |
@@ -52,15 +52,15 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @return Schema_Field_Group[] |
| 54 | 54 | */ |
| 55 | - private function get_fields_for_term( $identifier ) { |
|
| 56 | - $term_entity_types = get_term_meta( (int) $identifier, \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 55 | + private function get_fields_for_term($identifier) { |
|
| 56 | + $term_entity_types = get_term_meta((int) $identifier, \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
| 57 | 57 | $schema_classes = \Wordlift_Schema_Service::get_instance(); |
| 58 | 58 | |
| 59 | 59 | return array_map( |
| 60 | - function ( $schema_type ) use ( $schema_classes ) { |
|
| 61 | - $data = $schema_classes->get_schema( strtolower( $schema_type ) ); |
|
| 60 | + function($schema_type) use ($schema_classes) { |
|
| 61 | + $data = $schema_classes->get_schema(strtolower($schema_type)); |
|
| 62 | 62 | |
| 63 | - return new Schema_Field_Group( $schema_type, $data['custom_fields'] ); |
|
| 63 | + return new Schema_Field_Group($schema_type, $data['custom_fields']); |
|
| 64 | 64 | }, |
| 65 | 65 | $term_entity_types |
| 66 | 66 | ); |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | return array_filter( |
| 74 | 74 | array_map( |
| 75 | - function ( $schema_type ) use ( $schema_classes ) { |
|
| 76 | - $data = $schema_classes->get_schema( strtolower( $schema_type ) ); |
|
| 77 | - return new Schema_Field_Group( $schema_type, $data['custom_fields'] ); |
|
| 75 | + function($schema_type) use ($schema_classes) { |
|
| 76 | + $data = $schema_classes->get_schema(strtolower($schema_type)); |
|
| 77 | + return new Schema_Field_Group($schema_type, $data['custom_fields']); |
|
| 78 | 78 | }, |
| 79 | 79 | $all_schema_slugs |
| 80 | 80 | ) |
@@ -4,63 +4,63 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Context { |
| 6 | 6 | |
| 7 | - const POST = 0; |
|
| 8 | - const TERM = 1; |
|
| 9 | - const ADMIN_AJAX = 2; |
|
| 10 | - const UNKNOWN = -1; |
|
| 11 | - /** |
|
| 12 | - * @var $object_type int |
|
| 13 | - */ |
|
| 14 | - private $object_type; |
|
| 15 | - /** |
|
| 16 | - * @var $identifier int |
|
| 17 | - */ |
|
| 18 | - private $identifier; |
|
| 19 | - /** |
|
| 20 | - * @var $custom_fields Schema_Field_Group[] |
|
| 21 | - */ |
|
| 22 | - private $custom_fields; |
|
| 7 | + const POST = 0; |
|
| 8 | + const TERM = 1; |
|
| 9 | + const ADMIN_AJAX = 2; |
|
| 10 | + const UNKNOWN = -1; |
|
| 11 | + /** |
|
| 12 | + * @var $object_type int |
|
| 13 | + */ |
|
| 14 | + private $object_type; |
|
| 15 | + /** |
|
| 16 | + * @var $identifier int |
|
| 17 | + */ |
|
| 18 | + private $identifier; |
|
| 19 | + /** |
|
| 20 | + * @var $custom_fields Schema_Field_Group[] |
|
| 21 | + */ |
|
| 22 | + private $custom_fields; |
|
| 23 | 23 | |
| 24 | - private static $pod_types_map = array( |
|
| 25 | - self::POST => 'post_type', |
|
| 26 | - self::TERM => 'taxonomy', |
|
| 27 | - ); |
|
| 24 | + private static $pod_types_map = array( |
|
| 25 | + self::POST => 'post_type', |
|
| 26 | + self::TERM => 'taxonomy', |
|
| 27 | + ); |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @param int $object_type |
|
| 32 | - * @param $identifier |
|
| 33 | - * @param $custom_fields |
|
| 34 | - */ |
|
| 35 | - public function __construct( $object_type, $identifier, $custom_fields ) { |
|
| 36 | - $this->object_type = $object_type; |
|
| 37 | - $this->identifier = $identifier; |
|
| 38 | - $this->custom_fields = $custom_fields; |
|
| 39 | - } |
|
| 30 | + /** |
|
| 31 | + * @param int $object_type |
|
| 32 | + * @param $identifier |
|
| 33 | + * @param $custom_fields |
|
| 34 | + */ |
|
| 35 | + public function __construct( $object_type, $identifier, $custom_fields ) { |
|
| 36 | + $this->object_type = $object_type; |
|
| 37 | + $this->identifier = $identifier; |
|
| 38 | + $this->custom_fields = $custom_fields; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return int |
|
| 44 | - */ |
|
| 45 | - public function get_object_type() { |
|
| 46 | - return $this->object_type; |
|
| 47 | - } |
|
| 42 | + /** |
|
| 43 | + * @return int |
|
| 44 | + */ |
|
| 45 | + public function get_object_type() { |
|
| 46 | + return $this->object_type; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - public function get_pod_name() { |
|
| 51 | - if ( self::POST === $this->object_type ) { |
|
| 52 | - return get_post_type( $this->identifier ); |
|
| 53 | - } elseif ( self::TERM === $this->object_type ) { |
|
| 54 | - return get_term( $this->identifier )->taxonomy; |
|
| 55 | - } |
|
| 56 | - } |
|
| 50 | + public function get_pod_name() { |
|
| 51 | + if ( self::POST === $this->object_type ) { |
|
| 52 | + return get_post_type( $this->identifier ); |
|
| 53 | + } elseif ( self::TERM === $this->object_type ) { |
|
| 54 | + return get_term( $this->identifier )->taxonomy; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function get_pod_type() { |
|
| 59 | - return self::$pod_types_map[ $this->object_type ]; |
|
| 60 | - } |
|
| 58 | + public function get_pod_type() { |
|
| 59 | + return self::$pod_types_map[ $this->object_type ]; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public function get_custom_fields() { |
|
| 63 | - return $this->custom_fields; |
|
| 64 | - } |
|
| 62 | + public function get_custom_fields() { |
|
| 63 | + return $this->custom_fields; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param $identifier |
| 33 | 33 | * @param $custom_fields |
| 34 | 34 | */ |
| 35 | - public function __construct( $object_type, $identifier, $custom_fields ) { |
|
| 35 | + public function __construct($object_type, $identifier, $custom_fields) { |
|
| 36 | 36 | $this->object_type = $object_type; |
| 37 | 37 | $this->identifier = $identifier; |
| 38 | 38 | $this->custom_fields = $custom_fields; |
@@ -48,15 +48,15 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | public function get_pod_name() { |
| 51 | - if ( self::POST === $this->object_type ) { |
|
| 52 | - return get_post_type( $this->identifier ); |
|
| 53 | - } elseif ( self::TERM === $this->object_type ) { |
|
| 54 | - return get_term( $this->identifier )->taxonomy; |
|
| 51 | + if (self::POST === $this->object_type) { |
|
| 52 | + return get_post_type($this->identifier); |
|
| 53 | + } elseif (self::TERM === $this->object_type) { |
|
| 54 | + return get_term($this->identifier)->taxonomy; |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public function get_pod_type() { |
| 59 | - return self::$pod_types_map[ $this->object_type ]; |
|
| 59 | + return self::$pod_types_map[$this->object_type]; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | public function get_custom_fields() { |
@@ -7,129 +7,129 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Filters { |
| 9 | 9 | |
| 10 | - const FIELD_NAME = 'wlentity'; |
|
| 10 | + const FIELD_NAME = 'wlentity'; |
|
| 11 | 11 | |
| 12 | - public function __construct() { |
|
| 12 | + public function __construct() { |
|
| 13 | 13 | |
| 14 | - pods_register_related_object( 'wlentity', 'WordLift Entity', array( 'simple' => false ) ); |
|
| 15 | - add_filter( 'pods_form_ui_field_pick_ajax', array( $this, 'ajax_filter' ), 10, 4 ); |
|
| 16 | - add_filter( 'pods_api_get_table_info', array( $this, 'table_info_filter' ), 10, 6 ); |
|
| 17 | - add_filter( 'pods_field_pick_object_data', array( $this, 'field_options_filter' ), 10, 7 ); |
|
| 18 | - add_filter( 'pods_field_dfv_data', array( $this, 'data_filter' ), 10, 2 ); |
|
| 19 | - add_filter( 'pods_field_pick_data_ajax', array( $this, 'admin_ajax_filter' ), 10, 4 ); |
|
| 14 | + pods_register_related_object( 'wlentity', 'WordLift Entity', array( 'simple' => false ) ); |
|
| 15 | + add_filter( 'pods_form_ui_field_pick_ajax', array( $this, 'ajax_filter' ), 10, 4 ); |
|
| 16 | + add_filter( 'pods_api_get_table_info', array( $this, 'table_info_filter' ), 10, 6 ); |
|
| 17 | + add_filter( 'pods_field_pick_object_data', array( $this, 'field_options_filter' ), 10, 7 ); |
|
| 18 | + add_filter( 'pods_field_dfv_data', array( $this, 'data_filter' ), 10, 2 ); |
|
| 19 | + add_filter( 'pods_field_pick_data_ajax', array( $this, 'admin_ajax_filter' ), 10, 4 ); |
|
| 20 | 20 | |
| 21 | - } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function wl_pods_transform_data_for_pick_field( $item ) { |
|
| 23 | + public function wl_pods_transform_data_for_pick_field( $item ) { |
|
| 24 | 24 | |
| 25 | - $content = $item->get_content(); |
|
| 25 | + $content = $item->get_content(); |
|
| 26 | 26 | |
| 27 | - return array( |
|
| 28 | - 'id' => sprintf( '%s_%d', Object_Type_Enum::to_string( $content->get_object_type_enum() ), $content->get_id() ), |
|
| 29 | - 'icon' => 'https:\/\/wordlift.localhost\/wp-content\/plugins\/wordlift\/images\/svg\/wl-vocabulary-icon.svg', |
|
| 30 | - 'name' => $item->get_title() . ' (' . $item->get_schema_type() . ')', |
|
| 31 | - 'edit_link' => $content->get_edit_link(), |
|
| 32 | - 'link' => $content->get_permalink(), |
|
| 33 | - 'selected' => false, |
|
| 34 | - ); |
|
| 35 | - } |
|
| 27 | + return array( |
|
| 28 | + 'id' => sprintf( '%s_%d', Object_Type_Enum::to_string( $content->get_object_type_enum() ), $content->get_id() ), |
|
| 29 | + 'icon' => 'https:\/\/wordlift.localhost\/wp-content\/plugins\/wordlift\/images\/svg\/wl-vocabulary-icon.svg', |
|
| 30 | + 'name' => $item->get_title() . ' (' . $item->get_schema_type() . ')', |
|
| 31 | + 'edit_link' => $content->get_edit_link(), |
|
| 32 | + 'link' => $content->get_permalink(), |
|
| 33 | + 'selected' => false, |
|
| 34 | + ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | - public function admin_ajax_filter( $data, $name, $_, $field ) { |
|
| 38 | + public function admin_ajax_filter( $data, $name, $_, $field ) { |
|
| 39 | 39 | |
| 40 | - if ( ( ! $field instanceof Pods\Whatsit\Field ) || $field->get_arg( 'pick_object', false ) !== 'wlentity' ) { |
|
| 41 | - return $data; |
|
| 42 | - } |
|
| 40 | + if ( ( ! $field instanceof Pods\Whatsit\Field ) || $field->get_arg( 'pick_object', false ) !== 'wlentity' ) { |
|
| 41 | + return $data; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - $query = sanitize_text_field( wp_unslash( $_REQUEST['query'] ) ); |
|
| 45 | - $query_service = Entity_Query_Service::get_instance(); |
|
| 44 | + $query = sanitize_text_field( wp_unslash( $_REQUEST['query'] ) ); |
|
| 45 | + $query_service = Entity_Query_Service::get_instance(); |
|
| 46 | 46 | |
| 47 | - return array_map( array( $this, 'wl_pods_transform_data_for_pick_field' ), $query_service->query( $query, $field->get_arg( 'supported_schema_types', array( 'Thing' ) ) ) ); |
|
| 47 | + return array_map( array( $this, 'wl_pods_transform_data_for_pick_field' ), $query_service->query( $query, $field->get_arg( 'supported_schema_types', array( 'Thing' ) ) ) ); |
|
| 48 | 48 | |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public function data_filter( $data, $args ) { |
|
| 51 | + public function data_filter( $data, $args ) { |
|
| 52 | 52 | |
| 53 | - $args_arr = json_decode( wp_json_encode( $args ), true ); |
|
| 54 | - $field_data = $args_arr['options']; |
|
| 53 | + $args_arr = json_decode( wp_json_encode( $args ), true ); |
|
| 54 | + $field_data = $args_arr['options']; |
|
| 55 | 55 | |
| 56 | - if ( ! isset( $field_data['pick_object'] ) || 'wlentity' !== $field_data['pick_object'] ) { |
|
| 57 | - return $data; |
|
| 58 | - } |
|
| 56 | + if ( ! isset( $field_data['pick_object'] ) || 'wlentity' !== $field_data['pick_object'] ) { |
|
| 57 | + return $data; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - if ( ! isset( $args_arr['pod']['data']['pod_data']['type'] ) |
|
| 61 | - || ! is_string( $args_arr['pod']['data']['pod_data']['type'] ) ) { |
|
| 62 | - return $data; |
|
| 63 | - } |
|
| 60 | + if ( ! isset( $args_arr['pod']['data']['pod_data']['type'] ) |
|
| 61 | + || ! is_string( $args_arr['pod']['data']['pod_data']['type'] ) ) { |
|
| 62 | + return $data; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - $name = $field_data['name']; |
|
| 66 | - $identifier = $args->id; |
|
| 67 | - $type = $args_arr['pod']['data']['pod_data']['type']; |
|
| 65 | + $name = $field_data['name']; |
|
| 66 | + $identifier = $args->id; |
|
| 67 | + $type = $args_arr['pod']['data']['pod_data']['type']; |
|
| 68 | 68 | |
| 69 | - if ( 'post_type' === $type ) { |
|
| 70 | - $data['fieldValue'] = get_post_meta( $identifier, $name ); |
|
| 71 | - } elseif ( 'taxonomy' === $type ) { |
|
| 72 | - $data['fieldValue'] = get_term_meta( $identifier, $name ); |
|
| 73 | - } |
|
| 69 | + if ( 'post_type' === $type ) { |
|
| 70 | + $data['fieldValue'] = get_post_meta( $identifier, $name ); |
|
| 71 | + } elseif ( 'taxonomy' === $type ) { |
|
| 72 | + $data['fieldValue'] = get_term_meta( $identifier, $name ); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - return $data; |
|
| 76 | - } |
|
| 75 | + return $data; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | - public function ajax_filter( $result, $name, $value, $field_options ) { |
|
| 79 | + public function ajax_filter( $result, $name, $value, $field_options ) { |
|
| 80 | 80 | |
| 81 | - if ( ! isset( $field_options['pick_object'] ) ) { |
|
| 82 | - return $result; |
|
| 83 | - } |
|
| 81 | + if ( ! isset( $field_options['pick_object'] ) ) { |
|
| 82 | + return $result; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - return self::FIELD_NAME === $field_options['pick_object']; |
|
| 86 | - } |
|
| 85 | + return self::FIELD_NAME === $field_options['pick_object']; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - public function table_info_filter( $info, $object_type, $object, $name, $pod, $field ) { |
|
| 88 | + public function table_info_filter( $info, $object_type, $object, $name, $pod, $field ) { |
|
| 89 | 89 | |
| 90 | - if ( $field === null || 'wlentity' !== $field->get_arg( 'pick_object', false ) ) { |
|
| 91 | - return $info; |
|
| 92 | - } |
|
| 93 | - // We need to return an non empty array here to prevent pods from querying a table. |
|
| 94 | - // This is necessary to prevent errors on ui. |
|
| 95 | - return array( 'foo' => 'bar' ); |
|
| 96 | - } |
|
| 90 | + if ( $field === null || 'wlentity' !== $field->get_arg( 'pick_object', false ) ) { |
|
| 91 | + return $info; |
|
| 92 | + } |
|
| 93 | + // We need to return an non empty array here to prevent pods from querying a table. |
|
| 94 | + // This is necessary to prevent errors on ui. |
|
| 95 | + return array( 'foo' => 'bar' ); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | |
| 99 | - public function field_options_filter( $_, $name, $value, $options, $pod, $id, $object_params ) { |
|
| 99 | + public function field_options_filter( $_, $name, $value, $options, $pod, $id, $object_params ) { |
|
| 100 | 100 | |
| 101 | - $object_params = json_decode( wp_json_encode( $object_params ), true ); |
|
| 101 | + $object_params = json_decode( wp_json_encode( $object_params ), true ); |
|
| 102 | 102 | |
| 103 | - $query_service = Entity_Query_Service::get_instance(); |
|
| 103 | + $query_service = Entity_Query_Service::get_instance(); |
|
| 104 | 104 | |
| 105 | - if ( is_array( $object_params ) && isset( $object_params['options']['pick_object'] ) |
|
| 106 | - && is_string( $object_params['options']['pick_object'] ) |
|
| 107 | - && 'wlentity' === $object_params['options']['pick_object'] |
|
| 108 | - && isset( $object_params['pod']['data']['pod_data']['type'] ) |
|
| 109 | - && is_string( $object_params['pod']['data']['pod_data']['type'] ) ) { |
|
| 105 | + if ( is_array( $object_params ) && isset( $object_params['options']['pick_object'] ) |
|
| 106 | + && is_string( $object_params['options']['pick_object'] ) |
|
| 107 | + && 'wlentity' === $object_params['options']['pick_object'] |
|
| 108 | + && isset( $object_params['pod']['data']['pod_data']['type'] ) |
|
| 109 | + && is_string( $object_params['pod']['data']['pod_data']['type'] ) ) { |
|
| 110 | 110 | |
| 111 | - $type = $object_params['pod']['data']['pod_data']['type']; |
|
| 111 | + $type = $object_params['pod']['data']['pod_data']['type']; |
|
| 112 | 112 | |
| 113 | - if ( 'post_type' === $type ) { |
|
| 114 | - $linked_entities = get_post_meta( $id, $name ); |
|
| 115 | - } elseif ( 'taxonomy' === $type ) { |
|
| 116 | - $linked_entities = get_term_meta( $id, $name ); |
|
| 117 | - } |
|
| 118 | - $data = array(); |
|
| 119 | - $linked_entities = $query_service->get( $linked_entities ); |
|
| 120 | - foreach ( $linked_entities as $linked_entity ) { |
|
| 121 | - $content = $linked_entity->get_content(); |
|
| 122 | - $id = sprintf( '%s_%d', Object_Type_Enum::to_string( $content->get_object_type_enum() ), $content->get_id() ); |
|
| 123 | - $text = $linked_entity->get_title() . ' (' . $linked_entity->get_schema_type() . ')'; |
|
| 124 | - $data[ $id ] = $text; |
|
| 125 | - } |
|
| 113 | + if ( 'post_type' === $type ) { |
|
| 114 | + $linked_entities = get_post_meta( $id, $name ); |
|
| 115 | + } elseif ( 'taxonomy' === $type ) { |
|
| 116 | + $linked_entities = get_term_meta( $id, $name ); |
|
| 117 | + } |
|
| 118 | + $data = array(); |
|
| 119 | + $linked_entities = $query_service->get( $linked_entities ); |
|
| 120 | + foreach ( $linked_entities as $linked_entity ) { |
|
| 121 | + $content = $linked_entity->get_content(); |
|
| 122 | + $id = sprintf( '%s_%d', Object_Type_Enum::to_string( $content->get_object_type_enum() ), $content->get_id() ); |
|
| 123 | + $text = $linked_entity->get_title() . ' (' . $linked_entity->get_schema_type() . ')'; |
|
| 124 | + $data[ $id ] = $text; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - return $data; |
|
| 128 | - } |
|
| 127 | + return $data; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - return $_; |
|
| 130 | + return $_; |
|
| 131 | 131 | |
| 132 | - } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | |
| 135 | 135 | } |
@@ -11,23 +11,23 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | public function __construct() { |
| 13 | 13 | |
| 14 | - pods_register_related_object( 'wlentity', 'WordLift Entity', array( 'simple' => false ) ); |
|
| 15 | - add_filter( 'pods_form_ui_field_pick_ajax', array( $this, 'ajax_filter' ), 10, 4 ); |
|
| 16 | - add_filter( 'pods_api_get_table_info', array( $this, 'table_info_filter' ), 10, 6 ); |
|
| 17 | - add_filter( 'pods_field_pick_object_data', array( $this, 'field_options_filter' ), 10, 7 ); |
|
| 18 | - add_filter( 'pods_field_dfv_data', array( $this, 'data_filter' ), 10, 2 ); |
|
| 19 | - add_filter( 'pods_field_pick_data_ajax', array( $this, 'admin_ajax_filter' ), 10, 4 ); |
|
| 14 | + pods_register_related_object('wlentity', 'WordLift Entity', array('simple' => false)); |
|
| 15 | + add_filter('pods_form_ui_field_pick_ajax', array($this, 'ajax_filter'), 10, 4); |
|
| 16 | + add_filter('pods_api_get_table_info', array($this, 'table_info_filter'), 10, 6); |
|
| 17 | + add_filter('pods_field_pick_object_data', array($this, 'field_options_filter'), 10, 7); |
|
| 18 | + add_filter('pods_field_dfv_data', array($this, 'data_filter'), 10, 2); |
|
| 19 | + add_filter('pods_field_pick_data_ajax', array($this, 'admin_ajax_filter'), 10, 4); |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function wl_pods_transform_data_for_pick_field( $item ) { |
|
| 23 | + public function wl_pods_transform_data_for_pick_field($item) { |
|
| 24 | 24 | |
| 25 | 25 | $content = $item->get_content(); |
| 26 | 26 | |
| 27 | 27 | return array( |
| 28 | - 'id' => sprintf( '%s_%d', Object_Type_Enum::to_string( $content->get_object_type_enum() ), $content->get_id() ), |
|
| 28 | + 'id' => sprintf('%s_%d', Object_Type_Enum::to_string($content->get_object_type_enum()), $content->get_id()), |
|
| 29 | 29 | 'icon' => 'https:\/\/wordlift.localhost\/wp-content\/plugins\/wordlift\/images\/svg\/wl-vocabulary-icon.svg', |
| 30 | - 'name' => $item->get_title() . ' (' . $item->get_schema_type() . ')', |
|
| 30 | + 'name' => $item->get_title().' ('.$item->get_schema_type().')', |
|
| 31 | 31 | 'edit_link' => $content->get_edit_link(), |
| 32 | 32 | 'link' => $content->get_permalink(), |
| 33 | 33 | 'selected' => false, |
@@ -35,30 +35,30 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
| 38 | - public function admin_ajax_filter( $data, $name, $_, $field ) { |
|
| 38 | + public function admin_ajax_filter($data, $name, $_, $field) { |
|
| 39 | 39 | |
| 40 | - if ( ( ! $field instanceof Pods\Whatsit\Field ) || $field->get_arg( 'pick_object', false ) !== 'wlentity' ) { |
|
| 40 | + if (( ! $field instanceof Pods\Whatsit\Field) || $field->get_arg('pick_object', false) !== 'wlentity') { |
|
| 41 | 41 | return $data; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - $query = sanitize_text_field( wp_unslash( $_REQUEST['query'] ) ); |
|
| 44 | + $query = sanitize_text_field(wp_unslash($_REQUEST['query'])); |
|
| 45 | 45 | $query_service = Entity_Query_Service::get_instance(); |
| 46 | 46 | |
| 47 | - return array_map( array( $this, 'wl_pods_transform_data_for_pick_field' ), $query_service->query( $query, $field->get_arg( 'supported_schema_types', array( 'Thing' ) ) ) ); |
|
| 47 | + return array_map(array($this, 'wl_pods_transform_data_for_pick_field'), $query_service->query($query, $field->get_arg('supported_schema_types', array('Thing')))); |
|
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function data_filter( $data, $args ) { |
|
| 51 | + public function data_filter($data, $args) { |
|
| 52 | 52 | |
| 53 | - $args_arr = json_decode( wp_json_encode( $args ), true ); |
|
| 53 | + $args_arr = json_decode(wp_json_encode($args), true); |
|
| 54 | 54 | $field_data = $args_arr['options']; |
| 55 | 55 | |
| 56 | - if ( ! isset( $field_data['pick_object'] ) || 'wlentity' !== $field_data['pick_object'] ) { |
|
| 56 | + if ( ! isset($field_data['pick_object']) || 'wlentity' !== $field_data['pick_object']) { |
|
| 57 | 57 | return $data; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if ( ! isset( $args_arr['pod']['data']['pod_data']['type'] ) |
|
| 61 | - || ! is_string( $args_arr['pod']['data']['pod_data']['type'] ) ) { |
|
| 60 | + if ( ! isset($args_arr['pod']['data']['pod_data']['type']) |
|
| 61 | + || ! is_string($args_arr['pod']['data']['pod_data']['type'])) { |
|
| 62 | 62 | return $data; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -66,62 +66,62 @@ discard block |
||
| 66 | 66 | $identifier = $args->id; |
| 67 | 67 | $type = $args_arr['pod']['data']['pod_data']['type']; |
| 68 | 68 | |
| 69 | - if ( 'post_type' === $type ) { |
|
| 70 | - $data['fieldValue'] = get_post_meta( $identifier, $name ); |
|
| 71 | - } elseif ( 'taxonomy' === $type ) { |
|
| 72 | - $data['fieldValue'] = get_term_meta( $identifier, $name ); |
|
| 69 | + if ('post_type' === $type) { |
|
| 70 | + $data['fieldValue'] = get_post_meta($identifier, $name); |
|
| 71 | + } elseif ('taxonomy' === $type) { |
|
| 72 | + $data['fieldValue'] = get_term_meta($identifier, $name); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return $data; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
| 79 | - public function ajax_filter( $result, $name, $value, $field_options ) { |
|
| 79 | + public function ajax_filter($result, $name, $value, $field_options) { |
|
| 80 | 80 | |
| 81 | - if ( ! isset( $field_options['pick_object'] ) ) { |
|
| 81 | + if ( ! isset($field_options['pick_object'])) { |
|
| 82 | 82 | return $result; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | return self::FIELD_NAME === $field_options['pick_object']; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function table_info_filter( $info, $object_type, $object, $name, $pod, $field ) { |
|
| 88 | + public function table_info_filter($info, $object_type, $object, $name, $pod, $field) { |
|
| 89 | 89 | |
| 90 | - if ( $field === null || 'wlentity' !== $field->get_arg( 'pick_object', false ) ) { |
|
| 90 | + if ($field === null || 'wlentity' !== $field->get_arg('pick_object', false)) { |
|
| 91 | 91 | return $info; |
| 92 | 92 | } |
| 93 | 93 | // We need to return an non empty array here to prevent pods from querying a table. |
| 94 | 94 | // This is necessary to prevent errors on ui. |
| 95 | - return array( 'foo' => 'bar' ); |
|
| 95 | + return array('foo' => 'bar'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | |
| 99 | - public function field_options_filter( $_, $name, $value, $options, $pod, $id, $object_params ) { |
|
| 99 | + public function field_options_filter($_, $name, $value, $options, $pod, $id, $object_params) { |
|
| 100 | 100 | |
| 101 | - $object_params = json_decode( wp_json_encode( $object_params ), true ); |
|
| 101 | + $object_params = json_decode(wp_json_encode($object_params), true); |
|
| 102 | 102 | |
| 103 | 103 | $query_service = Entity_Query_Service::get_instance(); |
| 104 | 104 | |
| 105 | - if ( is_array( $object_params ) && isset( $object_params['options']['pick_object'] ) |
|
| 106 | - && is_string( $object_params['options']['pick_object'] ) |
|
| 105 | + if (is_array($object_params) && isset($object_params['options']['pick_object']) |
|
| 106 | + && is_string($object_params['options']['pick_object']) |
|
| 107 | 107 | && 'wlentity' === $object_params['options']['pick_object'] |
| 108 | - && isset( $object_params['pod']['data']['pod_data']['type'] ) |
|
| 109 | - && is_string( $object_params['pod']['data']['pod_data']['type'] ) ) { |
|
| 108 | + && isset($object_params['pod']['data']['pod_data']['type']) |
|
| 109 | + && is_string($object_params['pod']['data']['pod_data']['type'])) { |
|
| 110 | 110 | |
| 111 | 111 | $type = $object_params['pod']['data']['pod_data']['type']; |
| 112 | 112 | |
| 113 | - if ( 'post_type' === $type ) { |
|
| 114 | - $linked_entities = get_post_meta( $id, $name ); |
|
| 115 | - } elseif ( 'taxonomy' === $type ) { |
|
| 116 | - $linked_entities = get_term_meta( $id, $name ); |
|
| 113 | + if ('post_type' === $type) { |
|
| 114 | + $linked_entities = get_post_meta($id, $name); |
|
| 115 | + } elseif ('taxonomy' === $type) { |
|
| 116 | + $linked_entities = get_term_meta($id, $name); |
|
| 117 | 117 | } |
| 118 | 118 | $data = array(); |
| 119 | - $linked_entities = $query_service->get( $linked_entities ); |
|
| 120 | - foreach ( $linked_entities as $linked_entity ) { |
|
| 119 | + $linked_entities = $query_service->get($linked_entities); |
|
| 120 | + foreach ($linked_entities as $linked_entity) { |
|
| 121 | 121 | $content = $linked_entity->get_content(); |
| 122 | - $id = sprintf( '%s_%d', Object_Type_Enum::to_string( $content->get_object_type_enum() ), $content->get_id() ); |
|
| 123 | - $text = $linked_entity->get_title() . ' (' . $linked_entity->get_schema_type() . ')'; |
|
| 124 | - $data[ $id ] = $text; |
|
| 122 | + $id = sprintf('%s_%d', Object_Type_Enum::to_string($content->get_object_type_enum()), $content->get_id()); |
|
| 123 | + $text = $linked_entity->get_title().' ('.$linked_entity->get_schema_type().')'; |
|
| 124 | + $data[$id] = $text; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | return $data; |
@@ -4,28 +4,28 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Schema_Field_Group { |
| 6 | 6 | |
| 7 | - private $schema_type; |
|
| 8 | - |
|
| 9 | - private $custom_fields; |
|
| 10 | - |
|
| 11 | - public function __construct( $schema_type, $custom_fields ) { |
|
| 12 | - $this->schema_type = $schema_type; |
|
| 13 | - $this->custom_fields = $custom_fields; |
|
| 14 | - } |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * @return mixed |
|
| 18 | - */ |
|
| 19 | - public function get_schema_type() { |
|
| 20 | - return $this->schema_type; |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * @return mixed |
|
| 25 | - */ |
|
| 26 | - public function get_custom_fields() { |
|
| 27 | - return $this->custom_fields; |
|
| 28 | - } |
|
| 7 | + private $schema_type; |
|
| 8 | + |
|
| 9 | + private $custom_fields; |
|
| 10 | + |
|
| 11 | + public function __construct( $schema_type, $custom_fields ) { |
|
| 12 | + $this->schema_type = $schema_type; |
|
| 13 | + $this->custom_fields = $custom_fields; |
|
| 14 | + } |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * @return mixed |
|
| 18 | + */ |
|
| 19 | + public function get_schema_type() { |
|
| 20 | + return $this->schema_type; |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * @return mixed |
|
| 25 | + */ |
|
| 26 | + public function get_custom_fields() { |
|
| 27 | + return $this->custom_fields; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | private $custom_fields; |
| 10 | 10 | |
| 11 | - public function __construct( $schema_type, $custom_fields ) { |
|
| 11 | + public function __construct($schema_type, $custom_fields) { |
|
| 12 | 12 | $this->schema_type = $schema_type; |
| 13 | 13 | $this->custom_fields = $custom_fields; |
| 14 | 14 | } |
@@ -16,16 +16,16 @@ discard block |
||
| 16 | 16 | use Wordlift\Modules\Pods\WlEntityField\Filters; |
| 17 | 17 | |
| 18 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 19 | - exit; |
|
| 19 | + exit; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | if ( ! defined( 'PODS_VERSION' ) ) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | // Autoloader for plugin itself. |
| 27 | 27 | if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
| 28 | - require __DIR__ . '/vendor/autoload.php'; |
|
| 28 | + require __DIR__ . '/vendor/autoload.php'; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
@@ -35,19 +35,19 @@ discard block |
||
| 35 | 35 | $container_builder->compile(); |
| 36 | 36 | |
| 37 | 37 | add_action( |
| 38 | - 'plugins_loaded', |
|
| 39 | - function () use ($container_builder) { |
|
| 38 | + 'plugins_loaded', |
|
| 39 | + function () use ($container_builder) { |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - $factory = $container_builder->get( FieldDefinitionFactory::class ); |
|
| 45 | - $field_definition = $factory->get_field_definition(); |
|
| 46 | - $field_definition->register(); |
|
| 44 | + $factory = $container_builder->get( FieldDefinitionFactory::class ); |
|
| 45 | + $field_definition = $factory->get_field_definition(); |
|
| 46 | + $field_definition->register(); |
|
| 47 | 47 | |
| 48 | 48 | |
| 49 | 49 | |
| 50 | - } |
|
| 50 | + } |
|
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | 53 | |
@@ -15,33 +15,33 @@ discard block |
||
| 15 | 15 | use Wordlift\Modules\Pods\FieldDefinition\FieldDefinitionFactory; |
| 16 | 16 | use Wordlift\Modules\Pods\WlEntityField\Filters; |
| 17 | 17 | |
| 18 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 18 | +if ( ! defined('ABSPATH')) { |
|
| 19 | 19 | exit; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -if ( ! defined( 'PODS_VERSION' ) ) { |
|
| 22 | +if ( ! defined('PODS_VERSION')) { |
|
| 23 | 23 | return; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | // Autoloader for plugin itself. |
| 27 | -if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
| 28 | - require __DIR__ . '/vendor/autoload.php'; |
|
| 27 | +if (file_exists(__DIR__.'/vendor/autoload.php')) { |
|
| 28 | + require __DIR__.'/vendor/autoload.php'; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | $container_builder = new ContainerBuilder(); |
| 33 | -$loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
| 34 | -$loader->load( 'services.yml' ); |
|
| 33 | +$loader = new YamlFileLoader($container_builder, new FileLocator(__DIR__)); |
|
| 34 | +$loader->load('services.yml'); |
|
| 35 | 35 | $container_builder->compile(); |
| 36 | 36 | |
| 37 | 37 | add_action( |
| 38 | 38 | 'plugins_loaded', |
| 39 | - function () use ($container_builder) { |
|
| 39 | + function() use ($container_builder) { |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - $factory = $container_builder->get( FieldDefinitionFactory::class ); |
|
| 44 | + $factory = $container_builder->get(FieldDefinitionFactory::class); |
|
| 45 | 45 | $field_definition = $factory->get_field_definition(); |
| 46 | 46 | $field_definition->register(); |
| 47 | 47 | |
@@ -51,4 +51,4 @@ discard block |
||
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | 53 | |
| 54 | -$filters = $container_builder->get( 'Wordlift\Modules\Pods\WlEntityField\Filters' ); |
|
| 55 | 54 | \ No newline at end of file |
| 55 | +$filters = $container_builder->get('Wordlift\Modules\Pods\WlEntityField\Filters'); |
|
| 56 | 56 | \ No newline at end of file |
@@ -7,6 +7,6 @@ |
||
| 7 | 7 | exit(1); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 10 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 11 | 11 | |
| 12 | 12 | return ComposerAutoloaderInit1fa7477671b8ce4e96024c7b54cda86e::getLoader(); |