Completed
Push — develop ( ed564b...616180 )
by Naveen
01:21
created
src/modules/pods/load.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,45 +16,45 @@
 block discarded – undo
16 16
 use Wordlift\Modules\Pods\Notices;
17 17
 use Wordlift\Modules\Pods\WlEntityField\Filters;
18 18
 
19
-if ( ! defined( 'ABSPATH' ) ) {
19
+if ( ! defined('ABSPATH')) {
20 20
 	exit;
21 21
 }
22 22
 
23
-if ( ! apply_filters( 'wl_feature__enable__pods-integration', false ) || ! defined( 'PODS_VERSION' ) ) { //phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
23
+if ( ! apply_filters('wl_feature__enable__pods-integration', false) || ! defined('PODS_VERSION')) { //phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
24 24
 	return;
25 25
 }
26 26
 
27 27
 // Autoloader for plugin itself.
28
-if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
29
-	require __DIR__ . '/vendor/autoload.php';
28
+if (file_exists(__DIR__.'/vendor/autoload.php')) {
29
+	require __DIR__.'/vendor/autoload.php';
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
-		$factory          = $container_builder->get( FieldDefinitionFactory::class );
41
+		$factory          = $container_builder->get(FieldDefinitionFactory::class);
42 42
 		$field_definition = $factory->get_field_definition();
43 43
 		$field_definition->register();
44 44
 
45 45
 		/**
46 46
 		 * @var $installer \Wordlift\Modules\Pods\Installer
47 47
 		 */
48
-		$installer = $container_builder->get( Installer::class );
48
+		$installer = $container_builder->get(Installer::class);
49 49
 		$installer->register_hooks();
50 50
 
51 51
 		/**
52 52
 		 * @var $notices \Wordlift\Modules\Pods\Notices
53 53
 		 */
54
-		$notices = $container_builder->get( Notices::class );
54
+		$notices = $container_builder->get(Notices::class);
55 55
 		$notices->register_hooks();
56 56
 
57
-		$filters = $container_builder->get( Filters::class );
57
+		$filters = $container_builder->get(Filters::class);
58 58
 
59 59
 	}
60 60
 );
Please login to merge, or discard this patch.
src/modules/pods/includes/Schema.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@  discard block
 block discarded – undo
6 6
 
7 7
 	public function get_context_type() {
8 8
 
9
-		if ( isset( $_REQUEST['post'] ) || isset( $_REQUEST['post_ID'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
9
+		if (isset($_REQUEST['post']) || isset($_REQUEST['post_ID'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
10 10
 			return Context::POST;
11 11
 		}
12
-		if ( isset( $_REQUEST['tag_ID'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
12
+		if (isset($_REQUEST['tag_ID'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
13 13
 			return Context::TERM;
14 14
 		}
15 15
 
16
-		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
16
+		if (is_admin() && ! defined('DOING_AJAX')) {
17 17
 			return Context::ADMIN_AJAX;
18 18
 		}
19 19
 
@@ -26,41 +26,41 @@  discard block
 block discarded – undo
26 26
 	public function get() {
27 27
 		// we need to identify the context to filter the results.
28 28
 
29
-		$identifier = isset( $_REQUEST['post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['post'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
30
-			: sanitize_text_field( wp_unslash( isset( $_REQUEST['post_ID'] ) ? $_REQUEST['post_ID'] : '' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
29
+		$identifier = isset($_REQUEST['post']) ? sanitize_text_field(wp_unslash($_REQUEST['post'])) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
30
+			: sanitize_text_field(wp_unslash(isset($_REQUEST['post_ID']) ? $_REQUEST['post_ID'] : '')); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
31 31
 
32
-		if ( $identifier ) {
32
+		if ($identifier) {
33 33
 			// If post identifier, get schema.
34
-			return new Context( Context::POST, $identifier, $this->get_fields_for_post( $identifier ) );
34
+			return new Context(Context::POST, $identifier, $this->get_fields_for_post($identifier));
35 35
 		}
36 36
 
37
-		$identifier = isset( $_REQUEST['tag_ID'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tag_ID'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
37
+		$identifier = isset($_REQUEST['tag_ID']) ? sanitize_text_field(wp_unslash($_REQUEST['tag_ID'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
38 38
 
39
-		if ( $identifier ) {
39
+		if ($identifier) {
40 40
 			// If post identifier, get schema.
41
-			return new Context( Context::TERM, $identifier, $this->get_fields_for_term( $identifier ) );
41
+			return new Context(Context::TERM, $identifier, $this->get_fields_for_term($identifier));
42 42
 		}
43 43
 
44
-		if ( is_admin() && defined( 'DOING_AJAX' ) ) {
45
-			return new Context( Context::ADMIN_AJAX, null, $this->get_all_fields() );
44
+		if (is_admin() && defined('DOING_AJAX')) {
45
+			return new Context(Context::ADMIN_AJAX, null, $this->get_all_fields());
46 46
 		}
47 47
 
48
-		return new Context( Context::UNKNOWN, null, null );
48
+		return new Context(Context::UNKNOWN, null, null);
49 49
 
50 50
 	}
51 51
 
52 52
 	/**
53 53
 	 * @return Schema_Field_Group[]
54 54
 	 */
55
-	private function get_fields_for_post( $identifier ) {
56
-		$types          = \Wordlift_Entity_Type_Service::get_instance()->get_names( $identifier );
55
+	private function get_fields_for_post($identifier) {
56
+		$types          = \Wordlift_Entity_Type_Service::get_instance()->get_names($identifier);
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
 			$types
66 66
 		);
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
 	/**
70 70
 	 * @return Schema_Field_Group[]
71 71
 	 */
72
-	private function get_fields_for_term( $identifier ) {
73
-		$term_entity_types = get_term_meta( (int) $identifier, \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
72
+	private function get_fields_for_term($identifier) {
73
+		$term_entity_types = get_term_meta((int) $identifier, \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
74 74
 		$schema_classes    = \Wordlift_Schema_Service::get_instance();
75 75
 
76 76
 		return array_map(
77
-			function ( $schema_type ) use ( $schema_classes ) {
78
-				$data = $schema_classes->get_schema( strtolower( $schema_type ) );
77
+			function($schema_type) use ($schema_classes) {
78
+				$data = $schema_classes->get_schema(strtolower($schema_type));
79 79
 
80
-				return new Schema_Field_Group( $schema_type, $data['custom_fields'] );
80
+				return new Schema_Field_Group($schema_type, $data['custom_fields']);
81 81
 			},
82 82
 			$term_entity_types
83 83
 		);
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
 
90 90
 		return array_filter(
91 91
 			array_map(
92
-				function ( $schema_type ) use ( $schema_classes ) {
93
-					$data = $schema_classes->get_schema( strtolower( $schema_type ) );
92
+				function($schema_type) use ($schema_classes) {
93
+					$data = $schema_classes->get_schema(strtolower($schema_type));
94 94
 
95
-					return new Schema_Field_Group( $schema_type, $data['custom_fields'] );
95
+					return new Schema_Field_Group($schema_type, $data['custom_fields']);
96 96
 				},
97 97
 				$all_schema_slugs
98 98
 			)
Please login to merge, or discard this patch.
src/modules/pods/includes/FieldDefinition/AbstractFieldDefiniton.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	 *
17 17
 	 * @return void
18 18
 	 */
19
-	public function __construct( $schema ) {
19
+	public function __construct($schema) {
20 20
 		$this->schema = $schema;
21 21
 	}
22 22
 
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @return int
29 29
 	 */
30
-	protected function register_pod( $name, $type, $context ) {
31
-		$pod_id              = intval( substr( md5( $type . '_' . $name ), 0, 8 ), 16 );
32
-		$pod                 = $this->pod( $pod_id, $name, $type );
30
+	protected function register_pod($name, $type, $context) {
31
+		$pod_id              = intval(substr(md5($type.'_'.$name), 0, 8), 16);
32
+		$pod                 = $this->pod($pod_id, $name, $type);
33 33
 		$schema_field_groups = $context->get_custom_fields();
34 34
 
35
-		foreach ( $schema_field_groups as $schema_field_group ) {
35
+		foreach ($schema_field_groups as $schema_field_group) {
36 36
 			$custom_fields = $schema_field_group->get_custom_fields();
37
-			if ( is_array( $custom_fields ) && count( $custom_fields ) > 0 ) {
37
+			if (is_array($custom_fields) && count($custom_fields) > 0) {
38 38
 				$this->group(
39 39
 					$schema_field_group->get_schema_type(),
40 40
 					$pod,
41 41
 					$this->group_fields(
42
-						...$this->custom_fields_to_pod_fields( $custom_fields, $pod_id )
42
+						...$this->custom_fields_to_pod_fields($custom_fields, $pod_id)
43 43
 					)
44 44
 				);
45 45
 			}
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 		);
66 66
 	}
67 67
 
68
-	protected function relationship( $name, $field_data ) {
68
+	protected function relationship($name, $field_data) {
69 69
 
70 70
 		$supported_schema_types = $field_data['constraints']['uri_type'];
71 71
 
72
-		if ( ! is_array( $supported_schema_types ) ) {
73
-			$supported_schema_types = array( $supported_schema_types );
72
+		if ( ! is_array($supported_schema_types)) {
73
+			$supported_schema_types = array($supported_schema_types);
74 74
 		}
75 75
 
76 76
 		return array(
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		);
105 105
 	}
106 106
 
107
-	protected function repeatable( $field, $repeatable_label = 'Add New' ) {
107
+	protected function repeatable($field, $repeatable_label = 'Add New') {
108 108
 		$field['repeatable']               = 1;
109 109
 		$field['repeatable_add_new_label'] = $repeatable_label;
110 110
 
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
 		);
134 134
 	}
135 135
 
136
-	protected function group_fields( ...$fields ) {
136
+	protected function group_fields(...$fields) {
137 137
 		$result = array();
138 138
 		array_map(
139
-			function ( $item ) use ( &$result ) {
139
+			function($item) use (&$result) {
140 140
 				$field_name            = $item['name'];
141
-				$result[ $field_name ] = $item;
141
+				$result[$field_name] = $item;
142 142
 			},
143 143
 			$fields
144 144
 		);
@@ -146,21 +146,21 @@  discard block
 block discarded – undo
146 146
 		return $result;
147 147
 	}
148 148
 
149
-	protected function group( $name, $pod, $group_fields ) {
149
+	protected function group($name, $pod, $group_fields) {
150 150
 		$group = array(
151 151
 			'name'        => $name,
152
-			'label'       => sprintf( 'WordLift - %s', $this->format_label( $name ) ),
152
+			'label'       => sprintf('WordLift - %s', $this->format_label($name)),
153 153
 			'description' => '',
154 154
 			'weight'      => 0,
155 155
 
156 156
 		);
157
-		pods_register_group( $group, $pod['name'], $group_fields );
157
+		pods_register_group($group, $pod['name'], $group_fields);
158 158
 	}
159 159
 
160
-	protected function pod( $pod_id, $name, $type ) {
160
+	protected function pod($pod_id, $name, $type) {
161 161
 		$pod = array(
162 162
 			'name'        => $name,
163
-			'label'       => $this->format_label( $name ),
163
+			'label'       => $this->format_label($name),
164 164
 			'description' => '',
165 165
 			'type'        => $type,
166 166
 			'storage'     => 'meta',
@@ -168,31 +168,31 @@  discard block
 block discarded – undo
168 168
 			'object'      => $name,
169 169
 		);
170 170
 
171
-		pods_register_type( $pod['type'], $pod['name'], $pod );
171
+		pods_register_type($pod['type'], $pod['name'], $pod);
172 172
 
173 173
 		return $pod;
174 174
 	}
175 175
 
176 176
 	protected function register_on_all_supported_taxonomies() {
177 177
 		$taxonomies = Terms_Compat::get_public_taxonomies();
178
-		foreach ( $taxonomies as $taxonomy ) {
179
-			$this->register_pod( $taxonomy, 'taxonomy' );
178
+		foreach ($taxonomies as $taxonomy) {
179
+			$this->register_pod($taxonomy, 'taxonomy');
180 180
 
181 181
 		}
182 182
 	}
183 183
 
184
-	protected function get_field_by_type( $name, $type, $field_data ) {
185
-		if ( 'uri' === $type && isset( $field_data['constraints']['uri_type'] ) ) {
186
-			return $this->relationship( $name, $field_data );
187
-		} elseif ( 'uri' === $type ) {
184
+	protected function get_field_by_type($name, $type, $field_data) {
185
+		if ('uri' === $type && isset($field_data['constraints']['uri_type'])) {
186
+			return $this->relationship($name, $field_data);
187
+		} elseif ('uri' === $type) {
188 188
 			return $this->website();
189
-		} elseif ( 'string' === $type ) {
189
+		} elseif ('string' === $type) {
190 190
 			return $this->text();
191
-		} elseif ( 'double' === $type ) {
192
-			return $this->number( $name, 2 );
193
-		} elseif ( 'date' === $type ) {
191
+		} elseif ('double' === $type) {
192
+			return $this->number($name, 2);
193
+		} elseif ('date' === $type) {
194 194
 			return $this->datetime();
195
-		} elseif ( 'multiline' === $type ) {
195
+		} elseif ('multiline' === $type) {
196 196
 			return $this->multiline();
197 197
 		} else {
198 198
 			return $this->text();
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		);
222 222
 	}
223 223
 
224
-	protected function number( $name, $decimals = 0 ) {
224
+	protected function number($name, $decimals = 0) {
225 225
 		return array(
226 226
 			'description'        => '',
227 227
 			'weight'             => 1,
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 		);
261 261
 	}
262 262
 
263
-	protected function may_be_repeatable( $custom_field, $field ) {
264
-		$repeatable = isset( $custom_field['constraints']['cardinality'] ) && INF === $custom_field['constraints']['cardinality'];
265
-		if ( $repeatable ) {
266
-			return $this->repeatable( $field );
263
+	protected function may_be_repeatable($custom_field, $field) {
264
+		$repeatable = isset($custom_field['constraints']['cardinality']) && INF === $custom_field['constraints']['cardinality'];
265
+		if ($repeatable) {
266
+			return $this->repeatable($field);
267 267
 		}
268 268
 
269 269
 		return $field;
@@ -273,38 +273,38 @@  discard block
 block discarded – undo
273 273
 	 * @return array
274 274
 	 * A function which defines these pods on the edit post screen.
275 275
 	 */
276
-	protected function custom_field_to_pod_field( $custom_field ) {
276
+	protected function custom_field_to_pod_field($custom_field) {
277 277
 
278
-		$name = str_replace( 'http://schema.org/', '', $custom_field['predicate'] );
279
-		$type = isset( $custom_field['type'] ) ? $custom_field['type'] : 'string';
278
+		$name = str_replace('http://schema.org/', '', $custom_field['predicate']);
279
+		$type = isset($custom_field['type']) ? $custom_field['type'] : 'string';
280 280
 
281
-		return $this->may_be_repeatable( $custom_field, $this->get_field_by_type( $name, $type, $custom_field ) );
281
+		return $this->may_be_repeatable($custom_field, $this->get_field_by_type($name, $type, $custom_field));
282 282
 	}
283 283
 
284
-	protected function wordlift_css_class( $field ) {
284
+	protected function wordlift_css_class($field) {
285 285
 		$field['class'] = 'wordlift';
286 286
 
287 287
 		return $field;
288 288
 	}
289 289
 
290
-	protected function custom_fields_to_pod_fields( $custom_fields, $pod_id ) {
290
+	protected function custom_fields_to_pod_fields($custom_fields, $pod_id) {
291 291
 
292 292
 		$pod_fields = array();
293 293
 
294
-		foreach ( $custom_fields as $name => $custom_field ) {
295
-			$pod_fields[] = $this->wordlift_css_class( $this->custom_field_to_pod_field( $custom_field ) ) + array(
294
+		foreach ($custom_fields as $name => $custom_field) {
295
+			$pod_fields[] = $this->wordlift_css_class($this->custom_field_to_pod_field($custom_field)) + array(
296 296
 				'pod_id' => $pod_id,
297
-				'id'     => intval( substr( md5( $pod_id . '_' . $name ), 0, 8 ), 16 ),
297
+				'id'     => intval(substr(md5($pod_id.'_'.$name), 0, 8), 16),
298 298
 				'name'   => $name,
299
-				'label'  => $this->format_label( str_replace( 'http://schema.org/', '', $custom_field['predicate'] ) ),
299
+				'label'  => $this->format_label(str_replace('http://schema.org/', '', $custom_field['predicate'])),
300 300
 			);
301 301
 		}
302 302
 
303
-		return array_values( $pod_fields );
303
+		return array_values($pod_fields);
304 304
 	}
305 305
 
306
-	protected function format_label( $name ) {
307
-		return join( ' ', array_map( 'ucwords', preg_split( '/(?=[A-Z])/', $name ) ) );
306
+	protected function format_label($name) {
307
+		return join(' ', array_map('ucwords', preg_split('/(?=[A-Z])/', $name)));
308 308
 	}
309 309
 
310 310
 }
Please login to merge, or discard this patch.
src/modules/pods/includes/WlEntityField/Filters.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@  discard block
 block discarded – undo
11 11
 
12 12
 	public function __construct() {
13 13
 
14
-		pods_register_related_object( self::FIELD_NAME, '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(self::FIELD_NAME, '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
 		add_action(
22 22
 			'pods_meta_save_taxonomy',
23
-			function ( $data, $pod, $id, $groups, $term_id ) {
24
-				$this->save_field( 'term', $term_id, $groups );
23
+			function($data, $pod, $id, $groups, $term_id) {
24
+				$this->save_field('term', $term_id, $groups);
25 25
 			},
26 26
 			10,
27 27
 			5
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 
30 30
 		add_action(
31 31
 			'pods_meta_save_post',
32
-			function ( $data, $pod, $id, $groups ) {
33
-				$this->save_field( 'post', $id, $groups );
32
+			function($data, $pod, $id, $groups) {
33
+				$this->save_field('post', $id, $groups);
34 34
 			},
35 35
 			10,
36 36
 			4
@@ -38,74 +38,74 @@  discard block
 block discarded – undo
38 38
 
39 39
 	}
40 40
 
41
-	private function save_field( $type, $identifier, $groups ) {
41
+	private function save_field($type, $identifier, $groups) {
42 42
 
43
-		$entity_fields = $this->filter_entity_fields( $groups );
43
+		$entity_fields = $this->filter_entity_fields($groups);
44 44
 
45
-		foreach ( $entity_fields as $entity_field ) {
46
-			delete_metadata( $type, $identifier, $entity_field );
47
-			$key = sprintf( 'pods_meta_%s', $entity_field );
45
+		foreach ($entity_fields as $entity_field) {
46
+			delete_metadata($type, $identifier, $entity_field);
47
+			$key = sprintf('pods_meta_%s', $entity_field);
48 48
 
49
-			$data = filter_var_array( $_REQUEST, array( $key => array( 'flags' => FILTER_REQUIRE_ARRAY ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
49
+			$data = filter_var_array($_REQUEST, array($key => array('flags' => FILTER_REQUIRE_ARRAY))); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
50 50
 
51
-			if ( ! $data ) {
51
+			if ( ! $data) {
52 52
 				continue;
53 53
 			}
54
-			$values = $data[ $key ];
54
+			$values = $data[$key];
55 55
 
56
-			foreach ( $values as $value ) {
57
-				add_metadata( $type, $identifier, $entity_field, $value );
56
+			foreach ($values as $value) {
57
+				add_metadata($type, $identifier, $entity_field, $value);
58 58
 			}
59 59
 		}
60 60
 
61 61
 	}
62 62
 
63
-	private function filter_entity_fields( $groups ) {
63
+	private function filter_entity_fields($groups) {
64 64
 
65
-		$pods = json_decode( wp_json_encode( $groups ), true );
65
+		$pods = json_decode(wp_json_encode($groups), true);
66 66
 
67 67
 		$fields = array_reduce(
68 68
 			$pods,
69
-			function ( $carry, $item ) {
70
-				return array_merge( $carry, $item['fields'] );
69
+			function($carry, $item) {
70
+				return array_merge($carry, $item['fields']);
71 71
 			},
72 72
 			array()
73 73
 		);
74 74
 
75 75
 		return array_map(
76
-			function ( $item ) {
76
+			function($item) {
77 77
 				return $item['name'];
78 78
 			},
79 79
 			array_filter(
80 80
 				$fields,
81
-				function ( $item ) {
82
-					return is_array( $item ) && isset( $item['pick_object'] ) && self::FIELD_NAME === $item['pick_object'];
81
+				function($item) {
82
+					return is_array($item) && isset($item['pick_object']) && self::FIELD_NAME === $item['pick_object'];
83 83
 				}
84 84
 			)
85 85
 		);
86 86
 	}
87 87
 
88
-	public function wl_pods_transform_data_for_pick_field( $item ) {
88
+	public function wl_pods_transform_data_for_pick_field($item) {
89 89
 
90 90
 		$content = $item->get_content();
91 91
 
92 92
 		return array(
93
-			'id'        => sprintf( '%s_%d', Object_Type_Enum::to_string( $content->get_object_type_enum() ), $content->get_id() ),
93
+			'id'        => sprintf('%s_%d', Object_Type_Enum::to_string($content->get_object_type_enum()), $content->get_id()),
94 94
 			'icon'      => 'https:\/\/wordlift.localhost\/wp-content\/plugins\/wordlift\/images\/svg\/wl-vocabulary-icon.svg',
95
-			'name'      => $item->get_title() . ' (' . $item->get_schema_type() . ')',
95
+			'name'      => $item->get_title().' ('.$item->get_schema_type().')',
96 96
 			'edit_link' => $content->get_edit_link(),
97 97
 			'link'      => $content->get_permalink(),
98 98
 			'selected'  => false,
99 99
 		);
100 100
 	}
101 101
 
102
-	public function admin_ajax_filter( $data, $name, $_, $field ) {
102
+	public function admin_ajax_filter($data, $name, $_, $field) {
103 103
 
104
-		if ( ( ! $field instanceof \Pods\Whatsit\Field ) || $field->get_arg( 'pick_object', false ) !== self::FIELD_NAME ) {
104
+		if (( ! $field instanceof \Pods\Whatsit\Field) || $field->get_arg('pick_object', false) !== self::FIELD_NAME) {
105 105
 			return $data;
106 106
 		}
107 107
 
108
-		$query         = sanitize_text_field( wp_unslash( isset( $_REQUEST['query'] ) ? $_REQUEST['query'] : '' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
108
+		$query         = sanitize_text_field(wp_unslash(isset($_REQUEST['query']) ? $_REQUEST['query'] : '')); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
109 109
 		$query_service = Entity_Query_Service::get_instance();
110 110
 
111 111
 		return array_map(
@@ -113,22 +113,22 @@  discard block
 block discarded – undo
113 113
 				$this,
114 114
 				'wl_pods_transform_data_for_pick_field',
115 115
 			),
116
-			$query_service->query( $query, $field->get_arg( 'supported_schema_types', array( 'Thing' ) ) )
116
+			$query_service->query($query, $field->get_arg('supported_schema_types', array('Thing')))
117 117
 		);
118 118
 
119 119
 	}
120 120
 
121
-	public function data_filter( $data, $args ) {
121
+	public function data_filter($data, $args) {
122 122
 
123
-		$args_arr   = json_decode( wp_json_encode( $args ), true );
123
+		$args_arr   = json_decode(wp_json_encode($args), true);
124 124
 		$field_data = $args_arr['options'];
125 125
 
126
-		if ( ! isset( $field_data['pick_object'] ) || self::FIELD_NAME !== $field_data['pick_object'] ) {
126
+		if ( ! isset($field_data['pick_object']) || self::FIELD_NAME !== $field_data['pick_object']) {
127 127
 			return $data;
128 128
 		}
129 129
 
130
-		if ( ! isset( $args_arr['pod']['data']['pod_data']['type'] )
131
-			 || ! is_string( $args_arr['pod']['data']['pod_data']['type'] ) ) {
130
+		if ( ! isset($args_arr['pod']['data']['pod_data']['type'])
131
+			 || ! is_string($args_arr['pod']['data']['pod_data']['type'])) {
132 132
 			return $data;
133 133
 		}
134 134
 
@@ -136,60 +136,60 @@  discard block
 block discarded – undo
136 136
 		$identifier = $args->id;
137 137
 		$type       = $args_arr['pod']['data']['pod_data']['type'];
138 138
 
139
-		if ( 'post_type' === $type ) {
140
-			$data['fieldValue'] = get_post_meta( $identifier, $name );
141
-		} elseif ( 'taxonomy' === $type ) {
142
-			$data['fieldValue'] = get_term_meta( $identifier, $name );
139
+		if ('post_type' === $type) {
140
+			$data['fieldValue'] = get_post_meta($identifier, $name);
141
+		} elseif ('taxonomy' === $type) {
142
+			$data['fieldValue'] = get_term_meta($identifier, $name);
143 143
 		}
144 144
 
145 145
 		return $data;
146 146
 	}
147 147
 
148
-	public function ajax_filter( $result, $name, $value, $field_options ) {
148
+	public function ajax_filter($result, $name, $value, $field_options) {
149 149
 
150
-		if ( ! isset( $field_options['pick_object'] ) ) {
150
+		if ( ! isset($field_options['pick_object'])) {
151 151
 			return $result;
152 152
 		}
153 153
 
154 154
 		return self::FIELD_NAME === $field_options['pick_object'];
155 155
 	}
156 156
 
157
-	public function table_info_filter( $info, $object_type, $object, $name, $pod, $field ) {
157
+	public function table_info_filter($info, $object_type, $object, $name, $pod, $field) {
158 158
 
159
-		if ( $field === null || self::FIELD_NAME !== $field->get_arg( 'pick_object', false ) ) {
159
+		if ($field === null || self::FIELD_NAME !== $field->get_arg('pick_object', false)) {
160 160
 			return $info;
161 161
 		}
162 162
 		// We need to return an non empty array here to prevent pods from querying a table.
163 163
 		// This is necessary to prevent errors on ui.
164
-		return array( 'foo' => 'bar' );
164
+		return array('foo' => 'bar');
165 165
 	}
166 166
 
167
-	public function field_options_filter( $_, $name, $value, $options, $pod, $id, $object_params ) {
167
+	public function field_options_filter($_, $name, $value, $options, $pod, $id, $object_params) {
168 168
 
169
-		$object_params = json_decode( wp_json_encode( $object_params ), true );
169
+		$object_params = json_decode(wp_json_encode($object_params), true);
170 170
 
171 171
 		$query_service = Entity_Query_Service::get_instance();
172 172
 
173
-		if ( is_array( $object_params ) && isset( $object_params['options']['pick_object'] )
174
-			 && is_string( $object_params['options']['pick_object'] )
173
+		if (is_array($object_params) && isset($object_params['options']['pick_object'])
174
+			 && is_string($object_params['options']['pick_object'])
175 175
 			 && self::FIELD_NAME === $object_params['options']['pick_object']
176
-			 && isset( $object_params['pod']['data']['pod_data']['type'] )
177
-			 && is_string( $object_params['pod']['data']['pod_data']['type'] ) ) {
176
+			 && isset($object_params['pod']['data']['pod_data']['type'])
177
+			 && is_string($object_params['pod']['data']['pod_data']['type'])) {
178 178
 
179 179
 			$type            = $object_params['pod']['data']['pod_data']['type'];
180 180
 			$linked_entities = array();
181
-			if ( 'post_type' === $type ) {
182
-				$linked_entities = get_post_meta( $id, $name );
183
-			} elseif ( 'taxonomy' === $type ) {
184
-				$linked_entities = get_term_meta( $id, $name );
181
+			if ('post_type' === $type) {
182
+				$linked_entities = get_post_meta($id, $name);
183
+			} elseif ('taxonomy' === $type) {
184
+				$linked_entities = get_term_meta($id, $name);
185 185
 			}
186 186
 			$data            = array();
187
-			$linked_entities = $query_service->get( $linked_entities );
188
-			foreach ( $linked_entities as $linked_entity ) {
187
+			$linked_entities = $query_service->get($linked_entities);
188
+			foreach ($linked_entities as $linked_entity) {
189 189
 				$content     = $linked_entity->get_content();
190
-				$id          = sprintf( '%s_%d', Object_Type_Enum::to_string( $content->get_object_type_enum() ), $content->get_id() );
191
-				$text        = $linked_entity->get_title() . ' (' . $linked_entity->get_schema_type() . ')';
192
-				$data[ $id ] = $text;
190
+				$id          = sprintf('%s_%d', Object_Type_Enum::to_string($content->get_object_type_enum()), $content->get_id());
191
+				$text        = $linked_entity->get_title().' ('.$linked_entity->get_schema_type().')';
192
+				$data[$id] = $text;
193 193
 			}
194 194
 
195 195
 			return $data;
Please login to merge, or discard this patch.