-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwpem-divi-elements.php
130 lines (113 loc) · 4.14 KB
/
wpem-divi-elements.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/*
Plugin Name: WP Event Manager - Divi Elements
Plugin URI: www.wp-eventmanager.com
Description: Divi element provides an easy interface that smoothly combines with the Divi theme builder to offer you a toolset to add various elements without shortcodes.
Version: 1.0.1
Author: WPEM Team
Author URI: www.wp-eventmanager.com
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wpem-divi-elements
Domain Path: /languages
WP Event Manager Divi Elements is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
any later version.
WP Event Manager Divi Elements is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with WP Event Manager Divi Elements. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) )
exit;
include_once(ABSPATH.'wp-admin/includes/plugin.php');
function pre_check_before_installing_divi_elements()
{
/*
* Check weather WP Event Manager is installed or not. If WP Event Manger is not installed or active then it will give notification to admin panel
*/
if (! in_array( 'wp-event-manager/wp-event-manager.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) )
{
global $pagenow;
if( $pagenow == 'plugins.php' )
{
echo '<div id="error" class="error notice is-dismissible"><p>';
echo __( 'WP Event Manager is require to use WP Event Manager - Divi Elements' , 'wpem-divi-elements');
echo '</p></div>';
}
//return true;
}
}
add_action( 'admin_notices', 'pre_check_before_installing_divi_elements' );
/**
* WP_Event_Manager_Divi_Elements class.
*/
class WPEM_Divi_Elements {
/**
* The single instance of the class.
*
* @var self
* @since 1.0.0
*/
private static $_instance = null;
/**
* Main WP Event Manager Instance.
*
* Ensures only one instance of WP Event Manager is loaded or can be loaded.
*
* @since 1.0.0
* @static
* @see WP_Event_Manager()
* @return self Main instance.
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Constructor
*/
public function __construct()
{
// Define constants
define( 'WPEM_DIVI_ELEMENTS_VERSION', '1.0.1' );
define( 'WPEM_DIVI_ELEMENTS_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
define( 'WPEM_DIVI_ELEMENTS_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
add_action( 'divi_extensions_init', array($this,'wpem_initialize_extension') );
}
/**
* Creates the extension's main class instance.
*
* @since 1.0.0
*/
public function wpem_initialize_extension() {
require_once plugin_dir_path( __FILE__ ) . 'includes/WpEventManagerDiviElements.php';
}
/**
* Localisation
*/
public function load_plugin_textdomain() {
$domain = 'wpem-divi-elements';
$locale = apply_filters('plugin_locale', get_locale(), $domain);
load_textdomain( $domain, WP_LANG_DIR . "/wpem-divi-elements/".$domain."-" .$locale. ".mo" );
load_plugin_textdomain($domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
}
/**
* Main instance of WP Event Manager Speaker & Schedule.
*
* Returns the main instance of WP Event Manager to prevent the need to use globals.
*
* @since 1.0.0
* @return WPEM_Divi_Elements
*/
function wpem_divi_elements() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName
return WPEM_Divi_Elements::instance();
}
$GLOBALS['wpem_divi_elements'] = wpem_divi_elements();