From db145ccebf55934dee5d62745e18024c8a92f90c Mon Sep 17 00:00:00 2001 From: Nikolai Kristiansen Date: Wed, 2 Dec 2015 20:58:32 +0100 Subject: [PATCH] Bump plugins --- .../includes/class-advertisement.php | 26 +- .../includes/class-protect-admin.php | 181 ++ .../class-role-additional-options.php | 134 + .../includes/class-ure-lib.php | 42 +- .../includes/class-user-role-editor.php | 232 +- .../includes/misc-support-stuff.php | 12 +- .../includes/ure-role-edit.php | 8 +- .../plugins/user-role-editor/readme.txt | 11 +- .../plugins/user-role-editor/uninstall.php | 2 + .../user-role-editor/user-role-editor.php | 6 +- .../{codeclimate.yml => .codeclimate.yml} | 3 +- wp/wp-content/plugins/wordpress-seo/README.md | 1 + .../plugins/wordpress-seo/admin/ajax.php | 73 +- .../ajax/class-recalculate-scores-ajax.php | 192 ++ .../admin/ajax/class-shortcode-filter.php | 39 + .../ajax/class-yoast-dismissable-notice.php | 69 + .../admin/ajax/class-yoast-onpage-ajax.php | 39 + .../ajax/class-yoast-plugin-conflict-ajax.php | 9 +- .../wordpress-seo/admin/class-admin-init.php | 119 +- .../admin/class-admin-user-profile.php | 11 +- .../wordpress-seo/admin/class-admin.php | 113 +- ...ass-bulk-description-editor-list-table.php | 7 +- .../admin/class-bulk-editor-list-table.php | 45 +- .../class-bulk-title-editor-list-table.php | 8 +- .../wordpress-seo/admin/class-config.php | 26 +- .../wordpress-seo/admin/class-customizer.php | 2 +- .../wordpress-seo/admin/class-export.php | 13 +- .../admin/class-import-external.php | 8 +- .../admin/class-import-woothemes-seo.php | 8 +- .../admin/class-import-wpseo.php | 186 ++ .../wordpress-seo/admin/class-import.php | 7 +- .../admin/class-meta-columns.php | 430 +++ .../wordpress-seo/admin/class-metabox.php | 2303 -------------- .../admin/class-plugin-conflict.php | 7 +- .../wordpress-seo/admin/class-pointers.php | 28 +- .../admin/class-recalculate-scores.php | 65 + .../admin/class-sitemaps-admin.php | 10 +- ...graph-admin.php => class-social-admin.php} | 118 +- .../admin/class-social-facebook.php | 34 +- .../wordpress-seo/admin/class-taxonomy.php | 296 -- .../admin/class-yoast-dashboard-widget.php | 88 +- .../wordpress-seo/admin/class-yoast-form.php | 23 +- .../admin/class-yoast-notification-center.php | 24 +- .../admin/class-yoast-notification.php | 22 +- .../admin/class-yoast-plugin-conflict.php | 25 +- .../admin/class-yoast-textstatistics.php | 429 --- .../google_search_console/class-gsc-ajax.php | 3 +- .../class-gsc-bulk-action.php | 11 +- .../class-gsc-category-filters.php | 18 +- .../google_search_console/class-gsc-count.php | 29 +- .../google_search_console/class-gsc-issue.php | 19 +- .../class-gsc-issues.php | 23 +- .../class-gsc-mapper.php | 13 +- .../class-gsc-marker.php | 7 +- .../class-gsc-platform-tabs.php | 9 +- .../class-gsc-service.php | 19 +- .../class-gsc-settings.php | 9 +- .../google_search_console/class-gsc-table.php | 37 +- .../admin/google_search_console/class-gsc.php | 32 +- .../views/gsc-create-redirect.php | 2 +- .../import/class-import-aioseo-hooks.php | 39 + .../admin/import/class-import-hooks.php | 90 + .../import/class-import-robots-meta-hooks.php | 39 + .../admin/import/class-import-wpseo-hooks.php | 40 + .../metabox/class-metabox-add-keyword-tab.php | 57 + .../metabox/class-metabox-addon-section.php | 37 + .../admin/metabox/class-metabox-form-tab.php | 86 + .../metabox/class-metabox-tab-section.php | 126 + .../admin/metabox/class-metabox.php | 1405 ++++++++ .../metabox/interface-metabox-section.php | 20 + .../admin/metabox/interface-metabox-tab.php | 24 + .../onpage/class-onpage-email-presenter.php | 155 + .../admin/onpage/class-onpage-notifier.php | 53 + .../admin/onpage/class-onpage-option.php | 128 + .../admin/onpage/class-onpage-request.php | 78 + .../admin/onpage/class-onpage.php | 206 ++ .../wordpress-seo/admin/pages/dashboard.php | 8 + .../wordpress-seo/admin/pages/licenses.php | 4 +- .../wordpress-seo/admin/pages/metas.php | 30 +- .../wordpress-seo/admin/pages/tools.php | 20 +- .../class-taxonomy-content-fields.php | 54 + .../class-taxonomy-fields-presenter.php | 219 ++ .../admin/taxonomy/class-taxonomy-fields.php | 83 + .../admin/taxonomy/class-taxonomy-metabox.php | 297 ++ .../class-taxonomy-settings-fields.php | 126 + .../taxonomy/class-taxonomy-social-fields.php | 136 + .../admin/taxonomy/class-taxonomy.php | 312 ++ .../wordpress-seo/admin/views/about.php | 250 +- .../admin/views/dashboard-widget.php | 65 +- .../admin/views/tab-permalinks.php | 14 +- .../admin/views/tool-file-editor.php | 43 +- .../admin/views/tool-import-export.php | 30 +- .../plugins/wordpress-seo/bower.json | 34 + .../css/{adminbar.css => adminbar-302.css} | 4 - .../wordpress-seo/css/adminbar-302.min.css | 1 + .../wordpress-seo/css/adminbar.min.css | 1 - .../css/{dashboard.css => dashboard-305.css} | 33 +- .../wordpress-seo/css/dashboard-305.min.css | 1 + .../wordpress-seo/css/dashboard.min.css | 1 - .../css/dist/yoast-seo/editicon.png | Bin 0 -> 509 bytes .../css/dist/yoast-seo/yoast-seo-305.min.css | 1 + .../css/{edit-page.css => edit-page-302.css} | 4 - .../wordpress-seo/css/edit-page-302.min.css | 1 + .../wordpress-seo/css/edit-page.min.css | 1 - .../css/{metabox-tabs.css => metabox-302.css} | 270 +- .../wordpress-seo/css/metabox-302.min.css | 1 + .../wordpress-seo/css/metabox-classic.css | 22 - .../wordpress-seo/css/metabox-classic.min.css | 1 - .../wordpress-seo/css/metabox-fresh.css | 23 - .../wordpress-seo/css/metabox-fresh.min.css | 1 - .../wordpress-seo/css/metabox-tabs.min.css | 1 - .../plugins/wordpress-seo/css/snippet-302.css | 9 + .../wordpress-seo/css/snippet-302.min.css | 1 + ...gin_tools.css => yst_plugin_tools-302.css} | 29 +- ...s.min.css => yst_plugin_tools-302.min.css} | 2 +- .../wordpress-seo/css/yst_seo_score-302.css | 45 + .../css/yst_seo_score-302.min.css | 1 + .../class-snippet-preview.php | 105 +- .../deprecated/class-yoast-textstatistics.php | 196 ++ .../frontend/class-breadcrumbs.php | 32 +- .../wordpress-seo/frontend/class-frontend.php | 64 +- .../frontend/class-googleplus.php | 34 +- .../wordpress-seo/frontend/class-json-ld.php | 9 +- .../frontend/class-opengraph.php | 70 +- .../wordpress-seo/frontend/class-twitter.php | 144 +- .../wordpress-seo/images/Yoast_SEO_Icon.svg | 45 + .../wordpress-seo/images/banner-local-seo.png | Bin 11625 -> 17293 bytes .../wordpress-seo/images/banner-news-seo.png | Bin 11862 -> 16945 bytes .../images/banner-premium-seo.png | Bin 12430 -> 17754 bytes .../images/banner-seo-training.png | Bin 0 -> 21289 bytes .../wordpress-seo/images/banner-video-seo.png | Bin 11587 -> 18241 bytes .../images/banner-website-review.png | Bin 41321 -> 125835 bytes .../images/banner-woocommerce-seo.png | Bin 11827 -> 18725 bytes .../plugins/wordpress-seo/images/editicon.png | Bin 0 -> 509 bytes .../wordpress-seo/inc/class-rewrite.php | 2 +- .../inc/class-sitemap-timezone.php | 5 +- .../wordpress-seo/inc/class-sitemaps.php | 37 +- .../wordpress-seo/inc/class-upgrade.php | 15 +- .../wordpress-seo/inc/class-wpseo-meta.php | 49 +- .../wordpress-seo/inc/class-wpseo-rank.php | 192 ++ .../inc/class-wpseo-replace-vars.php | 31 +- .../inc/class-wpseo-statistics.php | 166 +- .../wordpress-seo/inc/class-wpseo-utils.php | 192 +- .../inc/options/class-wpseo-option-wpseo.php | 1 + .../inc/options/class-wpseo-option.php | 36 +- .../inc/options/class-wpseo-taxonomy-meta.php | 176 +- .../wordpress-seo/inc/wpseo-functions.php | 52 +- .../inc/wpseo-non-ajax-functions.php | 145 +- .../js/dist/yoast-seo/yoast-seo-305.min.js | 6 + .../plugins/wordpress-seo/js/jquery.min.js | 2 - .../{wp-seo-admin.js => wp-seo-admin-306.js} | 160 +- .../wordpress-seo/js/wp-seo-admin-306.min.js | 1 + ...n-global.js => wp-seo-admin-global-302.js} | 4 +- ....min.js => wp-seo-admin-global-302.min.js} | 0 ...o-admin-gsc.js => wp-seo-admin-gsc-302.js} | 4 +- .../js/wp-seo-admin-gsc-302.min.js | 1 + .../wordpress-seo/js/wp-seo-admin-gsc.min.js | 1 - .../js/wp-seo-admin-media-302.js | 31 + .../js/wp-seo-admin-media-302.min.js | 1 + .../wordpress-seo/js/wp-seo-admin-media.js | 33 - .../js/wp-seo-admin-media.min.js | 1 - .../wordpress-seo/js/wp-seo-admin.min.js | 1 - .../wordpress-seo/js/wp-seo-bulk-editor.js | 10 +- ...{wp-seo-export.js => wp-seo-export-302.js} | 4 +- .../wordpress-seo/js/wp-seo-export-302.min.js | 1 + .../wordpress-seo/js/wp-seo-export.min.js | 1 - .../js/wp-seo-featured-image-302.js | 161 + .../js/wp-seo-featured-image-302.min.js | 1 + .../wordpress-seo/js/wp-seo-featured-image.js | 74 - .../js/wp-seo-featured-image.min.js | 1 - .../wordpress-seo/js/wp-seo-metabox-302.js | 323 ++ .../js/wp-seo-metabox-302.min.js | 1 + .../wordpress-seo/js/wp-seo-metabox.js | 680 ---- .../wordpress-seo/js/wp-seo-metabox.min.js | 1 - .../js/wp-seo-post-scraper-305.js | 530 +++ .../js/wp-seo-post-scraper-305.min.js | 1 + .../js/wp-seo-replacevar-plugin-302.js | 133 + .../js/wp-seo-replacevar-plugin-302.min.js | 1 + .../js/wp-seo-shortcode-plugin-305.js | 273 ++ .../js/wp-seo-shortcode-plugin-305.min.js | 1 + .../js/wp-seo-term-scraper-305.js | 410 +++ .../js/wp-seo-term-scraper-305.min.js | 1 + .../languages/wordpress-seo-ar.mo | Bin 57202 -> 0 bytes .../languages/wordpress-seo-bg_BG.json | 1 + .../languages/wordpress-seo-bg_BG.mo | Bin 146915 -> 149168 bytes .../languages/wordpress-seo-ca.json | 1 + .../languages/wordpress-seo-ca.mo | Bin 108880 -> 110396 bytes .../languages/wordpress-seo-cs_CZ.json | 1 + .../languages/wordpress-seo-cs_CZ.mo | Bin 56717 -> 45284 bytes .../languages/wordpress-seo-cy.json | 1 + .../languages/wordpress-seo-cy.mo | Bin 0 -> 55178 bytes .../languages/wordpress-seo-da_DK.json | 1 + .../languages/wordpress-seo-da_DK.mo | Bin 104426 -> 105881 bytes .../languages/wordpress-seo-de_DE.json | 1 + .../languages/wordpress-seo-de_DE.mo | Bin 63674 -> 51668 bytes .../languages/wordpress-seo-el.mo | Bin 48326 -> 0 bytes .../languages/wordpress-seo-en_AU.json | 1 + .../languages/wordpress-seo-en_AU.mo | Bin 100571 -> 101973 bytes .../languages/wordpress-seo-en_GB.json | 1 + .../languages/wordpress-seo-en_GB.mo | Bin 100896 -> 102243 bytes .../languages/wordpress-seo-es_ES.json | 1 + .../languages/wordpress-seo-es_ES.mo | Bin 109250 -> 95031 bytes .../languages/wordpress-seo-es_MX.json | 1 + .../languages/wordpress-seo-es_MX.mo | Bin 109053 -> 94934 bytes .../languages/wordpress-seo-eu.json | 1 + .../languages/wordpress-seo-eu.mo | Bin 37885 -> 40292 bytes .../languages/wordpress-seo-fa_IR.json | 1 + .../languages/wordpress-seo-fa_IR.mo | Bin 94846 -> 94926 bytes .../languages/wordpress-seo-fi.json | 1 + .../languages/wordpress-seo-fi.mo | Bin 78385 -> 73293 bytes .../languages/wordpress-seo-fr_FR.json | 1 + .../languages/wordpress-seo-fr_FR.mo | Bin 111565 -> 112950 bytes .../languages/wordpress-seo-he_IL.json | 1 + .../languages/wordpress-seo-he_IL.mo | Bin 98918 -> 84693 bytes .../languages/wordpress-seo-hr.mo | Bin 32071 -> 0 bytes .../languages/wordpress-seo-hu_HU.mo | Bin 38028 -> 0 bytes .../languages/wordpress-seo-id_ID.json | 1 + .../languages/wordpress-seo-id_ID.mo | Bin 73256 -> 65724 bytes .../languages/wordpress-seo-it_IT.json | 1 + .../languages/wordpress-seo-it_IT.mo | Bin 107505 -> 109001 bytes .../languages/wordpress-seo-ja.json | 1 + .../languages/wordpress-seo-ja.mo | Bin 102084 -> 94693 bytes .../languages/wordpress-seo-nb_NO.json | 1 + .../languages/wordpress-seo-nb_NO.mo | Bin 104405 -> 91857 bytes .../languages/wordpress-seo-nl_NL.json | 1 + .../languages/wordpress-seo-nl_NL.mo | Bin 105972 -> 107593 bytes .../languages/wordpress-seo-pl_PL.json | 1 + .../languages/wordpress-seo-pl_PL.mo | Bin 109164 -> 110373 bytes .../languages/wordpress-seo-pt_BR.json | 1 + .../languages/wordpress-seo-pt_BR.mo | Bin 95380 -> 82229 bytes .../languages/wordpress-seo-pt_PT.json | 1 + .../languages/wordpress-seo-pt_PT.mo | Bin 105632 -> 107437 bytes .../languages/wordpress-seo-ro_RO.mo | Bin 35301 -> 0 bytes .../languages/wordpress-seo-ru_RU.json | 1 + .../languages/wordpress-seo-ru_RU.mo | Bin 142697 -> 123777 bytes .../languages/wordpress-seo-sk_SK.json | 1 + .../languages/wordpress-seo-sk_SK.mo | Bin 86879 -> 73646 bytes .../languages/wordpress-seo-sv_SE.json | 1 + .../languages/wordpress-seo-sv_SE.mo | Bin 96878 -> 84270 bytes .../languages/wordpress-seo-tr_TR.json | 1 + .../languages/wordpress-seo-tr_TR.mo | Bin 106264 -> 108200 bytes .../languages/wordpress-seo-zh_CN.json | 1 + .../languages/wordpress-seo-zh_CN.mo | Bin 43705 -> 45135 bytes .../languages/wordpress-seo-zh_TW.json | 1 + .../languages/wordpress-seo-zh_TW.mo | Bin 55125 -> 44921 bytes .../wordpress-seo/languages/wordpress-seo.pot | 2827 +++++++++-------- .../plugins/wordpress-seo/readme.txt | 112 +- .../plugins/wordpress-seo/vendor/autoload.php | 2 +- .../wordpress-seo/vendor/autoload_52.php | 2 +- .../vendor/composer/ClassLoader.php | 6 +- .../vendor/composer/autoload_classmap.php | 39 +- .../vendor/composer/autoload_real.php | 11 +- .../vendor/composer/autoload_real_52.php | 6 +- .../vendor/composer/installed.json | 12 +- .../xrstf/composer-php52/.hg_archival.txt | 4 +- .../vendor/xrstf/composer-php52/.hgtags | 2 + .../xrstf/Composer52/AutoloadGenerator.php | 28 +- .../lib/xrstf/Composer52/Generator.php | 13 +- .../plugins/wordpress-seo/wp-seo-main.php | 33 +- .../plugins/wordpress-seo/wp-seo.php | 2 +- 260 files changed, 11614 insertions(+), 6693 deletions(-) create mode 100644 wp/wp-content/plugins/user-role-editor/includes/class-protect-admin.php create mode 100644 wp/wp-content/plugins/user-role-editor/includes/class-role-additional-options.php rename wp/wp-content/plugins/wordpress-seo/{codeclimate.yml => .codeclimate.yml} (82%) create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/ajax/class-recalculate-scores-ajax.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/ajax/class-shortcode-filter.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/ajax/class-yoast-dismissable-notice.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/ajax/class-yoast-onpage-ajax.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/class-import-wpseo.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/class-meta-columns.php delete mode 100644 wp/wp-content/plugins/wordpress-seo/admin/class-metabox.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/class-recalculate-scores.php rename wp/wp-content/plugins/wordpress-seo/admin/{class-opengraph-admin.php => class-social-admin.php} (64%) delete mode 100644 wp/wp-content/plugins/wordpress-seo/admin/class-taxonomy.php delete mode 100644 wp/wp-content/plugins/wordpress-seo/admin/class-yoast-textstatistics.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/import/class-import-aioseo-hooks.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/import/class-import-hooks.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/import/class-import-robots-meta-hooks.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/import/class-import-wpseo-hooks.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-add-keyword-tab.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-addon-section.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-form-tab.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-tab-section.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/metabox/interface-metabox-section.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/metabox/interface-metabox-tab.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-email-presenter.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-notifier.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-option.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-request.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy-content-fields.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy-fields-presenter.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy-fields.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy-metabox.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy-settings-fields.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy-social-fields.php create mode 100644 wp/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy.php create mode 100644 wp/wp-content/plugins/wordpress-seo/bower.json rename wp/wp-content/plugins/wordpress-seo/css/{adminbar.css => adminbar-302.css} (91%) create mode 100644 wp/wp-content/plugins/wordpress-seo/css/adminbar-302.min.css delete mode 100644 wp/wp-content/plugins/wordpress-seo/css/adminbar.min.css rename wp/wp-content/plugins/wordpress-seo/css/{dashboard.css => dashboard-305.css} (53%) create mode 100644 wp/wp-content/plugins/wordpress-seo/css/dashboard-305.min.css delete mode 100644 wp/wp-content/plugins/wordpress-seo/css/dashboard.min.css create mode 100644 wp/wp-content/plugins/wordpress-seo/css/dist/yoast-seo/editicon.png create mode 100644 wp/wp-content/plugins/wordpress-seo/css/dist/yoast-seo/yoast-seo-305.min.css rename wp/wp-content/plugins/wordpress-seo/css/{edit-page.css => edit-page-302.css} (91%) create mode 100644 wp/wp-content/plugins/wordpress-seo/css/edit-page-302.min.css delete mode 100644 wp/wp-content/plugins/wordpress-seo/css/edit-page.min.css rename wp/wp-content/plugins/wordpress-seo/css/{metabox-tabs.css => metabox-302.css} (60%) create mode 100644 wp/wp-content/plugins/wordpress-seo/css/metabox-302.min.css delete mode 100644 wp/wp-content/plugins/wordpress-seo/css/metabox-classic.css delete mode 100644 wp/wp-content/plugins/wordpress-seo/css/metabox-classic.min.css delete mode 100644 wp/wp-content/plugins/wordpress-seo/css/metabox-fresh.css delete mode 100644 wp/wp-content/plugins/wordpress-seo/css/metabox-fresh.min.css delete mode 100644 wp/wp-content/plugins/wordpress-seo/css/metabox-tabs.min.css create mode 100644 wp/wp-content/plugins/wordpress-seo/css/snippet-302.css create mode 100644 wp/wp-content/plugins/wordpress-seo/css/snippet-302.min.css rename wp/wp-content/plugins/wordpress-seo/css/{yst_plugin_tools.css => yst_plugin_tools-302.css} (92%) rename wp/wp-content/plugins/wordpress-seo/css/{yst_plugin_tools.min.css => yst_plugin_tools-302.min.css} (88%) create mode 100644 wp/wp-content/plugins/wordpress-seo/css/yst_seo_score-302.css create mode 100644 wp/wp-content/plugins/wordpress-seo/css/yst_seo_score-302.min.css rename wp/wp-content/plugins/wordpress-seo/{admin => deprecated}/class-snippet-preview.php (50%) create mode 100644 wp/wp-content/plugins/wordpress-seo/deprecated/class-yoast-textstatistics.php create mode 100644 wp/wp-content/plugins/wordpress-seo/images/Yoast_SEO_Icon.svg create mode 100644 wp/wp-content/plugins/wordpress-seo/images/banner-seo-training.png create mode 100644 wp/wp-content/plugins/wordpress-seo/images/editicon.png create mode 100644 wp/wp-content/plugins/wordpress-seo/inc/class-wpseo-rank.php create mode 100644 wp/wp-content/plugins/wordpress-seo/js/dist/yoast-seo/yoast-seo-305.min.js delete mode 100644 wp/wp-content/plugins/wordpress-seo/js/jquery.min.js rename wp/wp-content/plugins/wordpress-seo/js/{wp-seo-admin.js => wp-seo-admin-306.js} (64%) create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-admin-306.min.js rename wp/wp-content/plugins/wordpress-seo/js/{wp-seo-admin-global.js => wp-seo-admin-global-302.js} (96%) rename wp/wp-content/plugins/wordpress-seo/js/{wp-seo-admin-global.min.js => wp-seo-admin-global-302.min.js} (100%) rename wp/wp-content/plugins/wordpress-seo/js/{wp-seo-admin-gsc.js => wp-seo-admin-gsc-302.js} (94%) create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-admin-gsc-302.min.js delete mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-admin-gsc.min.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-admin-media-302.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-admin-media-302.min.js delete mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-admin-media.js delete mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-admin-media.min.js delete mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-admin.min.js rename wp/wp-content/plugins/wordpress-seo/js/{wp-seo-export.js => wp-seo-export-302.js} (89%) create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-export-302.min.js delete mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-export.min.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-featured-image-302.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-featured-image-302.min.js delete mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-featured-image.js delete mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-featured-image.min.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-metabox-302.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-metabox-302.min.js delete mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-metabox.js delete mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-metabox.min.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-post-scraper-305.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-post-scraper-305.min.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-replacevar-plugin-302.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-replacevar-plugin-302.min.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-shortcode-plugin-305.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-shortcode-plugin-305.min.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-term-scraper-305.js create mode 100644 wp/wp-content/plugins/wordpress-seo/js/wp-seo-term-scraper-305.min.js delete mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-ar.mo create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-bg_BG.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-ca.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-cs_CZ.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-cy.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-cy.mo create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-da_DK.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-de_DE.json delete mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-el.mo create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-en_AU.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-en_GB.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-es_ES.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-es_MX.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-eu.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-fa_IR.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-fi.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-fr_FR.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-he_IL.json delete mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-hr.mo delete mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-hu_HU.mo create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-id_ID.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-it_IT.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-ja.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-nb_NO.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-nl_NL.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-pl_PL.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-pt_BR.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-pt_PT.json delete mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-ro_RO.mo create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-ru_RU.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-sk_SK.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-sv_SE.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-tr_TR.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-zh_CN.json create mode 100644 wp/wp-content/plugins/wordpress-seo/languages/wordpress-seo-zh_TW.json diff --git a/wp/wp-content/plugins/user-role-editor/includes/class-advertisement.php b/wp/wp-content/plugins/user-role-editor/includes/class-advertisement.php index f2953925..ce2d1414 100644 --- a/wp/wp-content/plugins/user-role-editor/includes/class-advertisement.php +++ b/wp/wp-content/plugins/user-role-editor/includes/class-advertisement.php @@ -18,13 +18,7 @@ class ure_Advertisement { $index = $this->rand_unique( $used ); $this->slots[$index] = $this->admin_menu_editor(); $used[] = $index; - - if ( date('Y-m-d') < date('Y-m-d', strtotime('2015-11-03')) ) { - $index = $this->rand_unique( $used ); - $this->slots[$index] = $this->manage_wp(); - $used[] = $index; - } - + $index = $this->rand_unique( $used ); $this->slots[$index] = $this->wp_esignature(); $used[] = $index; @@ -65,23 +59,7 @@ class ure_Advertisement { return $output; } // end of admin_menu_editor() - - - // content of Manage WP advertisement slot - private function manage_wp() { - - $output = ' -
- - ManageWP - -
- '; - - return $output; - } - // end of manage_wp() - + // content of WP eSignature advertisement slot private function wp_esignature() { diff --git a/wp/wp-content/plugins/user-role-editor/includes/class-protect-admin.php b/wp/wp-content/plugins/user-role-editor/includes/class-protect-admin.php new file mode 100644 index 00000000..05a1f680 --- /dev/null +++ b/wp/wp-content/plugins/user-role-editor/includes/class-protect-admin.php @@ -0,0 +1,181 @@ +lib = $lib; + $this->user_to_check = array(); + + // Exclude administrator role from edit list. + add_filter('editable_roles', array($this, 'exclude_admin_role')); + // prohibit any actions with user who has Administrator role + add_filter('user_has_cap', array($this, 'not_edit_admin'), 10, 3); + // exclude users with 'Administrator' role from users list + add_action('pre_user_query', array($this, 'exclude_administrators')); + // do not show 'Administrator (s)' view above users list + add_filter('views_users', array($this, 'exclude_admins_view')); + } + // end of __construct() + + + /** + * exclude administrator role from the roles list + * + * @param string $roles + * @return array + */ + public function exclude_admin_role($roles) { + + if (isset($roles['administrator'])) { + unset($roles['administrator']); + } + + return $roles; + } + // end of exclude_admin_role() + + + /** + * Check if user has "Administrator" role assigned + * + * @global wpdb $wpdb + * @param int $user_id + * @return boolean returns true is user has Role "Administrator" + */ + private function has_administrator_role($user_id) { + global $wpdb; + + if (empty($user_id) || !is_numeric($user_id)) { + return false; + } + + $table_name = $this->lib->get_usermeta_table_name(); + $meta_key = $wpdb->prefix . 'capabilities'; + $query = "SELECT count(*) + FROM $table_name + WHERE user_id=$user_id AND meta_key='$meta_key' AND meta_value like '%administrator%'"; + $has_admin_role = $wpdb->get_var($query); + if ($has_admin_role > 0) { + $result = true; + } else { + $result = false; + } + // cache checking result for the future use + $this->user_to_check[$user_id] = $result; + + return $result; + } + + // end of has_administrator_role() + + + /** + * We have two vulnerable queries with user id at admin interface, which should be processed + * 1st: http://blogdomain.com/wp-admin/user-edit.php?user_id=ID&wp_http_referer=%2Fwp-admin%2Fusers.php + * 2nd: http://blogdomain.com/wp-admin/users.php?action=delete&user=ID&_wpnonce=ab34225a78 + * If put Administrator user ID into such request, user with lower capabilities (if he has 'edit_users') + * can edit, delete admin record + * This function removes 'edit_users' capability from current user capabilities + * if request has admin user ID in it + * + * @param array $allcaps + * @param type $caps + * @param string $name + * @return array + */ + public function not_edit_admin($allcaps, $caps, $name) { + + $user_keys = array('user_id', 'user'); + foreach ($user_keys as $user_key) { + $access_deny = false; + $user_id = $this->lib->get_request_var($user_key, 'get'); + if (empty($user_id)) { + break; + } + if ($user_id == 1) { // built-in WordPress Admin + $access_deny = true; + } else { + if (!isset($this->user_to_check[$user_id])) { + // check if user_id has Administrator role + $access_deny = $this->has_administrator_role($user_id); + } else { + // user_id was checked already, get result from cash + $access_deny = $this->user_to_check[$user_id]; + } + } + if ($access_deny) { + unset($allcaps['edit_users']); + } + break; + } + + return $allcaps; + } + // end of not_edit_admin() + + + /** + * add where criteria to exclude users with 'Administrator' role from users list + * + * @global wpdb $wpdb + * @param type $user_query + */ + public function exclude_administrators($user_query) { + + global $wpdb; + + $result = false; + $links_to_block = array('profile.php', 'users.php'); + foreach ($links_to_block as $key => $value) { + $result = stripos($_SERVER['REQUEST_URI'], $value); + if ($result !== false) { + break; + } + } + + if ($result === false) { // block the user edit stuff only + return; + } + + // get user_id of users with 'Administrator' role + $tableName = $this->lib->get_usermeta_table_name(); + $meta_key = $wpdb->prefix . 'capabilities'; + $admin_role_key = '%"administrator"%'; + $query = "select user_id + from $tableName + where meta_key='$meta_key' and meta_value like '$admin_role_key'"; + $ids_arr = $wpdb->get_col($query); + if (is_array($ids_arr) && count($ids_arr) > 0) { + $ids = implode(',', $ids_arr); + $user_query->query_where .= " AND ( $wpdb->users.ID NOT IN ( $ids ) )"; + } + } + // end of exclude_administrators() + + + /* + * Exclude view of users with Administrator role + * + */ + public function exclude_admins_view($views) { + + unset($views['administrator']); + + return $views; + } + // end of exclude_admins_view() + +} +// end of URE_Protect_Admin class diff --git a/wp/wp-content/plugins/user-role-editor/includes/class-role-additional-options.php b/wp/wp-content/plugins/user-role-editor/includes/class-role-additional-options.php new file mode 100644 index 00000000..320952e0 --- /dev/null +++ b/wp/wp-content/plugins/user-role-editor/includes/class-role-additional-options.php @@ -0,0 +1,134 @@ +lib = $lib; + $this->init(); + } + // end of __construct() + + + public static function get_instance($lib) { + + if (self::$instance===null) { + self::$instance = new URE_Role_Additional_Options($lib); + } + + return self::$instance; + } + // end of get_instance() + + + public static function create_item($id, $label, $hook, $routine) { + $item = new stdClass(); + $item->id = $id; + $item->label = $label; + $item->hook = $hook; + $item->routine = $routine; + + return $item; + } + // end of create_item() + + + public static function get_active_items() { + + $items = get_option(self::STORAGE_ID, array()); + + return $items; + } + + + private function init() { + + $this->items = array(); + $item = self::create_item('hide_admin_bar', esc_html__('Hide admin bar', 'user-role-editor'), 'init', 'ure_hide_admin_bar'); + $this->items[$item->id] = $item; + + // Allow other developers to modify the list of role's additonal options + $this->items = apply_filters('ure_role_additional_options', $this->items); + + $this->active_items = self::get_active_items(); + } + // end of init() + + + public function set_active_items_hooks() { + global $current_user; + + if (current_user_can('ure_edit_roles')) { + return; + } + + foreach($current_user->roles as $role) { + if (!isset($this->active_items[$role])) { + continue; + } + foreach(array_keys($this->active_items[$role]) as $item_id) { + add_action($this->items[$item_id]->hook, $this->items[$item_id]->routine); + } + } + + } + // end of set_active_items_hooks() + + + public function save($current_role) { + $this->active_items = self::get_active_items(); + $this->active_items[$current_role] = array(); + foreach($this->items as $item) { + if (isset($_POST[$item->id])) { + $this->active_items[$current_role][$item->id] = 1; + } + } + update_option(self::STORAGE_ID, $this->active_items); + + } + // end of save() + + + public function show($current_role) { + +?> + +
+ : + + + + + +
+ +items as $item) { + $checked = (isset($this->active_items[$current_role]) && + isset($this->active_items[$current_role][$item->id])) ? 'checked="checked"' : ''; + if (!$first_time) { +?> +
+ + > + + +
+ - +multisite && !is_network_admin()) { +?>
role_default_html; ?>
- +
@@ -571,7 +576,7 @@ class Ure_Lib extends Garvs_WP_Lib { $this->notification = $this->init_current_role_name(); } $this->prepare_capabilities_to_save(); - $this->notification = $this->permissions_object_update($this->notification); + $this->notification = $this->permissions_object_update($this->notification); } else { do_action('ure_process_user_request'); } // if ($action @@ -637,7 +642,10 @@ class Ure_Lib extends Garvs_WP_Lib { } $this->init_full_capabilities(); - + if (empty($this->role_additional_options)) { + $this->role_additional_options = URE_Role_Additional_Options::get_instance($this); + } + if (!$this->is_pro()) { require_once(URE_PLUGIN_DIR . 'includes/class-advertisement.php'); } @@ -1337,10 +1345,14 @@ class Ure_Lib extends Garvs_WP_Lib { multisite && !is_network_admin()) { // Show for single site for WP multisite only ?>

+
roles); + // save additional options for the current role + if (empty($this->role_additional_options)) { + $this->role_additional_options = URE_Role_Additional_Options::get_instance($this); + } + $this->role_additional_options->save($this->current_role); + return true; } // end of save_roles() @@ -2170,6 +2188,9 @@ class Ure_Lib extends Garvs_WP_Lib { protected function change_default_role() { global $wp_roles; + if (!$this->multisite || is_network_admin()) { + return 'Try to misuse the plugin functionality'; + } $mess = ''; if (!isset($wp_roles)) { $wp_roles = new WP_Roles(); @@ -2567,7 +2588,12 @@ class Ure_Lib extends Garvs_WP_Lib { // end of show_admin_role() - private function role_default_prepare_html($select_width=200) { + public function role_default_prepare_html($select_width=200) { + + if (!isset($this->roles) || !$this->roles) { + // get roles data from database + $this->roles = $this->get_user_roles(); + } $caps_access_restrict_for_simple_admin = $this->get_option('caps_access_restrict_for_simple_admin', 0); $show_admin_role = $this->show_admin_role_allowed(); @@ -2639,7 +2665,9 @@ class Ure_Lib extends Garvs_WP_Lib { public function role_edit_prepare_html($select_width=200) { $this->role_select_copy_prepare_html($select_width); - $this->role_default_prepare_html($select_width); + if ($this->multisite && !is_network_admin()) { + $this->role_default_prepare_html($select_width); + } $this->role_delete_prepare_html(); $this->caps_to_remove_prepare_html(); } diff --git a/wp/wp-content/plugins/user-role-editor/includes/class-user-role-editor.php b/wp/wp-content/plugins/user-role-editor/includes/class-user-role-editor.php index ef039c10..d86f26a4 100644 --- a/wp/wp-content/plugins/user-role-editor/includes/class-user-role-editor.php +++ b/wp/wp-content/plugins/user-role-editor/includes/class-user-role-editor.php @@ -6,7 +6,7 @@ * Author URI: https://www.role-editor.com * License: GPL v2+ * -*/ + */ class User_Role_Editor { // plugin specific library object: common code stuff, including options data processor @@ -52,6 +52,9 @@ class User_Role_Editor { add_action( 'wpmu_new_blog', array($this, 'duplicate_roles_for_new_blog'), 10, 2); } + // setup additional options hooks for the roles + add_action('init', array($this, 'set_role_additional_options_hooks'), 9); + if (!is_admin()) { return; } @@ -73,7 +76,7 @@ class User_Role_Editor { // add a Settings link in the installed plugins page add_filter('plugin_action_links_'. URE_PLUGIN_BASE_NAME, array($this, 'plugin_action_links'), 10, 1); add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2); - + } // end of __construct() @@ -89,65 +92,57 @@ class User_Role_Editor { // end of is_pro() - /** - * Plugin initialization - * - */ - public function plugin_init() { + /** + * Plugin initialization + * + */ + public function plugin_init() { - global $current_user, $pagenow; + global $current_user, $pagenow; - if (!empty($current_user->ID)) { - $user_id = $current_user->ID; - } else { - $user_id = 0; - } + if (!empty($current_user->ID)) { + $user_id = $current_user->ID; + } else { + $user_id = 0; + } - $supress_protection = apply_filters('ure_supress_administrators_protection', false); - // these filters and actions should prevent editing users with administrator role - // by other users with 'edit_users' capability - if (!$supress_protection && !$this->lib->user_is_admin($user_id)) { - // Exclude administrator role from edit list. - add_filter('editable_roles', array($this, 'exclude_admin_role' ) ); - // prohibit any actions with user who has Administrator role - add_filter('user_has_cap', array($this, 'not_edit_admin' ), 10, 3); - // exclude users with 'Administrator' role from users list - add_action('pre_user_query', array($this, 'exclude_administrators' ) ); - // do not show 'Administrator (s)' view above users list - add_filter('views_users', array($this, 'exclude_admins_view' ) ); - } - - add_action( 'admin_enqueue_scripts', array($this, 'admin_load_js' ) ); - add_action( 'user_row_actions', array($this, 'user_row'), 10, 2 ); - add_filter( 'all_plugins', array($this, 'exclude_from_plugins_list' ) ); - - if ($this->lib->multisite) { - $allow_edit_users_to_not_super_admin = $this->lib->get_option('allow_edit_users_to_not_super_admin', 0); - if ($allow_edit_users_to_not_super_admin) { - add_filter( 'map_meta_cap', array($this, 'restore_users_edit_caps'), 1, 4 ); - remove_all_filters( 'enable_edit_any_user_configuration' ); - add_filter( 'enable_edit_any_user_configuration', '__return_true'); - add_filter( 'admin_head', array($this, 'edit_user_permission_check'), 1, 4 ); - if ($pagenow=='user-new.php') { - add_filter( 'site_option_site_admins', array($this, 'allow_add_user_as_superadmin') ); + $supress_protection = apply_filters('ure_supress_administrators_protection', false); + // these filters and actions should prevent editing users with administrator role + // by other users with 'edit_users' capability + if (!$supress_protection && !$this->lib->user_is_admin($user_id)) { + new URE_Protect_Admin($this->lib); + } + + add_action('admin_enqueue_scripts', array($this, 'admin_load_js')); + add_action('user_row_actions', array($this, 'user_row'), 10, 2); + add_filter('all_plugins', array($this, 'exclude_from_plugins_list')); + + if ($this->lib->multisite) { + $allow_edit_users_to_not_super_admin = $this->lib->get_option('allow_edit_users_to_not_super_admin', 0); + if ($allow_edit_users_to_not_super_admin) { + add_filter('map_meta_cap', array($this, 'restore_users_edit_caps'), 1, 4); + remove_all_filters('enable_edit_any_user_configuration'); + add_filter('enable_edit_any_user_configuration', '__return_true'); + add_filter('admin_head', array($this, 'edit_user_permission_check'), 1, 4); + if ($pagenow == 'user-new.php') { + add_filter('site_option_site_admins', array($this, 'allow_add_user_as_superadmin')); + } + } + } else { + $count_users_without_role = $this->lib->get_option('count_users_without_role', 0); + if ($count_users_without_role) { + add_action('restrict_manage_users', array($this, 'move_users_from_no_role_button')); + add_action('admin_init', array($this, 'add_css_to_users_page')); + add_action('admin_footer', array($this, 'add_js_to_users_page')); } } - } else { - $count_users_without_role = $this->lib->get_option('count_users_without_role', 0); - if ($count_users_without_role) { - add_action( 'restrict_manage_users', array($this, 'move_users_from_no_role_button') ); - add_action( 'admin_init', array($this, 'add_css_to_users_page')); - add_action( 'admin_footer', array($this, 'add_js_to_users_page') ); - } - } - - add_action('wp_ajax_ure_ajax', array($this, 'ure_ajax')); - } - // end of plugin_init() - - - /** + add_action('wp_ajax_ure_ajax', array($this, 'ure_ajax')); + } + // end of plugin_init() + + + /** * Allow non-superadmin user to add/create users to the site as superadmin does. * Include current user to the list of superadmins - for the user-new.php page only, and * if user really can create_users and promote_users @@ -306,120 +301,6 @@ class User_Role_Editor { } // end of edit_user_permission_check() - - /** - * exclude administrator role from the roles list - * - * @param string $roles - * @return array - */ - public function exclude_admin_role($roles) - { - - if (isset($roles['administrator'])) { - unset($roles['administrator']); - } - - return $roles; - } - // end of exclude_admin_role() - - - /** - * We have two vulnerable queries with user id at admin interface, which should be processed - * 1st: http://blogdomain.com/wp-admin/user-edit.php?user_id=ID&wp_http_referer=%2Fwp-admin%2Fusers.php - * 2nd: http://blogdomain.com/wp-admin/users.php?action=delete&user=ID&_wpnonce=ab34225a78 - * If put Administrator user ID into such request, user with lower capabilities (if he has 'edit_users') - * can edit, delete admin record - * This function removes 'edit_users' capability from current user capabilities - * if request has admin user ID in it - * - * @param array $allcaps - * @param type $caps - * @param string $name - * @return array - */ - public function not_edit_admin($allcaps, $caps, $name) { - - $user_keys = array('user_id', 'user'); - foreach ($user_keys as $user_key) { - $access_deny = false; - $user_id = $this->lib->get_request_var($user_key, 'get'); - if (!empty($user_id)) { - if ($user_id == 1) { // built-in WordPress Admin - $access_deny = true; - } else { - if (!isset($this->lib->user_to_check[$user_id])) { - // check if user_id has Administrator role - $access_deny = $this->lib->has_administrator_role($user_id); - } else { - // user_id was checked already, get result from cash - $access_deny = $this->lib->user_to_check[$user_id]; - } - } - if ($access_deny) { - unset($allcaps['edit_users']); - } - break; - } - } - - return $allcaps; - } - // end of not_edit_admin() - - - /** - * add where criteria to exclude users with 'Administrator' role from users list - * - * @global wpdb $wpdb - * @param type $user_query - */ - public function exclude_administrators($user_query) { - - global $wpdb; - - $result = false; - $links_to_block = array('profile.php', 'users.php'); - foreach ($links_to_block as $key => $value) { - $result = stripos($_SERVER['REQUEST_URI'], $value); - if ($result !== false) { - break; - } - } - - if ($result === false) { // block the user edit stuff only - return; - } - - // get user_id of users with 'Administrator' role - $tableName = (!$this->lib->multisite && defined('CUSTOM_USER_META_TABLE')) ? CUSTOM_USER_META_TABLE : $wpdb->usermeta; - $meta_key = $wpdb->prefix . 'capabilities'; - $admin_role_key = '%"administrator"%'; - $query = "select user_id - from $tableName - where meta_key='$meta_key' and meta_value like '$admin_role_key'"; - $ids_arr = $wpdb->get_col($query); - if (is_array($ids_arr) && count($ids_arr) > 0) { - $ids = implode(',', $ids_arr); - $user_query->query_where .= " AND ( $wpdb->users.ID NOT IN ( $ids ) )"; - } - } - // end of exclude_administrators() - - - /* - * Exclude view of users with Administrator role - * - */ - public function exclude_admins_view($views) { - - unset($views['administrator']); - - return $views; - } - // end of exclude_admins_view() - /** * Add/hide edit actions for every user row at the users list @@ -792,8 +673,8 @@ class User_Role_Editor { } $this->lib->get_default_role(); - $this->lib->editor_init1(); - $this->lib->role_edit_prepare_html(0); + //$this->lib->editor_init1(); + $this->lib->role_default_prepare_html(0); $ure_tab_idx = $this->lib->get_request_var('ure_tab_idx', 'int'); @@ -929,6 +810,15 @@ class User_Role_Editor { } // end of ure_ajax() + + + public function set_role_additional_options_hooks() { + + $role_additional_options = URE_Role_Additional_Options::get_instance($this->lib); + $role_additional_options->set_active_items_hooks(); + + } + // end of set_role_additional_options_hooks() // execute on plugin deactivation diff --git a/wp/wp-content/plugins/user-role-editor/includes/misc-support-stuff.php b/wp/wp-content/plugins/user-role-editor/includes/misc-support-stuff.php index 055633c9..980390b0 100644 --- a/wp/wp-content/plugins/user-role-editor/includes/misc-support-stuff.php +++ b/wp/wp-content/plugins/user-role-editor/includes/misc-support-stuff.php @@ -41,4 +41,14 @@ if (!function_exists('ure_get_post_view_access_users')) { } // end of ure_get_post_view_users() -} // if (!function_exists('ure_get_post_view_users')) +} + + +if (!function_exists('ure_hide_admin_bar')) { + function ure_hide_admin_bar() { + + show_admin_bar(false); + + } + // end of hide_admin_bar() +} \ No newline at end of file diff --git a/wp/wp-content/plugins/user-role-editor/includes/ure-role-edit.php b/wp/wp-content/plugins/user-role-editor/includes/ure-role-edit.php index 701814cf..0be4ce4f 100644 --- a/wp/wp-content/plugins/user-role-editor/includes/ure-role-edit.php +++ b/wp/wp-content/plugins/user-role-editor/includes/ure-role-edit.php @@ -14,7 +14,7 @@ if (!defined('URE_PLUGIN_URL')) {
-

role_select_html; ?>

+

  role_select_html; ?>

caps_readable) { @@ -92,9 +92,11 @@ if ($this->multisite && $this->active_for_network && !is_network_admin() && is_m 0) + + $this->role_additional_options->show($this->current_role); + ?> - - + display_box_end(); ?> diff --git a/wp/wp-content/plugins/user-role-editor/readme.txt b/wp/wp-content/plugins/user-role-editor/readme.txt index dcf27700..b898651a 100644 --- a/wp/wp-content/plugins/user-role-editor/readme.txt +++ b/wp/wp-content/plugins/user-role-editor/readme.txt @@ -3,8 +3,8 @@ Contributors: shinephp Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=vladimir%40shinephp%2ecom&lc=RU&item_name=ShinePHP%2ecom&item_number=User%20Role%20Editor%20WordPress%20plugin¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted Tags: user, role, editor, security, access, permission, capability Requires at least: 4.0 -Tested up to: 4.3.1 -Stable tag: 4.19.3 +Tested up to: 4.4 +Stable tag: 4.20.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -76,6 +76,13 @@ If you wish to check available translations or help with translation visit this https://translate.wordpress.org/projects/wp-plugins/user-role-editor/ == Changelog == += [4.20.1] 15.11.2015 = +* Fix: "Primary default role" drop-down menu was not shown at "Settings - User Role Editor - Default Roles" tab for WordPress single site installation. + += [4.20] 15.11.2015 = +* "Additional options" section was added to the user role editor page. Currently it contains the only "Hide admin bar". The list of options may be customized/extended by developers via "ure_role_additonal_options" filter. +* "Default Role" button is hidden to not duplicate functionality. Use "Settings - User Role Editor - Default Roles" tab instead. This button is available only for the single sites of WP multisite now. +* Code restructure, optimization: administrator protection parts extracted to the separate class. = [4.19.3] 14.10.2015 = * Fix: minor CSS change. diff --git a/wp/wp-content/plugins/user-role-editor/uninstall.php b/wp/wp-content/plugins/user-role-editor/uninstall.php index 4f15c458..ea565334 100644 --- a/wp/wp-content/plugins/user-role-editor/uninstall.php +++ b/wp/wp-content/plugins/user-role-editor/uninstall.php @@ -19,6 +19,7 @@ if (!is_multisite()) { delete_option('ure_show_deprecated_caps'); delete_option('ure_hide_pro_banner'); delete_option('user_role_editor'); + delete_option('ure_role_additional_options_values'); } else { $old_blog = $wpdb->blogid; // Get all blog ids @@ -31,6 +32,7 @@ if (!is_multisite()) { delete_option('ure_show_deprecated_caps'); delete_option('ure_hide_pro_banner'); delete_option('user_role_editor'); + delete_option('ure_role_additional_options_values'); } switch_to_blog($old_blog); } diff --git a/wp/wp-content/plugins/user-role-editor/user-role-editor.php b/wp/wp-content/plugins/user-role-editor/user-role-editor.php index ae11cee9..96149cf9 100644 --- a/wp/wp-content/plugins/user-role-editor/user-role-editor.php +++ b/wp/wp-content/plugins/user-role-editor/user-role-editor.php @@ -3,7 +3,7 @@ Plugin Name: User Role Editor Plugin URI: https://www.role-editor.com Description: Change/add/delete WordPress user roles and capabilities. -Version: 4.19.3 +Version: 4.20.1 Author: Vladimir Garagulya Author URI: https://www.role-editor.com Text Domain: ure @@ -23,7 +23,7 @@ if (defined('URE_PLUGIN_URL')) { wp_die('It seems that other version of User Role Editor is active. Please deactivate it before use this version'); } -define('URE_VERSION', '4.19.3'); +define('URE_VERSION', '4.20.1'); define('URE_PLUGIN_URL', plugin_dir_url(__FILE__)); define('URE_PLUGIN_DIR', plugin_dir_path(__FILE__)); define('URE_PLUGIN_BASE_NAME', plugin_basename(__FILE__)); @@ -49,8 +49,10 @@ Ure_Lib::check_version(get_bloginfo('version'), $ure_required_wp_version, $exit_ require_once(URE_PLUGIN_DIR .'includes/define-constants.php'); require_once(URE_PLUGIN_DIR .'includes/misc-support-stuff.php'); +require_once(URE_PLUGIN_DIR .'includes/class-role-additional-options.php'); require_once(URE_PLUGIN_DIR .'includes/class-assign-role.php'); require_once(URE_PLUGIN_DIR .'includes/class-user-other-roles.php'); +require_once(URE_PLUGIN_DIR .'includes/class-protect-admin.php'); require_once(URE_PLUGIN_DIR .'includes/class-ajax-processor.php'); require_once(URE_PLUGIN_DIR .'includes/class-ure-screen-help.php'); require_once(URE_PLUGIN_DIR .'includes/class-known-js-css-compatibility-issues.php'); diff --git a/wp/wp-content/plugins/wordpress-seo/codeclimate.yml b/wp/wp-content/plugins/wordpress-seo/.codeclimate.yml similarity index 82% rename from wp/wp-content/plugins/wordpress-seo/codeclimate.yml rename to wp/wp-content/plugins/wordpress-seo/.codeclimate.yml index 2fbbe938..a48b566a 100644 --- a/wp/wp-content/plugins/wordpress-seo/codeclimate.yml +++ b/wp/wp-content/plugins/wordpress-seo/.codeclimate.yml @@ -6,4 +6,5 @@ exclude_paths: - "tests/*" - "grunt/*" - "grunt/**/*" -- "js/jquery.qtip*" \ No newline at end of file +- "js/jquery.qtip*" +- "js/dist/**/*" \ No newline at end of file diff --git a/wp/wp-content/plugins/wordpress-seo/README.md b/wp/wp-content/plugins/wordpress-seo/README.md index 942b616d..2e81557e 100644 --- a/wp/wp-content/plugins/wordpress-seo/README.md +++ b/wp/wp-content/plugins/wordpress-seo/README.md @@ -54,3 +54,4 @@ There are various ways you can contribute: * Send us a Pull Request with your bug fixes and/or new features. * [Translate Yoast SEO into different languages](http://translate.yoast.com/projects/wordpress-seo/). * Provide feedback and [suggestions on enhancements](https://github.com/yoast/wordpress-seo/issues?direction=desc&labels=Enhancement&page=1&sort=created&state=open). + diff --git a/wp/wp-content/plugins/wordpress-seo/admin/ajax.php b/wp/wp-content/plugins/wordpress-seo/admin/ajax.php index 6b354a63..09255f13 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/ajax.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/ajax.php @@ -14,12 +14,12 @@ if ( ! defined( 'WPSEO_VERSION' ) ) { */ /** - * Convenience function to JSON encode and echo resuls and then die + * Convenience function to JSON encode and echo results and then die * - * @param array $results + * @param array $results Results array for encoding. */ function wpseo_ajax_json_echo_die( $results ) { - echo json_encode( $results ); + echo WPSEO_Utils::json_encode( $results ); die(); } @@ -141,6 +141,9 @@ function wpseo_ajax_replace_vars() { check_ajax_referer( 'wpseo-replace-vars' ); $post = get_post( intval( filter_input( INPUT_POST, 'post_id' ) ) ); + global $wp_query; + $wp_query->queried_object = $post; + $wp_query->queried_object_id = $post->ID; $omit = array( 'excerpt', 'excerpt_only', 'title' ); echo wpseo_replace_vars( stripslashes( filter_input( INPUT_POST, 'string' ) ), $post, $omit ); die; @@ -169,7 +172,7 @@ add_action( 'wp_ajax_wpseo_save_metadesc', 'wpseo_save_description' ); /** * Save titles & descriptions * - * @param string $what + * @param string $what Type of item to save (title, description). */ function wpseo_save_what( $what ) { check_ajax_referer( 'wpseo-bulk-editor' ); @@ -187,11 +190,11 @@ function wpseo_save_what( $what ) { * Helper function to update a post's meta data, returning relevant information * about the information updated and the results or the meta update. * - * @param int $post_id - * @param string $new_meta_value - * @param string $orig_meta_value - * @param string $meta_key - * @param string $return_key + * @param int $post_id Post ID. + * @param string $new_meta_value New meta value to record. + * @param string $orig_meta_value Original meta value. + * @param string $meta_key Meta key string. + * @param string $return_key Return key string to use in results. * * @return string */ @@ -279,7 +282,7 @@ add_action( 'wp_ajax_wpseo_save_all_descriptions', 'wpseo_save_all_descriptions' /** * Utility function to save values * - * @param string $what + * @param string $what Type of item so save. */ function wpseo_save_all( $what ) { check_ajax_referer( 'wpseo-bulk-editor' ); @@ -302,10 +305,10 @@ function wpseo_save_all( $what ) { /** * Insert a new value * - * @param string $what - * @param int $post_id - * @param string $new - * @param string $original + * @param string $what Item type (such as title). + * @param int $post_id Post ID. + * @param string $new New value to record. + * @param string $original Original value. * * @return string */ @@ -345,4 +348,46 @@ function wpseo_add_fb_admin() { add_action( 'wp_ajax_wpseo_add_fb_admin', 'wpseo_add_fb_admin' ); +/** + * Retrieves the keyword for the keyword doubles. + */ +function ajax_get_keyword_usage() { + $post_id = filter_input( INPUT_POST, 'post_id' ); + $keyword = filter_input( INPUT_POST, 'keyword' ); + + wp_die( + WPSEO_Utils::json_encode( WPSEO_Meta::keyword_usage( $keyword, $post_id ) ) + ); +} + +add_action( 'wp_ajax_get_focus_keyword_usage', 'ajax_get_keyword_usage' ); + +/** + * Retrieves the keyword for the keyword doubles of the termpages. + */ +function ajax_get_term_keyword_usage() { + $post_id = filter_input( INPUT_POST, 'post_id' ); + $keyword = filter_input( INPUT_POST, 'keyword' ); + $taxonomy = filter_input( INPUT_POST, 'taxonomy' ); + + wp_die( + WPSEO_Utils::json_encode( WPSEO_Taxonomy_Meta::get_keyword_usage( $keyword, $post_id, $taxonomy ) ) + ); +} + +add_action( 'wp_ajax_get_term_keyword_usage', 'ajax_get_term_keyword_usage' ); + +// Crawl Issue Manager AJAX hooks. +new WPSEO_GSC_Ajax; + +// SEO Score Recalculations. +new WPSEO_Recalculate_Scores_Ajax; + new Yoast_Dashboard_Widget(); + +new Yoast_OnPage_Ajax(); + +new WPSEO_Shortcode_Filter(); + +// Setting the notice for the recalculate the posts. +new Yoast_Dismissable_Notice_Ajax( 'recalculate', Yoast_Dismissable_Notice_Ajax::FOR_SITE ); diff --git a/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-recalculate-scores-ajax.php b/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-recalculate-scores-ajax.php new file mode 100644 index 00000000..d5571995 --- /dev/null +++ b/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-recalculate-scores-ajax.php @@ -0,0 +1,192 @@ + 'any', + 'meta_key' => '_yoast_wpseo_focuskw', + ); + + /** + * @var array The options stored in the database + */ + private $options; + + /** + * Initialize the AJAX hooks + */ + public function __construct() { + add_action( 'wp_ajax_wpseo_recalculate_scores', array( $this, 'recalculate_scores' ) ); + add_action( 'wp_ajax_wpseo_update_score', array( $this, 'save_score' ) ); + } + + /** + * Start recalculation + */ + public function recalculate_scores() { + check_ajax_referer( 'wpseo_recalculate', 'nonce' ); + wp_die( + $this->get_posts( filter_input( INPUT_POST, 'paged', FILTER_VALIDATE_INT ) ) + ); + } + + /** + * Saving the new linkdex score for given post + */ + public function save_score() { + check_ajax_referer( 'wpseo_recalculate', 'nonce' ); + + $scores = filter_input( INPUT_POST, 'scores', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + foreach ( $scores as $score ) { + WPSEO_Meta::set_value( 'linkdex', $score['score'], $score['post_id'] ); + } + wp_die(); + } + + /** + * Getting the posts from the database by doing a WP_Query. + * + * @param integer $paged The page. + * + * @return string + */ + private function get_posts( $paged ) { + $post_query = new WP_Query( + array_merge( + $this->query_fields, + array( + 'posts_per_page' => $this->posts_per_page, + 'paged' => $paged, + 'posts' => array(), + ) + ) + ); + + if ( $posts = $post_query->get_posts() ) { + $this->options = WPSEO_Options::get_all(); + + $parsed_posts = $this->parse_posts( $posts ); + + $response = array( + 'posts' => $parsed_posts, + 'total_posts' => count( $parsed_posts ), + 'next_page' => ( $paged + 1 ), + ); + + return json_encode( $response ); + } + + return ''; + } + + /** + * Parsing the posts with the value we need + * + * @param array $posts The posts to parse. + * + * @return array + */ + private function parse_posts( array $posts ) { + $parsed_posts = array(); + foreach ( $posts as $post ) { + $parsed_posts[] = $this->post_to_response( $post ); + } + + return $parsed_posts; + } + + /** + * @param WP_Post $post The post for which to build the analyzer data. + * + * @return array + */ + private function post_to_response( WP_Post $post ) { + $focus_keyword = WPSEO_Meta::get_value( 'focuskw', $post->ID ); + + return array( + 'post_id' => $post->ID, + 'text' => $post->post_content, + 'keyword' => $focus_keyword, + 'url' => urldecode( $post->post_name ), + 'pageTitle' => apply_filters( 'wpseo_title', wpseo_replace_vars( $this->get_title( $post->ID, $post->post_type ), $post ) ), + 'meta' => apply_filters( 'wpseo_metadesc', wpseo_replace_vars( $this->get_meta_description( $post->ID, $post->post_type ), $post ) ), + 'keyword_usage' => array( + $focus_keyword => WPSEO_Meta::keyword_usage( $focus_keyword, $post->ID ), + ), + ); + } + + /** + * Getting the title for given post + * + * @param integer $post_id The ID of the post for which to get the title. + * @param string $post_type The post type. + * + * @return mixed|string + */ + private function get_title( $post_id, $post_type ) { + if ( ( $title = WPSEO_Meta::get_value( 'title', $post_id ) ) !== '' ) { + return $title; + } + + if ( $default_from_options = $this->default_from_options( 'title', $post_type ) ) { + return str_replace( ' %%page%% ', ' ', $default_from_options ); + } + + return '%%title%%'; + } + + /** + * Getting the meta description for given post + * + * @param integer $post_id The ID of the post for which to get the meta description. + * @param string $post_type The post type. + * + * @return bool|string + */ + private function get_meta_description( $post_id, $post_type ) { + if ( ( $meta_description = WPSEO_Meta::get_value( 'metadesc', $post_id ) ) !== '' ) { + return $meta_description; + } + + if ( $default_from_options = $this->default_from_options( 'metadesc', $post_type ) ) { + return $default_from_options; + } + + return ''; + } + + /** + * Getting default from the options for given field + * + * @param string $field The field for which to get the default options. + * @param string $post_type The post type. + * + * @return bool|string + */ + private function default_from_options( $field, $post_type ) { + $target_option_field = $field . '-' . $post_type; + if ( ! empty( $this->options[ $target_option_field ] ) ) { + return $this->options[ $target_option_field ]; + } + + return false; + } + +} diff --git a/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-shortcode-filter.php b/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-shortcode-filter.php new file mode 100644 index 00000000..834001fa --- /dev/null +++ b/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-shortcode-filter.php @@ -0,0 +1,39 @@ + $shortcode, + 'output' => do_shortcode( $shortcode ), + ); + } + + wp_die( wp_json_encode( $parsed_shortcodes ) ); + } +} diff --git a/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-yoast-dismissable-notice.php b/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-yoast-dismissable-notice.php new file mode 100644 index 00000000..fb688c5f --- /dev/null +++ b/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-yoast-dismissable-notice.php @@ -0,0 +1,69 @@ +notice_name = $notice_name; + $this->notice_type = $notice_type; + + add_action( 'wp_ajax_wpseo_dismiss_' . $notice_name, array( $this, 'dismiss_notice' ) ); + } + + /** + * Handles the dismiss notice request + */ + public function dismiss_notice() { + check_ajax_referer( 'wpseo-dismiss-' . $this->notice_name ); + + $this->save_dismissed(); + + wp_die( 'true' ); + } + + /** + * Storing the dismissed value in the database. The target location is based on the set notification type. + */ + private function save_dismissed() { + if ( $this->notice_type === self::FOR_SITE ) { + update_option( 'wpseo_dismiss_' . $this->notice_name, 1 ); + + return; + } + + if ( $this->notice_type === self::FOR_NETWORK ) { + update_site_option( 'wpseo_dismiss_' . $this->notice_name, 1 ); + + return; + } + + update_user_meta( get_current_user_id(), 'wpseo_dismiss_' . $this->notice_name, 1 ); + } +} diff --git a/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-yoast-onpage-ajax.php b/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-yoast-onpage-ajax.php new file mode 100644 index 00000000..9159fb3e --- /dev/null +++ b/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-yoast-onpage-ajax.php @@ -0,0 +1,39 @@ +save_dismissed(); + + wp_die( 'true' ); + } + + /** + * Storing the the dismissed value as an user option in the database + */ + private function save_dismissed() { + update_user_meta( get_current_user_id(), WPSEO_OnPage::USER_META_KEY, 1 ); + } + +} diff --git a/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-yoast-plugin-conflict-ajax.php b/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-yoast-plugin-conflict-ajax.php index 24038451..398beb23 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-yoast-plugin-conflict-ajax.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/ajax/class-yoast-plugin-conflict-ajax.php @@ -54,7 +54,7 @@ class Yoast_Plugin_Conflict_Ajax { /** * Getting the dismissed conflicts from the database * - * @param string $plugin_section + * @param string $plugin_section Type of conflict group (such as Open Graph or sitemap). * * @return array */ @@ -71,7 +71,7 @@ class Yoast_Plugin_Conflict_Ajax { /** * Storing the conflicting plugins as an user option in the database * - * @param string $plugin_section + * @param string $plugin_section Plugin conflict type (such as Open Graph or sitemap). */ private function save_dismissed_conflicts( $plugin_section ) { $dismissed_conflicts = $this->get_dismissed_option(); @@ -84,7 +84,7 @@ class Yoast_Plugin_Conflict_Ajax { /** * Loop through the plugins to compare them with the already stored dismissed plugin conflicts * - * @param array $posted_plugins + * @param array $posted_plugins Plugin set to check. */ public function compare_plugins( array $posted_plugins ) { foreach ( $posted_plugins as $posted_plugin ) { @@ -95,12 +95,11 @@ class Yoast_Plugin_Conflict_Ajax { /** * Check if plugin is already dismissed, if not store it in the array that will be saved later * - * @param string $posted_plugin + * @param string $posted_plugin Plugin to check against dismissed conflicts. */ private function compare_plugin( $posted_plugin ) { if ( ! in_array( $posted_plugin, $this->dismissed_conflicts ) ) { $this->dismissed_conflicts[] = $posted_plugin; } } - } diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-admin-init.php b/wp/wp-content/plugins/wordpress-seo/admin/class-admin-init.php index 9aec701f..85ed776f 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-admin-init.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-admin-init.php @@ -36,13 +36,15 @@ class WPSEO_Admin_Init { add_action( 'admin_init', array( $this, 'after_update_notice' ), 15 ); add_action( 'admin_init', array( $this, 'tagline_notice' ), 15 ); add_action( 'admin_init', array( $this, 'ga_compatibility_notice' ), 15 ); + add_action( 'admin_init', array( $this, 'recalculate_notice' ), 15 ); + add_action( 'admin_init', array( $this, 'ignore_tour' ) ); + add_action( 'admin_init', array( $this, 'load_tour' ) ); + add_action( 'admin_init', array( $this, 'show_hook_deprecation_warnings' ) ); $this->load_meta_boxes(); $this->load_taxonomy_class(); $this->load_admin_page_class(); $this->load_admin_user_class(); - $this->ignore_tour(); - $this->load_tour(); $this->load_xml_sitemaps_admin(); } @@ -59,7 +61,10 @@ class WPSEO_Admin_Init { * Redirect first time or just upgraded users to the about screen. */ public function after_update_notice() { - if ( current_user_can( 'manage_options' ) && ! $this->seen_about() ) { + + $can_access = is_multisite() ? WPSEO_Utils::grant_access() : current_user_can( 'manage_options' ); + + if ( $can_access && $this->has_ignored_tour() && ! $this->seen_about() ) { if ( filter_input( INPUT_GET, 'intro' ) === '1' ) { update_user_meta( get_current_user_id(), 'wpseo_seen_about_version' , WPSEO_VERSION ); @@ -100,8 +105,8 @@ class WPSEO_Admin_Init { public function tagline_notice() { if ( current_user_can( 'manage_options' ) && $this->has_default_tagline() && ! $this->seen_tagline_notice() ) { - // Only add the notice on GET requests and not in the customizer to prevent faulty return url. - if ( 'GET' !== filter_input( INPUT_SERVER, 'REQUEST_METHOD' ) || is_customize_preview() ) { + // Only add the notice on GET requests, not in the customizer, and not in "action" type submits to prevent faulty return url. + if ( 'GET' !== filter_input( INPUT_SERVER, 'REQUEST_METHOD' ) || is_customize_preview() || null !== filter_input( INPUT_GET, 'action' ) ) { return; } @@ -168,6 +173,46 @@ class WPSEO_Admin_Init { } } + /** + * Shows the notice for recalculating the post. the Notice will only be shown if the user hasn't dismissed it before. + */ + public function recalculate_notice() { + if ( filter_input( INPUT_GET, 'recalculate' ) === '1' ) { + update_option( 'wpseo_dismiss_recalculate', '1' ); + return; + } + + $can_access = is_multisite() ? WPSEO_Utils::grant_access() : current_user_can( 'manage_options' ); + if ( $can_access && ! $this->is_site_notice_dismissed( 'wpseo_dismiss_recalculate' ) ) { + Yoast_Notification_Center::get()->add_notification( + new Yoast_Notification( + /* translators: 1: is a link to 'admin_url / admin.php?page=wpseo_tools&recalculate=1' 2: closing link tag */ + sprintf( + __( 'We\'ve updated our SEO score algorithm. %1$sClick here to recalculate the SEO scores%2$s for all posts and pages.', 'wordpress-seo' ), + '', + '' + ), + array( + 'type' => 'updated yoast-dismissible', + 'id' => 'wpseo-dismiss-recalculate', + 'nonce' => wp_create_nonce( 'wpseo-dismiss-recalculate' ), + ) + ) + ); + } + } + + /** + * Check if the user has dismissed the given notice (by $notice_name) + * + * @param string $notice_name The name of the notice that might be dismissed. + * + * @return bool + */ + private function is_site_notice_dismissed( $notice_name ) { + return '1' === get_option( $notice_name, true ); + } + /** * Helper to verify if the user is currently visiting one of our admin pages. * @@ -181,6 +226,10 @@ class WPSEO_Admin_Init { * Determine whether we should load the meta box class and if so, load it. */ private function load_meta_boxes() { + + $is_editor = in_array( $this->pagenow, array( 'edit.php', 'post.php', 'post-new.php' ) ); + $is_inline_save = filter_input( INPUT_POST, 'action' ) === 'inline-save'; + /** * Filter: 'wpseo_always_register_metaboxes_on_admin' - Allow developers to change whether * the WPSEO metaboxes are only registered on the typical pages (lean loading) or always @@ -188,16 +237,14 @@ class WPSEO_Admin_Init { * * @api bool Whether to always register the metaboxes or not. Defaults to false. */ - if ( in_array( $this->pagenow, array( + if ( $is_editor || $is_inline_save || in_array( $this->pagenow, array( 'edit.php', 'post.php', 'post-new.php', ) ) || apply_filters( 'wpseo_always_register_metaboxes_on_admin', false ) ) { - $GLOBALS['wpseo_metabox'] = new WPSEO_Metabox; - if ( $this->options['opengraph'] === true || $this->options['twitter'] === true || $this->options['googleplus'] === true ) { - new WPSEO_Social_Admin; - } + $GLOBALS['wpseo_metabox'] = new WPSEO_Metabox; + $GLOBALS['wpseo_meta_columns'] = new WPSEO_Meta_Columns(); } } @@ -258,13 +305,13 @@ class WPSEO_Admin_Init { /** * See if we should start our tour. */ - private function load_tour() { + public function load_tour() { $restart_tour = filter_input( INPUT_GET, 'wpseo_restart_tour' ); if ( $restart_tour ) { delete_user_meta( get_current_user_id(), 'wpseo_ignore_tour' ); } - if ( ! get_user_meta( get_current_user_id(), 'wpseo_ignore_tour' ) ) { + if ( ! $this->has_ignored_tour() ) { add_action( 'admin_enqueue_scripts', array( 'WPSEO_Pointers', 'get_instance' ) ); } } @@ -278,13 +325,59 @@ class WPSEO_Admin_Init { } } + /** + * Returns the value of the ignore tour. + * + * @return bool + */ + private function has_ignored_tour() { + $user_meta = get_user_meta( get_current_user_id(), 'wpseo_ignore_tour' ); + + return ! empty( $user_meta ); + } + /** * Listener for the ignore tour GET value. If this one is set, just set the user meta to true. */ - private function ignore_tour() { + public function ignore_tour() { if ( filter_input( INPUT_GET, 'wpseo_ignore_tour' ) && wp_verify_nonce( filter_input( INPUT_GET, 'nonce' ), 'wpseo-ignore-tour' ) ) { update_user_meta( get_current_user_id(), 'wpseo_ignore_tour', true ); } } + + /** + * Shows deprecation warnings to the user if a plugin has registered a filter we have deprecated. + */ + public function show_hook_deprecation_warnings() { + global $wp_filter; + + if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { + return false; + } + + // WordPress hooks that have been deprecated in Yoast SEO 3.0. + $deprecated_30 = array( + 'wpseo_pre_analysis_post_content', + 'wpseo_metadesc_length', + 'wpseo_metadesc_length_reason', + 'wpseo_body_length_score', + 'wpseo_linkdex_results', + 'wpseo_snippet', + ); + + $deprecated_notices = array_intersect( + $deprecated_30, + array_keys( $wp_filter ) + ); + + foreach ( $deprecated_notices as $deprecated_filter ) { + _deprecated_function( + /* %s expands to the actual filter/action that has been used. */ + sprintf( __( '%s filter/action', 'wordpress-seo' ), $deprecated_filter ), + 'WPSEO 3.0', + 'javascript' + ); + } + } } diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-admin-user-profile.php b/wp/wp-content/plugins/wordpress-seo/admin/class-admin-user-profile.php index 732eda46..6e4006f8 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-admin-user-profile.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-admin-user-profile.php @@ -21,7 +21,7 @@ class WPSEO_Admin_User_Profile { /** * Filter POST variables. * - * @param string $var_name + * @param string $var_name Name of the variable to filter. * * @return mixed */ @@ -41,6 +41,12 @@ class WPSEO_Admin_User_Profile { public function process_user_option_update( $user_id ) { update_user_meta( $user_id, '_yoast_wpseo_profile_updated', time() ); + $nonce_value = $this->filter_input_post( 'wpseo_nonce' ); + + if ( empty( $nonce_value ) ) { // Submit from alternate forms. + return; + } + check_admin_referer( 'wpseo_user_profile_update', 'wpseo_nonce' ); update_user_meta( $user_id, 'wpseo_title', $this->filter_input_post( 'wpseo_author_title' ) ); @@ -52,7 +58,7 @@ class WPSEO_Admin_User_Profile { /** * Add the inputs needed for SEO values to the User Profile page * - * @param object $user + * @param WP_User $user User instance to output for. */ public function user_profile( $user ) { $options = WPSEO_Options::get_all(); @@ -61,5 +67,4 @@ class WPSEO_Admin_User_Profile { require_once( 'views/user-profile.php' ); } - } diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-admin.php b/wp/wp-content/plugins/wordpress-seo/admin/class-admin.php index 9e21737c..bf5c1fe5 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-admin.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-admin.php @@ -39,9 +39,10 @@ class WPSEO_Admin { add_action( 'delete_category', array( $this, 'schedule_rewrite_flush' ) ); } - $this->page_gsc = new WPSEO_GSC(); + $this->page_gsc = new WPSEO_GSC(); $this->dashboard_widget = new Yoast_Dashboard_Widget(); + // Needs the lower than default priority so other plugins can hook underneath it without issue. add_action( 'admin_menu', array( $this, 'register_settings_page' ), 5 ); add_action( 'network_admin_menu', array( $this, 'register_network_settings_page' ) ); @@ -55,7 +56,7 @@ class WPSEO_Admin { } if ( ( ( isset( $this->options['theme_has_description'] ) && $this->options['theme_has_description'] === true ) || - $this->options['theme_description_found'] !== '' ) && $this->options['ignore_meta_description_warning'] !== true + $this->options['theme_description_found'] !== '' ) && $this->options['ignore_meta_description_warning'] !== true ) { add_action( 'admin_footer', array( $this, 'meta_description_warning' ) ); } @@ -72,8 +73,22 @@ class WPSEO_Admin { add_filter( 'set-screen-option', array( $this, 'save_bulk_edit_options' ), 10, 3 ); add_action( 'admin_init', array( 'WPSEO_Plugin_Conflict', 'hook_check_for_plugin_conflicts' ), 10, 1 ); + add_action( 'admin_init', array( $this, 'import_plugin_hooks' ) ); - WPSEO_Utils::register_cache_clear_option( 'wpseo', '' ); + WPSEO_Utils::register_cache_clear_option( 'wpseo', '' ); + } + + /** + * Setting the hooks for importing data from other plugins + */ + public function import_plugin_hooks() { + if ( current_user_can( $this->get_manage_options_cap() ) ) { + $plugin_imports = array( + 'wpSEO' => new WPSEO_Import_WPSEO_Hooks(), + 'aioseo' => new WPSEO_Import_AIOSEO_Hooks(), + 'robots_meta' => new WPSEO_Import_Robots_Meta_Hooks(), + ); + } } /** @@ -94,21 +109,16 @@ class WPSEO_Admin { } // Base 64 encoded SVG image. - $icon_svg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCIgWw0KCTwhRU5USVRZIG5zX2Zsb3dzICJodHRwOi8vbnMuYWRvYmUuY29tL0Zsb3dzLzEuMC8iPg0KCTwhRU5USVRZIG5zX2V4dGVuZCAiaHR0cDovL25zLmFkb2JlLmNvbS9FeHRlbnNpYmlsaXR5LzEuMC8iPg0KCTwhRU5USVRZIG5zX2FpICJodHRwOi8vbnMuYWRvYmUuY29tL0Fkb2JlSWxsdXN0cmF0b3IvMTAuMC8iPg0KCTwhRU5USVRZIG5zX2dyYXBocyAiaHR0cDovL25zLmFkb2JlLmNvbS9HcmFwaHMvMS4wLyI+DQpdPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYWFnXzEiIHhtbG5zOng9IiZuc19leHRlbmQ7IiB4bWxuczppPSImbnNfYWk7IiB4bWxuczpncmFwaD0iJm5zX2dyYXBoczsiDQoJIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHhtbG5zOmE9Imh0dHA6Ly9ucy5hZG9iZS5jb20vQWRvYmVTVkdWaWV3ZXJFeHRlbnNpb25zLzMuMC8iDQoJIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgNDAgMzEuODkiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDQwIDMxLjg5IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KPHBhdGggZmlsbD0iI0ZGRkZGRiIgZD0iTTQwLDEyLjUyNEM0MCw1LjYwOCwzMS40NjksMCwyMCwwQzguNTMsMCwwLDUuNjA4LDAsMTIuNTI0YzAsNS41Niw1LjI0MywxMC4yNzIsMTMuNTU3LDExLjkwN3YtNC4wNjUNCgljMCwwLDAuMDQtMS0wLjI4LTEuOTJjLTAuMzItMC45MjEtMS43Ni0zLjAwMS0xLjc2LTUuMTIxYzAtMi4xMjEsMi41NjEtOS41NjMsNS4xMjItMTAuNDQ0Yy0wLjQsMS4yMDEtMC4zMiw3LjY4My0wLjMyLDcuNjgzDQoJczEuNCwyLjcyLDQuNjQxLDIuNzJjMy4yNDIsMCw0LjUxMS0xLjc2LDQuNzE1LTIuMmMwLjIwNi0wLjQ0LDAuODQ2LTguNzIzLDAuODQ2LTguNzIzczQuMDgyLDQuNDAyLDMuNjgyLDkuMzYzDQoJYy0wLjQwMSw0Ljk2Mi00LjQ4Miw3LjIwMy02LjEyMiw5LjEyM2MtMS4yODYsMS41MDUtMi4yMjQsMy4xMy0yLjYyOSw0LjE2OGMwLjgwMS0wLjAzNCwxLjU4Ny0wLjA5OCwyLjM2MS0wLjE4NGw5LjE1MSw3LjA1OQ0KCWwtNC44ODQtNy44M0MzNS41MzUsMjIuMTYxLDQwLDE3LjcxMyw0MCwxMi41MjR6Ii8+DQo8L2c+DQo8L3N2Zz4='; + $icon_svg = $this->get_menu_svg(); + + $manage_options_cap = $this->get_manage_options_cap(); // Add main page. - $admin_page = add_menu_page( 'Yoast SEO: ' . __( 'General Settings', 'wordpress-seo' ), __( 'SEO', 'wordpress-seo' ), 'manage_options', 'wpseo_dashboard', array( + $admin_page = add_menu_page( 'Yoast SEO: ' . __( 'General Settings', 'wordpress-seo' ), __( 'SEO', 'wordpress-seo' ), $manage_options_cap, 'wpseo_dashboard', array( $this, 'load_page', ), $icon_svg, '99.31337' ); - /** - * Filter: 'wpseo_manage_options_capability' - Allow changing the capability users need to view the settings pages - * - * @api string unsigned The capability - */ - $manage_options_cap = apply_filters( 'wpseo_manage_options_capability', 'manage_options' ); - // Sub menu pages. $submenu_pages = array( array( @@ -165,18 +175,17 @@ class WPSEO_Admin { array( $this->page_gsc, 'display' ), array( array( $this->page_gsc, 'set_help' ) ), ), + array( + 'wpseo_dashboard', + '', + '' . __( 'Extensions', 'wordpress-seo' ) . '', + $manage_options_cap, + 'wpseo_licenses', + array( $this, 'load_page' ), + null, + ), ); - // Add Extension submenu page. - $submenu_pages[] = array( - 'wpseo_dashboard', - '', - '' . __( 'Extensions', 'wordpress-seo' ) . '', - $manage_options_cap, - 'wpseo_licenses', - array( $this, 'load_page' ), - null, - ); // Allow submenu pages manipulation. $submenu_pages = apply_filters( 'wpseo_submenu_pages', $submenu_pages ); @@ -203,6 +212,22 @@ class WPSEO_Admin { } } + /** + * Returns the manage_options cap + * + * @return mixed|void + */ + private function get_manage_options_cap() { + /** + * Filter: 'wpseo_manage_options_capability' - Allow changing the capability users need to view the settings pages + * + * @api string unsigned The capability + */ + $manage_options_cap = apply_filters( 'wpseo_manage_options_capability', 'manage_options' ); + + return $manage_options_cap; + } + /** * Adds contextual help to the titles & metas page. */ @@ -247,7 +272,7 @@ class WPSEO_Admin { function register_network_settings_page() { if ( WPSEO_Utils::grant_access() ) { // Base 64 encoded SVG image. - $icon_svg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCIgWw0KCTwhRU5USVRZIG5zX2Zsb3dzICJodHRwOi8vbnMuYWRvYmUuY29tL0Zsb3dzLzEuMC8iPg0KCTwhRU5USVRZIG5zX2V4dGVuZCAiaHR0cDovL25zLmFkb2JlLmNvbS9FeHRlbnNpYmlsaXR5LzEuMC8iPg0KCTwhRU5USVRZIG5zX2FpICJodHRwOi8vbnMuYWRvYmUuY29tL0Fkb2JlSWxsdXN0cmF0b3IvMTAuMC8iPg0KCTwhRU5USVRZIG5zX2dyYXBocyAiaHR0cDovL25zLmFkb2JlLmNvbS9HcmFwaHMvMS4wLyI+DQpdPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYWFnXzEiIHhtbG5zOng9IiZuc19leHRlbmQ7IiB4bWxuczppPSImbnNfYWk7IiB4bWxuczpncmFwaD0iJm5zX2dyYXBoczsiDQoJIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHhtbG5zOmE9Imh0dHA6Ly9ucy5hZG9iZS5jb20vQWRvYmVTVkdWaWV3ZXJFeHRlbnNpb25zLzMuMC8iDQoJIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgNDAgMzEuODkiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDQwIDMxLjg5IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KPHBhdGggZmlsbD0iI0ZGRkZGRiIgZD0iTTQwLDEyLjUyNEM0MCw1LjYwOCwzMS40NjksMCwyMCwwQzguNTMsMCwwLDUuNjA4LDAsMTIuNTI0YzAsNS41Niw1LjI0MywxMC4yNzIsMTMuNTU3LDExLjkwN3YtNC4wNjUNCgljMCwwLDAuMDQtMS0wLjI4LTEuOTJjLTAuMzItMC45MjEtMS43Ni0zLjAwMS0xLjc2LTUuMTIxYzAtMi4xMjEsMi41NjEtOS41NjMsNS4xMjItMTAuNDQ0Yy0wLjQsMS4yMDEtMC4zMiw3LjY4My0wLjMyLDcuNjgzDQoJczEuNCwyLjcyLDQuNjQxLDIuNzJjMy4yNDIsMCw0LjUxMS0xLjc2LDQuNzE1LTIuMmMwLjIwNi0wLjQ0LDAuODQ2LTguNzIzLDAuODQ2LTguNzIzczQuMDgyLDQuNDAyLDMuNjgyLDkuMzYzDQoJYy0wLjQwMSw0Ljk2Mi00LjQ4Miw3LjIwMy02LjEyMiw5LjEyM2MtMS4yODYsMS41MDUtMi4yMjQsMy4xMy0yLjYyOSw0LjE2OGMwLjgwMS0wLjAzNCwxLjU4Ny0wLjA5OCwyLjM2MS0wLjE4NGw5LjE1MSw3LjA1OQ0KCWwtNC44ODQtNy44M0MzNS41MzUsMjIuMTYxLDQwLDE3LjcxMyw0MCwxMi41MjR6Ii8+DQo8L2c+DQo8L3N2Zz4='; + $icon_svg = $this->get_menu_svg(); add_menu_page( 'Yoast SEO: ' . __( 'MultiSite Settings', 'wordpress-seo' ), __( 'SEO', 'wordpress-seo' ), 'delete_users', 'wpseo_dashboard', array( $this, 'network_config_page', @@ -337,9 +362,9 @@ class WPSEO_Admin { /** * Saves the posts per page limit for bulk edit pages. * - * @param int $status - * @param string $option - * @param int $value + * @param int $status Status value to pass through. + * @param string $option Option name. + * @param int $value Count value to check. * * @return int */ @@ -359,6 +384,10 @@ class WPSEO_Admin { return; } + if ( ! current_user_can( 'manage_options' ) ) { + return; + } + if ( $this->options['ignore_blog_public_warning'] === true ) { return; } @@ -451,7 +480,7 @@ class WPSEO_Admin { */ function config_page_scripts() { if ( WPSEO_Utils::grant_access() ) { - wp_enqueue_script( 'wpseo-admin-global-script', plugins_url( 'js/wp-seo-admin-global' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( 'jquery' ), WPSEO_VERSION, true ); + wp_enqueue_script( 'wpseo-admin-global-script', plugins_url( 'js/wp-seo-admin-global-' . '302' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( 'jquery' ), WPSEO_VERSION, true ); } } @@ -485,22 +514,36 @@ class WPSEO_Admin { * @return string $clean_slug cleaned slug */ function remove_stopwords_from_slug( $slug ) { + return $this->filter_stopwords_from_slug( $slug, filter_input( INPUT_POST, 'post_title' ) ); + } + + /** + * Filter the stopwords from the slug + * + * @param string $slug The current slug, if not empty there will be done nothing. + * @param string $post_title The title which will be used in case of an empty slug. + * + * @return string + */ + public function filter_stopwords_from_slug( $slug, $post_title ) { // Don't change an existing slug. if ( isset( $slug ) && $slug !== '' ) { return $slug; } - if ( ! filter_input( INPUT_POST, 'post_title' ) ) { + // When the post title is empty, just return the slug. + if ( empty( $post_title ) ) { return $slug; } // Don't change slug if the post is a draft, this conflicts with polylang. - if ( 'draft' == filter_input( INPUT_POST, 'post_status' ) ) { + // Doesn't work with filter_input() since need current value, not originally submitted one. + if ( 'draft' === $_POST['post_status'] ) { return $slug; } // Lowercase the slug and strip slashes. - $clean_slug = sanitize_title( stripslashes( filter_input( INPUT_POST, 'post_title' ) ) ); + $clean_slug = sanitize_title( stripslashes( $post_title ) ); // Turn it to an array and strip stopwords by comparing against an array of stopwords. $clean_slug_array = array_diff( explode( '-', $clean_slug ), $this->stopwords() ); @@ -645,6 +688,14 @@ class WPSEO_Admin { _deprecated_function( __METHOD__, 'WPSEO 1.5.0', 'WPSEO_Option::register_setting()' ); } + /** + * Returns a base64 URL for the svg for use in the menu + * + * @return string + */ + private function get_menu_svg() { + $icon_svg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbDpzcGFjZT0icHJlc2VydmUiIGZpbGw9Im5vbmUiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48Zz48Zz48Zz48Zz48cGF0aCBzdHlsZT0iZmlsbDojMDAwIiBkPSJNMjAzLjYsMzk1YzYuOC0xNy40LDYuOC0zNi42LDAtNTRsLTc5LjQtMjA0aDcwLjlsNDcuNywxNDkuNGw3NC44LTIwNy42SDExNi40Yy00MS44LDAtNzYsMzQuMi03Niw3NlYzNTdjMCw0MS44LDM0LjIsNzYsNzYsNzZIMTczQzE4OSw0MjQuMSwxOTcuNiw0MTAuMywyMDMuNiwzOTV6Ii8+PC9nPjxnPjxwYXRoIHN0eWxlPSJmaWxsOiMwMDAiIGQ9Ik00NzEuNiwxNTQuOGMwLTQxLjgtMzQuMi03Ni03Ni03NmgtM0wyODUuNywzNjVjLTkuNiwyNi43LTE5LjQsNDkuMy0zMC4zLDY4aDIxNi4yVjE1NC44eiIvPjwvZz48L2c+PHBhdGggc3R5bGU9ImZpbGw6IzAwMCIgc3Ryb2tlLXdpZHRoPSIyLjk3NCIgc3Ryb2tlLW1pdGVybGltaXQ9IjEwIiBkPSJNMzM4LDEuM2wtOTMuMywyNTkuMWwtNDIuMS0xMzEuOWgtODkuMWw4My44LDIxNS4yYzYsMTUuNSw2LDMyLjUsMCw0OGMtNy40LDE5LTE5LDM3LjMtNTMsNDEuOWwtNy4yLDF2NzZoOC4zYzgxLjcsMCwxMTguOS01Ny4yLDE0OS42LTE0Mi45TDQzMS42LDEuM0gzMzh6IE0yNzkuNCwzNjJjLTMyLjksOTItNjcuNiwxMjguNy0xMjUuNywxMzEuOHYtNDVjMzcuNS03LjUsNTEuMy0zMSw1OS4xLTUxLjFjNy41LTE5LjMsNy41LTQwLjcsMC02MGwtNzUtMTkyLjdoNTIuOGw1My4zLDE2Ni44bDEwNS45LTI5NGg1OC4xTDI3OS40LDM2MnoiLz48L2c+PC9nPjwvc3ZnPg=='; - + return $icon_svg; + } } /* End of class */ diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-bulk-description-editor-list-table.php b/wp/wp-content/plugins/wordpress-seo/admin/class-bulk-description-editor-list-table.php index d785eec9..ad97641d 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-bulk-description-editor-list-table.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-bulk-description-editor-list-table.php @@ -50,9 +50,9 @@ class WPSEO_Bulk_Description_List_Table extends WPSEO_Bulk_List_Table { /** * Parse the metadescription * - * @param string $column_name - * @param object $record - * @param string $attributes + * @param string $column_name Column name. + * @param object $record Data object. + * @param string $attributes HTML attributes. * * @return string */ @@ -72,5 +72,4 @@ class WPSEO_Bulk_Description_List_Table extends WPSEO_Bulk_List_Table { break; } } - } /* End of class */ diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-bulk-editor-list-table.php b/wp/wp-content/plugins/wordpress-seo/admin/class-bulk-editor-list-table.php index ffa9872c..efe2e4b3 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-bulk-editor-list-table.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-bulk-editor-list-table.php @@ -198,7 +198,7 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { /** * Will shown the navigation for the table like pagenavigation and pagefilter; * - * @param string $which + * @param string $which Table nav location (such as top). */ function display_tablenav( $which ) { $post_status = sanitize_text_field( filter_input( INPUT_GET, 'post_status' ) ); @@ -341,7 +341,7 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { /** - * @param string $which + * @param string $which Table nav location (such as top). */ function extra_tablenav( $which ) { @@ -489,9 +489,9 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { /** * Counting total items * - * @param string $subquery - * @param string $all_states - * @param string $post_type_clause + * @param string $subquery SQL FROM part. + * @param string $all_states SQL IN part. + * @param string $post_type_clause SQL post type part. * * @return mixed */ @@ -532,7 +532,7 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { * * Total items is the number of all visible items. * - * @param int $total_items + * @param int $total_items Total items counts. */ protected function set_pagination( $total_items ) { @@ -565,9 +565,9 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { * Based on given parameters there will be parse a query which will get all the pages/posts and other post_types * from the database. * - * @param string $subquery - * @param string $all_states - * @param string $post_type_clause + * @param string $subquery SQL FROM part. + * @param string $all_states SQL IN part. + * @param string $post_type_clause SQL post type part. * * @return string */ @@ -621,7 +621,7 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { * * @param string $order Whether we want to sort ascending or descending. * - * @return string $order + * @return string $order SQL order string (ASC, DESC). */ protected function sanitize_order( $order ) { if ( in_array( strtoupper( $order ), array( 'ASC', 'DESC' ) ) ) { @@ -634,7 +634,7 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { /** * Getting all the items. * - * @param string $query + * @param string $query SQL query to use. */ protected function get_items( $query ) { global $wpdb; @@ -709,8 +709,8 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { /** * Getting the attributes for each table cell. * - * @param string $column_name - * @param string $hidden + * @param string $column_name Column name string. + * @param array $hidden Set of hidden columns. * * @return string */ @@ -731,7 +731,7 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { /** * Parsing the title. * - * @param object $rec + * @param WP_Post $rec Post object. * * @return string */ @@ -768,8 +768,8 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { /** * Parsing the column based on the $column_name. * - * @param string $column_name - * @param stdobject $rec + * @param string $column_name Column name. + * @param WP_Post $rec Post object. * * @return string */ @@ -819,9 +819,9 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { /** * Parse the field where the existing meta-data value is displayed. * - * @param integer $record_id - * @param string $attributes - * @param bool|array $values + * @param integer $record_id Record ID. + * @param string $attributes HTML attributes. + * @param bool|array $values Optional values data array. * * @return string */ @@ -876,7 +876,7 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { /** * Getting the meta_data from database. * - * @param string $post_ids + * @param string $post_ids Post IDs string for SQL IN part. * * @return mixed */ @@ -897,7 +897,7 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { /** * Setting $this->meta_data. * - * @param array $meta_data + * @param array $meta_data Meta data set. */ protected function parse_meta_data( $meta_data ) { @@ -910,7 +910,7 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { /** * This method will merge general array with given parameter $columns. * - * @param array $columns + * @param array $columns Optional columns set. * * @return array */ @@ -930,5 +930,4 @@ class WPSEO_Bulk_List_Table extends WP_List_Table { return $columns; } - } /* End of class */ diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-bulk-title-editor-list-table.php b/wp/wp-content/plugins/wordpress-seo/admin/class-bulk-title-editor-list-table.php index 0df34ee0..96d08d5a 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-bulk-title-editor-list-table.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-bulk-title-editor-list-table.php @@ -52,9 +52,9 @@ class WPSEO_Bulk_Title_Editor_List_Table extends WPSEO_Bulk_List_Table { /** * Parse the title columns * - * @param string $column_name - * @param object $record - * @param string $attributes + * @param string $column_name Column name. + * @param object $record Data object. + * @param string $attributes HTML attributes. * * @return string */ @@ -80,6 +80,4 @@ class WPSEO_Bulk_Title_Editor_List_Table extends WPSEO_Bulk_List_Table { unset( $meta_data ); } - - } /* End of class */ diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-config.php b/wp/wp-content/plugins/wordpress-seo/admin/class-config.php index f8ac3deb..c4923868 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-config.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-config.php @@ -45,7 +45,7 @@ class WPSEO_Admin_Pages { wp_enqueue_style( 'thickbox' ); wp_enqueue_style( 'global' ); wp_enqueue_style( 'wp-admin' ); - wp_enqueue_style( 'yoast-admin-css', plugins_url( 'css/yst_plugin_tools' . WPSEO_CSSJS_SUFFIX . '.css', WPSEO_FILE ), array(), WPSEO_VERSION ); + wp_enqueue_style( 'yoast-admin-css', plugins_url( 'css/yst_plugin_tools-' . '302' . WPSEO_CSSJS_SUFFIX . '.css', WPSEO_FILE ), array(), WPSEO_VERSION ); if ( is_rtl() ) { wp_enqueue_style( 'wpseo-rtl', plugins_url( 'css/wpseo-rtl' . WPSEO_CSSJS_SUFFIX . '.css', WPSEO_FILE ), array(), WPSEO_VERSION ); @@ -56,32 +56,39 @@ class WPSEO_Admin_Pages { * Loads the required scripts for the config page. */ function config_page_scripts() { - wp_enqueue_script( 'wpseo-admin-script', plugins_url( 'js/wp-seo-admin' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( + wp_enqueue_script( 'wpseo-admin-script', plugins_url( 'js/wp-seo-admin-' . '306' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( 'jquery', 'jquery-ui-core', + 'jquery-ui-progressbar', ), WPSEO_VERSION, true ); wp_localize_script( 'wpseo-admin-script', 'wpseoAdminL10n', $this->localize_admin_script() ); wp_enqueue_script( 'dashboard' ); wp_enqueue_script( 'thickbox' ); + + $page = filter_input( INPUT_GET, 'page' ); $tool = filter_input( INPUT_GET, 'tool' ); if ( in_array( $page, array( 'wpseo_social', 'wpseo_dashboard' ) ) ) { wp_enqueue_media(); - wp_enqueue_script( 'wpseo-admin-media', plugins_url( 'js/wp-seo-admin-media' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( + wp_enqueue_script( 'wpseo-admin-media', plugins_url( 'js/wp-seo-admin-media-' . '302' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( 'jquery', 'jquery-ui-core', ), WPSEO_VERSION, true ); wp_localize_script( 'wpseo-admin-media', 'wpseoMediaL10n', $this->localize_media_script() ); } + if ( 'wpseo_tools' === $page && empty( $tool ) ) { + wp_enqueue_script( 'yoast-seo', plugins_url( 'js/dist/yoast-seo/yoast-seo-' . '305' . '.min.js', WPSEO_FILE ), null, WPSEO_VERSION, true ); + } + if ( 'wpseo_tools' === $page && 'bulk-editor' === $tool ) { wp_enqueue_script( 'wpseo-bulk-editor', plugins_url( 'js/wp-seo-bulk-editor' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( 'jquery' ), WPSEO_VERSION, true ); } if ( 'wpseo_tools' === $page && 'import-export' === $tool ) { - wp_enqueue_script( 'wpseo-export', plugins_url( 'js/wp-seo-export' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( 'jquery' ), WPSEO_VERSION, true ); + wp_enqueue_script( 'wpseo-export', plugins_url( 'js/wp-seo-export-' . '302' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( 'jquery' ), WPSEO_VERSION, true ); } } @@ -107,6 +114,7 @@ class WPSEO_Admin_Pages { return array( /* translators: %s: '%%term_title%%' variable used in titles and meta's template that's not compatible with the given template */ 'variable_warning' => sprintf( __( 'Warning: the variable %s cannot be used in this template.', 'wordpress-seo' ), '%s' ) . ' ' . __( 'See the help tab for more info.', 'wordpress-seo' ), + 'locale' => get_locale(), ); } @@ -292,9 +300,9 @@ class WPSEO_Admin_Pages { * * @deprecated 2.0 * - * @param string $var - * @param string $label - * @param string $option + * @param string $var Option name. + * @param string $label Label message. + * @param string $option Optional option key. */ function media_input( $var, $label, $option = '' ) { _deprecated_function( __METHOD__, 'WPSEO 2.0', 'This method is deprecated, please use the Yoast_Form class.' ); @@ -340,7 +348,7 @@ class WPSEO_Admin_Pages { ?>
-

+

write_line( '[' . $opt_group . ']', true ); @@ -157,8 +157,8 @@ class WPSEO_Export { /** * Writes a settings line to the export * - * @param string $key - * @param string $val + * @param string $key Key string. + * @param string $val Value string. */ private function write_setting( $key, $val ) { if ( is_string( $val ) ) { @@ -175,7 +175,7 @@ class WPSEO_Export { $taxonomy_meta = get_option( 'wpseo_taxonomy_meta' ); if ( is_array( $taxonomy_meta ) ) { $this->write_line( '[wpseo_taxonomy_meta]', true ); - $this->write_setting( 'wpseo_taxonomy_meta', urlencode( json_encode( $taxonomy_meta ) ) ); + $this->write_setting( 'wpseo_taxonomy_meta', urlencode( WPSEO_Utils::json_encode( $taxonomy_meta ) ) ); } else { $this->write_line( '; ' . __( 'No taxonomy metadata found', 'wordpress-seo' ), true ); @@ -220,5 +220,4 @@ class WPSEO_Export { return true; } - } diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-import-external.php b/wp/wp-content/plugins/wordpress-seo/admin/class-import-external.php index 41823531..b9941c44 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-import-external.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-import-external.php @@ -25,9 +25,9 @@ class WPSEO_Import_External { public $msg = ''; /** - * Class constructor + * Import class constructor. * - * @param boolean $replace + * @param boolean $replace Boolean replace switch. */ public function __construct( $replace = false ) { $this->replace = $replace; @@ -38,7 +38,7 @@ class WPSEO_Import_External { /** * Convenience function to set import message * - * @param string $msg + * @param string $msg Message string. */ protected function set_msg( $msg ) { if ( ! empty( $this->msg ) ) { @@ -50,7 +50,7 @@ class WPSEO_Import_External { /** * Deletes an option depending on the class replace state * - * @param string $option + * @param string $option Option key. */ protected function perhaps_delete( $option ) { if ( $this->replace ) { diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-import-woothemes-seo.php b/wp/wp-content/plugins/wordpress-seo/admin/class-import-woothemes-seo.php index 04910430..f06fcd30 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-import-woothemes-seo.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-import-woothemes-seo.php @@ -39,8 +39,8 @@ class WPSEO_Import_WooThemes_SEO extends WPSEO_Import_External { /** * Import options. * - * @param string $option - * @param string $post_type + * @param string $option Option key. + * @param string $post_type Post type name to import for. */ private function import_option( $option, $post_type ) { switch ( get_option( $option ) ) { @@ -87,8 +87,8 @@ class WPSEO_Import_WooThemes_SEO extends WPSEO_Import_External { /** * Import custom descriptions and meta keys * - * @param string $option - * @param string $key + * @param string $option Option key. + * @param string $key Internal key to import over. */ private function import_custom_values( $option, $key ) { // Import the custom homepage description. diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-import-wpseo.php b/wp/wp-content/plugins/wordpress-seo/admin/class-import-wpseo.php new file mode 100644 index 00000000..31579244 --- /dev/null +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-import-wpseo.php @@ -0,0 +1,186 @@ +import_post_metas(); + $this->import_taxonomy_metas(); + + $this->set_msg( + __( + sprintf( + 'wpSEO data successfully imported. Would you like to %sdisable the wpSEO plugin%s?', + '', + '' + ), + 'wordpress-seo' + ) + ); + + } + + /** + * Import the post meta values to Yoast SEO by replacing the wpSEO fields by Yoast SEO fields + */ + private function import_post_metas() { + WPSEO_Meta::replace_meta( '_wpseo_edit_title', WPSEO_Meta::$meta_prefix . 'title', $this->replace ); + WPSEO_Meta::replace_meta( '_wpseo_edit_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace ); + WPSEO_Meta::replace_meta( '_wpseo_edit_keywords', WPSEO_Meta::$meta_prefix . 'keywords', $this->replace ); + WPSEO_Meta::replace_meta( '_wpseo_edit_canonical', WPSEO_Meta::$meta_prefix . 'canonical', $this->replace ); + + $this->import_post_robots(); + } + + /** + * Importing the robot values from WPSEO plugin. These have to be converted to the Yoast format. + */ + private function import_post_robots() { + $query_posts = new WP_Query( 'post_type=any&meta_key=_wpseo_edit_robots&order=ASC' ); + + if ( ! empty( $query_posts->posts ) ) { + foreach ( $query_posts->posts as $post ) { + $this->import_post_robot( $post->ID ); + } + } + } + + /** + * Getting the wpSEO robot value and map this to Yoast SEO values. + * + * @param integer $post_id The post id of the current post. + */ + private function import_post_robot( $post_id ) { + $wpseo_robots = get_post_meta( $post_id, '_wpseo_edit_robots', true ); + + // Does the value exists in our mapping. + if ( $robot_value = $this->get_robot_value( $wpseo_robots ) ) { + // Saving the new meta values for Yoast SEO. + WPSEO_Meta::set_value( $robot_value['index'], 'meta-robots-noindex', $post_id ); + WPSEO_Meta::set_value( $robot_value['follow'], 'meta-robots-nofollow', $post_id ); + } + + $this->delete_post_robot( $post_id ); + } + + /** + * Delete the wpSEO robot values, because they aren't needed anymore. + * + * @param integer $post_id The post id of the current post. + */ + private function delete_post_robot( $post_id ) { + if ( $this->replace ) { + delete_post_meta( $post_id, '_wpseo_edit_robots' ); + } + } + + /** + * Import the taxonomy metas from wpSEO + */ + private function import_taxonomy_metas() { + $terms = get_terms( get_taxonomies(), array( 'hide_empty' => false ) ); + $tax_meta = get_option( 'wpseo_taxonomy_meta' ); + + foreach ( $terms as $term ) { + $this->import_taxonomy_description( $tax_meta, $term->taxonomy, $term->term_id ); + $this->import_taxonomy_robots( $tax_meta, $term->taxonomy, $term->term_id ); + $this->delete_taxonomy_metas( $term->taxonomy, $term->term_id ); + } + + update_option( 'wpseo_taxonomy_meta', $tax_meta ); + } + + /** + * Import the meta description to Yoast SEO + * + * @param array $tax_meta The array with the current metadata. + * @param string $taxonomy String with the name of the taxonomy. + * @param string $term_id The ID of the current term. + */ + private function import_taxonomy_description( & $tax_meta, $taxonomy, $term_id ) { + $description = get_option( 'wpseo_' . $taxonomy . '_' . $term_id, false ); + if ( $description !== false ) { + // Import description. + $tax_meta[ $taxonomy ][ $term_id ]['wpseo_desc'] = $description; + } + } + + /** + * Import the robot value to Yoast SEO + * + * @param array $tax_meta The array with the current metadata. + * @param string $taxonomy String with the name of the taxonomy. + * @param string $term_id The ID of the current term. + */ + private function import_taxonomy_robots( & $tax_meta, $taxonomy, $term_id ) { + $wpseo_robots = get_option( 'wpseo_' . $taxonomy . '_' . $term_id . '_robots', false ); + if ( $wpseo_robots !== false ) { + // The value 1, 2 and 6 are the index values in wpSEO. + $new_robot_value = ( in_array( $wpseo_robots, array( 1, 2, 6 ) ) ) ? 'index' : 'noindex'; + + $tax_meta[ $taxonomy ][ $term_id ]['wpseo_noindex'] = $new_robot_value; + } + } + + /** + * Delete the wpSEO taxonomy meta data. + * + * @param string $taxonomy String with the name of the taxonomy. + * @param string $term_id The ID of the current term. + */ + private function delete_taxonomy_metas( $taxonomy, $term_id ) { + if ( $this->replace ) { + delete_option( 'wpseo_' . $taxonomy . '_' . $term_id ); + delete_option( 'wpseo_' . $taxonomy . '_' . $term_id . '_robots' ); + } + } + + /** + * Getting the robot config by given wpSEO robots value. + * + * @param string $wpseo_robots The value in wpSEO that needs to be converted to the Yoast format. + * + * @return array + */ + private function get_robot_value( $wpseo_robots ) { + static $robot_values; + + if ( $robot_values === null ) { + /** + * The values 1 - 6 are the configured values from wpSEO. This array will map the values of wpSEO to our values. + * + * There are some double array like 1-6 and 3-4. The reason is they only set the index value. The follow value is + * the default we use in the cases there isn't a follow value present. + * + * @var array + */ + $robot_values = array( + 1 => array( 'index' => 2, 'follow' => 0 ), // In wpSEO: index, follow. + 2 => array( 'index' => 2, 'follow' => 1 ), // In wpSEO: index, nofollow. + 3 => array( 'index' => 1, 'follow' => 0 ), // In wpSEO: noindex. + 4 => array( 'index' => 1, 'follow' => 0 ), // In wpSEO: noindex, follow. + 5 => array( 'index' => 1, 'follow' => 1 ), // In wpSEO: noindex, nofollow. + 6 => array( 'index' => 2, 'follow' => 0 ), // In wpSEO: index. + ); + } + + if ( array_key_exists( $wpseo_robots, $robot_values ) ) { + return $robot_values[ $wpseo_robots ]; + } + + return array( 'index' => 2, 'follow' => 0 ); + } + +} diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-import.php b/wp/wp-content/plugins/wordpress-seo/admin/class-import.php index 3316bb74..31369239 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-import.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-import.php @@ -155,9 +155,9 @@ class WPSEO_Import { /** * Parse the option group and import it * - * @param string $name - * @param array $opt_group - * @param array $options + * @param string $name Name string. + * @param array $opt_group Option group data. + * @param array $options Options data. */ private function parse_option_group( $name, $opt_group, $options ) { if ( $name === 'wpseo_taxonomy_meta' ) { @@ -188,5 +188,4 @@ class WPSEO_Import { rmdir( $this->path ); } } - } diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-meta-columns.php b/wp/wp-content/plugins/wordpress-seo/admin/class-meta-columns.php new file mode 100644 index 00000000..14ce98f9 --- /dev/null +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-meta-columns.php @@ -0,0 +1,430 @@ +set_post_type_hooks(); + + add_action( 'restrict_manage_posts', array( $this, 'posts_filter_dropdown' ) ); + add_filter( 'request', array( $this, 'column_sort_orderby' ) ); + } + + /** + * Adds the column headings for the SEO plugin for edit posts / pages overview + * + * @param array $columns Already existing columns. + * + * @return array + */ + public function column_heading( $columns ) { + if ( $this->is_metabox_hidden() === true ) { + return $columns; + } + + return array_merge( $columns, array( + 'wpseo-score' => __( 'SEO', 'wordpress-seo' ), + 'wpseo-title' => __( 'SEO Title', 'wordpress-seo' ), + 'wpseo-metadesc' => __( 'Meta Desc.', 'wordpress-seo' ), + 'wpseo-focuskw' => __( 'Focus KW', 'wordpress-seo' ), + ) ); + } + + /** + * Display the column content for the given column + * + * @param string $column_name Column to display the content for. + * @param int $post_id Post to display the column content for. + */ + public function column_content( $column_name, $post_id ) { + if ( $this->is_metabox_hidden() === true ) { + return; + } + + switch ( $column_name ) { + case 'wpseo-score' : + echo $this->parse_column_score( $post_id ); + break; + case 'wpseo-title' : + echo esc_html( apply_filters( 'wpseo_title', wpseo_replace_vars( $this->page_title( $post_id ), get_post( $post_id, ARRAY_A ) ) ) ); + break; + case 'wpseo-metadesc' : + echo esc_html( apply_filters( 'wpseo_metadesc', wpseo_replace_vars( WPSEO_Meta::get_value( 'metadesc', $post_id ), get_post( $post_id, ARRAY_A ) ) ) ); + break; + case 'wpseo-focuskw' : + $focuskw = WPSEO_Meta::get_value( 'focuskw', $post_id ); + echo esc_html( $focuskw ); + break; + } + } + + /** + * Indicate which of the SEO columns are sortable. + * + * @param array $columns appended with their orderby variable. + * + * @return array + */ + public function column_sort( $columns ) { + if ( $this->is_metabox_hidden() === true ) { + return $columns; + } + + $columns['wpseo-score'] = 'wpseo-score'; + $columns['wpseo-metadesc'] = 'wpseo-metadesc'; + $columns['wpseo-focuskw'] = 'wpseo-focuskw'; + + return $columns; + } + + /** + * Hide the SEO Title, Meta Desc and Focus KW columns if the user hasn't chosen which columns to hide + * + * @param array|false $result The hidden columns. + * @param string $option The option name used to set which columns should be hidden. + * @param WP_User $user The User. + * + * @return array|false $result + */ + public function column_hidden( $result, $option, $user ) { + global $wpdb; + + $prefix = $wpdb->get_blog_prefix(); + if ( ! $user->has_prop( $prefix . $option ) && ! $user->has_prop( $option ) ) { + + if ( ! is_array( $result ) ) { + $result = array(); + } + + array_push( $result, 'wpseo-title', 'wpseo-metadesc', 'wpseo-focuskw' ); + } + + return $result; + } + + /** + * Adds a dropdown that allows filtering on the posts SEO Quality. + * + * @return void + */ + public function posts_filter_dropdown() { + if ( $GLOBALS['pagenow'] === 'upload.php' || $this->is_metabox_hidden() === true ) { + return; + } + + $ranks = WPSEO_Rank::get_all_ranks(); + $current_seo_filter = filter_input( INPUT_GET, 'seo_filter' ); + + echo ' + '; + } + + /** + * Hacky way to get round the limitation that you can only have AND *or* OR relationship between + * meta key clauses and not a combination - which is what we need. + * + * @param string $where Where clause. + * + * @return string + */ + public function seo_score_posts_where( $where ) { + global $wpdb; + + /* Find the two mutually exclusive noindex clauses which should be changed from AND to OR relation */ + $find = '`([\s]+AND[\s]+)((?:' . $wpdb->prefix . 'postmeta|mt[0-9]|mt1)\.post_id IS NULL[\s]+)AND([\s]+\([\s]*(?:' . $wpdb->prefix . 'postmeta|mt[0-9])\.meta_key = \'' . WPSEO_Meta::$meta_prefix . 'meta-robots-noindex\' AND CAST\([^\)]+\)[^\)]+\))`'; + + $replace = '$1( $2OR$3 )'; + + $new_where = preg_replace( $find, $replace, $where ); + + if ( $new_where ) { + return $new_where; + } + return $where; + } + + /** + * Modify the query based on the seo_filter variable in $_GET + * + * @param array $vars Query variables. + * + * @return array + */ + public function column_sort_orderby( $vars ) { + if ( $seo_filter = filter_input( INPUT_GET, 'seo_filter' ) ) { + $rank = new WPSEO_Rank( $seo_filter ); + + if ( WPSEO_Rank::NO_FOCUS === $seo_filter || WPSEO_Rank::NO_INDEX === $seo_filter ) { + $vars = $this->filter_other( $vars, $seo_filter ); + } + else { + $vars = array_merge( $vars, $this->filter_scored( $rank->get_starting_score(), $rank->get_end_score() ) ); + + add_filter( 'posts_where', array( $this, 'seo_score_posts_where' ) ); + } + } + + if ( $seo_kw_filter = filter_input( INPUT_GET, 'seo_kw_filter' ) ) { + $vars = array_merge( + $vars, array( + 'post_type' => get_query_var( 'post_type', 'post' ), + 'meta_key' => WPSEO_Meta::$meta_prefix . 'focuskw', + 'meta_value' => sanitize_text_field( $seo_kw_filter ), + ) + ); + } + + if ( isset( $vars['orderby'] ) ) { + $vars = array_merge( $vars, $this->filter_order_by( $vars['orderby'] ) ); + } + + return $vars; + } + + /** + * When there is a score just return this meta query array + * + * @param string $low The lowest number in the score range. + * @param string $high The highest number in the score range. + * + * @return array + */ + private function filter_scored( $low, $high ) { + /** + * @internal DON'T touch the order of these without double-checking/adjusting the seo_score_posts_where() method below! + */ + return array( + 'meta_query' => array( + 'relation' => 'AND', + array( + 'key' => WPSEO_Meta::$meta_prefix . 'linkdex', + 'value' => array( $low, $high ), + 'type' => 'numeric', + 'compare' => 'BETWEEN', + ), + array( + 'key' => WPSEO_Meta::$meta_prefix . 'meta-robots-noindex', + 'value' => 'needs-a-value-anyway', + 'compare' => 'NOT EXISTS', + ), + array( + 'key' => WPSEO_Meta::$meta_prefix . 'meta-robots-noindex', + 'value' => '1', + 'compare' => '!=', + ), + ), + ); + } + + /** + * Get vars for noindex or na filters + * + * @param array $vars The unmerged vars. + * @param string $seo_filter The SEO filter. + * + * @return array + */ + private function filter_other( $vars, $seo_filter ) { + switch ( $seo_filter ) { + case 'noindex': + $vars = array_merge( + $vars, + array( + 'meta_query' => array( + array( + 'key' => WPSEO_Meta::$meta_prefix . 'meta-robots-noindex', + 'value' => '1', + 'compare' => '=', + ), + ), + ) + ); + break; + case 'na': + $vars = array_merge( + $vars, + array( + 'meta_query' => array( + 'relation' => 'OR', + array( + 'key' => WPSEO_Meta::$meta_prefix . 'linkdex', + 'value' => 'needs-a-value-anyway', + 'compare' => 'NOT EXISTS', + ) + ), + ) + ); + break; + } + + return $vars; + } + + /** + * Returning filters when $order_by is matched in the if-statement + * + * @param string $order_by The ID of the column by which to order the posts. + * + * @return array + */ + private function filter_order_by( $order_by ) { + switch ( $order_by ) { + case 'wpseo-score' : + return array( + 'meta_key' => WPSEO_Meta::$meta_prefix . 'linkdex', + 'orderby' => 'meta_value_num', + ); + break; + case 'wpseo-metadesc' : + return array( + 'meta_key' => WPSEO_Meta::$meta_prefix . 'metadesc', + 'orderby' => 'meta_value', + ); + break; + case 'wpseo-focuskw' : + return array( + 'meta_key' => WPSEO_Meta::$meta_prefix . 'focuskw', + 'orderby' => 'meta_value', + ); + break; + } + + return array(); + } + + /** + * Parsing the score column + * + * @param integer $post_id The ID of the post for which to show the score. + * + * @return string + */ + private function parse_column_score( $post_id ) { + if ( '1' === WPSEO_Meta::get_value( 'meta-robots-noindex', $post_id ) ) { + $rank = new WPSEO_Rank( WPSEO_Rank::NO_INDEX ); + $title = __( 'Post is set to noindex.', 'wordpress-seo' ); + WPSEO_Meta::set_value( 'linkdex', 0, $post_id ); + } + elseif ( '' === WPSEO_Meta::get_value( 'focuskw', $post_id ) ) { + $rank = new WPSEO_Rank( WPSEO_Rank::NO_FOCUS ); + $title = __( 'Focus keyword not set.', 'wordpress-seo' ); + } + else { + $score = (int) WPSEO_Meta::get_value( 'linkdex', $post_id ); + $rank = WPSEO_Rank::from_numeric_score( $score ); + $title = $rank->get_label(); + } + + return '
'; + + } + + /** + * Setting the hooks for the post_types + */ + private function set_post_type_hooks() { + $post_types = get_post_types( array( 'public' => true ), 'names' ); + + if ( is_array( $post_types ) && $post_types !== array() ) { + foreach ( $post_types as $pt ) { + if ( $this->is_metabox_hidden( $pt ) === false ) { + add_filter( 'manage_' . $pt . '_posts_columns', array( $this, 'column_heading' ), 10, 1 ); + add_action( 'manage_' . $pt . '_posts_custom_column', array( + $this, + 'column_content', + ), 10, 2 ); + add_action( 'manage_edit-' . $pt . '_sortable_columns', array( + $this, + 'column_sort', + ), 10, 2 ); + + /* + * Use the `get_user_option_{$option}` filter to change the output of the get_user_option + * function for the `manage{$screen}columnshidden` option, which is based on the current + * admin screen. The admin screen we want to target is the `edit-{$post_type}` screen. + */ + $filter = sprintf( 'get_user_option_%s', sprintf( 'manage%scolumnshidden', 'edit-' . $pt ) ); + add_filter( $filter, array( $this, 'column_hidden' ), 10, 3 ); + } + } + unset( $pt ); + } + } + + /** + * Test whether the metabox should be hidden either by choice of the admin or because + * the post type is not a public post type + * + * @since 1.5.0 + * + * @param string $post_type (optional) The post type to test, defaults to the current post post_type. + * + * @return bool Whether or not the meta box (and associated columns etc) should be hidden + */ + private function is_metabox_hidden( $post_type = null ) { + if ( ! isset( $post_type ) && $get_post_type = filter_input( INPUT_GET, 'post_type' ) ) { + $post_type = sanitize_text_field( $get_post_type ); + } + + if ( isset( $post_type ) ) { + // Don't make static as post_types may still be added during the run. + $cpts = get_post_types( array( 'public' => true ), 'names' ); + $options = get_option( 'wpseo_titles' ); + + return ( ( isset( $options[ 'hideeditbox-' . $post_type ] ) && $options[ 'hideeditbox-' . $post_type ] === true ) || in_array( $post_type, $cpts ) === false ); + } + + return false; + } + + /** + * Retrieve the page title. + * + * @param int $post_id Post to retrieve the title for. + * + * @return string + */ + private function page_title( $post_id ) { + $fixed_title = WPSEO_Meta::get_value( 'title', $post_id ); + if ( $fixed_title !== '' ) { + return $fixed_title; + } + + $post = get_post( $post_id ); + $options = WPSEO_Options::get_all(); + if ( is_object( $post ) && ( isset( $options[ 'title-' . $post->post_type ] ) && $options[ 'title-' . $post->post_type ] !== '' ) ) { + $title_template = $options[ 'title-' . $post->post_type ]; + $title_template = str_replace( ' %%page%% ', ' ', $title_template ); + + return wpseo_replace_vars( $title_template, $post ); + } + + return wpseo_replace_vars( '%%title%%', $post ); + } + +} diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-metabox.php b/wp/wp-content/plugins/wordpress-seo/admin/class-metabox.php deleted file mode 100644 index 1f5139ab..00000000 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-metabox.php +++ /dev/null @@ -1,2303 +0,0 @@ -
Read %sthis post%s for more info.', 'wordpress-seo' ), '', '' ); - - self::$meta_fields['general']['focuskw']['title'] = __( 'Focus Keyword', 'wordpress-seo' ); - self::$meta_fields['general']['focuskw']['help'] = sprintf( __( 'Pick the main keyword or keyphrase that this post/page is about.

Read %sthis post%s for more info.', 'wordpress-seo' ), '', '' ); - - self::$meta_fields['general']['title']['title'] = __( 'SEO Title', 'wordpress-seo' ); - self::$meta_fields['general']['title']['description'] = '

' . __( 'Warning:', 'wordpress-seo' ) . ' ' . __( 'Title display in Google is limited to a fixed width, yours is too long.', 'wordpress-seo' ) . '

'; - self::$meta_fields['general']['title']['help'] = __( 'The SEO title defaults to what is generated based on this sites title template for this posttype.', 'wordpress-seo' ); - - self::$meta_fields['general']['metadesc']['title'] = __( 'Meta description', 'wordpress-seo' ); - self::$meta_fields['general']['metadesc']['description'] = sprintf( __( 'The meta description will be limited to %s chars%s, %s chars left.', 'wordpress-seo' ), self::$meta_length, self::$meta_length_reason, '' ) . '
'; - self::$meta_fields['general']['metadesc']['help'] = sprintf( __( 'The meta description is often shown as the black text under the title in a search result. For this to work it has to contain the keyword that was searched for.

Read %sthis post%s for more info.', 'wordpress-seo' ), '', '' ); - - self::$meta_fields['general']['metakeywords']['title'] = __( 'Meta keywords', 'wordpress-seo' ); - self::$meta_fields['general']['metakeywords']['description'] = __( 'If you type something above it will override your %smeta keywords template%s.', 'wordpress-seo' ); - - - self::$meta_fields['advanced']['meta-robots-noindex']['title'] = __( 'Meta Robots Index', 'wordpress-seo' ); - if ( '0' == get_option( 'blog_public' ) ) { - self::$meta_fields['advanced']['meta-robots-noindex']['description'] = '

' . __( 'Warning: even though you can set the meta robots setting here, the entire site is set to noindex in the sitewide privacy settings, so these settings won\'t have an effect.', 'wordpress-seo' ) . '

'; - } - self::$meta_fields['advanced']['meta-robots-noindex']['options']['0'] = __( 'Default for post type, currently: %s', 'wordpress-seo' ); - self::$meta_fields['advanced']['meta-robots-noindex']['options']['2'] = __( 'index', 'wordpress-seo' ); - self::$meta_fields['advanced']['meta-robots-noindex']['options']['1'] = __( 'noindex', 'wordpress-seo' ); - - self::$meta_fields['advanced']['meta-robots-nofollow']['title'] = __( 'Meta Robots Follow', 'wordpress-seo' ); - self::$meta_fields['advanced']['meta-robots-nofollow']['options']['0'] = __( 'Follow', 'wordpress-seo' ); - self::$meta_fields['advanced']['meta-robots-nofollow']['options']['1'] = __( 'Nofollow', 'wordpress-seo' ); - - self::$meta_fields['advanced']['meta-robots-adv']['title'] = __( 'Meta Robots Advanced', 'wordpress-seo' ); - self::$meta_fields['advanced']['meta-robots-adv']['description'] = __( 'Advanced meta robots settings for this page.', 'wordpress-seo' ); - self::$meta_fields['advanced']['meta-robots-adv']['options']['-'] = __( 'Site-wide default: %s', 'wordpress-seo' ); - self::$meta_fields['advanced']['meta-robots-adv']['options']['none'] = __( 'None', 'wordpress-seo' ); - self::$meta_fields['advanced']['meta-robots-adv']['options']['noodp'] = __( 'NO ODP', 'wordpress-seo' ); - self::$meta_fields['advanced']['meta-robots-adv']['options']['noydir'] = __( 'NO YDIR', 'wordpress-seo' ); - self::$meta_fields['advanced']['meta-robots-adv']['options']['noimageindex'] = __( 'No Image Index', 'wordpress-seo' ); - self::$meta_fields['advanced']['meta-robots-adv']['options']['noarchive'] = __( 'No Archive', 'wordpress-seo' ); - self::$meta_fields['advanced']['meta-robots-adv']['options']['nosnippet'] = __( 'No Snippet', 'wordpress-seo' ); - - self::$meta_fields['advanced']['bctitle']['title'] = __( 'Breadcrumbs Title', 'wordpress-seo' ); - self::$meta_fields['advanced']['bctitle']['description'] = __( 'Title to use for this page in breadcrumb paths', 'wordpress-seo' ); - - self::$meta_fields['advanced']['canonical']['title'] = __( 'Canonical URL', 'wordpress-seo' ); - self::$meta_fields['advanced']['canonical']['description'] = sprintf( __( 'The canonical URL that this page should point to, leave empty to default to permalink. %sCross domain canonical%s supported too.', 'wordpress-seo' ), '', '' ); - - self::$meta_fields['advanced']['redirect']['title'] = __( '301 Redirect', 'wordpress-seo' ); - self::$meta_fields['advanced']['redirect']['description'] = __( 'The URL that this page should redirect to.', 'wordpress-seo' ); - - do_action( 'wpseo_tab_translate' ); - } - - /** - * Test whether the metabox should be hidden either by choice of the admin or because - * the post type is not a public post type - * - * @since 1.5.0 - * - * @param string $post_type (optional) The post type to test, defaults to the current post post_type. - * - * @return bool Whether or not the meta box (and associated columns etc) should be hidden - */ - function is_metabox_hidden( $post_type = null ) { - if ( ! isset( $post_type ) ) { - if ( isset( $GLOBALS['post'] ) && ( is_object( $GLOBALS['post'] ) && isset( $GLOBALS['post']->post_type ) ) ) { - $post_type = $GLOBALS['post']->post_type; - } - elseif ( isset( $_GET['post_type'] ) && $_GET['post_type'] !== '' ) { - $post_type = sanitize_text_field( $_GET['post_type'] ); - } - } - - if ( isset( $post_type ) ) { - // Don't make static as post_types may still be added during the run. - $cpts = get_post_types( array( 'public' => true ), 'names' ); - $options = get_option( 'wpseo_titles' ); - - return ( ( isset( $options[ 'hideeditbox-' . $post_type ] ) && $options[ 'hideeditbox-' . $post_type ] === true ) || in_array( $post_type, $cpts ) === false ); - } - return false; - } - - /** - * Sets up all the functionality related to the prominence of the page analysis functionality. - */ - public function setup_page_analysis() { - - if ( apply_filters( 'wpseo_use_page_analysis', true ) === true ) { - - $post_types = get_post_types( array( 'public' => true ), 'names' ); - - if ( is_array( $post_types ) && $post_types !== array() ) { - foreach ( $post_types as $pt ) { - if ( $this->is_metabox_hidden( $pt ) === false ) { - add_filter( 'manage_' . $pt . '_posts_columns', array( $this, 'column_heading' ), 10, 1 ); - add_action( 'manage_' . $pt . '_posts_custom_column', array( - $this, - 'column_content', - ), 10, 2 ); - add_action( 'manage_edit-' . $pt . '_sortable_columns', array( - $this, - 'column_sort', - ), 10, 2 ); - - /* - * Use the `get_user_option_{$option}` filter to change the output of the get_user_option - * function for the `manage{$screen}columnshidden` option, which is based on the current - * admin screen. The admin screen we want to target is the `edit-{$post_type}` screen. - */ - $filter = sprintf( 'get_user_option_%s', sprintf( 'manage%scolumnshidden', 'edit-' . $pt ) ); - add_filter( $filter, array( $this, 'column_hidden' ), 10, 3 ); - } - } - unset( $pt ); - } - add_action( 'restrict_manage_posts', array( $this, 'posts_filter_dropdown' ) ); - add_filter( 'request', array( $this, 'column_sort_orderby' ) ); - - add_action( 'post_submitbox_misc_actions', array( $this, 'publish_box' ) ); - } - } - - /** - * Get an instance of the text statistics class - * - * @return Yoast_TextStatistics - */ - private function statistics() { - if ( ! isset( $this->statistics ) ) { - $this->statistics = new Yoast_TextStatistics( get_bloginfo( 'charset' ) ); - } - - return $this->statistics; - } - - /** - * Returns post in metabox context - * - * @returns WP_Post - */ - private function get_metabox_post() { - if ( isset( $_GET['post'] ) ) { - $post_id = (int) WPSEO_Utils::validate_int( $_GET['post'] ); - $post = get_post( $post_id ); - } - else { - $post = $GLOBALS['post']; - } - - return $post; - } - - /** - * Lowercase a sentence while preserving "weird" characters. - * - * This should work with Greek, Russian, Polish & French amongst other languages... - * - * @param string $string String to lowercase. - * - * @return string - */ - public function strtolower_utf8( $string ) { - - // Prevent comparison between utf8 characters and html entities (é vs é). - $string = html_entity_decode( $string ); - - $convert_to = array( - 'a', - 'b', - 'c', - 'd', - 'e', - 'f', - 'g', - 'h', - 'i', - 'j', - 'k', - 'l', - 'm', - 'n', - 'o', - 'p', - 'q', - 'r', - 's', - 't', - 'u', - 'v', - 'w', - 'x', - 'y', - 'z', - 'à', - 'á', - 'â', - 'ã', - 'ä', - 'å', - 'æ', - 'ç', - 'è', - 'é', - 'ê', - 'ë', - 'ì', - 'í', - 'î', - 'ï', - 'ð', - 'ñ', - 'ò', - 'ó', - 'ô', - 'õ', - 'ö', - 'ø', - 'ù', - 'ú', - 'û', - 'ü', - 'ý', - 'а', - 'б', - 'в', - 'г', - 'д', - 'е', - 'ё', - 'ж', - 'з', - 'и', - 'й', - 'к', - 'л', - 'м', - 'н', - 'о', - 'п', - 'р', - 'с', - 'т', - 'у', - 'ф', - 'х', - 'ц', - 'ч', - 'ш', - 'щ', - 'ъ', - 'ы', - 'ь', - 'э', - 'ю', - 'я', - 'ą', - 'ć', - 'ę', - 'ł', - 'ń', - 'ó', - 'ś', - 'ź', - 'ż', - ); - $convert_from = array( - 'A', - 'B', - 'C', - 'D', - 'E', - 'F', - 'G', - 'H', - 'I', - 'J', - 'K', - 'L', - 'M', - 'N', - 'O', - 'P', - 'Q', - 'R', - 'S', - 'T', - 'U', - 'V', - 'W', - 'X', - 'Y', - 'Z', - 'À', - 'Á', - 'Â', - 'Ã', - 'Ä', - 'Å', - 'Æ', - 'Ç', - 'È', - 'É', - 'Ê', - 'Ë', - 'Ì', - 'Í', - 'Î', - 'Ï', - 'Ð', - 'Ñ', - 'Ò', - 'Ó', - 'Ô', - 'Õ', - 'Ö', - 'Ø', - 'Ù', - 'Ú', - 'Û', - 'Ü', - 'Ý', - 'А', - 'Б', - 'В', - 'Г', - 'Д', - 'Е', - 'Ё', - 'Ж', - 'З', - 'И', - 'Й', - 'К', - 'Л', - 'М', - 'Н', - 'О', - 'П', - 'Р', - 'С', - 'Т', - 'У', - 'Ф', - 'Х', - 'Ц', - 'Ч', - 'Ш', - 'Щ', - 'Ъ', - 'Ъ', - 'Ь', - 'Э', - 'Ю', - 'Я', - 'Ą', - 'Ć', - 'Ę', - 'Ł', - 'Ń', - 'Ó', - 'Ś', - 'Ź', - 'Ż', - ); - - return str_replace( $convert_from, $convert_to, $string ); - } - - /** - * Outputs the page analysis score in the Publish Box. - */ - public function publish_box() { - if ( $this->is_metabox_hidden() === true ) { - return; - } - - - $post = $this->get_metabox_post(); - - if ( self::get_value( 'meta-robots-noindex', $post->ID ) === '1' ) { - $score_label = 'noindex'; - $title = __( 'Post is set to noindex.', 'wordpress-seo' ); - $score_title = $title; - } - else { - - $score = ''; - $results = $this->calculate_results( $post ); - if ( ! is_wp_error( $results ) && isset( $results['total'] ) ) { - $score = $results['total']; - unset( $results ); - } - - if ( $score === '' ) { - $score_label = 'na'; - $title = __( 'No focus keyword set.', 'wordpress-seo' ); - } - else { - $score_label = WPSEO_Utils::translate_score( $score ); - } - - $score_title = WPSEO_Utils::translate_score( $score, false ); - if ( ! isset( $title ) ) { - $title = $score_title; - } - } - - printf( ' -
-
- %3$s %4$s - %5$s -
', - esc_attr( $title ), - esc_attr( 'wpseo-score-icon ' . $score_label ), - __( 'SEO:', 'wordpress-seo' ), - $score_title, - __( 'Check', 'wordpress-seo' ) - ); - } - - /** - * Adds the Yoast SEO meta box to the edit boxes in the edit post / page / cpt pages. - */ - public function add_meta_box() { - $post_types = get_post_types( array( 'public' => true ) ); - - if ( is_array( $post_types ) && $post_types !== array() ) { - foreach ( $post_types as $post_type ) { - if ( $this->is_metabox_hidden( $post_type ) === false ) { - add_meta_box( 'wpseo_meta', 'Yoast SEO', array( - $this, - 'meta_box', - ), $post_type, 'normal', apply_filters( 'wpseo_metabox_prio', 'high' ) ); - } - } - } - } - - /** - * Pass some variables to js for the edit / post page overview, snippet preview, etc. - * - * @return array - */ - public function localize_script() { - $post = $this->get_metabox_post(); - - if ( ( ! is_object( $post ) || ! isset( $post->post_type ) ) || $this->is_metabox_hidden( $post->post_type ) === true ) { - return array(); - } - - $options = get_option( 'wpseo_titles' ); - - $date = ''; - if ( isset( $options[ 'showdate-' . $post->post_type ] ) && $options[ 'showdate-' . $post->post_type ] === true ) { - $date = $this->get_post_date( $post ); - - self::$meta_length = ( self::$meta_length - ( strlen( $date ) + 5 ) ); - self::$meta_length_reason = __( ' (because of date display)', 'wordpress-seo' ); - } - - self::$meta_length_reason = apply_filters( 'wpseo_metadesc_length_reason', self::$meta_length_reason, $post ); - self::$meta_length = apply_filters( 'wpseo_metadesc_length', self::$meta_length, $post ); - - unset( $date ); - - $title_template = ''; - if ( isset( $options[ 'title-' . $post->post_type ] ) && $options[ 'title-' . $post->post_type ] !== '' ) { - $title_template = $options[ 'title-' . $post->post_type ]; - } - - // If there's no title template set, use the default, otherwise title preview won't work. - if ( $title_template == '' ) { - $title_template = '%%title%% - %%sitename%%'; - } - - $metadesc_template = ''; - if ( isset( $options[ 'metadesc-' . $post->post_type ] ) && $options[ 'metadesc-' . $post->post_type ] !== '' ) { - $metadesc_template = $options[ 'metadesc-' . $post->post_type ]; - } - - $sample_permalink = get_sample_permalink( $post->ID ); - $sample_permalink = str_replace( '%page', '%post', $sample_permalink[0] ); - - $cached_replacement_vars = array(); - - $vars_to_cache = array( - 'date', - 'id', - 'sitename', - 'sitedesc', - 'sep', - 'page', - 'currenttime', - 'currentdate', - 'currentday', - 'currentmonth', - 'currentyear', - ); - foreach ( $vars_to_cache as $var ) { - $cached_replacement_vars[ $var ] = wpseo_replace_vars( '%%' . $var . '%%', $post ); - } - - return array_merge( $cached_replacement_vars, array( - 'field_prefix' => self::$form_prefix, - 'keyword_header' => '' . __( 'Focus keyword usage', 'wordpress-seo' ) . '
' . __( 'Your focus keyword was found in:', 'wordpress-seo' ), - 'article_header_text' => __( 'Article Heading: ', 'wordpress-seo' ), - 'page_title_text' => __( 'Page title: ', 'wordpress-seo' ), - 'page_url_text' => __( 'Page URL: ', 'wordpress-seo' ), - 'content_text' => __( 'Content: ', 'wordpress-seo' ), - 'meta_description_text' => __( 'Meta description: ', 'wordpress-seo' ), - 'choose_image' => __( 'Use Image', 'wordpress-seo' ), - 'wpseo_meta_desc_length' => self::$meta_length, - 'wpseo_title_template' => $title_template, - 'wpseo_metadesc_template' => $metadesc_template, - 'wpseo_permalink_template' => $sample_permalink, - 'wpseo_keyword_suggest_nonce' => wp_create_nonce( 'wpseo-get-suggest' ), - 'wpseo_replace_vars_nonce' => wp_create_nonce( 'wpseo-replace-vars' ), - 'no_parent_text' => __( '(no parent)', 'wordpress-seo' ), - 'featured_image_notice' => __( 'The featured image should be at least 200x200 pixels to be picked up by Facebook and other social media sites.', 'wordpress-seo' ), - ) ); - } - - /** - * Output a tab in the Yoast SEO Metabox - * - * @param string $id CSS ID of the tab. - * @param string $heading Heading for the tab. - * @param string $content Content of the tab. This content should be escaped. - */ - public function do_tab( $id, $heading, $content ) { - ?> -
-

- - -
-
- get_metabox_post(); - $options = WPSEO_Options::get_all(); - - ?> -
-
    -
  • -
  • -
  • - -
  • - -
  • - -
  • - - -
- post_type ) ) { - foreach ( $this->get_meta_field_defs( 'general', $post->post_type ) as $key => $meta_field ) { - $content .= $this->do_meta_box( $meta_field, $key ); - } - unset( $key, $meta_field ); - } - $this->do_tab( 'general', __( 'General', 'wordpress-seo' ), $content ); - - $this->do_tab( 'linkdex', __( 'Page Analysis', 'wordpress-seo' ), $this->linkdex_output( $post ) ); - - if ( current_user_can( 'manage_options' ) || $options['disableadvanced_meta'] === false ) { - $content = ''; - foreach ( $this->get_meta_field_defs( 'advanced' ) as $key => $meta_field ) { - $content .= $this->do_meta_box( $meta_field, $key ); - } - unset( $key, $meta_field ); - $this->do_tab( 'advanced', __( 'Advanced', 'wordpress-seo' ), $content ); - } - - do_action( 'wpseo_tab_content' ); - - echo '
'; - } - - /** - * Adds a line in the meta box - * - * @todo [JRF] check if $class is added appropriately everywhere - * - * @param array $meta_field_def Contains the vars based on which output is generated. - * @param string $key Internal key (without prefix). - * - * @return string - */ - function do_meta_box( $meta_field_def, $key = '' ) { - $content = ''; - $esc_form_key = esc_attr( self::$form_prefix . $key ); - $post = $this->get_metabox_post(); - $meta_value = self::get_value( $key, $post->ID ); - - $class = ''; - if ( isset( $meta_field_def['class'] ) && $meta_field_def['class'] !== '' ) { - $class = ' ' . $meta_field_def['class']; - } - - $placeholder = ''; - if ( isset( $meta_field_def['placeholder'] ) && $meta_field_def['placeholder'] !== '' ) { - $placeholder = $meta_field_def['placeholder']; - } - - switch ( $meta_field_def['type'] ) { - case 'snippetpreview': - $content .= $this->snippet(); - break; - - case 'text': - $ac = ''; - if ( isset( $meta_field_def['autocomplete'] ) && $meta_field_def['autocomplete'] === false ) { - $ac = 'autocomplete="off" '; - } - if ( $placeholder !== '' ) { - $placeholder = ' placeholder="' . esc_attr( $placeholder ) . '"'; - } - $content .= '
'; - break; - - case 'textarea': - $rows = 3; - if ( isset( $meta_field_def['rows'] ) && $meta_field_def['rows'] > 0 ) { - $rows = $meta_field_def['rows']; - } - $content .= ''; - break; - - case 'select': - if ( isset( $meta_field_def['options'] ) && is_array( $meta_field_def['options'] ) && $meta_field_def['options'] !== array() ) { - $content .= ''; - } - break; - - case 'multiselect': - if ( isset( $meta_field_def['options'] ) && is_array( $meta_field_def['options'] ) && $meta_field_def['options'] !== array() ) { - - // Set $meta_value as $selected_arr. - $selected_arr = $meta_value; - - // If the multiselect field is 'meta-robots-adv' we should explode on ,. - if ( 'meta-robots-adv' === $key ) { - $selected_arr = explode( ',', $meta_value ); - } - - if ( ! is_array( $selected_arr ) ) { - $selected_arr = (array) $selected_arr; - } - - $options_count = count( $meta_field_def['options'] ); - - // @todo [JRF => whomever] verify height calculation for older WP versions, was 16x, for WP3.8 20x is more appropriate. - $content .= ''; - unset( $val, $option, $selected, $selected_arr, $options_count ); - } - break; - - case 'checkbox': - $checked = checked( $meta_value, 'on', false ); - $expl = ( isset( $meta_field_def['expl'] ) ) ? esc_html( $meta_field_def['expl'] ) : ''; - $content .= '
'; - unset( $checked, $expl ); - break; - - case 'radio': - if ( isset( $meta_field_def['options'] ) && is_array( $meta_field_def['options'] ) && $meta_field_def['options'] !== array() ) { - foreach ( $meta_field_def['options'] as $val => $option ) { - $checked = checked( $meta_value, $val, false ); - $content .= ' '; - } - unset( $val, $option, $checked ); - } - break; - - case 'upload': - $content .= ''; - $content .= ''; - break; - } - - - $html = ''; - if ( $content === '' ) { - $content = apply_filters( 'wpseo_do_meta_box_field_' . $key, $content, $meta_value, $esc_form_key, $meta_field_def, $key ); - } - - if ( $content !== '' ) { - - $label = esc_html( $meta_field_def['title'] ); - if ( in_array( $meta_field_def['type'], array( - 'snippetpreview', - 'radio', - 'checkbox', - ), true ) === false - ) { - $label = ''; - } - - $help = ''; - if ( isset( $meta_field_def['help'] ) && $meta_field_def['help'] !== '' ) { - $help = '' . esc_attr( $meta_field_def['help'] ) . ''; - } - - $html = ' - - ' . $label . $help . ' - '; - - $html .= $content; - - if ( isset( $meta_field_def['description'] ) ) { - $html .= '
' . $meta_field_def['description'] . '
'; - } - - $html .= ' - - '; - } - - return $html; - } - - /** - * Retrieve a post date when post is published, or return current date when it's not. - * - * @param object $post Post to retrieve the date for. - * - * @return string - */ - function get_post_date( $post ) { - if ( isset( $post->post_date ) && $post->post_status == 'publish' ) { - $date = date_i18n( 'j M Y', strtotime( $post->post_date ) ); - } - else { - $date = date_i18n( 'j M Y' ); - } - - return (string) $date; - } - - /** - * Generate a snippet preview. - * - * @return string - */ - function snippet() { - $post = $this->get_metabox_post(); - $title = self::get_value( 'title', $post->ID ); - $description = self::get_value( 'metadesc', $post->ID ); - - $snippet_preview = new WPSEO_Snippet_Preview( $post, $title, $description ); - - return $snippet_preview->get_content(); - } - - /** - * Save the Yoast SEO metadata for posts. - * - * @internal $_POST parameters are validated via sanitize_post_meta() - * - * @param int $post_id - * - * @return bool|void Boolean false if invalid save post request - */ - function save_postdata( $post_id ) { - if ( $post_id === null ) { - return false; - } - - if ( wp_is_post_revision( $post_id ) ) { - $post_id = wp_is_post_revision( $post_id ); - } - - clean_post_cache( $post_id ); - $post = get_post( $post_id ); - - if ( ! is_object( $post ) ) { - // Non-existent post. - return false; - } - - do_action( 'wpseo_save_compare_data', $post ); - - $meta_boxes = apply_filters( 'wpseo_save_metaboxes', array() ); - $meta_boxes = array_merge( $meta_boxes, $this->get_meta_field_defs( 'general', $post->post_type ), $this->get_meta_field_defs( 'advanced' ) ); - - foreach ( $meta_boxes as $key => $meta_box ) { - $data = null; - if ( 'checkbox' === $meta_box['type'] ) { - $data = isset( $_POST[ self::$form_prefix . $key ] ) ? 'on' : 'off'; - } - else { - if ( isset( $_POST[ self::$form_prefix . $key ] ) ) { - $data = $_POST[ self::$form_prefix . $key ]; - } - } - if ( isset( $data ) ) { - self::set_value( $key, $data, $post_id ); - } - } - - do_action( 'wpseo_saved_postdata' ); - } - - /** - * Enqueues all the needed JS and CSS. - * @todo [JRF => whomever] create css/metabox-mp6.css file and add it to the below allowed colors array when done - */ - public function enqueue() { - global $pagenow; - /* Filter 'wpseo_always_register_metaboxes_on_admin' documented in wpseo-main.php */ - if ( ( ! in_array( $pagenow, array( - 'post-new.php', - 'post.php', - 'edit.php', - ), true ) && apply_filters( 'wpseo_always_register_metaboxes_on_admin', false ) === false ) || $this->is_metabox_hidden() === true - ) { - return; - } - - - $color = get_user_meta( get_current_user_id(), 'admin_color', true ); - if ( '' == $color || in_array( $color, array( 'classic', 'fresh' ), true ) === false ) { - $color = 'fresh'; - } - - - if ( $pagenow == 'edit.php' ) { - wp_enqueue_style( 'edit-page', plugins_url( 'css/edit-page' . WPSEO_CSSJS_SUFFIX . '.css', WPSEO_FILE ), array(), WPSEO_VERSION ); - } - else { - if ( 0 != get_queried_object_id() ) { - wp_enqueue_media( array( 'post' => get_queried_object_id() ) ); // Enqueue files needed for upload functionality. - } - wp_enqueue_style( 'metabox-tabs', plugins_url( 'css/metabox-tabs' . WPSEO_CSSJS_SUFFIX . '.css', WPSEO_FILE ), array(), WPSEO_VERSION ); - wp_enqueue_style( "metabox-$color", plugins_url( 'css/metabox-' . esc_attr( $color ) . WPSEO_CSSJS_SUFFIX . '.css', WPSEO_FILE ), array(), WPSEO_VERSION ); - wp_enqueue_style( 'featured-image', plugins_url( 'css/featured-image' . WPSEO_CSSJS_SUFFIX . '.css', WPSEO_FILE ), array(), WPSEO_VERSION ); - wp_enqueue_style( 'jquery-qtip.js', plugins_url( 'css/jquery.qtip' . WPSEO_CSSJS_SUFFIX . '.css', WPSEO_FILE ), array(), '2.2.1' ); - - // Always enqueue minified as it's not our code. - wp_enqueue_script( 'jquery-qtip', plugins_url( 'js/jquery.qtip.min.js', WPSEO_FILE ), array( 'jquery' ), '2.2.1', true ); - - wp_enqueue_script( 'wp-seo-metabox', plugins_url( 'js/wp-seo-metabox' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( - 'jquery', - 'jquery-ui-core', - ), WPSEO_VERSION, true ); - - if ( post_type_supports( get_post_type(), 'thumbnail' ) ) { - wp_enqueue_script( 'wp-seo-featured-image', plugins_url( 'js/wp-seo-featured-image' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( 'jquery' ), WPSEO_VERSION, true ); - } - - wp_enqueue_script( 'wpseo-admin-media', plugins_url( 'js/wp-seo-admin-media' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( - 'jquery', - 'jquery-ui-core', - ), WPSEO_VERSION, true ); - - wp_localize_script( 'wpseo-admin-media', 'wpseoMediaL10n', $this->localize_media_script() ); - - // Text strings to pass to metabox for keyword analysis. - wp_localize_script( 'wp-seo-metabox', 'wpseoMetaboxL10n', $this->localize_script() ); - } - } - - /** - * Pass some variables to js for upload module. - * - * @return array - */ - public function localize_media_script() { - return array( - 'choose_image' => __( 'Use Image', 'wordpress-seo' ), - ); - } - - /** - * Adds a dropdown that allows filtering on the posts SEO Quality. - * - * @return void - */ - function posts_filter_dropdown() { - if ( $GLOBALS['pagenow'] === 'upload.php' || $this->is_metabox_hidden() === true ) { - return; - } - - $scores_array = array( - 'na' => __( 'SEO: No Focus Keyword', 'wordpress-seo' ), - 'bad' => __( 'SEO: Bad', 'wordpress-seo' ), - 'poor' => __( 'SEO: Poor', 'wordpress-seo' ), - 'ok' => __( 'SEO: OK', 'wordpress-seo' ), - 'good' => __( 'SEO: Good', 'wordpress-seo' ), - 'noindex' => __( 'SEO: Post Noindexed', 'wordpress-seo' ), - ); - - echo ' - '; - } - - /** - * Adds the column headings for the SEO plugin for edit posts / pages overview - * - * @param array $columns Already existing columns. - * - * @return array - */ - function column_heading( $columns ) { - if ( $this->is_metabox_hidden() === true ) { - return $columns; - } - - return array_merge( $columns, array( - 'wpseo-score' => __( 'SEO', 'wordpress-seo' ), - 'wpseo-title' => __( 'SEO Title', 'wordpress-seo' ), - 'wpseo-metadesc' => __( 'Meta Desc.', 'wordpress-seo' ), - 'wpseo-focuskw' => __( 'Focus KW', 'wordpress-seo' ), - ) ); - } - - /** - * Display the column content for the given column - * - * @param string $column_name Column to display the content for. - * @param int $post_id Post to display the column content for. - */ - function column_content( $column_name, $post_id ) { - if ( $this->is_metabox_hidden() === true ) { - return; - } - - if ( $column_name === 'wpseo-score' ) { - $score = self::get_value( 'linkdex', $post_id ); - if ( self::get_value( 'meta-robots-noindex', $post_id ) === '1' ) { - $score_label = 'noindex'; - $title = __( 'Post is set to noindex.', 'wordpress-seo' ); - self::set_value( 'linkdex', 0, $post_id ); - } - elseif ( $score !== '' ) { - $nr = WPSEO_Utils::calc( $score, '/', 10, true ); - $score_label = WPSEO_Utils::translate_score( $nr ); - $title = WPSEO_Utils::translate_score( $nr, false ); - unset( $nr ); - } - else { - $this->calculate_results( get_post( $post_id ) ); - $score = self::get_value( 'linkdex', $post_id ); - if ( $score === '' ) { - $score_label = 'na'; - $title = __( 'Focus keyword not set.', 'wordpress-seo' ); - } - else { - $score_label = WPSEO_Utils::translate_score( $score ); - $title = WPSEO_Utils::translate_score( $score, false ); - } - } - - echo '
'; - } - if ( $column_name === 'wpseo-title' ) { - echo esc_html( apply_filters( 'wpseo_title', wpseo_replace_vars( $this->page_title( $post_id ), get_post( $post_id, ARRAY_A ) ) ) ); - } - if ( $column_name === 'wpseo-metadesc' ) { - echo esc_html( apply_filters( 'wpseo_metadesc', wpseo_replace_vars( self::get_value( 'metadesc', $post_id ), get_post( $post_id, ARRAY_A ) ) ) ); - } - if ( $column_name === 'wpseo-focuskw' ) { - $focuskw = self::get_value( 'focuskw', $post_id ); - echo esc_html( $focuskw ); - } - } - - /** - * Indicate which of the SEO columns are sortable. - * - * @param array $columns appended with their orderby variable. - * - * @return array - */ - function column_sort( $columns ) { - if ( $this->is_metabox_hidden() === true ) { - return $columns; - } - - $columns['wpseo-score'] = 'wpseo-score'; - $columns['wpseo-metadesc'] = 'wpseo-metadesc'; - $columns['wpseo-focuskw'] = 'wpseo-focuskw'; - - return $columns; - } - - /** - * Modify the query based on the seo_filter variable in $_GET - * - * @param array $vars Query variables. - * - * @return array - */ - function column_sort_orderby( $vars ) { - if ( isset( $_GET['seo_filter'] ) ) { - $na = false; - $noindex = false; - $high = false; - switch ( $_GET['seo_filter'] ) { - case 'noindex': - $low = false; - $noindex = true; - break; - case 'na': - $low = false; - $na = true; - break; - case 'bad': - $low = 1; - $high = 34; - break; - case 'poor': - $low = 35; - $high = 54; - break; - case 'ok': - $low = 55; - $high = 74; - break; - case 'good': - $low = 75; - $high = 100; - break; - default: - $low = false; - $high = false; - $noindex = false; - break; - } - if ( $low !== false ) { - /** - * @internal DON'T touch the order of these without double-checking/adjusting the seo_score_posts_where() method below! - */ - $vars = array_merge( - $vars, - array( - 'meta_query' => array( - 'relation' => 'AND', - array( - 'key' => self::$meta_prefix . 'linkdex', - 'value' => array( $low, $high ), - 'type' => 'numeric', - 'compare' => 'BETWEEN', - ), - array( - 'key' => self::$meta_prefix . 'meta-robots-noindex', - 'value' => 'needs-a-value-anyway', - 'compare' => 'NOT EXISTS', - ), - array( - 'key' => self::$meta_prefix . 'meta-robots-noindex', - 'value' => '1', - 'compare' => '!=', - ), - ), - ) - ); - - add_filter( 'posts_where', array( $this, 'seo_score_posts_where' ) ); - - } - elseif ( $na ) { - $vars = array_merge( - $vars, - array( - 'meta_query' => array( - 'relation' => 'OR', - array( - 'key' => self::$meta_prefix . 'linkdex', - 'value' => 'needs-a-value-anyway', - 'compare' => 'NOT EXISTS', - ) - ), - ) - ); - - } - elseif ( $noindex ) { - $vars = array_merge( - $vars, - array( - 'meta_query' => array( - array( - 'key' => self::$meta_prefix . 'meta-robots-noindex', - 'value' => '1', - 'compare' => '=', - ), - ), - ) - ); - } - } - if ( isset( $_GET['seo_kw_filter'] ) && $_GET['seo_kw_filter'] !== '' ) { - $vars = array_merge( - $vars, array( - 'post_type' => 'any', - 'meta_key' => self::$meta_prefix . 'focuskw', - 'meta_value' => sanitize_text_field( $_GET['seo_kw_filter'] ), - ) - ); - } - if ( isset( $vars['orderby'] ) && 'wpseo-score' === $vars['orderby'] ) { - $vars = array_merge( - $vars, array( - 'meta_key' => self::$meta_prefix . 'linkdex', - 'orderby' => 'meta_value_num', - ) - ); - } - if ( isset( $vars['orderby'] ) && 'wpseo-metadesc' === $vars['orderby'] ) { - $vars = array_merge( - $vars, array( - 'meta_key' => self::$meta_prefix . 'metadesc', - 'orderby' => 'meta_value', - ) - ); - } - if ( isset( $vars['orderby'] ) && 'wpseo-focuskw' === $vars['orderby'] ) { - $vars = array_merge( - $vars, array( - 'meta_key' => self::$meta_prefix . 'focuskw', - 'orderby' => 'meta_value', - ) - ); - } - - return $vars; - } - - /** - * Hide the SEO Title, Meta Desc and Focus KW columns if the user hasn't chosen which columns to hide - * - * @param array|false $result - * @param string $option - * @param WP_User $user - * - * @return array|false $result - */ - public function column_hidden( $result, $option, $user ) { - global $wpdb; - - $prefix = $wpdb->get_blog_prefix(); - if ( ! $user->has_prop( $prefix . $option ) && ! $user->has_prop( $option ) ) { - - if ( ! is_array( $result ) ) { - $result = array(); - } - - array_push( $result, 'wpseo-title', 'wpseo-metadesc', 'wpseo-focuskw' ); - } - - return $result; - } - - /** - * Hacky way to get round the limitation that you can only have AND *or* OR relationship between - * meta key clauses and not a combination - which is what we need. - * - * @param string $where - * - * @return string - */ - function seo_score_posts_where( $where ) { - global $wpdb; - - /* Find the two mutually exclusive noindex clauses which should be changed from AND to OR relation */ - $find = '`([\s]+AND[\s]+)((?:' . $wpdb->prefix . 'postmeta|mt[0-9]|mt1)\.post_id IS NULL[\s]+)AND([\s]+\([\s]*(?:' . $wpdb->prefix . 'postmeta|mt[0-9])\.meta_key = \'' . self::$meta_prefix . 'meta-robots-noindex\' AND CAST\([^\)]+\)[^\)]+\))`'; - - $replace = '$1( $2OR$3 )'; - - $new_where = preg_replace( $find, $replace, $where ); - - if ( $new_where ) { - return $new_where; - } - return $where; - } - - /** - * Retrieve the page title. - * - * @param int $post_id Post to retrieve the title for. - * - * @return string - */ - function page_title( $post_id ) { - $fixed_title = self::get_value( 'title', $post_id ); - if ( $fixed_title !== '' ) { - return $fixed_title; - } - else { - $post = get_post( $post_id ); - $options = WPSEO_Options::get_all(); - if ( is_object( $post ) && ( isset( $options[ 'title-' . $post->post_type ] ) && $options[ 'title-' . $post->post_type ] !== '' ) ) { - $title_template = $options[ 'title-' . $post->post_type ]; - $title_template = str_replace( ' %%page%% ', ' ', $title_template ); - - return wpseo_replace_vars( $title_template, $post ); - } - else { - return wpseo_replace_vars( '%%title%%', $post ); - } - } - } - - /** - * Sort an array by a given key. - * - * @param array $array Array to sort, array is returned sorted. - * @param string $key Key to sort array by. - */ - function aasort( &$array, $key ) { - $sorter = array(); - $ret = array(); - reset( $array ); - foreach ( $array as $ii => $va ) { - $sorter[ $ii ] = $va[ $key ]; - } - asort( $sorter ); - foreach ( $sorter as $ii => $va ) { - $ret[ $ii ] = $array[ $ii ]; - } - $array = $ret; - } - - /** - * Output the page analysis results. - * - * @param object $post Post to output the page analysis results for. - * - * @return string - */ - function linkdex_output( $post ) { - $results = $this->calculate_results( $post ); - - if ( is_wp_error( $results ) ) { - $error = $results->get_error_messages(); - - return '

' . esc_html( $error[0] ) . '

'; - } - $output = ''; - - if ( is_array( $results ) && $results !== array() ) { - - $output = ''; - $perc_score = absint( $results['total'] ); - unset( $results['total'] ); // Unset to prevent echoing it. - - foreach ( $results as $result ) { - if ( is_array( $result ) ) { - $score = WPSEO_Utils::translate_score( $result['val'] ); - $output .= ''; - } - } - unset( $result, $score ); - $output .= '
' . $result['msg'] . '
'; - - if ( WP_DEBUG === true || ( defined( 'WPSEO_DEBUG' ) && WPSEO_DEBUG === true ) ) { - $output .= '

(' . $perc_score . '%)

'; - } - } - - $output = '

' . __( 'To update this page analysis, save as draft or update and check this tab again', 'wordpress-seo' ) . '.

' . $output; - - unset( $results ); - - return $output; - } - - /** - * Calculate the page analysis results for post. - * - * @todo [JRF => whomever] check whether the results of this method are always checked with is_wp_error() - * @todo [JRF => whomever] check the usage of this method as it's quite intense/heavy, see if it's only - * used when really necessary - * @todo [JRF => whomever] see if we can get rid of the passing by reference of $results as it makes - * the code obfuscated - * - * @param object $post Post to calculate the results for. - * - * @return array|WP_Error - */ - function calculate_results( $post ) { - $options = WPSEO_Options::get_all(); - - if ( ! class_exists( 'DOMDocument' ) ) { - $result = new WP_Error( 'no-domdocument', sprintf( __( "Your hosting environment does not support PHP's %sDocument Object Model%s.", 'wordpress-seo' ), '', '' ) . ' ' . __( "To enjoy all the benefits of the page analysis feature, you'll need to (get your host to) install it.", 'wordpress-seo' ) ); - - return $result; - } - - if ( ! is_array( $post ) && ! is_object( $post ) ) { - $result = new WP_Error( 'no-post', __( 'No post content to analyse.', 'wordpress-seo' ) ); - - return $result; - } - elseif ( self::get_value( 'focuskw', $post->ID ) === '' ) { - $result = new WP_Error( 'no-focuskw', sprintf( __( 'No focus keyword was set for this %s. If you do not set a focus keyword, no score can be calculated.', 'wordpress-seo' ), $post->post_type ) ); - - self::set_value( 'linkdex', 0, $post->ID ); - - return $result; - } - elseif ( apply_filters( 'wpseo_use_page_analysis', true ) !== true ) { - $result = new WP_Error( 'page-analysis-disabled', sprintf( __( 'Page Analysis has been disabled.', 'wordpress-seo' ), $post->post_type ) ); - - return $result; - } - - $results = array(); - $job = array(); - - $sampleurl = $this->get_sample_permalink( $post ); - $job['pageUrl'] = preg_replace( '`%(?:post|page)name%`', $sampleurl[1], $sampleurl[0] ); - $job['pageSlug'] = urldecode( $post->post_name ); - $job['keyword'] = self::get_value( 'focuskw', $post->ID ); - $job['keyword_folded'] = $this->strip_separators_and_fold( $job['keyword'] ); - $job['post_id'] = $post->ID; - $job['post_type'] = $post->post_type; - - $dom = new domDocument; - $dom->strictErrorChecking = false; - $dom->preserveWhiteSpace = false; - - /** - * Filter: 'wpseo_pre_analysis_post_content' - Make the post content filterable before calculating the page analysis - * - * @api string $post_content The post content - * - * @param object $post The post. - */ - $post_content = apply_filters( 'wpseo_pre_analysis_post_content', $post->post_content, $post ); - - // Check if the post content is not empty. - if ( ! empty( $post_content ) ) { - @$dom->loadHTML( $post_content ); - } - - unset( $post_content ); - - $xpath = new DOMXPath( $dom ); - - // Check if this focus keyword has been used already. - $this->check_double_focus_keyword( $job, $results ); - - // Keyword. - $this->score_keyword( $job['keyword'], $results ); - - // Title. - $title = self::get_value( 'title', $post->ID ); - if ( $title !== '' ) { - $job['title'] = $title; - } - else { - if ( isset( $options[ 'title-' . $post->post_type ] ) && $options[ 'title-' . $post->post_type ] !== '' ) { - $title_template = $options[ 'title-' . $post->post_type ]; - } - else { - $title_template = '%%title%% - %%sitename%%'; - } - $job['title'] = wpseo_replace_vars( $title_template, $post ); - } - unset( $title ); - $this->score_title( $job, $results ); - - // Meta description. - $description = ''; - $desc_meta = self::get_value( 'metadesc', $post->ID ); - if ( $desc_meta !== '' ) { - $description = $desc_meta; - } - elseif ( isset( $options[ 'metadesc-' . $post->post_type ] ) && $options[ 'metadesc-' . $post->post_type ] !== '' ) { - $description = wpseo_replace_vars( $options[ 'metadesc-' . $post->post_type ], $post ); - } - unset( $desc_meta ); - - self::$meta_length = apply_filters( 'wpseo_metadesc_length', self::$meta_length, $post ); - - $this->score_description( $job, $results, $description, self::$meta_length ); - unset( $description ); - - // Body. - $body = $this->get_body( $post ); - $firstp = $this->get_first_paragraph( $body ); - $this->score_body( $job, $results, $body, $firstp ); - unset( $firstp ); - - // URL. - $this->score_url( $job, $results ); - - // Headings. - $headings = $this->get_headings( $body ); - $this->score_headings( $job, $results, $headings ); - unset( $headings ); - - // Images. - $imgs = array(); - $imgs['count'] = substr_count( $body, 'get_images_alt_text( $post->ID, $body, $imgs ); - - // Check featured image. - if ( function_exists( 'has_post_thumbnail' ) && has_post_thumbnail() ) { - $imgs['count'] += 1; - - if ( empty( $imgs['alts'] ) ) { - $imgs['alts'] = array(); - } - - $imgs['alts'][] = $this->strtolower_utf8( get_post_meta( get_post_thumbnail_id( $post->ID ), '_wp_attachment_image_alt', true ) ); - } - - $this->score_images_alt_text( $job, $results, $imgs ); - unset( $imgs ); - unset( $body ); - - // Anchors. - $anchors = $this->get_anchor_texts( $xpath ); - $count = $this->get_anchor_count( $xpath ); - - $this->score_anchor_texts( $job, $results, $anchors, $count ); - unset( $anchors, $count, $dom ); - - $results = apply_filters( 'wpseo_linkdex_results', $results, $job, $post ); - - $this->aasort( $results, 'val' ); - - $overall = 0; - $overall_max = 0; - - foreach ( $results as $result ) { - $overall += $result['val']; - $overall_max += 9; - } - unset( $result ); - - if ( $overall < 1 ) { - $overall = 1; - } - $score = WPSEO_Utils::calc( WPSEO_Utils::calc( $overall, '/', $overall_max ), '*', 100, true ); - - if ( ! is_wp_error( $score ) ) { - self::set_value( 'linkdex', absint( $score ), $post->ID ); - - $results['total'] = $score; - } - - return $results; - } - - /** - * Get sample permalink - * - * @param object $post - * - * @return array - */ - function get_sample_permalink( $post ) { - if ( ! function_exists( 'get_sample_permalink' ) ) { - // Front-end post update. - include_once( ABSPATH . 'wp-admin/includes/post.php' ); - } - - return get_sample_permalink( $post ); - } - - /** - * Save the score result to the results array. - * - * @param array $results The results array used to store results. - * @param int $scoreValue The score value. - * @param string $scoreMessage The score message. - * @param string $scoreLabel The label of the score to use in the results array. - * @param string $rawScore The raw score, to be used by other filters. - */ - function save_score_result( &$results, $scoreValue, $scoreMessage, $scoreLabel, $rawScore = null ) { - $score = array( - 'val' => $scoreValue, - 'msg' => $scoreMessage, - 'raw' => $rawScore, - ); - $results[ $scoreLabel ] = $score; - } - - /** - * Clean up the input string. - * - * @param string $inputString String to clean up. - * @param bool $removeOptionalCharacters Whether or not to do a cleanup of optional chars too. - * - * @return string - */ - function strip_separators_and_fold( $inputString, $removeOptionalCharacters = false ) { - $keywordCharactersAlwaysReplacedBySpace = array( ',', "'", '"', '?', '’', '“', '”', '|', '/' ); - $keywordCharactersRemovedOrReplaced = array( '_', '-' ); - $keywordWordsRemoved = array( ' a ', ' in ', ' an ', ' on ', ' for ', ' the ', ' and ' ); - - // Lower. - $inputString = $this->strtolower_utf8( $inputString ); - - // Default characters replaced by space. - $inputString = str_replace( $keywordCharactersAlwaysReplacedBySpace, ' ', $inputString ); - - // Standardise whitespace. - $inputString = WPSEO_Utils::standardize_whitespace( $inputString ); - - // Deal with the separators that can be either removed or replaced by space. - if ( $removeOptionalCharacters ) { - // Remove word separators with a space. - $inputString = str_replace( $keywordWordsRemoved, ' ', $inputString ); - - $inputString = str_replace( $keywordCharactersRemovedOrReplaced, '', $inputString ); - } - else { - $inputString = str_replace( $keywordCharactersRemovedOrReplaced, ' ', $inputString ); - } - - // Standardise whitespace again. - $inputString = WPSEO_Utils::standardize_whitespace( $inputString ); - - return trim( $inputString ); - } - - /** - * Check whether this focus keyword has been used for other posts before. - * - * @param array $job - * @param array $results - */ - function check_double_focus_keyword( $job, &$results ) { - $posts = get_posts( - array( - 'meta_key' => self::$meta_prefix . 'focuskw', - 'meta_value' => $job['keyword'], - 'exclude' => $job['post_id'], - 'fields' => 'ids', - 'post_type' => 'any', - 'numberposts' => -1, - ) - ); - - if ( count( $posts ) == 0 ) { - $this->save_score_result( $results, 9, __( 'You\'ve never used this focus keyword before, very good.', 'wordpress-seo' ), 'keyword_overused' ); - } - elseif ( count( $posts ) == 1 ) { - $this->save_score_result( $results, 6, sprintf( __( 'You\'ve used this focus keyword %1$sonce before%2$s, be sure to make very clear which URL on your site is the most important for this keyword.', 'wordpress-seo' ), '', '' ), 'keyword_overused' ); - } - else { - $keyword = str_replace( ' ', '%20', $job['keyword'] ); - $url = add_query_arg( array( 'seo_kw_filter' => $keyword ), admin_url( 'edit.php' ) ); - $message = sprintf( - __( 'You\'ve used this focus keyword %3$s%4$d times before%2$s, it\'s probably a good idea to read %1$sthis post on cornerstone content%2$s and improve your keyword strategy.', 'wordpress-seo' ), - '', - '', - '', - count( $posts ) - ); - $this->save_score_result( $results, 1, $message, 'keyword_overused' ); - } - } - - /** - * Check whether the keyword contains stopwords. - * - * @param string $keyword The keyword to check for stopwords. - * @param array $results The results array. - */ - function score_keyword( $keyword, &$results ) { - global $wpseo_admin; - - $keywordStopWord = __( 'The keyword for this page contains one or more %sstop words%s, consider removing them. Found \'%s\'.', 'wordpress-seo' ); - - if ( $wpseo_admin->stopwords_check( $keyword ) !== false ) { - $this->save_score_result( $results, 5, sprintf( $keywordStopWord, '', '', $wpseo_admin->stopwords_check( $keyword ) ), 'keyword_stopwords' ); - } - } - - /** - * Check whether the keyword is contained in the URL. - * - * @param array $job The job array holding both the keyword and the URLs. - * @param array $results The results array. - */ - function score_url( $job, &$results ) { - $urlGood = __( 'The keyword / phrase appears in the URL for this page.', 'wordpress-seo' ); - $urlMedium = __( 'The keyword / phrase does not appear in the URL for this page. If you decide to rename the URL be sure to check the old URL 301 redirects to the new one!', 'wordpress-seo' ); - $urlStopWords = __( 'The slug for this page contains one or more stop words, consider removing them.', 'wordpress-seo' ); - $longSlug = __( 'The slug for this page is a bit long, consider shortening it.', 'wordpress-seo' ); - - $needle = $this->strip_separators_and_fold( remove_accents( $job['keyword'] ) ); - $haystack1 = $this->strip_separators_and_fold( $job['pageUrl'], true ); - $haystack2 = $this->strip_separators_and_fold( $job['pageUrl'], false ); - - if ( stripos( $haystack1, $needle ) || stripos( $haystack2, $needle ) ) { - $this->save_score_result( $results, 9, $urlGood, 'url_keyword' ); - } - else { - $this->save_score_result( $results, 6, $urlMedium, 'url_keyword' ); - } - - // Check for Stop Words in the slug. - if ( $GLOBALS['wpseo_admin']->stopwords_check( $job['pageSlug'], true ) !== false ) { - $this->save_score_result( $results, 5, $urlStopWords, 'url_stopword' ); - } - - // Check if the slug isn't too long relative to the length of the keyword. - if ( ( $this->statistics()->text_length( $job['keyword'] ) + 20 ) < $this->statistics()->text_length( $job['pageSlug'] ) && 40 < $this->statistics()->text_length( $job['pageSlug'] ) ) { - $this->save_score_result( $results, 5, $longSlug, 'url_length' ); - } - } - - /** - * Check whether the keyword is contained in the title. - * - * @param array $job The job array holding both the keyword versions. - * @param array $results The results array. - */ - function score_title( $job, &$results ) { - $scoreTitleMinLength = 40; - $scoreTitleMaxLength = 70; - $scoreTitleKeywordLimit = 0; - - $scoreTitleMissing = __( 'Please create a page title.', 'wordpress-seo' ); - $scoreTitleCorrectLength = __( 'The page title is more than 40 characters and less than the recommended 70 character limit.', 'wordpress-seo' ); - $scoreTitleTooShort = __( 'The page title contains %d characters, which is less than the recommended minimum of 40 characters. Use the space to add keyword variations or create compelling call-to-action copy.', 'wordpress-seo' ); - $scoreTitleTooLong = __( 'The page title contains %d characters, which is more than the viewable limit of 70 characters; some words will not be visible to users in your listing.', 'wordpress-seo' ); - $scoreTitleKeywordMissing = __( 'The keyword / phrase %s does not appear in the page title.', 'wordpress-seo' ); - $scoreTitleKeywordBeginning = __( 'The page title contains keyword / phrase, at the beginning which is considered to improve rankings.', 'wordpress-seo' ); - $scoreTitleKeywordEnd = __( 'The page title contains keyword / phrase, but it does not appear at the beginning; try and move it to the beginning.', 'wordpress-seo' ); - - if ( $job['title'] == '' ) { - $this->save_score_result( $results, 1, $scoreTitleMissing, 'title' ); - } - else { - $job['title'] = wp_strip_all_tags( $job['title'] ); - - $length = $this->statistics()->text_length( $job['title'] ); - if ( $length < $scoreTitleMinLength ) { - $this->save_score_result( $results, 6, sprintf( $scoreTitleTooShort, $length ), 'title_length' ); - } - elseif ( $length > $scoreTitleMaxLength ) { - $this->save_score_result( $results, 6, sprintf( $scoreTitleTooLong, $length ), 'title_length' ); - } - else { - $this->save_score_result( $results, 9, $scoreTitleCorrectLength, 'title_length' ); - } - - // @todo MA Keyword/Title matching is exact match with separators removed, but should extend to distributed match. - $needle_position = stripos( $job['title'], $job['keyword_folded'] ); - - if ( $needle_position === false ) { - $needle_position = stripos( $job['title'], $job['keyword'] ); - } - - if ( $needle_position === false ) { - $this->save_score_result( $results, 2, sprintf( $scoreTitleKeywordMissing, $job['keyword_folded'] ), 'title_keyword' ); - } - elseif ( $needle_position <= $scoreTitleKeywordLimit ) { - $this->save_score_result( $results, 9, $scoreTitleKeywordBeginning, 'title_keyword' ); - } - else { - $this->save_score_result( $results, 6, $scoreTitleKeywordEnd, 'title_keyword' ); - } - } - } - - /** - * Check whether the document contains outbound links and whether it's anchor text matches the keyword. - * - * @param array $job The job array holding both the keyword versions. - * @param array $results The results array. - * @param array $anchor_texts The array holding all anchors in the document. - * @param array $count The number of anchors in the document, grouped by type. - */ - function score_anchor_texts( $job, &$results, $anchor_texts, $count ) { - $scoreNoLinks = __( 'No outbound links appear in this page, consider adding some as appropriate.', 'wordpress-seo' ); - $scoreKeywordInOutboundLink = __( 'You\'re linking to another page with the keyword you want this page to rank for, consider changing that if you truly want this page to rank.', 'wordpress-seo' ); - $scoreLinksDofollow = __( 'This page has %s outbound link(s).', 'wordpress-seo' ); - $scoreLinksNofollow = __( 'This page has %s outbound link(s), all nofollowed.', 'wordpress-seo' ); - $scoreLinks = __( 'This page has %s nofollowed link(s) and %s normal outbound link(s).', 'wordpress-seo' ); - - if ( $count['external']['nofollow'] == 0 && $count['external']['dofollow'] == 0 ) { - $this->save_score_result( $results, 6, $scoreNoLinks, 'links' ); - } - else { - $found = false; - if ( is_array( $anchor_texts ) && $anchor_texts !== array() ) { - foreach ( $anchor_texts as $anchor_text ) { - if ( $this->strtolower_utf8( $anchor_text ) == $job['keyword_folded'] ) { - $found = true; - } - } - unset( $anchor_text ); - } - if ( $found ) { - $this->save_score_result( $results, 2, $scoreKeywordInOutboundLink, 'links_focus_keyword' ); - } - - if ( $count['external']['nofollow'] == 0 && $count['external']['dofollow'] > 0 ) { - $this->save_score_result( $results, 9, sprintf( $scoreLinksDofollow, $count['external']['dofollow'] ), 'links_number' ); - } - elseif ( $count['external']['nofollow'] > 0 && $count['external']['dofollow'] == 0 ) { - $this->save_score_result( $results, 7, sprintf( $scoreLinksNofollow, $count['external']['nofollow'] ), 'links_number' ); - } - else { - $this->save_score_result( $results, 8, sprintf( $scoreLinks, $count['external']['nofollow'], $count['external']['dofollow'] ), 'links_number' ); - } - } - } - - /** - * Retrieve the anchor texts used in the current document. - * - * @param object $xpath An XPATH object of the current document. - * - * @return array - */ - function get_anchor_texts( &$xpath ) { - $query = '//a|//A'; - $dom_objects = $xpath->query( $query ); - $anchor_texts = array(); - if ( is_object( $dom_objects ) && is_a( $dom_objects, 'DOMNodeList' ) && $dom_objects->length > 0 ) { - foreach ( $dom_objects as $dom_object ) { - if ( $dom_object->attributes->getNamedItem( 'href' ) ) { - $href = $dom_object->attributes->getNamedItem( 'href' )->textContent; - if ( substr( $href, 0, 4 ) == 'http' ) { - $anchor_texts['external'] = $dom_object->textContent; - } - } - } - } - - return $anchor_texts; - } - - /** - * Count the number of anchors and group them by type. - * - * @param object $xpath An XPATH object of the current document. - * - * @return array - */ - function get_anchor_count( &$xpath ) { - $query = '//a|//A'; - $dom_objects = $xpath->query( $query ); - - $count = array( - 'total' => 0, - 'internal' => array( 'nofollow' => 0, 'dofollow' => 0 ), - 'external' => array( 'nofollow' => 0, 'dofollow' => 0 ), - 'other' => array( 'nofollow' => 0, 'dofollow' => 0 ), - ); - - if ( is_object( $dom_objects ) && is_a( $dom_objects, 'DOMNodeList' ) && $dom_objects->length > 0 ) { - foreach ( $dom_objects as $dom_object ) { - $count['total'] ++; - if ( $dom_object->attributes->getNamedItem( 'href' ) ) { - $href = $dom_object->attributes->getNamedItem( 'href' )->textContent; - $wpurl = get_bloginfo( 'url' ); - if ( WPSEO_Utils::is_url_relative( $href ) === true || substr( $href, 0, strlen( $wpurl ) ) === $wpurl ) { - $type = 'internal'; - } - elseif ( substr( $href, 0, 4 ) == 'http' ) { - $type = 'external'; - } - else { - $type = 'other'; - } - - if ( $dom_object->attributes->getNamedItem( 'rel' ) ) { - $link_rel = $dom_object->attributes->getNamedItem( 'rel' )->textContent; - if ( stripos( $link_rel, 'nofollow' ) !== false ) { - $count[ $type ]['nofollow'] ++; - } - else { - $count[ $type ]['dofollow'] ++; - } - } - else { - $count[ $type ]['dofollow'] ++; - } - } - } - } - - return $count; - } - - /** - * Check whether the images alt texts contain the keyword. - * - * @param array $job The job array holding both the keyword versions. - * @param array $results The results array. - * @param array $imgs The array with images alt texts. - */ - function score_images_alt_text( $job, &$results, $imgs ) { - $scoreImagesNoImages = __( 'No images appear in this page, consider adding some as appropriate.', 'wordpress-seo' ); - $scoreImagesNoAlt = __( 'The images on this page are missing alt tags.', 'wordpress-seo' ); - $scoreImagesAltKeywordIn = __( 'The images on this page contain alt tags with the target keyword / phrase.', 'wordpress-seo' ); - $scoreImagesAltKeywordMissing = __( 'The images on this page do not have alt tags containing your keyword / phrase.', 'wordpress-seo' ); - - if ( $imgs['count'] == 0 ) { - $this->save_score_result( $results, 3, $scoreImagesNoImages, 'images_alt' ); - } - elseif ( count( $imgs['alts'] ) == 0 && $imgs['count'] != 0 ) { - $this->save_score_result( $results, 5, $scoreImagesNoAlt, 'images_alt' ); - } - else { - $found = false; - foreach ( $imgs['alts'] as $alt ) { - $haystack1 = $this->strip_separators_and_fold( $alt, true ); - $haystack2 = $this->strip_separators_and_fold( $alt, false ); - if ( strrpos( $haystack1, $job['keyword_folded'] ) !== false ) { - $found = true; - } - elseif ( strrpos( $haystack2, $job['keyword_folded'] ) !== false ) { - $found = true; - } - } - unset( $alt, $haystack1, $haystack2 ); - - if ( $found ) { - $this->save_score_result( $results, 9, $scoreImagesAltKeywordIn, 'images_alt' ); - } - else { - $this->save_score_result( $results, 5, $scoreImagesAltKeywordMissing, 'images_alt' ); - } - } - } - - /** - * Retrieve the alt texts from the images. - * - * @param int $post_id The post to find images in. - * @param string $body The post content to find images in. - * @param array $imgs The array holding the image information. - * - * @return array The updated images array. - */ - function get_images_alt_text( $post_id, $body, $imgs ) { - $imgs['alts'] = array(); - if ( preg_match_all( '`]+>`im', $body, $matches ) ) { - foreach ( $matches[0] as $img ) { - if ( preg_match( '`alt=(["\'])(.*?)\1`', $img, $alt ) && isset( $alt[2] ) ) { - $imgs['alts'][] = $this->strtolower_utf8( $alt[2] ); - } - } - unset( $img, $alt ); - } - unset( $matches ); - - if ( strpos( $body, '[gallery' ) !== false ) { - $attachments = get_children( array( - 'post_parent' => $post_id, - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'fields' => 'ids', - ) ); - if ( is_array( $attachments ) && $attachments !== array() ) { - foreach ( $attachments as $att_id ) { - $alt = get_post_meta( $att_id, '_wp_attachment_image_alt', true ); - if ( $alt && ! empty( $alt ) ) { - $imgs['alts'][] = $alt; - } - $imgs['count'] ++; - } - } - } - - return $imgs; - } - - /** - * Score the headings for keyword appearance. - * - * @param array $job The array holding the keywords. - * @param array $results The results array. - * @param array $headings The headings found in the document. - */ - function score_headings( $job, &$results, $headings ) { - $scoreHeadingsNone = __( 'No subheading tags (like an H2) appear in the copy.', 'wordpress-seo' ); - $scoreHeadingsKeywordIn = __( 'Keyword / keyphrase appears in %s (out of %s) subheadings in the copy. While not a major ranking factor, this is beneficial.', 'wordpress-seo' ); - $scoreHeadingsKeywordMissing = __( 'You have not used your keyword / keyphrase in any subheading (such as an H2) in your copy.', 'wordpress-seo' ); - - $headingCount = count( $headings ); - if ( $headingCount == 0 ) { - $this->save_score_result( $results, 7, $scoreHeadingsNone, 'headings' ); - } - else { - $found = 0; - foreach ( $headings as $heading ) { - $haystack1 = $this->strip_separators_and_fold( $heading, true ); - $haystack2 = $this->strip_separators_and_fold( $heading, false ); - - if ( strrpos( $haystack1, $job['keyword_folded'] ) !== false ) { - $found ++; - } - elseif ( strrpos( $haystack2, $job['keyword_folded'] ) !== false ) { - $found ++; - } - } - unset( $heading, $haystack1, $haystack2 ); - - if ( $found ) { - $this->save_score_result( $results, 9, sprintf( $scoreHeadingsKeywordIn, $found, $headingCount ), 'headings' ); - } - else { - $this->save_score_result( $results, 3, $scoreHeadingsKeywordMissing, 'headings' ); - } - } - } - - /** - * Fetch all headings and return their content. - * - * @param string $postcontent Post content to find headings in. - * - * @return array Array of heading texts. - */ - function get_headings( $postcontent ) { - $headings = array(); - - preg_match_all( '`]+)?>(.*?)`si', $postcontent, $matches ); - - if ( isset( $matches[2] ) && is_array( $matches[2] ) && $matches[2] !== array() ) { - foreach ( $matches[2] as $heading ) { - $headings[] = $this->strtolower_utf8( $heading ); - } - } - - return $headings; - } - - /** - * Score the meta description for length and keyword appearance. - * - * @param array $job The array holding the keywords. - * @param array $results The results array. - * @param string $description The meta description. - * @param int $maxlength The maximum length of the meta description. - */ - function score_description( $job, &$results, $description, $maxlength = 155 ) { - $scoreDescriptionMinLength = 120; - $scoreDescriptionCorrectLength = __( 'In the specified meta description, consider: How does it compare to the competition? Could it be made more appealing?', 'wordpress-seo' ); - $scoreDescriptionTooShort = __( 'The meta description is under 120 characters, however up to %s characters are available. %s', 'wordpress-seo' ); - $scoreDescriptionTooLong = __( 'The specified meta description is over %s characters, reducing it will ensure the entire description is visible. %s', 'wordpress-seo' ); - $scoreDescriptionMissing = __( 'No meta description has been specified, search engines will display copy from the page instead.', 'wordpress-seo' ); - $scoreDescriptionKeywordIn = __( 'The meta description contains the primary keyword / phrase.', 'wordpress-seo' ); - $scoreDescriptionKeywordMissing = __( 'A meta description has been specified, but it does not contain the target keyword / phrase.', 'wordpress-seo' ); - - $metaShorter = ''; - if ( $maxlength != 155 ) { - $metaShorter = __( 'The available space is shorter than the usual 155 characters because Google will also include the publication date in the snippet.', 'wordpress-seo' ); - } - - if ( $description == '' ) { - $this->save_score_result( $results, 1, $scoreDescriptionMissing, 'description_length' ); - } - else { - $length = $this->statistics()->text_length( $description ); - - if ( $length < $scoreDescriptionMinLength ) { - $this->save_score_result( $results, 6, sprintf( $scoreDescriptionTooShort, $maxlength, $metaShorter ), 'description_length' ); - } - elseif ( $length <= $maxlength ) { - $this->save_score_result( $results, 9, $scoreDescriptionCorrectLength, 'description_length' ); - } - else { - $this->save_score_result( $results, 6, sprintf( $scoreDescriptionTooLong, $maxlength, $metaShorter ), 'description_length' ); - } - - // @todo MA Keyword/Title matching is exact match with separators removed, but should extend to distributed match. - $haystack1 = $this->strip_separators_and_fold( $description, true ); - $haystack2 = $this->strip_separators_and_fold( $description, false ); - if ( strrpos( $haystack1, $job['keyword_folded'] ) === false && strrpos( $haystack2, $job['keyword_folded'] ) === false ) { - $this->save_score_result( $results, 3, $scoreDescriptionKeywordMissing, 'description_keyword' ); - } - else { - $this->save_score_result( $results, 9, $scoreDescriptionKeywordIn, 'description_keyword' ); - } - } - } - - /** - * Score the body for length and keyword appearance. - * - * @param array $job The array holding the keywords. - * @param array $results The results array. - * @param string $body The body. - * @param string $firstp The first paragraph. - */ - function score_body( $job, &$results, $body, $firstp ) { - $lengthScore = array( - 'good' => 300, - 'ok' => 250, - 'poor' => 200, - 'bad' => 100, - ); - $lengthScore = apply_filters( 'wpseo_body_length_score', $lengthScore, $job ); - - $scoreBodyGoodLength = __( 'There are %d words contained in the body copy, this is more than the %d word recommended minimum.', 'wordpress-seo' ); - $scoreBodyPoorLength = __( 'There are %d words contained in the body copy, this is below the %d word recommended minimum. Add more useful content on this topic for readers.', 'wordpress-seo' ); - $scoreBodyOKLength = __( 'There are %d words contained in the body copy, this is slightly below the %d word recommended minimum, add a bit more copy.', 'wordpress-seo' ); - $scoreBodyBadLength = __( 'There are %d words contained in the body copy. This is far too low and should be increased.', 'wordpress-seo' ); - - $scoreKeywordDensityLow = __( 'The keyword density is %s%%, which is a bit low, the keyword was found %s times.', 'wordpress-seo' ); - $scoreKeywordDensityHigh = __( 'The keyword density is %s%%, which is over the advised 4.5%% maximum, the keyword was found %s times.', 'wordpress-seo' ); - $scoreKeywordDensityGood = __( 'The keyword density is %s%%, which is great, the keyword was found %s times.', 'wordpress-seo' ); - - $scoreFirstParagraphLow = __( 'The keyword doesn\'t appear in the first paragraph of the copy, make sure the topic is clear immediately.', 'wordpress-seo' ); - $scoreFirstParagraphHigh = __( 'The keyword appears in the first paragraph of the copy.', 'wordpress-seo' ); - - $fleschurl = '' . __( 'Flesch Reading Ease', 'wordpress-seo' ) . ''; - $scoreFlesch = __( 'The copy scores %s in the %s test, which is considered %s to read. %s', 'wordpress-seo' ); - - // Replace images with their alt tags, then strip all tags. - $body = preg_replace( '`]+)?alt="([^"]+)"(?:[^>]+)>`', '$1', $body ); - $body = strip_tags( $body ); - - // Copy length check. - $wordCount = $this->statistics()->word_count( $body ); - - if ( $wordCount < $lengthScore['bad'] ) { - $this->save_score_result( $results, - 20, sprintf( $scoreBodyBadLength, $wordCount, $lengthScore['good'] ), 'body_length', $wordCount ); - } - elseif ( $wordCount < $lengthScore['poor'] ) { - $this->save_score_result( $results, - 10, sprintf( $scoreBodyPoorLength, $wordCount, $lengthScore['good'] ), 'body_length', $wordCount ); - } - elseif ( $wordCount < $lengthScore['ok'] ) { - $this->save_score_result( $results, 5, sprintf( $scoreBodyPoorLength, $wordCount, $lengthScore['good'] ), 'body_length', $wordCount ); - } - elseif ( $wordCount < $lengthScore['good'] ) { - $this->save_score_result( $results, 7, sprintf( $scoreBodyOKLength, $wordCount, $lengthScore['good'] ), 'body_length', $wordCount ); - } - else { - $this->save_score_result( $results, 9, sprintf( $scoreBodyGoodLength, $wordCount, $lengthScore['good'] ), 'body_length', $wordCount ); - } - - $body = $this->strtolower_utf8( $body ); - $job['keyword'] = $this->strtolower_utf8( $job['keyword'] ); - - $keywordWordCount = $this->statistics()->word_count( $job['keyword'] ); - - if ( $keywordWordCount > 10 ) { - $this->save_score_result( $results, 0, __( 'Your keyphrase is over 10 words, a keyphrase should be shorter and there can be only one keyphrase.', 'wordpress-seo' ), 'focus_keyword_length' ); - } - else { - // Keyword Density check. - $keywordDensity = 0; - if ( $wordCount > 100 ) { - $keywordCount = preg_match_all( '`\b' . preg_quote( $job['keyword'], '`' ) . '\b`miu', $body, $matches ); - if ( ( $keywordCount > 0 && $keywordWordCount > 0 ) && $wordCount > $keywordCount ) { - $keywordDensity = WPSEO_Utils::calc( WPSEO_Utils::calc( $keywordCount, '/', WPSEO_Utils::calc( $wordCount, '-', ( WPSEO_Utils::calc( WPSEO_Utils::calc( $keywordWordCount, '-', 1 ), '*', $keywordCount ) ) ) ), '*', 100, true, 2 ); - } - if ( $keywordDensity < 1 ) { - $this->save_score_result( $results, 4, sprintf( $scoreKeywordDensityLow, $keywordDensity, $keywordCount ), 'keyword_density' ); - } - elseif ( $keywordDensity > 4.5 ) { - $this->save_score_result( $results, - 50, sprintf( $scoreKeywordDensityHigh, $keywordDensity, $keywordCount ), 'keyword_density' ); - } - else { - $this->save_score_result( $results, 9, sprintf( $scoreKeywordDensityGood, $keywordDensity, $keywordCount ), 'keyword_density' ); - } - } - } - - $firstp = $this->strtolower_utf8( $firstp ); - - // First Paragraph Test. - // Check without /u modifier as well as /u might break with non UTF-8 chars. - if ( preg_match( '`\b' . preg_quote( $job['keyword'], '`' ) . '\b`miu', $firstp ) || preg_match( '`\b' . preg_quote( $job['keyword'], '`' ) . '\b`mi', $firstp ) || preg_match( '`\b' . preg_quote( $job['keyword_folded'], '`' ) . '\b`miu', $firstp ) - ) { - $this->save_score_result( $results, 9, $scoreFirstParagraphHigh, 'keyword_first_paragraph' ); - } - else { - $this->save_score_result( $results, 3, $scoreFirstParagraphLow, 'keyword_first_paragraph' ); - } - - $lang = get_bloginfo( 'language' ); - if ( substr( $lang, 0, 2 ) == 'en' && $wordCount > 100 ) { - // Flesch Reading Ease check. - $flesch = $this->statistics()->flesch_kincaid_reading_ease( $body ); - - $note = ''; - $level = ''; - $score = 1; - if ( $flesch >= 90 ) { - $level = __( 'very easy', 'wordpress-seo' ); - $score = 9; - } - elseif ( $flesch >= 80 ) { - $level = __( 'easy', 'wordpress-seo' ); - $score = 9; - } - elseif ( $flesch >= 70 ) { - $level = __( 'fairly easy', 'wordpress-seo' ); - $score = 8; - } - elseif ( $flesch >= 60 ) { - $level = __( 'OK', 'wordpress-seo' ); - $score = 7; - } - elseif ( $flesch >= 50 ) { - $level = __( 'fairly difficult', 'wordpress-seo' ); - $note = __( 'Try to make shorter sentences to improve readability.', 'wordpress-seo' ); - $score = 6; - } - elseif ( $flesch >= 30 ) { - $level = __( 'difficult', 'wordpress-seo' ); - $note = __( 'Try to make shorter sentences, using less difficult words to improve readability.', 'wordpress-seo' ); - $score = 5; - } - elseif ( $flesch >= 0 ) { - $level = __( 'very difficult', 'wordpress-seo' ); - $note = __( 'Try to make shorter sentences, using less difficult words to improve readability.', 'wordpress-seo' ); - $score = 4; - } - $this->save_score_result( $results, $score, sprintf( $scoreFlesch, $flesch, $fleschurl, $level, $note ), 'flesch_kincaid' ); - } - } - - /** - * Retrieve the body from the post. - * - * @param object $post The post object. - * - * @return string The post content. - */ - function get_body( $post ) { - // This filter allows plugins to add their content to the content to be analyzed. - $post_content = apply_filters( 'wpseo_pre_analysis_post_content', $post->post_content, $post ); - - // Strip shortcodes, for obvious reasons, if plugins think their content should be in the analysis, they should - // hook into the above filter. - $post_content = WPSEO_Utils::trim_nbsp_from_string( WPSEO_Utils::strip_shortcode( $post_content ) ); - - if ( trim( $post_content ) == '' ) { - return ''; - } - - $htmdata3 = preg_replace( '`<(?:\x20*script|script).*?(?:/>|/script>)`', '', $post_content ); - if ( $htmdata3 == null ) { - $htmdata3 = $post_content; - } - else { - unset( $post_content ); - } - - $htmdata4 = preg_replace( '``', '', $htmdata3 ); - if ( $htmdata4 == null ) { - $htmdata4 = $htmdata3; - } - else { - unset( $htmdata3 ); - } - - $htmdata5 = preg_replace( '`<(?:\x20*style|style).*?(?:/>|/style>)`', '', $htmdata4 ); - if ( $htmdata5 == null ) { - $htmdata5 = $htmdata4; - } - else { - unset( $htmdata4 ); - } - - return $htmdata5; - } - - /** - * Retrieve the first paragraph from the post. - * - * @param string $body The post content to retrieve the first paragraph from. - * - * @return string - */ - function get_first_paragraph( $body ) { - // To determine the first paragraph we first need to autop the content, then match the first paragraph and return. - if ( preg_match( '`(.*)

`s', wpautop( $body ), $matches ) ) { - return $matches[1]; - } - - return false; - } - - /********************** DEPRECATED METHODS **********************/ - - /** - * Adds the Yoast SEO box - * - * @deprecated 1.4.24 - * @deprecated use WPSEO_Metabox::add_meta_box() - * @see WPSEO_Meta::add_meta_box() - */ - public function add_custom_box() { - _deprecated_function( __METHOD__, 'WPSEO 1.4.24', 'WPSEO_Metabox::add_meta_box()' ); - $this->add_meta_box(); - } - - /** - * Retrieve the meta boxes for the given post type. - * - * @deprecated 1.5.0 - * @deprecated use WPSEO_Meta::get_meta_field_defs() - * @see WPSEO_Meta::get_meta_field_defs() - * - * @param string $post_type - * - * @return array - */ - public function get_meta_boxes( $post_type = 'post' ) { - _deprecated_function( __METHOD__, 'WPSEO 1.5.0', 'WPSEO_Meta::get_meta_field_defs()' ); - - return $this->get_meta_field_defs( 'general', $post_type ); - } - - /** - * Pass some variables to js - * - * @deprecated 1.5.0 - * @deprecated use WPSEO_Meta::localize_script() - * @see WPSEO_Meta::localize_script() - */ - public function script() { - _deprecated_function( __METHOD__, 'WPSEO 1.5.0', 'WPSEO_Meta::localize_script()' ); - - return $this->localize_script(); - } - -} /* End of class */ diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-plugin-conflict.php b/wp/wp-content/plugins/wordpress-seo/admin/class-plugin-conflict.php index 2d623eaa..c23792e0 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-plugin-conflict.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-plugin-conflict.php @@ -98,7 +98,7 @@ class WPSEO_Plugin_Conflict extends Yoast_Plugin_Conflict { /** * Overrides instance to set with this class as class * - * @param string $class_name + * @param string $class_name Optional class name. * * @return Yoast_Plugin_Conflict */ @@ -111,14 +111,14 @@ class WPSEO_Plugin_Conflict extends Yoast_Plugin_Conflict { * * If the activated plugin is conflicting with ours a notice will be shown. * - * @param string|bool $plugin + * @param string|bool $plugin Optional plugin basename to check. */ public static function hook_check_for_plugin_conflicts( $plugin = false ) { // The instance of itself. $instance = self::get_instance(); // Only add plugin as active plugin if $plugin isn't false. - if ( $plugin ) { + if ( $plugin && is_string( $plugin ) ) { // Because it's just activated. $instance->add_active_plugin( $instance->find_plugin_category( $plugin ), $plugin ); } @@ -142,5 +142,4 @@ class WPSEO_Plugin_Conflict extends Yoast_Plugin_Conflict { $instance->check_plugin_conflicts( $plugin_sections ); } - } diff --git a/wp/wp-content/plugins/wordpress-seo/admin/class-pointers.php b/wp/wp-content/plugins/wordpress-seo/admin/class-pointers.php index 624c62aa..f5234ef3 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/class-pointers.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/class-pointers.php @@ -94,17 +94,7 @@ class WPSEO_Pointers { 'function' => '', ), ); - $this->button_array = wp_parse_args( $this->button_array, $button_array_defaults ); - - if ( function_exists( 'wp_json_encode' ) ) { - $json_options = wp_json_encode( $options ); - } - else { - // @codingStandardsIgnoreStart - $json_options = json_encode( $options ); - // @codingStandardsIgnoreEnd - } - + $this->button_array = wp_parse_args( $this->button_array, $button_array_defaults ); ?> '; + } + + /** + * Returns Jed compatible YoastSEO.js translations. + * + * @return array + */ + private function get_scraper_translations() { + $file = plugin_dir_path( WPSEO_FILE ) . 'languages/wordpress-seo-' . get_locale() . '.json'; + if ( file_exists( $file ) && $file = file_get_contents( $file ) ) { + return json_decode( $file, true ); + } + return array(); + } + + /********************** DEPRECATED METHODS **********************/ + + /** + * Adds the Yoast SEO box + * + * @deprecated 1.4.24 + * @deprecated use WPSEO_Metabox::add_meta_box() + * @see WPSEO_Meta::add_meta_box() + */ + public function add_custom_box() { + _deprecated_function( __METHOD__, 'WPSEO 1.4.24', 'WPSEO_Metabox::add_meta_box()' ); + $this->add_meta_box(); + } + + /** + * Retrieve the meta boxes for the given post type. + * + * @deprecated 1.5.0 + * @deprecated use WPSEO_Meta::get_meta_field_defs() + * @see WPSEO_Meta::get_meta_field_defs() + * + * @param string $post_type The post type for which to get the meta fields. + * + * @return array + */ + public function get_meta_boxes( $post_type = 'post' ) { + _deprecated_function( __METHOD__, 'WPSEO 1.5.0', 'WPSEO_Meta::get_meta_field_defs()' ); + + return $this->get_meta_field_defs( 'general', $post_type ); + } + + /** + * Pass some variables to js + * + * @deprecated 1.5.0 + * @deprecated use WPSEO_Meta::localize_script() + * @see WPSEO_Meta::localize_script() + */ + public function script() { + _deprecated_function( __METHOD__, 'WPSEO 1.5.0', 'WPSEO_Meta::localize_script()' ); + + return $this->localize_script(); + } + + /** + * @deprecated 3.0 Removed, use javascript functions instead + * + * @param string $string Deprecated. + * + * @return string + */ + public function strtolower_utf8( $string ) { + _deprecated_function( 'WPSEO_Metabox::strtolower_utf8', 'WPSEO 3.0', 'use javascript instead' ); + + return $string; + } + + /** + * @deprecated 3.0 Removed. + * + * @return array + */ + public function localize_script() { + _deprecated_function( 'WPSEO_Metabox::localize_script', 'WPSEO 3.0' ); + + return array(); + } + + /** + * @deprecated 3.0 Removed, use javascript functions instead. + * + * @return string + */ + public function snippet() { + _deprecated_function( 'WPSEO_Metabox::snippet', 'WPSEO 3.0', 'use javascript instead' ); + + return ''; + } + + /** + * @deprecated 3.0 Use WPSEO_Meta_Columns::posts_filter_dropdown instead. + */ + public function posts_filter_dropdown() { + _deprecated_function( 'WPSEO_Metabox::posts_filter_dropdown', 'WPSEO 3.0', 'WPSEO_Metabox_Columns::posts_filter_dropdown' ); + + /** @var WPSEO_Meta_Columns $meta_columns */ + $meta_columns = $GLOBALS['wpseo_meta_columns']; + $meta_columns->posts_filter_dropdown(); + } + + /** + * @deprecated 3.0 Use WPSEO_Meta_Columns::column_heading instead. + * + * @param array $columns Already existing columns. + * + * @return array + */ + public function column_heading( $columns ) { + _deprecated_function( 'WPSEO_Metabox::column_heading', 'WPSEO 3.0', 'WPSEO_Metabox_Columns::column_heading' ); + + /** @var WPSEO_Meta_Columns $meta_columns */ + $meta_columns = $GLOBALS['wpseo_meta_columns']; + return $meta_columns->column_heading( $columns ); + } + + /** + * @deprecated 3.0 Use WPSEO_Meta_Columns::column_content instead. + * + * @param string $column_name Column to display the content for. + * @param int $post_id Post to display the column content for. + */ + public function column_content( $column_name, $post_id ) { + _deprecated_function( 'WPSEO_Metabox::column_content', 'WPSEO 3.0', 'WPSEO_Metabox_Columns::column_content' ); + + /** @var WPSEO_Meta_Columns $meta_columns */ + $meta_columns = $GLOBALS['wpseo_meta_columns']; + $meta_columns->column_content( $column_name, $post_id ); + } + + /** + * @deprecated 3.0 Use WPSEO_Meta_Columns::column_sort instead. + * + * @param array $columns appended with their orderby variable. + * + * @return array + */ + public function column_sort( $columns ) { + _deprecated_function( 'WPSEO_Metabox::column_sort', 'WPSEO 3.0', 'WPSEO_Metabox_Columns::column_sort' ); + + /** @var WPSEO_Meta_Columns $meta_columns */ + $meta_columns = $GLOBALS['wpseo_meta_columns']; + return $meta_columns->column_sort( $columns ); + } + + /** + * @deprecated 3.0 Use WPSEO_Meta_Columns::column_sort_orderby instead. + * + * @param array $vars Query variables. + * + * @return array + */ + public function column_sort_orderby( $vars ) { + _deprecated_function( 'WPSEO_Metabox::column_sort_orderby', 'WPSEO 3.0', 'WPSEO_Metabox_Columns::column_sort_orderby' ); + + /** @var WPSEO_Meta_Columns $meta_columns */ + $meta_columns = $GLOBALS['wpseo_meta_columns']; + return $meta_columns->column_sort_orderby( $vars ); + } + + /** + * @deprecated 3.0 Use WPSEO_Meta_Columns::column_hidden instead. + * + * @param array|false $result The hidden columns. + * @param string $option The option name used to set which columns should be hidden. + * @param WP_User $user The User. + * + * @return array|false $result + */ + public function column_hidden( $result, $option, $user ) { + _deprecated_function( 'WPSEO_Metabox::column_hidden', 'WPSEO 3.0', 'WPSEO_Metabox_Columns::column_hidden' ); + + /** @var WPSEO_Meta_Columns $meta_columns */ + $meta_columns = $GLOBALS['wpseo_meta_columns']; + return $meta_columns->column_hidden( $result, $option, $user ); + } + + /** + * @deprecated 3.0 Use WPSEO_Meta_Columns::seo_score_posts_where instead. + * + * @param string $where Where clause. + * + * @return string + */ + public function seo_score_posts_where( $where ) { + _deprecated_function( 'WPSEO_Metabox::seo_score_posts_where', 'WPSEO 3.0', 'WPSEO_Metabox_Columns::seo_score_posts_where' ); + + /** @var WPSEO_Meta_Columns $meta_columns */ + $meta_columns = $GLOBALS['wpseo_meta_columns']; + return $meta_columns->seo_score_posts_where( $where ); + } + + /** + * @deprecated 3.0 Removed. + * + * @param int $post_id Post to retrieve the title for. + * + * @return string + */ + public function page_title( $post_id ) { + _deprecated_function( 'WPSEO_Metabox::page_title', 'WPSEO 3.0' ); + + return ''; + } + + /** + * @deprecated 3.0 + * + * @param array $array Array to sort, array is returned sorted. + * @param string $key Key to sort array by. + */ + public function aasort( &$array, $key ) { + _deprecated_function( 'WPSEO_Metabox::aasort', 'WPSEO 3.0' ); + + } + + /** + * @deprecated 3.0 + * + * @param object $post Post to output the page analysis results for. + * + * @return string + */ + public function linkdex_output( $post ) { + _deprecated_function( 'WPSEO_Metabox::linkdex_output', 'WPSEO 3.0' ); + + return ''; + + } + + /** + * @deprecated 3.0 + * + * @param object $post Post to calculate the results for. + * + * @return array|WP_Error + */ + public function calculate_results( $post ) { + _deprecated_function( 'WPSEO_Metabox::calculate_results', 'WPSEO 3.0' ); + + return array(); + + } + + /** + * @deprecated 3.0 + * + * @param WP_Post $post Post object instance. + * + * @return array + */ + public function get_sample_permalink( $post ) { + _deprecated_function( 'WPSEO_Metabox::get_sample_permalink', 'WPSEO 3.0' ); + + return array(); + } + + /** + * @deprecated 3.0 + * + * @param array $results The results array used to store results. + * @param int $scoreValue The score value. + * @param string $scoreMessage The score message. + * @param string $scoreLabel The label of the score to use in the results array. + * @param string $rawScore The raw score, to be used by other filters. + */ + public function save_score_result( &$results, $scoreValue, $scoreMessage, $scoreLabel, $rawScore = null ) { + _deprecated_function( 'WPSEO_Metabox::save_score_result', 'WPSEO 3.0' ); + } + + /** + * @deprecated 3.0 + * + * @param string $inputString String to clean up. + * @param bool $removeOptionalCharacters Whether or not to do a cleanup of optional chars too. + * + * @return string + */ + public function strip_separators_and_fold( $inputString, $removeOptionalCharacters ) { + _deprecated_function( 'WPSEO_Metabox::strip_separators_and_f', 'WPSEO 3.0' ); + + return ''; + } + + /** + * @deprecated 3.0 + * + * @param array $job Job data array. + * @param array $results Results set by reference. + */ + public function check_double_focus_keyword( $job, &$results ) { + _deprecated_function( 'WPSEO_Metabox::check_double_focus_key', 'WPSEO 3.0' ); + + } + + /** + * @deprecated 3.0 + * + * @param string $keyword The keyword to check for stopwords. + * @param array $results The results array. + */ + public function score_keyword( $keyword, &$results ) { + _deprecated_function( 'WPSEO_Metabox::score_keyword', 'WPSEO 3.0' ); + } + + /** + * @deprecated 3.0 + * + * @param array $job The job array holding both the keyword and the URLs. + * @param array $results The results array. + */ + public function score_url( $job, &$results ) { + _deprecated_function( 'WPSEO_Metabox::score_url', 'WPSEO 3.0' ); + } + + /** + * @deprecated 3.0 + * + * @param array $job The job array holding both the keyword versions. + * @param array $results The results array. + */ + public function score_title( $job, &$results ) { + _deprecated_function( 'WPSEO_Metabox::score_title', 'WPSEO 3.0' ); + } + + /** + * @deprecated 3.0 + * + * @param array $job The job array holding both the keyword versions. + * @param array $results The results array. + * @param array $anchor_texts The array holding all anchors in the document. + * @param array $count The number of anchors in the document, grouped by type. + */ + public function score_anchor_texts( $job, &$results, $anchor_texts, $count ) { + _deprecated_function( 'WPSEO_Metabox::score_anchor_texts', 'WPSEO 3.0' ); + } + + /** + * @deprecated 3.0 + * + * @param object $xpath An XPATH object of the current document. + * + * @return array + */ + public function get_anchor_texts( &$xpath ) { + _deprecated_function( 'WPSEO_Metabox::get_anchor_texts', 'WPSEO 3.0' ); + + return array(); + } + + /** + * @deprecated 3.0 + * + * @param object $xpath An XPATH object of the current document. + * + * @return array + */ + public function get_anchor_count( &$xpath ) { + _deprecated_function( 'WPSEO_Metabox::get_anchor_count', 'WPSEO 3.0' ); + + return array(); + } + + /** + * @deprecated 3.0 + * + * @param array $job The job array holding both the keyword versions. + * @param array $results The results array. + * @param array $imgs The array with images alt texts. + */ + public function score_images_alt_text( $job, &$results, $imgs ) { + _deprecated_function( 'WPSEO_Metabox::score_images_alt_text', 'WPSEO 3.0' ); + } + + /** + * @deprecated 3.0 + * + * @param int $post_id The post to find images in. + * @param string $body The post content to find images in. + * @param array $imgs The array holding the image information. + * + * @return array The updated images array. + */ + public function get_images_alt_text( $post_id, $body, $imgs ) { + _deprecated_function( 'WPSEO_Metabox::get_images_alt_text', 'WPSEO 3.0' ); + + return array(); + } + + /** + * @deprecated 3.0 + * + * @param array $job The array holding the keywords. + * @param array $results The results array. + * @param array $headings The headings found in the document. + */ + public function score_headings( $job, &$results, $headings ) { + _deprecated_function( 'WPSEO_Metabox::score_headings', 'WPSEO 3.0' ); + } + + /** + * @deprecated 3.0 + * + * @param string $postcontent Post content to find headings in. + * + * @return array Array of heading texts. + */ + public function get_headings( $postcontent ) { + _deprecated_function( 'WPSEO_Metabox::get_headings', 'WPSEO 3.0' ); + + return array(); + } + + /** + * @deprecated 3.0 + * + * @param array $job The array holding the keywords. + * @param array $results The results array. + * @param string $description The meta description. + * @param int $maxlength The maximum length of the meta description. + */ + public function score_description( $job, &$results, $description, $maxlength = 155 ) { + _deprecated_function( 'WPSEO_Metabox::score_description', 'WPSEO 3.0' ); + } + + /** + * @deprecated 3.0 + * + * @param array $job The array holding the keywords. + * @param array $results The results array. + * @param string $body The body. + * @param string $firstp The first paragraph. + */ + public function score_body( $job, &$results, $body, $firstp ) { + _deprecated_function( 'WPSEO_Metabox::score_body', 'WPSEO 3.0' ); + } + + /** + * @deprecated 3.0 + * + * @param object $post The post object. + * + * @return string The post content. + */ + public function get_body( $post ) { + _deprecated_function( 'WPSEO_Metabox::get_body', 'WPSEO 3.0' ); + + return ''; + } + + /** + * @deprecated 3.0 + * + * @param string $body The post content to retrieve the first paragraph from. + * + * @return string + */ + public function get_first_paragraph( $body ) { + _deprecated_function( 'WPSEO_Metabox::get_first_paragraph', 'WPSEO 3.0' ); + + return ''; + } +} /* End of class */ diff --git a/wp/wp-content/plugins/wordpress-seo/admin/metabox/interface-metabox-section.php b/wp/wp-content/plugins/wordpress-seo/admin/metabox/interface-metabox-section.php new file mode 100644 index 00000000..f2c5986b --- /dev/null +++ b/wp/wp-content/plugins/wordpress-seo/admin/metabox/interface-metabox-section.php @@ -0,0 +1,20 @@ +statuses = $statuses; + } + + /** + * Generates and returns the subject of the email. + * + * @return string + */ + public function get_subject() { + if ( $this->statuses['old_status'] !== null ) { + return $this->get_change_subject(); + } + + return $this->get_new_subject(); + } + + /** + * Generates and returns the message body of the email. + * + * @return string + */ + public function get_message() { + if ( $this->statuses['old_status'] !== null ) { + $message = $this->get_change_message(); + } + else { + $message = $this->get_new_message(); + } + + $powered_by = sprintf( + /* translators: 1: opens a link to yoast.com. 2: closes the link 3: opens a link to onpage.org */ + __( 'Indexing powered by %1$sYoast%2$s and %3$sOnPage.org%2$s.', 'wordpress-seo' ), + '', + '', + '' + ); + + return $message . '

' . $powered_by; + } + + /** + * In case the status has been changed + * + * @return string + */ + private function get_change_message() { + $subjects = array( + '0' => sprintf( + /* translators: 1: expands to get_option( 'home' ). 2: opens a link to a related knowledge base article. 3: closes the link */ + __( 'Yoast SEO has detected that %1$s can no longer be indexed. Please note that this will make it impossible for search engines like Google and Bing to index your site. %2$sRead more about this error on our knowledge base%3$s.', 'wordpress-seo' ), + get_option( 'home' ), + '
', + '' + ), + '1' => sprintf( + /* translators: 1: expands to get_option( 'home' ). */ + __( 'Yoast SEO has detected that %1$s can be indexed again.', 'wordpress-seo' ), + get_option( 'home' ) + ), + ); + + return $subjects[ $this->statuses['new_status'] ]; + } + + /** + * The status is fetched for the first time + * + * @return string + */ + private function get_new_message() { + $subjects = array( + '0' => sprintf( + /* translators: 1: expands to get_option( 'home' ). 2: opens a link to a related knowledge base article. 3: closes the link */ + __( 'Yoast SEO has detected that %1$s can not be indexed. Please note that this will make it impossible for search engines like Google and Bing to index your site. %2$sRead more about this error on our knowledge base%3$s.', 'wordpress-seo' ), + get_option( 'home' ), + '', + '' + ), + '1' => sprintf( + /* translators: 1: expands to get_option( 'home' ). */ + __( 'Yoast SEO has detected that %1$s can be indexed.', 'wordpress-seo' ), + get_option( 'home' ) + ), + ); + + return $subjects[ $this->statuses['new_status'] ]; + } + + /** + * In case the status has been changed + * + * @return string + */ + private function get_change_subject() { + $subjects = array( + '0' => sprintf( + /* translators: 1: expands to get_option( 'home' ). */ + __( 'Yoast SEO alert: Search engines can no longer index %1$s!', 'wordpress-seo' ), + get_option( 'home' ) + ), + '1' => sprintf( + /* translators: 1: expands to get_option( 'home' ). */ + __( 'Yoast SEO alert fixed: Search engines can index %1$s again.', 'wordpress-seo' ), + get_option( 'home' ) + ), + ); + + return $subjects[ $this->statuses['new_status'] ]; + } + + /** + * The status is fetched for the first time + * + * @return string + */ + private function get_new_subject() { + $subjects = array( + '0' => sprintf( + /* translators: 1: expands to get_option( 'home' ). */ + __( 'Yoast SEO alert: Search engines cannot index %1$s!', 'wordpress-seo' ), + get_option( 'home' ) + ), + '1' => sprintf( + /* translators: 1: expands to get_option( 'home' ). */ + __( 'Yoast SEO alert fixed: Search engines can index %1$s.', 'wordpress-seo' ), + get_option( 'home' ) + ), + ); + + return $subjects[ $this->statuses['new_status'] ]; + } + +} diff --git a/wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-notifier.php b/wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-notifier.php new file mode 100644 index 00000000..b57b5355 --- /dev/null +++ b/wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-notifier.php @@ -0,0 +1,53 @@ + $old_status, + 'new_status' => $new_status, + ) + ); + + add_filter( 'wp_mail_content_type', array( $this, 'set_content_type' ) ); + wp_mail( + get_option( 'admin_email' ), + $email_presenter->get_subject(), + $email_presenter->get_message() + ); + remove_filter( 'wp_mail_content_type', array( $this, 'set_content_type' ) ); + } + + /** + * Forces the MIME type of emails to text/html + * + * @param string $content_type The content type for the email containing the indexability check. + * + * @return string + */ + public function set_content_type( $content_type ) { + return 'text/html'; + } + + /** + * Let's start showing the notices to all admins by removing the hide-notice meta data for each admin resulting in + * popping up the notice again + */ + public function show_notices() { + delete_metadata( 'user', 0, WPSEO_OnPage::USER_META_KEY, '', true ); + } + +} diff --git a/wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-option.php b/wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-option.php new file mode 100644 index 00000000..9f6109f1 --- /dev/null +++ b/wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-option.php @@ -0,0 +1,128 @@ +onpage_option = $this->get_option(); + } + + /** + * Getting the status from the option. + * + * @return string + */ + public function get_status() { + if ( array_key_exists( self::STATUS, $this->onpage_option ) ) { + return $this->onpage_option[ self::STATUS ]; + } + + return self::CANNOT_FETCH; + } + + /** + * Saving the status to the options. + * + * @param string $status The status to save. + */ + public function set_status( $status ) { + $this->onpage_option[ self::STATUS ] = $status; + } + + /** + * Saving the last fetch timestamp to the options. + * + * @param integer $timestamp Timestamp with the new value. + */ + public function set_last_fetch( $timestamp ) { + $this->onpage_option[ self::LAST_FETCH ] = $timestamp; + } + + /** + * Check if the last fetch is within the time of 60 minutes + * + * @return bool + */ + public function should_be_fetched() { + return ( ( time() - $this->onpage_option[ self::LAST_FETCH ] ) > self::FETCH_LIMIT ); + } + + /** + * Saving the option with the current data + */ + public function save_option() { + update_option( self::OPTION_NAME, $this->onpage_option ); + } + + /** + * Returns the value of the onpage_enabled status + * + * @return bool + */ + public function is_enabled() { + $options = get_option( 'wpseo' ); + + return ! empty( $options['onpage_indexability'] ); + } + + /** + * Getting the option with the OnPage.org data + * + * @return array + */ + private function get_option() { + return get_option( self::OPTION_NAME, array( self::STATUS => self::NOT_FETCHED, self::LAST_FETCH => 0 ) ); + } + + /** + * @deprecated 3.0.2 + * + * Returns the indexable status of the website. + * + * @return bool + */ + public function is_indexable() { + _deprecated_function( 'WPSEO_OnPage_Option::is_indexable', 'WPSEO 3.0.2' ); + + return self::IS_INDEXABLE === $this->get_status(); + } + +} diff --git a/wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-request.php b/wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-request.php new file mode 100644 index 00000000..59159048 --- /dev/null +++ b/wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage-request.php @@ -0,0 +1,78 @@ +response = $this->do_request( $target_url ); + } + + /** + * Returns the fetched response + * + * @return array + */ + public function get_response() { + return $this->response; + } + + /** + * Doing the remote get and returns the body + * + * @param string $target_url The home url. + * + * @return array + * @throws Exception The error message that can be used to show to the user. + */ + protected function get_remote( $target_url ) { + $response = wp_remote_get( $this->onpage_endpoint . '?url=' . $target_url ); + $response_code = wp_remote_retrieve_response_code( $response ); + + // When the request is successful, the response code will be 200. + if ( $response_code === 200 ) { + $response_body = wp_remote_retrieve_body( $response ); + + return json_decode( $response_body, true ); + } + } + + /** + * Sending a request to OnPage to check if the $home_url is indexable + * + * @param string $target_url The URL that will be send to the API. + * + * @return array + */ + private function do_request( $target_url ) { + $json_body = $this->get_remote( $target_url ); + + // OnPage.org recognized a redirect, fetch the data of that URL by calling this method with the value from OnPage.org. + if ( ! empty( $json_body['passes_juice_to'] ) ) { + return $this->do_request( $json_body['passes_juice_to'] ); + } + + return $json_body; + } + +} diff --git a/wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage.php b/wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage.php new file mode 100644 index 00000000..dec22722 --- /dev/null +++ b/wp/wp-content/plugins/wordpress-seo/admin/onpage/class-onpage.php @@ -0,0 +1,206 @@ +onpage_option = new WPSEO_OnPage_Option(); + + if ( $this->onpage_option->is_enabled() ) { + $this->set_hooks(); + $this->catch_redo_listener(); + } + } + } + + /** + * The hooks to run on plugin activation + */ + public function activate_hooks() { + $this->set_cron(); + } + + /** + * Adding a weekly schedule to the schedules array + * + * @param array $schedules Array with schedules. + * + * @return array + */ + public function add_weekly_schedule( array $schedules ) { + $schedules['weekly'] = array( 'interval' => WEEK_IN_SECONDS, 'display' => __( 'Once Weekly' ) ); + + return $schedules; + } + + /** + * Fetching the data from onpage. + * + * @return bool + */ + public function fetch_from_onpage() { + if ( $this->onpage_option->should_be_fetched() && false !== ( $new_status = $this->request_indexability() ) ) { + + // Updates the timestamp in the option. + $this->onpage_option->set_last_fetch( time() ); + + // The currently indexability status. + $old_status = $this->onpage_option->get_status(); + + // Saving the new status. + $this->onpage_option->set_status( $new_status ); + + // Saving the option. + $this->onpage_option->save_option(); + + // Check if the status has been changed. + if ( $old_status !== $new_status && $new_status !== WPSEO_OnPage_Option::CANNOT_FETCH ) { + $this->notify_admins( $old_status, $new_status ); + } + + return true; + } + + return false; + } + + /** + * Show a notice when the website is not indexable + */ + public function show_notice() { + if ( $this->should_show_notice() ) { + $notice = sprintf( + /* translators: 1: opens a link to a related knowledge base article. 2: closes the link */ + __( '%1$sYour homepage cannot be indexed by search engines%2$s. This is very bad for SEO and should be fixed.', 'wordpress-seo' ), + '', + '' + ); + + Yoast_Notification_Center::get()->add_notification( + new Yoast_Notification( + $notice, + array( + 'type' => 'error yoast-dismissible', + 'id' => 'wpseo-dismiss-onpageorg', + 'nonce' => wp_create_nonce( 'wpseo-dismiss-onpageorg' ), + ) + ) + ); + } + } + + /** + * Send a request to OnPage.org to get the indexability + * + * @return int(0)|int(1)|false + */ + protected function request_indexability() { + $request = new WPSEO_OnPage_Request( get_option( 'home' ) ); + $response = $request->get_response(); + + if ( isset( $response['is_indexable'] ) ) { + return (int) $response['is_indexable']; + } + + return WPSEO_OnPage_Option::CANNOT_FETCH; + } + + /** + * Should the notice being given? + * + * @return bool + */ + protected function should_show_notice() { + // If development note is on or the tagline notice is shown, just don't show this notice. + if ( WPSEO_Utils::is_development_mode() || ( '0' === get_option( 'blog_public' ) ) ) { + return false; + } + + return WPSEO_Utils::grant_access() && ! $this->user_has_dismissed() && $this->onpage_option->get_status() === WPSEO_OnPage_Option::IS_NOT_INDEXABLE; + } + + /** + * Notify the admins + * + * @param int|null $old_status The old indexable status. + * @param int $new_status The new indexable status. + */ + protected function notify_admins( $old_status, $new_status ) { + $notify = new WPSEO_OnPage_Notifier( $old_status, $new_status ); + + $notify->send_email( $old_status, $new_status ); + $notify->show_notices(); + } + + /** + * Setting up the hooks. + */ + private function set_hooks() { + // Schedule cronjob when it doesn't exists on activation. + register_activation_hook( WPSEO_FILE, array( $this, 'activate_hooks' ) ); + + // Add weekly schedule to the cron job schedules. + add_filter( 'cron_schedules', array( $this, 'add_weekly_schedule' ) ); + + // Adding admin notice if necessary. + add_filter( 'admin_init', array( $this, 'show_notice' ) ); + + // Setting the action for the OnPage fetch. + add_action( 'wpseo_onpage_fetch', array( $this, 'fetch_from_onpage' ) ); + } + + /** + * Setting the cronjob to get the new indexibility status. + */ + private function set_cron() { + if ( ! wp_next_scheduled( 'wpseo_onpage_fetch' ) ) { + wp_schedule_event( time(), 'weekly', 'wpseo_onpage_fetch' ); + } + } + + /** + * Get the state from the user to check if the current user has dismissed + * + * @return mixed + */ + private function user_has_dismissed() { + return '1' === get_user_meta( get_current_user_id(), WPSEO_OnPage::USER_META_KEY, true ); + } + + /** + * Redo the fetch request for onpage + */ + private function catch_redo_listener() { + if ( filter_input( INPUT_GET, 'wpseo-redo-onpage' ) === '1' ) { + $this->is_manual_request = true; + + add_action( 'admin_init', array( $this, 'fetch_from_onpage' ) ); + } + } + +} diff --git a/wp/wp-content/plugins/wordpress-seo/admin/pages/dashboard.php b/wp/wp-content/plugins/wordpress-seo/admin/pages/dashboard.php index 4036899f..0c377434 100644 --- a/wp/wp-content/plugins/wordpress-seo/admin/pages/dashboard.php +++ b/wp/wp-content/plugins/wordpress-seo/admin/pages/dashboard.php @@ -148,6 +148,7 @@ if ( get_option( 'page_comments' ) && $options['ignore_page_comments'] === false + OnPage.org
@@ -189,6 +190,7 @@ if ( get_option( 'page_comments' ) && $options['ignore_page_comments'] === false

+

@@ -243,6 +245,12 @@ if ( get_option( 'page_comments' ) && $options['ignore_page_comments'] === false $yform->checkbox( 'disableadvanced_meta', sprintf( __( 'Disable the Advanced part of the %1$s meta box', 'wordpress-seo' ), 'Yoast SEO' ) ); ?>
+
+ checkbox( 'onpage_indexability', sprintf( __( 'Enable %1$s indexability check', 'wordpress-seo' ), 'OnPage.org' ) ); + ?> +
-

+ ?>