Completed
Pull Request — develop (#1576)
by Naveen
01:24
created
src/modules/pods/includes/FieldDefinition/FieldDefinitionFactory.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,21 +7,21 @@
 block discarded – undo
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() {
20
+    public function get_field_definition() {
21 21
 
22
-		// For now we are registering all the pods.
23
-		return new AllPodsDefiniton( $this->schema );
24
-	}
22
+        // For now we are registering all the pods.
23
+        return new AllPodsDefiniton( $this->schema );
24
+    }
25 25
 
26 26
 
27 27
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
20 20
 	public function get_field_definition() {
21 21
 
22 22
 		// For now we are registering all the pods.
23
-		return new AllPodsDefiniton( $this->schema );
23
+		return new AllPodsDefiniton($this->schema);
24 24
 	}
25 25
 
26 26
 
Please login to merge, or discard this patch.
src/modules/pods/includes/FieldDefinition/AbstractFieldDefiniton.php 2 patches
Indentation   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -6,316 +6,316 @@
 block discarded – undo
6 6
 use Wordlift\Vocabulary\Terms_Compat;
7 7
 
8 8
 abstract class AbstractFieldDefiniton implements FieldDefinition {
9
-	/**
10
-	 * @var \Wordlift\Modules\Pods\Schema
11
-	 */
12
-	protected $schema;
13
-
14
-	/**
15
-	 * @param  \Wordlift\Modules\Pods\Schema $schema
16
- 	 *
17
-	 * @return void
18
-	 */
19
-	public function __construct( $schema ) {
20
-		$this->schema = $schema;
21
-	}
22
-
23
-
24
-	/**
25
-	 * @param $name string
26
-	 * @param $type string
27
-	 * @param $context Context
28
-	 *
29
-	 * @return int
30
-	 */
31
-	protected function register_pod( $name, $type, $context ) {
32
-		$pod_id              = intval( substr( md5( $type . '_' . $name ), 0, 8 ), 16 );
33
-		$pod                 = $this->pod( $pod_id, $name, $type );
34
-		$schema_field_groups = $context->get_custom_fields();
35
-
36
-		foreach ( $schema_field_groups as $schema_field_group ) {
37
-			$custom_fields = $schema_field_group->get_custom_fields();
38
-			if ( is_array( $custom_fields ) && count( $custom_fields ) > 0 ) {
39
-				$this->group(
40
-					$schema_field_group->get_schema_type(),
41
-					$pod,
42
-					$this->group_fields(
43
-						...$this->custom_fields_to_pod_fields( $custom_fields, $pod_id )
44
-					)
45
-				);
46
-			}
47
-		}
48
-
49
-		return $pod_id;
50
-
51
-	}
52
-
53
-	protected function text( $name ) {
54
-		return array(
55
-			'description'            => '',
56
-			'weight'                 => 0,
57
-			'type'                   => 'text',
58
-			'sister_id'              => '-- Select One --',
59
-			'rest_route'             => '/pods/v1/fields',
60
-			'required'               => '0',
61
-			'text_allowed_html_tags' => 'strong em a ul ol li b i',
62
-			'text_max_length'        => '255',
63
-			'roles_allowed'          => 'administrator',
64
-			'rest_pick_response'     => 'array',
65
-			'rest_pick_depth'        => '1',
66
-		);
67
-	}
68
-
69
-	protected function relationship( $name, $field_data ) {
70
-
71
-		$supported_schema_types = $field_data['constraints']['uri_type'];
72
-
73
-		if ( ! is_array( $supported_schema_types ) ) {
74
-			$supported_schema_types = array( $supported_schema_types );
75
-		}
76
-
77
-		return array(
78
-			'description'                   => '',
79
-			'weight'                        => 0,
80
-			'type'                          => 'pick',
81
-			'pick_object'                   => 'wlentity',
82
-			'sister_id'                     => '-- Select One --',
83
-			'rest_route'                    => '/pods/v1/fields',
84
-			'pick_table'                    => '-- Select One --',
85
-			'required'                      => '0',
86
-			'repeatable'                    => '0',
87
-			'pick_format_type'              => 'single',
88
-			'pick_format_single'            => 'autocomplete',
89
-			'pick_format_multi'             => 'list',
90
-			'pick_display_format_multi'     => 'autocomplete',
91
-			'pick_display_format_separator' => ', ',
92
-			'pick_allow_add_new'            => '1',
93
-			'pick_taggable'                 => '0',
94
-			'pick_show_icon'                => '1',
95
-			'pick_show_edit_link'           => '1',
96
-			'pick_show_view_link'           => '1',
97
-			'pick_limit'                    => '0',
98
-			'pick_user_role'                => 'Administrator',
99
-			'pick_post_status'              => 'publish',
100
-			'pick_post_author'              => '0',
101
-			'roles_allowed'                 => 'administrator',
102
-			'rest_pick_response'            => 'array',
103
-			'rest_pick_depth'               => '1',
104
-			'supported_schema_types'        => $supported_schema_types,
105
-		);
106
-	}
107
-
108
-
109
-	protected function repeatable( $field, $repeatable_label = 'Add New' ) {
110
-		$field['repeatable']               = 1;
111
-		$field['repeatable_add_new_label'] = $repeatable_label;
112
-
113
-		return $field;
114
-	}
115
-
116
-	protected function website( $name ) {
117
-		return array(
118
-			'description'        => '',
119
-			'weight'             => 0,
120
-			'type'               => 'website',
121
-			'sister_id'          => '-- Select One --',
122
-			'rest_route'         => '/pods/v1/fields',
123
-			'required'           => '0',
124
-			'repeatable'         => '0',
125
-			'roles_allowed'      => 'administrator',
126
-			'rest_pick_response' => 'array',
127
-			'rest_pick_depth'    => '1',
128
-			'website_format'     => 'normal',
129
-			'website_allow_port' => '0',
130
-			'website_clickable'  => '0',
131
-			'website_new_window' => '0',
132
-			'website_nofollow'   => '0',
133
-			'website_max_length' => '255',
134
-			'website_html5'      => '0',
135
-		);
136
-	}
137
-
138
-
139
-	protected function group_fields( ...$fields ) {
140
-		$result = array();
141
-		array_map(
142
-			function ( $item ) use ( &$result ) {
143
-				$field_name            = $item['name'];
144
-				$result[ $field_name ] = $item;
145
-			},
146
-			$fields
147
-		);
148
-
149
-		return $result;
150
-	}
151
-
152
-	protected function group( $name, $pod, $group_fields ) {
153
-		$group = array(
154
-			'name'        => $name,
155
-			'label'       => sprintf( 'WordLift - %s', $this->format_label( $name ) ),
156
-			'description' => '',
157
-			'weight'      => 0,
158
-
159
-		);
160
-		pods_register_group( $group, $pod['name'], $group_fields );
161
-	}
162
-
163
-	protected function pod( $pod_id, $name, $type ) {
164
-		$pod = array(
165
-			'name'        => $name,
166
-			'label'       => $this->format_label( $name ),
167
-			'description' => '',
168
-			'type'        => $type,
169
-			'storage'     => 'meta',
170
-			'id'          => $pod_id,
171
-			'object'      => $name,
172
-		);
173
-
174
-		pods_register_type( $pod['type'], $pod['name'], $pod );
175
-
176
-		return $pod;
177
-	}
178
-
179
-	protected function register_on_all_supported_taxonomies() {
180
-		$taxonomies = Terms_Compat::get_public_taxonomies();
181
-		foreach ( $taxonomies as $taxonomy ) {
182
-			$this->register_pod( $taxonomy, 'taxonomy' );
183
-
184
-		}
185
-	}
186
-
187
-
188
-	protected function get_field_by_type( $name, $type, $field_data ) {
189
-		if ( 'uri' === $type && isset( $field_data['constraints']['uri_type'] ) ) {
190
-			return $this->relationship( $name, $field_data );
191
-		} elseif ( 'uri' === $type ) {
192
-			return $this->website( $name );
193
-		} elseif ( 'string' === $type ) {
194
-			return $this->text( $name );
195
-		} elseif ( 'double' === $type ) {
196
-			return $this->number( $name, 2 );
197
-		} elseif ( 'date' === $type ) {
198
-			return $this->datetime( $name );
199
-		} elseif ( 'multiline' === $type ) {
200
-			return $this->multiline( $name );
201
-		} else {
202
-			return $this->text( $name );
203
-		}
204
-	}
205
-
206
-	protected function datetime( $name ) {
207
-		return array(
208
-			'description'             => '',
209
-			'weight'                  => 2,
210
-			'type'                    => 'datetime',
211
-			'sister_id'               => '-- Select One --',
212
-			'rest_route'              => '/pods/v1/fields',
213
-			'required'                => '0',
214
-			'repeatable'              => '0',
215
-			'datetime_type'           => 'format',
216
-			'datetime_format'         => 'ymd_slash',
217
-			'datetime_time_type'      => '24',
218
-			'datetime_time_format'    => 'h_mma',
219
-			'datetime_time_format_24' => 'hh_mm',
220
-			'datetime_allow_empty'    => '1',
221
-			'datetime_html5'          => '0',
222
-			'roles_allowed'           => 'administrator',
223
-			'rest_pick_response'      => 'array',
224
-			'rest_pick_depth'         => '1',
225
-		);
226
-	}
227
-
228
-
229
-	protected function number( $name, $decimals = 0 ) {
230
-		return array(
231
-			'description'        => '',
232
-			'weight'             => 1,
233
-			'type'               => 'number',
234
-			'sister_id'          => '-- Select One --',
235
-			'rest_route'         => '/pods/v1/fields',
236
-			'required'           => '0',
237
-			'repeatable'         => '0',
238
-			'number_format_type' => 'number',
239
-			'number_format'      => 'i18n',
240
-			'number_decimals'    => $decimals,
241
-			'number_format_soft' => '0',
242
-			'number_step'        => '2',
243
-			'number_max_length'  => '0',
244
-			'number_html5'       => '0',
245
-			'roles_allowed'      => 'administrator',
246
-			'rest_pick_response' => 'array',
247
-			'rest_pick_depth'    => '1',
248
-		);
249
-	}
250
-
251
-
252
-	protected function multiline( $name ) {
253
-		return array(
254
-			'description'                 => '',
255
-			'weight'                      => 3,
256
-			'type'                        => 'paragraph',
257
-			'sister_id'                   => '-- Select One --',
258
-			'rest_route'                  => '/pods/v1/fields',
259
-			'required'                    => '0',
260
-			'repeatable'                  => '0',
261
-			'paragraph_allowed_html_tags' => 'strong em a ul ol li b i',
262
-			'paragraph_max_length'        => '-1',
263
-			'roles_allowed'               => 'administrator',
264
-			'rest_pick_response'          => 'array',
265
-			'rest_pick_depth'             => '1',
266
-		);
267
-	}
268
-
269
-	protected function may_be_repeatable( $custom_field, $field ) {
270
-		$repeatable = isset( $custom_field['constraints']['cardinality'] ) && INF === $custom_field['constraints']['cardinality'];
271
-		if ( $repeatable ) {
272
-			return $this->repeatable( $field );
273
-		}
274
-
275
-		return $field;
276
-	}
277
-
278
-
279
-	/**
280
-	 * @return array
281
-	 * A function which defines these pods on the edit post screen.
282
-	 */
283
-
284
-	protected function custom_field_to_pod_field( $custom_field ) {
285
-
286
-		$name = str_replace( 'http://schema.org/', '', $custom_field['predicate'] );
287
-		$type = isset( $custom_field['type'] ) ? $custom_field['type'] : 'string';
288
-
289
-		return $this->may_be_repeatable( $custom_field, $this->get_field_by_type( $name, $type, $custom_field ) );
290
-	}
291
-
292
-	protected function wordlift_css_class( $field ) {
293
-		$field['class'] = 'wordlift';
294
-
295
-		return $field;
296
-	}
297
-
298
-
299
-	protected function custom_fields_to_pod_fields( $custom_fields, $pod_id ) {
300
-
301
-		$pod_fields = array();
302
-
303
-		foreach ( $custom_fields as $name => $custom_field ) {
304
-			$pod_fields[] =  $this->wordlift_css_class( $this->custom_field_to_pod_field( $custom_field ) ) + array(
305
-					'pod_id' => $pod_id,
306
-					'id'     => intval( substr( md5( $pod_id . '_' . $name ), 0, 8 ), 16 ),
307
-					'name'   => $name,
308
-					'label'  => $this->format_label( str_replace( 'http://schema.org/', '', $custom_field['predicate'] ) ),
309
-				);
310
-		}
311
-
312
-
313
-		return array_values( $pod_fields );
314
-	}
315
-
316
-	protected function format_label( $name ) {
317
-		return join( ' ', array_map( 'ucwords', preg_split( '/(?=[A-Z])/', $name ) ) );
318
-	}
9
+    /**
10
+     * @var \Wordlift\Modules\Pods\Schema
11
+     */
12
+    protected $schema;
13
+
14
+    /**
15
+     * @param  \Wordlift\Modules\Pods\Schema $schema
16
+     *
17
+     * @return void
18
+     */
19
+    public function __construct( $schema ) {
20
+        $this->schema = $schema;
21
+    }
22
+
23
+
24
+    /**
25
+     * @param $name string
26
+     * @param $type string
27
+     * @param $context Context
28
+     *
29
+     * @return int
30
+     */
31
+    protected function register_pod( $name, $type, $context ) {
32
+        $pod_id              = intval( substr( md5( $type . '_' . $name ), 0, 8 ), 16 );
33
+        $pod                 = $this->pod( $pod_id, $name, $type );
34
+        $schema_field_groups = $context->get_custom_fields();
35
+
36
+        foreach ( $schema_field_groups as $schema_field_group ) {
37
+            $custom_fields = $schema_field_group->get_custom_fields();
38
+            if ( is_array( $custom_fields ) && count( $custom_fields ) > 0 ) {
39
+                $this->group(
40
+                    $schema_field_group->get_schema_type(),
41
+                    $pod,
42
+                    $this->group_fields(
43
+                        ...$this->custom_fields_to_pod_fields( $custom_fields, $pod_id )
44
+                    )
45
+                );
46
+            }
47
+        }
48
+
49
+        return $pod_id;
50
+
51
+    }
52
+
53
+    protected function text( $name ) {
54
+        return array(
55
+            'description'            => '',
56
+            'weight'                 => 0,
57
+            'type'                   => 'text',
58
+            'sister_id'              => '-- Select One --',
59
+            'rest_route'             => '/pods/v1/fields',
60
+            'required'               => '0',
61
+            'text_allowed_html_tags' => 'strong em a ul ol li b i',
62
+            'text_max_length'        => '255',
63
+            'roles_allowed'          => 'administrator',
64
+            'rest_pick_response'     => 'array',
65
+            'rest_pick_depth'        => '1',
66
+        );
67
+    }
68
+
69
+    protected function relationship( $name, $field_data ) {
70
+
71
+        $supported_schema_types = $field_data['constraints']['uri_type'];
72
+
73
+        if ( ! is_array( $supported_schema_types ) ) {
74
+            $supported_schema_types = array( $supported_schema_types );
75
+        }
76
+
77
+        return array(
78
+            'description'                   => '',
79
+            'weight'                        => 0,
80
+            'type'                          => 'pick',
81
+            'pick_object'                   => 'wlentity',
82
+            'sister_id'                     => '-- Select One --',
83
+            'rest_route'                    => '/pods/v1/fields',
84
+            'pick_table'                    => '-- Select One --',
85
+            'required'                      => '0',
86
+            'repeatable'                    => '0',
87
+            'pick_format_type'              => 'single',
88
+            'pick_format_single'            => 'autocomplete',
89
+            'pick_format_multi'             => 'list',
90
+            'pick_display_format_multi'     => 'autocomplete',
91
+            'pick_display_format_separator' => ', ',
92
+            'pick_allow_add_new'            => '1',
93
+            'pick_taggable'                 => '0',
94
+            'pick_show_icon'                => '1',
95
+            'pick_show_edit_link'           => '1',
96
+            'pick_show_view_link'           => '1',
97
+            'pick_limit'                    => '0',
98
+            'pick_user_role'                => 'Administrator',
99
+            'pick_post_status'              => 'publish',
100
+            'pick_post_author'              => '0',
101
+            'roles_allowed'                 => 'administrator',
102
+            'rest_pick_response'            => 'array',
103
+            'rest_pick_depth'               => '1',
104
+            'supported_schema_types'        => $supported_schema_types,
105
+        );
106
+    }
107
+
108
+
109
+    protected function repeatable( $field, $repeatable_label = 'Add New' ) {
110
+        $field['repeatable']               = 1;
111
+        $field['repeatable_add_new_label'] = $repeatable_label;
112
+
113
+        return $field;
114
+    }
115
+
116
+    protected function website( $name ) {
117
+        return array(
118
+            'description'        => '',
119
+            'weight'             => 0,
120
+            'type'               => 'website',
121
+            'sister_id'          => '-- Select One --',
122
+            'rest_route'         => '/pods/v1/fields',
123
+            'required'           => '0',
124
+            'repeatable'         => '0',
125
+            'roles_allowed'      => 'administrator',
126
+            'rest_pick_response' => 'array',
127
+            'rest_pick_depth'    => '1',
128
+            'website_format'     => 'normal',
129
+            'website_allow_port' => '0',
130
+            'website_clickable'  => '0',
131
+            'website_new_window' => '0',
132
+            'website_nofollow'   => '0',
133
+            'website_max_length' => '255',
134
+            'website_html5'      => '0',
135
+        );
136
+    }
137
+
138
+
139
+    protected function group_fields( ...$fields ) {
140
+        $result = array();
141
+        array_map(
142
+            function ( $item ) use ( &$result ) {
143
+                $field_name            = $item['name'];
144
+                $result[ $field_name ] = $item;
145
+            },
146
+            $fields
147
+        );
148
+
149
+        return $result;
150
+    }
151
+
152
+    protected function group( $name, $pod, $group_fields ) {
153
+        $group = array(
154
+            'name'        => $name,
155
+            'label'       => sprintf( 'WordLift - %s', $this->format_label( $name ) ),
156
+            'description' => '',
157
+            'weight'      => 0,
158
+
159
+        );
160
+        pods_register_group( $group, $pod['name'], $group_fields );
161
+    }
162
+
163
+    protected function pod( $pod_id, $name, $type ) {
164
+        $pod = array(
165
+            'name'        => $name,
166
+            'label'       => $this->format_label( $name ),
167
+            'description' => '',
168
+            'type'        => $type,
169
+            'storage'     => 'meta',
170
+            'id'          => $pod_id,
171
+            'object'      => $name,
172
+        );
173
+
174
+        pods_register_type( $pod['type'], $pod['name'], $pod );
175
+
176
+        return $pod;
177
+    }
178
+
179
+    protected function register_on_all_supported_taxonomies() {
180
+        $taxonomies = Terms_Compat::get_public_taxonomies();
181
+        foreach ( $taxonomies as $taxonomy ) {
182
+            $this->register_pod( $taxonomy, 'taxonomy' );
183
+
184
+        }
185
+    }
186
+
187
+
188
+    protected function get_field_by_type( $name, $type, $field_data ) {
189
+        if ( 'uri' === $type && isset( $field_data['constraints']['uri_type'] ) ) {
190
+            return $this->relationship( $name, $field_data );
191
+        } elseif ( 'uri' === $type ) {
192
+            return $this->website( $name );
193
+        } elseif ( 'string' === $type ) {
194
+            return $this->text( $name );
195
+        } elseif ( 'double' === $type ) {
196
+            return $this->number( $name, 2 );
197
+        } elseif ( 'date' === $type ) {
198
+            return $this->datetime( $name );
199
+        } elseif ( 'multiline' === $type ) {
200
+            return $this->multiline( $name );
201
+        } else {
202
+            return $this->text( $name );
203
+        }
204
+    }
205
+
206
+    protected function datetime( $name ) {
207
+        return array(
208
+            'description'             => '',
209
+            'weight'                  => 2,
210
+            'type'                    => 'datetime',
211
+            'sister_id'               => '-- Select One --',
212
+            'rest_route'              => '/pods/v1/fields',
213
+            'required'                => '0',
214
+            'repeatable'              => '0',
215
+            'datetime_type'           => 'format',
216
+            'datetime_format'         => 'ymd_slash',
217
+            'datetime_time_type'      => '24',
218
+            'datetime_time_format'    => 'h_mma',
219
+            'datetime_time_format_24' => 'hh_mm',
220
+            'datetime_allow_empty'    => '1',
221
+            'datetime_html5'          => '0',
222
+            'roles_allowed'           => 'administrator',
223
+            'rest_pick_response'      => 'array',
224
+            'rest_pick_depth'         => '1',
225
+        );
226
+    }
227
+
228
+
229
+    protected function number( $name, $decimals = 0 ) {
230
+        return array(
231
+            'description'        => '',
232
+            'weight'             => 1,
233
+            'type'               => 'number',
234
+            'sister_id'          => '-- Select One --',
235
+            'rest_route'         => '/pods/v1/fields',
236
+            'required'           => '0',
237
+            'repeatable'         => '0',
238
+            'number_format_type' => 'number',
239
+            'number_format'      => 'i18n',
240
+            'number_decimals'    => $decimals,
241
+            'number_format_soft' => '0',
242
+            'number_step'        => '2',
243
+            'number_max_length'  => '0',
244
+            'number_html5'       => '0',
245
+            'roles_allowed'      => 'administrator',
246
+            'rest_pick_response' => 'array',
247
+            'rest_pick_depth'    => '1',
248
+        );
249
+    }
250
+
251
+
252
+    protected function multiline( $name ) {
253
+        return array(
254
+            'description'                 => '',
255
+            'weight'                      => 3,
256
+            'type'                        => 'paragraph',
257
+            'sister_id'                   => '-- Select One --',
258
+            'rest_route'                  => '/pods/v1/fields',
259
+            'required'                    => '0',
260
+            'repeatable'                  => '0',
261
+            'paragraph_allowed_html_tags' => 'strong em a ul ol li b i',
262
+            'paragraph_max_length'        => '-1',
263
+            'roles_allowed'               => 'administrator',
264
+            'rest_pick_response'          => 'array',
265
+            'rest_pick_depth'             => '1',
266
+        );
267
+    }
268
+
269
+    protected function may_be_repeatable( $custom_field, $field ) {
270
+        $repeatable = isset( $custom_field['constraints']['cardinality'] ) && INF === $custom_field['constraints']['cardinality'];
271
+        if ( $repeatable ) {
272
+            return $this->repeatable( $field );
273
+        }
274
+
275
+        return $field;
276
+    }
277
+
278
+
279
+    /**
280
+     * @return array
281
+     * A function which defines these pods on the edit post screen.
282
+     */
283
+
284
+    protected function custom_field_to_pod_field( $custom_field ) {
285
+
286
+        $name = str_replace( 'http://schema.org/', '', $custom_field['predicate'] );
287
+        $type = isset( $custom_field['type'] ) ? $custom_field['type'] : 'string';
288
+
289
+        return $this->may_be_repeatable( $custom_field, $this->get_field_by_type( $name, $type, $custom_field ) );
290
+    }
291
+
292
+    protected function wordlift_css_class( $field ) {
293
+        $field['class'] = 'wordlift';
294
+
295
+        return $field;
296
+    }
297
+
298
+
299
+    protected function custom_fields_to_pod_fields( $custom_fields, $pod_id ) {
300
+
301
+        $pod_fields = array();
302
+
303
+        foreach ( $custom_fields as $name => $custom_field ) {
304
+            $pod_fields[] =  $this->wordlift_css_class( $this->custom_field_to_pod_field( $custom_field ) ) + array(
305
+                    'pod_id' => $pod_id,
306
+                    'id'     => intval( substr( md5( $pod_id . '_' . $name ), 0, 8 ), 16 ),
307
+                    'name'   => $name,
308
+                    'label'  => $this->format_label( str_replace( 'http://schema.org/', '', $custom_field['predicate'] ) ),
309
+                );
310
+        }
311
+
312
+
313
+        return array_values( $pod_fields );
314
+    }
315
+
316
+    protected function format_label( $name ) {
317
+        return join( ' ', array_map( 'ucwords', preg_split( '/(?=[A-Z])/', $name ) ) );
318
+    }
319 319
 
320 320
 
321 321
 
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 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
 
@@ -28,19 +28,19 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @return int
30 30
 	 */
31
-	protected function register_pod( $name, $type, $context ) {
32
-		$pod_id              = intval( substr( md5( $type . '_' . $name ), 0, 8 ), 16 );
33
-		$pod                 = $this->pod( $pod_id, $name, $type );
31
+	protected function register_pod($name, $type, $context) {
32
+		$pod_id              = intval(substr(md5($type.'_'.$name), 0, 8), 16);
33
+		$pod                 = $this->pod($pod_id, $name, $type);
34 34
 		$schema_field_groups = $context->get_custom_fields();
35 35
 
36
-		foreach ( $schema_field_groups as $schema_field_group ) {
36
+		foreach ($schema_field_groups as $schema_field_group) {
37 37
 			$custom_fields = $schema_field_group->get_custom_fields();
38
-			if ( is_array( $custom_fields ) && count( $custom_fields ) > 0 ) {
38
+			if (is_array($custom_fields) && count($custom_fields) > 0) {
39 39
 				$this->group(
40 40
 					$schema_field_group->get_schema_type(),
41 41
 					$pod,
42 42
 					$this->group_fields(
43
-						...$this->custom_fields_to_pod_fields( $custom_fields, $pod_id )
43
+						...$this->custom_fields_to_pod_fields($custom_fields, $pod_id)
44 44
 					)
45 45
 				);
46 46
 			}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 	}
52 52
 
53
-	protected function text( $name ) {
53
+	protected function text($name) {
54 54
 		return array(
55 55
 			'description'            => '',
56 56
 			'weight'                 => 0,
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 		);
67 67
 	}
68 68
 
69
-	protected function relationship( $name, $field_data ) {
69
+	protected function relationship($name, $field_data) {
70 70
 
71 71
 		$supported_schema_types = $field_data['constraints']['uri_type'];
72 72
 
73
-		if ( ! is_array( $supported_schema_types ) ) {
74
-			$supported_schema_types = array( $supported_schema_types );
73
+		if ( ! is_array($supported_schema_types)) {
74
+			$supported_schema_types = array($supported_schema_types);
75 75
 		}
76 76
 
77 77
 		return array(
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 
108 108
 
109
-	protected function repeatable( $field, $repeatable_label = 'Add New' ) {
109
+	protected function repeatable($field, $repeatable_label = 'Add New') {
110 110
 		$field['repeatable']               = 1;
111 111
 		$field['repeatable_add_new_label'] = $repeatable_label;
112 112
 
113 113
 		return $field;
114 114
 	}
115 115
 
116
-	protected function website( $name ) {
116
+	protected function website($name) {
117 117
 		return array(
118 118
 			'description'        => '',
119 119
 			'weight'             => 0,
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
 	}
137 137
 
138 138
 
139
-	protected function group_fields( ...$fields ) {
139
+	protected function group_fields(...$fields) {
140 140
 		$result = array();
141 141
 		array_map(
142
-			function ( $item ) use ( &$result ) {
142
+			function($item) use (&$result) {
143 143
 				$field_name            = $item['name'];
144
-				$result[ $field_name ] = $item;
144
+				$result[$field_name] = $item;
145 145
 			},
146 146
 			$fields
147 147
 		);
@@ -149,21 +149,21 @@  discard block
 block discarded – undo
149 149
 		return $result;
150 150
 	}
151 151
 
152
-	protected function group( $name, $pod, $group_fields ) {
152
+	protected function group($name, $pod, $group_fields) {
153 153
 		$group = array(
154 154
 			'name'        => $name,
155
-			'label'       => sprintf( 'WordLift - %s', $this->format_label( $name ) ),
155
+			'label'       => sprintf('WordLift - %s', $this->format_label($name)),
156 156
 			'description' => '',
157 157
 			'weight'      => 0,
158 158
 
159 159
 		);
160
-		pods_register_group( $group, $pod['name'], $group_fields );
160
+		pods_register_group($group, $pod['name'], $group_fields);
161 161
 	}
162 162
 
163
-	protected function pod( $pod_id, $name, $type ) {
163
+	protected function pod($pod_id, $name, $type) {
164 164
 		$pod = array(
165 165
 			'name'        => $name,
166
-			'label'       => $this->format_label( $name ),
166
+			'label'       => $this->format_label($name),
167 167
 			'description' => '',
168 168
 			'type'        => $type,
169 169
 			'storage'     => 'meta',
@@ -171,39 +171,39 @@  discard block
 block discarded – undo
171 171
 			'object'      => $name,
172 172
 		);
173 173
 
174
-		pods_register_type( $pod['type'], $pod['name'], $pod );
174
+		pods_register_type($pod['type'], $pod['name'], $pod);
175 175
 
176 176
 		return $pod;
177 177
 	}
178 178
 
179 179
 	protected function register_on_all_supported_taxonomies() {
180 180
 		$taxonomies = Terms_Compat::get_public_taxonomies();
181
-		foreach ( $taxonomies as $taxonomy ) {
182
-			$this->register_pod( $taxonomy, 'taxonomy' );
181
+		foreach ($taxonomies as $taxonomy) {
182
+			$this->register_pod($taxonomy, 'taxonomy');
183 183
 
184 184
 		}
185 185
 	}
186 186
 
187 187
 
188
-	protected function get_field_by_type( $name, $type, $field_data ) {
189
-		if ( 'uri' === $type && isset( $field_data['constraints']['uri_type'] ) ) {
190
-			return $this->relationship( $name, $field_data );
191
-		} elseif ( 'uri' === $type ) {
192
-			return $this->website( $name );
193
-		} elseif ( 'string' === $type ) {
194
-			return $this->text( $name );
195
-		} elseif ( 'double' === $type ) {
196
-			return $this->number( $name, 2 );
197
-		} elseif ( 'date' === $type ) {
198
-			return $this->datetime( $name );
199
-		} elseif ( 'multiline' === $type ) {
200
-			return $this->multiline( $name );
188
+	protected function get_field_by_type($name, $type, $field_data) {
189
+		if ('uri' === $type && isset($field_data['constraints']['uri_type'])) {
190
+			return $this->relationship($name, $field_data);
191
+		} elseif ('uri' === $type) {
192
+			return $this->website($name);
193
+		} elseif ('string' === $type) {
194
+			return $this->text($name);
195
+		} elseif ('double' === $type) {
196
+			return $this->number($name, 2);
197
+		} elseif ('date' === $type) {
198
+			return $this->datetime($name);
199
+		} elseif ('multiline' === $type) {
200
+			return $this->multiline($name);
201 201
 		} else {
202
-			return $this->text( $name );
202
+			return $this->text($name);
203 203
 		}
204 204
 	}
205 205
 
206
-	protected function datetime( $name ) {
206
+	protected function datetime($name) {
207 207
 		return array(
208 208
 			'description'             => '',
209 209
 			'weight'                  => 2,
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	}
227 227
 
228 228
 
229
-	protected function number( $name, $decimals = 0 ) {
229
+	protected function number($name, $decimals = 0) {
230 230
 		return array(
231 231
 			'description'        => '',
232 232
 			'weight'             => 1,
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	}
250 250
 
251 251
 
252
-	protected function multiline( $name ) {
252
+	protected function multiline($name) {
253 253
 		return array(
254 254
 			'description'                 => '',
255 255
 			'weight'                      => 3,
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 		);
267 267
 	}
268 268
 
269
-	protected function may_be_repeatable( $custom_field, $field ) {
270
-		$repeatable = isset( $custom_field['constraints']['cardinality'] ) && INF === $custom_field['constraints']['cardinality'];
271
-		if ( $repeatable ) {
272
-			return $this->repeatable( $field );
269
+	protected function may_be_repeatable($custom_field, $field) {
270
+		$repeatable = isset($custom_field['constraints']['cardinality']) && INF === $custom_field['constraints']['cardinality'];
271
+		if ($repeatable) {
272
+			return $this->repeatable($field);
273 273
 		}
274 274
 
275 275
 		return $field;
@@ -281,40 +281,40 @@  discard block
 block discarded – undo
281 281
 	 * A function which defines these pods on the edit post screen.
282 282
 	 */
283 283
 
284
-	protected function custom_field_to_pod_field( $custom_field ) {
284
+	protected function custom_field_to_pod_field($custom_field) {
285 285
 
286
-		$name = str_replace( 'http://schema.org/', '', $custom_field['predicate'] );
287
-		$type = isset( $custom_field['type'] ) ? $custom_field['type'] : 'string';
286
+		$name = str_replace('http://schema.org/', '', $custom_field['predicate']);
287
+		$type = isset($custom_field['type']) ? $custom_field['type'] : 'string';
288 288
 
289
-		return $this->may_be_repeatable( $custom_field, $this->get_field_by_type( $name, $type, $custom_field ) );
289
+		return $this->may_be_repeatable($custom_field, $this->get_field_by_type($name, $type, $custom_field));
290 290
 	}
291 291
 
292
-	protected function wordlift_css_class( $field ) {
292
+	protected function wordlift_css_class($field) {
293 293
 		$field['class'] = 'wordlift';
294 294
 
295 295
 		return $field;
296 296
 	}
297 297
 
298 298
 
299
-	protected function custom_fields_to_pod_fields( $custom_fields, $pod_id ) {
299
+	protected function custom_fields_to_pod_fields($custom_fields, $pod_id) {
300 300
 
301 301
 		$pod_fields = array();
302 302
 
303
-		foreach ( $custom_fields as $name => $custom_field ) {
304
-			$pod_fields[] =  $this->wordlift_css_class( $this->custom_field_to_pod_field( $custom_field ) ) + array(
303
+		foreach ($custom_fields as $name => $custom_field) {
304
+			$pod_fields[] = $this->wordlift_css_class($this->custom_field_to_pod_field($custom_field)) + array(
305 305
 					'pod_id' => $pod_id,
306
-					'id'     => intval( substr( md5( $pod_id . '_' . $name ), 0, 8 ), 16 ),
306
+					'id'     => intval(substr(md5($pod_id.'_'.$name), 0, 8), 16),
307 307
 					'name'   => $name,
308
-					'label'  => $this->format_label( str_replace( 'http://schema.org/', '', $custom_field['predicate'] ) ),
308
+					'label'  => $this->format_label(str_replace('http://schema.org/', '', $custom_field['predicate'])),
309 309
 				);
310 310
 		}
311 311
 
312 312
 
313
-		return array_values( $pod_fields );
313
+		return array_values($pod_fields);
314 314
 	}
315 315
 
316
-	protected function format_label( $name ) {
317
-		return join( ' ', array_map( 'ucwords', preg_split( '/(?=[A-Z])/', $name ) ) );
316
+	protected function format_label($name) {
317
+		return join(' ', array_map('ucwords', preg_split('/(?=[A-Z])/', $name)));
318 318
 	}
319 319
 
320 320
 
Please login to merge, or discard this patch.
src/modules/pods/includes/FieldDefinition/AllPodsDefiniton.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -11,29 +11,29 @@
 block discarded – undo
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
-		$context = $this->schema->get();
23
-		$taxonomies = Terms_Compat::get_public_taxonomies();
24
-		foreach ( $taxonomies as $taxonomy ) {
25
-			$this->register_pod( $taxonomy, 'taxonomy', $context );
21
+    public function register_on_all_supported_taxonomies() {
22
+        $context = $this->schema->get();
23
+        $taxonomies = Terms_Compat::get_public_taxonomies();
24
+        foreach ( $taxonomies as $taxonomy ) {
25
+            $this->register_pod( $taxonomy, 'taxonomy', $context );
26 26
 
27
-		}
28
-	}
27
+        }
28
+    }
29 29
 
30
-	public function register_on_all_valid_post_types() {
31
-		$context = $this->schema->get();
32
-		$supported_types = \Wordlift_Entity_Service::valid_entity_post_types();
33
-		foreach ( $supported_types as $supported_type ) {
34
-			$this->register_pod( $supported_type, 'post_type', $context );
35
-		}
36
-	}
30
+    public function register_on_all_valid_post_types() {
31
+        $context = $this->schema->get();
32
+        $supported_types = \Wordlift_Entity_Service::valid_entity_post_types();
33
+        foreach ( $supported_types as $supported_type ) {
34
+            $this->register_pod( $supported_type, 'post_type', $context );
35
+        }
36
+    }
37 37
 
38 38
 
39 39
 }
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@  discard block
 block discarded – undo
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
 		$context = $this->schema->get();
23 23
 		$taxonomies = Terms_Compat::get_public_taxonomies();
24
-		foreach ( $taxonomies as $taxonomy ) {
25
-			$this->register_pod( $taxonomy, 'taxonomy', $context );
24
+		foreach ($taxonomies as $taxonomy) {
25
+			$this->register_pod($taxonomy, 'taxonomy', $context);
26 26
 
27 27
 		}
28 28
 	}
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	public function register_on_all_valid_post_types() {
31 31
 		$context = $this->schema->get();
32 32
 		$supported_types = \Wordlift_Entity_Service::valid_entity_post_types();
33
-		foreach ( $supported_types as $supported_type ) {
34
-			$this->register_pod( $supported_type, 'post_type', $context );
33
+		foreach ($supported_types as $supported_type) {
34
+			$this->register_pod($supported_type, 'post_type', $context);
35 35
 		}
36 36
 	}
37 37
 
Please login to merge, or discard this patch.