Completed
Push — develop ( f5cfcc...e2baaf )
by Naveen
01:17
created
src/includes/schemaorg/class-wordlift-schemaorg-class-service.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -18,113 +18,113 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Schemaorg_Class_Service {
20 20
 
21
-	/**
22
-	 * The term meta key holding the CamelCase name for the term. The term has also a WP_Term->name
23
-	 * property which however is to be considered a customizable label (especially for languages other
24
-	 * than English).
25
-	 *
26
-	 * @since 3.20.0
27
-	 */
28
-	const NAME_META_KEY = '_wl_name';
29
-
30
-	/**
31
-	 * The term meta key holding the term URI.
32
-	 *
33
-	 * @since 3.20.0
34
-	 */
35
-	const URI_META_KEY = '_wl_uri';
36
-
37
-	/**
38
-	 * The term meta key holding the list of children terms ids.
39
-	 *
40
-	 * @since 3.20.0
41
-	 */
42
-	const PARENT_OF_META_KEY = '_wl_parent_of';
43
-
44
-	/**
45
-	 * The singleton instance.
46
-	 *
47
-	 * @since 3.20.0
48
-	 * @access private
49
-	 * @var \Wordlift_Schemaorg_Class_Service $instance The singleton instance.
50
-	 */
51
-	private static $instance;
52
-
53
-	/**
54
-	 * Create a {@link Wordlift_Schema_Class} instance.
55
-	 *
56
-	 * @since 3.20.0
57
-	 */
58
-	public function __construct() {
59
-
60
-		add_action( 'wp_ajax_wl_schemaorg_class', array( $this, 'schemaorg_class' ) );
61
-
62
-		self::$instance = $this;
63
-
64
-	}
65
-
66
-	/**
67
-	 * Get the singleton instance.
68
-	 *
69
-	 * @since 3.20.0
70
-	 * @return \Wordlift_Schemaorg_Class_Service The singleton instance.
71
-	 */
72
-	public static function get_instance() {
73
-
74
-		return self::$instance;
75
-	}
76
-
77
-	/**
78
-	 * The end-point to output the list of terms from the `wl_entity_taxonomy`.
79
-	 *
80
-	 * Example output:
81
-	 * ```
82
-	 * {
83
-	 *  "name": "AMRadioChannel",
84
-	 *  "dashname": "am-radio-channel",
85
-	 *  "description": "A radio channel that uses AM.",
86
-	 *  "children": []
87
-	 * }
88
-	 * ```
89
-	 *
90
-	 * @since 3.20.0
91
-	 */
92
-	public function schemaorg_class() {
93
-
94
-		// Since we want to be compatible with WP 4.4, we use the pre-4.5.0 style when
95
-		// calling `get_terms`.
96
-		$terms = get_terms( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'get' => 'all', ) );
97
-
98
-		// PHP 5.3 compat.
99
-		$name_meta_key      = Wordlift_Schemaorg_Class_Service::NAME_META_KEY;
100
-		$parent_of_meta_key = Wordlift_Schemaorg_Class_Service::PARENT_OF_META_KEY;
101
-
102
-		$json = array_map(
103
-			function ( $term ) use ( $name_meta_key, $parent_of_meta_key ) {
104
-				// Do not change the following, the `name` is used to reference the correct
105
-				// Schema.org class (CamelCase name). Do not use WP_Term->name.
106
-				$camel_case_name = get_term_meta( $term->term_id, $name_meta_key, true );
107
-
108
-				return array(
109
-					'id'          => $term->term_id,
110
-					// Do not change the following, the `name` is used to reference the correct
111
-					// Schema.org class (CamelCase name). Do not use WP_Term->name.
112
-					'name'        => $camel_case_name,
113
-					'dashname'    => $term->slug,
114
-					'description' => $term->description,
115
-					'children'    => array_map( function ( $child ) {
116
-						// Map the slug to the term id.
117
-						$child_term = get_term_by( 'slug', $child, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
118
-
119
-						return array( 'id' => $child_term->term_id );
120
-					}, get_term_meta( $term->term_id, $parent_of_meta_key ) ),
121
-				);
122
-
123
-			}, $terms );
124
-
125
-		// Finally send the data.
126
-		wp_send_json_success( array( 'schemaClasses' => $json ) );
127
-
128
-	}
21
+    /**
22
+     * The term meta key holding the CamelCase name for the term. The term has also a WP_Term->name
23
+     * property which however is to be considered a customizable label (especially for languages other
24
+     * than English).
25
+     *
26
+     * @since 3.20.0
27
+     */
28
+    const NAME_META_KEY = '_wl_name';
29
+
30
+    /**
31
+     * The term meta key holding the term URI.
32
+     *
33
+     * @since 3.20.0
34
+     */
35
+    const URI_META_KEY = '_wl_uri';
36
+
37
+    /**
38
+     * The term meta key holding the list of children terms ids.
39
+     *
40
+     * @since 3.20.0
41
+     */
42
+    const PARENT_OF_META_KEY = '_wl_parent_of';
43
+
44
+    /**
45
+     * The singleton instance.
46
+     *
47
+     * @since 3.20.0
48
+     * @access private
49
+     * @var \Wordlift_Schemaorg_Class_Service $instance The singleton instance.
50
+     */
51
+    private static $instance;
52
+
53
+    /**
54
+     * Create a {@link Wordlift_Schema_Class} instance.
55
+     *
56
+     * @since 3.20.0
57
+     */
58
+    public function __construct() {
59
+
60
+        add_action( 'wp_ajax_wl_schemaorg_class', array( $this, 'schemaorg_class' ) );
61
+
62
+        self::$instance = $this;
63
+
64
+    }
65
+
66
+    /**
67
+     * Get the singleton instance.
68
+     *
69
+     * @since 3.20.0
70
+     * @return \Wordlift_Schemaorg_Class_Service The singleton instance.
71
+     */
72
+    public static function get_instance() {
73
+
74
+        return self::$instance;
75
+    }
76
+
77
+    /**
78
+     * The end-point to output the list of terms from the `wl_entity_taxonomy`.
79
+     *
80
+     * Example output:
81
+     * ```
82
+     * {
83
+     *  "name": "AMRadioChannel",
84
+     *  "dashname": "am-radio-channel",
85
+     *  "description": "A radio channel that uses AM.",
86
+     *  "children": []
87
+     * }
88
+     * ```
89
+     *
90
+     * @since 3.20.0
91
+     */
92
+    public function schemaorg_class() {
93
+
94
+        // Since we want to be compatible with WP 4.4, we use the pre-4.5.0 style when
95
+        // calling `get_terms`.
96
+        $terms = get_terms( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'get' => 'all', ) );
97
+
98
+        // PHP 5.3 compat.
99
+        $name_meta_key      = Wordlift_Schemaorg_Class_Service::NAME_META_KEY;
100
+        $parent_of_meta_key = Wordlift_Schemaorg_Class_Service::PARENT_OF_META_KEY;
101
+
102
+        $json = array_map(
103
+            function ( $term ) use ( $name_meta_key, $parent_of_meta_key ) {
104
+                // Do not change the following, the `name` is used to reference the correct
105
+                // Schema.org class (CamelCase name). Do not use WP_Term->name.
106
+                $camel_case_name = get_term_meta( $term->term_id, $name_meta_key, true );
107
+
108
+                return array(
109
+                    'id'          => $term->term_id,
110
+                    // Do not change the following, the `name` is used to reference the correct
111
+                    // Schema.org class (CamelCase name). Do not use WP_Term->name.
112
+                    'name'        => $camel_case_name,
113
+                    'dashname'    => $term->slug,
114
+                    'description' => $term->description,
115
+                    'children'    => array_map( function ( $child ) {
116
+                        // Map the slug to the term id.
117
+                        $child_term = get_term_by( 'slug', $child, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
118
+
119
+                        return array( 'id' => $child_term->term_id );
120
+                    }, get_term_meta( $term->term_id, $parent_of_meta_key ) ),
121
+                );
122
+
123
+            }, $terms );
124
+
125
+        // Finally send the data.
126
+        wp_send_json_success( array( 'schemaClasses' => $json ) );
127
+
128
+    }
129 129
 
130 130
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function __construct() {
59 59
 
60
-		add_action( 'wp_ajax_wl_schemaorg_class', array( $this, 'schemaorg_class' ) );
60
+		add_action('wp_ajax_wl_schemaorg_class', array($this, 'schemaorg_class'));
61 61
 
62 62
 		self::$instance = $this;
63 63
 
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 
94 94
 		// Since we want to be compatible with WP 4.4, we use the pre-4.5.0 style when
95 95
 		// calling `get_terms`.
96
-		$terms = get_terms( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'get' => 'all', ) );
96
+		$terms = get_terms(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array('get' => 'all',));
97 97
 
98 98
 		// PHP 5.3 compat.
99 99
 		$name_meta_key      = Wordlift_Schemaorg_Class_Service::NAME_META_KEY;
100 100
 		$parent_of_meta_key = Wordlift_Schemaorg_Class_Service::PARENT_OF_META_KEY;
101 101
 
102 102
 		$json = array_map(
103
-			function ( $term ) use ( $name_meta_key, $parent_of_meta_key ) {
103
+			function($term) use ($name_meta_key, $parent_of_meta_key) {
104 104
 				// Do not change the following, the `name` is used to reference the correct
105 105
 				// Schema.org class (CamelCase name). Do not use WP_Term->name.
106
-				$camel_case_name = get_term_meta( $term->term_id, $name_meta_key, true );
106
+				$camel_case_name = get_term_meta($term->term_id, $name_meta_key, true);
107 107
 
108 108
 				return array(
109 109
 					'id'          => $term->term_id,
@@ -112,18 +112,18 @@  discard block
 block discarded – undo
112 112
 					'name'        => $camel_case_name,
113 113
 					'dashname'    => $term->slug,
114 114
 					'description' => $term->description,
115
-					'children'    => array_map( function ( $child ) {
115
+					'children'    => array_map(function($child) {
116 116
 						// Map the slug to the term id.
117
-						$child_term = get_term_by( 'slug', $child, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
117
+						$child_term = get_term_by('slug', $child, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
118 118
 
119
-						return array( 'id' => $child_term->term_id );
120
-					}, get_term_meta( $term->term_id, $parent_of_meta_key ) ),
119
+						return array('id' => $child_term->term_id);
120
+					}, get_term_meta($term->term_id, $parent_of_meta_key)),
121 121
 				);
122 122
 
123 123
 			}, $terms );
124 124
 
125 125
 		// Finally send the data.
126
-		wp_send_json_success( array( 'schemaClasses' => $json ) );
126
+		wp_send_json_success(array('schemaClasses' => $json));
127 127
 
128 128
 	}
129 129
 
Please login to merge, or discard this patch.
src/includes/schemaorg/class-wordlift-schemaorg-property-service.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -16,113 +16,113 @@
 block discarded – undo
16 16
  */
17 17
 class Wordlift_Schemaorg_Property_Service {
18 18
 
19
-	/**
20
-	 * The meta key prefix used to store properties. The `_` prefix makes these metas invisible in the
21
-	 * edit screen custom fields metabox.
22
-	 *
23
-	 * @since 3.20.0
24
-	 */
25
-	const PREFIX = "_wl_prop_";
26
-
27
-	/**
28
-	 * The singleton instance.
29
-	 *
30
-	 * @since 3.20.0
31
-	 * @access private
32
-	 * @var \Wordlift_Schemaorg_Property_Service $instance The singleton instance.
33
-	 */
34
-	private static $instance;
35
-
36
-	/**
37
-	 * Create a {@link Wordlift_Schemaorg_Property_Service} instance.
38
-	 *
39
-	 * @since 3.20.0
40
-	 */
41
-	public function __construct() {
42
-
43
-		self::$instance = $this;
44
-
45
-	}
46
-
47
-	/**
48
-	 * Get the singleton instance.
49
-	 *
50
-	 * @since 3.20.0
51
-	 *
52
-	 * @return \Wordlift_Schemaorg_Property_Service The singleton instance.
53
-	 */
54
-	public static function get_instance() {
55
-
56
-		return self::$instance;
57
-	}
58
-
59
-	/**
60
-	 * Get all the properties bound to the specified post.
61
-	 *
62
-	 * @since 3.20.0
63
-	 *
64
-	 * @param int $post_id The post id.
65
-	 *
66
-	 * @return array An array of properties instances keyed by the property name. Each property contains a
67
-	 *  `type` and a `value` and optionally a `language`.
68
-	 * }
69
-	 */
70
-	public function get_all( $post_id ) {
71
-
72
-		// Get all the post metas.
73
-		$post_metas = get_post_meta( $post_id );
74
-
75
-		// Cycle through them to get the Schema.org properties.
76
-		$props = array();
77
-		foreach ( $post_metas as $key => $values ) {
78
-			$matches = array();
79
-
80
-			// We're looking for `_wl_prop_propName_uuid_key`.
81
-			if ( 1 === preg_match( '/' . self::PREFIX . '(\w+)_([\w-]+)_(\w+)/i', $key, $matches ) ) {
82
-				$name = $matches[1];
83
-				$uuid = $matches[2];
84
-				$key  = $matches[3];
85
-
86
-				// Record the value.
87
-				$props[ $name ][ $uuid ][ $key ] = $values[0];
88
-			}
89
-		}
90
-
91
-		// Remove the UUIDs.
92
-		foreach ( $props as $name => $instance ) {
93
-			foreach ( $instance as $uuid => $keys ) {
94
-				// This way we remove the `uuid`s.
95
-				$props[ $name ] = array_values( $instance );
96
-			}
97
-		}
98
-
99
-		// Finally return the props.
100
-		return $props;
101
-	}
102
-
103
-	/**
104
-	 * Get the meta keys for Schema.org properties associated with the specified post.
105
-	 *
106
-	 * @since 3.20.0
107
-	 *
108
-	 * @param int $post_id The post id.
109
-	 *
110
-	 * @return array An array of meta keys.
111
-	 */
112
-	public function get_keys( $post_id ) {
113
-
114
-		// Get all the post metas to remove the `_wl_prop` ones.
115
-		$post_meta = get_post_meta( $post_id );
116
-
117
-		// Get the keys.
118
-		$post_meta_keys = array_unique( array_keys( $post_meta ) );
119
-
120
-		// Get only the `_wl_prop` keys. `array_values` resets the indexes.
121
-		$prop_keys = array_values( array_filter( $post_meta_keys, function ( $item ) {
122
-			return 0 === strpos( $item, Wordlift_Schemaorg_Property_Service::PREFIX );
123
-		} ) );
124
-
125
-		return $prop_keys;
126
-	}
19
+    /**
20
+     * The meta key prefix used to store properties. The `_` prefix makes these metas invisible in the
21
+     * edit screen custom fields metabox.
22
+     *
23
+     * @since 3.20.0
24
+     */
25
+    const PREFIX = "_wl_prop_";
26
+
27
+    /**
28
+     * The singleton instance.
29
+     *
30
+     * @since 3.20.0
31
+     * @access private
32
+     * @var \Wordlift_Schemaorg_Property_Service $instance The singleton instance.
33
+     */
34
+    private static $instance;
35
+
36
+    /**
37
+     * Create a {@link Wordlift_Schemaorg_Property_Service} instance.
38
+     *
39
+     * @since 3.20.0
40
+     */
41
+    public function __construct() {
42
+
43
+        self::$instance = $this;
44
+
45
+    }
46
+
47
+    /**
48
+     * Get the singleton instance.
49
+     *
50
+     * @since 3.20.0
51
+     *
52
+     * @return \Wordlift_Schemaorg_Property_Service The singleton instance.
53
+     */
54
+    public static function get_instance() {
55
+
56
+        return self::$instance;
57
+    }
58
+
59
+    /**
60
+     * Get all the properties bound to the specified post.
61
+     *
62
+     * @since 3.20.0
63
+     *
64
+     * @param int $post_id The post id.
65
+     *
66
+     * @return array An array of properties instances keyed by the property name. Each property contains a
67
+     *  `type` and a `value` and optionally a `language`.
68
+     * }
69
+     */
70
+    public function get_all( $post_id ) {
71
+
72
+        // Get all the post metas.
73
+        $post_metas = get_post_meta( $post_id );
74
+
75
+        // Cycle through them to get the Schema.org properties.
76
+        $props = array();
77
+        foreach ( $post_metas as $key => $values ) {
78
+            $matches = array();
79
+
80
+            // We're looking for `_wl_prop_propName_uuid_key`.
81
+            if ( 1 === preg_match( '/' . self::PREFIX . '(\w+)_([\w-]+)_(\w+)/i', $key, $matches ) ) {
82
+                $name = $matches[1];
83
+                $uuid = $matches[2];
84
+                $key  = $matches[3];
85
+
86
+                // Record the value.
87
+                $props[ $name ][ $uuid ][ $key ] = $values[0];
88
+            }
89
+        }
90
+
91
+        // Remove the UUIDs.
92
+        foreach ( $props as $name => $instance ) {
93
+            foreach ( $instance as $uuid => $keys ) {
94
+                // This way we remove the `uuid`s.
95
+                $props[ $name ] = array_values( $instance );
96
+            }
97
+        }
98
+
99
+        // Finally return the props.
100
+        return $props;
101
+    }
102
+
103
+    /**
104
+     * Get the meta keys for Schema.org properties associated with the specified post.
105
+     *
106
+     * @since 3.20.0
107
+     *
108
+     * @param int $post_id The post id.
109
+     *
110
+     * @return array An array of meta keys.
111
+     */
112
+    public function get_keys( $post_id ) {
113
+
114
+        // Get all the post metas to remove the `_wl_prop` ones.
115
+        $post_meta = get_post_meta( $post_id );
116
+
117
+        // Get the keys.
118
+        $post_meta_keys = array_unique( array_keys( $post_meta ) );
119
+
120
+        // Get only the `_wl_prop` keys. `array_values` resets the indexes.
121
+        $prop_keys = array_values( array_filter( $post_meta_keys, function ( $item ) {
122
+            return 0 === strpos( $item, Wordlift_Schemaorg_Property_Service::PREFIX );
123
+        } ) );
124
+
125
+        return $prop_keys;
126
+    }
127 127
 
128 128
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -67,32 +67,32 @@  discard block
 block discarded – undo
67 67
 	 *  `type` and a `value` and optionally a `language`.
68 68
 	 * }
69 69
 	 */
70
-	public function get_all( $post_id ) {
70
+	public function get_all($post_id) {
71 71
 
72 72
 		// Get all the post metas.
73
-		$post_metas = get_post_meta( $post_id );
73
+		$post_metas = get_post_meta($post_id);
74 74
 
75 75
 		// Cycle through them to get the Schema.org properties.
76 76
 		$props = array();
77
-		foreach ( $post_metas as $key => $values ) {
77
+		foreach ($post_metas as $key => $values) {
78 78
 			$matches = array();
79 79
 
80 80
 			// We're looking for `_wl_prop_propName_uuid_key`.
81
-			if ( 1 === preg_match( '/' . self::PREFIX . '(\w+)_([\w-]+)_(\w+)/i', $key, $matches ) ) {
81
+			if (1 === preg_match('/'.self::PREFIX.'(\w+)_([\w-]+)_(\w+)/i', $key, $matches)) {
82 82
 				$name = $matches[1];
83 83
 				$uuid = $matches[2];
84 84
 				$key  = $matches[3];
85 85
 
86 86
 				// Record the value.
87
-				$props[ $name ][ $uuid ][ $key ] = $values[0];
87
+				$props[$name][$uuid][$key] = $values[0];
88 88
 			}
89 89
 		}
90 90
 
91 91
 		// Remove the UUIDs.
92
-		foreach ( $props as $name => $instance ) {
93
-			foreach ( $instance as $uuid => $keys ) {
92
+		foreach ($props as $name => $instance) {
93
+			foreach ($instance as $uuid => $keys) {
94 94
 				// This way we remove the `uuid`s.
95
-				$props[ $name ] = array_values( $instance );
95
+				$props[$name] = array_values($instance);
96 96
 			}
97 97
 		}
98 98
 
@@ -109,18 +109,18 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return array An array of meta keys.
111 111
 	 */
112
-	public function get_keys( $post_id ) {
112
+	public function get_keys($post_id) {
113 113
 
114 114
 		// Get all the post metas to remove the `_wl_prop` ones.
115
-		$post_meta = get_post_meta( $post_id );
115
+		$post_meta = get_post_meta($post_id);
116 116
 
117 117
 		// Get the keys.
118
-		$post_meta_keys = array_unique( array_keys( $post_meta ) );
118
+		$post_meta_keys = array_unique(array_keys($post_meta));
119 119
 
120 120
 		// Get only the `_wl_prop` keys. `array_values` resets the indexes.
121
-		$prop_keys = array_values( array_filter( $post_meta_keys, function ( $item ) {
122
-			return 0 === strpos( $item, Wordlift_Schemaorg_Property_Service::PREFIX );
123
-		} ) );
121
+		$prop_keys = array_values(array_filter($post_meta_keys, function($item) {
122
+			return 0 === strpos($item, Wordlift_Schemaorg_Property_Service::PREFIX);
123
+		} ));
124 124
 
125 125
 		return $prop_keys;
126 126
 	}
Please login to merge, or discard this patch.
src/install/class-wordlift-install.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -18,63 +18,63 @@
 block discarded – undo
18 18
  */
19 19
 abstract class Wordlift_Install {
20 20
 
21
-	/**
22
-	 * A {@link Wordlift_Log_Service} instance.
23
-	 *
24
-	 * @since  3.18.0
25
-	 * @access private
26
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
27
-	 */
28
-	protected $log;
21
+    /**
22
+     * A {@link Wordlift_Log_Service} instance.
23
+     *
24
+     * @since  3.18.0
25
+     * @access private
26
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
27
+     */
28
+    protected $log;
29 29
 
30
-	/**
31
-	 * The default install version. Overridden by the installation packages.
32
-	 *
33
-	 * @since 3.18.0
34
-	 * @access protected
35
-	 * @var string $version The install version.
36
-	 */
37
-	protected static $version = '0.0.0';
30
+    /**
31
+     * The default install version. Overridden by the installation packages.
32
+     *
33
+     * @since 3.18.0
34
+     * @access protected
35
+     * @var string $version The install version.
36
+     */
37
+    protected static $version = '0.0.0';
38 38
 
39
-	/**
40
-	 * Wordlift_Install_Service constructor.
41
-	 *
42
-	 * @since 3.18.0
43
-	 */
44
-	public function __construct() {
39
+    /**
40
+     * Wordlift_Install_Service constructor.
41
+     *
42
+     * @since 3.18.0
43
+     */
44
+    public function __construct() {
45 45
 
46
-		$this->log = Wordlift_Log_Service::get_logger( get_class( $this ) );
46
+        $this->log = Wordlift_Log_Service::get_logger( get_class( $this ) );
47 47
 
48
-	}
48
+    }
49 49
 
50
-	/**
51
-	 * Return the current version of the installation.
52
-	 *
53
-	 * @since 3.18.0
54
-	 */
55
-	public function get_version() {
56
-		return static::$version;
57
-	}
50
+    /**
51
+     * Return the current version of the installation.
52
+     *
53
+     * @since 3.18.0
54
+     */
55
+    public function get_version() {
56
+        return static::$version;
57
+    }
58 58
 
59
-	/**
60
-	 * Run the install procedure. This function must be implemented by superclasses.
61
-	 *
62
-	 * @since 3.18.0
63
-	 *
64
-	 * @return mixed The result.
65
-	 */
66
-	abstract public function install();
59
+    /**
60
+     * Run the install procedure. This function must be implemented by superclasses.
61
+     *
62
+     * @since 3.18.0
63
+     *
64
+     * @return mixed The result.
65
+     */
66
+    abstract public function install();
67 67
 
68
-	/**
69
-	 * A custom procedure run by the caller to determine whether the install procedure must be run.
70
-	 *
71
-	 * @since 3.20.0
72
-	 *
73
-	 * @return bool True if the procedure must run.
74
-	 */
75
-	public function must_install() {
68
+    /**
69
+     * A custom procedure run by the caller to determine whether the install procedure must be run.
70
+     *
71
+     * @since 3.20.0
72
+     *
73
+     * @return bool True if the procedure must run.
74
+     */
75
+    public function must_install() {
76 76
 
77
-		return false;
78
-	}
77
+        return false;
78
+    }
79 79
 
80 80
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
 	 */
44 44
 	public function __construct() {
45 45
 
46
-		$this->log = Wordlift_Log_Service::get_logger( get_class( $this ) );
46
+		$this->log = Wordlift_Log_Service::get_logger(get_class($this));
47 47
 
48 48
 	}
49 49
 
Please login to merge, or discard this patch.
src/install/class-wordlift-install-1-0-0.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -15,120 +15,120 @@  discard block
 block discarded – undo
15 15
  * @subpackage Wordlift/install
16 16
  */
17 17
 class Wordlift_Install_1_0_0 extends Wordlift_Install {
18
-	/**
19
-	 * @inheritdoc
20
-	 */
21
-	protected static $version = '1.0.0';
22
-
23
-	/**
24
-	 * The WordLift entity type terms.
25
-	 *
26
-	 * @since  3.18.0
27
-	 * @access private
28
-	 * @var array $terms The entity type terms.
29
-	 */
30
-	private static $terms = array(
31
-		'thing'         => array(
32
-			'label'       => 'Thing',
33
-			'description' => 'A generic thing (something that doesn\'t fit in the previous definitions.',
34
-		),
35
-		'creative-work' => array(
36
-			'label'       => 'CreativeWork',
37
-			'description' => 'A creative work (or a Music Album).',
38
-		),
39
-		'event'         => array(
40
-			'label'       => 'Event',
41
-			'description' => 'An event.',
42
-		),
43
-		'organization'  => array(
44
-			'label'       => 'Organization',
45
-			'description' => 'An organization, including a government or a newspaper.',
46
-		),
47
-		'person'        => array(
48
-			'label'       => 'Person',
49
-			'description' => 'A person (or a music artist).',
50
-		),
51
-		'place'         => array(
52
-			'label'       => 'Place',
53
-			'description' => 'A place.',
54
-		),
55
-		'localbusiness' => array(
56
-			'label'       => 'LocalBusiness',
57
-			'description' => 'A local business.',
58
-		),
59
-	);
60
-
61
-	/**
62
-	 * @inheritdoc
63
-	 */
64
-	public function install() {
65
-		// Set the dataset uri.
66
-		$this->set_dataset_uri();
67
-
68
-		// Create entity type terms.
69
-		$this->create_entity_type_terms();
70
-
71
-		// Create relations table.
72
-		$this->create_relation_instance_table();
73
-	}
74
-
75
-	/**
76
-	 * Create required entity type terms
77
-	 *
78
-	 * @since 3.18.0
79
-	 *
80
-	 * @return void
81
-	 */
82
-	private function create_entity_type_terms() {
83
-		$this->log->debug( 'Installing Entity Type data...' );
84
-
85
-		// Set the taxonomy data.
86
-		// Note: parent types must be defined before child types.
87
-		foreach ( self::$terms as $slug => $term ) {
88
-
89
-			// Check whether the term exists and create it if it doesn't.
90
-			$term_id = $this->get_term_or_create_if_not_exists( $slug );
91
-
92
-			// Bail if the term doesn't exists or it's not created.
93
-			if ( empty( $term_id ) ) {
94
-				continue;
95
-			}
96
-
97
-			// Update term with description, slug and parent.
98
-			$term = wp_update_term(
99
-				$term_id,
100
-				Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
101
-				array(
102
-					'name'        => $term['label'],
103
-					'slug'        => $slug,
104
-					'description' => $term['description'],
105
-					// We give to WP taxonomy just one parent.
106
-					'parent'      => 0,
107
-				)
108
-			);
109
-
110
-			$this->log->trace( "Entity Type $slug installed with ID {$term['term_id']}." );
111
-
112
-		}
113
-
114
-		$this->log->debug( 'Entity Type data installed.' );
115
-	}
116
-
117
-	/**
118
-	 * Install custom relations table.
119
-	 *
120
-	 * @since 3.8.0
121
-	 *
122
-	 * @return void
123
-	 */
124
-	private function create_relation_instance_table() {
125
-		global $wpdb;
126
-
127
-		$table_name      = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME;
128
-		$charset_collate = $wpdb->get_charset_collate();
129
-
130
-		// Sql statement for the relation instances custom table.
131
-		$sql = <<<EOF
18
+    /**
19
+     * @inheritdoc
20
+     */
21
+    protected static $version = '1.0.0';
22
+
23
+    /**
24
+     * The WordLift entity type terms.
25
+     *
26
+     * @since  3.18.0
27
+     * @access private
28
+     * @var array $terms The entity type terms.
29
+     */
30
+    private static $terms = array(
31
+        'thing'         => array(
32
+            'label'       => 'Thing',
33
+            'description' => 'A generic thing (something that doesn\'t fit in the previous definitions.',
34
+        ),
35
+        'creative-work' => array(
36
+            'label'       => 'CreativeWork',
37
+            'description' => 'A creative work (or a Music Album).',
38
+        ),
39
+        'event'         => array(
40
+            'label'       => 'Event',
41
+            'description' => 'An event.',
42
+        ),
43
+        'organization'  => array(
44
+            'label'       => 'Organization',
45
+            'description' => 'An organization, including a government or a newspaper.',
46
+        ),
47
+        'person'        => array(
48
+            'label'       => 'Person',
49
+            'description' => 'A person (or a music artist).',
50
+        ),
51
+        'place'         => array(
52
+            'label'       => 'Place',
53
+            'description' => 'A place.',
54
+        ),
55
+        'localbusiness' => array(
56
+            'label'       => 'LocalBusiness',
57
+            'description' => 'A local business.',
58
+        ),
59
+    );
60
+
61
+    /**
62
+     * @inheritdoc
63
+     */
64
+    public function install() {
65
+        // Set the dataset uri.
66
+        $this->set_dataset_uri();
67
+
68
+        // Create entity type terms.
69
+        $this->create_entity_type_terms();
70
+
71
+        // Create relations table.
72
+        $this->create_relation_instance_table();
73
+    }
74
+
75
+    /**
76
+     * Create required entity type terms
77
+     *
78
+     * @since 3.18.0
79
+     *
80
+     * @return void
81
+     */
82
+    private function create_entity_type_terms() {
83
+        $this->log->debug( 'Installing Entity Type data...' );
84
+
85
+        // Set the taxonomy data.
86
+        // Note: parent types must be defined before child types.
87
+        foreach ( self::$terms as $slug => $term ) {
88
+
89
+            // Check whether the term exists and create it if it doesn't.
90
+            $term_id = $this->get_term_or_create_if_not_exists( $slug );
91
+
92
+            // Bail if the term doesn't exists or it's not created.
93
+            if ( empty( $term_id ) ) {
94
+                continue;
95
+            }
96
+
97
+            // Update term with description, slug and parent.
98
+            $term = wp_update_term(
99
+                $term_id,
100
+                Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
101
+                array(
102
+                    'name'        => $term['label'],
103
+                    'slug'        => $slug,
104
+                    'description' => $term['description'],
105
+                    // We give to WP taxonomy just one parent.
106
+                    'parent'      => 0,
107
+                )
108
+            );
109
+
110
+            $this->log->trace( "Entity Type $slug installed with ID {$term['term_id']}." );
111
+
112
+        }
113
+
114
+        $this->log->debug( 'Entity Type data installed.' );
115
+    }
116
+
117
+    /**
118
+     * Install custom relations table.
119
+     *
120
+     * @since 3.8.0
121
+     *
122
+     * @return void
123
+     */
124
+    private function create_relation_instance_table() {
125
+        global $wpdb;
126
+
127
+        $table_name      = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME;
128
+        $charset_collate = $wpdb->get_charset_collate();
129
+
130
+        // Sql statement for the relation instances custom table.
131
+        $sql = <<<EOF
132 132
 			CREATE TABLE $table_name (
133 133
 					id int(11) NOT NULL AUTO_INCREMENT,
134 134
 					subject_id int(11) NOT NULL,
@@ -140,66 +140,66 @@  discard block
 block discarded – undo
140 140
 			) $charset_collate;
141 141
 EOF;
142 142
 
143
-		// @see: https://codex.wordpress.org/Creating_Tables_with_Plugins
144
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
145
-		$results = dbDelta( $sql );
146
-
147
-		$this->log->trace( 'create_relation_instance_table :: ' . var_export( $results, true ) );
148
-
149
-	}
150
-
151
-	/**
152
-	 * Configure the dataset uri.
153
-	 *
154
-	 * @since 3.18.0
155
-	 *
156
-	 * @return void
157
-	 */
158
-	private function set_dataset_uri() {
159
-		// Get the configuration service and load the key.
160
-		$configuration_service = Wordlift_Configuration_Service::get_instance();
161
-		$key                   = $configuration_service->get_key();
162
-
163
-		// If the key is not empty then set the dataset URI while sending
164
-		// the site URL.
165
-		if ( ! empty( $key ) ) {
166
-			$this->log->info( 'Updating the remote dataset URI...' );
167
-
168
-			$configuration_service->get_remote_dataset_uri( $key );
169
-		}
170
-
171
-	}
172
-
173
-	/**
174
-	 * Checks whether the term exists and create it if it doesn't.
175
-	 *
176
-	 * @since 3.18.0
177
-	 *
178
-	 * @param string $slug Term slug.
179
-	 *
180
-	 * @return mixed Term id if the term exists or if it's created. False on failure
181
-	 */
182
-	private function get_term_or_create_if_not_exists( $slug ) {
183
-		// Create the term if it does not exist, then get its ID.
184
-		$term_id = term_exists( $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
185
-
186
-		if ( empty( $term_id ) ) {
187
-			// The term doesn't exists, so create it.
188
-			$maybe_term = wp_insert_term( $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
189
-		} else {
190
-			// Get the term.
191
-			$maybe_term = get_term( $term_id['term_id'], Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, ARRAY_A );
192
-		}
193
-
194
-		// Check for errors.
195
-		if ( is_wp_error( $maybe_term ) ) {
196
-			$this->log->info( 'wl_install_entity_type_data [ ' . $maybe_term->get_error_message() . ' ]' );
197
-
198
-			return false;
199
-		}
200
-
201
-		// Finally return the term id.
202
-		return $maybe_term['term_id'];
203
-	}
143
+        // @see: https://codex.wordpress.org/Creating_Tables_with_Plugins
144
+        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
145
+        $results = dbDelta( $sql );
146
+
147
+        $this->log->trace( 'create_relation_instance_table :: ' . var_export( $results, true ) );
148
+
149
+    }
150
+
151
+    /**
152
+     * Configure the dataset uri.
153
+     *
154
+     * @since 3.18.0
155
+     *
156
+     * @return void
157
+     */
158
+    private function set_dataset_uri() {
159
+        // Get the configuration service and load the key.
160
+        $configuration_service = Wordlift_Configuration_Service::get_instance();
161
+        $key                   = $configuration_service->get_key();
162
+
163
+        // If the key is not empty then set the dataset URI while sending
164
+        // the site URL.
165
+        if ( ! empty( $key ) ) {
166
+            $this->log->info( 'Updating the remote dataset URI...' );
167
+
168
+            $configuration_service->get_remote_dataset_uri( $key );
169
+        }
170
+
171
+    }
172
+
173
+    /**
174
+     * Checks whether the term exists and create it if it doesn't.
175
+     *
176
+     * @since 3.18.0
177
+     *
178
+     * @param string $slug Term slug.
179
+     *
180
+     * @return mixed Term id if the term exists or if it's created. False on failure
181
+     */
182
+    private function get_term_or_create_if_not_exists( $slug ) {
183
+        // Create the term if it does not exist, then get its ID.
184
+        $term_id = term_exists( $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
185
+
186
+        if ( empty( $term_id ) ) {
187
+            // The term doesn't exists, so create it.
188
+            $maybe_term = wp_insert_term( $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
189
+        } else {
190
+            // Get the term.
191
+            $maybe_term = get_term( $term_id['term_id'], Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, ARRAY_A );
192
+        }
193
+
194
+        // Check for errors.
195
+        if ( is_wp_error( $maybe_term ) ) {
196
+            $this->log->info( 'wl_install_entity_type_data [ ' . $maybe_term->get_error_message() . ' ]' );
197
+
198
+            return false;
199
+        }
200
+
201
+        // Finally return the term id.
202
+        return $maybe_term['term_id'];
203
+    }
204 204
 
205 205
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -80,17 +80,17 @@  discard block
 block discarded – undo
80 80
 	 * @return void
81 81
 	 */
82 82
 	private function create_entity_type_terms() {
83
-		$this->log->debug( 'Installing Entity Type data...' );
83
+		$this->log->debug('Installing Entity Type data...');
84 84
 
85 85
 		// Set the taxonomy data.
86 86
 		// Note: parent types must be defined before child types.
87
-		foreach ( self::$terms as $slug => $term ) {
87
+		foreach (self::$terms as $slug => $term) {
88 88
 
89 89
 			// Check whether the term exists and create it if it doesn't.
90
-			$term_id = $this->get_term_or_create_if_not_exists( $slug );
90
+			$term_id = $this->get_term_or_create_if_not_exists($slug);
91 91
 
92 92
 			// Bail if the term doesn't exists or it's not created.
93
-			if ( empty( $term_id ) ) {
93
+			if (empty($term_id)) {
94 94
 				continue;
95 95
 			}
96 96
 
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 				)
108 108
 			);
109 109
 
110
-			$this->log->trace( "Entity Type $slug installed with ID {$term['term_id']}." );
110
+			$this->log->trace("Entity Type $slug installed with ID {$term['term_id']}.");
111 111
 
112 112
 		}
113 113
 
114
-		$this->log->debug( 'Entity Type data installed.' );
114
+		$this->log->debug('Entity Type data installed.');
115 115
 	}
116 116
 
117 117
 	/**
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	private function create_relation_instance_table() {
125 125
 		global $wpdb;
126 126
 
127
-		$table_name      = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME;
127
+		$table_name      = $wpdb->prefix.WL_DB_RELATION_INSTANCES_TABLE_NAME;
128 128
 		$charset_collate = $wpdb->get_charset_collate();
129 129
 
130 130
 		// Sql statement for the relation instances custom table.
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
 EOF;
142 142
 
143 143
 		// @see: https://codex.wordpress.org/Creating_Tables_with_Plugins
144
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
145
-		$results = dbDelta( $sql );
144
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
145
+		$results = dbDelta($sql);
146 146
 
147
-		$this->log->trace( 'create_relation_instance_table :: ' . var_export( $results, true ) );
147
+		$this->log->trace('create_relation_instance_table :: '.var_export($results, true));
148 148
 
149 149
 	}
150 150
 
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 
163 163
 		// If the key is not empty then set the dataset URI while sending
164 164
 		// the site URL.
165
-		if ( ! empty( $key ) ) {
166
-			$this->log->info( 'Updating the remote dataset URI...' );
165
+		if ( ! empty($key)) {
166
+			$this->log->info('Updating the remote dataset URI...');
167 167
 
168
-			$configuration_service->get_remote_dataset_uri( $key );
168
+			$configuration_service->get_remote_dataset_uri($key);
169 169
 		}
170 170
 
171 171
 	}
@@ -179,21 +179,21 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @return mixed Term id if the term exists or if it's created. False on failure
181 181
 	 */
182
-	private function get_term_or_create_if_not_exists( $slug ) {
182
+	private function get_term_or_create_if_not_exists($slug) {
183 183
 		// Create the term if it does not exist, then get its ID.
184
-		$term_id = term_exists( $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
184
+		$term_id = term_exists($slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
185 185
 
186
-		if ( empty( $term_id ) ) {
186
+		if (empty($term_id)) {
187 187
 			// The term doesn't exists, so create it.
188
-			$maybe_term = wp_insert_term( $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
188
+			$maybe_term = wp_insert_term($slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
189 189
 		} else {
190 190
 			// Get the term.
191
-			$maybe_term = get_term( $term_id['term_id'], Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, ARRAY_A );
191
+			$maybe_term = get_term($term_id['term_id'], Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, ARRAY_A);
192 192
 		}
193 193
 
194 194
 		// Check for errors.
195
-		if ( is_wp_error( $maybe_term ) ) {
196
-			$this->log->info( 'wl_install_entity_type_data [ ' . $maybe_term->get_error_message() . ' ]' );
195
+		if (is_wp_error($maybe_term)) {
196
+			$this->log->info('wl_install_entity_type_data [ '.$maybe_term->get_error_message().' ]');
197 197
 
198 198
 			return false;
199 199
 		}
Please login to merge, or discard this patch.
src/install/class-wordlift-install-3-20-0.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -12,68 +12,68 @@
 block discarded – undo
12 12
  */
13 13
 class Wordlift_Install_3_20_0 extends Wordlift_Install {
14 14
 
15
-	/**
16
-	 * {@inheritdoc}
17
-	 */
18
-	protected static $version = '3.20.0';
15
+    /**
16
+     * {@inheritdoc}
17
+     */
18
+    protected static $version = '3.20.0';
19 19
 
20
-	public function install() {
20
+    public function install() {
21 21
 
22
-		$this->add_names_to_existing_terms();
23
-		$this->rename_localbusiness_to_local_business();
22
+        $this->add_names_to_existing_terms();
23
+        $this->rename_localbusiness_to_local_business();
24 24
 
25
-	}
25
+    }
26 26
 
27
-	private function add_names_to_existing_terms() {
27
+    private function add_names_to_existing_terms() {
28 28
 
29
-		$this->log->debug( 'Adding names and URIs to existing terms...' );
29
+        $this->log->debug( 'Adding names and URIs to existing terms...' );
30 30
 
31
-		$schema_names = array(
32
-			'article'       => 'Article',
33
-			'thing'         => 'Thing',
34
-			'creative-work' => 'CreativeWork',
35
-			'event'         => 'Event',
36
-			'organization'  => 'Organization',
37
-			'person'        => 'Person',
38
-			'place'         => 'Place',
39
-			'localbusiness' => 'LocalBusiness',
40
-			'recipe'        => 'Recipe',
41
-			'web-page'      => 'WebPage',
42
-			'offer'         => 'Offer',
43
-		);
31
+        $schema_names = array(
32
+            'article'       => 'Article',
33
+            'thing'         => 'Thing',
34
+            'creative-work' => 'CreativeWork',
35
+            'event'         => 'Event',
36
+            'organization'  => 'Organization',
37
+            'person'        => 'Person',
38
+            'place'         => 'Place',
39
+            'localbusiness' => 'LocalBusiness',
40
+            'recipe'        => 'Recipe',
41
+            'web-page'      => 'WebPage',
42
+            'offer'         => 'Offer',
43
+        );
44 44
 
45
-		foreach ( $schema_names as $slug => $name ) {
46
-			$term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
45
+        foreach ( $schema_names as $slug => $name ) {
46
+            $term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
47 47
 
48
-			if ( false === $term ) {
49
-				$this->log->warn( "Term `$slug` not found." );
48
+            if ( false === $term ) {
49
+                $this->log->warn( "Term `$slug` not found." );
50 50
 
51
-				continue;
52
-			}
51
+                continue;
52
+            }
53 53
 
54
-			// $this->log->debug( "Adding $name and http://schema.org/$name as name and URI of term `$slug` ({$term->term_id})." );
54
+            // $this->log->debug( "Adding $name and http://schema.org/$name as name and URI of term `$slug` ({$term->term_id})." );
55 55
 
56
-			// We don't use the references to the Wordlift_Schemaorg_Class_Service because it might not be
57
-			// loaded if the `WL_ALL_ENTITY_TYPES` constant isn't set.
58
-			$result_1 = update_term_meta( $term->term_id, '_wl_name', $name );
59
-			$result_2 = update_term_meta( $term->term_id, '_wl_uri', "http://schema.org/$name" );
56
+            // We don't use the references to the Wordlift_Schemaorg_Class_Service because it might not be
57
+            // loaded if the `WL_ALL_ENTITY_TYPES` constant isn't set.
58
+            $result_1 = update_term_meta( $term->term_id, '_wl_name', $name );
59
+            $result_2 = update_term_meta( $term->term_id, '_wl_uri', "http://schema.org/$name" );
60 60
 
61
-			// $this->log->debug( 'name :: ' . var_export( $result_1, true ) . ' URI :: ' . var_export( $result_2, true ) );
61
+            // $this->log->debug( 'name :: ' . var_export( $result_1, true ) . ' URI :: ' . var_export( $result_2, true ) );
62 62
 
63
-		}
63
+        }
64 64
 
65
-	}
65
+    }
66 66
 
67
-	private function rename_localbusiness_to_local_business() {
67
+    private function rename_localbusiness_to_local_business() {
68 68
 
69
-		$term = get_term_by( 'slug', 'localbusiness', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
69
+        $term = get_term_by( 'slug', 'localbusiness', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
70 70
 
71
-		if ( false === $term ) {
72
-			return;
73
-		}
71
+        if ( false === $term ) {
72
+            return;
73
+        }
74 74
 
75
-		wp_update_term( $term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'slug' => 'local-business' ) );
75
+        wp_update_term( $term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'slug' => 'local-business' ) );
76 76
 
77
-	}
77
+    }
78 78
 
79 79
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 	private function add_names_to_existing_terms() {
28 28
 
29
-		$this->log->debug( 'Adding names and URIs to existing terms...' );
29
+		$this->log->debug('Adding names and URIs to existing terms...');
30 30
 
31 31
 		$schema_names = array(
32 32
 			'article'       => 'Article',
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 			'offer'         => 'Offer',
43 43
 		);
44 44
 
45
-		foreach ( $schema_names as $slug => $name ) {
46
-			$term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
45
+		foreach ($schema_names as $slug => $name) {
46
+			$term = get_term_by('slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
47 47
 
48
-			if ( false === $term ) {
49
-				$this->log->warn( "Term `$slug` not found." );
48
+			if (false === $term) {
49
+				$this->log->warn("Term `$slug` not found.");
50 50
 
51 51
 				continue;
52 52
 			}
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 
56 56
 			// We don't use the references to the Wordlift_Schemaorg_Class_Service because it might not be
57 57
 			// loaded if the `WL_ALL_ENTITY_TYPES` constant isn't set.
58
-			$result_1 = update_term_meta( $term->term_id, '_wl_name', $name );
59
-			$result_2 = update_term_meta( $term->term_id, '_wl_uri', "http://schema.org/$name" );
58
+			$result_1 = update_term_meta($term->term_id, '_wl_name', $name);
59
+			$result_2 = update_term_meta($term->term_id, '_wl_uri', "http://schema.org/$name");
60 60
 
61 61
 			// $this->log->debug( 'name :: ' . var_export( $result_1, true ) . ' URI :: ' . var_export( $result_2, true ) );
62 62
 
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 
67 67
 	private function rename_localbusiness_to_local_business() {
68 68
 
69
-		$term = get_term_by( 'slug', 'localbusiness', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
69
+		$term = get_term_by('slug', 'localbusiness', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
70 70
 
71
-		if ( false === $term ) {
71
+		if (false === $term) {
72 72
 			return;
73 73
 		}
74 74
 
75
-		wp_update_term( $term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'slug' => 'local-business' ) );
75
+		wp_update_term($term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array('slug' => 'local-business'));
76 76
 
77 77
 	}
78 78
 
Please login to merge, or discard this patch.
src/includes/class-wordlift-schema-url-property-service.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function get_metabox_label() {
68 68
 
69
-		return __( 'Web Site(s)', 'wordlift' );
69
+		return __('Web Site(s)', 'wordlift');
70 70
 	}
71 71
 
72 72
 	/**
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param Wordlift_Sparql_Service $sparql_service
82 82
 	 */
83
-	public function __construct( $sparql_service ) {
83
+	public function __construct($sparql_service) {
84 84
 		parent::__construct();
85 85
 
86 86
 		// Finally listen for metadata requests for this field.
@@ -98,20 +98,20 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return array|NULL The schema:url value or NULL if not set.
100 100
 	 */
101
-	public function get( $post_id ) {
101
+	public function get($post_id) {
102 102
 
103 103
 		// Get the schema:url values set in WP.
104
-		$values = get_post_meta( $post_id, self::META_KEY, false );
104
+		$values = get_post_meta($post_id, self::META_KEY, false);
105 105
 
106 106
 		// If the property has never been set, we set its default value the first
107 107
 		// time to <permalink>.
108
-		if ( empty( $values ) ) {
109
-			return array( '<permalink>' );
108
+		if (empty($values)) {
109
+			return array('<permalink>');
110 110
 		}
111 111
 
112 112
 		// If there's only one value and that value is empty, we return NULL, i.e.
113 113
 		// variable not set.
114
-		if ( 1 === count( $values ) && empty( $values[0] ) ) {
114
+		if (1 === count($values) && empty($values[0])) {
115 115
 			return null;
116 116
 		}
117 117
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	/**
123 123
 	 * {@inheritdoc}
124 124
 	 */
125
-	public function sanitize( $value ) {
125
+	public function sanitize($value) {
126 126
 
127 127
 		// TODO: check that it's an URL or that is <permalink>
128 128
 
@@ -173,26 +173,26 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @return array|mixed|NULL|string
175 175
 	 */
176
-	public function get_post_metadata( $value, $object_id, $meta_key, $single ) {
176
+	public function get_post_metadata($value, $object_id, $meta_key, $single) {
177 177
 
178 178
 		// It's not us, return the value.
179
-		if ( self::META_KEY !== $meta_key ) {
179
+		if (self::META_KEY !== $meta_key) {
180 180
 			return $value;
181 181
 		}
182 182
 
183 183
 		$this->remove_filter_get_post_metadata();
184 184
 
185
-		$new_value = $this->get( $object_id );
185
+		$new_value = $this->get($object_id);
186 186
 
187 187
 		$this->add_filter_get_post_metadata();
188 188
 
189 189
 		// If we must return a single value, but we don't have a value, then return an empty string.
190
-		if ( $single && ( is_null( $new_value ) || empty( $new_value ) ) ) {
190
+		if ($single && (is_null($new_value) || empty($new_value))) {
191 191
 			return '';
192 192
 		}
193 193
 
194 194
 		// If we have a value and we need to return it as single, return the first value.
195
-		if ( $single ) {
195
+		if ($single) {
196 196
 			return $new_value[0];
197 197
 		}
198 198
 
@@ -202,19 +202,19 @@  discard block
 block discarded – undo
202 202
 
203 203
 	private function add_filter_get_post_metadata() {
204 204
 
205
-		add_filter( 'get_post_metadata', array(
205
+		add_filter('get_post_metadata', array(
206 206
 			$this,
207 207
 			'get_post_metadata',
208
-		), 10, 4 );
208
+		), 10, 4);
209 209
 
210 210
 	}
211 211
 
212 212
 	private function remove_filter_get_post_metadata() {
213 213
 
214
-		remove_filter( 'get_post_metadata', array(
214
+		remove_filter('get_post_metadata', array(
215 215
 			$this,
216 216
 			'get_post_metadata',
217
-		), 10 );
217
+		), 10);
218 218
 
219 219
 	}
220 220
 
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -13,179 +13,179 @@
 block discarded – undo
13 13
  */
14 14
 class Wordlift_Schema_Url_Property_Service extends Wordlift_Property_Service {
15 15
 
16
-	/**
17
-	 * The meta key used to store data for this property. We don't use wl_url to
18
-	 * avoid potential confusion about other URLs.
19
-	 *
20
-	 * @since 3.6.0
21
-	 */
22
-	const META_KEY = 'wl_schema_url';
23
-
24
-	/**
25
-	 * {@inheritdoc}
26
-	 */
27
-	public function get_rdf_predicate() {
28
-
29
-		return 'http://schema.org/url';
30
-	}
31
-
32
-	/**
33
-	 * {@inheritdoc}
34
-	 */
35
-	public function get_rdf_data_type() {
36
-
37
-		return 'xsd:anyURI';
38
-	}
39
-
40
-	/**
41
-	 * {@inheritdoc}
42
-	 */
43
-	public function get_data_type() {
44
-
45
-		return Wordlift_Schema_Service::DATA_TYPE_URI;
46
-	}
47
-
48
-	/**
49
-	 * {@inheritdoc}
50
-	 */
51
-	public function get_cardinality() {
52
-
53
-		return INF;
54
-	}
55
-
56
-	/**
57
-	 * {@inheritdoc}
58
-	 */
59
-	public function get_metabox_class() {
60
-
61
-		return 'Wl_Metabox_Field';
62
-	}
63
-
64
-	/**
65
-	 * {@inheritdoc}
66
-	 */
67
-	public function get_metabox_label() {
68
-
69
-		return __( 'Web Site(s)', 'wordlift' );
70
-	}
71
-
72
-	/**
73
-	 * @var
74
-	 */
75
-	private $sparql_service;
76
-
77
-	/**
78
-	 * Create a Wordlift_Schema_Url_Property_Service instance.
79
-	 * @since 3.6.0
80
-	 *
81
-	 * @param Wordlift_Sparql_Service $sparql_service
82
-	 */
83
-	public function __construct( $sparql_service ) {
84
-		parent::__construct();
85
-
86
-		// Finally listen for metadata requests for this field.
87
-		$this->add_filter_get_post_metadata();
88
-
89
-		$this->sparql_service = $sparql_service;
90
-	}
91
-
92
-	/**
93
-	 * Get the schema:url value for the specified post/entity.
94
-	 *
95
-	 * @since 3.6.0
96
-	 *
97
-	 * @param int $post_id The post id.
98
-	 *
99
-	 * @return array|NULL The schema:url value or NULL if not set.
100
-	 */
101
-	public function get( $post_id ) {
102
-
103
-		// Get the schema:url values set in WP.
104
-		$values = get_post_meta( $post_id, self::META_KEY, false );
105
-
106
-		// If the property has never been set, we set its default value the first
107
-		// time to <permalink>.
108
-		if ( empty( $values ) ) {
109
-			return array( '<permalink>' );
110
-		}
111
-
112
-		// If there's only one value and that value is empty, we return NULL, i.e.
113
-		// variable not set.
114
-		if ( 1 === count( $values ) && empty( $values[0] ) ) {
115
-			return null;
116
-		}
117
-
118
-		// Finally return whatever values the editor set.
119
-		return $values;
120
-	}
121
-
122
-	/**
123
-	 * {@inheritdoc}
124
-	 */
125
-	public function sanitize( $value ) {
126
-
127
-		// TODO: check that it's an URL or that is <permalink>
128
-
129
-		return $value;
130
-	}
131
-
132
-	/**
133
-	 * Get direct calls to read this meta and alter the response according to our
134
-	 * own strategy, i.e. if a value has never been set for this meta, then return
135
-	 * <permalink>.
136
-	 *
137
-	 * @since 3.6.0
138
-	 *
139
-	 * @param mixed  $value The original value.
140
-	 * @param int    $object_id The post id.
141
-	 * @param string $meta_key The meta key. We expect wl_schema_url or we return straight the value.
142
-	 * @param bool   $single Whether to return a single value.
143
-	 *
144
-	 * @return array|mixed|NULL|string
145
-	 */
146
-	public function get_post_metadata( $value, $object_id, $meta_key, $single ) {
147
-
148
-		// It's not us, return the value.
149
-		if ( self::META_KEY !== $meta_key ) {
150
-			return $value;
151
-		}
152
-
153
-		$this->remove_filter_get_post_metadata();
154
-
155
-		$new_value = $this->get( $object_id );
156
-
157
-		$this->add_filter_get_post_metadata();
158
-
159
-		// If we must return a single value, but we don't have a value, then return an empty string.
160
-		if ( $single && ( is_null( $new_value ) || empty( $new_value ) ) ) {
161
-			return '';
162
-		}
163
-
164
-		// If we have a value and we need to return it as single, return the first value.
165
-		if ( $single ) {
166
-			return $new_value[0];
167
-		}
168
-
169
-		// Otherwise return the array.
170
-		return $new_value;
171
-	}
172
-
173
-	private function add_filter_get_post_metadata() {
174
-
175
-		add_filter( 'get_post_metadata', array(
176
-			$this,
177
-			'get_post_metadata',
178
-		), 10, 4 );
179
-
180
-	}
181
-
182
-	private function remove_filter_get_post_metadata() {
183
-
184
-		remove_filter( 'get_post_metadata', array(
185
-			$this,
186
-			'get_post_metadata',
187
-		), 10 );
188
-
189
-	}
16
+    /**
17
+     * The meta key used to store data for this property. We don't use wl_url to
18
+     * avoid potential confusion about other URLs.
19
+     *
20
+     * @since 3.6.0
21
+     */
22
+    const META_KEY = 'wl_schema_url';
23
+
24
+    /**
25
+     * {@inheritdoc}
26
+     */
27
+    public function get_rdf_predicate() {
28
+
29
+        return 'http://schema.org/url';
30
+    }
31
+
32
+    /**
33
+     * {@inheritdoc}
34
+     */
35
+    public function get_rdf_data_type() {
36
+
37
+        return 'xsd:anyURI';
38
+    }
39
+
40
+    /**
41
+     * {@inheritdoc}
42
+     */
43
+    public function get_data_type() {
44
+
45
+        return Wordlift_Schema_Service::DATA_TYPE_URI;
46
+    }
47
+
48
+    /**
49
+     * {@inheritdoc}
50
+     */
51
+    public function get_cardinality() {
52
+
53
+        return INF;
54
+    }
55
+
56
+    /**
57
+     * {@inheritdoc}
58
+     */
59
+    public function get_metabox_class() {
60
+
61
+        return 'Wl_Metabox_Field';
62
+    }
63
+
64
+    /**
65
+     * {@inheritdoc}
66
+     */
67
+    public function get_metabox_label() {
68
+
69
+        return __( 'Web Site(s)', 'wordlift' );
70
+    }
71
+
72
+    /**
73
+     * @var
74
+     */
75
+    private $sparql_service;
76
+
77
+    /**
78
+     * Create a Wordlift_Schema_Url_Property_Service instance.
79
+     * @since 3.6.0
80
+     *
81
+     * @param Wordlift_Sparql_Service $sparql_service
82
+     */
83
+    public function __construct( $sparql_service ) {
84
+        parent::__construct();
85
+
86
+        // Finally listen for metadata requests for this field.
87
+        $this->add_filter_get_post_metadata();
88
+
89
+        $this->sparql_service = $sparql_service;
90
+    }
91
+
92
+    /**
93
+     * Get the schema:url value for the specified post/entity.
94
+     *
95
+     * @since 3.6.0
96
+     *
97
+     * @param int $post_id The post id.
98
+     *
99
+     * @return array|NULL The schema:url value or NULL if not set.
100
+     */
101
+    public function get( $post_id ) {
102
+
103
+        // Get the schema:url values set in WP.
104
+        $values = get_post_meta( $post_id, self::META_KEY, false );
105
+
106
+        // If the property has never been set, we set its default value the first
107
+        // time to <permalink>.
108
+        if ( empty( $values ) ) {
109
+            return array( '<permalink>' );
110
+        }
111
+
112
+        // If there's only one value and that value is empty, we return NULL, i.e.
113
+        // variable not set.
114
+        if ( 1 === count( $values ) && empty( $values[0] ) ) {
115
+            return null;
116
+        }
117
+
118
+        // Finally return whatever values the editor set.
119
+        return $values;
120
+    }
121
+
122
+    /**
123
+     * {@inheritdoc}
124
+     */
125
+    public function sanitize( $value ) {
126
+
127
+        // TODO: check that it's an URL or that is <permalink>
128
+
129
+        return $value;
130
+    }
131
+
132
+    /**
133
+     * Get direct calls to read this meta and alter the response according to our
134
+     * own strategy, i.e. if a value has never been set for this meta, then return
135
+     * <permalink>.
136
+     *
137
+     * @since 3.6.0
138
+     *
139
+     * @param mixed  $value The original value.
140
+     * @param int    $object_id The post id.
141
+     * @param string $meta_key The meta key. We expect wl_schema_url or we return straight the value.
142
+     * @param bool   $single Whether to return a single value.
143
+     *
144
+     * @return array|mixed|NULL|string
145
+     */
146
+    public function get_post_metadata( $value, $object_id, $meta_key, $single ) {
147
+
148
+        // It's not us, return the value.
149
+        if ( self::META_KEY !== $meta_key ) {
150
+            return $value;
151
+        }
152
+
153
+        $this->remove_filter_get_post_metadata();
154
+
155
+        $new_value = $this->get( $object_id );
156
+
157
+        $this->add_filter_get_post_metadata();
158
+
159
+        // If we must return a single value, but we don't have a value, then return an empty string.
160
+        if ( $single && ( is_null( $new_value ) || empty( $new_value ) ) ) {
161
+            return '';
162
+        }
163
+
164
+        // If we have a value and we need to return it as single, return the first value.
165
+        if ( $single ) {
166
+            return $new_value[0];
167
+        }
168
+
169
+        // Otherwise return the array.
170
+        return $new_value;
171
+    }
172
+
173
+    private function add_filter_get_post_metadata() {
174
+
175
+        add_filter( 'get_post_metadata', array(
176
+            $this,
177
+            'get_post_metadata',
178
+        ), 10, 4 );
179
+
180
+    }
181
+
182
+    private function remove_filter_get_post_metadata() {
183
+
184
+        remove_filter( 'get_post_metadata', array(
185
+            $this,
186
+            'get_post_metadata',
187
+        ), 10 );
188
+
189
+    }
190 190
 
191 191
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift-image-service.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -19,85 +19,85 @@
 block discarded – undo
19 19
  */
20 20
 class Wordlift_Image_Service {
21 21
 
22
-	/**
23
-	 * The image ratios and sizes.
24
-	 *
25
-	 * @since 3.19.4
26
-	 * @access public
27
-	 * @var array $sizes The image ratios and sizes.
28
-	 */
29
-	public static $sizes = array(
30
-		'16x9' => array( 1200, 675 ),
31
-		'4x3'  => array( 1200, 900 ),
32
-		'1x1'  => array( 1200, 1200 ),
33
-	);
34
-
35
-	/**
36
-	 * Create a {@link Wordlift_Image_Service} instance.
37
-	 *
38
-	 * @since 3.19.4
39
-	 */
40
-	public function __construct() {
41
-
42
-		// Add hook to define the image sizes. Since we're a plugin, we cannot use the
43
-		// `after_theme_setup` hook.
44
-		add_action( 'init', array( $this, 'after_theme_setup' ) );
45
-
46
-	}
47
-
48
-	/**
49
-	 * Hook `after_theme_setup`: add our own image sizes.
50
-	 *
51
-	 * @since 3.19.4
52
-	 */
53
-	public function after_theme_setup() {
54
-
55
-		foreach ( self::$sizes as $ratio => $sizes ) {
56
-			add_image_size( "wl-$ratio", $sizes[0], $sizes[1], true );
57
-		}
58
-
59
-	}
60
-
61
-	/**
62
-	 * Get the sources for the specified attachment.
63
-	 *
64
-	 * @since 3.19.4
65
-	 *
66
-	 * @param int   $attachment_id The attachment id.
67
-	 *
68
-	 * @return array {
69
-	 * An array of image sources.
70
-	 *
71
-	 * @type string $url The attachment URL.
72
-	 * @type int    $width The attachment width.
73
-	 * @type int    $height The attachment height.
74
-	 * }
75
-	 */
76
-	public static function get_sources( $attachment_id ) {
77
-
78
-		// Get the source for the specified image sizes.
79
-		$sources = array_map( function ( $ratio ) use ( $attachment_id ) {
80
-
81
-			// Get the source of the specified ratio.
82
-			$source = wp_get_attachment_image_src( $attachment_id, "wl-$ratio" );
83
-
84
-			// Get the size for the specified ratio.
85
-			$size = Wordlift_Image_Service::$sizes[ $ratio ];
86
-
87
-			// Check that the source has an image, and the required size.
88
-			if ( empty( $source[0] ) || $size[0] !== $source[1] || $size[1] !== $source[2] ) {
89
-				return null;
90
-			}
91
-
92
-			// Return the source.
93
-			return $source;
94
-		}, array_keys( self::$sizes ) );
95
-
96
-		// Filter unavailable sources.
97
-		$sources_1200 = array_filter( $sources );
98
-
99
-		// Make the results unique.
100
-		return $sources_1200;
101
-	}
22
+    /**
23
+     * The image ratios and sizes.
24
+     *
25
+     * @since 3.19.4
26
+     * @access public
27
+     * @var array $sizes The image ratios and sizes.
28
+     */
29
+    public static $sizes = array(
30
+        '16x9' => array( 1200, 675 ),
31
+        '4x3'  => array( 1200, 900 ),
32
+        '1x1'  => array( 1200, 1200 ),
33
+    );
34
+
35
+    /**
36
+     * Create a {@link Wordlift_Image_Service} instance.
37
+     *
38
+     * @since 3.19.4
39
+     */
40
+    public function __construct() {
41
+
42
+        // Add hook to define the image sizes. Since we're a plugin, we cannot use the
43
+        // `after_theme_setup` hook.
44
+        add_action( 'init', array( $this, 'after_theme_setup' ) );
45
+
46
+    }
47
+
48
+    /**
49
+     * Hook `after_theme_setup`: add our own image sizes.
50
+     *
51
+     * @since 3.19.4
52
+     */
53
+    public function after_theme_setup() {
54
+
55
+        foreach ( self::$sizes as $ratio => $sizes ) {
56
+            add_image_size( "wl-$ratio", $sizes[0], $sizes[1], true );
57
+        }
58
+
59
+    }
60
+
61
+    /**
62
+     * Get the sources for the specified attachment.
63
+     *
64
+     * @since 3.19.4
65
+     *
66
+     * @param int   $attachment_id The attachment id.
67
+     *
68
+     * @return array {
69
+     * An array of image sources.
70
+     *
71
+     * @type string $url The attachment URL.
72
+     * @type int    $width The attachment width.
73
+     * @type int    $height The attachment height.
74
+     * }
75
+     */
76
+    public static function get_sources( $attachment_id ) {
77
+
78
+        // Get the source for the specified image sizes.
79
+        $sources = array_map( function ( $ratio ) use ( $attachment_id ) {
80
+
81
+            // Get the source of the specified ratio.
82
+            $source = wp_get_attachment_image_src( $attachment_id, "wl-$ratio" );
83
+
84
+            // Get the size for the specified ratio.
85
+            $size = Wordlift_Image_Service::$sizes[ $ratio ];
86
+
87
+            // Check that the source has an image, and the required size.
88
+            if ( empty( $source[0] ) || $size[0] !== $source[1] || $size[1] !== $source[2] ) {
89
+                return null;
90
+            }
91
+
92
+            // Return the source.
93
+            return $source;
94
+        }, array_keys( self::$sizes ) );
95
+
96
+        // Filter unavailable sources.
97
+        $sources_1200 = array_filter( $sources );
98
+
99
+        // Make the results unique.
100
+        return $sources_1200;
101
+    }
102 102
 
103 103
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 	 * @var array $sizes The image ratios and sizes.
28 28
 	 */
29 29
 	public static $sizes = array(
30
-		'16x9' => array( 1200, 675 ),
31
-		'4x3'  => array( 1200, 900 ),
32
-		'1x1'  => array( 1200, 1200 ),
30
+		'16x9' => array(1200, 675),
31
+		'4x3'  => array(1200, 900),
32
+		'1x1'  => array(1200, 1200),
33 33
 	);
34 34
 
35 35
 	/**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
 		// Add hook to define the image sizes. Since we're a plugin, we cannot use the
43 43
 		// `after_theme_setup` hook.
44
-		add_action( 'init', array( $this, 'after_theme_setup' ) );
44
+		add_action('init', array($this, 'after_theme_setup'));
45 45
 
46 46
 	}
47 47
 
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function after_theme_setup() {
54 54
 
55
-		foreach ( self::$sizes as $ratio => $sizes ) {
56
-			add_image_size( "wl-$ratio", $sizes[0], $sizes[1], true );
55
+		foreach (self::$sizes as $ratio => $sizes) {
56
+			add_image_size("wl-$ratio", $sizes[0], $sizes[1], true);
57 57
 		}
58 58
 
59 59
 	}
@@ -73,28 +73,28 @@  discard block
 block discarded – undo
73 73
 	 * @type int    $height The attachment height.
74 74
 	 * }
75 75
 	 */
76
-	public static function get_sources( $attachment_id ) {
76
+	public static function get_sources($attachment_id) {
77 77
 
78 78
 		// Get the source for the specified image sizes.
79
-		$sources = array_map( function ( $ratio ) use ( $attachment_id ) {
79
+		$sources = array_map(function($ratio) use ($attachment_id) {
80 80
 
81 81
 			// Get the source of the specified ratio.
82
-			$source = wp_get_attachment_image_src( $attachment_id, "wl-$ratio" );
82
+			$source = wp_get_attachment_image_src($attachment_id, "wl-$ratio");
83 83
 
84 84
 			// Get the size for the specified ratio.
85
-			$size = Wordlift_Image_Service::$sizes[ $ratio ];
85
+			$size = Wordlift_Image_Service::$sizes[$ratio];
86 86
 
87 87
 			// Check that the source has an image, and the required size.
88
-			if ( empty( $source[0] ) || $size[0] !== $source[1] || $size[1] !== $source[2] ) {
88
+			if (empty($source[0]) || $size[0] !== $source[1] || $size[1] !== $source[2]) {
89 89
 				return null;
90 90
 			}
91 91
 
92 92
 			// Return the source.
93 93
 			return $source;
94
-		}, array_keys( self::$sizes ) );
94
+		}, array_keys(self::$sizes));
95 95
 
96 96
 		// Filter unavailable sources.
97
-		$sources_1200 = array_filter( $sources );
97
+		$sources_1200 = array_filter($sources);
98 98
 
99 99
 		// Make the results unique.
100 100
 		return $sources_1200;
Please login to merge, or discard this patch.
src/install/class-wordlift-install-3-19-5.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,23 +16,23 @@
 block discarded – undo
16 16
  */
17 17
 class Wordlift_Install_3_19_5 extends Wordlift_Install {
18 18
 
19
-	/**
20
-	 * {@inheritdoc}
21
-	 */
22
-	protected static $version = '3.19.5';
19
+    /**
20
+     * {@inheritdoc}
21
+     */
22
+    protected static $version = '3.19.5';
23 23
 
24
-	/**
25
-	 * {@inheritdoc}
26
-	 */
27
-	public function install() {
24
+    /**
25
+     * {@inheritdoc}
26
+     */
27
+    public function install() {
28 28
 
29
-		/*
29
+        /*
30 30
 		 * Flush all the caches, since we changed some JSON-LD publishing rules.
31 31
 		 *
32 32
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/858
33 33
 		 */
34
-		Wordlift_File_Cache_Service::flush_all();
34
+        Wordlift_File_Cache_Service::flush_all();
35 35
 
36
-	}
36
+    }
37 37
 
38 38
 }
Please login to merge, or discard this patch.
src/admin/elements/class-wordlift-admin-language-select-element.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Admin_Language_Select_Element extends Wordlift_Admin_Select_Element {
20 20
 
21
-	/**
22
-	 * @inheritdoc
23
-	 */
24
-	public function render_options( $params ) {
25
-		/*
21
+    /**
22
+     * @inheritdoc
23
+     */
24
+    public function render_options( $params ) {
25
+        /*
26 26
 		 * Print all the supported language, preselecting the one configured
27 27
 		 * in WP (or English if not supported). We now use the `Wordlift_Languages`
28 28
 		 * class which provides the list of languages supported by WordLift.
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 		 * See https://github.com/insideout10/wordlift-plugin/issues/349
31 31
 		 */
32 32
 
33
-		// Get WordLift's supported languages.
34
-		$languages = Wordlift_Languages::get_languages();
33
+        // Get WordLift's supported languages.
34
+        $languages = Wordlift_Languages::get_languages();
35 35
 
36
-		// If we support WP's configured language, then use that, otherwise use English by default.
37
-		$language = isset( $languages[ $params['value'] ] ) ? $params['value'] : 'en';
36
+        // If we support WP's configured language, then use that, otherwise use English by default.
37
+        $language = isset( $languages[ $params['value'] ] ) ? $params['value'] : 'en';
38 38
 
39
-		foreach ( $languages as $code => $label ) :
40
-			?>
39
+        foreach ( $languages as $code => $label ) :
40
+            ?>
41 41
             <option
42 42
                     value="<?php echo esc_attr( $code ); ?>"
43 43
 				<?php echo selected( $code, $language, false ); ?>
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 				<?php echo esc_html( $label ); ?>
46 46
             </option>
47 47
 		<?php
48
-		endforeach;
49
-	}
48
+        endforeach;
49
+    }
50 50
 
51 51
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	/**
22 22
 	 * @inheritdoc
23 23
 	 */
24
-	public function render_options( $params ) {
24
+	public function render_options($params) {
25 25
 		/*
26 26
 		 * Print all the supported language, preselecting the one configured
27 27
 		 * in WP (or English if not supported). We now use the `Wordlift_Languages`
@@ -34,15 +34,15 @@  discard block
 block discarded – undo
34 34
 		$languages = Wordlift_Languages::get_languages();
35 35
 
36 36
 		// If we support WP's configured language, then use that, otherwise use English by default.
37
-		$language = isset( $languages[ $params['value'] ] ) ? $params['value'] : 'en';
37
+		$language = isset($languages[$params['value']]) ? $params['value'] : 'en';
38 38
 
39
-		foreach ( $languages as $code => $label ) :
39
+		foreach ($languages as $code => $label) :
40 40
 			?>
41 41
             <option
42
-                    value="<?php echo esc_attr( $code ); ?>"
43
-				<?php echo selected( $code, $language, false ); ?>
42
+                    value="<?php echo esc_attr($code); ?>"
43
+				<?php echo selected($code, $language, false); ?>
44 44
             >
45
-				<?php echo esc_html( $label ); ?>
45
+				<?php echo esc_html($label); ?>
46 46
             </option>
47 47
 		<?php
48 48
 		endforeach;
Please login to merge, or discard this patch.