@@ -19,27 +19,27 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | interface Rule_Validator { |
| 21 | 21 | |
| 22 | - const IS_EQUAL_TO = '==='; |
|
| 23 | - const IS_NOT_EQUAL_TO = '!=='; |
|
| 22 | + const IS_EQUAL_TO = '==='; |
|
| 23 | + const IS_NOT_EQUAL_TO = '!=='; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Get the validator label. |
|
| 27 | - * |
|
| 28 | - * @return string The validator label. |
|
| 29 | - */ |
|
| 30 | - public function get_label(); |
|
| 25 | + /** |
|
| 26 | + * Get the validator label. |
|
| 27 | + * |
|
| 28 | + * @return string The validator label. |
|
| 29 | + */ |
|
| 30 | + public function get_label(); |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Test whether a post passes a validation. |
|
| 34 | - * |
|
| 35 | - * @param int $identifier The post id or term id. |
|
| 36 | - * @param string $operator The operator. |
|
| 37 | - * @param string $operand_1 The first operand. |
|
| 38 | - * @param string $operand_2 The second operand. |
|
| 39 | - * @param string $type The type is either post or term. |
|
| 40 | - * |
|
| 41 | - * @return bool Whether the post passes or not the validation. |
|
| 42 | - */ |
|
| 43 | - public function is_valid( $identifier, $operator, $operand_1, $operand_2, $type ); |
|
| 32 | + /** |
|
| 33 | + * Test whether a post passes a validation. |
|
| 34 | + * |
|
| 35 | + * @param int $identifier The post id or term id. |
|
| 36 | + * @param string $operator The operator. |
|
| 37 | + * @param string $operand_1 The first operand. |
|
| 38 | + * @param string $operand_2 The second operand. |
|
| 39 | + * @param string $type The type is either post or term. |
|
| 40 | + * |
|
| 41 | + * @return bool Whether the post passes or not the validation. |
|
| 42 | + */ |
|
| 43 | + public function is_valid( $identifier, $operator, $operand_1, $operand_2, $type ); |
|
| 44 | 44 | |
| 45 | 45 | } |
@@ -40,6 +40,6 @@ |
||
| 40 | 40 | * |
| 41 | 41 | * @return bool Whether the post passes or not the validation. |
| 42 | 42 | */ |
| 43 | - public function is_valid( $identifier, $operator, $operand_1, $operand_2, $type ); |
|
| 43 | + public function is_valid($identifier, $operator, $operand_1, $operand_2, $type); |
|
| 44 | 44 | |
| 45 | 45 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @param Rule_Validators_Registry $rule_validators_registry |
| 33 | 33 | */ |
| 34 | - public function __construct( $rule_validators_registry ) { |
|
| 34 | + public function __construct($rule_validators_registry) { |
|
| 35 | 35 | |
| 36 | 36 | $this->rule_validators_registry = $rule_validators_registry; |
| 37 | 37 | |
@@ -46,18 +46,18 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return bool Whether the post passes at least one rule group. |
| 48 | 48 | */ |
| 49 | - public function is_valid( $identifier, $rule_groups, $type ) { |
|
| 49 | + public function is_valid($identifier, $rule_groups, $type) { |
|
| 50 | 50 | |
| 51 | 51 | // Validate each group. Return true as soon as one group is validated (all rules). |
| 52 | - foreach ( (array) $rule_groups as $rule_group ) { |
|
| 53 | - foreach ( $rule_group['rules'] as $rule ) { |
|
| 52 | + foreach ((array) $rule_groups as $rule_group) { |
|
| 53 | + foreach ($rule_group['rules'] as $rule) { |
|
| 54 | 54 | $rule_field_one = $rule['rule_field_one']; |
| 55 | 55 | $rule_logic_field = $rule['rule_logic_field']; |
| 56 | 56 | $rule_field_two = $rule['rule_field_two']; |
| 57 | 57 | |
| 58 | - $rule_validator = $this->rule_validators_registry->get_rule_validator( $rule_field_one ); |
|
| 58 | + $rule_validator = $this->rule_validators_registry->get_rule_validator($rule_field_one); |
|
| 59 | 59 | // Skip to the next Rule Group if a rule isn't valid. |
| 60 | - if ( ! $rule_validator->is_valid( $identifier, $rule_logic_field, $rule_field_one, $rule_field_two, $type ) ) { |
|
| 60 | + if ( ! $rule_validator->is_valid($identifier, $rule_logic_field, $rule_field_one, $rule_field_two, $type)) { |
|
| 61 | 61 | continue 2; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -19,55 +19,55 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Rule_Groups_Validator { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * The {@link Rule_Validators_Registry} instance. |
|
| 24 | - * |
|
| 25 | - * @var Rule_Validators_Registry $rule_validators_registry The {@link Rule_Validators_Registry} instance. |
|
| 26 | - */ |
|
| 27 | - private $rule_validators_registry; |
|
| 22 | + /** |
|
| 23 | + * The {@link Rule_Validators_Registry} instance. |
|
| 24 | + * |
|
| 25 | + * @var Rule_Validators_Registry $rule_validators_registry The {@link Rule_Validators_Registry} instance. |
|
| 26 | + */ |
|
| 27 | + private $rule_validators_registry; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Rule_Groups_Validator constructor. |
|
| 31 | - * |
|
| 32 | - * @param Rule_Validators_Registry $rule_validators_registry |
|
| 33 | - */ |
|
| 34 | - public function __construct( $rule_validators_registry ) { |
|
| 29 | + /** |
|
| 30 | + * Rule_Groups_Validator constructor. |
|
| 31 | + * |
|
| 32 | + * @param Rule_Validators_Registry $rule_validators_registry |
|
| 33 | + */ |
|
| 34 | + public function __construct( $rule_validators_registry ) { |
|
| 35 | 35 | |
| 36 | - $this->rule_validators_registry = $rule_validators_registry; |
|
| 36 | + $this->rule_validators_registry = $rule_validators_registry; |
|
| 37 | 37 | |
| 38 | - } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Check whether the specified post passes at least one group of rules. |
|
| 42 | - * |
|
| 43 | - * @param int $identifier The post id or term id. |
|
| 44 | - * @param array $rule_groups An array of rules' groups. |
|
| 45 | - * @param $type string Post or term |
|
| 46 | - * |
|
| 47 | - * @return bool Whether the post passes at least one rule group. |
|
| 48 | - */ |
|
| 49 | - public function is_valid( $identifier, $rule_groups, $type ) { |
|
| 40 | + /** |
|
| 41 | + * Check whether the specified post passes at least one group of rules. |
|
| 42 | + * |
|
| 43 | + * @param int $identifier The post id or term id. |
|
| 44 | + * @param array $rule_groups An array of rules' groups. |
|
| 45 | + * @param $type string Post or term |
|
| 46 | + * |
|
| 47 | + * @return bool Whether the post passes at least one rule group. |
|
| 48 | + */ |
|
| 49 | + public function is_valid( $identifier, $rule_groups, $type ) { |
|
| 50 | 50 | |
| 51 | - // Validate each group. Return true as soon as one group is validated (all rules). |
|
| 52 | - foreach ( (array) $rule_groups as $rule_group ) { |
|
| 53 | - foreach ( $rule_group['rules'] as $rule ) { |
|
| 54 | - $rule_field_one = $rule['rule_field_one']; |
|
| 55 | - $rule_logic_field = $rule['rule_logic_field']; |
|
| 56 | - $rule_field_two = $rule['rule_field_two']; |
|
| 51 | + // Validate each group. Return true as soon as one group is validated (all rules). |
|
| 52 | + foreach ( (array) $rule_groups as $rule_group ) { |
|
| 53 | + foreach ( $rule_group['rules'] as $rule ) { |
|
| 54 | + $rule_field_one = $rule['rule_field_one']; |
|
| 55 | + $rule_logic_field = $rule['rule_logic_field']; |
|
| 56 | + $rule_field_two = $rule['rule_field_two']; |
|
| 57 | 57 | |
| 58 | - $rule_validator = $this->rule_validators_registry->get_rule_validator( $rule_field_one ); |
|
| 59 | - // Skip to the next Rule Group if a rule isn't valid. |
|
| 60 | - if ( ! $rule_validator->is_valid( $identifier, $rule_logic_field, $rule_field_one, $rule_field_two, $type ) ) { |
|
| 61 | - continue 2; |
|
| 62 | - } |
|
| 58 | + $rule_validator = $this->rule_validators_registry->get_rule_validator( $rule_field_one ); |
|
| 59 | + // Skip to the next Rule Group if a rule isn't valid. |
|
| 60 | + if ( ! $rule_validator->is_valid( $identifier, $rule_logic_field, $rule_field_one, $rule_field_two, $type ) ) { |
|
| 61 | + continue 2; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - // If we got here it means that all the rules have been validated (or the rules' group has no rules). |
|
| 67 | - return true; |
|
| 68 | - } |
|
| 66 | + // If we got here it means that all the rules have been validated (or the rules' group has no rules). |
|
| 67 | + return true; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - return false; |
|
| 71 | - } |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | } |
@@ -15,63 +15,63 @@ |
||
| 15 | 15 | * @package Wordlift\Mappings\Validators |
| 16 | 16 | */ |
| 17 | 17 | class Post_Type_Rule_Validator implements Rule_Validator { |
| 18 | - /** |
|
| 19 | - * @since 3.25.0 |
|
| 20 | - * Enum for the post type rule validator. |
|
| 21 | - */ |
|
| 22 | - const POST_TYPE = 'post_type'; |
|
| 23 | - /** |
|
| 24 | - * Post_Type_Rule_Validator constructor. |
|
| 25 | - * |
|
| 26 | - * When initializing the class hooks to `wl_mappings_rule_validators`. |
|
| 27 | - */ |
|
| 28 | - public function __construct() { |
|
| 29 | - |
|
| 30 | - add_filter( 'wl_mappings_rule_validators', array( $this, 'wl_mappings_rule_validators' ) ); |
|
| 31 | - |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Hook to `wl_mappings_rule_validators` to register ourselves. |
|
| 36 | - * |
|
| 37 | - * @param array $value An array with validators. |
|
| 38 | - * |
|
| 39 | - * @return array An array with validators plus ours. |
|
| 40 | - */ |
|
| 41 | - public function wl_mappings_rule_validators( $value ) { |
|
| 42 | - |
|
| 43 | - $value[self::POST_TYPE] = $this; |
|
| 44 | - |
|
| 45 | - return $value; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * {@inheritdoc} |
|
| 50 | - */ |
|
| 51 | - public function get_label() { |
|
| 52 | - return __( 'Post Type', 'wordlift' ); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * {@inheritdoc} |
|
| 57 | - */ |
|
| 58 | - public function is_valid( $identifier, $operator, $operand_1, $operand_2, $type ) { |
|
| 59 | - |
|
| 60 | - // Get the post type and then check whether it matches or not according to the operator. |
|
| 61 | - $post_type = get_post_type( $identifier ); |
|
| 62 | - |
|
| 63 | - switch ( $operator ) { |
|
| 64 | - case Rule_Validator::IS_NOT_EQUAL_TO: |
|
| 65 | - return $post_type !== $operand_2; |
|
| 66 | - |
|
| 67 | - case Rule_Validator::IS_EQUAL_TO: |
|
| 68 | - return $post_type === $operand_2; |
|
| 69 | - |
|
| 70 | - default: |
|
| 71 | - |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - return false; |
|
| 75 | - } |
|
| 18 | + /** |
|
| 19 | + * @since 3.25.0 |
|
| 20 | + * Enum for the post type rule validator. |
|
| 21 | + */ |
|
| 22 | + const POST_TYPE = 'post_type'; |
|
| 23 | + /** |
|
| 24 | + * Post_Type_Rule_Validator constructor. |
|
| 25 | + * |
|
| 26 | + * When initializing the class hooks to `wl_mappings_rule_validators`. |
|
| 27 | + */ |
|
| 28 | + public function __construct() { |
|
| 29 | + |
|
| 30 | + add_filter( 'wl_mappings_rule_validators', array( $this, 'wl_mappings_rule_validators' ) ); |
|
| 31 | + |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Hook to `wl_mappings_rule_validators` to register ourselves. |
|
| 36 | + * |
|
| 37 | + * @param array $value An array with validators. |
|
| 38 | + * |
|
| 39 | + * @return array An array with validators plus ours. |
|
| 40 | + */ |
|
| 41 | + public function wl_mappings_rule_validators( $value ) { |
|
| 42 | + |
|
| 43 | + $value[self::POST_TYPE] = $this; |
|
| 44 | + |
|
| 45 | + return $value; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * {@inheritdoc} |
|
| 50 | + */ |
|
| 51 | + public function get_label() { |
|
| 52 | + return __( 'Post Type', 'wordlift' ); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * {@inheritdoc} |
|
| 57 | + */ |
|
| 58 | + public function is_valid( $identifier, $operator, $operand_1, $operand_2, $type ) { |
|
| 59 | + |
|
| 60 | + // Get the post type and then check whether it matches or not according to the operator. |
|
| 61 | + $post_type = get_post_type( $identifier ); |
|
| 62 | + |
|
| 63 | + switch ( $operator ) { |
|
| 64 | + case Rule_Validator::IS_NOT_EQUAL_TO: |
|
| 65 | + return $post_type !== $operand_2; |
|
| 66 | + |
|
| 67 | + case Rule_Validator::IS_EQUAL_TO: |
|
| 68 | + return $post_type === $operand_2; |
|
| 69 | + |
|
| 70 | + default: |
|
| 71 | + |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + return false; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function __construct() { |
| 29 | 29 | |
| 30 | - add_filter( 'wl_mappings_rule_validators', array( $this, 'wl_mappings_rule_validators' ) ); |
|
| 30 | + add_filter('wl_mappings_rule_validators', array($this, 'wl_mappings_rule_validators')); |
|
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @return array An array with validators plus ours. |
| 40 | 40 | */ |
| 41 | - public function wl_mappings_rule_validators( $value ) { |
|
| 41 | + public function wl_mappings_rule_validators($value) { |
|
| 42 | 42 | |
| 43 | 43 | $value[self::POST_TYPE] = $this; |
| 44 | 44 | |
@@ -49,18 +49,18 @@ discard block |
||
| 49 | 49 | * {@inheritdoc} |
| 50 | 50 | */ |
| 51 | 51 | public function get_label() { |
| 52 | - return __( 'Post Type', 'wordlift' ); |
|
| 52 | + return __('Post Type', 'wordlift'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * {@inheritdoc} |
| 57 | 57 | */ |
| 58 | - public function is_valid( $identifier, $operator, $operand_1, $operand_2, $type ) { |
|
| 58 | + public function is_valid($identifier, $operator, $operand_1, $operand_2, $type) { |
|
| 59 | 59 | |
| 60 | 60 | // Get the post type and then check whether it matches or not according to the operator. |
| 61 | - $post_type = get_post_type( $identifier ); |
|
| 61 | + $post_type = get_post_type($identifier); |
|
| 62 | 62 | |
| 63 | - switch ( $operator ) { |
|
| 63 | + switch ($operator) { |
|
| 64 | 64 | case Rule_Validator::IS_NOT_EQUAL_TO: |
| 65 | 65 | return $post_type !== $operand_2; |
| 66 | 66 | |
@@ -16,28 +16,28 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Taxonomy_Rule_Validator implements Rule_Validator { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * {@inheritdoc} |
|
| 21 | - */ |
|
| 22 | - public function is_valid( $identifier, $operator, $operand_1, $operand_2, $type ) { |
|
| 23 | - |
|
| 24 | - $taxonomy = $operand_1; |
|
| 25 | - $term_slug = $operand_2; |
|
| 26 | - |
|
| 27 | - $is_object_in_term = is_object_in_term( $identifier, $taxonomy, $term_slug ); |
|
| 28 | - |
|
| 29 | - if ( is_wp_error( $is_object_in_term ) ) { |
|
| 30 | - return false; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - return ( $is_object_in_term && self::IS_EQUAL_TO === $operator ) |
|
| 34 | - || ( ! $is_object_in_term && self::IS_NOT_EQUAL_TO === $operator ); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * {@inheritdoc} |
|
| 39 | - */ |
|
| 40 | - public function get_label() { |
|
| 41 | - return __( 'Taxonomy', 'wordlift' ); |
|
| 42 | - } |
|
| 19 | + /** |
|
| 20 | + * {@inheritdoc} |
|
| 21 | + */ |
|
| 22 | + public function is_valid( $identifier, $operator, $operand_1, $operand_2, $type ) { |
|
| 23 | + |
|
| 24 | + $taxonomy = $operand_1; |
|
| 25 | + $term_slug = $operand_2; |
|
| 26 | + |
|
| 27 | + $is_object_in_term = is_object_in_term( $identifier, $taxonomy, $term_slug ); |
|
| 28 | + |
|
| 29 | + if ( is_wp_error( $is_object_in_term ) ) { |
|
| 30 | + return false; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + return ( $is_object_in_term && self::IS_EQUAL_TO === $operator ) |
|
| 34 | + || ( ! $is_object_in_term && self::IS_NOT_EQUAL_TO === $operator ); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * {@inheritdoc} |
|
| 39 | + */ |
|
| 40 | + public function get_label() { |
|
| 41 | + return __( 'Taxonomy', 'wordlift' ); |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -19,25 +19,25 @@ |
||
| 19 | 19 | /** |
| 20 | 20 | * {@inheritdoc} |
| 21 | 21 | */ |
| 22 | - public function is_valid( $identifier, $operator, $operand_1, $operand_2, $type ) { |
|
| 22 | + public function is_valid($identifier, $operator, $operand_1, $operand_2, $type) { |
|
| 23 | 23 | |
| 24 | 24 | $taxonomy = $operand_1; |
| 25 | 25 | $term_slug = $operand_2; |
| 26 | 26 | |
| 27 | - $is_object_in_term = is_object_in_term( $identifier, $taxonomy, $term_slug ); |
|
| 27 | + $is_object_in_term = is_object_in_term($identifier, $taxonomy, $term_slug); |
|
| 28 | 28 | |
| 29 | - if ( is_wp_error( $is_object_in_term ) ) { |
|
| 29 | + if (is_wp_error($is_object_in_term)) { |
|
| 30 | 30 | return false; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - return ( $is_object_in_term && self::IS_EQUAL_TO === $operator ) |
|
| 34 | - || ( ! $is_object_in_term && self::IS_NOT_EQUAL_TO === $operator ); |
|
| 33 | + return ($is_object_in_term && self::IS_EQUAL_TO === $operator) |
|
| 34 | + || ( ! $is_object_in_term && self::IS_NOT_EQUAL_TO === $operator); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * {@inheritdoc} |
| 39 | 39 | */ |
| 40 | 40 | public function get_label() { |
| 41 | - return __( 'Taxonomy', 'wordlift' ); |
|
| 41 | + return __('Taxonomy', 'wordlift'); |
|
| 42 | 42 | } |
| 43 | 43 | } |
@@ -11,45 +11,45 @@ |
||
| 11 | 11 | |
| 12 | 12 | class Data_Source_Factory { |
| 13 | 13 | |
| 14 | - private static $instance = null; |
|
| 15 | - |
|
| 16 | - private $data_sources = array(); |
|
| 17 | - |
|
| 18 | - public function __construct() { |
|
| 19 | - $this->data_sources = array( |
|
| 20 | - 'acf' => new Acf_Data_Source(), |
|
| 21 | - 'meta' => new Meta_Data_Source() |
|
| 22 | - ); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @param $identifier int post id or term id based on type. |
|
| 27 | - * @param $property_data array |
|
| 28 | - * @param $type string post or term. |
|
| 29 | - * |
|
| 30 | - * @return mixed |
|
| 31 | - */ |
|
| 32 | - public function get_data( $identifier, $property_data, $type ) { |
|
| 33 | - switch ( $property_data['field_type'] ) { |
|
| 34 | - case Jsonld_Converter::FIELD_TYPE_ACF: |
|
| 35 | - return $this->data_sources['acf']->get_data( $identifier, $property_data, $type ); |
|
| 36 | - case Jsonld_Converter::FIELD_TYPE_CUSTOM_FIELD: |
|
| 37 | - return $this->data_sources['meta']->get_data( $identifier, $property_data, $type ); |
|
| 38 | - default: |
|
| 39 | - return $property_data['field_name']; |
|
| 40 | - } |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @return Data_Source_Factory |
|
| 46 | - */ |
|
| 47 | - public static function get_instance() { |
|
| 48 | - if ( self::$instance === null ) { |
|
| 49 | - self::$instance = new Data_Source_Factory(); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - return self::$instance; |
|
| 53 | - } |
|
| 14 | + private static $instance = null; |
|
| 15 | + |
|
| 16 | + private $data_sources = array(); |
|
| 17 | + |
|
| 18 | + public function __construct() { |
|
| 19 | + $this->data_sources = array( |
|
| 20 | + 'acf' => new Acf_Data_Source(), |
|
| 21 | + 'meta' => new Meta_Data_Source() |
|
| 22 | + ); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @param $identifier int post id or term id based on type. |
|
| 27 | + * @param $property_data array |
|
| 28 | + * @param $type string post or term. |
|
| 29 | + * |
|
| 30 | + * @return mixed |
|
| 31 | + */ |
|
| 32 | + public function get_data( $identifier, $property_data, $type ) { |
|
| 33 | + switch ( $property_data['field_type'] ) { |
|
| 34 | + case Jsonld_Converter::FIELD_TYPE_ACF: |
|
| 35 | + return $this->data_sources['acf']->get_data( $identifier, $property_data, $type ); |
|
| 36 | + case Jsonld_Converter::FIELD_TYPE_CUSTOM_FIELD: |
|
| 37 | + return $this->data_sources['meta']->get_data( $identifier, $property_data, $type ); |
|
| 38 | + default: |
|
| 39 | + return $property_data['field_name']; |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @return Data_Source_Factory |
|
| 46 | + */ |
|
| 47 | + public static function get_instance() { |
|
| 48 | + if ( self::$instance === null ) { |
|
| 49 | + self::$instance = new Data_Source_Factory(); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + return self::$instance; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | } |
@@ -29,12 +29,12 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @return mixed |
| 31 | 31 | */ |
| 32 | - public function get_data( $identifier, $property_data, $type ) { |
|
| 33 | - switch ( $property_data['field_type'] ) { |
|
| 32 | + public function get_data($identifier, $property_data, $type) { |
|
| 33 | + switch ($property_data['field_type']) { |
|
| 34 | 34 | case Jsonld_Converter::FIELD_TYPE_ACF: |
| 35 | - return $this->data_sources['acf']->get_data( $identifier, $property_data, $type ); |
|
| 35 | + return $this->data_sources['acf']->get_data($identifier, $property_data, $type); |
|
| 36 | 36 | case Jsonld_Converter::FIELD_TYPE_CUSTOM_FIELD: |
| 37 | - return $this->data_sources['meta']->get_data( $identifier, $property_data, $type ); |
|
| 37 | + return $this->data_sources['meta']->get_data($identifier, $property_data, $type); |
|
| 38 | 38 | default: |
| 39 | 39 | return $property_data['field_name']; |
| 40 | 40 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @return Data_Source_Factory |
| 46 | 46 | */ |
| 47 | 47 | public static function get_instance() { |
| 48 | - if ( self::$instance === null ) { |
|
| 48 | + if (self::$instance === null) { |
|
| 49 | 49 | self::$instance = new Data_Source_Factory(); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -13,6 +13,6 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | interface Abstract_Data_Source { |
| 15 | 15 | |
| 16 | - public function get_data( $identifier, $property, $type ); |
|
| 16 | + public function get_data( $identifier, $property, $type ); |
|
| 17 | 17 | |
| 18 | 18 | } |
@@ -13,6 +13,6 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | interface Abstract_Data_Source { |
| 15 | 15 | |
| 16 | - public function get_data( $identifier, $property, $type ); |
|
| 16 | + public function get_data($identifier, $property, $type); |
|
| 17 | 17 | |
| 18 | 18 | } |
@@ -23,14 +23,14 @@ |
||
| 23 | 23 | * |
| 24 | 24 | * @return array |
| 25 | 25 | */ |
| 26 | - public function get_data( $identifier, $property, $type ) { |
|
| 26 | + public function get_data($identifier, $property, $type) { |
|
| 27 | 27 | |
| 28 | 28 | $value = $property['field_name']; |
| 29 | 29 | |
| 30 | - if ( $type === Jsonld_Converter::TERM ) { |
|
| 31 | - return array_map( 'wp_strip_all_tags', get_term_meta( $identifier, $value ) ); |
|
| 30 | + if ($type === Jsonld_Converter::TERM) { |
|
| 31 | + return array_map('wp_strip_all_tags', get_term_meta($identifier, $value)); |
|
| 32 | 32 | } else { |
| 33 | - return array_map( 'wp_strip_all_tags', get_post_meta( $identifier, $value ) ); |
|
| 33 | + return array_map('wp_strip_all_tags', get_post_meta($identifier, $value)); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -16,21 +16,21 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Meta_Data_Source implements Abstract_Data_Source { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @param int $identifier Post id or term id |
|
| 21 | - * @param $property |
|
| 22 | - * @param $type |
|
| 23 | - * |
|
| 24 | - * @return array |
|
| 25 | - */ |
|
| 26 | - public function get_data( $identifier, $property, $type ) { |
|
| 19 | + /** |
|
| 20 | + * @param int $identifier Post id or term id |
|
| 21 | + * @param $property |
|
| 22 | + * @param $type |
|
| 23 | + * |
|
| 24 | + * @return array |
|
| 25 | + */ |
|
| 26 | + public function get_data( $identifier, $property, $type ) { |
|
| 27 | 27 | |
| 28 | - $value = $property['field_name']; |
|
| 28 | + $value = $property['field_name']; |
|
| 29 | 29 | |
| 30 | - if ( $type === Jsonld_Converter::TERM ) { |
|
| 31 | - return array_map( 'wp_strip_all_tags', get_term_meta( $identifier, $value ) ); |
|
| 32 | - } else { |
|
| 33 | - return array_map( 'wp_strip_all_tags', get_post_meta( $identifier, $value ) ); |
|
| 34 | - } |
|
| 35 | - } |
|
| 30 | + if ( $type === Jsonld_Converter::TERM ) { |
|
| 31 | + return array_map( 'wp_strip_all_tags', get_term_meta( $identifier, $value ) ); |
|
| 32 | + } else { |
|
| 33 | + return array_map( 'wp_strip_all_tags', get_post_meta( $identifier, $value ) ); |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -11,58 +11,58 @@ |
||
| 11 | 11 | |
| 12 | 12 | class Acf_Data_Source implements Abstract_Data_Source { |
| 13 | 13 | |
| 14 | - public function get_data( $identifier, $property_data, $type ) { |
|
| 14 | + public function get_data( $identifier, $property_data, $type ) { |
|
| 15 | 15 | |
| 16 | - if ( ! function_exists( 'get_field' ) || ! function_exists( 'get_field_object' ) ) { |
|
| 17 | - return array(); |
|
| 18 | - } |
|
| 16 | + if ( ! function_exists( 'get_field' ) || ! function_exists( 'get_field_object' ) ) { |
|
| 17 | + return array(); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - return $this->get_data_for_acf_field( $property_data['field_name'], $identifier, $type ); |
|
| 21 | - } |
|
| 20 | + return $this->get_data_for_acf_field( $property_data['field_name'], $identifier, $type ); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Gets data from acf, format the data if it is a repeater field. |
|
| 25 | - * |
|
| 26 | - * @param $field_name string |
|
| 27 | - * @param $identifier int Identifier ( post id or term id ) |
|
| 28 | - * |
|
| 29 | - * @return array|mixed |
|
| 30 | - */ |
|
| 31 | - private function get_data_for_acf_field( $field_name, $identifier, $type ) { |
|
| 32 | - if ( $type === Jsonld_Converter::TERM ) { |
|
| 33 | - $term = get_term( $identifier ); |
|
| 34 | - // Data fetching method for term is different. |
|
| 35 | - $field_data = get_field_object( $field_name, $term ); |
|
| 36 | - $data = get_field( $field_name, $term ); |
|
| 37 | - } else { |
|
| 38 | - $field_data = get_field_object( $field_name, $identifier ); |
|
| 39 | - $data = get_field( $field_name, $identifier ); |
|
| 40 | - } |
|
| 41 | - // only process if it is a repeater field, else return the data. |
|
| 42 | - if ( is_array( $field_data ) && array_key_exists( 'type', $field_data ) |
|
| 43 | - && $field_data['type'] === 'repeater' ) { |
|
| 44 | - /** |
|
| 45 | - * check if we have only one sub field, currently we only support one subfield, |
|
| 46 | - * so each repeater item should be checked if there is a single sub field. |
|
| 47 | - */ |
|
| 48 | - if ( is_array( $data ) && |
|
| 49 | - count( $data ) > 0 && |
|
| 50 | - count( array_keys( $data[0] ) ) === 1 ) { |
|
| 51 | - $repeater_formatted_data = array(); |
|
| 52 | - foreach ( $data as $item ) { |
|
| 53 | - $repeater_formatted_data = array_merge( $repeater_formatted_data, array_values( $item ) ); |
|
| 54 | - } |
|
| 55 | - // Remove non unique values. |
|
| 56 | - $repeater_formatted_data = array_unique( $repeater_formatted_data ); |
|
| 57 | - // Remove empty values |
|
| 58 | - $repeater_formatted_data = array_filter( $repeater_formatted_data, 'strlen' ); |
|
| 23 | + /** |
|
| 24 | + * Gets data from acf, format the data if it is a repeater field. |
|
| 25 | + * |
|
| 26 | + * @param $field_name string |
|
| 27 | + * @param $identifier int Identifier ( post id or term id ) |
|
| 28 | + * |
|
| 29 | + * @return array|mixed |
|
| 30 | + */ |
|
| 31 | + private function get_data_for_acf_field( $field_name, $identifier, $type ) { |
|
| 32 | + if ( $type === Jsonld_Converter::TERM ) { |
|
| 33 | + $term = get_term( $identifier ); |
|
| 34 | + // Data fetching method for term is different. |
|
| 35 | + $field_data = get_field_object( $field_name, $term ); |
|
| 36 | + $data = get_field( $field_name, $term ); |
|
| 37 | + } else { |
|
| 38 | + $field_data = get_field_object( $field_name, $identifier ); |
|
| 39 | + $data = get_field( $field_name, $identifier ); |
|
| 40 | + } |
|
| 41 | + // only process if it is a repeater field, else return the data. |
|
| 42 | + if ( is_array( $field_data ) && array_key_exists( 'type', $field_data ) |
|
| 43 | + && $field_data['type'] === 'repeater' ) { |
|
| 44 | + /** |
|
| 45 | + * check if we have only one sub field, currently we only support one subfield, |
|
| 46 | + * so each repeater item should be checked if there is a single sub field. |
|
| 47 | + */ |
|
| 48 | + if ( is_array( $data ) && |
|
| 49 | + count( $data ) > 0 && |
|
| 50 | + count( array_keys( $data[0] ) ) === 1 ) { |
|
| 51 | + $repeater_formatted_data = array(); |
|
| 52 | + foreach ( $data as $item ) { |
|
| 53 | + $repeater_formatted_data = array_merge( $repeater_formatted_data, array_values( $item ) ); |
|
| 54 | + } |
|
| 55 | + // Remove non unique values. |
|
| 56 | + $repeater_formatted_data = array_unique( $repeater_formatted_data ); |
|
| 57 | + // Remove empty values |
|
| 58 | + $repeater_formatted_data = array_filter( $repeater_formatted_data, 'strlen' ); |
|
| 59 | 59 | |
| 60 | - // re-index all the values. |
|
| 61 | - return array_values( $repeater_formatted_data ); |
|
| 62 | - } |
|
| 63 | - } |
|
| 60 | + // re-index all the values. |
|
| 61 | + return array_values( $repeater_formatted_data ); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - // Return normal acf data if it is not a repeater field. |
|
| 66 | - return $data; |
|
| 67 | - } |
|
| 65 | + // Return normal acf data if it is not a repeater field. |
|
| 66 | + return $data; |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -11,13 +11,13 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class Acf_Data_Source implements Abstract_Data_Source { |
| 13 | 13 | |
| 14 | - public function get_data( $identifier, $property_data, $type ) { |
|
| 14 | + public function get_data($identifier, $property_data, $type) { |
|
| 15 | 15 | |
| 16 | - if ( ! function_exists( 'get_field' ) || ! function_exists( 'get_field_object' ) ) { |
|
| 16 | + if ( ! function_exists('get_field') || ! function_exists('get_field_object')) { |
|
| 17 | 17 | return array(); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - return $this->get_data_for_acf_field( $property_data['field_name'], $identifier, $type ); |
|
| 20 | + return $this->get_data_for_acf_field($property_data['field_name'], $identifier, $type); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -28,37 +28,37 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return array|mixed |
| 30 | 30 | */ |
| 31 | - private function get_data_for_acf_field( $field_name, $identifier, $type ) { |
|
| 32 | - if ( $type === Jsonld_Converter::TERM ) { |
|
| 33 | - $term = get_term( $identifier ); |
|
| 31 | + private function get_data_for_acf_field($field_name, $identifier, $type) { |
|
| 32 | + if ($type === Jsonld_Converter::TERM) { |
|
| 33 | + $term = get_term($identifier); |
|
| 34 | 34 | // Data fetching method for term is different. |
| 35 | - $field_data = get_field_object( $field_name, $term ); |
|
| 36 | - $data = get_field( $field_name, $term ); |
|
| 35 | + $field_data = get_field_object($field_name, $term); |
|
| 36 | + $data = get_field($field_name, $term); |
|
| 37 | 37 | } else { |
| 38 | - $field_data = get_field_object( $field_name, $identifier ); |
|
| 39 | - $data = get_field( $field_name, $identifier ); |
|
| 38 | + $field_data = get_field_object($field_name, $identifier); |
|
| 39 | + $data = get_field($field_name, $identifier); |
|
| 40 | 40 | } |
| 41 | 41 | // only process if it is a repeater field, else return the data. |
| 42 | - if ( is_array( $field_data ) && array_key_exists( 'type', $field_data ) |
|
| 43 | - && $field_data['type'] === 'repeater' ) { |
|
| 42 | + if (is_array($field_data) && array_key_exists('type', $field_data) |
|
| 43 | + && $field_data['type'] === 'repeater') { |
|
| 44 | 44 | /** |
| 45 | 45 | * check if we have only one sub field, currently we only support one subfield, |
| 46 | 46 | * so each repeater item should be checked if there is a single sub field. |
| 47 | 47 | */ |
| 48 | - if ( is_array( $data ) && |
|
| 49 | - count( $data ) > 0 && |
|
| 50 | - count( array_keys( $data[0] ) ) === 1 ) { |
|
| 48 | + if (is_array($data) && |
|
| 49 | + count($data) > 0 && |
|
| 50 | + count(array_keys($data[0])) === 1) { |
|
| 51 | 51 | $repeater_formatted_data = array(); |
| 52 | - foreach ( $data as $item ) { |
|
| 53 | - $repeater_formatted_data = array_merge( $repeater_formatted_data, array_values( $item ) ); |
|
| 52 | + foreach ($data as $item) { |
|
| 53 | + $repeater_formatted_data = array_merge($repeater_formatted_data, array_values($item)); |
|
| 54 | 54 | } |
| 55 | 55 | // Remove non unique values. |
| 56 | - $repeater_formatted_data = array_unique( $repeater_formatted_data ); |
|
| 56 | + $repeater_formatted_data = array_unique($repeater_formatted_data); |
|
| 57 | 57 | // Remove empty values |
| 58 | - $repeater_formatted_data = array_filter( $repeater_formatted_data, 'strlen' ); |
|
| 58 | + $repeater_formatted_data = array_filter($repeater_formatted_data, 'strlen'); |
|
| 59 | 59 | |
| 60 | 60 | // re-index all the values. |
| 61 | - return array_values( $repeater_formatted_data ); |
|
| 61 | + return array_values($repeater_formatted_data); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
@@ -17,56 +17,56 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Taxonomy_Term_Rule_Validator implements Rule_Validator { |
| 19 | 19 | |
| 20 | - const TAXONOMY = 'taxonomy'; |
|
| 20 | + const TAXONOMY = 'taxonomy'; |
|
| 21 | 21 | |
| 22 | - public function __construct() { |
|
| 23 | - add_filter( 'wl_mappings_rule_validators', array( $this, 'wl_mappings_rule_validators' ) ); |
|
| 24 | - } |
|
| 22 | + public function __construct() { |
|
| 23 | + add_filter( 'wl_mappings_rule_validators', array( $this, 'wl_mappings_rule_validators' ) ); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Hook to `wl_mappings_rule_validators` to register ourselves. |
|
| 28 | - * |
|
| 29 | - * @param array $value An array with validators. |
|
| 30 | - * |
|
| 31 | - * @return array An array with validators plus ours. |
|
| 32 | - */ |
|
| 33 | - public function wl_mappings_rule_validators( $value ) { |
|
| 34 | - $value[ self::TAXONOMY ] = $this; |
|
| 26 | + /** |
|
| 27 | + * Hook to `wl_mappings_rule_validators` to register ourselves. |
|
| 28 | + * |
|
| 29 | + * @param array $value An array with validators. |
|
| 30 | + * |
|
| 31 | + * @return array An array with validators plus ours. |
|
| 32 | + */ |
|
| 33 | + public function wl_mappings_rule_validators( $value ) { |
|
| 34 | + $value[ self::TAXONOMY ] = $this; |
|
| 35 | 35 | |
| 36 | - return $value; |
|
| 37 | - } |
|
| 36 | + return $value; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | - public function get_label() { |
|
| 41 | - return __( 'TaxonomyTerm', 'wordlift' ); |
|
| 42 | - } |
|
| 40 | + public function get_label() { |
|
| 41 | + return __( 'TaxonomyTerm', 'wordlift' ); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - public function is_valid( $identifier, $operator, $operand_1, $taxonomy, $type ) { |
|
| 45 | - if ( $type !== Jsonld_Converter::TERM ) { |
|
| 46 | - return false; |
|
| 47 | - } |
|
| 48 | - $current_term = get_term( $identifier ); |
|
| 49 | - // If it is not a term page, then return false for two operators. |
|
| 50 | - if ( ! $current_term instanceof \WP_Term ) { |
|
| 51 | - return false; |
|
| 52 | - } |
|
| 53 | - $terms = get_terms( $taxonomy, array( 'get' => 'all' ) ); |
|
| 54 | - $terms = array_map( function ( $term ) { |
|
| 55 | - /** |
|
| 56 | - * @var $term \WP_Term |
|
| 57 | - */ |
|
| 58 | - return $term->term_id; |
|
| 59 | - }, $terms ); |
|
| 60 | - if ( $operator === Rule_Validator::IS_EQUAL_TO ) { |
|
| 61 | - // if we dont have term id, then skip the flow. |
|
| 62 | - // If we are in term page, then we need to check if the current |
|
| 63 | - // term belongs to the taxonomy |
|
| 64 | - return in_array( $current_term->term_id, $terms ); |
|
| 65 | - } |
|
| 44 | + public function is_valid( $identifier, $operator, $operand_1, $taxonomy, $type ) { |
|
| 45 | + if ( $type !== Jsonld_Converter::TERM ) { |
|
| 46 | + return false; |
|
| 47 | + } |
|
| 48 | + $current_term = get_term( $identifier ); |
|
| 49 | + // If it is not a term page, then return false for two operators. |
|
| 50 | + if ( ! $current_term instanceof \WP_Term ) { |
|
| 51 | + return false; |
|
| 52 | + } |
|
| 53 | + $terms = get_terms( $taxonomy, array( 'get' => 'all' ) ); |
|
| 54 | + $terms = array_map( function ( $term ) { |
|
| 55 | + /** |
|
| 56 | + * @var $term \WP_Term |
|
| 57 | + */ |
|
| 58 | + return $term->term_id; |
|
| 59 | + }, $terms ); |
|
| 60 | + if ( $operator === Rule_Validator::IS_EQUAL_TO ) { |
|
| 61 | + // if we dont have term id, then skip the flow. |
|
| 62 | + // If we are in term page, then we need to check if the current |
|
| 63 | + // term belongs to the taxonomy |
|
| 64 | + return in_array( $current_term->term_id, $terms ); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - if ( $operator === Rule_Validator::IS_NOT_EQUAL_TO ) { |
|
| 68 | - return ! in_array( $current_term->term_id, $terms ); |
|
| 69 | - } |
|
| 67 | + if ( $operator === Rule_Validator::IS_NOT_EQUAL_TO ) { |
|
| 68 | + return ! in_array( $current_term->term_id, $terms ); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | const TAXONOMY = 'taxonomy'; |
| 21 | 21 | |
| 22 | 22 | public function __construct() { |
| 23 | - add_filter( 'wl_mappings_rule_validators', array( $this, 'wl_mappings_rule_validators' ) ); |
|
| 23 | + add_filter('wl_mappings_rule_validators', array($this, 'wl_mappings_rule_validators')); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -30,42 +30,42 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return array An array with validators plus ours. |
| 32 | 32 | */ |
| 33 | - public function wl_mappings_rule_validators( $value ) { |
|
| 34 | - $value[ self::TAXONOMY ] = $this; |
|
| 33 | + public function wl_mappings_rule_validators($value) { |
|
| 34 | + $value[self::TAXONOMY] = $this; |
|
| 35 | 35 | |
| 36 | 36 | return $value; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | public function get_label() { |
| 41 | - return __( 'TaxonomyTerm', 'wordlift' ); |
|
| 41 | + return __('TaxonomyTerm', 'wordlift'); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function is_valid( $identifier, $operator, $operand_1, $taxonomy, $type ) { |
|
| 45 | - if ( $type !== Jsonld_Converter::TERM ) { |
|
| 44 | + public function is_valid($identifier, $operator, $operand_1, $taxonomy, $type) { |
|
| 45 | + if ($type !== Jsonld_Converter::TERM) { |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | - $current_term = get_term( $identifier ); |
|
| 48 | + $current_term = get_term($identifier); |
|
| 49 | 49 | // If it is not a term page, then return false for two operators. |
| 50 | - if ( ! $current_term instanceof \WP_Term ) { |
|
| 50 | + if ( ! $current_term instanceof \WP_Term) { |
|
| 51 | 51 | return false; |
| 52 | 52 | } |
| 53 | - $terms = get_terms( $taxonomy, array( 'get' => 'all' ) ); |
|
| 54 | - $terms = array_map( function ( $term ) { |
|
| 53 | + $terms = get_terms($taxonomy, array('get' => 'all')); |
|
| 54 | + $terms = array_map(function($term) { |
|
| 55 | 55 | /** |
| 56 | 56 | * @var $term \WP_Term |
| 57 | 57 | */ |
| 58 | 58 | return $term->term_id; |
| 59 | - }, $terms ); |
|
| 60 | - if ( $operator === Rule_Validator::IS_EQUAL_TO ) { |
|
| 59 | + }, $terms); |
|
| 60 | + if ($operator === Rule_Validator::IS_EQUAL_TO) { |
|
| 61 | 61 | // if we dont have term id, then skip the flow. |
| 62 | 62 | // If we are in term page, then we need to check if the current |
| 63 | 63 | // term belongs to the taxonomy |
| 64 | - return in_array( $current_term->term_id, $terms ); |
|
| 64 | + return in_array($current_term->term_id, $terms); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if ( $operator === Rule_Validator::IS_NOT_EQUAL_TO ) { |
|
| 68 | - return ! in_array( $current_term->term_id, $terms ); |
|
| 67 | + if ($operator === Rule_Validator::IS_NOT_EQUAL_TO) { |
|
| 68 | + return ! in_array($current_term->term_id, $terms); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | } |