Completed
Push — develop ( a2521a...180e23 )
by Naveen
02:05 queued 12s
created
src/install/class-wordlift-install-3-44-4.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,23 +10,23 @@
 block discarded – undo
10 10
  */
11 11
 class Wordlift_Install_3_44_4 extends Wordlift_Install {
12 12
 
13
-	/**
14
-	 * {@inheritdoc}
15
-	 */
16
-	protected static $version = '3.44.4';
13
+    /**
14
+     * {@inheritdoc}
15
+     */
16
+    protected static $version = '3.44.4';
17 17
 
18
-	public function install() {
18
+    public function install() {
19 19
 
20
-		global $wpdb;
20
+        global $wpdb;
21 21
 
22
-		$wpdb->query(
23
-			"
22
+        $wpdb->query(
23
+            "
24 24
 			UPDATE {$wpdb->prefix}wl_entities
25 25
 			SET about_jsonld = NULL
26 26
 			WHERE about_jsonld = '' OR about_jsonld = 'null'
27 27
 		"
28
-		);
28
+        );
29 29
 
30
-		Ttl_Cache::flush_all();
31
-	}
30
+        Ttl_Cache::flush_all();
31
+    }
32 32
 }
Please login to merge, or discard this patch.
src/install/class-wordlift-install-service.php 2 patches
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -18,192 +18,192 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Install_Service {
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
-	private $log;
29
-
30
-	/**
31
-	 * The singleton instance.
32
-	 *
33
-	 * @since  3.18.0
34
-	 * @access private
35
-	 * @var \Wordlift_Install_Service $instance A {@link Wordlift_Install_Service} instance.
36
-	 */
37
-	private static $instance;
38
-
39
-	/**
40
-	 * @var array
41
-	 */
42
-	private $installs;
43
-
44
-	/**
45
-	 * Wordlift_Install_Service constructor.
46
-	 *
47
-	 * @since 3.18.0
48
-	 */
49
-	public function __construct() {
50
-
51
-		/** Installs. */
52
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install.php';
53
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-1-0-0.php';
54
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-10-0.php';
55
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-12-0.php';
56
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-14-0.php';
57
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-15-0.php';
58
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-0.php';
59
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-3.php';
60
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-19-5.php';
61
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-20-0.php';
62
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-23-4.php';
63
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-24-2.php';
64
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-all-entity-types.php';
65
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-package-type.php';
66
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-25-0.php';
67
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-0.php';
68
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-1.php';
69
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-28-0.php';
70
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-32-0.php';
71
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-33-9.php';
72
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-36-0.php';
73
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-38-5.php';
74
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-39-1.php';
75
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-40-1.php';
76
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-40-2.php';
77
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-41-0.php';
78
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-42-0.php';
79
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-44-1.php';
80
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-44-4.php';
81
-		// Get the install services.
82
-		$this->installs = array(
83
-			new Wordlift_Install_1_0_0(),
84
-			new Wordlift_Install_3_10_0(),
85
-			new Wordlift_Install_3_12_0(),
86
-			new Wordlift_Install_3_14_0(),
87
-			new Wordlift_Install_3_15_0(),
88
-			new Wordlift_Install_3_18_0(),
89
-			new Wordlift_Install_3_18_3(),
90
-			new Wordlift_Install_3_19_5(),
91
-			new Wordlift_Install_3_20_0(),
92
-
93
-			/*
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
+    private $log;
29
+
30
+    /**
31
+     * The singleton instance.
32
+     *
33
+     * @since  3.18.0
34
+     * @access private
35
+     * @var \Wordlift_Install_Service $instance A {@link Wordlift_Install_Service} instance.
36
+     */
37
+    private static $instance;
38
+
39
+    /**
40
+     * @var array
41
+     */
42
+    private $installs;
43
+
44
+    /**
45
+     * Wordlift_Install_Service constructor.
46
+     *
47
+     * @since 3.18.0
48
+     */
49
+    public function __construct() {
50
+
51
+        /** Installs. */
52
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install.php';
53
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-1-0-0.php';
54
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-10-0.php';
55
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-12-0.php';
56
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-14-0.php';
57
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-15-0.php';
58
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-0.php';
59
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-3.php';
60
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-19-5.php';
61
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-20-0.php';
62
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-23-4.php';
63
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-24-2.php';
64
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-all-entity-types.php';
65
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-package-type.php';
66
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-25-0.php';
67
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-0.php';
68
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-1.php';
69
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-28-0.php';
70
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-32-0.php';
71
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-33-9.php';
72
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-36-0.php';
73
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-38-5.php';
74
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-39-1.php';
75
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-40-1.php';
76
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-40-2.php';
77
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-41-0.php';
78
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-42-0.php';
79
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-44-1.php';
80
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-44-4.php';
81
+        // Get the install services.
82
+        $this->installs = array(
83
+            new Wordlift_Install_1_0_0(),
84
+            new Wordlift_Install_3_10_0(),
85
+            new Wordlift_Install_3_12_0(),
86
+            new Wordlift_Install_3_14_0(),
87
+            new Wordlift_Install_3_15_0(),
88
+            new Wordlift_Install_3_18_0(),
89
+            new Wordlift_Install_3_18_3(),
90
+            new Wordlift_Install_3_19_5(),
91
+            new Wordlift_Install_3_20_0(),
92
+
93
+            /*
94 94
 			 * This should be enabled with #852.
95 95
 			 */
96
-			new Wordlift_Install_Package_Type(),
97
-			new Wordlift_Install_3_23_4(),
98
-			new Wordlift_Install_3_24_2(),
99
-			new Wordlift_Install_3_25_0(),
100
-			new Wordlift_Install_3_27_0(),
101
-			new Wordlift_Install_3_27_1(),
102
-			new Wordlift_Install_3_28_0(),
103
-			// Add column to represent term
104
-			new Wordlift_Install_3_32_0(),
105
-			// Add the entities table.
106
-			new Wordlift_Install_3_33_9(),
107
-			// When woocommerce extension installed, acf4so should be installed automatically.
108
-			new Wordlift_Install_3_36_0(),
109
-
110
-			new Wordlift_Install_3_38_5(),
111
-			new Wordlift_Install_3_39_1(),
112
-
113
-			// See #1621.
114
-			new Wordlift_Install_3_40_1(),
115
-
116
-			// @link https://github.com/insideout10/wordlift-plugin/issues/1627
117
-			new Wordlift_Install_3_40_2(),
118
-
119
-			new Wordlift_Install_3_41_0(),
120
-			new Wordlift_Install_3_42_0(),
121
-
122
-			new Wordlift_Install_3_44_1(),
123
-			new Wordlift_Install_3_44_4(),
124
-		);
125
-		self::$instance = $this;
126
-
127
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
128
-
129
-		add_action( 'init', array( $this, 'install' ) );
130
-
131
-	}
132
-
133
-	/**
134
-	 * Get the singleton instance.
135
-	 *
136
-	 * @since 3.18.0
137
-	 */
138
-	public static function get_instance() {
139
-
140
-		return self::$instance;
141
-	}
142
-
143
-	/**
144
-	 * Loop thought all versions and install the updates.
145
-	 *
146
-	 * @return void
147
-	 * @since 3.18.0
148
-	 *
149
-	 * @since 3.20.0 use a transient to avoid concurrent installation calls.
150
-	 */
151
-	public function install() {
152
-
153
-		$version = null;
154
-
155
-		if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
156
-			set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
157
-			/** @var Wordlift_Install $install */
158
-			foreach ( $this->installs as $install ) {
159
-				// Get the install version.
160
-				$version = $install->get_version();
161
-
162
-				if ( version_compare( $version, $this->get_current_version(), '>' )
163
-					 || $install->must_install() ) {
164
-					$class_name = get_class( $install );
165
-
166
-					$this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
167
-					// Install version.
168
-					$install->install();
169
-
170
-					$this->log->info( "$class_name installed." );
171
-
172
-					// Bump the version.
173
-					update_option( 'wl_db_version', $version );
174
-				}
175
-			}
176
-
177
-			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
178
-			@delete_transient( '_wl_installing' );
179
-
180
-		}
181
-
182
-	}
183
-
184
-	private function install_required() {
185
-
186
-		/** @var Wordlift_Install $install */
187
-		foreach ( $this->installs as $install ) {
188
-			// Get the install version.
189
-			$version = $install->get_version();
190
-
191
-			if ( version_compare( $version, $this->get_current_version(), '>' )
192
-				 || $install->must_install() ) {
193
-				return true;
194
-			}
195
-		}
196
-
197
-		return false;
198
-	}
199
-
200
-	/**
201
-	 * Retrieve the current db version.
202
-	 *
203
-	 * @return type
204
-	 */
205
-	private function get_current_version() {
206
-		return get_option( 'wl_db_version', '0.0.0' );
207
-	}
96
+            new Wordlift_Install_Package_Type(),
97
+            new Wordlift_Install_3_23_4(),
98
+            new Wordlift_Install_3_24_2(),
99
+            new Wordlift_Install_3_25_0(),
100
+            new Wordlift_Install_3_27_0(),
101
+            new Wordlift_Install_3_27_1(),
102
+            new Wordlift_Install_3_28_0(),
103
+            // Add column to represent term
104
+            new Wordlift_Install_3_32_0(),
105
+            // Add the entities table.
106
+            new Wordlift_Install_3_33_9(),
107
+            // When woocommerce extension installed, acf4so should be installed automatically.
108
+            new Wordlift_Install_3_36_0(),
109
+
110
+            new Wordlift_Install_3_38_5(),
111
+            new Wordlift_Install_3_39_1(),
112
+
113
+            // See #1621.
114
+            new Wordlift_Install_3_40_1(),
115
+
116
+            // @link https://github.com/insideout10/wordlift-plugin/issues/1627
117
+            new Wordlift_Install_3_40_2(),
118
+
119
+            new Wordlift_Install_3_41_0(),
120
+            new Wordlift_Install_3_42_0(),
121
+
122
+            new Wordlift_Install_3_44_1(),
123
+            new Wordlift_Install_3_44_4(),
124
+        );
125
+        self::$instance = $this;
126
+
127
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
128
+
129
+        add_action( 'init', array( $this, 'install' ) );
130
+
131
+    }
132
+
133
+    /**
134
+     * Get the singleton instance.
135
+     *
136
+     * @since 3.18.0
137
+     */
138
+    public static function get_instance() {
139
+
140
+        return self::$instance;
141
+    }
142
+
143
+    /**
144
+     * Loop thought all versions and install the updates.
145
+     *
146
+     * @return void
147
+     * @since 3.18.0
148
+     *
149
+     * @since 3.20.0 use a transient to avoid concurrent installation calls.
150
+     */
151
+    public function install() {
152
+
153
+        $version = null;
154
+
155
+        if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
156
+            set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
157
+            /** @var Wordlift_Install $install */
158
+            foreach ( $this->installs as $install ) {
159
+                // Get the install version.
160
+                $version = $install->get_version();
161
+
162
+                if ( version_compare( $version, $this->get_current_version(), '>' )
163
+                     || $install->must_install() ) {
164
+                    $class_name = get_class( $install );
165
+
166
+                    $this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
167
+                    // Install version.
168
+                    $install->install();
169
+
170
+                    $this->log->info( "$class_name installed." );
171
+
172
+                    // Bump the version.
173
+                    update_option( 'wl_db_version', $version );
174
+                }
175
+            }
176
+
177
+            // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
178
+            @delete_transient( '_wl_installing' );
179
+
180
+        }
181
+
182
+    }
183
+
184
+    private function install_required() {
185
+
186
+        /** @var Wordlift_Install $install */
187
+        foreach ( $this->installs as $install ) {
188
+            // Get the install version.
189
+            $version = $install->get_version();
190
+
191
+            if ( version_compare( $version, $this->get_current_version(), '>' )
192
+                 || $install->must_install() ) {
193
+                return true;
194
+            }
195
+        }
196
+
197
+        return false;
198
+    }
199
+
200
+    /**
201
+     * Retrieve the current db version.
202
+     *
203
+     * @return type
204
+     */
205
+    private function get_current_version() {
206
+        return get_option( 'wl_db_version', '0.0.0' );
207
+    }
208 208
 
209 209
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -49,35 +49,35 @@  discard block
 block discarded – undo
49 49
 	public function __construct() {
50 50
 
51 51
 		/** Installs. */
52
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install.php';
53
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-1-0-0.php';
54
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-10-0.php';
55
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-12-0.php';
56
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-14-0.php';
57
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-15-0.php';
58
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-0.php';
59
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-3.php';
60
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-19-5.php';
61
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-20-0.php';
62
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-23-4.php';
63
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-24-2.php';
64
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-all-entity-types.php';
65
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-package-type.php';
66
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-25-0.php';
67
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-0.php';
68
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-1.php';
69
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-28-0.php';
70
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-32-0.php';
71
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-33-9.php';
72
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-36-0.php';
73
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-38-5.php';
74
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-39-1.php';
75
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-40-1.php';
76
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-40-2.php';
77
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-41-0.php';
78
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-42-0.php';
79
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-44-1.php';
80
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-44-4.php';
52
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install.php';
53
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-1-0-0.php';
54
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-10-0.php';
55
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-12-0.php';
56
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-14-0.php';
57
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-15-0.php';
58
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-18-0.php';
59
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-18-3.php';
60
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-19-5.php';
61
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-20-0.php';
62
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-23-4.php';
63
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-24-2.php';
64
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-all-entity-types.php';
65
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-package-type.php';
66
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-25-0.php';
67
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-27-0.php';
68
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-27-1.php';
69
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-28-0.php';
70
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-32-0.php';
71
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-33-9.php';
72
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-36-0.php';
73
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-38-5.php';
74
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-39-1.php';
75
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-40-1.php';
76
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-40-2.php';
77
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-41-0.php';
78
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-42-0.php';
79
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-44-1.php';
80
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-44-4.php';
81 81
 		// Get the install services.
82 82
 		$this->installs = array(
83 83
 			new Wordlift_Install_1_0_0(),
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 		);
125 125
 		self::$instance = $this;
126 126
 
127
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
127
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
128 128
 
129
-		add_action( 'init', array( $this, 'install' ) );
129
+		add_action('init', array($this, 'install'));
130 130
 
131 131
 	}
132 132
 
@@ -152,30 +152,30 @@  discard block
 block discarded – undo
152 152
 
153 153
 		$version = null;
154 154
 
155
-		if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
156
-			set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
155
+		if ($this->install_required() && false === get_transient('_wl_installing')) {
156
+			set_transient('_wl_installing', true, 5 * MINUTE_IN_SECONDS);
157 157
 			/** @var Wordlift_Install $install */
158
-			foreach ( $this->installs as $install ) {
158
+			foreach ($this->installs as $install) {
159 159
 				// Get the install version.
160 160
 				$version = $install->get_version();
161 161
 
162
-				if ( version_compare( $version, $this->get_current_version(), '>' )
163
-					 || $install->must_install() ) {
164
-					$class_name = get_class( $install );
162
+				if (version_compare($version, $this->get_current_version(), '>')
163
+					 || $install->must_install()) {
164
+					$class_name = get_class($install);
165 165
 
166
-					$this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
166
+					$this->log->info("Current version is {$this->get_current_version()}, installing $class_name...");
167 167
 					// Install version.
168 168
 					$install->install();
169 169
 
170
-					$this->log->info( "$class_name installed." );
170
+					$this->log->info("$class_name installed.");
171 171
 
172 172
 					// Bump the version.
173
-					update_option( 'wl_db_version', $version );
173
+					update_option('wl_db_version', $version);
174 174
 				}
175 175
 			}
176 176
 
177 177
 			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
178
-			@delete_transient( '_wl_installing' );
178
+			@delete_transient('_wl_installing');
179 179
 
180 180
 		}
181 181
 
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
 	private function install_required() {
185 185
 
186 186
 		/** @var Wordlift_Install $install */
187
-		foreach ( $this->installs as $install ) {
187
+		foreach ($this->installs as $install) {
188 188
 			// Get the install version.
189 189
 			$version = $install->get_version();
190 190
 
191
-			if ( version_compare( $version, $this->get_current_version(), '>' )
192
-				 || $install->must_install() ) {
191
+			if (version_compare($version, $this->get_current_version(), '>')
192
+				 || $install->must_install()) {
193 193
 				return true;
194 194
 			}
195 195
 		}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @return type
204 204
 	 */
205 205
 	private function get_current_version() {
206
-		return get_option( 'wl_db_version', '0.0.0' );
206
+		return get_option('wl_db_version', '0.0.0');
207 207
 	}
208 208
 
209 209
 }
Please login to merge, or discard this patch.
src/modules/dashboard/load.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -21,67 +21,67 @@  discard block
 block discarded – undo
21 21
  */
22 22
 function __wl_dashboard__load() {
23 23
 
24
-	// Dashboard is available only for Food Kg and Gardening Kg atm
25
-	// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
26
-	if ( ! apply_filters( 'wl_feature__enable__food-kg', false ) && ! apply_filters( 'wl_feature__enable__gardening-kg', false ) ) {
27
-		return;
28
-	}
24
+    // Dashboard is available only for Food Kg and Gardening Kg atm
25
+    // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
26
+    if ( ! apply_filters( 'wl_feature__enable__food-kg', false ) && ! apply_filters( 'wl_feature__enable__gardening-kg', false ) ) {
27
+        return;
28
+    }
29 29
 
30
-	// Autoloader for plugin itself.
31
-	if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
32
-		require_once __DIR__ . '/vendor/autoload.php';
33
-	}
30
+    // Autoloader for plugin itself.
31
+    if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
32
+        require_once __DIR__ . '/vendor/autoload.php';
33
+    }
34 34
 
35
-	$container_builder = new ContainerBuilder();
36
-	$loader            = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) );
37
-	$loader->load( 'services.yml' );
38
-	$container_builder->compile();
35
+    $container_builder = new ContainerBuilder();
36
+    $loader            = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) );
37
+    $loader->load( 'services.yml' );
38
+    $container_builder->compile();
39 39
 
40
-	/**
41
-	 * @var $rest_controller Rest_Controller
42
-	 */
43
-	$rest_controller = $container_builder->get( 'Wordlift\Modules\Dashboard\Synchronization\Rest_Controller' );
44
-	$rest_controller->register_hooks();
40
+    /**
41
+     * @var $rest_controller Rest_Controller
42
+     */
43
+    $rest_controller = $container_builder->get( 'Wordlift\Modules\Dashboard\Synchronization\Rest_Controller' );
44
+    $rest_controller->register_hooks();
45 45
 
46
-	/**
47
-	 * @var $term_entity_match_rest_controller Term_Entity_Match_Rest_Controller
48
-	 */
49
-	$term_entity_match_rest_controller = $container_builder->get( Term_Entity_Match_Rest_Controller::class );
50
-	$term_entity_match_rest_controller->register_hooks();
46
+    /**
47
+     * @var $term_entity_match_rest_controller Term_Entity_Match_Rest_Controller
48
+     */
49
+    $term_entity_match_rest_controller = $container_builder->get( Term_Entity_Match_Rest_Controller::class );
50
+    $term_entity_match_rest_controller->register_hooks();
51 51
 
52
-	/**
53
-	 * @var $term_entity_match_rest_controller \Wordlift\Modules\Dashboard\Post_Entity_Match\Post_Entity_Match_Rest_Controller
54
-	 */
55
-	$post_entity_match_rest_controller = $container_builder->get( \Wordlift\Modules\Dashboard\Post_Entity_Match\Post_Entity_Match_Rest_Controller::class );
56
-	$post_entity_match_rest_controller->register_hooks();
52
+    /**
53
+     * @var $term_entity_match_rest_controller \Wordlift\Modules\Dashboard\Post_Entity_Match\Post_Entity_Match_Rest_Controller
54
+     */
55
+    $post_entity_match_rest_controller = $container_builder->get( \Wordlift\Modules\Dashboard\Post_Entity_Match\Post_Entity_Match_Rest_Controller::class );
56
+    $post_entity_match_rest_controller->register_hooks();
57 57
 
58
-	/**
59
-	 * @var $synchronization_service Synchronization_Service
60
-	 */
61
-	$synchronization_service = $container_builder->get( 'Wordlift\Modules\Dashboard\Synchronization\Synchronization_Service' );
62
-	$synchronization_service->register_hooks();
58
+    /**
59
+     * @var $synchronization_service Synchronization_Service
60
+     */
61
+    $synchronization_service = $container_builder->get( 'Wordlift\Modules\Dashboard\Synchronization\Synchronization_Service' );
62
+    $synchronization_service->register_hooks();
63 63
 
64
-	$app_settings = $container_builder->get( App_Settings::class );
65
-	$app_settings->register_hooks();
64
+    $app_settings = $container_builder->get( App_Settings::class );
65
+    $app_settings->register_hooks();
66 66
 
67
-	/** Admin Menu */
68
-	add_action(
69
-		'admin_menu',
70
-		function () {
71
-			add_submenu_page( 'wl_admin_menu', __( 'Dashboard', 'wordlift' ), __( 'Dashboard', 'wordlift' ), 'manage_options', 'wl_admin_menu', '_wl_dashboard__main' );
72
-		},
73
-		9
74
-	);
67
+    /** Admin Menu */
68
+    add_action(
69
+        'admin_menu',
70
+        function () {
71
+            add_submenu_page( 'wl_admin_menu', __( 'Dashboard', 'wordlift' ), __( 'Dashboard', 'wordlift' ), 'manage_options', 'wl_admin_menu', '_wl_dashboard__main' );
72
+        },
73
+        9
74
+    );
75 75
 
76
-	add_action(
77
-		'_wl_dashboard__main',
78
-		function () {
79
-			// why not wp_enqueue_script ? because the iframe will start loading and it won't find the
80
-			// settings in parent window if it's not printed before.
81
-			wp_print_scripts( WL_ANGULAR_APP_SCRIPT_HANDLE );
82
-			$iframe_src = WL_ANGULAR_APP_URL . '#/admin/dashboard';
83
-			// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
84
-			echo "
76
+    add_action(
77
+        '_wl_dashboard__main',
78
+        function () {
79
+            // why not wp_enqueue_script ? because the iframe will start loading and it won't find the
80
+            // settings in parent window if it's not printed before.
81
+            wp_print_scripts( WL_ANGULAR_APP_SCRIPT_HANDLE );
82
+            $iframe_src = WL_ANGULAR_APP_URL . '#/admin/dashboard';
83
+            // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
84
+            echo "
85 85
 			<style>
86 86
 			    #wlx-plugin-app {
87 87
 			      margin-left: -20px;
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 			<iframe id='wlx-plugin-app' src='$iframe_src'></iframe>
93 93
             ";
94 94
 
95
-		}
96
-	);
95
+        }
96
+    );
97 97
 
98 98
 }
99 99
 
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -23,63 +23,63 @@
 block discarded – undo
23 23
 
24 24
 	// Dashboard is available only for Food Kg and Gardening Kg atm
25 25
 	// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
26
-	if ( ! apply_filters( 'wl_feature__enable__food-kg', false ) && ! apply_filters( 'wl_feature__enable__gardening-kg', false ) ) {
26
+	if ( ! apply_filters('wl_feature__enable__food-kg', false) && ! apply_filters('wl_feature__enable__gardening-kg', false)) {
27 27
 		return;
28 28
 	}
29 29
 
30 30
 	// Autoloader for plugin itself.
31
-	if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
32
-		require_once __DIR__ . '/vendor/autoload.php';
31
+	if (file_exists(__DIR__.'/vendor/autoload.php')) {
32
+		require_once __DIR__.'/vendor/autoload.php';
33 33
 	}
34 34
 
35 35
 	$container_builder = new ContainerBuilder();
36
-	$loader            = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) );
37
-	$loader->load( 'services.yml' );
36
+	$loader            = new YamlFileLoader($container_builder, new FileLocator(__DIR__));
37
+	$loader->load('services.yml');
38 38
 	$container_builder->compile();
39 39
 
40 40
 	/**
41 41
 	 * @var $rest_controller Rest_Controller
42 42
 	 */
43
-	$rest_controller = $container_builder->get( 'Wordlift\Modules\Dashboard\Synchronization\Rest_Controller' );
43
+	$rest_controller = $container_builder->get('Wordlift\Modules\Dashboard\Synchronization\Rest_Controller');
44 44
 	$rest_controller->register_hooks();
45 45
 
46 46
 	/**
47 47
 	 * @var $term_entity_match_rest_controller Term_Entity_Match_Rest_Controller
48 48
 	 */
49
-	$term_entity_match_rest_controller = $container_builder->get( Term_Entity_Match_Rest_Controller::class );
49
+	$term_entity_match_rest_controller = $container_builder->get(Term_Entity_Match_Rest_Controller::class);
50 50
 	$term_entity_match_rest_controller->register_hooks();
51 51
 
52 52
 	/**
53 53
 	 * @var $term_entity_match_rest_controller \Wordlift\Modules\Dashboard\Post_Entity_Match\Post_Entity_Match_Rest_Controller
54 54
 	 */
55
-	$post_entity_match_rest_controller = $container_builder->get( \Wordlift\Modules\Dashboard\Post_Entity_Match\Post_Entity_Match_Rest_Controller::class );
55
+	$post_entity_match_rest_controller = $container_builder->get(\Wordlift\Modules\Dashboard\Post_Entity_Match\Post_Entity_Match_Rest_Controller::class);
56 56
 	$post_entity_match_rest_controller->register_hooks();
57 57
 
58 58
 	/**
59 59
 	 * @var $synchronization_service Synchronization_Service
60 60
 	 */
61
-	$synchronization_service = $container_builder->get( 'Wordlift\Modules\Dashboard\Synchronization\Synchronization_Service' );
61
+	$synchronization_service = $container_builder->get('Wordlift\Modules\Dashboard\Synchronization\Synchronization_Service');
62 62
 	$synchronization_service->register_hooks();
63 63
 
64
-	$app_settings = $container_builder->get( App_Settings::class );
64
+	$app_settings = $container_builder->get(App_Settings::class);
65 65
 	$app_settings->register_hooks();
66 66
 
67 67
 	/** Admin Menu */
68 68
 	add_action(
69 69
 		'admin_menu',
70
-		function () {
71
-			add_submenu_page( 'wl_admin_menu', __( 'Dashboard', 'wordlift' ), __( 'Dashboard', 'wordlift' ), 'manage_options', 'wl_admin_menu', '_wl_dashboard__main' );
70
+		function() {
71
+			add_submenu_page('wl_admin_menu', __('Dashboard', 'wordlift'), __('Dashboard', 'wordlift'), 'manage_options', 'wl_admin_menu', '_wl_dashboard__main');
72 72
 		},
73 73
 		9
74 74
 	);
75 75
 
76 76
 	add_action(
77 77
 		'_wl_dashboard__main',
78
-		function () {
78
+		function() {
79 79
 			// why not wp_enqueue_script ? because the iframe will start loading and it won't find the
80 80
 			// settings in parent window if it's not printed before.
81
-			wp_print_scripts( WL_ANGULAR_APP_SCRIPT_HANDLE );
82
-			$iframe_src = WL_ANGULAR_APP_URL . '#/admin/dashboard';
81
+			wp_print_scripts(WL_ANGULAR_APP_SCRIPT_HANDLE);
82
+			$iframe_src = WL_ANGULAR_APP_URL.'#/admin/dashboard';
83 83
 			// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
84 84
 			echo "
85 85
 			<style>
Please login to merge, or discard this patch.
src/modules/dashboard/includes/Match/Match_Query_Builder.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -5,104 +5,104 @@
 block discarded – undo
5 5
 use Wordlift\Assertions;
6 6
 
7 7
 abstract class Match_Query_Builder {
8
-	/**
9
-	 * @var array
10
-	 */
11
-	protected $params;
12
-	/**
13
-	 * @var Match_Sort
14
-	 */
15
-	protected $sort;
16
-
17
-	protected $sql = '';
18
-
19
-	/**
20
-	 * @param $params array
21
-	 * @param $sort Match_Sort
22
-	 *
23
-	 * @throws \Exception Throws Exception if the parameters arent of right type.
24
-	 */
25
-	public function __construct( $params, $sort ) {
26
-
27
-		Assertions::is_array( $params );
28
-		Assertions::is_a( $sort, Match_Sort::class );
29
-
30
-		$this->params = $params;
31
-		$this->sort   = $sort;
32
-	}
33
-
34
-	/**
35
-	 * This method should build the query from params and sort object,
36
-	 * then return the prepared query.
37
-	 *
38
-	 * @return string
39
-	 */
40
-	public function get() {
41
-		$this->build();
42
-
43
-		return $this->sql;
44
-	}
45
-
46
-	/**
47
-	 * @return void
48
-	 */
49
-	abstract protected function build();
50
-
51
-	/**
52
-	 * Apply the sort for the cursor.
53
-	 *
54
-	 * @return Match_Query_Builder
55
-	 */
56
-	protected function cursor() {
57
-		global $wpdb;
58
-		$tmp_sql             = " AND {$this->sort->get_field_name()} ";
59
-		$is_included         = ( $this->params['element'] !== 'EXCLUDED' );
60
-		$is_ascending        = ( $this->params['direction'] !== 'DESCENDING' );
61
-		$is_sorted_ascending = $this->sort->is_ascending();
62
-		switch ( array( $is_ascending, $is_sorted_ascending ) ) {
63
-			case array( true, true ):   // Forward & Ascending Order
64
-			case array( false, false ): // Backward & Descending Order
65
-				$tmp_sql .= ' >';
66
-				break;
67
-			case array( true, false ):  // Forward & Ascending Order
68
-			case array( false, true ):  // Backward & Descending Order
69
-				$tmp_sql .= ' <';
70
-				break;
71
-		}
72
-		if ( $is_included ) {
73
-			$tmp_sql .= '=';
74
-		}
75
-		$tmp_sql .= ' %s';
76
-
77
-		// `$tmp_sql` is built dynamically in this function
78
-		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
79
-		$this->sql .= $wpdb->prepare( $tmp_sql, $this->params['position'] );
80
-		return $this;
81
-	}
82
-
83
-	protected function has_match() {
84
-		$value = $this->params['has_match'];
85
-
86
-		if ( true === $value ) {
87
-			$this->sql .= ' AND e.about_jsonld IS NOT NULL ';
88
-		} elseif ( false === $value ) {
89
-			$this->sql .= ' AND e.about_jsonld IS NULL ';
90
-		}
91
-
92
-		return $this;
93
-	}
94
-
95
-	protected function limit() {
96
-		$limit = $this->params['limit'];
97
-		global $wpdb;
98
-		$this->sql .= $wpdb->prepare( ' LIMIT %d', $limit );
99
-		return $this;
100
-	}
101
-
102
-	protected function order_by() {
103
-		$direction  = $this->params['direction'];
104
-		$this->sql .= $this->sort->get_orderby_clause( $direction );
105
-		return $this;
106
-	}
8
+    /**
9
+     * @var array
10
+     */
11
+    protected $params;
12
+    /**
13
+     * @var Match_Sort
14
+     */
15
+    protected $sort;
16
+
17
+    protected $sql = '';
18
+
19
+    /**
20
+     * @param $params array
21
+     * @param $sort Match_Sort
22
+     *
23
+     * @throws \Exception Throws Exception if the parameters arent of right type.
24
+     */
25
+    public function __construct( $params, $sort ) {
26
+
27
+        Assertions::is_array( $params );
28
+        Assertions::is_a( $sort, Match_Sort::class );
29
+
30
+        $this->params = $params;
31
+        $this->sort   = $sort;
32
+    }
33
+
34
+    /**
35
+     * This method should build the query from params and sort object,
36
+     * then return the prepared query.
37
+     *
38
+     * @return string
39
+     */
40
+    public function get() {
41
+        $this->build();
42
+
43
+        return $this->sql;
44
+    }
45
+
46
+    /**
47
+     * @return void
48
+     */
49
+    abstract protected function build();
50
+
51
+    /**
52
+     * Apply the sort for the cursor.
53
+     *
54
+     * @return Match_Query_Builder
55
+     */
56
+    protected function cursor() {
57
+        global $wpdb;
58
+        $tmp_sql             = " AND {$this->sort->get_field_name()} ";
59
+        $is_included         = ( $this->params['element'] !== 'EXCLUDED' );
60
+        $is_ascending        = ( $this->params['direction'] !== 'DESCENDING' );
61
+        $is_sorted_ascending = $this->sort->is_ascending();
62
+        switch ( array( $is_ascending, $is_sorted_ascending ) ) {
63
+            case array( true, true ):   // Forward & Ascending Order
64
+            case array( false, false ): // Backward & Descending Order
65
+                $tmp_sql .= ' >';
66
+                break;
67
+            case array( true, false ):  // Forward & Ascending Order
68
+            case array( false, true ):  // Backward & Descending Order
69
+                $tmp_sql .= ' <';
70
+                break;
71
+        }
72
+        if ( $is_included ) {
73
+            $tmp_sql .= '=';
74
+        }
75
+        $tmp_sql .= ' %s';
76
+
77
+        // `$tmp_sql` is built dynamically in this function
78
+        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
79
+        $this->sql .= $wpdb->prepare( $tmp_sql, $this->params['position'] );
80
+        return $this;
81
+    }
82
+
83
+    protected function has_match() {
84
+        $value = $this->params['has_match'];
85
+
86
+        if ( true === $value ) {
87
+            $this->sql .= ' AND e.about_jsonld IS NOT NULL ';
88
+        } elseif ( false === $value ) {
89
+            $this->sql .= ' AND e.about_jsonld IS NULL ';
90
+        }
91
+
92
+        return $this;
93
+    }
94
+
95
+    protected function limit() {
96
+        $limit = $this->params['limit'];
97
+        global $wpdb;
98
+        $this->sql .= $wpdb->prepare( ' LIMIT %d', $limit );
99
+        return $this;
100
+    }
101
+
102
+    protected function order_by() {
103
+        $direction  = $this->params['direction'];
104
+        $this->sql .= $this->sort->get_orderby_clause( $direction );
105
+        return $this;
106
+    }
107 107
 
108 108
 }
Please login to merge, or discard this patch.
src/modules/dashboard/includes/Match/Match_Service.php 2 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -6,93 +6,93 @@
 block discarded – undo
6 6
 
7 7
 abstract class Match_Service {
8 8
 
9
-	/**
10
-	 * @param $content_id
11
-	 * @param $content_type
12
-	 * @param $match_id
13
-	 * @param $jsonld
14
-	 *
15
-	 * @return Match_Entry
16
-	 * @throws \Exception Throw Exception if the jsonld cant be set.
17
-	 */
18
-	public function set_jsonld( $content_id, $content_type, $match_id, $jsonld ) {
9
+    /**
10
+     * @param $content_id
11
+     * @param $content_type
12
+     * @param $match_id
13
+     * @param $jsonld
14
+     *
15
+     * @return Match_Entry
16
+     * @throws \Exception Throw Exception if the jsonld cant be set.
17
+     */
18
+    public function set_jsonld( $content_id, $content_type, $match_id, $jsonld ) {
19 19
 
20
-		global $wpdb;
20
+        global $wpdb;
21 21
 
22
-		/**
23
-		 * As of May 16 2023, $wpdb:prepare doesnt support null
24
-		 * values in about_jsonld, this results in NULL values being populated
25
-		 * as `null` if we directly pass it to the prepare function(). So its necessary
26
-		 * to make the query conditional based on the $value
27
-		 */
28
-		if ( null === $jsonld ) {
29
-			$wpdb->query(
30
-				$wpdb->prepare(
31
-					"UPDATE {$wpdb->prefix}wl_entities SET about_jsonld = NULL WHERE id = %d AND content_id = %d AND content_type = %d",
32
-					$match_id,
33
-					$content_id,
34
-					$content_type
35
-				)
36
-			);
37
-		} else {
38
-			$wpdb->query(
39
-				$wpdb->prepare(
40
-					"UPDATE {$wpdb->prefix}wl_entities SET about_jsonld = %s WHERE id = %d AND content_id = %d AND content_type = %d",
41
-					wp_json_encode( $jsonld ),
42
-					$match_id,
43
-					$content_id,
44
-					$content_type
45
-				)
46
-			);
47
-		}
22
+        /**
23
+         * As of May 16 2023, $wpdb:prepare doesnt support null
24
+         * values in about_jsonld, this results in NULL values being populated
25
+         * as `null` if we directly pass it to the prepare function(). So its necessary
26
+         * to make the query conditional based on the $value
27
+         */
28
+        if ( null === $jsonld ) {
29
+            $wpdb->query(
30
+                $wpdb->prepare(
31
+                    "UPDATE {$wpdb->prefix}wl_entities SET about_jsonld = NULL WHERE id = %d AND content_id = %d AND content_type = %d",
32
+                    $match_id,
33
+                    $content_id,
34
+                    $content_type
35
+                )
36
+            );
37
+        } else {
38
+            $wpdb->query(
39
+                $wpdb->prepare(
40
+                    "UPDATE {$wpdb->prefix}wl_entities SET about_jsonld = %s WHERE id = %d AND content_id = %d AND content_type = %d",
41
+                    wp_json_encode( $jsonld ),
42
+                    $match_id,
43
+                    $content_id,
44
+                    $content_type
45
+                )
46
+            );
47
+        }
48 48
 
49
-		if ( Object_Type_Enum::TERM === $content_type ) {
49
+        if ( Object_Type_Enum::TERM === $content_type ) {
50 50
 
51
-			$query = "SELECT e.content_id as match_id, e.about_jsonld as match_jsonld,  t.name,  e.id FROM {$wpdb->prefix}wl_entities e
51
+            $query = "SELECT e.content_id as match_id, e.about_jsonld as match_jsonld,  t.name,  e.id FROM {$wpdb->prefix}wl_entities e
52 52
                   LEFT JOIN {$wpdb->prefix}terms t ON e.content_id = t.term_id
53 53
                   WHERE  e.id = %d AND e.content_id = %d AND e.content_type = %d";
54
-			// `{$wpdb->prefix}` cant be escaped for preparing.
55
-			// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
56
-			$results = $wpdb->get_row( $wpdb->prepare( $query, $match_id, $content_id, $content_type ), ARRAY_A );
57
-			return Match_Entry::from( $results );
58
-		}
54
+            // `{$wpdb->prefix}` cant be escaped for preparing.
55
+            // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
56
+            $results = $wpdb->get_row( $wpdb->prepare( $query, $match_id, $content_id, $content_type ), ARRAY_A );
57
+            return Match_Entry::from( $results );
58
+        }
59 59
 
60
-		if ( Object_Type_Enum::POST === $content_type ) {
60
+        if ( Object_Type_Enum::POST === $content_type ) {
61 61
 
62
-			$query = "SELECT e.content_id as match_id, e.about_jsonld as match_jsonld,  p.post_title AS name,  e.id FROM {$wpdb->prefix}wl_entities e
62
+            $query = "SELECT e.content_id as match_id, e.about_jsonld as match_jsonld,  p.post_title AS name,  e.id FROM {$wpdb->prefix}wl_entities e
63 63
                   LEFT JOIN {$wpdb->prefix}posts p ON e.content_id = p.ID
64 64
                   WHERE  e.id = %d AND e.content_id = %d AND e.content_type = %d";
65
-			// `{$wpdb->prefix}` cant be escaped for preparing.
66
-			// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
67
-			$results = $wpdb->get_row( $wpdb->prepare( $query, $match_id, $content_id, $content_type ), ARRAY_A );
65
+            // `{$wpdb->prefix}` cant be escaped for preparing.
66
+            // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
67
+            $results = $wpdb->get_row( $wpdb->prepare( $query, $match_id, $content_id, $content_type ), ARRAY_A );
68 68
 
69
-			return Match_Entry::from( $results );
70
-		}
69
+            return Match_Entry::from( $results );
70
+        }
71 71
 
72
-	}
72
+    }
73 73
 
74
-	/**
75
-	 * @param $content_id int
76
-	 * @param $content_type int
77
-	 * @throws \Exception Throw Exception if the entry is not found.
78
-	 * @return int
79
-	 */
80
-	public function get_id( $content_id, $content_type ) {
81
-		global $wpdb;
82
-		$result = $wpdb->get_var(
83
-			// `{$wpdb->prefix}` cant be escaped for preparing.
84
-			// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
85
-			$wpdb->prepare(
86
-				"SELECT id FROM {$wpdb->prefix}wl_entities WHERE content_id = %d AND content_type = %d",
87
-				$content_id,
88
-				$content_type
89
-			)
90
-		);
91
-		if ( null === $result ) {
92
-			throw new \Exception( "Unable to find match id for {$content_id} and {$content_type}" );
93
-		}
74
+    /**
75
+     * @param $content_id int
76
+     * @param $content_type int
77
+     * @throws \Exception Throw Exception if the entry is not found.
78
+     * @return int
79
+     */
80
+    public function get_id( $content_id, $content_type ) {
81
+        global $wpdb;
82
+        $result = $wpdb->get_var(
83
+            // `{$wpdb->prefix}` cant be escaped for preparing.
84
+            // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
85
+            $wpdb->prepare(
86
+                "SELECT id FROM {$wpdb->prefix}wl_entities WHERE content_id = %d AND content_type = %d",
87
+                $content_id,
88
+                $content_type
89
+            )
90
+        );
91
+        if ( null === $result ) {
92
+            throw new \Exception( "Unable to find match id for {$content_id} and {$content_type}" );
93
+        }
94 94
 
95
-		return $result;
96
-	}
95
+        return $result;
96
+    }
97 97
 
98 98
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 * @return Match_Entry
16 16
 	 * @throws \Exception Throw Exception if the jsonld cant be set.
17 17
 	 */
18
-	public function set_jsonld( $content_id, $content_type, $match_id, $jsonld ) {
18
+	public function set_jsonld($content_id, $content_type, $match_id, $jsonld) {
19 19
 
20 20
 		global $wpdb;
21 21
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 		 * as `null` if we directly pass it to the prepare function(). So its necessary
26 26
 		 * to make the query conditional based on the $value
27 27
 		 */
28
-		if ( null === $jsonld ) {
28
+		if (null === $jsonld) {
29 29
 			$wpdb->query(
30 30
 				$wpdb->prepare(
31 31
 					"UPDATE {$wpdb->prefix}wl_entities SET about_jsonld = NULL WHERE id = %d AND content_id = %d AND content_type = %d",
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 			$wpdb->query(
39 39
 				$wpdb->prepare(
40 40
 					"UPDATE {$wpdb->prefix}wl_entities SET about_jsonld = %s WHERE id = %d AND content_id = %d AND content_type = %d",
41
-					wp_json_encode( $jsonld ),
41
+					wp_json_encode($jsonld),
42 42
 					$match_id,
43 43
 					$content_id,
44 44
 					$content_type
@@ -46,27 +46,27 @@  discard block
 block discarded – undo
46 46
 			);
47 47
 		}
48 48
 
49
-		if ( Object_Type_Enum::TERM === $content_type ) {
49
+		if (Object_Type_Enum::TERM === $content_type) {
50 50
 
51 51
 			$query = "SELECT e.content_id as match_id, e.about_jsonld as match_jsonld,  t.name,  e.id FROM {$wpdb->prefix}wl_entities e
52 52
                   LEFT JOIN {$wpdb->prefix}terms t ON e.content_id = t.term_id
53 53
                   WHERE  e.id = %d AND e.content_id = %d AND e.content_type = %d";
54 54
 			// `{$wpdb->prefix}` cant be escaped for preparing.
55 55
 			// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
56
-			$results = $wpdb->get_row( $wpdb->prepare( $query, $match_id, $content_id, $content_type ), ARRAY_A );
57
-			return Match_Entry::from( $results );
56
+			$results = $wpdb->get_row($wpdb->prepare($query, $match_id, $content_id, $content_type), ARRAY_A);
57
+			return Match_Entry::from($results);
58 58
 		}
59 59
 
60
-		if ( Object_Type_Enum::POST === $content_type ) {
60
+		if (Object_Type_Enum::POST === $content_type) {
61 61
 
62 62
 			$query = "SELECT e.content_id as match_id, e.about_jsonld as match_jsonld,  p.post_title AS name,  e.id FROM {$wpdb->prefix}wl_entities e
63 63
                   LEFT JOIN {$wpdb->prefix}posts p ON e.content_id = p.ID
64 64
                   WHERE  e.id = %d AND e.content_id = %d AND e.content_type = %d";
65 65
 			// `{$wpdb->prefix}` cant be escaped for preparing.
66 66
 			// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
67
-			$results = $wpdb->get_row( $wpdb->prepare( $query, $match_id, $content_id, $content_type ), ARRAY_A );
67
+			$results = $wpdb->get_row($wpdb->prepare($query, $match_id, $content_id, $content_type), ARRAY_A);
68 68
 
69
-			return Match_Entry::from( $results );
69
+			return Match_Entry::from($results);
70 70
 		}
71 71
 
72 72
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @throws \Exception Throw Exception if the entry is not found.
78 78
 	 * @return int
79 79
 	 */
80
-	public function get_id( $content_id, $content_type ) {
80
+	public function get_id($content_id, $content_type) {
81 81
 		global $wpdb;
82 82
 		$result = $wpdb->get_var(
83 83
 			// `{$wpdb->prefix}` cant be escaped for preparing.
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 				$content_type
89 89
 			)
90 90
 		);
91
-		if ( null === $result ) {
92
-			throw new \Exception( "Unable to find match id for {$content_id} and {$content_type}" );
91
+		if (null === $result) {
92
+			throw new \Exception("Unable to find match id for {$content_id} and {$content_type}");
93 93
 		}
94 94
 
95 95
 		return $result;
Please login to merge, or discard this patch.
src/wordlift/content/wordpress/class-abstract-wordpress-content-service.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -10,121 +10,121 @@
 block discarded – undo
10 10
 // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledClassName
11 11
 abstract class Abstract_Wordpress_Content_Service implements Content_Service {
12 12
 
13
-	protected function __construct() {
13
+    protected function __construct() {
14 14
 
15
-	}
15
+    }
16 16
 
17
-	protected function get_dataset_uri() {
18
-		return trailingslashit( Wordlift_Configuration_Service::get_instance()->get_dataset_uri() );
19
-	}
17
+    protected function get_dataset_uri() {
18
+        return trailingslashit( Wordlift_Configuration_Service::get_instance()->get_dataset_uri() );
19
+    }
20 20
 
21
-	protected function is_absolute( $uri ) {
22
-		return 1 === preg_match( '@^https?://@', $uri );
23
-	}
21
+    protected function is_absolute( $uri ) {
22
+        return 1 === preg_match( '@^https?://@', $uri );
23
+    }
24 24
 
25
-	protected function is_internal( $uri ) {
26
-		$dataset_uri = $this->get_dataset_uri();
25
+    protected function is_internal( $uri ) {
26
+        $dataset_uri = $this->get_dataset_uri();
27 27
 
28
-		return ! empty( $dataset_uri ) && 0 === strpos( $uri, $dataset_uri );
29
-	}
28
+        return ! empty( $dataset_uri ) && 0 === strpos( $uri, $dataset_uri );
29
+    }
30 30
 
31
-	protected function make_absolute( $uri ) {
32
-		Assertions::not_empty( $this->get_dataset_uri(), '`dataset_uri` cannot be empty.' );
31
+    protected function make_absolute( $uri ) {
32
+        Assertions::not_empty( $this->get_dataset_uri(), '`dataset_uri` cannot be empty.' );
33 33
 
34
-		if ( 1 !== preg_match( '@^https?://@', $uri ) ) {
35
-			return $this->get_dataset_uri() . $uri;
36
-		}
34
+        if ( 1 !== preg_match( '@^https?://@', $uri ) ) {
35
+            return $this->get_dataset_uri() . $uri;
36
+        }
37 37
 
38
-		return $uri;
39
-	}
38
+        return $uri;
39
+    }
40 40
 
41
-	protected function make_relative( $uri ) {
42
-		$dataset_uri = $this->get_dataset_uri();
43
-		if ( 0 === strpos( $uri, $dataset_uri ) ) {
44
-			return substr( $uri, strlen( $dataset_uri ) );
45
-		}
41
+    protected function make_relative( $uri ) {
42
+        $dataset_uri = $this->get_dataset_uri();
43
+        if ( 0 === strpos( $uri, $dataset_uri ) ) {
44
+            return substr( $uri, strlen( $dataset_uri ) );
45
+        }
46 46
 
47
-		return $uri;
48
-	}
47
+        return $uri;
48
+    }
49 49
 
50
-	/**
51
-	 * @param Wordpress_Content_Id $content_id
52
-	 *
53
-	 * @return string|null
54
-	 */
55
-	public function get_about_jsonld( $content_id ) {
56
-		global $wpdb;
50
+    /**
51
+     * @param Wordpress_Content_Id $content_id
52
+     *
53
+     * @return string|null
54
+     */
55
+    public function get_about_jsonld( $content_id ) {
56
+        global $wpdb;
57 57
 
58
-		return $wpdb->get_var(
59
-			$wpdb->prepare(
60
-				"
58
+        return $wpdb->get_var(
59
+            $wpdb->prepare(
60
+                "
61 61
 			SELECT about_jsonld FROM {$wpdb->prefix}wl_entities
62 62
 			WHERE content_id = %d AND content_type = %d
63 63
 			",
64
-				$content_id->get_id(),
65
-				$content_id->get_type()
66
-			)
67
-		);
68
-	}
69
-
70
-	/**
71
-	 * @param Wordpress_Content_Id $content_id
72
-	 * @param string               $value
73
-	 */
74
-	public function set_about_jsonld( $content_id, $value ) {
75
-		global $wpdb;
76
-
77
-		// Cleanup value.
78
-		$value = ( is_string( $value ) && strlen( $value ) > 2 ) ? $value : null;
79
-
80
-		// This `hack` is necessary to ensure the entity exists in the entities table, but we
81
-		// should revise how this works really.
82
-		//
83
-		// This is currently needed because rel_uri is required in the table.
84
-		switch ( $content_id->get_type() ) {
85
-			case Object_Type_Enum::POST:
86
-				Wordpress_Dataset_Content_Service_Hooks::insert_post( $content_id->get_id() );
87
-				break;
88
-			case Object_Type_Enum::TERM:
89
-				Wordpress_Dataset_Content_Service_Hooks::created_term( $content_id->get_id() );
90
-				break;
91
-			case Object_Type_Enum::USER:
92
-				Wordpress_Dataset_Content_Service_Hooks::user_register( $content_id->get_id() );
93
-				break;
94
-		}
95
-
96
-		/**
97
-		 * As of May 16 2023, $wpdb:prepare doesnt support null
98
-		 * values in about_jsonld, this results in NULL values being populated
99
-		 * as `null` if we directly pass it to the prepare function(). So its necessary
100
-		 * to make the query conditional based on the $value
101
-		 */
102
-		if ( null === $value ) {
103
-			return $wpdb->query(
104
-				$wpdb->prepare(
105
-					"
64
+                $content_id->get_id(),
65
+                $content_id->get_type()
66
+            )
67
+        );
68
+    }
69
+
70
+    /**
71
+     * @param Wordpress_Content_Id $content_id
72
+     * @param string               $value
73
+     */
74
+    public function set_about_jsonld( $content_id, $value ) {
75
+        global $wpdb;
76
+
77
+        // Cleanup value.
78
+        $value = ( is_string( $value ) && strlen( $value ) > 2 ) ? $value : null;
79
+
80
+        // This `hack` is necessary to ensure the entity exists in the entities table, but we
81
+        // should revise how this works really.
82
+        //
83
+        // This is currently needed because rel_uri is required in the table.
84
+        switch ( $content_id->get_type() ) {
85
+            case Object_Type_Enum::POST:
86
+                Wordpress_Dataset_Content_Service_Hooks::insert_post( $content_id->get_id() );
87
+                break;
88
+            case Object_Type_Enum::TERM:
89
+                Wordpress_Dataset_Content_Service_Hooks::created_term( $content_id->get_id() );
90
+                break;
91
+            case Object_Type_Enum::USER:
92
+                Wordpress_Dataset_Content_Service_Hooks::user_register( $content_id->get_id() );
93
+                break;
94
+        }
95
+
96
+        /**
97
+         * As of May 16 2023, $wpdb:prepare doesnt support null
98
+         * values in about_jsonld, this results in NULL values being populated
99
+         * as `null` if we directly pass it to the prepare function(). So its necessary
100
+         * to make the query conditional based on the $value
101
+         */
102
+        if ( null === $value ) {
103
+            return $wpdb->query(
104
+                $wpdb->prepare(
105
+                    "
106 106
 			UPDATE {$wpdb->prefix}wl_entities
107 107
 			SET about_jsonld = NULL
108 108
 			WHERE content_id = %d AND content_type = %d
109 109
 			",
110
-					$content_id->get_id(),
111
-					$content_id->get_type()
112
-				)
113
-			);
114
-		}
115
-
116
-		return $wpdb->query(
117
-			$wpdb->prepare(
118
-				"
110
+                    $content_id->get_id(),
111
+                    $content_id->get_type()
112
+                )
113
+            );
114
+        }
115
+
116
+        return $wpdb->query(
117
+            $wpdb->prepare(
118
+                "
119 119
 			UPDATE {$wpdb->prefix}wl_entities
120 120
 			SET about_jsonld = %s
121 121
 			WHERE content_id = %d AND content_type = %d
122 122
 			",
123
-				$value,
124
-				$content_id->get_id(),
125
-				$content_id->get_type()
126
-			)
127
-		);
128
-	}
123
+                $value,
124
+                $content_id->get_id(),
125
+                $content_id->get_type()
126
+            )
127
+        );
128
+    }
129 129
 
130 130
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@  discard block
 block discarded – undo
15 15
 	}
16 16
 
17 17
 	protected function get_dataset_uri() {
18
-		return trailingslashit( Wordlift_Configuration_Service::get_instance()->get_dataset_uri() );
18
+		return trailingslashit(Wordlift_Configuration_Service::get_instance()->get_dataset_uri());
19 19
 	}
20 20
 
21
-	protected function is_absolute( $uri ) {
22
-		return 1 === preg_match( '@^https?://@', $uri );
21
+	protected function is_absolute($uri) {
22
+		return 1 === preg_match('@^https?://@', $uri);
23 23
 	}
24 24
 
25
-	protected function is_internal( $uri ) {
25
+	protected function is_internal($uri) {
26 26
 		$dataset_uri = $this->get_dataset_uri();
27 27
 
28
-		return ! empty( $dataset_uri ) && 0 === strpos( $uri, $dataset_uri );
28
+		return ! empty($dataset_uri) && 0 === strpos($uri, $dataset_uri);
29 29
 	}
30 30
 
31
-	protected function make_absolute( $uri ) {
32
-		Assertions::not_empty( $this->get_dataset_uri(), '`dataset_uri` cannot be empty.' );
31
+	protected function make_absolute($uri) {
32
+		Assertions::not_empty($this->get_dataset_uri(), '`dataset_uri` cannot be empty.');
33 33
 
34
-		if ( 1 !== preg_match( '@^https?://@', $uri ) ) {
35
-			return $this->get_dataset_uri() . $uri;
34
+		if (1 !== preg_match('@^https?://@', $uri)) {
35
+			return $this->get_dataset_uri().$uri;
36 36
 		}
37 37
 
38 38
 		return $uri;
39 39
 	}
40 40
 
41
-	protected function make_relative( $uri ) {
41
+	protected function make_relative($uri) {
42 42
 		$dataset_uri = $this->get_dataset_uri();
43
-		if ( 0 === strpos( $uri, $dataset_uri ) ) {
44
-			return substr( $uri, strlen( $dataset_uri ) );
43
+		if (0 === strpos($uri, $dataset_uri)) {
44
+			return substr($uri, strlen($dataset_uri));
45 45
 		}
46 46
 
47 47
 		return $uri;
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return string|null
54 54
 	 */
55
-	public function get_about_jsonld( $content_id ) {
55
+	public function get_about_jsonld($content_id) {
56 56
 		global $wpdb;
57 57
 
58 58
 		return $wpdb->get_var(
@@ -71,25 +71,25 @@  discard block
 block discarded – undo
71 71
 	 * @param Wordpress_Content_Id $content_id
72 72
 	 * @param string               $value
73 73
 	 */
74
-	public function set_about_jsonld( $content_id, $value ) {
74
+	public function set_about_jsonld($content_id, $value) {
75 75
 		global $wpdb;
76 76
 
77 77
 		// Cleanup value.
78
-		$value = ( is_string( $value ) && strlen( $value ) > 2 ) ? $value : null;
78
+		$value = (is_string($value) && strlen($value) > 2) ? $value : null;
79 79
 
80 80
 		// This `hack` is necessary to ensure the entity exists in the entities table, but we
81 81
 		// should revise how this works really.
82 82
 		//
83 83
 		// This is currently needed because rel_uri is required in the table.
84
-		switch ( $content_id->get_type() ) {
84
+		switch ($content_id->get_type()) {
85 85
 			case Object_Type_Enum::POST:
86
-				Wordpress_Dataset_Content_Service_Hooks::insert_post( $content_id->get_id() );
86
+				Wordpress_Dataset_Content_Service_Hooks::insert_post($content_id->get_id());
87 87
 				break;
88 88
 			case Object_Type_Enum::TERM:
89
-				Wordpress_Dataset_Content_Service_Hooks::created_term( $content_id->get_id() );
89
+				Wordpress_Dataset_Content_Service_Hooks::created_term($content_id->get_id());
90 90
 				break;
91 91
 			case Object_Type_Enum::USER:
92
-				Wordpress_Dataset_Content_Service_Hooks::user_register( $content_id->get_id() );
92
+				Wordpress_Dataset_Content_Service_Hooks::user_register($content_id->get_id());
93 93
 				break;
94 94
 		}
95 95
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		 * as `null` if we directly pass it to the prepare function(). So its necessary
100 100
 		 * to make the query conditional based on the $value
101 101
 		 */
102
-		if ( null === $value ) {
102
+		if (null === $value) {
103 103
 			return $wpdb->query(
104 104
 				$wpdb->prepare(
105 105
 					"
Please login to merge, or discard this patch.