Completed
Push — develop ( 86c636...1f5665 )
by David
02:02 queued 13s
created
src/wordlift.php 1 patch
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
  * @since 3.33.6
48 48
  */
49 49
 if ( ! apply_filters( 'wl_is_enabled', true ) ) {
50
-	return;
50
+    return;
51 51
 }
52 52
 
53 53
 require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
@@ -76,33 +76,33 @@  discard block
 block discarded – undo
76 76
  */
77 77
 function activate_wordlift() {
78 78
 
79
-	$log = Wordlift_Log_Service::get_logger( 'activate_wordlift' );
79
+    $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' );
80 80
 
81
-	$log->info( 'Activating WordLift...' );
81
+    $log->info( 'Activating WordLift...' );
82 82
 
83
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
84
-	Wordlift_Activator::activate();
83
+    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
84
+    Wordlift_Activator::activate();
85 85
 
86
-	/**
87
-	 * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks.
88
-	 *
89
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue.
90
-	 * @since 3.19.2
91
-	 */
92
-	Wordlift_Http_Api::activate();
86
+    /**
87
+     * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks.
88
+     *
89
+     * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue.
90
+     * @since 3.19.2
91
+     */
92
+    Wordlift_Http_Api::activate();
93 93
 
94
-	// Ensure the post type is registered before flushing the rewrite rules.
95
-	Wordlift_Entity_Post_Type_Service::get_instance()->register();
96
-	flush_rewrite_rules();
97
-	/**
98
-	 * @since 3.27.7
99
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/1214
100
-	 */
101
-	Top_Entities::activate();
94
+    // Ensure the post type is registered before flushing the rewrite rules.
95
+    Wordlift_Entity_Post_Type_Service::get_instance()->register();
96
+    flush_rewrite_rules();
97
+    /**
98
+     * @since 3.27.7
99
+     * @see https://github.com/insideout10/wordlift-plugin/issues/1214
100
+     */
101
+    Top_Entities::activate();
102 102
 
103
-	if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) {
104
-		wp_schedule_event( time(), 'daily', 'wl_daily_cron' );
105
-	}
103
+    if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) {
104
+        wp_schedule_event( time(), 'daily', 'wl_daily_cron' );
105
+    }
106 106
 
107 107
 }
108 108
 
@@ -112,23 +112,23 @@  discard block
 block discarded – undo
112 112
  */
113 113
 function deactivate_wordlift() {
114 114
 
115
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
116
-	Wordlift_Deactivator::deactivate();
117
-	Wordlift_Http_Api::deactivate();
118
-	Ttl_Cache_Cleaner::deactivate();
119
-	/**
120
-	 * @since 3.27.7
121
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/1214
122
-	 */
123
-	Top_Entities::deactivate();
124
-	/**
125
-	 * @since 3.27.8
126
-	 * Remove notification flag on deactivation.
127
-	 */
128
-	Key_Validation_Notice::remove_notification_flag();
129
-	flush_rewrite_rules();
130
-
131
-	wp_clear_scheduled_hook( 'wl_daily_cron' );
115
+    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
116
+    Wordlift_Deactivator::deactivate();
117
+    Wordlift_Http_Api::deactivate();
118
+    Ttl_Cache_Cleaner::deactivate();
119
+    /**
120
+     * @since 3.27.7
121
+     * @see https://github.com/insideout10/wordlift-plugin/issues/1214
122
+     */
123
+    Top_Entities::deactivate();
124
+    /**
125
+     * @since 3.27.8
126
+     * Remove notification flag on deactivation.
127
+     */
128
+    Key_Validation_Notice::remove_notification_flag();
129
+    flush_rewrite_rules();
130
+
131
+    wp_clear_scheduled_hook( 'wl_daily_cron' );
132 132
 
133 133
 }
134 134
 
@@ -151,84 +151,84 @@  discard block
 block discarded – undo
151 151
  * @since    1.0.0
152 152
  */
153 153
 function run_wordlift() {
154
-	/**
155
-	 * Filter: wl_feature__enable__widgets.
156
-	 *
157
-	 * @param bool whether the widgets needed to be registered, defaults to true.
158
-	 *
159
-	 * @return bool
160
-	 * @since 3.27.6
161
-	 */
162
-	if ( apply_filters( 'wl_feature__enable__widgets', true ) ) {
163
-		add_action( 'widgets_init', 'wl_register_chord_widget' );
164
-		add_action( 'widgets_init', 'wl_register_geo_widget' );
165
-		add_action( 'widgets_init', 'wl_register_timeline_widget' );
166
-	}
167
-	add_filter( 'widget_text', 'do_shortcode' );
168
-
169
-	/**
170
-	 * Filter: wl_feature__enable__analysis
171
-	 *
172
-	 * @param bool Whether to send api request to analysis or not
173
-	 *
174
-	 * @return bool
175
-	 * @since 3.27.6
176
-	 */
177
-	if ( apply_filters( 'wl_feature__enable__analysis', true ) ) {
178
-		add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' );
179
-	} else {
180
-		add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' );
181
-	}
182
-
183
-	$plugin = new Wordlift();
184
-	$plugin->run();
185
-
186
-	// Initialize the TTL Cache Cleaner.
187
-	new Ttl_Cache_Cleaner();
188
-
189
-	// Load the new Post Adapter.
190
-	new Post_Adapter();
191
-
192
-	// Load the API Data Hooks.
193
-	new Api_Data_Hooks();
194
-
195
-	add_action(
196
-		'plugins_loaded',
197
-		function () {
198
-			// All features from registry should be initialized here.
199
-			$features_registry = Features_Registry::get_instance();
200
-			$features_registry->initialize_all_features();
201
-		},
202
-		5
203
-	);
204
-
205
-	add_action(
206
-		'plugins_loaded',
207
-		// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
208
-		function () use ( $plugin ) {
209
-
210
-			new Wordlift_Products_Navigator_Shortcode_REST();
211
-
212
-			// Register the Dataset module, requires `$api_service`.
213
-			require_once plugin_dir_path( __FILE__ ) . 'classes/dataset/index.php';
214
-			require_once plugin_dir_path( __FILE__ ) . 'classes/shipping-data/index.php';
215
-
216
-			/*
154
+    /**
155
+     * Filter: wl_feature__enable__widgets.
156
+     *
157
+     * @param bool whether the widgets needed to be registered, defaults to true.
158
+     *
159
+     * @return bool
160
+     * @since 3.27.6
161
+     */
162
+    if ( apply_filters( 'wl_feature__enable__widgets', true ) ) {
163
+        add_action( 'widgets_init', 'wl_register_chord_widget' );
164
+        add_action( 'widgets_init', 'wl_register_geo_widget' );
165
+        add_action( 'widgets_init', 'wl_register_timeline_widget' );
166
+    }
167
+    add_filter( 'widget_text', 'do_shortcode' );
168
+
169
+    /**
170
+     * Filter: wl_feature__enable__analysis
171
+     *
172
+     * @param bool Whether to send api request to analysis or not
173
+     *
174
+     * @return bool
175
+     * @since 3.27.6
176
+     */
177
+    if ( apply_filters( 'wl_feature__enable__analysis', true ) ) {
178
+        add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' );
179
+    } else {
180
+        add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' );
181
+    }
182
+
183
+    $plugin = new Wordlift();
184
+    $plugin->run();
185
+
186
+    // Initialize the TTL Cache Cleaner.
187
+    new Ttl_Cache_Cleaner();
188
+
189
+    // Load the new Post Adapter.
190
+    new Post_Adapter();
191
+
192
+    // Load the API Data Hooks.
193
+    new Api_Data_Hooks();
194
+
195
+    add_action(
196
+        'plugins_loaded',
197
+        function () {
198
+            // All features from registry should be initialized here.
199
+            $features_registry = Features_Registry::get_instance();
200
+            $features_registry->initialize_all_features();
201
+        },
202
+        5
203
+    );
204
+
205
+    add_action(
206
+        'plugins_loaded',
207
+        // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
208
+        function () use ( $plugin ) {
209
+
210
+            new Wordlift_Products_Navigator_Shortcode_REST();
211
+
212
+            // Register the Dataset module, requires `$api_service`.
213
+            require_once plugin_dir_path( __FILE__ ) . 'classes/dataset/index.php';
214
+            require_once plugin_dir_path( __FILE__ ) . 'classes/shipping-data/index.php';
215
+
216
+            /*
217 217
 			* Require the Entity annotation cleanup module.
218 218
 			*
219 219
 			* @since 3.34.6
220 220
 			*/
221
-			require_once plugin_dir_path( __FILE__ ) . 'classes/cleanup/index.php';
221
+            require_once plugin_dir_path( __FILE__ ) . 'classes/cleanup/index.php';
222 222
 
223
-			/*
223
+            /*
224 224
 			* Import LOD entities.
225 225
 			*
226 226
 			* @since 3.35.0
227 227
 			*/
228
-			require_once plugin_dir_path( __FILE__ ) . 'classes/lod-import/index.php';
228
+            require_once plugin_dir_path( __FILE__ ) . 'classes/lod-import/index.php';
229 229
 
230
-		}
231
-	);
230
+        }
231
+    );
232 232
 
233 233
 }
234 234
 
@@ -242,50 +242,50 @@  discard block
 block discarded – undo
242 242
  */
243 243
 function wordlift_plugin_autoload_register() {
244 244
 
245
-	spl_autoload_register(
246
-		function ( $class_name ) {
245
+    spl_autoload_register(
246
+        function ( $class_name ) {
247 247
 
248
-			// Bail out if these are not our classes.
249
-			if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) {
250
-				return false;
251
-			}
248
+            // Bail out if these are not our classes.
249
+            if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) {
250
+                return false;
251
+            }
252 252
 
253
-			$class_name_lc = strtolower( str_replace( '_', '-', $class_name ) );
253
+            $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) );
254 254
 
255
-			preg_match( '|^wordlift\\\\(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches );
255
+            preg_match( '|^wordlift\\\\(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches );
256 256
 
257
-			$path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] );
258
-			$file = 'class-' . $matches[2] . '.php';
257
+            $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] );
258
+            $file = 'class-' . $matches[2] . '.php';
259 259
 
260
-			$full_path = plugin_dir_path( __FILE__ ) . 'classes' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $file;
260
+            $full_path = plugin_dir_path( __FILE__ ) . 'classes' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $file;
261 261
 
262
-			if ( ! file_exists( $full_path ) ) {
263
-				return false;
264
-			}
262
+            if ( ! file_exists( $full_path ) ) {
263
+                return false;
264
+            }
265 265
 
266
-			try {
267
-				require_once $full_path;
268
-			} catch ( Exception $e ) {
269
-				// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
270
-				error_log( "[WordLift] $full_path not found, cannot include." );
271
-			}
266
+            try {
267
+                require_once $full_path;
268
+            } catch ( Exception $e ) {
269
+                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
270
+                error_log( "[WordLift] $full_path not found, cannot include." );
271
+            }
272 272
 
273
-			return true;
274
-		}
275
-	);
273
+            return true;
274
+        }
275
+    );
276 276
 
277 277
 }
278 278
 
279 279
 function wl_block_categories( $categories ) {
280
-	return array_merge(
281
-		$categories,
282
-		array(
283
-			array(
284
-				'slug'  => 'wordlift',
285
-				'title' => __( 'WordLift', 'wordlift' ),
286
-			),
287
-		)
288
-	);
280
+    return array_merge(
281
+        $categories,
282
+        array(
283
+            array(
284
+                'slug'  => 'wordlift',
285
+                'title' => __( 'WordLift', 'wordlift' ),
286
+            ),
287
+        )
288
+    );
289 289
 }
290 290
 
291 291
 /**
@@ -293,19 +293,19 @@  discard block
 block discarded – undo
293 293
  * this has to be removed when removing the legacy fields from the ui.
294 294
  */
295 295
 function wl_enqueue_leaflet( $in_footer = false ) {
296
-	// Leaflet.
297
-	wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' );
298
-	wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer );
296
+    // Leaflet.
297
+    wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' );
298
+    wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer );
299 299
 }
300 300
 
301 301
 add_filter( 'block_categories', 'wl_block_categories', 10 );
302 302
 
303 303
 // Temporary fix for a typo in WooCommerce Extension.
304 304
 add_filter(
305
-	'wl_feature__enable__dataset',
306
-	function ( $value ) {
307
-		return apply_filters( 'wl_features__enable__dataset', $value );
308
-	}
305
+    'wl_feature__enable__dataset',
306
+    function ( $value ) {
307
+        return apply_filters( 'wl_features__enable__dataset', $value );
308
+    }
309 309
 );
310 310
 
311 311
 require_once __DIR__ . '/modules/food-kg/load.php';
@@ -319,35 +319,35 @@  discard block
 block discarded – undo
319 319
 require_once __DIR__ . '/modules/raptive-setup/load.php';
320 320
 
321 321
 function _wl_update_plugins_raptive_domain( $update, $plugin_data, $plugin_file ) {
322
-	// Bail out if it's not our plugin.
323
-	$update_uri = $plugin_data['UpdateURI'];
324
-	if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) {
325
-		return $update;
326
-	}
327
-
328
-	$response = wp_remote_get( "$update_uri?nocache=" . time() );
329
-
330
-	if ( is_wp_error( $response ) ) {
331
-		return $update;
332
-	}
333
-
334
-	try {
335
-		return json_decode( wp_remote_retrieve_body( $response ) );
336
-	} catch ( Exception $e ) {
337
-		return $update;
338
-	}
322
+    // Bail out if it's not our plugin.
323
+    $update_uri = $plugin_data['UpdateURI'];
324
+    if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) {
325
+        return $update;
326
+    }
327
+
328
+    $response = wp_remote_get( "$update_uri?nocache=" . time() );
329
+
330
+    if ( is_wp_error( $response ) ) {
331
+        return $update;
332
+    }
333
+
334
+    try {
335
+        return json_decode( wp_remote_retrieve_body( $response ) );
336
+    } catch ( Exception $e ) {
337
+        return $update;
338
+    }
339 339
 }
340 340
 
341 341
 add_action(
342
-	'update_plugins_adthrive.wordlift.io',
343
-	'_wl_update_plugins_raptive_domain',
344
-	10,
345
-	3
342
+    'update_plugins_adthrive.wordlift.io',
343
+    '_wl_update_plugins_raptive_domain',
344
+    10,
345
+    3
346 346
 );
347 347
 
348 348
 add_action(
349
-	'update_plugins_raptive.wordlift.io',
350
-	'_wl_update_plugins_raptive_domain',
351
-	10,
352
-	3
349
+    'update_plugins_raptive.wordlift.io',
350
+    '_wl_update_plugins_raptive_domain',
351
+    10,
352
+    3
353 353
 );
Please login to merge, or discard this patch.