forked from awesomemotive/all-in-one-seo-pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
all_in_one_seo_pack.php
492 lines (406 loc) · 15.9 KB
/
all_in_one_seo_pack.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
<?php
/*
Plugin Name: All In One SEO Pack
Plugin URI: https://semperfiwebdesign.com
Description: Out-of-the-box SEO for your WordPress blog. Features like XML Sitemaps, SEO for custom post types, SEO for blogs or business sites, SEO for ecommerce sites, and much more. Almost 30 million downloads since 2007.
Version: 2.3.12.1
Author: Michael Torbert
Author URI: https://michaeltorbert.com
Text Domain: all-in-one-seo-pack
Domain Path: /i18n/
*/
/*
Copyright (C) 2007-2016 Michael Torbert, https://semperfiwebdesign.com
This program 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; version 2 of the License.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* All in One SEO Pack.
* The original WordPress SEO plugin.
*
* @package All-in-One-SEO-Pack
* @version 2.3.12.1
*/
if ( ! defined( 'AIOSEOPPRO' ) ) {
define( 'AIOSEOPPRO', false );
}
if ( ! defined( 'AIOSEOP_VERSION' ) ) {
define( 'AIOSEOP_VERSION', '2.3.12.1' );
}
global $aioseop_plugin_name;
$aioseop_plugin_name = 'All in One SEO Pack';
/*
* DO NOT EDIT BELOW THIS LINE.
*/
if ( ! defined( 'ABSPATH' ) ) {
return;
}
if ( AIOSEOPPRO ) {
add_action( 'admin_head', 'disable_all_in_one_free', 1 );
}
if ( ! function_exists( 'aiosp_add_cap' ) ) {
function aiosp_add_cap() {
/*
TODO we should put this into an install script. We just need to make sure it runs soon enough and we need to make
sure people updating from previous versions have access to it.
*/
$role = get_role( 'administrator' );
if ( is_object( $role ) ) {
$role->add_cap( 'aiosp_manage_seo' );
}
}
}
add_action( 'plugins_loaded', 'aiosp_add_cap' );
if ( ! defined( 'AIOSEOP_PLUGIN_NAME' ) ) {
define( 'AIOSEOP_PLUGIN_NAME', $aioseop_plugin_name );
}
if ( ! defined( 'AIOSEOP_PLUGIN_DIR' ) ) {
define( 'AIOSEOP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
} elseif ( AIOSEOP_PLUGIN_DIR !== plugin_dir_path( __FILE__ ) ) {
/*
This is not a great message.
add_action( 'admin_notices', create_function( '', 'echo "' . "<div class='error'>" . sprintf(
__( "%s detected a conflict; please deactivate the plugin located in %s.", 'all-in-one-seo-pack' ),
$aioseop_plugin_name, AIOSEOP_PLUGIN_DIR ) . "</div>" . '";' ) );
*/
return;
}
if ( ! defined( 'AIOSEOP_PLUGIN_BASENAME' ) ) {
define( 'AIOSEOP_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
}
if ( ! defined( 'AIOSEOP_PLUGIN_DIRNAME' ) ) {
define( 'AIOSEOP_PLUGIN_DIRNAME', dirname( AIOSEOP_PLUGIN_BASENAME ) );
}
if ( ! defined( 'AIOSEOP_PLUGIN_URL' ) ) {
define( 'AIOSEOP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'AIOSEOP_PLUGIN_IMAGES_URL' ) ) {
define( 'AIOSEOP_PLUGIN_IMAGES_URL', AIOSEOP_PLUGIN_URL . 'images/' );
}
if ( ! defined( 'AIOSEOP_BASELINE_MEM_LIMIT' ) ) {
define( 'AIOSEOP_BASELINE_MEM_LIMIT', 268435456 );
} // 256MB
if ( ! defined( 'WP_CONTENT_URL' ) ) {
define( 'WP_CONTENT_URL', site_url() . '/wp-content' );
}
if ( ! defined( 'WP_ADMIN_URL' ) ) {
define( 'WP_ADMIN_URL', site_url() . '/wp-admin' );
}
if ( ! defined( 'WP_CONTENT_DIR' ) ) {
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
}
if ( ! defined( 'WP_PLUGIN_URL' ) ) {
define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' );
}
if ( ! defined( 'WP_PLUGIN_DIR' ) ) {
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
}
global $aiosp, $aioseop_options, $aioseop_modules, $aioseop_module_list, $aiosp_activation, $aioseop_mem_limit, $aioseop_get_pages_start, $aioseop_admin_menu;
$aioseop_get_pages_start = $aioseop_admin_menu = 0;
if ( AIOSEOPPRO ) {
global $aioseop_update_checker;
}
$aioseop_options = get_option( 'aioseop_options' );
$aioseop_mem_limit = @ini_get( 'memory_limit' );
if ( ! function_exists( 'aioseop_convert_bytestring' ) ) {
/**
* @param $byte_string
*
* @return int
*/
function aioseop_convert_bytestring( $byte_string ) {
$num = 0;
preg_match( '/^\s*([0-9.]+)\s*([KMGTPE])B?\s*$/i', $byte_string, $matches );
if ( ! empty( $matches ) ) {
$num = (float) $matches[1];
switch ( strtoupper( $matches[2] ) ) {
case 'E':
$num *= 1024;
case 'P':
$num *= 1024;
case 'T':
$num *= 1024;
case 'G':
$num *= 1024;
case 'M':
$num *= 1024;
case 'K':
$num *= 1024;
}
}
return intval( $num );
}
}
if ( is_array( $aioseop_options ) && isset( $aioseop_options['modules'] ) && isset( $aioseop_options['modules']['aiosp_performance_options'] ) ) {
$perf_opts = $aioseop_options['modules']['aiosp_performance_options'];
if ( isset( $perf_opts['aiosp_performance_memory_limit'] ) ) {
$aioseop_mem_limit = $perf_opts['aiosp_performance_memory_limit'];
}
if ( isset( $perf_opts['aiosp_performance_execution_time'] ) && ( '' !== $perf_opts['aiosp_performance_execution_time'] ) ) {
@ini_set( 'max_execution_time', (int) $perf_opts['aiosp_performance_execution_time'] );
@set_time_limit( (int) $perf_opts['aiosp_performance_execution_time'] );
}
} else {
$aioseop_mem_limit = aioseop_convert_bytestring( $aioseop_mem_limit );
if ( ( $aioseop_mem_limit > 0 ) && ( $aioseop_mem_limit < AIOSEOP_BASELINE_MEM_LIMIT ) ) {
$aioseop_mem_limit = AIOSEOP_BASELINE_MEM_LIMIT;
}
}
if ( ! empty( $aioseop_mem_limit ) ) {
if ( ! is_int( $aioseop_mem_limit ) ) {
$aioseop_mem_limit = aioseop_convert_bytestring( $aioseop_mem_limit );
}
if ( ( $aioseop_mem_limit > 0 ) && ( $aioseop_mem_limit <= AIOSEOP_BASELINE_MEM_LIMIT ) ) {
@ini_set( 'memory_limit', $aioseop_mem_limit );
}
}
$aiosp_activation = false;
$aioseop_module_list = array(
'sitemap',
'opengraph',
'robots',
'file_editor',
'importer_exporter',
'bad_robots',
'performance',
); // list all available modules here
if ( AIOSEOPPRO ) {
$aioseop_module_list[] = 'video_sitemap';
}
if ( class_exists( 'All_in_One_SEO_Pack' ) ) {
add_action( 'admin_notices', create_function( '', 'echo "<div class=\'error\'>The All In One SEO Pack class is already defined";'
. "if ( class_exists( 'ReflectionClass' ) ) { \$r = new ReflectionClass( 'All_in_One_SEO_Pack' ); echo ' in ' . \$r->getFileName(); } "
. ' echo ", preventing All In One SEO Pack from loading.</div>";' ) );
return;
}
if ( AIOSEOPPRO ) {
require( AIOSEOP_PLUGIN_DIR . 'pro/sfwd_update_checker.php' );
$aiosp_update_url = 'https://semperplugins.com/upgrade_plugins.php';
if( defined( 'AIOSEOP_UPDATE_URL' ) ) {
$aiosp_update_url = AIOSEOP_UPDATE_URL;
}
$aioseop_update_checker = new SFWD_Update_Checker(
$aiosp_update_url,
__FILE__,
'aioseop'
);
$aioseop_update_checker->plugin_name = AIOSEOP_PLUGIN_NAME;
$aioseop_update_checker->plugin_basename = AIOSEOP_PLUGIN_BASENAME;
if ( ! empty( $aioseop_options['aiosp_license_key'] ) ) {
$aioseop_update_checker->license_key = $aioseop_options['aiosp_license_key'];
} else {
$aioseop_update_checker->license_key = '';
}
$aioseop_update_checker->options_page = AIOSEOP_PLUGIN_DIRNAME . "/aioseop_class.php";
$aioseop_update_checker->renewal_page = 'https://semperplugins.com/all-in-one-seo-pack-pro-support-updates-renewal/';
$aioseop_update_checker->addQueryArgFilter( array( $aioseop_update_checker, 'add_secret_key' ) );
}
if ( ! function_exists( 'aioseop_activate' ) ) {
function aioseop_activate() {
//Check if we just got activated.
global $aiosp_activation;
if ( AIOSEOPPRO ) {
global $aioseop_update_checker;
}
$aiosp_activation = true;
// These checks might be duplicated in the function being called.
if( ! is_network_admin() || !isset( $_GET['activate-multi'] ) ) {
set_transient( '_aioseop_activation_redirect', true, 30 ); // Sets 30 second transient for welcome screen redirect on activation.
}
delete_user_meta( get_current_user_id(), 'aioseop_yst_detected_notice_dismissed' );
if ( AIOSEOPPRO ) {
$aioseop_update_checker->checkForUpdates();
}
}
}
add_action( 'plugins_loaded', 'aioseop_init_class' );
if ( ! function_exists( 'aiosp_plugin_row_meta' ) ) {
add_filter( 'plugin_row_meta', 'aiosp_plugin_row_meta', 10, 2 );
/**
* @param $actions
* @param $plugin_file
*
* @return array
*/
function aiosp_plugin_row_meta( $actions, $plugin_file ) {
if ( ! AIOSEOPPRO ) {
$action_links = array(
);
} else {
$action_links = '';
}
return aiosp_action_links( $actions, $plugin_file, $action_links, 'after' );
}
}
if ( ! function_exists( 'aiosp_add_action_links' ) ) {
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'aiosp_add_action_links', 10, 2 );
/**
* @param $actions
* @param $plugin_file
*
* @return array
*/
function aiosp_add_action_links( $actions, $plugin_file ) {
$aioseop_plugin_dirname = AIOSEOP_PLUGIN_DIRNAME;
$action_links = array();
$action_links = array(
'settings' => array(
'label' => __( 'SEO Settings', 'all-in-one-seo-pack' ),
'url' => get_admin_url( null, "admin.php?page=$aioseop_plugin_dirname/aioseop_class.php" ),
),
'forum' => array(
'label' => __( 'Support Forum', 'all-in-one-seo-pack' ),
'url' => 'https://semperplugins.com/support/',
),
'docs' => array(
'label' => __( 'Documentation', 'all-in-one-seo-pack' ),
'url' => 'https://semperplugins.com/documentation/',
),
);
unset( $actions['edit'] );
if ( ! AIOSEOPPRO ) {
$action_links['proupgrade'] =
array(
'label' => __( 'Upgrade to Pro', 'all-in-one-seo-pack' ),
'url' => 'https://semperplugins.com/plugins/all-in-one-seo-pack-pro-version/?loc=plugins',
);
}
return aiosp_action_links( $actions, $plugin_file, $action_links, 'before' );
}
}
if ( ! function_exists( 'aiosp_action_links' ) ) {
/**
* @param $actions
* @param $plugin_file
* @param array $action_links
* @param string $position
*
* @return array
*/
function aiosp_action_links( $actions, $plugin_file, $action_links = array(), $position = 'after' ) {
static $plugin;
if ( ! isset( $plugin ) ) {
$plugin = plugin_basename( __FILE__ );
}
if ( $plugin === $plugin_file && ! empty( $action_links ) ) {
foreach ( $action_links as $key => $value ) {
$link = array( $key => '<a href="' . $value['url'] . '">' . $value['label'] . '</a>' );
if ( 'after' === $position ) {
$actions = array_merge( $actions, $link );
} else {
$actions = array_merge( $link, $actions );
}
}//foreach
}// if
return $actions;
}
}
if ( ! function_exists( 'aioseop_init_class' ) ) {
function aioseop_init_class() {
global $aiosp;
load_plugin_textdomain( 'all-in-one-seo-pack', false, dirname( plugin_basename( __FILE__ ) ) . '/i18n/' );
require_once( AIOSEOP_PLUGIN_DIR . 'inc/aioseop_functions.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'aioseop_class.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'inc/aioseop_updates_class.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'inc/commonstrings.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'admin/display/postedit.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'admin/display/general-metaboxes.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'inc/aiosp_common.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'admin/meta_import.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'inc/translations.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'public/opengraph.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'inc/compatability/compat-init.php');
require_once( AIOSEOP_PLUGIN_DIR . 'public/front.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'public/google-analytics.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'admin/display/welcome.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'admin/display/dashboard_widget.php' );
require_once( AIOSEOP_PLUGIN_DIR . 'admin/display/menu.php' );
$aioseop_welcome = new aioseop_welcome(); // TODO move this to updates file.
if ( AIOSEOPPRO ) {
require_once( AIOSEOP_PLUGIN_DIR . 'pro/class-aio-pro-init.php' ); // Loads pro files and other pro init stuff.
}
aiosp_seometa_import(); // call importer functions... this should be moved somewhere better
$aiosp = new All_in_One_SEO_Pack();
$aioseop_updates = new AIOSEOP_Updates();
if ( AIOSEOPPRO ) {
$aioseop_pro_updates = new AIOSEOP_Pro_Updates();
add_action( 'admin_init', array( $aioseop_pro_updates, 'version_updates' ), 12 );
}
add_action( 'admin_init', 'aioseop_welcome' );
if ( aioseop_option_isset( 'aiosp_unprotect_meta' ) ) {
add_filter( 'is_protected_meta', 'aioseop_unprotect_meta', 10, 3 );
}
add_action( 'init', array( $aiosp, 'add_hooks' ) );
add_action( 'admin_init', array( $aioseop_updates, 'version_updates' ), 11 );
if ( defined( 'DOING_AJAX' ) && ! empty( $_POST ) && ! empty( $_POST['action'] ) && 'aioseop_ajax_scan_header' === $_POST['action'] ) {
remove_action( 'init', array( $aiosp, 'add_hooks' ) );
add_action( 'admin_init', 'aioseop_scan_post_header' );
add_action( 'shutdown', 'aioseop_ajax_scan_header' ); // if the action doesn't run -- pdb
include_once( ABSPATH . 'wp-admin/includes/screen.php' );
global $current_screen;
if ( class_exists( 'WP_Screen' ) ) {
$current_screen = WP_Screen::get( 'front' );
}
}
}
}
if ( ! function_exists( 'aioseop_welcome' ) ){
function aioseop_welcome(){
if( get_transient( '_aioseop_activation_redirect') ){
$aioseop_welcome = new aioseop_welcome();
delete_transient( '_aioseop_activation_redirect' );
$aioseop_welcome->init( TRUE );
}
}
}
add_action( 'init', 'aioseop_load_modules', 1 );
//add_action( 'after_setup_theme', 'aioseop_load_modules' );
if ( is_admin() ) {
add_action( 'wp_ajax_aioseop_ajax_save_meta', 'aioseop_ajax_save_meta' );
add_action( 'wp_ajax_aioseop_ajax_save_url', 'aioseop_ajax_save_url' );
add_action( 'wp_ajax_aioseop_ajax_delete_url', 'aioseop_ajax_delete_url' );
add_action( 'wp_ajax_aioseop_ajax_scan_header', 'aioseop_ajax_scan_header' );
if ( AIOSEOPPRO ) {
add_action( 'wp_ajax_aioseop_ajax_facebook_debug', 'aioseop_ajax_facebook_debug' );
}
add_action( 'wp_ajax_aioseop_ajax_save_settings', 'aioseop_ajax_save_settings' );
add_action( 'wp_ajax_aioseop_ajax_get_menu_links', 'aioseop_ajax_get_menu_links' );
add_action( 'wp_ajax_aioseo_dismiss_yst_notice', 'aioseop_update_yst_detected_notice' );
add_action( 'wp_ajax_aioseo_dismiss_visibility_notice', 'aioseop_update_user_visibilitynotice' );
add_action( 'wp_ajax_aioseo_dismiss_woo_upgrade_notice', 'aioseop_woo_upgrade_notice_dismissed' );
if ( AIOSEOPPRO ) {
add_action( 'wp_ajax_aioseop_ajax_update_oembed', 'aioseop_ajax_update_oembed' );
}
}
if ( ! function_exists( 'aioseop_scan_post_header' ) ) {
function aioseop_scan_post_header() {
require_once( ABSPATH . WPINC . '/default-filters.php' );
global $wp_query;
$wp_query->query_vars['paged'] = 0;
query_posts( 'post_type=post&posts_per_page=1' );
if ( have_posts() ) {
the_post();
}
}
}
require_once( AIOSEOP_PLUGIN_DIR . 'aioseop-init.php' );
if ( ! function_exists( 'aioseop_install' ) ) {
register_activation_hook( __FILE__, 'aioseop_install' );
function aioseop_install() {
aioseop_activate();
}
}
if ( ! function_exists( 'disable_all_in_one_free' ) ) {
function disable_all_in_one_free() {
if ( AIOSEOPPRO && is_plugin_active( 'all-in-one-seo-pack/all_in_one_seo_pack.php' ) ) {
deactivate_plugins( 'all-in-one-seo-pack/all_in_one_seo_pack.php' );
}
}
}