forked from etruel/wpematico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwpematico.php
190 lines (178 loc) · 6.12 KB
/
wpematico.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
/**
* Plugin Name: WPeMatico
* Plugin URI: https://www.wpematico.com
* Description: Enables administrators to create posts automatically from RSS/Atom feeds with multiples filters. If you like it, please rate it 5 stars.
* Version: 2.6.3
* Author: etruel <[email protected]>
* Author URI: https://www.netmdp.com
* Text Domain: wpematico
* Domain Path: /lang/
*
* @package WPeMatico
* @category Core
* @author etruel <[email protected]>
*/
# @charset utf-8
if (!function_exists('add_filter'))
exit;
if (!class_exists('Main_WPeMatico')) {
/**
* Main_WPeMatico Class.
*/
class Main_WPeMatico {
private static $instance;
private function setup_constants() {
if (!defined('WPEMATICO_VERSION'))
define('WPEMATICO_VERSION', '2.6.3');
if (!defined('WPEMATICO_BASENAME'))
define('WPEMATICO_BASENAME', plugin_basename(__FILE__));
if (!defined('WPEMATICO_ROOTFILE'))
define('WPEMATICO_ROOTFILE', __FILE__);
if (!defined('WPEMATICO_PLUGIN_URL'))
define('WPEMATICO_PLUGIN_URL', plugin_dir_url(__FILE__));
if (!defined('WPEMATICO_PLUGIN_DIR'))
define('WPEMATICO_PLUGIN_DIR', plugin_dir_path(__FILE__));
}
public static function required_php_notice() {
$class = "error";
$message = '<b>WPeMatico:</b> ' . __('PHP 5.3.0 or higher needed!', 'wpematico') . '<br />';
echo"<div class=\"$class\"> <p>$message</p></div>";
}
public static function instance() {
if (version_compare(phpversion(), '5.3.0', '<')) { // check PHP Version
add_action('admin_notices', array(__CLASS__, 'required_php_notice'));
return false;
}
if (!self::$instance) {
self::$instance = new Main_WPeMatico();
self::$instance->setup_constants();
self::$instance->includes();
self::$instance->load_textdomain();
self::$instance->hooks();
self::$instance->setup_cron();
}
return self::$instance;
}
private function includes() {
global $cfg;
if (is_admin()) {
if (file_exists('app/nonstatic.php'))
require_once('app/nonstatic.php');
require_once('app/plugin_functions.php');
require_once('app/campaigns_list.php');
require_once("app/campaign_edit_functions.php");
require_once('app/campaign_edit.php');
require_once("app/settings_help.php");
require_once("app/settings_page.php");
require_once("app/debug_page.php");
require_once("app/settings_tabs.php");
require_once("app/addons_page.php");
require_once("app/notification_traslate.php");
require_once("app/smart_notifications.php");
require_once("app/wp-backend-helpers.php");
require_once('app/lib/licenses_handlers.php');
require_once("app/lib/welcome.php");
require_once('app/campaign_log.php');
require_once('app/campaign_preview.php');
require_once('app/campaign_preview_item.php');
}
require_once('app/cron_functions.php');
require_once('app/compatibilities.php');
require_once('app/wpematico_functions.php');
require_once('wpematico_class.php');
require_once('app/xml-importer.php');
require_once('app/cron.php');
}
private function hooks() {
add_action('init', array('WPeMatico', 'init'));
add_action('the_permalink', array('WPeMatico', 'wpematico_permalink'));
add_filter('post_link', array('WPeMatico', 'wpematico_permalink'));
}
/**
* setup_cron
*
* @access public
* @since 1.0.0
* @return void
*/
public function setup_cron() {
global $cfg;
//Disable WP_Cron
if (isset($cfg['disablewpcron']) && $cfg['disablewpcron']) {
if (!defined('DISABLE_WP_CRON')) {
define('DISABLE_WP_CRON', true);
}
}
if (isset($cfg['enable_alternate_wp_cron']) && $cfg['enable_alternate_wp_cron']) {
if (!defined('ALTERNATE_WP_CRON')) {
define('ALTERNATE_WP_CRON', true);
}
}
if (isset($cfg['dontruncron']) && $cfg['dontruncron']) {
wp_clear_scheduled_hook('wpematico_cron');
} else {
add_filter('cron_schedules', 'wpematico_intervals'); //add cron intervals
add_action('wpematico_cron', 'wpem_cron_callback'); //Actions for Cron job
//test if cron active
if (!wp_next_scheduled('wpematico_cron')) {
wp_schedule_event(time(), 'wpematico_int', 'wpematico_cron');
}
}
}
/**
* Internationalization
*
* @access public
* @since 1.0.0
* @simplify to standard WP 2.6.3
* @return void
*/
public function load_textdomain() {
load_plugin_textdomain('wpematico', false, 'wpematico/lang');
}
/**
* Internationalization
*
* @access public
* @since 1.0.0
* @return void
*/
// public function load_textdomain() {
// // Set filter for language directory
// $lang_dir = WPEMATICO_PLUGIN_DIR . '/lang/';
// $lang_dir = apply_filters( 'wpematico_languages_directory', $lang_dir );
//
// // Traditional WordPress plugin locale filter
// $locale = apply_filters( 'plugin_locale', get_locale(), 'wpematico' );
// $mofile = sprintf( '%1$s-%2$s.mo', 'wpematico', $locale );
//
// // Setup paths to current locale file
// $mofile_local = $lang_dir . $mofile;
// $mofile_global = WP_LANG_DIR . '/wpematico/' . $mofile;
//
// /**
// * Directory of language packs through translate.wordpress.org
// * @var $mofile_global2 String.
// * @since 1.6.2
// */
// $mofile_global2 = WP_LANG_DIR . '/plugins/wpematico/' . $mofile;
//
// if( file_exists( $mofile_global ) ) {
// // Look in global /wp-content/languages/wpematico/ folder
// load_textdomain( 'wpematico', $mofile_global );
// } elseif( file_exists( $mofile_global2 ) ) {
// // Look in global /wp-content/languages/plugins/wpematico/ folder
// load_textdomain( 'wpematico', $mofile_global2 );
// } elseif( file_exists( $mofile_local ) ) {
// // Look in local /wp-content/plugins/wpematico/languages/ folder
// load_textdomain( 'wpematico', $mofile_local );
// } else {
// // Load the default language files
// load_plugin_textdomain( 'wpematico', false, $lang_dir );
// }
// }
}
//class WPeMatico
}
$WPeMatico = Main_WPeMatico::instance();