Completed
Push — develop ( f65bd6...158ffc )
by David
08:55
created

wordlift.php ➔ wl_get_sparql_images()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 3
nop 2
dl 0
loc 22
rs 9.2
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A wordlift.php ➔ wl_set_source_url() 0 5 1
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.0-dev
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()->info( $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
	wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
138
	wp_enqueue_script( 'angularjs-geolocation', plugin_dir_url( __FILE__ ) . '/bower_components/angularjs-geolocation/dist/angularjs-geolocation.min.js' );
139
	wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js' );
140
	wp_enqueue_script( 'angularjs-animate', 'https://code.angularjs.org/1.3.11/angular-animate.min.js' );
141
142
	// Disable auto-save for custom entity posts only
143
	if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
144
		wp_dequeue_script( 'autosave' );
145
	}
146
}
147
148
add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' );
149
150
function wl_enqueue_scripts() {
151
	wp_enqueue_style( 'wordlift-ui', plugin_dir_url( __FILE__ ) . 'css/wordlift-ui.min.css' );
152
}
153
154
add_action( 'wp_enqueue_scripts', 'wl_enqueue_scripts' );
155
156
/**
157
 * Hooked to *wp_kses_allowed_html* filter, adds microdata attributes.
158
 *
159
 * @param array  $allowedtags The array with the currently configured elements and attributes.
160
 * @param string $context     The context.
161
 *
162
 * @return array An array which contains allowed microdata attributes.
163
 */
164
function wordlift_allowed_html( $allowedtags, $context ) {
165
166
	if ( 'post' !== $context ) {
167
		return $allowedtags;
168
	}
169
170
	return array_merge_recursive( $allowedtags, array(
171
		'span' => array(
172
			'itemscope' => true,
173
			'itemtype'  => true,
174
			'itemid'    => true,
175
			'itemprop'  => true,
176
		),
177
	) );
178
}
179
180
add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 );
181
182
/**
183
 * Get the coordinates for the specified post ID.
184
 *
185
 * @param int $post_id The post ID.
186
 *
187
 * @return array|null An array of coordinates or null.
188
 */
189
function wl_get_coordinates( $post_id ) {
190
191
	$latitude  = wl_schema_get_value( $post_id, 'latitude' );
192
	$longitude = wl_schema_get_value( $post_id, 'longitude' );
193
194
	// DO NOT set latitude/longitude to 0/0 as default values. It's a specific
195
	// place on the globe:"The zero/zero point of this system is located in the
196
	// Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
197
	return array(
198
		'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
199
		'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
200
	);
201
}
202
203
/**
204
 * Get all the images bound to a post.
205
 *
206
 * @deprecated use Wordlift_Storage_Factory::get_instance()->post_images()->get( $post_id )
207
 *
208
 * @param int $post_id The post ID.
209
 *
210
 * @return array An array of image URLs.
211
 */
212
function wl_get_image_urls( $post_id ) {
213
214
	return Wordlift_Storage_Factory::get_instance()
215
	                               ->post_images()
216
	                               ->get( $post_id );
217
218
//	// 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...
219
//	$featured_image_id = get_post_thumbnail_id( $post_id );
220
//	if ( is_numeric( $featured_image_id ) ) {
221
//		$image_url = wp_get_attachment_url( $featured_image_id );
222
//
223
//		return array( $image_url );
224
//	}
225
//
226
//	$images = get_children( array(
227
//		'post_parent'    => $post_id,
228
//		'post_type'      => 'attachment',
229
//		'post_mime_type' => 'image',
230
//	) );
231
//
232
//	// Return an empty array if no image is found.
233
//	if ( empty( $images ) ) {
234
//		return array();
235
//	}
236
//
237
//	// Prepare the return array.
238
//	$image_urls = array();
239
//
240
//	// Collect the URLs.
241
//	foreach ( $images as $attachment_id => $attachment ) {
242
//		$image_url = wp_get_attachment_url( $attachment_id );
243
//		// Ensure the URL isn't collected already.
244
//		if ( ! in_array( $image_url, $image_urls ) ) {
245
//			array_push( $image_urls, $image_url );
246
//		}
247
//	}
248
//
249
//	// wl_write_log( "wl_get_image_urls [ post id :: $post_id ][ image urls count :: " . count( $image_urls ) . " ]" );
250
//
251
//	return $image_urls;
252
}
253
254
/**
255
 * Get an attachment with the specified parent post ID and source URL.
256
 *
257
 * @param int    $parent_post_id The parent post ID.
258
 * @param string $source_url     The source URL.
259
 *
260
 * @return WP_Post|null A post instance or null if not found.
261
 */
262
function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) {
263
264
	// 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...
265
266
	$posts = get_posts( array(
267
		'post_type'      => 'attachment',
268
		'posts_per_page' => 1,
269
		'post_status'    => 'any',
270
		'post_parent'    => $parent_post_id,
271
		'meta_key'       => 'wl_source_url',
272
		'meta_value'     => $source_url,
273
	) );
274
275
	// Return the found post.
276
	if ( 1 === count( $posts ) ) {
277
		return $posts[0];
278
	}
279
280
	// Return null.
281
	return null;
282
}
283
284
/**
285
 * Set the source URL.
286
 *
287
 * @param int    $post_id    The post ID.
288
 * @param string $source_url The source URL.
289
 */
290
function wl_set_source_url( $post_id, $source_url ) {
291
292
	delete_post_meta( $post_id, 'wl_source_url' );
293
	add_post_meta( $post_id, 'wl_source_url', $source_url );
294
}
295
296
297
/**
298
 * This function is called by the *flush_rewrite_rules_hard* hook. It recalculates the URI for all the posts.
299
 *
300
 * @since 3.0.0
301
 *
302
 * @uses  rl_sparql_prefixes() to get the SPARQL prefixes.
303
 * @uses  wl_get_entity_uri() to get an entity URI.
304
 * @uses  rl_execute_sparql_update_query() to post the DELETE and INSERT queries.
305
 *
306
 * @param bool $hard True if the rewrite involves configuration updates in Apache/IIS.
307
 */
308
function wl_flush_rewrite_rules_hard( $hard ) {
0 ignored issues
show
Unused Code introduced by
The parameter $hard is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
309
310
	// If WL is not yet configured, we cannot perform any update, so we exit.
311
	if ( '' === wl_configuration_get_key() ) {
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...
312
		return;
313
	}
314
315
	// Set the initial offset and limit each call to 100 posts to avoid memory errors.
316
	$offset = 0;
317
	$limit  = 100;
318
319
	// Get more posts if the number of returned posts matches the limit.
320
	while ( $limit === ( $posts = get_posts( array(
321
			'offset'      => $offset,
322
			'numberposts' => $limit,
323
			'orderby'     => 'ID',
324
			'post_type'   => 'any',
325
			'post_status' => 'publish',
326
		) ) ) ) {
327
328
		// Holds the delete part of the query.
329
		$delete_query = rl_sparql_prefixes();
330
331
		// Holds the insert part of the query.
332
		$insert_query = '';
333
334
		// Cycle in each post to build the query.
335
		foreach ( $posts as $post ) {
336
337
			// Ignore revisions.
338
			if ( wp_is_post_revision( $post->ID ) ) {
339
				continue;
340
			}
341
342
			// Get the entity URI.
343
			$s = Wordlift_Sparql_Service::escape_uri( Wordlift_Entity_Service::get_instance()
344
			                                                                 ->get_uri( $post->ID ) );
345
346
			// Get the post URL.
347
			// $url = wl_sparql_escape_uri( get_permalink( $post->ID ) );
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...
348
349
			// Prepare the DELETE and INSERT commands.
350
			$delete_query .= "DELETE { <$s> schema:url ?u . } WHERE  { <$s> schema:url ?u . };\n";
351
352
			$insert_query .= Wordlift_Schema_Url_Property_Service::get_instance()
353
			                                                     ->get_insert_query( $s, $post->ID );
354
355
		}
356
357
358
		// Execute the query.
359
		rl_execute_sparql_update_query( $delete_query . $insert_query );
360
361
		// Advance to the next posts.
362
		$offset += $limit;
363
364
	}
365
366
}
367
368
add_filter( 'flush_rewrite_rules_hard', 'wl_flush_rewrite_rules_hard', 10, 1 );
369
370
/**
371
 * Sanitizes an URI path by replacing the non allowed characters with an underscore.
372
 * @uses       sanitize_title() to manage not ASCII chars
373
 * @deprecated use Wordlift_Uri_Service::get_instance()->sanitize_path();
374
 * @see        https://codex.wordpress.org/Function_Reference/sanitize_title
375
 *
376
 * @param string $path The path to sanitize.
377
 * @param string $char The replacement character (by default an underscore).
378
 *
379
 * @return string The sanitized path.
380
 */
381
function wl_sanitize_uri_path( $path, $char = '_' ) {
382
383
	return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
384
}
385
386
///**
387
// * Schedule the execution of SPARQL Update queries before the WordPress look ends.
388
// */
389
//function wl_shutdown() {
390
//
391
//	// Get the filename to the temporary SPARQL file.
392
//	$filename = WL_TEMP_DIR . WL_REQUEST_ID . '.sparql';
393
//
394
//	// If WordLift is buffering SPARQL queries, we're admins and a buffer exists, then schedule it.
395
//	if ( WL_ENABLE_SPARQL_UPDATE_QUERIES_BUFFERING && is_admin() && file_exists( $filename ) ) {
396
//
397
//		// The request ID.
398
//		$args = array( WL_REQUEST_ID );
399
//
400
//		// Schedule the execution of the SPARQL query with the request ID.
401
//		wp_schedule_single_event( time(), 'wl_execute_saved_sparql_update_query', $args );
402
//
403
//		// Check that the request is scheduled.
404
//		$timestamp = wp_next_scheduled( 'wl_execute_saved_sparql_update_query', $args );
405
//
406
//		// Spawn the cron.
407
//		spawn_cron();
408
//
409
//		wl_write_log( "wl_shutdown [ request id :: " . WL_REQUEST_ID . " ][ timestamp :: $timestamp ]" );
410
//	}
411
//}
412
//
413
//add_action( 'shutdown', 'wl_shutdown' );
414
415
/**
416
 * Replaces the *itemid* attributes URIs with the WordLift URIs.
417
 *
418
 * @param string $content The post content.
419
 *
420
 * @return string The updated post content.
421
 */
422
function wl_replace_item_id_with_uri( $content ) {
423
424
	// wl_write_log( "wl_replace_item_id_with_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...
425
426
	// Strip slashes, see https://core.trac.wordpress.org/ticket/21767
427
	$content = stripslashes( $content );
428
429
	// If any match are found.
430
	$matches = array();
431
	if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
432
433
		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...
434
435
			// Get the item ID.
436
			$item_id = $match[1];
437
438
			// Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
439
			$post = Wordlift_Entity_Service::get_instance()
440
			                               ->get_entity_post_by_uri( $item_id );
441
442
			// If no entity is found, continue to the next one.
443
			if ( null === $post ) {
444
				continue;
445
			}
446
447
			// Get the URI for that post.
448
			$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...
449
450
			// 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...
451
452
			// If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
453
			if ( $item_id !== $uri ) {
454
				$uri_e   = esc_html( $uri );
455
				$content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
456
			}
457
		}
458
	}
459
460
	// Reapply slashes.
461
	$content = addslashes( $content );
462
463
	return $content;
464
}
465
466
add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 );
467
468
require_once( 'wordlift_entity_functions.php' );
469
470
// add editor related methods.
471
require_once( 'wordlift_editor.php' );
472
473
// add the WordLift entity custom type.
474
require_once( 'wordlift_entity_type.php' );
475
require_once( 'wordlift_entity_type_taxonomy.php' );
476
477
// add callbacks on post save to notify data changes from wp to redlink triple store
478
require_once( 'wordlift_to_redlink_data_push_callbacks.php' );
479
480
require_once( 'modules/configuration/wordlift_configuration_settings.php' );
481
482
// Load modules
483
require_once( 'modules/analyzer/wordlift_analyzer.php' );
484
require_once( 'modules/linked_data/wordlift_linked_data.php' );
485
require_once( 'modules/prefixes/wordlift_prefixes.php' );
486
487
// Shortcodes
488
489
require_once( 'modules/geo_widget/wordlift_geo_widget.php' );
490
require_once( 'shortcodes/wordlift_shortcode_chord.php' );
491
require_once( 'shortcodes/wordlift_shortcode_geomap.php' );
492
require_once( 'shortcodes/wordlift_shortcode_field.php' );
493
require_once( 'shortcodes/wordlift_shortcode_faceted_search.php' );
494
require_once( 'shortcodes/wordlift_shortcode_navigator.php' );
495
496
require_once( 'widgets/wordlift_widget_geo.php' );
497
require_once( 'widgets/wordlift_widget_chord.php' );
498
require_once( 'widgets/wordlift_widget_timeline.php' );
499
500
require_once( 'wordlift_redlink.php' );
501
502
// Add admin functions.
503
// TODO: find a way to make 'admin' UI tests work.
504
//if ( is_admin() ) {
505
506
require_once( 'admin/wordlift_admin.php' );
507
require_once( 'admin/wordlift_admin_edit_post.php' );
508
require_once( 'admin/wordlift_admin_save_post.php' );
509
510
// add the entities meta box.
511
require_once( 'admin/wordlift_admin_meta_box_entities.php' );
512
513
// add the entity creation AJAX.
514
require_once( 'admin/wordlift_admin_ajax_related_posts.php' );
515
516
// Load the wl_chord TinyMCE button and configuration dialog.
517
require_once( 'admin/wordlift_admin_shortcodes.php' );
518
519
// load languages.
520
// TODO: the following call gives for granted that the plugin is in the wordlift directory,
521
//       we're currently doing this because wordlift is symbolic linked.
522
load_plugin_textdomain( 'wordlift', false, '/wordlift/languages' );
523
524
525
/**
526
 * The code that runs during plugin activation.
527
 * This action is documented in includes/class-wordlift-activator.php
528
 */
529
function activate_wordlift() {
530
	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
531
	Wordlift_Activator::activate();
532
}
533
534
/**
535
 * The code that runs during plugin deactivation.
536
 * This action is documented in includes/class-wordlift-deactivator.php
537
 */
538
function deactivate_wordlift() {
539
	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
540
	Wordlift_Deactivator::deactivate();
541
}
542
543
register_activation_hook( __FILE__, 'activate_wordlift' );
544
register_deactivation_hook( __FILE__, 'deactivate_wordlift' );
545
546
/**
547
 * The core plugin class that is used to define internationalization,
548
 * admin-specific hooks, and public-facing site hooks.
549
 */
550
require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php';
551
552
/**
553
 * Begins execution of the plugin.
554
 *
555
 * Since everything within the plugin is registered via hooks,
556
 * then kicking off the plugin from this point in the file does
557
 * not affect the page life cycle.
558
 *
559
 * @since    1.0.0
560
 */
561
function run_wordlift() {
562
563
	$plugin = new Wordlift();
564
	$plugin->run();
565
566
}
567
568
run_wordlift();
569