The SEO Framework - Version 2.8.2

Version Description

In the 2.8.0 update WordPress 4.3 and PHP 5.2 support have been dropped for better code quality.

Download this release

Release Info

Developer Cybr
Plugin Icon 128x128 The SEO Framework
Version 2.8.2
Comparing to
See all releases

Code changes from version 2.7.3 to 2.8.2

Files changed (69) hide show
  1. autodescription.php +66 -54
  2. inc/classes/admin-init.class.php +142 -83
  3. inc/classes/{adminpages.class.php → admin-pages.class.php} +178 -169
  4. inc/classes/{transients.class.php → cache.class.php} +422 -137
  5. inc/classes/compat.class.php +69 -70
  6. inc/classes/core.class.php +310 -133
  7. inc/classes/debug.class.php +417 -219
  8. inc/classes/deprecated.class.php +505 -0
  9. inc/classes/detect.class.php +112 -191
  10. inc/classes/{doingitright.class.php → doing-it-right.class.php} +169 -162
  11. inc/classes/feed.class.php +22 -34
  12. inc/classes/generate-description.class.php +264 -209
  13. inc/classes/generate-image.class.php +244 -105
  14. inc/classes/generate-ldjson.class.php +110 -79
  15. inc/classes/generate-title.class.php +207 -208
  16. inc/classes/generate-url.class.php +301 -623
  17. inc/classes/generate.class.php +122 -37
  18. inc/classes/init.class.php +389 -116
  19. inc/classes/inpost.class.php +72 -444
  20. inc/classes/load.class.php +263 -0
  21. inc/classes/metaboxes.class.php +157 -167
  22. inc/classes/{postdata.class.php → post-data.class.php} +184 -93
  23. inc/classes/query.class.php +93 -114
  24. inc/classes/render.class.php +133 -125
  25. inc/classes/sanitize.class.php +411 -251
  26. inc/classes/search.class.php +0 -183
  27. inc/classes/{siteoptions.class.php → site-options.class.php} +110 -71
  28. inc/classes/sitemaps.class.php +402 -291
  29. inc/classes/{termdata.class.php → term-data.class.php} +79 -108
  30. inc/{functions/compat.php → compat/php-mbstring.php} +4 -152
  31. inc/compat/plugin-bbpress.php +35 -0
  32. inc/compat/plugin-donncha-dm.php +65 -0
  33. inc/compat/plugin-qtranslatex.php +100 -0
  34. inc/compat/plugin-ultimatemember.php +47 -0
  35. inc/compat/plugin-wpml.php +203 -0
  36. inc/compat/plugin-wpmudev-dm.php +122 -0
  37. inc/compat/theme-genesis.php +71 -0
  38. inc/deprecated/deprecated.class.php +0 -905
  39. inc/{deprecated → functions}/deprecated.php +2 -2
  40. inc/functions/optionsapi.php +17 -4
  41. inc/functions/plugin-test-server.php +113 -0
  42. inc/functions/upgrade.php +12 -14
  43. inc/interfaces/debug.interface.php +106 -0
  44. inc/views/debug/output.php +42 -19
  45. inc/views/inpost/index.php +8 -0
  46. inc/views/inpost/seo-settings.php +423 -0
  47. inc/views/metaboxes/description-metabox.php +16 -16
  48. inc/views/metaboxes/general-metabox.php +192 -0
  49. inc/views/metaboxes/homepage-metabox.php +101 -72
  50. inc/views/metaboxes/knowledge-metabox.php +0 -230
  51. inc/views/metaboxes/schema-metabox.php +256 -57
  52. inc/views/metaboxes/sitemaps-metabox.php +114 -47
  53. inc/views/metaboxes/social-metabox.php +84 -80
  54. inc/views/metaboxes/title-metabox.php +21 -21
  55. inc/views/sitemap/index.php +6 -0
  56. inc/views/sitemap/xsl-stylesheet.php +249 -0
  57. language/autodescription.pot +750 -464
  58. lib/css/autodescription-rtl.min.css +0 -1
  59. lib/css/autodescription.min.css +0 -1
  60. lib/css/{autodescription-rtl.css → tsf-rtl.css} +66 -9
  61. lib/css/tsf-rtl.min.css +1 -0
  62. lib/css/{autodescription.css → tsf.css} +68 -11
  63. lib/css/tsf.min.css +1 -0
  64. lib/js/autodescription.js +0 -1408
  65. lib/js/autodescription.min.js +0 -25
  66. lib/js/tsf.externs.js +277 -0
  67. lib/js/tsf.externs.protected.js +412 -0
  68. lib/js/tsf.js +2011 -0
  69. lib/js/tsf.min.js +25 -0
autodescription.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
  * Plugin Name: The SEO Framework
4
- * Plugin URI: https://wordpress.org/plugins/autodescription/
5
  * Description: An automated, advanced, accessible, unbranded and extremely fast SEO solution for any WordPress website.
6
- * Version: 2.7.3
7
  * Author: Sybre Waaijer
8
  * Author URI: https://cyberwire.nl/
9
  * License: GPLv3
@@ -33,11 +33,11 @@ defined( 'ABSPATH' ) or die;
33
  //* Debug. Not to be used on production websites as it dumps and/or disables all kinds of stuff everywhere.
34
  //add_action( 'plugins_loaded', function() { if ( is_super_admin() ) {
35
  //if ( is_admin() ) {
36
- // define( 'THE_SEO_FRAMEWORK_DEBUG', true );
37
- // define( 'THE_SEO_FRAMEWORK_DEBUG_HIDDEN', true );
38
- // define( 'THE_SEO_FRAMEWORK_DISABLE_TRANSIENTS', true );
39
- // update_option( 'the_seo_framework_upgraded_db_version', '0' );
40
- // add_filter( 'the_seo_framework_use_object_cache', '__return_false' );
41
  //}
42
  //}},0);
43
 
@@ -46,13 +46,13 @@ defined( 'ABSPATH' ) or die;
46
  * Not many caching plugins use CDN in dashboard. What a shame. Firefox does cache.
47
  * @since 1.0.0
48
  */
49
- define( 'THE_SEO_FRAMEWORK_VERSION', '2.7.3' );
50
 
51
  /**
52
- * Plugin Database version for lightweight version comparing.
53
  * @since 2.7.0
54
  */
55
- define( 'THE_SEO_FRAMEWORK_DB_VERSION', '2701' );
56
 
57
  /**
58
  * Plugin options filter.
@@ -108,74 +108,86 @@ define( 'THE_SEO_FRAMEWORK_PLUGIN_BASE_FILE', __FILE__ );
108
  * The plugin views map absolute path.
109
  * @since 2.7.0
110
  */
111
- define( 'THE_SEO_FRAMEWORK_DIR_PATH_VIEWS', THE_SEO_FRAMEWORK_DIR_PATH . 'inc/views/' );
112
 
113
  /**
114
  * The plugin class map absolute path.
115
  * @since 2.2.9
116
  */
117
- define( 'THE_SEO_FRAMEWORK_DIR_PATH_CLASS', THE_SEO_FRAMEWORK_DIR_PATH . 'inc/classes/' );
118
 
119
  /**
120
- * The plugin function map absolute path.
121
- * @since 2.2.9
122
  */
123
- define( 'THE_SEO_FRAMEWORK_DIR_PATH_FUNCT', THE_SEO_FRAMEWORK_DIR_PATH . 'inc/functions/' );
124
 
125
- add_action( 'plugins_loaded', 'the_seo_framework_locale_init', 10 );
126
  /**
127
- * Plugin locale 'autodescription'
128
- * File located in plugin folder autodescription/language/
129
- * @since 1.0.0
130
  */
131
- function the_seo_framework_locale_init() {
132
- load_plugin_textdomain( 'autodescription', false, basename( dirname( __FILE__ ) ) . '/language/' );
133
- }
134
 
135
  /**
136
- * Load plugin files.
137
- * @since 1.0.0
138
- * @uses THE_SEO_FRAMEWORK_DIR_PATH
139
  */
140
- require_once( THE_SEO_FRAMEWORK_DIR_PATH . 'load.class.php' );
141
 
142
- //* Load deprecated functions.
143
- require_once( THE_SEO_FRAMEWORK_DIR_PATH . 'inc/deprecated/deprecated.php' );
144
-
145
- register_activation_hook( THE_SEO_FRAMEWORK_PLUGIN_BASE_FILE, 'the_seo_framework_flush_rewrite_rules_activation' );
146
  /**
147
- * Add and Flush rewrite rules on plugin activation.
148
  *
149
- * @since 2.6.6
150
- * @since 2.7.1: 1. Now no longer reinitializes global $wp_rewrite.
151
- * 2. Now always listens to the preconditions of the sitemap addition.
152
- * 3. Now flushes the rules on shutdown.
153
- * @access private
154
  */
155
- function the_seo_framework_flush_rewrite_rules_activation() {
156
-
157
- $the_seo_framework = the_seo_framework();
158
-
159
- if ( isset( $the_seo_framework ) ) {
160
- $the_seo_framework->rewrite_rule_sitemap();
161
- add_action( 'shutdown', 'flush_rewrite_rules' );
162
  }
163
  }
164
 
165
- register_deactivation_hook( THE_SEO_FRAMEWORK_PLUGIN_BASE_FILE, 'the_seo_framework_flush_rewrite_rules_deactivation' );
166
  /**
167
- * Flush rewrite rules on plugin deactivation.
168
  *
169
- * @since 2.6.6
170
- * @since 2.7.1: 1. Now no longer reinitializes global $wp_rewrite.
171
- * 2. Now flushes the rules on shutdown.
172
- * @access private
173
- * @global object $wp_rewrite
174
  */
175
- function the_seo_framework_flush_rewrite_rules_deactivation() {
176
- global $wp_rewrite;
177
 
178
- unset( $wp_rewrite->extra_rules_top['sitemap\.xml$'] );
 
179
 
180
- add_action( 'shutdown', 'flush_rewrite_rules' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  }
1
  <?php
2
  /**
3
  * Plugin Name: The SEO Framework
4
+ * Plugin URI: https://theseoframework.com/
5
  * Description: An automated, advanced, accessible, unbranded and extremely fast SEO solution for any WordPress website.
6
+ * Version: 2.8.2
7
  * Author: Sybre Waaijer
8
  * Author URI: https://cyberwire.nl/
9
  * License: GPLv3
33
  //* Debug. Not to be used on production websites as it dumps and/or disables all kinds of stuff everywhere.
34
  //add_action( 'plugins_loaded', function() { if ( is_super_admin() ) {
35
  //if ( is_admin() ) {
36
+ //define( 'THE_SEO_FRAMEWORK_DEBUG', true );
37
+ //define( 'THE_SEO_FRAMEWORK_DEBUG_HIDDEN', true );
38
+ //define( 'THE_SEO_FRAMEWORK_DISABLE_TRANSIENTS', true );
39
+ //update_option( 'the_seo_framework_upgraded_db_version', '0' );
40
+ //add_filter( 'the_seo_framework_use_object_cache', '__return_false' );
41
  //}
42
  //}},0);
43
 
46
  * Not many caching plugins use CDN in dashboard. What a shame. Firefox does cache.
47
  * @since 1.0.0
48
  */
49
+ define( 'THE_SEO_FRAMEWORK_VERSION', '2.8.2' );
50
 
51
  /**
52
+ * Plugin Database version for lightweight version upgrade comparing.
53
  * @since 2.7.0
54
  */
55
+ define( 'THE_SEO_FRAMEWORK_DB_VERSION', '2804' );
56
 
57
  /**
58
  * Plugin options filter.
108
  * The plugin views map absolute path.
109
  * @since 2.7.0
110
  */
111
+ define( 'THE_SEO_FRAMEWORK_DIR_PATH_VIEWS', THE_SEO_FRAMEWORK_DIR_PATH . 'inc' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR );
112
 
113
  /**
114
  * The plugin class map absolute path.
115
  * @since 2.2.9
116
  */
117
+ define( 'THE_SEO_FRAMEWORK_DIR_PATH_CLASS', THE_SEO_FRAMEWORK_DIR_PATH . 'inc' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR );
118
 
119
  /**
120
+ * The plugin interface map absolute path.
121
+ * @since 2.8.0
122
  */
123
+ define( 'THE_SEO_FRAMEWORK_DIR_PATH_INTERFACE', THE_SEO_FRAMEWORK_DIR_PATH . 'inc' . DIRECTORY_SEPARATOR . 'interfaces' . DIRECTORY_SEPARATOR );
124
 
 
125
  /**
126
+ * The plugin function map absolute path.
127
+ * @since 2.2.9
 
128
  */
129
+ define( 'THE_SEO_FRAMEWORK_DIR_PATH_FUNCT', THE_SEO_FRAMEWORK_DIR_PATH . 'inc' . DIRECTORY_SEPARATOR . 'functions' . DIRECTORY_SEPARATOR );
 
 
130
 
131
  /**
132
+ * The plugin function map absolute path.
133
+ * @since 2.8.0
 
134
  */
135
+ define( 'THE_SEO_FRAMEWORK_DIR_PATH_COMPAT', THE_SEO_FRAMEWORK_DIR_PATH . 'inc' . DIRECTORY_SEPARATOR . 'compat' . DIRECTORY_SEPARATOR );
136
 
137
+ the_seo_framework_pre_load();
 
 
 
138
  /**
139
+ * Determines whether we can "just" load the plugin, or require verification beforehand.
140
  *
141
+ * @since 2.8.0
 
 
 
 
142
  */
143
+ function the_seo_framework_pre_load() {
144
+ if ( get_site_option( 'the_seo_framework_tested_upgrade_version' ) >= THE_SEO_FRAMEWORK_DB_VERSION ) {
145
+ the_seo_framework_load_base_files();
146
+ } else {
147
+ the_seo_framework_test_server();
 
 
148
  }
149
  }
150
 
 
151
  /**
152
+ * Tests plugin upgrade.
153
  *
154
+ * @since 2.8.0
 
 
 
 
155
  */
156
+ function the_seo_framework_test_server() {
 
157
 
158
+ //* Load on init action (manual FTP upload) or after plugin has been upgraded.
159
+ require_once( THE_SEO_FRAMEWORK_DIR_PATH_FUNCT . 'plugin-test-server.php' );
160
 
161
+ if ( get_site_option( 'the_seo_framework_tested_upgrade_version' ) >= THE_SEO_FRAMEWORK_DB_VERSION )
162
+ the_seo_framework_load_base_files();
163
+ }
164
+
165
+ /**
166
+ * Loads plugin base files.
167
+ *
168
+ * @since 2.8.0
169
+ */
170
+ function the_seo_framework_load_base_files() {
171
+ /**
172
+ * Load plugin files.
173
+ *
174
+ * @since 1.0.0
175
+ * @uses THE_SEO_FRAMEWORK_DIR_PATH
176
+ */
177
+ require_once( THE_SEO_FRAMEWORK_DIR_PATH . 'load.php' );
178
+
179
+ /**
180
+ * Load deprecated functions.
181
+ *
182
+ * @since 2.7.0
183
+ * @uses THE_SEO_FRAMEWORK_DIR_PATH_FUNCT
184
+ */
185
+ require_once( THE_SEO_FRAMEWORK_DIR_PATH_FUNCT . 'deprecated.php' );
186
+
187
+ /**
188
+ * Load API files.
189
+ * @since 2.1.6
190
+ * @uses THE_SEO_FRAMEWORK_DIR_PATH_FUNCT
191
+ */
192
+ require_once( THE_SEO_FRAMEWORK_DIR_PATH_FUNCT . 'optionsapi.php' );
193
  }
inc/classes/admin-init.class.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  /**
3
  * The SEO Framework plugin
4
  * Copyright (C) 2015 - 2016 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
@@ -16,17 +23,15 @@
16
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
  */
18
 
19
- defined( 'ABSPATH' ) or die;
20
-
21
  /**
22
- * Class AutoDescription_Admin_Init
23
  *
24
  * Initializes the plugin for the wp-admin screens.
25
  * Enqueues CSS and Javascript.
26
  *
27
- * @since 2.1.6
28
  */
29
- class AutoDescription_Admin_Init extends AutoDescription_Init {
30
 
31
  /**
32
  * The page base file.
@@ -41,44 +46,27 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
41
  * JavaScript name identifier to be used with enqueuing.
42
  *
43
  * @since 2.5.2.2
 
44
  *
45
  * @var string JavaScript name identifier.
46
  */
47
- public $js_name = 'autodescription';
48
 
49
  /**
50
  * CSS script name identifier to be used with enqueuing.
51
  *
52
  * @since 2.6.0
 
53
  *
54
  * @var string CSS name identifier.
55
  */
56
- public $css_name = 'autodescription';
57
-
58
- /**
59
- * Unserializing instances of this class is forbidden.
60
- */
61
- private function __wakeup() { }
62
-
63
- /**
64
- * Handle unapproachable invoked methods.
65
- */
66
- public function __call( $name, $arguments ) {
67
- parent::__call( $name, $arguments );
68
- }
69
 
70
  /**
71
  * Constructor. Loads parent constructor, registers script names and adds actions.
72
  */
73
- public function __construct() {
74
  parent::__construct();
75
-
76
- //* Enqueues admin scripts.
77
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 0, 1 );
78
-
79
- //* Admin AJAX for counter options.
80
- add_action( 'wp_ajax_the_seo_framework_update_counter', array( $this, 'wp_ajax_update_counter_type' ) );
81
-
82
  }
83
 
84
  /**
@@ -98,6 +86,10 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
98
  'term.php',
99
  );
100
 
 
 
 
 
101
  /**
102
  * Check hook first.
103
  * @since 2.3.9
@@ -116,6 +108,8 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
116
  * Registers admin scripts and styles.
117
  *
118
  * @since 2.6.0
 
 
119
  */
120
  public function init_admin_scripts( $direct = false ) {
121
 
@@ -123,10 +117,9 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
123
  $this->enqueue_admin_css( $this->page_base_file );
124
  $this->enqueue_admin_javascript( $this->page_base_file );
125
  } else {
126
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_css' ), 1 );
127
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_javascript' ), 1 );
128
  }
129
-
130
  }
131
 
132
  /**
@@ -142,18 +135,24 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
142
  * Put hook and js name in class vars.
143
  * @since 2.5.2.2
144
  */
145
- $this->page_base_file = $this->page_base_file ? $this->page_base_file : $hook;
146
 
147
  //* Register the script.
148
- $this->register_admin_javascript();
 
 
 
149
 
150
- wp_enqueue_script( $this->js_name );
 
 
 
151
 
152
  /**
153
  * Localize JavaScript.
154
  * @since 2.5.2.2
155
  */
156
- add_action( 'admin_footer', array( $this, 'localize_admin_javascript' ) );
157
 
158
  }
159
 
@@ -164,7 +163,7 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
164
  * @staticvar bool $registered : Prevents Re-registering of the style.
165
  * @access private
166
  */
167
- public function register_admin_javascript() {
168
 
169
  static $registered = null;
170
 
@@ -173,7 +172,7 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
173
 
174
  $suffix = $this->script_debug ? '' : '.min';
175
 
176
- wp_register_script( $this->js_name, THE_SEO_FRAMEWORK_DIR_URL . "lib/js/autodescription{$suffix}.js", array( 'jquery' ), THE_SEO_FRAMEWORK_VERSION, true );
177
 
178
  $registered = true;
179
 
@@ -186,7 +185,7 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
186
  * @staticvar bool $localized : Prevents Re-registering of the l10n.
187
  * @access private
188
  */
189
- public function localize_admin_javascript() {
190
 
191
  static $localized = null;
192
 
@@ -195,7 +194,7 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
195
 
196
  $strings = $this->get_javascript_l10n();
197
 
198
- wp_localize_script( $this->js_name, 'autodescriptionL10n', $strings );
199
 
200
  $localized = true;
201
 
@@ -207,16 +206,15 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
207
  * @since 2.6.0
208
  * @staticvar array $strings : The l10n strings.
209
  * @since 2.7.0 Added AJAX nonce: 'autodescription-ajax-nonce'
 
 
 
 
210
  *
211
  * @return array $strings The l10n strings.
212
  */
213
  protected function get_javascript_l10n() {
214
 
215
- static $strings = null;
216
-
217
- if ( isset( $strings ) )
218
- return $strings;
219
-
220
  $blog_name = $this->get_blogname();
221
  $description = $this->get_blogdescription();
222
  $title = '';
@@ -237,7 +235,6 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
237
  $title_separator = $this->get_separator( 'title' );
238
  $description_separator = $this->get_separator( 'description' );
239
 
240
- $isrtl = (bool) is_rtl();
241
  $ishome = false;
242
 
243
  if ( isset( $this->page_base_file ) && $this->page_base_file ) {
@@ -273,16 +270,14 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
273
  }
274
  } elseif ( $this->is_archive() ) {
275
  //* Category or Tag.
276
- global $current_screen;
277
-
278
- if ( isset( $current_screen->taxonomy ) ) {
279
 
280
  $term_id = $this->get_admin_term_id();
281
 
282
  if ( $term_id ) {
283
  $generated_doctitle_args = array(
284
  'term_id' => $term_id,
285
- 'taxonomy' => $current_screen->taxonomy,
286
  'notagline' => true,
287
  'get_custom_field' => false,
288
  );
@@ -301,47 +296,85 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
301
  // We're on our SEO settings pages.
302
  if ( $this->has_page_on_front() ) {
303
  // Home is a page.
304
- $inpost_title = $this->get_custom_field( '_genesis_title', get_option( 'page_on_front' ) );
305
  } else {
306
  // Home is a blog.
307
  $inpost_title = '';
308
  }
309
- $title = $inpost_title ? $inpost_title : $blog_name;
310
- $additions = $home_tagline ? $home_tagline : $description;
311
  }
312
 
313
- $nonce = wp_create_nonce( 'autodescription-ajax-nonce' );
314
-
315
- return $strings = array(
316
- 'saveAlert' => esc_html__( 'The changes you made will be lost if you navigate away from this page.', 'autodescription' ),
317
- 'confirmReset' => esc_html__( 'Are you sure you want to reset all SEO settings to their defaults?', 'autodescription' ),
318
- 'siteTitle' => esc_html( $title ),
319
- 'titleAdditions' => esc_html( $additions ),
320
- 'blogDescription' => esc_html( $description ),
321
- 'titleTagline' => $tagline,
322
- 'titleSeparator' => esc_html( $title_separator ),
323
- 'titleLocation' => esc_html( $title_location ),
324
- 'descriptionSeparator' => esc_html( $description_separator ),
325
- 'isRTL' => $isrtl,
326
- 'isHome' => $ishome,
327
- 'counterType' => absint( $counter_type ),
328
- 'good' => esc_html( $good ),
329
- 'okay' => esc_html( $okay ),
330
- 'bad' => esc_html( $bad ),
331
- 'unknown' => esc_html( $unknown ),
332
  'nonce' => $nonce,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  );
334
  }
335
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
  /**
337
  * CSS for the AutoDescription Bar
338
  *
339
  * @since 2.1.9
340
  *
341
  * @param $hook the current page
342
- *
343
- * @todo get_network_option
344
- * @priority low 3.0.0
345
  */
346
  public function enqueue_admin_css( $hook ) {
347
 
@@ -349,12 +382,16 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
349
  * Put hook and js name in class vars.
350
  * @since 2.5.2.2
351
  */
352
- $this->page_base_file = $this->page_base_file ? $this->page_base_file : $hook;
353
 
354
  //* Register the script.
355
  $this->register_admin_css();
356
 
357
- wp_enqueue_style( $this->css_name );
 
 
 
 
358
 
359
  }
360
 
@@ -372,12 +409,31 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
372
  if ( isset( $registered ) )
373
  return;
374
 
375
- $rtl = is_rtl() ? '-rtl' : '';
376
  $suffix = $this->script_debug ? '' : '.min';
377
  $registered = true;
378
 
379
- wp_register_style( $this->css_name, THE_SEO_FRAMEWORK_DIR_URL . "lib/css/autodescription{$rtl}{$suffix}.css", array(), THE_SEO_FRAMEWORK_VERSION, 'all' );
 
 
 
 
 
 
 
 
 
 
 
 
380
 
 
 
 
 
 
 
 
381
  }
382
 
383
  /**
@@ -396,16 +452,16 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
396
  if ( empty( $page ) )
397
  return;
398
 
399
- $url = html_entity_decode( menu_page_url( $page, 0 ) );
400
 
401
  foreach ( $query_args as $key => $value ) {
402
  if ( empty( $key ) || empty( $value ) )
403
  unset( $query_args[ $key ] );
404
  }
405
 
406
- $url = add_query_arg( $query_args, $url );
407
 
408
- wp_safe_redirect( esc_url_raw( $url ), 302 );
409
  exit;
410
  }
411
 
@@ -420,17 +476,17 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
420
  if ( $this->is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) {
421
 
422
  //* If current user isn't allowed to edit posts, don't do anything and kill PHP.
423
- if ( ! current_user_can( 'publish_posts' ) )
424
  exit;
425
 
426
- check_ajax_referer( 'autodescription-ajax-nonce', 'nonce' );
427
 
428
  /**
429
  * Count up, reset to 0 if needed. We have 4 options: 0, 1, 2, 3
430
  * $_POST['val'] already contains updated number.
431
  */
432
  $value = isset( $_POST['val'] ) ? intval( $_POST['val'] ) : $this->get_user_option( 0, 'counter_type', 3 ) + 1;
433
- $value = absint( $value );
434
 
435
  if ( $value > 3 )
436
  $value = 0;
@@ -443,6 +499,9 @@ class AutoDescription_Admin_Init extends AutoDescription_Init {
443
  'value' => $value,
444
  );
445
 
 
 
 
446
  //* Encode and echo results. Requires JSON decode within JS.
447
  echo json_encode( $results );
448
 
1
  <?php
2
+ /**
3
+ * @package The_SEO_Framework\Classes
4
+ */
5
+ namespace The_SEO_Framework;
6
+
7
+ defined( 'ABSPATH' ) or die;
8
+
9
  /**
10
  * The SEO Framework plugin
11
  * Copyright (C) 2015 - 2016 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
23
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24
  */
25
 
 
 
26
  /**
27
+ * Class The_SEO_Framework\Admin_Init
28
  *
29
  * Initializes the plugin for the wp-admin screens.
30
  * Enqueues CSS and Javascript.
31
  *
32
+ * @since 2.8.0
33
  */
34
+ class Admin_Init extends Init {
35
 
36
  /**
37
  * The page base file.
46
  * JavaScript name identifier to be used with enqueuing.
47
  *
48
  * @since 2.5.2.2
49
+ * @since 2.8.0 Renamed
50
  *
51
  * @var string JavaScript name identifier.
52
  */
53
+ public $js_name = 'tsf';
54
 
55
  /**
56
  * CSS script name identifier to be used with enqueuing.
57
  *
58
  * @since 2.6.0
59
+ * @since 2.8.0 Renamed
60
  *
61
  * @var string CSS name identifier.
62
  */
63
+ public $css_name = 'tsf';
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
  /**
66
  * Constructor. Loads parent constructor, registers script names and adds actions.
67
  */
68
+ protected function __construct() {
69
  parent::__construct();
 
 
 
 
 
 
 
70
  }
71
 
72
  /**
86
  'term.php',
87
  );
88
 
89
+ if ( ! $this->is_option_checked( 'display_seo_bar_tables' ) ) {
90
+ $enqueue_hooks = array_diff( $enqueue_hooks, array( 'edit.php', 'edit-tags.php' ) );
91
+ }
92
+
93
  /**
94
  * Check hook first.
95
  * @since 2.3.9
108
  * Registers admin scripts and styles.
109
  *
110
  * @since 2.6.0
111
+ *
112
+ * @param bool $direct Whether to directly include the files, or let the action handler do it.
113
  */
114
  public function init_admin_scripts( $direct = false ) {
115
 
117
  $this->enqueue_admin_css( $this->page_base_file );
118
  $this->enqueue_admin_javascript( $this->page_base_file );
119
  } else {
120
+ \add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_css' ), 1 );
121
+ \add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_javascript' ), 1 );
122
  }
 
123
  }
124
 
125
  /**
135
  * Put hook and js name in class vars.
136
  * @since 2.5.2.2
137
  */
138
+ $this->page_base_file = $this->page_base_file ?: $hook;
139
 
140
  //* Register the script.
141
+ $this->_register_admin_javascript();
142
+
143
+ if ( $this->is_post_edit() || $this->is_seo_settings_page() )
144
+ \wp_enqueue_media();
145
 
146
+ if ( $this->is_seo_settings_page() )
147
+ \wp_enqueue_script( 'wp-color-picker' );
148
+
149
+ \wp_enqueue_script( $this->js_name );
150
 
151
  /**
152
  * Localize JavaScript.
153
  * @since 2.5.2.2
154
  */
155
+ \add_action( 'admin_footer', array( $this, '_localize_admin_javascript' ) );
156
 
157
  }
158
 
163
  * @staticvar bool $registered : Prevents Re-registering of the style.
164
  * @access private
165
  */
166
+ public function _register_admin_javascript() {
167
 
168
  static $registered = null;
169
 
172
 
173
  $suffix = $this->script_debug ? '' : '.min';
174
 
175
+ \wp_register_script( $this->js_name, THE_SEO_FRAMEWORK_DIR_URL . "lib/js/{$this->js_name}{$suffix}.js", array( 'jquery' ), THE_SEO_FRAMEWORK_VERSION, true );
176
 
177
  $registered = true;
178
 
185
  * @staticvar bool $localized : Prevents Re-registering of the l10n.
186
  * @access private
187
  */
188
+ public function _localize_admin_javascript() {
189
 
190
  static $localized = null;
191
 
194
 
195
  $strings = $this->get_javascript_l10n();
196
 
197
+ \wp_localize_script( $this->js_name, "{$this->js_name}L10n", $strings );
198
 
199
  $localized = true;
200
 
206
  * @since 2.6.0
207
  * @staticvar array $strings : The l10n strings.
208
  * @since 2.7.0 Added AJAX nonce: 'autodescription-ajax-nonce'
209
+ * @since 2.8.0 1. Added input detection: 'hasInput'
210
+ * 2. Reworked output.
211
+ * 3. Removed unused caching.
212
+ * 4. Added dynamic output control.
213
  *
214
  * @return array $strings The l10n strings.
215
  */
216
  protected function get_javascript_l10n() {
217
 
 
 
 
 
 
218
  $blog_name = $this->get_blogname();
219
  $description = $this->get_blogdescription();
220
  $title = '';
235
  $title_separator = $this->get_separator( 'title' );
236
  $description_separator = $this->get_separator( 'description' );
237
 
 
238
  $ishome = false;
239
 
240
  if ( isset( $this->page_base_file ) && $this->page_base_file ) {
270
  }
271
  } elseif ( $this->is_archive() ) {
272
  //* Category or Tag.
273
+ if ( isset( $GLOBALS['current_screen']->taxonomy ) ) {
 
 
274
 
275
  $term_id = $this->get_admin_term_id();
276
 
277
  if ( $term_id ) {
278
  $generated_doctitle_args = array(
279
  'term_id' => $term_id,
280
+ 'taxonomy' => $GLOBALS['current_screen']->taxonomy,
281
  'notagline' => true,
282
  'get_custom_field' => false,
283
  );
296
  // We're on our SEO settings pages.
297
  if ( $this->has_page_on_front() ) {
298
  // Home is a page.
299
+ $inpost_title = $this->get_custom_field( '_genesis_title', \get_option( 'page_on_front' ) );
300
  } else {
301
  // Home is a blog.
302
  $inpost_title = '';
303
  }
304
+ $title = $inpost_title ?: $blog_name;
305
+ $additions = $home_tagline ?: $description;
306
  }
307
 
308
+ $nonce = \wp_create_nonce( 'autodescription-ajax-nonce' );
309
+
310
+ return array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  'nonce' => $nonce,
312
+ 'i18n' => array(
313
+ 'saveAlert' => \esc_html__( 'The changes you made will be lost if you navigate away from this page.', 'autodescription' ),
314
+ 'confirmReset' => \esc_html__( 'Are you sure you want to reset all SEO settings to their defaults?', 'autodescription' ),
315
+ 'good' => \esc_html( $good ),
316
+ 'okay' => \esc_html( $okay ),
317
+ 'bad' => \esc_html( $bad ),
318
+ 'unknown' => \esc_html( $unknown ),
319
+ ),
320
+ 'states' => array(
321
+ 'isRTL' => (bool) \is_rtl(),
322
+ 'isHome' => $ishome,
323
+ 'hasInput' => $this->is_term_edit() || $this->is_post_edit() || $this->is_seo_settings_page(),
324
+ 'counterType' => \absint( $counter_type ),
325
+ 'titleTagline' => $tagline,
326
+ ),
327
+ 'params' => array(
328
+ 'siteTitle' => \esc_html( \wp_kses_decode_entities( $title ) ),
329
+ 'titleAdditions' => \esc_html( \wp_kses_decode_entities( $additions ) ),
330
+ 'blogDescription' => \esc_html( \wp_kses_decode_entities( $description ) ),
331
+ 'titleSeparator' => \esc_html( $title_separator ),
332
+ 'descriptionSeparator' => \esc_html( $description_separator ),
333
+ 'titleLocation' => \esc_html( $title_location ),
334
+ ),
335
+ 'other' => $this->additional_js_l10n( null, array(), true ),
336
  );
337
  }
338
 
339
+ /**
340
+ * Maintains and Returns additional JS l10n.
341
+ *
342
+ * They are put under object 'tsfemL10n.other.$key.[ $val ]'.
343
+ *
344
+ * @since 2.8.0
345
+ * @staticvar object $strings The cached strings object.
346
+ *
347
+ * @param null|string $key The object key. Requires escape.
348
+ * @param null|array $val The object val. Requires escape.
349
+ * @param bool $get Whether to return the cached strings.
350
+ * @param bool $escape Whether to escape the input.
351
+ * @return object Early when $get is true
352
+ */
353
+ public function additional_js_l10n( $key = null, array $val = array(), $get = false, $escape = true ) {
354
+
355
+ static $strings = null;
356
+
357
+ if ( null === $strings )
358
+ $strings = new \stdClass();
359
+
360
+ if ( $get )
361
+ return $strings;
362
+
363
+ if ( $escape ) {
364
+ $key = \esc_attr( $key );
365
+ $val = \map_deep( $val, 'esc_attr' );
366
+ }
367
+
368
+ if ( $key )
369
+ $strings->$key = $val;
370
+ }
371
+
372
  /**
373
  * CSS for the AutoDescription Bar
374
  *
375
  * @since 2.1.9
376
  *
377
  * @param $hook the current page
 
 
 
378
  */
379
  public function enqueue_admin_css( $hook ) {
380
 
382
  * Put hook and js name in class vars.
383
  * @since 2.5.2.2
384
  */
385
+ $this->page_base_file = $this->page_base_file ?: $hook;
386
 
387
  //* Register the script.
388
  $this->register_admin_css();
389
 
390
+ if ( $this->is_seo_settings_page() ) {
391
+ \wp_enqueue_style( 'wp-color-picker' );
392
+ }
393
+
394
+ \wp_enqueue_style( $this->css_name );
395
 
396
  }
397
 
409
  if ( isset( $registered ) )
410
  return;
411
 
412
+ $rtl = \is_rtl() ? '-rtl' : '';
413
  $suffix = $this->script_debug ? '' : '.min';
414
  $registered = true;
415
 
416
+ \wp_register_style( $this->css_name, THE_SEO_FRAMEWORK_DIR_URL . "lib/css/{$this->css_name}{$rtl}{$suffix}.css", array(), THE_SEO_FRAMEWORK_VERSION, 'all' );
417
+
418
+ }
419
+
420
+ /**
421
+ * Adds removable query args to WordPress query arg handler.
422
+ *
423
+ * @since 2.8.0
424
+ *
425
+ * @param array $removable_query_args
426
+ * @return array $removable_query_args The adjusted removable query args.
427
+ */
428
+ public function add_removable_query_args( $removable_query_args = array() ) {
429
 
430
+ if ( ! is_array( $removable_query_args ) )
431
+ return $removable_query_args;
432
+
433
+ $removable_query_args[] = 'tsf-settings-reset';
434
+ $removable_query_args[] = 'tsf-settings-updated';
435
+
436
+ return $removable_query_args;
437
  }
438
 
439
  /**
452
  if ( empty( $page ) )
453
  return;
454
 
455
+ $url = html_entity_decode( \menu_page_url( $page, false ) );
456
 
457
  foreach ( $query_args as $key => $value ) {
458
  if ( empty( $key ) || empty( $value ) )
459
  unset( $query_args[ $key ] );
460
  }
461
 
462
+ $url = \add_query_arg( $query_args, $url );
463
 
464
+ \wp_safe_redirect( \esc_url_raw( $url ), 302 );
465
  exit;
466
  }
467
 
476
  if ( $this->is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) {
477
 
478
  //* If current user isn't allowed to edit posts, don't do anything and kill PHP.
479
+ if ( ! \current_user_can( 'publish_posts' ) )
480
  exit;
481
 
482
+ \check_ajax_referer( 'autodescription-ajax-nonce', 'nonce' );
483
 
484
  /**
485
  * Count up, reset to 0 if needed. We have 4 options: 0, 1, 2, 3
486
  * $_POST['val'] already contains updated number.
487
  */
488
  $value = isset( $_POST['val'] ) ? intval( $_POST['val'] ) : $this->get_user_option( 0, 'counter_type', 3 ) + 1;
489
+ $value = \absint( $value );
490
 
491
  if ( $value > 3 )
492
  $value = 0;
499
  'value' => $value,
500
  );
501
 
502
+ //* Remove output buffer.
503
+ $this->clean_reponse_header();
504
+
505
  //* Encode and echo results. Requires JSON decode within JS.
506
  echo json_encode( $results );
507
 
inc/classes/{adminpages.class.php → admin-pages.class.php} RENAMED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  /**
3
  * The SEO Framework plugin
4
  * Copyright (C) 2015 - 2016 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
@@ -16,16 +23,14 @@
16
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
  */
18
 
19
- defined( 'ABSPATH' ) or die;
20
-
21
  /**
22
- * Class AutoDescription_Siteoptions
23
  *
24
- * Renders admin pages content for AutoDescription.
25
  *
26
- * @since 2.2.2
27
  */
28
- class AutoDescription_Adminpages extends AutoDescription_Inpost {
29
 
30
  /**
31
  * Page Defaults.
@@ -54,57 +59,11 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
54
  */
55
  public $load_options;
56
 
57
- /**
58
- * Unserializing instances of this class is forbidden.
59
- */
60
- private function __wakeup() { }
61
-
62
- /**
63
- * Handle unapproachable invoked methods.
64
- */
65
- public function __call( $name, $arguments ) {
66
- parent::__call( $name, $arguments );
67
- }
68
-
69
  /**
70
  * Constructor. Loads parent constructor, does actions and sets up variables.
71
  */
72
- public function __construct() {
73
  parent::__construct();
74
-
75
- /**
76
- * Applies filters the_seo_framework_load_options : Boolean Allows the options page to be removed
77
- * @since 2.2.2
78
- */
79
- $this->load_options = (bool) apply_filters( 'the_seo_framework_load_options', true );
80
-
81
- add_action( 'init', array( $this, 'init_admin_actions' ), 0 );
82
- }
83
-
84
- /**
85
- * Initializes Admin Menu actions.
86
- *
87
- * @since 2.7.0
88
- */
89
- public function init_admin_actions() {
90
-
91
- if ( $this->load_options && $this->is_admin() ) {
92
- // Enqueue i18n defaults.
93
- add_action( 'admin_init', array( $this, 'enqueue_page_defaults' ), 1 );
94
-
95
- // Add menu links and register $this->seo_settings_page_hook
96
- add_action( 'admin_menu', array( $this, 'add_menu_link' ) );
97
-
98
- //* Load the page content
99
- add_action( 'admin_init', array( $this, 'settings_init' ) );
100
-
101
- // Set up notices
102
- add_action( 'admin_notices', array( $this, 'notices' ) );
103
-
104
- // Load nessecary assets
105
- add_action( 'admin_init', array( $this, 'load_assets' ) );
106
- }
107
-
108
  }
109
 
110
  /**
@@ -117,18 +76,17 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
117
  */
118
  public function enqueue_page_defaults() {
119
 
120
- $this->page_defaults = (array) apply_filters(
121
  'the_seo_framework_admin_page_defaults',
122
  array(
123
- 'save_button_text' => esc_html__( 'Save Settings', 'autodescription' ),
124
- 'reset_button_text' => esc_html__( 'Reset Settings', 'autodescription' ),
125
- 'saved_notice_text' => esc_html__( 'Settings are saved.', 'autodescription' ),
126
- 'reset_notice_text' => esc_html__( 'Settings are reset.', 'autodescription' ),
127
- 'error_notice_text' => esc_html__( 'Error saving settings.', 'autodescription' ),
128
- 'plugin_update_text' => esc_html__( 'New SEO Settings have been updated.', 'autodescription' ),
129
  )
130
  );
131
-
132
  }
133
 
134
  /**
@@ -141,8 +99,8 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
141
  public function add_menu_link() {
142
 
143
  $menu = array(
144
- 'page_title' => esc_html__( 'SEO Settings', 'autodescription' ),
145
- 'menu_title' => esc_html__( 'SEO', 'autodescription' ),
146
  'capability' => $this->settings_capability(),
147
  'menu_slug' => $this->seo_settings_page_slug,
148
  'callback' => array( $this, 'admin' ),
@@ -150,7 +108,7 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
150
  'position' => '90.9001',
151
  );
152
 
153
- $this->seo_settings_page_hook = add_menu_page(
154
  $menu['page_title'],
155
  $menu['menu_title'],
156
  $menu['capability'],
@@ -164,7 +122,7 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
164
  * Simply copy the previous, but rename the submenu entry.
165
  * The function add_submenu_page() takes care of the duplications.
166
  */
167
- add_submenu_page(
168
  $menu['menu_slug'],
169
  $menu['page_title'],
170
  $menu['page_title'],
@@ -174,10 +132,10 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
174
  );
175
 
176
  //* Enqueue styles
177
- add_action( 'admin_print_styles-' . $this->seo_settings_page_hook, array( $this, 'enqueue_admin_css' ), 11 );
178
 
179
  //* Enqueue scripts
180
- add_action( 'admin_print_scripts-' . $this->seo_settings_page_hook, array( $this, 'enqueue_admin_javascript' ), 11 );
181
 
182
  }
183
 
@@ -185,48 +143,49 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
185
  * Initialize the settings page.
186
  *
187
  * @since 2.2.2
 
188
  */
189
  public function settings_init() {
190
 
191
- add_action( $this->seo_settings_page_hook . '_settings_page_boxes', array( $this, 'do_metaboxes' ) );
192
- add_action( 'load-' . $this->seo_settings_page_hook, array( $this, 'metaboxes' ) );
 
193
 
 
 
 
194
  }
195
 
196
  /**
197
  * Echo out the do_metaboxes() and wrapping markup.
198
  *
199
  * @since 2.2.2
200
- *
201
- * @global array $wp_meta_boxes Holds all metaboxes data.
202
  */
203
  public function do_metaboxes() {
204
- global $wp_meta_boxes;
205
-
206
  ?>
207
  <div class="metabox-holder columns-2">
208
  <div class="postbox-container-1">
209
  <?php
210
- do_action( 'the_seo_framework_before_siteadmin_metaboxes', $this->seo_settings_page_hook );
211
 
212
- do_meta_boxes( $this->seo_settings_page_hook, 'main', null );
213
 
214
- if ( isset( $wp_meta_boxes[ $this->seo_settings_page_hook ]['main_extra'] ) )
215
- do_meta_boxes( $this->seo_settings_page_hook, 'main_extra', null );
216
 
217
- do_action( 'the_seo_framework_after_siteadmin_metaboxes', $this->seo_settings_page_hook );
218
  ?>
219
  </div>
220
  <div class="postbox-container-2">
221
  <?php
222
- do_action( 'the_seo_framework_before_siteadmin_metaboxes_side', $this->seo_settings_page_hook );
223
 
224
  /**
225
  * @TODO fill this in
226
  * @priority low 2.9.0
227
  */
228
 
229
- do_action( 'the_seo_framework_after_siteadmin_metaboxes_side', $this->seo_settings_page_hook );
230
  ?>
231
  </div>
232
  </div>
@@ -238,16 +197,16 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
238
  *
239
  * @since 2.2.2
240
  *
241
- * @see $this->title_metabox() Callback for Title Settings box.
242
- * @see $this->description_metabox() Callback for Description Settings box.
243
- * @see $this->robots_metabox() Callback for Robots Settings box.
244
- * @see $this->homepage_metabox() Callback for Home Page Settings box.
245
- * @see $this->social_metabox() Callback for Social Settings box.
246
- * @see $this->knowledge_metabox() Callback for Knowledge Graph Settings box.
247
- * @see $this->schema_metabox() Callback for Schema Settings box.
248
- * @see $this->webmaster_metabox() Callback for Webmaster Settings box.
249
- * @see $this->sitemaps_metabox() Callback for Sitemap Settings box.
250
- * @see $this->feed_metabox() Callback for Feed Settings box.
251
  */
252
  public function metaboxes() {
253
 
@@ -256,23 +215,35 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
256
  * Set any to false if you wish the meta box to be removed.
257
  *
258
  * @since 2.2.4
 
259
  */
260
- $title = (bool) apply_filters( 'the_seo_framework_title_metabox', true );
261
- $description = (bool) apply_filters( 'the_seo_framework_description_metabox', true );
262
- $robots = (bool) apply_filters( 'the_seo_framework_robots_metabox', true );
263
- $home = (bool) apply_filters( 'the_seo_framework_home_metabox', true );
264
- $social = (bool) apply_filters( 'the_seo_framework_social_metabox', true );
265
- $knowledge = (bool) apply_filters( 'the_seo_framework_knowledge_metabox', true );
266
- $schema = (bool) apply_filters( 'the_seo_framework_schema_metabox', true );
267
- $webmaster = (bool) apply_filters( 'the_seo_framework_webmaster_metabox', true );
268
- $sitemap = (bool) apply_filters( 'the_seo_framework_sitemap_metabox', true );
269
- $feed = (bool) apply_filters( 'the_seo_framework_feed_metabox', true );
 
 
 
 
 
 
 
 
 
 
 
270
 
271
  //* Title Meta Box
272
  if ( $title )
273
- add_meta_box(
274
  'autodescription-title-settings',
275
- esc_html__( 'Title Settings', 'autodescription' ),
276
  array( $this, 'title_metabox' ),
277
  $this->seo_settings_page_hook,
278
  'main',
@@ -281,9 +252,9 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
281
 
282
  //* Description Meta Box
283
  if ( $description )
284
- add_meta_box(
285
  'autodescription-description-settings',
286
- esc_html__( 'Description Meta Settings', 'autodescription' ),
287
  array( $this, 'description_metabox' ),
288
  $this->seo_settings_page_hook,
289
  'main',
@@ -292,9 +263,9 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
292
 
293
  //* Home Page Meta Box
294
  if ( $home )
295
- add_meta_box(
296
  'autodescription-homepage-settings',
297
- esc_html__( 'Home Page Settings', 'autodescription' ),
298
  array( $this, 'homepage_metabox' ),
299
  $this->seo_settings_page_hook,
300
  'main',
@@ -303,31 +274,20 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
303
 
304
  //* Social Meta Box
305
  if ( $social )
306
- add_meta_box(
307
  'autodescription-social-settings',
308
- esc_html__( 'Social Meta Settings', 'autodescription' ),
309
  array( $this, 'social_metabox' ),
310
  $this->seo_settings_page_hook,
311
  'main',
312
  array()
313
  );
314
 
315
- //* Knowledge Graph Meta Box
316
- if ( $knowledge )
317
- add_meta_box(
318
- 'autodescription-knowledgegraph-settings',
319
- esc_html__( 'Knowledge Graph Settings', 'autodescription' ),
320
- array( $this, 'knowledge_metabox' ),
321
- $this->seo_settings_page_hook,
322
- 'main',
323
- array()
324
- );
325
-
326
  //* Title Meta Box
327
  if ( $schema )
328
- add_meta_box(
329
  'autodescription-schema-settings',
330
- esc_html__( 'Schema Settings', 'autodescription' ),
331
  array( $this, 'schema_metabox' ),
332
  $this->seo_settings_page_hook,
333
  'main',
@@ -336,9 +296,9 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
336
 
337
  //* Robots Meta Box
338
  if ( $robots )
339
- add_meta_box(
340
  'autodescription-robots-settings',
341
- esc_html__( 'Robots Meta Settings', 'autodescription' ),
342
  array( $this, 'robots_metabox' ),
343
  $this->seo_settings_page_hook,
344
  'main',
@@ -347,9 +307,9 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
347
 
348
  //* Webmaster Meta Box
349
  if ( $webmaster )
350
- add_meta_box(
351
  'autodescription-webmaster-settings',
352
- esc_html__( 'Webmaster Meta Settings', 'autodescription' ),
353
  array( $this, 'webmaster_metabox' ),
354
  $this->seo_settings_page_hook,
355
  'main',
@@ -358,9 +318,9 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
358
 
359
  //* Sitemaps Meta Box
360
  if ( $sitemap )
361
- add_meta_box(
362
  'autodescription-sitemap-settings',
363
- esc_html__( 'Sitemap Settings', 'autodescription' ),
364
  array( $this, 'sitemaps_metabox' ),
365
  $this->seo_settings_page_hook,
366
  'main',
@@ -369,15 +329,14 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
369
 
370
  //* Feed Meta Box
371
  if ( $feed )
372
- add_meta_box(
373
  'autodescription-feed-settings',
374
- esc_html__( 'Feed Settings', 'autodescription' ),
375
  array( $this, 'feed_metabox' ),
376
  $this->seo_settings_page_hook,
377
  'main',
378
  array()
379
  );
380
-
381
  }
382
 
383
  /**
@@ -392,26 +351,26 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
392
  <div class="wrap tsf-metaboxes">
393
  <form method="post" action="options.php">
394
 
395
- <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
396
- <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
397
- <?php settings_fields( $this->settings_field ); ?>
398
 
399
  <div class="tsf-top-wrap">
400
- <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
401
  <p class="tsf-top-buttons">
402
  <?php
403
- submit_button( $this->page_defaults['save_button_text'], 'primary', 'submit', false, array( 'id' => '' ) );
404
- submit_button( $this->page_defaults['reset_button_text'], 'secondary autodescription-js-confirm-reset', $this->get_field_name( 'reset' ), false, array( 'id' => '' ) );
405
  ?>
406
  </p>
407
  </div>
408
 
409
- <?php do_action( "{$this->seo_settings_page_hook}_settings_page_boxes", $this->seo_settings_page_hook ); ?>
410
 
411
  <div class="tsf-bottom-buttons">
412
  <?php
413
- submit_button( $this->page_defaults['save_button_text'], 'primary', 'submit', false, array( 'id' => '' ) );
414
- submit_button( $this->page_defaults['reset_button_text'], 'secondary autodescription-js-confirm-reset', $this->get_field_name( 'reset' ), false, array( 'id' => '' ) );
415
  ?>
416
  </div>
417
  </form>
@@ -419,11 +378,11 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
419
  <?php // Add postbox listeners ?>
420
  <script type="text/javascript">
421
  //<![CDATA[
422
- jQuery(document).ready( function ($) {
423
  // close postboxes that should be closed
424
  $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
425
  // postboxes setup
426
- postboxes.add_postbox_toggles('<?php echo esc_js( $this->seo_settings_page_hook ); ?>');
427
  });
428
  //]]>
429
  </script>
@@ -443,15 +402,20 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
443
  if ( false === $this->is_seo_settings_page( true ) )
444
  return;
445
 
446
- if ( isset( $_REQUEST['settings-updated'] ) && 'true' === $_REQUEST['settings-updated'] )
 
 
 
 
 
447
  $this->do_dismissible_notice( $this->page_defaults['saved_notice_text'], 'updated' );
448
- elseif ( isset( $_REQUEST['reset'] ) && 'true' === $_REQUEST['reset'] )
449
  $this->do_dismissible_notice( $this->page_defaults['reset_notice_text'], 'warning' );
450
- elseif ( isset( $_REQUEST['error'] ) && 'true' === $_REQUEST['error'] )
451
  $this->do_dismissible_notice( $this->page_defaults['error_notice_text'], 'error' );
452
- elseif ( isset( $_REQUEST['seo-updated'] ) && 'true' === $_REQUEST['seo-updated'] )
453
  $this->do_dismissible_notice( $this->page_defaults['plugin_update_text'], 'updated' );
454
-
455
  }
456
 
457
  /**
@@ -478,7 +442,7 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
478
  * @param string $name Field name base
479
  */
480
  public function field_name( $name ) {
481
- echo esc_attr( $this->get_field_name( $name ) );
482
  }
483
 
484
  /**
@@ -506,7 +470,7 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
506
  public function field_id( $id, $echo = true ) {
507
 
508
  if ( $echo ) {
509
- echo esc_attr( $this->get_field_id( $id ) );
510
  } else {
511
  return $this->get_field_id( $id );
512
  }
@@ -535,7 +499,7 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
535
  * @param string $key Field key
536
  */
537
  public function field_value( $key ) {
538
- echo esc_attr( $this->get_field_value( $key ) );
539
  }
540
 
541
  /**
@@ -550,12 +514,13 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
550
  public function wrap_fields( $input = '', $echo = false ) {
551
 
552
  if ( is_array( $input ) )
553
- $input = implode( "\r\n", $input );
554
 
555
  if ( $echo ) {
556
- echo '<div class="tsf-fields">' . "\r\n" . $input . "\r\n" . '</div>';
 
557
  } else {
558
- return '<div class="tsf-fields">' . "\r\n" . $input . "\r\n" . '</div>';
559
  }
560
  }
561
 
@@ -573,8 +538,10 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
573
  */
574
  public function make_checkbox( $field_id = '', $label = '', $description = '', $escape = true ) {
575
 
576
- $description = $escape ? esc_html( $description ) : $description;
577
- $label = $escape ? esc_html( $label ) : $label;
 
 
578
 
579
  $description = $description ? '<p class="description tsf-option-spacer">' . $description . '</p>' : '';
580
 
@@ -586,7 +553,7 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
586
  . 'id="' . $this->get_field_id( $field_id ) . '" '
587
  . $this->get_is_conditional_checked( $field_id ) . ' '
588
  . 'value="1" '
589
- . checked( $this->get_field_value( $field_id ), true, false ) .
590
  ' />'
591
  . $label
592
  . '</label>'
@@ -597,6 +564,48 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
597
  return $output;
598
  }
599
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
600
  /**
601
  * Return a wrapped question mark.
602
  *
@@ -610,9 +619,9 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
610
  public function make_info( $description = '', $link = '', $echo = true ) {
611
 
612
  if ( $link ) {
613
- $output = '<a href="' . esc_url( $link ) . '" target="_blank" title="' . esc_attr( $description ) . '">[?]</a>';
614
  } else {
615
- $output = '<span title="' . esc_attr( $description ) . '">[?]</span>';
616
  }
617
 
618
  if ( $echo ) {
@@ -630,7 +639,7 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
630
  */
631
  public function load_assets() {
632
  //* Hook scripts method
633
- add_action( "load-{$this->seo_settings_page_hook}", array( $this, 'metabox_scripts' ) );
634
  }
635
 
636
  /**
@@ -639,9 +648,9 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
639
  * @since 2.2.2
640
  */
641
  public function metabox_scripts() {
642
- wp_enqueue_script( 'common' );
643
- wp_enqueue_script( 'wp-lists' );
644
- wp_enqueue_script( 'postbox' );
645
  }
646
 
647
  /**
@@ -668,9 +677,9 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
668
 
669
  if ( $echo ) {
670
  if ( $wrap ) {
671
- printf( 'class="%s"', esc_attr( $class ) );
672
  } else {
673
- echo esc_attr( $class );
674
  }
675
  } else {
676
  if ( $wrap )
@@ -702,9 +711,9 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
702
 
703
  if ( $echo ) {
704
  if ( $wrap ) {
705
- printf( 'class="%s"', esc_attr( $class ) );
706
  } else {
707
- echo esc_attr( $class );
708
  }
709
  } else {
710
  if ( $wrap )
@@ -757,9 +766,9 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
757
 
758
  if ( $echo ) {
759
  if ( $wrap ) {
760
- printf( 'class="%s"', esc_attr( $class ) );
761
  } else {
762
- echo esc_attr( $class );
763
  }
764
  } else {
765
  if ( $wrap )
@@ -795,9 +804,9 @@ class AutoDescription_Adminpages extends AutoDescription_Inpost {
795
 
796
  if ( $echo ) {
797
  if ( $wrap ) {
798
- echo sprintf( 'class="%s"', esc_attr( $class ) );
799
  } else {
800
- echo esc_attr( $class );
801
  }
802
  } else {
803
  if ( $wrap )
1
  <?php
2
+ /**
3
+ * @package The_SEO_Framework\Classes
4
+ */
5
+ namespace The_SEO_Framework;
6
+
7
+ defined( 'ABSPATH' ) or die;
8
+
9
  /**
10
  * The SEO Framework plugin
11
  * Copyright (C) 2015 - 2016 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
23
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24
  */
25
 
 
 
26
  /**
27
+ * Class The_SEO_Framework\Site_Options
28
  *
29
+ * Renders admin pages content for this plugin.
30
  *
31
+ * @since 2.8.0
32
  */
33
+ class Admin_Pages extends Inpost {
34
 
35
  /**
36
  * Page Defaults.
59
  */
60
  public $load_options;
61
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  /**
63
  * Constructor. Loads parent constructor, does actions and sets up variables.
64
  */
65
+ protected function __construct() {
66
  parent::__construct();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
68
 
69
  /**
76
  */
77
  public function enqueue_page_defaults() {
78
 
79
+ $this->page_defaults = (array) \apply_filters(
80
  'the_seo_framework_admin_page_defaults',
81
  array(
82
+ 'save_button_text' => \esc_html__( 'Save Settings', 'autodescription' ),
83
+ 'reset_button_text' => \esc_html__( 'Reset Settings', 'autodescription' ),
84
+ 'saved_notice_text' => \esc_html__( 'Settings are saved.', 'autodescription' ),
85
+ 'reset_notice_text' => \esc_html__( 'Settings are reset.', 'autodescription' ),
86
+ 'error_notice_text' => \esc_html__( 'Error saving settings.', 'autodescription' ),
87
+ 'plugin_update_text' => \esc_html__( 'New SEO Settings have been updated.', 'autodescription' ),
88
  )
89
  );
 
90
  }
91
 
92
  /**
99
  public function add_menu_link() {
100
 
101
  $menu = array(
102
+ 'page_title' => \esc_html__( 'SEO Settings', 'autodescription' ),
103
+ 'menu_title' => \esc_html__( 'SEO', 'autodescription' ),
104
  'capability' => $this->settings_capability(),
105
  'menu_slug' => $this->seo_settings_page_slug,
106
  'callback' => array( $this, 'admin' ),
108
  'position' => '90.9001',
109
  );
110
 
111
+ $this->seo_settings_page_hook = \add_menu_page(
112
  $menu['page_title'],
113
  $menu['menu_title'],
114
  $menu['capability'],
122
  * Simply copy the previous, but rename the submenu entry.
123
  * The function add_submenu_page() takes care of the duplications.
124
  */
125
+ \add_submenu_page(
126
  $menu['menu_slug'],
127
  $menu['page_title'],
128
  $menu['page_title'],
132
  );
133
 
134
  //* Enqueue styles
135
+ \add_action( 'admin_print_styles-' . $this->seo_settings_page_hook, array( $this, 'enqueue_admin_css' ), 11 );
136
 
137
  //* Enqueue scripts
138
+ \add_action( 'admin_print_scripts-' . $this->seo_settings_page_hook, array( $this, 'enqueue_admin_javascript' ), 11 );
139
 
140
  }
141
 
143
  * Initialize the settings page.
144
  *
145
  * @since 2.2.2
146
+ * @since 2.8.0 Handled settings POST initialization.
147
  */
148
  public function settings_init() {
149
 
150
+ //* Handle post-update actions. Must be initialized on admin_init and is initalized on options.php.
151
+ if ( 'options.php' === $GLOBALS['pagenow'] )
152
+ $this->handle_update_post();
153
 
154
+ //* Output metaboxes.
155
+ \add_action( $this->seo_settings_page_hook . '_settings_page_boxes', array( $this, 'do_metaboxes' ) );
156
+ \add_action( 'load-' . $this->seo_settings_page_hook, array( $this, 'metaboxes' ) );
157
  }
158
 
159
  /**
160
  * Echo out the do_metaboxes() and wrapping markup.
161
  *
162
  * @since 2.2.2
 
 
163
  */
164
  public function do_metaboxes() {
 
 
165
  ?>
166
  <div class="metabox-holder columns-2">
167
  <div class="postbox-container-1">
168
  <?php
169
+ \do_action( 'the_seo_framework_before_siteadmin_metaboxes', $this->seo_settings_page_hook );
170
 
171
+ \do_meta_boxes( $this->seo_settings_page_hook, 'main', null );
172
 
173
+ if ( isset( $GLOBALS['wp_meta_boxes'][ $this->seo_settings_page_hook ]['main_extra'] ) )
174
+ \do_meta_boxes( $this->seo_settings_page_hook, 'main_extra', null );
175
 
176
+ \do_action( 'the_seo_framework_after_siteadmin_metaboxes', $this->seo_settings_page_hook );
177
  ?>
178
  </div>
179
  <div class="postbox-container-2">
180
  <?php
181
+ \do_action( 'the_seo_framework_before_siteadmin_metaboxes_side', $this->seo_settings_page_hook );
182
 
183
  /**
184
  * @TODO fill this in
185
  * @priority low 2.9.0
186
  */
187
 
188
+ \do_action( 'the_seo_framework_after_siteadmin_metaboxes_side', $this->seo_settings_page_hook );
189
  ?>
190
  </div>
191
  </div>
197
  *
198
  * @since 2.2.2
199
  *
200
+ * @see $this->general_metabox() Callback for General Settings box.
201
+ * @see $this->title_metabox() Callback for Title Settings box.
202
+ * @see $this->description_metabox() Callback for Description Settings box.
203
+ * @see $this->robots_metabox() Callback for Robots Settings box.
204
+ * @see $this->homepage_metabox() Callback for Home Page Settings box.
205
+ * @see $this->social_metabox() Callback for Social Settings box.
206
+ * @see $this->schema_metabox() Callback for Schema Settings box.
207
+ * @see $this->webmaster_metabox() Callback for Webmaster Settings box.
208
+ * @see $this->sitemaps_metabox() Callback for Sitemap Settings box.
209
+ * @see $this->feed_metabox() Callback for Feed Settings box.
210
  */
211
  public function metaboxes() {
212
 
215
  * Set any to false if you wish the meta box to be removed.
216
  *
217
  * @since 2.2.4
218
+ * @since 2.8.0: Added `the_seo_framework_general_metabox` filter.
219
  */
220
+ $general = (bool) \apply_filters( 'the_seo_framework_general_metabox', true );
221
+ $title = (bool) \apply_filters( 'the_seo_framework_title_metabox', true );
222
+ $description = (bool) \apply_filters( 'the_seo_framework_description_metabox', true );
223
+ $robots = (bool) \apply_filters( 'the_seo_framework_robots_metabox', true );
224
+ $home = (bool) \apply_filters( 'the_seo_framework_home_metabox', true );
225
+ $social = (bool) \apply_filters( 'the_seo_framework_social_metabox', true );
226
+ $schema = (bool) \apply_filters( 'the_seo_framework_schema_metabox', true );
227
+ $webmaster = (bool) \apply_filters( 'the_seo_framework_webmaster_metabox', true );
228
+ $sitemap = (bool) \apply_filters( 'the_seo_framework_sitemap_metabox', true );
229
+ $feed = (bool) \apply_filters( 'the_seo_framework_feed_metabox', true );
230
+
231
+ //* Title Meta Box
232
+ if ( $general )
233
+ \add_meta_box(
234
+ 'autodescription-general-settings',
235
+ \esc_html__( 'General Settings', 'autodescription' ),
236
+ array( $this, 'general_metabox' ),
237
+ $this->seo_settings_page_hook,
238
+ 'main',
239
+ array()
240
+ );
241
 
242
  //* Title Meta Box
243
  if ( $title )
244
+ \add_meta_box(
245
  'autodescription-title-settings',
246
+ \esc_html__( 'Title Settings', 'autodescription' ),
247
  array( $this, 'title_metabox' ),
248
  $this->seo_settings_page_hook,
249
  'main',
252
 
253
  //* Description Meta Box
254
  if ( $description )
255
+ \add_meta_box(
256
  'autodescription-description-settings',
257
+ \esc_html__( 'Description Meta Settings', 'autodescription' ),
258
  array( $this, 'description_metabox' ),
259
  $this->seo_settings_page_hook,
260
  'main',
263
 
264
  //* Home Page Meta Box
265
  if ( $home )
266
+ \add_meta_box(
267
  'autodescription-homepage-settings',
268
+ \esc_html__( 'Home Page Settings', 'autodescription' ),
269
  array( $this, 'homepage_metabox' ),
270
  $this->seo_settings_page_hook,
271
  'main',
274
 
275
  //* Social Meta Box
276
  if ( $social )
277
+ \add_meta_box(
278
  'autodescription-social-settings',
279
+ \esc_html__( 'Social Meta Settings', 'autodescription' ),
280
  array( $this, 'social_metabox' ),
281
  $this->seo_settings_page_hook,
282
  'main',
283
  array()
284
  );
285
 
 
 
 
 
 
 
 
 
 
 
 
286
  //* Title Meta Box
287
  if ( $schema )
288
+ \add_meta_box(
289
  'autodescription-schema-settings',
290
+ \esc_html__( 'Schema Settings', 'autodescription' ),
291
  array( $this, 'schema_metabox' ),
292
  $this->seo_settings_page_hook,
293
  'main',
296
 
297
  //* Robots Meta Box
298
  if ( $robots )
299
+ \add_meta_box(
300
  'autodescription-robots-settings',
301
+ \esc_html__( 'Robots Meta Settings', 'autodescription' ),
302
  array( $this, 'robots_metabox' ),
303
  $this->seo_settings_page_hook,
304
  'main',
307
 
308
  //* Webmaster Meta Box
309
  if ( $webmaster )
310
+ \add_meta_box(
311
  'autodescription-webmaster-settings',
312
+ \esc_html__( 'Webmaster Meta Settings', 'autodescription' ),
313
  array( $this, 'webmaster_metabox' ),
314
  $this->seo_settings_page_hook,
315
  'main',
318
 
319
  //* Sitemaps Meta Box
320
  if ( $sitemap )
321
+ \add_meta_box(
322
  'autodescription-sitemap-settings',
323
+ \esc_html__( 'Sitemap Settings', 'autodescription' ),
324
  array( $this, 'sitemaps_metabox' ),
325
  $this->seo_settings_page_hook,
326
  'main',
329
 
330
  //* Feed Meta Box
331
  if ( $feed )
332
+ \add_meta_box(
333
  'autodescription-feed-settings',
334
+ \esc_html__( 'Feed Settings', 'autodescription' ),
335
  array( $this, 'feed_metabox' ),
336
  $this->seo_settings_page_hook,
337
  'main',
338
  array()
339
  );
 
340
  }
341
 
342
  /**
351
  <div class="wrap tsf-metaboxes">
352
  <form method="post" action="options.php">
353
 
354
+ <?php \wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
355
+ <?php \wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
356
+ <?php \settings_fields( $this->settings_field ); ?>
357
 
358
  <div class="tsf-top-wrap">
359
+ <h1><?php echo \esc_html( \get_admin_page_title() ); ?></h1>
360
  <p class="tsf-top-buttons">
361
  <?php
362
+ \submit_button( $this->page_defaults['save_button_text'], 'primary', 'submit', false, array( 'id' => '' ) );
363
+ \submit_button( $this->page_defaults['reset_button_text'], 'secondary tsf-js-confirm-reset', $this->get_field_name( 'tsf-settings-reset' ), false, array( 'id' => '' ) );
364
  ?>
365
  </p>
366
  </div>
367
 
368
+ <?php \do_action( "{$this->seo_settings_page_hook}_settings_page_boxes", $this->seo_settings_page_hook ); ?>
369
 
370
  <div class="tsf-bottom-buttons">
371
  <?php
372
+ \submit_button( $this->page_defaults['save_button_text'], 'primary', 'submit', false, array( 'id' => '' ) );
373
+ \submit_button( $this->page_defaults['reset_button_text'], 'secondary tsf-js-confirm-reset', $this->get_field_name( 'tsf-settings-reset' ), false, array( 'id' => '' ) );
374
  ?>
375
  </div>
376
  </form>
378
  <?php // Add postbox listeners ?>
379
  <script type="text/javascript">
380
  //<![CDATA[
381
+ jQuery(document).ready( function($) {
382
  // close postboxes that should be closed
383
  $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
384
  // postboxes setup
385
+ postboxes.add_postbox_toggles('<?php echo \esc_js( $this->seo_settings_page_hook ); ?>');
386
  });
387
  //]]>
388
  </script>
402
  if ( false === $this->is_seo_settings_page( true ) )
403
  return;
404
 
405
+ $request = isset( $_REQUEST ) ? $_REQUEST : null;
406
+
407
+ if ( null === $request )
408
+ return;
409
+
410
+ if ( isset( $request['settings-updated'] ) && 'true' === $request['settings-updated'] ) :
411
  $this->do_dismissible_notice( $this->page_defaults['saved_notice_text'], 'updated' );
412
+ elseif ( isset( $request['tsf-settings-reset'] ) && 'true' === $request['tsf-settings-reset'] ) :
413
  $this->do_dismissible_notice( $this->page_defaults['reset_notice_text'], 'warning' );
414
+ elseif ( isset( $request['error'] ) && 'true' === $request['error'] ) :
415
  $this->do_dismissible_notice( $this->page_defaults['error_notice_text'], 'error' );
416
+ elseif ( isset( $request['tsf-settings-updated'] ) && 'true' === $request['tsf-settings-updated'] ) :
417
  $this->do_dismissible_notice( $this->page_defaults['plugin_update_text'], 'updated' );
418
+ endif;
419
  }
420
 
421
  /**
442
  * @param string $name Field name base
443
  */
444
  public function field_name( $name ) {
445
+ echo \esc_attr( $this->get_field_name( $name ) );
446
  }
447
 
448
  /**
470
  public function field_id( $id, $echo = true ) {
471
 
472
  if ( $echo ) {
473
+ echo \esc_attr( $this->get_field_id( $id ) );
474
  } else {
475
  return $this->get_field_id( $id );
476
  }
499
  * @param string $key Field key
500
  */
501
  public function field_value( $key ) {
502
+ echo \esc_attr( $this->get_field_value( $key ) );
503
  }
504
 
505
  /**
514
  public function wrap_fields( $input = '', $echo = false ) {
515
 
516
  if ( is_array( $input ) )
517
+ $input = implode( PHP_EOL, $input );
518
 
519
  if ( $echo ) {
520
+ //* Already escaped.
521
+ echo '<div class="tsf-fields">' . $input . '</div>';
522
  } else {
523
+ return '<div class="tsf-fields">' . $input . '</div>';
524
  }
525
  }
526
 
538
  */
539
  public function make_checkbox( $field_id = '', $label = '', $description = '', $escape = true ) {
540
 
541
+ if ( $escape ) {
542
+ $description = \esc_html( $description );
543
+ $label = \esc_html( $label );
544
+ }
545
 
546
  $description = $description ? '<p class="description tsf-option-spacer">' . $description . '</p>' : '';
547
 
553
  . 'id="' . $this->get_field_id( $field_id ) . '" '
554
  . $this->get_is_conditional_checked( $field_id ) . ' '
555
  . 'value="1" '
556
+ . \checked( $this->get_field_value( $field_id ), true, false ) .
557
  ' />'
558
  . $label
559
  . '</label>'
564
  return $output;
565
  }
566
 
567
+ /**
568
+ * Return a text field wrapper.
569
+ *
570
+ * @since 2.8.0
571
+ * @ignore Unused.
572
+ * @access private
573
+ *
574
+ * @param string $field_id The option ID. Must be within the Autodescription settings.
575
+ * @param string $label The checkbox description label.
576
+ * @param string $description Addition description to place beneath the checkbox.
577
+ * @param string $placeholder The text field placeholder.
578
+ * @param bool $escape Whether to escape the label and description.
579
+ * @return HTML text field output.
580
+ */
581
+ public function make_textfield( $field_id = '', $label = '', $description = '', $placeholder = '', $escape = true ) {
582
+
583
+ if ( $escape ) {
584
+ $description = \esc_html( $description );
585
+ $label = \esc_html( $label );
586
+ $placeholder = \esc_attr( $placeholder );
587
+ }
588
+
589
+ $description = $description ? '<p class="description tsf-option-spacer">' . $description . '</p>' : '';
590
+
591
+ $output = '<p>'
592
+ . '<label for="' . $this->field_id( $field_id ) . '" class="tsf-toblock">'
593
+ . '<strong>' . $label . '</strong>'
594
+ . '</label>'
595
+ . '</p>'
596
+ . '<p>'
597
+ . '<input type="text" name="' . $this->field_name( $field_id ) . '"'
598
+ . ' class="large-text" id="' . $this->field_id( $field_id ) . '"'
599
+ . ' placeholder="' . $placeholder . '"'
600
+ . ' value="' . $this->get_field_value( $field_id ) . '"'
601
+ . ' />'
602
+ . '</p>'
603
+ . $description
604
+ ;
605
+
606
+ return $output;
607
+ }
608
+
609
  /**
610
  * Return a wrapped question mark.
611
  *
619
  public function make_info( $description = '', $link = '', $echo = true ) {
620
 
621
  if ( $link ) {
622
+ $output = '<a href="' . \esc_url( $link ) . '" target="_blank" title="' . \esc_attr( $description ) . '">[?]</a>';
623
  } else {
624
+ $output = '<span title="' . \esc_attr( $description ) . '">[?]</span>';
625
  }
626
 
627
  if ( $echo ) {
639
  */
640
  public function load_assets() {
641
  //* Hook scripts method
642
+ \add_action( "load-{$this->seo_settings_page_hook}", array( $this, 'metabox_scripts' ) );
643
  }
644
 
645
  /**
648
  * @since 2.2.2
649
  */
650
  public function metabox_scripts() {
651
+ \wp_enqueue_script( 'common' );
652
+ \wp_enqueue_script( 'wp-lists' );
653
+ \wp_enqueue_script( 'postbox' );
654
  }
655
 
656
  /**
677
 
678
  if ( $echo ) {
679
  if ( $wrap ) {
680
+ printf( 'class="%s"', \esc_attr( $class ) );
681
  } else {
682
+ echo \esc_attr( $class );
683
  }
684
  } else {
685
  if ( $wrap )
711
 
712
  if ( $echo ) {
713
  if ( $wrap ) {
714
+ printf( 'class="%s"', \esc_attr( $class ) );
715
  } else {
716
+ echo \esc_attr( $class );
717
  }
718
  } else {
719
  if ( $wrap )
766
 
767
  if ( $echo ) {
768
  if ( $wrap ) {
769
+ printf( 'class="%s"', \esc_attr( $class ) );
770
  } else {
771
+ echo \esc_attr( $class );
772
  }
773
  } else {
774
  if ( $wrap )
804
 
805
  if ( $echo ) {
806
  if ( $wrap ) {
807
+ printf( 'class="%s"', \esc_attr( $class ) );
808
  } else {
809
+ echo \esc_attr( $class );
810
  }
811
  } else {
812
  if ( $wrap )
inc/classes/{transients.class.php → cache.class.php} RENAMED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  /**
3
  * The SEO Framework plugin
4
  * Copyright (C) 2015 - 2016 Sybre Waaijer, CyberWire (https://cyberwire.nl/)
@@ -16,16 +23,14 @@
16
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
  */
18
 
19
- defined( 'ABSPATH' ) or die;
20
-
21
  /**
22
- * Class AutoDescription_Transients
23
  *
24
  * Generates, stores and deletes common transients.
25
  *
26
- * @since 2.3.3
27
  */
28
- class AutoDescription_Transients extends AutoDescription_Sitemaps {
29
 
30
  /**
31
  * The sitemap transient name.
@@ -64,52 +69,283 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
64
  protected $theme_doing_it_right_transient;
65
 
66
  /**
67
- * Unserializing instances of this class is forbidden.
68
  */
69
- private function __wakeup() { }
 
 
 
 
 
70
 
71
  /**
72
- * Handle unapproachable invoked methods.
 
 
 
 
 
73
  */
74
- public function __call( $name, $arguments ) {
75
- parent::__call( $name, $arguments );
76
  }
77
 
78
  /**
79
- * Constructor, load parent constructor and set up caches.
 
 
 
 
80
  */
81
- public function __construct() {
82
- parent::__construct();
83
-
84
- // Setup Transient names
85
- add_action( 'plugins_loaded', array( $this, 'setup_transient_names' ), 10 );
86
 
87
- /**
88
- * Delete Sitemap and Description transients on post publish/delete.
89
- * @see WP Core wp_transition_post_status()
90
- */
91
- add_action( 'publish_post', array( $this, 'delete_transients_post' ) );
92
- add_action( 'publish_page', array( $this, 'delete_transients_post' ) );
93
- add_action( 'deleted_post', array( $this, 'delete_transients_post' ) );
94
- add_action( 'deleted_page', array( $this, 'delete_transients_post' ) );
95
- add_action( 'post_updated', array( $this, 'delete_transients_post' ) );
96
- add_action( 'page_updated', array( $this, 'delete_transients_post' ) );
97
 
98
- add_action( 'profile_update', array( $this, 'delete_transients_author' ) );
 
 
99
 
100
- add_action( 'edit_term', array( $this, 'delete_auto_description_transients_term' ), 10, 3 );
101
- add_action( 'delete_term', array( $this, 'delete_auto_description_transients_term' ), 10, 4 );
102
 
103
  //* Delete Sitemap transient on permalink structure change.
104
- add_action( 'load-options-permalink.php', array( $this, 'delete_sitemap_transient_permalink_updated' ), 20 );
105
 
106
  //* Deletes front page description transient on Tagline change.
107
- add_action( 'update_option_blogdescription', array( $this, 'delete_auto_description_frontpage_transient' ), 10, 1 );
108
 
109
- //* Delete doing it wrong transient after theme switch.
110
- add_action( 'after_switch_theme', array( $this, 'delete_theme_dir_transient' ), 10, 0 );
111
- add_action( 'upgrader_process_complete', array( $this, 'delete_theme_dir_transient' ), 10, 2 );
 
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
114
 
115
  /**
@@ -123,42 +359,79 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
123
  * @since 2.6.0
124
  *
125
  * @param string $transient Transient name. Expected to not be SQL-escaped.
126
- *
127
  * @return mixed|bool Value of the transient. False on failure or non existing transient.
128
  */
129
  public function get_transient( $transient ) {
130
 
131
  if ( $this->the_seo_framework_use_transients )
132
- return get_transient( $transient );
133
 
134
  return false;
135
  }
136
 
137
  /**
138
- * Set the value of the transient..
139
  *
140
- * Prevents setting of transients when they're disabled.
141
- * @see $this->the_seo_framework_use_transients
142
  *
143
- * @since 2.6.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  *
145
- * @param string $transient Transient name. Expected to not be SQL-escaped.
146
- * @param string $value Transient value. Expected to not be SQL-escaped.
147
- * @param int $expiration Optional Transient expiration date, optional. Expected to not be SQL-escaped.
 
 
 
 
148
  */
149
- public function set_transient( $transient, $value, $expiration = '' ) {
150
 
151
- if ( $this->the_seo_framework_use_transients )
152
- set_transient( $transient, $value, $expiration );
153
 
 
154
  }
155
 
156
  /**
157
- * Setup vars for general site transients.
158
  *
159
- * @global int $blog_id
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  *
161
  * @since 2.3.3
 
 
 
 
162
  */
163
  public function setup_transient_names() {
164
  global $blog_id;
@@ -167,23 +440,29 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
167
  * When the caching mechanism changes. Change this value.
168
  * Use hex. e.g. 0, 1, 2, 9, a, b
169
  */
170
- $revision = '0';
 
171
 
172
- $this->sitemap_transient = 'tsf_sitemap_' . (string) $revision . '_' . (string) $blog_id;
173
- $this->theme_doing_it_right_transient = 'tsf_tdir_' . (string) $revision . '_' . (string) $blog_id;
174
  }
175
 
176
  /**
177
  * Setup vars for transients which require $page_id.
178
  *
179
  * @since 2.3.3
 
180
  *
181
  * @param int|string|bool $page_id the Taxonomy or Post ID. If false it will generate for the blog page.
182
  * @param string $taxonomy The taxonomy name.
183
- * @param strgin $type The Post Type
 
184
  */
185
  public function setup_auto_description_transient( $page_id, $taxonomy = '', $type = null ) {
186
 
 
 
 
187
  $cache_key = $this->generate_cache_key( $page_id, $taxonomy, $type );
188
 
189
  /**
@@ -192,7 +471,7 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
192
  *
193
  * @since 2.3.4
194
  */
195
- $revision = '1';
196
 
197
  $additions = $this->add_description_additions( $page_id, $taxonomy );
198
 
@@ -208,13 +487,18 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
208
  * Setup vars for transients which require $page_id.
209
  *
210
  * @since 2.3.3
 
211
  *
212
  * @param int|string|bool $page_id the Taxonomy or Post ID. If false it will generate for the blog page.
213
  * @param string $taxonomy The taxonomy name.
214
  * @param string|null $type The post type.
 
215
  */
216
  public function setup_ld_json_transient( $page_id, $taxonomy = '', $type = null ) {
217
 
 
 
 
218
  $cache_key = $this->generate_cache_key( $page_id, $taxonomy, $type );
219
 
220
  /**
@@ -222,7 +506,7 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
222
  *
223
  * Use hex. e.g. 0, 1, 2, 9, a, b
224
  */
225
- $revision = '1';
226
 
227
  /**
228
  * Change key based on options.
@@ -250,7 +534,7 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
250
  */
251
  public function generate_cache_key( $page_id, $taxonomy = '', $type = null ) {
252
 
253
- $page_id = $page_id ? $page_id : $this->get_the_real_ID();
254
 
255
  if ( isset( $type ) ) {
256
  if ( 'author' === $type ) {
@@ -260,8 +544,8 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
260
  //* Front/HomePage.
261
  return $this->add_cache_key_suffix( $this->generate_front_page_cache_key() );
262
  } else {
263
- $this->_doing_it_wrong( __METHOD__, esc_html__( 'Third parameter must be a known type.', 'autodescription' ), '2.6.5' );
264
- return $this->add_cache_key_suffix( esc_sql( $type . '_' . $page_id . '_' . $taxonomy ) );
265
  }
266
  }
267
 
@@ -296,7 +580,7 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
296
  $query = '';
297
 
298
  if ( function_exists( 'get_search_query' ) ) {
299
- $search_query = get_search_query();
300
 
301
  if ( $search_query )
302
  $query = str_replace( ' ', '', $search_query );
@@ -305,15 +589,19 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
305
  if ( mb_strlen( $query ) > 10 )
306
  $query = mb_substr( $query, 0, 10 );
307
 
308
- $query = esc_sql( $query );
309
  }
310
 
 
 
 
 
311
  $the_id = $page_id . '_s_' . $query;
312
  } elseif ( $this->is_archive() ) {
313
  if ( $this->is_category() || $this->is_tag() || $this->is_tax() ) {
314
 
315
  if ( empty( $t ) ) {
316
- $o = get_queried_object();
317
 
318
  if ( isset( $o->taxonomy ) )
319
  $t = $o->taxonomy;
@@ -327,18 +615,18 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
327
  } elseif ( $this->is_author() ) {
328
  $the_id = 'author_' . $page_id;
329
  } elseif ( $this->is_date() ) {
330
- $post = get_post();
331
 
332
  if ( $post && isset( $post->post_date ) ) {
333
  $date = $post->post_date;
334
 
335
  if ( $this->is_year() ) {
336
- $the_id .= 'year_' . mysql2date( 'y', $date, false );
337
  } elseif ( $this->is_month() ) {
338
- $the_id .= 'month_' . mysql2date( 'm_y', $date, false );
339
  } elseif ( $this->is_day() ) {
340
  //* Day. The correct notation.
341
- $the_id .= 'day_' . mysql2date( 'd_m_y', $date, false );
342
  }
343
  } else {
344
  //* Get seconds since UNIX Epoch. This is a failsafe.
@@ -361,13 +649,13 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
361
  //* Other taxonomial archives.
362
 
363
  if ( empty( $t ) ) {
364
- $post_type = get_query_var( 'post_type' );
365
 
366
  if ( is_array( $post_type ) )
367
  reset( $post_type );
368
 
369
  if ( $post_type )
370
- $post_type_obj = get_post_type_object( $post_type );
371
 
372
  if ( isset( $post_type_obj->labels->name ) )
373
  $t = $post_type_obj->labels->name;
@@ -375,7 +663,7 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
375
 
376
  //* Still empty? Try this.
377
  if ( empty( $t ) )
378
- $t = get_query_var( 'taxonomy' );
379
 
380
  $the_id = $this->generate_taxonomial_cache_key( $page_id, $t );
381
 
@@ -402,13 +690,19 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
402
  * Adds cache key suffix based on blog id and locale.
403
  *
404
  * @since 2.7.0
 
 
 
405
  *
406
  * @return string the cache key.
407
  */
408
- protected function add_cache_key_suffix( $key ) {
409
  global $blog_id;
410
 
411
- $locale = strtolower( get_locale() );
 
 
 
412
 
413
  return $key . '_' . $blog_id . '_' . $locale;
414
  }
@@ -417,7 +711,6 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
417
  * Returns the front page partial transient key.
418
  *
419
  * @param string $type
420
- *
421
  * @return string the front page transient key.
422
  */
423
  public function generate_front_page_cache_key( $type = '' ) {
@@ -429,7 +722,7 @@ class AutoDescription_Transients extends AutoDescription_Sitemaps {
429
  $type = 'blog';
430
  }
431