-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathum-polylang.php
77 lines (69 loc) · 2.79 KB
/
um-polylang.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* Plugin Name: Ultimate Member - Polylang
* Plugin URI: https://github.com/umdevelopera/um-polylang
* Description: Integrates Ultimate Member with Polylang.
* Author: umdevelopera
* Author URI: https://github.com/umdevelopera
* Text Domain: um-polylang
* Domain Path: /languages
*
* Requires Plugins: ultimate-member, polylang
* Requires at least: 6.5
* Requires PHP: 7.4
* UM version: 2.9.2
* Version: 1.2.2
*
* @package um_ext\um_polylang
*/
defined( 'ABSPATH' ) || exit;
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$plugin_data = get_plugin_data( __FILE__, true, false );
define( 'um_polylang_url', plugin_dir_url( __FILE__ ) );
define( 'um_polylang_path', plugin_dir_path( __FILE__ ) );
define( 'um_polylang_plugin', plugin_basename( __FILE__ ) );
define( 'um_polylang_extension', $plugin_data['Name'] );
define( 'um_polylang_version', $plugin_data['Version'] );
define( 'um_polylang_textdomain', 'um-polylang' );
// Activation script.
if ( ! function_exists( 'um_polylang_activation_hook' ) ) {
function um_polylang_activation_hook() {
if ( function_exists( 'UM' ) && function_exists( 'pll_languages_list' ) ) {
require_once 'includes/admin/class-pll.php';
require_once 'includes/core/class-setup.php';
if ( class_exists( 'um_ext\um_polylang\core\Setup' ) ) {
$setup = new um_ext\um_polylang\core\Setup();
$setup->run();
}
}
}
}
register_activation_hook( um_polylang_plugin, 'um_polylang_activation_hook' );
// Check dependencies.
if ( ! function_exists( 'um_polylang_check_dependencies' ) ) {
function um_polylang_check_dependencies() {
if ( ! defined( 'um_path' ) || ! function_exists( 'UM' ) || ! UM()->dependencies()->ultimatemember_active_check() ) {
// Ultimate Member is not active.
add_action(
'admin_notices',
function () {
// translators: %s - plugin name.
echo '<div class="error"><p>' . wp_kses_post( sprintf( __( 'The <strong>%s</strong> extension requires the Ultimate Member plugin to be activated to work properly. You can download it <a href="https://wordpress.org/plugins/ultimate-member">here</a>', 'um-polylang' ), um_polylang_extension ) ) . '</p></div>';
}
);
} elseif ( ! defined( 'POLYLANG_VERSION' ) ) {
// Polylang is not active.
add_action(
'admin_notices',
function () {
// translators: %s - plugin name.
echo '<div class="error"><p>' . wp_kses_post( sprintf( __( 'The <strong>%s</strong> extension requires the Polylang plugin to be activated to work properly. You can download it <a href="https://wordpress.org/plugins/polylang/">here</a>', 'um-polylang' ), um_polylang_extension ) ) . '</p></div>';
}
);
} else {
require_once 'includes/class-um-polylang.php';
UM()->set_class( 'Polylang', true );
}
}
}
add_action( 'init', 'um_polylang_check_dependencies', 1 );