Version Description
Download this release
Release Info
Developer | jipmoors |
Plugin | Yoast SEO |
Version | 7.1 |
Comparing to | |
See all releases |
Code changes from version 7.0.3 to 7.1
- admin/ajax.php +14 -17
- admin/banner/class-admin-banner-sidebar.php +10 -52
- admin/class-admin.php +0 -13
- admin/class-customizer.php +3 -3
- admin/class-import-aioseo.php +0 -107
- admin/class-import-external.php +0 -113
- admin/class-import-jetpack.php +0 -31
- admin/class-import-ultimate-seo.php +0 -54
- admin/class-import-woothemes-seo.php +0 -149
- admin/class-import-wpseo.php +0 -208
- admin/class-social-facebook-form.php +0 -273
- admin/class-social-facebook.php +0 -211
- admin/class-yoast-dashboard-widget.php +1 -1
- admin/import/class-import-aioseo-hooks.php +0 -40
- admin/import/class-import-detector.php +29 -0
- admin/import/class-import-hooks.php +0 -89
- admin/import/class-import-plugin.php +56 -0
- admin/{class-import.php → import/class-import-settings.php} +39 -43
- admin/import/class-import-status.php +126 -0
- admin/import/class-import-wpseo-hooks.php +0 -40
- admin/import/plugins/class-import-aioseo.php +113 -0
- admin/import/plugins/class-import-headspace.php +123 -0
- admin/import/plugins/class-import-jetpack.php +99 -0
- admin/{class-import-seopressor.php → import/plugins/class-import-seopressor.php} +84 -43
- admin/import/plugins/class-import-ultimate-seo.php +107 -0
- admin/import/plugins/class-import-woothemes-seo.php +154 -0
- admin/import/plugins/class-import-wpseo.php +300 -0
- admin/import/plugins/class-importers.php +33 -0
- admin/import/plugins/interface-plugin-importer.php +39 -0
- admin/onpage/class-onpage.php +94 -76
- admin/statistics/class-statistics-service.php +4 -5
- admin/views/licenses.php +36 -32
- admin/views/tabs/metas/breadcrumbs.php +1 -1
- admin/views/tabs/social/facebook.php +0 -3
- admin/views/tabs/tool/import-seo.php +91 -34
- admin/views/tabs/tool/wpseo-export.php +0 -1
- admin/views/tool-import-export.php +18 -40
- css/dist/{admin-global-703-rtl.min.css → admin-global-710-rtl.min.css} +0 -0
- css/dist/{admin-global-703.min.css → admin-global-710.min.css} +0 -0
- css/dist/{adminbar-703-rtl.min.css → adminbar-710-rtl.min.css} +0 -0
- css/dist/{adminbar-703.min.css → adminbar-710.min.css} +0 -0
- css/dist/{alerts-703-rtl.min.css → alerts-710-rtl.min.css} +0 -0
- css/dist/{alerts-703.min.css → alerts-710.min.css} +0 -0
- css/dist/{dashboard-703-rtl.min.css → dashboard-710-rtl.min.css} +0 -0
- css/dist/{dashboard-703.min.css → dashboard-710.min.css} +0 -0
- css/dist/{edit-page-703-rtl.min.css → edit-page-710-rtl.min.css} +0 -0
- css/dist/{edit-page-703.min.css → edit-page-710.min.css} +0 -0
- css/dist/{featured-image-703-rtl.min.css → featured-image-710-rtl.min.css} +0 -0
- css/dist/{featured-image-703.min.css → featured-image-710.min.css} +0 -0
- css/dist/{filter-explanation-703-rtl.min.css → filter-explanation-710-rtl.min.css} +0 -0
- css/dist/{filter-explanation-703.min.css → filter-explanation-710.min.css} +0 -0
- css/dist/{inside-editor-703-rtl.min.css → inside-editor-710-rtl.min.css} +0 -0
- css/dist/{inside-editor-703.min.css → inside-editor-710.min.css} +0 -0
- css/dist/{metabox-703-rtl.min.css → metabox-710-rtl.min.css} +1 -1
- css/dist/{metabox-703.min.css → metabox-710.min.css} +1 -1
- css/dist/{metabox-primary-category-703-rtl.min.css → metabox-primary-category-710-rtl.min.css} +0 -0
- css/dist/{metabox-primary-category-703.min.css → metabox-primary-category-710.min.css} +0 -0
- css/dist/{snippet-703-rtl.min.css → snippet-710-rtl.min.css} +0 -0
- css/dist/{snippet-703.min.css → snippet-710.min.css} +0 -0
- css/dist/{toggle-switch-703-rtl.min.css → toggle-switch-710-rtl.min.css} +0 -0
- css/dist/{toggle-switch-703.min.css → toggle-switch-710.min.css} +0 -0
- css/dist/{wpseo-dismissible-703-rtl.min.css → wpseo-dismissible-710-rtl.min.css} +0 -0
- css/dist/{wpseo-dismissible-703.min.css → wpseo-dismissible-710.min.css} +0 -0
- css/dist/{yoast-components-703-rtl.min.css → yoast-components-710-rtl.min.css} +0 -0
- css/dist/{yoast-components-703.min.css → yoast-components-710.min.css} +0 -0
- css/dist/{yoast-extensions-703-rtl.min.css → yoast-extensions-710-rtl.min.css} +0 -0
- css/dist/{yoast-extensions-703.min.css → yoast-extensions-710.min.css} +0 -0
- css/dist/yst_plugin_tools-703.min.css +0 -1
- css/dist/{yst_plugin_tools-703-rtl.min.css → yst_plugin_tools-710-rtl.min.css} +1 -1
- css/dist/yst_plugin_tools-710.min.css +1 -0
- css/dist/{yst_seo_score-703-rtl.min.css → yst_seo_score-710-rtl.min.css} +0 -0
- css/dist/{yst_seo_score-703.min.css → yst_seo_score-710.min.css} +0 -0
- frontend/class-breadcrumbs.php +1 -1
- frontend/class-frontend.php +77 -59
- frontend/class-opengraph.php +17 -39
- inc/class-upgrade.php +21 -1
- inc/class-wpseo-meta.php +1 -1
- inc/class-wpseo-replace-vars.php +15 -2
- inc/options/class-wpseo-option-social.php +0 -86
- inc/options/class-wpseo-option-titles.php +2 -2
- inc/options/class-wpseo-option.php +3 -0
- inc/options/class-wpseo-options-backfill.php +14 -1
- inc/options/class-wpseo-options.php +5 -0
- inc/wpseo-non-ajax-functions.php +0 -7
- js/dist/{commons-703.min.js → commons-710.min.js} +6 -6
- js/dist/configuration-wizard-703.min.js +0 -19
admin/ajax.php
CHANGED
@@ -282,23 +282,6 @@ function wpseo_upsert_new( $what, $post_id, $new, $original ) {
|
|
282 |
return wpseo_upsert_meta( $post_id, $new, $original, $meta_key, $what );
|
283 |
}
|
284 |
|
285 |
-
/**
|
286 |
-
* Handles the posting of a new FB admin.
|
287 |
-
*/
|
288 |
-
function wpseo_add_fb_admin() {
|
289 |
-
check_ajax_referer( 'wpseo_fb_admin_nonce' );
|
290 |
-
|
291 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
292 |
-
die( '-1' );
|
293 |
-
}
|
294 |
-
|
295 |
-
$facebook_social = new Yoast_Social_Facebook();
|
296 |
-
|
297 |
-
wp_die( $facebook_social->add_admin( filter_input( INPUT_POST, 'admin_name' ), filter_input( INPUT_POST, 'admin_id' ) ) );
|
298 |
-
}
|
299 |
-
|
300 |
-
add_action( 'wp_ajax_wpseo_add_fb_admin', 'wpseo_add_fb_admin' );
|
301 |
-
|
302 |
/**
|
303 |
* Retrieves the keyword for the keyword doubles.
|
304 |
*/
|
@@ -388,3 +371,17 @@ function wpseo_kill_blocking_files() {
|
|
388 |
|
389 |
wpseo_ajax_json_echo_die( '' );
|
390 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
return wpseo_upsert_meta( $post_id, $new, $original, $meta_key, $what );
|
283 |
}
|
284 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
/**
|
286 |
* Retrieves the keyword for the keyword doubles.
|
287 |
*/
|
371 |
|
372 |
wpseo_ajax_json_echo_die( '' );
|
373 |
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* Handles the posting of a new FB admin.
|
377 |
+
*
|
378 |
+
* @deprecated 7.1
|
379 |
+
* @codeCoverageIgnore
|
380 |
+
*/
|
381 |
+
function wpseo_add_fb_admin() {
|
382 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
383 |
+
die( '-1' );
|
384 |
+
}
|
385 |
+
_deprecated_function( __FUNCTION__, 'WPSEO 7.0', 'This method is deprecated.' );
|
386 |
+
wpseo_ajax_json_echo_die( '' );
|
387 |
+
}
|
admin/banner/class-admin-banner-sidebar.php
CHANGED
@@ -88,45 +88,19 @@ class WPSEO_Admin_Banner_Sidebar {
|
|
88 |
|
89 |
$premium_spot->set_extra(
|
90 |
/* translators: %1$s expands to the plugin name */
|
91 |
-
'<h2>' . sprintf(
|
92 |
'<ul>' .
|
93 |
-
'<li><strong>' .
|
94 |
-
'<li><strong>' .
|
95 |
-
'<li><strong>' .
|
96 |
-
'<li><strong>' .
|
97 |
-
'<li><strong>' .
|
98 |
-
'<li><strong>' .
|
99 |
'</ul>' .
|
100 |
/* translators: %s expands to Yoast SEO Premium */
|
101 |
-
'<a id="wpseo-premium-button" class="button button-primary" href="' . $premium_uri . '" target="_blank">' . sprintf( __( 'Get %s now
|
102 |
);
|
103 |
|
104 |
-
/*
|
105 |
-
$premium_spot->set_description(
|
106 |
-
sprintf(
|
107 |
-
/* translators: %1$s expands to a link start tag to the Yoast plugin page, %2$s is the link closing tag * /
|
108 |
-
__( 'Want to get the most out of your SEO-strategy? %1$sGo premium!%2$s.', 'wordpress-seo' ),
|
109 |
-
'<a target="_blank" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/ji' ) . '">',
|
110 |
-
'</a>'
|
111 |
-
)
|
112 |
-
);
|
113 |
-
/*
|
114 |
-
|
115 |
-
$premium_spot->add_banner(
|
116 |
-
new WPSEO_Admin_Banner(
|
117 |
-
WPSEO_Shortlinker::get( 'https://yoa.st/jj' ),
|
118 |
-
'premium-seo.png',
|
119 |
-
261,
|
120 |
-
152,
|
121 |
-
sprintf(
|
122 |
-
/* translators: %1$s expands to Yoast SEO Premium. * /
|
123 |
-
__( 'Buy the %1$s plugin now and get access to extra features and 24/7 support!', 'wordpress-seo' ),
|
124 |
-
'Yoast SEO Premium'
|
125 |
-
)
|
126 |
-
)
|
127 |
-
);
|
128 |
-
*/
|
129 |
-
|
130 |
return $premium_spot;
|
131 |
}
|
132 |
|
@@ -162,22 +136,6 @@ class WPSEO_Admin_Banner_Sidebar {
|
|
162 |
)
|
163 |
);
|
164 |
|
165 |
-
/*
|
166 |
-
$service_spot->add_banner(
|
167 |
-
new WPSEO_Admin_Banner(
|
168 |
-
WPSEO_Shortlinker::get( 'https://yoa.st/seo-care-banner' ),
|
169 |
-
'seo-care.png',
|
170 |
-
261,
|
171 |
-
152,
|
172 |
-
sprintf(
|
173 |
-
/* translators: %1$s expands to Yoast SEO Care. * /
|
174 |
-
__( 'Let us help you take care of the SEO of your website. Order %1$s now!', 'wordpress-seo' ),
|
175 |
-
'Yoast SEO Care'
|
176 |
-
)
|
177 |
-
)
|
178 |
-
);
|
179 |
-
*/
|
180 |
-
|
181 |
return $service_spot;
|
182 |
}
|
183 |
|
@@ -286,12 +244,12 @@ class WPSEO_Admin_Banner_Sidebar {
|
|
286 |
* @return WPSEO_Admin_Banner_Spot
|
287 |
*/
|
288 |
protected function get_courses_spot() {
|
289 |
-
$courses_spot = new WPSEO_Admin_Banner_Spot( __( '
|
290 |
|
291 |
$courses_spot->set_description(
|
292 |
sprintf(
|
293 |
/* translators: %1$s expands to a link start tag to the Yoast Services page, %2$s is the link closing tag. */
|
294 |
-
__( '
|
295 |
'<a target="_blank" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/jt' ) . '">',
|
296 |
'</a>'
|
297 |
)
|
88 |
|
89 |
$premium_spot->set_extra(
|
90 |
/* translators: %1$s expands to the plugin name */
|
91 |
+
'<h2>' . sprintf( esc_html__( 'Upgrade to %1$s', 'wordpress-seo' ), 'Yoast SEO Premium' ) . '</h2>' .
|
92 |
'<ul>' .
|
93 |
+
'<li><strong>' . esc_html__( 'Rank for up to 5 focus keywords per page', 'wordpress-seo' ) . '</strong></li>' .
|
94 |
+
'<li><strong>' . esc_html__( 'Preview your page in Facebook and Twitter', 'wordpress-seo' ) . '</strong></li>' .
|
95 |
+
'<li><strong>' . esc_html__( 'Get real-time suggestions for internal links', 'wordpress-seo' ) . '</strong></li>' .
|
96 |
+
'<li><strong>' . esc_html__( 'No more dead links a.k.a. 404 pages', 'wordpress-seo' ) . '</strong></li>' .
|
97 |
+
'<li><strong>' . esc_html__( '24/7 email support', 'wordpress-seo' ) . '</strong></li>' .
|
98 |
+
'<li><strong>' . esc_html__( 'No ads', 'wordpress-seo' ) . '</strong></li>' .
|
99 |
'</ul>' .
|
100 |
/* translators: %s expands to Yoast SEO Premium */
|
101 |
+
'<a id="wpseo-premium-button" class="button button-primary" href="' . $premium_uri . '" target="_blank">' . sprintf( __( 'Get %s now', 'wordpress-seo' ), 'Yoast SEO Premium' ) . '</a><br/>'
|
102 |
);
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
return $premium_spot;
|
105 |
}
|
106 |
|
136 |
)
|
137 |
);
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
return $service_spot;
|
140 |
}
|
141 |
|
244 |
* @return WPSEO_Admin_Banner_Spot
|
245 |
*/
|
246 |
protected function get_courses_spot() {
|
247 |
+
$courses_spot = new WPSEO_Admin_Banner_Spot( __( 'Improve your SEO skills', 'wordpress-seo' ), $this->banner_renderer );
|
248 |
|
249 |
$courses_spot->set_description(
|
250 |
sprintf(
|
251 |
/* translators: %1$s expands to a link start tag to the Yoast Services page, %2$s is the link closing tag. */
|
252 |
+
__( 'We believe SEO should be for everyone. That’s why we develop courses on any topic related to SEO. %1$sDiscover our online SEO courses »%2$s', 'wordpress-seo' ),
|
253 |
'<a target="_blank" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/jt' ) . '">',
|
254 |
'</a>'
|
255 |
)
|
admin/class-admin.php
CHANGED
@@ -66,7 +66,6 @@ class WPSEO_Admin {
|
|
66 |
add_filter( 'set-screen-option', array( $this, 'save_bulk_edit_options' ), 10, 3 );
|
67 |
|
68 |
add_action( 'admin_init', array( 'WPSEO_Plugin_Conflict', 'hook_check_for_plugin_conflicts' ), 10, 1 );
|
69 |
-
add_action( 'admin_init', array( $this, 'import_plugin_hooks' ) );
|
70 |
|
71 |
add_action( 'admin_init', array( $this, 'map_manage_options_cap' ) );
|
72 |
|
@@ -102,18 +101,6 @@ class WPSEO_Admin {
|
|
102 |
|
103 |
}
|
104 |
|
105 |
-
/**
|
106 |
-
* Setting the hooks for importing data from other plugins.
|
107 |
-
*/
|
108 |
-
public function import_plugin_hooks() {
|
109 |
-
if ( current_user_can( $this->get_manage_options_cap() ) ) {
|
110 |
-
$plugin_imports = array(
|
111 |
-
'wpSEO' => new WPSEO_Import_WPSEO_Hooks(),
|
112 |
-
'aioseo' => new WPSEO_Import_AIOSEO_Hooks(),
|
113 |
-
);
|
114 |
-
}
|
115 |
-
}
|
116 |
-
|
117 |
/**
|
118 |
* Schedules a rewrite flush to happen at shutdown.
|
119 |
*/
|
66 |
add_filter( 'set-screen-option', array( $this, 'save_bulk_edit_options' ), 10, 3 );
|
67 |
|
68 |
add_action( 'admin_init', array( 'WPSEO_Plugin_Conflict', 'hook_check_for_plugin_conflicts' ), 10, 1 );
|
|
|
69 |
|
70 |
add_action( 'admin_init', array( $this, 'map_manage_options_cap' ) );
|
71 |
|
101 |
|
102 |
}
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
/**
|
105 |
* Schedules a rewrite flush to happen at shutdown.
|
106 |
*/
|
admin/class-customizer.php
CHANGED
@@ -71,7 +71,7 @@ class WPSEO_Customizer {
|
|
71 |
*/
|
72 |
private function breadcrumbs_blog_remove_setting() {
|
73 |
$this->wp_customize->add_setting(
|
74 |
-
'wpseo_titles[breadcrumbs-blog-
|
75 |
'default' => '',
|
76 |
'type' => 'option',
|
77 |
'transport' => 'refresh',
|
@@ -80,11 +80,11 @@ class WPSEO_Customizer {
|
|
80 |
|
81 |
$this->wp_customize->add_control(
|
82 |
new WP_Customize_Control(
|
83 |
-
$this->wp_customize, 'wpseo-breadcrumbs-blog-
|
84 |
'label' => __( 'Remove blog page from breadcrumbs', 'wordpress-seo' ),
|
85 |
'type' => 'checkbox',
|
86 |
'section' => 'wpseo_breadcrumbs_customizer_section',
|
87 |
-
'settings' => 'wpseo_titles[breadcrumbs-blog-
|
88 |
'context' => '',
|
89 |
'active_callback' => array( $this, 'breadcrumbs_blog_remove_active_cb' ),
|
90 |
)
|
71 |
*/
|
72 |
private function breadcrumbs_blog_remove_setting() {
|
73 |
$this->wp_customize->add_setting(
|
74 |
+
'wpseo_titles[breadcrumbs-display-blog-page]', array(
|
75 |
'default' => '',
|
76 |
'type' => 'option',
|
77 |
'transport' => 'refresh',
|
80 |
|
81 |
$this->wp_customize->add_control(
|
82 |
new WP_Customize_Control(
|
83 |
+
$this->wp_customize, 'wpseo-breadcrumbs-display-blog-page', array(
|
84 |
'label' => __( 'Remove blog page from breadcrumbs', 'wordpress-seo' ),
|
85 |
'type' => 'checkbox',
|
86 |
'section' => 'wpseo_breadcrumbs_customizer_section',
|
87 |
+
'settings' => 'wpseo_titles[breadcrumbs-display-blog-page]',
|
88 |
'context' => '',
|
89 |
'active_callback' => array( $this, 'breadcrumbs_blog_remove_active_cb' ),
|
90 |
)
|
admin/class-import-aioseo.php
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package WPSEO\Admin\Import\External
|
4 |
-
*/
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class with functionality to import Yoast SEO settings from All In One SEO.
|
8 |
-
*/
|
9 |
-
class WPSEO_Import_AIOSEO extends WPSEO_Import_External {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Holds the AOIOSEO options
|
13 |
-
*
|
14 |
-
* @var array
|
15 |
-
*/
|
16 |
-
private $aioseo_options;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Import All In One SEO settings
|
20 |
-
*
|
21 |
-
* @param boolean $replace Boolean replace switch.
|
22 |
-
*/
|
23 |
-
public function __construct( $replace = false ) {
|
24 |
-
parent::__construct( $replace );
|
25 |
-
|
26 |
-
$this->aioseo_options = get_option( 'aioseop_options' );
|
27 |
-
|
28 |
-
$this->success = true;
|
29 |
-
$this->import_metas();
|
30 |
-
$this->import_ga();
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Import All In One SEO meta values.
|
35 |
-
*/
|
36 |
-
private function import_metas() {
|
37 |
-
WPSEO_Meta::replace_meta( '_aioseop_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace );
|
38 |
-
WPSEO_Meta::replace_meta( '_aioseop_keywords', WPSEO_Meta::$meta_prefix . 'metakeywords', $this->replace );
|
39 |
-
WPSEO_Meta::replace_meta( '_aioseop_title', WPSEO_Meta::$meta_prefix . 'title', $this->replace );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Import the Google Analytics settings.
|
44 |
-
*
|
45 |
-
* These values are used in Google Analytics for WordPress by MonsterInsights and will be converted in the plugin
|
46 |
-
* to usable settings when a user installs the Google Analytics plugin for the first time.
|
47 |
-
*/
|
48 |
-
private function import_ga() {
|
49 |
-
if ( ! isset( $this->aioseo_options['aiosp_google_analytics_id'] ) ) {
|
50 |
-
$this->set_msg( sprintf(
|
51 |
-
/* translators: 1: link open tag; 2: link close tag. */
|
52 |
-
__( 'All in One SEO data successfully imported. Would you like to %1$sdisable the All in One SEO plugin%2$s?', 'wordpress-seo' ),
|
53 |
-
'<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_tools&tool=import-export&deactivate_aioseo=1#top#import-seo' ) ) . '">',
|
54 |
-
'</a>'
|
55 |
-
) );
|
56 |
-
|
57 |
-
return;
|
58 |
-
}
|
59 |
-
|
60 |
-
if ( get_option( 'yst_ga' ) === false ) {
|
61 |
-
update_option( 'yst_ga', $this->determine_ga_settings() );
|
62 |
-
}
|
63 |
-
|
64 |
-
$plugin_install_nonce = wp_create_nonce( 'install-plugin_google-analytics-for-wordpress' ); // Use the old name because that's the WordPress.org repo.
|
65 |
-
|
66 |
-
$this->set_msg( sprintf(
|
67 |
-
/* translators: 1,2: link open tag; 3: link close tag. */
|
68 |
-
__( 'All in One SEO data successfully imported. Would you like to %1$sdisable the All in One SEO plugin%3$s? You\'ve had Google Analytics enabled in All in One SEO, would you like to install the %2$sGoogle Analytics plugin%3$s?', 'wordpress-seo' ),
|
69 |
-
'<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_tools&tool=import-export&deactivate_aioseo=1#top#import-seo' ) ) . '">',
|
70 |
-
'<a href="' . esc_url( admin_url( 'update.php?action=install-plugin&plugin=google-analytics-for-wordpress&_wpnonce=' . $plugin_install_nonce ) ) . '">',
|
71 |
-
'</a>'
|
72 |
-
) );
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Determine the appropriate GA settings for this site.
|
77 |
-
*
|
78 |
-
* @return array $ga_settings The imported settings.
|
79 |
-
*/
|
80 |
-
private function determine_ga_settings() {
|
81 |
-
$ga_universal = 0;
|
82 |
-
if ( $this->aioseo_options['aiosp_ga_use_universal_analytics'] === 'on' ) {
|
83 |
-
$ga_universal = 1;
|
84 |
-
}
|
85 |
-
|
86 |
-
$ga_track_outbound = 0;
|
87 |
-
if ( $this->aioseo_options['aiosp_ga_track_outbound_links'] === 'on' ) {
|
88 |
-
$ga_track_outbound = 1;
|
89 |
-
}
|
90 |
-
|
91 |
-
$ga_anonymize_ip = 0;
|
92 |
-
if ( $this->aioseo_options['aiosp_ga_anonymize_ip'] === 'on' ) {
|
93 |
-
$ga_anonymize_ip = 1;
|
94 |
-
}
|
95 |
-
|
96 |
-
return array(
|
97 |
-
'ga_general' => array(
|
98 |
-
'manual_ua_code' => (int) 1,
|
99 |
-
'manual_ua_code_field' => $this->aioseo_options['aiosp_google_analytics_id'],
|
100 |
-
'enable_universal' => $ga_universal,
|
101 |
-
'track_outbound' => $ga_track_outbound,
|
102 |
-
'ignore_users' => (array) $this->aioseo_options['aiosp_ga_exclude_users'],
|
103 |
-
'anonymize_ips' => (int) $ga_anonymize_ip,
|
104 |
-
),
|
105 |
-
);
|
106 |
-
}
|
107 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-import-external.php
DELETED
@@ -1,113 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package WPSEO\Admin\Import\External
|
4 |
-
*/
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class WPSEO_Import_External
|
8 |
-
*
|
9 |
-
* Class with functionality to import Yoast SEO settings from other plugins
|
10 |
-
*/
|
11 |
-
class WPSEO_Import_External {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Whether or not to delete old data.
|
15 |
-
*
|
16 |
-
* @var boolean
|
17 |
-
*/
|
18 |
-
protected $replace;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Message about the import status.
|
22 |
-
*
|
23 |
-
* @var string
|
24 |
-
*/
|
25 |
-
public $msg = '';
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Whether import has been successful.
|
29 |
-
*
|
30 |
-
* @var bool
|
31 |
-
*/
|
32 |
-
public $success = false;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Import class constructor.
|
36 |
-
*
|
37 |
-
* @param boolean $replace Boolean replace switch.
|
38 |
-
*/
|
39 |
-
public function __construct( $replace = false ) {
|
40 |
-
$this->replace = $replace;
|
41 |
-
|
42 |
-
WPSEO_Options::initialize();
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Convenience function to set import message
|
47 |
-
*
|
48 |
-
* @param string $msg Message string.
|
49 |
-
*/
|
50 |
-
protected function set_msg( $msg ) {
|
51 |
-
if ( ! empty( $this->msg ) ) {
|
52 |
-
$this->msg .= PHP_EOL;
|
53 |
-
}
|
54 |
-
$this->msg .= $msg;
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Deletes an option depending on the class replace state
|
59 |
-
*
|
60 |
-
* @param string $option Option key.
|
61 |
-
*/
|
62 |
-
protected function perhaps_delete( $option ) {
|
63 |
-
if ( $this->replace ) {
|
64 |
-
delete_option( $option );
|
65 |
-
}
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Import HeadSpace SEO settings
|
70 |
-
*/
|
71 |
-
public function import_headspace() {
|
72 |
-
global $wpdb;
|
73 |
-
|
74 |
-
WPSEO_Meta::replace_meta( '_headspace_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace );
|
75 |
-
WPSEO_Meta::replace_meta( '_headspace_keywords', WPSEO_Meta::$meta_prefix . 'metakeywords', $this->replace );
|
76 |
-
WPSEO_Meta::replace_meta( '_headspace_page_title', WPSEO_Meta::$meta_prefix . 'title', $this->replace );
|
77 |
-
|
78 |
-
/**
|
79 |
-
* @todo [JRF => whomever] verify how headspace sets these metas ( 'noindex', 'nofollow', 'noarchive', 'noodp', 'noydir' )
|
80 |
-
* and if the values saved are concurrent with the ones we use (i.e. 0/1/2)
|
81 |
-
*/
|
82 |
-
WPSEO_Meta::replace_meta( '_headspace_noindex', WPSEO_Meta::$meta_prefix . 'meta-robots-noindex', $this->replace );
|
83 |
-
WPSEO_Meta::replace_meta( '_headspace_nofollow', WPSEO_Meta::$meta_prefix . 'meta-robots-nofollow', $this->replace );
|
84 |
-
|
85 |
-
/*
|
86 |
-
* @todo - [JRF => whomever] check if this can be done more efficiently by querying only the meta table
|
87 |
-
* possibly directly changing it using concat on the existing values
|
88 |
-
*/
|
89 |
-
$posts = $wpdb->get_results( "SELECT ID FROM $wpdb->posts" );
|
90 |
-
if ( is_array( $posts ) && $posts !== array() ) {
|
91 |
-
foreach ( $posts as $post ) {
|
92 |
-
$custom = get_post_custom( $post->ID );
|
93 |
-
$robotsmeta_adv = '';
|
94 |
-
if ( isset( $custom['_headspace_noarchive'] ) ) {
|
95 |
-
$robotsmeta_adv .= 'noarchive,';
|
96 |
-
}
|
97 |
-
$robotsmeta_adv = preg_replace( '`,$`', '', $robotsmeta_adv );
|
98 |
-
WPSEO_Meta::set_value( 'meta-robots-adv', $robotsmeta_adv, $post->ID );
|
99 |
-
}
|
100 |
-
}
|
101 |
-
|
102 |
-
if ( $this->replace ) {
|
103 |
-
// We no longer use noydir, but we remove the meta key as it's unneeded.
|
104 |
-
$hs_meta = array( 'noarchive', 'noodp', 'noydir' );
|
105 |
-
foreach ( $hs_meta as $meta ) {
|
106 |
-
delete_post_meta_by_key( '_headspace_' . $meta );
|
107 |
-
}
|
108 |
-
unset( $hs_meta, $meta );
|
109 |
-
}
|
110 |
-
$this->success = true;
|
111 |
-
$this->set_msg( __( 'HeadSpace2 data successfully imported', 'wordpress-seo' ) );
|
112 |
-
}
|
113 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-import-jetpack.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package WPSEO\Admin\Import\External
|
4 |
-
*/
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class WPSEO_Import_Jetpack_SEO
|
8 |
-
*
|
9 |
-
* Class with functionality to import Yoast SEO settings from Jetpack Advanced SEO
|
10 |
-
*/
|
11 |
-
class WPSEO_Import_Jetpack_SEO extends WPSEO_Import_External {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Import Jetpack Advanced SEO settings
|
15 |
-
*
|
16 |
-
* @param boolean $replace Boolean replace switch.
|
17 |
-
*/
|
18 |
-
public function __construct( $replace = false ) {
|
19 |
-
parent::__construct( $replace );
|
20 |
-
|
21 |
-
$this->success = true;
|
22 |
-
$this->import_metas();
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Import All In One SEO meta values
|
27 |
-
*/
|
28 |
-
private function import_metas() {
|
29 |
-
WPSEO_Meta::replace_meta( 'advanced_seo_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace );
|
30 |
-
}
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-import-ultimate-seo.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package WPSEO\Admin\Import\External
|
4 |
-
*/
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class with functionality to import Yoast SEO settings from Ultimate SEO.
|
8 |
-
*/
|
9 |
-
class WPSEO_Import_Ultimate_SEO extends WPSEO_Import_External {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Constructs the import SEO Ultimate settings.
|
13 |
-
*
|
14 |
-
* @param boolean $replace Boolean replace switch.
|
15 |
-
*/
|
16 |
-
public function __construct( $replace = false ) {
|
17 |
-
parent::__construct( $replace );
|
18 |
-
|
19 |
-
$this->import_metas();
|
20 |
-
$this->cleanup();
|
21 |
-
|
22 |
-
$this->success = true;
|
23 |
-
$this->set_msg( __( 'SEO Ultimate data successfully imported.', 'wordpress-seo' ) );
|
24 |
-
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Imports the Ultimate SEO meta values.
|
29 |
-
*
|
30 |
-
* @returns void
|
31 |
-
*/
|
32 |
-
private function import_metas() {
|
33 |
-
WPSEO_Meta::replace_meta( '_su_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace );
|
34 |
-
WPSEO_Meta::replace_meta( '_su_meta_robots_nofollow', WPSEO_Meta::$meta_prefix . 'meta-robots-nofollow', $this->replace );
|
35 |
-
WPSEO_Meta::replace_meta( '_su_meta_robots_noindex', WPSEO_Meta::$meta_prefix . 'meta-robots-nofollow', $this->replace );
|
36 |
-
WPSEO_Meta::replace_meta( '_su_og_title', WPSEO_Meta::$meta_prefix . 'opengraph-title', $this->replace );
|
37 |
-
WPSEO_Meta::replace_meta( '_su_og_description', WPSEO_Meta::$meta_prefix . 'opengraph-description', $this->replace );
|
38 |
-
WPSEO_Meta::replace_meta( '_su_og_image', WPSEO_Meta::$meta_prefix . 'opengraph-image', $this->replace );
|
39 |
-
WPSEO_Meta::replace_meta( '_su_title', WPSEO_Meta::$meta_prefix . 'title', $this->replace );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Removes all leftover SEO ultimate data from the database.
|
44 |
-
*
|
45 |
-
* @return void
|
46 |
-
*/
|
47 |
-
private function cleanup() {
|
48 |
-
if ( ! $this->replace ) {
|
49 |
-
return;
|
50 |
-
}
|
51 |
-
global $wpdb;
|
52 |
-
$wpdb->query( "DELETE FROM {$wpdb->prefix}postmeta WHERE meta_key LIKE '_su_%'" );
|
53 |
-
}
|
54 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-import-woothemes-seo.php
DELETED
@@ -1,149 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package WPSEO\Admin\Import\External
|
4 |
-
*/
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class WPSEO_Import_WooThemes_SEO
|
8 |
-
*
|
9 |
-
* Class with functionality to import Yoast SEO settings from WooThemes SEO
|
10 |
-
*/
|
11 |
-
class WPSEO_Import_WooThemes_SEO extends WPSEO_Import_External {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Class constructor
|
15 |
-
*
|
16 |
-
* @param boolean $replace Boolean replace switch.
|
17 |
-
*/
|
18 |
-
public function __construct( $replace = false ) {
|
19 |
-
parent::__construct( $replace );
|
20 |
-
|
21 |
-
$this->success = true;
|
22 |
-
$this->import_home();
|
23 |
-
$this->import_option( 'seo_woo_single_layout', 'post' );
|
24 |
-
$this->import_option( 'seo_woo_page_layout', 'page' );
|
25 |
-
$this->import_archive_option();
|
26 |
-
$this->import_custom_values( 'seo_woo_meta_home_desc', 'metadesc-home-wpseo' );
|
27 |
-
$this->import_custom_values( 'seo_woo_meta_home_key', 'metakey-home-wpseo' );
|
28 |
-
$this->import_metas();
|
29 |
-
|
30 |
-
update_option( 'wpseo_titles', $this->options );
|
31 |
-
|
32 |
-
$this->set_msg( __( 'WooThemes SEO framework settings & data successfully imported.', 'wordpress-seo' ) );
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Holds the WPSEO Title Options
|
37 |
-
*
|
38 |
-
* @var array
|
39 |
-
*/
|
40 |
-
private $options;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Import options.
|
44 |
-
*
|
45 |
-
* @param string $option Option key.
|
46 |
-
* @param string $post_type Post type name to import for.
|
47 |
-
*/
|
48 |
-
private function import_option( $option, $post_type ) {
|
49 |
-
switch ( get_option( $option ) ) {
|
50 |
-
case 'a':
|
51 |
-
$this->options[ 'title-' . $post_type ] = '%%title%% %%sep%% %%sitename%%';
|
52 |
-
break;
|
53 |
-
case 'b':
|
54 |
-
$this->options[ 'title-' . $post_type ] = '%%title%%';
|
55 |
-
break;
|
56 |
-
case 'c':
|
57 |
-
$this->options[ 'title-' . $post_type ] = '%%sitename%% %%sep%% %%title%%';
|
58 |
-
break;
|
59 |
-
case 'd':
|
60 |
-
$this->options[ 'title-' . $post_type ] = '%%title%% %%sep%% %%sitedesc%%';
|
61 |
-
break;
|
62 |
-
case 'e':
|
63 |
-
$this->options[ 'title-' . $post_type ] = '%%sitename%% %%sep%% %%title%% %%sep%% %%sitedesc%%';
|
64 |
-
break;
|
65 |
-
}
|
66 |
-
$this->perhaps_delete( $option );
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Import the archive layout for all taxonomies
|
71 |
-
*/
|
72 |
-
private function import_archive_option() {
|
73 |
-
$reinstate_replace = false;
|
74 |
-
if ( $this->replace ) {
|
75 |
-
$this->replace = false;
|
76 |
-
$reinstate_replace = true;
|
77 |
-
}
|
78 |
-
$taxonomies = get_taxonomies( array( 'public' => true ), 'names' );
|
79 |
-
if ( is_array( $taxonomies ) && $taxonomies !== array() ) {
|
80 |
-
foreach ( $taxonomies as $tax ) {
|
81 |
-
$this->import_option( 'seo_woo_archive_layout', 'tax-' . $tax );
|
82 |
-
}
|
83 |
-
}
|
84 |
-
if ( $reinstate_replace ) {
|
85 |
-
$this->replace = true;
|
86 |
-
$this->perhaps_delete( 'seo_woo_archive_layout' );
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Import custom descriptions and meta keys
|
92 |
-
*
|
93 |
-
* @param string $option Option key.
|
94 |
-
* @param string $key Internal key to import over.
|
95 |
-
*/
|
96 |
-
private function import_custom_values( $option, $key ) {
|
97 |
-
// Import the custom homepage description.
|
98 |
-
if ( 'c' === get_option( $option ) ) {
|
99 |
-
$this->options[ $key ] = get_option( $option . '_custom' );
|
100 |
-
}
|
101 |
-
$this->perhaps_delete( $option );
|
102 |
-
$this->perhaps_delete( $option . '_custom' );
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Imports the WooThemes SEO homepage settings
|
107 |
-
*/
|
108 |
-
private function import_home() {
|
109 |
-
switch ( get_option( 'seo_woo_home_layout' ) ) {
|
110 |
-
case 'a':
|
111 |
-
$this->options['title-home-wpseo'] = '%%sitename%% %%sep%% %%sitedesc%%';
|
112 |
-
break;
|
113 |
-
case 'b':
|
114 |
-
$this->options['title-home-wpseo'] = '%%sitename%% ' . get_option( 'seo_woo_paged_var' ) . ' %%pagenum%%';
|
115 |
-
break;
|
116 |
-
case 'c':
|
117 |
-
$this->options['title-home-wpseo'] = '%%sitedesc%%';
|
118 |
-
break;
|
119 |
-
}
|
120 |
-
$this->perhaps_delete( 'seo_woo_home_layout' );
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Import meta values if they're applicable
|
125 |
-
*/
|
126 |
-
private function import_metas() {
|
127 |
-
WPSEO_Meta::replace_meta( 'seo_follow', WPSEO_Meta::$meta_prefix . 'meta-robots-nofollow', $this->replace );
|
128 |
-
WPSEO_Meta::replace_meta( 'seo_noindex', WPSEO_Meta::$meta_prefix . 'meta-robots-noindex', $this->replace );
|
129 |
-
|
130 |
-
// If WooSEO is set to use the Woo titles, import those.
|
131 |
-
if ( 'true' == get_option( 'seo_woo_wp_title' ) ) {
|
132 |
-
WPSEO_Meta::replace_meta( 'seo_title', WPSEO_Meta::$meta_prefix . 'title', $this->replace );
|
133 |
-
}
|
134 |
-
|
135 |
-
// If WooSEO is set to use the Woo meta descriptions, import those.
|
136 |
-
if ( 'b' === get_option( 'seo_woo_meta_single_desc' ) ) {
|
137 |
-
WPSEO_Meta::replace_meta( 'seo_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace );
|
138 |
-
}
|
139 |
-
|
140 |
-
// If WooSEO is set to use the Woo meta keywords, import those.
|
141 |
-
if ( 'b' === get_option( 'seo_woo_meta_single_key' ) ) {
|
142 |
-
WPSEO_Meta::replace_meta( 'seo_keywords', WPSEO_Meta::$meta_prefix . 'metakeywords', $this->replace );
|
143 |
-
}
|
144 |
-
|
145 |
-
foreach ( array( 'seo_woo_wp_title', 'seo_woo_meta_single_desc', 'seo_woo_meta_single_key' ) as $option ) {
|
146 |
-
$this->perhaps_delete( $option );
|
147 |
-
}
|
148 |
-
}
|
149 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-import-wpseo.php
DELETED
@@ -1,208 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package WPSEO\Admin\Import\External
|
4 |
-
*/
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class WPSEO_Import_WPSEO
|
8 |
-
*
|
9 |
-
* Class with functionality to import Yoast SEO settings from wpSEO
|
10 |
-
*/
|
11 |
-
class WPSEO_Import_WPSEO extends WPSEO_Import_External {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Import wpSEO settings
|
15 |
-
*
|
16 |
-
* @param boolean $replace Boolean replace switch.
|
17 |
-
*/
|
18 |
-
public function __construct( $replace = false ) {
|
19 |
-
parent::__construct( $replace );
|
20 |
-
|
21 |
-
$this->import_post_metas();
|
22 |
-
$this->import_taxonomy_metas();
|
23 |
-
|
24 |
-
$this->success = true;
|
25 |
-
$this->set_msg(
|
26 |
-
sprintf(
|
27 |
-
/* translators: 1: link open tag; 2: link close tag. */
|
28 |
-
__( 'wpSEO data successfully imported. Would you like to %1$sdisable the wpSEO plugin%2$s?', 'wordpress-seo' ),
|
29 |
-
'<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_tools&tool=import-export&deactivate_wpseo=1#top#import-seo' ) ) . '">',
|
30 |
-
'</a>'
|
31 |
-
)
|
32 |
-
);
|
33 |
-
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Import the post meta values to Yoast SEO by replacing the wpSEO fields by Yoast SEO fields
|
38 |
-
*/
|
39 |
-
private function import_post_metas() {
|
40 |
-
WPSEO_Meta::replace_meta( '_wpseo_edit_title', WPSEO_Meta::$meta_prefix . 'title', $this->replace );
|
41 |
-
WPSEO_Meta::replace_meta( '_wpseo_edit_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace );
|
42 |
-
WPSEO_Meta::replace_meta( '_wpseo_edit_keywords', WPSEO_Meta::$meta_prefix . 'keywords', $this->replace );
|
43 |
-
WPSEO_Meta::replace_meta( '_wpseo_edit_canonical', WPSEO_Meta::$meta_prefix . 'canonical', $this->replace );
|
44 |
-
|
45 |
-
$this->import_post_robots();
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Importing the robot values from WPSEO plugin. These have to be converted to the Yoast format.
|
50 |
-
*/
|
51 |
-
private function import_post_robots() {
|
52 |
-
$query_posts = new WP_Query( 'post_type=any&meta_key=_wpseo_edit_robots&order=ASC&fields=ids&nopaging=true' );
|
53 |
-
|
54 |
-
if ( ! empty( $query_posts->posts ) ) {
|
55 |
-
foreach ( array_values( $query_posts->posts ) as $post_id ) {
|
56 |
-
$this->import_post_robot( $post_id );
|
57 |
-
}
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Getting the wpSEO robot value and map this to Yoast SEO values.
|
63 |
-
*
|
64 |
-
* @param integer $post_id The post id of the current post.
|
65 |
-
*/
|
66 |
-
private function import_post_robot( $post_id ) {
|
67 |
-
$wpseo_robots = get_post_meta( $post_id, '_wpseo_edit_robots', true );
|
68 |
-
$robot_value = $this->get_robot_value( $wpseo_robots );
|
69 |
-
|
70 |
-
// Saving the new meta values for Yoast SEO.
|
71 |
-
WPSEO_Meta::set_value( $robot_value['index'], 'meta-robots-noindex', $post_id );
|
72 |
-
WPSEO_Meta::set_value( $robot_value['follow'], 'meta-robots-nofollow', $post_id );
|
73 |
-
|
74 |
-
$this->delete_post_robot( $post_id );
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Delete the wpSEO robot values, because they aren't needed anymore.
|
79 |
-
*
|
80 |
-
* @param integer $post_id The post id of the current post.
|
81 |
-
*/
|
82 |
-
private function delete_post_robot( $post_id ) {
|
83 |
-
if ( $this->replace ) {
|
84 |
-
delete_post_meta( $post_id, '_wpseo_edit_robots' );
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Import the taxonomy metas from wpSEO
|
90 |
-
*/
|
91 |
-
private function import_taxonomy_metas() {
|
92 |
-
$terms = get_terms( get_taxonomies(), array( 'hide_empty' => false ) );
|
93 |
-
$tax_meta = get_option( 'wpseo_taxonomy_meta' );
|
94 |
-
|
95 |
-
foreach ( $terms as $term ) {
|
96 |
-
$this->import_taxonomy_description( $tax_meta, $term->taxonomy, $term->term_id );
|
97 |
-
$this->import_taxonomy_robots( $tax_meta, $term->taxonomy, $term->term_id );
|
98 |
-
$this->delete_taxonomy_metas( $term->taxonomy, $term->term_id );
|
99 |
-
}
|
100 |
-
|
101 |
-
update_option( 'wpseo_taxonomy_meta', $tax_meta );
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Import the meta description to Yoast SEO
|
106 |
-
*
|
107 |
-
* @param array $tax_meta The array with the current metadata.
|
108 |
-
* @param string $taxonomy String with the name of the taxonomy.
|
109 |
-
* @param string $term_id The ID of the current term.
|
110 |
-
*/
|
111 |
-
private function import_taxonomy_description( & $tax_meta, $taxonomy, $term_id ) {
|
112 |
-
$description = get_option( 'wpseo_' . $taxonomy . '_' . $term_id, false );
|
113 |
-
if ( $description !== false ) {
|
114 |
-
// Import description.
|
115 |
-
$tax_meta[ $taxonomy ][ $term_id ]['wpseo_desc'] = $description;
|
116 |
-
}
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Import the robot value to Yoast SEO
|
121 |
-
*
|
122 |
-
* @param array $tax_meta The array with the current metadata.
|
123 |
-
* @param string $taxonomy String with the name of the taxonomy.
|
124 |
-
* @param string $term_id The ID of the current term.
|
125 |
-
*/
|
126 |
-
private function import_taxonomy_robots( & $tax_meta, $taxonomy, $term_id ) {
|
127 |
-
$wpseo_robots = get_option( 'wpseo_' . $taxonomy . '_' . $term_id . '_robots', false );
|
128 |
-
if ( $wpseo_robots !== false ) {
|
129 |
-
// The value 1, 2 and 6 are the index values in wpSEO.
|
130 |
-
$new_robot_value = ( in_array( (int) $wpseo_robots, array( 1, 2, 6 ), true ) ) ? 'index' : 'noindex';
|
131 |
-
|
132 |
-
$tax_meta[ $taxonomy ][ $term_id ]['wpseo_noindex'] = $new_robot_value;
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Delete the wpSEO taxonomy meta data.
|
138 |
-
*
|
139 |
-
* @param string $taxonomy String with the name of the taxonomy.
|
140 |
-
* @param string $term_id The ID of the current term.
|
141 |
-
*/
|
142 |
-
private function delete_taxonomy_metas( $taxonomy, $term_id ) {
|
143 |
-
if ( $this->replace ) {
|
144 |
-
delete_option( 'wpseo_' . $taxonomy . '_' . $term_id );
|
145 |
-
delete_option( 'wpseo_' . $taxonomy . '_' . $term_id . '_robots' );
|
146 |
-
}
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Getting the robot config by given wpSEO robots value.
|
151 |
-
*
|
152 |
-
* @param string $wpseo_robots The value in wpSEO that needs to be converted to the Yoast format.
|
153 |
-
*
|
154 |
-
* @return array
|
155 |
-
*/
|
156 |
-
private function get_robot_value( $wpseo_robots ) {
|
157 |
-
static $robot_values;
|
158 |
-
|
159 |
-
if ( $robot_values === null ) {
|
160 |
-
/**
|
161 |
-
* The values 1 - 6 are the configured values from wpSEO. This array will map the values of wpSEO to our values.
|
162 |
-
*
|
163 |
-
* There are some double array like 1-6 and 3-4. The reason is they only set the index value. The follow value is
|
164 |
-
* the default we use in the cases there isn't a follow value present.
|
165 |
-
*
|
166 |
-
* @var array
|
167 |
-
*/
|
168 |
-
$robot_values = array(
|
169 |
-
// In wpSEO: index, follow.
|
170 |
-
1 => array(
|
171 |
-
'index' => 2,
|
172 |
-
'follow' => 0,
|
173 |
-
),
|
174 |
-
// In wpSEO: index, nofollow.
|
175 |
-
2 => array(
|
176 |
-
'index' => 2,
|
177 |
-
'follow' => 1,
|
178 |
-
),
|
179 |
-
// In wpSEO: noindex.
|
180 |
-
3 => array(
|
181 |
-
'index' => 1,
|
182 |
-
'follow' => 0,
|
183 |
-
),
|
184 |
-
// In wpSEO: noindex, follow.
|
185 |
-
4 => array(
|
186 |
-
'index' => 1,
|
187 |
-
'follow' => 0,
|
188 |
-
),
|
189 |
-
// In wpSEO: noindex, nofollow.
|
190 |
-
5 => array(
|
191 |
-
'index' => 1,
|
192 |
-
'follow' => 1,
|
193 |
-
),
|
194 |
-
// In wpSEO: index.
|
195 |
-
6 => array(
|
196 |
-
'index' => 2,
|
197 |
-
'follow' => 0,
|
198 |
-
),
|
199 |
-
);
|
200 |
-
}
|
201 |
-
|
202 |
-
if ( array_key_exists( $wpseo_robots, $robot_values ) ) {
|
203 |
-
return $robot_values[ $wpseo_robots ];
|
204 |
-
}
|
205 |
-
|
206 |
-
return $robot_values[1];
|
207 |
-
}
|
208 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-social-facebook-form.php
DELETED
@@ -1,273 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package WPSEO
|
4 |
-
* @subpackage Admin
|
5 |
-
*/
|
6 |
-
|
7 |
-
/**
|
8 |
-
* This will display the HTML for the facebook insights part
|
9 |
-
*/
|
10 |
-
class Yoast_Social_Facebook_Form {
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @var array - The FB admins
|
14 |
-
*/
|
15 |
-
private $fb_admins;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @var array - The repository for the buttons that will be shown
|
19 |
-
*/
|
20 |
-
private $buttons = array();
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @var string - The URL to link to
|
24 |
-
*/
|
25 |
-
private $admin_url = 'admin.php?page=wpseo_social';
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Setting the FB admins option and call the methods to display everything
|
29 |
-
*/
|
30 |
-
public function __construct() {
|
31 |
-
$this->fb_admins = WPSEO_Options::get( 'fb_admins', array() );
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Returns the output-property
|
36 |
-
*/
|
37 |
-
public function show_form() {
|
38 |
-
$this
|
39 |
-
->form_head()
|
40 |
-
->manage_user_admin()
|
41 |
-
->form_thickbox()
|
42 |
-
->show_buttons()
|
43 |
-
->manage_app_as_admin();
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Parses the admin_link
|
48 |
-
*
|
49 |
-
* @param string $admin_id Facebook admin ID string.
|
50 |
-
* @param array $admin Admin data array.
|
51 |
-
* @param string|bool $nonce Optional nonce string.
|
52 |
-
*
|
53 |
-
* @return string
|
54 |
-
*/
|
55 |
-
public function get_admin_link( $admin_id, $admin, $nonce = false ) {
|
56 |
-
if ( $nonce === false ) {
|
57 |
-
$nonce = $this->get_delete_nonce();
|
58 |
-
}
|
59 |
-
|
60 |
-
$return = '<li><a target="_blank" href="' . esc_url( $admin['link'] ) . '">' . esc_html( $admin['name'] ) . '</a>';
|
61 |
-
$return .= ' - <strong><a href="' . esc_url( $this->admin_delete_link( $admin_id, $nonce ) ) . '">X</a></strong></li>';
|
62 |
-
|
63 |
-
return $return;
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* SHow the top of the social insights part of the page
|
68 |
-
*
|
69 |
-
* @return $this
|
70 |
-
*/
|
71 |
-
private function form_head() {
|
72 |
-
echo '<h2>' . esc_html__( 'Facebook Insights and Admins', 'wordpress-seo' ) . '</h2>';
|
73 |
-
echo '<p>', sprintf(
|
74 |
-
/* translators: %1$s and %2$s expand to a link to Facebook Insights */
|
75 |
-
esc_html__( 'To be able to access %1$sFacebook Insights%2$s for your site, you need to specify a Facebook Admin. This can be a user. If you have an app for your site, you could use that as well.', 'wordpress-seo' ),
|
76 |
-
'<a target="_blank" href="https://www.facebook.com/insights">',
|
77 |
-
'</a>'
|
78 |
-
);
|
79 |
-
echo ' ';
|
80 |
-
printf(
|
81 |
-
/* translators: %1$s and %2$s expand to a link to the Yoast Knowledge Base */
|
82 |
-
esc_html__( 'More info can be found %1$son our knowledge base%2$s.', 'wordpress-seo' ),
|
83 |
-
'<a target="_blank" href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/facebook-insights' ) ) . '">',
|
84 |
-
'</a>'
|
85 |
-
);
|
86 |
-
echo '</p>';
|
87 |
-
|
88 |
-
return $this;
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Show the form inside the thickbox
|
93 |
-
*/
|
94 |
-
private function form_thickbox() {
|
95 |
-
// Adding the thickbox.
|
96 |
-
add_thickbox();
|
97 |
-
|
98 |
-
echo '<div id="add_facebook_admin" class="hidden">';
|
99 |
-
echo "<div class='form-wrap wpseo_content_wrapper wpseo-add-fb-admin-form-wrap'>";
|
100 |
-
echo '<p>';
|
101 |
-
printf(
|
102 |
-
/* translators: %1$s and %2$s expand to a link to Facebook Insights */
|
103 |
-
esc_html__( 'To be able to access %1$sFacebook Insights%2$s, you need to add a user here. The name is used for reference only, the ID is used for verification.', 'wordpress-seo' ),
|
104 |
-
'<a target="_blank" href="https://www.facebook.com/insights">',
|
105 |
-
'</a>'
|
106 |
-
);
|
107 |
-
echo '</p>';
|
108 |
-
echo '<p>';
|
109 |
-
printf(
|
110 |
-
/* translators: %1$s and %2$s expand to a link to the Yoast Knowledge Base */
|
111 |
-
esc_html__( 'If you don\'t know where to find the needed ID, see %1$sthis knowledge base article%2$s.', 'wordpress-seo' ),
|
112 |
-
'<a target="_blank" href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/facebook-insights' ) ) . '">',
|
113 |
-
'</a>'
|
114 |
-
);
|
115 |
-
echo '</p>';
|
116 |
-
echo '<div class="form-field form-required">';
|
117 |
-
echo '<label for="fb_admin_name">' . esc_html__( 'Admin\'s name:', 'wordpress-seo' ) . '</label>';
|
118 |
-
echo '<input type="text" id="fb_admin_name" name="fb_admin_name" value="" maxlength="255" />';
|
119 |
-
echo '</div>';
|
120 |
-
echo '<div class="form-field form-required">';
|
121 |
-
echo '<label for="fb_admin_id">' . esc_html__( 'Admin\'s Facebook user ID:', 'wordpress-seo' ) . '</label>';
|
122 |
-
echo '<input type="text" id="fb_admin_id" name="fb_admin_id" value="" maxlength="255" />';
|
123 |
-
echo '</div>';
|
124 |
-
echo "<p class='submit'>";
|
125 |
-
echo '<input type="hidden" name="fb_admin_nonce" value="' . esc_attr( wp_create_nonce( 'wpseo_fb_admin_nonce' ) ) . '" />';
|
126 |
-
echo '<input type="submit" value="' . esc_attr__( 'Add Facebook admin', 'wordpress-seo' ) . '" class="button button-primary" onclick="javascript:wpseo_add_fb_admin();" />';
|
127 |
-
echo '</p>';
|
128 |
-
echo '</div>';
|
129 |
-
echo '</div>';
|
130 |
-
|
131 |
-
return $this;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Display the buttons to add an admin or add another admin from Facebook and display the admin that has been added already.
|
136 |
-
*
|
137 |
-
* @return $this
|
138 |
-
*/
|
139 |
-
private function manage_user_admin() {
|
140 |
-
$button_text = __( 'Add Facebook admin', 'wordpress-seo' );
|
141 |
-
$nonce = false;
|
142 |
-
$class_attr = ' class="hidden"';
|
143 |
-
|
144 |
-
if ( $this->has_fb_admins() ) {
|
145 |
-
$nonce = $this->get_delete_nonce();
|
146 |
-
$button_text = __( 'Add Another Facebook Admin', 'wordpress-seo' );
|
147 |
-
$class_attr = '';
|
148 |
-
}
|
149 |
-
|
150 |
-
echo "<div id='connected_fb_admins'{$class_attr}>";
|
151 |
-
echo '<p>' . esc_html__( 'Currently connected Facebook admins:', 'wordpress-seo' ) . '</p>';
|
152 |
-
echo '<ul id="user_admin">';
|
153 |
-
$this->show_user_admins( $nonce );
|
154 |
-
echo '</ul>';
|
155 |
-
echo '</div>';
|
156 |
-
|
157 |
-
unset( $nonce );
|
158 |
-
|
159 |
-
$this->add_button(
|
160 |
-
array(
|
161 |
-
'url' => '#TB_inline?width=600&height=350&inlineId=add_facebook_admin',
|
162 |
-
'value' => $button_text,
|
163 |
-
'class' => 'thickbox',
|
164 |
-
'title' => $button_text,
|
165 |
-
)
|
166 |
-
);
|
167 |
-
|
168 |
-
return $this;
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Show input field to set a facebook apps as an admin
|
173 |
-
*
|
174 |
-
* @return $this
|
175 |
-
*/
|
176 |
-
private function manage_app_as_admin() {
|
177 |
-
echo '<div class="clear"></div><br />';
|
178 |
-
Yoast_Form::get_instance()->textinput( 'fbadminapp', __( 'Facebook App ID', 'wordpress-seo' ) );
|
179 |
-
|
180 |
-
return $this;
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* Loop through the fb-admins to parse the output for them
|
185 |
-
*
|
186 |
-
* @param string $nonce Nonce string.
|
187 |
-
*/
|
188 |
-
private function show_user_admins( $nonce ) {
|
189 |
-
foreach ( $this->fb_admins as $admin_id => $admin ) {
|
190 |
-
echo $this->get_admin_link( $admin_id, $admin, $nonce );
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
/**
|
195 |
-
* Parsing the link that directs to the admin removal
|
196 |
-
*
|
197 |
-
* @param string $admin_id Facebook admin ID.
|
198 |
-
* @param string $nonce Nonce string.
|
199 |
-
*
|
200 |
-
* @return string
|
201 |
-
*/
|
202 |
-
private function admin_delete_link( $admin_id, $nonce ) {
|
203 |
-
return add_query_arg(
|
204 |
-
array(
|
205 |
-
'delfbadmin' => esc_attr( $admin_id ),
|
206 |
-
'nonce' => $nonce,
|
207 |
-
),
|
208 |
-
admin_url( $this->admin_url . '#top#facebook' )
|
209 |
-
);
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Adding a button to the button property
|
214 |
-
*
|
215 |
-
* @param array $args Arguments data array.
|
216 |
-
*/
|
217 |
-
private function add_button( $args ) {
|
218 |
-
$args = wp_parse_args(
|
219 |
-
$args,
|
220 |
-
array(
|
221 |
-
'url' => '',
|
222 |
-
'value' => '',
|
223 |
-
'class' => '',
|
224 |
-
'id' => '',
|
225 |
-
'title' => '',
|
226 |
-
|
227 |
-
)
|
228 |
-
);
|
229 |
-
|
230 |
-
$this->buttons[] = '<a title="' . esc_attr( $args['title'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="button ' . esc_attr( $args['class'] ) . '" href="' . esc_url( $args['url'] ) . '">' . esc_html( $args['value'] ) . '</a>';
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Showing the buttons
|
235 |
-
*/
|
236 |
-
private function show_buttons() {
|
237 |
-
if ( $this->has_fb_admins() ) {
|
238 |
-
$this->add_button(
|
239 |
-
array(
|
240 |
-
'url' => add_query_arg( array(
|
241 |
-
'nonce' => wp_create_nonce( 'fbclearall' ),
|
242 |
-
'fbclearall' => 'true',
|
243 |
-
), admin_url( $this->admin_url . '#top#facebook' ) ),
|
244 |
-
'value' => __( 'Clear all Facebook Data', 'wordpress-seo' ),
|
245 |
-
)
|
246 |
-
);
|
247 |
-
}
|
248 |
-
|
249 |
-
if ( is_array( $this->buttons ) && $this->buttons !== array() ) {
|
250 |
-
echo '<p class="fb-buttons">' . implode( '', $this->buttons ) . '</p>';
|
251 |
-
}
|
252 |
-
|
253 |
-
return $this;
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Check if the clear button should be displayed. This is based on the set options.
|
258 |
-
*
|
259 |
-
* @return bool When fb admins is a valid array.
|
260 |
-
*/
|
261 |
-
private function has_fb_admins() {
|
262 |
-
return is_array( $this->fb_admins ) && $this->fb_admins !== array();
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Creates nonce for removal link
|
267 |
-
*
|
268 |
-
* @return mixed
|
269 |
-
*/
|
270 |
-
private function get_delete_nonce() {
|
271 |
-
return wp_create_nonce( 'delfbadmin' );
|
272 |
-
}
|
273 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-social-facebook.php
DELETED
@@ -1,211 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package WPSEO
|
4 |
-
* @subpackage Admin
|
5 |
-
*/
|
6 |
-
|
7 |
-
/**
|
8 |
-
* The Facebook insights class, this will add some listeners to fetch GET params
|
9 |
-
*/
|
10 |
-
class Yoast_Social_Facebook {
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @var Yoast_Social_Facebook_Form
|
14 |
-
*/
|
15 |
-
private $form;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Setting the options and define the listener to fetch $_GET values
|
19 |
-
*/
|
20 |
-
public function __construct() {
|
21 |
-
$this->get_listener();
|
22 |
-
|
23 |
-
$this->form = new Yoast_Social_Facebook_Form();
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Returns the output from the form class
|
28 |
-
*/
|
29 |
-
public function show_form() {
|
30 |
-
$this->form->show_form();
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Adding a new admin
|
35 |
-
*
|
36 |
-
* @param string $admin_name Name string.
|
37 |
-
* @param string $admin_id ID string.
|
38 |
-
*
|
39 |
-
* @return string
|
40 |
-
*/
|
41 |
-
public function add_admin( $admin_name, $admin_id ) {
|
42 |
-
$success = 0;
|
43 |
-
|
44 |
-
// If one of the fields is empty.
|
45 |
-
if ( empty( $admin_name ) || empty( $admin_id ) ) {
|
46 |
-
$response_body = $this->get_response_body( 'not_present' );
|
47 |
-
}
|
48 |
-
else {
|
49 |
-
$admin_id = $this->parse_admin_id( $admin_id );
|
50 |
-
$option = WPSEO_Options::get( 'fb_admins' );
|
51 |
-
|
52 |
-
if ( ! isset( $option[ $admin_id ] ) ) {
|
53 |
-
$name = sanitize_text_field( urldecode( $admin_name ) );
|
54 |
-
$admin_id = sanitize_text_field( $admin_id );
|
55 |
-
|
56 |
-
if ( preg_match( '/[0-9]+?/', $admin_id ) && preg_match( '/[\w\s]+?/', $name ) ) {
|
57 |
-
$option[ $admin_id ]['name'] = $name;
|
58 |
-
$option[ $admin_id ]['link'] = urldecode( 'http://www.facebook.com/' . $admin_id );
|
59 |
-
WPSEO_Options::set( 'fb_admins', $option );
|
60 |
-
|
61 |
-
$success = 1;
|
62 |
-
$response_body = $this->form->get_admin_link( $admin_id, $option[ $admin_id ] );
|
63 |
-
}
|
64 |
-
else {
|
65 |
-
$response_body = $this->get_response_body( 'invalid_format' );
|
66 |
-
}
|
67 |
-
}
|
68 |
-
else {
|
69 |
-
$response_body = $this->get_response_body( 'already_exists' );
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
return wp_json_encode(
|
74 |
-
array(
|
75 |
-
'success' => $success,
|
76 |
-
'html' => $response_body,
|
77 |
-
)
|
78 |
-
);
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Fetches the id if the full meta tag or a full url was given
|
83 |
-
*
|
84 |
-
* @param string $admin_id Admin ID input string to process.
|
85 |
-
*
|
86 |
-
* @return string
|
87 |
-
*/
|
88 |
-
private function parse_admin_id( $admin_id ) {
|
89 |
-
if ( preg_match( '/^\<meta property\=\"fb:admins\" content\=\"(\d+?)\"/', $admin_id, $matches_full_meta ) ) {
|
90 |
-
return $matches_full_meta[1];
|
91 |
-
}
|
92 |
-
|
93 |
-
return trim( wp_parse_url( $admin_id, PHP_URL_PATH ), '/' );
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Returns a different response body depending on the response type
|
98 |
-
*
|
99 |
-
* @param string $type Type string.
|
100 |
-
*
|
101 |
-
* @return string
|
102 |
-
*/
|
103 |
-
private function get_response_body( $type ) {
|
104 |
-
switch ( $type ) {
|
105 |
-
case 'not_present':
|
106 |
-
$return = "<p class='notice-error notice'><span>" . __( 'Please make sure both fields are filled.', 'wordpress-seo' ) . '</span></p>';
|
107 |
-
break;
|
108 |
-
case 'invalid_format':
|
109 |
-
$return = "<p class='notice-error notice'><span>" . __( 'Your input contains invalid characters. Please make sure both fields are filled in correctly.', 'wordpress-seo' ) . '</span></p>';
|
110 |
-
break;
|
111 |
-
case 'already_exists':
|
112 |
-
$return = "<p class='notice-error notice'><span>" . __( 'This Facebook user has already been added as an admin.', 'wordpress-seo' ) . '</span></p>';
|
113 |
-
break;
|
114 |
-
default:
|
115 |
-
$return = '';
|
116 |
-
break;
|
117 |
-
}
|
118 |
-
|
119 |
-
return $return;
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* This method will hook into the defined get params
|
124 |
-
*/
|
125 |
-
private function get_listener() {
|
126 |
-
$delfbadmin = filter_input( INPUT_GET, 'delfbadmin' );
|
127 |
-
if ( ! empty( $delfbadmin ) ) {
|
128 |
-
$this->delete_admin( $delfbadmin );
|
129 |
-
}
|
130 |
-
elseif ( filter_input( INPUT_GET, 'fbclearall' ) ) {
|
131 |
-
$this->clear_all();
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Deletes the admin from the options
|
137 |
-
*
|
138 |
-
* @param string $delfbadmin Facebook admin ID.
|
139 |
-
*/
|
140 |
-
private function delete_admin( $delfbadmin ) {
|
141 |
-
$this->verify_nonce( 'delfbadmin' );
|
142 |
-
|
143 |
-
$admin_id = sanitize_text_field( $delfbadmin );
|
144 |
-
$option = WPSEO_Options::get( 'fb_admins' );
|
145 |
-
|
146 |
-
if ( isset( $option[ $admin_id ] ) ) {
|
147 |
-
$fbadmin = $option[ $admin_id ]['name'];
|
148 |
-
unset( $option[ $admin_id ][ $admin_id ] );
|
149 |
-
WPSEO_Options::set( 'fb_admins', $option );
|
150 |
-
|
151 |
-
/* translators: %s expands to the username of the removed Facebook admin. */
|
152 |
-
$this->success_notice( sprintf( __( 'Successfully removed admin %s', 'wordpress-seo' ), $fbadmin ) );
|
153 |
-
|
154 |
-
unset( $fbadmin );
|
155 |
-
}
|
156 |
-
|
157 |
-
unset( $admin_id );
|
158 |
-
|
159 |
-
// Clean up the referrer url for later use.
|
160 |
-
if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
|
161 |
-
$this->cleanup_referrer_url( 'nonce', 'delfbadmin' );
|
162 |
-
}
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Clear all the facebook that has been set already
|
167 |
-
*/
|
168 |
-
private function clear_all() {
|
169 |
-
$this->verify_nonce( 'fbclearall' );
|
170 |
-
|
171 |
-
// Reset to defaults, don't unset as otherwise the old values will be retained.
|
172 |
-
WPSEO_Options::set( 'fb_admins', WPSEO_Options::get_default( 'wpseo_social', 'fb_admins' ) );
|
173 |
-
|
174 |
-
$this->success_notice( __( 'Successfully cleared all Facebook Data', 'wordpress-seo' ) );
|
175 |
-
|
176 |
-
// Clean up the referrer url for later use.
|
177 |
-
if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
|
178 |
-
$this->cleanup_referrer_url( 'nonce', 'fbclearall' );
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
/**
|
183 |
-
* Clean up the request_uri. The given params are the params that will be removed from the URL
|
184 |
-
*/
|
185 |
-
private function cleanup_referrer_url() {
|
186 |
-
$_SERVER['REQUEST_URI'] = remove_query_arg(
|
187 |
-
func_get_args(),
|
188 |
-
sanitize_text_field( $_SERVER['REQUEST_URI'] )
|
189 |
-
);
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* When something is going well, show a success notice
|
194 |
-
*
|
195 |
-
* @param string $notice_text Message string.
|
196 |
-
*/
|
197 |
-
private function success_notice( $notice_text ) {
|
198 |
-
add_settings_error( 'yoast_wpseo_social_options', 'success', $notice_text, 'updated' );
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Verify the nonce from the URL with the saved nonce
|
203 |
-
*
|
204 |
-
* @param string $nonce_name Nonce name string.
|
205 |
-
*/
|
206 |
-
private function verify_nonce( $nonce_name ) {
|
207 |
-
if ( wp_verify_nonce( filter_input( INPUT_GET, 'nonce' ), $nonce_name ) !== 1 ) {
|
208 |
-
die( "I don't think that's really nice of you!." );
|
209 |
-
}
|
210 |
-
}
|
211 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|