Completed
Push — master ( 20c3c4...b6edec )
by David
11:30
created

wordlift.php ➔ wordlift_admin_enqueue_scripts()   B

Complexity

Conditions 6
Paths 8

Size

Total Lines 30
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 14
nc 8
nop 0
dl 0
loc 30
rs 8.439
c 0
b 0
f 0
1
<?php
2
/**
3
 * The plugin bootstrap file
4
 *
5
 * This file is read by WordPress to generate the plugin information in the plugin
6
 * admin area. This file also includes all of the dependencies used by the plugin,
7
 * registers the activation and deactivation functions, and defines a function
8
 * that starts the plugin.
9
 *
10
 * @link              https://wordlift.io
11
 * @since             1.0.0
12
 * @package           Wordlift
13
 *
14
 * @wordpress-plugin
15
 * Plugin Name:       WordLift
16
 * Plugin URI:        https://wordlift.io
17
 * Description:       WordLift brings the power of AI to organize content, attract new readers and get their attention. To activate the plugin ​<a href="https://wordlift.io/">visit our website</a>.
18
 * Version:           3.15.4
19
 * Author:            WordLift, Insideout10
20
 * Author URI:        https://wordlift.io
21
 * License:           GPL-2.0+
22
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
23
 * Text Domain:       wordlift
24
 * Domain Path:       /languages
25
 */
26
27
// If this file is called directly, abort.
28
if ( ! defined( 'WPINC' ) ) {
29
	die;
30
}
31
32
// Include WordLift constants.
33
require_once( 'wordlift_constants.php' );
34
35
// Load modules.
36
require_once( 'modules/core/wordlift_core.php' );
37
38
/**
39
 * Log to the debug.log file.
40
 *
41
 * @deprecated use Wordlift_Log_Service::get_instance()->info( $log );
42
 *
43
 * @since      3.0.0
44
 *
45
 * @uses       wl_write_log_handler() to write the log output.
46
 *
47
 * @param string|mixed $log The log data.
48
 */
49
function wl_write_log( $log ) {
50
51
	Wordlift_Log_Service::get_instance()->debug( $log );
52
53
}
54
55
/**
56
 * The default log handler prints out the log.
57
 *
58
 * @deprecated
59
 *
60
 * @since 3.0.0
61
 *
62
 * @param string|array $log    The log data.
63
 * @param string       $caller The calling function.
64
 */
65
function wl_write_log_handler( $log, $caller = null ) {
66
67
	global $wl_logger;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
68
69
	if ( true === WP_DEBUG ) {
70
71
		$message = ( isset( $caller ) ? sprintf( '[%-40.40s] ', $caller ) : '' ) .
72
				   ( is_array( $log ) || is_object( $log ) ? print_r( $log, true ) : wl_write_log_hide_key( $log ) );
0 ignored issues
show
Deprecated Code introduced by
The function wl_write_log_hide_key() has been deprecated.

This function has been deprecated.

Loading history...
73
74
		if ( isset( $wl_logger ) ) {
75
			$wl_logger->info( $message );
76
		} else {
77
			error_log( $message );
78
		}
79
80
	}
81
82
}
83
84
/**
85
 * Hide the WordLift Key from the provided text.
86
 *
87
 * @deprecated
88
 *
89
 * @since 3.0.0
90
 *
91
 * @param string $text A text that may potentially contain a WL key.
92
 *
93
 * @return string A text with the key hidden.
94
 */
95
function wl_write_log_hide_key( $text ) {
96
97
	return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
0 ignored issues
show
Deprecated Code introduced by
The function wl_configuration_get_key() has been deprecated with message: use Wordlift_Configuration_Service::get_instance()->get_key()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
98
}
99
100
/**
101
 * Enable microdata schema.org tagging.
102
 * see http://vip.wordpress.com/documentation/register-additional-html-attributes-for-tinymce-and-wp-kses/
103
 */
104
function wordlift_allowed_post_tags() {
105
	global $allowedposttags;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
106
107
	$tags           = array( 'span' );
108
	$new_attributes = array(
109
		'itemscope' => array(),
110
		'itemtype'  => array(),
111
		'itemprop'  => array(),
112
		'itemid'    => array(),
113
	);
114
115
	foreach ( $tags as $tag ) {
116
		if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
117
			$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
118
		}
119
	}
120
}
121
122
// add allowed post tags.
123
add_action( 'init', 'wordlift_allowed_post_tags' );
124
125
/**
126
 * Register additional scripts for the admin UI.
127
 */
128
function wordlift_admin_enqueue_scripts() {
129
130
	// Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
131
	wp_enqueue_script( 'wpdialogs' );
132
	wp_enqueue_style( 'wp-jquery-ui-dialog' );
133
134
	wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
135
136
	wp_enqueue_script( 'jquery-ui-autocomplete' );
137
138
	$log = Wordlift_Log_Service::get_logger( 'wordlift_admin_enqueue_scripts' );
139
	$log->trace( 'Registering admin scripts...' );
140
141
	// We now register angular scripts and have dependent scripts (currently
142
	// only the edit post page) depend on them, to avoid potential conflicts.
143
	//
144
	// See https://github.com/insideout10/wordlift-plugin/issues/691.
145
	$result = wp_register_script( 'wl-angular', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' )
146
			  && wp_register_script( 'wl-angular-geolocation', plugin_dir_url( __FILE__ ) . 'bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' )
147
			  && wp_register_script( 'wl-angular-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' )
148
			  && wp_register_script( 'wl-angular-animate', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-animate.min.js' );
149
150
	$log->debug( 'Registering angular scripts was ' . ( $result ? 'successful.' : 'unsuccessful.' ) );
151
152
	// Disable auto-save for custom entity posts only
153
	if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
154
		wp_dequeue_script( 'autosave' );
155
	}
156
157
}
158
159
add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' );
160
161
function wl_enqueue_scripts() {
162
	wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' );
163
}
164
165
add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' );
166
167
/**
168
 * Hooked to *wp_kses_allowed_html* filter, adds microdata attributes.
169
 *
170
 * @param array  $allowedtags The array with the currently configured elements and attributes.
171
 * @param string $context     The context.
172
 *
173
 * @return array An array which contains allowed microdata attributes.
174
 */
175
function wordlift_allowed_html( $allowedtags, $context ) {
176
177
	if ( 'post' !== $context ) {
178
		return $allowedtags;
179
	}
180
181
	return array_merge_recursive( $allowedtags, array(
182
		'span' => array(
183
			'itemscope' => true,
184
			'itemtype'  => true,
185
			'itemid'    => true,
186
			'itemprop'  => true,
187
		),
188
	) );
189
}
190
191
add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 );
192
193
/**
194
 * Get the coordinates for the specified post ID.
195
 *
196
 * @param int $post_id The post ID.
197
 *
198
 * @return array|null An array of coordinates or null.
199
 */
200
function wl_get_coordinates( $post_id ) {
201
202
	$latitude  = wl_schema_get_value( $post_id, 'latitude' );
203
	$longitude = wl_schema_get_value( $post_id, 'longitude' );
204
205
	// DO NOT set latitude/longitude to 0/0 as default values. It's a specific
206
	// place on the globe:"The zero/zero point of this system is located in the
207
	// Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
208
	return array(
209
		'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
210
		'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
211
	);
212
}
213
214
/**
215
 * Get all the images bound to a post.
216
 *
217
 * @deprecated use Wordlift_Storage_Factory::get_instance()->post_images()->get( $post_id )
218
 *
219
 * @param int $post_id The post ID.
220
 *
221
 * @return array An array of image URLs.
222
 */
223
function wl_get_image_urls( $post_id ) {
224
225
	return Wordlift_Storage_Factory::get_instance()
226
								   ->post_images()
227
								   ->get( $post_id );
228
229
//	// If there is a featured image it has the priority.
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
230
//	$featured_image_id = get_post_thumbnail_id( $post_id );
231
//	if ( is_numeric( $featured_image_id ) ) {
232
//		$image_url = wp_get_attachment_url( $featured_image_id );
233
//
234
//		return array( $image_url );
235
//	}
236
//
237
//	$images = get_children( array(
238
//		'post_parent'    => $post_id,
239
//		'post_type'      => 'attachment',
240
//		'post_mime_type' => 'image',
241
//	) );
242
//
243
//	// Return an empty array if no image is found.
244
//	if ( empty( $images ) ) {
245
//		return array();
246
//	}
247
//
248
//	// Prepare the return array.
249
//	$image_urls = array();
250
//
251
//	// Collect the URLs.
252
//	foreach ( $images as $attachment_id => $attachment ) {
253
//		$image_url = wp_get_attachment_url( $attachment_id );
254
//		// Ensure the URL isn't collected already.
255
//		if ( ! in_array( $image_url, $image_urls ) ) {
256
//			array_push( $image_urls, $image_url );
257
//		}
258
//	}
259
//
260
//	// wl_write_log( "wl_get_image_urls [ post id :: $post_id ][ image urls count :: " . count( $image_urls ) . " ]" );
261
//
262
//	return $image_urls;
263
}
264
265
/**
266
 * Get an attachment with the specified parent post ID and source URL.
267
 *
268
 * @param int    $parent_post_id The parent post ID.
269
 * @param string $source_url     The source URL.
270
 *
271
 * @return WP_Post|null A post instance or null if not found.
272
 */
273
function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) {
274
275
	// wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
276
277
	$posts = get_posts( array(
278
		'post_type'      => 'attachment',
279
		'posts_per_page' => 1,
280
		'post_status'    => 'any',
281
		'post_parent'    => $parent_post_id,
282
		'meta_key'       => 'wl_source_url',
283
		'meta_value'     => $source_url,
284
	) );
285
286
	// Return the found post.
287
	if ( 1 === count( $posts ) ) {
288
		return $posts[0];
289
	}
290
291
	// Return null.
292
	return null;
293
}
294
295
/**
296
 * Set the source URL.
297
 *
298
 * @param int    $post_id    The post ID.
299
 * @param string $source_url The source URL.
300
 */
301
function wl_set_source_url( $post_id, $source_url ) {
302
303
	delete_post_meta( $post_id, 'wl_source_url' );
304
	add_post_meta( $post_id, 'wl_source_url', $source_url );
305
}
306
307
308
///**
309
// * This function is called by the *flush_rewrite_rules_hard* hook. It recalculates the URI for all the posts.
310
// *
311
// * @since 3.0.0
312
// *
313
// * @uses  rl_sparql_prefixes() to get the SPARQL prefixes.
314
// * @uses  wl_get_entity_uri() to get an entity URI.
315
// * @uses  rl_execute_sparql_update_query() to post the DELETE and INSERT queries.
316
// *
317
// * @param bool $hard True if the rewrite involves configuration updates in Apache/IIS.
318
// */
319
//function wl_flush_rewrite_rules_hard( $hard ) {
320
//
321
//	// If WL is not yet configured, we cannot perform any update, so we exit.
322
//	if ( '' === wl_configuration_get_key() ) {
323
//		return;
324
//	}
325
//
326
//	// Set the initial offset and limit each call to 100 posts to avoid memory errors.
327
//	$offset = 0;
328
//	$limit  = 100;
329
//
330
//	// Get more posts if the number of returned posts matches the limit.
331
//	while ( $limit === ( $posts = get_posts( array(
332
//			'offset'      => $offset,
333
//			'numberposts' => $limit,
334
//			'orderby'     => 'ID',
335
//			'post_type'   => 'any',
336
//			'post_status' => 'publish',
337
//		) ) ) ) {
338
//
339
//		// Holds the delete part of the query.
340
//		$delete_query = rl_sparql_prefixes();
341
//
342
//		// Holds the insert part of the query.
343
//		$insert_query = '';
344
//
345
//		// Cycle in each post to build the query.
346
//		foreach ( $posts as $post ) {
347
//
348
//			// Ignore revisions.
349
//			if ( wp_is_post_revision( $post->ID ) ) {
350
//				continue;
351
//			}
352
//
353
//			// Get the entity URI.
354
//			$s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance()
355
//																			 ->get_uri( $post->ID ) );
356
//
357
//			// Get the post URL.
358
//			// $url = wl_sparql_escape_uri( get_permalink( $post->ID ) );
359
//
360
//			// Prepare the DELETE and INSERT commands.
361
//			$delete_query .= "DELETE { <$s> schema:url ?u . } WHERE  { <$s> schema:url ?u . };\n";
362
//
363
//			$insert_query .= Wordlift_Schema_Url_Property_Service::get_instance()
364
//																 ->get_insert_query( $s, $post->ID );
365
//
366
//		}
367
//
368
//
369
//		// Execute the query.
370
//		rl_execute_sparql_update_query( $delete_query . $insert_query );
371
//
372
//		// Advance to the next posts.
373
//		$offset += $limit;
374
//
375
//	}
376
//
377
//}
378
//
379
//add_filter( 'flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1 );
380
381
/**
382
 * Sanitizes an URI path by replacing the non allowed characters with an underscore.
383
 * @uses       sanitize_title() to manage not ASCII chars
384
 * @deprecated use Wordlift_Uri_Service::get_instance()->sanitize_path();
385
 * @see        https://codex.wordpress.org/Function_Reference/sanitize_title
386
 *
387
 * @param string $path The path to sanitize.
388
 * @param string $char The replacement character (by default an underscore).
389
 *
390
 * @return string The sanitized path.
391
 */
392
function wl_sanitize_uri_path( $path, $char = '_' ) {
393
394
	return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
395
}
396
397
///**
398
// * Schedule the execution of SPARQL Update queries before the WordPress look ends.
399
// */
400
//function wl_shutdown() {
401
//
402
//	// Get the filename to the temporary SPARQL file.
403
//	$filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
404
//
405
//	// If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it.
406
//	if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) {
407
//
408
//		// The request ID.
409
//		$args = array( WL_REQUEST_ID );
410
//
411
//		// Schedule the execution of the SPARQL query with the request ID.
412
//		wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args );
413
//
414
//		// Check that the request is scheduled.
415
//		$timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args );
416
//
417
//		// Spawn the cron.
418
//		spawn_cron();
419
//
420
//		wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" );
421
//	}
422
//}
423
//
424
//add_action( 'shutdown', 'wl_shutdown' );
425
426
/**
427
 * Replaces the *itemid* attributes URIs with the WordLift URIs.
428
 *
429
 * @param string $content The post content.
430
 *
431
 * @return string The updated post content.
432
 */
433
function wl_replace_item_id_with_uri( $content ) {
434
435
	$log = Wordlift_Log_Service::get_logger( 'wl_replace_item_id_with_uri' );
436
	$log->trace( 'Replacing item IDs with URIs...' );
437
438
	// Strip slashes, see https://core.trac.wordpress.org/ticket/21767
439
	$content = stripslashes( $content );
440
441
	// If any match are found.
442
	$matches = array();
443
	if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
444
445
		foreach ( $matches as $match ) {
0 ignored issues
show
Bug introduced by
The expression $matches of type null|array<integer,array<integer,string>> is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
446
447
			// Get the item ID.
448
			$item_id = $match[1];
449
450
			// Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
451
			$post = Wordlift_Entity_Service::get_instance()
452
										   ->get_entity_post_by_uri( $item_id );
453
454
			// If no entity is found, continue to the next one.
455
			if ( null === $post ) {
456
				continue;
457
			}
458
459
			// Get the URI for that post.
460
			$uri = wl_get_entity_uri( $post->ID );
0 ignored issues
show
Deprecated Code introduced by
The function wl_get_entity_uri() has been deprecated with message: use Wordlift_Entity_Service::get_instance()->get_uri( $post_id )

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
461
462
			// wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
463
464
			// If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
465
			if ( $item_id !== $uri ) {
466
				$uri_e   = esc_html( $uri );
467
				$content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
468
			}
469
		}
470
	}
471
472
	// Reapply slashes.
473
	$content = addslashes( $content );
474
475
	return $content;
476
}
477
478
add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 );
479
480
require_once( 'wordlift_entity_functions.php' );
481
482
// add editor related methods.
483
require_once( 'wordlift_editor.php' );
484
485
// add the WordLift entity custom type.
486
require_once( 'wordlift_entity_type.php' );
487
require_once( 'wordlift_entity_type_taxonomy.php' );
488
489
// add callbacks on post save to notify data changes from wp to redlink triple store
490
require_once( 'wordlift_to_redlink_data_push_callbacks.php' );
491
492
require_once( 'modules/configuration/wordlift_configuration_settings.php' );
493
494
// Load modules
495
require_once( 'modules/analyzer/wordlift_analyzer.php' );
496
require_once( 'modules/linked_data/wordlift_linked_data.php' );
497
require_once( 'modules/prefixes/wordlift_prefixes.php' );
498
499
// Shortcodes
500
501
require_once( 'modules/geo_widget/wordlift_geo_widget.php' );
502
require_once( 'shortcodes/wordlift_shortcode_chord.php' );
503
require_once( 'shortcodes/wordlift_shortcode_geomap.php' );
504
require_once( 'shortcodes/wordlift_shortcode_field.php' );
505
require_once( 'shortcodes/wordlift_shortcode_faceted_search.php' );
506
require_once( 'shortcodes/wordlift_shortcode_navigator.php' );
507
508
require_once( 'widgets/wordlift_widget_geo.php' );
509
require_once( 'widgets/wordlift_widget_chord.php' );
510
require_once( 'widgets/wordlift_widget_timeline.php' );
511
512
require_once( 'wordlift_redlink.php' );
513
514
// Add admin functions.
515
// TODO: find a way to make 'admin' UI tests work.
516
//if ( is_admin() ) {
517
518
require_once( 'admin/wordlift_admin.php' );
519
require_once( 'admin/wordlift_admin_edit_post.php' );
520
require_once( 'admin/wordlift_admin_save_post.php' );
521
522
// add the entities meta box.
523
require_once( 'admin/wordlift_admin_meta_box_entities.php' );
524
525
// add the entity creation AJAX.
526
require_once( 'admin/wordlift_admin_ajax_related_posts.php' );
527
528
// Load the wl_chord TinyMCE button and configuration dialog.
529
require_once( 'admin/wordlift_admin_shortcodes.php' );
530
531
// load languages.
532
// TODO: the following call gives for granted that the plugin is in the wordlift directory,
533
//       we're currently doing this because wordlift is symbolic linked.
534
load_plugin_textdomain( 'wordlift', false, '/wordlift/languages' );
535
536
537
/**
538
 * The code that runs during plugin activation.
539
 * This action is documented in includes/class-wordlift-activator.php
540
 */
541
function activate_wordlift() {
542
543
	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
544
	Wordlift_Activator::activate();
545
	flush_rewrite_rules();
546
547
}
548
549
/**
550
 * The code that runs during plugin deactivation.
551
 * This action is documented in includes/class-wordlift-deactivator.php
552
 */
553
function deactivate_wordlift() {
554
555
	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
556
	Wordlift_Deactivator::deactivate();
557
	flush_rewrite_rules();
558
559
}
560
561
register_activation_hook( __FILE__, 'activate_wordlift' );
562
register_deactivation_hook( __FILE__, 'deactivate_wordlift' );
563
564
/**
565
 * The core plugin class that is used to define internationalization,
566
 * admin-specific hooks, and public-facing site hooks.
567
 */
568
require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php';
569
570
/**
571
 * Begins execution of the plugin.
572
 *
573
 * Since everything within the plugin is registered via hooks,
574
 * then kicking off the plugin from this point in the file does
575
 * not affect the page life cycle.
576
 *
577
 * @since    1.0.0
578
 */
579
function run_wordlift() {
580
581
	$plugin = new Wordlift();
582
	$plugin->run();
583
584
}
585
586
run_wordlift();
587