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