forked from cubica/p2p-wpml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp2p-wpml.php
executable file
·49 lines (41 loc) · 1.38 KB
/
p2p-wpml.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
Plugin Name: Posts 2 Posts - WPML integration
Plugin URI: https://github.com/cubica/p2p-wpml
Description: A plugin for integrating Posts 2 Posts and WPML, solving some inconsistencies
Version: 1.2.2
Author: Lorenzo Carrara
Author URI: http://www.cubica.eu
License: GPL2
*/
class P2P_WPML {
private static $REQUIRED_PLUGINS = array(
'sitepress-multilingual-cms/sitepress.php',
'posts-to-posts/posts-to-posts.php'
);
public static function init() {
if(self::checkRequiredPlugins()) {
$basePath = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
require_once $basePath . 'synchronizer.php';
require_once $basePath . 'admin.php';
// initialize classes
P2P_WPML_UI::init();
P2P_WPML_Synchronizer::init();
P2P_WPML_Admin::init();
}
else {
add_action('admin_init', array(__CLASS__, 'add_missing_plugins_warning'));
}
}
public static function add_missing_plugins_warning() {
echo '<div class="error"><p><strong>P2P-WPML: in order to use this plugin, both WPML and Posts to Posts must be installed and activated</p></div>';
}
private static function checkRequiredPlugins() {
if(!function_exists('is_plugin_active')) include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
foreach(self::$REQUIRED_PLUGINS as $plugin) {
if(!is_plugin_active($plugin)) return false;
}
return true;
}
}
add_action('init', array('P2P_WPML', 'init'));