summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury German <blueknight@gentoo.org>2022-06-15 12:08:35 -0400
committerYury German <blueknight@gentoo.org>2022-06-15 12:08:35 -0400
commit36d7691c33cb64ece817246e47a779ec648d10b0 (patch)
tree08f2fb95303a1d8eeba2c8629a24b35a91fb1cac /plugins/jetpack/modules
parenttwentyfourteen upg 2.7 to 3.2 and twentysixteen from 2.0 to 2.5 (diff)
downloadblogs-gentoo-36d7691c33cb64ece817246e47a779ec648d10b0.tar.gz
blogs-gentoo-36d7691c33cb64ece817246e47a779ec648d10b0.tar.bz2
blogs-gentoo-36d7691c33cb64ece817246e47a779ec648d10b0.zip
Openid-3.6.1 and jetpack-11.0 upgrade
Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules')
-rw-r--r--plugins/jetpack/modules/.eslintrc.js40
-rw-r--r--plugins/jetpack/modules/after-the-deadline.php6
-rw-r--r--plugins/jetpack/modules/calypsoify/class-jetpack-calypsoify.php12
-rw-r--r--plugins/jetpack/modules/calypsoify/class.jetpack-calypsoify.php507
-rw-r--r--plugins/jetpack/modules/calypsoify/style-gutenberg-rtl.min.css4
-rw-r--r--plugins/jetpack/modules/calypsoify/style-gutenberg.min.css3
-rw-r--r--plugins/jetpack/modules/calypsoify/style-rtl.min.css4
-rw-r--r--plugins/jetpack/modules/calypsoify/style.min.css3
-rw-r--r--plugins/jetpack/modules/carousel.php8
-rw-r--r--plugins/jetpack/modules/carousel/images/arrows-2x.pngbin10063 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/carousel/images/arrows.pngbin4529 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/carousel/images/carousel-likereblog-2x.pngbin1096 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/carousel/images/carousel-likereblog.pngbin547 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/carousel/images/carousel-link-2x.pngbin867 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/carousel/images/carousel-link.pngbin431 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/carousel/images/carousel-sprite-2x.pngbin2076 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/carousel/images/carousel-sprite.pngbin1318 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/carousel/jetpack-carousel-rtl.css2
-rw-r--r--plugins/jetpack/modules/carousel/jetpack-carousel.php405
-rw-r--r--plugins/jetpack/modules/carousel/rtl/jetpack-carousel-rtl.css1134
-rw-r--r--plugins/jetpack/modules/cloudflare-analytics/cloudflare-analytics.php2
-rw-r--r--plugins/jetpack/modules/comments.php4
-rw-r--r--plugins/jetpack/modules/comments/admin.php95
-rw-r--r--plugins/jetpack/modules/comments/base.php143
-rw-r--r--plugins/jetpack/modules/comments/comments.php237
-rw-r--r--plugins/jetpack/modules/contact-form/css/editor-inline-editing-style-rtl.css923
-rw-r--r--plugins/jetpack/modules/contact-form/css/editor-inline-editing-style-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/contact-form/css/editor-inline-editing-style.css3
-rw-r--r--plugins/jetpack/modules/contact-form/css/editor-inline-editing-style.min.css3
-rw-r--r--plugins/jetpack/modules/contact-form/css/editor-style-rtl.css790
-rw-r--r--plugins/jetpack/modules/contact-form/css/editor-style-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/contact-form/css/editor-style.min.css3
-rw-r--r--plugins/jetpack/modules/contact-form/css/editor-ui-rtl.css19
-rw-r--r--plugins/jetpack/modules/contact-form/css/editor-ui-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/contact-form/css/editor-ui.min.css3
-rw-r--r--plugins/jetpack/modules/contact-form/css/grunion-rtl.css2
-rw-r--r--plugins/jetpack/modules/contact-form/css/grunion.css12
-rw-r--r--plugins/jetpack/modules/contact-form/grunion-contact-form.php20
-rw-r--r--plugins/jetpack/modules/copy-post.php17
-rw-r--r--plugins/jetpack/modules/custom-content-types.php17
-rw-r--r--plugins/jetpack/modules/custom-css.php40
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/class.csstidy-ctype.php (renamed from plugins/jetpack/modules/custom-css/csstidy/class.csstidy_ctype.php)31
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/class.csstidy-optimise.php1007
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/class.csstidy-print.php432
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/class.csstidy.php1014
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/class.csstidy_optimise.php943
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/class.csstidy_print.php410
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/cssparse-rtl.css125
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/cssparse-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/cssparse.min.css3
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/cssparsed-rtl.css21
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/cssparsed-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/cssparsed.min.css3
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/data-wp.inc.php90
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/data.inc.php1124
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/lang.inc.php89
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css-4.7.php428
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css.php995
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css/css/codemirror-rtl.css269
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css/css/codemirror-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css/css/codemirror.min.css3
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css/css/css-editor-rtl.css23
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css/css/css-editor.min.css1
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css/css/use-codemirror-rtl.css11
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css/css/use-codemirror.min.css1
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css/preprocessors.php27
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css/preprocessors/lessc.inc.php3
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css/preprocessors/scss.inc.php4
-rw-r--r--plugins/jetpack/modules/custom-css/migrate-to-core.php114
-rw-r--r--plugins/jetpack/modules/custom-post-types/comics.php477
-rw-r--r--plugins/jetpack/modules/custom-post-types/comics/comics-rtl.css73
-rw-r--r--plugins/jetpack/modules/custom-post-types/comics/comics-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/custom-post-types/comics/comics.min.css3
-rw-r--r--plugins/jetpack/modules/custom-post-types/nova.php1428
-rw-r--r--plugins/jetpack/modules/custom-post-types/portfolios.php942
-rw-r--r--plugins/jetpack/modules/custom-post-types/testimonial.php606
-rw-r--r--plugins/jetpack/modules/enhanced-distribution.php60
-rw-r--r--plugins/jetpack/modules/geo-location.php38
-rw-r--r--plugins/jetpack/modules/geo-location/class.jetpack-geo-location.php33
-rw-r--r--plugins/jetpack/modules/google-analytics.php6
-rw-r--r--plugins/jetpack/modules/google-analytics/classes/class-jetpack-google-amp-analytics.php2
-rw-r--r--plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-legacy.php42
-rw-r--r--plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-options.php102
-rw-r--r--plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-universal.php159
-rw-r--r--plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-utils.php30
-rw-r--r--plugins/jetpack/modules/google-analytics/wp-google-analytics.php60
-rw-r--r--plugins/jetpack/modules/google-fonts.php107
-rw-r--r--plugins/jetpack/modules/gravatar-hovercards.php140
-rw-r--r--plugins/jetpack/modules/infinite-scroll.php71
-rw-r--r--plugins/jetpack/modules/infinite-scroll/infinity.php533
-rw-r--r--plugins/jetpack/modules/infinite-scroll/themes/twentyeleven.php21
-rw-r--r--plugins/jetpack/modules/infinite-scroll/themes/twentyfifteen.php13
-rw-r--r--plugins/jetpack/modules/infinite-scroll/themes/twentyfourteen.php18
-rw-r--r--plugins/jetpack/modules/infinite-scroll/themes/twentyseventeen.php21
-rw-r--r--plugins/jetpack/modules/infinite-scroll/themes/twentysixteen.php15
-rw-r--r--plugins/jetpack/modules/infinite-scroll/themes/twentyten.php19
-rw-r--r--plugins/jetpack/modules/infinite-scroll/themes/twentythirteen.php15
-rw-r--r--plugins/jetpack/modules/infinite-scroll/themes/twentytwelve.php20
-rw-r--r--plugins/jetpack/modules/latex.php48
-rw-r--r--plugins/jetpack/modules/lazy-images.php6
-rw-r--r--plugins/jetpack/modules/lazy-images/images/1x1.trans.gifbin42 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/lazy-images/js/lazy-images.js868
-rw-r--r--plugins/jetpack/modules/lazy-images/lazy-images.php355
-rw-r--r--plugins/jetpack/modules/likes/jetpack-likes-master-iframe.php17
-rw-r--r--plugins/jetpack/modules/likes/jetpack-likes-settings.php259
-rw-r--r--plugins/jetpack/modules/markdown.php6
-rw-r--r--plugins/jetpack/modules/markdown/easy-markdown.php357
-rw-r--r--plugins/jetpack/modules/masterbar/admin-menu/admin-menu-rtl.css594
-rw-r--r--plugins/jetpack/modules/masterbar/admin-menu/admin-menu-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/masterbar/admin-menu/admin-menu.css80
-rw-r--r--plugins/jetpack/modules/masterbar/admin-menu/admin-menu.js42
-rw-r--r--plugins/jetpack/modules/masterbar/admin-menu/admin-menu.min.css3
-rw-r--r--plugins/jetpack/modules/masterbar/admin-menu/class-admin-menu.php133
-rw-r--r--plugins/jetpack/modules/masterbar/admin-menu/class-atomic-admin-menu.php71
-rw-r--r--plugins/jetpack/modules/masterbar/admin-menu/class-base-admin-menu.php81
-rw-r--r--plugins/jetpack/modules/masterbar/admin-menu/class-dashboard-switcher-tracking.php8
-rw-r--r--plugins/jetpack/modules/masterbar/admin-menu/class-wpcom-admin-menu.php27
-rw-r--r--plugins/jetpack/modules/masterbar/admin-menu/load.php2
-rw-r--r--plugins/jetpack/modules/masterbar/masterbar.php1392
-rw-r--r--plugins/jetpack/modules/masterbar/masterbar/class-masterbar.php11
-rw-r--r--plugins/jetpack/modules/masterbar/nudges/additional-css/class-atomic-additional-css-manager.php4
-rw-r--r--plugins/jetpack/modules/masterbar/nudges/additional-css/class-wpcom-additional-css-manager.php9
-rw-r--r--plugins/jetpack/modules/masterbar/overrides.css132
-rw-r--r--plugins/jetpack/modules/masterbar/rtl-admin-bar.php55
-rw-r--r--plugins/jetpack/modules/masterbar/tracks-events.js160
-rw-r--r--plugins/jetpack/modules/masterbar/wp-posts-list/class-posts-list-page-notification.php2
-rw-r--r--plugins/jetpack/modules/memberships/class-jetpack-memberships.php14
-rw-r--r--plugins/jetpack/modules/minileven.php57
-rw-r--r--plugins/jetpack/modules/minileven/images/wp-app-devices.pngbin1014 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/minileven/minileven.php360
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/comments.php52
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/content-gallery.php83
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/content.php63
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/footer.php78
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/functions.php275
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/header.php70
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/image.php108
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/inc/custom-header.php107
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.eotbin7475 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.svg81
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.ttfbin13516 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.woffbin8676 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/inc/template-tags.php96
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/inc/tweaks.php103
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/index.php75
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/js/small-menu.js38
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/page.php47
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/rtl.css574
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/screenshot.pngbin58138 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/searchform.php12
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/sidebar.php12
-rw-r--r--plugins/jetpack/modules/minileven/theme/pub/minileven/style.css1588
-rw-r--r--plugins/jetpack/modules/mobile-push.php6
-rw-r--r--plugins/jetpack/modules/module-headings.php86
-rw-r--r--plugins/jetpack/modules/module-info.php18
-rw-r--r--plugins/jetpack/modules/monitor.php2
-rw-r--r--plugins/jetpack/modules/photon-cdn.php25
-rw-r--r--plugins/jetpack/modules/photon-cdn/jetpack-manifest.php798
-rw-r--r--plugins/jetpack/modules/post-by-email/post-by-email-rtl.css6
-rw-r--r--plugins/jetpack/modules/post-by-email/post-by-email.min.css1
-rw-r--r--plugins/jetpack/modules/protect.php399
-rw-r--r--plugins/jetpack/modules/protect/blocked-login-page.php258
-rw-r--r--plugins/jetpack/modules/protect/math-fallback.php102
-rw-r--r--plugins/jetpack/modules/protect/protect-dashboard-widget-rtl.css94
-rw-r--r--plugins/jetpack/modules/protect/protect-dashboard-widget-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/protect/protect-dashboard-widget.min.css3
-rw-r--r--plugins/jetpack/modules/protect/shared-functions.php15
-rw-r--r--plugins/jetpack/modules/protect/transient-cleanup.php35
-rw-r--r--plugins/jetpack/modules/publicize.php79
-rw-r--r--plugins/jetpack/modules/publicize/enhanced-open-graph.php144
-rw-r--r--plugins/jetpack/modules/publicize/publicize-jetpack.php657
-rw-r--r--plugins/jetpack/modules/publicize/publicize.php789
-rw-r--r--plugins/jetpack/modules/publicize/ui.php292
-rw-r--r--plugins/jetpack/modules/pwa.php4
-rw-r--r--plugins/jetpack/modules/pwa/class.jetpack-pwa-helpers.php4
-rw-r--r--plugins/jetpack/modules/pwa/class.jetpack-pwa-manifest.php4
-rw-r--r--plugins/jetpack/modules/pwa/images/wp-192.pngbin6584 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/pwa/images/wp-512.pngbin16496 -> 0 bytes
-rw-r--r--plugins/jetpack/modules/related-posts.php19
-rw-r--r--plugins/jetpack/modules/related-posts/class.related-posts-customize.php96
-rw-r--r--plugins/jetpack/modules/related-posts/jetpack-related-posts.php724
-rw-r--r--plugins/jetpack/modules/related-posts/related-posts-rtl.css2
-rw-r--r--plugins/jetpack/modules/scan/class-admin-bar-notice.php2
-rw-r--r--plugins/jetpack/modules/scan/class-admin-sidebar-link.php7
-rw-r--r--plugins/jetpack/modules/scan/scan.php4
-rw-r--r--plugins/jetpack/modules/search.php35
-rw-r--r--plugins/jetpack/modules/search/class-jetpack-instant-search.php629
-rw-r--r--plugins/jetpack/modules/search/class-jetpack-search-customberg.php141
-rw-r--r--plugins/jetpack/modules/search/class-jetpack-search-customize.php283
-rw-r--r--plugins/jetpack/modules/search/class.jetpack-search-helpers.php701
-rw-r--r--plugins/jetpack/modules/search/class.jetpack-search-template-tags.php225
-rw-r--r--plugins/jetpack/modules/search/class.jetpack-search.php1959
-rw-r--r--plugins/jetpack/modules/search/customize-controls/class-excluded-post-types-control.css5
-rw-r--r--plugins/jetpack/modules/search/customize-controls/class-excluded-post-types-control.js23
-rw-r--r--plugins/jetpack/modules/search/customize-controls/class-excluded-post-types-control.php128
-rw-r--r--plugins/jetpack/modules/search/customize-controls/class-label-control.css18
-rw-r--r--plugins/jetpack/modules/search/customize-controls/class-label-control.php48
-rw-r--r--plugins/jetpack/modules/search/customize-controls/customize-controls.js43
-rw-r--r--plugins/jetpack/modules/seo-tools/class-jetpack-seo-utils.php14
-rw-r--r--plugins/jetpack/modules/seo-tools/jetpack-seo-posts.php91
-rw-r--r--plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php301
-rw-r--r--plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php126
-rw-r--r--plugins/jetpack/modules/seo-tools/jetpack-seo.php206
-rw-r--r--plugins/jetpack/modules/sharedaddy.php2
-rw-r--r--plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.css472
-rw-r--r--plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/sharedaddy/admin-sharing.min.css3
-rw-r--r--plugins/jetpack/modules/sharedaddy/amp-sharing.css9
-rw-r--r--plugins/jetpack/modules/sharedaddy/recaptcha.php11
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharedaddy.php281
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing-service.php363
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing-sources.php1519
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.css77
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.js260
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.php397
-rw-r--r--plugins/jetpack/modules/shortcodes.php14
-rw-r--r--plugins/jetpack/modules/shortcodes/css/recipes-print.min.css1
-rw-r--r--plugins/jetpack/modules/shortcodes/css/recipes-rtl.css2
-rw-r--r--plugins/jetpack/modules/shortcodes/css/recipes-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/shortcodes/css/recipes.min.css3
-rw-r--r--plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.css284
-rw-r--r--plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.css46
-rw-r--r--plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css3
-rw-r--r--plugins/jetpack/modules/shortcodes/descript.php116
-rw-r--r--plugins/jetpack/modules/shortcodes/hulu.php275
-rw-r--r--plugins/jetpack/modules/shortcodes/js/gist.js32
-rw-r--r--plugins/jetpack/modules/shortcodes/js/instagram.js25
-rw-r--r--plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js12
-rw-r--r--plugins/jetpack/modules/shortcodes/quiz.php4
-rw-r--r--plugins/jetpack/modules/shortcodes/slideshow.php45
-rw-r--r--plugins/jetpack/modules/shortcodes/wufoo.php2
-rw-r--r--plugins/jetpack/modules/shortlinks.php23
-rw-r--r--plugins/jetpack/modules/simple-payments/paypal-express-checkout.js1
-rw-r--r--plugins/jetpack/modules/simple-payments/simple-payments.css14
-rw-r--r--plugins/jetpack/modules/simple-payments/simple-payments.php567
-rw-r--r--plugins/jetpack/modules/sitemaps.php2
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer-fallback.php19
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer-image-fallback.php7
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer-image.php13
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer-master-fallback.php6
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer-master.php14
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer-news-fallback.php9
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer-news.php16
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer-page-fallback.php7
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer-page.php14
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php7
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer-video.php14
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer.php7
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-builder.php28
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-constants.php6
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-finder.php4
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-librarian.php22
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-logger.php4
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-state.php2
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-stylist.php17
-rw-r--r--plugins/jetpack/modules/sso.php413
-rw-r--r--plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php521
-rw-r--r--plugins/jetpack/modules/sso/class.jetpack-sso-notices.php7
-rw-r--r--plugins/jetpack/modules/sso/jetpack-sso-login-rtl.css155
-rw-r--r--plugins/jetpack/modules/sso/jetpack-sso-login-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/sso/jetpack-sso-login.min.css3
-rw-r--r--plugins/jetpack/modules/stats.php102
-rw-r--r--plugins/jetpack/modules/stats/class-jetpack-stats-upgrade-nudges.php11
-rw-r--r--plugins/jetpack/modules/subscriptions.php379
-rw-r--r--plugins/jetpack/modules/subscriptions/views.php563
-rw-r--r--plugins/jetpack/modules/theme-tools.php16
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentyfifteen.css16
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentyfifteen.php8
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentyfourteen.css4
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentyfourteen.php13
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentynineteen-rtl.css2
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentynineteen.php81
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentyseventeen.php5
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentysixteen.css4
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentysixteen.php13
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentytwenty-rtl.css2
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentytwenty.css2
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentytwentyone-rtl.css2
-rw-r--r--plugins/jetpack/modules/theme-tools/content-options.php28
-rw-r--r--plugins/jetpack/modules/theme-tools/content-options/author-bio.php18
-rw-r--r--plugins/jetpack/modules/theme-tools/content-options/blog-display.php22
-rw-r--r--plugins/jetpack/modules/theme-tools/content-options/customizer.php54
-rw-r--r--plugins/jetpack/modules/theme-tools/content-options/featured-images-fallback.php16
-rw-r--r--plugins/jetpack/modules/theme-tools/content-options/featured-images.php16
-rw-r--r--plugins/jetpack/modules/theme-tools/content-options/post-details.php28
-rw-r--r--plugins/jetpack/modules/theme-tools/featured-content.php74
-rw-r--r--plugins/jetpack/modules/theme-tools/infinite-scroll.php13
-rw-r--r--plugins/jetpack/modules/theme-tools/random-redirect.php92
-rw-r--r--plugins/jetpack/modules/theme-tools/responsive-videos.php18
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo.php22
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control-rtl.css49
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control-rtl.min.css1
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control.css49
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control.min.css2
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo-control.php128
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo.php41
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo/inc/functions.php6
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo/js/site-logo-control.js160
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo/js/site-logo-control.min.js1
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo/js/site-logo.js46
-rw-r--r--plugins/jetpack/modules/theme-tools/site-logo/js/site-logo.min.js1
-rw-r--r--plugins/jetpack/modules/theme-tools/social-links.php21
-rw-r--r--plugins/jetpack/modules/theme-tools/social-menu.php6
-rw-r--r--plugins/jetpack/modules/tiled-gallery.php11
-rw-r--r--plugins/jetpack/modules/tiled-gallery/math/class-constrained-array-rounding.php43
-rw-r--r--plugins/jetpack/modules/tiled-gallery/tiled-gallery.php133
-rw-r--r--plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/carousel-container.php22
-rw-r--r--plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/carousel-image-args.php13
-rw-r--r--plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/item.php20
-rw-r--r--plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-circle.php12
-rw-r--r--plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-item.php81
-rw-r--r--plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-layout.php96
-rw-r--r--plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-rectangular.php159
-rw-r--r--plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-rtl.css2
-rw-r--r--plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-shape.php252
-rw-r--r--plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-square.php40
-rw-r--r--plugins/jetpack/modules/vaultpress.php13
-rw-r--r--plugins/jetpack/modules/verification-tools/blog-verification-tools.php20
-rw-r--r--plugins/jetpack/modules/verification-tools/verification-tools-utils.php17
-rw-r--r--plugins/jetpack/modules/videopress.php23
-rw-r--r--plugins/jetpack/modules/videopress/class-videopress-attachment-metadata.php47
-rw-r--r--plugins/jetpack/modules/videopress/class.jetpack-videopress.php96
-rw-r--r--plugins/jetpack/modules/videopress/class.videopress-ajax.php191
-rw-r--r--plugins/jetpack/modules/videopress/class.videopress-cli.php30
-rw-r--r--plugins/jetpack/modules/videopress/class.videopress-edit-attachment.php97
-rw-r--r--plugins/jetpack/modules/videopress/class.videopress-gutenberg.php83
-rw-r--r--plugins/jetpack/modules/videopress/class.videopress-options.php28
-rw-r--r--plugins/jetpack/modules/videopress/class.videopress-player.php98
-rw-r--r--plugins/jetpack/modules/videopress/class.videopress-scheduler.php28
-rw-r--r--plugins/jetpack/modules/videopress/class.videopress-video.php40
-rw-r--r--plugins/jetpack/modules/videopress/class.videopress-xmlrpc.php22
-rw-r--r--plugins/jetpack/modules/videopress/css/editor-rtl.css54
-rw-r--r--plugins/jetpack/modules/videopress/css/editor-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/videopress/css/editor.min.css3
-rw-r--r--plugins/jetpack/modules/videopress/css/videopress-editor-style-rtl.css29
-rw-r--r--plugins/jetpack/modules/videopress/css/videopress-editor-style-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/videopress/css/videopress-editor-style.min.css3
-rw-r--r--plugins/jetpack/modules/videopress/editor-media-view.php43
-rw-r--r--plugins/jetpack/modules/videopress/js/gutenberg-video-upload.js2
-rw-r--r--plugins/jetpack/modules/videopress/js/videopress-add-resumable-upload-support.js1
-rw-r--r--plugins/jetpack/modules/videopress/js/videopress-token-bridge.js54
-rw-r--r--plugins/jetpack/modules/videopress/shortcode.php45
-rw-r--r--plugins/jetpack/modules/videopress/utility-functions.php100
-rw-r--r--plugins/jetpack/modules/videopress/videopress-admin-rtl.css125
-rw-r--r--plugins/jetpack/modules/videopress/videopress-admin-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/videopress/videopress-admin.min.css3
-rw-r--r--plugins/jetpack/modules/waf.php13
-rw-r--r--plugins/jetpack/modules/widget-visibility.php8
-rw-r--r--plugins/jetpack/modules/widget-visibility/widget-conditions.php176
-rw-r--r--plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.css214
-rw-r--r--plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.min.css3
-rw-r--r--plugins/jetpack/modules/widgets.php35
-rw-r--r--plugins/jetpack/modules/widgets/authors.php87
-rw-r--r--plugins/jetpack/modules/widgets/blog-stats.php14
-rw-r--r--plugins/jetpack/modules/widgets/class-jetpack-eu-cookie-law-widget.php (renamed from plugins/jetpack/modules/widgets/eu-cookie-law.php)42
-rw-r--r--plugins/jetpack/modules/widgets/contact-info.php2
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/form.php37
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/widget.php10
-rw-r--r--plugins/jetpack/modules/widgets/facebook-likebox.php175
-rw-r--r--plugins/jetpack/modules/widgets/flickr.php30
-rw-r--r--plugins/jetpack/modules/widgets/flickr/form.php30
-rw-r--r--plugins/jetpack/modules/widgets/flickr/widget.php11
-rw-r--r--plugins/jetpack/modules/widgets/gallery.php119
-rw-r--r--plugins/jetpack/modules/widgets/gallery/css/admin-rtl.css15
-rw-r--r--plugins/jetpack/modules/widgets/gallery/css/admin-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/widgets/gallery/css/admin.min.css3
-rw-r--r--plugins/jetpack/modules/widgets/gallery/templates/form.php82
-rw-r--r--plugins/jetpack/modules/widgets/goodreads.php115
-rw-r--r--plugins/jetpack/modules/widgets/google-translate.php46
-rw-r--r--plugins/jetpack/modules/widgets/gravatar-profile.php179
-rw-r--r--plugins/jetpack/modules/widgets/image-widget.php168
-rw-r--r--plugins/jetpack/modules/widgets/internet-defense-league.php136
-rw-r--r--plugins/jetpack/modules/widgets/mailchimp.php13
-rw-r--r--plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php8
-rw-r--r--plugins/jetpack/modules/widgets/my-community.php13
-rw-r--r--plugins/jetpack/modules/widgets/search.php1083
-rw-r--r--plugins/jetpack/modules/widgets/search/css/search-widget-admin-ui.css87
-rw-r--r--plugins/jetpack/modules/widgets/search/css/search-widget-frontend.css66
-rw-r--r--plugins/jetpack/modules/widgets/search/js/search-widget-admin.js358
-rw-r--r--plugins/jetpack/modules/widgets/search/js/search-widget.js47
-rw-r--r--plugins/jetpack/modules/widgets/simple-payments.php137
-rw-r--r--plugins/jetpack/modules/widgets/simple-payments/admin-warning.php17
-rw-r--r--plugins/jetpack/modules/widgets/simple-payments/form.php33
-rw-r--r--plugins/jetpack/modules/widgets/simple-payments/widget.php9
-rw-r--r--plugins/jetpack/modules/widgets/top-posts.php128
-rw-r--r--plugins/jetpack/modules/widgets/wordpress-post-widget.php19
-rw-r--r--plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget-base.php165
-rw-r--r--plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget.php48
-rw-r--r--plugins/jetpack/modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-universal.php2
-rw-r--r--plugins/jetpack/modules/woocommerce-analytics/classes/wp-woocommerce-analytics-universal.php403
-rw-r--r--plugins/jetpack/modules/woocommerce-analytics/wp-woocommerce-analytics.php94
-rw-r--r--plugins/jetpack/modules/wordads/class-wordads.php12
-rw-r--r--plugins/jetpack/modules/wordads/php/admin.php49
-rw-r--r--plugins/jetpack/modules/wordads/php/api.php146
-rw-r--r--plugins/jetpack/modules/wordads/php/class-wordads-api.php127
-rw-r--r--plugins/jetpack/modules/wordads/php/class-wordads-california-privacy.php8
-rw-r--r--plugins/jetpack/modules/wordads/php/class-wordads-params.php17
-rw-r--r--plugins/jetpack/modules/wordads/php/class-wordads-sidebar-widget.php14
-rw-r--r--plugins/jetpack/modules/wordads/php/cron.php48
-rw-r--r--plugins/jetpack/modules/wordads/php/params.php228
-rw-r--r--plugins/jetpack/modules/wordads/php/widgets.php115
-rw-r--r--plugins/jetpack/modules/wordads/wordads.php717
-rw-r--r--plugins/jetpack/modules/wpcom-block-editor/class-jetpack-wpcom-block-editor.php23
405 files changed, 20725 insertions, 30741 deletions
diff --git a/plugins/jetpack/modules/.eslintrc.js b/plugins/jetpack/modules/.eslintrc.js
deleted file mode 100644
index 527bbeab..00000000
--- a/plugins/jetpack/modules/.eslintrc.js
+++ /dev/null
@@ -1,40 +0,0 @@
-module.exports = {
- plugins: [ 'es5' ],
- extends: [ 'eslint:recommended', 'plugin:es5/no-es2015' ],
- env: {
- browser: true,
- jquery: true,
- },
- globals: {
- _: false,
- Backbone: false,
- // jQuery: false,
- wp: false,
- },
- parserOptions: {
- ecmaVersion: 5,
- },
- rules: {
- // TODO: maybe fix the above warnings
- eqeqeq: 'warn',
- curly: 'warn',
- 'no-console': 'warn',
- 'no-empty': 'warn',
- 'no-unused-vars': 'warn',
- 'es5/no-es6-methods': 0, // TODO: maybe disable it on line/file basis
- 'no-useless-escape': 0,
- 'no-control-regex': 0,
- 'no-unused-expressions': 'warn',
-
- 'es5/no-block-scoping': [ 'error' ],
- 'no-caller': 'error',
- 'no-cond-assign': [ 'error', 'except-parens' ],
- 'no-eq-null': 'error',
- 'no-irregular-whitespace': 'error',
- 'no-trailing-spaces': 'error',
- 'no-undef': 'error',
- // 'one-var': [ 'error', 'always' ],
- quotes: [ 'warn', 'single', { avoidEscape: true } ],
- 'wrap-iife': [ 'error', 'any' ],
- },
-};
diff --git a/plugins/jetpack/modules/after-the-deadline.php b/plugins/jetpack/modules/after-the-deadline.php
deleted file mode 100644
index 88c13090..00000000
--- a/plugins/jetpack/modules/after-the-deadline.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * Deprecated. No longer needed.
- *
- * @package Jetpack
- */
diff --git a/plugins/jetpack/modules/calypsoify/class-jetpack-calypsoify.php b/plugins/jetpack/modules/calypsoify/class-jetpack-calypsoify.php
index 080cf508..b704b92c 100644
--- a/plugins/jetpack/modules/calypsoify/class-jetpack-calypsoify.php
+++ b/plugins/jetpack/modules/calypsoify/class-jetpack-calypsoify.php
@@ -100,7 +100,7 @@ class Jetpack_Calypsoify {
* @return string
*/
private function get_calypso_origin() {
- $origin = ! empty( $_GET['origin'] ) ? $_GET['origin'] : 'https://wordpress.com'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $origin = ! empty( $_GET['origin'] ) ? wp_unslash( $_GET['origin'] ) : 'https://wordpress.com'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$allowed = array(
'http://calypso.localhost:3000',
'http://127.0.0.1:41050', // Desktop App.
@@ -124,7 +124,7 @@ class Jetpack_Calypsoify {
$post_type = $screen->post_type;
$site_suffix = ( new Status() )->get_site_suffix();
- if ( is_null( $post_id ) ) {
+ if ( $post_id === null ) {
// E.g. posts or pages have no special suffix. CPTs are in the `types/{cpt}` format.
$post_type_suffix = ( 'post' === $post_type || 'page' === $post_type )
? "/${post_type}s/"
@@ -192,25 +192,25 @@ class Jetpack_Calypsoify {
public function is_page_gutenberg() {
// phpcs:disable WordPress.Security.NonceVerification.Recommended
// Disabling WordPress.Security.NonceVerification.Recommended because this function fires within admin_init and this is only changing display.
- $page = wp_basename( esc_url( $_SERVER['REQUEST_URI'] ) );
+ $page = isset( $_SERVER['REQUEST_URI'] ) ? wp_basename( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) : '';
if ( false !== strpos( $page, 'post-new.php' ) && empty( $_GET['post_type'] ) ) {
return true;
}
- if ( false !== strpos( $page, 'post-new.php' ) && isset( $_GET['post_type'] ) && $this->is_post_type_gutenberg( $_GET['post_type'] ) ) {
+ if ( false !== strpos( $page, 'post-new.php' ) && isset( $_GET['post_type'] ) && $this->is_post_type_gutenberg( sanitize_key( $_GET['post_type'] ) ) ) {
return true;
}
if ( false !== strpos( $page, 'post.php' ) ) {
- $post = get_post( $_GET['post'] );
+ $post = get_post( isset( $_GET['post'] ) ? intval( $_GET['post'] ) : null );
if ( isset( $post ) && isset( $post->post_type ) && $this->is_post_type_gutenberg( $post->post_type ) ) {
return true;
}
}
if ( false !== strpos( $page, 'revision.php' ) ) {
- $post = get_post( $_GET['revision'] );
+ $post = get_post( isset( $_GET['revision'] ) ? intval( $_GET['revision'] ) : null );
$parent = get_post( $post->post_parent );
if ( isset( $parent ) && isset( $parent->post_type ) && $this->is_post_type_gutenberg( $parent->post_type ) ) {
return true;
diff --git a/plugins/jetpack/modules/calypsoify/class.jetpack-calypsoify.php b/plugins/jetpack/modules/calypsoify/class.jetpack-calypsoify.php
deleted file mode 100644
index 36db8ea8..00000000
--- a/plugins/jetpack/modules/calypsoify/class.jetpack-calypsoify.php
+++ /dev/null
@@ -1,507 +0,0 @@
-<?php
-/**
- * This is Calypso skin of the wp-admin interface that is conditionally triggered via the ?calypsoify=1 param.
- * Ported from an internal Automattic plugin.
- */
-class Jetpack_Calypsoify {
-
- /**
- * Singleton instance of `Jetpack_Calypsoify`.
- *
- * @var object
- */
- public static $instance = false;
-
- /**
- * Is Calypsoify enabled, based on any value of `calypsoify` user meta.
- *
- * @var bool
- */
- public $is_calypsoify_enabled = false;
-
- private function __construct() {
- add_action( 'wp_loaded', array( $this, 'setup' ) );
- }
-
- public static function getInstance() {
- if ( ! self::$instance ) {
- self::$instance = new self();
- }
-
- return self::$instance;
- }
-
- public function setup() {
- $this->is_calypsoify_enabled = 1 == (int) get_user_meta( get_current_user_id(), 'calypsoify', true );
- add_action( 'admin_init', array( $this, 'check_param' ), 4 );
-
- if ( $this->is_calypsoify_enabled ) {
- add_action( 'admin_init', array( $this, 'setup_admin' ), 6 );
- add_action( 'admin_menu', array( $this, 'remove_core_menus' ), 100 );
- add_action( 'admin_menu', array( $this, 'add_custom_menus' ), 101 );
- }
-
- // Make this always available -- in case calypsoify gets toggled off.
- add_action( 'wp_ajax_jetpack_toggle_autoupdate', array( $this, 'jetpack_toggle_autoupdate' ) );
- add_filter( 'handle_bulk_actions-plugins', array( $this, 'handle_bulk_actions_plugins' ), 10, 3 );
- }
-
- public function setup_admin() {
- // Masterbar is currently required for this to work properly. Mock the instance of it
- if ( ! Jetpack::is_module_active( 'masterbar' ) ) {
- $this->mock_masterbar_activation();
- }
-
- if ( $this->is_page_gutenberg() ) {
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_for_gutenberg' ), 100 );
- return;
- }
-
- add_action( 'admin_init', array( $this, 'check_page' ) );
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 100 );
- add_action( 'in_admin_header', array( $this, 'insert_sidebar_html' ) );
- add_action( 'wp_before_admin_bar_render', array( $this, 'modify_masterbar' ), 100000 );
-
- add_filter( 'get_user_option_admin_color', array( $this, 'admin_color_override' ) );
-
- add_action( 'manage_plugins_columns', array( $this, 'manage_plugins_columns_header' ) );
- add_action( 'manage_plugins_custom_column', array( $this, 'manage_plugins_custom_column' ), 10, 2 );
- add_filter( 'bulk_actions-plugins', array( $this, 'bulk_actions_plugins' ) );
-
- add_action( 'current_screen', array( $this, 'attach_views_filter' ) );
-
- if ( 'plugins.php' === basename( $_SERVER['PHP_SELF'] ) ) {
- add_action( 'admin_notices', array( $this, 'plugins_admin_notices' ) );
- }
- }
-
- public function manage_plugins_columns_header( $columns ) {
- if ( current_user_can( 'jetpack_manage_autoupdates' ) ) {
- $columns['autoupdate'] = __( 'Automatic Update', 'jetpack' );
- }
- return $columns;
- }
-
- public function manage_plugins_custom_column( $column_name, $slug ) {
- static $repo_plugins = array();
-
- if ( ! current_user_can( 'jetpack_manage_autoupdates' ) ) {
- return;
- }
-
- if ( empty( $repo_plugins ) ) {
- $repo_plugins = self::get_dotorg_repo_plugins();
- }
-
- $autoupdating_plugins = Jetpack_Options::get_option( 'autoupdate_plugins', array() );
- // $autoupdating_plugins_translations = Jetpack_Options::get_option( 'autoupdate_plugins_translations', array() );
- if ( 'autoupdate' === $column_name ) {
- if ( ! in_array( $slug, $repo_plugins ) ) {
- return;
- }
- // Shamelessly swiped from https://github.com/Automattic/wp-calypso/blob/59bdfeeb97eda4266ad39410cb0a074d2c88dbc8/client/components/forms/form-toggle
- ?>
-
- <span class="form-toggle__wrapper">
- <input
- id="autoupdate_plugin-toggle-<?php echo esc_attr( $slug ) ?>"
- name="autoupdate_plugins[<?php echo esc_attr( $slug ) ?>]"
- value="autoupdate"
- class="form-toggle autoupdate-toggle"
- type="checkbox"
- <?php checked( in_array( $slug, $autoupdating_plugins ) ); ?>
- readonly
- data-slug="<?php echo esc_attr( $slug ); ?>"
- />
- <label class="form-toggle__label" for="autoupdate_plugin-toggle-<?php echo esc_attr( $slug ) ?>">
- <span class="form-toggle__switch" role="checkbox"></span>
- <span class="form-toggle__label-content"><?php /* */ ?></span>
- </label>
- </span>
-
- <?php
- }
- }
-
- public static function get_dotorg_repo_plugins() {
- $plugins = get_site_transient( 'update_plugins' );
- return array_merge( array_keys( $plugins->response ), array_keys( $plugins->no_update ) );
- }
-
- public function bulk_actions_plugins( $bulk_actions ) {
- $bulk_actions['jetpack_enable_plugin_autoupdates'] = __( 'Enable Automatic Updates', 'jetpack' );
- $bulk_actions['jetpack_disable_plugin_autoupdates'] = __( 'Disable Automatic Updates', 'jetpack' );
- return $bulk_actions;
- }
-
- public function handle_bulk_actions_plugins( $redirect_to, $action, $slugs ) {
- $redirect_to = remove_query_arg( array( 'jetpack_enable_plugin_autoupdates', 'jetpack_disable_plugin_autoupdates' ), $redirect_to );
- if ( in_array( $action, array( 'jetpack_enable_plugin_autoupdates', 'jetpack_disable_plugin_autoupdates' ) ) ) {
- $list = Jetpack_Options::get_option( 'autoupdate_plugins', array() );
- $initial_qty = sizeof( $list );
-
- if ( 'jetpack_enable_plugin_autoupdates' === $action ) {
- $list = array_unique( array_merge( $list, $slugs ) );
- } elseif ( 'jetpack_disable_plugin_autoupdates' === $action ) {
- $list = array_diff( $list, $slugs );
- }
-
- Jetpack_Options::update_option( 'autoupdate_plugins', $list );
- $redirect_to = add_query_arg( $action, absint( sizeof( $list ) - $initial_qty ), $redirect_to );
- }
- return $redirect_to;
- }
-
- public function plugins_admin_notices() {
- if ( ! empty( $_GET['jetpack_enable_plugin_autoupdates'] ) ) {
- $qty = (int) $_GET['jetpack_enable_plugin_autoupdates'];
- printf( '<div id="message" class="updated fade"><p>' . _n( 'Enabled automatic updates on %d plugin.', 'Enabled automatic updates on %d plugins.', $qty, 'jetpack' ) . '</p></div>', $qty );
- } elseif ( ! empty( $_GET['jetpack_disable_plugin_autoupdates'] ) ) {
- $qty = (int) $_GET['jetpack_disable_plugin_autoupdates'];
- printf( '<div id="message" class="updated fade"><p>' . _n( 'Disabled automatic updates on %d plugin.', 'Disabled automatic updates on %d plugins.', $qty, 'jetpack' ) . '</p></div>', $qty );
- }
- }
-
- public function jetpack_toggle_autoupdate() {
- if ( ! current_user_can( 'jetpack_manage_autoupdates' ) ) {
- wp_send_json_error();
- return;
- }
-
- $type = $_POST['type'];
- $slug = $_POST['slug'];
- $active = 'false' !== $_POST['active'];
-
- check_ajax_referer( "jetpack_toggle_autoupdate-{$type}" );
-
- if ( ! in_array( $type, array( 'plugins', 'plugins_translations' ) ) ) {
- wp_send_json_error();
- return;
- }
-
- $jetpack_option_name = "autoupdate_{$type}";
-
- $list = Jetpack_Options::get_option( $jetpack_option_name, array() );
-
- if ( $active ) {
- $list = array_unique( array_merge( $list, (array) $slug ) );
- } else {
- $list = array_diff( $list, (array) $slug );
- }
-
- Jetpack_Options::update_option( $jetpack_option_name, $list );
-
- wp_send_json_success( $list );
- }
-
- public function admin_color_override( $color ) {
- return 'fresh';
- }
-
- public function mock_masterbar_activation() {
- include_once JETPACK__PLUGIN_DIR . 'modules/masterbar/masterbar.php';
- new A8C_WPCOM_Masterbar;
- }
-
- public function remove_core_menus() {
- remove_menu_page( 'edit.php?post_type=feedback' );
- remove_menu_page( 'index.php' );
- remove_menu_page( 'jetpack' );
- remove_menu_page( 'edit.php' );
- remove_menu_page( 'upload.php' );
- remove_menu_page( 'edit.php?post_type=page' );
- remove_menu_page( 'edit-comments.php' );
- remove_menu_page( 'themes.php' );
- remove_menu_page( 'plugins.php' );
- remove_menu_page( 'users.php' );
- remove_menu_page( 'tools.php' );
- remove_menu_page( 'link-manager.php' );
-
- // Core settings pages
- remove_submenu_page( 'options-general.php', 'options-general.php' );
- remove_submenu_page( 'options-general.php', 'options-writing.php' );
- remove_submenu_page( 'options-general.php', 'options-reading.php' );
- remove_submenu_page( 'options-general.php', 'options-discussion.php' );
- remove_submenu_page( 'options-general.php', 'options-media.php' );
- remove_submenu_page( 'options-general.php', 'options-permalink.php' );
- remove_submenu_page( 'options-general.php', 'privacy.php' );
- remove_submenu_page( 'options-general.php', 'sharing' );
- }
-
- public function add_custom_menus() {
- global $menu, $submenu;
-
- if ( isset( $_GET['post_type'] ) && 'feedback' === $_GET['post_type'] ) {
- // there is currently no gridicon for feedback, so using dashicon.
- add_menu_page( __( 'Feedback', 'jetpack' ), __( 'Feedback', 'jetpack' ), 'edit_pages', 'edit.php?post_type=feedback', '', 'dashicons-feedback', 1 );
- remove_menu_page( 'options-general.php' );
- remove_submenu_page( 'edit.php?post_type=feedback', 'feedback-export' );
- } else {
- add_menu_page( __( 'Manage Plugins', 'jetpack' ), __( 'Manage Plugins', 'jetpack' ), 'activate_plugins', 'plugins.php', '', $this->installed_plugins_icon(), 1 );
- // Count the settings page submenus, if it's zero then don't show this.
- if ( empty( $submenu['options-general.php'] ) ) {
- remove_menu_page( 'options-general.php' );
- } else {
- // Rename and make sure the plugin settings menu is always last.
- // Sneaky plugins seem to override this otherwise.
- // Settings is always key 80.
- $menu[80][0] = __( 'Plugin Settings', 'jetpack' );
- $menu[ max( array_keys( $menu ) ) + 1 ] = $menu[80];
- unset( $menu[80] );
- }
- }
- }
-
- public function enqueue() {
- wp_enqueue_style( 'calypsoify_wpadminmods_css', plugin_dir_url( __FILE__ ) . 'style.min.css', false, JETPACK__VERSION );
- wp_style_add_data( 'calypsoify_wpadminmods_css', 'rtl', 'replace' );
- wp_style_add_data( 'calypsoify_wpadminmods_css', 'suffix', '.min' );
-
- wp_enqueue_script( 'calypsoify_wpadminmods_js', plugin_dir_url( __FILE__ ) . 'mods.js', false, JETPACK__VERSION );
- wp_localize_script( 'calypsoify_wpadminmods_js', 'CalypsoifyOpts', array(
- 'nonces' => array(
- 'autoupdate_plugins' => wp_create_nonce( 'jetpack_toggle_autoupdate-plugins' ),
- 'autoupdate_plugins_translations' => wp_create_nonce( 'jetpack_toggle_autoupdate-plugins_translations' ),
- )
- ) );
- }
-
- public function enqueue_for_gutenberg() {
- wp_enqueue_style( 'calypsoify_wpadminmods_css', plugin_dir_url( __FILE__ ) . 'style-gutenberg.min.css', false, JETPACK__VERSION );
- wp_style_add_data( 'calypsoify_wpadminmods_css', 'rtl', 'replace' );
- wp_style_add_data( 'calypsoify_wpadminmods_css', 'suffix', '.min' );
-
- wp_enqueue_script( 'calypsoify_wpadminmods_js', plugin_dir_url( __FILE__ ) . 'mods-gutenberg.js', false, JETPACK__VERSION );
- wp_localize_script(
- 'calypsoify_wpadminmods_js',
- 'calypsoifyGutenberg',
- array(
- 'closeUrl' => $this->get_close_gutenberg_url(),
- 'manageReusableBlocksUrl' => $this->get_calypso_origin() . '/types/wp_block' . $this->get_site_suffix(),
- )
- );
- }
-
- public function insert_sidebar_html() {
- $heading = ( isset( $_GET['post_type'] ) && 'feedback' === $_GET['post_type'] ) ? __( 'Feedback', 'jetpack' ) : __( 'Plugins', 'jetpack' );
- ?>
- <a href="<?php echo esc_url( 'https://wordpress.com/stats/day/' . Jetpack::build_raw_urls( home_url() ) ); ?>" id="calypso-sidebar-header">
- <svg class="gridicon gridicons-chevron-left" height="24" width="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g><path d="M14 20l-8-8 8-8 1.414 1.414L8.828 12l6.586 6.586"></path></g></svg>
-
- <ul>
- <li id="calypso-sitename"><?php bloginfo( 'name' ); ?></li>
- <li id="calypso-plugins"><?php echo esc_html( $heading ); ?></li>
- </ul>
- </a>
- <?php
- }
-
- public function modify_masterbar() {
- global $wp_admin_bar;
-
- // Add proper links to masterbar top sections.
- $my_sites_node = (object) $wp_admin_bar->get_node( 'blog' );
- $my_sites_node->href = 'https://wordpress.com/stats/day/' . Jetpack::build_raw_urls( home_url() );
- $wp_admin_bar->add_node( $my_sites_node );
-
- $reader_node = (object) $wp_admin_bar->get_node( 'newdash' );
- $reader_node->href = 'https://wordpress.com/read';
- $wp_admin_bar->add_node( $reader_node );
-
- $me_node = (object) $wp_admin_bar->get_node( 'my-account' );
- $me_node->href = 'https://wordpress.com/me';
- $wp_admin_bar->add_node( $me_node );
- }
-
- private function installed_plugins_icon() {
- $svg = '<svg class="gridicon gridicons-plugins" height="24" width="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 24"><g><path d="M16 8V3c0-.552-.448-1-1-1s-1 .448-1 1v5h-4V3c0-.552-.448-1-1-1s-1 .448-1 1v5H5v4c0 2.79 1.637 5.193 4 6.317V22h6v-3.683c2.363-1.124 4-3.527 4-6.317V8h-3z" fill="black"></path></g></svg>';
-
- return 'data:image/svg+xml;base64,' . base64_encode( $svg );
- }
-
- /**
- * Returns the Calypso domain that originated the current request.
- *
- * @return string
- */
- private function get_calypso_origin() {
- $origin = ! empty( $_GET['origin'] ) ? $_GET['origin'] : 'https://wordpress.com';
- $whitelist = array(
- 'http://calypso.localhost:3000',
- 'http://127.0.0.1:41050', // Desktop App
- 'https://wpcalypso.wordpress.com',
- 'https://horizon.wordpress.com',
- 'https://wordpress.com',
- );
- return in_array( $origin, $whitelist ) ? $origin : 'https://wordpress.com';
-
- function get_site_suffix() {
- if ( class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'build_raw_urls' ) ) {
- $site_suffix = Jetpack::build_raw_urls( home_url() );
- } elseif ( class_exists( 'WPCOM_Masterbar' ) && method_exists( 'WPCOM_Masterbar', 'get_calypso_site_slug' ) ) {
- $site_suffix = WPCOM_Masterbar::get_calypso_site_slug( get_current_blog_id() );
- }
-
- if ( $site_suffix ) {
- return "/${site_suffix}";
- }
- return '';
- }
- }
-
- /**
- * Returns the site slug suffix to be used as part of the Calypso URLs. It already
- * includes the slash separator at the beginning.
- *
- * @example "https://wordpress.com/block-editor" . $this->get_site_suffix()
- *
- * @return string
- */
- private function get_site_suffix() {
- if ( class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'build_raw_urls' ) ) {
- $site_suffix = Jetpack::build_raw_urls( home_url() );
- } elseif ( class_exists( 'WPCOM_Masterbar' ) && method_exists( 'WPCOM_Masterbar', 'get_calypso_site_slug' ) ) {
- $site_suffix = WPCOM_Masterbar::get_calypso_site_slug( get_current_blog_id() );
- }
-
- if ( $site_suffix ) {
- return "/${site_suffix}";
- }
- return '';
- }
-
- /**
- * Returns the Calypso URL that displays either the current post type list (if no args
- * are supplied) or the classic editor for the current post (if a post ID is supplied).
- *
- * @param int|null $post_id
- * @return string
- */
- public function get_calypso_url( $post_id = null ) {
- $screen = get_current_screen();
- $post_type = $screen->post_type;
- if ( is_null( $post_id ) ) {
- // E.g. `posts`, `pages`, or `types/some_custom_post_type`
- $post_type_suffix = ( 'post' === $post_type || 'page' === $post_type )
- ? "/${post_type}s"
- : "/types/${post_type}";
- $post_suffix = '';
- } else {
- $post_type_suffix = ( 'post' === $post_type || 'page' === $post_type )
- ? "/${post_type}"
- : "/edit/${post_type}";
- $post_suffix = "/${post_id}";
- }
-
- return $this->get_calypso_origin() . $post_type_suffix . $this->get_site_suffix() . $post_suffix;
- }
-
- /**
- * Returns the URL to be used on the block editor close button for going back to the
- * Calypso post list.
- *
- * @return string
- */
- public function get_close_gutenberg_url() {
- return $this->get_calypso_url();
- }
-
- /**
- * Returns the URL for switching the user's editor to the Calypso (WordPress.com Classic) editor.
- *
- * @return string
- */
- public function get_switch_to_classic_editor_url() {
- return add_query_arg(
- 'set-editor',
- 'classic',
- $this->is_calypsoify_enabled ? $this->get_calypso_url( get_the_ID() ) : false
- );
- }
-
- public function check_param() {
- if ( isset( $_GET['calypsoify'] ) ) {
- if ( 1 == (int) $_GET['calypsoify'] ) {
- update_user_meta( get_current_user_id(), 'calypsoify', 1 );
- } else {
- update_user_meta( get_current_user_id(), 'calypsoify', 0 );
- }
-
- $page = remove_query_arg( 'calypsoify', wp_basename( $_SERVER['REQUEST_URI'] ) );
-
- wp_safe_redirect( admin_url( $page ) );
- }
- }
-
- public function check_page() {
- // If the user hits plain /wp-admin/ then disable Calypso styles.
- $page = wp_basename( esc_url( $_SERVER['REQUEST_URI'] ) );
-
- if ( false !== strpos( 'index.php', $page ) || false !== strpos( 'wp-admin', $page ) ) {
- update_user_meta( get_current_user_id(), 'calypsoify', 0 );
- wp_safe_redirect( admin_url() );
- die;
- }
- }
-
- /**
- * Return whether a post type should display the Gutenberg/block editor.
- *
- * @since 6.7.0
- */
- public function is_post_type_gutenberg( $post_type ) {
- return use_block_editor_for_post_type( $post_type );
- }
-
- public function is_page_gutenberg() {
- $page = wp_basename( esc_url( $_SERVER['REQUEST_URI'] ) );
-
- if ( false !== strpos( $page, 'post-new.php' ) && empty ( $_GET['post_type'] ) ) {
- return true;
- }
-
- if ( false !== strpos( $page, 'post-new.php' ) && isset( $_GET['post_type'] ) && $this->is_post_type_gutenberg( $_GET['post_type'] ) ) {
- return true;
- }
-
- if ( false !== strpos( $page, 'post.php' ) ) {
- $post = get_post( $_GET['post'] );
- if ( isset( $post ) && isset( $post->post_type ) && $this->is_post_type_gutenberg( $post->post_type ) ) {
- return true;
- }
- }
-
- if ( false !== strpos( $page, 'revision.php' ) ) {
- $post = get_post( $_GET['revision'] );
- $parent = get_post( $post->post_parent );
- if ( isset( $parent ) && isset( $parent->post_type ) && $this->is_post_type_gutenberg( $parent->post_type ) ) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Attach a WP_List_Table views filter to all screens.
- */
- public function attach_views_filter( $current_screen ) {
- add_filter( "views_{$current_screen->id}", array( $this, 'filter_views' ) );
- }
-
- /**
- * Remove the parentheses from list table view counts when Calypsofied.
- *
- * @param array $views Array of views. See: WP_List_Table::get_views().
- * @return array Filtered views.
- */
- public function filter_views( $views ) {
- foreach ( $views as $id => $view ) {
- $views[ $id ] = preg_replace( '/<span class="count">\((\d+)\)<\/span>/', '<span class="count">$1</span>', $view );
- }
-
- return $views;
- }
-}
-
-$Jetpack_Calypsoify = Jetpack_Calypsoify::getInstance();
diff --git a/plugins/jetpack/modules/calypsoify/style-gutenberg-rtl.min.css b/plugins/jetpack/modules/calypsoify/style-gutenberg-rtl.min.css
index 8c771d0a..3d51177b 100644
--- a/plugins/jetpack/modules/calypsoify/style-gutenberg-rtl.min.css
+++ b/plugins/jetpack/modules/calypsoify/style-gutenberg-rtl.min.css
@@ -1,3 +1 @@
-/* Do not modify this file directly. It is compiled SASS code. */
-.components-button.is-default{color:#3c434a;border-color:#c3c4c7;background:#fff;box-shadow:none;border-width:1px 1px 2px}.components-button.is-default:hover{background:#fff;border-color:#a7aaad;box-shadow:none;color:#3c434a}.components-button.is-default:focus:enabled{background:#fff;color:#3c434a;border-color:#2271b1;box-shadow:0 0 0 2px #5198d9}.components-button.is-default:active:enabled{background:#fff;border-color:#c3c4c7;border-width:2px 1px 1px;box-shadow:none}.components-button.is-default:disabled,.components-button.is-default[aria-disabled=true]{color:#646970;background-color:#fff;border-color:#646970;text-shadow:none}.components-button.is-primary{background:#c9356e;border-color:#8c1749;box-shadow:none;color:#fff;text-shadow:none}.components-button.is-primary:focus:enabled{background:#e34c84;border-color:#c9356e;color:#fff;box-shadow:0 0 0 2px #eb6594}.components-button.is-primary:hover{box-shadow:none;background:#e34c84;border-color:#8c1749;color:#fff}.components-button.is-primary:focus:enabled{box-shadow:0 0 0 2px #eb6594}.components-button.is-primary:active:enabled{background:#e34c84;border-color:#8c1749;box-shadow:inset 0 1px 0 #8c1749}.components-button.is-primary:disabled,.components-button.is-primary[aria-disabled=true]{color:#646970;background:#fff;border-color:#646970;text-shadow:none}.components-button.is-primary:disabled:hover,.components-button.is-primary:disabled:focus,.components-button.is-primary:disabled:active,.components-button.is-primary[aria-disabled=true]:hover,.components-button.is-primary[aria-disabled=true]:focus,.components-button.is-primary[aria-disabled=true]:active{color:#646970;background-color:#fff;border-color:#646970;box-shadow:none}.components-button.is-primary.is-busy,.components-button.is-primary.is-busy:disabled,.components-button.is-primary.is-busy[aria-disabled=true]{background-image:linear-gradient(45deg, #c9356e 28%, #ab235a 28%, #ab235a 72%, #c9356e 72%);border-color:#8c1749}.components-button.is-link{color:#2271b1}.components-button.is-link:hover,.components-button.is-link:active{color:#0a4b78}.components-button.is-link:focus{color:#0a4b78;box-shadow:0 0 0 2px #5198d9}.components-button.is-link.is-destructive{color:#e65054}.components-button.is-busy{background-image:repeating-linear-gradient(45deg, #646970, #fff 11px, #fff 10px, #646970 20px)}.components-button.is-tertiary{color:#2271b1}.components-button.is-tertiary:not(:disabled):not([aria-disabled=true]):not(.is-default):hover{color:#0a4b78}.edit-post-sidebar__panel-tab.is-active{border-color:#2271b1}.edit-post-sidebar .input-control:focus,.edit-post-sidebar input[type=checkbox]:focus,.edit-post-sidebar input[type=color]:focus,.edit-post-sidebar input[type=date]:focus,.edit-post-sidebar input[type=datetime-local]:focus,.edit-post-sidebar input[type=datetime]:focus,.edit-post-sidebar input[type=email]:focus,.edit-post-sidebar input[type=month]:focus,.edit-post-sidebar input[type=number]:focus,.edit-post-sidebar input[type=password]:focus,.edit-post-sidebar input[type=radio]:focus,.edit-post-sidebar input[type=search]:focus,.edit-post-sidebar input[type=tel]:focus,.edit-post-sidebar input[type=text]:focus,.edit-post-sidebar input[type=time]:focus,.edit-post-sidebar input[type=url]:focus,.edit-post-sidebar input[type=week]:focus,.edit-post-sidebar select:focus,.edit-post-sidebar textarea:focus{border-color:#2271b1;box-shadow:0 0 0 2px #5198d9}.edit-post-sidebar input[type=checkbox]:checked{background:#2271b1;border-color:#2271b1}a{color:#2271b1}a:active,a:hover{color:#0a4b78}a:focus{color:#0a4b78;box-shadow:none;outline:thin dotted}.wp-toolbar .revision-php{margin-top:-32px}.revision-php{background:#f6f7f7}.revision-php #wpadminbar,.revision-php #adminmenumain,.revision-php #wp-admin-bar-menu-toggle{display:none}.revision-php #wpcontent{margin-right:0 !important}.revision-php #wpbody{padding-top:0}.revision-php #screen-meta-links{display:none !important}.revision-php #wpfooter{display:none !important}.revision-tickmarks{margin-top:8px}.revisions-controls{height:118px}.revisions-controls .author-card .avatar{border-radius:50%;height:38px;margin-top:4px;width:38px}.revisions-controls .author-card .author-info{line-height:20px;margin-top:4px}.comparing-two-revisions .revisions-controls{height:176px}.revisions-meta{margin-top:28px}.diff-meta{min-height:46px}.revision-toggle-compare-mode label{vertical-align:top}.revisions-tooltip{transform:translateY(-36px)}
-/*# sourceMappingURL=style-gutenberg-rtl.min.css.map */
+.components-button.is-default{background:#fff;border-color:#c3c4c7;border-width:1px 1px 2px;box-shadow:none;color:#3c434a}.components-button.is-default:hover{background:#fff;border-color:#a7aaad;box-shadow:none;color:#3c434a}.components-button.is-default:focus:enabled{background:#fff;border-color:#2271b1;box-shadow:0 0 0 2px #5198d9;color:#3c434a}.components-button.is-default:active:enabled{background:#fff;border-color:#c3c4c7;border-width:2px 1px 1px;box-shadow:none}.components-button.is-default:disabled,.components-button.is-default[aria-disabled=true]{background-color:#fff;border-color:#646970;color:#646970;text-shadow:none}.components-button.is-primary{background:#c9356e;border-color:#8c1749;box-shadow:none;color:#fff;text-shadow:none}.components-button.is-primary:focus:enabled{background:#e34c84;border-color:#c9356e;color:#fff}.components-button.is-primary:hover{background:#e34c84;border-color:#8c1749;box-shadow:none;color:#fff}.components-button.is-primary:focus:enabled{box-shadow:0 0 0 2px #eb6594}.components-button.is-primary:active:enabled{background:#e34c84;border-color:#8c1749;box-shadow:inset 0 1px 0 #8c1749}.components-button.is-primary:disabled,.components-button.is-primary[aria-disabled=true]{background:#fff;border-color:#646970;color:#646970;text-shadow:none}.components-button.is-primary:disabled:active,.components-button.is-primary:disabled:focus,.components-button.is-primary:disabled:hover,.components-button.is-primary[aria-disabled=true]:active,.components-button.is-primary[aria-disabled=true]:focus,.components-button.is-primary[aria-disabled=true]:hover{background-color:#fff;border-color:#646970;box-shadow:none;color:#646970}.components-button.is-primary.is-busy,.components-button.is-primary.is-busy:disabled,.components-button.is-primary.is-busy[aria-disabled=true]{background-image:linear-gradient(45deg,#c9356e 28%,#ab235a 0,#ab235a 72%,#c9356e 0);border-color:#8c1749}.components-button.is-link{color:#2271b1}.components-button.is-link:active,.components-button.is-link:hover{color:#0a4b78}.components-button.is-link:focus{box-shadow:0 0 0 2px #5198d9;color:#0a4b78}.components-button.is-link.is-destructive{color:#e65054}.components-button.is-busy{background-image:repeating-linear-gradient(45deg,#646970,#fff 11px,#fff 0,#646970 20px)}.components-button.is-tertiary{color:#2271b1}.components-button.is-tertiary:not(:disabled):not([aria-disabled=true]):not(.is-default):hover{color:#0a4b78}.edit-post-sidebar__panel-tab.is-active{border-color:#2271b1}.edit-post-sidebar .input-control:focus,.edit-post-sidebar input[type=checkbox]:focus,.edit-post-sidebar input[type=color]:focus,.edit-post-sidebar input[type=date]:focus,.edit-post-sidebar input[type=datetime-local]:focus,.edit-post-sidebar input[type=datetime]:focus,.edit-post-sidebar input[type=email]:focus,.edit-post-sidebar input[type=month]:focus,.edit-post-sidebar input[type=number]:focus,.edit-post-sidebar input[type=password]:focus,.edit-post-sidebar input[type=radio]:focus,.edit-post-sidebar input[type=search]:focus,.edit-post-sidebar input[type=tel]:focus,.edit-post-sidebar input[type=text]:focus,.edit-post-sidebar input[type=time]:focus,.edit-post-sidebar input[type=url]:focus,.edit-post-sidebar input[type=week]:focus,.edit-post-sidebar select:focus,.edit-post-sidebar textarea:focus{border-color:#2271b1;box-shadow:0 0 0 2px #5198d9}.edit-post-sidebar input[type=checkbox]:checked{background:#2271b1;border-color:#2271b1}a{color:#2271b1}a:active,a:focus,a:hover{color:#0a4b78}a:focus{box-shadow:none;outline:thin dotted}.wp-toolbar .revision-php{margin-top:-32px}.revision-php{background:#f6f7f7}.revision-php #adminmenumain,.revision-php #wp-admin-bar-menu-toggle,.revision-php #wpadminbar{display:none}.revision-php #wpcontent{margin-right:0!important}.revision-php #wpbody{padding-top:0}.revision-php #screen-meta-links,.revision-php #wpfooter{display:none!important}.revision-tickmarks{margin-top:8px}.revisions-controls{height:118px}.revisions-controls .author-card .avatar{border-radius:50%;height:38px;margin-top:4px;width:38px}.revisions-controls .author-card .author-info{line-height:20px;margin-top:4px}.comparing-two-revisions .revisions-controls{height:176px}.revisions-meta{margin-top:28px}.diff-meta{min-height:46px}.revision-toggle-compare-mode label{vertical-align:top}.revisions-tooltip{transform:translateY(-36px)} \ No newline at end of file
diff --git a/plugins/jetpack/modules/calypsoify/style-gutenberg.min.css b/plugins/jetpack/modules/calypsoify/style-gutenberg.min.css
index 157ff68f..5f49e01a 100644
--- a/plugins/jetpack/modules/calypsoify/style-gutenberg.min.css
+++ b/plugins/jetpack/modules/calypsoify/style-gutenberg.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is compiled SASS code. */
-.components-button.is-default{color:#3c434a;border-color:#c3c4c7;background:#fff;box-shadow:none;border-width:1px 1px 2px}.components-button.is-default:hover{background:#fff;border-color:#a7aaad;box-shadow:none;color:#3c434a}.components-button.is-default:focus:enabled{background:#fff;color:#3c434a;border-color:#2271b1;box-shadow:0 0 0 2px #5198d9}.components-button.is-default:active:enabled{background:#fff;border-color:#c3c4c7;border-width:2px 1px 1px;box-shadow:none}.components-button.is-default:disabled,.components-button.is-default[aria-disabled=true]{color:#646970;background-color:#fff;border-color:#646970;text-shadow:none}.components-button.is-primary{background:#c9356e;border-color:#8c1749;box-shadow:none;color:#fff;text-shadow:none}.components-button.is-primary:focus:enabled{background:#e34c84;border-color:#c9356e;color:#fff;box-shadow:0 0 0 2px #eb6594}.components-button.is-primary:hover{box-shadow:none;background:#e34c84;border-color:#8c1749;color:#fff}.components-button.is-primary:focus:enabled{box-shadow:0 0 0 2px #eb6594}.components-button.is-primary:active:enabled{background:#e34c84;border-color:#8c1749;box-shadow:inset 0 1px 0 #8c1749}.components-button.is-primary:disabled,.components-button.is-primary[aria-disabled=true]{color:#646970;background:#fff;border-color:#646970;text-shadow:none}.components-button.is-primary:disabled:hover,.components-button.is-primary:disabled:focus,.components-button.is-primary:disabled:active,.components-button.is-primary[aria-disabled=true]:hover,.components-button.is-primary[aria-disabled=true]:focus,.components-button.is-primary[aria-disabled=true]:active{color:#646970;background-color:#fff;border-color:#646970;box-shadow:none}.components-button.is-primary.is-busy,.components-button.is-primary.is-busy:disabled,.components-button.is-primary.is-busy[aria-disabled=true]{background-image:linear-gradient(-45deg, #c9356e 28%, #ab235a 28%, #ab235a 72%, #c9356e 72%);border-color:#8c1749}.components-button.is-link{color:#2271b1}.components-button.is-link:hover,.components-button.is-link:active{color:#0a4b78}.components-button.is-link:focus{color:#0a4b78;box-shadow:0 0 0 2px #5198d9}.components-button.is-link.is-destructive{color:#e65054}.components-button.is-busy{background-image:repeating-linear-gradient(-45deg, #646970, #fff 11px, #fff 10px, #646970 20px)}.components-button.is-tertiary{color:#2271b1}.components-button.is-tertiary:not(:disabled):not([aria-disabled=true]):not(.is-default):hover{color:#0a4b78}.edit-post-sidebar__panel-tab.is-active{border-color:#2271b1}.edit-post-sidebar .input-control:focus,.edit-post-sidebar input[type=checkbox]:focus,.edit-post-sidebar input[type=color]:focus,.edit-post-sidebar input[type=date]:focus,.edit-post-sidebar input[type=datetime-local]:focus,.edit-post-sidebar input[type=datetime]:focus,.edit-post-sidebar input[type=email]:focus,.edit-post-sidebar input[type=month]:focus,.edit-post-sidebar input[type=number]:focus,.edit-post-sidebar input[type=password]:focus,.edit-post-sidebar input[type=radio]:focus,.edit-post-sidebar input[type=search]:focus,.edit-post-sidebar input[type=tel]:focus,.edit-post-sidebar input[type=text]:focus,.edit-post-sidebar input[type=time]:focus,.edit-post-sidebar input[type=url]:focus,.edit-post-sidebar input[type=week]:focus,.edit-post-sidebar select:focus,.edit-post-sidebar textarea:focus{border-color:#2271b1;box-shadow:0 0 0 2px #5198d9}.edit-post-sidebar input[type=checkbox]:checked{background:#2271b1;border-color:#2271b1}a{color:#2271b1}a:active,a:hover{color:#0a4b78}a:focus{color:#0a4b78;box-shadow:none;outline:thin dotted}.wp-toolbar .revision-php{margin-top:-32px}.revision-php{background:#f6f7f7}.revision-php #wpadminbar,.revision-php #adminmenumain,.revision-php #wp-admin-bar-menu-toggle{display:none}.revision-php #wpcontent{margin-left:0 !important}.revision-php #wpbody{padding-top:0}.revision-php #screen-meta-links{display:none !important}.revision-php #wpfooter{display:none !important}.revision-tickmarks{margin-top:8px}.revisions-controls{height:118px}.revisions-controls .author-card .avatar{border-radius:50%;height:38px;margin-top:4px;width:38px}.revisions-controls .author-card .author-info{line-height:20px;margin-top:4px}.comparing-two-revisions .revisions-controls{height:176px}.revisions-meta{margin-top:28px}.diff-meta{min-height:46px}.revision-toggle-compare-mode label{vertical-align:top}.revisions-tooltip{transform:translateY(-36px)} \ No newline at end of file
+.components-button.is-default{background:#fff;border-color:#c3c4c7;border-width:1px 1px 2px;box-shadow:none;color:#3c434a}.components-button.is-default:hover{background:#fff;border-color:#a7aaad;box-shadow:none;color:#3c434a}.components-button.is-default:focus:enabled{background:#fff;border-color:#2271b1;box-shadow:0 0 0 2px #5198d9;color:#3c434a}.components-button.is-default:active:enabled{background:#fff;border-color:#c3c4c7;border-width:2px 1px 1px;box-shadow:none}.components-button.is-default:disabled,.components-button.is-default[aria-disabled=true]{background-color:#fff;border-color:#646970;color:#646970;text-shadow:none}.components-button.is-primary{background:#c9356e;border-color:#8c1749;box-shadow:none;color:#fff;text-shadow:none}.components-button.is-primary:focus:enabled{background:#e34c84;border-color:#c9356e;color:#fff}.components-button.is-primary:hover{background:#e34c84;border-color:#8c1749;box-shadow:none;color:#fff}.components-button.is-primary:focus:enabled{box-shadow:0 0 0 2px #eb6594}.components-button.is-primary:active:enabled{background:#e34c84;border-color:#8c1749;box-shadow:inset 0 1px 0 #8c1749}.components-button.is-primary:disabled,.components-button.is-primary[aria-disabled=true]{background:#fff;border-color:#646970;color:#646970;text-shadow:none}.components-button.is-primary:disabled:active,.components-button.is-primary:disabled:focus,.components-button.is-primary:disabled:hover,.components-button.is-primary[aria-disabled=true]:active,.components-button.is-primary[aria-disabled=true]:focus,.components-button.is-primary[aria-disabled=true]:hover{background-color:#fff;border-color:#646970;box-shadow:none;color:#646970}.components-button.is-primary.is-busy,.components-button.is-primary.is-busy:disabled,.components-button.is-primary.is-busy[aria-disabled=true]{background-image:linear-gradient(-45deg,#c9356e 28%,#ab235a 0,#ab235a 72%,#c9356e 0);border-color:#8c1749}.components-button.is-link{color:#2271b1}.components-button.is-link:active,.components-button.is-link:hover{color:#0a4b78}.components-button.is-link:focus{box-shadow:0 0 0 2px #5198d9;color:#0a4b78}.components-button.is-link.is-destructive{color:#e65054}.components-button.is-busy{background-image:repeating-linear-gradient(-45deg,#646970,#fff 11px,#fff 0,#646970 20px)}.components-button.is-tertiary{color:#2271b1}.components-button.is-tertiary:not(:disabled):not([aria-disabled=true]):not(.is-default):hover{color:#0a4b78}.edit-post-sidebar__panel-tab.is-active{border-color:#2271b1}.edit-post-sidebar .input-control:focus,.edit-post-sidebar input[type=checkbox]:focus,.edit-post-sidebar input[type=color]:focus,.edit-post-sidebar input[type=date]:focus,.edit-post-sidebar input[type=datetime-local]:focus,.edit-post-sidebar input[type=datetime]:focus,.edit-post-sidebar input[type=email]:focus,.edit-post-sidebar input[type=month]:focus,.edit-post-sidebar input[type=number]:focus,.edit-post-sidebar input[type=password]:focus,.edit-post-sidebar input[type=radio]:focus,.edit-post-sidebar input[type=search]:focus,.edit-post-sidebar input[type=tel]:focus,.edit-post-sidebar input[type=text]:focus,.edit-post-sidebar input[type=time]:focus,.edit-post-sidebar input[type=url]:focus,.edit-post-sidebar input[type=week]:focus,.edit-post-sidebar select:focus,.edit-post-sidebar textarea:focus{border-color:#2271b1;box-shadow:0 0 0 2px #5198d9}.edit-post-sidebar input[type=checkbox]:checked{background:#2271b1;border-color:#2271b1}a{color:#2271b1}a:active,a:focus,a:hover{color:#0a4b78}a:focus{box-shadow:none;outline:thin dotted}.wp-toolbar .revision-php{margin-top:-32px}.revision-php{background:#f6f7f7}.revision-php #adminmenumain,.revision-php #wp-admin-bar-menu-toggle,.revision-php #wpadminbar{display:none}.revision-php #wpcontent{margin-left:0!important}.revision-php #wpbody{padding-top:0}.revision-php #screen-meta-links,.revision-php #wpfooter{display:none!important}.revision-tickmarks{margin-top:8px}.revisions-controls{height:118px}.revisions-controls .author-card .avatar{border-radius:50%;height:38px;margin-top:4px;width:38px}.revisions-controls .author-card .author-info{line-height:20px;margin-top:4px}.comparing-two-revisions .revisions-controls{height:176px}.revisions-meta{margin-top:28px}.diff-meta{min-height:46px}.revision-toggle-compare-mode label{vertical-align:top}.revisions-tooltip{transform:translateY(-36px)} \ No newline at end of file
diff --git a/plugins/jetpack/modules/calypsoify/style-rtl.min.css b/plugins/jetpack/modules/calypsoify/style-rtl.min.css
index 979971fd..5fe69eb5 100644
--- a/plugins/jetpack/modules/calypsoify/style-rtl.min.css
+++ b/plugins/jetpack/modules/calypsoify/style-rtl.min.css
@@ -1,3 +1 @@
-/* Do not modify this file directly. It is compiled SASS code. */
-body,#wp-content-editor-tools{background:#f6f7f7}#wpwrap{top:14px}#wp-admin-bar-notes #wpnt-notes-unread-count.wpn-unread{background-image:none !important;background-color:#eb6594 !important;border:none !important}#adminmenu #collapse-menu,#adminmenu .wp-menu-separator,#screen-meta-links,.wp-submenu,#toplevel_page_jetpack{display:none}.wp-menu-open .wp-submenu{display:block}#adminmenuwrap,#adminmenuback,#adminmenu{background:#fff}#adminmenuback{border-left:1px solid #f6f7f7}#adminmenu,#adminmenuwrap,#adminmenuback,#adminmenu .wp-submenu{width:272px}#adminmenu{margin-top:71px}#adminmenu .wp-submenu{padding:0}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .opensub .wp-submenu,#adminmenu .opensub .wp-submenu:after,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu{background:transparent !important}#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus,#adminmenu li.wp-menu-open{background:transparent}#adminmenu a:hover{background-color:#f6f7f7 !important}#adminmenu .wp-submenu-head,#adminmenu a.menu-top{padding:5px 5px 5px 0}#adminmenu .wp-has-current-submenu ul>li>a{padding:7px 46px 7px 12px;font-size:15px;font-weight:400 !important}#adminmenu a.wp-has-current-submenu:after,#adminmenu>li.current>a.current:after,#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border:none}#adminmenu .dashicons,#adminmenu .dashicons-before:before{width:24px;height:24px;font-size:24px}#adminmenu a{color:#2c3338 !important}#adminmenu li.current>a{background:#e9eff5 !important}#adminmenu div.wp-menu-image:before{color:#646970 !important}#adminmenu li a:hover div.wp-menu-image:before{color:#2c3338 !important}#adminmenu li.current a div.wp-menu-image:before{color:#2271b1 !important}#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu{background:transparent}#adminmenu div.wp-menu-image.svg{filter:brightness(0.4)}#adminmenu li a:hover div.wp-menu-image.svg,#adminmenu li.current div.wp-menu-image.svg{filter:brightness(0.25)}#adminmenu li.current div.wp-menu-image:before,#adminmenu li.current a,#adminmenu li.current .wp-menu-name{color:#2271b1 !important}#adminmenu div.wp-menu-name{color:#646970;font-size:15px;padding:9px 41px 8px 0;font-weight:600}#adminmenu li a:hover div.wp-menu-name{color:#2c3338}#adminmenu li.menu-top{min-height:46px}#adminmenu .awaiting-mod,#adminmenu .update-plugins{background-color:#2271b1}.no-js li.wp-has-current-submenu:hover .wp-submenu{background:transparent !important}#wpcontent,#wpfooter{margin-right:272px}#toplevel_page_plugins div.wp-menu-image.svg,#toplevel_page_plugin-install div.wp-menu-image.svg{background-size:24px auto}#toplevel_page_plugins div.wp-menu-image.svg{position:relative;right:-2px}#calypso-sidebar-header{border-bottom:1px solid #646970;position:fixed;top:47px;right:0;width:272px;height:65px;background:#fff;z-index:10000}#calypso-sidebar-header svg{float:right;position:relative;right:10px;top:23px}#calypso-sidebar-header ul{float:right;position:relative;right:15px}#calypso-sidebar-header ul li{margin:0}#calypso-sidebar-header ul li#calypso-sitename{font-size:12px;color:#646970;overflow:hidden;white-space:nowrap;width:225px}@media screen and (max-width: 782px){#calypso-sidebar-header ul li#calypso-sitename{width:150px}}#calypso-sidebar-header ul li#calypso-sitename:after{content:"";display:block;position:absolute;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;pointer-events:none;background:linear-gradient(to left, rgba(255, 255, 255, 0), #fff 90%);top:0px;bottom:0px;left:0px;right:auto;width:20%;height:auto}#calypso-sidebar-header ul li#calypso-plugins{font-weight:bold;color:#2c3338;font-size:16px}.folded #adminmenu .wp-has-current-submenu .wp-submenu,.folded #adminmenu .opensub .wp-submenu,.folded #adminmenu .opensub .wp-submenu:after,.folded #adminmenu a.wp-has-current-submenu:focus+.wp-submenu{background:transparent !important}.folded #adminmenu li.menu-top .wp-submenu>li>a{padding:7px 46px 7px 12px;font-size:14px}.folded #adminmenu li.current.menu-top,.folded #adminmenu li.wp-has-current-submenu,.folded #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head{background:#e9eff5}.folded #adminmenu .wp-submenu .wp-submenu-head{padding:14px 11px 14px 4px}.folded #adminmenu a.menu-top{padding-right:1px}.folded #wpcontent #calypso-sidebar-header{width:36px}.folded #wpcontent #calypso-sidebar-header svg{right:6px}.folded #wpcontent #calypso-sidebar-header ul{display:none}.folded .no-js li.wp-has-current-submenu:hover .wp-submenu{background:#f6f7f7 !important}.folded #toplevel_page_plugins div.wp-menu-image.svg{position:relative;right:-2px}@media only screen and (max-width: 960px){#calypso-sidebar-header{width:36px}#calypso-sidebar-header ul{display:none}#calypso-sidebar-header svg{right:6px}#adminmenu a.menu-top{padding-right:1px}}@media screen and (max-width: 782px){#calypso-sidebar-header{position:absolute;display:none;width:190px;top:-14px}.wp-responsive-open #calypso-sidebar-header{display:block}#calypso-sidebar-header ul{display:block}.auto-fold #adminmenu .wp-menu-name{margin-right:0}.auto-fold #adminmenu{top:-14px}#adminmenu .wp-submenu,.auto-fold #adminmenu .selected .wp-submenu,.auto-fold #adminmenu .wp-menu-open .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu{background:#fff !important}.auto-fold #adminmenu li.selected div.wp-menu-image.svg{filter:brightness(100)}.auto-fold #adminmenu li.selected div.wp-menu-image:before,.auto-fold #adminmenu li.selected div.wp-menu-name{color:#2271b1 !important}#wpadminbar .quicklinks>ul>li>a,#wpadminbar .quicklinks>ul>li>.ab-empty-item{padding:0 15px !important}#wpadminbar li#wp-admin-bar-ab-new-post a{padding:7px 15px !important}}@media screen and (max-width: 600px){#calypso-sidebar-header{top:32px}.auto-fold #adminmenu{top:32px}}@media screen and (max-width: 480px){#wpadminbar #wp-admin-bar-blog.my-sites>a.ab-item:before{margin-top:4px !important}#wpadminbar #wp-admin-bar-newdash>a.ab-item:before{margin-top:6px !important}#wpadminbar ul li#wp-admin-bar-ab-new-post a:before{top:-5px !important;margin-right:-12px !important}}.nav-tab-wrapper,.wrap h2.nav-tab-wrapper{margin:10px 0 25px;background:#fff;border:1px solid rgba(200,215,225,.5)}.nav-tab{border:none;background:none;font-weight:400;padding:3px 13px 12px;color:#2271b1}.nav-tab-active,.nav-tab-active:focus,.nav-tab-active:focus:active,.nav-tab-active:hover{background:transparent;box-shadow:none}.nav-tab:first-child{margin-right:0}.nav-tab-active,.nav-tab-active:focus,.nav-tab-active:focus:active{border-bottom:2px solid #3c434a;color:#2c3338}#wpadminbar{background:#006088;-webkit-box-shadow:none;-mozilla-box-shadow:none;border-bottom:1px solid #0a4b78;height:46px;position:fixed}#wpadminbar .ab-top-menu>li>.ab-item{font-size:14px}#wpadminbar .ab-top-menu>li.hover>.ab-item{background:#004e6e !important;color:#fff}#wpadminbar *{line-height:46px}#wpadminbar .quicklinks a,#wpadminbar .quicklinks .ab-empty-item,#wpadminbar .shortlink-input{height:46px}#wpadminbar .quicklinks>ul>li>a{padding:0 15px}#wpadminbar .quicklinks>ul>li.current>a{background:#004966}#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar .ab-top-menu>li.ab-hover>.ab-item{background:transparent !important}#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item{background:#004e6e !important;color:#fff}#wpadminbar .ab-top-menu>li.my-sites>.ab-item,#wpadminbar .ab-top-menu>li.my-sites.hover>.ab-item,#wpadminbar .ab-top-menu>li.my-sites.ab-hover>.ab-item{background:#002c40 !important}#wpadminbar #wp-admin-bar-blog.my-sites>a.ab-item:before,#wpadminbar #wp-admin-bar-newdash>a.ab-item:before{margin-top:13px}#wpadminbar #wp-admin-bar-blog.my-sites>a.ab-item:before{top:-2px !important}#wpadminbar ul li#wp-admin-bar-ab-new-post{border-radius:3px}#wpadminbar ul li#wp-admin-bar-ab-new-post a{padding:6px 15px;color:#2271b1 !important}#wpadminbar ul li#wp-admin-bar-ab-new-post a span{color:#2271b1 !important;font-size:14px !important;margin-left:4px;margin-right:6px}#wpadminbar ul li#wp-admin-bar-ab-new-post a:before,#wpadminbar ul li#wp-admin-bar-ab-new-post a:after{background-image:url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect x="0" fill="none" width="24" height="24"/><g><path fill="%230087be" d="M21 14v5c0 1.105-.895 2-2 2H5c-1.105 0-2-.895-2-2V5c0-1.105.895-2 2-2h5v2H5v14h14v-5h2z"/><path fill="%230087be" d="M21 7h-4V3h-2v4h-4v2h4v4h2V9h4"/></g></svg>') !important}#wpadminbar ul li#wp-admin-bar-ab-new-post a:before{margin-right:-6px}#wpadminbar ul li#wp-admin-bar-ab-new-post:hover,#wpadminbar ul li#wp-admin-bar-ab-new-post:hover>.ab-item{background:#f6f7f7 !important;opacity:1;border-radius:3px !important}#wpadminbar li#wp-admin-bar-blog.menupop>.ab-sub-wrapper,#wpadminbar li#wp-admin-bar-newdash.menupop>.ab-sub-wrapper,#wpadminbar li#wp-admin-bar-my-account.menupop>.ab-sub-wrapper{display:none !important}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar{margin-left:-1px;margin-right:9px}#wpadminbar li#wp-admin-bar-notes.active,#wpadminbar li#wp-admin-bar-notes.active>.ab-item{background:#002c40 !important}#wpadminbar li#wp-admin-bar-notes>#wpnt-notes-panel2{top:46px}#wpadminbar .ab-top-menu>li.ab-active>.ab-item,#wpadminbar>#wp-toolbar .wpnt-show span.noticon,#wpadminbar #wp-admin-bar-notes.wpnt-show .noticon{color:#fff !important}#wpadminbar .ab-active>a.ab-item:before,#wpadminbar #wp-admin-bar-notes.active .noticon-bell:before{filter:brightness(100) !important}#wpadminbar .quicklinks>ul>li#wp-admin-bar-notes>a.ab-item span.noticon,#wpadminbar>#wp-toolbar span.noticon,#wpadminbar #wp-admin-bar-notes .noticon{top:10px}#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon,#wpadminbar .ab-icon,#wpadminbar .ab-item:before{font-size:24px;line-height:1.45}#wpadminbar li#wp-admin-bar-recovery-mode{background-color:#b26200 !important}body #wp-admin-bar-notes>.ab-item{padding:0 15px !important}#wpadminbar ul li#wp-admin-bar-ab-new-post{top:5px !important}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{display:none}.wrap{margin:20px 15px 25px 30px}@media screen and (max-width: 782px){.wrap{margin:10px 7px 10px 18px}}.subsubsub,.wp-filter{margin:10px 0 25px;background:#fff;border:1px solid rgba(200,215,225,.5);width:100%;box-shadow:none;padding:0}.subsubsub a,.filter-links li>a{padding:10px 15px;display:inline-block;font-size:14px;margin:0;color:#2271b1;border-bottom:2px solid #fff;outline:none}.subsubsub a:focus,.filter-links li>a:focus{box-shadow:0 0 0 1px #2271b1,0 0 2px 1px #5198d9}.subsubsub a:hover,.filter-links li>a:hover{color:#0a4b78;background-color:#e9eff5}.subsubsub a:hover:not(.current),.filter-links li>a:hover:not(.current){border-color:#e9eff5}.filter-links li>a{padding:16px}.subsubsub a.current,.filter-links .current{border-bottom:2px solid #3c434a}@media only screen and (max-width: 480px){.filter-links,.filter-links li,.filter-links li a{display:block}.filter-links li>a{font-size:16px}}.count{display:inline-block;padding:1px 6px;border:solid 1px #8e9196;border-radius:12px;font-size:11px;font-weight:bold;line-height:14px;color:#646970;text-align:center;margin-right:2px}.plugins-php .plugins a{color:#2271b1}.plugins-php .plugins a:hover,.plugins-php .plugins a:focus{color:#0a4b78}.plugins-php .plugins a:focus{box-shadow:0 0 0 1px #2271b1,0 0 2px 1px #5198d9}.plugins-php .plugins a.delete{color:#d63638}.plugins-php .plugins a.delete:hover,.plugins-php .plugins a.delete:focus{color:#8a2424}.plugins-php .plugins a.delete:focus{box-shadow:0 0 0 1px #d63638,0 0 2px 1px #f86368}.plugins-php .tablenav{clear:none;float:right;margin-bottom:15px}.plugins-php .tablenav .one-page .displaying-num{display:none}.plugins-php .bulkactions select:focus{border-color:#2271b1;box-shadow:0 0 2px #5198d9}.plugins-php p.search-box{margin-top:5px}.plugins-php p.search-box .wp-filter-search:focus{border-color:#2271b1;box-shadow:0 0 2px #5198d9}.plugins-php .plugin-update-tr.active td,.plugins-php .plugins .active th{border-right:4px solid #2271b1}.plugins-php .plugins .active th,.plugins-php .plugins .active td,.plugins-php .plugins .active th.check-column,.plugins-php .plugin-update-tr.active td{background-color:#e9eff5}.wrap .wp-heading-inline+.page-title-action,.wrap .add-new-h2,.wrap .add-new-h2:active,.wrap .page-title-action,.wrap .page-title-action:active{background:#c9356e;border-color:#8c1749;color:#fff;border-style:solid;border-width:1px 1px 2px;cursor:pointer;display:inline-block;margin:0 0 0 5px;outline:0;overflow:hidden;font-weight:500;text-overflow:ellipsis;text-decoration:none;vertical-align:middle;box-sizing:border-box;font-size:13px;line-height:21px;border-radius:4px;padding:2px 10px 2px;margin-bottom:2px;-webkit-appearance:none;appearance:none}.wrap .wp-heading-inline+.page-title-action:hover,.wrap .add-new-h2:hover,.wrap .add-new-h2:active:hover,.wrap .page-title-action:hover,.wrap .page-title-action:active:hover{background-color:#e34c84}.wrap .wp-heading-inline+.page-title-action:focus,.wrap .add-new-h2:focus,.wrap .add-new-h2:active:focus,.wrap .page-title-action:focus,.wrap .page-title-action:active:focus{box-shadow:0 0 0 2px #eb6594;background-color:#e34c84}.wp-core-ui .button{background:#fff}.wp-core-ui .button:focus{border-color:#2271b1;box-shadow:0 0 3px #5198d9}.wp-core-ui .button-primary{background:#2271b1;border-color:#0a4b78;color:#fff;text-shadow:none}.wp-core-ui .button-primary:hover,.wp-core-ui .button-primary:focus{background-color:#3582c4}.ui-tabs-nav li,.wp-switch-editor{background-color:#f6f7f7 !important}.plugin-card a,.popular-tags a,.filter-links>li>a{color:#2271b1}.plugin-card a:hover,.plugin-card a:focus,.popular-tags a:hover,.popular-tags a:focus,.filter-links>li>a:hover,.filter-links>li>a:focus{color:#0a4b78}.plugin-card a:focus,.popular-tags a:focus,.filter-links>li>a:focus{box-shadow:0 0 0 1px #2271b1,0 0 2px 1px #5198d9}.plugin-card-bottom,.alternate,.striped>tbody>:nth-child(odd),ul.striped>:nth-child(odd),.ui-tabs-panel,.ui-tabs-nav li.ui-tabs-active,.ui-tabs-nav li.ui-tabs-active:hover,div.mce-toolbar-grp,.html-active .switch-html,.tmce-active .switch-tmce,#post-status-info,.quicktags-toolbar,#major-publishing-actions{background-color:#fff;border-color:#d7e1e9}.wp-filter .search-form{margin-left:10px}@media only screen and (max-width: 1000px){.wp-filter .search-form{margin-right:10px}}@media only screen and (max-width: 782px){.wp-filter .search-form input[type=search].wp-filter-search{padding:5px}}@media only screen and (max-width: 480px){.wp-filter .search-form.search-plugins{align-items:center;display:flex}.wp-filter .search-form.search-plugins .wp-filter-search{flex:0 1 auto;max-width:none;width:100%}.wp-filter .search-form select{flex-shrink:0}.wp-filter .search-form>label{flex:1 1 auto}}.form-toggle[type=checkbox]{display:none}.form-toggle__switch{position:relative;display:inline-block;border-radius:12px;box-sizing:border-box;padding:2px;width:40px;height:24px;vertical-align:middle;align-self:flex-start;outline:0;cursor:pointer;transition:all .4s ease,box-shadow 0s}.form-toggle__switch:before,.form-toggle__switch:after{position:relative;display:block;content:"";width:20px;height:20px}.form-toggle__switch:after{right:0;border-radius:50%;background:#fff;transition:all .2s ease}.form-toggle__switch:before{display:none}.accessible-focus .form-toggle__switch:focus{box-shadow:0 0 0 2px #2271b1}.form-toggle__label{cursor:pointer}.is-disabled .form-toggle__label{cursor:default}.form-toggle__label .form-toggle__label-content{flex:0 1 100%;margin-right:12px}.accessible-focus .form-toggle:focus+.form-toggle__label .form-toggle__switch{box-shadow:0 0 0 2px #2271b1}.accessible-focus .form-toggle:focus:checked+.form-toggle__label .form-toggle__switch{box-shadow:0 0 0 2px #5198d9}.form-toggle+.form-toggle__label .form-toggle__switch{background:#a7aaad}.form-toggle:not(:disabled)+.form-toggle__label:hover .form-toggle__switch{background:#c3c4c7}.form-toggle:checked+.form-toggle__label .form-toggle__switch{background:#2271b1}.form-toggle:checked+.form-toggle__label .form-toggle__switch:after{right:16px}.form-toggle:checked:not(:disabled)+.form-toggle__label:hover .form-toggle__switch{background:#5198d9}.form-toggle:disabled+label.form-toggle__label span.form-toggle__switch{opacity:.25;cursor:default}.form-toggle.is-toggling+.form-toggle__label .form-toggle__switch{background:#2271b1}.form-toggle.is-toggling:checked+.form-toggle__label .form-toggle__switch{background:#c3c4c7}.form-toggle.is-compact+.form-toggle__label .form-toggle__switch{border-radius:8px;width:24px;height:16px}.form-toggle.is-compact+.form-toggle__label .form-toggle__switch:before,.form-toggle.is-compact+.form-toggle__label .form-toggle__switch:after{width:12px;height:12px}.form-toggle.is-compact:checked+.form-toggle__label .form-toggle__switch:after{right:8px}
-/*# sourceMappingURL=style-rtl.min.css.map */
+#wp-content-editor-tools,body{background:#f6f7f7}#wpwrap{top:14px}#wp-admin-bar-notes #wpnt-notes-unread-count.wpn-unread{background-color:#eb6594!important;background-image:none!important;border:none!important}#adminmenu #collapse-menu,#adminmenu .wp-menu-separator,#screen-meta-links,#toplevel_page_jetpack,.wp-submenu{display:none}.wp-menu-open .wp-submenu{display:block}#adminmenu,#adminmenuback,#adminmenuwrap{background:#fff}#adminmenuback{border-left:1px solid #f6f7f7}#adminmenu,#adminmenu .wp-submenu,#adminmenuback,#adminmenuwrap{width:272px}#adminmenu{margin-top:71px}#adminmenu .wp-submenu{padding:0}#adminmenu .opensub .wp-submenu,#adminmenu .opensub .wp-submenu:after,#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu{background:transparent!important}#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li.wp-menu-open,#adminmenu li>a.menu-top:focus{background:transparent}#adminmenu a:hover{background-color:#f6f7f7!important}#adminmenu .wp-submenu-head,#adminmenu a.menu-top{padding:5px 5px 5px 0}#adminmenu .wp-has-current-submenu ul>li>a{font-size:15px;font-weight:400!important;padding:7px 46px 7px 12px}#adminmenu a.wp-has-current-submenu:after,#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after,#adminmenu>li.current>a.current:after{border:none}#adminmenu .dashicons,#adminmenu .dashicons-before:before{font-size:24px;height:24px;width:24px}#adminmenu a{color:#2c3338!important}#adminmenu li.current>a{background:#e9eff5!important}#adminmenu div.wp-menu-image:before{color:#646970!important}#adminmenu li a:hover div.wp-menu-image:before{color:#2c3338!important}#adminmenu li.current a div.wp-menu-image:before{color:#2271b1!important}#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu{background:transparent}#adminmenu div.wp-menu-image.svg{filter:brightness(.4)}#adminmenu li a:hover div.wp-menu-image.svg,#adminmenu li.current div.wp-menu-image.svg{filter:brightness(.25)}#adminmenu li.current .wp-menu-name,#adminmenu li.current a,#adminmenu li.current div.wp-menu-image:before{color:#2271b1!important}#adminmenu div.wp-menu-name{color:#646970;font-size:15px;font-weight:600;padding:9px 41px 8px 0}#adminmenu li a:hover div.wp-menu-name{color:#2c3338}#adminmenu li.menu-top{min-height:46px}#adminmenu .awaiting-mod,#adminmenu .update-plugins{background-color:#2271b1}.no-js li.wp-has-current-submenu:hover .wp-submenu{background:transparent!important}#wpcontent,#wpfooter{margin-right:272px}#toplevel_page_plugin-install div.wp-menu-image.svg,#toplevel_page_plugins div.wp-menu-image.svg{background-size:24px auto}#toplevel_page_plugins div.wp-menu-image.svg{position:relative;right:-2px}#calypso-sidebar-header{background:#fff;border-bottom:1px solid #646970;height:65px;position:fixed;right:0;top:47px;width:272px;z-index:10000}#calypso-sidebar-header svg{float:right;position:relative;right:10px;top:23px}#calypso-sidebar-header ul{float:right;position:relative;right:15px}#calypso-sidebar-header ul li{margin:0}#calypso-sidebar-header ul li#calypso-sitename{color:#646970;font-size:12px;overflow:hidden;white-space:nowrap;width:225px}@media screen and (max-width:782px){#calypso-sidebar-header ul li#calypso-sitename{width:150px}}#calypso-sidebar-header ul li#calypso-sitename:after{-webkit-touch-callout:none;background:linear-gradient(270deg,hsla(0,0%,100%,0),#fff 90%);bottom:0;content:"";display:block;height:auto;left:0;pointer-events:none;position:absolute;right:auto;top:0;-webkit-user-select:none;user-select:none;width:20%}#calypso-sidebar-header ul li#calypso-plugins{color:#2c3338;font-size:16px;font-weight:700}.folded #adminmenu .opensub .wp-submenu,.folded #adminmenu .opensub .wp-submenu:after,.folded #adminmenu .wp-has-current-submenu .wp-submenu,.folded #adminmenu a.wp-has-current-submenu:focus+.wp-submenu{background:transparent!important}.folded #adminmenu li.menu-top .wp-submenu>li>a{font-size:14px;padding:7px 46px 7px 12px}.folded #adminmenu li.current.menu-top,.folded #adminmenu li.wp-has-current-submenu,.folded #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head{background:#e9eff5}.folded #adminmenu .wp-submenu .wp-submenu-head{padding:14px 11px 14px 4px}.folded #adminmenu a.menu-top{padding-right:1px}.folded #wpcontent #calypso-sidebar-header{width:36px}.folded #wpcontent #calypso-sidebar-header svg{right:6px}.folded #wpcontent #calypso-sidebar-header ul{display:none}.folded .no-js li.wp-has-current-submenu:hover .wp-submenu{background:#f6f7f7!important}.folded #toplevel_page_plugins div.wp-menu-image.svg{position:relative;right:-2px}@media only screen and (max-width:960px){#calypso-sidebar-header{width:36px}#calypso-sidebar-header ul{display:none}#calypso-sidebar-header svg{right:6px}#adminmenu a.menu-top{padding-right:1px}}@media screen and (max-width:782px){#calypso-sidebar-header{display:none;position:absolute;top:-14px;width:190px}#calypso-sidebar-header ul,.wp-responsive-open #calypso-sidebar-header{display:block}.auto-fold #adminmenu .wp-menu-name{margin-right:0}.auto-fold #adminmenu{top:-14px}#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.auto-fold #adminmenu .selected .wp-submenu,.auto-fold #adminmenu .wp-menu-open .wp-submenu{background:#fff!important}.auto-fold #adminmenu li.selected div.wp-menu-image.svg{filter:brightness(100)}.auto-fold #adminmenu li.selected div.wp-menu-image:before,.auto-fold #adminmenu li.selected div.wp-menu-name{color:#2271b1!important}#wpadminbar .quicklinks>ul>li>.ab-empty-item,#wpadminbar .quicklinks>ul>li>a{padding:0 15px!important}#wpadminbar li#wp-admin-bar-ab-new-post a{padding:7px 15px!important}}@media screen and (max-width:600px){#calypso-sidebar-header,.auto-fold #adminmenu{top:32px}}@media screen and (max-width:480px){#wpadminbar #wp-admin-bar-blog.my-sites>a.ab-item:before{margin-top:4px!important}#wpadminbar #wp-admin-bar-newdash>a.ab-item:before{margin-top:6px!important}#wpadminbar ul li#wp-admin-bar-ab-new-post a:before{margin-right:-12px!important;top:-5px!important}}.nav-tab-wrapper,.wrap h2.nav-tab-wrapper{background:#fff;border:1px solid rgba(200,215,225,.5);margin:10px 0 25px}.nav-tab{background:none;border:none;color:#2271b1;font-weight:400;padding:3px 13px 12px}.nav-tab-active,.nav-tab-active:focus,.nav-tab-active:focus:active,.nav-tab-active:hover{background:transparent;box-shadow:none}.nav-tab:first-child{margin-right:0}.nav-tab-active,.nav-tab-active:focus,.nav-tab-active:focus:active{border-bottom:2px solid #3c434a;color:#2c3338}#wpadminbar{background:#006088;border-bottom:1px solid #0a4b78;-webkit-box-shadow:none;-mozilla-box-shadow:none;height:46px;position:fixed}#wpadminbar .ab-top-menu>li>.ab-item{font-size:14px}#wpadminbar .ab-top-menu>li.hover>.ab-item{background:#004e6e!important;color:#fff}#wpadminbar *{line-height:46px}#wpadminbar .quicklinks .ab-empty-item,#wpadminbar .quicklinks a,#wpadminbar .shortlink-input{height:46px}#wpadminbar .quicklinks>ul>li>a{padding:0 15px}#wpadminbar .quicklinks>ul>li.current>a{background:#004966}#wpadminbar .ab-top-menu>li.ab-hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{background:transparent!important}#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item{background:#004e6e!important;color:#fff}#wpadminbar .ab-top-menu>li.my-sites.ab-hover>.ab-item,#wpadminbar .ab-top-menu>li.my-sites.hover>.ab-item,#wpadminbar .ab-top-menu>li.my-sites>.ab-item{background:#002c40!important}#wpadminbar #wp-admin-bar-blog.my-sites>a.ab-item:before,#wpadminbar #wp-admin-bar-newdash>a.ab-item:before{margin-top:13px}#wpadminbar #wp-admin-bar-blog.my-sites>a.ab-item:before{top:-2px!important}#wpadminbar ul li#wp-admin-bar-ab-new-post{border-radius:3px}#wpadminbar ul li#wp-admin-bar-ab-new-post a{color:#2271b1!important;padding:6px 15px}#wpadminbar ul li#wp-admin-bar-ab-new-post a span{color:#2271b1!important;font-size:14px!important;margin-left:4px;margin-right:6px}#wpadminbar ul li#wp-admin-bar-ab-new-post a:after,#wpadminbar ul li#wp-admin-bar-ab-new-post a:before{background-image:url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect x="0" fill="none" width="24" height="24"/><g><path fill="%230087be" d="M21 14v5c0 1.105-.895 2-2 2H5c-1.105 0-2-.895-2-2V5c0-1.105.895-2 2-2h5v2H5v14h14v-5h2z"/><path fill="%230087be" d="M21 7h-4V3h-2v4h-4v2h4v4h2V9h4"/></g></svg>')!important}#wpadminbar ul li#wp-admin-bar-ab-new-post a:before{margin-right:-6px}#wpadminbar ul li#wp-admin-bar-ab-new-post:hover,#wpadminbar ul li#wp-admin-bar-ab-new-post:hover>.ab-item{background:#f6f7f7!important;border-radius:3px!important;opacity:1}#wpadminbar li#wp-admin-bar-blog.menupop>.ab-sub-wrapper,#wpadminbar li#wp-admin-bar-my-account.menupop>.ab-sub-wrapper,#wpadminbar li#wp-admin-bar-newdash.menupop>.ab-sub-wrapper{display:none!important}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar{margin-left:-1px;margin-right:9px}#wpadminbar li#wp-admin-bar-notes.active,#wpadminbar li#wp-admin-bar-notes.active>.ab-item{background:#002c40!important}#wpadminbar li#wp-admin-bar-notes>#wpnt-notes-panel2{top:46px}#wpadminbar #wp-admin-bar-notes.wpnt-show .noticon,#wpadminbar .ab-top-menu>li.ab-active>.ab-item,#wpadminbar>#wp-toolbar .wpnt-show span.noticon{color:#fff!important}#wpadminbar #wp-admin-bar-notes.active .noticon-bell:before,#wpadminbar .ab-active>a.ab-item:before{filter:brightness(100)!important}#wpadminbar #wp-admin-bar-notes .noticon,#wpadminbar .quicklinks>ul>li#wp-admin-bar-notes>a.ab-item span.noticon,#wpadminbar>#wp-toolbar span.noticon{top:10px}#wpadminbar .ab-icon,#wpadminbar .ab-item:before,#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon{font-size:24px;line-height:1.45}#wpadminbar li#wp-admin-bar-recovery-mode{background-color:#b26200!important}body #wp-admin-bar-notes>.ab-item{padding:0 15px!important}#wpadminbar ul li#wp-admin-bar-ab-new-post{top:5px!important}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{display:none}.wrap{margin:20px 15px 25px 30px}@media screen and (max-width:782px){.wrap{margin:10px 7px 10px 18px}}.subsubsub,.wp-filter{background:#fff;border:1px solid rgba(200,215,225,.5);box-shadow:none;margin:10px 0 25px;padding:0;width:100%}.filter-links li>a,.subsubsub a{border-bottom:2px solid #fff;color:#2271b1;display:inline-block;font-size:14px;margin:0;outline:none;padding:10px 15px}.filter-links li>a:focus,.subsubsub a:focus{box-shadow:0 0 0 1px #2271b1,0 0 2px 1px #5198d9}.filter-links li>a:hover,.subsubsub a:hover{background-color:#e9eff5;color:#0a4b78}.filter-links li>a:hover:not(.current),.subsubsub a:hover:not(.current){border-color:#e9eff5}.filter-links li>a{padding:16px}.filter-links .current,.subsubsub a.current{border-bottom:2px solid #3c434a}@media only screen and (max-width:480px){.filter-links,.filter-links li,.filter-links li a{display:block}.filter-links li>a{font-size:16px}}.count{border:1px solid #8e9196;border-radius:12px;color:#646970;display:inline-block;font-size:11px;font-weight:700;line-height:14px;margin-right:2px;padding:1px 6px;text-align:center}.plugins-php .plugins a{color:#2271b1}.plugins-php .plugins a:focus,.plugins-php .plugins a:hover{color:#0a4b78}.plugins-php .plugins a:focus{box-shadow:0 0 0 1px #2271b1,0 0 2px 1px #5198d9}.plugins-php .plugins a.delete{color:#d63638}.plugins-php .plugins a.delete:focus,.plugins-php .plugins a.delete:hover{color:#8a2424}.plugins-php .plugins a.delete:focus{box-shadow:0 0 0 1px #d63638,0 0 2px 1px #f86368}.plugins-php .tablenav{clear:none;float:right;margin-bottom:15px}.plugins-php .tablenav .one-page .displaying-num{display:none}.plugins-php .bulkactions select:focus{border-color:#2271b1;box-shadow:0 0 2px #5198d9}.plugins-php p.search-box{margin-top:5px}.plugins-php p.search-box .wp-filter-search:focus{border-color:#2271b1;box-shadow:0 0 2px #5198d9}.plugins-php .plugin-update-tr.active td,.plugins-php .plugins .active th{border-right:4px solid #2271b1}.plugins-php .plugin-update-tr.active td,.plugins-php .plugins .active td,.plugins-php .plugins .active th,.plugins-php .plugins .active th.check-column{background-color:#e9eff5}.wrap .add-new-h2,.wrap .add-new-h2:active,.wrap .page-title-action,.wrap .page-title-action:active,.wrap .wp-heading-inline+.page-title-action{-webkit-appearance:none;appearance:none;background:#c9356e;border:solid #8c1749;border-radius:4px;border-width:1px 1px 2px;box-sizing:border-box;color:#fff;cursor:pointer;display:inline-block;font-size:13px;font-weight:500;line-height:21px;margin:0 0 2px 5px;outline:0;overflow:hidden;padding:2px 10px;text-decoration:none;text-overflow:ellipsis;vertical-align:middle}.wrap .add-new-h2:active:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:active:hover,.wrap .page-title-action:hover,.wrap .wp-heading-inline+.page-title-action:hover{background-color:#e34c84}.wrap .add-new-h2:active:focus,.wrap .add-new-h2:focus,.wrap .page-title-action:active:focus,.wrap .page-title-action:focus,.wrap .wp-heading-inline+.page-title-action:focus{background-color:#e34c84;box-shadow:0 0 0 2px #eb6594}.wp-core-ui .button{background:#fff}.wp-core-ui .button:focus{border-color:#2271b1;box-shadow:0 0 3px #5198d9}.wp-core-ui .button-primary{background:#2271b1;border-color:#0a4b78;color:#fff;text-shadow:none}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background-color:#3582c4}.ui-tabs-nav li,.wp-switch-editor{background-color:#f6f7f7!important}.filter-links>li>a,.plugin-card a,.popular-tags a{color:#2271b1}.filter-links>li>a:focus,.filter-links>li>a:hover,.plugin-card a:focus,.plugin-card a:hover,.popular-tags a:focus,.popular-tags a:hover{color:#0a4b78}.filter-links>li>a:focus,.plugin-card a:focus,.popular-tags a:focus{box-shadow:0 0 0 1px #2271b1,0 0 2px 1px #5198d9}#major-publishing-actions,#post-status-info,.alternate,.html-active .switch-html,.plugin-card-bottom,.quicktags-toolbar,.striped>tbody>:nth-child(odd),.tmce-active .switch-tmce,.ui-tabs-nav li.ui-tabs-active,.ui-tabs-nav li.ui-tabs-active:hover,.ui-tabs-panel,div.mce-toolbar-grp,ul.striped>:nth-child(odd){background-color:#fff;border-color:#d7e1e9}.wp-filter .search-form{margin-left:10px}@media only screen and (max-width:1000px){.wp-filter .search-form{margin-right:10px}}@media only screen and (max-width:782px){.wp-filter .search-form input[type=search].wp-filter-search{padding:5px}}@media only screen and (max-width:480px){.wp-filter .search-form.search-plugins{align-items:center;display:flex}.wp-filter .search-form.search-plugins .wp-filter-search{flex:0 1 auto;max-width:none;width:100%}.wp-filter .search-form select{flex-shrink:0}.wp-filter .search-form>label{flex:1 1 auto}}.form-toggle[type=checkbox]{display:none}.form-toggle__switch{align-self:flex-start;border-radius:12px;box-sizing:border-box;cursor:pointer;display:inline-block;height:24px;outline:0;padding:2px;position:relative;transition:all .4s ease,box-shadow 0s;vertical-align:middle;width:40px}.form-toggle__switch:after,.form-toggle__switch:before{content:"";display:block;height:20px;position:relative;width:20px}.form-toggle__switch:after{background:#fff;border-radius:50%;right:0;transition:all .2s ease}.form-toggle__switch:before{display:none}.accessible-focus .form-toggle__switch:focus{box-shadow:0 0 0 2px #2271b1}.form-toggle__label{cursor:pointer}.is-disabled .form-toggle__label{cursor:default}.form-toggle__label .form-toggle__label-content{flex:0 1 100%;margin-right:12px}.accessible-focus .form-toggle:focus+.form-toggle__label .form-toggle__switch{box-shadow:0 0 0 2px #2271b1}.accessible-focus .form-toggle:focus:checked+.form-toggle__label .form-toggle__switch{box-shadow:0 0 0 2px #5198d9}.form-toggle+.form-toggle__label .form-toggle__switch{background:#a7aaad}.form-toggle:not(:disabled)+.form-toggle__label:hover .form-toggle__switch{background:#c3c4c7}.form-toggle:checked+.form-toggle__label .form-toggle__switch{background:#2271b1}.form-toggle:checked+.form-toggle__label .form-toggle__switch:after{right:16px}.form-toggle:checked:not(:disabled)+.form-toggle__label:hover .form-toggle__switch{background:#5198d9}.form-toggle:disabled+label.form-toggle__label span.form-toggle__switch{cursor:default;opacity:.25}.form-toggle.is-toggling+.form-toggle__label .form-toggle__switch{background:#2271b1}.form-toggle.is-toggling:checked+.form-toggle__label .form-toggle__switch{background:#c3c4c7}.form-toggle.is-compact+.form-toggle__label .form-toggle__switch{border-radius:8px;height:16px;width:24px}.form-toggle.is-compact+.form-toggle__label .form-toggle__switch:after,.form-toggle.is-compact+.form-toggle__label .form-toggle__switch:before{height:12px;width:12px}.form-toggle.is-compact:checked+.form-toggle__label .form-toggle__switch:after{right:8px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/calypsoify/style.min.css b/plugins/jetpack/modules/calypsoify/style.min.css
index c9cb7517..ec532fd1 100644
--- a/plugins/jetpack/modules/calypsoify/style.min.css
+++ b/plugins/jetpack/modules/calypsoify/style.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is compiled SASS code. */
-body,#wp-content-editor-tools{background:#f6f7f7}#wpwrap{top:14px}#wp-admin-bar-notes #wpnt-notes-unread-count.wpn-unread{background-image:none !important;background-color:#eb6594 !important;border:none !important}#adminmenu #collapse-menu,#adminmenu .wp-menu-separator,#screen-meta-links,.wp-submenu,#toplevel_page_jetpack{display:none}.wp-menu-open .wp-submenu{display:block}#adminmenuwrap,#adminmenuback,#adminmenu{background:#fff}#adminmenuback{border-right:1px solid #f6f7f7}#adminmenu,#adminmenuwrap,#adminmenuback,#adminmenu .wp-submenu{width:272px}#adminmenu{margin-top:71px}#adminmenu .wp-submenu{padding:0}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .opensub .wp-submenu,#adminmenu .opensub .wp-submenu:after,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu{background:transparent !important}#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus,#adminmenu li.wp-menu-open{background:transparent}#adminmenu a:hover{background-color:#f6f7f7 !important}#adminmenu .wp-submenu-head,#adminmenu a.menu-top{padding:5px 0 5px 5px}#adminmenu .wp-has-current-submenu ul>li>a{padding:7px 12px 7px 46px;font-size:15px;font-weight:400 !important}#adminmenu a.wp-has-current-submenu:after,#adminmenu>li.current>a.current:after,#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border:none}#adminmenu .dashicons,#adminmenu .dashicons-before:before{width:24px;height:24px;font-size:24px}#adminmenu a{color:#2c3338 !important}#adminmenu li.current>a{background:#e9eff5 !important}#adminmenu div.wp-menu-image:before{color:#646970 !important}#adminmenu li a:hover div.wp-menu-image:before{color:#2c3338 !important}#adminmenu li.current a div.wp-menu-image:before{color:#2271b1 !important}#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu{background:transparent}#adminmenu div.wp-menu-image.svg{filter:brightness(0.4)}#adminmenu li a:hover div.wp-menu-image.svg,#adminmenu li.current div.wp-menu-image.svg{filter:brightness(0.25)}#adminmenu li.current div.wp-menu-image:before,#adminmenu li.current a,#adminmenu li.current .wp-menu-name{color:#2271b1 !important}#adminmenu div.wp-menu-name{color:#646970;font-size:15px;padding:9px 0 8px 41px;font-weight:600}#adminmenu li a:hover div.wp-menu-name{color:#2c3338}#adminmenu li.menu-top{min-height:46px}#adminmenu .awaiting-mod,#adminmenu .update-plugins{background-color:#2271b1}.no-js li.wp-has-current-submenu:hover .wp-submenu{background:transparent !important}#wpcontent,#wpfooter{margin-left:272px}#toplevel_page_plugins div.wp-menu-image.svg,#toplevel_page_plugin-install div.wp-menu-image.svg{background-size:24px auto}#toplevel_page_plugins div.wp-menu-image.svg{position:relative;left:-2px}#calypso-sidebar-header{border-bottom:1px solid #646970;position:fixed;top:47px;left:0;width:272px;height:65px;background:#fff;z-index:10000}#calypso-sidebar-header svg{float:left;position:relative;left:10px;top:23px}#calypso-sidebar-header ul{float:left;position:relative;left:15px}#calypso-sidebar-header ul li{margin:0}#calypso-sidebar-header ul li#calypso-sitename{font-size:12px;color:#646970;overflow:hidden;white-space:nowrap;width:225px}@media screen and (max-width: 782px){#calypso-sidebar-header ul li#calypso-sitename{width:150px}}#calypso-sidebar-header ul li#calypso-sitename:after{content:"";display:block;position:absolute;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;pointer-events:none;background:linear-gradient(to right, rgba(255, 255, 255, 0), #fff 90%);top:0px;bottom:0px;right:0px;left:auto;width:20%;height:auto}#calypso-sidebar-header ul li#calypso-plugins{font-weight:bold;color:#2c3338;font-size:16px}.folded #adminmenu .wp-has-current-submenu .wp-submenu,.folded #adminmenu .opensub .wp-submenu,.folded #adminmenu .opensub .wp-submenu:after,.folded #adminmenu a.wp-has-current-submenu:focus+.wp-submenu{background:transparent !important}.folded #adminmenu li.menu-top .wp-submenu>li>a{padding:7px 12px 7px 46px;font-size:14px}.folded #adminmenu li.current.menu-top,.folded #adminmenu li.wp-has-current-submenu,.folded #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head{background:#e9eff5}.folded #adminmenu .wp-submenu .wp-submenu-head{padding:14px 4px 14px 11px}.folded #adminmenu a.menu-top{padding-left:1px}.folded #wpcontent #calypso-sidebar-header{width:36px}.folded #wpcontent #calypso-sidebar-header svg{left:6px}.folded #wpcontent #calypso-sidebar-header ul{display:none}.folded .no-js li.wp-has-current-submenu:hover .wp-submenu{background:#f6f7f7 !important}.folded #toplevel_page_plugins div.wp-menu-image.svg{position:relative;left:-2px}@media only screen and (max-width: 960px){#calypso-sidebar-header{width:36px}#calypso-sidebar-header ul{display:none}#calypso-sidebar-header svg{left:6px}#adminmenu a.menu-top{padding-left:1px}}@media screen and (max-width: 782px){#calypso-sidebar-header{position:absolute;display:none;width:190px;top:-14px}.wp-responsive-open #calypso-sidebar-header{display:block}#calypso-sidebar-header ul{display:block}.auto-fold #adminmenu .wp-menu-name{margin-left:0}.auto-fold #adminmenu{top:-14px}#adminmenu .wp-submenu,.auto-fold #adminmenu .selected .wp-submenu,.auto-fold #adminmenu .wp-menu-open .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu{background:#fff !important}.auto-fold #adminmenu li.selected div.wp-menu-image.svg{filter:brightness(100)}.auto-fold #adminmenu li.selected div.wp-menu-image:before,.auto-fold #adminmenu li.selected div.wp-menu-name{color:#2271b1 !important}#wpadminbar .quicklinks>ul>li>a,#wpadminbar .quicklinks>ul>li>.ab-empty-item{padding:0 15px !important}#wpadminbar li#wp-admin-bar-ab-new-post a{padding:7px 15px !important}}@media screen and (max-width: 600px){#calypso-sidebar-header{top:32px}.auto-fold #adminmenu{top:32px}}@media screen and (max-width: 480px){#wpadminbar #wp-admin-bar-blog.my-sites>a.ab-item:before{margin-top:4px !important}#wpadminbar #wp-admin-bar-newdash>a.ab-item:before{margin-top:6px !important}#wpadminbar ul li#wp-admin-bar-ab-new-post a:before{top:-5px !important;margin-left:-12px !important}}.nav-tab-wrapper,.wrap h2.nav-tab-wrapper{margin:10px 0 25px;background:#fff;border:1px solid rgba(200,215,225,.5)}.nav-tab{border:none;background:none;font-weight:400;padding:3px 13px 12px;color:#2271b1}.nav-tab-active,.nav-tab-active:focus,.nav-tab-active:focus:active,.nav-tab-active:hover{background:transparent;box-shadow:none}.nav-tab:first-child{margin-left:0}.nav-tab-active,.nav-tab-active:focus,.nav-tab-active:focus:active{border-bottom:2px solid #3c434a;color:#2c3338}#wpadminbar{background:#006088;-webkit-box-shadow:none;-mozilla-box-shadow:none;border-bottom:1px solid #0a4b78;height:46px;position:fixed}#wpadminbar .ab-top-menu>li>.ab-item{font-size:14px}#wpadminbar .ab-top-menu>li.hover>.ab-item{background:#004e6e !important;color:#fff}#wpadminbar *{line-height:46px}#wpadminbar .quicklinks a,#wpadminbar .quicklinks .ab-empty-item,#wpadminbar .shortlink-input{height:46px}#wpadminbar .quicklinks>ul>li>a{padding:0 15px}#wpadminbar .quicklinks>ul>li.current>a{background:#004966}#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar .ab-top-menu>li.ab-hover>.ab-item{background:transparent !important}#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item{background:#004e6e !important;color:#fff}#wpadminbar .ab-top-menu>li.my-sites>.ab-item,#wpadminbar .ab-top-menu>li.my-sites.hover>.ab-item,#wpadminbar .ab-top-menu>li.my-sites.ab-hover>.ab-item{background:#002c40 !important}#wpadminbar #wp-admin-bar-blog.my-sites>a.ab-item:before,#wpadminbar #wp-admin-bar-newdash>a.ab-item:before{margin-top:13px}#wpadminbar #wp-admin-bar-blog.my-sites>a.ab-item:before{top:-2px !important}#wpadminbar ul li#wp-admin-bar-ab-new-post{border-radius:3px}#wpadminbar ul li#wp-admin-bar-ab-new-post a{padding:6px 15px;color:#2271b1 !important}#wpadminbar ul li#wp-admin-bar-ab-new-post a span{color:#2271b1 !important;font-size:14px !important;margin-right:4px;margin-left:6px}#wpadminbar ul li#wp-admin-bar-ab-new-post a:before,#wpadminbar ul li#wp-admin-bar-ab-new-post a:after{background-image:url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect x="0" fill="none" width="24" height="24"/><g><path fill="%230087be" d="M21 14v5c0 1.105-.895 2-2 2H5c-1.105 0-2-.895-2-2V5c0-1.105.895-2 2-2h5v2H5v14h14v-5h2z"/><path fill="%230087be" d="M21 7h-4V3h-2v4h-4v2h4v4h2V9h4"/></g></svg>') !important}#wpadminbar ul li#wp-admin-bar-ab-new-post a:before{margin-left:-6px}#wpadminbar ul li#wp-admin-bar-ab-new-post:hover,#wpadminbar ul li#wp-admin-bar-ab-new-post:hover>.ab-item{background:#f6f7f7 !important;opacity:1;border-radius:3px !important}#wpadminbar li#wp-admin-bar-blog.menupop>.ab-sub-wrapper,#wpadminbar li#wp-admin-bar-newdash.menupop>.ab-sub-wrapper,#wpadminbar li#wp-admin-bar-my-account.menupop>.ab-sub-wrapper{display:none !important}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar{margin-right:-1px;margin-left:9px}#wpadminbar li#wp-admin-bar-notes.active,#wpadminbar li#wp-admin-bar-notes.active>.ab-item{background:#002c40 !important}#wpadminbar li#wp-admin-bar-notes>#wpnt-notes-panel2{top:46px}#wpadminbar .ab-top-menu>li.ab-active>.ab-item,#wpadminbar>#wp-toolbar .wpnt-show span.noticon,#wpadminbar #wp-admin-bar-notes.wpnt-show .noticon{color:#fff !important}#wpadminbar .ab-active>a.ab-item:before,#wpadminbar #wp-admin-bar-notes.active .noticon-bell:before{filter:brightness(100) !important}#wpadminbar .quicklinks>ul>li#wp-admin-bar-notes>a.ab-item span.noticon,#wpadminbar>#wp-toolbar span.noticon,#wpadminbar #wp-admin-bar-notes .noticon{top:10px}#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon,#wpadminbar .ab-icon,#wpadminbar .ab-item:before{font-size:24px;line-height:1.45}#wpadminbar li#wp-admin-bar-recovery-mode{background-color:#b26200 !important}body #wp-admin-bar-notes>.ab-item{padding:0 15px !important}#wpadminbar ul li#wp-admin-bar-ab-new-post{top:5px !important}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{display:none}.wrap{margin:20px 30px 25px 15px}@media screen and (max-width: 782px){.wrap{margin:10px 18px 10px 7px}}.subsubsub,.wp-filter{margin:10px 0 25px;background:#fff;border:1px solid rgba(200,215,225,.5);width:100%;box-shadow:none;padding:0}.subsubsub a,.filter-links li>a{padding:10px 15px;display:inline-block;font-size:14px;margin:0;color:#2271b1;border-bottom:2px solid #fff;outline:none}.subsubsub a:focus,.filter-links li>a:focus{box-shadow:0 0 0 1px #2271b1,0 0 2px 1px #5198d9}.subsubsub a:hover,.filter-links li>a:hover{color:#0a4b78;background-color:#e9eff5}.subsubsub a:hover:not(.current),.filter-links li>a:hover:not(.current){border-color:#e9eff5}.filter-links li>a{padding:16px}.subsubsub a.current,.filter-links .current{border-bottom:2px solid #3c434a}@media only screen and (max-width: 480px){.filter-links,.filter-links li,.filter-links li a{display:block}.filter-links li>a{font-size:16px}}.count{display:inline-block;padding:1px 6px;border:solid 1px #8e9196;border-radius:12px;font-size:11px;font-weight:bold;line-height:14px;color:#646970;text-align:center;margin-left:2px}.plugins-php .plugins a{color:#2271b1}.plugins-php .plugins a:hover,.plugins-php .plugins a:focus{color:#0a4b78}.plugins-php .plugins a:focus{box-shadow:0 0 0 1px #2271b1,0 0 2px 1px #5198d9}.plugins-php .plugins a.delete{color:#d63638}.plugins-php .plugins a.delete:hover,.plugins-php .plugins a.delete:focus{color:#8a2424}.plugins-php .plugins a.delete:focus{box-shadow:0 0 0 1px #d63638,0 0 2px 1px #f86368}.plugins-php .tablenav{clear:none;float:left;margin-bottom:15px}.plugins-php .tablenav .one-page .displaying-num{display:none}.plugins-php .bulkactions select:focus{border-color:#2271b1;box-shadow:0 0 2px #5198d9}.plugins-php p.search-box{margin-top:5px}.plugins-php p.search-box .wp-filter-search:focus{border-color:#2271b1;box-shadow:0 0 2px #5198d9}.plugins-php .plugin-update-tr.active td,.plugins-php .plugins .active th{border-left:4px solid #2271b1}.plugins-php .plugins .active th,.plugins-php .plugins .active td,.plugins-php .plugins .active th.check-column,.plugins-php .plugin-update-tr.active td{background-color:#e9eff5}.wrap .wp-heading-inline+.page-title-action,.wrap .add-new-h2,.wrap .add-new-h2:active,.wrap .page-title-action,.wrap .page-title-action:active{background:#c9356e;border-color:#8c1749;color:#fff;border-style:solid;border-width:1px 1px 2px;cursor:pointer;display:inline-block;margin:0 5px 0 0;outline:0;overflow:hidden;font-weight:500;text-overflow:ellipsis;text-decoration:none;vertical-align:middle;box-sizing:border-box;font-size:13px;line-height:21px;border-radius:4px;padding:2px 10px 2px;margin-bottom:2px;-webkit-appearance:none;appearance:none}.wrap .wp-heading-inline+.page-title-action:hover,.wrap .add-new-h2:hover,.wrap .add-new-h2:active:hover,.wrap .page-title-action:hover,.wrap .page-title-action:active:hover{background-color:#e34c84}.wrap .wp-heading-inline+.page-title-action:focus,.wrap .add-new-h2:focus,.wrap .add-new-h2:active:focus,.wrap .page-title-action:focus,.wrap .page-title-action:active:focus{box-shadow:0 0 0 2px #eb6594;background-color:#e34c84}.wp-core-ui .button{background:#fff}.wp-core-ui .button:focus{border-color:#2271b1;box-shadow:0 0 3px #5198d9}.wp-core-ui .button-primary{background:#2271b1;border-color:#0a4b78;color:#fff;text-shadow:none}.wp-core-ui .button-primary:hover,.wp-core-ui .button-primary:focus{background-color:#3582c4}.ui-tabs-nav li,.wp-switch-editor{background-color:#f6f7f7 !important}.plugin-card a,.popular-tags a,.filter-links>li>a{color:#2271b1}.plugin-card a:hover,.plugin-card a:focus,.popular-tags a:hover,.popular-tags a:focus,.filter-links>li>a:hover,.filter-links>li>a:focus{color:#0a4b78}.plugin-card a:focus,.popular-tags a:focus,.filter-links>li>a:focus{box-shadow:0 0 0 1px #2271b1,0 0 2px 1px #5198d9}.plugin-card-bottom,.alternate,.striped>tbody>:nth-child(odd),ul.striped>:nth-child(odd),.ui-tabs-panel,.ui-tabs-nav li.ui-tabs-active,.ui-tabs-nav li.ui-tabs-active:hover,div.mce-toolbar-grp,.html-active .switch-html,.tmce-active .switch-tmce,#post-status-info,.quicktags-toolbar,#major-publishing-actions{background-color:#fff;border-color:#d7e1e9}.wp-filter .search-form{margin-right:10px}@media only screen and (max-width: 1000px){.wp-filter .search-form{margin-left:10px}}@media only screen and (max-width: 782px){.wp-filter .search-form input[type=search].wp-filter-search{padding:5px}}@media only screen and (max-width: 480px){.wp-filter .search-form.search-plugins{align-items:center;display:flex}.wp-filter .search-form.search-plugins .wp-filter-search{flex:0 1 auto;max-width:none;width:100%}.wp-filter .search-form select{flex-shrink:0}.wp-filter .search-form>label{flex:1 1 auto}}.form-toggle[type=checkbox]{display:none}.form-toggle__switch{position:relative;display:inline-block;border-radius:12px;box-sizing:border-box;padding:2px;width:40px;height:24px;vertical-align:middle;align-self:flex-start;outline:0;cursor:pointer;transition:all .4s ease,box-shadow 0s}.form-toggle__switch:before,.form-toggle__switch:after{position:relative;display:block;content:"";width:20px;height:20px}.form-toggle__switch:after{left:0;border-radius:50%;background:#fff;transition:all .2s ease}.form-toggle__switch:before{display:none}.accessible-focus .form-toggle__switch:focus{box-shadow:0 0 0 2px #2271b1}.form-toggle__label{cursor:pointer}.is-disabled .form-toggle__label{cursor:default}.form-toggle__label .form-toggle__label-content{flex:0 1 100%;margin-left:12px}.accessible-focus .form-toggle:focus+.form-toggle__label .form-toggle__switch{box-shadow:0 0 0 2px #2271b1}.accessible-focus .form-toggle:focus:checked+.form-toggle__label .form-toggle__switch{box-shadow:0 0 0 2px #5198d9}.form-toggle+.form-toggle__label .form-toggle__switch{background:#a7aaad}.form-toggle:not(:disabled)+.form-toggle__label:hover .form-toggle__switch{background:#c3c4c7}.form-toggle:checked+.form-toggle__label .form-toggle__switch{background:#2271b1}.form-toggle:checked+.form-toggle__label .form-toggle__switch:after{left:16px}.form-toggle:checked:not(:disabled)+.form-toggle__label:hover .form-toggle__switch{background:#5198d9}.form-toggle:disabled+label.form-toggle__label span.form-toggle__switch{opacity:.25;cursor:default}.form-toggle.is-toggling+.form-toggle__label .form-toggle__switch{background:#2271b1}.form-toggle.is-toggling:checked+.form-toggle__label .form-toggle__switch{background:#c3c4c7}.form-toggle.is-compact+.form-toggle__label .form-toggle__switch{border-radius:8px;width:24px;height:16px}.form-toggle.is-compact+.form-toggle__label .form-toggle__switch:before,.form-toggle.is-compact+.form-toggle__label .form-toggle__switch:after{width:12px;height:12px}.form-toggle.is-compact:checked+.form-toggle__label .form-toggle__switch:after{left:8px} \ No newline at end of file
+#wp-content-editor-tools,body{background:#f6f7f7}#wpwrap{top:14px}#wp-admin-bar-notes #wpnt-notes-unread-count.wpn-unread{background-color:#eb6594!important;background-image:none!important;border:none!important}#adminmenu #collapse-menu,#adminmenu .wp-menu-separator,#screen-meta-links,#toplevel_page_jetpack,.wp-submenu{display:none}.wp-menu-open .wp-submenu{display:block}#adminmenu,#adminmenuback,#adminmenuwrap{background:#fff}#adminmenuback{border-right:1px solid #f6f7f7}#adminmenu,#adminmenu .wp-submenu,#adminmenuback,#adminmenuwrap{width:272px}#adminmenu{margin-top:71px}#adminmenu .wp-submenu{padding:0}#adminmenu .opensub .wp-submenu,#adminmenu .opensub .wp-submenu:after,#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu{background:transparent!important}#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li.wp-menu-open,#adminmenu li>a.menu-top:focus{background:transparent}#adminmenu a:hover{background-color:#f6f7f7!important}#adminmenu .wp-submenu-head,#adminmenu a.menu-top{padding:5px 0 5px 5px}#adminmenu .wp-has-current-submenu ul>li>a{font-size:15px;font-weight:400!important;padding:7px 12px 7px 46px}#adminmenu a.wp-has-current-submenu:after,#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after,#adminmenu>li.current>a.current:after{border:none}#adminmenu .dashicons,#adminmenu .dashicons-before:before{font-size:24px;height:24px;width:24px}#adminmenu a{color:#2c3338!important}#adminmenu li.current>a{background:#e9eff5!important}#adminmenu div.wp-menu-image:before{color:#646970!important}#adminmenu li a:hover div.wp-menu-image:before{color:#2c3338!important}#adminmenu li.current a div.wp-menu-image:before{color:#2271b1!important}#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu{background:transparent}#adminmenu div.wp-menu-image.svg{filter:brightness(.4)}#adminmenu li a:hover div.wp-menu-image.svg,#adminmenu li.current div.wp-menu-image.svg{filter:brightness(.25)}#adminmenu li.current .wp-menu-name,#adminmenu li.current a,#adminmenu li.current div.wp-menu-image:before{color:#2271b1!important}#adminmenu div.wp-menu-name{color:#646970;font-size:15px;font-weight:600;padding:9px 0 8px 41px}#adminmenu li a:hover div.wp-menu-name{color:#2c3338}#adminmenu li.menu-top{min-height:46px}#adminmenu .awaiting-mod,#adminmenu .update-plugins{background-color:#2271b1}.no-js li.wp-has-current-submenu:hover .wp-submenu{background:transparent!important}#wpcontent,#wpfooter{margin-left:272px}#toplevel_page_plugin-install div.wp-menu-image.svg,#toplevel_page_plugins div.wp-menu-image.svg{background-size:24px auto}#toplevel_page_plugins div.wp-menu-image.svg{left:-2px;position:relative}#calypso-sidebar-header{background:#fff;border-bottom:1px solid #646970;height:65px;left:0;position:fixed;top:47px;width:272px;z-index:10000}#calypso-sidebar-header svg{float:left;left:10px;position:relative;top:23px}#calypso-sidebar-header ul{float:left;left:15px;position:relative}#calypso-sidebar-header ul li{margin:0}#calypso-sidebar-header ul li#calypso-sitename{color:#646970;font-size:12px;overflow:hidden;white-space:nowrap;width:225px}@media screen and (max-width:782px){#calypso-sidebar-header ul li#calypso-sitename{width:150px}}#calypso-sidebar-header ul li#calypso-sitename:after{-webkit-touch-callout:none;background:linear-gradient(90deg,hsla(0,0%,100%,0),#fff 90%);bottom:0;content:"";display:block;height:auto;left:auto;pointer-events:none;position:absolute;right:0;top:0;-webkit-user-select:none;user-select:none;width:20%}#calypso-sidebar-header ul li#calypso-plugins{color:#2c3338;font-size:16px;font-weight:700}.folded #adminmenu .opensub .wp-submenu,.folded #adminmenu .opensub .wp-submenu:after,.folded #adminmenu .wp-has-current-submenu .wp-submenu,.folded #adminmenu a.wp-has-current-submenu:focus+.wp-submenu{background:transparent!important}.folded #adminmenu li.menu-top .wp-submenu>li>a{font-size:14px;padding:7px 12px 7px 46px}.folded #adminmenu li.current.menu-top,.folded #adminmenu li.wp-has-current-submenu,.folded #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head{background:#e9eff5}.folded #adminmenu .wp-submenu .wp-submenu-head{padding:14px 4px 14px 11px}.folded #adminmenu a.menu-top{padding-left:1px}.folded #wpcontent #calypso-sidebar-header{width:36px}.folded #wpcontent #calypso-sidebar-header svg{left:6px}.folded #wpcontent #calypso-sidebar-header ul{display:none}.folded .no-js li.wp-has-current-submenu:hover .wp-submenu{background:#f6f7f7!important}.folded #toplevel_page_plugins div.wp-menu-image.svg{left:-2px;position:relative}@media only screen and (max-width:960px){#calypso-sidebar-header{width:36px}#calypso-sidebar-header ul{display:none}#calypso-sidebar-header svg{left:6px}#adminmenu a.menu-top{padding-left:1px}}@media screen and (max-width:782px){#calypso-sidebar-header{display:none;position:absolute;top:-14px;width:190px}#calypso-sidebar-header ul,.wp-responsive-open #calypso-sidebar-header{display:block}.auto-fold #adminmenu .wp-menu-name{margin-left:0}.auto-fold #adminmenu{top:-14px}#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.auto-fold #adminmenu .selected .wp-submenu,.auto-fold #adminmenu .wp-menu-open .wp-submenu{background:#fff!important}.auto-fold #adminmenu li.selected div.wp-menu-image.svg{filter:brightness(100)}.auto-fold #adminmenu li.selected div.wp-menu-image:before,.auto-fold #adminmenu li.selected div.wp-menu-name{color:#2271b1!important}#wpadminbar .quicklinks>ul>li>.ab-empty-item,#wpadminbar .quicklinks>ul>li>a{padding:0 15px!important}#wpadminbar li#wp-admin-bar-ab-new-post a{padding:7px 15px!important}}@media screen and (max-width:600px){#calypso-sidebar-header,.auto-fold #adminmenu{top:32px}}@media screen and (max-width:480px){#wpadminbar #wp-admin-bar-blog.my-sites>a.ab-item:before{margin-top:4px!important}#wpadminbar #wp-admin-bar-newdash>a.ab-item:before{margin-top:6px!important}#wpadminbar ul li#wp-admin-bar-ab-new-post a:before{margin-left:-12px!important;top:-5px!important}}.nav-tab-wrapper,.wrap h2.nav-tab-wrapper{background:#fff;border:1px solid rgba(200,215,225,.5);margin:10px 0 25px}.nav-tab{background:none;border:none;color:#2271b1;font-weight:400;padding:3px 13px 12px}.nav-tab-active,.nav-tab-active:focus,.nav-tab-active:focus:active,.nav-tab-active:hover{background:transparent;box-shadow:none}.nav-tab:first-child{margin-left:0}.nav-tab-active,.nav-tab-active:focus,.nav-tab-active:focus:active{border-bottom:2px solid #3c434a;color:#2c3338}#wpadminbar{background:#006088;border-bottom:1px solid #0a4b78;-webkit-box-shadow:none;-mozilla-box-shadow:none;height:46px;position:fixed}#wpadminbar .ab-top-menu>li>.ab-item{font-size:14px}#wpadminbar .ab-top-menu>li.hover>.ab-item{background:#004e6e!important;color:#fff}#wpadminbar *{line-height:46px}#wpadminbar .quicklinks .ab-empty-item,#wpadminbar .quicklinks a,#wpadminbar .shortlink-input{height:46px}#wpadminbar .quicklinks>ul>li>a{padding:0 15px}#wpadminbar .quicklinks>ul>li.current>a{background:#004966}#wpadminbar .ab-top-menu>li.ab-hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{background:transparent!important}#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item{background:#004e6e!important;color:#fff}#wpadminbar .ab-top-menu>li.my-sites.ab-hover>.ab-item,#wpadminbar .ab-top-menu>li.my-sites.hover>.ab-item,#wpadminbar .ab-top-menu>li.my-sites>.ab-item{background:#002c40!important}#wpadminbar #wp-admin-bar-blog.my-sites>a.ab-item:before,#wpadminbar #wp-admin-bar-newdash>a.ab-item:before{margin-top:13px}#wpadminbar #wp-admin-bar-blog.my-sites>a.ab-item:before{top:-2px!important}#wpadminbar ul li#wp-admin-bar-ab-new-post{border-radius:3px}#wpadminbar ul li#wp-admin-bar-ab-new-post a{color:#2271b1!important;padding:6px 15px}#wpadminbar ul li#wp-admin-bar-ab-new-post a span{color:#2271b1!important;font-size:14px!important;margin-left:6px;margin-right:4px}#wpadminbar ul li#wp-admin-bar-ab-new-post a:after,#wpadminbar ul li#wp-admin-bar-ab-new-post a:before{background-image:url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect x="0" fill="none" width="24" height="24"/><g><path fill="%230087be" d="M21 14v5c0 1.105-.895 2-2 2H5c-1.105 0-2-.895-2-2V5c0-1.105.895-2 2-2h5v2H5v14h14v-5h2z"/><path fill="%230087be" d="M21 7h-4V3h-2v4h-4v2h4v4h2V9h4"/></g></svg>')!important}#wpadminbar ul li#wp-admin-bar-ab-new-post a:before{margin-left:-6px}#wpadminbar ul li#wp-admin-bar-ab-new-post:hover,#wpadminbar ul li#wp-admin-bar-ab-new-post:hover>.ab-item{background:#f6f7f7!important;border-radius:3px!important;opacity:1}#wpadminbar li#wp-admin-bar-blog.menupop>.ab-sub-wrapper,#wpadminbar li#wp-admin-bar-my-account.menupop>.ab-sub-wrapper,#wpadminbar li#wp-admin-bar-newdash.menupop>.ab-sub-wrapper{display:none!important}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar{margin-left:9px;margin-right:-1px}#wpadminbar li#wp-admin-bar-notes.active,#wpadminbar li#wp-admin-bar-notes.active>.ab-item{background:#002c40!important}#wpadminbar li#wp-admin-bar-notes>#wpnt-notes-panel2{top:46px}#wpadminbar #wp-admin-bar-notes.wpnt-show .noticon,#wpadminbar .ab-top-menu>li.ab-active>.ab-item,#wpadminbar>#wp-toolbar .wpnt-show span.noticon{color:#fff!important}#wpadminbar #wp-admin-bar-notes.active .noticon-bell:before,#wpadminbar .ab-active>a.ab-item:before{filter:brightness(100)!important}#wpadminbar #wp-admin-bar-notes .noticon,#wpadminbar .quicklinks>ul>li#wp-admin-bar-notes>a.ab-item span.noticon,#wpadminbar>#wp-toolbar span.noticon{top:10px}#wpadminbar .ab-icon,#wpadminbar .ab-item:before,#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon{font-size:24px;line-height:1.45}#wpadminbar li#wp-admin-bar-recovery-mode{background-color:#b26200!important}body #wp-admin-bar-notes>.ab-item{padding:0 15px!important}#wpadminbar ul li#wp-admin-bar-ab-new-post{top:5px!important}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{display:none}.wrap{margin:20px 30px 25px 15px}@media screen and (max-width:782px){.wrap{margin:10px 18px 10px 7px}}.subsubsub,.wp-filter{background:#fff;border:1px solid rgba(200,215,225,.5);box-shadow:none;margin:10px 0 25px;padding:0;width:100%}.filter-links li>a,.subsubsub a{border-bottom:2px solid #fff;color:#2271b1;display:inline-block;font-size:14px;margin:0;outline:none;padding:10px 15px}.filter-links li>a:focus,.subsubsub a:focus{box-shadow:0 0 0 1px #2271b1,0 0 2px 1px #5198d9}.filter-links li>a:hover,.subsubsub a:hover{background-color:#e9eff5;color:#0a4b78}.filter-links li>a:hover:not(.current),.subsubsub a:hover:not(.current){border-color:#e9eff5}.filter-links li>a{padding:16px}.filter-links .current,.subsubsub a.current{border-bottom:2px solid #3c434a}@media only screen and (max-width:480px){.filter-links,.filter-links li,.filter-links li a{display:block}.filter-links li>a{font-size:16px}}.count{border:1px solid #8e9196;border-radius:12px;color:#646970;display:inline-block;font-size:11px;font-weight:700;line-height:14px;margin-left:2px;padding:1px 6px;text-align:center}.plugins-php .plugins a{color:#2271b1}.plugins-php .plugins a:focus,.plugins-php .plugins a:hover{color:#0a4b78}.plugins-php .plugins a:focus{box-shadow:0 0 0 1px #2271b1,0 0 2px 1px #5198d9}.plugins-php .plugins a.delete{color:#d63638}.plugins-php .plugins a.delete:focus,.plugins-php .plugins a.delete:hover{color:#8a2424}.plugins-php .plugins a.delete:focus{box-shadow:0 0 0 1px #d63638,0 0 2px 1px #f86368}.plugins-php .tablenav{clear:none;float:left;margin-bottom:15px}.plugins-php .tablenav .one-page .displaying-num{display:none}.plugins-php .bulkactions select:focus{border-color:#2271b1;box-shadow:0 0 2px #5198d9}.plugins-php p.search-box{margin-top:5px}.plugins-php p.search-box .wp-filter-search:focus{border-color:#2271b1;box-shadow:0 0 2px #5198d9}.plugins-php .plugin-update-tr.active td,.plugins-php .plugins .active th{border-left:4px solid #2271b1}.plugins-php .plugin-update-tr.active td,.plugins-php .plugins .active td,.plugins-php .plugins .active th,.plugins-php .plugins .active th.check-column{background-color:#e9eff5}.wrap .add-new-h2,.wrap .add-new-h2:active,.wrap .page-title-action,.wrap .page-title-action:active,.wrap .wp-heading-inline+.page-title-action{-webkit-appearance:none;appearance:none;background:#c9356e;border:solid #8c1749;border-radius:4px;border-width:1px 1px 2px;box-sizing:border-box;color:#fff;cursor:pointer;display:inline-block;font-size:13px;font-weight:500;line-height:21px;margin:0 5px 2px 0;outline:0;overflow:hidden;padding:2px 10px;text-decoration:none;text-overflow:ellipsis;vertical-align:middle}.wrap .add-new-h2:active:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:active:hover,.wrap .page-title-action:hover,.wrap .wp-heading-inline+.page-title-action:hover{background-color:#e34c84}.wrap .add-new-h2:active:focus,.wrap .add-new-h2:focus,.wrap .page-title-action:active:focus,.wrap .page-title-action:focus,.wrap .wp-heading-inline+.page-title-action:focus{background-color:#e34c84;box-shadow:0 0 0 2px #eb6594}.wp-core-ui .button{background:#fff}.wp-core-ui .button:focus{border-color:#2271b1;box-shadow:0 0 3px #5198d9}.wp-core-ui .button-primary{background:#2271b1;border-color:#0a4b78;color:#fff;text-shadow:none}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background-color:#3582c4}.ui-tabs-nav li,.wp-switch-editor{background-color:#f6f7f7!important}.filter-links>li>a,.plugin-card a,.popular-tags a{color:#2271b1}.filter-links>li>a:focus,.filter-links>li>a:hover,.plugin-card a:focus,.plugin-card a:hover,.popular-tags a:focus,.popular-tags a:hover{color:#0a4b78}.filter-links>li>a:focus,.plugin-card a:focus,.popular-tags a:focus{box-shadow:0 0 0 1px #2271b1,0 0 2px 1px #5198d9}#major-publishing-actions,#post-status-info,.alternate,.html-active .switch-html,.plugin-card-bottom,.quicktags-toolbar,.striped>tbody>:nth-child(odd),.tmce-active .switch-tmce,.ui-tabs-nav li.ui-tabs-active,.ui-tabs-nav li.ui-tabs-active:hover,.ui-tabs-panel,div.mce-toolbar-grp,ul.striped>:nth-child(odd){background-color:#fff;border-color:#d7e1e9}.wp-filter .search-form{margin-right:10px}@media only screen and (max-width:1000px){.wp-filter .search-form{margin-left:10px}}@media only screen and (max-width:782px){.wp-filter .search-form input[type=search].wp-filter-search{padding:5px}}@media only screen and (max-width:480px){.wp-filter .search-form.search-plugins{align-items:center;display:flex}.wp-filter .search-form.search-plugins .wp-filter-search{flex:0 1 auto;max-width:none;width:100%}.wp-filter .search-form select{flex-shrink:0}.wp-filter .search-form>label{flex:1 1 auto}}.form-toggle[type=checkbox]{display:none}.form-toggle__switch{align-self:flex-start;border-radius:12px;box-sizing:border-box;cursor:pointer;display:inline-block;height:24px;outline:0;padding:2px;position:relative;transition:all .4s ease,box-shadow 0s;vertical-align:middle;width:40px}.form-toggle__switch:after,.form-toggle__switch:before{content:"";display:block;height:20px;position:relative;width:20px}.form-toggle__switch:after{background:#fff;border-radius:50%;left:0;transition:all .2s ease}.form-toggle__switch:before{display:none}.accessible-focus .form-toggle__switch:focus{box-shadow:0 0 0 2px #2271b1}.form-toggle__label{cursor:pointer}.is-disabled .form-toggle__label{cursor:default}.form-toggle__label .form-toggle__label-content{flex:0 1 100%;margin-left:12px}.accessible-focus .form-toggle:focus+.form-toggle__label .form-toggle__switch{box-shadow:0 0 0 2px #2271b1}.accessible-focus .form-toggle:focus:checked+.form-toggle__label .form-toggle__switch{box-shadow:0 0 0 2px #5198d9}.form-toggle+.form-toggle__label .form-toggle__switch{background:#a7aaad}.form-toggle:not(:disabled)+.form-toggle__label:hover .form-toggle__switch{background:#c3c4c7}.form-toggle:checked+.form-toggle__label .form-toggle__switch{background:#2271b1}.form-toggle:checked+.form-toggle__label .form-toggle__switch:after{left:16px}.form-toggle:checked:not(:disabled)+.form-toggle__label:hover .form-toggle__switch{background:#5198d9}.form-toggle:disabled+label.form-toggle__label span.form-toggle__switch{cursor:default;opacity:.25}.form-toggle.is-toggling+.form-toggle__label .form-toggle__switch{background:#2271b1}.form-toggle.is-toggling:checked+.form-toggle__label .form-toggle__switch{background:#c3c4c7}.form-toggle.is-compact+.form-toggle__label .form-toggle__switch{border-radius:8px;height:16px;width:24px}.form-toggle.is-compact+.form-toggle__label .form-toggle__switch:after,.form-toggle.is-compact+.form-toggle__label .form-toggle__switch:before{height:12px;width:12px}.form-toggle.is-compact:checked+.form-toggle__label .form-toggle__switch:after{left:8px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/carousel.php b/plugins/jetpack/modules/carousel.php
index fda08752..bc9e672c 100644
--- a/plugins/jetpack/modules/carousel.php
+++ b/plugins/jetpack/modules/carousel.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Module Name: Carousel
* Module Description: Display images and galleries in a gorgeous, full-screen browsing experience
@@ -11,6 +10,11 @@
* Module Tags: Photos and Videos
* Feature: Appearance
* Additional Search Queries: gallery, carousel, diaporama, slideshow, images, lightbox, exif, metadata, image
+ *
+ * @package automattic/jetpack
*/
-include dirname( __FILE__ ) . '/carousel/jetpack-carousel.php';
+/**
+ * Require the jetpack-carousel module code
+ */
+require __DIR__ . '/carousel/jetpack-carousel.php';
diff --git a/plugins/jetpack/modules/carousel/images/arrows-2x.png b/plugins/jetpack/modules/carousel/images/arrows-2x.png
deleted file mode 100644
index 01214f2e..00000000
--- a/plugins/jetpack/modules/carousel/images/arrows-2x.png
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/carousel/images/arrows.png b/plugins/jetpack/modules/carousel/images/arrows.png
deleted file mode 100644
index 9251dce1..00000000
--- a/plugins/jetpack/modules/carousel/images/arrows.png
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/carousel/images/carousel-likereblog-2x.png b/plugins/jetpack/modules/carousel/images/carousel-likereblog-2x.png
deleted file mode 100644
index 1dd594fe..00000000
--- a/plugins/jetpack/modules/carousel/images/carousel-likereblog-2x.png
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/carousel/images/carousel-likereblog.png b/plugins/jetpack/modules/carousel/images/carousel-likereblog.png
deleted file mode 100644
index e4cd0596..00000000
--- a/plugins/jetpack/modules/carousel/images/carousel-likereblog.png
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/carousel/images/carousel-link-2x.png b/plugins/jetpack/modules/carousel/images/carousel-link-2x.png
deleted file mode 100644
index 9939ecba..00000000
--- a/plugins/jetpack/modules/carousel/images/carousel-link-2x.png
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/carousel/images/carousel-link.png b/plugins/jetpack/modules/carousel/images/carousel-link.png
deleted file mode 100644
index 225348db..00000000
--- a/plugins/jetpack/modules/carousel/images/carousel-link.png
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/carousel/images/carousel-sprite-2x.png b/plugins/jetpack/modules/carousel/images/carousel-sprite-2x.png
deleted file mode 100644
index 85d0e3f3..00000000
--- a/plugins/jetpack/modules/carousel/images/carousel-sprite-2x.png
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/carousel/images/carousel-sprite.png b/plugins/jetpack/modules/carousel/images/carousel-sprite.png
deleted file mode 100644
index 41ad9c8d..00000000
--- a/plugins/jetpack/modules/carousel/images/carousel-sprite.png
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/carousel/jetpack-carousel-rtl.css b/plugins/jetpack/modules/carousel/jetpack-carousel-rtl.css
index 75b412e6..5ec82d9a 100644
--- a/plugins/jetpack/modules/carousel/jetpack-carousel-rtl.css
+++ b/plugins/jetpack/modules/carousel/jetpack-carousel-rtl.css
@@ -1 +1 @@
-:root{--jp-carousel-primary-color:#fff;--jp-carousel-primary-subtle-color:#999;--jp-carousel-bg-color:#000;--jp-carousel-bg-faded-color:#222;--jp-carousel-border-color:#3a3a3a}:root .jp-carousel-light{--jp-carousel-primary-color:#000;--jp-carousel-primary-subtle-color:#646970;--jp-carousel-bg-color:#fff;--jp-carousel-bg-faded-color:#fbfbfb;--jp-carousel-border-color:#dcdcde}.jp-carousel-overlay .swiper-button-next,.jp-carousel-overlay .swiper-button-prev,.jp-carousel-overlay .swiper-container-rtl .swiper-button-next,.jp-carousel-overlay .swiper-container-rtl .swiper-button-prev{background-image:none}[data-carousel-extra]:not(.jp-carousel-wrap) img,[data-carousel-extra]:not(.jp-carousel-wrap) img+figcaption{cursor:pointer}.jp-carousel-wrap *{line-height:inherit}.jp-carousel-wrap.swiper-container{height:auto;width:100vw}.jp-carousel-overlay .swiper-zoom-container{background-size:200%;background-repeat:no-repeat;background-position:center}.jp-carousel-overlay .swiper-slide.swiper-slide-next .swiper-zoom-container img,.jp-carousel-overlay .swiper-slide.swiper-slide-prev .swiper-zoom-container img{transition:none!important}.jp-carousel-overlay .swiper-button-next,.jp-carousel-overlay .swiper-button-prev{opacity:.5;transition:.5s opacity ease-out;height:initial;width:initial;padding:20px 40px;background-image:none}.jp-carousel-overlay .swiper-button-next:hover,.jp-carousel-overlay .swiper-button-prev:hover{opacity:1}.jp-carousel-overlay .swiper-button-next:after,.jp-carousel-overlay .swiper-button-prev:after,.jp-carousel-overlay .swiper-container-rtl .swiper-button-next:after,.jp-carousel-overlay .swiper-container-rtl .swiper-button-prev:after{content:none}.jp-carousel-overlay .swiper-button-next svg,.jp-carousel-overlay .swiper-button-prev svg{height:30px;width:28px;background:var(--jp-carousel-bg-color);border-radius:4px}.jp-carousel-overlay{font-family:'Helvetica Neue',sans-serif!important;z-index:2147483647;overflow-x:hidden;overflow-y:auto;direction:rtl;position:fixed;top:0;left:0;bottom:0;right:0;background:var(--jp-carousel-bg-color)}.jp-carousel-overlay *{box-sizing:border-box}.jp-carousel-overlay h1:before,.jp-carousel-overlay h2:before,.jp-carousel-overlay h3:before{content:none;display:none}.jp-carousel-overlay .swiper-container .swiper-button-prev{right:0;left:auto}.jp-carousel-overlay .swiper-container .swiper-button-next{left:0;right:auto}.jp-carousel-overlay .swiper-container.swiper-container-rtl .swiper-button-next,.jp-carousel-overlay .swiper-container.swiper-container-rtl .swiper-button-prev{transform:scaleX(-1)}.jp-carousel-container{display:grid;grid-template-rows:1fr 64px;height:100%}.jp-carousel-hide-controls .jp-carousel-container{grid-template-rows:1fr}.jp-carousel-hide-controls .swiper-wrapper{margin-top:-32px}.jp-carousel-hide-controls .jp-swiper-button-next,.jp-carousel-hide-controls .jp-swiper-button-prev{margin-top:-54px}.jp-carousel-msg{font-family:'Open Sans',sans-serif;font-style:normal;display:inline-block;line-height:19px;padding:11px 15px;font-size:14px;text-align:center;margin:25px 2px 0 20px;background-color:var(--jp-carousel-primary-color);border-right:4px solid #ffba00;box-shadow:0 1px 1px 0 rgba(0,0,0,.1)}.jp-carousel-info{display:flex;flex-direction:column;text-align:right!important;-webkit-font-smoothing:subpixel-antialiased!important;z-index:100;background-color:var(--jp-carousel-bg-color);transition:opacity .2s ease-out;opacity:1}.jp-carousel-hide-controls .jp-carousel-info{visibility:hidden;height:0;overflow:hidden}.jp-carousel-info-footer{position:relative;background-color:var(--jp-carousel-bg-color);height:64px;display:flex;align-items:center;justify-content:space-between;width:100vw}.jp-carousel-info-extra{display:none;background-color:var(--jp-carousel-bg-color);padding:35px;width:100vw;border-top:1px solid var(--jp-carousel-bg-faded-color)}.jp-carousel-title-and-caption{margin-bottom:15px}.jp-carousel-info-extra.jp-carousel-show{display:block}.jp-carousel-info ::selection{background:var(--jp-carousel-primary-color);color:var(--jp-carousel-primary-color)}.jp-carousel-info ::-moz-selection{background:var(--jp-carousel-primary-color);color:var(--jp-carousel-primary-color)}.jp-carousel-photo-info{right:0!important;width:100%!important}.jp-carousel-comments-wrapper{padding:0;width:100%!important;display:none}.jp-carousel-comments-wrapper.jp-carousel-show{display:block}.jp-carousel-comments-wrapper>.jp-carousel-photo-info{display:none}.jp-carousel-transitions .jp-carousel-photo-info{transition:.4s ease-out}.jp-carousel-buttons{margin:-18px -20px 15px;padding:8px 10px;border-bottom:1px solid #222;background:#222;text-align:center}div.jp-carousel-buttons a{border:none!important;color:var(--jp-carousel-primary-subtle-color);font:normal 11px/1.2em 'Helvetica Neue',sans-serif!important;letter-spacing:0!important;padding:5px 0 5px 2px;text-decoration:none!important;text-shadow:none!important;vertical-align:middle;-webkit-font-smoothing:subpixel-antialiased}div.jp-carousel-buttons a:hover{color:var(--jp-carousel-primary-color);border:none!important}.jp-carousel-transitions div.jp-carousel-buttons a:hover{transition:none!important}.jp-carousel-slide,.jp-carousel-slide img{transform:translate3d(0,0,0)}.jp-carousel-close-hint{cursor:default;letter-spacing:0!important;position:fixed;top:20px;left:30px;padding:10px;text-align:left;width:45px;height:45px;z-index:15;color:var(--jp-carousel-primary-color);cursor:pointer;transition:opacity .2s ease-out}.jp-carousel-transitions .jp-carousel-close-hint{transition:color .2s linear}.jp-carousel-close-hint svg{padding:3px 2px;background:var(--jp-carousel-bg-color);border-radius:4px}.jp-carousel-close-hint:hover{color:var(--jp-carousel-primary-color)}.jp-carousel-close-hint:hover span{border-color:var(--jp-carousel-primary-color)}.jp-carousel-pagination-container{flex:1;margin:0 35px 0 15px}.jp-carousel-pagination,.jp-swiper-pagination{color:var(--jp-carousel-primary-color);font-size:15px;font-weight:400;white-space:nowrap;display:none;position:static!important}.jp-carousel-pagination-container .swiper-pagination{text-align:right;line-height:8px}.jp-carousel-pagination{padding-right:5px}.jp-swiper-pagination .swiper-pagination-bullet{background:var(--jp-carousel-primary-subtle-color);margin:0 9px}.jp-swiper-pagination .swiper-pagination-bullet.swiper-pagination-bullet-active{background:var(--jp-carousel-primary-color)}.jp-swiper-pagination .swiper-pagination-bullet:not(.swiper-pagination-bullet-active){background:var(--jp-carousel-primary-color);opacity:.5}.jp-carousel-info-footer .jp-carousel-photo-title-container{flex-basis:50vw;flex:4;justify-content:center;overflow:hidden;margin:0}.jp-carousel-photo-caption,.jp-carousel-photo-title{background:100% 0!important;border:none!important;display:inline-block;font:normal 20px/1.3em 'Helvetica Neue',sans-serif;line-height:normal;letter-spacing:0!important;margin:0 0 10px 0;padding:0;overflow:hidden;text-shadow:none!important;text-transform:none!important;color:var(--jp-carousel-primary-color)}.jp-carousel-info-footer .jp-carousel-photo-caption{text-align:center;font-size:15px;white-space:nowrap;color:var(--jp-carousel-primary-subtle-color);cursor:pointer;margin:0;text-overflow:ellipsis}.jp-carousel-info-footer .jp-carousel-photo-caption p{margin:0}.jp-carousel-photo-title{font-size:32px;margin-bottom:2px}.jp-carousel-photo-description{color:var(--jp-carousel-primary-subtle-color);font-size:16px;margin:25px 0;width:100%}.jp-carousel-photo-description{overflow:hidden;overflow-wrap:break-word}.jp-carousel-photo-description p{color:var(--jp-carousel-primary-subtle-color);line-height:1.4;margin-bottom:0}.jp-carousel-comments p a,.jp-carousel-info h2 a,.jp-carousel-photo-description p a{color:var(--jp-carousel-primary-color)!important;border:none!important;text-decoration:underline!important;font-weight:400!important;font-style:normal!important}.jp-carousel-photo-description p b,.jp-carousel-photo-description p strong{font-weight:700;color:var(--jp-carousel-primary-subtle-color)}.jp-carousel-photo-description p em,.jp-carousel-photo-description p i{font-style:italic;color:var(--jp-carousel-primary-subtle-color)}.jp-carousel-comments p a:hover,.jp-carousel-info h2 a:hover,.jp-carousel-photo-description p a:hover{color:var(--jp-carousel-primary-subtle-color)!important}.jp-carousel-photo-description p:empty{display:none}.jp-carousel-comments-wrapper h1:after,.jp-carousel-comments-wrapper h1:before,.jp-carousel-photo-info h1:after,.jp-carousel-photo-info h1:before{content:none!important}.jp-carousel-caption{font-size:14px;font-weight:400;margin:0}.jp-carousel-image-meta{color:var(--jp-carousel-primary-color);font-size:13px;font:12px/1.4 'Helvetica Neue',sans-serif!important;width:100%;display:none}.jp-carousel-image-meta.jp-carousel-show{display:block}.jp-carousel-image-meta h5,.jp-carousel-image-meta li{font-family:'Helvetica Neue',sans-serif!important;position:inherit!important;top:auto!important;left:auto!important;right:auto!important;bottom:auto!important;background:100% 0!important;border:none!important;font-weight:400!important;line-height:1.3em!important}.jp-carousel-image-meta ul{margin:0!important;padding:0!important;list-style:none!important}.jp-carousel-image-meta li{width:48%!important;display:inline-block!important;vertical-align:top!important;margin:0 0 15px 2%!important;color:var(--jp-carousel-primary-color)!important;font-size:13px!important}.jp-carousel-image-meta h5{color:var(--jp-carousel-primary-subtle-color)!important;text-transform:uppercase!important;font-size:10px!important;margin:0 0 2px!important;letter-spacing:.1em!important}a.jp-carousel-image-download{display:inline-block;clear:both;color:var(--jp-carousel-primary-subtle-color);line-height:1;font-weight:400;font-size:14px;text-decoration:none}a.jp-carousel-image-download svg{display:inline-block;vertical-align:middle;margin:0 3px;padding-bottom:2px}a.jp-carousel-image-download span.photo-size{font-size:11px;border-radius:1em;margin-right:2px;display:inline-block}a.jp-carousel-image-download span.photo-size-times{padding:0 2px 0 1px}.jp-carousel-comments{font:15px/1.7 'Helvetica Neue',sans-serif!important;font-weight:400;background:none transparent;width:100%;bottom:10px;margin-top:20px}.jp-carousel-comments p a:active,.jp-carousel-comments p a:focus,.jp-carousel-comments p a:hover{color:var(--jp-carousel-primary-color)!important}.jp-carousel-comment{background:none transparent;color:var(--jp-carousel-primary-subtle-color);overflow:auto;width:100%;display:flex}.jp-carousel-comment+.jp-carousel-comment{margin-top:20px}.jp-carousel-comment:last-of-type{margin-bottom:20px}.jp-carousel-comment p{color:var(--jp-carousel-primary-subtle-color)!important}.jp-carousel-comment .comment-author{font-size:15px;font-weight:500;padding:0;width:auto;display:inline;float:none;border:none;margin:0}.jp-carousel-comment .comment-author a{color:var(--jp-carousel-primary-color)}.jp-carousel-comment .comment-gravatar{float:none;margin-left:10px}.jp-carousel-comment .comment-content{border:none;padding:0}.jp-carousel-comment .avatar{margin:0;border-radius:4px;border:none!important;padding:0!important;background-color:transparent!important;min-width:64px;min-height:64px;width:64px;height:64px}.jp-carousel-comment .comment-date{color:var(--jp-carousel-primary-subtle-color);font-size:11px;border-bottom:1px solid var(--jp-carousel-bg-faded-color);margin-bottom:6px}#jp-carousel-comment-form{margin:0 0 10px!important;width:100%}#jp-carousel-comment-form.jp-carousel-is-disabled{opacity:.5;pointer-events:none}textarea#jp-carousel-comment-form-comment-field{background:var(--jp-carousel-bg-faded-color);border:1px solid var(--jp-carousel-border-color);color:var(--jp-carousel-primary-subtle-color);font:16px/1.4 'Helvetica Neue',sans-serif!important;width:100%;padding:10px 10px 5px;margin:0;float:none;height:147px;box-shadow:inset -2px 2px 2px rgba(0,0,0,.1);border-radius:3px;overflow:hidden;box-sizing:border-box}textarea#jp-carousel-comment-form-comment-field::-webkit-input-placeholder{color:#555}textarea#jp-carousel-comment-form-comment-field:focus{background:var(--jp-carousel-bg-faded-color);color:var(--jp-carousel-primary-subtle-color)}textarea#jp-carousel-comment-form-comment-field:focus::-webkit-input-placeholder{color:var(--jp-carousel-primary-subtle-color)}#jp-carousel-loading-overlay{display:none;position:fixed;top:0;bottom:0;right:0;left:0}#jp-carousel-loading-wrapper{display:flex;align-items:center;justify-content:center;height:100vh;width:100vw}#jp-carousel-library-loading,#jp-carousel-library-loading:after{border-radius:50%;width:40px;height:40px}#jp-carousel-library-loading{float:right;margin:22px 10px 0 0;font-size:10px;position:relative;text-indent:-9999em;border-top:8px solid rgba(255,255,255,.2);border-left:8px solid rgba(255,255,255,.2);border-bottom:8px solid rgba(255,255,255,.2);border-right:8px solid var(--jp-carousel-primary-color);transform:translateZ(0);animation:load8 1.1s infinite linear}#jp-carousel-comment-form-spinner,#jp-carousel-comment-form-spinner:after{border-radius:50%;width:20px;height:20px}#jp-carousel-comment-form-spinner{display:none;float:right;margin:22px 10px 0 0;font-size:10px;position:absolute;text-indent:-9999em;border-top:4px solid rgba(255,255,255,.2);border-left:4px solid rgba(255,255,255,.2);border-bottom:4px solid rgba(255,255,255,.2);border-right:4px solid var(--jp-carousel-primary-color);transform:translateZ(0);animation:load8 1.1s infinite linear;margin:0 auto;top:calc(50% - 15px);right:0;bottom:0;left:0}@keyframes load8{0%{transform:rotate(0)}100%{transform:rotate(-360deg)}}.jp-carousel-info-content-wrapper{max-width:800px;margin:auto}#jp-carousel-comment-form-submit-and-info-wrapper{display:none;overflow:hidden;width:100%}#jp-carousel-comment-form-commenting-as input{background:var(--jp-carousel-bg-color);border:1px solid var(--jp-carousel-border-color);color:var(--jp-carousel-primary-subtle-color);font:16px/1.4 'Helvetica Neue',sans-serif!important;padding:10px;float:right;box-shadow:inset -2px 2px 2px rgba(0,0,0,.2);border-radius:2px;width:285px}#jp-carousel-comment-form-commenting-as input:focus{background:var(--jp-carousel-bg-faded-color);color:var(--jp-carousel-primary-subtle-color)}#jp-carousel-comment-form-commenting-as p{font:400 13px/1.7 'Helvetica Neue',sans-serif!important;margin:22px 0 0;float:right}#jp-carousel-comment-form-commenting-as fieldset{float:right;border:none;margin:20px 0 0 0;padding:0;clear:both}#jp-carousel-comment-form-commenting-as label{font:400 13px/1.7 'Helvetica Neue',sans-serif!important;margin:0 0 3px 20px;float:right;width:100px}#jp-carousel-comment-form-button-submit{margin-top:20px;margin-right:auto;display:block;border:solid 1px var(--jp-carousel-primary-color);background:var(--jp-carousel-bg-color);border-radius:3px;padding:8px 16px;font-size:14px;color:var(--jp-carousel-primary-color)}#jp-carousel-comment-form-button-submit:active,#jp-carousel-comment-form-button-submit:focus{background:var(--jp-carousel-primary-color);color:var(--jp-carousel-bg-color)}#jp-carousel-comment-form-container{margin-bottom:15px;width:100%;margin-top:20px;color:var(--jp-carousel-primary-subtle-color);position:relative;overflow:hidden}#jp-carousel-comment-post-results{display:none;overflow:auto;width:100%}#jp-carousel-comment-post-results span{display:block;text-align:center;margin-top:20px;width:100%;overflow:auto;padding:1em 0;box-sizing:border-box;border-radius:2px;font:13px/1.4 'Helvetica Neue',sans-serif!important;border:1px solid var(--jp-carousel-border-color);box-shadow:inset 0 0 5px 0 rgba(0,0,0,.2)}.jp-carousel-comment-post-error{color:#df4926}#jp-carousel-comments-closed{display:none;color:var(--jp-carousel-primary-subtle-color)}#jp-carousel-comments-loading{font:400 15px/1.7 'Helvetica Neue',sans-serif!important;display:none;color:var(--jp-carousel-primary-subtle-color);text-align:right;margin-bottom:20px;width:100%;bottom:10px;margin-top:20px}.jp-carousel-photo-icons-container{flex:1;display:block;text-align:left;margin:0 30px 0 20px;white-space:nowrap}.jp-carousel-icon-btn{padding:16px;text-decoration:none;border:none;background:100% 0;display:inline-block;height:64px}.jp-carousel-icon{border:none;pointer-events:none;display:inline-block;line-height:0;font-weight:400;font-style:normal;border-radius:4px;width:31px;padding:4px 3px 3px}.jp-carousel-icon svg{display:inline-block}.jp-carousel-overlay rect{fill:var(--jp-carousel-primary-color)}.jp-carousel-selected .jp-carousel-icon{background:var(--jp-carousel-primary-color)}.jp-carousel-selected rect{fill:var(--jp-carousel-bg-color)}.jp-carousel-icon-comments.jp-carousel-show{display:inline-block}.jp-carousel-icon .jp-carousel-has-comments-indicator{display:none;font-size:12px;vertical-align:top;margin-right:-16px;line-height:1;padding:2px 4px;border-radius:4px;background:var(--jp-carousel-primary-color);color:var(--jp-carousel-bg-color);font-weight:400;font-family:'Helvetica Neue',sans-serif!important;position:relative}.jp-carousel-selected .jp-carousel-icon .jp-carousel-has-comments-indicator{background:var(--jp-carousel-bg-color);color:var(--jp-carousel-primary-color)}.jp-carousel-has-comments-indicator.jp-carousel-show{display:inline-block}@media only screen and (max-width:760px){.jp-carousel-overlay .swiper-container .swiper-button-next,.jp-carousel-overlay .swiper-container .swiper-button-prev{display:none!important}.jp-carousel-buttons{display:none!important}.jp-carousel-image-meta{float:none!important;width:100%!important;box-sizing:border-box;margin-right:0}.jp-carousel-close-hint{font-size:26px!important;position:fixed!important;top:10px;left:10px}.admin-bar .jp-carousel-close-hint{top:40px}.jp-carousel-slide img{opacity:1}.jp-carousel-wrap{background-color:var(--jp-carousel-bg-color)}.jp-carousel-fadeaway{display:none}.jp-carousel-info>.jp-carousel-photo-info{display:none}.jp-carousel-comments-wrapper>.jp-carousel-photo-info{display:block}.jp-carousel-caption{overflow:visible!important}.jp-carousel-info-footer .jp-carousel-photo-title-container{display:none}.jp-carousel-photo-icons-container{margin:0 0 0 10px;white-space:nowrap}.jp-carousel-icon-btn{padding-right:20px}.jp-carousel-pagination{padding-right:5px}.jp-carousel-pagination-container{margin-right:25px}.jp-carousel-comment .avatar{min-width:48px}#jp-carousel-comment-form-commenting-as fieldset,#jp-carousel-comment-form-commenting-as input{width:100%;float:none}} \ No newline at end of file
+:root{--jp-carousel-primary-color:#fff;--jp-carousel-primary-subtle-color:#999;--jp-carousel-bg-color:#000;--jp-carousel-bg-faded-color:#222;--jp-carousel-border-color:#3a3a3a}:root .jp-carousel-light{--jp-carousel-primary-color:#000;--jp-carousel-primary-subtle-color:#646970;--jp-carousel-bg-color:#fff;--jp-carousel-bg-faded-color:#fbfbfb;--jp-carousel-border-color:#dcdcde}.jp-carousel-overlay .swiper-button-next,.jp-carousel-overlay .swiper-button-prev,.jp-carousel-overlay .swiper-container-rtl .swiper-button-next,.jp-carousel-overlay .swiper-container-rtl .swiper-button-prev{background-image:none}[data-carousel-extra]:not(.jp-carousel-wrap) img,[data-carousel-extra]:not(.jp-carousel-wrap) img+figcaption{cursor:pointer}.jp-carousel-wrap *{line-height:inherit}.jp-carousel-wrap.swiper-container{height:auto;width:100vw}.jp-carousel-overlay .swiper-zoom-container{background-position:50%;background-repeat:no-repeat;background-size:200%}.jp-carousel-overlay .swiper-slide.swiper-slide-next .swiper-zoom-container img,.jp-carousel-overlay .swiper-slide.swiper-slide-prev .swiper-zoom-container img{transition:none!important}.jp-carousel-overlay .swiper-button-next,.jp-carousel-overlay .swiper-button-prev{background-image:none;height:auto;opacity:.5;padding:20px 40px;transition:opacity .5s ease-out;width:auto}.jp-carousel-overlay .swiper-button-next:hover,.jp-carousel-overlay .swiper-button-prev:hover{opacity:1}.jp-carousel-overlay .swiper-button-next:after,.jp-carousel-overlay .swiper-button-prev:after,.jp-carousel-overlay .swiper-container-rtl .swiper-button-next:after,.jp-carousel-overlay .swiper-container-rtl .swiper-button-prev:after{content:none}.jp-carousel-overlay .swiper-button-next svg,.jp-carousel-overlay .swiper-button-prev svg{background:var(--jp-carousel-bg-color);border-radius:4px;height:30px;width:28px}.jp-carousel-overlay{background:var(--jp-carousel-bg-color);bottom:0;direction:rtl;font-family:Helvetica Neue,sans-serif!important;left:0;overflow-x:hidden;overflow-y:auto;position:fixed;right:0;top:0;z-index:2147483647}.jp-carousel-overlay *{box-sizing:border-box}.jp-carousel-overlay h1:before,.jp-carousel-overlay h2:before,.jp-carousel-overlay h3:before{content:none;display:none}.jp-carousel-overlay .swiper-container .swiper-button-prev{left:auto;right:0}.jp-carousel-overlay .swiper-container .swiper-button-next{left:0;right:auto}.jp-carousel-overlay .swiper-container.swiper-container-rtl .swiper-button-next,.jp-carousel-overlay .swiper-container.swiper-container-rtl .swiper-button-prev{transform:scaleX(-1)}.jp-carousel-container{display:grid;grid-template-rows:1fr 64px;height:100%}.jp-carousel-hide-controls .jp-carousel-container{grid-template-rows:1fr}.jp-carousel-hide-controls .swiper-wrapper{margin-top:-32px}.jp-carousel-hide-controls .jp-swiper-button-next,.jp-carousel-hide-controls .jp-swiper-button-prev{margin-top:-54px}.jp-carousel-msg{background-color:var(--jp-carousel-primary-color);border-right:4px solid #ffba00;box-shadow:0 1px 1px 0 rgba(0,0,0,.1);display:inline-block;font-family:Open Sans,sans-serif;font-size:14px;font-style:normal;line-height:19px;margin:25px 2px 0 20px;padding:11px 15px;text-align:center}.jp-carousel-info{-webkit-font-smoothing:subpixel-antialiased!important;background-color:var(--jp-carousel-bg-color);display:flex;flex-direction:column;opacity:1;text-align:right!important;transition:opacity .2s ease-out;z-index:100}.jp-carousel-hide-controls .jp-carousel-info{height:0;overflow:hidden;visibility:hidden}.jp-carousel-info-footer{align-items:center;display:flex;height:64px;justify-content:space-between;position:relative}.jp-carousel-info-extra,.jp-carousel-info-footer{background-color:var(--jp-carousel-bg-color);width:100vw}.jp-carousel-info-extra{border-top:1px solid var(--jp-carousel-bg-faded-color);display:none;padding:35px}.jp-carousel-title-and-caption{margin-bottom:15px}.jp-carousel-info-extra.jp-carousel-show{display:block}.jp-carousel-info ::selection{background:var(--jp-carousel-primary-color);color:var(--jp-carousel-primary-color)}.jp-carousel-info ::-moz-selection{background:var(--jp-carousel-primary-color);color:var(--jp-carousel-primary-color)}.jp-carousel-photo-info{right:0!important;width:100%!important}.jp-carousel-comments-wrapper{display:none;padding:0;width:100%!important}.jp-carousel-comments-wrapper.jp-carousel-show{display:block}.jp-carousel-comments-wrapper>.jp-carousel-photo-info{display:none}.jp-carousel-transitions .jp-carousel-photo-info{transition:.4s ease-out}.jp-carousel-buttons{background:#222;border-bottom:1px solid #222;margin:-18px -20px 15px;padding:8px 10px;text-align:center}div.jp-carousel-buttons a{-webkit-font-smoothing:subpixel-antialiased;border:none!important;color:var(--jp-carousel-primary-subtle-color);font:normal 11px/1.2em Helvetica Neue,sans-serif!important;letter-spacing:0!important;padding:5px 0 5px 2px;text-decoration:none!important;text-shadow:none!important;vertical-align:middle}div.jp-carousel-buttons a:hover{border:none!important;color:var(--jp-carousel-primary-color)}.jp-carousel-transitions div.jp-carousel-buttons a:hover{transition:none!important}.jp-carousel-slide,.jp-carousel-slide img{transform:translateZ(0)}.jp-carousel-close-hint{color:var(--jp-carousel-primary-color);cursor:default;cursor:pointer;height:45px;left:30px;letter-spacing:0!important;padding:10px;position:fixed;text-align:left;top:20px;transition:opacity .2s ease-out;width:45px;z-index:15}.jp-carousel-transitions .jp-carousel-close-hint{transition:color .2s linear}.jp-carousel-close-hint svg{background:var(--jp-carousel-bg-color);border-radius:4px;padding:3px 2px}.jp-carousel-close-hint:hover{color:var(--jp-carousel-primary-color)}.jp-carousel-close-hint:hover span{border-color:var(--jp-carousel-primary-color)}.jp-carousel-pagination-container{flex:1;margin:0 35px 0 15px}.jp-carousel-pagination,.jp-swiper-pagination{color:var(--jp-carousel-primary-color);display:none;font-size:15px;font-weight:400;position:static!important;white-space:nowrap}.jp-carousel-pagination-container .swiper-pagination{line-height:8px;text-align:right}.jp-carousel-pagination{padding-right:5px}.jp-swiper-pagination .swiper-pagination-bullet{background:var(--jp-carousel-primary-subtle-color);margin:0 9px}.jp-swiper-pagination .swiper-pagination-bullet.swiper-pagination-bullet-active{background:var(--jp-carousel-primary-color)}.jp-swiper-pagination .swiper-pagination-bullet:not(.swiper-pagination-bullet-active){background:var(--jp-carousel-primary-color);opacity:.5}.jp-carousel-info-footer .jp-carousel-photo-title-container{flex-basis:50vw;flex:4;justify-content:center;margin:0;overflow:hidden}.jp-carousel-photo-caption,.jp-carousel-photo-title{background:none!important;border:none!important;color:var(--jp-carousel-primary-color);display:inline-block;font:normal 20px/1.3em Helvetica Neue,sans-serif;letter-spacing:0!important;line-height:normal;margin:0 0 10px;overflow:hidden;padding:0;text-shadow:none!important;text-transform:none!important}.jp-carousel-info-footer .jp-carousel-photo-caption{color:var(--jp-carousel-primary-subtle-color);cursor:pointer;font-size:15px;margin:0;text-align:center;text-overflow:ellipsis;white-space:nowrap}.jp-carousel-info-footer .jp-carousel-photo-caption p{margin:0}.jp-carousel-photo-title{font-size:32px;margin-bottom:2px}.jp-carousel-photo-description{color:var(--jp-carousel-primary-subtle-color);font-size:16px;margin:25px 0;overflow:hidden;overflow-wrap:break-word;width:100%}.jp-carousel-photo-description p{color:var(--jp-carousel-primary-subtle-color);line-height:1.4;margin-bottom:0}.jp-carousel-comments p a,.jp-carousel-info h2 a,.jp-carousel-photo-description p a{border:none!important;color:var(--jp-carousel-primary-color)!important;font-style:normal!important;font-weight:400!important;text-decoration:underline!important}.jp-carousel-photo-description p b,.jp-carousel-photo-description p strong{color:var(--jp-carousel-primary-subtle-color);font-weight:700}.jp-carousel-photo-description p em,.jp-carousel-photo-description p i{color:var(--jp-carousel-primary-subtle-color);font-style:italic}.jp-carousel-comments p a:hover,.jp-carousel-info h2 a:hover,.jp-carousel-photo-description p a:hover{color:var(--jp-carousel-primary-subtle-color)!important}.jp-carousel-photo-description p:empty{display:none}.jp-carousel-comments-wrapper h1:after,.jp-carousel-comments-wrapper h1:before,.jp-carousel-photo-info h1:after,.jp-carousel-photo-info h1:before{content:none!important}.jp-carousel-caption{font-size:14px;font-weight:400;margin:0}.jp-carousel-image-meta{color:var(--jp-carousel-primary-color);display:none;font-size:13px;font:12px/1.4 Helvetica Neue,sans-serif!important;width:100%}.jp-carousel-image-meta.jp-carousel-show{display:block}.jp-carousel-image-meta h5,.jp-carousel-image-meta li{background:none!important;border:none!important;bottom:auto!important;font-family:Helvetica Neue,sans-serif!important;font-weight:400!important;left:auto!important;line-height:1.3em!important;position:inherit!important;right:auto!important;top:auto!important}.jp-carousel-image-meta ul{list-style:none!important;margin:0!important;padding:0!important}.jp-carousel-image-meta li{color:var(--jp-carousel-primary-color)!important;display:inline-block!important;font-size:13px!important;margin:0 0 15px 2%!important;vertical-align:top!important;width:48%!important}.jp-carousel-image-meta h5{color:var(--jp-carousel-primary-subtle-color)!important;font-size:10px!important;letter-spacing:.1em!important;margin:0 0 2px!important;text-transform:uppercase!important}a.jp-carousel-image-download{clear:both;color:var(--jp-carousel-primary-subtle-color);display:inline-block;font-size:14px;font-weight:400;line-height:1;text-decoration:none}a.jp-carousel-image-download svg{display:inline-block;margin:0 3px;padding-bottom:2px;vertical-align:middle}a.jp-carousel-image-download span.photo-size{border-radius:1em;display:inline-block;font-size:11px;margin-right:2px}a.jp-carousel-image-download span.photo-size-times{padding:0 2px 0 1px}.jp-carousel-comments{background:none transparent;bottom:10px;font:15px/1.7 Helvetica Neue,sans-serif!important;font-weight:400;margin-top:20px;width:100%}.jp-carousel-comments p a:active,.jp-carousel-comments p a:focus,.jp-carousel-comments p a:hover{color:var(--jp-carousel-primary-color)!important}.jp-carousel-comment{background:none transparent;color:var(--jp-carousel-primary-subtle-color);display:flex;overflow:auto;width:100%}.jp-carousel-comment+.jp-carousel-comment{margin-top:20px}.jp-carousel-comment:last-of-type{margin-bottom:20px}.jp-carousel-comment p{color:var(--jp-carousel-primary-subtle-color)!important}.jp-carousel-comment .comment-author{border:none;display:inline;float:none;font-size:15px;font-weight:500;margin:0;padding:0;width:auto}.jp-carousel-comment .comment-author a{color:var(--jp-carousel-primary-color)}.jp-carousel-comment .comment-gravatar{float:none;margin-left:10px}.jp-carousel-comment .comment-content{border:none;padding:0}.jp-carousel-comment .avatar{background-color:transparent!important;border:none!important;border-radius:4px;height:64px;margin:0;min-height:64px;min-width:64px;padding:0!important;width:64px}.jp-carousel-comment .comment-date{border-bottom:1px solid var(--jp-carousel-bg-faded-color);color:var(--jp-carousel-primary-subtle-color);font-size:11px;margin-bottom:6px}#jp-carousel-comment-form{margin:0 0 10px!important;width:100%}#jp-carousel-comment-form.jp-carousel-is-disabled{opacity:.5;pointer-events:none}textarea#jp-carousel-comment-form-comment-field{background:var(--jp-carousel-bg-faded-color);border:1px solid var(--jp-carousel-border-color);border-radius:3px;box-shadow:inset -2px 2px 2px rgba(0,0,0,.1);box-sizing:border-box;color:var(--jp-carousel-primary-subtle-color);float:none;font:16px/1.4 Helvetica Neue,sans-serif!important;height:147px;margin:0;overflow:hidden;padding:10px 10px 5px;width:100%}textarea#jp-carousel-comment-form-comment-field::-webkit-input-placeholder{color:#555}textarea#jp-carousel-comment-form-comment-field:focus{background:var(--jp-carousel-bg-faded-color);color:var(--jp-carousel-primary-subtle-color)}textarea#jp-carousel-comment-form-comment-field:focus::-webkit-input-placeholder{color:var(--jp-carousel-primary-subtle-color)}#jp-carousel-loading-overlay{bottom:0;display:none;left:0;position:fixed;right:0;top:0}#jp-carousel-loading-wrapper{align-items:center;display:flex;height:100vh;justify-content:center;width:100vw}#jp-carousel-library-loading,#jp-carousel-library-loading:after{border-radius:50%;height:40px;width:40px}#jp-carousel-library-loading{animation:load8 1.1s linear infinite;border:8px solid hsla(0,0%,100%,.2);border-right:8px solid var(--jp-carousel-primary-color);float:right;font-size:10px;margin:22px 10px 0 0;position:relative;text-indent:-9999em;transform:translateZ(0)}#jp-carousel-comment-form-spinner,#jp-carousel-comment-form-spinner:after{border-radius:50%;height:20px;width:20px}#jp-carousel-comment-form-spinner{animation:load8 1.1s linear infinite;border:4px solid hsla(0,0%,100%,.2);border-right:4px solid var(--jp-carousel-primary-color);bottom:0;display:none;float:right;font-size:10px;left:0;margin:0 auto;position:absolute;right:0;text-indent:-9999em;top:calc(50% - 15px);transform:translateZ(0)}@keyframes load8{0%{transform:rotate(0deg)}to{transform:rotate(-1turn)}}.jp-carousel-info-content-wrapper{margin:auto;max-width:800px}#jp-carousel-comment-form-submit-and-info-wrapper{display:none;overflow:hidden;width:100%}#jp-carousel-comment-form-commenting-as input{background:var(--jp-carousel-bg-color);border:1px solid var(--jp-carousel-border-color);border-radius:2px;box-shadow:inset -2px 2px 2px rgba(0,0,0,.2);color:var(--jp-carousel-primary-subtle-color);float:right;font:16px/1.4 Helvetica Neue,sans-serif!important;padding:10px;width:285px}#jp-carousel-comment-form-commenting-as input:focus{background:var(--jp-carousel-bg-faded-color);color:var(--jp-carousel-primary-subtle-color)}#jp-carousel-comment-form-commenting-as p{float:right;font:400 13px/1.7 Helvetica Neue,sans-serif!important;margin:22px 0 0}#jp-carousel-comment-form-commenting-as fieldset{border:none;clear:both;float:right;margin:20px 0 0;padding:0}#jp-carousel-comment-form-commenting-as label{float:right;font:400 13px/1.7 Helvetica Neue,sans-serif!important;margin:0 0 3px 20px;width:100px}#jp-carousel-comment-form-button-submit{background:var(--jp-carousel-bg-color);border:1px solid var(--jp-carousel-primary-color);border-radius:3px;color:var(--jp-carousel-primary-color);display:block;font-size:14px;margin-right:auto;margin-top:20px;padding:8px 16px}#jp-carousel-comment-form-button-submit:active,#jp-carousel-comment-form-button-submit:focus{background:var(--jp-carousel-primary-color);color:var(--jp-carousel-bg-color)}#jp-carousel-comment-form-container{color:var(--jp-carousel-primary-subtle-color);margin-bottom:15px;margin-top:20px;overflow:hidden;position:relative;width:100%}#jp-carousel-comment-post-results{display:none;overflow:auto;width:100%}#jp-carousel-comment-post-results span{border:1px solid var(--jp-carousel-border-color);border-radius:2px;box-shadow:inset 0 0 5px 0 rgba(0,0,0,.2);box-sizing:border-box;display:block;font:13px/1.4 Helvetica Neue,sans-serif!important;margin-top:20px;overflow:auto;padding:1em 0;text-align:center;width:100%}.jp-carousel-comment-post-error{color:#df4926}#jp-carousel-comments-closed,#jp-carousel-comments-loading{color:var(--jp-carousel-primary-subtle-color);display:none}#jp-carousel-comments-loading{bottom:10px;font:400 15px/1.7 Helvetica Neue,sans-serif!important;margin-bottom:20px;margin-top:20px;text-align:right;width:100%}.jp-carousel-photo-icons-container{display:block;flex:1;margin:0 30px 0 20px;text-align:left;white-space:nowrap}.jp-carousel-icon-btn{background:none;border:none;display:inline-block;height:64px;padding:16px;text-decoration:none}.jp-carousel-icon{border:none;border-radius:4px;font-style:normal;font-weight:400;line-height:0;padding:4px 3px 3px;pointer-events:none;width:31px}.jp-carousel-icon,.jp-carousel-icon svg{display:inline-block}.jp-carousel-overlay rect{fill:var(--jp-carousel-primary-color)}.jp-carousel-selected .jp-carousel-icon{background:var(--jp-carousel-primary-color)}.jp-carousel-selected rect{fill:var(--jp-carousel-bg-color)}.jp-carousel-icon-comments.jp-carousel-show{display:inline-block}.jp-carousel-icon .jp-carousel-has-comments-indicator{background:var(--jp-carousel-primary-color);border-radius:4px;color:var(--jp-carousel-bg-color);display:none;font-family:Helvetica Neue,sans-serif!important;font-size:12px;font-weight:400;line-height:1;margin-right:-16px;padding:2px 4px;position:relative;vertical-align:top}.jp-carousel-selected .jp-carousel-icon .jp-carousel-has-comments-indicator{background:var(--jp-carousel-bg-color);color:var(--jp-carousel-primary-color)}.jp-carousel-has-comments-indicator.jp-carousel-show{display:inline-block}@media only screen and (max-width:760px){.jp-carousel-buttons,.jp-carousel-overlay .swiper-container .swiper-button-next,.jp-carousel-overlay .swiper-container .swiper-button-prev{display:none!important}.jp-carousel-image-meta{box-sizing:border-box;float:none!important;margin-right:0;width:100%!important}.jp-carousel-close-hint{font-size:26px!important;left:10px;position:fixed!important;top:10px}.admin-bar .jp-carousel-close-hint{top:40px}.jp-carousel-slide img{opacity:1}.jp-carousel-wrap{background-color:var(--jp-carousel-bg-color)}.jp-carousel-fadeaway,.jp-carousel-info>.jp-carousel-photo-info{display:none}.jp-carousel-comments-wrapper>.jp-carousel-photo-info{display:block}.jp-carousel-caption{overflow:visible!important}.jp-carousel-info-footer .jp-carousel-photo-title-container{display:none}.jp-carousel-photo-icons-container{margin:0 0 0 10px;white-space:nowrap}.jp-carousel-icon-btn{padding-right:20px}.jp-carousel-pagination{padding-right:5px}.jp-carousel-pagination-container{margin-right:25px}.jp-carousel-comment .avatar{min-width:48px}#jp-carousel-comment-form-commenting-as fieldset,#jp-carousel-comment-form-commenting-as input{float:none;width:100%}} \ No newline at end of file
diff --git a/plugins/jetpack/modules/carousel/jetpack-carousel.php b/plugins/jetpack/modules/carousel/jetpack-carousel.php
index 45ed2975..d357b946 100644
--- a/plugins/jetpack/modules/carousel/jetpack-carousel.php
+++ b/plugins/jetpack/modules/carousel/jetpack-carousel.php
@@ -1,39 +1,71 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Module: Jetpack Carousel
+ *
+ * @package automattic/jetpack
+ */
+
use Automattic\Jetpack\Assets;
use Automattic\Jetpack\Status;
-/*
-Plugin Name: Jetpack Carousel
-Plugin URL: https://wordpress.com/
-Description: Transform your standard image galleries into an immersive full-screen experience.
-Version: 0.1
-Author: Automattic
-
-Released under the GPL v.2 license.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-*/
+/**
+ * Jetpack_Carousel class.
+ */
class Jetpack_Carousel {
-
+ /**
+ * Defines Carousel pre-built widths
+ *
+ * @var array
+ */
public $prebuilt_widths = array( 370, 700, 1000, 1200, 1400, 2000 );
+ /**
+ * Represents whether or not this is the first load of Carousel on a page. Default is true.
+ *
+ * @var bool
+ */
public $first_run = true;
+ /**
+ * Determines whether or not to set in the gallery. Default is false.
+ *
+ * @deprecated since 10.8
+ *
+ * @var bool
+ */
public $in_gallery = false;
+ /**
+ * Determines whether the Jetpack class and method exists. Default is true.
+ *
+ * @var bool
+ */
public $in_jetpack = true;
+ /**
+ * Determines whether or not a single image gallery is enabled. Default is false.
+ *
+ * @var bool
+ */
public $single_image_gallery_enabled = false;
+ /**
+ * Determines whether images that link to themselves should be replaced with a one image gallery. Default is false.
+ *
+ * @var bool
+ */
public $single_image_gallery_enabled_media_file = false;
- function __construct() {
+ /**
+ * Constructor.
+ */
+ public function __construct() {
add_action( 'init', array( $this, 'init' ) );
}
- function init() {
+ /**
+ * Initialize class
+ */
+ public function init() {
if ( $this->maybe_disable_jp_carousel() ) {
return;
}
@@ -44,11 +76,11 @@ class Jetpack_Carousel {
$this->single_image_gallery_enabled_media_file = $this->maybe_enable_jp_carousel_single_images_media_file();
if ( is_admin() ) {
- // Register the Carousel-related related settings
+ // Register the Carousel-related related settings.
add_action( 'admin_init', array( $this, 'register_settings' ), 5 );
if ( ! $this->in_jetpack ) {
- if ( 0 == $this->test_1or0_option( get_option( 'carousel_enable_it' ), true ) ) {
- return; // Carousel disabled, abort early, but still register setting so user can switch it back on
+ if ( 0 === $this->test_1or0_option( get_option( 'carousel_enable_it' ), true ) ) {
+ return; // Carousel disabled, abort early, but still register setting so user can switch it back on.
}
}
// If in admin, register the ajax endpoints.
@@ -58,8 +90,8 @@ class Jetpack_Carousel {
add_action( 'wp_ajax_nopriv_post_attachment_comment', array( $this, 'post_attachment_comment' ) );
} else {
if ( ! $this->in_jetpack ) {
- if ( 0 == $this->test_1or0_option( get_option( 'carousel_enable_it' ), true ) ) {
- return; // Carousel disabled, abort early
+ if ( 0 === $this->test_1or0_option( get_option( 'carousel_enable_it' ), true ) ) {
+ return; // Carousel disabled, abort early.
}
}
// If on front-end, do the Carousel thang.
@@ -73,7 +105,7 @@ class Jetpack_Carousel {
* @param array $this->prebuilt_widths Array of default widths.
*/
$this->prebuilt_widths = apply_filters( 'jp_carousel_widths', $this->prebuilt_widths );
- // below: load later than other callbacks hooked it (e.g. 3rd party plugins handling gallery shortcode)
+ // below: load later than other callbacks hooked it (e.g. 3rd party plugins handling gallery shortcode).
add_filter( 'post_gallery', array( $this, 'check_if_shortcode_processed_and_enqueue_assets' ), 1000, 2 );
add_filter( 'post_gallery', array( $this, 'set_in_gallery' ), -1000 );
add_filter( 'gallery_style', array( $this, 'add_data_to_container' ) );
@@ -86,11 +118,18 @@ class Jetpack_Carousel {
}
if ( $this->in_jetpack ) {
- Jetpack::enable_module_configurable( dirname( dirname( __FILE__ ) ) . '/carousel.php' );
+ Jetpack::enable_module_configurable( dirname( __DIR__ ) . '/carousel.php' );
}
}
- function maybe_disable_jp_carousel() {
+ /**
+ * Returns the value of the applied jp_carousel_maybe_disable filter
+ *
+ * @since 1.6.0
+ *
+ * @return bool - Should Carousel be disabled? Default to false.
+  */
+ public function maybe_disable_jp_carousel() {
/**
* Allow third-party plugins or themes to disable Carousel.
*
@@ -103,7 +142,14 @@ class Jetpack_Carousel {
return apply_filters( 'jp_carousel_maybe_disable', false );
}
- function maybe_disable_jp_carousel_single_images() {
+ /**
+ * Returns the value of the applied jp_carousel_maybe_disable_single_images filter
+ *
+ * @since 4.5.0
+ *
+ * @return bool - Should Carousel be disabled for single images? Default to false.
+ */
+ public function maybe_disable_jp_carousel_single_images() {
/**
* Allow third-party plugins or themes to disable Carousel for single images.
*
@@ -116,7 +162,14 @@ class Jetpack_Carousel {
return apply_filters( 'jp_carousel_maybe_disable_single_images', false );
}
- function maybe_enable_jp_carousel_single_images_media_file() {
+ /**
+ * Returns the value of the applied jp_carousel_load_for_images_linked_to_file filter
+ *
+ * @since 4.5.0
+ *
+ * @return bool - Should Carousel be enabled for single images linking to 'Media File'? Default to false.
+ */
+ public function maybe_enable_jp_carousel_single_images_media_file() {
/**
* Allow third-party plugins or themes to enable Carousel
* for single images linking to 'Media File' (full size image).
@@ -130,7 +183,16 @@ class Jetpack_Carousel {
return apply_filters( 'jp_carousel_load_for_images_linked_to_file', false );
}
- function asset_version( $version ) {
+ /**
+ * Returns the value of the applied jp_carousel_asset_version filter
+ *
+ * @since 1.6.0
+ *
+ * @param string $version Asset version.
+ *
+ * @return string
+ */
+ public function asset_version( $version ) {
/**
* Filter the version string used when enqueuing Carousel assets.
*
@@ -143,17 +205,36 @@ class Jetpack_Carousel {
return apply_filters( 'jp_carousel_asset_version', $version );
}
- function display_bail_message( $output = '' ) {
- // Displays a message on top of gallery if carousel has bailed
+ /**
+ * Displays a message on top of gallery if carousel has bailed.
+ *
+ * @param string $output Gallery shortcode output.
+ *
+ * @return string Shortcode output with bail message prepended.
+ */
+ public function display_bail_message( $output = '' ) {
$message = '<div class="jp-carousel-msg"><p>';
$message .= __( 'Jetpack\'s Carousel has been disabled, because another plugin or your theme is overriding the [gallery] shortcode.', 'jetpack' );
$message .= '</p></div>';
- // put before gallery output
+ // put before gallery output.
$output = $message . $output;
return $output;
}
- function check_if_shortcode_processed_and_enqueue_assets( $output ) {
+ /**
+ * Determine whether Carousel is enabled, and adjust filters and enqueue assets accordingly.
+ *
+ * If no other filter hook produced output for the gallery shortcode or something returns true for
+ * the `jp_carousel_force_enable` filter, Carousel is enabled and we queue our assets. Otherwise
+ * it's disabled and we remove some of our subsequent filter hooks.
+ *
+ * @since 1.9.0
+ *
+ * @param string $output Gallery shortcode output.
+ *
+ * @return string Gallery shortcode output.
+ */
+ public function check_if_shortcode_processed_and_enqueue_assets( $output ) {
if (
class_exists( 'Jetpack_AMP_Support' )
&& Jetpack_AMP_Support::is_amp_request()
@@ -194,7 +275,7 @@ class Jetpack_Carousel {
* @module carousel
*
* @since 1.6.0
- **/
+ */
do_action( 'jp_carousel_thumbnails_shown' );
$this->enqueue_assets();
@@ -211,7 +292,7 @@ class Jetpack_Carousel {
*
* @return string $content Post content.
*/
- function check_content_for_blocks( $content ) {
+ public function check_content_for_blocks( $content ) {
if (
class_exists( 'Jetpack_AMP_Support' )
&& Jetpack_AMP_Support::is_amp_request()
@@ -226,7 +307,10 @@ class Jetpack_Carousel {
return $content;
}
- function enqueue_assets() {
+ /**
+ * Enqueueing Carousel assets.
+ */
+ public function enqueue_assets() {
if ( $this->first_run ) {
wp_enqueue_script(
'jetpack-carousel',
@@ -247,7 +331,7 @@ class Jetpack_Carousel {
);
wp_localize_script( 'jetpack-carousel', 'jetpackSwiperLibraryPath', $swiper_library_path );
- // Note: using home_url() instead of admin_url() for ajaxurl to be sure to get same domain on wpcom when using mapped domains (also works on self-hosted)
+ // Note: using home_url() instead of admin_url() for ajaxurl to be sure to get same domain on wpcom when using mapped domains (also works on self-hosted).
// Also: not hardcoding path since there is no guarantee site is running on site root in self-hosted context.
$is_logged_in = is_user_logged_in();
$comment_registration = (int) get_option( 'comment_registration' );
@@ -260,7 +344,6 @@ class Jetpack_Carousel {
'nonce' => wp_create_nonce( 'carousel_nonce' ),
'display_exif' => $this->test_1or0_option( Jetpack_Options::get_option_and_ensure_autoload( 'carousel_display_exif', true ) ),
'display_comments' => $this->test_1or0_option( Jetpack_Options::get_option_and_ensure_autoload( 'carousel_display_comments', true ) ),
- 'display_geo' => $this->test_1or0_option( Jetpack_Options::get_option_and_ensure_autoload( 'carousel_display_geo', true ) ),
'single_image_gallery' => $this->single_image_gallery_enabled,
'single_image_gallery_media_file' => $this->single_image_gallery_enabled_media_file,
'background_color' => $this->carousel_background_color_sanitize( Jetpack_Options::get_option_and_ensure_autoload( 'carousel_background_color', '' ) ),
@@ -268,7 +351,12 @@ class Jetpack_Carousel {
'post_comment' => __( 'Post Comment', 'jetpack' ),
'write_comment' => __( 'Write a Comment...', 'jetpack' ),
'loading_comments' => __( 'Loading Comments...', 'jetpack' ),
- 'download_original' => sprintf( __( 'View full size <span class="photo-size">%1$s<span class="photo-size-times">&times;</span>%2$s</span>', 'jetpack' ), '{0}', '{1}' ),
+ 'download_original' => sprintf(
+ /* translators: %1s is the full-size image width, and %2s is the height. */
+ __( 'View full size <span class="photo-size">%1$s<span class="photo-size-times">&times;</span>%2$s</span>', 'jetpack' ),
+ '{0}',
+ '{1}'
+ ),
'no_comment_text' => __( 'Please be sure to submit some text with your comment.', 'jetpack' ),
'no_comment_email' => __( 'Please provide an email address to comment.', 'jetpack' ),
'no_comment_author' => __( 'Please provide your name to comment.', 'jetpack' ),
@@ -568,7 +656,16 @@ class Jetpack_Carousel {
<?php
}
- function set_in_gallery( $output ) {
+ /**
+ * Sets the "in_gallery" flag when the first gallery is encountered (unless in AMP mode).
+ *
+ * @deprecated since 10.8
+ *
+ * @param string $output Gallery shortcode output. Passed through unchanged.
+ *
+ * @return string
+ */
+ public function set_in_gallery( $output ) {
if (
class_exists( 'Jetpack_AMP_Support' )
&& Jetpack_AMP_Support::is_amp_request()
@@ -586,10 +683,10 @@ class Jetpack_Carousel {
* @see add_data_to_images()
* @see wp_make_content_images_responsive() in wp-includes/media.php
*
- * @param string $content HTML content of the post
- * @return string Modified HTML content of the post
+ * @param string $content HTML content of the post.
+ * @return string
*/
- function add_data_img_tags_and_enqueue_assets( $content ) {
+ public function add_data_img_tags_and_enqueue_assets( $content ) {
if (
class_exists( 'Jetpack_AMP_Support' )
&& Jetpack_AMP_Support::is_amp_request()
@@ -649,7 +746,18 @@ class Jetpack_Carousel {
return $content;
}
- function add_data_to_images( $attr, $attachment = null ) {
+ /**
+ * Adds the data attributes themselves to img tags.
+ *
+ * @see add_data_img_tags_and_enqueue_assets()
+ * @see https://developer.wordpress.org/reference/functions/wp_get_attachment_image/ Documentation about wp_get_attachment_image
+ *
+ * @param string[] $attr Array of attribute values for the image markup, keyed by attribute name.
+ * @param WP_Post $attachment Image attachment post.
+ *
+ * @return string[] Modified image attributes.
+ */
+ public function add_data_to_images( $attr, $attachment = null ) {
if (
class_exists( 'Jetpack_AMP_Support' )
&& Jetpack_AMP_Support::is_amp_request()
@@ -695,21 +803,12 @@ class Jetpack_Carousel {
$attachment_desc = ! empty( $attachment ) ? wpautop( wptexturize( $attachment->post_content ) ) : '';
$attachment_caption = ! empty( $attachment ) ? wpautop( wptexturize( $attachment->post_excerpt ) ) : '';
- // Not yet providing geo-data, need to "fuzzify" for privacy
- if ( ! empty( $img_meta ) ) {
- foreach ( $img_meta as $k => $v ) {
- if ( 'latitude' == $k || 'longitude' == $k ) {
- unset( $img_meta[ $k ] );
- }
- }
- }
-
- // See https://github.com/Automattic/jetpack/issues/2765
+ // See https://github.com/Automattic/jetpack/issues/2765.
if ( isset( $img_meta['keywords'] ) ) {
unset( $img_meta['keywords'] );
}
- $img_meta = json_encode( array_map( 'strval', array_filter( $img_meta, 'is_scalar' ) ) );
+ $img_meta = wp_json_encode( array_map( 'strval', array_filter( $img_meta, 'is_scalar' ) ) );
$attr['data-attachment-id'] = $attachment_id;
$attr['data-permalink'] = esc_attr( get_permalink( $attachment_id ) );
@@ -726,7 +825,14 @@ class Jetpack_Carousel {
return $attr;
}
- function add_data_to_container( $html ) {
+ /**
+ * Add additional attributes to the Gallery container HTML.
+ *
+ * @param string $html The HTML to which the additional attributes are added.
+ *
+ * @return string
+ */
+ public function add_data_to_container( $html ) {
global $post;
if (
class_exists( 'Jetpack_AMP_Support' )
@@ -791,7 +897,7 @@ class Jetpack_Carousel {
return preg_replace_callback(
'#(<a[^>]* href=(["\']?)(\S+)\2>)\s*(<img[^>]*)(class=(["\']?)[^>]*wp-image-[0-9]+[^>]*\6.*>)\s*</a>#is',
- static function( $matches ) {
+ static function ( $matches ) {
if ( ! preg_match( '#\.\w+$#', $matches[3] ) ) {
// The a[href] doesn't end in a file extension like .jpeg, so this is not a link to the media file, and should get a lightbox.
return $matches[4] . ' data-amp-lightbox="true" lightbox="true" ' . $matches[5]; // https://github.com/ampproject/amp-wp/blob/1094ea03bd5dc92889405a47a8c41de1a88908de/includes/sanitizers/class-amp-img-sanitizer.php#L419.
@@ -803,7 +909,12 @@ class Jetpack_Carousel {
);
}
- function get_attachment_comments() {
+ /**
+ * Retrieves comment information
+ *
+ * @return string
+ */
+ public function get_attachment_comments() {
if ( ! headers_sent() ) {
header( 'Content-type: text/javascript' );
}
@@ -819,8 +930,10 @@ class Jetpack_Carousel {
*/
do_action( 'jp_carousel_check_blog_user_privileges' );
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended -- we do not need to verify the nonce for this public request for publicly accessible data (as checked below).
$attachment_id = ( isset( $_REQUEST['id'] ) ) ? (int) $_REQUEST['id'] : 0;
$offset = ( isset( $_REQUEST['offset'] ) ) ? (int) $_REQUEST['offset'] : 0;
+ // phpcs:enable
if ( ! $attachment_id ) {
wp_send_json_error(
@@ -895,7 +1008,7 @@ class Jetpack_Carousel {
$comments = get_comments(
array(
'status' => 'approve',
- 'order' => ( 'asc' == get_option( 'comment_order' ) ) ? 'ASC' : 'DESC',
+ 'order' => ( 'asc' === get_option( 'comment_order' ) ) ? 'ASC' : 'DESC',
'number' => 10,
'offset' => $offset,
'post_id' => $attachment_id,
@@ -920,37 +1033,40 @@ class Jetpack_Carousel {
);
}
- die( json_encode( $out ) );
+ die( wp_json_encode( $out ) );
}
- function post_attachment_comment() {
+ /**
+ * Adds a new comment to the database
+ */
+ public function post_attachment_comment() {
if ( ! headers_sent() ) {
header( 'Content-type: text/javascript' );
}
- if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'carousel_nonce' ) ) {
- die( json_encode( array( 'error' => __( 'Nonce verification failed.', 'jetpack' ) ) ) );
+ if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'carousel_nonce' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- WP Core doesn't unslash or sanitize nonces either
+ die( wp_json_encode( array( 'error' => __( 'Nonce verification failed.', 'jetpack' ) ) ) );
}
- $_blog_id = (int) $_POST['blog_id'];
- $_post_id = (int) $_POST['id'];
- $comment = $_POST['comment'];
+ $_blog_id = isset( $_POST['blog_id'] ) ? (int) $_POST['blog_id'] : 0;
+ $_post_id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
+ $comment = isset( $_POST['comment'] ) ? filter_var( wp_unslash( $_POST['comment'] ) ) : null;
if ( empty( $_blog_id ) ) {
- die( json_encode( array( 'error' => __( 'Missing target blog ID.', 'jetpack' ) ) ) );
+ die( wp_json_encode( array( 'error' => __( 'Missing target blog ID.', 'jetpack' ) ) ) );
}
if ( empty( $_post_id ) ) {
- die( json_encode( array( 'error' => __( 'Missing target post ID.', 'jetpack' ) ) ) );
+ die( wp_json_encode( array( 'error' => __( 'Missing target post ID.', 'jetpack' ) ) ) );
}
if ( empty( $comment ) ) {
- die( json_encode( array( 'error' => __( 'No comment text was submitted.', 'jetpack' ) ) ) );
+ die( wp_json_encode( array( 'error' => __( 'No comment text was submitted.', 'jetpack' ) ) ) );
}
- // Used in context like NewDash
+ // Used in context like NewDash.
$switched = false;
- if ( is_multisite() && $_blog_id != get_current_blog_id() ) {
+ if ( is_multisite() && get_current_blog_id() !== $_blog_id ) {
switch_to_blog( $_blog_id );
$switched = true;
}
@@ -962,7 +1078,7 @@ class Jetpack_Carousel {
if ( $switched ) {
restore_current_blog();
}
- die( json_encode( array( 'error' => __( 'Comments on this post are closed.', 'jetpack' ) ) ) );
+ die( wp_json_encode( array( 'error' => __( 'Comments on this post are closed.', 'jetpack' ) ) ) );
}
if ( is_user_logged_in() ) {
@@ -976,35 +1092,37 @@ class Jetpack_Carousel {
if ( $switched ) {
restore_current_blog();
}
- die( json_encode( array( 'error' => __( 'Sorry, but we could not authenticate your request.', 'jetpack' ) ) ) );
+ die( wp_json_encode( array( 'error' => __( 'Sorry, but we could not authenticate your request.', 'jetpack' ) ) ) );
}
} else {
$user_id = 0;
- $display_name = $_POST['author'];
- $email = $_POST['email'];
- $url = $_POST['url'];
+ $display_name = isset( $_POST['author'] ) ? sanitize_text_field( wp_unslash( $_POST['author'] ) ) : null;
+ $email = isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : null; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Checked or sanitized below.
+ $url = isset( $_POST['url'] ) ? esc_url_raw( wp_unslash( $_POST['url'] ) ) : null;
if ( get_option( 'require_name_email' ) ) {
if ( empty( $display_name ) ) {
if ( $switched ) {
restore_current_blog();
}
- die( json_encode( array( 'error' => __( 'Please provide your name.', 'jetpack' ) ) ) );
+ die( wp_json_encode( array( 'error' => __( 'Please provide your name.', 'jetpack' ) ) ) );
}
if ( empty( $email ) ) {
if ( $switched ) {
restore_current_blog();
}
- die( json_encode( array( 'error' => __( 'Please provide an email address.', 'jetpack' ) ) ) );
+ die( wp_json_encode( array( 'error' => __( 'Please provide an email address.', 'jetpack' ) ) ) );
}
if ( ! is_email( $email ) ) {
if ( $switched ) {
restore_current_blog();
}
- die( json_encode( array( 'error' => __( 'Please provide a valid email address.', 'jetpack' ) ) ) );
+ die( wp_json_encode( array( 'error' => __( 'Please provide a valid email address.', 'jetpack' ) ) ) );
}
+ } else {
+ $email = $email !== null ? sanitize_email( $email ) : null;
}
}
@@ -1035,12 +1153,12 @@ class Jetpack_Carousel {
do_action( 'jp_carousel_post_attachment_comment' );
$comment_status = wp_get_comment_status( $comment_id );
- if ( true == $switched ) {
+ if ( $switched ) {
restore_current_blog();
}
die(
- json_encode(
+ wp_json_encode(
array(
'comment_id' => $comment_id,
'comment_status' => $comment_status,
@@ -1049,7 +1167,10 @@ class Jetpack_Carousel {
);
}
- function register_settings() {
+ /**
+ * Register Carousel settings
+ */
+ public function register_settings() {
add_settings_section( 'carousel_section', __( 'Image Gallery Carousel', 'jetpack' ), array( $this, 'carousel_section_callback' ), 'media' );
if ( ! $this->in_jetpack ) {
@@ -1066,31 +1187,53 @@ class Jetpack_Carousel {
add_settings_field( 'carousel_display_comments', __( 'Comments', 'jetpack' ), array( $this, 'carousel_display_comments_callback' ), 'media', 'carousel_section' );
register_setting( 'media', 'carousel_display_comments', array( $this, 'carousel_display_comments_sanitize' ) );
- // No geo setting yet, need to "fuzzify" data first, for privacy
- // add_settings_field('carousel_display_geo', __( 'Geolocation', 'jetpack' ), array( $this, 'carousel_display_geo_callback' ), 'media', 'carousel_section' );
- // register_setting( 'media', 'carousel_display_geo', array( $this, 'carousel_display_geo_sanitize' ) );
}
- // Fulfill the settings section callback requirement by returning nothing
- function carousel_section_callback() {
- return;
+ /**
+ * Fulfill the settings section callback requirement by returning nothing.
+ */
+ public function carousel_section_callback() {
}
- function test_1or0_option( $value, $default_to_1 = true ) {
- if ( true == $default_to_1 ) {
- // Binary false (===) of $value means it has not yet been set, in which case we do want to default sites to 1
+ /**
+ * Tests if a value is set
+ *
+ * @param mixed $value The value passed into this function with which to test.
+ * @param bool $default_to_1 Default is true.
+ *
+ * @return bool
+ */
+ public function test_1or0_option( $value, $default_to_1 = true ) {
+ if ( $default_to_1 ) {
+ // Boolean false (===) of $value means it has not yet been set, in which case we do want to default to 1.
if ( false === $value ) {
$value = 1;
}
}
- return ( 1 == $value ) ? 1 : 0;
+ return ( 1 == $value ) ? 1 : 0; // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
}
- function sanitize_1or0_option( $value ) {
- return ( 1 == $value ) ? 1 : 0;
+ /**
+ * Ensures the value returned is in the correct format.
+ *
+ * @see test_1or0_option()
+ * @param mixed $value The value returned from the test_1or0_option function.
+ *
+ * @return int
+ */
+ public function sanitize_1or0_option( $value ) {
+ return ( 1 == $value ) ? 1 : 0; // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
}
- function settings_checkbox( $name, $label_text, $extra_text = '', $default_to_checked = true ) {
+ /**
+ * Outputs a settings checkbox.
+ *
+ * @param string $name - For name attribute.
+ * @param string $label_text - For label attribute.
+ * @param string $extra_text - Additional checkbox description text. Defaults to empty.
+ * @param bool $default_to_checked - If the checkbox is checked. Default is true.
+ */
+ public function settings_checkbox( $name, $label_text, $extra_text = '', $default_to_checked = true ) {
if ( empty( $name ) ) {
return;
}
@@ -1098,14 +1241,21 @@ class Jetpack_Carousel {
echo '<fieldset>';
echo '<input type="checkbox" name="' . esc_attr( $name ) . '" id="' . esc_attr( $name ) . '" value="1" ';
checked( '1', $option );
- echo '/> <label for="' . esc_attr( $name ) . '">' . $label_text . '</label>';
+ echo '/> <label for="' . esc_attr( $name ) . '">' . wp_kses_post( $label_text ) . '</label>';
if ( ! empty( $extra_text ) ) {
- echo '<p class="description">' . $extra_text . '</p>';
+ echo '<p class="description">' . wp_kses_post( $extra_text ) . '</p>';
}
echo '</fieldset>';
}
- function settings_select( $name, $values, $extra_text = '' ) {
+ /**
+ * Output a selection list options
+ *
+ * @param string $name - For name attribute.
+ * @param string $values - For the different option values.
+ * @param string $extra_text - Additional option section description text. Defaults to empty.
+ */
+ public function settings_select( $name, $values, $extra_text = '' ) {
if ( empty( $name ) || ! is_array( $values ) || empty( $values ) ) {
return;
}
@@ -1119,12 +1269,15 @@ class Jetpack_Carousel {
}
echo '</select>';
if ( ! empty( $extra_text ) ) {
- echo '<p class="description">' . $extra_text . '</p>';
+ echo '<p class="description">' . wp_kses_post( $extra_text ) . '</p>';
}
echo '</fieldset>';
}
- function carousel_display_exif_callback() {
+ /**
+ * Callback for checkbox and label of field that allows to toggle exif display.
+ */
+ public function carousel_display_exif_callback() {
$this->settings_checkbox( 'carousel_display_exif', __( 'Show photo metadata (<a href="https://en.wikipedia.org/wiki/Exchangeable_image_file_format" rel="noopener noreferrer" target="_blank">Exif</a>) in carousel, when available.', 'jetpack' ) );
}
@@ -1135,7 +1288,14 @@ class Jetpack_Carousel {
$this->settings_checkbox( 'carousel_display_comments', esc_html__( 'Show comments area in carousel', 'jetpack' ) );
}
- function carousel_display_exif_sanitize( $value ) {
+ /**
+ * Sanitize input for the `carousel_display_exif` setting.
+ *
+ * @param mixed $value User input setting value.
+ *
+ * @return number Sanitized value, only 1 or 0.
+ */
+ public function carousel_display_exif_sanitize( $value ) {
return $this->sanitize_1or0_option( $value );
}
@@ -1150,34 +1310,47 @@ class Jetpack_Carousel {
return $this->sanitize_1or0_option( $value );
}
- function carousel_display_geo_callback() {
- $this->settings_checkbox( 'carousel_display_geo', __( 'Show map of photo location in carousel, when available.', 'jetpack' ) );
- }
-
- function carousel_display_geo_sanitize( $value ) {
- return $this->sanitize_1or0_option( $value );
- }
-
- function carousel_background_color_callback() {
+ /**
+ * Callback for the Carousel background color.
+ */
+ public function carousel_background_color_callback() {
$this->settings_select(
- 'carousel_background_color', array(
+ 'carousel_background_color',
+ array(
'black' => __( 'Black', 'jetpack' ),
'white' => __( 'White', 'jetpack' ),
)
);
}
- function carousel_background_color_sanitize( $value ) {
- return ( 'white' == $value ) ? 'white' : 'black';
+ /**
+ * Sanitizing the Carousel backgound color selection.
+ *
+ * @param string $value The color string to sanitize.
+ *
+ * @return string Sanitized value, 'white' or 'black'.
+ */
+ public function carousel_background_color_sanitize( $value ) {
+ return ( 'white' === $value ) ? 'white' : 'black';
}
- function carousel_enable_it_callback() {
+ /**
+ * Callback to display text for the carousel_enable_it settings field.
+ */
+ public function carousel_enable_it_callback() {
$this->settings_checkbox( 'carousel_enable_it', __( 'Display images in full-size carousel slideshow.', 'jetpack' ) );
}
- function carousel_enable_it_sanitize( $value ) {
+ /**
+ * Sanitize input for the `carousel_enable_it` setting.
+ *
+ * @param mixed $value User input.
+ *
+ * @return number Sanitized value, only 1 or 0.
+ */
+ public function carousel_enable_it_sanitize( $value ) {
return $this->sanitize_1or0_option( $value );
}
}
-new Jetpack_Carousel;
+new Jetpack_Carousel();
diff --git a/plugins/jetpack/modules/carousel/rtl/jetpack-carousel-rtl.css b/plugins/jetpack/modules/carousel/rtl/jetpack-carousel-rtl.css
deleted file mode 100644
index a9ad0fdb..00000000
--- a/plugins/jetpack/modules/carousel/rtl/jetpack-carousel-rtl.css
+++ /dev/null
@@ -1,1134 +0,0 @@
-/* This file was automatically generated on Jul 30 2015 22:37:09 */
-
-[data-carousel-extra] {
- cursor: pointer; /* adds a cursor when the carousel takes effect */
-}
-
-.jp-carousel-wrap * {
- line-height:inherit; /* prevent declarations of line-height in the universal selector */
-}
-
-.jp-carousel-overlay {
- background: #000;
-}
-
-div.jp-carousel-fadeaway {
- background: -moz-linear-gradient(bottom, rgba(0,0,0,0.5), rgba(0,0,0,0));
- background: -webkit-gradient(linear, right bottom, right top, from(rgba(0,0,0,0.5)), to(rgba(0,0,0,0)));
- position: fixed;
- bottom: 0;
- z-index: 2147483647;
- width: 100%;
- height: 15px;
-}
-
-.jp-carousel-next-button span,
-.jp-carousel-previous-button span {
- background: url(.././images/arrows.png) no-repeat center center;
- background-size: 200px 126px;
-}
-
-.jp-carousel-msg {
- font-family: "Open Sans", sans-serif;
- font-style: normal;
- display: inline-block;
- line-height: 19px;
- padding: 11px 15px;
- font-size: 14px;
- text-align: center;
- margin: 25px 2px 0 20px;
- background-color: #fff;
- border-right: 4px solid #ffba00;
- -webkit-box-shadow: 0 0 1px 1px rgba(0,0,0,0.1);
- box-shadow: 0 0 1px 1px rgba(0,0,0,0.1);
-}
-
-@media
-only screen and (-webkit-min-device-pixel-ratio: 1.5),
-only screen and (-o-min-device-pixel-ratio: 3/2),
-only screen and (min--moz-device-pixel-ratio: 1.5),
-only screen and (min-device-pixel-ratio: 1.5) {
- .jp-carousel-next-button span,
- .jp-carousel-previous-button span {
- background-image: url(.././images/arrows-2x.png);
- }
-}
-
-.jp-carousel-wrap {
- font-family: "Helvetica Neue", sans-serif !important;
-}
-
-.jp-carousel-info {
- position: absolute;
- bottom: 0;
- text-align: right !important;
- -webkit-font-smoothing: subpixel-antialiased !important;
-}
-
-.jp-carousel-info ::selection {
- background: #68c9e8; /* Safari */
- color: #fff;
- }
-
-.jp-carousel-info ::-moz-selection {
- background: #68c9e8; /* Firefox */
- color: #fff;
-}
-
-.jp-carousel-photo-info {
- position: relative;
- right: 25%;
- width: 50%;
-}
-
-.jp-carousel-transitions .jp-carousel-photo-info {
- -webkit-transition: 400ms ease-out;
- -moz-transition: 400ms ease-out;
- -o-transition: 400ms ease-out;
- transition: 400ms ease-out;
-}
-
-.jp-carousel-info h2 {
- background: none !important;
- border: none !important;
- color: #999;
- display: block !important;
- font: normal 13px/1.25em "Helvetica Neue", sans-serif !important;
- letter-spacing: 0 !important;
- margin: 7px 0 0 0 !important;
- padding: 10px 0 0 !important;
- overflow: hidden;
- text-align: right;
- text-shadow: none !important;
- text-transform: none !important;
- -webkit-font-smoothing: subpixel-antialiased;
-}
-
-.jp-carousel-next-button,
-.jp-carousel-previous-button {
- text-indent: -9999px;
- overflow: hidden;
- cursor: pointer;
-}
-
-.jp-carousel-next-button span,
-.jp-carousel-previous-button span {
- position: absolute;
- top: 0;
- bottom: 0;
- width: 82px;
- zoom: 1;
- filter: alpha(opacity=20);
- opacity: 0.2;
-}
-
-.jp-carousel-transitions .jp-carousel-next-button span,
-.jp-carousel-transitions .jp-carousel-previous-button span {
- -webkit-transition: 500ms opacity ease-out;
- -moz-transition: 500ms opacity ease-out;
- -o-transition: 500ms opacity ease-out;
- transition: 500ms opacity ease-out;
-}
-
-.jp-carousel-next-button:hover span,
-.jp-carousel-previous-button:hover span {
- filter: alpha(opacity=60);
- opacity: 0.6;
-}
-.jp-carousel-next-button span {
- background-position: -110px center;
- left: 0;
-}
-
-.jp-carousel-previous-button span {
- background-position: -10px center;
- right:0;
-}
-
-.jp-carousel-buttons {
- margin:-18px -20px 15px;
- padding:8px 10px;
- border-bottom:1px solid #222;
- background: #222;
- text-align: center;
-}
-
-div.jp-carousel-buttons a {
- border: none !important;
- color: #999;
- font: normal 11px/1.2em "Helvetica Neue", sans-serif !important;
- letter-spacing: 0 !important;
- padding: 5px 0 5px 2px;
- text-decoration: none !important;
- text-shadow: none !important;
- vertical-align: middle;
- -webkit-font-smoothing: subpixel-antialiased;
-}
-
-div.jp-carousel-buttons a:hover {
- color: #68c9e8;
- border: none !important;
-}
-
-.jp-carousel-transitions div.jp-carousel-buttons a:hover {
- -webkit-transition: none !important;
- -moz-transition: none !important;
- -o-transition: none !important;
- transition: none !important;
-}
-
-.jp-carousel-slide, .jp-carousel-slide img, .jp-carousel-next-button,
-.jp-carousel-previous-button {
- -webkit-transform:translate3d(0, 0, 0);
- -moz-transform:translate3d(0, 0, 0);
- -o-transform:translate3d(0, 0, 0);
- -ms-transform:translate3d(0, 0, 0);
-}
-
-.jp-carousel-slide {
- position:fixed;
- width:0;
- bottom:0;
- background-color:#000;
- border-radius:2px;
- -webkit-border-radius:2px;
- -moz-border-radius:2px;
- -ms-border-radius:2px;
- -o-border-radius:2px;
-}
-
-.jp-carousel-transitions .jp-carousel-slide {
- -webkit-transition: 300ms ease-out;
- -moz-transition: 300ms ease-out;
- -o-transition: 300ms ease-out;
- transition: 300ms ease-out;
-}
-
-.jp-carousel-slide.selected {
- position: absolute !important;
- filter: alpha(opacity=100);
- opacity: 1;
-}
-
-.jp-carousel-slide {
- filter: alpha(opacity=25);
- opacity: 0.25;
-}
-
-.jp-carousel-slide img {
- display: block;
- width: 100% !important;
- height: 100% !important;
- max-width: 100% !important;
- max-height: 100% !important;
- background: none !important;
- border: none !important;
- padding: 0 !important;
- -webkit-box-shadow: 0 2px 8px rgba(0,0,0,0.1);
- -moz-box-shadow: 0 2px 8px rgba(0,0,0,0.1);
- box-shadow: 0 2px 8px rgba(0,0,0,0.1);
- zoom: 1;
-}
-
-.jp-carousel-transitions .jp-carousel-slide {
- -webkit-transition: opacity 400ms linear;
- -moz-transition: opacity 400ms linear;
- -o-transition: opacity 400ms linear;
- transition: opacity 400ms linear;
-}
-
-.jp-carousel-close-hint {
- color: #999;
- cursor: default;
- letter-spacing: 0 !important;
- padding:0.35em 0 0;
- position: absolute;
- text-align: right;
- width: 90%;
-}
-
-.jp-carousel-transitions .jp-carousel-close-hint {
- -webkit-transition: color 200ms linear;
- -moz-transition: color 200ms linear;
- -o-transition: color 200ms linear;
- transition: color 200ms linear;
-}
-
-.jp-carousel-close-hint span {
- cursor: pointer;
- background-color: black;
- background-color: rgba(0,0,0,0.8);
- display: block;
- height: 22px;
- font: 400 24px/1 "Helvetica Neue", sans-serif !important;
- line-height: 22px;
- margin: 0 0.4em 0 0;
- text-align: center;
- vertical-align: middle;
- width: 22px;
- -moz-border-radius: 4px;
- -webkit-border-radius: 4px;
- border-radius: 4px;
-}
-
-.jp-carousel-transitions .jp-carousel-close-hint span {
- -webkit-transition: border-color 200ms linear;
- -moz-transition: border-color 200ms linear;
- -o-transition: border-color 200ms linear;
- transition: border-color 200ms linear;
-}
-
-.jp-carousel-close-hint:hover {
- cursor: default;
- color: #fff;
-}
-
-.jp-carousel-close-hint:hover span {
- border-color: #fff;
-}
-
-div.jp-carousel-buttons a.jp-carousel-reblog,
-div.jp-carousel-buttons a.jp-carousel-commentlink,
-a.jp-carousel-image-download {
- background: url(.././images/carousel-sprite.png?5) no-repeat;
- background-size: 16px 200px;
-}
-
-div.jp-carousel-buttons a.jp-carousel-reblog,
-div.jp-carousel-buttons a.jp-carousel-commentlink {
- margin: 0 0 0 14px !important;
-}
-
-div.jp-carousel-buttons a.jp-carousel-reblog.reblogged {
- background-color: #303030;
- padding-left: 8px !important;
- border-radius: 2px;
- border-radius: 2px;
- -webkit-border-radius:2px;
- -moz-border-radius:2px;
- -ms-border-radius:2px;
- -o-border-radius:2px;
-}
-
-div.jp-carousel-buttons a.jp-carousel-reblog.reblogged {
- margin: 0 -12px 0 2px !important;
-}
-
-div.jp-carousel-buttons a.jp-carousel-reblog,
-div.jp-carousel-buttons a.jp-carousel-reblog.reblogged:hover {
- background-position: 6px -36px;
- padding-left: auto !important;
- padding-right: 26px !important;
- color: #999;
-}
-
-div.jp-carousel-buttons a.jp-carousel-commentlink {
- background-position: 0px -156px;
- padding-right: 19px !important;
-}
-
-div.jp-carousel-buttons a.jp-carousel-reblog.reblogged:hover {
- cursor: default;
-}
-
-div.jp-carousel-buttons a.jp-carousel-reblog:hover {
- background-position: 6px -56px;
- color: #68c9e8;
-}
-
-@media
-only screen and (-webkit-min-device-pixel-ratio: 1.5),
-only screen and (-o-min-device-pixel-ratio: 3/2),
-only screen and (min--moz-device-pixel-ratio: 1.5),
-only screen and (min-device-pixel-ratio: 1.5) {
- div.jp-carousel-buttons a.jp-carousel-reblog,
- div.jp-carousel-buttons a.jp-carousel-commentlink,
- a.jp-carousel-image-download {
- background-image: url(.././images/carousel-sprite-2x.png?5);
- }
-}
-
-/* reblog */
-div#carousel-reblog-box {
- background: #222;
- background: -moz-linear-gradient(bottom, #222, #333);
- background: -webkit-gradient(linear, right bottom, right top, from(#222), to(#333));
- padding: 3px 0 0;
- display: none;
- margin: 5px auto 0;
- -moz-border-radius: 2px;
- -webkit-border-radius: 2px;
- border-radius: 2px;
- -webkit-box-shadow: 0 0 20px rgba(0,0,0,0.9);
- -moz-box-shadow: 0 0 20px rgba(0,0,0,0.9);
- box-shadow: 0 0 20px rgba(0,0,0,0.9);
- height: 74px;
- width: 565px;
-}
-
-#carousel-reblog-box textarea {
- background: #999;
- font: 13px/1.4 "Helvetica Neue", sans-serif !important;
- color: #444;
- padding: 3px 6px;
- width: 370px;
- height: 48px;
- float: right;
- margin: 6px 9px 0 9px;
- border: 1px solid #666;
- -webkit-box-shadow: inset 2px 2px 2px rgba(0,0,0,0.2);
- box-shadow: inset 2px 2px 2px rgba(0,0,0,0.2);
- -moz-border-radius: 2px;
- -webkit-border-radius: 2px;
- border-radius: 2px;
-}
-
-#carousel-reblog-box textarea:focus {
- background: #ccc;
- color: #222;
-}
-
-#carousel-reblog-box label {
- color: #aaa;
- font-size: 11px;
- padding-left: 2px;
- padding-right: 2px;
- display: inline;
- font-weight: normal;
-}
-
-#carousel-reblog-box select {
- width: 110px;
- padding: 0;
- font-size: 12px;
- font-family: "Helvetica Neue", sans-serif !important;
- background: #333;
- color: #eee;
- border: 1px solid #444;
- margin-top:5px;
-}
-
-#carousel-reblog-box .submit,
-#wrapper #carousel-reblog-box p.response {
- float: right;
- width: 154px;
- padding-top: 0;
- padding-right: 1px;
- overflow: hidden;
- height: 34px;
- margin:3px 2px 0 0 !important;
-}
-
-#wrapper #carousel-reblog-box p.response {
- font-size: 13px;
- clear: none;
- padding-right: 2px;
- height: 34px;
- color: #aaa;
-}
-
-#carousel-reblog-box input#carousel-reblog-submit, #jp-carousel-comment-form-button-submit {
- font: 13px/24px "Helvetica Neue", sans-serif !important;
- margin-top: 8px;
- padding: 0 10px !important;
- border-radius: 1em;
- height: 24px;
- color: #333;
- cursor:pointer;
- font-weight: normal;
- background: #aaa;
- background: -moz-linear-gradient(bottom, #aaa, #ccc);
- background: -webkit-gradient(linear, right bottom, right top, from(#aaa), to(#ccc));
- border: 1px solid #444;
-}
-
-#carousel-reblog-box input#carousel-reblog-submit:hover, #jp-carousel-comment-form-button-submit:hover {
- background: #ccc;
- background: -moz-linear-gradient(bottom, #ccc, #eee);
- background: -webkit-gradient(linear, right bottom, right top, from(#ccc), to(#eee));
-}
-
-#carousel-reblog-box .canceltext {
- color: #aaa;
- font-size: 11px;
- line-height: 24px;
-}
-
-#carousel-reblog-box .canceltext a {
- color: #fff;
-}
-/* reblog end */
-
-
-/** Title and Desc Start **/
-.jp-carousel-titleanddesc {
- border-top: 1px solid #222;
- color: #999;
- font-size: 15px;
- padding-top: 24px;
- margin-bottom: 20px;
- font-weight:400;
-}
-.jp-carousel-titleanddesc-title {
- font: 300 1.5em/1.1 "Helvetica Neue", sans-serif !important;
- text-transform: none !important; /* prevents uppercase from leaking through */
- color: #fff;
- margin: 0 0 15px;
- padding:0;
-}
-
-.jp-carousel-titleanddesc-desc p {
- color: #999;
- line-height:1.4;
- margin-bottom: 0.75em;
-}
-
-.jp-carousel-titleanddesc p a,
-.jp-carousel-comments p a,
-.jp-carousel-info h2 a {
- color: #fff !important;
- border: none !important;
- text-decoration: underline !important;
- font-weight: normal !important;
- font-style: normal !important;
-}
-
-.jp-carousel-titleanddesc p strong,
-.jp-carousel-titleanddesc p b {
- font-weight: bold;
- color: #999;
-}
-
-.jp-carousel-titleanddesc p em,
-.jp-carousel-titleanddesc p i {
- font-style: italic;
- color: #999;
-}
-
-
-.jp-carousel-titleanddesc p a:hover,
-.jp-carousel-comments p a:hover,
-.jp-carousel-info h2 a:hover {
- color: #68c9e8 !important;
-}
-
-.jp-carousel-titleanddesc p:empty {
- display: none;
-}
-
-.jp-carousel-photo-info h1:before,
-.jp-carousel-photo-info h1:after,
-.jp-carousel-left-column-wrapper h1:before,
-.jp-carousel-left-column-wrapper h1:after {
- content:none !important;
-}
-/** Title and Desc End **/
-
-/** Meta Box Start **/
-.jp-carousel-image-meta {
- background: #111;
- border: 1px solid #222;
- color: #fff;
- font-size: 13px;
- font: 12px/1.4 "Helvetica Neue", sans-serif !important;
- overflow: hidden;
- padding: 18px 20px;
- width: 209px !important;
-}
-
-.jp-carousel-image-meta li,
-.jp-carousel-image-meta h5 {
- font-family: "Helvetica Neue", sans-serif !important;
- position: inherit !important;
- top: auto !important;
- left: auto !important;
- right: auto !important;
- bottom: auto !important;
- background: none !important;
- border: none !important;
- font-weight: 400 !important;
- line-height: 1.3em !important;
-}
-
-.jp-carousel-image-meta ul {
- margin: 0 !important;
- padding: 0 !important;
- list-style: none !important;
-}
-
-.jp-carousel-image-meta li {
- width: 48% !important;
- float: right !important;
- margin: 0 0 15px 2% !important;
- color: #fff !important;
- font-size:13px !important;
-}
-
-.jp-carousel-image-meta h5 {
- color: #999 !important;
- text-transform: uppercase !important;
- font-size:10px !important;
- margin:0 0 2px !important;
- letter-spacing: 0.1em !important;
-}
-
-a.jp-carousel-image-download {
- padding-right: 23px;
- display: inline-block;
- clear: both;
- color: #999;
- line-height: 1;
- font-weight: 400;
- font-size: 13px;
- text-decoration: none;
- background-position: 0 -82px;
-}
-
-a.jp-carousel-image-download span.photo-size {
- font-size: 11px;
- border-radius: 1em;
- margin-right: 2px;
- display: inline-block;
-}
-
-a.jp-carousel-image-download span.photo-size-times {
- padding: 0 2px 0 1px;
-}
-
-a.jp-carousel-image-download:hover {
- background-position: 0 -122px;
- color: #68c9e8;
- border: none !important;
-}
-
-/** Meta Box End **/
-
-/** GPS Map Start **/
-.jp-carousel-image-map {
- position: relative;
- margin: -20px -20px 20px;
- border-bottom: 1px solid rgba( 255, 255, 255, 0.17 );
- height: 154px;
-}
-
-.jp-carousel-image-map img.gmap-main {
- -moz-border-radius-topleft: 6px;
- border-top-right-radius: 6px;
- border-left: 1px solid rgba( 255, 255, 255, 0.17 );
-}
-.jp-carousel-image-map div.gmap-topright {
- width: 94px;
- height: 154px;
- position: absolute;
- top: 0;
- left: 0;
-}
-.jp-carousel-image-map div.imgclip {
- overflow: hidden;
- -moz-border-radius-topright: 6px;
- border-top-left-radius: 6px;
-}
-.jp-carousel-image-map div.gmap-topright img {
- margin-right: -40px;
-}
-.jp-carousel-image-map img.gmap-bottomright {
- position: absolute;
- top: 96px;
- left: 0;
-}
-
-/** Comments Start **/
-.jp-carousel-comments {
- font: 15px/1.7 "Helvetica Neue", sans-serif !important;
- font-weight: 400;
- background:none transparent;
-}
-
-.jp-carousel-comments p a:hover, .jp-carousel-comments p a:focus, .jp-carousel-comments p a:active {
- color: #68c9e8 !important;
-}
-
-.jp-carousel-comment {
- background:none transparent;
- color: #999;
- margin-bottom: 20px;
- clear:right;
- overflow: auto;
- width: 100%
-}
-
-.jp-carousel-comment p {
- color: #999 !important;
-}
-
-.jp-carousel-comment .comment-author {
- font-size: 13px;
- font-weight:400;
- padding:0;
- width:auto;
- display: inline;
- float:none;
- border:none;
- margin:0;
-}
-
-.jp-carousel-comment .comment-author a {
- color: #fff;
-}
-
-.jp-carousel-comment .comment-gravatar {
- float:right;
-}
-
-.jp-carousel-comment .comment-content {
- border:none;
- margin-right:85px;
- padding: 0;
-}
-
-.jp-carousel-comment .avatar {
- margin:0 0 0 20px;
- -moz-border-radius: 4px;
- -webkit-border-radius: 4px;
- border-radius: 4px;
- border: none !important;
- padding: 0 !important;
- background-color: transparent !important;
-}
-
-.jp-carousel-comment .comment-date {
- color:#999;
- margin-top: 4px;
- font-size:11px;
- display: inline;
- float: left;
- /*clear: right;*/
-}
-
-#jp-carousel-comment-form {
- margin:0 0 10px !important;
- float: right;
- width: 100%;
-}
-
-textarea#jp-carousel-comment-form-comment-field {
- background: rgba(34,34,34,0.9);
- border: 1px solid #3a3a3a;
- color: #aaa;
- font: 15px/1.4 "Helvetica Neue", sans-serif !important;
- width: 100%;
- padding: 10px 10px 5px;
- margin: 0;
- float: none;
- height: 147px;
- -webkit-box-shadow: inset 2px 2px 2px rgba(0,0,0,0.2);
- box-shadow: inset 2px 2px 2px rgba(0,0,0,0.2);
- -moz-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
- overflow: hidden;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
-}
-
-textarea#jp-carousel-comment-form-comment-field::-webkit-input-placeholder {
- color: #555;
-}
-
-textarea#jp-carousel-comment-form-comment-field:focus {
- background: #ccc;
- color: #222;
-}
-
-textarea#jp-carousel-comment-form-comment-field:focus::-webkit-input-placeholder {
- color: #aaa;
-}
-
-#jp-carousel-comment-form-spinner {
- color: #fff;
- margin:22px 10px 0 0;
- display: block;
- width: 20px;
- height: 20px;
- float: right;
-}
-
-#jp-carousel-comment-form-submit-and-info-wrapper {
- display: none;
- /*margin-bottom:15px;*/
- overflow: hidden;
- width: 100%
-}
-
-#jp-carousel-comment-form-commenting-as {
-}
-
-#jp-carousel-comment-form-commenting-as input {
- background: rgba(34,34,34,0.9);
- border: 1px solid #3a3a3a;
- color: #aaa;
- font: 13px/1.4 "Helvetica Neue", sans-serif !important;
- padding: 3px 6px;
- float: right;
- -webkit-box-shadow: inset 2px 2px 2px rgba(0,0,0,0.2);
- box-shadow: inset 2px 2px 2px rgba(0,0,0,0.2);
- -moz-border-radius: 2px;
- -webkit-border-radius: 2px;
- border-radius: 2px;
- width:285px;
-}
-
-#jp-carousel-comment-form-commenting-as input:focus {
- background: #ccc;
- color: #222;
-}
-
-#jp-carousel-comment-form-commenting-as p {
- font: 400 13px/1.7 "Helvetica Neue", sans-serif !important;
- margin:22px 0 0;
- float: right;
-}
-
-#jp-carousel-comment-form-commenting-as fieldset {
- float:right;
- border:none;
- margin:20px 0 0 0;
- padding:0;
-}
-
-#jp-carousel-comment-form-commenting-as fieldset {
- clear: both;
-}
-
-#jp-carousel-comment-form-commenting-as label {
- font: 400 13px/1.7 "Helvetica Neue", sans-serif !important;
- margin:0 0 3px 20px;
- float:right;
- width:100px;
-}
-
-#jp-carousel-comment-form-button-submit {
- margin-top: 20px;
- float:left;
-}
-
-#js-carousel-comment-form-container {
- margin-bottom:15px;
- overflow: auto;
- width: 100%;
-}
-
-#jp-carousel-comment-form-container {
- margin-bottom:15px;
- overflow: auto;
- width: 100%;
-}
-
-#jp-carousel-comment-post-results {
- display: none;
- overflow:auto;
- width:100%;
-}
-
-#jp-carousel-comment-post-results span {
- display:block;
- text-align: center;
- margin-top:20px;
- width: 100%;
- overflow: auto;
- padding: 1em 0;
- box-sizing: border-box;
- background: rgba( 0, 0, 0, 0.7 );
- border-radius: 2px;
- font: 13px/1.4 "Helvetica Neue", sans-serif !important;
- border: 1px solid rgba( 255, 255, 255, 0.17 );
- -webkit-box-shadow: inset 0px 5px 5px 0px rgba(0, 0, 0, 1);
- box-shadow: inset 0px 5px 5px 0px rgba(0, 0, 0, 1);
-}
-
-.jp-carousel-comment-post-error {
- color:#DF4926;
-}
-
-.jp-carousel-comment-post-success {
- /*color:#21759B;*/
-}
-
-#jp-carousel-comments-closed {
- display: none;
- color: #999;
-}
-
-#jp-carousel-comments-loading {
- font: 400 15px/1.7 "Helvetica Neue", sans-serif !important;
- display: none;
- color: #999;
- text-align: right;
- margin-bottom: 20px;
-}
-
-
-/* ----- Light variant ----- */
-
-.jp-carousel-light .jp-carousel-overlay {
- background: #fff;
-}
-
-.jp-carousel-light .jp-carousel-next-button:hover span,
-.jp-carousel-light .jp-carousel-previous-button:hover span {
- opacity: 0.8;
-}
-
-.jp-carousel-light .jp-carousel-close-hint:hover,
-.jp-carousel-light .jp-carousel-titleanddesc div {
- color: #000 !important;
-}
-
-.jp-carousel-light .jp-carousel-comments p a,
-.jp-carousel-light .jp-carousel-comment .comment-author a,
-.jp-carousel-light .jp-carousel-titleanddesc p a,
-.jp-carousel-light .jp-carousel-titleanddesc p a,
-.jp-carousel-light .jp-carousel-comments p a,
-.jp-carousel-light .jp-carousel-info h2 a {
- color: #1e8cbe !important;
-}
-
-.jp-carousel-light .jp-carousel-comments p a:hover,
-.jp-carousel-light .jp-carousel-comment .comment-author a:hover,
-.jp-carousel-light .jp-carousel-titleanddesc p a:hover,
-.jp-carousel-light .jp-carousel-titleanddesc p a:hover,
-.jp-carousel-light .jp-carousel-comments p a:hover,
-.jp-carousel-light .jp-carousel-info h2 a:hover {
- color: #f1831e !important;
-}
-
-.jp-carousel-light .jp-carousel-info h2,
-.jp-carousel-light .jp-carousel-titleanddesc,
-.jp-carousel-light .jp-carousel-titleanddesc p,
-.jp-carousel-light .jp-carousel-comment,
-.jp-carousel-light .jp-carousel-comment p,
-.jp-carousel-light div.jp-carousel-buttons a,
-.jp-carousel-light .jp-carousel-titleanddesc p strong,
-.jp-carousel-light .jp-carousel-titleanddesc p b,
-.jp-carousel-light .jp-carousel-titleanddesc p em,
-.jp-carousel-light .jp-carousel-titleanddesc p i {
- color: #666;
-}
-
-.jp-carousel-light .jp-carousel-buttons {
- border-bottom-color: #f0f0f0;
- background: #f5f5f5;
-}
-
-.jp-carousel-light div.jp-carousel-buttons a:hover {
- text-decoration: none;
- color: #f1831e;
-}
-
-.jp-carousel-light div.jp-carousel-buttons a.jp-carousel-reblog,
-.jp-carousel-light div.jp-carousel-buttons a.jp-carousel-reblog:hover {
- background-position: 4px -56px;
- padding-right: 24px !important;
-}
-
-.jp-carousel-light div.jp-carousel-buttons a.jp-carousel-reblog.reblogged {
- background-color: #2ea2cc;
- color: #fff;
-}
-
-.jp-carousel-light div.jp-carousel-buttons a.jp-carousel-commentlink {
- background-position: 0px -176px;
-}
-
-.jp-carousel-light div.jp-carousel-buttons a.jp-carousel-reblog.reblogged {
- background-position: 5px -36px;
-}
-
-.jp-carousel-light div#carousel-reblog-box {
- background: #eee;
- background: -moz-linear-gradient(bottom, #ececec, #f7f7f7);
- background: -webkit-gradient(linear, right bottom, right top, from(#ececec), to(#f7f7f7));
- -webkit-box-shadow: 0 2px 6px rgba(0,0,0,0.1);
- -moz-box-shadow: 0 2px 10px rgba(0,0,0,0.1);
- box-shadow: 0 2px 10px rgba(0,0,0,0.1);
- border:1px solid #ddd;
-}
-
-.jp-carousel-light #carousel-reblog-box textarea {
- border: 1px inset #ccc;
- color: #666;
- border: 1px solid #cfcfcf;
- background: #fff;
-}
-
-.jp-carousel-light #carousel-reblog-box .canceltext {
- color: #888;
-}
-
-.jp-carousel-light #carousel-reblog-box .canceltext a {
- color: #666;
-}
-
-.jp-carousel-light #carousel-reblog-box select {
- background: #eee;
- color: #333;
- border: 1px solid #aaa;
-}
-
-.jp-carousel-light #carousel-reblog-box input#carousel-reblog-submit, #jp-carousel-comment-form-button-submit {
- color: #333;
- background: #fff;
- background: -moz-linear-gradient(bottom, #ddd, #fff);
- background: -webkit-gradient(linear, right bottom, right top, from(#ddd), to(#fff));
- border: 1px solid #aaa;
-}
-
-.jp-carousel-light .jp-carousel-image-meta {
- background: #fafafa;
- border: 1px solid #eee;
- border-top-color: #f5f5f5;
- border-right-color: #f5f5f5;
- color: #333;
-}
-
-.jp-carousel-light .jp-carousel-image-meta li {
- color: #000 !important;
-}
-
-.jp-carousel-light .jp-carousel-close-hint {
- color: #ccc;
-}
-
-.jp-carousel-light .jp-carousel-close-hint span {
- background-color: white;
- border-color: #ccc;
-}
-
-.jp-carousel-light #jp-carousel-comment-form-comment-field::-webkit-input-placeholder {
- color: #aaa;
-}
-
-.jp-carousel-light #jp-carousel-comment-form-comment-field:focus {
- color: #333;
-}
-
-.jp-carousel-light #jp-carousel-comment-form-comment-field:focus::-webkit-input-placeholder {
- color: #ddd;
-}
-
-.jp-carousel-light a.jp-carousel-image-download {
- background-position: 0 -122px;
-}
-
-.jp-carousel-light a.jp-carousel-image-download:hover {
- background-position: 0 -122px;
- color: #f1831e;
-}
-
-.jp-carousel-light textarea#jp-carousel-comment-form-comment-field {
- background: #fbfbfb;
- color: #333;
- border: 1px solid #dfdfdf;
- -webkit-box-shadow: inset 2px 2px 2px rgba(0,0,0,0.1);
- box-shadow: inset 2px 2px 2px rgba(0,0,0,0.1);
-}
-
-.jp-carousel-light #jp-carousel-comment-form-commenting-as input {
- background: #fbfbfb;
- border: 1px solid #dfdfdf;
- color: #333;
- -webkit-box-shadow: inset 2px 2px 2px rgba(0,0,0,0.1);
- box-shadow: inset 2px 2px 2px rgba(0,0,0,0.1);
-}
-
-.jp-carousel-light #jp-carousel-comment-form-commenting-as input:focus {
- background: #fbfbfb;
- color: #333;
-}
-
-.jp-carousel-light #jp-carousel-comment-post-results span {
- background: #f7f7f7;
- border:1px solid #dfdfdf;
- -webkit-box-shadow: inset 0px 0px 5px rgba(0, 0, 0, 0.05);
- box-shadow: inset 0px 0px 5px rgba(0, 0, 0, 0.05);
-}
-
-.jp-carousel-light .jp-carousel-slide {
- background-color:#fff;
-}
-
-.jp-carousel-light .jp-carousel-titleanddesc {
- border-top: 1px solid #eee;
-}
-
-.jp-carousel-light .jp-carousel-fadeaway {
- background: -moz-linear-gradient(bottom, rgba(255,255,255,0.75), rgba(255,255,255,0));
- background: -webkit-gradient(linear, right bottom, right top, from(rgba(255,255,255,0.75)), to(rgba(255,255,255,0)));
-}
-
-/* Small screens */
-@media only screen and (max-width: 760px) {
-
- .jp-carousel-info {
- margin: 0 10px !important;
- }
-
- .jp-carousel-next-button, .jp-carousel-previous-button {
- display: none !important;
- }
-
- .jp-carousel-buttons {
- display: none !important;
- }
-
- .jp-carousel-image-meta {
- float: none !important;
- width: 100% !important;
- -moz-box-sizing:border-box;
- -webkit-box-sizing:border-box;
- box-sizing: border-box;
- }
-
- .jp-carousel-close-hint {
- font-weight: 800 !important;
- font-size: 26px !important;
- position: fixed !important;
- top: -10px;
- }
-
- .jp-carousel-slide img {
- filter: alpha(opacity=100);
- opacity: 1;
- }
-
- .jp-carousel-wrap {
- background-color: #000;
- }
-
- .jp-carousel-fadeaway {
- display: none;
- }
-
- #jp-carousel-comment-form-container {
- display: none !important;
- }
-
- .jp-carousel-titleanddesc {
- padding-top: 0 !important;
- border: none !important;
- }
- .jp-carousel-titleanddesc-title {
- font-size: 1em !important;
- }
-
- .jp-carousel-left-column-wrapper {
- padding: 0;
- width: 100% !important;
- }
-
- .jp-carousel-photo-info {
- right: 0 !important;
- width: 100% !important;
- }
-}
diff --git a/plugins/jetpack/modules/cloudflare-analytics/cloudflare-analytics.php b/plugins/jetpack/modules/cloudflare-analytics/cloudflare-analytics.php
index 63b2a814..ee57cc08 100644
--- a/plugins/jetpack/modules/cloudflare-analytics/cloudflare-analytics.php
+++ b/plugins/jetpack/modules/cloudflare-analytics/cloudflare-analytics.php
@@ -25,6 +25,7 @@ function insert_tracking_id() {
&& ( class_exists( 'Jetpack_AMP_Support' ) && ! \Jetpack_AMP_Support::is_amp_request() )
&& ( ( defined( 'IS_WPCOM' ) && IS_WPCOM ) || ( new Host() )->is_woa_site() )
) {
+ // phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript
printf(
"<!-- Jetpack Cloudflare Web Analytics -->
<script defer
@@ -34,6 +35,7 @@ function insert_tracking_id() {
<!-- End Jetpack Cloudflare Web Analytics -->\r\n",
esc_html( $option['code'] )
);
+ // phpcs:enable WordPress.WP.EnqueuedResources.NonEnqueuedScript
}
}
add_action( 'wp_footer', __NAMESPACE__ . '\insert_tracking_id', 999 );
diff --git a/plugins/jetpack/modules/comments.php b/plugins/jetpack/modules/comments.php
index 6da9f924..1e28523b 100644
--- a/plugins/jetpack/modules/comments.php
+++ b/plugins/jetpack/modules/comments.php
@@ -1,14 +1,14 @@
<?php
/**
* Module Name: Comments
- * Module Description: Let visitors use a WordPress.com, Twitter, Facebook, or Google account to comment
+ * Module Description: Let visitors use a WordPress.com, Twitter, or Facebook account to comment
* First Introduced: 1.4
* Sort Order: 20
* Requires Connection: Yes
* Auto Activate: No
* Module Tags: Social
* Feature: Engagement
- * Additional Search Queries: comments, comment, facebook, twitter, google+, social
+ * Additional Search Queries: comments, comment, facebook, twitter, social
*
* @package automattic/jetpack
*/
diff --git a/plugins/jetpack/modules/comments/admin.php b/plugins/jetpack/modules/comments/admin.php
index 59300465..208b7ee7 100644
--- a/plugins/jetpack/modules/comments/admin.php
+++ b/plugins/jetpack/modules/comments/admin.php
@@ -1,26 +1,41 @@
-<?php
-
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Jetpack comments admin menu file.
+ *
+ * @package automattic/jetpack
+ */
+/**
+ * Class Jetpack_Comments_Settings
+ * This class represents the comments settings functionality.
+ */
class Jetpack_Comments_Settings {
/** Variables *************************************************************/
/**
- * The Jetpack Coments singleton
+ * The Jetpack Comments singleton
+ *
+ * @var Highlander_Comments_Base
*/
public $jetpack_comments;
/**
- * The default comment form greeting
+ * The default comment form greeting - blank to start with
+ *
* @var string
*/
- public $default_greeting = ''; // Set in constructor
+ public $default_greeting = ''; // Set in constructor.
/**
- * The default comment form color scheme
+ * The default comment form color scheme - an empty array to start with
+ *
* @var string
*/
public $color_schemes = array();
+ /**
+ * Initialize class
+ */
public static function init() {
static $instance = false;
@@ -31,25 +46,31 @@ class Jetpack_Comments_Settings {
return $instance;
}
+ /**
+ * Constructor
+ *
+ * @param Highlander_Comments_Base $jetpack_comments The Jetpack Comments singleton.
+ */
public function __construct( Highlander_Comments_Base $jetpack_comments ) {
$this->jetpack_comments = $jetpack_comments;
- // Setup settings
+ // Setup settings.
add_action( 'admin_init', array( $this, 'add_settings' ) );
$this->setup_globals();
}
- /** Private Methods *******************************************************/
+ /** Private Methods ****************************************************** */
/**
* Set any global variables or class variables
+ *
* @since JetpackComments (1.4)
*/
protected function setup_globals() {
- // Default option values
+ // Default option values.
$this->default_greeting = __( 'Leave a Reply', 'jetpack' );
- // Possible color schemes
+ // Possible color schemes.
$this->color_schemes = array(
'light' => __( 'Light', 'jetpack' ),
'dark' => __( 'Dark', 'jetpack' ),
@@ -57,7 +78,7 @@ class Jetpack_Comments_Settings {
);
}
- /** Settings **************************************************************/
+ /** Settings ************************************************************* */
/**
* Add the Jetpack settings to WordPress's discussions page
@@ -66,7 +87,7 @@ class Jetpack_Comments_Settings {
*/
public function add_settings() {
- // Create the section
+ // Create the section.
add_settings_section(
'jetpack_comment_form',
__( 'Comments', 'jetpack' ),
@@ -74,8 +95,9 @@ class Jetpack_Comments_Settings {
'discussion'
);
- /** Clever Greeting ***************************************************/
-
+ /**
+ * Clever Greeting
+ */
add_settings_field(
'highlander_comment_form_prompt',
__( 'Greeting Text', 'jetpack' ),
@@ -90,8 +112,9 @@ class Jetpack_Comments_Settings {
array( $this, 'comment_form_greeting_sanitize' )
);
- /** Color Scheme ******************************************************/
-
+ /**
+ * Color Scheme
+ */
add_settings_field(
'jetpack_comment_form_color_scheme',
__( 'Color Scheme', 'jetpack' ),
@@ -113,11 +136,11 @@ class Jetpack_Comments_Settings {
* @since JetpackComments (1.4)
*/
public function comment_form_settings_section() {
- ?>
+ ?>
- <p id="jetpack-comments-settings"><?php _e( 'Adjust your Comments form with a clever greeting and color-scheme.', 'jetpack' ); ?></p>
+ <p id="jetpack-comments-settings"><?php esc_html_e( 'Adjust your Comments form with a clever greeting and color-scheme.', 'jetpack' ); ?></p>
- <?php
+ <?php
}
/**
@@ -127,27 +150,27 @@ class Jetpack_Comments_Settings {
*/
public function comment_form_greeting_setting() {
- // The greeting
+ // The greeting.
$greeting = get_option( 'highlander_comment_form_prompt', $this->default_greeting );
?>
<input type="text" name="highlander_comment_form_prompt" id="jetpack-comment-form-greeting" value="<?php echo esc_attr( $greeting ); ?>" class="regular-text">
- <p class="description"><?php _e( 'A few catchy words to motivate your readers to comment', 'jetpack' ); ?></p>
+ <p class="description"><?php esc_html_e( 'A few catchy words to motivate your readers to comment', 'jetpack' ); ?></p>
- <?php
+ <?php
}
/**
* Sanitize the clever comment greeting
*
* @since JetpackComments (1.4)
- * @param type $val
+ * @param string $val The contact form greeting string.
* @return string
*/
- function comment_form_greeting_sanitize( $val ) {
+ public function comment_form_greeting_sanitize( $val ) {
- // Delete if empty or the default
- if ( empty( $val ) || ( $this->default_greeting == $val ) ) {
+ // Delete if empty or the default.
+ if ( empty( $val ) || ( $this->default_greeting === $val ) ) {
delete_option( 'highlander_comment_form_prompt' );
return false;
}
@@ -156,24 +179,24 @@ class Jetpack_Comments_Settings {
}
/**
- * Color Scheme Setting
+ * Comment Form Color Scheme Setting
*
* @since JetpackComments (1.4)
*/
public function comment_form_color_scheme_setting() {
- // The color scheme
+ // The color scheme.
$scheme = get_option( 'jetpack_comment_form_color_scheme', $this->jetpack_comments->default_color_scheme );
?>
<fieldset>
- <legend class="screen-reader-text"><?php _e( 'Color Scheme', 'jetpack' ); ?></legend>
+ <legend class="screen-reader-text"><?php esc_html_e( 'Color Scheme', 'jetpack' ); ?></legend>
<?php foreach ( $this->color_schemes as $key => $label ) : ?>
<label>
- <input type="radio" name="jetpack_comment_form_color_scheme" id="jetpack-comment-form-color-scheme" value="<?php echo $key; ?>" <?php checked( $scheme, $key ); ?>>
- <?php echo $label; ?>
+ <input type="radio" name="jetpack_comment_form_color_scheme" id="jetpack-comment-form-color-scheme" value="<?php echo esc_attr( $key ); ?>" <?php checked( $scheme, $key ); ?>>
+ <?php echo esc_attr( $label ); ?>
</label>
<br />
@@ -181,23 +204,23 @@ class Jetpack_Comments_Settings {
</fieldset>
- <?php
+ <?php
}
/**
* Sanitize the color scheme
*
* @since JetpackComments (1.4)
- * @param type $val
+ * @param string $val The color scheme string.
* @return string
*/
public function comment_form_color_scheme_sanitize( $val ) {
- // Delete the option if it's...
+ // Delete the option if it's unknown, or the default.
if (
- empty( $val ) || ! in_array( $val, array_keys( $this->color_schemes ) ) // ... unknown
+ empty( $val ) || ! array_key_exists( $val, $this->color_schemes )
||
- $val == $this->jetpack_comments->default_color_scheme // ... or the default
+ $val === $this->jetpack_comments->default_color_scheme
) {
delete_option( 'jetpack_comment_form_color_scheme' );
return false;
diff --git a/plugins/jetpack/modules/comments/base.php b/plugins/jetpack/modules/comments/base.php
index f6f9834a..df3e462a 100644
--- a/plugins/jetpack/modules/comments/base.php
+++ b/plugins/jetpack/modules/comments/base.php
@@ -1,10 +1,18 @@
-<?php
-
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Jetpack comments base file - where the code shared between WP.com Highlander and Jetpack Highlander is defined
+ *
+ * @package automattic/jetpack
+ */
/**
* All the code shared between WP.com Highlander and Jetpack Highlander
*/
class Highlander_Comments_Base {
- function __construct() {
+
+ /**
+ * Constructor
+ */
+ public function __construct() {
$this->setup_globals();
$this->setup_actions();
$this->setup_filters();
@@ -12,24 +20,27 @@ class Highlander_Comments_Base {
/**
* Set any global variables or class variables
+ *
* @since JetpackComments (1.4)
*/
protected function setup_globals() {}
/**
* Setup actions for methods in this class
+ *
* @since JetpackComments (1.4)
*/
protected function setup_actions() {
- // Before a comment is posted
+ // Before a comment is posted.
add_action( 'pre_comment_on_post', array( $this, 'allow_logged_out_user_to_comment_as_external' ) );
- // After a comment is posted
+ // After a comment is posted.
add_action( 'comment_post', array( $this, 'set_comment_cookies' ) );
}
/**
* Setup filters for methods in this class
+ *
* @since JetpackComments (1.4)
*/
protected function setup_filters() {
@@ -41,38 +52,42 @@ class Highlander_Comments_Base {
* Is this a Highlander POST request?
* Optionally restrict to one or more credentials slug (facebook, twitter, ...)
*
- * @param string Comment credentials slug
- * @param ...
+ * @param mixed ...$args Comments credentials slugs.
* @return false|string false if it's not a Highlander POST request. The matching credentials slug if it is.
*/
- function is_highlander_comment_post( ...$args ) {
+ public function is_highlander_comment_post( ...$args ) {
+
+ // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verification should happen in Jetpack_Comments::pre_comment_on_post(). Internal ref for details: p1645643468937519/1645189749.180299-slack-C02HQGKMFJ8
if ( empty( $_POST['hc_post_as'] ) ) {
return false;
}
+ $hc_post_as = wp_unslash( $_POST['hc_post_as'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized here by comparing against known values.
+ // phpcs:enable WordPress.Security.NonceVerification.Missing
if ( $args ) {
foreach ( $args as $id_source ) {
- if ( $id_source === $_POST['hc_post_as'] ) {
+ if ( $id_source === $hc_post_as ) {
return $id_source;
}
}
return false;
}
-
- return is_string( $_POST['hc_post_as'] ) && in_array( $_POST['hc_post_as'], $this->id_sources ) ? $_POST['hc_post_as'] : false;
+ return is_string( $hc_post_as ) && in_array( $hc_post_as, $this->id_sources, true ) ? $hc_post_as : false;
}
/**
* Signs an array of scalars with the self-hosted blog's Jetpack Token
*
- * @param array $parameters
- * @param string $key
+ * If parameter values are not scalars a WP_Error is returned, otherwise a keyed hash value is returned using the HMAC method.
+ *
+ * @param array $parameters Comment parameters.
+ * @param string $key Key used for generating the HMAC variant of the message digest.
* @return string HMAC
*/
- static function sign_remote_comment_parameters( $parameters, $key ) {
+ public static function sign_remote_comment_parameters( $parameters, $key ) {
unset(
- $parameters['sig'], // Don't sign the signature
- $parameters['replytocom'] // This parameter is unsigned - it changes dynamically as the comment form moves from parent comment to parent comment
+ $parameters['sig'], // Don't sign the signature.
+ $parameters['replytocom'] // This parameter is unsigned - it changes dynamically as the comment form moves from parent comment to parent comment.
);
ksort( $parameters );
@@ -89,18 +104,18 @@ class Highlander_Comments_Base {
return hash_hmac( 'sha1', implode( ':', $signing ), $key );
}
- /*
- * After commenting as a guest while logged in, the user needs to see both:
+ /**
+ * Adds comment author email and whether the comment is approved to the comments array
*
+ * After commenting as a guest while logged in, the user needs to see both:
* ( user_id = blah AND comment_approved = 0 )
- * and
- * ( comment_author_email = blah AND comment_approved = 0 )
+ * and ( comment_author_email = blah AND comment_approved = 0 )
+ * Core only does the first since the user is logged in, so this adds the second to the comments array.
*
- * Core only does the first since the user is logged in.
- *
- * Add the second to the comments array.
- */
- function comments_array( $comments ) {
+ * @param array $comments All comment data.
+ * @return array A modified array of comment data.
+ */
+ public function comments_array( $comments ) {
global $wpdb, $post;
$commenter = $this->get_current_commenter();
@@ -137,12 +152,12 @@ class Highlander_Comments_Base {
* Comment sort comparator: comment_date_gmt
*
* @since JetpackComments (1.4)
- * @param object $a
- * @param object $b
+ * @param object $a The first comment to compare dates with.
+ * @param object $b The second comment to compare dates with.
* @return int
*/
public function sort_comments_by_comment_date_gmt( $a, $b ) {
- if ( $a->comment_date_gmt == $b->comment_date_gmt ) {
+ if ( $a->comment_date_gmt === $b->comment_date_gmt ) {
return 0;
}
@@ -156,22 +171,22 @@ class Highlander_Comments_Base {
* @return array Commenters information from cookie
*/
protected function get_current_commenter() {
- // Defaults
+ // Defaults.
$user_id = 0;
$comment_author = '';
$comment_author_email = '';
$comment_author_url = '';
if ( isset( $_COOKIE[ 'comment_author_' . COOKIEHASH ] ) ) {
- $comment_author = $_COOKIE[ 'comment_author_' . COOKIEHASH ];
+ $comment_author = sanitize_text_field( wp_unslash( $_COOKIE[ 'comment_author_' . COOKIEHASH ] ) );
}
if ( isset( $_COOKIE[ 'comment_author_email_' . COOKIEHASH ] ) ) {
- $comment_author_email = $_COOKIE[ 'comment_author_email_' . COOKIEHASH ];
+ $comment_author_email = sanitize_email( wp_unslash( $_COOKIE[ 'comment_author_email_' . COOKIEHASH ] ) );
}
if ( isset( $_COOKIE[ 'comment_author_url_' . COOKIEHASH ] ) ) {
- $comment_author_url = $_COOKIE[ 'comment_author_url_' . COOKIEHASH ];
+ $comment_author_url = esc_url_raw( wp_unslash( $_COOKIE[ 'comment_author_url_' . COOKIEHASH ] ) );
}
if ( is_user_logged_in() ) {
@@ -187,10 +202,9 @@ class Highlander_Comments_Base {
* Overrides WordPress' core comment_registration option to treat these commenters as "registered" (verified) users.
*
* @since JetpackComments (1.4)
- * @return If no
*/
- function allow_logged_out_user_to_comment_as_external() {
- if ( ! $this->is_highlander_comment_post( 'facebook', 'twitter', 'googleplus' ) ) {
+ public function allow_logged_out_user_to_comment_as_external() {
+ if ( ! $this->is_highlander_comment_post( 'facebook', 'twitter' ) ) {
return;
}
@@ -204,22 +218,22 @@ class Highlander_Comments_Base {
* Respects comment_registration option.
*
* @since JetpackComments (1.4)
- * @param array $comment_data
- * @return int
+ * @param array $comment_data All data for a specific comment.
+ * @return array Modified comment data, or an error if the required fields or a valid email address are not entered.
*/
- function allow_logged_in_user_to_comment_as_guest( $comment_data ) {
- // Bail if user registration is allowed
+ public function allow_logged_in_user_to_comment_as_guest( $comment_data ) {
+ // Bail if user registration is allowed.
if ( get_option( 'comment_registration' ) ) {
return $comment_data;
}
- // Bail if user is not logged in or not a post request
- if ( 'POST' != strtoupper( $_SERVER['REQUEST_METHOD'] ) || ! is_user_logged_in() ) {
+ // Bail if user is not logged in or not a post request.
+ if ( ! isset( $_SERVER['REQUEST_METHOD'] ) || 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) || ! is_user_logged_in() ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- simple comparison
return $comment_data;
}
- // Bail if this is not a guest or external service credentialed request
- if ( ! $this->is_highlander_comment_post( 'guest', 'facebook', 'twitter', 'googleplus' ) ) {
+ // Bail if this is not a guest or external service credentialed request.
+ if ( ! $this->is_highlander_comment_post( 'guest', 'facebook', 'twitter' ) ) {
return $comment_data;
}
@@ -230,16 +244,18 @@ class Highlander_Comments_Base {
'comment_author_email' => 'user_email',
'comment_author_url' => 'user_url',
) as $comment_field => $user_field ) {
- if ( $comment_data[ $comment_field ] != addslashes( $user->$user_field ) ) {
- return $comment_data; // some other plugin already did something funky
+ if ( addslashes( $user->$user_field ) !== $comment_data[ $comment_field ] ) {
+ return $comment_data; // some other plugin already did something funky.
}
}
+ // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verification should happen in Jetpack_Comments::pre_comment_on_post()
+ // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitization too
if ( get_option( 'require_name_email' ) ) {
- if ( 6 > strlen( $_POST['email'] ) || empty( $_POST['author'] ) ) {
- wp_die( __( 'Error: please fill the required fields (name, email).', 'jetpack' ), 400 );
- } elseif ( ! is_email( $_POST['email'] ) ) {
- wp_die( __( 'Error: please enter a valid email address.', 'jetpack' ), 400 );
+ if ( isset( $_POST['email'] ) && 6 > strlen( wp_unslash( $_POST['email'] ) ) || empty( $_POST['author'] ) ) {
+ wp_die( esc_html__( 'Error: please fill the required fields (name, email).', 'jetpack' ), 400 );
+ } elseif ( ! isset( $_POST['email'] ) || ! is_email( wp_unslash( $_POST['email'] ) ) ) {
+ wp_die( esc_html__( 'Error: please enter a valid email address.', 'jetpack' ), 400 );
}
}
@@ -249,15 +265,17 @@ class Highlander_Comments_Base {
'comment_author_email' => 'email',
'comment_author_url' => 'url',
) as $comment_field => $post_field ) {
- if ( $comment_data[ $comment_field ] != $_POST[ $post_field ] && 'url' != $post_field ) {
+ if ( ( ! isset( $_POST[ $post_field ] ) || $comment_data[ $comment_field ] !== $_POST[ $post_field ] ) && 'url' !== $post_field ) {
$author_change = true;
}
- $comment_data[ $comment_field ] = $_POST[ $post_field ];
+ $comment_data[ $comment_field ] = isset( $_POST[ $post_field ] ) ? wp_unslash( $_POST[ $post_field ] ) : null;
}
+ // phpcs:enable WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
- // Mark as guest comment if name or email were changed
+ // Mark as guest comment if name or email were changed.
if ( $author_change ) {
- $comment_data['user_id'] = $comment_data['user_ID'] = 0;
+ $comment_data['user_ID'] = 0;
+ $comment_data['user_id'] = $comment_data['user_ID'];
}
return $comment_data;
@@ -267,11 +285,10 @@ class Highlander_Comments_Base {
* Set the comment cookies or bail if comment is invalid
*
* @since JetpackComments (1.4)
- * @param type $comment_id
- * @return If comment is invalid
+ * @param int $comment_id The comment ID.
*/
public function set_comment_cookies( $comment_id ) {
- // Get comment and bail if it's invalid somehow
+ // Get comment and bail if it's invalid somehow.
$comment = get_comment( $comment_id );
if ( empty( $comment ) || is_wp_error( $comment ) ) {
return;
@@ -282,14 +299,14 @@ class Highlander_Comments_Base {
return;
}
- // Set comment author cookies
+ // Set comment author cookies.
// phpcs:ignore WordPress.WP.CapitalPDangit
- if ( ( 'wordpress' != $id_source ) && is_user_logged_in() ) {
+ if ( ( 'wordpress' !== $id_source ) && is_user_logged_in() ) {
/** This filter is already documented in core/wp-includes/comment-functions.php */
$comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
- setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN );
- setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN );
- setcookie( 'comment_author_url_' . COOKIEHASH, esc_url( $comment->comment_author_url ), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN );
+ setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );
+ setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );
+ setcookie( 'comment_author_url_' . COOKIEHASH, esc_url( $comment->comment_author_url ), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );
}
}
@@ -297,8 +314,8 @@ class Highlander_Comments_Base {
* Get an avatar from Photon
*
* @since JetpackComments (1.4)
- * @param string $url
- * @param int $size
+ * @param string $url The avatar URL.
+ * @param int $size The avatar size.
* @return string
*/
protected function photon_avatar( $url, $size ) {
diff --git a/plugins/jetpack/modules/comments/comments.php b/plugins/jetpack/modules/comments/comments.php
index 368f1633..494f4793 100644
--- a/plugins/jetpack/modules/comments/comments.php
+++ b/plugins/jetpack/modules/comments/comments.php
@@ -1,6 +1,11 @@
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Module: Comments
+ *
+ * @package automattic/jetpack
+ */
-require dirname( __FILE__ ) . '/base.php';
+require __DIR__ . '/base.php';
use Automattic\Jetpack\Connection\Tokens;
/**
@@ -15,19 +20,22 @@ class Jetpack_Comments extends Highlander_Comments_Base {
/** Variables *************************************************************/
/**
- * Possible comment form sources
+ * Possible comment form sources - empty array as default
+ *
* @var array
*/
public $id_sources = array();
/**
- * URL
+ * Remote comment URL - empty string as default
+ *
* @var string
*/
public $signed_url = '';
/**
- * The default comment form color scheme
+ * The default comment form color scheme - default is light
+ *
* @var string
* @see ::set_default_color_theme_based_on_theme_settings()
*/
@@ -35,11 +43,14 @@ class Jetpack_Comments extends Highlander_Comments_Base {
/** Methods ***************************************************************/
+ /**
+ * Initialize class
+ */
public static function init() {
static $instance = false;
if ( ! $instance ) {
- $instance = new Jetpack_Comments;
+ $instance = new Jetpack_Comments();
}
return $instance;
@@ -53,7 +64,7 @@ class Jetpack_Comments extends Highlander_Comments_Base {
public function __construct() {
parent::__construct();
- // Comments is loaded
+ // Comments is loaded.
/**
* Fires after the Jetpack_Comments object has been instantiated
@@ -63,11 +74,14 @@ class Jetpack_Comments extends Highlander_Comments_Base {
* @since 1.4.0
*
* @param array $jetpack_comments_loaded First element in array of type Jetpack_Comments
- **/
+ */
do_action_ref_array( 'jetpack_comments_loaded', array( $this ) );
add_action( 'after_setup_theme', array( $this, 'set_default_color_theme_based_on_theme_settings' ), 100 );
}
+ /**
+ * Set the default comments color theme based on theme settings
+ */
public function set_default_color_theme_based_on_theme_settings() {
if ( function_exists( 'twentyeleven_get_theme_options' ) ) {
$theme_options = twentyeleven_get_theme_options();
@@ -75,8 +89,8 @@ class Jetpack_Comments extends Highlander_Comments_Base {
} else {
$theme_color_scheme = get_theme_mod( 'color_scheme', 'transparent' );
}
- // Default for $theme_color_scheme is 'transparent' just so it doesn't match 'light' or 'dark'
- // The default for Jetpack's color scheme is still defined above as 'light'
+ // Default for $theme_color_scheme is 'transparent' just so it doesn't match 'light' or 'dark'.
+ // The default for Jetpack's color scheme is still defined above as 'light'.
if ( false !== stripos( $theme_color_scheme, 'light' ) ) {
$this->default_color_scheme = 'light';
@@ -89,12 +103,15 @@ class Jetpack_Comments extends Highlander_Comments_Base {
/**
* Set any global variables or class variables
+ *
+ * This is primarily defining the comment form sources.
+ *
* @since JetpackComments (1.4)
*/
protected function setup_globals() {
parent::setup_globals();
- // Sources
+ // Sources.
$this->id_sources = array(
'guest',
'jetpack',
@@ -106,27 +123,29 @@ class Jetpack_Comments extends Highlander_Comments_Base {
/**
* Setup actions for methods in this class
+ *
* @since JetpackComments (1.4)
*/
protected function setup_actions() {
parent::setup_actions();
- // Selfishly remove everything from the existing comment form
+ // Selfishly remove everything from the existing comment form.
remove_all_actions( 'comment_form_before' );
- // Selfishly add only our actions back to the comment form
+ // Selfishly add only our actions back to the comment form.
add_action( 'comment_form_before', array( $this, 'comment_form_before' ) );
add_action( 'comment_form_after', array( $this, 'comment_form_after' ), 1 ); // Set very early since we remove everything outputed before our action.
- // Before a comment is posted
+ // Before a comment is posted.
add_action( 'pre_comment_on_post', array( $this, 'pre_comment_on_post' ), 1 );
- // After a comment is posted
+ // After a comment is posted.
add_action( 'comment_post', array( $this, 'add_comment_meta' ) );
}
/**
* Setup filters for methods in this class
+ *
* @since 1.6.2
*/
protected function setup_filters() {
@@ -141,20 +160,19 @@ class Jetpack_Comments extends Highlander_Comments_Base {
*
* @since JetpackComments (1.4)
*
- * @param string $avatar Current avatar URL
- * @param string $comment Comment for the avatar
- * @param int $size Size of the avatar
- * @param string $default Not used
+ * @param string $avatar Current avatar URL.
+ * @param string $comment Comment for the avatar.
+ * @param int $size Size of the avatar.
*
* @return string New avatar
*/
- public function get_avatar( $avatar, $comment, $size, $default ) {
+ public function get_avatar( $avatar, $comment, $size ) {
if ( ! isset( $comment->comment_post_ID ) || ! isset( $comment->comment_ID ) ) {
- // it's not a comment - bail
+ // it's not a comment - bail.
return $avatar;
}
- // Detect whether it's a Facebook or Twitter avatar
+ // Detect whether it's a Facebook or Twitter avatar.
$foreign_avatar = get_comment_meta( $comment->comment_ID, 'hc_avatar', true );
$foreign_avatar_hostname = wp_parse_url( $foreign_avatar, PHP_URL_HOST );
if ( ! $foreign_avatar_hostname ||
@@ -162,7 +180,7 @@ class Jetpack_Comments extends Highlander_Comments_Base {
return $avatar;
}
- // Return the FB or Twitter avatar
+ // Return the Facebook or Twitter avatar.
return preg_replace( '#src=([\'"])[^\'"]+\\1#', 'src=\\1' . esc_url( set_url_scheme( $this->photon_avatar( $foreign_avatar, $size ), 'https' ) ) . '\\1', $avatar );
}
@@ -170,6 +188,9 @@ class Jetpack_Comments extends Highlander_Comments_Base {
/**
* Start capturing the core comment_form() output
+ *
+ * Comment form output will only be captured if comments are enabled - we return otherwise.
+ *
* @since JetpackComments (1.4)
*/
public function comment_form_before() {
@@ -187,7 +208,7 @@ class Jetpack_Comments extends Highlander_Comments_Base {
return;
}
- // Add some JS to the footer
+ // Add some JS to the footer.
add_action( 'wp_footer', array( $this, 'watch_comment_parent' ), 100 );
ob_start();
@@ -205,10 +226,10 @@ class Jetpack_Comments extends Highlander_Comments_Base {
return;
}
- // Throw it all out and drop in our replacement
+ // Throw it all out and drop in our replacement.
ob_end_clean();
- // If users are required to be logged in, and they're not, then we don't need to do anything else
+ // If users are required to be logged in, and they're not, then we don't need to do anything else.
if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) {
/**
* Changes the log in to comment prompt.
@@ -219,12 +240,20 @@ class Jetpack_Comments extends Highlander_Comments_Base {
*
* @param string $var Default is "You must log in to post a comment."
*/
- echo '<p class="must-log-in">' . sprintf( apply_filters( 'jetpack_must_log_in_to_comment', __( 'You must <a href="%s">log in</a> to post a comment.', 'jetpack' ) ), wp_login_url( get_permalink() . '#respond' ) ) . '</p>';
-
+ echo '<p class="must-log-in">' . wp_kses_post(
+ sprintf(
+ apply_filters(
+ 'jetpack_must_log_in_to_comment',
+ /* translators: %s is the wp-login URL for the site */
+ __( 'You must <a href="%s">log in</a> to post a comment.', 'jetpack' )
+ ),
+ wp_login_url( get_permalink() . '#respond' )
+ )
+ ) . '</p>';
return;
}
- if ( in_array( 'subscriptions', Jetpack::get_active_modules() ) ) {
+ if ( in_array( 'subscriptions', Jetpack::get_active_modules(), true ) ) {
$stb_enabled = get_option( 'stb_enabled', 1 );
$stb_enabled = empty( $stb_enabled ) ? 0 : 1;
@@ -236,15 +265,16 @@ class Jetpack_Comments extends Highlander_Comments_Base {
}
$params = array(
- 'blogid' => Jetpack_Options::get_option( 'id' ),
- 'postid' => get_the_ID(),
- 'comment_registration' => ( get_option( 'comment_registration' ) ? '1' : '0' ), // Need to explicitly send a '1' or a '0' for these
- 'require_name_email' => ( get_option( 'require_name_email' ) ? '1' : '0' ),
- 'stc_enabled' => $stc_enabled,
- 'stb_enabled' => $stb_enabled,
- 'show_avatars' => ( get_option( 'show_avatars' ) ? '1' : '0' ),
- 'avatar_default' => get_option( 'avatar_default' ),
- 'greeting' => get_option( 'highlander_comment_form_prompt', __( 'Leave a Reply', 'jetpack' ) ),
+ 'blogid' => Jetpack_Options::get_option( 'id' ),
+ 'postid' => get_the_ID(),
+ 'comment_registration' => ( get_option( 'comment_registration' ) ? '1' : '0' ), // Need to explicitly send a '1' or a '0' for these.
+ 'require_name_email' => ( get_option( 'require_name_email' ) ? '1' : '0' ),
+ 'stc_enabled' => $stc_enabled,
+ 'stb_enabled' => $stb_enabled,
+ 'show_avatars' => ( get_option( 'show_avatars' ) ? '1' : '0' ),
+ 'avatar_default' => get_option( 'avatar_default' ),
+ 'greeting' => get_option( 'highlander_comment_form_prompt', __( 'Leave a Reply', 'jetpack' ) ),
+ 'jetpack_comments_nonce' => wp_create_nonce( 'jetpack_comments_nonce-' . get_the_ID() ),
/**
* Changes the comment form prompt.
*
@@ -254,13 +284,17 @@ class Jetpack_Comments extends Highlander_Comments_Base {
*
* @param string $var Default is "Leave a Reply to %s."
*/
- 'greeting_reply' => apply_filters( 'jetpack_comment_form_prompt_reply', __( 'Leave a Reply to %s', 'jetpack' ) ),
- 'color_scheme' => get_option( 'jetpack_comment_form_color_scheme', $this->default_color_scheme ),
- 'lang' => get_locale(),
- 'jetpack_version' => JETPACK__VERSION,
+ 'greeting_reply' => apply_filters(
+ 'jetpack_comment_form_prompt_reply',
+ /* translators: %s is the displayed username of the post (or comment) author */
+ __( 'Leave a Reply to %s', 'jetpack' )
+ ),
+ 'color_scheme' => get_option( 'jetpack_comment_form_color_scheme', $this->default_color_scheme ),
+ 'lang' => get_locale(),
+ 'jetpack_version' => JETPACK__VERSION,
);
- // Extra parameters for logged in user
+ // Extra parameters for logged in user.
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
$params['hc_post_as'] = 'jetpack';
@@ -296,21 +330,22 @@ class Jetpack_Comments extends Highlander_Comments_Base {
}
}
- $signature = Jetpack_Comments::sign_remote_comment_parameters( $params, $blog_token->secret );
+ $signature = self::sign_remote_comment_parameters( $params, $blog_token->secret );
if ( is_wp_error( $signature ) ) {
$signature = 'error';
}
- $params['sig'] = $signature;
- $url_origin = 'https://jetpack.wordpress.com';
- $url = "{$url_origin}/jetpack-comment/?" . http_build_query( $params );
- $url = "{$url}#parent=" . urlencode( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) );
+ $params['sig'] = $signature;
+ $url_origin = 'https://jetpack.wordpress.com';
+ $url = "{$url_origin}/jetpack-comment/?" . http_build_query( $params );
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sniff misses the esc_url_raw.
+ $url = "{$url}#parent=" . rawurlencode( esc_url_raw( set_url_scheme( 'http://' . ( isset( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : '' ) . ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '' ) ) ) );
$this->signed_url = $url;
- $height = $params['comment_registration'] || is_user_logged_in() ? '315' : '430'; // Iframe can be shorter if we're not allowing guest commenting
- $transparent = ( $params['color_scheme'] == 'transparent' ) ? 'true' : 'false';
+ $height = $params['comment_registration'] || is_user_logged_in() ? '315' : '430'; // Iframe can be shorter if we're not allowing guest commenting.
+ $transparent = ( 'transparent' === $params['color_scheme'] ) ? 'true' : 'false';
- if ( isset( $_GET['replytocom'] ) ) {
- $url .= '&replytocom=' . (int) $_GET['replytocom'];
+ if ( isset( $_GET['replytocom'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $url .= '&replytocom=' . (int) $_GET['replytocom']; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
/**
@@ -324,7 +359,7 @@ class Jetpack_Comments extends Highlander_Comments_Base {
*/
$show_greeting = apply_filters( 'jetpack_comment_form_display_greeting', true );
- // The actual iframe (loads comment form from Jetpack server)
+ // The actual iframe (loads comment form from Jetpack server).
$is_amp = Jetpack_AMP_Support::is_amp_request();
?>
@@ -361,7 +396,7 @@ class Jetpack_Comments extends Highlander_Comments_Base {
document.addEventListener('DOMContentLoaded', function () {
var commentForms = document.getElementsByClassName('jetpack_remote_comment');
for (var i = 0; i < commentForms.length; i++) {
- commentForms[i].allowTransparency = <?php echo $transparent; ?>;
+ commentForms[i].allowTransparency = <?php echo esc_html( $transparent ); ?>;
commentForms[i].scrolling = 'no';
}
});
@@ -371,7 +406,7 @@ class Jetpack_Comments extends Highlander_Comments_Base {
</form>
</div>
- <?php // Below is required for comment reply JS to work ?>
+ <?php // Below is required for comment reply JS to work. ?>
<input type="hidden" name="comment_parent" id="comment_parent" value="" />
@@ -381,6 +416,8 @@ class Jetpack_Comments extends Highlander_Comments_Base {
/**
* Add some JS to wp_footer to watch for hierarchical reply parent change
*
+ * If AMP is enabled, we don't make any changes.
+ *
* @since JetpackComments (1.4)
*/
public function watch_comment_parent() {
@@ -461,7 +498,7 @@ class Jetpack_Comments extends Highlander_Comments_Base {
// Do the post message bit after the dom has loaded.
document.addEventListener( 'DOMContentLoaded', function () {
- var iframe_url = <?php echo json_encode( esc_url_raw( $url_origin ) ); ?>;
+ var iframe_url = <?php echo wp_json_encode( esc_url_raw( $url_origin ) ); ?>;
if ( window.postMessage ) {
if ( document.addEventListener ) {
window.addEventListener( 'message', function ( event ) {
@@ -492,44 +529,49 @@ class Jetpack_Comments extends Highlander_Comments_Base {
/**
* Verify the hash included in remote comments.
*
- * @since JetpackComments (1.4)
+ * If the Jetpack token is missing we return nothing,
+ * and if the token is unknown or invalid, or comments not allowed, an error is returned.
*
- * @param type $comment Not used
+ * @since JetpackComments (1.4)
*/
- public function pre_comment_on_post( $comment ) {
+ public function pre_comment_on_post() {
$post_array = stripslashes_deep( $_POST );
- // Bail if missing the Jetpack token
+ // Bail if missing the Jetpack token.
if ( ! isset( $post_array['sig'] ) || ! isset( $post_array['token_key'] ) ) {
unset( $_POST['hc_post_as'] );
return;
}
+ if ( empty( $post_array['jetpack_comments_nonce'] ) || ! wp_verify_nonce( $post_array['jetpack_comments_nonce'], "jetpack_comments_nonce-{$post_array['comment_post_ID']}" ) ) {
+ wp_die( esc_html__( 'Nonce verification failed.', 'jetpack' ), 400 );
+ }
+
if ( false !== strpos( $post_array['hc_avatar'], '.gravatar.com' ) ) {
$post_array['hc_avatar'] = htmlentities( $post_array['hc_avatar'] );
}
$blog_token = ( new Tokens() )->get_access_token( false, $post_array['token_key'] );
if ( ! $blog_token ) {
- wp_die( __( 'Unknown security token.', 'jetpack' ), 400 );
+ wp_die( esc_html__( 'Unknown security token.', 'jetpack' ), 400 );
}
- $check = Jetpack_Comments::sign_remote_comment_parameters( $post_array, $blog_token->secret );
+ $check = self::sign_remote_comment_parameters( $post_array, $blog_token->secret );
if ( is_wp_error( $check ) ) {
- wp_die( $check );
+ wp_die( esc_html( $check ) );
}
- // Bail if token is expired or not valid
+ // Bail if token is expired or not valid.
if ( ! hash_equals( $check, $post_array['sig'] ) ) {
- wp_die( __( 'Invalid security token.', 'jetpack' ), 400 );
+ wp_die( esc_html__( 'Invalid security token.', 'jetpack' ), 400 );
}
/** This filter is documented in modules/comments/comments.php */
if ( ! apply_filters( 'jetpack_comment_form_enabled_for_' . get_post_type( $post_array['comment_post_ID'] ), true ) ) {
// In case the comment POST is legit, but the comments are
- // now disabled, we don't allow the comment
+ // now disabled, we don't allow the comment.
- wp_die( __( 'Comments are not allowed.', 'jetpack' ), 403 );
+ wp_die( esc_html__( 'Comments are not allowed.', 'jetpack' ), 403 );
}
}
@@ -541,54 +583,61 @@ class Jetpack_Comments extends Highlander_Comments_Base {
*
* @since JetpackComments (1.4)
*
- * @param type $comment_id
+ * @param int $comment_id The comment ID.
*/
public function add_comment_meta( $comment_id ) {
$comment_meta = array();
+ // phpcs:disable WordPress.Security.NonceVerification.Missing
switch ( $this->is_highlander_comment_post() ) {
case 'facebook':
$comment_meta['hc_post_as'] = 'facebook';
- $comment_meta['hc_avatar'] = stripslashes( $_POST['hc_avatar'] );
- $comment_meta['hc_foreign_user_id'] = stripslashes( $_POST['hc_userid'] );
+ $comment_meta['hc_avatar'] = isset( $_POST['hc_avatar'] ) ? filter_var( wp_unslash( $_POST['hc_avatar'] ) ) : null;
+ $comment_meta['hc_foreign_user_id'] = isset( $_POST['hc_userid'] ) ? filter_var( wp_unslash( $_POST['hc_userid'] ) ) : null;
break;
case 'twitter':
$comment_meta['hc_post_as'] = 'twitter';
- $comment_meta['hc_avatar'] = stripslashes( $_POST['hc_avatar'] );
- $comment_meta['hc_foreign_user_id'] = stripslashes( $_POST['hc_userid'] );
+ $comment_meta['hc_avatar'] = isset( $_POST['hc_avatar'] ) ? filter_var( wp_unslash( $_POST['hc_avatar'] ) ) : null;
+ $comment_meta['hc_foreign_user_id'] = isset( $_POST['hc_userid'] ) ? filter_var( wp_unslash( $_POST['hc_userid'] ) ) : null;
break;
// phpcs:ignore WordPress.WP.CapitalPDangit
case 'wordpress':
// phpcs:ignore WordPress.WP.CapitalPDangit
$comment_meta['hc_post_as'] = 'wordpress';
- $comment_meta['hc_avatar'] = stripslashes( $_POST['hc_avatar'] );
- $comment_meta['hc_foreign_user_id'] = stripslashes( $_POST['hc_userid'] );
- $comment_meta['hc_wpcom_id_sig'] = stripslashes( $_POST['hc_wpcom_id_sig'] ); //since 1.9
+ $comment_meta['hc_avatar'] = isset( $_POST['hc_avatar'] ) ? filter_var( wp_unslash( $_POST['hc_avatar'] ) ) : null;
+ $comment_meta['hc_foreign_user_id'] = isset( $_POST['hc_userid'] ) ? filter_var( wp_unslash( $_POST['hc_userid'] ) ) : null;
+ $comment_meta['hc_wpcom_id_sig'] = isset( $_POST['hc_wpcom_id_sig'] ) ? filter_var( wp_unslash( $_POST['hc_wpcom_id_sig'] ) ) : null; // since 1.9.
break;
case 'jetpack':
$comment_meta['hc_post_as'] = 'jetpack';
- $comment_meta['hc_avatar'] = stripslashes( $_POST['hc_avatar'] );
- $comment_meta['hc_foreign_user_id'] = stripslashes( $_POST['hc_userid'] );
+ $comment_meta['hc_avatar'] = isset( $_POST['hc_avatar'] ) ? filter_var( wp_unslash( $_POST['hc_avatar'] ) ) : null;
+ $comment_meta['hc_foreign_user_id'] = isset( $_POST['hc_userid'] ) ? filter_var( wp_unslash( $_POST['hc_userid'] ) ) : null;
break;
}
+ // phpcs:enable WordPress.Security.NonceVerification.Missing
- // Bail if no extra comment meta
+ // Bail if no extra comment meta.
if ( empty( $comment_meta ) ) {
return;
}
- // Loop through extra meta and add values
+ // Loop through extra meta and add values.
foreach ( $comment_meta as $key => $value ) {
add_comment_meta( $comment_id, $key, $value, true );
}
}
- function capture_comment_post_redirect_to_reload_parent_frame( $url ) {
- if ( ! isset( $_GET['for'] ) || 'jetpack' != $_GET['for'] ) {
+ /**
+ * POST the submitted comment to the iframe
+ *
+ * @param string $url The comment URL origin.
+ */
+ public function capture_comment_post_redirect_to_reload_parent_frame( $url ) {
+ if ( ! isset( $_GET['for'] ) || 'jetpack' !== $_GET['for'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return $url;
}
?>
@@ -597,7 +646,17 @@ class Jetpack_Comments extends Highlander_Comments_Base {
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
- <title><?php printf( __( 'Submitting Comment%s', 'jetpack' ), '&hellip;' ); ?></title>
+ <title>
+ <?php
+ wp_kses_post(
+ printf(
+ /* translators: %s is replaced by an ellipsis */
+ __( 'Submitting Comment%s', 'jetpack' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ '&hellip;'
+ )
+ );
+ ?>
+ </title>
<style type="text/css">
body {
display: table;
@@ -648,13 +707,23 @@ class Jetpack_Comments extends Highlander_Comments_Base {
</style>
</head>
<body>
- <h1><?php printf( __( 'Submitting Comment%s', 'jetpack' ), '<span id="ellipsis" class="hidden">&hellip;</span>' ); ?></h1>
+ <h1>
+ <?php
+ wp_kses_post(
+ printf(
+ /* translators: %s is replaced by HTML markup to include an ellipsis */
+ __( 'Submitting Comment%s', 'jetpack' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ '<span id="ellipsis" class="hidden">&hellip;</span>'
+ )
+ );
+ ?>
+ </h1>
<script type="text/javascript">
try {
- window.parent.location = <?php echo json_encode( $url ); ?>;
+ window.parent.location = <?php echo wp_json_encode( $url ); ?>;
window.parent.location.reload(true);
} catch (e) {
- window.location = <?php echo json_encode( $url ); ?>;
+ window.location = <?php echo wp_json_encode( $url ); ?>;
window.location.reload(true);
}
ellipsis = document.getElementById('ellipsis');
diff --git a/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style-rtl.css b/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style-rtl.css
index 463d8191..7406319c 100644
--- a/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style-rtl.css
+++ b/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style-rtl.css
@@ -1,764 +1,741 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
+@charset "UTF-8";
/* ==========================================================================
** Normalize
** ======================================================================== */
-
html {
- direction: rtl;
+ direction: rtl;
}
body {
- font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
- font-size: 16px;
- line-height: 1.4em;
- margin: 0;
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
+ font-size: 16px;
+ line-height: 1.4em;
+ margin: 0;
}
/* Links */
a,
a:visited {
- color: #0087be;
- text-decoration: none;
+ color: #0087be;
+ text-decoration: none;
}
a:hover,
a:focus,
a:active {
- color: $link-highlight;
+ /* Not defined here? */
+ /* color: $link-highlight; */
}
/* ==========================================================================
** Card
** ======================================================================= */
-
.card,
body {
- display: block;
- position: relative;
- margin: 0 auto 10px auto;
- padding: 16px;
- box-sizing: border-box;
- background: white;
- box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
+ display: block;
+ position: relative;
+ margin: 0 auto 10px auto;
+ padding: 16px;
+ box-sizing: border-box;
+ background: white;
+ box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
}
body {
- margin: 0;
- background: #f6f7f7;
+ margin: 0;
+ background: #f6f7f7;
}
.card:after {
- content: ".";
- display: block;
- height: 0;
- clear: both;
- visibility: hidden;
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
}
.card:hover,
.card:focus {
- box-shadow: 0 0 0 1px #999, 0 1px 2px #e9eff3;
+ box-shadow: 0 0 0 1px #999, 0 1px 2px #e9eff3;
}
.card .delete-field {
- display: block;
- float: left;
+ display: block;
+ float: left;
}
-@media ( min-width: 481px ) {
- .card {
- margin-bottom: 16px;
- padding: 24px;
- }
- body {
- padding: 24px;
- }
-}
+@media (min-width: 481px) {
+ .card {
+ margin-bottom: 16px;
+ padding: 24px;
+ }
+ body {
+ padding: 24px;
+ }
+}
.card.is-compact {
- margin-bottom: 1px;
+ margin-bottom: 1px;
}
-@media ( min-width: 481px ) {
- .card.is-compact {
- margin-bottom: 1px;
- padding: 16px 24px;
- }
+@media (min-width: 481px) {
+ .card.is-compact {
+ margin-bottom: 1px;
+ padding: 16px 24px;
+ }
}
-
.card > div {
- margin-top: 24px;
+ margin-top: 24px;
}
.card > div:first-child {
- margin-top: 0;
+ margin-top: 0;
}
-
/* ==========================================================================
** Labels
** ======================================================================= */
-
label {
- display: block;
- font-size: 14px;
- font-weight: 600;
- margin-bottom: 5px;
- margin-top: 8px;
+ display: block;
+ font-size: 14px;
+ font-weight: 600;
+ margin-bottom: 5px;
+ margin-top: 8px;
}
label:first-of-type {
- margin-top: 4px;
+ margin-top: 4px;
}
-
/* ==========================================================================
** Text Inputs
** ======================================================================= */
-
-input[type="text"],
-input[type="tel"],
-input[type="email"],
-input[type="url"] {
- border-radius: 0;
- -webkit-appearance: none;
- appearance: none;
- box-sizing: border-box;
- margin: 0;
- padding: 7px 14px;
- width: 100%;
- color: #2e4453;
- font-size: 16px;
- line-height: 1.5;
- border: 1px solid #c8d7e1;
- background-color: #fff;
- transition: all .15s ease-in-out;
- box-shadow: none;
-}
-
-input[type="text"]::placeholder,
-input[type="tel"]::placeholder,
-input[type="email"]::placeholder,
-input[type="url"]::placeholder {
- color: #87a6bc;
-}
-
-input[type="text"]:hover,
-input[type="tel"]:hover,
-input[type="email"]:hover,
-input[type="url"]:hover {
- border-color: #a8bece;
-}
-
-input[type="text"]:focus,
-input[type="tel"]:focus,
-input[type="email"]:focus,
-input[type="url"]:focus {
- border-color: #0087be;
- outline: none;
- box-shadow: 0 0 0 2px #78dcfa;
-}
-
-input[type="text"]:focus::-ms-clear,
-input[type="tel"]:focus::-ms-clear,
-input[type="email"]:focus::-ms-clear,
-input[type="url"]:focus::-ms-clear {
- display: none;
-}
-
-input[type="text"]:disabled,
-input[type="tel"]:disabled,
-input[type="email"]:disabled,
-input[type="url"]:disabled {
- background: #f3f6f8;
- border-color: #e9eff3;
- color: #a8bece;
- -webkit-text-fill-color: #a8bece;
-}
-
-input[type="text"]:disabled:hover,
-input[type="tel"]:disabled:hover,
-input[type="email"]:disabled:hover,
-input[type="url"]:disabled:hover {
- cursor: default;
-}
-
-input[type="text"]:disabled::placeholder,
-input[type="tel"]:disabled::placeholder,
-input[type="email"]:disabled::placeholder,
-input[type="url"]:disabled::placeholder {
- color: #a8bece;
+input[type=text],
+input[type=tel],
+input[type=email],
+input[type=url] {
+ border-radius: 0;
+ -webkit-appearance: none;
+ appearance: none;
+ box-sizing: border-box;
+ margin: 0;
+ padding: 7px 14px;
+ width: 100%;
+ color: #2e4453;
+ font-size: 16px;
+ line-height: 1.5;
+ border: 1px solid #c8d7e1;
+ background-color: #fff;
+ transition: all 0.15s ease-in-out;
+ box-shadow: none;
+}
+
+input[type=text]::placeholder,
+input[type=tel]::placeholder,
+input[type=email]::placeholder,
+input[type=url]::placeholder {
+ color: #87a6bc;
+}
+
+input[type=text]:hover,
+input[type=tel]:hover,
+input[type=email]:hover,
+input[type=url]:hover {
+ border-color: #a8bece;
+}
+
+input[type=text]:focus,
+input[type=tel]:focus,
+input[type=email]:focus,
+input[type=url]:focus {
+ border-color: #0087be;
+ outline: none;
+ box-shadow: 0 0 0 2px #78dcfa;
+}
+
+input[type=text]:focus::-ms-clear,
+input[type=tel]:focus::-ms-clear,
+input[type=email]:focus::-ms-clear,
+input[type=url]:focus::-ms-clear {
+ display: none;
+}
+
+input[type=text]:disabled,
+input[type=tel]:disabled,
+input[type=email]:disabled,
+input[type=url]:disabled {
+ background: #f3f6f8;
+ border-color: #e9eff3;
+ color: #a8bece;
+ -webkit-text-fill-color: #a8bece;
+}
+
+input[type=text]:disabled:hover,
+input[type=tel]:disabled:hover,
+input[type=email]:disabled:hover,
+input[type=url]:disabled:hover {
+ cursor: default;
+}
+
+input[type=text]:disabled::placeholder,
+input[type=tel]:disabled::placeholder,
+input[type=email]:disabled::placeholder,
+input[type=url]:disabled::placeholder {
+ color: #a8bece;
}
-
/* ==========================================================================
** Textareas
** ======================================================================= */
-
textarea {
- border-radius: 0;
- -webkit-appearance: none;
- appearance: none;
- box-sizing: border-box;
- margin: 0;
- padding: 7px 14px;
- height: 92px;
- width: 100%;
- color: #2e4453;
- font-size: 16px;
- line-height: 1.5;
- border: 1px solid #c8d7e1;
- background-color: #fff;
- transition: all .15s ease-in-out;
- box-shadow: none;
+ border-radius: 0;
+ -webkit-appearance: none;
+ appearance: none;
+ box-sizing: border-box;
+ margin: 0;
+ padding: 7px 14px;
+ height: 92px;
+ width: 100%;
+ color: #2e4453;
+ font-size: 16px;
+ line-height: 1.5;
+ border: 1px solid #c8d7e1;
+ background-color: #fff;
+ transition: all 0.15s ease-in-out;
+ box-shadow: none;
}
textarea::placeholder {
- color: #87a6bc;
+ color: #87a6bc;
}
textarea:hover {
- border-color: #a8bece;
+ border-color: #a8bece;
}
textarea:focus {
- border-color: #0087be;
- outline: none;
- box-shadow: 0 0 0 2px #78dcfa;
+ border-color: #0087be;
+ outline: none;
+ box-shadow: 0 0 0 2px #78dcfa;
}
textarea:focus::-ms-clear {
- display: none;
+ display: none;
}
textarea:disabled {
- background: #f3f6f8;
- border-color: #e9eff3;
- color: #a8bece;
- -webkit-text-fill-color: #a8bece;
+ background: #f3f6f8;
+ border-color: #e9eff3;
+ color: #a8bece;
+ -webkit-text-fill-color: #a8bece;
}
textarea:disabled:hover {
- cursor: default;
+ cursor: default;
}
textarea:disabled::placeholder {
- color: #a8bece;
+ color: #a8bece;
}
-
/* ==========================================================================
** Checkboxes
** ======================================================================= */
-
.checkbox,
-input[type="checkbox"] {
- -webkit-appearance: none;
- display: inline-block;
- box-sizing: border-box;
- margin: 2px 0 0;
- padding: 7px 14px;
- width: 16px;
- height: 16px;
- float: right;
- outline: 0;
- padding: 0;
- box-shadow: none;
- background-color: #fff;
- border: 1px solid #c8d7e1;
- color: #2e4453;
- font-size: 16px;
- line-height: 0;
- text-align: center;
- vertical-align: middle;
- appearance: none;
- transition: all .15s ease-in-out;
- clear: none;
- cursor: pointer;
+input[type=checkbox] {
+ -webkit-appearance: none;
+ display: inline-block;
+ box-sizing: border-box;
+ margin: 2px 0 0;
+ padding: 7px 14px;
+ width: 16px;
+ height: 16px;
+ float: right;
+ outline: 0;
+ padding: 0;
+ box-shadow: none;
+ background-color: #fff;
+ border: 1px solid #c8d7e1;
+ color: #2e4453;
+ font-size: 16px;
+ line-height: 0;
+ text-align: center;
+ vertical-align: middle;
+ appearance: none;
+ transition: all 0.15s ease-in-out;
+ clear: none;
+ cursor: pointer;
}
.checkbox:checked:before,
-input[type="checkbox"]:checked:before {
- content: '\f147';
- font-family: Dashicons;
- margin: -3px -4px 0 0;
- float: right;
- display: inline-block;
- vertical-align: middle;
- width: 16px;
- font-size: 20px;
- line-height: 1;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- speak: none;
- color: #00aadc;
+input[type=checkbox]:checked:before {
+ content: "\f147";
+ font-family: Dashicons;
+ margin: -3px -4px 0 0;
+ float: right;
+ display: inline-block;
+ vertical-align: middle;
+ width: 16px;
+ font-size: 20px;
+ line-height: 1;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ speak: none;
+ color: #00aadc;
}
.checkbox:disabled:checked:before,
-input[type="checkbox"]:disabled:checked:before {
- color: #a8bece;
+input[type=checkbox]:disabled:checked:before {
+ color: #a8bece;
}
.checkbox:hover,
-input[type="checkbox"]:hover {
- border-color: #a8bece;
+input[type=checkbox]:hover {
+ border-color: #a8bece;
}
.checkbox:focus,
-input[type="checkbox"]:focus {
- border-color: #0087be;
- outline: none;
- box-shadow: 0 0 0 2px #78dcfa;
+input[type=checkbox]:focus {
+ border-color: #0087be;
+ outline: none;
+ box-shadow: 0 0 0 2px #78dcfa;
}
.checkbox:disabled,
-input[type="checkbox"]:disabled {
- background: #f3f6f8;
- border-color: #e9eff3;
- color: #a8bece;
- opacity: 1;
+input[type=checkbox]:disabled {
+ background: #f3f6f8;
+ border-color: #e9eff3;
+ color: #a8bece;
+ opacity: 1;
}
.checkbox:disabled:hover,
-input[type="checkbox"]:disabled:hover {
- cursor: default;
+input[type=checkbox]:disabled:hover {
+ cursor: default;
}
.checkbox + span,
-input[type="checkbox"] + span {
- display: block;
- font-weight: normal;
- margin-right: 24px;
+input[type=checkbox] + span {
+ display: block;
+ font-weight: normal;
+ margin-right: 24px;
}
-
/* ==========================================================================
** Radio buttons
** ======================================================================== */
-
.radio-button,
input[type=radio] {
- color: #2e4453;
- font-size: 16px;
- border: 1px solid #c8d7e1;
- background-color: #fff;
- transition: all .15s ease-in-out;
- box-sizing: border-box;
- -webkit-appearance: none;
- clear: none;
- cursor: pointer;
- display: inline-block;
- line-height: 0;
- height: 16px;
- margin: 2px 0 0 4px;
- float: right;
- outline: 0;
- padding: 0;
- text-align: center;
- vertical-align: middle;
- width: 16px;
- min-width: 16px;
- appearance: none;
- border-radius: 50%;
- line-height: 10px;
+ color: #2e4453;
+ font-size: 16px;
+ border: 1px solid #c8d7e1;
+ background-color: #fff;
+ transition: all 0.15s ease-in-out;
+ box-sizing: border-box;
+ -webkit-appearance: none;
+ clear: none;
+ cursor: pointer;
+ display: inline-block;
+ line-height: 0;
+ height: 16px;
+ margin: 2px 0 0 4px;
+ float: right;
+ outline: 0;
+ padding: 0;
+ text-align: center;
+ vertical-align: middle;
+ width: 16px;
+ min-width: 16px;
+ appearance: none;
+ border-radius: 50%;
+ line-height: 10px;
}
.radio-button:hover,
-input[type="radio"]:hover {
- border-color: #a8bece;
+input[type=radio]:hover {
+ border-color: #a8bece;
}
.radio-button:focus,
-input[type="radio"]:focus {
- border-color: #0087be;
- outline: none;
- box-shadow: 0 0 0 2px #78dcfa;
+input[type=radio]:focus {
+ border-color: #0087be;
+ outline: none;
+ box-shadow: 0 0 0 2px #78dcfa;
}
.radio-button:focus::-ms-clear,
-input[type="radio"]:focus::-ms-clear {
- display: none;
+input[type=radio]:focus::-ms-clear {
+ display: none;
}
.radio-button:checked:before,
-input[type="radio"]:checked:before {
- float: right;
- display: inline-block;
- content: '\2022';
- margin: 3px;
- width: 8px;
- height: 8px;
- text-indent: -9999px;
- background: #00aadc;
- vertical-align: middle;
- border-radius: 50%;
- animation: grow .2s ease-in-out;
+input[type=radio]:checked:before {
+ float: right;
+ display: inline-block;
+ content: "•";
+ margin: 3px;
+ width: 8px;
+ height: 8px;
+ text-indent: -9999px;
+ background: #00aadc;
+ vertical-align: middle;
+ border-radius: 50%;
+ animation: grow 0.2s ease-in-out;
}
.radio-button:disabled,
-input[type="radio"]:disabled {
- background: #f3f6f8;
- border-color: #e9eff3;
- color: #a8bece;
- opacity: 1;
- -webkit-text-fill-color: #a8bece;
+input[type=radio]:disabled {
+ background: #f3f6f8;
+ border-color: #e9eff3;
+ color: #a8bece;
+ opacity: 1;
+ -webkit-text-fill-color: #a8bece;
}
.radio-button:disabled:hover,
-input[type="radio"]:disabled:hover {
- cursor: default;
+input[type=radio]:disabled:hover {
+ cursor: default;
}
.radio-button:disabled::placeholder,
-input[type="radio"]:disabled::placeholder {
- color: #a8bece;
+input[type=radio]:disabled::placeholder {
+ color: #a8bece;
}
.radio-button:disabled:checked::before,
-input[type="radio"]:disabled:checked:before {
- background: #e9eff3;
+input[type=radio]:disabled:checked:before {
+ background: #e9eff3;
}
.radio-button + span,
-input[type="radio"] + span {
- display: block;
- font-weight: normal;
- margin-right: 24px;
+input[type=radio] + span {
+ display: block;
+ font-weight: normal;
+ margin-right: 24px;
}
@keyframes grow {
- 0% {
- transform: scale(0.3);
- }
-
- 60% {
- transform: scale(1.15);
- }
-
- 100% {
- transform: scale(1);
- }
+ 0% {
+ transform: scale(0.3);
+ }
+ 60% {
+ transform: scale(1.15);
+ }
+ 100% {
+ transform: scale(1);
+ }
}
-
@keyframes grow {
- 0% {
- transform: scale(0.3);
- }
-
- 60% {
- transform: scale(1.15);
- }
-
- 100% {
- transform: scale(1);
- }
+ 0% {
+ transform: scale(0.3);
+ }
+ 60% {
+ transform: scale(1.15);
+ }
+ 100% {
+ transform: scale(1);
+ }
}
-
-
/* ==========================================================================
** Selects
** ======================================================================== */
-
select {
- background: #fff url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjQzhEN0UxIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat left 10px center;
- border-color: #c8d7e1;
- border-style: solid;
- border-radius: 4px;
- border-width: 1px 1px 2px;
- color: #2e4453;
- cursor: pointer;
- display: inline-block;
- margin: 0;
- outline: 0;
- overflow: hidden;
- font-size: 14px;
- line-height: 21px;
- font-weight: 600;
- text-overflow: ellipsis;
- text-decoration: none;
- vertical-align: top;
- white-space: nowrap;
- box-sizing: border-box;
- /* Aligns the text to the 8px baseline grid and adds padding on right to allow for the arrow. */
- padding: 7px 14px 9px 32px;
- -webkit-appearance: none;
- appearance: none;
+ background: #fff url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjQzhEN0UxIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat left 10px center;
+ border-color: #c8d7e1;
+ border-style: solid;
+ border-radius: 4px;
+ border-width: 1px 1px 2px;
+ color: #2e4453;
+ cursor: pointer;
+ display: inline-block;
+ margin: 0;
+ outline: 0;
+ overflow: hidden;
+ font-size: 14px;
+ line-height: 21px;
+ font-weight: 600;
+ text-overflow: ellipsis;
+ text-decoration: none;
+ vertical-align: top;
+ white-space: nowrap;
+ box-sizing: border-box;
+ /* Aligns the text to the 8px baseline grid and adds padding on right to allow for the arrow. */
+ padding: 7px 14px 9px 32px;
+ -webkit-appearance: none;
+ appearance: none;
}
select:hover {
- background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjYThiZWNlIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==);
+ background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjYThiZWNlIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==);
}
select:focus {
- background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiA8dGl0bGU+YXJyb3ctZG93bjwvdGl0bGU+IDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPiA8ZGVmcz48L2RlZnM+IDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHNrZXRjaDp0eXBlPSJNU1BhZ2UiPiA8ZyBpZD0iYXJyb3ctZG93biIgc2tldGNoOnR5cGU9Ik1TQXJ0Ym9hcmRHcm91cCIgZmlsbD0iIzJlNDQ1MyI+IDxwYXRoIGQ9Ik0xNS41LDYgTDE3LDcuNSBMMTAuMjUsMTQuMjUgTDMuNSw3LjUgTDUsNiBMMTAuMjUsMTEuMjUgTDE1LjUsNiBaIiBpZD0iRG93bi1BcnJvdyIgc2tldGNoOnR5cGU9Ik1TU2hhcGVHcm91cCI+PC9wYXRoPiA8L2c+IDwvZz48L3N2Zz4=);
- border-color: #00aadc;
- box-shadow: 0 0 0 2px #78dcfa;
- outline: 0;
- -moz-outline:none;
- -moz-user-focus:ignore;
+ background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiA8dGl0bGU+YXJyb3ctZG93bjwvdGl0bGU+IDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPiA8ZGVmcz48L2RlZnM+IDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHNrZXRjaDp0eXBlPSJNU1BhZ2UiPiA8ZyBpZD0iYXJyb3ctZG93biIgc2tldGNoOnR5cGU9Ik1TQXJ0Ym9hcmRHcm91cCIgZmlsbD0iIzJlNDQ1MyI+IDxwYXRoIGQ9Ik0xNS41LDYgTDE3LDcuNSBMMTAuMjUsMTQuMjUgTDMuNSw3LjUgTDUsNiBMMTAuMjUsMTEuMjUgTDE1LjUsNiBaIiBpZD0iRG93bi1BcnJvdyIgc2tldGNoOnR5cGU9Ik1TU2hhcGVHcm91cCI+PC9wYXRoPiA8L2c+IDwvZz48L3N2Zz4=);
+ border-color: #00aadc;
+ box-shadow: 0 0 0 2px #78dcfa;
+ outline: 0;
+ -moz-outline: none;
+ -moz-user-focus: ignore;
}
select:disabled,
select:hover:disabled {
- background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjZTllZmYzIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat left 10px center;;
+ background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjZTllZmYzIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat left 10px center;
}
select.is-compact {
- min-width: 0;
- padding: 0 6px 2px 20px;
- margin: 0 4px;
- background-position: left 5px center;
- background-size: 12px 12px;
+ min-width: 0;
+ padding: 0 6px 2px 20px;
+ margin: 0 4px;
+ background-position: left 5px center;
+ background-size: 12px 12px;
}
/* Make it display:block when it follows a label */
label select,
label + select {
- display: block;
- min-width: 200px;
+ display: block;
+ min-width: 200px;
}
label select.is-compact,
label + select.is-compact {
- display: inline-block;
- min-width: 0;
+ display: inline-block;
+ min-width: 0;
}
/* IE: Remove the default arrow */
select::-ms-expand {
- display: none;
+ display: none;
}
/* IE: Remove default background and color styles on focus */
select::-ms-value {
- background: none;
- color: #2e4453;
+ background: none;
+ color: #2e4453;
}
/* Firefox: Remove the focus outline, see http://stackoverflow.com/questions/3773430/remove-outline-from-select-box-in-ff/18853002#18853002 */
select:-moz-focusring {
- color: transparent;
- text-shadow: 0 0 0 #2e4453;
+ color: transparent;
+ text-shadow: 0 0 0 #2e4453;
}
-
/* ==========================================================================
** Buttons
** ======================================================================== */
-
-input[type="submit"] {
- padding: 0;
- font-size: 14px;
- -webkit-appearance: none;
- appearance: none;
- vertical-align: baseline;
- background: white;
- border-color: #c8d7e1;
- border-style: solid;
- border-width: 1px 1px 2px;
- color: #2e4453;
- cursor: pointer;
- display: inline-block;
- margin: 24px 0 0;
- outline: 0;
- overflow: hidden;
- font-weight: 500;
- text-overflow: ellipsis;
- text-decoration: none;
- vertical-align: top;
- box-sizing: border-box;
- font-size: 14px;
- line-height: 21px;
- border-radius: 4px;
- padding: 7px 14px 9px;
- -webkit-appearance: none;
- appearance: none;
+input[type=submit] {
+ padding: 0;
+ font-size: 14px;
+ -webkit-appearance: none;
+ appearance: none;
+ vertical-align: baseline;
+ background: white;
+ border-color: #c8d7e1;
+ border-style: solid;
+ border-width: 1px 1px 2px;
+ color: #2e4453;
+ cursor: pointer;
+ display: inline-block;
+ margin: 24px 0 0;
+ outline: 0;
+ overflow: hidden;
+ font-weight: 500;
+ text-overflow: ellipsis;
+ text-decoration: none;
+ vertical-align: top;
+ box-sizing: border-box;
+ font-size: 14px;
+ line-height: 21px;
+ border-radius: 4px;
+ padding: 7px 14px 9px;
+ -webkit-appearance: none;
+ appearance: none;
}
-input[type="submit"]:hover {
- border-color: #a8bece;
- color: #2e4453;
+input[type=submit]:hover {
+ border-color: #a8bece;
+ color: #2e4453;
}
-input[type="submit"]:active {
- border-width: 2px 1px 1px;
+input[type=submit]:active {
+ border-width: 2px 1px 1px;
}
-input[type="submit"]:visited {
- color: #2e4453;
+input[type=submit]:visited {
+ color: #2e4453;
}
-input[type="submit"][disabled],
-input[type="submit"]:disabled {
- color: #e9eff3;
- background: white;
- border-color: #e9eff3;
- cursor: default;
+input[type=submit][disabled],
+input[type=submit]:disabled {
+ color: #e9eff3;
+ background: white;
+ border-color: #e9eff3;
+ cursor: default;
}
-input[type="submit"][disabled]:active,
-input[type="submit"]:disabled:active {
- border-width: 1px 1px 2px;
+input[type=submit][disabled]:active,
+input[type=submit]:disabled:active {
+ border-width: 1px 1px 2px;
}
-input[type="submit"]:focus {
- border-color: #00aadc;
- box-shadow: 0 0 0 2px #78dcfa;
+input[type=submit]:focus {
+ border-color: #00aadc;
+ box-shadow: 0 0 0 2px #78dcfa;
}
-input[type="submit"].hidden {
- display: none;
+input[type=submit].hidden {
+ display: none;
}
-input[type="submit"] .gridicon {
- position: relative;
- top: 4px;
- margin-top: -2px;
- width: 18px;
- height: 18px;
+input[type=submit] .gridicon {
+ position: relative;
+ top: 4px;
+ margin-top: -2px;
+ width: 18px;
+ height: 18px;
}
-input[type="submit"].button-primary {
- background: #00aadc;
- border-color: #008ab3;
- color: white;
+input[type=submit].button-primary {
+ background: #00aadc;
+ border-color: #008ab3;
+ color: white;
}
-input[type="submit"].button-primary:hover,
-input[type="submit"].button-primary:focus {
- border-color: #005082;
- color: white;
+input[type=submit].button-primary:hover,
+input[type=submit].button-primary:focus {
+ border-color: #005082;
+ color: white;
}
-input[type="submit"].button-primary[disabled],
-input[type="submit"].button-primary:disabled {
- background: #bceefd;
- border-color: #8cc9e2;
- color: white;
+input[type=submit].button-primary[disabled],
+input[type=submit].button-primary:disabled {
+ background: #bceefd;
+ border-color: #8cc9e2;
+ color: white;
}
-input[type="submit"].button-primary {
- color: white;
+input[type=submit].button-primary {
+ color: white;
}
-
/* ==========================================================================
** Inline editor styles
** ======================================================================== */
-
-
.ui-sortable-handle {
- cursor: move;
+ cursor: move;
}
.grunion-section-header {
- font-size: 21px;
- margin-top: 32px;
- font-weight: 600;
+ font-size: 21px;
+ margin-top: 32px;
+ font-weight: 600;
}
.grunion-form-settings:hover {
- box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
+ box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
}
.grunion-section-header:first-child {
- margin-top: 0;
+ margin-top: 0;
}
.grunion-type-options {
- display: flex;
- flex-wrap: wrap;
+ display: flex;
+ flex-wrap: wrap;
}
.grunion-type {
- flex-grow: 0;
- flex-shrink: 0;
+ flex-grow: 0;
+ flex-shrink: 0;
}
.grunion-type select {
- -webkit-appearance: none;
- width: 100%;
+ -webkit-appearance: none;
+ width: 100%;
}
.grunion-required {
- padding: 27px 16px 0 0;
- flex-grow: 0;
- flex-shrink: 0;
+ padding: 27px 16px 0 0;
+ flex-grow: 0;
+ flex-shrink: 0;
}
.grunion-options {
- padding-top: 16px;
+ padding-top: 16px;
}
.grunion-options ol {
- list-style: none;
- padding: 0;
- margin: 8px 0 0;
+ list-style: none;
+ padding: 0;
+ margin: 8px 0 0;
}
.grunion-options li {
- display: flex;
- margin-bottom: 16px;
+ display: flex;
+ margin-bottom: 16px;
}
.grunion-field-edit .grunion-options {
- display: none;
+ display: none;
}
.delete-option,
.delete-field {
- color: #0087be;
- text-decoration: none;
- width: 40px;
- line-height: 40px;
- font-size: 21px;
- text-align: center;
- font-weight: 600;
+ color: #0087be;
+ text-decoration: none;
+ width: 40px;
+ line-height: 40px;
+ font-size: 21px;
+ text-align: center;
+ font-weight: 600;
}
.delete-field {
- position: absolute;
- top: 0;
- left: 0;
+ position: absolute;
+ top: 0;
+ left: 0;
}
.grunion-controls {
- display: flex;
- flex-wrap: wrap;
+ display: flex;
+ flex-wrap: wrap;
}
.grunion-update-controls {
- text-align: left;
- flex-grow: 1;
+ text-align: left;
+ flex-grow: 1;
}
#add-field {
- flex-grow: 0;
+ flex-grow: 0;
}
.delete-option:before,
.delete-field:before {
- font-family: Dashicons;
-/* content: "\f158"; /* This is the bolder X */
- content: "\f335"; /* This is the thinner X */
- display: inline-block;
- speak: none;
+ font-family: Dashicons;
+ /* content: "\f158"; /* This is the bolder X */
+ content: "\f335";
+ /* This is the thinner X */
+ display: inline-block;
+ speak: none;
}
.grunion-field-edit.grunion-field-checkbox-multiple .grunion-options,
.grunion-field-edit.grunion-field-radio .grunion-options,
.grunion-field-edit.grunion-field-select .grunion-options {
- display: block;
+ display: block;
}
.screen-reader-text {
- position: absolute;
- margin: -1px;
- padding: 0;
- height: 1px;
- width: 1px;
- overflow: hidden;
- clip: rect(0 0 0 0);
- border: 0;
- word-wrap: normal !important; /* many screen reader and browser combinations announce broken words as they would appear visually */
+ position: absolute;
+ margin: -1px;
+ padding: 0;
+ height: 1px;
+ width: 1px;
+ overflow: hidden;
+ clip: rect(0 0 0 0);
+ border: 0;
+ word-wrap: normal !important;
+ /* many screen reader and browser combinations announce broken words as they would appear visually */
}
diff --git a/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style-rtl.min.css b/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style-rtl.min.css
index 5b888096..78da53a0 100644
--- a/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style-rtl.min.css
+++ b/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style-rtl.min.css
@@ -1 +1 @@
-html{direction:rtl}body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:16px;line-height:1.4em;margin:0}a,a:visited{color:#0087be;text-decoration:none}a:active,a:focus,a:hover{color:$link-highlight}.card,body{display:block;position:relative;margin:0 auto 10px auto;padding:16px;box-sizing:border-box;background:#fff;box-shadow:0 0 0 1px rgba(200,215,225,.5),0 1px 2px #e9eff3}body{margin:0;background:#f6f7f7}.card:after{content:".";display:block;height:0;clear:both;visibility:hidden}.card:focus,.card:hover{box-shadow:0 0 0 1px #999,0 1px 2px #e9eff3}.card .delete-field{display:block;float:left}@media (min-width:481px){.card{margin-bottom:16px;padding:24px}body{padding:24px}}.card.is-compact{margin-bottom:1px}@media (min-width:481px){.card.is-compact{margin-bottom:1px;padding:16px 24px}}.card>div{margin-top:24px}.card>div:first-child{margin-top:0}label{display:block;font-size:14px;font-weight:600;margin-bottom:5px;margin-top:8px}label:first-of-type{margin-top:4px}input[type=email],input[type=tel],input[type=text],input[type=url]{border-radius:0;-webkit-appearance:none;appearance:none;box-sizing:border-box;margin:0;padding:7px 14px;width:100%;color:#2e4453;font-size:16px;line-height:1.5;border:1px solid #c8d7e1;background-color:#fff;transition:all .15s ease-in-out;box-shadow:none}input[type=email]::placeholder,input[type=tel]::placeholder,input[type=text]::placeholder,input[type=url]::placeholder{color:#87a6bc}input[type=email]:hover,input[type=tel]:hover,input[type=text]:hover,input[type=url]:hover{border-color:#a8bece}input[type=email]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=url]:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}input[type=email]:focus::-ms-clear,input[type=tel]:focus::-ms-clear,input[type=text]:focus::-ms-clear,input[type=url]:focus::-ms-clear{display:none}input[type=email]:disabled,input[type=tel]:disabled,input[type=text]:disabled,input[type=url]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;-webkit-text-fill-color:#a8bece}input[type=email]:disabled:hover,input[type=tel]:disabled:hover,input[type=text]:disabled:hover,input[type=url]:disabled:hover{cursor:default}input[type=email]:disabled::placeholder,input[type=tel]:disabled::placeholder,input[type=text]:disabled::placeholder,input[type=url]:disabled::placeholder{color:#a8bece}textarea{border-radius:0;-webkit-appearance:none;appearance:none;box-sizing:border-box;margin:0;padding:7px 14px;height:92px;width:100%;color:#2e4453;font-size:16px;line-height:1.5;border:1px solid #c8d7e1;background-color:#fff;transition:all .15s ease-in-out;box-shadow:none}textarea::placeholder{color:#87a6bc}textarea:hover{border-color:#a8bece}textarea:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}textarea:focus::-ms-clear{display:none}textarea:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;-webkit-text-fill-color:#a8bece}textarea:disabled:hover{cursor:default}textarea:disabled::placeholder{color:#a8bece}.checkbox,input[type=checkbox]{-webkit-appearance:none;display:inline-block;box-sizing:border-box;margin:2px 0 0;padding:7px 14px;width:16px;height:16px;float:right;outline:0;padding:0;box-shadow:none;background-color:#fff;border:1px solid #c8d7e1;color:#2e4453;font-size:16px;line-height:0;text-align:center;vertical-align:middle;appearance:none;transition:all .15s ease-in-out;clear:none;cursor:pointer}.checkbox:checked:before,input[type=checkbox]:checked:before{content:'\f147';font-family:Dashicons;margin:-3px -4px 0 0;float:right;display:inline-block;vertical-align:middle;width:16px;font-size:20px;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none;color:#00aadc}.checkbox:disabled:checked:before,input[type=checkbox]:disabled:checked:before{color:#a8bece}.checkbox:hover,input[type=checkbox]:hover{border-color:#a8bece}.checkbox:focus,input[type=checkbox]:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}.checkbox:disabled,input[type=checkbox]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1}.checkbox:disabled:hover,input[type=checkbox]:disabled:hover{cursor:default}.checkbox+span,input[type=checkbox]+span{display:block;font-weight:400;margin-right:24px}.radio-button,input[type=radio]{color:#2e4453;font-size:16px;border:1px solid #c8d7e1;background-color:#fff;transition:all .15s ease-in-out;box-sizing:border-box;-webkit-appearance:none;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:2px 0 0 4px;float:right;outline:0;padding:0;text-align:center;vertical-align:middle;width:16px;min-width:16px;appearance:none;border-radius:50%;line-height:10px}.radio-button:hover,input[type=radio]:hover{border-color:#a8bece}.radio-button:focus,input[type=radio]:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}.radio-button:focus::-ms-clear,input[type=radio]:focus::-ms-clear{display:none}.radio-button:checked:before,input[type=radio]:checked:before{float:right;display:inline-block;content:'\2022';margin:3px;width:8px;height:8px;text-indent:-9999px;background:#00aadc;vertical-align:middle;border-radius:50%;animation:grow .2s ease-in-out}.radio-button:disabled,input[type=radio]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1;-webkit-text-fill-color:#a8bece}.radio-button:disabled:hover,input[type=radio]:disabled:hover{cursor:default}.radio-button:disabled::placeholder,input[type=radio]:disabled::placeholder{color:#a8bece}.radio-button:disabled:checked::before,input[type=radio]:disabled:checked:before{background:#e9eff3}.radio-button+span,input[type=radio]+span{display:block;font-weight:400;margin-right:24px}@keyframes grow{0%{transform:scale(.3)}60%{transform:scale(1.15)}100%{transform:scale(1)}}@keyframes grow{0%{transform:scale(.3)}60%{transform:scale(1.15)}100%{transform:scale(1)}}select{background:#fff url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjQzhEN0UxIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat left 10px center;border-color:#c8d7e1;border-style:solid;border-radius:4px;border-width:1px 1px 2px;color:#2e4453;cursor:pointer;display:inline-block;margin:0;outline:0;overflow:hidden;font-size:14px;line-height:21px;font-weight:600;text-overflow:ellipsis;text-decoration:none;vertical-align:top;white-space:nowrap;box-sizing:border-box;padding:7px 14px 9px 32px;-webkit-appearance:none;appearance:none}select:hover{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjYThiZWNlIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==)}select:focus{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiA8dGl0bGU+YXJyb3ctZG93bjwvdGl0bGU+IDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPiA8ZGVmcz48L2RlZnM+IDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHNrZXRjaDp0eXBlPSJNU1BhZ2UiPiA8ZyBpZD0iYXJyb3ctZG93biIgc2tldGNoOnR5cGU9Ik1TQXJ0Ym9hcmRHcm91cCIgZmlsbD0iIzJlNDQ1MyI+IDxwYXRoIGQ9Ik0xNS41LDYgTDE3LDcuNSBMMTAuMjUsMTQuMjUgTDMuNSw3LjUgTDUsNiBMMTAuMjUsMTEuMjUgTDE1LjUsNiBaIiBpZD0iRG93bi1BcnJvdyIgc2tldGNoOnR5cGU9Ik1TU2hhcGVHcm91cCI+PC9wYXRoPiA8L2c+IDwvZz48L3N2Zz4=);border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa;outline:0;-moz-outline:none;-moz-user-focus:ignore}select:disabled,select:hover:disabled{background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjZTllZmYzIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat left 10px center}select.is-compact{min-width:0;padding:0 6px 2px 20px;margin:0 4px;background-position:left 5px center;background-size:12px 12px}label select,label+select{display:block;min-width:200px}label select.is-compact,label+select.is-compact{display:inline-block;min-width:0}select::-ms-expand{display:none}select::-ms-value{background:0 0;color:#2e4453}select:-moz-focusring{color:transparent;text-shadow:0 0 0 #2e4453}input[type=submit]{padding:0;font-size:14px;-webkit-appearance:none;appearance:none;vertical-align:baseline;background:#fff;border-color:#c8d7e1;border-style:solid;border-width:1px 1px 2px;color:#2e4453;cursor:pointer;display:inline-block;margin:24px 0 0;outline:0;overflow:hidden;font-weight:500;text-overflow:ellipsis;text-decoration:none;vertical-align:top;box-sizing:border-box;font-size:14px;line-height:21px;border-radius:4px;padding:7px 14px 9px;-webkit-appearance:none;appearance:none}input[type=submit]:hover{border-color:#a8bece;color:#2e4453}input[type=submit]:active{border-width:2px 1px 1px}input[type=submit]:visited{color:#2e4453}input[type=submit]:disabled,input[type=submit][disabled]{color:#e9eff3;background:#fff;border-color:#e9eff3;cursor:default}input[type=submit]:disabled:active,input[type=submit][disabled]:active{border-width:1px 1px 2px}input[type=submit]:focus{border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa}input[type=submit].hidden{display:none}input[type=submit] .gridicon{position:relative;top:4px;margin-top:-2px;width:18px;height:18px}input[type=submit].button-primary{background:#00aadc;border-color:#008ab3;color:#fff}input[type=submit].button-primary:focus,input[type=submit].button-primary:hover{border-color:#005082;color:#fff}input[type=submit].button-primary:disabled,input[type=submit].button-primary[disabled]{background:#bceefd;border-color:#8cc9e2;color:#fff}input[type=submit].button-primary{color:#fff}.ui-sortable-handle{cursor:move}.grunion-section-header{font-size:21px;margin-top:32px;font-weight:600}.grunion-form-settings:hover{box-shadow:0 0 0 1px rgba(200,215,225,.5),0 1px 2px #e9eff3}.grunion-section-header:first-child{margin-top:0}.grunion-type-options{display:flex;flex-wrap:wrap}.grunion-type{flex-grow:0;flex-shrink:0}.grunion-type select{-webkit-appearance:none;width:100%}.grunion-required{padding:27px 16px 0 0;flex-grow:0;flex-shrink:0}.grunion-options{padding-top:16px}.grunion-options ol{list-style:none;padding:0;margin:8px 0 0}.grunion-options li{display:flex;margin-bottom:16px}.grunion-field-edit .grunion-options{display:none}.delete-field,.delete-option{color:#0087be;text-decoration:none;width:40px;line-height:40px;font-size:21px;text-align:center;font-weight:600}.delete-field{position:absolute;top:0;left:0}.grunion-controls{display:flex;flex-wrap:wrap}.grunion-update-controls{text-align:left;flex-grow:1}#add-field{flex-grow:0}.delete-field:before,.delete-option:before{font-family:Dashicons;content:"\f335";display:inline-block;speak:none}.grunion-field-edit.grunion-field-checkbox-multiple .grunion-options,.grunion-field-edit.grunion-field-radio .grunion-options,.grunion-field-edit.grunion-field-select .grunion-options{display:block}.screen-reader-text{position:absolute;margin:-1px;padding:0;height:1px;width:1px;overflow:hidden;clip:rect(0 0 0 0);border:0;word-wrap:normal!important} \ No newline at end of file
+@charset "UTF-8";html{direction:rtl}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:16px;line-height:1.4em}a,a:visited{color:#0087be;text-decoration:none}.card,body{background:#fff;box-shadow:0 0 0 1px rgba(200,215,225,.5),0 1px 2px #e9eff3;box-sizing:border-box;display:block;margin:0 auto 10px;padding:16px;position:relative}body{background:#f6f7f7;margin:0}.card:after{clear:both;content:".";display:block;height:0;visibility:hidden}.card:focus,.card:hover{box-shadow:0 0 0 1px #999,0 1px 2px #e9eff3}.card .delete-field{display:block;float:left}@media (min-width:481px){.card{margin-bottom:16px}.card,body{padding:24px}}.card.is-compact{margin-bottom:1px}@media (min-width:481px){.card.is-compact{margin-bottom:1px;padding:16px 24px}}.card>div{margin-top:24px}.card>div:first-child{margin-top:0}label{display:block;font-size:14px;font-weight:600;margin-bottom:5px;margin-top:8px}label:first-of-type{margin-top:4px}input[type=email],input[type=tel],input[type=text],input[type=url]{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;border-radius:0;box-shadow:none;box-sizing:border-box;color:#2e4453;font-size:16px;line-height:1.5;margin:0;padding:7px 14px;transition:all .15s ease-in-out;width:100%}input[type=email]::placeholder,input[type=tel]::placeholder,input[type=text]::placeholder,input[type=url]::placeholder{color:#87a6bc}input[type=email]:hover,input[type=tel]:hover,input[type=text]:hover,input[type=url]:hover{border-color:#a8bece}input[type=email]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=url]:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}input[type=email]:focus::-ms-clear,input[type=tel]:focus::-ms-clear,input[type=text]:focus::-ms-clear,input[type=url]:focus::-ms-clear{display:none}input[type=email]:disabled,input[type=tel]:disabled,input[type=text]:disabled,input[type=url]:disabled{-webkit-text-fill-color:#a8bece;background:#f3f6f8;border-color:#e9eff3;color:#a8bece}input[type=email]:disabled:hover,input[type=tel]:disabled:hover,input[type=text]:disabled:hover,input[type=url]:disabled:hover{cursor:default}input[type=email]:disabled::placeholder,input[type=tel]:disabled::placeholder,input[type=text]:disabled::placeholder,input[type=url]:disabled::placeholder{color:#a8bece}textarea{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;border-radius:0;box-shadow:none;box-sizing:border-box;color:#2e4453;font-size:16px;height:92px;line-height:1.5;margin:0;padding:7px 14px;transition:all .15s ease-in-out;width:100%}textarea::placeholder{color:#87a6bc}textarea:hover{border-color:#a8bece}textarea:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}textarea:focus::-ms-clear{display:none}textarea:disabled{-webkit-text-fill-color:#a8bece;background:#f3f6f8;border-color:#e9eff3;color:#a8bece}textarea:disabled:hover{cursor:default}textarea:disabled::placeholder{color:#a8bece}.checkbox,input[type=checkbox]{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;box-shadow:none;box-sizing:border-box;clear:none;color:#2e4453;cursor:pointer;display:inline-block;float:right;font-size:16px;height:16px;line-height:0;margin:2px 0 0;outline:0;padding:0;text-align:center;transition:all .15s ease-in-out;vertical-align:middle;width:16px}.checkbox:checked:before,input[type=checkbox]:checked:before{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none;color:#00aadc;content:"\f147";display:inline-block;float:right;font-family:Dashicons;font-size:20px;line-height:1;margin:-3px -4px 0 0;vertical-align:middle;width:16px}.checkbox:disabled:checked:before,input[type=checkbox]:disabled:checked:before{color:#a8bece}.checkbox:hover,input[type=checkbox]:hover{border-color:#a8bece}.checkbox:focus,input[type=checkbox]:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}.checkbox:disabled,input[type=checkbox]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1}.checkbox:disabled:hover,input[type=checkbox]:disabled:hover{cursor:default}.checkbox+span,input[type=checkbox]+span{display:block;font-weight:400;margin-right:24px}.radio-button,input[type=radio]{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;border-radius:50%;box-sizing:border-box;clear:none;color:#2e4453;cursor:pointer;display:inline-block;float:right;font-size:16px;height:16px;line-height:0;line-height:10px;margin:2px 0 0 4px;min-width:16px;outline:0;padding:0;text-align:center;transition:all .15s ease-in-out;vertical-align:middle;width:16px}.radio-button:hover,input[type=radio]:hover{border-color:#a8bece}.radio-button:focus,input[type=radio]:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}.radio-button:focus::-ms-clear,input[type=radio]:focus::-ms-clear{display:none}.radio-button:checked:before,input[type=radio]:checked:before{animation:grow .2s ease-in-out;background:#00aadc;border-radius:50%;content:"•";display:inline-block;float:right;height:8px;margin:3px;text-indent:-9999px;vertical-align:middle;width:8px}.radio-button:disabled,input[type=radio]:disabled{-webkit-text-fill-color:#a8bece;background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1}.radio-button:disabled:hover,input[type=radio]:disabled:hover{cursor:default}.radio-button:disabled::placeholder,input[type=radio]:disabled::placeholder{color:#a8bece}.radio-button:disabled:checked:before,input[type=radio]:disabled:checked:before{background:#e9eff3}.radio-button+span,input[type=radio]+span{display:block;font-weight:400;margin-right:24px}@keyframes grow{0%{transform:scale(.3)}60%{transform:scale(1.15)}to{transform:scale(1)}}select{-webkit-appearance:none;appearance:none;background:#fff url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iI0M4RDdFMSIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+) no-repeat left 10px center;border:solid #c8d7e1;border-radius:4px;border-width:1px 1px 2px;box-sizing:border-box;color:#2e4453;cursor:pointer;display:inline-block;font-size:14px;font-weight:600;line-height:21px;margin:0;outline:0;overflow:hidden;padding:7px 14px 9px 32px;text-decoration:none;text-overflow:ellipsis;vertical-align:top;white-space:nowrap}select:hover{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iI2E4YmVjZSIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+)}select:focus{-moz-user-focus:ignore;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iIzJlNDQ1MyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+);border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa;outline:0;-moz-outline:none}select:disabled,select:hover:disabled{background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iI2U5ZWZmMyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+) no-repeat left 10px center}select.is-compact{background-position:left 5px center;background-size:12px 12px;margin:0 4px;min-width:0;padding:0 6px 2px 20px}label select,label+select{display:block;min-width:200px}label select.is-compact,label+select.is-compact{display:inline-block;min-width:0}select::-ms-expand{display:none}select::-ms-value{background:none;color:#2e4453}select:-moz-focusring{color:transparent;text-shadow:0 0 0 #2e4453}input[type=submit]{-webkit-appearance:none;appearance:none;background:#fff;border:solid #c8d7e1;border-radius:4px;border-width:1px 1px 2px;box-sizing:border-box;color:#2e4453;cursor:pointer;display:inline-block;font-size:14px;font-weight:500;line-height:21px;margin:24px 0 0;outline:0;overflow:hidden;padding:7px 14px 9px;text-decoration:none;text-overflow:ellipsis;vertical-align:baseline;vertical-align:top}input[type=submit]:hover{border-color:#a8bece;color:#2e4453}input[type=submit]:active{border-width:2px 1px 1px}input[type=submit]:visited{color:#2e4453}input[type=submit]:disabled,input[type=submit][disabled]{background:#fff;border-color:#e9eff3;color:#e9eff3;cursor:default}input[type=submit]:disabled:active,input[type=submit][disabled]:active{border-width:1px 1px 2px}input[type=submit]:focus{border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa}input[type=submit].hidden{display:none}input[type=submit] .gridicon{height:18px;margin-top:-2px;position:relative;top:4px;width:18px}input[type=submit].button-primary{background:#00aadc;border-color:#008ab3}input[type=submit].button-primary:focus,input[type=submit].button-primary:hover{border-color:#005082;color:#fff}input[type=submit].button-primary:disabled,input[type=submit].button-primary[disabled]{background:#bceefd;border-color:#8cc9e2;color:#fff}input[type=submit].button-primary{color:#fff}.ui-sortable-handle{cursor:move}.grunion-section-header{font-size:21px;font-weight:600;margin-top:32px}.grunion-form-settings:hover{box-shadow:0 0 0 1px rgba(200,215,225,.5),0 1px 2px #e9eff3}.grunion-section-header:first-child{margin-top:0}.grunion-type-options{display:flex;flex-wrap:wrap}.grunion-type{flex-grow:0;flex-shrink:0}.grunion-type select{-webkit-appearance:none;width:100%}.grunion-required{flex-grow:0;flex-shrink:0;padding:27px 16px 0 0}.grunion-options{padding-top:16px}.grunion-options ol{list-style:none;margin:8px 0 0;padding:0}.grunion-options li{display:flex;margin-bottom:16px}.grunion-field-edit .grunion-options{display:none}.delete-field,.delete-option{color:#0087be;font-size:21px;font-weight:600;line-height:40px;text-align:center;text-decoration:none;width:40px}.delete-field{left:0;position:absolute;top:0}.grunion-controls{display:flex;flex-wrap:wrap}.grunion-update-controls{flex-grow:1;text-align:left}#add-field{flex-grow:0}.delete-field:before,.delete-option:before{speak:none;content:"\f335";display:inline-block;font-family:Dashicons}.grunion-field-edit.grunion-field-checkbox-multiple .grunion-options,.grunion-field-edit.grunion-field-radio .grunion-options,.grunion-field-edit.grunion-field-select .grunion-options{display:block}.screen-reader-text{clip:rect(0 0 0 0);word-wrap:normal!important;border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style.css b/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style.css
index 596406ea..ebef84d9 100644
--- a/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style.css
+++ b/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style.css
@@ -23,7 +23,8 @@ a:visited {
a:hover,
a:focus,
a:active {
- color: $link-highlight;
+ /* Not defined here? */
+ /* color: $link-highlight; */
}
/* ==========================================================================
diff --git a/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style.min.css b/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style.min.css
index eb5a1fa2..426d8045 100644
--- a/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style.min.css
+++ b/plugins/jetpack/modules/contact-form/css/editor-inline-editing-style.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-html{direction:ltr}body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:16px;line-height:1.4em;margin:0}a,a:visited{color:#0087be;text-decoration:none}a:active,a:focus,a:hover{color:$link-highlight}.card,body{display:block;position:relative;margin:0 auto 10px auto;padding:16px;box-sizing:border-box;background:#fff;box-shadow:0 0 0 1px rgba(200,215,225,.5),0 1px 2px #e9eff3}body{margin:0;background:#f6f7f7}.card:after{content:".";display:block;height:0;clear:both;visibility:hidden}.card:focus,.card:hover{box-shadow:0 0 0 1px #999,0 1px 2px #e9eff3}.card .delete-field{display:block;float:right}@media (min-width:481px){.card{margin-bottom:16px;padding:24px}body{padding:24px}}.card.is-compact{margin-bottom:1px}@media (min-width:481px){.card.is-compact{margin-bottom:1px;padding:16px 24px}}.card>div{margin-top:24px}.card>div:first-child{margin-top:0}label{display:block;font-size:14px;font-weight:600;margin-bottom:5px;margin-top:8px}label:first-of-type{margin-top:4px}input[type=email],input[type=tel],input[type=text],input[type=url]{border-radius:0;-webkit-appearance:none;appearance:none;box-sizing:border-box;margin:0;padding:7px 14px;width:100%;color:#2e4453;font-size:16px;line-height:1.5;border:1px solid #c8d7e1;background-color:#fff;transition:all .15s ease-in-out;box-shadow:none}input[type=email]::placeholder,input[type=tel]::placeholder,input[type=text]::placeholder,input[type=url]::placeholder{color:#87a6bc}input[type=email]:hover,input[type=tel]:hover,input[type=text]:hover,input[type=url]:hover{border-color:#a8bece}input[type=email]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=url]:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}input[type=email]:focus::-ms-clear,input[type=tel]:focus::-ms-clear,input[type=text]:focus::-ms-clear,input[type=url]:focus::-ms-clear{display:none}input[type=email]:disabled,input[type=tel]:disabled,input[type=text]:disabled,input[type=url]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;-webkit-text-fill-color:#a8bece}input[type=email]:disabled:hover,input[type=tel]:disabled:hover,input[type=text]:disabled:hover,input[type=url]:disabled:hover{cursor:default}input[type=email]:disabled::placeholder,input[type=tel]:disabled::placeholder,input[type=text]:disabled::placeholder,input[type=url]:disabled::placeholder{color:#a8bece}textarea{border-radius:0;-webkit-appearance:none;appearance:none;box-sizing:border-box;margin:0;padding:7px 14px;height:92px;width:100%;color:#2e4453;font-size:16px;line-height:1.5;border:1px solid #c8d7e1;background-color:#fff;transition:all .15s ease-in-out;box-shadow:none}textarea::placeholder{color:#87a6bc}textarea:hover{border-color:#a8bece}textarea:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}textarea:focus::-ms-clear{display:none}textarea:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;-webkit-text-fill-color:#a8bece}textarea:disabled:hover{cursor:default}textarea:disabled::placeholder{color:#a8bece}.checkbox,input[type=checkbox]{-webkit-appearance:none;display:inline-block;box-sizing:border-box;margin:2px 0 0;padding:7px 14px;width:16px;height:16px;float:left;outline:0;padding:0;box-shadow:none;background-color:#fff;border:1px solid #c8d7e1;color:#2e4453;font-size:16px;line-height:0;text-align:center;vertical-align:middle;appearance:none;transition:all .15s ease-in-out;clear:none;cursor:pointer}.checkbox:checked:before,input[type=checkbox]:checked:before{content:'\f147';font-family:Dashicons;margin:-3px 0 0 -4px;float:left;display:inline-block;vertical-align:middle;width:16px;font-size:20px;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none;color:#00aadc}.checkbox:disabled:checked:before,input[type=checkbox]:disabled:checked:before{color:#a8bece}.checkbox:hover,input[type=checkbox]:hover{border-color:#a8bece}.checkbox:focus,input[type=checkbox]:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}.checkbox:disabled,input[type=checkbox]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1}.checkbox:disabled:hover,input[type=checkbox]:disabled:hover{cursor:default}.checkbox+span,input[type=checkbox]+span{display:block;font-weight:400;margin-left:24px}.radio-button,input[type=radio]{color:#2e4453;font-size:16px;border:1px solid #c8d7e1;background-color:#fff;transition:all .15s ease-in-out;box-sizing:border-box;-webkit-appearance:none;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:2px 4px 0 0;float:left;outline:0;padding:0;text-align:center;vertical-align:middle;width:16px;min-width:16px;appearance:none;border-radius:50%;line-height:10px}.radio-button:hover,input[type=radio]:hover{border-color:#a8bece}.radio-button:focus,input[type=radio]:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}.radio-button:focus::-ms-clear,input[type=radio]:focus::-ms-clear{display:none}.radio-button:checked:before,input[type=radio]:checked:before{float:left;display:inline-block;content:'\2022';margin:3px;width:8px;height:8px;text-indent:-9999px;background:#00aadc;vertical-align:middle;border-radius:50%;animation:grow .2s ease-in-out}.radio-button:disabled,input[type=radio]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1;-webkit-text-fill-color:#a8bece}.radio-button:disabled:hover,input[type=radio]:disabled:hover{cursor:default}.radio-button:disabled::placeholder,input[type=radio]:disabled::placeholder{color:#a8bece}.radio-button:disabled:checked::before,input[type=radio]:disabled:checked:before{background:#e9eff3}.radio-button+span,input[type=radio]+span{display:block;font-weight:400;margin-left:24px}@keyframes grow{0%{transform:scale(.3)}60%{transform:scale(1.15)}100%{transform:scale(1)}}@keyframes grow{0%{transform:scale(.3)}60%{transform:scale(1.15)}100%{transform:scale(1)}}select{background:#fff url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjQzhEN0UxIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat right 10px center;border-color:#c8d7e1;border-style:solid;border-radius:4px;border-width:1px 1px 2px;color:#2e4453;cursor:pointer;display:inline-block;margin:0;outline:0;overflow:hidden;font-size:14px;line-height:21px;font-weight:600;text-overflow:ellipsis;text-decoration:none;vertical-align:top;white-space:nowrap;box-sizing:border-box;padding:7px 32px 9px 14px;-webkit-appearance:none;appearance:none}select:hover{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjYThiZWNlIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==)}select:focus{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiA8dGl0bGU+YXJyb3ctZG93bjwvdGl0bGU+IDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPiA8ZGVmcz48L2RlZnM+IDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHNrZXRjaDp0eXBlPSJNU1BhZ2UiPiA8ZyBpZD0iYXJyb3ctZG93biIgc2tldGNoOnR5cGU9Ik1TQXJ0Ym9hcmRHcm91cCIgZmlsbD0iIzJlNDQ1MyI+IDxwYXRoIGQ9Ik0xNS41LDYgTDE3LDcuNSBMMTAuMjUsMTQuMjUgTDMuNSw3LjUgTDUsNiBMMTAuMjUsMTEuMjUgTDE1LjUsNiBaIiBpZD0iRG93bi1BcnJvdyIgc2tldGNoOnR5cGU9Ik1TU2hhcGVHcm91cCI+PC9wYXRoPiA8L2c+IDwvZz48L3N2Zz4=);border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa;outline:0;-moz-outline:none;-moz-user-focus:ignore}select:disabled,select:hover:disabled{background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjZTllZmYzIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat right 10px center}select.is-compact{min-width:0;padding:0 20px 2px 6px;margin:0 4px;background-position:right 5px center;background-size:12px 12px}label select,label+select{display:block;min-width:200px}label select.is-compact,label+select.is-compact{display:inline-block;min-width:0}select::-ms-expand{display:none}select::-ms-value{background:0 0;color:#2e4453}select:-moz-focusring{color:transparent;text-shadow:0 0 0 #2e4453}input[type=submit]{padding:0;font-size:14px;-webkit-appearance:none;appearance:none;vertical-align:baseline;background:#fff;border-color:#c8d7e1;border-style:solid;border-width:1px 1px 2px;color:#2e4453;cursor:pointer;display:inline-block;margin:24px 0 0;outline:0;overflow:hidden;font-weight:500;text-overflow:ellipsis;text-decoration:none;vertical-align:top;box-sizing:border-box;font-size:14px;line-height:21px;border-radius:4px;padding:7px 14px 9px;-webkit-appearance:none;appearance:none}input[type=submit]:hover{border-color:#a8bece;color:#2e4453}input[type=submit]:active{border-width:2px 1px 1px}input[type=submit]:visited{color:#2e4453}input[type=submit]:disabled,input[type=submit][disabled]{color:#e9eff3;background:#fff;border-color:#e9eff3;cursor:default}input[type=submit]:disabled:active,input[type=submit][disabled]:active{border-width:1px 1px 2px}input[type=submit]:focus{border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa}input[type=submit].hidden{display:none}input[type=submit] .gridicon{position:relative;top:4px;margin-top:-2px;width:18px;height:18px}input[type=submit].button-primary{background:#00aadc;border-color:#008ab3;color:#fff}input[type=submit].button-primary:focus,input[type=submit].button-primary:hover{border-color:#005082;color:#fff}input[type=submit].button-primary:disabled,input[type=submit].button-primary[disabled]{background:#bceefd;border-color:#8cc9e2;color:#fff}input[type=submit].button-primary{color:#fff}.ui-sortable-handle{cursor:move}.grunion-section-header{font-size:21px;margin-top:32px;font-weight:600}.grunion-form-settings:hover{box-shadow:0 0 0 1px rgba(200,215,225,.5),0 1px 2px #e9eff3}.grunion-section-header:first-child{margin-top:0}.grunion-type-options{display:flex;flex-wrap:wrap}.grunion-type{flex-grow:0;flex-shrink:0}.grunion-type select{-webkit-appearance:none;width:100%}.grunion-required{padding:27px 0 0 16px;flex-grow:0;flex-shrink:0}.grunion-options{padding-top:16px}.grunion-options ol{list-style:none;padding:0;margin:8px 0 0}.grunion-options li{display:flex;margin-bottom:16px}.grunion-field-edit .grunion-options{display:none}.delete-field,.delete-option{color:#0087be;text-decoration:none;width:40px;line-height:40px;font-size:21px;text-align:center;font-weight:600}.delete-field{position:absolute;top:0;right:0}.grunion-controls{display:flex;flex-wrap:wrap}.grunion-update-controls{text-align:right;flex-grow:1}#add-field{flex-grow:0}.delete-field:before,.delete-option:before{font-family:Dashicons;content:"\f335";display:inline-block;speak:none}.grunion-field-edit.grunion-field-checkbox-multiple .grunion-options,.grunion-field-edit.grunion-field-radio .grunion-options,.grunion-field-edit.grunion-field-select .grunion-options{display:block}.screen-reader-text{position:absolute;margin:-1px;padding:0;height:1px;width:1px;overflow:hidden;clip:rect(0 0 0 0);border:0;word-wrap:normal!important} \ No newline at end of file
+@charset "UTF-8";html{direction:ltr}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:16px;line-height:1.4em}a,a:visited{color:#0087be;text-decoration:none}.card,body{background:#fff;box-shadow:0 0 0 1px rgba(200,215,225,.5),0 1px 2px #e9eff3;box-sizing:border-box;display:block;margin:0 auto 10px;padding:16px;position:relative}body{background:#f6f7f7;margin:0}.card:after{clear:both;content:".";display:block;height:0;visibility:hidden}.card:focus,.card:hover{box-shadow:0 0 0 1px #999,0 1px 2px #e9eff3}.card .delete-field{display:block;float:right}@media (min-width:481px){.card{margin-bottom:16px}.card,body{padding:24px}}.card.is-compact{margin-bottom:1px}@media (min-width:481px){.card.is-compact{margin-bottom:1px;padding:16px 24px}}.card>div{margin-top:24px}.card>div:first-child{margin-top:0}label{display:block;font-size:14px;font-weight:600;margin-bottom:5px;margin-top:8px}label:first-of-type{margin-top:4px}input[type=email],input[type=tel],input[type=text],input[type=url]{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;border-radius:0;box-shadow:none;box-sizing:border-box;color:#2e4453;font-size:16px;line-height:1.5;margin:0;padding:7px 14px;transition:all .15s ease-in-out;width:100%}input[type=email]::placeholder,input[type=tel]::placeholder,input[type=text]::placeholder,input[type=url]::placeholder{color:#87a6bc}input[type=email]:hover,input[type=tel]:hover,input[type=text]:hover,input[type=url]:hover{border-color:#a8bece}input[type=email]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=url]:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}input[type=email]:focus::-ms-clear,input[type=tel]:focus::-ms-clear,input[type=text]:focus::-ms-clear,input[type=url]:focus::-ms-clear{display:none}input[type=email]:disabled,input[type=tel]:disabled,input[type=text]:disabled,input[type=url]:disabled{-webkit-text-fill-color:#a8bece;background:#f3f6f8;border-color:#e9eff3;color:#a8bece}input[type=email]:disabled:hover,input[type=tel]:disabled:hover,input[type=text]:disabled:hover,input[type=url]:disabled:hover{cursor:default}input[type=email]:disabled::placeholder,input[type=tel]:disabled::placeholder,input[type=text]:disabled::placeholder,input[type=url]:disabled::placeholder{color:#a8bece}textarea{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;border-radius:0;box-shadow:none;box-sizing:border-box;color:#2e4453;font-size:16px;height:92px;line-height:1.5;margin:0;padding:7px 14px;transition:all .15s ease-in-out;width:100%}textarea::placeholder{color:#87a6bc}textarea:hover{border-color:#a8bece}textarea:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}textarea:focus::-ms-clear{display:none}textarea:disabled{-webkit-text-fill-color:#a8bece;background:#f3f6f8;border-color:#e9eff3;color:#a8bece}textarea:disabled:hover{cursor:default}textarea:disabled::placeholder{color:#a8bece}.checkbox,input[type=checkbox]{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;box-shadow:none;box-sizing:border-box;clear:none;color:#2e4453;cursor:pointer;display:inline-block;float:left;font-size:16px;height:16px;line-height:0;margin:2px 0 0;outline:0;padding:0;text-align:center;transition:all .15s ease-in-out;vertical-align:middle;width:16px}.checkbox:checked:before,input[type=checkbox]:checked:before{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none;color:#00aadc;content:"\f147";display:inline-block;float:left;font-family:Dashicons;font-size:20px;line-height:1;margin:-3px 0 0 -4px;vertical-align:middle;width:16px}.checkbox:disabled:checked:before,input[type=checkbox]:disabled:checked:before{color:#a8bece}.checkbox:hover,input[type=checkbox]:hover{border-color:#a8bece}.checkbox:focus,input[type=checkbox]:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}.checkbox:disabled,input[type=checkbox]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1}.checkbox:disabled:hover,input[type=checkbox]:disabled:hover{cursor:default}.checkbox+span,input[type=checkbox]+span{display:block;font-weight:400;margin-left:24px}.radio-button,input[type=radio]{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;border-radius:50%;box-sizing:border-box;clear:none;color:#2e4453;cursor:pointer;display:inline-block;float:left;font-size:16px;height:16px;line-height:0;line-height:10px;margin:2px 4px 0 0;min-width:16px;outline:0;padding:0;text-align:center;transition:all .15s ease-in-out;vertical-align:middle;width:16px}.radio-button:hover,input[type=radio]:hover{border-color:#a8bece}.radio-button:focus,input[type=radio]:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}.radio-button:focus::-ms-clear,input[type=radio]:focus::-ms-clear{display:none}.radio-button:checked:before,input[type=radio]:checked:before{animation:grow .2s ease-in-out;background:#00aadc;border-radius:50%;content:"•";display:inline-block;float:left;height:8px;margin:3px;text-indent:-9999px;vertical-align:middle;width:8px}.radio-button:disabled,input[type=radio]:disabled{-webkit-text-fill-color:#a8bece;background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1}.radio-button:disabled:hover,input[type=radio]:disabled:hover{cursor:default}.radio-button:disabled::placeholder,input[type=radio]:disabled::placeholder{color:#a8bece}.radio-button:disabled:checked:before,input[type=radio]:disabled:checked:before{background:#e9eff3}.radio-button+span,input[type=radio]+span{display:block;font-weight:400;margin-left:24px}@keyframes grow{0%{transform:scale(.3)}60%{transform:scale(1.15)}to{transform:scale(1)}}select{-webkit-appearance:none;appearance:none;background:#fff url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iI0M4RDdFMSIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+) no-repeat right 10px center;border:solid #c8d7e1;border-radius:4px;border-width:1px 1px 2px;box-sizing:border-box;color:#2e4453;cursor:pointer;display:inline-block;font-size:14px;font-weight:600;line-height:21px;margin:0;outline:0;overflow:hidden;padding:7px 32px 9px 14px;text-decoration:none;text-overflow:ellipsis;vertical-align:top;white-space:nowrap}select:hover{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iI2E4YmVjZSIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+)}select:focus{-moz-user-focus:ignore;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iIzJlNDQ1MyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+);border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa;outline:0;-moz-outline:none}select:disabled,select:hover:disabled{background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iI2U5ZWZmMyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+) no-repeat right 10px center}select.is-compact{background-position:right 5px center;background-size:12px 12px;margin:0 4px;min-width:0;padding:0 20px 2px 6px}label select,label+select{display:block;min-width:200px}label select.is-compact,label+select.is-compact{display:inline-block;min-width:0}select::-ms-expand{display:none}select::-ms-value{background:none;color:#2e4453}select:-moz-focusring{color:transparent;text-shadow:0 0 0 #2e4453}input[type=submit]{-webkit-appearance:none;appearance:none;background:#fff;border:solid #c8d7e1;border-radius:4px;border-width:1px 1px 2px;box-sizing:border-box;color:#2e4453;cursor:pointer;display:inline-block;font-size:14px;font-weight:500;line-height:21px;margin:24px 0 0;outline:0;overflow:hidden;padding:7px 14px 9px;text-decoration:none;text-overflow:ellipsis;vertical-align:baseline;vertical-align:top}input[type=submit]:hover{border-color:#a8bece;color:#2e4453}input[type=submit]:active{border-width:2px 1px 1px}input[type=submit]:visited{color:#2e4453}input[type=submit]:disabled,input[type=submit][disabled]{background:#fff;border-color:#e9eff3;color:#e9eff3;cursor:default}input[type=submit]:disabled:active,input[type=submit][disabled]:active{border-width:1px 1px 2px}input[type=submit]:focus{border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa}input[type=submit].hidden{display:none}input[type=submit] .gridicon{height:18px;margin-top:-2px;position:relative;top:4px;width:18px}input[type=submit].button-primary{background:#00aadc;border-color:#008ab3}input[type=submit].button-primary:focus,input[type=submit].button-primary:hover{border-color:#005082;color:#fff}input[type=submit].button-primary:disabled,input[type=submit].button-primary[disabled]{background:#bceefd;border-color:#8cc9e2;color:#fff}input[type=submit].button-primary{color:#fff}.ui-sortable-handle{cursor:move}.grunion-section-header{font-size:21px;font-weight:600;margin-top:32px}.grunion-form-settings:hover{box-shadow:0 0 0 1px rgba(200,215,225,.5),0 1px 2px #e9eff3}.grunion-section-header:first-child{margin-top:0}.grunion-type-options{display:flex;flex-wrap:wrap}.grunion-type{flex-grow:0;flex-shrink:0}.grunion-type select{-webkit-appearance:none;width:100%}.grunion-required{flex-grow:0;flex-shrink:0;padding:27px 0 0 16px}.grunion-options{padding-top:16px}.grunion-options ol{list-style:none;margin:8px 0 0;padding:0}.grunion-options li{display:flex;margin-bottom:16px}.grunion-field-edit .grunion-options{display:none}.delete-field,.delete-option{color:#0087be;font-size:21px;font-weight:600;line-height:40px;text-align:center;text-decoration:none;width:40px}.delete-field{position:absolute;right:0;top:0}.grunion-controls{display:flex;flex-wrap:wrap}.grunion-update-controls{flex-grow:1;text-align:right}#add-field{flex-grow:0}.delete-field:before,.delete-option:before{speak:none;content:"\f335";display:inline-block;font-family:Dashicons}.grunion-field-edit.grunion-field-checkbox-multiple .grunion-options,.grunion-field-edit.grunion-field-radio .grunion-options,.grunion-field-edit.grunion-field-select .grunion-options{display:block}.screen-reader-text{clip:rect(0 0 0 0);word-wrap:normal!important;border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/contact-form/css/editor-style-rtl.css b/plugins/jetpack/modules/contact-form/css/editor-style-rtl.css
index 57bf5234..a7e87f93 100644
--- a/plugins/jetpack/modules/contact-form/css/editor-style-rtl.css
+++ b/plugins/jetpack/modules/contact-form/css/editor-style-rtl.css
@@ -1,554 +1,530 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
+@charset "UTF-8";
/* ==========================================================================
** Normalize
** ======================================================================== */
-
body,
label {
- font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
- font-size: 16px;
- line-height: 1.4em;
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
+ font-size: 16px;
+ line-height: 1.4em;
}
/* ==========================================================================
** Card
** ======================================================================= */
-
.card {
- display: block;
- position: relative;
- margin: 0 auto;
- padding: 16px;
- box-sizing: border-box;
- background: white;
- box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
+ display: block;
+ position: relative;
+ margin: 0 auto;
+ padding: 16px;
+ box-sizing: border-box;
+ background: white;
+ box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
}
.card:after {
- content: ".";
- display: block;
- height: 0;
- clear: both;
- visibility: hidden;
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
}
-@media ( min-width: 481px ) {
- .card {
- padding: 24px;
- }
+@media (min-width: 481px) {
+ .card {
+ padding: 24px;
+ }
}
-
.card > div {
- margin-top: 24px;
+ margin-top: 24px;
}
.card > div:first-child {
- margin-top: 0;
+ margin-top: 0;
}
-
/* ==========================================================================
** Labels
** ======================================================================= */
-
label {
- display: block;
- font-size: 14px;
- font-weight: 600;
- margin-bottom: 5px;
+ display: block;
+ font-size: 14px;
+ font-weight: 600;
+ margin-bottom: 5px;
}
-
/* ==========================================================================
** Text Inputs
** ======================================================================= */
-
-input[type="text"],
-input[type="tel"],
-input[type="email"],
-input[type="url"] {
- border-radius: 0;
- -webkit-appearance: none;
- appearance: none;
- box-sizing: border-box;
- margin: 0;
- padding: 7px 14px;
- width: 100%;
- color: #2e4453;
- font-size: 16px;
- line-height: 1.5;
- border: 1px solid #c8d7e1;
- background-color: #fff;
- transition: all .15s ease-in-out;
- box-shadow: none;
-}
-
-input[type="text"]::placeholder,
-input[type="tel"]::placeholder,
-input[type="email"]::placeholder,
-input[type="url"]::placeholder {
- color: #87a6bc;
-}
-
-input[type="text"]:hover,
-input[type="tel"]:hover,
-input[type="email"]:hover,
-input[type="url"]:hover {
- border-color: #a8bece;
-}
-
-input[type="text"]:focus,
-input[type="tel"]:focus,
-input[type="email"]:focus,
-input[type="url"]:focus {
- border-color: #0087be;
- outline: none;
- box-shadow: 0 0 0 2px #78dcfa;
-}
-
-input[type="text"]:focus::-ms-clear,
-input[type="tel"]:focus::-ms-clear,
-input[type="email"]:focus::-ms-clear,
-input[type="url"]:focus::-ms-clear {
- display: none;
-}
-
-input[type="text"]:disabled,
-input[type="tel"]:disabled,
-input[type="email"]:disabled,
-input[type="url"]:disabled {
- background: #f3f6f8;
- border-color: #e9eff3;
- color: #a8bece;
- -webkit-text-fill-color: #a8bece;
-}
-
-input[type="text"]:disabled:hover,
-input[type="tel"]:disabled:hover,
-input[type="email"]:disabled:hover,
-input[type="url"]:disabled:hover {
- cursor: default;
-}
-
-input[type="text"]:disabled::placeholder,
-input[type="tel"]:disabled::placeholder,
-input[type="email"]:disabled::placeholder,
-input[type="url"]:disabled::placeholder {
- color: #a8bece;
+input[type=text],
+input[type=tel],
+input[type=email],
+input[type=url] {
+ border-radius: 0;
+ -webkit-appearance: none;
+ appearance: none;
+ box-sizing: border-box;
+ margin: 0;
+ padding: 7px 14px;
+ width: 100%;
+ color: #2e4453;
+ font-size: 16px;
+ line-height: 1.5;
+ border: 1px solid #c8d7e1;
+ background-color: #fff;
+ transition: all 0.15s ease-in-out;
+ box-shadow: none;
+}
+
+input[type=text]::placeholder,
+input[type=tel]::placeholder,
+input[type=email]::placeholder,
+input[type=url]::placeholder {
+ color: #87a6bc;
+}
+
+input[type=text]:hover,
+input[type=tel]:hover,
+input[type=email]:hover,
+input[type=url]:hover {
+ border-color: #a8bece;
+}
+
+input[type=text]:focus,
+input[type=tel]:focus,
+input[type=email]:focus,
+input[type=url]:focus {
+ border-color: #0087be;
+ outline: none;
+ box-shadow: 0 0 0 2px #78dcfa;
+}
+
+input[type=text]:focus::-ms-clear,
+input[type=tel]:focus::-ms-clear,
+input[type=email]:focus::-ms-clear,
+input[type=url]:focus::-ms-clear {
+ display: none;
+}
+
+input[type=text]:disabled,
+input[type=tel]:disabled,
+input[type=email]:disabled,
+input[type=url]:disabled {
+ background: #f3f6f8;
+ border-color: #e9eff3;
+ color: #a8bece;
+ -webkit-text-fill-color: #a8bece;
+}
+
+input[type=text]:disabled:hover,
+input[type=tel]:disabled:hover,
+input[type=email]:disabled:hover,
+input[type=url]:disabled:hover {
+ cursor: default;
+}
+
+input[type=text]:disabled::placeholder,
+input[type=tel]:disabled::placeholder,
+input[type=email]:disabled::placeholder,
+input[type=url]:disabled::placeholder {
+ color: #a8bece;
}
-
/* ==========================================================================
** Textareas
** ======================================================================= */
-
textarea {
- border-radius: 0;
- -webkit-appearance: none;
- appearance: none;
- box-sizing: border-box;
- margin: 0;
- padding: 7px 14px;
- height: 92px;
- width: 100%;
- color: #2e4453;
- font-size: 16px;
- line-height: 1.5;
- border: 1px solid #c8d7e1;
- background-color: #fff;
- transition: all .15s ease-in-out;
- box-shadow: none;
+ border-radius: 0;
+ -webkit-appearance: none;
+ appearance: none;
+ box-sizing: border-box;
+ margin: 0;
+ padding: 7px 14px;
+ height: 92px;
+ width: 100%;
+ color: #2e4453;
+ font-size: 16px;
+ line-height: 1.5;
+ border: 1px solid #c8d7e1;
+ background-color: #fff;
+ transition: all 0.15s ease-in-out;
+ box-shadow: none;
}
textarea::placeholder {
- color: #87a6bc;
+ color: #87a6bc;
}
textarea:hover {
- border-color: #a8bece;
+ border-color: #a8bece;
}
textarea:focus {
- border-color: #0087be;
- outline: none;
- box-shadow: 0 0 0 2px #78dcfa;
+ border-color: #0087be;
+ outline: none;
+ box-shadow: 0 0 0 2px #78dcfa;
}
textarea:focus::-ms-clear {
- display: none;
+ display: none;
}
textarea:disabled {
- background: #f3f6f8;
- border-color: #e9eff3;
- color: #a8bece;
- -webkit-text-fill-color: #a8bece;
+ background: #f3f6f8;
+ border-color: #e9eff3;
+ color: #a8bece;
+ -webkit-text-fill-color: #a8bece;
}
textarea:disabled:hover {
- cursor: default;
+ cursor: default;
}
textarea:disabled::placeholder {
- color: #a8bece;
+ color: #a8bece;
}
-
/* ==========================================================================
** Checkboxes
** ======================================================================= */
-
-input[type="checkbox"] {
- -webkit-appearance: none;
- display: inline-block;
- box-sizing: border-box;
- margin: 2px 0 0;
- padding: 7px 14px;
- width: 16px;
- height: 16px;
- float: right;
- outline: 0;
- padding: 0;
- box-shadow: none;
- background-color: #fff;
- border: 1px solid #c8d7e1;
- color: #2e4453;
- font-size: 16px;
- line-height: 0;
- text-align: center;
- vertical-align: middle;
- appearance: none;
- transition: all .15s ease-in-out;
- clear: none;
- cursor: pointer;
-}
-
-input[type="checkbox"]:checked:before {
- content: '\f147';
- font-family: Dashicons;
- margin: -3px -4px 0 0;
- float: right;
- display: inline-block;
- vertical-align: middle;
- width: 16px;
- font-size: 20px;
- line-height: 1;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- speak: none;
- color: #00aadc;
-}
-
-input[type="checkbox"]:disabled:checked:before {
- color: #a8bece;
-}
-
-input[type="checkbox"]:hover {
- border-color: #a8bece;
-}
-
-input[type="checkbox"]:focus {
- border-color: #0087be;
- outline: none;
- box-shadow: 0 0 0 2px #78dcfa;
-}
-
-input[type="checkbox"]:disabled {
- background: #f3f6f8;
- border-color: #e9eff3;
- color: #a8bece;
- opacity: 1;
-}
-
-input[type="checkbox"]:disabled:hover {
- cursor: default;
-}
-
-input[type="checkbox"] + span {
- display: block;
- font-weight: normal;
- margin-right: 24px;
+input[type=checkbox] {
+ -webkit-appearance: none;
+ display: inline-block;
+ box-sizing: border-box;
+ margin: 2px 0 0;
+ padding: 7px 14px;
+ width: 16px;
+ height: 16px;
+ float: right;
+ outline: 0;
+ padding: 0;
+ box-shadow: none;
+ background-color: #fff;
+ border: 1px solid #c8d7e1;
+ color: #2e4453;
+ font-size: 16px;
+ line-height: 0;
+ text-align: center;
+ vertical-align: middle;
+ appearance: none;
+ transition: all 0.15s ease-in-out;
+ clear: none;
+ cursor: pointer;
+}
+
+input[type=checkbox]:checked:before {
+ content: "\f147";
+ font-family: Dashicons;
+ margin: -3px -4px 0 0;
+ float: right;
+ display: inline-block;
+ vertical-align: middle;
+ width: 16px;
+ font-size: 20px;
+ line-height: 1;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ speak: none;
+ color: #00aadc;
+}
+
+input[type=checkbox]:disabled:checked:before {
+ color: #a8bece;
+}
+
+input[type=checkbox]:hover {
+ border-color: #a8bece;
+}
+
+input[type=checkbox]:focus {
+ border-color: #0087be;
+ outline: none;
+ box-shadow: 0 0 0 2px #78dcfa;
+}
+
+input[type=checkbox]:disabled {
+ background: #f3f6f8;
+ border-color: #e9eff3;
+ color: #a8bece;
+ opacity: 1;
+}
+
+input[type=checkbox]:disabled:hover {
+ cursor: default;
+}
+
+input[type=checkbox] + span {
+ display: block;
+ font-weight: normal;
+ margin-right: 24px;
}
-
/* ==========================================================================
** Radio buttons
** ======================================================================== */
-
input[type=radio] {
- color: #2e4453;
- font-size: 16px;
- border: 1px solid #c8d7e1;
- background-color: #fff;
- transition: all .15s ease-in-out;
- box-sizing: border-box;
- -webkit-appearance: none;
- clear: none;
- cursor: pointer;
- display: inline-block;
- line-height: 0;
- height: 16px;
- margin: 2px 0 0 4px;
- float: right;
- outline: 0;
- padding: 0;
- text-align: center;
- vertical-align: middle;
- width: 16px;
- min-width: 16px;
- appearance: none;
- border-radius: 50%;
- line-height: 10px;
+ color: #2e4453;
+ font-size: 16px;
+ border: 1px solid #c8d7e1;
+ background-color: #fff;
+ transition: all 0.15s ease-in-out;
+ box-sizing: border-box;
+ -webkit-appearance: none;
+ clear: none;
+ cursor: pointer;
+ display: inline-block;
+ line-height: 0;
+ height: 16px;
+ margin: 2px 0 0 4px;
+ float: right;
+ outline: 0;
+ padding: 0;
+ text-align: center;
+ vertical-align: middle;
+ width: 16px;
+ min-width: 16px;
+ appearance: none;
+ border-radius: 50%;
+ line-height: 10px;
}
-input[type="radio"]:hover {
- border-color: #a8bece;
+input[type=radio]:hover {
+ border-color: #a8bece;
}
-input[type="radio"]:focus {
- border-color: #0087be;
- outline: none;
- box-shadow: 0 0 0 2px #78dcfa;
+input[type=radio]:focus {
+ border-color: #0087be;
+ outline: none;
+ box-shadow: 0 0 0 2px #78dcfa;
}
-input[type="radio"]:focus::-ms-clear {
- display: none;
+input[type=radio]:focus::-ms-clear {
+ display: none;
}
-input[type="radio"]:checked:before {
- float: right;
- display: inline-block;
- content: '\2022';
- margin: 3px;
- width: 8px;
- height: 8px;
- text-indent: -9999px;
- background: #00aadc;
- vertical-align: middle;
- border-radius: 50%;
- animation: grow .2s ease-in-out;
+input[type=radio]:checked:before {
+ float: right;
+ display: inline-block;
+ content: "•";
+ margin: 3px;
+ width: 8px;
+ height: 8px;
+ text-indent: -9999px;
+ background: #00aadc;
+ vertical-align: middle;
+ border-radius: 50%;
+ animation: grow 0.2s ease-in-out;
}
-input[type="radio"]:disabled {
- background: #f3f6f8;
- border-color: #e9eff3;
- color: #a8bece;
- opacity: 1;
- -webkit-text-fill-color: #a8bece;
+input[type=radio]:disabled {
+ background: #f3f6f8;
+ border-color: #e9eff3;
+ color: #a8bece;
+ opacity: 1;
+ -webkit-text-fill-color: #a8bece;
}
-input[type="radio"]:disabled:hover {
- cursor: default;
+input[type=radio]:disabled:hover {
+ cursor: default;
}
-input[type="radio"]:disabled::placeholder {
- color: #a8bece;
+input[type=radio]:disabled::placeholder {
+ color: #a8bece;
}
-input[type="radio"]:disabled:checked:before {
- background: #e9eff3;
+input[type=radio]:disabled:checked:before {
+ background: #e9eff3;
}
-input[type="radio"] + span {
- display: block;
- font-weight: normal;
- margin-right: 24px;
+input[type=radio] + span {
+ display: block;
+ font-weight: normal;
+ margin-right: 24px;
}
@keyframes grow {
- 0% {
- transform: scale(0.3);
- }
-
- 60% {
- transform: scale(1.15);
- }
-
- 100% {
- transform: scale(1);
- }
+ 0% {
+ transform: scale(0.3);
+ }
+ 60% {
+ transform: scale(1.15);
+ }
+ 100% {
+ transform: scale(1);
+ }
}
-
@keyframes grow {
- 0% {
- transform: scale(0.3);
- }
-
- 60% {
- transform: scale(1.15);
- }
-
- 100% {
- transform: scale(1);
- }
+ 0% {
+ transform: scale(0.3);
+ }
+ 60% {
+ transform: scale(1.15);
+ }
+ 100% {
+ transform: scale(1);
+ }
}
-
-
/* ==========================================================================
** Selects
** ======================================================================== */
-
select {
- background: #fff url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjQzhEN0UxIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat left 10px center;
- border-color: #c8d7e1;
- border-style: solid;
- border-radius: 4px;
- border-width: 1px 1px 2px;
- color: #2e4453;
- cursor: pointer;
- display: inline-block;
- margin: 0;
- outline: 0;
- overflow: hidden;
- font-size: 14px;
- line-height: 21px;
- font-weight: 600;
- text-overflow: ellipsis;
- text-decoration: none;
- vertical-align: top;
- white-space: nowrap;
- box-sizing: border-box;
- /* Aligns the text to the 8px baseline grid and adds padding on right to allow for the arrow. */
- padding: 7px 14px 9px 32px;
- -webkit-appearance: none;
- appearance: none;
+ background: #fff url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjQzhEN0UxIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat left 10px center;
+ border-color: #c8d7e1;
+ border-style: solid;
+ border-radius: 4px;
+ border-width: 1px 1px 2px;
+ color: #2e4453;
+ cursor: pointer;
+ display: inline-block;
+ margin: 0;
+ outline: 0;
+ overflow: hidden;
+ font-size: 14px;
+ line-height: 21px;
+ font-weight: 600;
+ text-overflow: ellipsis;
+ text-decoration: none;
+ vertical-align: top;
+ white-space: nowrap;
+ box-sizing: border-box;
+ /* Aligns the text to the 8px baseline grid and adds padding on right to allow for the arrow. */
+ padding: 7px 14px 9px 32px;
+ -webkit-appearance: none;
+ appearance: none;
}
select:hover {
- background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjYThiZWNlIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==);
+ background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjYThiZWNlIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==);
}
select:focus {
- background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiA8dGl0bGU+YXJyb3ctZG93bjwvdGl0bGU+IDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPiA8ZGVmcz48L2RlZnM+IDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHNrZXRjaDp0eXBlPSJNU1BhZ2UiPiA8ZyBpZD0iYXJyb3ctZG93biIgc2tldGNoOnR5cGU9Ik1TQXJ0Ym9hcmRHcm91cCIgZmlsbD0iIzJlNDQ1MyI+IDxwYXRoIGQ9Ik0xNS41LDYgTDE3LDcuNSBMMTAuMjUsMTQuMjUgTDMuNSw3LjUgTDUsNiBMMTAuMjUsMTEuMjUgTDE1LjUsNiBaIiBpZD0iRG93bi1BcnJvdyIgc2tldGNoOnR5cGU9Ik1TU2hhcGVHcm91cCI+PC9wYXRoPiA8L2c+IDwvZz48L3N2Zz4=);
- border-color: #00aadc;
- box-shadow: 0 0 0 2px #78dcfa;
- outline: 0;
- -moz-outline:none;
- -moz-user-focus:ignore;
+ background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiA8dGl0bGU+YXJyb3ctZG93bjwvdGl0bGU+IDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPiA8ZGVmcz48L2RlZnM+IDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHNrZXRjaDp0eXBlPSJNU1BhZ2UiPiA8ZyBpZD0iYXJyb3ctZG93biIgc2tldGNoOnR5cGU9Ik1TQXJ0Ym9hcmRHcm91cCIgZmlsbD0iIzJlNDQ1MyI+IDxwYXRoIGQ9Ik0xNS41LDYgTDE3LDcuNSBMMTAuMjUsMTQuMjUgTDMuNSw3LjUgTDUsNiBMMTAuMjUsMTEuMjUgTDE1LjUsNiBaIiBpZD0iRG93bi1BcnJvdyIgc2tldGNoOnR5cGU9Ik1TU2hhcGVHcm91cCI+PC9wYXRoPiA8L2c+IDwvZz48L3N2Zz4=);
+ border-color: #00aadc;
+ box-shadow: 0 0 0 2px #78dcfa;
+ outline: 0;
+ -moz-outline: none;
+ -moz-user-focus: ignore;
}
select:disabled,
select:hover:disabled {
- background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjZTllZmYzIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat left 10px center;;
+ background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjZTllZmYzIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat left 10px center;
}
select.is-compact {
- min-width: 0;
- padding: 0 6px 2px 20px;
- margin: 0 4px;
- background-position: left 5px center;
- background-size: 12px 12px;
+ min-width: 0;
+ padding: 0 6px 2px 20px;
+ margin: 0 4px;
+ background-position: left 5px center;
+ background-size: 12px 12px;
}
/* Make it display:block when it follows a label */
label select,
label + select {
- display: block;
- min-width: 200px;
+ display: block;
+ min-width: 200px;
}
label select.is-compact,
label + select.is-compact {
- display: inline-block;
- min-width: 0;
+ display: inline-block;
+ min-width: 0;
}
/* IE: Remove the default arrow */
select::-ms-expand {
- display: none;
+ display: none;
}
/* IE: Remove default background and color styles on focus */
select::-ms-value {
- background: none;
- color: #2e4453;
+ background: none;
+ color: #2e4453;
}
/* Firefox: Remove the focus outline, see http://stackoverflow.com/questions/3773430/remove-outline-from-select-box-in-ff/18853002#18853002 */
select:-moz-focusring {
- color: transparent;
- text-shadow: 0 0 0 #2e4453;
+ color: transparent;
+ text-shadow: 0 0 0 #2e4453;
}
-
/* ==========================================================================
** Buttons
** ======================================================================== */
-
-input[type="submit"] {
- padding: 0;
- font-size: 14px;
- -webkit-appearance: none;
- appearance: none;
- vertical-align: baseline;
- background: white;
- border-color: #c8d7e1;
- border-style: solid;
- border-width: 1px 1px 2px;
- color: #2e4453;
- cursor: pointer;
- display: inline-block;
- margin: 24px 0 0;
- outline: 0;
- overflow: hidden;
- font-weight: 500;
- text-overflow: ellipsis;
- text-decoration: none;
- vertical-align: top;
- box-sizing: border-box;
- font-size: 14px;
- line-height: 21px;
- border-radius: 4px;
- padding: 7px 14px 9px;
- -webkit-appearance: none;
- appearance: none;
-}
-
-input[type="submit"]:hover {
- border-color: #a8bece;
- color: #2e4453;
-}
-
-input[type="submit"]:active {
- border-width: 2px 1px 1px;
-}
-
-input[type="submit"]:visited {
- color: #2e4453;
-}
-
-input[type="submit"][disabled],
-input[type="submit"]:disabled {
- color: #e9eff3;
- background: white;
- border-color: #e9eff3;
- cursor: default;
-}
-
-input[type="submit"][disabled]:active,
-input[type="submit"]:disabled:active {
- border-width: 1px 1px 2px;
-}
-
-input[type="submit"]:focus {
- border-color: #00aadc;
- box-shadow: 0 0 0 2px #78dcfa;
+input[type=submit] {
+ padding: 0;
+ font-size: 14px;
+ -webkit-appearance: none;
+ appearance: none;
+ vertical-align: baseline;
+ background: white;
+ border-color: #c8d7e1;
+ border-style: solid;
+ border-width: 1px 1px 2px;
+ color: #2e4453;
+ cursor: pointer;
+ display: inline-block;
+ margin: 24px 0 0;
+ outline: 0;
+ overflow: hidden;
+ font-weight: 500;
+ text-overflow: ellipsis;
+ text-decoration: none;
+ vertical-align: top;
+ box-sizing: border-box;
+ font-size: 14px;
+ line-height: 21px;
+ border-radius: 4px;
+ padding: 7px 14px 9px;
+ -webkit-appearance: none;
+ appearance: none;
+}
+
+input[type=submit]:hover {
+ border-color: #a8bece;
+ color: #2e4453;
+}
+
+input[type=submit]:active {
+ border-width: 2px 1px 1px;
+}
+
+input[type=submit]:visited {
+ color: #2e4453;
+}
+
+input[type=submit][disabled],
+input[type=submit]:disabled {
+ color: #e9eff3;
+ background: white;
+ border-color: #e9eff3;
+ cursor: default;
+}
+
+input[type=submit][disabled]:active,
+input[type=submit]:disabled:active {
+ border-width: 1px 1px 2px;
+}
+
+input[type=submit]:focus {
+ border-color: #00aadc;
+ box-shadow: 0 0 0 2px #78dcfa;
}
/* ==========================================================================
** Preview styles
** ======================================================================== */
-
.wpview.wpview-wrap[data-wpview-type=contact-form] iframe.inline-edit-contact-form {
- width: 100%;
- min-height: 500px;
- border: 0;
- overflow: hidden;
- margin-bottom: 0;
- display: block;
+ width: 100%;
+ min-height: 500px;
+ border: 0;
+ overflow: hidden;
+ margin-bottom: 0;
+ display: block;
}
.contact-submit.contact-submit {
- margin-top: 0;
- margin-bottom: 0;
+ margin-top: 0;
+ margin-bottom: 0;
}
diff --git a/plugins/jetpack/modules/contact-form/css/editor-style-rtl.min.css b/plugins/jetpack/modules/contact-form/css/editor-style-rtl.min.css
index 62703fbb..1ca0e5b1 100644
--- a/plugins/jetpack/modules/contact-form/css/editor-style-rtl.min.css
+++ b/plugins/jetpack/modules/contact-form/css/editor-style-rtl.min.css
@@ -1 +1 @@
-body,label{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:16px;line-height:1.4em}.card{display:block;position:relative;margin:0 auto;padding:16px;box-sizing:border-box;background:#fff;box-shadow:0 0 0 1px rgba(200,215,225,.5),0 1px 2px #e9eff3}.card:after{content:".";display:block;height:0;clear:both;visibility:hidden}@media (min-width:481px){.card{padding:24px}}.card>div{margin-top:24px}.card>div:first-child{margin-top:0}label{display:block;font-size:14px;font-weight:600;margin-bottom:5px}input[type=email],input[type=tel],input[type=text],input[type=url]{border-radius:0;-webkit-appearance:none;appearance:none;box-sizing:border-box;margin:0;padding:7px 14px;width:100%;color:#2e4453;font-size:16px;line-height:1.5;border:1px solid #c8d7e1;background-color:#fff;transition:all .15s ease-in-out;box-shadow:none}input[type=email]::placeholder,input[type=tel]::placeholder,input[type=text]::placeholder,input[type=url]::placeholder{color:#87a6bc}input[type=email]:hover,input[type=tel]:hover,input[type=text]:hover,input[type=url]:hover{border-color:#a8bece}input[type=email]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=url]:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}input[type=email]:focus::-ms-clear,input[type=tel]:focus::-ms-clear,input[type=text]:focus::-ms-clear,input[type=url]:focus::-ms-clear{display:none}input[type=email]:disabled,input[type=tel]:disabled,input[type=text]:disabled,input[type=url]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;-webkit-text-fill-color:#a8bece}input[type=email]:disabled:hover,input[type=tel]:disabled:hover,input[type=text]:disabled:hover,input[type=url]:disabled:hover{cursor:default}input[type=email]:disabled::placeholder,input[type=tel]:disabled::placeholder,input[type=text]:disabled::placeholder,input[type=url]:disabled::placeholder{color:#a8bece}textarea{border-radius:0;-webkit-appearance:none;appearance:none;box-sizing:border-box;margin:0;padding:7px 14px;height:92px;width:100%;color:#2e4453;font-size:16px;line-height:1.5;border:1px solid #c8d7e1;background-color:#fff;transition:all .15s ease-in-out;box-shadow:none}textarea::placeholder{color:#87a6bc}textarea:hover{border-color:#a8bece}textarea:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}textarea:focus::-ms-clear{display:none}textarea:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;-webkit-text-fill-color:#a8bece}textarea:disabled:hover{cursor:default}textarea:disabled::placeholder{color:#a8bece}input[type=checkbox]{-webkit-appearance:none;display:inline-block;box-sizing:border-box;margin:2px 0 0;padding:7px 14px;width:16px;height:16px;float:right;outline:0;padding:0;box-shadow:none;background-color:#fff;border:1px solid #c8d7e1;color:#2e4453;font-size:16px;line-height:0;text-align:center;vertical-align:middle;appearance:none;transition:all .15s ease-in-out;clear:none;cursor:pointer}input[type=checkbox]:checked:before{content:'\f147';font-family:Dashicons;margin:-3px -4px 0 0;float:right;display:inline-block;vertical-align:middle;width:16px;font-size:20px;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none;color:#00aadc}input[type=checkbox]:disabled:checked:before{color:#a8bece}input[type=checkbox]:hover{border-color:#a8bece}input[type=checkbox]:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}input[type=checkbox]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1}input[type=checkbox]:disabled:hover{cursor:default}input[type=checkbox]+span{display:block;font-weight:400;margin-right:24px}input[type=radio]{color:#2e4453;font-size:16px;border:1px solid #c8d7e1;background-color:#fff;transition:all .15s ease-in-out;box-sizing:border-box;-webkit-appearance:none;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:2px 0 0 4px;float:right;outline:0;padding:0;text-align:center;vertical-align:middle;width:16px;min-width:16px;appearance:none;border-radius:50%;line-height:10px}input[type=radio]:hover{border-color:#a8bece}input[type=radio]:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}input[type=radio]:focus::-ms-clear{display:none}input[type=radio]:checked:before{float:right;display:inline-block;content:'\2022';margin:3px;width:8px;height:8px;text-indent:-9999px;background:#00aadc;vertical-align:middle;border-radius:50%;animation:grow .2s ease-in-out}input[type=radio]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1;-webkit-text-fill-color:#a8bece}input[type=radio]:disabled:hover{cursor:default}input[type=radio]:disabled::placeholder{color:#a8bece}input[type=radio]:disabled:checked:before{background:#e9eff3}input[type=radio]+span{display:block;font-weight:400;margin-right:24px}@keyframes grow{0%{transform:scale(.3)}60%{transform:scale(1.15)}100%{transform:scale(1)}}@keyframes grow{0%{transform:scale(.3)}60%{transform:scale(1.15)}100%{transform:scale(1)}}select{background:#fff url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjQzhEN0UxIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat left 10px center;border-color:#c8d7e1;border-style:solid;border-radius:4px;border-width:1px 1px 2px;color:#2e4453;cursor:pointer;display:inline-block;margin:0;outline:0;overflow:hidden;font-size:14px;line-height:21px;font-weight:600;text-overflow:ellipsis;text-decoration:none;vertical-align:top;white-space:nowrap;box-sizing:border-box;padding:7px 14px 9px 32px;-webkit-appearance:none;appearance:none}select:hover{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjYThiZWNlIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==)}select:focus{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiA8dGl0bGU+YXJyb3ctZG93bjwvdGl0bGU+IDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPiA8ZGVmcz48L2RlZnM+IDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHNrZXRjaDp0eXBlPSJNU1BhZ2UiPiA8ZyBpZD0iYXJyb3ctZG93biIgc2tldGNoOnR5cGU9Ik1TQXJ0Ym9hcmRHcm91cCIgZmlsbD0iIzJlNDQ1MyI+IDxwYXRoIGQ9Ik0xNS41LDYgTDE3LDcuNSBMMTAuMjUsMTQuMjUgTDMuNSw3LjUgTDUsNiBMMTAuMjUsMTEuMjUgTDE1LjUsNiBaIiBpZD0iRG93bi1BcnJvdyIgc2tldGNoOnR5cGU9Ik1TU2hhcGVHcm91cCI+PC9wYXRoPiA8L2c+IDwvZz48L3N2Zz4=);border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa;outline:0;-moz-outline:none;-moz-user-focus:ignore}select:disabled,select:hover:disabled{background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjZTllZmYzIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat left 10px center}select.is-compact{min-width:0;padding:0 6px 2px 20px;margin:0 4px;background-position:left 5px center;background-size:12px 12px}label select,label+select{display:block;min-width:200px}label select.is-compact,label+select.is-compact{display:inline-block;min-width:0}select::-ms-expand{display:none}select::-ms-value{background:0 0;color:#2e4453}select:-moz-focusring{color:transparent;text-shadow:0 0 0 #2e4453}input[type=submit]{padding:0;font-size:14px;-webkit-appearance:none;appearance:none;vertical-align:baseline;background:#fff;border-color:#c8d7e1;border-style:solid;border-width:1px 1px 2px;color:#2e4453;cursor:pointer;display:inline-block;margin:24px 0 0;outline:0;overflow:hidden;font-weight:500;text-overflow:ellipsis;text-decoration:none;vertical-align:top;box-sizing:border-box;font-size:14px;line-height:21px;border-radius:4px;padding:7px 14px 9px;-webkit-appearance:none;appearance:none}input[type=submit]:hover{border-color:#a8bece;color:#2e4453}input[type=submit]:active{border-width:2px 1px 1px}input[type=submit]:visited{color:#2e4453}input[type=submit]:disabled,input[type=submit][disabled]{color:#e9eff3;background:#fff;border-color:#e9eff3;cursor:default}input[type=submit]:disabled:active,input[type=submit][disabled]:active{border-width:1px 1px 2px}input[type=submit]:focus{border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa}.wpview.wpview-wrap[data-wpview-type=contact-form] iframe.inline-edit-contact-form{width:100%;min-height:500px;border:0;overflow:hidden;margin-bottom:0;display:block}.contact-submit.contact-submit{margin-top:0;margin-bottom:0} \ No newline at end of file
+@charset "UTF-8";body,label{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:16px;line-height:1.4em}.card{background:#fff;box-shadow:0 0 0 1px rgba(200,215,225,.5),0 1px 2px #e9eff3;box-sizing:border-box;display:block;margin:0 auto;padding:16px;position:relative}.card:after{clear:both;content:".";display:block;height:0;visibility:hidden}@media (min-width:481px){.card{padding:24px}}.card>div{margin-top:24px}.card>div:first-child{margin-top:0}label{display:block;font-size:14px;font-weight:600;margin-bottom:5px}input[type=email],input[type=tel],input[type=text],input[type=url]{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;border-radius:0;box-shadow:none;box-sizing:border-box;color:#2e4453;font-size:16px;line-height:1.5;margin:0;padding:7px 14px;transition:all .15s ease-in-out;width:100%}input[type=email]::placeholder,input[type=tel]::placeholder,input[type=text]::placeholder,input[type=url]::placeholder{color:#87a6bc}input[type=email]:hover,input[type=tel]:hover,input[type=text]:hover,input[type=url]:hover{border-color:#a8bece}input[type=email]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=url]:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}input[type=email]:focus::-ms-clear,input[type=tel]:focus::-ms-clear,input[type=text]:focus::-ms-clear,input[type=url]:focus::-ms-clear{display:none}input[type=email]:disabled,input[type=tel]:disabled,input[type=text]:disabled,input[type=url]:disabled{-webkit-text-fill-color:#a8bece;background:#f3f6f8;border-color:#e9eff3;color:#a8bece}input[type=email]:disabled:hover,input[type=tel]:disabled:hover,input[type=text]:disabled:hover,input[type=url]:disabled:hover{cursor:default}input[type=email]:disabled::placeholder,input[type=tel]:disabled::placeholder,input[type=text]:disabled::placeholder,input[type=url]:disabled::placeholder{color:#a8bece}textarea{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;border-radius:0;box-shadow:none;box-sizing:border-box;color:#2e4453;font-size:16px;height:92px;line-height:1.5;margin:0;padding:7px 14px;transition:all .15s ease-in-out;width:100%}textarea::placeholder{color:#87a6bc}textarea:hover{border-color:#a8bece}textarea:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}textarea:focus::-ms-clear{display:none}textarea:disabled{-webkit-text-fill-color:#a8bece;background:#f3f6f8;border-color:#e9eff3;color:#a8bece}textarea:disabled:hover{cursor:default}textarea:disabled::placeholder{color:#a8bece}input[type=checkbox]{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;box-shadow:none;box-sizing:border-box;clear:none;color:#2e4453;cursor:pointer;font-size:16px;height:16px;line-height:0;margin:2px 0 0;outline:0;padding:0;text-align:center;transition:all .15s ease-in-out}input[type=checkbox],input[type=checkbox]:checked:before{display:inline-block;float:right;vertical-align:middle;width:16px}input[type=checkbox]:checked:before{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none;color:#00aadc;content:"\f147";font-family:Dashicons;font-size:20px;line-height:1;margin:-3px -4px 0 0}input[type=checkbox]:disabled:checked:before{color:#a8bece}input[type=checkbox]:hover{border-color:#a8bece}input[type=checkbox]:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}input[type=checkbox]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1}input[type=checkbox]:disabled:hover{cursor:default}input[type=checkbox]+span{display:block;font-weight:400;margin-right:24px}input[type=radio]{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;border-radius:50%;box-sizing:border-box;clear:none;color:#2e4453;cursor:pointer;display:inline-block;float:right;font-size:16px;height:16px;line-height:0;line-height:10px;margin:2px 0 0 4px;min-width:16px;outline:0;padding:0;text-align:center;transition:all .15s ease-in-out;vertical-align:middle;width:16px}input[type=radio]:hover{border-color:#a8bece}input[type=radio]:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}input[type=radio]:focus::-ms-clear{display:none}input[type=radio]:checked:before{animation:grow .2s ease-in-out;background:#00aadc;border-radius:50%;content:"•";display:inline-block;float:right;height:8px;margin:3px;text-indent:-9999px;vertical-align:middle;width:8px}input[type=radio]:disabled{-webkit-text-fill-color:#a8bece;background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1}input[type=radio]:disabled:hover{cursor:default}input[type=radio]:disabled::placeholder{color:#a8bece}input[type=radio]:disabled:checked:before{background:#e9eff3}input[type=radio]+span{display:block;font-weight:400;margin-right:24px}@keyframes grow{0%{transform:scale(.3)}60%{transform:scale(1.15)}to{transform:scale(1)}}select{-webkit-appearance:none;appearance:none;background:#fff url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iI0M4RDdFMSIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+) no-repeat left 10px center;border:solid #c8d7e1;border-radius:4px;border-width:1px 1px 2px;box-sizing:border-box;color:#2e4453;cursor:pointer;display:inline-block;font-size:14px;font-weight:600;line-height:21px;margin:0;outline:0;overflow:hidden;padding:7px 14px 9px 32px;text-decoration:none;text-overflow:ellipsis;vertical-align:top;white-space:nowrap}select:hover{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iI2E4YmVjZSIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+)}select:focus{-moz-user-focus:ignore;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iIzJlNDQ1MyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+);border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa;outline:0;-moz-outline:none}select:disabled,select:hover:disabled{background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iI2U5ZWZmMyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+) no-repeat left 10px center}select.is-compact{background-position:left 5px center;background-size:12px 12px;margin:0 4px;min-width:0;padding:0 6px 2px 20px}label select,label+select{display:block;min-width:200px}label select.is-compact,label+select.is-compact{display:inline-block;min-width:0}select::-ms-expand{display:none}select::-ms-value{background:none;color:#2e4453}select:-moz-focusring{color:transparent;text-shadow:0 0 0 #2e4453}input[type=submit]{-webkit-appearance:none;appearance:none;background:#fff;border:solid #c8d7e1;border-radius:4px;border-width:1px 1px 2px;box-sizing:border-box;color:#2e4453;cursor:pointer;display:inline-block;font-size:14px;font-weight:500;line-height:21px;margin:24px 0 0;outline:0;overflow:hidden;padding:7px 14px 9px;text-decoration:none;text-overflow:ellipsis;vertical-align:baseline;vertical-align:top}input[type=submit]:hover{border-color:#a8bece;color:#2e4453}input[type=submit]:active{border-width:2px 1px 1px}input[type=submit]:visited{color:#2e4453}input[type=submit]:disabled,input[type=submit][disabled]{background:#fff;border-color:#e9eff3;color:#e9eff3;cursor:default}input[type=submit]:disabled:active,input[type=submit][disabled]:active{border-width:1px 1px 2px}input[type=submit]:focus{border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa}.wpview.wpview-wrap[data-wpview-type=contact-form] iframe.inline-edit-contact-form{border:0;display:block;margin-bottom:0;min-height:500px;overflow:hidden;width:100%}.contact-submit.contact-submit{margin-bottom:0;margin-top:0} \ No newline at end of file
diff --git a/plugins/jetpack/modules/contact-form/css/editor-style.min.css b/plugins/jetpack/modules/contact-form/css/editor-style.min.css
index 67a63821..230ee125 100644
--- a/plugins/jetpack/modules/contact-form/css/editor-style.min.css
+++ b/plugins/jetpack/modules/contact-form/css/editor-style.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-body,label{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:16px;line-height:1.4em}.card{display:block;position:relative;margin:0 auto;padding:16px;box-sizing:border-box;background:#fff;box-shadow:0 0 0 1px rgba(200,215,225,.5),0 1px 2px #e9eff3}.card:after{content:".";display:block;height:0;clear:both;visibility:hidden}@media (min-width:481px){.card{padding:24px}}.card>div{margin-top:24px}.card>div:first-child{margin-top:0}label{display:block;font-size:14px;font-weight:600;margin-bottom:5px}input[type=email],input[type=tel],input[type=text],input[type=url]{border-radius:0;-webkit-appearance:none;appearance:none;box-sizing:border-box;margin:0;padding:7px 14px;width:100%;color:#2e4453;font-size:16px;line-height:1.5;border:1px solid #c8d7e1;background-color:#fff;transition:all .15s ease-in-out;box-shadow:none}input[type=email]::placeholder,input[type=tel]::placeholder,input[type=text]::placeholder,input[type=url]::placeholder{color:#87a6bc}input[type=email]:hover,input[type=tel]:hover,input[type=text]:hover,input[type=url]:hover{border-color:#a8bece}input[type=email]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=url]:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}input[type=email]:focus::-ms-clear,input[type=tel]:focus::-ms-clear,input[type=text]:focus::-ms-clear,input[type=url]:focus::-ms-clear{display:none}input[type=email]:disabled,input[type=tel]:disabled,input[type=text]:disabled,input[type=url]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;-webkit-text-fill-color:#a8bece}input[type=email]:disabled:hover,input[type=tel]:disabled:hover,input[type=text]:disabled:hover,input[type=url]:disabled:hover{cursor:default}input[type=email]:disabled::placeholder,input[type=tel]:disabled::placeholder,input[type=text]:disabled::placeholder,input[type=url]:disabled::placeholder{color:#a8bece}textarea{border-radius:0;-webkit-appearance:none;appearance:none;box-sizing:border-box;margin:0;padding:7px 14px;height:92px;width:100%;color:#2e4453;font-size:16px;line-height:1.5;border:1px solid #c8d7e1;background-color:#fff;transition:all .15s ease-in-out;box-shadow:none}textarea::placeholder{color:#87a6bc}textarea:hover{border-color:#a8bece}textarea:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}textarea:focus::-ms-clear{display:none}textarea:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;-webkit-text-fill-color:#a8bece}textarea:disabled:hover{cursor:default}textarea:disabled::placeholder{color:#a8bece}input[type=checkbox]{-webkit-appearance:none;display:inline-block;box-sizing:border-box;margin:2px 0 0;padding:7px 14px;width:16px;height:16px;float:left;outline:0;padding:0;box-shadow:none;background-color:#fff;border:1px solid #c8d7e1;color:#2e4453;font-size:16px;line-height:0;text-align:center;vertical-align:middle;appearance:none;transition:all .15s ease-in-out;clear:none;cursor:pointer}input[type=checkbox]:checked:before{content:'\f147';font-family:Dashicons;margin:-3px 0 0 -4px;float:left;display:inline-block;vertical-align:middle;width:16px;font-size:20px;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none;color:#00aadc}input[type=checkbox]:disabled:checked:before{color:#a8bece}input[type=checkbox]:hover{border-color:#a8bece}input[type=checkbox]:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}input[type=checkbox]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1}input[type=checkbox]:disabled:hover{cursor:default}input[type=checkbox]+span{display:block;font-weight:400;margin-left:24px}input[type=radio]{color:#2e4453;font-size:16px;border:1px solid #c8d7e1;background-color:#fff;transition:all .15s ease-in-out;box-sizing:border-box;-webkit-appearance:none;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:2px 4px 0 0;float:left;outline:0;padding:0;text-align:center;vertical-align:middle;width:16px;min-width:16px;appearance:none;border-radius:50%;line-height:10px}input[type=radio]:hover{border-color:#a8bece}input[type=radio]:focus{border-color:#0087be;outline:0;box-shadow:0 0 0 2px #78dcfa}input[type=radio]:focus::-ms-clear{display:none}input[type=radio]:checked:before{float:left;display:inline-block;content:'\2022';margin:3px;width:8px;height:8px;text-indent:-9999px;background:#00aadc;vertical-align:middle;border-radius:50%;animation:grow .2s ease-in-out}input[type=radio]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1;-webkit-text-fill-color:#a8bece}input[type=radio]:disabled:hover{cursor:default}input[type=radio]:disabled::placeholder{color:#a8bece}input[type=radio]:disabled:checked:before{background:#e9eff3}input[type=radio]+span{display:block;font-weight:400;margin-left:24px}@keyframes grow{0%{transform:scale(.3)}60%{transform:scale(1.15)}100%{transform:scale(1)}}@keyframes grow{0%{transform:scale(.3)}60%{transform:scale(1.15)}100%{transform:scale(1)}}select{background:#fff url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjQzhEN0UxIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat right 10px center;border-color:#c8d7e1;border-style:solid;border-radius:4px;border-width:1px 1px 2px;color:#2e4453;cursor:pointer;display:inline-block;margin:0;outline:0;overflow:hidden;font-size:14px;line-height:21px;font-weight:600;text-overflow:ellipsis;text-decoration:none;vertical-align:top;white-space:nowrap;box-sizing:border-box;padding:7px 32px 9px 14px;-webkit-appearance:none;appearance:none}select:hover{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjYThiZWNlIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==)}select:focus{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiA8dGl0bGU+YXJyb3ctZG93bjwvdGl0bGU+IDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPiA8ZGVmcz48L2RlZnM+IDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHNrZXRjaDp0eXBlPSJNU1BhZ2UiPiA8ZyBpZD0iYXJyb3ctZG93biIgc2tldGNoOnR5cGU9Ik1TQXJ0Ym9hcmRHcm91cCIgZmlsbD0iIzJlNDQ1MyI+IDxwYXRoIGQ9Ik0xNS41LDYgTDE3LDcuNSBMMTAuMjUsMTQuMjUgTDMuNSw3LjUgTDUsNiBMMTAuMjUsMTEuMjUgTDE1LjUsNiBaIiBpZD0iRG93bi1BcnJvdyIgc2tldGNoOnR5cGU9Ik1TU2hhcGVHcm91cCI+PC9wYXRoPiA8L2c+IDwvZz48L3N2Zz4=);border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa;outline:0;-moz-outline:none;-moz-user-focus:ignore}select:disabled,select:hover:disabled{background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM6c2tldGNoPSJodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2gvbnMiPiAgICAgICAgPHRpdGxlPmFycm93LWRvd248L3RpdGxlPiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4gICAgPGRlZnM+PC9kZWZzPiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBza2V0Y2g6dHlwZT0iTVNQYWdlIj4gICAgICAgIDxnIGlkPSJhcnJvdy1kb3duIiBza2V0Y2g6dHlwZT0iTVNBcnRib2FyZEdyb3VwIiBmaWxsPSIjZTllZmYzIj4gICAgICAgICAgICA8cGF0aCBkPSJNMTUuNSw2IEwxNyw3LjUgTDEwLjI1LDE0LjI1IEwzLjUsNy41IEw1LDYgTDEwLjI1LDExLjI1IEwxNS41LDYgWiIgaWQ9IkRvd24tQXJyb3ciIHNrZXRjaDp0eXBlPSJNU1NoYXBlR3JvdXAiPjwvcGF0aD4gICAgICAgIDwvZz4gICAgPC9nPjwvc3ZnPg==) no-repeat right 10px center}select.is-compact{min-width:0;padding:0 20px 2px 6px;margin:0 4px;background-position:right 5px center;background-size:12px 12px}label select,label+select{display:block;min-width:200px}label select.is-compact,label+select.is-compact{display:inline-block;min-width:0}select::-ms-expand{display:none}select::-ms-value{background:0 0;color:#2e4453}select:-moz-focusring{color:transparent;text-shadow:0 0 0 #2e4453}input[type=submit]{padding:0;font-size:14px;-webkit-appearance:none;appearance:none;vertical-align:baseline;background:#fff;border-color:#c8d7e1;border-style:solid;border-width:1px 1px 2px;color:#2e4453;cursor:pointer;display:inline-block;margin:24px 0 0;outline:0;overflow:hidden;font-weight:500;text-overflow:ellipsis;text-decoration:none;vertical-align:top;box-sizing:border-box;font-size:14px;line-height:21px;border-radius:4px;padding:7px 14px 9px;-webkit-appearance:none;appearance:none}input[type=submit]:hover{border-color:#a8bece;color:#2e4453}input[type=submit]:active{border-width:2px 1px 1px}input[type=submit]:visited{color:#2e4453}input[type=submit]:disabled,input[type=submit][disabled]{color:#e9eff3;background:#fff;border-color:#e9eff3;cursor:default}input[type=submit]:disabled:active,input[type=submit][disabled]:active{border-width:1px 1px 2px}input[type=submit]:focus{border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa}.wpview.wpview-wrap[data-wpview-type=contact-form] iframe.inline-edit-contact-form{width:100%;min-height:500px;border:0;overflow:hidden;margin-bottom:0;display:block}.contact-submit.contact-submit{margin-top:0;margin-bottom:0} \ No newline at end of file
+@charset "UTF-8";body,label{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:16px;line-height:1.4em}.card{background:#fff;box-shadow:0 0 0 1px rgba(200,215,225,.5),0 1px 2px #e9eff3;box-sizing:border-box;display:block;margin:0 auto;padding:16px;position:relative}.card:after{clear:both;content:".";display:block;height:0;visibility:hidden}@media (min-width:481px){.card{padding:24px}}.card>div{margin-top:24px}.card>div:first-child{margin-top:0}label{display:block;font-size:14px;font-weight:600;margin-bottom:5px}input[type=email],input[type=tel],input[type=text],input[type=url]{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;border-radius:0;box-shadow:none;box-sizing:border-box;color:#2e4453;font-size:16px;line-height:1.5;margin:0;padding:7px 14px;transition:all .15s ease-in-out;width:100%}input[type=email]::placeholder,input[type=tel]::placeholder,input[type=text]::placeholder,input[type=url]::placeholder{color:#87a6bc}input[type=email]:hover,input[type=tel]:hover,input[type=text]:hover,input[type=url]:hover{border-color:#a8bece}input[type=email]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=url]:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}input[type=email]:focus::-ms-clear,input[type=tel]:focus::-ms-clear,input[type=text]:focus::-ms-clear,input[type=url]:focus::-ms-clear{display:none}input[type=email]:disabled,input[type=tel]:disabled,input[type=text]:disabled,input[type=url]:disabled{-webkit-text-fill-color:#a8bece;background:#f3f6f8;border-color:#e9eff3;color:#a8bece}input[type=email]:disabled:hover,input[type=tel]:disabled:hover,input[type=text]:disabled:hover,input[type=url]:disabled:hover{cursor:default}input[type=email]:disabled::placeholder,input[type=tel]:disabled::placeholder,input[type=text]:disabled::placeholder,input[type=url]:disabled::placeholder{color:#a8bece}textarea{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;border-radius:0;box-shadow:none;box-sizing:border-box;color:#2e4453;font-size:16px;height:92px;line-height:1.5;margin:0;padding:7px 14px;transition:all .15s ease-in-out;width:100%}textarea::placeholder{color:#87a6bc}textarea:hover{border-color:#a8bece}textarea:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}textarea:focus::-ms-clear{display:none}textarea:disabled{-webkit-text-fill-color:#a8bece;background:#f3f6f8;border-color:#e9eff3;color:#a8bece}textarea:disabled:hover{cursor:default}textarea:disabled::placeholder{color:#a8bece}input[type=checkbox]{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;box-shadow:none;box-sizing:border-box;clear:none;color:#2e4453;cursor:pointer;font-size:16px;height:16px;line-height:0;margin:2px 0 0;outline:0;padding:0;text-align:center;transition:all .15s ease-in-out}input[type=checkbox],input[type=checkbox]:checked:before{display:inline-block;float:left;vertical-align:middle;width:16px}input[type=checkbox]:checked:before{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none;color:#00aadc;content:"\f147";font-family:Dashicons;font-size:20px;line-height:1;margin:-3px 0 0 -4px}input[type=checkbox]:disabled:checked:before{color:#a8bece}input[type=checkbox]:hover{border-color:#a8bece}input[type=checkbox]:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}input[type=checkbox]:disabled{background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1}input[type=checkbox]:disabled:hover{cursor:default}input[type=checkbox]+span{display:block;font-weight:400;margin-left:24px}input[type=radio]{-webkit-appearance:none;appearance:none;background-color:#fff;border:1px solid #c8d7e1;border-radius:50%;box-sizing:border-box;clear:none;color:#2e4453;cursor:pointer;display:inline-block;float:left;font-size:16px;height:16px;line-height:0;line-height:10px;margin:2px 4px 0 0;min-width:16px;outline:0;padding:0;text-align:center;transition:all .15s ease-in-out;vertical-align:middle;width:16px}input[type=radio]:hover{border-color:#a8bece}input[type=radio]:focus{border-color:#0087be;box-shadow:0 0 0 2px #78dcfa;outline:none}input[type=radio]:focus::-ms-clear{display:none}input[type=radio]:checked:before{animation:grow .2s ease-in-out;background:#00aadc;border-radius:50%;content:"•";display:inline-block;float:left;height:8px;margin:3px;text-indent:-9999px;vertical-align:middle;width:8px}input[type=radio]:disabled{-webkit-text-fill-color:#a8bece;background:#f3f6f8;border-color:#e9eff3;color:#a8bece;opacity:1}input[type=radio]:disabled:hover{cursor:default}input[type=radio]:disabled::placeholder{color:#a8bece}input[type=radio]:disabled:checked:before{background:#e9eff3}input[type=radio]+span{display:block;font-weight:400;margin-left:24px}@keyframes grow{0%{transform:scale(.3)}60%{transform:scale(1.15)}to{transform:scale(1)}}select{-webkit-appearance:none;appearance:none;background:#fff url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iI0M4RDdFMSIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+) no-repeat right 10px center;border:solid #c8d7e1;border-radius:4px;border-width:1px 1px 2px;box-sizing:border-box;color:#2e4453;cursor:pointer;display:inline-block;font-size:14px;font-weight:600;line-height:21px;margin:0;outline:0;overflow:hidden;padding:7px 32px 9px 14px;text-decoration:none;text-overflow:ellipsis;vertical-align:top;white-space:nowrap}select:hover{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iI2E4YmVjZSIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+)}select:focus{-moz-user-focus:ignore;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iIzJlNDQ1MyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+);border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa;outline:0;-moz-outline:none}select:disabled,select:hover:disabled{background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE1LjUgNiAxNyA3LjVsLTYuNzUgNi43NUwzLjUgNy41IDUgNmw1LjI1IDUuMjVMMTUuNSA2WiIgZmlsbD0iI2U5ZWZmMyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+) no-repeat right 10px center}select.is-compact{background-position:right 5px center;background-size:12px 12px;margin:0 4px;min-width:0;padding:0 20px 2px 6px}label select,label+select{display:block;min-width:200px}label select.is-compact,label+select.is-compact{display:inline-block;min-width:0}select::-ms-expand{display:none}select::-ms-value{background:none;color:#2e4453}select:-moz-focusring{color:transparent;text-shadow:0 0 0 #2e4453}input[type=submit]{-webkit-appearance:none;appearance:none;background:#fff;border:solid #c8d7e1;border-radius:4px;border-width:1px 1px 2px;box-sizing:border-box;color:#2e4453;cursor:pointer;display:inline-block;font-size:14px;font-weight:500;line-height:21px;margin:24px 0 0;outline:0;overflow:hidden;padding:7px 14px 9px;text-decoration:none;text-overflow:ellipsis;vertical-align:baseline;vertical-align:top}input[type=submit]:hover{border-color:#a8bece;color:#2e4453}input[type=submit]:active{border-width:2px 1px 1px}input[type=submit]:visited{color:#2e4453}input[type=submit]:disabled,input[type=submit][disabled]{background:#fff;border-color:#e9eff3;color:#e9eff3;cursor:default}input[type=submit]:disabled:active,input[type=submit][disabled]:active{border-width:1px 1px 2px}input[type=submit]:focus{border-color:#00aadc;box-shadow:0 0 0 2px #78dcfa}.wpview.wpview-wrap[data-wpview-type=contact-form] iframe.inline-edit-contact-form{border:0;display:block;margin-bottom:0;min-height:500px;overflow:hidden;width:100%}.contact-submit.contact-submit{margin-bottom:0;margin-top:0} \ No newline at end of file
diff --git a/plugins/jetpack/modules/contact-form/css/editor-ui-rtl.css b/plugins/jetpack/modules/contact-form/css/editor-ui-rtl.css
index f5f33a42..381bc812 100644
--- a/plugins/jetpack/modules/contact-form/css/editor-ui-rtl.css
+++ b/plugins/jetpack/modules/contact-form/css/editor-ui-rtl.css
@@ -1,19 +1,18 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
i.mce-i-grunion {
- font-size: 20px;
- font-family: dashicons;
+ font-size: 20px;
+ font-family: dashicons;
}
i.mce-i-grunion:before,
.jetpack-contact-form-icon:before {
- content: '\f175';
- vertical-align: top;
+ content: "\f175";
+ vertical-align: top;
}
.jetpack-contact-form-icon {
- opacity: 0.7;
- vertical-align: text-top;
- display: inline-block;
- height: 18px;
- font: 18px/1 dashicons;
+ opacity: 0.7;
+ vertical-align: text-top;
+ display: inline-block;
+ height: 18px;
+ font: 18px/1 dashicons;
}
diff --git a/plugins/jetpack/modules/contact-form/css/editor-ui-rtl.min.css b/plugins/jetpack/modules/contact-form/css/editor-ui-rtl.min.css
index e9eb7c4d..65a5b650 100644
--- a/plugins/jetpack/modules/contact-form/css/editor-ui-rtl.min.css
+++ b/plugins/jetpack/modules/contact-form/css/editor-ui-rtl.min.css
@@ -1 +1 @@
-i.mce-i-grunion{font-size:20px;font-family:dashicons}.jetpack-contact-form-icon:before,i.mce-i-grunion:before{content:'\f175';vertical-align:top}.jetpack-contact-form-icon{opacity:.7;vertical-align:text-top;display:inline-block;height:18px;font:18px/1 dashicons} \ No newline at end of file
+i.mce-i-grunion{font-family:dashicons;font-size:20px}.jetpack-contact-form-icon:before,i.mce-i-grunion:before{content:"\f175";vertical-align:top}.jetpack-contact-form-icon{display:inline-block;font:18px/1 dashicons;height:18px;opacity:.7;vertical-align:text-top} \ No newline at end of file
diff --git a/plugins/jetpack/modules/contact-form/css/editor-ui.min.css b/plugins/jetpack/modules/contact-form/css/editor-ui.min.css
index 2ca28137..65a5b650 100644
--- a/plugins/jetpack/modules/contact-form/css/editor-ui.min.css
+++ b/plugins/jetpack/modules/contact-form/css/editor-ui.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-i.mce-i-grunion{font-size:20px;font-family:dashicons}.jetpack-contact-form-icon:before,i.mce-i-grunion:before{content:'\f175';vertical-align:top}.jetpack-contact-form-icon{opacity:.7;vertical-align:text-top;display:inline-block;height:18px;font:18px/1 dashicons} \ No newline at end of file
+i.mce-i-grunion{font-family:dashicons;font-size:20px}.jetpack-contact-form-icon:before,i.mce-i-grunion:before{content:"\f175";vertical-align:top}.jetpack-contact-form-icon{display:inline-block;font:18px/1 dashicons;height:18px;opacity:.7;vertical-align:text-top} \ No newline at end of file
diff --git a/plugins/jetpack/modules/contact-form/css/grunion-rtl.css b/plugins/jetpack/modules/contact-form/css/grunion-rtl.css
index 071add9e..adfb9192 100644
--- a/plugins/jetpack/modules/contact-form/css/grunion-rtl.css
+++ b/plugins/jetpack/modules/contact-form/css/grunion-rtl.css
@@ -1 +1 @@
-.contact-form .clear-form{clear:both}.contact-form input::placeholder{transition:opacity .3s ease-out}.contact-form input:hover::placeholder{opacity:.5}.contact-form input:focus::placeholder{opacity:.3}.contact-form input[type=email],.contact-form input[type=tel],.contact-form input[type=text],.contact-form input[type=url]{box-sizing:border-box;margin-bottom:1.5em;width:100%;padding:14px 7px}.contact-form select{margin-bottom:1.5em;padding:14px 7px;min-width:150px}.contact-form textarea{box-sizing:border-box;float:none;height:200px;margin-bottom:1.5em;width:100%;padding:7px;font:inherit}.contact-form input[type=checkbox],.contact-form input[type=radio]{float:none;margin:0 5px 0 .75rem}.contact-form input[type=checkbox]{top:0;margin-right:0}.contact-form label{margin-bottom:.25em;float:none;font-weight:700;display:block}.contact-form label.consent-implicit input{display:none}.contact-form label.checkbox,.contact-form label.checkbox-multiple,.contact-form label.radio{margin-bottom:.25em;float:none;font-weight:400;display:inline-flex;align-items:center}.contact-form .grunion-field-checkbox-multiple-wrap,.contact-form .grunion-field-checkbox-wrap,.contact-form .grunion-field-consent-wrap,.contact-form .grunion-field-radio-wrap{margin-bottom:1em}.contact-form label span{font-size:85%;margin-right:.25em;font-weight:400}.contact-form-submission{margin-bottom:4em;padding:1.5em 1em}.contact-form-submission p{margin:0 auto;word-wrap:break-word}.form-errors .form-error-message{color:red}.textwidget .contact-form input[type=email],.textwidget .contact-form input[type=tel],.textwidget .contact-form input[type=text],.textwidget .contact-form input[type=url],.textwidget .contact-form textarea,.wp-block-column .contact-form input[type=email],.wp-block-column .contact-form input[type=tel],.wp-block-column .contact-form input[type=text],.wp-block-column .contact-form input[type=url],.wp-block-column .contact-form textarea{width:100%}#jetpack-check-feedback-spam{margin:1px 0 0 8px}.jetpack-check-feedback-spam-spinner{display:inline-block;margin-top:7px}.wp-block-jetpack-contact-form{display:flex;flex-wrap:wrap;justify-content:flex-start;flex-direction:row}.wp-block-jetpack-button,.wp-block-jetpack-contact-form .grunion-field-wrap{flex:0 0 100%}.wp-block-jetpack-button button{padding:20px 30px;border:inherit;font:inherit}.wp-block-jetpack-button.alignright button{float:left}.wp-block-jetpack-contact-form .grunion-field-wrap{border-left:15px solid transparent}.wp-block-jetpack-contact-form .grunion-field-width-25-wrap{flex:0 0 25%}.wp-block-jetpack-contact-form .grunion-field-width-50-wrap{flex:0 0 50%}.wp-block-jetpack-contact-form .grunion-field-width-75-wrap{flex:0 0 75%}.grunion-field-checkbox-wrap,.grunion-field-consent-wrap{align-self:center}@media only screen and (min-width:600px){.contact-form input[type=email],.contact-form input[type=tel],.contact-form input[type=text],.contact-form input[type=url]{width:50%}.wp-block-jetpack-contact-form input[type=email],.wp-block-jetpack-contact-form input[type=tel],.wp-block-jetpack-contact-form input[type=text],.wp-block-jetpack-contact-form input[type=url]{width:100%}}.jetpack-empty-spam-container{display:inline-block}.jetpack-empty-spam{display:inline-block}.jetpack-empty-spam-spinner{display:inline-block;margin-top:7px}.wp-block-jetpack-contact-form .wp-block-spacer{width:100%} \ No newline at end of file
+.contact-form .clear-form{clear:both}.contact-form input{font:inherit}.contact-form input::placeholder{transition:opacity .3s ease-out}.contact-form input:hover::placeholder{opacity:.5}.contact-form input:focus::placeholder{opacity:.3}.contact-form input[type=email],.contact-form input[type=tel],.contact-form input[type=text],.contact-form input[type=url]{box-sizing:border-box;margin-bottom:1.5em;padding:14px 7px;width:100%}.contact-form select{margin-bottom:1.5em;min-width:150px;padding:14px 7px}.contact-form textarea{box-sizing:border-box;float:none;font:inherit;height:200px;margin-bottom:1.5em;padding:7px;width:100%}.contact-form input[type=checkbox],.contact-form input[type=radio]{float:none;margin:0 5px 0 .75rem}.contact-form input[type=checkbox]{margin-right:0;top:0}.contact-form label{display:block;float:none;font-weight:700;margin-bottom:.25em}.contact-form label.consent-implicit input{display:none}.contact-form label.checkbox,.contact-form label.checkbox-multiple,.contact-form label.radio{align-items:center;display:inline-flex;float:none;font-weight:400;margin-bottom:.25em}.contact-form .grunion-field-checkbox-multiple-wrap,.contact-form .grunion-field-checkbox-wrap,.contact-form .grunion-field-consent-wrap,.contact-form .grunion-field-radio-wrap{margin-bottom:1em}.contact-form label span{font-size:85%;font-weight:400;margin-right:.25em}.contact-form-submission{margin-bottom:4em;padding:1.5em 1em}.contact-form-submission p{word-wrap:break-word;margin:0 auto}.form-errors .form-error-message{color:red}.textwidget .contact-form input[type=email],.textwidget .contact-form input[type=tel],.textwidget .contact-form input[type=text],.textwidget .contact-form input[type=url],.textwidget .contact-form textarea,.wp-block-column .contact-form input[type=email],.wp-block-column .contact-form input[type=tel],.wp-block-column .contact-form input[type=text],.wp-block-column .contact-form input[type=url],.wp-block-column .contact-form textarea{width:100%}#jetpack-check-feedback-spam{margin:1px 0 0 8px}.jetpack-check-feedback-spam-spinner{display:inline-block;margin-top:7px}.wp-block-jetpack-contact-form{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start}.wp-block-jetpack-button,.wp-block-jetpack-contact-form .grunion-field-wrap{flex:0 0 100%}.wp-block-jetpack-button.alignright button{float:left}.wp-block-jetpack-contact-form .grunion-field-wrap{border-left:15px solid transparent}.wp-block-jetpack-contact-form .grunion-field-width-25-wrap{flex:0 0 25%}.wp-block-jetpack-contact-form .grunion-field-width-50-wrap{flex:0 0 50%}.wp-block-jetpack-contact-form .grunion-field-width-75-wrap{flex:0 0 75%}.grunion-field-checkbox-wrap,.grunion-field-consent-wrap{align-self:center}@media only screen and (min-width:600px){.contact-form input[type=email],.contact-form input[type=tel],.contact-form input[type=text],.contact-form input[type=url]{width:50%}.wp-block-jetpack-contact-form input[type=email],.wp-block-jetpack-contact-form input[type=tel],.wp-block-jetpack-contact-form input[type=text],.wp-block-jetpack-contact-form input[type=url]{width:100%}}.jetpack-empty-spam,.jetpack-empty-spam-container{display:inline-block}.jetpack-empty-spam-spinner{display:inline-block;margin-top:7px}.wp-block-jetpack-contact-form .wp-block-spacer{width:100%} \ No newline at end of file
diff --git a/plugins/jetpack/modules/contact-form/css/grunion.css b/plugins/jetpack/modules/contact-form/css/grunion.css
index be46a132..c2f55447 100644
--- a/plugins/jetpack/modules/contact-form/css/grunion.css
+++ b/plugins/jetpack/modules/contact-form/css/grunion.css
@@ -2,6 +2,10 @@
clear: both;
}
+.contact-form input {
+ font: inherit;
+}
+
.contact-form input::placeholder {
transition: opacity 0.3s ease-out;
}
@@ -131,12 +135,6 @@
flex: 0 0 100%;
}
-.wp-block-jetpack-button button {
- padding: 20px 30px;
- border: inherit;
- font: inherit;
-}
-
.wp-block-jetpack-button.alignright button {
float: right;
}
@@ -200,4 +198,4 @@
/* Make sure the set height of the Spacer block nested inside the Contact Form block is respected */
.wp-block-jetpack-contact-form .wp-block-spacer {
width: 100%;
-} \ No newline at end of file
+}
diff --git a/plugins/jetpack/modules/contact-form/grunion-contact-form.php b/plugins/jetpack/modules/contact-form/grunion-contact-form.php
index 3eaa34c3..5a64fbf1 100644
--- a/plugins/jetpack/modules/contact-form/grunion-contact-form.php
+++ b/plugins/jetpack/modules/contact-form/grunion-contact-form.php
@@ -161,7 +161,7 @@ class Grunion_Contact_Form_Plugin {
// Export to CSV feature
if ( is_admin() ) {
- add_action( 'admin_init', array( $this, 'download_feedback_as_csv' ) );
+ add_action( 'admin_post_feedback_export', array( $this, 'download_feedback_as_csv' ) );
add_action( 'admin_footer-edit.php', array( $this, 'export_form' ) );
}
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
@@ -510,13 +510,17 @@ class Grunion_Contact_Form_Plugin {
*
* Conditionally attached to `template_redirect`
*/
- function process_form_submission() {
- // Add a filter to replace tokens in the subject field with sanitized field values
+ public function process_form_submission() {
+ // Add a filter to replace tokens in the subject field with sanitized field values.
add_filter( 'contact_form_subject', array( $this, 'replace_tokens_with_input' ), 10, 2 );
- $id = stripslashes( $_POST['contact-form-id'] );
- $hash = isset( $_POST['contact-form-hash'] ) ? $_POST['contact-form-hash'] : '';
+ // phpcs:disable WordPress.Security.NonceVerification.Missing
+ $id = isset( $_POST['contact-form-id'] ) ? wp_unslash( $_POST['contact-form-id'] ) : null;
+ $id = is_string( $id ) ? $id : null;
+ $hash = isset( $_POST['contact-form-hash'] ) ? wp_unslash( $_POST['contact-form-hash'] ) : null;
+ $hash = is_string( $hash ) ? $hash : null;
$hash = preg_replace( '/[^\da-f]/i', '', $hash );
+ // phpcs:enable
if ( ! is_string( $id ) || ! is_string( $hash ) ) {
return false;
@@ -2532,13 +2536,13 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode {
$form->fields[] = $field;
}
- if (
+ if ( // phpcs:disable WordPress.Security.NonceVerification.Missing
isset( $_POST['action'] ) && 'grunion-contact-form' === $_POST['action']
&&
isset( $_POST['contact-form-id'] ) && $form->get_attribute( 'id' ) == $_POST['contact-form-id']
&&
- isset( $_POST['contact-form-hash'] ) && hash_equals( $form->hash, $_POST['contact-form-hash'] )
- ) {
+ isset( $_POST['contact-form-hash'] ) && is_string( $_POST['contact-form-hash'] ) && hash_equals( $form->hash, $_POST['contact-form-hash'] )
+ ) { // phpcs:enable
// If we're processing a POST submission for this contact form, validate the field value so we can show errors as necessary.
$field->validate();
}
diff --git a/plugins/jetpack/modules/copy-post.php b/plugins/jetpack/modules/copy-post.php
index 3aea777d..676845a1 100644
--- a/plugins/jetpack/modules/copy-post.php
+++ b/plugins/jetpack/modules/copy-post.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Module Name: Copy Post
* Module Description: Enable the option to copy entire posts and pages, including tags and settings
@@ -9,6 +9,8 @@
* Module Tags: Writing
* Feature: Writing
* Additional Search Queries: copy, duplicate
+ *
+ * @package automattic/jetpack
*/
/**
@@ -29,7 +31,7 @@ class Jetpack_Copy_Post {
return;
}
- if ( ! empty( $_GET['jetpack-copy'] ) && 'post-new.php' === $GLOBALS['pagenow'] ) {
+ if ( ! empty( $_GET['jetpack-copy'] ) && 'post-new.php' === $GLOBALS['pagenow'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- update_post_data() handles access check.
add_action( 'wp_insert_post', array( $this, 'update_post_data' ), 10, 3 );
add_filter( 'pre_option_default_post_format', '__return_empty_string' );
}
@@ -49,7 +51,12 @@ class Jetpack_Copy_Post {
return;
}
- $source_post = get_post( $_GET['jetpack-copy'] );
+ // Shouldn't happen, since this filter is only added when the value isn't empty, but check anyway.
+ if ( empty( $_GET['jetpack-copy'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ return;
+ }
+
+ $source_post = get_post( intval( $_GET['jetpack-copy'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( ! $source_post instanceof WP_Post ||
! $this->user_can_access_post( $source_post->ID ) ||
! $this->validate_post_type( $source_post ) ) {
@@ -316,8 +323,8 @@ class Jetpack_Copy_Post {
);
// Insert the Copy action before the Trash action.
- $edit_offset = array_search( 'trash', array_keys( $actions ), true );
- $updated_actions = array_merge(
+ $edit_offset = array_search( 'trash', array_keys( $actions ), true );
+ $updated_actions = array_merge(
array_slice( $actions, 0, $edit_offset ),
$edit_action,
array_slice( $actions, $edit_offset )
diff --git a/plugins/jetpack/modules/custom-content-types.php b/plugins/jetpack/modules/custom-content-types.php
index eb53741d..6c3d62ca 100644
--- a/plugins/jetpack/modules/custom-content-types.php
+++ b/plugins/jetpack/modules/custom-content-types.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Module Name: Custom content types
* Module Description: Display different types of content on your site with custom content types.
@@ -10,20 +9,30 @@
* Sort Order: 34
* Feature: Writing
* Additional Search Queries: cpt, custom post types, portfolio, portfolios, testimonial, testimonials
+ *
+ * @package automattic/jetpack
*/
use Automattic\Jetpack\Redirect;
+/**
+ * Load Portfolio CPT.
+ */
function jetpack_load_custom_post_types() {
- include dirname( __FILE__ ) . "/custom-post-types/portfolios.php";
+ include __DIR__ . '/custom-post-types/portfolios.php';
}
+/**
+ * Make module configurable.
+ */
function jetpack_custom_post_types_loaded() {
Jetpack::enable_module_configurable( __FILE__ );
}
add_action( 'jetpack_modules_loaded', 'jetpack_custom_post_types_loaded' );
-// Add Settings Section for CPT
+/**
+ * Add Settings Section for CPT
+ */
function jetpack_cpt_settings_api_init() {
add_settings_section(
'jetpack_cpt_section',
@@ -34,7 +43,7 @@ function jetpack_cpt_settings_api_init() {
}
add_action( 'admin_init', 'jetpack_cpt_settings_api_init' );
-/*
+/**
* Settings Description
*/
function jetpack_cpt_section_callback() {
diff --git a/plugins/jetpack/modules/custom-css.php b/plugins/jetpack/modules/custom-css.php
index 3ba63055..cbe70694 100644
--- a/plugins/jetpack/modules/custom-css.php
+++ b/plugins/jetpack/modules/custom-css.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Module Name: Custom CSS
@@ -12,6 +12,9 @@
* Additional Search Queries: css, customize, custom, style, editor, less, sass, preprocessor, font, mobile, appearance, theme, stylesheet
*/
+/**
+ * Load custom CSS
+ */
function jetpack_load_custom_css() {
// If WordPress has the core version of Custom CSS, load our new version.
// @see https://core.trac.wordpress.org/changeset/38829
@@ -20,32 +23,34 @@ function jetpack_load_custom_css() {
wp_die( 'Please run a SVN up to get the latest version of trunk, or update to at least 4.7 RC1' );
}
if ( ! Jetpack_Options::get_option( 'custom_css_4.7_migration' ) ) {
- include_once dirname( __FILE__ ) . '/custom-css/migrate-to-core.php';
- }
-
- // TODO: DELETE THIS
- else {
+ include_once __DIR__ . '/custom-css/migrate-to-core.php';
+ } else { // TODO: DELETE THIS.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
- function jetpack_custom_css_undo_data_migration_cli() {
- Jetpack_Options::delete_option( 'custom_css_4.7_migration' );
- WP_CLI::success( __( 'Option deleted, re-migrate via `wp jetpack custom-css migrate`.', 'jetpack' ) );
- }
- WP_CLI::add_command( 'jetpack custom-css undo-migrate', 'jetpack_custom_css_undo_data_migration_cli' );
+ WP_CLI::add_command(
+ 'jetpack custom-css undo-migrate',
+ function () {
+ Jetpack_Options::delete_option( 'custom_css_4.7_migration' );
+ WP_CLI::success( __( 'Option deleted, re-migrate via `wp jetpack custom-css migrate`.', 'jetpack' ) );
+ }
+ );
}
}
- // TODO: END DELETE THIS
+ // TODO: END DELETE THIS.
- include_once dirname( __FILE__ ) . '/custom-css/custom-css/preprocessors.php';
- include_once dirname( __FILE__ ) . '/custom-css/custom-css-4.7.php';
+ include_once __DIR__ . '/custom-css/custom-css/preprocessors.php';
+ include_once __DIR__ . '/custom-css/custom-css-4.7.php';
return;
}
- include_once dirname( __FILE__ ) . "/custom-css/custom-css.php";
+ include_once __DIR__ . '/custom-css/custom-css.php';
add_action( 'init', array( 'Jetpack_Custom_CSS', 'init' ) );
}
add_action( 'jetpack_modules_loaded', 'custom_css_loaded' );
+/**
+ * Enable CSS module.
+ */
function custom_css_loaded() {
Jetpack::enable_module_configurable( __FILE__ );
add_filter( 'jetpack_module_configuration_url_custom-css', 'jetpack_custom_css_configuration_url' );
@@ -56,13 +61,14 @@ function custom_css_loaded() {
* Overrides default configuration url
*
* @uses admin_url
+ *
+ * @param string $default_url - the default URL.
* @return string module settings URL
*/
-function jetpack_custom_css_configuration_url( $default_url ) {
+function jetpack_custom_css_configuration_url( $default_url ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
return Jetpack_Custom_CSS_Enhancements::customizer_link(
array( 'return_url' => wp_get_referer() )
);
}
-
jetpack_load_custom_css();
diff --git a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_ctype.php b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy-ctype.php
index 37e87f7d..a94b39bf 100644
--- a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_ctype.php
+++ b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy-ctype.php
@@ -1,5 +1,4 @@
<?php
-
/**
* CSSTidy - CSS Parser and Optimiser
*
@@ -27,20 +26,28 @@
* @author Nikolay Matsievsky (speed at webo dot name) 2009-2010
* @version 1.0
*/
-/* ctype_space Check for whitespace character(s) */
-if (!function_exists('ctype_space')) {
- function ctype_space($text) {
- return!preg_match("/[^\s\r\n\t\f]/", $text);
- }
+if ( ! function_exists( 'ctype_space' ) ) {
+ /**
+ * Check for whitespace character(s).
+ *
+ * @param string $text - the text.
+ */
+ function ctype_space( $text ) {
+ return ! preg_match( "/[^\s\r\n\t\f]/", $text );
+ }
}
-/* ctype_alpha Check for alphabetic character(s) */
-if (!function_exists('ctype_alpha')) {
- function ctype_alpha($text) {
- return preg_match("/[a-zA-Z]/", $text);
- }
+if ( ! function_exists( 'ctype_alpha' ) ) {
+ /**
+ * Check for alphabetic character(s)
+ *
+ * @param string $text - the text.
+ */
+ function ctype_alpha( $text ) {
+ return preg_match( '/[a-zA-Z]/', $text );
+ }
}
-?>
+
diff --git a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy-optimise.php b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy-optimise.php
new file mode 100644
index 00000000..0889b015
--- /dev/null
+++ b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy-optimise.php
@@ -0,0 +1,1007 @@
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * CSSTidy - CSS Parser and Optimiser
+ *
+ * CSS Optimising Class
+ * This class optimises CSS data generated by csstidy.
+ *
+ * Copyright 2005, 2006, 2007 Florian Schmitz
+ *
+ * This file is part of CSSTidy.
+ *
+ * CSSTidy is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * CSSTidy is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * @license https://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
+ * @package csstidy
+ * @author Florian Schmitz (floele at gmail dot com) 2005-2007
+ * @author Brett Zamir (brettz9 at yahoo dot com) 2007
+ * @author Nikolay Matsievsky (speed at webo dot name) 2009-2010
+ */
+
+/**
+ * CSS Optimising Class
+ *
+ * This class optimises CSS data generated by csstidy.
+ *
+ * @package csstidy
+ * @author Florian Schmitz (floele at gmail dot com) 2005-2006
+ * @version 1.0
+ */
+class csstidy_optimise { // phpcs:ignore
+ /**
+ * Constructor
+ *
+ * @param array $css contains the class csstidy.
+ * @access private
+ * @version 1.0
+ */
+ public function __construct( &$css ) {
+ $this->parser = & $css;
+ $this->css = & $css->css;
+ $this->sub_value = & $css->sub_value;
+ $this->at = & $css->at;
+ $this->selector = & $css->selector;
+ $this->property = & $css->property;
+ $this->value = & $css->value;
+ }
+
+ /**
+ * Call constructor function.
+ *
+ * @param object $css - the CSS.
+ */
+ public function csstidy_optimise( &$css ) {
+ $this->__construct( $css );
+ }
+
+ /**
+ * Optimises $css after parsing
+ *
+ * @access public
+ * @version 1.0
+ */
+ public function postparse() {
+ if ( $this->parser->get_cfg( 'preserve_css' ) ) {
+ return;
+ }
+
+ if ( $this->parser->get_cfg( 'merge_selectors' ) === 2 ) {
+ foreach ( $this->css as $medium => $value ) {
+ $this->merge_selectors( $this->css[ $medium ] );
+ }
+ }
+
+ if ( $this->parser->get_cfg( 'discard_invalid_selectors' ) ) {
+ foreach ( $this->css as $medium => $value ) {
+ $this->discard_invalid_selectors( $this->css[ $medium ] );
+ }
+ }
+
+ if ( $this->parser->get_cfg( 'optimise_shorthands' ) > 0 ) {
+ foreach ( $this->css as $medium => $value ) {
+ foreach ( $value as $selector => $value1 ) {
+ $this->css[ $medium ][ $selector ] = self::merge_4value_shorthands( $this->css[ $medium ][ $selector ] );
+
+ if ( $this->parser->get_cfg( 'optimise_shorthands' ) < 2 ) {
+ continue;
+ }
+
+ $this->css[ $medium ][ $selector ] = self::merge_font( $this->css[ $medium ][ $selector ] );
+
+ if ( $this->parser->get_cfg( 'optimise_shorthands' ) < 3 ) {
+ continue;
+ }
+
+ $this->css[ $medium ][ $selector ] = self::merge_bg( $this->css[ $medium ][ $selector ] );
+ if ( empty( $this->css[ $medium ][ $selector ] ) ) {
+ unset( $this->css[ $medium ][ $selector ] );
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Optimises values
+ *
+ * @access public
+ * @version 1.0
+ */
+ public function value() {
+ $shorthands = & $GLOBALS['csstidy']['shorthands'];
+
+ // optimise shorthand properties.
+ if ( isset( $shorthands[ $this->property ] ) ) {
+ $temp = self::shorthand( $this->value ); // FIXME - move.
+ if ( $temp !== $this->value ) {
+ $this->parser->log( 'Optimised shorthand notation (' . $this->property . '): Changed "' . $this->value . '" to "' . $temp . '"', 'Information' );
+ }
+ $this->value = $temp;
+ }
+
+ // Remove whitespace at ! important.
+ if ( $this->value !== $this->compress_important( $this->value ) ) {
+ $this->parser->log( 'Optimised !important', 'Information' );
+ }
+ }
+
+ /**
+ * Optimises shorthands
+ *
+ * @access public
+ * @version 1.0
+ */
+ public function shorthands() {
+ $shorthands = & $GLOBALS['csstidy']['shorthands'];
+
+ if ( ! $this->parser->get_cfg( 'optimise_shorthands' ) || $this->parser->get_cfg( 'preserve_css' ) ) {
+ return;
+ }
+
+ if ( $this->property === 'font' && $this->parser->get_cfg( 'optimise_shorthands' ) > 1 ) {
+ $this->css[ $this->at ][ $this->selector ]['font'] = '';
+ $this->parser->merge_css_blocks( $this->at, $this->selector, self::dissolve_short_font( $this->value ) );
+ }
+ if ( $this->property === 'background' && $this->parser->get_cfg( 'optimise_shorthands' ) > 2 ) {
+ $this->css[ $this->at ][ $this->selector ]['background'] = '';
+ $this->parser->merge_css_blocks( $this->at, $this->selector, self::dissolve_short_bg( $this->value ) );
+ }
+ if ( isset( $shorthands[ $this->property ] ) ) {
+ $this->parser->merge_css_blocks( $this->at, $this->selector, self::dissolve_4value_shorthands( $this->property, $this->value ) );
+ if ( is_array( $shorthands[ $this->property ] ) ) {
+ $this->css[ $this->at ][ $this->selector ][ $this->property ] = '';
+ }
+ }
+ }
+
+ /**
+ * Optimises a sub-value
+ *
+ * @access public
+ * @version 1.0
+ */
+ public function subvalue() {
+ $replace_colors = & $GLOBALS['csstidy']['replace_colors'];
+
+ $this->sub_value = trim( $this->sub_value );
+ if ( $this->sub_value === '' ) {
+ return;
+ }
+
+ $important = '';
+ if ( csstidy::is_important( $this->sub_value ) ) {
+ $important = '!important';
+ }
+ $this->sub_value = csstidy::gvw_important( $this->sub_value );
+
+ // Compress font-weight.
+ if ( $this->property === 'font-weight' && $this->parser->get_cfg( 'compress_font-weight' ) ) {
+ if ( $this->sub_value === 'bold' ) {
+ $this->sub_value = '700';
+ $this->parser->log( 'Optimised font-weight: Changed "bold" to "700"', 'Information' );
+ } elseif ( $this->sub_value === 'normal' ) {
+ $this->sub_value = '400';
+ $this->parser->log( 'Optimised font-weight: Changed "normal" to "400"', 'Information' );
+ }
+ }
+
+ $temp = $this->compress_numbers( $this->sub_value );
+ if ( strcasecmp( $temp, $this->sub_value ) !== 0 ) {
+ if ( strlen( $temp ) > strlen( $this->sub_value ) ) {
+ $this->parser->log( 'Fixed invalid number: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Warning' );
+ } else {
+ $this->parser->log( 'Optimised number: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Information' );
+ }
+ $this->sub_value = $temp;
+ }
+ if ( $this->parser->get_cfg( 'compress_colors' ) ) {
+ $temp = $this->cut_color( $this->sub_value );
+ if ( $temp !== $this->sub_value ) {
+ if ( isset( $replace_colors[ $this->sub_value ] ) ) {
+ $this->parser->log( 'Fixed invalid color name: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Warning' );
+ } else {
+ $this->parser->log( 'Optimised color: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Information' );
+ }
+ $this->sub_value = $temp;
+ }
+ }
+ $this->sub_value .= $important;
+ }
+
+ /**
+ * Compresses shorthand values. Example: margin:1px 1px 1px 1px -> margin:1px
+ *
+ * @param string $value - the value.
+ * @access public
+ * @return string
+ * @version 1.0
+ */
+ public static function shorthand( $value ) {
+ $important = '';
+ if ( csstidy::is_important( $value ) ) {
+ $values = csstidy::gvw_important( $value );
+ $important = '!important';
+ } else {
+ $values = $value;
+ }
+
+ $values = explode( ' ', $values );
+ switch ( count( $values ) ) {
+ case 4:
+ if ( $values[0] === $values[1] && $values[0] === $values[2] && $values[0] === $values[3] ) {
+ return $values[0] . $important;
+ } elseif ( $values[1] === $values[3] && $values[0] === $values[2] ) {
+ return $values[0] . ' ' . $values[1] . $important;
+ } elseif ( $values[1] === $values[3] ) {
+ return $values[0] . ' ' . $values[1] . ' ' . $values[2] . $important;
+ }
+ break;
+
+ case 3:
+ if ( $values[0] === $values[1] && $values[0] === $values[2] ) {
+ return $values[0] . $important;
+ } elseif ( $values[0] === $values[2] ) {
+ return $values[0] . ' ' . $values[1] . $important;
+ }
+ break;
+
+ case 2:
+ if ( $values[0] === $values[1] ) {
+ return $values[0] . $important;
+ }
+ break;
+ }
+
+ return $value;
+ }
+
+ /**
+ * Removes unnecessary whitespace in ! important
+ *
+ * @param string $string - the string.
+ * @return string
+ * @access public
+ * @version 1.1
+ */
+ public function compress_important( &$string ) {
+ if ( csstidy::is_important( $string ) ) {
+ $string = csstidy::gvw_important( $string ) . ' !important'; }
+ return $string;
+ }
+
+ /**
+ * Color compression function. Converts all rgb() values to #-values and uses the short-form if possible. Also replaces 4 color names by #-values.
+ *
+ * @param string $color - the color.
+ * @return string
+ * @version 1.1
+ */
+ public function cut_color( $color ) {
+ $replace_colors = & $GLOBALS['csstidy']['replace_colors'];
+
+ // an example: rgb(0,0,0) -> #000000 (or #000 in this case later).
+ if ( strtolower( substr( $color, 0, 4 ) ) === 'rgb(' ) {
+ $color_tmp = substr( $color, 4, strlen( $color ) - 5 );
+ $color_tmp = explode( ',', $color_tmp );
+ for ( $i = 0, $l = count( $color_tmp ); $i < $l; $i++ ) {
+ $color_tmp[ $i ] = trim( $color_tmp[ $i ] );
+ if ( substr( $color_tmp[ $i ], -1 ) === '%' ) {
+ $color_tmp[ $i ] = round( ( 255 * $color_tmp[ $i ] ) / 100 );
+ }
+ if ( $color_tmp[ $i ] > 255 ) {
+ $color_tmp[ $i ] = 255;
+ }
+ }
+ $color = '#';
+ for ( $i = 0; $i < 3; $i++ ) {
+ if ( $color_tmp[ $i ] < 16 ) {
+ $color .= '0' . dechex( $color_tmp[ $i ] );
+ } else {
+ $color .= dechex( $color_tmp[ $i ] );
+ }
+ }
+ }
+
+ // Fix bad color names.
+ if ( isset( $replace_colors[ strtolower( $color ) ] ) ) {
+ $color = $replace_colors[ strtolower( $color ) ];
+ }
+
+ // #aabbcc -> #abc
+ if ( strlen( $color ) === 7 ) {
+ $color_temp = strtolower( $color );
+ if ( $color_temp[0] === '#' && $color_temp[1] === $color_temp[2] && $color_temp[3] === $color_temp[4] && $color_temp[5] === $color_temp[6] ) {
+ $color = '#' . $color[1] . $color[3] . $color[5];
+ }
+ }
+
+ switch ( strtolower( $color ) ) {
+ /* color name -> hex code */
+ case 'black':
+ return '#000';
+ case 'fuchsia':
+ return '#f0f';
+ case 'white':
+ return '#fff';
+ case 'yellow':
+ return '#ff0';
+
+ /* hex code -> color name */
+ case '#800000':
+ return 'maroon';
+ case '#ffa500':
+ return 'orange';
+ case '#808000':
+ return 'olive';
+ case '#800080':
+ return 'purple';
+ case '#008000':
+ return 'green';
+ case '#000080':
+ return 'navy';
+ case '#008080':
+ return 'teal';
+ case '#c0c0c0':
+ return 'silver';
+ case '#808080':
+ return 'gray';
+ case '#f00':
+ return 'red';
+ }
+
+ return $color;
+ }
+
+ /**
+ * Compresses numbers (ie. 1.0 becomes 1 or 1.100 becomes 1.1 )
+ *
+ * @param string $subvalue - the subvalue.
+ * @return string
+ * @version 1.2
+ */
+ public function compress_numbers( $subvalue ) {
+ $unit_values = & $GLOBALS['csstidy']['unit_values'];
+ $color_values = & $GLOBALS['csstidy']['color_values'];
+
+ // for font:1em/1em sans-serif...;.
+ if ( $this->property === 'font' ) {
+ $temp = explode( '/', $subvalue );
+ } else {
+ $temp = array( $subvalue );
+ }
+
+ for ( $l = 0, $m = count( $temp ); $l < $m; $l++ ) {
+ // if we are not dealing with a number at this point, do not optimise anything.
+ $number = $this->analyse_css_number( $temp[ $l ] );
+ if ( $number === false ) {
+ return $subvalue;
+ }
+
+ // Fix bad colors.
+ if ( in_array( $this->property, $color_values, true ) ) {
+ if ( strlen( $temp[ $l ] ) === 3 || strlen( $temp[ $l ] ) === 6 ) {
+ $temp[ $l ] = '#' . $temp[ $l ];
+ } else {
+ $temp[ $l ] = '0';
+ }
+ continue;
+ }
+
+ if ( abs( $number[0] ) > 0 ) {
+ if ( $number[1] === '' && in_array( $this->property, $unit_values, true ) ) {
+ $number[1] = 'px';
+ }
+ } else {
+ $number[1] = '';
+ }
+
+ $temp[ $l ] = $number[0] . $number[1];
+ }
+
+ return ( ( count( $temp ) > 1 ) ? $temp[0] . '/' . $temp[1] : $temp[0] );
+ }
+
+ /**
+ * Checks if a given string is a CSS valid number. If it is,
+ * an array containing the value and unit is returned
+ *
+ * @param string $string - the string we're checking.
+ * @return array ('unit' if unit is found or '' if no unit exists, number value) or false if no number
+ */
+ public function analyse_css_number( $string ) {
+ // most simple checks first
+ if ( $string === '' || ctype_alpha( $string[0] ) ) {
+ return false;
+ }
+
+ $units = & $GLOBALS['csstidy']['units'];
+ $return = array( 0, '' );
+
+ $return[0] = (float) $string;
+ if ( abs( $return[0] ) > 0 && abs( $return[0] ) < 1 ) {
+ // Removes the initial `0` from a decimal number, e.g., `0.7 => .7` or `-0.666 => -.666`.
+ if ( ! $this->parser->get_cfg( 'preserve_leading_zeros' ) ) {
+ if ( $return[0] < 0 ) {
+ $return[0] = '-' . ltrim( substr( $return[0], 1 ), '0' );
+ } else {
+ $return[0] = ltrim( $return[0], '0' );
+ }
+ }
+ }
+
+ // Look for unit and split from value if exists
+ foreach ( $units as $unit ) {
+ $expect_unit_at = strlen( $string ) - strlen( $unit );
+ $unit_in_string = stristr( $string, $unit );
+ if ( ! $unit_in_string ) { // mb_strpos() fails with "false"
+ continue;
+ }
+ $actual_position = strpos( $string, $unit_in_string );
+ if ( $expect_unit_at === $actual_position ) {
+ $return[1] = $unit;
+ $string = substr( $string, 0, - strlen( $unit ) );
+ break;
+ }
+ }
+ if ( ! is_numeric( $string ) ) {
+ return false;
+ }
+ return $return;
+ }
+
+ /**
+ * Merges selectors with same properties. Example: a{color:red} b{color:red} -> a,b{color:red}
+ * Very basic and has at least one bug. Hopefully there is a replacement soon.
+ *
+ * @param array $array - the selector array.
+ * @access public
+ * @version 1.2
+ */
+ public function merge_selectors( &$array ) {
+ $css = $array;
+ foreach ( $css as $key => $value ) {
+ if ( ! isset( $css[ $key ] ) ) {
+ continue;
+ }
+ $newsel = '';
+
+ // Check if properties also exist in another selector.
+ $keys = array();
+ // PHP bug (?) without $css = $array; here.
+ foreach ( $css as $selector => $vali ) {
+ if ( $selector === $key ) {
+ continue;
+ }
+
+ if ( $css[ $key ] === $vali ) {
+ $keys[] = $selector;
+ }
+ }
+
+ if ( ! empty( $keys ) ) {
+ $newsel = $key;
+ unset( $css[ $key ] );
+ foreach ( $keys as $selector ) {
+ unset( $css[ $selector ] );
+ $newsel .= ',' . $selector;
+ }
+ $css[ $newsel ] = $value;
+ }
+ }
+ $array = $css;
+ }
+
+ /**
+ * Removes invalid selectors and their corresponding rule-sets as
+ * defined by 4.1.7 in REC-CSS2. This is a very rudimentary check
+ * and should be replaced by a full-blown parsing algorithm or
+ * regular expression
+ *
+ * @version 1.4
+ *
+ * @param array $array - selector array.
+ */
+ public function discard_invalid_selectors( &$array ) {
+ foreach ( $array as $selector => $decls ) {
+ $ok = true;
+ $selectors = array_map( 'trim', explode( ',', $selector ) );
+ foreach ( $selectors as $s ) {
+ $simple_selectors = preg_split( '/\s*[+>~\s]\s*/', $s );
+ foreach ( $simple_selectors as $ss ) {
+ if ( $ss === '' ) {
+ $ok = false;
+ }
+ // could also check $ss for internal structure, but that probably would be too slow.
+ }
+ }
+ if ( ! $ok ) {
+ unset( $array[ $selector ] );
+ }
+ }
+ }
+
+ /**
+ * Dissolves properties like padding:10px 10px 10px to padding-top:10px;padding-bottom:10px;...
+ *
+ * @param string $property - the property.
+ * @param string $value - the value.
+ * @return array
+ * @version 1.0
+ * @see merge_4value_shorthands()
+ */
+ public static function dissolve_4value_shorthands( $property, $value ) {
+ $shorthands = & $GLOBALS['csstidy']['shorthands'];
+ if ( ! is_array( $shorthands[ $property ] ) ) {
+ $return = array();
+ $return[ $property ] = $value;
+ return $return;
+ }
+
+ $important = '';
+ if ( csstidy::is_important( $value ) ) {
+ $value = csstidy::gvw_important( $value );
+ $important = '!important';
+ }
+ $values = explode( ' ', $value );
+
+ $return = array();
+ if ( count( $values ) === 4 ) {
+ for ( $i = 0; $i < 4; $i++ ) {
+ $return[ $shorthands[ $property ][ $i ] ] = $values[ $i ] . $important;
+ }
+ } elseif ( count( $values ) === 3 ) {
+ $return[ $shorthands[ $property ][0] ] = $values[0] . $important;
+ $return[ $shorthands[ $property ][1] ] = $values[1] . $important;
+ $return[ $shorthands[ $property ][3] ] = $values[1] . $important;
+ $return[ $shorthands[ $property ][2] ] = $values[2] . $important;
+ } elseif ( count( $values ) === 2 ) {
+ for ( $i = 0; $i < 4; $i++ ) {
+ $return[ $shorthands[ $property ][ $i ] ] = ( ( $i % 2 !== 0 ) ) ? $values[1] . $important : $values[0] . $important;
+ }
+ } else {
+ for ( $i = 0; $i < 4; $i++ ) {
+ $return[ $shorthands[ $property ][ $i ] ] = $values[0] . $important;
+ }
+ }
+
+ return $return;
+ }
+
+ /**
+ * Explodes a string as explode() does, however, not if $sep is escaped or within a string.
+ *
+ * @param string $sep - seperator.
+ * @param string $string - the string.
+ * @return array
+ * @version 1.0
+ */
+ public static function explode_ws( $sep, $string ) {
+ $status = 'st';
+ $to = '';
+
+ $output = array();
+ $num = 0;
+ for ( $i = 0, $len = strlen( $string ); $i < $len; $i++ ) {
+ switch ( $status ) {
+ case 'st':
+ if ( $string[ $i ] === $sep && ! csstidy::escaped( $string, $i ) ) {
+ ++$num;
+ } elseif ( $string[ $i ] === '"' || $string[ $i ] === '\'' || $string[ $i ] === '(' && ! csstidy::escaped( $string, $i ) ) {
+ $status = 'str';
+ $to = ( $string[ $i ] === '(' ) ? ')' : $string[ $i ];
+ ( isset( $output[ $num ] ) ) ? $output[ $num ] .= $string[ $i ] : $output[ $num ] = $string[ $i ];
+ } else {
+ ( isset( $output[ $num ] ) ) ? $output[ $num ] .= $string[ $i ] : $output[ $num ] = $string[ $i ];
+ }
+ break;
+
+ case 'str':
+ if ( $string[ $i ] === $to && ! csstidy::escaped( $string, $i ) ) {
+ $status = 'st';
+ }
+ ( isset( $output[ $num ] ) ) ? $output[ $num ] .= $string[ $i ] : $output[ $num ] = $string[ $i ];
+ break;
+ }
+ }
+
+ if ( isset( $output[0] ) ) {
+ return $output;
+ } else {
+ return array( $output );
+ }
+ }
+
+ /**
+ * Merges Shorthand properties again, the opposite of dissolve_4value_shorthands()
+ *
+ * @param array $array - the property array.
+ * @return array
+ * @version 1.2
+ * @see dissolve_4value_shorthands()
+ */
+ public static function merge_4value_shorthands( $array ) {
+ $return = $array;
+ $shorthands = & $GLOBALS['csstidy']['shorthands'];
+
+ foreach ( $shorthands as $key => $value ) {
+ if ( isset( $array[ $value[0] ] ) && isset( $array[ $value[1] ] )
+ && isset( $array[ $value[2] ] ) && isset( $array[ $value[3] ] ) && $value !== 0 ) {
+ $return[ $key ] = '';
+
+ $important = '';
+ for ( $i = 0; $i < 4; $i++ ) {
+ $val = $array[ $value[ $i ] ];
+ if ( csstidy::is_important( $val ) ) {
+ $important = '!important';
+ $return[ $key ] .= csstidy::gvw_important( $val ) . ' ';
+ } else {
+ $return[ $key ] .= $val . ' ';
+ }
+ unset( $return[ $value[ $i ] ] );
+ }
+ $return[ $key ] = self::shorthand( trim( $return[ $key ] . $important ) );
+ }
+ }
+ return $return;
+ }
+
+ /**
+ * Dissolve background property
+ *
+ * @param string $str_value - the string value.
+ * @return array
+ * @version 1.0
+ * @see merge_bg()
+ * @todo full CSS 3 compliance
+ */
+ public static function dissolve_short_bg( $str_value ) {
+ $have = array();
+ // don't try to explose background gradient !
+ if ( stripos( $str_value, 'gradient(' ) !== false ) {
+ return array( 'background' => $str_value );
+ }
+
+ $background_prop_default = & $GLOBALS['csstidy']['background_prop_default'];
+ $repeat = array( 'repeat', 'repeat-x', 'repeat-y', 'no-repeat', 'space' );
+ $attachment = array( 'scroll', 'fixed', 'local' );
+ $clip = array( 'border', 'padding' );
+ $origin = array( 'border', 'padding', 'content' );
+ $pos = array( 'top', 'center', 'bottom', 'left', 'right' );
+ $important = '';
+ $return = array(
+ 'background-image' => null,
+ 'background-size' => null,
+ 'background-repeat' => null,
+ 'background-position' => null,
+ 'background-attachment' => null,
+ 'background-clip' => null,
+ 'background-origin' => null,
+ 'background-color' => null,
+ );
+
+ if ( csstidy::is_important( $str_value ) ) {
+ $important = ' !important';
+ $str_value = csstidy::gvw_important( $str_value );
+ }
+
+ $str_value = self::explode_ws( ',', $str_value );
+ for ( $i = 0, $l = count( $str_value ); $i < $l; $i++ ) {
+ $have['clip'] = false;
+ $have['pos'] = false;
+ $have['color'] = false;
+ $have['bg'] = false;
+
+ if ( is_array( $str_value[ $i ] ) ) {
+ $str_value[ $i ] = $str_value[ $i ][0];
+ }
+ $str_value[ $i ] = self::explode_ws( ' ', trim( $str_value[ $i ] ) );
+
+ for ( $j = 0, $k = count( $str_value[ $i ] ); $j < $k; $j++ ) {
+ if ( $have['bg'] === false && ( substr( $str_value[ $i ][ $j ], 0, 4 ) === 'url(' || $str_value[ $i ][ $j ] === 'none' ) ) {
+ $return['background-image'] .= $str_value[ $i ][ $j ] . ',';
+ $have['bg'] = true;
+ } elseif ( in_array( $str_value[ $i ][ $j ], $repeat, true ) ) {
+ $return['background-repeat'] .= $str_value[ $i ][ $j ] . ',';
+ } elseif ( in_array( $str_value[ $i ][ $j ], $attachment, true ) ) {
+ $return['background-attachment'] .= $str_value[ $i ][ $j ] . ',';
+ } elseif ( in_array( $str_value[ $i ][ $j ], $clip, true ) && ! $have['clip'] ) {
+ $return['background-clip'] .= $str_value[ $i ][ $j ] . ',';
+ $have['clip'] = true;
+ } elseif ( in_array( $str_value[ $i ][ $j ], $origin, true ) ) {
+ $return['background-origin'] .= $str_value[ $i ][ $j ] . ',';
+ } elseif ( $str_value[ $i ][ $j ][0] === '(' ) {
+ $return['background-size'] .= substr( $str_value[ $i ][ $j ], 1, -1 ) . ',';
+ } elseif ( in_array( $str_value[ $i ][ $j ], $pos, true ) || is_numeric( $str_value[ $i ][ $j ][0] ) || $str_value[ $i ][ $j ][0] === null || $str_value[ $i ][ $j ][0] === '-' || $str_value[ $i ][ $j ][0] === '.' ) {
+ $return['background-position'] .= $str_value[ $i ][ $j ];
+ if ( ! $have['pos'] ) {
+ $return['background-position'] .= ' ';
+ } else {
+ $return['background-position'] .= ',';
+ }
+ $have['pos'] = true;
+ } elseif ( ! $have['color'] ) {
+ $return['background-color'] .= $str_value[ $i ][ $j ] . ',';
+ $have['color'] = true;
+ }
+ }
+ }
+
+ foreach ( $background_prop_default as $bg_prop => $default_value ) {
+ if ( $return[ $bg_prop ] !== null ) {
+ $return[ $bg_prop ] = substr( $return[ $bg_prop ], 0, -1 ) . $important;
+ } else {
+ $return[ $bg_prop ] = $default_value . $important;
+ }
+ }
+ return $return;
+ }
+
+ /**
+ * Merges all background properties
+ *
+ * @param array $input_css - inputted CSS.
+ * @return array
+ * @version 1.0
+ * @see dissolve_short_bg()
+ * @todo full CSS 3 compliance
+ */
+ public static function merge_bg( $input_css ) {
+ $background_prop_default = & $GLOBALS['csstidy']['background_prop_default'];
+ // Max number of background images. CSS3 not yet fully implemented.
+ $number_of_values = @max( count( self::explode_ws( ',', $input_css['background-image'] ) ), count( self::explode_ws( ',', $input_css['background-color'] ) ), 1 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
+ // Array with background images to check if BG image exists.
+ $bg_img_array = @self::explode_ws( ',', csstidy::gvw_important( $input_css['background-image'] ) ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
+ $new_bg_value = '';
+ $important = '';
+
+ // if background properties is here and not empty, don't try anything.
+ if ( isset( $input_css['background'] ) && $input_css['background'] ) {
+ return $input_css;
+ }
+
+ for ( $i = 0; $i < $number_of_values; $i++ ) {
+ foreach ( $background_prop_default as $bg_property => $default_value ) {
+ // Skip if property does not exist
+ if ( ! isset( $input_css[ $bg_property ] ) ) {
+ continue;
+ }
+
+ $cur_value = $input_css[ $bg_property ];
+ // skip all optimisation if gradient() somewhere.
+ if ( stripos( $cur_value, 'gradient(' ) !== false ) {
+ return $input_css;
+ }
+
+ // Skip some properties if there is no background image.
+ if ( ( ! isset( $bg_img_array[ $i ] ) || $bg_img_array[ $i ] === 'none' )
+ && ( $bg_property === 'background-size' || $bg_property === 'background-position'
+ || $bg_property === 'background-attachment' || $bg_property === 'background-repeat' ) ) {
+ continue;
+ }
+
+ // Remove !important.
+ if ( csstidy::is_important( $cur_value ) ) {
+ $important = ' !important';
+ $cur_value = csstidy::gvw_important( $cur_value );
+ }
+
+ // Do not add default values.
+ if ( $cur_value === $default_value ) {
+ continue;
+ }
+
+ $temp = self::explode_ws( ',', $cur_value );
+
+ if ( isset( $temp[ $i ] ) ) {
+ if ( $bg_property === 'background-size' ) {
+ $new_bg_value .= '(' . $temp[ $i ] . ') ';
+ } else {
+ $new_bg_value .= $temp[ $i ] . ' ';
+ }
+ }
+ }
+
+ $new_bg_value = trim( $new_bg_value );
+ if ( $i !== $number_of_values - 1 ) {
+ $new_bg_value .= ',';
+ }
+ }
+
+ // Delete all background-properties.
+ foreach ( $background_prop_default as $bg_property => $default_value ) {
+ unset( $input_css[ $bg_property ] );
+ }
+
+ // Add new background property.
+ if ( $new_bg_value !== '' ) {
+ $input_css['background'] = $new_bg_value . $important;
+ } elseif ( isset( $input_css['background'] ) ) {
+ $input_css['background'] = 'none';
+ }
+
+ return $input_css;
+ }
+
+ /**
+ * Dissolve font property
+ *
+ * @param string $str_value - the string value.
+ * @return array
+ * @version 1.3
+ * @see merge_font()
+ */
+ public static function dissolve_short_font( $str_value ) {
+ $have = array();
+ $font_prop_default = & $GLOBALS['csstidy']['font_prop_default'];
+ $font_weight = array( 'normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '700', '800', '900' );
+ $font_variant = array( 'normal', 'small-caps' );
+ $font_style = array( 'normal', 'italic', 'oblique' );
+ $important = '';
+ $return = array(
+ 'font-style' => null,
+ 'font-variant' => null,
+ 'font-weight' => null,
+ 'font-size' => null,
+ 'line-height' => null,
+ 'font-family' => null,
+ );
+
+ if ( csstidy::is_important( $str_value ) ) {
+ $important = '!important';
+ $str_value = csstidy::gvw_important( $str_value );
+ }
+
+ $have['style'] = false;
+ $have['variant'] = false;
+ $have['weight'] = false;
+ $have['size'] = false;
+ // Detects if font-family consists of several words w/o quotes.
+ $multiwords = false;
+
+ // Workaround with multiple font-family.
+ $str_value = self::explode_ws( ',', trim( $str_value ) );
+
+ $str_value[0] = self::explode_ws( ' ', trim( $str_value[0] ) );
+
+ for ( $j = 0, $k = count( $str_value[0] ); $j < $k; $j++ ) {
+ if ( $have['weight'] === false && in_array( $str_value[0][ $j ], $font_weight, true ) ) {
+ $return['font-weight'] = $str_value[0][ $j ];
+ $have['weight'] = true;
+ } elseif ( $have['variant'] === false && in_array( $str_value[0][ $j ], $font_variant, true ) ) {
+ $return['font-variant'] = $str_value[0][ $j ];
+ $have['variant'] = true;
+ } elseif ( $have['style'] === false && in_array( $str_value[0][ $j ], $font_style, true ) ) {
+ $return['font-style'] = $str_value[0][ $j ];
+ $have['style'] = true;
+ } elseif ( $have['size'] === false && ( is_numeric( $str_value[0][ $j ][0] ) || $str_value[0][ $j ][0] === null || $str_value[0][ $j ][0] === '.' ) ) {
+ $size = self::explode_ws( '/', trim( $str_value[0][ $j ] ) );
+ $return['font-size'] = $size[0];
+ if ( isset( $size[1] ) ) {
+ $return['line-height'] = $size[1];
+ } else {
+ $return['line-height'] = ''; // don't add 'normal' !
+ }
+ $have['size'] = true;
+ } else {
+ if ( isset( $return['font-family'] ) ) {
+ $return['font-family'] .= ' ' . $str_value[0][ $j ];
+ $multiwords = true;
+ } else {
+ $return['font-family'] = $str_value[0][ $j ];
+ }
+ }
+ }
+ // add quotes if we have several qords in font-family.
+ if ( $multiwords !== false ) {
+ $return['font-family'] = '"' . $return['font-family'] . '"';
+ }
+ $i = 1;
+ while ( isset( $str_value[ $i ] ) ) {
+ $return['font-family'] .= ',' . trim( $str_value[ $i ] );
+ $i++;
+ }
+
+ // Fix for 100 and more font-size.
+ if ( $have['size'] === false && isset( $return['font-weight'] ) &&
+ is_numeric( $return['font-weight'][0] )
+ ) {
+ $return['font-size'] = $return['font-weight'];
+ unset( $return['font-weight'] );
+ }
+
+ foreach ( $font_prop_default as $font_prop => $default_value ) {
+ if ( $return[ $font_prop ] !== null ) {
+ $return[ $font_prop ] = $return[ $font_prop ] . $important;
+ } else {
+ $return[ $font_prop ] = $default_value . $important;
+ }
+ }
+ return $return;
+ }
+
+ /**
+ * Merges all fonts properties
+ *
+ * @param array $input_css - input CSS.
+ * @return array
+ * @version 1.3
+ * @see dissolve_short_font()
+ */
+ public static function merge_font( $input_css ) {
+ $font_prop_default = & $GLOBALS['csstidy']['font_prop_default'];
+ $new_font_value = '';
+ $important = '';
+ // Skip if not font-family and font-size set.
+ if ( isset( $input_css['font-family'] ) && isset( $input_css['font-size'] ) ) {
+ // fix several words in font-family - add quotes.
+ if ( isset( $input_css['font-family'] ) ) {
+ $families = explode( ',', $input_css['font-family'] );
+ $result_families = array();
+ foreach ( $families as $family ) {
+ $family = trim( $family );
+ $len = strlen( $family );
+ if ( strpos( $family, ' ' ) &&
+ ! ( ( $family[0] === '"' && $family[ $len - 1 ] === '"' ) ||
+ ( $family[0] === "'" && $family[ $len - 1 ] === "'" ) ) ) {
+ $family = '"' . $family . '"';
+ }
+ $result_families[] = $family;
+ }
+ $input_css['font-family'] = implode( ',', $result_families );
+ }
+ foreach ( $font_prop_default as $font_property => $default_value ) {
+
+ // Skip if property does not exist.
+ if ( ! isset( $input_css[ $font_property ] ) ) {
+ continue;
+ }
+
+ $cur_value = $input_css[ $font_property ];
+
+ // Skip if default value is used.
+ if ( $cur_value === $default_value ) {
+ continue;
+ }
+
+ // Remove !important.
+ if ( csstidy::is_important( $cur_value ) ) {
+ $important = '!important';
+ $cur_value = csstidy::gvw_important( $cur_value );
+ }
+
+ $new_font_value .= $cur_value;
+ // Add delimiter.
+ $new_font_value .= ( $font_property === 'font-size' &&
+ isset( $input_css['line-height'] ) ) ? '/' : ' ';
+ }
+
+ $new_font_value = trim( $new_font_value );
+
+ // Delete all font-properties.
+ foreach ( $font_prop_default as $font_property => $default_value ) {
+ if ( $font_property !== 'font' || ! $new_font_value ) {
+ unset( $input_css[ $font_property ] );
+ }
+ }
+
+ // Add new font property.
+ if ( $new_font_value !== '' ) {
+ $input_css['font'] = $new_font_value . $important;
+ }
+ }
+
+ return $input_css;
+ }
+
+}
diff --git a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy-print.php b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy-print.php
new file mode 100644
index 00000000..5ce9de5b
--- /dev/null
+++ b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy-print.php
@@ -0,0 +1,432 @@
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * CSSTidy - CSS Parser and Optimiser
+ *
+ * CSS Printing class
+ * This class prints CSS data generated by csstidy.
+ *
+ * Copyright 2005, 2006, 2007 Florian Schmitz
+ *
+ * This file is part of CSSTidy.
+ *
+ * CSSTidy is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * CSSTidy is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * @license https://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
+ * @package csstidy
+ * @author Florian Schmitz (floele at gmail dot com) 2005-2007
+ * @author Brett Zamir (brettz9 at yahoo dot com) 2007
+ * @author Cedric Morin (cedric at yterium dot com) 2010
+ */
+
+/**
+ * CSS Printing class
+ *
+ * This class prints CSS data generated by csstidy.
+ *
+ * @package csstidy
+ * @author Florian Schmitz (floele at gmail dot com) 2005-2006
+ * @version 1.0.1
+ */
+class csstidy_print { // phpcs:ignore
+
+ /**
+ * Saves the input CSS string
+ *
+ * @var string
+ * @access private
+ */
+ public $input_css = '';
+ /**
+ * Saves the formatted CSS string
+ *
+ * @var string
+ * @access public
+ */
+ public $output_css = '';
+ /**
+ * Saves the formatted CSS string (plain text)
+ *
+ * @var string
+ * @access public
+ */
+ public $output_css_plain = '';
+
+ /**
+ * Constructor
+ *
+ * @param array $css contains the class csstidy.
+ * @access private
+ * @version 1.0
+ */
+ public function __construct( &$css ) {
+ $this->parser = & $css;
+ $this->css = & $css->css;
+ $this->template = & $css->template;
+ $this->tokens = & $css->tokens;
+ $this->charset = & $css->charset;
+ $this->import = & $css->import;
+ $this->namespace = & $css->namespace;
+ }
+
+ /**
+ * Call constructor function.
+ *
+ * @param object $css - the CSS we're working with.
+ */
+ public function csstidy_print( &$css ) {
+ $this->__construct( $css );
+ }
+
+ /**
+ * Resets output_css and output_css_plain (new css code)
+ *
+ * @access private
+ * @version 1.0
+ */
+ public function _reset() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
+ $this->output_css = '';
+ $this->output_css_plain = '';
+ }
+
+ /**
+ * Returns the CSS code as plain text
+ *
+ * @param string $default_media default @media to add to selectors without any @media.
+ * @return string
+ * @access public
+ * @version 1.0
+ */
+ public function plain( $default_media = '' ) {
+ $this->_print( true, $default_media );
+ return $this->output_css_plain;
+ }
+
+ /**
+ * Returns the formatted CSS code
+ *
+ * @param string $default_media default @media to add to selectors without any @media.
+ * @return string
+ * @access public
+ * @version 1.0
+ */
+ public function formatted( $default_media = '' ) {
+ $this->_print( false, $default_media );
+ return $this->output_css;
+ }
+
+ /**
+ * Returns the formatted CSS code to make a complete webpage
+ *
+ * @param string $doctype shorthand for the document type.
+ * @param bool $externalcss indicates whether styles to be attached internally or as an external stylesheet.
+ * @param string $title title to be added in the head of the document.
+ * @param string $lang two-letter language code to be added to the output.
+ * @return string
+ * @access public
+ * @version 1.4
+ */
+ public function formatted_page( $doctype = 'xhtml1.1', $externalcss = true, $title = '', $lang = 'en' ) {
+ switch ( $doctype ) {
+ case 'xhtml1.0strict':
+ $doctype_output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
+ break;
+ case 'xhtml1.1':
+ default:
+ $doctype_output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
+ break;
+ }
+ $cssparsed = '';
+ $output = '';
+ $this->output_css_plain = & $output;
+
+ $output .= $doctype_output . "\n" . '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $lang . '"';
+ $output .= ( $doctype === 'xhtml1.1' ) ? '>' : ' lang="' . $lang . '">';
+ $output .= "\n<head>\n <title>$title</title>";
+
+ if ( $externalcss ) {
+ $output .= "\n <style type=\"text/css\">\n";
+ $cssparsed = file_get_contents( 'cssparsed.css' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
+ $output .= $cssparsed; // Adds an invisible BOM or something, but not in css_optimised.php
+ $output .= "\n</style>";
+ } else {
+ $output .= "\n" . ' <link rel="stylesheet" type="text/css" href="cssparsed.css" />'; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
+ // }
+ }
+ $output .= "\n</head>\n<body><code id=\"copytext\">";
+ $output .= $this->formatted();
+ $output .= '</code>' . "\n" . '</body></html>';
+ return $this->output_css_plain;
+ }
+
+ /**
+ * Returns the formatted CSS Code and saves it into $this->output_css and $this->output_css_plain
+ *
+ * @param bool $plain plain text or not.
+ * @param string $default_media default @media to add to selectors without any @media.
+ * @access private
+ * @version 2.0
+ */
+ public function _print( $plain = false, $default_media = '' ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore -- print is a reserved word anyway.
+ if ( $this->output_css && $this->output_css_plain ) {
+ return;
+ }
+
+ $output = '';
+ if ( ! $this->parser->get_cfg( 'preserve_css' ) ) {
+ $this->convert_raw_css( $default_media );
+ }
+
+ $template = & $this->template;
+
+ if ( $plain ) {
+ $template = array_map( 'strip_tags', $template );
+ }
+
+ if ( $this->parser->get_cfg( 'timestamp' ) ) {
+ array_unshift( $this->tokens, array( COMMENT, ' CSSTidy ' . $this->parser->version . ': ' . gmdate( 'r' ) . ' ' ) );
+ }
+
+ if ( ! empty( $this->charset ) ) {
+ $output .= $template[0] . '@charset ' . $template[5] . $this->charset . $template[6];
+ }
+
+ if ( ! empty( $this->import ) ) {
+ for ( $i = 0, $size = count( $this->import ); $i < $size; $i++ ) {
+ $import_components = explode( ' ', $this->import[ $i ] );
+ if ( substr( $import_components[0], 0, 4 ) === 'url(' && substr( $import_components[0], -1, 1 ) === ')' ) {
+ $import_components[0] = '\'' . trim( substr( $import_components[0], 4, -1 ), "'\"" ) . '\'';
+ $this->import[ $i ] = implode( ' ', $import_components );
+ $this->parser->log( 'Optimised @import : Removed "url("', 'Information' );
+ }
+ $output .= $template[0] . '@import ' . $template[5] . $this->import[ $i ] . $template[6];
+ }
+ }
+ if ( ! empty( $this->namespace ) ) {
+ if ( substr( $this->namespace, 0, 4 ) === 'url(' && substr( $this->namespace, -1, 1 ) === ')' ) {
+ $this->namespace = '\'' . substr( $this->namespace, 4, -1 ) . '\'';
+ $this->parser->log( 'Optimised @namespace : Removed "url("', 'Information' );
+ }
+ $output .= $template[0] . '@namespace ' . $template[5] . $this->namespace . $template[6];
+ }
+
+ $output .= $template[13];
+ $in_at_out = '';
+ $out = & $output;
+
+ foreach ( $this->tokens as $key => $token ) {
+ switch ( $token[0] ) {
+ case AT_START:
+ $out .= $template[0] . $this->htmlsp( $token[1], $plain ) . $template[1];
+ $out = & $in_at_out;
+ break;
+
+ case SEL_START:
+ if ( $this->parser->get_cfg( 'lowercase_s' ) ) {
+ $token[1] = strtolower( $token[1] );
+ }
+ $out .= ( $token[1][0] !== '@' ) ? $template[2] . $this->htmlsp( $token[1], $plain ) : $template[0] . $this->htmlsp( $token[1], $plain );
+ $out .= $template[3];
+ break;
+
+ case PROPERTY:
+ if ( $this->parser->get_cfg( 'case_properties' ) === 2 ) {
+ $token[1] = strtoupper( $token[1] );
+ } elseif ( $this->parser->get_cfg( 'case_properties' ) === 1 ) {
+ $token[1] = strtolower( $token[1] );
+ }
+ $out .= $template[4] . $this->htmlsp( $token[1], $plain ) . ':' . $template[5];
+ break;
+
+ case VALUE:
+ $out .= $this->htmlsp( $token[1], $plain );
+ if ( $this->seeknocomment( $key, 1 ) === SEL_END && $this->parser->get_cfg( 'remove_last_;' ) ) {
+ $out .= str_replace( ';', '', $template[6] );
+ } else {
+ $out .= $template[6];
+ }
+ break;
+
+ case SEL_END:
+ $out .= $template[7];
+ if ( $this->seeknocomment( $key, 1 ) !== AT_END ) {
+ $out .= $template[8];
+ }
+ break;
+
+ case AT_END:
+ $out = & $output;
+ $out .= $template[10] . str_replace( "\n", "\n" . $template[10], $in_at_out );
+ $in_at_out = '';
+ $out .= $template[9];
+ break;
+
+ case COMMENT:
+ $out .= $template[11] . '/*' . $this->htmlsp( $token[1], $plain ) . '*/' . $template[12];
+ break;
+ }
+ }
+
+ $output = trim( $output );
+
+ if ( ! $plain ) {
+ $this->output_css = $output;
+ $this->_print( true );
+ } else {
+ // If using spaces in the template, don't want these to appear in the plain output
+ $this->output_css_plain = str_replace( '&#160;', '', $output );
+ }
+ }
+
+ /**
+ * Gets the next token type which is $move away from $key, excluding comments
+ *
+ * @param integer $key current position.
+ * @param integer $move move this far.
+ * @return mixed a token type
+ * @access private
+ * @version 1.0
+ */
+ public function seeknocomment( $key, $move ) {
+ $go = ( $move > 0 ) ? 1 : -1;
+ for ( $i = $key + 1; abs( $key - $i ) - 1 < abs( $move ); $i += $go ) { // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
+ if ( ! isset( $this->tokens[ $i ] ) ) {
+ return;
+ }
+ if ( $this->tokens[ $i ][0] === COMMENT ) {
+ ++$move;
+ continue;
+ }
+ return $this->tokens[ $i ][0];
+ }
+ }
+
+ /**
+ * Converts $this->css array to a raw array ($this->tokens)
+ *
+ * @param string $default_media default @media to add to selectors without any @media.
+ * @access private
+ * @version 1.0
+ */
+ public function convert_raw_css( $default_media = '' ) {
+ $this->tokens = array();
+
+ foreach ( $this->css as $medium => $val ) {
+ if ( $this->parser->get_cfg( 'sort_selectors' ) ) {
+ ksort( $val );
+ }
+ if ( (int) $medium < DEFAULT_AT ) {
+ $this->parser->_add_token( AT_START, $medium, true );
+ } elseif ( $default_media ) {
+ $this->parser->_add_token( AT_START, $default_media, true );
+ }
+
+ foreach ( $val as $selector => $vali ) {
+ if ( $this->parser->get_cfg( 'sort_properties' ) ) {
+ ksort( $vali );
+ }
+ $this->parser->_add_token( SEL_START, $selector, true );
+
+ foreach ( $vali as $property => $valj ) {
+ $this->parser->_add_token( PROPERTY, $property, true );
+ $this->parser->_add_token( VALUE, $valj, true );
+ }
+
+ $this->parser->_add_token( SEL_END, $selector, true );
+ }
+
+ if ( (int) $medium < DEFAULT_AT ) {
+ $this->parser->_add_token( AT_END, $medium, true );
+ } elseif ( $default_media ) {
+ $this->parser->_add_token( AT_END, $default_media, true );
+ }
+ }
+ }
+
+ /**
+ * Same as htmlspecialchars, only that chars are not replaced if $plain !== true. This makes print_code() cleaner.
+ *
+ * @param string $string - the string we're converting.
+ * @param bool $plain - plain text or not.
+ * @return string
+ * @see csstidy_print::_print()
+ * @access private
+ * @version 1.0
+ */
+ public function htmlsp( $string, $plain ) {
+ if ( ! $plain ) {
+ return htmlspecialchars( $string, ENT_QUOTES, 'utf-8' );
+ }
+ return $string;
+ }
+
+ /**
+ * Get compression ratio
+ *
+ * @access public
+ * @return float
+ * @version 1.2
+ */
+ public function get_ratio() {
+ if ( ! $this->output_css_plain ) {
+ $this->formatted();
+ }
+ return round( ( strlen( $this->input_css ) - strlen( $this->output_css_plain ) ) / strlen( $this->input_css ), 3 ) * 100;
+ }
+
+ /**
+ * Get difference between the old and new code in bytes and prints the code if necessary.
+ *
+ * @access public
+ * @return string
+ * @version 1.1
+ */
+ public function get_diff() {
+ if ( ! $this->output_css_plain ) {
+ $this->formatted();
+ }
+
+ $diff = strlen( $this->output_css_plain ) - strlen( $this->input_css );
+
+ if ( $diff > 0 ) {
+ return '+' . $diff;
+ } elseif ( $diff === 0 ) {
+ return '+-' . $diff;
+ }
+
+ return $diff;
+ }
+
+ /**
+ * Get the size of either input or output CSS in KB
+ *
+ * @param string $loc default is "output".
+ * @access public
+ * @return integer
+ * @version 1.0
+ */
+ public function size( $loc = 'output' ) {
+ if ( $loc === 'output' && ! $this->output_css ) {
+ $this->formatted();
+ }
+
+ if ( $loc === 'input' ) {
+ return ( strlen( $this->input_css ) / 1000 );
+ } else {
+ return ( strlen( $this->output_css_plain ) / 1000 );
+ }
+ }
+
+}
diff --git a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy.php b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy.php
index 106a770b..f7286d27 100644
--- a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy.php
+++ b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* CSSTidy - CSS Parser and Optimiser
*
@@ -28,63 +28,69 @@
* @author Nikolay Matsievsky (speed at webo dot name) 2009-2010
* @author Cedric Morin (cedric at yterium dot com) 2010
*/
+
+// phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged
+
/**
* Defines ctype functions if required
*
* @version 1.0
*/
-require_once( dirname( __FILE__ ) . '/class.csstidy_ctype.php' );
+require_once __DIR__ . '/class.csstidy-ctype.php';
/**
* Various CSS data needed for correct optimisations etc.
*
* @version 1.3
*/
-require( dirname( __FILE__ ) . '/data.inc.php' );
+require __DIR__ . '/data.inc.php';
/**
* Contains a class for printing CSS code
*
* @version 1.0
*/
-require( dirname( __FILE__ ) . '/class.csstidy_print.php' );
+require __DIR__ . '/class.csstidy-print.php';
/**
* Contains a class for optimising CSS code
*
* @version 1.0
*/
-require( dirname( __FILE__ ) . '/class.csstidy_optimise.php' );
+require __DIR__ . '/class.csstidy-optimise.php';
/**
* CSS Parser class
- *
* This class represents a CSS parser which reads CSS code and saves it in an array.
* In opposite to most other CSS parsers, it does not use regular expressions and
* thus has full CSS2 support and a higher reliability.
* Additional to that it applies some optimisations and fixes to the CSS code.
* An online version should be available here: https://cdburnerxp.se/cssparse/css_optimiser.php
+ *
* @package csstidy
* @author Florian Schmitz (floele at gmail dot com) 2005-2006
* @version 1.3.1
*/
-class csstidy {
+class csstidy { // phpcs:ignore
/**
* Saves the parsed CSS. This array is empty if preserve_css is on.
+ *
* @var array
* @access public
*/
public $css = array();
/**
* Saves the parsed CSS (raw)
+ *
* @var array
* @access private
*/
public $tokens = array();
/**
* Printer class
+ *
* @see csstidy_print
* @var object
* @access public
@@ -92,6 +98,7 @@ class csstidy {
public $print;
/**
* Optimiser class
+ *
* @see csstidy_optimise
* @var object
* @access private
@@ -99,30 +106,35 @@ class csstidy {
public $optimise;
/**
* Saves the CSS charset (@charset)
+ *
* @var string
* @access private
*/
public $charset = '';
/**
* Saves all @import URLs
+ *
* @var array
* @access private
*/
public $import = array();
/**
* Saves the namespace
+ *
* @var string
* @access private
*/
public $namespace = '';
/**
* Contains the version of csstidy
+ *
* @var string
* @access private
*/
public $version = '1.3';
/**
* Stores the settings
+ *
* @var array
* @access private
*/
@@ -144,30 +156,35 @@ class csstidy {
public $status = 'is';
/**
* Saves the current at rule (@media)
+ *
* @var string
* @access private
*/
public $at = '';
/**
* Saves the current selector
+ *
* @var string
* @access private
*/
public $selector = '';
/**
* Saves the current property
+ *
* @var string
* @access private
*/
public $property = '';
/**
* Saves the position of , in selectors
+ *
* @var array
* @access private
*/
public $sel_separate = array();
/**
* Saves the current value
+ *
* @var string
* @access private
*/
@@ -179,12 +196,14 @@ class csstidy {
* background:url(foo.png) red no-repeat;
* "url(foo.png)", "red", and "no-repeat" are subvalues,
* separated by whitespace
+ *
* @var string
* @access private
*/
public $sub_value = '';
/**
* Array which saves all subvalues for a property.
+ *
* @var array
* @see sub_value
* @access private
@@ -192,13 +211,21 @@ class csstidy {
public $sub_value_arr = array();
/**
* Saves the stack of characters that opened the current strings
+ *
* @var array
* @access private
*/
public $str_char = array();
+ /**
+ * Current strings.
+ *
+ * @var array
+ * @access private
+ */
public $cur_string = array();
/**
* Status from which the parser switched to ic or instr
+ *
* @var array
* @access private
*/
@@ -206,30 +233,35 @@ class csstidy {
/**
/**
* =true if in invalid at-rule
+ *
* @var bool
* @access private
*/
public $invalid_at = false;
/**
* =true if something has been added to the current selector
+ *
* @var bool
* @access private
*/
public $added = false;
/**
* Array which saves the message log
+ *
* @var array
* @access private
*/
public $log = array();
/**
* Saves the line number
+ *
* @var integer
* @access private
*/
public $line = 1;
/**
* Marks if we need to leave quotes for a string
+ *
* @var array
* @access private
*/
@@ -237,125 +269,137 @@ class csstidy {
/**
* List of tokens
+ *
* @var string
*/
- public $tokens_list = "";
+ public $tokens_list = '';
/**
- * Loads standard template and sets default settings
+ * Loads standard template and sets default settings.
+ *
* @access private
* @version 1.3
*/
- function __construct() {
- $this->settings['remove_bslash'] = true;
- $this->settings['compress_colors'] = true;
+ public function __construct() {
+ $this->settings['remove_bslash'] = true;
+ $this->settings['compress_colors'] = true;
$this->settings['compress_font-weight'] = true;
- $this->settings['lowercase_s'] = false;
+ $this->settings['lowercase_s'] = false;
+
/*
- 1 common shorthands optimization
- 2 + font property optimization
- 3 + background property optimization
+ 1 common shorthands optimization
+ 2 + font property optimization
+ 3 + background property optimization
*/
$this->settings['optimise_shorthands'] = 1;
- $this->settings['remove_last_;'] = true;
+ $this->settings['remove_last_;'] = true;
/* rewrite all properties with low case, better for later gzip OK, safe*/
$this->settings['case_properties'] = 1;
- /* sort properties in alpabetic order, better for later gzip
+
+ /*
+ * sort properties in alpabetic order, better for later gzip
* but can cause trouble in case of overiding same propertie or using hack
*/
$this->settings['sort_properties'] = false;
+
/*
- 1, 3, 5, etc -- enable sorting selectors inside @media: a{}b{}c{}
- 2, 5, 8, etc -- enable sorting selectors inside one CSS declaration: a,b,c{}
- preserve order by default cause it can break functionnality
+ 1, 3, 5, etc -- enable sorting selectors inside @media: a{}b{}c{}
+ 2, 5, 8, etc -- enable sorting selectors inside one CSS declaration: a,b,c{}
+ preserve order by default cause it can break functionnality
*/
$this->settings['sort_selectors'] = 0;
/* is dangeroues to be used: CSS is broken sometimes */
$this->settings['merge_selectors'] = 0;
/* preserve or not browser hacks */
- $this->settings['discard_invalid_selectors'] = false;
+ $this->settings['discard_invalid_selectors'] = false;
$this->settings['discard_invalid_properties'] = false;
- $this->settings['css_level'] = 'CSS2.1';
- $this->settings['preserve_css'] = false;
- $this->settings['timestamp'] = false;
- $this->settings['template'] = ''; // say that propertie exist
- $this->set_cfg('template','default'); // call load_template
+ $this->settings['css_level'] = 'CSS2.1';
+ $this->settings['preserve_css'] = false;
+ $this->settings['timestamp'] = false;
+ $this->settings['template'] = ''; // say that propertie exist.
+ $this->set_cfg( 'template', 'default' ); // call load_template.
/* Tells csstidy_optimise to keep leading zeros on decimal numbers, e.g., 0.7 */
$this->settings['preserve_leading_zeros'] = false;
- $this->optimise = new csstidy_optimise($this);
+ $this->optimise = new csstidy_optimise( $this );
$this->tokens_list = & $GLOBALS['csstidy']['tokens'];
}
- function csstidy() {
+ /**
+ * Call the construct function.
+ */
+ public function csstidy() {
$this->__construct();
}
/**
* Get the value of a setting.
- * @param string $setting
+ *
+ * @param string $setting - the settings.
* @access public
* @return mixed
* @version 1.0
*/
- function get_cfg($setting) {
- if (isset($this->settings[$setting])) {
- return $this->settings[$setting];
+ public function get_cfg( $setting ) {
+ if ( isset( $this->settings[ $setting ] ) ) {
+ return $this->settings[ $setting ];
}
return false;
}
/**
* Load a template
- * @param string $template used by set_cfg to load a template via a configuration setting
+ *
+ * @param string $template used by set_cfg to load a template via a configuration setting.
* @access private
* @version 1.4
*/
- function _load_template($template) {
- switch ($template) {
+ public function _load_template( $template ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
+ switch ( $template ) {
case 'default':
- $this->load_template('default');
+ $this->load_template( 'default' );
break;
case 'highest':
- $this->load_template('highest_compression');
+ $this->load_template( 'highest_compression' );
break;
case 'high':
- $this->load_template('high_compression');
+ $this->load_template( 'high_compression' );
break;
case 'low':
- $this->load_template('low_compression');
+ $this->load_template( 'low_compression' );
break;
default:
- $this->load_template($template);
+ $this->load_template( $template );
break;
}
}
/**
* Set the value of a setting.
- * @param string $setting
- * @param mixed $value
+ *
+ * @param string $setting - the setting.
+ * @param mixed $value - the value we're setting.
* @access public
* @return bool
* @version 1.0
*/
- function set_cfg($setting, $value=null) {
- if (is_array($setting) && $value === null) {
- foreach ($setting as $setprop => $setval) {
- $this->settings[$setprop] = $setval;
+ public function set_cfg( $setting, $value = null ) {
+ if ( is_array( $setting ) && null === $value ) {
+ foreach ( $setting as $setprop => $setval ) {
+ $this->settings[ $setprop ] = $setval;
}
- if (array_key_exists('template', $setting)) {
- $this->_load_template($this->settings['template']);
+ if ( array_key_exists( 'template', $setting ) ) {
+ $this->_load_template( $this->settings['template'] );
}
return true;
- } else if (isset($this->settings[$setting]) && $value !== '') {
- $this->settings[$setting] = $value;
- if ($setting === 'template') {
- $this->_load_template($this->settings['template']);
+ } elseif ( isset( $this->settings[ $setting ] ) && '' !== $value ) {
+ $this->settings[ $setting ] = $value;
+ if ( 'template' === $setting ) {
+ $this->_load_template( $this->settings['template'] );
}
return true;
}
@@ -364,481 +408,482 @@ class csstidy {
/**
* Adds a token to $this->tokens
- * @param mixed $type
- * @param string $data
- * @param bool $do add a token even if preserve_css is off
+ *
+ * @param mixed $type - the type.
+ * @param string $data - data.
+ * @param bool $do add a token even if preserve_css is off.
* @access private
* @version 1.0
*/
- function _add_token($type, $data, $do = false) {
- if ($this->get_cfg('preserve_css') || $do) {
- $this->tokens[] = array($type, ($type == COMMENT) ? $data : trim($data));
+ public function _add_token( $type, $data, $do = false ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
+ if ( $this->get_cfg( 'preserve_css' ) || $do ) {
+ $this->tokens[] = array( $type, ( COMMENT === $type ) ? $data : trim( $data ) );
}
}
/**
* Add a message to the message log
- * @param string $message
- * @param string $type
- * @param integer $line
+ *
+ * @param string $message - the message.
+ * @param string $type - the type of message.
+ * @param integer $line - the line.
* @access private
* @version 1.0
*/
- function log($message, $type, $line = -1) {
- if ($line === -1) {
+ public function log( $message, $type, $line = -1 ) {
+ if ( -1 === $line ) {
$line = $this->line;
}
$line = (int) $line;
- $add = array('m' => $message, 't' => $type);
- if (!isset($this->log[$line]) || !in_array($add, $this->log[$line])) {
- $this->log[$line][] = $add;
+ $add = array(
+ 'm' => $message,
+ 't' => $type,
+ );
+ if ( ! isset( $this->log[ $line ] ) || ! in_array( $add, $this->log[ $line ], true ) ) {
+ $this->log[ $line ][] = $add;
}
}
/**
* Parse unicode notations and find a replacement character
- * @param string $string
- * @param integer $i
+ *
+ * @param string $string - a string.
+ * @param integer $i - counting integer.
* @access private
* @return string
* @version 1.2
*/
- function _unicode(&$string, &$i) {
+ public function _unicode( &$string, &$i ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
++$i;
- $add = '';
+ $add = '';
$replaced = false;
- while ($i < strlen($string) && (ctype_xdigit($string[$i]) || ctype_space($string[$i])) && strlen($add) < 6) {
- $add .= $string[$i];
+ while ( $i < strlen( $string ) && ( ctype_xdigit( $string[ $i ] ) || ctype_space( $string[ $i ] ) ) && strlen( $add ) < 6 ) { // phpcs:ignore Squiz.PHP.DisallowSizeFunctionsInLoops.Found
+ $add .= $string[ $i ];
- if (ctype_space($string[$i])) {
+ if ( ctype_space( $string[ $i ] ) ) {
break;
}
$i++;
}
- if (hexdec($add) > 47 && hexdec($add) < 58 || hexdec($add) > 64 && hexdec($add) < 91 || hexdec($add) > 96 && hexdec($add) < 123) {
- $this->log('Replaced unicode notation: Changed \\' . $add . ' to ' . chr(hexdec($add)), 'Information');
- $add = chr(hexdec($add));
+ if ( hexdec( $add ) > 47 && hexdec( $add ) < 58 || hexdec( $add ) > 64 && hexdec( $add ) < 91 || hexdec( $add ) > 96 && hexdec( $add ) < 123 ) {
+ $this->log( 'Replaced unicode notation: Changed \\' . $add . ' to ' . chr( hexdec( $add ) ), 'Information' );
+ $add = chr( hexdec( $add ) );
$replaced = true;
} else {
- $add = trim('\\' . $add);
+ $add = trim( '\\' . $add );
}
- if (@ctype_xdigit($string[$i + 1]) && ctype_space($string[$i])
- && !$replaced || !ctype_space($string[$i])) {
+ if ( @ctype_xdigit( $string[ $i + 1 ] ) && ctype_space( $string[ $i ] )
+ && ! $replaced || ! ctype_space( $string[ $i ] ) ) {
$i--;
}
- if ($add !== '\\' || !$this->get_cfg('remove_bslash') || strpos($this->tokens_list, $string[$i + 1]) !== false) {
+ if ( '\\' !== $add || ! $this->get_cfg( 'remove_bslash' ) || strpos( $this->tokens_list, $string[ $i + 1 ] ) !== false ) {
return $add;
}
- if ($add === '\\') {
- $this->log('Removed unnecessary backslash', 'Information');
+ if ( '\\' === $add ) {
+ $this->log( 'Removed unnecessary backslash', 'Information' );
}
return '';
}
/**
* Write formatted output to a file
- * @param string $filename
- * @param string $doctype when printing formatted, is a shorthand for the document type
- * @param bool $externalcss when printing formatted, indicates whether styles to be attached internally or as an external stylesheet
- * @param string $title when printing formatted, is the title to be added in the head of the document
- * @param string $lang when printing formatted, gives a two-letter language code to be added to the output
+ *
+ * @param string $filename - the file na,e.
+ * @param string $doctype when printing formatted, is a shorthand for the document type.
+ * @param bool $externalcss when printing formatted, indicates whether styles to be attached internally or as an external stylesheet.
+ * @param string $title when printing formatted, is the title to be added in the head of the document.
+ * @param string $lang when printing formatted, gives a two-letter language code to be added to the output.
* @access public
* @version 1.4
*/
- function write_page($filename, $doctype='xhtml1.1', $externalcss=true, $title='', $lang='en') {
- $this->write($filename, true);
+ public function write_page( $filename, $doctype = 'xhtml1.1', $externalcss = true, $title = '', $lang = 'en' ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
+ $this->write( $filename, true );
}
/**
* Write plain output to a file
- * @param string $filename
- * @param bool $formatted whether to print formatted or not
- * @param string $doctype when printing formatted, is a shorthand for the document type
- * @param bool $externalcss when printing formatted, indicates whether styles to be attached internally or as an external stylesheet
- * @param string $title when printing formatted, is the title to be added in the head of the document
- * @param string $lang when printing formatted, gives a two-letter language code to be added to the output
- * @param bool $pre_code whether to add pre and code tags around the code (for light HTML formatted templates)
+ *
+ * @param string $filename the file name.
+ * @param bool $formatted whether to print formatted or not.
+ * @param string $doctype when printing formatted, is a shorthand for the document type.
+ * @param bool $externalcss when printing formatted, indicates whether styles to be attached internally or as an external stylesheet.
+ * @param string $title when printing formatted, is the title to be added in the head of the document.
+ * @param string $lang when printing formatted, gives a two-letter language code to be added to the output.
+ * @param bool $pre_code whether to add pre and code tags around the code (for light HTML formatted templates).
* @access public
* @version 1.4
*/
- function write($filename, $formatted=false, $doctype='xhtml1.1', $externalcss=true, $title='', $lang='en', $pre_code=true) {
- $filename .= ( $formatted) ? '.xhtml' : '.css';
+ public function write( $filename, $formatted = false, $doctype = 'xhtml1.1', $externalcss = true, $title = '', $lang = 'en', $pre_code = true ) {
+ $filename .= ( $formatted ) ? '.xhtml' : '.css';
- if (!is_dir('temp')) {
- $madedir = mkdir('temp');
- if (!$madedir) {
- print 'Could not make directory "temp" in ' . dirname(__FILE__);
+ if ( ! is_dir( 'temp' ) ) {
+ $madedir = mkdir( 'temp' );
+ if ( ! $madedir ) {
+ print 'Could not make directory "temp" in ' . __DIR__;
exit;
}
}
- $handle = fopen('temp/' . $filename, 'w');
- if ($handle) {
- if (!$formatted) {
- fwrite($handle, $this->print->plain());
+ $handle = fopen( 'temp/' . $filename, 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen
+ if ( $handle ) {
+ if ( ! $formatted ) {
+ fwrite( $handle, $this->print->plain() ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite
} else {
- fwrite($handle, $this->print->formatted_page($doctype, $externalcss, $title, $lang, $pre_code));
+ fwrite( $handle, $this->print->formatted_page( $doctype, $externalcss, $title, $lang, $pre_code ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite
}
}
- fclose($handle);
+ fclose( $handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
}
/**
* Loads a new template
- * @param string $content either filename (if $from_file == true), content of a template file, "high_compression", "highest_compression", "low_compression", or "default"
- * @param bool $from_file uses $content as filename if true
+ *
+ * @param string $content either filename (if $from_file == true), content of a template file, "high_compression", "highest_compression", "low_compression", or "default".
+ * @param bool $from_file uses $content as filename if true.
* @access public
* @version 1.1
* @see http://csstidy.sourceforge.net/templates.php
*/
- function load_template($content, $from_file=true) {
+ public function load_template( $content, $from_file = true ) {
$predefined_templates = & $GLOBALS['csstidy']['predefined_templates'];
- if ($content === 'high_compression' || $content === 'default' || $content === 'highest_compression' || $content === 'low_compression') {
- $this->template = $predefined_templates[$content];
+ if ( 'high_compression' === $content || 'default' === $content || 'highest_compression' === $content || 'low_compression' === $content ) {
+ $this->template = $predefined_templates[ $content ];
return;
}
-
- if ($from_file) {
- $content = strip_tags(file_get_contents($content), '<span>');
+ if ( $from_file ) {
+ $content = strip_tags( file_get_contents( $content ), '<span>' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
}
- $content = str_replace("\r\n", "\n", $content); // Unify newlines (because the output also only uses \n)
- $template = explode('|', $content);
+ $content = str_replace( "\r\n", "\n", $content ); // Unify newlines (because the output also only uses \n).
+ $template = explode( '|', $content );
- for ($i = 0; $i < count($template); $i++) {
- $this->template[$i] = $template[$i];
- }
+ $this->template = array_replace( $this->template, $template );
}
/**
* Starts parsing from URL
- * @param string $url
+ *
+ * @param string $url - the URL.
* @access public
* @version 1.0
*/
- function parse_from_url($url) {
- return $this->parse(@file_get_contents($url));
+ public function parse_from_url( $url ) {
+ return $this->parse( @file_get_contents( $url ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
}
/**
* Checks if there is a token at the current position
- * @param string $string
- * @param integer $i
+ *
+ * @param string $string - the string we're checking.
+ * @param integer $i - an int.
* @access public
* @version 1.11
*/
- function is_token(&$string, $i) {
- return (strpos($this->tokens_list, $string[$i]) !== false && !csstidy::escaped($string, $i));
+ public function is_token( &$string, $i ) {
+ return ( strpos( $this->tokens_list, $string[ $i ] ) !== false && ! self::escaped( $string, $i ) );
}
/**
* Parses CSS in $string. The code is saved as array in $this->css
- * @param string $string the CSS code
+ *
+ * @param string $string the CSS code.
* @access public
* @return bool
* @version 1.1
*/
- function parse($string) {
- // Temporarily set locale to en_US in order to handle floats properly
- $old = @setlocale(LC_ALL, 0);
- @setlocale(LC_ALL, 'C');
+ public function parse( $string ) {
+ // Temporarily set locale to en_US in order to handle floats properly.
+ $old = @setlocale( LC_ALL, 0 );
+ @setlocale( LC_ALL, 'C' );
- // PHP bug? Settings need to be refreshed in PHP4
- $this->print = new csstidy_print($this);
- //$this->optimise = new csstidy_optimise($this);
+ // PHP bug? Settings need to be refreshed in PHP4.
+ $this->print = new csstidy_print( $this );
- $all_properties = & $GLOBALS['csstidy']['all_properties'];
- $at_rules = & $GLOBALS['csstidy']['at_rules'];
+ $at_rules = & $GLOBALS['csstidy']['at_rules'];
$quoted_string_properties = & $GLOBALS['csstidy']['quoted_string_properties'];
- $this->css = array();
+ $this->css = array();
$this->print->input_css = $string;
- $string = str_replace("\r\n", "\n", $string) . ' ';
- $cur_comment = '';
+ $string = str_replace( "\r\n", "\n", $string ) . ' ';
+ $cur_comment = '';
- for ($i = 0, $size = strlen($string); $i < $size; $i++) {
- if ($string[$i] === "\n" || $string[$i] === "\r") {
+ for ( $i = 0, $size = strlen( $string ); $i < $size; $i++ ) {
+ if ( "\n" === $string[ $i ] || "\r" === $string[ $i ] ) {
++$this->line;
}
- switch ($this->status) {
+ switch ( $this->status ) {
/* Case in at-block */
case 'at':
- if (csstidy::is_token($string, $i)) {
- if ($string[$i] === '/' && @$string[$i + 1] === '*') {
+ if ( self::is_token( $string, $i ) ) {
+ if ( '/' === $string[ $i ] && '*' === @$string[ $i + 1 ] ) {
$this->status = 'ic';
++$i;
$this->from[] = 'at';
- } elseif ($string[$i] === '{') {
+ } elseif ( '{' === $string[ $i ] ) {
$this->status = 'is';
- $this->at = $this->css_new_media_section($this->at);
- $this->_add_token(AT_START, $this->at);
- } elseif ($string[$i] === ',') {
- $this->at = trim($this->at) . ',';
- } elseif ($string[$i] === '\\') {
- $this->at .= $this->_unicode($string, $i);
- }
- // fix for complicated media, i.e @media screen and (-webkit-min-device-pixel-ratio:1.5)
- // '/' is included for ratios in Opera: (-o-min-device-pixel-ratio: 3/2)
- elseif (in_array($string[$i], array('(', ')', ':', '.', '/'))) {
- $this->at .= $string[$i];
+ $this->at = $this->css_new_media_section( $this->at );
+ $this->_add_token( AT_START, $this->at );
+ } elseif ( ',' === $string[ $i ] ) {
+ $this->at = trim( $this->at ) . ',';
+ } elseif ( '\\' === $string[ $i ] ) {
+ $this->at .= $this->_unicode( $string, $i );
+ } elseif ( in_array( $string[ $i ], array( '(', ')', ':', '.', '/' ), true ) ) {
+ // fix for complicated media, i.e @media screen and (-webkit-min-device-pixel-ratio:1.5)
+ // '/' is included for ratios in Opera: (-o-min-device-pixel-ratio: 3/2).
+ $this->at .= $string[ $i ];
}
} else {
- $lastpos = strlen($this->at) - 1;
- if (!( (ctype_space($this->at[$lastpos]) || csstidy::is_token($this->at, $lastpos) && $this->at[$lastpos] === ',') && ctype_space($string[$i]))) {
- $this->at .= $string[$i];
+ $lastpos = strlen( $this->at ) - 1;
+ if ( ! ( ( ctype_space( $this->at[ $lastpos ] ) || self::is_token( $this->at, $lastpos ) && ',' === $this->at[ $lastpos ] ) && ctype_space( $string[ $i ] ) ) ) {
+ $this->at .= $string[ $i ];
}
}
break;
/* Case in-selector */
case 'is':
- if (csstidy::is_token($string, $i)) {
- if ($string[$i] === '/' && @$string[$i + 1] === '*' && trim($this->selector) == '') {
+ if ( self::is_token( $string, $i ) ) {
+ if ( '/' === $string[ $i ] && '*' === @$string[ $i + 1 ] && '' === trim( $this->selector ) ) {
$this->status = 'ic';
++$i;
$this->from[] = 'is';
- } elseif ($string[$i] === '@' && trim($this->selector) == '') {
- // Check for at-rule
+ } elseif ( '@' === $string[ $i ] && '' === trim( $this->selector ) ) {
+ // Check for at-rule.
$this->invalid_at = true;
- foreach ($at_rules as $name => $type) {
- if (!strcasecmp(substr($string, $i + 1, strlen($name)), $name)) {
- ($type === 'at') ? $this->at = '@' . $name : $this->selector = '@' . $name;
- $this->status = $type;
- $i += strlen($name);
- $this->invalid_at = false;
+ foreach ( $at_rules as $name => $type ) {
+ if ( ! strcasecmp( substr( $string, $i + 1, strlen( $name ) ), $name ) ) {
+ ( 'at' === $type ) ? $this->at = '@' . $name : $this->selector = '@' . $name;
+ $this->status = $type;
+ $i += strlen( $name );
+ $this->invalid_at = false;
}
}
- if ($this->invalid_at) {
- $this->selector = '@';
+ if ( $this->invalid_at ) {
+ $this->selector = '@';
$invalid_at_name = '';
- for ($j = $i + 1; $j < $size; ++$j) {
- if (!ctype_alpha($string[$j])) {
+ for ( $j = $i + 1; $j < $size; ++$j ) {
+ if ( ! ctype_alpha( $string[ $j ] ) ) {
break;
}
- $invalid_at_name .= $string[$j];
+ $invalid_at_name .= $string[ $j ];
}
- $this->log('Invalid @-rule: ' . $invalid_at_name . ' (removed)', 'Warning');
+ $this->log( 'Invalid @-rule: ' . $invalid_at_name . ' (removed)', 'Warning' );
}
- } elseif (($string[$i] === '"' || $string[$i] === "'")) {
- $this->cur_string[] = $string[$i];
- $this->status = 'instr';
- $this->str_char[] = $string[$i];
- $this->from[] = 'is';
+ } elseif ( ( '"' === $string[ $i ] || "'" === $string[ $i ] ) ) {
+ $this->cur_string[] = $string[ $i ];
+ $this->status = 'instr';
+ $this->str_char[] = $string[ $i ];
+ $this->from[] = 'is';
/* fixing CSS3 attribute selectors, i.e. a[href$=".mp3" */
- $this->quoted_string[] = ($string[$i - 1] == '=' );
- } elseif ($this->invalid_at && $string[$i] === ';') {
+ $this->quoted_string[] = ( '=' === $string[ $i - 1 ] );
+ } elseif ( $this->invalid_at && ';' === $string[ $i ] ) {
$this->invalid_at = false;
- $this->status = 'is';
- } elseif ($string[$i] === '{') {
+ $this->status = 'is';
+ } elseif ( '{' === $string[ $i ] ) {
$this->status = 'ip';
- if($this->at == '') {
- $this->at = $this->css_new_media_section(DEFAULT_AT);
+ if ( '' === $this->at ) {
+ $this->at = $this->css_new_media_section( DEFAULT_AT );
}
- $this->selector = $this->css_new_selector($this->at,$this->selector);
- $this->_add_token(SEL_START, $this->selector);
+ $this->selector = $this->css_new_selector( $this->at, $this->selector );
+ $this->_add_token( SEL_START, $this->selector );
$this->added = false;
- } elseif ($string[$i] === '}') {
- $this->_add_token(AT_END, $this->at);
- $this->at = '';
- $this->selector = '';
+ } elseif ( '}' === $string[ $i ] ) {
+ $this->_add_token( AT_END, $this->at );
+ $this->at = '';
+ $this->selector = '';
$this->sel_separate = array();
- } elseif ($string[$i] === ',') {
- $this->selector = trim($this->selector) . ',';
- $this->sel_separate[] = strlen($this->selector);
- } elseif ($string[$i] === '\\') {
- $this->selector .= $this->_unicode($string, $i);
- } elseif ($string[$i] === '*' && @in_array($string[$i + 1], array('.', '#', '[', ':'))) {
- // remove unnecessary universal selector, FS#147
+ } elseif ( ',' === $string[ $i ] ) {
+ $this->selector = trim( $this->selector ) . ',';
+ $this->sel_separate[] = strlen( $this->selector );
+ } elseif ( '\\' === $string[ $i ] ) {
+ $this->selector .= $this->_unicode( $string, $i );
+ } elseif ( '*' === $string[ $i ] && @in_array( $string[ $i + 1 ], array( '.', '#', '[', ':' ), true ) ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedElseif
+ // remove unnecessary universal selector, FS#147.
} else {
- $this->selector .= $string[$i];
+ $this->selector .= $string[ $i ];
}
} else {
- $lastpos = strlen($this->selector) - 1;
- if ($lastpos == -1 || !( (ctype_space($this->selector[$lastpos]) || csstidy::is_token($this->selector, $lastpos) && $this->selector[$lastpos] === ',') && ctype_space($string[$i]))) {
- $this->selector .= $string[$i];
- }
- else if (ctype_space($string[$i]) && $this->get_cfg('preserve_css') && !$this->get_cfg('merge_selectors')) {
- $this->selector .= $string[$i];
+ $lastpos = strlen( $this->selector ) - 1;
+ if ( -1 === $lastpos || ! ( ( ctype_space( $this->selector[ $lastpos ] ) || self::is_token( $this->selector, $lastpos ) && ',' === $this->selector[ $lastpos ] ) && ctype_space( $string[ $i ] ) ) ) {
+ $this->selector .= $string[ $i ];
+ } elseif ( ctype_space( $string[ $i ] ) && $this->get_cfg( 'preserve_css' ) && ! $this->get_cfg( 'merge_selectors' ) ) {
+ $this->selector .= $string[ $i ];
}
}
break;
/* Case in-property */
case 'ip':
- if (csstidy::is_token($string, $i)) {
- if (($string[$i] === ':' || $string[$i] === '=') && $this->property != '') {
+ if ( self::is_token( $string, $i ) ) {
+ if ( ( ':' === $string[ $i ] || '=' === $string[ $i ] ) && '' !== $this->property ) {
$this->status = 'iv';
- if (!$this->get_cfg('discard_invalid_properties') || csstidy::property_is_valid($this->property)) {
- $this->property = $this->css_new_property($this->at,$this->selector,$this->property);
- $this->_add_token(PROPERTY, $this->property);
+ if ( ! $this->get_cfg( 'discard_invalid_properties' ) || self::property_is_valid( $this->property ) ) {
+ $this->property = $this->css_new_property( $this->at, $this->selector, $this->property );
+ $this->_add_token( PROPERTY, $this->property );
}
- } elseif ($string[$i] === '/' && @$string[$i + 1] === '*' && $this->property == '') {
+ } elseif ( '/' === $string[ $i ] && '*' === @$string[ $i + 1 ] && '' === $this->property ) {
$this->status = 'ic';
++$i;
$this->from[] = 'ip';
- } elseif ($string[$i] === '}') {
+ } elseif ( '}' === $string[ $i ] ) {
$this->explode_selectors();
- $this->status = 'is';
+ $this->status = 'is';
$this->invalid_at = false;
- $this->_add_token(SEL_END, $this->selector);
+ $this->_add_token( SEL_END, $this->selector );
$this->selector = '';
$this->property = '';
- } elseif ($string[$i] === ';') {
+ } elseif ( ';' === $string[ $i ] ) {
$this->property = '';
- } elseif ($string[$i] === '\\') {
- $this->property .= $this->_unicode($string, $i);
+ } elseif ( '\\' === $string[ $i ] ) {
+ $this->property .= $this->_unicode( $string, $i );
+ } elseif ( '' === $this->property && ! ctype_space( $string[ $i ] ) ) {
+ // else this is dumb IE a hack, keep it.
+ $this->property .= $string[ $i ];
}
- // else this is dumb IE a hack, keep it
- elseif ($this->property=='' AND !ctype_space($string[$i])) {
- $this->property .= $string[$i];
- }
- }
- elseif (!ctype_space($string[$i])) {
- $this->property .= $string[$i];
+ } elseif ( ! ctype_space( $string[ $i ] ) ) {
+ $this->property .= $string[ $i ];
}
break;
/* Case in-value */
case 'iv':
- $pn = (($string[$i] === "\n" || $string[$i] === "\r") && $this->property_is_next($string, $i + 1) || $i == strlen($string) - 1);
- if ((csstidy::is_token($string, $i) || $pn) && (!($string[$i] == ',' && !ctype_space($string[$i+1])))) {
- if ($string[$i] === '/' && @$string[$i + 1] === '*') {
+ $pn = ( ( "\n" === $string[ $i ] || "\r" === $string[ $i ] ) && $this->property_is_next( $string, $i + 1 ) || strlen( $string ) - 1 === $i );
+ if ( ( self::is_token( $string, $i ) || $pn ) && ( ! ( ',' === $string[ $i ] && ! ctype_space( $string[ $i + 1 ] ) ) ) ) {
+ if ( '/' === $string[ $i ] && '*' === @$string[ $i + 1 ] ) {
$this->status = 'ic';
++$i;
$this->from[] = 'iv';
- } elseif (($string[$i] === '"' || $string[$i] === "'" || $string[$i] === '(')) {
- $this->cur_string[] = $string[$i];
- $this->str_char[] = ($string[$i] === '(') ? ')' : $string[$i];
- $this->status = 'instr';
- $this->from[] = 'iv';
- $this->quoted_string[] = in_array(strtolower($this->property), $quoted_string_properties);
- } elseif ($string[$i] === ',') {
- $this->sub_value = trim($this->sub_value) . ',';
- } elseif ($string[$i] === '\\') {
- $this->sub_value .= $this->_unicode($string, $i);
- } elseif ($string[$i] === ';' || $pn) {
- if ($this->selector[0] === '@' && isset($at_rules[substr($this->selector, 1)]) && $at_rules[substr($this->selector, 1)] === 'iv') {
+ } elseif ( ( '"' === $string[ $i ] || "'" === $string[ $i ] || '(' === $string[ $i ] ) ) {
+ $this->cur_string[] = $string[ $i ];
+ $this->str_char[] = ( '(' === $string[ $i ] ) ? ')' : $string[ $i ];
+ $this->status = 'instr';
+ $this->from[] = 'iv';
+ $this->quoted_string[] = in_array( strtolower( $this->property ), $quoted_string_properties, true );
+ } elseif ( ',' === $string[ $i ] ) {
+ $this->sub_value = trim( $this->sub_value ) . ',';
+ } elseif ( '\\' === $string[ $i ] ) {
+ $this->sub_value .= $this->_unicode( $string, $i );
+ } elseif ( ';' === $string[ $i ] || $pn ) {
+ if ( '@' === $this->selector[0] && isset( $at_rules[ substr( $this->selector, 1 ) ] ) && 'iv' === $at_rules[ substr( $this->selector, 1 ) ] ) {
$this->status = 'is';
- switch ($this->selector) {
+ switch ( $this->selector ) {
case '@charset':
/* Add quotes to charset */
- $this->sub_value_arr[] = '"' . trim($this->sub_value) . '"';
- $this->charset = $this->sub_value_arr[0];
+ $this->sub_value_arr[] = '"' . trim( $this->sub_value ) . '"';
+ $this->charset = $this->sub_value_arr[0];
break;
case '@namespace':
/* Add quotes to namespace */
- $this->sub_value_arr[] = '"' . trim($this->sub_value) . '"';
- $this->namespace = implode(' ', $this->sub_value_arr);
+ $this->sub_value_arr[] = '"' . trim( $this->sub_value ) . '"';
+ $this->namespace = implode( ' ', $this->sub_value_arr );
break;
case '@import':
- $this->sub_value = trim($this->sub_value);
+ $this->sub_value = trim( $this->sub_value );
- if (empty($this->sub_value_arr)) {
+ if ( empty( $this->sub_value_arr ) ) {
// Quote URLs in imports only if they're not already inside url() and not already quoted.
- if (substr($this->sub_value, 0, 4) != 'url(') {
- if (!($this->sub_value[0] == substr($this->sub_value, -1) && in_array($this->sub_value[0], array("'", '"')))) {
+ if ( substr( $this->sub_value, 0, 4 ) !== 'url(' ) {
+ if ( ! ( substr( $this->sub_value, -1 ) === $this->sub_value[0] && in_array( $this->sub_value[0], array( "'", '"' ), true ) ) ) {
$this->sub_value = '"' . $this->sub_value . '"';
}
}
}
$this->sub_value_arr[] = $this->sub_value;
- $this->import[] = implode(' ', $this->sub_value_arr);
+ $this->import[] = implode( ' ', $this->sub_value_arr );
break;
}
$this->sub_value_arr = array();
- $this->sub_value = '';
- $this->selector = '';
- $this->sel_separate = array();
+ $this->sub_value = '';
+ $this->selector = '';
+ $this->sel_separate = array();
} else {
$this->status = 'ip';
}
- } elseif ($string[$i] !== '}') {
- $this->sub_value .= $string[$i];
+ } elseif ( '}' !== $string[ $i ] ) {
+ $this->sub_value .= $string[ $i ];
}
- if (($string[$i] === '}' || $string[$i] === ';' || $pn) && !empty($this->selector)) {
- if ($this->at == '') {
- $this->at = $this->css_new_media_section(DEFAULT_AT);
+ if ( ( '}' === $string[ $i ] || ';' === $string[ $i ] || $pn ) && ! empty( $this->selector ) ) {
+ if ( '' === $this->at ) {
+ $this->at = $this->css_new_media_section( DEFAULT_AT );
}
- // case settings
- if ($this->get_cfg('lowercase_s')) {
- $this->selector = strtolower($this->selector);
+ // case settings.
+ if ( $this->get_cfg( 'lowercase_s' ) ) {
+ $this->selector = strtolower( $this->selector );
}
- $this->property = strtolower($this->property);
+ $this->property = strtolower( $this->property );
$this->optimise->subvalue();
- if ($this->sub_value != '') {
- if (substr($this->sub_value, 0, 6) == 'format') {
- $format_strings = csstidy::parse_string_list(substr($this->sub_value, 7, -1));
- if (!$format_strings) {
- $this->sub_value = "";
- }
- else {
- $this->sub_value = "format(";
-
- foreach ($format_strings as $format_string) {
- $this->sub_value .= '"' . str_replace('"', '\\"', $format_string) . '",';
+ if ( '' !== $this->sub_value ) {
+ if ( substr( $this->sub_value, 0, 6 ) === 'format' ) {
+ $format_strings = self::parse_string_list( substr( $this->sub_value, 7, -1 ) );
+ if ( ! $format_strings ) {
+ $this->sub_value = '';
+ } else {
+ $this->sub_value = 'format(';
+
+ foreach ( $format_strings as $format_string ) {
+ $this->sub_value .= '"' . str_replace( '"', '\\"', $format_string ) . '",';
}
- $this->sub_value = substr($this->sub_value, 0, -1) . ")";
+ $this->sub_value = substr( $this->sub_value, 0, -1 ) . ')';
}
}
- if ($this->sub_value != '') {
+ if ( '' !== $this->sub_value ) {
$this->sub_value_arr[] = $this->sub_value;
}
$this->sub_value = '';
}
- $this->value = array_shift($this->sub_value_arr);
- while(count($this->sub_value_arr)){
- //$this->value .= (substr($this->value,-1,1)==','?'':' ').array_shift($this->sub_value_arr);
- $this->value .= ' '.array_shift($this->sub_value_arr);
+ $this->value = array_shift( $this->sub_value_arr );
+ while ( $this->sub_value_arr ) {
+ $this->value .= ' ' . array_shift( $this->sub_value_arr );
}
$this->optimise->value();
- $valid = csstidy::property_is_valid($this->property);
- if ((!$this->invalid_at || $this->get_cfg('preserve_css')) && (!$this->get_cfg('discard_invalid_properties') || $valid)) {
- $this->css_add_property($this->at, $this->selector, $this->property, $this->value);
- $this->_add_token(VALUE, $this->value);
+ $valid = self::property_is_valid( $this->property );
+ if ( ( ! $this->invalid_at || $this->get_cfg( 'preserve_css' ) ) && ( ! $this->get_cfg( 'discard_invalid_properties' ) || $valid ) ) {
+ $this->css_add_property( $this->at, $this->selector, $this->property, $this->value );
+ $this->_add_token( VALUE, $this->value );
$this->optimise->shorthands();
}
- if (!$valid) {
- if ($this->get_cfg('discard_invalid_properties')) {
- $this->log('Removed invalid property: ' . $this->property, 'Warning');
+ if ( ! $valid ) {
+ if ( $this->get_cfg( 'discard_invalid_properties' ) ) {
+ $this->log( 'Removed invalid property: ' . $this->property, 'Warning' );
} else {
- $this->log('Invalid property in ' . strtoupper($this->get_cfg('css_level')) . ': ' . $this->property, 'Warning');
+ $this->log( 'Invalid property in ' . strtoupper( $this->get_cfg( 'css_level' ) ) . ': ' . $this->property, 'Warning' );
}
}
- $this->property = '';
+ $this->property = '';
$this->sub_value_arr = array();
- $this->value = '';
+ $this->value = '';
}
- if ($string[$i] === '}') {
+ if ( '}' === $string[ $i ] ) {
$this->explode_selectors();
- $this->_add_token(SEL_END, $this->selector);
- $this->status = 'is';
+ $this->_add_token( SEL_END, $this->selector );
+ $this->status = 'is';
$this->invalid_at = false;
- $this->selector = '';
+ $this->selector = '';
}
- } elseif (!$pn) {
- $this->sub_value .= $string[$i];
+ } elseif ( ! $pn ) {
+ $this->sub_value .= $string[ $i ];
- if (ctype_space($string[$i]) || $string[$i] == ',') {
+ if ( ctype_space( $string[ $i ] ) || ',' === $string[ $i ] ) {
$this->optimise->subvalue();
- if ($this->sub_value != '') {
+ if ( '' !== $this->sub_value ) {
$this->sub_value_arr[] = $this->sub_value;
- $this->sub_value = '';
+ $this->sub_value = '';
}
}
}
@@ -846,35 +891,35 @@ class csstidy {
/* Case in string */
case 'instr':
- $_str_char = $this->str_char[count($this->str_char)-1];
- $_cur_string = $this->cur_string[count($this->cur_string)-1];
- $temp_add = $string[$i];
+ $_str_char = $this->str_char[ count( $this->str_char ) - 1 ];
+ $_cur_string = $this->cur_string[ count( $this->cur_string ) - 1 ];
+ $temp_add = $string[ $i ];
// Add another string to the stack. Strings can't be nested inside of quotes, only parentheses, but
// parentheticals can be nested more than once.
- if ($_str_char === ")" && ($string[$i] === "(" || $string[$i] === '"' || $string[$i] === '\'') && !csstidy::escaped($string, $i)) {
- $this->cur_string[] = $string[$i];
- $this->str_char[] = $string[$i] == "(" ? ")" : $string[$i];
- $this->from[] = 'instr';
- $this->quoted_string[] = !($string[$i] === "(");
+ if ( ')' === $_str_char && ( '(' === $string[ $i ] || '"' === $string[ $i ] || '\'' === $string[ $i ] ) && ! self::escaped( $string, $i ) ) {
+ $this->cur_string[] = $string[ $i ];
+ $this->str_char[] = $string[ $i ] === '(' ? ')' : $string[ $i ];
+ $this->from[] = 'instr';
+ $this->quoted_string[] = ! ( '(' === $string[ $i ] );
continue 2;
}
- if ($_str_char !== ")" && ($string[$i] === "\n" || $string[$i] === "\r") && !($string[$i - 1] === '\\' && !csstidy::escaped($string, $i - 1))) {
- $temp_add = "\\A";
- $this->log('Fixed incorrect newline in string', 'Warning');
+ if ( ')' !== $_str_char && ( "\n" === $string[ $i ] || "\r" === $string[ $i ] ) && ! ( '\\' === $string[ $i - 1 ] && ! self::escaped( $string, $i - 1 ) ) ) {
+ $temp_add = '\\A';
+ $this->log( 'Fixed incorrect newline in string', 'Warning' );
}
$_cur_string .= $temp_add;
- if ($string[$i] === $_str_char && !csstidy::escaped($string, $i)) {
- $_quoted_string = array_pop($this->quoted_string);
+ if ( $string[ $i ] === $_str_char && ! self::escaped( $string, $i ) ) {
+ $_quoted_string = array_pop( $this->quoted_string );
- $this->status = array_pop($this->from);
+ $this->status = array_pop( $this->from );
- if (!preg_match('|[' . implode('', $GLOBALS['csstidy']['whitespace']) . ']|uis', $_cur_string) && $this->property !== 'content') {
- if (!$_quoted_string) {
- if ($_str_char !== ')') {
+ if ( ! preg_match( '|[' . implode( '', $GLOBALS['csstidy']['whitespace'] ) . ']|uis', $_cur_string ) && 'content' !== $this->property ) {
+ if ( ! $_quoted_string ) {
+ if ( ')' !== $_str_char ) {
// Convert properties like
// font-family: 'Arial';
// to
@@ -882,51 +927,57 @@ class csstidy {
// or
// url("abc")
// to
- // url(abc)
- $_cur_string = substr($_cur_string, 1, -1);
+ // url(abc).
+ $_cur_string = substr( $_cur_string, 1, -1 );
}
} else {
$_quoted_string = false;
}
}
- array_pop($this->cur_string);
- array_pop($this->str_char);
+ array_pop( $this->cur_string );
+ array_pop( $this->str_char );
- if ($_str_char === ")") {
- $_cur_string = "(" . trim(substr($_cur_string, 1, -1)) . ")";
+ if ( ')' === $_str_char ) {
+ $_cur_string = '(' . trim( substr( $_cur_string, 1, -1 ) ) . ')';
}
- if ($this->status === 'iv') {
- if (!$_quoted_string){
- if (strpos($_cur_string,',')!==false)
- // we can on only remove space next to ','
- $_cur_string = implode(',',array_map('trim',explode(',',$_cur_string)));
- // and multiple spaces (too expensive)
- if (strpos($_cur_string,' ')!==false)
- $_cur_string = preg_replace(",\s+,"," ",$_cur_string);
- }
+ if ( 'iv' === $this->status ) {
+ // phpcs:disable Squiz.PHP.CommentedOutCode.Found, Squiz.Commenting.BlockComment.NoNewLine
+ // WPCOM hack: prevents CSSTidy from removing spaces after commas inside
+ // declaration's values.
+ // For more information, see D74626-code.
+ /*if ( ! $_quoted_string ) {
+ if ( strpos( $_cur_string, ',' ) !== false ) {
+ // we can on only remove space next to ','.
+ $_cur_string = implode( ',', array_map( 'trim', explode( ',', $_cur_string ) ) );
+ }
+ // and multiple spaces (too expensive).
+ if ( strpos( $_cur_string, ' ' ) !== false ) {
+ $_cur_string = preg_replace( ',\s+,', ' ', $_cur_string );
+ }
+ }*/
+ // phpcs:enable Squiz.PHP.CommentedOutCode.Found, Squiz.Commenting.BlockComment.NoNewLine
$this->sub_value .= $_cur_string;
- } elseif ($this->status === 'is') {
+ } elseif ( 'is' === $this->status ) {
$this->selector .= $_cur_string;
- } elseif ($this->status === 'instr') {
- $this->cur_string[count($this->cur_string)-1] .= $_cur_string;
+ } elseif ( 'instr' === $this->status ) {
+ $this->cur_string[ count( $this->cur_string ) - 1 ] .= $_cur_string;
}
- }
- else {
- $this->cur_string[count($this->cur_string)-1] = $_cur_string;
+ } else {
+ $this->cur_string[ count( $this->cur_string ) - 1 ] = $_cur_string;
}
break;
/* Case in-comment */
case 'ic':
- if ($string[$i] === '*' && $string[$i + 1] === '/') {
- $this->status = array_pop($this->from);
+ if ( '*' === $string[ $i ] && '/' === $string[ $i + 1 ] ) {
+ $this->status = array_pop( $this->from );
$i++;
- $this->_add_token(COMMENT, $cur_comment);
+ $this->_add_token( COMMENT, $cur_comment );
$cur_comment = '';
} else {
- $cur_comment .= $string[$i];
+ $cur_comment .= $string[ $i ];
}
break;
}
@@ -936,38 +987,39 @@ class csstidy {
$this->print->_reset();
- @setlocale(LC_ALL, $old); // Set locale back to original setting
+ @setlocale( LC_ALL, $old ); // Set locale back to original setting.
- return!(empty($this->css) && empty($this->import) && empty($this->charset) && empty($this->tokens) && empty($this->namespace));
+ return ! ( empty( $this->css ) && empty( $this->import ) && empty( $this->charset ) && empty( $this->tokens ) && empty( $this->namespace ) );
}
/**
* Explodes selectors
+ *
* @access private
* @version 1.0
*/
- function explode_selectors() {
- // Explode multiple selectors
- if ($this->get_cfg('merge_selectors') === 1) {
- $new_sels = array();
- $lastpos = 0;
- $this->sel_separate[] = strlen($this->selector);
- foreach ($this->sel_separate as $num => $pos) {
- if ($num == count($this->sel_separate) - 1) {
- $pos += 1;
+ public function explode_selectors() {
+ // Explode multiple selectors.
+ if ( $this->get_cfg( 'merge_selectors' ) === 1 ) {
+ $new_sels = array();
+ $lastpos = 0;
+ $this->sel_separate[] = strlen( $this->selector );
+ foreach ( $this->sel_separate as $num => $pos ) {
+ if ( count( $this->sel_separate ) - 1 === $num ) {
+ ++$pos;
}
- $new_sels[] = substr($this->selector, $lastpos, $pos - $lastpos - 1);
- $lastpos = $pos;
+ $new_sels[] = substr( $this->selector, $lastpos, $pos - $lastpos - 1 );
+ $lastpos = $pos;
}
- if (count($new_sels) > 1) {
- foreach ($new_sels as $selector) {
- if (isset($this->css[$this->at][$this->selector])) {
- $this->merge_css_blocks($this->at, $selector, $this->css[$this->at][$this->selector]);
+ if ( count( $new_sels ) > 1 ) {
+ foreach ( $new_sels as $selector ) {
+ if ( isset( $this->css[ $this->at ][ $this->selector ] ) ) {
+ $this->merge_css_blocks( $this->at, $selector, $this->css[ $this->at ][ $this->selector ] );
}
}
- unset($this->css[$this->at][$this->selector]);
+ unset( $this->css[ $this->at ][ $this->selector ] );
}
}
$this->sel_separate = array();
@@ -975,37 +1027,39 @@ class csstidy {
/**
* Checks if a character is escaped (and returns true if it is)
- * @param string $string
- * @param integer $pos
+ *
+ * @param string $string - the string.
+ * @param integer $pos - the position.
* @access public
* @return bool
* @version 1.02
*/
- static function escaped(&$string, $pos) {
- return!(@($string[$pos - 1] !== '\\') || csstidy::escaped($string, $pos - 1));
+ public static function escaped( &$string, $pos ) {
+ return ! ( @( '\\' !== $string[ $pos - 1 ] ) || self::escaped( $string, $pos - 1 ) );
}
/**
* Adds a property with value to the existing CSS code
- * @param string $media
- * @param string $selector
- * @param string $property
- * @param string $new_val
+ *
+ * @param string $media - the media.
+ * @param string $selector - the selector.
+ * @param string $property - the property.
+ * @param string $new_val - new value.
* @access private
* @version 1.2
*/
- function css_add_property($media, $selector, $property, $new_val) {
- if ($this->get_cfg('preserve_css') || trim($new_val) == '') {
+ public function css_add_property( $media, $selector, $property, $new_val ) {
+ if ( $this->get_cfg( 'preserve_css' ) || '' === trim( $new_val ) ) {
return;
}
$this->added = true;
- if (isset($this->css[$media][$selector][$property])) {
- if ((csstidy::is_important($this->css[$media][$selector][$property]) && csstidy::is_important($new_val)) || !csstidy::is_important($this->css[$media][$selector][$property])) {
- $this->css[$media][$selector][$property] = trim($new_val);
+ if ( isset( $this->css[ $media ][ $selector ][ $property ] ) ) {
+ if ( ( self::is_important( $this->css[ $media ][ $selector ][ $property ] ) && self::is_important( $new_val ) ) || ! self::is_important( $this->css[ $media ][ $selector ][ $property ] ) ) {
+ $this->css[ $media ][ $selector ][ $property ] = trim( $new_val );
}
} else {
- $this->css[$media][$selector][$property] = trim($new_val);
+ $this->css[ $media ][ $selector ][ $property ] = trim( $new_val );
}
}
@@ -1015,29 +1069,30 @@ class csstidy {
* else rename it with extra spaces
* to avoid merging
*
- * @param string $media
+ * @param string $media - the media.
* @return string
*/
- function css_new_media_section($media){
- if($this->get_cfg('preserve_css')) {
+ public function css_new_media_section( $media ) {
+ if ( $this->get_cfg( 'preserve_css' ) ) {
return $media;
}
- // if the last @media is the same as this
- // keep it
- if (!$this->css OR !is_array($this->css) OR empty($this->css)){
+ // if the last @media is the same as this keep it.
+ if ( ! $this->css || ! is_array( $this->css ) || empty( $this->css ) ) {
return $media;
}
- end($this->css);
+ end( $this->css );
$at = current( $this->css );
- if ($at == $media){
+ if ( $at === $media ) {
return $media;
}
- while (isset($this->css[$media]))
- if (is_numeric($media))
+ while ( isset( $this->css[ $media ] ) ) {
+ if ( is_numeric( $media ) ) {
$media++;
- else
- $media .= " ";
+ } else {
+ $media .= ' ';
+ }
+ }
return $media;
}
@@ -1048,34 +1103,37 @@ class csstidy {
* except if merging is required,
* or last selector is the same (merge siblings)
*
- * never merge @font-face
+ * Never merge @font-face
*
- * @param string $media
- * @param string $selector
+ * @param string $media - the media.
+ * @param string $selector - the selector.
* @return string
*/
- function css_new_selector($media,$selector){
- if($this->get_cfg('preserve_css')) {
+ public function css_new_selector( $media, $selector ) {
+ if ( $this->get_cfg( 'preserve_css' ) ) {
return $selector;
}
- $selector = trim($selector);
- if (strncmp($selector,"@font-face",10)!=0){
- if ($this->settings['merge_selectors'] != false)
+ $selector = trim( $selector );
+ if ( strncmp( $selector, '@font-face', 10 ) !== 0 ) {
+ if ( $this->settings['merge_selectors'] ) {
return $selector;
+ }
- if (!$this->css OR !isset($this->css[$media]) OR !$this->css[$media])
+ if ( ! $this->css || ! isset( $this->css[ $media ] ) || ! $this->css[ $media ] ) {
return $selector;
+ }
- // if last is the same, keep it
- end($this->css[$media]);
- $sel = current( $this->css[$media] );
- if ($sel == $selector){
+ // if last is the same, keep it.
+ end( $this->css[ $media ] );
+ $sel = current( $this->css[ $media ] );
+ if ( $sel === $selector ) {
return $selector;
}
}
- while (isset($this->css[$media][$selector]))
- $selector .= " ";
+ while ( isset( $this->css[ $media ][ $selector ] ) ) {
+ $selector .= ' ';
+ }
return $selector;
}
@@ -1084,63 +1142,68 @@ class csstidy {
* If already references in this selector,
* rename it with extra space to avoid override
*
- * @param string $media
- * @param string $selector
- * @param string $property
+ * @param string $media - the media.
+ * @param string $selector - the selector.
+ * @param string $property - the property.
* @return string
*/
- function css_new_property($media, $selector, $property){
- if($this->get_cfg('preserve_css')) {
+ public function css_new_property( $media, $selector, $property ) {
+ if ( $this->get_cfg( 'preserve_css' ) ) {
return $property;
}
- if (!$this->css OR !isset($this->css[$media][$selector]) OR !$this->css[$media][$selector])
+ if ( ! $this->css || ! isset( $this->css[ $media ][ $selector ] ) || ! $this->css[ $media ][ $selector ] ) {
return $property;
+ }
- while (isset($this->css[$media][$selector][$property]))
- $property .= " ";
+ while ( isset( $this->css[ $media ][ $selector ][ $property ] ) ) {
+ $property .= ' ';
+ }
return $property;
}
/**
* Adds CSS to an existing media/selector
- * @param string $media
- * @param string $selector
- * @param array $css_add
+ *
+ * @param string $media - the media.
+ * @param string $selector - the selector.
+ * @param array $css_add - css being added.
* @access private
* @version 1.1
*/
- function merge_css_blocks($media, $selector, $css_add) {
- foreach ($css_add as $property => $value) {
- $this->css_add_property($media, $selector, $property, $value, false);
+ public function merge_css_blocks( $media, $selector, $css_add ) {
+ foreach ( $css_add as $property => $value ) {
+ $this->css_add_property( $media, $selector, $property, $value, false );
}
}
/**
* Checks if $value is !important.
- * @param string $value
+ *
+ * @param string $value - the value.
* @return bool
* @access public
* @version 1.0
*/
- static function is_important(&$value) {
- return (!strcasecmp(substr(str_replace($GLOBALS['csstidy']['whitespace'], '', $value), -10, 10), '!important'));
+ public static function is_important( &$value ) {
+ return ( ! strcasecmp( substr( str_replace( $GLOBALS['csstidy']['whitespace'], '', $value ), -10, 10 ), '!important' ) );
}
/**
* Returns a value without !important
- * @param string $value
+ *
+ * @param string $value - the value.
* @return string
* @access public
* @version 1.0
*/
- static function gvw_important($value) {
- if (csstidy::is_important($value)) {
- $value = trim($value);
- $value = substr($value, 0, -9);
- $value = trim($value);
- $value = substr($value, 0, -1);
- $value = trim($value);
+ public static function gvw_important( $value ) {
+ if ( self::is_important( $value ) ) {
+ $value = trim( $value );
+ $value = substr( $value, 0, -9 );
+ $value = trim( $value );
+ $value = substr( $value, 0, -1 );
+ $value = trim( $value );
return $value;
}
return $value;
@@ -1148,22 +1211,23 @@ class csstidy {
/**
* Checks if the next word in a string from pos is a CSS property
- * @param string $istring
- * @param integer $pos
+ *
+ * @param string $istring - if it's a string.
+ * @param integer $pos - position.
* @return bool
* @access private
* @version 1.2
*/
- function property_is_next($istring, $pos) {
+ public function property_is_next( $istring, $pos ) {
$all_properties = & $GLOBALS['csstidy']['all_properties'];
- $istring = substr($istring, $pos, strlen($istring) - $pos);
- $pos = strpos($istring, ':');
- if ($pos === false) {
+ $istring = substr( $istring, $pos, strlen( $istring ) - $pos );
+ $pos = strpos( $istring, ':' );
+ if ( false === $pos ) {
return false;
}
- $istring = strtolower(trim(substr($istring, 0, $pos)));
- if (isset($all_properties[$istring])) {
- $this->log('Added semicolon to the end of declaration', 'Warning');
+ $istring = strtolower( trim( substr( $istring, 0, $pos ) ) );
+ if ( isset( $all_properties[ $istring ] ) ) {
+ $this->log( 'Added semicolon to the end of declaration', 'Warning' );
return true;
}
return false;
@@ -1171,75 +1235,75 @@ class csstidy {
/**
* Checks if a property is valid
- * @param string $property
+ *
+ * @param string $property - the property.
* @return bool;
* @access public
* @version 1.0
*/
- function property_is_valid($property) {
- $property = strtolower($property);
- if (in_array(trim($property), $GLOBALS['csstidy']['multiple_properties'])) $property = trim($property);
+ public function property_is_valid( $property ) {
+ $property = strtolower( $property );
+ if ( in_array( trim( $property ), $GLOBALS['csstidy']['multiple_properties'], true ) ) {
+ $property = trim( $property );
+ }
$all_properties = & $GLOBALS['csstidy']['all_properties'];
- return (isset($all_properties[$property]) && strpos($all_properties[$property], strtoupper($this->get_cfg('css_level'))) !== false );
+ return ( isset( $all_properties[ $property ] ) && strpos( $all_properties[ $property ], strtoupper( $this->get_cfg( 'css_level' ) ) ) !== false );
}
/**
* Accepts a list of strings (e.g., the argument to format() in a @font-face src property)
* and returns a list of the strings. Converts things like:
*
- * format(abc) => format("abc")
+ * Format(abc) => format("abc")
* format(abc def) => format("abc","def")
* format(abc "def") => format("abc","def")
* format(abc, def, ghi) => format("abc","def","ghi")
* format("abc",'def') => format("abc","def")
* format("abc, def, ghi") => format("abc, def, ghi")
*
- * @param string
+ * @param string $value - the value.
* @return array
*/
+ public function parse_string_list( $value ) {
+ $value = trim( $value );
- function parse_string_list($value) {
- $value = trim($value);
-
- // Case: empty
- if (!$value) return array();
+ // Case: if it's empty.
+ if ( ! $value ) {
+ return array();
+ }
$strings = array();
- $in_str = false;
- $current_string = "";
-
- for ($i = 0, $_len = strlen($value); $i < $_len; $i++) {
- if (($value[$i] == "," || $value[$i] === " ") && $in_str === true) {
- $in_str = false;
- $strings[] = $current_string;
- $current_string = "";
- }
- else if ($value[$i] == '"' || $value[$i] == "'"){
- if ($in_str === $value[$i]) {
- $strings[] = $current_string;
- $in_str = false;
- $current_string = "";
+ $in_str = false;
+ $current_string = '';
+
+ for ( $i = 0, $_len = strlen( $value ); $i < $_len; $i++ ) {
+ if ( ( ',' === $value[ $i ] || ' ' === $value[ $i ] ) && true === $in_str ) {
+ $in_str = false;
+ $strings[] = $current_string;
+ $current_string = '';
+ } elseif ( '"' === $value[ $i ] || "'" === $value[ $i ] ) {
+ if ( $in_str === $value[ $i ] ) {
+ $strings[] = $current_string;
+ $in_str = false;
+ $current_string = '';
continue;
+ } elseif ( ! $in_str ) {
+ $in_str = $value[ $i ];
}
- else if (!$in_str) {
- $in_str = $value[$i];
- }
- }
- else {
- if ($in_str){
- $current_string .= $value[$i];
- }
- else {
- if (!preg_match("/[\s,]/", $value[$i])) {
- $in_str = true;
- $current_string = $value[$i];
+ } else {
+ if ( $in_str ) {
+ $current_string .= $value[ $i ];
+ } else {
+ if ( ! preg_match( '/[\s,]/', $value[ $i ] ) ) {
+ $in_str = true;
+ $current_string = $value[ $i ];
}
}
}
}
- if ($current_string) {
+ if ( $current_string ) {
$strings[] = $current_string;
}
diff --git a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_optimise.php b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_optimise.php
deleted file mode 100644
index 5f4a3843..00000000
--- a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_optimise.php
+++ /dev/null
@@ -1,943 +0,0 @@
-<?php
-
-/**
- * CSSTidy - CSS Parser and Optimiser
- *
- * CSS Optimising Class
- * This class optimises CSS data generated by csstidy.
- *
- * Copyright 2005, 2006, 2007 Florian Schmitz
- *
- * This file is part of CSSTidy.
- *
- * CSSTidy is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * CSSTidy is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- * @license https://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
- * @package csstidy
- * @author Florian Schmitz (floele at gmail dot com) 2005-2007
- * @author Brett Zamir (brettz9 at yahoo dot com) 2007
- * @author Nikolay Matsievsky (speed at webo dot name) 2009-2010
- */
-
-/**
- * CSS Optimising Class
- *
- * This class optimises CSS data generated by csstidy.
- *
- * @package csstidy
- * @author Florian Schmitz (floele at gmail dot com) 2005-2006
- * @version 1.0
- */
-class csstidy_optimise {
- /**
- * Constructor
- * @param array $css contains the class csstidy
- * @access private
- * @version 1.0
- */
- function __construct(&$css) {
- $this->parser = & $css;
- $this->css = & $css->css;
- $this->sub_value = & $css->sub_value;
- $this->at = & $css->at;
- $this->selector = & $css->selector;
- $this->property = & $css->property;
- $this->value = & $css->value;
- }
-
- function csstidy_optimise(&$css) {
- $this->__construct($css);
- }
-
- /**
- * Optimises $css after parsing
- * @access public
- * @version 1.0
- */
- function postparse() {
- if ($this->parser->get_cfg('preserve_css')) {
- return;
- }
-
- if ($this->parser->get_cfg('merge_selectors') === 2) {
- foreach ($this->css as $medium => $value) {
- $this->merge_selectors($this->css[$medium]);
- }
- }
-
- if ($this->parser->get_cfg('discard_invalid_selectors')) {
- foreach ($this->css as $medium => $value) {
- $this->discard_invalid_selectors($this->css[$medium]);
- }
- }
-
- if ($this->parser->get_cfg('optimise_shorthands') > 0) {
- foreach ($this->css as $medium => $value) {
- foreach ($value as $selector => $value1) {
- $this->css[$medium][$selector] = csstidy_optimise::merge_4value_shorthands($this->css[$medium][$selector]);
-
- if ($this->parser->get_cfg('optimise_shorthands') < 2) {
- continue;
- }
-
- $this->css[$medium][$selector] = csstidy_optimise::merge_font($this->css[$medium][$selector]);
-
- if ($this->parser->get_cfg('optimise_shorthands') < 3) {
- continue;
- }
-
- $this->css[$medium][$selector] = csstidy_optimise::merge_bg($this->css[$medium][$selector]);
- if (empty($this->css[$medium][$selector])) {
- unset($this->css[$medium][$selector]);
- }
- }
- }
- }
- }
-
- /**
- * Optimises values
- * @access public
- * @version 1.0
- */
- function value() {
- $shorthands = & $GLOBALS['csstidy']['shorthands'];
-
- // optimise shorthand properties
- if (isset($shorthands[$this->property])) {
- $temp = csstidy_optimise::shorthand($this->value); // FIXME - move
- if ($temp != $this->value) {
- $this->parser->log('Optimised shorthand notation (' . $this->property . '): Changed "' . $this->value . '" to "' . $temp . '"', 'Information');
- }
- $this->value = $temp;
- }
-
- // Remove whitespace at ! important
- if ($this->value != $this->compress_important($this->value)) {
- $this->parser->log('Optimised !important', 'Information');
- }
- }
-
- /**
- * Optimises shorthands
- * @access public
- * @version 1.0
- */
- function shorthands() {
- $shorthands = & $GLOBALS['csstidy']['shorthands'];
-
- if (!$this->parser->get_cfg('optimise_shorthands') || $this->parser->get_cfg('preserve_css')) {
- return;
- }
-
- if ($this->property === 'font' && $this->parser->get_cfg('optimise_shorthands') > 1) {
- $this->css[$this->at][$this->selector]['font']='';
- $this->parser->merge_css_blocks($this->at, $this->selector, csstidy_optimise::dissolve_short_font($this->value));
- }
- if ($this->property === 'background' && $this->parser->get_cfg('optimise_shorthands') > 2) {
- $this->css[$this->at][$this->selector]['background']='';
- $this->parser->merge_css_blocks($this->at, $this->selector, csstidy_optimise::dissolve_short_bg($this->value));
- }
- if (isset($shorthands[$this->property])) {
- $this->parser->merge_css_blocks($this->at, $this->selector, csstidy_optimise::dissolve_4value_shorthands($this->property, $this->value));
- if (is_array($shorthands[$this->property])) {
- $this->css[$this->at][$this->selector][$this->property] = '';
- }
- }
- }
-
- /**
- * Optimises a sub-value
- * @access public
- * @version 1.0
- */
- function subvalue() {
- $replace_colors = & $GLOBALS['csstidy']['replace_colors'];
-
- $this->sub_value = trim($this->sub_value);
- if ($this->sub_value == '') { // caution : '0'
- return;
- }
-
- $important = '';
- if (csstidy::is_important($this->sub_value)) {
- $important = '!important';
- }
- $this->sub_value = csstidy::gvw_important($this->sub_value);
-
- // Compress font-weight
- if ($this->property === 'font-weight' && $this->parser->get_cfg('compress_font-weight')) {
- if ($this->sub_value === 'bold') {
- $this->sub_value = '700';
- $this->parser->log('Optimised font-weight: Changed "bold" to "700"', 'Information');
- } else if ($this->sub_value === 'normal') {
- $this->sub_value = '400';
- $this->parser->log('Optimised font-weight: Changed "normal" to "400"', 'Information');
- }
- }
-
- $temp = $this->compress_numbers($this->sub_value);
- if (strcasecmp($temp, $this->sub_value) !== 0) {
- if (strlen($temp) > strlen($this->sub_value)) {
- $this->parser->log('Fixed invalid number: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Warning');
- } else {
- $this->parser->log('Optimised number: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Information');
- }
- $this->sub_value = $temp;
- }
- if ($this->parser->get_cfg('compress_colors')) {
- $temp = $this->cut_color($this->sub_value);
- if ($temp !== $this->sub_value) {
- if (isset($replace_colors[$this->sub_value])) {
- $this->parser->log('Fixed invalid color name: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Warning');
- } else {
- $this->parser->log('Optimised color: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Information');
- }
- $this->sub_value = $temp;
- }
- }
- $this->sub_value .= $important;
- }
-
- /**
- * Compresses shorthand values. Example: margin:1px 1px 1px 1px -> margin:1px
- * @param string $value
- * @access public
- * @return string
- * @version 1.0
- */
- static function shorthand($value) {
- $important = '';
- if (csstidy::is_important($value)) {
- $values = csstidy::gvw_important($value);
- $important = '!important';
- }
- else
- $values = $value;
-
- $values = explode(' ', $values);
- switch (count($values)) {
- case 4:
- if ($values[0] == $values[1] && $values[0] == $values[2] && $values[0] == $values[3]) {
- return $values[0] . $important;
- } elseif ($values[1] == $values[3] && $values[0] == $values[2]) {
- return $values[0] . ' ' . $values[1] . $important;
- } elseif ($values[1] == $values[3]) {
- return $values[0] . ' ' . $values[1] . ' ' . $values[2] . $important;
- }
- break;
-
- case 3:
- if ($values[0] == $values[1] && $values[0] == $values[2]) {
- return $values[0] . $important;
- } elseif ($values[0] == $values[2]) {
- return $values[0] . ' ' . $values[1] . $important;
- }
- break;
-
- case 2:
- if ($values[0] == $values[1]) {
- return $values[0] . $important;
- }
- break;
- }
-
- return $value;
- }
-
- /**
- * Removes unnecessary whitespace in ! important
- * @param string $string
- * @return string
- * @access public
- * @version 1.1
- */
- function compress_important(&$string) {
- if (csstidy::is_important($string)) {
- $string = csstidy::gvw_important($string) . ' !important'; }
- return $string;
- }
-
- /**
- * Color compression function. Converts all rgb() values to #-values and uses the short-form if possible. Also replaces 4 color names by #-values.
- * @param string $color
- * @return string
- * @version 1.1
- */
- function cut_color($color) {
- $replace_colors = & $GLOBALS['csstidy']['replace_colors'];
-
- // rgb(0,0,0) -> #000000 (or #000 in this case later)
- if (strtolower(substr($color, 0, 4)) === 'rgb(') {
- $color_tmp = substr($color, 4, strlen($color) - 5);
- $color_tmp = explode(',', $color_tmp);
- for ($i = 0; $i < count($color_tmp); $i++) {
- $color_tmp[$i] = trim($color_tmp[$i]);
- if (substr($color_tmp[$i], -1) === '%') {
- $color_tmp[$i] = round((255 * $color_tmp[$i]) / 100);
- }
- if ($color_tmp[$i] > 255)
- $color_tmp[$i] = 255;
- }
- $color = '#';
- for ($i = 0; $i < 3; $i++) {
- if ($color_tmp[$i] < 16) {
- $color .= '0' . dechex($color_tmp[$i]);
- } else {
- $color .= dechex($color_tmp[$i]);
- }
- }
- }
-
- // Fix bad color names
- if (isset($replace_colors[strtolower($color)])) {
- $color = $replace_colors[strtolower($color)];
- }
-
- // #aabbcc -> #abc
- if (strlen($color) == 7) {
- $color_temp = strtolower($color);
- if ($color_temp[0] === '#' && $color_temp[1] == $color_temp[2] && $color_temp[3] == $color_temp[4] && $color_temp[5] == $color_temp[6]) {
- $color = '#' . $color[1] . $color[3] . $color[5];
- }
- }
-
- switch (strtolower($color)) {
- /* color name -> hex code */
- case 'black': return '#000';
- case 'fuchsia': return '#f0f';
- case 'white': return '#fff';
- case 'yellow': return '#ff0';
-
- /* hex code -> color name */
- case '#800000': return 'maroon';
- case '#ffa500': return 'orange';
- case '#808000': return 'olive';
- case '#800080': return 'purple';
- case '#008000': return 'green';
- case '#000080': return 'navy';
- case '#008080': return 'teal';
- case '#c0c0c0': return 'silver';
- case '#808080': return 'gray';
- case '#f00': return 'red';
- }
-
- return $color;
- }
-
- /**
- * Compresses numbers (ie. 1.0 becomes 1 or 1.100 becomes 1.1 )
- * @param string $subvalue
- * @return string
- * @version 1.2
- */
- function compress_numbers($subvalue) {
- $unit_values = & $GLOBALS['csstidy']['unit_values'];
- $color_values = & $GLOBALS['csstidy']['color_values'];
-
- // for font:1em/1em sans-serif...;
- if ($this->property === 'font') {
- $temp = explode('/', $subvalue);
- } else {
- $temp = array($subvalue);
- }
- for ($l = 0; $l < count($temp); $l++) {
- // if we are not dealing with a number at this point, do not optimise anything
- $number = $this->AnalyseCssNumber($temp[$l]);
- if ($number === false) {
- return $subvalue;
- }
-
- // Fix bad colors
- if (in_array($this->property, $color_values)) {
- if (strlen($temp[$l]) == 3 || strlen($temp[$l]) == 6) {
- $temp[$l] = '#' . $temp[$l];
- }
- else {
- $temp[$l] = "0";
- }
- continue;
- }
-
- if (abs($number[0]) > 0) {
- if ($number[1] == '' && in_array($this->property, $unit_values, true)) {
- $number[1] = 'px';
- }
- } else {
- $number[1] = '';
- }
-
- $temp[$l] = $number[0] . $number[1];
- }
-
- return ((count($temp) > 1) ? $temp[0] . '/' . $temp[1] : $temp[0]);
- }
-
- /**
- * Checks if a given string is a CSS valid number. If it is,
- * an array containing the value and unit is returned
- * @param string $string
- * @return array ('unit' if unit is found or '' if no unit exists, number value) or false if no number
- */
- function AnalyseCssNumber($string) {
- // most simple checks first
- if (strlen($string) == 0 || ctype_alpha($string[0])) {
- return false;
- }
-
- $units = & $GLOBALS['csstidy']['units'];
- $return = array(0, '');
-
- $return[0] = (float) $string;
- if (abs($return[0]) > 0 && abs($return[0]) < 1) {
- // Removes the initial `0` from a decimal number, e.g., `0.7 => .7` or `-0.666 => -.666`.
- if ( ! $this->parser->get_cfg( 'preserve_leading_zeros' ) ) {
- if ( $return[0] < 0 ) {
- $return[0] = '-' . ltrim( substr( $return[0], 1 ), '0' );
- } else {
- $return[0] = ltrim( $return[0], '0' );
- }
- }
- }
-
- // Look for unit and split from value if exists
- foreach ($units as $unit) {
- $expectUnitAt = strlen($string) - strlen($unit);
- if (!($unitInString = stristr($string, $unit))) { // mb_strpos() fails with "false"
- continue;
- }
- $actualPosition = strpos($string, $unitInString);
- if ($expectUnitAt === $actualPosition) {
- $return[1] = $unit;
- $string = substr($string, 0, - strlen($unit));
- break;
- }
- }
- if (!is_numeric($string)) {
- return false;
- }
- return $return;
- }
-
- /**
- * Merges selectors with same properties. Example: a{color:red} b{color:red} -> a,b{color:red}
- * Very basic and has at least one bug. Hopefully there is a replacement soon.
- * @param array $array
- * @return array
- * @access public
- * @version 1.2
- */
- function merge_selectors(&$array) {
- $css = $array;
- foreach ($css as $key => $value) {
- if (!isset($css[$key])) {
- continue;
- }
- $newsel = '';
-
- // Check if properties also exist in another selector
- $keys = array();
- // PHP bug (?) without $css = $array; here
- foreach ($css as $selector => $vali) {
- if ($selector == $key) {
- continue;
- }
-
- if ($css[$key] === $vali) {
- $keys[] = $selector;
- }
- }
-
- if (!empty($keys)) {
- $newsel = $key;
- unset($css[$key]);
- foreach ($keys as $selector) {
- unset($css[$selector]);
- $newsel .= ',' . $selector;
- }
- $css[$newsel] = $value;
- }
- }
- $array = $css;
- }
-
- /**
- * Removes invalid selectors and their corresponding rule-sets as
- * defined by 4.1.7 in REC-CSS2. This is a very rudimentary check
- * and should be replaced by a full-blown parsing algorithm or
- * regular expression
- * @version 1.4
- */
- function discard_invalid_selectors(&$array) {
- $invalid = array('+' => true, '~' => true, ',' => true, '>' => true);
- foreach ($array as $selector => $decls) {
- $ok = true;
- $selectors = array_map('trim', explode(',', $selector));
- foreach ($selectors as $s) {
- $simple_selectors = preg_split('/\s*[+>~\s]\s*/', $s);
- foreach ($simple_selectors as $ss) {
- if ($ss === '')
- $ok = false;
- // could also check $ss for internal structure,
- // but that probably would be too slow
- }
- }
- if (!$ok)
- unset($array[$selector]);
- }
- }
-
- /**
- * Dissolves properties like padding:10px 10px 10px to padding-top:10px;padding-bottom:10px;...
- * @param string $property
- * @param string $value
- * @return array
- * @version 1.0
- * @see merge_4value_shorthands()
- */
- static function dissolve_4value_shorthands($property, $value) {
- $shorthands = & $GLOBALS['csstidy']['shorthands'];
- if (!is_array($shorthands[$property])) {
- $return[$property] = $value;
- return $return;
- }
-
- $important = '';
- if (csstidy::is_important($value)) {
- $value = csstidy::gvw_important($value);
- $important = '!important';
- }
- $values = explode(' ', $value);
-
-
- $return = array();
- if (count($values) == 4) {
- for ($i = 0; $i < 4; $i++) {
- $return[$shorthands[$property][$i]] = $values[$i] . $important;
- }
- } elseif (count($values) == 3) {
- $return[$shorthands[$property][0]] = $values[0] . $important;
- $return[$shorthands[$property][1]] = $values[1] . $important;
- $return[$shorthands[$property][3]] = $values[1] . $important;
- $return[$shorthands[$property][2]] = $values[2] . $important;
- } elseif (count($values) == 2) {
- for ($i = 0; $i < 4; $i++) {
- $return[$shorthands[$property][$i]] = (($i % 2 != 0)) ? $values[1] . $important : $values[0] . $important;
- }
- } else {
- for ($i = 0; $i < 4; $i++) {
- $return[$shorthands[$property][$i]] = $values[0] . $important;
- }
- }
-
- return $return;
- }
-
- /**
- * Explodes a string as explode() does, however, not if $sep is escaped or within a string.
- * @param string $sep seperator
- * @param string $string
- * @return array
- * @version 1.0
- */
- static function explode_ws($sep, $string) {
- $status = 'st';
- $to = '';
-
- $output = array();
- $num = 0;
- for ($i = 0, $len = strlen($string); $i < $len; $i++) {
- switch ($status) {
- case 'st':
- if ($string[$i] == $sep && !csstidy::escaped($string, $i)) {
- ++$num;
- } elseif ($string[$i] === '"' || $string[$i] === '\'' || $string[$i] === '(' && !csstidy::escaped($string, $i)) {
- $status = 'str';
- $to = ($string[$i] === '(') ? ')' : $string[$i];
- (isset($output[$num])) ? $output[$num] .= $string[$i] : $output[$num] = $string[$i];
- } else {
- (isset($output[$num])) ? $output[$num] .= $string[$i] : $output[$num] = $string[$i];
- }
- break;
-
- case 'str':
- if ($string[$i] == $to && !csstidy::escaped($string, $i)) {
- $status = 'st';
- }
- (isset($output[$num])) ? $output[$num] .= $string[$i] : $output[$num] = $string[$i];
- break;
- }
- }
-
- if (isset($output[0])) {
- return $output;
- } else {
- return array($output);
- }
- }
-
- /**
- * Merges Shorthand properties again, the opposite of dissolve_4value_shorthands()
- * @param array $array
- * @return array
- * @version 1.2
- * @see dissolve_4value_shorthands()
- */
- static function merge_4value_shorthands($array) {
- $return = $array;
- $shorthands = & $GLOBALS['csstidy']['shorthands'];
-
- foreach ($shorthands as $key => $value) {
- if (isset($array[$value[0]]) && isset($array[$value[1]])
- && isset($array[$value[2]]) && isset($array[$value[3]]) && $value !== 0) {
- $return[$key] = '';
-
- $important = '';
- for ($i = 0; $i < 4; $i++) {
- $val = $array[$value[$i]];
- if (csstidy::is_important($val)) {
- $important = '!important';
- $return[$key] .= csstidy::gvw_important($val) . ' ';
- } else {
- $return[$key] .= $val . ' ';
- }
- unset($return[$value[$i]]);
- }
- $return[$key] = csstidy_optimise::shorthand(trim($return[$key] . $important));
- }
- }
- return $return;
- }
-
- /**
- * Dissolve background property
- * @param string $str_value
- * @return array
- * @version 1.0
- * @see merge_bg()
- * @todo full CSS 3 compliance
- */
- static function dissolve_short_bg($str_value) {
- $have = array();
- // don't try to explose background gradient !
- if (stripos($str_value, "gradient(")!==FALSE)
- return array('background'=>$str_value);
-
- $background_prop_default = & $GLOBALS['csstidy']['background_prop_default'];
- $repeat = array('repeat', 'repeat-x', 'repeat-y', 'no-repeat', 'space');
- $attachment = array('scroll', 'fixed', 'local');
- $clip = array('border', 'padding');
- $origin = array('border', 'padding', 'content');
- $pos = array('top', 'center', 'bottom', 'left', 'right');
- $important = '';
- $return = array('background-image' => null, 'background-size' => null, 'background-repeat' => null, 'background-position' => null, 'background-attachment' => null, 'background-clip' => null, 'background-origin' => null, 'background-color' => null);
-
- if (csstidy::is_important($str_value)) {
- $important = ' !important';
- $str_value = csstidy::gvw_important($str_value);
- }
-
- $str_value = csstidy_optimise::explode_ws(',', $str_value);
- for ($i = 0; $i < count($str_value); $i++) {
- $have['clip'] = false;
- $have['pos'] = false;
- $have['color'] = false;
- $have['bg'] = false;
-
- if (is_array($str_value[$i])) {
- $str_value[$i] = $str_value[$i][0];
- }
- $str_value[$i] = csstidy_optimise::explode_ws(' ', trim($str_value[$i]));
-
- for ($j = 0; $j < count($str_value[$i]); $j++) {
- if ($have['bg'] === false && (substr($str_value[$i][$j], 0, 4) === 'url(' || $str_value[$i][$j] === 'none')) {
- $return['background-image'] .= $str_value[$i][$j] . ',';
- $have['bg'] = true;
- } elseif (in_array($str_value[$i][$j], $repeat, true)) {
- $return['background-repeat'] .= $str_value[$i][$j] . ',';
- } elseif (in_array($str_value[$i][$j], $attachment, true)) {
- $return['background-attachment'] .= $str_value[$i][$j] . ',';
- } elseif (in_array($str_value[$i][$j], $clip, true) && !$have['clip']) {
- $return['background-clip'] .= $str_value[$i][$j] . ',';
- $have['clip'] = true;
- } elseif (in_array($str_value[$i][$j], $origin, true)) {
- $return['background-origin'] .= $str_value[$i][$j] . ',';
- } elseif ($str_value[$i][$j][0] === '(') {
- $return['background-size'] .= substr($str_value[$i][$j], 1, -1) . ',';
- } elseif (in_array($str_value[$i][$j], $pos, true) || is_numeric($str_value[$i][$j][0]) || $str_value[$i][$j][0] === null || $str_value[$i][$j][0] === '-' || $str_value[$i][$j][0] === '.') {
- $return['background-position'] .= $str_value[$i][$j];
- if (!$have['pos'])
- $return['background-position'] .= ' '; else
- $return['background-position'].= ',';
- $have['pos'] = true;
- }
- elseif (!$have['color']) {
- $return['background-color'] .= $str_value[$i][$j] . ',';
- $have['color'] = true;
- }
- }
- }
-
- foreach ($background_prop_default as $bg_prop => $default_value) {
- if ($return[$bg_prop] !== null) {
- $return[$bg_prop] = substr($return[$bg_prop], 0, -1) . $important;
- }
- else
- $return[$bg_prop] = $default_value . $important;
- }
- return $return;
- }
-
- /**
- * Merges all background properties
- * @param array $input_css
- * @return array
- * @version 1.0
- * @see dissolve_short_bg()
- * @todo full CSS 3 compliance
- */
- static function merge_bg($input_css) {
- $background_prop_default = & $GLOBALS['csstidy']['background_prop_default'];
- // Max number of background images. CSS3 not yet fully implemented
- $number_of_values = @max(count(csstidy_optimise::explode_ws(',', $input_css['background-image'])), count(csstidy_optimise::explode_ws(',', $input_css['background-color'])), 1);
- // Array with background images to check if BG image exists
- $bg_img_array = @csstidy_optimise::explode_ws(',', csstidy::gvw_important($input_css['background-image']));
- $new_bg_value = '';
- $important = '';
-
- // if background properties is here and not empty, don't try anything
- if (isset($input_css['background']) AND $input_css['background'])
- return $input_css;
-
- for ($i = 0; $i < $number_of_values; $i++) {
- foreach ($background_prop_default as $bg_property => $default_value) {
- // Skip if property does not exist
- if (!isset($input_css[$bg_property])) {
- continue;
- }
-
- $cur_value = $input_css[$bg_property];
- // skip all optimisation if gradient() somewhere
- if (stripos($cur_value, "gradient(")!==FALSE)
- return $input_css;
-
- // Skip some properties if there is no background image
- if ((!isset($bg_img_array[$i]) || $bg_img_array[$i] === 'none')
- && ($bg_property === 'background-size' || $bg_property === 'background-position'
- || $bg_property === 'background-attachment' || $bg_property === 'background-repeat')) {
- continue;
- }
-
- // Remove !important
- if (csstidy::is_important($cur_value)) {
- $important = ' !important';
- $cur_value = csstidy::gvw_important($cur_value);
- }
-
- // Do not add default values
- if ($cur_value === $default_value) {
- continue;
- }
-
- $temp = csstidy_optimise::explode_ws(',', $cur_value);
-
- if (isset($temp[$i])) {
- if ($bg_property === 'background-size') {
- $new_bg_value .= '(' . $temp[$i] . ') ';
- } else {
- $new_bg_value .= $temp[$i] . ' ';
- }
- }
- }
-
- $new_bg_value = trim($new_bg_value);
- if ($i != $number_of_values - 1)
- $new_bg_value .= ',';
- }
-
- // Delete all background-properties
- foreach ($background_prop_default as $bg_property => $default_value) {
- unset($input_css[$bg_property]);
- }
-
- // Add new background property
- if ($new_bg_value !== '')
- $input_css['background'] = $new_bg_value . $important;
- elseif(isset ($input_css['background']))
- $input_css['background'] = 'none';
-
- return $input_css;
- }
-
- /**
- * Dissolve font property
- * @param string $str_value
- * @return array
- * @version 1.3
- * @see merge_font()
- */
- static function dissolve_short_font($str_value) {
- $have = array();
- $font_prop_default = & $GLOBALS['csstidy']['font_prop_default'];
- $font_weight = array('normal', 'bold', 'bolder', 'lighter', 100, 200, 300, 400, 500, 600, 700, 800, 900);
- $font_variant = array('normal', 'small-caps');
- $font_style = array('normal', 'italic', 'oblique');
- $important = '';
- $return = array('font-style' => null, 'font-variant' => null, 'font-weight' => null, 'font-size' => null, 'line-height' => null, 'font-family' => null);
-
- if (csstidy::is_important($str_value)) {
- $important = '!important';
- $str_value = csstidy::gvw_important($str_value);
- }
-
- $have['style'] = false;
- $have['variant'] = false;
- $have['weight'] = false;
- $have['size'] = false;
- // Detects if font-family consists of several words w/o quotes
- $multiwords = false;
-
- // Workaround with multiple font-family
- $str_value = csstidy_optimise::explode_ws(',', trim($str_value));
-
- $str_value[0] = csstidy_optimise::explode_ws(' ', trim($str_value[0]));
-
- for ($j = 0; $j < count($str_value[0]); $j++) {
- if ($have['weight'] === false && in_array($str_value[0][$j], $font_weight)) {
- $return['font-weight'] = $str_value[0][$j];
- $have['weight'] = true;
- } elseif ($have['variant'] === false && in_array($str_value[0][$j], $font_variant)) {
- $return['font-variant'] = $str_value[0][$j];
- $have['variant'] = true;
- } elseif ($have['style'] === false && in_array($str_value[0][$j], $font_style)) {
- $return['font-style'] = $str_value[0][$j];
- $have['style'] = true;
- } elseif ($have['size'] === false && (is_numeric($str_value[0][$j][0]) || $str_value[0][$j][0] === null || $str_value[0][$j][0] === '.')) {
- $size = csstidy_optimise::explode_ws('/', trim($str_value[0][$j]));
- $return['font-size'] = $size[0];
- if (isset($size[1])) {
- $return['line-height'] = $size[1];
- } else {
- $return['line-height'] = ''; // don't add 'normal' !
- }
- $have['size'] = true;
- } else {
- if (isset($return['font-family'])) {
- $return['font-family'] .= ' ' . $str_value[0][$j];
- $multiwords = true;
- } else {
- $return['font-family'] = $str_value[0][$j];
- }
- }
- }
- // add quotes if we have several qords in font-family
- if ($multiwords !== false) {
- $return['font-family'] = '"' . $return['font-family'] . '"';
- }
- $i = 1;
- while (isset($str_value[$i])) {
- $return['font-family'] .= ',' . trim($str_value[$i]);
- $i++;
- }
-
- // Fix for 100 and more font-size
- if ($have['size'] === false && isset($return['font-weight']) &&
- is_numeric($return['font-weight'][0])) {
- $return['font-size'] = $return['font-weight'];
- unset($return['font-weight']);
- }
-
- foreach ($font_prop_default as $font_prop => $default_value) {
- if ($return[$font_prop] !== null) {
- $return[$font_prop] = $return[$font_prop] . $important;
- }
- else
- $return[$font_prop] = $default_value . $important;
- }
- return $return;
- }
-
- /**
- * Merges all fonts properties
- * @param array $input_css
- * @return array
- * @version 1.3
- * @see dissolve_short_font()
- */
- static function merge_font($input_css) {
- $font_prop_default = & $GLOBALS['csstidy']['font_prop_default'];
- $new_font_value = '';
- $important = '';
- // Skip if not font-family and font-size set
- if (isset($input_css['font-family']) && isset($input_css['font-size'])) {
- // fix several words in font-family - add quotes
- if (isset($input_css['font-family'])) {
- $families = explode(",", $input_css['font-family']);
- $result_families = array();
- foreach ($families as $family) {
- $family = trim($family);
- $len = strlen($family);
- if (strpos($family, " ") &&
- !(($family[0] == '"' && $family[$len - 1] == '"') ||
- ($family[0] == "'" && $family[$len - 1] == "'"))) {
- $family = '"' . $family . '"';
- }
- $result_families[] = $family;
- }
- $input_css['font-family'] = implode(",", $result_families);
- }
- foreach ($font_prop_default as $font_property => $default_value) {
-
- // Skip if property does not exist
- if (!isset($input_css[$font_property])) {
- continue;
- }
-
- $cur_value = $input_css[$font_property];
-
- // Skip if default value is used
- if ($cur_value === $default_value) {
- continue;
- }
-
- // Remove !important
- if (csstidy::is_important($cur_value)) {
- $important = '!important';
- $cur_value = csstidy::gvw_important($cur_value);
- }
-
- $new_font_value .= $cur_value;
- // Add delimiter
- $new_font_value .= ( $font_property === 'font-size' &&
- isset($input_css['line-height'])) ? '/' : ' ';
- }
-
- $new_font_value = trim($new_font_value);
-
- // Delete all font-properties
- foreach ($font_prop_default as $font_property => $default_value) {
- if ($font_property!=='font' OR !$new_font_value)
- unset($input_css[$font_property]);
- }
-
- // Add new font property
- if ($new_font_value !== '') {
- $input_css['font'] = $new_font_value . $important;
- }
- }
-
- return $input_css;
- }
-
-}
diff --git a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_print.php b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_print.php
deleted file mode 100644
index 80b6c990..00000000
--- a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_print.php
+++ /dev/null
@@ -1,410 +0,0 @@
-<?php
-/**
- * CSSTidy - CSS Parser and Optimiser
- *
- * CSS Printing class
- * This class prints CSS data generated by csstidy.
- *
- * Copyright 2005, 2006, 2007 Florian Schmitz
- *
- * This file is part of CSSTidy.
- *
- * CSSTidy is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * CSSTidy is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- * @license https://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
- * @package csstidy
- * @author Florian Schmitz (floele at gmail dot com) 2005-2007
- * @author Brett Zamir (brettz9 at yahoo dot com) 2007
- * @author Cedric Morin (cedric at yterium dot com) 2010
- */
-
-/**
- * CSS Printing class
- *
- * This class prints CSS data generated by csstidy.
- *
- * @package csstidy
- * @author Florian Schmitz (floele at gmail dot com) 2005-2006
- * @version 1.0.1
- */
-class csstidy_print {
-
- /**
- * Saves the input CSS string
- * @var string
- * @access private
- */
- public $input_css = '';
- /**
- * Saves the formatted CSS string
- * @var string
- * @access public
- */
- public $output_css = '';
- /**
- * Saves the formatted CSS string (plain text)
- * @var string
- * @access public
- */
- public $output_css_plain = '';
-
- /**
- * Constructor
- * @param array $css contains the class csstidy
- * @access private
- * @version 1.0
- */
- function __construct(&$css) {
- $this->parser = & $css;
- $this->css = & $css->css;
- $this->template = & $css->template;
- $this->tokens = & $css->tokens;
- $this->charset = & $css->charset;
- $this->import = & $css->import;
- $this->namespace = & $css->namespace;
- }
-
- function csstidy_print(&$css) {
- $this->__construct($css);
- }
-
- /**
- * Resets output_css and output_css_plain (new css code)
- * @access private
- * @version 1.0
- */
- function _reset() {
- $this->output_css = '';
- $this->output_css_plain = '';
- }
-
- /**
- * Returns the CSS code as plain text
- * @param string $default_media default @media to add to selectors without any @media
- * @return string
- * @access public
- * @version 1.0
- */
- function plain($default_media='') {
- $this->_print(true, $default_media);
- return $this->output_css_plain;
- }
-
- /**
- * Returns the formatted CSS code
- * @param string $default_media default @media to add to selectors without any @media
- * @return string
- * @access public
- * @version 1.0
- */
- function formatted($default_media='') {
- $this->_print(false, $default_media);
- return $this->output_css;
- }
-
- /**
- * Returns the formatted CSS code to make a complete webpage
- * @param string $doctype shorthand for the document type
- * @param bool $externalcss indicates whether styles to be attached internally or as an external stylesheet
- * @param string $title title to be added in the head of the document
- * @param string $lang two-letter language code to be added to the output
- * @return string
- * @access public
- * @version 1.4
- */
- function formatted_page($doctype='xhtml1.1', $externalcss=true, $title='', $lang='en') {
- switch ($doctype) {
- case 'xhtml1.0strict':
- $doctype_output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
- break;
- case 'xhtml1.1':
- default:
- $doctype_output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
- "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
- break;
- }
-
- $output = $cssparsed = '';
- $this->output_css_plain = & $output;
-
- $output .= $doctype_output . "\n" . '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $lang . '"';
- $output .= ( $doctype === 'xhtml1.1') ? '>' : ' lang="' . $lang . '">';
- $output .= "\n<head>\n <title>$title</title>";
-
- if ($externalcss) {
- $output .= "\n <style type=\"text/css\">\n";
- $cssparsed = file_get_contents('cssparsed.css');
- $output .= $cssparsed; // Adds an invisible BOM or something, but not in css_optimised.php
- $output .= "\n</style>";
- } else {
- $output .= "\n" . ' <link rel="stylesheet" type="text/css" href="cssparsed.css" />';
-// }
- }
- $output .= "\n</head>\n<body><code id=\"copytext\">";
- $output .= $this->formatted();
- $output .= '</code>' . "\n" . '</body></html>';
- return $this->output_css_plain;
- }
-
- /**
- * Returns the formatted CSS Code and saves it into $this->output_css and $this->output_css_plain
- * @param bool $plain plain text or not
- * @param string $default_media default @media to add to selectors without any @media
- * @access private
- * @version 2.0
- */
- function _print($plain = false, $default_media='') {
- if ($this->output_css && $this->output_css_plain) {
- return;
- }
-
- $output = '';
- if (!$this->parser->get_cfg('preserve_css')) {
- $this->_convert_raw_css($default_media);
- }
-
- $template = & $this->template;
-
- if ($plain) {
- $template = array_map('strip_tags', $template);
- }
-
- if ($this->parser->get_cfg('timestamp')) {
- array_unshift($this->tokens, array(COMMENT, ' CSSTidy ' . $this->parser->version . ': ' . date('r') . ' '));
- }
-
- if (!empty($this->charset)) {
- $output .= $template[0] . '@charset ' . $template[5] . $this->charset . $template[6];
- }
-
- if (!empty($this->import)) {
- for ($i = 0, $size = count($this->import); $i < $size; $i++) {
- $import_components = explode(' ', $this->import[$i]);
- if (substr($import_components[0], 0, 4) === 'url(' && substr($import_components[0], -1, 1) === ')') {
- $import_components[0] = '\'' . trim(substr($import_components[0], 4, -1), "'\"") . '\'';
- $this->import[$i] = implode(' ', $import_components);
- $this->parser->log('Optimised @import : Removed "url("', 'Information');
- }
- $output .= $template[0] . '@import ' . $template[5] . $this->import[$i] . $template[6];
- }
- }
- if (!empty($this->namespace)) {
- if (substr($this->namespace, 0, 4) === 'url(' && substr($this->namespace, -1, 1) === ')') {
- $this->namespace = '\'' . substr($this->namespace, 4, -1) . '\'';
- $this->parser->log('Optimised @namespace : Removed "url("', 'Information');
- }
- $output .= $template[0] . '@namespace ' . $template[5] . $this->namespace . $template[6];
- }
-
- $output .= $template[13];
- $in_at_out = '';
- $out = & $output;
-
- foreach ($this->tokens as $key => $token) {
- switch ($token[0]) {
- case AT_START:
- $out .= $template[0] . $this->_htmlsp($token[1], $plain) . $template[1];
- $out = & $in_at_out;
- break;
-
- case SEL_START:
- if ($this->parser->get_cfg('lowercase_s'))
- $token[1] = strtolower($token[1]);
- $out .= ( $token[1][0] !== '@') ? $template[2] . $this->_htmlsp($token[1], $plain) : $template[0] . $this->_htmlsp($token[1], $plain);
- $out .= $template[3];
- break;
-
- case PROPERTY:
- if ($this->parser->get_cfg('case_properties') === 2) {
- $token[1] = strtoupper($token[1]);
- } elseif ($this->parser->get_cfg('case_properties') === 1) {
- $token[1] = strtolower($token[1]);
- }
- $out .= $template[4] . $this->_htmlsp($token[1], $plain) . ':' . $template[5];
- break;
-
- case VALUE:
- $out .= $this->_htmlsp($token[1], $plain);
- if ($this->_seeknocomment($key, 1) == SEL_END && $this->parser->get_cfg('remove_last_;')) {
- $out .= str_replace(';', '', $template[6]);
- } else {
- $out .= $template[6];
- }
- break;
-
- case SEL_END:
- $out .= $template[7];
- if ($this->_seeknocomment($key, 1) != AT_END)
- $out .= $template[8];
- break;
-
- case AT_END:
- $out = & $output;
- $out .= $template[10] . str_replace("\n", "\n" . $template[10], $in_at_out);
- $in_at_out = '';
- $out .= $template[9];
- break;
-
- case COMMENT:
- $out .= $template[11] . '/*' . $this->_htmlsp($token[1], $plain) . '*/' . $template[12];
- break;
- }
- }
-
- $output = trim($output);
-
- if (!$plain) {
- $this->output_css = $output;
- $this->_print(true);
- } else {
- // If using spaces in the template, don't want these to appear in the plain output
- $this->output_css_plain = str_replace('&#160;', '', $output);
- }
- }
-
- /**
- * Gets the next token type which is $move away from $key, excluding comments
- * @param integer $key current position
- * @param integer $move move this far
- * @return mixed a token type
- * @access private
- * @version 1.0
- */
- function _seeknocomment($key, $move) {
- $go = ($move > 0) ? 1 : -1;
- for ($i = $key + 1; abs($key - $i) - 1 < abs($move); $i += $go) {
- if (!isset($this->tokens[$i])) {
- return;
- }
- if ($this->tokens[$i][0] == COMMENT) {
- $move += 1;
- continue;
- }
- return $this->tokens[$i][0];
- }
- }
-
- /**
- * Converts $this->css array to a raw array ($this->tokens)
- * @param string $default_media default @media to add to selectors without any @media
- * @access private
- * @version 1.0
- */
- function _convert_raw_css($default_media='') {
- $this->tokens = array();
-
- foreach ($this->css as $medium => $val) {
- if ($this->parser->get_cfg('sort_selectors'))
- ksort($val);
- if ( (int) $medium < DEFAULT_AT ) {
- $this->parser->_add_token(AT_START, $medium, true);
- }
- elseif ($default_media) {
- $this->parser->_add_token(AT_START, $default_media, true);
- }
-
- foreach ($val as $selector => $vali) {
- if ($this->parser->get_cfg('sort_properties'))
- ksort($vali);
- $this->parser->_add_token(SEL_START, $selector, true);
-
- foreach ($vali as $property => $valj) {
- $this->parser->_add_token(PROPERTY, $property, true);
- $this->parser->_add_token(VALUE, $valj, true);
- }
-
- $this->parser->_add_token(SEL_END, $selector, true);
- }
-
- if ( (int) $medium < DEFAULT_AT ) {
- $this->parser->_add_token(AT_END, $medium, true);
- }
- elseif ($default_media) {
- $this->parser->_add_token(AT_END, $default_media, true);
- }
- }
- }
-
- /**
- * Same as htmlspecialchars, only that chars are not replaced if $plain !== true. This makes print_code() cleaner.
- * @param string $string
- * @param bool $plain
- * @return string
- * @see csstidy_print::_print()
- * @access private
- * @version 1.0
- */
- function _htmlsp($string, $plain) {
- if (!$plain) {
- return htmlspecialchars($string, ENT_QUOTES, 'utf-8');
- }
- return $string;
- }
-
- /**
- * Get compression ratio
- * @access public
- * @return float
- * @version 1.2
- */
- function get_ratio() {
- if (!$this->output_css_plain) {
- $this->formatted();
- }
- return round((strlen($this->input_css) - strlen($this->output_css_plain)) / strlen($this->input_css), 3) * 100;
- }
-
- /**
- * Get difference between the old and new code in bytes and prints the code if necessary.
- * @access public
- * @return string
- * @version 1.1
- */
- function get_diff() {
- if (!$this->output_css_plain) {
- $this->formatted();
- }
-
- $diff = strlen($this->output_css_plain) - strlen($this->input_css);
-
- if ($diff > 0) {
- return '+' . $diff;
- } elseif ($diff == 0) {
- return '+-' . $diff;
- }
-
- return $diff;
- }
-
- /**
- * Get the size of either input or output CSS in KB
- * @param string $loc default is "output"
- * @access public
- * @return integer
- * @version 1.0
- */
- function size($loc = 'output') {
- if ($loc === 'output' && !$this->output_css) {
- $this->formatted();
- }
-
- if ($loc === 'input') {
- return (strlen($this->input_css) / 1000);
- } else {
- return (strlen($this->output_css_plain) / 1000);
- }
- }
-
-}
diff --git a/plugins/jetpack/modules/custom-css/csstidy/cssparse-rtl.css b/plugins/jetpack/modules/custom-css/csstidy/cssparse-rtl.css
index 522433be..f04a746e 100644
--- a/plugins/jetpack/modules/custom-css/csstidy/cssparse-rtl.css
+++ b/plugins/jetpack/modules/custom-css/csstidy/cssparse-rtl.css
@@ -1,119 +1,146 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-@import url("./cssparsed.css");
+code#copytext {
+ white-space: pre;
+ font-family: Verdana;
+}
+
+.at {
+ color: darkblue;
+}
+
+.format {
+ color: gray;
+}
+
+.property {
+ color: green;
+}
+.selector {
+ color: blue;
+}
+
+.value {
+ color: red;
+ right: 500px;
+}
+
+.comment {
+ color: orange;
+}
html, body {
-font:0.8em Verdana,Helvetica,sans-serif;
-background:#F8F8F6;
+ font: 0.8em Verdana, Helvetica, sans-serif;
+ background: #F8F8F6;
}
code {
-font-size:1.2em;
+ font-size: 1.2em;
}
div#rightcol {
-padding-right:32em;
+ padding-right: 32em;
}
fieldset {
-display:block;
-margin:0.5em 0;
-padding:1em;
-border:solid #7284AB 2px;
+ display: block;
+ margin: 0.5em 0;
+ padding: 1em;
+ border: solid #7284AB 2px;
}
+
fieldset.code_output {
-display:inline;
+ display: inline;
}
h1 {
-font-size:2em;
+ font-size: 2em;
}
small {
-font-size:0.7em;
+ font-size: 0.7em;
}
fieldset#field_input {
-float:right;
-margin:0 0 1em 0.5em;
+ float: right;
+ margin: 0 0 1em 0.5em;
}
-fieldset#options,fieldset#code_layout {
-width:31em;
+fieldset#options, fieldset#code_layout {
+ width: 31em;
}
input#submit {
-clear:both;
-display:block;
-margin:1em;
+ clear: both;
+ display: block;
+ margin: 1em;
}
select {
-margin:2px 0 0;
+ margin: 2px 0 0;
}
label.block {
-display:block;
+ display: block;
}
legend {
-background:#c4E1C3;
-padding:2px 4px;
-border:dashed 1px;
+ background: #c4E1C3;
+ padding: 2px 4px;
+ border: dashed 1px;
}
textarea#css_text {
-width:27em;
-height:370px;
-display:block;
-margin-left:1em;
+ width: 27em;
+ height: 370px;
+ display: block;
+ margin-left: 1em;
}
.help {
-cursor:help;
+ cursor: help;
}
p.important {
-border:solid 1px red;
-font-weight:bold;
-padding:1em;
-background:white;
+ border: solid 1px red;
+ font-weight: bold;
+ padding: 1em;
+ background: white;
}
p {
-margin:1em 0;
+ margin: 1em 0;
}
dl {
-padding-right:0.5em;
+ padding-right: 0.5em;
}
dt {
-font-weight:bold;
-margin:0;
-float:right;
-clear:both;
-height:1.5em;
+ font-weight: bold;
+ margin: 0;
+ float: right;
+ clear: both;
+ height: 1.5em;
}
dd {
-margin:0 4em 0 0;
-height:1.5em;
+ margin: 0 4em 0 0;
+ height: 1.5em;
}
fieldset#messages {
-background:white;
-padding:0 1em 0 0;
+ background: white;
+ padding: 0 1em 0 0;
}
fieldset#messages div {
-height:10em;
-overflow:auto;
+ height: 10em;
+ overflow: auto;
}
dd.Warning {
-color:orange;
+ color: orange;
}
dd.Information {
-color:green;
+ color: green;
}
diff --git a/plugins/jetpack/modules/custom-css/csstidy/cssparse-rtl.min.css b/plugins/jetpack/modules/custom-css/csstidy/cssparse-rtl.min.css
index 02da7f4c..cea0e4f0 100644
--- a/plugins/jetpack/modules/custom-css/csstidy/cssparse-rtl.min.css
+++ b/plugins/jetpack/modules/custom-css/csstidy/cssparse-rtl.min.css
@@ -1 +1 @@
-code#copytext{white-space:pre;font-family:Verdana}.at{color:#00008b}.format{color:gray}.property{color:green}.selector{color:#00f}.value{color:red;left:500px}.comment{color:orange}body,html{font:.8em Verdana,Helvetica,sans-serif;background:#f8f8f6}code{font-size:1.2em}div#rightcol{padding-right:32em}fieldset{display:block;margin:.5em 0;padding:1em;border:solid #7284ab 2px}fieldset.code_output{display:inline}h1{font-size:2em}small{font-size:.7em}fieldset#field_input{float:right;margin:0 0 1em .5em}fieldset#code_layout,fieldset#options{width:31em}input#submit{clear:both;display:block;margin:1em}select{margin:2px 0 0}label.block{display:block}legend{background:#c4e1c3;padding:2px 4px;border:dashed 1px}textarea#css_text{width:27em;height:370px;display:block;margin-left:1em}.help{cursor:help}p.important{border:solid 1px red;font-weight:700;padding:1em;background:#fff}p{margin:1em 0}dl{padding-right:.5em}dt{font-weight:700;margin:0;float:right;clear:both;height:1.5em}dd{margin:0 4em 0 0;height:1.5em}fieldset#messages{background:#fff;padding:0 1em 0 0}fieldset#messages div{height:10em;overflow:auto}dd.Warning{color:orange}dd.Information{color:green} \ No newline at end of file
+code#copytext{font-family:Verdana;white-space:pre}.at{color:#00008b}.format{color:gray}.property{color:green}.selector{color:blue}.value{color:red;right:500px}.comment{color:orange}body,html{background:#f8f8f6;font:.8em Verdana,Helvetica,sans-serif}code{font-size:1.2em}div#rightcol{padding-right:32em}fieldset{border:2px solid #7284ab;display:block;margin:.5em 0;padding:1em}fieldset.code_output{display:inline}h1{font-size:2em}small{font-size:.7em}fieldset#field_input{float:right;margin:0 0 1em .5em}fieldset#code_layout,fieldset#options{width:31em}input#submit{clear:both;display:block;margin:1em}select{margin:2px 0 0}label.block{display:block}legend{background:#c4e1c3;border:1px dashed;padding:2px 4px}textarea#css_text{display:block;height:370px;margin-left:1em;width:27em}.help{cursor:help}p.important{background:#fff;border:1px solid red;font-weight:700;padding:1em}p{margin:1em 0}dl{padding-right:.5em}dt{clear:both;float:right;font-weight:700;margin:0}dd,dt{height:1.5em}dd{margin:0 4em 0 0}fieldset#messages{background:#fff;padding:0 1em 0 0}fieldset#messages div{height:10em;overflow:auto}dd.Warning{color:orange}dd.Information{color:green} \ No newline at end of file
diff --git a/plugins/jetpack/modules/custom-css/csstidy/cssparse.min.css b/plugins/jetpack/modules/custom-css/csstidy/cssparse.min.css
index fa4927e5..74aaa8ba 100644
--- a/plugins/jetpack/modules/custom-css/csstidy/cssparse.min.css
+++ b/plugins/jetpack/modules/custom-css/csstidy/cssparse.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-code#copytext{white-space:pre;font-family:Verdana}.at{color:#00008b}.format{color:gray}.property{color:green}.selector{color:#00f}.value{color:red;left:500px}.comment{color:orange}body,html{font:.8em Verdana,Helvetica,sans-serif;background:#f8f8f6}code{font-size:1.2em}div#rightcol{padding-left:32em}fieldset{display:block;margin:.5em 0;padding:1em;border:solid #7284ab 2px}fieldset.code_output{display:inline}h1{font-size:2em}small{font-size:.7em}fieldset#field_input{float:left;margin:0 .5em 1em 0}fieldset#code_layout,fieldset#options{width:31em}input#submit{clear:both;display:block;margin:1em}select{margin:2px 0 0}label.block{display:block}legend{background:#c4e1c3;padding:2px 4px;border:dashed 1px}textarea#css_text{width:27em;height:370px;display:block;margin-right:1em}.help{cursor:help}p.important{border:solid 1px red;font-weight:700;padding:1em;background:#fff}p{margin:1em 0}dl{padding-left:.5em}dt{font-weight:700;margin:0;float:left;clear:both;height:1.5em}dd{margin:0 0 0 4em;height:1.5em}fieldset#messages{background:#fff;padding:0 0 0 1em}fieldset#messages div{height:10em;overflow:auto}dd.Warning{color:orange}dd.Information{color:green} \ No newline at end of file
+code#copytext{font-family:Verdana;white-space:pre}.at{color:#00008b}.format{color:gray}.property{color:green}.selector{color:blue}.value{color:red;left:500px}.comment{color:orange}body,html{background:#f8f8f6;font:.8em Verdana,Helvetica,sans-serif}code{font-size:1.2em}div#rightcol{padding-left:32em}fieldset{border:2px solid #7284ab;display:block;margin:.5em 0;padding:1em}fieldset.code_output{display:inline}h1{font-size:2em}small{font-size:.7em}fieldset#field_input{float:left;margin:0 .5em 1em 0}fieldset#code_layout,fieldset#options{width:31em}input#submit{clear:both;display:block;margin:1em}select{margin:2px 0 0}label.block{display:block}legend{background:#c4e1c3;border:1px dashed;padding:2px 4px}textarea#css_text{display:block;height:370px;margin-right:1em;width:27em}.help{cursor:help}p.important{background:#fff;border:1px solid red;font-weight:700;padding:1em}p{margin:1em 0}dl{padding-left:.5em}dt{clear:both;float:left;font-weight:700;margin:0}dd,dt{height:1.5em}dd{margin:0 0 0 4em}fieldset#messages{background:#fff;padding:0 0 0 1em}fieldset#messages div{height:10em;overflow:auto}dd.Warning{color:orange}dd.Information{color:green} \ No newline at end of file
diff --git a/plugins/jetpack/modules/custom-css/csstidy/cssparsed-rtl.css b/plugins/jetpack/modules/custom-css/csstidy/cssparsed-rtl.css
index d765e2d7..5b8877af 100644
--- a/plugins/jetpack/modules/custom-css/csstidy/cssparsed-rtl.css
+++ b/plugins/jetpack/modules/custom-css/csstidy/cssparsed-rtl.css
@@ -1,30 +1,29 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
code#copytext {
- white-space: pre;
- font-family: Verdana;
+ white-space: pre;
+ font-family: Verdana;
}
.at {
-color:darkblue;
+ color: darkblue;
}
.format {
-color:gray;
+ color: gray;
}
.property {
-color:green;
+ color: green;
}
.selector {
-color:blue;
+ color: blue;
}
.value {
-color:red;
-right: 500px;
+ color: red;
+ right: 500px;
}
.comment {
-color:orange;
-} \ No newline at end of file
+ color: orange;
+}
diff --git a/plugins/jetpack/modules/custom-css/csstidy/cssparsed-rtl.min.css b/plugins/jetpack/modules/custom-css/csstidy/cssparsed-rtl.min.css
index ba9903d0..99cd80fd 100644
--- a/plugins/jetpack/modules/custom-css/csstidy/cssparsed-rtl.min.css
+++ b/plugins/jetpack/modules/custom-css/csstidy/cssparsed-rtl.min.css
@@ -1 +1 @@
-code#copytext{white-space:pre;font-family:Verdana}.at{color:#00008b}.format{color:gray}.property{color:green}.selector{color:#00f}.value{color:red;right:500px}.comment{color:orange} \ No newline at end of file
+code#copytext{font-family:Verdana;white-space:pre}.at{color:#00008b}.format{color:gray}.property{color:green}.selector{color:blue}.value{color:red;right:500px}.comment{color:orange} \ No newline at end of file
diff --git a/plugins/jetpack/modules/custom-css/csstidy/cssparsed.min.css b/plugins/jetpack/modules/custom-css/csstidy/cssparsed.min.css
index db96935e..76b00200 100644
--- a/plugins/jetpack/modules/custom-css/csstidy/cssparsed.min.css
+++ b/plugins/jetpack/modules/custom-css/csstidy/cssparsed.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-code#copytext{white-space:pre;font-family:Verdana}.at{color:#00008b}.format{color:gray}.property{color:green}.selector{color:#00f}.value{color:red;left:500px}.comment{color:orange} \ No newline at end of file
+code#copytext{font-family:Verdana;white-space:pre}.at{color:#00008b}.format{color:gray}.property{color:green}.selector{color:blue}.value{color:red;left:500px}.comment{color:orange} \ No newline at end of file
diff --git a/plugins/jetpack/modules/custom-css/csstidy/data-wp.inc.php b/plugins/jetpack/modules/custom-css/csstidy/data-wp.inc.php
index f0f7376f..518a5bb6 100644
--- a/plugins/jetpack/modules/custom-css/csstidy/data-wp.inc.php
+++ b/plugins/jetpack/modules/custom-css/csstidy/data-wp.inc.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
unset( $GLOBALS['csstidy']['all_properties']['binding'] );
@@ -6,14 +6,14 @@ $GLOBALS['csstidy']['all_properties']['text-size-adjust'] = 'CSS3.0';
// Support browser prefixes for properties only in the latest CSS draft
foreach ( $GLOBALS['csstidy']['all_properties'] as $property => $levels ) {
- if ( strpos( $levels, "," ) === false ) {
- $GLOBALS['csstidy']['all_properties']['-moz-' . $property] = $levels;
- $GLOBALS['csstidy']['all_properties']['-webkit-' . $property] = $levels;
- $GLOBALS['csstidy']['all_properties']['-ms-' . $property] = $levels;
- $GLOBALS['csstidy']['all_properties']['-o-' . $property] = $levels;
- $GLOBALS['csstidy']['all_properties']['-khtml-' . $property] = $levels;
+ if ( strpos( $levels, ',' ) === false ) {
+ $GLOBALS['csstidy']['all_properties'][ '-moz-' . $property ] = $levels;
+ $GLOBALS['csstidy']['all_properties'][ '-webkit-' . $property ] = $levels;
+ $GLOBALS['csstidy']['all_properties'][ '-ms-' . $property ] = $levels;
+ $GLOBALS['csstidy']['all_properties'][ '-o-' . $property ] = $levels;
+ $GLOBALS['csstidy']['all_properties'][ '-khtml-' . $property ] = $levels;
- if ( in_array( $property, $GLOBALS['csstidy']['unit_values'] ) ) {
+ if ( in_array( $property, $GLOBALS['csstidy']['unit_values'], true ) ) {
$GLOBALS['csstidy']['unit_values'][] = '-moz-' . $property;
$GLOBALS['csstidy']['unit_values'][] = '-webkit-' . $property;
$GLOBALS['csstidy']['unit_values'][] = '-ms-' . $property;
@@ -21,7 +21,7 @@ foreach ( $GLOBALS['csstidy']['all_properties'] as $property => $levels ) {
$GLOBALS['csstidy']['unit_values'][] = '-khtml-' . $property;
}
- if ( in_array( $property, $GLOBALS['csstidy']['color_values'] ) ) {
+ if ( in_array( $property, $GLOBALS['csstidy']['color_values'], true ) ) {
$GLOBALS['csstidy']['color_values'][] = '-moz-' . $property;
$GLOBALS['csstidy']['color_values'][] = '-webkit-' . $property;
$GLOBALS['csstidy']['color_values'][] = '-ms-' . $property;
@@ -36,7 +36,7 @@ $GLOBALS['csstidy']['multiple_properties'][] = 'display';
// Allow vendor prefixes for any property that is allowed to be used multiple times inside a single selector
foreach ( $GLOBALS['csstidy']['multiple_properties'] as $property ) {
- if ( '-' != $property[0] ) {
+ if ( '-' !== $property[0] ) {
$GLOBALS['csstidy']['multiple_properties'][] = '-o-' . $property;
$GLOBALS['csstidy']['multiple_properties'][] = '-ms-' . $property;
$GLOBALS['csstidy']['multiple_properties'][] = '-webkit-' . $property;
@@ -51,52 +51,52 @@ foreach ( $GLOBALS['csstidy']['multiple_properties'] as $property ) {
* @see https://developer.mozilla.org/en/CSS/CSS_animations
*/
$GLOBALS['csstidy']['at_rules']['-webkit-keyframes'] = 'at';
-$GLOBALS['csstidy']['at_rules']['-moz-keyframes'] = 'at';
-$GLOBALS['csstidy']['at_rules']['-ms-keyframes'] = 'at';
-$GLOBALS['csstidy']['at_rules']['-o-keyframes'] = 'at';
+$GLOBALS['csstidy']['at_rules']['-moz-keyframes'] = 'at';
+$GLOBALS['csstidy']['at_rules']['-ms-keyframes'] = 'at';
+$GLOBALS['csstidy']['at_rules']['-o-keyframes'] = 'at';
/**
* Non-standard viewport rule.
*/
-$GLOBALS['csstidy']['at_rules']['viewport'] = 'is';
+$GLOBALS['csstidy']['at_rules']['viewport'] = 'is';
$GLOBALS['csstidy']['at_rules']['-webkit-viewport'] = 'is';
-$GLOBALS['csstidy']['at_rules']['-moz-viewport'] = 'is';
-$GLOBALS['csstidy']['at_rules']['-ms-viewport'] = 'is';
+$GLOBALS['csstidy']['at_rules']['-moz-viewport'] = 'is';
+$GLOBALS['csstidy']['at_rules']['-ms-viewport'] = 'is';
/**
* Non-standard CSS properties. They're not part of any spec, but we say
* they're in all of them so that we can support them.
*/
-$GLOBALS['csstidy']['all_properties']['-webkit-filter'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['-moz-filter'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['-ms-filter'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['filter'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scrollbar-face-color'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['-ms-interpolation-mode'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-rendering'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['-webkit-filter'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['-moz-filter'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['-ms-filter'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['filter'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scrollbar-face-color'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['-ms-interpolation-mode'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-rendering'] = 'CSS2.0,CSS2.1,CSS3.0';
$GLOBALS['csstidy']['all_properties']['-webkit-transform-origin-x'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['-webkit-transform-origin-y'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['-webkit-transform-origin-z'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['-webkit-font-smoothing'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['-moz-osx-font-smoothing'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['-font-smooth'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['-o-object-fit'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['object-fit'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['-o-object-position'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['object-position'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-overflow'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['zoom'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['pointer-events'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-feature-settings'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-kerning'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-language-override'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-synthesis'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-variant-alternates'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-variant-caps'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-variant-east-asian'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-variant-ligatures'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-variant-numeric'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-variant-position'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-variation-settings'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['line-height-step'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['-webkit-font-smoothing'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['-moz-osx-font-smoothing'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['-font-smooth'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['-o-object-fit'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['object-fit'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['-o-object-position'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['object-position'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-overflow'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['zoom'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['pointer-events'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-feature-settings'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-kerning'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-language-override'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-synthesis'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-variant-alternates'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-variant-caps'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-variant-east-asian'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-variant-ligatures'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-variant-numeric'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-variant-position'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-variation-settings'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['line-height-step'] = 'CSS3.0';
diff --git a/plugins/jetpack/modules/custom-css/csstidy/data.inc.php b/plugins/jetpack/modules/custom-css/csstidy/data.inc.php
index 882749ba..f6de9994 100644
--- a/plugins/jetpack/modules/custom-css/csstidy/data.inc.php
+++ b/plugins/jetpack/modules/custom-css/csstidy/data.inc.php
@@ -20,18 +20,17 @@
*
* @license https://opensource.org/licenses/gpl-license.php GNU Public License
* @package csstidy
- * @author Florian Schmitz (floele at gmail dot com) 2005
- * @author Nikolay Matsievsky (speed at webo dot name) 2010
+ * @author Florian Schmitz (floele at gmail dot com) 2005, Nikolay Matsievsky (speed at webo dot name) 2010
*/
-define('AT_START', 1);
-define('AT_END', 2);
-define('SEL_START', 3);
-define('SEL_END', 4);
-define('PROPERTY', 5);
-define('VALUE', 6);
-define('COMMENT', 7);
-define('DEFAULT_AT', 41);
+define( 'AT_START', 1 );
+define( 'AT_END', 2 );
+define( 'SEL_START', 3 );
+define( 'SEL_END', 4 );
+define( 'PROPERTY', 5 );
+define( 'VALUE', 6 );
+define( 'COMMENT', 7 );
+define( 'DEFAULT_AT', 41 );
/**
* All whitespace allowed in CSS
@@ -39,7 +38,7 @@ define('DEFAULT_AT', 41);
* @global array $GLOBALS['csstidy']['whitespace']
* @version 1.0
*/
-$GLOBALS['csstidy']['whitespace'] = array(' ',"\n","\t","\r","\x0B");
+$GLOBALS['csstidy']['whitespace'] = array( ' ', "\n", "\t", "\r", "\x0B" );
/**
* All CSS tokens used by csstidy
@@ -56,7 +55,7 @@ $GLOBALS['csstidy']['tokens'] = '/@}{;:=\'"(,\\!$%&)*+.<>?[]^`|~';
* @global array $GLOBALS['csstidy']['units']
* @version 1.0
*/
-$GLOBALS['csstidy']['units'] = array('in','cm','mm','pt','pc','px','rem','em','%','ex','gd','vw','vh','vm','deg','grad','rad','ms','s','khz','hz');
+$GLOBALS['csstidy']['units'] = array( 'in', 'cm', 'mm', 'pt', 'pc', 'px', 'rem', 'em', '%', 'ex', 'gd', 'vw', 'vh', 'vm', 'deg', 'grad', 'rad', 'ms', 's', 'khz', 'hz' );
/**
* Available at-rules
@@ -64,9 +63,18 @@ $GLOBALS['csstidy']['units'] = array('in','cm','mm','pt','pc','px','rem','em','%
* @global array $GLOBALS['csstidy']['at_rules']
* @version 1.0
*/
-$GLOBALS['csstidy']['at_rules'] = array('page' => 'is','font-face' => 'is','charset' => 'iv', 'import' => 'iv','namespace' => 'iv','media' => 'at','keyframes' => 'at', 'supports' => 'at');
+$GLOBALS['csstidy']['at_rules'] = array(
+ 'page' => 'is',
+ 'font-face' => 'is',
+ 'charset' => 'iv',
+ 'import' => 'iv',
+ 'namespace' => 'iv',
+ 'media' => 'at',
+ 'keyframes' => 'at',
+ 'supports' => 'at',
+);
- /**
+/**
* Properties that need a value with unit
*
* @todo CSS3 properties
@@ -74,11 +82,51 @@ $GLOBALS['csstidy']['at_rules'] = array('page' => 'is','font-face' => 'is','char
* @global array $GLOBALS['csstidy']['unit_values']
* @version 1.2
*/
-$GLOBALS['csstidy']['unit_values'] = array ('background', 'background-position', 'background-size', 'border', 'border-top', 'border-right', 'border-bottom', 'border-left', 'border-width',
- 'border-top-width', 'border-right-width', 'border-left-width', 'border-bottom-width', 'bottom', 'border-spacing', 'column-gap', 'column-width',
- 'font-size', 'height', 'left', 'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left', 'max-height',
- 'max-width', 'min-height', 'min-width', 'outline', 'outline-width', 'padding', 'padding-top', 'padding-right',
- 'padding-bottom', 'padding-left', 'perspective', 'right', 'top', 'text-indent', 'letter-spacing', 'word-spacing', 'width');
+$GLOBALS['csstidy']['unit_values'] = array(
+ 'background',
+ 'background-position',
+ 'background-size',
+ 'border',
+ 'border-top',
+ 'border-right',
+ 'border-bottom',
+ 'border-left',
+ 'border-width',
+ 'border-top-width',
+ 'border-right-width',
+ 'border-left-width',
+ 'border-bottom-width',
+ 'bottom',
+ 'border-spacing',
+ 'column-gap',
+ 'column-width',
+ 'font-size',
+ 'height',
+ 'left',
+ 'margin',
+ 'margin-top',
+ 'margin-right',
+ 'margin-bottom',
+ 'margin-left',
+ 'max-height',
+ 'max-width',
+ 'min-height',
+ 'min-width',
+ 'outline',
+ 'outline-width',
+ 'padding',
+ 'padding-top',
+ 'padding-right',
+ 'padding-bottom',
+ 'padding-left',
+ 'perspective',
+ 'right',
+ 'top',
+ 'text-indent',
+ 'letter-spacing',
+ 'word-spacing',
+ 'width',
+);
/**
* Properties that allow <color> as value
@@ -88,7 +136,7 @@ $GLOBALS['csstidy']['unit_values'] = array ('background', 'background-position',
* @global array $GLOBALS['csstidy']['color_values']
* @version 1.0
*/
-$GLOBALS['csstidy']['color_values'] = array();
+$GLOBALS['csstidy']['color_values'] = array();
$GLOBALS['csstidy']['color_values'][] = 'background-color';
$GLOBALS['csstidy']['color_values'][] = 'border-color';
$GLOBALS['csstidy']['color_values'][] = 'border-top-color';
@@ -108,15 +156,15 @@ $GLOBALS['csstidy']['color_values'][] = 'column-rule-color';
* @see merge_bg()
* @version 1.0
*/
-$GLOBALS['csstidy']['background_prop_default'] = array();
-$GLOBALS['csstidy']['background_prop_default']['background-image'] = 'none';
-$GLOBALS['csstidy']['background_prop_default']['background-size'] = 'auto';
-$GLOBALS['csstidy']['background_prop_default']['background-repeat'] = 'repeat';
-$GLOBALS['csstidy']['background_prop_default']['background-position'] = '0 0';
+$GLOBALS['csstidy']['background_prop_default'] = array();
+$GLOBALS['csstidy']['background_prop_default']['background-image'] = 'none';
+$GLOBALS['csstidy']['background_prop_default']['background-size'] = 'auto';
+$GLOBALS['csstidy']['background_prop_default']['background-repeat'] = 'repeat';
+$GLOBALS['csstidy']['background_prop_default']['background-position'] = '0 0';
$GLOBALS['csstidy']['background_prop_default']['background-attachment'] = 'scroll';
-$GLOBALS['csstidy']['background_prop_default']['background-clip'] = 'border';
-$GLOBALS['csstidy']['background_prop_default']['background-origin'] = 'padding';
-$GLOBALS['csstidy']['background_prop_default']['background-color'] = 'transparent';
+$GLOBALS['csstidy']['background_prop_default']['background-clip'] = 'border';
+$GLOBALS['csstidy']['background_prop_default']['background-origin'] = 'padding';
+$GLOBALS['csstidy']['background_prop_default']['background-color'] = 'transparent';
/**
* Default values for the font properties
@@ -125,13 +173,13 @@ $GLOBALS['csstidy']['background_prop_default']['background-color'] = 'transparen
* @see merge_fonts()
* @version 1.3
*/
-$GLOBALS['csstidy']['font_prop_default'] = array();
-$GLOBALS['csstidy']['font_prop_default']['font-style'] = 'normal';
+$GLOBALS['csstidy']['font_prop_default'] = array();
+$GLOBALS['csstidy']['font_prop_default']['font-style'] = 'normal';
$GLOBALS['csstidy']['font_prop_default']['font-variant'] = 'normal';
-$GLOBALS['csstidy']['font_prop_default']['font-weight'] = 'normal';
-$GLOBALS['csstidy']['font_prop_default']['font-size'] = '';
-$GLOBALS['csstidy']['font_prop_default']['line-height'] = '';
-$GLOBALS['csstidy']['font_prop_default']['font-family'] = '';
+$GLOBALS['csstidy']['font_prop_default']['font-weight'] = 'normal';
+$GLOBALS['csstidy']['font_prop_default']['font-size'] = '';
+$GLOBALS['csstidy']['font_prop_default']['line-height'] = '';
+$GLOBALS['csstidy']['font_prop_default']['font-family'] = '';
/**
* A list of non-W3C color names which get replaced by their hex-codes
@@ -140,133 +188,133 @@ $GLOBALS['csstidy']['font_prop_default']['font-family'] = '';
* @see cut_color()
* @version 1.0
*/
-$GLOBALS['csstidy']['replace_colors'] = array();
-$GLOBALS['csstidy']['replace_colors']['aliceblue'] = '#f0f8ff';
-$GLOBALS['csstidy']['replace_colors']['antiquewhite'] = '#faebd7';
-$GLOBALS['csstidy']['replace_colors']['aquamarine'] = '#7fffd4';
-$GLOBALS['csstidy']['replace_colors']['azure'] = '#f0ffff';
-$GLOBALS['csstidy']['replace_colors']['beige'] = '#f5f5dc';
-$GLOBALS['csstidy']['replace_colors']['bisque'] = '#ffe4c4';
-$GLOBALS['csstidy']['replace_colors']['blanchedalmond'] = '#ffebcd';
-$GLOBALS['csstidy']['replace_colors']['blueviolet'] = '#8a2be2';
-$GLOBALS['csstidy']['replace_colors']['brown'] = '#a52a2a';
-$GLOBALS['csstidy']['replace_colors']['burlywood'] = '#deb887';
-$GLOBALS['csstidy']['replace_colors']['cadetblue'] = '#5f9ea0';
-$GLOBALS['csstidy']['replace_colors']['chartreuse'] = '#7fff00';
-$GLOBALS['csstidy']['replace_colors']['chocolate'] = '#d2691e';
-$GLOBALS['csstidy']['replace_colors']['coral'] = '#ff7f50';
-$GLOBALS['csstidy']['replace_colors']['cornflowerblue'] = '#6495ed';
-$GLOBALS['csstidy']['replace_colors']['cornsilk'] = '#fff8dc';
-$GLOBALS['csstidy']['replace_colors']['crimson'] = '#dc143c';
-$GLOBALS['csstidy']['replace_colors']['cyan'] = '#00ffff';
-$GLOBALS['csstidy']['replace_colors']['darkblue'] = '#00008b';
-$GLOBALS['csstidy']['replace_colors']['darkcyan'] = '#008b8b';
-$GLOBALS['csstidy']['replace_colors']['darkgoldenrod'] = '#b8860b';
-$GLOBALS['csstidy']['replace_colors']['darkgray'] = '#a9a9a9';
-$GLOBALS['csstidy']['replace_colors']['darkgreen'] = '#006400';
-$GLOBALS['csstidy']['replace_colors']['darkkhaki'] = '#bdb76b';
-$GLOBALS['csstidy']['replace_colors']['darkmagenta'] = '#8b008b';
-$GLOBALS['csstidy']['replace_colors']['darkolivegreen'] = '#556b2f';
-$GLOBALS['csstidy']['replace_colors']['darkorange'] = '#ff8c00';
-$GLOBALS['csstidy']['replace_colors']['darkorchid'] = '#9932cc';
-$GLOBALS['csstidy']['replace_colors']['darkred'] = '#8b0000';
-$GLOBALS['csstidy']['replace_colors']['darksalmon'] = '#e9967a';
-$GLOBALS['csstidy']['replace_colors']['darkseagreen'] = '#8fbc8f';
-$GLOBALS['csstidy']['replace_colors']['darkslateblue'] = '#483d8b';
-$GLOBALS['csstidy']['replace_colors']['darkslategray'] = '#2f4f4f';
-$GLOBALS['csstidy']['replace_colors']['darkturquoise'] = '#00ced1';
-$GLOBALS['csstidy']['replace_colors']['darkviolet'] = '#9400d3';
-$GLOBALS['csstidy']['replace_colors']['deeppink'] = '#ff1493';
-$GLOBALS['csstidy']['replace_colors']['deepskyblue'] = '#00bfff';
-$GLOBALS['csstidy']['replace_colors']['dimgray'] = '#696969';
-$GLOBALS['csstidy']['replace_colors']['dodgerblue'] = '#1e90ff';
-$GLOBALS['csstidy']['replace_colors']['feldspar'] = '#d19275';
-$GLOBALS['csstidy']['replace_colors']['firebrick'] = '#b22222';
-$GLOBALS['csstidy']['replace_colors']['floralwhite'] = '#fffaf0';
-$GLOBALS['csstidy']['replace_colors']['forestgreen'] = '#228b22';
-$GLOBALS['csstidy']['replace_colors']['gainsboro'] = '#dcdcdc';
-$GLOBALS['csstidy']['replace_colors']['ghostwhite'] = '#f8f8ff';
-$GLOBALS['csstidy']['replace_colors']['gold'] = '#ffd700';
-$GLOBALS['csstidy']['replace_colors']['goldenrod'] = '#daa520';
-$GLOBALS['csstidy']['replace_colors']['greenyellow'] = '#adff2f';
-$GLOBALS['csstidy']['replace_colors']['honeydew'] = '#f0fff0';
-$GLOBALS['csstidy']['replace_colors']['hotpink'] = '#ff69b4';
-$GLOBALS['csstidy']['replace_colors']['indianred'] = '#cd5c5c';
-$GLOBALS['csstidy']['replace_colors']['indigo'] = '#4b0082';
-$GLOBALS['csstidy']['replace_colors']['ivory'] = '#fffff0';
-$GLOBALS['csstidy']['replace_colors']['khaki'] = '#f0e68c';
-$GLOBALS['csstidy']['replace_colors']['lavender'] = '#e6e6fa';
-$GLOBALS['csstidy']['replace_colors']['lavenderblush'] = '#fff0f5';
-$GLOBALS['csstidy']['replace_colors']['lawngreen'] = '#7cfc00';
-$GLOBALS['csstidy']['replace_colors']['lemonchiffon'] = '#fffacd';
-$GLOBALS['csstidy']['replace_colors']['lightblue'] = '#add8e6';
-$GLOBALS['csstidy']['replace_colors']['lightcoral'] = '#f08080';
-$GLOBALS['csstidy']['replace_colors']['lightcyan'] = '#e0ffff';
+$GLOBALS['csstidy']['replace_colors'] = array();
+$GLOBALS['csstidy']['replace_colors']['aliceblue'] = '#f0f8ff';
+$GLOBALS['csstidy']['replace_colors']['antiquewhite'] = '#faebd7';
+$GLOBALS['csstidy']['replace_colors']['aquamarine'] = '#7fffd4';
+$GLOBALS['csstidy']['replace_colors']['azure'] = '#f0ffff';
+$GLOBALS['csstidy']['replace_colors']['beige'] = '#f5f5dc';
+$GLOBALS['csstidy']['replace_colors']['bisque'] = '#ffe4c4';
+$GLOBALS['csstidy']['replace_colors']['blanchedalmond'] = '#ffebcd';
+$GLOBALS['csstidy']['replace_colors']['blueviolet'] = '#8a2be2';
+$GLOBALS['csstidy']['replace_colors']['brown'] = '#a52a2a';
+$GLOBALS['csstidy']['replace_colors']['burlywood'] = '#deb887';
+$GLOBALS['csstidy']['replace_colors']['cadetblue'] = '#5f9ea0';
+$GLOBALS['csstidy']['replace_colors']['chartreuse'] = '#7fff00';
+$GLOBALS['csstidy']['replace_colors']['chocolate'] = '#d2691e';
+$GLOBALS['csstidy']['replace_colors']['coral'] = '#ff7f50';
+$GLOBALS['csstidy']['replace_colors']['cornflowerblue'] = '#6495ed';
+$GLOBALS['csstidy']['replace_colors']['cornsilk'] = '#fff8dc';
+$GLOBALS['csstidy']['replace_colors']['crimson'] = '#dc143c';
+$GLOBALS['csstidy']['replace_colors']['cyan'] = '#00ffff';
+$GLOBALS['csstidy']['replace_colors']['darkblue'] = '#00008b';
+$GLOBALS['csstidy']['replace_colors']['darkcyan'] = '#008b8b';
+$GLOBALS['csstidy']['replace_colors']['darkgoldenrod'] = '#b8860b';
+$GLOBALS['csstidy']['replace_colors']['darkgray'] = '#a9a9a9';
+$GLOBALS['csstidy']['replace_colors']['darkgreen'] = '#006400';
+$GLOBALS['csstidy']['replace_colors']['darkkhaki'] = '#bdb76b';
+$GLOBALS['csstidy']['replace_colors']['darkmagenta'] = '#8b008b';
+$GLOBALS['csstidy']['replace_colors']['darkolivegreen'] = '#556b2f';
+$GLOBALS['csstidy']['replace_colors']['darkorange'] = '#ff8c00';
+$GLOBALS['csstidy']['replace_colors']['darkorchid'] = '#9932cc';
+$GLOBALS['csstidy']['replace_colors']['darkred'] = '#8b0000';
+$GLOBALS['csstidy']['replace_colors']['darksalmon'] = '#e9967a';
+$GLOBALS['csstidy']['replace_colors']['darkseagreen'] = '#8fbc8f';
+$GLOBALS['csstidy']['replace_colors']['darkslateblue'] = '#483d8b';
+$GLOBALS['csstidy']['replace_colors']['darkslategray'] = '#2f4f4f';
+$GLOBALS['csstidy']['replace_colors']['darkturquoise'] = '#00ced1';
+$GLOBALS['csstidy']['replace_colors']['darkviolet'] = '#9400d3';
+$GLOBALS['csstidy']['replace_colors']['deeppink'] = '#ff1493';
+$GLOBALS['csstidy']['replace_colors']['deepskyblue'] = '#00bfff';
+$GLOBALS['csstidy']['replace_colors']['dimgray'] = '#696969';
+$GLOBALS['csstidy']['replace_colors']['dodgerblue'] = '#1e90ff';
+$GLOBALS['csstidy']['replace_colors']['feldspar'] = '#d19275';
+$GLOBALS['csstidy']['replace_colors']['firebrick'] = '#b22222';
+$GLOBALS['csstidy']['replace_colors']['floralwhite'] = '#fffaf0';
+$GLOBALS['csstidy']['replace_colors']['forestgreen'] = '#228b22';
+$GLOBALS['csstidy']['replace_colors']['gainsboro'] = '#dcdcdc';
+$GLOBALS['csstidy']['replace_colors']['ghostwhite'] = '#f8f8ff';
+$GLOBALS['csstidy']['replace_colors']['gold'] = '#ffd700';
+$GLOBALS['csstidy']['replace_colors']['goldenrod'] = '#daa520';
+$GLOBALS['csstidy']['replace_colors']['greenyellow'] = '#adff2f';
+$GLOBALS['csstidy']['replace_colors']['honeydew'] = '#f0fff0';
+$GLOBALS['csstidy']['replace_colors']['hotpink'] = '#ff69b4';
+$GLOBALS['csstidy']['replace_colors']['indianred'] = '#cd5c5c';
+$GLOBALS['csstidy']['replace_colors']['indigo'] = '#4b0082';
+$GLOBALS['csstidy']['replace_colors']['ivory'] = '#fffff0';
+$GLOBALS['csstidy']['replace_colors']['khaki'] = '#f0e68c';
+$GLOBALS['csstidy']['replace_colors']['lavender'] = '#e6e6fa';
+$GLOBALS['csstidy']['replace_colors']['lavenderblush'] = '#fff0f5';
+$GLOBALS['csstidy']['replace_colors']['lawngreen'] = '#7cfc00';
+$GLOBALS['csstidy']['replace_colors']['lemonchiffon'] = '#fffacd';
+$GLOBALS['csstidy']['replace_colors']['lightblue'] = '#add8e6';
+$GLOBALS['csstidy']['replace_colors']['lightcoral'] = '#f08080';
+$GLOBALS['csstidy']['replace_colors']['lightcyan'] = '#e0ffff';
$GLOBALS['csstidy']['replace_colors']['lightgoldenrodyellow'] = '#fafad2';
-$GLOBALS['csstidy']['replace_colors']['lightgrey'] = '#d3d3d3';
-$GLOBALS['csstidy']['replace_colors']['lightgreen'] = '#90ee90';
-$GLOBALS['csstidy']['replace_colors']['lightpink'] = '#ffb6c1';
-$GLOBALS['csstidy']['replace_colors']['lightsalmon'] = '#ffa07a';
-$GLOBALS['csstidy']['replace_colors']['lightseagreen'] = '#20b2aa';
-$GLOBALS['csstidy']['replace_colors']['lightskyblue'] = '#87cefa';
-$GLOBALS['csstidy']['replace_colors']['lightslateblue'] = '#8470ff';
-$GLOBALS['csstidy']['replace_colors']['lightslategray'] = '#778899';
-$GLOBALS['csstidy']['replace_colors']['lightsteelblue'] = '#b0c4de';
-$GLOBALS['csstidy']['replace_colors']['lightyellow'] = '#ffffe0';
-$GLOBALS['csstidy']['replace_colors']['limegreen'] = '#32cd32';
-$GLOBALS['csstidy']['replace_colors']['linen'] = '#faf0e6';
-$GLOBALS['csstidy']['replace_colors']['magenta'] = '#ff00ff';
-$GLOBALS['csstidy']['replace_colors']['mediumaquamarine'] = '#66cdaa';
-$GLOBALS['csstidy']['replace_colors']['mediumblue'] = '#0000cd';
-$GLOBALS['csstidy']['replace_colors']['mediumorchid'] = '#ba55d3';
-$GLOBALS['csstidy']['replace_colors']['mediumpurple'] = '#9370d8';
-$GLOBALS['csstidy']['replace_colors']['mediumseagreen'] = '#3cb371';
-$GLOBALS['csstidy']['replace_colors']['mediumslateblue'] = '#7b68ee';
-$GLOBALS['csstidy']['replace_colors']['mediumspringgreen'] = '#00fa9a';
-$GLOBALS['csstidy']['replace_colors']['mediumturquoise'] = '#48d1cc';
-$GLOBALS['csstidy']['replace_colors']['mediumvioletred'] = '#c71585';
-$GLOBALS['csstidy']['replace_colors']['midnightblue'] = '#191970';
-$GLOBALS['csstidy']['replace_colors']['mintcream'] = '#f5fffa';
-$GLOBALS['csstidy']['replace_colors']['mistyrose'] = '#ffe4e1';
-$GLOBALS['csstidy']['replace_colors']['moccasin'] = '#ffe4b5';
-$GLOBALS['csstidy']['replace_colors']['navajowhite'] = '#ffdead';
-$GLOBALS['csstidy']['replace_colors']['oldlace'] = '#fdf5e6';
-$GLOBALS['csstidy']['replace_colors']['olivedrab'] = '#6b8e23';
-$GLOBALS['csstidy']['replace_colors']['orangered'] = '#ff4500';
-$GLOBALS['csstidy']['replace_colors']['orchid'] = '#da70d6';
-$GLOBALS['csstidy']['replace_colors']['palegoldenrod'] = '#eee8aa';
-$GLOBALS['csstidy']['replace_colors']['palegreen'] = '#98fb98';
-$GLOBALS['csstidy']['replace_colors']['paleturquoise'] = '#afeeee';
-$GLOBALS['csstidy']['replace_colors']['palevioletred'] = '#d87093';
-$GLOBALS['csstidy']['replace_colors']['papayawhip'] = '#ffefd5';
-$GLOBALS['csstidy']['replace_colors']['peachpuff'] = '#ffdab9';
-$GLOBALS['csstidy']['replace_colors']['peru'] = '#cd853f';
-$GLOBALS['csstidy']['replace_colors']['pink'] = '#ffc0cb';
-$GLOBALS['csstidy']['replace_colors']['plum'] = '#dda0dd';
-$GLOBALS['csstidy']['replace_colors']['powderblue'] = '#b0e0e6';
-$GLOBALS['csstidy']['replace_colors']['rosybrown'] = '#bc8f8f';
-$GLOBALS['csstidy']['replace_colors']['royalblue'] = '#4169e1';
-$GLOBALS['csstidy']['replace_colors']['saddlebrown'] = '#8b4513';
-$GLOBALS['csstidy']['replace_colors']['salmon'] = '#fa8072';
-$GLOBALS['csstidy']['replace_colors']['sandybrown'] = '#f4a460';
-$GLOBALS['csstidy']['replace_colors']['seagreen'] = '#2e8b57';
-$GLOBALS['csstidy']['replace_colors']['seashell'] = '#fff5ee';
-$GLOBALS['csstidy']['replace_colors']['sienna'] = '#a0522d';
-$GLOBALS['csstidy']['replace_colors']['skyblue'] = '#87ceeb';
-$GLOBALS['csstidy']['replace_colors']['slateblue'] = '#6a5acd';
-$GLOBALS['csstidy']['replace_colors']['slategray'] = '#708090';
-$GLOBALS['csstidy']['replace_colors']['snow'] = '#fffafa';
-$GLOBALS['csstidy']['replace_colors']['springgreen'] = '#00ff7f';
-$GLOBALS['csstidy']['replace_colors']['steelblue'] = '#4682b4';
-$GLOBALS['csstidy']['replace_colors']['tan'] = '#d2b48c';
-$GLOBALS['csstidy']['replace_colors']['thistle'] = '#d8bfd8';
-$GLOBALS['csstidy']['replace_colors']['tomato'] = '#ff6347';
-$GLOBALS['csstidy']['replace_colors']['turquoise'] = '#40e0d0';
-$GLOBALS['csstidy']['replace_colors']['violet'] = '#ee82ee';
-$GLOBALS['csstidy']['replace_colors']['violetred'] = '#d02090';
-$GLOBALS['csstidy']['replace_colors']['wheat'] = '#f5deb3';
-$GLOBALS['csstidy']['replace_colors']['whitesmoke'] = '#f5f5f5';
-$GLOBALS['csstidy']['replace_colors']['yellowgreen'] = '#9acd32';
+$GLOBALS['csstidy']['replace_colors']['lightgrey'] = '#d3d3d3';
+$GLOBALS['csstidy']['replace_colors']['lightgreen'] = '#90ee90';
+$GLOBALS['csstidy']['replace_colors']['lightpink'] = '#ffb6c1';
+$GLOBALS['csstidy']['replace_colors']['lightsalmon'] = '#ffa07a';
+$GLOBALS['csstidy']['replace_colors']['lightseagreen'] = '#20b2aa';
+$GLOBALS['csstidy']['replace_colors']['lightskyblue'] = '#87cefa';
+$GLOBALS['csstidy']['replace_colors']['lightslateblue'] = '#8470ff';
+$GLOBALS['csstidy']['replace_colors']['lightslategray'] = '#778899';
+$GLOBALS['csstidy']['replace_colors']['lightsteelblue'] = '#b0c4de';
+$GLOBALS['csstidy']['replace_colors']['lightyellow'] = '#ffffe0';
+$GLOBALS['csstidy']['replace_colors']['limegreen'] = '#32cd32';
+$GLOBALS['csstidy']['replace_colors']['linen'] = '#faf0e6';
+$GLOBALS['csstidy']['replace_colors']['magenta'] = '#ff00ff';
+$GLOBALS['csstidy']['replace_colors']['mediumaquamarine'] = '#66cdaa';
+$GLOBALS['csstidy']['replace_colors']['mediumblue'] = '#0000cd';
+$GLOBALS['csstidy']['replace_colors']['mediumorchid'] = '#ba55d3';
+$GLOBALS['csstidy']['replace_colors']['mediumpurple'] = '#9370d8';
+$GLOBALS['csstidy']['replace_colors']['mediumseagreen'] = '#3cb371';
+$GLOBALS['csstidy']['replace_colors']['mediumslateblue'] = '#7b68ee';
+$GLOBALS['csstidy']['replace_colors']['mediumspringgreen'] = '#00fa9a';
+$GLOBALS['csstidy']['replace_colors']['mediumturquoise'] = '#48d1cc';
+$GLOBALS['csstidy']['replace_colors']['mediumvioletred'] = '#c71585';
+$GLOBALS['csstidy']['replace_colors']['midnightblue'] = '#191970';
+$GLOBALS['csstidy']['replace_colors']['mintcream'] = '#f5fffa';
+$GLOBALS['csstidy']['replace_colors']['mistyrose'] = '#ffe4e1';
+$GLOBALS['csstidy']['replace_colors']['moccasin'] = '#ffe4b5';
+$GLOBALS['csstidy']['replace_colors']['navajowhite'] = '#ffdead';
+$GLOBALS['csstidy']['replace_colors']['oldlace'] = '#fdf5e6';
+$GLOBALS['csstidy']['replace_colors']['olivedrab'] = '#6b8e23';
+$GLOBALS['csstidy']['replace_colors']['orangered'] = '#ff4500';
+$GLOBALS['csstidy']['replace_colors']['orchid'] = '#da70d6';
+$GLOBALS['csstidy']['replace_colors']['palegoldenrod'] = '#eee8aa';
+$GLOBALS['csstidy']['replace_colors']['palegreen'] = '#98fb98';
+$GLOBALS['csstidy']['replace_colors']['paleturquoise'] = '#afeeee';
+$GLOBALS['csstidy']['replace_colors']['palevioletred'] = '#d87093';
+$GLOBALS['csstidy']['replace_colors']['papayawhip'] = '#ffefd5';
+$GLOBALS['csstidy']['replace_colors']['peachpuff'] = '#ffdab9';
+$GLOBALS['csstidy']['replace_colors']['peru'] = '#cd853f';
+$GLOBALS['csstidy']['replace_colors']['pink'] = '#ffc0cb';
+$GLOBALS['csstidy']['replace_colors']['plum'] = '#dda0dd';
+$GLOBALS['csstidy']['replace_colors']['powderblue'] = '#b0e0e6';
+$GLOBALS['csstidy']['replace_colors']['rosybrown'] = '#bc8f8f';
+$GLOBALS['csstidy']['replace_colors']['royalblue'] = '#4169e1';
+$GLOBALS['csstidy']['replace_colors']['saddlebrown'] = '#8b4513';
+$GLOBALS['csstidy']['replace_colors']['salmon'] = '#fa8072';
+$GLOBALS['csstidy']['replace_colors']['sandybrown'] = '#f4a460';
+$GLOBALS['csstidy']['replace_colors']['seagreen'] = '#2e8b57';
+$GLOBALS['csstidy']['replace_colors']['seashell'] = '#fff5ee';
+$GLOBALS['csstidy']['replace_colors']['sienna'] = '#a0522d';
+$GLOBALS['csstidy']['replace_colors']['skyblue'] = '#87ceeb';
+$GLOBALS['csstidy']['replace_colors']['slateblue'] = '#6a5acd';
+$GLOBALS['csstidy']['replace_colors']['slategray'] = '#708090';
+$GLOBALS['csstidy']['replace_colors']['snow'] = '#fffafa';
+$GLOBALS['csstidy']['replace_colors']['springgreen'] = '#00ff7f';
+$GLOBALS['csstidy']['replace_colors']['steelblue'] = '#4682b4';
+$GLOBALS['csstidy']['replace_colors']['tan'] = '#d2b48c';
+$GLOBALS['csstidy']['replace_colors']['thistle'] = '#d8bfd8';
+$GLOBALS['csstidy']['replace_colors']['tomato'] = '#ff6347';
+$GLOBALS['csstidy']['replace_colors']['turquoise'] = '#40e0d0';
+$GLOBALS['csstidy']['replace_colors']['violet'] = '#ee82ee';
+$GLOBALS['csstidy']['replace_colors']['violetred'] = '#d02090';
+$GLOBALS['csstidy']['replace_colors']['wheat'] = '#f5deb3';
+$GLOBALS['csstidy']['replace_colors']['whitesmoke'] = '#f5f5f5';
+$GLOBALS['csstidy']['replace_colors']['yellowgreen'] = '#9acd32';
/**
* A list of all shorthand properties that are divided into four properties and/or have four subvalues
@@ -277,12 +325,12 @@ $GLOBALS['csstidy']['replace_colors']['yellowgreen'] = '#9acd32';
* @see merge_4value_shorthands()
* @version 1.0
*/
-$GLOBALS['csstidy']['shorthands'] = array();
-$GLOBALS['csstidy']['shorthands']['border-color'] = array('border-top-color','border-right-color','border-bottom-color','border-left-color');
-$GLOBALS['csstidy']['shorthands']['border-style'] = array('border-top-style','border-right-style','border-bottom-style','border-left-style');
-$GLOBALS['csstidy']['shorthands']['border-width'] = array('border-top-width','border-right-width','border-bottom-width','border-left-width');
-$GLOBALS['csstidy']['shorthands']['margin'] = array('margin-top','margin-right','margin-bottom','margin-left');
-$GLOBALS['csstidy']['shorthands']['padding'] = array('padding-top','padding-right','padding-bottom','padding-left');
+$GLOBALS['csstidy']['shorthands'] = array();
+$GLOBALS['csstidy']['shorthands']['border-color'] = array( 'border-top-color', 'border-right-color', 'border-bottom-color', 'border-left-color' );
+$GLOBALS['csstidy']['shorthands']['border-style'] = array( 'border-top-style', 'border-right-style', 'border-bottom-style', 'border-left-style' );
+$GLOBALS['csstidy']['shorthands']['border-width'] = array( 'border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width' );
+$GLOBALS['csstidy']['shorthands']['margin'] = array( 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' );
+$GLOBALS['csstidy']['shorthands']['padding'] = array( 'padding-top', 'padding-right', 'padding-bottom', 'padding-left' );
$GLOBALS['csstidy']['shorthands']['-moz-border-radius'] = 0;
/**
@@ -293,363 +341,367 @@ $GLOBALS['csstidy']['shorthands']['-moz-border-radius'] = 0;
* @version 1.0
* @see csstidy::property_is_next()
*/
-$GLOBALS['csstidy']['all_properties']['align-content'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['align-items'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['align-self'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['alignment-adjust'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['alignment-baseline'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['animation'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['animation-delay'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['animation-direction'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['animation-duration'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['animation-fill-mode'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['animation-iteration-count'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['animation-name'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['animation-play-state'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['animation-timing-function'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['appearance'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['azimuth'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['backface-visibility'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['background'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['background-attachment'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['background-clip'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['background-color'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['background-image'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['background-origin'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['background-position'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['background-repeat'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['background-size'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['baseline-shift'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['binding'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['bleed'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['bookmark-label'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['bookmark-level'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['bookmark-state'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['bookmark-target'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-bottom'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-bottom-color'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-bottom-left-radius'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-bottom-right-radius'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-bottom-style'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-bottom-width'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-collapse'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-color'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-image'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-image-outset'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-image-repeat'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-image-slice'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-image-source'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-image-width'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-left'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-left-color'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-left-style'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-left-width'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-radius'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-right'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-right-color'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-right-style'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-right-width'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-spacing'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-style'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-top'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-top-color'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-top-left-radius'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-top-right-radius'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-top-style'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-top-width'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['border-width'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['bottom'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['box-decoration-break'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['box-shadow'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['box-sizing'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['break-after'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['break-before'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['break-inside'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['caption-side'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['clear'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['clip'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['clip-path'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['color'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['color-profile'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['column-count'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['column-fill'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['column-gap'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['column-rule'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['column-rule-color'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['column-rule-style'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['column-rule-width'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['column-span'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['column-width'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['columns'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['content'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['counter-increment'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['counter-reset'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['crop'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['cue'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['cue-after'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['cue-before'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['cursor'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['direction'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['display'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['dominant-baseline'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['drop-initial-after-adjust'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['drop-initial-after-align'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['drop-initial-before-adjust'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['drop-initial-before-align'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['drop-initial-size'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['drop-initial-value'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['elevation'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['empty-cells'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['fill'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['fit'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['fit-position'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['flex'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['flex-align'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['flex-basis'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['flex-direction'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['flex-flow'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['flex-grow'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['flex-line-pack'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['flex-order'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['flex-pack'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['flex-shrink'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['flex-wrap'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['float'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['float-offset'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-family'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-size'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-size-adjust'] = 'CSS2.0,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-stretch'] = 'CSS2.0,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-style'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-variant'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['font-weight'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-area'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-auto-columns'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-auto-flow'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-auto-rows'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-column'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-columns'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-column-end'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-column-gap'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-column-start'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-gap'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-row'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-rows'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-row-end'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-row-gap'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-row-start'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-template'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-template-areas'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-template-columns'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['grid-template-rows'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['hanging-punctuation'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['height'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['hyphenate-after'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['hyphenate-before'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['hyphenate-character'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['hyphenate-lines'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['hyphenate-resource'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['hyphens'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['icon'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['image-orientation'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['image-rendering'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['image-resolution'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['inline-box-align'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['justify-content'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['justify-items'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['justify-self'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['left'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['letter-spacing'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['line-break'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['line-height'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['line-stacking'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['line-stacking-ruby'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['line-stacking-shift'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['line-stacking-strategy'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['list-style'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['list-style-image'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['list-style-position'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['list-style-type'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['margin'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['margin-bottom'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['margin-left'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['margin-right'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['margin-top'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['marker-offset'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['marks'] = 'CSS2.0,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['marquee-direction'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['marquee-loop'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['marquee-play-count'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['marquee-speed'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['marquee-style'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['mask-clip'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['mask-composite'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['mask-image'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['mask-mode'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['mask-origin'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['mask-position'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['mask-repeat'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['mask-size'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['max-height'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['max-width'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['min-height'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['min-width'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['move-to'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['nav-down'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['nav-index'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['nav-left'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['nav-right'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['nav-up'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['object-fit'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['object-position'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['opacity'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['order'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['orphans'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['outline'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['outline-color'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['outline-offset'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['outline-style'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['outline-width'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['overflow'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['overflow-style'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['overflow-wrap'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['overflow-x'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['overflow-y'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['padding'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['padding-bottom'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['padding-left'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['padding-right'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['padding-top'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['page'] = 'CSS2.0,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['page-break-after'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['page-break-before'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['page-break-inside'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['page-policy'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['pause'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['pause-after'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['pause-before'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['perspective'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['perspective-origin'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['phonemes'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['pitch'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['pitch-range'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['play-during'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['position'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['presentation-level'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['punctuation-trim'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['quotes'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['rendering-intent'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['resize'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['rest'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['rest-after'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['rest-before'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['richness'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['right'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['rotation'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['rotation-point'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['ruby-align'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['ruby-overhang'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['ruby-position'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['ruby-span'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-behavior'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-margin'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-margin-block'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-margin-block-end'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-margin-block-start'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-margin-bottom'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-margin-inline'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-margin-inline-end'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-margin-inline-start'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-margin-left'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-margin-right'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-margin-top'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-padding'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-padding-block'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-padding-block-end'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-padding-block-start'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-padding-bottom'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-padding-inline'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-padding-inline-end'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['accent-color'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['align-content'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['align-items'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['align-self'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['alignment-adjust'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['alignment-baseline'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['animation'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['animation-delay'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['animation-direction'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['animation-duration'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['animation-fill-mode'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['animation-iteration-count'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['animation-name'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['animation-play-state'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['animation-timing-function'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['appearance'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['aspect-ratio'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['azimuth'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['backface-visibility'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['background'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['background-attachment'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['background-clip'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['background-color'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['background-image'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['background-origin'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['background-position'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['background-repeat'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['background-size'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['baseline-shift'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['binding'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['bleed'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['bookmark-label'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['bookmark-level'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['bookmark-state'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['bookmark-target'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-bottom'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-bottom-color'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-bottom-left-radius'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-bottom-right-radius'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-bottom-style'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-bottom-width'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-collapse'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-color'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-image'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-image-outset'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-image-repeat'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-image-slice'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-image-source'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-image-width'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-left'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-left-color'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-left-style'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-left-width'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-radius'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-right'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-right-color'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-right-style'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-right-width'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-spacing'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-style'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-top'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-top-color'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-top-left-radius'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-top-right-radius'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-top-style'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-top-width'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['border-width'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['bottom'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['box-decoration-break'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['box-shadow'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['box-sizing'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['break-after'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['break-before'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['break-inside'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['caption-side'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['clear'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['clip'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['clip-path'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['color'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['color-profile'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['column-count'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['column-fill'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['column-gap'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['column-rule'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['column-rule-color'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['column-rule-style'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['column-rule-width'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['column-span'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['column-width'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['columns'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['content'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['counter-increment'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['counter-reset'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['crop'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['cue'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['cue-after'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['cue-before'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['cursor'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['direction'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['display'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['dominant-baseline'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['drop-initial-after-adjust'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['drop-initial-after-align'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['drop-initial-before-adjust'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['drop-initial-before-align'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['drop-initial-size'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['drop-initial-value'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['elevation'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['empty-cells'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['fill'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['fit'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['fit-position'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['flex'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['flex-align'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['flex-basis'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['flex-direction'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['flex-flow'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['flex-grow'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['flex-line-pack'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['flex-order'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['flex-pack'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['flex-shrink'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['flex-wrap'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['float'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['float-offset'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-family'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-size'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-size-adjust'] = 'CSS2.0,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-stretch'] = 'CSS2.0,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-style'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-variant'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['font-weight'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['gap'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-area'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-auto-columns'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-auto-flow'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-auto-rows'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-column'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-columns'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-column-end'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-column-gap'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-column-start'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-gap'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-row'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-rows'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-row-end'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-row-gap'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-row-start'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-template'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-template-areas'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-template-columns'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['grid-template-rows'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['hanging-punctuation'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['height'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['hyphenate-after'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['hyphenate-before'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['hyphenate-character'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['hyphenate-lines'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['hyphenate-resource'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['hyphens'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['icon'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['image-orientation'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['image-rendering'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['image-resolution'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['inline-box-align'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['justify-content'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['justify-items'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['justify-self'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['left'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['letter-spacing'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['line-break'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['line-height'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['line-stacking'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['line-stacking-ruby'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['line-stacking-shift'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['line-stacking-strategy'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['list-style'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['list-style-image'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['list-style-position'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['list-style-type'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['margin'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['margin-bottom'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['margin-left'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['margin-right'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['margin-top'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['marker-offset'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['marks'] = 'CSS2.0,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['marquee-direction'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['marquee-loop'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['marquee-play-count'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['marquee-speed'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['marquee-style'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['mask-clip'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['mask-composite'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['mask-image'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['mask-mode'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['mask-origin'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['mask-position'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['mask-repeat'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['mask-size'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['max-height'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['max-width'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['min-height'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['min-width'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['move-to'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['nav-down'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['nav-index'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['nav-left'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['nav-right'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['nav-up'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['object-fit'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['object-position'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['opacity'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['order'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['orphans'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['outline'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['outline-color'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['outline-offset'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['outline-style'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['outline-width'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['overflow'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['overflow-style'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['overflow-wrap'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['overflow-x'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['overflow-y'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['padding'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['padding-bottom'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['padding-left'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['padding-right'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['padding-top'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['page'] = 'CSS2.0,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['page-break-after'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['page-break-before'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['page-break-inside'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['page-policy'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['pause'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['pause-after'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['pause-before'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['perspective'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['perspective-origin'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['phonemes'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['pitch'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['pitch-range'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['play-during'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['position'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['presentation-level'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['punctuation-trim'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['quotes'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['rendering-intent'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['resize'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['rest'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['rest-after'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['rest-before'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['richness'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['right'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['rotation'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['rotation-point'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['ruby-align'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['ruby-overhang'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['ruby-position'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['ruby-span'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-behavior'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-margin'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-margin-block'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-margin-block-end'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-margin-block-start'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-margin-bottom'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-margin-inline'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-margin-inline-end'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-margin-inline-start'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-margin-left'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-margin-right'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-margin-top'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-padding'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-padding-block'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-padding-block-end'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-padding-block-start'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-padding-bottom'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-padding-inline'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-padding-inline-end'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['scroll-padding-inline-start'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-padding-left'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-padding-right'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-padding-top'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-snap-align'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['scroll-snap-stop'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['size'] = 'CSS2.0,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['speak'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['speak-header'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['speak-numeral'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['speak-punctuation'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['speech-rate'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['src'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['stress'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['string-set'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['stroke'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['tab-size'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['table-layout'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['target'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['target-name'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['target-new'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['target-position'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-align'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-align-last'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-decoration'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-decoration-color'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-decoration-line'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-decoration-skip'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-decoration-style'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-emphasis'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-emphasis-color'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-emphasis-position'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-emphasis-style'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-height'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-indent'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-justify'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-outline'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-shadow'] = 'CSS2.0,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-space-collapse'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-transform'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-underline-position'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['text-wrap'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['top'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['transform'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['transform-origin'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['transform-style'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['transition'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['transition-delay'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['transition-duration'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['transition-property'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['transition-timing-function'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['unicode-bidi'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['vertical-align'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['visibility'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['voice-balance'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['voice-duration'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['voice-family'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['voice-pitch'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['voice-pitch-range'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['voice-rate'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['voice-stress'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['voice-volume'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['volume'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['white-space'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['widows'] = 'CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['width'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['word-break'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['word-spacing'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
-$GLOBALS['csstidy']['all_properties']['word-wrap'] = 'CSS3.0';
-$GLOBALS['csstidy']['all_properties']['z-index'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-padding-left'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-padding-right'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-padding-top'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-snap-align'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['scroll-snap-stop'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['size'] = 'CSS2.0,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['speak'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['speak-header'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['speak-numeral'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['speak-punctuation'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['speech-rate'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['src'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['stress'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['string-set'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['stroke'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['tab-size'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['table-layout'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['target'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['target-name'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['target-new'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['target-position'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-align'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-align-last'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-decoration'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-decoration-color'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-decoration-line'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-decoration-skip'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-decoration-style'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-emphasis'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-emphasis-color'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-emphasis-position'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-emphasis-style'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-height'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-indent'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-justify'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-outline'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-shadow'] = 'CSS2.0,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-space-collapse'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-transform'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-underline-offset'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-underline-position'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['text-wrap'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['top'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['transform'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['transform-origin'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['transform-style'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['transition'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['transition-delay'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['transition-duration'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['transition-property'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['transition-timing-function'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['unicode-bidi'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['vertical-align'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['visibility'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['voice-balance'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['voice-duration'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['voice-family'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['voice-pitch'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['voice-pitch-range'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['voice-rate'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['voice-stress'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['voice-volume'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['volume'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['white-space'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['widows'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['width'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['word-break'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['word-spacing'] = 'CSS1.0,CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['word-wrap'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['z-index'] = 'CSS2.0,CSS2.1,CSS3.0';
/**
* An array containing all properties that can accept a quoted string as a value.
*
* @global array $GLOBALS['csstidy']['quoted_string_properties']
*/
-$GLOBALS['csstidy']['quoted_string_properties'] = array('content', 'font', 'font-family', 'quotes');
+$GLOBALS['csstidy']['quoted_string_properties'] = array( 'content', 'font', 'font-family', 'quotes' );
/**
* An array containing all properties that can be defined multiple times without being overwritten.
@@ -666,23 +718,23 @@ $GLOBALS['csstidy']['multiple_properties'] = array_merge( $GLOBALS['csstidy']['c
* @version 1.0
* @see csstidy::load_template()
*/
-$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="at">'; //string before @rule
-$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span> <span class="format">{</span>'."\n"; //bracket after @-rule
-$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="selector">'; //string before selector
-$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span> <span class="format">{</span>'."\n"; //bracket after selector
-$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="property">'; //string before property
-$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span><span class="value">'; //string after property+before value
-$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span><span class="format">;</span>'."\n"; //string after value
-$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="format">}</span>'; //closing bracket - selector
-$GLOBALS['csstidy']['predefined_templates']['default'][] = "\n\n"; //space between blocks {...}
-$GLOBALS['csstidy']['predefined_templates']['default'][] = "\n".'<span class="format">}</span>'. "\n\n"; //closing bracket @-rule
-$GLOBALS['csstidy']['predefined_templates']['default'][] = ''; //indent in @-rule
+$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="at">'; // string before @rule
+$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span> <span class="format">{</span>' . "\n"; // bracket after @-rule
+$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="selector">'; // string before selector
+$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span> <span class="format">{</span>' . "\n"; // bracket after selector
+$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="property">'; // string before property
+$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span><span class="value">'; // string after property+before value
+$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span><span class="format">;</span>' . "\n"; // string after value
+$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="format">}</span>'; // closing bracket - selector
+$GLOBALS['csstidy']['predefined_templates']['default'][] = "\n\n"; // space between blocks {...}
+$GLOBALS['csstidy']['predefined_templates']['default'][] = "\n" . '<span class="format">}</span>' . "\n\n"; // closing bracket @-rule
+$GLOBALS['csstidy']['predefined_templates']['default'][] = ''; // indent in @-rule
$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="comment">'; // before comment
-$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span>'."\n"; // after comment
+$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span>' . "\n"; // after comment
$GLOBALS['csstidy']['predefined_templates']['default'][] = "\n"; // after last line @-rule
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="at">';
-$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span> <span class="format">{</span>'."\n";
+$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span> <span class="format">{</span>' . "\n";
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="selector">';
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span><span class="format">{</span>';
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="property">';
@@ -690,7 +742,7 @@ $GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span><spa
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span><span class="format">;</span>';
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="format">}</span>';
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = "\n";
-$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = "\n". '<span class="format">}'."\n".'</span>';
+$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = "\n" . '<span class="format">}' . "\n" . '</span>';
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '';
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="comment">'; // before comment
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span>'; // after comment
@@ -712,18 +764,18 @@ $GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '</span>'
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '';
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class="at">';
-$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span> <span class="format">{</span>'."\n";
+$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span> <span class="format">{</span>' . "\n";
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class="selector">';
-$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span>'."\n".'<span class="format">{</span>'."\n";
+$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span>' . "\n" . '<span class="format">{</span>' . "\n";
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = ' <span class="property">';
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span><span class="value">';
-$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span><span class="format">;</span>'."\n";
+$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span><span class="format">;</span>' . "\n";
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class="format">}</span>';
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = "\n\n";
-$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = "\n".'<span class="format">}</span>'."\n\n";
+$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = "\n" . '<span class="format">}</span>' . "\n\n";
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = ' ';
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class="comment">'; // before comment
-$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span>'."\n"; // after comment
+$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span>' . "\n"; // after comment
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = "\n";
-require dirname( __FILE__ ) . '/data-wp.inc.php';
+require __DIR__ . '/data-wp.inc.php';
diff --git a/plugins/jetpack/modules/custom-css/csstidy/lang.inc.php b/plugins/jetpack/modules/custom-css/csstidy/lang.inc.php
index 0a3ad014..f35bc8d8 100644
--- a/plugins/jetpack/modules/custom-css/csstidy/lang.inc.php
+++ b/plugins/jetpack/modules/custom-css/csstidy/lang.inc.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Localization of CSS Optimiser Interface of CSSTidy
*
@@ -22,33 +21,32 @@
*
* @license https://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
* @package csstidy
- * @author Florian Schmitz (floele at gmail dot com) 2005-2007
- * @author Brett Zamir (brettz9 at yahoo dot com) 2007
+ * @author Florian Schmitz (floele at gmail dot com) 2005-2007, Brett Zamir (brettz9 at yahoo dot com) 2007
*/
-if ( isset( $_GET['lang'] ) ) {
- $l = $_GET['lang'];
+if ( isset( $_GET['lang'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site, determening language for translations.
+ $l = sanitize_text_field( wp_unslash( $_GET['lang'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site, determining language for translations.
} elseif ( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
- $l = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
+ $l = filter_var( wp_unslash( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) );
$l = strtolower( substr( $l, 0, 2 ) );
} else {
$l = '';
}
-$l = ( in_array( $l, array( 'de', 'fr', 'zh' ) ) ) ? $l : 'en';
+$l = ( in_array( $l, array( 'de', 'fr', 'zh' ), true ) ) ? $l : 'en';
// note 5 in all but French, and 40 in all are orphaned
-$lang = array();
-$lang['en'][0] = 'CSS Formatter and Optimiser/Optimizer (based on CSSTidy ';
-$lang['en'][1] = 'CSS Formatter and Optimiser';
-$lang['en'][2] = '(based on';
-$lang['en'][3] = '(plaintext)';
-$lang['en'][4] = 'Important Note:';
-$lang['en'][6] = 'Your code should be well-formed. This is <strong>not a validator</strong> which points out errors in your CSS code. To make sure that your code is valid, use the <a href="https://jigsaw.w3.org/css-validator/">W3C Validator</a>.';
-$lang['en'][7] = 'all comments are removed';
-$lang['en'][8] = 'CSS Input:';
-$lang['en'][9] = 'CSS-Code:';
+$lang = array();
+$lang['en'][0] = 'CSS Formatter and Optimiser/Optimizer (based on CSSTidy ';
+$lang['en'][1] = 'CSS Formatter and Optimiser';
+$lang['en'][2] = '(based on';
+$lang['en'][3] = '(plaintext)';
+$lang['en'][4] = 'Important Note:';
+$lang['en'][6] = 'Your code should be well-formed. This is <strong>not a validator</strong> which points out errors in your CSS code. To make sure that your code is valid, use the <a href="https://jigsaw.w3.org/css-validator/">W3C Validator</a>.';
+$lang['en'][7] = 'all comments are removed';
+$lang['en'][8] = 'CSS Input:';
+$lang['en'][9] = 'CSS-Code:';
$lang['en'][10] = 'CSS from URL:';
$lang['en'][11] = 'Code Layout:';
$lang['en'][12] = 'Compression&#160;(code&#160;layout):';
@@ -106,16 +104,15 @@ $lang['en'][64] = 'Code';
$lang['en'][65] = 'CSS to style CSS output';
$lang['en'][66] = 'You need to go to about:config in your URL bar, select \'signed.applets.codebase_principal_support\' in the filter field, and set its value to true in order to use this feature; however, be aware that doing so increases security risks.';
-
-$lang['de'][0] = 'CSS Formatierer und Optimierer (basierend auf CSSTidy ';
-$lang['de'][1] = 'CSS Formatierer und Optimierer';
-$lang['de'][2] = '(basierend auf';
-$lang['de'][3] = '(Textversion)';
-$lang['de'][4] = 'Wichtiger Hinweis:';
-$lang['de'][6] = 'Der CSS Code sollte wohlgeformt sein. Der CSS Code wird <strong>nicht auf Gültigkeit überprüft</strong>. Um sicherzugehen dass dein Code valide ist, benutze den <a href="https://jigsaw.w3.org/css-validator/">W3C Validierungsservice</a>.';
-$lang['de'][7] = 'alle Kommentare werden entfernt';
-$lang['de'][8] = 'CSS Eingabe:';
-$lang['de'][9] = 'CSS-Code:';
+$lang['de'][0] = 'CSS Formatierer und Optimierer (basierend auf CSSTidy ';
+$lang['de'][1] = 'CSS Formatierer und Optimierer';
+$lang['de'][2] = '(basierend auf';
+$lang['de'][3] = '(Textversion)';
+$lang['de'][4] = 'Wichtiger Hinweis:';
+$lang['de'][6] = 'Der CSS Code sollte wohlgeformt sein. Der CSS Code wird <strong>nicht auf Gültigkeit überprüft</strong>. Um sicherzugehen dass dein Code valide ist, benutze den <a href="https://jigsaw.w3.org/css-validator/">W3C Validierungsservice</a>.';
+$lang['de'][7] = 'alle Kommentare werden entfernt';
+$lang['de'][8] = 'CSS Eingabe:';
+$lang['de'][9] = 'CSS-Code:';
$lang['de'][10] = 'CSS von URL:';
$lang['de'][11] = 'Code Layout:';
$lang['de'][12] = 'Komprimierung&#160;(Code&#160;Layout):';
@@ -173,16 +170,15 @@ $lang['de'][64] = 'Code';
$lang['de'][65] = 'CSS to style CSS output';
$lang['de'][66] = 'You need to go to about:config in your URL bar, select \'signed.applets.codebase_principal_support\' in the filter field, and set its value to true in order to use this feature; however, be aware that doing so increases security risks.';
-
-$lang['fr'][0] = 'CSS Formatteur et Optimiseur (basé sur CSSTidy ';
-$lang['fr'][1] = 'CSS Formatteur et Optimiseur';
-$lang['fr'][2] = '(basé sur ';
-$lang['fr'][3] = '(Version texte)';
-$lang['fr'][4] = 'Note Importante&#160;:';
-$lang['fr'][6] = 'Votre code doit être valide. Ce n’est <strong>pas un validateur</strong> qui signale les erreurs dans votre code CSS. Pour être sûr que votre code est correct, utilisez le validateur&#160;: <a href="https://jigsaw.w3.org/css-validator/">W3C Validator</a>.';
-$lang['fr'][7] = 'tous les commentaires sont enlevés';
-$lang['fr'][8] = 'Champ CSS&#160;:';
-$lang['fr'][9] = 'Code CSS&#160;:';
+$lang['fr'][0] = 'CSS Formatteur et Optimiseur (basé sur CSSTidy ';
+$lang['fr'][1] = 'CSS Formatteur et Optimiseur';
+$lang['fr'][2] = '(basé sur ';
+$lang['fr'][3] = '(Version texte)';
+$lang['fr'][4] = 'Note Importante&#160;:';
+$lang['fr'][6] = 'Votre code doit être valide. Ce n’est <strong>pas un validateur</strong> qui signale les erreurs dans votre code CSS. Pour être sûr que votre code est correct, utilisez le validateur&#160;: <a href="https://jigsaw.w3.org/css-validator/">W3C Validator</a>.';
+$lang['fr'][7] = 'tous les commentaires sont enlevés';
+$lang['fr'][8] = 'Champ CSS&#160;:';
+$lang['fr'][9] = 'Code CSS&#160;:';
$lang['fr'][10] = 'CSS en provenance d’une URL&#160;:<br />';
$lang['fr'][11] = 'Mise en page du code&#160;:';
$lang['fr'][12] = 'Compression (mise en page du code)&#160;:';
@@ -240,16 +236,15 @@ $lang['fr'][64] = 'Code';
$lang['fr'][65] = 'CSS pour colorier la sortie CSS';
$lang['fr'][66] = 'Vous devez aller dans about:config dans votre barre d’adresse, selectionner \'signed.applets.codebase_principal_support\' dans le champ Filtre et attribuez-lui la valeur \'true\' pour utiliser cette fonctionnalité; toutefois, soyez conscient que cela augmente les risques de sécurité.';
-
-$lang['zh'][0] = 'CSS整形與最佳化工具(使用 CSSTidy ';
-$lang['zh'][1] = 'CSS整形與最佳化工具';
-$lang['zh'][2] = '(使用';
-$lang['zh'][3] = '(純文字)';
-$lang['zh'][4] = '重要事項:';
-$lang['zh'][6] = '你的原始碼必須是良構的(well-formed). 這個工具<strong>沒有內建驗證器(validator)</strong>. 驗證器能夠指出你CSS原始碼裡的錯誤. 請使用 <a href="https://jigsaw.w3.org/css-validator/">W3C 驗證器</a>, 確保你的原始碼合乎規範.';
-$lang['zh'][7] = '所有註解都移除了';
-$lang['zh'][8] = 'CSS 輸入:';
-$lang['zh'][9] = 'CSS 原始碼:';
+$lang['zh'][0] = 'CSS整形與最佳化工具(使用 CSSTidy ';
+$lang['zh'][1] = 'CSS整形與最佳化工具';
+$lang['zh'][2] = '(使用';
+$lang['zh'][3] = '(純文字)';
+$lang['zh'][4] = '重要事項:';
+$lang['zh'][6] = '你的原始碼必須是良構的(well-formed). 這個工具<strong>沒有內建驗證器(validator)</strong>. 驗證器能夠指出你CSS原始碼裡的錯誤. 請使用 <a href="https://jigsaw.w3.org/css-validator/">W3C 驗證器</a>, 確保你的原始碼合乎規範.';
+$lang['zh'][7] = '所有註解都移除了';
+$lang['zh'][8] = 'CSS 輸入:';
+$lang['zh'][9] = 'CSS 原始碼:';
$lang['zh'][10] = 'CSS 檔案網址(URL):';
$lang['zh'][11] = '原始碼規劃:';
$lang['zh'][12] = '壓縮程度(原始碼規劃):';
diff --git a/plugins/jetpack/modules/custom-css/custom-css-4.7.php b/plugins/jetpack/modules/custom-css/custom-css-4.7.php
index cdce3444..af635fcc 100644
--- a/plugins/jetpack/modules/custom-css/custom-css-4.7.php
+++ b/plugins/jetpack/modules/custom-css/custom-css-4.7.php
@@ -1,6 +1,7 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Assets;
+use Automattic\Jetpack\Blocks;
/**
* Alternate Custom CSS source for 4.7 compat.
@@ -20,12 +21,11 @@ class Jetpack_Custom_CSS_Enhancements {
*/
public static function add_hooks() {
add_action( 'init', array( __CLASS__, 'init' ) );
- add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ) );
add_action( 'customize_controls_enqueue_scripts', array( __CLASS__, 'customize_controls_enqueue_scripts' ) );
add_action( 'customize_register', array( __CLASS__, 'customize_register' ) );
add_filter( 'map_meta_cap', array( __CLASS__, 'map_meta_cap' ), 20, 2 );
add_action( 'customize_preview_init', array( __CLASS__, 'customize_preview_init' ) );
- add_filter( '_wp_post_revision_fields', array( __CLASS__, '_wp_post_revision_fields' ), 10, 2 );
+ add_filter( '_wp_post_revision_fields', array( __CLASS__, 'wp_post_revision_fields' ), 10, 2 );
add_action( 'load-revision.php', array( __CLASS__, 'load_revision_php' ) );
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'wp_enqueue_scripts' ) );
@@ -46,30 +46,49 @@ class Jetpack_Custom_CSS_Enhancements {
add_action( 'template_redirect', array( __CLASS__, 'set_content_width' ) );
add_action( 'admin_init', array( __CLASS__, 'set_content_width' ) );
- // Stuff?
+ // Remove the Customizer link from the menu to avoid additional confusion if the site is a FSE themed site.
+ if ( wp_is_block_theme() || Blocks::is_fse_theme() ) {
+ if ( isset( $_SERVER['REQUEST_URI'] ) ) {
+ add_action(
+ 'admin_menu',
+ function () {
+ remove_submenu_page(
+ 'themes.php',
+ add_query_arg(
+ 'return',
+ rawurlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ 'customize.php'
+ )
+ );
+ }
+ );
+ }
+ }
}
/**
* Things that we do on init.
*/
public static function init() {
- $min = '.min';
- if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
- $min = '';
- }
- wp_register_style( 'jetpack-codemirror', plugins_url( 'custom-css/css/codemirror.css', __FILE__ ), array(), '20120905' );
- wp_register_style( 'jetpack-customizer-css', plugins_url( 'custom-css/css/customizer-control.css', __FILE__ ), array(), '20140728' );
- wp_register_script( 'jetpack-codemirror', plugins_url( 'custom-css/js/codemirror.min.js', __FILE__ ), array(), '3.16', true );
+ wp_register_style( 'jetpack-codemirror', plugins_url( 'custom-css/css/codemirror.css', __FILE__ ), array(), '20120905' );
+ wp_register_style( 'jetpack-customizer-css', plugins_url( 'custom-css/css/customizer-control.css', __FILE__ ), array(), '20140728' );
+ wp_register_script( 'jetpack-codemirror', plugins_url( 'custom-css/js/codemirror.min.js', __FILE__ ), array(), '3.16', true );
- $src = Assets::get_file_url_for_environment(
+ $src = Assets::get_file_url_for_environment(
'_inc/build/custom-css/custom-css/js/core-customizer-css.core-4.9.min.js',
'modules/custom-css/custom-css/js/core-customizer-css.core-4.9.js'
);
- wp_register_script( 'jetpack-customizer-css', $src, array(
- 'customize-controls',
- 'underscore'
- ), JETPACK__VERSION, true );
+ wp_register_script(
+ 'jetpack-customizer-css',
+ $src,
+ array(
+ 'customize-controls',
+ 'underscore',
+ ),
+ JETPACK__VERSION,
+ true
+ );
wp_register_script(
'jetpack-customizer-css-preview',
@@ -86,7 +105,7 @@ class Jetpack_Custom_CSS_Enhancements {
remove_action( 'wp_head', 'wp_custom_css_cb', 101 );
add_action( 'wp_head', array( __CLASS__, 'wp_custom_css_cb' ), 101 );
- if ( isset( $_GET['custom-css'] ) ) {
+ if ( isset( $_GET['custom-css'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site.
self::print_linked_custom_css();
}
}
@@ -104,7 +123,7 @@ class Jetpack_Custom_CSS_Enhancements {
public static function print_linked_custom_css() {
header( 'Content-type: text/css' );
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + YEAR_IN_SECONDS ) . ' GMT' );
- echo wp_get_custom_css();
+ echo wp_get_custom_css(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
exit;
}
@@ -131,33 +150,6 @@ class Jetpack_Custom_CSS_Enhancements {
}
/**
- * Handle our admin menu item and legacy page declaration.
- */
- public static function admin_menu() {
- // Add in our legacy page to support old bookmarks and such.
- add_submenu_page( null, __( 'CSS', 'jetpack' ), __( 'Additional CSS', 'jetpack' ), 'edit_theme_options', 'editcss', array( __CLASS__, 'admin_page' ) );
-
- // Add in our new page slug that will redirect to the customizer.
- $hook = add_theme_page( __( 'CSS', 'jetpack' ), __( 'Additional CSS', 'jetpack' ), 'edit_theme_options', 'editcss-customizer-redirect', array( __CLASS__, 'admin_page' ) );
- add_action( "load-{$hook}", array( __CLASS__, 'customizer_redirect' ) );
- }
-
- /**
- * Handle the redirect for the customizer. This is necessary because
- * we can't directly add customizer links to the admin menu.
- *
- * There is a core patch in trac that would make this unnecessary.
- *
- * @link https://core.trac.wordpress.org/ticket/39050
- */
- public static function customizer_redirect() {
- wp_safe_redirect( self::customizer_link( array(
- 'return_url' => wp_get_referer(),
- ) ) );
- exit;
- }
-
- /**
* Shows Preprocessor code in the Revisions screen, and ensures that post_content_filtered
* is maintained on revisions
*
@@ -166,7 +158,7 @@ class Jetpack_Custom_CSS_Enhancements {
*
* @return array $fields Modified array to include post_content_filtered.
*/
- public static function _wp_post_revision_fields( $fields, $post ) {
+ public static function wp_post_revision_fields( $fields, $post ) {
// None of the fields in $post are required to be passed in this filter.
if ( ! isset( $post['post_type'], $post['ID'] ) ) {
return $fields;
@@ -175,10 +167,10 @@ class Jetpack_Custom_CSS_Enhancements {
// If we're passed in a revision, go get the main post instead.
if ( 'revision' === $post['post_type'] ) {
$main_post_id = wp_is_post_revision( $post['ID'] );
- $post = get_post( $main_post_id, ARRAY_A );
+ $post = get_post( $main_post_id, ARRAY_A );
}
if ( 'custom_css' === $post['post_type'] ) {
- $fields['post_content'] = __( 'CSS', 'jetpack' );
+ $fields['post_content'] = __( 'CSS', 'jetpack' );
$fields['post_content_filtered'] = __( 'Preprocessor', 'jetpack' );
}
return $fields;
@@ -243,7 +235,7 @@ class Jetpack_Custom_CSS_Enhancements {
* Partial for use in the Customizer.
*/
public static function echo_custom_css_partial() {
- echo wp_get_custom_css();
+ echo wp_get_custom_css(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
@@ -257,11 +249,11 @@ class Jetpack_Custom_CSS_Enhancements {
* If we ever add back in a non-Customizer CSS editor, this would be the place.
*/
public static function admin_page() {
- $post = null;
+ $post = null;
$stylesheet = null;
- if ( isset( $_GET['id'] ) ) {
- $post_id = absint( $_GET['id'] );
- $post = get_post( $post_id );
+ if ( isset( $_GET['id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site.
+ $post_id = absint( $_GET['id'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site
+ $post = get_post( $post_id );
if ( $post instanceof WP_Post && 'custom_css' === $post->post_type ) {
$stylesheet = $post->post_title;
}
@@ -272,7 +264,7 @@ class Jetpack_Custom_CSS_Enhancements {
<h1>
<?php
if ( $post ) {
- printf( 'Custom CSS for &#8220;%1$s&#8221;', wp_get_theme( $stylesheet )->Name );
+ printf( 'Custom CSS for &#8220;%1$s&#8221;', wp_get_theme( $stylesheet )->Name ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
esc_html_e( 'Custom CSS', 'jetpack' );
}
@@ -350,9 +342,12 @@ class Jetpack_Custom_CSS_Enhancements {
* @return string
*/
public static function customizer_link( $args = array() ) {
- $args = wp_parse_args( $args, array(
- 'return_url' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
- ) );
+ $args = wp_parse_args(
+ $args,
+ array(
+ 'return_url' => isset( $_SERVER['REQUEST_URI'] ) ? rawurlencode( filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) : '',
+ )
+ );
return add_query_arg(
array(
@@ -377,26 +372,31 @@ class Jetpack_Custom_CSS_Enhancements {
$content_help = __( 'Set a different content width for full size images.', 'jetpack' );
if ( ! empty( $GLOBALS['content_width'] ) ) {
$content_help .= sprintf(
+ // translators: the theme name and then the default width.
_n( ' The default content width for the <strong>%1$s</strong> theme is %2$d pixel.', ' The default content width for the <strong>%1$s</strong> theme is %2$d pixels.', (int) $GLOBALS['content_width'], 'jetpack' ),
wp_get_theme()->Name,
(int) $GLOBALS['content_width']
);
}
- wp_localize_script( 'jetpack-customizer-css', '_jp_css_settings', array(
- /** This filter is documented in modules/custom-css/custom-css.php */
- 'useRichEditor' => ! jetpack_is_mobile() && apply_filters( 'safecss_use_ace', true ),
- 'areThereCssRevisions' => self::are_there_css_revisions(),
- 'revisionsUrl' => self::get_revisions_url(),
- 'cssHelpUrl' => '//en.support.wordpress.com/custom-design/editing-css/',
- 'l10n' => array(
- 'mode' => __( 'Start Fresh', 'jetpack' ),
- 'mobile' => __( 'On Mobile', 'jetpack' ),
- 'contentWidth' => $content_help,
- 'revisions' => _x( 'See full history', 'Toolbar button to see full CSS revision history', 'jetpack' ),
- 'css_help_title' => _x( 'Help', 'Toolbar button to get help with custom CSS', 'jetpack' ),
- ),
- ));
+ wp_localize_script(
+ 'jetpack-customizer-css',
+ '_jp_css_settings',
+ array(
+ /** This filter is documented in modules/custom-css/custom-css.php */
+ 'useRichEditor' => ! jetpack_is_mobile() && apply_filters( 'safecss_use_ace', true ),
+ 'areThereCssRevisions' => self::are_there_css_revisions(),
+ 'revisionsUrl' => self::get_revisions_url(),
+ 'cssHelpUrl' => '//en.support.wordpress.com/custom-design/editing-css/',
+ 'l10n' => array(
+ 'mode' => __( 'Start Fresh', 'jetpack' ),
+ 'mobile' => __( 'On Mobile', 'jetpack' ),
+ 'contentWidth' => $content_help,
+ 'revisions' => _x( 'See full history', 'Toolbar button to see full CSS revision history', 'jetpack' ),
+ 'css_help_title' => _x( 'Help', 'Toolbar button to get help with custom CSS', 'jetpack' ),
+ ),
+ )
+ );
}
/**
@@ -447,7 +447,7 @@ class Jetpack_Custom_CSS_Enhancements {
*/
public static function get_themes() {
$themes = wp_get_themes( array( 'errors' => null ) );
- $all = array();
+ $all = array();
foreach ( $themes as $theme ) {
$all[ $theme->name ] = $theme->stylesheet;
}
@@ -460,19 +460,21 @@ class Jetpack_Custom_CSS_Enhancements {
* @return array
*/
public static function get_all_themes_with_custom_css() {
- $themes = self::get_themes();
- $custom_css = get_posts( array(
- 'post_type' => 'custom_css',
- 'post_status' => get_post_stati(),
- 'number' => -1,
- 'order' => 'DESC',
- 'orderby' => 'modified',
- ) );
- $return = array();
+ $themes = self::get_themes();
+ $custom_css = get_posts(
+ array(
+ 'post_type' => 'custom_css',
+ 'post_status' => get_post_stati(),
+ 'number' => -1,
+ 'order' => 'DESC',
+ 'orderby' => 'modified',
+ )
+ );
+ $return = array();
foreach ( $custom_css as $post ) {
$stylesheet = $post->post_title;
- $label = array_search( $stylesheet, $themes );
+ $label = array_search( $stylesheet, $themes, true );
if ( ! $label ) {
continue;
@@ -493,10 +495,14 @@ class Jetpack_Custom_CSS_Enhancements {
public static function wp_enqueue_scripts() {
if ( is_customize_preview() ) {
wp_enqueue_script( 'jetpack-customizer-css-preview' );
- wp_localize_script( 'jetpack-customizer-css-preview', 'jpCustomizerCssPreview', array(
- /** This filter is documented in modules/custom-css/custom-css.php */
- 'preprocessors' => apply_filters( 'jetpack_custom_css_preprocessors', array() ),
- ));
+ wp_localize_script(
+ 'jetpack-customizer-css-preview',
+ 'jpCustomizerCssPreview',
+ array(
+ /** This filter is documented in modules/custom-css/custom-css.php */
+ 'preprocessors' => apply_filters( 'jetpack_custom_css_preprocessors', array() ),
+ )
+ );
}
}
@@ -509,56 +515,55 @@ class Jetpack_Custom_CSS_Enhancements {
* @return mixed|string
*/
public static function sanitize_css( $css, $args = array() ) {
- $args = wp_parse_args( $args, array(
- 'force' => false,
- 'preprocessor' => null,
- ) );
+ $args = wp_parse_args(
+ $args,
+ array(
+ 'force' => false,
+ 'preprocessor' => null,
+ )
+ );
if ( $args['force'] || ! current_user_can( 'unfiltered_html' ) ) {
$warnings = array();
safecss_class();
- $csstidy = new csstidy();
+ $csstidy = new csstidy();
$csstidy->optimise = new safecss( $csstidy );
- $csstidy->set_cfg( 'remove_bslash', false );
- $csstidy->set_cfg( 'compress_colors', false );
- $csstidy->set_cfg( 'compress_font-weight', false );
- $csstidy->set_cfg( 'optimise_shorthands', 0 );
- $csstidy->set_cfg( 'remove_last_;', false );
- $csstidy->set_cfg( 'case_properties', false );
+ $csstidy->set_cfg( 'remove_bslash', false );
+ $csstidy->set_cfg( 'compress_colors', false );
+ $csstidy->set_cfg( 'compress_font-weight', false );
+ $csstidy->set_cfg( 'optimise_shorthands', 0 );
+ $csstidy->set_cfg( 'remove_last_;', false );
+ $csstidy->set_cfg( 'case_properties', false );
$csstidy->set_cfg( 'discard_invalid_properties', true );
- $csstidy->set_cfg( 'css_level', 'CSS3.0' );
- $csstidy->set_cfg( 'preserve_css', true );
- $csstidy->set_cfg( 'template', dirname( __FILE__ ) . '/csstidy/wordpress-standard.tpl' );
+ $csstidy->set_cfg( 'css_level', 'CSS3.0' );
+ $csstidy->set_cfg( 'preserve_css', true );
+ $csstidy->set_cfg( 'template', __DIR__ . '/csstidy/wordpress-standard.tpl' );
// Test for some preg_replace stuff.
- {
- $prev = $css;
- $css = preg_replace( '/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $css );
- // prevent content: '\3434' from turning into '\\3434'.
- $css = str_replace( array( '\'\\\\', '"\\\\' ), array( '\'\\', '"\\' ), $css );
- if ( $css !== $prev ) {
- $warnings[] = 'preg_replace found stuff';
- }
+ $prev = $css;
+ $css = preg_replace( '/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $css );
+ // prevent content: '\3434' from turning into '\\3434'.
+ $css = str_replace( array( '\'\\\\', '"\\\\' ), array( '\'\\', '"\\' ), $css );
+ if ( $css !== $prev ) {
+ $warnings[] = 'preg_replace found stuff';
}
// Some people put weird stuff in their CSS, KSES tends to be greedy.
$css = str_replace( '<=', '&lt;=', $css );
// Test for some kses stuff.
- {
- $prev = $css;
- // Why KSES instead of strip_tags? Who knows?
- $css = wp_kses_split( $css, array(), array() );
- $css = str_replace( '&gt;', '>', $css ); // kses replaces lone '>' with &gt;
- // Why both KSES and strip_tags? Because we just added some '>'.
- $css = strip_tags( $css );
-
- if ( $css != $prev ) {
- $warnings[] = 'kses found stuff';
- }
+ $prev = $css;
+ // Why KSES instead of strip_tags? Who knows?
+ $css = wp_kses_split( $css, array(), array() );
+ $css = str_replace( '&gt;', '>', $css ); // kses replaces lone '>' with &gt;
+ // Why both KSES and strip_tags? Because we just added some '>'.
+ $css = strip_tags( $css ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags -- scared to update this to wp_strip_all_tags since we're building a CSS file here.
+
+ if ( $css !== $prev ) {
+ $warnings[] = 'kses found stuff';
}
// if we're not using a preprocessor.
@@ -605,7 +610,7 @@ class Jetpack_Custom_CSS_Enhancements {
*
* @return mixed|void
*/
- static function style_filter( $current ) {
+ public static function style_filter( $current ) {
if ( is_admin() ) {
return $current;
} elseif ( self::is_freetrial() && ( ! self::is_preview() || ! current_user_can( 'switch_themes' ) ) ) {
@@ -623,10 +628,10 @@ class Jetpack_Custom_CSS_Enhancements {
*
* @return mixed The truthiness of this value determines whether the stylesheet should be skipped.
*/
- static function skip_stylesheet() {
+ public static function skip_stylesheet() {
/** This filter is documented in modules/custom-css/custom-css.php */
$skip_stylesheet = apply_filters( 'safecss_skip_stylesheet', null );
- if ( ! is_null( $skip_stylesheet ) ) {
+ if ( $skip_stylesheet !== null ) {
return $skip_stylesheet;
}
@@ -677,22 +682,31 @@ class Jetpack_Custom_CSS_Enhancements {
* SETTINGS.
*/
- $wp_customize->add_setting( 'jetpack_custom_css[preprocessor]', array(
- 'default' => '',
- 'transport' => 'postMessage',
- 'sanitize_callback' => array( __CLASS__, 'sanitize_preprocessor' ),
- ) );
+ $wp_customize->add_setting(
+ 'jetpack_custom_css[preprocessor]',
+ array(
+ 'default' => '',
+ 'transport' => 'postMessage',
+ 'sanitize_callback' => array( __CLASS__, 'sanitize_preprocessor' ),
+ )
+ );
- $wp_customize->add_setting( 'jetpack_custom_css[replace]', array(
- 'default' => false,
- 'transport' => 'refresh',
- ) );
+ $wp_customize->add_setting(
+ 'jetpack_custom_css[replace]',
+ array(
+ 'default' => false,
+ 'transport' => 'refresh',
+ )
+ );
- $wp_customize->add_setting( 'jetpack_custom_css[content_width]', array(
- 'default' => '',
- 'transport' => 'refresh',
- 'sanitize_callback' => array( __CLASS__, 'intval_base10' ),
- ) );
+ $wp_customize->add_setting(
+ 'jetpack_custom_css[content_width]',
+ array(
+ 'default' => '',
+ 'transport' => 'refresh',
+ 'sanitize_callback' => array( __CLASS__, 'intval_base10' ),
+ )
+ );
// Add custom sanitization to the core css customizer setting.
foreach ( $wp_customize->settings() as $setting ) {
@@ -710,7 +724,7 @@ class Jetpack_Custom_CSS_Enhancements {
if ( $core_custom_css ) {
if ( $core_custom_css instanceof WP_Customize_Code_Editor_Control ) {
// In WP 4.9, we let the Core CodeMirror control keep running the show, but hook into it to tweak stuff.
- $types = array(
+ $types = array(
'default' => 'text/css',
'less' => 'text/x-less',
'sass' => 'text/x-scss',
@@ -725,31 +739,40 @@ class Jetpack_Custom_CSS_Enhancements {
}
}
- $wp_customize->selective_refresh->add_partial( 'custom_css', array(
- 'type' => 'custom_css',
- 'selector' => '#wp-custom-css',
- 'container_inclusive' => false,
- 'fallback_refresh' => false,
- 'settings' => array(
- 'custom_css[' . $wp_customize->get_stylesheet() . ']',
- 'jetpack_custom_css[preprocessor]',
- ),
- 'render_callback' => array( __CLASS__, 'echo_custom_css_partial' ),
- ) );
-
- $wp_customize->add_control( 'wpcom_custom_css_content_width_control', array(
- 'type' => 'text',
- 'label' => __( 'Media Width', 'jetpack' ),
- 'section' => 'custom_css',
- 'settings' => 'jetpack_custom_css[content_width]',
- ) );
-
- $wp_customize->add_control( 'jetpack_css_mode_control', array(
- 'type' => 'checkbox',
- 'label' => __( 'Don\'t use the theme\'s original CSS.', 'jetpack' ),
- 'section' => 'custom_css',
- 'settings' => 'jetpack_custom_css[replace]',
- ) );
+ $wp_customize->selective_refresh->add_partial(
+ 'custom_css',
+ array(
+ 'type' => 'custom_css',
+ 'selector' => '#wp-custom-css',
+ 'container_inclusive' => false,
+ 'fallback_refresh' => false,
+ 'settings' => array(
+ 'custom_css[' . $wp_customize->get_stylesheet() . ']',
+ 'jetpack_custom_css[preprocessor]',
+ ),
+ 'render_callback' => array( __CLASS__, 'echo_custom_css_partial' ),
+ )
+ );
+
+ $wp_customize->add_control(
+ 'wpcom_custom_css_content_width_control',
+ array(
+ 'type' => 'text',
+ 'label' => __( 'Media Width', 'jetpack' ),
+ 'section' => 'custom_css',
+ 'settings' => 'jetpack_custom_css[content_width]',
+ )
+ );
+
+ $wp_customize->add_control(
+ 'jetpack_css_mode_control',
+ array(
+ 'type' => 'checkbox',
+ 'label' => __( 'Don\'t use the theme\'s original CSS.', 'jetpack' ),
+ 'section' => 'custom_css',
+ 'settings' => 'jetpack_custom_css[replace]',
+ )
+ );
/**
* An action to grab on to if another Jetpack Module would like to add its own controls.
@@ -773,13 +796,16 @@ class Jetpack_Custom_CSS_Enhancements {
$preprocessor_choices[ $preprocessor_key ] = $processor['name'];
}
- $wp_customize->add_control( 'jetpack_css_preprocessors_control', array(
- 'type' => 'select',
- 'choices' => $preprocessor_choices,
- 'label' => __( 'Preprocessor', 'jetpack' ),
- 'section' => 'custom_css',
- 'settings' => 'jetpack_custom_css[preprocessor]',
- ) );
+ $wp_customize->add_control(
+ 'jetpack_css_preprocessors_control',
+ array(
+ 'type' => 'select',
+ 'choices' => $preprocessor_choices,
+ 'label' => __( 'Preprocessor', 'jetpack' ),
+ 'section' => 'custom_css',
+ 'settings' => 'jetpack_custom_css[preprocessor]',
+ )
+ );
}
}
@@ -787,16 +813,18 @@ class Jetpack_Custom_CSS_Enhancements {
/**
* The callback to handle sanitizing the CSS. Takes different arguments, hence the proxy function.
*
- * @param mixed $css Value of the setting.
- * @param WP_Customize_Setting $setting WP_Customize_Setting instance.
+ * @param mixed $css Value of the setting.
*
* @return mixed|string
*/
- public static function sanitize_css_callback( $css, $setting ) {
+ public static function sanitize_css_callback( $css ) {
global $wp_customize;
- return self::sanitize_css( $css, array(
- 'preprocessor' => $wp_customize->get_setting( 'jetpack_custom_css[preprocessor]' )->value(),
- ) );
+ return self::sanitize_css(
+ $css,
+ array(
+ 'preprocessor' => $wp_customize->get_setting( 'jetpack_custom_css[preprocessor]' )->value(),
+ )
+ );
}
/**
@@ -882,13 +910,12 @@ class Jetpack_Custom_CSS_Enhancements {
* Store the original pre-processed CSS in `post_content_filtered`
* and then store processed CSS in `post_content`.
*
- * @param array $args Content post args.
- * @param string $css Original CSS being updated.
- * @param WP_Customize_Custom_CSS_Setting $setting Custom CSS Setting.
+ * @param array $args Content post args.
+ * @param string $css Original CSS being updated.
*
* @return mixed
*/
- public static function customize_update_custom_css_post_content_args( $args, $css, $setting ) {
+ public static function customize_update_custom_css_post_content_args( $args, $css ) {
// Find the current preprocessor.
$jetpack_custom_css = get_theme_mod( 'jetpack_custom_css', array() );
if ( empty( $jetpack_custom_css['preprocessor'] ) ) {
@@ -906,7 +933,7 @@ class Jetpack_Custom_CSS_Enhancements {
if ( isset( $preprocessors[ $preprocessor ] ) ) {
$args['post_content_filtered'] = $css;
- $args['post_content'] = call_user_func( $preprocessors[ $preprocessor ]['callback'], $css );
+ $args['post_content'] = call_user_func( $preprocessors[ $preprocessor ]['callback'], $css );
}
return $args;
@@ -915,12 +942,11 @@ class Jetpack_Custom_CSS_Enhancements {
/**
* Filter to handle the processing of preprocessed css on save.
*
- * @param array $args Custom CSS options.
- * @param string $stylesheet Original CSS to be updated.
+ * @param array $args Custom CSS options.
*
* @return mixed
*/
- public static function update_custom_css_data( $args, $stylesheet ) {
+ public static function update_custom_css_data( $args ) {
// Find the current preprocessor.
$jetpack_custom_css = get_theme_mod( 'jetpack_custom_css', array() );
if ( empty( $jetpack_custom_css['preprocessor'] ) ) {
@@ -929,16 +955,16 @@ class Jetpack_Custom_CSS_Enhancements {
/** This filter is documented in modules/custom-css/custom-css.php */
$preprocessors = apply_filters( 'jetpack_custom_css_preprocessors', array() );
- $preprocessor = $jetpack_custom_css['preprocessor'];
+ $preprocessor = $jetpack_custom_css['preprocessor'];
// If we have a preprocessor specified ...
if ( isset( $preprocessors[ $preprocessor ] ) ) {
// And no other preprocessor has run ...
if ( empty( $args['preprocessed'] ) ) {
$args['preprocessed'] = $args['css'];
- $args['css'] = call_user_func( $preprocessors[ $preprocessor ]['callback'], $args['css'] );
+ $args['css'] = call_user_func( $preprocessors[ $preprocessor ]['callback'], $args['css'] );
} else {
- trigger_error( 'Jetpack CSS Preprocessor specified, but something else has already modified the argument.', E_USER_WARNING );
+ trigger_error( 'Jetpack CSS Preprocessor specified, but something else has already modified the argument.', E_USER_WARNING ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
}
}
@@ -955,7 +981,7 @@ class Jetpack_Custom_CSS_Enhancements {
*
* @return array
*/
- static function editor_max_image_size( $dims, $size = 'medium', $context = null ) {
+ public static function editor_max_image_size( $dims, $size = 'medium', $context = null ) {
list( $width, $height ) = $dims;
if ( 'large' === $size && 'edit' === $context ) {
@@ -972,7 +998,7 @@ class Jetpack_Custom_CSS_Enhancements {
*
* @return int
*/
- static function jetpack_content_width( $content_width ) {
+ public static function jetpack_content_width( $content_width ) {
$custom_content_width = 0;
$jetpack_custom_css = get_theme_mod( 'jetpack_custom_css', array() );
@@ -992,9 +1018,9 @@ class Jetpack_Custom_CSS_Enhancements {
* 'template_redirect' action and
* 'admin_init' action
*/
- static function set_content_width() {
+ public static function set_content_width() {
// Don't apply this filter on the Edit CSS page.
- if ( isset( $_GET['page'] ) && 'editcss' === $_GET['page'] && is_admin() ) {
+ if ( isset( $_GET['page'] ) && 'editcss' === $_GET['page'] && is_admin() ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- nothing is changed on the site.
return;
}
@@ -1050,7 +1076,7 @@ class Jetpack_Custom_CSS_Enhancements {
$stylesheet = $post->post_title;
?>
<script type="text/html" id="tmpl-other-themes-switcher">
- <?php self::revisions_switcher_box( $stylesheet ); ?>
+ <?php self::revisions_switcher_box( $stylesheet ); ?>
</script>
<style>
.other-themes-wrap {
@@ -1121,7 +1147,11 @@ class Jetpack_Custom_CSS_Enhancements {
?>
<option value="<?php echo esc_url( add_query_arg( 'id', $data['post']->ID, menu_page_url( 'editcss', 0 ) ) ); ?>" <?php disabled( $stylesheet, $theme_stylesheet ); ?>>
<?php echo esc_html( $data['label'] ); ?>
- <?php printf( esc_html__( '(modified %s ago)', 'jetpack' ), human_time_diff( strtotime( $data['post']->post_modified_gmt ) ) ); ?></option>
+ <?php
+ // translators: how long ago the stylesheet was modified.
+ printf( esc_html__( '(modified %s ago)', 'jetpack' ), human_time_diff( strtotime( $data['post']->post_modified_gmt ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ ?>
+ </option>
<?php
continue;
}
@@ -1129,7 +1159,11 @@ class Jetpack_Custom_CSS_Enhancements {
?>
<option value="<?php echo esc_url( get_edit_post_link( $revision->ID ) ); ?>" <?php disabled( $stylesheet, $theme_stylesheet ); ?>>
<?php echo esc_html( $data['label'] ); ?>
- <?php printf( esc_html__( '(modified %s ago)', 'jetpack' ), human_time_diff( strtotime( $data['post']->post_modified_gmt ) ) ); ?></option>
+ <?php
+ // translators: how long ago the stylesheet was modified.
+ printf( esc_html__( '(modified %s ago)', 'jetpack' ), human_time_diff( strtotime( $data['post']->post_modified_gmt ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ ?>
+ </option>
<?php
}
?>
@@ -1152,17 +1186,17 @@ if ( ! function_exists( 'safecss_class' ) ) :
return;
}
- require_once( dirname( __FILE__ ) . '/csstidy/class.csstidy.php' );
+ require_once __DIR__ . '/csstidy/class.csstidy.php';
/**
* Class safecss
*/
- class safecss extends csstidy_optimise {
+ class safecss extends csstidy_optimise { // phpcs:ignore
/**
* Optimises $css after parsing.
*/
- function postparse() {
+ public function postparse() { // phpcs:ignore MediaWiki.Usage.NestedFunctions.NestedFunction
/** This action is documented in modules/custom-css/custom-css.php */
do_action( 'csstidy_optimize_postparse', $this );
@@ -1173,7 +1207,7 @@ if ( ! function_exists( 'safecss_class' ) ) :
/**
* Optimises a sub-value.
*/
- function subvalue() {
+ public function subvalue() { // phpcs:ignore MediaWiki.Usage.NestedFunctions.NestedFunction
/** This action is documented in modules/custom-css/custom-css.php */
do_action( 'csstidy_optimize_subvalue', $this );
diff --git a/plugins/jetpack/modules/custom-css/custom-css.php b/plugins/jetpack/modules/custom-css/custom-css.php
index 179fef4d..6bd2d296 100644
--- a/plugins/jetpack/modules/custom-css/custom-css.php
+++ b/plugins/jetpack/modules/custom-css/custom-css.php
@@ -1,11 +1,18 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Assets;
-use Automattic\Jetpack\Redirect;
use Automattic\Jetpack\Device_Detection\User_Agent_Info;
+use Automattic\Jetpack\Redirect;
+/**
+ * Custom CSS class.
+ */
class Jetpack_Custom_CSS {
- static function init() {
+
+ /**
+ * Initialize the class.
+ */
+ public static function init() {
add_action( 'switch_theme', array( __CLASS__, 'reset' ) );
add_action( 'wp_restore_post_revision', array( __CLASS__, 'restore_revision' ), 10, 2 );
@@ -19,8 +26,9 @@ class Jetpack_Custom_CSS {
add_action( 'template_redirect', array( __CLASS__, 'set_content_width' ) );
add_action( 'admin_init', array( __CLASS__, 'set_content_width' ) );
- if ( ! is_admin() )
+ if ( ! is_admin() ) {
add_filter( 'stylesheet_uri', array( __CLASS__, 'style_filter' ) );
+ }
define(
'SAFECSS_USE_ACE',
@@ -28,6 +36,7 @@ class Jetpack_Custom_CSS {
! User_Agent_Info::is_ipad() &&
/**
* Should the Custom CSS module use ACE to process CSS.
+ *
* @see https://ace.c9.io/
*
* @module custom-css
@@ -41,40 +50,45 @@ class Jetpack_Custom_CSS {
// Register safecss as a custom post_type
// Explicit capability definitions are largely unnecessary because the posts are manipulated in code via an options page, managing CSS revisions does check the capabilities, so let's ensure that the proper caps are checked.
- register_post_type( 'safecss', array(
- // These are the defaults
- // 'exclude_from_search' => true,
- // 'public' => false,
- // 'publicly_queryable' => false,
- // 'show_ui' => false,
- 'supports' => array( 'revisions' ),
- 'label' => 'Custom CSS',
- 'can_export' => false,
- 'rewrite' => false,
- 'capabilities' => array(
- 'edit_post' => 'edit_theme_options',
- 'read_post' => 'read',
- 'delete_post' => 'edit_theme_options',
- 'edit_posts' => 'edit_theme_options',
- 'edit_others_posts' => 'edit_theme_options',
- 'publish_posts' => 'edit_theme_options',
- 'read_private_posts' => 'read'
+ register_post_type(
+ 'safecss',
+ array(
+ /**
+ * These are the defaults
+ * 'exclude_from_search' => true,
+ * 'public' => false,
+ * 'publicly_queryable' => false,
+ * 'show_ui' => false,
+ */
+ 'supports' => array( 'revisions' ),
+ 'label' => 'Custom CSS',
+ 'can_export' => false,
+ 'rewrite' => false,
+ 'capabilities' => array(
+ 'edit_post' => 'edit_theme_options',
+ 'read_post' => 'read',
+ 'delete_post' => 'edit_theme_options',
+ 'edit_posts' => 'edit_theme_options',
+ 'edit_others_posts' => 'edit_theme_options',
+ 'publish_posts' => 'edit_theme_options',
+ 'read_private_posts' => 'read',
+ ),
)
- ) );
+ );
// Short-circuit WP if this is a CSS stylesheet request
if ( isset( $_GET['custom-css'] ) ) {
header( 'Content-Type: text/css', true, 200 );
- header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 31536000) . ' GMT' ); // 1 year
- Jetpack_Custom_CSS::print_css();
+ header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 31536000 ) . ' GMT' ); // 1 year
+ self::print_css();
exit;
}
add_action( 'admin_enqueue_scripts', array( 'Jetpack_Custom_CSS', 'enqueue_scripts' ) );
- if ( isset( $_GET['page'] ) && 'editcss' == $_GET['page'] && is_admin() ) {
+ if ( isset( $_GET['page'] ) && 'editcss' === $_GET['page'] && is_admin() ) {
// Do migration routine if necessary
- Jetpack_Custom_CSS::upgrade();
+ self::upgrade();
/**
* Allows additional work when migrating safecss from wp_options to wp_post.
@@ -90,6 +104,7 @@ class Jetpack_Custom_CSS {
* Never embed the style in the head on wpcom.
* Yes, this filter should be added to an unsynced file on wpcom, but
* there is no good syntactically-correct location to put it yet.
+ *
* @link https://github.com/Automattic/jetpack/commit/a1be114e9179f64d147124727a58e2cf76c7e5a1#commitcomment-7763921
*/
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
@@ -103,45 +118,39 @@ class Jetpack_Custom_CSS {
add_filter( 'jetpack_content_width', array( 'Jetpack_Custom_CSS', 'jetpack_content_width' ) );
add_filter( 'editor_max_image_size', array( 'Jetpack_Custom_CSS', 'editor_max_image_size' ), 10, 3 );
- if ( !current_user_can( 'switch_themes' ) && !is_super_admin() )
+ if ( ! current_user_can( 'switch_themes' ) && ! is_super_admin() ) {
return;
+ }
add_action( 'admin_menu', array( 'Jetpack_Custom_CSS', 'menu' ) );
- if ( isset( $_POST['safecss'] ) && false == strstr( $_SERVER[ 'REQUEST_URI' ], 'options.php' ) ) {
+ if ( isset( $_POST['safecss'] ) && ( ! isset( $_SERVER['REQUEST_URI'] ) || false === strstr( filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'options.php' ) ) ) {
check_admin_referer( 'safecss' );
- $save_result = self::save( array(
- 'css' => stripslashes( $_POST['safecss'] ),
- 'is_preview' => isset( $_POST['action'] ) && $_POST['action'] == 'preview',
- 'preprocessor' => isset( $_POST['custom_css_preprocessor'] ) ? $_POST['custom_css_preprocessor'] : '',
- 'add_to_existing' => isset( $_POST['add_to_existing'] ) ? $_POST['add_to_existing'] == 'true' : true,
- 'content_width' => isset( $_POST['custom_content_width'] ) ? $_POST['custom_content_width'] : false,
- ) );
+ $save_result = self::save(
+ array(
+ 'css' => filter_var( wp_unslash( $_POST['safecss'] ) ),
+ 'is_preview' => isset( $_POST['action'] ) && $_POST['action'] === 'preview',
+ 'preprocessor' => isset( $_POST['custom_css_preprocessor'] ) ? sanitize_key( $_POST['custom_css_preprocessor'] ) : '',
+ 'add_to_existing' => isset( $_POST['add_to_existing'] ) ? $_POST['add_to_existing'] === 'true' : true,
+ 'content_width' => isset( $_POST['custom_content_width'] ) ? intval( $_POST['custom_content_width'] ) : false,
+ )
+ );
- if ( $_POST['action'] == 'preview' ) {
+ if ( $_POST['action'] === 'preview' ) {
wp_safe_redirect( add_query_arg( 'csspreview', 'true', get_option( 'home' ) ) );
exit;
}
- if ( $save_result )
+ if ( $save_result ) {
add_action( 'admin_notices', array( 'Jetpack_Custom_CSS', 'saved_message' ) );
- }
-
- // Prevent content filters running on CSS when restoring revisions
- if ( isset( $_REQUEST[ 'action' ] ) && 'restore' === $_REQUEST[ 'action' ] && false !== strstr( $_SERVER[ 'REQUEST_URI' ], 'revision.php' ) ) {
- $parent_post = get_post( wp_get_post_parent_id( (int) $_REQUEST['revision'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
- if ( $parent_post && ! is_wp_error( $parent_post ) && 'safecss' === $parent_post->post_type ) {
- // Remove wp_filter_post_kses, this causes CSS escaping issues
- remove_filter( 'content_save_pre', 'wp_filter_post_kses' );
- remove_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' );
- remove_all_filters( 'content_save_pre' );
}
}
// Modify all internal links so that preview state persists
- if ( Jetpack_Custom_CSS::is_preview() )
+ if ( self::is_preview() ) {
ob_start( array( 'Jetpack_Custom_CSS', 'buffer' ) );
+ }
}
/**
@@ -158,11 +167,11 @@ class Jetpack_Custom_CSS {
*/
public static function save( $args = array() ) {
$defaults = array(
- 'css' => '',
- 'is_preview' => false,
- 'preprocessor' => '',
+ 'css' => '',
+ 'is_preview' => false,
+ 'preprocessor' => '',
'add_to_existing' => true,
- 'content_width' => false,
+ 'content_width' => false,
);
$args = wp_parse_args( $args, $defaults );
@@ -180,11 +189,6 @@ class Jetpack_Custom_CSS {
$args['content_width'] = false;
}
- // Remove wp_filter_post_kses, this causes CSS escaping issues
- remove_filter( 'content_save_pre', 'wp_filter_post_kses' );
- remove_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' );
- remove_all_filters( 'content_save_pre' );
-
/**
* Fires prior to saving custom css values. Necessitated because the
* core WordPress save_pre filters were removed:
@@ -197,11 +201,11 @@ class Jetpack_Custom_CSS {
*
* @param array $args {
* Array of custom CSS arguments.
- * @type string $css The CSS (or LESS or Sass).
- * @type bool $is_preview Whether this CSS is preview or published.
- * @type string preprocessor Which CSS preprocessor to use.
- * @type bool $add_to_existing Whether this CSS replaces the theme's CSS or supplements it.
- * @type int $content_width A custom $content_width to go along with this CSS.
+ * @type string $css The CSS (or LESS or Sass).
+ * @type bool $is_preview Whether this CSS is preview or published.
+ * @type string preprocessor Which CSS preprocessor to use.
+ * @type bool $add_to_existing Whether this CSS replaces the theme's CSS or supplements it.
+ * @type int $content_width A custom $content_width to go along with this CSS.
* }
*/
do_action( 'safecss_save_pre', $args );
@@ -209,39 +213,41 @@ class Jetpack_Custom_CSS {
$warnings = array();
safecss_class();
- $csstidy = new csstidy();
+ $csstidy = new csstidy();
$csstidy->optimise = new safecss( $csstidy );
- $csstidy->set_cfg( 'remove_bslash', false );
- $csstidy->set_cfg( 'compress_colors', false );
- $csstidy->set_cfg( 'compress_font-weight', false );
- $csstidy->set_cfg( 'optimise_shorthands', 0 );
- $csstidy->set_cfg( 'remove_last_;', false );
- $csstidy->set_cfg( 'case_properties', false );
+ $csstidy->set_cfg( 'remove_bslash', false );
+ $csstidy->set_cfg( 'compress_colors', false );
+ $csstidy->set_cfg( 'compress_font-weight', false );
+ $csstidy->set_cfg( 'optimise_shorthands', 0 );
+ $csstidy->set_cfg( 'remove_last_;', false );
+ $csstidy->set_cfg( 'case_properties', false );
$csstidy->set_cfg( 'discard_invalid_properties', true );
- $csstidy->set_cfg( 'css_level', 'CSS3.0' );
- $csstidy->set_cfg( 'preserve_css', true );
- $csstidy->set_cfg( 'template', dirname( __FILE__ ) . '/csstidy/wordpress-standard.tpl' );
-
- $css = $orig = $args['css'];
+ $csstidy->set_cfg( 'css_level', 'CSS3.0' );
+ $csstidy->set_cfg( 'preserve_css', true );
+ $csstidy->set_cfg( 'template', __DIR__ . '/csstidy/wordpress-standard.tpl' );
- $css = preg_replace( '/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $prev = $css );
+ $prev = $args['css'];
+ $css = preg_replace( '/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $prev );
// prevent content: '\3434' from turning into '\\3434'
$css = str_replace( array( '\'\\\\', '"\\\\' ), array( '\'\\', '"\\' ), $css );
- if ( $css != $prev )
+ if ( $css !== $prev ) {
$warnings[] = 'preg_replace found stuff';
+ }
// Some people put weird stuff in their CSS, KSES tends to be greedy
$css = str_replace( '<=', '&lt;=', $css );
// Why KSES instead of strip_tags? Who knows?
- $css = wp_kses_split( $prev = $css, array(), array() );
- $css = str_replace( '&gt;', '>', $css ); // kses replaces lone '>' with &gt;
+ $prev = $css;
+ $css = wp_kses_split( $prev, array(), array() );
+ $css = str_replace( '&gt;', '>', $css ); // kses replaces lone '>' with &gt;
// Why both KSES and strip_tags? Because we just added some '>'.
- $css = strip_tags( $css );
+ $css = strip_tags( $css ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags
- if ( $css != $prev )
+ if ( $css !== $prev ) {
$warnings[] = 'kses found stuff';
+ }
// if we're not using a preprocessor
if ( ! $args['preprocessor'] ) {
@@ -279,14 +285,15 @@ class Jetpack_Custom_CSS {
$css = $csstidy->print->plain();
}
- if ( $args['add_to_existing'] )
+ if ( $args['add_to_existing'] ) {
$add_to_existing = 'yes';
- else
+ } else {
$add_to_existing = 'no';
+ }
- if ( $args['is_preview'] || Jetpack_Custom_CSS::is_freetrial() ) {
+ if ( $args['is_preview'] || self::is_freetrial() ) {
// Save the CSS
- $safecss_revision_id = Jetpack_Custom_CSS::save_revision( $css, true, $args['preprocessor'] );
+ $safecss_revision_id = self::save_revision( $css, true, $args['preprocessor'] );
// Cache Buster
update_option( 'safecss_preview_rev', (int) get_option( 'safecss_preview_rev' ) + 1 );
@@ -313,9 +320,9 @@ class Jetpack_Custom_CSS {
}
// Save the CSS
- $safecss_post_id = Jetpack_Custom_CSS::save_revision( $css, false, $args['preprocessor'] );
+ $safecss_post_id = self::save_revision( $css, false, $args['preprocessor'] );
- $safecss_post_revision = Jetpack_Custom_CSS::get_current_revision();
+ $safecss_post_revision = self::get_current_revision();
update_option( 'safecss_rev', (int) get_option( 'safecss_rev' ) + 1 );
@@ -340,11 +347,12 @@ class Jetpack_Custom_CSS {
*
* @return array
*/
- static function get_post() {
- $custom_css_post_id = Jetpack_Custom_CSS::post_id();
+ public static function get_post() {
+ $custom_css_post_id = self::post_id();
- if ( $custom_css_post_id )
+ if ( $custom_css_post_id ) {
return get_post( $custom_css_post_id, ARRAY_A );
+ }
return array();
}
@@ -354,7 +362,7 @@ class Jetpack_Custom_CSS {
*
* @return int|bool The post ID if it exists; false otherwise.
*/
- static function post_id() {
+ public static function post_id() {
/**
* Filter the ID of the post where Custom CSS is stored, before the ID is retrieved.
*
@@ -368,32 +376,36 @@ class Jetpack_Custom_CSS {
* @param null null The ID to return instead of the normal ID.
*/
$custom_css_post_id = apply_filters( 'jetpack_custom_css_pre_post_id', null );
- if ( ! is_null( $custom_css_post_id ) ) {
+ if ( $custom_css_post_id !== null ) {
return $custom_css_post_id;
}
$custom_css_post_id = wp_cache_get( 'custom_css_post_id' );
if ( false === $custom_css_post_id ) {
- $custom_css_posts = get_posts( array(
- 'posts_per_page' => 1,
- 'post_type' => 'safecss',
- 'post_status' => 'publish',
- 'orderby' => 'date',
- 'order' => 'DESC'
- ) );
+ $custom_css_posts = get_posts(
+ array(
+ 'posts_per_page' => 1,
+ 'post_type' => 'safecss',
+ 'post_status' => 'publish',
+ 'orderby' => 'date',
+ 'order' => 'DESC',
+ )
+ );
- if ( count( $custom_css_posts ) > 0 )
+ if ( count( $custom_css_posts ) > 0 ) {
$custom_css_post_id = $custom_css_posts[0]->ID;
- else
+ } else {
$custom_css_post_id = 0;
+ }
// Save post_id=0 to note that no safecss post exists.
wp_cache_set( 'custom_css_post_id', $custom_css_post_id );
}
- if ( ! $custom_css_post_id )
+ if ( ! $custom_css_post_id ) {
return false;
+ }
return $custom_css_post_id;
}
@@ -403,14 +415,21 @@ class Jetpack_Custom_CSS {
*
* @return object
*/
- static function get_current_revision() {
- $safecss_post = Jetpack_Custom_CSS::get_post();
+ public static function get_current_revision() {
+ $safecss_post = self::get_post();
if ( empty( $safecss_post ) ) {
return false;
}
- $revisions = wp_get_post_revisions( $safecss_post['ID'], array( 'posts_per_page' => 1, 'orderby' => 'date', 'order' => 'DESC' ) );
+ $revisions = wp_get_post_revisions(
+ $safecss_post['ID'],
+ array(
+ 'posts_per_page' => 1,
+ 'orderby' => 'date',
+ 'order' => 'DESC',
+ )
+ );
// Empty array if no revisions exist
if ( empty( $revisions ) ) {
@@ -427,45 +446,50 @@ class Jetpack_Custom_CSS {
* Save new revision of CSS
* Checks to see if content was modified before really saving
*
- * @param string $css
- * @param bool $is_preview
+ * @param string $css - the CSS.
+ * @param bool $is_preview - if we're in preview mode.
+ * @param string $preprocessor - what preprocessor we're using.
+ *
* @return bool|int If nothing was saved, returns false. If a post
* or revision was saved, returns the post ID.
*/
- static function save_revision( $css, $is_preview = false, $preprocessor = '' ) {
- $safecss_post = Jetpack_Custom_CSS::get_post();
+ public static function save_revision( $css, $is_preview = false, $preprocessor = '' ) {
+ $safecss_post = self::get_post();
- $compressed_css = Jetpack_Custom_CSS::minify( $css, $preprocessor );
+ $compressed_css = self::minify( $css, $preprocessor );
// If null, there was no original safecss record, so create one
- if ( null == $safecss_post ) {
- if ( ! $css )
+ if ( ! $safecss_post ) {
+ if ( ! $css ) {
return false;
+ }
- $post = array();
- $post['post_content'] = wp_slash( $css );
- $post['post_title'] = 'safecss';
- $post['post_status'] = 'publish';
- $post['post_type'] = 'safecss';
+ $post = array();
+ $post['post_content'] = wp_slash( $css );
+ $post['post_title'] = 'safecss';
+ $post['post_status'] = 'publish';
+ $post['post_type'] = 'safecss';
$post['post_content_filtered'] = wp_slash( $compressed_css );
// Set excerpt to current theme, for display in revisions list
- $current_theme = wp_get_theme();
- $post['post_excerpt'] = $current_theme->Name;
+ $current_theme = wp_get_theme();
+ $post['post_excerpt'] = $current_theme->Name; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
+ add_filter( 'wp_insert_post_data', array( __CLASS__, 'restore_unsafe_postcss_content' ), 9, 3 );
// Insert the CSS into wp_posts
$post_id = wp_insert_post( $post );
+ remove_filter( 'wp_insert_post_data', array( __CLASS__, 'restore_unsafe_postcss_content' ), 9 );
wp_cache_set( 'custom_css_post_id', $post_id );
return $post_id;
}
// Update CSS in post array with new value passed to this function
- $safecss_post['post_content'] = $css;
+ $safecss_post['post_content'] = $css;
$safecss_post['post_content_filtered'] = $compressed_css;
// Set excerpt to current theme, for display in revisions list
- $current_theme = wp_get_theme();
- $safecss_post['post_excerpt'] = $current_theme->Name;
+ $current_theme = wp_get_theme();
+ $safecss_post['post_excerpt'] = $current_theme->Name; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
// Don't carry over last revision's timestamps, otherwise revisions all have matching timestamps
unset( $safecss_post['post_date'] );
@@ -475,18 +499,54 @@ class Jetpack_Custom_CSS {
// Do not update post if we are only saving a preview
if ( false === $is_preview ) {
- $safecss_post['post_content'] = wp_slash( $safecss_post['post_content'] );
+ $safecss_post['post_content'] = wp_slash( $safecss_post['post_content'] );
$safecss_post['post_content_filtered'] = wp_slash( $safecss_post['post_content_filtered'] );
+ add_filter( 'wp_insert_post_data', array( __CLASS__, 'restore_unsafe_postcss_content' ), 9, 3 );
$post_id = wp_update_post( $safecss_post );
+ remove_filter( 'wp_insert_post_data', array( __CLASS__, 'restore_unsafe_postcss_content' ), 9 );
wp_cache_set( 'custom_css_post_id', $post_id );
return $post_id;
+ } elseif ( ! defined( 'DOING_MIGRATE' ) ) {
+ add_filter( 'wp_insert_post_data', array( __CLASS__, 'restore_unsafe_postcss_content' ), 9, 3 );
+ $revision = _wp_put_post_revision( $safecss_post );
+ remove_filter( 'wp_insert_post_data', array( __CLASS__, 'restore_unsafe_postcss_content' ), 9 );
+ return $revision;
}
- else if ( ! defined( 'DOING_MIGRATE' ) ) {
- return _wp_put_post_revision( $safecss_post );
+ }
+
+ /**
+ * Restore Unsafe Post CSS Content.
+ *
+ * @param array $data The post data being filtered.
+ * @param array $postarray Unused.
+ * @param array $unsanitized The unsanitized post data.
+ *
+ * @return array Post data.
+ */
+ public static function restore_unsafe_postcss_content( $data, $postarray, $unsanitized ) {
+ $replace_content =
+ isset( $data['post_type'] ) &&
+ isset( $unsanitized['post_content'] ) &&
+ (
+ 'safecss' === $data['post_type'] ||
+ (
+ 'revision' === $data['post_type'] &&
+ ! empty( $data['post_parent'] ) &&
+ 'safecss' === get_post_type( $data['post_parent'] )
+ )
+ );
+ if ( $replace_content ) {
+ $data['post_content'] = $unsanitized['post_content'];
}
+ return $data;
}
- static function skip_stylesheet() {
+ /**
+ * Prevent the stylesheet from being enqued.
+ *
+ * @return bool
+ */
+ public static function skip_stylesheet() {
/**
* Prevent the Custom CSS stylesheet from being enqueued.
*
@@ -500,19 +560,19 @@ class Jetpack_Custom_CSS {
if ( null !== $skip_stylesheet ) {
return $skip_stylesheet;
- } elseif ( Jetpack_Custom_CSS::is_customizer_preview() ) {
+ } elseif ( self::is_customizer_preview() ) {
return false;
} else {
- if ( Jetpack_Custom_CSS::is_preview() ) {
- $safecss_post = Jetpack_Custom_CSS::get_current_revision();
+ if ( self::is_preview() ) {
+ $safecss_post = self::get_current_revision();
- if ( $safecss_post )
- return (bool) ( get_post_meta( $safecss_post['ID'], 'custom_css_add', true ) == 'no' );
- else
- return (bool) ( get_option( 'safecss_preview_add' ) == 'no' );
- }
- else {
- $custom_css_post_id = Jetpack_Custom_CSS::post_id();
+ if ( $safecss_post ) {
+ return (bool) ( get_post_meta( $safecss_post['ID'], 'custom_css_add', true ) === 'no' );
+ } else {
+ return (bool) ( get_option( 'safecss_preview_add' ) === 'no' );
+ }
+ } else {
+ $custom_css_post_id = self::post_id();
if ( $custom_css_post_id ) {
$custom_css_add = get_post_meta( $custom_css_post_id, 'custom_css_add', true );
@@ -520,17 +580,23 @@ class Jetpack_Custom_CSS {
// It is possible for the CSS to be stored in a post but for the safecss_add option
// to have not been upgraded yet if the user hasn't opened their Custom CSS editor
// since October 2012.
- if ( ! empty( $custom_css_add ) )
+ if ( ! empty( $custom_css_add ) ) {
return (bool) ( $custom_css_add === 'no' );
+ }
}
- return (bool) ( Jetpack_Options::get_option_and_ensure_autoload( 'safecss_add', '' ) == 'no' );
+ return (bool) ( Jetpack_Options::get_option_and_ensure_autoload( 'safecss_add', '' ) === 'no' );
}
}
}
- static function is_preview() {
- return isset( $_GET['csspreview'] ) && $_GET['csspreview'] === 'true';
+ /**
+ * Checks if we're in a preview mode.
+ *
+ * @return bool
+ */
+ public static function is_preview() {
+ return isset( $_GET['csspreview'] ) && $_GET['csspreview'] === 'true'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site.
}
/**
@@ -538,20 +604,23 @@ class Jetpack_Custom_CSS {
* 'template_redirect' action and
* 'admin_init' action
*/
- static function set_content_width(){
+ public static function set_content_width() {
// Don't apply this filter on the Edit CSS page
- if ( isset( $_GET ) && isset( $_GET['page'] ) && 'editcss' == $_GET['page'] && is_admin() ) {
+ if ( isset( $_GET ) && isset( $_GET['page'] ) && 'editcss' === $_GET['page'] && is_admin() ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- nothing changing on the site, it's not applying a filter if set.
return;
}
$GLOBALS['content_width'] = Jetpack::get_content_width();
}
- /*
+ /**
* False when the site has the Custom Design upgrade.
* Used only on WordPress.com.
+ *
+ * @return bool
+ * @todo see if we can remove this, I don't believe WordPress.com uses free trials anymore.
*/
- static function is_freetrial() {
+ public static function is_freetrial() {
/**
* Determine if a WordPress.com site uses a Free trial of the Custom Design Upgrade.
* Used only on WordPress.com.
@@ -565,20 +634,37 @@ class Jetpack_Custom_CSS {
return apply_filters( 'safecss_is_freetrial', false );
}
- static function get_preprocessor_key() {
- $safecss_post = Jetpack_Custom_CSS::get_current_revision();
+ /**
+ * Get the preprocessor key.
+ *
+ * @return string|false
+ */
+ public static function get_preprocessor_key() {
+ $safecss_post = self::get_current_revision();
return get_post_meta( $safecss_post['ID'], 'custom_css_preprocessor', true );
}
- static function get_preprocessor() {
+ /**
+ * Get the prepocessor.
+ *
+ * @return string|null
+ */
+ public static function get_preprocessor() {
/** This filter is documented in modules/custom-css/custom-css.php */
- $preprocessors = apply_filters( 'jetpack_custom_css_preprocessors', array() );
+ $preprocessors = apply_filters( 'jetpack_custom_css_preprocessors', array() );
$selected_preprocessor_key = self::get_preprocessor_key();
- $selected_preprocessor = isset( $preprocessors[ $selected_preprocessor_key ] ) ? $preprocessors[ $selected_preprocessor_key ] : null;
+ $selected_preprocessor = isset( $preprocessors[ $selected_preprocessor_key ] ) ? $preprocessors[ $selected_preprocessor_key ] : null;
return $selected_preprocessor;
}
- static function get_css( $compressed = false ) {
+ /**
+ * Get the CSS.
+ *
+ * @param boolean $compressed - if the CSS is compressed.
+ *
+ * @return string
+ */
+ public static function get_css( $compressed = false ) {
/**
* Filter the Custom CSS returned.
* Can be used to return an error, or no CSS at all.
@@ -591,21 +677,22 @@ class Jetpack_Custom_CSS {
*/
$default_css = apply_filters( 'safecss_get_css_error', false );
- if ( $default_css !== false )
+ if ( $default_css !== false ) {
return $default_css;
+ }
- $option = ( Jetpack_Custom_CSS::is_preview() || Jetpack_Custom_CSS::is_freetrial() ) ? 'safecss_preview' : 'safecss';
- $css = '';
+ $option = ( self::is_preview() || self::is_freetrial() ) ? 'safecss_preview' : 'safecss';
+ $css = '';
- if ( 'safecss' == $option ) {
+ if ( 'safecss' === $option ) {
// Don't bother checking for a migrated 'safecss' option if it never existed.
if ( false === get_option( 'safecss' ) || get_option( 'safecss_revision_migrated' ) ) {
- $safecss_post = Jetpack_Custom_CSS::get_post();
+ $safecss_post = self::get_post();
if ( ! empty( $safecss_post ) ) {
$css = ( $compressed && $safecss_post['post_content_filtered'] ) ? $safecss_post['post_content_filtered'] : $safecss_post['post_content'];
}
} else {
- $current_revision = Jetpack_Custom_CSS::get_current_revision();
+ $current_revision = self::get_current_revision();
if ( false === $current_revision ) {
$css = '';
} else {
@@ -616,15 +703,14 @@ class Jetpack_Custom_CSS {
// Fix for un-migrated Custom CSS
if ( empty( $safecss_post ) ) {
$_css = get_option( 'safecss' );
- if ( !empty( $_css ) ) {
+ if ( ! empty( $_css ) ) {
$css = $_css;
}
}
- }
- else if ( 'safecss_preview' == $option ) {
- $safecss_post = Jetpack_Custom_CSS::get_current_revision();
- $css = $safecss_post['post_content'];
- $css = Jetpack_Custom_CSS::minify( $css, get_post_meta( $safecss_post['ID'], 'custom_css_preprocessor', true ) );
+ } elseif ( 'safecss_preview' === $option ) {
+ $safecss_post = self::get_current_revision();
+ $css = $safecss_post['post_content'];
+ $css = self::minify( $css, get_post_meta( $safecss_post['ID'], 'custom_css_preprocessor', true ) );
}
$css = str_replace( array( '\\\00BB \\\0020', '\0BB \020', '0BB 020' ), '\00BB \0020', $css );
@@ -643,7 +729,14 @@ class Jetpack_Custom_CSS {
return $css;
}
- static function replace_insecure_urls( $css ) {
+ /**
+ * Replace insecure URLs.
+ *
+ * @param string $css - the CSS.
+ *
+ * @return string
+ */
+ public static function replace_insecure_urls( $css ) {
if ( ! function_exists( '_sa_get_frontend_https_url_replacement_map' ) ) {
return $css;
}
@@ -652,7 +745,10 @@ class Jetpack_Custom_CSS {
return str_replace( $http_urls, $secure_urls, $css );
}
- static function print_css() {
+ /**
+ * Print the CSS.
+ */
+ public static function print_css() {
/**
* Fires right before printing the custom CSS inside the <head> element.
@@ -662,16 +758,26 @@ class Jetpack_Custom_CSS {
* @since 1.7.0
*/
do_action( 'safecss_print_pre' );
- $css = Jetpack_Custom_CSS::get_css( true );
- echo self::replace_insecure_urls( $css );
+ $css = self::get_css( true );
+ echo self::replace_insecure_urls( $css ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
- static function should_we_inline_custom_css( $should_we, $css ) {
- // If the CSS is less than 2,000 characters, inline it! otherwise return what was passed in.
+ /**
+ * If the CSS is less than 2,000 characters, inline it! otherwise return what was passed in.
+ *
+ * @param bool $should_we if we should inline the CSS.
+ * @param string $css - the CSS object.
+ *
+ * @return bool
+ */
+ public static function should_we_inline_custom_css( $should_we, $css ) {
return ( strlen( $css ) < 2000 ) ? true : $should_we;
}
- static function link_tag() {
+ /**
+ * Add the link tag to inline CSS.
+ */
+ public static function link_tag() {
global $blog_id, $current_blog;
if (
@@ -690,24 +796,26 @@ class Jetpack_Custom_CSS {
return;
}
- if ( ! is_super_admin() && isset( $current_blog ) && ( 1 == $current_blog->spam || 1 == $current_blog->deleted ) )
+ if ( ! is_super_admin() && isset( $current_blog ) && ( $current_blog->spam || $current_blog->deleted ) ) {
return;
+ }
- if ( Jetpack_Custom_CSS::is_customizer_preview() )
+ if ( self::is_customizer_preview() ) {
return;
+ }
$css = '';
- $option = Jetpack_Custom_CSS::is_preview() ? 'safecss_preview' : 'safecss';
+ $option = self::is_preview() ? 'safecss_preview' : 'safecss';
- if ( 'safecss' == $option ) {
+ if ( 'safecss' === $option ) {
if ( Jetpack_Options::get_option_and_ensure_autoload( 'safecss_revision_migrated', '0' ) ) {
- $safecss_post = Jetpack_Custom_CSS::get_post();
+ $safecss_post = self::get_post();
if ( ! empty( $safecss_post['post_content'] ) ) {
$css = $safecss_post['post_content'];
}
} else {
- $current_revision = Jetpack_Custom_CSS::get_current_revision();
+ $current_revision = self::get_current_revision();
if ( ! empty( $current_revision['post_content'] ) ) {
$css = $current_revision['post_content'];
@@ -717,24 +825,25 @@ class Jetpack_Custom_CSS {
// Fix for un-migrated Custom CSS
if ( empty( $safecss_post ) ) {
$_css = Jetpack_Options::get_option_and_ensure_autoload( 'safecss', '' );
- if ( !empty( $_css ) ) {
+ if ( ! empty( $_css ) ) {
$css = $_css;
}
}
}
- if ( 'safecss_preview' == $option ) {
- $safecss_post = Jetpack_Custom_CSS::get_current_revision();
+ if ( 'safecss_preview' === $option ) {
+ $safecss_post = self::get_current_revision();
- if ( !empty( $safecss_post['post_content'] ) ) {
+ if ( ! empty( $safecss_post['post_content'] ) ) {
$css = $safecss_post['post_content'];
}
}
$css = str_replace( array( '\\\00BB \\\0020', '\0BB \020', '0BB 020' ), '\00BB \0020', $css );
- if ( $css == '' )
+ if ( $css === '' ) {
return;
+ }
if (
/**
@@ -750,7 +859,7 @@ class Jetpack_Custom_CSS {
apply_filters( 'safecss_embed_style', false, $css )
) {
- echo "\r\n" . '<style id="custom-css-css">' . Jetpack_Custom_CSS::get_css( true ) . "</style>\r\n";
+ echo "\r\n" . '<style id="custom-css-css">' . self::get_css( true ) . "</style>\r\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
@@ -772,11 +881,12 @@ class Jetpack_Custom_CSS {
*/
$href = apply_filters( 'safecss_href', $href, $blog_id );
- if ( Jetpack_Custom_CSS::is_preview() )
+ if ( self::is_preview() ) {
$href = add_query_arg( 'csspreview', 'true', $href );
+ }
?>
- <link rel="stylesheet" id="custom-css-css" type="text/css" href="<?php echo esc_url( $href ); ?>" />
+ <link rel="stylesheet" id="custom-css-css" type="text/css" href="<?php echo esc_url( $href ); // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet ?>" />
<?php
}
@@ -791,10 +901,17 @@ class Jetpack_Custom_CSS {
do_action( 'safecss_link_tag_post' );
}
- static function style_filter( $current ) {
- if ( Jetpack_Custom_CSS::is_freetrial() && ( ! Jetpack_Custom_CSS::is_preview() || ! current_user_can( 'switch_themes' ) ) )
+ /**
+ * Filter the default blank Custom CSS URL.
+ *
+ * @param string $current - the current CSS.
+ *
+ * @return string
+ */
+ public static function style_filter( $current ) {
+ if ( self::is_freetrial() && ( ! self::is_preview() || ! current_user_can( 'switch_themes' ) ) ) {
return $current;
- else if ( Jetpack_Custom_CSS::skip_stylesheet() )
+ } elseif ( self::skip_stylesheet() ) {
/**
* Filter the default blank Custom CSS URL.
*
@@ -805,18 +922,34 @@ class Jetpack_Custom_CSS {
* @param string $url Default blank Custom CSS URL.
*/
return apply_filters( 'safecss_style_filter_url', plugins_url( 'custom-css/css/blank.css', __FILE__ ) );
+ }
return $current;
}
- static function buffer( $html ) {
- $html = str_replace( '</body>', Jetpack_Custom_CSS::preview_flag(), $html );
+ /**
+ * Buffer the HTML.
+ *
+ * @param string $html - the HTML.
+ *
+ * @return string
+ */
+ public static function buffer( $html ) {
+ $html = str_replace( '</body>', self::preview_flag(), $html );
return preg_replace_callback( '!href=([\'"])(.*?)\\1!', array( 'Jetpack_Custom_CSS', 'preview_links' ), $html );
}
- static function preview_links( $matches ) {
- if ( 0 !== strpos( $matches[2], get_option( 'home' ) ) )
+ /**
+ * Preview links.
+ *
+ * @param array $matches - the matches.
+ *
+ * @return string
+ */
+ public static function preview_links( $matches ) {
+ if ( 0 !== strpos( $matches[2], get_option( 'home' ) ) ) {
return $matches[0];
+ }
$link = wp_specialchars_decode( $matches[2] );
$link = add_query_arg( 'csspreview', 'true', $link );
@@ -827,9 +960,10 @@ class Jetpack_Custom_CSS {
/**
* Places a black bar above every preview page
*/
- static function preview_flag() {
- if ( is_admin() )
+ public static function preview_flag() {
+ if ( is_admin() ) {
return;
+ }
$message = esc_html__( 'Preview: changes must be saved or they will be lost', 'jetpack' );
/**
@@ -844,7 +978,7 @@ class Jetpack_Custom_CSS {
$message = apply_filters( 'safecss_preview_message', $message );
$preview_flag_js = "var flag = document.createElement('div');
- flag.innerHTML = " . json_encode( $message ) . ";
+ flag.innerHTML = " . wp_json_encode( $message ) . ";
flag.style.background = '#FF6600';
flag.style.color = 'white';
flag.style.textAlign = 'center';
@@ -876,12 +1010,14 @@ class Jetpack_Custom_CSS {
return $preview_flag_js;
}
- static function menu() {
- $parent = 'themes.php';
- $title = __( 'Additional CSS', 'jetpack' );
- $hook = add_theme_page( $title, $title, 'edit_theme_options', 'editcss', array( 'Jetpack_Custom_CSS', 'admin' ) );
+ /**
+ * Add the additional CSS menu.
+ */
+ public static function menu() {
+ $title = __( 'Additional CSS', 'jetpack' );
+ $hook = add_theme_page( $title, $title, 'edit_theme_options', 'editcss', array( 'Jetpack_Custom_CSS', 'admin' ) );
- add_action( "load-revision.php", array( 'Jetpack_Custom_CSS', 'prettify_post_revisions' ) );
+ add_action( 'load-revision.php', array( 'Jetpack_Custom_CSS', 'prettify_post_revisions' ) );
add_action( "load-$hook", array( 'Jetpack_Custom_CSS', 'update_title' ) );
}
@@ -889,34 +1025,53 @@ class Jetpack_Custom_CSS {
* Adds a menu item in the appearance section for this plugin's administration
* page. Also adds hooks to enqueue the CSS and JS for the admin page.
*/
- static function update_title() {
+ public static function update_title() {
global $title;
- $title = __( 'CSS', 'jetpack' );
+ $title = __( 'CSS', 'jetpack' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
}
- static function prettify_post_revisions() {
+ /**
+ * Prettify the post revision.
+ */
+ public static function prettify_post_revisions() {
add_filter( 'the_title', array( 'Jetpack_Custom_CSS', 'post_title' ), 10, 2 );
}
- static function post_title( $title, $post_id ) {
- if ( !$post_id = (int) $post_id ) {
+ /**
+ * Get the post title.
+ *
+ * @param string $title - the post title.
+ * @param int $post_id - the post ID.
+ *
+ * @return string
+ */
+ public static function post_title( $title, $post_id ) {
+ $post_id = (int) $post_id;
+ if ( ! $post_id ) {
return $title;
}
- if ( !$post = get_post( $post_id ) ) {
+ $post = get_post( $post_id );
+ if ( ! $post ) {
return $title;
}
- if ( 'safecss' != $post->post_type ) {
+ if ( 'safecss' !== $post->post_type ) {
return $title;
}
return __( 'Custom CSS Stylesheet', 'jetpack' );
}
- static function enqueue_scripts( $hook ) {
- if ( 'appearance_page_editcss' != $hook )
+ /**
+ * Enqueue scripts.
+ *
+ * @param string $hook - the hook.
+ */
+ public static function enqueue_scripts( $hook ) {
+ if ( 'appearance_page_editcss' !== $hook ) {
return;
+ }
wp_enqueue_script( 'postbox' );
wp_enqueue_script(
@@ -929,7 +1084,7 @@ class Jetpack_Custom_CSS {
'20130325',
true
);
- wp_enqueue_style( 'custom-css-editor', plugins_url( 'custom-css/css/css-editor.css', __FILE__ ) );
+ wp_enqueue_style( 'custom-css-editor', plugins_url( 'custom-css/css/css-editor.css', __FILE__ ) ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
if ( defined( 'SAFECSS_USE_ACE' ) && SAFECSS_USE_ACE ) {
wp_register_style( 'jetpack-css-codemirror', plugins_url( 'custom-css/css/codemirror.css', __FILE__ ), array(), '20120905' );
@@ -949,18 +1104,25 @@ class Jetpack_Custom_CSS {
}
}
- static function saved_message() {
- echo '<div id="message" class="updated fade"><p><strong>' . __( 'Stylesheet saved.', 'jetpack' ) . '</strong></p></div>';
+ /**
+ * Render the saved message.
+ */
+ public static function saved_message() {
+ echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Stylesheet saved.', 'jetpack' ) . '</strong></p></div>';
}
- static function admin() {
+ /**
+ * Render the admin page.
+ */
+ public static function admin() {
add_meta_box( 'submitdiv', __( 'Publish', 'jetpack' ), array( __CLASS__, 'publish_box' ), 'editcss', 'side' );
add_action( 'custom_css_submitbox_misc_actions', array( __CLASS__, 'content_width_settings' ) );
- $safecss_post = Jetpack_Custom_CSS::get_post();
+ $safecss_post = self::get_post();
- if ( ! empty( $safecss_post ) && 0 < $safecss_post['ID'] && wp_get_post_revisions( $safecss_post['ID'], array( 'posts_per_page' => 1 ) ) )
+ if ( ! empty( $safecss_post ) && 0 < $safecss_post['ID'] && wp_get_post_revisions( $safecss_post['ID'], array( 'posts_per_page' => 1 ) ) ) {
add_meta_box( 'revisionsdiv', __( 'CSS Revisions', 'jetpack' ), array( __CLASS__, 'revisions_meta_box' ), 'editcss', 'side' );
+ }
?>
<div class="wrap">
<?php
@@ -975,9 +1137,9 @@ class Jetpack_Custom_CSS {
do_action( 'custom_design_header' );
?>
- <h1><?php _e( 'CSS Stylesheet Editor', 'jetpack' ); ?></h1>
+ <h1><?php esc_html_e( 'CSS Stylesheet Editor', 'jetpack' ); ?></h1>
<form id="safecssform" action="" method="post">
- <?php wp_nonce_field( 'safecss' ) ?>
+ <?php wp_nonce_field( 'safecss' ); ?>
<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
<input type="hidden" name="action" value="save" />
@@ -993,15 +1155,28 @@ class Jetpack_Custom_CSS {
*
* @param string $str Intro text appearing above the Custom CSS editor.
*/
- echo apply_filters( 'safecss_intro_text', __( 'New to CSS? Start with a <a href="https://www.htmldog.com/guides/css/beginner/" rel="noopener noreferrer" target="_blank">beginner tutorial</a>. Questions?
- Ask in the <a href="https://wordpress.org/support/forum/themes-and-templates" rel="noopener noreferrer" target="_blank">Themes and Templates forum</a>.', 'jetpack' ) );
- ?></p>
- <p class="css-support"><?php echo __( 'Note: Custom CSS will be reset when changing themes.', 'jetpack' ); ?></p>
+ echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ 'safecss_intro_text',
+ __(
+ 'New to CSS? Start with a <a href="https://www.htmldog.com/guides/css/beginner/" rel="noopener noreferrer" target="_blank">beginner tutorial</a>. Questions?
+ Ask in the <a href="https://wordpress.org/support/forum/themes-and-templates" rel="noopener noreferrer" target="_blank">Themes and Templates forum</a>.',
+ 'jetpack'
+ )
+ );
+ ?>
+ </p>
+ <p class="css-support"><?php echo esc_html__( 'Note: Custom CSS will be reset when changing themes.', 'jetpack' ); ?></p>
<div id="post-body" class="metabox-holder columns-2">
<div id="post-body-content">
<div class="postarea">
- <textarea id="safecss" name="safecss"<?php if ( SAFECSS_USE_ACE ) echo ' class="hide-if-js"'; ?>><?php echo esc_textarea( Jetpack_Custom_CSS::get_css() ); ?></textarea>
+ <textarea id="safecss" name="safecss"
+ <?php
+ if ( SAFECSS_USE_ACE ) {
+ echo ' class="hide-if-js"';
+ }
+ ?>
+ ><?php echo esc_textarea( self::get_css() ); ?></textarea>
<div class="clear"></div>
</div>
</div>
@@ -1019,22 +1194,34 @@ class Jetpack_Custom_CSS {
/**
* Content width setting callback
*/
- static function content_width_settings() {
- $safecss_post = Jetpack_Custom_CSS::get_current_revision();
+ public static function content_width_settings() {
+ $safecss_post = self::get_current_revision();
$custom_content_width = get_post_meta( $safecss_post['ID'], 'content_width', true );
// If custom content width hasn't been overridden and the theme has a content_width value, use that as a default.
- if ( $custom_content_width <= 0 && ! empty( $GLOBALS['content_width'] ) )
+ if ( $custom_content_width <= 0 && ! empty( $GLOBALS['content_width'] ) ) {
$custom_content_width = $GLOBALS['content_width'];
+ }
- if ( ! $custom_content_width || ( isset( $GLOBALS['content_width'] ) && $custom_content_width == $GLOBALS['content_width'] ) )
+ if ( ! $custom_content_width || ( isset( $GLOBALS['content_width'] ) && $custom_content_width == $GLOBALS['content_width'] ) ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
$custom_content_width = '';
+ }
?>
<div class="misc-pub-section">
<label><?php esc_html_e( 'Media Width:', 'jetpack' ); ?></label>
- <span id="content-width-display" data-default-text="<?php esc_attr_e( 'Default', 'jetpack' ); ?>" data-custom-text="<?php esc_attr_e( '%s px', 'jetpack' ); ?>"><?php echo $custom_content_width ? sprintf( esc_html__( '%s px', 'jetpack' ), $custom_content_width ) : esc_html_e( 'Default', 'jetpack' ); ?></span>
+ <span id="content-width-display" data-default-text="<?php esc_attr_e( 'Default', 'jetpack' ); ?>" data-custom-text="
+ <?php
+ // translators: the custom content width.
+ esc_attr_e( '%s px', 'jetpack' );
+ ?>
+ ">
+ <?php
+ // translators: the custom content width.
+ echo esc_html( $custom_content_width ? sprintf( __( '%s px', 'jetpack' ), $custom_content_width ) : __( 'Default', 'jetpack' ) );
+ ?>
+ </span>
<a class="edit-content-width hide-if-no-js" href="#content-width"><?php echo esc_html_e( 'Edit', 'jetpack' ); ?></a>
<div id="content-width-select" class="hide-if-js">
<input type="hidden" name="custom_content_width" id="custom_content_width" value="<?php echo esc_attr( $custom_content_width ); ?>" />
@@ -1042,7 +1229,7 @@ class Jetpack_Custom_CSS {
<?php
printf( /* translators: %1$s is replaced with an input field for numbers. */
- __( 'Limit width to %1$s pixels for full size images. (<a href="%2$s" rel="noopener noreferrer" target="_blank">More info</a>.)', 'jetpack' ),
+ wp_kses_post( __( 'Limit width to %1$s pixels for full size images. (<a href="%2$s" rel="noopener noreferrer" target="_blank">More info</a>.)', 'jetpack' ) ),
'<input type="text" id="custom_content_width_visible" value="' . esc_attr( $custom_content_width ) . '" size="4" />',
/**
* Filter the Custom CSS limited width's support doc URL.
@@ -1064,7 +1251,7 @@ class Jetpack_Custom_CSS {
if (
! empty( $GLOBALS['content_width'] )
- && $custom_content_width != $GLOBALS['content_width']
+ && $custom_content_width != $GLOBALS['content_width'] // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
) {
$current_theme = wp_get_theme()->Name;
@@ -1095,7 +1282,7 @@ class Jetpack_Custom_CSS {
</div>
<script type="text/javascript">
jQuery( function ( $ ) {
- var defaultContentWidth = <?php echo isset( $GLOBALS['content_width'] ) ? json_encode( (int) $GLOBALS['content_width'] ) : 0; ?>;
+ var defaultContentWidth = <?php echo isset( $GLOBALS['content_width'] ) ? wp_json_encode( (int) $GLOBALS['content_width'] ) : 0; ?>;
$( '.edit-content-width' ).bind( 'click', function ( e ) {
e.preventDefault();
@@ -1140,7 +1327,10 @@ class Jetpack_Custom_CSS {
<?php
}
- static function publish_box() {
+ /**
+ * Render the publish box.
+ */
+ public static function publish_box() {
?>
<div id="minor-publishing">
<div id="misc-publishing-actions">
@@ -1158,9 +1348,9 @@ class Jetpack_Custom_CSS {
$preprocessors = apply_filters( 'jetpack_custom_css_preprocessors', array() );
if ( ! empty( $preprocessors ) ) {
- $safecss_post = Jetpack_Custom_CSS::get_current_revision();
+ $safecss_post = self::get_current_revision();
$selected_preprocessor_key = get_post_meta( $safecss_post['ID'], 'custom_css_preprocessor', true );
- $selected_preprocessor = isset( $preprocessors[$selected_preprocessor_key] ) ? $preprocessors[$selected_preprocessor_key] : null;
+ $selected_preprocessor = isset( $preprocessors[ $selected_preprocessor_key ] ) ? $preprocessors[ $selected_preprocessor_key ] : null;
?>
<div class="misc-pub-section">
@@ -1174,7 +1364,7 @@ class Jetpack_Custom_CSS {
<?php
foreach ( $preprocessors as $preprocessor_key => $preprocessor ) {
- ?>
+ ?>
<option value="<?php echo esc_attr( $preprocessor_key ); ?>" <?php selected( $selected_preprocessor_key, $preprocessor_key ); ?>><?php echo esc_html( $preprocessor['name'] ); ?></option>
<?php
}
@@ -1188,9 +1378,9 @@ class Jetpack_Custom_CSS {
<?php
}
- $safecss_post = Jetpack_Custom_CSS::get_current_revision();
+ $safecss_post = self::get_current_revision();
- $add_css = ( get_post_meta( $safecss_post['ID'], 'custom_css_add', true ) != 'no' );
+ $add_css = ( get_post_meta( $safecss_post['ID'], 'custom_css_add', true ) !== 'no' );
?>
<div class="misc-pub-section">
@@ -1202,13 +1392,15 @@ class Jetpack_Custom_CSS {
<p>
<label>
<input type="radio" name="add_to_existing_display" value="true" <?php checked( $add_css ); ?>/>
- <?php _e( 'Add-on CSS <b>(Recommended)</b>', 'jetpack' ); ?>
+ <?php echo wp_kses( __( 'Add-on CSS <b>(Recommended)</b>', 'jetpack' ), array( 'b' => array() ) ); ?>
</label>
<br />
<label>
<input type="radio" name="add_to_existing_display" value="false" <?php checked( ! $add_css ); ?>/>
- <?php printf(
- __( 'Replace <a href="%s">theme\'s CSS</a> <b>(Advanced)</b>', 'jetpack' ),
+ <?php
+ printf(
+ // translators: the theme's stylesheet URL.
+ wp_kses_post( __( 'Replace <a href="%s">theme\'s CSS</a> <b>(Advanced)</b>', 'jetpack' ) ),
/**
* Filter the theme's stylesheet URL.
*
@@ -1218,8 +1410,9 @@ class Jetpack_Custom_CSS {
*
* @param string $url Active theme's stylesheet URL. Default to get_stylesheet_uri().
*/
- apply_filters( 'safecss_theme_stylesheet_url', get_stylesheet_uri() )
- ); ?>
+ esc_url( apply_filters( 'safecss_theme_stylesheet_url', get_stylesheet_uri() ) )
+ );
+ ?>
</label>
</p>
<a class="save-css-mode hide-if-no-js button" href="#css-mode"><?php esc_html_e( 'OK', 'jetpack' ); ?></a>
@@ -1241,9 +1434,9 @@ class Jetpack_Custom_CSS {
</div>
</div>
<div id="major-publishing-actions">
- <input type="button" class="button" id="preview" name="preview" value="<?php esc_attr_e( 'Preview', 'jetpack' ) ?>" />
+ <input type="button" class="button" id="preview" name="preview" value="<?php esc_attr_e( 'Preview', 'jetpack' ); ?>" />
<div id="publishing-action">
- <input type="submit" class="button-primary" id="save" name="save" value="<?php ( Jetpack_Custom_CSS::is_freetrial() ) ? esc_attr_e( 'Save &amp; Buy Upgrade', 'jetpack' ) : esc_attr_e( 'Save Stylesheet', 'jetpack' ); ?>" />
+ <input type="submit" class="button-primary" id="save" name="save" value="<?php ( self::is_freetrial() ) ? esc_attr_e( 'Save &amp; Buy Upgrade', 'jetpack' ) : esc_attr_e( 'Save Stylesheet', 'jetpack' ); ?>" />
</div>
</div>
<?php
@@ -1254,7 +1447,7 @@ class Jetpack_Custom_CSS {
* Called by safecss_admin
*
* @global $post
- * @param array $safecss_post
+ * @param array $safecss_post - the safecss array.
* @uses wp_revisions_to_keep
* @uses WP_Query
* @uses wp_post_revision_title
@@ -1262,11 +1455,12 @@ class Jetpack_Custom_CSS {
* @uses add_query_arg
* @uses menu_page_url
* @uses wp_reset_query
- * @return string
+ *
+ * @todo can this be removed? The revision page seems to work via the customizer now.
*/
- static function revisions_meta_box( $safecss_post ) {
+ public static function revisions_meta_box( $safecss_post ) {
- $show_all_revisions = isset( $_GET['show_all_rev'] );
+ $show_all_revisions = isset( $_GET['show_all_rev'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- nothing on the site is changing
if ( function_exists( 'wp_revisions_to_keep' ) ) {
$max_revisions = wp_revisions_to_keep( (object) $safecss_post );
@@ -1276,62 +1470,71 @@ class Jetpack_Custom_CSS {
$posts_per_page = $show_all_revisions ? $max_revisions : 6;
- $revisions = new WP_Query( array(
- 'posts_per_page' => $posts_per_page,
- 'post_type' => 'revision',
- 'post_status' => 'inherit',
- 'post_parent' => $safecss_post['ID'],
- 'orderby' => 'date',
- 'order' => 'DESC'
- ) );
+ $revisions = new WP_Query(
+ array(
+ 'posts_per_page' => $posts_per_page,
+ 'post_type' => 'revision',
+ 'post_status' => 'inherit',
+ 'post_parent' => $safecss_post['ID'],
+ 'orderby' => 'date',
+ 'order' => 'DESC',
+ )
+ );
- if ( $revisions->have_posts() ) { ?>
- <ul class="post-revisions"><?php
+ if ( $revisions->have_posts() ) {
+ ?>
+ <ul class="post-revisions">
+ <?php
global $post;
while ( $revisions->have_posts() ) :
$revisions->the_post();
- ?><li>
+ ?>
+ <li>
<?php
- echo wp_post_revision_title( $post );
+ echo wp_post_revision_title( $post ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- if ( ! empty( $post->post_excerpt ) )
- echo ' (' . esc_html( $post->post_excerpt ) . ')';
+ if ( ! empty( $post->post_excerpt ) ) {
+ echo ' (' . esc_html( $post->post_excerpt ) . ')';
+ }
?>
- </li><?php
+ </li>
+ <?php
endwhile;
- ?></ul><?php
+ ?>
+ </ul>
+ <?php
- if ( $revisions->found_posts > 6 && !$show_all_revisions ) {
+ if ( $revisions->found_posts > 6 && ! $show_all_revisions ) {
?>
<br>
- <a href="<?php echo add_query_arg( 'show_all_rev', 'true', menu_page_url( 'editcss', false ) ); ?>"><?php esc_html_e( 'Show all', 'jetpack' ); ?></a>
+ <a href="<?php echo esc_url( add_query_arg( 'show_all_rev', 'true', menu_page_url( 'editcss', false ) ) ); ?>"><?php esc_html_e( 'Show all', 'jetpack' ); ?></a>
<?php
}
}
- wp_reset_query();
+ wp_reset_postdata();
}
/**
* Hook in init at priority 11 to disable custom CSS.
*/
- static function disable() {
+ public static function disable() {
remove_action( 'wp_head', array( 'Jetpack_Custom_CSS', 'link_tag' ), 101 );
- remove_filter( 'stylesheet_uri', array( 'Jetpack_Custom_CSS', 'style_filter' ) );
+ remove_filter( 'stylesheet_uri', array( 'Jetpack_Custom_CSS', 'style_filter' ) );
}
/**
* Reset all aspects of Custom CSS on a theme switch so that changing
* themes is a sure-fire way to get a clean start.
*/
- static function reset() {
- $safecss_post_id = Jetpack_Custom_CSS::save_revision( '' );
- $safecss_revision = Jetpack_Custom_CSS::get_current_revision();
+ public static function reset() {
+ $safecss_post_id = self::save_revision( '' );
+ $safecss_revision = self::get_current_revision();
update_option( 'safecss_rev', (int) get_option( 'safecss_rev' ) + 1 );
@@ -1349,38 +1552,53 @@ class Jetpack_Custom_CSS {
delete_option( 'safecss_preview_add' );
}
- static function is_customizer_preview() {
- if ( isset ( $GLOBALS['wp_customize'] ) )
+ /**
+ * Checks of we're in the customizer.
+ *
+ * @return bool
+ */
+ public static function is_customizer_preview() {
+ if ( isset( $GLOBALS['wp_customize'] ) ) {
return ! $GLOBALS['wp_customize']->is_theme_active();
+ }
return false;
}
- static function minify( $css, $preprocessor = '' ) {
- if ( ! $css )
+ /**
+ * Handle minifying CSS.
+ *
+ * @param string $css - the CSS.
+ * @param string $preprocessor - the preprocessor we want to use.
+ *
+ * @return string
+ */
+ public static function minify( $css, $preprocessor = '' ) {
+ if ( ! $css ) {
return '';
+ }
if ( $preprocessor ) {
/** This filter is documented in modules/custom-css/custom-css.php */
$preprocessors = apply_filters( 'jetpack_custom_css_preprocessors', array() );
- if ( isset( $preprocessors[$preprocessor] ) ) {
- $css = call_user_func( $preprocessors[$preprocessor]['callback'], $css );
+ if ( isset( $preprocessors[ $preprocessor ] ) ) {
+ $css = call_user_func( $preprocessors[ $preprocessor ]['callback'], $css );
}
}
safecss_class();
- $csstidy = new csstidy();
+ $csstidy = new csstidy();
$csstidy->optimise = new safecss( $csstidy );
- $csstidy->set_cfg( 'remove_bslash', false );
- $csstidy->set_cfg( 'compress_colors', true );
- $csstidy->set_cfg( 'compress_font-weight', true );
- $csstidy->set_cfg( 'remove_last_;', true );
- $csstidy->set_cfg( 'case_properties', true );
+ $csstidy->set_cfg( 'remove_bslash', false );
+ $csstidy->set_cfg( 'compress_colors', true );
+ $csstidy->set_cfg( 'compress_font-weight', true );
+ $csstidy->set_cfg( 'remove_last_;', true );
+ $csstidy->set_cfg( 'case_properties', true );
$csstidy->set_cfg( 'discard_invalid_properties', true );
- $csstidy->set_cfg( 'css_level', 'CSS3.0' );
- $csstidy->set_cfg( 'template', 'highest');
+ $csstidy->set_cfg( 'css_level', 'CSS3.0' );
+ $csstidy->set_cfg( 'template', 'highest' );
$csstidy->parse( $css );
return $csstidy->print->plain();
@@ -1389,18 +1607,22 @@ class Jetpack_Custom_CSS {
/**
* When restoring a SafeCSS post revision, also copy over the
* content_width and custom_css_add post metadata.
+ *
+ * @param int $_post_id - the post ID.
+ * @param int $_revision_id - the revision ID.
*/
- static function restore_revision( $_post_id, $_revision_id ) {
+ public static function restore_revision( $_post_id, $_revision_id ) {
$_post = get_post( $_post_id );
- if ( 'safecss' != $_post->post_type )
+ if ( 'safecss' !== $_post->post_type ) {
return;
+ }
- $safecss_revision = Jetpack_Custom_CSS::get_current_revision();
+ $safecss_revision = self::get_current_revision();
- $content_width = get_post_meta( $_revision_id, 'content_width', true );
+ $content_width = get_post_meta( $_revision_id, 'content_width', true );
$custom_css_add = get_post_meta( $_revision_id, 'custom_css_add', true );
- $preprocessor = get_post_meta( $_revision_id, 'custom_css_preprocessor', true );
+ $preprocessor = get_post_meta( $_revision_id, 'custom_css_preprocessor', true );
update_metadata( 'post', $safecss_revision['ID'], 'content_width', $content_width );
update_metadata( 'post', $safecss_revision['ID'], 'custom_css_add', $custom_css_add );
@@ -1418,10 +1640,8 @@ class Jetpack_Custom_CSS {
/**
* Migration routine for moving safecss from wp_options to wp_posts to support revisions
- *
- * @return void
*/
- static function upgrade() {
+ public static function upgrade() {
$css = get_option( 'safecss' );
if ( get_option( 'safecss_revision_migrated' ) ) {
@@ -1433,17 +1653,18 @@ class Jetpack_Custom_CSS {
// Remove the async actions from publish_post
remove_action( 'publish_post', 'queue_publish_post' );
- $post = array();
+ $post = array();
$post['post_content'] = $css;
- $post['post_title'] = 'safecss';
- $post['post_status'] = 'publish';
- $post['post_type'] = 'safecss';
+ $post['post_title'] = 'safecss';
+ $post['post_status'] = 'publish';
+ $post['post_type'] = 'safecss';
// Insert the CSS into wp_posts
$post_id = wp_insert_post( $post );
// Check for errors
- if ( !$post_id or is_wp_error( $post_id ) )
- die( $post_id->get_error_message() );
+ if ( ! $post_id || is_wp_error( $post_id ) ) {
+ die( $post_id->get_error_message() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ }
// Delete safecss option
delete_option( 'safecss' );
@@ -1452,26 +1673,28 @@ class Jetpack_Custom_CSS {
unset( $css );
// Check if we have already done this
- if ( !get_option( 'safecss_revision_migrated' ) ) {
+ if ( ! get_option( 'safecss_revision_migrated' ) ) {
define( 'DOING_MIGRATE', true );
// Get hashes of safecss post and current revision
- $safecss_post = Jetpack_Custom_CSS::get_post();
+ $safecss_post = self::get_post();
- if ( empty( $safecss_post ) )
+ if ( empty( $safecss_post ) ) {
return;
+ }
$safecss_post_hash = md5( $safecss_post['post_content'] );
- $current_revision = Jetpack_Custom_CSS::get_current_revision();
+ $current_revision = self::get_current_revision();
- if ( null == $current_revision )
+ if ( null === $current_revision ) {
return;
+ }
$current_revision_hash = md5( $current_revision['post_content'] );
// If hashes are not equal, set safecss post with content from current revision
if ( $safecss_post_hash !== $current_revision_hash ) {
- Jetpack_Custom_CSS::save_revision( $current_revision['post_content'] );
+ self::save_revision( $current_revision['post_content'] );
// Reset post_content to display the migrated revsion
$safecss_post['post_content'] = $current_revision['post_content'];
}
@@ -1480,7 +1703,7 @@ class Jetpack_Custom_CSS {
update_option( 'safecss_revision_migrated', time() );
}
- $newest_safecss_post = Jetpack_Custom_CSS::get_current_revision();
+ $newest_safecss_post = self::get_current_revision();
if ( $newest_safecss_post ) {
if ( get_option( 'safecss_content_width' ) ) {
@@ -1503,7 +1726,7 @@ class Jetpack_Custom_CSS {
/**
* Adds a filter to the redirect location in `wp-admin/revisions.php`.
*/
- static function add_revision_redirect() {
+ public static function add_revision_redirect() {
add_filter( 'wp_redirect', array( __CLASS__, 'revision_redirect' ) );
}
@@ -1513,13 +1736,13 @@ class Jetpack_Custom_CSS {
* @param string $location The path to redirect to.
* @return string
*/
- static function revision_redirect( $location ) {
+ public static function revision_redirect( $location ) {
$post = get_post();
- if ( ! empty( $post->post_type ) && 'safecss' == $post->post_type ) {
+ if ( ! empty( $post->post_type ) && 'safecss' === $post->post_type ) {
$location = 'themes.php?page=editcss';
- if ( 'edit.php' == $location ) {
+ if ( 'edit.php' === $location ) {
$location = '';
}
}
@@ -1527,22 +1750,33 @@ class Jetpack_Custom_CSS {
return $location;
}
- static function revision_post_link( $post_link, $post_id, $context ) {
- if ( !$post_id = (int) $post_id ) {
+ /**
+ * The revision post link.
+ *
+ * @param string $post_link - the post link.
+ * @param int $post_id - the post ID.
+ * @param string $context - the context.
+ *
+ * @return string
+ */
+ public static function revision_post_link( $post_link, $post_id, $context ) {
+ $post_id = (int) $post_id;
+ if ( ! $post_id ) {
return $post_link;
}
- if ( !$post = get_post( $post_id ) ) {
+ $post = get_post( $post_id );
+ if ( ! $post ) {
return $post_link;
}
- if ( 'safecss' != $post->post_type ) {
+ if ( 'safecss' !== $post->post_type ) {
return $post_link;
}
$post_link = admin_url( 'themes.php?page=editcss' );
- if ( 'display' == $context ) {
+ if ( 'display' === $context ) {
return esc_url( $post_link );
}
@@ -1552,45 +1786,69 @@ class Jetpack_Custom_CSS {
/**
* When on the edit screen, make sure the custom content width
* setting is applied to the large image size.
+ *
+ * @param array $dims - the width and height dimensions.
+ * @param string $size - the size.
+ * @param string $context - the context in which we're applying dimensions.
+ *
+ * @return array
*/
- static function editor_max_image_size( $dims, $size = 'medium', $context = null ) {
+ public static function editor_max_image_size( $dims, $size = 'medium', $context = null ) {
list( $width, $height ) = $dims;
- if ( 'large' == $size && 'edit' == $context )
+ if ( 'large' === $size && 'edit' === $context ) {
$width = Jetpack::get_content_width();
+ }
return array( $width, $height );
}
/**
* Override the content_width with a custom value if one is set.
+ *
+ * @param int $content_width - the content width in pixels.
+ *
+ * @return int
*/
- static function jetpack_content_width( $content_width ) {
+ public static function jetpack_content_width( $content_width ) {
$custom_content_width = 0;
- if ( Jetpack_Custom_CSS::is_preview() ) {
- $safecss_post = Jetpack_Custom_CSS::get_current_revision();
+ if ( self::is_preview() ) {
+ $safecss_post = self::get_current_revision();
$custom_content_width = (int) get_post_meta( $safecss_post['ID'], 'content_width', true );
- } else if ( ! Jetpack_Custom_CSS::is_freetrial() ) {
- $custom_css_post_id = Jetpack_Custom_CSS::post_id();
- if ( $custom_css_post_id )
+ } elseif ( ! self::is_freetrial() ) {
+ $custom_css_post_id = self::post_id();
+ if ( $custom_css_post_id ) {
$custom_content_width = (int) get_post_meta( $custom_css_post_id, 'content_width', true );
+ }
}
- if ( $custom_content_width > 0 )
+ if ( $custom_content_width > 0 ) {
$content_width = $custom_content_width;
+ }
return $content_width;
}
}
-class Jetpack_Safe_CSS {
- static function filter_attr( $css, $element = 'div' ) {
+/**
+ * The Safe CSS Class.
+ */
+class Jetpack_Safe_CSS { // phpcs:ignore Generic.Files.OneObjectStructurePerFile.MultipleFound, Generic.Classes.OpeningBraceSameLine.ContentAfterBrace
+ /**
+ * Filter attriburtes.
+ *
+ * @param string $css - the CSS.
+ * @param string $element - the HTML element.
+ *
+ * @return string
+ */
+ public static function filter_attr( $css, $element = 'div' ) {
safecss_class();
$css = $element . ' {' . $css . '}';
- $csstidy = new csstidy();
+ $csstidy = new csstidy();
$csstidy->optimise = new safecss( $csstidy );
$csstidy->set_cfg( 'remove_bslash', false );
$csstidy->set_cfg( 'compress_colors', false );
@@ -1610,66 +1868,87 @@ class Jetpack_Safe_CSS {
$css = $csstidy->print->plain();
- $css = str_replace( array( "\n","\r","\t" ), '', $css );
+ $css = str_replace( array( "\n", "\r", "\t" ), '', $css );
preg_match( "/^{$element}\s*{(.*)}\s*$/", $css, $matches );
- if ( empty( $matches[1] ) )
+ if ( empty( $matches[1] ) ) {
return '';
+ }
return $matches[1];
}
}
if ( ! function_exists( 'safecss_class' ) ) :
-function safecss_class() {
- // Wrapped so we don't need the parent class just to load the plugin
- if ( class_exists('safecss') )
- return;
-
- require_once( dirname( __FILE__ ) . '/csstidy/class.csstidy.php' );
+ /**
+ * Setup safecss class.
+ */
+ function safecss_class() {
+ // Wrapped so we don't need the parent class just to load the plugin
+ if ( class_exists( 'safecss' ) ) {
+ return;
+ }
- class safecss extends csstidy_optimise {
+ require_once __DIR__ . '/csstidy/class.csstidy.php';
- function postparse() {
+ /**
+ * Safe CSS Class.
+ */
+ class safecss extends csstidy_optimise { // phpcs:ignore
/**
- * Fires after parsing the css.
- *
- * @module custom-css
- *
- * @since 1.8.0
- *
- * @param obj $this CSSTidy object.
+ * Add action to fire after parsing CSS.
*/
- do_action( 'csstidy_optimize_postparse', $this );
+ public function postparse() { // phpcs:ignore MediaWiki.Usage.NestedFunctions.NestedFunction
- return parent::postparse();
- }
+ /**
+ * Fires after parsing the css.
+ *
+ * @module custom-css
+ *
+ * @since 1.8.0
+ *
+ * @param obj $this CSSTidy object.
+ */
+ do_action( 'csstidy_optimize_postparse', $this );
- function subvalue() {
+ return parent::postparse();
+ }
/**
- * Fires before optimizing the Custom CSS subvalue.
- *
- * @module custom-css
- *
- * @since 1.8.0
- *
- * @param obj $this CSSTidy object.
- **/
- do_action( 'csstidy_optimize_subvalue', $this );
+ * Handle subvalue action.
+ */
+ public function subvalue() { // phpcs:ignore MediaWiki.Usage.NestedFunctions.NestedFunction
+
+ /**
+ * Fires before optimizing the Custom CSS subvalue.
+ *
+ * @module custom-css
+ *
+ * @since 1.8.0
+ *
+ * @param obj $this CSSTidy object.
+ */
+ do_action( 'csstidy_optimize_subvalue', $this );
- return parent::subvalue();
+ return parent::subvalue();
+ }
}
}
-}
endif;
if ( ! function_exists( 'safecss_filter_attr' ) ) {
+
+ /**
+ * Filter safecss attriburtes.
+ *
+ * @param string $css - the CSS.
+ * @param string $element - the HTML element.
+ */
function safecss_filter_attr( $css, $element = 'div' ) {
return Jetpack_Safe_CSS::filter_attr( $css, $element );
}
}
-include_once dirname( __FILE__ ) . '/custom-css/preprocessors.php';
+require_once __DIR__ . '/custom-css/preprocessors.php';
diff --git a/plugins/jetpack/modules/custom-css/custom-css/css/codemirror-rtl.css b/plugins/jetpack/modules/custom-css/custom-css/css/codemirror-rtl.css
index 9d3bbc7b..a88da0ad 100644
--- a/plugins/jetpack/modules/custom-css/custom-css/css/codemirror-rtl.css
+++ b/plugins/jetpack/modules/custom-css/custom-css/css/codemirror-rtl.css
@@ -1,40 +1,44 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
/* NOAUTORTL */
.rtl .CodeMirror {
- direction: rtl; /* code should always be written left to right */
+ direction: rtl;
+ /* code should always be written left to right */
}
+
/* BASICS */
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: 400px;
}
+
.CodeMirror-scroll {
/* Set scrolling behavior here */
overflow: auto;
}
/* PADDING */
-
.CodeMirror-lines {
- padding: 4px 0; /* Vertical padding around content */
+ padding: 4px 0;
+ /* Vertical padding around content */
}
+
.CodeMirror pre {
- padding: 0 4px; /* Horizontal padding of content */
+ padding: 0 4px;
+ /* Horizontal padding of content */
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
- background-color: white; /* The little square between H and V scrollbars */
+ background-color: white;
+ /* The little square between H and V scrollbars */
}
/* GUTTER */
-
.CodeMirror-gutters {
border-left: 1px solid #dcdcde;
background-color: #f6f7f7;
white-space: nowrap;
}
-.CodeMirror-linenumbers {}
+
.CodeMirror-linenumber {
padding: 0 5px 0 3px;
min-width: 20px;
@@ -43,69 +47,160 @@
}
/* CURSOR */
-
.CodeMirror div.CodeMirror-cursor {
border-right: 1px solid black;
z-index: 3;
}
+
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
border-right: 1px solid silver;
}
+
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
width: auto;
border: 0;
background: #7e7;
z-index: 1;
}
-/* Can style cursor different in overwrite (non-insert) mode */
-.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite {}
-.cm-tab { display: inline-block; }
+/* Can style cursor different in overwrite (non-insert) mode */
+.cm-tab {
+ display: inline-block;
+}
/* DEFAULT THEME */
+.cm-s-default .cm-keyword {
+ color: #708;
+}
-.cm-s-default .cm-keyword {color: #708;}
-.cm-s-default .cm-atom {color: #219;}
-.cm-s-default .cm-number {color: #164;}
-.cm-s-default .cm-def {color: #00f;}
-.cm-s-default .cm-variable {color: black;}
-.cm-s-default .cm-variable-2 {color: #05a;}
-.cm-s-default .cm-variable-3 {color: #085;}
-.cm-s-default .cm-property {color: black;}
-.cm-s-default .cm-operator {color: black;}
-.cm-s-default .cm-comment {color: #a50;}
-.cm-s-default .cm-string {color: #a11;}
-.cm-s-default .cm-string-2 {color: #f50;}
-.cm-s-default .cm-meta {color: #555;}
-.cm-s-default .cm-error {color: #f00;}
-.cm-s-default .cm-qualifier {color: #555;}
-.cm-s-default .cm-builtin {color: #30a;}
-.cm-s-default .cm-bracket {color: #997;}
-.cm-s-default .cm-tag {color: #170;}
-.cm-s-default .cm-attribute {color: #00c;}
-.cm-s-default .cm-header {color: blue;}
-.cm-s-default .cm-quote {color: #090;}
-.cm-s-default .cm-hr {color: #999;}
-.cm-s-default .cm-link {color: #00c;}
-
-.cm-negative {color: #d44;}
-.cm-positive {color: #292;}
-.cm-header, .cm-strong {font-weight: bold;}
-.cm-em {font-style: italic;}
-.cm-link {text-decoration: underline;}
-
-.cm-invalidchar {color: #f00;}
-
-div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
-div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
-.CodeMirror-activeline-background {background: #e8f2ff;}
+.cm-s-default .cm-atom {
+ color: #219;
+}
-/* STOP */
+.cm-s-default .cm-number {
+ color: #164;
+}
+
+.cm-s-default .cm-def {
+ color: #00f;
+}
+
+.cm-s-default .cm-variable {
+ color: black;
+}
+
+.cm-s-default .cm-variable-2 {
+ color: #05a;
+}
+
+.cm-s-default .cm-variable-3 {
+ color: #085;
+}
+
+.cm-s-default .cm-property {
+ color: black;
+}
+
+.cm-s-default .cm-operator {
+ color: black;
+}
+
+.cm-s-default .cm-comment {
+ color: #a50;
+}
+
+.cm-s-default .cm-string {
+ color: #a11;
+}
+
+.cm-s-default .cm-string-2 {
+ color: #f50;
+}
+
+.cm-s-default .cm-meta {
+ color: #555;
+}
+
+.cm-s-default .cm-error {
+ color: #f00;
+}
+
+.cm-s-default .cm-qualifier {
+ color: #555;
+}
+
+.cm-s-default .cm-builtin {
+ color: #30a;
+}
+
+.cm-s-default .cm-bracket {
+ color: #997;
+}
+
+.cm-s-default .cm-tag {
+ color: #170;
+}
+
+.cm-s-default .cm-attribute {
+ color: #00c;
+}
+.cm-s-default .cm-header {
+ color: blue;
+}
+
+.cm-s-default .cm-quote {
+ color: #090;
+}
+
+.cm-s-default .cm-hr {
+ color: #999;
+}
+
+.cm-s-default .cm-link {
+ color: #00c;
+}
+
+.cm-negative {
+ color: #d44;
+}
+
+.cm-positive {
+ color: #292;
+}
+
+.cm-header, .cm-strong {
+ font-weight: bold;
+}
+
+.cm-em {
+ font-style: italic;
+}
+
+.cm-link {
+ text-decoration: underline;
+}
+
+.cm-invalidchar {
+ color: #f00;
+}
+
+div.CodeMirror span.CodeMirror-matchingbracket {
+ color: #0f0;
+}
+
+div.CodeMirror span.CodeMirror-nonmatchingbracket {
+ color: #f22;
+}
+
+.CodeMirror-activeline-background {
+ background: #e8f2ff;
+}
+
+/* STOP */
/* The rest of this file contains styles related to the mechanics of
the editor. You probably shouldn't touch them. */
-
.CodeMirror {
line-height: 1;
position: relative;
@@ -117,12 +212,16 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-scroll {
/* 30px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
- margin-bottom: -30px; margin-left: -30px;
- padding-bottom: 30px; padding-left: 30px;
+ margin-bottom: -30px;
+ margin-left: -30px;
+ padding-bottom: 30px;
+ padding-left: 30px;
height: 100%;
- outline: none; /* Prevent dragging from highlighting the element */
+ outline: none;
+ /* Prevent dragging from highlighting the element */
position: relative;
}
+
.CodeMirror-sizer {
position: relative;
}
@@ -135,28 +234,39 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
z-index: 6;
display: none;
}
+
.CodeMirror-vscrollbar {
- left: 0; top: 0;
+ left: 0;
+ top: 0;
overflow-x: hidden;
overflow-y: scroll;
}
+
.CodeMirror-hscrollbar {
- bottom: 0; right: 0;
+ bottom: 0;
+ right: 0;
overflow-y: hidden;
overflow-x: scroll;
}
+
.CodeMirror-scrollbar-filler {
- left: 0; bottom: 0;
+ left: 0;
+ bottom: 0;
}
+
.CodeMirror-gutter-filler {
- right: 0; bottom: 0;
+ right: 0;
+ bottom: 0;
}
.CodeMirror-gutters {
- position: absolute; right: 0; top: 0;
+ position: absolute;
+ right: 0;
+ top: 0;
padding-bottom: 30px;
z-index: 3;
}
+
.CodeMirror-gutter {
white-space: normal;
height: 100%;
@@ -164,9 +274,10 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
margin-bottom: -32px;
display: inline-block;
/* Hack to make IE7 behave */
- *zoom:1;
- *display:inline;
+ *zoom: 1;
+ *display: inline;
}
+
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
@@ -176,8 +287,10 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-lines {
cursor: text;
}
+
.CodeMirror pre {
- /* Reset some styles that the rest of the page might have set */ border-radius: 0;
+ /* Reset some styles that the rest of the page might have set */
+ border-radius: 0;
border-width: 0;
background: transparent;
font-family: inherit;
@@ -191,23 +304,30 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
position: relative;
overflow: visible;
}
+
.CodeMirror-wrap pre {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal;
}
+
.CodeMirror-code pre {
border-left: 30px solid transparent;
width: -moz-fit-content;
width: fit-content;
}
+
.CodeMirror-wrap .CodeMirror-code pre {
border-left: none;
width: auto;
}
+
.CodeMirror-linebackground {
position: absolute;
- right: 0; left: 0; top: 0; bottom: 0;
+ right: 0;
+ left: 0;
+ top: 0;
+ bottom: 0;
z-index: 0;
}
@@ -217,20 +337,21 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
overflow: auto;
}
-.CodeMirror-widget {
-}
-
.CodeMirror-wrap .CodeMirror-scroll {
overflow-x: hidden;
}
.CodeMirror-measure {
position: absolute;
- width: 100%; height: 0px;
+ width: 100%;
+ height: 0px;
overflow: hidden;
visibility: hidden;
}
-.CodeMirror-measure pre { position: static; }
+
+.CodeMirror-measure pre {
+ position: static;
+}
.CodeMirror div.CodeMirror-cursor {
position: absolute;
@@ -238,20 +359,28 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
border-left: none;
width: 0;
}
+
.CodeMirror-focused div.CodeMirror-cursor {
visibility: visible;
}
-.CodeMirror-selected { background: #d9d9d9; }
-.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
+.CodeMirror-selected {
+ background: #d9d9d9;
+}
+
+.CodeMirror-focused .CodeMirror-selected {
+ background: #d7d4f0;
+}
.cm-searching {
background: #ffa;
- background: rgba(255, 255, 0, .4);
+ background: rgba(255, 255, 0, 0.4);
}
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
-.CodeMirror span { *vertical-align: text-bottom; }
+.CodeMirror span {
+ *vertical-align: text-bottom;
+}
@media print {
/* Hide the cursor when printing */
diff --git a/plugins/jetpack/modules/custom-css/custom-css/css/codemirror-rtl.min.css b/plugins/jetpack/modules/custom-css/custom-css/css/codemirror-rtl.min.css
index 2a42c1c6..ea4ffc54 100644
--- a/plugins/jetpack/modules/custom-css/custom-css/css/codemirror-rtl.min.css
+++ b/plugins/jetpack/modules/custom-css/custom-css/css/codemirror-rtl.min.css
@@ -1 +1 @@
-.rtl .CodeMirror{direction:rtl}.CodeMirror{font-family:monospace;height:400px}.CodeMirror-scroll{overflow:auto}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-left:1px solid #dcdcde;background-color:#f6f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 5px 0 3px;min-width:20px;text-align:left;color:#999}.CodeMirror div.CodeMirror-cursor{border-right:1px solid #000;z-index:3}.CodeMirror div.CodeMirror-secondarycursor{border-right:1px solid silver}.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor{width:auto;border:0;background:#7e7;z-index:1}.cm-tab{display:inline-block}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable{color:#000}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-property{color:#000}.cm-s-default .cm-operator{color:#000}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-error{color:red}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-invalidchar{color:red}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{line-height:1;position:relative;overflow:hidden;background:#fff;color:#000}.CodeMirror-scroll{margin-bottom:-30px;margin-left:-30px;padding-bottom:30px;padding-left:30px;height:100%;outline:0;position:relative}.CodeMirror-sizer{position:relative}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{left:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;right:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{left:0;bottom:0}.CodeMirror-gutter-filler{right:0;bottom:0}.CodeMirror-gutters{position:absolute;right:0;top:0;padding-bottom:30px;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;padding-bottom:30px;margin-bottom:-32px;display:inline-block}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-lines{cursor:text}.CodeMirror pre{border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-code pre{border-left:30px solid transparent;width:-moz-fit-content;width:fit-content}.CodeMirror-wrap .CodeMirror-code pre{border-left:none;width:auto}.CodeMirror-linebackground{position:absolute;right:0;left:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-measure pre{position:static}.CodeMirror div.CodeMirror-cursor{position:absolute;visibility:hidden;border-left:none;width:0}.CodeMirror-focused div.CodeMirror-cursor{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}@media print{.CodeMirror div.CodeMirror-cursor{visibility:hidden}} \ No newline at end of file
+.rtl .CodeMirror{direction:rtl}.CodeMirror{font-family:monospace;height:400px}.CodeMirror-scroll{overflow:auto}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{background-color:#f6f7f7;border-left:1px solid #dcdcde;white-space:nowrap}.CodeMirror-linenumber{color:#999;min-width:20px;padding:0 5px 0 3px;text-align:left}.CodeMirror div.CodeMirror-cursor{border-right:1px solid #000;z-index:3}.CodeMirror div.CodeMirror-secondarycursor{border-right:1px solid silver}.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor{background:#7e7;border:0;width:auto;z-index:1}.cm-tab{display:inline-block}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable{color:#000}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-operator,.cm-s-default .cm-property{color:#000}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-error{color:red}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-header{color:blue}.cm-s-default .cm-quote{color:#090}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-invalidchar{color:red}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{background:#fff;color:#000;line-height:1;overflow:hidden;position:relative}.CodeMirror-scroll{height:100%;margin-bottom:-30px;margin-left:-30px;outline:none;padding-bottom:30px;padding-left:30px;position:relative}.CodeMirror-sizer{position:relative}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{display:none;position:absolute;z-index:6}.CodeMirror-vscrollbar{left:0;overflow-x:hidden;overflow-y:scroll;top:0}.CodeMirror-hscrollbar{bottom:0;overflow-x:scroll;overflow-y:hidden;right:0}.CodeMirror-scrollbar-filler{bottom:0;left:0}.CodeMirror-gutter-filler{bottom:0;right:0}.CodeMirror-gutters{padding-bottom:30px;position:absolute;right:0;top:0;z-index:3}.CodeMirror-gutter{*zoom:1;display:inline-block;*display:inline;height:100%;margin-bottom:-32px;padding-bottom:30px;white-space:normal}.CodeMirror-gutter-elt{cursor:default;position:absolute;z-index:4}.CodeMirror-lines{cursor:text}.CodeMirror pre{word-wrap:normal;background:transparent;border-radius:0;border-width:0;color:inherit;font-family:inherit;font-size:inherit;line-height:inherit;margin:0;overflow:visible;position:relative;white-space:pre;z-index:2}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-code pre{border-left:30px solid transparent;width:-moz-fit-content;width:fit-content}.CodeMirror-wrap .CodeMirror-code pre{border-left:none;width:auto}.CodeMirror-linebackground{bottom:0;left:0;position:absolute;right:0;top:0;z-index:0}.CodeMirror-linewidget{overflow:auto;position:relative;z-index:2}.CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}.CodeMirror-measure{height:0;overflow:hidden;position:absolute;visibility:hidden;width:100%}.CodeMirror-measure pre{position:static}.CodeMirror div.CodeMirror-cursor{border-left:none;position:absolute;visibility:hidden;width:0}.CodeMirror-focused div.CodeMirror-cursor{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.CodeMirror span{*vertical-align:text-bottom}@media print{.CodeMirror div.CodeMirror-cursor{visibility:hidden}} \ No newline at end of file
diff --git a/plugins/jetpack/modules/custom-css/custom-css/css/codemirror.min.css b/plugins/jetpack/modules/custom-css/custom-css/css/codemirror.min.css
index d2c39eef..097c7c6c 100644
--- a/plugins/jetpack/modules/custom-css/custom-css/css/codemirror.min.css
+++ b/plugins/jetpack/modules/custom-css/custom-css/css/codemirror.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-.rtl .CodeMirror{direction:ltr}.CodeMirror{font-family:monospace;height:400px}.CodeMirror-scroll{overflow:auto}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #dcdcde;background-color:#f6f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999}.CodeMirror div.CodeMirror-cursor{border-left:1px solid #000;z-index:3}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor{width:auto;border:0;background:#7e7;z-index:1}.cm-tab{display:inline-block}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable{color:#000}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-property{color:#000}.cm-s-default .cm-operator{color:#000}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-error{color:red}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-invalidchar{color:red}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{line-height:1;position:relative;overflow:hidden;background:#fff;color:#000}.CodeMirror-scroll{margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;padding-right:30px;height:100%;outline:0;position:relative}.CodeMirror-sizer{position:relative}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;padding-bottom:30px;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;padding-bottom:30px;margin-bottom:-32px;display:inline-block}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-lines{cursor:text}.CodeMirror pre{border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-code pre{border-right:30px solid transparent;width:-moz-fit-content;width:fit-content}.CodeMirror-wrap .CodeMirror-code pre{border-right:none;width:auto}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-measure pre{position:static}.CodeMirror div.CodeMirror-cursor{position:absolute;visibility:hidden;border-right:none;width:0}.CodeMirror-focused div.CodeMirror-cursor{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}@media print{.CodeMirror div.CodeMirror-cursor{visibility:hidden}} \ No newline at end of file
+.rtl .CodeMirror{direction:ltr}.CodeMirror{font-family:monospace;height:400px}.CodeMirror-scroll{overflow:auto}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{background-color:#f6f7f7;border-right:1px solid #dcdcde;white-space:nowrap}.CodeMirror-linenumber{color:#999;min-width:20px;padding:0 3px 0 5px;text-align:right}.CodeMirror div.CodeMirror-cursor{border-left:1px solid #000;z-index:3}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor{background:#7e7;border:0;width:auto;z-index:1}.cm-tab{display:inline-block}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable{color:#000}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-operator,.cm-s-default .cm-property{color:#000}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-error{color:red}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-header{color:blue}.cm-s-default .cm-quote{color:#090}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-invalidchar{color:red}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{background:#fff;color:#000;line-height:1;overflow:hidden;position:relative}.CodeMirror-scroll{height:100%;margin-bottom:-30px;margin-right:-30px;outline:none;padding-bottom:30px;padding-right:30px;position:relative}.CodeMirror-sizer{position:relative}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{display:none;position:absolute;z-index:6}.CodeMirror-vscrollbar{overflow-x:hidden;overflow-y:scroll;right:0;top:0}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-x:scroll;overflow-y:hidden}.CodeMirror-scrollbar-filler{bottom:0;right:0}.CodeMirror-gutter-filler{bottom:0;left:0}.CodeMirror-gutters{left:0;padding-bottom:30px;position:absolute;top:0;z-index:3}.CodeMirror-gutter{*zoom:1;display:inline-block;*display:inline;height:100%;margin-bottom:-32px;padding-bottom:30px;white-space:normal}.CodeMirror-gutter-elt{cursor:default;position:absolute;z-index:4}.CodeMirror-lines{cursor:text}.CodeMirror pre{word-wrap:normal;background:transparent;border-radius:0;border-width:0;color:inherit;font-family:inherit;font-size:inherit;line-height:inherit;margin:0;overflow:visible;position:relative;white-space:pre;z-index:2}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-code pre{border-right:30px solid transparent;width:-moz-fit-content;width:fit-content}.CodeMirror-wrap .CodeMirror-code pre{border-right:none;width:auto}.CodeMirror-linebackground{bottom:0;left:0;position:absolute;right:0;top:0;z-index:0}.CodeMirror-linewidget{overflow:auto;position:relative;z-index:2}.CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}.CodeMirror-measure{height:0;overflow:hidden;position:absolute;visibility:hidden;width:100%}.CodeMirror-measure pre{position:static}.CodeMirror div.CodeMirror-cursor{border-right:none;position:absolute;visibility:hidden;width:0}.CodeMirror-focused div.CodeMirror-cursor{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.CodeMirror span{*vertical-align:text-bottom}@media print{.CodeMirror div.CodeMirror-cursor{visibility:hidden}} \ No newline at end of file
diff --git a/plugins/jetpack/modules/custom-css/custom-css/css/css-editor-rtl.css b/plugins/jetpack/modules/custom-css/custom-css/css/css-editor-rtl.css
index a8202fb2..fb9b95b9 100644
--- a/plugins/jetpack/modules/custom-css/custom-css/css/css-editor-rtl.css
+++ b/plugins/jetpack/modules/custom-css/custom-css/css/css-editor-rtl.css
@@ -1,33 +1,32 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
#revision-field-post_title, #revision-field-post_excerpt {
- display: none;
+ display: none;
}
#safecssform {
- position: relative;
+ position: relative;
}
#poststuff {
- padding-top: 0;
+ padding-top: 0;
}
#safecss {
- min-height: 250px;
- width: 100%;
+ min-height: 250px;
+ width: 100%;
}
.misc-pub-section > span {
- font-weight: bold;
+ font-weight: bold;
}
.misc-pub-section > div {
- margin-top: 3px;
+ margin-top: 3px;
}
+
#safecss-ace .ace_gutter {
- z-index: 1;
+ z-index: 1;
}
-#post-body-content{
- margin-bottom: 20px;
+#post-body-content {
+ margin-bottom: 20px;
}
-
diff --git a/plugins/jetpack/modules/custom-css/custom-css/css/css-editor.min.css b/plugins/jetpack/modules/custom-css/custom-css/css/css-editor.min.css
index 6245c019..62eb4809 100644
--- a/plugins/jetpack/modules/custom-css/custom-css/css/css-editor.min.css
+++ b/plugins/jetpack/modules/custom-css/custom-css/css/css-editor.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
#revision-field-post_excerpt,#revision-field-post_title{display:none}#safecssform{position:relative}#poststuff{padding-top:0}#safecss{min-height:250px;width:100%}.misc-pub-section>span{font-weight:700}.misc-pub-section>div{margin-top:3px}#safecss-ace .ace_gutter{z-index:1}#post-body-content{margin-bottom:20px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/custom-css/custom-css/css/use-codemirror-rtl.css b/plugins/jetpack/modules/custom-css/custom-css/css/use-codemirror-rtl.css
index 649fb168..77af38b5 100644
--- a/plugins/jetpack/modules/custom-css/custom-css/css/use-codemirror-rtl.css
+++ b/plugins/jetpack/modules/custom-css/custom-css/css/use-codemirror-rtl.css
@@ -1,7 +1,6 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
.CodeMirror, #safecss {
- font-family: Consolas, Monaco, monospace;
- font-size: 12px;
- line-height: 16px;
- min-height: 300px;
-} \ No newline at end of file
+ font-family: Consolas, Monaco, monospace;
+ font-size: 12px;
+ line-height: 16px;
+ min-height: 300px;
+}
diff --git a/plugins/jetpack/modules/custom-css/custom-css/css/use-codemirror.min.css b/plugins/jetpack/modules/custom-css/custom-css/css/use-codemirror.min.css
index 024ae478..8dce7dda 100644
--- a/plugins/jetpack/modules/custom-css/custom-css/css/use-codemirror.min.css
+++ b/plugins/jetpack/modules/custom-css/custom-css/css/use-codemirror.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
#safecss,.CodeMirror{font-family:Consolas,Monaco,monospace;font-size:12px;line-height:16px;min-height:300px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/custom-css/custom-css/preprocessors.php b/plugins/jetpack/modules/custom-css/custom-css/preprocessors.php
index 7d561b3d..6cea6b06 100644
--- a/plugins/jetpack/modules/custom-css/custom-css/preprocessors.php
+++ b/plugins/jetpack/modules/custom-css/custom-css/preprocessors.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* CSS preprocessor registration.
@@ -15,16 +15,15 @@
* @param array $preprocessors The list of preprocessors added thus far.
* @return array
*/
-
function jetpack_register_css_preprocessors( $preprocessors ) {
$preprocessors['less'] = array(
- 'name' => 'LESS',
- 'callback' => 'jetpack_less_css_preprocess'
+ 'name' => 'LESS',
+ 'callback' => 'jetpack_less_css_preprocess',
);
$preprocessors['sass'] = array(
- 'name' => 'Sass (SCSS Syntax)',
- 'callback' => 'jetpack_sass_css_preprocess'
+ 'name' => 'Sass (SCSS Syntax)',
+ 'callback' => 'jetpack_sass_css_preprocess',
);
return $preprocessors;
@@ -32,8 +31,13 @@ function jetpack_register_css_preprocessors( $preprocessors ) {
add_filter( 'jetpack_custom_css_preprocessors', 'jetpack_register_css_preprocessors' );
+/**
+ * Compile less prepocessors?
+ *
+ * @param string $less - less.
+ */
function jetpack_less_css_preprocess( $less ) {
- require_once( dirname( __FILE__ ) . '/preprocessors/lessc.inc.php' );
+ require_once __DIR__ . '/preprocessors/lessc.inc.php';
$compiler = new lessc();
@@ -44,8 +48,13 @@ function jetpack_less_css_preprocess( $less ) {
}
}
+/**
+ * Compile sass prepocessors?
+ *
+ * @param string $sass - sass.
+ */
function jetpack_sass_css_preprocess( $sass ) {
- require_once( dirname( __FILE__ ) . '/preprocessors/scss.inc.php' );
+ require_once __DIR__ . '/preprocessors/scss.inc.php';
$compiler = new scssc();
$compiler->setFormatter( 'scss_formatter' );
@@ -55,4 +64,4 @@ function jetpack_sass_css_preprocess( $sass ) {
} catch ( Exception $e ) {
return $sass;
}
-} \ No newline at end of file
+}
diff --git a/plugins/jetpack/modules/custom-css/custom-css/preprocessors/lessc.inc.php b/plugins/jetpack/modules/custom-css/custom-css/preprocessors/lessc.inc.php
index 4bdd2766..ce0a4e48 100644
--- a/plugins/jetpack/modules/custom-css/custom-css/preprocessors/lessc.inc.php
+++ b/plugins/jetpack/modules/custom-css/custom-css/preprocessors/lessc.inc.php
@@ -1,5 +1,4 @@
-<?php
-
+<?php // phpcs:disable -- Copy-pasted library. Not reformatting to facilitate identification of actual changes.
/**
* lessphp v0.5.0
* https://leafo.net/lessphp
diff --git a/plugins/jetpack/modules/custom-css/custom-css/preprocessors/scss.inc.php b/plugins/jetpack/modules/custom-css/custom-css/preprocessors/scss.inc.php
index d057c0ee..69b2fa84 100644
--- a/plugins/jetpack/modules/custom-css/custom-css/preprocessors/scss.inc.php
+++ b/plugins/jetpack/modules/custom-css/custom-css/preprocessors/scss.inc.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:disable -- Copy-pasted library. Not reformatting to facilitate identification of actual changes.
/**
* SCSS compiler written in PHP
*
@@ -1631,7 +1631,7 @@ class scssc {
foreach ($args as $arg) {
list($key, $value) = $arg;
- $key = $key[1];
+ $key = isset( $key[1] ) ? $key[1] : null;
if (empty($key)) {
$posArgs[] = $value;
} else {
diff --git a/plugins/jetpack/modules/custom-css/migrate-to-core.php b/plugins/jetpack/modules/custom-css/migrate-to-core.php
index d26092b4..c902dc2a 100644
--- a/plugins/jetpack/modules/custom-css/migrate-to-core.php
+++ b/plugins/jetpack/modules/custom-css/migrate-to-core.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Migration from Jetpack Custom CSS to WordPress' Core CSS.
*
@@ -18,7 +18,7 @@ class Jetpack_Custom_CSS_Data_Migration {
add_action( 'init', array( __CLASS__, 'register_legacy_post_type' ) );
add_action( 'admin_init', array( __CLASS__, 'do_migration' ) );
- include_once( dirname( __FILE__ ) . '/custom-css.php' );
+ include_once __DIR__ . '/custom-css.php';
if ( ! is_admin() ) {
add_action( 'init', array( 'Jetpack_Custom_CSS', 'init' ) );
}
@@ -38,15 +38,15 @@ class Jetpack_Custom_CSS_Data_Migration {
}
/** This filter is documented in modules/custom-css/custom-css.php */
- $preprocessors = apply_filters( 'jetpack_custom_css_preprocessors', array() );
- $core_css_post = wp_get_custom_css_post();
- $jetpack_css_post = self::get_post();
+ $preprocessors = apply_filters( 'jetpack_custom_css_preprocessors', array() );
+ $core_css_post = wp_get_custom_css_post();
+ $jetpack_css_post = self::get_post();
if ( ! $jetpack_css_post ) {
return;
}
- $revisions = self::get_all_revisions();
+ $revisions = self::get_all_revisions();
// Migrate the settings from revision meta to theme mod.
$options = self::get_options( $jetpack_css_post->ID );
@@ -63,11 +63,11 @@ class Jetpack_Custom_CSS_Data_Migration {
return null;
}
- $revisions = array_reverse( $revisions );
- $themes = Jetpack_Custom_CSS_Enhancements::get_themes();
- $migrated = array();
+ $revisions = array_reverse( $revisions );
+ $themes = Jetpack_Custom_CSS_Enhancements::get_themes();
+ $migrated = array();
- foreach ( $revisions as $post_id => $post ) {
+ foreach ( $revisions as $post ) {
// Jetpack had stored the theme Name, not the stylesheet directory, for ... reasons.
// Get the stylesheet. If null, the theme is no longer available. Skip.
$stylesheet = isset( $themes[ $post->post_excerpt ] ) ? $themes[ $post->post_excerpt ] : null;
@@ -75,10 +75,10 @@ class Jetpack_Custom_CSS_Data_Migration {
continue;
}
- $migrated[] = $post->ID;
+ $migrated[] = $post->ID;
$preprocessor = get_post_meta( $post->ID, 'custom_css_preprocessor', true );
- $css = $post->post_content;
- $pre = '';
+ $css = $post->post_content;
+ $pre = '';
// Do a revision by revision parsing.
if ( $preprocessor && isset( $preprocessors[ $preprocessor ] ) ) {
@@ -87,10 +87,13 @@ class Jetpack_Custom_CSS_Data_Migration {
}
kses_remove_filters();
- wp_update_custom_css_post( $css, array(
- 'stylesheet' => $stylesheet,
- 'preprocessed' => $pre,
- ) );
+ wp_update_custom_css_post(
+ $css,
+ array(
+ 'stylesheet' => $stylesheet,
+ 'preprocessed' => $pre,
+ )
+ );
kses_init();
}
@@ -113,9 +116,12 @@ class Jetpack_Custom_CSS_Data_Migration {
$css .= $jetpack_css_post->post_content;
}
- wp_update_custom_css_post( $css, array(
- 'preprocessed' => $pre,
- ) );
+ wp_update_custom_css_post(
+ $css,
+ array(
+ 'preprocessed' => $pre,
+ )
+ );
}
Jetpack::log( 'custom_css_4.7_migration', count( $migrated ) . 'revisions migrated' );
@@ -131,21 +137,24 @@ class Jetpack_Custom_CSS_Data_Migration {
}
// Register safecss as a custom post_type
// Explicit capability definitions are largely unnecessary because the posts are manipulated in code via an options page, managing CSS revisions does check the capabilities, so let's ensure that the proper caps are checked.
- register_post_type( 'safecss', array(
- 'label' => 'Custom CSS',
- 'supports' => array( 'revisions' ),
- 'can_export' => false,
- 'rewrite' => false,
- 'capabilities' => array(
- 'edit_post' => 'edit_theme_options',
- 'read_post' => 'read',
- 'delete_post' => 'edit_theme_options',
- 'edit_posts' => 'edit_theme_options',
- 'edit_others_posts' => 'edit_theme_options',
- 'publish_posts' => 'edit_theme_options',
- 'read_private_posts' => 'read',
- ),
- ) );
+ register_post_type(
+ 'safecss',
+ array(
+ 'label' => 'Custom CSS',
+ 'supports' => array( 'revisions' ),
+ 'can_export' => false,
+ 'rewrite' => false,
+ 'capabilities' => array(
+ 'edit_post' => 'edit_theme_options',
+ 'read_post' => 'read',
+ 'delete_post' => 'edit_theme_options',
+ 'edit_posts' => 'edit_theme_options',
+ 'edit_others_posts' => 'edit_theme_options',
+ 'publish_posts' => 'edit_theme_options',
+ 'read_private_posts' => 'read',
+ ),
+ )
+ );
}
/**
@@ -158,20 +167,22 @@ class Jetpack_Custom_CSS_Data_Migration {
public static function get_post() {
/** This filter is documented in modules/custom-css/custom-css.php */
$custom_css_post_id = apply_filters( 'jetpack_custom_css_pre_post_id', null );
- if ( ! is_null( $custom_css_post_id ) ) {
+ if ( $custom_css_post_id !== null ) {
return get_post( $custom_css_post_id );
}
$custom_css_post_id = wp_cache_get( 'custom_css_post_id' );
if ( false === $custom_css_post_id ) {
- $custom_css_posts = get_posts( array(
- 'posts_per_page' => 1,
- 'post_type' => 'safecss',
- 'post_status' => 'publish',
- 'orderby' => 'date',
- 'order' => 'DESC',
- ) );
+ $custom_css_posts = get_posts(
+ array(
+ 'posts_per_page' => 1,
+ 'post_type' => 'safecss',
+ 'post_status' => 'publish',
+ 'orderby' => 'date',
+ 'order' => 'DESC',
+ )
+ );
$custom_css_post_id = 0;
if ( count( $custom_css_posts ) > 0 ) {
@@ -201,11 +212,14 @@ class Jetpack_Custom_CSS_Data_Migration {
return array();
}
- $revisions = wp_get_post_revisions( $post->ID, array(
- 'posts_per_page' => -1,
- 'orderby' => 'date',
- 'order' => 'DESC',
- ) );
+ $revisions = wp_get_post_revisions(
+ $post->ID,
+ array(
+ 'posts_per_page' => -1,
+ 'orderby' => 'date',
+ 'order' => 'DESC',
+ )
+ );
return $revisions;
}
@@ -221,7 +235,7 @@ class Jetpack_Custom_CSS_Data_Migration {
*/
public static function get_options( $post_id = null ) {
if ( empty( $post_id ) ) {
- $post = self::get_post();
+ $post = self::get_post();
$post_id = $post->ID;
}
@@ -235,7 +249,7 @@ class Jetpack_Custom_CSS_Data_Migration {
return array(
'preprocessor' => isset( $meta['custom_css_preprocessor'][0] ) ? $meta['custom_css_preprocessor'][0] : '',
'replace' => $replace,
- 'content_width' => isset( $meta['content_width'][0] ) ? $meta['content_width'][0] : '',
+ 'content_width' => isset( $meta['content_width'][0] ) ? $meta['content_width'][0] : '',
);
}
}
diff --git a/plugins/jetpack/modules/custom-post-types/comics.php b/plugins/jetpack/modules/custom-post-types/comics.php
index fdbf62b7..7357c523 100644
--- a/plugins/jetpack/modules/custom-post-types/comics.php
+++ b/plugins/jetpack/modules/custom-post-types/comics.php
@@ -1,15 +1,29 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Create and manage comics with this Custom Post Type.
+ *
+ * @package automattic/jetpack
+ */
use Automattic\Jetpack\Assets;
+/**
+ * Create a jetpack-comic CPT.
+ */
class Jetpack_Comic {
const POST_TYPE = 'jetpack-comic';
- static function init() {
+ /**
+ * Initialize the class.
+ *
+ * @return self
+ */
+ public static function init() {
static $instance = false;
- if ( ! $instance )
+ if ( ! $instance ) {
$instance = new Jetpack_Comic();
+ }
return $instance;
}
@@ -23,7 +37,7 @@ class Jetpack_Comic {
* If no theme support is found there is no need to hook into
* WordPress. We'll just return early instead.
*/
- function __construct() {
+ public function __construct() {
// Make sure the post types are loaded for imports
add_action( 'import_start', array( $this, 'register_post_types' ) );
@@ -34,8 +48,9 @@ class Jetpack_Comic {
add_action( 'restapi_theme_init', array( $this, 'maybe_register_post_types' ) );
// Return early if theme does not support Jetpack Comic.
- if ( ! ( $this->site_supports_comics() ) )
+ if ( ! ( $this->site_supports_comics() ) ) {
return;
+ }
$this->register_post_types();
@@ -78,22 +93,27 @@ class Jetpack_Comic {
add_action( 'admin_notices', array( $this, 'bulk_edit_notices' ) );
}
+ /**
+ * Enqueue JavaScript in the footer.
+ *
+ * @return void
+ */
public function admin_footer() {
$post_type = get_post_type();
?>
<script type="text/javascript">
jQuery( document ).ready( function( $ ) {
- <?php if ( ! $post_type || 'post' == $post_type ) { ?>
+ <?php if ( ! $post_type || 'post' === $post_type ) { ?>
$( '<option>' )
.val( 'post2comic' )
- .text( <?php echo json_encode( __( 'Convert to Comic', 'jetpack' ) ); ?> )
+ .text( <?php echo wp_json_encode( __( 'Convert to Comic', 'jetpack' ) ); ?> )
.appendTo( "select[name='action'], select[name='action2']" );
<?php } ?>
- <?php if ( ! $post_type || self::POST_TYPE == $post_type ) { ?>
+ <?php if ( ! $post_type || self::POST_TYPE === $post_type ) { ?>
$( '<option>' )
.val( 'comic2post' )
- .text( <?php echo json_encode( __( 'Convert to Post', 'jetpack' ) ); ?> )
+ .text( <?php echo wp_json_encode( __( 'Convert to Post', 'jetpack' ) ); ?> )
.appendTo( "select[name='action'], select[name='action2']" );
<?php } ?>
@@ -105,34 +125,38 @@ class Jetpack_Comic {
/**
* Handle the "Convert to [Post|Comic]" bulk action.
+ *
+ * @return void
*/
public function bulk_edit() {
- if ( empty( $_REQUEST['post'] ) )
+ if ( empty( $_REQUEST['post'] ) ) {
return;
+ }
$wp_list_table = _get_list_table( 'WP_Posts_List_Table' );
- $action = $wp_list_table->current_action();
+ $action = $wp_list_table->current_action();
check_admin_referer( 'bulk-posts' );
- if ( 'post2comic' == $action || 'comic2post' == $action ) {
- if ( ! current_user_can( 'publish_posts' ) )
- wp_die( __( 'You are not allowed to make this change.', 'jetpack' ) );
+ if ( 'post2comic' === $action || 'comic2post' === $action ) {
+ if ( ! current_user_can( 'publish_posts' ) ) {
+ wp_die( esc_html__( 'You are not allowed to make this change.', 'jetpack' ) );
+ }
$post_ids = array_map( 'intval', $_REQUEST['post'] );
$modified_count = 0;
foreach ( $post_ids as $post_id ) {
- $destination_post_type = ( $action == 'post2comic' ) ? self::POST_TYPE : 'post';
- $origin_post_type = ( $destination_post_type == 'post' ) ? self::POST_TYPE : 'post';
+ $destination_post_type = ( $action === 'post2comic' ) ? self::POST_TYPE : 'post';
+ $origin_post_type = ( $destination_post_type === 'post' ) ? self::POST_TYPE : 'post';
if ( current_user_can( 'edit_post', $post_id ) ) {
$post = get_post( $post_id );
// Only convert posts that are post => comic or comic => post.
// (e.g., Ignore comic => comic, page => post, etc. )
- if ( $post->post_type != $destination_post_type && $post->post_type == $origin_post_type ) {
+ if ( $post->post_type !== $destination_post_type && $post->post_type === $origin_post_type ) {
$post_type_object = get_post_type_object( $destination_post_type );
if ( current_user_can( $post_type_object->cap->publish_posts ) ) {
@@ -145,11 +169,20 @@ class Jetpack_Comic {
$sendback = remove_query_arg( array( 'exported', 'untrashed', 'deleted', 'ids' ), wp_get_referer() );
- if ( ! $sendback )
+ if ( ! $sendback ) {
$sendback = add_query_arg( array( 'post_type', get_post_type() ), admin_url( 'edit.php' ) );
+ }
- $pagenum = $wp_list_table->get_pagenum();
- $sendback = add_query_arg( array( 'paged' => $pagenum, 'post_type_changed' => $modified_count ), $sendback );
+ $pagenum = $wp_list_table->get_pagenum();
+ $bulk_edit_comics_nonce = wp_create_nonce( 'bulk-edit-comics-nonce' );
+ $sendback = add_query_arg(
+ array(
+ 'paged' => $pagenum,
+ 'post_type_changed' => $modified_count,
+ 'bulk_edit_comics_nonce' => $bulk_edit_comics_nonce,
+ ),
+ $sendback
+ );
wp_safe_redirect( $sendback );
exit();
@@ -158,17 +191,45 @@ class Jetpack_Comic {
/**
* Show the post conversion success notice.
+ *
+ * @return void
*/
public function bulk_edit_notices() {
global $pagenow;
- if ( 'edit.php' == $pagenow && ! empty( $_GET['post_type_changed'] ) ) {
- ?><div id="message" class="updated below-h2 jetpack-comic-post-type-conversion" style="display: none;"><p><?php
- printf( _n( 'Post converted.', '%s posts converted', $_GET['post_type_changed'], 'jetpack' ), number_format_i18n( $_GET['post_type_changed'] ) );
- ?></p></div><?php
+ if (
+ empty( $_GET['bulk_edit_comics_nonce'] )
+ || ! wp_verify_nonce( sanitize_key( $_GET['bulk_edit_comics_nonce'] ), 'bulk-edit-comics-nonce' )
+ ) {
+ return;
+ }
+
+ $number_posts_changed = isset( $_GET['post_type_changed'] )
+ ? (int) $_GET['post_type_changed']
+ : 0;
+
+ if ( 'edit.php' === $pagenow && $number_posts_changed ) {
+ ?>
+ <div id="message" class="updated below-h2 jetpack-comic-post-type-conversion" style="display: none;"><p>
+ <?php
+ echo esc_html(
+ sprintf(
+ /* Translators: placeholder is a number. */
+ _n( '%s post converted.', '%s posts converted', (int) $number_posts_changed, 'jetpack' ),
+ number_format_i18n( $number_posts_changed )
+ )
+ );
+ ?>
+ </p></div>
+ <?php
}
}
+ /**
+ * Enqueue scripts and styles.
+ *
+ * @return void
+ */
public function register_scripts() {
wp_enqueue_style( 'jetpack-comics-style', plugins_url( 'comics/comics.css', __FILE__ ), array(), JETPACK__VERSION );
wp_style_add_data( 'jetpack-comics-style', 'rtl', 'replace' );
@@ -203,70 +264,89 @@ class Jetpack_Comic {
}
}
+ /**
+ * Enqueue stylesheet in the admin.
+ */
public function admin_enqueue_scripts() {
- wp_enqueue_style( 'jetpack-comics-admin', plugins_url( 'comics/admin.css', __FILE__ ) );
+ wp_enqueue_style( 'jetpack-comics-admin', plugins_url( 'comics/admin.css', __FILE__ ), array(), JETPACK__VERSION );
}
+ /**
+ * Register the post types if the theme supports them.
+ */
public function maybe_register_post_types() {
// Return early if theme does not support Jetpack Comic.
- if ( ! ( $this->site_supports_comics() ) )
+ if ( ! ( $this->site_supports_comics() ) ) {
return;
+ }
$this->register_post_types();
}
- function register_post_types() {
+ /**
+ * Register our CPT.
+ */
+ public function register_post_types() {
if ( post_type_exists( self::POST_TYPE ) ) {
return;
}
- register_post_type( self::POST_TYPE, array(
- 'description' => __( 'Comics', 'jetpack' ),
- 'labels' => array(
- 'name' => esc_html__( 'Comics', 'jetpack' ),
- 'singular_name' => esc_html__( 'Comic', 'jetpack' ),
- 'menu_name' => esc_html__( 'Comics', 'jetpack' ),
- 'all_items' => esc_html__( 'All Comics', 'jetpack' ),
- 'add_new' => esc_html__( 'Add New', 'jetpack' ),
- 'add_new_item' => esc_html__( 'Add New Comic', 'jetpack' ),
- 'edit_item' => esc_html__( 'Edit Comic', 'jetpack' ),
- 'new_item' => esc_html__( 'New Comic', 'jetpack' ),
- 'view_item' => esc_html__( 'View Comic', 'jetpack' ),
- 'search_items' => esc_html__( 'Search Comics', 'jetpack' ),
- 'not_found' => esc_html__( 'No Comics found', 'jetpack' ),
- 'not_found_in_trash' => esc_html__( 'No Comics found in Trash', 'jetpack' ),
- 'filter_items_list' => esc_html__( 'Filter comics list', 'jetpack' ),
- 'items_list_navigation' => esc_html__( 'Comics list navigation', 'jetpack' ),
- 'items_list' => esc_html__( 'Comics list', 'jetpack' ),
- ),
- 'supports' => array(
- 'title',
- 'editor',
- 'thumbnail',
- 'comments',
- 'revisions',
- 'publicize', // Jetpack
- 'subscriptions', // wpcom
- 'shortlinks', // Jetpack
- ),
- 'rewrite' => array(
- 'slug' => 'comic',
- 'with_front' => false,
- ),
- 'taxonomies' => array(
- 'category',
- 'post_tag',
- ),
- // Only make the type public for sites that support Comics.
- 'public' => true,
- 'menu_position' => 5, // below Posts
- 'map_meta_cap' => true,
- 'has_archive' => true,
- 'query_var' => 'comic',
- 'show_in_rest' => true,
- ) );
+ register_post_type(
+ self::POST_TYPE,
+ array(
+ 'description' => __( 'Comics', 'jetpack' ),
+ 'labels' => array(
+ 'name' => esc_html__( 'Comics', 'jetpack' ),
+ 'singular_name' => esc_html__( 'Comic', 'jetpack' ),
+ 'menu_name' => esc_html__( 'Comics', 'jetpack' ),
+ 'all_items' => esc_html__( 'All Comics', 'jetpack' ),
+ 'add_new' => esc_html__( 'Add New', 'jetpack' ),
+ 'add_new_item' => esc_html__( 'Add New Comic', 'jetpack' ),
+ 'edit_item' => esc_html__( 'Edit Comic', 'jetpack' ),
+ 'new_item' => esc_html__( 'New Comic', 'jetpack' ),
+ 'view_item' => esc_html__( 'View Comic', 'jetpack' ),
+ 'search_items' => esc_html__( 'Search Comics', 'jetpack' ),
+ 'not_found' => esc_html__( 'No Comics found', 'jetpack' ),
+ 'not_found_in_trash' => esc_html__( 'No Comics found in Trash', 'jetpack' ),
+ 'filter_items_list' => esc_html__( 'Filter comics list', 'jetpack' ),
+ 'items_list_navigation' => esc_html__( 'Comics list navigation', 'jetpack' ),
+ 'items_list' => esc_html__( 'Comics list', 'jetpack' ),
+ ),
+ 'supports' => array(
+ 'title',
+ 'editor',
+ 'thumbnail',
+ 'comments',
+ 'revisions',
+ 'publicize', // Jetpack
+ 'subscriptions', // wpcom
+ 'shortlinks', // Jetpack
+ ),
+ 'rewrite' => array(
+ 'slug' => 'comic',
+ 'with_front' => false,
+ ),
+ 'taxonomies' => array(
+ 'category',
+ 'post_tag',
+ ),
+ // Only make the type public for sites that support Comics.
+ 'public' => true,
+ 'menu_position' => 5, // below Posts
+ 'map_meta_cap' => true,
+ 'has_archive' => true,
+ 'query_var' => 'comic',
+ 'show_in_rest' => true,
+ )
+ );
}
+ /**
+ * Add a Preview colunm to the Comic CPT admin view.
+ *
+ * @param array $columns An array of column names.
+ * @return array Updated `$columns`.
+ */
public function manage_posts_columns( $columns ) {
$new_columns = array(
'preview-jetpack-comic' => __( 'Preview', 'jetpack' ),
@@ -274,8 +354,14 @@ class Jetpack_Comic {
return array_merge( array_slice( $columns, 0, 2 ), $new_columns, array_slice( $columns, 2 ) );
}
+ /**
+ * Display the post's featured image in column.
+ *
+ * @param string $column_name The name of the column to display.
+ * @param int $post_ID The current post ID.
+ */
public function manage_posts_custom_column( $column_name, $post_ID ) {
- if ( 'preview-jetpack-comic' == $column_name && has_post_thumbnail( $post_ID ) ) {
+ if ( 'preview-jetpack-comic' === $column_name && has_post_thumbnail( $post_ID ) ) {
echo get_the_post_thumbnail( $post_ID, 'jetpack-comic-thumb' );
}
}
@@ -288,38 +374,78 @@ class Jetpack_Comic {
*
* @see https://core.trac.wordpress.org/ticket/19744
* @param string $permalink The existing (possibly pretty) permalink.
+ *
+ * @return string The permalink to use.
*/
public function custom_permalink_for_feedbag( $permalink ) {
global $post;
- if ( ! empty( $GLOBALS['is_feedbag_rss_script'] ) && self::POST_TYPE == $post->post_type ) {
- $permalink = home_url( add_query_arg( array( 'p' => $post->ID, 'post_type' => self::POST_TYPE ), '?' ) );
+ if ( ! empty( $GLOBALS['is_feedbag_rss_script'] ) && self::POST_TYPE === $post->post_type ) {
+ $permalink = home_url(
+ add_query_arg(
+ array(
+ 'p' => $post->ID,
+ 'post_type' => self::POST_TYPE,
+ ),
+ '?'
+ )
+ );
}
return $permalink;
}
- /*
+ /**
* Update messages for the Comic admin.
+ *
+ * @param array $messages Existing post update messages.
+ *
+ * @return array $messages Amended post update messages.
*/
- function updated_messages( $messages ) {
+ public function updated_messages( $messages ) {
global $post;
$messages['jetpack-comic'] = array(
0 => '', // Unused. Messages start at index 1.
- 1 => sprintf( __( 'Comic updated. <a href="%s">View comic</a>', 'jetpack'), esc_url( get_permalink( $post->ID ) ) ),
+ 1 => sprintf(
+ /* Translators: link to comic item's page. */
+ __( 'Comic updated. <a href="%s">View comic</a>', 'jetpack' ),
+ esc_url( get_permalink( $post->ID ) )
+ ),
2 => esc_html__( 'Custom field updated.', 'jetpack' ),
3 => esc_html__( 'Custom field deleted.', 'jetpack' ),
4 => esc_html__( 'Comic updated.', 'jetpack' ),
/* translators: %s: date and time of the revision */
- 5 => isset( $_GET['revision'] ) ? sprintf( esc_html__( 'Comic restored to revision from %s', 'jetpack'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
- 6 => sprintf( __( 'Comic published. <a href="%s">View comic</a>', 'jetpack' ), esc_url( get_permalink( $post->ID ) ) ),
+ 5 => isset( $_GET['revision'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling.
+ ? sprintf(
+ /* Translators: link to comic item's page. */
+ esc_html__( 'Comic restored to revision from %s', 'jetpack' ),
+ wp_post_revision_title( (int) $_GET['revision'], false ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling.
+ )
+ : false,
+ 6 => sprintf(
+ /* Translators: link to comic item's page. */
+ __( 'Comic published. <a href="%s">View comic</a>', 'jetpack' ),
+ esc_url( get_permalink( $post->ID ) )
+ ),
7 => esc_html__( 'Comic saved.', 'jetpack' ),
- 8 => sprintf( __( 'Comic submitted. <a target="_blank" href="%s">Preview comic</a>', 'jetpack'), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ),
- 9 => sprintf( __( 'Comic scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview comic</a>', 'jetpack' ),
- // translators: Publish box date format, see https://php.net/date
- date_i18n( __( 'M j, Y @ G:i', 'jetpack' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ),
- 10 => sprintf( __( 'Comic draft updated. <a target="_blank" href="%s">Preview comic</a>', 'jetpack' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ),
+ 8 => sprintf(
+ /* Translators: link to portfolio item's page. */
+ __( 'Comic submitted. <a target="_blank" href="%s">Preview comic</a>', 'jetpack' ),
+ esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) )
+ ),
+ 9 => sprintf(
+ /* Translators: link to comic item's page. */
+ __( 'Comic scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview comic</a>', 'jetpack' ),
+ // translators: Publish box date format, see https://php.net/date
+ date_i18n( __( 'M j, Y @ G:i', 'jetpack' ), strtotime( $post->post_date ) ),
+ esc_url( get_permalink( $post->ID ) )
+ ),
+ 10 => sprintf(
+ /* Translators: link to comic item's page. */
+ __( 'Comic draft updated. <a target="_blank" href="%s">Preview comic</a>', 'jetpack' ),
+ esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) )
+ ),
);
return $messages;
@@ -327,32 +453,45 @@ class Jetpack_Comic {
/**
* Should this Custom Post Type be made available?
+ *
+ * @return bool
*/
public function site_supports_comics() {
- /**
- * @todo: Extract this out into a wpcom only file.
- */
- if ( 'blog-rss.php' == substr( $_SERVER['PHP_SELF'], -12 ) && count( $_SERVER['argv'] ) > 1 ) {
- // blog-rss.php isn't run in the context of the target blog when the init action fires,
- // so check manually whether the target blog supports comics.
- switch_to_blog( $_SERVER['argv'][1] );
- // The add_theme_support( 'jetpack-comic' ) won't fire on switch_to_blog, so check for Panel manually.
- $supports_comics = ( ( function_exists( 'site_vertical' ) && 'comics' == site_vertical() )
- || current_theme_supports( self::POST_TYPE )
- || get_stylesheet() == 'pub/panel' );
- restore_current_blog();
-
- /** This action is documented in modules/custom-post-types/nova.php */
- return (bool) apply_filters( 'jetpack_enable_cpt', $supports_comics, self::POST_TYPE );
+ if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
+ $php_self = isset( $_SERVER['PHP_SELF'] )
+ ? sanitize_text_field( wp_unslash( $_SERVER['PHP_SELF'] ) )
+ : '';
+ $blog_ids = isset( $_SERVER['argv'] )
+ ? array_map( 'intval', (array) wp_unslash( $_SERVER['argv'] ) )
+ : array();
+
+ if (
+ ! empty( $php_self )
+ && 'blog-rss.php' === substr( $php_self, -12 )
+ && count( $blog_ids ) > 1
+ ) {
+ // blog-rss.php isn't run in the context of the target blog when the init action fires,
+ // so check manually whether the target blog supports comics.
+ switch_to_blog( $blog_ids[1] );
+ // The add_theme_support( 'jetpack-comic' ) won't fire on switch_to_blog, so check for Panel manually.
+ $supports_comics = ( ( function_exists( 'site_vertical' ) && 'comics' === site_vertical() )
+ || current_theme_supports( self::POST_TYPE )
+ || get_stylesheet() === 'pub/panel' );
+ restore_current_blog();
+
+ /** This action is documented in modules/custom-post-types/nova.php */
+ return (bool) apply_filters( 'jetpack_enable_cpt', $supports_comics, self::POST_TYPE );
+ }
}
$supports_comics = false;
/**
* If we're on WordPress.com, and it has the menu site vertical.
+ *
* @todo: Extract this out into a wpcom only file.
*/
- if ( function_exists( 'site_vertical' ) && 'comics' == site_vertical() ) {
+ if ( function_exists( 'site_vertical' ) && 'comics' === site_vertical() ) {
$supports_comics = true;
}
@@ -373,25 +512,31 @@ class Jetpack_Comic {
/**
* Anywhere that a feed is displaying posts, show comics too.
*
- * @param WP_Query $query
+ * @param WP_Query $query The current query.
+ *
+ * @return void
*/
public function include_in_feeds( $query ) {
- if ( ! $query->is_feed() )
+ if ( ! $query->is_feed() ) {
return;
+ }
// Don't modify the query if the post type isn't public.
- if ( ! get_post_type_object( 'jetpack-comic' )->public )
+ if ( ! get_post_type_object( 'jetpack-comic' )->public ) {
return;
+ }
$query_post_types = $query->get( 'post_type' );
- if ( empty( $query_post_types ) )
+ if ( empty( $query_post_types ) ) {
$query_post_types = 'post';
+ }
- if ( ! is_array( $query_post_types ) )
+ if ( ! is_array( $query_post_types ) ) {
$query_post_types = array( $query_post_types );
+ }
- if ( in_array( 'post', $query_post_types ) ) {
+ if ( in_array( 'post', $query_post_types, true ) ) {
$query_post_types[] = self::POST_TYPE;
$query->set( 'post_type', $query_post_types );
}
@@ -405,17 +550,21 @@ class Jetpack_Comic {
header( 'Content-Type: application/json' );
- if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'jetpack_comic_upload_nonce' ) )
- die( json_encode( array( 'error' => __( 'Invalid or expired nonce.', 'jetpack' ) ) ) );
+ if (
+ empty( $_REQUEST['nonce'] )
+ || ! wp_verify_nonce( sanitize_key( $_REQUEST['nonce'] ), 'jetpack_comic_upload_nonce' )
+ ) {
+ die( wp_json_encode( array( 'error' => __( 'Invalid or expired nonce.', 'jetpack' ) ) ) );
+ }
$_POST['action'] = 'wp_handle_upload';
- $image_id_arr = array();
+ $image_id_arr = array();
$image_error_arr = array();
$i = 0;
- while ( isset( $_FILES['image_' . $i ] ) ) {
+ while ( isset( $_FILES[ 'image_' . $i ] ) ) {
// Create attachment for the image.
$image_id = media_handle_upload( "image_$i", 0 );
@@ -429,38 +578,48 @@ class Jetpack_Comic {
$i++;
}
- if ( count( $image_id_arr ) == 0 ) {
+ if ( count( $image_id_arr ) === 0 ) {
// All image uploads failed.
$rv = array( 'error' => '' );
- foreach ( $image_error_arr as $error )
+ foreach ( $image_error_arr as $error ) {
$rv['error'] .= $error[1] . "\n";
- }
- else {
- if ( count( $image_id_arr ) == 1 ) {
+ }
+ } else {
+ if ( count( $image_id_arr ) === 1 ) {
$image_id = $image_id_arr[0];
// Get the image
- $image_src = get_the_guid( $image_id );
+ $image_src = get_the_guid( $image_id );
$image_dims = wp_get_attachment_image_src( $image_id, 'full' );
// Take off 10px of width to account for padding and border. @todo make this smarter.
- if ( $content_width )
+ if ( $content_width ) {
$image_width = $content_width - 10;
- else
+ } else {
$image_width = $image_dims[1] - 10;
+ }
- $post_content = '<a href="' . esc_attr( $image_src ) .'"><img src="' . esc_attr( $image_src ) . '?w=' . esc_attr( $image_width ) . '" alt="' . esc_attr( $_FILES['image_0']['name'] ) . '" class="size-full wp-image alignnone" id="i-' . esc_attr( $image_id ) . '" data-filename="' . esc_attr( $_FILES['image_0']['name'] ) . '" /></a>';
- }
- else {
+ $image_name = isset( $_FILES['image_0']['name'] )
+ ? sanitize_file_name( wp_unslash( $_FILES['image_0']['name'] ) )
+ : '';
+ $post_content = sprintf(
+ '<a href="%1$s"><img src="%1$s?w=%2$d" alt="%3$s" class="size-full wp-image alignnone" id="%4$s" data-filename="%3$s"/></a>',
+ esc_url( $image_src ),
+ esc_attr( $image_width ),
+ esc_attr( $image_name ),
+ esc_attr( $image_id )
+ );
+ } else {
$post_content = '[gallery ids="' . esc_attr( implode( ',', $image_id_arr ) ) . '"]';
}
// Create a new post with the image(s)
- $post_id = wp_insert_post( array(
+ $post_id = wp_insert_post(
+ array(
'post_content' => $post_content,
- 'post_type' => 'jetpack-comic',
- 'post_status' => 'draft',
+ 'post_type' => 'jetpack-comic',
+ 'post_status' => 'draft',
),
true
);
@@ -473,34 +632,51 @@ class Jetpack_Comic {
foreach ( $image_id_arr as $image_id ) {
wp_delete_post( $image_id, true );
}
- }
- else {
+ } else {
foreach ( $image_id_arr as $image_id ) {
- wp_update_post( array(
- 'ID' => $image_id,
- 'post_parent' => $post_id
- ) );
+ wp_update_post(
+ array(
+ 'ID' => $image_id,
+ 'post_parent' => $post_id,
+ )
+ );
}
- if ( current_theme_supports( 'post-thumbnails' ) && count( $image_id_arr ) == 1 )
+ if ( current_theme_supports( 'post-thumbnails' ) && count( $image_id_arr ) === 1 ) {
set_post_thumbnail( $post_id, $image_id_arr[0] );
+ }
- $rv = array( 'url' => add_query_arg( array( 'post' => $post_id, 'action' => 'edit' ), admin_url( 'post.php' ) ) );
+ $rv = array(
+ 'url' => add_query_arg(
+ array(
+ 'post' => $post_id,
+ 'action' => 'edit',
+ ),
+ admin_url( 'post.php' )
+ ),
+ );
}
}
- die( json_encode( $rv ) );
+ die( wp_json_encode( $rv ) );
}
+ /**
+ * Add comic posts to the tag and category pages.
+ *
+ * @param WP_Query $query Post query.
+ *
+ * @return WP_Query
+ */
public function add_posts_to_loop( $query ) {
- // Add comic posts to the tag and category pages.
if ( ! is_admin() && $query->is_main_query() && ( $query->is_category() || $query->is_tag() ) ) {
$post_types = $query->get( 'post_type' );
- if ( ! $post_types || 'post' == $post_types )
+ if ( ! $post_types || 'post' === $post_types ) {
$post_types = array( 'post', self::POST_TYPE );
- else if ( is_array( $post_types ) )
+ } elseif ( is_array( $post_types ) ) {
$post_types[] = self::POST_TYPE;
+ }
$query->set( 'post_type', $post_types );
}
@@ -510,6 +686,10 @@ class Jetpack_Comic {
/**
* Add to REST API post type allowed list.
+ *
+ * @param array $post_types Array of post types to add to the allowed list.
+ *
+ * @return array
*/
public function allow_rest_api_type( $post_types ) {
$post_types[] = self::POST_TYPE;
@@ -520,20 +700,33 @@ class Jetpack_Comic {
add_action( 'init', array( 'Jetpack_Comic', 'init' ) );
-
+/**
+ * Custom welcome email for WordPress.com sites in the Comic vertical.
+ *
+ * @param string $welcome_email Body of the email.
+ * @param int $blog_id Site ID.
+ * @param int $user_id User ID.
+ * @param string $password User password, or "N/A" if the user account is not new.
+ * @param string $title Site title.
+ * @param array $meta Signup meta data. By default, contains the requested privacy setting and lang id.
+ *
+ * @return string
+ */
function comics_welcome_email( $welcome_email, $blog_id, $user_id, $password, $title, $meta ) {
- if ( ( isset( $meta['vertical'] ) && 'comics' == $meta['vertical'] ) || has_blog_sticker( 'vertical-comics', $blog_id ) ) {
- return __( "Welcome! Ready to publish your first strip?
+ if ( ( isset( $meta['vertical'] ) && 'comics' === $meta['vertical'] ) || has_blog_sticker( 'vertical-comics', $blog_id ) ) {
+ return __(
+ "Welcome! Ready to publish your first strip?
Your webcomic's new site is ready to go. Get started by <a href=\"BLOG_URLwp-admin/customize.php#title\">setting your comic's title and tagline</a> so your readers know what it's all about.
Looking for more help with setting up your site? Check out the WordPress.com <a href=\"https://learn.wordpress.com/\" target=\"_blank\">beginner's tutorial</a> and the <a href=\"https://en.support.wordpress.com/comics/\" target=\"_blank\">guide to comics on WordPress.com</a>. Dive right in by <a href=\"BLOG_URLwp-admin/customize.php#title\">publishing your first strip!</a>
Lots of laughs,
-The WordPress.com Team", 'jetpack' );
+The WordPress.com Team",
+ 'jetpack'
+ );
}
return $welcome_email;
}
-
add_filter( 'update_welcome_email_pre_replacement', 'comics_welcome_email', 10, 6 );
diff --git a/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.css b/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.css
index bcf00642..8f13c819 100644
--- a/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.css
+++ b/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.css
@@ -1,54 +1,53 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
#jetpack-comic-drop-zone .dragging, #jetpack-comic-drop-zone .uploading {
- margin-top: 200px;
- display: none;
+ margin-top: 200px;
+ display: none;
}
/* Display the appropriate loading message for each upload state. */
body.dragging #jetpack-comic-drop-zone .dragging, body.uploading #jetpack-comic-drop-zone .uploading {
- display: block;
+ display: block;
}
body.uploading #jetpack-comic-drop-zone .uploading .spinner,
body.uploading #jetpack-comic-drop-zone .uploading .spinner:after {
- border-radius: 50%;
- width: 60px;
- height: 60px;
+ border-radius: 50%;
+ width: 60px;
+ height: 60px;
}
+
body.uploading #jetpack-comic-drop-zone .uploading .spinner {
- display: block;
- margin: 15px auto;
- font-size: 10px;
- position: relative;
- text-indent: -9999em;
- border-top: 1.1em solid rgba(255, 255, 255, 0.2);
- border-left: 1.1em solid rgba(255, 255, 255, 0.2);
- border-bottom: 1.1em solid rgba(255, 255, 255, 0.2);
- border-right: 1.1em solid #ffffff;
- transform: translateZ(0);
- animation: load8 1.1s infinite linear;
+ display: block;
+ margin: 15px auto;
+ font-size: 10px;
+ position: relative;
+ text-indent: -9999em;
+ border-top: 1.1em solid rgba(255, 255, 255, 0.2);
+ border-left: 1.1em solid rgba(255, 255, 255, 0.2);
+ border-bottom: 1.1em solid rgba(255, 255, 255, 0.2);
+ border-right: 1.1em solid #ffffff;
+ transform: translateZ(0);
+ animation: load8 1.1s infinite linear;
}
@keyframes load8 {
- 0% {
- transform: rotate(0deg);
- }
- 100% {
- transform: rotate(-360deg);
- }
+ 0% {
+ transform: rotate(0deg);
+ }
+ 100% {
+ transform: rotate(-360deg);
+ }
}
-
/* Add the drop zone overlay. */
body.dragging #jetpack-comic-drop-zone, body.uploading #jetpack-comic-drop-zone {
- background: rgba( 0, 86, 132, 0.9 );
- border: 1px dashed #fff;
- color: #fff;
- display: block;
- font-size: 30px;
- position: fixed;
- top: 10px;
- right: 10px;
- left: 10px;
- bottom: 10px;
- text-align: center;
- z-index: 99999;
+ background: rgba(0, 86, 132, 0.9);
+ border: 1px dashed #fff;
+ color: #fff;
+ display: block;
+ font-size: 30px;
+ position: fixed;
+ top: 10px;
+ right: 10px;
+ left: 10px;
+ bottom: 10px;
+ text-align: center;
+ z-index: 99999;
}
diff --git a/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.min.css b/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.min.css
index 16adbc17..27096f46 100644
--- a/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.min.css
+++ b/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.min.css
@@ -1 +1 @@
-#jetpack-comic-drop-zone .dragging,#jetpack-comic-drop-zone .uploading{margin-top:200px;display:none}body.dragging #jetpack-comic-drop-zone .dragging,body.uploading #jetpack-comic-drop-zone .uploading{display:block}body.uploading #jetpack-comic-drop-zone .uploading .spinner,body.uploading #jetpack-comic-drop-zone .uploading .spinner:after{border-radius:50%;width:60px;height:60px}body.uploading #jetpack-comic-drop-zone .uploading .spinner{display:block;margin:15px auto;font-size:10px;position:relative;text-indent:-9999em;border-top:1.1em solid rgba(255,255,255,.2);border-left:1.1em solid rgba(255,255,255,.2);border-bottom:1.1em solid rgba(255,255,255,.2);border-right:1.1em solid #fff;transform:translateZ(0);animation:load8 1.1s infinite linear}@keyframes load8{0%{transform:rotate(0)}100%{transform:rotate(-360deg)}}body.dragging #jetpack-comic-drop-zone,body.uploading #jetpack-comic-drop-zone{background:rgba(0,86,132,.9);border:1px dashed #fff;color:#fff;display:block;font-size:30px;position:fixed;top:10px;right:10px;left:10px;bottom:10px;text-align:center;z-index:99999} \ No newline at end of file
+#jetpack-comic-drop-zone .dragging,#jetpack-comic-drop-zone .uploading{display:none;margin-top:200px}body.dragging #jetpack-comic-drop-zone .dragging,body.uploading #jetpack-comic-drop-zone .uploading{display:block}body.uploading #jetpack-comic-drop-zone .uploading .spinner,body.uploading #jetpack-comic-drop-zone .uploading .spinner:after{border-radius:50%;height:60px;width:60px}body.uploading #jetpack-comic-drop-zone .uploading .spinner{animation:load8 1.1s linear infinite;border:1.1em solid hsla(0,0%,100%,.2);border-right-color:#fff;display:block;font-size:10px;margin:15px auto;position:relative;text-indent:-9999em;transform:translateZ(0)}@keyframes load8{0%{transform:rotate(0deg)}to{transform:rotate(-1turn)}}body.dragging #jetpack-comic-drop-zone,body.uploading #jetpack-comic-drop-zone{background:rgba(0,86,132,.9);border:1px dashed #fff;bottom:10px;color:#fff;display:block;font-size:30px;left:10px;position:fixed;right:10px;text-align:center;top:10px;z-index:99999} \ No newline at end of file
diff --git a/plugins/jetpack/modules/custom-post-types/comics/comics.min.css b/plugins/jetpack/modules/custom-post-types/comics/comics.min.css
index 08b5f1fc..278477a3 100644
--- a/plugins/jetpack/modules/custom-post-types/comics/comics.min.css
+++ b/plugins/jetpack/modules/custom-post-types/comics/comics.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-#jetpack-comic-drop-zone .dragging,#jetpack-comic-drop-zone .uploading{margin-top:200px;display:none}body.dragging #jetpack-comic-drop-zone .dragging,body.uploading #jetpack-comic-drop-zone .uploading{display:block}body.uploading #jetpack-comic-drop-zone .uploading .spinner,body.uploading #jetpack-comic-drop-zone .uploading .spinner:after{border-radius:50%;width:60px;height:60px}body.uploading #jetpack-comic-drop-zone .uploading .spinner{display:block;margin:15px auto;font-size:10px;position:relative;text-indent:-9999em;border-top:1.1em solid rgba(255,255,255,.2);border-right:1.1em solid rgba(255,255,255,.2);border-bottom:1.1em solid rgba(255,255,255,.2);border-left:1.1em solid #fff;transform:translateZ(0);animation:load8 1.1s infinite linear}@keyframes load8{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}body.dragging #jetpack-comic-drop-zone,body.uploading #jetpack-comic-drop-zone{background:rgba(0,86,132,.9);border:1px dashed #fff;color:#fff;display:block;font-size:30px;position:fixed;top:10px;left:10px;right:10px;bottom:10px;text-align:center;z-index:99999} \ No newline at end of file
+#jetpack-comic-drop-zone .dragging,#jetpack-comic-drop-zone .uploading{display:none;margin-top:200px}body.dragging #jetpack-comic-drop-zone .dragging,body.uploading #jetpack-comic-drop-zone .uploading{display:block}body.uploading #jetpack-comic-drop-zone .uploading .spinner,body.uploading #jetpack-comic-drop-zone .uploading .spinner:after{border-radius:50%;height:60px;width:60px}body.uploading #jetpack-comic-drop-zone .uploading .spinner{animation:load8 1.1s linear infinite;border:1.1em solid hsla(0,0%,100%,.2);border-left-color:#fff;display:block;font-size:10px;margin:15px auto;position:relative;text-indent:-9999em;transform:translateZ(0)}@keyframes load8{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}body.dragging #jetpack-comic-drop-zone,body.uploading #jetpack-comic-drop-zone{background:rgba(0,86,132,.9);border:1px dashed #fff;bottom:10px;color:#fff;display:block;font-size:30px;left:10px;position:fixed;right:10px;text-align:center;top:10px;z-index:99999} \ No newline at end of file
diff --git a/plugins/jetpack/modules/custom-post-types/nova.php b/plugins/jetpack/modules/custom-post-types/nova.php
index e4d7f00b..78d7fa5b 100644
--- a/plugins/jetpack/modules/custom-post-types/nova.php
+++ b/plugins/jetpack/modules/custom-post-types/nova.php
@@ -1,36 +1,39 @@
-<?php
-
-use Automattic\Jetpack\Assets;
-
-/*
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Manage restaurant menus from your WordPress site,
+ * via a new "nova" CPT.
+ *
* Put the following code in your theme's Food Menu Page Template to customize the markup of the menu.
+ *
+ * if ( class_exists( 'Nova_Restaurant' ) ) {
+ * Nova_Restaurant::init( array(
+ * 'menu_tag' => 'section',
+ * 'menu_class' => 'menu-items',
+ * 'menu_header_tag' => 'header',
+ * 'menu_header_class' => 'menu-group-header',
+ * 'menu_title_tag' => 'h1',
+ * 'menu_title_class' => 'menu-group-title',
+ * 'menu_description_tag' => 'div',
+ * 'menu_description_class' => 'menu-group-description',
+ * ) );
+ * }
+ *
+ * @todo
+ * - Bulk/Quick edit response of Menu Item rows is broken.
+ * - Drag and Drop reordering.
+ *
+ * @package automattic/jetpack
+ */
-if ( class_exists( 'Nova_Restaurant' ) ) {
- Nova_Restaurant::init( array(
- 'menu_tag' => 'section',
- 'menu_class' => 'menu-items',
- 'menu_header_tag' => 'header',
- 'menu_header_class' => 'menu-group-header',
- 'menu_title_tag' => 'h1',
- 'menu_title_class' => 'menu-group-title',
- 'menu_description_tag' => 'div',
- 'menu_description_class' => 'menu-group-description',
- ) );
-}
-
-*/
-
-/* @todo
-
-Bulk/Quick edit response of Menu Item rows is broken.
-
-Drag and Drop reordering.
-*/
+use Automattic\Jetpack\Assets;
+/**
+ * Create the new Nova CPT.
+ */
class Nova_Restaurant {
const MENU_ITEM_POST_TYPE = 'nova_menu_item';
const MENU_ITEM_LABEL_TAX = 'nova_menu_item_label';
- const MENU_TAX = 'nova_menu';
+ const MENU_TAX = 'nova_menu';
/**
* Version number used when enqueuing all resources (css and js).
@@ -39,6 +42,11 @@ class Nova_Restaurant {
*/
public $version = '20210303';
+ /**
+ * Default markup for the menu items.
+ *
+ * @var array
+ */
protected $default_menu_item_loop_markup = array(
'menu_tag' => 'section',
'menu_class' => 'menu-items',
@@ -50,14 +58,38 @@ class Nova_Restaurant {
'menu_description_class' => 'menu-group-description',
);
+ /**
+ * Array of markup for the menu items.
+ *
+ * @var array
+ */
protected $menu_item_loop_markup = array();
+
+ /**
+ * Last term ID of a loop of menu items.
+ *
+ * @var bool|int
+ */
protected $menu_item_loop_last_term_id = false;
+
+ /**
+ * Current term ID of a loop of menu items.
+ *
+ * @var bool|int
+ */
protected $menu_item_loop_current_term = false;
- static function init( $menu_item_loop_markup = array() ) {
+ /**
+ * Initialize class.
+ *
+ * @param array $menu_item_loop_markup Array of markup for the menu items.
+ *
+ * @return self
+ */
+ public static function init( $menu_item_loop_markup = array() ) {
static $instance = false;
- if ( !$instance ) {
+ if ( ! $instance ) {
$instance = new Nova_Restaurant();
}
@@ -68,18 +100,23 @@ class Nova_Restaurant {
return $instance;
}
- function __construct() {
- if ( ! $this->site_supports_nova() )
+ /**
+ * Constructor.
+ * Hook into WordPress to create CPT and utilities if needed.
+ */
+ public function __construct() {
+ if ( ! $this->site_supports_nova() ) {
return;
+ }
$this->register_taxonomies();
$this->register_post_types();
- add_action( 'admin_menu', array( $this, 'add_admin_menus' ) );
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_nova_styles' ) );
- add_action( 'admin_head', array( $this, 'set_custom_font_icon' ) );
+ add_action( 'admin_menu', array( $this, 'add_admin_menus' ) );
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_nova_styles' ) );
+ add_action( 'admin_head', array( $this, 'set_custom_font_icon' ) );
// Always sort menu items correctly
- add_action( 'parse_query', array( $this, 'sort_menu_item_queries_by_menu_order' ) );
+ add_action( 'parse_query', array( $this, 'sort_menu_item_queries_by_menu_order' ) );
add_filter( 'posts_results', array( $this, 'sort_menu_item_queries_by_menu_taxonomy' ), 10, 2 );
add_action( 'wp_insert_post', array( $this, 'add_post_meta' ) );
@@ -89,22 +126,26 @@ class Nova_Restaurant {
// Only output our Menu Item Loop Markup on a real blog view. Not feeds, XML-RPC, admin, etc.
add_filter( 'template_include', array( $this, 'setup_menu_item_loop_markup__in_filter' ) );
- add_filter( 'enter_title_here', array( $this, 'change_default_title' ) );
- add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) );
- add_filter( 'dashboard_glance_items', array( $this, 'add_to_dashboard' ) );
+ add_filter( 'enter_title_here', array( $this, 'change_default_title' ) );
+ add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) );
+ add_filter( 'dashboard_glance_items', array( $this, 'add_to_dashboard' ) );
}
/**
- * Should this Custom Post Type be made available?
- */
- function site_supports_nova() {
+ * Should this Custom Post Type be made available?
+ *
+ * @return bool
+ */
+ private function site_supports_nova() {
// If we're on WordPress.com, and it has the menu site vertical.
- if ( function_exists( 'site_vertical' ) && 'nova_menu' == site_vertical() )
+ if ( function_exists( 'site_vertical' ) && 'nova_menu' === site_vertical() ) {
return true;
+ }
// Else, if the current theme requests it.
- if ( current_theme_supports( self::MENU_ITEM_POST_TYPE ) )
+ if ( current_theme_supports( self::MENU_ITEM_POST_TYPE ) ) {
return true;
+ }
// Otherwise, say no unless something wants to filter us to say yes.
/**
@@ -120,201 +161,244 @@ class Nova_Restaurant {
return (bool) apply_filters( 'jetpack_enable_cpt', false, self::MENU_ITEM_POST_TYPE );
}
-/* Setup */
+ /* Setup */
/**
* Register Taxonomies and Post Type
*/
- function register_taxonomies() {
+ private function register_taxonomies() {
if ( ! taxonomy_exists( self::MENU_ITEM_LABEL_TAX ) ) {
- register_taxonomy( self::MENU_ITEM_LABEL_TAX, self::MENU_ITEM_POST_TYPE, array(
- 'labels' => array(
- /* translators: this is about a food menu */
- 'name' => __( 'Menu Item Labels', 'jetpack' ),
- /* translators: this is about a food menu */
- 'singular_name' => __( 'Menu Item Label', 'jetpack' ),
- /* translators: this is about a food menu */
- 'search_items' => __( 'Search Menu Item Labels', 'jetpack' ),
- 'popular_items' => __( 'Popular Labels', 'jetpack' ),
- /* translators: this is about a food menu */
- 'all_items' => __( 'All Menu Item Labels', 'jetpack' ),
- /* translators: this is about a food menu */
- 'edit_item' => __( 'Edit Menu Item Label', 'jetpack' ),
- /* translators: this is about a food menu */
- 'view_item' => __( 'View Menu Item Label', 'jetpack' ),
- /* translators: this is about a food menu */
- 'update_item' => __( 'Update Menu Item Label', 'jetpack' ),
- /* translators: this is about a food menu */
- 'add_new_item' => __( 'Add New Menu Item Label', 'jetpack' ),
- /* translators: this is about a food menu */
- 'new_item_name' => __( 'New Menu Item Label Name', 'jetpack' ),
- 'separate_items_with_commas' => __( 'For example, spicy, favorite, etc. <br /> Separate Labels with commas', 'jetpack' ),
- 'add_or_remove_items' => __( 'Add or remove Labels', 'jetpack' ),
- 'choose_from_most_used' => __( 'Choose from the most used Labels', 'jetpack' ),
- 'items_list_navigation' => __( 'Menu item label list navigation', 'jetpack' ),
- 'items_list' => __( 'Menu item labels list', 'jetpack' ),
- ),
- 'no_tagcloud' => __( 'No Labels found', 'jetpack' ),
- 'hierarchical' => false,
- ) );
+ register_taxonomy(
+ self::MENU_ITEM_LABEL_TAX,
+ self::MENU_ITEM_POST_TYPE,
+ array(
+ 'labels' => array(
+ /* translators: this is about a food menu */
+ 'name' => __( 'Menu Item Labels', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'singular_name' => __( 'Menu Item Label', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'search_items' => __( 'Search Menu Item Labels', 'jetpack' ),
+ 'popular_items' => __( 'Popular Labels', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'all_items' => __( 'All Menu Item Labels', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'edit_item' => __( 'Edit Menu Item Label', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'view_item' => __( 'View Menu Item Label', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'update_item' => __( 'Update Menu Item Label', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'add_new_item' => __( 'Add New Menu Item Label', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'new_item_name' => __( 'New Menu Item Label Name', 'jetpack' ),
+ 'separate_items_with_commas' => __( 'For example, spicy, favorite, etc. <br /> Separate Labels with commas', 'jetpack' ),
+ 'add_or_remove_items' => __( 'Add or remove Labels', 'jetpack' ),
+ 'choose_from_most_used' => __( 'Choose from the most used Labels', 'jetpack' ),
+ 'items_list_navigation' => __( 'Menu item label list navigation', 'jetpack' ),
+ 'items_list' => __( 'Menu item labels list', 'jetpack' ),
+ ),
+ 'no_tagcloud' => __( 'No Labels found', 'jetpack' ),
+ 'hierarchical' => false,
+ )
+ );
}
if ( ! taxonomy_exists( self::MENU_TAX ) ) {
- register_taxonomy( self::MENU_TAX, self::MENU_ITEM_POST_TYPE, array(
- 'labels' => array(
+ register_taxonomy(
+ self::MENU_TAX,
+ self::MENU_ITEM_POST_TYPE,
+ array(
+ 'labels' => array(
+ /* translators: this is about a food menu */
+ 'name' => __( 'Menu Sections', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'singular_name' => __( 'Menu Section', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'search_items' => __( 'Search Menu Sections', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'all_items' => __( 'All Menu Sections', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'parent_item' => __( 'Parent Menu Section', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'parent_item_colon' => __( 'Parent Menu Section:', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'edit_item' => __( 'Edit Menu Section', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'view_item' => __( 'View Menu Section', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'update_item' => __( 'Update Menu Section', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'add_new_item' => __( 'Add New Menu Section', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'new_item_name' => __( 'New Menu Sections Name', 'jetpack' ),
+ 'items_list_navigation' => __( 'Menu section list navigation', 'jetpack' ),
+ 'items_list' => __( 'Menu section list', 'jetpack' ),
+ ),
+ 'rewrite' => array(
+ 'slug' => 'menu',
+ 'with_front' => false,
+ 'hierarchical' => true,
+ ),
+ 'hierarchical' => true,
+ 'show_tagcloud' => false,
+ 'query_var' => 'menu',
+ )
+ );
+ }
+ }
+
+ /**
+ * Register our Post Type.
+ */
+ private function register_post_types() {
+ if ( post_type_exists( self::MENU_ITEM_POST_TYPE ) ) {
+ return;
+ }
+
+ register_post_type(
+ self::MENU_ITEM_POST_TYPE,
+ array(
+ 'description' => __( "Items on your restaurant's menu", 'jetpack' ),
+
+ 'labels' => array(
/* translators: this is about a food menu */
- 'name' => __( 'Menu Sections', 'jetpack' ),
+ 'name' => __( 'Menu Items', 'jetpack' ),
/* translators: this is about a food menu */
- 'singular_name' => __( 'Menu Section', 'jetpack' ),
+ 'singular_name' => __( 'Menu Item', 'jetpack' ),
/* translators: this is about a food menu */
- 'search_items' => __( 'Search Menu Sections', 'jetpack' ),
+ 'menu_name' => __( 'Food Menus', 'jetpack' ),
/* translators: this is about a food menu */
- 'all_items' => __( 'All Menu Sections', 'jetpack' ),
+ 'all_items' => __( 'Menu Items', 'jetpack' ),
/* translators: this is about a food menu */
- 'parent_item' => __( 'Parent Menu Section', 'jetpack' ),
+ 'add_new' => __( 'Add One Item', 'jetpack' ),
/* translators: this is about a food menu */
- 'parent_item_colon' => __( 'Parent Menu Section:', 'jetpack' ),
+ 'add_new_item' => __( 'Add Menu Item', 'jetpack' ),
/* translators: this is about a food menu */
- 'edit_item' => __( 'Edit Menu Section', 'jetpack' ),
+ 'edit_item' => __( 'Edit Menu Item', 'jetpack' ),
/* translators: this is about a food menu */
- 'view_item' => __( 'View Menu Section', 'jetpack' ),
+ 'new_item' => __( 'New Menu Item', 'jetpack' ),
/* translators: this is about a food menu */
- 'update_item' => __( 'Update Menu Section', 'jetpack' ),
+ 'view_item' => __( 'View Menu Item', 'jetpack' ),
/* translators: this is about a food menu */
- 'add_new_item' => __( 'Add New Menu Section', 'jetpack' ),
+ 'search_items' => __( 'Search Menu Items', 'jetpack' ),
/* translators: this is about a food menu */
- 'new_item_name' => __( 'New Menu Sections Name', 'jetpack' ),
- 'items_list_navigation' => __( 'Menu section list navigation', 'jetpack' ),
- 'items_list' => __( 'Menu section list', 'jetpack' ),
+ 'not_found' => __( 'No Menu Items found', 'jetpack' ),
+ /* translators: this is about a food menu */
+ 'not_found_in_trash' => __( 'No Menu Items found in Trash', 'jetpack' ),
+ 'filter_items_list' => __( 'Filter menu items list', 'jetpack' ),
+ 'items_list_navigation' => __( 'Menu item list navigation', 'jetpack' ),
+ 'items_list' => __( 'Menu items list', 'jetpack' ),
),
- 'rewrite' => array(
- 'slug' => 'menu',
- 'with_front' => false,
- 'hierarchical' => true,
+ 'supports' => array(
+ 'title',
+ 'editor',
+ 'thumbnail',
+ 'excerpt',
),
- 'hierarchical' => true,
- 'show_tagcloud' => false,
- 'query_var' => 'menu',
- ) );
- }
- }
-
- function register_post_types() {
- if ( post_type_exists( self::MENU_ITEM_POST_TYPE ) ) {
- return;
- }
-
- register_post_type( self::MENU_ITEM_POST_TYPE, array(
- 'description' => __( "Items on your restaurant's menu", 'jetpack' ),
-
- 'labels' => array(
- /* translators: this is about a food menu */
- 'name' => __( 'Menu Items', 'jetpack' ),
- /* translators: this is about a food menu */
- 'singular_name' => __( 'Menu Item', 'jetpack' ),
- /* translators: this is about a food menu */
- 'menu_name' => __( 'Food Menus', 'jetpack' ),
- /* translators: this is about a food menu */
- 'all_items' => __( 'Menu Items', 'jetpack' ),
- /* translators: this is about a food menu */
- 'add_new' => __( 'Add One Item', 'jetpack' ),
- /* translators: this is about a food menu */
- 'add_new_item' => __( 'Add Menu Item', 'jetpack' ),
- /* translators: this is about a food menu */
- 'edit_item' => __( 'Edit Menu Item', 'jetpack' ),
- /* translators: this is about a food menu */
- 'new_item' => __( 'New Menu Item', 'jetpack' ),
- /* translators: this is about a food menu */
- 'view_item' => __( 'View Menu Item', 'jetpack' ),
- /* translators: this is about a food menu */
- 'search_items' => __( 'Search Menu Items', 'jetpack' ),
- /* translators: this is about a food menu */
- 'not_found' => __( 'No Menu Items found', 'jetpack' ),
- /* translators: this is about a food menu */
- 'not_found_in_trash' => __( 'No Menu Items found in Trash', 'jetpack' ),
- 'filter_items_list' => __( 'Filter menu items list', 'jetpack' ),
- 'items_list_navigation' => __( 'Menu item list navigation', 'jetpack' ),
- 'items_list' => __( 'Menu items list', 'jetpack' ),
- ),
- 'supports' => array(
- 'title',
- 'editor',
- 'thumbnail',
- 'excerpt',
- ),
- 'rewrite' => array(
- 'slug' => 'item',
- 'with_front' => false,
- 'feeds' => false,
- 'pages' => false,
- ),
- 'register_meta_box_cb' => array( $this, 'register_menu_item_meta_boxes' ),
-
- 'public' => true,
- 'show_ui' => true, // set to false to replace with custom UI
- 'menu_position' => 20, // below Pages
- 'capability_type' => 'page',
- 'map_meta_cap' => true,
- 'has_archive' => false,
- 'query_var' => 'item',
- ) );
+ 'rewrite' => array(
+ 'slug' => 'item',
+ 'with_front' => false,
+ 'feeds' => false,
+ 'pages' => false,
+ ),
+ 'register_meta_box_cb' => array( $this, 'register_menu_item_meta_boxes' ),
+
+ 'public' => true,
+ 'show_ui' => true, // set to false to replace with custom UI
+ 'menu_position' => 20, // below Pages
+ 'capability_type' => 'page',
+ 'map_meta_cap' => true,
+ 'has_archive' => false,
+ 'query_var' => 'item',
+ )
+ );
}
-
/**
* Update messages for the Menu Item admin.
+ *
+ * @param array $messages Existing post update messages.
+ *
+ * @return array $messages Updated post update messages.
*/
- function updated_messages( $messages ) {
+ public function updated_messages( $messages ) {
global $post;
- $messages[self::MENU_ITEM_POST_TYPE] = array(
+ $messages[ self::MENU_ITEM_POST_TYPE ] = array(
0 => '', // Unused. Messages start at index 1.
- /* translators: this is about a food menu */
- 1 => sprintf( __( 'Menu item updated. <a href="%s">View item</a>', 'jetpack' ), esc_url( get_permalink( $post->ID ) ) ),
+ 1 => sprintf(
+ /* translators: this is about a food menu. Placeholder is a link to the food menu. */
+ __( 'Menu item updated. <a href="%s">View item</a>', 'jetpack' ),
+ esc_url( get_permalink( $post->ID ) )
+ ),
2 => esc_html__( 'Custom field updated.', 'jetpack' ),
3 => esc_html__( 'Custom field deleted.', 'jetpack' ),
/* translators: this is about a food menu */
4 => esc_html__( 'Menu item updated.', 'jetpack' ),
- /* translators: %s: date and time of the revision */
- 5 => isset( $_GET['revision'] ) ? sprintf( esc_html__( 'Menu item restored to revision from %s', 'jetpack' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
- /* translators: this is about a food menu */
- 6 => sprintf( __( 'Menu item published. <a href="%s">View item</a>', 'jetpack' ), esc_url( get_permalink( $post->ID ) ) ),
+ 5 => isset( $_GET['revision'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling.
+ ? sprintf(
+ /* translators: %s: date and time of the revision */
+ esc_html__( 'Menu item restored to revision from %s', 'jetpack' ),
+ wp_post_revision_title( (int) $_GET['revision'], false ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling.
+ )
+ : false,
+ 6 => sprintf(
+ /* translators: this is about a food menu. Placeholder is a link to the food menu. */
+ __( 'Menu item published. <a href="%s">View item</a>', 'jetpack' ),
+ esc_url( get_permalink( $post->ID ) )
+ ),
/* translators: this is about a food menu */
7 => esc_html__( 'Menu item saved.', 'jetpack' ),
- /* translators: this is about a food menu */
- 8 => sprintf( __( 'Menu item submitted. <a target="_blank" href="%s">Preview item</a>', 'jetpack' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ),
- /* translators: this is about a food menu */
- 9 => sprintf( __( 'Menu item scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview item</a>', 'jetpack' ),
- // translators: Publish box date format, see https://php.net/date
- date_i18n( __( 'M j, Y @ G:i', 'jetpack' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ),
- /* translators: this is about a food menu */
- 10 => sprintf( __( 'Menu item draft updated. <a target="_blank" href="%s">Preview item</a>', 'jetpack' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ),
+ 8 => sprintf(
+ /* translators: this is about a food menu */
+ __( 'Menu item submitted. <a target="_blank" href="%s">Preview item</a>', 'jetpack' ),
+ esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) )
+ ),
+ 9 => sprintf(
+ /* translators: this is about a food menu. 1. Publish box date format, see https://php.net/date 2. link to the food menu. */
+ __( 'Menu item scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview item</a>', 'jetpack' ),
+ /* translators: Publish box date format, see https://php.net/date */
+ date_i18n( __( 'M j, Y @ G:i', 'jetpack' ), strtotime( $post->post_date ) ),
+ esc_url( get_permalink( $post->ID ) )
+ ),
+ 10 => sprintf(
+ /* translators: this is about a food menu. Placeholder is a link to the food menu. */
+ __( 'Menu item draft updated. <a target="_blank" href="%s">Preview item</a>', 'jetpack' ),
+ esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) )
+ ),
);
return $messages;
}
-
/**
- * Nova Styles and Scripts
+ * Nova styles and scripts.
+ *
+ * @param string $hook Page hook.
+ *
+ * @return void
*/
- function enqueue_nova_styles( $hook ) {
+ public function enqueue_nova_styles( $hook ) {
global $post_type;
$pages = array( 'edit.php', 'post.php', 'post-new.php' );
- if ( in_array( $hook, $pages ) && $post_type == self::MENU_ITEM_POST_TYPE ) {
- wp_enqueue_style( 'nova-style', plugins_url( 'css/nova.css', __FILE__ ), array(), $this->version );
+ if ( in_array( $hook, $pages, true ) && $post_type === self::MENU_ITEM_POST_TYPE ) {
+ wp_enqueue_style( 'nova-style', plugins_url( 'css/nova.css', __FILE__ ), array(), $this->version );
}
- wp_enqueue_style( 'nova-font', plugins_url( 'css/nova-font.css', __FILE__ ), array(), $this->version );
+ wp_enqueue_style( 'nova-font', plugins_url( 'css/nova-font.css', __FILE__ ), array(), $this->version );
}
-
/**
* Change ‘Enter Title Here’ text for the Menu Item.
+ *
+ * @param string $title Default title placeholder text.
+ *
+ * @return string
*/
- function change_default_title( $title ) {
- if ( self::MENU_ITEM_POST_TYPE == get_post_type() ) {
+ public function change_default_title( $title ) {
+ if ( self::MENU_ITEM_POST_TYPE === get_post_type() ) {
/* translators: this is about a food menu */
$title = esc_html__( "Enter the menu item's name here", 'jetpack' );
}
@@ -322,11 +406,12 @@ class Nova_Restaurant {
return $title;
}
-
/**
* Add to Dashboard At A Glance
+ *
+ * @return void
*/
- function add_to_dashboard() {
+ public function add_to_dashboard() {
$number_menu_items = wp_count_posts( self::MENU_ITEM_POST_TYPE );
if ( current_user_can( 'administrator' ) ) {
@@ -365,18 +450,21 @@ class Nova_Restaurant {
);
}
- echo '<li class="nova-menu-count">' . $number_menu_items_published . '</li>';
+ echo '<li class="nova-menu-count">' . $number_menu_items_published . '</li>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- we escape things above.
}
-
/**
- * Query
+ * If the WP query for our menu items.
+ *
+ * @param WP_Query $query WP Query.
+ *
+ * @return bool
*/
- function is_menu_item_query( $query ) {
+ private function is_menu_item_query( $query ) {
if (
- ( isset( $query->query_vars['taxonomy'] ) && self::MENU_TAX == $query->query_vars['taxonomy'] )
+ ( isset( $query->query_vars['taxonomy'] ) && self::MENU_TAX === $query->query_vars['taxonomy'] )
||
- ( isset( $query->query_vars['post_type'] ) && self::MENU_ITEM_POST_TYPE == $query->query_vars['post_type'] )
+ ( isset( $query->query_vars['post_type'] ) && self::MENU_ITEM_POST_TYPE === $query->query_vars['post_type'] )
) {
return true;
}
@@ -384,25 +472,40 @@ class Nova_Restaurant {
return false;
}
- function sort_menu_item_queries_by_menu_order( $query ) {
+ /**
+ * Custom sort the menu item queries by menu order.
+ *
+ * @param WP_Query $query WP Query.
+ *
+ * @return void
+ */
+ public function sort_menu_item_queries_by_menu_order( $query ) {
if ( ! $this->is_menu_item_query( $query ) ) {
return;
}
$query->query_vars['orderby'] = 'menu_order';
- $query->query_vars['order'] = 'ASC';
+ $query->query_vars['order'] = 'ASC';
// For now, just turn off paging so we can sort by taxonmy later
// If we want paging in the future, we'll need to add the taxonomy sort here (or at least before the DB query is made)
$query->query_vars['posts_per_page'] = -1;
}
- function sort_menu_item_queries_by_menu_taxonomy( $posts, $query ) {
- if ( !$posts ) {
+ /**
+ * Custom sort the menu item queries by menu taxonomies.
+ *
+ * @param WP_Post[] $posts Array of post objects.
+ * @param WP_Query $query The WP_Query instance.
+ *
+ * @return WP_Post[]
+ */
+ public function sort_menu_item_queries_by_menu_taxonomy( $posts, $query ) {
+ if ( ! $posts ) {
return $posts;
}
- if ( !$this->is_menu_item_query( $query ) ) {
+ if ( ! $this->is_menu_item_query( $query ) ) {
return $posts;
}
@@ -410,26 +513,26 @@ class Nova_Restaurant {
foreach ( $posts as $post ) {
$term = $this->get_menu_item_menu_leaf( $post->ID );
- if ( !$term || is_wp_error( $term ) ) {
+ if ( ! $term || is_wp_error( $term ) ) {
$term_id = 0;
} else {
$term_id = $term->term_id;
}
- if ( !isset( $grouped_by_term["$term_id"] ) ) {
- $grouped_by_term["$term_id"] = array();
+ if ( ! isset( $grouped_by_term[ "$term_id" ] ) ) {
+ $grouped_by_term[ "$term_id" ] = array();
}
- $grouped_by_term["$term_id"][] = $post;
+ $grouped_by_term[ "$term_id" ][] = $post;
}
$term_order = get_option( 'nova_menu_order', array() );
$return = array();
foreach ( $term_order as $term_id ) {
- if ( isset( $grouped_by_term["$term_id"] ) ) {
- $return = array_merge( $return, $grouped_by_term["$term_id"] );
- unset( $grouped_by_term["$term_id"] );
+ if ( isset( $grouped_by_term[ "$term_id" ] ) ) {
+ $return = array_merge( $return, $grouped_by_term[ "$term_id" ] );
+ unset( $grouped_by_term[ "$term_id" ] );
}
}
@@ -440,11 +543,12 @@ class Nova_Restaurant {
return $return;
}
-
/**
- * Add Many Items
+ * Add new "Add many items" submenu, custom colunmns, and custom bulk actions.
+ *
+ * @return void
*/
- function add_admin_menus() {
+ public function add_admin_menus() {
$hook = add_submenu_page(
'edit.php?post_type=' . self::MENU_ITEM_POST_TYPE,
__( 'Add Many Items', 'jetpack' ),
@@ -454,17 +558,21 @@ class Nova_Restaurant {
array( $this, 'add_many_new_items_page' )
);
- add_action( "load-$hook", array( $this, 'add_many_new_items_page_load' ) );
+ add_action( "load-$hook", array( $this, 'add_many_new_items_page_load' ) );
add_action( 'current_screen', array( $this, 'current_screen_load' ) );
- //Adjust 'Add Many Items' submenu position
- if ( isset( $GLOBALS['submenu']['edit.php?post_type=' . self::MENU_ITEM_POST_TYPE] ) ) {
- $submenu_item = array_pop( $GLOBALS['submenu']['edit.php?post_type=' . self::MENU_ITEM_POST_TYPE] );
- $GLOBALS['submenu']['edit.php?post_type=' . self::MENU_ITEM_POST_TYPE][11] = $submenu_item;
- ksort( $GLOBALS['submenu']['edit.php?post_type=' . self::MENU_ITEM_POST_TYPE] );
+ /*
+ * Adjust 'Add Many Items' submenu position
+ * We're making changes to the menu global, but no other choice unfortunately.
+ * phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited
+ */
+ if ( isset( $GLOBALS['submenu'][ 'edit.php?post_type=' . self::MENU_ITEM_POST_TYPE ] ) ) {
+ $submenu_item = array_pop( $GLOBALS['submenu'][ 'edit.php?post_type=' . self::MENU_ITEM_POST_TYPE ] );
+ $GLOBALS['submenu'][ 'edit.php?post_type=' . self::MENU_ITEM_POST_TYPE ][11] = $submenu_item;
+ ksort( $GLOBALS['submenu'][ 'edit.php?post_type=' . self::MENU_ITEM_POST_TYPE ] );
}
-
+ // phpcs:enable WordPress.WP.GlobalVariablesOverride.Prohibited
$this->setup_menu_item_columns();
@@ -480,22 +588,28 @@ class Nova_Restaurant {
);
}
-
/**
* Custom Nova Icon CSS
+ *
+ * @return void
*/
- function set_custom_font_icon() {
- ?>
+ public function set_custom_font_icon() {
+ ?>
<style type="text/css">
#menu-posts-nova_menu_item .wp-menu-image:before {
font-family: 'nova-font' !important;
content: '\e603' !important;
}
</style>
- <?php
+ <?php
}
- function current_screen_load() {
+ /**
+ * Load Nova menu management tools on the CPT admin screen.
+ *
+ * @return void
+ */
+ public function current_screen_load() {
$screen = get_current_screen();
if ( 'edit-nova_menu_item' !== $screen->id ) {
return;
@@ -505,90 +619,143 @@ class Nova_Restaurant {
add_filter( 'admin_notices', array( $this, 'admin_notices' ) );
}
-/* Edit Items List */
+ /* Edit Items List */
- function admin_notices() {
- if ( isset( $_GET['nova_reordered'] ) )
- /* translators: this is about a food menu */
- printf( '<div class="updated"><p>%s</p></div>', __( 'Menu Items re-ordered.', 'jetpack' ) );
+ /**
+ * Display a notice in wp-admin after items have been changed.
+ *
+ * @return void
+ */
+ public function admin_notices() {
+ if ( isset( $_GET['nova_reordered'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- this is only displaying a message with no dynamic values.
+ printf(
+ '<div class="updated"><p>%s</p></div>',
+ /* translators: this is about a food menu */
+ esc_html__( 'Menu Items re-ordered.', 'jetpack' )
+ );
+ }
}
- function no_title_sorting( $columns ) {
- if ( isset( $columns['title'] ) )
+ /**
+ * Do not allow sorting by title.
+ *
+ * @param array $columns An array of sortable columns.
+ *
+ * @return array $columns.
+ */
+ public function no_title_sorting( $columns ) {
+ if ( isset( $columns['title'] ) ) {
unset( $columns['title'] );
+ }
return $columns;
}
- function setup_menu_item_columns() {
+ /**
+ * Set up custom columns for our Nova menu.
+ *
+ * @return void
+ */
+ private function setup_menu_item_columns() {
add_filter( sprintf( 'manage_edit-%s_sortable_columns', self::MENU_ITEM_POST_TYPE ), array( $this, 'no_title_sorting' ) );
add_filter( sprintf( 'manage_%s_posts_columns', self::MENU_ITEM_POST_TYPE ), array( $this, 'menu_item_columns' ) );
add_action( sprintf( 'manage_%s_posts_custom_column', self::MENU_ITEM_POST_TYPE ), array( $this, 'menu_item_column_callback' ), 10, 2 );
}
- function menu_item_columns( $columns ) {
+ /**
+ * Add custom columns to the Nova menu item list.
+ *
+ * @param array $columns An array of columns.
+ *
+ * @return array $columns.
+ */
+ public function menu_item_columns( $columns ) {
unset( $columns['date'], $columns['likes'] );
$columns['thumbnail'] = __( 'Thumbnail', 'jetpack' );
- $columns['labels'] = __( 'Labels', 'jetpack' );
- $columns['price'] = __( 'Price', 'jetpack' );
- $columns['order'] = __( 'Order', 'jetpack' );
+ $columns['labels'] = __( 'Labels', 'jetpack' );
+ $columns['price'] = __( 'Price', 'jetpack' );
+ $columns['order'] = __( 'Order', 'jetpack' );
return $columns;
}
- function menu_item_column_callback( $column, $post_id ) {
+ /**
+ * Display custom data in each new custom column we created.
+ *
+ * @param string $column The name of the column to display.
+ * @param int $post_id The current post ID.
+ *
+ * @return void
+ */
+ public function menu_item_column_callback( $column, $post_id ) {
$screen = get_current_screen();
switch ( $column ) {
case 'thumbnail':
echo get_the_post_thumbnail( $post_id, array( 50, 50 ) );
break;
- case 'labels' :
+ case 'labels':
$this->list_admin_labels( $post_id );
break;
- case 'price' :
+ case 'price':
$this->display_price( $post_id );
break;
- case 'order' :
+ case 'order':
$url = admin_url( $screen->parent_file );
- $up_url = add_query_arg( array(
- 'action' => 'move-item-up',
- 'post_id' => (int) $post_id,
- ), wp_nonce_url( $url, 'nova_move_item_up_' . $post_id ) );
+ $up_url = add_query_arg(
+ array(
+ 'action' => 'move-item-up',
+ 'post_id' => (int) $post_id,
+ ),
+ wp_nonce_url( $url, 'nova_move_item_up_' . $post_id )
+ );
- $down_url = add_query_arg( array(
- 'action' => 'move-item-down',
- 'post_id' => (int) $post_id,
- ), wp_nonce_url( $url, 'nova_move_item_down_' . $post_id ) );
- $menu_item = get_post($post_id);
+ $down_url = add_query_arg(
+ array(
+ 'action' => 'move-item-down',
+ 'post_id' => (int) $post_id,
+ ),
+ wp_nonce_url( $url, 'nova_move_item_down_' . $post_id )
+ );
+ $menu_item = get_post( $post_id );
$this->get_menu_by_post_id( $post_id );
- if ( $term_id = $this->get_menu_by_post_id( $post_id ) ) {
+ $term_id = $this->get_menu_by_post_id( $post_id );
+ if ( $term_id ) {
$term_id = $term_id->term_id;
}
- ?>
- <input type="hidden" class="menu-order-value" name="nova_order[<?php echo (int) $post_id ?>]" value="<?php echo esc_attr( $menu_item->menu_order ) ?>" />
- <input type="hidden" class='nova-menu-term' name="nova_menu_term[<?php echo (int) $post_id ?>]" value="<?php echo esc_attr( $term_id ); ?>">
+ ?>
+ <input type="hidden" class="menu-order-value" name="nova_order[<?php echo (int) $post_id; ?>]" value="<?php echo esc_attr( $menu_item->menu_order ); ?>" />
+ <input type="hidden" class='nova-menu-term' name="nova_menu_term[<?php echo (int) $post_id; ?>]" value="<?php echo esc_attr( $term_id ); ?>">
<span class="hide-if-js">
&nbsp; &nbsp; &mdash; <a class="nova-move-item-up" data-post-id="<?php echo (int) $post_id; ?>" href="<?php echo esc_url( $up_url ); ?>">up</a>
<br />
&nbsp; &nbsp; &mdash; <a class="nova-move-item-down" data-post-id="<?php echo (int) $post_id; ?>" href="<?php echo esc_url( $down_url ); ?>">down</a>
</span>
- <?php
+ <?php
break;
}
}
- function get_menu_by_post_id( $post_id = null ) {
- if ( ! $post_id )
+ /**
+ * Get menu item by post ID.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return bool|WP_Term
+ */
+ private function get_menu_by_post_id( $post_id = null ) {
+ if ( ! $post_id ) {
return false;
+ }
$terms = get_the_terms( $post_id, self::MENU_TAX );
- if ( ! is_array( $terms ) )
+ if ( ! is_array( $terms ) ) {
return false;
+ }
return array_pop( $terms );
}
@@ -596,50 +763,78 @@ class Nova_Restaurant {
/**
* Fires on a menu edit page. We might have drag-n-drop reordered
*/
- function maybe_reorder_menu_items() {
- // make sure we clicked our button
- if ( ! ( isset( $_REQUEST['menu_reorder_submit'] ) && $_REQUEST['menu_reorder_submit'] === __( 'Save New Order', 'jetpack' ) ) )
+ private function maybe_reorder_menu_items() {
+ // make sure we clicked our button.
+ if (
+ empty( $_REQUEST['menu_reorder_submit'] )
+ || __( 'Save New Order', 'jetpack' ) !== $_REQUEST['menu_reorder_submit']
+ ) {
return;
- ;
+ }
- // make sure we have the nonce
- if ( ! ( isset( $_REQUEST['drag-drop-reorder'] ) && wp_verify_nonce( $_REQUEST['drag-drop-reorder'], 'drag-drop-reorder' ) ) )
+ // make sure we have the nonce.
+ if (
+ empty( $_REQUEST['drag-drop-reorder'] )
+ || ! wp_verify_nonce( sanitize_key( $_REQUEST['drag-drop-reorder'] ), 'drag-drop-reorder' )
+ ) {
return;
+ }
- $term_pairs = array_map( 'absint', $_REQUEST['nova_menu_term'] );
+ // make sure we have data to work with.
+ if ( empty( $_REQUEST['nova_menu_term'] ) || empty( $_REQUEST['nova_order'] ) ) {
+ return;
+ }
+
+ $term_pairs = array_map( 'absint', $_REQUEST['nova_menu_term'] );
$order_pairs = array_map( 'absint', $_REQUEST['nova_order'] );
- foreach( $order_pairs as $ID => $menu_order ) {
- $ID = absint( $ID );
- unset( $order_pairs[$ID] );
- if ( $ID < 0 )
+ foreach ( $order_pairs as $id => $menu_order ) {
+ $id = absint( $id );
+ unset( $order_pairs[ $id ] );
+ if ( $id < 0 ) {
continue;
+ }
- $post = get_post( $ID );
- if ( ! $post )
+ $post = get_post( $id );
+ if ( ! $post ) {
continue;
+ }
// save a write if the order hasn't changed
- if ( $menu_order != $post->menu_order )
- wp_update_post( compact( 'ID', 'menu_order' ) );
+ if ( (int) $menu_order !== $post->menu_order ) {
+ $args = array(
+ 'ID' => $id,
+ 'menu_order' => $menu_order,
+ );
+ wp_update_post( $args );
+ }
// save a write if the term hasn't changed
- if ( $term_pairs[$ID] != $this->get_menu_by_post_id( $ID )->term_id )
- wp_set_object_terms( $ID, $term_pairs[$ID], self::MENU_TAX );
-
+ if ( (int) $term_pairs[ $id ] !== $this->get_menu_by_post_id( $id )->term_id ) {
+ wp_set_object_terms( $id, $term_pairs[ $id ], self::MENU_TAX );
+ }
}
- $redirect = add_query_arg( array(
- 'post_type' => self::MENU_ITEM_POST_TYPE,
- 'nova_reordered' => '1'
- ), admin_url( 'edit.php' ) );
+ $redirect = add_query_arg(
+ array(
+ 'post_type' => self::MENU_ITEM_POST_TYPE,
+ 'nova_reordered' => '1',
+ ),
+ admin_url( 'edit.php' )
+ );
wp_safe_redirect( $redirect );
exit;
}
- function edit_menu_items_page_load() {
- if ( isset( $_GET['action'] ) ) {
+ /**
+ * Handle changes to menu items.
+ * (process actions, update data, enqueue necessary scripts).
+ *
+ * @return void
+ */
+ private function edit_menu_items_page_load() {
+ if ( isset( $_GET['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- we process the form and check nonces in handle_menu_item_actions.
$this->handle_menu_item_actions();
}
@@ -656,161 +851,191 @@ class Nova_Restaurant {
true
);
- wp_localize_script( 'nova-drag-drop', '_novaDragDrop', array(
- 'nonce' => wp_create_nonce( 'drag-drop-reorder' ),
- 'nonceName' => 'drag-drop-reorder',
- 'reorder' => __( 'Save New Order', 'jetpack' ),
- 'reorderName' => 'menu_reorder_submit'
- ) );
+ wp_localize_script(
+ 'nova-drag-drop',
+ '_novaDragDrop',
+ array(
+ 'nonce' => wp_create_nonce( 'drag-drop-reorder' ),
+ 'nonceName' => 'drag-drop-reorder',
+ 'reorder' => __( 'Save New Order', 'jetpack' ),
+ 'reorderName' => 'menu_reorder_submit',
+ )
+ );
add_action( 'the_post', array( $this, 'show_menu_titles_in_menu_item_list' ) );
}
- function handle_menu_item_actions() {
- $action = (string) $_GET['action'];
+ /**
+ * Process actions to move menu items around.
+ *
+ * @return void
+ */
+ private function handle_menu_item_actions() {
+ if ( isset( $_GET['action'] ) ) {
+ $action = (string) wp_unslash( $_GET['action'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- we check for nonces below, and check against specific strings in switch statement.
+ } else {
+ return;
+ }
switch ( $action ) {
- case 'move-item-up' :
- case 'move-item-down' :
- $reorder = false;
-
- $post_id = (int) $_GET['post_id'];
+ case 'move-item-up':
+ case 'move-item-down':
+ $reorder = false;
- $term = $this->get_menu_item_menu_leaf( $post_id );
+ if ( empty( $_GET['post_id'] ) ) {
+ break;
+ }
- // Get all posts in that term
- $query = new WP_Query( array(
- 'taxonomy' => self::MENU_TAX,
- 'term' => $term->slug,
- ) );
+ $post_id = (int) $_GET['post_id'];
- $order = array();
- foreach ( $query->posts as $post ) {
- $order[] = $post->ID;
- }
+ $term = $this->get_menu_item_menu_leaf( $post_id );
- if ( 'move-item-up' == $action ) {
- check_admin_referer( 'nova_move_item_up_' . $post_id );
+ // Get all posts in that term.
+ $query = new WP_Query(
+ array(
+ 'taxonomy' => self::MENU_TAX,
+ 'term' => $term->slug,
+ )
+ );
- $first_post_id = $order[0];
- if ( $post_id == $first_post_id ) {
- break;
+ $order = array();
+ foreach ( $query->posts as $post ) {
+ $order[] = $post->ID;
}
- foreach ( $order as $menu_order => $order_post_id ) {
- if ( $post_id != $order_post_id ) {
- continue;
+ if ( 'move-item-up' === $action ) {
+ check_admin_referer( 'nova_move_item_up_' . $post_id );
+
+ $first_post_id = $order[0];
+ if ( $post_id === $first_post_id ) {
+ break;
}
- $swap_post_id = $order[$menu_order - 1];
- $order[$menu_order - 1] = $post_id;
- $order[$menu_order] = $swap_post_id;
+ foreach ( $order as $menu_order => $order_post_id ) {
+ if ( $post_id !== $order_post_id ) {
+ continue;
+ }
- $reorder = true;
- break;
- }
- } else {
- check_admin_referer( 'nova_move_item_down_' . $post_id );
+ $swap_post_id = $order[ $menu_order - 1 ];
+ $order[ $menu_order - 1 ] = $post_id;
+ $order[ $menu_order ] = $swap_post_id;
- $last_post_id = end( $order );
- if ( $post_id == $last_post_id ) {
- break;
- }
+ $reorder = true;
+ break;
+ }
+ } else {
+ check_admin_referer( 'nova_move_item_down_' . $post_id );
- foreach ( $order as $menu_order => $order_post_id ) {
- if ( $post_id != $order_post_id ) {
- continue;
+ $last_post_id = end( $order );
+ if ( $post_id === $last_post_id ) {
+ break;
}
- $swap_post_id = $order[$menu_order + 1];
- $order[$menu_order + 1] = $post_id;
- $order[$menu_order] = $swap_post_id;
+ foreach ( $order as $menu_order => $order_post_id ) {
+ if ( $post_id !== $order_post_id ) {
+ continue;
+ }
- $reorder = true;
- }
- }
+ $swap_post_id = $order[ $menu_order + 1 ];
+ $order[ $menu_order + 1 ] = $post_id;
+ $order[ $menu_order ] = $swap_post_id;
- if ( $reorder ) {
- foreach ( $order as $menu_order => $ID ) {
- wp_update_post( compact( 'ID', 'menu_order' ) );
+ $reorder = true;
+ }
}
- }
- break;
- case 'move-menu-up' :
- case 'move-menu-down' :
- $reorder = false;
+ if ( $reorder ) {
+ foreach ( $order as $menu_order => $id ) {
+ wp_update_post( compact( 'id', 'menu_order' ) );
+ }
+ }
- $term_id = (int) $_GET['term_id'];
+ break;
+ case 'move-menu-up':
+ case 'move-menu-down':
+ $reorder = false;
- $terms = $this->get_menus();
+ if ( empty( $_GET['term_id'] ) ) {
+ break;
+ }
- $order = array();
- foreach ( $terms as $term ) {
- $order[] = $term->term_id;
- }
+ $term_id = (int) $_GET['term_id'];
- if ( 'move-menu-up' == $action ) {
- check_admin_referer( 'nova_move_menu_up_' . $term_id );
+ $terms = $this->get_menus();
- $first_term_id = $order[0];
- if ( $term_id == $first_term_id ) {
- break;
+ $order = array();
+ foreach ( $terms as $term ) {
+ $order[] = $term->term_id;
}
- foreach ( $order as $menu_order => $order_term_id ) {
- if ( $term_id != $order_term_id ) {
- continue;
+ if ( 'move-menu-up' === $action ) {
+ check_admin_referer( 'nova_move_menu_up_' . $term_id );
+
+ $first_term_id = $order[0];
+ if ( $term_id === $first_term_id ) {
+ break;
}
- $swap_term_id = $order[$menu_order - 1];
- $order[$menu_order - 1] = $term_id;
- $order[$menu_order] = $swap_term_id;
+ foreach ( $order as $menu_order => $order_term_id ) {
+ if ( $term_id !== $order_term_id ) {
+ continue;
+ }
- $reorder = true;
- break;
- }
- } else {
- check_admin_referer( 'nova_move_menu_down_' . $term_id );
+ $swap_term_id = $order[ $menu_order - 1 ];
+ $order[ $menu_order - 1 ] = $term_id;
+ $order[ $menu_order ] = $swap_term_id;
- $last_term_id = end( $order );
- if ( $term_id == $last_term_id ) {
- break;
- }
+ $reorder = true;
+ break;
+ }
+ } else {
+ check_admin_referer( 'nova_move_menu_down_' . $term_id );
- foreach ( $order as $menu_order => $order_term_id ) {
- if ( $term_id != $order_term_id ) {
- continue;
+ $last_term_id = end( $order );
+ if ( $term_id === $last_term_id ) {
+ break;
}
- $swap_term_id = $order[$menu_order + 1];
- $order[$menu_order + 1] = $term_id;
- $order[$menu_order] = $swap_term_id;
+ foreach ( $order as $menu_order => $order_term_id ) {
+ if ( $term_id !== $order_term_id ) {
+ continue;
+ }
- $reorder = true;
+ $swap_term_id = $order[ $menu_order + 1 ];
+ $order[ $menu_order + 1 ] = $term_id;
+ $order[ $menu_order ] = $swap_term_id;
+
+ $reorder = true;
+ }
}
- }
- if ( $reorder ) {
- update_option( 'nova_menu_order', $order );
- }
+ if ( $reorder ) {
+ update_option( 'nova_menu_order', $order );
+ }
- break;
- default :
- return;
+ break;
+ default:
+ return;
}
- $redirect = add_query_arg( array(
- 'post_type' => self::MENU_ITEM_POST_TYPE,
- 'nova_reordered' => '1'
- ), admin_url( 'edit.php' ) );
+ $redirect = add_query_arg(
+ array(
+ 'post_type' => self::MENU_ITEM_POST_TYPE,
+ 'nova_reordered' => '1',
+ ),
+ admin_url( 'edit.php' )
+ );
wp_safe_redirect( $redirect );
exit;
}
- /*
+ /**
* Add menu title rows to the list table
+ *
+ * @param WP_Post $post The Post object.
+ *
+ * @return void
*/
- function show_menu_titles_in_menu_item_list( $post ) {
+ public function show_menu_titles_in_menu_item_list( $post ) {
global $wp_list_table;
static $last_term_id = false;
@@ -823,13 +1048,13 @@ class Nova_Restaurant {
return;
}
- if ( is_null( $term_id ) ) {
+ if ( $term_id === null ) {
$last_term_id = null;
- $term_name = '';
+ $term_name = '';
$parent_count = 0;
} else {
$last_term_id = $term->term_id;
- $term_name = $term->name;
+ $term_name = $term->name;
$parent_count = 0;
$current_term = $term;
while ( $current_term->parent ) {
@@ -844,46 +1069,63 @@ class Nova_Restaurant {
$url = admin_url( $screen->parent_file );
- $up_url = add_query_arg( array(
- 'action' => 'move-menu-up',
- 'term_id' => (int) $term_id,
- ), wp_nonce_url( $url, 'nova_move_menu_up_' . $term_id ) );
+ $up_url = add_query_arg(
+ array(
+ 'action' => 'move-menu-up',
+ 'term_id' => (int) $term_id,
+ ),
+ wp_nonce_url( $url, 'nova_move_menu_up_' . $term_id )
+ );
- $down_url = add_query_arg( array(
- 'action' => 'move-menu-down',
- 'term_id' => (int) $term_id,
- ), wp_nonce_url( $url, 'nova_move_menu_down_' . $term_id ) );
+ $down_url = add_query_arg(
+ array(
+ 'action' => 'move-menu-down',
+ 'term_id' => (int) $term_id,
+ ),
+ wp_nonce_url( $url, 'nova_move_menu_down_' . $term_id )
+ );
-?>
- <tr class="no-items menu-label-row" data-term_id="<?php echo esc_attr( $term_id ) ?>">
+ ?>
+ <tr class="no-items menu-label-row" data-term_id="<?php echo esc_attr( $term_id ); ?>">
<td class="colspanchange" colspan="<?php echo (int) $non_order_column_count; ?>">
- <h3><?php
- echo str_repeat( ' &mdash; ', (int) $parent_count );
+ <h3>
+ <?php
+ echo str_repeat( ' &mdash; ', (int) $parent_count ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- nothing to escape here.
- if ( $term instanceof WP_Term ) {
- echo esc_html( sanitize_term_field( 'name', $term_name, $term_id, self::MENU_TAX, 'display' ) );
- edit_term_link( __( 'edit', 'jetpack' ), '<span class="edit-nova-section"><span class="dashicon dashicon-edit"></span>', '</span>', $term );
+ if ( $term instanceof WP_Term ) {
+ echo esc_html( sanitize_term_field( 'name', $term_name, $term_id, self::MENU_TAX, 'display' ) );
+ edit_term_link( __( 'edit', 'jetpack' ), '<span class="edit-nova-section"><span class="dashicon dashicon-edit"></span>', '</span>', $term );
- } else {
- _e( 'Uncategorized' , 'jetpack' );
- }
- ?></h3>
+ } else {
+ esc_html_e( 'Uncategorized', 'jetpack' );
+ }
+ ?>
+ </h3>
</td>
<td>
<?php if ( $term instanceof WP_Term ) { ?>
- <a class="nova-move-menu-up" title="<?php esc_attr_e( 'Move menu section up', 'jetpack' ); ?>" href="<?php echo esc_url( $up_url ); ?>"><?php esc_html_e( 'UP', 'jetpack' ); ?></a>
+ <a class="nova-move-menu-up" title="<?php esc_attr_e( 'Move menu section up', 'jetpack' ); ?>" href="<?php echo esc_url( $up_url ); ?>"><?php echo esc_html_x( 'UP', 'indicates movement (up or down)', 'jetpack' ); ?></a>
<br />
- <a class="nova-move-menu-down" title="<?php esc_attr_e( 'Move menu section down', 'jetpack' ); ?>" href="<?php echo esc_url( $down_url ); ?>"><?php esc_html_e( 'DOWN', 'jetpack' ); ?></a>
+ <a class="nova-move-menu-down" title="<?php esc_attr_e( 'Move menu section down', 'jetpack' ); ?>" href="<?php echo esc_url( $down_url ); ?>"><?php echo esc_html_x( 'DOWN', 'indicates movement (up or down)', 'jetpack' ); ?></a>
<?php } ?>
</td>
</tr>
-<?php
+ <?php
}
-/* Edit Many Items */
+ /* Edit Many Items */
- function add_many_new_items_page_load() {
- if ( 'POST' === strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
+ /**
+ * Handle form submissions that aim to add many menu items at once.
+ * (process posted data and enqueue necessary script).
+ *
+ * @return void
+ */
+ public function add_many_new_items_page_load() {
+ if (
+ isset( $_SERVER['REQUEST_METHOD'] )
+ && 'POST' === strtoupper( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) )
+ ) {
$this->process_form_request();
exit;
}
@@ -891,7 +1133,12 @@ class Nova_Restaurant {
$this->enqueue_many_items_scripts();
}
- function enqueue_many_items_scripts() {
+ /**
+ * Enqueue script to create many items at once.
+ *
+ * @return void
+ */
+ public function enqueue_many_items_scripts() {
wp_enqueue_script(
'nova-many-items',
Assets::get_file_url_for_environment(
@@ -904,12 +1151,17 @@ class Nova_Restaurant {
);
}
- function process_form_request() {
- if ( !isset( $_POST['nova_title'] ) || !is_array( $_POST['nova_title'] ) ) {
+ /**
+ * Process form request to create many items at once.
+ *
+ * @return void
+ */
+ private function process_form_request() {
+ if ( ! isset( $_POST['nova_title'] ) || ! is_array( $_POST['nova_title'] ) ) {
return;
}
- $is_ajax = !empty( $_POST['ajax'] );
+ $is_ajax = ! empty( $_POST['ajax'] );
if ( $is_ajax ) {
check_ajax_referer( 'nova_many_items' );
@@ -917,37 +1169,54 @@ class Nova_Restaurant {
check_admin_referer( 'nova_many_items' );
}
- foreach ( array_keys( $_POST['nova_title'] ) as $key ) :
- // $_POST is already slashed
+ /*
+ * $_POST is already slashed
+ * phpcs:disable WordPress.Security.ValidatedSanitizedInput.MissingUnslash
+ */
+ foreach ( array_keys( $_POST['nova_title'] ) as $key ) : // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- we sanitize below.
$post_details = array(
'post_status' => 'publish',
'post_type' => self::MENU_ITEM_POST_TYPE,
- 'post_content' => $_POST['nova_content'][$key],
- 'post_title' => $_POST['nova_title'][$key],
+ 'post_content' => ! empty( $_POST['nova_content'] ) && ! empty( $_POST['nova_content'][ $key ] )
+ ? sanitize_text_field( $_POST['nova_content'][ $key ] )
+ : '',
+ 'post_title' => isset( $_POST['nova_title'][ $key ] )
+ ? sanitize_title( $_POST['nova_title'][ $key ] )
+ : '',
'tax_input' => array(
- self::MENU_ITEM_LABEL_TAX => $_POST['nova_labels'][$key],
- self::MENU_TAX => isset( $_POST['nova_menu_tax'] ) ? $_POST['nova_menu_tax'] : null,
+ self::MENU_ITEM_LABEL_TAX => isset( $_POST['nova_labels'][ $key ] )
+ ? sanitize_meta( self::MENU_ITEM_LABEL_TAX, $_POST['nova_labels'][ $key ], 'term' )
+ : null,
+ self::MENU_TAX => isset( $_POST['nova_menu_tax'] )
+ ? sanitize_meta( self::MENU_TAX, $_POST['nova_menu_tax'], 'term' )
+ : null,
),
);
$post_id = wp_insert_post( $post_details );
- if ( !$post_id || is_wp_error( $post_id ) ) {
+ if ( ! $post_id || is_wp_error( $post_id ) ) {
continue;
}
- $this->set_price( $post_id, isset( $_POST['nova_price'][$key] ) ? stripslashes( $_POST['nova_price'][$key] ) : '' );
+ $this->set_price(
+ $post_id,
+ isset( $_POST['nova_price'][ $key ] )
+ ? sanitize_meta( 'nova_price', $_POST['nova_price'][ $key ], 'post' )
+ : ''
+ );
+ // phpcs:enable WordPress.Security.ValidatedSanitizedInput.MissingUnslash
if ( $is_ajax ) :
- $post = get_post( $post_id );
- $GLOBALS['post'] = $post;
+ $post = get_post( $post_id );
+ $GLOBALS['post'] = $post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
setup_postdata( $post );
-?>
+ ?>
<td><?php the_title(); ?></td>
<td class="nova-price"><?php $this->display_price(); ?></td>
<td><?php $this->list_labels( $post_id ); ?></td>
<td><?php the_content(); ?></td>
-<?php
+ <?php
endif;
endforeach;
@@ -960,28 +1229,59 @@ class Nova_Restaurant {
exit;
}
- function add_many_new_items_page() {
-?>
+ /**
+ * Admin page contents for adding many menu items at once.
+ *
+ * @return void
+ */
+ public function add_many_new_items_page() {
+ ?>
<div class="wrap">
<h2><?php esc_html_e( 'Add Many Items', 'jetpack' ); ?></h2>
- <p><?php _e( 'Use the <kbd>TAB</kbd> key on your keyboard to move between colums and the <kbd>ENTER</kbd> or <kbd>RETURN</kbd> key to save each row and move on to the next.', 'jetpack' ); ?></p>
+ <p>
+ <?php
+ echo wp_kses(
+ __( 'Use the <kbd>TAB</kbd> key on your keyboard to move between colums and the <kbd>ENTER</kbd> or <kbd>RETURN</kbd> key to save each row and move on to the next.', 'jetpack' ),
+ array(
+ 'kbd' => array(),
+ )
+ );
+ ?>
+ </p>
<form method="post" action="" enctype="multipart/form-data">
- <p><h3><?php esc_html_e( 'Add to section:', 'jetpack' ); ?> <?php wp_dropdown_categories( array(
- 'id' => 'nova-menu-tax',
- 'name' => 'nova_menu_tax',
- 'taxonomy' => self::MENU_TAX,
- 'hide_empty' => false,
- 'hierarchical' => true,
- ) ); ?></h3></p>
+ <p>
+ <h3><?php esc_html_e( 'Add to section:', 'jetpack' ); ?>
+ <?php
+ wp_dropdown_categories(
+ array(
+ 'id' => 'nova-menu-tax',
+ 'name' => 'nova_menu_tax',
+ 'taxonomy' => self::MENU_TAX,
+ 'hide_empty' => false,
+ 'hierarchical' => true,
+ )
+ );
+ ?>
+ </h3></p>
<table class="many-items-table wp-list-table widefat">
<thead>
<tr>
<th scope="col"><?php esc_html_e( 'Name', 'jetpack' ); ?></th>
<th scope="col" class="nova-price"><?php esc_html_e( 'Price', 'jetpack' ); ?></th>
- <th scope="col"><?php _e( 'Labels: <small>spicy, favorite, etc. <em>Separate Labels with commas</em></small>', 'jetpack' ); ?></th>
+ <th scope="col">
+ <?php
+ echo wp_kses(
+ __( 'Labels: <small>spicy, favorite, etc. <em>Separate Labels with commas</em></small>', 'jetpack' ),
+ array(
+ 'small' => array(),
+ 'em' => array(),
+ )
+ );
+ ?>
+ </th>
<th scope="col"><?php esc_html_e( 'Description', 'jetpack' ); ?></th>
</tr>
</thead>
@@ -1003,7 +1303,7 @@ class Nova_Restaurant {
</tbody>
<tfoot>
<tr>
- <th><a class="button button-secondary nova-new-row"><span class="dashicon dashicon-plus"></span> <?php esc_html_e( 'New Row' , 'jetpack' ); ?></a></th>
+ <th><a class="button button-secondary nova-new-row"><span class="dashicon dashicon-plus"></span> <?php esc_html_e( 'New Row', 'jetpack' ); ?></a></th>
<th class="nova-price"></th>
<th></th>
<th></th>
@@ -1017,57 +1317,96 @@ class Nova_Restaurant {
</p>
</form>
</div>
-<?php
+ <?php
}
-/* Edit One Item */
+ /* Edit One Item */
- function register_menu_item_meta_boxes() {
+ /**
+ * Create admin meta box to save price for a menu item,
+ * and add script to add extra checkboxes to the UI.
+ *
+ * @return void
+ */
+ public function register_menu_item_meta_boxes() {
wp_enqueue_script( 'nova-menu-checkboxes' );
- add_meta_box( 'menu_item_price', __( 'Price', 'jetpack' ), array( $this, 'menu_item_price_meta_box' ), null, 'side', 'high' );
+ add_meta_box(
+ 'menu_item_price',
+ __( 'Price', 'jetpack' ),
+ array( $this, 'menu_item_price_meta_box' ),
+ null,
+ 'side',
+ 'high'
+ );
}
- function menu_item_price_meta_box( $post, $meta_box ) {
- $price = $this->get_price( $post->ID );
-?>
- <label for="nova-price-<?php echo (int) $post->ID; ?>" class="screen-reader-text"><?php esc_html_e( 'Price', 'jetpack' ); ?></label>
- <input type="text" id="nova-price-<?php echo (int) $post->ID; ?>" class="widefat" name="nova_price[<?php echo (int) $post->ID; ?>]" value="<?php echo esc_attr( $price ); ?>" />
-<?php
+ /**
+ * Meta box to edit the price of a menu item.
+ *
+ * @param WP_Post $post The post object.
+ *
+ * @return void
+ */
+ public function menu_item_price_meta_box( $post ) {
+ printf(
+ '<label for="nova-price-%1$s" class="screen-reader-text">%2$s</label><input type="text" id="nova-price-%1$s" class="widefat" name="nova_price[%1$s]" value="%3$s" />',
+ (int) $post->ID,
+ esc_html__( 'Price', 'jetpack' ),
+ esc_attr( $this->get_price( (int) $post->ID ) )
+ );
}
- function add_post_meta( $post_id ) {
- if ( !isset( $_POST['nova_price'][$post_id] ) ) {
+ /**
+ * Save the price of a menu item.
+ *
+ * @param int $post_id Post ID.
+ */
+ public function add_post_meta( $post_id ) {
+ if ( ! isset( $_POST['nova_price'][ $post_id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce handling happens via core, since we hook into wp_insert_post.
return;
}
- $this->set_price( $post_id, stripslashes( $_POST['nova_price'][$post_id] ) );
+ $this->set_price(
+ $post_id,
+ sanitize_meta( 'nova_price', wp_unslash( $_POST['nova_price'][ $post_id ] ), 'post' ) // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce handling happens via core, since we hook into wp_insert_post.
+ );
}
-/* Data */
+ /* Data */
- function get_menus( $args = array() ) {
- $args = wp_parse_args( $args, array(
- 'hide_empty' => false,
- ) );
+ /**
+ * Get ordered array of menu items.
+ *
+ * @param array $args Optional argumments.
+ *
+ * @return array
+ */
+ private function get_menus( $args = array() ) {
+ $args = wp_parse_args(
+ $args,
+ array(
+ 'hide_empty' => false,
+ )
+ );
$terms = get_terms( self::MENU_TAX, $args );
- if ( !$terms || is_wp_error( $terms ) ) {
+ if ( ! $terms || is_wp_error( $terms ) ) {
return array();
}
$terms_by_id = array();
foreach ( $terms as $term ) {
- $terms_by_id["{$term->term_id}"] = $term;
+ $terms_by_id[ "{$term->term_id}" ] = $term;
}
$term_order = get_option( 'nova_menu_order', array() );
$return = array();
foreach ( $term_order as $term_id ) {
- if ( isset( $terms_by_id["$term_id"] ) ) {
- $return[] = $terms_by_id["$term_id"];
- unset( $terms_by_id["$term_id"] );
+ if ( isset( $terms_by_id[ "$term_id" ] ) ) {
+ $return[] = $terms_by_id[ "$term_id" ];
+ unset( $terms_by_id[ "$term_id" ] );
}
}
@@ -1078,8 +1417,15 @@ class Nova_Restaurant {
return $return;
}
- function get_menu_item_menu_leaf( $post_id ) {
- // Get first menu taxonomy "leaf"
+ /**
+ * Get first menu taxonomy "leaf".
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return bool|WP_Term|WP_Error|null
+ */
+ private function get_menu_item_menu_leaf( $post_id ) {
+ // Get first menu taxonomy "leaf".
$term_ids = wp_get_object_terms( $post_id, self::MENU_TAX, array( 'fields' => 'ids' ) );
foreach ( $term_ids as $term_id ) {
@@ -1097,54 +1443,100 @@ class Nova_Restaurant {
}
- function list_labels( $post_id = 0 ) {
+ /**
+ * Get a list of the labels linked to a menu item.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return void
+ */
+ private function list_labels( $post_id = 0 ) {
$post = get_post( $post_id );
echo get_the_term_list( $post->ID, self::MENU_ITEM_LABEL_TAX, '', _x( ', ', 'Nova label separator', 'jetpack' ), '' );
}
- function list_admin_labels( $post_id = 0 ) {
- $post = get_post( $post_id );
+ /**
+ * Get a list of the labels linked to a menu item, with links to manage them.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return void
+ */
+ private function list_admin_labels( $post_id = 0 ) {
+ $post = get_post( $post_id );
$labels = get_the_terms( $post->ID, self::MENU_ITEM_LABEL_TAX );
- if ( !empty( $labels ) ) {
+ if ( ! empty( $labels ) ) {
$out = array();
foreach ( $labels as $label ) {
- $out[] = sprintf( '<a href="%s">%s</a>',
- esc_url( add_query_arg( array(
- 'post_type' => self::MENU_ITEM_POST_TYPE,
- 'taxonomy' => self::MENU_ITEM_LABEL_TAX,
- 'term' => $label->slug
- ), 'edit.php' ) ),
- esc_html( sanitize_term_field( 'name', $label->name, $label->term_id, self::MENU_ITEM_LABEL_TAX, 'display' ) )
+ $out[] = sprintf(
+ '<a href="%s">%s</a>',
+ esc_url(
+ add_query_arg(
+ array(
+ 'post_type' => self::MENU_ITEM_POST_TYPE,
+ 'taxonomy' => self::MENU_ITEM_LABEL_TAX,
+ 'term' => $label->slug,
+ ),
+ 'edit.php'
+ )
+ ),
+ esc_html(
+ sanitize_term_field( 'name', $label->name, $label->term_id, self::MENU_ITEM_LABEL_TAX, 'display' )
+ )
);
}
- echo join( _x( ', ', 'Nova label separator', 'jetpack' ), $out );
+ echo join( _x( ', ', 'Nova label separator', 'jetpack' ), $out ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- we build $out ourselves and escape things there.
} else {
esc_html_e( 'No Labels', 'jetpack' );
}
}
- function set_price( $post_id = 0, $price = '' ) {
- $post = get_post( $post_id );
-
- return update_post_meta( $post->ID, 'nova_price', $price );
+ /**
+ * Update post meta with the price defined in meta box.
+ *
+ * @param int $post_id Post ID.
+ * @param string $price Price.
+ *
+ * @return int|bool
+ */
+ private function set_price( $post_id = 0, $price = '' ) {
+ return update_post_meta( $post_id, 'nova_price', $price );
}
- function get_price( $post_id = 0 ) {
- $post = get_post( $post_id );
-
- return get_post_meta( $post->ID, 'nova_price', true );
+ /**
+ * Get the price of a menu item.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return bool|string
+ */
+ private function get_price( $post_id = 0 ) {
+ return get_post_meta( $post_id, 'nova_price', true );
}
- function display_price( $post_id = 0 ) {
+ /**
+ * Echo the price of a menu item.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return void
+ */
+ private function display_price( $post_id = 0 ) {
echo esc_html( $this->get_price( $post_id ) );
}
-/* Menu Item Loop Markup */
-
- /* Does not support nested loops */
+ /* Menu Item Loop Markup */
- function get_menu_item_loop_markup( $field = null ) {
+ /**
+ * Get markup for a menu item.
+ * Note: Does not support nested loops.
+ *
+ * @param null|string $field The field to get the value for.
+ *
+ * @return array
+ */
+ private function get_menu_item_loop_markup( $field = null ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
return $this->menu_item_loop_markup;
}
@@ -1153,10 +1545,11 @@ class Nova_Restaurant {
* Attached to the 'template_include' *filter*,
* which fires only during a real blog view (not in admin, feeds, etc.)
*
- * @param string Template File
+ * @param string $template Template File.
+ *
* @return string Template File. VERY Important.
*/
- function setup_menu_item_loop_markup__in_filter( $template ) {
+ public function setup_menu_item_loop_markup__in_filter( $template ) {
add_action( 'loop_start', array( $this, 'start_menu_item_loop' ) );
return $template;
@@ -1166,10 +1559,12 @@ class Nova_Restaurant {
* If the Query is a Menu Item Query, start outputing the Menu Item Loop Marku
* Attached to the 'loop_start' action.
*
- * @param WP_Query
+ * @param WP_Query $query Post query.
+ *
+ * @return void
*/
- function start_menu_item_loop( $query ) {
- if ( !$this->is_menu_item_query( $query ) ) {
+ public function start_menu_item_loop( $query ) {
+ if ( ! $this->is_menu_item_query( $query ) ) {
return;
}
@@ -1184,9 +1579,11 @@ class Nova_Restaurant {
* Outputs the Menu Item Loop Marku
* Attached to the 'the_post' action.
*
- * @param WP_Post
+ * @param WP_Post $post Post object.
+ *
+ * @return void
*/
- function menu_item_loop_each_post( $post ) {
+ public function menu_item_loop_each_post( $post ) {
$this->menu_item_loop_current_term = $this->get_menu_item_menu_leaf( $post->ID );
if ( false === $this->menu_item_loop_last_term_id ) {
@@ -1194,7 +1591,7 @@ class Nova_Restaurant {
$this->menu_item_loop_open_element( 'menu' ); // Start a new menu section
$this->menu_item_loop_header(); // Output the menu's header
- } elseif ( $this->menu_item_loop_last_term_id != $this->menu_item_loop_current_term->term_id ) {
+ } elseif ( $this->menu_item_loop_last_term_id !== $this->menu_item_loop_current_term->term_id ) {
// We're not at the very beginning but still need to start a new menu section. End the previous menu section first.
$this->menu_item_loop_close_element( 'menu' ); // End the previous menu section
@@ -1209,10 +1606,12 @@ class Nova_Restaurant {
* If the Query is a Menu Item Query, stop outputing the Menu Item Loop Marku
* Attached to the 'loop_end' action.
*
- * @param WP_Query
+ * @param WP_Query $query Post query.
+ *
+ * @return void
*/
- function stop_menu_item_loop( $query ) {
- if ( !$this->is_menu_item_query( $query ) ) {
+ public function stop_menu_item_loop( $query ) {
+ if ( ! $this->is_menu_item_query( $query ) ) {
return;
}
@@ -1225,8 +1624,10 @@ class Nova_Restaurant {
/**
* Outputs the Menu Group Header
+ *
+ * @return void
*/
- function menu_item_loop_header() {
+ private function menu_item_loop_header() {
$this->menu_item_loop_open_element( 'menu_header' );
$this->menu_item_loop_open_element( 'menu_title' );
echo esc_html( $this->menu_item_loop_current_term->name ); // @todo tax filter
@@ -1243,8 +1644,10 @@ class Nova_Restaurant {
* Outputs a Menu Item Markup element opening tag
*
* @param string $field - Menu Item Markup settings field.
+ *
+ * @return void
*/
- function menu_item_loop_open_element( $field ) {
+ private function menu_item_loop_open_element( $field ) {
$markup = $this->get_menu_item_loop_markup();
/**
* Filter a menu item's element opening tag.
@@ -1258,9 +1661,9 @@ class Nova_Restaurant {
* @param array $markup Array of markup elements for the menu item.
* @param false|object $term Taxonomy term for current menu item.
*/
- echo apply_filters(
+ echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- it's escaped in menu_item_loop_class.
'jetpack_nova_menu_item_loop_open_element',
- '<' . tag_escape( $markup["{$field}_tag"] ) . $this->menu_item_loop_class( $markup["{$field}_class"] ) . ">\n",
+ '<' . tag_escape( $markup[ "{$field}_tag" ] ) . $this->menu_item_loop_class( $markup[ "{$field}_class" ] ) . ">\n",
$field,
$markup,
$this->menu_item_loop_current_term
@@ -1270,9 +1673,11 @@ class Nova_Restaurant {
/**
* Outputs a Menu Item Markup element closing tag
*
- * @param string $field - Menu Item Markup settings field
+ * @param string $field - Menu Item Markup settings field.
+ *
+ * @return void
*/
- function menu_item_loop_close_element( $field ) {
+ private function menu_item_loop_close_element( $field ) {
$markup = $this->get_menu_item_loop_markup();
/**
* Filter a menu item's element closing tag.
@@ -1286,9 +1691,9 @@ class Nova_Restaurant {
* @param array $markup Array of markup elements for the menu item.
* @param false|object $term Taxonomy term for current menu item.
*/
- echo apply_filters(
+ echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- tag_escape is used.
'jetpack_nova_menu_item_loop_close_element',
- '</' . tag_escape( $markup["{$field}_tag"] ) . ">\n",
+ '</' . tag_escape( $markup[ "{$field}_tag" ] ) . ">\n",
$field,
$markup,
$this->menu_item_loop_current_term
@@ -1299,9 +1704,10 @@ class Nova_Restaurant {
* Returns a Menu Item Markup element's class attribute.
*
* @param string $class Class name.
- * @return string HTML class attribute with leading whitespace.
+ *
+ * @return string HTML class attribute with leading whitespace.
*/
- function menu_item_loop_class( $class ) {
+ private function menu_item_loop_class( $class ) {
if ( ! $class ) {
return '';
}
diff --git a/plugins/jetpack/modules/custom-post-types/portfolios.php b/plugins/jetpack/modules/custom-post-types/portfolios.php
index 2fda4bd7..2fc0432c 100644
--- a/plugins/jetpack/modules/custom-post-types/portfolios.php
+++ b/plugins/jetpack/modules/custom-post-types/portfolios.php
@@ -1,5 +1,13 @@
-<?php
-
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Register a portfolio post type and handle displaying it anywhere on the site.
+ *
+ * @package automattic/jetpack
+ */
+
+/**
+ * Jetpack Portfolio.
+ */
class Jetpack_Portfolio {
const CUSTOM_POST_TYPE = 'jetpack-portfolio';
const CUSTOM_TAXONOMY_TYPE = 'jetpack-portfolio-type';
@@ -7,13 +15,14 @@ class Jetpack_Portfolio {
const OPTION_NAME = 'jetpack_portfolio';
const OPTION_READING_SETTING = 'jetpack_portfolio_posts_per_page';
- public $version = '0.1';
-
- static function init() {
+ /**
+ * Initialize class.
+ */
+ public static function init() {
static $instance = false;
if ( ! $instance ) {
- $instance = new Jetpack_Portfolio;
+ $instance = new Jetpack_Portfolio();
}
return $instance;
@@ -25,72 +34,87 @@ class Jetpack_Portfolio {
* Setup user option for enabling CPT
* If user has CPT enabled, show in admin
*/
- function __construct() {
- // Add an option to enable the CPT
- add_action( 'admin_init', array( $this, 'settings_api_init' ) );
+ public function __construct() {
+ // Add an option to enable the CPT.
+ add_action( 'admin_init', array( $this, 'settings_api_init' ) );
- // Check on theme switch if theme supports CPT and setting is disabled
- add_action( 'after_switch_theme', array( $this, 'activation_post_type_support' ) );
+ // Check on theme switch if theme supports CPT and setting is disabled.
+ add_action( 'after_switch_theme', array( $this, 'activation_post_type_support' ) );
- // Make sure the post types are loaded for imports
- add_action( 'import_start', array( $this, 'register_post_types' ) );
+ // Make sure the post types are loaded for imports.
+ add_action( 'import_start', array( $this, 'register_post_types' ) );
// Add to REST API post type allowed list.
- add_filter( 'rest_api_allowed_post_types', array( $this, 'allow_portfolio_rest_api_type' ) );
+ add_filter( 'rest_api_allowed_post_types', array( $this, 'allow_portfolio_rest_api_type' ) );
- $setting = Jetpack_Options::get_option_and_ensure_autoload( self::OPTION_NAME, '0' );
+ // If called via REST API, we need to register later in lifecycle.
+ add_action( 'restapi_theme_init', array( $this, 'maybe_register_cpt' ) );
+
+ $this->maybe_register_cpt();
+ }
+
+ /**
+ * Registers the custom post types and adds action/filter handlers, but
+ * only if the site supports it
+ */
+ public function maybe_register_cpt() {
+ if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
+ $setting = get_option( self::OPTION_NAME, '0' );
+ } else {
+ $setting = Jetpack_Options::get_option_and_ensure_autoload( self::OPTION_NAME, '0' );
+ }
- // Bail early if Portfolio option is not set and the theme doesn't declare support
+ // Bail early if Portfolio option is not set and the theme doesn't declare support.
if ( empty( $setting ) && ! $this->site_supports_custom_post_type() ) {
return;
}
- // CPT magic
+ // CPT magic.
$this->register_post_types();
- add_action( sprintf( 'add_option_%s', self::OPTION_NAME ), array( $this, 'flush_rules_on_enable' ), 10 );
- add_action( sprintf( 'update_option_%s', self::OPTION_NAME ), array( $this, 'flush_rules_on_enable' ), 10 );
- add_action( sprintf( 'publish_%s', self::CUSTOM_POST_TYPE), array( $this, 'flush_rules_on_first_project' ) );
- add_action( 'after_switch_theme', array( $this, 'flush_rules_on_switch' ) );
+ add_action( sprintf( 'add_option_%s', self::OPTION_NAME ), array( $this, 'flush_rules_on_enable' ), 10 );
+ add_action( sprintf( 'update_option_%s', self::OPTION_NAME ), array( $this, 'flush_rules_on_enable' ), 10 );
+ add_action( sprintf( 'publish_%s', self::CUSTOM_POST_TYPE ), array( $this, 'flush_rules_on_first_project' ) );
+ add_action( 'after_switch_theme', array( $this, 'flush_rules_on_switch' ) );
- // Admin Customization
- add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) );
- add_filter( sprintf( 'manage_%s_posts_columns', self::CUSTOM_POST_TYPE), array( $this, 'edit_admin_columns' ) );
- add_filter( sprintf( 'manage_%s_posts_custom_column', self::CUSTOM_POST_TYPE), array( $this, 'image_column' ), 10, 2 );
- add_action( 'customize_register', array( $this, 'customize_register' ) );
+ // Admin Customization.
+ add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) );
+ add_filter( sprintf( 'manage_%s_posts_columns', self::CUSTOM_POST_TYPE ), array( $this, 'edit_admin_columns' ) );
+ add_filter( sprintf( 'manage_%s_posts_custom_column', self::CUSTOM_POST_TYPE ), array( $this, 'image_column' ), 10, 2 );
+ add_action( 'customize_register', array( $this, 'customize_register' ) );
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
- // Track all the things
- add_action( sprintf( 'add_option_%s', self::OPTION_NAME ), array( $this, 'new_activation_stat_bump' ) );
- add_action( sprintf( 'update_option_%s', self::OPTION_NAME ), array( $this, 'update_option_stat_bump' ), 11, 2 );
- add_action( sprintf( 'publish_%s', self::CUSTOM_POST_TYPE), array( $this, 'new_project_stat_bump' ) );
+ // Track all the things.
+ add_action( sprintf( 'add_option_%s', self::OPTION_NAME ), array( $this, 'new_activation_stat_bump' ) );
+ add_action( sprintf( 'update_option_%s', self::OPTION_NAME ), array( $this, 'update_option_stat_bump' ), 11, 2 );
+ add_action( sprintf( 'publish_%s', self::CUSTOM_POST_TYPE ), array( $this, 'new_project_stat_bump' ) );
}
add_image_size( 'jetpack-portfolio-admin-thumb', 50, 50, true );
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
- // register jetpack_portfolio shortcode and portfolio shortcode (legacy)
- add_shortcode( 'portfolio', array( $this, 'portfolio_shortcode' ) );
- add_shortcode( 'jetpack_portfolio', array( $this, 'portfolio_shortcode' ) );
+ // register jetpack_portfolio shortcode and portfolio shortcode (legacy).
+ add_shortcode( 'portfolio', array( $this, 'portfolio_shortcode' ) );
+ add_shortcode( 'jetpack_portfolio', array( $this, 'portfolio_shortcode' ) );
- // Adjust CPT archive and custom taxonomies to obey CPT reading setting
- add_filter( 'infinite_scroll_settings', array( $this, 'infinite_scroll_click_posts_per_page' ) );
- add_filter( 'infinite_scroll_results', array( $this, 'infinite_scroll_results' ), 10, 3 );
+ // Adjust CPT archive and custom taxonomies to obey CPT reading setting.
+ add_filter( 'infinite_scroll_settings', array( $this, 'infinite_scroll_click_posts_per_page' ) );
+ add_filter( 'infinite_scroll_results', array( $this, 'infinite_scroll_results' ), 10, 3 );
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
- // Add to Dotcom XML sitemaps
- add_filter( 'wpcom_sitemap_post_types', array( $this, 'add_to_sitemap' ) );
+ // Add to Dotcom XML sitemaps.
+ add_filter( 'wpcom_sitemap_post_types', array( $this, 'add_to_sitemap' ) );
} else {
- // Add to Jetpack XML sitemap
- add_filter( 'jetpack_sitemap_post_types', array( $this, 'add_to_sitemap' ) );
+ // Add to Jetpack XML sitemap.
+ add_filter( 'jetpack_sitemap_post_types', array( $this, 'add_to_sitemap' ) );
}
- // Adjust CPT archive and custom taxonomies to obey CPT reading setting
- add_filter( 'pre_get_posts', array( $this, 'query_reading_setting' ) );
+ // Adjust CPT archive and custom taxonomies to obey CPT reading setting.
+ add_filter( 'pre_get_posts', array( $this, 'query_reading_setting' ) );
- // If CPT was enabled programatically and no CPT items exist when user switches away, disable
+ // If CPT was enabled programatically and no CPT items exist when user switches away, disable.
if ( $setting && $this->site_supports_custom_post_type() ) {
- add_action( 'switch_theme', array( $this, 'deactivation_post_type_support' ) );
+ add_action( 'switch_theme', array( $this, 'deactivation_post_type_support' ) );
}
}
@@ -98,9 +122,9 @@ class Jetpack_Portfolio {
* Add a checkbox field in 'Settings' > 'Writing'
* for enabling CPT functionality.
*
- * @return null
+ * @return void
*/
- function settings_api_init() {
+ public function settings_api_init() {
add_settings_field(
self::OPTION_NAME,
'<span class="cpt-options">' . __( 'Portfolio Projects', 'jetpack' ) . '</span>',
@@ -114,7 +138,7 @@ class Jetpack_Portfolio {
'intval'
);
- // Check if CPT is enabled first so that intval doesn't get set to NULL on re-registering
+ // Check if CPT is enabled first so that intval doesn't get set to NULL on re-registering.
if ( get_option( self::OPTION_NAME, '0' ) || current_theme_supports( self::CUSTOM_POST_TYPE ) ) {
register_setting(
'writing',
@@ -128,24 +152,41 @@ class Jetpack_Portfolio {
* HTML code to display a checkbox true/false option
* for the Portfolio CPT setting.
*
- * @return html
+ * @return void
*/
- function setting_html() {
+ public function setting_html() {
if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) : ?>
- <p><?php printf( /* translators: %s is the name of a custom post type such as "jetpack-portfolio" */ __( 'Your theme supports <strong>%s</strong>', 'jetpack' ), self::CUSTOM_POST_TYPE ); ?></p>
+ <p>
+ <?php
+ echo wp_kses(
+ sprintf(
+ /* translators: %s is the name of a custom post type such as "jetpack-portfolio" */
+ __( 'Your theme supports <strong>%s</strong>', 'jetpack' ),
+ esc_attr( self::CUSTOM_POST_TYPE )
+ ),
+ array(
+ 'strong' => array(),
+ )
+ );
+ ?>
+ </p>
<?php else : ?>
<label for="<?php echo esc_attr( self::OPTION_NAME ); ?>">
<input name="<?php echo esc_attr( self::OPTION_NAME ); ?>" id="<?php echo esc_attr( self::OPTION_NAME ); ?>" <?php echo checked( get_option( self::OPTION_NAME, '0' ), true, false ); ?> type="checkbox" value="1" />
<?php esc_html_e( 'Enable Portfolio Projects for this site.', 'jetpack' ); ?>
<a target="_blank" href="https://en.support.wordpress.com/portfolios/"><?php esc_html_e( 'Learn More', 'jetpack' ); ?></a>
</label>
- <?php endif;
+ <?php
+ endif;
if ( get_option( self::OPTION_NAME, '0' ) || current_theme_supports( self::CUSTOM_POST_TYPE ) ) :
- printf( '<p><label for="%1$s">%2$s</label></p>',
+ printf(
+ '<p><label for="%1$s">%2$s</label></p>',
esc_attr( self::OPTION_READING_SETTING ),
- /* translators: %1$s is replaced with an input field for numbers */
- sprintf( __( 'Portfolio pages display at most %1$s projects', 'jetpack' ),
- sprintf( '<input name="%1$s" id="%1$s" type="number" step="1" min="1" value="%2$s" class="small-text" />',
+ sprintf(
+ /* translators: %1$s is replaced with an input field for numbers */
+ __( 'Portfolio pages display at most %1$s projects', 'jetpack' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- the placeholder contains HTML.
+ sprintf(
+ '<input name="%1$s" id="%1$s" type="number" step="1" min="1" value="%2$s" class="small-text" />',
esc_attr( self::OPTION_READING_SETTING ),
esc_attr( get_option( self::OPTION_READING_SETTING, '10' ) )
)
@@ -154,17 +195,20 @@ class Jetpack_Portfolio {
endif;
}
- /*
- * Bump Portfolio > New Activation stat
+ /**
+ * Bump Portfolio > New Activation stat.
*/
- function new_activation_stat_bump() {
+ public function new_activation_stat_bump() {
bump_stats_extras( 'portfolios', 'new-activation' );
}
- /*
- * Bump Portfolio > Option On/Off stats to get total active
+ /**
+ * Bump Portfolio > Option On/Off stats to get total active.
+ *
+ * @param mixed $old The old option value.
+ * @param mixed $new The new option value.
*/
- function update_option_stat_bump( $old, $new ) {
+ public function update_option_stat_bump( $old, $new ) {
if ( empty( $old ) && ! empty( $new ) ) {
bump_stats_extras( 'portfolios', 'option-on' );
}
@@ -174,17 +218,17 @@ class Jetpack_Portfolio {
}
}
- /*
- * Bump Portfolio > Published Projects stat when projects are published
+ /**
+ * Bump Portfolio > Published Projects stat when projects are published.
*/
- function new_project_stat_bump() {
+ public function new_project_stat_bump() {
bump_stats_extras( 'portfolios', 'published-projects' );
}
/**
- * Should this Custom Post Type be made available?
- */
- function site_supports_custom_post_type() {
+ * Should this Custom Post Type be made available?
+ */
+ private function site_supports_custom_post_type() {
// If the current theme requests it.
if ( current_theme_supports( self::CUSTOM_POST_TYPE ) || get_option( self::OPTION_NAME, '0' ) ) {
return true;
@@ -195,17 +239,17 @@ class Jetpack_Portfolio {
return (bool) apply_filters( 'jetpack_enable_cpt', false, self::CUSTOM_POST_TYPE );
}
- /*
+ /**
* Flush permalinks when CPT option is turned on/off
*/
- function flush_rules_on_enable() {
+ public function flush_rules_on_enable() {
flush_rewrite_rules();
}
- /*
+ /**
* Count published projects and flush permalinks when first projects is published
*/
- function flush_rules_on_first_project() {
+ public function flush_rules_on_first_project() {
$projects = get_transient( 'jetpack-portfolio-count-cache' );
if ( false === $projects ) {
@@ -218,10 +262,10 @@ class Jetpack_Portfolio {
}
}
- /*
+ /**
* Flush permalinks when CPT supported theme is activated
*/
- function flush_rules_on_switch() {
+ public function flush_rules_on_switch() {
if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) {
flush_rewrite_rules();
}
@@ -230,7 +274,7 @@ class Jetpack_Portfolio {
/**
* On plugin/theme activation, check if current theme supports CPT
*/
- static function activation_post_type_support() {
+ public static function activation_post_type_support() {
if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) {
update_option( self::OPTION_NAME, '1' );
}
@@ -239,13 +283,15 @@ class Jetpack_Portfolio {
/**
* On theme switch, check if CPT item exists and disable if not
*/
- function deactivation_post_type_support() {
- $portfolios = get_posts( array(
- 'fields' => 'ids',
- 'posts_per_page' => 1,
- 'post_type' => self::CUSTOM_POST_TYPE,
- 'suppress_filters' => false
- ) );
+ public function deactivation_post_type_support() {
+ $portfolios = get_posts(
+ array(
+ 'fields' => 'ids',
+ 'posts_per_page' => 1,
+ 'post_type' => self::CUSTOM_POST_TYPE,
+ 'suppress_filters' => false,
+ )
+ );
if ( empty( $portfolios ) ) {
update_option( self::OPTION_NAME, '0' );
@@ -255,139 +301,180 @@ class Jetpack_Portfolio {
/**
* Register Post Type
*/
- function register_post_types() {
+ public function register_post_types() {
if ( post_type_exists( self::CUSTOM_POST_TYPE ) ) {
return;
}
- register_post_type( self::CUSTOM_POST_TYPE, array(
- 'labels' => array(
- 'name' => esc_html__( 'Projects', 'jetpack' ),
- 'singular_name' => esc_html__( 'Project', 'jetpack' ),
- 'menu_name' => esc_html__( 'Portfolio', 'jetpack' ),
- 'all_items' => esc_html__( 'All Projects', 'jetpack' ),
- 'add_new' => esc_html__( 'Add New', 'jetpack' ),
- 'add_new_item' => esc_html__( 'Add New Project', 'jetpack' ),
- 'edit_item' => esc_html__( 'Edit Project', 'jetpack' ),
- 'new_item' => esc_html__( 'New Project', 'jetpack' ),
- 'view_item' => esc_html__( 'View Project', 'jetpack' ),
- 'search_items' => esc_html__( 'Search Projects', 'jetpack' ),
- 'not_found' => esc_html__( 'No Projects found', 'jetpack' ),
- 'not_found_in_trash' => esc_html__( 'No Projects found in Trash', 'jetpack' ),
- 'filter_items_list' => esc_html__( 'Filter projects list', 'jetpack' ),
- 'items_list_navigation' => esc_html__( 'Project list navigation', 'jetpack' ),
- 'items_list' => esc_html__( 'Projects list', 'jetpack' ),
- ),
- 'supports' => array(
- 'title',
- 'editor',
- 'thumbnail',
- 'author',
- 'comments',
- 'publicize',
- 'wpcom-markdown',
- 'revisions',
- 'excerpt',
- 'custom-fields',
- 'newspack_blocks',
- ),
- 'rewrite' => array(
- 'slug' => 'portfolio',
- 'with_front' => false,
- 'feeds' => true,
- 'pages' => true,
- ),
- 'public' => true,
- 'show_ui' => true,
- 'menu_position' => 20, // below Pages
- 'menu_icon' => 'dashicons-portfolio', // 3.8+ dashicon option
- 'capability_type' => 'page',
- 'map_meta_cap' => true,
- 'taxonomies' => array( self::CUSTOM_TAXONOMY_TYPE, self::CUSTOM_TAXONOMY_TAG ),
- 'has_archive' => true,
- 'query_var' => 'portfolio',
- 'show_in_rest' => true,
- ) );
-
- register_taxonomy( self::CUSTOM_TAXONOMY_TYPE, self::CUSTOM_POST_TYPE, array(
- 'hierarchical' => true,
- 'labels' => array(
- 'name' => esc_html__( 'Project Types', 'jetpack' ),
- 'singular_name' => esc_html__( 'Project Type', 'jetpack' ),
- 'menu_name' => esc_html__( 'Project Types', 'jetpack' ),
- 'all_items' => esc_html__( 'All Project Types', 'jetpack' ),
- 'edit_item' => esc_html__( 'Edit Project Type', 'jetpack' ),
- 'view_item' => esc_html__( 'View Project Type', 'jetpack' ),
- 'update_item' => esc_html__( 'Update Project Type', 'jetpack' ),
- 'add_new_item' => esc_html__( 'Add New Project Type', 'jetpack' ),
- 'new_item_name' => esc_html__( 'New Project Type Name', 'jetpack' ),
- 'parent_item' => esc_html__( 'Parent Project Type', 'jetpack' ),
- 'parent_item_colon' => esc_html__( 'Parent Project Type:', 'jetpack' ),
- 'search_items' => esc_html__( 'Search Project Types', 'jetpack' ),
- 'items_list_navigation' => esc_html__( 'Project type list navigation', 'jetpack' ),
- 'items_list' => esc_html__( 'Project type list', 'jetpack' ),
- ),
- 'public' => true,
- 'show_ui' => true,
- 'show_in_nav_menus' => true,
- 'show_in_rest' => true,
- 'show_admin_column' => true,
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'project-type' ),
- ) );
-
- register_taxonomy( self::CUSTOM_TAXONOMY_TAG, self::CUSTOM_POST_TYPE, array(
- 'hierarchical' => false,
- 'labels' => array(
- 'name' => esc_html__( 'Project Tags', 'jetpack' ),
- 'singular_name' => esc_html__( 'Project Tag', 'jetpack' ),
- 'menu_name' => esc_html__( 'Project Tags', 'jetpack' ),
- 'all_items' => esc_html__( 'All Project Tags', 'jetpack' ),
- 'edit_item' => esc_html__( 'Edit Project Tag', 'jetpack' ),
- 'view_item' => esc_html__( 'View Project Tag', 'jetpack' ),
- 'update_item' => esc_html__( 'Update Project Tag', 'jetpack' ),
- 'add_new_item' => esc_html__( 'Add New Project Tag', 'jetpack' ),
- 'new_item_name' => esc_html__( 'New Project Tag Name', 'jetpack' ),
- 'search_items' => esc_html__( 'Search Project Tags', 'jetpack' ),
- 'popular_items' => esc_html__( 'Popular Project Tags', 'jetpack' ),
- 'separate_items_with_commas' => esc_html__( 'Separate tags with commas', 'jetpack' ),
- 'add_or_remove_items' => esc_html__( 'Add or remove tags', 'jetpack' ),
- 'choose_from_most_used' => esc_html__( 'Choose from the most used tags', 'jetpack' ),
- 'not_found' => esc_html__( 'No tags found.', 'jetpack' ),
- 'items_list_navigation' => esc_html__( 'Project tag list navigation', 'jetpack' ),
- 'items_list' => esc_html__( 'Project tag list', 'jetpack' ),
- ),
- 'public' => true,
- 'show_ui' => true,
- 'show_in_nav_menus' => true,
- 'show_in_rest' => true,
- 'show_admin_column' => true,
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'project-tag' ),
- ) );
+ register_post_type(
+ self::CUSTOM_POST_TYPE,
+ array(
+ 'labels' => array(
+ 'name' => esc_html__( 'Projects', 'jetpack' ),
+ 'singular_name' => esc_html__( 'Project', 'jetpack' ),
+ 'menu_name' => esc_html__( 'Portfolio', 'jetpack' ),
+ 'all_items' => esc_html__( 'All Projects', 'jetpack' ),
+ 'add_new' => esc_html__( 'Add New', 'jetpack' ),
+ 'add_new_item' => esc_html__( 'Add New Project', 'jetpack' ),
+ 'edit_item' => esc_html__( 'Edit Project', 'jetpack' ),
+ 'new_item' => esc_html__( 'New Project', 'jetpack' ),
+ 'view_item' => esc_html__( 'View Project', 'jetpack' ),
+ 'search_items' => esc_html__( 'Search Projects', 'jetpack' ),
+ 'not_found' => esc_html__( 'No Projects found', 'jetpack' ),
+ 'not_found_in_trash' => esc_html__( 'No Projects found in Trash', 'jetpack' ),
+ 'filter_items_list' => esc_html__( 'Filter projects list', 'jetpack' ),
+ 'items_list_navigation' => esc_html__( 'Project list navigation', 'jetpack' ),
+ 'items_list' => esc_html__( 'Projects list', 'jetpack' ),
+ ),
+ 'supports' => array(
+ 'title',
+ 'editor',
+ 'thumbnail',
+ 'author',
+ 'post-formats',
+ 'comments',
+ 'publicize',
+ 'wpcom-markdown',
+ 'revisions',
+ 'excerpt',
+ 'custom-fields',
+ 'newspack_blocks',
+ ),
+ 'rewrite' => array(
+ 'slug' => 'portfolio',
+ 'with_front' => false,
+ 'feeds' => true,
+ 'pages' => true,
+ ),
+ 'public' => true,
+ 'show_ui' => true,
+ 'menu_position' => 20, // below Pages.
+ 'menu_icon' => 'dashicons-portfolio', // 3.8+ dashicon option.
+ 'capability_type' => 'page',
+ 'map_meta_cap' => true,
+ 'taxonomies' => array( self::CUSTOM_TAXONOMY_TYPE, self::CUSTOM_TAXONOMY_TAG ),
+ 'has_archive' => true,
+ 'query_var' => 'portfolio',
+ 'show_in_rest' => true,
+ )
+ );
+
+ register_taxonomy(
+ self::CUSTOM_TAXONOMY_TYPE,
+ self::CUSTOM_POST_TYPE,
+ array(
+ 'hierarchical' => true,
+ 'labels' => array(
+ 'name' => esc_html__( 'Project Types', 'jetpack' ),
+ 'singular_name' => esc_html__( 'Project Type', 'jetpack' ),
+ 'menu_name' => esc_html__( 'Project Types', 'jetpack' ),
+ 'all_items' => esc_html__( 'All Project Types', 'jetpack' ),
+ 'edit_item' => esc_html__( 'Edit Project Type', 'jetpack' ),
+ 'view_item' => esc_html__( 'View Project Type', 'jetpack' ),
+ 'update_item' => esc_html__( 'Update Project Type', 'jetpack' ),
+ 'add_new_item' => esc_html__( 'Add New Project Type', 'jetpack' ),
+ 'new_item_name' => esc_html__( 'New Project Type Name', 'jetpack' ),
+ 'parent_item' => esc_html__( 'Parent Project Type', 'jetpack' ),
+ 'parent_item_colon' => esc_html__( 'Parent Project Type:', 'jetpack' ),
+ 'search_items' => esc_html__( 'Search Project Types', 'jetpack' ),
+ 'items_list_navigation' => esc_html__( 'Project type list navigation', 'jetpack' ),
+ 'items_list' => esc_html__( 'Project type list', 'jetpack' ),
+ ),
+ 'public' => true,
+ 'show_ui' => true,
+ 'show_in_nav_menus' => true,
+ 'show_in_rest' => true,
+ 'show_admin_column' => true,
+ 'query_var' => true,
+ 'rewrite' => array( 'slug' => 'project-type' ),
+ )
+ );
+
+ register_taxonomy(
+ self::CUSTOM_TAXONOMY_TAG,
+ self::CUSTOM_POST_TYPE,
+ array(
+ 'hierarchical' => false,
+ 'labels' => array(
+ 'name' => esc_html__( 'Project Tags', 'jetpack' ),
+ 'singular_name' => esc_html__( 'Project Tag', 'jetpack' ),
+ 'menu_name' => esc_html__( 'Project Tags', 'jetpack' ),
+ 'all_items' => esc_html__( 'All Project Tags', 'jetpack' ),
+ 'edit_item' => esc_html__( 'Edit Project Tag', 'jetpack' ),
+ 'view_item' => esc_html__( 'View Project Tag', 'jetpack' ),
+ 'update_item' => esc_html__( 'Update Project Tag', 'jetpack' ),
+ 'add_new_item' => esc_html__( 'Add New Project Tag', 'jetpack' ),
+ 'new_item_name' => esc_html__( 'New Project Tag Name', 'jetpack' ),
+ 'search_items' => esc_html__( 'Search Project Tags', 'jetpack' ),
+ 'popular_items' => esc_html__( 'Popular Project Tags', 'jetpack' ),
+ 'separate_items_with_commas' => esc_html__( 'Separate tags with commas', 'jetpack' ),
+ 'add_or_remove_items' => esc_html__( 'Add or remove tags', 'jetpack' ),
+ 'choose_from_most_used' => esc_html__( 'Choose from the most used tags', 'jetpack' ),
+ 'not_found' => esc_html__( 'No tags found.', 'jetpack' ),
+ 'items_list_navigation' => esc_html__( 'Project tag list navigation', 'jetpack' ),
+ 'items_list' => esc_html__( 'Project tag list', 'jetpack' ),
+ ),
+ 'public' => true,
+ 'show_ui' => true,
+ 'show_in_nav_menus' => true,
+ 'show_in_rest' => true,
+ 'show_admin_column' => true,
+ 'query_var' => true,
+ 'rewrite' => array( 'slug' => 'project-tag' ),
+ )
+ );
+
+ register_taxonomy_for_object_type( 'post_format', self::CUSTOM_POST_TYPE );
}
/**
* Update messages for the Portfolio admin.
+ *
+ * @param array $messages Existing post update messages.
*/
- function updated_messages( $messages ) {
+ public function updated_messages( $messages ) {
global $post;
- $messages[self::CUSTOM_POST_TYPE] = array(
+ $messages[ self::CUSTOM_POST_TYPE ] = array(
0 => '', // Unused. Messages start at index 1.
- 1 => sprintf( __( 'Project updated. <a href="%s">View item</a>', 'jetpack'), esc_url( get_permalink( $post->ID ) ) ),
+ 1 => sprintf(
+ /* Translators: link to portfolio item's page. */
+ __( 'Project updated. <a href="%s">View item</a>', 'jetpack' ),
+ esc_url( get_permalink( $post->ID ) )
+ ),
2 => esc_html__( 'Custom field updated.', 'jetpack' ),
3 => esc_html__( 'Custom field deleted.', 'jetpack' ),
4 => esc_html__( 'Project updated.', 'jetpack' ),
- /* translators: %s: date and time of the revision */
- 5 => isset( $_GET['revision'] ) ? sprintf( esc_html__( 'Project restored to revision from %s', 'jetpack'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
- 6 => sprintf( __( 'Project published. <a href="%s">View project</a>', 'jetpack' ), esc_url( get_permalink( $post->ID ) ) ),
+ 5 => isset( $_GET['revision'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling.
+ ? sprintf(
+ /* translators: %s: date and time of the revision */
+ esc_html__( 'Project restored to revision from %s', 'jetpack' ),
+ wp_post_revision_title( (int) $_GET['revision'], false ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling.
+ )
+ : false,
+ 6 => sprintf(
+ /* Translators: link to portfolio item's page. */
+ __( 'Project published. <a href="%s">View project</a>', 'jetpack' ),
+ esc_url( get_permalink( $post->ID ) )
+ ),
7 => esc_html__( 'Project saved.', 'jetpack' ),
- 8 => sprintf( __( 'Project submitted. <a target="_blank" href="%s">Preview project</a>', 'jetpack'), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ),
- 9 => sprintf( __( 'Project scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview project</a>', 'jetpack' ),
- // translators: Publish box date format, see https://php.net/date
- date_i18n( __( 'M j, Y @ G:i', 'jetpack' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post->ID ) ) ),
- 10 => sprintf( __( 'Project item draft updated. <a target="_blank" href="%s">Preview project</a>', 'jetpack' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ),
+ 8 => sprintf(
+ /* Translators: link to portfolio item's page. */
+ __( 'Project submitted. <a target="_blank" href="%s">Preview project</a>', 'jetpack' ),
+ esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) )
+ ),
+ 9 => sprintf(
+ /* Translators: 1: Publishing date and time. 2. Link to portfolio's item page. */
+ __( 'Project scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview project</a>', 'jetpack' ),
+ /* translators: Publish box date format, see https://php.net/date */
+ date_i18n( __( 'M j, Y @ G:i', 'jetpack' ), strtotime( $post->post_date ) ),
+ esc_url( get_permalink( $post->ID ) )
+ ),
+ 10 => sprintf(
+ /* Translators: link to portfolio item's page. */
+ __( 'Project item draft updated. <a target="_blank" href="%s">Preview project</a>', 'jetpack' ),
+ esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) )
+ ),
);
return $messages;
@@ -396,13 +483,15 @@ class Jetpack_Portfolio {
/**
* Change ‘Title’ column label
* Add Featured Image column
+ *
+ * @param array $columns An array of column names.
*/
- function edit_admin_columns( $columns ) {
- // change 'Title' to 'Project'
+ public function edit_admin_columns( $columns ) {
+ // change 'Title' to 'Project'.
$columns['title'] = __( 'Project', 'jetpack' );
if ( current_theme_supports( 'post-thumbnails' ) ) {
- // add featured image before 'Project'
- $columns = array_slice( $columns, 0, 1, true ) + array( 'thumbnail' => '' ) + array_slice( $columns, 1, NULL, true );
+ // add featured image before 'Project'.
+ $columns = array_slice( $columns, 0, 1, true ) + array( 'thumbnail' => '' ) + array_slice( $columns, 1, null, true );
}
return $columns;
@@ -410,93 +499,129 @@ class Jetpack_Portfolio {
/**
* Add featured image to column
+ *
+ * @param string $column The name of the column to display.
+ * @param int $post_id The current post ID.
*/
- function image_column( $column, $post_id ) {
- global $post;
- switch ( $column ) {
- case 'thumbnail':
- echo get_the_post_thumbnail( $post_id, 'jetpack-portfolio-admin-thumb' );
- break;
+ public function image_column( $column, $post_id ) {
+ if ( 'thumbnail' !== $column ) {
+ return;
}
+
+ echo get_the_post_thumbnail( $post_id, 'jetpack-portfolio-admin-thumb' );
}
/**
* Adjust image column width
+ *
+ * @param string $hook Page hook.
*/
- function enqueue_admin_styles( $hook ) {
+ public function enqueue_admin_styles( $hook ) {
$screen = get_current_screen();
- if ( 'edit.php' == $hook && self::CUSTOM_POST_TYPE == $screen->post_type && current_theme_supports( 'post-thumbnails' ) ) {
+ if (
+ 'edit.php' === $hook
+ && self::CUSTOM_POST_TYPE === $screen->post_type
+ && current_theme_supports( 'post-thumbnails' )
+ ) {
wp_add_inline_style( 'wp-admin', '.manage-column.column-thumbnail { width: 50px; } @media screen and (max-width: 360px) { .column-thumbnail{ display:none; } }' );
}
}
/**
* Adds portfolio section to the Customizer.
+ *
+ * @param WP_Customize_Manager $wp_customize Customizer instance.
*/
- function customize_register( $wp_customize ) {
+ public function customize_register( $wp_customize ) {
$options = get_theme_support( self::CUSTOM_POST_TYPE );
if ( ( ! isset( $options[0]['title'] ) || true !== $options[0]['title'] ) && ( ! isset( $options[0]['content'] ) || true !== $options[0]['content'] ) && ( ! isset( $options[0]['featured-image'] ) || true !== $options[0]['featured-image'] ) ) {
return;
}
- $wp_customize->add_section( 'jetpack_portfolio', array(
- 'title' => esc_html__( 'Portfolio', 'jetpack' ),
- 'theme_supports' => self::CUSTOM_POST_TYPE,
- 'priority' => 130,
- ) );
+ $wp_customize->add_section(
+ 'jetpack_portfolio',
+ array(
+ 'title' => esc_html__( 'Portfolio', 'jetpack' ),
+ 'theme_supports' => self::CUSTOM_POST_TYPE,
+ 'priority' => 130,
+ )
+ );
if ( isset( $options[0]['title'] ) && true === $options[0]['title'] ) {
- $wp_customize->add_setting( 'jetpack_portfolio_title', array(
- 'default' => esc_html__( 'Projects', 'jetpack' ),
- 'type' => 'option',
- 'sanitize_callback' => 'sanitize_text_field',
- 'sanitize_js_callback' => 'sanitize_text_field',
- ) );
+ $wp_customize->add_setting(
+ 'jetpack_portfolio_title',
+ array(
+ 'default' => esc_html__( 'Projects', 'jetpack' ),
+ 'type' => 'option',
+ 'sanitize_callback' => 'sanitize_text_field',
+ 'sanitize_js_callback' => 'sanitize_text_field',
+ )
+ );
- $wp_customize->add_control( 'jetpack_portfolio_title', array(
- 'section' => 'jetpack_portfolio',
- 'label' => esc_html__( 'Portfolio Archive Title', 'jetpack' ),
- 'type' => 'text',
- ) );
+ $wp_customize->add_control(
+ 'jetpack_portfolio_title',
+ array(
+ 'section' => 'jetpack_portfolio',
+ 'label' => esc_html__( 'Portfolio Archive Title', 'jetpack' ),
+ 'type' => 'text',
+ )
+ );
}
if ( isset( $options[0]['content'] ) && true === $options[0]['content'] ) {
- $wp_customize->add_setting( 'jetpack_portfolio_content', array(
- 'default' => '',
- 'type' => 'option',
- 'sanitize_callback' => 'wp_kses_post',
- 'sanitize_js_callback' => 'wp_kses_post',
- ) );
+ $wp_customize->add_setting(
+ 'jetpack_portfolio_content',
+ array(
+ 'default' => '',
+ 'type' => 'option',
+ 'sanitize_callback' => 'wp_kses_post',
+ 'sanitize_js_callback' => 'wp_kses_post',
+ )
+ );
- $wp_customize->add_control( 'jetpack_portfolio_content', array(
- 'section' => 'jetpack_portfolio',
- 'label' => esc_html__( 'Portfolio Archive Content', 'jetpack' ),
- 'type' => 'textarea',
- ) );
+ $wp_customize->add_control(
+ 'jetpack_portfolio_content',
+ array(
+ 'section' => 'jetpack_portfolio',
+ 'label' => esc_html__( 'Portfolio Archive Content', 'jetpack' ),
+ 'type' => 'textarea',
+ )
+ );
}
if ( isset( $options[0]['featured-image'] ) && true === $options[0]['featured-image'] ) {
- $wp_customize->add_setting( 'jetpack_portfolio_featured_image', array(
- 'default' => '',
- 'type' => 'option',
- 'sanitize_callback' => 'attachment_url_to_postid',
- 'sanitize_js_callback' => 'attachment_url_to_postid',
- 'theme_supports' => 'post-thumbnails',
- ) );
+ $wp_customize->add_setting(
+ 'jetpack_portfolio_featured_image',
+ array(
+ 'default' => '',
+ 'type' => 'option',
+ 'sanitize_callback' => 'attachment_url_to_postid',
+ 'sanitize_js_callback' => 'attachment_url_to_postid',
+ 'theme_supports' => 'post-thumbnails',
+ )
+ );
- $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'jetpack_portfolio_featured_image', array(
- 'section' => 'jetpack_portfolio',
- 'label' => esc_html__( 'Portfolio Archive Featured Image', 'jetpack' ),
- ) ) );
+ $wp_customize->add_control(
+ new WP_Customize_Image_Control(
+ $wp_customize,
+ 'jetpack_portfolio_featured_image',
+ array(
+ 'section' => 'jetpack_portfolio',
+ 'label' => esc_html__( 'Portfolio Archive Featured Image', 'jetpack' ),
+ )
+ )
+ );
}
}
/**
* Follow CPT reading setting on CPT archive and taxonomy pages
+ *
+ * @param WP_Query $query A WP_Query instance.
*/
- function query_reading_setting( $query ) {
+ public function query_reading_setting( $query ) {
if ( ( ! is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) )
&& $query->is_main_query()
&& ( $query->is_post_type_archive( self::CUSTOM_POST_TYPE )
@@ -507,10 +632,12 @@ class Jetpack_Portfolio {
}
}
- /*
+ /**
* If Infinite Scroll is set to 'click', use our custom reading setting instead of core's `posts_per_page`.
+ *
+ * @param array $settings Array of Infinite Scroll settings.
*/
- function infinite_scroll_click_posts_per_page( $settings ) {
+ public function infinite_scroll_click_posts_per_page( $settings ) {
global $wp_query;
if ( ( ! is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) )
@@ -519,24 +646,30 @@ class Jetpack_Portfolio {
|| $wp_query->is_tax( self::CUSTOM_TAXONOMY_TYPE )
|| $wp_query->is_tax( self::CUSTOM_TAXONOMY_TAG ) )
) {
- $settings['posts_per_page'] = get_option( self::OPTION_READING_SETTING, $settings['posts_per_page'] );
+ $settings['posts_per_page'] = get_option( self::OPTION_READING_SETTING, $settings['posts_per_page'] ); // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
}
return $settings;
}
- /*
+ /**
* Filter the results of infinite scroll to make sure we get `lastbatch` right.
+ *
+ * @param array $results Array of Infinite Scroll results.
+ * @param array $query_args Array of main query arguments.
+ * @param WP_Query $query WP Query.
*/
- function infinite_scroll_results( $results, $query_args, $query ) {
+ public function infinite_scroll_results( $results, $query_args, $query ) {
$results['lastbatch'] = $query_args['paged'] >= $query->max_num_pages;
return $results;
}
/**
* Add CPT to Dotcom sitemap
+ *
+ * @param array $post_types Array of post types included in sitemap.
*/
- function add_to_sitemap( $post_types ) {
+ public function add_to_sitemap( $post_types ) {
$post_types[] = self::CUSTOM_POST_TYPE;
return $post_types;
@@ -544,8 +677,10 @@ class Jetpack_Portfolio {
/**
* Add to REST API post type allowed list.
+ *
+ * @param array $post_types Array of post types to add to the allowed list. Default to `array( 'post', 'page', 'revision' )`.
*/
- function allow_portfolio_rest_api_type( $post_types ) {
+ public function allow_portfolio_rest_api_type( $post_types ) {
$post_types[] = self::CUSTOM_POST_TYPE;
return $post_types;
@@ -555,39 +690,44 @@ class Jetpack_Portfolio {
* Our [portfolio] shortcode.
* Prints Portfolio data styled to look good on *any* theme.
*
+ * @param array $atts Shortcode attributes.
+ *
* @return portfolio_shortcode_html
*/
- static function portfolio_shortcode( $atts ) {
- // Default attributes
- $atts = shortcode_atts( array(
- 'display_types' => true,
- 'display_tags' => true,
- 'display_content' => true,
- 'display_author' => false,
- 'show_filter' => false,
- 'include_type' => false,
- 'include_tag' => false,
- 'columns' => 2,
- 'showposts' => -1,
- 'order' => 'asc',
- 'orderby' => 'date',
- ), $atts, 'portfolio' );
-
- // A little sanitization
- if ( $atts['display_types'] && 'true' != $atts['display_types'] ) {
- $atts['display_types'] = false;
- }
-
- if ( $atts['display_tags'] && 'true' != $atts['display_tags'] ) {
- $atts['display_tags'] = false;
- }
+ public static function portfolio_shortcode( $atts ) {
+ // Default attributes.
+ $atts = shortcode_atts(
+ array(
+ 'display_types' => true,
+ 'display_tags' => true,
+ 'display_content' => true, // Can be false, true, or full.
+ 'display_author' => false,
+ 'show_filter' => false,
+ 'include_type' => false,
+ 'include_tag' => false,
+ 'columns' => 2,
+ 'showposts' => -1,
+ 'order' => 'asc',
+ 'orderby' => 'date',
+ ),
+ $atts,
+ 'portfolio'
+ );
- if ( $atts['display_author'] && 'true' != $atts['display_author'] ) {
- $atts['display_author'] = false;
- }
+ /*
+ * A little sanitization for our shortcode attributes aiming to use booleans.
+ * Attributes can be booleans (from the default values) or strings.
+ */
+ foreach ( $atts as $attribute_name => $attribute_value ) {
+ if ( preg_match( '#^(?:display_|show_)#i', $attribute_name ) ) {
+ // display_content is a special case.
+ if ( 'display_content' === $attribute_name && 'full' === $attribute_value ) {
+ $atts['display_content'] = 'full';
+ continue;
+ }
- if ( $atts['display_content'] && 'true' != $atts['display_content'] && 'full' != $atts['display_content'] ) {
- $atts['display_content'] = false;
+ $atts[ $attribute_name ] = self::sanitize_boolean_attribute( $attribute_value );
+ }
}
if ( $atts['include_type'] ) {
@@ -602,11 +742,10 @@ class Jetpack_Portfolio {
$atts['showposts'] = (int) $atts['showposts'];
-
if ( $atts['order'] ) {
$atts['order'] = urldecode( $atts['order'] );
$atts['order'] = strtoupper( $atts['order'] );
- if ( 'DESC' != $atts['order'] ) {
+ if ( 'DESC' !== $atts['order'] ) {
$atts['order'] = 'ASC';
}
}
@@ -614,11 +753,11 @@ class Jetpack_Portfolio {
if ( $atts['orderby'] ) {
$atts['orderby'] = urldecode( $atts['orderby'] );
$atts['orderby'] = strtolower( $atts['orderby'] );
- $allowed_keys = array( 'author', 'date', 'title', 'rand' );
+ $allowed_keys = array( 'author', 'date', 'title', 'rand' );
$parsed = array();
- foreach ( explode( ',', $atts['orderby'] ) as $portfolio_index_number => $orderby ) {
- if ( ! in_array( $orderby, $allowed_keys ) ) {
+ foreach ( explode( ',', $atts['orderby'] ) as $orderby ) {
+ if ( ! in_array( $orderby, $allowed_keys, true ) ) {
continue;
}
$parsed[] = $orderby;
@@ -631,7 +770,7 @@ class Jetpack_Portfolio {
}
}
- // enqueue shortcode styles when shortcode is used
+ // enqueue shortcode styles when shortcode is used.
if ( ! wp_style_is( 'jetpack-portfolio-style', 'enqueued' ) ) {
wp_enqueue_style( 'jetpack-portfolio-style', plugins_url( 'css/portfolio-shortcode.css', __FILE__ ), array(), '20140326' );
}
@@ -640,48 +779,74 @@ class Jetpack_Portfolio {
}
/**
+ * Sanitizes an attribute value.
+ * Attributes can be booleans (from the default values) or strings.
+ *
+ * @since 11.0
+ *
+ * @param bool|string $attr Shortcode attribute value.
+ *
+ * @return bool
+ */
+ private static function sanitize_boolean_attribute( $attr ) {
+ if ( $attr && 'true' == $attr ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
* Query to retrieve entries from the Portfolio post_type.
*
+ * @param array $atts Shortcode attributes.
+ *
* @return object
*/
- static function portfolio_query( $atts ) {
- // Default query arguments
+ private static function portfolio_query( $atts ) {
+ // Default query arguments.
$default = array(
'order' => $atts['order'],
'orderby' => $atts['orderby'],
'posts_per_page' => $atts['showposts'],
);
- $args = wp_parse_args( $atts, $default );
- $args['post_type'] = self::CUSTOM_POST_TYPE; // Force this post type
+ $args = wp_parse_args( $atts, $default );
+ $args['post_type'] = self::CUSTOM_POST_TYPE; // Force this post type.
- if ( false != $atts['include_type'] || false != $atts['include_tag'] ) {
+ if ( $atts['include_type'] || $atts['include_tag'] ) {
$args['tax_query'] = array();
}
- // If 'include_type' has been set use it on the main query
- if ( false != $atts['include_type'] ) {
- array_push( $args['tax_query'], array(
- 'taxonomy' => self::CUSTOM_TAXONOMY_TYPE,
- 'field' => 'slug',
- 'terms' => $atts['include_type'],
- ) );
+ // If 'include_type' has been set use it on the main query.
+ if ( $atts['include_type'] ) {
+ array_push(
+ $args['tax_query'],
+ array(
+ 'taxonomy' => self::CUSTOM_TAXONOMY_TYPE,
+ 'field' => 'slug',
+ 'terms' => $atts['include_type'],
+ )
+ );
}
- // If 'include_tag' has been set use it on the main query
- if ( false != $atts['include_tag'] ) {
- array_push( $args['tax_query'], array(
- 'taxonomy' => self::CUSTOM_TAXONOMY_TAG,
- 'field' => 'slug',
- 'terms' => $atts['include_tag'],
- ) );
+ // If 'include_tag' has been set use it on the main query.
+ if ( $atts['include_tag'] ) {
+ array_push(
+ $args['tax_query'],
+ array(
+ 'taxonomy' => self::CUSTOM_TAXONOMY_TAG,
+ 'field' => 'slug',
+ 'terms' => $atts['include_tag'],
+ )
+ );
}
- if ( false != $atts['include_type'] && false != $atts['include_tag'] ) {
+ if ( $atts['include_type'] && $atts['include_tag'] ) {
$args['tax_query']['relation'] = 'AND';
}
- // Run the query and return
+ // Run the query and return.
$query = new WP_Query( $args );
return $query;
}
@@ -690,52 +855,57 @@ class Jetpack_Portfolio {
* The Portfolio shortcode loop.
*
* @todo add theme color styles
+ *
+ * @param array $atts Shortcode attributes.
+ *
* @return html
*/
- static function portfolio_shortcode_html( $atts ) {
-
- $query = self::portfolio_query( $atts );
+ private static function portfolio_shortcode_html( $atts ) {
+ $query = self::portfolio_query( $atts );
$portfolio_index_number = 0;
ob_start();
- // If we have posts, create the html
- // with hportfolio markup
+ /*
+ * If we have posts, create the html
+ * with portfolio markup
+ */
if ( $query->have_posts() ) {
-
- // Render styles
- //self::themecolor_styles();
-
- ?>
+ /*
+ * Render styles
+ * See self::themecolor_styles();
+ */
+ ?>
<div class="jetpack-portfolio-shortcode column-<?php echo esc_attr( $atts['columns'] ); ?>">
- <?php // open .jetpack-portfolio
+ <?php
+ // open .jetpack-portfolio.
// Construct the loop...
while ( $query->have_posts() ) {
$query->the_post();
$post_id = get_the_ID();
?>
- <div class="portfolio-entry <?php echo esc_attr( self::get_project_class( $portfolio_index_number, $atts['columns'] ) ); ?>">
+ <div class="portfolio-entry <?php echo esc_attr( self::get_project_class( $portfolio_index_number, (int) $atts['columns'] ) ); ?>">
<header class="portfolio-entry-header">
<?php
- // Featured image
- echo self::get_portfolio_thumbnail_link( $post_id );
+ // Featured image.
+ echo self::get_portfolio_thumbnail_link( $post_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in method.
?>
- <h2 class="portfolio-entry-title"><a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php echo esc_attr( the_title_attribute( ) ); ?>"><?php the_title(); ?></a></h2>
+ <h2 class="portfolio-entry-title"><a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php echo esc_attr( the_title_attribute() ); ?>"><?php the_title(); ?></a></h2>
<div class="portfolio-entry-meta">
<?php
- if ( false != $atts['display_types'] ) {
- echo self::get_project_type( $post_id );
+ if ( $atts['display_types'] ) {
+ echo self::get_project_type( $post_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in method.
}
- if ( false != $atts['display_tags'] ) {
- echo self::get_project_tags( $post_id );
+ if ( $atts['display_tags'] ) {
+ echo self::get_project_tags( $post_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in method.
}
- if ( false != $atts['display_author'] ) {
- echo self::get_project_author( $post_id );
+ if ( $atts['display_author'] ) {
+ echo self::get_project_author( $post_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in method.
}
?>
</div>
@@ -743,74 +913,77 @@ class Jetpack_Portfolio {
</header>
<?php
- // The content
- if ( false !== $atts['display_content'] ) {
+ // The content.
+ if ( $atts['display_content'] ) {
add_filter( 'wordads_inpost_disable', '__return_true', 20 );
if ( 'full' === $atts['display_content'] ) {
- ?>
+ ?>
<div class="portfolio-entry-content"><?php the_content(); ?></div>
- <?php
+ <?php
} else {
- ?>
+ ?>
<div class="portfolio-entry-content"><?php the_excerpt(); ?></div>
- <?php
+ <?php
}
remove_filter( 'wordads_inpost_disable', '__return_true', 20 );
}
?>
</div><!-- close .portfolio-entry -->
- <?php $portfolio_index_number++;
- } // end of while loop
+ <?php
+ $portfolio_index_number++;
+ } // end of while loop.
wp_reset_postdata();
?>
</div><!-- close .jetpack-portfolio -->
- <?php
- } else { ?>
- <p><em><?php _e( 'Your Portfolio Archive currently has no entries. You can start creating them on your dashboard.', 'jetpack' ); ?></p></em>
- <?php
+ <?php
+ } else {
+ ?>
+ <p><em><?php esc_html_e( 'Your Portfolio Archive currently has no entries. You can start creating them on your dashboard.', 'jetpack' ); ?></p></em>
+ <?php
}
$html = ob_get_clean();
- // If there is a [portfolio] within a [portfolio], remove the shortcode
- if ( has_shortcode( $html, 'portfolio' ) ){
+ // If there is a [portfolio] within a [portfolio], remove the shortcode.
+ if ( has_shortcode( $html, 'portfolio' ) ) {
remove_shortcode( 'portfolio' );
}
- // Return the HTML block
+ // Return the HTML block.
return $html;
}
/**
* Individual project class
*
+ * @param int $portfolio_index_number Index number when looping through Portfolio items.
+ * @param int $columns Number of columns in shortcode output.
* @return string
*/
- static function get_project_class( $portfolio_index_number, $columns ) {
+ private static function get_project_class( $portfolio_index_number, $columns ) {
$project_types = wp_get_object_terms( get_the_ID(), self::CUSTOM_TAXONOMY_TYPE, array( 'fields' => 'slugs' ) );
- $class = array();
+ $class = array();
- $class[] = 'portfolio-entry-column-'.$columns;
- // add a type- class for each project type
+ $class[] = 'portfolio-entry-column-' . $columns;
+ // add a type- class for each project type.
foreach ( $project_types as $project_type ) {
$class[] = 'type-' . esc_html( $project_type );
}
- if( $columns > 1) {
- if ( ( $portfolio_index_number % 2 ) == 0 ) {
+ if ( $columns > 1 ) {
+ if ( ( $portfolio_index_number % 2 ) === 0 ) {
$class[] = 'portfolio-entry-mobile-first-item-row';
} else {
$class[] = 'portfolio-entry-mobile-last-item-row';
}
}
- // add first and last classes to first and last items in a row
- if ( ( $portfolio_index_number % $columns ) == 0 ) {
+ // add first and last classes to first and last items in a row.
+ if ( ( $portfolio_index_number % $columns ) === 0 ) {
$class[] = 'portfolio-entry-first-item-row';
- } elseif ( ( $portfolio_index_number % $columns ) == ( $columns - 1 ) ) {
+ } elseif ( ( $portfolio_index_number % $columns ) === ( $columns - 1 ) ) {
$class[] = 'portfolio-entry-last-item-row';
}
-
/**
* Filter the class applied to project div in the portfolio
*
@@ -821,27 +994,33 @@ class Jetpack_Portfolio {
* @param string $class class name of the div.
* @param int $portfolio_index_number iterator count the number of columns up starting from 0.
* @param int $columns number of columns to display the content in.
- *
*/
- return apply_filters( 'portfolio-project-post-class', implode( " ", $class ) , $portfolio_index_number, $columns );
+ return apply_filters(
+ 'portfolio-project-post-class', // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
+ implode( ' ', $class ),
+ $portfolio_index_number,
+ $columns
+ );
}
/**
* Displays the project type that a project belongs to.
*
+ * @param int $post_id Post ID.
+ *
* @return html
*/
- static function get_project_type( $post_id ) {
+ private static function get_project_type( $post_id ) {
$project_types = get_the_terms( $post_id, self::CUSTOM_TAXONOMY_TYPE );
- // If no types, return empty string
+ // If no types, return empty string.
if ( empty( $project_types ) || is_wp_error( $project_types ) ) {
return;
}
- $html = '<div class="project-types"><span>' . __( 'Types', 'jetpack' ) . ':</span>';
+ $html = '<div class="project-types"><span>' . __( 'Types:', 'jetpack' ) . '</span>';
$types = array();
- // Loop thorugh all the types
+ // Loop through all the types.
foreach ( $project_types as $project_type ) {
$project_type_link = get_term_link( $project_type, self::CUSTOM_TAXONOMY_TYPE );
@@ -851,7 +1030,7 @@ class Jetpack_Portfolio {
$types[] = '<a href="' . esc_url( $project_type_link ) . '" rel="tag">' . esc_html( $project_type->name ) . '</a>';
}
- $html .= ' '.implode( ', ', $types );
+ $html .= ' ' . implode( ', ', $types );
$html .= '</div>';
return $html;
@@ -860,19 +1039,21 @@ class Jetpack_Portfolio {
/**
* Displays the project tags that a project belongs to.
*
+ * @param int $post_id Post ID.
+ *
* @return html
*/
- static function get_project_tags( $post_id ) {
+ private static function get_project_tags( $post_id ) {
$project_tags = get_the_terms( $post_id, self::CUSTOM_TAXONOMY_TAG );
- // If no tags, return empty string
+ // If no tags, return empty string.
if ( empty( $project_tags ) || is_wp_error( $project_tags ) ) {
return false;
}
- $html = '<div class="project-tags"><span>' . __( 'Tags', 'jetpack' ) . ':</span>';
+ $html = '<div class="project-tags"><span>' . __( 'Tags:', 'jetpack' ) . '</span>';
$tags = array();
- // Loop thorugh all the tags
+ // Loop through all the tags.
foreach ( $project_tags as $project_tag ) {
$project_tag_link = get_term_link( $project_tag, self::CUSTOM_TAXONOMY_TYPE );
@@ -882,7 +1063,7 @@ class Jetpack_Portfolio {
$tags[] = '<a href="' . esc_url( $project_tag_link ) . '" rel="tag">' . esc_html( $project_tag->name ) . '</a>';
}
- $html .= ' '. implode( ', ', $tags );
+ $html .= ' ' . implode( ', ', $tags );
$html .= '</div>';
return $html;
@@ -893,10 +1074,11 @@ class Jetpack_Portfolio {
*
* @return html
*/
- static function get_project_author() {
- $html = '<div class="project-author">';
- /* translators: %1$s is link to author posts, %2$s is author display name */
- $html .= sprintf( __( '<span>Author:</span> <a href="%1$s">%2$s</a>', 'jetpack' ),
+ private static function get_project_author() {
+ $html = '<div class="project-author">';
+ $html .= sprintf(
+ /* translators: %1$s is link to author posts, %2$s is author display name */
+ __( '<span>Author:</span> <a href="%1$s">%2$s</a>', 'jetpack' ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_html( get_the_author() )
);
@@ -908,9 +1090,11 @@ class Jetpack_Portfolio {
/**
* Display the featured image if it's available
*
+ * @param int $post_id Post ID.
+ *
* @return html
*/
- static function get_portfolio_thumbnail_link( $post_id ) {
+ private static function get_portfolio_thumbnail_link( $post_id ) {
if ( has_post_thumbnail( $post_id ) ) {
/**
* Change the Portfolio thumbnail size.
@@ -928,6 +1112,6 @@ class Jetpack_Portfolio {
add_action( 'init', array( 'Jetpack_Portfolio', 'init' ) );
-// Check on plugin activation if theme supports CPT
-register_activation_hook( __FILE__, array( 'Jetpack_Portfolio', 'activation_post_type_support' ) );
+// Check on plugin activation if theme supports CPT.
+register_activation_hook( __FILE__, array( 'Jetpack_Portfolio', 'activation_post_type_support' ) );
add_action( 'jetpack_activate_module_custom-content-types', array( 'Jetpack_Portfolio', 'activation_post_type_support' ) );
diff --git a/plugins/jetpack/modules/custom-post-types/testimonial.php b/plugins/jetpack/modules/custom-post-types/testimonial.php
index 1e839c76..59031486 100644
--- a/plugins/jetpack/modules/custom-post-types/testimonial.php
+++ b/plugins/jetpack/modules/custom-post-types/testimonial.php
@@ -1,17 +1,30 @@
-<?php
-
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Register a Testimonial post type and handle displaying it anywhere on the site.
+ *
+ * @package automattic/jetpack
+ * @phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound
+ * @phpcs:disable MediaWiki.Usage.NestedFunctions.NestedFunction
+ */
+
+/**
+ * Add a Testimonial CPT, and display it with a shortcode
+ */
class Jetpack_Testimonial {
const CUSTOM_POST_TYPE = 'jetpack-testimonial';
const OPTION_NAME = 'jetpack_testimonial';
const OPTION_READING_SETTING = 'jetpack_testimonial_posts_per_page';
- public $version = '0.1';
-
- static function init() {
+ /**
+ * Initialize class.
+ *
+ * @return self
+ */
+ public static function init() {
static $instance = false;
if ( ! $instance ) {
- $instance = new Jetpack_Testimonial;
+ $instance = new Jetpack_Testimonial();
}
return $instance;
@@ -23,12 +36,12 @@ class Jetpack_Testimonial {
* Setup user option for enabling CPT.
* If user has CPT enabled, show in admin.
*/
- function __construct() {
+ public function __construct() {
// Make sure the post types are loaded for imports
- add_action( 'import_start', array( $this, 'register_post_types' ) );
+ add_action( 'import_start', array( $this, 'register_post_types' ) );
// If called via REST API, we need to register later in lifecycle
- add_action( 'restapi_theme_init', array( $this, 'maybe_register_cpt' ) );
+ add_action( 'restapi_theme_init', array( $this, 'maybe_register_cpt' ) );
// Add to REST API post type allowed list.
add_filter( 'rest_api_allowed_post_types', array( $this, 'allow_cpt_rest_api_type' ) );
@@ -40,7 +53,7 @@ class Jetpack_Testimonial {
* Registers the custom post types and adds action/filter handlers, but
* only if the site supports it
*/
- function maybe_register_cpt() {
+ public function maybe_register_cpt() {
// Add an option to enable the CPT
add_action( 'admin_init', array( $this, 'settings_api_init' ) );
@@ -60,50 +73,50 @@ class Jetpack_Testimonial {
// CPT magic
$this->register_post_types();
- add_action( sprintf( 'add_option_%s', self::OPTION_NAME ), array( $this, 'flush_rules_on_enable' ), 10 );
- add_action( sprintf( 'update_option_%s', self::OPTION_NAME ), array( $this, 'flush_rules_on_enable' ), 10 );
- add_action( sprintf( 'publish_%s', self::CUSTOM_POST_TYPE ), array( $this, 'flush_rules_on_first_testimonial' ) );
- add_action( 'after_switch_theme', array( $this, 'flush_rules_on_switch' ) );
+ add_action( sprintf( 'add_option_%s', self::OPTION_NAME ), array( $this, 'flush_rules_on_enable' ), 10 );
+ add_action( sprintf( 'update_option_%s', self::OPTION_NAME ), array( $this, 'flush_rules_on_enable' ), 10 );
+ add_action( sprintf( 'publish_%s', self::CUSTOM_POST_TYPE ), array( $this, 'flush_rules_on_first_testimonial' ) );
+ add_action( 'after_switch_theme', array( $this, 'flush_rules_on_switch' ) );
// Admin Customization
- add_filter( 'enter_title_here', array( $this, 'change_default_title' ) );
- add_filter( sprintf( 'manage_%s_posts_columns', self::CUSTOM_POST_TYPE), array( $this, 'edit_title_column_label' ) );
- add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) );
- add_action( 'customize_register', array( $this, 'customize_register' ) );
+ add_filter( 'enter_title_here', array( $this, 'change_default_title' ) );
+ add_filter( sprintf( 'manage_%s_posts_columns', self::CUSTOM_POST_TYPE ), array( $this, 'edit_title_column_label' ) );
+ add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) );
+ add_action( 'customize_register', array( $this, 'customize_register' ) );
// Only add the 'Customize' sub-menu if the theme supports it.
if ( is_admin() && current_theme_supports( self::CUSTOM_POST_TYPE ) && ! empty( self::count_testimonials() ) ) {
- add_action( 'admin_menu', array( $this, 'add_customize_page' ) );
+ add_action( 'admin_menu', array( $this, 'add_customize_page' ) );
}
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
// Track all the things
- add_action( sprintf( 'add_option_%s', self::OPTION_NAME ), array( $this, 'new_activation_stat_bump' ) );
- add_action( sprintf( 'update_option_%s', self::OPTION_NAME ), array( $this, 'update_option_stat_bump' ), 11, 2 );
- add_action( sprintf( 'publish_%s', self::CUSTOM_POST_TYPE), array( $this, 'new_testimonial_stat_bump' ) );
+ add_action( sprintf( 'add_option_%s', self::OPTION_NAME ), array( $this, 'new_activation_stat_bump' ) );
+ add_action( sprintf( 'update_option_%s', self::OPTION_NAME ), array( $this, 'update_option_stat_bump' ), 11, 2 );
+ add_action( sprintf( 'publish_%s', self::CUSTOM_POST_TYPE ), array( $this, 'new_testimonial_stat_bump' ) );
// Add to Dotcom XML sitemaps
- add_filter( 'wpcom_sitemap_post_types', array( $this, 'add_to_sitemap' ) );
+ add_filter( 'wpcom_sitemap_post_types', array( $this, 'add_to_sitemap' ) );
} else {
// Add to Jetpack XML sitemap
- add_filter( 'jetpack_sitemap_post_types', array( $this, 'add_to_sitemap' ) );
+ add_filter( 'jetpack_sitemap_post_types', array( $this, 'add_to_sitemap' ) );
}
// Adjust CPT archive and custom taxonomies to obey CPT reading setting
- add_filter( 'pre_get_posts', array( $this, 'query_reading_setting' ), 20 );
- add_filter( 'infinite_scroll_settings', array( $this, 'infinite_scroll_click_posts_per_page' ) );
+ add_filter( 'pre_get_posts', array( $this, 'query_reading_setting' ), 20 );
+ add_filter( 'infinite_scroll_settings', array( $this, 'infinite_scroll_click_posts_per_page' ) );
// Register [jetpack_testimonials] always and
// register [testimonials] if [testimonials] isn't already set
- add_shortcode( 'jetpack_testimonials', array( $this, 'jetpack_testimonial_shortcode' ) );
+ add_shortcode( 'jetpack_testimonials', array( $this, 'jetpack_testimonial_shortcode' ) );
if ( ! shortcode_exists( 'testimonials' ) ) {
- add_shortcode( 'testimonials', array( $this, 'jetpack_testimonial_shortcode' ) );
+ add_shortcode( 'testimonials', array( $this, 'jetpack_testimonial_shortcode' ) );
}
// If CPT was enabled programatically and no CPT items exist when user switches away, disable
if ( $setting && $this->site_supports_custom_post_type() ) {
- add_action( 'switch_theme', array( $this, 'deactivation_post_type_support' ) );
+ add_action( 'switch_theme', array( $this, 'deactivation_post_type_support' ) );
}
}
@@ -111,9 +124,9 @@ class Jetpack_Testimonial {
* Add a checkbox field in 'Settings' > 'Writing'
* for enabling CPT functionality.
*
- * @return null
+ * @return void
*/
- function settings_api_init() {
+ public function settings_api_init() {
add_settings_field(
self::OPTION_NAME,
'<span class="cpt-options">' . __( 'Testimonials', 'jetpack' ) . '</span>',
@@ -128,7 +141,7 @@ class Jetpack_Testimonial {
'intval'
);
- // Check if CPT is enabled first so that intval doesn't get set to NULL on re-registering
+ // Check if CPT is enabled first so that intval doesn't get set to NULL on re-registering.
if ( $this->site_supports_custom_post_type() ) {
register_setting(
'writing',
@@ -142,25 +155,29 @@ class Jetpack_Testimonial {
* HTML code to display a checkbox true/false option
* for the CPT setting.
*
- * @return html
+ * @return void
*/
- function setting_html() {
+ public function setting_html() {
if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) : ?>
- <p><?php printf( __( 'Your theme supports Testimonials', 'jetpack' ) ); ?></p>
+ <p><?php esc_html_e( 'Your theme supports Testimonials', 'jetpack' ); ?></p>
<?php else : ?>
<label for="<?php echo esc_attr( self::OPTION_NAME ); ?>">
<input name="<?php echo esc_attr( self::OPTION_NAME ); ?>" id="<?php echo esc_attr( self::OPTION_NAME ); ?>" <?php echo checked( get_option( self::OPTION_NAME, '0' ), true, false ); ?> type="checkbox" value="1" />
<?php esc_html_e( 'Enable Testimonials for this site.', 'jetpack' ); ?>
<a target="_blank" href="https://en.support.wordpress.com/testimonials/"><?php esc_html_e( 'Learn More', 'jetpack' ); ?></a>
</label>
- <?php endif;
+ <?php
+ endif;
if ( $this->site_supports_custom_post_type() ) :
- printf( '<p><label for="%1$s">%2$s</label></p>',
+ printf(
+ '<p><label for="%1$s">%2$s</label></p>',
esc_attr( self::OPTION_READING_SETTING ),
- /* translators: %1$s is replaced with an input field for numbers */
- sprintf( __( 'Testimonial pages display at most %1$s testimonials', 'jetpack' ),
- sprintf( '<input name="%1$s" id="%1$s" type="number" step="1" min="1" value="%2$s" class="small-text" />',
+ sprintf(
+ /* translators: %1$s is replaced with an input field for numbers */
+ esc_html__( 'Testimonial pages display at most %1$s testimonials', 'jetpack' ),
+ sprintf(
+ '<input name="%1$s" id="%1$s" type="number" step="1" min="1" value="%2$s" class="small-text" />',
esc_attr( self::OPTION_READING_SETTING ),
esc_attr( get_option( self::OPTION_READING_SETTING, '10' ) )
)
@@ -172,7 +189,7 @@ class Jetpack_Testimonial {
/**
* Should this Custom Post Type be made available?
*/
- function site_supports_custom_post_type() {
+ private function site_supports_custom_post_type() {
// If the current theme requests it.
if ( current_theme_supports( self::CUSTOM_POST_TYPE ) || get_option( self::OPTION_NAME, '0' ) ) {
return true;
@@ -185,8 +202,11 @@ class Jetpack_Testimonial {
/**
* Add to REST API post type allowed list.
+ *
+ * @param array $post_types Array of allowed post types.
+ * @return array `$post_types` with our type added.
*/
- function allow_cpt_rest_api_type( $post_types ) {
+ public function allow_cpt_rest_api_type( $post_types ) {
$post_types[] = self::CUSTOM_POST_TYPE;
return $post_types;
@@ -195,15 +215,18 @@ class Jetpack_Testimonial {
/**
* Bump Testimonial > New Activation stat
*/
- function new_activation_stat_bump() {
+ public function new_activation_stat_bump() {
/** This action is documented in modules/widgets/social-media-icons.php */
do_action( 'jetpack_bump_stats_extras', 'testimonials', 'new-activation' );
}
/**
* Bump Testimonial > Option On/Off stats to get total active
+ *
+ * @param mixed $old The old option value.
+ * @param mixed $new The new option value.
*/
- function update_option_stat_bump( $old, $new ) {
+ public function update_option_stat_bump( $old, $new ) {
if ( empty( $old ) && ! empty( $new ) ) {
/** This action is documented in modules/widgets/social-media-icons.php */
do_action( 'jetpack_bump_stats_extras', 'testimonials', 'option-on' );
@@ -218,22 +241,22 @@ class Jetpack_Testimonial {
/**
* Bump Testimonial > Published Testimonials stat when testimonials are published
*/
- function new_testimonial_stat_bump() {
+ public function new_testimonial_stat_bump() {
/** This action is documented in modules/widgets/social-media-icons.php */
- do_action ( 'jetpack_bump_stats_extras', 'testimonials', 'published-testimonials' );
+ do_action( 'jetpack_bump_stats_extras', 'testimonials', 'published-testimonials' );
}
- /*
+ /**
* Flush permalinks when CPT option is turned on/off
*/
- function flush_rules_on_enable() {
+ public function flush_rules_on_enable() {
flush_rewrite_rules();
}
- /*
+ /**
* Count published testimonials and flush permalinks when first testimonial is published
*/
- function flush_rules_on_first_testimonial() {
+ public function flush_rules_on_first_testimonial() {
$testimonials = get_transient( 'jetpack-testimonial-count-cache' );
if ( false === $testimonials ) {
@@ -246,10 +269,10 @@ class Jetpack_Testimonial {
}
}
- /*
+ /**
* Flush permalinks when CPT supported theme is activated
*/
- function flush_rules_on_switch() {
+ public function flush_rules_on_switch() {
if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) {
flush_rewrite_rules();
}
@@ -258,7 +281,7 @@ class Jetpack_Testimonial {
/**
* On plugin/theme activation, check if current theme supports CPT
*/
- static function activation_post_type_support() {
+ public static function activation_post_type_support() {
if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) {
update_option( self::OPTION_NAME, '1' );
}
@@ -267,13 +290,15 @@ class Jetpack_Testimonial {
/**
* On theme switch, check if CPT item exists and disable if not
*/
- function deactivation_post_type_support() {
- $portfolios = get_posts( array(
- 'fields' => 'ids',
- 'posts_per_page' => 1,
- 'post_type' => self::CUSTOM_POST_TYPE,
- 'suppress_filters' => false
- ) );
+ public function deactivation_post_type_support() {
+ $portfolios = get_posts(
+ array(
+ 'fields' => 'ids',
+ 'posts_per_page' => 1,
+ 'post_type' => self::CUSTOM_POST_TYPE,
+ 'suppress_filters' => false,
+ )
+ );
if ( empty( $portfolios ) ) {
update_option( self::OPTION_NAME, '0' );
@@ -283,78 +308,109 @@ class Jetpack_Testimonial {
/**
* Register Post Type
*/
- function register_post_types() {
+ public function register_post_types() {
if ( post_type_exists( self::CUSTOM_POST_TYPE ) ) {
return;
}
- register_post_type( self::CUSTOM_POST_TYPE, array(
- 'description' => __( 'Customer Testimonials', 'jetpack' ),
- 'labels' => array(
- 'name' => esc_html__( 'Testimonials', 'jetpack' ),
- 'singular_name' => esc_html__( 'Testimonial', 'jetpack' ),
- 'menu_name' => esc_html__( 'Testimonials', 'jetpack' ),
- 'all_items' => esc_html__( 'All Testimonials', 'jetpack' ),
- 'add_new' => esc_html__( 'Add New', 'jetpack' ),
- 'add_new_item' => esc_html__( 'Add New Testimonial', 'jetpack' ),
- 'edit_item' => esc_html__( 'Edit Testimonial', 'jetpack' ),
- 'new_item' => esc_html__( 'New Testimonial', 'jetpack' ),
- 'view_item' => esc_html__( 'View Testimonial', 'jetpack' ),
- 'search_items' => esc_html__( 'Search Testimonials', 'jetpack' ),
- 'not_found' => esc_html__( 'No Testimonials found', 'jetpack' ),
- 'not_found_in_trash' => esc_html__( 'No Testimonials found in Trash', 'jetpack' ),
- 'filter_items_list' => esc_html__( 'Filter Testimonials list', 'jetpack' ),
- 'items_list_navigation' => esc_html__( 'Testimonial list navigation', 'jetpack' ),
- 'items_list' => esc_html__( 'Testimonials list', 'jetpack' ),
- ),
- 'supports' => array(
- 'title',
- 'editor',
- 'thumbnail',
- 'page-attributes',
- 'revisions',
- 'excerpt',
- 'newspack_blocks',
- ),
- 'rewrite' => array(
- 'slug' => 'testimonial',
- 'with_front' => false,
- 'feeds' => false,
- 'pages' => true,
- ),
- 'public' => true,
- 'show_ui' => true,
- 'menu_position' => 20, // below Pages
- 'menu_icon' => 'dashicons-testimonial',
- 'capability_type' => 'page',
- 'map_meta_cap' => true,
- 'has_archive' => true,
- 'query_var' => 'testimonial',
- 'show_in_rest' => true,
- ) );
+ register_post_type(
+ self::CUSTOM_POST_TYPE,
+ array(
+ 'description' => __( 'Customer Testimonials', 'jetpack' ),
+ 'labels' => array(
+ 'name' => esc_html__( 'Testimonials', 'jetpack' ),
+ 'singular_name' => esc_html__( 'Testimonial', 'jetpack' ),
+ 'menu_name' => esc_html__( 'Testimonials', 'jetpack' ),
+ 'all_items' => esc_html__( 'All Testimonials', 'jetpack' ),
+ 'add_new' => esc_html__( 'Add New', 'jetpack' ),
+ 'add_new_item' => esc_html__( 'Add New Testimonial', 'jetpack' ),
+ 'edit_item' => esc_html__( 'Edit Testimonial', 'jetpack' ),
+ 'new_item' => esc_html__( 'New Testimonial', 'jetpack' ),
+ 'view_item' => esc_html__( 'View Testimonial', 'jetpack' ),
+ 'search_items' => esc_html__( 'Search Testimonials', 'jetpack' ),
+ 'not_found' => esc_html__( 'No Testimonials found', 'jetpack' ),
+ 'not_found_in_trash' => esc_html__( 'No Testimonials found in Trash', 'jetpack' ),
+ 'filter_items_list' => esc_html__( 'Filter Testimonials list', 'jetpack' ),
+ 'items_list_navigation' => esc_html__( 'Testimonial list navigation', 'jetpack' ),
+ 'items_list' => esc_html__( 'Testimonials list', 'jetpack' ),
+ ),
+ 'supports' => array(
+ 'title',
+ 'editor',
+ 'thumbnail',
+ 'page-attributes',
+ 'revisions',
+ 'excerpt',
+ 'newspack_blocks',
+ ),
+ 'rewrite' => array(
+ 'slug' => 'testimonial',
+ 'with_front' => false,
+ 'feeds' => false,
+ 'pages' => true,
+ ),
+ 'public' => true,
+ 'show_ui' => true,
+ 'menu_position' => 20, // below Pages
+ 'menu_icon' => 'dashicons-testimonial',
+ 'capability_type' => 'page',
+ 'map_meta_cap' => true,
+ 'has_archive' => true,
+ 'query_var' => 'testimonial',
+ 'show_in_rest' => true,
+ )
+ );
}
/**
* Update messages for the Testimonial admin.
+ *
+ * @param array $messages Existing post update messages.
+ * @return array Updated `$messages`.
*/
- function updated_messages( $messages ) {
+ public function updated_messages( $messages ) {
global $post;
$messages[ self::CUSTOM_POST_TYPE ] = array(
0 => '', // Unused. Messages start at index 1.
- 1 => sprintf( __( 'Testimonial updated. <a href="%s">View testimonial</a>', 'jetpack'), esc_url( get_permalink( $post->ID ) ) ),
+ 1 => sprintf(
+ /* Translators: link to Testimonial item's page. */
+ __( 'Testimonial updated. <a href="%s">View testimonial</a>', 'jetpack' ),
+ esc_url( get_permalink( $post->ID ) )
+ ),
2 => esc_html__( 'Custom field updated.', 'jetpack' ),
3 => esc_html__( 'Custom field deleted.', 'jetpack' ),
4 => esc_html__( 'Testimonial updated.', 'jetpack' ),
- /* translators: %s: date and time of the revision */
- 5 => isset( $_GET['revision'] ) ? sprintf( esc_html__( 'Testimonial restored to revision from %s', 'jetpack'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
- 6 => sprintf( __( 'Testimonial published. <a href="%s">View testimonial</a>', 'jetpack' ), esc_url( get_permalink( $post->ID ) ) ),
+ 5 => isset( $_GET['revision'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling.
+ ? sprintf(
+ /* translators: %s: date and time of the revision */
+ esc_html__( 'Testimonial restored to revision from %s', 'jetpack' ),
+ wp_post_revision_title( (int) $_GET['revision'], false ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling.
+ )
+ : false,
+ 6 => sprintf(
+ /* Translators: link to Testimonial item's page. */
+ __( 'Testimonial published. <a href="%s">View testimonial</a>', 'jetpack' ),
+ esc_url( get_permalink( $post->ID ) )
+ ),
7 => esc_html__( 'Testimonial saved.', 'jetpack' ),
- 8 => sprintf( __( 'Testimonial submitted. <a target="_blank" href="%s">Preview testimonial</a>', 'jetpack'), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ),
- 9 => sprintf( __( 'Testimonial scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview testimonial</a>', 'jetpack' ),
+ 8 => sprintf(
+ /* Translators: link to Testimonial item's page. */
+ __( 'Testimonial submitted. <a target="_blank" href="%s">Preview testimonial</a>', 'jetpack' ),
+ esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) )
+ ),
+ 9 => sprintf(
+ /* Translators: 1: Publishing date and time. 2. Link to testimonial's item page. */
+ __( 'Testimonial scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview testimonial</a>', 'jetpack' ),
// translators: Publish box date format, see https://php.net/date
- date_i18n( __( 'M j, Y @ G:i', 'jetpack' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ),
- 10 => sprintf( __( 'Testimonial draft updated. <a target="_blank" href="%s">Preview testimonial</a>', 'jetpack' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ),
+ date_i18n( __( 'M j, Y @ G:i', 'jetpack' ), strtotime( $post->post_date ) ),
+ esc_url( get_permalink( $post->ID ) )
+ ),
+ 10 => sprintf(
+ /* Translators: link to Testimonial item's page. */
+ __( 'Testimonial draft updated. <a target="_blank" href="%s">Preview testimonial</a>', 'jetpack' ),
+ esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) )
+ ),
);
return $messages;
@@ -362,9 +418,12 @@ class Jetpack_Testimonial {
/**
* Change ‘Enter Title Here’ text for the Testimonial.
+ *
+ * @param string $title Placeholder text. Default 'Add title'.
+ * @return string Replacement title.
*/
- function change_default_title( $title ) {
- if ( self::CUSTOM_POST_TYPE == get_post_type() ) {
+ public function change_default_title( $title ) {
+ if ( self::CUSTOM_POST_TYPE === get_post_type() ) {
$title = esc_html__( "Enter the customer's name here", 'jetpack' );
}
@@ -373,8 +432,11 @@ class Jetpack_Testimonial {
/**
* Change ‘Title’ column label on all Testimonials page.
+ *
+ * @param array $columns An array of column names.
+ * @return array Updated array.
*/
- function edit_title_column_label( $columns ) {
+ public function edit_title_column_label( $columns ) {
$columns['title'] = esc_html__( 'Customer Name', 'jetpack' );
return $columns;
@@ -382,8 +444,10 @@ class Jetpack_Testimonial {
/**
* Follow CPT reading setting on CPT archive page
+ *
+ * @param WP_Query $query A WP_Query instance.
*/
- function query_reading_setting( $query ) {
+ public function query_reading_setting( $query ) {
if ( ! is_admin()
&& $query->is_main_query()
&& $query->is_post_type_archive( self::CUSTOM_POST_TYPE )
@@ -392,14 +456,17 @@ class Jetpack_Testimonial {
}
}
- /*
+ /**
* If Infinite Scroll is set to 'click', use our custom reading setting instead of core's `posts_per_page`.
+ *
+ * @param array $settings Array of Infinite Scroll settings.
+ * @return array Updated `$settings`.
*/
- function infinite_scroll_click_posts_per_page( $settings ) {
+ public function infinite_scroll_click_posts_per_page( $settings ) {
global $wp_query;
if ( ! is_admin() && true === $settings['click_handle'] && $wp_query->is_post_type_archive( self::CUSTOM_POST_TYPE ) ) {
- $settings['posts_per_page'] = get_option( self::OPTION_READING_SETTING, $settings['posts_per_page'] );
+ $settings['posts_per_page'] = get_option( self::OPTION_READING_SETTING, $settings['posts_per_page'] ); // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
}
return $settings;
@@ -407,28 +474,29 @@ class Jetpack_Testimonial {
/**
* Add CPT to Dotcom sitemap
+ *
+ * @param array $post_types Array of post types included in sitemap.
+ * @return array Updated `$post_types`.
*/
- function add_to_sitemap( $post_types ) {
+ public function add_to_sitemap( $post_types ) {
$post_types[] = self::CUSTOM_POST_TYPE;
return $post_types;
}
- function set_testimonial_option() {
- $testimonials = wp_count_posts( self::CUSTOM_POST_TYPE );
- $published_testimonials = $testimonials->publish;
-
- update_option( self::OPTION_NAME, $published_testimonials );
- }
-
- function count_testimonials() {
+ /**
+ * Count the number of published testimonials.
+ *
+ * @return int
+ */
+ private function count_testimonials() {
$testimonials = get_transient( 'jetpack-testimonial-count-cache' );
if ( false === $testimonials ) {
$testimonials = (int) wp_count_posts( self::CUSTOM_POST_TYPE )->publish;
if ( ! empty( $testimonials ) ) {
- set_transient( 'jetpack-testimonial-count-cache', $testimonials, 60*60*12 );
+ set_transient( 'jetpack-testimonial-count-cache', $testimonials, 60 * 60 * 12 );
}
}
@@ -438,63 +506,95 @@ class Jetpack_Testimonial {
/**
* Adds a submenu link to the Customizer.
*/
- function add_customize_page() {
+ public function add_customize_page() {
add_submenu_page(
'edit.php?post_type=' . self::CUSTOM_POST_TYPE,
esc_html__( 'Customize Testimonials Archive', 'jetpack' ),
esc_html__( 'Customize', 'jetpack' ),
'edit_theme_options',
- add_query_arg( array(
- 'url' => urlencode( home_url( '/testimonial/' ) ),
- 'autofocus[section]' => 'jetpack_testimonials'
- ), 'customize.php' )
+ add_query_arg(
+ array(
+ 'url' => rawurlencode( home_url( '/testimonial/' ) ),
+ 'autofocus[section]' => 'jetpack_testimonials',
+ ),
+ 'customize.php'
+ )
);
}
/**
* Adds testimonial section to the Customizer.
+ *
+ * @param WP_Customize_Manager $wp_customize Customizer instance.
*/
- function customize_register( $wp_customize ) {
+ public function customize_register( $wp_customize ) {
jetpack_testimonial_custom_control_classes();
- $wp_customize->add_section( 'jetpack_testimonials', array(
- 'title' => esc_html__( 'Testimonials', 'jetpack' ),
- 'theme_supports' => self::CUSTOM_POST_TYPE,
- 'priority' => 130,
- ) );
-
- $wp_customize->add_setting( 'jetpack_testimonials[page-title]', array(
- 'default' => esc_html__( 'Testimonials', 'jetpack' ),
- 'sanitize_callback' => array( 'Jetpack_Testimonial_Title_Control', 'sanitize_content' ),
- 'sanitize_js_callback' => array( 'Jetpack_Testimonial_Title_Control', 'sanitize_content' ),
- ) );
- $wp_customize->add_control( 'jetpack_testimonials[page-title]', array(
- 'section' => 'jetpack_testimonials',
- 'label' => esc_html__( 'Testimonial Archive Title', 'jetpack' ),
- 'type' => 'text',
- ) );
-
- $wp_customize->add_setting( 'jetpack_testimonials[page-content]', array(
- 'default' => '',
- 'sanitize_callback' => array( 'Jetpack_Testimonial_Textarea_Control', 'sanitize_content' ),
- 'sanitize_js_callback' => array( 'Jetpack_Testimonial_Textarea_Control', 'sanitize_content' ),
- ) );
- $wp_customize->add_control( new Jetpack_Testimonial_Textarea_Control( $wp_customize, 'jetpack_testimonials[page-content]', array(
- 'section' => 'jetpack_testimonials',
- 'settings' => 'jetpack_testimonials[page-content]',
- 'label' => esc_html__( 'Testimonial Archive Content', 'jetpack' ),
- ) ) );
-
- $wp_customize->add_setting( 'jetpack_testimonials[featured-image]', array(
- 'default' => '',
- 'sanitize_callback' => 'attachment_url_to_postid',
- 'sanitize_js_callback' => 'attachment_url_to_postid',
- 'theme_supports' => 'post-thumbnails',
- ) );
- $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'jetpack_testimonials[featured-image]', array(
- 'section' => 'jetpack_testimonials',
- 'label' => esc_html__( 'Testimonial Archive Featured Image', 'jetpack' ),
- ) ) );
+ $wp_customize->add_section(
+ 'jetpack_testimonials',
+ array(
+ 'title' => esc_html__( 'Testimonials', 'jetpack' ),
+ 'theme_supports' => self::CUSTOM_POST_TYPE,
+ 'priority' => 130,
+ )
+ );
+
+ $wp_customize->add_setting(
+ 'jetpack_testimonials[page-title]',
+ array(
+ 'default' => esc_html__( 'Testimonials', 'jetpack' ),
+ 'sanitize_callback' => array( 'Jetpack_Testimonial_Title_Control', 'sanitize_content' ),
+ 'sanitize_js_callback' => array( 'Jetpack_Testimonial_Title_Control', 'sanitize_content' ),
+ )
+ );
+ $wp_customize->add_control(
+ 'jetpack_testimonials[page-title]',
+ array(
+ 'section' => 'jetpack_testimonials',
+ 'label' => esc_html__( 'Testimonial Archive Title', 'jetpack' ),
+ 'type' => 'text',
+ )
+ );
+
+ $wp_customize->add_setting(
+ 'jetpack_testimonials[page-content]',
+ array(
+ 'default' => '',
+ 'sanitize_callback' => array( 'Jetpack_Testimonial_Textarea_Control', 'sanitize_content' ),
+ 'sanitize_js_callback' => array( 'Jetpack_Testimonial_Textarea_Control', 'sanitize_content' ),
+ )
+ );
+ $wp_customize->add_control(
+ new Jetpack_Testimonial_Textarea_Control(
+ $wp_customize,
+ 'jetpack_testimonials[page-content]',
+ array(
+ 'section' => 'jetpack_testimonials',
+ 'settings' => 'jetpack_testimonials[page-content]',
+ 'label' => esc_html__( 'Testimonial Archive Content', 'jetpack' ),
+ )
+ )
+ );
+
+ $wp_customize->add_setting(
+ 'jetpack_testimonials[featured-image]',
+ array(
+ 'default' => '',
+ 'sanitize_callback' => 'attachment_url_to_postid',
+ 'sanitize_js_callback' => 'attachment_url_to_postid',
+ 'theme_supports' => 'post-thumbnails',
+ )
+ );
+ $wp_customize->add_control(
+ new WP_Customize_Image_Control(
+ $wp_customize,
+ 'jetpack_testimonials[featured-image]',
+ array(
+ 'section' => 'jetpack_testimonials',
+ 'label' => esc_html__( 'Testimonial Archive Featured Image', 'jetpack' ),
+ )
+ )
+ );
// The featured image control doesn't display properly in the Customizer unless we coerce
// it back into a URL sooner, since that's what WP_Customize_Upload_Control::to_json() expects
@@ -503,6 +603,12 @@ class Jetpack_Testimonial {
}
}
+ /**
+ * Add Featured image to theme mod if necessary.
+ *
+ * @param array $opt The value of the current theme modification.
+ * @return array Updated `$opt`.
+ */
public function coerce_testimonial_image_to_url( $opt ) {
if ( ! $opt || ! is_array( $opt ) ) {
return $opt;
@@ -521,25 +627,35 @@ class Jetpack_Testimonial {
* Our [testimonial] shortcode.
* Prints Testimonial data styled to look good on *any* theme.
*
- * @return jetpack_testimonial_shortcode_html
- */
- static function jetpack_testimonial_shortcode( $atts ) {
- // Default attributes
- $atts = shortcode_atts( array(
- 'display_content' => true,
- 'image' => true,
- 'columns' => 1,
- 'showposts' => -1,
- 'order' => 'asc',
- 'orderby' => 'menu_order,date',
- ), $atts, 'testimonial' );
-
- // A little sanitization
- if ( $atts['display_content'] && 'true' != $atts['display_content'] && 'full' != $atts['display_content'] ) {
+ * @param array $atts Shortcode attributes.
+ *
+ * @return string HTML from `self::jetpack_testimonial_shortcode_html()`.
+ */
+ public static function jetpack_testimonial_shortcode( $atts ) {
+ // Default attributes.
+ $atts = shortcode_atts(
+ array(
+ 'display_content' => true, // Can be false, true, or full.
+ 'image' => true,
+ 'columns' => 1,
+ 'showposts' => -1,
+ 'order' => 'asc',
+ 'orderby' => 'menu_order,date',
+ ),
+ $atts,
+ 'testimonial'
+ );
+
+ // A little sanitization.
+ if (
+ $atts['display_content']
+ && 'true' != $atts['display_content'] // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
+ && 'full' !== $atts['display_content']
+ ) {
$atts['display_content'] = false;
}
- if ( $atts['image'] && 'true' != $atts['image'] ) {
+ if ( $atts['image'] && 'true' != $atts['image'] ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
$atts['image'] = false;
}
@@ -550,7 +666,7 @@ class Jetpack_Testimonial {
if ( $atts['order'] ) {
$atts['order'] = urldecode( $atts['order'] );
$atts['order'] = strtoupper( $atts['order'] );
- if ( 'DESC' != $atts['order'] ) {
+ if ( 'DESC' !== $atts['order'] ) {
$atts['order'] = 'ASC';
}
}
@@ -558,18 +674,18 @@ class Jetpack_Testimonial {
if ( $atts['orderby'] ) {
$atts['orderby'] = urldecode( $atts['orderby'] );
$atts['orderby'] = strtolower( $atts['orderby'] );
- $allowed_keys = array( 'author', 'date', 'title', 'menu_order', 'rand' );
+ $allowed_keys = array( 'author', 'date', 'title', 'menu_order', 'rand' );
$parsed = array();
- foreach ( explode( ',', $atts['orderby'] ) as $testimonial_index_number => $orderby ) {
- if ( ! in_array( $orderby, $allowed_keys ) ) {
+ foreach ( explode( ',', $atts['orderby'] ) as $orderby ) {
+ if ( ! in_array( $orderby, $allowed_keys, true ) ) {
continue;
}
$parsed[] = $orderby;
}
if ( empty( $parsed ) ) {
- unset($atts['orderby']);
+ unset( $atts['orderby'] );
} else {
$atts['orderby'] = implode( ' ', $parsed );
}
@@ -586,9 +702,11 @@ class Jetpack_Testimonial {
/**
* The Testimonial shortcode loop.
*
- * @return html
+ * @param array $atts Shortcode attributes.
+ *
+ * @return string html
*/
- static function jetpack_testimonial_shortcode_html( $atts ) {
+ private static function jetpack_testimonial_shortcode_html( $atts ) {
// Default query arguments
$defaults = array(
'order' => $atts['order'],
@@ -596,9 +714,9 @@ class Jetpack_Testimonial {
'posts_per_page' => $atts['showposts'],
);
- $args = wp_parse_args( $atts, $defaults );
+ $args = wp_parse_args( $atts, $defaults );
$args['post_type'] = self::CUSTOM_POST_TYPE; // Force this post type
- $query = new WP_Query( $args );
+ $query = new WP_Query( $args );
$testimonial_index_number = 0;
@@ -609,8 +727,7 @@ class Jetpack_Testimonial {
?>
<div class="jetpack-testimonial-shortcode column-<?php echo esc_attr( $atts['columns'] ); ?>">
- <?php // open .jetpack-testimonial-shortcode
-
+ <?php
// Construct the loop...
while ( $query->have_posts() ) {
$query->the_post();
@@ -621,21 +738,21 @@ class Jetpack_Testimonial {
// The content
if ( false !== $atts['display_content'] ) {
if ( 'full' === $atts['display_content'] ) {
- ?>
+ ?>
<div class="testimonial-entry-content"><?php the_content(); ?></div>
- <?php
+ <?php
} else {
- ?>
+ ?>
<div class="testimonial-entry-content"><?php the_excerpt(); ?></div>
- <?php
+ <?php
}
}
?>
- <span class="testimonial-entry-title">&#8213; <a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php echo esc_attr( the_title_attribute( ) ); ?>"><?php the_title(); ?></a></span>
+ <span class="testimonial-entry-title">&#8213; <a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php echo esc_attr( the_title_attribute() ); ?>"><?php the_title(); ?></a></span>
<?php
// Featured image
if ( false !== $atts['image'] ) :
- echo self::get_testimonial_thumbnail_link( $post_id );
+ echo self::get_testimonial_thumbnail_link( $post_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in method.
endif;
?>
</div><!-- close .testimonial-entry -->
@@ -646,10 +763,11 @@ class Jetpack_Testimonial {
wp_reset_postdata();
?>
</div><!-- close .jetpack-testimonial-shortcode -->
- <?php
- } else { ?>
- <p><em><?php _e( 'Your Testimonial Archive currently has no entries. You can start creating them on your dashboard.', 'jetpack' ); ?></p></em>
- <?php
+ <?php
+ } else {
+ ?>
+ <p><em><?php esc_html_e( 'Your Testimonial Archive currently has no entries. You can start creating them on your dashboard.', 'jetpack' ); ?></p></em>
+ <?php
}
$html = ob_get_clean();
@@ -660,15 +778,19 @@ class Jetpack_Testimonial {
/**
* Individual testimonial class
*
+ * @param int $testimonial_index_number iterator count the number of columns up starting from 0.
+ * @param int $columns number of columns to display the content in.
+ * @param bool $image has a thumbnail or not.
+ *
* @return string
*/
- static function get_testimonial_class( $testimonial_index_number, $columns, $image ) {
+ private static function get_testimonial_class( $testimonial_index_number, $columns, $image ) {
$class = array();
- $class[] = 'testimonial-entry-column-'.$columns;
+ $class[] = 'testimonial-entry-column-' . $columns;
- if( $columns > 1) {
- if ( ( $testimonial_index_number % 2 ) == 0 ) {
+ if ( $columns > 1 ) {
+ if ( ( $testimonial_index_number % 2 ) === 0 ) {
$class[] = 'testimonial-entry-mobile-first-item-row';
} else {
$class[] = 'testimonial-entry-mobile-last-item-row';
@@ -676,9 +798,9 @@ class Jetpack_Testimonial {
}
// add first and last classes to first and last items in a row
- if ( ( $testimonial_index_number % $columns ) == 0 ) {
+ if ( ( $testimonial_index_number % $columns ) === 0 ) {
$class[] = 'testimonial-entry-first-item-row';
- } elseif ( ( $testimonial_index_number % $columns ) == ( $columns - 1 ) ) {
+ } elseif ( ( $testimonial_index_number % $columns ) === ( $columns - 1 ) ) {
$class[] = 'testimonial-entry-last-item-row';
}
@@ -698,17 +820,18 @@ class Jetpack_Testimonial {
* @param int $testimonial_index_number iterator count the number of columns up starting from 0.
* @param int $columns number of columns to display the content in.
* @param boolean $image has a thumbnail or not.
- *
*/
- return apply_filters( 'testimonial-entry-post-class', implode( " ", $class ) , $testimonial_index_number, $columns, $image );
+ return apply_filters( 'testimonial-entry-post-class', implode( ' ', $class ), $testimonial_index_number, $columns, $image ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
}
/**
* Display the featured image if it's available
*
- * @return html
+ * @param int $post_id Post ID.
+ *
+ * @return string html
*/
- static function get_testimonial_thumbnail_link( $post_id ) {
+ private static function get_testimonial_thumbnail_link( $post_id ) {
if ( has_post_thumbnail( $post_id ) ) {
/**
* Change the thumbnail size for the Testimonial CPT.
@@ -724,32 +847,63 @@ class Jetpack_Testimonial {
}
}
+/**
+ * Additional Testimonial customizer options.
+ */
function jetpack_testimonial_custom_control_classes() {
+ /**
+ * Clean the title parameter.
+ */
class Jetpack_Testimonial_Title_Control extends WP_Customize_Control {
+ /**
+ * Sanitize content passed to control.
+ *
+ * @param string $value Control value.
+ * @return string Sanitized value.
+ */
public static function sanitize_content( $value ) {
- if ( '' != $value )
+ if ( '' != $value ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
$value = trim( convert_chars( wptexturize( $value ) ) );
+ }
return $value;
}
}
+ /**
+ * Clean textarea content.
+ */
class Jetpack_Testimonial_Textarea_Control extends WP_Customize_Control {
+ /**
+ * Control type.
+ *
+ * @var string
+ */
public $type = 'textarea';
+ /**
+ * Render the control's content.
+ */
public function render_content() {
?>
<label>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<textarea rows="5" style="width:100%;" <?php $this->link(); ?>><?php echo esc_textarea( $this->value() ); ?></textarea>
</label>
- <?php
+ <?php
}
+ /**
+ * Sanitize content passed to control.
+ *
+ * @param string $value Control value.
+ * @return string Sanitized value.
+ */
public static function sanitize_content( $value ) {
- if ( ! empty( $value ) )
+ if ( ! empty( $value ) ) {
/** This filter is already documented in core. wp-includes/post-template.php */
$value = apply_filters( 'the_content', $value );
+ }
$value = preg_replace( '@<div id="jp-post-flair"([^>]+)?>(.+)?</div>@is', '', $value ); // Strip WPCOM and Jetpack post flair if included in content
@@ -761,5 +915,5 @@ function jetpack_testimonial_custom_control_classes() {
add_action( 'init', array( 'Jetpack_Testimonial', 'init' ) );
// Check on plugin activation if theme supports CPT
-register_activation_hook( __FILE__, array( 'Jetpack_Testimonial', 'activation_post_type_support' ) );
+register_activation_hook( __FILE__, array( 'Jetpack_Testimonial', 'activation_post_type_support' ) );
add_action( 'jetpack_activate_module_custom-content-types', array( 'Jetpack_Testimonial', 'activation_post_type_support' ) );
diff --git a/plugins/jetpack/modules/enhanced-distribution.php b/plugins/jetpack/modules/enhanced-distribution.php
index 43c7f31d..85e7772a 100644
--- a/plugins/jetpack/modules/enhanced-distribution.php
+++ b/plugins/jetpack/modules/enhanced-distribution.php
@@ -9,11 +9,15 @@
* Module Tags: Writing
* Feature: Engagement
* Additional Search Queries: google, seo, firehose, search, broadcast, broadcasting
+ *
+ * @package automattic/jetpack
*/
-// In case it's active prior to upgrading to 1.9
+/**
+ * In case it's active prior to upgrading to '1.9'.
+ */
function jetpack_enhanced_distribution_before_activate_default_modules() {
- $old_version = Jetpack_Options::get_option( 'old_version' );
+ $old_version = Jetpack_Options::get_option( 'old_version' );
list( $old_version ) = explode( ':', $old_version );
if ( version_compare( $old_version, '1.9-something', '>=' ) ) {
@@ -25,43 +29,53 @@ function jetpack_enhanced_distribution_before_activate_default_modules() {
add_action( 'jetpack_before_activate_default_modules', 'jetpack_enhanced_distribution_before_activate_default_modules' );
-/**
- * If a request has ?get_freshly_pressed_data=true appended
- * to the end, then let's provide the necessary data back via JSON.
- */
-if ( isset( $_GET['get_freshly_pressed_data'] ) ) {
- add_action( 'template_redirect', 'jetpack_get_freshly_pressed_data' );
+if ( isset( $_GET['get_freshly_pressed_data'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ /**
+ * If a request has ?get_freshly_pressed_data=true appended
+ * to the end, then let's provide the necessary data back via JSON.
+ */
function jetpack_get_freshly_pressed_data() {
if ( is_single() ) {
- wp_send_json_success( array(
- 'blog_id' => Jetpack_Options::get_option( 'id' ),
- 'post_id' => get_the_ID(),
- ) );
+ wp_send_json_success(
+ array(
+ 'blog_id' => Jetpack_Options::get_option( 'id' ),
+ 'post_id' => get_the_ID(),
+ )
+ );
} else {
- wp_send_json_error( array(
- 'message' => 'Not Singular',
- ) );
+ wp_send_json_error(
+ array(
+ 'message' => 'Not Singular',
+ )
+ );
}
}
+ add_action( 'template_redirect', 'jetpack_get_freshly_pressed_data' );
}
-add_action( 'rss_head', 'jetpack_enhanced_distribution_feed_id' );
-add_action( 'rss_item', 'jetpack_enhanced_distribution_post_id' );
+add_action( 'rss_head', 'jetpack_enhanced_distribution_feed_id' );
+add_action( 'rss_item', 'jetpack_enhanced_distribution_post_id' );
add_action( 'rss2_head', 'jetpack_enhanced_distribution_feed_id' );
add_action( 'rss2_item', 'jetpack_enhanced_distribution_post_id' );
-function jetpack_enhanced_distribution_feed_id(){
- (int) $id = Jetpack_Options::get_option( 'id' );
+/**
+ * Output feed identifier based on blog ID.
+ */
+function jetpack_enhanced_distribution_feed_id() {
+ $id = (int) Jetpack_Options::get_option( 'id' );
if ( $id > 0 ) {
$output = sprintf( '<site xmlns="com-wordpress:feed-additions:1">%d</site>', $id );
- echo $output;
+ echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
-function jetpack_enhanced_distribution_post_id(){
- $id = get_the_ID();
+/**
+ * Output feed item identifier based on current post ID.
+ */
+function jetpack_enhanced_distribution_post_id() {
+ $id = (int) get_the_ID();
if ( $id ) {
$output = sprintf( '<post-id xmlns="com-wordpress:feed-additions:1">%d</post-id>', $id );
- echo $output;
+ echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
diff --git a/plugins/jetpack/modules/geo-location.php b/plugins/jetpack/modules/geo-location.php
index 4d3e255c..59fb2c0d 100644
--- a/plugins/jetpack/modules/geo-location.php
+++ b/plugins/jetpack/modules/geo-location.php
@@ -1,22 +1,38 @@
<?php
+/**
+ * Module: geo-location
+ *
+ * @package automattic/jetpack
+ */
+
+/**
+ * Adds support for geo-location features.
+ */
-require_once dirname( __FILE__ ) . '/geo-location/class.jetpack-geo-location.php';
+require_once __DIR__ . '/geo-location/class.jetpack-geo-location.php';
/**
- * Geo-location shortcode for display of location data associated with a post.
+ * Geo-location shortcode callback for display of location data associated with a post.
*
* Usage with current global $post:
* [geo-location]
*
* Usage with specific post ID:
* [geo-location post=5]
+ *
+ * @param array $attributes Shortcode attributes.
*/
-add_shortcode( 'geo-location', 'jetpack_geo_shortcode' );
-
function jetpack_geo_shortcode( $attributes ) {
- $attributes = shortcode_atts( array( 'post' => null, 'id' => null ), $attributes );
+ $attributes = shortcode_atts(
+ array(
+ 'post' => null,
+ 'id' => null,
+ ),
+ $attributes
+ );
return jetpack_geo_get_location( $attributes['post'] ? $attributes['post'] : $attributes['id'] );
}
+add_shortcode( 'geo-location', 'jetpack_geo_shortcode' );
/**
* Get the geo-location data associated with the supplied post ID, if it's available
@@ -26,11 +42,11 @@ function jetpack_geo_shortcode( $attributes ) {
* If you do not supply a value for $post_id, the global $post will be used, if
* available.
*
- * @param integer|null $post_id
+ * @param integer|null $post_id Post ID.
*
* @return array|null
*/
-function jetpack_geo_get_data( $post_id = null) {
+function jetpack_geo_get_data( $post_id = null ) {
$geo = Jetpack_Geo_Location::init();
if ( ! $post_id ) {
@@ -46,7 +62,7 @@ function jetpack_geo_get_data( $post_id = null) {
return array(
'latitude' => $meta_values['latitude'],
'longitude' => $meta_values['longitude'],
- 'label' => $meta_values['label']
+ 'label' => $meta_values['label'],
);
}
@@ -57,12 +73,12 @@ function jetpack_geo_get_data( $post_id = null) {
* If you do not supply a value for $post_id, the global $post will be used, if
* available.
*
- * @param integer|null $post_id
+ * @param integer|null $post_id Post ID.
*
* @return void
*/
function jetpack_geo_display_location( $post_id = null ) {
- echo jetpack_geo_get_location( $post_id );
+ echo jetpack_geo_get_location( $post_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in `Jetpack_Geo_Location::get_location_label`.
}
/**
@@ -72,7 +88,7 @@ function jetpack_geo_display_location( $post_id = null ) {
* If you do not supply a value for $post_id, the global $post will be used, if
* available.
*
- * @param integer|null $post_id
+ * @param integer|null $post_id Post ID.
*
* @return string
*/
diff --git a/plugins/jetpack/modules/geo-location/class.jetpack-geo-location.php b/plugins/jetpack/modules/geo-location/class.jetpack-geo-location.php
index c16ce422..17f56433 100644
--- a/plugins/jetpack/modules/geo-location/class.jetpack-geo-location.php
+++ b/plugins/jetpack/modules/geo-location/class.jetpack-geo-location.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Adds support for geo-location features.
@@ -31,6 +31,11 @@
* add_filter( 'jetpack_geo_location_display', 'your_filter_function_name', 10, 2);
*/
class Jetpack_Geo_Location {
+ /**
+ * Jetpack_Geo_Location singleton instance.
+ *
+ * @var Jetpack_Geo_Location|null
+ */
private static $instance;
/**
@@ -42,8 +47,11 @@ class Jetpack_Geo_Location {
*/
private static $style_enqueued = false;
+ /**
+ * Jetpack_Geo_Location instance init.
+ */
public static function init() {
- if ( is_null( self::$instance ) ) {
+ if ( self::$instance === null ) {
self::$instance = new Jetpack_Geo_Location();
}
@@ -57,6 +65,9 @@ class Jetpack_Geo_Location {
self::$instance = null;
}
+ /**
+ * Jetpack_Geo_Location class constructor.
+ */
public function __construct() {
add_action( 'init', array( $this, 'wordpress_init' ) );
add_action( 'wp_head', array( $this, 'wp_head' ) );
@@ -122,7 +133,7 @@ class Jetpack_Geo_Location {
/**
* Filter "public" input to always be either 1 or 0.
*
- * @param mixed $public
+ * @param mixed $public Value to normalize.
*
* @return int
*/
@@ -133,7 +144,7 @@ class Jetpack_Geo_Location {
/**
* Filter geo coordinates and normalize them to floats with 7 digits of precision.
*
- * @param mixed $coordinate
+ * @param mixed $coordinate Latitude or longitude coordinate.
*
* @return float|null
*/
@@ -197,7 +208,7 @@ class Jetpack_Geo_Location {
* Note that we cannot render the microformat in the context of an excerpt because tags are stripped
* in that context, making our microformat data visible.
*
- * @param string $content
+ * @param string $content Current post content.
*
* @return string
*/
@@ -286,7 +297,7 @@ class Jetpack_Geo_Location {
* If we're rendering a single post and public geo-location data is available for it,
* include the human-friendly location label in the output.
*
- * @param string $content
+ * @param string $content Current post content.
*
* @return string
*/
@@ -303,7 +314,7 @@ class Jetpack_Geo_Location {
* supplied post ID. If no post ID is given, we'll use the global $post variable, if
* it is available.
*
- * @param integer|null $post_id
+ * @param integer|null $post_id Post ID.
*
* @return string
*/
@@ -356,6 +367,8 @@ class Jetpack_Geo_Location {
}
/**
+ * Retrieve geo-location post_meta data for the specified post ID.
+ *
* This method always returns an array with the following structure:
*
* array(is_public => bool, latitude => float, longitude => float, label => string, is_populated => bool)
@@ -367,7 +380,7 @@ class Jetpack_Geo_Location {
* Mocking this method during testing can also be useful for testing output and logic in various
* hook functions.
*
- * @param integer $post_id
+ * @param integer $post_id Post ID.
*
* @return array A predictably structured array representing the meta values for the supplied post ID.
*/
@@ -391,8 +404,8 @@ class Jetpack_Geo_Location {
* This function wraps get_post_meta() to enable us to keep the "geo_" prefix isolated to a single
* location in the code and to assist in mocking during testing.
*
- * @param integer $post_id
- * @param string $meta_field_name
+ * @param integer $post_id Post ID.
+ * @param string $meta_field_name The meta field to retrieve.
*
* @return mixed
*/
diff --git a/plugins/jetpack/modules/google-analytics.php b/plugins/jetpack/modules/google-analytics.php
index 0a606327..bd62094d 100644
--- a/plugins/jetpack/modules/google-analytics.php
+++ b/plugins/jetpack/modules/google-analytics.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Module Name: Google Analytics
* Module Description: Set up Google Analytics without touching a line of code.
@@ -10,6 +9,9 @@
* Feature: Engagement
* Additional Search Queries: webmaster, google, analytics, console
* Plans: business, premium, security, complete
+ *
+ * @package automattic/jetpack
*/
-include dirname( __FILE__ ) . "/google-analytics/wp-google-analytics.php";
+// Load main Jetpack_Google_Analytics class.
+require __DIR__ . '/google-analytics/wp-google-analytics.php';
diff --git a/plugins/jetpack/modules/google-analytics/classes/class-jetpack-google-amp-analytics.php b/plugins/jetpack/modules/google-analytics/classes/class-jetpack-google-amp-analytics.php
index daa369b1..896f194b 100644
--- a/plugins/jetpack/modules/google-analytics/classes/class-jetpack-google-amp-analytics.php
+++ b/plugins/jetpack/modules/google-analytics/classes/class-jetpack-google-amp-analytics.php
@@ -118,7 +118,7 @@ class Jetpack_Google_AMP_Analytics {
* Send the stored events to GA.
*/
public function amp_send_ga_events() {
- if ( 'GET' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
+ if ( ! isset( $_SERVER['REQUEST_METHOD'] ) || 'GET' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- Simple comparison
return;
}
diff --git a/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-legacy.php b/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-legacy.php
index f78040b1..e86a3bc8 100644
--- a/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-legacy.php
+++ b/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-legacy.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Jetpack_Google_Analytics_Legacy hooks and enqueues support for ga.js
@@ -15,7 +15,13 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
+/**
+ * Jetpack_Google_Analytics_Legacy hooks and enqueues support for ga.js
+ */
class Jetpack_Google_Analytics_Legacy {
+ /**
+ * Jetpack_Google_Analytics_Legacy constructor.
+ */
public function __construct() {
add_filter( 'jetpack_wga_classic_custom_vars', array( $this, 'jetpack_wga_classic_anonymize_ip' ) );
add_filter( 'jetpack_wga_classic_custom_vars', array( $this, 'jetpack_wga_classic_track_purchases' ) );
@@ -30,8 +36,8 @@ class Jetpack_Google_Analytics_Legacy {
* @param array $track - Must have ['data'] and ['code'].
* @return string - Tracking URL
*/
- private function _get_url( $track ) {
- $site_url = ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ); // Input var okay.
+ private function get_url( $track ) {
+ $site_url = ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( wp_unslash( isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '' ) );
foreach ( $track as $k => $value ) {
if ( strpos( strtolower( $value ), strtolower( $site_url ) ) === 0 ) {
$track[ $k ] = substr( $track[ $k ], strlen( $site_url ) );
@@ -50,7 +56,7 @@ class Jetpack_Google_Analytics_Legacy {
$track[ $k ] = trim( $track[ $k ], '_' );
}
$char = ( strpos( $track['data'], '?' ) === false ) ? '?' : '&amp;';
- return str_replace( "'", "\'", "/{$track['code']}/{$track['data']}{$char}referer=" . rawurlencode( isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '' ) ); // Input var okay.
+ return str_replace( "'", "\'", "/{$track['code']}/{$track['data']}{$char}referer=" . rawurlencode( isset( $_SERVER['HTTP_REFERER'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '' ) );
}
/**
@@ -100,15 +106,15 @@ class Jetpack_Google_Analytics_Legacy {
$custom_vars[] = "_gaq.push(['_trackEvent', '404', document.location.href, document.referrer]);";
} elseif (
is_search()
- && isset( $_REQUEST['s'] )
+ && isset( $_REQUEST['s'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Function renders client-side JS, no site actions.
) {
// Set track for searches, if it's a search, and we are supposed to.
- $track['data'] = sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ); // Input var okay.
+ $track['data'] = sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Function renders client-side JS, no site actions.
$track['code'] = 'search';
}
if ( ! empty( $track ) ) {
- $track['url'] = $this->_get_url( $track );
+ $track['url'] = $this->get_url( $track );
// adjust the code that we output, account for both types of tracking.
$track['url'] = esc_js( str_replace( '&', '&amp;', $track['url'] ) );
$custom_vars[] = "_gaq.push(['_trackPageview','{$track['url']}']);";
@@ -138,7 +144,7 @@ class Jetpack_Google_Analytics_Legacy {
})();
</script>
<!-- End Jetpack Google Analytics -->\r\n",
- implode( "\r\n", $custom_vars )
+ implode( "\r\n", $custom_vars ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Additional elements added to the classic Google Analytics script.
);
}
@@ -194,8 +200,8 @@ class Jetpack_Google_Analytics_Legacy {
* Used to filter in the anonymize IP snippet to the custom vars array for classic analytics
* Ref https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApi_gat#_gat._anonymizelp
*
- * @param array custom vars to be filtered
- * @return array possibly updated custom vars
+ * @param array $custom_vars Custom vars to be filtered.
+ * @return array Possibly updated custom vars.
*/
public function jetpack_wga_classic_anonymize_ip( $custom_vars ) {
if ( Jetpack_Google_Analytics_Options::anonymize_ip_is_enabled() ) {
@@ -208,8 +214,8 @@ class Jetpack_Google_Analytics_Legacy {
/**
* Used to filter in the order details to the custom vars array for classic analytics
*
- * @param array custom vars to be filtered
- * @return array possibly updated custom vars
+ * @param array $custom_vars Custom vars to be filtered.
+ * @return array Possibly updated custom vars.
*/
public function jetpack_wga_classic_track_purchases( $custom_vars ) {
global $wp;
@@ -230,15 +236,17 @@ class Jetpack_Google_Analytics_Legacy {
$minimum_woocommerce_active = class_exists( 'WooCommerce' ) && version_compare( WC_VERSION, '3.0', '>=' );
if ( $minimum_woocommerce_active && is_order_received_page() ) {
$order_id = isset( $wp->query_vars['order-received'] ) ? $wp->query_vars['order-received'] : 0;
- if ( 0 < $order_id && 1 != get_post_meta( $order_id, '_ga_tracked', true ) ) {
+ if ( 0 < $order_id && 1 !== (int) get_post_meta( $order_id, '_ga_tracked', true ) ) {
$order = new WC_Order( $order_id );
- // [ '_add_Trans', '123', 'Site Title', '21.00', '1.00', '5.00', 'Snohomish', 'WA', 'USA' ]
+ /**
+ * [ '_add_Trans', '123', 'Site Title', '21.00', '1.00', '5.00', 'Snohomish', 'WA', 'USA' ]
+ */
array_push(
$custom_vars,
sprintf(
'_gaq.push( %s );',
- json_encode(
+ wp_json_encode(
array(
'_addTrans',
(string) $order->get_order_number(),
@@ -264,7 +272,7 @@ class Jetpack_Google_Analytics_Legacy {
$custom_vars,
sprintf(
'_gaq.push( %s );',
- json_encode(
+ wp_json_encode(
array(
'_addItem',
(string) $order->get_order_number(),
@@ -308,7 +316,7 @@ class Jetpack_Google_Analytics_Legacy {
if ( is_product() ) { // product page
global $product;
- $product_sku_or_id = $product->get_sku() ? $product->get_sku() : '#' + $product->get_id();
+ $product_sku_or_id = $product->get_sku() ? $product->get_sku() : '#' . $product->get_id();
wc_enqueue_js(
"$( '.single_add_to_cart_button' ).click( function() {
_gaq.push(['_trackEvent', 'Products', 'Add to Cart', '#" . esc_js( $product_sku_or_id ) . "']);
diff --git a/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-options.php b/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-options.php
index b6e208b7..e84ab748 100644
--- a/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-options.php
+++ b/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-options.php
@@ -1,70 +1,130 @@
-<?php
-
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileNames
/**
-* Jetpack_Google_Analytics_Options provides a single interface to module options
-*
-* @author allendav
-*/
+ * Jetpack_Google_Analytics_Options provides a single interface to module options
+ *
+ * @author allendav
+ */
/**
-* Bail if accessed directly
-*/
+ * Bail if accessed directly
+ */
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
+/**
+ * Jetpack_Google_Analytics_Options main class.
+ */
class Jetpack_Google_Analytics_Options {
+ /**
+ * Get the Google Analytics tracking ID.
+ *
+ * @param string $option_name Nested 'jetpack_wga' option value to retrieve.
+ * @param mixed $default Default value if $option is not set.
+ * @return mixed Option value or `$default`.
+ */
public static function get_option( $option_name, $default = false ) {
$o = get_option( 'jetpack_wga' );
return isset( $o[ $option_name ] ) ? $o[ $option_name ] : $default;
}
+ /**
+ * Get the analytics tracking code.
+ *
+ * @return string
+ */
public static function get_tracking_code() {
return self::get_option( 'code', '' );
}
+ /**
+ * Check if the tracking code is set.
+ *
+ * @return bool
+ */
public static function has_tracking_code() {
$code = self::get_tracking_code();
return ! empty( $code );
}
- // Options used by both legacy and universal analytics
+ /**
+ * Get the 'anonymize_ip' option used by both legacy and universal analytics.
+ *
+ * @return bool
+ */
public static function anonymize_ip_is_enabled() {
- return self::get_option( 'anonymize_ip' );
+ return (bool) self::get_option( 'anonymize_ip' );
}
- // eCommerce options used by both legacy and universal analytics
+ /**
+ * Get the 'ec_track_purchases' eCommerce option used by both legacy and universal analytics
+ *
+ * @return bool
+ */
public static function track_purchases_is_enabled() {
- return self::get_option( 'ec_track_purchases' );
+ return (bool) self::get_option( 'ec_track_purchases' );
}
+ /**
+ * Get the 'ec_track_add_to_cart' analytics option.
+ *
+ * @return bool
+ */
public static function track_add_to_cart_is_enabled() {
- return self::get_option( 'ec_track_add_to_cart' );
+ return (bool) self::get_option( 'ec_track_add_to_cart' );
}
- // Enhanced eCommerce options
+ /**
+ * Get the 'enh_ec_tracking' analytics option.
+ *
+ * @return bool
+ */
public static function enhanced_ecommerce_tracking_is_enabled() {
- return self::get_option( 'enh_ec_tracking' );
+ return (bool) self::get_option( 'enh_ec_tracking' );
}
+ /**
+ * Get the 'enh_ec_track_remove_from_cart' analytics option.
+ *
+ * @return bool
+ */
public static function track_remove_from_cart_is_enabled() {
- return self::get_option( 'enh_ec_track_remove_from_cart' );
+ return (bool) self::get_option( 'enh_ec_track_remove_from_cart' );
}
+ /**
+ * Get the 'enh_ec_track_prod_impression' analytics option.
+ *
+ * @return bool
+ */
public static function track_product_impressions_is_enabled() {
- return self::get_option( 'enh_ec_track_prod_impression' );
+ return (bool) self::get_option( 'enh_ec_track_prod_impression' );
}
+ /**
+ * Get the 'enh_ec_track_prod_click' analytics option.
+ *
+ * @return bool
+ */
public static function track_product_clicks_is_enabled() {
- return self::get_option( 'enh_ec_track_prod_click' );
+ return (bool) self::get_option( 'enh_ec_track_prod_click' );
}
+ /**
+ * Get the 'enh_ec_track_prod_detail_view' analytics option.
+ *
+ * @return bool
+ */
public static function track_product_detail_view_is_enabled() {
- return self::get_option( 'enh_ec_track_prod_detail_view' );
+ return (bool) self::get_option( 'enh_ec_track_prod_detail_view' );
}
+ /**
+ * Get the 'enh_ec_track_checkout_started' analytics option.
+ *
+ * @return bool
+ */
public static function track_checkout_started_is_enabled() {
- return self::get_option( 'enh_ec_track_checkout_started' );
+ return (bool) self::get_option( 'enh_ec_track_checkout_started' );
}
}
-
diff --git a/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-universal.php b/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-universal.php
index 268f72ef..ea80b904 100644
--- a/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-universal.php
+++ b/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-universal.php
@@ -1,21 +1,26 @@
-<?php
-
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
-* Jetpack_Google_Analytics_Universal hooks and and enqueues support for analytics.js
-* https://developers.google.com/analytics/devguides/collection/analyticsjs/
-* https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce
-*
-* @author allendav
-*/
+ * Jetpack_Google_Analytics_Universal hooks and and enqueues support for analytics.js
+ * https://developers.google.com/analytics/devguides/collection/analyticsjs/
+ * https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce
+ *
+ * @author allendav
+ */
/**
-* Bail if accessed directly
-*/
+ * Bail if accessed directly
+ */
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
+/**
+ * Jetpack_Google_Analytics_Universal main class.
+ */
class Jetpack_Google_Analytics_Universal {
+ /**
+ * Jetpack_Google_Analytics_Universal constructor.
+ */
public function __construct() {
add_filter( 'jetpack_wga_universal_commands', array( $this, 'maybe_anonymize_ip' ) );
add_filter( 'jetpack_wga_universal_commands', array( $this, 'maybe_track_purchases' ) );
@@ -37,6 +42,9 @@ class Jetpack_Google_Analytics_Universal {
add_action( 'wp_footer', array( $this, 'send_pageview_in_footer' ), 24 );
}
+ /**
+ * Hook for the `wp_head` action to output the analytics code.
+ */
public function wp_head() {
$tracking_code = Jetpack_Google_Analytics_Options::get_tracking_code();
if ( empty( $tracking_code ) ) {
@@ -66,6 +74,7 @@ class Jetpack_Google_Analytics_Universal {
*/
$universal_commands = apply_filters( 'jetpack_wga_universal_commands', array() );
+ // phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript -- Script is added to wp_head.
$async_code = "
<!-- Jetpack Google Analytics -->
<script>
@@ -76,15 +85,21 @@ class Jetpack_Google_Analytics_Universal {
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Jetpack Google Analytics -->
- ";
+ "; // phpcs:enable WordPress.WP.EnqueuedResources.NonEnqueuedScript
$async_code = str_replace( '%tracking_id%', $tracking_code, $async_code );
$universal_commands_string = implode( "\r\n", $universal_commands );
- $async_code = str_replace( '%universal_commands%', $universal_commands_string, $async_code );
+ $async_code = str_replace( '%universal_commands%', $universal_commands_string, $async_code );
- echo "$async_code\r\n";
+ echo "$async_code\r\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
+ /**
+ * Check if the 'anonymize_ip' option should be added to the universal Google Analytics queue (ga) commands.
+ *
+ * @param array $command_array Array of commands.
+ * @return array `$command_array` with the additional command conditionally added.
+ */
public function maybe_anonymize_ip( $command_array ) {
if ( Jetpack_Google_Analytics_Options::anonymize_ip_is_enabled() ) {
array_push( $command_array, "ga( 'set', 'anonymizeIp', true );" );
@@ -93,6 +108,14 @@ class Jetpack_Google_Analytics_Universal {
return $command_array;
}
+ /**
+ * Process purchase tracking options for the universal Google Analytics queue (ga) commands.
+ *
+ * May also update post meta to indicate the order has been tracked.
+ *
+ * @param array $command_array Array of commands.
+ * @return array `$command_array` with additional commands conditionally added.
+ */
public function maybe_track_purchases( $command_array ) {
global $wp;
@@ -114,47 +137,47 @@ class Jetpack_Google_Analytics_Universal {
}
$order_id = isset( $wp->query_vars['order-received'] ) ? $wp->query_vars['order-received'] : 0;
- if ( 0 == $order_id ) {
+ if ( 0 === (int) $order_id ) {
return $command_array;
}
// A 1 indicates we've already tracked this order - don't do it again
- if ( 1 == get_post_meta( $order_id, '_ga_tracked', true ) ) {
+ if ( 1 === (int) get_post_meta( $order_id, '_ga_tracked', true ) ) {
return $command_array;
}
- $order = new WC_Order( $order_id );
+ $order = new WC_Order( $order_id );
$order_currency = $order->get_currency();
- $command = "ga( 'set', '&cu', '" . esc_js( $order_currency ) . "' );";
+ $command = "ga( 'set', '&cu', '" . esc_js( $order_currency ) . "' );";
array_push( $command_array, $command );
// Order items
if ( $order->get_items() ) {
foreach ( $order->get_items() as $item ) {
- $product = $order->get_product_from_item( $item );
+ $product = $order->get_product_from_item( $item );
$product_sku_or_id = Jetpack_Google_Analytics_Utils::get_product_sku_or_id( $product );
$item_details = array(
- 'id' => $product_sku_or_id,
- 'name' => $item['name'],
+ 'id' => $product_sku_or_id,
+ 'name' => $item['name'],
'category' => Jetpack_Google_Analytics_Utils::get_product_categories_concatenated( $product ),
- 'price' => $order->get_item_total( $item ),
+ 'price' => $order->get_item_total( $item ),
'quantity' => $item['qty'],
);
- $command = "ga( 'ec:addProduct', " . wp_json_encode( $item_details ) . " );";
+ $command = "ga( 'ec:addProduct', " . wp_json_encode( $item_details ) . ' );';
array_push( $command_array, $command );
}
}
// Order summary
$summary = array(
- 'id' => $order->get_order_number(),
+ 'id' => $order->get_order_number(),
'affiliation' => get_bloginfo( 'name' ),
- 'revenue' => $order->get_total(),
- 'tax' => $order->get_total_tax(),
- 'shipping' => $order->get_total_shipping()
+ 'revenue' => $order->get_total(),
+ 'tax' => $order->get_total_tax(),
+ 'shipping' => $order->get_total_shipping(),
);
- $command = "ga( 'ec:setAction', 'purchase', " . wp_json_encode( $summary ) . " );";
+ $command = "ga( 'ec:setAction', 'purchase', " . wp_json_encode( $summary ) . ' );';
array_push( $command_array, $command );
update_post_meta( $order_id, '_ga_tracked', 1 );
@@ -162,6 +185,9 @@ class Jetpack_Google_Analytics_Universal {
return $command_array;
}
+ /**
+ * Enqueue add-to-cart click tracking script, if enabled.
+ */
public function add_to_cart() {
if ( ! Jetpack_Google_Analytics_Options::track_add_to_cart_is_enabled() ) {
return;
@@ -174,7 +200,7 @@ class Jetpack_Google_Analytics_Universal {
global $product;
$product_sku_or_id = Jetpack_Google_Analytics_Utils::get_product_sku_or_id( $product );
- $selector = ".single_add_to_cart_button";
+ $selector = '.single_add_to_cart_button';
wc_enqueue_js(
"$( '" . esc_js( $selector ) . "' ).click( function() {
@@ -190,6 +216,9 @@ class Jetpack_Google_Analytics_Universal {
);
}
+ /**
+ * Enqueue add-to-cart click tracking script for looped product views, if enabled.
+ */
public function loop_add_to_cart() {
if ( ! Jetpack_Google_Analytics_Options::track_add_to_cart_is_enabled() ) {
return;
@@ -204,7 +233,7 @@ class Jetpack_Google_Analytics_Universal {
return;
}
- $selector = ".add_to_cart_button:not(.product_type_variable, .product_type_grouped)";
+ $selector = '.add_to_cart_button:not(.product_type_variable, .product_type_grouped)';
wc_enqueue_js(
"$( '" . esc_js( $selector ) . "' ).click( function() {
@@ -221,6 +250,9 @@ class Jetpack_Google_Analytics_Universal {
);
}
+ /**
+ * Enqueue remove-from-cart click tracking script, if enabled.
+ */
public function remove_from_cart() {
if ( ! Jetpack_Google_Analytics_Options::enhanced_ecommerce_tracking_is_enabled() ) {
return;
@@ -273,6 +305,9 @@ class Jetpack_Google_Analytics_Universal {
return $url;
}
+ /**
+ * Enqueue listing impression tracking script, if enabled.
+ */
public function listing_impression() {
if ( ! Jetpack_Google_Analytics_Options::enhanced_ecommerce_tracking_is_enabled() ) {
return;
@@ -282,25 +317,28 @@ class Jetpack_Google_Analytics_Universal {
return;
}
- if ( isset( $_GET['s'] ) ) {
- $list = "Search Results";
+ if ( isset( $_GET['s'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- No site actions, just GA options being set.
+ $list = 'Search Results';
} else {
- $list = "Product List";
+ $list = 'Product List';
}
global $product, $woocommerce_loop;
$product_sku_or_id = Jetpack_Google_Analytics_Utils::get_product_sku_or_id( $product );
$item_details = array(
- 'id' => $product_sku_or_id,
- 'name' => $product->get_title(),
+ 'id' => $product_sku_or_id,
+ 'name' => $product->get_title(),
'category' => Jetpack_Google_Analytics_Utils::get_product_categories_concatenated( $product ),
- 'list' => $list,
- 'position' => $woocommerce_loop['loop']
+ 'list' => $list,
+ 'position' => $woocommerce_loop['loop'],
);
- wc_enqueue_js( "ga( 'ec:addImpression', " . wp_json_encode( $item_details ) . " );" );
+ wc_enqueue_js( "ga( 'ec:addImpression', " . wp_json_encode( $item_details ) . ' );' );
}
+ /**
+ * Enqueue listing click tracking script, if enabled.
+ */
public function listing_click() {
if ( ! Jetpack_Google_Analytics_Options::enhanced_ecommerce_tracking_is_enabled() ) {
return;
@@ -310,22 +348,22 @@ class Jetpack_Google_Analytics_Universal {
return;
}
- if ( isset( $_GET['s'] ) ) {
- $list = "Search Results";
+ if ( isset( $_GET['s'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- No site actions, just GA options being set.
+ $list = 'Search Results';
} else {
- $list = "Product List";
+ $list = 'Product List';
}
global $product, $woocommerce_loop;
$product_sku_or_id = Jetpack_Google_Analytics_Utils::get_product_sku_or_id( $product );
- $selector = ".products .post-" . esc_js( $product->get_id() ) . " a";
+ $selector = '.products .post-' . esc_js( $product->get_id() ) . ' a';
$item_details = array(
- 'id' => $product_sku_or_id,
- 'name' => $product->get_title(),
+ 'id' => $product_sku_or_id,
+ 'name' => $product->get_title(),
'category' => Jetpack_Google_Analytics_Utils::get_product_categories_concatenated( $product ),
- 'position' => $woocommerce_loop['loop']
+ 'position' => $woocommerce_loop['loop'],
);
wc_enqueue_js(
@@ -341,6 +379,9 @@ class Jetpack_Google_Analytics_Universal {
);
}
+ /**
+ * Enqueue product detail view tracking script, if enabled.
+ */
public function product_detail() {
if ( ! Jetpack_Google_Analytics_Options::enhanced_ecommerce_tracking_is_enabled() ) {
return;
@@ -354,17 +395,20 @@ class Jetpack_Google_Analytics_Universal {
$product_sku_or_id = Jetpack_Google_Analytics_Utils::get_product_sku_or_id( $product );
$item_details = array(
- 'id' => $product_sku_or_id,
- 'name' => $product->get_title(),
+ 'id' => $product_sku_or_id,
+ 'name' => $product->get_title(),
'category' => Jetpack_Google_Analytics_Utils::get_product_categories_concatenated( $product ),
- 'price' => $product->get_price()
+ 'price' => $product->get_price(),
);
wc_enqueue_js(
- "ga( 'ec:addProduct', " . wp_json_encode( $item_details ) . " );" .
+ "ga( 'ec:addProduct', " . wp_json_encode( $item_details ) . ' );' .
"ga( 'ec:setAction', 'detail' );"
);
}
+ /**
+ * Enqueue post-checkout tracking script, if enabled.
+ */
public function checkout_process() {
if ( ! Jetpack_Google_Analytics_Options::enhanced_ecommerce_tracking_is_enabled() ) {
return;
@@ -375,24 +419,24 @@ class Jetpack_Google_Analytics_Universal {
}
$universal_commands = array();
- $cart = WC()->cart->get_cart();
+ $cart = WC()->cart->get_cart();
foreach ( $cart as $cart_item_key => $cart_item ) {
/**
* This filter is already documented in woocommerce/templates/cart/cart.php
*/
- $product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
+ $product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_sku_or_id = Jetpack_Google_Analytics_Utils::get_product_sku_or_id( $product );
$item_details = array(
- 'id' => $product_sku_or_id,
- 'name' => $product->get_title(),
+ 'id' => $product_sku_or_id,
+ 'name' => $product->get_title(),
'category' => Jetpack_Google_Analytics_Utils::get_product_categories_concatenated( $product ),
- 'price' => $product->get_price(),
- 'quantity' => $cart_item[ 'quantity' ]
+ 'price' => $product->get_price(),
+ 'quantity' => $cart_item['quantity'],
);
- array_push( $universal_commands, "ga( 'ec:addProduct', " . wp_json_encode( $item_details ) . " );" );
+ array_push( $universal_commands, "ga( 'ec:addProduct', " . wp_json_encode( $item_details ) . ' );' );
}
array_push( $universal_commands, "ga( 'ec:setAction','checkout' );" );
@@ -400,6 +444,11 @@ class Jetpack_Google_Analytics_Universal {
wc_enqueue_js( implode( "\r\n", $universal_commands ) );
}
+ /**
+ * Enqueue pageview event in footer of all pages.
+ *
+ * Action hook added with later priority to come after all of the above tracking.
+ */
public function send_pageview_in_footer() {
if ( ! Jetpack_Google_Analytics_Options::has_tracking_code() ) {
return;
diff --git a/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-utils.php b/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-utils.php
index 807461de..ceabc8ff 100644
--- a/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-utils.php
+++ b/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-utils.php
@@ -1,22 +1,25 @@
-<?php
-
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
-* Jetpack_Google_Analytics_Options provides a single interface to module options
-*
-* @author allendav
-*/
+ * Jetpack_Google_Analytics_Options provides a single interface to module options
+ *
+ * @author allendav
+ */
/**
-* Bail if accessed directly
-*/
+ * Bail if accessed directly
+ */
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
+/**
+ * Jetpack_Google_Analytics_Utils main class.
+ */
class Jetpack_Google_Analytics_Utils {
/**
* Gets product categories or varation attributes as a formatted concatenated string
- * @param WC_Product
+ *
+ * @param WC_Product $product Product to get categories/variations for.
* @return string
*/
public static function get_product_categories_concatenated( $product ) {
@@ -32,21 +35,22 @@ class Jetpack_Google_Analytics_Utils {
if ( is_array( $variation_data ) && ! empty( $variation_data ) ) {
$line = wc_get_formatted_variation( $variation_data, true );
} else {
- $out = array();
+ $out = array();
$categories = get_the_terms( $product->get_id(), 'product_cat' );
if ( $categories ) {
foreach ( $categories as $category ) {
$out[] = $category->name;
}
}
- $line = join( "/", $out );
+ $line = join( '/', $out );
}
return $line;
}
/**
* Gets a product's SKU with fallback to just ID. IDs are prepended with a hash symbol.
- * @param WC_Product
+ *
+ * @param WC_Product $product Product to get SKU/ID for.
* @return string
*/
public static function get_product_sku_or_id( $product ) {
@@ -60,4 +64,4 @@ class Jetpack_Google_Analytics_Utils {
return $product->get_sku() ? $product->get_sku() : '#' . $product->get_id();
}
-} \ No newline at end of file
+}
diff --git a/plugins/jetpack/modules/google-analytics/wp-google-analytics.php b/plugins/jetpack/modules/google-analytics/wp-google-analytics.php
index 7915fb9b..c60b72d8 100644
--- a/plugins/jetpack/modules/google-analytics/wp-google-analytics.php
+++ b/plugins/jetpack/modules/google-analytics/wp-google-analytics.php
@@ -1,49 +1,53 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+
/*
- Copyright 2006 Aaron D. Campbell (email : wp_plugins@xavisys.com)
+ Copyright 2006 Aaron D. Campbell (email : wp_plugins@xavisys.com)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/**
- * Jetpack_Google_Analytics is the class that handles ALL of the plugin functionality.
- * It helps us avoid name collisions
- * https://codex.wordpress.org/Writing_a_Plugin#Avoiding_Function_Name_Collisions
- */
-
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
-require_once( plugin_basename( 'classes/wp-google-analytics-utils.php' ) );
-require_once( plugin_basename( 'classes/wp-google-analytics-options.php' ) );
-require_once( plugin_basename( 'classes/wp-google-analytics-legacy.php' ) );
-require_once( plugin_basename( 'classes/wp-google-analytics-universal.php' ) );
+require_once plugin_basename( 'classes/wp-google-analytics-utils.php' );
+require_once plugin_basename( 'classes/wp-google-analytics-options.php' );
+require_once plugin_basename( 'classes/wp-google-analytics-legacy.php' );
+require_once plugin_basename( 'classes/wp-google-analytics-universal.php' );
require_once plugin_basename( 'classes/class-jetpack-google-amp-analytics.php' );
+/**
+ * Jetpack_Google_Analytics is the class that handles ALL of the plugin functionality.
+ * It helps us avoid name collisions
+ * https://codex.wordpress.org/Writing_a_Plugin#Avoiding_Function_Name_Collisions
+ */
class Jetpack_Google_Analytics {
/**
- * @var Jetpack_Google_Analytics - Static property to hold our singleton instance
+ * Jetpack_Google_Analytics singleton instance.
+ *
+ * @var Jetpack_Google_Analytics
*/
- static $instance = false;
+ public static $instance = false;
/**
- * @var Static property to hold concrete analytics impl that does the work (universal or legacy)
+ * Property to hold concrete analytics implementation that does the work (universal or legacy).
+ *
+ * @var Static
*/
- static $analytics = false;
+ public static $analytics = false;
/**
* This is our constructor, which is private to force the use of get_instance()
@@ -66,7 +70,7 @@ class Jetpack_Google_Analytics {
*/
public static function get_instance() {
if ( ! self::$instance ) {
- self::$instance = new self;
+ self::$instance = new self();
}
return self::$instance;
diff --git a/plugins/jetpack/modules/google-fonts.php b/plugins/jetpack/modules/google-fonts.php
new file mode 100644
index 00000000..7d9f91fe
--- /dev/null
+++ b/plugins/jetpack/modules/google-fonts.php
@@ -0,0 +1,107 @@
+<?php
+/**
+ * Module Name: Google Fonts (Beta)
+ * Module Description: A selection of Google fonts for block enabled themes. This feature is still being developed.
+ * Sort Order: 1
+ * Recommendation Order: 2
+ * First Introduced: 10.8.0
+ * Requires Connection: No
+ * Auto Activate: No
+ * Module Tags: Fonts, Recommended
+ * Feature: Writing
+ * Additional Search Queries: fonts, webfonts, typography
+ *
+ * @package automattic/jetpack
+ */
+
+/**
+ * Curated list of Google Fonts
+ * See https://wp.me/p9Jlb4-22P
+ */
+const JETPACK_GOOGLE_FONTS_LIST = array(
+ 'Arvo',
+ 'Bodoni Moda',
+ 'Cabin',
+ 'Chivo',
+ 'Courier Prime',
+ 'DM Sans',
+ 'Domine',
+ 'EB Garamond',
+ 'Fira Sans',
+ 'IBM Plex Sans',
+ 'IBM Plex Mono',
+ 'Inter',
+ 'Josefin Sans',
+ 'Jost',
+ 'Libre Baskerville',
+ 'Libre Franklin',
+ 'Literata',
+ 'Lora',
+ 'Merriweather',
+ 'Montserrat',
+ 'Newsreader',
+ 'Nunito',
+ 'Open Sans',
+ 'Overpass',
+ 'Playfair Display',
+ 'Poppins',
+ 'Raleway',
+ 'Roboto',
+ 'Roboto Slab',
+ 'Rubik',
+ 'Source Sans Pro',
+ 'Source Serif Pro',
+ 'Space Mono',
+ 'Texturina',
+ 'Work Sans',
+);
+
+/**
+ * Register a curated selection of Google Fonts.
+ *
+ * @return void
+ */
+function jetpack_add_google_fonts_provider() {
+ if ( ! function_exists( 'wp_register_webfont_provider' ) || ! function_exists( 'wp_register_webfonts' ) ) {
+ return;
+ }
+
+ wp_register_webfont_provider( 'jetpack-google-fonts', '\Automattic\Jetpack\Fonts\Google_Fonts_Provider' );
+
+ /**
+ * Curated list of Google Fonts.
+ *
+ * @module google-fonts
+ *
+ * @since 10.8
+ *
+ * @param array $fonts_to_register Array of Google Font names to register.
+ */
+ $fonts_to_register = apply_filters( 'jetpack_google_fonts_list', JETPACK_GOOGLE_FONTS_LIST );
+
+ foreach ( $fonts_to_register as $font_family ) {
+ wp_register_webfonts(
+ array(
+ array(
+ 'font-family' => $font_family,
+ 'font-weight' => '100 900',
+ 'font-style' => 'normal',
+ 'font-display' => 'fallback',
+ 'provider' => 'jetpack-google-fonts',
+ ),
+ array(
+ 'font-family' => $font_family,
+ 'font-weight' => '100 900',
+ 'font-style' => 'italic',
+ 'font-display' => 'fallback',
+ 'provider' => 'jetpack-google-fonts',
+ ),
+ )
+ );
+ }
+}
+add_action( 'after_setup_theme', 'jetpack_add_google_fonts_provider' );
+
+add_filter( 'wp_resource_hints', '\Automattic\Jetpack\Fonts\Utils::font_source_resource_hint', 10, 2 );
+add_filter( 'pre_render_block', '\Automattic\Jetpack\Fonts\Introspectors\Blocks::enqueue_block_fonts', 10, 2 );
+add_action( 'init', '\Automattic\Jetpack\Fonts\Introspectors\Global_Styles::enqueue_global_styles_fonts' );
diff --git a/plugins/jetpack/modules/gravatar-hovercards.php b/plugins/jetpack/modules/gravatar-hovercards.php
index 9e7bf1e8..c8d75624 100644
--- a/plugins/jetpack/modules/gravatar-hovercards.php
+++ b/plugins/jetpack/modules/gravatar-hovercards.php
@@ -10,19 +10,24 @@
* Module Tags: Social, Appearance
* Feature: Appearance
* Additional Search Queries: gravatar, hovercards
+ *
+ * @package automattic/jetpack
*/
define( 'GROFILES__CACHE_BUSTER', gmdate( 'YW' ) );
+/**
+ * Actions that are run on init.
+ */
function grofiles_hovercards_init() {
- add_filter( 'get_avatar', 'grofiles_get_avatar', 10, 2 );
- add_action( 'wp_enqueue_scripts', 'grofiles_attach_cards' );
- add_action( 'wp_footer', 'grofiles_extra_data' );
- add_action( 'admin_init', 'grofiles_add_settings' );
-
- add_action( 'load-index.php', 'grofiles_admin_cards' );
- add_action( 'load-users.php', 'grofiles_admin_cards' );
- add_action( 'load-edit-comments.php', 'grofiles_admin_cards' );
+ add_filter( 'get_avatar', 'grofiles_get_avatar', 10, 2 );
+ add_action( 'wp_enqueue_scripts', 'grofiles_attach_cards' );
+ add_action( 'wp_footer', 'grofiles_extra_data' );
+ add_action( 'admin_init', 'grofiles_add_settings' );
+
+ add_action( 'load-index.php', 'grofiles_admin_cards' );
+ add_action( 'load-users.php', 'grofiles_admin_cards' );
+ add_action( 'load-edit-comments.php', 'grofiles_admin_cards' );
add_action( 'load-options-discussion.php', 'grofiles_admin_cards_forced' );
add_filter( 'jetpack_module_configuration_url_gravatar-hovercards', 'gravatar_hovercards_configuration_url' );
@@ -30,6 +35,9 @@ function grofiles_hovercards_init() {
add_filter( 'get_comment_author_url', 'grofiles_amp_comment_author_url', 10, 2 );
}
+/**
+ * Set configuration page URL.
+ */
function gravatar_hovercards_configuration_url() {
return admin_url( 'options-discussion.php#show_avatars' );
}
@@ -44,11 +52,12 @@ add_action( 'jetpack_modules_loaded', 'grofiles_hovercards_init' );
* @todo - always print HTML, hide via CSS/JS if !show_avatars
*/
function grofiles_add_settings() {
- if ( !get_option( 'show_avatars' ) )
+ if ( ! get_option( 'show_avatars' ) ) {
return;
+ }
- add_settings_field( 'gravatar_disable_hovercards', __( 'Gravatar Hovercards', 'jetpack' ), 'grofiles_setting_callback', 'discussion', 'avatars' );
- register_setting( 'discussion', 'gravatar_disable_hovercards', 'grofiles_hovercard_option_sanitize' );
+ add_settings_field( 'gravatar_disable_hovercards', __( 'Gravatar Hovercards', 'jetpack' ), 'grofiles_setting_callback', 'discussion', 'avatars' );
+ register_setting( 'discussion', 'gravatar_disable_hovercards', 'grofiles_hovercard_option_sanitize' );
}
/**
@@ -57,10 +66,14 @@ function grofiles_add_settings() {
function grofiles_setting_callback() {
global $current_user;
- $checked = 'disabled' == get_option( 'gravatar_disable_hovercards' ) ? '' : 'checked="checked" ';
+ $option = get_option( 'gravatar_disable_hovercards' );
+ printf(
+ "<label id='gravatar-hovercard-options'><input %s name='gravatar_disable_hovercards' id='gravatar_disable_hovercards' type='checkbox' value='enabled' class='code'/>%s</label>",
+ checked( $option, 'enabled', false ),
+ esc_html__( 'View people\'s profiles when you mouse over their Gravatars', 'jetpack' )
+ );
- echo "<label id='gravatar-hovercard-options'><input {$checked}name='gravatar_disable_hovercards' id='gravatar_disable_hovercards' type='checkbox' value='enabled' class='code' /> " . __( "View people's profiles when you mouse over their Gravatars", 'jetpack' ) . "</label>";
-?>
+ ?>
<style type="text/css">
#grav-profile-example img {
float: left;
@@ -86,22 +99,29 @@ jQuery( function($) {
} );
// ]]>
</script>
- <p id="grav-profile-example" class="hide-if-no-js"<?php if ( !$checked ) echo ' style="display:none"'; ?>><?php echo get_avatar( $current_user->ID, 64 ); ?> <span><?php _e( 'Put your mouse over your Gravatar to check out your profile.', 'jetpack' ); ?> <br class="clear" /></span></p>
-<?php
+ <p id="grav-profile-example" class="hide-if-no-js"
+ <?php
+ if ( 'disabled' === $option ) {
+ echo ' style="display:none"';}
+ ?>
+ >
+ <?php echo get_avatar( $current_user->ID, 64 ); ?> <span><?php esc_html_e( 'Put your mouse over your Gravatar to check out your profile.', 'jetpack' ); ?> <br class="clear" /></span></p>
+ <?php
}
/**
* Sanitation filter for Gravatar Hovercard setting
+ *
+ * @param string $val Disabled or enabled.
*/
function grofiles_hovercard_option_sanitize( $val ) {
- if ( 'disabled' == $val ) {
+ if ( 'disabled' === $val ) {
return $val;
}
return $val ? 'enabled' : 'disabled';
}
-
/* Hovercard Display */
/**
@@ -116,18 +136,18 @@ function grofiles_hovercard_option_sanitize( $val ) {
function grofiles_gravatars_to_append( $author = null ) {
static $authors = array();
- // Get
- if ( is_null( $author ) ) {
+ // Get.
+ if ( $author === null ) {
return array_keys( $authors );
}
- // Set
+ // Set.
if ( is_numeric( $author ) ) {
$author = (int) $author;
}
- $authors[$author] = true;
+ $authors[ $author ] = true;
}
/**
@@ -154,7 +174,7 @@ function grofiles_amp_comment_author_url( $url, $id ) {
* Attached to the 'get_avatar' filter.
*
* @param string $avatar The <img/> element of the avatar.
- * @param mixed $author User ID, email address, user login, comment object, user object, post object
+ * @param mixed $author User ID, email address, user login, comment object, user object, post object.
*
* @return string The <img/> element of the avatar.
*/
@@ -163,14 +183,16 @@ function grofiles_get_avatar( $avatar, $author ) {
if ( is_numeric( $author ) ) {
grofiles_gravatars_to_append( $author );
- } else if ( is_string( $author ) ) {
+ } elseif ( is_string( $author ) ) {
if ( false !== strpos( $author, '@' ) ) {
grofiles_gravatars_to_append( $author );
} else {
- if ( $user = get_user_by( 'slug', $author ) )
+ $user = get_user_by( 'slug', $author );
+ if ( $user ) {
grofiles_gravatars_to_append( $user->ID );
+ }
}
- } else if ( isset( $author->comment_type ) ) {
+ } elseif ( isset( $author->comment_type ) ) {
if ( $is_amp ) {
if ( 1 === preg_match( '/avatar\/([a-zA-Z0-9]+)\?/', $avatar, $email_hash ) ) {
$email_hash = $email_hash[1];
@@ -205,15 +227,17 @@ function grofiles_get_avatar( $avatar, $author ) {
return $avatar;
}
- if ( '' != $author->comment_type && 'comment' != $author->comment_type )
+ if ( '' !== $author->comment_type && 'comment' !== $author->comment_type ) {
return $avatar;
- if ( $author->user_id )
+ }
+ if ( $author->user_id ) {
grofiles_gravatars_to_append( $author->user_id );
- else
+ } else {
grofiles_gravatars_to_append( $author->comment_author_email );
- } else if ( isset( $author->user_login ) ) {
+ }
+ } elseif ( isset( $author->user_login ) ) {
grofiles_gravatars_to_append( $author->ID );
- } else if ( isset( $author->post_author ) ) {
+ } elseif ( isset( $author->post_author ) ) {
grofiles_gravatars_to_append( $author->post_author );
}
@@ -226,7 +250,6 @@ function grofiles_get_avatar( $avatar, $author ) {
* @todo is_singular() only?
*/
function grofiles_attach_cards() {
- global $blog_id;
// Is the display of Avatars disabled?
if ( ! get_option( 'show_avatars' ) ) {
@@ -234,7 +257,7 @@ function grofiles_attach_cards() {
}
// Is the display of Gravatar Hovercards disabled?
- if ( 'disabled' == Jetpack_Options::get_option_and_ensure_autoload( 'gravatar_disable_hovercards', '0' ) ) {
+ if ( 'disabled' === Jetpack_Options::get_option_and_ensure_autoload( 'gravatar_disable_hovercards', '0' ) ) {
return;
}
@@ -247,31 +270,41 @@ function grofiles_attach_cards() {
$cu = wp_get_current_user();
$my_hash = md5( $cu->user_email );
} elseif ( ! empty( $_COOKIE[ 'comment_author_email_' . COOKIEHASH ] ) ) {
- $my_hash = md5( $_COOKIE[ 'comment_author_email_' . COOKIEHASH ] );
+ $my_hash = md5( filter_var( wp_unslash( $_COOKIE[ 'comment_author_email_' . COOKIEHASH ] ) ) );
} else {
$my_hash = '';
}
wp_localize_script( 'wpgroho', 'WPGroHo', compact( 'my_hash' ) );
}
}
-
+/**
+ * Add hovercards on Discussion settings panel.
+ */
function grofiles_attach_cards_forced() {
add_filter( 'pre_option_gravatar_disable_hovercards', 'grofiles_force_gravatar_enable_hovercards' );
grofiles_attach_cards();
}
-
+/**
+ * Set hovercards as enabled on Discussion settings panel.
+ */
function grofiles_force_gravatar_enable_hovercards() {
return 'enabled';
}
-
+/**
+ * Add script to admin footer on Discussion settings panel.
+ */
function grofiles_admin_cards_forced() {
add_action( 'admin_footer', 'grofiles_attach_cards_forced' );
}
-
+/**
+ * Add script to admin footer.
+ */
function grofiles_admin_cards() {
add_action( 'admin_footer', 'grofiles_attach_cards' );
}
-
+/**
+ * Dequeue the FE assets when there are no gravatars on the page to be displayed.
+ */
function grofiles_extra_data() {
$authors = grofiles_gravatars_to_append();
@@ -279,15 +312,15 @@ function grofiles_extra_data() {
wp_dequeue_script( 'grofiles-cards' );
wp_dequeue_script( 'wpgroho' );
} else {
-?>
+ ?>
<div style="display:none">
-<?php
+ <?php
foreach ( $authors as $author ) {
grofiles_hovercards_data_html( $author );
}
-?>
+ ?>
</div>
-<?php
+ <?php
}
}
@@ -296,7 +329,7 @@ function grofiles_extra_data() {
*
* @since 5.5.0 Add support for a passed WP_User object
*
- * @param int|string|WP_User $author User ID, email address, or a WP_User object
+ * @param int|string|WP_User $author User ID, email address, or a WP_User object.
*/
function grofiles_hovercards_data_html( $author ) {
$data = grofiles_hovercards_data( $author );
@@ -315,16 +348,15 @@ function grofiles_hovercards_data_html( $author ) {
if ( ! $hash ) {
return;
}
-?>
- <div class="grofile-hash-map-<?php echo $hash; ?>">
-<?php foreach ( $data as $key => $value ) : ?>
+ ?>
+ <div class="grofile-hash-map-<?php echo esc_attr( $hash ); ?>">
+ <?php foreach ( $data as $key => $value ) : ?>
<span class="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value ); ?></span>
<?php endforeach; ?>
</div>
-<?php
+ <?php
}
-
/* API */
/**
@@ -350,18 +382,20 @@ function grofiles_hovercards_data_callbacks() {
/**
* Keyed JSON object containing all profile data provided by registered callbacks
*
- * @param int|strung $author User ID or email address
+ * @param int|strung $author User ID or email address.
*
* @return array( data_key => data, ... )
*/
function grofiles_hovercards_data( $author ) {
$r = array();
foreach ( grofiles_hovercards_data_callbacks() as $key => $callback ) {
- if ( !is_callable( $callback ) )
+ if ( ! is_callable( $callback ) ) {
continue;
+ }
$data = call_user_func( $callback, $author, $key );
- if ( !is_null( $data ) )
- $r[$key] = $data;
+ if ( $data !== null ) {
+ $r[ $key ] = $data;
+ }
}
return $r;
diff --git a/plugins/jetpack/modules/infinite-scroll.php b/plugins/jetpack/modules/infinite-scroll.php
index 7674217f..4f050867 100644
--- a/plugins/jetpack/modules/infinite-scroll.php
+++ b/plugins/jetpack/modules/infinite-scroll.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Module Name: Infinite Scroll
* Module Description: Automatically load new content when a visitor scrolls
@@ -16,12 +16,17 @@
*/
class Jetpack_Infinite_Scroll_Extras {
/**
- * Class variables
+ * Class variable singleton.
+ *
+ * @var Jetpack_Infinite_Scroll_Extras
*/
- // Oh look, a singleton
- private static $__instance = null;
+ private static $instance = null;
- // Option names
+ /**
+ * Option names.
+ *
+ * @var string
+ */
private $option_name_google_analytics = 'infinite_scroll_google_analytics';
/**
@@ -30,17 +35,17 @@ class Jetpack_Infinite_Scroll_Extras {
* @return object
*/
public static function instance() {
- if ( ! is_a( self::$__instance, 'Jetpack_Infinite_Scroll_Extras' ) )
- self::$__instance = new Jetpack_Infinite_Scroll_Extras;
+ if ( ! self::$instance instanceof Jetpack_Infinite_Scroll_Extras ) {
+ self::$instance = new Jetpack_Infinite_Scroll_Extras();
+ }
- return self::$__instance;
+ return self::$instance;
}
/**
* Register actions and filters
*
* @uses add_action, add_filter
- * @return null
*/
private function __construct() {
add_action( 'jetpack_modules_loaded', array( $this, 'action_jetpack_modules_loaded' ) );
@@ -59,7 +64,6 @@ class Jetpack_Infinite_Scroll_Extras {
*
* @uses Jetpack::enable_module_configurable
* @action jetpack_modules_loaded
- * @return null
*/
public function action_jetpack_modules_loaded() {
Jetpack::enable_module_configurable( __FILE__ );
@@ -70,9 +74,12 @@ class Jetpack_Infinite_Scroll_Extras {
*
* @uses add_settings_field, __, register_setting
* @action admin_init
- * @return null
*/
public function action_admin_init() {
+ if ( ! Jetpack_Plan::supports( 'google-analytics' ) ) {
+ return;
+ }
+
add_settings_field( $this->option_name_google_analytics, '<span id="infinite-scroll-google-analytics">' . __( 'Use Google Analytics with Infinite Scroll', 'jetpack' ) . '</span>', array( $this, 'setting_google_analytics' ), 'reading' );
register_setting( 'reading', $this->option_name_google_analytics, array( $this, 'sanitize_boolean_value' ) );
}
@@ -81,17 +88,16 @@ class Jetpack_Infinite_Scroll_Extras {
* Render Google Analytics option
*
* @uses checked, get_option, __
- * @return html
*/
public function setting_google_analytics() {
- echo '<label><input name="infinite_scroll_google_analytics" type="checkbox" value="1" ' . checked( true, (bool) get_option( $this->option_name_google_analytics, false ), false ) . ' /> ' . esc_html__( 'Track each scroll load (7 posts by default) as a page view in Google Analytics', 'jetpack' ) . '</label>';
+ echo '<label><input name="infinite_scroll_google_analytics" type="checkbox" value="1" ' . checked( true, (bool) get_option( $this->option_name_google_analytics, false ), false ) . ' /> ' . esc_html__( 'Track each scroll load (7 posts by default) as a page view in Google Analytics', 'jetpack' ) . '</label>';
echo '<p class="description">' . esc_html__( 'Check the box above to record each new set of posts loaded via Infinite Scroll as a page view in Google Analytics.', 'jetpack' ) . '</p>';
}
/**
* Sanitize value as a boolean
*
- * @param mixed $value
+ * @param mixed $value - the value we're sanitizing.
* @return bool
*/
public function sanitize_boolean_value( $value ) {
@@ -108,23 +114,24 @@ class Jetpack_Infinite_Scroll_Extras {
* @action setup_theme
* @return null
*/
- function action_after_setup_theme() {
+ public function action_after_setup_theme() {
$theme = wp_get_theme();
- if ( ! is_a( $theme, 'WP_Theme' ) && ! is_array( $theme ) )
+ if ( ! $theme instanceof WP_Theme && ! is_array( $theme ) ) {
return;
+ }
/** This filter is already documented in modules/infinite-scroll/infinity.php */
- $customization_file = apply_filters( 'infinite_scroll_customization_file', dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Stylesheet']}.php", $theme['Stylesheet'] );
+ $customization_file = apply_filters( 'infinite_scroll_customization_file', __DIR__ . "/infinite-scroll/themes/{$theme['Stylesheet']}.php", $theme['Stylesheet'] );
if ( is_readable( $customization_file ) ) {
- require_once( $customization_file );
- }
- elseif ( ! empty( $theme['Template'] ) ) {
- $customization_file = dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Template']}.php";
+ require_once $customization_file;
+ } elseif ( ! empty( $theme['Template'] ) ) {
+ $customization_file = __DIR__ . "/infinite-scroll/themes/{$theme['Template']}.php";
- if ( is_readable( $customization_file ) )
- require_once( $customization_file );
+ if ( is_readable( $customization_file ) ) {
+ require_once $customization_file;
+ }
}
}
@@ -133,19 +140,22 @@ class Jetpack_Infinite_Scroll_Extras {
*
* @uses Jetpack::get_active_modules, is_user_logged_in, stats_get_options, Jetpack_Options::get_option, get_option, JETPACK__API_VERSION, JETPACK__VERSION
* @filter infinite_scroll_js_settings
+ *
+ * @param array $settings - the settings.
* @return array
*/
public function filter_infinite_scroll_js_settings( $settings ) {
// Provide WP Stats info for tracking Infinite Scroll loads
// Abort if Stats module isn't active
- if ( in_array( 'stats', Jetpack::get_active_modules() ) ) {
+ if ( in_array( 'stats', Jetpack::get_active_modules(), true ) ) {
// Abort if user is logged in but logged-in users shouldn't be tracked.
if ( is_user_logged_in() && function_exists( 'stats_get_options' ) ) {
- $stats_options = stats_get_options();
+ $stats_options = stats_get_options();
$track_loggedin_users = isset( $stats_options['reg_users'] ) ? (bool) $stats_options['reg_users'] : false;
- if ( ! $track_loggedin_users )
+ if ( ! $track_loggedin_users ) {
return $settings;
+ }
}
// We made it this far, so gather the data needed to track IS views
@@ -153,14 +163,15 @@ class Jetpack_Infinite_Scroll_Extras {
// Pagetype parameter
$settings['stats'] .= '&x_pagetype=infinite';
- if ( 'click' == $settings['type'] )
+ if ( 'click' === $settings['type'] ) {
$settings['stats'] .= '-click';
+ }
$settings['stats'] .= '-jetpack';
}
- // Check if Google Analytics tracking is requested
- $settings['google_analytics'] = (bool) Jetpack_Options::get_option_and_ensure_autoload( $this->option_name_google_analytics, 0 );
+ // Check if Google Analytics tracking is requested.
+ $settings['google_analytics'] = Jetpack_Plan::supports( 'google-analytics' ) && Jetpack_Options::get_option_and_ensure_autoload( $this->option_name_google_analytics, 0 );
return $settings;
}
@@ -222,7 +233,7 @@ Jetpack_Infinite_Scroll_Extras::instance();
/**
* Load main IS file
*/
-require_once( dirname( __FILE__ ) . "/infinite-scroll/infinity.php" );
+require_once __DIR__ . '/infinite-scroll/infinity.php';
/**
* Remove the IS annotation loading function bundled with the IS plugin in favor of the Jetpack-specific version in Jetpack_Infinite_Scroll_Extras::action_after_setup_theme();
diff --git a/plugins/jetpack/modules/infinite-scroll/infinity.php b/plugins/jetpack/modules/infinite-scroll/infinity.php
index a26419d7..aab990db 100644
--- a/plugins/jetpack/modules/infinite-scroll/infinity.php
+++ b/plugins/jetpack/modules/infinite-scroll/infinity.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Assets;
use Automattic\Jetpack\Redirect;
@@ -12,6 +12,7 @@ Author: Automattic
Author URI: https://automattic.com/
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
+Text Domain: jetpack
*/
/**
@@ -28,9 +29,8 @@ class The_Neverending_Home_Page {
* Register actions and filters, plus parse IS settings
*
* @uses add_action, add_filter, self::get_settings
- * @return null
*/
- function __construct() {
+ public function __construct() {
add_action( 'pre_get_posts', array( $this, 'posts_per_page_query' ) );
add_action( 'admin_init', array( $this, 'settings_api_init' ) );
add_action( 'template_redirect', array( $this, 'action_template_redirect' ) );
@@ -57,10 +57,29 @@ class The_Neverending_Home_Page {
/**
* Initialize our static variables
*/
- static $the_time = null;
- static $settings = null; // Don't access directly, instead use self::get_settings().
- static $option_name_enabled = 'infinite_scroll';
+ /**
+ * The time.
+ *
+ * @var null - I don't think this is used?
+ */
+ public static $the_time = null;
+
+ /**
+ * Settings.
+ *
+ * Don't access directly, instead use self::get_settings().
+ *
+ * @var array
+ */
+ public static $settings = null;
+
+ /**
+ * The enabled option name.
+ *
+ * @var string
+ */
+ public static $option_name_enabled = 'infinite_scroll';
/**
* Parse IS settings provided by theme
@@ -68,23 +87,23 @@ class The_Neverending_Home_Page {
* @uses get_theme_support, infinite_scroll_has_footer_widgets, sanitize_title, add_action, get_option, wp_parse_args, is_active_sidebar
* @return object
*/
- static function get_settings() {
- if ( is_null( self::$settings ) ) {
+ public static function get_settings() {
+ if ( self::$settings === null ) {
$css_pattern = '#[^A-Z\d\-_]#i';
- $settings = $defaults = array(
+ $defaults = array(
'type' => 'scroll', // scroll | click
'requested_type' => 'scroll', // store the original type for use when logic overrides it
'footer_widgets' => false, // true | false | sidebar_id | array of sidebar_ids -- last two are checked with is_active_sidebar
'container' => 'content', // container html id
- 'wrapper' => true, // true | false | html class
+ 'wrapper' => true, // true | false | html class -- the html class.
'render' => false, // optional function, otherwise the `content` template part will be used
'footer' => true, // boolean to enable or disable the infinite footer | string to provide an html id to derive footer width from
'footer_callback' => false, // function to be called to render the IS footer, in place of the default
- 'posts_per_page' => false, // int | false to set based on IS type
+ 'posts_per_page' => false, // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page -- int | false to set based on IS type
'click_handle' => true, // boolean to enable or disable rendering the click handler div. If type is click and this is false, page must include its own trigger with the HTML ID `infinite-handle`.
);
-
+ $settings = $defaults;
// Validate settings passed through add_theme_support()
$_settings = get_theme_support( 'infinite-scroll' );
@@ -93,69 +112,76 @@ class The_Neverending_Home_Page {
if ( isset( $_settings[0] ) && is_array( $_settings[0] ) ) {
foreach ( $_settings[0] as $key => $value ) {
switch ( $key ) {
- case 'type' :
- if ( in_array( $value, array( 'scroll', 'click' ) ) )
- $settings[ $key ] = $settings['requested_type'] = $value;
+ case 'type':
+ if ( in_array( $value, array( 'scroll', 'click' ), true ) ) {
+ $settings['requested_type'] = $value;
+ $settings[ $key ] = $settings['requested_type'];
+ }
break;
- case 'footer_widgets' :
- if ( is_string( $value ) )
+ case 'footer_widgets':
+ if ( is_string( $value ) ) {
$settings[ $key ] = sanitize_title( $value );
- elseif ( is_array( $value ) )
+ } elseif ( is_array( $value ) ) {
$settings[ $key ] = array_map( 'sanitize_title', $value );
- elseif ( is_bool( $value ) )
+ } elseif ( is_bool( $value ) ) {
$settings[ $key ] = $value;
+ }
break;
- case 'container' :
- case 'wrapper' :
- if ( 'wrapper' == $key && is_bool( $value ) ) {
+ case 'container':
+ case 'wrapper':
+ if ( 'wrapper' === $key && is_bool( $value ) ) {
$settings[ $key ] = $value;
} else {
$value = preg_replace( $css_pattern, '', $value );
- if ( ! empty( $value ) )
+ if ( ! empty( $value ) ) {
$settings[ $key ] = $value;
+ }
}
break;
- case 'render' :
+ case 'render':
if ( false !== $value && is_callable( $value ) ) {
$settings[ $key ] = $value;
}
break;
- case 'footer' :
+ case 'footer':
if ( is_bool( $value ) ) {
$settings[ $key ] = $value;
} elseif ( is_string( $value ) ) {
$value = preg_replace( $css_pattern, '', $value );
- if ( ! empty( $value ) )
+ if ( ! empty( $value ) ) {
$settings[ $key ] = $value;
+ }
}
break;
- case 'footer_callback' :
- if ( is_callable( $value ) )
+ case 'footer_callback':
+ if ( is_callable( $value ) ) {
$settings[ $key ] = $value;
- else
+ } else {
$settings[ $key ] = false;
+ }
break;
- case 'posts_per_page' :
- if ( is_numeric( $value ) )
+ case 'posts_per_page':
+ if ( is_numeric( $value ) ) {
$settings[ $key ] = (int) $value;
+ }
break;
- case 'click_handle' :
+ case 'click_handle':
if ( is_bool( $value ) ) {
$settings[ $key ] = $value;
}
@@ -173,8 +199,9 @@ class The_Neverending_Home_Page {
$settings['container'] = preg_replace( $css_pattern, '', $_settings[0] );
// Wrap IS elements?
- if ( isset( $_settings[1] ) )
+ if ( isset( $_settings[1] ) ) {
$settings['wrapper'] = (bool) $_settings[1];
+ }
}
}
@@ -187,7 +214,7 @@ class The_Neverending_Home_Page {
if ( function_exists( 'infinite_scroll_has_footer_widgets' ) ) {
$settings['footer_widgets'] = (bool) infinite_scroll_has_footer_widgets();
} elseif ( is_array( $settings['footer_widgets'] ) ) {
- $sidebar_ids = $settings['footer_widgets'];
+ $sidebar_ids = $settings['footer_widgets'];
$settings['footer_widgets'] = false;
foreach ( $sidebar_ids as $sidebar_id ) {
@@ -215,17 +242,19 @@ class The_Neverending_Home_Page {
$settings['footer_widgets'] = apply_filters( 'infinite_scroll_has_footer_widgets', $settings['footer_widgets'] );
// Finally, after all of the sidebar checks and filtering, ensure that a boolean value is present, otherwise set to default of `false`.
- if ( ! is_bool( $settings['footer_widgets'] ) )
+ if ( ! is_bool( $settings['footer_widgets'] ) ) {
$settings['footer_widgets'] = false;
+ }
// Ensure that IS is enabled and no footer widgets exist if the IS type isn't already "click".
- if ( 'click' != $settings['type'] ) {
+ if ( 'click' !== $settings['type'] ) {
// Check the setting status
$disabled = '' === get_option( self::$option_name_enabled ) ? true : false;
// Footer content or Reading option check
- if ( $settings['footer_widgets'] || $disabled )
+ if ( $settings['footer_widgets'] || $disabled ) {
$settings['type'] = 'click';
+ }
}
// Force display of the click handler and attendant bits when the type isn't `click`
@@ -256,7 +285,7 @@ class The_Neverending_Home_Page {
* @uses self::wp_query, self::get_settings, apply_filters
* @return int
*/
- static function posts_per_page() {
+ public static function posts_per_page() {
$posts_per_page = self::get_settings()->posts_per_page ? self::get_settings()->posts_per_page : self::wp_query()->get( 'posts_per_page' );
$posts_per_page_core_option = get_option( 'posts_per_page' );
@@ -295,7 +324,7 @@ class The_Neverending_Home_Page {
* @uses apply_filters
* @return object
*/
- static function wp_query() {
+ public static function wp_query() {
global $wp_the_query;
/**
* Filter the Infinite Scroll query object.
@@ -312,7 +341,7 @@ class The_Neverending_Home_Page {
/**
* Has infinite scroll been triggered?
*/
- static function got_infinity() {
+ public static function got_infinity() {
/**
* Filter the parameter used to check if Infinite Scroll has been triggered.
*
@@ -322,13 +351,13 @@ class The_Neverending_Home_Page {
*
* @param bool isset( $_GET[ 'infinity' ] ) Return true if the "infinity" parameter is set.
*/
- return apply_filters( 'infinite_scroll_got_infinity', isset( $_GET[ 'infinity' ] ) );
+ return apply_filters( 'infinite_scroll_got_infinity', isset( $_GET['infinity'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site.
}
/**
* Is this guaranteed to be the last batch of posts?
*/
- static function is_last_batch() {
+ public static function is_last_batch() {
/**
* Override whether or not this is the last batch for a request
*
@@ -345,11 +374,11 @@ class The_Neverending_Home_Page {
return $override;
}
- $entries = (int) self::wp_query()->found_posts;
+ $entries = (int) self::wp_query()->found_posts;
$posts_per_page = self::posts_per_page();
// This is to cope with an issue in certain themes or setups where posts are returned but found_posts is 0.
- if ( 0 == $entries ) {
+ if ( 0 === $entries ) {
return (bool) ( count( self::wp_query()->posts ) < $posts_per_page );
}
$paged = max( 1, self::wp_query()->get( 'paged' ) );
@@ -371,12 +400,16 @@ class The_Neverending_Home_Page {
/**
* The more tag will be ignored by default if the blog page isn't our homepage.
* Let's force the $more global to false.
+ *
+ * @param array $array - the_post array.
+ * @return array
*/
- function preserve_more_tag( $array ) {
+ public function preserve_more_tag( $array ) {
global $more;
- if ( self::got_infinity() )
- $more = 0; //0 = show content up to the more tag. Add more link.
+ if ( self::got_infinity() ) {
+ $more = 0; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- 0 = show content up to the more tag. Add more link.
+ }
return $array;
}
@@ -391,13 +424,15 @@ class The_Neverending_Home_Page {
* @action admin_init
* @return null
*/
- function settings_api_init() {
- if ( ! current_theme_supports( 'infinite-scroll' ) )
+ public function settings_api_init() {
+ if ( ! current_theme_supports( 'infinite-scroll' ) ) {
return;
+ }
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
// This setting is no longer configurable in wp-admin on WordPress.com -- leave a pointer
- add_settings_field( self::$option_name_enabled,
+ add_settings_field(
+ self::$option_name_enabled,
'<span id="infinite-scroll-options">' . esc_html__( 'Infinite Scroll Behavior', 'jetpack' ) . '</span>',
array( $this, 'infinite_setting_html_calypso_placeholder' ),
'reading'
@@ -410,7 +445,10 @@ class The_Neverending_Home_Page {
register_setting( 'reading', self::$option_name_enabled, 'esc_attr' );
}
- function infinite_setting_html_calypso_placeholder() {
+ /**
+ * Render the redirect link to the infinite scroll settings in Calypso.
+ */
+ public function infinite_setting_html_calypso_placeholder() {
$details = get_blog_details();
$writing_url = Redirect::get_url( 'calypso-settings-writing', array( 'site' => $details->domain ) );
echo '<span>' . sprintf(
@@ -425,14 +463,14 @@ class The_Neverending_Home_Page {
* HTML code to display a checkbox true/false option
* for the infinite_scroll setting.
*/
- function infinite_setting_html() {
- $notice = '<em>' . __( 'We&rsquo;ve changed this option to a click-to-scroll version for you since you have footer widgets in Appearance &rarr; Widgets, or your theme uses click-to-scroll as the default behavior.', 'jetpack' ) . '</em>';
+ public function infinite_setting_html() {
// If the blog has footer widgets, show a notice instead of the checkbox
- if ( self::get_settings()->footer_widgets || 'click' == self::get_settings()->requested_type ) {
- echo '<label>' . $notice . '</label>';
+ if ( self::get_settings()->footer_widgets || 'click' === self::get_settings()->requested_type ) {
+ echo '<label><em>' . esc_html__( 'We&rsquo;ve changed this option to a click-to-scroll version for you since you have footer widgets in Appearance &rarr; Widgets, or your theme uses click-to-scroll as the default behavior.', 'jetpack' ) . '</em></label>';
} else {
echo '<label><input name="infinite_scroll" type="checkbox" value="1" ' . checked( 1, '' !== get_option( self::$option_name_enabled ), false ) . ' /> ' . esc_html__( 'Check to load posts as you scroll. Uncheck to show clickable button to load posts', 'jetpack' ) . '</label>';
+ // translators: the number of posts to show on each page load.
echo '<p class="description">' . esc_html( sprintf( _n( 'Shows %s post on each load.', 'Shows %s posts on each load.', self::posts_per_page(), 'jetpack' ), number_format_i18n( self::posts_per_page() ) ) ) . '</p>';
}
}
@@ -444,16 +482,18 @@ class The_Neverending_Home_Page {
* @action template_redirect
* @return null
*/
- function action_template_redirect() {
+ public function action_template_redirect() {
// Check that we support infinite scroll, and are on the home page.
- if ( ! current_theme_supports( 'infinite-scroll' ) || ! self::archive_supports_infinity() )
+ if ( ! current_theme_supports( 'infinite-scroll' ) || ! self::archive_supports_infinity() ) {
return;
+ }
$id = self::get_settings()->container;
// Check that we have an id.
- if ( empty( $id ) )
+ if ( empty( $id ) ) {
return;
+ }
// AMP infinite scroll functionality will start on amp_load_hooks().
if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
@@ -521,15 +561,16 @@ class The_Neverending_Home_Page {
*
* @return string
*/
- function body_class() {
+ public function body_class() {
$classes = '';
// Do not add infinity-scroll class if disabled through the Reading page
$disabled = '' === get_option( self::$option_name_enabled ) ? true : false;
- if ( ! $disabled || 'click' == self::get_settings()->type ) {
+ if ( ! $disabled || 'click' === self::get_settings()->type ) {
$classes = 'infinite-scroll';
- if ( 'scroll' == self::get_settings()->type )
+ if ( 'scroll' === self::get_settings()->type ) {
$classes .= ' neverending';
+ }
}
return $classes;
@@ -543,20 +584,20 @@ class The_Neverending_Home_Page {
* @uses self::has_only_title_matching_posts
* @return array
*/
- function get_excluded_posts() {
+ public function get_excluded_posts() {
$excluded_posts = array();
- //loop through posts returned by wp_query call
- foreach( self::wp_query()->get_posts() as $post ) {
+ // loop through posts returned by wp_query call
+ foreach ( self::wp_query()->get_posts() as $post ) {
- $orderby = isset( self::wp_query()->query_vars['orderby'] ) ? self::wp_query()->query_vars['orderby'] : '';
+ $orderby = isset( self::wp_query()->query_vars['orderby'] ) ? self::wp_query()->query_vars['orderby'] : '';
$post_date = ( ! empty( $post->post_date ) ? $post->post_date : false );
if ( 'modified' === $orderby || false === $post_date ) {
$post_date = $post->post_modified;
}
- //in case all posts initially displayed match the keyword by title we add em all to excluded posts array
- //else, we add only posts which are older than last_post_date param as newer are natually excluded by last_post_date condition in the SQL query
+ // in case all posts initially displayed match the keyword by title we add em all to excluded posts array
+ // else, we add only posts which are older than last_post_date param as newer are natually excluded by last_post_date condition in the SQL query
if ( self::has_only_title_matching_posts() || $post_date <= self::get_last_post_date() ) {
array_push( $excluded_posts, $post->ID );
}
@@ -571,18 +612,18 @@ class The_Neverending_Home_Page {
* @uses self::get_excluded_posts
* @return array
*/
- function get_query_vars() {
+ public function get_query_vars() {
$query_vars = self::wp_query()->query_vars;
- //applies to search page only
+ // applies to search page only
if ( true === self::wp_query()->is_search() ) {
- //set post__not_in array in query_vars in case it does not exists
+ // set post__not_in array in query_vars in case it does not exists
if ( false === isset( $query_vars['post__not_in'] ) ) {
$query_vars['post__not_in'] = array();
}
- //get excluded posts
+ // get excluded posts
$excluded = self::get_excluded_posts();
- //merge them with other post__not_in posts (eg.: sticky posts)
+ // merge them with other post__not_in posts (eg.: sticky posts)
$query_vars['post__not_in'] = array_merge( $query_vars['post__not_in'], $excluded );
}
return $query_vars;
@@ -595,17 +636,17 @@ class The_Neverending_Home_Page {
* @uses self::wp_query
* @return bool
*/
- function has_only_title_matching_posts() {
+ public function has_only_title_matching_posts() {
- //apply following logic for search page results only
+ // apply following logic for search page results only
if ( false === self::wp_query()->is_search() ) {
return false;
}
- //grab the last posts in the stack as if the last one is title-matching the rest is title-matching as well
+ // grab the last posts in the stack as if the last one is title-matching the rest is title-matching as well
$post = end( self::wp_query()->posts );
- //code inspired by WP_Query class
+ // code inspired by WP_Query class
if ( preg_match_all( '/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', self::wp_query()->get( 's' ), $matches ) ) {
$search_terms = self::wp_query()->query_vars['search_terms'];
// if the search string has only short terms or stopwords, or is 10+ terms long, match it as sentence
@@ -616,7 +657,7 @@ class The_Neverending_Home_Page {
$search_terms = array( self::wp_query()->get( 's' ) );
}
- //actual testing. As search query combines multiple keywords with AND, it's enough to check if any of the keywords is present in the title
+ // actual testing. As search query combines multiple keywords with AND, it's enough to check if any of the keywords is present in the title
$term = current( $search_terms );
if ( ! empty( $term ) && false !== strpos( $post->post_title, $term ) ) {
return true;
@@ -636,21 +677,22 @@ class The_Neverending_Home_Page {
* @uses self::wp_query
* @return string 'Y-m-d H:i:s' or false
*/
- function get_last_post_date() {
- if ( self::got_infinity() )
+ public function get_last_post_date() {
+ if ( self::got_infinity() ) {
return;
+ }
if ( ! self::wp_query()->have_posts() ) {
return null;
}
- //In case there are only title-matching posts in the initial WP_Query result, we don't want to use the last_post_date param yet
+ // In case there are only title-matching posts in the initial WP_Query result, we don't want to use the last_post_date param yet
if ( true === self::has_only_title_matching_posts() ) {
return false;
}
- $post = end( self::wp_query()->posts );
- $orderby = isset( self::wp_query()->query_vars['orderby'] ) ?
+ $post = end( self::wp_query()->posts );
+ $orderby = isset( self::wp_query()->query_vars['orderby'] ) ?
self::wp_query()->query_vars['orderby'] : '';
$post_date = ( ! empty( $post->post_date ) ? $post->post_date : false );
switch ( $orderby ) {
@@ -668,13 +710,14 @@ class The_Neverending_Home_Page {
* Returns the appropriate `wp_posts` table field for a given query's
* 'orderby' parameter, if applicable.
*
- * @param optional object $query
+ * @param object $query - an optional query object.
* @uses self::wp_query
* @return string or false
*/
- function get_query_sort_field( $query = null ) {
- if ( empty( $query ) )
+ public function get_query_sort_field( $query = null ) {
+ if ( empty( $query ) ) {
$query = self::wp_query();
+ }
$orderby = isset( $query->query_vars['orderby'] ) ? $query->query_vars['orderby'] : '';
@@ -695,23 +738,23 @@ class The_Neverending_Home_Page {
* and we're sorting by post date.
*
* @global $wpdb
- * @param string $where
- * @param object $query
+ * @param string $where - the where clause.
+ * @param object $query - the query.
* @uses apply_filters
* @filter posts_where
* @return string
*/
- function query_time_filter( $where, $query ) {
+ public function query_time_filter( $where, $query ) {
if ( self::got_infinity() ) {
global $wpdb;
$sort_field = self::get_query_sort_field( $query );
- if ( 'post_date' !== $sort_field || 'DESC' !== $_REQUEST['query_args']['order'] ) {
+ if ( 'post_date' !== $sort_field || 'DESC' !== $_REQUEST['query_args']['order'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- no changes made to the site.
return $where;
}
- $query_before = sanitize_text_field( wp_unslash( $_REQUEST['query_before'] ) );
+ $query_before = sanitize_text_field( wp_unslash( $_REQUEST['query_before'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- no changes made to the site.
if ( empty( $query_before ) ) {
return $where;
@@ -732,8 +775,8 @@ class The_Neverending_Home_Page {
* @param string $operator @deprecated Query operator.
* @param string $last_post_date @deprecated Last Post Date timestamp.
*/
- $operator = 'ASC' === $_REQUEST['query_args']['order'] ? '>' : '<';
- $last_post_date = sanitize_text_field( wp_unslash( $_REQUEST['last_post_date'] ) );
+ $operator = 'ASC' === $_REQUEST['query_args']['order'] ? '>' : '<'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- no changes to the site.
+ $last_post_date = sanitize_text_field( wp_unslash( $_REQUEST['last_post_date'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- no changes to the site.
$where .= apply_filters( 'infinite_scroll_posts_where', $clause, $query, $operator, $last_post_date );
}
@@ -743,13 +786,13 @@ class The_Neverending_Home_Page {
/**
* Let's overwrite the default post_per_page setting to always display a fixed amount.
*
- * @param object $query
+ * @param object $query - the query.
* @uses is_admin, self::archive_supports_infinity, self::get_settings
- * @return null
*/
- function posts_per_page_query( $query ) {
- if ( ! is_admin() && self::archive_supports_infinity() && $query->is_main_query() )
+ public function posts_per_page_query( $query ) {
+ if ( ! is_admin() && self::archive_supports_infinity() && $query->is_main_query() ) {
$query->set( 'posts_per_page', self::posts_per_page() );
+ }
}
/**
@@ -759,7 +802,7 @@ class The_Neverending_Home_Page {
* @uses self::get_settings
* @return bool
*/
- function has_wrapper() {
+ public function has_wrapper() {
return (bool) self::get_settings()->wrapper;
}
@@ -770,7 +813,7 @@ class The_Neverending_Home_Page {
* @uses home_url, add_query_arg, apply_filters
* @return string
*/
- function ajax_url() {
+ public function ajax_url() {
$base_url = set_url_scheme( home_url( '/' ) );
$ajaxurl = add_query_arg( array( 'infinity' => 'scrolling' ), $base_url );
@@ -790,17 +833,18 @@ class The_Neverending_Home_Page {
/**
* Our own Ajax response, avoiding calling admin-ajax
*/
- function ajax_response() {
+ public function ajax_response() {
// Only proceed if the url query has a key of "Infinity"
- if ( ! self::got_infinity() )
+ if ( ! self::got_infinity() ) {
return false;
+ }
// This should already be defined below, but make sure.
if ( ! defined( 'DOING_AJAX' ) ) {
define( 'DOING_AJAX', true );
}
- @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
+ @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
send_nosniff_header();
/**
@@ -820,7 +864,7 @@ class The_Neverending_Home_Page {
* Previously, JS settings object was unnecessarily output in the document head.
* When the hook was changed, the method name no longer made sense.
*/
- function action_wp_head() {
+ public function action_wp_head() {
$this->action_wp_footer_settings();
}
@@ -830,9 +874,8 @@ class The_Neverending_Home_Page {
* @global $wp_rewrite
* @uses self::get_settings, esc_js, esc_url_raw, self::has_wrapper, __, apply_filters, do_action, self::get_query_vars
* @action wp_footer
- * @return string
*/
- function action_wp_footer_settings() {
+ public function action_wp_footer_settings() {
global $wp_rewrite;
global $currentday;
@@ -906,19 +949,20 @@ class The_Neverending_Home_Page {
'use_trailing_slashes' => $wp_rewrite->use_trailing_slashes,
'parameters' => self::get_request_parameters(),
),
- 'query_args' => self::get_query_vars(),
- 'query_before' => current_time( 'mysql' ),
- 'last_post_date' => self::get_last_post_date(),
- 'body_class' => self::body_class(),
- 'loading_text' => esc_js( __( 'Loading new page', 'jetpack' ) ),
+ 'query_args' => self::get_query_vars(),
+ 'query_before' => current_time( 'mysql' ),
+ 'last_post_date' => self::get_last_post_date(),
+ 'body_class' => self::body_class(),
+ 'loading_text' => esc_js( __( 'Loading new page', 'jetpack' ) ),
);
// Optional order param
- if ( isset( $_REQUEST['order'] ) ) {
- $order = strtoupper( $_REQUEST['order'] );
+ if ( isset( $_REQUEST['order'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site.
+ $order = strtoupper( sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site.
- if ( in_array( $order, array( 'ASC', 'DESC' ) ) )
+ if ( in_array( $order, array( 'ASC', 'DESC' ), true ) ) {
$js_settings['order'] = $order;
+ }
}
/**
@@ -943,15 +987,13 @@ class The_Neverending_Home_Page {
?>
<script type="text/javascript">
- //<![CDATA[
- var infiniteScroll = JSON.parse( decodeURIComponent( '<?php echo
- rawurlencode( json_encode( array( 'settings' => $js_settings ) ) );
- ?>' ) );
- //]]>
+ var infiniteScroll = <?php echo wp_json_encode( array( 'settings' => $js_settings ), JSON_HEX_TAG ); ?>;
</script>
<?php
}
+ // phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited
+
/**
* Build path data for current request.
* Used for Google Analytics and pushState history tracking.
@@ -968,23 +1010,26 @@ class The_Neverending_Home_Page {
global $wp;
// If called too early, bail
- if ( ! isset( $wp->request ) )
+ if ( ! isset( $wp->request ) ) {
return false;
+ }
// Determine path for paginated version of current request
- if ( false != preg_match( '#' . $wp_rewrite->pagination_base . '/\d+/?$#i', $wp->request ) )
- $path = preg_replace( '#' . $wp_rewrite->pagination_base . '/\d+$#i', $wp_rewrite->pagination_base . '/%d', $wp->request );
- else
+ if ( preg_match( '#' . preg_quote( $wp_rewrite->pagination_base, '#' ) . '/\d+/?$#i', $wp->request ) ) {
+ $path = preg_replace( '#' . preg_quote( $wp_rewrite->pagination_base, '#' ) . '/\d+$#i', $wp_rewrite->pagination_base . '/%d', $wp->request );
+ } else {
$path = $wp->request . '/' . $wp_rewrite->pagination_base . '/%d';
+ }
// Slashes everywhere we need them
- if ( 0 !== strpos( $path, '/' ) )
+ if ( 0 !== strpos( $path, '/' ) ) {
$path = '/' . $path;
+ }
$path = user_trailingslashit( $path );
} else {
// Clean up raw $_REQUEST input
- $path = array_map( 'sanitize_text_field', $_REQUEST );
+ $path = array_map( 'sanitize_text_field', wp_unslash( $_REQUEST ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- seems this is used for Google Analytics and browser history tracking.
$path = array_filter( $path );
$path['paged'] = '%d';
@@ -1001,10 +1046,11 @@ class The_Neverending_Home_Page {
* @return string
*/
private function get_request_parameters() {
- $uri = $_SERVER[ 'REQUEST_URI' ];
+ $uri = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
$uri = preg_replace( '/^[^?]*(\?.*$)/', '$1', $uri, 1, $count );
- if ( $count != 1 )
+ if ( $count !== 1 ) {
return '';
+ }
return $uri;
}
@@ -1014,9 +1060,8 @@ class The_Neverending_Home_Page {
*
* @global $wp_scripts, $wp_styles
* @action wp_footer
- * @return string
*/
- function action_wp_footer() {
+ public function action_wp_footer() {
global $wp_scripts, $wp_styles;
$scripts = is_a( $wp_scripts, 'WP_Scripts' ) ? $wp_scripts->done : array();
@@ -1043,7 +1088,8 @@ class The_Neverending_Home_Page {
*/
$styles = apply_filters( 'infinite_scroll_existing_stylesheets', $styles );
- ?><script type="text/javascript">
+ ?>
+ <script type="text/javascript">
(function() {
var extend = function(out) {
out = out || {};
@@ -1077,18 +1123,22 @@ class The_Neverending_Home_Page {
/**
* Identify additional scripts required by the latest set of IS posts and provide the necessary data to the IS response handler.
*
+ * @param array $results - the results.
+ * @param array $query_args - Array of Query arguments.
+ * @param array $wp_query - the WP query.
* @global $wp_scripts
* @uses sanitize_text_field, add_query_arg
* @filter infinite_scroll_results
* @return array
*/
- function filter_infinite_scroll_results( $results, $query_args, $wp_query ) {
+ public function filter_infinite_scroll_results( $results, $query_args, $wp_query ) {
// Don't bother unless there are posts to display
- if ( 'success' != $results['type'] )
+ if ( 'success' !== $results['type'] ) {
return $results;
+ }
// Parse and sanitize the script handles already output
- $initial_scripts = isset( $_REQUEST['scripts'] ) && is_array( $_REQUEST['scripts'] ) ? array_map( 'sanitize_text_field', $_REQUEST['scripts'] ) : false;
+ $initial_scripts = isset( $_REQUEST['scripts'] ) && is_array( $_REQUEST['scripts'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['scripts'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no site changes made.
if ( is_array( $initial_scripts ) ) {
global $wp_scripts;
@@ -1134,17 +1184,20 @@ class The_Neverending_Home_Page {
$src = $wp_scripts->registered[ $handle ]->src;
// Take base_url into account
- if ( strpos( $src, 'http' ) !== 0 )
+ if ( strpos( $src, 'http' ) !== 0 ) {
$src = $wp_scripts->base_url . $src;
+ }
// Version and additional arguments
- if ( null === $wp_scripts->registered[ $handle ]->ver )
+ if ( null === $wp_scripts->registered[ $handle ]->ver ) {
$ver = '';
- else
+ } else {
$ver = $wp_scripts->registered[ $handle ]->ver ? $wp_scripts->registered[ $handle ]->ver : $wp_scripts->default_version;
+ }
- if ( isset( $wp_scripts->args[ $handle ] ) )
- $ver = $ver ? $ver . '&amp;' . $wp_scripts->args[$handle] : $wp_scripts->args[$handle];
+ if ( isset( $wp_scripts->args[ $handle ] ) ) {
+ $ver = $ver ? $ver . '&amp;' . $wp_scripts->args[ $handle ] : $wp_scripts->args[ $handle ];
+ }
// Full script source with version info
$script_data['src'] = add_query_arg( 'ver', $ver, $src );
@@ -1156,8 +1209,9 @@ class The_Neverending_Home_Page {
}
// Expose additional script data to filters, but only include in final `$results` array if needed.
- if ( ! isset( $results['scripts'] ) )
+ if ( ! isset( $results['scripts'] ) ) {
$results['scripts'] = array();
+ }
/**
* Filter the additional scripts required by the latest set of IS posts.
@@ -1181,11 +1235,12 @@ class The_Neverending_Home_Page {
$wp_query
);
- if ( empty( $results['scripts'] ) )
- unset( $results['scripts' ] );
+ if ( empty( $results['scripts'] ) ) {
+ unset( $results['scripts'] );
+ }
// Parse and sanitize the style handles already output
- $initial_styles = isset( $_REQUEST['styles'] ) && is_array( $_REQUEST['styles'] ) ? array_map( 'sanitize_text_field', $_REQUEST['styles'] ) : false;
+ $initial_styles = isset( $_REQUEST['styles'] ) && is_array( $_REQUEST['styles'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['styles'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( is_array( $initial_styles ) ) {
global $wp_styles;
@@ -1199,30 +1254,34 @@ class The_Neverending_Home_Page {
foreach ( $new_styles as $handle ) {
// Abort if somehow the handle doesn't correspond to a registered stylesheet
- if ( ! isset( $wp_styles->registered[ $handle ] ) )
+ if ( ! isset( $wp_styles->registered[ $handle ] ) ) {
continue;
+ }
// Provide basic style data
$style_data = array(
'handle' => $handle,
- 'media' => 'all'
+ 'media' => 'all',
);
// Base source
$src = $wp_styles->registered[ $handle ]->src;
// Take base_url into account
- if ( strpos( $src, 'http' ) !== 0 )
+ if ( strpos( $src, 'http' ) !== 0 ) {
$src = $wp_styles->base_url . $src;
+ }
// Version and additional arguments
- if ( null === $wp_styles->registered[ $handle ]->ver )
+ if ( null === $wp_styles->registered[ $handle ]->ver ) {
$ver = '';
- else
+ } else {
$ver = $wp_styles->registered[ $handle ]->ver ? $wp_styles->registered[ $handle ]->ver : $wp_styles->default_version;
+ }
- if ( isset($wp_styles->args[ $handle ] ) )
- $ver = $ver ? $ver . '&amp;' . $wp_styles->args[$handle] : $wp_styles->args[$handle];
+ if ( isset( $wp_styles->args[ $handle ] ) ) {
+ $ver = $ver ? $ver . '&amp;' . $wp_styles->args[ $handle ] : $wp_styles->args[ $handle ];
+ }
// Full stylesheet source with version info
$style_data['src'] = add_query_arg( 'ver', $ver, $src );
@@ -1230,17 +1289,21 @@ class The_Neverending_Home_Page {
// Parse stylesheet's conditional comments if present, converting to logic executable in JS
if ( isset( $wp_styles->registered[ $handle ]->extra['conditional'] ) && $wp_styles->registered[ $handle ]->extra['conditional'] ) {
// First, convert conditional comment operators to standard logical operators. %ver is replaced in JS with the IE version
- $style_data['conditional'] = str_replace( array(
- 'lte',
- 'lt',
- 'gte',
- 'gt'
- ), array(
- '%ver <=',
- '%ver <',
- '%ver >=',
- '%ver >',
- ), $wp_styles->registered[ $handle ]->extra['conditional'] );
+ $style_data['conditional'] = str_replace(
+ array(
+ 'lte',
+ 'lt',
+ 'gte',
+ 'gt',
+ ),
+ array(
+ '%ver <=',
+ '%ver <',
+ '%ver >=',
+ '%ver >',
+ ),
+ $wp_styles->registered[ $handle ]->extra['conditional']
+ );
// Next, replace any !IE checks. These shouldn't be present since WP's conditional stylesheet implementation doesn't support them, but someone could be _doing_it_wrong().
$style_data['conditional'] = preg_replace( '#!\s*IE(\s*\d+){0}#i', '1==2', $style_data['conditional'] );
@@ -1250,8 +1313,9 @@ class The_Neverending_Home_Page {
}
// Parse requested media context for stylesheet
- if ( isset( $wp_styles->registered[ $handle ]->args ) )
+ if ( isset( $wp_styles->registered[ $handle ]->args ) ) {
$style_data['media'] = esc_attr( $wp_styles->registered[ $handle ]->args );
+ }
// Add stylesheet to data that will be returned to IS JS
array_push( $results['styles'], $style_data );
@@ -1260,8 +1324,9 @@ class The_Neverending_Home_Page {
}
// Expose additional stylesheet data to filters, but only include in final `$results` array if needed.
- if ( ! isset( $results['styles'] ) )
+ if ( ! isset( $results['styles'] ) ) {
$results['styles'] = array();
+ }
/**
* Filter the additional styles required by the latest set of IS posts.
@@ -1285,8 +1350,9 @@ class The_Neverending_Home_Page {
$wp_query
);
- if ( empty( $results['styles'] ) )
- unset( $results['styles' ] );
+ if ( empty( $results['styles'] ) ) {
+ unset( $results['styles'] );
+ }
// Lastly, return the IS results array
return $results;
@@ -1299,32 +1365,37 @@ class The_Neverending_Home_Page {
* @global $wp_query
* @global $wp_the_query
* @uses current_theme_supports, get_option, self::wp_query, current_user_can, apply_filters, self::get_settings, add_filter, WP_Query, remove_filter, have_posts, wp_head, do_action, add_action, this::render, this::has_wrapper, esc_attr, wp_footer, sharing_register_post_for_share_counts, get_the_id
- * @return string or null
*/
- function query() {
- if ( ! isset( $_REQUEST['page'] ) || ! current_theme_supports( 'infinite-scroll' ) )
+ public function query() {
+ if ( ! isset( $_REQUEST['page'] ) || ! current_theme_supports( 'infinite-scroll' ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes to the site.
die;
+ }
- $page = (int) $_REQUEST['page'];
+ // @todo see if we should validate this nonce since we use it to form a query.
+ $page = (int) $_REQUEST['page']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- we're casting this to an int and not making changes to the site.
// Sanitize and set $previousday. Expected format: dd.mm.yy
- if ( preg_match( '/^\d{2}\.\d{2}\.\d{2}$/', $_REQUEST['currentday'] ) ) {
+ if ( isset( $_REQUEST['currentday'] ) && preg_match( '/^\d{2}\.\d{2}\.\d{2}$/', $_REQUEST['currentday'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput, WordPress.Security.NonceVerification.Recommended -- manually validating, no changes to site
global $previousday;
- $previousday = $_REQUEST['currentday'];
+ $previousday = $_REQUEST['currentday']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput
}
$post_status = array( 'publish' );
- if ( current_user_can( 'read_private_posts' ) )
+ if ( current_user_can( 'read_private_posts' ) ) {
array_push( $post_status, 'private' );
+ }
- $order = in_array( $_REQUEST['order'], array( 'ASC', 'DESC' ) ) ? $_REQUEST['order'] : 'DESC';
+ $order = isset( $_REQUEST['order'] ) && in_array( $_REQUEST['order'], array( 'ASC', 'DESC' ), true ) ? sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ) : 'DESC'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes made to the site.
- $query_args = array_merge( self::wp_query()->query_vars, array(
- 'paged' => $page,
- 'post_status' => $post_status,
- 'posts_per_page' => self::posts_per_page(),
- 'order' => $order
- ) );
+ $query_args = array_merge(
+ self::wp_query()->query_vars,
+ array(
+ 'paged' => $page,
+ 'post_status' => $post_status,
+ 'posts_per_page' => self::posts_per_page(), // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
+ 'order' => $order,
+ )
+ );
// 4.0 ?s= compatibility, see https://core.trac.wordpress.org/ticket/11330#comment:50
if ( empty( $query_args['s'] ) && ! isset( self::wp_query()->query['s'] ) ) {
@@ -1349,7 +1420,9 @@ class The_Neverending_Home_Page {
add_filter( 'posts_where', array( $this, 'query_time_filter' ), 10, 2 );
- $GLOBALS['wp_the_query'] = $GLOBALS['wp_query'] = $infinite_scroll_query = new WP_Query();
+ $infinite_scroll_query = new WP_Query();
+ $GLOBALS['wp_the_query'] = $infinite_scroll_query;
+ $GLOBALS['wp_query'] = $infinite_scroll_query;
$infinite_scroll_query->query( $query_args );
@@ -1427,10 +1500,10 @@ class The_Neverending_Home_Page {
do_action( 'infinite_scroll_empty' );
$results['type'] = 'empty';
} elseif ( $this->has_wrapper() ) {
- $wrapper_classes = is_string( self::get_settings()->wrapper ) ? self::get_settings()->wrapper : 'infinite-wrap';
+ $wrapper_classes = is_string( self::get_settings()->wrapper ) ? self::get_settings()->wrapper : 'infinite-wrap';
$wrapper_classes .= ' infinite-view-' . $page;
- $wrapper_classes = trim( $wrapper_classes );
- $aria_label = sprintf(
+ $wrapper_classes = trim( $wrapper_classes );
+ $aria_label = sprintf(
/* translators: %1$s is the page count */
__( 'Page: %1$d.', 'jetpack' ),
$page
@@ -1446,17 +1519,17 @@ class The_Neverending_Home_Page {
ob_end_clean();
}
- if ( 'success' == $results['type'] ) {
+ if ( 'success' === $results['type'] ) {
global $currentday;
- $results['lastbatch'] = self::is_last_batch();
+ $results['lastbatch'] = self::is_last_batch();
$results['currentday'] = $currentday;
}
// Loop through posts to capture sharing data for new posts loaded via Infinite Scroll
- if ( 'success' == $results['type'] && function_exists( 'sharing_register_post_for_share_counts' ) ) {
+ if ( 'success' === $results['type'] && function_exists( 'sharing_register_post_for_share_counts' ) ) {
global $jetpack_sharing_counts;
- while( have_posts() ) {
+ while ( have_posts() ) {
the_post();
sharing_register_post_for_share_counts( get_the_ID() );
@@ -1491,18 +1564,18 @@ class The_Neverending_Home_Page {
* query vars, as well as taxonomy vars
*
* @global $wp
- * @param array $allowed_vars
+ * @param array $allowed_vars - the allowed variables array.
* @filter infinite_scroll_allowed_vars
* @return array
*/
- function allowed_query_vars( $allowed_vars ) {
+ public function allowed_query_vars( $allowed_vars ) {
global $wp;
$allowed_vars += $wp->public_query_vars;
$allowed_vars += $wp->private_query_vars;
$allowed_vars += $this->get_taxonomy_vars();
- foreach ( array_keys( $allowed_vars, 'paged' ) as $key ) {
+ foreach ( array_keys( $allowed_vars, 'paged', true ) as $key ) {
unset( $allowed_vars[ $key ] );
}
@@ -1515,13 +1588,14 @@ class The_Neverending_Home_Page {
* @global $wp_taxonomies
* @return array
*/
- function get_taxonomy_vars() {
+ public function get_taxonomy_vars() {
global $wp_taxonomies;
$taxonomy_vars = array();
- foreach ( $wp_taxonomies as $taxonomy => $t ) {
- if ( $t->query_var )
+ foreach ( $wp_taxonomies as $t ) {
+ if ( $t->query_var ) {
$taxonomy_vars[] = $t->query_var;
+ }
}
// still needed?
@@ -1533,11 +1607,11 @@ class The_Neverending_Home_Page {
/**
* Update the $query_args array with the parameters provided via AJAX/GET.
*
- * @param array $query_args
+ * @param array $query_args - the query args.
* @filter infinite_scroll_query_args
* @return array
*/
- function inject_query_args( $query_args ) {
+ public function inject_query_args( $query_args ) {
/**
* Filter the array of allowed Infinite Scroll query arguments.
*
@@ -1550,14 +1624,18 @@ class The_Neverending_Home_Page {
*/
$allowed_vars = apply_filters( 'infinite_scroll_allowed_vars', array(), $query_args );
- $query_args = array_merge( $query_args, array(
- 'suppress_filters' => false,
- ) );
+ $query_args = array_merge(
+ $query_args,
+ array(
+ 'suppress_filters' => false,
+ )
+ );
- if ( is_array( $_REQUEST[ 'query_args' ] ) ) {
- foreach ( $_REQUEST[ 'query_args' ] as $var => $value ) {
- if ( in_array( $var, $allowed_vars ) && ! empty( $value ) )
- $query_args[ $var ] = $value;
+ if ( isset( $_REQUEST['query_args'] ) && is_array( $_REQUEST['query_args'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no site changes.
+ foreach ( wp_unslash( $_REQUEST['query_args'] ) as $var => $value ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- no site changes, sanitized below.
+ if ( in_array( $var, $allowed_vars, true ) && ! empty( $value ) ) {
+ $query_args[ $var ] = filter_var( $value );
+ }
}
}
@@ -1569,9 +1647,8 @@ class The_Neverending_Home_Page {
*
* @uses have_posts, the_post, get_template_part, get_post_format
* @action infinite_scroll_render
- * @return string
*/
- function render() {
+ public function render() {
while ( have_posts() ) {
the_post();
@@ -1612,36 +1689,37 @@ class The_Neverending_Home_Page {
* @uses self::get_settings, self::archive_supports_infinity, self::default_footer
* @return string or null
*/
- function footer() {
+ public function footer() {
if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
return;
}
// Bail if theme requested footer not show
- if ( false == self::get_settings()->footer )
+ if ( false === self::get_settings()->footer ) {
return;
+ }
// We only need the new footer for the 'scroll' type
- if ( 'scroll' != self::get_settings()->type || ! self::archive_supports_infinity() )
+ if ( 'scroll' !== self::get_settings()->type || ! self::archive_supports_infinity() ) {
return;
+ }
if ( self::is_last_batch() ) {
return;
}
// Display a footer, either user-specified or a default
- if ( false !== self::get_settings()->footer_callback && is_callable( self::get_settings()->footer_callback ) )
+ if ( false !== self::get_settings()->footer_callback && is_callable( self::get_settings()->footer_callback ) ) {
call_user_func( self::get_settings()->footer_callback, self::get_settings() );
- else
+ } else {
self::default_footer();
+ }
}
/**
* Render default IS footer
*
* @uses __, wp_get_theme, apply_filters, home_url, esc_attr, get_bloginfo, bloginfo
- * @return string
- *
*/
private function default_footer() {
if ( '' !== get_privacy_policy_url() ) {
@@ -1673,12 +1751,12 @@ class The_Neverending_Home_Page {
<div id="infinite-footer">
<div class="container">
<div class="blog-info">
- <a id="infinity-blog-title" href="<?php echo home_url( '/' ); ?>" rel="home">
+ <a id="infinity-blog-title" href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
<?php bloginfo( 'name' ); ?>
</a>
</div>
<div class="blog-credits">
- <?php echo $credits; ?>
+ <?php echo $credits; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</div>
</div><!-- #infinite-footer -->
@@ -1689,7 +1767,7 @@ class The_Neverending_Home_Page {
* Ensure that IS doesn't interfere with Grunion by stripping IS query arguments from the Grunion redirect URL.
* When arguments are present, Grunion redirects to the IS AJAX endpoint.
*
- * @param string $url
+ * @param string $url - the Grunion redirect URL.
* @uses remove_query_arg
* @filter grunion_contact_form_redirect_url
* @return string
@@ -1697,14 +1775,17 @@ class The_Neverending_Home_Page {
public function filter_grunion_redirect_url( $url ) {
// Remove IS query args, if present
if ( false !== strpos( $url, 'infinity=scrolling' ) ) {
- $url = remove_query_arg( array(
- 'infinity',
- 'action',
- 'page',
- 'order',
- 'scripts',
- 'styles'
- ), $url );
+ $url = remove_query_arg(
+ array(
+ 'infinity',
+ 'action',
+ 'page',
+ 'order',
+ 'scripts',
+ 'styles',
+ ),
+ $url
+ );
}
return $url;
@@ -2000,14 +2081,15 @@ class The_Neverending_Home_Page {
protected static function amp_is_last_page() {
return 0 === static::amp_get_max_pages();
}
-};
+}
/**
* Initialize The_Neverending_Home_Page
*/
function the_neverending_home_page_init() {
- if ( ! current_theme_supports( 'infinite-scroll' ) )
+ if ( ! current_theme_supports( 'infinite-scroll' ) ) {
return;
+ }
new The_Neverending_Home_Page();
}
@@ -2038,10 +2120,11 @@ function the_neverending_home_page_theme_support() {
* @param string $str IS compatibility file path.
* @param string $theme_name Theme name.
*/
- $customization_file = apply_filters( 'infinite_scroll_customization_file', dirname( __FILE__ ) . "/themes/{$theme_name}.php", $theme_name );
+ $customization_file = apply_filters( 'infinite_scroll_customization_file', __DIR__ . "/themes/{$theme_name}.php", $theme_name );
- if ( is_readable( $customization_file ) )
- require_once( $customization_file );
+ if ( is_readable( $customization_file ) ) {
+ require_once $customization_file;
+ }
}
add_action( 'after_setup_theme', 'the_neverending_home_page_theme_support', 5 );
@@ -2055,7 +2138,7 @@ if ( The_Neverending_Home_Page::got_infinity() ) {
*/
if ( ! defined( 'DOING_AJAX' ) &&
isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) &&
- strtoupper( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'XMLHTTPREQUEST'
+ strtoupper( sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REQUESTED_WITH'] ) ) ) === 'XMLHTTPREQUEST'
) {
define( 'DOING_AJAX', true );
}
diff --git a/plugins/jetpack/modules/infinite-scroll/themes/twentyeleven.php b/plugins/jetpack/modules/infinite-scroll/themes/twentyeleven.php
index 42a69b2d..f801cfc2 100644
--- a/plugins/jetpack/modules/infinite-scroll/themes/twentyeleven.php
+++ b/plugins/jetpack/modules/infinite-scroll/themes/twentyeleven.php
@@ -3,17 +3,22 @@
* Infinite Scroll Theme Assets
*
* Register support for @Twenty Eleven and enqueue relevant styles.
+ *
+ * @package jetpack
*/
/**
* Add theme support for infinity scroll
*/
function jetpack_twentyeleven_infinite_scroll_init() {
- add_theme_support( 'infinite-scroll', array(
- 'container' => 'content',
- 'footer' => 'page',
- 'footer_widgets' => jetpack_twentyeleven_has_footer_widgets(),
- ) );
+ add_theme_support(
+ 'infinite-scroll',
+ array(
+ 'container' => 'content',
+ 'footer' => 'page',
+ 'footer_widgets' => jetpack_twentyeleven_has_footer_widgets(),
+ )
+ );
}
add_action( 'init', 'jetpack_twentyeleven_infinite_scroll_init' );
@@ -33,12 +38,14 @@ add_action( 'wp_enqueue_scripts', 'jetpack_twentyeleven_infinite_scroll_enqueue_
*/
function jetpack_twentyeleven_has_footer_widgets() {
// Are any of the "Footer Area" sidebars active?
- if ( is_active_sidebar( 'sidebar-3' ) || is_active_sidebar( 'sidebar-4' ) || is_active_sidebar( 'sidebar-5' ) )
+ if ( is_active_sidebar( 'sidebar-3' ) || is_active_sidebar( 'sidebar-4' ) || is_active_sidebar( 'sidebar-5' ) ) {
return true;
+ }
// If we're on mobile and the Main Sidebar has widgets, it falls below the content, so we have footer widgets.
- if ( function_exists( 'jetpack_is_mobile' ) && jetpack_is_mobile() && is_active_sidebar( 'sidebar-1' ) )
+ if ( function_exists( 'jetpack_is_mobile' ) && jetpack_is_mobile() && is_active_sidebar( 'sidebar-1' ) ) {
return true;
+ }
return false;
}
diff --git a/plugins/jetpack/modules/infinite-scroll/themes/twentyfifteen.php b/plugins/jetpack/modules/infinite-scroll/themes/twentyfifteen.php
index d917dd56..fec19025 100644
--- a/plugins/jetpack/modules/infinite-scroll/themes/twentyfifteen.php
+++ b/plugins/jetpack/modules/infinite-scroll/themes/twentyfifteen.php
@@ -3,16 +3,21 @@
* Infinite Scroll Theme Assets
*
* Register support for Twenty Fifteen.
+ *
+ * @package jetpack
*/
/**
* Add theme support for infinite scroll
*/
function jetpack_twentyfifteen_infinite_scroll_init() {
- add_theme_support( 'infinite-scroll', array(
- 'container' => 'main',
- 'footer' => 'page',
- ) );
+ add_theme_support(
+ 'infinite-scroll',
+ array(
+ 'container' => 'main',
+ 'footer' => 'page',
+ )
+ );
}
add_action( 'after_setup_theme', 'jetpack_twentyfifteen_infinite_scroll_init' );
diff --git a/plugins/jetpack/modules/infinite-scroll/themes/twentyfourteen.php b/plugins/jetpack/modules/infinite-scroll/themes/twentyfourteen.php
index c9710abd..1ca9f606 100644
--- a/plugins/jetpack/modules/infinite-scroll/themes/twentyfourteen.php
+++ b/plugins/jetpack/modules/infinite-scroll/themes/twentyfourteen.php
@@ -3,6 +3,8 @@
* Infinite Scroll Theme Assets
*
* Register support for Twenty Fourteen.
+ *
+ * @package jetpack
*/
use Automattic\Jetpack\Device_Detection\User_Agent_Info;
@@ -11,11 +13,14 @@ use Automattic\Jetpack\Device_Detection\User_Agent_Info;
* Add theme support for infinite scroll
*/
function jetpack_twentyfourteen_infinite_scroll_init() {
- add_theme_support( 'infinite-scroll', array(
- 'container' => 'content',
- 'footer' => 'page',
- 'footer_widgets' => jetpack_twentyfourteen_has_footer_widgets(),
- ) );
+ add_theme_support(
+ 'infinite-scroll',
+ array(
+ 'container' => 'content',
+ 'footer' => 'page',
+ 'footer_widgets' => jetpack_twentyfourteen_has_footer_widgets(),
+ )
+ );
}
add_action( 'after_setup_theme', 'jetpack_twentyfourteen_infinite_scroll_init' );
@@ -31,9 +36,10 @@ function jetpack_twentyfourteen_has_footer_widgets() {
if ( function_exists( 'jetpack_is_mobile' ) ) {
if ( ( User_Agent_Info::is_ipad() && is_active_sidebar( 'sidebar-1' ) )
|| ( jetpack_is_mobile( '', true ) && ( is_active_sidebar( 'sidebar-1' ) || is_active_sidebar( 'sidebar-2' ) ) )
- || is_active_sidebar( 'sidebar-3' ) )
+ || is_active_sidebar( 'sidebar-3' ) ) {
return true;
+ }
}
return false;
diff --git a/plugins/jetpack/modules/infinite-scroll/themes/twentyseventeen.php b/plugins/jetpack/modules/infinite-scroll/themes/twentyseventeen.php
index ca4c64c7..f72811c9 100644
--- a/plugins/jetpack/modules/infinite-scroll/themes/twentyseventeen.php
+++ b/plugins/jetpack/modules/infinite-scroll/themes/twentyseventeen.php
@@ -3,18 +3,23 @@
* Infinite Scroll Theme Assets
*
* Register support for Twenty Seventeen.
+ *
+ * @package jetpack
*/
/**
* Add theme support for infinite scroll
*/
function jetpack_twentyseventeen_infinite_scroll_init() {
- add_theme_support( 'infinite-scroll', array(
- 'container' => 'main',
- 'render' => 'jetpack_twentyseventeen_infinite_scroll_render',
- 'footer' => 'content',
- 'footer_widgets' => jetpack_twentyseventeen_has_footer_widgets(),
- ) );
+ add_theme_support(
+ 'infinite-scroll',
+ array(
+ 'container' => 'main',
+ 'render' => 'jetpack_twentyseventeen_infinite_scroll_render',
+ 'footer' => 'content',
+ 'footer_widgets' => jetpack_twentyseventeen_has_footer_widgets(),
+ )
+ );
}
add_action( 'init', 'jetpack_twentyseventeen_infinite_scroll_init' );
@@ -37,8 +42,8 @@ function jetpack_twentyseventeen_infinite_scroll_render() {
*/
function jetpack_twentyseventeen_has_footer_widgets() {
if ( is_active_sidebar( 'sidebar-2' ) ||
- is_active_sidebar( 'sidebar-3' ) ||
- has_nav_menu( 'social' ) ) {
+ is_active_sidebar( 'sidebar-3' ) ||
+ has_nav_menu( 'social' ) ) {
return true;
}
diff --git a/plugins/jetpack/modules/infinite-scroll/themes/twentysixteen.php b/plugins/jetpack/modules/infinite-scroll/themes/twentysixteen.php
index df0c14e9..f05c86f5 100644
--- a/plugins/jetpack/modules/infinite-scroll/themes/twentysixteen.php
+++ b/plugins/jetpack/modules/infinite-scroll/themes/twentysixteen.php
@@ -3,17 +3,22 @@
* Infinite Scroll Theme Assets
*
* Register support for Twenty Sixteen.
+ *
+ * @package jetpack
*/
/**
* Add theme support for infinite scroll
*/
function jetpack_twentysixteen_infinite_scroll_init() {
- add_theme_support( 'infinite-scroll', array(
- 'container' => 'main',
- 'render' => 'jetpack_twentysixteen_infinite_scroll_render',
- 'footer' => 'content',
- ) );
+ add_theme_support(
+ 'infinite-scroll',
+ array(
+ 'container' => 'main',
+ 'render' => 'jetpack_twentysixteen_infinite_scroll_render',
+ 'footer' => 'content',
+ )
+ );
}
add_action( 'after_setup_theme', 'jetpack_twentysixteen_infinite_scroll_init' );
diff --git a/plugins/jetpack/modules/infinite-scroll/themes/twentyten.php b/plugins/jetpack/modules/infinite-scroll/themes/twentyten.php
index b6128707..cdc2621a 100644
--- a/plugins/jetpack/modules/infinite-scroll/themes/twentyten.php
+++ b/plugins/jetpack/modules/infinite-scroll/themes/twentyten.php
@@ -3,18 +3,23 @@
* Infinite Scroll Theme Assets
*
* Register support for @Twenty Ten and enqueue relevant styles.
+ *
+ * @package jetpack
*/
/**
* Add theme support for infinity scroll
*/
function jetpack_twentyten_infinite_scroll_init() {
- add_theme_support( 'infinite-scroll', array(
- 'container' => 'content',
- 'render' => 'jetpack_twentyten_infinite_scroll_render',
- 'footer' => 'wrapper',
- 'footer_widgets' => jetpack_twentyten_has_footer_widgets(),
- ) );
+ add_theme_support(
+ 'infinite-scroll',
+ array(
+ 'container' => 'content',
+ 'render' => 'jetpack_twentyten_infinite_scroll_render',
+ 'footer' => 'wrapper',
+ 'footer_widgets' => jetpack_twentyten_has_footer_widgets(),
+ )
+ );
}
add_action( 'init', 'jetpack_twentyten_infinite_scroll_init' );
@@ -45,7 +50,7 @@ add_action( 'wp_enqueue_scripts', 'jetpack_twentyten_infinite_scroll_enqueue_sty
function jetpack_twentyten_has_footer_widgets() {
if ( is_active_sidebar( 'first-footer-widget-area' ) ||
is_active_sidebar( 'second-footer-widget-area' ) ||
- is_active_sidebar( 'third-footer-widget-area' ) ||
+ is_active_sidebar( 'third-footer-widget-area' ) ||
is_active_sidebar( 'fourth-footer-widget-area' ) ) {
return true;
diff --git a/plugins/jetpack/modules/infinite-scroll/themes/twentythirteen.php b/plugins/jetpack/modules/infinite-scroll/themes/twentythirteen.php
index 803b31bb..bf13f065 100644
--- a/plugins/jetpack/modules/infinite-scroll/themes/twentythirteen.php
+++ b/plugins/jetpack/modules/infinite-scroll/themes/twentythirteen.php
@@ -3,17 +3,22 @@
* Infinite Scroll Theme Assets
*
* Register support for Twenty Thirteen.
+ *
+ * @package jetpack
*/
/**
* Add theme support for infinite scroll
*/
function jetpack_twentythirteen_infinite_scroll_init() {
- add_theme_support( 'infinite-scroll', array(
- 'container' => 'content',
- 'footer' => 'page',
- 'footer_widgets' => array( 'sidebar-1' ),
- ) );
+ add_theme_support(
+ 'infinite-scroll',
+ array(
+ 'container' => 'content',
+ 'footer' => 'page',
+ 'footer_widgets' => array( 'sidebar-1' ),
+ )
+ );
}
add_action( 'after_setup_theme', 'jetpack_twentythirteen_infinite_scroll_init' );
diff --git a/plugins/jetpack/modules/infinite-scroll/themes/twentytwelve.php b/plugins/jetpack/modules/infinite-scroll/themes/twentytwelve.php
index b8b17b3f..8edc335a 100644
--- a/plugins/jetpack/modules/infinite-scroll/themes/twentytwelve.php
+++ b/plugins/jetpack/modules/infinite-scroll/themes/twentytwelve.php
@@ -3,17 +3,22 @@
* Infinite Scroll Theme Assets
*
* Register support for Twenty Twelve and enqueue relevant styles.
+ *
+ * @package jetpack
*/
/**
* Add theme support for infinite scroll
*/
function jetpack_twentytwelve_infinite_scroll_init() {
- add_theme_support( 'infinite-scroll', array(
- 'container' => 'content',
- 'footer' => 'page',
- 'footer_widgets' => jetpack_twentytwelve_has_footer_widgets(),
- ) );
+ add_theme_support(
+ 'infinite-scroll',
+ array(
+ 'container' => 'content',
+ 'footer' => 'page',
+ 'footer_widgets' => jetpack_twentytwelve_has_footer_widgets(),
+ )
+ );
}
add_action( 'after_setup_theme', 'jetpack_twentytwelve_infinite_scroll_init' );
@@ -33,10 +38,11 @@ add_action( 'wp_enqueue_scripts', 'jetpack_twentytwelve_infinite_scroll_enqueue_
*/
function jetpack_twentytwelve_has_footer_widgets() {
if ( function_exists( 'jetpack_is_mobile' ) && jetpack_is_mobile() ) {
- if ( is_front_page() && ( is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-3' ) ) )
+ if ( is_front_page() && ( is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-3' ) ) ) {
return true;
- elseif ( is_active_sidebar( 'sidebar-1' ) )
+ } elseif ( is_active_sidebar( 'sidebar-1' ) ) {
return true;
+ }
}
return false;
diff --git a/plugins/jetpack/modules/latex.php b/plugins/jetpack/modules/latex.php
index 3257fdf3..3658e4df 100644
--- a/plugins/jetpack/modules/latex.php
+++ b/plugins/jetpack/modules/latex.php
@@ -9,6 +9,8 @@
* Module Tags: Writing
* Feature: Writing
* Additional Search Queries: latex, math, equation, equations, formula, code
+ *
+ * @package automattic/jetpack
*/
/**
@@ -21,6 +23,11 @@
* $latex [a, b]$ -> [latex][a, b][/latex]
*/
+/**
+ * Markup LaTeX content.
+ *
+ * @param string $content Post or comment contents to markup.
+ */
function latex_markup( $content ) {
$textarr = wp_html_split( $content );
@@ -35,7 +42,7 @@ function latex_markup( $content ) {
%ix';
foreach ( $textarr as &$element ) {
- if ( '' == $element || '<' === $element[0] ) {
+ if ( '' === $element || '<' === $element[0] ) {
continue;
}
@@ -49,36 +56,51 @@ function latex_markup( $content ) {
return implode( '', $textarr );
}
+/**
+ * Process LaTeX string to rendered image.
+ *
+ * @param array $matches Matched regex results.
+ */
function latex_src( $matches ) {
$latex = $matches[1];
$bg = latex_get_default_color( 'bg' );
$fg = latex_get_default_color( 'text', '000' );
- $s = 0;
-
+ $s = 0;
$latex = latex_entity_decode( $latex );
if ( preg_match( '/.+(&fg=[0-9a-f]{6}).*/i', $latex, $fg_matches ) ) {
- $fg = substr( $fg_matches[1], 4 );
+ $fg = substr( $fg_matches[1], 4 );
$latex = str_replace( $fg_matches[1], '', $latex );
}
if ( preg_match( '/.+(&bg=[0-9a-f]{6}).*/i', $latex, $bg_matches ) ) {
- $bg = substr( $bg_matches[1], 4 );
+ $bg = substr( $bg_matches[1], 4 );
$latex = str_replace( $bg_matches[1], '', $latex );
}
if ( preg_match( '/.+(&s=[0-9-]{1,2}).*/i', $latex, $s_matches ) ) {
- $s = (int) substr( $s_matches[1], 3 );
+ $s = (int) substr( $s_matches[1], 3 );
$latex = str_replace( $s_matches[1], '', $latex );
}
return latex_render( $latex, $fg, $bg, $s );
}
+/**
+ * Get the default color for an attribute.
+ *
+ * @param string $color Attribute to color (e.g. bg).
+ * @param string $default_color Default fallback color to use.
+ */
function latex_get_default_color( $color, $default_color = 'ffffff' ) {
global $themecolors;
- return isset($themecolors[$color]) ? $themecolors[$color] : $default_color;
+ return isset( $themecolors[ $color ] ) ? $themecolors[ $color ] : $default_color;
}
+/**
+ * Decode special characters in a LaTeX string.
+ *
+ * @param string $latex Character encoded content.
+ */
function latex_entity_decode( $latex ) {
return str_replace( array( '&lt;', '&gt;', '&quot;', '&#039;', '&#038;', '&amp;', "\n", "\r" ), array( '<', '>', '"', "'", '&', '&', ' ', ' ' ), $latex );
}
@@ -121,6 +143,9 @@ function latex_render( $latex, $fg, $bg, $s = 0 ) {
* and background, and 's' is for the font size.
*
* Example: [latex s=4 bg=00f fg=ff0]\LaTeX[/latex]
+ *
+ * @param array $atts Shortcode attributes.
+ * @param string $content Content to format.
*/
function latex_shortcode( $atts, $content = '' ) {
$attr = shortcode_atts(
@@ -137,15 +162,16 @@ function latex_shortcode( $atts, $content = '' ) {
}
/**
- * LaTeX needs to be untexturized
+ * LaTeX needs to be untexturized.
+ *
+ * @param array $shortcodes Array of shortcodes not to texturize.
*/
function latex_no_texturize( $shortcodes ) {
$shortcodes[] = 'latex';
return $shortcodes;
}
-
add_filter( 'no_texturize_shortcodes', 'latex_no_texturize' );
-add_filter( 'the_content', 'latex_markup', 9 ); // before wptexturize
-add_filter( 'comment_text', 'latex_markup', 9 ); // before wptexturize
+add_filter( 'the_content', 'latex_markup', 9 ); // Before wptexturize.
+add_filter( 'comment_text', 'latex_markup', 9 ); // Before wptexturize.
add_shortcode( 'latex', 'latex_shortcode' );
diff --git a/plugins/jetpack/modules/lazy-images.php b/plugins/jetpack/modules/lazy-images.php
index 9cb427fa..8ea372d8 100644
--- a/plugins/jetpack/modules/lazy-images.php
+++ b/plugins/jetpack/modules/lazy-images.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Module Name: Lazy Images
* Module Description: Speed up your site and create a smoother viewing experience by loading images as visitors scroll down the screen, instead of all at once.
@@ -11,13 +10,14 @@
* Module Tags: Appearance, Recommended
* Feature: Appearance
* Additional Search Queries: mobile, theme, fast images, fast image, image, lazy, lazy load, lazyload, images, lazy images, thumbnail, image lazy load, lazy loading, load, loading
+ *
+ * @package automattic/jetpack
*/
/**
+ * The core of this module has been migrated to an standalone reusable package.
*
* @since 8.8
- *
- * The core of this module has been migrated to an standalone reusable package.
*/
/*
diff --git a/plugins/jetpack/modules/lazy-images/images/1x1.trans.gif b/plugins/jetpack/modules/lazy-images/images/1x1.trans.gif
deleted file mode 100644
index f191b280..00000000
--- a/plugins/jetpack/modules/lazy-images/images/1x1.trans.gif
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/lazy-images/js/lazy-images.js b/plugins/jetpack/modules/lazy-images/js/lazy-images.js
deleted file mode 100644
index 1ddbc2c6..00000000
--- a/plugins/jetpack/modules/lazy-images/js/lazy-images.js
+++ /dev/null
@@ -1,868 +0,0 @@
-/* globals IntersectionObserver, jQuery */
-
-var jetpackLazyImagesModule = function( $ ) {
- var images,
- config = {
- // If the image gets within 200px in the Y axis, start the download.
- rootMargin: '200px 0px',
- threshold: 0.01
- },
- imageCount = 0,
- observer,
- image,
- i;
-
- $( document ).ready( function() {
- lazy_load_init();
-
- // Lazy load images that are brought in from Infinite Scroll
- $( 'body' ).bind( 'post-load', lazy_load_init );
-
- // Add event to provide optional compatibility for other code.
- $( 'body' ).bind( 'jetpack-lazy-images-load', lazy_load_init );
- } );
-
- function lazy_load_init() {
- images = document.querySelectorAll( 'img.jetpack-lazy-image:not(.jetpack-lazy-image--handled)' );
- imageCount = images.length;
-
- // If initialized, then disconnect the observer
- if ( observer ) {
- observer.disconnect();
- }
-
- // If we don't have support for intersection observer, loads the images immediately
- if ( ! ( 'IntersectionObserver' in window ) ) {
- loadImagesImmediately( images );
- } else {
- // It is supported, load the images
- observer = new IntersectionObserver( onIntersection, config );
-
- // foreach() is not supported in IE
- for ( i = 0; i < images.length; i++ ) {
- image = images[ i ];
- if ( image.getAttribute( 'data-lazy-loaded' ) ) {
- continue;
- }
-
- observer.observe( image );
- }
- }
- }
-
- /**
- * Load all of the images immediately
- * @param {NodeListOf<Element>} immediateImages List of lazy-loaded images to load immediately.
- */
- function loadImagesImmediately( immediateImages ) {
- var i;
-
- // foreach() is not supported in IE
- for ( i = 0; i < immediateImages.length; i++ ) {
- var image = immediateImages[ i ];
- applyImage( image );
- }
- }
-
- /**
- * On intersection
- * @param {array} entries List of elements being observed.
- */
- function onIntersection( entries ) {
- var i;
-
- // Disconnect if we've already loaded all of the images
- if ( imageCount === 0 ) {
- observer.disconnect();
- }
-
- // Loop through the entries
- for ( i = 0; i < entries.length; i++ ) {
- var entry = entries[ i ];
-
- // Are we in viewport?
- if ( entry.intersectionRatio > 0 ) {
- imageCount--;
-
- // Stop watching and load the image
- observer.unobserve( entry.target );
- applyImage( entry.target );
- }
- }
- }
-
- /**
- * Apply the image
- * @param {object} image The image object.
- */
- function applyImage( image ) {
- var theImage = $( image ),
- srcset,
- sizes,
- theClone;
-
- if ( ! theImage.length ) {
- return;
- }
-
- srcset = theImage.attr( 'data-lazy-srcset' );
- sizes = theImage.attr( 'data-lazy-sizes' );
- theClone = theImage.clone(true);
-
- // Remove lazy attributes from the clone.
- theClone.removeAttr( 'data-lazy-srcset' ),
- theClone.removeAttr( 'data-lazy-sizes' );
- theClone.removeAttr( 'data-lazy-src' );
-
- // Add the attributes we want on the finished image.
- theClone.addClass( 'jetpack-lazy-image--handled' );
- theClone.attr( 'data-lazy-loaded', 1 );
- if ( ! srcset ) {
- theClone.removeAttr( 'srcset' );
- } else {
- theClone.attr( 'srcset', srcset );
- }
- if ( sizes ) {
- theClone.attr( 'sizes', sizes );
- }
-
- theImage.replaceWith( theClone );
-
- // Fire an event so that third-party code can perform actions after an image is loaded.
- theClone.trigger( 'jetpack-lazy-loaded-image' );
- }
-};
-
-/**
- * The following is an Intersection observer polyfill which is licensed under
- * the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE and can be found at:
- * https://github.com/w3c/IntersectionObserver/tree/master/polyfill
- */
-
-/**
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.
- *
- * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
- *
- */
-
-(function(window, document) {
- 'use strict';
-
-
- // Exits early if all IntersectionObserver and IntersectionObserverEntry
- // features are natively supported.
- if ('IntersectionObserver' in window &&
- 'IntersectionObserverEntry' in window &&
- 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
-
- // Minimal polyfill for Edge 15's lack of `isIntersecting`
- // See: https://github.com/w3c/IntersectionObserver/issues/211
- if (!('isIntersecting' in window.IntersectionObserverEntry.prototype)) {
- Object.defineProperty(window.IntersectionObserverEntry.prototype,
- 'isIntersecting', {
- get: function () {
- return this.intersectionRatio > 0;
- }
- });
- }
- return;
- }
-
-
- /**
- * An IntersectionObserver registry. This registry exists to hold a strong
- * reference to IntersectionObserver instances currently observering a target
- * element. Without this registry, instances without another reference may be
- * garbage collected.
- */
- var registry = [];
-
-
- /**
- * Creates the global IntersectionObserverEntry constructor.
- * https://w3c.github.io/IntersectionObserver/#intersection-observer-entry
- * @param {Object} entry A dictionary of instance properties.
- * @constructor
- */
- function IntersectionObserverEntry(entry) {
- this.time = entry.time;
- this.target = entry.target;
- this.rootBounds = entry.rootBounds;
- this.boundingClientRect = entry.boundingClientRect;
- this.intersectionRect = entry.intersectionRect || getEmptyRect();
- this.isIntersecting = !!entry.intersectionRect;
-
- // Calculates the intersection ratio.
- var targetRect = this.boundingClientRect;
- var targetArea = targetRect.width * targetRect.height;
- var intersectionRect = this.intersectionRect;
- var intersectionArea = intersectionRect.width * intersectionRect.height;
-
- // Sets intersection ratio.
- if (targetArea) {
- this.intersectionRatio = intersectionArea / targetArea;
- } else {
- // If area is zero and is intersecting, sets to 1, otherwise to 0
- this.intersectionRatio = this.isIntersecting ? 1 : 0;
- }
- }
-
-
- /**
- * Creates the global IntersectionObserver constructor.
- * https://w3c.github.io/IntersectionObserver/#intersection-observer-interface
- * @param {Function} callback The function to be invoked after intersection
- * changes have queued. The function is not invoked if the queue has
- * been emptied by calling the `takeRecords` method.
- * @param {Object=} opt_options Optional configuration options.
- * @constructor
- */
- function IntersectionObserver(callback, opt_options) {
-
- var options = opt_options || {};
-
- if (typeof callback != 'function') {
- throw new Error('callback must be a function');
- }
-
- if (options.root && options.root.nodeType != 1) {
- throw new Error('root must be an Element');
- }
-
- // Binds and throttles `this._checkForIntersections`.
- this._checkForIntersections = throttle(
- this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT);
-
- // Private properties.
- this._callback = callback;
- this._observationTargets = [];
- this._queuedEntries = [];
- this._rootMarginValues = this._parseRootMargin(options.rootMargin);
-
- // Public properties.
- this.thresholds = this._initThresholds(options.threshold);
- this.root = options.root || null;
- this.rootMargin = this._rootMarginValues.map(function(margin) {
- return margin.value + margin.unit;
- }).join(' ');
- }
-
-
- /**
- * The minimum interval within which the document will be checked for
- * intersection changes.
- */
- IntersectionObserver.prototype.THROTTLE_TIMEOUT = 100;
-
-
- /**
- * The frequency in which the polyfill polls for intersection changes.
- * this can be updated on a per instance basis and must be set prior to
- * calling `observe` on the first target.
- */
- IntersectionObserver.prototype.POLL_INTERVAL = null;
-
- /**
- * Use a mutation observer on the root element
- * to detect intersection changes.
- */
- IntersectionObserver.prototype.USE_MUTATION_OBSERVER = true;
-
-
- /**
- * Starts observing a target element for intersection changes based on
- * the thresholds values.
- * @param {Element} target The DOM element to observe.
- */
- IntersectionObserver.prototype.observe = function(target) {
- var isTargetAlreadyObserved = this._observationTargets.some(function(item) {
- return item.element == target;
- });
-
- if (isTargetAlreadyObserved) {
- return;
- }
-
- if (!(target && target.nodeType == 1)) {
- throw new Error('target must be an Element');
- }
-
- this._registerInstance();
- this._observationTargets.push({element: target, entry: null});
- this._monitorIntersections();
- this._checkForIntersections();
- };
-
-
- /**
- * Stops observing a target element for intersection changes.
- * @param {Element} target The DOM element to observe.
- */
- IntersectionObserver.prototype.unobserve = function(target) {
- this._observationTargets =
- this._observationTargets.filter(function(item) {
-
- return item.element != target;
- });
- if (!this._observationTargets.length) {
- this._unmonitorIntersections();
- this._unregisterInstance();
- }
- };
-
-
- /**
- * Stops observing all target elements for intersection changes.
- */
- IntersectionObserver.prototype.disconnect = function() {
- this._observationTargets = [];
- this._unmonitorIntersections();
- this._unregisterInstance();
- };
-
-
- /**
- * Returns any queue entries that have not yet been reported to the
- * callback and clears the queue. This can be used in conjunction with the
- * callback to obtain the absolute most up-to-date intersection information.
- * @return {Array} The currently queued entries.
- */
- IntersectionObserver.prototype.takeRecords = function() {
- var records = this._queuedEntries.slice();
- this._queuedEntries = [];
- return records;
- };
-
-
- /**
- * Accepts the threshold value from the user configuration object and
- * returns a sorted array of unique threshold values. If a value is not
- * between 0 and 1 and error is thrown.
- * @private
- * @param {Array|number=} opt_threshold An optional threshold value or
- * a list of threshold values, defaulting to [0].
- * @return {Array} A sorted list of unique and valid threshold values.
- */
- IntersectionObserver.prototype._initThresholds = function(opt_threshold) {
- var threshold = opt_threshold || [0];
- if (!Array.isArray(threshold)) threshold = [threshold];
-
- return threshold.sort().filter(function(t, i, a) {
- if (typeof t != 'number' || isNaN(t) || t < 0 || t > 1) {
- throw new Error('threshold must be a number between 0 and 1 inclusively');
- }
- return t !== a[i - 1];
- });
- };
-
-
- /**
- * Accepts the rootMargin value from the user configuration object
- * and returns an array of the four margin values as an object containing
- * the value and unit properties. If any of the values are not properly
- * formatted or use a unit other than px or %, and error is thrown.
- * @private
- * @param {string=} opt_rootMargin An optional rootMargin value,
- * defaulting to '0px'.
- * @return {Array<Object>} An array of margin objects with the keys
- * value and unit.
- */
- IntersectionObserver.prototype._parseRootMargin = function(opt_rootMargin) {
- var marginString = opt_rootMargin || '0px';
- var margins = marginString.split(/\s+/).map(function(margin) {
- var parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin);
- if (!parts) {
- throw new Error('rootMargin must be specified in pixels or percent');
- }
- return {value: parseFloat(parts[1]), unit: parts[2]};
- });
-
- // Handles shorthand.
- margins[1] = margins[1] || margins[0];
- margins[2] = margins[2] || margins[0];
- margins[3] = margins[3] || margins[1];
-
- return margins;
- };
-
-
- /**
- * Starts polling for intersection changes if the polling is not already
- * happening, and if the page's visibilty state is visible.
- * @private
- */
- IntersectionObserver.prototype._monitorIntersections = function() {
- if (!this._monitoringIntersections) {
- this._monitoringIntersections = true;
-
- // If a poll interval is set, use polling instead of listening to
- // resize and scroll events or DOM mutations.
- if (this.POLL_INTERVAL) {
- this._monitoringInterval = setInterval(
- this._checkForIntersections, this.POLL_INTERVAL);
- }
- else {
- addEvent(window, 'resize', this._checkForIntersections, true);
- addEvent(document, 'scroll', this._checkForIntersections, true);
-
- if (this.USE_MUTATION_OBSERVER && 'MutationObserver' in window) {
- this._domObserver = new MutationObserver(this._checkForIntersections);
- this._domObserver.observe(document, {
- attributes: true,
- childList: true,
- characterData: true,
- subtree: true
- });
- }
- }
- }
- };
-
-
- /**
- * Stops polling for intersection changes.
- * @private
- */
- IntersectionObserver.prototype._unmonitorIntersections = function() {
- if (this._monitoringIntersections) {
- this._monitoringIntersections = false;
-
- clearInterval(this._monitoringInterval);
- this._monitoringInterval = null;
-
- removeEvent(window, 'resize', this._checkForIntersections, true);
- removeEvent(document, 'scroll', this._checkForIntersections, true);
-
- if (this._domObserver) {
- this._domObserver.disconnect();
- this._domObserver = null;
- }
- }
- };
-
-
- /**
- * Scans each observation target for intersection changes and adds them
- * to the internal entries queue. If new entries are found, it
- * schedules the callback to be invoked.
- * @private
- */
- IntersectionObserver.prototype._checkForIntersections = function() {
- var rootIsInDom = this._rootIsInDom();
- var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();
-
- this._observationTargets.forEach(function(item) {
- var target = item.element;
- var targetRect = getBoundingClientRect(target);
- var rootContainsTarget = this._rootContainsTarget(target);
- var oldEntry = item.entry;
- var intersectionRect = rootIsInDom && rootContainsTarget &&
- this._computeTargetAndRootIntersection(target, rootRect);
-
- var newEntry = item.entry = new IntersectionObserverEntry({
- time: now(),
- target: target,
- boundingClientRect: targetRect,
- rootBounds: rootRect,
- intersectionRect: intersectionRect
- });
-
- if (!oldEntry) {
- this._queuedEntries.push(newEntry);
- } else if (rootIsInDom && rootContainsTarget) {
- // If the new entry intersection ratio has crossed any of the
- // thresholds, add a new entry.
- if (this._hasCrossedThreshold(oldEntry, newEntry)) {
- this._queuedEntries.push(newEntry);
- }
- } else {
- // If the root is not in the DOM or target is not contained within
- // root but the previous entry for this target had an intersection,
- // add a new record indicating removal.
- if (oldEntry && oldEntry.isIntersecting) {
- this._queuedEntries.push(newEntry);
- }
- }
- }, this);
-
- if (this._queuedEntries.length) {
- this._callback(this.takeRecords(), this);
- }
- };
-
-
- /**
- * Accepts a target and root rect computes the intersection between then
- * following the algorithm in the spec.
- * TODO(philipwalton): at this time clip-path is not considered.
- * https://w3c.github.io/IntersectionObserver/#calculate-intersection-rect-algo
- * @param {Element} target The target DOM element
- * @param {Object} rootRect The bounding rect of the root after being
- * expanded by the rootMargin value.
- * @return {?Object} The final intersection rect object or undefined if no
- * intersection is found.
- * @private
- */
- IntersectionObserver.prototype._computeTargetAndRootIntersection =
- function(target, rootRect) {
-
- // If the element isn't displayed, an intersection can't happen.
- if (window.getComputedStyle(target).display == 'none') return;
-
- var targetRect = getBoundingClientRect(target);
- var intersectionRect = targetRect;
- var parent = getParentNode(target);
- var atRoot = false;
-
- while (!atRoot) {
- var parentRect = null;
- var parentComputedStyle = parent.nodeType == 1 ?
- window.getComputedStyle(parent) : {};
-
- // If the parent isn't displayed, an intersection can't happen.
- if (parentComputedStyle.display == 'none') return;
-
- if (parent == this.root || parent == document) {
- atRoot = true;
- parentRect = rootRect;
- } else {
- // If the element has a non-visible overflow, and it's not the <body>
- // or <html> element, update the intersection rect.
- // Note: <body> and <html> cannot be clipped to a rect that's not also
- // the document rect, so no need to compute a new intersection.
- if (parent != document.body &&
- parent != document.documentElement &&
- parentComputedStyle.overflow != 'visible') {
- parentRect = getBoundingClientRect(parent);
- }
- }
-
- // If either of the above conditionals set a new parentRect,
- // calculate new intersection data.
- if (parentRect) {
- intersectionRect = computeRectIntersection(parentRect, intersectionRect);
-
- if (!intersectionRect) break;
- }
- parent = getParentNode(parent);
- }
- return intersectionRect;
- };
-
-
- /**
- * Returns the root rect after being expanded by the rootMargin value.
- * @return {Object} The expanded root rect.
- * @private
- */
- IntersectionObserver.prototype._getRootRect = function() {
- var rootRect;
- if (this.root) {
- rootRect = getBoundingClientRect(this.root);
- } else {
- // Use <html>/<body> instead of window since scroll bars affect size.
- var html = document.documentElement;
- var body = document.body;
- rootRect = {
- top: 0,
- left: 0,
- right: html.clientWidth || body.clientWidth,
- width: html.clientWidth || body.clientWidth,
- bottom: html.clientHeight || body.clientHeight,
- height: html.clientHeight || body.clientHeight
- };
- }
- return this._expandRectByRootMargin(rootRect);
- };
-
-
- /**
- * Accepts a rect and expands it by the rootMargin value.
- * @param {Object} rect The rect object to expand.
- * @return {Object} The expanded rect.
- * @private
- */
- IntersectionObserver.prototype._expandRectByRootMargin = function(rect) {
- var margins = this._rootMarginValues.map(function(margin, i) {
- return margin.unit == 'px' ? margin.value :
- margin.value * (i % 2 ? rect.width : rect.height) / 100;
- });
- var newRect = {
- top: rect.top - margins[0],
- right: rect.right + margins[1],
- bottom: rect.bottom + margins[2],
- left: rect.left - margins[3]
- };
- newRect.width = newRect.right - newRect.left;
- newRect.height = newRect.bottom - newRect.top;
-
- return newRect;
- };
-
-
- /**
- * Accepts an old and new entry and returns true if at least one of the
- * threshold values has been crossed.
- * @param {?IntersectionObserverEntry} oldEntry The previous entry for a
- * particular target element or null if no previous entry exists.
- * @param {IntersectionObserverEntry} newEntry The current entry for a
- * particular target element.
- * @return {boolean} Returns true if a any threshold has been crossed.
- * @private
- */
- IntersectionObserver.prototype._hasCrossedThreshold =
- function(oldEntry, newEntry) {
-
- // To make comparing easier, an entry that has a ratio of 0
- // but does not actually intersect is given a value of -1
- var oldRatio = oldEntry && oldEntry.isIntersecting ?
- oldEntry.intersectionRatio || 0 : -1;
- var newRatio = newEntry.isIntersecting ?
- newEntry.intersectionRatio || 0 : -1;
-
- // Ignore unchanged ratios
- if (oldRatio === newRatio) return;
-
- for (var i = 0; i < this.thresholds.length; i++) {
- var threshold = this.thresholds[i];
-
- // Return true if an entry matches a threshold or if the new ratio
- // and the old ratio are on the opposite sides of a threshold.
- if (threshold == oldRatio || threshold == newRatio ||
- threshold < oldRatio !== threshold < newRatio) {
- return true;
- }
- }
- };
-
-
- /**
- * Returns whether or not the root element is an element and is in the DOM.
- * @return {boolean} True if the root element is an element and is in the DOM.
- * @private
- */
- IntersectionObserver.prototype._rootIsInDom = function() {
- return !this.root || containsDeep(document, this.root);
- };
-
-
- /**
- * Returns whether or not the target element is a child of root.
- * @param {Element} target The target element to check.
- * @return {boolean} True if the target element is a child of root.
- * @private
- */
- IntersectionObserver.prototype._rootContainsTarget = function(target) {
- return containsDeep(this.root || document, target);
- };
-
-
- /**
- * Adds the instance to the global IntersectionObserver registry if it isn't
- * already present.
- * @private
- */
- IntersectionObserver.prototype._registerInstance = function() {
- if (registry.indexOf(this) < 0) {
- registry.push(this);
- }
- };
-
-
- /**
- * Removes the instance from the global IntersectionObserver registry.
- * @private
- */
- IntersectionObserver.prototype._unregisterInstance = function() {
- var index = registry.indexOf(this);
- if (index != -1) registry.splice(index, 1);
- };
-
-
- /**
- * Returns the result of the performance.now() method or null in browsers
- * that don't support the API.
- * @return {number} The elapsed time since the page was requested.
- */
- function now() {
- return window.performance && performance.now && performance.now();
- }
-
-
- /**
- * Throttles a function and delays its executiong, so it's only called at most
- * once within a given time period.
- * @param {Function} fn The function to throttle.
- * @param {number} timeout The amount of time that must pass before the
- * function can be called again.
- * @return {Function} The throttled function.
- */
- function throttle(fn, timeout) {
- var timer = null;
- return function () {
- if (!timer) {
- timer = setTimeout(function() {
- fn();
- timer = null;
- }, timeout);
- }
- };
- }
-
-
- /**
- * Adds an event handler to a DOM node ensuring cross-browser compatibility.
- * @param {Node} node The DOM node to add the event handler to.
- * @param {string} event The event name.
- * @param {Function} fn The event handler to add.
- * @param {boolean} opt_useCapture Optionally adds the even to the capture
- * phase. Note: this only works in modern browsers.
- */
- function addEvent(node, event, fn, opt_useCapture) {
- if (typeof node.addEventListener == 'function') {
- node.addEventListener(event, fn, opt_useCapture || false);
- }
- else if (typeof node.attachEvent == 'function') {
- node.attachEvent('on' + event, fn);
- }
- }
-
-
- /**
- * Removes a previously added event handler from a DOM node.
- * @param {Node} node The DOM node to remove the event handler from.
- * @param {string} event The event name.
- * @param {Function} fn The event handler to remove.
- * @param {boolean} opt_useCapture If the event handler was added with this
- * flag set to true, it should be set to true here in order to remove it.
- */
- function removeEvent(node, event, fn, opt_useCapture) {
- if (typeof node.removeEventListener == 'function') {
- node.removeEventListener(event, fn, opt_useCapture || false);
- }
- else if (typeof node.detatchEvent == 'function') {
- node.detatchEvent('on' + event, fn);
- }
- }
-
-
- /**
- * Returns the intersection between two rect objects.
- * @param {Object} rect1 The first rect.
- * @param {Object} rect2 The second rect.
- * @return {?Object} The intersection rect or undefined if no intersection
- * is found.
- */
- function computeRectIntersection(rect1, rect2) {
- var top = Math.max(rect1.top, rect2.top);
- var bottom = Math.min(rect1.bottom, rect2.bottom);
- var left = Math.max(rect1.left, rect2.left);
- var right = Math.min(rect1.right, rect2.right);
- var width = right - left;
- var height = bottom - top;
-
- return (width >= 0 && height >= 0) && {
- top: top,
- bottom: bottom,
- left: left,
- right: right,
- width: width,
- height: height
- };
- }
-
-
- /**
- * Shims the native getBoundingClientRect for compatibility with older IE.
- * @param {Element} el The element whose bounding rect to get.
- * @return {Object} The (possibly shimmed) rect of the element.
- */
- function getBoundingClientRect(el) {
- var rect;
-
- try {
- rect = el.getBoundingClientRect();
- } catch (err) {
- // Ignore Windows 7 IE11 "Unspecified error"
- // https://github.com/w3c/IntersectionObserver/pull/205
- }
-
- if (!rect) return getEmptyRect();
-
- // Older IE
- if (!(rect.width && rect.height)) {
- rect = {
- top: rect.top,
- right: rect.right,
- bottom: rect.bottom,
- left: rect.left,
- width: rect.right - rect.left,
- height: rect.bottom - rect.top
- };
- }
- return rect;
- }
-
-
- /**
- * Returns an empty rect object. An empty rect is returned when an element
- * is not in the DOM.
- * @return {Object} The empty rect.
- */
- function getEmptyRect() {
- return {
- top: 0,
- bottom: 0,
- left: 0,
- right: 0,
- width: 0,
- height: 0
- };
- }
-
- /**
- * Checks to see if a parent element contains a child elemnt (including inside
- * shadow DOM).
- * @param {Node} parent The parent element.
- * @param {Node} child The child element.
- * @return {boolean} True if the parent node contains the child node.
- */
- function containsDeep(parent, child) {
- var node = child;
- while (node) {
- if (node == parent) return true;
-
- node = getParentNode(node);
- }
- return false;
- }
-
-
- /**
- * Gets the parent node of an element or its host element if the parent node
- * is a shadow root.
- * @param {Node} node The node whose parent to get.
- * @return {Node|null} The parent node or null if no parent exists.
- */
- function getParentNode(node) {
- var parent = node.parentNode;
-
- if (parent && parent.nodeType == 11 && parent.host) {
- // If the parent is a shadow root, return the host element.
- return parent.host;
- }
- return parent;
- }
-
-
- // Exposes the constructors globally.
- window.IntersectionObserver = IntersectionObserver;
- window.IntersectionObserverEntry = IntersectionObserverEntry;
-
- }(window, document));
-
-// Let's kick things off now
-jetpackLazyImagesModule( jQuery );
diff --git a/plugins/jetpack/modules/lazy-images/lazy-images.php b/plugins/jetpack/modules/lazy-images/lazy-images.php
deleted file mode 100644
index c8092840..00000000
--- a/plugins/jetpack/modules/lazy-images/lazy-images.php
+++ /dev/null
@@ -1,355 +0,0 @@
-<?php
-
-use Automattic\Jetpack\Assets;
-
-class Jetpack_Lazy_Images {
- private static $__instance = null;
-
- /**
- * Singleton implementation
- *
- * @return object
- */
- public static function instance() {
- if ( is_null( self::$__instance ) ) {
- self::$__instance = new Jetpack_Lazy_Images();
- }
-
- return self::$__instance;
- }
-
- /**
- * Registers actions
- */
- private function __construct() {
- if ( is_admin() ) {
- return;
- }
-
- /**
- * Whether the lazy-images module should load.
- *
- * This filter is not prefixed with jetpack_ to provide a smoother migration
- * process from the WordPress Lazy Load plugin.
- *
- * @module lazy-images
- *
- * @since 5.6.0
- *
- * @param bool true Whether lazy image loading should occur.
- */
- if ( ! apply_filters( 'lazyload_is_enabled', true ) ) {
- return;
- }
-
- if ( Jetpack_AMP_Support::is_amp_request() ) {
- return;
- }
-
- add_action( 'wp_head', array( $this, 'setup_filters' ), 9999 ); // we don't really want to modify anything in <head> since it's mostly all metadata
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_assets' ) );
-
- // Do not lazy load avatar in admin bar
- add_action( 'admin_bar_menu', array( $this, 'remove_filters' ), 0 );
-
- add_filter( 'wp_kses_allowed_html', array( $this, 'allow_lazy_attributes' ) );
- add_action( 'wp_head', array( $this, 'add_nojs_fallback' ) );
- }
-
- public function setup_filters() {
- add_filter( 'the_content', array( $this, 'add_image_placeholders' ), PHP_INT_MAX ); // run this later, so other content filters have run, including image_add_wh on WP.com
- add_filter( 'post_thumbnail_html', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
- add_filter( 'get_avatar', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
- add_filter( 'widget_text', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
- add_filter( 'get_image_tag', array( $this, 'add_image_placeholders' ), PHP_INT_MAX);
- add_filter( 'wp_get_attachment_image_attributes', array( __CLASS__, 'process_image_attributes' ), PHP_INT_MAX );
- }
-
- public function remove_filters() {
- remove_filter( 'the_content', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
- remove_filter( 'post_thumbnail_html', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
- remove_filter( 'get_avatar', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
- remove_filter( 'widget_text', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
- remove_filter( 'get_image_tag', array( $this, 'add_image_placeholders' ), PHP_INT_MAX);
- remove_filter( 'wp_get_attachment_image_attributes', array( __CLASS__, 'process_image_attributes' ), PHP_INT_MAX );
- }
-
- /**
- * Ensure that our lazy image attributes are not filtered out of image tags.
- *
- * @param array $allowed_tags The allowed tags and their attributes.
- * @return array
- */
- public function allow_lazy_attributes( $allowed_tags ) {
- if ( ! isset( $allowed_tags['img'] ) ) {
- return $allowed_tags;
- }
-
- // But, if images are allowed, ensure that our attributes are allowed!
- $img_attributes = array_merge( $allowed_tags['img'], array(
- 'data-lazy-src' => 1,
- 'data-lazy-srcset' => 1,
- 'data-lazy-sizes' => 1,
- ) );
-
- $allowed_tags['img'] = $img_attributes;
-
- return $allowed_tags;
- }
-
- public function add_image_placeholders( $content ) {
- // Don't lazyload for feeds, previews
- if ( is_feed() || is_preview() ) {
- return $content;
- }
-
- // Don't lazy-load if the content has already been run through previously
- if ( false !== strpos( $content, 'data-lazy-src' ) ) {
- return $content;
- }
-
- // This is a pretty simple regex, but it works
- $content = preg_replace_callback( '#<(img)([^>]+?)(>(.*?)</\\1>|[\/]?>)#si', array( __CLASS__, 'process_image' ), $content );
-
- return $content;
- }
-
- /**
- * Returns true when a given string of classes contains a class signifying lazy images
- * should not process the image.
- *
- * @since 5.9.0
- *
- * @param string $classes A string of space-separated classes.
- * @return bool
- */
- public static function should_skip_image_with_blacklisted_class( $classes ) {
- $blacklisted_classes = array(
- 'skip-lazy',
- 'gazette-featured-content-thumbnail',
- );
-
- /**
- * Allow plugins and themes to tell lazy images to skip an image with a given class.
- *
- * @module lazy-images
- *
- * @since 5.9.0
- *
- * @param array An array of strings where each string is a class.
- */
- $blacklisted_classes = apply_filters( 'jetpack_lazy_images_blacklisted_classes', $blacklisted_classes );
-
- if ( ! is_array( $blacklisted_classes ) || empty( $blacklisted_classes ) ) {
- return false;
- }
-
- foreach ( $blacklisted_classes as $class ) {
- if ( false !== strpos( $classes, $class ) ) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Processes images in content by acting as the preg_replace_callback
- *
- * @since 5.6.0
- *
- * @param array $matches
- *
- * @return string The image with updated lazy attributes
- */
- static function process_image( $matches ) {
- $old_attributes_str = $matches[2];
- $old_attributes_kses_hair = wp_kses_hair( $old_attributes_str, wp_allowed_protocols() );
-
- if ( empty( $old_attributes_kses_hair['src'] ) ) {
- return $matches[0];
- }
-
- $old_attributes = self::flatten_kses_hair_data( $old_attributes_kses_hair );
-
- // If we didn't add lazy attributes, just return the original image source.
- if ( ! empty( $old_attributes['class'] ) && false !== strpos( $old_attributes['class'], 'jetpack-lazy-image' ) ) {
- return $matches[0];
- }
-
- $new_attributes = self::process_image_attributes( $old_attributes );
- $new_attributes_str = self::build_attributes_string( $new_attributes );
-
- return sprintf( '<img %1$s><noscript>%2$s</noscript>', $new_attributes_str, $matches[0] );
- }
-
- /**
- * Given an array of image attributes, updates the `src`, `srcset`, and `sizes` attributes so
- * that they load lazily.
- *
- * @since 5.7.0
- *
- * @param array $attributes
- *
- * @return array The updated image attributes array with lazy load attributes
- */
- static function process_image_attributes( $attributes ) {
- if ( empty( $attributes['src'] ) ) {
- return $attributes;
- }
-
- if ( ! empty( $attributes['class'] ) && self::should_skip_image_with_blacklisted_class( $attributes['class'] ) ) {
- return $attributes;
- }
-
- /**
- * Allow plugins and themes to conditionally skip processing an image via its attributes.
- *
- * @module-lazy-images
- *
- * @deprecated 6.5.0 Use jetpack_lazy_images_skip_image_with_attributes instead.
- *
- * @since 5.9.0
- *
- * @param bool Default to not skip processing the current image.
- * @param array An array of attributes via wp_kses_hair() for the current image.
- */
- if ( apply_filters( 'jetpack_lazy_images_skip_image_with_atttributes', false, $attributes ) ) {
- return $attributes;
- }
-
- /**
- * Allow plugins and themes to conditionally skip processing an image via its attributes.
- *
- * @module-lazy-images
- *
- * @since 6.5.0 Filter name was updated from jetpack_lazy_images_skip_image_with_atttributes to correct typo.
- * @since 5.9.0
- *
- * @param bool Default to not skip processing the current image.
- * @param array An array of attributes via wp_kses_hair() for the current image.
- */
- if ( apply_filters( 'jetpack_lazy_images_skip_image_with_attributes', false, $attributes ) ) {
- return $attributes;
- }
-
- $old_attributes = $attributes;
-
- // Stash srcset and sizes in data attributes.
- foreach ( array( 'srcset', 'sizes' ) as $attribute ) {
- if ( isset( $old_attributes[ $attribute ] ) ) {
- $attributes[ "data-lazy-$attribute" ] = $old_attributes[ $attribute ];
- unset( $attributes[ $attribute ] );
- }
- }
-
- // We set this, adding the query arg so that it doesn't exactly equal the src attribute, so that photon JavaScript
- // will hold off on processing this image.
- $attributes['data-lazy-src'] = esc_url_raw( add_query_arg( 'is-pending-load', true, $attributes['src'] ) );
-
- $attributes['srcset'] = self::get_placeholder_image();
- $attributes['class'] = sprintf(
- '%s jetpack-lazy-image',
- empty( $old_attributes['class'] )
- ? ''
- : $old_attributes['class']
- );
-
- /**
- * Allow plugins and themes to override the attributes on the image before the content is updated.
- *
- * One potential use of this filter is for themes that set `height:auto` on the `img` tag.
- * With this filter, the theme could get the width and height attributes from the
- * $attributes array and then add a style tag that sets those values as well, which could
- * minimize reflow as images load.
- *
- * @module lazy-images
- *
- * @since 5.6.0
- *
- * @param array An array containing the attributes for the image, where the key is the attribute name
- * and the value is the attribute value.
- */
- return apply_filters( 'jetpack_lazy_images_new_attributes', $attributes );
- }
-
- /**
- * Adds JavaScript to check if the current browser supports JavaScript as well as some styles to hide lazy
- * images when the browser does not support JavaScript.
- *
- * @return void
- */
- public function add_nojs_fallback() {
- ?>
- <style type="text/css">
- /* If html does not have either class, do not show lazy loaded images. */
- html:not( .jetpack-lazy-images-js-enabled ):not( .js ) .jetpack-lazy-image {
- display: none;
- }
- </style>
- <script>
- document.documentElement.classList.add(
- 'jetpack-lazy-images-js-enabled'
- );
- </script>
- <?php
- }
-
- /**
- * Retrieves the placeholder image after running it through the lazyload_images_placeholder_image filter.
- *
- * @return string The placeholder image source.
- */
- private static function get_placeholder_image() {
- /**
- * Allows plugins and themes to modify the placeholder image.
- *
- * This filter is not prefixed with jetpack_ to provide a smoother migration
- * process from the WordPress Lazy Load plugin.
- *
- * @module lazy-images
- *
- * @since 5.6.0
- * @since 6.5.0 Default image is now a base64 encoded transparent gif.
- *
- * @param string The URL to the placeholder image
- */
- return apply_filters(
- 'lazyload_images_placeholder_image',
- 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
- );
- }
-
- private static function flatten_kses_hair_data( $attributes ) {
- $flattened_attributes = array();
- foreach ( $attributes as $name => $attribute ) {
- $flattened_attributes[ $name ] = $attribute['value'];
- }
- return $flattened_attributes;
- }
-
- private static function build_attributes_string( $attributes ) {
- $string = array();
- foreach ( $attributes as $name => $value ) {
- if ( '' === $value ) {
- $string[] = sprintf( '%s', $name );
- } else {
- $string[] = sprintf( '%s="%s"', $name, esc_attr( $value ) );
- }
- }
- return implode( ' ', $string );
- }
-
- public function enqueue_assets() {
- wp_enqueue_script(
- 'jetpack-lazy-images',
- Assets::get_file_url_for_environment(
- '_inc/build/lazy-images/js/lazy-images.min.js',
- 'modules/lazy-images/js/lazy-images.js'
- ),
- array( 'jquery' ),
- JETPACK__VERSION,
- true
- );
- }
-}
diff --git a/plugins/jetpack/modules/likes/jetpack-likes-master-iframe.php b/plugins/jetpack/modules/likes/jetpack-likes-master-iframe.php
index 9ccca4c1..d520729b 100644
--- a/plugins/jetpack/modules/likes/jetpack-likes-master-iframe.php
+++ b/plugins/jetpack/modules/likes/jetpack-likes-master-iframe.php
@@ -1,10 +1,15 @@
<?php
+/**
+ * Jetpack likes iframe.
+ *
+ * @package jetpack
+ */
/**
* This function needs to get loaded after the like scripts get added to the page.
*/
function jetpack_likes_master_iframe() {
- $version = gmdate( 'YW' );
+ $version = gmdate( 'YW' );
$in_jetpack = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? false : true;
$_locale = get_locale();
@@ -18,10 +23,10 @@ function jetpack_likes_master_iframe() {
require_once JETPACK__GLOTPRESS_LOCALES_PATH;
$gp_locale = GP_Locales::by_field( 'wp_locale', $_locale );
- $_locale = isset( $gp_locale->slug ) ? $gp_locale->slug : '';
+ $_locale = isset( $gp_locale->slug ) ? $gp_locale->slug : '';
}
- $likes_locale = ( '' == $_locale || 'en' == $_locale ) ? '' : '&amp;lang=' . strtolower( $_locale );
+ $likes_locale = ( '' === $_locale || 'en' === $_locale ) ? '' : '&amp;lang=' . strtolower( $_locale );
$src = sprintf(
'https://widgets.wp.com/likes/master.html?ver=%1$s#ver=%1$s%2$s',
@@ -30,9 +35,9 @@ function jetpack_likes_master_iframe() {
);
/* translators: The value of %d is not available at the time of output */
- $likersText = wp_kses( __( '<span>%d</span> bloggers like this:', 'jetpack' ), array( 'span' => array() ) );
+ $likers_text = wp_kses( __( '<span>%d</span> bloggers like this:', 'jetpack' ), array( 'span' => array() ) );
?>
- <iframe src='<?php echo $src; ?>' scrolling='no' id='likes-master' name='likes-master' style='display:none;'></iframe>
- <div id='likes-other-gravatars'><div class="likes-text"><?php echo $likersText; ?></div><ul class="wpl-avatars sd-like-gravatars"></ul></div>
+ <iframe src='<?php echo esc_url( $src ); ?>' scrolling='no' id='likes-master' name='likes-master' style='display:none;'></iframe>
+ <div id='likes-other-gravatars'><div class="likes-text"><?php echo $likers_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div><ul class="wpl-avatars sd-like-gravatars"></ul></div>
<?php
}
diff --git a/plugins/jetpack/modules/likes/jetpack-likes-settings.php b/plugins/jetpack/modules/likes/jetpack-likes-settings.php
index 0e373f58..a7a19b24 100644
--- a/plugins/jetpack/modules/likes/jetpack-likes-settings.php
+++ b/plugins/jetpack/modules/likes/jetpack-likes-settings.php
@@ -1,9 +1,16 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Sync\Settings;
+/**
+ * Jetpack likes settings class.
+ */
class Jetpack_Likes_Settings {
- function __construct() {
+
+ /**
+ * Constructor function.
+ */
+ public function __construct() {
$this->in_jetpack = ! ( defined( 'IS_WPCOM' ) && IS_WPCOM );
}
@@ -44,16 +51,18 @@ class Jetpack_Likes_Settings {
* @param string Likes metabox title. Default to "Likes".
*/
$title = apply_filters( 'likes_meta_box_title', __( 'Likes', 'jetpack' ) );
- foreach( $post_types as $post_type ) {
+ foreach ( $post_types as $post_type ) {
add_meta_box( 'likes_meta', $title, array( $this, 'meta_box_content' ), $post_type, 'side', 'default', array( '__back_compat_meta_box' => true ) );
}
}
/**
* Shows the likes option in the post screen metabox.
+ *
+ * @param object $post - the post object.
*/
public function meta_box_content( $post ) {
- $post_id = ! empty( $post->ID ) ? (int) $post->ID : get_the_ID();
+ $post_id = ! empty( $post->ID ) ? (int) $post->ID : get_the_ID();
$checked = true;
$disabled = ! $this->is_enabled_sitewide();
$switched_status = get_post_meta( $post_id, 'switch_like_status', true );
@@ -80,7 +89,9 @@ class Jetpack_Likes_Settings {
<?php esc_html_e( 'Show likes.', 'jetpack' ); ?>
</label>
<input type="hidden" name="wpl_like_status_hidden" value="1" />
- </p> <?php
+ <?php wp_nonce_field( 'likes-and-shares', '_likesharenonce' ); ?>
+ </p>
+ <?php
/**
* Fires after the Likes meta box content in the post editor.
*
@@ -95,6 +106,7 @@ class Jetpack_Likes_Settings {
/**
* Returns the current state of the "WordPress.com Likes are" option.
+ *
* @return boolean true if enabled sitewide, false if not
*/
public function is_enabled_sitewide() {
@@ -111,18 +123,27 @@ class Jetpack_Likes_Settings {
return (bool) apply_filters( 'wpl_is_enabled_sitewide', ! Jetpack_Options::get_option_and_ensure_autoload( 'disabled_likes', 0 ) );
}
+ /**
+ * Handle meta box saving.
+ *
+ * @param int $post_id - the post ID.
+ */
public function meta_box_save( $post_id ) {
- if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
+ return $post_id;
+ }
+
+ if ( empty( $_POST['wpl_like_status_hidden'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- we're not changing anything on the site.
return $post_id;
}
- if ( empty( $_POST['wpl_like_status_hidden'] ) ) {
+ if ( ! isset( $_POST['_likesharenonce'] ) || ! wp_verify_nonce( $_POST['_likesharenonce'], 'likes-and-shares' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- WordPress core doesn't unslash or verify nonces either.
return $post_id;
}
- // Record sharing disable. Only needs to be done for WPCOM
+ // Record sharing disable. Only needs to be done for WPCOM.
if ( ! $this->in_jetpack ) {
- if ( isset( $_POST['post_type'] ) && in_array( $_POST['post_type'], get_post_types( array( 'public' => true ) ) ) ) {
+ if ( isset( $_POST['post_type'] ) && in_array( $_POST['post_type'], get_post_types( array( 'public' => true ) ), true ) ) {
if ( ! isset( $_POST['wpl_enable_post_sharing'] ) ) {
update_post_meta( $post_id, 'sharing_disabled', 1 );
} else {
@@ -131,8 +152,8 @@ class Jetpack_Likes_Settings {
}
}
- if ( 'post' == $_POST['post_type'] ) {
- if ( !current_user_can( 'edit_post', $post_id ) ) {
+ if ( 'post' === $_POST['post_type'] ) {
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
return $post_id;
}
}
@@ -140,14 +161,14 @@ class Jetpack_Likes_Settings {
// Record a change in like status for this post - only if it contradicts the
// site like setting. If it doesn't contradict, then we delete the new individual status.
if ( ! $this->is_enabled_sitewide() && ! empty( $_POST['wpl_enable_post_likes'] ) ) {
- // Likes turned on for individual posts. User wants to add the button to a single post
+ // Likes turned on for individual posts. User wants to add the button to a single post.
update_post_meta( $post_id, 'switch_like_status', 1 );
- } else if ( $this->is_enabled_sitewide() && empty( $_POST['wpl_enable_post_likes'] ) ) {
- // Likes turned on for all posts. User wants to remove the button from a single post
+ } elseif ( $this->is_enabled_sitewide() && empty( $_POST['wpl_enable_post_likes'] ) ) {
+ // Likes turned on for all posts. User wants to remove the button from a single post.
update_post_meta( $post_id, 'switch_like_status', 0 );
- } else if (
- ( ! $this->is_enabled_sitewide() && empty( $_POST['wpl_enable_post_likes'] ) ) ||
- ( $this->is_enabled_sitewide() && ! empty( $_POST['wpl_enable_post_likes'] ) )
+ } elseif (
+ ( ! $this->is_enabled_sitewide() && empty( $_POST['wpl_enable_post_likes'] ) ) ||
+ ( $this->is_enabled_sitewide() && ! empty( $_POST['wpl_enable_post_likes'] ) )
) {
// User wants to update the likes button status for an individual post, but the new status
// is the same as if they're asking for the default behavior according to the current Likes setting.
@@ -159,25 +180,29 @@ class Jetpack_Likes_Settings {
}
/**
- * WordPress.com: Metabox option for sharing (sharedaddy will handle this on the JP blog)
+ * WordPress.com: Metabox option for sharing (sharedaddy will handle this on the JP blog).
+ *
+ * @param object $post - the post object.
*/
public function sharing_meta_box_content( $post ) {
- $post_id = ! empty( $post->ID ) ? (int) $post->ID : get_the_ID();
- $disabled = get_post_meta( $post_id, 'sharing_disabled', true ); ?>
+ $post_id = ! empty( $post->ID ) ? (int) $post->ID : get_the_ID();
+ $disabled = get_post_meta( $post_id, 'sharing_disabled', true );
+ ?>
<p>
<label for="wpl_enable_post_sharing">
<input type="checkbox" name="wpl_enable_post_sharing" id="wpl_enable_post_sharing" value="1" <?php checked( ! $disabled ); ?>>
- <?php _e( 'Show sharing buttons.', 'jetpack' ); ?>
+ <?php esc_html_e( 'Show sharing buttons.', 'jetpack' ); ?>
</label>
<input type="hidden" name="wpl_sharing_status_hidden" value="1" />
- </p> <?php
+ </p>
+ <?php
}
/**
* Adds the 'sharing' menu to the settings menu.
* Only ran if sharedaddy and publicize are not already active.
*/
- function sharing_menu() {
+ public function sharing_menu() {
add_submenu_page( 'options-general.php', esc_html__( 'Sharing Settings', 'jetpack' ), esc_html__( 'Sharing', 'jetpack' ), 'manage_options', 'sharing', array( $this, 'sharing_page' ) );
}
@@ -186,8 +211,9 @@ class Jetpack_Likes_Settings {
* so we can display the setting.
* Only ran if sharedaddy and publicize are not already active.
*/
- function sharing_page() {
- $this->updated_message(); ?>
+ public function sharing_page() {
+ $this->updated_message();
+ ?>
<div class="wrap">
<div class="icon32" id="icon-options-general"><br /></div>
<h1><?php esc_html_e( 'Sharing Settings', 'jetpack' ); ?></h1>
@@ -196,14 +222,16 @@ class Jetpack_Likes_Settings {
do_action( 'pre_admin_screen_sharing' );
?>
<?php $this->sharing_block(); ?>
- </div> <?php
+ </div>
+ <?php
}
/**
* Returns the settings have been saved message.
*/
- function updated_message() {
- if ( isset( $_GET['update'] ) && $_GET['update'] == 'saved' ){
+ public function updated_message() {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- ignoring since we are just displaying that the settings have been saved and not making any other changes to the site.
+ if ( isset( $_GET['update'] ) && 'saved' === $_GET['update'] ) {
echo '<div class="updated"><p>' . esc_html__( 'Settings have been saved', 'jetpack' ) . '</p></div>';
}
}
@@ -211,7 +239,8 @@ class Jetpack_Likes_Settings {
/**
* Returns just the "sharing buttons" w/ like option block, so it can be inserted into different sharing page contexts
*/
- function sharing_block() { ?>
+ public function sharing_block() {
+ ?>
<h2><?php esc_html_e( 'Sharing Buttons', 'jetpack' ); ?></h2>
<form method="post" action="">
<table class="form-table">
@@ -224,20 +253,19 @@ class Jetpack_Likes_Settings {
</table>
<p class="submit">
- <input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'jetpack' ); ?>" />
- </p>
-
- <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
- </form> <?php
+ <input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'jetpack' ); ?>" />
+ <?php wp_nonce_field( 'sharing-options' ); ?>
+ </form>
+ <?php
}
/**
* Are likes enabled for this post?
*
- * @param int $post_id
+ * @param int $post_id - the post ID.
* @return bool
*/
- function is_post_likeable( $post_id = 0 ) {
+ public function is_post_likeable( $post_id = 0 ) {
$post = get_post( $post_id );
if ( ! $post || is_wp_error( $post ) ) {
return false;
@@ -264,7 +292,7 @@ class Jetpack_Likes_Settings {
*/
$last_modified_time = strtotime( $post->post_modified_gmt );
- $behavior_was_changed_at = strtotime( "2019-02-22 00:40:42" );
+ $behavior_was_changed_at = strtotime( '2019-02-22 00:40:42' );
if ( $this->in_jetpack || $last_modified_time > $behavior_was_changed_at ) {
/*
@@ -304,7 +332,7 @@ class Jetpack_Likes_Settings {
* Some of this code was taken and modified from sharing_display() to ensure
* similar logic and filters apply here, too.
*/
- function is_likes_visible() {
+ public function is_likes_visible() {
if ( Settings::is_syncing() ) {
return false;
}
@@ -332,7 +360,7 @@ class Jetpack_Likes_Settings {
$enabled = false;
}
- if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
+ if ( in_array( 'get_the_excerpt', (array) $wp_current_filter, true ) ) {
$enabled = false;
}
// Sharing Setting Overrides ****************************************
@@ -362,12 +390,12 @@ class Jetpack_Likes_Settings {
if ( $post instanceof WP_Post ) {
// Check that the post is a public, published post.
- if ( 'attachment' == $post->post_type ) {
+ if ( 'attachment' === $post->post_type ) {
$post_status = get_post_status( $post->post_parent );
} else {
$post_status = $post->post_status;
}
- if ( 'publish' != $post_status ) {
+ if ( 'publish' !== $post_status ) {
$enabled = false;
}
}
@@ -392,10 +420,10 @@ class Jetpack_Likes_Settings {
/**
* Are Post Likes enabled on single posts?
*
- * @param String $post_type custom post type identifier
+ * @param string $post_type custom post type identifier.
* @return bool
*/
- function is_single_post_enabled( $post_type = 'post' ) {
+ public function is_single_post_enabled( $post_type = 'post' ) {
$options = $this->get_options();
return (bool) apply_filters(
/**
@@ -410,7 +438,7 @@ class Jetpack_Likes_Settings {
* @param bool $enabled Are Post Likes enabled on single posts?
*/
"wpl_is_single_{$post_type}_disabled",
- (bool) in_array( $post_type, $options['show'] )
+ (bool) in_array( $post_type, $options['show'], true )
);
}
@@ -419,9 +447,9 @@ class Jetpack_Likes_Settings {
*
* @return array
*/
- function get_options() {
+ public function get_options() {
$setting = array();
- $setting['disabled'] = get_option( 'disabled_likes' );
+ $setting['disabled'] = get_option( 'disabled_likes' );
$sharing = get_option( 'sharing-options', array() );
// Default visibility settings
@@ -431,13 +459,13 @@ class Jetpack_Likes_Settings {
// Scalar check
} elseif ( is_scalar( $sharing['global']['show'] ) ) {
switch ( $sharing['global']['show'] ) {
- case 'posts' :
+ case 'posts':
$sharing['global']['show'] = array( 'post', 'page' );
break;
- case 'index' :
+ case 'index':
$sharing['global']['show'] = array( 'index' );
break;
- case 'posts-index' :
+ case 'posts-index':
$sharing['global']['show'] = array( 'post', 'page', 'index' );
break;
}
@@ -463,7 +491,7 @@ class Jetpack_Likes_Settings {
*
* @return bool
*/
- function is_index_enabled() {
+ public function is_index_enabled() {
$options = $this->get_options();
/**
* Filters whether Likes should be enabled on archive/front/search pages.
@@ -474,7 +502,7 @@ class Jetpack_Likes_Settings {
*
* @param bool $enabled Are Post Likes enabled on archive/front/search pages?
*/
- return (bool) apply_filters( 'wpl_is_index_disabled', (bool) in_array( 'index', $options['show'] ) );
+ return (bool) apply_filters( 'wpl_is_index_disabled', (bool) in_array( 'index', $options['show'], true ) );
}
/**
@@ -482,7 +510,7 @@ class Jetpack_Likes_Settings {
*
* @return bool
*/
- function is_single_page_enabled() {
+ public function is_single_page_enabled() {
$options = $this->get_options();
/**
* Filters whether Likes should be enabled on single pages.
@@ -493,7 +521,7 @@ class Jetpack_Likes_Settings {
*
* @param bool $enabled Are Post Likes enabled on single pages?
*/
- return (bool) apply_filters( 'wpl_is_single_page_disabled', (bool) in_array( 'page', $options['show'] ) );
+ return (bool) apply_filters( 'wpl_is_single_page_disabled', (bool) in_array( 'page', $options['show'], true ) );
}
/**
@@ -501,7 +529,7 @@ class Jetpack_Likes_Settings {
*
* @return bool
*/
- function is_attachment_enabled() {
+ public function is_attachment_enabled() {
$options = $this->get_options();
/**
* Filters whether Likes should be enabled on attachment pages.
@@ -512,13 +540,13 @@ class Jetpack_Likes_Settings {
*
* @param bool $enabled Are Post Likes enabled on attachment pages?
*/
- return (bool) apply_filters( 'wpl_is_attachment_disabled', (bool) in_array( 'attachment', $options['show'] ) );
+ return (bool) apply_filters( 'wpl_is_attachment_disabled', (bool) in_array( 'attachment', $options['show'], true ) );
}
/**
* The actual options block to be inserted into the sharing page.
*/
- function admin_settings_init() {
+ public function admin_settings_init() {
?>
<tr>
<th scope="row">
@@ -577,14 +605,15 @@ class Jetpack_Likes_Settings {
<?php endif; ?>
<?php endif; ?>
</tbody> <?php // closes the tbody attached to sharing_show_buttons_on_row_start... ?>
- <?php
+ <?php
}
/**
* Returns the current state of the "WordPress.com Reblogs are" option.
- * @return boolean true if enabled sitewide, false if not
+ *
+ * @return bool true if enabled sitewide, false if not
*/
- function reblogs_enabled_sitewide() {
+ public function reblogs_enabled_sitewide() {
/**
* Filters whether Reblogs are enabled by default on all posts.
* true if enabled sitewide, false if not.
@@ -601,9 +630,10 @@ class Jetpack_Likes_Settings {
/**
* Used for WPCOM ONLY. Comment likes are in their own module in Jetpack.
* Returns if comment likes are enabled. Defaults to 'off'
+ *
* @return boolean true if we should show comment likes, false if not
*/
- function is_comments_enabled() {
+ public function is_comments_enabled() {
/**
* Filters whether Comment Likes are enabled.
* true if enabled, false if not.
@@ -618,62 +648,63 @@ class Jetpack_Likes_Settings {
}
/**
- * Saves the setting in the database, bumps a stat on WordPress.com
+ * Saves the setting in the database.
*/
- function admin_settings_callback() {
+ public function admin_settings_callback() {
+ if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- WordPress core doesn't unslash or verify nonces either.
+ return;
+ }
+
// We're looking for these, and doing a dance to set some stats and save
// them together in array option.
- $new_state = ! empty( $_POST['wpl_default'] ) ? $_POST['wpl_default'] : 'on';
- $db_state = $this->is_enabled_sitewide();
+ if ( ! empty( $_POST['wpl_default'] ) ) {
+ $new_state = sanitize_text_field( wp_unslash( $_POST['wpl_default'] ) );
+ } else {
+ $new_state = 'on';
+ }
- $reblogs_new_state = ! empty( $_POST['jetpack_reblogs_enabled'] ) ? $_POST['jetpack_reblogs_enabled'] : 'on';
- $reblogs_db_state = $this->reblogs_enabled_sitewide();
- /** Default State *********************************************************/
+ if ( ! empty( $_POST['jetpack_reblogs_enabled'] ) ) {
+ $reblogs_new_state = sanitize_text_field( wp_unslash( $_POST['jetpack_reblogs_enabled'] ) );
+ } else {
+ $reblogs_new_state = 'on';
+ }
// Checked (enabled)
- switch( $new_state ) {
- case 'off' :
- if ( true == $db_state && ! $this->in_jetpack ) {
- $g_gif = file_get_contents( 'https://pixel.wp.com/g.gif?v=wpcom-no-pv&x_likes=disabled_likes' );
- }
+ switch ( $new_state ) {
+ case 'off':
update_option( 'disabled_likes', 1 );
break;
- case 'on' :
+ case 'on':
default:
- if ( false == $db_state && ! $this->in_jetpack ) {
- $g_gif = file_get_contents( 'https://pixel.wp.com/g.gif?v=wpcom-no-pv&x_likes=reenabled_likes' );
- }
delete_option( 'disabled_likes' );
break;
}
- switch( $reblogs_new_state ) {
- case 'off' :
- if ( true == $reblogs_db_state && ! $this->in_jetpack ) {
- $g_gif = file_get_contents( 'https://pixel.wp.com/g.gif?v=wpcom-no-pv&x_reblogs=disabled_reblogs' );
- }
+ switch ( $reblogs_new_state ) {
+ case 'off':
update_option( 'disabled_reblogs', 1 );
break;
- case 'on' :
+ case 'on':
default:
- if ( false == $reblogs_db_state && ! $this->in_jetpack ) {
- $g_gif = file_get_contents( 'https://pixel.wp.com/g.gif?v=wpcom-no-pv&x_reblogs=reenabled_reblogs' );
- }
delete_option( 'disabled_reblogs' );
break;
}
// WPCOM only: Comment Likes
if ( ! $this->in_jetpack ) {
- $new_comments_state = ! empty( $_POST['jetpack_comment_likes_enabled'] ) ? $_POST['jetpack_comment_likes_enabled'] : false;
- switch( (bool) $new_comments_state ) {
+ if ( ! empty( $_POST['jetpack_comment_likes_enabled'] ) ) {
+ $new_comments_state = sanitize_text_field( wp_unslash( $_POST['jetpack_comment_likes_enabled'] ) );
+ } else {
+ $new_comments_state = false;
+ }
+ switch ( (bool) $new_comments_state ) {
case true:
update_option( 'jetpack_comment_likes_enabled', 1 );
- break;
+ break;
case false:
default:
update_option( 'jetpack_comment_likes_enabled', 0 );
- break;
+ break;
}
}
}
@@ -681,9 +712,9 @@ class Jetpack_Likes_Settings {
/**
* Adds the admin update hook so we can save settings even if Sharedaddy is not enabled.
*/
- function process_update_requests_if_sharedaddy_not_loaded() {
- if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'sharing.php' || $_GET['page'] == 'sharing' ) ) {
- if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) ) {
+ public function process_update_requests_if_sharedaddy_not_loaded() {
+ if ( isset( $_GET['page'] ) && ( $_GET['page'] === 'sharing.php' || $_GET['page'] === 'sharing' ) ) {
+ if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- WordPress core doesn't unslash or verify nonces either.
/** This action is documented in modules/sharedaddy/sharing.php */
do_action( 'sharing_admin_update' );
wp_safe_redirect( admin_url( 'options-general.php?page=sharing&update=saved' ) );
@@ -695,63 +726,71 @@ class Jetpack_Likes_Settings {
/**
* If sharedaddy is not loaded, we don't have the "Show buttons on" yet, so we need to add that since it affects likes too.
*/
- function admin_settings_showbuttonon_init() {
+ public function admin_settings_showbuttonon_init() {
/** This action is documented in modules/sharedaddy/sharing.php */
- echo apply_filters( 'sharing_show_buttons_on_row_start', '<tr valign="top">' );
+ echo apply_filters( 'sharing_show_buttons_on_row_start', '<tr valign="top">' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
- <th scope="row"><label><?php _e( 'Show buttons on', 'jetpack' ); ?></label></th>
+ <th scope="row"><label><?php esc_html_e( 'Show buttons on', 'jetpack' ); ?></label></th>
<td>
<?php
- $br = false;
+ $br = false;
$shows = array_values( get_post_types( array( 'public' => true ) ) );
array_unshift( $shows, 'index' );
$global = $this->get_options();
foreach ( $shows as $show ) :
- if ( 'index' == $show ) {
+ if ( 'index' === $show ) {
$label = __( 'Front Page, Archive Pages, and Search Results', 'jetpack' );
} else {
$post_type_object = get_post_type_object( $show );
- $label = $post_type_object->labels->name;
+ $label = $post_type_object->labels->name;
+ }
+
+ if ( $br ) {
+ echo '<br />';
}
?>
- <?php if ( $br ) echo '<br />'; ?><label><input type="checkbox"<?php checked( in_array( $show, $global['show'] ) ); ?> name="show[]" value="<?php echo esc_attr( $show ); ?>" /> <?php echo esc_html( $label ); ?></label>
- <?php $br = true; endforeach; ?>
+ <label><input type="checkbox"<?php checked( in_array( $show, $global['show'], true ) ); ?> name="show[]" value="<?php echo esc_attr( $show ); ?>" /> <?php echo esc_html( $label ); ?></label>
+ <?php
+ $br = true;
+ endforeach;
+ ?>
</td>
<?php
/** This action is documented in modules/sharedaddy/sharing.php */
- echo apply_filters( 'sharing_show_buttons_on_row_end', '</tr>' );
- ?>
- <?php
+ echo apply_filters( 'sharing_show_buttons_on_row_end', '</tr>' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* If sharedaddy is not loaded, we still need to save the the settings of the "Show buttons on" option.
*/
- function admin_settings_showbuttonon_callback() {
+ public function admin_settings_showbuttonon_callback() {
$options = get_option( 'sharing-options' );
- if ( !is_array( $options ) )
+ if ( ! is_array( $options ) ) {
$options = array();
+ }
- $shows = array_values( get_post_types( array( 'public' => true ) ) );
+ $shows = array_values( get_post_types( array( 'public' => true ) ) );
$shows[] = 'index';
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing -- triggered due to the 'sharing_admin_update' action, but the code in sharing.php checks for the nonce before firing the action.
$data = $_POST;
if ( isset( $data['show'] ) ) {
if ( is_scalar( $data['show'] ) ) {
switch ( $data['show'] ) {
- case 'posts' :
+ case 'posts':
$data['show'] = array( 'post', 'page' );
break;
- case 'index' :
+ case 'index':
$data['show'] = array( 'index' );
break;
- case 'posts-index' :
+ case 'posts-index':
$data['show'] = array( 'post', 'page', 'index' );
break;
}
}
- if ( $data['show'] = array_intersect( $data['show'], $shows ) ) {
+ $data['show'] = array_intersect( $data['show'], $shows );
+ if ( $data['show'] ) {
$options['global']['show'] = $data['show'];
}
} else {
diff --git a/plugins/jetpack/modules/markdown.php b/plugins/jetpack/modules/markdown.php
index 719095a6..ee83557d 100644
--- a/plugins/jetpack/modules/markdown.php
+++ b/plugins/jetpack/modules/markdown.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Module Name: Markdown
* Module Description: Write posts or pages in plain-text Markdown syntax
@@ -10,9 +9,12 @@
* Module Tags: Writing
* Feature: Writing
* Additional Search Queries: md, markdown
+ *
+ * @package automattic/jetpack
*/
-include dirname( __FILE__ ) . '/markdown/easy-markdown.php';
+// Require the markdown class file.
+require __DIR__ . '/markdown/easy-markdown.php';
/**
* Remove checkbox set in modules/markdown/easy-markdown.php.
diff --git a/plugins/jetpack/modules/markdown/easy-markdown.php b/plugins/jetpack/modules/markdown/easy-markdown.php
index 43e30de4..0abcddf3 100644
--- a/plugins/jetpack/modules/markdown/easy-markdown.php
+++ b/plugins/jetpack/modules/markdown/easy-markdown.php
@@ -1,13 +1,15 @@
-<?php
-
-/*
-Plugin Name: Easy Markdown
-Plugin URI: https://automattic.com/
-Description: Write in Markdown, publish in WordPress
-Version: 0.1
-Author: Matt Wiebe
-Author URI: https://automattic.com/
-*/
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Plugin URI: https://automattic.com/
+ * Plugin Name: Easy Markdown
+ * Description: Write in Markdown, publish in WordPress
+ * Version: 0.1
+ * Author: Matt Wiebe
+ * Author URI: https://automattic.com/
+ * Text Domain: jetpack
+ *
+ * @package automattic/jetpack
+ */
/**
* Copyright (c) Automattic. All rights reserved.
@@ -31,35 +33,61 @@ Author URI: https://automattic.com/
* **********************************************************************
*/
+/**
+ * WPCom_Markdown class.
+ */
class WPCom_Markdown {
-
- const POST_OPTION = 'wpcom_publish_posts_with_markdown';
- const COMMENT_OPTION = 'wpcom_publish_comments_with_markdown';
+ const POST_OPTION = 'wpcom_publish_posts_with_markdown';
+ const COMMENT_OPTION = 'wpcom_publish_comments_with_markdown';
const POST_TYPE_SUPPORT = 'wpcom-markdown';
- const IS_MD_META = '_wpcom_is_markdown';
+ const IS_MD_META = '_wpcom_is_markdown';
+ /**
+ * Our markdown parser.
+ *
+ * @var WPCom_GHF_Markdown_Parser
+ */
private static $parser;
+
+ /**
+ * An instance of the markdown class.
+ *
+ * @var WPCom_Markdown
+ */
private static $instance;
- // to ensure that our munged posts over xml-rpc are removed from the cache
+ /**
+ * To ensure that our munged posts over xml-rpc are removed from the cache.
+ *
+ * @var array
+ */
public $posts_to_uncache = array();
- private $monitoring = array( 'post' => array(), 'parent' => array() );
+ /**
+ * Posts and parents to monitor.
+ *
+ * @var array
+ */
+ private $monitoring = array(
+ 'post' => array(),
+ 'parent' => array(),
+ );
/**
* Yay singletons!
+ *
* @return object WPCom_Markdown instance
*/
public static function get_instance() {
- if ( ! self::$instance )
+ if ( ! self::$instance ) {
self::$instance = new self();
+ }
return self::$instance;
}
/**
* Kicks things off on `init` action
- * @return null
*/
public function load() {
$this->add_default_post_type_support();
@@ -76,10 +104,9 @@ class WPCom_Markdown {
/**
* If we're in a bulk edit session, unload so that we don't lose our markdown metadata
- * @return null
*/
public function maybe_unload_for_bulk_edit() {
- if ( isset( $_REQUEST['bulk_edit'] ) && $this->is_posting_enabled() ) {
+ if ( isset( $_REQUEST['bulk_edit'] ) && $this->is_posting_enabled() ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$this->unload_markdown_for_posts();
}
}
@@ -87,8 +114,9 @@ class WPCom_Markdown {
/**
* Called on init and fires on switch_blog to decide if our actions and filters
* should be running.
- * @param int|null $new_blog_id New blog ID
- * @param int|null $old_blog_id Old blog ID
+ *
+ * @param int|null $new_blog_id New blog ID.
+ * @param int|null $old_blog_id Old blog ID.
* @return null
*/
public function maybe_load_actions_and_filters( $new_blog_id = null, $old_blog_id = null ) {
@@ -98,7 +126,7 @@ class WPCom_Markdown {
return;
}
- // If this is a switch_to_blog call, and the blog isn't changing, we'll already be loaded
+ // If this is a switch_to_blog call, and the blog isn't changing, we'll already be loaded.
if ( $new_blog_id && $new_blog_id === $old_blog_id ) {
return;
}
@@ -118,7 +146,6 @@ class WPCom_Markdown {
/**
* Set up hooks for enabling Markdown conversion on posts
- * @return null
*/
public function load_markdown_for_posts() {
add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 );
@@ -128,7 +155,7 @@ class WPCom_Markdown {
add_filter( 'edit_post_content', array( $this, 'edit_post_content' ), 10, 2 );
add_filter( 'edit_post_content_filtered', array( $this, 'edit_post_content_filtered' ), 10, 2 );
add_action( 'wp_restore_post_revision', array( $this, 'wp_restore_post_revision' ), 10, 2 );
- add_filter( '_wp_post_revision_fields', array( $this, '_wp_post_revision_fields' ) );
+ add_filter( '_wp_post_revision_fields', array( $this, 'wp_post_revision_fields' ) );
add_action( 'xmlrpc_call', array( $this, 'xmlrpc_actions' ) );
add_filter( 'content_save_pre', array( $this, 'preserve_code_blocks' ), 1 );
if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
@@ -138,7 +165,6 @@ class WPCom_Markdown {
/**
* Removes hooks to disable Markdown conversion on posts
- * @return null
*/
public function unload_markdown_for_posts() {
remove_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ) );
@@ -148,14 +174,13 @@ class WPCom_Markdown {
remove_filter( 'edit_post_content', array( $this, 'edit_post_content' ), 10, 2 );
remove_filter( 'edit_post_content_filtered', array( $this, 'edit_post_content_filtered' ), 10, 2 );
remove_action( 'wp_restore_post_revision', array( $this, 'wp_restore_post_revision' ), 10, 2 );
- remove_filter( '_wp_post_revision_fields', array( $this, '_wp_post_revision_fields' ) );
+ remove_filter( '_wp_post_revision_fields', array( $this, 'wp_post_revision_fields' ) );
remove_action( 'xmlrpc_call', array( $this, 'xmlrpc_actions' ) );
remove_filter( 'content_save_pre', array( $this, 'preserve_code_blocks' ), 1 );
}
/**
* Set up hooks for enabling Markdown conversion on comments
- * @return null
*/
protected function load_markdown_for_comments() {
// Use priority 9 so that Markdown runs before KSES, which can clean up
@@ -165,15 +190,13 @@ class WPCom_Markdown {
/**
* Removes hooks to disable Markdown conversion
- * @return null
*/
protected function unload_markdown_for_comments() {
remove_filter( 'pre_comment_content', array( $this, 'pre_comment_content' ), 9 );
}
/**
- * o2 does some of what we do. Let's take precedence.
- * @return null
+ * The o2 plugin does some of what we do. Let's take precedence.
*/
public function add_o2_helpers() {
if ( $this->is_posting_enabled() ) {
@@ -189,7 +212,8 @@ class WPCom_Markdown {
/**
* If Markdown is enabled for posts on this blog, filter the text for o2 previews
- * @param string $text Post text
+ *
+ * @param string $text Post text.
* @return string Post text transformed through the magic of Markdown
*/
public function o2_preview_post( $text ) {
@@ -201,7 +225,8 @@ class WPCom_Markdown {
/**
* If Markdown is enabled for comments on this blog, filter the text for o2 previews
- * @param string $text Comment text
+ *
+ * @param string $text Comment text.
* @return string Comment text transformed through the magic of Markdown
*/
public function o2_preview_comment( $text ) {
@@ -213,8 +238,9 @@ class WPCom_Markdown {
/**
* Escapes lists so that o2 doesn't trounce them
- * @param string $text Post/comment text
- * @return string Text escaped with HTML entity for asterisk
+ *
+ * @param string $text Post/comment text.
+ * @return string Text escaped with HTML entity for asterisk.
*/
public function o2_escape_lists( $text ) {
return preg_replace( '/^\\* /um', '&#42; ', $text );
@@ -222,7 +248,8 @@ class WPCom_Markdown {
/**
* Unescapes the token we inserted on o2_escape_lists
- * @param string $text Post/comment text with HTML entities for asterisks
+ *
+ * @param string $text Post/comment text with HTML entities for asterisks.
* @return string Text with the HTML entity removed
*/
public function o2_unescape_lists( $text ) {
@@ -231,8 +258,9 @@ class WPCom_Markdown {
/**
* Preserve code blocks from being munged by KSES before they have a chance
- * @param string $text post content
- * @return string post content with code blocks escaped
+ *
+ * @param string $text post content.
+ * @return string post content with code blocks escaped.
*/
public function preserve_code_blocks( $text ) {
return $this->get_parser()->codeblock_preserve( $text );
@@ -240,28 +268,28 @@ class WPCom_Markdown {
/**
* Remove KSES if it's there. Store the result to manually invoke later if needed.
- * @return null
*/
public function maybe_remove_kses() {
- // Filters return true if they existed before you removed them
- if ( $this->is_posting_enabled() )
+ // Filters return true if they existed before you removed them.
+ if ( $this->is_posting_enabled() ) {
$this->kses = remove_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' ) && remove_filter( 'content_save_pre', 'wp_filter_post_kses' );
+ }
}
/**
* Add our Writing and Discussion settings.
- * @return null
*/
public function register_setting() {
add_settings_field( self::POST_OPTION, __( 'Markdown', 'jetpack' ), array( $this, 'post_field' ), 'writing' );
- register_setting( 'writing', self::POST_OPTION, array( $this, 'sanitize_setting') );
+ register_setting( 'writing', self::POST_OPTION, array( $this, 'sanitize_setting' ) );
add_settings_field( self::COMMENT_OPTION, __( 'Markdown', 'jetpack' ), array( $this, 'comment_field' ), 'discussion' );
- register_setting( 'discussion', self::COMMENT_OPTION, array( $this, 'sanitize_setting') );
+ register_setting( 'discussion', self::COMMENT_OPTION, array( $this, 'sanitize_setting' ) );
}
/**
* Sanitize setting. Don't really want to store "on" value, so we'll store "1" instead!
- * @param string $input Value received by settings API via $_POST
+ *
+ * @param string $input Value received by settings API via $_POST.
* @return bool Cast to boolean.
*/
public function sanitize_setting( $input ) {
@@ -270,13 +298,11 @@ class WPCom_Markdown {
/**
* Prints HTML for the Writing setting
- * @return null
*/
public function post_field() {
printf(
- '<label><input name="%s" id="%s" type="checkbox"%s /> %s</label><p class="description">%s</p>',
- self::POST_OPTION,
- self::POST_OPTION,
+ '<label><input name="%1$s" id="%1$s" type="checkbox"%2$s /> %3$s</label><p class="description">%4$s</p>',
+ esc_attr( self::POST_OPTION ),
checked( $this->is_posting_enabled(), true, false ),
esc_html__( 'Use Markdown for posts and pages.', 'jetpack' ),
sprintf( '<a href="%s">%s</a>', esc_url( $this->get_support_url() ), esc_html__( 'Learn more about Markdown.', 'jetpack' ) )
@@ -285,13 +311,11 @@ class WPCom_Markdown {
/**
* Prints HTML for the Discussion setting
- * @return null
*/
public function comment_field() {
printf(
- '<label><input name="%s" id="%s" type="checkbox"%s /> %s</label><p class="description">%s</p>',
- self::COMMENT_OPTION,
- self::COMMENT_OPTION,
+ '<label><input name="%1$s" id="%1$s" type="checkbox"%2$s /> %3$s</label><p class="description">%4$s</p>',
+ esc_attr( self::COMMENT_OPTION ),
checked( $this->is_commenting_enabled(), true, false ),
esc_html__( 'Use Markdown for comments.', 'jetpack' ),
sprintf( '<a href="%s">%s</a>', esc_url( $this->get_support_url() ), esc_html__( 'Learn more about Markdown.', 'jetpack' ) )
@@ -300,6 +324,7 @@ class WPCom_Markdown {
/**
* Get the support url for Markdown
+ *
* @uses apply_filters
* @return string support url
*/
@@ -318,6 +343,7 @@ class WPCom_Markdown {
/**
* Is Mardown conversion for posts enabled?
+ *
* @return boolean
*/
public function is_posting_enabled() {
@@ -326,6 +352,7 @@ class WPCom_Markdown {
/**
* Is Markdown conversion for comments enabled?
+ *
* @return boolean
*/
public function is_commenting_enabled() {
@@ -334,7 +361,8 @@ class WPCom_Markdown {
/**
* Check if a $post_id has Markdown enabled
- * @param int $post_id A post ID.
+ *
+ * @param int $post_id A post ID.
* @return boolean
*/
public function is_markdown( $post_id ) {
@@ -344,7 +372,8 @@ class WPCom_Markdown {
/**
* Set Markdown as enabled on a post_id. We skip over update_postmeta so we
* can sneakily set metadata on post revisions, which we need.
- * @param int $post_id A post ID.
+ *
+ * @param int $post_id A post ID.
* @return bool The metadata was successfully set.
*/
protected function set_as_markdown( $post_id ) {
@@ -354,13 +383,14 @@ class WPCom_Markdown {
/**
* Get our Markdown parser object, optionally requiring all of our needed classes and
* instantiating our parser.
+ *
* @return object WPCom_GHF_Markdown_Parser instance.
*/
public function get_parser() {
if ( ! self::$parser ) {
jetpack_require_lib( 'markdown' );
- self::$parser = new WPCom_GHF_Markdown_Parser;
+ self::$parser = new WPCom_GHF_Markdown_Parser();
}
return self::$parser;
@@ -368,7 +398,6 @@ class WPCom_Markdown {
/**
* We don't want Markdown conversion all over the place.
- * @return null
*/
public function add_default_post_type_support() {
add_post_type_support( 'post', self::POST_TYPE_SUPPORT );
@@ -378,24 +407,33 @@ class WPCom_Markdown {
/**
* Figure out the post type of the post screen we're on
+ *
+ * @deprecated since 10.8
* @return string Current post_type
*/
protected function get_post_screen_post_type() {
+ _deprecated_function( __METHOD__, 'jetpack-10.8', '' );
+
global $pagenow;
- if ( 'post-new.php' === $pagenow )
- return ( isset( $_GET['post_type'] ) ) ? $_GET['post_type'] : 'post';
- if ( isset( $_GET['post'] ) ) {
- $post = get_post( (int) $_GET['post'] );
- if ( is_object( $post ) && isset( $post->post_type ) )
- return $post->post_type;
+ $post_type = filter_input( INPUT_GET, 'post_type', FILTER_UNSAFE_RAW );
+ $post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT );
+
+ if ( 'post-new.php' === $pagenow ) {
+ return ! empty( $post_type ) ? $post_type : 'post';
+ }
+
+ if ( $post_id ) {
+ $post_type = get_post_type( $post_id );
}
- return 'post';
+
+ return ! empty( $post_type ) ? $post_type : 'post';
}
/**
* Swap post_content and post_content_filtered for editing
- * @param string $content Post content
- * @param int $id post ID
+ *
+ * @param string $content Post content.
+ * @param int $id post ID.
* @return string Swapped content
*/
public function edit_post_content( $content, $id ) {
@@ -411,16 +449,18 @@ class WPCom_Markdown {
/**
* Swap post_content_filtered and post_content for editing
- * @param string $content Post content_filtered
- * @param int $id post ID
+ *
+ * @param string $content Post content_filtered.
+ * @param int $id post ID.
* @return string Swapped content
*/
public function edit_post_content_filtered( $content, $id ) {
- // if markdown was disabled, let's turn this off
+ // if markdown was disabled, let's turn this off.
if ( ! $this->is_posting_enabled() && $this->is_markdown( $id ) ) {
$post = get_post( $id );
- if ( $post && ! empty( $post->post_content_filtered ) )
+ if ( $post && ! empty( $post->post_content_filtered ) ) {
$content = '';
+ }
}
return $content;
}
@@ -428,7 +468,8 @@ class WPCom_Markdown {
/**
* Some tags are allowed to have a 'markdown' attribute, allowing them to contain Markdown.
* We need to tell KSES about those tags.
- * @param array $tags List of tags that KSES allows.
+ *
+ * @param array $tags List of tags that KSES allows.
* @param string $context The context that KSES is allowing these tags.
* @return array The tags that KSES allows, with our extra 'markdown' parameter where necessary.
*/
@@ -441,7 +482,7 @@ class WPCom_Markdown {
foreach ( $tags as $tag => $attributes ) {
if ( preg_match( $re, $tag ) ) {
$attributes['markdown'] = true;
- $tags[ $tag ] = $attributes;
+ $tags[ $tag ] = $attributes;
}
}
@@ -454,7 +495,7 @@ class WPCom_Markdown {
* to the schema instead.
*/
public function after_wp_tiny_mce() {
-?>
+ ?>
<script type="text/javascript">
jQuery( function() {
( 'undefined' !== typeof tinymce ) && tinymce.on( 'AddEditor', function( event ) {
@@ -468,12 +509,13 @@ jQuery( function() {
}, true );
} );
</script>
-<?php
+ <?php
}
/**
* Magic happens here. Markdown is converted and stored on post_content. Original Markdown is stored
* in post_content_filtered so that we can continue editing as Markdown.
+ *
* @param array $post_data The post data that will be inserted into the DB. Slashed.
* @param array $postarr All the stuff that was in $_POST.
* @return array $post_data with post_content and post_content_filtered modified
@@ -494,8 +536,8 @@ jQuery( function() {
}
// rejigger post_content and post_content_filtered
// revisions are already in the right place, except when we're restoring, but that's taken care of elsewhere
- // also prevent quick edit feature from overriding already-saved markdown (issue https://github.com/Automattic/jetpack/issues/636)
- if ( 'revision' !== $post_data['post_type'] && ! isset( $_POST['_inline_edit'] ) ) {
+ // also prevent quick edit feature from overriding already-saved markdown (issue https://github.com/Automattic/jetpack/issues/636).
+ if ( 'revision' !== $post_data['post_type'] && ! isset( $_POST['_inline_edit'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
/**
* Filter the original post content passed to Markdown.
*
@@ -506,25 +548,27 @@ jQuery( function() {
* @param string $post_data['post_content'] Untransformed post content.
*/
$post_data['post_content_filtered'] = apply_filters( 'wpcom_untransformed_content', $post_data['post_content'] );
- $post_data['post_content'] = $this->transform( $post_data['post_content'], array( 'id' => $post_id ) );
+ $post_data['post_content'] = $this->transform( $post_data['post_content'], array( 'id' => $post_id ) );
/** This filter is already documented in core/wp-includes/default-filters.php */
$post_data['post_content'] = apply_filters( 'content_save_pre', $post_data['post_content'] );
} elseif ( 0 === strpos( $post_data['post_name'], $post_data['post_parent'] . '-autosave' ) ) {
- // autosaves for previews are weird
+ // autosaves for previews are weird.
/** This filter is already documented in modules/markdown/easy-markdown.php */
$post_data['post_content_filtered'] = apply_filters( 'wpcom_untransformed_content', $post_data['post_content'] );
- $post_data['post_content'] = $this->transform( $post_data['post_content'], array( 'id' => $post_data['post_parent'] ) );
+ $post_data['post_content'] = $this->transform( $post_data['post_content'], array( 'id' => $post_data['post_parent'] ) );
/** This filter is already documented in core/wp-includes/default-filters.php */
$post_data['post_content'] = apply_filters( 'content_save_pre', $post_data['post_content'] );
}
- // set as markdown on the wp_insert_post hook later
- if ( $post_id )
+ // set as markdown on the wp_insert_post hook later.
+ if ( $post_id ) {
$this->monitoring['post'][ $post_id ] = true;
- else
+ } else {
$this->monitoring['content'] = wp_unslash( $post_data['post_content'] );
- if ( 'revision' === $postarr['post_type'] && $this->is_markdown( $postarr['post_parent'] ) )
+ }
+ if ( 'revision' === $postarr['post_type'] && $this->is_markdown( $postarr['post_parent'] ) ) {
$this->monitoring['parent'][ $postarr['post_parent'] ] = true;
+ }
return $post_data;
}
@@ -532,43 +576,53 @@ jQuery( function() {
/**
* Calls on wp_insert_post action, after wp_insert_post_data. This way we can
* still set postmeta on our revisions after it's all been deleted.
- * @param int $post_id The post ID that has just been added/updated
- * @return null
+ *
+ * @param int $post_id The post ID that has just been added/updated.
*/
public function wp_insert_post( $post_id ) {
$post_parent = get_post_field( 'post_parent', $post_id );
// this didn't have an ID yet. Compare the content that was just saved.
- if ( isset( $this->monitoring['content'] ) && $this->monitoring['content'] === get_post_field( 'post_content', $post_id ) ) {
+ if ( isset( $this->monitoring['content'] ) && get_post_field( 'post_content', $post_id ) === $this->monitoring['content'] ) {
unset( $this->monitoring['content'] );
$this->set_as_markdown( $post_id );
}
- if ( isset( $this->monitoring['post'][$post_id] ) ) {
- unset( $this->monitoring['post'][$post_id] );
+ if ( isset( $this->monitoring['post'][ $post_id ] ) ) {
+ unset( $this->monitoring['post'][ $post_id ] );
$this->set_as_markdown( $post_id );
- } elseif ( isset( $this->monitoring['parent'][$post_parent] ) ) {
- unset( $this->monitoring['parent'][$post_parent] );
+ } elseif ( isset( $this->monitoring['parent'][ $post_parent ] ) ) {
+ unset( $this->monitoring['parent'][ $post_parent ] );
$this->set_as_markdown( $post_id );
}
}
/**
* Run a comment through Markdown. Easy peasy.
- * @param string $content
+ *
+ * @param string $content - the content.
* @return string
*/
public function pre_comment_content( $content ) {
- return $this->transform( $content, array(
- 'id' => $this->comment_hash( $content ),
- ) );
+ return $this->transform(
+ $content,
+ array(
+ 'id' => $this->comment_hash( $content ),
+ )
+ );
}
+ /**
+ * Return a comment hash.
+ *
+ * @param string $content - the content of the comment.
+ */
protected function comment_hash( $content ) {
return 'c-' . substr( md5( $content ), 0, 8 );
}
/**
* Markdown conversion. Some DRYness for repetitive tasks.
- * @param string $text Content to be run through Markdown
+ *
+ * @param string $text Content to be run through Markdown.
* @param array $args Arguments, with keys:
* id: provide a string to prefix footnotes with a unique identifier
* unslash: when true, expects and returns slashed data
@@ -583,14 +637,18 @@ jQuery( function() {
return $text;
}
- $args = wp_parse_args( $args, array(
- 'id' => false,
- 'unslash' => true,
- 'decode_code_blocks' => ! $this->get_parser()->use_code_shortcode
- ) );
- // probably need to unslash
- if ( $args['unslash'] )
+ $args = wp_parse_args(
+ $args,
+ array(
+ 'id' => false,
+ 'unslash' => true,
+ 'decode_code_blocks' => ! $this->get_parser()->use_code_shortcode,
+ )
+ );
+ // probably need to unslash.
+ if ( $args['unslash'] ) {
$text = wp_unslash( $text );
+ }
/**
* Filter the content to be run through Markdown, before it's transformed by Markdown.
@@ -603,13 +661,13 @@ jQuery( function() {
* @param array $args Array of Markdown options.
*/
$text = apply_filters( 'wpcom_markdown_transform_pre', $text, $args );
- // ensure our paragraphs are separated
+ // ensure our paragraphs are separated.
$text = str_replace( array( '</p><p>', "</p>\n<p>" ), "</p>\n\n<p>", $text );
// visual editor likes to add <p>s. Buh-bye.
$text = $this->get_parser()->unp( $text );
- // sometimes we get an encoded > at start of line, breaking blockquotes
+ // sometimes we get an encoded > at start of line, breaking blockquotes.
$text = preg_replace( '/^&gt;/m', '>', $text );
- // prefixes are because we need to namespace footnotes by post_id
+ // prefixes are because we need to namespace footnotes by post_id.
$this->get_parser()->fn_id_prefix = $args['id'] ? $args['id'] . '-' : '';
// If we're not using the code shortcode, prevent over-encoding.
if ( $args['decode_code_blocks'] ) {
@@ -617,8 +675,8 @@ jQuery( function() {
}
// Transform it!
$text = $this->get_parser()->transform( $text );
- // Fix footnotes - kses doesn't like the : IDs it supplies
- $text = preg_replace( '/((id|href)="#?fn(ref)?):/', "$1-", $text );
+ // Fix footnotes - kses doesn't like the : IDs it supplies.
+ $text = preg_replace( '/((id|href)="#?fn(ref)?):/', '$1-', $text );
// Markdown inserts extra spaces to make itself work. Buh-bye.
$text = rtrim( $text );
/**
@@ -633,9 +691,10 @@ jQuery( function() {
*/
$text = apply_filters( 'wpcom_markdown_transform_post', $text, $args );
- // probably need to re-slash
- if ( $args['unslash'] )
+ // probably need to re-slash.
+ if ( $args['unslash'] ) {
$text = wp_slash( $text );
+ }
return $text;
}
@@ -643,10 +702,10 @@ jQuery( function() {
/**
* Shows Markdown in the Revisions screen, and ensures that post_content_filtered
* is maintained on revisions
- * @param array $fields Post fields pertinent to revisions
- * @return array Modified array to include post_content_filtered
+ *
+ * @param array $fields Post fields pertinent to revisions.
*/
- public function _wp_post_revision_fields( $fields ) {
+ public function wp_post_revision_fields( $fields ) {
$fields['post_content_filtered'] = __( 'Markdown content', 'jetpack' );
return $fields;
}
@@ -654,18 +713,18 @@ jQuery( function() {
/**
* Do some song and dance to keep all post_content and post_content_filtered content
* in the expected place when a post revision is restored.
- * @param int $post_id The post ID have a restore done to it
- * @param int $revision_id The revision ID being restored
- * @return null
+ *
+ * @param int $post_id The post ID have a restore done to it.
+ * @param int $revision_id The revision ID being restored.
*/
public function wp_restore_post_revision( $post_id, $revision_id ) {
if ( $this->is_markdown( $revision_id ) ) {
- $revision = get_post( $revision_id, ARRAY_A );
- $post = get_post( $post_id, ARRAY_A );
- $post['post_content'] = $revision['post_content_filtered']; // Yes, we put it in post_content, because our wp_insert_post_data() expects that
- // set this flag so we can restore the post_content_filtered on the last revision later
+ $revision = get_post( $revision_id, ARRAY_A );
+ $post = get_post( $post_id, ARRAY_A );
+ $post['post_content'] = $revision['post_content_filtered']; // Yes, we put it in post_content, because our wp_insert_post_data() expects that.
+ // set this flag so we can restore the post_content_filtered on the last revision later.
$this->monitoring['restore'] = true;
- // let's not make a revision of our fixing update
+ // let's not make a revision of our fixing update.
add_filter( 'wp_revisions_to_keep', '__return_false', 99 );
wp_update_post( $post );
$this->fix_latest_revision_on_restore( $post_id );
@@ -676,13 +735,13 @@ jQuery( function() {
/**
* We need to ensure the last revision has Markdown, not HTML in its post_content_filtered
* column after a restore.
+ *
* @param int $post_id The post ID that was just restored.
- * @return null
*/
protected function fix_latest_revision_on_restore( $post_id ) {
global $wpdb;
- $post = get_post( $post_id );
- $last_revision = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_type = 'revision' AND post_parent = %d ORDER BY ID DESC", $post->ID ) );
+ $post = get_post( $post_id );
+ $last_revision = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_type = 'revision' AND post_parent = %d ORDER BY ID DESC", $post->ID ) );
$last_revision->post_content_filtered = $post->post_content_filtered;
wp_insert_post( (array) $last_revision );
}
@@ -690,8 +749,8 @@ jQuery( function() {
/**
* Kicks off magic for an XML-RPC session. We want to keep editing Markdown
* and publishing HTML.
- * @param string $xmlrpc_method The current XML-RPC method
- * @return null
+ *
+ * @param string $xmlrpc_method The current XML-RPC method.
*/
public function xmlrpc_actions( $xmlrpc_method ) {
switch ( $xmlrpc_method ) {
@@ -707,20 +766,21 @@ jQuery( function() {
}
/**
- * metaWeblog.getPost and wp.getPage fire xmlrpc_call action *after* get_post() is called.
+ * Function metaWeblog.getPost and wp.getPage fire xmlrpc_call action *after* get_post() is called.
* So, we have to detect those methods and prime the post cache early.
+ *
* @return null
*/
protected function check_for_early_methods() {
- $raw_post_data = file_get_contents( "php://input" );
+ $raw_post_data = file_get_contents( 'php://input' );
if ( false === strpos( $raw_post_data, 'metaWeblog.getPost' )
&& false === strpos( $raw_post_data, 'wp.getPage' ) ) {
return;
}
- include_once( ABSPATH . WPINC . '/class-IXR.php' );
+ include_once ABSPATH . WPINC . '/class-IXR.php';
$message = new IXR_Message( $raw_post_data );
$message->parse();
- $post_id_position = 'metaWeblog.getPost' === $message->methodName ? 0 : 1;
+ $post_id_position = 'metaWeblog.getPost' === $message->methodName ? 0 : 1; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
$this->prime_post_cache( $message->params[ $post_id_position ] );
}
@@ -728,7 +788,7 @@ jQuery( function() {
* Prime the post cache with swapped post_content. This is a sneaky way of getting around
* the fact that there are no good hooks to call on the *.getPost xmlrpc methods.
*
- * @return null
+ * @param bool $post_id - the post ID that we're priming.
*/
private function prime_post_cache( $post_id = false ) {
global $wp_xmlrpc_server;
@@ -736,7 +796,7 @@ jQuery( function() {
$post_id = $wp_xmlrpc_server->message->params[3];
}
- // prime the post cache
+ // prime the post cache.
if ( $this->is_markdown( $post_id ) ) {
$post = get_post( $post_id );
if ( ! empty( $post->post_content_filtered ) ) {
@@ -746,7 +806,7 @@ jQuery( function() {
$this->posts_to_uncache[] = $post_id;
}
}
- // uncache munged posts if using a persistent object cache
+ // uncache munged posts if using a persistent object cache.
if ( wp_using_ext_object_cache() ) {
add_action( 'shutdown', array( $this, 'uncache_munged_posts' ) );
}
@@ -754,29 +814,28 @@ jQuery( function() {
/**
* Swaps `post_content_filtered` back to `post_content` for editing purposes.
- * @param object $post WP_Post object
- * @return object WP_Post object with swapped `post_content_filtered` and `post_content`
+ *
+ * @param object $post WP_Post object.
+ * @return object WP_Post object with swapped `post_content_filtered` and `post_content`.
*/
protected function swap_for_editing( $post ) {
$markdown = $post->post_content_filtered;
- // unencode encoded code blocks
+ // unencode encoded code blocks.
$markdown = $this->get_parser()->codeblock_restore( $markdown );
- // restore beginning of line blockquotes
- $markdown = preg_replace( '/^&gt; /m', '> ', $markdown );
+ // restore beginning of line blockquotes.
+ $markdown = preg_replace( '/^&gt; /m', '> ', $markdown );
$post->post_content_filtered = $post->post_content;
- $post->post_content = $markdown;
+ $post->post_content = $markdown;
return $post;
}
-
/**
* We munge the post cache to serve proper markdown content to XML-RPC clients.
* Uncache these after the XML-RPC session ends.
- * @return null
*/
public function uncache_munged_posts() {
// $this context gets lost in testing sometimes. Weird.
- foreach( WPCom_Markdown::get_instance()->posts_to_uncache as $post_id ) {
+ foreach ( self::get_instance()->posts_to_uncache as $post_id ) {
wp_cache_delete( $post_id, 'posts' );
}
}
@@ -784,8 +843,8 @@ jQuery( function() {
/**
* Since *.(get)?[Rr]ecentPosts calls get_posts with suppress filters on, we need to
* turn them back on so that we can swap things for editing.
- * @param object $wp_query WP_Query object
- * @return null
+ *
+ * @param object $wp_query WP_Query object.
*/
public function make_filterable( $wp_query ) {
$wp_query->set( 'suppress_filters', false );
@@ -794,16 +853,16 @@ jQuery( function() {
/**
* Swaps post_content and post_content_filtered for editing.
- * @param array $posts Posts returned by the just-completed query
- * @param object $wp_query Current WP_Query object
- * @return array Modified $posts
+ *
+ * @param array $posts Posts returned by the just-completed query.
+ * @return array Modified $posts
*/
- public function the_posts( $posts, $wp_query ) {
+ public function the_posts( $posts ) {
foreach ( $posts as $key => $post ) {
if ( $this->is_markdown( $post->ID ) && ! empty( $posts[ $key ]->post_content_filtered ) ) {
- $markdown = $posts[ $key ]->post_content_filtered;
+ $markdown = $posts[ $key ]->post_content_filtered;
$posts[ $key ]->post_content_filtered = $posts[ $key ]->post_content;
- $posts[ $key ]->post_content = $markdown;
+ $posts[ $key ]->post_content = $markdown;
}
}
return $posts;
diff --git a/plugins/jetpack/modules/masterbar/admin-menu/admin-menu-rtl.css b/plugins/jetpack/modules/masterbar/admin-menu/admin-menu-rtl.css
index 854a83b1..494ccf0f 100644
--- a/plugins/jetpack/modules/masterbar/admin-menu/admin-menu-rtl.css
+++ b/plugins/jetpack/modules/masterbar/admin-menu/admin-menu-rtl.css
@@ -1,6 +1,5 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
#adminmenu {
- margin: 0;
+ margin: 0;
}
/**
@@ -8,64 +7,63 @@
*/
#wpcontent,
#wpfooter {
- margin-right: 272px;
+ margin-right: 272px;
}
#adminmenuback,
#adminmenuwrap,
#adminmenu,
#adminmenu .wp-submenu {
- width: 272px;
+ width: 272px;
}
#adminmenu .wp-submenu {
- right: 272px;
+ right: 272px;
}
#adminmenu .wp-not-current-submenu .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu {
- min-width: 272px;
+ min-width: 272px;
}
/**
* Fixes Gutenberg in not fullscreen mode.
*/
- @media (min-width: 783px) {
- .interface-interface-skeleton,
- .edit-post-layout .components-editor-notices__snackbar {
- right: 272px;
- }
+@media (min-width: 783px) {
+ .interface-interface-skeleton,
+.edit-post-layout .components-editor-notices__snackbar {
+ right: 272px;
+ }
}
-
@media (min-width: 961px) {
- .auto-fold .interface-interface-skeleton,
- .auto-fold .edit-post-layout .components-editor-notices__snackbar,
- .jp-dialogue-modern-full__container {
- right: 272px;
- }
+ .auto-fold .interface-interface-skeleton,
+.auto-fold .edit-post-layout .components-editor-notices__snackbar,
+.jp-dialogue-modern-full__container {
+ right: 272px;
+ }
- .global-notices {
- max-width: calc( 100% - 48px - 272px );
- }
+ .global-notices {
+ max-width: calc( 100% - 48px - 272px );
+ }
}
-
/**
* Jetpack logo
*/
-#adminmenu [class*="activity-log"] .wp-menu-image img {
- padding-top: 7px;
+#adminmenu [class*=activity-log] .wp-menu-image img {
+ padding-top: 7px;
}
/**
* Site Card
*/
#adminmenu .toplevel_page_site-card .wp-menu-name {
- margin-right: 40px; /* icon width (32) + padding (8). */
- padding: 0;
+ margin-right: 40px;
+ /* icon width (32) + padding (8). */
+ padding: 0;
}
#adminmenu li.toplevel_page_site-card a {
- padding: 10px 8px 10px 0;
+ padding: 10px 8px 10px 0;
}
/**
@@ -75,416 +73,448 @@
#adminmenu a.toplevel_page_site-notices:focus,
#adminmenu li.toplevel_page_site-notices:hover,
#adminmenu li.toplevel_page_site-notices:focus {
- background-color: inherit !important;
- color: inherit !important;
+ background-color: inherit !important;
+ color: inherit !important;
}
#adminmenu li.toplevel_page_site-notices .wp-menu-image {
- display: none;
+ display: none;
}
#adminmenu .toplevel_page_site-notices .wp-menu-image {
- border-radius: 2px;
- background-color: #fff;
+ border-radius: 2px;
+ background-color: #fff;
}
#adminmenu .toplevel_page_site-notices .wp-menu-image:before {
- content: '\f534';
- font-family: 'dashicons';
- font-size: 20px;
- line-height: 20px;
- background-color: #a7aaad;
- color: white;
- border-radius: 50%;
- margin: 5px;
- padding: 0;
+ content: "\f534";
+ font-family: "dashicons";
+ font-size: 20px;
+ line-height: 20px;
+ background-color: #a7aaad;
+ color: white;
+ border-radius: 50%;
+ margin: 5px;
+ padding: 0;
}
#adminmenu .toplevel_page_site-notices:hover .wp-menu-image:before {
- color: #fff;
+ color: #fff;
}
#adminmenu .toplevel_page_site-notices .upsell_banner {
- display: flex;
- flex-grow: 1;
- flex-wrap: nowrap;
- align-items: center;
- justify-content: space-between;
- position: relative;
- width: 100%;
- padding: 7px 12px;
- right: -28px;
- border-radius: 2px;
- font-size: 12px;
- line-height: 1.4;
- -webkit-hyphens: none;
- hyphens: none;
+ display: flex;
+ flex-grow: 1;
+ flex-wrap: nowrap;
+ align-items: center;
+ justify-content: space-between;
+ position: relative;
+ width: 100%;
+ padding: 7px 12px;
+ right: -28px;
+ border-radius: 2px;
+ font-size: 12px;
+ line-height: 1.4;
+ -webkit-hyphens: none;
+ hyphens: none;
}
#adminmenu .toplevel_page_site-notices .upsell_banner .banner__info {
- margin-left: 12px;
+ margin-left: 12px;
}
#adminmenu .toplevel_page_site-notices .upsell_banner .button {
- font-size: 12px;
- line-height: 12px;
- padding: 0 7px;
- border: 0;
- min-height: 26px;
+ font-size: 12px;
+ line-height: 12px;
+ padding: 0 7px;
+ border: 0;
+ min-height: 26px;
}
#adminmenu .toplevel_page_site-notices .upsell_banner svg.dismissible-card__close-icon {
- height: 24px;
- width: 24px;
- margin-right: 10px;
+ height: 24px;
+ width: 24px;
+ margin-right: 10px;
}
@media screen and (min-width: 782px) {
- .folded #adminmenu .toplevel_page_site-notices .wp-menu-image {
- display: block;
- width: 30px;
- }
-
- .folded #adminmenu .toplevel_page_site-notices {
- height: 50px;
- display: flex;
- align-items: center;
- justify-content: center;
- }
+ .folded #adminmenu .toplevel_page_site-notices .wp-menu-image {
+ display: block;
+ width: 30px;
+ }
+
+ .folded #adminmenu .toplevel_page_site-notices {
+ height: 50px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
}
-
-@media screen and (min-width: 782px) and (max-width: 960px){
- .auto-fold #adminmenu .toplevel_page_site-notices .wp-menu-image {
- display: block;
- width: 30px;
- }
-
- .auto-fold #adminmenu .toplevel_page_site-notices {
- height: 50px;
- display: flex;
- align-items: center;
- justify-content: center;
- }
+@media screen and (min-width: 782px) and (max-width: 960px) {
+ .auto-fold #adminmenu .toplevel_page_site-notices .wp-menu-image {
+ display: block;
+ width: 30px;
+ }
+
+ .auto-fold #adminmenu .toplevel_page_site-notices {
+ height: 50px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
}
-
/* Prevent box-shadow at the top of the sidebar */
#adminmenu .site-switcher:hover,
#adminmenu .toplevel_page_site-card:hover,
#adminmenu .toplevel_page_site-notices:hover {
- box-shadow: none;
+ box-shadow: none;
}
/**
* Site icon inline-styles for height and width are defined in set_site_icon_inline_styles
*/
#adminmenu .toplevel_page_site-card .wp-menu-image {
- background-image: none;
- background-position: center;
- background-repeat: no-repeat;
- background-size: 18px 18px;
- transform: translateZ(0);
- transition-property: background-image,background-color;
- transition-duration: .2s;
+ background-image: none;
+ background-position: center;
+ background-repeat: no-repeat;
+ background-size: 18px 18px;
+ transform: translateZ(0);
+ transition-property: background-image, background-color;
+ transition-duration: 0.2s;
}
#adminmenu a.toplevel_page_site-card:hover,
#adminmenu li.toplevel_page_site-card:hover {
- background-color: inherit;
+ background-color: inherit;
}
#adminmenu .toplevel_page_site-card img {
- opacity: initial;
+ opacity: initial;
}
#adminmenu .toplevel_page_site-card.has-site-icon img {
- padding: 0;
+ padding: 0;
}
#adminmenu .toplevel_page_site-card:hover div.wp-menu-image,
#adminmenu .toplevel_page_site-card a:focus div.wp-menu-image {
- background-image: url("data:image/svg+xml,%3Csvg class='gridicon gridicons-house' height='24' width='24' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg%3E%3Cpath fill='%23fff' d='M22 9L12 1 2 9v2h2v10h5v-4c0-1.657 1.343-3 3-3s3 1.343 3 3v4h5V11h2V9z'/%3E%3C/g%3E%3C/svg%3E%0A");
+ background-image: url("data:image/svg+xml,%3Csvg class=%27gridicon gridicons-house%27 height=%2724%27 width=%2724%27 xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27%3E%3Cg%3E%3Cpath fill=%27%23fff%27 d=%27M22 9L12 1 2 9v2h2v10h5v-4c0-1.657 1.343-3 3-3s3 1.343 3 3v4h5V11h2V9z%27/%3E%3C/g%3E%3C/svg%3E%0A");
}
#adminmenu .toplevel_page_site-card:not(.has-site-icon) .wp-menu-image {
- background-color: #c3c4c7;
+ background-color: #c3c4c7;
}
#adminmenu .toplevel_page_site-card:not(.has-site-icon) .wp-menu-image img[src^="data:image/svg"] {
- height: auto;
- padding-top: 7px;
- width: 18px;
+ height: auto;
+ padding-top: 7px;
+ width: 18px;
}
#adminmenu .toplevel_page_site-card:hover div.wp-menu-image img,
#adminmenu .toplevel_page_site-card a:focus div.wp-menu-image img {
- display: none;
+ display: none;
}
.site__info .site__title {
- display: block;
- font-size: 14px;
- font-weight: 400;
- line-height: 1.3;
+ display: block;
+ font-size: 14px;
+ font-weight: 400;
+ line-height: 1.3;
}
.site__info .site__domain {
- display: block;
- max-width: 95%;
- font-size: 12px;
- line-height: 1.4;
- margin-top: 2px;
+ display: block;
+ max-width: 95%;
+ font-size: 12px;
+ line-height: 1.4;
+ margin-top: 2px;
}
.site__info .site__title,
.site__info .site__domain {
- overflow: hidden;
- white-space: nowrap;
+ overflow: hidden;
+ white-space: nowrap;
}
+
.site__info .site__title::after,
.site__info .site__domain::after {
- content: "";
- display: block;
- position: absolute;
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- user-select: none;
- pointer-events: none;
- top: 0;
- bottom: 0;
- left: 0;
- right: auto;
- width: 20%;
- height: auto;
+ content: "";
+ display: block;
+ position: absolute;
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ user-select: none;
+ pointer-events: none;
+ top: 0;
+ bottom: 0;
+ left: 0;
+ right: auto;
+ width: 20%;
+ height: auto;
}
.site__info > .site__badge {
- font-size: 12px;
- border-radius: 12px;
- clear: both;
- display: inline-block;
- margin-top: 6px;
- margin-left: 3px;
- padding: 1px 10px;
+ font-size: 12px;
+ border-radius: 12px;
+ clear: both;
+ display: inline-block;
+ margin-top: 6px;
+ margin-left: 3px;
+ padding: 1px 10px;
}
/**
* Inline text in a menu title
*/
.inline-text {
- display: block !important;
- position: absolute;
- left: 20px;
- top: 50%;
- transform: translateY( -50% );
- opacity: 0.8;
+ display: block !important;
+ position: absolute;
+ left: 20px;
+ top: 50%;
+ transform: translateY(-50%);
+ opacity: 0.8;
}
/**
* Stats
*/
[class*="toplevel_page_https://wordpress.com/stats/day"] .sidebar-unified__sparkline {
- float: left;
- margin-left: 8px;
+ float: left;
+ margin-left: 8px;
}
/**
* Folded State
*/
.folded #adminmenu a.menu-top {
- height: 31px;
+ height: 31px;
}
.folded #adminmenu li.toplevel_page_site-card a {
- padding-right: 0;
+ padding-right: 0;
}
/* Auto-folding of the admin menu */
@media only screen and (max-width: 960px) {
- #adminmenu,
- #adminmenuwrap,
- #adminmenuback {
- width: 272px;
- }
+ #adminmenu,
+#adminmenuwrap,
+#adminmenuback {
+ width: 272px;
+ }
- .auto-fold #adminmenu a[class*="toplevel_page_http"].wp-first-item {
- height: auto;
- }
+ .auto-fold #adminmenu a[class*=toplevel_page_http].wp-first-item {
+ height: auto;
+ }
- .wp-responsive-open #adminmenu a.menu-top {
- height: auto;
- }
+ .wp-responsive-open #adminmenu a.menu-top {
+ height: auto;
+ }
- .auto-fold #adminmenu div.wp-menu-image {
- width: 36px;
- }
+ .auto-fold #adminmenu div.wp-menu-image {
+ width: 36px;
+ }
}
-
@media screen and (min-width: 782px) and (max-width: 960px) {
- .auto-fold #adminmenu a.menu-top {
- height: 34px;
- }
+ .auto-fold #adminmenu a.menu-top {
+ height: 34px;
+ }
- .auto-fold #adminmenu li.toplevel_page_site-card a {
- height: 36px;
- padding-right: 1px;
- }
+ .auto-fold #adminmenu li.toplevel_page_site-card a {
+ height: 36px;
+ padding-right: 1px;
+ }
}
-
@media screen and (max-width: 782px) {
- #adminmenu li.menu-top .wp-submenu>li>a,
- .auto-fold #adminmenu li.menu-top .wp-submenu>li>a {
- padding-right: 42px;
- }
+ #adminmenu li.menu-top .wp-submenu > li > a,
+.auto-fold #adminmenu li.menu-top .wp-submenu > li > a {
+ padding-right: 42px;
+ }
- .wp-responsive-open #wpbody {
- left: inherit;
- }
+ .wp-responsive-open #wpbody {
+ left: inherit;
+ }
- .wp-responsive-open #wpcontent {
- margin-right: 272px;
- }
+ .wp-responsive-open #wpcontent {
+ margin-right: 272px;
+ }
- .auto-fold #adminmenu, .auto-fold #adminmenuback, .auto-fold #adminmenuwrap {
- width: 272px;
- }
+ .auto-fold #adminmenu, .auto-fold #adminmenuback, .auto-fold #adminmenuwrap {
+ width: 272px;
+ }
- .auto-fold #adminmenu a.site-switcher,
- #adminmenu a.site-switcher {
- font-size: 14px;
- }
+ .auto-fold #adminmenu a.site-switcher,
+#adminmenu a.site-switcher {
+ font-size: 14px;
+ }
}
-
@media only screen and (max-width: 660px) {
- #adminmenuback,
- #adminmenuwrap,
- #adminmenu,
- #adminmenu .wp-submenu,
- .auto-fold #adminmenu,
- .auto-fold #adminmenuback,
- .auto-fold #adminmenuwrap {
- width: 100%;
- z-index: 171;
- }
-
- .wp-responsive-open #wpcontent {
- margin-right: 0;
- }
-
- ul#adminmenu a.wp-has-current-submenu:after,
- ul#adminmenu>li.current>a.current:after,
- ul#adminmenu li:hover a.wp-has-current-submenu:after,
- .auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after {
- display: none;
- }
-
- .auto-fold #adminmenu li.toplevel_page_site-card a {
- padding: 18px 12px 18px 0;
- }
+ #adminmenuback,
+#adminmenuwrap,
+#adminmenu,
+#adminmenu .wp-submenu,
+.auto-fold #adminmenu,
+.auto-fold #adminmenuback,
+.auto-fold #adminmenuwrap {
+ width: 100%;
+ z-index: 171;
+ }
+
+ .wp-responsive-open #wpcontent {
+ margin-right: 0;
+ }
+
+ ul#adminmenu a.wp-has-current-submenu:after,
+ul#adminmenu > li.current > a.current:after,
+ul#adminmenu li:hover a.wp-has-current-submenu:after,
+.auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after {
+ display: none;
+ }
+
+ .auto-fold #adminmenu li.toplevel_page_site-card a {
+ padding: 18px 12px 18px 0;
+ }
}
-
/*
* Styles for the nav-unification prototype (see pbAPfg-O2)
* TODO: depending on project outcome move or delete styles
*/
#wpadminbar #wp-admin-bar-notes #wpnt-notes-unread-count.wpn-unread {
- top: 50%;
- right: 50%;
- transform: translate( 10px, -13px );
-
+ top: 50%;
+ right: 50%;
+ transform: translate(10px, -13px);
}
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar {
- transform: translateX( -1px );
+ transform: translateX(-1px);
}
#wpadminbar #wp-admin-bar-notes.active .noticon-bell:before {
- background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cmVjdCB4PSIwIiBmaWxsPSJub25lIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiLz48Zz48cGF0aCBmaWxsPSIjZmZmZmZmIiBkPSJNNi4xNCAxNC45N2wyLjgyOCAyLjgyN2MtLjM2Mi4zNjItLjg2Mi41ODYtMS40MTQuNTg2LTEuMTA1IDAtMi0uODk1LTItMiAwLS41NTIuMjI0LTEuMDUyLjU4Ni0xLjQxNHptOC44NjcgNS4zMjRMMTQuMyAyMSAzIDkuN2wuNzA2LS43MDcgMS4xMDIuMTU3Yy43NTQuMTA4IDEuNjktLjEyMiAyLjA3Ny0uNTFsMy44ODUtMy44ODRjMi4zNC0yLjM0IDYuMTM1LTIuMzQgOC40NzUgMHMyLjM0IDYuMTM1IDAgOC40NzVsLTMuODg1IDMuODg2Yy0uMzg4LjM4OC0uNjE4IDEuMzIzLS41MSAyLjA3N2wuMTU3IDEuMXoiLz48L2c+PC9zdmc+") !important;
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cmVjdCB4PSIwIiBmaWxsPSJub25lIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiLz48Zz48cGF0aCBmaWxsPSIjZmZmZmZmIiBkPSJNNi4xNCAxNC45N2wyLjgyOCAyLjgyN2MtLjM2Mi4zNjItLjg2Mi41ODYtMS40MTQuNTg2LTEuMTA1IDAtMi0uODk1LTItMiAwLS41NTIuMjI0LTEuMDUyLjU4Ni0xLjQxNHptOC44NjcgNS4zMjRMMTQuMyAyMSAzIDkuN2wuNzA2LS43MDcgMS4xMDIuMTU3Yy43NTQuMTA4IDEuNjktLjEyMiAyLjA3Ny0uNTFsMy44ODUtMy44ODRjMi4zNC0yLjM0IDYuMTM1LTIuMzQgOC40NzUgMHMyLjM0IDYuMTM1IDAgOC40NzVsLTMuODg1IDMuODg2Yy0uMzg4LjM4OC0uNjE4IDEuMzIzLS41MSAyLjA3N2wuMTU3IDEuMXoiLz48L2c+PC9zdmc+) !important;
}
#wpadminbar > #wp-toolbar .wpnt-show span.noticon,
#wpadminbar #wp-admin-bar-notes.wpnt-show .noticon {
- color: #ffffff;
+ color: #ffffff;
}
#wpadminbar .quicklinks ul#wp-admin-bar-root-default {
- padding-right: 0 !important;
+ padding-right: 0 !important;
}
#wpadminbar #wp-admin-bar-menu-toggle {
- display: none;
+ display: none;
}
@media screen and (max-width: 782px) {
- #wpadminbar #wp-toolbar > ul > li {
- display: block;
- }
-
- #wpadminbar .ab-top-menu > li > .ab-item {
- box-sizing: border-box;
- line-height: 32px;
- }
-
- #wpadminbar #wp-admin-bar-ab-new-post > .ab-item {
- box-sizing: inherit !important;
- }
-
- #wpadminbar #wp-admin-bar-my-account > .ab-item {
- padding: 7px 15px;
- width: auto;
- }
-
- #wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
- display: block;
- left: auto;
- right: auto;
- position: static;
- margin-top: 3px;
- top: 13px;
- }
-
- /* Hide debug bar. */
- #wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-debug-bar {
- display: none;
- }
+ #wpadminbar #wp-toolbar > ul > li {
+ display: block;
+ }
+
+ #wpadminbar .ab-top-menu > li > .ab-item {
+ box-sizing: border-box;
+ line-height: 32px;
+ }
+
+ #wpadminbar #wp-admin-bar-ab-new-post > .ab-item {
+ box-sizing: inherit !important;
+ }
+
+ #wpadminbar #wp-admin-bar-my-account > .ab-item {
+ padding: 7px 15px;
+ width: auto;
+ }
+
+ #wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
+ display: block;
+ left: auto;
+ right: auto;
+ position: static;
+ margin-top: 3px;
+ top: 13px;
+ }
+
+ /* Hide debug bar. */
+ #wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-debug-bar {
+ display: none;
+ }
+}
+@media screen and (max-width: 480px) {
+ #wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar > a {
+ width: auto;
+ }
+
+ #wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
+ margin-top: 12px;
+ }
+}
+/* Dashboard Switcher */
+#view-link-wrap {
+ float: right;
+ margin: 0 6px 0 0;
+}
+
+.screen-options-tab__wrapper {
+ position: relative;
+}
+
+.screen-options-tab__dropdown {
+ background-color: #fff;
+ border: 1px solid var(--color-neutral-5);
+ border-radius: 4px;
+ box-shadow: 0 4px 10px #0000001a;
+ padding: 3px;
+ position: absolute;
+ left: 20px;
+ top: 37px;
+ width: 215px;
+ z-index: 9999;
}
-@media screen and (max-width: 480px) {
- #wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar > a {
- width: auto;
- }
-
- #wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
- margin-top: 12px;
- }
+@media screen and (max-width: 782px) {
+ .screen-options-tab__dropdown {
+ left: 10px;
+ top: 47px;
+ }
}
-
-/* Fixes the order of screen options,
- * showing the dashboard switcher button always first.
-*/
-#adv-settings {
- display: flex;
- flex-direction: column;
+@media screen and (max-width: 600px) {
+ .screen-options-tab__dropdown {
+ top: 93px;
+ }
+}
+.screen-switcher:not(:hover) .screen-switcher__button:nth-child(2) > strong {
+ color: var(--wp-admin-theme-color);
}
-/* Switcher should always be in the top */
-#adv-settings #dashboard-switcher {
- order: 0;
+.screen-switcher__button, a.screen-switcher__button {
+ background: transparent;
+ border: 1px solid #0000;
+ border-radius: 4px;
+ color: var(--color-text);
+ cursor: pointer;
+ display: inline-block;
+ font-size: 0.75rem;
+ line-height: normal;
+ text-decoration: none;
+ padding: 8px;
+ text-align: right;
}
-#adv-settings .dashboard-switcher-text {
- margin-top: 0;
+.screen-switcher__button:nth-child(2), a.screen-switcher__button:nth-child(2) {
+ border-color: var(--wp-admin-theme-color);
+ margin-bottom: 4px;
}
-#adv-settings .dashboard-switcher-button {
- padding: 3px 16px;
+.screen-switcher__button:last-child, a.screen-switcher__button:last-child {
+ margin-bottom: 0;
}
-/* Core registered options should be after the switcher */
-#adv-settings fieldset {
- order: 1;
+.screen-switcher__button strong, a.screen-switcher__button strong {
+ display: block;
+ font-size: 13px;
+ margin-bottom: 4px;
}
-/* Submit button should always be in the bottom */
-#adv-settings .submit {
- order: 2;
+.screen-switcher__button:focus > strong, .screen-switcher__button:hover > strong, a.screen-switcher__button:focus > strong, a.screen-switcher__button:hover > strong {
+ color: var(--wp-admin-theme-color);
}
diff --git a/plugins/jetpack/modules/masterbar/admin-menu/admin-menu-rtl.min.css b/plugins/jetpack/modules/masterbar/admin-menu/admin-menu-rtl.min.css
index 63bf1689..1dfbe353 100644
--- a/plugins/jetpack/modules/masterbar/admin-menu/admin-menu-rtl.min.css
+++ b/plugins/jetpack/modules/masterbar/admin-menu/admin-menu-rtl.min.css
@@ -1 +1 @@
-#adminmenu{margin:0}#wpcontent,#wpfooter{margin-right:272px}#adminmenu,#adminmenu .wp-submenu,#adminmenuback,#adminmenuwrap{width:272px}#adminmenu .wp-submenu{right:272px}#adminmenu .wp-not-current-submenu .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{min-width:272px}@media (min-width:783px){.edit-post-layout .components-editor-notices__snackbar,.interface-interface-skeleton{right:272px}}@media (min-width:961px){.auto-fold .edit-post-layout .components-editor-notices__snackbar,.auto-fold .interface-interface-skeleton,.jp-dialogue-modern-full__container{right:272px}.global-notices{max-width:calc(100% - 48px - 272px)}}#adminmenu [class*=activity-log] .wp-menu-image img{padding-top:7px}#adminmenu .toplevel_page_site-card .wp-menu-name{margin-right:40px;padding:0}#adminmenu li.toplevel_page_site-card a{padding:10px 8px 10px 0}#adminmenu a.toplevel_page_site-notices:focus,#adminmenu a.toplevel_page_site-notices:hover,#adminmenu li.toplevel_page_site-notices:focus,#adminmenu li.toplevel_page_site-notices:hover{background-color:inherit!important;color:inherit!important}#adminmenu li.toplevel_page_site-notices .wp-menu-image{display:none}#adminmenu .toplevel_page_site-notices .wp-menu-image{border-radius:2px;background-color:#fff}#adminmenu .toplevel_page_site-notices .wp-menu-image:before{content:'\f534';font-family:dashicons;font-size:20px;line-height:20px;background-color:#a7aaad;color:#fff;border-radius:50%;margin:5px;padding:0}#adminmenu .toplevel_page_site-notices:hover .wp-menu-image:before{color:#fff}#adminmenu .toplevel_page_site-notices .upsell_banner{display:flex;flex-grow:1;flex-wrap:nowrap;align-items:center;justify-content:space-between;position:relative;width:100%;padding:7px 12px;right:-28px;border-radius:2px;font-size:12px;line-height:1.4;-webkit-hyphens:none;hyphens:none}#adminmenu .toplevel_page_site-notices .upsell_banner .banner__info{margin-left:12px}#adminmenu .toplevel_page_site-notices .upsell_banner .button{font-size:12px;line-height:12px;padding:0 7px;border:0;min-height:26px}#adminmenu .toplevel_page_site-notices .upsell_banner svg.dismissible-card__close-icon{height:24px;width:24px;margin-right:10px}@media screen and (min-width:782px){.folded #adminmenu .toplevel_page_site-notices .wp-menu-image{display:block;width:30px}.folded #adminmenu .toplevel_page_site-notices{height:50px;display:flex;align-items:center;justify-content:center}}@media screen and (min-width:782px) and (max-width:960px){.auto-fold #adminmenu .toplevel_page_site-notices .wp-menu-image{display:block;width:30px}.auto-fold #adminmenu .toplevel_page_site-notices{height:50px;display:flex;align-items:center;justify-content:center}}#adminmenu .site-switcher:hover,#adminmenu .toplevel_page_site-card:hover,#adminmenu .toplevel_page_site-notices:hover{box-shadow:none}#adminmenu .toplevel_page_site-card .wp-menu-image{background-image:none;background-position:center;background-repeat:no-repeat;background-size:18px 18px;transform:translateZ(0);transition-property:background-image,background-color;transition-duration:.2s}#adminmenu a.toplevel_page_site-card:hover,#adminmenu li.toplevel_page_site-card:hover{background-color:inherit}#adminmenu .toplevel_page_site-card img{opacity:initial}#adminmenu .toplevel_page_site-card.has-site-icon img{padding:0}#adminmenu .toplevel_page_site-card a:focus div.wp-menu-image,#adminmenu .toplevel_page_site-card:hover div.wp-menu-image{background-image:url("data:image/svg+xml,%3Csvg class='gridicon gridicons-house' height='24' width='24' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg%3E%3Cpath fill='%23fff' d='M22 9L12 1 2 9v2h2v10h5v-4c0-1.657 1.343-3 3-3s3 1.343 3 3v4h5V11h2V9z'/%3E%3C/g%3E%3C/svg%3E%0A")}#adminmenu .toplevel_page_site-card:not(.has-site-icon) .wp-menu-image{background-color:#c3c4c7}#adminmenu .toplevel_page_site-card:not(.has-site-icon) .wp-menu-image img[src^="data:image/svg"]{height:auto;padding-top:7px;width:18px}#adminmenu .toplevel_page_site-card a:focus div.wp-menu-image img,#adminmenu .toplevel_page_site-card:hover div.wp-menu-image img{display:none}.site__info .site__title{display:block;font-size:14px;font-weight:400;line-height:1.3}.site__info .site__domain{display:block;max-width:95%;font-size:12px;line-height:1.4;margin-top:2px}.site__info .site__domain,.site__info .site__title{overflow:hidden;white-space:nowrap}.site__info .site__domain::after,.site__info .site__title::after{content:"";display:block;position:absolute;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;pointer-events:none;top:0;bottom:0;left:0;right:auto;width:20%;height:auto}.site__info>.site__badge{font-size:12px;border-radius:12px;clear:both;display:inline-block;margin-top:6px;margin-left:3px;padding:1px 10px}.inline-text{display:block!important;position:absolute;left:20px;top:50%;transform:translateY(-50%);opacity:.8}[class*="toplevel_page_https://wordpress.com/stats/day"] .sidebar-unified__sparkline{float:left;margin-left:8px}.folded #adminmenu a.menu-top{height:31px}.folded #adminmenu li.toplevel_page_site-card a{padding-right:0}@media only screen and (max-width:960px){#adminmenu,#adminmenuback,#adminmenuwrap{width:272px}.auto-fold #adminmenu a[class*=toplevel_page_http].wp-first-item{height:auto}.wp-responsive-open #adminmenu a.menu-top{height:auto}.auto-fold #adminmenu div.wp-menu-image{width:36px}}@media screen and (min-width:782px) and (max-width:960px){.auto-fold #adminmenu a.menu-top{height:34px}.auto-fold #adminmenu li.toplevel_page_site-card a{height:36px;padding-right:1px}}@media screen and (max-width:782px){#adminmenu li.menu-top .wp-submenu>li>a,.auto-fold #adminmenu li.menu-top .wp-submenu>li>a{padding-right:42px}.wp-responsive-open #wpbody{left:inherit}.wp-responsive-open #wpcontent{margin-right:272px}.auto-fold #adminmenu,.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{width:272px}#adminmenu a.site-switcher,.auto-fold #adminmenu a.site-switcher{font-size:14px}}@media only screen and (max-width:660px){#adminmenu,#adminmenu .wp-submenu,#adminmenuback,#adminmenuwrap,.auto-fold #adminmenu,.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{width:100%;z-index:171}.wp-responsive-open #wpcontent{margin-right:0}.auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after,ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu li:hover a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{display:none}.auto-fold #adminmenu li.toplevel_page_site-card a{padding:18px 12px 18px 0}}#wpadminbar #wp-admin-bar-notes #wpnt-notes-unread-count.wpn-unread{top:50%;right:50%;transform:translate(10px,-13px)}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar{transform:translateX(-1px)}#wpadminbar #wp-admin-bar-notes.active .noticon-bell:before{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cmVjdCB4PSIwIiBmaWxsPSJub25lIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiLz48Zz48cGF0aCBmaWxsPSIjZmZmZmZmIiBkPSJNNi4xNCAxNC45N2wyLjgyOCAyLjgyN2MtLjM2Mi4zNjItLjg2Mi41ODYtMS40MTQuNTg2LTEuMTA1IDAtMi0uODk1LTItMiAwLS41NTIuMjI0LTEuMDUyLjU4Ni0xLjQxNHptOC44NjcgNS4zMjRMMTQuMyAyMSAzIDkuN2wuNzA2LS43MDcgMS4xMDIuMTU3Yy43NTQuMTA4IDEuNjktLjEyMiAyLjA3Ny0uNTFsMy44ODUtMy44ODRjMi4zNC0yLjM0IDYuMTM1LTIuMzQgOC40NzUgMHMyLjM0IDYuMTM1IDAgOC40NzVsLTMuODg1IDMuODg2Yy0uMzg4LjM4OC0uNjE4IDEuMzIzLS41MSAyLjA3N2wuMTU3IDEuMXoiLz48L2c+PC9zdmc+)!important}#wpadminbar #wp-admin-bar-notes.wpnt-show .noticon,#wpadminbar>#wp-toolbar .wpnt-show span.noticon{color:#fff}#wpadminbar .quicklinks ul#wp-admin-bar-root-default{padding-right:0!important}#wpadminbar #wp-admin-bar-menu-toggle{display:none}@media screen and (max-width:782px){#wpadminbar #wp-toolbar>ul>li{display:block}#wpadminbar .ab-top-menu>li>.ab-item{box-sizing:border-box;line-height:32px}#wpadminbar #wp-admin-bar-ab-new-post>.ab-item{box-sizing:inherit!important}#wpadminbar #wp-admin-bar-my-account>.ab-item{padding:7px 15px;width:auto}#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar>a img{display:block;left:auto;right:auto;position:static;margin-top:3px;top:13px}#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-debug-bar{display:none}}@media screen and (max-width:480px){#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar>a{width:auto}#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar>a img{margin-top:12px}}#adv-settings{display:flex;flex-direction:column}#adv-settings #dashboard-switcher{order:0}#adv-settings .dashboard-switcher-text{margin-top:0}#adv-settings .dashboard-switcher-button{padding:3px 16px}#adv-settings fieldset{order:1}#adv-settings .submit{order:2} \ No newline at end of file
+#adminmenu{margin:0}#wpcontent,#wpfooter{margin-right:272px}#adminmenu,#adminmenu .wp-submenu,#adminmenuback,#adminmenuwrap{width:272px}#adminmenu .wp-submenu{right:272px}#adminmenu .wp-not-current-submenu .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{min-width:272px}@media (min-width:783px){.edit-post-layout .components-editor-notices__snackbar,.interface-interface-skeleton{right:272px}}@media (min-width:961px){.auto-fold .edit-post-layout .components-editor-notices__snackbar,.auto-fold .interface-interface-skeleton,.jp-dialogue-modern-full__container{right:272px}.global-notices{max-width:calc(100% - 320px)}}#adminmenu [class*=activity-log] .wp-menu-image img{padding-top:7px}#adminmenu .toplevel_page_site-card .wp-menu-name{margin-right:40px;padding:0}#adminmenu li.toplevel_page_site-card a{padding:10px 8px 10px 0}#adminmenu a.toplevel_page_site-notices:focus,#adminmenu a.toplevel_page_site-notices:hover,#adminmenu li.toplevel_page_site-notices:focus,#adminmenu li.toplevel_page_site-notices:hover{background-color:inherit!important;color:inherit!important}#adminmenu li.toplevel_page_site-notices .wp-menu-image{display:none}#adminmenu .toplevel_page_site-notices .wp-menu-image{background-color:#fff;border-radius:2px}#adminmenu .toplevel_page_site-notices .wp-menu-image:before{background-color:#a7aaad;border-radius:50%;color:#fff;content:"\f534";font-family:dashicons;font-size:20px;line-height:20px;margin:5px;padding:0}#adminmenu .toplevel_page_site-notices:hover .wp-menu-image:before{color:#fff}#adminmenu .toplevel_page_site-notices .upsell_banner{align-items:center;border-radius:2px;display:flex;flex-grow:1;flex-wrap:nowrap;font-size:12px;-webkit-hyphens:none;hyphens:none;justify-content:space-between;line-height:1.4;padding:7px 12px;position:relative;right:-28px;width:100%}#adminmenu .toplevel_page_site-notices .upsell_banner .banner__info{margin-left:12px}#adminmenu .toplevel_page_site-notices .upsell_banner .button{border:0;font-size:12px;line-height:12px;min-height:26px;padding:0 7px}#adminmenu .toplevel_page_site-notices .upsell_banner svg.dismissible-card__close-icon{height:24px;margin-right:10px;width:24px}@media screen and (min-width:782px){.folded #adminmenu .toplevel_page_site-notices .wp-menu-image{display:block;width:30px}.folded #adminmenu .toplevel_page_site-notices{align-items:center;display:flex;height:50px;justify-content:center}}@media screen and (min-width:782px) and (max-width:960px){.auto-fold #adminmenu .toplevel_page_site-notices .wp-menu-image{display:block;width:30px}.auto-fold #adminmenu .toplevel_page_site-notices{align-items:center;display:flex;height:50px;justify-content:center}}#adminmenu .site-switcher:hover,#adminmenu .toplevel_page_site-card:hover,#adminmenu .toplevel_page_site-notices:hover{box-shadow:none}#adminmenu .toplevel_page_site-card .wp-menu-image{background-image:none;background-position:50%;background-repeat:no-repeat;background-size:18px 18px;transform:translateZ(0);transition-duration:.2s;transition-property:background-image,background-color}#adminmenu a.toplevel_page_site-card:hover,#adminmenu li.toplevel_page_site-card:hover{background-color:inherit}#adminmenu .toplevel_page_site-card img{opacity:1}#adminmenu .toplevel_page_site-card.has-site-icon img{padding:0}#adminmenu .toplevel_page_site-card a:focus div.wp-menu-image,#adminmenu .toplevel_page_site-card:hover div.wp-menu-image{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg class='gridicon gridicons-house' height='24' width='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23fff' d='M22 9 12 1 2 9v2h2v10h5v-4a3 3 0 1 1 6 0v4h5V11h2V9z'/%3E%3C/svg%3E")}#adminmenu .toplevel_page_site-card:not(.has-site-icon) .wp-menu-image{background-color:#c3c4c7}#adminmenu .toplevel_page_site-card:not(.has-site-icon) .wp-menu-image img[src^="data:image/svg"]{height:auto;padding-top:7px;width:18px}#adminmenu .toplevel_page_site-card a:focus div.wp-menu-image img,#adminmenu .toplevel_page_site-card:hover div.wp-menu-image img{display:none}.site__info .site__title{display:block;font-size:14px;font-weight:400;line-height:1.3}.site__info .site__domain{display:block;font-size:12px;line-height:1.4;margin-top:2px;max-width:95%}.site__info .site__domain,.site__info .site__title{overflow:hidden;white-space:nowrap}.site__info .site__domain:after,.site__info .site__title:after{-webkit-touch-callout:none;bottom:0;content:"";display:block;height:auto;left:0;pointer-events:none;position:absolute;right:auto;top:0;-webkit-user-select:none;user-select:none;width:20%}.site__info>.site__badge{border-radius:12px;clear:both;display:inline-block;font-size:12px;margin-left:3px;margin-top:6px;padding:1px 10px}.inline-text{display:block!important;left:20px;opacity:.8;position:absolute;top:50%;transform:translateY(-50%)}[class*="toplevel_page_https://wordpress.com/stats/day"] .sidebar-unified__sparkline{float:left;margin-left:8px}.folded #adminmenu a.menu-top{height:31px}.folded #adminmenu li.toplevel_page_site-card a{padding-right:0}@media only screen and (max-width:960px){#adminmenu,#adminmenuback,#adminmenuwrap{width:272px}.auto-fold #adminmenu a[class*=toplevel_page_http].wp-first-item,.wp-responsive-open #adminmenu a.menu-top{height:auto}.auto-fold #adminmenu div.wp-menu-image{width:36px}}@media screen and (min-width:782px) and (max-width:960px){.auto-fold #adminmenu a.menu-top{height:34px}.auto-fold #adminmenu li.toplevel_page_site-card a{height:36px;padding-right:1px}}@media screen and (max-width:782px){#adminmenu li.menu-top .wp-submenu>li>a,.auto-fold #adminmenu li.menu-top .wp-submenu>li>a{padding-right:42px}.wp-responsive-open #wpbody{left:inherit}.wp-responsive-open #wpcontent{margin-right:272px}.auto-fold #adminmenu,.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{width:272px}#adminmenu a.site-switcher,.auto-fold #adminmenu a.site-switcher{font-size:14px}}@media only screen and (max-width:660px){#adminmenu,#adminmenu .wp-submenu,#adminmenuback,#adminmenuwrap,.auto-fold #adminmenu,.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{width:100%;z-index:171}.wp-responsive-open #wpcontent{margin-right:0}.auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after,ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu li:hover a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{display:none}.auto-fold #adminmenu li.toplevel_page_site-card a{padding:18px 12px 18px 0}}#wpadminbar #wp-admin-bar-notes #wpnt-notes-unread-count.wpn-unread{right:50%;top:50%;transform:translate(10px,-13px)}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar{transform:translateX(-1px)}#wpadminbar #wp-admin-bar-notes.active .noticon-bell:before{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgyNHYyNEgweiIvPjxwYXRoIGZpbGw9IiNmZmYiIGQ9Im02LjE0IDE0Ljk3IDIuODI4IDIuODI3YTIgMiAwIDEgMS0yLjgyOC0yLjgyOHptOC44NjcgNS4zMjRMMTQuMyAyMSAzIDkuN2wuNzA2LS43MDcgMS4xMDIuMTU3Yy43NTQuMTA4IDEuNjktLjEyMiAyLjA3Ny0uNTFsMy44ODUtMy44ODRhNS45OTMgNS45OTMgMCAwIDEgOC40NzUgOC40NzVsLTMuODg1IDMuODg2Yy0uMzg4LjM4OC0uNjE4IDEuMzIzLS41MSAyLjA3N2wuMTU3IDEuMXoiLz48L3N2Zz4=)!important}#wpadminbar #wp-admin-bar-notes.wpnt-show .noticon,#wpadminbar>#wp-toolbar .wpnt-show span.noticon{color:#fff}#wpadminbar .quicklinks ul#wp-admin-bar-root-default{padding-right:0!important}#wpadminbar #wp-admin-bar-menu-toggle{display:none}@media screen and (max-width:782px){#wpadminbar #wp-toolbar>ul>li{display:block}#wpadminbar .ab-top-menu>li>.ab-item{box-sizing:border-box;line-height:32px}#wpadminbar #wp-admin-bar-ab-new-post>.ab-item{box-sizing:inherit!important}#wpadminbar #wp-admin-bar-my-account>.ab-item{padding:7px 15px;width:auto}#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar>a img{display:block;left:auto;margin-top:3px;position:static;right:auto;top:13px}#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-debug-bar{display:none}}@media screen and (max-width:480px){#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar>a{width:auto}#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar>a img{margin-top:12px}}#view-link-wrap{float:right;margin:0 6px 0 0}.screen-options-tab__wrapper{position:relative}.screen-options-tab__dropdown{background-color:#fff;border:1px solid var(--color-neutral-5);border-radius:4px;box-shadow:0 4px 10px #0000001a;left:20px;padding:3px;position:absolute;top:37px;width:215px;z-index:9999}@media screen and (max-width:782px){.screen-options-tab__dropdown{left:10px;top:47px}}@media screen and (max-width:600px){.screen-options-tab__dropdown{top:93px}}.screen-switcher:not(:hover) .screen-switcher__button:nth-child(2)>strong{color:var(--wp-admin-theme-color)}.screen-switcher__button,a.screen-switcher__button{background:transparent;border:1px solid #0000;border-radius:4px;color:var(--color-text);cursor:pointer;display:inline-block;font-size:.75rem;line-height:normal;padding:8px;text-align:right;text-decoration:none}.screen-switcher__button:nth-child(2),a.screen-switcher__button:nth-child(2){border-color:var(--wp-admin-theme-color);margin-bottom:4px}.screen-switcher__button:last-child,a.screen-switcher__button:last-child{margin-bottom:0}.screen-switcher__button strong,a.screen-switcher__button strong{display:block;font-size:13px;margin-bottom:4px}.screen-switcher__button:focus>strong,.screen-switcher__button:hover>strong,a.screen-switcher__button:focus>strong,a.screen-switcher__button:hover>strong{color:var(--wp-admin-theme-color)} \ No newline at end of file
diff --git a/plugins/jetpack/modules/masterbar/admin-menu/admin-menu.css b/plugins/jetpack/modules/masterbar/admin-menu/admin-menu.css
index 92b762cb..72ddaf39 100644
--- a/plugins/jetpack/modules/masterbar/admin-menu/admin-menu.css
+++ b/plugins/jetpack/modules/masterbar/admin-menu/admin-menu.css
@@ -456,33 +456,75 @@
}
}
-/* Fixes the order of screen options,
- * showing the dashboard switcher button always first.
-*/
-#adv-settings {
- display: flex;
- flex-direction: column;
+/* Dashboard Switcher */
+#view-link-wrap {
+ float: left;
+ margin: 0 0 0 6px;
+}
+
+.screen-options-tab__wrapper {
+ position:relative
+}
+
+.screen-options-tab__dropdown {
+ background-color: #fff;
+ border: 1px solid var(--color-neutral-5);
+ border-radius: 4px;
+ box-shadow: 0 4px 10px #0000001a;
+ padding: 3px;
+ position: absolute;
+ right: 20px;
+ top: 37px;
+ width:215px;
+ z-index: 9999;
+}
+
+@media screen and (max-width: 782px) {
+ .screen-options-tab__dropdown {
+ right: 10px;
+ top: 47px;
+ }
}
-/* Switcher should always be in the top */
-#adv-settings #dashboard-switcher {
- order: 0;
+@media screen and (max-width: 600px) {
+ .screen-options-tab__dropdown {
+ top: 93px;
+ }
}
-#adv-settings .dashboard-switcher-text {
- margin-top: 0;
+.screen-switcher:not(:hover) .screen-switcher__button:nth-child(2) > strong {
+ color:var(--wp-admin-theme-color)
}
-#adv-settings .dashboard-switcher-button {
- padding: 3px 16px;
+.screen-switcher__button, a.screen-switcher__button {
+ background: transparent;
+ border: 1px solid #0000;
+ border-radius: 4px;
+ color: var(--color-text);
+ cursor: pointer;
+ display: inline-block;
+ font-size: .75rem;
+ line-height: normal;
+ text-decoration: none;
+ padding: 8px;
+ text-align:left
}
-/* Core registered options should be after the switcher */
-#adv-settings fieldset {
- order: 1;
+.screen-switcher__button:nth-child(2), a.screen-switcher__button:nth-child(2) {
+ border-color: var(--wp-admin-theme-color);
+ margin-bottom:4px
+}
+
+.screen-switcher__button:last-child, a.screen-switcher__button:last-child {
+ margin-bottom:0
+}
+
+.screen-switcher__button strong, a.screen-switcher__button strong {
+ display: block;
+ font-size: 13px;
+ margin-bottom:4px
}
-/* Submit button should always be in the bottom */
-#adv-settings .submit {
- order: 2;
+.screen-switcher__button:focus > strong, .screen-switcher__button:hover > strong, a.screen-switcher__button:focus > strong, a.screen-switcher__button:hover > strong {
+ color:var(--wp-admin-theme-color)
}
diff --git a/plugins/jetpack/modules/masterbar/admin-menu/admin-menu.js b/plugins/jetpack/modules/masterbar/admin-menu/admin-menu.js
index ce385913..59f8764b 100644
--- a/plugins/jetpack/modules/masterbar/admin-menu/admin-menu.js
+++ b/plugins/jetpack/modules/masterbar/admin-menu/admin-menu.js
@@ -5,6 +5,7 @@
var adminbar = document.querySelector( '#wpadminbar' );
var wpwrap = document.querySelector( '#wpwrap' );
var adminMenu = document.querySelector( '#adminmenu' );
+ var dismissClass = 'dismissible-card__close-icon';
if ( ! adminbar ) {
return;
@@ -59,9 +60,11 @@
} );
}
- const jitmDismissButton = adminMenu.querySelector( '.dismissible-card__close-icon' );
- if ( jitmDismissButton ) {
- jitmDismissButton.addEventListener( 'click', function ( event ) {
+ adminMenu.addEventListener( 'click', function ( event ) {
+ if (
+ event.target.classList.contains( dismissClass ) ||
+ event.target.closest( '.' + dismissClass )
+ ) {
event.preventDefault();
const siteNotice = document.getElementById( 'toplevel_page_site-notices' );
@@ -69,6 +72,8 @@
siteNotice.style.display = 'none';
}
+ const jitmDismissButton = event.target;
+
makeAjaxRequest(
'POST',
ajaxurl,
@@ -81,12 +86,32 @@
'&_ajax_nonce=' +
jetpackAdminMenu.jitmDismissNonce
);
- } );
- }
+ }
+ } );
+
+ makeAjaxRequest(
+ 'GET',
+ ajaxurl + '?action=upsell_nudge_jitm&_ajax_nonce=' + jetpackAdminMenu.upsellNudgeJitm,
+ undefined,
+ null,
+ function ( xhr ) {
+ try {
+ if ( xhr.readyState === XMLHttpRequest.DONE ) {
+ if ( xhr.status === 200 && xhr.responseText ) {
+ adminMenu
+ .querySelector( '#toplevel_page_site_card' )
+ .insertAdjacentHTML( 'afterend', xhr.responseText );
+ }
+ }
+ } catch ( error ) {
+ // On failure, we just won't display an upsell nudge
+ }
+ }
+ );
}
}
- function makeAjaxRequest( method, url, contentType, body ) {
+ function makeAjaxRequest( method, url, contentType, body = null, callback = null ) {
var xhr = new XMLHttpRequest();
xhr.open( method, url, true );
xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest' );
@@ -94,6 +119,11 @@
xhr.setRequestHeader( 'Content-Type', contentType );
}
xhr.withCredentials = true;
+ if ( callback ) {
+ xhr.onreadystatechange = function () {
+ callback( xhr );
+ };
+ }
xhr.send( body );
}
diff --git a/plugins/jetpack/modules/masterbar/admin-menu/admin-menu.min.css b/plugins/jetpack/modules/masterbar/admin-menu/admin-menu.min.css
index 1b50ea73..c06386d7 100644
--- a/plugins/jetpack/modules/masterbar/admin-menu/admin-menu.min.css
+++ b/plugins/jetpack/modules/masterbar/admin-menu/admin-menu.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-#adminmenu{margin:0}#wpcontent,#wpfooter{margin-left:272px}#adminmenu,#adminmenu .wp-submenu,#adminmenuback,#adminmenuwrap{width:272px}#adminmenu .wp-submenu{left:272px}#adminmenu .wp-not-current-submenu .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{min-width:272px}@media (min-width:783px){.edit-post-layout .components-editor-notices__snackbar,.interface-interface-skeleton{left:272px}}@media (min-width:961px){.auto-fold .edit-post-layout .components-editor-notices__snackbar,.auto-fold .interface-interface-skeleton,.jp-dialogue-modern-full__container{left:272px}.global-notices{max-width:calc(100% - 48px - 272px)}}#adminmenu [class*=activity-log] .wp-menu-image img{padding-top:7px}#adminmenu .toplevel_page_site-card .wp-menu-name{margin-left:40px;padding:0}#adminmenu li.toplevel_page_site-card a{padding:10px 0 10px 8px}#adminmenu a.toplevel_page_site-notices:focus,#adminmenu a.toplevel_page_site-notices:hover,#adminmenu li.toplevel_page_site-notices:focus,#adminmenu li.toplevel_page_site-notices:hover{background-color:inherit!important;color:inherit!important}#adminmenu li.toplevel_page_site-notices .wp-menu-image{display:none}#adminmenu .toplevel_page_site-notices .wp-menu-image{border-radius:2px;background-color:#fff}#adminmenu .toplevel_page_site-notices .wp-menu-image:before{content:'\f534';font-family:dashicons;font-size:20px;line-height:20px;background-color:#a7aaad;color:#fff;border-radius:50%;margin:5px;padding:0}#adminmenu .toplevel_page_site-notices:hover .wp-menu-image:before{color:#fff}#adminmenu .toplevel_page_site-notices .upsell_banner{display:flex;flex-grow:1;flex-wrap:nowrap;align-items:center;justify-content:space-between;position:relative;width:100%;padding:7px 12px;left:-28px;border-radius:2px;font-size:12px;line-height:1.4;-webkit-hyphens:none;hyphens:none}#adminmenu .toplevel_page_site-notices .upsell_banner .banner__info{margin-right:12px}#adminmenu .toplevel_page_site-notices .upsell_banner .button{font-size:12px;line-height:12px;padding:0 7px;border:0;min-height:26px}#adminmenu .toplevel_page_site-notices .upsell_banner svg.dismissible-card__close-icon{height:24px;width:24px;margin-left:10px}@media screen and (min-width:782px){.folded #adminmenu .toplevel_page_site-notices .wp-menu-image{display:block;width:30px}.folded #adminmenu .toplevel_page_site-notices{height:50px;display:flex;align-items:center;justify-content:center}}@media screen and (min-width:782px) and (max-width:960px){.auto-fold #adminmenu .toplevel_page_site-notices .wp-menu-image{display:block;width:30px}.auto-fold #adminmenu .toplevel_page_site-notices{height:50px;display:flex;align-items:center;justify-content:center}}#adminmenu .site-switcher:hover,#adminmenu .toplevel_page_site-card:hover,#adminmenu .toplevel_page_site-notices:hover{box-shadow:none}#adminmenu .toplevel_page_site-card .wp-menu-image{background-image:none;background-position:center;background-repeat:no-repeat;background-size:18px 18px;transform:translateZ(0);transition-property:background-image,background-color;transition-duration:.2s}#adminmenu a.toplevel_page_site-card:hover,#adminmenu li.toplevel_page_site-card:hover{background-color:inherit}#adminmenu .toplevel_page_site-card img{opacity:initial}#adminmenu .toplevel_page_site-card.has-site-icon img{padding:0}#adminmenu .toplevel_page_site-card a:focus div.wp-menu-image,#adminmenu .toplevel_page_site-card:hover div.wp-menu-image{background-image:url("data:image/svg+xml,%3Csvg class='gridicon gridicons-house' height='24' width='24' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg%3E%3Cpath fill='%23fff' d='M22 9L12 1 2 9v2h2v10h5v-4c0-1.657 1.343-3 3-3s3 1.343 3 3v4h5V11h2V9z'/%3E%3C/g%3E%3C/svg%3E%0A")}#adminmenu .toplevel_page_site-card:not(.has-site-icon) .wp-menu-image{background-color:#c3c4c7}#adminmenu .toplevel_page_site-card:not(.has-site-icon) .wp-menu-image img[src^="data:image/svg"]{height:auto;padding-top:7px;width:18px}#adminmenu .toplevel_page_site-card a:focus div.wp-menu-image img,#adminmenu .toplevel_page_site-card:hover div.wp-menu-image img{display:none}.site__info .site__title{display:block;font-size:14px;font-weight:400;line-height:1.3}.site__info .site__domain{display:block;max-width:95%;font-size:12px;line-height:1.4;margin-top:2px}.site__info .site__domain,.site__info .site__title{overflow:hidden;white-space:nowrap}.site__info .site__domain::after,.site__info .site__title::after{content:"";display:block;position:absolute;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;pointer-events:none;top:0;bottom:0;right:0;left:auto;width:20%;height:auto}.site__info>.site__badge{font-size:12px;border-radius:12px;clear:both;display:inline-block;margin-top:6px;margin-right:3px;padding:1px 10px}.inline-text{display:block!important;position:absolute;right:20px;top:50%;transform:translateY(-50%);opacity:.8}[class*="toplevel_page_https://wordpress.com/stats/day"] .sidebar-unified__sparkline{float:right;margin-right:8px}.folded #adminmenu a.menu-top{height:31px}.folded #adminmenu li.toplevel_page_site-card a{padding-left:0}@media only screen and (max-width:960px){#adminmenu,#adminmenuback,#adminmenuwrap{width:272px}.auto-fold #adminmenu a[class*=toplevel_page_http].wp-first-item{height:auto}.wp-responsive-open #adminmenu a.menu-top{height:auto}.auto-fold #adminmenu div.wp-menu-image{width:36px}}@media screen and (min-width:782px) and (max-width:960px){.auto-fold #adminmenu a.menu-top{height:34px}.auto-fold #adminmenu li.toplevel_page_site-card a{height:36px;padding-left:1px}}@media screen and (max-width:782px){#adminmenu li.menu-top .wp-submenu>li>a,.auto-fold #adminmenu li.menu-top .wp-submenu>li>a{padding-left:42px}.wp-responsive-open #wpbody{right:inherit}.wp-responsive-open #wpcontent{margin-left:272px}.auto-fold #adminmenu,.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{width:272px}#adminmenu a.site-switcher,.auto-fold #adminmenu a.site-switcher{font-size:14px}}@media only screen and (max-width:660px){#adminmenu,#adminmenu .wp-submenu,#adminmenuback,#adminmenuwrap,.auto-fold #adminmenu,.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{width:100%;z-index:171}.wp-responsive-open #wpcontent{margin-left:0}.auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after,ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu li:hover a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{display:none}.auto-fold #adminmenu li.toplevel_page_site-card a{padding:18px 0 18px 12px}}#wpadminbar #wp-admin-bar-notes #wpnt-notes-unread-count.wpn-unread{top:50%;left:50%;transform:translate(-10px,-13px)}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar{transform:translateX(1px)}#wpadminbar #wp-admin-bar-notes.active .noticon-bell:before{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cmVjdCB4PSIwIiBmaWxsPSJub25lIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiLz48Zz48cGF0aCBmaWxsPSIjZmZmZmZmIiBkPSJNNi4xNCAxNC45N2wyLjgyOCAyLjgyN2MtLjM2Mi4zNjItLjg2Mi41ODYtMS40MTQuNTg2LTEuMTA1IDAtMi0uODk1LTItMiAwLS41NTIuMjI0LTEuMDUyLjU4Ni0xLjQxNHptOC44NjcgNS4zMjRMMTQuMyAyMSAzIDkuN2wuNzA2LS43MDcgMS4xMDIuMTU3Yy43NTQuMTA4IDEuNjktLjEyMiAyLjA3Ny0uNTFsMy44ODUtMy44ODRjMi4zNC0yLjM0IDYuMTM1LTIuMzQgOC40NzUgMHMyLjM0IDYuMTM1IDAgOC40NzVsLTMuODg1IDMuODg2Yy0uMzg4LjM4OC0uNjE4IDEuMzIzLS41MSAyLjA3N2wuMTU3IDEuMXoiLz48L2c+PC9zdmc+)!important}#wpadminbar #wp-admin-bar-notes.wpnt-show .noticon,#wpadminbar>#wp-toolbar .wpnt-show span.noticon{color:#fff}#wpadminbar .quicklinks ul#wp-admin-bar-root-default{padding-left:0!important}#wpadminbar #wp-admin-bar-menu-toggle{display:none}@media screen and (max-width:782px){#wpadminbar #wp-toolbar>ul>li{display:block}#wpadminbar .ab-top-menu>li>.ab-item{box-sizing:border-box;line-height:32px}#wpadminbar #wp-admin-bar-ab-new-post>.ab-item{box-sizing:inherit!important}#wpadminbar #wp-admin-bar-my-account>.ab-item{padding:7px 15px;width:auto}#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar>a img{display:block;right:auto;left:auto;position:static;margin-top:3px;top:13px}#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-debug-bar{display:none}}@media screen and (max-width:480px){#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar>a{width:auto}#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar>a img{margin-top:12px}}#adv-settings{display:flex;flex-direction:column}#adv-settings #dashboard-switcher{order:0}#adv-settings .dashboard-switcher-text{margin-top:0}#adv-settings .dashboard-switcher-button{padding:3px 16px}#adv-settings fieldset{order:1}#adv-settings .submit{order:2} \ No newline at end of file
+#adminmenu{margin:0}#wpcontent,#wpfooter{margin-left:272px}#adminmenu,#adminmenu .wp-submenu,#adminmenuback,#adminmenuwrap{width:272px}#adminmenu .wp-submenu{left:272px}#adminmenu .wp-not-current-submenu .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{min-width:272px}@media (min-width:783px){.edit-post-layout .components-editor-notices__snackbar,.interface-interface-skeleton{left:272px}}@media (min-width:961px){.auto-fold .edit-post-layout .components-editor-notices__snackbar,.auto-fold .interface-interface-skeleton,.jp-dialogue-modern-full__container{left:272px}.global-notices{max-width:calc(100% - 320px)}}#adminmenu [class*=activity-log] .wp-menu-image img{padding-top:7px}#adminmenu .toplevel_page_site-card .wp-menu-name{margin-left:40px;padding:0}#adminmenu li.toplevel_page_site-card a{padding:10px 0 10px 8px}#adminmenu a.toplevel_page_site-notices:focus,#adminmenu a.toplevel_page_site-notices:hover,#adminmenu li.toplevel_page_site-notices:focus,#adminmenu li.toplevel_page_site-notices:hover{background-color:inherit!important;color:inherit!important}#adminmenu li.toplevel_page_site-notices .wp-menu-image{display:none}#adminmenu .toplevel_page_site-notices .wp-menu-image{background-color:#fff;border-radius:2px}#adminmenu .toplevel_page_site-notices .wp-menu-image:before{background-color:#a7aaad;border-radius:50%;color:#fff;content:"\f534";font-family:dashicons;font-size:20px;line-height:20px;margin:5px;padding:0}#adminmenu .toplevel_page_site-notices:hover .wp-menu-image:before{color:#fff}#adminmenu .toplevel_page_site-notices .upsell_banner{align-items:center;border-radius:2px;display:flex;flex-grow:1;flex-wrap:nowrap;font-size:12px;-webkit-hyphens:none;hyphens:none;justify-content:space-between;left:-28px;line-height:1.4;padding:7px 12px;position:relative;width:100%}#adminmenu .toplevel_page_site-notices .upsell_banner .banner__info{margin-right:12px}#adminmenu .toplevel_page_site-notices .upsell_banner .button{border:0;font-size:12px;line-height:12px;min-height:26px;padding:0 7px}#adminmenu .toplevel_page_site-notices .upsell_banner svg.dismissible-card__close-icon{height:24px;margin-left:10px;width:24px}@media screen and (min-width:782px){.folded #adminmenu .toplevel_page_site-notices .wp-menu-image{display:block;width:30px}.folded #adminmenu .toplevel_page_site-notices{align-items:center;display:flex;height:50px;justify-content:center}}@media screen and (min-width:782px) and (max-width:960px){.auto-fold #adminmenu .toplevel_page_site-notices .wp-menu-image{display:block;width:30px}.auto-fold #adminmenu .toplevel_page_site-notices{align-items:center;display:flex;height:50px;justify-content:center}}#adminmenu .site-switcher:hover,#adminmenu .toplevel_page_site-card:hover,#adminmenu .toplevel_page_site-notices:hover{box-shadow:none}#adminmenu .toplevel_page_site-card .wp-menu-image{background-image:none;background-position:50%;background-repeat:no-repeat;background-size:18px 18px;transform:translateZ(0);transition-duration:.2s;transition-property:background-image,background-color}#adminmenu a.toplevel_page_site-card:hover,#adminmenu li.toplevel_page_site-card:hover{background-color:inherit}#adminmenu .toplevel_page_site-card img{opacity:1}#adminmenu .toplevel_page_site-card.has-site-icon img{padding:0}#adminmenu .toplevel_page_site-card a:focus div.wp-menu-image,#adminmenu .toplevel_page_site-card:hover div.wp-menu-image{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg class='gridicon gridicons-house' height='24' width='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23fff' d='M22 9 12 1 2 9v2h2v10h5v-4a3 3 0 1 1 6 0v4h5V11h2V9z'/%3E%3C/svg%3E")}#adminmenu .toplevel_page_site-card:not(.has-site-icon) .wp-menu-image{background-color:#c3c4c7}#adminmenu .toplevel_page_site-card:not(.has-site-icon) .wp-menu-image img[src^="data:image/svg"]{height:auto;padding-top:7px;width:18px}#adminmenu .toplevel_page_site-card a:focus div.wp-menu-image img,#adminmenu .toplevel_page_site-card:hover div.wp-menu-image img{display:none}.site__info .site__title{display:block;font-size:14px;font-weight:400;line-height:1.3}.site__info .site__domain{display:block;font-size:12px;line-height:1.4;margin-top:2px;max-width:95%}.site__info .site__domain,.site__info .site__title{overflow:hidden;white-space:nowrap}.site__info .site__domain:after,.site__info .site__title:after{-webkit-touch-callout:none;bottom:0;content:"";display:block;height:auto;left:auto;pointer-events:none;position:absolute;right:0;top:0;-webkit-user-select:none;user-select:none;width:20%}.site__info>.site__badge{border-radius:12px;clear:both;display:inline-block;font-size:12px;margin-right:3px;margin-top:6px;padding:1px 10px}.inline-text{display:block!important;opacity:.8;position:absolute;right:20px;top:50%;transform:translateY(-50%)}[class*="toplevel_page_https://wordpress.com/stats/day"] .sidebar-unified__sparkline{float:right;margin-right:8px}.folded #adminmenu a.menu-top{height:31px}.folded #adminmenu li.toplevel_page_site-card a{padding-left:0}@media only screen and (max-width:960px){#adminmenu,#adminmenuback,#adminmenuwrap{width:272px}.auto-fold #adminmenu a[class*=toplevel_page_http].wp-first-item,.wp-responsive-open #adminmenu a.menu-top{height:auto}.auto-fold #adminmenu div.wp-menu-image{width:36px}}@media screen and (min-width:782px) and (max-width:960px){.auto-fold #adminmenu a.menu-top{height:34px}.auto-fold #adminmenu li.toplevel_page_site-card a{height:36px;padding-left:1px}}@media screen and (max-width:782px){#adminmenu li.menu-top .wp-submenu>li>a,.auto-fold #adminmenu li.menu-top .wp-submenu>li>a{padding-left:42px}.wp-responsive-open #wpbody{right:inherit}.wp-responsive-open #wpcontent{margin-left:272px}.auto-fold #adminmenu,.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{width:272px}#adminmenu a.site-switcher,.auto-fold #adminmenu a.site-switcher{font-size:14px}}@media only screen and (max-width:660px){#adminmenu,#adminmenu .wp-submenu,#adminmenuback,#adminmenuwrap,.auto-fold #adminmenu,.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{width:100%;z-index:171}.wp-responsive-open #wpcontent{margin-left:0}.auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after,ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu li:hover a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{display:none}.auto-fold #adminmenu li.toplevel_page_site-card a{padding:18px 0 18px 12px}}#wpadminbar #wp-admin-bar-notes #wpnt-notes-unread-count.wpn-unread{left:50%;top:50%;transform:translate(-10px,-13px)}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar{transform:translateX(1px)}#wpadminbar #wp-admin-bar-notes.active .noticon-bell:before{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgyNHYyNEgweiIvPjxwYXRoIGZpbGw9IiNmZmYiIGQ9Im02LjE0IDE0Ljk3IDIuODI4IDIuODI3YTIgMiAwIDEgMS0yLjgyOC0yLjgyOHptOC44NjcgNS4zMjRMMTQuMyAyMSAzIDkuN2wuNzA2LS43MDcgMS4xMDIuMTU3Yy43NTQuMTA4IDEuNjktLjEyMiAyLjA3Ny0uNTFsMy44ODUtMy44ODRhNS45OTMgNS45OTMgMCAwIDEgOC40NzUgOC40NzVsLTMuODg1IDMuODg2Yy0uMzg4LjM4OC0uNjE4IDEuMzIzLS41MSAyLjA3N2wuMTU3IDEuMXoiLz48L3N2Zz4=)!important}#wpadminbar #wp-admin-bar-notes.wpnt-show .noticon,#wpadminbar>#wp-toolbar .wpnt-show span.noticon{color:#fff}#wpadminbar .quicklinks ul#wp-admin-bar-root-default{padding-left:0!important}#wpadminbar #wp-admin-bar-menu-toggle{display:none}@media screen and (max-width:782px){#wpadminbar #wp-toolbar>ul>li{display:block}#wpadminbar .ab-top-menu>li>.ab-item{box-sizing:border-box;line-height:32px}#wpadminbar #wp-admin-bar-ab-new-post>.ab-item{box-sizing:inherit!important}#wpadminbar #wp-admin-bar-my-account>.ab-item{padding:7px 15px;width:auto}#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar>a img{display:block;left:auto;margin-top:3px;position:static;right:auto;top:13px}#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-debug-bar{display:none}}@media screen and (max-width:480px){#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar>a{width:auto}#wpadminbar #wp-toolbar.quicklinks li#wp-admin-bar-my-account.with-avatar>a img{margin-top:12px}}#view-link-wrap{float:left;margin:0 0 0 6px}.screen-options-tab__wrapper{position:relative}.screen-options-tab__dropdown{background-color:#fff;border:1px solid var(--color-neutral-5);border-radius:4px;box-shadow:0 4px 10px #0000001a;padding:3px;position:absolute;right:20px;top:37px;width:215px;z-index:9999}@media screen and (max-width:782px){.screen-options-tab__dropdown{right:10px;top:47px}}@media screen and (max-width:600px){.screen-options-tab__dropdown{top:93px}}.screen-switcher:not(:hover) .screen-switcher__button:nth-child(2)>strong{color:var(--wp-admin-theme-color)}.screen-switcher__button,a.screen-switcher__button{background:transparent;border:1px solid #0000;border-radius:4px;color:var(--color-text);cursor:pointer;display:inline-block;font-size:.75rem;line-height:normal;padding:8px;text-align:left;text-decoration:none}.screen-switcher__button:nth-child(2),a.screen-switcher__button:nth-child(2){border-color:var(--wp-admin-theme-color);margin-bottom:4px}.screen-switcher__button:last-child,a.screen-switcher__button:last-child{margin-bottom:0}.screen-switcher__button strong,a.screen-switcher__button strong{display:block;font-size:13px;margin-bottom:4px}.screen-switcher__button:focus>strong,.screen-switcher__button:hover>strong,a.screen-switcher__button:focus>strong,a.screen-switcher__button:hover>strong{color:var(--wp-admin-theme-color)} \ No newline at end of file
diff --git a/plugins/jetpack/modules/masterbar/admin-menu/class-admin-menu.php b/plugins/jetpack/modules/masterbar/admin-menu/class-admin-menu.php
index 46b7f8bf..f49a6a5b 100644
--- a/plugins/jetpack/modules/masterbar/admin-menu/class-admin-menu.php
+++ b/plugins/jetpack/modules/masterbar/admin-menu/class-admin-menu.php
@@ -108,68 +108,6 @@ class Admin_Menu extends Base_Admin_Menu {
}
/**
- * Adds upsell nudge as a menu.
- *
- * @param object $nudge The $nudge object containing the content, CTA, link and tracks.
- */
- public function add_upsell_nudge( $nudge ) {
- $dismiss_button = '';
- if ( $nudge['dismissible'] ) {
- $dismiss_button = '<svg xmlns="http://www.w3.org/2000/svg" data-feature_class="%1$s" data-feature_id="%2$s" viewBox="0 0 24 24" class="gridicon gridicons-cross dismissible-card__close-icon" height="24" width="24"><g><path d="M18.36 19.78L12 13.41l-6.36 6.37-1.42-1.42L10.59 12 4.22 5.64l1.42-1.42L12 10.59l6.36-6.36 1.41 1.41L13.41 12l6.36 6.36z"></path></g></svg>';
- $dismiss_button = sprintf( $dismiss_button, esc_attr( $nudge['feature_class'] ), esc_attr( $nudge['id'] ) );
- }
-
- $message = '
-<div class="upsell_banner">
- <div class="banner__info">
- <div class="banner__title">%1$s</div>
- </div>
- <div class="banner__action">
- <button type="button" class="button">%2$s</button>
- </div>%3$s
-</div>';
-
- $message = sprintf(
- $message,
- wp_kses( $nudge['content'], array() ),
- wp_kses( $nudge['cta'], array() ),
- $dismiss_button
- );
-
- $menu_slug = $nudge['link'];
- if ( wp_startswith( $menu_slug, '/' ) ) {
- $menu_slug = 'https://wordpress.com' . $menu_slug;
- }
-
- add_menu_page( 'site-notices', $message, 'read', $menu_slug, null, null, 1 );
- add_filter( 'add_menu_classes', array( $this, 'set_site_notices_menu_class' ) );
- }
-
- /**
- * Adds a custom element class and id for Site Notices's menu item.
- *
- * @param array $menu Associative array of administration menu items.
- * @return array
- */
- public function set_site_notices_menu_class( array $menu ) {
- foreach ( $menu as $key => $menu_item ) {
- if ( 'site-notices' !== $menu_item[3] ) {
- continue;
- }
-
- $classes = ' toplevel_page_site-notices';
-
- if ( isset( $menu_item[4] ) ) {
- $menu[ $key ][4] = $menu_item[4] . $classes;
- $menu[ $key ][5] = 'toplevel_page_site-notices';
- break;
- }
- }
-
- return $menu;
- }
-
- /**
* Adds Inbox menu.
*/
public function add_inbox_menu() {
@@ -510,33 +448,58 @@ class Admin_Menu extends Base_Admin_Menu {
}
/**
- * Prepend a dashboard swithcer to the "Screen Options" box of the current page.
- * Callback for the 'screen_settings' filter (available in WP 3.0 and up).
- *
- * @param string $current The currently added panels in screen options.
- *
- * @return string The HTML code to append to "Screen Options"
+ * AJAX handler for retrieving the upsell nudge.
*/
- public function register_dashboard_switcher( $current ) {
- $menu_mappings = require __DIR__ . '/menu-mappings.php';
- $screen = $this->get_current_screen();
+ public function wp_ajax_upsell_nudge_jitm() {
+ check_ajax_referer( 'upsell_nudge_jitm' );
- // Let's show the switcher only in screens that we have a Calypso mapping to switch to.
- if ( ! isset( $menu_mappings[ $screen ] ) ) {
- return;
+ $nudge = $this->get_upsell_nudge();
+ if ( ! $nudge ) {
+ wp_die();
}
- $contents = sprintf(
- '<div id="dashboard-switcher"><h5>%s</h5><p class="dashboard-switcher-text">%s</p><a class="button button-primary dashboard-switcher-button" href="%s">%s</a></div>',
- __( 'Screen features', 'jetpack' ),
- __( 'Currently you are seeing the classic WP-Admin view of this page. Would you like to see the default WordPress.com view?', 'jetpack' ),
- add_query_arg( 'preferred-view', 'default' ),
- __( 'Use WordPress.com view', 'jetpack' )
- );
-
- // Prepend the Dashboard swither to the other custom panels.
- $current = $contents . $current;
+ $link = $nudge['link'];
+ if ( substr( $link, 0, 1 ) === '/' ) {
+ $link = 'https://wordpress.com' . $link;
+ }
+ ?>
+ <li class="wp-not-current-submenu menu-top menu-icon-generic toplevel_page_site-notices" id="toplevel_page_site-notices">
+ <a href="<?php echo esc_url( $link ); ?>" class="wp-not-current-submenu menu-top menu-icon-generic toplevel_page_site-notices">
+ <div class="wp-menu-arrow">
+ <div></div>
+ </div>
+ <div class="wp-menu-image dashicons-before dashicons-admin-generic" aria-hidden="true"><br></div>
+ <div class="wp-menu-name">
+ <div class="upsell_banner">
+ <div class="banner__info">
+ <div class="banner__title">
+ <?php echo wp_kses( $nudge['content'], array() ); ?>
+ </div>
+ </div>
+ <div class="banner__action">
+ <button type="button" class="button">
+ <?php echo wp_kses( $nudge['cta'], array() ); ?>
+ </button>
+ </div>
+ <?php if ( $nudge['dismissible'] ) : ?>
+ <svg xmlns="http://www.w3.org/2000/svg" data-feature_class="<?php echo esc_attr( $nudge['feature_class'] ); ?>" data-feature_id="<?php echo esc_attr( $nudge['id'] ); ?>" viewBox="0 0 24 24" class="gridicon gridicons-cross dismissible-card__close-icon" height="24" width="24"><g><path d="M18.36 19.78L12 13.41l-6.36 6.37-1.42-1.42L10.59 12 4.22 5.64l1.42-1.42L12 10.59l6.36-6.36 1.41 1.41L13.41 12l6.36 6.36z"></path></g></svg>
+ <?php endif; ?>
+ </div>
+ </div>
+ </a>
+ </li>
+ <?php
+ wp_die();
+ }
- return $current;
+ /**
+ * Returns the first available upsell nudge.
+ * Needs to be implemented separately for each child menu class.
+ * Empty by default.
+ *
+ * @return array
+ */
+ public function get_upsell_nudge() {
+ return array();
}
}
diff --git a/plugins/jetpack/modules/masterbar/admin-menu/class-atomic-admin-menu.php b/plugins/jetpack/modules/masterbar/admin-menu/class-atomic-admin-menu.php
index b3bd7c64..f869ba71 100644
--- a/plugins/jetpack/modules/masterbar/admin-menu/class-atomic-admin-menu.php
+++ b/plugins/jetpack/modules/masterbar/admin-menu/class-atomic-admin-menu.php
@@ -27,6 +27,7 @@ class Atomic_Admin_Menu extends Admin_Menu {
add_action( 'admin_enqueue_scripts', array( $this, 'dequeue_scripts' ), 20 );
add_action( 'wp_ajax_sidebar_state', array( $this, 'ajax_sidebar_state' ) );
add_action( 'wp_ajax_jitm_dismiss', array( $this, 'wp_ajax_jitm_dismiss' ) );
+ add_action( 'wp_ajax_upsell_nudge_jitm', array( $this, 'wp_ajax_upsell_nudge_jitm' ) );
if ( ! $this->is_api_request ) {
add_filter( 'submenu_file', array( $this, 'override_the_theme_installer' ), 10, 2 );
@@ -72,11 +73,6 @@ class Atomic_Admin_Menu extends Admin_Menu {
if ( ! $this->is_api_request ) {
$this->add_browse_sites_link();
$this->add_site_card_menu();
- $nudge = $this->get_upsell_nudge();
- if ( $nudge ) {
- parent::add_upsell_nudge( $nudge );
- }
-
$this->add_new_site_link();
}
@@ -116,34 +112,36 @@ class Atomic_Admin_Menu extends Admin_Menu {
*/
public function add_plugins_menu() {
global $submenu;
+
+ // Calypso plugins screens link.
+ $plugins_slug = 'https://wordpress.com/plugins/' . $this->domain;
+
+ // Link to the Marketplace on sites that can't manage plugins.
if (
- isset( $submenu['plugins.php'] )
- /**
- * Whether to enable the marketplace feature entrypoint.
- * This filter is specific to WPCOM, that's why there is no
- * need to use `jetpack_` prefix.
- *
- * @use add_filter( 'wpcom_marketplace_enabled', '__return_true' );
- * @module masterbar
- * @since 10.3
- * @param bool $wpcom_marketplace_enabled Load the WordPress.com Marketplace feature. Default to false.
- */
- && apply_filters( 'wpcom_marketplace_enabled', false )
+ function_exists( 'wpcom_site_has_feature' ) &&
+ ! wpcom_site_has_feature( \WPCOM_Features::MANAGE_PLUGINS )
) {
- $plugins_submenu = $submenu['plugins.php'];
- $slug_to_update = 'plugin-install.php';
-
- // Move "Add New" plugin submenu ( `plugin-install.php` ) to the top position.
- foreach ( $plugins_submenu as $submenu_key => $submenu_keys ) {
- if ( $submenu_keys[2] === $slug_to_update ) {
- // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
- $submenu['plugins.php'] = array( $submenu_key => $plugins_submenu[ $submenu_key ] ) + $plugins_submenu;
- }
- }
+ add_menu_page( __( 'Plugins', 'jetpack' ), __( 'Plugins', 'jetpack' ), 'manage_options', $plugins_slug, null, 'dashicons-admin-plugins', '65' );
+ return;
+ }
+
+ if ( ! isset( $submenu['plugins.php'] ) ) {
+ return;
+ }
- $submenus_to_update = array( $slug_to_update => 'https://wordpress.com/plugins/' . $this->domain );
- $this->update_submenus( 'plugins.php', $submenus_to_update );
+ $plugins_submenu = $submenu['plugins.php'];
+
+ // Move "Add New" plugin submenu to the top position.
+ foreach ( $plugins_submenu as $submenu_key => $submenu_keys ) {
+ if ( 'plugin-install.php' === $submenu_keys[2] ) {
+ // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
+ $submenu['plugins.php'] = array( $submenu_key => $plugins_submenu[ $submenu_key ] ) + $plugins_submenu;
+ }
}
+
+ $submenus_to_update = array( 'plugin-install.php' => $plugins_slug );
+
+ $this->update_submenus( 'plugins.php', $submenus_to_update );
}
/**
@@ -353,8 +351,15 @@ class Atomic_Admin_Menu extends Admin_Menu {
2
);
}
+
add_submenu_page( 'options-general.php', esc_attr__( 'Hosting Configuration', 'jetpack' ), __( 'Hosting Configuration', 'jetpack' ), 'manage_options', 'https://wordpress.com/hosting-config/' . $this->domain, null, 11 );
- add_submenu_page( 'options-general.php', esc_attr__( 'Jetpack', 'jetpack' ), __( 'Jetpack', 'jetpack' ), 'manage_options', 'https://wordpress.com/settings/jetpack/' . $this->domain, null, 12 );
+
+ if (
+ function_exists( 'wpcom_site_has_feature' ) &&
+ wpcom_site_has_feature( \WPCOM_Features::ATOMIC )
+ ) {
+ add_submenu_page( 'options-general.php', esc_attr__( 'Jetpack', 'jetpack' ), __( 'Jetpack', 'jetpack' ), 'manage_options', 'https://wordpress.com/settings/jetpack/' . $this->domain, null, 12 );
+ }
// Page Optimize is active by default on all Atomic sites and registers a Settings > Performance submenu which
// would conflict with our own Settings > Performance that links to Calypso, so we hide it it since the Calypso
@@ -390,7 +395,7 @@ class Atomic_Admin_Menu extends Admin_Menu {
* Saves the sidebar state ( expanded / collapsed ) via an ajax request.
*/
public function ajax_sidebar_state() {
- $expanded = filter_var( $_REQUEST['expanded'], FILTER_VALIDATE_BOOLEAN ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $expanded = isset( $_REQUEST['expanded'] ) ? filter_var( wp_unslash( $_REQUEST['expanded'] ), FILTER_VALIDATE_BOOLEAN ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
Client::wpcom_json_api_request_as_user(
'/me/preferences',
'2',
@@ -410,7 +415,9 @@ class Atomic_Admin_Menu extends Admin_Menu {
public function wp_ajax_jitm_dismiss() {
check_ajax_referer( 'jitm_dismiss' );
$jitm = \Automattic\Jetpack\JITMS\JITM::get_instance();
- $jitm->dismiss( $_REQUEST['id'], $_REQUEST['feature_class'] );
+ if ( isset( $_REQUEST['id'] ) && isset( $_REQUEST['feature_class'] ) ) {
+ $jitm->dismiss( sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ), sanitize_text_field( wp_unslash( $_REQUEST['feature_class'] ) ) );
+ }
wp_die();
}
diff --git a/plugins/jetpack/modules/masterbar/admin-menu/class-base-admin-menu.php b/plugins/jetpack/modules/masterbar/admin-menu/class-base-admin-menu.php
index 5f3b1f51..5ffc2ecb 100644
--- a/plugins/jetpack/modules/masterbar/admin-menu/class-base-admin-menu.php
+++ b/plugins/jetpack/modules/masterbar/admin-menu/class-base-admin-menu.php
@@ -66,7 +66,7 @@ abstract class Base_Admin_Menu {
* Base_Admin_Menu constructor.
*/
protected function __construct() {
- $this->is_api_request = defined( 'REST_REQUEST' ) && REST_REQUEST || 0 === strpos( $_SERVER['REQUEST_URI'], '/?rest_route=%2Fwpcom%2Fv2%2Fadmin-menu' );
+ $this->is_api_request = defined( 'REST_REQUEST' ) && REST_REQUEST || isset( $_SERVER['REQUEST_URI'] ) && 0 === strpos( filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/?rest_route=%2Fwpcom%2Fv2%2Fadmin-menu' );
$this->domain = ( new Status() )->get_site_suffix();
add_action( 'admin_menu', array( $this, 'reregister_menu_items' ), 99998 );
@@ -76,7 +76,8 @@ abstract class Base_Admin_Menu {
add_filter( 'admin_menu', array( $this, 'override_svg_icons' ), 99999 );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
add_action( 'admin_head', array( $this, 'set_site_icon_inline_styles' ) );
- add_filter( 'screen_settings', array( $this, 'register_dashboard_switcher' ), 99999 );
+ add_action( 'in_admin_header', array( $this, 'add_dashboard_switcher' ) );
+ add_action( 'admin_footer', array( $this, 'dashboard_switcher_scripts' ) );
add_action( 'admin_menu', array( $this, 'handle_preferred_view' ), 99997 );
add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
}
@@ -279,7 +280,10 @@ abstract class Base_Admin_Menu {
wp_localize_script(
'jetpack-admin-menu',
'jetpackAdminMenu',
- array( 'jitmDismissNonce' => wp_create_nonce( 'jitm_dismiss' ) )
+ array(
+ 'upsellNudgeJitm' => wp_create_nonce( 'upsell_nudge_jitm' ),
+ 'jitmDismissNonce' => wp_create_nonce( 'jitm_dismiss' ),
+ )
);
}
@@ -544,6 +548,65 @@ abstract class Base_Admin_Menu {
}
/**
+ * Adds a dashboard switcher to the list of screen meta links of the current page.
+ */
+ public function add_dashboard_switcher() {
+ $menu_mappings = require __DIR__ . '/menu-mappings.php';
+ $screen = $this->get_current_screen();
+
+ // Let's show the switcher only in screens that we have a Calypso mapping to switch to.
+ if ( empty( $menu_mappings[ $screen ] ) ) {
+ return;
+ }
+ ?>
+ <div id="view-link-wrap" class="hide-if-no-js screen-meta-toggle">
+ <button type="button" id="view-link" class="button show-settings" aria-expanded="false"><?php echo esc_html_x( 'View', 'View options to switch between', 'jetpack' ); ?></button>
+ </div>
+ <div id="view-wrap" class="screen-options-tab__wrapper hide-if-no-js hidden" tabindex="-1">
+ <div class="screen-options-tab__dropdown" data-testid="screen-options-dropdown">
+ <div class="screen-switcher">
+ <a class="screen-switcher__button" href="<?php echo esc_url( add_query_arg( 'preferred-view', 'default' ) ); ?>" data-view="default">
+ <strong><?php esc_html_e( 'Default view', 'jetpack' ); ?></strong>
+ <?php esc_html_e( 'Our WordPress.com redesign for a better experience.', 'jetpack' ); ?>
+ </a>
+ <button class="screen-switcher__button" data-view="classic">
+ <strong><?php esc_html_e( 'Classic view', 'jetpack' ); ?></strong>
+ <?php esc_html_e( 'The classic WP-Admin WordPress interface.', 'jetpack' ); ?>
+ </button>
+ </div>
+ </div>
+ </div>
+ <?php
+ }
+
+ /**
+ * Adds a script to append the dashboard switcher to screen meta
+ */
+ public function dashboard_switcher_scripts() {
+ wp_add_inline_script(
+ 'common',
+ "(function( $ ) {
+ $( '#view-link-wrap' ).appendTo( '#screen-meta-links' );
+
+ var viewLink = $( '#view-link' );
+ var viewWrap = $( '#view-wrap' );
+
+ viewLink.on( 'click', function() {
+ viewWrap.toggle();
+ viewLink.toggleClass( 'screen-meta-active' );
+ } );
+
+ $( document ).on( 'mouseup', function( event ) {
+ if ( ! viewLink.is( event.target ) && ! viewWrap.is( event.target ) && viewWrap.has( event.target ).length === 0 ) {
+ viewWrap.hide();
+ viewLink.removeClass( 'screen-meta-active' );
+ }
+ });
+ })( jQuery );"
+ );
+ }
+
+ /**
* Sets the given view as preferred for the givens screen.
*
* @param string $screen Screen identifier.
@@ -600,17 +663,17 @@ abstract class Base_Admin_Menu {
public function get_current_screen() {
// phpcs:disable WordPress.Security.NonceVerification
global $pagenow;
- $screen = isset( $_REQUEST['screen'] ) ? $_REQUEST['screen'] : $pagenow;
+ $screen = isset( $_REQUEST['screen'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['screen'] ) ) : $pagenow;
if ( isset( $_GET['post_type'] ) ) {
- $screen = add_query_arg( 'post_type', $_GET['post_type'], $screen );
+ $screen = add_query_arg( 'post_type', sanitize_text_field( wp_unslash( $_GET['post_type'] ) ), $screen );
}
if ( isset( $_GET['taxonomy'] ) ) {
- $screen = add_query_arg( 'taxonomy', $_GET['taxonomy'], $screen );
+ $screen = add_query_arg( 'taxonomy', sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) ), $screen );
}
if ( isset( $_GET['page'] ) ) {
- $screen = add_query_arg( 'page', $_GET['page'], $screen );
+ $screen = add_query_arg( 'page', sanitize_text_field( wp_unslash( $_GET['page'] ) ), $screen );
}
- return sanitize_text_field( wp_unslash( $screen ) );
+ return $screen;
// phpcs:enable WordPress.Security.NonceVerification
}
@@ -624,7 +687,7 @@ abstract class Base_Admin_Menu {
}
// phpcs:disable WordPress.Security.NonceVerification
- $preferred_view = $_GET['preferred-view'];
+ $preferred_view = sanitize_key( $_GET['preferred-view'] );
if ( ! in_array( $preferred_view, array( self::DEFAULT_VIEW, self::CLASSIC_VIEW ), true ) ) {
return;
diff --git a/plugins/jetpack/modules/masterbar/admin-menu/class-dashboard-switcher-tracking.php b/plugins/jetpack/modules/masterbar/admin-menu/class-dashboard-switcher-tracking.php
index b3fe7cd8..b1fcda47 100644
--- a/plugins/jetpack/modules/masterbar/admin-menu/class-dashboard-switcher-tracking.php
+++ b/plugins/jetpack/modules/masterbar/admin-menu/class-dashboard-switcher-tracking.php
@@ -97,8 +97,8 @@ class Dashboard_Switcher_Tracking {
if ( class_exists( '\WPCOM_Store_API' ) ) {
// @todo: Maybe introduce a wrapper for this since we are duplicating it from WPCOM_Admin_Menu:253
$products = \WPCOM_Store_API::get_current_plan( \get_current_blog_id() );
- if ( array_key_exists( 'product_name_short', $products ) ) {
- return $products['product_name_short'];
+ if ( ! empty( $products['product_slug'] ) ) {
+ return $products['product_slug'];
}
}
@@ -107,8 +107,8 @@ class Dashboard_Switcher_Tracking {
// @todo: Maybe introduce a helper for this since we are duplicating it from Atomic_Admin_Menu:240
$products = Jetpack_Plan::get();
- if ( array_key_exists( 'product_name_short', $products ) ) {
- return $products['product_name_short'];
+ if ( ! empty( $products['product_slug'] ) ) {
+ return $products['product_slug'];
}
return 'N/A'; // maybe we should return free or null? At the moment we use it for passing it to the event.
diff --git a/plugins/jetpack/modules/masterbar/admin-menu/class-wpcom-admin-menu.php b/plugins/jetpack/modules/masterbar/admin-menu/class-wpcom-admin-menu.php
index 12535a4e..89509683 100644
--- a/plugins/jetpack/modules/masterbar/admin-menu/class-wpcom-admin-menu.php
+++ b/plugins/jetpack/modules/masterbar/admin-menu/class-wpcom-admin-menu.php
@@ -30,6 +30,7 @@ class WPcom_Admin_Menu extends Admin_Menu {
add_action( 'wp_ajax_sidebar_state', array( $this, 'ajax_sidebar_state' ) );
add_action( 'wp_ajax_jitm_dismiss', array( $this, 'wp_ajax_jitm_dismiss' ) );
+ add_action( 'wp_ajax_upsell_nudge_jitm', array( $this, 'wp_ajax_upsell_nudge_jitm' ) );
add_action( 'admin_init', array( $this, 'sync_sidebar_collapsed_state' ) );
add_action( 'admin_menu', array( $this, 'remove_submenus' ), 140 ); // After hookpress hook at 130.
}
@@ -47,10 +48,6 @@ class WPcom_Admin_Menu extends Admin_Menu {
if ( ! $this->is_api_request ) {
$this->add_browse_sites_link();
$this->add_site_card_menu();
- $nudge = $this->get_upsell_nudge();
- if ( $nudge ) {
- parent::add_upsell_nudge( $nudge );
- }
$this->add_new_site_link();
}
@@ -88,10 +85,22 @@ class WPcom_Admin_Menu extends Admin_Menu {
}
/**
+ * Retrieve the number of blogs that the current user has.
+ *
+ * @return int
+ */
+ public function get_current_user_blog_count() {
+ if ( function_exists( '\get_blog_count_for_user' ) ) {
+ return \get_blog_count_for_user( get_current_user_id() );
+ }
+ return count( get_blogs_of_user( get_current_user_id() ) );
+ }
+
+ /**
* Adds the site switcher link if user has more than one site.
*/
public function add_browse_sites_link() {
- if ( count( get_blogs_of_user( get_current_user_id() ) ) < 2 ) {
+ if ( $this->get_current_user_blog_count() < 2 ) {
return;
}
@@ -123,7 +132,7 @@ class WPcom_Admin_Menu extends Admin_Menu {
* Adds a link to the menu to create a new site.
*/
public function add_new_site_link() {
- if ( count( get_blogs_of_user( get_current_user_id() ) ) > 1 ) {
+ if ( $this->get_current_user_blog_count() > 1 ) {
return;
}
@@ -384,7 +393,7 @@ class WPcom_Admin_Menu extends Admin_Menu {
* Saves the sidebar state ( expanded / collapsed ) via an ajax request.
*/
public function ajax_sidebar_state() {
- $expanded = filter_var( $_REQUEST['expanded'], FILTER_VALIDATE_BOOLEAN ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $expanded = isset( $_REQUEST['expanded'] ) ? filter_var( wp_unslash( $_REQUEST['expanded'] ), FILTER_VALIDATE_BOOLEAN ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$user_id = get_current_user_id();
$preferences = get_user_attribute( $user_id, 'calypso_preferences' );
if ( empty( $preferences ) ) {
@@ -410,7 +419,9 @@ class WPcom_Admin_Menu extends Admin_Menu {
public function wp_ajax_jitm_dismiss() {
check_ajax_referer( 'jitm_dismiss' );
require_lib( 'jetpack-jitm/jitm-engine' );
- JITM\Engine::dismiss( $_REQUEST['id'], $_REQUEST['feature_class'] );
+ if ( isset( $_REQUEST['id'] ) && isset( $_REQUEST['feature_class'] ) ) {
+ JITM\Engine::dismiss( sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ), sanitize_text_field( wp_unslash( $_REQUEST['feature_class'] ) ) );
+ }
wp_die();
}
diff --git a/plugins/jetpack/modules/masterbar/admin-menu/load.php b/plugins/jetpack/modules/masterbar/admin-menu/load.php
index 412819ef..cedb92bb 100644
--- a/plugins/jetpack/modules/masterbar/admin-menu/load.php
+++ b/plugins/jetpack/modules/masterbar/admin-menu/load.php
@@ -23,7 +23,7 @@ function should_customize_nav( $admin_menu_class ) {
return false;
}
- $is_api_request = defined( 'REST_REQUEST' ) && REST_REQUEST || 0 === strpos( $_SERVER['REQUEST_URI'], '/?rest_route=%2Fwpcom%2Fv2%2Fadmin-menu' );
+ $is_api_request = defined( 'REST_REQUEST' ) && REST_REQUEST || isset( $_SERVER['REQUEST_URI'] ) && 0 === strpos( filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/?rest_route=%2Fwpcom%2Fv2%2Fadmin-menu' );
// No nav customizations on WP Admin of Atomic sites when SSO is disabled.
if ( is_a( $admin_menu_class, Atomic_Admin_Menu::class, true ) && ! $is_api_request && ! \Jetpack::is_module_active( 'sso' ) ) {
diff --git a/plugins/jetpack/modules/masterbar/masterbar.php b/plugins/jetpack/modules/masterbar/masterbar.php
deleted file mode 100644
index 72c27800..00000000
--- a/plugins/jetpack/modules/masterbar/masterbar.php
+++ /dev/null
@@ -1,1392 +0,0 @@
-<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
-
-use Automattic\Jetpack\Assets;
-use Automattic\Jetpack\Connection\Client;
-
-require_once dirname( __FILE__ ) . '/rtl-admin-bar.php';
-
-/**
- * Custom Admin bar displayed instead of the default WordPress admin bar.
- */
-class A8C_WPCOM_Masterbar {
- /**
- * Use for testing changes made to remotely enqueued scripts and styles on your sandbox.
- * If not set it will default to loading the ones from WordPress.com.
- *
- * @var string $sandbox_url
- */
- private $sandbox_url = '';
-
- /**
- * Current locale.
- *
- * @var string
- */
- private $locale;
-
- /**
- * Current User ID.
- *
- * @var int
- */
- private $user_id;
- /**
- * WordPress.com user data of the connected user.
- *
- * @var array
- */
- private $user_data;
- /**
- * WordPress.com username for the connected user.
- *
- * @var string
- */
- private $user_login;
- /**
- * WordPress.com email address for the connected user.
- *
- * @var string
- */
- private $user_email;
- /**
- * WordPress.com display name for the connected user.
- *
- * @var string
- */
- private $display_name;
- /**
- * Site URL sanitized for usage in WordPress.com slugs.
- *
- * @var string
- */
- private $primary_site_slug;
- /**
- * Text direction (ltr or rtl) based on connected WordPress.com user's interface settings.
- *
- * @var string
- */
- private $user_text_direction;
- /**
- * Number of sites owned by connected WordPress.com user.
- *
- * @var int
- */
- private $user_site_count;
-
- /**
- * Constructor
- */
- public function __construct() {
- add_action( 'admin_bar_init', array( $this, 'init' ) );
-
- // Post logout on the site, also log the user out of WordPress.com.
- add_action( 'wp_logout', array( $this, 'maybe_logout_user_from_wpcom' ) );
- }
-
- /**
- * Initialize our masterbar.
- */
- public function init() {
- $this->locale = $this->get_locale();
- $this->user_id = get_current_user_id();
-
- // Limit the masterbar to be shown only to connected Jetpack users.
- if ( ! Jetpack::is_user_connected( $this->user_id ) ) {
- return;
- }
-
- // Don't show the masterbar on WordPress mobile apps.
- if ( Jetpack_User_Agent_Info::is_mobile_app() ) {
- add_filter( 'show_admin_bar', '__return_false' );
- return;
- }
-
- // Disable the Masterbar on AMP views.
- if (
- class_exists( 'Jetpack_AMP_Support' )
- && Jetpack_AMP_Support::is_amp_request()
- ) {
- return;
- }
-
- Jetpack::dns_prefetch(
- array(
- '//s0.wp.com',
- '//s1.wp.com',
- '//s2.wp.com',
- '//0.gravatar.com',
- '//1.gravatar.com',
- '//2.gravatar.com',
- )
- );
-
- // Atomic only.
- if ( jetpack_is_atomic_site() ) {
- /*
- * override user setting that hides masterbar from site's front.
- * https://github.com/Automattic/jetpack/issues/7667
- */
- add_filter( 'show_admin_bar', '__return_true' );
- }
-
- $this->user_data = Jetpack::get_connected_user_data( $this->user_id );
- $this->user_login = $this->user_data['login'];
- $this->user_email = $this->user_data['email'];
- $this->display_name = $this->user_data['display_name'];
- $this->user_site_count = $this->user_data['site_count'];
-
- // Used to build menu links that point directly to Calypso.
- $this->primary_site_slug = Jetpack::build_raw_urls( get_home_url() );
-
- // Used for display purposes and for building WP Admin links.
- $this->primary_site_url = str_replace( '::', '/', $this->primary_site_slug );
-
- // We need to use user's setting here, instead of relying on current blog's text direction.
- $this->user_text_direction = $this->user_data['text_direction'];
-
- if ( $this->is_rtl() ) {
- // Extend core WP_Admin_Bar class in order to add rtl styles.
- add_filter( 'wp_admin_bar_class', array( $this, 'get_rtl_admin_bar_class' ) );
- }
- add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
-
- add_action( 'wp_before_admin_bar_render', array( $this, 'replace_core_masterbar' ), 99999 );
-
- add_action( 'wp_enqueue_scripts', array( $this, 'add_styles_and_scripts' ) );
- add_action( 'admin_enqueue_scripts', array( $this, 'add_styles_and_scripts' ) );
-
- add_action( 'wp_enqueue_scripts', array( $this, 'remove_core_styles' ) );
- add_action( 'admin_enqueue_scripts', array( $this, 'remove_core_styles' ) );
-
- if ( Jetpack::is_module_active( 'notes' ) && $this->is_rtl() ) {
- // Override Notification module to include RTL styles.
- add_action( 'a8c_wpcom_masterbar_enqueue_rtl_notification_styles', '__return_true' );
- }
- }
-
- /**
- * Log out from WordPress.com when logging out of the local site.
- */
- public function maybe_logout_user_from_wpcom() {
- /**
- * Whether we should sign out from wpcom too when signing out from the masterbar.
- *
- * @since 5.9.0
- *
- * @param bool $masterbar_should_logout_from_wpcom True by default.
- */
- $masterbar_should_logout_from_wpcom = apply_filters( 'jetpack_masterbar_should_logout_from_wpcom', true );
- if (
- // No need to check for a nonce here, it happens further up.
- isset( $_GET['context'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- && 'masterbar' === $_GET['context'] // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- && $masterbar_should_logout_from_wpcom
- ) {
- do_action( 'wp_masterbar_logout' );
- }
- }
-
- /**
- * Get class name for RTL sites.
- */
- public function get_rtl_admin_bar_class() {
- return 'RTL_Admin_Bar';
- }
-
- /**
- * Adds CSS classes to admin body tag.
- *
- * @since 5.1
- *
- * @param string $admin_body_classes CSS classes that will be added.
- *
- * @return string
- */
- public function admin_body_class( $admin_body_classes ) {
- return "$admin_body_classes jetpack-masterbar";
- }
-
- /**
- * Remove the default Admin Bar CSS.
- */
- public function remove_core_styles() {
- /*
- * Notifications need the admin bar styles,
- * so let's not remove them when the module is active.
- */
- if ( ! Jetpack::is_module_active( 'notes' ) ) {
- wp_dequeue_style( 'admin-bar' );
- }
- }
-
- /**
- * Check if the user settings are for an RTL language or not.
- */
- public function is_rtl() {
- return 'rtl' === $this->user_text_direction ? true : false;
- }
-
- /**
- * Enqueue our own CSS and JS to display our custom admin bar.
- */
- public function add_styles_and_scripts() {
-
- if ( $this->is_rtl() ) {
- wp_enqueue_style( 'a8c-wpcom-masterbar-rtl', $this->wpcom_static_url( '/wp-content/mu-plugins/admin-bar/rtl/wpcom-admin-bar-rtl.css' ), array(), JETPACK__VERSION );
- wp_enqueue_style( 'a8c-wpcom-masterbar-overrides-rtl', $this->wpcom_static_url( '/wp-content/mu-plugins/admin-bar/masterbar-overrides/rtl/masterbar-rtl.css' ), array(), JETPACK__VERSION );
- } else {
- wp_enqueue_style( 'a8c-wpcom-masterbar', $this->wpcom_static_url( '/wp-content/mu-plugins/admin-bar/wpcom-admin-bar.css' ), array(), JETPACK__VERSION );
- wp_enqueue_style( 'a8c-wpcom-masterbar-overrides', $this->wpcom_static_url( '/wp-content/mu-plugins/admin-bar/masterbar-overrides/masterbar.css' ), array(), JETPACK__VERSION );
- }
-
- // Local overrides.
- wp_enqueue_style( 'a8c_wpcom_css_override', plugins_url( 'overrides.css', __FILE__ ), array(), JETPACK__VERSION );
-
- if ( ! Jetpack::is_module_active( 'notes ' ) ) {
- // Masterbar is relying on some icons from noticons.css.
- wp_enqueue_style( 'noticons', $this->wpcom_static_url( '/i/noticons/noticons.css' ), array(), JETPACK__VERSION . '-' . gmdate( 'oW' ) );
- }
-
- wp_enqueue_script(
- 'jetpack-accessible-focus',
- Assets::get_file_url_for_environment( '_inc/build/accessible-focus.min.js', '_inc/accessible-focus.js' ),
- array(),
- JETPACK__VERSION,
- false
- );
- wp_enqueue_script(
- 'a8c_wpcom_masterbar_tracks_events',
- Assets::get_file_url_for_environment(
- '_inc/build/masterbar/tracks-events.min.js',
- 'modules/masterbar/tracks-events.js'
- ),
- array( 'jquery' ),
- JETPACK__VERSION,
- false
- );
-
- wp_enqueue_script(
- 'a8c_wpcom_masterbar_overrides',
- $this->wpcom_static_url( '/wp-content/mu-plugins/admin-bar/masterbar-overrides/masterbar.js' ),
- array( 'jquery' ),
- JETPACK__VERSION,
- false
- );
- }
-
- /**
- * Get base URL where our CSS and JS will come from.
- *
- * @param string $file File path for a static resource.
- */
- private function wpcom_static_url( $file ) {
- if ( ! empty( $this->sandbox_url ) ) {
- // For testing undeployed changes to remotely enqueued scripts and styles.
- return set_url_scheme( $this->sandbox_url . $file, 'https' );
- }
-
- $i = hexdec( substr( md5( $file ), - 1 ) ) % 2;
- $url = 'https://s' . $i . '.wp.com' . $file;
-
- return set_url_scheme( $url, 'https' );
- }
-
- /**
- * Remove the default admin bar items and replace it with our own admin bar.
- */
- public function replace_core_masterbar() {
- global $wp_admin_bar;
-
- if ( ! is_object( $wp_admin_bar ) ) {
- return false;
- }
-
- $this->clear_core_masterbar( $wp_admin_bar );
- $this->build_wpcom_masterbar( $wp_admin_bar );
- }
-
- /**
- * Remove all existing toolbar entries from core Masterbar
- *
- * @param WP_Admin_Bar $wp_admin_bar Admin Bar instance.
- */
- public function clear_core_masterbar( $wp_admin_bar ) {
- foreach ( $wp_admin_bar->get_nodes() as $node ) {
- $wp_admin_bar->remove_node( $node->id );
- }
- }
-
- /**
- * Add entries corresponding to WordPress.com Masterbar
- *
- * @param WP_Admin_Bar $wp_admin_bar Admin Bar instance.
- */
- public function build_wpcom_masterbar( $wp_admin_bar ) {
- // Menu groups.
- $this->wpcom_adminbar_add_secondary_groups( $wp_admin_bar );
-
- // Left part.
- $this->add_my_sites_submenu( $wp_admin_bar );
- $this->add_reader_submenu( $wp_admin_bar );
-
- // Right part.
- if ( Jetpack::is_module_active( 'notes' ) ) {
- $this->add_notifications( $wp_admin_bar );
- }
-
- $this->add_me_submenu( $wp_admin_bar );
- $this->add_write_button( $wp_admin_bar );
-
- // Recovery mode exit.
- if ( function_exists( 'wp_admin_bar_recovery_mode_menu' ) ) {
- wp_admin_bar_recovery_mode_menu( $wp_admin_bar );
- }
- }
-
- /**
- * Get WordPress.com current locale name.
- */
- public function get_locale() {
- $wpcom_locale = get_locale();
-
- if ( ! class_exists( 'GP_Locales' ) ) {
- if ( defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) && file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) {
- require JETPACK__GLOTPRESS_LOCALES_PATH;
- }
- }
-
- if ( class_exists( 'GP_Locales' ) ) {
- $wpcom_locale_object = GP_Locales::by_field( 'wp_locale', get_locale() );
- if ( $wpcom_locale_object instanceof GP_Locale ) {
- $wpcom_locale = $wpcom_locale_object->slug;
- }
- }
-
- return $wpcom_locale;
- }
-
- /**
- * Add the Notifications menu item.
- *
- * @param WP_Admin_Bar $wp_admin_bar Admin Bar instance.
- */
- public function add_notifications( $wp_admin_bar ) {
- $wp_admin_bar->add_node(
- array(
- 'id' => 'notes',
- 'title' => '<span id="wpnt-notes-unread-count" class="wpnt-loading wpn-read"></span>
- <span class="screen-reader-text">' . esc_html__( 'Notifications', 'jetpack' ) . '</span>
- <span class="noticon noticon-bell"></span>',
- 'meta' => array(
- 'html' => '<div id="wpnt-notes-panel2" style="display:none" lang="' . esc_attr( $this->locale ) . '" dir="' . ( $this->is_rtl() ? 'rtl' : 'ltr' ) . '">' .
- '<div class="wpnt-notes-panel-header">' .
- '<span class="wpnt-notes-header">' .
- esc_html__( 'Notifications', 'jetpack' ) .
- '</span>' .
- '<span class="wpnt-notes-panel-link">' .
- '</span>' .
- '</div>' .
- '</div>',
- 'class' => 'menupop mb-trackable',
- ),
- 'parent' => 'top-secondary',
- )
- );
- }
-
- /**
- * Add the "Reader" menu item in the root default group.
- *
- * @param WP_Admin_Bar $wp_admin_bar Admin Bar instance.
- */
- public function add_reader_submenu( $wp_admin_bar ) {
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'root-default',
- 'id' => 'newdash',
- 'title' => esc_html__( 'Reader', 'jetpack' ),
- 'href' => '#',
- 'meta' => array(
- 'class' => 'mb-trackable',
- ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'newdash',
- 'id' => 'streams-header',
- 'title' => esc_html_x(
- 'Streams',
- 'Title for Reader sub-menu that contains followed sites, likes, and recommendations',
- 'jetpack'
- ),
- 'meta' => array(
- 'class' => 'ab-submenu-header',
- ),
- )
- );
-
- $following_title = $this->create_menu_item_pair(
- array(
- 'url' => 'https://wordpress.com/read',
- 'id' => 'wp-admin-bar-followed-sites',
- 'label' => esc_html__( 'Followed Sites', 'jetpack' ),
- ),
- array(
- 'url' => 'https://wordpress.com/following/edit',
- 'id' => 'wp-admin-bar-reader-followed-sites-manage',
- 'label' => esc_html__( 'Manage', 'jetpack' ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'newdash',
- 'id' => 'following',
- 'title' => $following_title,
- 'meta' => array( 'class' => 'inline-action' ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'newdash',
- 'id' => 'discover-discover',
- 'title' => esc_html__( 'Discover', 'jetpack' ),
- 'href' => 'https://wordpress.com/discover',
- 'meta' => array(
- 'class' => 'mb-icon-spacer',
- ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'newdash',
- 'id' => 'discover-search',
- 'title' => esc_html__( 'Search', 'jetpack' ),
- 'href' => 'https://wordpress.com/read/search',
- 'meta' => array(
- 'class' => 'mb-icon-spacer',
- ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'newdash',
- 'id' => 'discover-recommended-blogs',
- 'title' => esc_html__( 'Recommendations', 'jetpack' ),
- 'href' => 'https://wordpress.com/recommendations',
- 'meta' => array(
- 'class' => 'mb-icon-spacer',
- ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'newdash',
- 'id' => 'my-activity-my-likes',
- 'title' => esc_html__( 'My Likes', 'jetpack' ),
- 'href' => 'https://wordpress.com/activities/likes',
- 'meta' => array(
- 'class' => 'mb-icon-spacer',
- ),
- )
- );
-
- }
-
- /**
- * Merge 2 menu items together into 2 link tags.
- *
- * @param array $primary Array of menu information.
- * @param array $secondary Array of menu information.
- */
- public function create_menu_item_pair( $primary, $secondary ) {
- $primary_class = 'ab-item ab-primary mb-icon';
- $secondary_class = 'ab-secondary';
-
- $primary_anchor = $this->create_menu_item_anchor( $primary_class, $primary['url'], $primary['label'], $primary['id'] );
- $secondary_anchor = $this->create_menu_item_anchor( $secondary_class, $secondary['url'], $secondary['label'], $secondary['id'] );
-
- return $primary_anchor . $secondary_anchor;
- }
-
- /**
- * Create a link tag based on information about a menu item.
- *
- * @param string $class Menu item CSS class.
- * @param string $url URL you go to when clicking on the menu item.
- * @param string $label Menu item title.
- * @param string $id Menu item slug.
- */
- public function create_menu_item_anchor( $class, $url, $label, $id ) {
- return '<a href="' . $url . '" class="' . $class . '" id="' . $id . '">' . $label . '</a>';
- }
-
- /**
- * Add Secondary groups for submenu items.
- *
- * @param WP_Admin_Bar $wp_admin_bar Admin Bar instance.
- */
- public function wpcom_adminbar_add_secondary_groups( $wp_admin_bar ) {
- $wp_admin_bar->add_group(
- array(
- 'id' => 'root-default',
- 'meta' => array(
- 'class' => 'ab-top-menu',
- ),
- )
- );
-
- $wp_admin_bar->add_group(
- array(
- 'parent' => 'blog',
- 'id' => 'blog-secondary',
- 'meta' => array(
- 'class' => 'ab-sub-secondary',
- ),
- )
- );
-
- $wp_admin_bar->add_group(
- array(
- 'id' => 'top-secondary',
- 'meta' => array(
- 'class' => 'ab-top-secondary',
- ),
- )
- );
- }
-
- /**
- * Add User info menu item.
- *
- * @param WP_Admin_Bar $wp_admin_bar Admin Bar instance.
- */
- public function add_me_submenu( $wp_admin_bar ) {
- $user_id = get_current_user_id();
- if ( empty( $user_id ) ) {
- return;
- }
-
- $avatar = get_avatar( $this->user_email, 32, 'mm', '', array( 'force_display' => true ) );
- $class = empty( $avatar ) ? 'mb-trackable' : 'with-avatar mb-trackable';
-
- // Add the 'Me' menu.
- $wp_admin_bar->add_menu(
- array(
- 'id' => 'my-account',
- 'parent' => 'top-secondary',
- 'title' => $avatar . '<span class="ab-text">' . esc_html__( 'Me', 'jetpack' ) . '</span>',
- 'href' => '#',
- 'meta' => array(
- 'class' => $class,
- ),
- )
- );
-
- $id = 'user-actions';
- $wp_admin_bar->add_group(
- array(
- 'parent' => 'my-account',
- 'id' => $id,
- )
- );
-
- $settings_url = 'https://wordpress.com/me/account';
-
- $logout_url = wp_logout_url();
- $logout_url = add_query_arg( 'context', 'masterbar', $logout_url );
-
- $user_info = get_avatar( $this->user_email, 128, 'mm', '', array( 'force_display' => true ) );
- $user_info .= '<span class="display-name">' . $this->display_name . '</span>';
- $user_info .= '<a class="username" href="https://gravatar.com/' . $this->user_login . '">@' . $this->user_login . '</a>';
-
- $user_info .= sprintf(
- '<div><a href="%s" class="ab-sign-out">%s</a></div>',
- $logout_url,
- esc_html__( 'Sign Out', 'jetpack' )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => $id,
- 'id' => 'user-info',
- 'title' => $user_info,
- 'meta' => array(
- 'class' => 'user-info user-info-item',
- 'tabindex' => -1,
- ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => $id,
- 'id' => 'profile-header',
- 'title' => esc_html__( 'Profile', 'jetpack' ),
- 'meta' => array(
- 'class' => 'ab-submenu-header',
- ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => $id,
- 'id' => 'my-profile',
- 'title' => esc_html__( 'My Profile', 'jetpack' ),
- 'href' => 'https://wordpress.com/me',
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => $id,
- 'id' => 'account-settings',
- 'title' => esc_html__( 'Account Settings', 'jetpack' ),
- 'href' => $settings_url,
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => $id,
- 'id' => 'billing',
- 'title' => esc_html__( 'Manage Purchases', 'jetpack' ),
- 'href' => 'https://wordpress.com/me/purchases',
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => $id,
- 'id' => 'security',
- 'title' => esc_html__( 'Security', 'jetpack' ),
- 'href' => 'https://wordpress.com/me/security',
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => $id,
- 'id' => 'notifications',
- 'title' => esc_html__( 'Notifications', 'jetpack' ),
- 'href' => 'https://wordpress.com/me/notifications',
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => $id,
- 'id' => 'special-header',
- 'title' => esc_html_x(
- 'Special',
- 'Title for Me sub-menu that contains Get Apps, Next Steps, and Help options',
- 'jetpack'
- ),
- 'meta' => array(
- 'class' => 'ab-submenu-header',
- ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => $id,
- 'id' => 'get-apps',
- 'title' => esc_html__( 'Get Apps', 'jetpack' ),
- 'href' => 'https://wordpress.com/me/get-apps',
- 'meta' => array(
- 'class' => 'mb-icon user-info-item',
- ),
- )
- );
-
- $help_link = 'https://jetpack.com/support/';
-
- if ( jetpack_is_atomic_site() ) {
- $help_link = 'https://wordpress.com/help';
- }
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => $id,
- 'id' => 'help',
- 'title' => esc_html__( 'Help', 'jetpack' ),
- 'href' => $help_link,
- 'meta' => array(
- 'class' => 'mb-icon user-info-item',
- ),
- )
- );
- }
-
- /**
- * Add Write Menu item.
- *
- * @param WP_Admin_Bar $wp_admin_bar Admin Bar instance.
- */
- public function add_write_button( $wp_admin_bar ) {
- $current_user = wp_get_current_user();
-
- $posting_blog_id = get_current_blog_id();
- if ( ! is_user_member_of_blog( get_current_user_id(), get_current_blog_id() ) ) {
- $posting_blog_id = $current_user->primary_blog;
- }
-
- $user_can_post = current_user_can_for_blog( $posting_blog_id, 'publish_posts' );
-
- if ( ! $posting_blog_id || ! $user_can_post ) {
- return;
- }
-
- $blog_post_page = 'https://wordpress.com/post/' . esc_attr( $this->primary_site_slug );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'top-secondary',
- 'id' => 'ab-new-post',
- 'href' => $blog_post_page,
- 'title' => '<span>' . esc_html__( 'Write', 'jetpack' ) . '</span>',
- 'meta' => array(
- 'class' => 'mb-trackable',
- ),
- )
- );
- }
-
- /**
- * Add the "My Site" menu item in the root default group.
- *
- * @param WP_Admin_Bar $wp_admin_bar Admin Bar instance.
- */
- public function add_my_sites_submenu( $wp_admin_bar ) {
- $current_user = wp_get_current_user();
-
- $blog_name = get_bloginfo( 'name' );
- if ( empty( $blog_name ) ) {
- $blog_name = $this->primary_site_slug;
- }
-
- if ( mb_strlen( $blog_name ) > 20 ) {
- $blog_name = mb_substr( html_entity_decode( $blog_name, ENT_QUOTES ), 0, 20 ) . '&hellip;';
- }
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'root-default',
- 'id' => 'blog',
- 'title' => _n( 'My Site', 'My Sites', $this->user_site_count, 'jetpack' ),
- 'href' => '#',
- 'meta' => array(
- 'class' => 'my-sites mb-trackable',
- ),
- )
- );
-
- if ( $this->user_site_count > 1 ) {
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'blog',
- 'id' => 'switch-site',
- 'title' => esc_html__( 'Switch Site', 'jetpack' ),
- 'href' => 'https://wordpress.com/sites',
- )
- );
- } else {
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'blog',
- 'id' => 'new-site',
- 'title' => esc_html__( '+ Add New WordPress', 'jetpack' ),
- 'href' => 'https://wordpress.com/start?ref=admin-bar-logged-in',
- )
- );
- }
-
- if ( is_user_member_of_blog( $current_user->ID ) ) {
- $blavatar = '';
- $class = 'current-site';
-
- if ( has_site_icon() ) {
- $src = get_site_icon_url();
- $blavatar = '<img class="avatar" src="' . esc_attr( $src ) . '" alt="Current site avatar">';
- $class = 'has-blavatar';
- }
-
- $blog_info = '<div class="ab-site-icon">' . $blavatar . '</div>';
- $blog_info .= '<span class="ab-site-title">' . esc_html( $blog_name ) . '</span>';
- $blog_info .= '<span class="ab-site-description">' . esc_html( $this->primary_site_url ) . '</span>';
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'blog',
- 'id' => 'blog-info',
- 'title' => $blog_info,
- 'href' => esc_url( trailingslashit( $this->primary_site_url ) ),
- 'meta' => array(
- 'class' => $class,
- ),
- )
- );
- }
-
- // Site Preview.
- if ( is_admin() ) {
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'blog',
- 'id' => 'site-view',
- 'title' => __( 'View Site', 'jetpack' ),
- 'href' => home_url(),
- 'meta' => array(
- 'class' => 'mb-icon',
- 'target' => '_blank',
- ),
- )
- );
- }
-
- $this->add_my_home_submenu_item( $wp_admin_bar );
-
- // Stats.
- if ( Jetpack::is_module_active( 'stats' ) && current_user_can( 'view_stats' ) ) {
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'blog',
- 'id' => 'blog-stats',
- 'title' => esc_html__( 'Stats', 'jetpack' ),
- 'href' => 'https://wordpress.com/stats/' . esc_attr( $this->primary_site_slug ),
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- )
- );
- }
-
- if ( current_user_can( 'manage_options' ) ) {
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'blog',
- 'id' => 'activity',
- 'title' => esc_html__( 'Activity', 'jetpack' ),
- 'href' => 'https://wordpress.com/activity-log/' . esc_attr( $this->primary_site_slug ),
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- )
- );
- }
-
- // Add Calypso plans link and plan type indicator.
- if ( is_user_member_of_blog( $current_user->ID ) && current_user_can( 'manage_options' ) ) {
- $plans_url = 'https://wordpress.com/plans/' . esc_attr( $this->primary_site_slug );
- $label = esc_html__( 'Plan', 'jetpack' );
- $plan = Jetpack_Plan::get();
-
- $plan_title = $this->create_menu_item_pair(
- array(
- 'url' => $plans_url,
- 'id' => 'wp-admin-bar-plan',
- 'label' => $label,
- ),
- array(
- 'url' => $plans_url,
- 'id' => 'wp-admin-bar-plan-badge',
- 'label' => $plan['product_name_short'],
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'blog',
- 'id' => 'plan',
- 'title' => $plan_title,
- 'meta' => array(
- 'class' => 'inline-action',
- ),
- )
- );
- }
-
- // Publish group.
- $wp_admin_bar->add_group(
- array(
- 'parent' => 'blog',
- 'id' => 'publish',
- )
- );
-
- // Publish header.
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'publish',
- 'id' => 'publish-header',
- 'title' => esc_html_x( 'Manage', 'admin bar menu group label', 'jetpack' ),
- 'meta' => array(
- 'class' => 'ab-submenu-header',
- ),
- )
- );
-
- // Pages.
- $pages_title = $this->create_menu_item_pair(
- array(
- 'url' => 'https://wordpress.com/pages/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-edit-page',
- 'label' => esc_html__( 'Site Pages', 'jetpack' ),
- ),
- array(
- 'url' => 'https://wordpress.com/page/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-new-page-badge',
- 'label' => esc_html_x( 'Add', 'admin bar menu new item label', 'jetpack' ),
- )
- );
-
- if ( ! current_user_can( 'edit_pages' ) ) {
- $pages_title = $this->create_menu_item_anchor(
- 'ab-item ab-primary mb-icon',
- 'https://wordpress.com/pages/' . esc_attr( $this->primary_site_slug ),
- esc_html__( 'Site Pages', 'jetpack' ),
- 'wp-admin-bar-edit-page'
- );
- }
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'publish',
- 'id' => 'new-page',
- 'title' => $pages_title,
- 'meta' => array(
- 'class' => 'inline-action',
- ),
- )
- );
-
- // Blog Posts.
- $posts_title = $this->create_menu_item_pair(
- array(
- 'url' => 'https://wordpress.com/posts/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-edit-post',
- 'label' => esc_html__( 'Blog Posts', 'jetpack' ),
- ),
- array(
- 'url' => 'https://wordpress.com/post/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-new-post-badge',
- 'label' => esc_html_x( 'Add', 'admin bar menu new item label', 'jetpack' ),
- )
- );
-
- if ( ! current_user_can( 'edit_posts' ) ) {
- $posts_title = $this->create_menu_item_anchor(
- 'ab-item ab-primary mb-icon',
- 'https://wordpress.com/posts/' . esc_attr( $this->primary_site_slug ),
- esc_html__( 'Blog Posts', 'jetpack' ),
- 'wp-admin-bar-edit-post'
- );
- }
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'publish',
- 'id' => 'new-post',
- 'title' => $posts_title,
- 'meta' => array(
- 'class' => 'inline-action mb-trackable',
- ),
- )
- );
-
- // Comments.
- if ( current_user_can( 'moderate_comments' ) ) {
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'publish',
- 'id' => 'comments',
- 'title' => __( 'Comments', 'jetpack' ),
- 'href' => 'https://wordpress.com/comments/' . esc_attr( $this->primary_site_slug ),
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- )
- );
- }
-
- // Testimonials.
- if ( Jetpack::is_module_active( 'custom-content-types' ) && get_option( 'jetpack_testimonial' ) ) {
- $testimonials_title = $this->create_menu_item_pair(
- array(
- 'url' => 'https://wordpress.com/types/jetpack-testimonial/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-edit-testimonial',
- 'label' => esc_html__( 'Testimonials', 'jetpack' ),
- ),
- array(
- 'url' => 'https://wordpress.com/edit/jetpack-testimonial/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-new-testimonial',
- 'label' => esc_html_x( 'Add', 'Button label for adding a new item via the toolbar menu', 'jetpack' ),
- )
- );
-
- if ( ! current_user_can( 'edit_pages' ) ) {
- $testimonials_title = $this->create_menu_item_anchor(
- 'ab-item ab-primary mb-icon',
- 'https://wordpress.com/types/jetpack-testimonial/' . esc_attr( $this->primary_site_slug ),
- esc_html__( 'Testimonials', 'jetpack' ),
- 'wp-admin-bar-edit-testimonial'
- );
- }
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'publish',
- 'id' => 'new-jetpack-testimonial',
- 'title' => $testimonials_title,
- 'meta' => array(
- 'class' => 'inline-action',
- ),
- )
- );
- }
-
- // Portfolio.
- if ( Jetpack::is_module_active( 'custom-content-types' ) && get_option( 'jetpack_portfolio' ) ) {
- $portfolios_title = $this->create_menu_item_pair(
- array(
- 'url' => 'https://wordpress.com/types/jetpack-portfolio/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-edit-portfolio',
- 'label' => esc_html__( 'Portfolio', 'jetpack' ),
- ),
- array(
- 'url' => 'https://wordpress.com/edit/jetpack-portfolio/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-new-portfolio',
- 'label' => esc_html_x( 'Add', 'Button label for adding a new item via the toolbar menu', 'jetpack' ),
- )
- );
-
- if ( ! current_user_can( 'edit_pages' ) ) {
- $portfolios_title = $this->create_menu_item_anchor(
- 'ab-item ab-primary mb-icon',
- 'https://wordpress.com/types/jetpack-portfolio/' . esc_attr( $this->primary_site_slug ),
- esc_html__( 'Portfolio', 'jetpack' ),
- 'wp-admin-bar-edit-portfolio'
- );
- }
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'publish',
- 'id' => 'new-jetpack-portfolio',
- 'title' => $portfolios_title,
- 'meta' => array(
- 'class' => 'inline-action',
- ),
- )
- );
- }
-
- if ( current_user_can( 'edit_theme_options' ) ) {
- // Look and Feel group.
- $wp_admin_bar->add_group(
- array(
- 'parent' => 'blog',
- 'id' => 'look-and-feel',
- )
- );
-
- // Look and Feel header.
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'look-and-feel',
- 'id' => 'look-and-feel-header',
- 'title' => esc_html_x( 'Personalize', 'admin bar menu group label', 'jetpack' ),
- 'meta' => array(
- 'class' => 'ab-submenu-header',
- ),
- )
- );
-
- if ( is_admin() ) {
- // In wp-admin the `return` query arg will return to that page after closing the Customizer.
- $customizer_url = add_query_arg(
- array(
- 'return' => rawurlencode( site_url( $_SERVER['REQUEST_URI'] ) ),
- ),
- wp_customize_url()
- );
- } else {
- /*
- * On the frontend the `url` query arg will load that page in the Customizer
- * and also return to it after closing
- * non-home URLs won't work unless we undo domain mapping
- * since the Customizer preview is unmapped to always have HTTPS.
- */
- $current_page = '//' . $this->primary_site_slug . $_SERVER['REQUEST_URI'];
- $customizer_url = add_query_arg( array( 'url' => rawurlencode( $current_page ) ), wp_customize_url() );
- }
-
- $theme_title = $this->create_menu_item_pair(
- array(
- 'url' => $customizer_url,
- 'id' => 'wp-admin-bar-cmz',
- 'label' => esc_html_x( 'Customize', 'admin bar customize item label', 'jetpack' ),
- ),
- array(
- 'url' => 'https://wordpress.com/themes/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-themes',
- 'label' => esc_html__( 'Themes', 'jetpack' ),
- )
- );
- $meta = array(
- 'class' => 'mb-icon',
- 'class' => 'inline-action',
- );
- $href = false;
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'look-and-feel',
- 'id' => 'themes',
- 'title' => $theme_title,
- 'href' => $href,
- 'meta' => $meta,
- )
- );
- }
-
- if ( current_user_can( 'manage_options' ) ) {
- // Configuration group.
- $wp_admin_bar->add_group(
- array(
- 'parent' => 'blog',
- 'id' => 'configuration',
- )
- );
-
- // Configuration header.
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'configuration',
- 'id' => 'configuration-header',
- 'title' => esc_html_x( 'Configure', 'admin bar menu group label', 'jetpack' ),
- 'meta' => array(
- 'class' => 'ab-submenu-header',
- ),
- )
- );
-
- if ( Jetpack::is_module_active( 'publicize' ) || Jetpack::is_module_active( 'sharedaddy' ) ) {
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'configuration',
- 'id' => 'sharing',
- 'title' => esc_html__( 'Sharing', 'jetpack' ),
- 'href' => 'https://wordpress.com/sharing/' . esc_attr( $this->primary_site_slug ),
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- )
- );
- }
-
- $people_title = $this->create_menu_item_pair(
- array(
- 'url' => 'https://wordpress.com/people/team/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-people',
- 'label' => esc_html__( 'People', 'jetpack' ),
- ),
- array(
- 'url' => admin_url( 'user-new.php' ),
- 'id' => 'wp-admin-bar-people-add',
- 'label' => esc_html_x( 'Add', 'admin bar people item label', 'jetpack' ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'configuration',
- 'id' => 'users-toolbar',
- 'title' => $people_title,
- 'href' => false,
- 'meta' => array(
- 'class' => 'inline-action',
- ),
- )
- );
-
- $plugins_title = $this->create_menu_item_pair(
- array(
- 'url' => 'https://wordpress.com/plugins/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-plugins',
- 'label' => esc_html__( 'Plugins', 'jetpack' ),
- ),
- array(
- 'url' => 'https://wordpress.com/plugins/manage/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-plugins-add',
- 'label' => esc_html_x( 'Manage', 'Label for the button on the Masterbar to manage plugins', 'jetpack' ),
- )
- );
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'configuration',
- 'id' => 'plugins',
- 'title' => $plugins_title,
- 'href' => false,
- 'meta' => array(
- 'class' => 'inline-action',
- ),
- )
- );
-
- if ( jetpack_is_atomic_site() ) {
- $domain_title = $this->create_menu_item_pair(
- array(
- 'url' => 'https://wordpress.com/domains/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-domains',
- 'label' => esc_html__( 'Domains', 'jetpack' ),
- ),
- array(
- 'url' => 'https://wordpress.com/domains/add/' . esc_attr( $this->primary_site_slug ),
- 'id' => 'wp-admin-bar-domains-add',
- 'label' => esc_html_x( 'Add', 'Label for the button on the Masterbar to add a new domain', 'jetpack' ),
- )
- );
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'configuration',
- 'id' => 'domains',
- 'title' => $domain_title,
- 'href' => false,
- 'meta' => array(
- 'class' => 'inline-action',
- ),
- )
- );
- }
-
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'configuration',
- 'id' => 'blog-settings',
- 'title' => esc_html__( 'Settings', 'jetpack' ),
- 'href' => 'https://wordpress.com/settings/general/' . esc_attr( $this->primary_site_slug ),
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- )
- );
-
- if ( ! is_admin() ) {
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'configuration',
- 'id' => 'legacy-dashboard',
- 'title' => esc_html__( 'Dashboard', 'jetpack' ),
- 'href' => admin_url(),
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- )
- );
- }
-
- // Restore dashboard menu toggle that is needed on mobile views.
- if ( is_admin() ) {
- $wp_admin_bar->add_menu(
- array(
- 'id' => 'menu-toggle',
- 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . esc_html__( 'Menu', 'jetpack' ) . '</span>',
- 'href' => '#',
- )
- );
- }
-
- /**
- * Fires when menu items are added to the masterbar "My Sites" menu.
- *
- * @since 5.4.0
- */
- do_action( 'jetpack_masterbar' );
- }
- }
-
- /**
- * Calls the wpcom API to get the creation date of the site
- * and determine if it's eligible for the 'My Home' page.
- *
- * @return bool Whether the site has 'My Home' enabled.
- */
- private function is_my_home_enabled() {
- $my_home_enabled = get_transient( 'jetpack_my_home_enabled' );
-
- if ( false === $my_home_enabled ) {
- $site_id = Jetpack_Options::get_option( 'id' );
- $site_response = Client::wpcom_json_api_request_as_blog(
- sprintf( '/sites/%d', $site_id ) . '?force=wpcom&options=created_at',
- '1.1'
- );
-
- if ( is_wp_error( $site_response ) ) {
- return false;
- }
-
- $site_data = json_decode( wp_remote_retrieve_body( $site_response ) );
-
- $my_home_enabled = $site_data &&
- isset( $site_data->options->created_at ) &&
- ( new Datetime( '2019-08-06 00:00:00.000' ) ) <= ( new Datetime( $site_data->options->created_at ) )
- ? 1
- : 0;
-
- set_transient( 'jetpack_my_home_enabled', $my_home_enabled );
- }
-
- return (bool) $my_home_enabled;
- }
-
- /**
- * Adds "My Home" submenu item to sites that are eligible.
- *
- * @param WP_Admin_Bar $wp_admin_bar Admin Bar instance.
- * @return void
- */
- private function add_my_home_submenu_item( &$wp_admin_bar ) {
- if ( ! current_user_can( 'manage_options' ) || ! jetpack_is_atomic_site() ) {
- return;
- }
-
- if ( $this->is_my_home_enabled() ) {
- $wp_admin_bar->add_menu(
- array(
- 'parent' => 'blog',
- 'id' => 'my-home',
- 'title' => __( 'My Home', 'jetpack' ),
- 'href' => 'https://wordpress.com/home/' . esc_attr( $this->primary_site_slug ),
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- )
- );
- }
- }
-}
diff --git a/plugins/jetpack/modules/masterbar/masterbar/class-masterbar.php b/plugins/jetpack/modules/masterbar/masterbar/class-masterbar.php
index 260a38fd..487c59fa 100644
--- a/plugins/jetpack/modules/masterbar/masterbar/class-masterbar.php
+++ b/plugins/jetpack/modules/masterbar/masterbar/class-masterbar.php
@@ -439,7 +439,11 @@ class Masterbar {
}
}
- return $jetpack_locale;
+ if ( isset( $jetpack_locale ) ) {
+ return $jetpack_locale;
+ }
+
+ return 'en_US';
}
/**
@@ -1253,11 +1257,12 @@ class Masterbar {
)
);
+ $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
if ( is_admin() ) {
// In wp-admin the `return` query arg will return to that page after closing the Customizer.
$customizer_url = add_query_arg(
array(
- 'return' => rawurlencode( site_url( $_SERVER['REQUEST_URI'] ) ),
+ 'return' => rawurlencode( site_url( $request_uri ) ),
),
wp_customize_url()
);
@@ -1268,7 +1273,7 @@ class Masterbar {
* non-home URLs won't work unless we undo domain mapping
* since the Customizer preview is unmapped to always have HTTPS.
*/
- $current_page = '//' . $this->primary_site_slug . $_SERVER['REQUEST_URI'];
+ $current_page = '//' . $this->primary_site_slug . $request_uri;
$customizer_url = add_query_arg( array( 'url' => rawurlencode( $current_page ) ), wp_customize_url() );
}
diff --git a/plugins/jetpack/modules/masterbar/nudges/additional-css/class-atomic-additional-css-manager.php b/plugins/jetpack/modules/masterbar/nudges/additional-css/class-atomic-additional-css-manager.php
index 5f6893d8..1787cfdd 100644
--- a/plugins/jetpack/modules/masterbar/nudges/additional-css/class-atomic-additional-css-manager.php
+++ b/plugins/jetpack/modules/masterbar/nudges/additional-css/class-atomic-additional-css-manager.php
@@ -41,7 +41,7 @@ class Atomic_Additional_CSS_Manager {
$nudge = new CSS_Customizer_Nudge(
$this->get_nudge_url(),
- __( 'Purchase a Business Plan to<br> activate CSS customization', 'jetpack' )
+ __( 'Purchase a Pro Plan to<br> activate CSS customization', 'jetpack' )
);
$wp_customize_manager->remove_control( 'custom_css' );
@@ -56,6 +56,6 @@ class Atomic_Additional_CSS_Manager {
* @return string
*/
private function get_nudge_url() {
- return '/checkout/' . $this->domain . '/business';
+ return '/checkout/' . $this->domain . '/pro';
}
}
diff --git a/plugins/jetpack/modules/masterbar/nudges/additional-css/class-wpcom-additional-css-manager.php b/plugins/jetpack/modules/masterbar/nudges/additional-css/class-wpcom-additional-css-manager.php
index 51fd3859..8fc60d34 100644
--- a/plugins/jetpack/modules/masterbar/nudges/additional-css/class-wpcom-additional-css-manager.php
+++ b/plugins/jetpack/modules/masterbar/nudges/additional-css/class-wpcom-additional-css-manager.php
@@ -38,9 +38,12 @@ class WPCOM_Additional_CSS_Manager {
* @param \WP_Customize_Manager $wp_customize_manager The core customize manager.
*/
public function register_nudge( \WP_Customize_Manager $wp_customize_manager ) {
+ $nudge_url = $this->get_nudge_url();
+ $nudge_text = __( 'Purchase a Pro Plan to<br> activate CSS customization', 'jetpack' );
+
$nudge = new CSS_Customizer_Nudge(
- $this->get_nudge_url(),
- __( 'Purchase a Premium Plan to<br> activate CSS customization', 'jetpack' ),
+ $nudge_url,
+ $nudge_text,
'jetpack_custom_css'
);
@@ -53,6 +56,6 @@ class WPCOM_Additional_CSS_Manager {
* @return string
*/
private function get_nudge_url() {
- return '/checkout/' . $this->domain . '/premium';
+ return '/checkout/' . $this->domain . '/pro';
}
}
diff --git a/plugins/jetpack/modules/masterbar/overrides.css b/plugins/jetpack/modules/masterbar/overrides.css
deleted file mode 100644
index d6a09be0..00000000
--- a/plugins/jetpack/modules/masterbar/overrides.css
+++ /dev/null
@@ -1,132 +0,0 @@
-/* Remove min-height from menu elements that was causing them to render incorrectly */
-.my-sites li {
- min-height: unset !important;
-}
-
-/* Overwrite a core style which breaks the overflow for .my-sites in Safari */
-#wpadminbar li.menupop.my-sites {
- overflow: visible;
-}
-
-/* Add a focus style for menu items */
-.accessible-focus #wpadminbar li.menupop a.ab-item:focus,
-.accessible-focus #wpadminbar li#wp-admin-bar-notes.menupop .ab-item:focus,
-.accessible-focus #wpadminbar ul li#wp-admin-bar-ab-new-post a:focus {
- -webkit-box-shadow: inset 2px 2px 0 #668eaa,
- inset -2px -2px 0 #668eaa;
- box-shadow: inset 2px 2px 0 #668eaa,
- inset -2px -2px 0 #668eaa;
-}
-
-/* Menu items in panels are inside `ab-empty-item` */
-.accessible-focus #wpadminbar li.menupop .ab-empty-item a.ab-item:focus,
-.accessible-focus #wpadminbar li.menupop .ab-empty-item a.ab-secondary:focus,
-.accessible-focus #wpadminbar li.menupop .ab-empty-item a.username:focus {
- -webkit-box-shadow: inset 2px 2px 0 #2e4354,
- inset -2px -2px 0 #2e4354;
- box-shadow: inset 2px 2px 0 #2e4354,
- inset -2px -2px 0 #2e4354;
-}
-
-.accessible-focus #wpadminbar .quicklinks li#wp-admin-bar-my-account #wp-admin-bar-user-info .ab-sign-out:focus {
- -webkit-box-shadow: inset 2px 2px 0 #2e4354,
- inset -2px -2px 0 #2e4354 !important;
- box-shadow: inset 2px 2px 0 #2e4354,
- inset -2px -2px 0 #2e4354 !important;
-}
-
-.accessible-focus #wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus {
- background: transparent;
-}
-
-/* Hide the panels initially */
-#wpadminbar li#wp-admin-bar-blog.menupop > .ab-sub-wrapper, /* My Sites */
-#wpadminbar li#wp-admin-bar-newdash.menupop > .ab-sub-wrapper, /* Reader */
-#wpadminbar li#wp-admin-bar-my-account.menupop > .ab-sub-wrapper, /* Me */
-#wpadminbar li#wp-admin-bar-notes.menupop > #wpnt-notes-panel2 { /* Notifications */
- display: block !important;
-}
-
-/* Change notification icon the match the one on WP.com */
-#wp-admin-bar-notes .noticon-bell:before {
- content: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cmVjdCB4PSIwIiBmaWxsPSJub25lIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiLz48Zz48cGF0aCBmaWxsPSIjZmZmZmZmIiBkPSJNNi4xNCAxNC45N2wyLjgyOCAyLjgyN2MtLjM2Mi4zNjItLjg2Mi41ODYtMS40MTQuNTg2LTEuMTA1IDAtMi0uODk1LTItMiAwLS41NTIuMjI0LTEuMDUyLjU4Ni0xLjQxNHptOC44NjcgNS4zMjRMMTQuMyAyMSAzIDkuN2wuNzA2LS43MDcgMS4xMDIuMTU3Yy43NTQuMTA4IDEuNjktLjEyMiAyLjA3Ny0uNTFsMy44ODUtMy44ODRjMi4zNC0yLjM0IDYuMTM1LTIuMzQgOC40NzUgMHMyLjM0IDYuMTM1IDAgOC40NzVsLTMuODg1IDMuODg2Yy0uMzg4LjM4OC0uNjE4IDEuMzIzLS41MSAyLjA3N2wuMTU3IDEuMXoiLz48L2c+PC9zdmc+") !important;
-}
-#wp-admin-bar-notes.active .noticon-bell:before {
- content: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cmVjdCB4PSIwIiBmaWxsPSJub25lIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiLz48Zz48cGF0aCBmaWxsPSIjMjMyODJkIiBkPSJNNi4xNCAxNC45N2wyLjgyOCAyLjgyN2MtLjM2Mi4zNjItLjg2Mi41ODYtMS40MTQuNTg2LTEuMTA1IDAtMi0uODk1LTItMiAwLS41NTIuMjI0LTEuMDUyLjU4Ni0xLjQxNHptOC44NjcgNS4zMjRMMTQuMyAyMSAzIDkuN2wuNzA2LS43MDcgMS4xMDIuMTU3Yy43NTQuMTA4IDEuNjktLjEyMiAyLjA3Ny0uNTFsMy44ODUtMy44ODRjMi4zNC0yLjM0IDYuMTM1LTIuMzQgOC40NzUgMHMyLjM0IDYuMTM1IDAgOC40NzVsLTMuODg1IDMuODg2Yy0uMzg4LjM4OC0uNjE4IDEuMzIzLS41MSAyLjA3N2wuMTU3IDEuMXoiLz48L2c+PC9zdmc+") !important;
-}
-
-/* Fit width of sign out button to content */
-#wpadminbar .quicklinks li#wp-admin-bar-my-account #wp-admin-bar-user-info .ab-sign-out {
- display: inline-block;
-}
-
-/* Move the admin menu toggle in Gutenberg - https://github.com/Automattic/jetpack/issues/12320 */
-.jetpack-masterbar.post-new-php.block-editor-page #wpadminbar #wp-admin-bar-ab-new-post {
- display: none;
-}
-
-.jetpack-masterbar.post-new-php.block-editor-page #wpadminbar #wp-admin-bar-menu-toggle {
- top: -4px;
- position: relative;
-}
-
-.jetpack-masterbar.post-new-php.block-editor-page #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before {
- color: #fff !important;
- font-size: 28px;
-}
-
-.jetpack-masterbar #wpadminbar #wp-admin-bar-recovery-mode {
- background-color: #ca4a1f;
- color: #fff;
- margin-right: 1em;
-}
-
-@media screen and (max-width: 480px) {
- .jetpack-masterbar.post-new-php.block-editor-page #wp-toolbar ul li {
- flex: 1;
- width: auto !important;
- }
-
- .jetpack-masterbar.post-new-php.block-editor-page #wpadminbar ul#wp-admin-bar-root-default {
- width: 60%;
- }
-
- .jetpack-masterbar.post-new-php.block-editor-page #wpadminbar ul#wp-admin-bar-top-secondary {
- width: 40%;
- }
-
- .wp-admin.jetpack-masterbar.post-new-php.block-editor-page .wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle {
- left: 0;
- }
-}
-
-@media screen and (max-width: 782px) {
- .wp-admin.jetpack-masterbar.post-new-php.block-editor-page .wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle {
- left: 0 !important;
- }
-
- .jetpack-masterbar.post-new-php.block-editor-page #wp-toolbar,
- .jetpack-masterbar.post-new-php.block-editor-page #wp-toolbar ul {
- display: flex;
- }
-
- .jetpack-masterbar.post-new-php.block-editor-page #wpadminbar ul#wp-admin-bar-root-default {
- flex-grow: 1;
- }
-
- .jetpack-masterbar.post-new-php.block-editor-page #wpadminbar li#wp-admin-bar-menu-toggle {
- order: 1;
- }
-
- .jetpack-masterbar.post-new-php.block-editor-page #wpadminbar li#wp-admin-bar-blog {
- order: 2;
- }
-
- .jetpack-masterbar.post-new-php.block-editor-page #wpadminbar li#wp-admin-bar-newdash {
- order: 3;
- }
-
- .jetpack-masterbar #wpadminbar #wp-admin-bar-recovery-mode {
- display: none;
- }
-}
diff --git a/plugins/jetpack/modules/masterbar/rtl-admin-bar.php b/plugins/jetpack/modules/masterbar/rtl-admin-bar.php
deleted file mode 100644
index 539aa3fe..00000000
--- a/plugins/jetpack/modules/masterbar/rtl-admin-bar.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
-
-if ( ! class_exists( 'WP_Admin_Bar' ) ) {
- require_once ABSPATH . '/wp-includes/class-wp-admin-bar.php';
-}
-
-/**
- * We are using this class to replace core WP_Admin_Bar in cases when
- * we need to override the default styles with rtl ones. This is
- * achieved by adding 'rtl' class to #wpadminbar div. Apart from that
- * the output of render method should be the same as the one of base class.
- */
-class RTL_Admin_Bar extends WP_Admin_Bar {
- /**
- * Display the admin bar.
- */
- public function render() {
- global $is_IE;
- $root = $this->_bind();
-
- // Add browser and RTL classes.
- // We have to do this here since admin bar shows on the front end.
- $class = 'nojq nojs rtl';
- if ( $is_IE ) {
- if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 7' ) ) {
- $class .= ' ie7';
- } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) {
- $class .= ' ie8';
- } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 9' ) ) {
- $class .= ' ie9';
- }
- } elseif ( wp_is_mobile() ) {
- $class .= ' mobile';
- }
-
- ?>
- <div id="wpadminbar" class="<?php echo esc_attr( $class ); ?>">
- <?php if ( ! is_admin() ) : ?>
- <a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1"><?php esc_html_e( 'Skip to toolbar', 'jetpack' ); ?></a>
- <?php endif; ?>
- <div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="<?php esc_attr_e( 'Toolbar', 'jetpack' ); ?>" tabindex="0">
- <?php
- foreach ( $root->children as $group ) :
- $this->_render_group( $group );
- endforeach;
- ?>
- </div>
- <?php if ( is_user_logged_in() ) : ?>
- <a class="screen-reader-shortcut" href="<?php echo esc_url( wp_logout_url() ); ?>"><?php esc_html_e( 'Log Out', 'jetpack' ); ?></a>
- <?php endif; ?>
- </div>
-
- <?php
- }
-}
diff --git a/plugins/jetpack/modules/masterbar/tracks-events.js b/plugins/jetpack/modules/masterbar/tracks-events.js
deleted file mode 100644
index 76bd6a23..00000000
--- a/plugins/jetpack/modules/masterbar/tracks-events.js
+++ /dev/null
@@ -1,160 +0,0 @@
-/*globals jQuery, JSON */
-( function( $ ) {
- var eventName = 'masterbar_click';
-
- var linksTracksEvents = {
- //top level items
- 'wp-admin-bar-blog': 'my_sites',
- 'wp-admin-bar-newdash': 'reader',
- 'wp-admin-bar-ab-new-post': 'write_button',
- 'wp-admin-bar-my-account': 'my_account',
- 'wp-admin-bar-notes': 'notifications',
- //my sites - top items
- 'wp-admin-bar-switch-site': 'my_sites_switch_site',
- 'wp-admin-bar-blog-info': 'my_sites_blog_info',
- 'wp-admin-bar-site-view': 'my_sites_view_site',
- 'wp-admin-bar-my-home': 'my_sites_my_home',
- 'wp-admin-bar-blog-stats': 'my_sites_blog_stats',
- 'wp-admin-bar-activity': 'my_sites_activity',
- 'wp-admin-bar-plan': 'my_sites_plan',
- 'wp-admin-bar-plan-badge': 'my_sites_plan_badge',
- //my sites - manage
- 'wp-admin-bar-edit-page': 'my_sites_manage_site_pages',
- 'wp-admin-bar-new-page-badge': 'my_sites_manage_add_page',
- 'wp-admin-bar-edit-post': 'my_sites_manage_blog_posts',
- 'wp-admin-bar-new-post-badge': 'my_sites_manage_add_new_post',
- 'wp-admin-bar-edit-attachment': 'my_sites_manage_media',
- 'wp-admin-bar-new-attachment-badge': 'my_sites_manage_add_media',
- 'wp-admin-bar-comments': 'my_sites_manage_comments',
- 'wp-admin-bar-edit-testimonial': 'my_sites_manage_testimonials',
- 'wp-admin-bar-new-testimonial': 'my_sites_manage_add_testimonial',
- 'wp-admin-bar-edit-portfolio': 'my_sites_manage_portfolio',
- 'wp-admin-bar-new-portfolio': 'my_sites_manage_add_portfolio',
- //my sites - personalize
- 'wp-admin-bar-themes': 'my_sites_personalize_themes',
- 'wp-admin-bar-cmz': 'my_sites_personalize_themes_customize',
- //my sites - configure
- 'wp-admin-bar-sharing': 'my_sites_configure_sharing',
- 'wp-admin-bar-people': 'my_sites_configure_people',
- 'wp-admin-bar-people-add': 'my_sites_configure_people_add_button',
- 'wp-admin-bar-plugins': 'my_sites_configure_plugins',
- 'wp-admin-bar-plugins-add': 'my_sites_configure_manage_plugins',
- 'wp-admin-bar-blog-settings': 'my_sites_configure_settings',
- //reader
- 'wp-admin-bar-followed-sites': 'reader_followed_sites',
- 'wp-admin-bar-reader-followed-sites-manage': 'reader_manage_followed_sites',
- 'wp-admin-bar-discover-discover': 'reader_discover',
- 'wp-admin-bar-discover-search': 'reader_search',
- 'wp-admin-bar-discover-recommended-blogs': 'reader_recommendations',
- 'wp-admin-bar-my-activity-my-likes': 'reader_my_likes',
- //account
- 'wp-admin-bar-user-info': 'my_account_user_name',
- // account - profile
- 'wp-admin-bar-my-profile': 'my_account_profile_my_profile',
- 'wp-admin-bar-account-settings': 'my_account_profile_account_settings',
- 'wp-admin-bar-billing': 'my_account_profile_manage_purchases',
- 'wp-admin-bar-security': 'my_account_profile_security',
- 'wp-admin-bar-notifications': 'my_account_profile_notifications',
- //account - special
- 'wp-admin-bar-get-apps': 'my_account_special_get_apps',
- 'wp-admin-bar-next-steps': 'my_account_special_next_steps',
- 'wp-admin-bar-help': 'my_account_special_help',
- };
-
- var notesTracksEvents = {
- openSite: function( data ) {
- return {
- clicked: 'masterbar_notifications_panel_site',
- site_id: data.siteId,
- };
- },
- openPost: function( data ) {
- return {
- clicked: 'masterbar_notifications_panel_post',
- site_id: data.siteId,
- post_id: data.postId,
- };
- },
- openComment: function( data ) {
- return {
- clicked: 'masterbar_notifications_panel_comment',
- site_id: data.siteId,
- post_id: data.postId,
- comment_id: data.commentId,
- };
- },
- };
-
- function parseJson( s, defaultValue ) {
- try {
- return JSON.parse( s );
- } catch ( e ) {
- return defaultValue;
- }
- }
-
- $( document ).ready( function() {
- var trackableLinks =
- '.mb-trackable .ab-item:not(div),' +
- '#wp-admin-bar-notes .ab-item,' +
- '#wp-admin-bar-user-info .ab-item,' +
- '.mb-trackable .ab-secondary';
-
- $( trackableLinks ).on( 'click touchstart', function( e ) {
- if ( ! window.jpTracksAJAX || 'function' !== typeof window.jpTracksAJAX.record_ajax_event ) {
- return;
- }
-
- var $target = $( e.target ),
- $parent = $target.closest( 'li' );
-
- if ( ! $target.is( 'a' ) ) {
- $target = $target.closest( 'a' );
- }
-
- if ( ! $parent || ! $target ) {
- return;
- }
-
- var trackingId = $target.attr( 'ID' ) || $parent.attr( 'ID' );
-
- if ( ! linksTracksEvents.hasOwnProperty( trackingId ) ) {
- return;
- }
- var eventProps = { clicked: linksTracksEvents[ trackingId ] };
-
- if ( $parent.hasClass( 'menupop' ) ) {
- window.jpTracksAJAX.record_ajax_event( eventName, 'click', eventProps );
- } else {
- e.preventDefault();
- window.jpTracksAJAX.record_ajax_event( eventName, 'click', eventProps ).always( function() {
- window.location = $target.attr( 'href' );
- } );
- }
- } );
- } );
-
- // listen for postMessage events from the notifications iframe
- $( window ).on( 'message', function( e ) {
- if ( ! window.jpTracksAJAX || 'function' !== typeof window.jpTracksAJAX.record_ajax_event ) {
- return;
- }
-
- var event = ! e.data && e.originalEvent.data ? e.originalEvent : e;
- if ( event.origin !== 'https://widgets.wp.com' ) {
- return;
- }
-
- var data = 'string' === typeof event.data ? parseJson( event.data, {} ) : event.data;
- if ( 'notesIframeMessage' !== data.type ) {
- return;
- }
-
- var eventData = notesTracksEvents[ data.action ];
- if ( ! eventData ) {
- return;
- }
-
- window.jpTracksAJAX.record_ajax_event( eventName, 'click', eventData( data ) );
- } );
-} )( jQuery );
diff --git a/plugins/jetpack/modules/masterbar/wp-posts-list/class-posts-list-page-notification.php b/plugins/jetpack/modules/masterbar/wp-posts-list/class-posts-list-page-notification.php
index b59ed2da..6149481e 100644
--- a/plugins/jetpack/modules/masterbar/wp-posts-list/class-posts-list-page-notification.php
+++ b/plugins/jetpack/modules/masterbar/wp-posts-list/class-posts-list-page-notification.php
@@ -67,7 +67,7 @@ class Posts_List_Page_Notification {
* @return Posts_List_Page_Notification
*/
public static function init() {
- if ( is_null( self::$instance ) ) {
+ if ( self::$instance === null ) {
self::$instance = new self( \get_option( 'page_for_posts' ), \get_option( 'show_on_front' ), \get_option( 'page_on_front' ) );
}
diff --git a/plugins/jetpack/modules/memberships/class-jetpack-memberships.php b/plugins/jetpack/modules/memberships/class-jetpack-memberships.php
index ae8a3d8a..e2752b6d 100644
--- a/plugins/jetpack/modules/memberships/class-jetpack-memberships.php
+++ b/plugins/jetpack/modules/memberships/class-jetpack-memberships.php
@@ -108,8 +108,8 @@ class Jetpack_Memberships {
if ( ! self::$instance ) {
self::$instance = new self();
self::$instance->register_init_hook();
- // Yes, `personal-bundle` with a dash, `jetpack_personal` with an underscore. Check the v1.5 endpoint to verify.
- self::$required_plan = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? 'personal-bundle' : 'jetpack_personal';
+ // Yes, `pro-plan` with a dash, `jetpack_personal` with an underscore. Check the v1.5 endpoint to verify.
+ self::$required_plan = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? 'pro-plan' : 'jetpack_personal';
}
return self::$instance;
@@ -312,7 +312,7 @@ class Jetpack_Memberships {
$content = str_replace( 'recurring-payments-id', $block_id, $content );
$content = str_replace( 'wp-block-jetpack-recurring-payments', 'wp-block-jetpack-recurring-payments wp-block-button', $content );
$subscribe_url = $this->get_subscription_url( $plan_id );
- return str_replace( 'href="#"', 'href="' . $subscribe_url . '"', $content );
+ return preg_replace( '/(href=".*")/', 'href="' . $subscribe_url . '"', $content );
}
return $this->deprecated_render_button_v1( $attributes, $plan_id );
@@ -446,14 +446,8 @@ class Jetpack_Memberships {
* Whether the site's plan supports the Recurring Payments block.
*/
public static function is_supported_jetpack_recurring_payments() {
- // For WPCOM sites.
- if ( defined( 'IS_WPCOM' ) && IS_WPCOM && function_exists( 'has_any_blog_stickers' ) ) {
- $site_id = get_current_blog_id();
- return has_any_blog_stickers( array( 'personal-plan', 'premium-plan', 'business-plan', 'ecommerce-plan' ), $site_id );
- }
- // For Jetpack sites.
return (
- Jetpack::is_connection_ready() &&
+ ( ( defined( 'IS_WPCOM' ) && IS_WPCOM ) || Jetpack::is_connection_ready() ) &&
Jetpack_Plan::supports( 'recurring-payments' )
);
}
diff --git a/plugins/jetpack/modules/minileven.php b/plugins/jetpack/modules/minileven.php
deleted file mode 100644
index 0a12d167..00000000
--- a/plugins/jetpack/modules/minileven.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-/**
- * Module Name: Mobile Theme
- * Module Description: Enable the Jetpack Mobile theme
- * Sort Order: 21
- * Recommendation Order: 11
- * First Introduced: 1.8
- * Requires Connection: No
- * Auto Activate: No
- * Module Tags: Appearance, Mobile, Recommended
- * Feature: Appearance
- * Additional Search Queries: mobile, theme, minileven
- */
-
-function jetpack_load_minileven() {
- include dirname( __FILE__ ) . "/minileven/minileven.php";
-
- if ( Jetpack_Options::get_option_and_ensure_autoload( 'wp_mobile_app_promos', '0' ) != '1' )
- remove_action( 'wp_mobile_theme_footer', 'jetpack_mobile_app_promo' );
-}
-
-add_action( 'jetpack_modules_loaded', 'minileven_loaded' );
-
-function minileven_loaded() {
- Jetpack::enable_module_configurable( __FILE__ );
-}
-
-function minileven_theme_root( $theme_root ) {
- if ( jetpack_check_mobile() ) {
- return dirname( __FILE__ ) . '/minileven/theme';
- }
-
- return $theme_root;
-}
-
-add_filter( 'theme_root', 'minileven_theme_root' );
-
-function minileven_theme_root_uri( $theme_root_uri ) {
- if ( jetpack_check_mobile() ) {
- return plugins_url( 'modules/minileven/theme', dirname( __FILE__ ) );
- }
-
- return $theme_root_uri;
-}
-
-add_filter( 'theme_root_uri', 'minileven_theme_root_uri' );
-
-function minileven_enabled( $wp_mobile_disable_option ) {
- return true;
-}
-
-if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
- add_filter( 'option_wp_mobile_disable', 'minileven_enabled' );
-}
-
-jetpack_load_minileven();
diff --git a/plugins/jetpack/modules/minileven/images/wp-app-devices.png b/plugins/jetpack/modules/minileven/images/wp-app-devices.png
deleted file mode 100644
index 2efefe20..00000000
--- a/plugins/jetpack/modules/minileven/images/wp-app-devices.png
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/minileven/minileven.php b/plugins/jetpack/modules/minileven/minileven.php
deleted file mode 100644
index d5402429..00000000
--- a/plugins/jetpack/modules/minileven/minileven.php
+++ /dev/null
@@ -1,360 +0,0 @@
-<?php
-
-// ********** modify blog option 'wp_mobile_template' manually to specify a theme (ex. 'vip/cnnmobile')
-
-// WordPress Mobile Edition
-//
-// Copyright (c) 2002-2008 Alex King
-// http://alexking.org/projects/wordpress
-//
-// Released under the GPL license
-// https://www.opensource.org/licenses/gpl-license.php
-//
-// **********************************************************************
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-// *****************************************************************
-
-/*
-Plugin Name: WordPress Mobile Edition
-Plugin URI: http://alexking.org/projects/wordpress
-Description: Show a mobile view of the post/page if the visitor is on a known mobile device. Questions on configuration, etc.? Make sure to read the README.
-Author: Alex King
-Author URI: http://alexking.org
-Version: 2.1a-WPCOM
-*/
-
-$_SERVER['REQUEST_URI'] = ( isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['SCRIPT_NAME'] . (( isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')));
-
-function jetpack_check_mobile() {
- // allow mobile theme to be disabled via query string for testing during deprecation.
- if ( isset( $_GET['jetpack-preview'] ) && 'responsivetheme' === $_GET['jetpack-preview'] )
- return false;
- if ( ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) || ( defined('APP_REQUEST') && APP_REQUEST ) )
- return false;
- if ( !isset($_SERVER["HTTP_USER_AGENT"]) || (isset($_COOKIE['akm_mobile']) && $_COOKIE['akm_mobile'] == 'false') )
- return false;
- if ( jetpack_mobile_exclude() )
- return false;
- if ( 1 == Jetpack_Options::get_option_and_ensure_autoload( 'wp_mobile_disable', '0' ) )
- return false;
- if ( isset($_COOKIE['akm_mobile']) && $_COOKIE['akm_mobile'] == 'true' )
- return true;
-
- $is_mobile = jetpack_is_mobile();
-
- /**
- * Filter the Mobile check results.
- *
- * @module minileven
- *
- * @since 1.8.0
- *
- * @param bool $is_mobile Is the reader on a mobile device.
- */
- return apply_filters( 'jetpack_check_mobile', $is_mobile );
-}
-
-function jetpack_mobile_exclude() {
- $exclude = false;
- $pages_to_exclude = array(
- 'wp-admin',
- 'wp-comments-post.php',
- 'wp-mail.php',
- 'wp-login.php',
- 'wp-activate.php',
- );
- foreach ( $pages_to_exclude as $exclude_page ) {
- if ( strstr( strtolower( $_SERVER['REQUEST_URI'] ), $exclude_page ) )
- $exclude = true;
- }
-
- if ( defined( 'DOING_AJAX' ) && true === DOING_AJAX )
- $exclude = false;
-
- if ( isset( $GLOBALS['wp_customize'] ) )
- return true;
-
- return $exclude;
-}
-
-function wp_mobile_get_main_template() {
- remove_action( 'option_template', 'jetpack_mobile_template' );
- $template = get_option( 'template' );
- add_action( 'option_template', 'jetpack_mobile_template' );
- return $template;
-}
-
-function wp_mobile_get_main_stylesheet() {
- remove_action( 'option_stylesheet', 'jetpack_mobile_stylesheet' );
- $stylesheet = get_option( 'stylesheet' );
- add_action( 'option_stylesheet', 'jetpack_mobile_stylesheet' );
- return $stylesheet;
-}
-
-function jetpack_mobile_stylesheet( $theme ) {
- /**
- * Filter Jetpack's Mobile stylesheet.
- *
- * @module minileven
- *
- * @since 1.8.0
- *
- * @param string $theme Theme.
- */
- return apply_filters( 'jetpack_mobile_stylesheet', 'pub/minileven', $theme );
-}
-
-function jetpack_mobile_template( $theme ) {
- /**
- * Filter Jetpack's Mobile template.
- *
- * @module minileven
- *
- * @since 1.8.0
- *
- * @param string $theme Theme.
- */
- return apply_filters( 'jetpack_mobile_template', 'pub/minileven', $theme );
-}
-
-function jetpack_mobile_available() {
- /*
- * Create HTML markup with a link to "View Mobile Site".
- * The link adds "ak_action=accept_mobile" to the current URL.
- */
- global $wp;
- $url_params = array(
- 'ak_action' => 'accept_mobile',
- );
- if ( is_array( $_GET ) && ! empty( $_GET ) ) {
- $url_params[] = $_GET;
- }
- $target_url = home_url( add_query_arg( $url_params, $wp->request ) );
- $anchor = '<a href="' . esc_url( $target_url ) . '">' . __( 'View Mobile Site', 'jetpack' ) . '</a>';
- echo '<div class="jetpack-mobile-link" style="text-align:center;margin:10px 0;">' . $anchor . '</div>';
-}
-
-function jetpack_mobile_request_handler() {
- global $wpdb;
- if (isset($_GET['ak_action'])) {
- $url = wp_parse_url( get_bloginfo( 'url' ) );
- $domain = $url['host'];
- if (!empty($url['path'])) {
- $path = $url['path'];
- }
- else {
- $path = '/';
- }
- $redirect = false;
- switch ($_GET['ak_action']) {
- case 'reject_mobile':
- setcookie(
- 'akm_mobile'
- , 'false'
- , time() + 300000
- , $path
- , $domain
- );
- $redirect = true;
-
- /**
- * In Jetpack's Mobile theme, fires after the user taps on the link to display a full version of the site.
- *
- * @module minileven
- *
- * @since 1.8.0
- */
- do_action( 'mobile_reject_mobile' );
- break;
- case 'force_mobile':
- case 'accept_mobile':
- setcookie(
- 'akm_mobile'
- , 'true'
- , time() + 300000
- , $path
- , $domain
- );
- $redirect = true;
-
- /**
- * In Jetpack's Mobile theme, fires after the user taps on the link to go back from full site to mobile site.
- *
- * @module minileven
- *
- * @since 1.8.0
- */
- do_action( 'mobile_force_mobile' );
- break;
- }
- if ($redirect) {
- if ( isset( $_GET['redirect_to'] ) && $_GET['redirect_to'] ) {
- $go = urldecode( $_GET['redirect_to'] );
- } else {
- $go = remove_query_arg( array( 'ak_action' ) );
- }
- wp_safe_redirect( $go );
- exit;
- }
- }
-}
-add_action('init', 'jetpack_mobile_request_handler');
-
-function jetpack_mobile_theme_setup() {
- if ( jetpack_check_mobile() ) {
- // Redirect to download page if user clicked mobile app promo link in mobile footer
- if ( isset( $_GET['app-download'] ) ) {
- /**
- * Fires before you're redirected to download page if you clicked the mobile app promo link in mobile footer
- *
- * @module minileven
- *
- * @since 1.8.0
- *
- * @param string $_GET['app-download'] app-download URL parameter.
- */
- do_action( 'mobile_app_promo_download', $_GET['app-download'] );
-
- switch ( $_GET['app-download'] ) {
- case 'android':
- header( 'Location: market://search?q=pname:org.wordpress.android' );
- exit;
- break;
- case 'ios':
- header( 'Location: https://itunes.apple.com/us/app/wordpress/id335703880?mt=8' );
- exit;
- break;
- case 'blackberry':
- header( 'Location: http://blackberry.wordpress.org/download/' );
- exit;
- break;
- }
- }
-
- add_action('stylesheet', 'jetpack_mobile_stylesheet');
- add_action('template', 'jetpack_mobile_template');
- add_action('option_template', 'jetpack_mobile_template');
- add_action('option_stylesheet', 'jetpack_mobile_stylesheet');
-
- if ( class_exists( 'Jetpack_Custom_CSS' ) && method_exists( 'Jetpack_Custom_CSS', 'disable' ) && ! get_option( 'wp_mobile_custom_css' ) )
- add_action( 'init', array( 'Jetpack_Custom_CSS', 'disable' ), 11 );
-
- /**
- * Fires after Jetpack's mobile theme has been setup.
- *
- * @module minileven
- *
- * @since 1.8.0
- */
- do_action( 'mobile_setup' );
- }
-}
-
-// Need a hook after plugins_loaded (since this code won't be loaded in Jetpack
-// until then) but after init (because it has its own init hooks to add).
-add_action( 'setup_theme', 'jetpack_mobile_theme_setup' );
-
-if (isset($_COOKIE['akm_mobile']) && $_COOKIE['akm_mobile'] == 'false') {
- add_action('wp_footer', 'jetpack_mobile_available');
-}
-
-function jetpack_mobile_app_promo() {
- ?>
- <script type="text/javascript">
- if ( ! navigator.userAgent.match( /wp-(iphone|android|blackberry|nokia|windowsphone)/i ) ) {
- if ( ( navigator.userAgent.match( /iphone/i ) ) || ( navigator.userAgent.match( /ipod/i ) ) )
- document.write( '<span id="wpcom-mobile-app-promo" style="margin-top: 10px; font-size: 13px;"><strong>Now Available!</strong> <a href="/index.php?app-download=ios">Download WordPress for iOS</a></span><br /><br />' );
- else if ( ( navigator.userAgent.match( /android/i ) ) && ( null == navigator.userAgent.match( /playbook/i ) && null == navigator.userAgent.match( /bb10/i ) ) )
- document.write( '<span id="wpcom-mobile-app-promo" style="margin-top: 10px; font-size: 13px;"><strong>Now Available!</strong> <a href="/index.php?app-download=android">Download WordPress for Android</a></span><br /><br />' );
- else if ( ( navigator.userAgent.match( /blackberry/i ) ) || ( navigator.userAgent.match( /playbook/i ) ) || ( navigator.userAgent.match( /bb10/i ) ) )
- document.write( '<span id="wpcom-mobile-app-promo" style="margin-top: 10px; font-size: 13px;"><strong>Now Available!</strong> <a href="/index.php?app-download=blackberry">Download WordPress for BlackBerry</a></span><br /><br />' );
- }
- </script>
- <?php
-}
-
-add_action( 'wp_mobile_theme_footer', 'jetpack_mobile_app_promo' );
-
-/**
- * Adds an option to allow your Custom CSS to also be applied to the Mobile Theme.
- * It's disabled by default, but this should allow people who know what they're
- * doing to customize the mobile theme.
- */
-function jetpack_mobile_css_settings() {
- $mobile_css = get_option( 'wp_mobile_custom_css' );
-
- ?>
- <div class="misc-pub-section">
- <label><?php esc_html_e( 'Mobile-compatible:', 'jetpack' ); ?></label>
- <span id="mobile-css-display"><?php echo $mobile_css ? __( 'Yes', 'jetpack' ) : __( 'No', 'jetpack' ); ?></span>
- <a class="edit-mobile-css hide-if-no-js" href="#mobile-css"><?php echo esc_html_e( 'Edit', 'jetpack' ); ?></a>
- <div id="mobile-css-select" class="hide-if-js">
- <input type="hidden" name="mobile_css" id="mobile-css" value="<?php echo intval( $mobile_css ); ?>" />
- <label>
- <input type="checkbox" id="mobile-css-visible" <?php checked( get_option( 'wp_mobile_custom_css' ) ); ?> />
- <?php esc_html_e( 'Include this CSS in the Mobile Theme', 'jetpack' ); ?>
- </label>
- <p>
- <a class="save-mobile-css hide-if-no-js button" href="#mobile-css"><?php esc_html_e( 'OK', 'jetpack' ); ?></a>
- <a class="cancel-mobile-css hide-if-no-js" href="#mobile-css"><?php esc_html_e( 'Cancel', 'jetpack' ); ?></a>
- </p>
- </div>
- </div>
- <script type="text/javascript">
- jQuery( function ( $ ) {
- $( '.edit-mobile-css' ).bind( 'click', function ( e ) {
- e.preventDefault();
-
- $( '#mobile-css-select' ).slideDown();
- $( this ).hide();
- } );
-
- $( '.cancel-mobile-css' ).bind( 'click', function ( e ) {
- e.preventDefault();
-
- $( '#mobile-css-select' ).slideUp( function () {
- $( '.edit-mobile-css' ).show();
-
- $( '#mobile-css-visible' ).prop( 'checked', $( '#mobile-css' ).val() == '1' );
- } );
- } );
-
- $( '.save-mobile-css' ).bind( 'click', function ( e ) {
- e.preventDefault();
-
- $( '#mobile-css-select' ).slideUp();
- $( '#mobile-css-display' ).text( $( '#mobile-css-visible' ).prop( 'checked' ) ? 'Yes' : 'No' );
- $( '#mobile-css' ).val( $( '#mobile-css-visible' ).prop( 'checked' ) ? '1' : '0' );
- $( '.edit-mobile-css' ).show();
- } );
- } );
- </script>
- <?php
-}
-
-add_action( 'custom_css_submitbox_misc_actions', 'jetpack_mobile_css_settings' );
-
-function jetpack_mobile_customizer_controls( $wp_customize ) {
- $wp_customize->add_setting( 'wp_mobile_custom_css' , array(
- 'default' => true,
- 'transport' => 'postMessage',
- 'type' => 'option'
- ) );
-
- $wp_customize->add_control( 'jetpack_mobile_css_control', array(
- 'type' => 'checkbox',
- 'label' => __( 'Include this CSS in the Mobile Theme', 'jetpack' ),
- 'section' => 'jetpack_custom_css',
- 'settings' => 'wp_mobile_custom_css',
- ) );
-}
-
-add_action( 'jetpack_custom_css_customizer_controls', 'jetpack_mobile_customizer_controls' );
-
-function jetpack_mobile_save_css_settings() {
- update_option( 'wp_mobile_custom_css', isset( $_POST['mobile_css'] ) && ! empty( $_POST['mobile_css'] ) );
-}
-
-add_action( 'safecss_save_pre', 'jetpack_mobile_save_css_settings' );
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/comments.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/comments.php
deleted file mode 100644
index 55c35161..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/comments.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-/**
- * The template for displaying Comments.
- *
- * The area of the page that contains both current comments
- * and the comment form. The actual display of comments is
- * handled by a callback to minileven_comment() which is
- * located in the functions.php file.
- *
- * @package Minileven
- */
-?>
- <div id="comments">
- <?php if ( post_password_required() ) : ?>
- <p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'jetpack' ); ?></p>
- </div><!-- #comments -->
- <?php
- /* Stop the rest of comments.php from being processed,
- * but don't kill the script entirely -- we still have
- * to fully load the template.
- */
- return;
- endif;
- ?>
-
- <?php // You can start editing here -- including this comment! ?>
-
- <?php comment_form(); ?>
-
- <?php if ( have_comments() ) : ?>
- <ol class="commentlist">
- <?php
- /* Loop through and list the comments. Tell wp_list_comments()
- * to use minileven_comment() to format the comments.
- * If you want to overload this in a child theme then you can
- * define minileven_comment() and that will be used instead.
- * See minileven_comment() in minileven/functions.php for more.
- */
- wp_list_comments( array( 'callback' => 'minileven_comment' ) );
- ?>
- </ol>
-
- <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
- <nav id="comment-nav-below">
- <h1 class="assistive-text"><?php _e( 'Comment navigation', 'jetpack' ); ?></h1>
- <div class="nav-previous"><?php previous_comments_link( __( '&larr; Older Comments', 'jetpack' ) ); ?></div>
- <div class="nav-next"><?php next_comments_link( __( 'Newer Comments &rarr;', 'jetpack' ) ); ?></div>
- </nav>
- <?php endif; // check for comment navigation
- endif; // check for the existence of comments
- ?>
- </div><!-- #comments --> \ No newline at end of file
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/content-gallery.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/content-gallery.php
deleted file mode 100644
index 218949ea..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/content-gallery.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-/**
- * The template for displaying posts in the Gallery Post Format on index and archive pages
- *
- * Learn more: http://codex.wordpress.org/Post_Formats
- *
- * @package Minileven
- */
-?>
-
-<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
- <header class="entry-header">
- <div class="entry-heading">
- <?php if ( '1' == get_option( 'wp_mobile_featured_images' ) && minileven_show_featured_images() ) : ?>
- <div class="entry-thumbnail">
- <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'jetpack' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="<?php the_ID(); ?>" class="minileven-featured-thumbnail"><?php the_post_thumbnail(); ?></a>
- </div><!-- .entry-thumbnail -->
- <?php endif; ?>
- <h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
- <h3 class="entry-format"><?php _e( 'Gallery', 'jetpack' ); ?></h3>
- </div>
- </header><!-- .entry-header -->
-
- <div class="entry-content">
- <?php if ( is_single() || post_password_required() ) : ?>
- <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'jetpack' ) ); ?>
-
- <?php else : ?>
- <?php
- $images = minileven_get_gallery_images();
- if ( $images ) :
- $total_images = count( $images );
- $large_image = array_shift( $images );
- $thumb1_image = array_shift( $images );
- $thumb2_image = array_shift( $images );
- $thumb3_image = array_shift( $images );
-
- $image_img_tag = wp_get_attachment_image( (int) $large_image, 'large' );
- $thumb1_img_tag = wp_get_attachment_image( (int) $thumb1_image, 'thumbnail' );
- $thumb2_img_tag = wp_get_attachment_image( (int) $thumb2_image, 'thumbnail' );
- $thumb3_img_tag = wp_get_attachment_image( (int) $thumb3_image, 'thumbnail' );
- ?>
- <div class="img-gallery">
- <div class="gallery-large">
- <a href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
- </div><!-- .gallery-large -->
- <?php if ( 3 == $total_images ) : ?>
- <div class="gallery-thumbs-2">
- <a href="<?php the_permalink(); ?>" class="gallery-thumb-1"><?php echo $thumb1_img_tag; ?></a>
- <a href="<?php the_permalink(); ?>" class="gallery-thumb-2"><?php echo $thumb2_img_tag; ?></a>
- </div><!-- .gallery-thumbs -->
-
- <?php elseif ( 4 <= $total_images ) : ?>
- <div class="gallery-thumbs-3">
- <a href="<?php the_permalink(); ?>" class="gallery-thumb-1"><?php echo $thumb1_img_tag; ?></a>
- <a href="<?php the_permalink(); ?>" class="gallery-thumb-2"><?php echo $thumb2_img_tag; ?></a>
- <a href="<?php the_permalink(); ?>" class="gallery-thumb-3"><?php echo $thumb3_img_tag; ?></a>
- </div><!-- .gallery-thumbs -->
- </div><!-- .img-gallery -->
- <?php endif; ?>
-
- <p class="gallery-info"><em><?php printf( _n( 'This gallery contains <a %1$s>%2$s photo</a>.', 'This gallery contains <a %1$s>%2$s photos</a>.', $total_images, 'jetpack' ),
- 'href="' . esc_url( get_permalink() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to %s', 'jetpack' ), the_title_attribute( 'echo=0' ) ) ) . '" rel="bookmark"',
- number_format_i18n( $total_images ) );
- ?></em></p>
-
- <?php endif; ?>
- <?php endif; ?>
-
- <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'jetpack' ) . '</span>', 'after' => '</div>' ) ); ?>
-</div><!-- .entry-content -->
-
- <footer class="entry-meta">
- <?php minileven_posted_on(); ?>
- <?php if ( comments_open() ) : ?>
- <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a Reply', 'jetpack' ) . '</span>', __( '<b>1</b> Reply', 'jetpack' ), __( '<b>%</b> Replies', 'jetpack' ) ); ?></span>
- <?php endif; // End if comments_open() ?>
-
- <?php edit_post_link( __( 'Edit', 'jetpack' ), '<span class="edit-link">', '</span>' ); ?>
- </footer><!-- #entry-meta -->
-</article><!-- #post-<?php the_ID(); ?> -->
-
-<?php comments_template( '', true ); ?>
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/content.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/content.php
deleted file mode 100644
index e434ea41..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/content.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-/**
- * The default template for displaying content
- *
- * @package Minileven
- */
-?>
-
- <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
- <header class="entry-header">
- <?php if ( '1' == get_option( 'wp_mobile_featured_images' ) && minileven_show_featured_images() ) : ?>
- <div class="entry-thumbnail">
- <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'jetpack' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="<?php the_ID(); ?>" class="minileven-featured-thumbnail"><?php the_post_thumbnail(); ?></a>
- </div><!-- .entry-thumbnail -->
- <?php endif; ?>
- <?php if ( is_sticky() ) : ?>
- <div class="entry-heading">
- <h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
- <h3 class="entry-format"><?php _e( 'Featured', 'jetpack' ); ?></h3>
- <div>
- <?php else : ?>
- <h1 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
- <?php endif; ?>
-
- <div class="entry-meta">
- <?php if ( is_singular() && is_multi_author() ) : ?>
- <span class="author-link">
- <?php _e( 'Posted by ', 'jetpack' ); ?>
- <?php the_author_posts_link(); ?>
- </span><!-- .author-link -->
- <?php endif; ?>
- </div><!-- .entry-meta -->
- </header><!-- .entry-header -->
-
- <div class="entry-content">
- <?php if ( '1' == get_option( 'wp_mobile_excerpt' ) && ( is_home() || is_search() || is_archive() ) ) : ?>
- <?php echo minileven_excerpt( 300 ); ?>
- <?php else : ?>
- <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'jetpack' ) ); ?>
- <?php endif; ?>
- <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'jetpack' ) . '</span>', 'after' => '</div>' ) ); ?>
- </div><!-- .entry-content -->
-
- <footer class="entry-meta">
- <?php if ( 'post' == get_post_type() ) : ?>
- <?php minileven_posted_on(); ?>
- <?php endif; ?>
- <?php if ( comments_open() ) : ?>
- <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'jetpack' ) . '</span>', __( '<b>1</b> Reply', 'jetpack' ), __( '<b>%</b> Replies', 'jetpack' ) ); ?></span>
- <?php endif; // End if comments_open() ?>
- <?php edit_post_link( __( 'Edit', 'jetpack' ), '<span class="edit-link">', '</span>' ); ?>
- </footer><!-- #entry-meta -->
- </article><!-- #post-<?php the_ID(); ?> -->
-
- <?php if ( is_single() ) : ?>
- <nav id="nav-single">
- <h3 class="assistive-text"><?php _e( 'Post navigation', 'jetpack' ); ?></h3>
- <span class="nav-previous"><?php previous_post_link( '%link', __( '&laquo; Previous', 'jetpack' ) ); ?></span>
- <span class="nav-next"><?php next_post_link( '%link', __( 'Next &raquo;', 'jetpack' ) ); ?></span>
- </nav><!-- #nav-single -->
- <?php endif; ?>
-
- <?php comments_template( '', true ); ?>
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/footer.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/footer.php
deleted file mode 100644
index bab105bf..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/footer.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-/**
- * The template for displaying the footer.
- *
- * Contains the closing of the id=main div and all content after
- *
- * @package Minileven
- */
-?>
-
- </div><!-- #main -->
-</div><!-- #page -->
-<?php get_sidebar(); ?>
-
-</div><!-- #wrapper -->
-
-<?php
- /**
- * Fires before the Mobile Theme's <footer> tag.
- *
- * @module minileven
- *
- * @since 3.7.0
- */
- do_action( 'jetpack_mobile_footer_before' );
-?>
-
-<footer id="colophon" role="contentinfo">
- <div id="site-generator">
-
- <?php
- /*
- * Construct "$target_url", which adds "ak_action=reject_mobile"
- * to the current URL.
- */
- global $wp;
- $url_params = array(
- 'ak_action' => 'reject_mobile',
- );
- if ( is_array( $_GET ) && ! empty( $_GET ) ) {
- $url_params[] = $_GET;
- }
- $target_url = home_url( add_query_arg( $url_params, $wp->request ) );
- ?>
-
- <a href="<?php echo esc_url( $target_url ); ?>"><?php _e( 'View Full Site', 'jetpack' ); ?></a>
- <br />
-
- <?php
- /**
- * Fires after the View Full Site link in the Mobile Theme's footer.
- *
- * By default, a promo to download the native apps is added to this action.
- *
- * @module minileven
- *
- * @since 1.8.0
- */
- do_action( 'wp_mobile_theme_footer' );
-
- /**
- * Fires before the credit links in the Mobile Theme's footer.
- *
- * @module minilven
- *
- * @since 1.8.0
- */
- do_action( 'minileven_credits' );
- ?>
-
- <a href="<?php echo esc_url( __( 'https://wordpress.org/', 'jetpack' ) ); ?>" rel="noopener noreferrer" target="_blank" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'jetpack' ); ?>" rel="generator"><?php printf( __( 'Proudly powered by %s', 'jetpack' ), 'WordPress' ); ?></a>
- </div>
-</footer><!-- #colophon -->
-
-<?php wp_footer(); ?>
-
-</body>
-</html>
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/functions.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/functions.php
deleted file mode 100644
index cd702872..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/functions.php
+++ /dev/null
@@ -1,275 +0,0 @@
-<?php
-
-use Automattic\Jetpack\Assets;
-
-/**
- * Minileven functions and definitions
- *
- * Sets up the theme and provides some helper functions. Some helper functions
- * are used in the theme as custom template tags. Others are attached to action and
- * filter hooks in WordPress to change core functionality.
- *
- * The first function, minileven_setup(), sets up the theme by registering support
- * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
- *
- * @package Minileven
- */
-
-/**
- * Set the content width based on the theme's design and stylesheet.
- */
-if ( ! isset( $content_width ) )
- $content_width = 584;
-
-/**
- * Tell WordPress to run minileven_setup() when the 'after_setup_theme' hook is run.
- */
-add_action( 'after_setup_theme', 'minileven_setup' );
-
-if ( ! function_exists( 'minileven_setup' ) ):
-/**
- * Sets up theme defaults and registers support for various WordPress features.
- */
-function minileven_setup() {
- global $wp_version;
-
- /**
- * Custom template tags for this theme.
- */
- require( get_template_directory() . '/inc/template-tags.php' );
-
- /**
- * Custom functions that act independently of the theme templates
- */
- require( get_template_directory() . '/inc/tweaks.php' );
-
- /**
- * Implement the Custom Header functions
- */
- require( get_template_directory() . '/inc/custom-header.php' );
-
- /* Make Minileven available for translation.
- * Translations can be added to the /languages/ directory.
- * If you're building a theme based on Minileven, use a find and replace
- * to change 'minileven' to the name of your theme in all the template files.
- */
-/* Don't load a minileven textdomain, as it uses the Jetpack textdomain.
- load_theme_textdomain( 'minileven', get_template_directory() . '/languages' );
-*/
-
- // Add default posts and comments RSS feed links to <head>.
- add_theme_support( 'automatic-feed-links' );
-
- // This theme uses wp_nav_menu() in one location.
- register_nav_menu( 'primary', __( 'Primary Menu', 'jetpack' ) );
-
- // Add support for a variety of post formats
- add_theme_support( 'post-formats', array( 'gallery' ) );
-
- // Add support for custom backgrounds
- add_theme_support( 'custom-background' );
-
- // Add support for post thumbnails
- add_theme_support( 'post-thumbnails' );
-}
-endif; // minileven_setup
-
-/**
- * Enqueue scripts and styles
- */
-function minileven_scripts() {
- global $post;
-
- wp_enqueue_style( 'style', get_stylesheet_uri() );
- wp_enqueue_script(
- 'small-menu',
- Assets::get_file_url_for_environment(
- '_inc/build/minileven/theme/pub/minileven/js/small-menu.min.js',
- 'modules/minileven/theme/pub/minileven/js/small-menu.js'
- ),
- array( 'jquery' ),
- '20120206',
- true
- );
-
- if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
- wp_enqueue_script( 'comment-reply' );
- }
-}
-add_action( 'wp_enqueue_scripts', 'minileven_scripts' );
-
-function minileven_fonts() {
-
- /* translators: If there are characters in your language that are not supported
- by Open Sans, translate this to 'off'. Do not translate into your own language. */
-
- if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'jetpack' ) ) {
-
- $opensans_subsets = 'latin,latin-ext';
-
- /* translators: To add an additional Open Sans character subset specific to your language, translate
- this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. */
- $opensans_subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'jetpack' );
-
- if ( 'cyrillic' == $opensans_subset )
- $opensans_subsets .= ',cyrillic,cyrillic-ext';
- elseif ( 'greek' == $opensans_subset )
- $opensans_subsets .= ',greek,greek-ext';
- elseif ( 'vietnamese' == $opensans_subset )
- $opensans_subsets .= ',vietnamese';
-
- $opensans_query_args = array(
- 'family' => 'Open+Sans:200,200italic,300,300italic,400,400italic,600,600italic,700,700italic',
- 'subset' => $opensans_subsets,
- );
- wp_register_style( 'minileven-open-sans', add_query_arg( $opensans_query_args, "//fonts.googleapis.com/css" ), array(), null );
- }
-}
-add_action( 'init', 'minileven_fonts' );
-
-/**
- * Register our sidebars and widgetized areas.
- * @since Minileven 1.0
- */
-function minileven_widgets_init() {
- register_sidebar( array(
- 'name' => __( 'Main Sidebar', 'jetpack' ),
- 'id' => 'sidebar-1',
- 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
- 'after_widget' => "</aside>",
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
-}
-add_action( 'widgets_init', 'minileven_widgets_init' );
-
-function minileven_posts_per_page() {
- return 5;
-}
-add_filter('pre_option_posts_per_page', 'minileven_posts_per_page');
-
-/**
- * Determine the currently active theme.
- */
-function minileven_actual_current_theme() {
- $removed = remove_action( 'option_stylesheet', 'jetpack_mobile_stylesheet' );
- $stylesheet = get_option( 'stylesheet' );
- if ( $removed )
- add_action( 'option_stylesheet', 'jetpack_mobile_stylesheet' );
-
- return $stylesheet;
-}
-
-/* This function grabs the location of the custom menus from the current theme. If no menu is set in a location
-* it will return a boolean "false". This function helps Minileven know which custom menu to display. */
-function minileven_get_menu_location() {
- $theme_slug = minileven_actual_current_theme();
- $mods = get_option( "theme_mods_{$theme_slug}" );
-
- if ( has_filter( 'jetpack_mobile_theme_menu' ) ) {
-
- /**
- * Filter the menu displayed in the Mobile Theme.
- *
- * @module minileven
- *
- * @since 3.4.0
- *
- * @param int $menu_id ID of the menu to display.
- */
- return array( 'primary' => apply_filters( 'jetpack_mobile_theme_menu', $menu_id ) );
- }
-
- if ( isset( $mods['nav_menu_locations'] ) && ! empty( $mods['nav_menu_locations'] ) )
- return $mods['nav_menu_locations'];
-
- return false;
-}
-
-/* This function grabs the custom background image from the user's current theme so that Minileven can display it. */
-function minileven_get_background() {
- $theme_slug = minileven_actual_current_theme();
- $mods = get_option( "theme_mods_$theme_slug" );
-
- if ( ! empty( $mods ) ) {
- return array(
- 'color' => isset( $mods['background_color'] ) ? $mods['background_color'] : null,
- 'image' => isset( $mods['background_image'] ) ? $mods['background_image'] : null,
- 'repeat' => isset( $mods['background_repeat'] ) ? $mods['background_repeat'] : null,
- 'position' => isset( $mods['background_position_x'] ) ? $mods['background_position_x'] : null,
- 'attachment' => isset( $mods['attachment'] ) ? $mods['attachment'] : null,
- );
- }
- return false;
-}
-
-/**
- * If the user has set a static front page, show all posts on the front page, instead of a static page.
- */
-if ( '1' == get_option( 'wp_mobile_static_front_page' ) )
- add_filter( 'pre_option_page_on_front', '__return_zero' );
-
-/**
- * Retrieves the IDs for images in a gallery.
- *
- * @uses get_post_galleries() first, if available. Falls back to shortcode parsing,
- * then as last option uses a get_posts() call.
- *
- * @return array List of image IDs from the post gallery.
- */
-function minileven_get_gallery_images() {
- $images = array();
-
- if ( function_exists( 'get_post_galleries' ) ) {
- $galleries = get_post_galleries( get_the_ID(), false );
- if ( isset( $galleries[0]['ids'] ) )
- $images = explode( ',', $galleries[0]['ids'] );
- } else {
- $pattern = get_shortcode_regex();
- preg_match( "/$pattern/s", get_the_content(), $match );
- $atts = shortcode_parse_atts( $match[3] );
- if ( isset( $atts['ids'] ) )
- $images = explode( ',', $atts['ids'] );
- }
-
- if ( ! $images ) {
- $images = get_posts( array(
- 'fields' => 'ids',
- 'numberposts' => 999,
- 'order' => 'ASC',
- 'orderby' => 'menu_order',
- 'post_mime_type' => 'image',
- 'post_parent' => get_the_ID(),
- 'post_type' => 'attachment',
- 'suppress_filters' => false,
- ) );
- }
-
- return $images;
-}
-
-/**
- * Allow plugins to filter where Featured Images are displayed.
- * Default has Featured Images disabled on single view and pages.
- *
- * @uses is_search()
- * @uses apply_filters()
- * @return bool
- */
-function minileven_show_featured_images() {
- $enabled = ( is_home() || is_search() || is_archive() ) ? true : false;
-
- /**
- * Filter where featured images are displayed in the Mobile Theme.
- *
- * By setting $enabled to true or false using functions like is_home() or
- * is_archive(), you can control where featured images are be displayed.
- *
- * @module minileven
- *
- * @since 3.2.0
- *
- * @param bool $enabled True if featured images should be displayed, false if not.
- */
- return (bool) apply_filters( 'minileven_show_featured_images', $enabled );
-}
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/header.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/header.php
deleted file mode 100644
index 2488a47f..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/header.php
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
- * The Header for our theme.
- *
- * Displays all of the <head> section and everything up till <div id="main">
- *
- * @package Minileven
- */
-?><!DOCTYPE html>
-<html <?php language_attributes(); ?>>
-<head>
-<meta charset="<?php bloginfo( 'charset' ); ?>" />
-<meta name="viewport" content="width=device-width" />
-<title><?php wp_title( '|', true, 'right' ); ?></title>
-<link rel="profile" href="http://gmpg.org/xfn/11" />
-<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
-<?php wp_head(); ?>
-</head>
-
-<body <?php body_class(); ?>>
-<div id="wrapper">
- <?php
- $location = minileven_get_menu_location(); // get the menu locations from the current theme in use
- ?>
- <div class="menu-search">
- <nav id="access" class="site-navigation main-navigation" role="navigation">
- <h3 class="menu-toggle"><?php _e( 'Menu', 'jetpack' ); ?></h3>
-
- <?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff. */ ?>
- <div class="skip-link"><a class="assistive-text" href="#content"><?php _e( 'Skip to primary content', 'jetpack' ); ?></a></div>
- <?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */
- if ( false !== $location ) :
- $location_values = array_values( $location );
- $menu_id = array_shift( $location_values ); // acccess the ID of the menu assigned to that location. Using only the first menu ID returned in the array.
- wp_nav_menu( array( 'theme_location' => 'primary', 'container_class' => '', 'menu_class' => 'nav-menu', 'menu' => $menu_id ) );
- else: // if the $location variable is false, wp_page_menu() is shown instead.
- wp_nav_menu( array( 'theme_location' => 'primary', 'container_class' => '', 'menu_class' => 'nav-menu' ) );
- endif;
- ?>
- </nav><!-- #access -->
- <div class="search-form">
- <?php get_search_form(); ?>
- </div><!-- .search-form-->
- </div><!-- .menu-search-->
-
- <?php
- /**
- * Fires before Minileven header.
- *
- * @module minileven
- *
- * @since 3.4.0
- */
- do_action( 'jetpack_mobile_header_before' );
-
- if ( function_exists( 'minileven_header' ) )
- minileven_header();
-
- /**
- * Fires after Minileven header.
- *
- * @module minilven
- *
- * @since 3.4.0
- */
- do_action( 'jetpack_mobile_header_after' );
- ?>
-
- <div id="page" class="hfeed">
- <div id="main">
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/image.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/image.php
deleted file mode 100644
index 02032c2c..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/image.php
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-/**
- * The template for displaying image attachments.
- *
- * @package Minileven
- */
-
-get_header(); ?>
-
- <div id="primary" class="image-attachment">
- <div id="content" role="main">
-
- <?php while ( have_posts() ) : the_post(); ?>
-
- <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
- <header class="entry-header">
- <h1 class="entry-title"><?php the_title(); ?></h1>
- </header><!-- .entry-header -->
-
- <div class="entry-content">
-
- <div class="entry-attachment">
- <div class="attachment">
-<?php
- /**
- * Grab the IDs of all the image attachments in a gallery so we can get the URL of the next adjacent image in a gallery,
- * or the first image (if we're looking at the last image in a gallery), or, in a gallery of one, just the link to that image file
- */
- $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID', 'suppress_filters' => false ) ) );
- foreach ( $attachments as $k => $attachment ) {
- if ( $attachment->ID == $post->ID )
- break;
- }
- $k++;
- // If there is more than 1 attachment in a gallery
- if ( count( $attachments ) > 1 ) {
- if ( isset( $attachments[ $k ] ) )
- // get the URL of the next image attachment
- $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
- else
- // or get the URL of the first image attachment
- $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
- } else {
- // or, if there's only 1 image, get the URL of the image
- $next_attachment_url = wp_get_attachment_url();
- }
-?>
- <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
-
- /**
- * Filter the Mobile Theme image size.
- *
- * @module minileven
- *
- * @since 1.8.0
- *
- * @param int Image size in pixels.
- */
- $attachment_size = apply_filters( 'minileven_attachment_size', 848 );
- echo wp_get_attachment_image( $post->ID, array( $attachment_size, 1024 ) ); // filterable image width with 1024px limit for image height.
- ?></a>
-
- <?php if ( ! empty( $post->post_excerpt ) ) : ?>
- <div class="entry-caption">
- <?php the_excerpt(); ?>
- </div>
- <?php endif; ?>
- </div><!-- .attachment -->
-
- </div><!-- .entry-attachment -->
-
- <div class="entry-description">
- <?php the_content(); ?>
- <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'jetpack' ) . '</span>', 'after' => '</div>' ) ); ?>
- </div><!-- .entry-description -->
-
- </div><!-- .entry-content -->
-
- <footer class="entry-meta">
- <div class="attachment-meta">
- <?php
- $metadata = wp_get_attachment_metadata();
- printf( __( '<span class="entry-gallery">&laquo; <a href="%1$s" title="Back to %2$s" rel="gallery">Back to Gallery</a></span>', 'jetpack' ),
- esc_url( get_permalink( $post->post_parent ) ),
- get_the_title( $post->post_parent )
- );
- ?>
- </div><!-- .attachment-meta-->
- <?php if ( comments_open() ) : ?>
- <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'jetpack' ) . '</span>', __( '<b>1</b> Reply', 'jetpack' ), __( '<b>%</b> Replies', 'jetpack' ) ); ?></span>
- <?php endif; // End if comments_open() ?>
- <?php edit_post_link( __( 'Edit', 'jetpack' ), '<span class="edit-link">', '</span>' ); ?>
- </footer><!-- #entry-meta -->
- </article><!-- #post-<?php the_ID(); ?> -->
-
- <nav id="nav-single">
- <h3 class="assistive-text"><?php _ex( 'Image navigation', 'next-saturday' , 'jetpack' ); ?></h3>
- <span class="nav-previous"><?php previous_image_link( false, __( '&laquo; Previous' , 'jetpack' ) ); ?></span>
- <span class="nav-next"><?php next_image_link( false, __( 'Next &raquo; ' , 'jetpack' ) ); ?></span>
- </nav><!-- #nav-single -->
-
- <?php comments_template(); ?>
-
- <?php endwhile; // end of the loop. ?>
-
- </div><!-- #content -->
- </div><!-- #primary -->
-<?php get_footer(); ?>
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/custom-header.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/custom-header.php
deleted file mode 100644
index dc8758b7..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/custom-header.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-/**
- * @package Minileven
- * @since Minileven 2.0
- */
-
-/* This function grabs the custom header from the current theme so that Minileven can display it. */
-function minileven_get_header_image() {
- $theme_slug = minileven_actual_current_theme();
- $mods = get_option( "theme_mods_{$theme_slug}" );
-
- if ( isset( $mods['header_image'] ) && 'remove-header' != $mods['header_image'] && 'random-default-image' != $mods['header_image'] && 'random-uploaded-image' != $mods['header_image'] )
- return $mods['header_image'];
-
- return false;
-}
-
-/* This function determines whether or not the user is displaying the header on the current theme */
-function minileven_header_text_display() {
- $theme_slug = minileven_actual_current_theme();
- $mods = get_option( "theme_mods_{$theme_slug}" );
-
- if ( isset( $mods['header_textcolor'] ) )
- return $mods['header_textcolor'];
-
- return false;
-}
-
-/* This function determines how the header should be displayed. */
-function minileven_header() {
- $header_image = minileven_get_header_image();
- $header_text = minileven_header_text_display();
-
- if ( 'blank' != $header_text || false != $header_image ) : ?>
-
- <header id="branding" role="banner">
- <?php if ( 'blank' != $header_text ) : ?>
- <div class="site-branding">
- <h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h1>
- <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
- </div>
- <?php endif;
-
- if ( false !== $header_image ) : ?>
- <div id="header-img">
- <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
- <img src="<?php echo $header_image; ?>" alt="" />
- </a>
- </div><!-- #header-img -->
- <?php endif; // end check for header image existence. ?>
- </header><!-- #branding -->
-<?php endif; // end check for both header text and header image
-}
-
-/* This function displays the custom background image or color, and custom text color */
-function minileven_show_background_and_header_color() {
- $background = minileven_get_background();
- $header_text = minileven_header_text_display();
-
- $style = '';
-
- if ( $background['color'] || $background['image'] ) :
- $style = $background['color'] ? "background-color: #$background[color];" : '';
-
- if ( $background['image'] ) :
- $image = " background-image: url('$background[image]');";
-
- if ( ! in_array( $background['repeat'], array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) )
- $background['repeat'] = 'repeat';
- $repeat = " background-repeat: $background[repeat];";
-
- if ( ! in_array( $background['position'], array( 'center', 'right', 'left' ) ) )
- $background['position'] = 'left';
- $position = " background-position: top $background[position];";
-
- if ( ! in_array( $background['attachment'], array( 'fixed', 'scroll' ) ) )
- $background['attachment'] = 'scroll';
- $attachment = " background-attachment: $background[attachment];";
-
- $style .= $image . $repeat . $position . $attachment;
- endif;
- endif;
-?>
- <style type="text/css">
- <?php if ( $style ) { ?>
- body {
- <?php echo trim( $style ); ?>
- }
- <?php } ?>
- #page,
- #branding {
- margin: 0.6em 0.6em 0.8em;
- }
- #site-generator {
- border: 0;
- }
- <?php if ( 'blank' != $header_text && '1' != get_option( 'wp_mobile_header_color' ) ) : ?>
- /* If The user has set a header text color, use that */
- #site-title,
- #site-title a {
- color: #<?php echo $header_text; ?>;
- <?php endif; ?>
- }
- </style>
-<?php
-}
-add_action( 'wp_head', 'minileven_show_background_and_header_color' ); \ No newline at end of file
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.eot b/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.eot
deleted file mode 100644
index 5a60506a..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.eot
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.svg b/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.svg
deleted file mode 100644
index 3dce209e..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.svg
+++ /dev/null
@@ -1,81 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
-<svg xmlns="http://www.w3.org/2000/svg">
-<metadata></metadata>
-<defs>
-<font id="genericonsregular" horiz-adv-x="2048" >
-<font-face units-per-em="2048" ascent="1638" descent="-410" />
-<missing-glyph horiz-adv-x="500" />
-<glyph unicode="&#x2000;" horiz-adv-x="1024" />
-<glyph unicode="&#x2001;" />
-<glyph unicode="&#x2002;" horiz-adv-x="1024" />
-<glyph unicode="&#x2003;" />
-<glyph unicode="&#x2004;" horiz-adv-x="682" />
-<glyph unicode="&#x2005;" horiz-adv-x="512" />
-<glyph unicode="&#x2006;" horiz-adv-x="341" />
-<glyph unicode="&#x2007;" horiz-adv-x="341" />
-<glyph unicode="&#x2008;" horiz-adv-x="256" />
-<glyph unicode="&#x2009;" horiz-adv-x="409" />
-<glyph unicode="&#x200a;" horiz-adv-x="113" />
-<glyph unicode="&#x202f;" horiz-adv-x="409" />
-<glyph unicode="&#x205f;" horiz-adv-x="512" />
-<glyph unicode="&#xe000;" horiz-adv-x="500" d="M0 0z" />
-<glyph unicode="&#xf100;" d="M512 512v128h768v-128h-768zM512 768v128h256v-128h-256zM512 1024v128h640v-128h-640zM512 1280v128h1024v-128h-1024zM896 768v128h640v-128h-640zM1280 1024v128h256v-128h-256z" />
-<glyph unicode="&#xf101;" d="M256 1024q0 209 103 385.5t279.5 279.5t385.5 103t385.5 -103t279.5 -279.5t103 -385.5t-103 -385.5t-279.5 -279.5t-385.5 -103t-385.5 103t-279.5 279.5t-103 385.5zM768 1024q0 -106 75 -181t181 -75t181 75t75 181t-75 181t-181 75t-181 -75t-75 -181z" />
-<glyph unicode="&#xf102;" d="M128 384v896l512 128l128 256h512l128 -256h512v-1024h-1792zM256 1440v160h256v-96zM576 960q0 -185 131.5 -316.5t316.5 -131.5q186 0 317 131.5t131 316.5t-131 316.5t-317 131.5q-185 0 -316.5 -131.5t-131.5 -316.5zM704 960q0 133 93.5 226.5t226.5 93.5 t226.5 -93.5t93.5 -226.5t-93.5 -226.5t-226.5 -93.5t-226.5 93.5t-93.5 226.5z" />
-<glyph unicode="&#xf103;" d="M128 512v384h384v-384h-384zM128 1024v384h896v-384h-896zM640 512v384h384v-384h-384zM1152 512v896h896v-896h-896z" />
-<glyph unicode="&#xf104;" d="M512 384v1280l1152 -640z" />
-<glyph unicode="&#xf105;" d="M640 1408q0 159 112.5 271.5t271.5 112.5t271.5 -112.5t112.5 -271.5q0 -124 -71.5 -222t-184.5 -138v-536l-256 -128v664q-113 40 -184.5 138t-71.5 222z" />
-<glyph unicode="&#xf106;" d="M384 640l128 768h512l-256 -768h-384zM1152 640l128 768h512l-256 -768h-384z" />
-<glyph unicode="&#xf107;" d="M376 852q0 108 72 204l160 128l96 -96l-160 -128q-48 -96 0 -192l96 -96q96 -48 192 0l128 160l96 -96l-128 -160q-96 -72 -204 -72t-180 72l-96 96q-72 72 -72 180zM736 960l352 352l96 -96l-352 -352zM864 1440l128 160q96 72 204 72t180 -72l96 -96q72 -72 72 -180 t-72 -204l-160 -128l-96 96l160 128q48 96 0 192l-96 96q-96 48 -192 0l-128 -160z" />
-<glyph unicode="&#xf108;" d="M0 1152v384q0 96 80 176t176 80h1024q96 0 176 -80t80 -176v-384q0 -96 -80 -176t-176 -80h-448l-448 -448v448h-128q-96 0 -176 80t-80 176zM768 640l128 128h384q168 0 276 108t108 276v384q96 0 176 -80t80 -176v-384q0 -96 -80 -176t-176 -80h-128v-448l-448 448 h-320z" />
-<glyph unicode="&#xf109;" d="M256 768v512h384l384 384v-1280l-384 384h-384zM1216 832q21 43 32 66.5t21.5 59.5t10.5 66t-10.5 66t-21.5 59.5t-32 66.5l96 96q96 -144 96 -288q0 -160 -96 -256zM1376 672q74 74 117 166t43 186t-43 186t-117 166l96 96q95 -71 143.5 -186.5t48.5 -261.5 t-48.5 -261.5t-143.5 -186.5z" />
-<glyph unicode="&#xf200;" d="M0 1024q0 212 79.5 402t216 326.5t326.5 216t402 79.5t402 -79.5t326.5 -216t216 -326.5t79.5 -402t-79.5 -402t-216 -326.5t-326.5 -216t-402 -79.5t-402 79.5t-326.5 216t-216 326.5t-79.5 402zM128 1024q0 -307 173.5 -536.5t466.5 -327.5v224q0 224 128 224 q-125 0 -213.5 16t-146.5 47t-91.5 83t-47 115.5t-13.5 154.5q0 100 25 187t71 133q-28 71 -28 143t14 109l14 36q7 0 18 -1t44 -7.5t63 -18.5t67 -38.5t64 -62.5q144 24 300 24t276 -24q27 36 60 62.5t60.5 38.5t51.5 18.5t38 7.5l14 1q4 -5 10 -14.5t19 -40.5t20 -63 t4 -78.5t-21 -91.5q96 -144 96 -320q0 -113 -21 -187.5t-75 -128t-147.5 -77t-236.5 -23.5q49 -25 72.5 -77.5t23.5 -146.5v-224q293 98 466.5 327.5t173.5 536.5q0 176 -73 341.5t-194.5 287t-287 194.5t-341.5 73t-341.5 -73t-287 -194.5t-194.5 -287t-73 -341.5z" />
-<glyph unicode="&#xf201;" d="M0 1024q0 206 82 395.5t219.5 327t327 219.5t395.5 82t395.5 -82t327 -219.5t219.5 -327t82 -395.5t-82 -395.5t-219.5 -327t-327 -219.5t-395.5 -82t-395.5 82t-327 219.5t-219.5 327t-82 395.5zM128 1024q0 -167 58 -319.5t166 -272.5q125 205 339 360t445 232 q-16 48 -80 176q-282 -86 -481.5 -111t-446.5 -1v-64zM160 1232q194 -22 444 14t388 82q-141 282 -320 528q-194 -85 -329.5 -247.5t-182.5 -376.5zM480 320q216 -192 544 -192q181 0 368 80q-33 300 -208 688q-222 -74 -410 -225.5t-294 -350.5zM832 1904 q102 -166 304 -512q6 2 86 31t118.5 45t108 47t122 64t93.5 69q-126 126 -290.5 199t-349.5 73q-32 0 -96 -8t-96 -8zM1200 1248q22 -29 36.5 -54.5t34 -67.5t25.5 -54q170 33 336 30t288 -30q-26 285 -160 464q-71 -57 -162 -104.5t-214.5 -100.5t-183.5 -83zM1344 928 q14 -27 43 -103t74.5 -231t74.5 -306q156 108 258 278t126 362q-276 46 -576 0z" />
-<glyph unicode="&#xf202;" d="M0 381q50 -6 100 -6q293 0 522 180q-137 2 -244.5 83t-147.5 208q44 -7 79 -7q57 0 110 15q-145 29 -241 144.5t-96 267.5v5q86 -48 191 -53q-86 58 -136.5 150t-50.5 200q0 113 57 211q158 -194 383 -310t483 -129q-11 49 -11 96q0 174 123 297t297 123q89 0 168.5 -35 t138.5 -97q142 27 266 102q-47 -150 -184 -233q124 15 241 66q-84 -127 -210 -217q2 -36 2 -55q0 -168 -49 -337t-150 -323.5t-241 -273.5t-336 -190t-420 -71q-351 0 -644 189z" />
-<glyph unicode="&#xf203;" d="M0 117q0 -48 34.5 -82.5t82.5 -34.5h1814q48 0 82.5 34.5t34.5 82.5v1814q0 48 -34.5 82.5t-82.5 34.5h-1814q-48 0 -82.5 -34.5t-34.5 -82.5v-1814zM900 969v303h222v258q0 78 26 147t77 124t136.5 87t194.5 32q55 0 108 -3t79 -6l26 -3l-7 -282h-193q-76 0 -101.5 -32 t-25.5 -101v-3v-2v-9v-207h329l-14 -303h-315v-841h-320v841h-222z" />
-<glyph unicode="&#xf204;" d="M640 969v303h222v258q0 78 26 147t77 124t136.5 87t194.5 32q55 0 108 -3t79 -6l26 -3l-7 -282h-193q-76 0 -101.5 -32t-25.5 -101v-3v-2v-9v-207h329l-14 -303h-315v-841h-320v841h-222z" />
-<glyph unicode="&#xf205;" d="M0 1024q0 208 81 397.5t218.5 327t327 218.5t397.5 81t398 -81t327 -218.5t218 -327t81 -397.5q0 -209 -81 -398.5t-218 -326.5t-326.5 -218t-398.5 -81q-208 0 -397.5 81t-327 218t-218.5 327t-81 398zM128 1024q0 -259 135.5 -473.5t359.5 -327.5l-421 1156 q-74 -168 -74 -355zM285 1530q4 0 13.5 -0.5t15.5 -0.5q70 0 127.5 2.5t80.5 4.5l22 3q29 2 46.5 -16t19.5 -40.5t-13 -43t-44 -24.5q-27 -4 -70 -8l295 -877l198 591l-104 283l-90 11q-38 2 -51.5 34t4.5 62t56 28q54 -10 201 -10q70 0 127.5 2.5t80.5 4.5l22 3 q38 2 56.5 -27t5 -60.5t-51.5 -36.5q-27 -4 -69 -8l293 -870l90 301q69 177 69 293q0 51 -14 107q-18 45 -40 81q-2 3 -15 24t-15.5 25t-13 22t-13 24.5t-10 22t-10 24.5t-6.5 22t-5 25t-1 24q0 63 42 110.5t106 49.5q-121 108 -274.5 168t-321.5 60q-226 0 -421 -105 t-318 -285zM772 165q123 -37 252 -37q152 0 296 51q0 1 -1 1l-1 2l-278 763zM1485 256q199 120 317 324t118 444q0 216 -99 409q4 -44 4 -68q0 -153 -69 -324z" />
-<glyph unicode="&#xf206;" d="M128 486v485q125 -127 330 -127q30 0 59 3q-32 -61 -32 -118q0 -33 13 -63t28.5 -48.5t45.5 -47.5q-18 0 -54.5 -0.5t-55.5 -0.5q-183 0 -334 -83zM128 1599v97q0 93 65.5 158.5t158.5 65.5h1344q93 0 158.5 -65.5t65.5 -158.5v-224h-280v280h-140v-280h-280v-140h280 v-280h140v280h280v-980q0 -93 -65.5 -158.5t-158.5 -65.5h-539q5 28 5 50q0 143 -46.5 230t-189.5 194q-3 2 -20.5 15t-25 19t-25.5 20t-27.5 22.5t-24 22t-23 23.5t-17 22t-12.5 22.5t-4 20.5q0 52 23 87t99 94q180 141 180 324q0 113 -45 204.5t-128 139.5h160l135 142 h-607q-127 0 -241.5 -49t-194.5 -132zM134 301q56 89 166.5 143.5t241.5 53.5q84 -1 158 -26q19 -13 62 -42.5t61 -42t48 -37t44.5 -41.5t29 -41.5t21.5 -49.5q7 -29 7 -66q0 -16 -1 -24h-620q-79 0 -140 49t-78 124zM228 1307q-21 161 50.5 269.5t194.5 104.5 q121 -4 215.5 -118.5t116.5 -277.5q21 -160 -43 -256t-187 -92q-125 4 -225.5 108t-121.5 262z" />
-<glyph unicode="&#xf207;" d="M384 1422q0 -58 40.5 -97.5t105.5 -39.5h1q67 0 108.5 39.5t41.5 97.5q-2 60 -42 98.5t-106 38.5q-67 0 -108 -39t-41 -98zM400 384h263v793h-263v-793zM809 384h264v443q0 45 8 64q16 40 50.5 68t85.5 28q133 0 133 -179v-424h264v455q0 175 -83.5 266t-220.5 91 q-50 0 -90.5 -12t-68.5 -34t-45 -41t-33 -44v112h-264v-793z" />
-<glyph unicode="&#xf208;" d="M128 384v1280q0 106 75 181t181 75h1280q106 0 181 -75t75 -181v-1280q0 -106 -75 -181t-181 -75h-1280q-106 0 -181 75t-75 181zM384 1422q0 -58 40.5 -97.5t105.5 -39.5h1q67 0 108.5 39.5t41.5 97.5q-2 60 -42 98.5t-106 38.5q-67 0 -108 -39t-41 -98zM400 384h263 v793h-263v-793zM809 384h264v443q0 45 8 64q16 40 50.5 68t85.5 28q133 0 133 -179v-424h264v455q0 175 -83.5 266t-220.5 91q-50 0 -90.5 -12t-68.5 -34t-45 -41t-33 -44v112h-264v-793z" />
-<glyph unicode="&#xf209;" d="M171 1260q0 109 35.5 219t110 213t179 182t254 126.5t323.5 47.5q176 0 327.5 -60.5t253.5 -161t160 -231t58 -270.5q0 -246 -85 -443t-241 -309.5t-355 -112.5q-99 0 -186.5 46.5t-121.5 110.5q-73 -290 -89 -347q-34 -123 -127 -270l-149 54q-7 167 22 290l162 688 q-40 81 -40 200q0 139 70.5 232.5t172.5 93.5q83 0 127 -53.5t44 -135.5q0 -51 -18.5 -124t-49 -170t-44.5 -154q-23 -99 37.5 -171t161.5 -72q117 0 209.5 92t142 244.5t49.5 334.5q0 214 -139 349t-387 135q-139 0 -257.5 -49.5t-197 -133t-122.5 -193t-44 -229.5 q0 -147 83 -247q18 -21 21.5 -34t-3.5 -37q-16 -61 -25 -101q-7 -24 -24.5 -32t-39.5 1q-127 51 -192.5 181.5t-65.5 300.5z" />
-<glyph unicode="&#xf210;" d="M0 1024q0 208 81 398t218.5 327t327 218t397.5 81q209 0 398.5 -81t326.5 -218t218 -326.5t81 -398.5t-81 -398.5t-218 -326.5t-326.5 -218t-398.5 -81q-147 0 -290 42q74 116 103 219l72 282q28 -53 99 -90.5t151 -37.5q162 0 288.5 91.5t195.5 251t69 359.5 q0 114 -47 220t-130 187.5t-206.5 130.5t-265.5 49q-141 0 -262 -38.5t-205.5 -103t-145.5 -147.5t-89.5 -172.5t-28.5 -178.5q0 -138 53 -243.5t156 -147.5q18 -8 32.5 -1t18.5 26q2 9 10 41t11 41q5 19 2.5 30t-16.5 28q-68 78 -68 200q0 97 35.5 186t99.5 156.5t160 108 t209 40.5q201 0 313.5 -109.5t112.5 -283.5q0 -148 -40 -271.5t-115 -198t-169 -74.5q-82 0 -131.5 58.5t-30.5 138.5q11 46 35.5 125t39.5 138t15 101q0 66 -35.5 109.5t-102.5 43.5q-82 0 -139.5 -76t-57.5 -189q0 -43 8 -83.5t16 -59.5l9 -19q-113 -475 -132 -558 q-24 -97 -18 -235q-275 120 -444 374t-169 564z" />
-<glyph unicode="&#xf211;" d="M160 1024q0 -172 122 -294t294 -122t294 122t122 294t-122 294t-294 122t-294 -122t-122 -294zM1056 1024q0 -172 122 -294t294 -122t294 122t122 294t-122 294t-294 122t-294 -122t-122 -294z" />
-<glyph unicode="&#xf300;" d="M256 896v384q0 106 75 181t181 75h1024q106 0 181 -75t75 -181v-384q0 -106 -75 -181t-181 -75h-448l-448 -448v448h-128q-106 0 -181 75t-75 181z" />
-<glyph unicode="&#xf301;" d="M384 512v1024h384l64 -128h448v-128h-640l-128 -256h128l64 128h960l-256 -640h-1024z" />
-<glyph unicode="&#xf302;" d="M256 768l768 768h512v-512l-768 -768zM1152 1280q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5t37.5 90.5t-37.5 90.5t-90.5 37.5t-90.5 -37.5t-37.5 -90.5z" />
-<glyph unicode="&#xf303;" d="M256 1088q0 143 55.5 273.5t150 225t225 150t273.5 55.5t273.5 -55.5t225 -150t150 -225t55.5 -273.5t-55.5 -273.5t-150 -225t-225 -150t-273.5 -55.5t-273.5 55.5t-225 150t-150 225t-55.5 273.5zM384 1088q0 -117 45.5 -223.5t123 -184t184 -123t223.5 -45.5 t223.5 45.5t184 123t123 184t45.5 223.5t-45.5 223.5t-123 184t-184 123t-223.5 45.5t-223.5 -45.5t-184 -123t-123 -184t-45.5 -223.5zM896 1062v474h128v-421l298 -298l-90 -91z" />
-<glyph unicode="&#xf304;" d="M512 384v256q0 159 112.5 271.5t271.5 112.5h256q159 0 271.5 -112.5t112.5 -271.5v-256h-1024zM768 1408q0 106 75 181t181 75t181 -75t75 -181t-75 -181t-181 -75t-181 75t-75 181z" />
-<glyph unicode="&#xf305;" d="M256 384v1280h256v128h128v-128h640v128h128v-128h256v-1280h-1408zM384 640q0 -53 37.5 -90.5t90.5 -37.5h896q53 0 90.5 37.5t37.5 90.5v640q0 53 -37.5 90.5t-90.5 37.5h-896q-53 0 -90.5 -37.5t-37.5 -90.5v-640zM768 1216q0 26 19 45t45 19h128q26 0 45 -19t19 -45 v-512q0 -26 -19 -45t-45 -19t-45 19t-19 45v448h-64q-26 0 -45 19t-19 45z" />
-<glyph unicode="&#xf306;" d="M256 384v1280h256v128h128v-128h640v128h128v-128h256v-1280h-1408zM384 640q0 -53 37.5 -90.5t90.5 -37.5h896q53 0 90.5 37.5t37.5 90.5v640q0 53 -37.5 90.5t-90.5 37.5h-896q-53 0 -90.5 -37.5t-37.5 -90.5v-640zM768 1216q0 26 19 45t45 19h256h2h1h3 q22 -2 38.5 -18t19.5 -39v-2v-2v-1v-2q0 -5 -2 -15l-128 -512q-6 -26 -28.5 -40t-48.5 -7q-26 6 -40 28.5t-7 48.5l108 433h-174q-26 0 -45 19t-19 45z" />
-<glyph unicode="&#xf307;" d="M256 384v1280h256v128h128v-128h640v128h128v-128h256v-1280h-1408zM384 640q0 -53 37.5 -90.5t90.5 -37.5h896q53 0 90.5 37.5t37.5 90.5v640q0 53 -37.5 90.5t-90.5 37.5h-896q-53 0 -90.5 -37.5t-37.5 -90.5v-640zM512 640v128h128v-128h-128zM512 896v128h128v-128 h-128zM768 640v128h128v-128h-128zM768 896v128h128v-128h-128zM768 1152v128h128v-128h-128zM1024 640v128h128v-128h-128zM1024 896v128h128v-128h-128zM1024 1152v128h128v-128h-128zM1280 896v128h128v-128h-128zM1280 1152v128h128v-128h-128z" />
-<glyph unicode="&#xf400;" d="M256 1216q0 117 45.5 223.5t123 184t184 123t223.5 45.5t223.5 -45.5t184 -123t123 -184t45.5 -223.5q0 -184 -111 -337l495 -495l-128 -128l-495 495q-153 -111 -337 -111q-117 0 -223.5 45.5t-184 123t-123 184t-45.5 223.5zM384 1216q0 -185 131.5 -316.5 t316.5 -131.5q186 0 317 131.5t131 316.5t-131 316.5t-317 131.5q-185 0 -316.5 -131.5t-131.5 -316.5z" />
-<glyph unicode="&#xf401;" d="M256 1216q0 117 45.5 223.5t123 184t184 123t223.5 45.5t223.5 -45.5t184 -123t123 -184t45.5 -223.5q0 -184 -111 -337l495 -495l-128 -128l-495 495q-153 -111 -337 -111q-117 0 -223.5 45.5t-184 123t-123 184t-45.5 223.5zM384 1216q0 -185 131.5 -316.5 t316.5 -131.5q186 0 317 131.5t131 316.5t-131 316.5t-317 131.5q-185 0 -316.5 -131.5t-131.5 -316.5zM512 1152v128h640v-128h-640z" />
-<glyph unicode="&#xf402;" d="M256 1216q0 117 45.5 223.5t123 184t184 123t223.5 45.5t223.5 -45.5t184 -123t123 -184t45.5 -223.5q0 -184 -111 -337l495 -495l-128 -128l-495 495q-153 -111 -337 -111q-117 0 -223.5 45.5t-184 123t-123 184t-45.5 223.5zM384 1216q0 -185 131.5 -316.5 t316.5 -131.5q186 0 317 131.5t131 316.5t-131 316.5t-317 131.5q-185 0 -316.5 -131.5t-131.5 -316.5zM512 1152v128h256v256h128v-256h256v-128h-256v-256h-128v256h-256z" />
-<glyph unicode="&#xf403;" d="M0 1024l506 506q101 103 234.5 160.5t283.5 57.5t283.5 -57.5t233.5 -159.5l507 -507l-506 -507q-101 -103 -234.5 -160t-283.5 -57t-283.5 57.5t-233.5 160.5zM272 1024l370 -371q77 -78 175.5 -119.5t206.5 -41.5t206 41.5t174 118.5l373 372l-371 371 q-158 161 -382 161q-108 0 -206.5 -41t-173.5 -119zM640 1024q0 159 112.5 271.5t271.5 112.5t271.5 -112.5t112.5 -271.5t-112.5 -271.5t-271.5 -112.5t-271.5 112.5t-112.5 271.5zM1024 1152q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5t37.5 90.5t-37.5 90.5t-90.5 37.5 t-90.5 -37.5t-37.5 -90.5z" />
-<glyph unicode="&#xf404;" d="M0 1024l506 506q101 103 234.5 160.5t283.5 57.5q193 0 358 -95l-143 -143q-103 46 -215 46q-108 0 -206.5 -41t-173.5 -119l-372 -372l240 -240l-136 -136zM339 429l90 -90l1280 1280l-90 90zM640 1024q0 159 112.5 271.5t271.5 112.5q44 0 98 -14l-468 -468 q-14 54 -14 98zM666 395l143 143q103 -46 215 -46q108 0 206 41.5t174 118.5l373 372l-241 241l136 135l376 -376l-506 -507q-101 -103 -234.5 -160t-283.5 -57q-193 0 -358 95zM926 654l468 468q14 -54 14 -98q0 -159 -112.5 -271.5t-271.5 -112.5q-44 0 -98 14z" />
-<glyph unicode="&#xf405;" d="M640 768l320 320l-320 320l128 128l320 -320l320 320l128 -128l-320 -320l320 -320l-128 -128l-320 320l-320 -320z" />
-<glyph unicode="&#xf406;" d="M128 256l832 832l-832 832l128 128l832 -832l832 832l128 -128l-832 -832l832 -832l-128 -128l-832 832l-832 -832z" />
-<glyph unicode="&#xf407;" d="M384 1280q0 106 75 181t181 75h140q20 56 69.5 92t110.5 36q62 0 111 -35.5t69 -92.5h140q106 0 181 -75t75 -181h-128v-768q0 -53 -37.5 -90.5t-90.5 -37.5h-640q-53 0 -90.5 37.5t-37.5 90.5v768h-128zM640 576q0 -26 19 -45t45 -19t45 19t19 45v640q0 26 -19 45 t-45 19t-45 -19t-19 -45v-640zM896 576q0 -26 19 -45t45 -19t45 19t19 45v640q0 26 -19 45t-45 19t-45 -19t-19 -45v-640zM1152 576q0 -26 19 -45t45 -19t45 19t19 45v640q0 26 -19 45t-45 19t-45 -19t-19 -45v-640z" />
-<glyph unicode="&#xf408;" d="M256 1151l476 -330l-183 -535l475 332l475 -332l-183 535l476 329h-587l-181 535l-180 -534h-588z" />
-<glyph unicode="&#xf409;" d="M384 1024l640 640l640 -640l-128 -128l-512 512l-512 -512zM640 512v384l384 384l384 -384v-384h-256v384h-256v-384h-256z" />
-<glyph unicode="&#xf410;" d="M0 384l640 640l384 -384l384 384l640 -640h-2048zM0 512v1152l576 -576zM0 1792h2048l-1024 -1024zM1472 1088l576 576v-1152z" />
-<glyph unicode="&#xf411;" d="M384 384v448l896 896l448 -448l-896 -896h-448zM512 768l256 -256l128 128l-256 256zM685 941l96 -96l595 595l-96 96zM845 781l96 -96l595 595l-96 96z" />
-<glyph unicode="&#xf412;" d="M256 640v704l384 384v-704h640v448l640 -640l-640 -640v448h-1024z" />
-<glyph unicode="&#xf413;" d="M128 384q0 106 75 181t181 75t181 -75t75 -181t-75 -181t-181 -75t-181 75t-75 181zM128 971v345q240 0 459 -94t377.5 -253.5t252.5 -379.5t94 -461h-345q0 170 -63.5 324t-181.5 273q-119 119 -272 182.5t-321 63.5zM129 1582v345q243 0 475 -64.5t428.5 -181 t362 -282.5t281 -363.5t180 -430.5t64.5 -477h-345q0 197 -52 385.5t-145.5 348t-227 294t-292 228t-346 146t-383.5 52.5z" />
-<glyph unicode="&#xf414;" d="M21 230q-57 102 31 244l760 1237q57 93 134.5 126.5t155 0t135.5 -126.5l759 -1237q88 -142 31 -244t-224 -102h-1557q-168 0 -225 102zM896 512q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5t37.5 90.5t-37.5 90.5t-90.5 37.5t-90.5 -37.5t-37.5 -90.5zM896 896 q0 -53 37.5 -90.5t90.5 -37.5t90.5 37.5t37.5 90.5v384q0 53 -37.5 90.5t-90.5 37.5t-90.5 -37.5t-37.5 -90.5v-384z" />
-<glyph unicode="&#xf415;" d="M128 1024h400q45 0 79.5 27.5t44.5 69.5q33 125 136.5 206t235.5 81q154 0 270 -114q38 -38 90.5 -38t90.5 38q37 38 37 91t-37 90q-88 89 -204.5 139t-246.5 50q-194 0 -353 -106t-234 -278h-309v-256zM536 663q0 -53 37 -90q89 -89 205 -139t246 -50q194 0 353 106 t234 278h309v256h-400q-45 0 -79.5 -27.5t-44.5 -69.5q-33 -125 -136.5 -206t-235.5 -81q-156 0 -269 115q-38 37 -91 37t-91 -38q-37 -38 -37 -91zM768 1024q0 -106 75 -181t181 -75t181 75t75 181t-75 181t-181 75t-181 -75t-75 -181z" />
-<glyph unicode="&#xf416;" d="M512 832v320h128v-320q0 -133 93.5 -226.5t226.5 -93.5t226.5 93.5t93.5 226.5v640q0 80 -56 136t-136 56t-136 -56t-56 -136v-512q0 -26 19 -45t45 -19t45 19t19 45v452h128v-452q0 -80 -56 -136t-136 -56t-136 56t-56 136v512q0 133 93.5 226.5t226.5 93.5t226.5 -93.5 t93.5 -226.5v-640q0 -185 -131.5 -316.5t-316.5 -131.5t-316.5 131.5t-131.5 316.5z" />
-<glyph unicode="&#xf417;" d="M384 1216q0 117 45.5 223.5t123 184t184 123t223.5 45.5t223.5 -45.5t184 -123t123 -184t45.5 -223.5t-44.5 -222.5t-124.5 -185.5l-407 -406l-407 406q-80 80 -124.5 185.5t-44.5 222.5zM640 1216q0 -133 93.5 -226.5t226.5 -93.5t226.5 93.5t93.5 226.5t-93.5 226.5 t-226.5 93.5t-226.5 -93.5t-93.5 -226.5z" />
-<glyph unicode="&#xf418;" d="M608 1056l128 128l224 -192l448 512l128 -96l-512 -768h-128z" />
-<glyph unicode="&#xf419;" d="M0 256v256h2048v-256h-2048zM0 896v256h2048v-256h-2048zM0 1536v256h2048v-256h-2048z" />
-<glyph unicode="&#xf420;" d="M384 512l640 640l640 -640h-1280zM384 1280v128h1280v-128h-1280z" />
-<glyph unicode="&#xf421;" d="M384 896v256h1152v-256h-1152z" />
-<glyph unicode="&#xf422;" d="M384 512v1024h1152v-1024h-1152zM512 640h896v640h-896v-640z" />
-<glyph unicode="&#xf500;" d="M128 0l960 960l960 -960h-1920z" />
-<glyph unicode="&#xf501;" d="M0 128l960 960l-960 960v-1920z" />
-<glyph unicode="&#xf502;" d="M128 2048l960 -960l960 960h-1920z" />
-<glyph unicode="&#xf503;" d="M1088 1088l960 960v-1920z" />
-</font>
-</defs></svg> \ No newline at end of file
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.ttf b/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.ttf
deleted file mode 100644
index 45228d9e..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.ttf
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.woff b/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.woff
deleted file mode 100644
index a64be4b1..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/fonts/genericons-regular-webfont.woff
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/template-tags.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/template-tags.php
deleted file mode 100644
index 6a398391..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/template-tags.php
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-/**
- * Custom template tags for this theme.
- *
- * Eventually, some of the functionality here could be replaced by core features
- *
- * @package Minileven
- * @since Minileven 2.0
- */
-
-/**
- * Display navigation to next/previous pages when applicable
- */
-function minileven_content_nav( $nav_id ) {
- global $wp_query;
-
- if ( $wp_query->max_num_pages > 1 ) : ?>
- <nav id="<?php echo $nav_id; ?>">
- <h3 class="assistive-text"><?php _e( 'Post navigation', 'jetpack' ); ?></h3>
- <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&laquo;</span> Older', 'jetpack' ) ); ?></div>
- <div class="nav-next"><?php previous_posts_link( __( 'Newer <span class="meta-nav">&raquo;</span>', 'jetpack' ) ); ?></div>
- </nav><!-- #nav-above -->
- <?php endif;
-}
-
-/**
- * Template for comments and pingbacks.
- * Used as a callback by wp_list_comments() for displaying the comments.
- * @since Minileven 1.0
- */
-function minileven_comment( $comment, $args, $depth ) {
- $GLOBALS['comment'] = $comment;
- switch ( $comment->comment_type ) :
- case 'pingback' :
- case 'trackback' :
- ?>
- <li class="post pingback">
- <p><?php _e( 'Pingback:', 'jetpack' ); ?> <?php comment_author_link(); ?></p>
- <?php
- break;
- default :
- ?>
- <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
- <article id="comment-<?php comment_ID(); ?>" class="comment">
- <footer class="comment-meta">
- <div class="comment-author vcard">
- <?php
- $avatar_size = 32;
- if ( '0' != $comment->comment_parent )
- $avatar_size = 24;
-
- echo get_avatar( $comment, $avatar_size );
-
- /* translators: 1: comment author, 2: date and time */
- printf( __( '%1$s on %2$s', 'jetpack' ),
- sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
- sprintf( '<a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a>',
- esc_url( get_comment_link( $comment->comment_ID ) ),
- get_comment_time( 'c' ),
- /* translators: 1: date, 2: time */
- sprintf( __( '%1$s at %2$s', 'jetpack' ), get_comment_date(), get_comment_time() )
- )
- );
- ?>
- </div><!-- .comment-author .vcard -->
-
- <?php if ( $comment->comment_approved == '0' ) : ?>
- <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'jetpack' ); ?></em>
- <br />
- <?php endif; ?>
-
- </footer>
-
- <div class="comment-content"><?php comment_text(); ?></div>
- <div class="reply">
- <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'jetpack' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
- </div><!-- .reply -->
- </article><!-- #comment-## -->
-
- <?php
- break;
- endswitch;
-}
-
-/**
- * Prints HTML with meta information for the current post-date/time and author.
- * @since Minileven 1.0
- */
-function minileven_posted_on() {
- printf( __( '<span class="entry-date"><a href="%1$s" title="%2$s" rel="bookmark"><time datetime="%3$s" pubdate>%4$s</time></a></span>', 'jetpack' ),
- esc_url( get_permalink() ),
- esc_attr( get_the_time() ),
- esc_attr( get_the_date( 'c' ) ),
- esc_html( get_the_date() )
- );
-} \ No newline at end of file
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/tweaks.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/tweaks.php
deleted file mode 100644
index a0c664f5..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/inc/tweaks.php
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/**
- * Custom functions that act independently of the theme templates
- *
- * Eventually, some of the functionality here could be replaced by core features
- *
- * @package Minileven
- * @since Minileven 2.0
- */
-
-/**
-* Sets the post excerpt length based on number of characters, without breaking words at the end
-*
-*/
-function minileven_excerpt( $count ) {
- $excerpt = get_the_content();
- $excerpt = strip_tags( $excerpt );
- $excerpt = strip_shortcodes( $excerpt );
- $excerpt = substr( $excerpt, 0, $count );
- $excerpt = substr( $excerpt, 0, strripos( $excerpt, " " ) );
- $excerpt = $excerpt . minileven_continue_reading_link();
- return $excerpt;
-}
-/**
-
-/**
- * Returns a "Continue Reading" link for excerpts
- */
-function minileven_continue_reading_link() {
- return ' &hellip; <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'jetpack' ) . '</a>';
-}
-
-/**
- * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and minileven_continue_reading_link().
- */
-function minileven_auto_excerpt_more( $more ) {
- return ' &hellip;' . minileven_continue_reading_link();
-}
-add_filter( 'excerpt_more', 'minileven_auto_excerpt_more' );
-
-/**
- * Adds a pretty "Continue Reading" link to custom post excerpts.
- *
- * To override this link in a child theme, remove the filter and add your own
- * function tied to the get_the_excerpt filter hook.
- */
-function minileven_custom_excerpt_more( $output ) {
- if ( has_excerpt() && ! is_attachment() ) {
- $output .= minileven_continue_reading_link();
- }
- return $output;
-}
-add_filter( 'get_the_excerpt', 'minileven_custom_excerpt_more' );
-
-/**
- * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
- */
-function minileven_page_menu_args( $args ) {
- $args['show_home'] = true;
- return $args;
-}
-add_filter( 'wp_page_menu_args', 'minileven_page_menu_args' );
-
-/**
- * Adds a custom class to the array of body classes, to allow Minileven to be targeted with Custom CSS.
- */
-function minileven_body_classes( $classes ) {
- $classes[] = 'mobile-theme';
- return $classes;
-}
-add_filter( 'body_class', 'minileven_body_classes' );
-
-/**
- * Filters wp_title to print a neat <title> tag based on what is being viewed.
- *
- * @since Minileven 2.0
- */
-function minileven_wp_title( $title, $sep ) {
- global $page, $paged;
-
- if ( is_feed() )
- return $title;
-
- // Add the blog name
- $title .= get_bloginfo( 'name' );
-
- // Add the blog description for the home/front page.
- $site_description = get_bloginfo( 'description', 'display' );
- if ( $site_description && ( is_home() || is_front_page() ) )
- $title .= " $sep $site_description";
-
- // Add a page number if necessary:
- if ( $paged >= 2 || $page >= 2 )
- $title .= " $sep " . sprintf( __( 'Page %s', 'jetpack' ), max( $paged, $page ) );
-
- return $title;
-}
-add_filter( 'wp_title', 'minileven_wp_title', 10, 2 );
-
-/**
- * Add theme support for Responsive Videos.
- */
-add_theme_support( 'jetpack-responsive-videos' ); \ No newline at end of file
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/index.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/index.php
deleted file mode 100644
index 14a1afdc..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/index.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-/**
- * The main template file.
- *
- * This is the most generic template file in a WordPress theme
- * and one of the two required files for a theme (the other being style.css).
- * It is used to display a page when nothing more specific matches a query.
- * E.g., it puts together the home page when no home.php file exists.
- * Learn more: https://codex.wordpress.org/Template_Hierarchy
- *
- * @package Minileven
- */
-
-get_header(); ?>
-
- <div id="primary">
- <div id="content" role="main">
-
- <?php if ( is_archive() ) : ?>
- <header class="page-header">
- <h1 class="page-title">
- <?php if ( is_day() ) : ?>
- <?php printf( __( 'Daily Archives: %s', 'jetpack' ), '<span>' . get_the_date() . '</span>' ); ?>
- <?php elseif ( is_month() ) : ?>
- <?php printf( __( 'Monthly Archives: %s', 'jetpack' ), '<span>' . get_the_date( 'F Y' ) . '</span>' ); ?>
- <?php elseif ( is_year() ) : ?>
- <?php printf( __( 'Yearly Archives: %s', 'jetpack' ), '<span>' . get_the_date( 'Y' ) . '</span>' ); ?>
- <?php elseif ( is_category() ) : ?>
- <?php printf( __( 'Posted in %s', 'jetpack' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?>
- <?php elseif ( is_tag() ) : ?>
- <?php printf( __( 'Tagged with %s', 'jetpack' ), '<span>' . single_tag_title( '', false ) . '</span>' ); ?>
- <?php elseif( is_author() ) : ?>
- <?php printf( __( 'Posted by %s', 'jetpack' ), '<span>' . get_the_author() . '</span>' ); ?>
- <?php else : ?>
- <?php _e( 'Blog Archives', 'jetpack' ); ?>
- <?php endif; ?>
- </h1>
- </header>
- <?php endif; ?>
-
- <?php if ( is_search() ) : ?>
- <header class="page-header">
- <h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'jetpack' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
- </header>
- <?php endif; ?>
-
- <?php if ( have_posts() ) : // Start the loop ?>
- <?php while ( have_posts() ) : the_post(); ?>
-
- <?php get_template_part( 'content', get_post_format() ); ?>
-
- <?php endwhile; ?>
-
- <?php else : ?>
- <article id="post-0" class="post error404 not-found">
- <header class="entry-header">
- <h1 class="entry-title"><?php _e( 'Nothing Found', 'jetpack' ); ?></h1>
- </header><!-- .entry-header -->
-
- <div class="entry-content">
- <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'jetpack' ); ?></p>
- <?php get_search_form(); ?>
- </div><!-- .entry-content -->
- </article><!-- #post-0 -->
-
- <?php endif; ?>
-
- </div><!-- #content -->
-
- <?php minileven_content_nav( 'nav-below' ); ?>
-
- </div><!-- #primary -->
-
-<?php get_sidebar(); ?>
-<?php get_footer(); ?>
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/js/small-menu.js b/plugins/jetpack/modules/minileven/theme/pub/minileven/js/small-menu.js
deleted file mode 100644
index ee3c7a4d..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/js/small-menu.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * navigation.js
- *
- * Handles toggling the navigation menu for small screens.
- */
-( function() {
- var nav = document.getElementById( 'access' ),
- button,
- menu;
- if ( ! nav ) {
- return;
- }
- button = nav.getElementsByTagName( 'h3' )[ 0 ];
- menu = nav.getElementsByTagName( 'ul' )[ 0 ];
- if ( ! button ) {
- return;
- }
-
- // Hide button if menu is missing or empty.
- if ( ! menu || ! menu.childNodes.length ) {
- button.style.display = 'none';
- return;
- }
-
- button.onclick = function() {
- if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
- menu.className = 'nav-menu';
- }
-
- if ( -1 !== button.className.indexOf( 'toggled-on' ) ) {
- button.className = button.className.replace( ' toggled-on', '' );
- menu.className = menu.className.replace( ' toggled-on', '' );
- } else {
- button.className += ' toggled-on';
- menu.className += ' toggled-on';
- }
- };
-} )();
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/page.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/page.php
deleted file mode 100644
index 0b09197b..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/page.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/**
- * The template for displaying all pages.
- *
- * This is the template that displays all pages by default.
- * Please note that this is the WordPress construct of pages
- * and that other 'pages' on your WordPress site will use a
- * different template.
- *
- * @package Minileven
- */
-
-get_header(); ?>
-
- <div id="primary">
- <div id="content" role="main">
-
- <?php while ( have_posts() ) : the_post(); ?>
-
- <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
- <header class="entry-header">
- <?php if ( '1' == get_option( 'wp_mobile_featured_images' ) && minileven_show_featured_images() ) : ?>
- <div class="entry-thumbnail">
- <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'jetpack' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="<?php the_ID(); ?>" class="minileven-featured-thumbnail"><?php the_post_thumbnail(); ?></a>
- </div><!-- .entry-thumbnail -->
- <?php endif; ?>
- <h1 class="entry-title"><?php the_title(); ?></h1>
- </header><!-- .entry-header -->
-
- <div class="entry-content">
- <?php the_content(); ?>
- <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'jetpack' ) . '</span>', 'after' => '</div>' ) ); ?>
- </div><!-- .entry-content -->
- <?php if ( is_user_logged_in() ) : ?>
- <footer class="entry-meta">
- <?php edit_post_link( __( 'Edit', 'jetpack' ), '<span class="edit-link">', '</span>' ); ?>
- </footer><!-- .entry-meta -->
- <?php endif; ?>
- </article><!-- #post-<?php the_ID(); ?> -->
-
- <?php comments_template( '', true ); ?>
-
- <?php endwhile; // end of the loop. ?>
-
- </div><!-- #content -->
- </div><!-- #primary -->
-<?php get_footer(); ?> \ No newline at end of file
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/rtl.css b/plugins/jetpack/modules/minileven/theme/pub/minileven/rtl.css
deleted file mode 100644
index b2839d74..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/rtl.css
+++ /dev/null
@@ -1,574 +0,0 @@
-/*
-Theme Name: Twenty Eleven
-
-Adding support for language written in a Right To Left (RTL) direction is easy -
-it's just a matter of overwriting all the horizontal positioning attributes
-of your CSS stylesheet in a separate stylesheet file named rtl.css.
-
-http://codex.wordpress.org/Right_to_Left_Language_Support
-
-*/
-
-/* =Reset reset
------------------------------------------------ */
-
-caption, th, td {
- text-align: right;
-}
-
-/* =Structure
------------------------------------------------ */
-
-body {
- direction:rtl;
- unicode-bidi:embed;
-}
-
-/* Showcase */
-.page-template-showcase-php section.recent-posts {
- float: left;
- margin: 0 31% 0 0;
-}
-.page-template-showcase-php #main .widget-area {
- float: right;
- margin: 0 0 0 -22.15%;
-}
-
-/* One column */
-
-.one-column article.feature-image.small .entry-summary a {
- left: auto;
- right: -9%;
-}
-
-/* Simplify the pullquotes and pull styles */
-.one-column.singular .entry-meta .edit-link a {
- right: 0px;
- left: auto;
-}
-/* Make sure we have room for our comment avatars */
-.one-column .commentlist > li.comment {
- margin-left: 0;
- margin-right: 102px;
-}
-/* Make sure the logo and search form don't collide */
-.one-column #branding #searchform {
- right: auto;
- left: 40px;
-}
-/* Talking avatars take up too much room at this size */
-.one-column .commentlist > li.comment {
- margin-right: 0;
-}
-.one-column .commentlist > li.comment .comment-meta,
-.one-column .commentlist > li.comment .comment-content {
- margin-right: 0;
- margin-left: 85px;
-}
-.one-column .commentlist .avatar {
- right: auto;
- left: 1.625em;
-}
-.one-column .commentlist .children .avatar {
- left: auto;
- right: 2.2em;
-}
-
-/* =Global
------------------------------------------------ */
-
-/* Text elements */
-p {
- margin-bottom: 1.625em;
-}
-ul, ol {
- margin: 0 2.5em 1.625em 0;
-}
-.ltr ul, ol {
- margin: 0 0 1.625em 2.5em;
-}
-blockquote {
- font-family: Arial, sans-serif;
-}
-blockquote em, blockquote i, blockquote cite {
- font-style: normal;
-}
-
-/* Forms */
-textarea {
- padding-left: 0;
- padding-right: 3px;
-}
-input#s {
- background-position: 97% 6px;
- padding: 4px 28px 4px 10px;
-}
-
-/* Assistive text */
-#access a.assistive-text:active,
-#access a.assistive-text:focus {
- left: auto;
- right: 7.6%;
-}
-
-/* =Header
------------------------------------------------ */
-
-#site-title {
- margin-right: 0;
- margin-left: 270px;
-}
-
-#site-description {
- margin: 0 0 3.65625em 270px;
-}
-
-/* =Menu
--------------------------------------------------------------- */
-
-#access {
- float: right;
-}
-#access ul {
- margin: 0 -0.8125em 0 0;
- padding-right: 0;
-}
-#access li {
- float: right;
-}
-#access ul ul {
- float: right;
- left: auto;
- right: 0;
-}
-#access ul ul ul {
- left: auto;
- right: 100%;
-}
-
-/* Search Form */
-#branding #searchform {
- right: auto;
- left: 7.6%;
- text-align: left;
-}
-#branding #s {
- float: left;
-}
-#branding .only-search + #access div {
- padding-right: 0;
- padding-left: 205px;
-}
-
-
-/* =Content
------------------------------------------------ */
-.entry-title,
-.entry-header .entry-meta {
- padding-right: 0;
- padding-left: 76px;
-}
-.entry-content td,
-.comment-content td {
- padding: 6px 0 6px 10px;
-}
-.page-link span {
- margin-right: 0;
- margin-left: 6px;
-}
-.entry-meta .edit-link a {
- float: left;
-}
-/* Images */
-
-.wp-caption .wp-caption-text,
-.gallery-caption {
- font-family: Arial, sans-serif;
-}
-.wp-caption .wp-caption-text {
- padding: 10px 40px 5px 0px;
-}
-.wp-caption .wp-caption-text:before {
- margin-right: 0;
- margin-left: 5px;
- left: auto;
- right: 10px;
-}
-#content .gallery-columns-4 .gallery-item {
- padding-right:0;
- padding-left:2%;
-}
-
-/* Author Info */
-.singular #author-info {
- margin: 2.2em -35.4% 0 -35.6%;
-}
-#author-avatar {
- float: right;
- margin-right: 0;
- margin-left: -78px;
-}
-#author-description {
- float: right;
- margin-left: 0;
- margin-right: 108px;
-}
-/* Comments link */
-.entry-header .comments-link a {
- background-image: url(images/comment-bubble-rtl.png);
- right: auto;
- left: 0;
-}
-
-/*
- Post Formats Headings
-*/
-.singular .entry-title,
-.singular .entry-header .entry-meta {
- padding-left: 0;
-}
-.singular .entry-header .entry-meta {
- left: auto;
- right: 0;
-}
-.singular .entry-meta .edit-link a {
- left: auto;
- right: 50px;
-}
-
-
-/* =Gallery
------------------------------------------------ */
-
-.format-gallery .gallery-thumb {
- float: right;
- margin: .375em 0 0 1.625em;
-}
-
-
-/* =Status
------------------------------------------------ */
-
-.format-status img.avatar {
- float: right;
- margin: 4px 0 2px 10px;
-}
-
-
-/* =Image
------------------------------------------------ */
-
-.indexed.format-image div.entry-meta {
- float: right;
-}
-/* =error404
-----------------------
-------------------------- */
-.error404 #main .widget {
- float: right;
- margin-right: auto;
- margin-left: 3.7%;
-}
-.error404 #main .widget_archive {
- margin-left: 0;
-}
-.error404 #main .widget_tag_cloud {
- margin-left: 0;
-}
-
-/* =Showcase
------------------------------------------------ */
-
-article.intro .edit-link a {
- right: auto;
- left: 20px;
-}
-
-/* Featured post */
-section.featured-post {
- float: right;
-}
-
-/* Small featured post */
-section.featured-post .attachment-small-feature {
- float: left;
- margin: 0 0 1.625em -8.9%;
- right: auto;
- left: -15px;
-}
-article.feature-image.small {
- float: right;
-}
-article.feature-image.small .entry-summary p a {
- left:auto;
- right: -23.8%;
- padding: 9px 85px 9px 26px;
-}
-
-/* Large featured post */
-section.feature-image.large .hentry {
- left:auto;
- right: 9%;
- margin: 1.625em 0 0 9%;
-}
-/* Featured Slider */
-.featured-posts .showcase-heading {
- padding-left: 0;
- padding-right: 8.9%;
-}
-.featured-posts section.featured-post {
- left: auto;
- right: 0;
-}
-#content .feature-slider {
- right: auto;
- left: 8.9%;
-}
-.feature-slider li {
- float: right;
-}
-/* Recent Posts */
-section.recent-posts .other-recent-posts a[rel="bookmark"] {
- float: right;
-}
-section.recent-posts .other-recent-posts .comments-link a,
-section.recent-posts .other-recent-posts .comments-link > span {
- padding: 0.3125em 1em 0.3125em 0;
- left: 0;
- text-align: left;
-}
-
-/* =Attachments
------------------------------------------------ */
-
-/* =Navigation
--------------------------------------------------------------- */
-
-.nav-previous {
- float: right;
-}
-.nav-next {
- float: left;
- text-align: left;
-}
-
-/* Singular navigation */
-#nav-single {
- float: left;
- text-align: left;
-}
-#nav-single .nav-next {
- padding-left: 0;
- padding-right: .5em;
-}
-
-
-/* =Widgets
------------------------------------------------ */
-
-.widget ul ul {
- margin-left: 0;
- margin-right: 1.5em;
-}
-
-/* Twitter */
-.widget_twitter .timesince {
- margin-right: 0;
- margin-left: -10px;
- text-align: left;
-}
-
-/* =Comments
------------------------------------------------ */
-
-.commentlist .children li.comment {
- border-left: none;
- border-right: 1px solid #ddd;
- -moz-border-radius: 3px 0 0 3px;
- border-radius: 3px 0 0 3px;
-}
-.commentlist .children li.comment .comment-meta {
- margin-left: 0;
- margin-right: 50px;
-}
-.commentlist .avatar {
- left: auto;
- right: -102px;
-}
-.commentlist > li:before {
- content: url(images/comment-arrow-rtl.png);
- left:auto;
- right: -21px;
-}
-.commentlist > li.pingback:before {
- content: '';
-}
-.commentlist .children .avatar {
- left: auto;
- right: 2.2em;
-}
-
-/* Post author highlighting */
-.commentlist > li.bypostauthor:before {
- content: url(images/comment-arrow-bypostauthor-rtl.png);
-}
-
-/* sidebar-page.php comments */
-/* Make sure we have room for our comment avatars */
-.page-template-sidebar-page-php .commentlist > li.comment,
-.page-template-sidebar-page-php.commentlist .pingback {
- margin-left: 0;
- margin-right: 102px;
-}
-
-/* Comment Form */
-#respond .comment-form-author label,
-#respond .comment-form-email label,
-#respond .comment-form-url label,
-#respond .comment-form-comment label {
- left: auto;
- right: 4px;
-}
-#respond .comment-form-author label,
-#respond .comment-form-email label,
-#respond .comment-form-url label,
-#respond .comment-form-comment label {
- -webkit-box-shadow: -1px 2px 2px rgba(204,204,204,0.8);
- -moz-box-shadow: -1px 2px 2px rgba(204,204,204,0.8);
- box-shadow: -1px 2px 2px rgba(204,204,204,0.8);
-}
-#respond .comment-form-author .required,
-#respond .comment-form-email .required {
- left: auto;
- right: 75%;
-}
-#respond .form-submit {
- float: left;
-}
-#respond input#submit {
- left: auto;
- right: 30px;
- padding: 5px 22px 5px 42px;
-}
-#respond #cancel-comment-reply-link {
- margin-left: 0;
- margin-right: 10px;
-}
-#cancel-comment-reply-link {
- right: auto;
- left: 1.625em;
-}
-
-/* =Footer
------------------------------------------------ */
-
-/* Two Footer Widget Areas */
-#supplementary.two .widget-area {
- float: right;
- margin-right: 0;
- margin-left: 3.7%;
-}
-#supplementary.two .widget-area + .widget-area {
- margin-left: 0;
-}
-
-/* Three Footer Widget Areas */
-#supplementary.three .widget-area {
- float: right;
- margin-right: 0;
- margin-left: 3.7%;
-}
-#supplementary.three .widget-area + .widget-area + .widget-area {
- margin-left: 0;
-}
-
-/* Site Generator Line */
-#site-generator .sep {
- background-position: right center;
-}
-
-
-/* =Responsive Structure
------------------------------------------------ */
-
-@media (max-width: 800px) {
- /* Simplify the showcase template when small feature */
- section.featured-post .attachment-small-feature,
- .one-column section.featured-post .attachment-small-feature {
- float: right;
- }
- article.feature-image.small {
- float: left;
- }
- article.feature-image.small .entry-summary p a {
- right: 0;
- }
- .singular .entry-meta .edit-link a {
- left: auto;
- right: 0px;
- }
- /* Make sure we have room for our comment avatars */
- .commentlist > li.comment,
- .commentlist .pingback {
- margin-left: 0;
- margin-right: 102px;
- }
- /* No need to float footer widgets at this size */
- #colophon #supplementary .widget-area {
- margin-left: 0;
- }
- /* No need to float 404 widgets at this size */
- .error404 #main .widget {
- margin-left: 0;
- }
-}
-@media (max-width: 650px) {
- /* @media (max-width: 650px) Reduce font-sizes for better readability on smaller devices */
- #site-title,
- #site-description {
- margin-left: 0;
- }
- /* Talking avatars take up too much room at this size */
- .commentlist > li.comment,
- .commentlist > li.pingback {
- margin-right: 0 !important;
- }
- .commentlist .children .avatar {
- left: auto;
- right: 2.2em;
- }
- /* Use the available space in the smaller comment form */
- #respond .comment-form-author .required,
- #respond .comment-form-email .required {
- left: auto;
- right: 95%;
- }
- #content .gallery-columns-3 .gallery-item {
- padding-right: 0;
- padding-left:2%;
- }
-}
-@media (max-width: 450px) {
- #content .gallery-columns-2 .gallery-item {
- padding-right:0;
- padding-left:4%;
- }
-}
-
-/* =Print
------------------------------------------------ */
-
-@media print {
- #primary {
- float: right;
- }
- /* Comments */
- .commentlist .avatar {
- left: auto;
- right: 2.2em;
- }
- .commentlist li.comment .comment-meta {
- margin-left: 0;
- margin-right: 50px;
- }
-}
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/screenshot.png b/plugins/jetpack/modules/minileven/theme/pub/minileven/screenshot.png
deleted file mode 100644
index d735057f..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/screenshot.png
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/searchform.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/searchform.php
deleted file mode 100644
index b4fd79aa..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/searchform.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-/**
- * The template for displaying search forms in Minileven
- *
- * @package Minileven
- */
-?>
- <form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
- <label for="s" class="assistive-text"><?php _e( 'Search', 'jetpack' ); ?></label>
- <input type="text" class="field" name="s" id="s" placeholder="<?php esc_attr_e( 'Search', 'jetpack' ); ?>" />
- <input type="submit" class="submit" name="submit" id="searchsubmit" value="<?php esc_attr_e( 'Search', 'jetpack' ); ?>" />
- </form>
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/sidebar.php b/plugins/jetpack/modules/minileven/theme/pub/minileven/sidebar.php
deleted file mode 100644
index 5d1a4a06..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/sidebar.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-/**
- * The Sidebar containing the main widget area.
- *
- * @package Minileven
- */
-?>
- <?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
- <div id="secondary" class="widget-area" role="complementary">
- <?php dynamic_sidebar( 'sidebar-1' ); ?>
- </div><!-- #secondary .widget-area -->
- <?php endif; ?> \ No newline at end of file
diff --git a/plugins/jetpack/modules/minileven/theme/pub/minileven/style.css b/plugins/jetpack/modules/minileven/theme/pub/minileven/style.css
deleted file mode 100644
index d3727dc0..00000000
--- a/plugins/jetpack/modules/minileven/theme/pub/minileven/style.css
+++ /dev/null
@@ -1,1588 +0,0 @@
-/*
-Theme Name: Minileven
-Theme URI: http://theme.wordpress.com
-Author: Automattic
-Author URI: http://theme.wordpress.com
-Description: The Minileven theme is a clean, lightweight mobile experience for your blog based on Twenty Eleven.
-Version: 2.0-wpcom
-License: GNU General Public License
-License URI: license.txt
-Tags: dark, light, white, black, gray, one-column, fluid-layout, responsive-layout, custom-background, custom-header, custom-menu, full-width-template, infinite-scroll, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready, blog, bright, clean, contemporary, elegant, minimal, modern, photography, simple, tumblelog
-*/
-
-.image-attachment .entry-caption p {
- font-size: 0.769em;
- letter-spacing: 0.1em;
- line-height: 2.6;
- margin: 0 0 2.6em;
- text-transform: uppercase;
-}
-
-/* =Webfont, thanks to FontSquirrel.com for conversion!
--------------------------------------------------------------- */
-@font-face {
- font-family: 'Genericons';
- src: url('inc/fonts/genericons-regular-webfont.eot');
- src: url('inc/fonts/genericons-regular-webfont.eot?#iefix') format('embedded-opentype'),
- url('inc/fonts/genericons-regular-webfont.woff') format('woff'),
- url('inc/fonts/genericons-regular-webfont.ttf') format('truetype'),
- url('inc/fonts/genericons-regular-webfont.svg#genericonsregular') format('svg');
- font-weight: normal;
- font-style: normal;
-
-}
-
-/* =Reset default browser CSS. Based on work by Eric Meyer: http://meyerweb.com/eric/tools/css/reset/index.html
--------------------------------------------------------------- */
-
-html, body, div, span, applet, object, iframe,
-h1, h2, h3, h4, h5, h6, p, blockquote, pre,
-a, abbr, acronym, address, big, cite, code,
-del, dfn, em, font, ins, kbd, q, s, samp,
-small, strike, strong, sub, sup, tt, var,
-dl, dt, dd, ol, ul, li,
-fieldset, form, label, legend,
-table, caption, tbody, tfoot, thead, tr, th, td {
- border: 0;
- font-family: inherit;
- font-size: 100%;
- font-style: inherit;
- font-weight: inherit;
- margin: 0;
- outline: 0;
- padding: 0;
- vertical-align: baseline;
-}
-:focus {/* remember to define focus styles! */
- outline: 0;
-}
-body {
- background: #fff;
- line-height: 1;
-}
-ol, ul {
- list-style: none;
-}
-a img {
- border: 0;
-}
-article, aside, details, figcaption, figure,
-footer, header, menu, nav, section {
- display: block;
-}
-
-
-/* =Global
------------------------------------------------ */
-
-body, input, textarea {
- color: #404040;
- font: 13px "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
- line-height: 1.625;
- word-wrap: break-word;
-}
-body {
- background: #f1f1f1;
- font-weight: 400;
-}
-#page,
-#branding {
- background: #fff;
- -moz-box-shadow: 0 1px 2px rgba( 0,0,0,0.075 );
- -webkit-box-shadow: 0 1px 2px rgba( 0,0,0,0.075 );
- box-shadow: 0 1px 2px rgba( 0,0,0,0.075 );
-}
-
-/* Headings */
-h1,h2,h3,h4,h5,h6 {
- clear: both;
-}
-hr {
- background-color: #ccc;
- border: 0;
- height: 1px;
- margin-bottom: 1.625em;
-}
-
-/* Text elements */
-p {
- margin-bottom: 1.0em;
-}
-ul, ol {
- margin: 0 0 1.625em 2.5em;
-}
-ul {
- list-style: square;
-}
-ol {
- list-style-type: decimal;
-}
-ul ul, ol ol, ul ol, ol ul {
- margin-bottom: 0;
-}
-dl {
- margin: 0 1.625em;
-}
-dt {
- font-weight: bold;
-}
-dd {
- margin-bottom: 1.625em;
-}
-strong {
- font-weight: bold;
-}
-cite, em, i {
- font-style: italic;
-}
-blockquote {
- font-style: italic;
- font-weight: normal;
- margin: 0;
-}
-blockquote em, blockquote i, blockquote cite {
- font-style: normal;
-}
-blockquote cite {
- color: #666;
- font-size: 0.800em;
- font-weight: 300;
- letter-spacing: 0.05em;
- text-transform: uppercase;
-}
-pre {
- background: #f4f4f4;
- font: 1em "Courier 10 Pitch", Courier, monospace;
- line-height: 1.5;
- margin-bottom: 1.625em;
- overflow: auto;
- padding: 0.75em 1.625em;
-}
-code, kbd {
- font: 1em Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
-}
-abbr, acronym, dfn {
- border-bottom: 1px dotted #666;
- cursor: help;
-}
-address {
- display: block;
- margin: 0 0 1.625em;
-}
-ins {
- background: #fff9c0;
- text-decoration: none;
-}
-sup,
-sub {
- font-size: 0.667em;
- height: 0;
- line-height: 1;
- position: relative;
- vertical-align: baseline;
-}
-sup {
- bottom: 1ex;
-}
-sub {
- top: .5ex;
-}
-
-/* Forms */
-input[type=text],
-input[type=email],
-input[type=password],
-textarea {
- background: #fafafa;
- -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.1);
- -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.1);
- box-shadow: inset 0 1px 1px rgba(0,0,0,0.1);
- border: 1px solid #ddd;
- color: #888;
-}
-input[type=text]:focus,
-input[type=email]:focus,
-textarea:focus {
- color: #373737;
-}
-textarea {
- padding-left: 3px;
- width: 98%;
-}
-input[type=text],
-input[type=email] {
- padding: 3px;
-}
-input#s {
- border-radius: 2px;
- height: 1.692em;
- line-height: 1.2;
- padding: 0.4em 0.6em 0.29em;
-}
-input#s:focus {
- padding-bottom: 0.3em;
-}
-input#searchsubmit {
- display: none;
-}
-input#s:focus,
-input[type=text]:focus,
-input[type=email]:focus,
-textarea:focus {
- font-size: 1.231em;
-}
-
-/* Links */
-a {
- color: #278dbc;
- text-decoration: none;
-}
-a:hover,
-.entry-title a:hover,
-.entry-meta .edit-link a:hover,
-.commentlist .edit-link a:hover,
-.entry-meta .comments-link a:hover {
- color: #7dcae7;
-}
-/* Assistive text */
-.assistive-text {
- clip: rect(1px, 1px, 1px, 1px);
- position: absolute !important;
- visibility: hidden;
-}
-
-
-/* =Structure
------------------------------------------------ */
-
-#page {
- margin: 0 auto;
- padding: 2.5%;
-}
-#branding {
- margin: 0.6em auto 0;
- padding: 2.5% 2.5% 1.5%;
-}
-
-#primary,
-#secondary {
- margin: 0 auto;
- width: auto;
-}
-#secondary {
- margin-top: 0.8em;
-}
-
-/* Alignment */
-.aligncenter,
-.alignleft,
-.alignright {
- clear: both;
- display: block;
- margin-left: auto;
- margin-right: auto;
-}
-
-/* Make sure embeds and iframes scale on smaller screens */
-embed,
-iframe,
-object {
- width: auto;
-}
-.jetpack-video-wrapper {
- margin-bottom: 1.0em;
-}
-
-/* Make sure the WordPress Video Shortcode scales on smaller screens */
-video {
- height: 100% !important;
- max-width: 100% !important;
- width: 100% !important;
-}
-.wp-video {
- width: 100% !important;
-}
-
-
-/* =Header
------------------------------------------------ */
-
-#branding .site-branding {
- margin-bottom: 1.3em;
-}
-#site-title,
-#site-description {
- clear: none;
-}
-#site-title a {
- color: #111;
- font-size: 1.846em;
- font-weight: bold;
- line-height: 1.3;
-}
-#site-description {
- color: #7a7a7a;
- font-size: 0.923em;
-}
-
-/* Header Image */
-#header-img {
- text-align: center;
-}
-header img {
- max-width: 100%;
- height: auto;
-}
-
-
-/* =Navigation and Search Form
------------------------------------------------ */
-
-.menu-search {
- background: #1e8cbe;
- -webkit-box-shadow: inset 0 -1px rgba(0, 86, 132, 0.8), 0 1px 3px rgba(0, 86, 132, 0.4);
- -moz-box-shadow: inset 0 -1px 0 rgba(0, 86, 132, 0.8), 0 1px 3px rgba(0, 86, 132, 0.4);
- box-shadow: inset 0 -1px 0 rgba(0, 86, 132, 0.8), 0 1px 3px rgba(0, 86, 132, 0.4);
- clear: both;
- height: 46px;
- width: 100%;
-}
-.menu-search:after {
- clear: both;
- content: "";
- display: block;
-}
-.menu-search,
-#access,
-.menu-toggle,
-#access .menu-label {
- height: 46px;
-}
-
-/* Small menu */
-#access {
- float: left;
- width: 60%;
-}
-.search-form {
- float: right;
- text-align: right;
- width: 39%;
-}
-.menu-toggle {
- cursor: pointer;
-}
-#access h3.toggled-on {
- opacity: 0.8;
-}
-#access ul.nav-menu {
- background: #fff;
- -webkit-box-shadow: 0 0 2px rgba(0, 0, 0, 0.15), 0 3px 8px rgba(0, 0, 0, 0.1);
- -moz-box-shadow: 0 0 2px rgba(0, 0, 0, 0.15), 0 3px 8px rgba(0, 0, 0, 0.1);
- box-shadow: 0 0 2px rgba(0, 0, 0, 0.15), 0 3px 8px rgba(0, 0, 0, 0.1);
- display: none;
- position: absolute;
- left: 0.5em;
- top: 3em;
- width: 100%;
- z-index: 99999;
-}
-.admin-bar #access ul.nav-menu {
- top: 6.6em;
-}
-.main-small-navigation .menu {
- background: #f9f9f9;
- border: 1px solid #e9e9e9;
- position: absolute;
- width: 100%;
-}
-#access ul.nav-menu:before {
- color: #fff;
- content: '\f500';
- display: inline-block;
- font: 0.9em/1 'Genericons';
- left: 49px;
- position: absolute;
- top: -11px;
- }
-#access ul li {
- border-bottom: 1px solid rgba( 0, 0, 0, 0.1 );
- padding: 1em 0.8em;
-}
-#access ul li:last-of-type {
- border: none;
-}
-#access ul ul li,
-#access ul ul ul li {
- border: none;
- padding-bottom: 0;
-}
-#access a {
- display: block;
- font-size: 1em;
-}
-#access ul {
- display: none;
- list-style: none;
- margin: 0;
- padding: 0.5em 0;
-}
-#access ul ul {
- display: block;
-}
-#access .sub-menu {
- margin: 0 0 0 15px;
-}
-#access .menu-toggle {
- clear: none;
- color: #fff;
- font-size: 1.077em;
- line-height: 2.5;
- padding: 0.3em 0 0 0.8em;
-}
-#access .menu-toggle:after {
- content: '\f502';
- cursor: pointer;
- display: inline-block;
- font: 0.7em/1 'Genericons';
- margin-left: 0.8em;
- margin-top: 1.7em;
- position: absolute;
-}
-#access .toggled-on:after {
- opacity: 0.8;
-}
-#access ul.nav-menu.toggled-on {
- display: inline-block;
-}
-.search-form #s {
- background: #006d9d;
- border: 1px solid #00587f;
- border-width: 0 0 0 1px;
- border-radius: 0;
- color: rgba( 255, 255, 255, 0.6 );
- font-size: 1em;
- height: 30px;
- margin-right: 0;
- padding: 0.6em;
- width: 80%;
-}
-
-
-/* =Content
------------------------------------------------ */
-
-.page-title {
- color: #666;
- font-size: 0.769em;
- font-weight: 300;
- letter-spacing: 0.1em;
- line-height: 2.6;
- margin-bottom: 1.2em;
- text-transform: uppercase;
-}
-.page-title a {
- font-size: 0.923em;
- font-weight: bold;
- letter-spacing: 0;
- text-transform: none;
-}
-.hentry,
-.no-results {
- clear: both;
- margin: 0 0 1.5em;
- padding: 0 0 2em;
- position: relative;
-}
-.hentry {
- border-bottom: 1px solid #ececec;
-}
-.hentry:last-child,
-.no-results,
-body.singular .hentry {
- border-bottom: none;
-}
-.blog .sticky .entry-header .entry-meta {
- clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
- clip: rect(1px, 1px, 1px, 1px);
- position: absolute !important;
-}
-.entry-title {
- clear: both;
- font-size: 1.538em;
- line-height: 1.260;
- word-wrap: break-word;
-}
-.featured-post .entry-title {
- font-size: 1.077em;
-}
-.entry-title,
-.entry-title a {
- color: #333;
- text-decoration: none;
-}
-.entry-meta {
- color: #666;
- clear: both;
- font-size: 0.923em;
- font-weight: 300;
- line-height: 1.385;
- overflow: hidden;
- padding: 0 0 0.6em 0;
-}
-.entry-meta .entry-date,
-.entry-meta .entry-gallery {
- display: block;
- float: left;
-}
-.entry-meta .author-link {
- display: block;
- margin-top: 0.7em;
-}
-.entry-meta .comments-link {
- display: block;
- float: right;
-}
-.entry-meta .edit-link a {
- margin-right: .5em;
-}
-.entry-meta .edit-link a,
-.commentlist .edit-link a,
-.entry-meta .comments-link a,
-a.comment-reply-link {
- color: #464646;
-}
-.entry-meta .edit-link a {
- float: right;
- text-decoration: none;
- padding: 0 0.615em;
-}
-.entry-meta .comments-link a:before,
-.entry-meta .edit-link a:before {
- display: inline-block;
- -webkit-font-smoothing: antialiased;
- font: normal 18px/1 'Genericons';
- margin-right: 0.1em;
- vertical-align: top;
-}
-.entry-meta .comments-link a:before {
- content: '\f300';
- font-family: Genericons;
-}
-.entry-meta .edit-link a:before,
-.commentlist .edit-link a:before {
- content: '\f411';
- font-family: Genericons;
-}
-.commentlist .edit-link a:before,
-.entry-meta .comments-link a:before,
-.entry-meta .edit-link a:before,
-a.comment-reply-link:before {
- color: #7bcbe4;
-}
-.entry-content {
- font-size: 1em;
- line-height: 1.538;
- margin: 1.286em 0;
- padding: 0;
-}
-.entry-content h1,
-.entry-content h2,
-.comment-content h1,
-.comment-content h2,
-.entry-content h3,
-.comment-content h3 {
- color: #000;
- margin: 0 0 .8125em;
-}
-.entry-content h1,
-.comment-content h1 {
- font-size: 1.5em;
- line-height: 2.9;
-}
-.entry-content h2,
-.comment-content h2 {
- font-size: 1.4em;
- line-height: 2.6;
-}
-.entry-content h3,
-.comment-content h3 {
- font-size: 1.3em;
- line-height: 2.3;
-}
-.entry-content table,
-.comment-content table {
- border-bottom: 1px solid #ddd;
- margin: 0 0 1.625em;
- width: 100%;
-}
-.entry-content th,
-.comment-content th {
- color: #666;
- font-size: 0.769em;
- font-weight: 500;
- letter-spacing: 0.1em;
- line-height: 2.6;
- text-transform: uppercase;
-}
-.entry-content td,
-.comment-content td {
- border-top: 1px solid #ddd;
- padding: 0.600em 1em 0.600em 0;
-}
-.entry-content #s {
- width: 75%;
-}
-.comment-content ul,
-.comment-content ol {
- margin-bottom: 1.625em;
-}
-.comment-content ul ul,
-.comment-content ol ol,
-.comment-content ul ol,
-.comment-content ol ul {
- margin-bottom: 0;
-}
-dl.gallery-item {
- margin: 0;
-}
-.page-link {
- clear: both;
- display: block;
- margin: 0 0 1em;
-}
-.page-link a {
- background: #278dbc;
- color: #fff;
- margin: 0;
- padding: 0.1em 0.231em;
- text-decoration: none;
-}
-.page-link span {
- margin-right: 0.462em;
-}
-
-/* Images */
-.entry-content img,
-.comment-content img,
-.widget img {
- height: auto;
- max-width: 100% !important; /* Fluid images for posts, comments, and widgets */
-}
-#content .gallery-columns-3 .gallery-item img,
-#content .gallery-columns-4 .gallery-item img,
-#content .gallery-columns-2 .gallery-item img {
- width: 100%;
- height: auto;
-}
-img[class*="align"],
-img[class*="wp-image-"],
-img[class*="attachment-"] {
- height: auto; /* Make sure images with WordPress-added height and width attributes are scaled correctly */
-}
-img.size-full,
-img.size-large {
- max-width: 100%;
- width: auto; /* Prevent stretching of full-size and large-size images with height and width attributes in IE8 */
- height: auto; /* Make sure images with WordPress-added height and width attributes are scaled correctly */
-}
-img.size-full,
-img.size-large,
-img.size-medium {
- display: block;
- margin: 0 auto;
-}
-.entry-content img.wp-smiley {
- border: none;
- margin-bottom: 0;
- margin-top: 0;
- padding: 0;
-}
-img.alignleft,
-img.alignright,
-img.aligncenter {
- margin-bottom: 1.625em;
-}
-p img,
-.wp-caption {
- margin-top: 0.4em;
-}
-.wp-caption {
- max-width: 96%;
-}
-.wp-caption img {
- display: block;
- margin: 0 auto;
- max-width: 98%;
-}
-.wp-caption .wp-caption-text,
-.gallery-caption {
- color: #999;
- font-size: 0.923em;
-}
-.wp-caption .wp-caption-text {
- margin-bottom: 0.6em;
- padding: 0.833em 0 0.417em 0;
- position: relative;
-}
-#content .gallery {
- margin: 0 auto 1.625em;
-}
-#content .gallery a img {
- border: none;
-}
-#content .gallery-columns-3 .gallery-item {
- width: 31%;
- padding-right: 2%;
-}
-#content .gallery-columns-4 .gallery-item {
- width: 23%;
- padding-right: 2%;
-}
-#content .gallery-columns-2 .gallery-item {
- width: 45%;
- padding-right: 4%;
-}
-
-
-/* Make sure embeds and iframes fit their containers */
-embed,
-iframe,
-object {
- max-width: 100%;
-}
-
-/* Password Protected Posts */
-.post-password-required .entry-header .comments-link {
- margin: 1.625em 0 0;
-}
-.post-password-required input[type=password] {
- margin: 0.8125em 0;
-}
-.post-password-required input[type=password]:focus {
- background: #f7f7f7;
-}
-
-
-/*
-Post Formats Headings
-To hide the headings, display: none the ".entry-header .entry-format" selector,
-and remove the padding rules below.
-*/
-.entry-header .entry-format {
- color: #666;
- font-size: 0.7em;
- font-weight: 300;
- letter-spacing: 0.1em;
- line-height: 2em;
- position: absolute;
- text-transform: uppercase;
- top: -5px;
-}
-.entry-header .entry-heading .entry-title {
- padding-top: 0.8em;
-}
-.entry-header .entry-heading {
- position: relative;
-}
-.entry-thumbnail {
- margin-bottom: 0.7em;
- text-align: center;
-}
-
-/* Singular content styles for Posts and Pages */
-.singular .hentry {
- padding: 1.625em 0 0;
- position: relative;
-}
-.page .hentry {
- padding-bottom: .7em;
-}
-.singular .entry-meta .edit-link a {
- bottom: auto;
- left: 0;
- position: absolute;
- right: auto;
- top: 40px;
-}
-.single-format-gallery .hentry {
- margin-bottom: 0;
-}
-.singular #author-info {
- margin: 2.2em -8.8% 0;
- padding: 1.538em 8.8%;
-}
-
-
-/* =Gallery Posts
------------------------------------------------ */
-
-#content .gallery {
- margin-bottom: 0;
-}
-.format-gallery img {
- margin: 0;
-}
-.format-gallery .gallery-large {
- line-height: 1.2em;
- margin: 0;
- width: 100%;
-}
-.format-gallery .gallery-thumbs-2,
- .format-gallery .gallery-thumbs-3 {
- overflow: hidden;
- width: 100%;
-}
-.format-gallery .gallery-thumbs-2 img {
- margin-right: 0.3%;
- max-width: 48%;
-}
-.format-gallery .gallery-thumbs-3 img {
- float: left;
- margin-left: 0.2%;
- max-width: 33%;
-}
-.format-gallery .gallery-large,
-.format-gallery .gallery-thumbs-2 img,
- .format-gallery .gallery-thumbs-3 img {
- display: inline-block;
-}
-.format-gallery .gallery-thumbs-3 .gallery-thumb-1 img {
- margin: 0;
-}
-.gallery-info {
- margin-top: 1.3em;
-}
-
-/* =Quote Posts
------------------------------------------------ */
-
-.format-quote blockquote {
- color: #555;
- font-size: 1.308em;
- margin: 0;
-}
-
-/* =error404
------------------------------------------------ */
-
-.error404 #main #searchform {
- background: #f9f9f9;
- border: 1px solid #ddd;
- border-width: 1px 0;
- margin: 0 -8.9% 1.625em;
- overflow: hidden;
- padding: 1.625em 8.9%;
-}
-.error404 #main #s {
- width: 95%;
-}
-.error404 .widgettitle {
- font-size: 0.769em;
- letter-spacing: 0.1em;
- line-height: 2.6em;
- text-transform: uppercase;
-}
-
-
-/* =Attachments
------------------------------------------------ */
-
-.image-attachment div.attachment {
- background: #f9f9f9;
- border: 1px solid #ddd;
- border-width: 1px 0;
- margin: 0 -8.9% 1.625em;
- overflow: hidden;
- padding: 1.625em 1.625em 0;
- text-align: center;
-}
-.image-attachment div.attachment img {
- display: block;
- height: auto;
- margin: 0 auto 1.625em;
- max-width: 100%;
-}
-.image-attachment div.attachment a img {
- border-color: #f9f9f9;
-}
-.image-attachment div.attachment a:focus img,
-.image-attachment div.attachment a:hover img,
-.image-attachment div.attachment a:active img {
- border-color: #ddd;
- background: #fff;
-}
-
-
-/* =Navigation
--------------------------------------------------------------- */
-
-#content nav {
- clear: both;
-}
-#nav-below,
-#nav-single {
- margin: 0 auto 1.9em;
- overflow: hidden;
- width: 100%;
-}
-.nav-previous {
- float: left;
- width: 48%;
-}
-.nav-next {
- float: right;
- width: 46%;
-}
-#nav-single {
- display: block;
- position: static;
-}
-#nav-single .nav-previous {
- margin-left: 0;
- width: 50%;
-}
-#nav-single .nav-next {
- margin-right: 0;
- width: 49%;
-}
-.nav-previous a,
-.nav-next a {
- background: #278dbc;
- color: #fff;
- display: block;
- font-size: 1.231em;
- padding: 1em 0;
- text-align: center;
- width: 100%;
-}
-#content nav .meta-nav {
- font-weight: normal;
-}
-#jp-post-flair {
- margin: 1em auto !important;
-}
-
-
-
-/* =Widget Area & Widgets
------------------------------------------------ */
-
-.widget-area {
- background: #f9f9f9;
- border-top: 1px solid #ddd;
- color: #666;
- font-size: 0.923em;
- padding: .6em 0.8em;
- -moz-box-shadow: 0 1px 2px rgba( 0,0,0,0.075 );
- -webkit-box-shadow: 0 1px 2px rgba( 0,0,0,0.075 );
- box-shadow: 0 1px 2px rgba( 0,0,0,0.075 );
-}
-.widget {
- border-bottom: 1px solid #ddd;
- clear: both;
- margin: 0;
- overflow: hidden;
- padding: 1em 0;
-}
-.widget:last-of-type {
- border: 0;
-}
-.widget-title {
- color: #666;
- font-size: 1.2em;
- font-weight: bold;
- line-height: 2em;
- margin-bottom: 0.5em;
-}
-.widget-title a {
- color: #666;
-}
-.widget ul {
- list-style: none;
- margin-bottom: 0;
- margin-left: 0;
-}
-.widget ul ul {
- margin-left: 1.5em;
-}
-.widget ul li {
- color: #777;
-}
-.widget a {
- font-weight: normal;
- text-decoration: none;
-}
-.widget a:hover,
-.widget a:focus,
-.widget a:active {
- text-decoration: underline;
-}
-
-/* Search Widget */
-.widget_search #s {
- width: 77%;
-}
-.widget_search #searchsubmit {
- background: #ddd;
- border: 1px solid #ccc;
- -webkit-box-shadow: inset 0px -1px 1px rgba(0, 0, 0, 0.09);
- -moz-box-shadow: inset 0px -1px 1px rgba(0, 0, 0, 0.09);
- box-shadow: inset 0px -1px 1px rgba(0, 0, 0, 0.09);
- color: #888;
- line-height: 2.083em;
- position: relative;
- top: -2px;
-}
-.widget_search #searchsubmit:active {
- background: #278dbc;
- border-color: #0861a5;
- -webkit-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.1);
- -moz-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.1);
- box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.1);
- color: #bfddf3;
-}
-
-/* Twitter */
-.tweets {
- margin-left: 0;
-}
-.widget_twitter li {
- list-style-type: none;
- margin-bottom: 1.167em;
-}
-.widget_twitter .timesince {
- font-size: 0.917em;
- font-weight: normal;
- text-align: right;
-}
-
-/* RSS-Related Widgets */
-.widget_rss img {
- display: inline-block;
- margin: 0;
- vertical-align: middle;
-}
-.widget_rss .rss-date {
- font-size: 90%;
-}
-.widget_rss_links img,
-.widget_rss_links a:hover img,
-.widget_rss_links a:focus img,
-.widget_rss_links a:active img {
- background: transparent;
- border: none;
- padding: 0;
-}
-
-/* Calendar Widget */
-.widget_calendar #wp-calendar {
- color: #555;
- width: 95%;
- text-align: center;
-}
-.widget_calendar #wp-calendar caption,
-.widget_calendar #wp-calendar td,
-.widget_calendar #wp-calendar th {
- text-align: center;
-}
-.widget_calendar #wp-calendar caption {
- font-size: 11px;
- font-weight: 500;
- padding: 5px 0 3px 0;
- text-transform: uppercase;
-}
-.widget_calendar #wp-calendar th {
- background: #f4f4f4;
- border-top: 1px solid #ccc;
- border-bottom: 1px solid #ccc;
- font-weight: bold;
-}
-.widget_calendar #wp-calendar tfoot td {
- background: #f4f4f4;
- border-top: 1px solid #ccc;
- border-bottom: 1px solid #ccc;
-}
-
-/* Recent Comments */
-.widget_recent_comments td.recentcommentstexttop,
-.widget_recent_comments td.recentcommentstextend {
- vertical-align: top;
-}
-
-/* Authors Widget */
-.widget_authors ul {
- margin-left: 0;
-}
-.widget_authors li {
- background: none !important;
- overflow: hidden;
-}
-.widget_authors ul ul li {
- overflow: hidden;
-}
-.widget_authors img {
- float: left;
- padding-right: 0.833em;
- vertical-align: text-top;
-}
-
-/*Flickr Widget */
-.widget_flickr #flickr_badge_wrapper {
- background-color: transparent;
- border: none;
-}
-#flickr_badge_uber_wrapper a:hover,
-#flickr_badge_uber_wrapper a:link,
-#flickr_badge_uber_wrapper a:active,
-#flickr_badge_uber_wrapper a:visited {
- color: #278dbc !important;
-}
-
-
-/* =Comments
------------------------------------------------ */
-
-#comments {
- margin-top: 1.5em;
-}
-#comments-title {
- color: #000;
- font-size: 1.154em;
- font-weight: bold;
- line-height: 1em;
- padding: 1em 0;
-}
-#comment-nav-below {
- overflow: hidden;
-}
-.nopassword,
-.nocomments {
- color: #aaa;
- font-size: 1.846em;
- font-weight: 100;
- margin: 2em 0;
- text-align: center;
-}
-.commentlist {
- list-style: none;
- margin: 2em auto;
- width: 100%;
-}
-.commentlist > li.comment {
- border: 1px solid rgba(0, 0, 0, 0.1);
- border-width: 1px 0 0;
- clear: both;
- margin: 0 -2.5% 0.5em;
- overflow: hidden;
- padding: .8em;
- position: relative;
-}
-.commentlist > li.comment,
-.commentlist .pingback {
- width: auto;
-}
-
-/* Reblogs */
-.commentlist > li.reblog {
- border: 1px solid #eee;
- -moz-border-radius: 3px;
- border-radius: 3px;
- margin: 0 0 1.625em;
- padding: 1.625em;
- position: relative;
-}
-.commentlist .reblog .comment-meta {
- display: none;
-}
-.commentlist .reblog p:first-child {
- color: #999;
- font-size: 1em;
-}
-.commentlist .reblog p:first-child a {
- font-weight: bold;
-}
-.commentlist .pingback {
- border-top: 1px solid rgba( 0, 0, 0, 0.1 );
- margin: 0 -2.5% 0.5em;
-}
-.commentlist .pingback p {
- color: #c0c0c0;
- margin-bottom: 0;
- padding: 0.8em;
-}
-.commentlist .children {
- list-style: none;
- margin: 0;
-}
-.commentlist .children li.comment {
- background: #f9f9f9;
- border-top: 1px solid rgba( 0, 0, 0, 0.1 );
- clear: both;
- margin: 1.625em 0 0;
- overflow: hidden;
- padding: 1.625em 1.625em 0.5em;
- position: relative;
-}
-.comment-meta .fn {
- font-style: normal;
-}
-.comment-meta,
-.comment-content {
- margin-left: 4em;
-}
-.comment-meta {
- font-size: 0.923em;
-}
-.comment-content {
- margin-top: 1em;
-}
-.commentlist .children li.comment .comment-meta {
- line-height: 1.625;
- margin-left: 3.462em;
-}
-.commentlist .children li.comment .comment-content {
- margin: 1em 0 0 3.1em;
-}
-.comment-meta a:focus,
-.comment-meta a:active,
-.comment-meta a:hover {
-}
-.commentlist .avatar {
- background: transparent;
- display: block;
- padding: 0;
- position: absolute;
- left: 13px;
- top: 13px;
-}
-.commentlist .children .avatar {
- background: none;
- -webkit-box-shadow: none;
- -moz-box-shadow: none;
- box-shadow: none;
- left: 2.2em;
- padding: 0;
- position: absolute;
- top: 2.2em;
-}
-.comment-actions {
- float: right;
- font-weight: 300;
- margin-bottom: 1em;
-}
-a.comment-reply-link:before {
- content: '\f412';
- display: inline-block;
- -webkit-font-smoothing: antialiased;
- font: normal 13px/1 'Genericons';
- margin: 0.2em 0.1em 0 0;
- vertical-align: top;
-}
-a.comment-reply-link {
- display: inline-block;
- font-size: 0.923em;
- padding: 0 0.615em;
- text-decoration: none;
-}
-a.comment-reply-link > span {
- display: inline-block;
- position: relative;
- top: -1px;
-}
-
-/* Comment Form */
-#respond {
- margin: 0 auto 1.625em;
- width: auto;
-}
-#respond input[type="text"],
-#respond textarea {
- background: #fff;
- position: relative;
- padding: 0.615em;
-}
-#respond .comment-form-author,
-#respond .comment-form-email,
-#respond .comment-form-url,
-#respond .comment-form-comment {
- position: relative;
-}
-#respond .comment-form-author label,
-#respond .comment-form-email label,
-#respond .comment-form-url label,
-#respond .comment-form-comment label {
- display: inline-block;
- font-size: 1.077em;
- padding: 0.154em 0 0;
- position: relative;
-}
-#respond textarea {
- resize: vertical;
- width: 95%;
-}
-#respond .comment-form-author .required,
-#respond .comment-form-email .required {
- color: #bd3500;
- font-size: 1.692em;
- font-weight: bold;
- left: 95%;
- position: absolute;
- top: 45px;
- z-index: 1;
-}
-#respond .comment-notes,
-#respond .logged-in-as {
- font-size: 0.8em;
- color: #666;
-}
-#respond .logged-in-as {
- margin-top: 1em;
-}
-#respond p {
- margin: 0.769em 0 0;
-}
-#respond .form-submit {
- margin: 0;
-}
-#respond input#submit {
- background-color: #2ea2cc;
- background-image: -moz-linear-gradient(top, #278dbc 0%, #0074a2 100%);
- background-image: -webkit-linear-gradient(top, #278dbc 0%,#0074a2 100%);
- background-image: -ms-linear-gradient(top, #278dbc 0%,#0074a2 100%);
- background-image: -o-linear-gradient(top, #278dbc 0%,#0074a2 100%);
- background-image: linear-gradient(top, #278dbc 0%,#0074a2 100%);
-
- -moz-box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
- -webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
- -o-box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
- -ms-box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
- box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
- border: none;
- -moz-border-radius: 2px 0 0 0;
- -webkit-border-radius: 2px 0 0 0;
- -o-border-radius: 2px 0 0 0;
- -ms-border-radius: 2px 0 0 0;
- border-radius: 2px;
- color: rgba( 255, 255, 255, 0.9 );
- cursor: pointer;
- font-size: 1em;
- margin: 0.462em 0;
- padding: 1em;
- left: 30px;
- text-shadow: 0 -1px 0 rgba(0,116,162,0.8);
-}
-#respond input#submit:hover {
- color: #fff;
- text-shadow: 0 -1px 0 rgb(0,116,162);
-
- background-image: -moz-linear-gradient(top, #2ea2cc 0%, #0074a2 100%);
- background-image: -webkit-linear-gradient(top, #2ea2cc 0%,#0074a2 100%);
- background-image: -o-linear-gradient(top, #2ea2cc 0%,#0074a2 100%);
- background-image: -ms-linear-gradient(top, #2ea2cc 0%,#0074a2 100%);
- background-image: linear-gradient(top, #2ea2cc 0%,#0074a2 100%);
-
- -moz-box-shadow: inset 0 1px 0 #2ea2cc, inset 0 2px 0 rgba(120,200,230,0.7);
- -webkit-box-shadow: inset 0 1px 0 #2ea2cc, inset 0 2px 0 rgba(120,200,230,0.7);
- -o-box-shadow: inset 0 1px 0 #2ea2cc, inset 0 2px 0 rgba(120,200,230,0.7);
- -ms-box-shadow: inset 0 1px 0 #2ea2cc, inset 0 2px 0 rgba(120,200,230,0.7);
- box-shadow: inset 0 1px 0 #2ea2cc, inset 0 2px 0 rgba(120,200,230,0.7);
-}
-#respond input#submit:active {
- color:rgba(255,255,255,.9);
- background-image: -moz-linear-gradient(top, #278dbc 0%, #0074a2 100%);
- background-image: -webkit-linear-gradient(top, #278dbc 0%,#0074a2 100%);
- background-image: -o-linear-gradient(top, #278dbc 0%,#0074a2 100%);
- background-image: -ms-linear-gradient(top, #278dbc 0%,#0074a2 100%);
- background-image: linear-gradient(top, #278dbc 0%,#0074a2 100%);
-
- -moz-box-shadow: inset 0 1px 5px #005684, inset 0 -1px 0 #278dbc;
- -webkit-box-shadow: inset 0 1px 5px #005684, inset 0 -1px 0 #278dbc;
- -o-box-shadow: inset 0 1px 5px #005684, inset 0 -1px 0 #278dbc;
- -ms-box-shadow: inset 0 1px 5px #005684, inset 0 -1px 0 #278dbc;
- box-shadow: inset 0 1px 5px #005684, inset 0 -1px 0 #278dbc;
-}
-.commentlist #respond {
- margin: 1.625em 0 0;
- width: auto;
-}
-#respond .comment-subscription-form {
- margin: 6px 0;
-}
-#reply-title {
- font-size: 1.5em;
-}
-.comment #reply-title {
- margin-top: 1em;
-}
-#cancel-comment-reply-link {
- color: #bd3500;
- display: block;
- font-size: 0.6em;
- font-weight: 300;
- line-height: 2.2;
- margin-top: 0.4em;
- text-decoration: none;
-}
-#respond label {
- line-height: 2.2;
-}
-#respond input[type=text] {
- display: block;
- height: 1.846em;
- width: 95%;
-}
-#respond p {
- font-size: 0.923em;
-}
-p.comment-form-comment {
- margin: 0;
-}
-.form-allowed-tags {
- display: none;
-}
-
-
-/* =Footer
------------------------------------------------ */
-
-#colophon {
- background: #f1f1f1;
- clear: both;
- margin-bottom: -2em;
- padding-bottom: 1em;
-}
-
-/* Site Generator Line */
-#site-generator {
- border-top: 1px solid #ddd;
- font-size: 0.923em;
- line-height: 2.2;
- padding: 2.2em 0.5em;
- text-align: center;
-}
-#site-generator a {
- color: #278dbc;
-}
-#site-generator .sep {
- color: transparent;
- display: inline-block;
- height: 16px;
- line-height: 1.231;
- margin: 0 0.538em;
- text-indent: 40px; /* Push the separator just out of the way */
- width: 3.077em;
-}
-
-
-/* =WP.com
------------------------------------------------ */
-
-.entry-content .twitter-tweet-rendered {
- max-width: 100% !important; /* Override the Twitter embed fixed width */
-}
-.video-player {
- max-width: 100% !important;
-}
-.videopress-placeholder,
-.video-player img {
- max-width: 100% !important;
- height: auto !important;
-}
-.syntaxhighlighter {
- overflow: auto;
-}
-.single #content #wp-likebox,
-.page #content #wp-likebox {
- display: block;
-}
-#wpl-mustlogin {
- width: 240px !important;
- margin-left: -60px !important;
-}
-img.latex {
- display: inline;
-}
-
-/* WP.com comment form */
-#comments #respond {
- max-width: 75%;
- margin: 0 auto 15px;
-}
-.content #comments #respond,
-#comments .commentlist #respond {
- max-width: 100%;
-}
-#respond textarea {
- text-indent: 0;
-}
-.singular #content .wpl-likebox {
- width: 100%;
-}
-#comments #respond {
- max-width: 100%;
-}
-#wpstats {
- display: block;
- margin: -1.8em auto 0;
-}
-#wpstats2 {
- display: none;
-}
-
-/* Adjust the width of Crowdsignal polls */
-.PDS_Poll .pds-box,
-.CSS_Poll .css-box {
- width: 99% !important;
-}
-
-/* Infinite Scroll */
-.infinite-wrap {
- border-top: 1px solid #ececec;
- padding-top: 1.5em !important;
-}
-.infinite-scroll .hentry:last-of-type,
-.infinite-scroll .hentry.last-before-infinite {
- margin-bottom: 0;
-}
-.infinite-scroll #content {
- padding-bottom: 0.1em;
-}
-#infinite-handle span:before {
- display: none;
-}
-#infinite-handle span {
- background: #278dbc;
- border-radius: 2px;
- border: none;
- color: #fff;
- cursor: pointer;
- font-size: 14px;
- font-weight: 400;
- padding: 6px 26px;
- text-align: center;
-}
-#infinite-handle span:hover {
- background: #7dcae7;
-}
-
-/* Remove margins and padding on outer containers for super-tiny screens */
-@media only screen and (min-device-width: 100px) and (max-device-width: 300px) {
- #wrapper {
- margin: 0;
- padding: 0;
- }
- #access {
- padding: 0.385em 0;
- }
- #page,
- .widget-area,
- #main,
- #branding {
- width: 100%;
- margin: 0;
- }
- .widget-area {
- padding: 0.417em;
- }
-} \ No newline at end of file
diff --git a/plugins/jetpack/modules/mobile-push.php b/plugins/jetpack/modules/mobile-push.php
deleted file mode 100644
index a421f47d..00000000
--- a/plugins/jetpack/modules/mobile-push.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-/**
- * Deprecated. See notes.php for the new module
- *
- * @package Jetpack
- **/
diff --git a/plugins/jetpack/modules/module-headings.php b/plugins/jetpack/modules/module-headings.php
index 2da092a4..a1c42dd2 100644
--- a/plugins/jetpack/modules/module-headings.php
+++ b/plugins/jetpack/modules/module-headings.php
@@ -28,7 +28,7 @@ function jetpack_get_module_i18n( $key ) {
'comments' => array(
'name' => _x( 'Comments', 'Module Name', 'jetpack' ),
- 'description' => _x( 'Let visitors use a WordPress.com, Twitter, Facebook, or Google account to comment', 'Module Description', 'jetpack' ),
+ 'description' => _x( 'Let visitors use a WordPress.com, Twitter, or Facebook account to comment', 'Module Description', 'jetpack' ),
),
'contact-form' => array(
@@ -61,6 +61,11 @@ function jetpack_get_module_i18n( $key ) {
'description' => _x( 'Set up Google Analytics without touching a line of code.', 'Module Description', 'jetpack' ),
),
+ 'google-fonts' => array(
+ 'name' => _x( 'Google Fonts (Beta)', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'A selection of Google fonts for block enabled themes. This feature is still being developed.', 'Module Description', 'jetpack' ),
+ ),
+
'gravatar-hovercards' => array(
'name' => _x( 'Gravatar Hovercards', 'Module Name', 'jetpack' ),
'description' => _x( 'Enable pop-up business cards over commenters’ Gravatars.', 'Module Description', 'jetpack' ),
@@ -127,7 +132,7 @@ function jetpack_get_module_i18n( $key ) {
),
'protect' => array(
- 'name' => _x( 'Protect', 'Module Name', 'jetpack' ),
+ 'name' => _x( 'Brute force protection', 'Module Name', 'jetpack' ),
'description' => _x( 'Enabling brute force protection will prevent bots and hackers from attempting to log in to your website with common username and password combinations.', 'Module Description', 'jetpack' ),
),
@@ -153,7 +158,7 @@ function jetpack_get_module_i18n( $key ) {
'sharedaddy' => array(
'name' => _x( 'Sharing', 'Module Name', 'jetpack' ),
- 'description' => _x( 'Add Twitter, Facebook and Google+ buttons at the bottom of each post, making it easy for visitors to share your content.', 'Module Description', 'jetpack' ),
+ 'description' => _x( 'Add Twitter and Facebook buttons at the bottom of each post, making it easy for visitors to share your content.', 'Module Description', 'jetpack' ),
),
'shortcodes' => array(
@@ -206,6 +211,11 @@ function jetpack_get_module_i18n( $key ) {
'description' => _x( 'Save on hosting storage and bandwidth costs by streaming fast, ad-free video from our global network.', 'Module Description', 'jetpack' ),
),
+ 'waf' => array(
+ 'name' => _x( 'Firewall', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Protect your site with Jetpack\'s Web Application Firewall', 'Module Description', 'jetpack' ),
+ ),
+
'widget-visibility' => array(
'name' => _x( 'Widget Visibility', 'Module Name', 'jetpack' ),
'description' => _x( 'Control where widgets appear on your site.', 'Module Description', 'jetpack' ),
@@ -230,9 +240,6 @@ function jetpack_get_module_i18n( $key ) {
return isset( $modules[ $key ] ) ? $modules[ $key ] : null;
}
-// The lists of filenames below shouldn't be arbitrarily punctuated, but the sniff triggers anyway.
-// phpcs:disable Squiz.Commenting.InlineComment.InvalidEndChar
-
/**
* For a given module tag, return its translated version.
*
@@ -298,12 +305,12 @@ function jetpack_get_module_i18n_tag( $key ) {
// - modules/wordads.php
'Appearance' => _x( 'Appearance', 'Module Tag', 'jetpack' ),
- // Modules with `Developers` tag:
- // - modules/json-api.php
- // - modules/sso.php
- 'Developers' => _x( 'Developers', 'Module Tag', 'jetpack' ),
+ // Modules with `Fonts` tag:
+ // - modules/google-fonts.php
+ 'Fonts' => _x( 'Fonts', 'Module Tag', 'jetpack' ),
// Modules with `Recommended` tag:
+ // - modules/google-fonts.php
// - modules/lazy-images.php
// - modules/monitor.php
// - modules/photon-cdn.php
@@ -317,6 +324,11 @@ function jetpack_get_module_i18n_tag( $key ) {
// - modules/woocommerce-analytics.php
'Recommended' => _x( 'Recommended', 'Module Tag', 'jetpack' ),
+ // Modules with `Developers` tag:
+ // - modules/json-api.php
+ // - modules/sso.php
+ 'Developers' => _x( 'Developers', 'Module Tag', 'jetpack' ),
+
// Modules with `General` tag:
// - modules/masterbar.php
'General' => _x( 'General', 'Module Tag', 'jetpack' ),
@@ -329,6 +341,14 @@ function jetpack_get_module_i18n_tag( $key ) {
// Modules with `Site Stats` tag:
// - modules/stats.php
'Site Stats' => _x( 'Site Stats', 'Module Tag', 'jetpack' ),
+
+ // Modules with `Firewall` tag:
+ // - modules/waf.php
+ 'Firewall' => _x( 'Firewall', 'Module Tag', 'jetpack' ),
+
+ // Modules with `WAF` tag:
+ // - modules/waf.php
+ 'WAF' => _x( 'WAF', 'Module Tag', 'jetpack' ),
);
}
return ! empty( $module_tags[ $key ] ) ? $module_tags[ $key ] : '';
@@ -382,7 +402,7 @@ function jetpack_get_module_info( $key ) {
'comments' =>
array (
'name' => 'Comments',
- 'description' => 'Let visitors use a WordPress.com, Twitter, Facebook, or Google account to comment',
+ 'description' => 'Let visitors use a WordPress.com, Twitter, or Facebook account to comment',
'sort' => '20',
'recommendation_order' => '',
'introduced' => '1.4',
@@ -394,7 +414,7 @@ function jetpack_get_module_info( $key ) {
'auto_activate' => 'No',
'module_tags' => 'Social',
'feature' => 'Engagement',
- 'additional_search_queries' => 'comments, comment, facebook, twitter, google+, social',
+ 'additional_search_queries' => 'comments, comment, facebook, twitter, social',
'plan_classes' => '',
),
'contact-form' =>
@@ -505,6 +525,24 @@ function jetpack_get_module_info( $key ) {
'additional_search_queries' => 'webmaster, google, analytics, console',
'plan_classes' => 'business, premium, security, complete',
),
+ 'google-fonts' =>
+ array (
+ 'name' => 'Google Fonts (Beta)',
+ 'description' => 'A selection of Google fonts for block enabled themes. This feature is still being developed.',
+ 'sort' => '1',
+ 'recommendation_order' => '2',
+ 'introduced' => '10.8.0',
+ 'changed' => '',
+ 'deactivate' => '',
+ 'free' => '',
+ 'requires_connection' => 'No',
+ 'requires_user_connection' => '',
+ 'auto_activate' => 'No',
+ 'module_tags' => 'Fonts, Recommended',
+ 'feature' => 'Writing',
+ 'additional_search_queries' => 'fonts, webfonts, typography',
+ 'plan_classes' => '',
+ ),
'gravatar-hovercards' =>
array (
'name' => 'Gravatar Hovercards',
@@ -741,7 +779,7 @@ function jetpack_get_module_info( $key ) {
),
'protect' =>
array (
- 'name' => 'Protect',
+ 'name' => 'Brute force protection',
'description' => 'Enabling brute force protection will prevent bots and hackers from attempting to log in to your website with common username and password combinations.',
'sort' => '1',
'recommendation_order' => '4',
@@ -832,7 +870,7 @@ function jetpack_get_module_info( $key ) {
'sharedaddy' =>
array (
'name' => 'Sharing',
- 'description' => 'Add Twitter, Facebook and Google+ buttons at the bottom of each post, making it easy for visitors to share your content.',
+ 'description' => 'Add Twitter and Facebook buttons at the bottom of each post, making it easy for visitors to share your content.',
'sort' => '7',
'recommendation_order' => '6',
'introduced' => '1.1',
@@ -862,7 +900,7 @@ function jetpack_get_module_info( $key ) {
'auto_activate' => 'No',
'module_tags' => 'Photos and Videos, Social, Writing, Appearance',
'feature' => 'Writing',
- 'additional_search_queries' => 'shortcodes, shortcode, embeds, media, bandcamp, dailymotion, facebook, flickr, google calendars, google maps, google+, polldaddy, recipe, recipes, scribd, slideshare, slideshow, slideshows, soundcloud, ted, twitter, vimeo, vine, youtube',
+ 'additional_search_queries' => 'shortcodes, shortcode, embeds, media, bandcamp, dailymotion, facebook, flickr, google calendars, google maps, polldaddy, recipe, recipes, scribd, slideshare, slideshow, slideshows, soundcloud, ted, twitter, vimeo, vine, youtube',
'plan_classes' => '',
),
'shortlinks' =>
@@ -1027,6 +1065,24 @@ function jetpack_get_module_info( $key ) {
'additional_search_queries' => 'video, videos, videopress, video gallery, video player, videoplayer, mobile video, vimeo, youtube, html5 video, stream',
'plan_classes' => '',
),
+ 'waf' =>
+ array (
+ 'name' => 'Firewall',
+ 'description' => 'Protect your site with Jetpack\'s Web Application Firewall',
+ 'sort' => '5',
+ 'recommendation_order' => '',
+ 'introduced' => '10.9',
+ 'changed' => '',
+ 'deactivate' => '',
+ 'free' => '',
+ 'requires_connection' => 'Yes',
+ 'requires_user_connection' => '',
+ 'auto_activate' => 'No',
+ 'module_tags' => 'Firewall, WAF',
+ 'feature' => 'Security',
+ 'additional_search_queries' => '',
+ 'plan_classes' => '',
+ ),
'widget-visibility' =>
array (
'name' => 'Widget Visibility',
diff --git a/plugins/jetpack/modules/module-info.php b/plugins/jetpack/modules/module-info.php
index e80c237d..132b59c0 100644
--- a/plugins/jetpack/modules/module-info.php
+++ b/plugins/jetpack/modules/module-info.php
@@ -191,7 +191,7 @@ add_filter( 'jetpack_learn_more_button_sharedaddy', 'sharedaddy_load_more_link'
*/
function sharedaddy_more_info() {
esc_html_e(
- 'Visitors can share your posts with Twitter, Facebook, Reddit, Digg, LinkedIn, Google+, print,
+ 'Visitors can share your posts with Twitter, Facebook, Reddit, Digg, LinkedIn, print,
and email. You can configure services to appear as icons, text, or both and some services like Twitter
have additional options.',
'jetpack'
@@ -873,3 +873,19 @@ function jetpack_more_info_copy_post() {
esc_html_e( 'Create a new post based on an existing post.', 'jetpack' );
}
add_action( 'jetpack_module_more_info_copy-post', 'jetpack_more_info_copy_post' );
+
+/**
+ * Google Fonts support link.
+ */
+function jetpack_google_fonts_more_link() {
+ echo esc_url( Redirect::get_url( 'jetpack-support-google-fonts' ) );
+}
+add_action( 'jetpack_learn_more_button_google-fonts', 'jetpack_google_fonts_more_link' );
+
+/**
+ * Google Fonts description.
+ */
+function jetpack_more_info_google_fonts() {
+ esc_html_e( 'A selection of Google fonts for block enabled themes. This feature is still being developed.', 'jetpack' );
+}
+add_action( 'jetpack_module_more_info_google-fonts', 'jetpack_more_info_google_fonts' );
diff --git a/plugins/jetpack/modules/monitor.php b/plugins/jetpack/modules/monitor.php
index 75f9e8ac..6d0083bc 100644
--- a/plugins/jetpack/modules/monitor.php
+++ b/plugins/jetpack/modules/monitor.php
@@ -114,7 +114,7 @@ class Jetpack_Monitor {
* Returns date of the last downtime.
*
* @since 4.0.0
- * @return date in YYYY-MM-DD HH:mm:ss format
+ * @return string date in YYYY-MM-DD HH:mm:ss format
*/
public function monitor_get_last_downtime() {
$xml = new Jetpack_IXR_Client();
diff --git a/plugins/jetpack/modules/photon-cdn.php b/plugins/jetpack/modules/photon-cdn.php
index f4e70e6a..232a1c8d 100644
--- a/plugins/jetpack/modules/photon-cdn.php
+++ b/plugins/jetpack/modules/photon-cdn.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Module Name: Asset CDN
* Module Description: Jetpack’s Site Accelerator loads your site faster by optimizing your images and serving your images and static files from our global network of servers.
@@ -10,14 +10,19 @@
* Module Tags: Photos and Videos, Appearance, Recommended
* Feature: Recommended, Appearance
* Additional Search Queries: site accelerator, accelerate, static, assets, javascript, css, files, performance, cdn, bandwidth, content delivery network, pagespeed, combine js, optimize css
+ *
+ * @package automattic/jetpack
*/
use Automattic\Jetpack\Assets;
-$GLOBALS['concatenate_scripts'] = false;
+$GLOBALS['concatenate_scripts'] = false; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
Assets::add_resource_hint( '//c0.wp.com', 'dns-prefetch' );
+/**
+ * Asset CDN module main class file.
+ */
class Jetpack_Photon_Static_Assets_CDN {
const CDN = 'https://c0.wp.com/';
@@ -61,7 +66,7 @@ class Jetpack_Photon_Static_Assets_CDN {
*
* @param array $values array( $version = core assets version, i.e. 4.9.8, $locale = desired locale )
*/
- list( $version, $locale ) = apply_filters(
+ list( $version, $locale ) = apply_filters( // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
'jetpack_cdn_core_version_and_locale',
array( $wp_version, get_locale() )
);
@@ -73,7 +78,7 @@ class Jetpack_Photon_Static_Assets_CDN {
continue;
}
$src = ltrim( str_replace( $site_url, '', $thing->src ), '/' );
- if ( self::is_js_or_css_file( $src ) && in_array( substr( $src, 0, 9 ), array( 'wp-admin/', 'wp-includ' ) ) ) {
+ if ( self::is_js_or_css_file( $src ) && in_array( substr( $src, 0, 9 ), array( 'wp-admin/', 'wp-includ' ), true ) ) {
$wp_scripts->registered[ $handle ]->src = sprintf( self::CDN . 'c/%1$s/%2$s', $version, $src );
$wp_scripts->registered[ $handle ]->ver = null;
}
@@ -83,7 +88,7 @@ class Jetpack_Photon_Static_Assets_CDN {
continue;
}
$src = ltrim( str_replace( $site_url, '', $thing->src ), '/' );
- if ( self::is_js_or_css_file( $src ) && in_array( substr( $src, 0, 9 ), array( 'wp-admin/', 'wp-includ' ) ) ) {
+ if ( self::is_js_or_css_file( $src ) && in_array( substr( $src, 0, 9 ), array( 'wp-admin/', 'wp-includ' ), true ) ) {
$wp_styles->registered[ $handle ]->src = sprintf( self::CDN . 'c/%1$s/%2$s', $version, $src );
$wp_styles->registered[ $handle ]->ver = null;
}
@@ -135,7 +140,7 @@ class Jetpack_Photon_Static_Assets_CDN {
*
* @return string The transformed local languages path.
*/
- public static function fix_local_script_translation_path( $file, $handle, $domain ) {
+ public static function fix_local_script_translation_path( $file, $handle, $domain ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
global $wp_scripts;
// This is a rewritten plugin URL, so load the language file from the plugins path.
@@ -237,7 +242,7 @@ class Jetpack_Photon_Static_Assets_CDN {
* @param array $assets The assets array for the plugin.
* @param string $version The version of the plugin being requested.
*/
- $assets = apply_filters( "jetpack_cdn_plugin_assets-{$plugin}", null, $version );
+ $assets = apply_filters( "jetpack_cdn_plugin_assets-{$plugin}", null, $version ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
if ( is_array( $assets ) ) {
return $assets;
}
@@ -301,13 +306,13 @@ class Jetpack_Photon_Static_Assets_CDN {
*/
public static function is_public_version( $version, $include_beta_and_rc = false ) {
if ( preg_match( '/^\d+(\.\d+)+$/', $version ) ) {
- // matches `1` `1.2` `1.2.3`.
+ /** Example matches: `1`, `1.2`, `1.2.3`. */
return true;
} elseif ( $include_beta_and_rc && preg_match( '/^\d+(\.\d+)+(-(beta|rc|pressable)\d?)$/i', $version ) ) {
- // matches `1.2.3` `1.2.3-beta` `1.2.3-pressable` `1.2.3-beta1` `1.2.3-rc` `1.2.3-rc2`.
+ /** Example matches: `1.2.3`, `1.2.3-beta`, `1.2.3-pressable`, `1.2.3-beta1`, `1.2.3-rc`, `1.2.3-rc2`. */
return true;
}
- // unrecognized version.
+ // Unrecognized version.
return false;
}
}
diff --git a/plugins/jetpack/modules/photon-cdn/jetpack-manifest.php b/plugins/jetpack/modules/photon-cdn/jetpack-manifest.php
index 8a179c92..371a93b9 100644
--- a/plugins/jetpack/modules/photon-cdn/jetpack-manifest.php
+++ b/plugins/jetpack/modules/photon-cdn/jetpack-manifest.php
@@ -5,7 +5,7 @@ $assets = array (
0 => '3rd-party/debug-bar/debug-bar.css',
1 => '3rd-party/debug-bar/debug-bar.js',
2 => '_inc/accessible-focus.js',
- 3 => '_inc/blocks/860.js',
+ 3 => '_inc/blocks/302.js',
4 => '_inc/blocks/business-hours/view.css',
5 => '_inc/blocks/business-hours/view.js',
6 => '_inc/blocks/business-hours/view.rtl.css',
@@ -125,409 +125,395 @@ $assets = array (
120 => '_inc/build/gallery-settings.min.js',
121 => '_inc/build/infinite-scroll/infinity-customizer.min.js',
122 => '_inc/build/infinite-scroll/infinity.min.js',
- 123 => '_inc/build/instant-search/407.js',
- 124 => '_inc/build/instant-search/jp-search-configure-main.css',
- 125 => '_inc/build/instant-search/jp-search-configure-main.js',
- 126 => '_inc/build/instant-search/jp-search-configure-main.rtl.css',
- 127 => '_inc/build/instant-search/jp-search-main.js',
- 128 => '_inc/build/instant-search/jp-search.chunk-main-payload.css',
- 129 => '_inc/build/instant-search/jp-search.chunk-main-payload.js',
- 130 => '_inc/build/instant-search/jp-search.chunk-main-payload.rtl.css',
- 131 => '_inc/build/jetpack-admin.min.js',
- 132 => '_inc/build/jetpack-connection-banner.min.js',
- 133 => '_inc/build/jetpack-deactivate-dialog.min.js',
- 134 => '_inc/build/jetpack-modules.min.js',
- 135 => '_inc/build/jetpack-modules.models.min.js',
- 136 => '_inc/build/jetpack-modules.views.min.js',
- 137 => '_inc/build/jetpack-recommendations-banner.min.js',
- 138 => '_inc/build/likes/post-count-jetpack.min.js',
- 139 => '_inc/build/likes/post-count.min.js',
- 140 => '_inc/build/likes/queuehandler.min.js',
- 141 => '_inc/build/masterbar/admin-color-schemes/colors/aquatic/colors.css',
- 142 => '_inc/build/masterbar/admin-color-schemes/colors/blue/colors.css',
- 143 => '_inc/build/masterbar/admin-color-schemes/colors/classic-blue/colors.css',
- 144 => '_inc/build/masterbar/admin-color-schemes/colors/classic-bright/colors.css',
- 145 => '_inc/build/masterbar/admin-color-schemes/colors/classic-dark/colors.css',
- 146 => '_inc/build/masterbar/admin-color-schemes/colors/coffee/colors.css',
- 147 => '_inc/build/masterbar/admin-color-schemes/colors/contrast/colors.css',
- 148 => '_inc/build/masterbar/admin-color-schemes/colors/ectoplasm/colors.css',
- 149 => '_inc/build/masterbar/admin-color-schemes/colors/fresh/colors.css',
- 150 => '_inc/build/masterbar/admin-color-schemes/colors/light/colors.css',
- 151 => '_inc/build/masterbar/admin-color-schemes/colors/midnight/colors.css',
- 152 => '_inc/build/masterbar/admin-color-schemes/colors/modern/colors.css',
- 153 => '_inc/build/masterbar/admin-color-schemes/colors/nightfall/colors.css',
- 154 => '_inc/build/masterbar/admin-color-schemes/colors/ocean/colors.css',
- 155 => '_inc/build/masterbar/admin-color-schemes/colors/powder-snow/colors.css',
- 156 => '_inc/build/masterbar/admin-color-schemes/colors/sakura/colors.css',
- 157 => '_inc/build/masterbar/admin-color-schemes/colors/sunrise/colors.css',
- 158 => '_inc/build/masterbar/admin-color-schemes/colors/sunset/colors.css',
- 159 => '_inc/build/masterbar/admin-menu/admin-menu.min.js',
- 160 => '_inc/build/masterbar/masterbar/tracks-events.min.js',
- 161 => '_inc/build/masterbar/nudges/additional-css/js/additional-css.min.js',
- 162 => '_inc/build/photon/photon.min.js',
- 163 => '_inc/build/plugins-page.css',
- 164 => '_inc/build/plugins-page.js',
- 165 => '_inc/build/plugins-page.rtl.css',
- 166 => '_inc/build/polldaddy-shortcode.min.js',
- 167 => '_inc/build/related-posts/related-posts-customizer.min.js',
- 168 => '_inc/build/related-posts/related-posts.min.js',
- 169 => '_inc/build/scan/admin-bar-notice.min.js',
- 170 => '_inc/build/search-dashboard.css',
- 171 => '_inc/build/search-dashboard.js',
- 172 => '_inc/build/search-dashboard.rtl.css',
- 173 => '_inc/build/sharedaddy/admin-sharing.min.js',
- 174 => '_inc/build/sharedaddy/sharing.min.js',
- 175 => '_inc/build/shortcodes/js/brightcove.min.js',
- 176 => '_inc/build/shortcodes/js/jmpress.min.js',
- 177 => '_inc/build/shortcodes/js/main.min.js',
- 178 => '_inc/build/shortcodes/js/quiz.min.js',
- 179 => '_inc/build/shortcodes/js/recipes-printthis.min.js',
- 180 => '_inc/build/shortcodes/js/recipes.min.js',
- 181 => '_inc/build/shortcodes/js/slideshow-shortcode.min.js',
- 182 => '_inc/build/style.min.css',
- 183 => '_inc/build/style.min.rtl.css',
- 184 => '_inc/build/tiled-gallery/tiled-gallery/tiled-gallery.min.js',
- 185 => '_inc/build/twitter-timeline.min.js',
- 186 => '_inc/build/videopress/js/editor-view.min.js',
- 187 => '_inc/build/videopress/js/gutenberg-video-upload.min.js',
- 188 => '_inc/build/videopress/js/media-video-widget-extensions.min.js',
- 189 => '_inc/build/videopress/js/videopress-plupload.min.js',
- 190 => '_inc/build/videopress/js/videopress-uploader.min.js',
- 191 => '_inc/build/widget-visibility/editor/index.js',
- 192 => '_inc/build/widget-visibility/widget-conditions/widget-conditions.min.js',
- 193 => '_inc/build/widgets/contact-info/contact-info-admin.min.js',
- 194 => '_inc/build/widgets/customizer-utils.min.js',
- 195 => '_inc/build/widgets/eu-cookie-law/eu-cookie-law-admin.min.js',
- 196 => '_inc/build/widgets/eu-cookie-law/eu-cookie-law.min.js',
- 197 => '_inc/build/widgets/gallery/js/admin.min.js',
- 198 => '_inc/build/widgets/gallery/js/gallery.min.js',
- 199 => '_inc/build/widgets/google-translate/google-translate.min.js',
- 200 => '_inc/build/widgets/milestone/admin.min.js',
- 201 => '_inc/build/widgets/milestone/milestone.min.js',
- 202 => '_inc/build/widgets/search/js/search-widget-admin.min.js',
- 203 => '_inc/build/widgets/search/js/search-widget.min.js',
- 204 => '_inc/build/widgets/simple-payments/customizer.min.js',
- 205 => '_inc/build/widgets/social-icons/social-icons-admin.min.js',
- 206 => '_inc/build/widgets/twitter-timeline-admin.min.js',
- 207 => '_inc/build/wordads/js/wordads-ccpa.min.js',
- 208 => '_inc/connect-button.js',
- 209 => '_inc/crowdsignal-shortcode.js',
- 210 => '_inc/crowdsignal-survey.js',
- 211 => '_inc/facebook-embed.js',
- 212 => '_inc/gallery-settings.js',
- 213 => '_inc/genericons/genericons.css',
- 214 => '_inc/genericons/genericons/genericons.css',
- 215 => '_inc/genericons/genericons/rtl/genericons-rtl.css',
- 216 => '_inc/jetpack-admin.js',
- 217 => '_inc/jetpack-connection-banner.js',
- 218 => '_inc/jetpack-deactivate-dialog.js',
- 219 => '_inc/jetpack-modules.js',
- 220 => '_inc/jetpack-modules.models.js',
- 221 => '_inc/jetpack-modules.views.js',
- 222 => '_inc/jetpack-recommendations-banner.js',
- 223 => '_inc/lib/debugger/jetpack-debugger-site-health.css',
- 224 => '_inc/lib/debugger/jetpack-debugger-site-health.js',
- 225 => '_inc/polldaddy-shortcode.js',
- 226 => '_inc/social-logos/social-logos.css',
- 227 => '_inc/social-logos/social-logos.min.css',
- 228 => '_inc/twitter-timeline.js',
- 229 => 'css/cleanslate-rtl.css',
- 230 => 'css/cleanslate-rtl.min.css',
- 231 => 'css/cleanslate.css',
- 232 => 'css/cleanslate.min.css',
- 233 => 'css/dashboard-widget-rtl.css',
- 234 => 'css/dashboard-widget-rtl.min.css',
- 235 => 'css/dashboard-widget.css',
- 236 => 'css/dashboard-widget.min.css',
- 237 => 'css/jetpack-admin-rtl.css',
- 238 => 'css/jetpack-admin-rtl.min.css',
- 239 => 'css/jetpack-admin.css',
- 240 => 'css/jetpack-admin.min.css',
- 241 => 'css/jetpack-banners-rtl.css',
- 242 => 'css/jetpack-banners-rtl.min.css',
- 243 => 'css/jetpack-banners.css',
- 244 => 'css/jetpack-banners.min.css',
- 245 => 'css/jetpack-connect-rtl.css',
- 246 => 'css/jetpack-connect-rtl.min.css',
- 247 => 'css/jetpack-connect.css',
- 248 => 'css/jetpack-connect.min.css',
- 249 => 'css/jetpack-deactivate-dialog-rtl.css',
- 250 => 'css/jetpack-deactivate-dialog-rtl.min.css',
- 251 => 'css/jetpack-deactivate-dialog.css',
- 252 => 'css/jetpack-deactivate-dialog.min.css',
- 253 => 'css/jetpack-icons-rtl.css',
- 254 => 'css/jetpack-icons-rtl.min.css',
- 255 => 'css/jetpack-icons.css',
- 256 => 'css/jetpack-icons.min.css',
- 257 => 'css/jetpack-recommendations-banner-rtl.css',
- 258 => 'css/jetpack-recommendations-banner-rtl.min.css',
- 259 => 'css/jetpack-recommendations-banner.css',
- 260 => 'css/jetpack-recommendations-banner.min.css',
- 261 => 'css/jetpack-rtl.css',
- 262 => 'css/jetpack.css',
- 263 => 'css/wordads-ccpa-rtl.css',
- 264 => 'css/wordads-ccpa-rtl.min.css',
- 265 => 'css/wordads-ccpa.css',
- 266 => 'css/wordads-ccpa.min.css',
- 267 => 'modules/calypsoify/mods-gutenberg.js',
- 268 => 'modules/calypsoify/mods.js',
- 269 => 'modules/calypsoify/style-gutenberg-rtl.min.css',
- 270 => 'modules/calypsoify/style-gutenberg.min.css',
- 271 => 'modules/calypsoify/style-rtl.min.css',
- 272 => 'modules/calypsoify/style.min.css',
- 273 => 'modules/carousel/jetpack-carousel-rtl.css',
- 274 => 'modules/carousel/jetpack-carousel.css',
- 275 => 'modules/carousel/jetpack-carousel.js',
- 276 => 'modules/carousel/swiper-bundle.css',
- 277 => 'modules/carousel/swiper-bundle.js',
- 278 => 'modules/comment-likes/admin-style.css',
- 279 => 'modules/comment-likes/comment-like-count.js',
- 280 => 'modules/contact-form/css/editor-inline-editing-style-rtl.css',
- 281 => 'modules/contact-form/css/editor-inline-editing-style-rtl.min.css',
- 282 => 'modules/contact-form/css/editor-inline-editing-style.css',
- 283 => 'modules/contact-form/css/editor-inline-editing-style.min.css',
- 284 => 'modules/contact-form/css/editor-style-rtl.css',
- 285 => 'modules/contact-form/css/editor-style-rtl.min.css',
- 286 => 'modules/contact-form/css/editor-style.css',
- 287 => 'modules/contact-form/css/editor-style.min.css',
- 288 => 'modules/contact-form/css/editor-ui-rtl.css',
- 289 => 'modules/contact-form/css/editor-ui-rtl.min.css',
- 290 => 'modules/contact-form/css/editor-ui.css',
- 291 => 'modules/contact-form/css/editor-ui.min.css',
- 292 => 'modules/contact-form/css/grunion-rtl.css',
- 293 => 'modules/contact-form/css/grunion.css',
- 294 => 'modules/contact-form/css/jquery-ui-datepicker.css',
- 295 => 'modules/contact-form/js/editor-view.js',
- 296 => 'modules/contact-form/js/grunion-admin.js',
- 297 => 'modules/contact-form/js/grunion-frontend.js',
- 298 => 'modules/contact-form/js/grunion.js',
- 299 => 'modules/contact-form/js/tinymce-plugin-form-button.js',
- 300 => 'modules/custom-css/csstidy/cssparse-rtl.css',
- 301 => 'modules/custom-css/csstidy/cssparse-rtl.min.css',
- 302 => 'modules/custom-css/csstidy/cssparse.css',
- 303 => 'modules/custom-css/csstidy/cssparse.min.css',
- 304 => 'modules/custom-css/csstidy/cssparsed-rtl.css',
- 305 => 'modules/custom-css/csstidy/cssparsed-rtl.min.css',
- 306 => 'modules/custom-css/csstidy/cssparsed.css',
- 307 => 'modules/custom-css/csstidy/cssparsed.min.css',
- 308 => 'modules/custom-css/custom-css/css/blank.css',
- 309 => 'modules/custom-css/custom-css/css/codemirror-rtl.css',
- 310 => 'modules/custom-css/custom-css/css/codemirror-rtl.min.css',
- 311 => 'modules/custom-css/custom-css/css/codemirror.css',
- 312 => 'modules/custom-css/custom-css/css/codemirror.min.css',
- 313 => 'modules/custom-css/custom-css/css/css-editor-rtl.css',
- 314 => 'modules/custom-css/custom-css/css/css-editor-rtl.min.css',
- 315 => 'modules/custom-css/custom-css/css/css-editor.css',
- 316 => 'modules/custom-css/custom-css/css/css-editor.min.css',
- 317 => 'modules/custom-css/custom-css/css/customizer-control.css',
- 318 => 'modules/custom-css/custom-css/css/rtl/codemirror-rtl.css',
- 319 => 'modules/custom-css/custom-css/css/use-codemirror-rtl.css',
- 320 => 'modules/custom-css/custom-css/css/use-codemirror-rtl.min.css',
- 321 => 'modules/custom-css/custom-css/css/use-codemirror.css',
- 322 => 'modules/custom-css/custom-css/css/use-codemirror.min.css',
- 323 => 'modules/custom-css/custom-css/js/codemirror.min.js',
- 324 => 'modules/custom-css/custom-css/js/core-customizer-css-preview.js',
- 325 => 'modules/custom-css/custom-css/js/core-customizer-css.core-4.9.js',
- 326 => 'modules/custom-css/custom-css/js/core-customizer-css.js',
- 327 => 'modules/custom-css/custom-css/js/css-editor.js',
- 328 => 'modules/custom-css/custom-css/js/use-codemirror.js',
- 329 => 'modules/custom-post-types/comics/admin.css',
- 330 => 'modules/custom-post-types/comics/comics-rtl.css',
- 331 => 'modules/custom-post-types/comics/comics-rtl.min.css',
- 332 => 'modules/custom-post-types/comics/comics.css',
- 333 => 'modules/custom-post-types/comics/comics.js',
- 334 => 'modules/custom-post-types/comics/comics.min.css',
- 335 => 'modules/custom-post-types/comics/rtl/comics-rtl.css',
- 336 => 'modules/custom-post-types/css/edit-items.css',
- 337 => 'modules/custom-post-types/css/many-items.css',
- 338 => 'modules/custom-post-types/css/nova-font.css',
- 339 => 'modules/custom-post-types/css/nova.css',
- 340 => 'modules/custom-post-types/css/portfolio-shortcode.css',
- 341 => 'modules/custom-post-types/css/testimonial-shortcode.css',
- 342 => 'modules/custom-post-types/js/many-items.js',
- 343 => 'modules/custom-post-types/js/menu-checkboxes.js',
- 344 => 'modules/custom-post-types/js/nova-drag-drop.js',
- 345 => 'modules/gravatar/gravatar-hovercards-amp.css',
- 346 => 'modules/infinite-scroll/infinity-customizer.js',
- 347 => 'modules/infinite-scroll/infinity.css',
- 348 => 'modules/infinite-scroll/infinity.js',
- 349 => 'modules/infinite-scroll/themes/twentyeleven.css',
- 350 => 'modules/infinite-scroll/themes/twentyfifteen-rtl.css',
- 351 => 'modules/infinite-scroll/themes/twentyfifteen.css',
- 352 => 'modules/infinite-scroll/themes/twentyfourteen.css',
- 353 => 'modules/infinite-scroll/themes/twentyseventeen-rtl.css',
- 354 => 'modules/infinite-scroll/themes/twentyseventeen.css',
- 355 => 'modules/infinite-scroll/themes/twentysixteen-rtl.css',
- 356 => 'modules/infinite-scroll/themes/twentysixteen.css',
- 357 => 'modules/infinite-scroll/themes/twentyten.css',
- 358 => 'modules/infinite-scroll/themes/twentythirteen.css',
- 359 => 'modules/infinite-scroll/themes/twentytwelve.css',
- 360 => 'modules/likes/post-count-jetpack.js',
- 361 => 'modules/likes/post-count.js',
- 362 => 'modules/likes/queuehandler.js',
- 363 => 'modules/likes/style.css',
- 364 => 'modules/masterbar/admin-menu/admin-menu-rtl.css',
- 365 => 'modules/masterbar/admin-menu/admin-menu-rtl.min.css',
- 366 => 'modules/masterbar/admin-menu/admin-menu.css',
- 367 => 'modules/masterbar/admin-menu/admin-menu.js',
- 368 => 'modules/masterbar/admin-menu/admin-menu.min.css',
- 369 => 'modules/masterbar/inline-help/inline-help.css',
- 370 => 'modules/masterbar/masterbar/overrides.css',
- 371 => 'modules/masterbar/masterbar/tracks-events.js',
- 372 => 'modules/masterbar/nudges/additional-css/css/additional-css.css',
- 373 => 'modules/masterbar/nudges/additional-css/js/additional-css.js',
- 374 => 'modules/masterbar/wp-posts-list/wp-posts-list.css',
- 375 => 'modules/photon/photon.js',
- 376 => 'modules/plugin-search/plugin-search.css',
- 377 => 'modules/plugin-search/plugin-search.js',
- 378 => 'modules/post-by-email/post-by-email-rtl.css',
- 379 => 'modules/post-by-email/post-by-email-rtl.min.css',
- 380 => 'modules/post-by-email/post-by-email.css',
- 381 => 'modules/post-by-email/post-by-email.js',
- 382 => 'modules/post-by-email/post-by-email.min.css',
- 383 => 'modules/protect/protect-dashboard-widget-rtl.css',
- 384 => 'modules/protect/protect-dashboard-widget-rtl.min.css',
- 385 => 'modules/protect/protect-dashboard-widget.css',
- 386 => 'modules/protect/protect-dashboard-widget.min.css',
- 387 => 'modules/related-posts/related-posts-customizer.js',
- 388 => 'modules/related-posts/related-posts-rtl.css',
- 389 => 'modules/related-posts/related-posts.css',
- 390 => 'modules/related-posts/related-posts.js',
- 391 => 'modules/related-posts/rtl/related-posts-rtl.css',
- 392 => 'modules/scan/admin-bar-notice.js',
- 393 => 'modules/search/customize-controls/class-excluded-post-types-control.css',
- 394 => 'modules/search/customize-controls/class-excluded-post-types-control.js',
- 395 => 'modules/search/customize-controls/class-label-control.css',
- 396 => 'modules/search/customize-controls/customize-controls.js',
- 397 => 'modules/sharedaddy/admin-sharing-rtl.css',
- 398 => 'modules/sharedaddy/admin-sharing-rtl.min.css',
- 399 => 'modules/sharedaddy/admin-sharing.css',
- 400 => 'modules/sharedaddy/admin-sharing.js',
- 401 => 'modules/sharedaddy/admin-sharing.min.css',
- 402 => 'modules/sharedaddy/amp-sharing.css',
- 403 => 'modules/sharedaddy/sharing.css',
- 404 => 'modules/sharedaddy/sharing.js',
- 405 => 'modules/shortcodes/css/gravatar-amp.css',
- 406 => 'modules/shortcodes/css/quiz.css',
- 407 => 'modules/shortcodes/css/recipes-print-rtl.css',
- 408 => 'modules/shortcodes/css/recipes-print-rtl.min.css',
- 409 => 'modules/shortcodes/css/recipes-print.css',
- 410 => 'modules/shortcodes/css/recipes-print.min.css',
- 411 => 'modules/shortcodes/css/recipes-rtl.css',
- 412 => 'modules/shortcodes/css/recipes-rtl.min.css',
- 413 => 'modules/shortcodes/css/recipes.css',
- 414 => 'modules/shortcodes/css/recipes.min.css',
- 415 => 'modules/shortcodes/css/slideshow-shortcode-rtl.css',
- 416 => 'modules/shortcodes/css/slideshow-shortcode-rtl.min.css',
- 417 => 'modules/shortcodes/css/slideshow-shortcode.css',
- 418 => 'modules/shortcodes/css/slideshow-shortcode.min.css',
- 419 => 'modules/shortcodes/css/style.css',
- 420 => 'modules/shortcodes/js/brightcove.js',
- 421 => 'modules/shortcodes/js/jmpress.js',
- 422 => 'modules/shortcodes/js/jquery.cycle.min.js',
- 423 => 'modules/shortcodes/js/main.js',
- 424 => 'modules/shortcodes/js/quiz.js',
- 425 => 'modules/shortcodes/js/recipes-printthis.js',
- 426 => 'modules/shortcodes/js/recipes.js',
- 427 => 'modules/shortcodes/js/slideshow-shortcode.js',
- 428 => 'modules/simple-payments/paypal-express-checkout.js',
- 429 => 'modules/simple-payments/simple-payments.css',
- 430 => 'modules/sso/jetpack-sso-login-rtl.css',
- 431 => 'modules/sso/jetpack-sso-login-rtl.min.css',
- 432 => 'modules/sso/jetpack-sso-login.css',
- 433 => 'modules/sso/jetpack-sso-login.js',
- 434 => 'modules/sso/jetpack-sso-login.min.css',
- 435 => 'modules/subscriptions/subscriptions.css',
- 436 => 'modules/theme-tools/compat/twentyfifteen-rtl.css',
- 437 => 'modules/theme-tools/compat/twentyfifteen.css',
- 438 => 'modules/theme-tools/compat/twentyfourteen-rtl.css',
- 439 => 'modules/theme-tools/compat/twentyfourteen.css',
- 440 => 'modules/theme-tools/compat/twentynineteen-rtl.css',
- 441 => 'modules/theme-tools/compat/twentynineteen.css',
- 442 => 'modules/theme-tools/compat/twentysixteen-rtl.css',
- 443 => 'modules/theme-tools/compat/twentysixteen.css',
- 444 => 'modules/theme-tools/compat/twentytwenty-rtl.css',
- 445 => 'modules/theme-tools/compat/twentytwenty.css',
- 446 => 'modules/theme-tools/compat/twentytwentyone-rtl.css',
- 447 => 'modules/theme-tools/compat/twentytwentyone.css',
- 448 => 'modules/theme-tools/content-options/customizer.js',
- 449 => 'modules/theme-tools/js/suggest.js',
- 450 => 'modules/theme-tools/responsive-videos/responsive-videos.css',
- 451 => 'modules/theme-tools/responsive-videos/responsive-videos.js',
- 452 => 'modules/theme-tools/responsive-videos/responsive-videos.min.js',
- 453 => 'modules/theme-tools/site-logo/js/site-logo-header-text.js',
- 454 => 'modules/theme-tools/site-logo/js/site-logo-header-text.min.js',
- 455 => 'modules/theme-tools/social-menu/social-menu.css',
- 456 => 'modules/tiled-gallery/tiled-gallery/rtl/tiled-gallery-rtl.css',
- 457 => 'modules/tiled-gallery/tiled-gallery/tiled-gallery-rtl.css',
- 458 => 'modules/tiled-gallery/tiled-gallery/tiled-gallery.css',
- 459 => 'modules/tiled-gallery/tiled-gallery/tiled-gallery.js',
- 460 => 'modules/videopress/css/editor-rtl.css',
- 461 => 'modules/videopress/css/editor-rtl.min.css',
- 462 => 'modules/videopress/css/editor.css',
- 463 => 'modules/videopress/css/editor.min.css',
- 464 => 'modules/videopress/css/videopress-editor-style-rtl.css',
- 465 => 'modules/videopress/css/videopress-editor-style-rtl.min.css',
- 466 => 'modules/videopress/css/videopress-editor-style.css',
- 467 => 'modules/videopress/css/videopress-editor-style.min.css',
- 468 => 'modules/videopress/js/editor-view.js',
- 469 => 'modules/videopress/js/gutenberg-video-upload.js',
- 470 => 'modules/videopress/js/media-video-widget-extensions.js',
- 471 => 'modules/videopress/js/videopress-plupload.js',
- 472 => 'modules/videopress/js/videopress-uploader.js',
- 473 => 'modules/videopress/videopress-admin-rtl.css',
- 474 => 'modules/videopress/videopress-admin-rtl.min.css',
- 475 => 'modules/videopress/videopress-admin.css',
- 476 => 'modules/videopress/videopress-admin.min.css',
- 477 => 'modules/widget-visibility/widget-conditions/rtl/widget-conditions-rtl.css',
- 478 => 'modules/widget-visibility/widget-conditions/widget-conditions-rtl.css',
- 479 => 'modules/widget-visibility/widget-conditions/widget-conditions-rtl.min.css',
- 480 => 'modules/widget-visibility/widget-conditions/widget-conditions.css',
- 481 => 'modules/widget-visibility/widget-conditions/widget-conditions.js',
- 482 => 'modules/widget-visibility/widget-conditions/widget-conditions.min.css',
- 483 => 'modules/widgets/authors/style.css',
- 484 => 'modules/widgets/contact-info/contact-info-admin.js',
- 485 => 'modules/widgets/contact-info/contact-info-map.css',
- 486 => 'modules/widgets/customizer-controls.css',
- 487 => 'modules/widgets/customizer-utils.js',
- 488 => 'modules/widgets/eu-cookie-law/eu-cookie-law-admin.js',
- 489 => 'modules/widgets/eu-cookie-law/eu-cookie-law.js',
- 490 => 'modules/widgets/eu-cookie-law/style.css',
- 491 => 'modules/widgets/facebook-likebox/style.css',
- 492 => 'modules/widgets/flickr/style.css',
- 493 => 'modules/widgets/gallery/css/admin-rtl.css',
- 494 => 'modules/widgets/gallery/css/admin-rtl.min.css',
- 495 => 'modules/widgets/gallery/css/admin.css',
- 496 => 'modules/widgets/gallery/css/admin.min.css',
- 497 => 'modules/widgets/gallery/css/rtl/admin-rtl.css',
- 498 => 'modules/widgets/gallery/js/admin.js',
- 499 => 'modules/widgets/gallery/js/gallery.js',
- 500 => 'modules/widgets/goodreads/css/goodreads.css',
- 501 => 'modules/widgets/goodreads/css/rtl/goodreads-rtl.css',
- 502 => 'modules/widgets/google-translate/google-translate.js',
- 503 => 'modules/widgets/gravatar-profile.css',
- 504 => 'modules/widgets/image-widget/style.css',
- 505 => 'modules/widgets/instagram/instagram.css',
- 506 => 'modules/widgets/milestone/admin.js',
- 507 => 'modules/widgets/milestone/milestone-widget.css',
- 508 => 'modules/widgets/milestone/milestone.js',
- 509 => 'modules/widgets/milestone/style-admin.css',
- 510 => 'modules/widgets/my-community/style.css',
- 511 => 'modules/widgets/search/css/search-widget-admin-ui.css',
- 512 => 'modules/widgets/search/css/search-widget-frontend.css',
- 513 => 'modules/widgets/search/js/search-widget-admin.js',
- 514 => 'modules/widgets/search/js/search-widget.js',
- 515 => 'modules/widgets/simple-payments/customizer.css',
- 516 => 'modules/widgets/simple-payments/customizer.js',
- 517 => 'modules/widgets/simple-payments/style.css',
- 518 => 'modules/widgets/social-icons/social-icons-admin.css',
- 519 => 'modules/widgets/social-icons/social-icons-admin.js',
- 520 => 'modules/widgets/social-icons/social-icons.css',
- 521 => 'modules/widgets/social-media-icons/style.css',
- 522 => 'modules/widgets/top-posts/style.css',
- 523 => 'modules/widgets/twitter-timeline-admin.js',
- 524 => 'modules/widgets/wordpress-post-widget/style.css',
- 525 => 'modules/wordads/css/style.css',
- 526 => 'modules/wordads/js/wordads-ccpa.js',
- 527 => 'modules/wpgroho.js',
+ 123 => '_inc/build/jetpack-admin.min.js',
+ 124 => '_inc/build/jetpack-connection-banner.min.js',
+ 125 => '_inc/build/jetpack-deactivate-dialog.min.js',
+ 126 => '_inc/build/jetpack-modules.min.js',
+ 127 => '_inc/build/jetpack-modules.models.min.js',
+ 128 => '_inc/build/jetpack-modules.views.min.js',
+ 129 => '_inc/build/jetpack-recommendations-banner.min.js',
+ 130 => '_inc/build/likes/post-count-jetpack.min.js',
+ 131 => '_inc/build/likes/post-count.min.js',
+ 132 => '_inc/build/likes/queuehandler.min.js',
+ 133 => '_inc/build/masterbar/admin-color-schemes/colors/aquatic/colors.css',
+ 134 => '_inc/build/masterbar/admin-color-schemes/colors/blue/colors.css',
+ 135 => '_inc/build/masterbar/admin-color-schemes/colors/classic-blue/colors.css',
+ 136 => '_inc/build/masterbar/admin-color-schemes/colors/classic-bright/colors.css',
+ 137 => '_inc/build/masterbar/admin-color-schemes/colors/classic-dark/colors.css',
+ 138 => '_inc/build/masterbar/admin-color-schemes/colors/coffee/colors.css',
+ 139 => '_inc/build/masterbar/admin-color-schemes/colors/contrast/colors.css',
+ 140 => '_inc/build/masterbar/admin-color-schemes/colors/ectoplasm/colors.css',
+ 141 => '_inc/build/masterbar/admin-color-schemes/colors/fresh/colors.css',
+ 142 => '_inc/build/masterbar/admin-color-schemes/colors/light/colors.css',
+ 143 => '_inc/build/masterbar/admin-color-schemes/colors/midnight/colors.css',
+ 144 => '_inc/build/masterbar/admin-color-schemes/colors/modern/colors.css',
+ 145 => '_inc/build/masterbar/admin-color-schemes/colors/nightfall/colors.css',
+ 146 => '_inc/build/masterbar/admin-color-schemes/colors/ocean/colors.css',
+ 147 => '_inc/build/masterbar/admin-color-schemes/colors/powder-snow/colors.css',
+ 148 => '_inc/build/masterbar/admin-color-schemes/colors/sakura/colors.css',
+ 149 => '_inc/build/masterbar/admin-color-schemes/colors/sunrise/colors.css',
+ 150 => '_inc/build/masterbar/admin-color-schemes/colors/sunset/colors.css',
+ 151 => '_inc/build/masterbar/admin-menu/admin-menu.min.js',
+ 152 => '_inc/build/masterbar/masterbar/tracks-events.min.js',
+ 153 => '_inc/build/masterbar/nudges/additional-css/js/additional-css.min.js',
+ 154 => '_inc/build/photon/photon.min.js',
+ 155 => '_inc/build/plugins-page.css',
+ 156 => '_inc/build/plugins-page.js',
+ 157 => '_inc/build/plugins-page.rtl.css',
+ 158 => '_inc/build/polldaddy-shortcode.min.js',
+ 159 => '_inc/build/related-posts/related-posts-customizer.min.js',
+ 160 => '_inc/build/related-posts/related-posts.min.js',
+ 161 => '_inc/build/scan/admin-bar-notice.min.js',
+ 162 => '_inc/build/sharedaddy/admin-sharing.min.js',
+ 163 => '_inc/build/sharedaddy/sharing.min.js',
+ 164 => '_inc/build/shortcodes/js/brightcove.min.js',
+ 165 => '_inc/build/shortcodes/js/jmpress.min.js',
+ 166 => '_inc/build/shortcodes/js/main.min.js',
+ 167 => '_inc/build/shortcodes/js/quiz.min.js',
+ 168 => '_inc/build/shortcodes/js/recipes-printthis.min.js',
+ 169 => '_inc/build/shortcodes/js/recipes.min.js',
+ 170 => '_inc/build/shortcodes/js/slideshow-shortcode.min.js',
+ 171 => '_inc/build/style.min.css',
+ 172 => '_inc/build/style.min.rtl.css',
+ 173 => '_inc/build/tiled-gallery/tiled-gallery/tiled-gallery.min.js',
+ 174 => '_inc/build/twitter-timeline.min.js',
+ 175 => '_inc/build/videopress/js/editor-view.min.js',
+ 176 => '_inc/build/videopress/js/gutenberg-video-upload.min.js',
+ 177 => '_inc/build/videopress/js/media-video-widget-extensions.min.js',
+ 178 => '_inc/build/videopress/js/test/test-gutenberg-video-upload.min.js',
+ 179 => '_inc/build/videopress/js/videopress-add-resumable-upload-support.min.js',
+ 180 => '_inc/build/videopress/js/videopress-plupload.min.js',
+ 181 => '_inc/build/videopress/js/videopress-token-bridge.min.js',
+ 182 => '_inc/build/videopress/js/videopress-uploader.min.js',
+ 183 => '_inc/build/widget-visibility/editor/index.css',
+ 184 => '_inc/build/widget-visibility/editor/index.js',
+ 185 => '_inc/build/widget-visibility/editor/index.rtl.css',
+ 186 => '_inc/build/widget-visibility/widget-conditions/widget-conditions.min.js',
+ 187 => '_inc/build/widgets/contact-info/contact-info-admin.min.js',
+ 188 => '_inc/build/widgets/customizer-utils.min.js',
+ 189 => '_inc/build/widgets/eu-cookie-law/eu-cookie-law-admin.min.js',
+ 190 => '_inc/build/widgets/eu-cookie-law/eu-cookie-law.min.js',
+ 191 => '_inc/build/widgets/gallery/js/admin.min.js',
+ 192 => '_inc/build/widgets/gallery/js/gallery.min.js',
+ 193 => '_inc/build/widgets/google-translate/google-translate.min.js',
+ 194 => '_inc/build/widgets/milestone/admin.min.js',
+ 195 => '_inc/build/widgets/milestone/milestone.min.js',
+ 196 => '_inc/build/widgets/simple-payments/customizer.min.js',
+ 197 => '_inc/build/widgets/social-icons/social-icons-admin.min.js',
+ 198 => '_inc/build/widgets/twitter-timeline-admin.min.js',
+ 199 => '_inc/build/wordads/js/wordads-ccpa.min.js',
+ 200 => '_inc/connect-button.js',
+ 201 => '_inc/crowdsignal-shortcode.js',
+ 202 => '_inc/crowdsignal-survey.js',
+ 203 => '_inc/facebook-embed.js',
+ 204 => '_inc/gallery-settings.js',
+ 205 => '_inc/genericons/genericons.css',
+ 206 => '_inc/genericons/genericons/genericons.css',
+ 207 => '_inc/genericons/genericons/rtl/genericons-rtl.css',
+ 208 => '_inc/jetpack-admin.js',
+ 209 => '_inc/jetpack-connection-banner.js',
+ 210 => '_inc/jetpack-deactivate-dialog.js',
+ 211 => '_inc/jetpack-modules.js',
+ 212 => '_inc/jetpack-modules.models.js',
+ 213 => '_inc/jetpack-modules.views.js',
+ 214 => '_inc/jetpack-recommendations-banner.js',
+ 215 => '_inc/lib/debugger/jetpack-debugger-site-health.css',
+ 216 => '_inc/lib/debugger/jetpack-debugger-site-health.js',
+ 217 => '_inc/polldaddy-shortcode.js',
+ 218 => '_inc/social-logos/social-logos.css',
+ 219 => '_inc/social-logos/social-logos.min.css',
+ 220 => '_inc/twitter-timeline.js',
+ 221 => 'css/cleanslate-rtl.css',
+ 222 => 'css/cleanslate-rtl.min.css',
+ 223 => 'css/cleanslate.css',
+ 224 => 'css/cleanslate.min.css',
+ 225 => 'css/dashboard-widget-rtl.css',
+ 226 => 'css/dashboard-widget-rtl.min.css',
+ 227 => 'css/dashboard-widget.css',
+ 228 => 'css/dashboard-widget.min.css',
+ 229 => 'css/jetpack-admin-rtl.css',
+ 230 => 'css/jetpack-admin-rtl.min.css',
+ 231 => 'css/jetpack-admin.css',
+ 232 => 'css/jetpack-admin.min.css',
+ 233 => 'css/jetpack-banners-rtl.css',
+ 234 => 'css/jetpack-banners-rtl.min.css',
+ 235 => 'css/jetpack-banners.css',
+ 236 => 'css/jetpack-banners.min.css',
+ 237 => 'css/jetpack-connect-rtl.css',
+ 238 => 'css/jetpack-connect-rtl.min.css',
+ 239 => 'css/jetpack-connect.css',
+ 240 => 'css/jetpack-connect.min.css',
+ 241 => 'css/jetpack-deactivate-dialog-rtl.css',
+ 242 => 'css/jetpack-deactivate-dialog-rtl.min.css',
+ 243 => 'css/jetpack-deactivate-dialog.css',
+ 244 => 'css/jetpack-deactivate-dialog.min.css',
+ 245 => 'css/jetpack-icons-rtl.css',
+ 246 => 'css/jetpack-icons-rtl.min.css',
+ 247 => 'css/jetpack-icons.css',
+ 248 => 'css/jetpack-icons.min.css',
+ 249 => 'css/jetpack-recommendations-banner-rtl.css',
+ 250 => 'css/jetpack-recommendations-banner-rtl.min.css',
+ 251 => 'css/jetpack-recommendations-banner.css',
+ 252 => 'css/jetpack-recommendations-banner.min.css',
+ 253 => 'css/jetpack-rtl.css',
+ 254 => 'css/jetpack.css',
+ 255 => 'css/wordads-ccpa-rtl.css',
+ 256 => 'css/wordads-ccpa-rtl.min.css',
+ 257 => 'css/wordads-ccpa.css',
+ 258 => 'css/wordads-ccpa.min.css',
+ 259 => 'modules/calypsoify/mods-gutenberg.js',
+ 260 => 'modules/calypsoify/mods.js',
+ 261 => 'modules/calypsoify/style-gutenberg-rtl.min.css',
+ 262 => 'modules/calypsoify/style-gutenberg.min.css',
+ 263 => 'modules/calypsoify/style-rtl.min.css',
+ 264 => 'modules/calypsoify/style.min.css',
+ 265 => 'modules/carousel/jetpack-carousel-rtl.css',
+ 266 => 'modules/carousel/jetpack-carousel.css',
+ 267 => 'modules/carousel/jetpack-carousel.js',
+ 268 => 'modules/carousel/swiper-bundle.css',
+ 269 => 'modules/carousel/swiper-bundle.js',
+ 270 => 'modules/comment-likes/admin-style.css',
+ 271 => 'modules/comment-likes/comment-like-count.js',
+ 272 => 'modules/contact-form/css/editor-inline-editing-style-rtl.css',
+ 273 => 'modules/contact-form/css/editor-inline-editing-style-rtl.min.css',
+ 274 => 'modules/contact-form/css/editor-inline-editing-style.css',
+ 275 => 'modules/contact-form/css/editor-inline-editing-style.min.css',
+ 276 => 'modules/contact-form/css/editor-style-rtl.css',
+ 277 => 'modules/contact-form/css/editor-style-rtl.min.css',
+ 278 => 'modules/contact-form/css/editor-style.css',
+ 279 => 'modules/contact-form/css/editor-style.min.css',
+ 280 => 'modules/contact-form/css/editor-ui-rtl.css',
+ 281 => 'modules/contact-form/css/editor-ui-rtl.min.css',
+ 282 => 'modules/contact-form/css/editor-ui.css',
+ 283 => 'modules/contact-form/css/editor-ui.min.css',
+ 284 => 'modules/contact-form/css/grunion-rtl.css',
+ 285 => 'modules/contact-form/css/grunion.css',
+ 286 => 'modules/contact-form/css/jquery-ui-datepicker.css',
+ 287 => 'modules/contact-form/js/editor-view.js',
+ 288 => 'modules/contact-form/js/grunion-admin.js',
+ 289 => 'modules/contact-form/js/grunion-frontend.js',
+ 290 => 'modules/contact-form/js/grunion.js',
+ 291 => 'modules/contact-form/js/tinymce-plugin-form-button.js',
+ 292 => 'modules/custom-css/csstidy/cssparse-rtl.css',
+ 293 => 'modules/custom-css/csstidy/cssparse-rtl.min.css',
+ 294 => 'modules/custom-css/csstidy/cssparse.css',
+ 295 => 'modules/custom-css/csstidy/cssparse.min.css',
+ 296 => 'modules/custom-css/csstidy/cssparsed-rtl.css',
+ 297 => 'modules/custom-css/csstidy/cssparsed-rtl.min.css',
+ 298 => 'modules/custom-css/csstidy/cssparsed.css',
+ 299 => 'modules/custom-css/csstidy/cssparsed.min.css',
+ 300 => 'modules/custom-css/custom-css/css/blank.css',
+ 301 => 'modules/custom-css/custom-css/css/codemirror-rtl.css',
+ 302 => 'modules/custom-css/custom-css/css/codemirror-rtl.min.css',
+ 303 => 'modules/custom-css/custom-css/css/codemirror.css',
+ 304 => 'modules/custom-css/custom-css/css/codemirror.min.css',
+ 305 => 'modules/custom-css/custom-css/css/css-editor-rtl.css',
+ 306 => 'modules/custom-css/custom-css/css/css-editor-rtl.min.css',
+ 307 => 'modules/custom-css/custom-css/css/css-editor.css',
+ 308 => 'modules/custom-css/custom-css/css/css-editor.min.css',
+ 309 => 'modules/custom-css/custom-css/css/customizer-control.css',
+ 310 => 'modules/custom-css/custom-css/css/rtl/codemirror-rtl.css',
+ 311 => 'modules/custom-css/custom-css/css/use-codemirror-rtl.css',
+ 312 => 'modules/custom-css/custom-css/css/use-codemirror-rtl.min.css',
+ 313 => 'modules/custom-css/custom-css/css/use-codemirror.css',
+ 314 => 'modules/custom-css/custom-css/css/use-codemirror.min.css',
+ 315 => 'modules/custom-css/custom-css/js/codemirror.min.js',
+ 316 => 'modules/custom-css/custom-css/js/core-customizer-css-preview.js',
+ 317 => 'modules/custom-css/custom-css/js/core-customizer-css.core-4.9.js',
+ 318 => 'modules/custom-css/custom-css/js/core-customizer-css.js',
+ 319 => 'modules/custom-css/custom-css/js/css-editor.js',
+ 320 => 'modules/custom-css/custom-css/js/use-codemirror.js',
+ 321 => 'modules/custom-post-types/comics/admin.css',
+ 322 => 'modules/custom-post-types/comics/comics-rtl.css',
+ 323 => 'modules/custom-post-types/comics/comics-rtl.min.css',
+ 324 => 'modules/custom-post-types/comics/comics.css',
+ 325 => 'modules/custom-post-types/comics/comics.js',
+ 326 => 'modules/custom-post-types/comics/comics.min.css',
+ 327 => 'modules/custom-post-types/comics/rtl/comics-rtl.css',
+ 328 => 'modules/custom-post-types/css/edit-items.css',
+ 329 => 'modules/custom-post-types/css/many-items.css',
+ 330 => 'modules/custom-post-types/css/nova-font.css',
+ 331 => 'modules/custom-post-types/css/nova.css',
+ 332 => 'modules/custom-post-types/css/portfolio-shortcode.css',
+ 333 => 'modules/custom-post-types/css/testimonial-shortcode.css',
+ 334 => 'modules/custom-post-types/js/many-items.js',
+ 335 => 'modules/custom-post-types/js/menu-checkboxes.js',
+ 336 => 'modules/custom-post-types/js/nova-drag-drop.js',
+ 337 => 'modules/gravatar/gravatar-hovercards-amp.css',
+ 338 => 'modules/infinite-scroll/infinity-customizer.js',
+ 339 => 'modules/infinite-scroll/infinity.css',
+ 340 => 'modules/infinite-scroll/infinity.js',
+ 341 => 'modules/infinite-scroll/themes/twentyeleven.css',
+ 342 => 'modules/infinite-scroll/themes/twentyfifteen-rtl.css',
+ 343 => 'modules/infinite-scroll/themes/twentyfifteen.css',
+ 344 => 'modules/infinite-scroll/themes/twentyfourteen.css',
+ 345 => 'modules/infinite-scroll/themes/twentyseventeen-rtl.css',
+ 346 => 'modules/infinite-scroll/themes/twentyseventeen.css',
+ 347 => 'modules/infinite-scroll/themes/twentysixteen-rtl.css',
+ 348 => 'modules/infinite-scroll/themes/twentysixteen.css',
+ 349 => 'modules/infinite-scroll/themes/twentyten.css',
+ 350 => 'modules/infinite-scroll/themes/twentythirteen.css',
+ 351 => 'modules/infinite-scroll/themes/twentytwelve.css',
+ 352 => 'modules/likes/post-count-jetpack.js',
+ 353 => 'modules/likes/post-count.js',
+ 354 => 'modules/likes/queuehandler.js',
+ 355 => 'modules/likes/style.css',
+ 356 => 'modules/masterbar/admin-menu/admin-menu-rtl.css',
+ 357 => 'modules/masterbar/admin-menu/admin-menu-rtl.min.css',
+ 358 => 'modules/masterbar/admin-menu/admin-menu.css',
+ 359 => 'modules/masterbar/admin-menu/admin-menu.js',
+ 360 => 'modules/masterbar/admin-menu/admin-menu.min.css',
+ 361 => 'modules/masterbar/inline-help/inline-help.css',
+ 362 => 'modules/masterbar/masterbar/overrides.css',
+ 363 => 'modules/masterbar/masterbar/tracks-events.js',
+ 364 => 'modules/masterbar/nudges/additional-css/css/additional-css.css',
+ 365 => 'modules/masterbar/nudges/additional-css/js/additional-css.js',
+ 366 => 'modules/masterbar/wp-posts-list/wp-posts-list.css',
+ 367 => 'modules/photon/photon.js',
+ 368 => 'modules/plugin-search/plugin-search.css',
+ 369 => 'modules/plugin-search/plugin-search.js',
+ 370 => 'modules/post-by-email/post-by-email-rtl.css',
+ 371 => 'modules/post-by-email/post-by-email-rtl.min.css',
+ 372 => 'modules/post-by-email/post-by-email.css',
+ 373 => 'modules/post-by-email/post-by-email.js',
+ 374 => 'modules/post-by-email/post-by-email.min.css',
+ 375 => 'modules/protect/protect-dashboard-widget-rtl.css',
+ 376 => 'modules/protect/protect-dashboard-widget-rtl.min.css',
+ 377 => 'modules/protect/protect-dashboard-widget.css',
+ 378 => 'modules/protect/protect-dashboard-widget.min.css',
+ 379 => 'modules/related-posts/related-posts-customizer.js',
+ 380 => 'modules/related-posts/related-posts-rtl.css',
+ 381 => 'modules/related-posts/related-posts.css',
+ 382 => 'modules/related-posts/related-posts.js',
+ 383 => 'modules/related-posts/rtl/related-posts-rtl.css',
+ 384 => 'modules/scan/admin-bar-notice.js',
+ 385 => 'modules/sharedaddy/admin-sharing-rtl.css',
+ 386 => 'modules/sharedaddy/admin-sharing-rtl.min.css',
+ 387 => 'modules/sharedaddy/admin-sharing.css',
+ 388 => 'modules/sharedaddy/admin-sharing.js',
+ 389 => 'modules/sharedaddy/admin-sharing.min.css',
+ 390 => 'modules/sharedaddy/amp-sharing.css',
+ 391 => 'modules/sharedaddy/sharing.css',
+ 392 => 'modules/sharedaddy/sharing.js',
+ 393 => 'modules/shortcodes/css/gravatar-amp.css',
+ 394 => 'modules/shortcodes/css/quiz.css',
+ 395 => 'modules/shortcodes/css/recipes-print-rtl.css',
+ 396 => 'modules/shortcodes/css/recipes-print-rtl.min.css',
+ 397 => 'modules/shortcodes/css/recipes-print.css',
+ 398 => 'modules/shortcodes/css/recipes-print.min.css',
+ 399 => 'modules/shortcodes/css/recipes-rtl.css',
+ 400 => 'modules/shortcodes/css/recipes-rtl.min.css',
+ 401 => 'modules/shortcodes/css/recipes.css',
+ 402 => 'modules/shortcodes/css/recipes.min.css',
+ 403 => 'modules/shortcodes/css/slideshow-shortcode-rtl.css',
+ 404 => 'modules/shortcodes/css/slideshow-shortcode-rtl.min.css',
+ 405 => 'modules/shortcodes/css/slideshow-shortcode.css',
+ 406 => 'modules/shortcodes/css/slideshow-shortcode.min.css',
+ 407 => 'modules/shortcodes/css/style.css',
+ 408 => 'modules/shortcodes/js/brightcove.js',
+ 409 => 'modules/shortcodes/js/jmpress.js',
+ 410 => 'modules/shortcodes/js/jquery.cycle.min.js',
+ 411 => 'modules/shortcodes/js/main.js',
+ 412 => 'modules/shortcodes/js/quiz.js',
+ 413 => 'modules/shortcodes/js/recipes-printthis.js',
+ 414 => 'modules/shortcodes/js/recipes.js',
+ 415 => 'modules/shortcodes/js/slideshow-shortcode.js',
+ 416 => 'modules/simple-payments/paypal-express-checkout.js',
+ 417 => 'modules/simple-payments/simple-payments.css',
+ 418 => 'modules/sso/jetpack-sso-login-rtl.css',
+ 419 => 'modules/sso/jetpack-sso-login-rtl.min.css',
+ 420 => 'modules/sso/jetpack-sso-login.css',
+ 421 => 'modules/sso/jetpack-sso-login.js',
+ 422 => 'modules/sso/jetpack-sso-login.min.css',
+ 423 => 'modules/subscriptions/subscriptions.css',
+ 424 => 'modules/theme-tools/compat/twentyfifteen-rtl.css',
+ 425 => 'modules/theme-tools/compat/twentyfifteen.css',
+ 426 => 'modules/theme-tools/compat/twentyfourteen-rtl.css',
+ 427 => 'modules/theme-tools/compat/twentyfourteen.css',
+ 428 => 'modules/theme-tools/compat/twentynineteen-rtl.css',
+ 429 => 'modules/theme-tools/compat/twentynineteen.css',
+ 430 => 'modules/theme-tools/compat/twentysixteen-rtl.css',
+ 431 => 'modules/theme-tools/compat/twentysixteen.css',
+ 432 => 'modules/theme-tools/compat/twentytwenty-rtl.css',
+ 433 => 'modules/theme-tools/compat/twentytwenty.css',
+ 434 => 'modules/theme-tools/compat/twentytwentyone-rtl.css',
+ 435 => 'modules/theme-tools/compat/twentytwentyone.css',
+ 436 => 'modules/theme-tools/content-options/customizer.js',
+ 437 => 'modules/theme-tools/js/suggest.js',
+ 438 => 'modules/theme-tools/responsive-videos/responsive-videos.css',
+ 439 => 'modules/theme-tools/responsive-videos/responsive-videos.js',
+ 440 => 'modules/theme-tools/responsive-videos/responsive-videos.min.js',
+ 441 => 'modules/theme-tools/site-logo/js/site-logo-header-text.js',
+ 442 => 'modules/theme-tools/site-logo/js/site-logo-header-text.min.js',
+ 443 => 'modules/theme-tools/social-menu/social-menu.css',
+ 444 => 'modules/tiled-gallery/tiled-gallery/rtl/tiled-gallery-rtl.css',
+ 445 => 'modules/tiled-gallery/tiled-gallery/tiled-gallery-rtl.css',
+ 446 => 'modules/tiled-gallery/tiled-gallery/tiled-gallery.css',
+ 447 => 'modules/tiled-gallery/tiled-gallery/tiled-gallery.js',
+ 448 => 'modules/videopress/css/editor-rtl.css',
+ 449 => 'modules/videopress/css/editor-rtl.min.css',
+ 450 => 'modules/videopress/css/editor.css',
+ 451 => 'modules/videopress/css/editor.min.css',
+ 452 => 'modules/videopress/css/videopress-editor-style-rtl.css',
+ 453 => 'modules/videopress/css/videopress-editor-style-rtl.min.css',
+ 454 => 'modules/videopress/css/videopress-editor-style.css',
+ 455 => 'modules/videopress/css/videopress-editor-style.min.css',
+ 456 => 'modules/videopress/js/editor-view.js',
+ 457 => 'modules/videopress/js/gutenberg-video-upload.js',
+ 458 => 'modules/videopress/js/media-video-widget-extensions.js',
+ 459 => 'modules/videopress/js/videopress-add-resumable-upload-support.js',
+ 460 => 'modules/videopress/js/videopress-plupload.js',
+ 461 => 'modules/videopress/js/videopress-token-bridge.js',
+ 462 => 'modules/videopress/js/videopress-uploader.js',
+ 463 => 'modules/videopress/videopress-admin-rtl.css',
+ 464 => 'modules/videopress/videopress-admin-rtl.min.css',
+ 465 => 'modules/videopress/videopress-admin.css',
+ 466 => 'modules/videopress/videopress-admin.min.css',
+ 467 => 'modules/widget-visibility/widget-conditions/rtl/widget-conditions-rtl.css',
+ 468 => 'modules/widget-visibility/widget-conditions/widget-conditions-rtl.css',
+ 469 => 'modules/widget-visibility/widget-conditions/widget-conditions-rtl.min.css',
+ 470 => 'modules/widget-visibility/widget-conditions/widget-conditions.css',
+ 471 => 'modules/widget-visibility/widget-conditions/widget-conditions.js',
+ 472 => 'modules/widget-visibility/widget-conditions/widget-conditions.min.css',
+ 473 => 'modules/widgets/authors/style.css',
+ 474 => 'modules/widgets/contact-info/contact-info-admin.js',
+ 475 => 'modules/widgets/contact-info/contact-info-map.css',
+ 476 => 'modules/widgets/customizer-controls.css',
+ 477 => 'modules/widgets/customizer-utils.js',
+ 478 => 'modules/widgets/eu-cookie-law/eu-cookie-law-admin.js',
+ 479 => 'modules/widgets/eu-cookie-law/eu-cookie-law.js',
+ 480 => 'modules/widgets/eu-cookie-law/style.css',
+ 481 => 'modules/widgets/facebook-likebox/style.css',
+ 482 => 'modules/widgets/flickr/style.css',
+ 483 => 'modules/widgets/gallery/css/admin-rtl.css',
+ 484 => 'modules/widgets/gallery/css/admin-rtl.min.css',
+ 485 => 'modules/widgets/gallery/css/admin.css',
+ 486 => 'modules/widgets/gallery/css/admin.min.css',
+ 487 => 'modules/widgets/gallery/css/rtl/admin-rtl.css',
+ 488 => 'modules/widgets/gallery/js/admin.js',
+ 489 => 'modules/widgets/gallery/js/gallery.js',
+ 490 => 'modules/widgets/goodreads/css/goodreads.css',
+ 491 => 'modules/widgets/goodreads/css/rtl/goodreads-rtl.css',
+ 492 => 'modules/widgets/google-translate/google-translate.js',
+ 493 => 'modules/widgets/gravatar-profile.css',
+ 494 => 'modules/widgets/image-widget/style.css',
+ 495 => 'modules/widgets/instagram/instagram.css',
+ 496 => 'modules/widgets/milestone/admin.js',
+ 497 => 'modules/widgets/milestone/milestone-widget.css',
+ 498 => 'modules/widgets/milestone/milestone.js',
+ 499 => 'modules/widgets/milestone/style-admin.css',
+ 500 => 'modules/widgets/my-community/style.css',
+ 501 => 'modules/widgets/simple-payments/customizer.css',
+ 502 => 'modules/widgets/simple-payments/customizer.js',
+ 503 => 'modules/widgets/simple-payments/style.css',
+ 504 => 'modules/widgets/social-icons/social-icons-admin.css',
+ 505 => 'modules/widgets/social-icons/social-icons-admin.js',
+ 506 => 'modules/widgets/social-icons/social-icons.css',
+ 507 => 'modules/widgets/social-media-icons/style.css',
+ 508 => 'modules/widgets/top-posts/style.css',
+ 509 => 'modules/widgets/twitter-timeline-admin.js',
+ 510 => 'modules/widgets/wordpress-post-widget/style.css',
+ 511 => 'modules/wordads/css/style.css',
+ 512 => 'modules/wordads/js/wordads-ccpa.js',
+ 513 => 'modules/wpgroho.js',
);
diff --git a/plugins/jetpack/modules/post-by-email/post-by-email-rtl.css b/plugins/jetpack/modules/post-by-email/post-by-email-rtl.css
index 46768086..ae71babf 100644
--- a/plugins/jetpack/modules/post-by-email/post-by-email-rtl.css
+++ b/plugins/jetpack/modules/post-by-email/post-by-email-rtl.css
@@ -1,7 +1,7 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
#jp-pbe-error {
- display: none;
+ display: none;
}
+
#post-by-email:target .jetpack-inline-message {
- background-color: #fff;
+ background-color: #fff;
}
diff --git a/plugins/jetpack/modules/post-by-email/post-by-email.min.css b/plugins/jetpack/modules/post-by-email/post-by-email.min.css
index bfb7b63f..a4e020bb 100644
--- a/plugins/jetpack/modules/post-by-email/post-by-email.min.css
+++ b/plugins/jetpack/modules/post-by-email/post-by-email.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
#jp-pbe-error{display:none}#post-by-email:target .jetpack-inline-message{background-color:#fff} \ No newline at end of file
diff --git a/plugins/jetpack/modules/protect.php b/plugins/jetpack/modules/protect.php
index bcbaf94c..e0073001 100644
--- a/plugins/jetpack/modules/protect.php
+++ b/plugins/jetpack/modules/protect.php
@@ -1,6 +1,6 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
- * Module Name: Protect
+ * Module Name: Brute force protection
* Module Description: Enabling brute force protection will prevent bots and hackers from attempting to log in to your website with common username and password combinations.
* Sort Order: 1
* Recommendation Order: 4
@@ -15,20 +15,93 @@
use Automattic\Jetpack\Constants;
-include_once JETPACK__PLUGIN_DIR . 'modules/protect/shared-functions.php';
+require_once JETPACK__PLUGIN_DIR . 'modules/protect/shared-functions.php';
+/**
+ * Jetpack project module class.
+ */
class Jetpack_Protect_Module {
- private static $__instance = null;
+ /**
+ * Instance of the class.
+ *
+ * @var Jetpack_Protect_Module()
+ */
+ private static $instance = null;
+
+ /**
+ * API Key.
+ *
+ * @var string
+ */
public $api_key;
+
+ /**
+ * API Key error.
+ *
+ * @var string
+ */
public $api_key_error;
+
+ /**
+ * Whitelisted ips
+ *
+ * @var array
+ */
public $whitelist;
+
+ /**
+ * Whitelist error.
+ *
+ * @var string
+ */
public $whitelist_error;
+
+ /**
+ * Whitelist saved
+ *
+ * @todo find out if this is even used.
+ *
+ * @var array
+ */
public $whitelist_saved;
+
+ /**
+ * The URI.
+ *
+ * @var string
+ */
private $local_host;
+
+ /**
+ * Last request.
+ *
+ * @todo find out if this is even used.
+ *
+ * @var string
+ */
public $last_request;
+
+ /**
+ * Response fetched from wp_remote_post()
+ *
+ * @var array
+ */
public $last_response_raw;
+
+ /**
+ * Last response.
+ *
+ * @todo find out if this is used.
+ * @var array
+ */
public $last_response;
+
+ /**
+ * Block login with math, default is 1.
+ *
+ * @var int
+ */
private $block_login_with_math;
/**
@@ -37,53 +110,53 @@ class Jetpack_Protect_Module {
* @return object
*/
public static function instance() {
- if ( ! is_a( self::$__instance, 'Jetpack_Protect_Module' ) ) {
- self::$__instance = new Jetpack_Protect_Module();
+ if ( ! is_a( self::$instance, 'Jetpack_Protect_Module' ) ) {
+ self::$instance = new Jetpack_Protect_Module();
}
- return self::$__instance;
+ return self::$instance;
}
/**
* Registers actions
*/
private function __construct() {
- add_action( 'jetpack_activate_module_protect', array ( $this, 'on_activation' ) );
- add_action( 'jetpack_deactivate_module_protect', array ( $this, 'on_deactivation' ) );
- add_action( 'jetpack_modules_loaded', array ( $this, 'modules_loaded' ) );
- add_action( 'login_form', array ( $this, 'check_use_math' ), 0 );
- add_filter( 'authenticate', array ( $this, 'check_preauth' ), 10, 3 );
- add_action( 'wp_login', array ( $this, 'log_successful_login' ), 10, 2 );
- add_action( 'wp_login_failed', array ( $this, 'log_failed_attempt' ) );
- add_action( 'admin_init', array ( $this, 'maybe_update_headers' ) );
- add_action( 'admin_init', array ( $this, 'maybe_display_security_warning' ) );
+ add_action( 'jetpack_activate_module_protect', array( $this, 'on_activation' ) );
+ add_action( 'jetpack_deactivate_module_protect', array( $this, 'on_deactivation' ) );
+ add_action( 'jetpack_modules_loaded', array( $this, 'modules_loaded' ) );
+ add_action( 'login_form', array( $this, 'check_use_math' ), 0 );
+ add_filter( 'authenticate', array( $this, 'check_preauth' ), 10, 3 );
+ add_action( 'wp_login', array( $this, 'log_successful_login' ), 10, 2 );
+ add_action( 'wp_login_failed', array( $this, 'log_failed_attempt' ) );
+ add_action( 'admin_init', array( $this, 'maybe_update_headers' ) );
+ add_action( 'admin_init', array( $this, 'maybe_display_security_warning' ) );
- // This is a backup in case $pagenow fails for some reason
- add_action( 'login_form', array ( $this, 'check_login_ability' ), 1 );
+ // This is a backup in case $pagenow fails for some reason.
+ add_action( 'login_form', array( $this, 'check_login_ability' ), 1 );
- // Load math fallback after math page form submission
- if ( isset( $_POST[ 'jetpack_protect_process_math_form' ] ) ) {
- include_once dirname( __FILE__ ) . '/protect/math-fallback.php';
- new Jetpack_Protect_Math_Authenticate;
+ // Load math fallback after math page form submission.
+ if ( isset( $_POST['jetpack_protect_process_math_form'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- POST request just determines if we need to use Math for Authentication.
+ include_once __DIR__ . '/protect/math-fallback.php';
+ new Jetpack_Protect_Math_Authenticate();
}
// Runs a script every day to clean up expired transients so they don't
- // clog up our users' databases
- require_once( JETPACK__PLUGIN_DIR . '/modules/protect/transient-cleanup.php' );
+ // clog up our users' databases.
+ require_once JETPACK__PLUGIN_DIR . '/modules/protect/transient-cleanup.php';
}
/**
* On module activation, try to get an api key
*/
public function on_activation() {
- if ( is_multisite() && is_main_site() && get_site_option( 'jetpack_protect_active', 0 ) == 0 ) {
+ if ( is_multisite() && is_main_site() && get_site_option( 'jetpack_protect_active', 0 ) == 0 ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
update_site_option( 'jetpack_protect_active', 1 );
}
update_site_option( 'jetpack_protect_activating', 'activating' );
- // Get BruteProtect's counter number
- Jetpack_Protect_Module::protect_call( 'check_key' );
+ // Get BruteProtect's counter number.
+ self::protect_call( 'check_key' );
}
/**
@@ -95,6 +168,9 @@ class Jetpack_Protect_Module {
}
}
+ /**
+ * Get the protect key,
+ */
public function maybe_get_protect_key() {
if ( get_site_option( 'jetpack_protect_activating', false ) && ! get_site_option( 'jetpack_protect_key', false ) ) {
$key = $this->get_protect_key();
@@ -109,23 +185,25 @@ class Jetpack_Protect_Module {
* Sends a "check_key" API call once a day. This call allows us to track IP-related
* headers for this server via the Protect API, in order to better identify the source
* IP for login attempts
+ *
+ * @param bool $force - if we're forcing the request.
*/
public function maybe_update_headers( $force = false ) {
$updated_recently = $this->get_transient( 'jpp_headers_updated_recently' );
if ( ! $force ) {
- if ( isset( $_GET['protect_update_headers'] ) ) {
+ if ( isset( $_GET['protect_update_headers'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- this doesn't change anything, just forces the once-a-day check to run via force if set.
$force = true;
}
}
// check that current user is admin so we prevent a lower level user from adding
- // a trusted header, allowing them to brute force an admin account
+ // a trusted header, allowing them to brute force an admin account.
if ( ( $updated_recently && ! $force ) || ! current_user_can( 'update_plugins' ) ) {
return;
}
- $response = Jetpack_Protect_Module::protect_call( 'check_key' );
+ $response = self::protect_call( 'check_key' );
$this->set_transient( 'jpp_headers_updated_recently', 1, DAY_IN_SECONDS );
if ( isset( $response['msg'] ) && $response['msg'] ) {
@@ -134,10 +212,13 @@ class Jetpack_Protect_Module {
}
+ /**
+ * Handle discplaying a security warning.
+ */
public function maybe_display_security_warning() {
if ( is_multisite() && current_user_can( 'manage_network' ) ) {
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
+ require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if ( ! is_plugin_active_for_network( plugin_basename( JETPACK__PLUGIN_FILE ) ) ) {
@@ -147,15 +228,21 @@ class Jetpack_Protect_Module {
}
}
+ /**
+ * Handles preparing the multisite notice.
+ */
public function prepare_jetpack_protect_multisite_notice() {
$dismissed = get_site_option( 'jetpack_dismissed_protect_multisite_banner' );
if ( $dismissed ) {
return;
}
- add_action( 'admin_notices', array ( $this, 'admin_jetpack_manage_notice' ) );
+ add_action( 'admin_notices', array( $this, 'admin_jetpack_manage_notice' ) );
}
+ /**
+ * Handle dismissing the multisite banner.
+ */
public function ajax_dismiss_handler() {
check_ajax_referer( 'jetpack_protect_multisite_banner_opt_out' );
@@ -184,7 +271,7 @@ class Jetpack_Protect_Module {
<?php esc_html_e( 'View Network Admin', 'jetpack' ); ?>
</a>
<a class="button" href="<?php echo esc_url( __( 'https://jetpack.com/support/multisite-protect', 'jetpack' ) ); ?>" target="_blank">
- <?php esc_html_e( 'Learn More' ); ?>
+ <?php esc_html_e( 'Learn More', 'jetpack' ); ?>
</a>
</p>
</div>
@@ -198,9 +285,11 @@ class Jetpack_Protect_Module {
{
_wpnonce: $( event.delegateTarget ).data( 'dismiss-nonce' ),
}
- ).fail( function( error ) { <?php
+ ).fail( function( error ) {
+ <?php
// A failure here is really strange, and there's not really anything a site owner can do to fix one.
- // Just log the error for now to help debugging. ?>
+ // Just log the error for now to help debugging.
+ ?>
if ( 'function' === typeof error.done && '-1' === error.responseText ) {
console.error( 'Notice dismissal failed: check_ajax_referer' );
@@ -221,23 +310,23 @@ class Jetpack_Protect_Module {
*/
public function get_protect_key() {
- $protect_blog_id = Jetpack_Protect_Module::get_main_blog_jetpack_id();
+ $protect_blog_id = self::get_main_blog_jetpack_id();
// If we can't find the the blog id, that means we are on multisite, and the main site never connected
- // the protect api key is linked to the main blog id - instruct the user to connect their main blog
+ // the protect api key is linked to the main blog id - instruct the user to connect their main blog.
if ( ! $protect_blog_id ) {
$this->api_key_error = __( 'Your main blog is not connected to WordPress.com. Please connect to get an API key.', 'jetpack' );
return false;
}
- $request = array (
+ $request = array(
'jetpack_blog_id' => $protect_blog_id,
'bruteprotect_api_key' => get_site_option( 'bruteprotect_api_key' ),
'multisite' => '0',
);
- // Send the number of blogs on the network if we are on multisite
+ // Send the number of blogs on the network if we are on multisite.
if ( is_multisite() ) {
$request['multisite'] = get_blog_count();
if ( ! $request['multisite'] ) {
@@ -246,14 +335,15 @@ class Jetpack_Protect_Module {
}
}
- // Request the key
+ // Request the key.
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.protect.requestKey', $request );
- // Hmm, can't talk to wordpress.com
+ // Hmm, can't talk to wordpress.com.
if ( $xml->isError() ) {
- $code = $xml->getErrorCode();
- $message = $xml->getErrorMessage();
+ $code = $xml->getErrorCode();
+ $message = $xml->getErrorMessage();
+ // Translators: The xml error code, and the xml error message.
$this->api_key_error = sprintf( __( 'Error connecting to WordPress.com. Code: %1$s, %2$s', 'jetpack' ), $code, $message );
return false;
@@ -261,14 +351,14 @@ class Jetpack_Protect_Module {
$response = $xml->getResponse();
- // Hmm. Can't talk to the protect servers ( api.bruteprotect.com )
+ // Hmm, can't talk to the protect servers ( api.bruteprotect.com ).
if ( ! isset( $response['data'] ) ) {
$this->api_key_error = __( 'No reply from Jetpack servers', 'jetpack' );
return false;
}
- // There was an issue generating the key
+ // There was an issue generating the key.
if ( empty( $response['success'] ) ) {
$this->api_key_error = $response['data'];
@@ -278,8 +368,8 @@ class Jetpack_Protect_Module {
// Key generation successful!
$active_plugins = Jetpack::get_active_plugins();
- // We only want to deactivate BruteProtect if we successfully get a key
- if ( in_array( 'bruteprotect/bruteprotect.php', $active_plugins ) ) {
+ // We only want to deactivate BruteProtect if we successfully get a key.
+ if ( in_array( 'bruteprotect/bruteprotect.php', $active_plugins, true ) ) {
Jetpack_Client_Server::deactivate_plugin( 'bruteprotect/bruteprotect.php', 'BruteProtect' );
}
@@ -294,9 +384,10 @@ class Jetpack_Protect_Module {
*
* Fires custom, plugable action jpp_log_failed_attempt with the IP
*
+ * @param string $login_user - the user attempting to log in.
* @return void
*/
- function log_failed_attempt( $login_user = null ) {
+ public function log_failed_attempt( $login_user = null ) {
/**
* Fires before every failed login attempt.
@@ -314,16 +405,15 @@ class Jetpack_Protect_Module {
if ( isset( $_COOKIE['jpp_math_pass'] ) ) {
- $transient = $this->get_transient( 'jpp_math_pass_' . $_COOKIE['jpp_math_pass'] );
+ $transient = $this->get_transient( 'jpp_math_pass_' . sanitize_key( $_COOKIE['jpp_math_pass'] ) );
$transient--;
if ( ! $transient || $transient < 1 ) {
- $this->delete_transient( 'jpp_math_pass_' . $_COOKIE['jpp_math_pass'] );
- setcookie( 'jpp_math_pass', 0, time() - DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, false );
+ $this->delete_transient( 'jpp_math_pass_' . sanitize_key( $_COOKIE['jpp_math_pass'] ) );
+ setcookie( 'jpp_math_pass', 0, time() - DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, false, true );
} else {
- $this->set_transient( 'jpp_math_pass_' . $_COOKIE['jpp_math_pass'], $transient, DAY_IN_SECONDS );
+ $this->set_transient( 'jpp_math_pass_' . sanitize_key( $_COOKIE['jpp_math_pass'] ), $transient, DAY_IN_SECONDS );
}
-
}
$this->protect_call( 'failed_attempt' );
}
@@ -339,28 +429,30 @@ class Jetpack_Protect_Module {
* Logs a successful login back to our servers, this allows us to make sure we're not blocking
* a busy IP that has a lot of good logins along with some forgotten passwords. Also saves current user's ip
* to the ip address whitelist
+ *
+ * @param string $user_login - the user loggign in.
+ * @param string $user - the user.
*/
public function log_successful_login( $user_login, $user = null ) {
if ( ! $user ) { // For do_action( 'wp_login' ) calls that lacked passing the 2nd arg.
$user = get_user_by( 'login', $user_login );
}
- $this->protect_call( 'successful_login', array ( 'roles' => $user->roles ) );
+ $this->protect_call( 'successful_login', array( 'roles' => $user->roles ) );
}
-
/**
* Checks for loginability BEFORE authentication so that bots don't get to go around the log in form.
*
* If we are using our math fallback, authenticate via math-fallback.php
*
- * @param string $user
- * @param string $username
- * @param string $password
+ * @param string $user - the user.
+ * @param string $username - the username.
+ * @param string $password - the password.
*
* @return string $user
*/
- function check_preauth( $user = 'Not Used By Protect', $username = 'Not Used By Protect', $password = 'Not Used By Protect' ) {
+ public function check_preauth( $user = 'Not Used By Protect', $username = 'Not Used By Protect', $password = 'Not Used By Protect' ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$allow_login = $this->check_login_ability( true );
$use_math = $this->get_transient( 'brute_use_math' );
@@ -368,8 +460,8 @@ class Jetpack_Protect_Module {
$this->block_with_math();
}
- if ( ( 1 == $use_math || 1 == $this->block_login_with_math ) && isset( $_POST['log'] ) ) {
- include_once dirname( __FILE__ ) . '/protect/math-fallback.php';
+ if ( ( 1 == $use_math || 1 == $this->block_login_with_math ) && isset( $_POST['log'] ) ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual, WordPress.Security.NonceVerification.Missing -- POST request just determines if we use math authentication.
+ include_once __DIR__ . '/protect/math-fallback.php';
Jetpack_Protect_Math_Authenticate::math_authenticate();
}
@@ -381,9 +473,9 @@ class Jetpack_Protect_Module {
*
* @return array
*/
- function get_headers() {
+ public function get_headers() {
$output = array();
- $ip_related_headers = array (
+ $ip_related_headers = array(
'GD_PHP_HANDLER',
'HTTP_AKAMAI_ORIGIN_HOP',
'HTTP_CF_CONNECTING_IP',
@@ -400,41 +492,41 @@ class Jetpack_Protect_Module {
'HTTP_X_IP_TRAIL',
'HTTP_X_REAL_IP',
'HTTP_X_VARNISH',
- 'REMOTE_ADDR'
+ 'REMOTE_ADDR',
);
foreach ( $ip_related_headers as $header ) {
if ( ! empty( $_SERVER[ $header ] ) ) {
- $output[ $header ] = $_SERVER[ $header ];
+ $output[ $header ] = wp_unslash( $_SERVER[ $header ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
}
}
return $output;
}
- /*
+ /**
* Checks if the IP address has been whitelisted
*
- * @param string $ip
+ * @param string $ip - the IP address.
*
* @return bool
*/
- function ip_is_whitelisted( $ip ) {
- // If we found an exact match in wp-config
- if ( defined( 'JETPACK_IP_ADDRESS_OK' ) && JETPACK_IP_ADDRESS_OK == $ip ) {
+ public function ip_is_whitelisted( $ip ) {
+ // If we found an exact match in wp-config.
+ if ( defined( 'JETPACK_IP_ADDRESS_OK' ) && JETPACK_IP_ADDRESS_OK === $ip ) {
return true;
}
$whitelist = jetpack_protect_get_local_whitelist();
if ( is_multisite() ) {
- $whitelist = array_merge( $whitelist, get_site_option( 'jetpack_protect_global_whitelist', array () ) );
+ $whitelist = array_merge( $whitelist, get_site_option( 'jetpack_protect_global_whitelist', array() ) );
}
if ( ! empty( $whitelist ) ) :
foreach ( $whitelist as $item ) :
- // If the IPs are an exact match
- if ( ! $item->range && isset( $item->ip_address ) && $item->ip_address == $ip ) {
+ // If the IPs are an exact match.
+ if ( ! $item->range && isset( $item->ip_address ) && $item->ip_address === $ip ) {
return true;
}
@@ -452,11 +544,11 @@ class Jetpack_Protect_Module {
/**
* Checks the status for a given IP. API results are cached as transients
*
- * @param bool $preauth Whether or not we are checking prior to authorization
+ * @param bool $preauth - Whether or not we are checking prior to authorization.
*
* @return bool Either returns true, fires $this->kill_login, or includes a math fallback and returns false
*/
- function check_login_ability( $preauth = false ) {
+ public function check_login_ability( $preauth = false ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
/**
* JETPACK_ALWAYS_PROTECT_LOGIN will always disable the login page, and use a page provided by Jetpack.
@@ -466,19 +558,19 @@ class Jetpack_Protect_Module {
}
if ( $this->is_current_ip_whitelisted() ) {
- return true;
- }
+ return true;
+ }
$status = $this->get_cached_status();
if ( empty( $status ) ) {
// If we've reached this point, this means that the IP isn't cached.
- // Now we check with the Protect API to see if we should allow login
- $response = $this->protect_call( $action = 'check_ip' );
+ // Now we check with the Protect API to see if we should allow login.
+ $response = $this->protect_call( $action = 'check_ip' ); // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found
if ( isset( $response['math'] ) && ! function_exists( 'brute_math_authenticate' ) ) {
- include_once dirname( __FILE__ ) . '/protect/math-fallback.php';
- new Jetpack_Protect_Math_Authenticate;
+ include_once __DIR__ . '/protect/math-fallback.php';
+ new Jetpack_Protect_Math_Authenticate();
return false;
}
@@ -486,21 +578,24 @@ class Jetpack_Protect_Module {
$status = $response['status'];
}
- if ( 'blocked' == $status ) {
+ if ( 'blocked' === $status ) {
$this->block_with_math();
}
- if ( 'blocked-hard' == $status ) {
+ if ( 'blocked-hard' === $status ) {
$this->kill_login();
}
return true;
}
- function is_current_ip_whitelisted() {
+ /**
+ * Check if IP is whitelisted.
+ */
+ public function is_current_ip_whitelisted() {
$ip = jetpack_protect_get_ip();
- // Server is misconfigured and we can't get an IP
+ // Server is misconfigured and we can't get an IP.
if ( ! $ip && class_exists( 'Jetpack' ) ) {
Jetpack::deactivate_module( 'protect' );
ob_start();
@@ -533,29 +628,38 @@ class Jetpack_Protect_Module {
if ( $this->ip_is_whitelisted( $ip ) ) {
return true;
}
- }
-
- function has_login_ability() {
- if ( $this->is_current_ip_whitelisted() ) {
- return true;
- }
- $status = $this->get_cached_status();
- if ( empty( $status ) || $status === 'ok' ) {
- return true;
- }
- return false;
- }
-
- function get_cached_status() {
- $transient_name = $this->get_transient_name();
- $value = $this->get_transient( $transient_name );
+ }
+
+ /**
+ * Check if someone is able to login based on IP.
+ */
+ public function has_login_ability() {
+ if ( $this->is_current_ip_whitelisted() ) {
+ return true;
+ }
+ $status = $this->get_cached_status();
+ if ( empty( $status ) || 'ok' === $status ) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Check the status of the cached transient.
+ */
+ public function get_cached_status() {
+ $transient_name = $this->get_transient_name();
+ $value = $this->get_transient( $transient_name );
if ( isset( $value['status'] ) ) {
- return $value['status'];
- }
- return '';
+ return $value['status'];
+ }
+ return '';
}
- function block_with_math() {
+ /**
+ * Check if we need to block with a math question to continue logging in.
+ */
+ public function block_with_math() {
/**
* By default, Protect will allow a user who has been blocked for too
* many failed logins to start answering math questions to continue logging in
@@ -580,27 +684,27 @@ class Jetpack_Protect_Module {
* @param bool true Should we fallback to the Math questions when an IP is blocked. Default to true.
*/
$allow_math_fallback_on_fail = apply_filters( 'jpp_use_captcha_when_blocked', true );
- if ( ! $allow_math_fallback_on_fail ) {
+ if ( ! $allow_math_fallback_on_fail ) {
$this->kill_login();
}
- include_once dirname( __FILE__ ) . '/protect/math-fallback.php';
- new Jetpack_Protect_Math_Authenticate;
+ include_once __DIR__ . '/protect/math-fallback.php';
+ new Jetpack_Protect_Math_Authenticate();
return false;
}
- /*
+ /**
* Kill a login attempt
*/
- function kill_login() {
+ public function kill_login() {
if (
isset( $_GET['action'], $_GET['_wpnonce'] ) &&
'logout' === $_GET['action'] &&
- wp_verify_nonce( $_GET['_wpnonce'], 'log-out' ) &&
+ wp_verify_nonce( $_GET['_wpnonce'], 'log-out' ) && // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
wp_get_current_user()
) {
- // Allow users to logout
+ // Allow users to logout.
return;
}
@@ -616,16 +720,17 @@ class Jetpack_Protect_Module {
*/
do_action( 'jpp_kill_login', $ip );
- if( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
+ if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
+ // translators: variable is the IP address that was flagged.
$die_string = sprintf( __( 'Your IP (%1$s) has been flagged for potential security violations.', 'jetpack' ), str_replace( 'http://', '', esc_url( 'http://' . $ip ) ) );
wp_die(
- $die_string,
- __( 'Login Blocked by Jetpack', 'jetpack' ),
- array ( 'response' => 403 )
+ $die_string, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- esc_url used when forming string.
+ esc_html__( 'Login Blocked by Jetpack', 'jetpack' ),
+ array( 'response' => 403 )
);
}
- require_once dirname( __FILE__ ) . '/protect/blocked-login-page.php';
+ require_once __DIR__ . '/protect/blocked-login-page.php';
$blocked_login_page = Jetpack_Protect_Blocked_Login_Page::instance( $ip );
if ( $blocked_login_page->is_blocked_user_valid() ) {
@@ -635,14 +740,14 @@ class Jetpack_Protect_Module {
$blocked_login_page->render_and_die();
}
- /*
+ /**
* Checks if the protect API call has failed, and if so initiates the math captcha fallback.
*/
public function check_use_math() {
$use_math = $this->get_transient( 'brute_use_math' );
if ( $use_math ) {
- include_once dirname( __FILE__ ) . '/protect/math-fallback.php';
- new Jetpack_Protect_Math_Authenticate;
+ include_once __DIR__ . '/protect/math-fallback.php';
+ new Jetpack_Protect_Math_Authenticate();
}
}
@@ -679,6 +784,9 @@ class Jetpack_Protect_Module {
return $id;
}
+ /**
+ * Checks the API key.
+ */
public function check_api_key() {
$response = $this->protect_call( 'check_key' );
@@ -688,11 +796,11 @@ class Jetpack_Protect_Module {
if ( isset( $response['error'] ) ) {
- if ( $response['error'] == 'Invalid API Key' ) {
+ if ( 'Invalid API Key' === $response['error'] ) {
$this->api_key_error = __( 'Your API key is invalid', 'jetpack' );
}
- if ( $response['error'] == 'API Key Required' ) {
+ if ( 'API Key Required' === $response['error'] ) {
$this->api_key_error = __( 'No API key', 'jetpack' );
}
}
@@ -705,12 +813,12 @@ class Jetpack_Protect_Module {
/**
* Calls over to the api using wp_remote_post
*
- * @param string $action 'check_ip', 'check_key', or 'failed_attempt'
- * @param array $request Any custom data to post to the api
+ * @param string $action - 'check_ip', 'check_key', or 'failed_attempt'.
+ * @param array $request - Any custom data to post to the api.
*
* @return array
*/
- function protect_call( $action = 'check_ip', $request = array () ) {
+ public function protect_call( $action = 'check_ip', $request = array() ) {
global $wp_version;
$api_key = $this->maybe_get_protect_key();
@@ -720,17 +828,16 @@ class Jetpack_Protect_Module {
$request['action'] = $action;
$request['ip'] = jetpack_protect_get_ip();
$request['host'] = $this->get_local_host();
- $request['headers'] = json_encode( $this->get_headers() );
+ $request['headers'] = wp_json_encode( $this->get_headers() );
$request['jetpack_version'] = constant( 'JETPACK__VERSION' );
- $request['wordpress_version'] = (string) $wp_version ;
+ $request['wordpress_version'] = (string) $wp_version;
$request['api_key'] = $api_key;
- $request['multisite'] = "0";
+ $request['multisite'] = '0';
if ( is_multisite() ) {
$request['multisite'] = get_blog_count();
}
-
/**
* Filter controls maximum timeout in waiting for reponse from Protect servers.
*
@@ -742,11 +849,11 @@ class Jetpack_Protect_Module {
*/
$timeout = apply_filters( 'jetpack_protect_connect_timeout', 30 );
- $args = array (
+ $args = array(
'body' => $request,
'user-agent' => $user_agent,
'httpversion' => '1.0',
- 'timeout' => absint( $timeout )
+ 'timeout' => absint( $timeout ),
);
$response_json = wp_remote_post( JETPACK_PROTECT__API_HOST, $args );
@@ -767,7 +874,7 @@ class Jetpack_Protect_Module {
$response['expire'] = time() + $response['seconds_remaining'];
$this->set_transient( $transient_name, $response, $response['seconds_remaining'] );
$this->delete_transient( 'brute_use_math' );
- } else { // Fallback to Math Captcha if no response from API host
+ } else { // Fallback to Math Captcha if no response from API host.
$this->set_transient( 'brute_use_math', 1, 600 );
$response['status'] = 'ok';
$response['math'] = true;
@@ -782,9 +889,12 @@ class Jetpack_Protect_Module {
return $response;
}
- function get_transient_name() {
+ /**
+ * Gets the transient name.
+ */
+ public function get_transient_name() {
$headers = $this->get_headers();
- $header_hash = md5( json_encode( $headers ) );
+ $header_hash = md5( wp_json_encode( $headers ) );
return 'jpp_li_' . $header_hash;
}
@@ -799,13 +909,13 @@ class Jetpack_Protect_Module {
*
* @param string $transient Transient name. Expected to not be SQL-escaped. Must be
* 45 characters or fewer in length.
- * @param mixed $value Transient value. Must be serializable if non-scalar.
- * Expected to not be SQL-escaped.
- * @param int $expiration Optional. Time until expiration in seconds. Default 0.
+ * @param mixed $value Transient value. Must be serializable if non-scalar.
+ * Expected to not be SQL-escaped.
+ * @param int $expiration Optional. Time until expiration in seconds. Default 0.
*
* @return bool False if value was not set and true if value was set.
*/
- function set_transient( $transient, $value, $expiration ) {
+ public function set_transient( $transient, $value, $expiration ) {
if ( is_multisite() && ! is_main_site() ) {
switch_to_blog( $this->get_main_blog_id() );
$return = set_transient( $transient, $value, $expiration );
@@ -825,7 +935,7 @@ class Jetpack_Protect_Module {
*
* @return bool true if successful, false otherwise
*/
- function delete_transient( $transient ) {
+ public function delete_transient( $transient ) {
if ( is_multisite() && ! is_main_site() ) {
switch_to_blog( $this->get_main_blog_id() );
$return = delete_transient( $transient );
@@ -845,7 +955,7 @@ class Jetpack_Protect_Module {
*
* @return mixed Value of transient.
*/
- function get_transient( $transient ) {
+ public function get_transient( $transient ) {
if ( is_multisite() && ! is_main_site() ) {
switch_to_blog( $this->get_main_blog_id() );
$return = get_transient( $transient );
@@ -857,12 +967,15 @@ class Jetpack_Protect_Module {
return get_transient( $transient );
}
- function get_local_host() {
+ /**
+ * Returns the local host.
+ */
+ public function get_local_host() {
if ( isset( $this->local_host ) ) {
return $this->local_host;
}
- $uri = 'http://' . strtolower( $_SERVER['HTTP_HOST'] );
+ $uri = 'http://' . strtolower( isset( $_SERVER['HTTP_HOST'] ) ? filter_var( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '' );
if ( is_multisite() ) {
$uri = network_home_url();
@@ -872,7 +985,7 @@ class Jetpack_Protect_Module {
$domain = $uridata['host'];
- // If we still don't have the site_url, get it
+ // If we still don't have the site_url, get it.
if ( ! $domain ) {
$uri = get_site_url( 1 );
$uridata = wp_parse_url( $uri );
diff --git a/plugins/jetpack/modules/protect/blocked-login-page.php b/plugins/jetpack/modules/protect/blocked-login-page.php
index f6789e4b..70778987 100644
--- a/plugins/jetpack/modules/protect/blocked-login-page.php
+++ b/plugins/jetpack/modules/protect/blocked-login-page.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore - WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Connection\Client;
use Automattic\Jetpack\Redirect;
@@ -10,15 +10,42 @@ use Automattic\Jetpack\Redirect;
* is available, or during the login_head hook.
*
* Class will only be instanciated if Protect has detected a hard blocked IP address.
- *
- *
*/
class Jetpack_Protect_Blocked_Login_Page {
- private static $__instance = null;
+ /**
+ * Instance of the class.
+ *
+ * @var Jetpack_Protect_Blocked_Login_Page
+ */
+ private static $instance = null;
+
+ /**
+ * Can send recovery emails. defaults to true.
+ *
+ * @var bool
+ */
public $can_send_recovery_emails;
+
+ /**
+ * The IP address.
+ *
+ * @var string
+ */
public $ip_address;
+
+ /**
+ * Valid blocked user ID.
+ *
+ * @var int
+ */
public $valid_blocked_user_id;
+
+ /**
+ * The email address.
+ *
+ * @var string
+ */
public $email_address;
/**
@@ -29,24 +56,30 @@ class Jetpack_Protect_Blocked_Login_Page {
*
* @var string string $HELP_URL
*/
- const HELP_URL = 'https://jetpack.com/support/security-features/#unblock';
+ const HELP_URL = 'https://jetpack.com/support/security-features/#unblock';
const HTTP_STATUS_CODE_TOO_MANY_REQUESTS = 429;
/**
* Singleton implementation
*
+ * @param string $ip_address - the IP address.
+ *
* @return object
*/
public static function instance( $ip_address ) {
- if ( ! is_a( self::$__instance, 'Jetpack_Protect_Blocked_Login_Page' ) ) {
- self::$__instance = new Jetpack_Protect_Blocked_Login_Page( $ip_address );
+ if ( ! is_a( self::$instance, 'Jetpack_Protect_Blocked_Login_Page' ) ) {
+ self::$instance = new Jetpack_Protect_Blocked_Login_Page( $ip_address );
}
- return self::$__instance;
+ return self::$instance;
}
-
- function __construct( $ip_address ) {
+ /**
+ * Singleton implementation
+ *
+ * @param string $ip_address - the IP address.
+ */
+ public function __construct( $ip_address ) {
/**
* Filter controls if an email recovery form is shown to blocked IPs.
*
@@ -81,13 +114,18 @@ class Jetpack_Protect_Blocked_Login_Page {
return Redirect::get_url( 'jetpack-support-security-features', array( 'anchor' => 'unblock' ) );
}
+ /**
+ * Add arguments to lost password redirect url.
+ *
+ * @param string $url - the URL.
+ */
public function add_args_to_lostpassword_redirect_url( $url ) {
if ( $this->valid_blocked_user_id ) {
$url = empty( $url ) ? wp_login_url() : $url;
$url = add_query_arg(
array(
- 'validate_jetpack_protect_recovery' => $_GET['validate_jetpack_protect_recovery'],
- 'user_id' => $_GET['user_id'],
+ 'validate_jetpack_protect_recovery' => isset( $_GET['validate_jetpack_protect_recovery'] ) ? filter_var( wp_unslash( $_GET['validate_jetpack_protect_recovery'] ) ) : null, // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nothing on the site is changed in response to this request.
+ 'user_id' => isset( $_GET['user_id'] ) ? (int) $_GET['user_id'] : null, // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nothing on the site is changed in response to this request.
'checkemail' => 'confirm',
),
$url
@@ -97,11 +135,17 @@ class Jetpack_Protect_Blocked_Login_Page {
return $url;
}
+ /**
+ * Add arguments to lost password redirect url.
+ *
+ * @param string $url - the URL.
+ * @param string $redirect - where to redirect to.
+ */
public function add_args_to_lostpassword_url( $url, $redirect ) {
if ( $this->valid_blocked_user_id ) {
$args = array(
- 'validate_jetpack_protect_recovery' => $_GET['validate_jetpack_protect_recovery'],
- 'user_id' => $_GET['user_id'],
+ 'validate_jetpack_protect_recovery' => isset( $_GET['validate_jetpack_protect_recovery'] ) ? filter_var( wp_unslash( $_GET['validate_jetpack_protect_recovery'] ) ) : null, // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nothing on the site is changed in response to this request.
+ 'user_id' => isset( $_GET['user_id'] ) ? (int) $_GET['user_id'] : null, // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nothing on the site is changed in response to this request.
'action' => 'lostpassword',
);
if ( ! empty( $redirect ) ) {
@@ -113,12 +157,19 @@ class Jetpack_Protect_Blocked_Login_Page {
return $url;
}
+ /**
+ * Add arguments to login post url.
+ *
+ * @param string $url - the URL.
+ * @param string $path - the path.
+ * @param string $scheme -the scheme(?).
+ */
public function add_args_to_login_post_url( $url, $path, $scheme ) {
if ( $this->valid_blocked_user_id && ( 'login_post' === $scheme || 'login' === $scheme ) ) {
$url = add_query_arg(
array(
- 'validate_jetpack_protect_recovery' => $_GET['validate_jetpack_protect_recovery'],
- 'user_id' => $_GET['user_id'],
+ 'validate_jetpack_protect_recovery' => isset( $_GET['validate_jetpack_protect_recovery'] ) ? filter_var( wp_unslash( $_GET['validate_jetpack_protect_recovery'] ) ) : null, // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nothing on the site is changed in response to this request.
+ 'user_id' => isset( $_GET['user_id'] ) ? (int) $_GET['user_id'] : null, // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nothing on the site is changed in response to this request.
),
$url
);
@@ -128,11 +179,18 @@ class Jetpack_Protect_Blocked_Login_Page {
return $url;
}
+ /**
+ * Add arguments to login post url.
+ *
+ * @param string $url - the URL.
+ * @param string $redirect - where we want to redirect to.
+ * @param string $force_reauth -if we're forcing reauthorization.
+ */
public function add_args_to_login_url( $url, $redirect, $force_reauth ) {
if ( $this->valid_blocked_user_id ) {
$args = array(
- 'validate_jetpack_protect_recovery' => $_GET['validate_jetpack_protect_recovery'],
- 'user_id' => $_GET['user_id'],
+ 'validate_jetpack_protect_recovery' => isset( $_GET['validate_jetpack_protect_recovery'] ) ? filter_var( wp_unslash( $_GET['validate_jetpack_protect_recovery'] ) ) : null, // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nothing on the site is changed in response to this request.
+ 'user_id' => isset( $_GET['user_id'] ) ? (int) $_GET['user_id'] : null, // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nothing on the site is changed in response to this request.
);
if ( ! empty( $redirect ) ) {
@@ -148,14 +206,22 @@ class Jetpack_Protect_Blocked_Login_Page {
return $url;
}
+ /**
+ * Check if user is blocked.
+ *
+ * @param string $user - the user.
+ */
public function check_valid_blocked_user( $user ) {
- if ( $this->valid_blocked_user_id && $this->valid_blocked_user_id != $user->ID ) {
+ if ( $this->valid_blocked_user_id && $this->valid_blocked_user_id != $user->ID ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
return new WP_Error( 'invalid_recovery_token', __( 'The recovery token is not valid for this user.', 'jetpack' ) );
}
return $user;
}
+ /**
+ * Check if user is valid.
+ */
public function is_blocked_user_valid() {
if ( ! $this->can_send_recovery_emails ) {
return false;
@@ -165,19 +231,25 @@ class Jetpack_Protect_Blocked_Login_Page {
return true;
}
- if ( ! isset( $_GET['validate_jetpack_protect_recovery'], $_GET['user_id'] ) ) {
+ if ( ! isset( $_GET['validate_jetpack_protect_recovery'], $_GET['user_id'] ) ) { // phpcs:ignore: WordPress.Security.NonceVerification.Recommended -- no changes made if this isn't set.
return false;
}
- if ( ! $this->is_valid_protect_recovery_key( $_GET['validate_jetpack_protect_recovery'], $_GET['user_id'] ) ) {
+ if ( ! $this->is_valid_protect_recovery_key( filter_var( wp_unslash( $_GET['validate_jetpack_protect_recovery'] ) ), (int) $_GET['user_id'] ) ) { // phpcs:ignore: WordPress.Security.NonceVerification.Recommended -- no changes made if this isn't set.
return false;
}
- $this->valid_blocked_user_id = (int) $_GET['user_id'];
+ $this->valid_blocked_user_id = (int) $_GET['user_id']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nothing on the site is changed in response to this request.
return true;
}
+ /**
+ * Checks if recovery key is valid.
+ *
+ * @param string $key - they recovery key.
+ * @param string $user_id - the User ID.
+ */
public function is_valid_protect_recovery_key( $key, $user_id ) {
$path = sprintf( '/sites/%d/protect/recovery/confirm', Jetpack::get_option( 'id' ) );
@@ -185,7 +257,7 @@ class Jetpack_Protect_Blocked_Login_Page {
$path,
'1.1',
array(
- 'method' => 'post'
+ 'method' => 'post',
),
array(
'token' => $key,
@@ -203,6 +275,9 @@ class Jetpack_Protect_Blocked_Login_Page {
return true;
}
+ /**
+ * Check if we should render the recovery form.
+ */
public function render_and_die() {
if ( ! $this->can_send_recovery_emails ) {
$this->render_blocked_login_message();
@@ -210,7 +285,7 @@ class Jetpack_Protect_Blocked_Login_Page {
return;
}
- if ( isset( $_GET['validate_jetpack_protect_recovery'] ) && $_GET['user_id'] ) {
+ if ( isset( $_GET['validate_jetpack_protect_recovery'] ) && ! empty( $_GET['user_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no site changes, just throws invalid token error.
$error = new WP_Error( 'invalid_token', __( "Oops, we couldn't validate the recovery token.", 'jetpack' ) );
$this->protect_die( $error );
@@ -220,7 +295,7 @@ class Jetpack_Protect_Blocked_Login_Page {
if (
isset( $_GET['jetpack-protect-recovery'] ) &&
isset( $_POST['_wpnonce'] ) &&
- wp_verify_nonce( $_POST['_wpnonce'], 'bypass-protect' )
+ wp_verify_nonce( $_POST['_wpnonce'], 'bypass-protect' ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- WP Core doesn't unstrip or sanitize nonces either.
) {
$this->process_recovery_email();
@@ -234,25 +309,34 @@ class Jetpack_Protect_Blocked_Login_Page {
$this->render_recovery_form();
}
+ /**
+ * Render the blocked login message.
+ */
public function render_blocked_login_message() {
$this->protect_die( $this->get_html_blocked_login_message() );
}
- function process_recovery_email() {
- $sent = $this->send_recovery_email();
+ /**
+ * Process sending a recovery email.
+ */
+ public function process_recovery_email() {
+ $sent = $this->send_recovery_email();
$show_recovery_form = true;
if ( is_wp_error( $sent ) ) {
if ( 'email_already_sent' === $sent->get_error_code() ) {
$show_recovery_form = false;
}
- $this->protect_die( $sent,null,true, $show_recovery_form );
+ $this->protect_die( $sent, null, true, $show_recovery_form );
} else {
$this->render_recovery_success();
}
}
- function send_recovery_email() {
- $email = isset( $_POST['email'] ) ? $_POST['email'] : '';
+ /**
+ * Send the recovery form.
+ */
+ public function send_recovery_email() {
+ $email = isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- only triggered after bypass-protect nonce check is done, and sanitization is checked on the next line.
if ( sanitize_email( $email ) !== $email || ! is_email( $email ) ) {
return new WP_Error( 'invalid_email', __( "Oops, looks like that's not the right email address. Please try again!", 'jetpack' ) );
}
@@ -264,16 +348,15 @@ class Jetpack_Protect_Blocked_Login_Page {
$this->email_address = $email;
$path = sprintf( '/sites/%d/protect/recovery/request', Jetpack::get_option( 'id' ) );
-
$response = Client::wpcom_json_api_request_as_blog(
$path,
'1.1',
array(
- 'method' => 'post'
+ 'method' => 'post',
),
array(
'user_id' => $user->ID,
- 'ip' => $this->ip_address
+ 'ip' => $this->ip_address,
)
);
@@ -281,65 +364,87 @@ class Jetpack_Protect_Blocked_Login_Page {
$result = json_decode( wp_remote_retrieve_body( $response ) );
if ( self::HTTP_STATUS_CODE_TOO_MANY_REQUESTS === $code ) {
+ // translators: email address the recovery instructions were sent to.
return new WP_Error( 'email_already_sent', sprintf( __( 'Recovery instructions were sent to %s. Check your inbox!', 'jetpack' ), $this->email_address ) );
- } else if ( is_wp_error( $result ) || empty( $result ) || isset( $result->error ) ) {
+ } elseif ( is_wp_error( $result ) || empty( $result ) || isset( $result->error ) ) {
return new WP_Error( 'email_send_error', __( 'Oops, we were unable to send a recovery email. Try again.', 'jetpack' ) );
}
return true;
}
- function protect_die( $content, $title = null, $back_link = false, $recovery_form = false ) {
+ /**
+ * Prevent login by locking the login page.
+ *
+ * @param string $content - the content of the page.
+ * @param string $title - the page title.
+ * @param string $back_link - the back link.
+ * @param string $recovery_form - the recovery form.
+ */
+ public function protect_die( $content, $title = null, $back_link = false, $recovery_form = false ) {
if ( empty( $title ) ) {
$title = __( 'Jetpack has locked your site\'s login page.', 'jetpack' );
}
if ( is_wp_error( $content ) ) {
- $svg = '<svg class="gridicon gridicons-notice" height="24" width="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 15h-2v-2h2v2zm0-4h-2l-.5-6h3l-.5 6z"/></g></svg>';
- $content = '<span class="error"> '. $svg . $content->get_error_message() . '</span>';
+ $svg = '<svg class="gridicon gridicons-notice" height="24" width="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 15h-2v-2h2v2zm0-4h-2l-.5-6h3l-.5 6z"/></g></svg>';
+ $content = '<span class="error"> ' . $svg . $content->get_error_message() . '</span>';
}
- $content = '<p>'. $content .'</p>';
+ $content = '<p>' . $content . '</p>';
// If for some reason the login pop up box show up in the wp-admin.
- if ( isset( $_GET['interim-login'] ) ) {
- $content = "<style>html{ background-color: #fff; } #error-message { margin:0 auto; padding: 1em; box-shadow: none; } </style>" . $content;
+ if ( isset( $_GET['interim-login'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- no changes to the site itself, just rendering an error message.
+ $content = '<style>html{ background-color: #fff; } #error-message { margin:0 auto; padding: 1em; box-shadow: none; } </style>' . $content;
}
$this->display_page( $title, $content, $back_link, $recovery_form );
}
- function render_recovery_form() {
+ /**
+ * Render the recovery form.
+ */
+ public function render_recovery_form() {
$content = $this->get_html_blocked_login_message();
$this->protect_die( $content, null, null, true );
}
- function render_recovery_success() {
+ /**
+ * Render the recovery instructions.
+ */
+ public function render_recovery_success() {
+ // translators: the email address the recovery email was sent to.
$this->protect_die( sprintf( __( 'Recovery instructions were sent to %s. Check your inbox!', 'jetpack' ), $this->email_address ) );
}
-
- function get_html_blocked_login_message() {
+ /**
+ * Get the HTML for the blocked login message.
+ */
+ public function get_html_blocked_login_message() {
$icon = '<svg class="gridicon gridicons-spam" style="fill:#d94f4f" height="24" width="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g><path d="M17 2H7L2 7v10l5 5h10l5-5V7l-5-5zm-4 15h-2v-2h2v2zm0-4h-2l-.5-6h3l-.5 6z"/></g></svg>';
- $ip = str_replace( 'http://', '', esc_url( 'http://' . $this->ip_address ) );
+ $ip = str_replace( 'http://', '', esc_url( 'http://' . $this->ip_address ) );
return sprintf(
- __( '<p>Your IP address <code>%2$s</code> has been flagged for potential security violations. You can unlock your login by sending yourself a special link via email. <a href="%3$s">Learn More</a></p>', 'jetpack' ),
+ // translators: the IP address that was flagged.
+ __( '<p>Your IP address <code>%2$s</code> has been flagged for potential security violations. You can unlock your login by sending yourself a special link via email. <a href="%3$s">Learn More</a></p>', 'jetpack' ), // phpcs:ignore WordPress.WP.I18n.NoHtmlWrappedStrings
$icon,
$ip,
esc_url( self::get_help_url() )
);
}
- function get_html_recovery_form() {
+ /**
+ * Get the HTML recovery form.
+ */
+ public function get_html_recovery_form() {
ob_start(); ?>
- <div>
- <form method="post" action="?jetpack-protect-recovery=true">
- <?php echo wp_nonce_field( 'bypass-protect' ); ?>
- <p><label for="email"><?php esc_html_e( 'Your email', 'jetpack' ); ?><br/></label>
- <input type="email" name="email" class="text-input"/>
- <input type="submit" class="button"
- value="<?php esc_attr_e( 'Send email', 'jetpack' ); ?>"/>
- </p>
- </form>
- </div>
+ <div>
+ <form method="post" action="?jetpack-protect-recovery=true">
+ <?php wp_nonce_field( 'bypass-protect' ); ?>
+ <p><label for="email"><?php esc_html_e( 'Your email', 'jetpack' ); ?><br/></label>
+ <input type="email" name="email" class="text-input"/>
+ <input type="submit" class="button"
+ value="<?php esc_attr_e( 'Send email', 'jetpack' ); ?>"/>
+ </p>
+ </form>
+ </div>
<?php
$contents = ob_get_contents();
@@ -348,7 +453,15 @@ class Jetpack_Protect_Blocked_Login_Page {
return $contents;
}
- function display_page( $title, $message, $back_button = false, $recovery_form = false ) {
+ /**
+ * Display the page.
+ *
+ * @param string $title - the page title.
+ * @param string $message - the message we're sending.
+ * @param string $back_button - the back button.
+ * @param string $recovery_form - the recovery form.
+ */
+ public function display_page( $title, $message, $back_button = false, $recovery_form = false ) {
if ( ! headers_sent() ) {
nocache_headers();
@@ -361,11 +474,15 @@ class Jetpack_Protect_Blocked_Login_Page {
}
?>
<!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) {
+ <html xmlns="http://www.w3.org/1999/xhtml"
+ <?php
+ if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) {
language_attributes();
} else {
- echo "dir='$text_direction'";
- } ?>>
+ echo "dir='$text_direction'"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ }
+ ?>
+ >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width">
@@ -376,7 +493,7 @@ class Jetpack_Protect_Blocked_Login_Page {
echo "<meta name='robots' content='noindex,nofollow' />\n";
}
?>
- <title><?php echo $title ?></title>
+ <title><?php echo esc_html( $title ); ?></title>
<style type="text/css">
html {
background: #f6f6f6;
@@ -573,14 +690,14 @@ class Jetpack_Protect_Blocked_Login_Page {
}
<?php
$rtl_class = '';
- if ( 'rtl' == $text_direction ) {
+ if ( 'rtl' === $text_direction ) {
$rtl_class = 'class="is-rtl"';
echo 'body { font-family: Tahoma, Arial; }';
}
?>
</style>
</head>
- <body id="error-page" <?php echo $rtl_class; ?>>
+ <body id="error-page" <?php echo $rtl_class; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<h1 id="error-title"><?php echo esc_html( $title ); ?></h1>
<div id="error-message">
<svg id="image" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 250 134">
@@ -608,10 +725,12 @@ class Jetpack_Protect_Blocked_Login_Page {
<path fill="#86A6BD" d="M48.1,121.4l2.9-6.2c0.3-0.6,0.2-1.3-0.3-1.8c-1-1-1.5-2.5-1.2-4c0.3-1.7,1.7-3.1,3.4-3.4 c2.9-0.6,5.4,1.6,5.4,4.4c0,1.2-0.5,2.3-1.3,3.1c-0.5,0.5-0.6,1.2-0.3,1.8l2.9,6.2c0.1,0.2-0.1,0.5-0.3,0.5H48.4 C48.1,121.9,48,121.6,48.1,121.4"/>
</svg>
- <?php echo $message; ?>
- <?php if ( $recovery_form ) {
- echo $this->get_html_recovery_form();
- } ?>
+ <?php echo $message; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- message includes HTML that's marked up ourselves. ?>
+ <?php
+ if ( $recovery_form ) {
+ echo $this->get_html_recovery_form(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- content is escaped in the function.
+ }
+ ?>
</div>
<div id="error-footer">
<?php
@@ -633,7 +752,8 @@ class Jetpack_Protect_Blocked_Login_Page {
</a>
<?php
} else {
- $help_icon = '<svg class="gridicon gridicons-help" height="24" width="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 16h-2v-2h2v2zm0-4.14V15h-2v-2c0-.552.448-1 1-1 1.103 0 2-.897 2-2s-.897-2-2-2-2 .897-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 1.862-1.278 3.413-3 3.86z"/></g></svg>';?>
+ $help_icon = '<svg class="gridicon gridicons-help" height="24" width="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 16h-2v-2h2v2zm0-4.14V15h-2v-2c0-.552.448-1 1-1 1.103 0 2-.897 2-2s-.897-2-2-2-2 .897-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 1.862-1.278 3.413-3 3.86z"/></g></svg>';
+ ?>
<a href="<?php echo esc_url( self::get_help_url() ); ?>" rel="noopener noreferrer" target="_blank">
<?php
printf(
diff --git a/plugins/jetpack/modules/protect/math-fallback.php b/plugins/jetpack/modules/protect/math-fallback.php
index 9ee0d77c..84cff44a 100644
--- a/plugins/jetpack/modules/protect/math-fallback.php
+++ b/plugins/jetpack/modules/protect/math-fallback.php
@@ -1,14 +1,22 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
if ( ! class_exists( 'Jetpack_Protect_Math_Authenticate' ) ) {
- /*
+ /**
* The math captcha fallback if we can't talk to the Protect API
*/
class Jetpack_Protect_Math_Authenticate {
- static $loaded;
+ /**
+ * If the class is loaded.
+ *
+ * @var bool
+ */
+ public static $loaded;
- function __construct() {
+ /**
+ * Class constructor.
+ */
+ public function __construct() {
if ( self::$loaded ) {
return;
@@ -18,11 +26,14 @@ if ( ! class_exists( 'Jetpack_Protect_Math_Authenticate' ) ) {
add_action( 'login_form', array( $this, 'math_form' ) );
- if( isset( $_POST[ 'jetpack_protect_process_math_form' ] ) ) {
+ if ( isset( $_POST['jetpack_protect_process_math_form'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- No changes made, just queues the math authenticator hook.
add_action( 'init', array( $this, 'process_generate_math_page' ) );
}
}
+ /**
+ * The timeout window.
+ */
private static function time_window() {
return ceil( time() / ( MINUTE_IN_SECONDS * 2 ) );
}
@@ -31,30 +42,30 @@ if ( ! class_exists( 'Jetpack_Protect_Math_Authenticate' ) ) {
* Verifies that a user answered the math problem correctly while logging in.
*
* @return bool Returns true if the math is correct
- * @throws Error if insuffient $_POST variables are present.
- * @throws Error message if the math is wrong
+ * @throws Error If insuffient $_POST variables are present.
+ * @throws Error Message if the math is wrong.
*/
- static function math_authenticate() {
- if( isset( $_COOKIE[ 'jpp_math_pass' ] ) ) {
+ public static function math_authenticate() {
+ if ( isset( $_COOKIE['jpp_math_pass'] ) ) {
$jetpack_protect = Jetpack_Protect_Module::instance();
- $transient = $jetpack_protect->get_transient( 'jpp_math_pass_' . $_COOKIE[ 'jpp_math_pass' ] );
+ $transient = $jetpack_protect->get_transient( 'jpp_math_pass_' . sanitize_key( $_COOKIE['jpp_math_pass'] ) );
- if( !$transient || $transient < 1 ) {
- Jetpack_Protect_Math_Authenticate::generate_math_page();
+ if ( ! $transient || $transient < 1 ) {
+ self::generate_math_page();
}
return true;
}
- $ans = isset( $_POST['jetpack_protect_num'] ) ? (int) $_POST['jetpack_protect_num'] : '' ;
- $correct_ans = isset( $_POST[ 'jetpack_protect_answer' ] ) ? $_POST[ 'jetpack_protect_answer' ] : '' ;
+ $ans = isset( $_POST['jetpack_protect_num'] ) ? (int) $_POST['jetpack_protect_num'] : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing -- answers are salted.
+ $correct_ans = isset( $_POST['jetpack_protect_answer'] ) ? sanitize_key( $_POST['jetpack_protect_answer'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
- $time_window = Jetpack_Protect_Math_Authenticate::time_window();
+ $time_window = self::time_window();
$salt = get_site_option( 'jetpack_protect_key' ) . '|' . get_site_option( 'admin_email' ) . '|';
$salted_ans_1 = hash_hmac( 'sha1', $ans, $salt . $time_window );
$salted_ans_2 = hash_hmac( 'sha1', $ans, $salt . ( $time_window - 1 ) );
if ( ! $correct_ans || ! $ans ) {
- Jetpack_Protect_Math_Authenticate::generate_math_page();
+ self::generate_math_page();
} elseif ( ! hash_equals( $salted_ans_1, $correct_ans ) && ! hash_equals( $salted_ans_2, $correct_ans ) ) {
wp_die(
wp_kses(
@@ -75,48 +86,51 @@ if ( ! class_exists( 'Jetpack_Protect_Math_Authenticate' ) ) {
/**
* Creates an interim page to collect answers to a math captcha
*
- * @return none, execution stopped
+ * @param string $error - the error message.
*/
- static function generate_math_page( $error = false ) {
+ public static function generate_math_page( $error = false ) {
ob_start();
?>
<h2><?php esc_html_e( 'Please solve this math problem to prove that you are not a bot. Once you solve it, you will need to log in again.', 'jetpack' ); ?></h2>
- <?php if ($error): ?>
+ <?php if ( $error ) : ?>
<h3><?php esc_html_e( 'Your answer was incorrect, please try again.', 'jetpack' ); ?></h3>
<?php endif ?>
- <form action="<?php echo wp_login_url(); ?>" method="post" accept-charset="utf-8">
- <?php Jetpack_Protect_Math_Authenticate::math_form(); ?>
+ <form action="<?php echo esc_url( wp_login_url() ); ?>" method="post" accept-charset="utf-8">
+ <?php self::math_form(); ?>
<input type="hidden" name="jetpack_protect_process_math_form" value="1" id="jetpack_protect_process_math_form" />
<p><input type="submit" value="<?php esc_attr_e( 'Continue &rarr;', 'jetpack' ); ?>"></p>
</form>
- <?php
+ <?php
$mathpage = ob_get_contents();
ob_end_clean();
wp_die(
- $mathpage,
+ $mathpage, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- content is escaped.
'',
- array ( 'response' => 401 )
+ array( 'response' => 401 )
);
}
+ /**
+ * Generates the math page.
+ */
public function process_generate_math_page() {
- $ans = isset( $_POST['jetpack_protect_num'] ) ? (int)$_POST['jetpack_protect_num'] : '';
- $correct_ans = isset( $_POST[ 'jetpack_protect_answer' ] ) ? $_POST[ 'jetpack_protect_answer' ] : '' ;
+ $ans = isset( $_POST['jetpack_protect_num'] ) ? (int) $_POST['jetpack_protect_num'] : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing -- answers are salted.
+ $correct_ans = isset( $_POST['jetpack_protect_answer'] ) ? sanitize_key( $_POST['jetpack_protect_answer'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
- $time_window = Jetpack_Protect_Math_Authenticate::time_window();
+ $time_window = self::time_window();
$salt = get_site_option( 'jetpack_protect_key' ) . '|' . get_site_option( 'admin_email' ) . '|';
$salted_ans_1 = hash_hmac( 'sha1', $ans, $salt . $time_window );
$salted_ans_2 = hash_hmac( 'sha1', $ans, $salt . ( $time_window - 1 ) );
if ( ! hash_equals( $salted_ans_1, $correct_ans ) && ! hash_equals( $salted_ans_2, $correct_ans ) ) {
- Jetpack_Protect_Math_Authenticate::generate_math_page(true);
+ self::generate_math_page( true );
} else {
- $temp_pass = substr( hash_hmac( 'sha1', rand( 1, 100000000 ), get_site_option( 'jetpack_protect_key' ) ), 5, 25 );
+ $temp_pass = substr( hash_hmac( 'sha1', wp_rand( 1, 100000000 ), get_site_option( 'jetpack_protect_key' ) ), 5, 25 );
$jetpack_protect = Jetpack_Protect_Module::instance();
$jetpack_protect->set_transient( 'jpp_math_pass_' . $temp_pass, 3, DAY_IN_SECONDS );
- setcookie('jpp_math_pass', $temp_pass, time() + DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, false);
+ setcookie( 'jpp_math_pass', $temp_pass, time() + DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, false, true );
remove_action( 'login_form', array( $this, 'math_form' ) );
return true;
}
@@ -127,37 +141,37 @@ if ( ! class_exists( 'Jetpack_Protect_Math_Authenticate' ) ) {
*
* @return VOID outputs html
*/
- static function math_form() {
- // Check if jpp_math_pass cookie is set and it matches valid transient
- if( isset( $_COOKIE[ 'jpp_math_pass' ] ) ) {
+ public static function math_form() {
+ // Check if jpp_math_pass cookie is set and it matches valid transient.
+ if ( isset( $_COOKIE['jpp_math_pass'] ) ) {
$jetpack_protect = Jetpack_Protect_Module::instance();
- $transient = $jetpack_protect->get_transient( 'jpp_math_pass_' . $_COOKIE[ 'jpp_math_pass' ] );
+ $transient = $jetpack_protect->get_transient( 'jpp_math_pass_' . sanitize_key( $_COOKIE['jpp_math_pass'] ) );
- if( $transient && $transient > 0 ) {
+ if ( $transient && $transient > 0 ) {
return '';
}
}
- $num1 = rand( 0, 10 );
- $num2 = rand( 1, 10 );
+ $num1 = wp_rand( 0, 10 );
+ $num2 = wp_rand( 1, 10 );
$ans = $num1 + $num2;
- $time_window = Jetpack_Protect_Math_Authenticate::time_window();
+ $time_window = self::time_window();
$salt = get_site_option( 'jetpack_protect_key' ) . '|' . get_site_option( 'admin_email' ) . '|';
$salted_ans = hash_hmac( 'sha1', $ans, $salt . $time_window );
?>
<div style="margin: 5px 0 20px;">
- <label for="jetpack_protect_answer">
+ <p style="font-size: 14px;">
<?php esc_html_e( 'Prove your humanity', 'jetpack' ); ?>
- </label>
+ </p>
<br/>
- <span style="vertical-align:super;">
+ <label for="jetpack_protect_answer" style="vertical-align:super;">
<?php echo esc_html( "$num1 &nbsp; + &nbsp; $num2 &nbsp; = &nbsp;" ); ?>
- </span>
- <input type="text" id="jetpack_protect_answer" name="jetpack_protect_num" value="" size="2" style="width:30px;height:25px;vertical-align:middle;font-size:13px;" class="input" />
+ </label>
+ <input type="number" id="jetpack_protect_answer" name="jetpack_protect_num" value="" size="2" style="width:50px;height:25px;vertical-align:middle;font-size:13px;" class="input" />
<input type="hidden" name="jetpack_protect_answer" value="<?php echo esc_attr( $salted_ans ); ?>" />
</div>
- <?php
+ <?php
}
}
diff --git a/plugins/jetpack/modules/protect/protect-dashboard-widget-rtl.css b/plugins/jetpack/modules/protect/protect-dashboard-widget-rtl.css
index b9131462..353e5106 100644
--- a/plugins/jetpack/modules/protect/protect-dashboard-widget-rtl.css
+++ b/plugins/jetpack/modules/protect/protect-dashboard-widget-rtl.css
@@ -1,117 +1,115 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
/* loads inline on wp-admin in order to reduce http requests */
-
#protect_dashboard_widget .inside {
- margin: 0;
- padding: 0;
- text-align: center;
+ margin: 0;
+ padding: 0;
+ text-align: center;
}
.jetpack-security * {
- box-sizing: border-box;
+ box-sizing: border-box;
}
/* alert msgs */
#protect_dashboard_widget .msg {
- color: #fff;
- text-align: center;
- padding: 10px;
+ color: #fff;
+ text-align: center;
+ padding: 10px;
}
#protect_dashboard_widget .msg.working {
- background: #7BAC48;
+ background: #7BAC48;
}
#protect_dashboard_widget .msg.attn {
- background: #d94f4f;
+ background: #d94f4f;
}
#protect_dashboard_widget .msg a {
- color: #fff;
- text-decoration: underline;
+ color: #fff;
+ text-decoration: underline;
}
#protect_dashboard_widget .msg a:hover {
- text-decoration: none;
+ text-decoration: none;
}
#protect_dashboard_widget .msg .dashicons {
- float: left;
- text-decoration: none;
- border-radius: 2px;
+ float: left;
+ text-decoration: none;
+ border-radius: 2px;
}
#protect_dashboard_widget .msg.working .dashicons {
- color: #609643;
+ color: #609643;
}
#protect_dashboard_widget .msg.working .dashicons:hover {
- background: #609643;
- color: #7BAC48;
+ background: #609643;
+ color: #7BAC48;
}
#protect_dashboard_widget .msg.attn .dashicons {
- color: #a93838;
+ color: #a93838;
}
#protect_dashboard_widget .msg.attn .dashicons:hover {
- background: #a93838;
- color: #d94f4f;
+ background: #a93838;
+ color: #d94f4f;
}
.blocked-attacks,
.file-scanning {
- position: relative;
+ position: relative;
}
.blocked-attacks {
- background: #f6f7f7;
- border-bottom: 1px #f0f0f1 solid;
- padding-bottom: 35px;
+ background: #f6f7f7;
+ border-bottom: 1px #f0f0f1 solid;
+ padding-bottom: 35px;
}
.jetpack-security-sharing {
- width: 60px;
- display: inline-block;
- position: absolute;
- left: 0;
- top: 10px;
+ width: 60px;
+ display: inline-block;
+ position: absolute;
+ left: 0;
+ top: 10px;
}
.jetpack-security-sharing a {
- color: #dcdcdc;
+ color: #dcdcdc;
}
.jetpack-security-sharing a:hover {
- color: #cdcbcb;
+ color: #cdcbcb;
}
.blocked-attacks h2,
.blocked-attacks h3 {
- color: #7BAC48;
- font-weight: 300;
+ color: #7BAC48;
+ font-weight: 300;
}
.blocked-attacks h2 {
- font-size: 4em;
- line-height: 110%;
- margin: 0;
- padding: 10px 12px 10px 12px;
+ font-size: 4em;
+ line-height: 110%;
+ margin: 0;
+ padding: 10px 12px 10px 12px;
}
.blocked-attacks h3 {
- font-size: 1.1em;
- line-height: 110%;
- padding: 0 12px 10px 12px;
- margin: 0;
+ font-size: 1.1em;
+ line-height: 110%;
+ padding: 0 12px 10px 12px;
+ margin: 0;
}
.jetpack-protect-logo {
- width: 50px;
- position: relative;
+ width: 50px;
+ position: relative;
}
.file-scanning {
- margin-top: -30px;
- padding: 0 12px;
+ margin-top: -30px;
+ padding: 0 12px;
}
diff --git a/plugins/jetpack/modules/protect/protect-dashboard-widget-rtl.min.css b/plugins/jetpack/modules/protect/protect-dashboard-widget-rtl.min.css
index 449b8b69..e5f23dc2 100644
--- a/plugins/jetpack/modules/protect/protect-dashboard-widget-rtl.min.css
+++ b/plugins/jetpack/modules/protect/protect-dashboard-widget-rtl.min.css
@@ -1 +1 @@
-#protect_dashboard_widget .inside{margin:0;padding:0;text-align:center}.jetpack-security *{box-sizing:border-box}#protect_dashboard_widget .msg{color:#fff;text-align:center;padding:10px}#protect_dashboard_widget .msg.working{background:#7bac48}#protect_dashboard_widget .msg.attn{background:#d94f4f}#protect_dashboard_widget .msg a{color:#fff;text-decoration:underline}#protect_dashboard_widget .msg a:hover{text-decoration:none}#protect_dashboard_widget .msg .dashicons{float:left;text-decoration:none;border-radius:2px}#protect_dashboard_widget .msg.working .dashicons{color:#609643}#protect_dashboard_widget .msg.working .dashicons:hover{background:#609643;color:#7bac48}#protect_dashboard_widget .msg.attn .dashicons{color:#a93838}#protect_dashboard_widget .msg.attn .dashicons:hover{background:#a93838;color:#d94f4f}.blocked-attacks,.file-scanning{position:relative}.blocked-attacks{background:#f6f7f7;border-bottom:1px #f0f0f1 solid;padding-bottom:35px}.jetpack-security-sharing{width:60px;display:inline-block;position:absolute;left:0;top:10px}.jetpack-security-sharing a{color:#dcdcdc}.jetpack-security-sharing a:hover{color:#cdcbcb}.blocked-attacks h2,.blocked-attacks h3{color:#7bac48;font-weight:300}.blocked-attacks h2{font-size:4em;line-height:110%;margin:0;padding:10px 12px 10px 12px}.blocked-attacks h3{font-size:1.1em;line-height:110%;padding:0 12px 10px 12px;margin:0}.jetpack-protect-logo{width:50px;position:relative}.file-scanning{margin-top:-30px;padding:0 12px} \ No newline at end of file
+#protect_dashboard_widget .inside{margin:0;padding:0;text-align:center}.jetpack-security *{box-sizing:border-box}#protect_dashboard_widget .msg{color:#fff;padding:10px;text-align:center}#protect_dashboard_widget .msg.working{background:#7bac48}#protect_dashboard_widget .msg.attn{background:#d94f4f}#protect_dashboard_widget .msg a{color:#fff;text-decoration:underline}#protect_dashboard_widget .msg a:hover{text-decoration:none}#protect_dashboard_widget .msg .dashicons{border-radius:2px;float:left;text-decoration:none}#protect_dashboard_widget .msg.working .dashicons{color:#609643}#protect_dashboard_widget .msg.working .dashicons:hover{background:#609643;color:#7bac48}#protect_dashboard_widget .msg.attn .dashicons{color:#a93838}#protect_dashboard_widget .msg.attn .dashicons:hover{background:#a93838;color:#d94f4f}.blocked-attacks,.file-scanning{position:relative}.blocked-attacks{background:#f6f7f7;border-bottom:1px solid #f0f0f1;padding-bottom:35px}.jetpack-security-sharing{display:inline-block;left:0;position:absolute;top:10px;width:60px}.jetpack-security-sharing a{color:#dcdcdc}.jetpack-security-sharing a:hover{color:#cdcbcb}.blocked-attacks h2,.blocked-attacks h3{color:#7bac48;font-weight:300}.blocked-attacks h2{font-size:4em;line-height:110%;margin:0;padding:10px 12px}.blocked-attacks h3{font-size:1.1em;line-height:110%;margin:0;padding:0 12px 10px}.jetpack-protect-logo{position:relative;width:50px}.file-scanning{margin-top:-30px;padding:0 12px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/protect/protect-dashboard-widget.min.css b/plugins/jetpack/modules/protect/protect-dashboard-widget.min.css
index cc161dc0..6945fbdd 100644
--- a/plugins/jetpack/modules/protect/protect-dashboard-widget.min.css
+++ b/plugins/jetpack/modules/protect/protect-dashboard-widget.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-#protect_dashboard_widget .inside{margin:0;padding:0;text-align:center}.jetpack-security *{box-sizing:border-box}#protect_dashboard_widget .msg{color:#fff;text-align:center;padding:10px}#protect_dashboard_widget .msg.working{background:#7bac48}#protect_dashboard_widget .msg.attn{background:#d94f4f}#protect_dashboard_widget .msg a{color:#fff;text-decoration:underline}#protect_dashboard_widget .msg a:hover{text-decoration:none}#protect_dashboard_widget .msg .dashicons{float:right;text-decoration:none;border-radius:2px}#protect_dashboard_widget .msg.working .dashicons{color:#609643}#protect_dashboard_widget .msg.working .dashicons:hover{background:#609643;color:#7bac48}#protect_dashboard_widget .msg.attn .dashicons{color:#a93838}#protect_dashboard_widget .msg.attn .dashicons:hover{background:#a93838;color:#d94f4f}.blocked-attacks,.file-scanning{position:relative}.blocked-attacks{background:#f6f7f7;border-bottom:1px #f0f0f1 solid;padding-bottom:35px}.jetpack-security-sharing{width:60px;display:inline-block;position:absolute;right:0;top:10px}.jetpack-security-sharing a{color:#dcdcdc}.jetpack-security-sharing a:hover{color:#cdcbcb}.blocked-attacks h2,.blocked-attacks h3{color:#7bac48;font-weight:300}.blocked-attacks h2{font-size:4em;line-height:110%;margin:0;padding:10px 12px 10px 12px}.blocked-attacks h3{font-size:1.1em;line-height:110%;padding:0 12px 10px 12px;margin:0}.jetpack-protect-logo{width:50px;position:relative}.file-scanning{margin-top:-30px;padding:0 12px} \ No newline at end of file
+#protect_dashboard_widget .inside{margin:0;padding:0;text-align:center}.jetpack-security *{box-sizing:border-box}#protect_dashboard_widget .msg{color:#fff;padding:10px;text-align:center}#protect_dashboard_widget .msg.working{background:#7bac48}#protect_dashboard_widget .msg.attn{background:#d94f4f}#protect_dashboard_widget .msg a{color:#fff;text-decoration:underline}#protect_dashboard_widget .msg a:hover{text-decoration:none}#protect_dashboard_widget .msg .dashicons{border-radius:2px;float:right;text-decoration:none}#protect_dashboard_widget .msg.working .dashicons{color:#609643}#protect_dashboard_widget .msg.working .dashicons:hover{background:#609643;color:#7bac48}#protect_dashboard_widget .msg.attn .dashicons{color:#a93838}#protect_dashboard_widget .msg.attn .dashicons:hover{background:#a93838;color:#d94f4f}.blocked-attacks,.file-scanning{position:relative}.blocked-attacks{background:#f6f7f7;border-bottom:1px solid #f0f0f1;padding-bottom:35px}.jetpack-security-sharing{display:inline-block;position:absolute;right:0;top:10px;width:60px}.jetpack-security-sharing a{color:#dcdcdc}.jetpack-security-sharing a:hover{color:#cdcbcb}.blocked-attacks h2,.blocked-attacks h3{color:#7bac48;font-weight:300}.blocked-attacks h2{font-size:4em;line-height:110%;margin:0;padding:10px 12px}.blocked-attacks h3{font-size:1.1em;line-height:110%;margin:0;padding:0 12px 10px}.jetpack-protect-logo{position:relative;width:50px}.file-scanning{margin-top:-30px;padding:0 12px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/protect/shared-functions.php b/plugins/jetpack/modules/protect/shared-functions.php
index 1091260f..1ce9ba0c 100644
--- a/plugins/jetpack/modules/protect/shared-functions.php
+++ b/plugins/jetpack/modules/protect/shared-functions.php
@@ -1,7 +1,10 @@
<?php
/**
* These functions are shared by the Protect module and its related json-endpoints
+ *
+ * @package automattic/jetpack
*/
+
/**
* Returns an array of IP objects that will never be blocked by the Protect module
*
@@ -12,7 +15,7 @@
*/
function jetpack_protect_format_whitelist() {
$local_whitelist = jetpack_protect_get_local_whitelist();
- $formatted = array(
+ $formatted = array(
'local' => array(),
);
foreach ( $local_whitelist as $item ) {
@@ -161,11 +164,11 @@ function jetpack_protect_save_whitelist( $whitelist, $global = false ) {
function jetpack_protect_get_ip() {
$trusted_header_data = get_site_option( 'trusted_ip_header' );
if ( isset( $trusted_header_data->trusted_header ) && isset( $_SERVER[ $trusted_header_data->trusted_header ] ) ) {
- $ip = $_SERVER[ $trusted_header_data->trusted_header ];
+ $ip = wp_unslash( $_SERVER[ $trusted_header_data->trusted_header ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- jetpack_clean_ip does it below.
$segments = $trusted_header_data->segments;
$reverse_order = $trusted_header_data->reverse;
} else {
- $ip = $_SERVER['REMOTE_ADDR'];
+ $ip = isset( $_SERVER['REMOTE_ADDR'] ) ? wp_unslash( $_SERVER['REMOTE_ADDR'] ) : null; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- jetpack_clean_ip does it below.
}
if ( ! $ip ) {
@@ -186,7 +189,7 @@ function jetpack_protect_get_ip() {
$the_one = $ip_count - $segments;
return jetpack_clean_ip( $ips[ $the_one ] );
} else {
- return jetpack_clean_ip( $_SERVER['REMOTE_ADDR'] );
+ return jetpack_clean_ip( isset( $_SERVER['REMOTE_ADDR'] ) ? wp_unslash( $_SERVER['REMOTE_ADDR'] ) : null ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- jetpack_clean_ip does it.
}
}
@@ -201,7 +204,7 @@ function jetpack_clean_ip( $ip ) {
// Some misconfigured servers give back extra info, which comes after "unless".
$ips = explode( ' unless ', $ip );
- $ip = $ips[0];
+ $ip = $ips[0];
$ip = strtolower( trim( $ip ) );
@@ -243,7 +246,7 @@ function jetpack_protect_ip_is_private( $ip ) {
'169.254.0.0|169.254.255.255', // Link-local address also referred to as Automatic Private IP Addressing.
'127.0.0.0|127.255.255.255', // localhost.
);
- $long_ip = ip2long( $ip );
+ $long_ip = ip2long( $ip );
if ( -1 !== $long_ip ) {
foreach ( $private_ip4_addresses as $pri_addr ) {
list ( $start, $end ) = explode( '|', $pri_addr );
diff --git a/plugins/jetpack/modules/protect/transient-cleanup.php b/plugins/jetpack/modules/protect/transient-cleanup.php
index 8f1c169d..de5f5764 100644
--- a/plugins/jetpack/modules/protect/transient-cleanup.php
+++ b/plugins/jetpack/modules/protect/transient-cleanup.php
@@ -1,8 +1,11 @@
<?php
-/*
-Adapted from Purge Transients by Seebz
-https://github.com/Seebz/Snippets/tree/master/Wordpress/plugins/purge-transients
-*/
+/**
+ * Adapted from Purge Transients by Seebz
+ * https://github.com/Seebz/Snippets/tree/master/Wordpress/plugins/purge-transients
+ *
+ * @package automattic/jetpack
+ */
+
if ( ! function_exists( 'jp_purge_transients' ) ) {
/**
@@ -10,7 +13,6 @@ if ( ! function_exists( 'jp_purge_transients' ) ) {
*
* @access public
* @param string $older_than (default: '1 hour') Older Than.
- * @return void
*/
function jp_purge_transients( $older_than = '1 hour' ) {
global $wpdb;
@@ -18,13 +20,12 @@ if ( ! function_exists( 'jp_purge_transients' ) ) {
if ( $older_than_time > time() || $older_than_time < 1 ) {
return false;
}
- $sql = $wpdb->prepare( "
- SELECT REPLACE(option_name, '_transient_timeout_jpp_', '') AS transient_name
- FROM {$wpdb->options}
- WHERE option_name LIKE '\_transient\_timeout\_jpp\__%%'
- AND option_value < %d
- ", $older_than_time );
- $transients = $wpdb->get_col( $sql );
+ $sql = $wpdb->prepare(
+ // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.LikeWildcardsInQuery
+ "SELECT REPLACE(option_name, '_transient_timeout_jpp_', '') AS transient_name FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_timeout\_jpp\__%%' AND option_value < %d",
+ $older_than_time
+ );
+ $transients = $wpdb->get_col( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- $sql is prepared above.
$options_names = array();
foreach ( $transients as $transient ) {
$options_names[] = '_transient_jpp_' . $transient;
@@ -32,14 +33,16 @@ if ( ! function_exists( 'jp_purge_transients' ) ) {
}
if ( $options_names ) {
$option_names_string = implode( ', ', array_fill( 0, count( $options_names ), '%s' ) );
- $delete_sql = "DELETE FROM {$wpdb->options} WHERE option_name IN ($option_names_string)";
- $delete_sql = call_user_func_array( array( $wpdb, 'prepare' ), array_merge( array( $delete_sql ), $options_names ) );
- $result = $wpdb->query( $delete_sql );
+ $result = $wpdb->query(
+ $wpdb->prepare(
+ "DELETE FROM {$wpdb->options} WHERE option_name IN ($option_names_string)", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- the placeholders are set above.
+ $options_names
+ )
+ );
if ( ! $result ) {
return false;
}
}
- return;
}
}
diff --git a/plugins/jetpack/modules/publicize.php b/plugins/jetpack/modules/publicize.php
index dccc617b..ac860e24 100644
--- a/plugins/jetpack/modules/publicize.php
+++ b/plugins/jetpack/modules/publicize.php
@@ -33,30 +33,28 @@ class Jetpack_Publicize {
public function __construct() {
global $publicize_ui;
+ $this->modules = new Automattic\Jetpack\Modules();
$this->in_jetpack = ( class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'enable_module_configurable' ) ) ? true : false;
if ( $this->in_jetpack ) {
Jetpack::enable_module_configurable( __FILE__ );
- }
-
- require_once __DIR__ . '/publicize/publicize.php';
- if ( $this->in_jetpack ) {
- require_once __DIR__ . '/publicize/publicize-jetpack.php';
- } else {
- require_once dirname( __DIR__ ) . '/mu-plugins/keyring/keyring.php';
- require_once __DIR__ . '/publicize/publicize-wpcom.php';
- }
-
- require_once __DIR__ . '/publicize/ui.php';
- $publicize_ui = new Publicize_UI();
- $publicize_ui->in_jetpack = $this->in_jetpack;
+ if ( $this->modules->is_active( 'publicize' ) ) {
+ add_action(
+ 'jetpack_register_gutenberg_extensions',
+ function () {
+ global $publicize;
+ if ( $publicize->current_user_can_access_publicize_data() ) {
+ Jetpack_Gutenberg::set_extension_available( 'jetpack/publicize' );
+ } else {
+ Jetpack_Gutenberg::set_extension_unavailable( 'jetpack/publicize', 'unauthorized' );
+ }
+ }
+ );
+ }
- // Jetpack specific checks / hooks.
- if ( $this->in_jetpack ) {
// if sharedaddy isn't active, the sharing menu hasn't been added yet.
- $active = Jetpack::get_active_modules();
- if ( in_array( 'publicize', $active, true ) && ! in_array( 'sharedaddy', $active, true ) ) {
+ if ( $this->modules->is_active( 'publicize' ) && ! $this->modules->is_active( 'sharedaddy' ) ) {
add_action( 'admin_menu', array( &$publicize_ui, 'sharing_menu' ) );
}
@@ -93,28 +91,43 @@ class Jetpack_Publicize {
}
}
);
+ } else {
+ require_once __DIR__ . '/publicize/publicize.php';
+ require_once dirname( __DIR__ ) . '/mu-plugins/keyring/keyring.php';
+ require_once __DIR__ . '/publicize/publicize-wpcom.php';
+ require_once __DIR__ . '/publicize/ui.php';
+ $publicize_ui = new Publicize_UI();
}
+
+ $publicize_ui->in_jetpack = $this->in_jetpack;
}
}
-new Jetpack_Publicize();
+// On Jetpack, we instantiate Jetpack_Publicize only if the Publicize module is active.
+if ( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) {
-if ( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) && ! function_exists( 'publicize_init' ) ) {
- /**
- * Helper for grabbing a Publicize object from the "front-end" (non-admin) of
- * a site. Normally Publicize is only loaded in wp-admin, so there's a little
- * set up that you might need to do if you want to use it on the front end.
- * Just call this function and it returns a Publicize object.
- *
- * @return Publicize Object
- */
- function publicize_init() {
- global $publicize;
+ $modules = new Automattic\Jetpack\Modules();
- if ( ! class_exists( 'Publicize' ) ) {
- require_once __DIR__ . '/publicize/publicize.php';
- }
+ if ( $modules->is_active( 'publicize' ) ) {
+ new Jetpack_Publicize();
+ }
- return $publicize;
+ if ( ! function_exists( 'publicize_init' ) ) {
+ /**
+ * Helper for grabbing a Publicize object from the "front-end" (non-admin) of
+ * a site. Normally Publicize is only loaded in wp-admin, so there's a little
+ * set up that you might need to do if you want to use it on the front end.
+ * Just call this function and it returns a Publicize object.
+ *
+ * @return Publicize Object
+ */
+ function publicize_init() {
+ global $publicize;
+
+ return $publicize;
+ }
}
+} else {
+ // On wpcom, instantiate Jetpack_Publicize without any other checks.
+ new Jetpack_Publicize();
}
diff --git a/plugins/jetpack/modules/publicize/enhanced-open-graph.php b/plugins/jetpack/modules/publicize/enhanced-open-graph.php
deleted file mode 100644
index e50082ff..00000000
--- a/plugins/jetpack/modules/publicize/enhanced-open-graph.php
+++ /dev/null
@@ -1,144 +0,0 @@
-<?php
-if ( ! class_exists( 'Jetpack_Media_Summary' ) ) {
- if ( defined('IS_WPCOM') && IS_WPCOM ) {
- include WP_CONTENT_DIR . '/lib/class.wpcom-media-summary.php';
- } else {
- jetpack_require_lib( 'class.media-summary' );
- }
-}
-
-/**
- * Better OG Image Tags for Image Post Formats
- */
-function enhanced_og_image( $tags ) {
- if ( !is_singular() || post_password_required() )
- return $tags;
-
- global $post;
-
- // Bail if we do not have info about the post.
- if ( ! $post instanceof WP_Post ) {
- return $tags;
- }
-
- // Always favor featured images.
- if ( enhanced_og_has_featured_image( $post->ID ) )
- return $tags;
-
- $summary = Jetpack_Media_Summary::get( $post->ID );
-
- if ( 'image' != $summary['type'] )
- return $tags;
-
- $tags['og:image'] = $summary['image'];
- $tags['og:image:secure_url'] = $summary['secure']['image'];
-
- return $tags;
-}
-add_filter( 'jetpack_open_graph_tags', 'enhanced_og_image' );
-
-/**
- * Better OG Image Tags for Gallery Post Formats
- */
-function enhanced_og_gallery( $tags ) {
- if ( !is_singular() || post_password_required() )
- return $tags;
-
- global $post;
-
- // Bail if we do not have info about the post.
- if ( ! $post instanceof WP_Post ) {
- return $tags;
- }
-
- // Always favor featured images.
- if ( enhanced_og_has_featured_image( $post->ID ) )
- return $tags;
-
- $summary = Jetpack_Media_Summary::get( $post->ID );
-
- if ( 'gallery' != $summary['type'] )
- return $tags;
-
- if( !isset( $summary['images'] ) || !is_array( $summary['images'] ) || empty( $summary['images'] ) )
- return $tags;
-
- $images = $secures = array();
- foreach ( $summary['images'] as $i => $image ) {
- $images[] = $image['url'];
- $secures[] = $summary['secure']['images'][$i]['url'];
- }
-
- $tags['og:image'] = $images;
- $tags['og:image:secure_url'] = $secures;
-
- return $tags;
-}
-add_filter( 'jetpack_open_graph_tags', 'enhanced_og_gallery' );
-
-/**
- * Allows VideoPress, YouTube, and Vimeo videos to play inline on Facebook
- */
-function enhanced_og_video( $tags ) {
- if ( !is_singular() || post_password_required() )
- return $tags;
-
- global $post;
-
- // Bail if we do not have info about the post.
- if ( ! $post instanceof WP_Post ) {
- return $tags;
- }
-
- // Always favor featured images.
- if ( enhanced_og_has_featured_image( $post->ID ) )
- return $tags;
-
- $summary = Jetpack_Media_Summary::get( $post->ID );
-
- if ( 'video' != $summary['type'] ) {
- if ( $summary['count']['video'] > 0 && $summary['count']['image'] < 1 ) {
- $tags['og:image'] = $summary['image'];
- $tags['og:image:secure_url'] = $summary['secure']['image'];
- }
- return $tags;
- }
-
- $tags['og:image'] = $summary['image'];
- $tags['og:image:secure_url'] = $summary['secure']['image'];
-
- // This should be html by default for youtube/vimeo, since we're linking to HTML pages.
- $tags['og:video:type'] = isset( $summary['video_type'] ) ? $summary['video_type'] : 'text/html';
-
- $video_url = $summary['video'];
- $secure_video_url = $summary['secure']['video'];
-
- if ( preg_match( '/((youtube|vimeo)\.com|youtu.be)/', $video_url ) ) {
- if ( strstr( $video_url, 'youtube' ) ) {
- $id = jetpack_get_youtube_id( $video_url );
- $video_url = 'http://www.youtube.com/embed/' . $id;
- $secure_video_url = 'https://www.youtube.com/embed/' . $id;
- } else if ( strstr( $video_url, 'vimeo' ) ) {
- preg_match( '|vimeo\.com/(\d+)/?$|i', $video_url, $match );
- $id = (int) $match[1];
- $video_url = 'http://vimeo.com/moogaloop.swf?clip_id=' . $id;
- $secure_video_url = 'https://vimeo.com/moogaloop.swf?clip_id=' . $id;
- }
- }
-
- $tags['og:video'] = $video_url;
- $tags['og:video:secure_url'] = $secure_video_url;
-
- if ( empty( $post->post_title ) )
- $tags['og:title'] = sprintf( __( 'Video on %s', 'jetpack' ), get_option( 'blogname' ) );
-
- return $tags;
-}
-add_filter( 'jetpack_open_graph_tags', 'enhanced_og_video' );
-
-function enhanced_og_has_featured_image( $post_id ) {
- $featured = Jetpack_PostImages::from_thumbnail( $post_id, 200, 200 );
- if ( !empty( $featured ) && count( $featured ) > 0 )
- return true;
- return false;
-}
diff --git a/plugins/jetpack/modules/publicize/publicize-jetpack.php b/plugins/jetpack/modules/publicize/publicize-jetpack.php
index 6f618c62..da9a5b2c 100644
--- a/plugins/jetpack/modules/publicize/publicize-jetpack.php
+++ b/plugins/jetpack/modules/publicize/publicize-jetpack.php
@@ -1,13 +1,24 @@
-<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Publicize class.
+ *
+ * @package automattic/jetpack
+ */
use Automattic\Jetpack\Connection\Tokens;
use Automattic\Jetpack\Redirect;
+/**
+ * Extend the base class with Jetpack-specific functionality.
+ */
class Publicize extends Publicize_Base {
const CONNECTION_REFRESH_WAIT_TRANSIENT = 'jetpack_publicize_connection_refresh_wait';
- function __construct() {
+ /**
+ * Add hooks.
+ */
+ public function __construct() {
parent::__construct();
add_filter( 'jetpack_xmlrpc_unauthenticated_methods', array( $this, 'register_update_publicize_connections_xmlrpc_method' ) );
@@ -28,7 +39,7 @@ class Publicize extends Publicize_Base {
add_filter( 'jetpack_published_post_flags', array( $this, 'set_post_flags' ), 10, 2 );
- add_action( 'wp_insert_post', array( $this, 'save_publicized' ), 11, 3 );
+ add_action( 'wp_insert_post', array( $this, 'save_publicized' ), 11, 2 );
add_filter( 'jetpack_twitter_cards_site_tag', array( $this, 'enhaced_twitter_cards_site_tag' ) );
@@ -41,35 +52,43 @@ class Publicize extends Publicize_Base {
add_action( 'updating_jetpack_version', array( $this, 'init_refresh_transient' ) );
- include_once( JETPACK__PLUGIN_DIR . 'modules/publicize/enhanced-open-graph.php' );
-
jetpack_require_lib( 'class.jetpack-keyring-service-helper' );
}
- function add_disconnect_notice() {
+ /**
+ * Add a notice when a connection has been disconnected.
+ */
+ public function add_disconnect_notice() {
add_action( 'admin_notices', array( $this, 'display_disconnected' ) );
}
- function force_user_connection() {
+ /**
+ * Force user connection before showing the Publicize UI.
+ */
+ public function force_user_connection() {
global $current_user;
+
$user_token = ( new Tokens() )->get_access_token( $current_user->ID );
$is_user_connected = $user_token && ! is_wp_error( $user_token );
- // If the user is already connected via Jetpack, then we're good
+ // If the user is already connected via Jetpack, then we're good.
if ( $is_user_connected ) {
return;
}
- // If they're not connected, then remove the Publicize UI and tell them they need to connect first
+ // If they're not connected, then remove the Publicize UI and tell them they need to connect first.
global $publicize_ui;
remove_action( 'pre_admin_screen_sharing', array( $publicize_ui, 'admin_page' ) );
// Do we really need `admin_styles`? With the new admin UI, it's breaking some bits.
- // Jetpack::init()->admin_styles();
+ // Jetpack::init()->admin_styles();.
add_action( 'pre_admin_screen_sharing', array( $this, 'admin_page_warning' ), 1 );
}
- function admin_page_warning() {
+ /**
+ * Show a warning when Publicize does not have a connection.
+ */
+ public function admin_page_warning() {
$jetpack = Jetpack::init();
$blog_name = get_bloginfo( 'blogname' );
if ( empty( $blog_name ) ) {
@@ -80,16 +99,20 @@ class Publicize extends Publicize_Base {
<div id="message" class="updated jetpack-message jp-connect">
<div class="jetpack-wrap-container">
<div class="jetpack-text-container">
- <p><?php printf(
- /* translators: %s is the name of the blog */
- esc_html( wptexturize( __( "To use Publicize, you'll need to link your %s account to your WordPress.com account using the link below.", 'jetpack' ) ) ),
- '<strong>' . esc_html( $blog_name ) . '</strong>'
- ); ?></p>
+ <p>
+ <?php
+ printf(
+ /* translators: %s is the name of the blog */
+ esc_html( wptexturize( __( "To use Publicize, you'll need to link your %s account to your WordPress.com account using the link below.", 'jetpack' ) ) ),
+ '<strong>' . esc_html( $blog_name ) . '</strong>'
+ );
+ ?>
+ </p>
<p><?php echo esc_html( wptexturize( __( "If you don't have a WordPress.com account yet, you can sign up for free in just a few seconds.", 'jetpack' ) ) ); ?></p>
</div>
<div class="jetpack-install-container">
<p class="submit"><a
- href="<?php echo $jetpack->build_connect_url( false, menu_page_url( 'sharing', false ) ); ?>"
+ href="<?php echo esc_url( $jetpack->build_connect_url( false, menu_page_url( 'sharing', false ) ) ); ?>"
class="button-connector"
id="wpcom-connect"><?php esc_html_e( 'Link account with WordPress.com', 'jetpack' ); ?></a>
</p>
@@ -103,25 +126,52 @@ class Publicize extends Publicize_Base {
}
/**
- * Remove a Publicize connection
+ * Remove a Publicize Connection.
+ *
+ * @param string $service_name 'facebook', 'twitter', etc.
+ * @param string $connection_id Connection ID.
+ * @param false|int $_blog_id The blog ID. Use false (default) for the current blog.
+ * @param false|int $_user_id The user ID. Use false (default) for the current user.
+ * @param bool $force_delete Whether to skip permissions checks.
+ * @return false|void False on failure. Void on success.
*/
- function disconnect( $service_name, $connection_id, $_blog_id = false, $_user_id = false, $force_delete = false ) {
+ public function disconnect( $service_name, $connection_id, $_blog_id = false, $_user_id = false, $force_delete = false ) {
return Jetpack_Keyring_Service_Helper::disconnect( $service_name, $connection_id, $_blog_id, $_user_id, $force_delete );
}
- function receive_updated_publicize_connections( $publicize_connections ) {
+ /**
+ * Set updated Publicize conntections.
+ *
+ * @param mixed $publicize_connections Updated connections.
+ * @return true
+ */
+ public function receive_updated_publicize_connections( $publicize_connections ) {
Jetpack_Options::update_option( 'publicize_connections', $publicize_connections );
return true;
}
- function register_update_publicize_connections_xmlrpc_method( $methods ) {
- return array_merge( $methods, array(
- 'jetpack.updatePublicizeConnections' => array( $this, 'receive_updated_publicize_connections' ),
- ) );
+ /**
+ * Add method to update Publicize connections.
+ *
+ * @param array $methods Array of registered methods.
+ * @return array
+ */
+ public function register_update_publicize_connections_xmlrpc_method( $methods ) {
+ return array_merge(
+ $methods,
+ array(
+ 'jetpack.updatePublicizeConnections' => array( $this, 'receive_updated_publicize_connections' ),
+ )
+ );
}
- function get_all_connections() {
+ /**
+ * Get a list of all connections.
+ *
+ * @return array
+ */
+ public function get_all_connections() {
$this->refresh_connections();
$connections = Jetpack_Options::get_option( 'publicize_connections' );
if ( isset( $connections['google_plus'] ) ) {
@@ -130,7 +180,15 @@ class Publicize extends Publicize_Base {
return $connections;
}
- function get_connections( $service_name, $_blog_id = false, $_user_id = false ) {
+ /**
+ * Get connections for a specific service.
+ *
+ * @param string $service_name 'facebook', 'twitter', etc.
+ * @param false|int $_blog_id The blog ID. Use false (default) for the current blog.
+ * @param false|int $_user_id The user ID. Use false (default) for the current user.
+ * @return false|object[]|array[]
+ */
+ public function get_connections( $service_name, $_blog_id = false, $_user_id = false ) {
if ( false === $_user_id ) {
$_user_id = $this->user_id();
}
@@ -141,7 +199,7 @@ class Publicize extends Publicize_Base {
if ( ! empty( $connections ) && is_array( $connections ) ) {
if ( ! empty( $connections[ $service_name ] ) ) {
foreach ( $connections[ $service_name ] as $id => $connection ) {
- if ( 0 == $connection['connection_data']['user_id'] || $_user_id == $connection['connection_data']['user_id'] ) {
+ if ( $this->is_global_connection( $connection ) || $_user_id === (int) $connection['connection_data']['user_id'] ) {
$connections_to_return[ $id ] = $connection;
}
}
@@ -153,7 +211,12 @@ class Publicize extends Publicize_Base {
return false;
}
- function get_all_connections_for_user() {
+ /**
+ * Get all connections for a specific user.
+ *
+ * @return array|false
+ */
+ public function get_all_connections_for_user() {
$connections = $this->get_all_connections();
$connections_to_return = array();
@@ -174,33 +237,64 @@ class Publicize extends Publicize_Base {
return false;
}
- function get_connection_id( $connection ) {
+ /**
+ * Get the ID of a connection.
+ *
+ * @param array $connection The connection.
+ * @return string
+ */
+ public function get_connection_id( $connection ) {
return $connection['connection_data']['id'];
}
- function get_connection_unique_id( $connection ) {
+ /**
+ * Get the unique ID of a connection.
+ *
+ * @param array $connection The connection.
+ * @return string
+ */
+ public function get_connection_unique_id( $connection ) {
return $connection['connection_data']['token_id'];
}
- function get_connection_meta( $connection ) {
- $connection['user_id'] = $connection['connection_data']['user_id']; // Allows for shared connections
+ /**
+ * Get the meta of a connection.
+ *
+ * @param array $connection The connection.
+ * @return array
+ */
+ public function get_connection_meta( $connection ) {
+ $connection['user_id'] = $connection['connection_data']['user_id']; // Allows for shared connections.
return $connection;
}
- function admin_page_load() {
- if ( isset( $_GET['action'] ) && 'error' === $_GET['action'] ) {
- add_action( 'pre_admin_screen_sharing', array( $this, 'display_connection_error' ), 9 );
+ /**
+ * Show error on settings page if applicable.
+ */
+ public function admin_page_load() {
+ $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+
+ if ( 'error' === $action ) {
+ add_action( 'pre_admin_screen_sharing', array( $this, 'display_connection_error' ), 9 );
}
}
- function display_connection_error() {
+ /**
+ * Display an error message.
+ */
+ public function display_connection_error() {
$code = false;
- if ( isset( $_GET['service'] ) ) {
- $service_name = $_GET['service'];
- $error = sprintf( __( 'There was a problem connecting to %s to create an authorized connection. Please try again in a moment.', 'jetpack' ), Publicize::get_service_label( $service_name ) );
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended
+ $service = isset( $_GET['service'] ) ? sanitize_text_field( wp_unslash( $_GET['service'] ) ) : null;
+ $publicize_error = isset( $_GET['publicize_error'] ) ? sanitize_text_field( wp_unslash( $_GET['publicize_error'] ) ) : null;
+ // phpcs:enable WordPress.Security.NonceVerification.Recommended
+
+ if ( $service ) {
+ /* translators: %s is the name of the Publicize service (e.g. Facebook, Twitter) */
+ $error = sprintf( __( 'There was a problem connecting to %s to create an authorized connection. Please try again in a moment.', 'jetpack' ), self::get_service_label( $service ) );
} else {
- if ( isset( $_GET['publicize_error'] ) ) {
- $code = strtolower( $_GET['publicize_error'] );
+ if ( $publicize_error ) {
+ $code = strtolower( $publicize_error );
switch ( $code ) {
case '400':
$error = __( 'An invalid request was made. This normally means that something intercepted or corrupted the request from your server to the Jetpack Server. Try again and see if it works this time.', 'jetpack' );
@@ -212,6 +306,7 @@ class Publicize extends Publicize_Base {
$error = __( 'No blog_id was included in your request. Please try disconnecting Jetpack from WordPress.com and then reconnecting it. Once you have done that, try connecting Publicize again.', 'jetpack' );
break;
case 'empty_state':
+ /* translators: %s is the URL of the Jetpack admin page */
$error = sprintf( __( 'No user information was included in your request. Please make sure that your user account has connected to Jetpack. Connect your user account by going to the <a href="%s">Jetpack page</a> within wp-admin.', 'jetpack' ), Jetpack::admin_url() );
break;
default:
@@ -222,42 +317,72 @@ class Publicize extends Publicize_Base {
$error = __( 'There was a problem connecting with Publicize. Please try again in a moment.', 'jetpack' );
}
}
- // Using the same formatting/style as Jetpack::admin_notices() error
+ // Using the same formatting/style as Jetpack::admin_notices() error.
?>
<div id="message" class="jetpack-message jetpack-err">
<div class="squeezer">
- <h2><?php echo wp_kses( $error, array( 'a' => array( 'href' => true ),
- 'code' => true,
- 'strong' => true,
- 'br' => true,
- 'b' => true
- ) ); ?></h2>
+ <h2>
+ <?php
+ echo wp_kses(
+ $error,
+ array(
+ 'a' => array(
+ 'href' => true,
+ ),
+ 'code' => true,
+ 'strong' => true,
+ 'br' => true,
+ 'b' => true,
+ )
+ );
+ ?>
+ </h2>
<?php if ( $code ) : ?>
- <p><?php printf( __( 'Error code: %s', 'jetpack' ), esc_html( stripslashes( $code ) ) ); ?></p>
+ <p>
+ <?php
+ printf(
+ /* translators: %s is the name of the error */
+ esc_html__( 'Error code: %s', 'jetpack' ),
+ esc_html( stripslashes( $code ) )
+ );
+ ?>
+ </p>
<?php endif; ?>
</div>
</div>
<?php
}
- function display_disconnected() {
+ /**
+ * Show a message that the connection has been removed.
+ */
+ public function display_disconnected() {
echo "<div class='updated'>\n";
echo '<p>' . esc_html( __( 'That connection has been removed.', 'jetpack' ) ) . "</p>\n";
echo "</div>\n\n";
}
- function globalization() {
- if ( 'on' == $_REQUEST['global'] ) {
- $globalize_connection = $_REQUEST['connection'];
- if ( ! current_user_can( $this->GLOBAL_CAP ) ) {
+ /**
+ * If applicable, globalize a connection.
+ *
+ * @param string $connection_id Connection ID.
+ */
+ public function globalization( $connection_id ) {
+ if ( isset( $_REQUEST['global'] ) && 'on' === $_REQUEST['global'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- nonce check happens earlier in the process before we get here
+ if ( ! current_user_can( $this->GLOBAL_CAP ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
return;
}
- $this->globalize_connection( $globalize_connection );
+ $this->globalize_connection( $connection_id );
}
}
- function globalize_connection( $connection_id ) {
+ /**
+ * Globalize a connection.
+ *
+ * @param string $connection_id Connection ID.
+ */
+ public function globalize_connection( $connection_id ) {
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.globalizePublicizeConnection', $connection_id, 'globalize' );
@@ -267,7 +392,12 @@ class Publicize extends Publicize_Base {
}
}
- function unglobalize_connection( $connection_id ) {
+ /**
+ * Unglobalize a connection.
+ *
+ * @param string $connection_id Connection ID.
+ */
+ public function unglobalize_connection( $connection_id ) {
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.globalizePublicizeConnection', $connection_id, 'unglobalize' );
@@ -322,15 +452,36 @@ class Publicize extends Publicize_Base {
set_transient( self::CONNECTION_REFRESH_WAIT_TRANSIENT, microtime( true ), $wait_time );
}
- function connect_url( $service_name, $for = 'publicize' ) {
+ /**
+ * Get the Publicize connect URL from Keyring.
+ *
+ * @param string $service_name Name of the service to get connect URL for.
+ * @param string $for What the URL is for. Default 'publicize'.
+ * @return string
+ */
+ public function connect_url( $service_name, $for = 'publicize' ) {
return Jetpack_Keyring_Service_Helper::connect_url( $service_name, $for );
}
- function refresh_url( $service_name, $for = 'publicize' ) {
+ /**
+ * Get the Publicize refresh URL from Keyring.
+ *
+ * @param string $service_name Name of the service to get refresh URL for.
+ * @param string $for What the URL is for. Default 'publicize'.
+ * @return string
+ */
+ public function refresh_url( $service_name, $for = 'publicize' ) {
return Jetpack_Keyring_Service_Helper::refresh_url( $service_name, $for );
}
- function disconnect_url( $service_name, $id ) {
+ /**
+ * Get the Publicize disconnect URL from Keyring.
+ *
+ * @param string $service_name Name of the service to get disconnect URL for.
+ * @param mixed $id ID of the conenction to disconnect.
+ * @return string
+ */
+ public function disconnect_url( $service_name, $id ) {
return Jetpack_Keyring_Service_Helper::disconnect_url( $service_name, $id );
}
@@ -340,42 +491,61 @@ class Publicize extends Publicize_Base {
* @since 2.0.0
* @since 6.6.0 Removed Path. Service closed October 2018.
*
- * @param string $filter Select the list of services that will be returned. Defaults to 'all', accepts 'connected'.
- *
+ * @param string $filter Select the list of services that will be returned. Defaults to 'all', accepts 'connected'.
+ * @param false|int $_blog_id Get services for a specific blog by ID, or set to false for current blog. Default false.
+ * @param false|int $_user_id Get services for a specific user by ID, or set to false for current user. Default false.
* @return array List of social networks.
*/
- function get_services( $filter = 'all', $_blog_id = false, $_user_id = false ) {
+ public function get_services( $filter = 'all', $_blog_id = false, $_user_id = false ) {
$services = array(
- 'facebook' => array(),
- 'twitter' => array(),
- 'linkedin' => array(),
- 'tumblr' => array(),
+ 'facebook' => array(),
+ 'twitter' => array(),
+ 'linkedin' => array(),
+ 'tumblr' => array(),
);
- if ( 'all' == $filter ) {
+ if ( 'all' === $filter ) {
return $services;
- } else {
- $connected_services = array();
- foreach ( $services as $service_name => $empty ) {
- $connections = $this->get_connections( $service_name, $_blog_id, $_user_id );
- if ( $connections ) {
- $connected_services[ $service_name ] = $connections;
- }
+ }
+
+ $connected_services = array();
+ foreach ( $services as $service_name => $empty ) {
+ $connections = $this->get_connections( $service_name, $_blog_id, $_user_id );
+ if ( $connections ) {
+ $connected_services[ $service_name ] = $connections;
}
- return $connected_services;
}
+ return $connected_services;
}
- function get_connection( $service_name, $id, $_blog_id = false, $_user_id = false ) {
- // Stub
+ /**
+ * Get a specific connection. Stub.
+ *
+ * @param string $service_name 'facebook', 'twitter', etc.
+ * @param string $connection_id Connection ID.
+ * @param false|int $_blog_id The blog ID. Use false (default) for the current blog.
+ * @param false|int $_user_id The user ID. Use false (default) for the current user.
+ * @return void
+ */
+ public function get_connection( $service_name, $connection_id, $_blog_id = false, $_user_id = false ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
+ // Stub.
}
- function flag_post_for_publicize( $new_status, $old_status, $post ) {
+ /**
+ * Flag a post for Publicize after publishing.
+ *
+ * @param string $new_status New status of the post.
+ * @param string $old_status Old status of the post.
+ * @param WP_Post $post Post object.
+ */
+ public function flag_post_for_publicize( $new_status, $old_status, $post ) {
if ( ! $this->post_type_is_publicizeable( $post->post_type ) ) {
return;
}
- if ( 'publish' == $new_status && 'publish' != $old_status ) {
+ $should_publicize = $this->should_submit_post_pre_checks( $post );
+
+ if ( 'publish' === $new_status && 'publish' !== $old_status ) {
/**
* Determines whether a post being published gets publicized.
*
@@ -384,26 +554,32 @@ class Publicize extends Publicize_Base {
* @module publicize
*
* @since 4.1.0
+ * @since 10.9 No longer defaults to true. Adds checks to not publicize based on different contexts.
*
* @param bool $should_publicize Should the post be publicized? Default to true.
* @param WP_POST $post Current Post object.
*/
- $should_publicize = apply_filters( 'publicize_should_publicize_published_post', true, $post );
+ $should_publicize = apply_filters( 'publicize_should_publicize_published_post', $should_publicize, $post );
if ( $should_publicize ) {
- update_post_meta( $post->ID, $this->PENDING, true );
+ update_post_meta( $post->ID, $this->PENDING, true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
}
}
}
- function test_connection( $service_name, $connection ) {
-
+ /**
+ * Test a connection.
+ *
+ * @param string $service_name Name of the service.
+ * @param array $connection Connection to be tested.
+ */
+ public function test_connection( $service_name, $connection ) {
$id = $this->get_connection_id( $connection );
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.testPublicizeConnection', $id );
- // Bail if all is well
+ // Bail if all is well.
if ( ! $xml->isError() ) {
return true;
}
@@ -411,10 +587,10 @@ class Publicize extends Publicize_Base {
$xml_response = $xml->getResponse();
$connection_test_message = $xml_response['faultString'];
- // Set up refresh if the user can
- $user_can_refresh = current_user_can( $this->GLOBAL_CAP );
+ // Set up refresh if the user can.
+ $user_can_refresh = current_user_can( $this->GLOBAL_CAP ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
if ( $user_can_refresh ) {
- $nonce = wp_create_nonce( "keyring-request-" . $service_name );
+ /* translators: %s is the name of a social media service */
$refresh_text = sprintf( _x( 'Refresh connection with %s', 'Refresh connection with {social media service}', 'jetpack' ), $this->get_service_label( $service_name ) );
$refresh_url = $this->refresh_url( $service_name );
}
@@ -422,7 +598,7 @@ class Publicize extends Publicize_Base {
$error_data = array(
'user_can_refresh' => $user_can_refresh,
'refresh_text' => $refresh_text,
- 'refresh_url' => $refresh_url
+ 'refresh_url' => $refresh_url,
);
return new WP_Error( 'pub_conn_test_failed', $connection_test_message, $error_data );
@@ -444,35 +620,50 @@ class Publicize extends Publicize_Base {
public function post_is_done_sharing( $post_id = null ) {
// Defaults to current post if $post_id is null.
$post = get_post( $post_id );
- if ( is_null( $post ) ) {
+ if ( $post === null ) {
return false;
}
- return 'publish' == $post->post_status || get_post_meta( $post->ID, $this->POST_DONE . 'all', true );
+ return 'publish' === $post->post_status || get_post_meta( $post->ID, $this->POST_DONE . 'all', true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
}
/**
* Save a flag locally to indicate that this post has already been Publicized via the selected
* connections.
+ *
+ * @param int $post_ID Post ID.
+ * @param \WP_Post $post Post object.
*/
- function save_publicized( $post_ID, $post = null, $update = null ) {
- if ( is_null( $post ) ) {
+ public function save_publicized( $post_ID, $post = null ) {
+ if ( $post === null ) {
return;
}
- // Only do this when a post transitions to being published
+ // Only do this when a post transitions to being published.
+ // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
if ( get_post_meta( $post->ID, $this->PENDING ) && $this->post_type_is_publicizeable( $post->post_type ) ) {
delete_post_meta( $post->ID, $this->PENDING );
update_post_meta( $post->ID, $this->POST_DONE . 'all', true );
}
+ // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
}
- function set_post_flags( $flags, $post ) {
+ /**
+ * Set post flags for Publicize.
+ *
+ * @param array $flags List of flags.
+ * @param \WP_Post $post Post object.
+ * @return array
+ */
+ public function set_post_flags( $flags, $post ) {
$flags['publicize_post'] = false;
if ( ! $this->post_type_is_publicizeable( $post->post_type ) ) {
return $flags;
}
+
+ $should_publicize = $this->should_submit_post_pre_checks( $post );
+
/** This filter is already documented in modules/publicize/publicize-jetpack.php */
- if ( ! apply_filters( 'publicize_should_publicize_published_post', true, $post ) ) {
+ if ( ! apply_filters( 'publicize_should_publicize_published_post', $should_publicize, $post ) ) {
return $flags;
}
@@ -488,25 +679,25 @@ class Publicize extends Publicize_Base {
}
/**
- * Options Code
+ * Render Facebook options.
*/
+ public function options_page_facebook() {
+ $connection_name = isset( $_REQUEST['connection'] ) ? filter_var( wp_unslash( $_REQUEST['connection'] ) ) : '';
+ // Nonce check.
+ check_admin_referer( 'options_page_facebook_' . $connection_name );
- function options_page_facebook() {
$connected_services = $this->get_all_connections();
- $connection = $connected_services['facebook'][ $_REQUEST['connection'] ];
+ $connection = $connected_services['facebook'][ $connection_name ];
$options_to_show = ( ! empty( $connection['connection_data']['meta']['options_responses'] ) ? $connection['connection_data']['meta']['options_responses'] : false );
- // Nonce check
- check_admin_referer( 'options_page_facebook_' . $_REQUEST['connection'] );
-
$pages = ( ! empty( $options_to_show[1]['data'] ) ? $options_to_show[1]['data'] : false );
- $page_selected = false;
+ $page_selected = false;
if ( ! empty( $connection['connection_data']['meta']['facebook_page'] ) ) {
$found = false;
- if ( $pages && isset( $pages->data ) && is_array( $pages->data ) ) {
+ if ( $pages && isset( $pages->data ) && is_array( $pages->data ) ) {
foreach ( $pages->data as $page ) {
- if ( $page->id == $connection['connection_data']['meta']['facebook_page'] ) {
+ if ( $page->id === (int) $connection['connection_data']['meta']['facebook_page'] ) {
$found = true;
break;
}
@@ -514,29 +705,40 @@ class Publicize extends Publicize_Base {
}
if ( $found ) {
- $page_selected = $connection['connection_data']['meta']['facebook_page'];
+ $page_selected = $connection['connection_data']['meta']['facebook_page'];
}
}
?>
<div id="thickbox-content">
-
<?php
ob_start();
Publicize_UI::connected_notice( 'Facebook' );
$update_notice = ob_get_clean();
if ( ! empty( $update_notice ) ) {
- echo $update_notice;
+ echo wp_kses_post( $update_notice );
}
$page_info_message = sprintf(
- __( 'Facebook supports Publicize connections to Facebook Pages, but not to Facebook Profiles. <a href="%s">Learn More about Publicize for Facebook</a>', 'jetpack' ),
+ wp_kses(
+ /* translators: %s is the link to the support page about using Facebook with Publicize */
+ __( 'Facebook supports Publicize connections to Facebook Pages, but not to Facebook Profiles. <a href="%s">Learn More about Publicize for Facebook</a>', 'jetpack' ),
+ array( 'a' => array( 'href' ) )
+ ),
esc_url( Redirect::get_url( 'jetpack-support-publicize-facebook' ) )
);
- if ( $pages ) : ?>
- <p><?php _e( 'Publicize to my <strong>Facebook Page</strong>:', 'jetpack' ); ?></p>
+ if ( $pages ) :
+ ?>
+ <p>
+ <?php
+ echo wp_kses(
+ __( 'Publicize to my <strong>Facebook Page</strong>:', 'jetpack' ),
+ array( 'strong' )
+ );
+ ?>
+ </p>
<table id="option-fb-fanpage">
<tbody>
@@ -544,20 +746,25 @@ class Publicize extends Publicize_Base {
<?php if ( ! ( $i % 2 ) ) : ?>
<tr>
<?php endif; ?>
- <td class="radio"><input type="radio" name="option" data-type="page"
- id="<?php echo esc_attr( $page['id'] ) ?>"
- value="<?php echo esc_attr( $page['id'] ) ?>" <?php checked( $page_selected && $page_selected == $page['id'], true ); ?> />
+ <td class="radio">
+ <input
+ type="radio"
+ name="option"
+ data-type="page"
+ id="<?php echo esc_attr( $page['id'] ); ?>"
+ value="<?php echo esc_attr( $page['id'] ); ?>"
+ <?php checked( $page_selected && (int) $page_selected === (int) $page['id'], true ); ?> />
</td>
- <td class="thumbnail"><label for="<?php echo esc_attr( $page['id'] ) ?>"><img
- src="<?php echo esc_url( str_replace( '_s', '_q', $page['picture']['data']['url'] ) ) ?>"
+ <td class="thumbnail"><label for="<?php echo esc_attr( $page['id'] ); ?>"><img
+ src="<?php echo esc_url( str_replace( '_s', '_q', $page['picture']['data']['url'] ) ); ?>"
width="50" height="50"/></label></td>
<td class="details">
- <label for="<?php echo esc_attr( $page['id'] ) ?>">
- <span class="name"><?php echo esc_html( $page['name'] ) ?></span><br/>
- <span class="category"><?php echo esc_html( $page['category'] ) ?></span>
+ <label for="<?php echo esc_attr( $page['id'] ); ?>">
+ <span class="name"><?php echo esc_html( $page['name'] ); ?></span><br/>
+ <span class="category"><?php echo esc_html( $page['category'] ); ?></span>
</label>
</td>
- <?php if ( ( $i % 2 ) || ( $i == count( $pages ) - 1 ) ): ?>
+ <?php if ( ( $i % 2 ) || ( count( $pages ) - 1 === $i ) ) : ?>
</tr>
<?php endif; ?>
<?php endforeach; ?>
@@ -565,53 +772,75 @@ class Publicize extends Publicize_Base {
</tbody>
</table>
- <?php Publicize_UI::global_checkbox( 'facebook', $_REQUEST['connection'] ); ?>
+ <?php Publicize_UI::global_checkbox( 'facebook', $connection_name ); ?>
<p style="text-align: center;">
- <input type="submit" value="<?php esc_attr_e( 'OK', 'jetpack' ) ?>"
- class="button fb-options save-options" name="save"
- data-connection="<?php echo esc_attr( $_REQUEST['connection'] ); ?>"
- rel="<?php echo wp_create_nonce( 'save_fb_token_' . $_REQUEST['connection'] ) ?>"/>
+ <input type="submit" value="<?php esc_attr_e( 'OK', 'jetpack' ); ?>"
+ class="button fb-options save-options" name="save"
+ data-connection="<?php echo esc_attr( $connection_name ); ?>"
+ rel="<?php echo esc_attr( wp_create_nonce( 'save_fb_token_' . $connection_name ) ); ?>"/>
</p><br/>
+ <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<p><?php echo $page_info_message; ?></p>
- <?php else: ?>
+ <?php else : ?>
<div>
+ <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<p><?php echo $page_info_message; ?></p>
- <p><?php printf( __( '<a class="button" href="%s" target="%s">Create a Facebook page</a> to get started.', 'jetpack' ), 'https://www.facebook.com/pages/creation/', '_blank noopener noreferrer' ); ?></p>
+ <p>
+ <?php
+ echo wp_kses(
+ sprintf(
+ /* translators: %1$s is the link to Facebook documentation to create a page, %2$s is the target of the link */
+ __( '<a class="button" href="%1$s" target="%2$s">Create a Facebook page</a> to get started.', 'jetpack' ),
+ 'https://www.facebook.com/pages/creation/',
+ '_blank noopener noreferrer'
+ ),
+ array( 'a' => array( 'class', 'href', 'target' ) )
+ );
+ ?>
+ </p>
</div>
<?php endif; ?>
</div>
<?php
}
- function options_save_facebook() {
- // Nonce check
- check_admin_referer( 'save_fb_token_' . $_REQUEST['connection'] );
+ /**
+ * Save Facebook options.
+ */
+ public function options_save_facebook() {
+ $connection_name = isset( $_REQUEST['connection'] ) ? filter_var( wp_unslash( $_REQUEST['connection'] ) ) : '';
+ // Nonce check.
+ check_admin_referer( 'save_fb_token_' . $connection_name );
+
+ if ( ! isset( $_POST['type'] ) || 'page' !== $_POST['type'] || ! isset( $_POST['selected_id'] ) ) {
+ return;
+ }
- // Check for a numeric page ID
- $page_id = $_POST['selected_id'];
+ // Check for a numeric page ID.
+ $page_id = $_POST['selected_id']; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- Manually validated just below
if ( ! ctype_digit( $page_id ) ) {
die( 'Security check' );
}
- if ( 'page' != $_POST['type'] || ! isset( $_POST['selected_id'] ) ) {
- return;
- }
-
- // Publish to Page
+ // Publish to Page.
$options = array(
'facebook_page' => $page_id,
- 'facebook_profile' => null
+ 'facebook_profile' => null,
);
- $this->set_remote_publicize_options( $_POST['connection'], $options );
+ $this->set_remote_publicize_options( $connection_name, $options );
}
- function options_page_tumblr() {
- // Nonce check
- check_admin_referer( 'options_page_tumblr_' . $_REQUEST['connection'] );
+ /**
+ * Render Tumblr options.
+ */
+ public function options_page_tumblr() {
+ $connection_name = isset( $_REQUEST['connection'] ) ? filter_var( wp_unslash( $_REQUEST['connection'] ) ) : '';
+ // Nonce check.
+ check_admin_referer( 'options_page_tumblr_' . $connection_name );
$connected_services = $this->get_all_connections();
- $connection = $connected_services['tumblr'][ $_POST['connection'] ];
+ $connection = $connected_services['tumblr'][ $connection_name ];
$options_to_show = $connection['connection_data']['meta']['options_responses'];
$request = $options_to_show[0];
@@ -621,22 +850,22 @@ class Publicize extends Publicize_Base {
if ( ! empty( $connection['connection_data']['meta']['tumblr_base_hostname'] ) ) {
foreach ( $blogs as $blog ) {
- if ( $connection['connection_data']['meta']['tumblr_base_hostname'] == $this->get_basehostname( $blog['url'] ) ) {
+ if ( $connection['connection_data']['meta']['tumblr_base_hostname'] === $this->get_basehostname( $blog['url'] ) ) {
$blog_selected = $connection['connection_data']['meta']['tumblr_base_hostname'];
break;
}
}
-
}
- // Use their Primary blog if they haven't selected one yet
+ // Use their Primary blog if they haven't selected one yet.
if ( ! $blog_selected ) {
foreach ( $blogs as $blog ) {
if ( $blog['primary'] ) {
$blog_selected = $this->get_basehostname( $blog['url'] );
}
}
- } ?>
+ }
+ ?>
<div id="thickbox-content">
@@ -646,90 +875,128 @@ class Publicize extends Publicize_Base {
$update_notice = ob_get_clean();
if ( ! empty( $update_notice ) ) {
- echo $update_notice;
+ echo wp_kses_post( $update_notice );
}
?>
- <p><?php _e( 'Publicize to my <strong>Tumblr blog</strong>:', 'jetpack' ); ?></p>
+ <p><?php echo wp_kses( __( 'Publicize to my <strong>Tumblr blog</strong>:', 'jetpack' ), array( 'strong' ) ); ?></p>
<ul id="option-tumblr-blog">
<?php
foreach ( $blogs as $blog ) {
- $url = $this->get_basehostname( $blog['url'] ); ?>
+ $url = $this->get_basehostname( $blog['url'] );
+ ?>
<li>
- <input type="radio" name="option" data-type="blog" id="<?php echo esc_attr( $url ) ?>"
- value="<?php echo esc_attr( $url ) ?>" <?php checked( $blog_selected == $url, true ); ?> />
- <label for="<?php echo esc_attr( $url ) ?>"><span
- class="name"><?php echo esc_html( $blog['title'] ) ?></span></label>
+ <input type="radio" name="option" data-type="blog" id="<?php echo esc_attr( $url ); ?>"
+ value="<?php echo esc_attr( $url ); ?>" <?php checked( $blog_selected === $url, true ); ?> />
+ <label for="<?php echo esc_attr( $url ); ?>"><span
+ class="name"><?php echo esc_html( $blog['title'] ); ?></span></label>
</li>
<?php } ?>
</ul>
- <?php Publicize_UI::global_checkbox( 'tumblr', $_REQUEST['connection'] ); ?>
+ <?php Publicize_UI::global_checkbox( 'tumblr', $connection_name ); ?>
<p style="text-align: center;">
- <input type="submit" value="<?php esc_attr_e( 'OK', 'jetpack' ) ?>"
- class="button tumblr-options save-options" name="save"
- data-connection="<?php echo esc_attr( $_REQUEST['connection'] ); ?>"
- rel="<?php echo wp_create_nonce( 'save_tumblr_blog_' . $_REQUEST['connection'] ) ?>"/>
+ <input type="submit" value="<?php esc_attr_e( 'OK', 'jetpack' ); ?>"
+ class="button tumblr-options save-options" name="save"
+ data-connection="<?php echo esc_attr( $connection_name ); ?>"
+ rel="<?php echo esc_attr( wp_create_nonce( 'save_tumblr_blog_' . $connection_name ) ); ?>"/>
</p> <br/>
</div>
<?php
}
- function get_basehostname( $url ) {
+ /**
+ * Get the hostname from a URL.
+ *
+ * @param string $url The URL to extract the hostname from.
+ * @return string|false|null
+ */
+ public function get_basehostname( $url ) {
return wp_parse_url( $url, PHP_URL_HOST );
}
- function options_save_tumblr() {
- // Nonce check
- check_admin_referer( 'save_tumblr_blog_' . $_REQUEST['connection'] );
- $options = array( 'tumblr_base_hostname' => $_POST['selected_id'] );
+ /**
+ * Save Tumblr options.
+ */
+ public function options_save_tumblr() {
+ $connection_name = isset( $_REQUEST['connection'] ) ? filter_var( wp_unslash( $_REQUEST['connection'] ) ) : '';
+ // Nonce check.
+ check_admin_referer( 'save_tumblr_blog_' . $connection_name );
+ $options = array( 'tumblr_base_hostname' => isset( $_POST['selected_id'] ) ? sanitize_text_field( wp_unslash( $_POST['selected_id'] ) ) : null );
- $this->set_remote_publicize_options( $_POST['connection'], $options );
+ $this->set_remote_publicize_options( $connection_name, $options );
}
- function set_remote_publicize_options( $id, $options ) {
+ /**
+ * Set remote Publicize options.
+ *
+ * @param int $id Connection ID.
+ * @param array $options Options to set.
+ */
+ public function set_remote_publicize_options( $id, $options ) {
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.setPublicizeOptions', $id, $options );
if ( ! $xml->isError() ) {
$response = $xml->getResponse();
Jetpack_Options::update_option( 'publicize_connections', $response );
- $this->globalization();
+ $this->globalization( $id );
}
}
- function options_page_twitter() {
+ /**
+ * Render the options page for Twitter.
+ */
+ public function options_page_twitter() {
Publicize_UI::options_page_other( 'twitter' );
}
- function options_page_linkedin() {
+ /**
+ * Render the options page for LinkedIn.
+ */
+ public function options_page_linkedin() {
Publicize_UI::options_page_other( 'linkedin' );
}
- function options_save_twitter() {
+ /**
+ * Save the options page for Twitter.
+ */
+ public function options_save_twitter() {
$this->options_save_other( 'twitter' );
}
- function options_save_linkedin() {
+ /**
+ * Save the options page for LinkedIn.
+ */
+ public function options_save_linkedin() {
$this->options_save_other( 'linkedin' );
}
- function options_save_other( $service_name ) {
- // Nonce check
- check_admin_referer( 'save_' . $service_name . '_token_' . $_REQUEST['connection'] );
- $this->globalization();
+ /**
+ * Save the options page for a service.
+ *
+ * @param string $service_name Name of the service to save options for.
+ */
+ public function options_save_other( $service_name ) {
+ $connection_name = isset( $_REQUEST['connection'] ) ? filter_var( wp_unslash( $_REQUEST['connection'] ) ) : '';
+ // Nonce check.
+ check_admin_referer( 'save_' . $service_name . '_token_' . $connection_name );
+
+ $this->globalization( $connection_name );
}
/**
* If there's only one shared connection to Twitter set it as twitter:site tag.
+ *
+ * @param string $tag Tag.
*/
- function enhaced_twitter_cards_site_tag( $tag ) {
+ public function enhaced_twitter_cards_site_tag( $tag ) {
$custom_site_tag = get_option( 'jetpack-twitter-cards-site-tag' );
if ( ! empty( $custom_site_tag ) ) {
return $tag;
@@ -740,8 +1007,8 @@ class Publicize extends Publicize_Base {
$connections = $this->get_connections( 'twitter' );
foreach ( $connections as $connection ) {
$connection_meta = $this->get_connection_meta( $connection );
- if ( 0 == $connection_meta['connection_data']['user_id'] ) {
- // If the connection is shared
+ if ( $this->is_global_connection( $connection_meta ) ) {
+ // If the connection is shared.
return $this->get_display_name( 'twitter', $connection );
}
}
@@ -749,17 +1016,32 @@ class Publicize extends Publicize_Base {
return $tag;
}
- function save_publicized_twitter_account( $submit_post, $post_id, $service_name, $connection ) {
- if ( 'twitter' == $service_name && $submit_post ) {
+ /**
+ * Save the Publicized Twitter account when publishing a post.
+ *
+ * @param bool $submit_post Should the post be publicized.
+ * @param int $post_id Post ID.
+ * @param string $service_name Service name.
+ * @param array $connection Array of connection details.
+ */
+ public function save_publicized_twitter_account( $submit_post, $post_id, $service_name, $connection ) {
+ if ( 'twitter' === $service_name && $submit_post ) {
$connection_meta = $this->get_connection_meta( $connection );
$publicize_twitter_user = get_post_meta( $post_id, '_publicize_twitter_user' );
- if ( empty( $publicize_twitter_user ) || 0 != $connection_meta['connection_data']['user_id'] ) {
+ if ( empty( $publicize_twitter_user ) || ! $this->is_global_connection( $connection_meta ) ) {
update_post_meta( $post_id, '_publicize_twitter_user', $this->get_display_name( 'twitter', $connection ) );
}
}
}
- function get_publicized_twitter_account( $account, $post_id ) {
+ /**
+ * Get the Twitter username.
+ *
+ * @param string $account Twitter username.
+ * @param int $post_id ID of the post.
+ * @return string
+ */
+ public function get_publicized_twitter_account( $account, $post_id ) {
if ( ! empty( $account ) ) {
return $account;
}
@@ -774,12 +1056,17 @@ class Publicize extends Publicize_Base {
/**
* Save the Publicized Facebook account when publishing a post
* Use only Personal accounts, not Facebook Pages
+ *
+ * @param bool $submit_post Should the post be publicized.
+ * @param int $post_id Post ID.
+ * @param string $service_name Service name.
+ * @param array $connection Array of connection details.
*/
- function save_publicized_facebook_account( $submit_post, $post_id, $service_name, $connection ) {
+ public function save_publicized_facebook_account( $submit_post, $post_id, $service_name, $connection ) {
$connection_meta = $this->get_connection_meta( $connection );
- if ( 'facebook' == $service_name && isset( $connection_meta['connection_data']['meta']['facebook_profile'] ) && $submit_post ) {
+ if ( 'facebook' === $service_name && isset( $connection_meta['connection_data']['meta']['facebook_profile'] ) && $submit_post ) {
$publicize_facebook_user = get_post_meta( $post_id, '_publicize_facebook_user' );
- if ( empty( $publicize_facebook_user ) || 0 != $connection_meta['connection_data']['user_id'] ) {
+ if ( empty( $publicize_facebook_user ) || ! $this->is_global_connection( $connection_meta ) ) {
$profile_link = $this->get_profile_link( 'facebook', $connection );
if ( false !== $profile_link ) {
diff --git a/plugins/jetpack/modules/publicize/publicize.php b/plugins/jetpack/modules/publicize/publicize.php
index 32d43d09..d211c5d1 100644
--- a/plugins/jetpack/modules/publicize/publicize.php
+++ b/plugins/jetpack/modules/publicize/publicize.php
@@ -1,28 +1,49 @@
-<?php
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Publicize_Base class.
+ *
+ * @package automattic/jetpack
+ */
+
// phpcs:disable WordPress.NamingConventions.ValidVariableName
use Automattic\Jetpack\Redirect;
use Automattic\Jetpack\Status;
+/**
+ * Base class for Publicize.
+ */
abstract class Publicize_Base {
/**
- * Services that are currently connected to the given user
- * through publicize.
- */
+ * Services that are currently connected to the given user
+ * through Publicize.
+ *
+ * @var array
+ */
public $connected_services = array();
/**
- * Services that are supported by publicize. They don't
- * necessarily need to be connected to the current user.
- */
+ * Services that are supported by publicize. They don't
+ * necessarily need to be connected to the current user.
+ *
+ * @var array
+ */
public $services;
/**
- * key names for post meta
- */
- public $ADMIN_PAGE = 'wpas';
- public $POST_MESS = '_wpas_mess';
+ * Post meta key for admin page.
+ *
+ * @var string
+ */
+ public $ADMIN_PAGE = 'wpas';
+
+ /**
+ * Post meta key for post message.
+ *
+ * @var string
+ */
+ public $POST_MESS = '_wpas_mess';
/**
* Post meta key for flagging when the post is a tweetstorm.
@@ -38,75 +59,135 @@ abstract class Publicize_Base {
*/
const POST_PUBLICIZE_FEATURE_ENABLED = '_wpas_feature_enabled';
- public $POST_SKIP = '_wpas_skip_'; // connection id appended to indicate that a connection should NOT be publicized to
- public $POST_DONE = '_wpas_done_'; // connection id appended to indicate a connection has already been publicized to
- public $USER_AUTH = 'wpas_authorize';
- public $USER_OPT = 'wpas_';
- public $PENDING = '_publicize_pending'; // ready for Publicize to do its thing
- public $POST_SERVICE_DONE = '_publicize_done_external'; // array of external ids where we've Publicized
+ /**
+ * Connection ID appended to indicate that a connection should NOT be publicized to.
+ *
+ * @var string
+ */
+ public $POST_SKIP = '_wpas_skip_';
+
+ /**
+ * Connection ID appended to indicate a connection has already been publicized to.
+ *
+ * @var string
+ */
+ public $POST_DONE = '_wpas_done_';
+
+ /**
+ * Prefix for user authorization (used in publicize-wpcom.php)
+ *
+ * @var string
+ */
+ public $USER_AUTH = 'wpas_authorize';
+
+ /**
+ * Prefix for user opt.
+ *
+ * @var string
+ */
+ public $USER_OPT = 'wpas_';
+
+ /**
+ * Ready for Publicize to do its thing.
+ *
+ * @var string
+ */
+ public $PENDING = '_publicize_pending';
+
+ /**
+ * Array of external IDs where we've Publicized.
+ *
+ * @var string
+ */
+ public $POST_SERVICE_DONE = '_publicize_done_external';
+
+ /**
+ * Default pieces of the message used in constructing the
+ * content pushed out to other social networks.
+ */
/**
- * default pieces of the message used in constructing the
- * content pushed out to other social networks
- */
+ * Default prefix.
+ *
+ * @var string
+ */
+ public $default_prefix = '';
- public $default_prefix = '';
+ /**
+ * Default message.
+ *
+ * @var string
+ */
public $default_message = '%title%';
- public $default_suffix = ' ';
+
+ /**
+ * Default suffix.
+ *
+ * @var string
+ */
+ public $default_suffix = ' ';
/**
* What WP capability is require to create/delete global connections?
* All users with this cap can un-globalize all other global connections, and globalize any of their own
* Globalized connections cannot be unselected by users without this capability when publishing
+ *
+ * @var string
*/
public $GLOBAL_CAP = 'publish_posts';
/**
- * Sets up the basics of Publicize
- */
- function __construct() {
- $this->default_message = self::build_sprintf( array(
- /**
- * Filter the default Publicize message.
- *
- * @module publicize
- *
- * @since 2.0.0
- *
- * @param string $this->default_message Publicize's default message. Default is the post title.
- */
- apply_filters( 'wpas_default_message', $this->default_message ),
- 'title',
- 'url',
- ) );
-
- $this->default_prefix = self::build_sprintf( array(
- /**
- * Filter the message prepended to the Publicize custom message.
- *
- * @module publicize
- *
- * @since 2.0.0
- *
- * @param string $this->default_prefix String prepended to the Publicize custom message.
- */
- apply_filters( 'wpas_default_prefix', $this->default_prefix ),
- 'url',
- ) );
-
- $this->default_suffix = self::build_sprintf( array(
- /**
- * Filter the message appended to the Publicize custom message.
- *
- * @module publicize
- *
- * @since 2.0.0
- *
- * @param string $this->default_suffix String appended to the Publicize custom message.
- */
- apply_filters( 'wpas_default_suffix', $this->default_suffix ),
- 'url',
- ) );
+ * Sets up the basics of Publicize.
+ */
+ public function __construct() {
+ $this->default_message = self::build_sprintf(
+ array(
+ /**
+ * Filter the default Publicize message.
+ *
+ * @module publicize
+ *
+ * @since 2.0.0
+ *
+ * @param string $this->default_message Publicize's default message. Default is the post title.
+ */
+ apply_filters( 'wpas_default_message', $this->default_message ),
+ 'title',
+ 'url',
+ )
+ );
+
+ $this->default_prefix = self::build_sprintf(
+ array(
+ /**
+ * Filter the message prepended to the Publicize custom message.
+ *
+ * @module publicize
+ *
+ * @since 2.0.0
+ *
+ * @param string $this->default_prefix String prepended to the Publicize custom message.
+ */
+ apply_filters( 'wpas_default_prefix', $this->default_prefix ),
+ 'url',
+ )
+ );
+
+ $this->default_suffix = self::build_sprintf(
+ array(
+ /**
+ * Filter the message appended to the Publicize custom message.
+ *
+ * @module publicize
+ *
+ * @since 2.0.0
+ *
+ * @param string $this->default_suffix String appended to the Publicize custom message.
+ */
+ apply_filters( 'wpas_default_suffix', $this->default_suffix ),
+ 'url',
+ )
+ );
/**
* Filter the capability to change global Publicize connection options.
@@ -123,17 +204,17 @@ abstract class Publicize_Base {
$this->GLOBAL_CAP = apply_filters( 'jetpack_publicize_global_connections_cap', $this->GLOBAL_CAP );
// stage 1 and 2 of 3-stage Publicize. Flag for Publicize on creation, save meta,
- // then check meta and publicize based on that. stage 3 implemented on wpcom
+ // then check meta and publicize based on that. stage 3 implemented on wpcom.
add_action( 'transition_post_status', array( $this, 'flag_post_for_publicize' ), 10, 3 );
- add_action( 'save_post', array( &$this, 'save_meta' ), 20, 2 );
+ add_action( 'save_post', array( $this, 'save_meta' ), 20, 2 );
- // Default checkbox state for each Connection
- add_filter( 'publicize_checkbox_default', array( $this, 'publicize_checkbox_default' ), 10, 4 );
+ // Default checkbox state for each Connection.
+ add_filter( 'publicize_checkbox_default', array( $this, 'publicize_checkbox_default' ), 10, 2 );
// Alter the "Post Publish" admin notice to mention the Connections we Publicized to.
add_filter( 'post_updated_messages', array( $this, 'update_published_message' ), 20, 1 );
- // Connection test callback
+ // Connection test callback.
add_action( 'wp_ajax_test_publicize_conns', array( $this, 'test_publicize_conns' ) );
add_action( 'init', array( $this, 'add_post_type_support' ) );
@@ -141,42 +222,40 @@ abstract class Publicize_Base {
add_action( 'jetpack_register_gutenberg_extensions', array( $this, 'register_gutenberg_extension' ) );
}
-/*
- * Services: Facebook, Twitter, etc.
- */
+ /**
+ * Services: Facebook, Twitter, etc.
+ */
/**
* Get services for the given blog and user.
*
* Can return all available services or just the ones with an active connection.
*
- * @param string $filter
- * 'all' (default) - Get all services available for connecting
- * 'connected' - Get all services currently connected
- * @param false|int $_blog_id The blog ID. Use false (default) for the current blog
- * @param false|int $_user_id The user ID. Use false (default) for the current user
+ * @param string $filter Type of filter.
+ * 'all' (default) - Get all services available for connecting.
+ * 'connected' - Get all services currently connected.
+ * @param false|int $_blog_id The blog ID. Use false (default) for the current blog.
+ * @param false|int $_user_id The user ID. Use false (default) for the current user.
* @return array
*/
- abstract function get_services( $filter = 'all', $_blog_id = false, $_user_id = false );
-
- function can_connect_service( $service_name ) {
- return true;
- }
+ abstract public function get_services( $filter = 'all', $_blog_id = false, $_user_id = false );
/**
* Does the given user have a connection to the service on the given blog?
*
- * @param string $service_name 'facebook', 'twitter', etc.
- * @param false|int $_blog_id The blog ID. Use false (default) for the current blog
- * @param false|int $_user_id The user ID. Use false (default) for the current user
+ * @param string $service_name 'facebook', 'twitter', etc.
+ * @param false|int $_blog_id The blog ID. Use false (default) for the current blog.
+ * @param false|int $_user_id The user ID. Use false (default) for the current user.
* @return bool
*/
- function is_enabled( $service_name, $_blog_id = false, $_user_id = false ) {
- if ( !$_blog_id )
+ public function is_enabled( $service_name, $_blog_id = false, $_user_id = false ) {
+ if ( ! $_blog_id ) {
$_blog_id = $this->blog_id();
+ }
- if ( !$_user_id )
+ if ( ! $_user_id ) {
$_user_id = $this->user_id();
+ }
$connections = $this->get_connections( $service_name, $_blog_id, $_user_id );
return ( is_array( $connections ) && count( $connections ) > 0 ? true : false );
@@ -191,7 +270,7 @@ abstract class Publicize_Base {
* @param string $service_name 'facebook', 'twitter', etc.
* @return string
*/
- abstract function connect_url( $service_name );
+ abstract public function connect_url( $service_name );
/**
* Generates a Connection refresh URL.
@@ -202,7 +281,7 @@ abstract class Publicize_Base {
* @param string $service_name 'facebook', 'twitter', etc.
* @return string
*/
- abstract function refresh_url( $service_name );
+ abstract public function refresh_url( $service_name );
/**
* Generates a disconnection URL.
@@ -211,10 +290,10 @@ abstract class Publicize_Base {
* with the service.
*
* @param string $service_name 'facebook', 'twitter', etc.
- * @param string $connection_id Connection ID
+ * @param string $connection_id Connection ID.
* @return string
*/
- abstract function disconnect_url( $service_name, $connection_id );
+ abstract public function disconnect_url( $service_name, $connection_id );
/**
* Returns a display name for the Service
@@ -226,49 +305,46 @@ abstract class Publicize_Base {
switch ( $service_name ) {
case 'linkedin':
return 'LinkedIn';
- break;
case 'google_drive': // google-drive used to be called google_drive.
case 'google-drive':
return 'Google Drive';
- break;
case 'twitter':
case 'facebook':
case 'tumblr':
default:
return ucfirst( $service_name );
- break;
}
}
-/*
- * Connections: For each Service, there can be multiple connections
- * for a given user. For example, one user could be connected to Twitter
- * as both @jetpack and as @wordpressdotcom
- *
- * For historical reasons, Connections are represented as an object
- * on WordPress.com and as an array in Jetpack.
- */
+ /**
+ * Connections: For each Service, there can be multiple connections
+ * for a given user. For example, one user could be connected to Twitter
+ * as both @jetpack and as @wordpressdotcom
+ *
+ * For historical reasons, Connections are represented as an object
+ * on WordPress.com and as an array in Jetpack.
+ */
/**
* Get the active Connections of a Service
*
- * @param string $service_name 'facebook', 'twitter', etc.
- * @param false|int $_blog_id The blog ID. Use false (default) for the current blog
- * @param false|int $_user_id The user ID. Use false (default) for the current user
+ * @param string $service_name 'facebook', 'twitter', etc.
+ * @param false|int $_blog_id The blog ID. Use false (default) for the current blog.
+ * @param false|int $_user_id The user ID. Use false (default) for the current user.
* @return false|object[]|array[] false if no connections exist
*/
- abstract function get_connections( $service_name, $_blog_id = false, $_user_id = false );
+ abstract public function get_connections( $service_name, $_blog_id = false, $_user_id = false );
/**
* Get a single Connection of a Service
*
- * @param string $service_name 'facebook', 'twitter', etc.
- * @param string $connection_id Connection ID
- * @param false|int $_blog_id The blog ID. Use false (default) for the current blog
- * @param false|int $_user_id The user ID. Use false (default) for the current user
+ * @param string $service_name 'facebook', 'twitter', etc.
+ * @param string $connection_id Connection ID.
+ * @param false|int $_blog_id The blog ID. Use false (default) for the current blog.
+ * @param false|int $_user_id The user ID. Use false (default) for the current user.
* @return false|object[]|array[] false if no connections exist
*/
- abstract function get_connection( $service_name, $connection_id, $_blog_id = false, $_user_id = false );
+ abstract public function get_connection( $service_name, $connection_id, $_blog_id = false, $_user_id = false );
/**
* Get the Connection ID.
@@ -278,10 +354,10 @@ abstract class Publicize_Base {
* Via a quirk of history, ID is globally unique and unique_id
* is only unique per site.
*
- * @param object|array The Connection object (WordPress.com) or array (Jetpack)
+ * @param object|array $connection The Connection object (WordPress.com) or array (Jetpack).
* @return string
*/
- abstract function get_connection_id( $connection );
+ abstract public function get_connection_id( $connection );
/**
* Get the Connection unique_id
@@ -291,77 +367,88 @@ abstract class Publicize_Base {
* Via a quirk of history, ID is globally unique and unique_id
* is only unique per site.
*
- * @param object|array The Connection object (WordPress.com) or array (Jetpack)
+ * @param object|array $connection The Connection object (WordPress.com) or array (Jetpack).
* @return string
*/
- abstract function get_connection_unique_id( $connection );
+ abstract public function get_connection_unique_id( $connection );
/**
* Get the Connection's Meta data
*
- * @param object|array Connection
+ * @param object|array $connection Connection.
* @return array Connection Meta
*/
- abstract function get_connection_meta( $connection );
+ abstract public function get_connection_meta( $connection );
/**
* Disconnect a Connection
*
- * @param string $service_name 'facebook', 'twitter', etc.
- * @param string $connection_id Connection ID
- * @param false|int $_blog_id The blog ID. Use false (default) for the current blog
- * @param false|int $_user_id The user ID. Use false (default) for the current user
- * @param bool $force_delete Whether to skip permissions checks
+ * @param string $service_name 'facebook', 'twitter', etc.
+ * @param string $connection_id Connection ID.
+ * @param false|int $_blog_id The blog ID. Use false (default) for the current blog.
+ * @param false|int $_user_id The user ID. Use false (default) for the current user.
+ * @param bool $force_delete Whether to skip permissions checks.
* @return false|void False on failure. Void on success.
*/
- abstract function disconnect( $service_name, $connection_id, $_blog_id = false, $_user_id = false, $force_delete = false );
+ abstract public function disconnect( $service_name, $connection_id, $_blog_id = false, $_user_id = false, $force_delete = false );
/**
* Globalizes a Connection
*
- * @param string $connection_id Connection ID
+ * @param string $connection_id Connection ID.
* @return bool Falsey on failure. Truthy on success.
*/
- abstract function globalize_connection( $connection_id );
+ abstract public function globalize_connection( $connection_id );
/**
* Unglobalizes a Connection
*
- * @param string $connection_id Connection ID
+ * @param string $connection_id Connection ID.
* @return bool Falsey on failure. Truthy on success.
*/
- abstract function unglobalize_connection( $connection_id );
+ abstract public function unglobalize_connection( $connection_id );
/**
* Returns an external URL to the Connection's profile
*
- * @param string $service_name 'facebook', 'twitter', etc.
- * @param object|array The Connection object (WordPress.com) or array (Jetpack)
+ * @param string $service_name 'facebook', 'twitter', etc.
+ * @param object|array $connection The Connection object (WordPress.com) or array (Jetpack).
* @return false|string False on failure. URL on success.
*/
- function get_profile_link( $service_name, $connection ) {
+ public function get_profile_link( $service_name, $connection ) {
$cmeta = $this->get_connection_meta( $connection );
if ( isset( $cmeta['connection_data']['meta']['link'] ) ) {
- if ( 'facebook' == $service_name && 0 === strpos( wp_parse_url( $cmeta['connection_data']['meta']['link'], PHP_URL_PATH ), '/app_scoped_user_id/' ) ) {
- // App-scoped Facebook user IDs are not usable profile links
+ if ( 'facebook' === $service_name && 0 === strpos( wp_parse_url( $cmeta['connection_data']['meta']['link'], PHP_URL_PATH ), '/app_scoped_user_id/' ) ) {
+ // App-scoped Facebook user IDs are not usable profile links.
return false;
}
return $cmeta['connection_data']['meta']['link'];
- } elseif ( 'facebook' == $service_name && isset( $cmeta['connection_data']['meta']['facebook_page'] ) ) {
+ }
+
+ if ( 'facebook' === $service_name && isset( $cmeta['connection_data']['meta']['facebook_page'] ) ) {
return 'https://facebook.com/' . $cmeta['connection_data']['meta']['facebook_page'];
- } elseif ( 'tumblr' == $service_name && isset( $cmeta['connection_data']['meta']['tumblr_base_hostname'] ) ) {
- return 'https://' . $cmeta['connection_data']['meta']['tumblr_base_hostname'];
- } elseif ( 'twitter' == $service_name ) {
- return 'https://twitter.com/' . substr( $cmeta['external_display'], 1 ); // Has a leading '@'
- } else if ( 'linkedin' == $service_name ) {
- if ( !isset( $cmeta['connection_data']['meta']['profile_url'] ) ) {
+ }
+
+ if ( 'tumblr' === $service_name && isset( $cmeta['connection_data']['meta']['tumblr_base_hostname'] ) ) {
+ return 'https://' . $cmeta['connection_data']['meta']['tumblr_base_hostname'];
+ }
+
+ if ( 'twitter' === $service_name ) {
+ return 'https://twitter.com/' . substr( $cmeta['external_display'], 1 ); // Has a leading '@'.
+ }
+
+ if ( 'linkedin' === $service_name ) {
+ if ( ! isset( $cmeta['connection_data']['meta']['profile_url'] ) ) {
return false;
}
$profile_url_query = wp_parse_url( $cmeta['connection_data']['meta']['profile_url'], PHP_URL_QUERY );
wp_parse_str( $profile_url_query, $profile_url_query_args );
+
+ $id = null;
+
if ( isset( $profile_url_query_args['key'] ) ) {
$id = $profile_url_query_args['key'];
} elseif ( isset( $profile_url_query_args['id'] ) ) {
@@ -370,34 +457,41 @@ abstract class Publicize_Base {
return false;
}
- return esc_url_raw( add_query_arg( 'id', urlencode( $id ), 'https://www.linkedin.com/profile/view' ) );
- } else {
- return false; // no fallback. we just won't link it
+ return esc_url_raw( add_query_arg( 'id', rawurlencode( $id ), 'https://www.linkedin.com/profile/view' ) );
}
+
+ return false; // no fallback. we just won't link it.
}
/**
* Returns a display name for the Connection
*
- * @param string $service_name 'facebook', 'twitter', etc.
- * @param object|array The Connection object (WordPress.com) or array (Jetpack)
+ * @param string $service_name 'facebook', 'twitter', etc.
+ * @param object|array $connection The Connection object (WordPress.com) or array (Jetpack).
* @return string
*/
- function get_display_name( $service_name, $connection ) {
+ public function get_display_name( $service_name, $connection ) {
$cmeta = $this->get_connection_meta( $connection );
if ( isset( $cmeta['connection_data']['meta']['display_name'] ) ) {
return $cmeta['connection_data']['meta']['display_name'];
- } elseif ( $service_name == 'tumblr' && isset( $cmeta['connection_data']['meta']['tumblr_base_hostname'] ) ) {
- return $cmeta['connection_data']['meta']['tumblr_base_hostname'];
- } elseif ( $service_name == 'twitter' ) {
+ }
+
+ if ( 'tumblr' === $service_name && isset( $cmeta['connection_data']['meta']['tumblr_base_hostname'] ) ) {
+ return $cmeta['connection_data']['meta']['tumblr_base_hostname'];
+ }
+
+ if ( 'twitter' === $service_name ) {
return $cmeta['external_display'];
- } else {
- $connection_display = $cmeta['external_display'];
- if ( empty( $connection_display ) )
- $connection_display = $cmeta['external_name'];
- return $connection_display;
}
+
+ $connection_display = $cmeta['external_display'];
+
+ if ( empty( $connection_display ) ) {
+ $connection_display = $cmeta['external_name'];
+ }
+
+ return $connection_display;
}
/**
@@ -419,60 +513,81 @@ abstract class Publicize_Base {
/**
* Whether the user needs to select additional options after connecting
*
- * @param string $service_name 'facebook', 'twitter', etc.
- * @param object|array The Connection object (WordPress.com) or array (Jetpack)
+ * @param string $service_name 'facebook', 'twitter', etc.
+ * @param object|array $connection The Connection object (WordPress.com) or array (Jetpack).
* @return bool
*/
- function show_options_popup( $service_name, $connection ) {
+ public function show_options_popup( $service_name, $connection ) {
$cmeta = $this->get_connection_meta( $connection );
- // always show if no selection has been made for facebook
- if ( 'facebook' == $service_name && empty( $cmeta['connection_data']['meta']['facebook_profile'] ) && empty( $cmeta['connection_data']['meta']['facebook_page'] ) )
+ // Always show if no selection has been made for Facebook.
+ if ( 'facebook' === $service_name && empty( $cmeta['connection_data']['meta']['facebook_profile'] ) && empty( $cmeta['connection_data']['meta']['facebook_page'] ) ) {
return true;
+ }
- // always show if no selection has been made for tumblr
- if ( 'tumblr' == $service_name && empty ( $cmeta['connection_data']['meta']['tumblr_base_hostname'] ) )
+ // Always show if no selection has been made for Tumblr.
+ if ( 'tumblr' === $service_name && empty( $cmeta['connection_data']['meta']['tumblr_base_hostname'] ) ) {
return true;
+ }
// if we have the specific connection info..
- if ( isset( $_GET['id'] ) ) {
- if ( $cmeta['connection_data']['id'] == $_GET['id'] )
+ $id = ! empty( $_GET['id'] ) ? sanitize_text_field( wp_unslash( $_GET['id'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+
+ if ( $id ) {
+ if ( $cmeta['connection_data']['id'] === $id ) {
return true;
+ }
} else {
- // otherwise, just show if this is the completed step / first load
- if ( !empty( $_GET['action'] ) && 'completed' == $_GET['action'] && !empty( $_GET['service'] ) && $service_name == $_GET['service'] && ! in_array( $_GET['service'], array( 'facebook', 'tumblr' ) ) )
+ // Otherwise, just show if this is the completed step / first load.
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended
+ $is_completed = ! empty( $_GET['action'] ) && 'completed' === $_GET['action'];
+ $service = ! empty( $_GET['service'] ) ? sanitize_text_field( wp_unslash( $_GET['service'] ) ) : false;
+ // phpcs:enable WordPress.Security.NonceVerification.Recommended
+
+ if ( $is_completed && $service_name === $service && ! in_array( $service, array( 'facebook', 'tumblr' ), true ) ) {
return true;
+ }
}
return false;
}
/**
+ * Check if a connection is global
+ *
+ * @param array $connection Connection data.
+ * @return bool Whether the connection is global.
+ */
+ public function is_global_connection( $connection ) {
+ return empty( $connection['connection_data']['user_id'] );
+ }
+
+ /**
* Whether the Connection is "valid" wrt Facebook's requirements.
*
* Must be connected to a Page (not a Profile).
* (Also returns true if we're in the middle of the connection process)
*
- * @param object|array The Connection object (WordPress.com) or array (Jetpack)
+ * @param object|array $connection The Connection object (WordPress.com) or array (Jetpack).
* @return bool
*/
- function is_valid_facebook_connection( $connection ) {
+ public function is_valid_facebook_connection( $connection ) {
if ( $this->is_connecting_connection( $connection ) ) {
return true;
}
$connection_meta = $this->get_connection_meta( $connection );
$connection_data = $connection_meta['connection_data'];
- return isset( $connection_data[ 'meta' ][ 'facebook_page' ] );
+ return isset( $connection_data['meta']['facebook_page'] );
}
/**
* LinkedIn needs to be reauthenticated to use v2 of their API.
* If it's using LinkedIn old API, it's an 'invalid' connection
*
- * @param object|array The Connection object (WordPress.com) or array (Jetpack)
+ * @param object|array $connection The Connection object (WordPress.com) or array (Jetpack).
* @return bool
*/
- function is_invalid_linkedin_connection( $connection ) {
+ public function is_invalid_linkedin_connection( $connection ) {
// LinkedIn API v1 included the profile link in the connection data.
$connection_meta = $this->get_connection_meta( $connection );
return isset( $connection_meta['connection_data']['meta']['profile_url'] );
@@ -481,20 +596,21 @@ abstract class Publicize_Base {
/**
* Whether the Connection currently being connected
*
- * @param object|array The Connection object (WordPress.com) or array (Jetpack)
+ * @param object|array $connection The Connection object (WordPress.com) or array (Jetpack).
* @return bool
*/
- function is_connecting_connection( $connection ) {
+ public function is_connecting_connection( $connection ) {
$connection_meta = $this->get_connection_meta( $connection );
$connection_data = $connection_meta['connection_data'];
- return isset( $connection_data[ 'meta' ]['options_responses'] );
+ return isset( $connection_data['meta']['options_responses'] );
}
/**
* AJAX Handler to run connection tests on all Connections
+ *
* @return void
*/
- function test_publicize_conns() {
+ public function test_publicize_conns() {
wp_send_json_success( $this->get_publicize_conns_test_results() );
}
@@ -514,7 +630,7 @@ abstract class Publicize_Base {
* @type string 'unique_id' ID string representing connection
* }
*/
- function get_publicize_conns_test_results() {
+ public function get_publicize_conns_test_results() {
$test_results = array();
foreach ( (array) $this->get_services( 'connected' ) as $service_name => $connections ) {
@@ -522,11 +638,11 @@ abstract class Publicize_Base {
$id = $this->get_connection_id( $connection );
- $connection_test_passed = true;
- $connection_test_message = __( 'This connection is working correctly.' , 'jetpack' );
- $user_can_refresh = false;
- $refresh_text = '';
- $refresh_url = '';
+ $connection_test_passed = true;
+ $connection_test_message = __( 'This connection is working correctly.', 'jetpack' );
+ $user_can_refresh = false;
+ $refresh_text = '';
+ $refresh_url = '';
$connection_test_result = true;
if ( method_exists( $this, 'test_connection' ) ) {
@@ -534,34 +650,35 @@ abstract class Publicize_Base {
}
if ( is_wp_error( $connection_test_result ) ) {
- $connection_test_passed = false;
+ $connection_test_passed = false;
$connection_test_message = $connection_test_result->get_error_message();
- $error_data = $connection_test_result->get_error_data();
+ $error_data = $connection_test_result->get_error_data();
$user_can_refresh = $error_data['user_can_refresh'];
- $refresh_text = $error_data['refresh_text'];
- $refresh_url = $error_data['refresh_url'];
+ $refresh_text = $error_data['refresh_text'];
+ $refresh_url = $error_data['refresh_url'];
}
- // Mark facebook profiles as deprecated
+ // Mark Facebook profiles as deprecated.
if ( 'facebook' === $service_name ) {
if ( ! $this->is_valid_facebook_connection( $connection ) ) {
- $connection_test_passed = false;
- $user_can_refresh = false;
+ $connection_test_passed = false;
+ $user_can_refresh = false;
$connection_test_message = __( 'Please select a Facebook Page to publish updates.', 'jetpack' );
}
}
- // LinkedIn needs reauthentication to be compatible with v2 of their API
+ // LinkedIn needs reauthentication to be compatible with v2 of their API.
if ( 'linkedin' === $service_name && $this->is_invalid_linkedin_connection( $connection ) ) {
- $connection_test_passed = 'must_reauth';
- $user_can_refresh = false;
+ $connection_test_passed = 'must_reauth';
+ $user_can_refresh = false;
$connection_test_message = esc_html__( 'Your LinkedIn connection needs to be reauthenticated to continue working – head to Sharing to take care of it.', 'jetpack' );
}
$unique_id = null;
+
if ( ! empty( $connection->unique_id ) ) {
$unique_id = $connection->unique_id;
- } else if ( ! empty( $connection['connection_data']['token_id'] ) ) {
+ } elseif ( ! empty( $connection['connection_data']['token_id'] ) ) {
$unique_id = $connection['connection_data']['token_id'];
}
@@ -584,11 +701,11 @@ abstract class Publicize_Base {
/**
* Run the connection test for the Connection
*
- * @param string $service_name 'facebook', 'twitter', etc.
- * @param object|array The Connection object (WordPress.com) or array (Jetpack)
+ * @param string $service_name $service_name 'facebook', 'twitter', etc.
+ * @param object|array $connection The Connection object (WordPress.com) or array (Jetpack).
* @return WP_Error|true WP_Error on failure. True on success
*/
- abstract function test_connection( $service_name, $connection );
+ abstract public function test_connection( $service_name, $connection );
/**
* Retrieves current list of connections and applies filters.
@@ -641,14 +758,13 @@ abstract class Publicize_Base {
$unique_id = $this->get_connection_unique_id( $connection );
-
// Was this connection (OR, old-format service) already Publicized to?
$done = ! empty( $post ) && (
- // New flags
- 1 == get_post_meta( $post->ID, $this->POST_DONE . $unique_id, true )
+ // New flags.
+ 1 === (int) get_post_meta( $post->ID, $this->POST_DONE . $unique_id, true )
||
- // old flags
- 1 == get_post_meta( $post->ID, $this->POST_DONE . $service_name, true )
+ // Old flags.
+ 1 === (int) get_post_meta( $post->ID, $this->POST_DONE . $service_name, true )
);
/**
@@ -663,6 +779,7 @@ abstract class Publicize_Base {
* @param string $service_name Service name.
* @param array $connection_data Array of information about all Publicize details for the site.
*/
+ /* phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores */
if ( ! apply_filters( 'wpas_submit_post?', true, $post_id, $service_name, $connection_data ) ) {
continue;
}
@@ -672,13 +789,13 @@ abstract class Publicize_Base {
(
! empty( $post )
&&
- in_array( $post->post_status, array( 'publish', 'draft', 'future' ) )
+ in_array( $post->post_status, array( 'publish', 'draft', 'future' ), true )
&&
(
- // New flags
+ // New flags.
get_post_meta( $post->ID, $this->POST_SKIP . $unique_id, true )
||
- // Old flags
+ // Old flags.
get_post_meta( $post->ID, $this->POST_SKIP . $service_name )
)
)
@@ -713,7 +830,7 @@ abstract class Publicize_Base {
* If this is a global connection and this user doesn't have enough permissions to modify
* those connections, don't let them change it.
*/
- if ( ! $done && ( 0 == $connection_data['user_id'] && ! current_user_can( $this->GLOBAL_CAP ) ) ) {
+ if ( ! $done && $this->is_global_connection( $connection_meta ) && ! current_user_can( $this->GLOBAL_CAP ) ) {
$toggleable = false;
/**
@@ -746,7 +863,7 @@ abstract class Publicize_Base {
'enabled' => $enabled,
'done' => $done,
'toggleable' => $toggleable,
- 'global' => 0 == $connection_data['user_id'], // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Other types can be used at times.
+ 'global' => 0 == $connection_data['user_id'], // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual,WordPress.PHP.StrictComparisons.LooseComparison -- Other types can be used at times.
);
}
}
@@ -781,7 +898,7 @@ abstract class Publicize_Base {
* @type string 'url' URL for adding connection to service.
* }
*/
- function get_available_service_data() {
+ public function get_available_service_data() {
$available_services = $this->get_services( 'all' );
$available_service_data = array();
@@ -796,21 +913,31 @@ abstract class Publicize_Base {
return $available_service_data;
}
-/*
- * Site Data
- */
+ /**
+ * Site Data
+ */
- function user_id() {
+ /**
+ * Get user ID.
+ *
+ * @return int The current user's ID, or 0 if no user is logged in.
+ */
+ public function user_id() {
return get_current_user_id();
}
- function blog_id() {
+ /**
+ * Get site ID.
+ *
+ * @return int Site ID.
+ */
+ public function blog_id() {
return get_current_blog_id();
}
-/*
- * Posts
- */
+ /**
+ * Posts
+ */
/**
* Checks old and new status to see if the post should be flagged as
@@ -818,26 +945,26 @@ abstract class Publicize_Base {
*
* Attached to the `transition_post_status` filter.
*
- * @param string $new_status
- * @param string $old_status
- * @param WP_Post $post
+ * @param string $new_status New status.
+ * @param string $old_status Old status.
+ * @param WP_Post $post Post object.
* @return void
*/
- abstract function flag_post_for_publicize( $new_status, $old_status, $post );
+ abstract public function flag_post_for_publicize( $new_status, $old_status, $post );
/**
* Ensures the Post internal post-type supports `publicize`
*
* This feature support flag is used by the REST API.
*/
- function add_post_type_support() {
+ public function add_post_type_support() {
add_post_type_support( 'post', 'publicize' );
}
/**
* Register the Publicize Gutenberg extension
*/
- function register_gutenberg_extension() {
+ public function register_gutenberg_extension() {
// TODO: The `gutenberg/available-extensions` endpoint currently doesn't accept a post ID,
// so we cannot pass one to `$this->current_user_can_access_publicize_data()`.
@@ -845,17 +972,16 @@ abstract class Publicize_Base {
Jetpack_Gutenberg::set_extension_available( 'jetpack/publicize' );
} else {
Jetpack_Gutenberg::set_extension_unavailable( 'jetpack/publicize', 'unauthorized' );
-
}
}
/**
* Can the current user access Publicize Data.
*
- * @param int $post_id. 0 for general access. Post_ID for specific access.
+ * @param int $post_id 0 for general access. Post_ID for specific access.
* @return bool
*/
- function current_user_can_access_publicize_data( $post_id = 0 ) {
+ public function current_user_can_access_publicize_data( $post_id = 0 ) {
/**
* Filter what user capability is required to use the publicize form on the edit post page. Useful if publish post capability has been removed from role.
*
@@ -877,12 +1003,10 @@ abstract class Publicize_Base {
/**
* Auth callback for the protected ->POST_MESS post_meta
*
- * @param bool $allowed
- * @param string $meta_key
- * @param int $object_id Post ID
+ * @param int $object_id Post ID.
* @return bool
*/
- function message_meta_auth_callback( $allowed, $meta_key, $object_id ) {
+ public function message_meta_auth_callback( $object_id ) {
return $this->current_user_can_access_publicize_data( $object_id );
}
@@ -891,7 +1015,7 @@ abstract class Publicize_Base {
*
* Registers for each post type that with `publicize` feature support.
*/
- function register_post_meta() {
+ public function register_post_meta() {
$message_args = array(
'type' => 'string',
'description' => __( 'The message to use instead of the title when sharing to Publicize Services', 'jetpack' ),
@@ -941,53 +1065,36 @@ abstract class Publicize_Base {
}
/**
- * Fires when a post is saved, checks conditions and saves state in postmeta so that it
- * can be picked up later by @see ::publicize_post() on WordPress.com codebase.
- *
- * Attached to the `save_post` action.
+ * Helper function to allow us to not publicize posts in certain contexts.
*
- * @param int $post_id
- * @param WP_Post $post
- * @return void
+ * @param WP_Post $post Post object.
*/
- function save_meta( $post_id, $post ) {
- $cron_user = null;
+ public function should_submit_post_pre_checks( $post ) {
$submit_post = true;
- if ( ! $this->post_type_is_publicizeable( $post->post_type ) )
- return;
-
- // Don't Publicize during certain contexts:
-
- // - import
- if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
+ if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
$submit_post = false;
}
- // - on quick edit, autosave, etc but do fire on p2, quickpress, and instapost ajax
if (
- defined( 'DOING_AJAX' )
- &&
- DOING_AJAX
- &&
- !did_action( 'p2_ajax' )
+ defined( 'DOING_AUTOSAVE' )
&&
- !did_action( 'wp_ajax_json_quickpress_post' )
- &&
- !did_action( 'wp_ajax_instapost_publish' )
- &&
- !did_action( 'wp_ajax_post_reblog' )
- &&
- !did_action( 'wp_ajax_press-this-save-post' )
+ DOING_AUTOSAVE
) {
$submit_post = false;
}
- // - bulk edit
- if ( isset( $_GET['bulk_edit'] ) ) {
+ // To prevent quick edits from getting publicized.
+ if ( did_action( 'wp_ajax_inline-save' ) ) {
$submit_post = false;
}
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended
+ if ( ! empty( $_GET['bulk_edit'] ) ) {
+ $submit_post = false;
+ }
+ // phpcs:enable WordPress.Security.NonceVerification.Recommended
+
// - API/XML-RPC Test Posts
if (
(
@@ -1005,32 +1112,60 @@ abstract class Publicize_Base {
$submit_post = false;
}
- // only work with certain statuses (avoids inherits, auto drafts etc)
- if ( !in_array( $post->post_status, array( 'publish', 'draft', 'future' ) ) ) {
+ // Only work with certain statuses (avoids inherits, auto drafts etc).
+ if ( ! in_array( $post->post_status, array( 'publish', 'draft', 'future' ), true ) ) {
$submit_post = false;
}
- // don't publish password protected posts
+ // Don't publish password protected posts.
if ( '' !== $post->post_password ) {
$submit_post = false;
}
+ return $submit_post;
+ }
+
+ /**
+ * Fires when a post is saved, checks conditions and saves state in postmeta so that it
+ * can be picked up later by @see ::publicize_post() on WordPress.com codebase.
+ *
+ * Attached to the `save_post` action.
+ *
+ * @param int $post_id Post ID.
+ * @param WP_Post $post Post object.
+ */
+ public function save_meta( $post_id, $post ) {
+ $cron_user = null;
+ $submit_post = true;
+
+ if ( ! $this->post_type_is_publicizeable( $post->post_type ) ) {
+ return;
+ }
+
+ $submit_post = $this->should_submit_post_pre_checks( $post );
+
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- We're only checking if a value is set
+ $admin_page = isset( $_POST[ $this->ADMIN_PAGE ] ) ? $_POST[ $this->ADMIN_PAGE ] : null;
+
// Did this request happen via wp-admin?
$from_web = isset( $_SERVER['REQUEST_METHOD'] )
&&
- 'post' == strtolower( $_SERVER['REQUEST_METHOD'] )
+ 'post' === strtolower( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) )
&&
- isset( $_POST[$this->ADMIN_PAGE] );
+ ! empty( $admin_page );
+
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ $title = isset( $_POST['wpas_title'] ) ? sanitize_textarea_field( wp_unslash( $_POST['wpas_title'] ) ) : null;
- if ( ( $from_web || defined( 'POST_BY_EMAIL' ) ) && isset( $_POST['wpas_title'] ) ) {
- if ( empty( $_POST['wpas_title'] ) ) {
+ if ( ( $from_web || defined( 'POST_BY_EMAIL' ) ) && $title ) {
+ if ( empty( $title ) ) {
delete_post_meta( $post_id, $this->POST_MESS );
} else {
- update_post_meta( $post_id, $this->POST_MESS, trim( stripslashes( $_POST['wpas_title'] ) ) );
+ update_post_meta( $post_id, $this->POST_MESS, trim( stripslashes( $title ) ) );
}
}
- // change current user to provide context for get_services() if we're running during cron
+ // Change current user to provide context for get_services() if we're running during cron.
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
$cron_user = (int) $GLOBALS['user_ID'];
wp_set_current_user( $post->post_author );
@@ -1050,36 +1185,38 @@ abstract class Publicize_Base {
}
/** This action is documented in modules/publicize/ui.php */
- if ( false == apply_filters( 'wpas_submit_post?', $submit_post, $post_id, $service_name, $connection_data ) ) {
+ /* phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores */
+ if ( false === apply_filters( 'wpas_submit_post?', $submit_post, $post_id, $service_name, $connection_data ) ) {
delete_post_meta( $post_id, $this->PENDING );
continue;
}
- if ( !empty( $connection->unique_id ) )
+ if ( ! empty( $connection->unique_id ) ) {
$unique_id = $connection->unique_id;
- else if ( !empty( $connection['connection_data']['token_id'] ) )
+ } elseif ( ! empty( $connection['connection_data']['token_id'] ) ) {
$unique_id = $connection['connection_data']['token_id'];
+ }
- // This was a wp-admin request, so we need to check the state of checkboxes
+ // This was a wp-admin request, so we need to check the state of checkboxes.
if ( $from_web ) {
- // delete stray service-based post meta
+ // Delete stray service-based post meta.
delete_post_meta( $post_id, $this->POST_SKIP . $service_name );
- // We *unchecked* this stream from the admin page, or it's set to readonly, or it's a new addition
- if ( empty( $_POST[$this->ADMIN_PAGE]['submit'][$unique_id] ) ) {
+ // We *unchecked* this stream from the admin page, or it's set to readonly, or it's a new addition.
+ if ( empty( $admin_page['submit'][ $unique_id ] ) ) {
// Also make sure that the service-specific input isn't there.
// If the user connected to a new service 'in-page' then a hidden field with the service
// name is added, so we just assume they wanted to Publicize to that service.
- if ( empty( $_POST[$this->ADMIN_PAGE]['submit'][$service_name] ) ) {
- // Nothing seems to be checked, so we're going to mark this one to be skipped
+ if ( empty( $admin_page['submit'][ $service_name ] ) ) {
+ // Nothing seems to be checked, so we're going to mark this one to be skipped.
update_post_meta( $post_id, $this->POST_SKIP . $unique_id, 1 );
continue;
} else {
- // clean up any stray post meta
+ // Clean up any stray post meta.
delete_post_meta( $post_id, $this->POST_SKIP . $unique_id );
}
} else {
- // The checkbox for this connection is explicitly checked -- make sure we DON'T skip it
+ // The checkbox for this connection is explicitly checked -- make sure we DON'T skip it.
delete_post_meta( $post_id, $this->POST_SKIP . $unique_id );
}
}
@@ -1104,7 +1241,7 @@ abstract class Publicize_Base {
wp_set_current_user( $cron_user );
}
- // Next up will be ::publicize_post()
+ // Next up will be ::publicize_post().
}
/**
@@ -1113,7 +1250,7 @@ abstract class Publicize_Base {
*
* Attached to the `post_updated_messages` filter
*
- * @param string[] $messages
+ * @param string[] $messages Array of messages.
* @return string[]
*/
public function update_published_message( $messages ) {
@@ -1128,15 +1265,17 @@ abstract class Publicize_Base {
}
$view_post_link_html = '';
- $viewable = is_post_type_viewable( $post_type_object );
+ $viewable = is_post_type_viewable( $post_type_object );
if ( $viewable ) {
- $view_text = esc_html__( 'View post' ); // intentionally omitted domain
+ /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain, WordPress.Utils.I18nTextDomainFixer.MissingArgDomain */
+ $view_text = esc_html__( 'View post' ); // Intentionally omitted domain.
- if ( 'jetpack-portfolio' == $post_type ) {
+ if ( 'jetpack-portfolio' === $post_type ) {
$view_text = esc_html__( 'View project', 'jetpack' );
}
- $view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
+ $view_post_link_html = sprintf(
+ ' <a href="%1$s">%2$s</a>',
esc_url( get_permalink( $post ) ),
$view_text
);
@@ -1153,7 +1292,7 @@ abstract class Publicize_Base {
/* translators: Service name is %1$s, and account name is %2$s. */
esc_html__( '%1$s (%2$s)', 'jetpack' ),
esc_html( $service_name ),
- esc_html( implode( ', ', $display_names ) )
+ esc_html( is_array( $display_names ) ? implode( ', ', $display_names ) : $display_names )
);
}
@@ -1163,7 +1302,7 @@ abstract class Publicize_Base {
implode( ', ', $labels )
) . $view_post_link_html;
- if ( $post_type == 'post' && class_exists('Jetpack_Subscriptions' ) ) {
+ if ( 'post' === $post_type && class_exists( 'Jetpack_Subscriptions' ) ) {
$subscription = Jetpack_Subscriptions::init();
if ( $subscription->should_email_post_to_subscribers( $post ) ) {
$messages['post'][6] = sprintf(
@@ -1188,23 +1327,24 @@ abstract class Publicize_Base {
*
* Only reliable just after the Post was published.
*
- * @param int $post_id
+ * @param int $post_id Post ID.
* @return string[] Array of Service display name => Connection display name
*/
- function get_publicizing_services( $post_id ) {
+ public function get_publicizing_services( $post_id ) {
$services = array();
foreach ( (array) $this->get_services( 'connected' ) as $service_name => $connections ) {
// services have multiple connections.
foreach ( $connections as $connection ) {
$unique_id = '';
- if ( ! empty( $connection->unique_id ) )
+ if ( ! empty( $connection->unique_id ) ) {
$unique_id = $connection->unique_id;
- else if ( ! empty( $connection['connection_data']['token_id'] ) )
+ } elseif ( ! empty( $connection['connection_data']['token_id'] ) ) {
$unique_id = $connection['connection_data']['token_id'];
+ }
// Did we skip this connection?
- if ( get_post_meta( $post_id, $this->POST_SKIP . $unique_id, true ) ) {
+ if ( get_post_meta( $post_id, $this->POST_SKIP . $unique_id, true ) ) {
continue;
}
$services[ $this->get_service_label( $service_name ) ][] = $this->get_display_name( $service_name, $connection );
@@ -1219,21 +1359,23 @@ abstract class Publicize_Base {
*
* Only valid prior to Publicizing a Post.
*
- * @param WP_Post $post
+ * @param WP_Post $post Post to check.
* @return bool
*/
- function post_is_publicizeable( $post ) {
- if ( ! $this->post_type_is_publicizeable( $post->post_type ) )
+ public function post_is_publicizeable( $post ) {
+ if ( ! $this->post_type_is_publicizeable( $post->post_type ) ) {
return false;
+ }
- // This is more a precaution. To only publicize posts that are published. (Mostly relevant for Jetpack sites)
+ // This is more a precaution. To only publicize posts that are published. (Mostly relevant for Jetpack sites).
if ( 'publish' !== $post->post_status ) {
return false;
}
- // If it's not flagged as ready, then abort. @see ::flag_post_for_publicize()
- if ( ! get_post_meta( $post->ID, $this->PENDING, true ) )
+ // If it's not flagged as ready, then abort. @see ::flag_post_for_publicize().
+ if ( ! get_post_meta( $post->ID, $this->PENDING, true ) ) {
return false;
+ }
return true;
}
@@ -1247,9 +1389,10 @@ abstract class Publicize_Base {
* @param string $post_type The post type to check.
* @return bool True if the post type can be Publicized.
*/
- function post_type_is_publicizeable( $post_type ) {
- if ( 'post' == $post_type )
+ public function post_type_is_publicizeable( $post_type ) {
+ if ( 'post' === $post_type ) {
return true;
+ }
return post_type_supports( $post_type, 'publicize' );
}
@@ -1260,47 +1403,63 @@ abstract class Publicize_Base {
*
* Attached to the `publicize_checkbox_default` filter
*
- * @param bool $checked
- * @param int $post_id
- * @param string $service_name 'facebook', 'twitter', etc
- * @param object|array The Connection object (WordPress.com) or array (Jetpack)
+ * @param bool $checked True if checkbox is checked, false otherwise.
+ * @param int $post_id Post ID to set checkbox for.
* @return bool
*/
- function publicize_checkbox_default( $checked, $post_id, $service_name, $connection ) {
- if ( 'publish' == get_post_status( $post_id ) ) {
+ public function publicize_checkbox_default( $checked, $post_id ) {
+ if ( 'publish' === get_post_status( $post_id ) ) {
return false;
}
return $checked;
}
-/*
- * Util
- */
+ /**
+ * Util
+ */
/**
* Converts a Publicize message template string into a sprintf format string
*
- * @param string[] $args
+ * @param string[] $args Array of arguments.
* 0 - The Publicize message template: 'Check out my post: %title% @ %url'
* ... - The template tags 'title', 'url', etc.
* @return string
*/
protected static function build_sprintf( $args ) {
- $search = array();
+ $search = array();
$replace = array();
foreach ( $args as $k => $arg ) {
- if ( 0 == $k ) {
+ if ( 0 === $k ) {
$string = $arg;
continue;
}
- $search[] = "%$arg%";
+ $search[] = "%$arg%";
$replace[] = "%$k\$s";
}
return str_replace( $search, $replace, $string );
}
+
+ /**
+ * Get Calypso URL for Publicize connections.
+ *
+ * @param string $source The idenfitier of the place the function is called from.
+ * @return string
+ */
+ public function publicize_connections_url( $source = 'calypso-marketing-connections' ) {
+ $allowed_sources = array( 'jetpack-social-connections-admin-page', 'jetpack-social-connections-classic-editor', 'calypso-marketing-connections' );
+ $source = in_array( $source, $allowed_sources, true ) ? $source : 'calypso-marketing-connections';
+ return Redirect::get_url( $source, array( 'site' => ( new Status() )->get_site_suffix() ) );
+ }
}
+/**
+ * Get Calypso URL for Publicize connections.
+ *
+ * @return string
+ */
function publicize_calypso_url() {
+ _deprecated_function( __METHOD__, '11.0', 'Publicize::publicize_connections_url' );
return Redirect::get_url( 'calypso-marketing-connections', array( 'site' => ( new Status() )->get_site_suffix() ) );
}
diff --git a/plugins/jetpack/modules/publicize/ui.php b/plugins/jetpack/modules/publicize/ui.php
index 156b25ef..6ffe3979 100644
--- a/plugins/jetpack/modules/publicize/ui.php
+++ b/plugins/jetpack/modules/publicize/ui.php
@@ -1,47 +1,59 @@
-<?php
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Publicize_UI class.
+ *
+ * @package automattic/jetpack
+ */
/**
-* Only user facing pieces of Publicize are found here.
-*/
+ * Only user facing pieces of Publicize are found here.
+ */
class Publicize_UI {
-
/**
- * Contains an instance of class 'publicize' which loads Keyring, sets up services, etc.
- */
+ * Contains an instance of class 'Publicize' which loads Keyring, sets up services, etc.
+ *
+ * @var Publicize Instance of Publicize
+ */
public $publicize;
/**
- * @var string URL to Sharing settings page in wordpress.com
+ * URL to Sharing settings page in wordpress.com
+ *
+ * @var string
*/
protected $publicize_settings_url = '';
/**
- * Hooks into WordPress to display the various pieces of UI and load our assets
- */
- function __construct() {
+ * Hooks into WordPress to display the various pieces of UI and load our assets
+ */
+ public function __construct() {
global $publicize;
- $this->publicize = $publicize = new Publicize;
+ $publicize = new Publicize();
+ $this->publicize = $publicize;
add_action( 'init', array( $this, 'init' ) );
}
- function init() {
- $this->publicize_settings_url = publicize_calypso_url();
+ /**
+ * Initialize UI-related functionality.
+ */
+ public function init() {
+ $this->publicize_settings_url = $this->publicize->publicize_connections_url();
// Show only to users with the capability required to manage their Publicize connections.
if ( ! $this->publicize->current_user_can_access_publicize_data() ) {
return;
}
- // assets (css, js)
+ // Assets (css, js).
if ( $this->in_jetpack ) {
add_action( 'load-settings_page_sharing', array( $this, 'load_assets' ) );
}
add_action( 'admin_head-post.php', array( $this, 'post_page_metabox_assets' ) );
add_action( 'admin_head-post-new.php', array( $this, 'post_page_metabox_assets' ) );
- // management of publicize (sharing screen, ajax/lightbox popup, and metabox on post screen)
+ // Management of publicize (sharing screen, ajax/lightbox popup, and metabox on post screen).
add_action( 'pre_admin_screen_sharing', array( $this, 'admin_page' ) );
add_action( 'post_submitbox_misc_actions', array( $this, 'post_page_metabox' ) );
}
@@ -49,7 +61,7 @@ class Publicize_UI {
/**
* If the ShareDaddy plugin is not active we need to add the sharing settings page to the menu still
*/
- function sharing_menu() {
+ public function sharing_menu() {
add_submenu_page(
'options-general.php',
esc_html__( 'Sharing Settings', 'jetpack' ),
@@ -60,14 +72,18 @@ class Publicize_UI {
);
}
- function wrapper_admin_page() {
+ /**
+ * Add admin page with wrapper.
+ */
+ public function wrapper_admin_page() {
Jetpack_Admin_Page::wrap_ui( array( $this, 'management_page' ) );
}
/**
* Management page to load if Sharedaddy is not active so the 'pre_admin_screen_sharing' action exists.
*/
- function management_page() { ?>
+ public function management_page() {
+ ?>
<div class="wrap">
<div class="icon32" id="icon-options-general"><br /></div>
<h1><?php esc_html_e( 'Sharing Settings', 'jetpack' ); ?></h1>
@@ -76,15 +92,15 @@ class Publicize_UI {
/** This action is documented in modules/sharedaddy/sharing.php */
do_action( 'pre_admin_screen_sharing' );
?>
-
- </div> <?php
+ </div>
+ <?php
}
/**
- * styling for the sharing screen and popups
+ * Styling for the sharing screen and popups
* JS for the options and switching
*/
- function load_assets() {
+ public function load_assets() {
Jetpack_Admin_Page::load_wrapper_styles();
}
@@ -92,22 +108,30 @@ class Publicize_UI {
* Lists the current user's publicized accounts for the blog
* looks exactly like Publicize v1 for now, UI and functionality updates will come after the move to keyring
*/
- function admin_page() {
+ public function admin_page() {
?>
- <h2 id="publicize"><?php esc_html_e( 'Publicize', 'jetpack' ) ?></h2>
- <p><?php esc_html_e( 'Connect social media services to automatically share new posts.', 'jetpack' ) ?></p>
- <h4><?php
+ <h2 id="publicize"><?php esc_html_e( 'Publicize', 'jetpack' ); ?></h2>
+ <p><?php esc_html_e( 'Connect social media services to automatically share new posts.', 'jetpack' ); ?></p>
+ <h4>
+ <?php
printf(
wp_kses(
+ /* translators: %s is the link to the Publicize page in Calypso */
__( "We've made some updates to Publicize. Please visit the <a href='%s' class='jptracks' data-jptracks-name='legacy_publicize_settings'>WordPress.com sharing page</a> to manage your publicize connections or use the button below.", 'jetpack' ),
- array( 'a' => array( 'href' => array(), 'class' => array(), 'data-jptracks-name' => array() ) )
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'class' => array(),
+ 'data-jptracks-name' => array(),
+ ),
+ )
),
- esc_url( publicize_calypso_url() )
+ esc_url( $this->publicize->publicize_connections_url() )
);
?>
</h4>
- <a href="<?php echo esc_url( publicize_calypso_url() ); ?>" class="button button-primary jptracks" data-jptracks-name='legacy_publicize_settings'><?php esc_html_e( 'Publicize Settings', 'jetpack' ); ?></a>
+ <a href="<?php echo esc_url( $this->publicize->publicize_connections_url() ); ?>" class="button button-primary jptracks" data-jptracks-name='legacy_publicize_settings'><?php esc_html_e( 'Publicize Settings', 'jetpack' ); ?></a>
<?php
}
@@ -115,10 +139,7 @@ class Publicize_UI {
* CSS for styling the publicize message box and counter that displays on the post page.
* There is also some JavaScript for length counting and some basic display effects.
*/
- function post_page_metabox_assets() {
- global $post;
- $user_id = empty( $post->post_author ) ? $GLOBALS['user_ID'] : $post->post_author;
-
+ public function post_page_metabox_assets() {
$default_prefix = $this->publicize->default_prefix;
$default_prefix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_prefix ) );
@@ -129,7 +150,7 @@ class Publicize_UI {
$default_suffix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_suffix ) );
$max_length = defined( 'JETPACK_PUBLICIZE_TWITTER_LENGTH' ) ? JETPACK_PUBLICIZE_TWITTER_LENGTH : 280;
- $max_length = $max_length - 24; // t.co link, space
+ $max_length = $max_length - 24; // t.co link, space.
?>
@@ -161,6 +182,7 @@ jQuery( function($) {
// Keep the postTitle and the placeholder in sync
postTitle.on( 'keyup', function( e ) {
var url = $( '#sample-permalink' ).text();
+ <?php // phpcs:ignore ?>
var defaultMessage = $.trim( '<?php printf( $default_prefix, 'url' ); printf( $default_message, 'e.currentTarget.value', 'url' ); printf( $default_suffix, 'url' ); ?>' )
.replace( /<[^>]+>/g,'');
@@ -322,7 +344,7 @@ jQuery( function($) {
+ testResult.connectionTestMessage
+ '</p><p>'
+ ' <a class="button" href="<?php echo esc_url( $this->publicize_settings_url ); ?>" rel="noopener noreferrer" target="_blank">'
- + '<?php echo esc_html( __( 'Update Your Sharing Settings' ,'jetpack' ) ); ?>'
+ + '<?php echo esc_html( __( 'Update Your Sharing Settings', 'jetpack' ) ); ?>'
+ '</a>'
+ '<p>';
@@ -408,12 +430,15 @@ jQuery( function($) {
font-size: 16px;
text-decoration: none;
}
-</style><?php
+</style>
+ <?php
}
/**
- * @param string $service_label Service's human-readable Label ("Facebook", "Twitter", ...)
- * @param string $display_name Connection's human-readable Username ("@jetpack", ...)
+ * Get the connection label.
+ *
+ * @param string $service_label Service's human-readable Label ("Facebook", "Twitter", ...).
+ * @param string $display_name Connection's human-readable Username ("@jetpack", ...).
* @return string
*/
private function connection_label( $service_label, $display_name ) {
@@ -430,7 +455,7 @@ jQuery( function($) {
*
* @return array Connections that must be reauthenticated
*/
- function get_must_reauth_connections() {
+ public function get_must_reauth_connections() {
$must_reauth = array();
$connections = $this->publicize->get_connections( 'linkedin' );
if ( is_array( $connections ) ) {
@@ -444,88 +469,92 @@ jQuery( function($) {
}
/**
- * Controls the metabox that is displayed on the post page
- * Allows the user to customize the message that will be sent out to the social network, as well as pick which
- * networks to publish to. Also displays the character counter and some other information.
- */
- function post_page_metabox() {
+ * Controls the metabox that is displayed on the post page
+ * Allows the user to customize the message that will be sent out to the social network, as well as pick which
+ * networks to publish to. Also displays the character counter and some other information.
+ */
+ public function post_page_metabox() {
global $post;
- if ( ! $this->publicize->post_type_is_publicizeable( $post->post_type ) )
+ if ( ! $this->publicize->post_type_is_publicizeable( $post->post_type ) ) {
return;
+ }
- $user_id = empty( $post->post_author ) ? $GLOBALS['user_ID'] : $post->post_author;
$connections_data = $this->publicize->get_filtered_connection_data();
$available_services = $this->publicize->get_services( 'all' );
- if ( ! is_array( $available_services ) )
+ if ( ! is_array( $available_services ) ) {
$available_services = array();
+ }
- if ( ! is_array( $connections_data ) )
+ if ( ! is_array( $connections_data ) ) {
$connections_data = array();
+ }
?>
<div id="publicize" class="misc-pub-section misc-pub-section-last">
<span id="publicize-title">
<?php
- esc_html_e( 'Publicize:', 'jetpack' );
+ esc_html_e( 'Publicize:', 'jetpack' );
- if ( 0 < count( $connections_data ) ) :
- $publicize_form = $this->get_metabox_form_connected( $connections_data );
+ if ( ! empty( $connections_data ) ) :
+ $publicize_form = $this->get_metabox_form_connected( $connections_data );
- $must_reauth = $this->get_must_reauth_connections();
- if ( ! empty( $must_reauth ) ) {
- foreach ( $must_reauth as $connection_name ) {
- ?>
- <span class="notice-warning publicize__notice-warning">
- <?php
- /* translators: %s is the name of a Pubilicize service like "LinkedIn" */
- printf( esc_html__(
+ $must_reauth = $this->get_must_reauth_connections();
+ if ( ! empty( $must_reauth ) ) {
+ foreach ( $must_reauth as $connection_name ) {
+ ?>
+ <span class="notice-warning publicize__notice-warning">
+ <?php
+ printf(
+ /* translators: %s is the name of a Publicize service like "LinkedIn" */
+ esc_html__(
'Your %s connection needs to be reauthenticated to continue working – head to Sharing to take care of it.',
'jetpack'
- ), $connection_name );
- ?>
- <a
- class="publicize-external-link"
- href="<?php echo publicize_calypso_url() ?>"
- target="_blank"
- >
- <span class="publicize-external-link__text"><?php esc_html_e( 'Go to Sharing settings', 'jetpack' ); ?></span>
- <span class="dashicons dashicons-external"></span>
- </a>
- </span>
- <?php
- }
- ?>
+ ),
+ $connection_name // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ );
+ ?>
+ <a
+ class="publicize-external-link"
+ href="<?php echo esc_url( $this->publicize->publicize_connections_url() ); ?>"
+ target="_blank"
+ >
+ <span class="publicize-external-link__text"><?php esc_html_e( 'Go to Sharing settings', 'jetpack' ); ?></span>
+ <span class="dashicons dashicons-external"></span>
+ </a>
+ </span>
<?php
}
+ }
- $labels = array();
- foreach ( $connections_data as $connection_data ) {
- if ( ! $connection_data['enabled'] ) {
- continue;
- }
+ $labels = array();
- $labels[] = sprintf(
- '<strong>%s</strong>',
- esc_html( $this->connection_label( $connection_data['service_label'], $connection_data['display_name'] ) )
- );
+ foreach ( $connections_data as $connection_data ) {
+ if ( ! $connection_data['enabled'] ) {
+ continue;
}
+ $labels[] = sprintf(
+ '<strong>%s</strong>',
+ esc_html( $this->connection_label( $connection_data['service_label'], $connection_data['display_name'] ) )
+ );
+ }
+
?>
+ <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- labels are already escaped above ?>
<span id="publicize-defaults"><?php echo join( ', ', $labels ); ?></span>
- <a href="#" id="publicize-form-edit"><?php esc_html_e( 'Edit', 'jetpack' ); ?></a>&nbsp;<a href="<?php echo esc_url( $this->publicize_settings_url ); ?>" rel="noopener noreferrer" target="_blank"><?php _e( 'Settings', 'jetpack' ); ?></a><br />
+ <a href="#" id="publicize-form-edit"><?php esc_html_e( 'Edit', 'jetpack' ); ?></a>&nbsp;<a href="<?php echo esc_url( $this->publicize->publicize_connections_url( 'jetpack-social-connections-classic-editor' ) ); ?>" rel="noopener noreferrer" target="_blank"><?php esc_html_e( 'Settings', 'jetpack' ); ?></a><br />
<?php
- else :
- $publicize_form = $this->get_metabox_form_disconnected( $available_services );
-
+ else :
+ $publicize_form = $this->get_metabox_form_disconnected( $available_services );
?>
- <strong><?php echo __( 'Not Connected', 'jetpack' ); ?></strong>
- <a href="#" id="publicize-disconnected-form-show"><?php esc_html_e( 'Edit', 'jetpack' ); ?></a><br />
+ <strong><?php esc_html_e( 'Not Connected', 'jetpack' ); ?></strong>
+ <a href="#" id="publicize-disconnected-form-show"><?php esc_html_e( 'Edit', 'jetpack' ); ?></a><br />
<?php
- endif;
+ endif;
?>
</span>
<?php
@@ -538,9 +567,10 @@ jQuery( function($) {
*
* @param string $publicize_form Publicize Details form appearing above Publish button in the editor.
*/
- echo apply_filters( 'publicize_form', $publicize_form );
+ echo apply_filters( 'publicize_form', $publicize_form ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Parts of the form are escaped individually in the code above.
?>
- </div> <?php // #publicize
+ </div>
+ <?php
}
/**
@@ -550,14 +580,13 @@ jQuery( function($) {
*
* @global WP_Post $post The current post instance being published.
*
- * @param array $connections_data
- *
+ * @param array $connections_data Array of connections.
* @return array {
* Array of content for generating connection form.
*
* @type string HTML content of form
* @type array {
- * Array of connection labels for active connections only.
+ * Array of connection labels for active connections only.
*
* @type string Connection label string.
* }
@@ -566,7 +595,7 @@ jQuery( function($) {
private function get_metabox_form_connected( $connections_data ) {
global $post;
- $all_done = $this->publicize->post_is_done_sharing();
+ $all_done = $this->publicize->post_is_done_sharing();
$all_connections_done = true;
ob_start();
@@ -578,34 +607,34 @@ jQuery( function($) {
foreach ( $connections_data as $connection_data ) {
$all_connections_done = $all_connections_done && $connection_data['done'];
- ?>
+ ?>
- <li>
- <label for="wpas-submit-<?php echo esc_attr( $connection_data['unique_id'] ); ?>">
- <input
- type="checkbox"
- name="wpas[submit][<?php echo esc_attr( $connection_data['unique_id'] ); ?>]"
- id="wpas-submit-<?php echo esc_attr( $connection_data['unique_id'] ); ?>"
- class="wpas-submit-<?php echo esc_attr( $connection_data['service_name'] ); ?>"
- value="1"
- <?php
- checked( true, $connection_data['enabled'] );
- disabled( false, $connection_data['toggleable'] );
- ?>
- />
- <?php if ( $connection_data['enabled'] && ! $connection_data['toggleable'] ) : // Need to submit a value to force a global connection to POST ?>
- <input
- type="hidden"
- name="wpas[submit][<?php echo esc_attr( $connection_data['unique_id'] ); ?>]"
- value="1"
- />
- <?php endif; ?>
-
- <?php echo esc_html( $this->connection_label( $connection_data['service_label'], $connection_data['display_name'] ) ); ?>
-
- </label>
- </li>
- <?php
+ <li>
+ <label for="wpas-submit-<?php echo esc_attr( $connection_data['unique_id'] ); ?>">
+ <input
+ type="checkbox"
+ name="wpas[submit][<?php echo esc_attr( $connection_data['unique_id'] ); ?>]"
+ id="wpas-submit-<?php echo esc_attr( $connection_data['unique_id'] ); ?>"
+ class="wpas-submit-<?php echo esc_attr( $connection_data['service_name'] ); ?>"
+ value="1"
+ <?php
+ checked( true, $connection_data['enabled'] );
+ disabled( false, $connection_data['toggleable'] );
+ ?>
+ />
+ <?php if ( $connection_data['enabled'] && ! $connection_data['toggleable'] ) : // Need to submit a value to force a global connection to POST. ?>
+ <input
+ type="hidden"
+ name="wpas[submit][<?php echo esc_attr( $connection_data['unique_id'] ); ?>]"
+ value="1"
+ />
+ <?php endif; ?>
+
+ <?php echo esc_html( $this->connection_label( $connection_data['service_label'], $connection_data['display_name'] ) ); ?>
+
+ </label>
+ </li>
+ <?php
}
$title = get_post_meta( $post->ID, $this->publicize->POST_MESS, true );
@@ -619,7 +648,7 @@ jQuery( function($) {
</ul>
- <label for="wpas-title"><?php _e( 'Custom Message:', 'jetpack' ); ?></label>
+ <label for="wpas-title"><?php esc_html_e( 'Custom Message:', 'jetpack' ); ?></label>
<span id="wpas-title-counter" class="alignright hide-if-no-js">0</span>
<textarea name="wpas_title" id="wpas-title"<?php disabled( $all_done ); ?>><?php echo esc_textarea( $title ); ?></textarea>
<a href="#" class="hide-if-no-js button" id="publicize-form-hide"><?php esc_html_e( 'OK', 'jetpack' ); ?></a>
@@ -629,21 +658,28 @@ jQuery( function($) {
<?php if ( ! $all_done ) : ?>
<div id="pub-connection-tests"></div>
<?php endif; ?>
- <?php // #publicize-form
+ <?php
return ob_get_clean();
}
+ /**
+ * Metabox that is shown when no services are connected.
+ *
+ * @param array $available_services Array of available services for connecting.
+ */
private function get_metabox_form_disconnected( $available_services ) {
ob_start();
- ?><div id="publicize-form" class="hide-if-js">
+ ?>
+ <div id="publicize-form" class="hide-if-js">
<div id="add-publicize-check" style="display: none;"></div>
- <?php _e( 'Connect to', 'jetpack' ); ?>:
+ <?php esc_html_e( 'Connect to', 'jetpack' ); ?>:
<ul class="not-connected">
<?php foreach ( $available_services as $service_name => $service ) : ?>
<li>
+ <?php /* translators: %s is the name of a Publicize service such as "LinkedIn" */ ?>
<a class="pub-service" data-service="<?php echo esc_attr( $service_name ); ?>" title="<?php echo esc_attr( sprintf( __( 'Connect and share your posts on %s', 'jetpack' ), $this->publicize->get_service_label( $service_name ) ) ); ?>" rel="noopener noreferrer" target="_blank" href="<?php echo esc_url( $this->publicize->connect_url( $service_name ) ); ?>">
<?php echo esc_html( $this->publicize->get_service_label( $service_name ) ); ?>
</a>
@@ -651,7 +687,9 @@ jQuery( function($) {
<?php endforeach; ?>
</ul>
<a href="#" class="hide-if-no-js button" id="publicize-disconnected-form-hide"><?php esc_html_e( 'OK', 'jetpack' ); ?></a>
- </div><?php // #publicize-form
+ </div>
+ <?php
+
return ob_get_clean();
}
}
diff --git a/plugins/jetpack/modules/pwa.php b/plugins/jetpack/modules/pwa.php
deleted file mode 100644
index f372fac5..00000000
--- a/plugins/jetpack/modules/pwa.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-/**
- * Deprecated. No longer needed.
- */
diff --git a/plugins/jetpack/modules/pwa/class.jetpack-pwa-helpers.php b/plugins/jetpack/modules/pwa/class.jetpack-pwa-helpers.php
deleted file mode 100644
index f372fac5..00000000
--- a/plugins/jetpack/modules/pwa/class.jetpack-pwa-helpers.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-/**
- * Deprecated. No longer needed.
- */
diff --git a/plugins/jetpack/modules/pwa/class.jetpack-pwa-manifest.php b/plugins/jetpack/modules/pwa/class.jetpack-pwa-manifest.php
deleted file mode 100644
index f372fac5..00000000
--- a/plugins/jetpack/modules/pwa/class.jetpack-pwa-manifest.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-/**
- * Deprecated. No longer needed.
- */
diff --git a/plugins/jetpack/modules/pwa/images/wp-192.png b/plugins/jetpack/modules/pwa/images/wp-192.png
deleted file mode 100644
index 9bfd50f7..00000000
--- a/plugins/jetpack/modules/pwa/images/wp-192.png
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/pwa/images/wp-512.png b/plugins/jetpack/modules/pwa/images/wp-512.png
deleted file mode 100644
index 36106626..00000000
--- a/plugins/jetpack/modules/pwa/images/wp-512.png
+++ /dev/null
Binary files differ
diff --git a/plugins/jetpack/modules/related-posts.php b/plugins/jetpack/modules/related-posts.php
index 24591fe9..893132a5 100644
--- a/plugins/jetpack/modules/related-posts.php
+++ b/plugins/jetpack/modules/related-posts.php
@@ -1,4 +1,4 @@
-<?php
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Module Name: Related posts
* Module Description: Keep visitors engaged on your blog by highlighting relevant and new content at the bottom of each published post.
@@ -9,13 +9,16 @@
* Auto Activate: No
* Module Tags: Recommended
* Feature: Engagement
+ * // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
* Additional Search Queries: related, jetpack related posts, related posts for wordpress, related posts, popular posts, popular, related content, related post, contextual, context, contextual related posts, related articles, similar posts, easy related posts, related page, simple related posts, free related posts, related thumbnails, similar, engagement, yet another related posts plugin
*/
class Jetpack_RelatedPosts_Module {
/**
* Class variables
+ *
+ * @var Jetpack_RelatedPosts_Module
*/
- private static $__instance = null;
+ private static $instance = null;
/**
* Singleton implementation
@@ -23,10 +26,11 @@ class Jetpack_RelatedPosts_Module {
* @return object
*/
public static function instance() {
- if ( ! is_a( self::$__instance, 'Jetpack_RelatedPosts_Module' ) )
- self::$__instance = new Jetpack_RelatedPosts_Module();
+ if ( ! is_a( self::$instance, 'Jetpack_RelatedPosts_Module' ) ) {
+ self::$instance = new Jetpack_RelatedPosts_Module();
+ }
- return self::$__instance;
+ return self::$instance;
}
/**
@@ -42,10 +46,9 @@ class Jetpack_RelatedPosts_Module {
* This action triggers if the module is in an active state, load related posts and options.
*
* @uses Jetpack_RelatedPosts::init, is_admin, Jetpack::enable_module_configurable, Jetpack_Sync::sync_posts
- * @return null
*/
public function action_on_load() {
- require_once 'related-posts/jetpack-related-posts.php';
+ require_once __DIR__ . '/related-posts/jetpack-related-posts.php';
Jetpack_RelatedPosts::init();
if ( is_admin() ) {
@@ -54,7 +57,7 @@ class Jetpack_RelatedPosts_Module {
// Load Customizer controls.
if ( class_exists( WP_Customize_Manager::class ) && class_exists( WP_Customize_Control::class ) ) {
- require_once 'related-posts/class.related-posts-customize.php';
+ require_once __DIR__ . '/related-posts/class.related-posts-customize.php';
}
}
}
diff --git a/plugins/jetpack/modules/related-posts/class.related-posts-customize.php b/plugins/jetpack/modules/related-posts/class.related-posts-customize.php
index c6dd4788..b8d124e9 100644
--- a/plugins/jetpack/modules/related-posts/class.related-posts-customize.php
+++ b/plugins/jetpack/modules/related-posts/class.related-posts-customize.php
@@ -1,8 +1,8 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Assets;
-// Exit if file is accessed directly
+// Exit if file is accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@@ -19,19 +19,21 @@ class Jetpack_Related_Posts_Customize {
*
* @var string
*/
- var $prefix = 'jetpack_relatedposts';
+ public $prefix = 'jetpack_relatedposts';
/**
- * @var string Control to focus when customizer loads.
+ * Control to focus when customizer loads
+ *
+ * @var string
*/
- var $focus = '';
+ public $focus = '';
/**
* Class initialization.
*
* @since 4.4.0
*/
- function __construct() {
+ public function __construct() {
add_action( 'customize_register', array( $this, 'customize_register' ) );
add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_controls_enqueue_scripts' ) );
}
@@ -43,37 +45,39 @@ class Jetpack_Related_Posts_Customize {
*
* @param WP_Customize_Manager $wp_customize Customizer instance.
*/
- function customize_register( $wp_customize ) {
+ public function customize_register( $wp_customize ) {
- $wp_customize->add_section( $this->prefix,
+ $wp_customize->add_section(
+ $this->prefix,
array(
- 'title' => esc_html__( 'Related Posts', 'jetpack' ),
+ 'title' => esc_html__( 'Related Posts', 'jetpack' ),
'description' => '',
'capability' => 'edit_theme_options',
- 'priority' => 200,
+ 'priority' => 200,
)
);
$selective_options = array();
foreach ( $this->get_options( $wp_customize ) as $key => $field ) {
- $control_id = "$this->prefix[$key]";
+ $control_id = "$this->prefix[$key]";
$selective_options[] = $control_id;
- $wp_customize->add_setting( $control_id,
+ $wp_customize->add_setting(
+ $control_id,
array(
- 'default' => isset( $field['default'] ) ? $field['default'] : '',
- 'type' => isset( $field['setting_type'] ) ? $field['setting_type'] : 'option',
+ 'default' => isset( $field['default'] ) ? $field['default'] : '',
+ 'type' => isset( $field['setting_type'] ) ? $field['setting_type'] : 'option',
'capability' => isset( $field['capability'] ) ? $field['capability'] : 'edit_theme_options',
'transport' => isset( $field['transport'] ) ? $field['transport'] : 'postMessage',
)
);
$control_settings = array(
- 'label' => isset( $field['label'] ) ? $field['label'] : '',
- 'description' => isset( $field['description'] ) ? $field['description'] : '',
- 'settings' => $control_id,
- 'type' => isset( $field['control_type'] ) ? $field['control_type'] : 'text',
- 'section' => $this->prefix,
- 'priority' => 10,
+ 'label' => isset( $field['label'] ) ? $field['label'] : '',
+ 'description' => isset( $field['description'] ) ? $field['description'] : '',
+ 'settings' => $control_id,
+ 'type' => isset( $field['control_type'] ) ? $field['control_type'] : 'text',
+ 'section' => $this->prefix,
+ 'priority' => 10,
'active_callback' => isset( $field['active_callback'] ) ? $field['active_callback'] : __CLASS__ . '::is_single',
);
switch ( $field['control_type'] ) {
@@ -96,12 +100,15 @@ class Jetpack_Related_Posts_Customize {
// If selective refresh is available, implement it.
if ( isset( $wp_customize->selective_refresh ) ) {
- $wp_customize->selective_refresh->add_partial( "$this->prefix", array(
- 'selector' => '.jp-relatedposts:not(.jp-relatedposts-block)',
- 'settings' => $selective_options,
- 'render_callback' => __CLASS__ . '::render_callback',
- 'container_inclusive' => false,
- ) );
+ $wp_customize->selective_refresh->add_partial(
+ "$this->prefix",
+ array(
+ 'selector' => '.jp-relatedposts:not(.jp-relatedposts-block)',
+ 'settings' => $selective_options,
+ 'render_callback' => __CLASS__ . '::render_callback',
+ 'container_inclusive' => false,
+ )
+ );
}
}
@@ -112,7 +119,7 @@ class Jetpack_Related_Posts_Customize {
* @since 4.4.0
*/
public static function render_callback() {
- echo Jetpack_RelatedPosts::init()->get_headline();
+ echo Jetpack_RelatedPosts::init()->get_headline(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- content escaped in get_headline method
}
/**
@@ -167,15 +174,15 @@ class Jetpack_Related_Posts_Customize {
*
* @since 4.4.0
*
- * @param object $wp_customize Instance of WP Customizer
+ * @param object $wp_customize Instance of WP Customizer.
*
* @return mixed|void
*/
- function get_options( $wp_customize ) {
+ public function get_options( $wp_customize ) {
$transport = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
$switched_locale = switch_to_locale( get_user_locale() );
- $headline = __( 'Related', 'jetpack' );
+ $headline = __( 'Related', 'jetpack' );
if ( $switched_locale ) {
restore_previous_locale();
}
@@ -190,14 +197,15 @@ class Jetpack_Related_Posts_Customize {
* @param array $options Array of options used to display Related Posts in the Customizer.
*/
return apply_filters(
- 'jetpack_related_posts_customize_options', array(
- 'enabled' => array(
+ 'jetpack_related_posts_customize_options',
+ array(
+ 'enabled' => array(
'control_type' => 'hidden',
'default' => 1,
'setting_type' => 'option',
'transport' => $transport,
),
- 'show_headline' => array(
+ 'show_headline' => array(
'label' => esc_html__( 'Show a headline', 'jetpack' ),
'description' => esc_html__( 'This helps to clearly separate the related posts from post content.', 'jetpack' ),
'control_type' => 'checkbox',
@@ -205,7 +213,7 @@ class Jetpack_Related_Posts_Customize {
'setting_type' => 'option',
'transport' => $transport,
),
- 'headline' => array(
+ 'headline' => array(
'label' => '',
'description' => esc_html__( 'Enter text to use as headline.', 'jetpack' ),
'control_type' => 'text',
@@ -213,7 +221,7 @@ class Jetpack_Related_Posts_Customize {
'setting_type' => 'option',
'transport' => $transport,
),
- 'show_thumbnails' => array(
+ 'show_thumbnails' => array(
'label' => esc_html__( 'Show thumbnails', 'jetpack' ),
'description' => esc_html__( 'Show a thumbnail image where available.', 'jetpack' ),
'control_type' => 'checkbox',
@@ -221,7 +229,7 @@ class Jetpack_Related_Posts_Customize {
'setting_type' => 'option',
'transport' => $transport,
),
- 'show_date' => array(
+ 'show_date' => array(
'label' => esc_html__( 'Show date', 'jetpack' ),
'description' => esc_html__( 'Display date when entry was published.', 'jetpack' ),
'control_type' => 'checkbox',
@@ -229,7 +237,7 @@ class Jetpack_Related_Posts_Customize {
'setting_type' => 'option',
'transport' => $transport,
),
- 'show_context' => array(
+ 'show_context' => array(
'label' => esc_html__( 'Show context', 'jetpack' ),
'description' => esc_html__( "Display entry's category or tag.", 'jetpack' ),
'control_type' => 'checkbox',
@@ -237,11 +245,11 @@ class Jetpack_Related_Posts_Customize {
'setting_type' => 'option',
'transport' => $transport,
),
- 'layout' => array(
+ 'layout' => array(
'label' => esc_html__( 'Layout', 'jetpack' ),
'description' => esc_html__( 'Arrange entries in different layouts.', 'jetpack' ),
'control_type' => 'select',
- 'choices' => array(
+ 'choices' => array(
'grid' => esc_html__( 'Grid', 'jetpack' ),
'list' => esc_html__( 'List', 'jetpack' ),
),
@@ -267,7 +275,7 @@ class Jetpack_Related_Posts_Customize {
*
* @since 4.4.0
*/
- function customize_controls_enqueue_scripts() {
+ public function customize_controls_enqueue_scripts() {
wp_enqueue_script(
'jetpack_related-posts-customizer',
Assets::get_file_url_for_environment(
@@ -275,7 +283,8 @@ class Jetpack_Related_Posts_Customize {
'modules/related-posts/related-posts-customizer.js'
),
array( 'customize-controls' ),
- JETPACK__VERSION
+ JETPACK__VERSION,
+ false
);
}
@@ -285,8 +294,9 @@ class Jetpack_Related_Posts_Customize {
* Control that displays a message in Customizer.
*
* @since 4.4.0
+ * @todo break this out into its own file.
*/
-class Jetpack_Message_Control extends WP_Customize_Control {
+class Jetpack_Message_Control extends WP_Customize_Control { // phpcs:ignore
/**
* Render the message.
@@ -298,5 +308,5 @@ class Jetpack_Message_Control extends WP_Customize_Control {
}
} // class end
-// Initialize controls
+// Initialize controls.
new Jetpack_Related_Posts_Customize();
diff --git a/plugins/jetpack/modules/related-posts/jetpack-related-posts.php b/plugins/jetpack/modules/related-posts/jetpack-related-posts.php
index 1927e21c..25910da8 100644
--- a/plugins/jetpack/modules/related-posts/jetpack-related-posts.php
+++ b/plugins/jetpack/modules/related-posts/jetpack-related-posts.php
@@ -1,14 +1,33 @@
-<?php
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * The Jetpack_RelatedPosts class.
+ *
+ * @package automattic/jetpack
+ */
use Automattic\Jetpack\Assets;
use Automattic\Jetpack\Blocks;
use Automattic\Jetpack\Sync\Settings;
+/**
+ * The Jetpack_RelatedPosts class.
+ */
class Jetpack_RelatedPosts {
const VERSION = '20211209';
const SHORTCODE = 'jetpack-related-posts';
- private static $instance = null;
+ /**
+ * Instance of the class.
+ *
+ * @var Jetpack_RelatedPosts
+ */
+ private static $instance = null;
+
+ /**
+ * Instance of the raw class (?).
+ *
+ * @var Jetpack_RelatedPosts
+ */
private static $instance_raw = null;
/**
@@ -18,7 +37,7 @@ class Jetpack_RelatedPosts {
*/
public static function init() {
if ( ! self::$instance ) {
- if ( class_exists('WPCOM_RelatedPosts') && method_exists( 'WPCOM_RelatedPosts', 'init' ) ) {
+ if ( class_exists( 'WPCOM_RelatedPosts' ) && method_exists( 'WPCOM_RelatedPosts', 'init' ) ) {
self::$instance = WPCOM_RelatedPosts::init();
} else {
self::$instance = new Jetpack_RelatedPosts();
@@ -35,7 +54,7 @@ class Jetpack_RelatedPosts {
*/
public static function init_raw() {
if ( ! self::$instance_raw ) {
- if ( class_exists('WPCOM_RelatedPosts') && method_exists( 'WPCOM_RelatedPosts', 'init_raw' ) ) {
+ if ( class_exists( 'WPCOM_RelatedPosts' ) && method_exists( 'WPCOM_RelatedPosts', 'init_raw' ) ) {
self::$instance_raw = WPCOM_RelatedPosts::init_raw();
} else {
self::$instance_raw = new Jetpack_RelatedPosts_Raw();
@@ -45,24 +64,56 @@ class Jetpack_RelatedPosts {
return self::$instance_raw;
}
- protected $_options;
- protected $_allow_feature_toggle;
- protected $_blog_charset;
- protected $_convert_charset;
- protected $_previous_post_id;
- protected $_found_shortcode = false;
+ /**
+ * Options.
+ *
+ * @var array $options
+ */
+ protected $options;
+
+ /**
+ * Allow feature toggle variable.
+ *
+ * @var bool
+ */
+ protected $allow_feature_toggle;
+
+ /**
+ * Blog character set.
+ *
+ * @var mixed
+ */
+ protected $blog_charset;
+
+ /**
+ * Convert character set.
+ *
+ * @var bool
+ */
+ protected $convert_charset;
+
+ /**
+ * Previous Post ID
+ *
+ * @var int
+ */
+ protected $previous_post_id;
+
+ /**
+ * Shortcode usage.
+ *
+ * @var bool
+ */
+ protected $found_shortcode = false;
/**
* Constructor for Jetpack_RelatedPosts.
*
* @uses get_option, add_action, apply_filters
- *
- * @return null
*/
public function __construct() {
- $this->_blog_charset = get_option( 'blog_charset' );
- $this->_convert_charset = ( function_exists( 'iconv' ) && ! preg_match( '/^utf\-?8$/i', $this->_blog_charset ) );
-
+ $this->blog_charset = get_option( 'blog_charset' );
+ $this->convert_charset = ( function_exists( 'iconv' ) && ! preg_match( '/^utf\-?8$/i', $this->blog_charset ) );
add_action( 'admin_init', array( $this, 'action_admin_init' ) );
add_action( 'wp', array( $this, 'action_frontend_init' ) );
@@ -77,10 +128,30 @@ class Jetpack_RelatedPosts {
'jetpack/related-posts',
array(
'render_callback' => array( $this, 'render_block' ),
+ 'supports' => array(
+ 'color' => array(
+ 'gradients' => true,
+ 'link' => true,
+ ),
+ 'spacing' => array(
+ 'margin' => true,
+ 'padding' => true,
+ ),
+ 'typography' => array(
+ 'fontSize' => true,
+ 'lineHeight' => true,
+ ),
+ 'align' => array( 'wide', 'full' ),
+ ),
)
);
}
+ /**
+ * Get the blog ID.
+ *
+ * @return Object current blog id.
+ */
protected function get_blog_id() {
return Jetpack_Options::get_option( 'id' );
}
@@ -96,18 +167,17 @@ class Jetpack_RelatedPosts {
*
* @action admin_init
* @uses add_settings_field, __, register_setting, add_action
- * @return null
*/
public function action_admin_init() {
- // Add the setting field [jetpack_relatedposts] and place it in Settings > Reading
+ // Add the setting field [jetpack_relatedposts] and place it in Settings > Reading.
add_settings_field( 'jetpack_relatedposts', '<span id="jetpack_relatedposts">' . __( 'Related posts', 'jetpack' ) . '</span>', array( $this, 'print_setting_html' ), 'reading' );
register_setting( 'reading', 'jetpack_relatedposts', array( $this, 'parse_options' ) );
- add_action('admin_head', array( $this, 'print_setting_head' ) );
+ add_action( 'admin_head', array( $this, 'print_setting_head' ) );
- if( 'options-reading.php' == $GLOBALS['pagenow'] ) {
- // Enqueue style for live preview on the reading settings page
- $this->_enqueue_assets( false, true );
+ if ( 'options-reading.php' === $GLOBALS['pagenow'] ) {
+ // Enqueue style for live preview on the reading settings page.
+ $this->enqueue_assets( false, true );
}
}
@@ -117,25 +187,25 @@ class Jetpack_RelatedPosts {
* @global $_GET
* @action wp
* @uses add_shortcode, get_the_ID
- * @returns null
*/
public function action_frontend_init() {
- // Add a shortcode handler that outputs nothing, this gets overridden later if we can display related content
+ // Add a shortcode handler that outputs nothing, this gets overridden later if we can display related content.
add_shortcode( self::SHORTCODE, array( $this, 'get_client_rendered_html_unsupported' ) );
- if ( ! $this->_enabled_for_request() )
+ if ( ! $this->enabled_for_request() ) {
return;
+ }
- if ( isset( $_GET['relatedposts'] ) ) {
+ if ( isset( $_GET['relatedposts'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reading and checking if we need to generate a list of excuded posts, does not update anything on the site.
$excludes = $this->parse_numeric_get_arg( 'relatedposts_exclude' );
- $this->_action_frontend_init_ajax( $excludes );
+ $this->action_frontend_init_ajax( $excludes );
} else {
- if ( isset( $_GET['relatedposts_hit'], $_GET['relatedposts_origin'], $_GET['relatedposts_position'] ) ) {
- $this->_log_click( $_GET['relatedposts_origin'], get_the_ID(), $_GET['relatedposts_position'] );
- $this->_previous_post_id = (int) $_GET['relatedposts_origin'];
+ if ( isset( $_GET['relatedposts_hit'], $_GET['relatedposts_origin'], $_GET['relatedposts_position'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- checking if fields are set to setup tracking, nothing is changing on the site.
+ $this->previous_post_id = (int) $_GET['relatedposts_origin']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- fetching a previous post ID for tracking, nothing is changing on the site.
+ $this->log_click( $this->previous_post_id, get_the_ID(), sanitize_text_field( wp_unslash( $_GET['relatedposts_position'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- logging the click for tracking, nothing is changing on the site.
}
- $this->_action_frontend_init_page();
+ $this->action_frontend_init_page();
}
}
@@ -178,7 +248,7 @@ class Jetpack_RelatedPosts {
return $content;
}
- if ( ! $this->_found_shortcode && ! doing_filter( 'get_the_excerpt' ) ) {
+ if ( ! $this->found_shortcode && ! doing_filter( 'get_the_excerpt' ) ) {
if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
$content .= "\n" . $this->get_server_rendered_html();
} else {
@@ -214,12 +284,12 @@ class Jetpack_RelatedPosts {
* Looks for our shortcode on the unfiltered content, this has to execute early.
*
* @filter the_content
- * @param string $content
+ * @param string $content - content of the post.
* @uses has_shortcode
- * @returns string
+ * @return string $content
*/
public function test_for_shortcode( $content ) {
- $this->_found_shortcode = has_shortcode( $content, self::SHORTCODE );
+ $this->found_shortcode = has_shortcode( $content, self::SHORTCODE );
return $content;
}
@@ -228,7 +298,7 @@ class Jetpack_RelatedPosts {
* Returns the HTML for the related posts section.
*
* @uses esc_html__, apply_filters
- * @returns string
+ * @return string
*/
public function get_client_rendered_html() {
if ( Settings::is_syncing() ) {
@@ -246,10 +316,10 @@ class Jetpack_RelatedPosts {
*/
$headline = apply_filters( 'jetpack_relatedposts_filter_headline', $this->get_headline() );
- if ( $this->_previous_post_id ) {
- $exclude = "data-exclude='{$this->_previous_post_id}'";
+ if ( $this->previous_post_id ) {
+ $exclude = "data-exclude='{$this->previous_post_id}'";
} else {
- $exclude = "";
+ $exclude = '';
}
return <<<EOT
@@ -363,6 +433,7 @@ EOT;
* @return string
*/
public function render_block( $attributes ) {
+ $post_id = get_the_ID();
$block_attributes = array(
'headline' => isset( $attributes['headline'] ) ? $attributes['headline'] : null,
'show_thumbnails' => isset( $attributes['displayThumbnails'] ) && $attributes['displayThumbnails'],
@@ -375,7 +446,7 @@ EOT;
$excludes = $this->parse_numeric_get_arg( 'relatedposts_origin' );
$related_posts = $this->get_for_post_id(
- get_the_ID(),
+ $post_id,
array(
'size' => $block_attributes['size'],
'exclude_post_ids' => $excludes,
@@ -408,12 +479,30 @@ EOT;
$rows_markup .= $this->render_block_row( $lower_row_posts, $block_attributes );
}
- return sprintf(
- '<nav class="jp-relatedposts-i2" data-layout="%1$s">%2$s%3$s</nav>',
+ $wrapper_attributes = \WP_Block_Supports::get_instance()->apply_block_supports();
+
+ $display_markup = sprintf(
+ '<nav class="jp-relatedposts-i2%1$s"%2$s data-layout="%3$s">%4$s%5$s</nav>',
+ ! empty( $wrapper_attributes['class'] ) ? ' ' . esc_attr( $wrapper_attributes['class'] ) : '',
+ ! empty( $wrapper_attributes['style'] ) ? ' style="' . esc_attr( $wrapper_attributes['style'] ) . '"' : '',
esc_attr( $block_attributes['layout'] ),
$block_attributes['headline'],
$rows_markup
);
+
+ /**
+ * Filter the output HTML of Related Posts.
+ *
+ * @module related-posts
+ *
+ * @since 10.7
+ *
+ * @param string $display_markup HTML output of Related Posts.
+ * @param int|false get_the_ID() Post ID of the post for which we are retrieving Related Posts.
+ * @param array $related_posts Array of related posts.
+ * @param array $block_attributes Array of Block attributes.
+ */
+ return apply_filters( 'jetpack_related_posts_display_markup', $display_markup, $post_id, $related_posts, $block_attributes );
}
/**
@@ -435,11 +524,12 @@ EOT;
public function parse_numeric_get_arg( $arg ) {
$result = array();
- if ( isset( $_GET[ $arg ] ) ) {
- if ( is_string( $_GET[ $arg ] ) ) {
- $result = explode( ',', $_GET[ $arg ] );
- } elseif ( is_array( $_GET[ $arg ] ) ) {
- $result = array_values( $_GET[ $arg ] );
+ if ( isset( $_GET[ $arg ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- requests are used to generate a list of related posts we want to exclude.
+ if ( is_string( $_GET[ $arg ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $result = explode( ',', sanitize_text_field( wp_unslash( $_GET[ $arg ] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ } elseif ( is_array( $_GET[ $arg ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $args = array_map( 'sanitize_text_field', wp_unslash( $_GET[ $arg ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $result = array_values( $args );
}
$result = array_unique( array_filter( array_map( 'absint', $result ) ) );
@@ -455,30 +545,35 @@ EOT;
* @return array
*/
public function get_options() {
- if ( null === $this->_options ) {
- $this->_options = Jetpack_Options::get_option( 'relatedposts', array() );
- if ( ! is_array( $this->_options ) )
- $this->_options = array();
- if ( ! isset( $this->_options['enabled'] ) )
- $this->_options['enabled'] = true;
- if ( ! isset( $this->_options['show_headline'] ) )
- $this->_options['show_headline'] = true;
- if ( ! isset( $this->_options['show_thumbnails'] ) )
- $this->_options['show_thumbnails'] = false;
- if ( ! isset( $this->_options['show_date'] ) ) {
- $this->_options['show_date'] = true;
+ if ( null === $this->options ) {
+ $this->options = Jetpack_Options::get_option( 'relatedposts', array() );
+ if ( ! is_array( $this->options ) ) {
+ $this->options = array();
+ }
+ if ( ! isset( $this->options['enabled'] ) ) {
+ $this->options['enabled'] = true;
+ }
+ if ( ! isset( $this->options['show_headline'] ) ) {
+ $this->options['show_headline'] = true;
}
- if ( ! isset( $this->_options['show_context'] ) ) {
- $this->_options['show_context'] = true;
+ if ( ! isset( $this->options['show_thumbnails'] ) ) {
+ $this->options['show_thumbnails'] = false;
}
- if ( ! isset( $this->_options['layout'] ) ) {
- $this->_options['layout'] = 'grid';
+ if ( ! isset( $this->options['show_date'] ) ) {
+ $this->options['show_date'] = true;
}
- if ( ! isset( $this->_options['headline'] ) ) {
- $this->_options['headline'] = esc_html__( 'Related', 'jetpack' );
+ if ( ! isset( $this->options['show_context'] ) ) {
+ $this->options['show_context'] = true;
+ }
+ if ( ! isset( $this->options['layout'] ) ) {
+ $this->options['layout'] = 'grid';
+ }
+ if ( ! isset( $this->options['headline'] ) ) {
+ $this->options['headline'] = esc_html__( 'Related', 'jetpack' );
+ }
+ if ( empty( $this->options['size'] ) || (int) $this->options['size'] < 1 ) {
+ $this->options['size'] = 3;
}
- if ( empty( $this->_options['size'] ) || (int)$this->_options['size'] < 1 )
- $this->_options['size'] = 3;
/**
* Filter Related Posts basic options.
@@ -489,12 +584,17 @@ EOT;
*
* @param array $this->_options Array of basic Related Posts options.
*/
- $this->_options = apply_filters( 'jetpack_relatedposts_filter_options', $this->_options );
+ $this->options = apply_filters( 'jetpack_relatedposts_filter_options', $this->options );
}
- return $this->_options;
+ return $this->options;
}
+ /**
+ * Gets options.
+ *
+ * @param string $option_name - option we want to get.
+ */
public function get_option( $option_name ) {
$options = $this->get_options();
@@ -508,15 +608,16 @@ EOT;
/**
* Parses input and returns normalized options array.
*
- * @param array $input
+ * @param array $input - input we're parsing.
* @uses self::get_options
* @return array
*/
public function parse_options( $input ) {
$current = $this->get_options();
- if ( !is_array( $input ) )
+ if ( ! is_array( $input ) ) {
$input = array();
+ }
if (
! isset( $input['enabled'] )
@@ -528,23 +629,23 @@ EOT;
$input['enabled'] = '1';
}
- if ( '1' == $input['enabled'] ) {
- $current['enabled'] = true;
- $current['show_headline'] = ( isset( $input['show_headline'] ) && '1' == $input['show_headline'] );
- $current['show_thumbnails'] = ( isset( $input['show_thumbnails'] ) && '1' == $input['show_thumbnails'] );
- $current['show_date'] = ( isset( $input['show_date'] ) && '1' == $input['show_date'] );
- $current['show_context'] = ( isset( $input['show_context'] ) && '1' == $input['show_context'] );
- $current['layout'] = isset( $input['layout'] ) && in_array( $input['layout'], array( 'grid', 'list' ), true ) ? $input['layout'] : 'grid';
- $current['headline'] = isset( $input['headline'] ) ? $input['headline'] : esc_html__( 'Related', 'jetpack' );
+ if ( '1' == $input['enabled'] ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- expecting string, but may return bools.
+ $current['enabled'] = true;
+ $current['show_headline'] = ( isset( $input['show_headline'] ) && '1' == $input['show_headline'] ); // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
+ $current['show_thumbnails'] = ( isset( $input['show_thumbnails'] ) && '1' == $input['show_thumbnails'] ); // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
+ $current['show_date'] = ( isset( $input['show_date'] ) && '1' == $input['show_date'] ); // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
+ $current['show_context'] = ( isset( $input['show_context'] ) && '1' == $input['show_context'] ); // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
+ $current['layout'] = isset( $input['layout'] ) && in_array( $input['layout'], array( 'grid', 'list' ), true ) ? $input['layout'] : 'grid';
+ $current['headline'] = isset( $input['headline'] ) ? $input['headline'] : esc_html__( 'Related', 'jetpack' );
} else {
$current['enabled'] = false;
}
- if ( isset( $input['size'] ) && (int)$input['size'] > 0 )
- $current['size'] = (int)$input['size'];
- else
+ if ( isset( $input['size'] ) && (int) $input['size'] > 0 ) {
+ $current['size'] = (int) $input['size'];
+ } else {
$current['size'] = null;
-
+ }
return $current;
}
@@ -578,7 +679,7 @@ EOT;
<div id="jp-relatedposts" class="jp-relatedposts"></div>
</div>
EOT;
- $ui_settings = sprintf(
+ $ui_settings = sprintf(
$ui_settings_template,
esc_html__( 'The following settings will impact all related posts on your site, except for those you created via the block editor:', 'jetpack' ),
checked( $options['show_headline'], true, false ),
@@ -592,14 +693,14 @@ EOT;
esc_html__( 'Preview:', 'jetpack' )
);
- if ( !$this->_allow_feature_toggle() ) {
+ if ( ! $this->allow_feature_toggle() ) {
$template = <<<EOT
<input type="hidden" name="jetpack_relatedposts[enabled]" value="1" />
%s
EOT;
printf(
- $template,
- $ui_settings
+ $template, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ $ui_settings // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- data is escaped when variable is set.
);
} else {
$template = <<<EOT
@@ -614,12 +715,12 @@ EOT;
</ul>
EOT;
printf(
- $template,
+ $template, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
checked( $options['enabled'], false, false ),
esc_html__( 'Hide related content after posts', 'jetpack' ),
checked( $options['enabled'], true, false ),
esc_html__( 'Show related content after posts', 'jetpack' ),
- $ui_settings
+ $ui_settings // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- data is escaped when variable is set.
);
}
}
@@ -632,23 +733,24 @@ EOT;
*/
public function print_setting_head() {
- // only dislay the Related Posts JavaScript on the Reading Settings Admin Page
- $current_screen = get_current_screen();
+ // only dislay the Related Posts JavaScript on the Reading Settings Admin Page.
+ $current_screen = get_current_screen();
- if ( is_null( $current_screen ) ) {
+ if ( $current_screen === null ) {
return;
}
- if( 'options-reading' != $current_screen->id )
+ if ( 'options-reading' !== $current_screen->id ) {
return;
+ }
$related_headline = sprintf(
'<h3 class="jp-relatedposts-headline"><em>%s</em></h3>',
esc_html__( 'Related', 'jetpack' )
);
- $href_params = 'class="jp-relatedposts-post-a" href="#jetpack_relatedposts" rel="nofollow" data-origin="0" data-position="0"';
- $related_with_images = <<<EOT
+ $href_params = 'class="jp-relatedposts-post-a" href="#jetpack_relatedposts" rel="nofollow" data-origin="0" data-position="0"';
+ $related_with_images = <<<EOT
<div class="jp-relatedposts-items jp-relatedposts-items-visual">
<div class="jp-relatedposts-post jp-relatedposts-post0 jp-relatedposts-post-thumbs" data-post-id="0" data-post-format="image">
<a $href_params>
@@ -682,7 +784,7 @@ EOT;
</div>
</div>
EOT;
- $related_with_images = str_replace( "\n", '', $related_with_images );
+ $related_with_images = str_replace( "\n", '', $related_with_images );
$related_without_images = <<<EOT
<div class="jp-relatedposts-items jp-relatedposts-items-minimal">
<p class="jp-relatedposts-post jp-relatedposts-post0" data-post-id="0" data-post-format="image">
@@ -701,12 +803,12 @@ EOT;
EOT;
$related_without_images = str_replace( "\n", '', $related_without_images );
- if ( $this->_allow_feature_toggle() ) {
+ if ( $this->allow_feature_toggle() ) {
$extra_css = '#settings-reading-relatedposts-customize { padding-left:2em; margin-top:.5em; }';
} else {
$extra_css = '';
}
-
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo <<<EOT
<style type="text/css">
#settings-reading-relatedposts .disabled { opacity:.5; filter:Alpha(opacity=50); }
@@ -822,7 +924,7 @@ EOT;
*/
$args = apply_filters( 'jetpack_relatedposts_filter_args', $args, $post_id );
- $filters = $this->_get_es_filters_from_args( $post_id, $args );
+ $filters = $this->get_es_filters_from_args( $post_id, $args );
/**
* Filter Elasticsearch options used to calculate Related Posts.
*
@@ -835,7 +937,7 @@ EOT;
*/
$filters = apply_filters( 'jetpack_relatedposts_filter_filters', $filters, $post_id );
- $results = $this->_get_related_posts( $post_id, $args['size'], $filters );
+ $results = $this->get_related_posts( $post_id, $args['size'], $filters );
/**
* Filter the array of related posts matched by Elasticsearch.
*
@@ -844,7 +946,7 @@ EOT;
* @since 2.8.0
*
* @param array $results Array of related posts matched by Elasticsearch.
- * @param string $post_id Post ID of the post for which we are retrieving Related Posts.
+ * @param int $post_id Post ID of the post for which we are retrieving Related Posts.
*/
return apply_filters( 'jetpack_relatedposts_returned_results', $results, $post_id );
}
@@ -858,12 +960,12 @@ EOT;
/**
* Creates an array of Elasticsearch filters based on the post_id and args.
*
- * @param int $post_id
- * @param array $args
+ * @param int $post_id - the post ID.
+ * @param array $args - the arguments.
* @uses apply_filters, get_post_types, get_post_format_strings
* @return array
*/
- protected function _get_es_filters_from_args( $post_id, array $args ) {
+ protected function get_es_filters_from_args( $post_id, array $args ) {
$filters = array();
/**
@@ -878,7 +980,7 @@ EOT;
*/
$args['has_terms'] = apply_filters( 'jetpack_relatedposts_filter_has_terms', $args['has_terms'], $post_id );
if ( ! empty( $args['has_terms'] ) ) {
- foreach( (array)$args['has_terms'] as $term ) {
+ foreach ( (array) $args['has_terms'] as $term ) {
if ( mb_strlen( $term->taxonomy ) ) {
switch ( $term->taxonomy ) {
case 'post_tag':
@@ -907,17 +1009,19 @@ EOT;
* @param string $post_id Post ID of the post for which we are retrieving Related Posts.
*/
$args['post_type'] = apply_filters( 'jetpack_relatedposts_filter_post_type', $args['post_type'], $post_id );
- $valid_post_types = get_post_types();
+ $valid_post_types = get_post_types();
if ( is_array( $args['post_type'] ) ) {
$sanitized_post_types = array();
foreach ( $args['post_type'] as $pt ) {
- if ( in_array( $pt, $valid_post_types ) )
+ if ( in_array( $pt, $valid_post_types, true ) ) {
$sanitized_post_types[] = $pt;
+ }
}
- if ( ! empty( $sanitized_post_types ) )
+ if ( ! empty( $sanitized_post_types ) ) {
$filters[] = array( 'terms' => array( 'post_type' => $sanitized_post_types ) );
- } else if ( in_array( $args['post_type'], $valid_post_types ) && 'all' != $args['post_type'] ) {
- $filters[] = array( 'term' => array( 'post_type' => $args['post_type'] ) );
+ }
+ } elseif ( in_array( $args['post_type'], $valid_post_types, true ) && 'all' !== $args['post_type'] ) {
+ $filters[] = array( 'term' => array( 'post_type' => $args['post_type'] ) );
}
/**
@@ -930,8 +1034,8 @@ EOT;
* @param array $args['post_formats'] Array of Post Formats.
* @param string $post_id Post ID of the post for which we are retrieving Related Posts.
*/
- $args['post_formats'] = apply_filters( 'jetpack_relatedposts_filter_post_formats', $args['post_formats'], $post_id );
- $valid_post_formats = get_post_format_strings();
+ $args['post_formats'] = apply_filters( 'jetpack_relatedposts_filter_post_formats', $args['post_formats'], $post_id );
+ $valid_post_formats = get_post_format_strings();
$sanitized_post_formats = array();
foreach ( $args['post_formats'] as $pf ) {
if ( array_key_exists( $pf, $valid_post_formats ) ) {
@@ -955,11 +1059,11 @@ EOT;
$args['date_range'] = apply_filters( 'jetpack_relatedposts_filter_date_range', $args['date_range'], $post_id );
if ( is_array( $args['date_range'] ) && ! empty( $args['date_range'] ) ) {
$args['date_range'] = array_map( 'intval', $args['date_range'] );
- if ( !empty( $args['date_range']['from'] ) && !empty( $args['date_range']['to'] ) ) {
+ if ( ! empty( $args['date_range']['from'] ) && ! empty( $args['date_range']['to'] ) ) {
$filters[] = array(
'range' => array(
- 'date_gmt' => $this->_get_coalesced_range( $args['date_range'] ),
- )
+ 'date_gmt' => $this->get_coalesced_range( $args['date_range'] ),
+ ),
);
}
}
@@ -975,12 +1079,13 @@ EOT;
* @param string $post_id Post ID of the post for which we are retrieving Related Posts.
*/
$args['exclude_post_ids'] = apply_filters( 'jetpack_relatedposts_filter_exclude_post_ids', $args['exclude_post_ids'], $post_id );
- if ( !empty( $args['exclude_post_ids'] ) && is_array( $args['exclude_post_ids'] ) ) {
+ if ( ! empty( $args['exclude_post_ids'] ) && is_array( $args['exclude_post_ids'] ) ) {
$excluded_post_ids = array();
- foreach ( $args['exclude_post_ids'] as $exclude_post_id) {
- $exclude_post_id = (int)$exclude_post_id;
- if ( $exclude_post_id > 0 )
+ foreach ( $args['exclude_post_ids'] as $exclude_post_id ) {
+ $exclude_post_id = (int) $exclude_post_id;
+ if ( $exclude_post_id > 0 ) {
$excluded_post_ids[] = $exclude_post_id;
+ }
}
$filters[] = array( 'not' => array( 'terms' => array( 'post_id' => $excluded_post_ids ) ) );
}
@@ -991,25 +1096,27 @@ EOT;
/**
* Takes a range and coalesces it into a month interval bracketed by a time as determined by the blog_id to enhance caching.
*
- * @param array $date_range
+ * @todo Rewrite this function with proper date handling rather than `strtotime()` and `date()`.
+ *
+ * @param array $date_range - the date range.
* @return array
*/
- protected function _get_coalesced_range( array $date_range ) {
- $now = time();
+ protected function get_coalesced_range( array $date_range ) {
+ $now = time();
$coalesce_time = $this->get_blog_id() % 86400;
- $current_time = $now - strtotime( 'today', $now );
+ $current_time = $now - strtotime( 'today', $now );
- if ( $current_time < $coalesce_time && '01' == date( 'd', $now ) ) {
- // Move back 1 period
+ if ( $current_time < $coalesce_time && '01' === date( 'd', $now ) ) { // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
+ // Move back 1 period.
return array(
- 'from' => date( 'Y-m-01', strtotime( '-1 month', $date_range['from'] ) ) . ' ' . date( 'H:i:s', $coalesce_time ),
- 'to' => date( 'Y-m-01', $date_range['to'] ) . ' ' . date( 'H:i:s', $coalesce_time ),
+ 'from' => date( 'Y-m-01', strtotime( '-1 month', $date_range['from'] ) ) . ' ' . date( 'H:i:s', $coalesce_time ), //phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
+ 'to' => date( 'Y-m-01', $date_range['to'] ) . ' ' . date( 'H:i:s', $coalesce_time ), //phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
);
} else {
- // Use current period
+ // Use current period.
return array(
- 'from' => date( 'Y-m-01', $date_range['from'] ) . ' ' . date( 'H:i:s', $coalesce_time ),
- 'to' => date( 'Y-m-01', strtotime( '+1 month', $date_range['to'] ) ) . ' ' . date( 'H:i:s', $coalesce_time ),
+ 'from' => date( 'Y-m-01', $date_range['from'] ) . ' ' . date( 'H:i:s', $coalesce_time ), //phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
+ 'to' => date( 'Y-m-01', strtotime( '+1 month', $date_range['to'] ) ) . ' ' . date( 'H:i:s', $coalesce_time ), //phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
);
}
}
@@ -1018,29 +1125,28 @@ EOT;
* Generate and output ajax response for related posts API call.
* NOTE: Calls exit() to end all further processing after payload has been outputed.
*
- * @param array $excludes array of post_ids to exclude
+ * @param array $excludes array of post_ids to exclude.
* @uses send_nosniff_header, self::get_for_post_id, get_the_ID
- * @return null
*/
- protected function _action_frontend_init_ajax( array $excludes ) {
+ protected function action_frontend_init_ajax( array $excludes ) {
define( 'DOING_AJAX', true );
- header( 'Content-type: application/json; charset=utf-8' ); // JSON can only be UTF-8
+ header( 'Content-type: application/json; charset=utf-8' ); // JSON can only be UTF-8.
send_nosniff_header();
$options = $this->get_options();
- if ( isset( $_GET['jetpackrpcustomize'] ) ) {
+ if ( isset( $_GET['jetpackrpcustomize'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- adds dummy content if we're in the customizer.
// If we're in the customizer, add dummy content.
- $date_now = current_time( get_option( 'date_format' ) );
+ $date_now = current_time( get_option( 'date_format' ) );
$related_posts = array(
array(
'id' => - 1,
'url' => 'https://jetpackme.files.wordpress.com/2019/03/cat-blog.png',
'url_meta' => array(
'origin' => 0,
- 'position' => 0
+ 'position' => 0,
),
'title' => esc_html__( 'Big iPhone/iPad Update Now Available', 'jetpack' ),
'date' => $date_now,
@@ -1051,16 +1157,16 @@ EOT;
'img' => array(
'src' => 'https://jetpackme.files.wordpress.com/2019/03/cat-blog.png',
'width' => 350,
- 'height' => 200
+ 'height' => 200,
),
- 'classes' => array()
+ 'classes' => array(),
),
array(
'id' => - 1,
'url' => 'https://jetpackme.files.wordpress.com/2019/03/devices.jpg',
'url_meta' => array(
'origin' => 0,
- 'position' => 0
+ 'position' => 0,
),
'title' => esc_html__( 'The WordPress for Android App Gets a Big Facelift', 'jetpack' ),
'date' => $date_now,
@@ -1071,16 +1177,16 @@ EOT;
'img' => array(
'src' => 'https://jetpackme.files.wordpress.com/2019/03/devices.jpg',
'width' => 350,
- 'height' => 200
+ 'height' => 200,
),
- 'classes' => array()
+ 'classes' => array(),
),
array(
'id' => - 1,
'url' => 'https://jetpackme.files.wordpress.com/2019/03/mobile-wedding.jpg',
'url_meta' => array(
'origin' => 0,
- 'position' => 0
+ 'position' => 0,
),
'title' => esc_html__( 'Upgrade Focus, VideoPress for weddings', 'jetpack' ),
'date' => $date_now,
@@ -1091,9 +1197,9 @@ EOT;
'img' => array(
'src' => 'https://jetpackme.files.wordpress.com/2019/03/mobile-wedding.jpg',
'width' => 350,
- 'height' => 200
+ 'height' => 200,
),
- 'classes' => array()
+ 'classes' => array(),
),
);
@@ -1111,28 +1217,33 @@ EOT;
);
// Fetch posts with featured image.
- $with_post_thumbnails = get_posts( array(
- 'posts_per_page' => $options['size'],
- 'post__not_in' => $excluded_posts,
- 'post_type' => $current_post->post_type,
- 'meta_key' => '_thumbnail_id',
- 'suppress_filters' => false,
- ) );
+ $with_post_thumbnails = get_posts(
+ array(
+ 'posts_per_page' => $options['size'],
+ 'post__not_in' => $excluded_posts,
+ 'post_type' => $current_post->post_type,
+ 'meta_key' => '_thumbnail_id',
+ 'suppress_filters' => false,
+ )
+ );
// If we don't have enough, fetch posts without featured image.
- if ( 0 < ( $more = $options['size'] - count( $with_post_thumbnails ) ) ) {
- $no_post_thumbnails = get_posts( array(
- 'posts_per_page' => $more,
- 'post__not_in' => $excluded_posts,
- 'post_type' => $current_post->post_type,
- 'meta_query' => array(
- array(
- 'key' => '_thumbnail_id',
- 'compare' => 'NOT EXISTS',
+ $more = $options['size'] - count( $with_post_thumbnails );
+ if ( 0 < $more ) {
+ $no_post_thumbnails = get_posts(
+ array(
+ 'posts_per_page' => $more,
+ 'post__not_in' => $excluded_posts,
+ 'post_type' => $current_post->post_type,
+ 'meta_query' => array(
+ array(
+ 'key' => '_thumbnail_id',
+ 'compare' => 'NOT EXISTS',
+ ),
),
- ),
- 'suppress_filters' => false,
- ) );
+ 'suppress_filters' => false,
+ )
+ );
} else {
$no_post_thumbnails = array();
}
@@ -1140,11 +1251,11 @@ EOT;
foreach ( array_merge( $with_post_thumbnails, $no_post_thumbnails ) as $index => $real_post ) {
$related_posts[ $index ]['id'] = $real_post->ID;
$related_posts[ $index ]['url'] = esc_url( get_permalink( $real_post ) );
- $related_posts[ $index ]['title'] = $this->_to_utf8( $this->get_title( $real_post->post_title, $real_post->post_content, $real_post->ID ) );
+ $related_posts[ $index ]['title'] = $this->to_utf8( $this->get_title( $real_post->post_title, $real_post->post_content, $real_post->ID ) );
$related_posts[ $index ]['date'] = get_the_date( '', $real_post );
- $related_posts[ $index ]['excerpt'] = html_entity_decode( $this->_to_utf8( $this->_get_excerpt( $real_post->post_excerpt, $real_post->post_content ) ), ENT_QUOTES, 'UTF-8' );
- $related_posts[ $index ]['img'] = $this->_generate_related_post_image_params( $real_post->ID );
- $related_posts[ $index ]['context'] = $this->_generate_related_post_context( $real_post->ID );
+ $related_posts[ $index ]['excerpt'] = html_entity_decode( $this->to_utf8( $this->get_excerpt( $real_post->post_excerpt, $real_post->post_content ) ), ENT_QUOTES, 'UTF-8' );
+ $related_posts[ $index ]['img'] = $this->generate_related_post_image_params( $real_post->ID );
+ $related_posts[ $index ]['context'] = $this->generate_related_post_context( $real_post->ID );
}
} else {
$related_posts = $this->get_for_post_id(
@@ -1156,19 +1267,20 @@ EOT;
}
$response = array(
- 'version' => self::VERSION,
+ 'version' => self::VERSION,
'show_thumbnails' => (bool) $options['show_thumbnails'],
- 'show_date' => (bool) $options['show_date'],
- 'show_context' => (bool) $options['show_context'],
- 'layout' => (string) $options['layout'],
- 'headline' => (string) $options['headline'],
- 'items' => array(),
+ 'show_date' => (bool) $options['show_date'],
+ 'show_context' => (bool) $options['show_context'],
+ 'layout' => (string) $options['layout'],
+ 'headline' => (string) $options['headline'],
+ 'items' => array(),
);
- if ( count( $related_posts ) == $options['size'] )
+ if ( count( $related_posts ) === $options['size'] ) {
$response['items'] = $related_posts;
+ }
- echo json_encode( $response );
+ echo wp_json_encode( $response );
exit();
}
@@ -1176,15 +1288,14 @@ EOT;
/**
* Returns a UTF-8 encoded array of post information for the given post_id
*
- * @param int $post_id
- * @param int $position
- * @param int $origin The post id that this is related to
+ * @param int $post_id - the post ID.
+ * @param int $position - position of the post.
+ * @param int $origin - The post id that this is related to.
* @uses get_post, get_permalink, remove_query_arg, get_post_format, apply_filters
* @return array
*/
public function get_related_post_data_for_post( $post_id, $position, $origin ) {
$post = get_post( $post_id );
-
return array(
'id' => $post->ID,
'url' => get_permalink( $post->ID ),
@@ -1192,10 +1303,10 @@ EOT;
'origin' => $origin,
'position' => $position,
),
- 'title' => $this->_to_utf8( $this->get_title( $post->post_title, $post->post_content, $post->ID ) ),
+ 'title' => $this->to_utf8( $this->get_title( $post->post_title, $post->post_content, $post->ID ) ),
'date' => get_the_date( '', $post->ID ),
'format' => get_post_format( $post->ID ),
- 'excerpt' => html_entity_decode( $this->_to_utf8( $this->_get_excerpt( $post->post_excerpt, $post->post_content ) ), ENT_QUOTES, 'UTF-8' ),
+ 'excerpt' => html_entity_decode( $this->to_utf8( $this->get_excerpt( $post->post_excerpt, $post->post_content ) ), ENT_QUOTES, 'UTF-8' ),
/**
* Filters the rel attribute for the Related Posts' links.
*
@@ -1207,7 +1318,7 @@ EOT;
* @param string $link_rel Link rel attribute for Related Posts' link. Default is empty.
* @param int $post->ID Post ID.
*/
- 'rel' => apply_filters( 'jetpack_relatedposts_filter_post_link_rel', '', $post->ID ),
+ 'rel' => apply_filters( 'jetpack_relatedposts_filter_post_link_rel', '', $post->ID ),
/**
* Filter the context displayed below each Related Post.
*
@@ -1215,15 +1326,15 @@ EOT;
*
* @since 3.0.0
*
- * @param string $this->_to_utf8( $this->_generate_related_post_context( $post->ID ) ) Context displayed below each related post.
- * @param string $post_id Post ID of the post for which we are retrieving Related Posts.
+ * @param string $this->to_utf8( $this->generate_related_post_context( $post->ID ) ) Context displayed below each related post.
+ * @param int $post_id Post ID of the post for which we are retrieving Related Posts.
*/
- 'context' => apply_filters(
+ 'context' => apply_filters(
'jetpack_relatedposts_filter_post_context',
- $this->_to_utf8( $this->_generate_related_post_context( $post->ID ) ),
+ $this->to_utf8( $this->generate_related_post_context( $post->ID ) ),
$post->ID
),
- 'img' => $this->_generate_related_post_image_params( $post->ID ),
+ 'img' => $this->generate_related_post_image_params( $post->ID ),
/**
* Filter the post css classes added on HTML markup.
*
@@ -1234,7 +1345,7 @@ EOT;
* @param array array() CSS classes added on post HTML markup.
* @param string $post_id Post ID.
*/
- 'classes' => apply_filters(
+ 'classes' => apply_filters(
'jetpack_relatedposts_filter_post_css_classes',
array(),
$post->ID
@@ -1272,16 +1383,17 @@ EOT;
/**
* Returns a plain text post excerpt for title attribute of links.
*
- * @param string $post_excerpt
- * @param string $post_content
+ * @param string $post_excerpt - the post excerpt.
+ * @param string $post_content - the post content.
* @uses strip_shortcodes, wp_strip_all_tags, wp_trim_words
* @return string
*/
- protected function _get_excerpt( $post_excerpt, $post_content ) {
- if ( empty( $post_excerpt ) )
+ protected function get_excerpt( $post_excerpt, $post_content ) {
+ if ( empty( $post_excerpt ) ) {
$excerpt = $post_content;
- else
+ } else {
$excerpt = $post_excerpt;
+ }
return wp_trim_words( wp_strip_all_tags( strip_shortcodes( $excerpt ) ), 50, '…' );
}
@@ -1290,12 +1402,11 @@ EOT;
* Generates the thumbnail image to be used for the post. Uses the
* image as returned by Jetpack_PostImages::get_image()
*
- * @param int $post_id
+ * @param int $post_id - the post ID.
* @uses self::get_options, apply_filters, Jetpack_PostImages::get_image, Jetpack_PostImages::fit_image_url
* @return string
*/
- protected function _generate_related_post_image_params( $post_id ) {
- $options = $this->get_options();
+ protected function generate_related_post_image_params( $post_id ) {
$image_params = array(
'alt_text' => '',
'src' => '',
@@ -1314,16 +1425,19 @@ EOT;
*/
$thumbnail_size = apply_filters(
'jetpack_relatedposts_filter_thumbnail_size',
- array( 'width' => 350, 'height' => 200 )
+ array(
+ 'width' => 350,
+ 'height' => 200,
+ )
);
- if ( !is_array( $thumbnail_size ) ) {
+ if ( ! is_array( $thumbnail_size ) ) {
$thumbnail_size = array(
- 'width' => (int)$thumbnail_size,
- 'height' => (int)$thumbnail_size
+ 'width' => (int) $thumbnail_size,
+ 'height' => (int) $thumbnail_size,
);
}
- // Try to get post image
+ // Try to get post image.
if ( class_exists( 'Jetpack_PostImages' ) ) {
$img_url = '';
$post_image = Jetpack_PostImages::get_image(
@@ -1331,12 +1445,12 @@ EOT;
$thumbnail_size
);
- if ( is_array($post_image) ) {
+ if ( is_array( $post_image ) ) {
$img_url = $post_image['src'];
} elseif ( class_exists( 'Jetpack_Media_Summary' ) ) {
$media = Jetpack_Media_Summary::get( $post_id );
- if ( is_array($media) && !empty( $media['image'] ) ) {
+ if ( is_array( $media ) && ! empty( $media['image'] ) ) {
$img_url = $media['image'];
}
}
@@ -1363,12 +1477,12 @@ EOT;
/**
* Returns the string UTF-8 encoded
*
- * @param string $text
+ * @param string $text - the text we want to convert.
* @return string
*/
- protected function _to_utf8( $text ) {
- if ( $this->_convert_charset ) {
- return iconv( $this->_blog_charset, 'UTF-8', $text );
+ protected function to_utf8( $text ) {
+ if ( $this->convert_charset ) {
+ return iconv( $this->blog_charset, 'UTF-8', $text );
} else {
return $text;
}
@@ -1383,15 +1497,15 @@ EOT;
/**
* Workhorse method to return array of related posts matched by Elasticsearch.
*
- * @param int $post_id
- * @param int $size
- * @param array $filters
+ * @param int $post_id - the ID of the post.
+ * @param int $size - the size of the post.
+ * @param array $filters - filters.
* @uses wp_remote_post, is_wp_error, get_option, wp_remote_retrieve_body, get_post, add_query_arg, remove_query_arg, get_permalink, get_post_format, apply_filters
* @return array
*/
- protected function _get_related_posts( $post_id, $size, array $filters ) {
- $hits = $this->_filter_non_public_posts(
- $this->_get_related_post_ids(
+ protected function get_related_posts( $post_id, $size, array $filters ) {
+ $hits = $this->filter_non_public_posts(
+ $this->get_related_post_ids(
$post_id,
$size,
$filters
@@ -1420,68 +1534,70 @@ EOT;
/**
* Get array of related posts matched by Elasticsearch.
*
- * @param int $post_id
- * @param int $size
- * @param array $filters
+ * @param int $post_id - the post ID.
+ * @param int $size - the size.
+ * @param array $filters - some filters.
* @uses wp_remote_post, is_wp_error, wp_remote_retrieve_body, get_post_meta, update_post_meta
* @return array
*/
- protected function _get_related_post_ids( $post_id, $size, array $filters ) {
- $now_ts = time();
+ protected function get_related_post_ids( $post_id, $size, array $filters ) {
+ $now_ts = time();
$cache_meta_key = '_jetpack_related_posts_cache';
$body = array(
'size' => (int) $size,
);
- if ( !empty( $filters ) )
+ if ( ! empty( $filters ) ) {
$body['filter'] = array( 'and' => $filters );
+ }
- // Build cache key
- $cache_key = md5( serialize( $body ) );
+ // Build cache key.
+ $cache_key = md5( serialize( $body ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- this is used for caching.
- // Load all cached values
+ // Load all cached values.
if ( wp_using_ext_object_cache() ) {
$transient_name = "{$cache_meta_key}_{$cache_key}_{$post_id}";
- $cache = get_transient( $transient_name );
+ $cache = get_transient( $transient_name );
if ( false !== $cache ) {
return $cache;
}
} else {
$cache = get_post_meta( $post_id, $cache_meta_key, true );
- if ( empty( $cache ) )
+ if ( empty( $cache ) ) {
$cache = array();
-
+ }
// Cache is valid! Return cached value.
- if ( isset( $cache[ $cache_key ] ) && is_array( $cache[ $cache_key ] ) && $cache[ $cache_key ][ 'expires' ] > $now_ts ) {
- return $cache[ $cache_key ][ 'payload' ];
+ if ( isset( $cache[ $cache_key ] ) && is_array( $cache[ $cache_key ] ) && $cache[ $cache_key ]['expires'] > $now_ts ) {
+ return $cache[ $cache_key ]['payload'];
}
}
$response = wp_remote_post(
"https://public-api.wordpress.com/rest/v1/sites/{$this->get_blog_id()}/posts/$post_id/related/",
array(
- 'timeout' => 10,
+ 'timeout' => 10,
'user-agent' => 'jetpack_related_posts',
- 'sslverify' => true,
- 'body' => $body,
+ 'sslverify' => true,
+ 'body' => $body,
)
);
// Oh no... return nothing don't cache errors.
if ( is_wp_error( $response ) ) {
- if ( isset( $cache[ $cache_key ] ) && is_array( $cache[ $cache_key ] ) )
- return $cache[ $cache_key ][ 'payload' ]; // return stale
- else
+ if ( isset( $cache[ $cache_key ] ) && is_array( $cache[ $cache_key ] ) ) {
+ return $cache[ $cache_key ]['payload']; // return stale.
+ } else {
return array();
+ }
}
- $results = json_decode( wp_remote_retrieve_body( $response ), true );
+ $results = json_decode( wp_remote_retrieve_body( $response ), true );
$related_posts = array();
- if ( is_array( $results ) && !empty( $results['hits'] ) ) {
- foreach( $results['hits'] as $hit ) {
+ if ( is_array( $results ) && ! empty( $results['hits'] ) ) {
+ foreach ( $results['hits'] as $hit ) {
$related_posts[] = array(
'id' => $hit['fields']['post_id'],
);
@@ -1490,27 +1606,27 @@ EOT;
// An empty array might indicate no related posts or that posts
// are not yet synced to WordPress.com, so we cache for only 1
- // minute in this case
+ // minute in this case.
if ( empty( $related_posts ) ) {
$cache_ttl = 60;
} else {
$cache_ttl = 12 * HOUR_IN_SECONDS;
}
- // Update cache
+ // Update cache.
if ( wp_using_ext_object_cache() ) {
set_transient( $transient_name, $related_posts, $cache_ttl );
} else {
- // Copy all valid cache values
+ // Copy all valid cache values.
$new_cache = array();
foreach ( $cache as $k => $v ) {
- if ( is_array( $v ) && $v[ 'expires' ] > $now_ts ) {
+ if ( is_array( $v ) && $v['expires'] > $now_ts ) {
$new_cache[ $k ] = $v;
}
}
- // Set new cache value
- $cache_expires = $cache_ttl + $now_ts;
+ // Set new cache value.
+ $cache_expires = $cache_ttl + $now_ts;
$new_cache[ $cache_key ] = array(
'expires' => $cache_expires,
'payload' => $related_posts,
@@ -1524,16 +1640,16 @@ EOT;
/**
* Filter out any hits that are not public anymore.
*
- * @param array $related_posts
+ * @param array $related_posts - the related posts.
* @uses get_post_stati, get_post_status
* @return array
*/
- protected function _filter_non_public_posts( array $related_posts ) {
+ protected function filter_non_public_posts( array $related_posts ) {
$public_stati = get_post_stati( array( 'public' => true ) );
$filtered = array();
foreach ( $related_posts as $hit ) {
- if ( in_array( get_post_status( $hit['id'] ), $public_stati ) ) {
+ if ( in_array( get_post_status( $hit['id'] ), $public_stati, true ) ) {
$filtered[] = $hit;
}
}
@@ -1547,16 +1663,17 @@ EOT;
* - First post tag
* - Number of comments
*
- * @param int $post_id
+ * @param int $post_id - the post ID.
* @uses get_the_category, get_the_terms, get_comments_number, number_format_i18n, __, _n
* @return string
*/
- protected function _generate_related_post_context( $post_id ) {
+ protected function generate_related_post_context( $post_id ) {
$categories = get_the_category( $post_id );
if ( is_array( $categories ) ) {
foreach ( $categories as $category ) {
- if ( 'uncategorized' != $category->slug && '' != trim( $category->name ) ) {
+ if ( 'uncategorized' !== $category->slug && '' !== trim( $category->name ) ) {
$post_cat_context = sprintf(
+ // Translators: The category or tag name.
esc_html_x( 'In "%s"', 'in {category/tag name}', 'jetpack' ),
$category->name
);
@@ -1578,8 +1695,9 @@ EOT;
$tags = get_the_terms( $post_id, 'post_tag' );
if ( is_array( $tags ) ) {
foreach ( $tags as $tag ) {
- if ( '' != trim( $tag->name ) ) {
+ if ( '' !== trim( $tag->name ) ) {
$post_tag_context = sprintf(
+ // Translators: the category or tag name.
_x( 'In "%s"', 'in {category/tag name}', 'jetpack' ),
$tag->name
);
@@ -1601,7 +1719,8 @@ EOT;
$comment_count = get_comments_number( $post_id );
if ( $comment_count > 0 ) {
return sprintf(
- _n( 'With 1 comment', 'With %s comments', $comment_count, 'jetpack' ),
+ // Translators: amount of comments.
+ _n( 'With %s comment', 'With %s comments', $comment_count, 'jetpack' ),
number_format_i18n( $comment_count )
);
}
@@ -1612,9 +1731,11 @@ EOT;
/**
* Logs clicks for clickthrough analysis and related result tuning.
*
- * @return null
+ * @param int $post_id - the post ID.
+ * @param int $to_post_id - the to post ID.
+ * @param int $link_position - the link position.
*/
- protected function _log_click( $post_id, $to_post_id, $link_position ) {
+ protected function log_click( $post_id, $to_post_id, $link_position ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
}
@@ -1624,12 +1745,12 @@ EOT;
* @uses self::get_options, is_admin, is_single, apply_filters
* @return bool
*/
- protected function _enabled_for_request() {
+ protected function enabled_for_request() {
$enabled = is_single()
&& ! is_attachment()
&& ! is_admin()
&& ! is_embed()
- && ( ! $this->_allow_feature_toggle() || $this->get_option( 'enabled' ) );
+ && ( ! $this->allow_feature_toggle() || $this->get_option( 'enabled' ) );
/**
* Filter the Enabled value to allow related posts to be shown on pages as well.
@@ -1646,12 +1767,11 @@ EOT;
/**
* Adds filters.
*
- * @uses self::_enqueue_assets, self::_setup_shortcode, add_filter
- * @return null
+ * @uses self::enqueue_assets, self::setup_shortcode, add_filter
*/
- protected function _action_frontend_init_page() {
- $this->_enqueue_assets( true, true );
- $this->_setup_shortcode();
+ protected function action_frontend_init_page() {
+ $this->enqueue_assets( true, true );
+ $this->setup_shortcode();
add_filter( 'the_content', array( $this, 'filter_add_target_to_dom' ), 40 );
}
@@ -1672,10 +1792,12 @@ EOT;
/**
* Enqueues assets needed to do async loading of related posts.
*
+ * @param string $script - the script we're enqueing.
+ * @param string $style - the style we're enqueing.
+ *
* @uses wp_enqueue_script, wp_enqueue_style, plugins_url
- * @return null
*/
- protected function _enqueue_assets( $script, $style ) {
+ protected function enqueue_assets( $script, $style ) {
$dependencies = is_customize_preview() ? array( 'customize-base' ) : array();
// Do not enqueue scripts unless they are required.
if ( $script && $this->requires_scripts() ) {
@@ -1686,7 +1808,8 @@ EOT;
'modules/related-posts/related-posts.js'
),
$dependencies,
- self::VERSION
+ self::VERSION,
+ false
);
$related_posts_js_options = array(
/**
@@ -1700,31 +1823,36 @@ EOT;
);
wp_localize_script( 'jetpack_related-posts', 'related_posts_js_options', $related_posts_js_options );
}
- if ( $style ){
+ if ( $style ) {
wp_enqueue_style( 'jetpack_related-posts', plugins_url( 'related-posts.css', __FILE__ ), array(), self::VERSION );
wp_style_add_data( 'jetpack_related-posts', 'rtl', 'replace' );
add_action( 'amp_post_template_css', array( $this, 'render_amp_reader_mode_css' ) );
}
}
+ /**
+ * Render AMP's reader mode CSS.
+ */
public function render_amp_reader_mode_css() {
- echo file_get_contents( plugin_dir_path( __FILE__ ) . 'related-posts.css' );
+ echo file_get_contents( __DIR__ . '/related-posts.css' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- this is loading a CSS file.
}
/**
* Sets up the shortcode processing.
*
* @uses add_filter, add_shortcode
- * @return null
*/
- protected function _setup_shortcode() {
+ protected function setup_shortcode() {
add_filter( 'the_content', array( $this, 'test_for_shortcode' ), 0 );
add_shortcode( self::SHORTCODE, array( $this, 'get_client_rendered_html' ) );
}
- protected function _allow_feature_toggle() {
- if ( null === $this->_allow_feature_toggle ) {
+ /**
+ * Return status of related posts toggle.
+ */
+ protected function allow_feature_toggle() {
+ if ( null === $this->allow_feature_toggle ) {
/**
* Filter the display of the Related Posts toggle in Settings > Reading.
*
@@ -1732,11 +1860,11 @@ EOT;
*
* @since 2.8.0
*
- * @param bool false Display a feature toggle. Default to false.
+ * @param bool $allow_feature_toggle Display a feature toggle. Default to false.
*/
- $this->_allow_feature_toggle = apply_filters( 'jetpack_relatedposts_filter_allow_feature_toggle', false );
+ $this->allow_feature_toggle = apply_filters( 'jetpack_relatedposts_filter_allow_feature_toggle', false );
}
- return $this->_allow_feature_toggle;
+ return $this->allow_feature_toggle;
}
/**
@@ -1752,7 +1880,6 @@ EOT;
*
* @action rest_api_init
* @uses register_rest_field, self::rest_get_related_posts
- * @return null
*/
public function rest_register_related_posts() {
/** This filter is already documented in class.json-api-endpoints.php */
@@ -1777,42 +1904,57 @@ EOT;
* @since 4.4.0
*
* @param array $object Details of current post.
- * @param string $field_name Name of field.
- * @param WP_REST_Request $request Current request
*
* @uses self::get_for_post_id
*
* @return array
*/
- public function rest_get_related_posts( $object, $field_name, $request ) {
+ public function rest_get_related_posts( $object ) {
return $this->get_for_post_id( $object['id'], array( 'size' => 6 ) );
}
}
-class Jetpack_RelatedPosts_Raw extends Jetpack_RelatedPosts {
- protected $_query_name;
+/**
+ * The raw related posts class can be used by other plugins or themes
+ * to get related content. This class wraps the existing RelatedPosts
+ * logic thus we never want to add anything to the DOM or do anything
+ * for event hooks. We will also not present any settings for this
+ * class and keep it enabled as calls to this class are done
+ * programmatically.
+ */
+class Jetpack_RelatedPosts_Raw extends Jetpack_RelatedPosts { //phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace, Generic.Files.OneObjectStructurePerFile.MultipleFound
+
+ /**
+ * The query name we want to look up.
+ *
+ * @var string
+ */
+ protected $query_name;
/**
* Allows callers of this class to tag each query with a unique name for tracking purposes.
*
- * @param string $name
+ * @param string $name - the name of the query.
* @return Jetpack_RelatedPosts_Raw
*/
public function set_query_name( $name ) {
- $this->_query_name = (string) $name;
+ $this->query_name = (string) $name;
return $this;
}
/**
- * The raw related posts class can be used by other plugins or themes
- * to get related content. This class wraps the existing RelatedPosts
- * logic thus we never want to add anything to the DOM or do anything
- * for event hooks. We will also not present any settings for this
- * class and keep it enabled as calls to this class is done
- * programmatically.
+ * Initialize admin.
*/
public function action_admin_init() {}
+
+ /**
+ * Initialize front end.
+ */
public function action_frontend_init() {}
+
+ /**
+ * Get options.
+ */
public function get_options() {
return array(
'enabled' => true,
@@ -1822,15 +1964,15 @@ class Jetpack_RelatedPosts_Raw extends Jetpack_RelatedPosts {
/**
* Workhorse method to return array of related posts ids matched by Elasticsearch.
*
- * @param int $post_id
- * @param int $size
- * @param array $filters
+ * @param int $post_id - the post ID.
+ * @param int $size - size of the post.
+ * @param array $filters - filters we're using.
* @uses wp_remote_post, is_wp_error, wp_remote_retrieve_body
* @return array
*/
- protected function _get_related_posts( $post_id, $size, array $filters ) {
- $hits = $this->_filter_non_public_posts(
- $this->_get_related_post_ids(
+ protected function get_related_posts( $post_id, $size, array $filters ) {
+ $hits = $this->filter_non_public_posts(
+ $this->get_related_post_ids(
$post_id,
$size,
$filters
diff --git a/plugins/jetpack/modules/related-posts/related-posts-rtl.css b/plugins/jetpack/modules/related-posts/related-posts-rtl.css
index fa6c0309..61360683 100644
--- a/plugins/jetpack/modules/related-posts/related-posts-rtl.css
+++ b/plugins/jetpack/modules/related-posts/related-posts-rtl.css
@@ -1 +1 @@
-.jp-related-posts-i2__row{display:flex;margin-top:1.5rem}.jp-related-posts-i2__row:first-child{margin-top:0}.jp-related-posts-i2__post{flex-grow:1;flex-basis:0;margin:0 10px;display:flex;flex-direction:column;padding-right:0}.jp-related-posts-i2__row[data-post-count="3"] .jp-related-posts-i2__post{max-width:calc(33% - 20px)}.jp-related-posts-i2__row[data-post-count="1"] .jp-related-posts-i2__post,.jp-related-posts-i2__row[data-post-count="2"] .jp-related-posts-i2__post{max-width:calc(50% - 20px)}.jp-related-posts-i2__post-context,.jp-related-posts-i2__post-date,.jp-related-posts-i2__post-heading,.jp-related-posts-i2__post-img-link{flex-direction:row;display:block}.jp-related-posts-i2__post-heading{margin:.5rem 0;font-size:1rem;line-height:1.2em}.jp-related-posts-i2__post-link{display:block;width:100%;line-height:1.2em}.jp-related-posts-i2__post-img-link{order:-1}.jp-related-posts-i2__post-img-link img{width:100%}.jp-relatedposts-i2[data-layout=list] .jp-related-posts-i2__row{margin-top:0;display:block}.jp-relatedposts-i2[data-layout=list] .jp-related-posts-i2__post{max-width:none;margin:0}.jp-relatedposts-i2[data-layout=list].jp-related-posts-i2__post-img-link{margin-top:1rem}@media only screen and (max-width:640px){.jp-related-posts-i2__row{margin-top:0;display:block}.jp-related-posts-i2__row[data-post-count] .jp-related-posts-i2__post{max-width:none;margin:0;margin-top:1rem}.jp-related-posts-i2__post-img-link{margin-top:1rem}.jp-related-posts-i2__post-img-link img{width:350px}}#jp-relatedposts{display:none;padding-top:1em;margin:1em 0;position:relative;clear:both}.jp-relatedposts:after{content:'';display:block;clear:both}#jp-relatedposts h3.jp-relatedposts-headline{margin:0 0 1em 0;display:inline-block;float:right;font-size:9pt;font-weight:700;font-family:inherit}#jp-relatedposts h3.jp-relatedposts-headline em:before{content:"";display:block;width:100%;min-width:30px;border-top:1px solid #dcdcde;border-top:1px solid rgba(0,0,0,.2);margin-bottom:1em}#jp-relatedposts h3.jp-relatedposts-headline em{font-style:normal;font-weight:700}#jp-relatedposts .jp-relatedposts-items{clear:right}#jp-relatedposts .jp-relatedposts-items-visual{margin-left:-20px}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post{float:right;width:33%;margin:0 0 1em;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post{padding-left:20px;-moz-opacity:.8;opacity:.8}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:nth-child(3n+4),#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post:nth-child(3n+4){clear:both}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:hover .jp-relatedposts-post-title a{text-decoration:underline}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:hover{-moz-opacity:1;opacity:1}#jp-relatedposts .jp-relatedposts-items p,#jp-relatedposts .jp-relatedposts-items time,#jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title{font-size:14px;line-height:20px;margin:0}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs{position:relative}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs a.jp-relatedposts-post-aoverlay{position:absolute;top:0;bottom:0;right:0;left:0;display:block;border-bottom:0}#jp-relatedposts .jp-relatedposts-items p,#jp-relatedposts .jp-relatedposts-items time{margin-bottom:0}#jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title{text-transform:none;margin:0;font-family:inherit;display:block;max-width:100%}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-title a{font-size:inherit;font-weight:400;text-decoration:none;-moz-opacity:1;opacity:1}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-title a:hover{text-decoration:underline}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post img.jp-relatedposts-post-img,#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post span{display:block;max-width:90%;overflow:hidden;text-overflow:ellipsis}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post img.jp-relatedposts-post-img,#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post span{height:auto;max-width:100%}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-context,#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-date{opacity:.6}.jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-date{display:none}#jp-relatedposts .jp-relatedposts-items-visual div.jp-relatedposts-post-thumbs p.jp-relatedposts-post-excerpt{display:none}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs p.jp-relatedposts-post-excerpt{overflow:hidden}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs span{margin-bottom:1em}#jp-relatedposts .jp-relatedposts-list .jp-relatedposts-post{clear:both;width:100%}#jp-relatedposts .jp-relatedposts-list .jp-relatedposts-post img.jp-relatedposts-post-img{float:right;overflow:hidden;max-width:33%;margin-left:3%}#jp-relatedposts .jp-relatedposts-list h4.jp-relatedposts-post-title{display:inline-block;max-width:63%}@media only screen and (max-width:640px){#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post{width:50%}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:nth-child(3n){clear:right}#jp-relatedposts .jp-relatedposts-items-visual{margin-left:20px}}@media only screen and (max-width:320px){#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post{width:100%;clear:both;margin:0 0 1em}#jp-relatedposts .jp-relatedposts-list .jp-relatedposts-post img.jp-relatedposts-post-img,#jp-relatedposts .jp-relatedposts-list h4.jp-relatedposts-post-title{float:none;max-width:100%;margin-left:0}}@media print{.jp-relatedposts{display:none!important}} \ No newline at end of file
+.jp-related-posts-i2__row{display:flex;margin-top:1.5rem}.jp-related-posts-i2__row:first-child{margin-top:0}.jp-related-posts-i2__post{display:flex;flex-basis:0;flex-direction:column;flex-grow:1;margin:0 10px;padding-right:0}.jp-related-posts-i2__row[data-post-count="3"] .jp-related-posts-i2__post{max-width:calc(33% - 20px)}.jp-related-posts-i2__row[data-post-count="1"] .jp-related-posts-i2__post,.jp-related-posts-i2__row[data-post-count="2"] .jp-related-posts-i2__post{max-width:calc(50% - 20px)}.jp-related-posts-i2__post-context,.jp-related-posts-i2__post-date,.jp-related-posts-i2__post-heading,.jp-related-posts-i2__post-img-link{display:block;flex-direction:row}.jp-related-posts-i2__post-heading{font-size:1rem;line-height:1.2em;margin:.5rem 0}.jp-related-posts-i2__post-link{display:block;line-height:1.2em;width:100%}.jp-related-posts-i2__post-img-link{order:-1}.jp-related-posts-i2__post-img-link img{width:100%}.jp-relatedposts-i2[data-layout=list] .jp-related-posts-i2__row{display:block;margin-top:0}.jp-relatedposts-i2[data-layout=list] .jp-related-posts-i2__post{margin:0;max-width:none}.jp-relatedposts-i2[data-layout=list].jp-related-posts-i2__post-img-link{margin-top:1rem}@media only screen and (max-width:640px){.jp-related-posts-i2__row{display:block;margin-top:0}.jp-related-posts-i2__row[data-post-count] .jp-related-posts-i2__post{margin:1rem 0 0;max-width:none}.jp-related-posts-i2__post-img-link{margin-top:1rem}.jp-related-posts-i2__post-img-link img{width:350px}}#jp-relatedposts{clear:both;display:none;margin:1em 0;padding-top:1em;position:relative}.jp-relatedposts:after{clear:both;content:"";display:block}#jp-relatedposts h3.jp-relatedposts-headline{display:inline-block;float:right;font-family:inherit;font-size:9pt;font-weight:700;margin:0 0 1em}#jp-relatedposts h3.jp-relatedposts-headline em:before{border-top:1px solid #dcdcde;border-top:1px solid rgba(0,0,0,.2);content:"";display:block;margin-bottom:1em;min-width:30px;width:100%}#jp-relatedposts h3.jp-relatedposts-headline em{font-style:normal;font-weight:700}#jp-relatedposts .jp-relatedposts-items{clear:right}#jp-relatedposts .jp-relatedposts-items-visual{margin-left:-20px}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post{box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;float:right;margin:0 0 1em;width:33%}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post{filter:alpha(opacity=80);-moz-opacity:.8;opacity:.8;padding-left:20px}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:nth-child(3n+4),#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post:nth-child(3n+4){clear:both}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:hover .jp-relatedposts-post-title a{text-decoration:underline}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:hover{filter:alpha(opacity=100);-moz-opacity:1;opacity:1}#jp-relatedposts .jp-relatedposts-items p,#jp-relatedposts .jp-relatedposts-items time,#jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title{font-size:14px;line-height:20px;margin:0}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs{position:relative}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs a.jp-relatedposts-post-aoverlay{border-bottom:0;bottom:0;display:block;left:0;position:absolute;right:0;top:0}#jp-relatedposts .jp-relatedposts-items p,#jp-relatedposts .jp-relatedposts-items time{margin-bottom:0}#jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title{display:block;font-family:inherit;margin:0;max-width:100%;text-transform:none}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-title a{filter:alpha(opacity=100);font-size:inherit;font-weight:400;-moz-opacity:1;opacity:1;text-decoration:none}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-title a:hover{text-decoration:underline}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post img.jp-relatedposts-post-img,#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post span{display:block;max-width:90%;overflow:hidden;text-overflow:ellipsis}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post img.jp-relatedposts-post-img,#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post span{height:auto;max-width:100%}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-context,#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-date{opacity:.6}#jp-relatedposts .jp-relatedposts-items-visual div.jp-relatedposts-post-thumbs p.jp-relatedposts-post-excerpt,.jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-date{display:none}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs p.jp-relatedposts-post-excerpt{overflow:hidden}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs span{margin-bottom:1em}#jp-relatedposts .jp-relatedposts-list .jp-relatedposts-post{clear:both;width:100%}#jp-relatedposts .jp-relatedposts-list .jp-relatedposts-post img.jp-relatedposts-post-img{float:right;margin-left:3%;max-width:33%;overflow:hidden}#jp-relatedposts .jp-relatedposts-list h4.jp-relatedposts-post-title{display:inline-block;max-width:63%}@media only screen and (max-width:640px){#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post{width:50%}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:nth-child(3n){clear:right}#jp-relatedposts .jp-relatedposts-items-visual{margin-left:20px}}@media only screen and (max-width:320px){#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post{clear:both;margin:0 0 1em;width:100%}#jp-relatedposts .jp-relatedposts-list .jp-relatedposts-post img.jp-relatedposts-post-img,#jp-relatedposts .jp-relatedposts-list h4.jp-relatedposts-post-title{float:none;margin-left:0;max-width:100%}}@media print{.jp-relatedposts{display:none!important}} \ No newline at end of file
diff --git a/plugins/jetpack/modules/scan/class-admin-bar-notice.php b/plugins/jetpack/modules/scan/class-admin-bar-notice.php
index 76f3cdc0..25ada38e 100644
--- a/plugins/jetpack/modules/scan/class-admin-bar-notice.php
+++ b/plugins/jetpack/modules/scan/class-admin-bar-notice.php
@@ -94,7 +94,7 @@ class Admin_Bar_Notice {
public function enqueue_toolbar_script() {
$this->add_inline_styles();
- if ( ! is_null( $this->has_threats() ) ) {
+ if ( $this->has_threats() !== null ) {
return;
}
diff --git a/plugins/jetpack/modules/scan/class-admin-sidebar-link.php b/plugins/jetpack/modules/scan/class-admin-sidebar-link.php
index 78eee31c..a4f90958 100644
--- a/plugins/jetpack/modules/scan/class-admin-sidebar-link.php
+++ b/plugins/jetpack/modules/scan/class-admin-sidebar-link.php
@@ -93,6 +93,11 @@ class Admin_Sidebar_Link {
private function get_link_offset() {
global $submenu;
$offset = 0;
+
+ if ( ! array_key_exists( 'jetpack', $submenu ) ) {
+ return $offset;
+ }
+
foreach ( $submenu['jetpack'] as $link ) {
if ( 'jetpack_admin_page' !== $link[1] ) {
break;
@@ -193,5 +198,3 @@ class Admin_Sidebar_Link {
$this->schedule_refresh_checked = true;
}
}
-
-
diff --git a/plugins/jetpack/modules/scan/scan.php b/plugins/jetpack/modules/scan/scan.php
index 11bcc6da..15b9a927 100644
--- a/plugins/jetpack/modules/scan/scan.php
+++ b/plugins/jetpack/modules/scan/scan.php
@@ -8,8 +8,8 @@
namespace Automattic\Jetpack\Scan;
-require_once 'class-admin-bar-notice.php';
-require_once 'class-admin-sidebar-link.php';
+require_once __DIR__ . '/class-admin-bar-notice.php';
+require_once __DIR__ . '/class-admin-sidebar-link.php';
Admin_Bar_Notice::instance();
Admin_Sidebar_Link::instance();
diff --git a/plugins/jetpack/modules/search.php b/plugins/jetpack/modules/search.php
index c9029048..ef2d40b3 100644
--- a/plugins/jetpack/modules/search.php
+++ b/plugins/jetpack/modules/search.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Module Name: Search
* Module Description: Help visitors quickly find answers with highly relevant instant search results and powerful filtering.
@@ -14,9 +14,32 @@
* @package automattic/jetpack
*/
-// Include everything.
-require_once __DIR__ . '/search/class.jetpack-search.php';
-require_once __DIR__ . '/search/class-jetpack-search-customberg.php';
+use Automattic\Jetpack\Search\Classic_Search;
+use Automattic\Jetpack\Search\Helper as Search_Helper;
-Jetpack_Search::instance();
-Automattic\Jetpack\Search\Jetpack_Search_Customberg::instance();
+/**
+ * These are old legacy class names that were deprecated due to the move to packages.
+ *
+ * @todo Does this make more sense as a legacy dir in the search package?
+ */
+
+/**
+ * Jetpack Search deprecated class.
+ *
+ * @deprecated 10.6
+ */
+class Jetpack_Search {
+ /**
+ * Singleton
+ */
+ protected function __construct() {
+ }
+
+ /**
+ * Return the instance of the new class.
+ */
+ public static function instance() {
+ // Explicitly provide the blog ID, just in case.
+ return Classic_Search::instance( Search_Helper::get_wpcom_site_id() );
+ }
+}
diff --git a/plugins/jetpack/modules/search/class-jetpack-instant-search.php b/plugins/jetpack/modules/search/class-jetpack-instant-search.php
deleted file mode 100644
index afe391e9..00000000
--- a/plugins/jetpack/modules/search/class-jetpack-instant-search.php
+++ /dev/null
@@ -1,629 +0,0 @@
-<?php
-/**
- * Jetpack Search: Instant Front-End Search and Filtering
- *
- * @since 8.3.0
- * @package automattic/jetpack
- */
-
-use Automattic\Jetpack\Assets;
-use Automattic\Jetpack\Search\Helper;
-use Automattic\Jetpack\Search\Options;
-
-/**
- * Class to load Instant Search experience on the site.
- *
- * @since 8.3.0
- */
-class Jetpack_Instant_Search extends Jetpack_Search {
- /**
- * The name of instant search sidebar
- *
- * @since 9.8.0
- *
- * @var string
- */
- const JETPACK_INSTANT_SEARCH_SIDEBAR = 'jetpack-instant-search-sidebar';
-
- /**
- * Variable to save old sidebars_widgets value.
- *
- * The value is set when action `after_switch_theme` is applied and cleared on filter `pre_update_option_sidebars_widgets`.
- * The filters mentioned above run on /wp-admin/themes.php?activated=true, a request closely following switching theme.
- *
- * @since 9.8.0
- *
- * @var array
- */
- protected $old_sidebars_widgets;
-
- /**
- * Get singleton instance of Jetpack Instant Search.
- *
- * Instantiates and sets up a new instance if needed, or returns the singleton.
- *
- * @since 9.8.0
- *
- * @return Jetpack_Instant_Search The Jetpack_Instant_Search singleton.
- */
- public static function instance() {
- if ( ! isset( self::$instance ) ) {
- self::$instance = new static();
- self::$instance->setup();
- }
-
- return self::$instance;
- }
-
- /**
- * Loads the php for this version of search
- *
- * @since 8.3.0
- */
- public function load_php() {
- $this->base_load_php();
-
- new Automattic\Jetpack\Search\Settings();
-
- if ( class_exists( 'WP_Customize_Manager' ) ) {
- require_once __DIR__ . '/class-jetpack-search-customize.php';
- new Jetpack_Search_Customize();
- }
- }
-
- /**
- * Setup the various hooks needed for the plugin to take over search duties.
- *
- * @since 5.0.0
- */
- public function init_hooks() {
- if ( ! is_admin() ) {
- add_filter( 'posts_pre_query', array( $this, 'filter__posts_pre_query' ), 10, 2 );
- add_action( 'parse_query', array( $this, 'action__parse_query' ), 10, 1 );
-
- add_action( 'init', array( $this, 'set_filters_from_widgets' ) );
-
- add_action( 'wp_enqueue_scripts', array( $this, 'load_assets' ) );
- add_action( 'wp_footer', array( 'Automattic\Jetpack\Search\Helper', 'print_instant_search_sidebar' ) );
- add_filter( 'body_class', array( $this, 'add_body_class' ), 10 );
- } else {
- add_action( 'update_option', array( $this, 'track_widget_updates' ), 10, 3 );
- }
-
- /**
- * Note:
- * 1. The priority has to be lower than 10 to run before _wp_sidebars_changed.
- * Which migrates widgets from old theme to the new one.
- * 2. WP.com runs after_switch_theme hook from the frontend, so we'll need to hook it.
- * No matter it's admin or frontend.
- */
- add_action( 'after_switch_theme', array( $this, 'save_old_sidebars_widgets' ), 5, 0 );
- add_action( 'pre_update_option_sidebars_widgets', array( $this, 'remove_wp_migrated_widgets' ) );
-
- add_action( 'widgets_init', array( $this, 'register_jetpack_instant_sidebar' ) );
- add_action( 'jetpack_deactivate_module_search', array( $this, 'move_search_widgets_to_inactive' ) );
- }
-
- /**
- * Loads assets for Jetpack Instant Search Prototype featuring Search As You Type experience.
- */
- public function load_assets() {
- $this->load_assets_with_parameters( '', JETPACK__PLUGIN_FILE );
- }
-
- /**
- * Loads assets according to parameters provided.
- *
- * @param string $path_prefix - Prefix for assets' relative paths.
- * @param string $plugin_base_path - Base path for use in plugins_url.
- */
- public function load_assets_with_parameters( $path_prefix, $plugin_base_path ) {
- Assets::register_script(
- 'jetpack-instant-search',
- $path_prefix . '_inc/build/instant-search/jp-search-main.js',
- $plugin_base_path,
- array(
- 'in_footer' => true,
- 'textdomain' => 'jetpack',
- )
- );
- Assets::enqueue_script( 'jetpack-instant-search' );
- $this->load_and_initialize_tracks();
- $this->inject_javascript_options();
- }
-
- /**
- * Passes all options to the JS app.
- */
- protected function inject_javascript_options() {
- $options = Helper::generate_initial_javascript_state();
- // Use wp_add_inline_script instead of wp_localize_script, see https://core.trac.wordpress.org/ticket/25280.
- wp_add_inline_script( 'jetpack-instant-search', 'var JetpackInstantSearchOptions=JSON.parse(decodeURIComponent("' . rawurlencode( wp_json_encode( $options ) ) . '"));', 'before' );
- }
-
- /**
- * Registers a widget sidebar for Instant Search.
- */
- public function register_jetpack_instant_sidebar() {
- $args = array(
- 'name' => __( 'Jetpack Search Sidebar', 'jetpack' ),
- 'id' => 'jetpack-instant-search-sidebar',
- 'description' => __( 'Customize the sidebar inside the Jetpack Search overlay', 'jetpack' ),
- 'class' => '',
- 'before_widget' => '<div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2 class="widgettitle">',
- 'after_title' => '</h2>',
- );
- register_sidebar( $args );
- }
-
- /**
- * Loads scripts for Tracks analytics library
- */
- public function load_and_initialize_tracks() {
- wp_enqueue_script( 'jp-tracks', '//stats.wp.com/w.js', array(), gmdate( 'YW' ), true );
- }
-
- /**
- * Bypass the normal Search query since we will run it with instant search.
- *
- * @since 8.3.0
- *
- * @param array $posts Current array of posts (still pre-query).
- * @param WP_Query $query The WP_Query being filtered.
- *
- * @return array Array of matching posts.
- */
- public function filter__posts_pre_query( $posts, $query ) {
- if ( ! $this->should_handle_query( $query ) ) {
- // Intentionally not adding the 'jetpack_search_abort' action since this should fire for every request except for search.
- return $posts;
- }
-
- /**
- * Bypass the main query and return dummy data
- * WP Core doesn't call the set_found_posts and its filters when filtering
- * posts_pre_query like we do, so need to do these manually.
- */
- $query->found_posts = 1;
- $query->max_num_pages = 1;
-
- return array();
- }
-
- /**
- * Run the aggregations API query for any filtering
- *
- * @since 8.3.0
- */
- public function action__parse_query() {
- if ( ! empty( $this->search_result ) ) {
- return;
- }
-
- if ( is_admin() ) {
- return;
- }
-
- if ( empty( $this->aggregations ) ) {
- return;
- }
-
- $builder = new Automattic\Jetpack\Search\WPES\Query_Builder();
- $this->add_aggregations_to_es_query_builder( $this->aggregations, $builder );
- $this->search_result = $this->instant_api(
- array(
- 'aggregations' => $builder->build_aggregation(),
- 'size' => 0,
- 'from' => 0,
- )
- );
- }
-
- /**
- * Run an instant search on the WordPress.com public API.
- *
- * @since 8.3.0
- *
- * @param array $args Args conforming to the WP.com v1.3/sites/<blog_id>/search endpoint.
- *
- * @return object|WP_Error The response from the public API, or a WP_Error.
- */
- public function instant_api( array $args ) {
- global $wp_version;
- $start_time = microtime( true );
-
- // Cache locally to avoid remote request slowing the page.
- $transient_name = 'jetpack_instant_search_cache_' . md5( wp_json_encode( $args ) );
- $cache = get_transient( $transient_name );
- if ( false !== $cache ) {
- return $cache;
- }
-
- $service_url = add_query_arg(
- $args,
- sprintf(
- 'https://public-api.wordpress.com/rest/v1.3/sites/%d/search',
- $this->jetpack_blog_id
- )
- );
-
- $request_args = array(
- 'timeout' => 10,
- 'user-agent' => "WordPress/{$wp_version} | Jetpack/" . constant( 'JETPACK__VERSION' ),
- );
-
- $request = wp_remote_get( esc_url_raw( $service_url ), $request_args );
- $end_time = microtime( true );
-
- if ( is_wp_error( $request ) ) {
- return $request;
- }
-
- $response_code = wp_remote_retrieve_response_code( $request );
- $response = json_decode( wp_remote_retrieve_body( $request ), true );
-
- if ( ! $response_code || $response_code < 200 || $response_code >= 300 ) {
- /**
- * Fires after a search query request has failed
- *
- * @module search
- *
- * @since 5.6.0
- *
- * @param array Array containing the response code and response from the failed search query
- */
- do_action(
- 'failed_jetpack_search_query',
- array(
- 'response_code' => $response_code,
- 'json' => $response,
- )
- );
-
- return new WP_Error( 'invalid_search_api_response', 'Invalid response from API - ' . $response_code );
- }
-
- $took = is_array( $response ) && ! empty( $response['took'] )
- ? $response['took']
- : null;
-
- $query = array(
- 'args' => $args,
- 'response' => $response,
- 'response_code' => $response_code,
- 'elapsed_time' => ( $end_time - $start_time ) * 1000, // Convert from float seconds to ms.
- 'es_time' => $took,
- 'url' => $service_url,
- );
-
- /**
- * Fires after a search request has been performed.
- *
- * Includes the following info in the $query parameter:
- *
- * array args Array of Elasticsearch arguments for the search
- * array response Raw API response, JSON decoded
- * int response_code HTTP response code of the request
- * float elapsed_time Roundtrip time of the search request, in milliseconds
- * float es_time Amount of time Elasticsearch spent running the request, in milliseconds
- * string url API url that was queried
- *
- * @module search
- *
- * @since 5.0.0
- * @since 5.8.0 This action now fires on all queries instead of just successful queries.
- *
- * @param array $query Array of information about the query performed
- */
- do_action( 'did_jetpack_search_query', $query );
-
- // Update local cache.
- set_transient( $transient_name, $response, 1 * HOUR_IN_SECONDS );
-
- return $response;
- }
-
- /**
- * Get the raw Aggregation results from the Elasticsearch response.
- *
- * @since 8.4.0
- *
- * @return array Array of Aggregations performed on the search.
- */
- public function get_search_aggregations_results() {
- if ( empty( $this->search_result ) || is_wp_error( $this->search_result ) || ! isset( $this->search_result['aggregations'] ) ) {
- return array();
- }
-
- return $this->search_result['aggregations'];
- }
-
- /**
- * Automatically configure necessary settings for instant search
- *
- * @since 8.3.0
- */
- public function auto_config_search() {
- if ( ! current_user_can( 'edit_theme_options' ) ) {
- return;
- }
-
- // Set default result format to "expanded".
- update_option( Options::OPTION_PREFIX . 'result_format', Options::RESULT_FORMAT_EXPANDED );
-
- $this->auto_config_excluded_post_types();
- $this->auto_config_overlay_sidebar_widgets();
- $this->auto_config_woo_result_format();
- }
-
- /**
- * Automatically copy configured search widgets into the overlay sidebar
- *
- * @since 8.8.0
- */
- public function auto_config_overlay_sidebar_widgets() {
- global $wp_registered_sidebars;
- $sidebars = get_option( 'sidebars_widgets', array() );
- $slug = Helper::FILTER_WIDGET_BASE;
-
- if ( isset( $sidebars['jetpack-instant-search-sidebar'] ) ) {
- foreach ( (array) $sidebars['jetpack-instant-search-sidebar'] as $widget_id ) {
- if ( 0 === strpos( $widget_id, $slug ) ) {
- // Already configured.
- return;
- }
- }
- }
-
- $has_sidebar = isset( $wp_registered_sidebars['sidebar-1'] );
- $sidebar_id = false;
- $sidebar_searchbox_idx = false;
- if ( $has_sidebar ) {
- if ( empty( $sidebars['sidebar-1'] ) ) {
- // Adding to an empty sidebar is generally a bad idea.
- $has_sidebar = false;
- }
- foreach ( (array) $sidebars['sidebar-1'] as $idx => $widget_id ) {
- if ( 0 === strpos( $widget_id, 'search-' ) ) {
- $sidebar_searchbox_idx = $idx;
- }
- if ( 0 === strpos( $widget_id, $slug ) ) {
- $sidebar_id = (int) str_replace( Helper::FILTER_WIDGET_BASE . '-', '', $widget_id );
- break;
- }
- }
- }
-
- $next_id = 1;
- $widget_opt_name = Helper::get_widget_option_name();
- $widget_options = get_option( $widget_opt_name, array() );
- foreach ( $widget_options as $id => $w ) {
- if ( $id >= $next_id ) {
- $next_id = $id + 1;
- }
- }
-
- // Copy sidebar settings to overlay.
- if ( ( false !== $sidebar_id ) && isset( $widget_options[ $sidebar_id ] ) ) {
- $widget_options[ $next_id ] = $widget_options[ $sidebar_id ];
- update_option( $widget_opt_name, $widget_options );
-
- if ( ! isset( $sidebars['jetpack-instant-search-sidebar'] ) ) {
- $sidebars['jetpack-instant-search-sidebar'] = array();
- }
- array_unshift( $sidebars['jetpack-instant-search-sidebar'], Helper::build_widget_id( $next_id ) );
- update_option( 'sidebars_widgets', $sidebars );
-
- return;
- }
-
- // Configure overlay and sidebar (if it exists).
- $preconfig_opts = $this->get_preconfig_widget_options();
- if ( ! isset( $sidebars['jetpack-instant-search-sidebar'] ) ) {
- $sidebars['jetpack-instant-search-sidebar'] = array();
- }
- if ( $has_sidebar ) {
- $widget_options[ $next_id ] = $preconfig_opts;
- if ( false !== $sidebar_searchbox_idx ) {
- // Replace Core search box.
- $sidebars['sidebar-1'][ $sidebar_searchbox_idx ] = Helper::build_widget_id( $next_id );
- } else {
- // Add to top.
- array_unshift( $sidebars['sidebar-1'], Helper::build_widget_id( $next_id ) );
- }
- $next_id++;
- }
- $widget_options[ $next_id ] = $preconfig_opts;
- array_unshift( $sidebars['jetpack-instant-search-sidebar'], Helper::build_widget_id( $next_id ) );
-
- update_option( $widget_opt_name, $widget_options );
- update_option( 'sidebars_widgets', $sidebars );
- }
-
- /**
- * Autoconfig search by adding filter widgets
- *
- * @since 8.4.0
- *
- * @return array Array of config settings for search widget.
- */
- protected function get_preconfig_widget_options() {
- $settings = array(
- 'title' => '',
- 'filters' => array(),
- );
-
- $post_types = get_post_types(
- array(
- 'public' => true,
- '_builtin' => false,
- )
- );
-
- if ( ! empty( $post_types ) ) {
- $settings['filters'][] = array(
- 'name' => '',
- 'type' => 'post_type',
- 'count' => 5,
- );
- }
-
- // Grab a maximum of 3 taxonomies.
- $taxonomies = array_slice(
- get_taxonomies(
- array(
- 'public' => true,
- '_builtin' => false,
- )
- ),
- 0,
- 3
- );
-
- foreach ( $taxonomies as $t ) {
- $settings['filters'][] = array(
- 'name' => '',
- 'type' => 'taxonomy',
- 'taxonomy' => $t,
- 'count' => 5,
- );
- }
-
- $settings['filters'][] = array(
- 'name' => '',
- 'type' => 'taxonomy',
- 'taxonomy' => 'category',
- 'count' => 5,
- );
-
- $settings['filters'][] = array(
- 'name' => '',
- 'type' => 'taxonomy',
- 'taxonomy' => 'post_tag',
- 'count' => 5,
- );
-
- $settings['filters'][] = array(
- 'name' => '',
- 'type' => 'date_histogram',
- 'count' => 5,
- 'field' => 'post_date',
- 'interval' => 'year',
- );
-
- return $settings;
- }
-
- /**
- * Automatically configure post types to exclude from one of the search widgets
- *
- * @since 8.8.0
- */
- public function auto_config_excluded_post_types() {
- $post_types = get_post_types(
- array(
- 'exclude_from_search' => false,
- 'public' => true,
- )
- );
- $enabled_post_types = array();
- $widget_options = get_option( Helper::get_widget_option_name(), array() );
-
- // Prior to Jetpack 8.8, post types were enabled via Jetpack Search widgets rather than disabled via the Customizer.
- // To continue supporting post types set up in the old way, we iterate through each Jetpack Search
- // widget configuration and append each enabled post type to $enabled_post_types.
- foreach ( $widget_options as $widget_option ) {
- if ( isset( $widget_option['post_types'] ) && is_array( $widget_option['post_types'] ) ) {
- foreach ( $widget_option['post_types'] as $enabled_post_type ) {
- $enabled_post_types[ $enabled_post_type ] = $enabled_post_type;
- }
- }
- }
-
- if ( ! empty( $enabled_post_types ) ) {
- $post_types_to_disable = array_diff( $post_types, $enabled_post_types );
- update_option( Options::OPTION_PREFIX . 'excluded_post_types', join( ',', $post_types_to_disable ) );
- }
- }
-
- /**
- * Automatically set result format to 'product' if WooCommerce is installed
- *
- * @since 9.6.0
- */
- public function auto_config_woo_result_format() {
- if ( ! method_exists( 'Jetpack', 'get_active_plugins' ) ) {
- return false;
- }
-
- // Check if WooCommerce plugin is active (based on https://docs.woocommerce.com/document/create-a-plugin/).
- if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', Jetpack::get_active_plugins() ), true ) ) {
- return false;
- }
-
- update_option( Options::OPTION_PREFIX . 'result_format', Options::RESULT_FORMAT_PRODUCT );
- }
-
- /**
- * Save sidebars_widgets option before it's migrated by WordPress
- *
- * @since 9.8.0
- *
- * @param array $old_sidebars_widgets The sidebars_widgets option value to be saved.
- */
- public function save_old_sidebars_widgets( $old_sidebars_widgets = null ) {
- // The function should only run before _wp_sidebars_changed which migrates the sidebars.
- // So when _wp_sidebars_changed doesn't exist, we should skip the logic.
- if ( has_filter( 'after_switch_theme', '_wp_sidebars_changed' ) !== false ) {
- $this->old_sidebars_widgets = ! is_null( $old_sidebars_widgets ) ? $old_sidebars_widgets : wp_get_sidebars_widgets();
- }
- }
-
- /**
- * Clean WordPress auto-migrated sidebar widgets from instant search sidebar before saving option sidebars_widgets
- *
- * @since 9.8.0
- *
- * @param array $sidebars_widgets The sidebars_widgets option value to be filtered.
- * @return array The sidebars_widgets option value to be saved
- */
- public function remove_wp_migrated_widgets( $sidebars_widgets ) {
- // Hook the action only when it is a theme switch i.e. $this->old_sidebars_widgets is not empty.
- // Ensure that the hook only runs when necessary.
- if (
- empty( $this->old_sidebars_widgets )
- || ! is_array( $this->old_sidebars_widgets )
- || ! is_array( $sidebars_widgets )
- || ! array_key_exists( static::JETPACK_INSTANT_SEARCH_SIDEBAR, $sidebars_widgets )
- || ! array_key_exists( static::JETPACK_INSTANT_SEARCH_SIDEBAR, $this->old_sidebars_widgets )
- // If the new Jetpack sidebar already has fewer widgets, skip execution.
- // Uses less than comparison for defensive programming.
- || count( $sidebars_widgets[ static::JETPACK_INSTANT_SEARCH_SIDEBAR ] ) <= count( $this->old_sidebars_widgets[ static::JETPACK_INSTANT_SEARCH_SIDEBAR ] )
- ) {
- return $sidebars_widgets;
- }
-
- $lost_widgets = array_diff( $sidebars_widgets[ static::JETPACK_INSTANT_SEARCH_SIDEBAR ], $this->old_sidebars_widgets[ static::JETPACK_INSTANT_SEARCH_SIDEBAR ] );
- $sidebars_widgets['wp_inactive_widgets'] = array_merge( $lost_widgets, (array) $sidebars_widgets['wp_inactive_widgets'] );
- $sidebars_widgets[ static::JETPACK_INSTANT_SEARCH_SIDEBAR ] = $this->old_sidebars_widgets[ static::JETPACK_INSTANT_SEARCH_SIDEBAR ];
-
- // Reset $this->old_sidebars_widgets because we want to run the function only once after theme switch.
- $this->old_sidebars_widgets = null;
-
- return $sidebars_widgets;
- }
-
- /**
- * Add current theme name as a body class for easier override
- *
- * @param string[] $classes An array of body class names.
- *
- * @return string[] The array of classes after filtering
- */
- public function add_body_class( $classes ) {
- $classes[] = 'jps-theme-' . get_stylesheet();
- return $classes;
- }
-}
diff --git a/plugins/jetpack/modules/search/class-jetpack-search-customberg.php b/plugins/jetpack/modules/search/class-jetpack-search-customberg.php
deleted file mode 100644
index bdc54eaa..00000000
--- a/plugins/jetpack/modules/search/class-jetpack-search-customberg.php
+++ /dev/null
@@ -1,141 +0,0 @@
-<?php
-/**
- * A class that adds a search customization interface to wp-admin.
- *
- * @package automattic/jetpack
- */
-
-namespace Automattic\Jetpack\Search;
-
-use Automattic\Jetpack\Assets;
-use Automattic\Jetpack\Status;
-use Automattic\Jetpack\Tracking;
-use Jetpack;
-use Jetpack_Plan;
-
-/**
- * Responsible for adding a search customization interface to wp-admin.
- *
- * @package Automattic\Jetpack\Search
- */
-class Jetpack_Search_Customberg {
- /**
- * The singleton instance of this class.
- *
- * @var Jetpack_Search_Customberg
- */
- protected static $instance;
-
- /**
- * Get the singleton instance of the class.
- *
- * @return Jetpack_Search_Customberg
- */
- public static function instance() {
- if ( ! isset( self::$instance ) ) {
- self::$instance = new static();
- self::$instance->init_hooks();
- }
-
- return self::$instance;
- }
-
- /**
- * Adds action hooks.
- */
- public function init_hooks() {
- add_action( 'admin_menu', array( $this, 'add_wp_admin_page' ), 999 );
- }
-
- /**
- * Adds a wp-admin page without adding a sidebar submenu item.
- */
- public function add_wp_admin_page() {
- if ( ! $this->should_add_page() ) {
- return;
- }
-
- // Intentionally omits adding a submenu via the first null argument.
- $hook = add_submenu_page(
- null,
- __( 'Search Settings', 'jetpack' ),
- __( 'Search', 'jetpack' ),
- 'manage_options', // Must be an admin.
- 'jetpack-search-configure',
- array( $this, 'jetpack_search_admin_page' )
- );
-
- add_action( "admin_print_scripts-$hook", array( $this, 'load_assets' ) );
- add_action( 'admin_footer', array( 'Automattic\Jetpack\Search\Helper', 'print_instant_search_sidebar' ) );
- }
-
- /**
- * Prints the dashboard container.
- */
- public function jetpack_search_admin_page() {
- // TODO: Spin this function off into a static helper function in a helper class for code reuse.
- $static_url = apply_filters( 'jetpack_static_url', '//en.wordpress.com/i/loading/loading-64.gif' );
- ?>
- <div id="jp-search-configure" class="jp-search-configure-dashboard" style="height: calc(100vh - 100px);">
- <div class="hide-if-no-js" style="height: 100%;">
- <img class="jp-search-loader" width="32" height="32" alt="<?php esc_attr_e( 'Loading&hellip;', 'jetpack' ); ?>" src="<?php echo esc_url( $static_url ); ?>" style="
- position: absolute;
- left: 50%;
- top: 50%;
- "/>
- </div>
- <div class="hide-if-js"><?php esc_html_e( 'Your Search customization page requires JavaScript to function properly.', 'jetpack' ); ?></div>
- </div>
- <?php
- }
-
- /**
- * Loads assets for the customization experience.
- */
- public function load_assets() {
- $this->load_assets_with_parameters( '', JETPACK__PLUGIN_FILE );
- }
-
- /**
- * Loads script and style assets according to parameters provided.
- *
- * @param string $path_prefix - Path prefix for built assets.
- * @param string $plugin_base_path - Base path for plugin files.
- */
- public function load_assets_with_parameters( $path_prefix, $plugin_base_path ) {
- \Jetpack_Admin_Page::load_wrapper_styles();
- Tracking::register_tracks_functions_scripts( true );
-
- Assets::register_script(
- 'jp-search-configure',
- $path_prefix . '_inc/build/instant-search/jp-search-configure-main.js',
- $plugin_base_path,
- array(
- 'in_footer' => true,
- 'textdomain' => 'jetpack',
- )
- );
- Assets::enqueue_script( 'jp-search-configure' );
-
- // Use wp_add_inline_script instead of wp_localize_script, see https://core.trac.wordpress.org/ticket/25280.
- wp_add_inline_script( 'jp-search-configure', 'var JetpackInstantSearchOptions=JSON.parse(decodeURIComponent("' . rawurlencode( wp_json_encode( Helper::generate_initial_javascript_state() ) ) . '"));', 'before' );
- wp_add_inline_script(
- 'jp-search-configure',
- "window.jetpackSearchConfigureInit( 'jp-search-configure' )"
- );
- }
-
- /**
- * Determine if the requisite page should be added to wp-admin.
- *
- * @return boolean
- */
- protected function should_add_page() {
- $is_offline_mode = ( new Status() )->is_offline_mode();
- return (
- ! $is_offline_mode && // Must be online.
- Jetpack::is_connection_ready() && // Must be connected.
- method_exists( 'Jetpack_Plan', 'supports' ) && Jetpack_Plan::supports( 'search' ) // Must have plan supporting Jetpack (Instant) Search.
- );
- }
-}
diff --git a/plugins/jetpack/modules/search/class-jetpack-search-customize.php b/plugins/jetpack/modules/search/class-jetpack-search-customize.php
deleted file mode 100644
index a337e2c2..00000000
--- a/plugins/jetpack/modules/search/class-jetpack-search-customize.php
+++ /dev/null
@@ -1,283 +0,0 @@
-<?php
-/**
- * Jetpack Search Overlay Customization
- *
- * @package automattic/jetpack
- */
-
-use Automattic\Jetpack\Search\Options;
-
-// Exit if file is accessed directly.
-if ( ! defined( 'ABSPATH' ) ) {
- exit;
-}
-
-/**
- * Class to customize search on the site.
- *
- * @since 8.3.0
- */
-class Jetpack_Search_Customize {
-
- /**
- * Class initialization.
- *
- * @since 8.3.0
- */
- public function __construct() {
- add_action( 'customize_register', array( $this, 'customize_register' ) );
- add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_controls_enqueue_scripts' ) );
- }
-
- /**
- * Initialize Customizer controls.
- *
- * @since 8.3.0
- *
- * @param WP_Customize_Manager $wp_customize Customizer instance.
- */
- public function customize_register( $wp_customize ) {
- require_once dirname( JETPACK__PLUGIN_FILE ) . '/modules/search/customize-controls/class-label-control.php';
- require_once dirname( JETPACK__PLUGIN_FILE ) . '/modules/search/customize-controls/class-excluded-post-types-control.php';
- $section_id = 'jetpack_search';
- $setting_prefix = Options::OPTION_PREFIX;
-
- $wp_customize->add_section(
- $section_id,
- array(
- 'title' => esc_html__( 'Jetpack Search', 'jetpack' ),
- 'capability' => 'edit_theme_options',
- 'priority' => 200,
- )
- );
-
- $id = $setting_prefix . 'color_theme';
- $wp_customize->add_setting(
- $id,
- array(
- 'default' => 'light',
- 'transport' => 'postMessage',
- 'type' => 'option',
- )
- );
- $wp_customize->add_control(
- $id,
- array(
- 'label' => __( 'Theme', 'jetpack' ),
- 'description' => __( 'Select a theme for your search overlay.', 'jetpack' ),
- 'section' => $section_id,
- 'type' => 'radio',
- 'choices' => array(
- 'light' => __( 'Light', 'jetpack' ),
- 'dark' => __( 'Dark', 'jetpack' ),
- ),
- )
- );
-
- $id = $setting_prefix . 'result_format';
- $wp_customize->add_setting(
- $id,
- array(
- 'default' => 'minimal',
- 'transport' => 'postMessage',
- 'type' => 'option',
- )
- );
- $wp_customize->add_control(
- $id,
- array(
- 'label' => __( 'Result Format', 'jetpack' ),
- 'description' => __( 'Choose how the search results look.', 'jetpack' ),
- 'section' => $section_id,
- 'type' => 'select',
- 'choices' => array(
- 'minimal' => __( 'Minimal', 'jetpack' ),
- 'expanded' => __( 'Expanded (shows images)', 'jetpack' ),
- 'product' => __( 'Product (for WooCommerce stores)', 'jetpack' ),
- ),
- )
- );
-
- $id = $setting_prefix . 'default_sort';
- $wp_customize->add_setting(
- $id,
- array(
- 'default' => 'relevance',
- 'type' => 'option',
- )
- );
- $wp_customize->add_control(
- $id,
- array(
- 'choices' => array(
- 'relevance' => __( 'Relevance (recommended)', 'jetpack' ),
- 'newest' => __( 'Newest first', 'jetpack' ),
- 'oldest' => __( 'Oldest first', 'jetpack' ),
- ),
- 'description' => __( 'Pick the initial sort for your search results.', 'jetpack' ),
- 'label' => __( 'Default Sort', 'jetpack' ),
- 'section' => $section_id,
- 'type' => 'select',
- )
- );
-
- $id = $setting_prefix . 'overlay_trigger';
- $wp_customize->add_setting(
- $id,
- array(
- 'default' => Options::OVERLAY_TRIGGER_IMMEDIATE,
- 'transport' => 'postMessage',
- 'type' => 'option',
- )
- );
- $wp_customize->add_control(
- $id,
- array(
- 'label' => __( 'Search Input Overlay Trigger', 'jetpack' ),
- 'description' => __( 'Select when your overlay should appear.', 'jetpack' ),
- 'section' => $section_id,
- 'type' => 'select',
- 'choices' => array(
- Options::OVERLAY_TRIGGER_IMMEDIATE => __( 'Open when user starts typing', 'jetpack' ),
- Options::OVERLAY_TRIGGER_RESULTS => __( 'Open when results are available', 'jetpack' ),
- Options::OVERLAY_TRIGGER_SUBMIT => __( 'Open when user submits the form', 'jetpack' ),
- ),
- )
- );
-
- $id = $setting_prefix . 'excluded_post_types';
- $wp_customize->add_setting(
- $id,
- array(
- 'default' => '',
- 'type' => 'option',
- )
- );
- $wp_customize->add_control(
- new Excluded_Post_Types_Control(
- $wp_customize,
- $id,
- array(
- 'description' => __( 'Choose post types to exclude from search results. You must leave at least one post type unchecked.', 'jetpack' ),
- 'label' => __( 'Excluded Post Types', 'jetpack' ),
- 'section' => $section_id,
- )
- )
- );
-
- $id = $setting_prefix . 'highlight_color';
- $wp_customize->add_setting(
- $id,
- array(
- 'default' => '#FFC',
- 'transport' => 'postMessage',
- 'type' => 'option',
- )
- );
- $wp_customize->add_control(
- new WP_Customize_Color_Control(
- $wp_customize,
- $id,
- array(
- 'label' => __( 'Highlight Search Terms', 'jetpack' ),
- 'description' => __( 'Choose a color to highlight matching search terms.', 'jetpack' ),
- 'section' => $section_id,
- )
- )
- );
-
- $id = $setting_prefix . 'additional_settings_placeholder';
- $wp_customize->add_setting(
- $id,
- array( 'type' => 'option' )
- );
- $wp_customize->add_control(
- new Label_Control(
- $wp_customize,
- $id,
- array(
- 'label' => __( 'Additional Jetpack Search Settings', 'jetpack' ),
- 'section' => $section_id,
- )
- )
- );
-
- $id = $setting_prefix . 'enable_sort';
- $wp_customize->add_setting(
- $id,
- array(
- 'default' => '1',
- 'sanitize_callback' => array( 'Automattic\Jetpack\Search\Helper', 'sanitize_checkbox_value' ),
- 'sanitize_js_callback' => array( 'Automattic\Jetpack\Search\Helper', 'sanitize_checkbox_value_for_js' ),
- 'transport' => 'postMessage',
- 'type' => 'option',
- )
- );
- $wp_customize->add_control(
- $id,
- array(
- 'label' => __( 'Show sort selector', 'jetpack' ),
- 'section' => $section_id,
- 'type' => 'checkbox',
- )
- );
-
- $id = $setting_prefix . 'inf_scroll';
- $wp_customize->add_setting(
- $id,
- array(
- 'default' => '1',
- 'sanitize_callback' => array( 'Automattic\Jetpack\Search\Helper', 'sanitize_checkbox_value' ),
- 'sanitize_js_callback' => array( 'Automattic\Jetpack\Search\Helper', 'sanitize_checkbox_value_for_js' ),
- 'transport' => 'postMessage',
- 'type' => 'option',
- )
- );
- $wp_customize->add_control(
- $id,
- array(
- 'type' => 'checkbox',
- 'section' => $section_id,
- 'label' => __( 'Enable infinite scrolling', 'jetpack' ),
- )
- );
-
- $id = $setting_prefix . 'show_powered_by';
- $wp_customize->add_setting(
- $id,
- array(
- 'default' => '1',
- 'sanitize_callback' => array( 'Automattic\Jetpack\Search\Helper', 'sanitize_checkbox_value' ),
- 'sanitize_js_callback' => array( 'Automattic\Jetpack\Search\Helper', 'sanitize_checkbox_value_for_js' ),
- 'transport' => 'postMessage',
- 'type' => 'option',
- )
- );
- $wp_customize->add_control(
- $id,
- array(
- 'type' => 'checkbox',
- 'section' => $section_id,
- 'label' => __( 'Display "Powered by Jetpack"', 'jetpack' ),
- )
- );
- }
-
- /**
- * Enqueue assets for Customizer controls.
- *
- * @since 9.6.0
- */
- public function customize_controls_enqueue_scripts() {
- $script_relative_path = 'modules/search/customize-controls/customize-controls.js';
- $script_version = Automattic\Jetpack\Search\Helper::get_asset_version( $script_relative_path );
- $script_path = plugins_url( $script_relative_path, JETPACK__PLUGIN_FILE );
- wp_enqueue_script(
- 'jetpack-instant-search-customizer',
- $script_path,
- array( 'customize-controls' ),
- $script_version,
- true
- );
- }
-}
diff --git a/plugins/jetpack/modules/search/class.jetpack-search-helpers.php b/plugins/jetpack/modules/search/class.jetpack-search-helpers.php
deleted file mode 100644
index 39a89c53..00000000
--- a/plugins/jetpack/modules/search/class.jetpack-search-helpers.php
+++ /dev/null
@@ -1,701 +0,0 @@
-<?php
-/**
- * Jetpack Search: Jetpack_Search_Helpers class
- *
- * @package Jetpack
- * @subpackage Jetpack Search
- * @since 5.8.0
- */
-
-use Automattic\Jetpack\Constants;
-
-/**
- * Various helper functions for reuse throughout the Jetpack Search code.
- *
- * @since 5.8.0
- */
-class Jetpack_Search_Helpers {
-
- /**
- * The search widget's base ID.
- *
- * @since 5.8.0
- * @var string
- */
- const FILTER_WIDGET_BASE = 'jetpack-search-filters';
-
- /**
- * Create a URL for the current search that doesn't include the "paged" parameter.
- *
- * @since 5.8.0
- *
- * @return string The search URL.
- */
- static function get_search_url() {
- $query_args = stripslashes_deep( $_GET );
-
- // Handle the case where a permastruct is being used, such as /search/{$query}
- if ( ! isset( $query_args['s'] ) ) {
- $query_args['s'] = get_search_query();
- }
-
- if ( isset( $query_args['paged'] ) ) {
- unset( $query_args['paged'] );
- }
-
- $query = http_build_query( $query_args );
-
- return home_url( "?{$query}" );
- }
-
- /**
- * Wraps add_query_arg() with the URL defaulting to the current search URL.
- *
- * @see add_query_arg()
- *
- * @since 5.8.0
- *
- * @param string|array $key Either a query variable key, or an associative array of query variables.
- * @param string $value Optional. A query variable value.
- * @param bool|string $url Optional. A URL to act upon. Defaults to the current search URL.
- *
- * @return string New URL query string (unescaped).
- */
- static function add_query_arg( $key, $value = false, $url = false ) {
- $url = empty( $url ) ? self::get_search_url() : $url;
- if ( is_array( $key ) ) {
- return add_query_arg( $key, $url );
- }
-
- return add_query_arg( $key, $value, $url );
- }
-
- /**
- * Wraps remove_query_arg() with the URL defaulting to the current search URL.
- *
- * @see remove_query_arg()
- *
- * @since 5.8.0
- *
- * @param string|array $key Query key or keys to remove.
- * @param bool|string $query Optional. A URL to act upon. Defaults to the current search URL.
- *
- * @return string New URL query string (unescaped).
- */
- static function remove_query_arg( $key, $url = false ) {
- $url = empty( $url ) ? self::get_search_url() : $url;
-
- return remove_query_arg( $key, $url );
- }
-
- /**
- * Returns the name of the search widget's option.
- *
- * @since 5.8.0
- *
- * @return string The search widget option name.
- */
- static function get_widget_option_name() {
- return sprintf( 'widget_%s', self::FILTER_WIDGET_BASE );
- }
-
- /**
- * Returns the search widget instances from the widget's option.
- *
- * @since 5.8.0
- *
- * @return array The widget options.
- */
- static function get_widgets_from_option() {
- $widget_options = get_option( self::get_widget_option_name(), array() );
-
- // We don't need this
- if ( ! empty( $widget_options ) && isset( $widget_options['_multiwidget'] ) ) {
- unset( $widget_options['_multiwidget'] );
- }
-
- return $widget_options;
- }
-
- /**
- * Returns the widget ID (widget base plus the numeric ID).
- *
- * @param int $number The widget's numeric ID.
- *
- * @return string The widget's numeric ID prefixed with the search widget base.
- */
- static function build_widget_id( $number ) {
- return sprintf( '%s-%d', self::FILTER_WIDGET_BASE, $number );
- }
-
- /**
- * Wrapper for is_active_widget() with the other parameters automatically supplied.
- *
- * @see is_active_widget()
- *
- * @since 5.8.0
- *
- * @param int $widget_id Widget ID.
- *
- * @return bool Whether the widget is active or not.
- */
- static function is_active_widget( $widget_id ) {
- return (bool) is_active_widget( false, $widget_id, self::FILTER_WIDGET_BASE, true );
- }
-
- /**
- * Returns an array of the filters from all active search widgets.
- *
- * @since 5.8.0
- *
- * @return array Active filters.
- */
- static function get_filters_from_widgets() {
- $filters = array();
-
- $widget_options = self::get_widgets_from_option();
- if ( empty( $widget_options ) ) {
- return $filters;
- }
-
- foreach ( (array) $widget_options as $number => $settings ) {
- $widget_id = self::build_widget_id( $number );
- if ( ! self::is_active_widget( $widget_id ) || empty( $settings['filters'] ) ) {
- continue;
- }
-
- foreach ( (array) $settings['filters'] as $widget_filter ) {
- $widget_filter['widget_id'] = $widget_id;
-
- if ( empty( $widget_filter['name'] ) ) {
- $widget_filter['name'] = self::generate_widget_filter_name( $widget_filter );
- }
-
- $key = sprintf( '%s_%d', $widget_filter['type'], count( $filters ) );
-
- $filters[ $key ] = $widget_filter;
- }
- }
-
- return $filters;
- }
-
- /**
- * Get the localized default label for a date filter.
- *
- * @since 5.8.0
- *
- * @param string $type Date type, either year or month.
- * @param bool $is_updated Whether the filter was updated or not (adds "Updated" to the end).
- *
- * @return string The filter label.
- */
- static function get_date_filter_type_name( $type, $is_updated = false ) {
- switch ( $type ) {
- case 'year':
- $string = ( $is_updated )
- ? esc_html_x( 'Year Updated', 'label for filtering posts', 'jetpack' )
- : esc_html_x( 'Year', 'label for filtering posts', 'jetpack' );
- break;
- case 'month':
- default:
- $string = ( $is_updated )
- ? esc_html_x( 'Month Updated', 'label for filtering posts', 'jetpack' )
- : esc_html_x( 'Month', 'label for filtering posts', 'jetpack' );
- break;
- }
-
- return $string;
- }
-
- /**
- * Creates a default name for a filter. Used when the filter label is blank.
- *
- * @since 5.8.0
- *
- * @param array $widget_filter The filter to generate the title for.
- *
- * @return string The suggested filter name.
- */
- static function generate_widget_filter_name( $widget_filter ) {
- $name = '';
-
- switch ( $widget_filter['type'] ) {
- case 'post_type':
- $name = _x( 'Post Types', 'label for filtering posts', 'jetpack' );
- break;
-
- case 'date_histogram':
- $modified_fields = array(
- 'post_modified',
- 'post_modified_gmt',
- );
- switch ( $widget_filter['interval'] ) {
- case 'year':
- $name = self::get_date_filter_type_name(
- 'year',
- in_array( $widget_filter['field'], $modified_fields )
- );
- break;
- case 'month':
- default:
- $name = self::get_date_filter_type_name(
- 'month',
- in_array( $widget_filter['field'], $modified_fields )
- );
- break;
- }
- break;
-
- case 'taxonomy':
- $tax = get_taxonomy( $widget_filter['taxonomy'] );
- if ( ! $tax ) {
- break;
- }
-
- if ( isset( $tax->label ) ) {
- $name = $tax->label;
- } elseif ( isset( $tax->labels ) && isset( $tax->labels->name ) ) {
- $name = $tax->labels->name;
- }
- break;
- }
-
- return $name;
- }
-
- /**
- * Whether we should rerun a search in the customizer preview or not.
- *
- * @since 5.8.0
- *
- * @return bool
- */
- static function should_rerun_search_in_customizer_preview() {
- // Only update when in a customizer preview and data is being posted.
- // Check for $_POST removes an extra update when the customizer loads.
- //
- // Note: We use $GLOBALS['wp_customize'] here instead of is_customize_preview() to support unit tests.
- if ( ! isset( $GLOBALS['wp_customize'] ) || ! $GLOBALS['wp_customize']->is_preview() || empty( $_POST ) ) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Since PHP's built-in array_diff() works by comparing the values that are in array 1 to the other arrays,
- * if there are less values in array 1, it's possible to get an empty diff where one might be expected.
- *
- * @since 5.8.0
- *
- * @param array $array_1
- * @param array $array_2
- *
- * @return array
- */
- static function array_diff( $array_1, $array_2 ) {
- // If the array counts are the same, then the order doesn't matter. If the count of
- // $array_1 is higher than $array_2, that's also fine. If the count of $array_2 is higher,
- // we need to swap the array order though.
- if ( count( $array_1 ) !== count( $array_2 ) && count( $array_2 ) > count( $array_1 ) ) {
- $temp = $array_1;
- $array_1 = $array_2;
- $array_2 = $temp;
- }
-
- // Disregard keys
- return array_values( array_diff( $array_1, $array_2 ) );
- }
-
- /**
- * Given the widget instance, will return true when selected post types differ from searchable post types.
- *
- * @since 5.8.0
- *
- * @param array $post_types An array of post types.
- *
- * @return bool
- */
- static function post_types_differ_searchable( $post_types ) {
- if ( empty( $post_types ) ) {
- return false;
- }
-
- $searchable_post_types = get_post_types( array( 'exclude_from_search' => false ) );
- $diff_of_searchable = self::array_diff( $searchable_post_types, (array) $post_types );
-
- return ! empty( $diff_of_searchable );
- }
-
- /**
- * Given the array of post types, will return true when these differ from the current search query.
- *
- * @since 5.8.0
- *
- * @param array $post_types An array of post types.
- *
- * @return bool
- */
- static function post_types_differ_query( $post_types ) {
- if ( empty( $post_types ) ) {
- return false;
- }
-
- if ( empty( $_GET['post_type'] ) ) {
- $post_types_from_query = array();
- } elseif ( is_array( $_GET['post_type'] ) ) {
- $post_types_from_query = $_GET['post_type'];
- } else {
- $post_types_from_query = (array) explode( ',', $_GET['post_type'] );
- }
-
- $post_types_from_query = array_map( 'trim', $post_types_from_query );
-
- $diff_query = self::array_diff( (array) $post_types, $post_types_from_query );
-
- return ! empty( $diff_query );
- }
-
- /**
- * Determine what Tracks value should be used when updating a widget.
- *
- * @since 5.8.0
- *
- * @param mixed $old_value The old option value.
- * @param mixed $new_value The new option value.
- *
- * @return array|false False if the widget wasn't updated, otherwise an array of the Tracks action and widget properties.
- */
- static function get_widget_tracks_value( $old_value, $new_value ) {
- $old_value = (array) $old_value;
- if ( isset( $old_value['_multiwidget'] ) ) {
- unset( $old_value['_multiwidget'] );
- }
-
- $new_value = (array) $new_value;
- if ( isset( $new_value['_multiwidget'] ) ) {
- unset( $new_value['_multiwidget'] );
- }
-
- $old_keys = array_keys( $old_value );
- $new_keys = array_keys( $new_value );
-
- if ( count( $new_keys ) > count( $old_keys ) ) { // This is the case for a widget being added
- $diff = self::array_diff( $new_keys, $old_keys );
- $action = 'widget_added';
- $widget = empty( $diff ) || ! isset( $new_value[ $diff[0] ] )
- ? false
- : $new_value[ $diff[0] ];
- } elseif ( count( $old_keys ) > count( $new_keys ) ) { // This is the case for a widget being deleted
- $diff = self::array_diff( $old_keys, $new_keys );
- $action = 'widget_deleted';
- $widget = empty( $diff ) || ! isset( $old_value[ $diff[0] ] )
- ? false
- : $old_value[ $diff[0] ];
- } else {
- $action = 'widget_updated';
- $widget = false;
-
- // This is a bit crazy. Since there can be multiple widgets stored in a single option,
- // we need to diff the old and new values to figure out which widget was updated.
- foreach ( $new_value as $key => $new_instance ) {
- if ( ! isset( $old_value[ $key ] ) ) {
- continue;
- }
- $old_instance = $old_value[ $key ];
-
- // First, let's test the keys of each instance
- $diff = self::array_diff( array_keys( $new_instance ), array_keys( $old_instance ) );
- if ( ! empty( $diff ) ) {
- $widget = $new_instance;
- break;
- }
-
- // Next, lets's loop over each value and compare it
- foreach ( $new_instance as $k => $v ) {
- if ( is_scalar( $v ) && (string) $v !== (string) $old_instance[ $k ] ) {
- $widget = $new_instance;
- break;
- }
-
- if ( 'filters' == $k ) {
- if ( count( $new_instance['filters'] ) != count( $old_instance['filters'] ) ) {
- $widget = $new_instance;
- break;
- }
-
- foreach ( $v as $filter_key => $new_filter_value ) {
- $diff = self::array_diff( $new_filter_value, $old_instance['filters'][ $filter_key ] );
- if ( ! empty( $diff ) ) {
- $widget = $new_instance;
- break;
- }
- }
- }
- }
- }
- }
-
- if ( empty( $action ) || empty( $widget ) ) {
- return false;
- }
-
- return array(
- 'action' => $action,
- 'widget' => self::get_widget_properties_for_tracks( $widget ),
- );
- }
-
- /**
- * Creates the widget properties for sending to Tracks.
- *
- * @since 5.8.0
- *
- * @param array $widget The widget instance.
- *
- * @return array The widget properties.
- */
- static function get_widget_properties_for_tracks( $widget ) {
- $sanitized = array();
-
- foreach ( (array) $widget as $key => $value ) {
- if ( '_multiwidget' == $key ) {
- continue;
- }
-
- if ( is_scalar( $value ) ) {
- $key = str_replace( '-', '_', sanitize_key( $key ) );
- $key = "widget_{$key}";
- $sanitized[ $key ] = $value;
- }
- }
-
- $filters_properties = ! empty( $widget['filters'] )
- ? self::get_filter_properties_for_tracks( $widget['filters'] )
- : array();
-
- return array_merge( $sanitized, $filters_properties );
- }
-
- /**
- * Creates the filter properties for sending to Tracks.
- *
- * @since 5.8.0
- *
- * @param array $filters An array of filters.
- *
- * @return array The filter properties.
- */
- static function get_filter_properties_for_tracks( $filters ) {
- if ( empty( $filters ) ) {
- return $filters;
- }
-
- $filters_properties = array(
- 'widget_filter_count' => count( $filters ),
- );
-
- foreach ( $filters as $filter ) {
- if ( empty( $filter['type'] ) ) {
- continue;
- }
-
- $key = sprintf( 'widget_filter_type_%s', $filter['type'] );
- if ( isset( $filters_properties[ $key ] ) ) {
- $filters_properties[ $key ] ++;
- } else {
- $filters_properties[ $key ] = 1;
- }
- }
-
- return $filters_properties;
- }
-
- /**
- * Gets the active post types given a set of filters.
- *
- * @since 5.8.0
- *
- * @param array $filters The active filters for the current query.
- *
- * @return array The active post types.
- */
- public static function get_active_post_types( $filters ) {
- $active_post_types = array();
-
- foreach ( $filters as $item ) {
- if ( ( 'post_type' == $item['type'] ) && isset( $item['query_vars']['post_type'] ) ) {
- $active_post_types[] = $item['query_vars']['post_type'];
- }
- }
-
- return $active_post_types;
- }
-
- /**
- * Sets active to false on all post type buckets.
- *
- * @since 5.8.0
- *
- * @param array $filters The available filters for the current query.
- *
- * @return array The filters for the current query with modified active field.
- */
- public static function remove_active_from_post_type_buckets( $filters ) {
- $modified = $filters;
- foreach ( $filters as $key => $filter ) {
- if ( 'post_type' === $filter['type'] && ! empty( $filter['buckets'] ) ) {
- foreach ( $filter['buckets'] as $k => $bucket ) {
- $bucket['active'] = false;
- $modified[ $key ]['buckets'][ $k ] = $bucket;
- }
- }
- }
-
- return $modified;
- }
-
- /**
- * Given a url and an array of post types, will ensure that the post types are properly applied to the URL as args.
- *
- * @since 5.8.0
- *
- * @param string $url The URL to add post types to.
- * @param array $post_types An array of post types that should be added to the URL.
- *
- * @return string The URL with added post types.
- */
- public static function add_post_types_to_url( $url, $post_types ) {
- $url = Jetpack_Search_Helpers::remove_query_arg( 'post_type', $url );
- if ( empty( $post_types ) ) {
- return $url;
- }
-
- $url = Jetpack_Search_Helpers::add_query_arg(
- 'post_type',
- implode( ',', $post_types ),
- $url
- );
-
- return $url;
- }
-
- /**
- * Since we provide support for the widget restricting post types by adding the selected post types as
- * active filters, if removing a post type filter would result in there no longer be post_type args in the URL,
- * we need to be sure to add them back.
- *
- * @since 5.8.0
- *
- * @param array $filters An array of possible filters for the current query.
- * @param array $post_types The post types to ensure are on the link.
- *
- * @return array The updated array of filters with post typed added to the remove URLs.
- */
- public static function ensure_post_types_on_remove_url( $filters, $post_types ) {
- $modified = $filters;
-
- foreach ( (array) $filters as $filter_key => $filter ) {
- if ( 'post_type' !== $filter['type'] || empty( $filter['buckets'] ) ) {
- $modified[ $filter_key ] = $filter;
- continue;
- }
-
- foreach ( (array) $filter['buckets'] as $bucket_key => $bucket ) {
- if ( empty( $bucket['remove_url'] ) ) {
- continue;
- }
-
- $parsed = wp_parse_url( $bucket['remove_url'] );
- if ( ! $parsed ) {
- continue;
- }
-
- $query = array();
- if ( ! empty( $parsed['query'] ) ) {
- wp_parse_str( $parsed['query'], $query );
- }
-
- if ( empty( $query['post_type'] ) ) {
- $modified[ $filter_key ]['buckets'][ $bucket_key ]['remove_url'] = self::add_post_types_to_url(
- $bucket['remove_url'],
- $post_types
- );
- }
- }
- }
-
- return $modified;
- }
-
- /**
- * Wraps a WordPress filter called "jetpack_search_disable_widget_filters" that allows
- * developers to disable filters supplied by the search widget. Useful if filters are
- * being defined at the code level.
- *
- * @since 5.8.0
- *
- * @return bool
- */
- public static function are_filters_by_widget_disabled() {
- /**
- * Allows developers to disable filters being set by widget, in favor of manually
- * setting filters via `Jetpack_Search::set_filters()`.
- *
- * @module search
- *
- * @since 5.7.0
- *
- * @param bool false
- */
- return apply_filters( 'jetpack_search_disable_widget_filters', false );
- }
-
- /**
- * Returns a boolean for whether the current site has a VIP index.
- *
- * @since 5.8.0
- *
- * @return bool
- */
- public static function site_has_vip_index() {
- $has_vip_index = (
- Constants::is_defined( 'JETPACK_SEARCH_VIP_INDEX' ) &&
- Constants::get_constant( 'JETPACK_SEARCH_VIP_INDEX' )
- );
-
- /**
- * Allows developers to filter whether the current site has a VIP index.
- *
- * @module search
- *
- * @since 5.8.0
- *
- * @param bool $has_vip_index Whether the current site has a VIP index.
- */
- return apply_filters( 'jetpack_search_has_vip_index', $has_vip_index );
- }
-
- /**
- * Returns the maximum posts per page for a search query.
- *
- * @since 5.8.0
- *
- * @return int
- */
- public static function get_max_posts_per_page() {
- return self::site_has_vip_index() ? 1000 : 100;
- }
-
- /**
- * Returns the maximum offset for a search query.
- *
- * @since 5.8.0
- *
- * @return int
- */
- public static function get_max_offset() {
- return self::site_has_vip_index() ? 9000 : 1000;
- }
-}
diff --git a/plugins/jetpack/modules/search/class.jetpack-search-template-tags.php b/plugins/jetpack/modules/search/class.jetpack-search-template-tags.php
deleted file mode 100644
index 303e6caa..00000000
--- a/plugins/jetpack/modules/search/class.jetpack-search-template-tags.php
+++ /dev/null
@@ -1,225 +0,0 @@
-<?php
-/**
- * Jetpack Search: Jetpack_Search_Template_Tags class
- *
- * @package Jetpack
- * @subpackage Jetpack Search
- * @since 5.8.0
- */
-
-/**
- * Class that has various methods for outputting functionality into a theme that doesn't support widgets.
- * Additionally the widget itself makes use of these class.
- *
- * @since 5.8.0
- */
-class Jetpack_Search_Template_Tags {
-
- /**
- * Renders all available filters that can be used to filter down search results on the frontend.
- *
- * @since 5.8.0
- *
- * @param array $filters The available filters for the current query.
- * @param array $post_types An array of post types to make filterable
- */
- public static function render_available_filters( $filters = null, $post_types = null ) {
- if ( is_null( $filters ) ) {
- $filters = Jetpack_Search::instance()->get_filters();
- }
-
- if ( is_null( $post_types ) ) {
- $post_types = get_post_types( array( 'exclude_from_search' => false ) );
- }
-
- /**
- * If the post types specified by the widget differ from the default set of searchable post types,
- * then we need to track their state.
- */
- $active_post_types = array();
- if ( Jetpack_Search_Helpers::post_types_differ_searchable( $post_types ) ) {
- // get the active filter buckets from the query
- $active_buckets = Jetpack_Search::instance()->get_active_filter_buckets();
- $post_types_differ_query = Jetpack_Search_Helpers::post_types_differ_query( $post_types );
-
- // remove any post_type filters from display if the current query
- // already specifies to match all post types
- if ( ! $post_types_differ_query ) {
- $active_buckets = array_filter( $active_buckets, array( __CLASS__, 'is_not_post_type_filter' ) );
- }
-
- $active_post_types = Jetpack_Search_Helpers::get_active_post_types( $active_buckets );
- if ( empty( $active_post_types ) ) {
- $active_post_types = $post_types;
- }
-
- if ( $post_types_differ_query ) {
- $filters = Jetpack_Search_Helpers::ensure_post_types_on_remove_url( $filters, $post_types );
- } else {
- $filters = Jetpack_Search_Helpers::remove_active_from_post_type_buckets( $filters );
- }
- } else {
- $post_types = array();
- }
-
- foreach ( (array) $filters as $filter ) {
- if ( 'post_type' == $filter['type'] ) {
- self::render_filter( $filter, $post_types );
- } else {
- self::render_filter( $filter, $active_post_types );
- }
- }
- }
-
- /**
- * Renders a single filter that can be applied to the current search.
- *
- * @since 5.8.0
- *
- * @param array $filter The filter to render.
- * @param array $default_post_types The default post types for this filter.
- */
- public static function render_filter( $filter, $default_post_types ) {
- if ( empty( $filter ) || empty( $filter['buckets'] ) ) {
- return;
- }
-
- $query_vars = null;
- foreach ( $filter['buckets'] as $item ) {
- if ( $item['active'] ) {
- $query_vars = array_keys( $item['query_vars'] );
- break;
- }
- }
- $clear_url = null;
- if ( ! empty( $query_vars ) ) {
- $clear_url = Jetpack_Search_Helpers::remove_query_arg( $query_vars );
- if ( ! empty( $default_post_types ) ) {
- $clear_url = Jetpack_Search_Helpers::add_post_types_to_url( $clear_url, $default_post_types );
- }
- }
-
- ?>
- <h4 class="jetpack-search-filters-widget__sub-heading">
- <?php echo esc_html( $filter['name'] ); ?>
- </h4>
- <?php if ( $clear_url ) : ?>
- <div class="jetpack-search-filters-widget__clear">
- <a href="<?php echo esc_url( $clear_url ); ?>">
- <?php esc_html_e( '< Clear Filters', 'jetpack' ); ?>
- </a>
- </div>
- <?php endif; ?>
- <ul class="jetpack-search-filters-widget__filter-list">
- <?php
- foreach ( $filter['buckets'] as $item ) :
- $url = ( empty( $item['active'] ) ) ? $item['url'] : $item['remove_url'];
- ?>
- <li>
- <label>
- <input type="checkbox"<?php checked( ! empty( $item['active'] ) ); ?> disabled="disabled" />&nbsp;
- <a href="<?php echo esc_url( $url ); ?>">
- <?php
- echo esc_html( $item['name'] );
- echo '&nbsp;';
- echo esc_html( sprintf(
- '(%s)',
- number_format_i18n( absint( $item['count'] ) )
- ) );
- ?>
- </a>
- </label>
- </li>
- <?php endforeach; ?>
- </ul>
- <?php
- }
-
- /**
- * Outputs the search widget's title.
- *
- * @since 5.8.0
- *
- * @param string $title The widget's title
- * @param string $before_title The HTML tag to display before the title
- * @param string $after_title The HTML tag to display after the title
- */
- public static function render_widget_title( $title, $before_title, $after_title ) {
- echo $before_title . esc_html( $title ) . $after_title;
- }
-
- /**
- * Responsible for rendering the search box within our widget on the frontend.
- *
- * @since 5.8.0
- *
- * @param array $post_types Array of post types to limit search results to.
- * @param string $orderby How to order the search results.
- * @param string $order In what direction to order the search results.
- */
- public static function render_widget_search_form( $post_types, $orderby, $order ) {
- $form = get_search_form( false );
-
- $fields_to_inject = array(
- 'orderby' => $orderby,
- 'order' => $order
- );
-
- // If the widget has specified post types to search within and IF the post types differ
- // from the default post types that would have been searched, set the selected post
- // types via hidden inputs.
- if ( Jetpack_Search_Helpers::post_types_differ_searchable( $post_types ) ) {
- $fields_to_inject['post_type'] = implode( ',', $post_types );
- }
-
- $form = self::inject_hidden_form_fields( $form, $fields_to_inject );
-
- echo '<div class="jetpack-search-form">';
- echo $form;
- echo '</div>';
- }
-
- /**
- * Modifies an HTML form to add some additional hidden fields.
- *
- * @since 5.8.0
- *
- * @param string $form The form HTML to modify.
- * @param array $fields Array of hidden fields to add. Key is field name and value is the field value.
- *
- * @return string The modified form HTML.
- */
- private static function inject_hidden_form_fields( $form, $fields ) {
- $form_injection = '';
-
- foreach ( $fields as $field_name => $field_value ) {
- $form_injection .= sprintf(
- '<input type="hidden" name="%s" value="%s" />',
- esc_attr( $field_name ),
- esc_attr( $field_value )
- );
- }
-
- // This shouldn't need to be escaped since we've escaped above as we built $form_injection
- $form = str_replace(
- '</form>',
- $form_injection . '</form>',
- $form
- );
-
- return $form;
- }
-
- /**
- * Internal method for filtering out non-post_type filters.
- *
- * @since 5.8.0
- *
- * @param array $filter
- *
- * @return bool
- */
- private static function is_not_post_type_filter( $filter ) {
- return 'post_type' !== $filter['type'];
- }
-} \ No newline at end of file
diff --git a/plugins/jetpack/modules/search/class.jetpack-search.php b/plugins/jetpack/modules/search/class.jetpack-search.php
deleted file mode 100644
index fc276a02..00000000
--- a/plugins/jetpack/modules/search/class.jetpack-search.php
+++ /dev/null
@@ -1,1959 +0,0 @@
-<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
-
-/**
- * Jetpack Search: Main Jetpack_Search class
- *
- * @package Jetpack
- * @subpackage Jetpack Search
- * @since 5.0.0
- */
-
-use Automattic\Jetpack\Connection\Client;
-use Automattic\Jetpack\Search\Helper;
-
-/**
- * The main class for the Jetpack Search module.
- *
- * @since 5.0.0
- */
-class Jetpack_Search {
-
- /**
- * The number of found posts.
- *
- * @since 5.0.0
- *
- * @var int
- */
- protected $found_posts = 0;
-
- /**
- * The search result, as returned by the WordPress.com REST API.
- *
- * @since 5.0.0
- *
- * @var array
- */
- protected $search_result;
-
- /**
- * This site's blog ID on WordPress.com.
- *
- * @since 5.0.0
- *
- * @var int
- */
- protected $jetpack_blog_id;
-
- /**
- * The Elasticsearch aggregations (filters).
- *
- * @since 5.0.0
- *
- * @var array
- */
- protected $aggregations = array();
-
- /**
- * The maximum number of aggregations allowed.
- *
- * @since 5.0.0
- *
- * @var int
- */
- protected $max_aggregations_count = 100;
-
- /**
- * Statistics about the last Elasticsearch query.
- *
- * @since 5.6.0
- *
- * @var array
- */
- protected $last_query_info = array();
-
- /**
- * Statistics about the last Elasticsearch query failure.
- *
- * @since 5.6.0
- *
- * @var array
- */
- protected $last_query_failure_info = array();
-
- /**
- * The singleton instance of this class.
- *
- * @since 5.0.0
- *
- * @var Jetpack_Search
- */
- protected static $instance;
-
- /**
- * Languages with custom analyzers. Other languages are supported, but are analyzed with the default analyzer.
- *
- * @since 5.0.0
- *
- * @var array
- */
- public static $analyzed_langs = array( 'ar', 'bg', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'eu', 'fa', 'fi', 'fr', 'he', 'hi', 'hu', 'hy', 'id', 'it', 'ja', 'ko', 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' );
-
- /**
- * Jetpack_Search constructor.
- *
- * @since 5.0.0
- *
- * Doesn't do anything. This class needs to be initialized via the instance() method instead.
- */
- protected function __construct() {
- }
-
- /**
- * Prevent __clone()'ing of this class.
- *
- * @since 5.0.0
- */
- public function __clone() {
- wp_die( "Please don't __clone Jetpack_Search" );
- }
-
- /**
- * Prevent __wakeup()'ing of this class.
- *
- * @since 5.0.0
- */
- public function __wakeup() {
- wp_die( "Please don't __wakeup Jetpack_Search" );
- }
-
- /**
- * Get singleton instance of Jetpack_Search.
- *
- * Instantiates and sets up a new instance if needed, or returns the singleton.
- *
- * @since 5.0.0
- *
- * @return Jetpack_Search The Jetpack_Search singleton.
- */
- public static function instance() {
- if ( ! isset( self::$instance ) ) {
- if ( Automattic\Jetpack\Search\Options::is_instant_enabled() ) {
- require_once __DIR__ . '/class-jetpack-instant-search.php';
- self::$instance = new Jetpack_Instant_Search();
- } else {
- self::$instance = new Jetpack_Search();
- }
-
- self::$instance->setup();
- }
-
- return self::$instance;
- }
-
- /**
- * Perform various setup tasks for the class.
- *
- * Checks various pre-requisites and adds hooks.
- *
- * @since 5.0.0
- */
- public function setup() {
- if ( ! Jetpack::is_connection_ready() || ! $this->is_search_supported() ) {
- /**
- * Fires when the Jetpack Search fails and would fallback to MySQL.
- *
- * @module search
- * @since 7.9.0
- *
- * @param string $reason Reason for Search fallback.
- * @param mixed $data Data associated with the request, such as attempted search parameters.
- */
- do_action( 'jetpack_search_abort', 'inactive', null );
- return;
- }
-
- $this->jetpack_blog_id = Jetpack::get_option( 'id' );
-
- if ( ! $this->jetpack_blog_id ) {
- /** This action is documented in modules/search/class.jetpack-search.php */
- do_action( 'jetpack_search_abort', 'no_blog_id', null );
- return;
- }
-
- $this->load_php();
- $this->init_hooks();
- }
-
- /**
- * Loads the php for this version of search
- *
- * @since 8.3.0
- */
- public function load_php() {
- $this->base_load_php();
- }
-
- /**
- * Loads the PHP common to all search. Should be called from extending classes.
- */
- protected function base_load_php() {
- require_once JETPACK__PLUGIN_DIR . 'modules/widgets/search.php';
- }
-
- /**
- * Setup the various hooks needed for the plugin to take over search duties.
- *
- * @since 5.0.0
- */
- public function init_hooks() {
- if ( ! is_admin() ) {
- add_filter( 'posts_pre_query', array( $this, 'filter__posts_pre_query' ), 10, 2 );
-
- add_filter( 'jetpack_search_es_wp_query_args', array( $this, 'filter__add_date_filter_to_query' ), 10, 2 );
-
- add_action( 'did_jetpack_search_query', array( $this, 'store_last_query_info' ) );
- add_action( 'failed_jetpack_search_query', array( $this, 'store_query_failure' ) );
-
- add_action( 'init', array( $this, 'set_filters_from_widgets' ) );
-
- add_action( 'pre_get_posts', array( $this, 'maybe_add_post_type_as_var' ) );
- } else {
- add_action( 'update_option', array( $this, 'track_widget_updates' ), 10, 3 );
- }
-
- add_action( 'jetpack_deactivate_module_search', array( $this, 'move_search_widgets_to_inactive' ) );
- }
-
- /**
- * Is search supported on the current plan
- *
- * @since 6.0
- * Loads scripts for Tracks analytics library
- */
- public function is_search_supported() {
- if ( method_exists( 'Jetpack_Plan', 'supports' ) ) {
- return Jetpack_Plan::supports( 'search' );
- }
- return false;
- }
-
- /**
- * Does this site have a VIP index
- * Get the version number to use when loading the file. Allows us to bypass cache when developing.
- *
- * @since 6.0
- * @return string $script_version Version number.
- */
- public function has_vip_index() {
- return defined( 'JETPACK_SEARCH_VIP_INDEX' ) && JETPACK_SEARCH_VIP_INDEX;
- }
-
- /**
- * When an Elasticsearch query fails, this stores it and enqueues some debug information in the footer.
- *
- * @since 5.6.0
- *
- * @param array $meta Information about the failure.
- */
- public function store_query_failure( $meta ) {
- $this->last_query_failure_info = $meta;
- add_action( 'wp_footer', array( $this, 'print_query_failure' ) );
- }
-
- /**
- * Outputs information about the last Elasticsearch failure.
- *
- * @since 5.6.0
- */
- public function print_query_failure() {
- if ( $this->last_query_failure_info ) {
- printf(
- '<!-- Jetpack Search failed with code %s: %s - %s -->',
- esc_html( $this->last_query_failure_info['response_code'] ),
- esc_html( $this->last_query_failure_info['json']['error'] ),
- esc_html( $this->last_query_failure_info['json']['message'] )
- );
- }
- }
-
- /**
- * Stores information about the last Elasticsearch query and enqueues some debug information in the footer.
- *
- * @since 5.6.0
- *
- * @param array $meta Information about the query.
- */
- public function store_last_query_info( $meta ) {
- $this->last_query_info = $meta;
- add_action( 'wp_footer', array( $this, 'print_query_success' ) );
- }
-
- /**
- * Outputs information about the last Elasticsearch search.
- *
- * @since 5.6.0
- */
- public function print_query_success() {
- if ( $this->last_query_info ) {
- printf(
- '<!-- Jetpack Search took %s ms, ES time %s ms -->',
- (int) $this->last_query_info['elapsed_time'],
- esc_html( $this->last_query_info['es_time'] )
- );
-
- if ( isset( $_GET['searchdebug'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- printf(
- '<!-- Query response data: %s -->',
- esc_html( print_r( $this->last_query_info, 1 ) ) // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
- );
- }
- }
- }
-
- /**
- * Returns the last query information, or false if no information was stored.
- *
- * @since 5.8.0
- *
- * @return bool|array
- */
- public function get_last_query_info() {
- return empty( $this->last_query_info ) ? false : $this->last_query_info;
- }
-
- /**
- * Returns the last query failure information, or false if no failure information was stored.
- *
- * @since 5.8.0
- *
- * @return bool|array
- */
- public function get_last_query_failure_info() {
- return empty( $this->last_query_failure_info ) ? false : $this->last_query_failure_info;
- }
-
- /**
- * Wraps a WordPress filter called "jetpack_search_disable_widget_filters" that allows
- * developers to disable filters supplied by the search widget. Useful if filters are
- * being defined at the code level.
- *
- * @since 5.7.0
- * @deprecated 5.8.0 Use Helper::are_filters_by_widget_disabled() directly.
- *
- * @return bool
- */
- public function are_filters_by_widget_disabled() {
- return Helper::are_filters_by_widget_disabled();
- }
-
- /**
- * Retrieves a list of known Jetpack search filters widget IDs, gets the filters for each widget,
- * and applies those filters to this Jetpack_Search object.
- *
- * @since 5.7.0
- */
- public function set_filters_from_widgets() {
- if ( Helper::are_filters_by_widget_disabled() ) {
- return;
- }
-
- $filters = Helper::get_filters_from_widgets();
-
- if ( ! empty( $filters ) ) {
- $this->set_filters( $filters );
- }
- }
-
- /**
- * Restricts search results to certain post types via a GET argument.
- *
- * @since 5.8.0
- *
- * @param WP_Query $query A WP_Query instance.
- */
- public function maybe_add_post_type_as_var( WP_Query $query ) {
- $post_type = ( ! empty( $_GET['post_type'] ) ) ? $_GET['post_type'] : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- if ( $this->should_handle_query( $query ) && $post_type ) {
- $post_types = ( is_string( $post_type ) && false !== strpos( $post_type, ',' ) )
- ? explode( ',', $post_type )
- : (array) $post_type;
- $post_types = array_map( 'sanitize_key', $post_types );
- $query->set( 'post_type', $post_types );
- }
- }
-
- /**
- * Run a search on the WordPress.com public API.
- *
- * @since 5.0.0
- *
- * @param array $es_args Args conforming to the WP.com /sites/<blog_id>/search endpoint.
- *
- * @return object|WP_Error The response from the public API, or a WP_Error.
- */
- public function search( array $es_args ) {
- $endpoint = sprintf( '/sites/%s/search', $this->jetpack_blog_id );
- $service_url = 'https://public-api.wordpress.com/rest/v1' . $endpoint;
-
- $do_authenticated_request = false;
-
- if ( class_exists( 'Automattic\\Jetpack\\Connection\\Client' ) &&
- isset( $es_args['authenticated_request'] ) &&
- true === $es_args['authenticated_request'] ) {
- $do_authenticated_request = true;
- }
-
- unset( $es_args['authenticated_request'] );
-
- $request_args = array(
- 'headers' => array(
- 'Content-Type' => 'application/json',
- ),
- 'timeout' => 10,
- 'user-agent' => 'jetpack_search',
- );
-
- $request_body = wp_json_encode( $es_args );
-
- $start_time = microtime( true );
-
- if ( $do_authenticated_request ) {
- $request_args['method'] = 'POST';
-
- $request = Client::wpcom_json_api_request_as_blog( $endpoint, Client::WPCOM_JSON_API_VERSION, $request_args, $request_body );
- } else {
- $request_args = array_merge(
- $request_args,
- array(
- 'body' => $request_body,
- )
- );
-
- $request = wp_remote_post( $service_url, $request_args );
- }
-
- $end_time = microtime( true );
-
- if ( is_wp_error( $request ) ) {
- return $request;
- }
- $response_code = wp_remote_retrieve_response_code( $request );
-
- if ( ! $response_code || $response_code < 200 || $response_code >= 300 ) {
- return new WP_Error( 'invalid_search_api_response', 'Invalid response from API - ' . $response_code );
- }
-
- $response = json_decode( wp_remote_retrieve_body( $request ), true );
-
- $took = is_array( $response ) && ! empty( $response['took'] )
- ? $response['took']
- : null;
-
- $query = array(
- 'args' => $es_args,
- 'response' => $response,
- 'response_code' => $response_code,
- 'elapsed_time' => ( $end_time - $start_time ) * 1000, // Convert from float seconds to ms.
- 'es_time' => $took,
- 'url' => $service_url,
- );
-
- /**
- * Fires after a search request has been performed.
- *
- * Includes the following info in the $query parameter:
- *
- * array args Array of Elasticsearch arguments for the search
- * array response Raw API response, JSON decoded
- * int response_code HTTP response code of the request
- * float elapsed_time Roundtrip time of the search request, in milliseconds
- * float es_time Amount of time Elasticsearch spent running the request, in milliseconds
- * string url API url that was queried
- *
- * @module search
- *
- * @since 5.0.0
- * @since 5.8.0 This action now fires on all queries instead of just successful queries.
- *
- * @param array $query Array of information about the query performed
- */
- do_action( 'did_jetpack_search_query', $query );
-
- if ( ! $response_code || $response_code < 200 || $response_code >= 300 ) {
- /**
- * Fires after a search query request has failed
- *
- * @module search
- *
- * @since 5.6.0
- *
- * @param array Array containing the response code and response from the failed search query
- */
- do_action(
- 'failed_jetpack_search_query',
- array(
- 'response_code' => $response_code,
- 'json' => $response,
- )
- );
-
- return new WP_Error( 'invalid_search_api_response', 'Invalid response from API - ' . $response_code );
- }
-
- return $response;
- }
-
- /**
- * Bypass the normal Search query and offload it to Jetpack servers.
- *
- * This is the main hook of the plugin and is responsible for returning the posts that match the search query.
- *
- * @since 5.0.0
- *
- * @param array $posts Current array of posts (still pre-query).
- * @param WP_Query $query The WP_Query being filtered.
- *
- * @return array Array of matching posts.
- */
- public function filter__posts_pre_query( $posts, $query ) {
- if ( ! $this->should_handle_query( $query ) ) {
- // Intentionally not adding the 'jetpack_search_abort' action since this should fire for every request except for search.
- return $posts;
- }
-
- $this->do_search( $query );
-
- if ( ! is_array( $this->search_result ) ) {
- /** This action is documented in modules/search/class.jetpack-search.php */
- do_action( 'jetpack_search_abort', 'no_search_results_array', $this->search_result );
- return $posts;
- }
-
- // If no results, nothing to do.
- if ( ! count( $this->search_result['results']['hits'] ) ) {
- return array();
- }
-
- $post_ids = array();
-
- foreach ( $this->search_result['results']['hits'] as $result ) {
- $post_ids[] = (int) $result['fields']['post_id'];
- }
-
- // Query all posts now.
- $args = array(
- 'post__in' => $post_ids,
- 'orderby' => 'post__in',
- 'perm' => 'readable',
- 'post_type' => 'any',
- 'ignore_sticky_posts' => true,
- 'suppress_filters' => true,
- 'posts_per_page' => $query->get( 'posts_per_page' ),
- );
-
- $posts_query = new WP_Query( $args );
-
- // WP Core doesn't call the set_found_posts and its filters when filtering posts_pre_query like we do, so need to do these manually.
- $query->found_posts = $this->found_posts;
- $query->max_num_pages = ceil( $this->found_posts / $query->get( 'posts_per_page' ) );
-
- return $posts_query->posts;
- }
-
- /**
- * Build up the search, then run it against the Jetpack servers.
- *
- * @since 5.0.0
- *
- * @param WP_Query $query The original WP_Query to use for the parameters of our search.
- */
- public function do_search( WP_Query $query ) {
- if ( ! $this->should_handle_query( $query ) ) {
- // If we make it here, either 'filter__posts_pre_query' somehow allowed it or a different entry to do_search.
- /** This action is documented in modules/search/class.jetpack-search.php */
- do_action( 'jetpack_search_abort', 'search_attempted_non_search_query', $query );
- return;
- }
-
- $page = ( $query->get( 'paged' ) ) ? absint( $query->get( 'paged' ) ) : 1;
-
- // Get maximum allowed offset and posts per page values for the API.
- $max_offset = Helper::get_max_offset();
- $max_posts_per_page = Helper::get_max_posts_per_page();
-
- $posts_per_page = $query->get( 'posts_per_page' );
- if ( $posts_per_page > $max_posts_per_page ) {
- $posts_per_page = $max_posts_per_page;
- }
-
- // Start building the WP-style search query args.
- // They'll be translated to ES format args later.
- $es_wp_query_args = array(
- 'query' => $query->get( 's' ),
- 'posts_per_page' => $posts_per_page,
- 'paged' => $page,
- 'orderby' => $query->get( 'orderby' ),
- 'order' => $query->get( 'order' ),
- );
-
- if ( ! empty( $this->aggregations ) ) {
- $es_wp_query_args['aggregations'] = $this->aggregations;
- }
-
- // Did we query for authors?
- if ( $query->get( 'author_name' ) ) {
- $es_wp_query_args['author_name'] = $query->get( 'author_name' );
- }
-
- $es_wp_query_args['post_type'] = $this->get_es_wp_query_post_type_for_query( $query );
- $es_wp_query_args['terms'] = $this->get_es_wp_query_terms_for_query( $query );
-
- /**
- * Modify the search query parameters, such as controlling the post_type.
- *
- * These arguments are in the format of WP_Query arguments
- *
- * @module search
- *
- * @since 5.0.0
- *
- * @param array $es_wp_query_args The current query args, in WP_Query format.
- * @param WP_Query $query The original WP_Query object.
- */
- $es_wp_query_args = apply_filters( 'jetpack_search_es_wp_query_args', $es_wp_query_args, $query );
-
- // If page * posts_per_page is greater than our max offset, send a 404. This is necessary because the offset is
- // capped at Helper::get_max_offset(), so a high page would always return the last page of results otherwise.
- if ( ( $es_wp_query_args['paged'] * $es_wp_query_args['posts_per_page'] ) > $max_offset ) {
- $query->set_404();
-
- return;
- }
-
- // If there were no post types returned, then 404 to avoid querying against non-public post types, which could
- // happen if we don't add the post type restriction to the ES query.
- if ( empty( $es_wp_query_args['post_type'] ) ) {
- $query->set_404();
-
- return;
- }
-
- // Convert the WP-style args into ES args.
- $es_query_args = $this->convert_wp_es_to_es_args( $es_wp_query_args );
-
- // Only trust ES to give us IDs, not the content since it is a mirror.
- $es_query_args['fields'] = array(
- 'post_id',
- );
-
- /**
- * Modify the underlying ES query that is passed to the search endpoint. The returned args must represent a valid ES query
- *
- * This filter is harder to use if you're unfamiliar with ES, but allows complete control over the query
- *
- * @module search
- *
- * @since 5.0.0
- *
- * @param array $es_query_args The raw Elasticsearch query args.
- * @param WP_Query $query The original WP_Query object.
- */
- $es_query_args = apply_filters( 'jetpack_search_es_query_args', $es_query_args, $query );
-
- // Do the actual search query!
- $this->search_result = $this->search( $es_query_args );
-
- if ( is_wp_error( $this->search_result ) || ! is_array( $this->search_result ) || empty( $this->search_result['results'] ) || empty( $this->search_result['results']['hits'] ) ) {
- $this->found_posts = 0;
-
- return;
- }
-
- // If we have aggregations, fix the ordering to match the input order (ES doesn't guarantee the return order).
- if ( isset( $this->search_result['results']['aggregations'] ) && ! empty( $this->search_result['results']['aggregations'] ) ) {
- $this->search_result['results']['aggregations'] = $this->fix_aggregation_ordering( $this->search_result['results']['aggregations'], $this->aggregations );
- }
-
- // Total number of results for paging purposes. Capped at $max_offset + $posts_per_page, as deep paging gets quite expensive.
- $this->found_posts = min( $this->search_result['results']['total'], $max_offset + $posts_per_page );
- }
-
- /**
- * If the query has already been run before filters have been updated, then we need to re-run the query
- * to get the latest aggregations.
- *
- * This is especially useful for supporting widget management in the customizer.
- *
- * @since 5.8.0
- *
- * @return bool Whether the query was successful or not.
- */
- public function update_search_results_aggregations() {
- if ( empty( $this->last_query_info ) || empty( $this->last_query_info['args'] ) ) {
- return false;
- }
-
- $es_args = $this->last_query_info['args'];
- $builder = new Automattic\Jetpack\Search\WPES\Query_Builder();
- $this->add_aggregations_to_es_query_builder( $this->aggregations, $builder );
- $es_args['aggregations'] = $builder->build_aggregation();
-
- $this->search_result = $this->search( $es_args );
-
- return ! is_wp_error( $this->search_result );
- }
-
- /**
- * Given a WP_Query, convert its WP_Tax_Query (if present) into the WP-style Elasticsearch term arguments for the search.
- *
- * @since 5.0.0
- *
- * @param WP_Query $query The original WP_Query object for which to parse the taxonomy query.
- *
- * @return array The new WP-style Elasticsearch arguments (that will be converted into 'real' Elasticsearch arguments).
- */
- public function get_es_wp_query_terms_for_query( WP_Query $query ) {
- $args = array();
-
- $the_tax_query = $query->tax_query;
-
- if ( ! $the_tax_query ) {
- return $args;
- }
-
- if ( ! $the_tax_query instanceof WP_Tax_Query || empty( $the_tax_query->queried_terms ) || ! is_array( $the_tax_query->queried_terms ) ) {
- return $args;
- }
-
- $args = array();
-
- foreach ( $the_tax_query->queries as $tax_query ) {
- // Right now we only support slugs...see note above.
- if ( ! is_array( $tax_query ) || 'slug' !== $tax_query['field'] ) {
- continue;
- }
-
- $taxonomy = $tax_query['taxonomy'];
-
- if ( ! isset( $args[ $taxonomy ] ) || ! is_array( $args[ $taxonomy ] ) ) {
- $args[ $taxonomy ] = array();
- }
-
- $args[ $taxonomy ] = array_merge( $args[ $taxonomy ], $tax_query['terms'] );
- }
-
- return $args;
- }
-
- /**
- * Parse out the post type from a WP_Query.
- *
- * Only allows post types that are not marked as 'exclude_from_search'.
- *
- * @since 5.0.0
- *
- * @param WP_Query $query Original WP_Query object.
- *
- * @return array Array of searchable post types corresponding to the original query.
- */
- public function get_es_wp_query_post_type_for_query( WP_Query $query ) {
- $post_types = $query->get( 'post_type' );
-
- // If we're searching 'any', we want to only pass searchable post types to Elasticsearch.
- if ( 'any' === $post_types ) {
- $post_types = array_values(
- get_post_types(
- array(
- 'exclude_from_search' => false,
- )
- )
- );
- }
-
- if ( ! is_array( $post_types ) ) {
- $post_types = array( $post_types );
- }
-
- $post_types = array_unique( $post_types );
-
- $sanitized_post_types = array();
-
- // Make sure the post types are queryable.
- foreach ( $post_types as $post_type ) {
- if ( ! $post_type ) {
- continue;
- }
-
- $post_type_object = get_post_type_object( $post_type );
- if ( ! $post_type_object || $post_type_object->exclude_from_search ) {
- continue;
- }
-
- $sanitized_post_types[] = $post_type;
- }
-
- return $sanitized_post_types;
- }
-
- /**
- * Initialize widgets for the Search module (on wp.com only).
- *
- * @module search
- */
- public function action__widgets_init() {
- require_once __DIR__ . '/class.jetpack-search-widget-filters.php';
-
- register_widget( 'Jetpack_Search_Widget_Filters' );
- }
-
- /**
- * Get the Elasticsearch result.
- *
- * @since 5.0.0
- *
- * @param bool $raw If true, does not check for WP_Error or return the 'results' array - the JSON decoded HTTP response.
- *
- * @return array|bool The search results, or false if there was a failure.
- */
- public function get_search_result( $raw = false ) {
- if ( $raw ) {
- return $this->search_result;
- }
-
- return ( ! empty( $this->search_result ) && ! is_wp_error( $this->search_result ) && is_array( $this->search_result ) && ! empty( $this->search_result['results'] ) ) ? $this->search_result['results'] : false;
- }
-
- /**
- * Add the date portion of a WP_Query onto the query args.
- *
- * @since 5.0.0
- *
- * @param array $es_wp_query_args The Elasticsearch query arguments in WordPress form.
- * @param WP_Query $query The original WP_Query.
- *
- * @return array The es wp query args, with date filters added (as needed).
- */
- public function filter__add_date_filter_to_query( array $es_wp_query_args, WP_Query $query ) {
- if ( $query->get( 'year' ) ) {
- if ( $query->get( 'monthnum' ) ) {
- // Padding.
- $date_monthnum = sprintf( '%02d', $query->get( 'monthnum' ) );
-
- if ( $query->get( 'day' ) ) {
- // Padding.
- $date_day = sprintf( '%02d', $query->get( 'day' ) );
-
- $date_start = $query->get( 'year' ) . '-' . $date_monthnum . '-' . $date_day . ' 00:00:00';
- $date_end = $query->get( 'year' ) . '-' . $date_monthnum . '-' . $date_day . ' 23:59:59';
- } else {
- $days_in_month = gmdate( 't', mktime( 0, 0, 0, $query->get( 'monthnum' ), 14, $query->get( 'year' ) ) ); // 14 = middle of the month so no chance of DST issues
-
- $date_start = $query->get( 'year' ) . '-' . $date_monthnum . '-01 00:00:00';
- $date_end = $query->get( 'year' ) . '-' . $date_monthnum . '-' . $days_in_month . ' 23:59:59';
- }
- } else {
- $date_start = $query->get( 'year' ) . '-01-01 00:00:00';
- $date_end = $query->get( 'year' ) . '-12-31 23:59:59';
- }
-
- $es_wp_query_args['date_range'] = array(
- 'field' => 'date',
- 'gte' => $date_start,
- 'lte' => $date_end,
- );
- }
-
- return $es_wp_query_args;
- }
-
- /**
- * Converts WP_Query style args to Elasticsearch args.
- *
- * @since 5.0.0
- *
- * @param array $args Array of WP_Query style arguments.
- *
- * @return array Array of ES style query arguments.
- */
- public function convert_wp_es_to_es_args( array $args ) {
- $defaults = array(
- 'blog_id' => get_current_blog_id(),
- 'query' => null, // Search phrase.
- 'query_fields' => array(), // list of fields to search.
- 'excess_boost' => array(), // map of field to excess boost values (multiply).
- 'post_type' => null, // string or an array.
- 'terms' => array(), // ex: array( 'taxonomy-1' => array( 'slug' ), 'taxonomy-2' => array( 'slug-a', 'slug-b' ) ). phpcs:ignore Squiz.PHP.CommentedOutCode.Found.
- 'author' => null, // id or an array of ids.
- 'author_name' => array(), // string or an array.
- 'date_range' => null, // array( 'field' => 'date', 'gt' => 'YYYY-MM-dd', 'lte' => 'YYYY-MM-dd' ); date formats: 'YYYY-MM-dd' or 'YYYY-MM-dd HH:MM:SS'. phpcs:ignore Squiz.PHP.CommentedOutCode.Found.
- 'orderby' => null, // Defaults to 'relevance' if query is set, otherwise 'date'. Pass an array for multiple orders.
- 'order' => 'DESC',
- 'posts_per_page' => 10,
- 'offset' => null,
- 'paged' => null,
- /**
- * Aggregations. Examples:
- * array(
- * 'Tag' => array( 'type' => 'taxonomy', 'taxonomy' => 'post_tag', 'count' => 10 ) ),
- * 'Post Type' => array( 'type' => 'post_type', 'count' => 10 ) ),
- * );
- */
- 'aggregations' => null,
- );
-
- $args = wp_parse_args( $args, $defaults );
-
- $parser = new Automattic\Jetpack\Search\WPES\Query_Parser(
- $args['query'],
- /**
- * Filter the languages used by Jetpack Search's Query Parser.
- *
- * @module search
- *
- * @since 7.9.0
- *
- * @param array $languages The array of languages. Default is value of get_locale().
- */
- apply_filters( 'jetpack_search_query_languages', array( get_locale() ) )
- );
-
- if ( empty( $args['query_fields'] ) ) {
- if ( $this->has_vip_index() ) {
- // VIP indices do not have per language fields.
- $match_fields = $this->_get_caret_boosted_fields(
- array(
- 'title' => 0.1,
- 'content' => 0.1,
- 'excerpt' => 0.1,
- 'tag.name' => 0.1,
- 'category.name' => 0.1,
- 'author_login' => 0.1,
- 'author' => 0.1,
- )
- );
-
- $boost_fields = $this->_get_caret_boosted_fields(
- $this->_apply_boosts_multiplier(
- array(
- 'title' => 2,
- 'tag.name' => 1,
- 'category.name' => 1,
- 'author_login' => 1,
- 'author' => 1,
- ),
- $args['excess_boost']
- )
- );
-
- $boost_phrase_fields = $this->_get_caret_boosted_fields(
- array(
- 'title' => 1,
- 'content' => 1,
- 'excerpt' => 1,
- 'tag.name' => 1,
- 'category.name' => 1,
- 'author' => 1,
- )
- );
- } else {
- $match_fields = $parser->merge_ml_fields(
- array(
- 'title' => 0.1,
- 'content' => 0.1,
- 'excerpt' => 0.1,
- 'tag.name' => 0.1,
- 'category.name' => 0.1,
- ),
- $this->_get_caret_boosted_fields(
- array(
- 'author_login' => 0.1,
- 'author' => 0.1,
- )
- )
- );
-
- $boost_fields = $parser->merge_ml_fields(
- $this->_apply_boosts_multiplier(
- array(
- 'title' => 2,
- 'tag.name' => 1,
- 'category.name' => 1,
- ),
- $args['excess_boost']
- ),
- $this->_get_caret_boosted_fields(
- $this->_apply_boosts_multiplier(
- array(
- 'author_login' => 1,
- 'author' => 1,
- ),
- $args['excess_boost']
- )
- )
- );
-
- $boost_phrase_fields = $parser->merge_ml_fields(
- array(
- 'title' => 1,
- 'content' => 1,
- 'excerpt' => 1,
- 'tag.name' => 1,
- 'category.name' => 1,
- ),
- $this->_get_caret_boosted_fields(
- array(
- 'author' => 1,
- )
- )
- );
- }
- } else {
- // If code is overriding the fields, then use that. Important for backwards compatibility.
- $match_fields = $args['query_fields'];
- $boost_phrase_fields = $match_fields;
- $boost_fields = null;
- }
-
- $parser->phrase_filter(
- array(
- 'must_query_fields' => $match_fields,
- 'boost_query_fields' => null,
- )
- );
- $parser->remaining_query(
- array(
- 'must_query_fields' => $match_fields,
- 'boost_query_fields' => $boost_fields,
- )
- );
-
- // Boost on phrase matches.
- $parser->remaining_query(
- array(
- 'boost_query_fields' => $boost_phrase_fields,
- 'boost_query_type' => 'phrase',
- )
- );
-
- /**
- * Modify the recency decay parameters for the search query.
- *
- * The recency decay lowers the search scores based on the age of a post relative to an origin date. Basic adjustments:
- * - origin: A date. Posts with this date will have the highest score and no decay applied. Default is today.
- * - offset: Number of days/months/years (eg 30d). All posts within this time range of the origin (before and after) will have no decay applied. Default is no offset.
- * - scale: The number of days/months/years from the origin+offset at which the decay will equal the decay param. Default 360d
- * - decay: The amount of decay applied at offset+scale. Default 0.9.
- *
- * The curve applied is a Gaussian. More details available at {@see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-decay}
- *
- * @module search
- *
- * @since 5.8.0
- *
- * @param array $decay_params The decay parameters.
- * @param array $args The WP query parameters.
- */
- $decay_params = apply_filters(
- 'jetpack_search_recency_score_decay',
- array(
- 'origin' => gmdate( 'Y-m-d' ),
- 'scale' => '360d',
- 'decay' => 0.9,
- ),
- $args
- );
-
- if ( ! empty( $decay_params ) ) {
- // Newer content gets weighted slightly higher.
- $parser->add_decay(
- 'gauss',
- array(
- 'date_gmt' => $decay_params,
- )
- );
- }
-
- $es_query_args = array(
- 'blog_id' => absint( $args['blog_id'] ),
- 'size' => absint( $args['posts_per_page'] ),
- );
-
- // ES "from" arg (offset).
- if ( $args['offset'] ) {
- $es_query_args['from'] = absint( $args['offset'] );
- } elseif ( $args['paged'] ) {
- $es_query_args['from'] = max( 0, ( absint( $args['paged'] ) - 1 ) * $es_query_args['size'] );
- }
-
- $es_query_args['from'] = min( $es_query_args['from'], Helper::get_max_offset() );
-
- if ( ! is_array( $args['author_name'] ) ) {
- $args['author_name'] = array( $args['author_name'] );
- }
-
- // ES stores usernames, not IDs, so transform.
- if ( ! empty( $args['author'] ) ) {
- if ( ! is_array( $args['author'] ) ) {
- $args['author'] = array( $args['author'] );
- }
-
- foreach ( $args['author'] as $author ) {
- $user = get_user_by( 'id', $author );
-
- if ( $user && ! empty( $user->user_login ) ) {
- $args['author_name'][] = $user->user_login;
- }
- }
- }
-
- /*
- * Build the filters from the query elements.
- * Filters rock because they are cached from one query to the next
- * but they are cached as individual filters, rather than all combined together.
- * May get performance boost by also caching the top level boolean filter too.
- */
-
- if ( $args['post_type'] ) {
- if ( ! is_array( $args['post_type'] ) ) {
- $args['post_type'] = array( $args['post_type'] );
- }
-
- $parser->add_filter(
- array(
- 'terms' => array(
- 'post_type' => $args['post_type'],
- ),
- )
- );
- }
-
- if ( $args['author_name'] ) {
- $parser->add_filter(
- array(
- 'terms' => array(
- 'author_login' => $args['author_name'],
- ),
- )
- );
- }
-
- if ( ! empty( $args['date_range'] ) && isset( $args['date_range']['field'] ) ) {
- $field = $args['date_range']['field'];
-
- unset( $args['date_range']['field'] );
-
- $parser->add_filter(
- array(
- 'range' => array(
- $field => $args['date_range'],
- ),
- )
- );
- }
-
- if ( is_array( $args['terms'] ) ) {
- foreach ( $args['terms'] as $tax => $terms ) {
- $terms = (array) $terms;
-
- if ( count( $terms ) && mb_strlen( $tax ) ) {
- switch ( $tax ) {
- case 'post_tag':
- $tax_fld = 'tag.slug';
-
- break;
-
- case 'category':
- $tax_fld = 'category.slug';
-
- break;
-
- default:
- $tax_fld = 'taxonomy.' . $tax . '.slug';
-
- break;
- }
-
- foreach ( $terms as $term ) {
- $parser->add_filter(
- array(
- 'term' => array(
- $tax_fld => $term,
- ),
- )
- );
- }
- }
- }
- }
-
- if ( ! $args['orderby'] ) {
- if ( $args['query'] ) {
- $args['orderby'] = array( 'relevance' );
- } else {
- $args['orderby'] = array( 'date' );
- }
- }
-
- // Validate the "order" field.
- switch ( strtolower( $args['order'] ) ) {
- case 'asc':
- $args['order'] = 'asc';
- break;
-
- case 'desc':
- default:
- $args['order'] = 'desc';
- break;
- }
-
- $es_query_args['sort'] = array();
-
- foreach ( (array) $args['orderby'] as $orderby ) {
- // Translate orderby from WP field to ES field.
- switch ( $orderby ) {
- case 'relevance':
- // never order by score ascending.
- $es_query_args['sort'][] = array(
- '_score' => array(
- 'order' => 'desc',
- ),
- );
-
- break;
-
- case 'date':
- $es_query_args['sort'][] = array(
- 'date' => array(
- 'order' => $args['order'],
- ),
- );
-
- break;
-
- case 'ID':
- $es_query_args['sort'][] = array(
- 'id' => array(
- 'order' => $args['order'],
- ),
- );
-
- break;
-
- case 'author':
- $es_query_args['sort'][] = array(
- 'author.raw' => array(
- 'order' => $args['order'],
- ),
- );
-
- break;
- } // End switch.
- } // End foreach.
-
- if ( empty( $es_query_args['sort'] ) ) {
- unset( $es_query_args['sort'] );
- }
-
- // Aggregations.
- if ( ! empty( $args['aggregations'] ) ) {
- $this->add_aggregations_to_es_query_builder( $args['aggregations'], $parser );
- }
-
- $es_query_args['filter'] = $parser->build_filter();
- $es_query_args['query'] = $parser->build_query();
- $es_query_args['aggregations'] = $parser->build_aggregation();
-
- return $es_query_args;
- }
-
- /**
- * Given an array of aggregations, parse and add them onto the query builder object for use in Elasticsearch.
- *
- * @since 5.0.0
- *
- * @param array $aggregations Array of aggregations (filters) to add to the query builder.
- * @param Automattic\Jetpack\Search\WPES\Query_Builder $builder The builder instance that is creating the Elasticsearch query.
- */
- public function add_aggregations_to_es_query_builder( array $aggregations, $builder ) {
- foreach ( $aggregations as $label => $aggregation ) {
- if ( ! isset( $aggregation['type'] ) ) {
- continue;
- }
- switch ( $aggregation['type'] ) {
- case 'taxonomy':
- $this->add_taxonomy_aggregation_to_es_query_builder( $aggregation, $label, $builder );
-
- break;
-
- case 'post_type':
- $this->add_post_type_aggregation_to_es_query_builder( $aggregation, $label, $builder );
-
- break;
-
- case 'date_histogram':
- $this->add_date_histogram_aggregation_to_es_query_builder( $aggregation, $label, $builder );
-
- break;
- }
- }
- }
-
- /**
- * Given an individual taxonomy aggregation, add it to the query builder object for use in Elasticsearch.
- *
- * @since 5.0.0
- *
- * @param array $aggregation The aggregation to add to the query builder.
- * @param string $label The 'label' (unique id) for this aggregation.
- * @param Automattic\Jetpack\Search\WPES\Query_Builder $builder The builder instance that is creating the Elasticsearch query.
- */
- public function add_taxonomy_aggregation_to_es_query_builder( array $aggregation, $label, $builder ) {
- $field = null;
-
- switch ( $aggregation['taxonomy'] ) {
- case 'post_tag':
- $field = 'tag';
- break;
-
- case 'category':
- $field = 'category';
- break;
-
- default:
- $field = 'taxonomy.' . $aggregation['taxonomy'];
- break;
- }
-
- $builder->add_aggs(
- $label,
- array(
- 'terms' => array(
- 'field' => $field . '.slug',
- 'size' => min( (int) $aggregation['count'], $this->max_aggregations_count ),
- ),
- )
- );
- }
-
- /**
- * Given an individual post_type aggregation, add it to the query builder object for use in Elasticsearch.
- *
- * @since 5.0.0
- *
- * @param array $aggregation The aggregation to add to the query builder.
- * @param string $label The 'label' (unique id) for this aggregation.
- * @param Automattic\Jetpack\Search\WPES\Query_Builder $builder The builder instance that is creating the Elasticsearch query.
- */
- public function add_post_type_aggregation_to_es_query_builder( array $aggregation, $label, $builder ) {
- $builder->add_aggs(
- $label,
- array(
- 'terms' => array(
- 'field' => 'post_type',
- 'size' => min( (int) $aggregation['count'], $this->max_aggregations_count ),
- ),
- )
- );
- }
-
- /**
- * Given an individual date_histogram aggregation, add it to the query builder object for use in Elasticsearch.
- *
- * @since 5.0.0
- *
- * @param array $aggregation The aggregation to add to the query builder.
- * @param string $label The 'label' (unique id) for this aggregation.
- * @param Automattic\Jetpack\Search\WPES\Query_Builder $builder The builder instance that is creating the Elasticsearch query.
- */
- public function add_date_histogram_aggregation_to_es_query_builder( array $aggregation, $label, $builder ) {
- $args = array(
- 'interval' => $aggregation['interval'],
- 'field' => ( ! empty( $aggregation['field'] ) && 'post_date_gmt' === $aggregation['field'] ) ? 'date_gmt' : 'date',
- );
-
- if ( isset( $aggregation['min_doc_count'] ) ) {
- $args['min_doc_count'] = (int) $aggregation['min_doc_count'];
- } else {
- $args['min_doc_count'] = 1;
- }
-
- $builder->add_aggs(
- $label,
- array(
- 'date_histogram' => $args,
- )
- );
- }
-
- /**
- * And an existing filter object with a list of additional filters.
- *
- * Attempts to optimize the filters somewhat.
- *
- * @since 5.0.0
- *
- * @param array $curr_filter The existing filters to build upon.
- * @param array $filters The new filters to add.
- *
- * @return array The resulting merged filters.
- */
- public static function and_es_filters( array $curr_filter, array $filters ) {
- if ( ! is_array( $curr_filter ) || isset( $curr_filter['match_all'] ) ) {
- if ( 1 === count( $filters ) ) {
- return $filters[0];
- }
-
- return array(
- 'and' => $filters,
- );
- }
-
- return array(
- 'and' => array_merge( array( $curr_filter ), $filters ),
- );
- }
-
- /**
- * Set the available filters for the search.
- *
- * These get rendered via the Jetpack_Search_Widget() widget.
- *
- * Behind the scenes, these are implemented using Elasticsearch Aggregations.
- *
- * If you do not require counts of how many documents match each filter, please consider using regular WP Query
- * arguments instead, such as via the jetpack_search_es_wp_query_args filter
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html
- *
- * @since 5.0.0
- *
- * @param array $aggregations Array of filters (aggregations) to apply to the search.
- */
- public function set_filters( array $aggregations ) {
- foreach ( (array) $aggregations as $key => $agg ) {
- if ( empty( $agg['name'] ) ) {
- $aggregations[ $key ]['name'] = $key;
- }
- }
- $this->aggregations = $aggregations;
- }
-
- /**
- * Get the raw Aggregation results from the Elasticsearch response.
- *
- * @since 5.0.0
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html
- *
- * @return array Array of Aggregations performed on the search.
- */
- public function get_search_aggregations_results() {
- $aggregations = array();
-
- $search_result = $this->get_search_result();
-
- if ( ! empty( $search_result ) && ! empty( $search_result['aggregations'] ) ) {
- $aggregations = $search_result['aggregations'];
- }
-
- return $aggregations;
- }
-
- /**
- * Get the results of the Filters performed, including the number of matching documents.
- *
- * Returns an array of Filters (keyed by $label, as passed to Jetpack_Search::set_filters()), containing the Filter and all resulting
- * matching buckets, the url for applying/removing each bucket, etc.
- *
- * NOTE - if this is called before the search is performed, an empty array will be returned. Use the $aggregations class
- * member if you need to access the raw filters set in Jetpack_Search::set_filters().
- *
- * @since 5.0.0
- *
- * @param WP_Query $query The optional original WP_Query to use for determining which filters are active. Defaults to the main query.
- *
- * @return array Array of filters applied and info about them.
- */
- public function get_filters( WP_Query $query = null ) {
- if ( ! $query instanceof WP_Query ) {
- global $wp_query;
-
- $query = $wp_query;
- }
-
- $aggregation_data = $this->aggregations;
-
- if ( empty( $aggregation_data ) ) {
- return $aggregation_data;
- }
-
- $aggregation_results = $this->get_search_aggregations_results();
-
- if ( ! $aggregation_results ) {
- return $aggregation_data;
- }
-
- // NOTE - Looping over the _results_, not the original configured aggregations, so we get the 'real' data from ES.
- foreach ( $aggregation_results as $label => $aggregation ) {
- if ( empty( $aggregation ) ) {
- continue;
- }
-
- $type = $this->aggregations[ $label ]['type'];
-
- $aggregation_data[ $label ]['buckets'] = array();
-
- $existing_term_slugs = array();
-
- $tax_query_var = null;
-
- // Figure out which terms are active in the query, for this taxonomy.
- if ( 'taxonomy' === $this->aggregations[ $label ]['type'] ) {
- $tax_query_var = $this->get_taxonomy_query_var( $this->aggregations[ $label ]['taxonomy'] );
-
- if ( ! empty( $query->tax_query ) && ! empty( $query->tax_query->queries ) && is_array( $query->tax_query->queries ) ) {
- foreach ( $query->tax_query->queries as $tax_query ) {
- if ( is_array( $tax_query ) && $this->aggregations[ $label ]['taxonomy'] === $tax_query['taxonomy'] &&
- 'slug' === $tax_query['field'] &&
- is_array( $tax_query['terms'] ) ) {
- $existing_term_slugs = array_merge( $existing_term_slugs, $tax_query['terms'] );
- }
- }
- }
- }
-
- // Now take the resulting found aggregation items and generate the additional info about them, such as activation/deactivation url, name, count, etc.
- $buckets = array();
-
- if ( ! empty( $aggregation['buckets'] ) ) {
- $buckets = (array) $aggregation['buckets'];
- }
-
- if ( 'date_histogram' === $type ) {
- // re-order newest to oldest.
- $buckets = array_reverse( $buckets );
- }
-
- // Some aggregation types like date_histogram don't support the max results parameter.
- if ( is_int( $this->aggregations[ $label ]['count'] ) && count( $buckets ) > $this->aggregations[ $label ]['count'] ) {
- $buckets = array_slice( $buckets, 0, $this->aggregations[ $label ]['count'] );
- }
-
- foreach ( $buckets as $item ) {
- $query_vars = array();
- $active = false;
- $remove_url = null;
- $name = '';
-
- // What type was the original aggregation?
- switch ( $type ) {
- case 'taxonomy':
- $taxonomy = $this->aggregations[ $label ]['taxonomy'];
-
- $term = get_term_by( 'slug', $item['key'], $taxonomy );
-
- if ( ! $term || ! $tax_query_var ) {
- continue 2; // switch() is considered a looping structure.
- }
-
- $query_vars = array(
- $tax_query_var => implode( '+', array_merge( $existing_term_slugs, array( $term->slug ) ) ),
- );
-
- $name = $term->name;
-
- // Let's determine if this term is active or not.
-
- if ( in_array( $item['key'], $existing_term_slugs, true ) ) {
- $active = true;
-
- $slug_count = count( $existing_term_slugs );
-
- if ( $slug_count > 1 ) {
- $remove_url = Helper::add_query_arg(
- $tax_query_var,
- rawurlencode( implode( '+', array_diff( $existing_term_slugs, array( $item['key'] ) ) ) )
- );
- } else {
- $remove_url = Helper::remove_query_arg( $tax_query_var );
- }
- }
-
- break;
-
- case 'post_type':
- $post_type = get_post_type_object( $item['key'] );
-
- if ( ! $post_type || $post_type->exclude_from_search ) {
- continue 2; // switch() is considered a looping structure.
- }
-
- $query_vars = array(
- 'post_type' => $item['key'],
- );
-
- $name = $post_type->labels->singular_name;
-
- // Is this post type active on this search?
- $post_types = $query->get( 'post_type' );
-
- if ( ! is_array( $post_types ) ) {
- $post_types = array( $post_types );
- }
-
- if ( in_array( $item['key'], $post_types, true ) ) {
- $active = true;
-
- $post_type_count = count( $post_types );
-
- // For the right 'remove filter' url, we need to remove the post type from the array, or remove the param entirely if it's the only one.
- if ( $post_type_count > 1 ) {
- $remove_url = Helper::add_query_arg(
- 'post_type',
- rawurlencode( implode( ',', array_diff( $post_types, array( $item['key'] ) ) ) )
- );
- } else {
- $remove_url = Helper::remove_query_arg( 'post_type' );
- }
- }
-
- break;
-
- case 'date_histogram':
- $timestamp = $item['key'] / 1000;
-
- $current_year = $query->get( 'year' );
- $current_month = $query->get( 'monthnum' );
- $current_day = $query->get( 'day' );
-
- switch ( $this->aggregations[ $label ]['interval'] ) {
- case 'year':
- $year = (int) gmdate( 'Y', $timestamp );
-
- $query_vars = array(
- 'year' => $year,
- 'monthnum' => false,
- 'day' => false,
- );
-
- $name = $year;
-
- // Is this year currently selected?
- if ( ! empty( $current_year ) && (int) $current_year === $year ) {
- $active = true;
-
- $remove_url = Helper::remove_query_arg( array( 'year', 'monthnum', 'day' ) );
- }
-
- break;
-
- case 'month':
- $year = (int) gmdate( 'Y', $timestamp );
- $month = (int) gmdate( 'n', $timestamp );
-
- $query_vars = array(
- 'year' => $year,
- 'monthnum' => $month,
- 'day' => false,
- );
-
- $name = gmdate( 'F Y', $timestamp );
-
- // Is this month currently selected?
- if ( ! empty( $current_year ) && (int) $current_year === $year &&
- ! empty( $current_month ) && (int) $current_month === $month ) {
- $active = true;
-
- $remove_url = Helper::remove_query_arg( array( 'year', 'monthnum' ) );
- }
-
- break;
-
- case 'day':
- $year = (int) gmdate( 'Y', $timestamp );
- $month = (int) gmdate( 'n', $timestamp );
- $day = (int) gmdate( 'j', $timestamp );
-
- $query_vars = array(
- 'year' => $year,
- 'monthnum' => $month,
- 'day' => $day,
- );
-
- $name = gmdate( 'F jS, Y', $timestamp );
-
- // Is this day currently selected?
- if ( ! empty( $current_year ) && (int) $current_year === $year &&
- ! empty( $current_month ) && (int) $current_month === $month &&
- ! empty( $current_day ) && (int) $current_day === $day ) {
- $active = true;
-
- $remove_url = Helper::remove_query_arg( array( 'day' ) );
- }
-
- break;
-
- default:
- continue 3; // switch() is considered a looping structure.
- } // End switch.
-
- break;
-
- default:
- // continue 2; // switch() is considered a looping structure.
- } // End switch.
-
- // Need to urlencode param values since add_query_arg doesn't.
- $url_params = urlencode_deep( $query_vars );
-
- $aggregation_data[ $label ]['buckets'][] = array(
- 'url' => Helper::add_query_arg( $url_params ),
- 'query_vars' => $query_vars,
- 'name' => $name,
- 'count' => $item['doc_count'],
- 'active' => $active,
- 'remove_url' => $remove_url,
- 'type' => $type,
- 'type_label' => $aggregation_data[ $label ]['name'],
- 'widget_id' => ! empty( $aggregation_data[ $label ]['widget_id'] ) ? $aggregation_data[ $label ]['widget_id'] : 0,
- );
- } // End foreach.
- } // End foreach.
-
- /**
- * Modify the aggregation filters returned by get_filters().
- *
- * Useful if you are setting custom filters outside of the supported filters (taxonomy, post_type etc.) and
- * want to hook them up so they're returned when you call `get_filters()`.
- *
- * @module search
- *
- * @since 6.9.0
- *
- * @param array $aggregation_data The array of filters keyed on label.
- * @param WP_Query $query The WP_Query object.
- */
- return apply_filters( 'jetpack_search_get_filters', $aggregation_data, $query );
- }
-
- /**
- * Get the filters that are currently applied to this search.
- *
- * @since 5.0.0
- *
- * @return array Array of filters that were applied.
- */
- public function get_active_filter_buckets() {
- $active_buckets = array();
-
- $filters = $this->get_filters();
-
- if ( ! is_array( $filters ) ) {
- return $active_buckets;
- }
-
- foreach ( $filters as $filter ) {
- if ( isset( $filter['buckets'] ) && is_array( $filter['buckets'] ) ) {
- foreach ( $filter['buckets'] as $item ) {
- if ( isset( $item['active'] ) && $item['active'] ) {
- $active_buckets[] = $item;
- }
- }
- }
- }
-
- return $active_buckets;
- }
-
- /**
- * Calculate the right query var to use for a given taxonomy.
- *
- * Allows custom code to modify the GET var that is used to represent a given taxonomy, via the jetpack_search_taxonomy_query_var filter.
- *
- * @since 5.0.0
- *
- * @param string $taxonomy_name The name of the taxonomy for which to get the query var.
- *
- * @return bool|string The query var to use for this taxonomy, or false if none found.
- */
- public function get_taxonomy_query_var( $taxonomy_name ) {
- $taxonomy = get_taxonomy( $taxonomy_name );
-
- if ( ! $taxonomy || is_wp_error( $taxonomy ) ) {
- return false;
- }
-
- /**
- * Modify the query var to use for a given taxonomy
- *
- * @module search
- *
- * @since 5.0.0
- *
- * @param string $query_var The current query_var for the taxonomy
- * @param string $taxonomy_name The taxonomy name
- */
- return apply_filters( 'jetpack_search_taxonomy_query_var', $taxonomy->query_var, $taxonomy_name );
- }
-
- /**
- * Takes an array of aggregation results, and ensures the array key ordering matches the key order in $desired
- * which is the input order.
- *
- * Necessary because ES does not always return aggregations in the same order that you pass them in,
- * and it should be possible to control the display order easily.
- *
- * @since 5.0.0
- *
- * @param array $aggregations Aggregation results to be reordered.
- * @param array $desired Array with keys representing the desired ordering.
- *
- * @return array A new array with reordered keys, matching those in $desired.
- */
- public function fix_aggregation_ordering( array $aggregations, array $desired ) {
- if ( empty( $aggregations ) || empty( $desired ) ) {
- return $aggregations;
- }
-
- $reordered = array();
-
- foreach ( array_keys( $desired ) as $agg_name ) {
- if ( isset( $aggregations[ $agg_name ] ) ) {
- $reordered[ $agg_name ] = $aggregations[ $agg_name ];
- }
- }
-
- return $reordered;
- }
-
- /**
- * Sends events to Tracks when a search filters widget is updated.
- *
- * @since 5.8.0
- *
- * @param string $option The option name. Only "widget_jetpack-search-filters" is cared about.
- * @param array $old_value The old option value.
- * @param array $new_value The new option value.
- */
- public function track_widget_updates( $option, $old_value, $new_value ) {
- if ( 'widget_jetpack-search-filters' !== $option ) {
- return;
- }
-
- $event = Helper::get_widget_tracks_value( $old_value, $new_value );
- if ( ! $event ) {
- return;
- }
-
- $tracking = new Automattic\Jetpack\Tracking();
- $tracking->tracks_record_event(
- wp_get_current_user(),
- sprintf( 'jetpack_search_widget_%s', $event['action'] ),
- $event['widget']
- );
- }
-
- /**
- * Moves any active search widgets to the inactive category.
- *
- * @since 5.9.0
- */
- public function move_search_widgets_to_inactive() {
- if ( ! is_active_widget( false, false, Helper::FILTER_WIDGET_BASE, true ) ) {
- return;
- }
-
- $sidebars_widgets = wp_get_sidebars_widgets();
-
- if ( ! is_array( $sidebars_widgets ) ) {
- return;
- }
-
- $changed = false;
-
- foreach ( $sidebars_widgets as $sidebar => $widgets ) {
- if ( 'wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) {
- continue;
- }
-
- if ( is_array( $widgets ) ) {
- foreach ( $widgets as $key => $widget ) {
- if ( _get_widget_id_base( $widget ) === Helper::FILTER_WIDGET_BASE ) {
- $changed = true;
-
- array_unshift( $sidebars_widgets['wp_inactive_widgets'], $widget );
- unset( $sidebars_widgets[ $sidebar ][ $key ] );
- }
- }
- }
- }
-
- if ( $changed ) {
- wp_set_sidebars_widgets( $sidebars_widgets );
- }
- }
-
- /**
- * Determine whether a given WP_Query should be handled by ElasticSearch.
- *
- * @param WP_Query $query The WP_Query object.
- *
- * @return bool
- */
- public function should_handle_query( $query ) {
- /**
- * Determine whether a given WP_Query should be handled by ElasticSearch.
- *
- * @module search
- *
- * @since 5.6.0
- *
- * @param bool $should_handle Should be handled by Jetpack Search.
- * @param WP_Query $query The WP_Query object.
- */
- return apply_filters( 'jetpack_search_should_handle_query', $query->is_main_query() && $query->is_search(), $query );
- }
-
- /**
- * Transforms an array with fields name as keys and boosts as value into
- * shorthand "caret" format.
- *
- * @param array $fields_boost [ "title" => "2", "content" => "1" ].
- *
- * @return array [ "title^2", "content^1" ]
- */
- private function _get_caret_boosted_fields( array $fields_boost ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
- $caret_boosted_fields = array();
- foreach ( $fields_boost as $field => $boost ) {
- $caret_boosted_fields[] = "$field^$boost";
- }
- return $caret_boosted_fields;
- }
-
- /**
- * Apply a multiplier to boost values.
- *
- * @param array $fields_boost [ "title" => 2, "content" => 1 ].
- * @param array $fields_boost_multiplier [ "title" => 0.1234 ].
- *
- * @return array [ "title" => "0.247", "content" => "1.000" ]
- */
- private function _apply_boosts_multiplier( array $fields_boost, array $fields_boost_multiplier ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
- foreach ( $fields_boost as $field_name => $field_boost ) {
- if ( isset( $fields_boost_multiplier[ $field_name ] ) ) {
- $fields_boost[ $field_name ] *= $fields_boost_multiplier[ $field_name ];
- }
-
- // Set a floor and format the number as string.
- $fields_boost[ $field_name ] = number_format(
- max( 0.001, $fields_boost[ $field_name ] ),
- 3,
- '.',
- ''
- );
- }
-
- return $fields_boost;
- }
-}
diff --git a/plugins/jetpack/modules/search/customize-controls/class-excluded-post-types-control.css b/plugins/jetpack/modules/search/customize-controls/class-excluded-post-types-control.css
deleted file mode 100644
index 561f8e37..00000000
--- a/plugins/jetpack/modules/search/customize-controls/class-excluded-post-types-control.css
+++ /dev/null
@@ -1,5 +0,0 @@
-.customize-control-excluded-post-type-checkbox-container {
- line-height: 1.6;
- padding-top: 6px;
- padding-bottom: 6px;
-} \ No newline at end of file
diff --git a/plugins/jetpack/modules/search/customize-controls/class-excluded-post-types-control.js b/plugins/jetpack/modules/search/customize-controls/class-excluded-post-types-control.js
deleted file mode 100644
index d3c48c7a..00000000
--- a/plugins/jetpack/modules/search/customize-controls/class-excluded-post-types-control.js
+++ /dev/null
@@ -1,23 +0,0 @@
-/* eslint-disable no-var */
-
-jQuery( document ).ready( function ( $ ) {
- // Refresh our hidden field value if any checkboxes change
- $( '.customize-control-excluded-post-type-checkbox' ).on( 'change', function () {
- var $parent = $( this ).parent().parent();
- var newValue = $parent
- .find( '.customize-control-excluded-post-type-checkbox:checked' )
- .map( function () {
- return $( this ).val();
- } )
- .toArray();
- $parent.find( '.customize-control-excluded-post-types' ).val( newValue ).trigger( 'change' );
-
- // Set the last unchecked checkbox disabled to prvevent user from excluding all post types
- var excludedPostTypesCount = $parent.find(
- '.customize-control-excluded-post-type-checkbox:not(:checked)'
- ).length;
- $parent
- .find( '.customize-control-excluded-post-type-checkbox:not(:checked)' )
- .prop( 'disabled', excludedPostTypesCount <= 1 );
- } );
-} );
diff --git a/plugins/jetpack/modules/search/customize-controls/class-excluded-post-types-control.php b/plugins/jetpack/modules/search/customize-controls/class-excluded-post-types-control.php
deleted file mode 100644
index 5b5d0a1f..00000000
--- a/plugins/jetpack/modules/search/customize-controls/class-excluded-post-types-control.php
+++ /dev/null
@@ -1,128 +0,0 @@
-<?php
-/**
- * A multi-checkbox Customizer control for use with Jetpack Search configuration
- *
- * @package automattic/jetpack
- * @since 8.8.0
- */
-
-use Automattic\Jetpack\Search\Helper;
-
-/**
- * Label Control class.
- */
-class Excluded_Post_Types_Control extends WP_Customize_Control {
- /**
- * Control type.
- *
- * @since 8.8.0
- * @var string
- */
- public $type = 'excluded-post-types';
-
- /**
- * Enqueue styles related to this control.
- */
- public function enqueue() {
- $style_relative_path = 'modules/search/customize-controls/class-excluded-post-types-control.css';
- $style_version = Helper::get_asset_version( $style_relative_path );
- $style_path = plugins_url( $style_relative_path, JETPACK__PLUGIN_FILE );
- wp_enqueue_style( 'jetpack-instant-search-customizer-excluded-post-types', $style_path, array(), $style_version );
-
- $script_relative_path = 'modules/search/customize-controls/class-excluded-post-types-control.js';
- $script_version = Helper::get_asset_version( $script_relative_path );
- $script_path = plugins_url( $script_relative_path, JETPACK__PLUGIN_FILE );
- wp_enqueue_script( 'jetpack-instant-search-customizer-excluded-post-types', $script_path, array( 'customize-controls' ), $script_version, true );
- }
-
- /**
- * Checks if the post type has been selected.
- *
- * @since 8.8.0
- * @return array $post_types An array of strings representing post type names.
- */
- public function get_arrayed_value() {
- return explode( ',', $this->value() );
- }
-
- /**
- * Generates a customizer settings ID for a given post type.
- *
- * @since 8.8.0
- * @param object $post_type Post type object returned from get_post_types.
- * @return string $customizer_id Customizer setting ID.
- */
- public function generate_post_type_customizer_id( $post_type ) {
- return '_customize-post-type-input-' . $post_type->name;
- }
-
- /**
- * Checks if the post type has been selected.
- *
- * @since 8.8.0
- * @param object $post_type Post type object returned from get_post_types.
- * @return array $ids Post type => post type customizer ID object.
- */
- public function is_checked( $post_type ) {
- return in_array( $post_type->name, $this->get_arrayed_value(), true );
- }
-
- /**
- * Override rendering for custom class name; omit element ID.
- */
- protected function render() {
- $id = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id );
- $class = 'customize-control customize-control-excluded-post-types';
-
- printf( '<li id="%s" class="%s">', esc_attr( $id ), esc_attr( $class ) );
- $this->render_content();
- echo '</li>';
- }
-
- /**
- * Override content rendering.
- */
- protected function render_content() {
- $post_types = get_post_types( array( 'exclude_from_search' => false ), 'objects' );
- if ( count( $post_types ) === 0 ) {
- return;
- }
- ?>
- <label class="customize-control-title">
- <?php echo esc_html( $this->label ); ?>
- </label>
- <?php if ( ! empty( $this->description ) ) : ?>
- <span class="description customize-control-description">
- <?php echo esc_html( $this->description ); ?>
- </span>
- <?php endif ?>
- <input
- class="customize-control-excluded-post-types"
- id="<?php echo esc_attr( $this->id ); ?>"
- name="<?php echo esc_attr( $this->id ); ?>"
- type="hidden"
- value="<?php echo esc_attr( $this->value() ); ?>"
- <?php $this->link(); ?>
- />
- <?php
-
- $is_only_one_unchecked = ( count( $post_types ) - 1 ) === count( $this->get_arrayed_value() );
-
- foreach ( $post_types as $post_type ) {
- $input_id = Helper::generate_post_type_customizer_id( $post_type );
- ?>
- <div class="customize-control-excluded-post-type-checkbox-container">
- <input
- class="customize-control-excluded-post-type-checkbox"
- id="<?php echo esc_attr( $input_id ); ?>"
- type="checkbox"
- value="<?php echo esc_attr( $post_type->name ); ?>"
- <?php checked( $this->is_checked( $post_type ) ); ?>
- <?php disabled( ! $this->is_checked( $post_type ) && $is_only_one_unchecked ); ?>
- />
- <label for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $post_type->label ); ?></label>
- </div>
- <?php
- }
- }
-}
diff --git a/plugins/jetpack/modules/search/customize-controls/class-label-control.css b/plugins/jetpack/modules/search/customize-controls/class-label-control.css
deleted file mode 100644
index 3f1c7cc2..00000000
--- a/plugins/jetpack/modules/search/customize-controls/class-label-control.css
+++ /dev/null
@@ -1,18 +0,0 @@
-#sub-accordion-section-jetpack_search .customize-control {
- margin-bottom: 14px;
-}
-
-#sub-accordion-section-jetpack_search .customize-label-control,
-#sub-accordion-section-jetpack_search .customize-control-checkbox {
- margin-bottom: 0;
-}
-
-#sub-accordion-section-jetpack_search .customize-control-checkbox ~ .customize-label-control {
- margin-top: 12px;
-}
-
-#sub-accordion-section-jetpack_search .customize-control-radio {
- margin-bottom: 6px;
- padding-bottom: 0;
- padding-top: 0;
-}
diff --git a/plugins/jetpack/modules/search/customize-controls/class-label-control.php b/plugins/jetpack/modules/search/customize-controls/class-label-control.php
deleted file mode 100644
index a923fa8c..00000000
--- a/plugins/jetpack/modules/search/customize-controls/class-label-control.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-/**
- * A label-only Customizer control for use with Jetpack Search configuration
- *
- * @package automattic/jetpack
- * @since 8.6.0
- */
-
-/**
- * Label Control class.
- */
-class Label_Control extends WP_Customize_Control {
- /**
- * Enqueue styles related to this control.
- */
- public function enqueue() {
- $style_relative_path = 'modules/search/customize-controls/class-label-control.css';
- $style_version = Automattic\Jetpack\Search\Helper::get_asset_version( $style_relative_path );
- $style_path = plugins_url( $style_relative_path, JETPACK__PLUGIN_FILE );
- wp_enqueue_style( 'jetpack-instant-search-customizer-label', $style_path, array( 'customize-controls' ), $style_version );
- }
-
- /**
- * Override rendering for custom class name; omit element ID.
- */
- protected function render() {
- echo '<li class="customize-control customize-label-control">';
- $this->render_content();
- echo '</li>';
- }
-
- /**
- * Override content rendering.
- */
- protected function render_content() {
- if ( ! empty( $this->label ) ) : ?>
- <label class="customize-control-title">
- <?php echo esc_html( $this->label ); ?>
- </label>
- <?php endif; ?>
- <?php if ( ! empty( $this->description ) ) : ?>
- <span class="description customize-control-description">
- <?php echo esc_html( $this->description ); ?>
- </span>
- <?php
- endif;
- }
-}
diff --git a/plugins/jetpack/modules/search/customize-controls/customize-controls.js b/plugins/jetpack/modules/search/customize-controls/customize-controls.js
deleted file mode 100644
index ea77ce1a..00000000
--- a/plugins/jetpack/modules/search/customize-controls/customize-controls.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Binds iframe messages from the Customizer to SearchApp.
- *
- * @param {boolean} expanded - whether jetpack_search section is expanded and visible.
- */
-function postSectionMessage( expanded ) {
- // window.wp.customize.previewer.preview is not available until both customize and customize.previewer are ready.
- window.wp.customize.previewer.preview
- .targetWindow()
- .postMessage( { key: 'jetpackSearchSectionOpen', expanded: expanded }, '*' ); // Assume ES5 envorinment.
-}
-
-/**
- * Adds functionality for Jetpack Search section detection in the Customizer.
- */
-function init() {
- window.wp.customize.bind( 'ready', function () {
- // window.wp.customize.previewer will emit 'ready' multiple times, not just during initialization.
- window.wp.customize.previewer.bind( 'ready', function () {
- // window.wp.customize.previewer.loading is deinstanced after initial load.
- window.wp.customize.previewer.loading &&
- window.wp.customize.previewer.loading.done( function () {
- postSectionMessage( window.wp.customize.section( 'jetpack_search' ).expanded() );
- } );
-
- // If the Jetpack Search section is opened/closed, emit a message to open/close the modal.
- window.wp.customize.section( 'jetpack_search' ).expanded.bind( function () {
- postSectionMessage( window.wp.customize.section( 'jetpack_search' ).expanded() );
- } );
-
- // If Customizer values have changed while Jetpack Search section is open, emit a message to open the modal.
- window.wp.customize.bind( 'change', function () {
- window.wp.customize.section( 'jetpack_search' ).expanded() && postSectionMessage( true );
- } );
- } );
- } );
-}
-
-if ( document.readyState !== 'loading' ) {
- init();
-} else {
- document.addEventListener( 'DOMContentLoaded', init );
-}
diff --git a/plugins/jetpack/modules/seo-tools/class-jetpack-seo-utils.php b/plugins/jetpack/modules/seo-tools/class-jetpack-seo-utils.php
index c6d8c294..008d3a44 100644
--- a/plugins/jetpack/modules/seo-tools/class-jetpack-seo-utils.php
+++ b/plugins/jetpack/modules/seo-tools/class-jetpack-seo-utils.php
@@ -23,11 +23,9 @@ class Jetpack_SEO_Utils {
/**
* Used to check whether SEO tools are enabled for given site.
*
- * @param int $site_id Optional. Defaults to current blog id if not given.
- *
* @return bool True if SEO tools are enabled, false otherwise.
*/
- public static function is_enabled_jetpack_seo( $site_id = 0 ) {
+ public static function is_enabled_jetpack_seo() {
/**
* Can be used by SEO plugin authors to disable the conflicting output of SEO Tools.
*
@@ -41,13 +39,9 @@ class Jetpack_SEO_Utils {
return false;
}
- if ( function_exists( 'has_any_blog_stickers' ) ) {
- // For WPCOM simple sites.
- if ( empty( $site_id ) ) {
- $site_id = get_current_blog_id();
- }
-
- return has_any_blog_stickers( array( 'business-plan', 'ecommerce-plan' ), $site_id );
+ // For WPcom simple sites.
+ if ( defined( 'IS_WPCOM' ) && IS_WPCOM && method_exists( 'Jetpack_Plan', 'supports' ) ) {
+ return Jetpack_Plan::supports( 'advanced-seo' );
}
// For all Jetpack sites.
diff --git a/plugins/jetpack/modules/seo-tools/jetpack-seo-posts.php b/plugins/jetpack/modules/seo-tools/jetpack-seo-posts.php
deleted file mode 100644
index 82c9b0a5..00000000
--- a/plugins/jetpack/modules/seo-tools/jetpack-seo-posts.php
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-
-/**
- * Class containing utility static methods for managing SEO custom descriptions for Posts and Pages.
- */
-class Jetpack_SEO_Posts {
- /**
- * Key of the post meta value that will be used to store post custom description.
- */
- const DESCRIPTION_META_KEY = 'advanced_seo_description';
-
- /**
- * Build meta description for post SEO.
- *
- * @param WP_Post $post Source of data for custom description.
- *
- * @return string Post description or empty string.
- */
- public static function get_post_description( $post ) {
- if ( empty( $post ) ) {
- return '';
- }
-
- if ( post_password_required() || ! is_singular() ) {
- return '';
- }
-
- // Business users can overwrite the description
- $custom_description = self::get_post_custom_description( $post );
-
- if ( ! empty( $custom_description ) ) {
- return $custom_description;
- }
-
- if ( ! empty( $post->post_excerpt ) ) {
- return $post->post_excerpt;
- }
-
- return $post->post_content;
- }
-
- /**
- * Returns post's custom meta description if it is set, and if
- * SEO tools are enabled for current blog.
- *
- * @param WP_Post $post Source of data for custom description
- *
- * @return string Custom description or empty string
- */
- public static function get_post_custom_description( $post ) {
- if ( empty( $post ) ) {
- return '';
- }
-
- $custom_description = get_post_meta( $post->ID, self::DESCRIPTION_META_KEY, true );
-
- if ( empty( $custom_description ) || ! Jetpack_SEO_Utils::is_enabled_jetpack_seo() ) {
- return '';
- }
-
- return $custom_description;
- }
-
- /**
- * Registers the self::DESCRIPTION_META_KEY post_meta for use in the REST API.
- */
- public static function register_post_meta() {
- $args = array(
- 'type' => 'string',
- 'description' => __( 'Custom post description to be used in HTML <meta /> tag.', 'jetpack' ),
- 'single' => true,
- 'default' => '',
- 'show_in_rest' => array(
- 'name' => self::DESCRIPTION_META_KEY
- ),
- );
-
- register_meta( 'post', self::DESCRIPTION_META_KEY, $args );
- }
-
- /**
- * Register the Advanced SEO Gutenberg extension
- */
- public static function register_gutenberg_extension() {
- if ( Jetpack_SEO_Utils::is_enabled_jetpack_seo() ) {
- Jetpack_Gutenberg::set_extension_available( 'jetpack-seo' );
- } else {
- Jetpack_Gutenberg::set_extension_unavailable( 'jetpack-seo', 'jetpack_seo_disabled' );
- }
- }
-}
diff --git a/plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php b/plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php
deleted file mode 100644
index a7c2758d..00000000
--- a/plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php
+++ /dev/null
@@ -1,301 +0,0 @@
-<?php
-
-/*
- * Each title format is an array of arrays containing two values:
- * - type
- * - value
- *
- * Possible values for type are: 'token' and 'string'.
- * Possible values for 'value' are: any string in case that 'type' is set
- * to 'string', or allowed token values for page type in case that 'type'
- * is set to 'token'.
- *
- * Examples of valid formats:
- *
- * [
- * 'front_page' => [
- * [ 'type' => 'string', 'value' => 'Front page title and site name:'],
- * [ 'type' => 'token', 'value' => 'site_name']
- * ],
- * 'posts' => [
- * [ 'type' => 'token', 'value' => 'site_name' ],
- * [ 'type' => 'string', 'value' => ' | ' ],
- * [ 'type' => 'token', 'value' => 'post_title' ]
- * ],
- * 'pages' => [],
- * 'groups' => [],
- * 'archives' => []
- * ]
- * Custom title for given page type is created by concatenating all of the array 'value' parts.
- * Tokens are replaced with their corresponding values for current site.
- * Empty array signals that we are not overriding the default title for particular page type.
- */
-
-/**
- * Class containing utility static methods for managing SEO custom title formats.
- */
-class Jetpack_SEO_Titles {
- /**
- * Site option name used to store custom title formats.
- */
- const TITLE_FORMATS_OPTION = 'advanced_seo_title_formats';
-
- /**
- * Retrieves custom title formats from site option.
- *
- * @return array Array of custom title formats, or empty array.
- */
- public static function get_custom_title_formats() {
- if( Jetpack_SEO_Utils::is_enabled_jetpack_seo() ) {
- return get_option( self::TITLE_FORMATS_OPTION, array() );
- }
-
- return array();
- }
-
- /**
- * Returns tokens that are currently supported for each page type.
- *
- * @return array Array of allowed token strings.
- */
- public static function get_allowed_tokens() {
- return array(
- 'front_page' => array( 'site_name', 'tagline' ),
- 'posts' => array( 'site_name', 'tagline', 'post_title' ),
- 'pages' => array( 'site_name', 'tagline', 'page_title' ),
- 'groups' => array( 'site_name', 'tagline', 'group_title' ),
- 'archives' => array( 'site_name', 'tagline', 'date' ),
- );
- }
-
- /**
- * Used to modify the default title with custom SEO title.
- *
- * @param string $default_title Default title for current page.
- *
- * @return string Custom title with replaced tokens or default title.
- */
- public static function get_custom_title( $default_title = '' ) {
- // Don't filter title for unsupported themes.
- if ( self::is_conflicted_theme() ) {
- return $default_title;
- }
-
- $page_type = self::get_page_type();
-
- // Keep default title if invalid page type is supplied.
- if ( empty( $page_type ) ) {
- return $default_title;
- }
-
- $title_formats = self::get_custom_title_formats();
-
- // Keep default title if user has not defined custom title for this page type.
- if ( empty( $title_formats[ $page_type ] ) ) {
- return $default_title;
- }
-
- if ( ! Jetpack_SEO_Utils::is_enabled_jetpack_seo() ) {
- return $default_title;
- }
-
- $custom_title = '';
- $format_array = $title_formats[ $page_type ];
-
- foreach ( $format_array as $item ) {
- if ( 'token' == $item['type'] ) {
- $custom_title .= self::get_token_value( $item['value'] );
- } else {
- $custom_title .= $item['value'];
- }
- }
-
- return esc_html( $custom_title );
- }
-
- /**
- * Returns string value for given token.
- *
- * @param string $token_name The token name value that should be replaced.
- *
- * @return string Token replacement for current site, or empty string for unknown token name.
- */
- public static function get_token_value( $token_name ) {
-
- switch ( $token_name ) {
- case 'site_name':
- return get_bloginfo( 'name' );
-
- case 'tagline':
- return get_bloginfo( 'description' );
-
- case 'post_title':
- case 'page_title':
- return the_title_attribute( array( 'echo' => false ) );
-
- case 'group_title':
- return single_tag_title( '', false );
-
- case 'date':
- return self::get_date_for_title();
-
- default:
- return '';
- }
- }
-
- /**
- * Returns page type for current page. We need this helper in order to determine what
- * user defined title format should be used for custom title.
- *
- * @return string|bool Type of current page or false if unsupported.
- */
- public static function get_page_type() {
-
- if ( is_front_page() ) {
- return 'front_page';
- }
-
- if ( is_category() || is_tag() || is_tax() ) {
- return 'groups';
- }
-
- if ( is_archive() && ! is_author() ) {
- return 'archives';
- }
-
- if ( is_page() ) {
- return 'pages';
- }
-
- if ( is_singular() ) {
- return 'posts';
- }
-
- return false;
- }
-
- /**
- * Returns the value that should be used as a replacement for the date token,
- * depending on the archive path specified.
- *
- * @return string Token replacement for a given date, or empty string if no date is specified.
- */
- public static function get_date_for_title() {
- // If archive year, month, and day are specified.
- if ( is_day() ) {
- return get_the_date();
- }
-
- // If archive year, and month are specified.
- if ( is_month() ) {
- return trim( single_month_title( ' ', false ) );
- }
-
- // Only archive year is specified.
- if ( is_year() ) {
- return get_query_var( 'year' );
- }
-
- return '';
- }
-
- /**
- * Checks if current theme is defining custom title that won't work nicely
- * with our custom SEO title override.
- *
- * @return bool True if current theme sets custom title, false otherwise.
- */
- public static function is_conflicted_theme() {
- /**
- * Can be used to specify a list of themes that use their own custom title format.
- *
- * If current site is using one of the themes listed as conflicting,
- * Jetpack SEO custom title formats will be disabled.
- *
- * @module seo-tools
- *
- * @since 4.4.0
- *
- * @param array List of conflicted theme names. Defaults to empty array.
- */
- $conflicted_themes = apply_filters( 'jetpack_seo_custom_title_conflicted_themes', array() );
-
- return isset( $conflicted_themes[ get_option( 'template' ) ] );
- }
-
- /**
- * Checks if a given format conforms to predefined SEO title templates.
- *
- * Every format type and token must be whitelisted.
- * @see get_allowed_tokens()
- *
- * @param array $title_formats Template of SEO title to check.
- *
- * @return bool True if the formats are valid, false otherwise.
- */
- public static function are_valid_title_formats( $title_formats ) {
- $allowed_tokens = self::get_allowed_tokens();
-
- if ( ! is_array( $title_formats ) ) {
- return false;
- }
-
- foreach ( $title_formats as $format_type => $format_array ) {
- if ( ! in_array( $format_type, array_keys( $allowed_tokens ) ) ) {
- return false;
- }
-
- if ( '' === $format_array ) {
- continue;
- }
-
- if ( ! is_array( $format_array ) ) {
- return false;
- }
-
- foreach ( $format_array as $item ) {
- if ( empty( $item['type'] ) || empty( $item['value'] ) ) {
- return false;
- }
-
- if ( 'token' == $item['type'] ) {
- if ( ! in_array( $item['value'], $allowed_tokens[ $format_type ] ) ) {
- return false;
- }
- }
- }
- }
-
- return true;
- }
-
- /**
- * Combines the previous values of title formats, stored as array in site options,
- * with the new values that are provided.
- *
- * @param array $new_formats Array containing new title formats.
- *
- * @return array $result Array of updated title formats, or empty array if no update was performed.
- */
- public static function update_title_formats( $new_formats ) {
- // Empty array signals that custom title shouldn't be used.
- $empty_formats = array(
- 'front_page' => array(),
- 'posts' => array(),
- 'pages' => array(),
- 'groups' => array(),
- 'archives' => array(),
- );
-
- $previous_formats = self::get_custom_title_formats();
-
- $result = array_merge( $empty_formats, $previous_formats, $new_formats );
-
- if ( update_option( self::TITLE_FORMATS_OPTION, $result ) ) {
- return $result;
- }
-
- return array();
- }
-}
diff --git a/plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php b/plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php
deleted file mode 100644
index b7e4362a..00000000
--- a/plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php
+++ /dev/null
@@ -1,126 +0,0 @@
-<?php
-
-/**
- * Class containing utility static methods that other SEO tools are relying on.
- */
-class Jetpack_SEO_Utils {
- /**
- * Site option name used to store front page meta description.
- */
- const FRONT_PAGE_META_OPTION = 'advanced_seo_front_page_description';
-
- /**
- * Old version of option name that was previously used under Free plan.
- */
- const GRANDFATHERED_META_OPTION = 'seo_meta_description';
-
- /**
- * Used to check whether SEO tools are enabled for given site.
- *
- * @param int $site_id Optional. Defaults to current blog id if not given.
- *
- * @return bool True if SEO tools are enabled, false otherwise.
- */
- public static function is_enabled_jetpack_seo( $site_id = 0 ) {
- /**
- * Can be used by SEO plugin authors to disable the conflicting output of SEO Tools.
- *
- * @module seo-tools
- *
- * @since 5.0.0
- *
- * @param bool True if SEO Tools should be disabled, false otherwise.
- */
- if ( apply_filters( 'jetpack_disable_seo_tools', false ) ) {
- return false;
- }
-
- if ( function_exists( 'has_any_blog_stickers' ) ) {
- // For WPCOM sites
- if ( empty( $site_id ) ) {
- $site_id = get_current_blog_id();
- }
-
- return has_any_blog_stickers( array( 'business-plan', 'ecommerce-plan' ), $site_id );
- }
-
- // For all Jetpack sites
- return true;
- }
-
- /**
- * Checks if this option was set while it was still available under free plan.
- *
- * @return bool True if we should enable grandfathering, false otherwise.
- */
- public static function has_grandfathered_front_page_meta() {
- return ! self::is_enabled_jetpack_seo() && get_option( self::GRANDFATHERED_META_OPTION );
- }
-
- /**
- * Returns front page meta description for current site.
- *
- * Since we allowed non-business users to set Front page meta description for some time,
- * before bundling it with other SEO tools features that require a business plan,
- * we are supporting grandfathering here.
- *
- * @return string Front page meta description string or empty string.
- */
- public static function get_front_page_meta_description() {
- if ( self::is_enabled_jetpack_seo() ) {
- $front_page_meta = get_option( self::FRONT_PAGE_META_OPTION );
- return $front_page_meta ? $front_page_meta : get_option( self::GRANDFATHERED_META_OPTION, '' );
- }
-
- // Support grandfathering for non-business users.
- return get_option( self::GRANDFATHERED_META_OPTION, '' );
- }
-
- /**
- * Updates the site option value for front page meta description.
- *
- * We are taking care to update the correct option, in case the value is grandfathered for current site.
- *
- * @param $value string New value for front page meta description.
- *
- * @return string Saved value, or empty string if no update was performed.
- */
- public static function update_front_page_meta_description( $value ) {
- $front_page_description = sanitize_text_field( $value );
-
- /**
- * Can be used to limit the lenght of front page meta description.
- *
- * @module seo-tools
- *
- * @since 4.4.0
- *
- * @param int Maximum length of front page meta description. Defaults to 300.
- */
- $description_max_length = apply_filters( 'jetpack_seo_front_page_description_max_length', 300 );
-
- if ( function_exists( 'mb_substr' ) ) {
- $front_page_description = mb_substr( $front_page_description, 0, $description_max_length );
- } else {
- $front_page_description = substr( $front_page_description, 0, $description_max_length );
- }
-
- $can_set_meta = self::is_enabled_jetpack_seo();
- $grandfathered_meta_option = get_option( self::GRANDFATHERED_META_OPTION );
- $has_old_meta = ! empty( $grandfathered_meta_option );
- $option_name = self::has_grandfathered_front_page_meta() ? self::GRANDFATHERED_META_OPTION : self::FRONT_PAGE_META_OPTION;
-
- $did_update = update_option( $option_name, $front_page_description );
-
- if ( $did_update && $has_old_meta && $can_set_meta ) {
- // Delete grandfathered option if user has switched to Business plan and updated meta description.
- delete_option( 'seo_meta_description' );
- }
-
- if ( $did_update ) {
- return $front_page_description;
- }
-
- return '';
- }
-}
diff --git a/plugins/jetpack/modules/seo-tools/jetpack-seo.php b/plugins/jetpack/modules/seo-tools/jetpack-seo.php
deleted file mode 100644
index d8bccd46..00000000
--- a/plugins/jetpack/modules/seo-tools/jetpack-seo.php
+++ /dev/null
@@ -1,206 +0,0 @@
-<?php
-
-/**
- * An SEO expert walks into a bar, bars, pub, public house, Irish pub, drinks, beer, wine, liquor, Grey Goose, Cristal...
- */
-class Jetpack_SEO {
- public function __construct() {
- add_action( 'init', array( $this, 'init' ) );
- }
-
- public function init() {
- /**
- * Can be used to prevent SEO tools from inserting custom meta tags.
- *
- * @module seo-tools
- *
- * @since 4.4.0
- *
- * @param bool true Should Jetpack's SEO Meta Tags be enabled. Defaults to true.
- */
- if ( apply_filters( 'jetpack_seo_meta_tags_enabled', true ) ) {
- add_action( 'wp_head', array( $this, 'meta_tags' ) );
-
- // Add support for editing page excerpts in pages, regardless of theme support.
- add_post_type_support( 'page', 'excerpt' );
- }
-
- /**
- * Can be used to prevent SEO tools form modifying site titles.
- *
- * @module seo-tools
- *
- * @since 4.4.0
- *
- * @param bool true Should Jetpack SEO modify site titles. Defaults to true.
- */
- if ( apply_filters( 'jetpack_seo_custom_titles', true ) ) {
- // Overwrite page title with custom SEO meta title for themes that support title-tag.
- add_filter( 'pre_get_document_title', array( 'Jetpack_SEO_Titles', 'get_custom_title' ) );
-
- // Add overwrite support for themes that don't support title-tag.
- add_filter( 'wp_title', array( 'Jetpack_SEO_Titles', 'get_custom_title' ) );
- }
-
- add_filter( 'jetpack_open_graph_tags', array( $this, 'set_custom_og_tags' ) );
- }
-
- private function get_authors() {
- global $wp_query;
-
- $authors = array();
-
- foreach ( $wp_query->posts as $post ) {
- $authors[] = get_the_author_meta( 'display_name', (int) $post->post_author );
- }
-
- $authors = array_unique( $authors );
-
- return $authors;
- }
-
- public function set_custom_og_tags( $tags ) {
- $custom_title = Jetpack_SEO_Titles::get_custom_title();
-
- if ( ! empty( $custom_title ) ) {
- $tags['og:title'] = $custom_title;
- }
-
- $post_custom_description = Jetpack_SEO_Posts::get_post_custom_description( get_post() );
- $front_page_meta = Jetpack_SEO_Utils::get_front_page_meta_description();
-
- if ( is_front_page() && ! empty( $front_page_meta ) ) {
- $tags['og:description'] = $front_page_meta;
- } else {
- if ( ! empty( $post_custom_description ) ) {
- $tags['og:description'] = $post_custom_description;
- }
- }
-
- return $tags;
- }
-
- public function meta_tags() {
- global $wp_query;
-
- $period = '';
- $template = '';
- $meta = array();
-
- /**
- * Can be used to specify a list of themes that set their own meta tags.
- *
- * If current site is using one of the themes listed as conflicting, inserting Jetpack SEO
- * meta tags will be prevented.
- *
- * @module seo-tools
- *
- * @since 4.4.0
- *
- * @param array List of conflicted theme names. Defaults to empty array.
- */
- $conflicted_themes = apply_filters( 'jetpack_seo_meta_tags_conflicted_themes', array() );
-
- if ( isset( $conflicted_themes[ get_option( 'template' ) ] ) ) {
- return;
- }
-
- $front_page_meta = Jetpack_SEO_Utils::get_front_page_meta_description();
- $description = $front_page_meta ? $front_page_meta : get_bloginfo( 'description' );
- $meta['description'] = trim( $description );
-
- // Try to target things if we're on a "specific" page of any kind.
- if ( is_singular() ) {
- // Business users can overwrite the description.
- if ( ! ( is_front_page() && Jetpack_SEO_Utils::get_front_page_meta_description() ) ) {
- $description = Jetpack_SEO_Posts::get_post_description( get_post() );
-
- if ( $description ) {
- $description = wp_trim_words( strip_shortcodes( wp_kses( $description, array() ) ) );
- $meta['description'] = $description;
- }
- }
-
- } elseif ( is_author() ) {
- $obj = get_queried_object();
-
- $meta['description'] = sprintf(
- _x( 'Read all of the posts by %1$s on %2$s', 'Read all of the posts by Author Name on Blog Title', 'jetpack' ),
- $obj->display_name,
- get_bloginfo( 'title' )
- );
- } elseif ( is_tag() || is_category() || is_tax() ) {
- $obj = get_queried_object();
-
- $description = get_term_field( 'description', $obj->term_id, $obj->taxonomy, 'raw' );
-
- if ( ! is_wp_error( $description ) && '' != $description ) {
- $meta['description'] = wp_trim_words( $description );
- } else {
- $authors = $this->get_authors();
-
- $meta['description'] = wp_sprintf(
- _x( 'Posts about %1$s written by %2$l', 'Posts about Category written by John and Bob', 'jetpack' ),
- single_term_title( '', false ),
- $authors
- );
- }
- } elseif ( is_date() ) {
- if ( is_year() ) {
- $period = get_query_var( 'year' );
-
- $template = _nx(
- '%1$s post published by %2$l in the year %3$s', // singular
- '%1$s posts published by %2$l in the year %3$s', // plural
- count( $wp_query->posts ), // number
- '10 posts published by John in the year 2012', // context
- 'jetpack'
- );
- } elseif ( is_month() ) {
- $period = date( 'F Y', mktime( 0, 0, 0, get_query_var( 'monthnum' ), 1, get_query_var( 'year' ) ) );
-
- $template = _nx(
- '%1$s post published by %2$l during %3$s', // singular
- '%1$s posts published by %2$l during %3$s', // plural
- count( $wp_query->posts ), // number
- '10 posts publishes by John during May 2012', // context
- 'jetpack'
- );
- } elseif ( is_day() ) {
- $period = date(
- 'F j, Y',
- mktime( 0, 0, 0, get_query_var( 'monthnum' ), get_query_var( 'day' ), get_query_var( 'year' ) )
- );
-
- $template = _nx(
- '%1$s post published by %2$l on %3$s', // singular
- '%1$s posts published by %2$l on %3$s', // plural
- count( $wp_query->posts ), // number
- '10 posts published by John on May 30, 2012', // context
- 'jetpack'
- );
- }
-
- $authors = $this->get_authors();
- $meta['description'] = wp_sprintf( $template, count( $wp_query->posts ), $authors, $period );
- }
-
- /**
- * Can be used to edit the default SEO tools meta tags.
- *
- * @module seo-tools
- *
- * @since 4.4.0
- *
- * @param array Array that consists of meta name and meta content pairs.
- */
- $meta = apply_filters( 'jetpack_seo_meta_tags', $meta );
-
- // Output them
- foreach ( $meta as $name => $content ) {
- if ( ! empty( $content ) ) {
- echo '<meta name="' . esc_attr( $name ) . '" content="' . esc_attr( $content ) . '" />' . "\n";
- }
- }
- }
-}
diff --git a/plugins/jetpack/modules/sharedaddy.php b/plugins/jetpack/modules/sharedaddy.php
index 223f0db9..9bbebd66 100644
--- a/plugins/jetpack/modules/sharedaddy.php
+++ b/plugins/jetpack/modules/sharedaddy.php
@@ -1,7 +1,7 @@
<?php
/**
* Module Name: Sharing
- * Module Description: Add Twitter, Facebook and Google+ buttons at the bottom of each post, making it easy for visitors to share your content.
+ * Module Description: Add Twitter and Facebook buttons at the bottom of each post, making it easy for visitors to share your content.
* Sort Order: 7
* Recommendation Order: 6
* First Introduced: 1.1
diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.css b/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.css
index 2c0eab17..2ae885a9 100644
--- a/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.css
+++ b/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.css
@@ -1,453 +1,459 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
/**
* Sharedaddy Admin Styles
*/
-
#services-config {
- min-width: 700px;
- width: 100%;
- float: right;
+ min-width: 700px;
+ width: 100%;
+ float: right;
}
#services-config h3 {
- font-weight: normal;
- font-size: 15px;
- margin: 0;
- padding: 8px 10px;
- overflow: hidden;
- white-space: nowrap;
- color: #464646;
+ font-weight: normal;
+ font-size: 15px;
+ margin: 0;
+ padding: 8px 10px;
+ overflow: hidden;
+ white-space: nowrap;
+ color: #464646;
}
#available-services, #enabled-services, #live-preview {
- padding: 0;
- width: 100%;
- padding-top: 20px;
- border-spacing: 0;
+ padding: 0;
+ width: 100%;
+ padding-top: 20px;
+ border-spacing: 0;
}
#enabled-services .ui-sortable {
- min-height: 50px;
+ min-height: 50px;
}
#enabled-services {
- padding-bottom: 20px;
+ padding-bottom: 20px;
}
#available-services, #enabled-services {
- border-bottom: 2px solid #cccccc;
+ border-bottom: 2px solid #cccccc;
}
#live-preview {
- border-bottom: 1px solid #dcdcde;
- padding-bottom: 60px;
+ border-bottom: 1px solid #dcdcde;
+ padding-bottom: 60px;
}
#available-services h3, #enabled-services h3, #live-preview h3 {
- padding: 0px;
- margin-top: 0px;
- margin-bottom: 1em;
+ padding: 0px;
+ margin-top: 0px;
+ margin-bottom: 1em;
}
body.settings_page_sharing .description {
- width: 180px;
- vertical-align: top;
+ width: 180px;
+ vertical-align: top;
}
body.settings_page_sharing .description p {
- font-size: 13px;
- font-style: italic;
+ font-size: 13px;
+ font-style: italic;
}
body.settings_page_sharing .services {
- padding: 0px 20px;
- vertical-align: top;
+ padding: 0px 20px;
+ vertical-align: top;
}
body.settings_page_sharing .services ul li {
- float: right;
- cursor: move;
+ float: right;
+ cursor: move;
}
body.settings_page_sharing .services ul li.divider {
- border: none;
- padding: 0;
- background: none;
- cursor: default;
+ border: none;
+ padding: 0;
+ background: none;
+ cursor: default;
}
body.settings_page_sharing ul.services-hidden {
- margin-bottom: 0;
+ margin-bottom: 0;
}
/* Generic style */
#available-services .service, #enabled-services .service {
- margin-left: 10px;
- padding: 5px 5px 5px 10px;
- border-radius: 3px;
- border: 1px solid #bbb;
- background: #f8f8f8;
- background-repeat: no-repeat;
- background-position: center center;
+ margin-left: 10px;
+ padding: 5px 5px 5px 10px;
+ border-radius: 3px;
+ border: 1px solid #bbb;
+ background: #f8f8f8;
+ background-repeat: no-repeat;
+ background-position: center center;
}
#available-services .service:hover, #enabled-services .service:hover {
- background: #fff;
- border: 1px solid #bbb;
- box-shadow: 0 1px 3px rgba(0,0,0,0.2);
+ background: #fff;
+ border: 1px solid #bbb;
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
#available-services .service.share-deprecated,
#enabled-services .service.share-deprecated {
- opacity: 0.5;
- padding: 5px;
- text-decoration: line-through;
+ opacity: 0.5;
+ padding: 5px;
+ text-decoration: line-through;
}
#available-services .service.share-deprecated {
- display: none;
+ display: none;
}
/* Generic style icons */
li.service span:before {
- color: #555;
- display: inline-block;
- -webkit-font-smoothing: antialiased;
- font: normal 18px/1 'social-logos';
- vertical-align: top;
- position: relative;
- top: 1px;
- margin-left: 3px;
- width: 16px;
- height: 16px;
- text-align: center;
+ color: #555;
+ display: inline-block;
+ -webkit-font-smoothing: antialiased;
+ font: normal 18px/1 "social-logos";
+ vertical-align: top;
+ position: relative;
+ top: 1px;
+ margin-left: 3px;
+ width: 16px;
+ height: 16px;
+ text-align: center;
}
+
li.service.share-print span:before {
- content: '\f469';
+ content: "\f469";
}
+
li.service.share-digg span:before {
- content: '\f221';
+ content: "\f221";
}
+
li.service.share-email span:before {
- content: '\f410';
+ content: "\f410";
}
+
li.service.share-linkedin span:before {
- content: '\f207';
+ content: "\f207";
}
+
li.service.share-twitter span:before {
- content: '\f202';
+ content: "\f202";
}
+
li.service.share-reddit span:before {
- content: '\f222';
+ content: "\f222";
}
+
li.service.share-tumblr span:before {
- content: '\f214';
+ content: "\f214";
}
+
li.service.share-pocket span:before {
- content: '\f224';
+ content: "\f224";
}
+
li.service.share-pinterest span:before {
- content: '\f209';
+ content: "\f209";
}
+
li.service.share-facebook span:before {
- content: '\f203';
+ content: "\f203";
}
-li.service.share-press-this span:before { /* Fixme: remove this button in favor of reblog */
- content: '\f205';
+
+li.service.share-press-this span:before {
+ /* Fixme: remove this button in favor of reblog */
+ content: "\f205";
}
+
li.service.share-telegram span:before {
- content: '\f606';
+ content: "\f606";
}
+
li.service.share-jetpack-whatsapp span:before {
- content: '\f608';
+ content: "\f608";
}
+
li.service.share-skype span:before {
- content: '\f220';
+ content: "\f220";
}
/**
* Preview section
*/
-
body.settings_page_sharing ul.preview {
- float: right;
- margin: 0px;
+ float: right;
+ margin: 0px;
}
body.settings_page_sharing ul.preview li.preview-item, body.settings_page_sharing ul.preview li.preview-item a {
- cursor: default;
- text-decoration: none;
+ cursor: default;
+ text-decoration: none;
}
div.sd-social-icon ul.preview li.preview-item a span,
div.sd-social-icon .inner li.preview-item a span {
- display: none;
+ display: none;
}
div.sd-social-icon ul.preview li.preview-item.preview-custom a span {
- display: inline-block;
-
+ display: inline-block;
}
.services .preview li.share-custom a {
- text-decoration: none;
+ text-decoration: none;
}
.services ul li.end-fix {
- clear:both;
- float:none;
- visibility:hidden;
- padding:0;
- margin:0;
- height:20px;
- width:0;
+ clear: both;
+ float: none;
+ visibility: hidden;
+ padding: 0;
+ margin: 0;
+ height: 20px;
+ width: 0;
}
-#enabled-services h2{
- font-size:20px;
- padding-top:0px;
- font-weight: normal !important;
- color: #999;
+#enabled-services h2 {
+ font-size: 20px;
+ padding-top: 0px;
+ font-weight: normal !important;
+ color: #999;
}
body.settings_page_sharing #live-preview h2 {
- font-size:20px;
- font-weight: normal !important;
- color: #e3e3e3;
+ font-size: 20px;
+ font-weight: normal !important;
+ color: #e3e3e3;
}
body.settings_page_sharing .clearing {
- clear: both;
+ clear: both;
}
body.settings_page_sharing .options .options-left {
- float: right;
+ float: right;
}
body.settings_page_sharing .input label {
- font-size: 11px;
- line-height: 16px;
+ font-size: 11px;
+ line-height: 16px;
}
body.settings_page_sharing .advanced-form {
- padding: 10px 10px 8px 14px;
- margin-right: -24px;
- display: none;
- border-top: 1px #e3e3e3 solid;
- margin-top:4px;
+ padding: 10px 10px 8px 14px;
+ margin-right: -24px;
+ display: none;
+ border-top: 1px #e3e3e3 solid;
+ margin-top: 4px;
}
body.settings_page_sharing .utility {
- float: left;
- padding-top:10px;
- padding-left: 10px;
- font-size: 10px;
+ float: left;
+ padding-top: 10px;
+ padding-left: 10px;
+ font-size: 10px;
}
body.settings_page_sharing .advanced input[type=submit] {
- float: right;
- margin-top:10px;
- margin-left: 10px;
+ float: right;
+ margin-top: 10px;
+ margin-left: 10px;
}
.services li.dropzone {
- border: 1px dashed #999;
- border-radius: 3px;
- background: #e3e3e3;
- margin-left: 10px;
- padding: 5px;
- height: 18px;
+ border: 1px dashed #999;
+ border-radius: 3px;
+ background: #e3e3e3;
+ margin-left: 10px;
+ padding: 5px;
+ height: 18px;
}
.advanced-form .form-table th {
- width: auto !important;
+ width: auto !important;
}
.advanced-form .button-secondary {
- margin-top: 0 !important;
+ margin-top: 0 !important;
}
#hidden-drop-target {
- background: #e1e1e1;
- border: 1px solid #cdcdcd;
- width: 29%;
- padding: 10px;
- vertical-align: top;
+ background: #e1e1e1;
+ border: 1px solid #cdcdcd;
+ width: 29%;
+ padding: 10px;
+ vertical-align: top;
}
#hidden-drop-target p {
- font-size: 13px;
- font-style: italic;
- margin: 0 0 10px 0;
+ font-size: 13px;
+ font-style: italic;
+ margin: 0 0 10px 0;
}
-
/* Official button previews */
.preview li.preview-item {
- background-position: 0px 5px;
- cursor: default;
+ background-position: 0px 5px;
+ cursor: default;
}
.preview .option-smart-on {
- margin: 3px 0 0 5px;
+ margin: 3px 0 0 5px;
}
.preview-digg .option-smart-on {
- background: url(images/smart-digg.png) no-repeat top right;
- background-size: 76px 17px;
- width:76px;
- height:17px;
- margin-top: 2px;
+ background: url(../../modules/sharedaddy/images/smart-digg.png) no-repeat top right;
+ background-size: 76px 17px;
+ width: 76px;
+ height: 17px;
+ margin-top: 2px;
}
.preview-reddit .option-smart-on {
- background: url(images/smart-reddit.png) no-repeat top right;
- background-size: 104px 21px;
- width:104px;
- height:21px;
+ background: url(../../modules/sharedaddy/images/smart-reddit.png) no-repeat top right;
+ background-size: 104px 21px;
+ width: 104px;
+ height: 21px;
}
.preview-facebook .option-smart-on {
- background: url(images/smart-like.png) no-repeat top right;
- background-size: 85px 20px;
- width:85px;
- height:20px;
+ background: url(../../modules/sharedaddy/images/smart-like.png) no-repeat top right;
+ background-size: 85px 20px;
+ width: 85px;
+ height: 20px;
}
.preview-twitter .option-smart-on {
- background: url(images/smart-twitter.png?1) no-repeat top right;
- background-size: 60px 20px;
- width:60px;
- height:20px;
+ background: url(../../modules/sharedaddy/images/smart-twitter.png) no-repeat top right;
+ background-size: 60px 20px;
+ width: 60px;
+ height: 20px;
}
.preview-linkedin .option-smart-on {
- background: url(images/linkedin-smart.png) no-repeat top center;
- background-size: 99px 18px;
- width:99px;
- height:20px;
+ background: url(../../modules/sharedaddy/images/linkedin-smart.png) no-repeat top center;
+ background-size: 99px 18px;
+ width: 99px;
+ height: 20px;
}
.preview-tumblr .option-smart-on {
- background: url(images/smart-tumblr.png) no-repeat top right;
- background-size: 62px 20px;
- width: 62px;
- height: 20px;
+ background: url(../../modules/sharedaddy/images/smart-tumblr.png) no-repeat top right;
+ background-size: 62px 20px;
+ width: 62px;
+ height: 20px;
}
.preview-pinterest .option-smart-on {
- background: url(images/smart-pinterest.png) no-repeat top right;
- background-size: 39px 20px;
- width: 39px;
- height: 20px;
+ background: url(../../modules/sharedaddy/images/smart-pinterest.png) no-repeat top right;
+ background-size: 39px 20px;
+ width: 39px;
+ height: 20px;
}
.preview-pocket .option-smart-on {
- background: url(images/smart-pocket.png) no-repeat top right;
- background-size: 60px 20px;
- width: 60px;
- height: 20px;
+ background: url(../../modules/sharedaddy/images/smart-pocket.png) no-repeat top right;
+ background-size: 60px 20px;
+ width: 60px;
+ height: 20px;
}
.preview-skype .option-smart-on {
- background: url(images/smart-skype.png) no-repeat top right;
- background-size: 60px 20px;
- width: 60px;
- height: 20px;
+ background: url(../../modules/sharedaddy/images/smart-skype.png) no-repeat top right;
+ background-size: 60px 20px;
+ width: 60px;
+ height: 20px;
}
.preview-item.share-deprecated {
- opacity: 0.5;
+ opacity: 0.5;
}
.preview-item.share-deprecated a span {
- text-decoration: line-through;
+ text-decoration: line-through;
}
-@media
-(-webkit-min-device-pixel-ratio: 1.25),
-(min-resolution: 120dpi) {
- .preview-digg .option-smart-on {
- background-image: url(images/smart-digg@2x.png);
- }
+@media (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) {
+ .preview-digg .option-smart-on {
+ background-image: url(../../modules/sharedaddy/images/smart-digg@2x.png);
+ }
- .preview-reddit .option-smart-on {
- background-image: url(images/smart-reddit@2x.png);
- }
+ .preview-reddit .option-smart-on {
+ background-image: url(../../modules/sharedaddy/images/smart-reddit@2x.png);
+ }
- .preview-facebook .option-smart-on {
- background-image: url(images/smart-like@2x.png);
- }
+ .preview-facebook .option-smart-on {
+ background-image: url(../../modules/sharedaddy/images/smart-like@2x.png);
+ }
- .preview-twitter .option-smart-on {
- background-image: url(images/smart-twitter@2x.png?1);
- }
+ .preview-twitter .option-smart-on {
+ background-image: url(../../modules/sharedaddy/images/smart-twitter@2x.png);
+ }
- .preview-linkedin .option-smart-on {
- background-image: url(images/linkedin-smart@2x.png);
- }
+ .preview-linkedin .option-smart-on {
+ background-image: url(../../modules/sharedaddy/images/linkedin-smart@2x.png);
+ }
- .preview-tumblr .option-smart-on {
- background-image: url(images/smart-tumblr@2x.png);
- }
+ .preview-tumblr .option-smart-on {
+ background-image: url(../../modules/sharedaddy/images/smart-tumblr@2x.png);
+ }
- .preview-pinterest .option-smart-on {
- background-image: url(images/smart-pinterest@2x.png);
- }
+ .preview-pinterest .option-smart-on {
+ background-image: url(../../modules/sharedaddy/images/smart-pinterest@2x.png);
+ }
- .preview-pocket .option-smart-on {
- background-image: url(images/smart-pocket@2x.png);
- }
+ .preview-pocket .option-smart-on {
+ background-image: url(../../modules/sharedaddy/images/smart-pocket@2x.png);
+ }
- .preview-skype .option-smart-on {
- background-image: url(images/smart-skype@2x.png);
- }
+ .preview-skype .option-smart-on {
+ background-image: url(../../modules/sharedaddy/images/smart-skype@2x.png);
+ }
}
-
/**
* Overflow sharing dialog
*/
-
.services .sharing-hidden li {
- background-color: transparent;
+ background-color: transparent;
}
.sharing-hidden li.share-end {
- clear: both;
- height: 0;
- padding: 0px !important;
- margin: 0px !important;
- width: 0;
- visibility: hidden;
- float: none;
+ clear: both;
+ height: 0;
+ padding: 0px !important;
+ margin: 0px !important;
+ width: 0;
+ visibility: hidden;
+ float: none;
}
.preview .sharing-label {
- font-weight: bold;
- border: 0;
- padding: 4px 0 0 6px;
+ font-weight: bold;
+ border: 0;
+ padding: 4px 0 0 6px;
}
#services-config a.remove {
- background: #dcdcde;
- color: #fff;
- padding: 0px 4px 2px;
- border-radius: 15px;
- -moz-border-radius: 15px;
- -webkit-border-radius: 15px;
- text-decoration: none;
- font-weight: bold;
- font-size: 10px;
+ background: #dcdcde;
+ color: #fff;
+ padding: 0px 4px 2px;
+ border-radius: 15px;
+ -moz-border-radius: 15px;
+ -webkit-border-radius: 15px;
+ text-decoration: none;
+ font-weight: bold;
+ font-size: 10px;
}
#services-config a.remove:hover {
- background: #f00;
+ background: #f00;
}
.sd-social-icon .inner a.sd-button span,
.sd-social-icon .inner a.share-icon span {
- display: inline-block;
- overflow: hidden;
- width: 0;
- text-indent: 100%;
+ display: inline-block;
+ overflow: hidden;
+ width: 0;
+ text-indent: 100%;
}
diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.min.css b/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.min.css
index 04e5ff15..c38b2041 100644
--- a/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.min.css
+++ b/plugins/jetpack/modules/sharedaddy/admin-sharing-rtl.min.css
@@ -1 +1 @@
-#services-config{min-width:700px;width:100%;float:right}#services-config h3{font-weight:400;font-size:15px;margin:0;padding:8px 10px;overflow:hidden;white-space:nowrap;color:#464646}#available-services,#enabled-services,#live-preview{padding:0;width:100%;padding-top:20px;border-spacing:0}#enabled-services .ui-sortable{min-height:50px}#enabled-services{padding-bottom:20px}#available-services,#enabled-services{border-bottom:2px solid #ccc}#live-preview{border-bottom:1px solid #dcdcde;padding-bottom:60px}#available-services h3,#enabled-services h3,#live-preview h3{padding:0;margin-top:0;margin-bottom:1em}body.settings_page_sharing .description{width:180px;vertical-align:top}body.settings_page_sharing .description p{font-size:13px;font-style:italic}body.settings_page_sharing .services{padding:0 20px;vertical-align:top}body.settings_page_sharing .services ul li{float:right;cursor:move}body.settings_page_sharing .services ul li.divider{border:none;padding:0;background:0 0;cursor:default}body.settings_page_sharing ul.services-hidden{margin-bottom:0}#available-services .service,#enabled-services .service{margin-left:10px;padding:5px 5px 5px 10px;border-radius:3px;border:1px solid #bbb;background:#f8f8f8;background-repeat:no-repeat;background-position:center center}#available-services .service:hover,#enabled-services .service:hover{background:#fff;border:1px solid #bbb;box-shadow:0 1px 3px rgba(0,0,0,.2)}#available-services .service.share-deprecated,#enabled-services .service.share-deprecated{opacity:.5;padding:5px;text-decoration:line-through}#available-services .service.share-deprecated{display:none}li.service span:before{color:#555;display:inline-block;-webkit-font-smoothing:antialiased;font:normal 18px/1 social-logos;vertical-align:top;position:relative;top:1px;margin-left:3px;width:16px;height:16px;text-align:center}li.service.share-print span:before{content:'\f469'}li.service.share-digg span:before{content:'\f221'}li.service.share-email span:before{content:'\f410'}li.service.share-linkedin span:before{content:'\f207'}li.service.share-twitter span:before{content:'\f202'}li.service.share-reddit span:before{content:'\f222'}li.service.share-tumblr span:before{content:'\f214'}li.service.share-pocket span:before{content:'\f224'}li.service.share-pinterest span:before{content:'\f209'}li.service.share-facebook span:before{content:'\f203'}li.service.share-press-this span:before{content:'\f205'}li.service.share-telegram span:before{content:'\f606'}li.service.share-jetpack-whatsapp span:before{content:'\f608'}li.service.share-skype span:before{content:'\f220'}body.settings_page_sharing ul.preview{float:right;margin:0}body.settings_page_sharing ul.preview li.preview-item,body.settings_page_sharing ul.preview li.preview-item a{cursor:default;text-decoration:none}div.sd-social-icon .inner li.preview-item a span,div.sd-social-icon ul.preview li.preview-item a span{display:none}div.sd-social-icon ul.preview li.preview-item.preview-custom a span{display:inline-block}.services .preview li.share-custom a{text-decoration:none}.services ul li.end-fix{clear:both;float:none;visibility:hidden;padding:0;margin:0;height:20px;width:0}#enabled-services h2{font-size:20px;padding-top:0;font-weight:400!important;color:#999}body.settings_page_sharing #live-preview h2{font-size:20px;font-weight:400!important;color:#e3e3e3}body.settings_page_sharing .clearing{clear:both}body.settings_page_sharing .options .options-left{float:right}body.settings_page_sharing .input label{font-size:11px;line-height:16px}body.settings_page_sharing .advanced-form{padding:10px 10px 8px 14px;margin-right:-24px;display:none;border-top:1px #e3e3e3 solid;margin-top:4px}body.settings_page_sharing .utility{float:left;padding-top:10px;padding-left:10px;font-size:10px}body.settings_page_sharing .advanced input[type=submit]{float:right;margin-top:10px;margin-left:10px}.services li.dropzone{border:1px dashed #999;border-radius:3px;background:#e3e3e3;margin-left:10px;padding:5px;height:18px}.advanced-form .form-table th{width:auto!important}.advanced-form .button-secondary{margin-top:0!important}#hidden-drop-target{background:#e1e1e1;border:1px solid #cdcdcd;width:29%;padding:10px;vertical-align:top}#hidden-drop-target p{font-size:13px;font-style:italic;margin:0 0 10px 0}.preview li.preview-item{background-position:0 5px;cursor:default}.preview .option-smart-on{margin:3px 0 0 5px}.preview-digg .option-smart-on{background:url(images/smart-digg.png) no-repeat top right;background-size:76px 17px;width:76px;height:17px;margin-top:2px}.preview-reddit .option-smart-on{background:url(images/smart-reddit.png) no-repeat top right;background-size:104px 21px;width:104px;height:21px}.preview-facebook .option-smart-on{background:url(images/smart-like.png) no-repeat top right;background-size:85px 20px;width:85px;height:20px}.preview-twitter .option-smart-on{background:url(images/smart-twitter.png?1) no-repeat top right;background-size:60px 20px;width:60px;height:20px}.preview-linkedin .option-smart-on{background:url(images/linkedin-smart.png) no-repeat top center;background-size:99px 18px;width:99px;height:20px}.preview-tumblr .option-smart-on{background:url(images/smart-tumblr.png) no-repeat top right;background-size:62px 20px;width:62px;height:20px}.preview-pinterest .option-smart-on{background:url(images/smart-pinterest.png) no-repeat top right;background-size:39px 20px;width:39px;height:20px}.preview-pocket .option-smart-on{background:url(images/smart-pocket.png) no-repeat top right;background-size:60px 20px;width:60px;height:20px}.preview-skype .option-smart-on{background:url(images/smart-skype.png) no-repeat top right;background-size:60px 20px;width:60px;height:20px}.preview-item.share-deprecated{opacity:.5}.preview-item.share-deprecated a span{text-decoration:line-through}@media (-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.preview-digg .option-smart-on{background-image:url(images/smart-digg@2x.png)}.preview-reddit .option-smart-on{background-image:url(images/smart-reddit@2x.png)}.preview-facebook .option-smart-on{background-image:url(images/smart-like@2x.png)}.preview-twitter .option-smart-on{background-image:url(images/smart-twitter@2x.png?1)}.preview-linkedin .option-smart-on{background-image:url(images/linkedin-smart@2x.png)}.preview-tumblr .option-smart-on{background-image:url(images/smart-tumblr@2x.png)}.preview-pinterest .option-smart-on{background-image:url(images/smart-pinterest@2x.png)}.preview-pocket .option-smart-on{background-image:url(images/smart-pocket@2x.png)}.preview-skype .option-smart-on{background-image:url(images/smart-skype@2x.png)}}.services .sharing-hidden li{background-color:transparent}.sharing-hidden li.share-end{clear:both;height:0;padding:0!important;margin:0!important;width:0;visibility:hidden;float:none}.preview .sharing-label{font-weight:700;border:0;padding:4px 0 0 6px}#services-config a.remove{background:#dcdcde;color:#fff;padding:0 4px 2px;border-radius:15px;-moz-border-radius:15px;-webkit-border-radius:15px;text-decoration:none;font-weight:700;font-size:10px}#services-config a.remove:hover{background:red}.sd-social-icon .inner a.sd-button span,.sd-social-icon .inner a.share-icon span{display:inline-block;overflow:hidden;width:0;text-indent:100%} \ No newline at end of file
+#services-config{float:right;min-width:700px;width:100%}#services-config h3{color:#464646;font-size:15px;font-weight:400;margin:0;overflow:hidden;padding:8px 10px;white-space:nowrap}#available-services,#enabled-services,#live-preview{border-spacing:0;padding:20px 0 0;width:100%}#enabled-services .ui-sortable{min-height:50px}#enabled-services{padding-bottom:20px}#available-services,#enabled-services{border-bottom:2px solid #ccc}#live-preview{border-bottom:1px solid #dcdcde;padding-bottom:60px}#available-services h3,#enabled-services h3,#live-preview h3{margin-bottom:1em;margin-top:0;padding:0}body.settings_page_sharing .description{vertical-align:top;width:180px}body.settings_page_sharing .description p{font-size:13px;font-style:italic}body.settings_page_sharing .services{padding:0 20px;vertical-align:top}body.settings_page_sharing .services ul li{cursor:move;float:right}body.settings_page_sharing .services ul li.divider{background:none;border:none;cursor:default;padding:0}body.settings_page_sharing ul.services-hidden{margin-bottom:0}#available-services .service,#enabled-services .service{background:#f8f8f8;background-position:50%;background-repeat:no-repeat;border:1px solid #bbb;border-radius:3px;margin-left:10px;padding:5px 5px 5px 10px}#available-services .service:hover,#enabled-services .service:hover{background:#fff;border:1px solid #bbb;box-shadow:0 1px 3px rgba(0,0,0,.2)}#available-services .service.share-deprecated,#enabled-services .service.share-deprecated{opacity:.5;padding:5px;text-decoration:line-through}#available-services .service.share-deprecated{display:none}li.service span:before{-webkit-font-smoothing:antialiased;color:#555;display:inline-block;font:normal 18px/1 social-logos;height:16px;margin-left:3px;position:relative;text-align:center;top:1px;vertical-align:top;width:16px}li.service.share-print span:before{content:"\f469"}li.service.share-digg span:before{content:"\f221"}li.service.share-email span:before{content:"\f410"}li.service.share-linkedin span:before{content:"\f207"}li.service.share-twitter span:before{content:"\f202"}li.service.share-reddit span:before{content:"\f222"}li.service.share-tumblr span:before{content:"\f214"}li.service.share-pocket span:before{content:"\f224"}li.service.share-pinterest span:before{content:"\f209"}li.service.share-facebook span:before{content:"\f203"}li.service.share-press-this span:before{content:"\f205"}li.service.share-telegram span:before{content:"\f606"}li.service.share-jetpack-whatsapp span:before{content:"\f608"}li.service.share-skype span:before{content:"\f220"}body.settings_page_sharing ul.preview{float:right;margin:0}body.settings_page_sharing ul.preview li.preview-item,body.settings_page_sharing ul.preview li.preview-item a{cursor:default;text-decoration:none}div.sd-social-icon .inner li.preview-item a span,div.sd-social-icon ul.preview li.preview-item a span{display:none}div.sd-social-icon ul.preview li.preview-item.preview-custom a span{display:inline-block}.services .preview li.share-custom a{text-decoration:none}.services ul li.end-fix{clear:both;float:none;height:20px;margin:0;padding:0;visibility:hidden;width:0}#enabled-services h2{color:#999;font-size:20px;font-weight:400!important;padding-top:0}body.settings_page_sharing #live-preview h2{color:#e3e3e3;font-size:20px;font-weight:400!important}body.settings_page_sharing .clearing{clear:both}body.settings_page_sharing .options .options-left{float:right}body.settings_page_sharing .input label{font-size:11px;line-height:16px}body.settings_page_sharing .advanced-form{border-top:1px solid #e3e3e3;display:none;margin-right:-24px;margin-top:4px;padding:10px 10px 8px 14px}body.settings_page_sharing .utility{float:left;font-size:10px;padding-left:10px;padding-top:10px}body.settings_page_sharing .advanced input[type=submit]{float:right;margin-left:10px;margin-top:10px}.services li.dropzone{background:#e3e3e3;border:1px dashed #999;border-radius:3px;height:18px;margin-left:10px;padding:5px}.advanced-form .form-table th{width:auto!important}.advanced-form .button-secondary{margin-top:0!important}#hidden-drop-target{background:#e1e1e1;border:1px solid #cdcdcd;padding:10px;vertical-align:top;width:29%}#hidden-drop-target p{font-size:13px;font-style:italic;margin:0 0 10px}.preview li.preview-item{background-position:0 5px;cursor:default}.preview .option-smart-on{margin:3px 0 0 5px}.preview-digg .option-smart-on{background:url(../../modules/sharedaddy/images/smart-digg.png) no-repeat 100% 0;background-size:76px 17px;height:17px;margin-top:2px;width:76px}.preview-reddit .option-smart-on{background:url(../../modules/sharedaddy/images/smart-reddit.png) no-repeat 100% 0;background-size:104px 21px;height:21px;width:104px}.preview-facebook .option-smart-on{background:url(../../modules/sharedaddy/images/smart-like.png) no-repeat 100% 0;background-size:85px 20px;height:20px;width:85px}.preview-twitter .option-smart-on{background:url(../../modules/sharedaddy/images/smart-twitter.png) no-repeat 100% 0;background-size:60px 20px;height:20px;width:60px}.preview-linkedin .option-smart-on{background:url(../../modules/sharedaddy/images/linkedin-smart.png) no-repeat top;background-size:99px 18px;height:20px;width:99px}.preview-tumblr .option-smart-on{background:url(../../modules/sharedaddy/images/smart-tumblr.png) no-repeat 100% 0;background-size:62px 20px;height:20px;width:62px}.preview-pinterest .option-smart-on{background:url(../../modules/sharedaddy/images/smart-pinterest.png) no-repeat 100% 0;background-size:39px 20px;height:20px;width:39px}.preview-pocket .option-smart-on{background:url(../../modules/sharedaddy/images/smart-pocket.png) no-repeat 100% 0;background-size:60px 20px;height:20px;width:60px}.preview-skype .option-smart-on{background:url(../../modules/sharedaddy/images/smart-skype.png) no-repeat 100% 0;background-size:60px 20px;height:20px;width:60px}.preview-item.share-deprecated{opacity:.5}.preview-item.share-deprecated a span{text-decoration:line-through}@media (-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.preview-digg .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-digg@2x.png)}.preview-reddit .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-reddit@2x.png)}.preview-facebook .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-like@2x.png)}.preview-twitter .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-twitter@2x.png)}.preview-linkedin .option-smart-on{background-image:url(../../modules/sharedaddy/images/linkedin-smart@2x.png)}.preview-tumblr .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-tumblr@2x.png)}.preview-pinterest .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-pinterest@2x.png)}.preview-pocket .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-pocket@2x.png)}.preview-skype .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-skype@2x.png)}}.services .sharing-hidden li{background-color:transparent}.sharing-hidden li.share-end{clear:both;float:none;height:0;margin:0!important;padding:0!important;visibility:hidden;width:0}.preview .sharing-label{border:0;font-weight:700;padding:4px 0 0 6px}#services-config a.remove{background:#dcdcde;border-radius:15px;-moz-border-radius:15px;-webkit-border-radius:15px;color:#fff;font-size:10px;font-weight:700;padding:0 4px 2px;text-decoration:none}#services-config a.remove:hover{background:red}.sd-social-icon .inner a.sd-button span,.sd-social-icon .inner a.share-icon span{display:inline-block;overflow:hidden;text-indent:100%;width:0} \ No newline at end of file
diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing.min.css b/plugins/jetpack/modules/sharedaddy/admin-sharing.min.css
index 3a47248c..43172ba7 100644
--- a/plugins/jetpack/modules/sharedaddy/admin-sharing.min.css
+++ b/plugins/jetpack/modules/sharedaddy/admin-sharing.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-#services-config{min-width:700px;width:100%;float:left}#services-config h3{font-weight:400;font-size:15px;margin:0;padding:8px 10px;overflow:hidden;white-space:nowrap;color:#464646}#available-services,#enabled-services,#live-preview{padding:0;width:100%;padding-top:20px;border-spacing:0}#enabled-services .ui-sortable{min-height:50px}#enabled-services{padding-bottom:20px}#available-services,#enabled-services{border-bottom:2px solid #ccc}#live-preview{border-bottom:1px solid #dcdcde;padding-bottom:60px}#available-services h3,#enabled-services h3,#live-preview h3{padding:0;margin-top:0;margin-bottom:1em}body.settings_page_sharing .description{width:180px;vertical-align:top}body.settings_page_sharing .description p{font-size:13px;font-style:italic}body.settings_page_sharing .services{padding:0 20px;vertical-align:top}body.settings_page_sharing .services ul li{float:left;cursor:move}body.settings_page_sharing .services ul li.divider{border:none;padding:0;background:0 0;cursor:default}body.settings_page_sharing ul.services-hidden{margin-bottom:0}#available-services .service,#enabled-services .service{margin-right:10px;padding:5px 10px 5px 5px;border-radius:3px;border:1px solid #bbb;background:#f8f8f8;background-repeat:no-repeat;background-position:center center}#available-services .service:hover,#enabled-services .service:hover{background:#fff;border:1px solid #bbb;box-shadow:0 1px 3px rgba(0,0,0,.2)}#available-services .service.share-deprecated,#enabled-services .service.share-deprecated{opacity:.5;padding:5px;text-decoration:line-through}#available-services .service.share-deprecated{display:none}li.service span:before{color:#555;display:inline-block;-webkit-font-smoothing:antialiased;font:normal 18px/1 social-logos;vertical-align:top;position:relative;top:1px;margin-right:3px;width:16px;height:16px;text-align:center}li.service.share-print span:before{content:'\f469'}li.service.share-digg span:before{content:'\f221'}li.service.share-email span:before{content:'\f410'}li.service.share-linkedin span:before{content:'\f207'}li.service.share-twitter span:before{content:'\f202'}li.service.share-reddit span:before{content:'\f222'}li.service.share-tumblr span:before{content:'\f214'}li.service.share-pocket span:before{content:'\f224'}li.service.share-pinterest span:before{content:'\f209'}li.service.share-facebook span:before{content:'\f203'}li.service.share-press-this span:before{content:'\f205'}li.service.share-telegram span:before{content:'\f606'}li.service.share-jetpack-whatsapp span:before{content:'\f608'}li.service.share-skype span:before{content:'\f220'}body.settings_page_sharing ul.preview{float:left;margin:0}body.settings_page_sharing ul.preview li.preview-item,body.settings_page_sharing ul.preview li.preview-item a{cursor:default;text-decoration:none}div.sd-social-icon .inner li.preview-item a span,div.sd-social-icon ul.preview li.preview-item a span{display:none}div.sd-social-icon ul.preview li.preview-item.preview-custom a span{display:inline-block}.services .preview li.share-custom a{text-decoration:none}.services ul li.end-fix{clear:both;float:none;visibility:hidden;padding:0;margin:0;height:20px;width:0}#enabled-services h2{font-size:20px;padding-top:0;font-weight:400!important;color:#999}body.settings_page_sharing #live-preview h2{font-size:20px;font-weight:400!important;color:#e3e3e3}body.settings_page_sharing .clearing{clear:both}body.settings_page_sharing .options .options-left{float:left}body.settings_page_sharing .input label{font-size:11px;line-height:16px}body.settings_page_sharing .advanced-form{padding:10px 14px 8px 10px;margin-left:-24px;display:none;border-top:1px #e3e3e3 solid;margin-top:4px}body.settings_page_sharing .utility{float:right;padding-top:10px;padding-right:10px;font-size:10px}body.settings_page_sharing .advanced input[type=submit]{float:left;margin-top:10px;margin-right:10px}.services li.dropzone{border:1px dashed #999;border-radius:3px;background:#e3e3e3;margin-right:10px;padding:5px;height:18px}.advanced-form .form-table th{width:auto!important}.advanced-form .button-secondary{margin-top:0!important}#hidden-drop-target{background:#e1e1e1;border:1px solid #cdcdcd;width:29%;padding:10px;vertical-align:top}#hidden-drop-target p{font-size:13px;font-style:italic;margin:0 0 10px 0}.preview li.preview-item{background-position:0 5px;cursor:default}.preview .option-smart-on{margin:3px 5px 0 0}.preview-digg .option-smart-on{background:url(images/smart-digg.png) no-repeat top left;background-size:76px 17px;width:76px;height:17px;margin-top:2px}.preview-reddit .option-smart-on{background:url(images/smart-reddit.png) no-repeat top left;background-size:104px 21px;width:104px;height:21px}.preview-facebook .option-smart-on{background:url(images/smart-like.png) no-repeat top left;background-size:85px 20px;width:85px;height:20px}.preview-twitter .option-smart-on{background:url(images/smart-twitter.png?1) no-repeat top left;background-size:60px 20px;width:60px;height:20px}.preview-linkedin .option-smart-on{background:url(images/linkedin-smart.png) no-repeat top center;background-size:99px 18px;width:99px;height:20px}.preview-tumblr .option-smart-on{background:url(images/smart-tumblr.png) no-repeat top left;background-size:62px 20px;width:62px;height:20px}.preview-pinterest .option-smart-on{background:url(images/smart-pinterest.png) no-repeat top left;background-size:39px 20px;width:39px;height:20px}.preview-pocket .option-smart-on{background:url(images/smart-pocket.png) no-repeat top left;background-size:60px 20px;width:60px;height:20px}.preview-skype .option-smart-on{background:url(images/smart-skype.png) no-repeat top left;background-size:60px 20px;width:60px;height:20px}.preview-item.share-deprecated{opacity:.5}.preview-item.share-deprecated a span{text-decoration:line-through}@media (-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.preview-digg .option-smart-on{background-image:url(images/smart-digg@2x.png)}.preview-reddit .option-smart-on{background-image:url(images/smart-reddit@2x.png)}.preview-facebook .option-smart-on{background-image:url(images/smart-like@2x.png)}.preview-twitter .option-smart-on{background-image:url(images/smart-twitter@2x.png?1)}.preview-linkedin .option-smart-on{background-image:url(images/linkedin-smart@2x.png)}.preview-tumblr .option-smart-on{background-image:url(images/smart-tumblr@2x.png)}.preview-pinterest .option-smart-on{background-image:url(images/smart-pinterest@2x.png)}.preview-pocket .option-smart-on{background-image:url(images/smart-pocket@2x.png)}.preview-skype .option-smart-on{background-image:url(images/smart-skype@2x.png)}}.services .sharing-hidden li{background-color:transparent}.sharing-hidden li.share-end{clear:both;height:0;padding:0!important;margin:0!important;width:0;visibility:hidden;float:none}.preview .sharing-label{font-weight:700;border:0;padding:4px 6px 0 0}#services-config a.remove{background:#dcdcde;color:#fff;padding:0 4px 2px;border-radius:15px;-moz-border-radius:15px;-webkit-border-radius:15px;text-decoration:none;font-weight:700;font-size:10px}#services-config a.remove:hover{background:red}.sd-social-icon .inner a.sd-button span,.sd-social-icon .inner a.share-icon span{display:inline-block;overflow:hidden;width:0;text-indent:100%} \ No newline at end of file
+#services-config{float:left;min-width:700px;width:100%}#services-config h3{color:#464646;font-size:15px;font-weight:400;margin:0;overflow:hidden;padding:8px 10px;white-space:nowrap}#available-services,#enabled-services,#live-preview{border-spacing:0;padding:20px 0 0;width:100%}#enabled-services .ui-sortable{min-height:50px}#enabled-services{padding-bottom:20px}#available-services,#enabled-services{border-bottom:2px solid #ccc}#live-preview{border-bottom:1px solid #dcdcde;padding-bottom:60px}#available-services h3,#enabled-services h3,#live-preview h3{margin-bottom:1em;margin-top:0;padding:0}body.settings_page_sharing .description{vertical-align:top;width:180px}body.settings_page_sharing .description p{font-size:13px;font-style:italic}body.settings_page_sharing .services{padding:0 20px;vertical-align:top}body.settings_page_sharing .services ul li{cursor:move;float:left}body.settings_page_sharing .services ul li.divider{background:none;border:none;cursor:default;padding:0}body.settings_page_sharing ul.services-hidden{margin-bottom:0}#available-services .service,#enabled-services .service{background:#f8f8f8;background-position:50%;background-repeat:no-repeat;border:1px solid #bbb;border-radius:3px;margin-right:10px;padding:5px 10px 5px 5px}#available-services .service:hover,#enabled-services .service:hover{background:#fff;border:1px solid #bbb;box-shadow:0 1px 3px rgba(0,0,0,.2)}#available-services .service.share-deprecated,#enabled-services .service.share-deprecated{opacity:.5;padding:5px;text-decoration:line-through}#available-services .service.share-deprecated{display:none}li.service span:before{-webkit-font-smoothing:antialiased;color:#555;display:inline-block;font:normal 18px/1 social-logos;height:16px;margin-right:3px;position:relative;text-align:center;top:1px;vertical-align:top;width:16px}li.service.share-print span:before{content:"\f469"}li.service.share-digg span:before{content:"\f221"}li.service.share-email span:before{content:"\f410"}li.service.share-linkedin span:before{content:"\f207"}li.service.share-twitter span:before{content:"\f202"}li.service.share-reddit span:before{content:"\f222"}li.service.share-tumblr span:before{content:"\f214"}li.service.share-pocket span:before{content:"\f224"}li.service.share-pinterest span:before{content:"\f209"}li.service.share-facebook span:before{content:"\f203"}li.service.share-press-this span:before{content:"\f205"}li.service.share-telegram span:before{content:"\f606"}li.service.share-jetpack-whatsapp span:before{content:"\f608"}li.service.share-skype span:before{content:"\f220"}body.settings_page_sharing ul.preview{float:left;margin:0}body.settings_page_sharing ul.preview li.preview-item,body.settings_page_sharing ul.preview li.preview-item a{cursor:default;text-decoration:none}div.sd-social-icon .inner li.preview-item a span,div.sd-social-icon ul.preview li.preview-item a span{display:none}div.sd-social-icon ul.preview li.preview-item.preview-custom a span{display:inline-block}.services .preview li.share-custom a{text-decoration:none}.services ul li.end-fix{clear:both;float:none;height:20px;margin:0;padding:0;visibility:hidden;width:0}#enabled-services h2{color:#999;font-size:20px;font-weight:400!important;padding-top:0}body.settings_page_sharing #live-preview h2{color:#e3e3e3;font-size:20px;font-weight:400!important}body.settings_page_sharing .clearing{clear:both}body.settings_page_sharing .options .options-left{float:left}body.settings_page_sharing .input label{font-size:11px;line-height:16px}body.settings_page_sharing .advanced-form{border-top:1px solid #e3e3e3;display:none;margin-left:-24px;margin-top:4px;padding:10px 14px 8px 10px}body.settings_page_sharing .utility{float:right;font-size:10px;padding-right:10px;padding-top:10px}body.settings_page_sharing .advanced input[type=submit]{float:left;margin-right:10px;margin-top:10px}.services li.dropzone{background:#e3e3e3;border:1px dashed #999;border-radius:3px;height:18px;margin-right:10px;padding:5px}.advanced-form .form-table th{width:auto!important}.advanced-form .button-secondary{margin-top:0!important}#hidden-drop-target{background:#e1e1e1;border:1px solid #cdcdcd;padding:10px;vertical-align:top;width:29%}#hidden-drop-target p{font-size:13px;font-style:italic;margin:0 0 10px}.preview li.preview-item{background-position:0 5px;cursor:default}.preview .option-smart-on{margin:3px 5px 0 0}.preview-digg .option-smart-on{background:url(../../modules/sharedaddy/images/smart-digg.png) no-repeat 0 0;background-size:76px 17px;height:17px;margin-top:2px;width:76px}.preview-reddit .option-smart-on{background:url(../../modules/sharedaddy/images/smart-reddit.png) no-repeat 0 0;background-size:104px 21px;height:21px;width:104px}.preview-facebook .option-smart-on{background:url(../../modules/sharedaddy/images/smart-like.png) no-repeat 0 0;background-size:85px 20px;height:20px;width:85px}.preview-twitter .option-smart-on{background:url(../../modules/sharedaddy/images/smart-twitter.png) no-repeat 0 0;background-size:60px 20px;height:20px;width:60px}.preview-linkedin .option-smart-on{background:url(../../modules/sharedaddy/images/linkedin-smart.png) no-repeat top;background-size:99px 18px;height:20px;width:99px}.preview-tumblr .option-smart-on{background:url(../../modules/sharedaddy/images/smart-tumblr.png) no-repeat 0 0;background-size:62px 20px;height:20px;width:62px}.preview-pinterest .option-smart-on{background:url(../../modules/sharedaddy/images/smart-pinterest.png) no-repeat 0 0;background-size:39px 20px;height:20px;width:39px}.preview-pocket .option-smart-on{background:url(../../modules/sharedaddy/images/smart-pocket.png) no-repeat 0 0;background-size:60px 20px;height:20px;width:60px}.preview-skype .option-smart-on{background:url(../../modules/sharedaddy/images/smart-skype.png) no-repeat 0 0;background-size:60px 20px;height:20px;width:60px}.preview-item.share-deprecated{opacity:.5}.preview-item.share-deprecated a span{text-decoration:line-through}@media (-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.preview-digg .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-digg@2x.png)}.preview-reddit .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-reddit@2x.png)}.preview-facebook .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-like@2x.png)}.preview-twitter .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-twitter@2x.png)}.preview-linkedin .option-smart-on{background-image:url(../../modules/sharedaddy/images/linkedin-smart@2x.png)}.preview-tumblr .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-tumblr@2x.png)}.preview-pinterest .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-pinterest@2x.png)}.preview-pocket .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-pocket@2x.png)}.preview-skype .option-smart-on{background-image:url(../../modules/sharedaddy/images/smart-skype@2x.png)}}.services .sharing-hidden li{background-color:transparent}.sharing-hidden li.share-end{clear:both;float:none;height:0;margin:0!important;padding:0!important;visibility:hidden;width:0}.preview .sharing-label{border:0;font-weight:700;padding:4px 6px 0 0}#services-config a.remove{background:#dcdcde;border-radius:15px;-moz-border-radius:15px;-webkit-border-radius:15px;color:#fff;font-size:10px;font-weight:700;padding:0 4px 2px;text-decoration:none}#services-config a.remove:hover{background:red}.sd-social-icon .inner a.sd-button span,.sd-social-icon .inner a.share-icon span{display:inline-block;overflow:hidden;text-indent:100%;width:0} \ No newline at end of file
diff --git a/plugins/jetpack/modules/sharedaddy/amp-sharing.css b/plugins/jetpack/modules/sharedaddy/amp-sharing.css
index 5d7932e0..ad739cc4 100644
--- a/plugins/jetpack/modules/sharedaddy/amp-sharing.css
+++ b/plugins/jetpack/modules/sharedaddy/amp-sharing.css
@@ -37,6 +37,15 @@ amp-social-share::before,
color: #656565;
}
+amp-social-share[type='email'] {
+ background: #e9e9e9;
+ color: #656565;
+}
+
+amp-social-share[type='email']::before {
+ content: '\f410';
+}
+
amp-social-share[type='tumblr'] {
background: #2c4762;
}
diff --git a/plugins/jetpack/modules/sharedaddy/recaptcha.php b/plugins/jetpack/modules/sharedaddy/recaptcha.php
index b5946404..8d49d91b 100644
--- a/plugins/jetpack/modules/sharedaddy/recaptcha.php
+++ b/plugins/jetpack/modules/sharedaddy/recaptcha.php
@@ -1,7 +1,14 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Google reCAPTCHA utilities, for use in the sharing feature.
+ *
+ * @package automattic/jetpack
+ */
/**
* Class that handles reCAPTCHA.
+ *
+ * @deprecated 11.0
*/
class Jetpack_ReCaptcha {
@@ -167,7 +174,7 @@ class Jetpack_ReCaptcha {
*/
public function get_verify_request_params( $response, $remote_ip ) {
return array(
- 'body' => array(
+ 'body' => array(
'secret' => $this->secret_key,
'response' => $response,
'remoteip' => $remote_ip,
diff --git a/plugins/jetpack/modules/sharedaddy/sharedaddy.php b/plugins/jetpack/modules/sharedaddy/sharedaddy.php
index 1abe651d..daef460a 100644
--- a/plugins/jetpack/modules/sharedaddy/sharedaddy.php
+++ b/plugins/jetpack/modules/sharedaddy/sharedaddy.php
@@ -1,21 +1,34 @@
<?php
-/*
-Plugin Name: Sharedaddy
-Description: The most super duper sharing tool on the interwebs.
-Version: 0.3.1
-Author: Automattic, Inc.
-Author URI: https://automattic.com/
-Plugin URI: https://en.blog.wordpress.com/2010/08/24/more-ways-to-share/
-*/
+/**
+ * Jetpack's Sharing feature, nee Sharedaddy.
+ * The most super duper sharing tool on the interwebs.
+ *
+ * @package automattic/jetpack
+ */
-require_once plugin_dir_path( __FILE__ ).'sharing.php';
+// Set up Sharing in wp-admin.
+require_once plugin_dir_path( __FILE__ ) . 'sharing.php';
+/**
+ * Send an email via the Email sharing button.
+ *
+ * @param array $data Array of information about the shared message.
+ *
+ * @return void
+ *
+ * @deprecated 11.0
+ */
function sharing_email_send_post( $data ) {
$content = sharing_email_send_post_content( $data );
// Borrowed from wp_mail();
- $sitename = strtolower( $_SERVER['SERVER_NAME'] );
- if ( substr( $sitename, 0, 4 ) == 'www.' ) {
+
+ if ( empty( $_SERVER['SERVER_NAME'] ) ) {
+ return;
+ }
+
+ $sitename = strtolower( sanitize_text_field( wp_unslash( $_SERVER['SERVER_NAME'] ) ) );
+ if ( substr( $sitename, 0, 4 ) === 'www.' ) {
$sitename = substr( $sitename, 4 );
}
@@ -23,7 +36,7 @@ function sharing_email_send_post( $data ) {
$from_email = apply_filters( 'wp_mail_from', 'wordpress@' . $sitename );
if ( ! empty( $data['name'] ) ) {
- $s_name = (string) $data['name'];
+ $s_name = (string) $data['name'];
$name_needs_encoding_regex =
'/[' .
// SpamAssasin's list of characters which "need MIME" encoding
@@ -41,10 +54,11 @@ function sharing_email_send_post( $data ) {
mb_convert_encoding( $data['name'], 'ASCII' ) !== $s_name;
if ( $needs_encoding ) {
- $data['name'] = sprintf( '=?UTF-8?B?%s?=', base64_encode( $data['name'] ) );
+ $data['name'] = sprintf( '=?UTF-8?B?%s?=', base64_encode( $data['name'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
}
}
+ $headers = array();
$headers[] = sprintf( 'From: %1$s <%2$s>', $data['name'], $from_email );
$headers[] = sprintf( 'Reply-To: %1$s <%2$s>', $data['name'], $data['source'] );
@@ -65,44 +79,78 @@ function sharing_email_send_post( $data ) {
wp_mail( $data['target'], $subject, $content, $headers );
}
-
-/* Checks for spam using akismet if available. */
-/* Return $data as it if email about to be send out is not spam. */
+/**
+ * Checks for spam using Akismet if available.
+ * Return $data as it if email about to be send out is not spam.
+ *
+ * @param array $data Array of information about the shared message.
+ *
+ * @return array $data
+ *
+ * @deprecated 11.0
+ */
function sharing_email_check_for_spam_via_akismet( $data ) {
- if ( ! Jetpack::is_akismet_active() )
+ if ( ! Jetpack::is_akismet_active() ) {
return $data;
+ }
// Prepare the body_request for akismet
$body_request = array(
- 'blog' => get_option( 'home' ),
- 'permalink' => $data['sharing_source']->get_share_url( $data['post']->ID ),
- 'comment_type' => 'share',
- 'comment_author' => $data['name'],
- 'comment_author_email' => $data['source'],
- 'comment_content' => sharing_email_send_post_content( $data ),
- 'user_agent' => ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : null ),
- );
+ 'blog' => get_option( 'home' ),
+ 'permalink' => $data['sharing_source']->get_share_url( $data['post']->ID ),
+ 'comment_type' => 'share',
+ 'comment_author' => $data['name'],
+ 'comment_author_email' => $data['source'],
+ 'comment_content' => sharing_email_send_post_content( $data ),
+ 'user_agent' => ( isset( $_SERVER['HTTP_USER_AGENT'] )
+ ? filter_var( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) )
+ : null
+ ),
+ );
if ( method_exists( 'Akismet', 'http_post' ) ) {
- $body_request['user_ip'] = Akismet::get_ip_address();
- $response = Akismet::http_post( build_query( $body_request ), 'comment-check' );
+ $body_request['user_ip'] = Akismet::get_ip_address();
+ $response = Akismet::http_post( build_query( $body_request ), 'comment-check' );
} else {
global $akismet_api_host, $akismet_api_port;
- $body_request['user_ip'] = ( isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : null );
- $response = akismet_http_post( build_query( $body_request ), $akismet_api_host, '/1.1/comment-check', $akismet_api_port );
+ $body_request['user_ip'] = ( isset( $_SERVER['REMOTE_ADDR'] )
+ ? filter_var( wp_unslash( $_SERVER['REMOTE_ADDR'] ) )
+ : null
+ );
+ $response = akismet_http_post( build_query( $body_request ), $akismet_api_host, '/1.1/comment-check', $akismet_api_port );
}
- // The Response is spam lets not send the email.
- if ( ! empty( $response ) && isset( $response[1] ) && 'true' == trim( $response[1] ) ) { // 'true' is spam
+ /*
+ * The Response is spam lets not send the email.
+ * 'true' is spam
+ */
+ if (
+ ! empty( $response )
+ && isset( $response[1] )
+ && 'true' == trim( $response[1] ) // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- response comes from the Akismet API.
+ ) {
return false; // don't send the email
}
return $data;
}
+/**
+ * Content of the emails sent to the target email address.
+ *
+ * @param array $data Array of information about the shared message.
+ *
+ * @return string $content
+ *
+ * @deprecated 11.0
+ */
function sharing_email_send_post_content( $data ) {
- /* translators: included in email when post is shared via email. First item is sender's name. Second is sender's email address. */
- $content = sprintf( __( '%1$s (%2$s) thinks you may be interested in the following post:', 'jetpack' ), $data['name'], $data['source'] );
+ $content = sprintf(
+ /* translators: included in email when post is shared via email. First item is sender's name. Second is sender's email address. */
+ __( '%1$s (%2$s) thinks you may be interested in the following post:', 'jetpack' ),
+ $data['name'],
+ $data['source']
+ );
$content .= "\n\n";
// Make sure to pass the title and URL through the normal sharing filters.
$content .= $data['sharing_source']->get_share_title( $data['post']->ID ) . "\n";
@@ -110,6 +158,11 @@ function sharing_email_send_post_content( $data ) {
return $content;
}
+/**
+ * Add a meta box to the post editing screen for sharing.
+ *
+ * @return void
+ */
function sharing_add_meta_box() {
global $post;
if ( empty( $post ) ) { // If a current post is not defined, such as when editing a comment.
@@ -142,13 +195,19 @@ function sharing_add_meta_box() {
*/
$title = apply_filters( 'sharing_meta_box_title', __( 'Sharing', 'jetpack' ) );
if ( $post->ID !== get_option( 'page_for_posts' ) ) {
- foreach( $post_types as $post_type ) {
+ foreach ( $post_types as $post_type ) {
add_meta_box( 'sharing_meta', $title, 'sharing_meta_box_content', $post_type, 'side', 'default', array( '__back_compat_meta_box' => true ) );
}
}
}
-
+/**
+ * Content of the meta box.
+ *
+ * @param WP_Post $post The post to share.
+ *
+ * @return void
+ */
function sharing_meta_box_content( $post ) {
/**
* Fires before the sharing meta box content.
@@ -165,8 +224,8 @@ function sharing_meta_box_content( $post ) {
<p>
<label for="enable_post_sharing">
- <input type="checkbox" name="enable_post_sharing" id="enable_post_sharing" value="1" <?php checked( !$disabled ); ?>>
- <?php _e( 'Show sharing buttons.' , 'jetpack'); ?>
+ <input type="checkbox" name="enable_post_sharing" id="enable_post_sharing" value="1" <?php checked( ! $disabled ); ?>>
+ <?php esc_html_e( 'Show sharing buttons.', 'jetpack' ); ?>
</label>
<input type="hidden" name="sharing_status_hidden" value="1" />
</p>
@@ -180,47 +239,84 @@ function sharing_meta_box_content( $post ) {
* @since 2.2.0
*
* @param WP_Post $post The post to share.
- */
+ */
do_action( 'end_sharing_meta_box_content', $post );
}
+/**
+ * Save new sharing status in post meta in the meta box.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return int
+ */
function sharing_meta_box_save( $post_id ) {
- if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return $post_id;
+ }
- // Record sharing disable
- if ( isset( $_POST['post_type'] ) && ( $post_type_object = get_post_type_object( $_POST['post_type'] ) ) && $post_type_object->public ) {
- if ( current_user_can( 'edit_post', $post_id ) ) {
- if ( isset( $_POST['sharing_status_hidden'] ) ) {
- if ( !isset( $_POST['enable_post_sharing'] ) ) {
- update_post_meta( $post_id, 'sharing_disabled', 1 );
- } else {
- delete_post_meta( $post_id, 'sharing_disabled' );
- }
- }
+ if ( ! isset( $_POST['post_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation.
+ return $post_id;
+ }
+
+ $post_type_object = get_post_type_object( sanitize_key( $_POST['post_type'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation.
+
+ // Record sharing disable.
+ if (
+ $post_type_object->public
+ && current_user_can( 'edit_post', $post_id )
+ && isset( $_POST['sharing_status_hidden'] ) // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation.
+ ) {
+ if ( ! isset( $_POST['enable_post_sharing'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation.
+ update_post_meta( $post_id, 'sharing_disabled', 1 );
+ } else {
+ delete_post_meta( $post_id, 'sharing_disabled' );
}
}
- return $post_id;
+ return $post_id;
}
+/**
+ * If Sharing is disabled, disable the meta box.
+ *
+ * @param bool $protected Whether the key is considered protected.
+ * @param string $meta_key Metadata key.
+ *
+ * @return bool
+ */
function sharing_meta_box_protected( $protected, $meta_key ) {
- if ( 'sharing_disabled' == $meta_key )
+ if ( 'sharing_disabled' === $meta_key ) {
$protected = true;
+ }
return $protected;
}
-
add_filter( 'is_protected_meta', 'sharing_meta_box_protected', 10, 2 );
+/**
+ * Add link to sharing settings in the Plugins screen.
+ *
+ * @param array $links An array of plugin action links.
+ *
+ * @return array
+ */
function sharing_plugin_settings( $links ) {
- $settings_link = '<a href="options-general.php?page=sharing.php">'.__( 'Settings', 'jetpack' ).'</a>';
+ $settings_link = '<a href="options-general.php?page=sharing.php">' . __( 'Settings', 'jetpack' ) . '</a>';
array_unshift( $links, $settings_link );
return $links;
}
-function sharing_add_plugin_settings($links, $file) {
- if ( $file == basename( dirname( __FILE__ ) ).'/'.basename( __FILE__ ) ) {
+/**
+ * Add links to settings and support in the plugin row.
+ *
+ * @param array $links An array of the plugin's metadata, including the version, author, author URI, and plugin URI.
+ * @param string $file Path to the plugin file relative to the plugins directory.
+ *
+ * @return array
+ */
+function sharing_add_plugin_settings( $links, $file ) {
+ if ( $file === basename( __DIR__ ) . '/' . basename( __FILE__ ) ) {
$links[] = '<a href="options-general.php?page=sharing.php">' . __( 'Settings', 'jetpack' ) . '</a>';
$links[] = '<a href="https://support.wordpress.com/sharing/" rel="noopener noreferrer" target="_blank">' . __( 'Support', 'jetpack' ) . '</a>';
}
@@ -228,17 +324,23 @@ function sharing_add_plugin_settings($links, $file) {
return $links;
}
+/**
+ * Disable sharing on the frontend if disabled in the admin.
+ *
+ * @return void
+ */
function sharing_init() {
if ( Jetpack_Options::get_option_and_ensure_autoload( 'sharedaddy_disable_resources', '0' ) ) {
- add_filter( 'sharing_js', 'sharing_disable_js' );
+ add_filter( 'sharing_js', '__return_false' );
remove_action( 'wp_head', 'sharing_add_header', 1 );
}
}
-function sharing_disable_js() {
- return false;
-}
-
+/**
+ * Add settings to disable CSS and JS normally enqueued by our feature.
+ *
+ * @return void
+ */
function sharing_global_resources() {
$disable = get_option( 'sharedaddy_disable_resources' );
?>
@@ -248,7 +350,7 @@ function sharing_global_resources() {
<?php
printf(
'<input id="disable_css" type="checkbox" name="disable_resources"%1$s /> <small><em>%2$s</em></small>',
- ( 1 == $disable ) ? ' checked="checked"' : '', // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
+ ( 1 == $disable ) ? ' checked="checked"' : '', // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
esc_html__( 'Advanced. If this option is checked, you must include these files in your theme manually for the sharing links to work.', 'jetpack' )
);
?>
@@ -257,8 +359,13 @@ function sharing_global_resources() {
<?php
}
+/**
+ * Save settings to disable CSS and JS normally enqueued by our feature.
+ *
+ * @return void
+ */
function sharing_global_resources_save() {
- update_option( 'sharedaddy_disable_resources', isset( $_POST['disable_resources'] ) ? 1 : 0 );
+ update_option( 'sharedaddy_disable_resources', isset( $_POST['disable_resources'] ) ? 1 : 0 ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce handling is handled for all elements at once.
}
/**
@@ -267,6 +374,8 @@ function sharing_global_resources_save() {
* Supports legacy RECAPTCHA_PUBLIC_KEY or RECAPTCHA_SITE_KEY.
*
* @return string
+ *
+ * @deprecated 11.0
*/
function sharing_recaptcha_site_key() {
if ( ! defined( 'RECAPTCHA_PUBLIC_KEY' ) && ! defined( 'RECAPTCHA_SITE_KEY' ) ) {
@@ -286,6 +395,8 @@ function sharing_recaptcha_site_key() {
* Supports legacy RECAPTCHA_PRIVATE_KEY or RECAPTCHA_SECRET_KEY.
*
* @return string
+ *
+ * @deprecated 11.0
*/
function sharing_recaptcha_secret_key() {
if ( ! defined( 'RECAPTCHA_PRIVATE_KEY' ) && ! defined( 'RECAPTCHA_SECRET_KEY' ) ) {
@@ -300,19 +411,44 @@ function sharing_recaptcha_secret_key() {
}
+/**
+ * Contents of a reCAPTCHA box.
+ *
+ * @return void
+ *
+ * @deprecated 11.0
+ */
function sharing_email_dialog() {
require_once plugin_dir_path( __FILE__ ) . 'recaptcha.php';
- $recaptcha = new Jetpack_ReCaptcha( sharing_recaptcha_site_key(), sharing_recaptcha_secret_key(), array( 'script_lazy' => true ) );
- echo $recaptcha->get_recaptcha_html(); // xss ok
+ $recaptcha = new Jetpack_ReCaptcha(
+ sharing_recaptcha_site_key(),
+ sharing_recaptcha_secret_key(),
+ array( 'script_lazy' => true )
+ );
+ echo $recaptcha->get_recaptcha_html(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in method.
}
-function sharing_email_check( $true, $post, $data ) {
+/**
+ * Short-circuit the email sharing button based on the results of reCAPTCHA.
+ *
+ * @param bool $true Should we check if the message isn't spam.
+ * @param object $post Post information.
+ * @param array $data Information about the shared message.
+ *
+ * @deprecated 11.0
+ */
+function sharing_email_check( $true, $post, $data ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
require_once plugin_dir_path( __FILE__ ) . 'recaptcha.php';
- $recaptcha = new Jetpack_ReCaptcha( sharing_recaptcha_site_key(), sharing_recaptcha_secret_key(), array( 'script_lazy' => true ) );
- $response = ! empty( $_POST['g-recaptcha-response'] ) ? $_POST['g-recaptcha-response'] : '';
- $result = $recaptcha->verify( $response, $_SERVER['REMOTE_ADDR'] );
+ $recaptcha = new Jetpack_ReCaptcha( sharing_recaptcha_site_key(), sharing_recaptcha_secret_key(), array( 'script_lazy' => true ) );
+ $response = ! empty( $_POST['g-recaptcha-response'] ) // phpcs:ignore WordPress.Security.NonceVerification.Missing -- we do not change anything on the site based on that.
+ ? filter_var( wp_unslash( $_POST['g-recaptcha-response'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing -- we do not change anything on the site based on that.
+ : '';
+ $remote_addr = ! empty( $_SERVER['REMOTE_ADDR'] )
+ ? filter_var( wp_unslash( $_SERVER['REMOTE_ADDR'] ) )
+ : '';
+ $result = $recaptcha->verify( $response, $remote_addr );
return ( true === $result );
}
@@ -321,14 +457,7 @@ add_action( 'init', 'sharing_init' );
add_action( 'add_meta_boxes', 'sharing_add_meta_box' );
add_action( 'save_post', 'sharing_meta_box_save' );
add_action( 'edit_attachment', 'sharing_meta_box_save' );
-add_action( 'sharing_email_send_post', 'sharing_email_send_post' );
-add_filter( 'sharing_email_can_send', 'sharing_email_check_for_spam_via_akismet' );
add_action( 'sharing_global_options', 'sharing_global_resources', 30 );
add_action( 'sharing_admin_update', 'sharing_global_resources_save' );
-add_action( 'plugin_action_links_'.basename( dirname( __FILE__ ) ).'/'.basename( __FILE__ ), 'sharing_plugin_settings', 10, 4 );
+add_action( 'plugin_action_links_' . basename( __DIR__ ) . '/' . basename( __FILE__ ), 'sharing_plugin_settings', 10, 4 );
add_filter( 'plugin_row_meta', 'sharing_add_plugin_settings', 10, 2 );
-
-if ( sharing_recaptcha_site_key() && sharing_recaptcha_secret_key() ) {
- add_action( 'sharing_email_dialog', 'sharing_email_dialog' );
- add_filter( 'sharing_email_check', 'sharing_email_check', 10, 3 );
-}
diff --git a/plugins/jetpack/modules/sharedaddy/sharing-service.php b/plugins/jetpack/modules/sharedaddy/sharing-service.php
index f6d80dc3..a760ec5d 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing-service.php
+++ b/plugins/jetpack/modules/sharedaddy/sharing-service.php
@@ -1,33 +1,64 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Utilities to register and interact with a sharing service.
+ *
+ * Sharing_Service gets info about a service.
+ * Sharing_Service_Total and Sharing_Post_Total get stats data.
+ *
+ * @package automattic/jetpack
+ *
+ * phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound
+ */
use Automattic\Jetpack\Assets;
use Automattic\Jetpack\Redirect;
use Automattic\Jetpack\Status;
use Automattic\Jetpack\Sync\Settings;
-include_once dirname( __FILE__ ) . '/sharing-sources.php';
+require_once __DIR__ . '/sharing-sources.php';
define( 'WP_SHARING_PLUGIN_VERSION', JETPACK__VERSION );
+/**
+ * Interact with a sharing service.
+ */
class Sharing_Service {
- private $global = false;
+ /**
+ * Should the service be available globally?
+ *
+ * @var bool
+ */
+ private $global = false;
+
+ /**
+ * Default sharing label.
+ *
+ * @var string
+ */
public $default_sharing_label = '';
/**
* Initialize the sharing service.
* Only run this method once upon module loading.
+ *
+ * @return void
*/
public static function init() {
add_filter( 'the_content', 'sharing_display', 19 );
add_filter( 'the_excerpt', 'sharing_display', 19 );
}
+ /**
+ * Constructor.
+ */
public function __construct() {
$this->default_sharing_label = __( 'Share this:', 'jetpack' );
}
/**
* Gets a generic list of all services, without any config
+ *
+ * @return array
*/
public function get_all_services_blog() {
$options = get_option( 'sharing-options' );
@@ -39,7 +70,7 @@ class Sharing_Service {
$config = array();
// Pre-load custom modules otherwise they won't know who they are
- if ( substr( $id, 0, 7 ) == 'custom-' && is_array( $options[ $id ] ) ) {
+ if ( substr( $id, 0, 7 ) === 'custom-' && is_array( $options[ $id ] ) ) {
$config = $options[ $id ];
}
@@ -52,6 +83,10 @@ class Sharing_Service {
/**
* Gets a list of all available service names and classes
+ *
+ * @param bool $include_custom Include custom sharing services.
+ *
+ * @return array
*/
public function get_all_services( $include_custom = true ) {
// Default services
@@ -59,6 +94,7 @@ class Sharing_Service {
// in bin/tests/api/suites/SharingTest.php
$services = array(
'print' => 'Share_Print',
+ 'email' => 'Share_Email',
'facebook' => 'Share_Facebook',
'linkedin' => 'Share_LinkedIn',
'reddit' => 'Share_Reddit',
@@ -71,20 +107,6 @@ class Sharing_Service {
'skype' => 'Share_Skype',
);
- /**
- * Filters if Email Sharing is enabled.
- *
- * E-Mail sharing is often problematic due to spam concerns, so this filter enables it to be quickly and simply toggled.
- * @module sharedaddy
- *
- * @since 5.1.0
- *
- * @param bool $email Is e-mail sharing enabled? Default false if Akismet is not active or true if Akismet is active.
- */
- if ( apply_filters( 'sharing_services_email', Jetpack::is_akismet_active() ) ) {
- $services['email'] = 'Share_Email';
- }
-
if ( is_multisite() && is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
$services['press-this'] = 'Share_PressThis';
}
@@ -109,8 +131,17 @@ class Sharing_Service {
return apply_filters( 'sharing_services', $services );
}
+ /**
+ * Save a new custom sharing service.
+ *
+ * @param string $label Service name.
+ * @param string $url Service sharing URL.
+ * @param string $icon Service icon.
+ *
+ * @return bool|Share_Custom
+ */
public function new_service( $label, $url, $icon ) {
- // Validate
+ // Validate.
$label = trim( wp_html_excerpt( wp_kses( $label, array() ), 30 ) );
$url = trim( esc_url_raw( $url ) );
$icon = trim( esc_url_raw( $icon ) );
@@ -133,7 +164,8 @@ class Sharing_Service {
// Create a custom service and set the options for it
$service = new Share_Custom(
- $service_id, array(
+ $service_id,
+ array(
'name' => $label,
'url' => $url,
'icon' => $icon,
@@ -148,13 +180,20 @@ class Sharing_Service {
return false;
}
+ /**
+ * Delete a sharing service.
+ *
+ * @param string $service_id Service ID.
+ *
+ * @return bool
+ */
public function delete_service( $service_id ) {
$options = get_option( 'sharing-options' );
if ( isset( $options[ $service_id ] ) ) {
unset( $options[ $service_id ] );
}
- $key = array_search( $service_id, $options['global']['custom'] );
+ $key = array_search( $service_id, $options['global']['custom'], true );
if ( $key !== false ) {
unset( $options['global']['custom'][ $key ] );
}
@@ -163,6 +202,14 @@ class Sharing_Service {
return true;
}
+ /**
+ * Save enabled sharing services.
+ *
+ * @param array $visible Visible sharing services.
+ * @param array $hidden Hidden sharing services (available under a dropdown).
+ *
+ * @return bool
+ */
public function set_blog_services( array $visible, array $hidden ) {
$services = $this->get_all_services();
// Validate the services
@@ -193,7 +240,8 @@ class Sharing_Service {
* }
*/
do_action(
- 'sharing_get_services_state', array(
+ 'sharing_get_services_state',
+ array(
'services' => $services,
'available' => $available,
'hidden' => $hidden,
@@ -203,13 +251,19 @@ class Sharing_Service {
);
return update_option(
- 'sharing-services', array(
+ 'sharing-services',
+ array(
'visible' => $visible,
'hidden' => $hidden,
)
);
}
+ /**
+ * Get information about enabled sharing services on the site.
+ *
+ * @return array
+ */
public function get_blog_services() {
$options = get_option( 'sharing-options' );
$enabled = get_option( 'sharing-services' );
@@ -218,6 +272,7 @@ class Sharing_Service {
/**
* Check if options exist and are well formatted.
* This avoids issues on sites with corrupted options.
+ *
* @see https://github.com/Automattic/jetpack/issues/6121
*/
if ( ! is_array( $options ) || ! isset( $options['button_style'], $options['global'] ) ) {
@@ -302,6 +357,13 @@ class Sharing_Service {
return $blog;
}
+ /**
+ * Get information about a specific enabled sharing service.
+ *
+ * @param string $service_name Service name.
+ *
+ * @return bool|Sharing_Source
+ */
public function get_service( $service_name ) {
$services = $this->get_blog_services();
@@ -316,6 +378,11 @@ class Sharing_Service {
return false;
}
+ /**
+ * Update global sharing options.
+ *
+ * @param array $data Array of new sharing options to save.
+ */
public function set_global_options( $data ) {
$options = get_option( 'sharing-options' );
@@ -345,7 +412,10 @@ class Sharing_Service {
$options['global'] = apply_filters( 'sharing_default_global', $options['global'] );
// Validate options and set from our data
- if ( isset( $data['button_style'] ) && in_array( $data['button_style'], array( 'icon-text', 'icon', 'text', 'official' ) ) ) {
+ if (
+ isset( $data['button_style'] )
+ && in_array( $data['button_style'], array( 'icon-text', 'icon', 'text', 'official' ), true )
+ ) {
$options['global']['button_style'] = $data['button_style'];
}
@@ -357,7 +427,10 @@ class Sharing_Service {
}
}
- if ( isset( $data['open_links'] ) && in_array( $data['open_links'], array( 'new', 'same' ) ) ) {
+ if (
+ isset( $data['open_links'] )
+ && in_array( $data['open_links'], array( 'new', 'same' ), true )
+ ) {
$options['global']['open_links'] = $data['open_links'];
}
@@ -378,7 +451,8 @@ class Sharing_Service {
}
}
- if ( $data['show'] = array_intersect( $data['show'], $shows ) ) {
+ $data['show'] = array_intersect( $data['show'], $shows );
+ if ( $data['show'] ) {
$options['global']['show'] = $data['show'];
}
}
@@ -387,6 +461,11 @@ class Sharing_Service {
return $options['global'];
}
+ /**
+ * Get global sharing options for the site.
+ *
+ * @return array
+ */
public function get_global_options() {
if ( $this->global === false ) {
$options = get_option( 'sharing-options' );
@@ -421,6 +500,14 @@ class Sharing_Service {
return $this->global;
}
+ /**
+ * Save a sharing service for use.
+ *
+ * @param int $id Sharing unique ID.
+ * @param Sharing_Source $service Sharing service.
+ *
+ * @return void
+ */
public function set_service( $id, Sharing_Source $service ) {
// Update the options for this service
$options = get_option( 'sharing-options' );
@@ -446,7 +533,8 @@ class Sharing_Service {
* }
*/
do_action(
- 'sharing_get_button_state', array(
+ 'sharing_get_button_state',
+ array(
'id' => $id,
'options' => $options,
'service' => $service,
@@ -458,13 +546,22 @@ class Sharing_Service {
update_option( 'sharing-options', array_filter( $options ) );
}
- // Soon to come to a .org plugin near you!
+ /**
+ * Get stats for a site, a post, or a sharing service.
+ * Soon to come to a .org plugin near you!
+ *
+ * @param string|bool $service_name Service name.
+ * @param int|bool $post_id Post ID.
+ * @param int|bool $_blog_id Blog ID.
+ *
+ * @return int
+ */
public function get_total( $service_name = false, $post_id = false, $_blog_id = false ) {
global $wpdb, $blog_id;
if ( ! $_blog_id ) {
$_blog_id = $blog_id;
}
- if ( $service_name == false ) {
+ if ( $service_name === false ) {
if ( $post_id > 0 ) {
// total number of shares for this post
return (int) $wpdb->get_var( $wpdb->prepare( 'SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND post_id = %d', $_blog_id, $post_id ) );
@@ -481,6 +578,13 @@ class Sharing_Service {
}
}
+ /**
+ * Get total stats for a site, for all sharing services.
+ *
+ * @param int|bool $post_id Post ID.
+ *
+ * @return array
+ */
public function get_services_total( $post_id = false ) {
$totals = array();
$services = $this->get_blog_services();
@@ -495,6 +599,11 @@ class Sharing_Service {
return $totals;
}
+ /**
+ * Get sharing stats for all posts on the site.
+ *
+ * @return array
+ */
public function get_posts_total() {
$totals = array();
global $wpdb, $blog_id;
@@ -513,12 +622,44 @@ class Sharing_Service {
}
}
+/**
+ * Get stats for a specific sharing service.
+ */
class Sharing_Service_Total {
- public $id = '';
- public $name = '';
+ /**
+ * Sharing service ID.
+ *
+ * @var int
+ */
+ public $id = '';
+
+ /**
+ * Service name.
+ *
+ * @var string
+ */
+ public $name = '';
+
+ /**
+ * Sharing service name.
+ *
+ * @var string
+ */
public $service = '';
- public $total = 0;
+ /**
+ * Total number of shares for this service.
+ *
+ * @var string
+ */
+ public $total = 0;
+
+ /**
+ * Constructor.
+ *
+ * @param int $id Service ID.
+ * @param int $total Total shares.
+ */
public function __construct( $id, $total ) {
$services = new Sharing_Service();
$this->id = esc_html( $id );
@@ -528,20 +669,60 @@ class Sharing_Service_Total {
$this->name = $this->service->get_name();
}
- static function cmp( $a, $b ) {
- if ( $a->total == $b->total ) {
+ /**
+ * Compare total shares between 2 posts.
+ *
+ * @param object $a Sharing_Service_Total object.
+ * @param object $b Sharing_Service_Total object.
+ *
+ * @return bool
+ */
+ public static function cmp( $a, $b ) {
+ if ( $a->total === $b->total ) {
return $a->name < $b->name;
}
return $a->total < $b->total;
}
}
+/**
+ * Get sharing stats for a specific post.
+ */
class Sharing_Post_Total {
- public $id = 0;
+ /**
+ * Sharing service ID.
+ *
+ * @var int
+ */
+ public $id = 0;
+
+ /**
+ * Total shares.
+ *
+ * @var int
+ */
public $total = 0;
+
+ /**
+ * Post title.
+ *
+ * @var string
+ */
public $title = '';
- public $url = '';
+ /**
+ * Post permalink.
+ *
+ * @var string
+ */
+ public $url = '';
+
+ /**
+ * Constructor.
+ *
+ * @param int $id Service ID.
+ * @param int $total Total shares.
+ */
public function __construct( $id, $total ) {
$this->id = (int) $id;
$this->total = (int) $total;
@@ -549,14 +730,29 @@ class Sharing_Post_Total {
$this->url = get_permalink( $this->id );
}
- static function cmp( $a, $b ) {
- if ( $a->total == $b->total ) {
+ /**
+ * Compare total shares between 2 posts.
+ *
+ * @param object $a Sharing_Post_Total object.
+ * @param object $b Sharing_Post_Total object.
+ *
+ * @return bool
+ */
+ public static function cmp( $a, $b ) {
+ if ( $a->total === $b->total ) {
return $a->id < $b->id;
}
return $a->total < $b->total;
}
}
+/**
+ * Populate sharing counts global with a post we want to count shares for.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return void
+ */
function sharing_register_post_for_share_counts( $post_id ) {
global $jetpack_sharing_counts;
@@ -567,14 +763,28 @@ function sharing_register_post_for_share_counts( $post_id ) {
$jetpack_sharing_counts[ (int) $post_id ] = get_permalink( $post_id );
}
+/**
+ * Determine whether we should load sharing scripts or not.
+ *
+ * @return bool
+ */
function sharing_maybe_enqueue_scripts() {
$sharer = new Sharing_Service();
$global_options = $sharer->get_global_options();
$enqueue = false;
- if ( is_singular() && in_array( get_post_type(), $global_options['show'] ) ) {
+ if ( is_singular() && in_array( get_post_type(), $global_options['show'], true ) ) {
$enqueue = true;
- } elseif ( in_array( 'index', $global_options['show'] ) && ( is_home() || is_front_page() || is_archive() || is_search() || in_array( get_post_type(), $global_options['show'] ) ) ) {
+ } elseif (
+ in_array( 'index', $global_options['show'], true )
+ && (
+ is_home()
+ || is_front_page()
+ || is_archive()
+ || is_search()
+ || in_array( get_post_type(), $global_options['show'], true )
+ )
+ ) {
$enqueue = true;
}
@@ -590,6 +800,11 @@ function sharing_maybe_enqueue_scripts() {
return (bool) apply_filters( 'sharing_enqueue_scripts', $enqueue );
}
+/**
+ * Add sharing JavaScript to the footer of a page.
+ *
+ * @return void
+ */
function sharing_add_footer() {
if (
class_exists( 'Jetpack_AMP_Support' )
@@ -600,33 +815,39 @@ function sharing_add_footer() {
global $jetpack_sharing_counts;
- /**
- * Filter all JavaScript output by the sharing module.
- *
- * @module sharedaddy
- *
- * @since 1.1.0
- *
- * @param bool true Control whether the sharing module should add any JavaScript to the site. Default to true.
- */
- if ( apply_filters( 'sharing_js', true ) && sharing_maybe_enqueue_scripts() ) {
-
+ if (
/**
- * Filter the display of sharing counts next to the sharing buttons.
+ * Filter all JavaScript output by the sharing module.
*
* @module sharedaddy
*
- * @since 3.2.0
+ * @since 1.1.0
*
- * @param bool true Control the display of counters next to the sharing buttons. Default to true.
+ * @param bool true Control whether the sharing module should add any JavaScript to the site. Default to true.
*/
- if ( apply_filters( 'jetpack_sharing_counts', true ) && is_array( $jetpack_sharing_counts ) && count( $jetpack_sharing_counts ) ) :
+ apply_filters( 'sharing_js', true )
+ && sharing_maybe_enqueue_scripts()
+ ) {
+ if (
+ /**
+ * Filter the display of sharing counts next to the sharing buttons.
+ *
+ * @module sharedaddy
+ *
+ * @since 3.2.0
+ *
+ * @param bool true Control the display of counters next to the sharing buttons. Default to true.
+ */
+ apply_filters( 'jetpack_sharing_counts', true )
+ && is_array( $jetpack_sharing_counts )
+ && count( $jetpack_sharing_counts )
+ ) :
$sharing_post_urls = array_filter( $jetpack_sharing_counts );
if ( $sharing_post_urls ) :
?>
<script type="text/javascript">
- window.WPCOM_sharing_counts = <?php echo json_encode( array_flip( $sharing_post_urls ) ); ?>;
+ window.WPCOM_sharing_counts = <?php echo wp_json_encode( array_flip( $sharing_post_urls ) ); ?>;
</script>
<?php
endif;
@@ -648,6 +869,11 @@ function sharing_add_footer() {
}
}
+/**
+ * Enqueue sharing CSS in head.
+ *
+ * @return void
+ */
function sharing_add_header() {
$sharer = new Sharing_Service();
$enabled = $sharer->get_blog_services();
@@ -664,6 +890,11 @@ function sharing_add_header() {
}
add_action( 'wp_head', 'sharing_add_header', 1 );
+/**
+ * Launch sharing requests on page load when a specific query string is used.
+ *
+ * @return void
+ */
function sharing_process_requests() {
global $post;
@@ -671,9 +902,9 @@ function sharing_process_requests() {
if ( ( is_page() || is_single() ) && isset( $_GET['share'] ) && is_string( $_GET['share'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$sharer = new Sharing_Service();
- $service = $sharer->get_service( $_GET['share'] );
+ $service = $sharer->get_service( sanitize_text_field( wp_unslash( $_GET['share'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( $service ) {
- $service->process_request( $post, $_POST );
+ $service->process_request( $post, $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
}
}
}
@@ -805,8 +1036,8 @@ function sharing_display( $text = '', $echo = false ) {
if (
defined( 'DOING_AJAX' )
&& DOING_AJAX
- && isset( $_REQUEST['action'] )
- && $ajax_action === $_REQUEST['action']
+ && isset( $_REQUEST['action'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce handling happens within each custom implementation.
+ && $ajax_action === $_REQUEST['action'] // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce handling happens within each custom implementation.
) {
$show = true;
}
@@ -852,7 +1083,7 @@ function sharing_display( $text = '', $echo = false ) {
// Visible items.
$visible = '';
- foreach ( $enabled['visible'] as $id => $service ) {
+ foreach ( $enabled['visible'] as $service ) {
$klasses = array( 'share-' . $service->get_class() );
if ( $service->is_deprecated() ) {
if ( ! current_user_can( 'manage_options' ) ) {
@@ -907,7 +1138,7 @@ function sharing_display( $text = '', $echo = false ) {
}
$count = 1;
- foreach ( $enabled['hidden'] as $id => $service ) {
+ foreach ( $enabled['hidden'] as $service ) {
// Individual HTML for sharing service.
$klasses = array( 'share-' . $service->get_class() );
if ( $service->is_deprecated() ) {
@@ -971,14 +1202,18 @@ function sharing_display( $text = '', $echo = false ) {
$sharing_markup = apply_filters( 'jetpack_sharing_display_markup', $sharing_content, $enabled );
if ( $echo ) {
- echo $text . $sharing_markup;
+ echo $text . $sharing_markup; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
return $text . $sharing_markup;
}
}
+/**
+ * Get reCAPTCHA language code based off the language code of the site.
+ *
+ * @return string
+ */
function get_base_recaptcha_lang_code() {
-
$base_recaptcha_lang_code_mapping = array(
'en' => 'en',
'nl' => 'nl',
diff --git a/plugins/jetpack/modules/sharedaddy/sharing-sources.php b/plugins/jetpack/modules/sharedaddy/sharing-sources.php
index d4632e79..cb3b2204 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing-sources.php
+++ b/plugins/jetpack/modules/sharedaddy/sharing-sources.php
@@ -1,13 +1,51 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Define all sharing sources.
+ *
+ * phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound
+ */
use Automattic\Jetpack\Device_Detection\User_Agent_Info;
+/**
+ * Base class for sharing sources.
+ * See individual sharing classes below for the implementation of this class.
+ */
abstract class Sharing_Source {
- public $button_style;
- public $smart;
+ /**
+ * Button style (icon, icon-text, text, or official).
+ *
+ * @var string
+ */
+ public $button_style;
+
+ /**
+ * Does the service have an official version.
+ *
+ * @var bool
+ */
+ public $smart;
+
+ /**
+ * Should the sharing link open in a new tab.
+ *
+ * @var bool
+ */
protected $open_link_in_new;
+
+ /**
+ * Sharing unique ID.
+ *
+ * @var int
+ */
protected $id;
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
$this->id = $id;
/**
@@ -32,22 +70,49 @@ abstract class Sharing_Source {
}
}
+ /**
+ * Is a service deprecated.
+ *
+ * @return bool
+ */
public function is_deprecated() {
return false;
}
+ /**
+ * Get the protocol to use for a sharing service, based on the site settings.
+ *
+ * @return string
+ */
public function http() {
return is_ssl() ? 'https' : 'http';
}
+ /**
+ * Get unique sharing ID.
+ *
+ * @return int
+ */
public function get_id() {
return $this->id;
}
+ /**
+ * Get unique sharing ID. Similar to get_id().
+ *
+ * @return int
+ */
public function get_class() {
return $this->id;
}
+ /**
+ * Get a post's permalink to use for sharing.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return string
+ */
public function get_share_url( $post_id ) {
/**
* Filter the sharing permalink.
@@ -63,6 +128,13 @@ abstract class Sharing_Source {
return apply_filters( 'sharing_permalink', get_permalink( $post_id ), $post_id, $this->id );
}
+ /**
+ * Get a post's title to use for sharing.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return string
+ */
public function get_share_title( $post_id ) {
$post = get_post( $post_id );
/**
@@ -81,23 +153,41 @@ abstract class Sharing_Source {
return html_entity_decode( wp_kses( $title, null ) );
}
+ /**
+ * Does this sharing source have a custom style.
+ *
+ * @return bool
+ */
public function has_custom_button_style() {
return false;
}
- public function get_link( $url, $text, $title, $query = '', $id = false ) {
- $args = func_get_args();
+ /**
+ * Get the HTML markup to display a sharing link.
+ *
+ * @param string $url Post URL to share.
+ * @param string $text Sharing display text.
+ * @param string $title The title for the link.
+ * @param string $query Additional query arguments to add to the link. They should be in 'foo=bar&baz=1' format.
+ * @param bool|string $id Sharing ID to include in the data-shared attribute.
+ * @param array $data_attributes The keys are used as additional attribute names with 'data-' prefix.
+ * The values are used as the attribute values.
+ *
+ * @return string The HTML for the link.
+ */
+ public function get_link( $url, $text, $title, $query = '', $id = false, $data_attributes = array() ) {
+ $args = func_get_args();
$klasses = array( 'share-' . $this->get_class(), 'sd-button' );
- if ( 'icon' == $this->button_style || 'icon-text' == $this->button_style ) {
+ if ( 'icon' === $this->button_style || 'icon-text' === $this->button_style ) {
$klasses[] = 'share-icon';
}
- if ( 'icon' == $this->button_style ) {
- $text = $title;
+ if ( 'icon' === $this->button_style ) {
+ $text = $title;
$klasses[] = 'no-text';
- if ( true == $this->open_link_in_new ) {
+ if ( true === $this->open_link_in_new ) {
$text .= __( ' (Opens in new window)', 'jetpack' );
}
}
@@ -109,7 +199,7 @@ abstract class Sharing_Source {
*
* @since 3.4.0
*
- * @param int|false $id Sharing ID.
+ * @param string|false $id Sharing ID.
* @param object $this Sharing service properties.
* @param array $args Array of sharing service options.
*/
@@ -123,7 +213,7 @@ abstract class Sharing_Source {
*
* @param string $url Post URL.
* @param object $this Sharing service properties.
- * @param int|false $id Sharing ID.
+ * @param string|false $id Sharing ID.
* @param array $args Array of sharing service options.
*/
$url = apply_filters( 'sharing_display_link', $url, $this, $id, $args ); // backwards compatibility
@@ -136,7 +226,7 @@ abstract class Sharing_Source {
*
* @param string $url Post URL.
* @param object $this Sharing service properties.
- * @param int|false $id Sharing ID.
+ * @param string|false $id Sharing ID.
* @param array $args Array of sharing service options.
*/
$url = apply_filters( 'jetpack_sharing_display_link', $url, $this, $id, $args );
@@ -149,7 +239,7 @@ abstract class Sharing_Source {
*
* @param string $query Sharing service URL parameter.
* @param object $this Sharing service properties.
- * @param int|false $id Sharing ID.
+ * @param string|false $id Sharing ID.
* @param array $args Array of sharing service options.
*/
$query = apply_filters( 'jetpack_sharing_display_query', $query, $this, $id, $args );
@@ -162,7 +252,7 @@ abstract class Sharing_Source {
}
}
- if ( 'text' == $this->button_style ) {
+ if ( 'text' === $this->button_style ) {
$klasses[] = 'no-icon';
}
@@ -175,7 +265,7 @@ abstract class Sharing_Source {
*
* @param array $klasses Sharing service classes.
* @param object $this Sharing service properties.
- * @param int|false $id Sharing ID.
+ * @param string|false $id Sharing ID.
* @param array $args Array of sharing service options.
*/
$klasses = apply_filters( 'jetpack_sharing_display_classes', $klasses, $this, $id, $args );
@@ -188,7 +278,7 @@ abstract class Sharing_Source {
*
* @param string $title Sharing service title.
* @param object $this Sharing service properties.
- * @param int|false $id Sharing ID.
+ * @param string|false $id Sharing ID.
* @param array $args Array of sharing service options.
*/
$title = apply_filters( 'jetpack_sharing_display_title', $title, $this, $id, $args );
@@ -201,20 +291,54 @@ abstract class Sharing_Source {
*
* @param string $text Sharing service text.
* @param object $this Sharing service properties.
- * @param int|false $id Sharing ID.
+ * @param string|false $id Sharing ID.
* @param array $args Array of sharing service options.
*/
$text = apply_filters( 'jetpack_sharing_display_text', $text, $this, $id, $args );
+ /**
+ * Filter the sharing data attributes.
+ *
+ * @module sharedaddy
+ *
+ * @since 11.0
+ *
+ * @param array $data_attributes Attributes supplied from the sharing source.
+ * Note that 'data-' will be prepended to all keys.
+ * @param Sharing_Source $this Sharing source instance.
+ * @param string|false $id Sharing ID.
+ * @param array $args Array of sharing service options.
+ */
+ $data_attributes = apply_filters( 'jetpack_sharing_data_attributes', (array) $data_attributes, $this, $id, $args );
+
+ $encoded_data_attributes = '';
+ if ( ! empty( $data_attributes ) ) {
+ $encoded_data_attributes = implode(
+ ' ',
+ array_map(
+ function ( $data_key, $data_value ) {
+ return sprintf(
+ 'data-%s="%s"',
+ esc_attr( str_replace( array( ' ', '"' ), '', $data_key ) ),
+ esc_attr( $data_value )
+ );
+ },
+ array_keys( $data_attributes ),
+ array_values( $data_attributes )
+ )
+ );
+ }
+
return sprintf(
- '<a rel="nofollow%s" data-shared="%s" class="%s" href="%s"%s title="%s"><span%s>%s</span></a>',
- ( true == $this->open_link_in_new ) ? ' noopener noreferrer' : '',
+ '<a rel="nofollow%s" data-shared="%s" class="%s" href="%s"%s title="%s" %s><span%s>%s</span></a>',
+ ( true === $this->open_link_in_new ) ? ' noopener noreferrer' : '',
( $id ? esc_attr( $id ) : '' ),
implode( ' ', $klasses ),
$url,
- ( true == $this->open_link_in_new ) ? ' target="_blank"' : '',
+ ( true === $this->open_link_in_new ) ? ' target="_blank"' : '',
$title,
- ( 'icon' == $this->button_style ) ? '></span><span class="sharing-screen-reader-text"' : '',
+ $encoded_data_attributes,
+ ( 'icon' === $this->button_style ) ? '></span><span class="sharing-screen-reader-text"' : '',
$text
);
}
@@ -226,22 +350,44 @@ abstract class Sharing_Source {
*
* @since 3.7.0
* @param int $post_id Post ID.
+ *
* @uses get_permalink
+ *
* @return string get_permalink( $post_id ) Post permalink.
*/
public function get_process_request_url( $post_id ) {
return get_permalink( $post_id );
}
+ /**
+ * Get sharing name.
+ */
abstract public function get_name();
+
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ */
abstract public function get_display( $post );
+ /**
+ * Add content specific to a service in the head.
+ */
public function display_header() {
}
+ /**
+ * Add content specific to a service in the footer.
+ */
public function display_footer() {
}
+ /**
+ * Does the service have advanced options.
+ *
+ * @return bool
+ */
public function has_advanced_options() {
return false;
}
@@ -250,6 +396,8 @@ abstract class Sharing_Source {
* Get the AMP specific markup for a sharing button.
*
* @param \WP_Post $post The current post being viewed.
+ *
+ * @return bool|string
*/
public function get_amp_display( $post ) {
// Only display markup if we're on a post.
@@ -264,6 +412,8 @@ abstract class Sharing_Source {
* Generates and returns the markup for an AMP sharing button.
*
* @param array $attrs Custom attributes for rendering the social icon.
+ *
+ * @return string
*/
protected function build_amp_markup( $attrs = array() ) {
@@ -291,26 +441,35 @@ abstract class Sharing_Source {
return $sharing_link;
}
+ /**
+ * Display a preview of the sharing button.
+ *
+ * @param bool $echo Whether to echo the output or return it.
+ * @param bool $force_smart Whether to force the smart (official) services to be shown.
+ * @param null|string $button_style Button style.
+ *
+ * @return string|void
+ */
public function display_preview( $echo = true, $force_smart = false, $button_style = null ) {
- $text = '&nbsp;';
+ $text = '&nbsp;';
$button_style = ( ! empty( $button_style ) ) ? $button_style : $this->button_style;
if ( ! $this->smart && ! $force_smart ) {
- if ( $button_style != 'icon' ) {
+ if ( $button_style !== 'icon' ) {
$text = $this->get_name();
}
}
$klasses = array( 'share-' . $this->get_class(), 'sd-button' );
- if ( $button_style == 'icon' || $button_style == 'icon-text' ) {
+ if ( $button_style === 'icon' || $button_style === 'icon-text' ) {
$klasses[] = 'share-icon';
}
- if ( $button_style == 'icon' ) {
+ if ( $button_style === 'icon' ) {
$klasses[] = 'no-text';
}
- if ( $button_style == 'text' ) {
+ if ( $button_style === 'text' ) {
$klasses[] = 'no-icon';
}
@@ -333,21 +492,28 @@ abstract class Sharing_Source {
)
);
- $smart = ( $this->smart || $force_smart ) ? 'on' : 'off';
+ $smart = ( $this->smart || $force_smart ) ? 'on' : 'off';
$return = "<div class='option option-smart-$smart'>$link</div>";
if ( $echo ) {
- echo $return;
+ echo $return; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- we escape things above.
}
return $return;
}
+ /**
+ * Get sharing stats for a specific post or sharing service.
+ *
+ * @param bool|WP_Post $post Post object.
+ *
+ * @return int
+ */
public function get_total( $post = false ) {
global $wpdb, $blog_id;
$name = strtolower( $this->get_id() );
- if ( $post == false ) {
+ if ( $post === false ) {
// get total number of shares for service
return (int) $wpdb->get_var( $wpdb->prepare( 'SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND share_service = %s', $blog_id, $name ) );
}
@@ -356,11 +522,16 @@ abstract class Sharing_Source {
return (int) $wpdb->get_var( $wpdb->prepare( 'SELECT count FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s', $blog_id, $post->ID, $name ) );
}
+ /**
+ * Get sharing stats for all posts on the site.
+ *
+ * @return array
+ */
public function get_posts_total() {
global $wpdb, $blog_id;
$totals = array();
- $name = strtolower( $this->get_id() );
+ $name = strtolower( $this->get_id() );
$my_data = $wpdb->get_results( $wpdb->prepare( 'SELECT post_id as id, SUM( count ) as total FROM sharing_stats WHERE blog_id = %d AND share_service = %s GROUP BY post_id ORDER BY count DESC ', $blog_id, $name ) );
@@ -375,7 +546,15 @@ abstract class Sharing_Source {
return $totals;
}
- public function process_request( $post, array $post_data ) {
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
+ public function process_request( $post, array $post_data ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
/**
* Fires when a post is shared via one of the sharing buttons.
*
@@ -385,7 +564,13 @@ abstract class Sharing_Source {
*
* @param array $args Aray of information about the sharing service.
*/
- do_action( 'sharing_bump_stats', array( 'service' => $this, 'post' => $post ) );
+ do_action(
+ 'sharing_bump_stats',
+ array(
+ 'service' => $this,
+ 'post' => $post,
+ )
+ );
}
/**
@@ -401,26 +586,35 @@ abstract class Sharing_Source {
die();
}
+ /**
+ * Add extra JavaScript to a sharing service.
+ *
+ * @param string $name Sharing service name.
+ * @param array $params Array of sharing options.
+ *
+ * @return void
+ */
public function js_dialog( $name, $params = array() ) {
if ( true !== $this->open_link_in_new ) {
return;
}
$defaults = array(
- 'menubar' => 1,
+ 'menubar' => 1,
'resizable' => 1,
- 'width' => 600,
- 'height' => 400,
+ 'width' => 600,
+ 'height' => 400,
);
- $params = array_merge( $defaults, $params );
- $opts = array();
+ $params = array_merge( $defaults, $params );
+ $opts = array();
foreach ( $params as $key => $val ) {
$opts[] = "$key=$val";
}
$opts = implode( ',', $opts );
// Add JS after sharing-js has been enqueued.
- wp_add_inline_script( 'sharing-js',
+ wp_add_inline_script(
+ 'sharing-js',
"var windowOpen;
( function () {
function matches( el, sel ) {
@@ -458,13 +652,51 @@ abstract class Sharing_Source {
}
}
+/**
+ * Handle the display of deprecated sharing services.
+ */
abstract class Deprecated_Sharing_Source extends Sharing_Source {
- public $button_style = 'text';
- public $smart = false;
+ /**
+ * Button style (icon-text, icon, or text)
+ *
+ * @var string
+ */
+ public $button_style = 'text';
+
+ /**
+ * Does the service have an official version.
+ *
+ * @var bool
+ */
+ public $smart = false;
+
+ /**
+ * Should the sharing link open in a new tab.
+ *
+ * @var bool
+ */
protected $open_link_in_new = false;
+
+ /**
+ * Sharing unique ID.
+ *
+ * @var int
+ */
protected $id;
+
+ /**
+ * Is the service deprecated.
+ *
+ * @var bool
+ */
protected $deprecated = true;
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
final public function __construct( $id, array $settings ) {
$this->id = $id;
@@ -473,10 +705,22 @@ abstract class Deprecated_Sharing_Source extends Sharing_Source {
}
}
+ /**
+ * Is the service deprecated.
+ *
+ * @return bool
+ */
final public function is_deprecated() {
return true;
}
+ /**
+ * Get a post's permalink to use for sharing.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return string
+ */
final public function get_share_url( $post_id ) {
return get_permalink( $post_id );
}
@@ -490,22 +734,58 @@ abstract class Deprecated_Sharing_Source extends Sharing_Source {
return false;
}
+ /**
+ * Display a preview of the sharing button.
+ *
+ * @param bool $echo Whether to echo the output or return it.
+ * @param bool $force_smart Whether to force the smart (official) services to be shown.
+ * @param null|string $button_style Button style.
+ *
+ * @return string|void
+ */
final public function display_preview( $echo = true, $force_smart = false, $button_style = null ) {
return parent::display_preview( $echo, false, $button_style );
}
- final public function get_total( $post = false ) {
+ /**
+ * Get sharing stats for a specific post or sharing service.
+ *
+ * @param bool|WP_Post $post Post object.
+ *
+ * @return int
+ */
+ final public function get_total( $post = false ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
return 0;
}
+ /**
+ * Get sharing stats for all posts on the site.
+ *
+ * @return int|array
+ */
final public function get_posts_total() {
return 0;
}
- final public function process_request( $post, array $post_data ) {
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
+ final public function process_request( $post, array $post_data ) { // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found
parent::process_request( $post, $post_data );
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
final public function get_display( $post ) {
if ( current_user_can( 'manage_options' ) ) {
return $this->display_deprecated( $post );
@@ -514,6 +794,13 @@ abstract class Deprecated_Sharing_Source extends Sharing_Source {
return '';
}
+ /**
+ * Display a custom message for deprecated services.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function display_deprecated( $post ) {
return $this->get_link(
$this->get_share_url( $post->ID ),
@@ -525,225 +812,247 @@ abstract class Deprecated_Sharing_Source extends Sharing_Source {
}
}
+/**
+ * Handle the display of advanced sharing services.
+ * Custom sharing buttons we create ourselves will be such services.
+ */
abstract class Sharing_Advanced_Source extends Sharing_Source {
+ /**
+ * Does the service have advanced options.
+ *
+ * @return bool
+ */
public function has_advanced_options() {
return true;
}
+ /**
+ * Display options for our sharing buttons.
+ */
abstract public function display_options();
+
+ /**
+ * Sanitize and save options for our sharing buttons.
+ *
+ * @param array $data Data to be saved.
+ *
+ * @return void
+ */
abstract public function update_options( array $data );
+
+ /**
+ * Get array of information about the service.
+ *
+ * @return array
+ */
abstract public function get_options();
}
+/**
+ * Handle the display of the email sharing button.
+ */
class Share_Email extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'email';
+
+ /**
+ * Service icon font code.
+ *
+ * @var string
+ */
public $icon = '\f410';
+
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( 'official' == $this->button_style ) {
+ if ( 'official' === $this->button_style ) {
$this->smart = true;
} else {
$this->smart = false;
}
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return _x( 'Email', 'as sharing source', 'jetpack' );
}
- // Default does nothing
- public function process_request( $post, array $post_data ) {
- $ajax = false;
- if ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) {
- $ajax = true;
+ /**
+ * Helper function to return a nonce action based on the current post.
+ *
+ * @param WP_Post|null $post The current post if it is defined.
+ * @return string The nonce action name.
+ */
+ protected function get_email_share_nonce_action( $post ) {
+ if ( ! empty( $post ) && $post instanceof WP_Post ) {
+ return 'jetpack-email-share-' . $post->ID;
}
- $source_email = $target_email = $source_name = false;
+ return 'jetpack-email-share';
+ }
- if ( isset( $post_data['source_email'] ) && is_email( $post_data['source_email'] ) ) {
- $source_email = $post_data['source_email'];
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
+ public function process_request( $post, array $post_data ) {
+ $is_ajax = false;
+ if (
+ isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )
+ && strtolower( sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REQUESTED_WITH'] ) ) ) === 'xmlhttprequest'
+ ) {
+ $is_ajax = true;
}
- if ( isset( $post_data['target_email'] ) && is_email( $post_data['target_email'] ) ) {
- $target_email = $post_data['target_email'];
+ // Require an AJAX-driven submit and a valid nonce to process the request
+ if (
+ $is_ajax
+ && isset( $post_data['email-share-nonce'] )
+ && wp_verify_nonce( $post_data['email-share-nonce'], $this->get_email_share_nonce_action( $post ) )
+ ) {
+ // Ensure that we bump stats
+ parent::process_request( $post, $post_data );
}
- if ( isset( $post_data['source_name'] ) && strlen( $post_data['source_name'] ) < 200 ) {
- $source_name = $post_data['source_name'];
- } elseif ( isset( $post_data['source_name'] ) ) {
- $source_name = substr( $post_data['source_name'], 0, 200 );
- } else {
- $source_name = '';
+ if ( $is_ajax ) {
+ wp_send_json_success();
}
- // Test email
- $error = 1; // Failure in data
- if ( empty( $post_data['source_f_name'] ) && $source_email && $target_email && $source_name ) {
- /**
- * Allow plugins to stop the email sharing button from running the shared message through Akismet.
- *
- * @module sharedaddy
- *
- * @since 1.1.0
- *
- * @param bool true Should we check if the message isn't spam?
- * @param object $post Post information.
- * @param array $post_data Information about the shared message.
- */
- if ( apply_filters( 'sharing_email_check', true, $post, $post_data ) ) {
- $data = array(
- 'post' => $post,
- 'source' => $source_email,
- 'target' => $target_email,
- 'name' => $source_name,
- 'sharing_source' => $this,
- );
- // todo: implement an error message when email doesn't get sent.
- /**
- * Filter whether an email can be sent from the Email sharing button.
- *
- * @module sharedaddy
- *
- * @since 1.1.0
- *
- * @param array $data Array of information about the shared message.
- */
- if ( ( $data = apply_filters( 'sharing_email_can_send', $data ) ) !== false ) {
- // Record stats
- parent::process_request( $data['post'], $post_data );
-
- /**
- * Fires when an email is sent via the Email sharing button.
- *
- * @module sharedaddy
- *
- * @since 1.1.0
- *
- * @param array $data Array of information about the shared message.
- */
- do_action( 'sharing_email_send_post', $data );
- }
-
- // Return a positive regardless of whether the user is subscribed or not
- if ( $ajax ) {
-?>
-<div class="response">
- <div class="response-title"><?php _e( 'This post has been shared!', 'jetpack' ); ?></div>
- <div class="response-sub"><?php printf( __( 'You have shared this post with %s', 'jetpack' ), esc_html( $target_email ) ); ?></div>
- <div class="response-close"><a href="#" class="sharing_cancel"><?php _e( 'Close', 'jetpack' ); ?></a></div>
-</div>
-<?php
- } else {
- wp_safe_redirect( get_permalink( $post->ID ) . '?shared=email' );
- }
-
- die();
- } else {
- $error = 2; // Email check failed
- }
- }
+ wp_die();
+ }
- if ( $ajax ) {
- echo $error;
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string The HTML for the button.
+ */
+ public function get_display( $post ) {
+ $tracking_url = $this->get_process_request_url( $post->ID );
+ if ( false === stripos( $tracking_url, '?' ) ) {
+ $tracking_url .= '?';
} else {
- wp_safe_redirect( get_permalink( $post->ID ) . '?shared=email&msg=fail' );
+ $tracking_url .= '&';
}
+ $tracking_url .= 'share=email';
- die();
- }
+ $data_attributes = array(
+ 'email-share-error-title' => __( 'Do you have email set up?', 'jetpack' ),
+ 'email-share-error-text' => __(
+ "If you're having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.",
+ 'jetpack'
+ ),
+ 'email-share-nonce' => wp_create_nonce( $this->get_email_share_nonce_action( $post ) ),
+ 'email-share-track-url' => $tracking_url,
+ );
- public function get_display( $post ) {
- return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Email', 'share to', 'jetpack' ), __( 'Click to email this to a friend', 'jetpack' ), 'share=email' );
+ $post_title = $this->get_share_title( $post->ID );
+ $post_url = $this->get_share_url( $post->ID );
+
+ /** This filter is documented in plugins/jetpack/modules/sharedaddy/sharedaddy.php */
+ $email_subject = apply_filters(
+ 'wp_sharing_email_send_post_subject',
+ sprintf( '[%s] %s', __( 'Shared Post', 'jetpack' ), $post_title )
+ );
+
+ $mailto_query = sprintf(
+ 'subject=%s&body=%s&share=email',
+ rawurlencode( $email_subject ),
+ rawurlencode( $post_url )
+ );
+
+ return $this->get_link(
+ 'mailto:',
+ _x( 'Email', 'share to', 'jetpack' ),
+ __( 'Click to email a link to a friend', 'jetpack' ),
+ $mailto_query,
+ false,
+ $data_attributes
+ );
}
/**
- * No AMP display for email.
+ * AMP display for email.
*
* @param \WP_Post $post The current post being viewed.
*/
public function get_amp_display( $post ) { // phpcs:ignore
- return false;
- }
-
- /**
- * Outputs the hidden email dialog
- */
- public function display_footer() {
- global $current_user;
-
- $visible = $status = false;
-?>
- <div id="sharing_email" style="display: none;">
- <form action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" method="post">
- <label for="target_email"><?php _e( 'Send to Email Address', 'jetpack' ) ?></label>
- <input type="email" name="target_email" id="target_email" value="" />
-
- <?php if ( is_user_logged_in() ) : ?>
- <input type="hidden" name="source_name" value="<?php echo esc_attr( $current_user->display_name ); ?>" />
- <input type="hidden" name="source_email" value="<?php echo esc_attr( $current_user->user_email ); ?>" />
- <?php else : ?>
-
- <label for="source_name"><?php _e( 'Your Name', 'jetpack' ) ?></label>
- <input type="text" name="source_name" id="source_name" value="" />
-
- <label for="source_email"><?php _e( 'Your Email Address', 'jetpack' ) ?></label>
- <input type="email" name="source_email" id="source_email" value="" />
-
- <?php endif; ?>
- <input type="text" id="jetpack-source_f_name" name="source_f_name" class="input" value="" size="25" autocomplete="off" title="<?php esc_attr_e( 'This field is for validation and should not be changed', 'jetpack' ); ?>" />
- <?php
- /**
- * Fires when the Email sharing dialog is loaded.
- *
- * @module sharedaddy
- *
- * @since 1.1.0
- *
- * @param string jetpack Eail sharing source.
- */
- do_action( 'sharing_email_dialog', 'jetpack' );
- ?>
-
- <img style="float: right; display: none" class="loading" src="<?php
- /** This filter is documented in modules/stats.php */
- echo apply_filters( 'jetpack_static_url', plugin_dir_url( __FILE__ ) . 'images/loading.gif' ); ?>" alt="loading" width="16" height="16" />
- <input type="submit" value="<?php esc_attr_e( 'Send Email', 'jetpack' ); ?>" class="sharing_send" />
- <a rel="nofollow" href="#cancel" class="sharing_cancel" role="button"><?php _e( 'Cancel', 'jetpack' ); ?></a>
-
- <div class="errors errors-1" style="display: none;">
- <?php _e( 'Post was not sent - check your email addresses!', 'jetpack' ); ?>
- </div>
-
- <div class="errors errors-2" style="display: none;">
- <?php _e( 'Email check failed, please try again', 'jetpack' ); ?>
- </div>
+ $attrs = array(
+ // Prevents an empty window from opening on desktop: https://github.com/ampproject/amphtml/issues/9157.
+ 'data-target' => '_self',
+ );
- <div class="errors errors-3" style="display: none;">
- <?php _e( 'Sorry, your blog cannot share posts by email.', 'jetpack' ); ?>
- </div>
- </form>
- </div>
-<?php
+ return $this->build_amp_markup( $attrs );
}
}
+/**
+ * Twitter sharing button.
+ */
class Share_Twitter extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'twitter';
+
+ /**
+ * Service icon font code.
+ *
+ * @var string
+ */
public $icon = '\f202';
- // 'https://dev.twitter.com/rest/reference/get/help/configuration' ( 2015/02/06 ) short_url_length is 22, short_url_length_https is 23
+
+ /**
+ * Length of a URL on Twitter.
+ * 'https://dev.twitter.com/rest/reference/get/help/configuration'
+ * ( 2015/02/06 ) short_url_length is 22, short_url_length_https is 23
+ *
+ * @var int
+ */
public $short_url_length = 24;
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( 'official' == $this->button_style ) {
+ if ( 'official' === $this->button_style ) {
$this->smart = true;
} else {
$this->smart = false;
}
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return __( 'Twitter', 'jetpack' );
}
@@ -778,7 +1087,7 @@ class Share_Twitter extends Sharing_Source {
* was introduced with the adding of the Twitter cards.
* This should be a temporary solution until a better method is setup.
*/
- if ( 'jetpack' == $twitter_site_tag_value ) {
+ if ( 'jetpack' === $twitter_site_tag_value ) {
$twitter_site_tag_value = '';
}
@@ -834,6 +1143,13 @@ class Share_Twitter extends Sharing_Source {
return implode( ',', $related );
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
$via = $this->sharing_twitter_via( $post );
@@ -851,7 +1167,7 @@ class Share_Twitter extends Sharing_Source {
}
if ( $this->smart ) {
- $share_url = $this->get_share_url( $post->ID );
+ $share_url = $this->get_share_url( $post->ID );
$post_title = $this->get_share_title( $post->ID );
return sprintf(
'<a href="https://twitter.com/share" class="twitter-share-button" data-url="%1$s" data-text="%2$s" %3$s %4$s>Tweet</a>',
@@ -881,9 +1197,17 @@ class Share_Twitter extends Sharing_Source {
}
}
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
public function process_request( $post, array $post_data ) {
$post_title = $this->get_share_title( $post->ID );
- $post_link = $this->get_share_url( $post->ID );
+ $post_link = $this->get_share_url( $post->ID );
if ( function_exists( 'mb_stripos' ) ) {
$strlen = 'mb_strlen';
@@ -893,7 +1217,7 @@ class Share_Twitter extends Sharing_Source {
$substr = 'substr';
}
- $via = $this->sharing_twitter_via( $post );
+ $via = $this->sharing_twitter_via( $post );
$related = $this->get_related_accounts( $post );
if ( $via ) {
$sig = " via @$via";
@@ -918,7 +1242,7 @@ class Share_Twitter extends Sharing_Source {
// Record stats
parent::process_request( $post, $post_data );
- $url = $post_link;
+ $url = $post_link;
$twitter_url = add_query_arg(
rawurlencode_deep( array_filter( compact( 'via', 'related', 'text', 'url' ) ) ),
'https://twitter.com/intent/tweet'
@@ -927,10 +1251,18 @@ class Share_Twitter extends Sharing_Source {
parent::redirect_request( $twitter_url );
}
+ /**
+ * Does this sharing source have a custom style.
+ *
+ * @return bool
+ */
public function has_custom_button_style() {
return $this->smart;
}
+ /**
+ * Add content specific to a service in the footer.
+ */
public function display_footer() {
if ( $this->smart ) {
?>
@@ -942,24 +1274,56 @@ class Share_Twitter extends Sharing_Source {
}
}
-
+/**
+ * Reddit sharing button.
+ */
class Share_Reddit extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'reddit';
+
+ /**
+ * Service icon font code.
+ *
+ * @var string
+ */
public $icon = '\f222';
+
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( 'official' == $this->button_style ) {
+ if ( 'official' === $this->button_style ) {
$this->smart = true;
} else {
$this->smart = false;
}
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return __( 'Reddit', 'jetpack' );
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
if ( $this->smart ) {
return '<div class="reddit_button"><iframe src="' . $this->http() . '://www.reddit.com/static/button/button1.html?newwindow=true&width=120&amp;url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&amp;title=' . rawurlencode( $this->get_share_title( $post->ID ) ) . '" height="22" width="120" scrolling="no" frameborder="0"></iframe></div>';
@@ -981,6 +1345,14 @@ class Share_Reddit extends Sharing_Source {
return $this->build_amp_markup( $attrs );
}
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
public function process_request( $post, array $post_data ) {
$reddit_url = $this->http() . '://reddit.com/submit?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&title=' . rawurlencode( $this->get_share_title( $post->ID ) );
@@ -991,33 +1363,71 @@ class Share_Reddit extends Sharing_Source {
}
}
+/**
+ * LinkedIn sharing button.
+ */
class Share_LinkedIn extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'linkedin';
+
+ /**
+ * Service icon font code.
+ *
+ * @var string
+ */
public $icon = '\f207';
+
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( 'official' == $this->button_style ) {
+ if ( 'official' === $this->button_style ) {
$this->smart = true;
} else {
$this->smart = false;
}
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return __( 'LinkedIn', 'jetpack' );
}
+ /**
+ * Does this sharing source have a custom style.
+ *
+ * @return bool
+ */
public function has_custom_button_style() {
return $this->smart;
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
$display = '';
if ( $this->smart ) {
$share_url = $this->get_share_url( $post->ID );
- $display .= sprintf( '<div class="linkedin_button"><script type="in/share" data-url="%s" data-counter="right"></script></div>', esc_url( $share_url ) );
+ $display .= sprintf( '<div class="linkedin_button"><script type="in/share" data-url="%s" data-counter="right"></script></div>', esc_url( $share_url ) );
} else {
$display = $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'LinkedIn', 'share to', 'jetpack' ), __( 'Click to share on LinkedIn', 'jetpack' ), 'share=linkedin', 'sharing-linkedin-' . $post->ID );
}
@@ -1030,15 +1440,26 @@ class Share_LinkedIn extends Sharing_Source {
return $display;
}
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
public function process_request( $post, array $post_data ) {
$post_link = $this->get_share_url( $post->ID );
// Using the same URL as the official button, which is *not* LinkedIn's documented sharing link
// https://www.linkedin.com/cws/share?url={url}&token=&isFramed=false
- $linkedin_url = add_query_arg( array(
- 'url' => rawurlencode( $post_link ),
- ), 'https://www.linkedin.com/cws/share?token=&isFramed=false' );
+ $linkedin_url = add_query_arg(
+ array(
+ 'url' => rawurlencode( $post_link ),
+ ),
+ 'https://www.linkedin.com/cws/share?token=&isFramed=false'
+ );
// Record stats
parent::process_request( $post, $post_data );
@@ -1046,9 +1467,18 @@ class Share_LinkedIn extends Sharing_Source {
parent::redirect_request( $linkedin_url );
}
+ /**
+ * Add content specific to a service in the footer.
+ */
public function display_footer() {
if ( ! $this->smart ) {
- $this->js_dialog( $this->shortname, array( 'width' => 580, 'height' => 450 ) );
+ $this->js_dialog(
+ $this->shortname,
+ array(
+ 'width' => 580,
+ 'height' => 450,
+ )
+ );
} else {
?>
<script type="text/javascript">
@@ -1091,11 +1521,37 @@ class Share_LinkedIn extends Sharing_Source {
}
}
+/**
+ * Facebook sharing button.
+ */
class Share_Facebook extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'facebook';
+
+ /**
+ * Service icon font code.
+ *
+ * @var string
+ */
public $icon = '\f204';
+
+ /**
+ * Sharing type.
+ *
+ * @var string
+ */
private $share_type = 'default';
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
@@ -1103,22 +1559,37 @@ class Share_Facebook extends Sharing_Source {
$this->share_type = $settings['share_type'];
}
- if ( 'official' == $this->button_style ) {
+ if ( 'official' === $this->button_style ) {
$this->smart = true;
} else {
$this->smart = false;
}
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return __( 'Facebook', 'jetpack' );
}
+ /**
+ * Add content specific to a service in the head.
+ */
public function display_header() {
}
- function guess_locale_from_lang( $lang ) {
- if ( 'en' == $lang || 'en_US' == $lang || ! $lang ) {
+ /**
+ * Guess locale from language code.
+ *
+ * @param string $lang Language code.
+ *
+ * @return string|bool
+ */
+ public function guess_locale_from_lang( $lang ) {
+ if ( 'en' === $lang || 'en_US' === $lang || ! $lang ) {
return 'en_US';
}
@@ -1157,9 +1628,16 @@ class Share_Facebook extends Sharing_Source {
return $locale->facebook_locale;
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
if ( $this->smart ) {
- $share_url = $this->get_share_url( $post->ID );
+ $share_url = $this->get_share_url( $post->ID );
$fb_share_html = '<div class="fb-share-button" data-href="' . esc_attr( $share_url ) . '" data-layout="button_count"></div>';
/**
* Filter the output of the Facebook Sharing button.
@@ -1186,7 +1664,7 @@ class Share_Facebook extends Sharing_Source {
*
* @param \WP_Post $post The current post being viewed.
*/
- public function get_amp_display( $post ) {
+ public function get_amp_display( $post ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$attrs = array(
/** This filter is documented in modules/sharedaddy/sharing-sources.php */
'data-param-app_id' => apply_filters( 'jetpack_sharing_facebook_app_id', '249643311490' ),
@@ -1195,6 +1673,14 @@ class Share_Facebook extends Sharing_Source {
return $this->build_amp_markup( $attrs );
}
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
public function process_request( $post, array $post_data ) {
$fb_url = $this->http() . '://www.facebook.com/sharer.php?u=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&t=' . rawurlencode( $this->get_share_title( $post->ID ) );
@@ -1204,6 +1690,9 @@ class Share_Facebook extends Sharing_Source {
parent::redirect_request( $fb_url );
}
+ /**
+ * Add content specific to a service in the footer.
+ */
public function display_footer() {
$this->js_dialog( $this->shortname );
if ( $this->smart ) {
@@ -1224,8 +1713,9 @@ class Share_Facebook extends Sharing_Source {
} else {
$fb_app_id = '';
}
- ?><div id="fb-root"></div>
- <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = 'https://connect.facebook.net/<?php echo $locale; ?>/sdk.js#xfbml=1<?php echo $fb_app_id; ?>&version=v2.3'; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>
+ ?>
+ <div id="fb-root"></div>
+ <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = 'https://connect.facebook.net/<?php echo esc_attr( $locale ); ?>/sdk.js#xfbml=1<?php echo esc_attr( $fb_app_id ); ?>&version=v2.3'; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>
<script>
document.body.addEventListener( 'is.post-load', function() {
if ( 'undefined' !== typeof FB ) {
@@ -1238,25 +1728,58 @@ class Share_Facebook extends Sharing_Source {
}
}
+/**
+ * Print button.
+ */
class Share_Print extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'print';
+
+ /**
+ * Service icon font code.
+ *
+ * @var string
+ */
public $icon = '\f469';
+
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( 'official' == $this->button_style ) {
+ if ( 'official' === $this->button_style ) {
$this->smart = true;
} else {
$this->smart = false;
}
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return __( 'Print', 'jetpack' );
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
- return $this->get_link( $this->get_process_request_url( $post->ID ) . ( ( is_single() || is_page() ) ? '#print': '' ), _x( 'Print', 'share to', 'jetpack' ), __( 'Click to print', 'jetpack' ) );
+ return $this->get_link( $this->get_process_request_url( $post->ID ) . ( ( is_single() || is_page() ) ? '#print' : '' ), _x( 'Print', 'share to', 'jetpack' ), __( 'Click to print', 'jetpack' ) );
}
/**
@@ -1273,23 +1796,57 @@ class Share_Print extends Sharing_Source {
}
}
+/**
+ * Press This Button.
+ */
class Share_PressThis extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'pressthis';
+
+ /**
+ * Service icon font code.
+ *
+ * @var string
+ */
public $icon = '\f205';
+
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( 'official' == $this->button_style ) {
+ if ( 'official' === $this->button_style ) {
$this->smart = true;
} else {
$this->smart = false;
}
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return __( 'Press This', 'jetpack' );
}
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
public function process_request( $post, array $post_data ) {
global $current_user;
@@ -1320,10 +1877,10 @@ class Share_PressThis extends Sharing_Source {
$args = array(
'u' => rawurlencode( $this->get_share_url( $post->ID ) ),
- );
+ );
- $args[ 'url-scan-submit' ] = 'Scan';
- $args[ '_wpnonce' ] = wp_create_nonce( 'scan-site' );
+ $args['url-scan-submit'] = 'Scan';
+ $args['_wpnonce'] = wp_create_nonce( 'scan-site' );
$url = $blog->siteurl . '/wp-admin/press-this.php';
$url = add_query_arg( $args, $url );
@@ -1334,6 +1891,13 @@ class Share_PressThis extends Sharing_Source {
parent::redirect_request( $url );
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Press This', 'share to', 'jetpack' ), __( 'Click to Press This!', 'jetpack' ), 'share=press-this' );
}
@@ -1348,24 +1912,65 @@ class Share_PressThis extends Sharing_Source {
}
}
+/**
+ * Custom (user-defined) sharing button.
+ */
class Share_Custom extends Sharing_Advanced_Source {
+ /**
+ * Sharing service name.
+ *
+ * @var string
+ */
private $name;
+
+ /**
+ * Sharing icon.
+ *
+ * @var string
+ */
private $icon;
+
+ /**
+ * Sharing service URL.
+ *
+ * @var string
+ */
private $url;
+
+ /**
+ * Does the service have an official version.
+ *
+ * @var bool
+ */
public $smart = true;
+
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname;
+ /**
+ * Custom sharing class.
+ *
+ * @return string
+ */
public function get_class() {
return 'custom share-custom-' . sanitize_html_class( strtolower( $this->name ) );
}
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- $opts = $this->get_options();
-
if ( isset( $settings['name'] ) ) {
- $this->name = $settings['name'];
+ $this->name = $settings['name'];
$this->shortname = preg_replace( '/[^a-z0-9]*/', '', $settings['name'] );
}
@@ -1373,14 +1978,14 @@ class Share_Custom extends Sharing_Advanced_Source {
$this->icon = $settings['icon'];
$new_icon = esc_url_raw( wp_specialchars_decode( $this->icon, ENT_QUOTES ) );
- $i = 0;
- while ( $new_icon != $this->icon ) {
+ $i = 0;
+ while ( $new_icon !== $this->icon ) {
if ( $i > 5 ) {
$this->icon = false;
break;
} else {
$this->icon = $new_icon;
- $new_icon = esc_url_raw( wp_specialchars_decode( $this->icon, ENT_QUOTES ) );
+ $new_icon = esc_url_raw( wp_specialchars_decode( $this->icon, ENT_QUOTES ) );
}
$i++;
}
@@ -1391,12 +1996,33 @@ class Share_Custom extends Sharing_Advanced_Source {
}
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return $this->name;
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
- $str = $this->get_link( $this->get_process_request_url( $post->ID ), esc_html( $this->name ), sprintf( __( 'Click to share on %s', 'jetpack' ), esc_attr( $this->name ) ), 'share=' . $this->id );
+ $str = $this->get_link(
+ $this->get_process_request_url( $post->ID ),
+ esc_html( $this->name ),
+ sprintf(
+ /* Translators: placeholder is the name of a social network. */
+ __( 'Click to share on %s', 'jetpack' ),
+ esc_attr( $this->name )
+ ),
+ 'share=' . $this->id
+ );
return str_replace( '<span>', '<span style="' . esc_attr( 'background-image:url("' . addcslashes( esc_url_raw( $this->icon ), '"' ) . '");' ) . '">', $str );
}
@@ -1405,10 +2031,18 @@ class Share_Custom extends Sharing_Advanced_Source {
*
* @param \WP_Post $post The current post being viewed.
*/
- public function get_amp_display( $post ) { // phpcs:ignore
+ public function get_amp_display( $post ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
return false;
}
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
public function process_request( $post, array $post_data ) {
$url = str_replace( '&amp;', '&', $this->url );
$url = str_replace( '%post_id%', rawurlencode( $post->ID ), $url );
@@ -1419,7 +2053,7 @@ class Share_Custom extends Sharing_Advanced_Source {
$url = str_replace( '%post_slug%', rawurlencode( $post->post_name ), $url );
if ( strpos( $url, '%post_tags%' ) !== false ) {
- $tags = get_the_tags( $post->ID );
+ $tags = get_the_tags( $post->ID );
$tagged = '';
if ( $tags ) {
@@ -1440,10 +2074,10 @@ class Share_Custom extends Sharing_Advanced_Source {
$url_excerpt = $post->post_content;
}
- $url_excerpt = strip_tags( strip_shortcodes( $url_excerpt ) );
+ $url_excerpt = wp_strip_all_tags( strip_shortcodes( $url_excerpt ) );
$url_excerpt = wp_html_excerpt( $url_excerpt, 100 );
$url_excerpt = rtrim( preg_replace( '/[^ .]*$/', '', $url_excerpt ) );
- $url = str_replace( '%post_excerpt%', rawurlencode( $url_excerpt ), $url );
+ $url = str_replace( '%post_excerpt%', rawurlencode( $url_excerpt ), $url );
}
// Record stats
@@ -1452,23 +2086,28 @@ class Share_Custom extends Sharing_Advanced_Source {
parent::redirect_request( $url );
}
+ /**
+ * Display options for our sharing buttons.
+ *
+ * @return void
+ */
public function display_options() {
-?>
+ ?>
<div class="input">
<table class="form-table">
<tbody>
<tr>
- <th scope="row"><?php _e( 'Label', 'jetpack' ); ?></th>
+ <th scope="row"><?php esc_html_e( 'Label', 'jetpack' ); ?></th>
<td><input type="text" name="name" value="<?php echo esc_attr( $this->name ); ?>" /></td>
</tr>
<tr>
- <th scope="row"><?php _e( 'URL', 'jetpack' ); ?></th>
+ <th scope="row"><?php esc_html_e( 'URL', 'jetpack' ); ?></th>
<td><input type="text" name="url" value="<?php echo esc_attr( $this->url ); ?>" /></td>
</tr>
<tr>
- <th scope="row"><?php _e( 'Icon', 'jetpack' ); ?></th>
+ <th scope="row"><?php esc_html_e( 'Icon', 'jetpack' ); ?></th>
<td><input type="text" name="icon" value="<?php echo esc_attr( $this->icon ); ?>" /></td>
</tr>
@@ -1476,26 +2115,33 @@ class Share_Custom extends Sharing_Advanced_Source {
<th scope="row"></th>
<td>
<input class="button-secondary" type="submit" value="<?php esc_attr_e( 'Save', 'jetpack' ); ?>" />
- <a href="#" class="remove"><small><?php _e( 'Remove Service', 'jetpack' ); ?></small></a>
+ <a href="#" class="remove"><small><?php esc_html_e( 'Remove Service', 'jetpack' ); ?></small></a>
</td>
</tr>
</tbody>
</table>
</div>
-<?php
+ <?php
}
+ /**
+ * Sanitize and save options for our sharing buttons.
+ *
+ * @param array $data Data to be saved.
+ *
+ * @return void
+ */
public function update_options( array $data ) {
- $name = trim( wp_html_excerpt( wp_kses( stripslashes( $data['name'] ), array() ), 30 ) );
- $url = trim( esc_url_raw( $data['url'] ) );
- $icon = trim( esc_url_raw( $data['icon'] ) );
+ $name = trim( wp_html_excerpt( wp_kses( stripslashes( $data['name'] ), array() ), 30 ) );
+ $url = trim( esc_url_raw( $data['url'] ) );
+ $icon = trim( esc_url_raw( $data['icon'] ) );
if ( $name ) {
$this->name = $name;
}
if ( $url ) {
- $this->url = $url;
+ $this->url = $url;
}
if ( $icon ) {
@@ -1503,6 +2149,11 @@ class Share_Custom extends Sharing_Advanced_Source {
}
}
+ /**
+ * Get array of information about the service.
+ *
+ * @return array
+ */
public function get_options() {
return array(
'name' => $this->name,
@@ -1511,65 +2162,108 @@ class Share_Custom extends Sharing_Advanced_Source {
);
}
- public function display_preview( $echo = true, $force_smart = false, $button_style = null ) {
+ /**
+ * Display a preview of the sharing button.
+ *
+ * @param bool $echo Whether to echo the output or return it.
+ * @param bool $force_smart Whether to force the smart (official) services to be shown.
+ * @param null|string $button_style Button style.
+ *
+ * @return void
+ */
+ public function display_preview( $echo = true, $force_smart = false, $button_style = null ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$opts = $this->get_options();
$text = '&nbsp;';
if ( ! $this->smart ) {
- if ( $this->button_style != 'icon' ) {
+ if ( $this->button_style !== 'icon' ) {
$text = $this->get_name();
}
}
$klasses = array( 'share-' . $this->shortname );
- if ( $this->button_style == 'icon' || $this->button_style == 'icon-text' ) {
+ if ( $this->button_style === 'icon' || $this->button_style === 'icon-text' ) {
$klasses[] = 'share-icon';
}
- if ( $this->button_style == 'icon' ) {
- $text = '';
+ if ( $this->button_style === 'icon' ) {
+ $text = '';
$klasses[] = 'no-text';
}
- if ( $this->button_style == 'text' ) {
+ if ( $this->button_style === 'text' ) {
$klasses[] = 'no-icon';
}
$link = sprintf(
'<a rel="nofollow" class="%s" href="javascript:void(0)" title="%s"><span style="background-image:url(&quot;%s&quot;) !important;background-position:left center;background-repeat:no-repeat;">%s</span></a>',
- implode( ' ', $klasses ),
- $this->get_name(),
+ esc_attr( implode( ' ', $klasses ) ),
+ esc_attr( $this->get_name() ),
addcslashes( esc_url_raw( $opts['icon'] ), '"' ),
- $text
+ esc_html( $text )
);
?>
<div class="option option-smart-off">
- <?php echo $link ; ?>
- </div><?php
+ <?php echo $link; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above. ?>
+ </div>
+ <?php
}
}
+/**
+ * Tumblr sharing service.
+ */
class Share_Tumblr extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'tumblr';
+
+ /**
+ * Service icon font code.
+ *
+ * @var string
+ */
public $icon = '\f214';
+
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( 'official' == $this->button_style ) {
+ if ( 'official' === $this->button_style ) {
$this->smart = true;
} else {
$this->smart = false;
}
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return __( 'Tumblr', 'jetpack' );
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
if ( $this->smart ) {
$target = '';
- if ( true == $this->open_link_in_new ) {
+ if ( true === $this->open_link_in_new ) {
$target = '_blank';
}
@@ -1595,11 +2289,19 @@ class Share_Tumblr extends Sharing_Source {
__( 'Share on Tumblr', 'jetpack' ),
$posttype
);
- } else {
+ } else {
return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Tumblr', 'share to', 'jetpack' ), __( 'Click to share on Tumblr', 'jetpack' ), 'share=tumblr' );
}
}
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
public function process_request( $post, array $post_data ) {
// Record stats
parent::process_request( $post, $post_data );
@@ -1610,32 +2312,77 @@ class Share_Tumblr extends Sharing_Source {
parent::redirect_request( $url );
}
+ /**
+ * Add content specific to a service in the footer.
+ */
public function display_footer() {
if ( $this->smart ) {
- ?><script id="tumblr-js" type="text/javascript" src="https://assets.tumblr.com/share-button.js"></script><?php
+ // phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript
+ ?>
+ <script id="tumblr-js" type="text/javascript" src="https://assets.tumblr.com/share-button.js"></script>
+ <?php
+ // phpcs:enable WordPress.WP.EnqueuedResources.NonEnqueuedScript
} else {
- $this->js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) );
+ $this->js_dialog(
+ $this->shortname,
+ array(
+ 'width' => 450,
+ 'height' => 450,
+ )
+ );
}
}
}
+/**
+ * Pinterest sharing service.
+ */
class Share_Pinterest extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'pinterest';
+
+ /**
+ * Service icon font code.
+ *
+ * @var string
+ */
public $icon = '\f209';
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( 'official' == $this->button_style ) {
+ if ( 'official' === $this->button_style ) {
$this->smart = true;
} else {
$this->smart = false;
}
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return __( 'Pinterest', 'jetpack' );
}
+ /**
+ * Get image representative of the post to pass on to Pinterest.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_image( $post ) {
if ( class_exists( 'Jetpack_PostImages' ) ) {
$image = Jetpack_PostImages::get_image( $post->ID, array( 'fallback_to_avatars' => true ) );
@@ -1656,6 +2403,13 @@ class Share_Pinterest extends Sharing_Source {
return apply_filters( 'jetpack_sharing_pinterest_default_image', 'https://s0.wp.com/i/blank.jpg' );
}
+ /**
+ * Get Pinterest external sharing URL.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_external_url( $post ) {
$url = 'https://www.pinterest.com/pin/create/button/?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&media=' . rawurlencode( $this->get_image( $post ) ) . '&description=' . rawurlencode( $post->post_title );
@@ -1671,6 +2425,11 @@ class Share_Pinterest extends Sharing_Source {
return apply_filters( 'jetpack_sharing_pinterest_share_url', $url );
}
+ /**
+ * Get Pinterest widget type.
+ *
+ * @return string
+ */
public function get_widget_type() {
/**
* Filters the Pinterest widget type.
@@ -1686,6 +2445,13 @@ class Share_Pinterest extends Sharing_Source {
return apply_filters( 'jetpack_sharing_pinterest_widget_type', 'buttonPin' );
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
$display = '';
@@ -1707,11 +2473,19 @@ class Share_Pinterest extends Sharing_Source {
return $display;
}
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
public function process_request( $post, array $post_data ) {
// Record stats
parent::process_request( $post, $post_data );
// If we're triggering the multi-select panel, then we don't need to redirect to Pinterest
- if ( ! isset( $_GET['js_only'] ) ) {
+ if ( ! isset( $_GET['js_only'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$pinterest_url = esc_url_raw( $this->get_external_url( $post ) );
parent::redirect_request( $pinterest_url );
} else {
@@ -1720,6 +2494,9 @@ class Share_Pinterest extends Sharing_Source {
}
}
+ /**
+ * Add content specific to a service in the footer.
+ */
public function display_footer() {
/**
* Filter the Pin it button appearing when hovering over images when using the official button style.
@@ -1765,7 +2542,7 @@ class Share_Pinterest extends Sharing_Source {
}
} )();
</script>
- <?php elseif ( 'buttonPin' != $this->get_widget_type() ) : ?>
+ <?php elseif ( 'buttonPin' !== $this->get_widget_type() ) : ?>
<script type="text/javascript">
( function () {
function init() {
@@ -1798,28 +2575,62 @@ class Share_Pinterest extends Sharing_Source {
}
} )();
</script>
- <?php endif;
+ <?php
+ endif;
}
}
+/**
+ * Pocket sharing service.
+ */
class Share_Pocket extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'pocket';
+
+ /**
+ * Service icon font code.
+ *
+ * @var string
+ */
public $icon = '\f224';
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
- if ( 'official' == $this->button_style ) {
+ if ( 'official' === $this->button_style ) {
$this->smart = true;
} else {
$this->smart = false;
}
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return __( 'Pocket', 'jetpack' );
}
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
public function process_request( $post, array $post_data ) {
// Record stats
parent::process_request( $post, $post_data );
@@ -1829,11 +2640,18 @@ class Share_Pocket extends Sharing_Source {
parent::redirect_request( $pocket_url );
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
if ( $this->smart ) {
$post_count = 'horizontal';
- $button = '';
+ $button = '';
$button .= '<div class="pocket_button">';
$button .= sprintf( '<a href="https://getpocket.com/save" class="pocket-btn" data-lang="%s" data-save-url="%s" data-pocket-count="%s" >%s</a>', 'en', esc_attr( $this->get_share_url( $post->ID ) ), $post_count, esc_attr__( 'Pocket', 'jetpack' ) );
$button .= '</div>';
@@ -1858,9 +2676,12 @@ class Share_Pocket extends Sharing_Source {
return $this->build_amp_markup( $attrs );
}
- function display_footer() {
+ /**
+ * Add content specific to a service in the footer.
+ */
+ public function display_footer() {
if ( $this->smart ) :
- ?>
+ ?>
<script>
( function () {
var currentScript = document.currentScript;
@@ -1882,25 +2703,59 @@ class Share_Pocket extends Sharing_Source {
document.body.addEventListener( 'is.post-load', jetpack_sharing_pocket_init );
} )();
</script>
- <?php
+ <?php
else :
- $this->js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) );
+ $this->js_dialog(
+ $this->shortname,
+ array(
+ 'width' => 450,
+ 'height' => 450,
+ )
+ );
endif;
}
}
+/**
+ * Telegram sharing service.
+ */
class Share_Telegram extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'telegram';
- public function __construct( $id, array $settings ) {
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
+ public function __construct( $id, array $settings ) { // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found
parent::__construct( $id, $settings );
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return __( 'Telegram', 'jetpack' );
}
+
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
public function process_request( $post, array $post_data ) {
// Record stats
parent::process_request( $post, $post_data );
@@ -1910,6 +2765,13 @@ class Share_Telegram extends Sharing_Source {
parent::redirect_request( $telegram_url );
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Telegram', 'share to', 'jetpack' ), __( 'Click to share on Telegram', 'jetpack' ), 'share=telegram' );
}
@@ -1927,22 +2789,57 @@ class Share_Telegram extends Sharing_Source {
return $this->build_amp_markup( $attrs );
}
- function display_footer() {
- $this->js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) );
+ /**
+ * Add content specific to a service in the footer.
+ */
+ public function display_footer() {
+ $this->js_dialog(
+ $this->shortname,
+ array(
+ 'width' => 450,
+ 'height' => 450,
+ )
+ );
}
}
+/**
+ * WhatsApp sharing service.
+ */
class Jetpack_Share_WhatsApp extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'jetpack-whatsapp';
- public function __construct( $id, array $settings ) {
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
+ public function __construct( $id, array $settings ) { // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found
parent::__construct( $id, $settings );
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return __( 'WhatsApp', 'jetpack' );
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'WhatsApp', 'share to', 'jetpack' ), __( 'Click to share on WhatsApp', 'jetpack' ), 'share=jetpack-whatsapp' );
}
@@ -1952,7 +2849,7 @@ class Jetpack_Share_WhatsApp extends Sharing_Source {
*
* @param \WP_Post $post The current post being viewed.
*/
- public function get_amp_display( $post ) {
+ public function get_amp_display( $post ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$attrs = array(
'type' => 'whatsapp',
);
@@ -1960,6 +2857,14 @@ class Jetpack_Share_WhatsApp extends Sharing_Source {
return $this->build_amp_markup( $attrs );
}
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
public function process_request( $post, array $post_data ) {
// Record stats
parent::process_request( $post, $post_data );
@@ -1977,11 +2882,37 @@ class Jetpack_Share_WhatsApp extends Sharing_Source {
}
}
+/**
+ * Skype sharing service.
+ */
class Share_Skype extends Sharing_Source {
+ /**
+ * Service short name.
+ *
+ * @var string
+ */
public $shortname = 'skype';
+
+ /**
+ * Service icon font code.
+ *
+ * @var string
+ */
public $icon = '\f220';
+
+ /**
+ * Sharing type.
+ *
+ * @var string
+ */
private $share_type = 'default';
+ /**
+ * Constructor.
+ *
+ * @param int $id Sharing source ID.
+ * @param array $settings Sharing settings.
+ */
public function __construct( $id, array $settings ) {
parent::__construct( $id, $settings );
@@ -1989,7 +2920,7 @@ class Share_Skype extends Sharing_Source {
$this->share_type = $settings['share_type'];
}
- if ( 'official' == $this->button_style ) {
+ if ( 'official' === $this->button_style ) {
$this->smart = true;
} else {
$this->smart = false;
@@ -1997,10 +2928,22 @@ class Share_Skype extends Sharing_Source {
}
+ /**
+ * Service name.
+ *
+ * @return string
+ */
public function get_name() {
return __( 'Skype', 'jetpack' );
}
+ /**
+ * Get the markup of the sharing button.
+ *
+ * @param WP_Post $post Post object.
+ *
+ * @return string
+ */
public function get_display( $post ) {
if ( $this->smart ) {
$skype_share_html = sprintf(
@@ -2016,7 +2959,12 @@ class Share_Skype extends Sharing_Source {
sharing_register_post_for_share_counts( $post->ID );
}
return $this->get_link(
- $this->get_process_request_url( $post->ID ), _x( 'Skype', 'share to', 'jetpack' ), __( 'Click to share on Skype', 'jetpack' ), 'share=skype', 'sharing-skype-' . $post->ID );
+ $this->get_process_request_url( $post->ID ),
+ _x( 'Skype', 'share to', 'jetpack' ),
+ __( 'Click to share on Skype', 'jetpack' ),
+ 'share=skype',
+ 'sharing-skype-' . $post->ID
+ );
}
/**
@@ -2036,6 +2984,14 @@ class Share_Skype extends Sharing_Source {
return $this->build_amp_markup( $attrs );
}
+ /**
+ * Process sharing request. Add actions that need to happen when sharing here.
+ *
+ * @param WP_Post $post Post object.
+ * @param array $post_data Array of information about the post we're sharing.
+ *
+ * @return void
+ */
public function process_request( $post, array $post_data ) {
$skype_url = sprintf(
'https://web.skype.com/share?url=%1$s&lang=%2$s=&source=jetpack',
@@ -2049,6 +3005,9 @@ class Share_Skype extends Sharing_Source {
parent::redirect_request( $skype_url );
}
+ /**
+ * Add content specific to a service in the footer.
+ */
public function display_footer() {
if ( $this->smart ) :
?>
@@ -2072,7 +3031,13 @@ class Share_Skype extends Sharing_Source {
</script>
<?php
else :
- $this->js_dialog( $this->shortname, array( 'width' => 305, 'height' => 665 ) );
+ $this->js_dialog(
+ $this->shortname,
+ array(
+ 'width' => 305,
+ 'height' => 665,
+ )
+ );
endif;
}
}
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.css b/plugins/jetpack/modules/sharedaddy/sharing.css
index 111386d2..d96cdd5d 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing.css
+++ b/plugins/jetpack/modules/sharedaddy/sharing.css
@@ -74,6 +74,16 @@ body.highlander-dark h3.sd-title:before {
font-size: 12px;
}
+/* Sharing email errors */
+.sd-content .share-email-error .share-email-error-title {
+ margin: 0.5em 0;
+}
+.sd-content .share-email-error .share-email-error-text {
+ font-family: "Open Sans", sans-serif;
+ font-size: 12px;
+ margin: 0.5em 0;
+}
+
/* Buttons */
.sd-social-icon .sd-content ul li a.sd-button,
@@ -683,79 +693,12 @@ body .sd-social-icon .sd-content li.share-custom a span {
}
-/**
- * Sharing Email Dialog
- */
-
-#sharing_email {
- width: 342px;
- position: absolute;
- z-index: 1001;
- border: 1px solid #ccc;
- padding: 15px;
- background: #fff;
- box-shadow: 0px 5px 20px rgba(0,0,0,.2);
- text-align: left;
-}
-
-div.sharedaddy.sharedaddy-dark #sharing_email {
- border-color: #fff;
-}
-
-#sharing_email .errors {
- color: #fff;
- background-color: #771a09;
- font-size: 12px;
- padding: 5px 8px;
- line-height: 1;
- margin: 10px 0 0 0;
-}
-
-#sharing_email label {
- font-size: 12px;
- color: #333;
- font-weight: bold;
- display: block;
- padding: 0 0 4px 0;
- text-align: left;
- text-shadow: none;
-}
-
-#sharing_email form {
- margin: 0;
-}
-
-#sharing_email input[type="text"], #sharing_email input[type="email"] {
- width: 100%;
- box-sizing: border-box;
- -moz-box-sizing:border-box;
- -webkit-box-sizing:border-box;
- border: 1px solid #ccc;
- margin-bottom: 1em;
- background: #fff;
- font-size: 12px;
- color: #333;
- max-width: none;
- padding: 1px 3px;
-}
#jetpack-source_f_name {
display: none!important;
position: absolute !important;
left: -9000px;
}
-#sharing_email .sharing_cancel {
- padding: 0 0 0 1em;
- font-size: 12px;
- text-shadow: none;
-}
-
-#sharing_email .recaptcha {
- width: 312px;
- height: 123px;
- margin: 0 0 1em 0;
-}
-
.sd-content .share-customize-link {
margin-top: 0em;
line-height: 11px;
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.js b/plugins/jetpack/modules/sharedaddy/sharing.js
index 44ec1563..2e8ada82 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing.js
+++ b/plugins/jetpack/modules/sharedaddy/sharing.js
@@ -1,4 +1,4 @@
-/* global WPCOM_sharing_counts, grecaptcha */
+/* global WPCOM_sharing_counts */
// NOTE: This file intentionally does not make use of polyfills or libraries,
// including jQuery. Please keep all code as IE11-compatible vanilla ES5, and
@@ -8,7 +8,6 @@
( function () {
var currentScript = document.currentScript;
- var recaptchaScriptAdded = false;
// -------------------------- UTILITY FUNCTIONS -------------------------- //
@@ -210,8 +209,6 @@
clearTimeout( this.openTimer );
clearTimeout( this.closeTimer );
- closeEmailDialog();
-
if ( this.recentlyOpenedByHover ) {
this.recentlyOpenedByHover = false;
clearTimeout( this.hoverOpenTimer );
@@ -225,7 +222,6 @@
if ( ! this.openedBy ) {
this.openTimer = setTimeout(
function () {
- closeEmailDialog();
this.open();
this.openedBy = 'hover';
this.recentlyOpenedByHover = true;
@@ -363,27 +359,81 @@
}
// ------------------------ BUTTON FUNCTIONALITY ------------------------ //
+ function isUrlForCurrentHost( url ) {
+ var currentDomain = window.location.protocol + '//' + window.location.hostname + '/';
+
+ return String( url ).indexOf( currentDomain ) === 0;
+ }
+
+ function getEncodedFormFieldForSubmit( name, value ) {
+ // Encode the key and value into a URI-compatible string.
+ var encoded = encodeURIComponent( name ) + '=' + encodeURIComponent( value );
+
+ // In x-www-form-urlencoded, spaces should be `+`, not `%20`.
+ return encoded.replace( /%20/g, '+' );
+ }
+
+ function trackButtonClick( button ) {
+ var clickCount = getClickCountForButton( button );
+
+ setClickCountForButton( button, clickCount + 1 );
+ }
+
+ function setClickCountForButton( button, clickCount ) {
+ button.setAttribute( 'jetpack-share-click-count', clickCount );
+ }
+
+ function getClickCountForButton( button ) {
+ var currentClickCount = button.getAttribute( 'jetpack-share-click-count' );
+ if ( currentClickCount === null ) {
+ return 0;
+ }
+
+ return parseInt( currentClickCount, 10 );
+ }
+
+ function showEmailShareError( emailShareButton, sdUlGroup ) {
+ var sdContent = sdUlGroup.parentElement;
+ if ( ! sdContent.classList.contains( 'sd-content' ) ) {
+ return;
+ }
- function shareIsEmail( val ) {
- return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(
- val
+ forEachNode( sdContent.querySelectorAll( '.share-email-error' ), function ( shareEmailError ) {
+ shareEmailError.parentElement.removeChild( shareEmailError );
+ } );
+
+ var newShareEmailError = document.createElement( 'div' );
+ newShareEmailError.className = 'share-email-error';
+
+ var newShareEmailErrorTitle = document.createElement( 'h6' );
+ newShareEmailErrorTitle.className = 'share-email-error-title';
+ newShareEmailErrorTitle.innerText = emailShareButton.getAttribute(
+ 'data-email-share-error-title'
+ );
+ newShareEmailError.appendChild( newShareEmailErrorTitle );
+
+ var newShareEmailErrorText = document.createElement( 'p' );
+ newShareEmailErrorText.className = 'share-email-error-text';
+ newShareEmailErrorText.innerText = emailShareButton.getAttribute(
+ 'data-email-share-error-text'
);
+ newShareEmailError.appendChild( newShareEmailErrorText );
+
+ sdContent.appendChild( newShareEmailError );
}
- function closeEmailDialog() {
- var dialog = document.querySelector( '#sharing_email' );
- hideNode( dialog );
+ function recordEmailShareClick( emailShareTrackerUrl, emailShareNonce ) {
+ var request = new XMLHttpRequest();
+ request.open( 'POST', emailShareTrackerUrl, true );
+ request.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8' );
+ request.setRequestHeader( 'x-requested-with', 'XMLHttpRequest' );
+
+ request.send( getEncodedFormFieldForSubmit( 'email-share-nonce', emailShareNonce ) );
}
// Sharing initialization.
// Will run immediately or on `DOMContentLoaded`, depending on current page status.
function init() {
- // Move email dialog to end of body.
- var emailDialog = document.querySelector( '#sharing_email' );
- if ( emailDialog ) {
- document.body.appendChild( emailDialog );
- }
-
WPCOMSharing_do();
}
if ( document.readyState !== 'loading' ) {
@@ -516,174 +566,26 @@
// Email button
forEachNode( group.querySelectorAll( 'a.share-email' ), function ( emailButton ) {
- var dialog = document.querySelector( '#sharing_email' );
+ setClickCountForButton( emailButton, 0 );
- emailButton.addEventListener( 'click', function ( event ) {
- event.preventDefault();
- event.stopPropagation();
+ var emailShareNonce = emailButton.getAttribute( 'data-email-share-nonce' );
+ var emailShareTrackerUrl = emailButton.getAttribute( 'data-email-share-track-url' );
- // Load reCAPTCHA if needed.
- if ( typeof grecaptcha !== 'object' && ! recaptchaScriptAdded ) {
- var configEl = document.querySelector( '.g-recaptcha' );
+ if (
+ emailShareNonce &&
+ emailShareTrackerUrl &&
+ isUrlForCurrentHost( emailShareTrackerUrl )
+ ) {
+ emailButton.addEventListener( 'click', function () {
+ trackButtonClick( emailButton );
- if ( configEl && configEl.getAttribute( 'data-lazy' ) === 'true' ) {
- recaptchaScriptAdded = true;
- loadScript( decodeURI( configEl.getAttribute( 'data-url' ) ) );
+ if ( getClickCountForButton( emailButton ) > 2 ) {
+ showEmailShareError( emailButton, group );
}
- }
-
- var url = emailButton.getAttribute( 'href' );
- var currentDomain = window.location.protocol + '//' + window.location.hostname + '/';
- if ( url.indexOf( currentDomain ) !== 0 ) {
- return true;
- }
-
- if ( ! isNodeHidden( dialog ) ) {
- closeEmailDialog();
- return;
- }
-
- removeNode( document.querySelector( '#sharing_email .response' ) );
- var form = document.querySelector( '#sharing_email form' );
- showNode( form );
- form.querySelector( 'input[type=submit]' ).removeAttribute( 'disabled' );
- showNode( form.querySelector( 'a.sharing_cancel' ) );
-
- // Reset reCATPCHA if exists.
- if (
- 'object' === typeof grecaptcha &&
- 'function' === typeof grecaptcha.reset &&
- window.___grecaptcha_cfg.count
- ) {
- grecaptcha.reset();
- }
-
- // Show dialog
- var rect = emailButton.getBoundingClientRect();
- var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || 0;
- var scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
- dialog.style.left = scrollLeft + rect.left + 'px';
- dialog.style.top = scrollTop + rect.top + rect.height + 'px';
- showNode( dialog );
-
- // Close all open More Button dialogs.
- MoreButton.closeAll();
- } );
-
- // Hook up other buttons
- dialog.querySelector( 'a.sharing_cancel' ).addEventListener( 'click', function ( event ) {
- event.preventDefault();
- event.stopPropagation();
-
- hideNode( dialog.querySelector( '.errors' ) );
- hideNode( dialog );
- hideNode( document.querySelector( '#sharing_background' ) );
- } );
-
- var submitButton = dialog.querySelector( 'input[type=submit]' );
- submitButton.addEventListener( 'click', function ( event ) {
- event.preventDefault();
- event.stopPropagation();
-
- var form = closest( submitButton, 'form' );
- var source_email_input = form.querySelector( 'input[name=source_email]' );
- var target_email_input = form.querySelector( 'input[name=target_email]' );
-
- // Disable buttons + enable loading icon
- submitButton.setAttribute( 'disabled', true );
- hideNode( form.querySelector( 'a.sharing_cancel' ) );
- forEachNode( form.querySelectorAll( 'img.loading' ), function ( img ) {
- showNode( img );
+ recordEmailShareClick( emailShareTrackerUrl, emailShareNonce );
} );
-
- hideNode( form.querySelector( '.errors' ) );
-
- forEachNode( form.querySelectorAll( '.error' ), function ( node ) {
- node.classList.remove( 'error' );
- } );
-
- if ( ! shareIsEmail( source_email_input.value ) ) {
- source_email_input.classList.add( 'error' );
- }
-
- if ( ! shareIsEmail( target_email_input.value ) ) {
- target_email_input.classList.add( 'error' );
- }
-
- if ( ! form.querySelector( '.error' ) ) {
- // Encode form data. This would be much easier if we could rely on URLSearchParams...
- var params = [];
- for ( var i = 0; i < form.elements.length; i++ ) {
- if ( form.elements[ i ].name ) {
- // Encode each form element into a URI-compatible string.
- var encoded =
- encodeURIComponent( form.elements[ i ].name ) +
- '=' +
- encodeURIComponent( form.elements[ i ].value );
- // In x-www-form-urlencoded, spaces should be `+`, not `%20`.
- params.push( encoded.replace( '%20', '+' ) );
- }
- }
- var data = params.join( '&' );
-
- // AJAX send the form
- var request = new XMLHttpRequest();
- request.open( 'POST', emailButton.getAttribute( 'href' ), true );
- request.setRequestHeader(
- 'Content-Type',
- 'application/x-www-form-urlencoded; charset=UTF-8'
- );
- request.setRequestHeader( 'x-requested-with', 'XMLHttpRequest' );
-
- request.onreadystatechange = function () {
- if ( this.readyState === XMLHttpRequest.DONE && this.status === 200 ) {
- forEachNode( form.querySelectorAll( 'img.loading' ), function ( img ) {
- hideNode( img );
- } );
-
- if ( this.response === '1' || this.response === '2' || this.response === '3' ) {
- showNode( dialog.querySelector( '.errors-' + this.response ) );
- dialog.querySelector( 'input[type=submit]' ).removeAttribute( 'disabled' );
- showNode( dialog.querySelector( 'a.sharing_cancel' ) );
-
- if ( typeof grecaptcha === 'object' && typeof grecaptcha.reset === 'function' ) {
- grecaptcha.reset();
- }
- } else {
- hideNode( form );
- var temp = document.createElement( 'div' );
- temp.innerHTML = this.response;
- dialog.appendChild( temp.firstChild );
- showNode( dialog.querySelector( 'a.sharing_cancel' ) );
- var closeButton = dialog.querySelector( '.response a.sharing_cancel' );
- if ( closeButton ) {
- closeButton.addEventListener( 'click', function ( event ) {
- event.preventDefault();
- event.stopPropagation();
-
- closeEmailDialog();
- hideNode( document.querySelector( '#sharing_background' ) );
- } );
- }
- }
- }
- };
-
- request.send( data );
-
- return;
- }
-
- forEachNode( dialog.querySelectorAll( 'img.loading' ), function ( img ) {
- hideNode( img );
- } );
- submitButton.removeAttribute( 'disabled' );
- showNode( dialog.querySelector( 'a.sharing_cancel' ) );
- forEachNode( dialog.querySelectorAll( '.errors-1' ), function ( error ) {
- showNode( error );
- } );
- } );
+ }
} );
} );
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.php b/plugins/jetpack/modules/sharedaddy/sharing.php
index 757dd4d5..f61472f9 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing.php
+++ b/plugins/jetpack/modules/sharedaddy/sharing.php
@@ -1,4 +1,9 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Set up Sharing functionality and management in wp-admin.
+ *
+ * @package automattic/jetpack
+ */
use Automattic\Jetpack\Assets;
@@ -7,24 +12,36 @@ if ( ! defined( 'WP_SHARING_PLUGIN_URL' ) ) {
define( 'WP_SHARING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
+/**
+ * Utilities to manage sharing settings from wp-admin.
+ */
class Sharing_Admin {
+ /**
+ * Constructor.
+ * Hook into WordPress to add our functionality.
+ */
public function __construct() {
require_once WP_SHARING_PLUGIN_DIR . 'sharing-service.php';
- add_action( 'admin_init', array( &$this, 'admin_init' ) );
- add_action( 'admin_menu', array( &$this, 'subscription_menu' ) );
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
+ add_action( 'admin_menu', array( $this, 'subscription_menu' ) );
// Insert our CSS and JS
- add_action( 'load-settings_page_sharing', array( &$this, 'sharing_head' ) );
+ add_action( 'load-settings_page_sharing', array( $this, 'sharing_head' ) );
// Catch AJAX
- add_action( 'wp_ajax_sharing_save_services', array( &$this, 'ajax_save_services' ) );
- add_action( 'wp_ajax_sharing_save_options', array( &$this, 'ajax_save_options' ) );
- add_action( 'wp_ajax_sharing_new_service', array( &$this, 'ajax_new_service' ) );
- add_action( 'wp_ajax_sharing_delete_service', array( &$this, 'ajax_delete_service' ) );
+ add_action( 'wp_ajax_sharing_save_services', array( $this, 'ajax_save_services' ) );
+ add_action( 'wp_ajax_sharing_save_options', array( $this, 'ajax_save_options' ) );
+ add_action( 'wp_ajax_sharing_new_service', array( $this, 'ajax_new_service' ) );
+ add_action( 'wp_ajax_sharing_delete_service', array( $this, 'ajax_delete_service' ) );
}
+ /**
+ * Enqueue scripts and styles on the sharing settings page.
+ *
+ * @return void
+ */
public function sharing_head() {
wp_enqueue_script(
'sharing-js',
@@ -33,7 +50,8 @@ class Sharing_Admin {
'modules/sharedaddy/admin-sharing.js'
),
array( 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-form' ),
- 2
+ 2,
+ false
);
/**
@@ -53,7 +71,7 @@ class Sharing_Admin {
wp_enqueue_style( 'sharing', WP_SHARING_PLUGIN_URL . 'sharing.css', false, JETPACK__VERSION );
wp_enqueue_style( 'social-logos' );
- wp_enqueue_script( 'sharing-js-fe', WP_SHARING_PLUGIN_URL . 'sharing.js', array(), 4 );
+ wp_enqueue_script( 'sharing-js-fe', WP_SHARING_PLUGIN_URL . 'sharing.js', array(), 4, false );
add_thickbox();
// On Jetpack sites, make sure we include CSS to style the admin page.
@@ -62,14 +80,27 @@ class Sharing_Admin {
}
}
+ /**
+ * Load the process that handles saving changes on the sharing settings page.
+ *
+ * @return void
+ */
public function admin_init() {
- if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'sharing.php' || $_GET['page'] == 'sharing' ) ) {
+ if ( isset( $_GET['page'] ) && ( $_GET['page'] === 'sharing.php' || $_GET['page'] === 'sharing' ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- nonces are handled in process_requests.
$this->process_requests();
}
}
+ /**
+ * Save changes to sharing settings.
+ *
+ * @return void
+ */
public function process_requests() {
- if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) ) {
+ if (
+ isset( $_POST['_wpnonce'] )
+ && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'sharing-options' )
+ ) {
$sharer = new Sharing_Service();
$sharer->set_global_options( $_POST );
/**
@@ -86,10 +117,16 @@ class Sharing_Admin {
}
}
- public function subscription_menu( $user ) {
+ /**
+ * Register Sharing settings menu page.
+ */
+ public function subscription_menu() {
if ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) {
$active = Jetpack::get_active_modules();
- if ( ! in_array( 'publicize', $active ) && ! current_user_can( 'manage_options' ) ) {
+ if (
+ ! in_array( 'publicize', $active, true )
+ && ! current_user_can( 'manage_options' )
+ ) {
return;
}
}
@@ -100,23 +137,53 @@ class Sharing_Admin {
__( 'Sharing', 'jetpack' ),
'publish_posts',
'sharing',
- array( &$this, 'wrapper_admin_page' )
+ array( $this, 'wrapper_admin_page' )
);
}
+ /**
+ * Save changes to sharing services via AJAX.
+ *
+ * @return void
+ */
public function ajax_save_services() {
- if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) && isset( $_POST['hidden'] ) && isset( $_POST['visible'] ) ) {
+ if (
+ isset( $_POST['_wpnonce'] )
+ && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'sharing-options' )
+ && isset( $_POST['hidden'] )
+ && isset( $_POST['visible'] )
+ ) {
$sharer = new Sharing_Service();
- $sharer->set_blog_services( explode( ',', $_POST['visible'] ), explode( ',', $_POST['hidden'] ) );
+ $sharer->set_blog_services(
+ explode( ',', sanitize_text_field( wp_unslash( $_POST['visible'] ) ) ),
+ explode( ',', sanitize_text_field( wp_unslash( $_POST['hidden'] ) ) )
+ );
die();
}
}
+ /**
+ * Create a new custom sharing service via AJAX.
+ *
+ * @return void
+ */
public function ajax_new_service() {
- if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['sharing_name'] ) && isset( $_POST['sharing_url'] ) && isset( $_POST['sharing_icon'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-new_service' ) ) {
- $sharer = new Sharing_Service();
- if ( $service = $sharer->new_service( stripslashes( $_POST['sharing_name'] ), stripslashes( $_POST['sharing_url'] ), stripslashes( $_POST['sharing_icon'] ) ) ) {
+ if (
+ isset( $_POST['_wpnonce'] )
+ && isset( $_POST['sharing_name'] )
+ && isset( $_POST['sharing_url'] )
+ && isset( $_POST['sharing_icon'] )
+ && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'sharing-new_service' )
+ ) {
+ $sharer = new Sharing_Service();
+ $service = $sharer->new_service(
+ sanitize_text_field( wp_unslash( $_POST['sharing_name'] ) ),
+ esc_url_raw( wp_unslash( $_POST['sharing_url'] ) ),
+ esc_url_raw( wp_unslash( $_POST['sharing_icon'] ) )
+ );
+
+ if ( $service ) {
$this->output_service( $service->get_id(), $service );
echo '<!--->';
$service->button_style = 'icon-text';
@@ -130,22 +197,46 @@ class Sharing_Admin {
die( '1' );
}
+ /**
+ * Delete a sharing service via AJAX.
+ *
+ * @return void
+ */
public function ajax_delete_service() {
- if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['service'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options_' . $_POST['service'] ) ) {
+ if (
+ isset( $_POST['_wpnonce'] )
+ && isset( $_POST['service'] )
+ && wp_verify_nonce(
+ sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ),
+ 'sharing-options_' . sanitize_text_field( wp_unslash( $_POST['service'] ) )
+ )
+ ) {
$sharer = new Sharing_Service();
- $sharer->delete_service( $_POST['service'] );
+ $sharer->delete_service( sanitize_text_field( wp_unslash( $_POST['service'] ) ) );
}
}
+ /**
+ * Save changes to sharing settings via AJAX.
+ *
+ * @return void
+ */
public function ajax_save_options() {
- if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['service'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options_' . $_POST['service'] ) ) {
- $sharer = new Sharing_Service();
- $service = $sharer->get_service( $_POST['service'] );
+ if (
+ isset( $_POST['_wpnonce'] )
+ && isset( $_POST['service'] )
+ && wp_verify_nonce(
+ sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ),
+ 'sharing-options_' . sanitize_text_field( wp_unslash( $_POST['service'] ) )
+ )
+ ) {
+ $sharer = new Sharing_Service();
+ $service = $sharer->get_service( sanitize_text_field( wp_unslash( $_POST['service'] ) ) );
if ( $service && $service instanceof Sharing_Advanced_Source ) {
$service->update_options( $_POST );
- $sharer->set_service( $_POST['service'], $service );
+ $sharer->set_service( sanitize_text_field( wp_unslash( $_POST['service'] ) ), $service );
}
$this->output_service( $service->get_id(), $service, true );
@@ -156,80 +247,120 @@ class Sharing_Admin {
}
}
+ /**
+ * Display a preview of a sharing service.
+ *
+ * @param object $service Sharing service object.
+ *
+ * @return void
+ */
public function output_preview( $service ) {
-
$klasses = array( 'advanced', 'preview-item' );
- if ( $service->button_style != 'text' || $service->has_custom_button_style() ) {
+ if ( $service->button_style !== 'text' || $service->has_custom_button_style() ) {
$klasses[] = 'preview-' . $service->get_class();
$klasses[] = 'share-' . $service->get_class();
if ( $service->is_deprecated() ) {
$klasses[] = 'share-deprecated';
}
- if ( $service->get_class() != $service->get_id() ) {
+ if ( $service->get_class() !== $service->get_id() ) {
$klasses[] = 'preview-' . $service->get_id();
}
}
- echo '<li class="' . implode( ' ', $klasses ) . '">';
+ echo '<li class="' . esc_attr( implode( ' ', $klasses ) ) . '">';
$service->display_preview();
echo '</li>';
}
- public function output_service( $id, $service, $show_dropdown = false ) {
- $title = '';
- $klasses = array( 'service', 'advanced', 'share-' . $service->get_class() );
+ /**
+ * Display a specific sharing service.
+ *
+ * @param int $id Service unique ID.
+ * @param object $service Sharing service.
+ * @param bool $show_dropdown Display a dropdown. Not in use at the moment.
+ *
+ * @return void
+ */
+ public function output_service( $id, $service, $show_dropdown = false ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
+ $title = '';
+ $klasses = array( 'service', 'advanced', 'share-' . $service->get_class() );
+ $displayed_klasses = implode( ' ', $klasses );
+
if ( $service->is_deprecated() ) {
/* translators: %1$s is the name of a deprecated Sharing Service like "Google+" */
- $title = sprintf( __( 'The %1$s service has shut down. This sharing button is not displayed to your visitors and should be removed.', 'jetpack' ), $service->get_name() );
+ $title = sprintf( __( 'The %1$s service has shut down. This sharing button is not displayed to your visitors and should be removed.', 'jetpack' ), $service->get_name() );
$klasses[] = 'share-deprecated';
}
-?>
- <li class="<?php echo implode( ' ', $klasses ); ?>" id="<?php echo $service->get_id(); ?>" tabindex="0" title="<?php echo esc_attr( $title ); ?>">
+ ?>
+ <li class="<?php echo esc_attr( $displayed_klasses ); ?>" id="<?php echo esc_attr( $service->get_id() ); ?>" tabindex="0" title="<?php echo esc_attr( $title ); ?>">
<span class="options-left"><?php echo esc_html( $service->get_name() ); ?></span>
<?php if ( 0 === strpos( $service->get_id(), 'custom-' ) || $service->has_advanced_options() ) : ?>
<span class="close"><a href="#" class="remove">&times;</a></span>
- <form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
+ <form method="post" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>">
<input type="hidden" name="action" value="sharing_delete_service" />
<input type="hidden" name="service" value="<?php echo esc_attr( $id ); ?>" />
- <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options_' . $id );?>" />
+ <input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( 'sharing-options_' . $id ) ); ?>" />
</form>
<?php endif; ?>
</li>
-<?php
+ <?php
}
+ /**
+ * Display admin UI within a Jetpack header and footer.
+ *
+ * @return void
+ */
public function wrapper_admin_page() {
- Jetpack_Admin_Page::wrap_ui( array( &$this, 'management_page' ), array( 'is-wide' =>true ) );
+ Jetpack_Admin_Page::wrap_ui( array( $this, 'management_page' ), array( 'is-wide' => true ) );
}
+ /**
+ * Sharing settings inner page structure.
+ *
+ * @return void
+ */
public function management_page() {
- $sharer = new Sharing_Service();
+ $sharer = new Sharing_Service();
$enabled = $sharer->get_blog_services();
- $global = $sharer->get_global_options();
+ $global = $sharer->get_global_options();
$shows = array_values( get_post_types( array( 'public' => true ) ) );
array_unshift( $shows, 'index' );
- if ( false == function_exists( 'mb_stripos' ) ) {
- echo '<div id="message" class="updated fade"><h3>' . __( 'Warning! Multibyte support missing!', 'jetpack' ) . '</h3>';
- echo '<p>' . sprintf( __( 'This plugin will work without it, but multibyte support is used <a href="%s" rel="noopener noreferrer" target="_blank">if available</a>. You may see minor problems with Tweets and other sharing services.', 'jetpack' ), 'https://www.php.net/manual/en/mbstring.installation.php' ) . '</p></div>';
+ if ( ! function_exists( 'mb_stripos' ) ) {
+ echo '<div id="message" class="updated fade"><h3>' . esc_html__( 'Warning! Multibyte support missing!', 'jetpack' ) . '</h3>';
+ echo '<p>' . wp_kses(
+ sprintf(
+ /* Translators: placeholder is a link to a PHP support document. */
+ __( 'This plugin will work without it, but multibyte support is used <a href="%s" rel="noopener noreferrer" target="_blank">if available</a>. You may see minor problems with Tweets and other sharing services.', 'jetpack' ),
+ 'https://www.php.net/manual/en/mbstring.installation.php'
+ ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'rel' => array(),
+ 'target' => array(),
+ ),
+ )
+ ) . '</p></div>';
}
- if ( isset( $_GET['update'] ) && $_GET['update'] == 'saved' ) {
- echo '<div class="updated"><p>' . __( 'Settings have been saved', 'jetpack' ) . '</p></div>';
+ if ( isset( $_GET['update'] ) && 'saved' === $_GET['update'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- only used to display a message.
+ echo '<div class="updated"><p>' . esc_html__( 'Settings have been saved', 'jetpack' ) . '</p></div>';
}
if ( ! isset( $global['sharing_label'] ) ) {
$global['sharing_label'] = __( 'Share this:', 'jetpack' );
}
-?>
+ ?>
<div class="wrap">
<div class="icon32" id="icon-options-general"><br /></div>
- <h1><?php _e( 'Sharing Settings', 'jetpack' ); ?></h1>
+ <h1><?php esc_html_e( 'Sharing Settings', 'jetpack' ); ?></h1>
<?php
/**
@@ -245,16 +376,16 @@ class Sharing_Admin {
<?php if ( current_user_can( 'manage_options' ) ) : ?>
<div class="share_manage_options">
- <h2><?php _e( 'Sharing Buttons', 'jetpack' ) ?></h2>
- <p><?php _e( 'Add sharing buttons to your blog and allow your visitors to share posts with their friends.', 'jetpack' ) ?></p>
+ <h2><?php esc_html_e( 'Sharing Buttons', 'jetpack' ); ?></h2>
+ <p><?php esc_html_e( 'Add sharing buttons to your blog and allow your visitors to share posts with their friends.', 'jetpack' ); ?></p>
<div id="services-config">
<table id="available-services">
<tr>
<td class="description">
- <h3><?php _e( 'Available Services', 'jetpack' ); ?></h3>
- <p><?php _e( "Drag and drop the services you'd like to enable into the box below.", 'jetpack' ); ?></p>
- <p><a href="#TB_inline?height=395&amp;width=600&amp;inlineId=new-service" class="thickbox" id="add-a-new-service"><?php _e( 'Add a new service', 'jetpack' ); ?></a></p>
+ <h3><?php esc_html_e( 'Available Services', 'jetpack' ); ?></h3>
+ <p><?php esc_html_e( "Drag and drop the services you'd like to enable into the box below.", 'jetpack' ); ?></p>
+ <p><a href="#TB_inline?height=395&amp;width=600&amp;inlineId=new-service" class="thickbox" id="add-a-new-service"><?php esc_html_e( 'Add a new service', 'jetpack' ); ?></a></p>
</td>
<td class="services">
<ul class="services-available" style="height: 100px;">
@@ -263,12 +394,12 @@ class Sharing_Admin {
if ( ! isset( $enabled['all'][ $id ] ) ) {
$this->output_service( $id, $service );
}
- ?>
+ ?>
<?php endforeach; ?>
</ul>
<?php
- if ( -1 == get_option( 'blog_public' ) ) {
- echo '<p><strong>' . __( 'Please note that your services have been restricted because your site is private.', 'jetpack' ) . '</strong></p>';
+ if ( -1 === get_option( 'blog_public' ) ) {
+ echo '<p><strong>' . esc_html__( 'Please note that your services have been restricted because your site is private.', 'jetpack' ) . '</strong></p>';
}
?>
<br class="clearing" />
@@ -280,13 +411,18 @@ class Sharing_Admin {
<tr>
<td class="description">
<h3>
- <?php _e( 'Enabled Services', 'jetpack' ); ?>
- <img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
+ <?php esc_html_e( 'Enabled Services', 'jetpack' ); ?>
+ <img src="<?php echo esc_url( admin_url( 'images/loading.gif' ) ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
</h3>
- <p><?php _e( 'Services dragged here will appear individually.', 'jetpack' ); ?></p>
+ <p><?php esc_html_e( 'Services dragged here will appear individually.', 'jetpack' ); ?></p>
</td>
<td class="services" id="share-drop-target">
- <h2 id="drag-instructions" <?php if ( count( $enabled['visible'] ) > 0 ) { echo ' style="display: none"';} ?>><?php _e( 'Drag and drop available services here.', 'jetpack' ); ?></h2>
+ <h2 id="drag-instructions"
+ <?php
+ if ( count( $enabled['visible'] ) > 0 ) {
+ echo ' style="display: none"';}
+ ?>
+ ><?php esc_html_e( 'Drag and drop available services here.', 'jetpack' ); ?></h2>
<ul class="services-enabled">
<?php foreach ( $enabled['visible'] as $id => $service ) : ?>
@@ -297,7 +433,7 @@ class Sharing_Admin {
</ul>
</td>
<td id="hidden-drop-target" class="services">
- <p><?php _e( 'Services dragged here will be hidden behind a share button.', 'jetpack' ); ?></p>
+ <p><?php esc_html_e( 'Services dragged here will be hidden behind a share button.', 'jetpack' ); ?></p>
<ul class="services-hidden">
<?php foreach ( $enabled['hidden'] as $id => $service ) : ?>
@@ -312,10 +448,10 @@ class Sharing_Admin {
<table id="live-preview">
<tr>
<td class="description">
- <h3><?php _e( 'Live Preview', 'jetpack' ); ?></h3>
+ <h3><?php esc_html_e( 'Live Preview', 'jetpack' ); ?></h3>
</td>
<td class="services">
- <h2 <?php echo ( count( $enabled['all'] ) > 0 ) ? ' style="display: none"' : ''; ?>><?php _e( 'Sharing is off. Add services above to enable.', 'jetpack' ); ?></h2>
+ <h2 <?php echo ( count( $enabled['all'] ) > 0 ) ? ' style="display: none"' : ''; ?>><?php esc_html_e( 'Sharing is off. Add services above to enable.', 'jetpack' ); ?></h2>
<div class="sharedaddy sd-sharing-enabled">
<?php if ( count( $enabled['all'] ) > 0 ) : ?>
<h3 class="sd-title"><?php echo esc_html( $global['sharing_label'] ); ?></h3>
@@ -327,14 +463,14 @@ class Sharing_Admin {
<?php endforeach; ?>
<?php if ( count( $enabled['hidden'] ) > 0 ) : ?>
- <li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php _e( 'More', 'jetpack' ); ?></span></a></li>
+ <li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php esc_html_e( 'More', 'jetpack' ); ?></span></a></li>
<?php endif; ?>
</ul>
<?php if ( count( $enabled['hidden'] ) > 0 ) : ?>
<div class="sharing-hidden">
- <div class="inner" style="display: none; <?php echo count( $enabled['hidden'] ) == 1 ? 'width:150px;' : ''; ?>">
- <?php if ( count( $enabled['hidden'] ) == 1 ) : ?>
+ <div class="inner" style="display: none; <?php echo count( $enabled['hidden'] ) === 1 ? 'width:150px;' : ''; ?>">
+ <?php if ( count( $enabled['hidden'] ) === 1 ) : ?>
<ul style="background-image:none;">
<?php else : ?>
<ul>
@@ -359,11 +495,12 @@ class Sharing_Admin {
$service = $enabled['hidden'][ $id ];
}
- $service->button_style = 'icon-text'; // The archive needs the full text, which is removed in JS later
- $service->smart = false;
+ $service->button_style = 'icon-text'; // The archive needs the full text, which is removed in JS later.
+ $service->smart = false;
$this->output_preview( $service );
- endforeach; ?>
- <li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php _e( 'More', 'jetpack' ); ?></span></a></li>
+ endforeach;
+ ?>
+ <li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php esc_html_e( 'More', 'jetpack' ); ?></span></a></li>
</ul>
</div>
</div>
@@ -372,11 +509,11 @@ class Sharing_Admin {
</tr>
</table>
- <form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="save-enabled-shares">
+ <form method="post" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" id="save-enabled-shares">
<input type="hidden" name="action" value="sharing_save_services" />
- <input type="hidden" name="visible" value="<?php echo implode( ',', array_keys( $enabled['visible'] ) ); ?>" />
- <input type="hidden" name="hidden" value="<?php echo implode( ',', array_keys( $enabled['hidden'] ) ); ?>" />
- <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
+ <input type="hidden" name="visible" value="<?php echo esc_attr( implode( ',', array_keys( $enabled['visible'] ) ) ); ?>" />
+ <input type="hidden" name="hidden" value="<?php echo esc_attr( implode( ',', array_keys( $enabled['hidden'] ) ) ); ?>" />
+ <input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( 'sharing-options' ) ); ?>" />
</form>
</div>
@@ -384,18 +521,18 @@ class Sharing_Admin {
<table class="form-table">
<tbody>
<tr valign="top">
- <th scope="row"><label><?php _e( 'Button style', 'jetpack' ); ?></label></th>
+ <th scope="row"><label><?php esc_html_e( 'Button style', 'jetpack' ); ?></label></th>
<td>
<select name="button_style" id="button_style">
- <option<?php echo ( $global['button_style'] == 'icon-text' ) ? ' selected="selected"' : ''; ?> value="icon-text"><?php _e( 'Icon + text', 'jetpack' ); ?></option>
- <option<?php echo ( $global['button_style'] == 'icon' ) ? ' selected="selected"' : ''; ?> value="icon"><?php _e( 'Icon only', 'jetpack' ); ?></option>
- <option<?php echo ( $global['button_style'] == 'text' ) ? ' selected="selected"' : ''; ?> value="text"><?php _e( 'Text only', 'jetpack' ); ?></option>
- <option<?php echo ( $global['button_style'] == 'official' ) ? ' selected="selected"' : ''; ?> value="official"><?php _e( 'Official buttons', 'jetpack' ); ?></option>
+ <option<?php echo ( $global['button_style'] === 'icon-text' ) ? ' selected="selected"' : ''; ?> value="icon-text"><?php esc_html_e( 'Icon + text', 'jetpack' ); ?></option>
+ <option<?php echo ( $global['button_style'] === 'icon' ) ? ' selected="selected"' : ''; ?> value="icon"><?php esc_html_e( 'Icon only', 'jetpack' ); ?></option>
+ <option<?php echo ( $global['button_style'] === 'text' ) ? ' selected="selected"' : ''; ?> value="text"><?php esc_html_e( 'Text only', 'jetpack' ); ?></option>
+ <option<?php echo ( $global['button_style'] === 'official' ) ? ' selected="selected"' : ''; ?> value="official"><?php esc_html_e( 'Official buttons', 'jetpack' ); ?></option>
</select>
</td>
</tr>
<tr valign="top">
- <th scope="row"><label><?php _e( 'Sharing label', 'jetpack' ); ?></label></th>
+ <th scope="row"><label><?php esc_html_e( 'Sharing label', 'jetpack' ); ?></label></th>
<td>
<input type="text" name="sharing_label" value="<?php echo esc_attr( $global['sharing_label'] ); ?>" />
</td>
@@ -410,28 +547,28 @@ class Sharing_Admin {
*
* @param string $var Opening HTML tag at the beginning of the "Show button on" row.
*/
- echo apply_filters( 'sharing_show_buttons_on_row_start', '<tr valign="top">' );
+ echo apply_filters( 'sharing_show_buttons_on_row_start', '<tr valign="top">' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
- <th scope="row"><label><?php _e( 'Show buttons on', 'jetpack' ); ?></label></th>
+ <th scope="row"><label><?php esc_html_e( 'Show buttons on', 'jetpack' ); ?></label></th>
<td>
<?php
$br = false;
foreach ( $shows as $show ) :
- if ( 'index' == $show ) {
+ if ( 'index' === $show ) {
$label = __( 'Front Page, Archive Pages, and Search Results', 'jetpack' );
} else {
$post_type_object = get_post_type_object( $show );
- $label = $post_type_object->labels->name;
+ $label = $post_type_object->labels->name;
}
- ?>
- <?php
- if ( $br ) {
- echo '<br />';
- }
- ?>
- <label><input type="checkbox"<?php checked( in_array( $show, $global['show'] ) ); ?> name="show[]" value="<?php echo esc_attr( $show ); ?>" /> <?php echo esc_html( $label ); ?></label>
- <?php
- $br = true;
+ ?>
+ <?php
+ if ( $br ) {
+ echo '<br />';
+ }
+ ?>
+ <label><input type="checkbox"<?php checked( in_array( $show, $global['show'], true ) ); ?> name="show[]" value="<?php echo esc_attr( $show ); ?>" /> <?php echo esc_html( $label ); ?></label>
+ <?php
+ $br = true;
endforeach;
?>
</td>
@@ -445,7 +582,7 @@ class Sharing_Admin {
*
* @param string $var Closing HTML tag at the end of the "Show button on" row.
*/
- echo apply_filters( 'sharing_show_buttons_on_row_end', '</tr>' );
+ echo apply_filters( 'sharing_show_buttons_on_row_end', '</tr>' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
<?php
@@ -465,40 +602,40 @@ class Sharing_Admin {
<input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'jetpack' ); ?>" />
</p>
- <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
+ <input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( 'sharing-options' ) ); ?>" />
</form>
<div id="new-service" style="display: none">
- <form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="new-service-form">
+ <form method="post" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" id="new-service-form">
<table class="form-table">
<tbody>
<tr valign="top">
- <th scope="row" width="100"><label><?php _e( 'Service name', 'jetpack' ); ?></label></th>
+ <th scope="row" width="100"><label><?php esc_html_e( 'Service name', 'jetpack' ); ?></label></th>
<td>
<input type="text" name="sharing_name" id="new_sharing_name" size="40" />
</td>
</tr>
<tr valign="top">
- <th scope="row" width="100"><label><?php _e( 'Sharing URL', 'jetpack' ); ?></label></th>
+ <th scope="row" width="100"><label><?php esc_html_e( 'Sharing URL', 'jetpack' ); ?></label></th>
<td>
<input type="text" name="sharing_url" id="new_sharing_url" size="40" />
- <p><?php _e( 'You can add the following variables to your service sharing URL:', 'jetpack' ); ?><br/>
+ <p><?php esc_html_e( 'You can add the following variables to your service sharing URL:', 'jetpack' ); ?><br/>
<code>%post_id%</code>, <code>%post_title%</code>, <code>%post_slug%</code>, <code>%post_url%</code>, <code>%post_full_url%</code>, <code>%post_excerpt%</code>, <code>%post_tags%</code>, <code>%home_url%</code></p>
</td>
</tr>
<tr valign="top">
- <th scope="row" width="100"><label><?php _e( 'Icon URL', 'jetpack' ); ?></label></th>
+ <th scope="row" width="100"><label><?php esc_html_e( 'Icon URL', 'jetpack' ); ?></label></th>
<td>
<input type="text" name="sharing_icon" id="new_sharing_icon" size="40" />
- <p><?php _e( 'Enter the URL of a 16x16px icon you want to use for this service.', 'jetpack' ); ?></p>
+ <p><?php esc_html_e( 'Enter the URL of a 16x16px icon you want to use for this service.', 'jetpack' ); ?></p>
</td>
</tr>
<tr valign="top" width="100">
<th scope="row"></th>
<td>
<input type="submit" class="button-primary" value="<?php esc_attr_e( 'Create Share Button', 'jetpack' ); ?>" />
- <img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
+ <img src="<?php echo esc_url( admin_url( 'images/loading.gif' ) ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
</td>
</tr>
@@ -515,23 +652,23 @@ class Sharing_Admin {
</tbody>
</table>
- <?php
- /**
- * Fires at the bottom of the admin sharing settings screen.
- *
- * @module sharedaddy
- *
- * @since 1.6.0
- */
- do_action( 'post_admin_screen_sharing' );
- ?>
+ <?php
+ /**
+ * Fires at the bottom of the admin sharing settings screen.
+ *
+ * @module sharedaddy
+ *
+ * @since 1.6.0
+ */
+ do_action( 'post_admin_screen_sharing' );
+ ?>
<div class="inerror" style="display: none; margin-top: 15px">
- <p><?php _e( 'An error occurred creating your new sharing service - please check you gave valid details.', 'jetpack' ); ?></p>
+ <p><?php esc_html_e( 'An error occurred creating your new sharing service - please check you gave valid details.', 'jetpack' ); ?></p>
</div>
<input type="hidden" name="action" value="sharing_new_service" />
- <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-new_service' );?>" />
+ <input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( 'sharing-new_service' ) ); ?>" />
</form>
</div>
</div>
@@ -543,17 +680,24 @@ class Sharing_Admin {
<script type="text/javascript">
var sharing_loading_icon = '<?php echo esc_js( admin_url( '/images/loading.gif' ) ); ?>';
- <?php if ( isset( $_GET['create_new_service'] ) && 'true' == $_GET['create_new_service'] ) : ?>
+ <?php
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended -- we handle the nonce on the PHP side.
+ if (
+ isset( $_GET['create_new_service'], $_GET['name'], $_GET['url'], $_GET['icon'] )
+ && 'true' == $_GET['create_new_service'] // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
+ ) :
+ ?>
jQuery(document).ready(function() {
// Prefill new service box and then open it
- jQuery( '#new_sharing_name' ).val( '<?php echo esc_js( $_GET['name'] ); ?>' );
- jQuery( '#new_sharing_url' ).val( '<?php echo esc_js( $_GET['url'] ); ?>' );
- jQuery( '#new_sharing_icon' ).val( '<?php echo esc_js( $_GET['icon'] ); ?>' );
+ jQuery( '#new_sharing_name' ).val( '<?php echo esc_js( sanitize_text_field( wp_unslash( $_GET['name'] ) ) ); ?>' );
+ jQuery( '#new_sharing_url' ).val( '<?php echo esc_js( sanitize_text_field( wp_unslash( $_GET['url'] ) ) ); ?>' );
+ jQuery( '#new_sharing_icon' ).val( '<?php echo esc_js( sanitize_text_field( wp_unslash( $_GET['icon'] ) ) ); ?>' );
jQuery( '#add-a-new-service' ).click();
});
<?php endif; ?>
</script>
-<?php
+ <?php
+ // phpcs:enable WordPress.Security.NonceVerification.Recommended
}
}
@@ -563,6 +707,10 @@ class Sharing_Admin {
* When the sharing_disabled post_meta is unset, we follow the global setting in Sharing.
* When it is set to 1, we disable sharing on the post, regardless of the global setting.
* It is not possible to enable sharing on a post if it is disabled globally.
+ *
+ * @param array $post The post object.
+ *
+ * @return bool
*/
function jetpack_post_sharing_get_value( array $post ) {
// if sharing IS disabled on this post, enabled=false, so negate the meta
@@ -577,6 +725,10 @@ function jetpack_post_sharing_get_value( array $post ) {
* When it is set to 1, we disable sharing on the post, regardless of the global setting.
* It is not possible to enable sharing on a post if it is disabled globally.
*
+ * @param bool $enable_sharing Should sharing be enabled on this post.
+ * @param WP_Post $post_object The post object.
+ *
+ * @return int|bool
*/
function jetpack_post_sharing_update_value( $enable_sharing, $post_object ) {
if ( $enable_sharing ) {
@@ -625,6 +777,11 @@ add_action( 'rest_api_init', 'jetpack_post_sharing_register_rest_field' );
// restapi_theme_init because they depend on theme support, so let's also hook to that
add_action( 'restapi_theme_init', 'jetpack_post_likes_register_rest_field', 20 );
+/**
+ * Initialize sharing settings in WP Admin.
+ *
+ * @return void
+ */
function sharing_admin_init() {
global $sharing_admin;
diff --git a/plugins/jetpack/modules/shortcodes.php b/plugins/jetpack/modules/shortcodes.php
index 39e18d49..cb77ca92 100644
--- a/plugins/jetpack/modules/shortcodes.php
+++ b/plugins/jetpack/modules/shortcodes.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Module Name: Shortcode Embeds
* Module Description: Shortcodes are WordPress-specific markup that let you add media from popular sites. This feature is no longer necessary as the editor now handles media embeds rather gracefully.
@@ -10,7 +9,9 @@
* Auto Activate: No
* Module Tags: Photos and Videos, Social, Writing, Appearance
* Feature: Writing
- * Additional Search Queries: shortcodes, shortcode, embeds, media, bandcamp, dailymotion, facebook, flickr, google calendars, google maps, google+, polldaddy, recipe, recipes, scribd, slideshare, slideshow, slideshows, soundcloud, ted, twitter, vimeo, vine, youtube
+ * Additional Search Queries: shortcodes, shortcode, embeds, media, bandcamp, dailymotion, facebook, flickr, google calendars, google maps, polldaddy, recipe, recipes, scribd, slideshare, slideshow, slideshows, soundcloud, ted, twitter, vimeo, vine, youtube
+ *
+ * @package automattic/jetpack
*/
/**
@@ -47,7 +48,7 @@ function shortcode_new_to_old_params( $params, $old_format_support = false ) {
function jetpack_load_shortcodes() {
$shortcode_includes = array();
- foreach ( Jetpack::glob_php( dirname( __FILE__ ) . '/shortcodes' ) as $file ) {
+ foreach ( Jetpack::glob_php( __DIR__ . '/shortcodes' ) as $file ) {
$filename = substr( basename( $file ), 0, -4 );
$shortcode_includes[ $filename ] = $file;
@@ -178,7 +179,7 @@ function wpcom_shortcodereverse_parseattr( $attrs ) {
$attrs = shortcode_atts( $defaults, $attrs );
- $attrs['src'] = strip_tags( $attrs['src'] ); // For sanity
+ $attrs['src'] = wp_strip_all_tags( $attrs['src'] ); // For sanity.
$attrs['width'] = ( is_numeric( $attrs['width'] ) ) ? abs( (int) $attrs['width'] ) : $defaults['width'];
$attrs['height'] = ( is_numeric( $attrs['height'] ) ) ? abs( (int) $attrs['height'] ) : $defaults['height'];
@@ -188,6 +189,11 @@ function wpcom_shortcodereverse_parseattr( $attrs ) {
/**
* When an embed service goes away, we can use this handler
* to output a link for history's sake.
+ *
+ * @param array $matches Regex partial matches against the URL passed.
+ * @param array $attr Attributes received in embed response.
+ * @param string $url Requested URL to be embedded.
+ * @return string Link to output.
*/
function jetpack_deprecated_embed_handler( $matches, $attr, $url ) {
return sprintf( '<a href="%s">%s</a>', esc_url( $url ), esc_html( esc_url( $url ) ) );
diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-print.min.css b/plugins/jetpack/modules/shortcodes/css/recipes-print.min.css
index 52cf81bf..c21ef4c8 100644
--- a/plugins/jetpack/modules/shortcodes/css/recipes-print.min.css
+++ b/plugins/jetpack/modules/shortcodes/css/recipes-print.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
.jetpack-recipe-meta li.jetpack-recipe-print{display:none}.jetpack-recipe-title{font-size:16pt}.jetpack-recipe-content img{display:inline-block!important;max-width:100%}.jetpack-recipe-image{display:none!important}.jetpack-recipe-content .aligncenter{display:block!important;margin:0 auto 1em!important;text-align:center!important}.jetpack-recipe-content .alignright{float:right!important;margin:0 0 .5em 1em!important}.jetpack-recipe-content .alignleft{float:left!important;margin:0 1em .5em 0!important}.jetpack-recipe-content .alignnone{display:inline-block} \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-rtl.css b/plugins/jetpack/modules/shortcodes/css/recipes-rtl.css
index a0492b5f..ee8280a6 100644
--- a/plugins/jetpack/modules/shortcodes/css/recipes-rtl.css
+++ b/plugins/jetpack/modules/shortcodes/css/recipes-rtl.css
@@ -1 +1 @@
-.jetpack-recipe{border:1px solid #f2f2f2;border-radius:1px;clear:both;margin:1.5em 1%;padding:1% 2%}.jetpack-recipe-title{border-bottom:1px solid #ccc;margin:.25em 0;padding:.25em 0}.jetpack-recipe .jetpack-recipe-meta{display:block;font-size:.9em;list-style-type:none;margin-left:0;margin-right:0;padding:0;overflow:hidden;width:100%}.jetpack-recipe .jetpack-recipe-meta li{float:right;list-style-type:none;margin:0;padding:0 0 0 5%}.jetpack-recipe-meta li.jetpack-recipe-print{float:left;padding-left:0;text-align:left}.jetpack-recipe-notes{font-style:italic} \ No newline at end of file
+.jetpack-recipe{border:1px solid #f2f2f2;border-radius:1px;clear:both;margin:1.5em 1%;padding:1% 2%}.jetpack-recipe-title{border-bottom:1px solid #ccc;margin:.25em 0;padding:.25em 0}.jetpack-recipe .jetpack-recipe-meta{display:block;font-size:.9em;list-style-type:none;margin-left:0;margin-right:0;overflow:hidden;padding:0;width:100%}.jetpack-recipe .jetpack-recipe-meta li{float:right;list-style-type:none;margin:0;padding:0 0 0 5%}.jetpack-recipe-meta li.jetpack-recipe-print{float:left;padding-left:0;text-align:left}.jetpack-recipe-notes{font-style:italic} \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-rtl.min.css b/plugins/jetpack/modules/shortcodes/css/recipes-rtl.min.css
index a0492b5f..ee8280a6 100644
--- a/plugins/jetpack/modules/shortcodes/css/recipes-rtl.min.css
+++ b/plugins/jetpack/modules/shortcodes/css/recipes-rtl.min.css
@@ -1 +1 @@
-.jetpack-recipe{border:1px solid #f2f2f2;border-radius:1px;clear:both;margin:1.5em 1%;padding:1% 2%}.jetpack-recipe-title{border-bottom:1px solid #ccc;margin:.25em 0;padding:.25em 0}.jetpack-recipe .jetpack-recipe-meta{display:block;font-size:.9em;list-style-type:none;margin-left:0;margin-right:0;padding:0;overflow:hidden;width:100%}.jetpack-recipe .jetpack-recipe-meta li{float:right;list-style-type:none;margin:0;padding:0 0 0 5%}.jetpack-recipe-meta li.jetpack-recipe-print{float:left;padding-left:0;text-align:left}.jetpack-recipe-notes{font-style:italic} \ No newline at end of file
+.jetpack-recipe{border:1px solid #f2f2f2;border-radius:1px;clear:both;margin:1.5em 1%;padding:1% 2%}.jetpack-recipe-title{border-bottom:1px solid #ccc;margin:.25em 0;padding:.25em 0}.jetpack-recipe .jetpack-recipe-meta{display:block;font-size:.9em;list-style-type:none;margin-left:0;margin-right:0;overflow:hidden;padding:0;width:100%}.jetpack-recipe .jetpack-recipe-meta li{float:right;list-style-type:none;margin:0;padding:0 0 0 5%}.jetpack-recipe-meta li.jetpack-recipe-print{float:left;padding-left:0;text-align:left}.jetpack-recipe-notes{font-style:italic} \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/css/recipes.min.css b/plugins/jetpack/modules/shortcodes/css/recipes.min.css
index e4e36a3d..d4ae4f51 100644
--- a/plugins/jetpack/modules/shortcodes/css/recipes.min.css
+++ b/plugins/jetpack/modules/shortcodes/css/recipes.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-.jetpack-recipe{border:1px solid #f2f2f2;border-radius:1px;clear:both;margin:1.5em 1%;padding:1% 2%}.jetpack-recipe-title{border-bottom:1px solid #ccc;margin:.25em 0;padding:.25em 0}.jetpack-recipe .jetpack-recipe-meta{display:block;font-size:.9em;list-style-type:none;margin-right:0;margin-left:0;padding:0;overflow:hidden;width:100%}.jetpack-recipe .jetpack-recipe-meta li{float:left;list-style-type:none;margin:0;padding:0 5% 0 0}.jetpack-recipe-meta li.jetpack-recipe-print{float:right;padding-right:0;text-align:right}.jetpack-recipe-notes{font-style:italic} \ No newline at end of file
+.jetpack-recipe{border:1px solid #f2f2f2;border-radius:1px;clear:both;margin:1.5em 1%;padding:1% 2%}.jetpack-recipe-title{border-bottom:1px solid #ccc;margin:.25em 0;padding:.25em 0}.jetpack-recipe .jetpack-recipe-meta{display:block;font-size:.9em;list-style-type:none;margin-left:0;margin-right:0;overflow:hidden;padding:0;width:100%}.jetpack-recipe .jetpack-recipe-meta li{float:left;list-style-type:none;margin:0;padding:0 5% 0 0}.jetpack-recipe-meta li.jetpack-recipe-print{float:right;padding-right:0;text-align:right}.jetpack-recipe-notes{font-style:italic} \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.css b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.css
index 24bed853..2a6da72a 100644
--- a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.css
+++ b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.css
@@ -1,145 +1,157 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-.slideshow-window {
- background-color: #222;
- border: 20px solid #222;
- border-radius: 10px;
- height: 0;
- margin-bottom: 20px;
- overflow: hidden;
- padding-top: 30px !important;
- padding-bottom: 56.25% !important;
- position: relative;
- z-index: 1;
-}
-
-.slideshow-window.slideshow-white {
- background-color: #fff;
- border-color: #fff;
-}
-
-.slideshow-window, .slideshow-window * {
- box-sizing: content-box;
-}
-
-.slideshow-loading {
- height: 100%;
- text-align: center;
- margin: auto;
-}
-
-body div.slideshow-window * img {
- /* Override any styles that might be present in the page stylesheet */
- background-color: transparent !important;
- background-image: none !important;
- border-width: 0 !important;
- display: block;
- margin: 0 auto;
- max-width: 100%;
- max-height: 100%;
- padding: 0 !important;
- position: relative;
- transform: translateY(-50%);
- top: 50%;
-}
-
-.slideshow-loading img {
- vertical-align: middle;
-}
-
-.slideshow-slide {
- display: none;
- height: 100% !important;
- right: 0;
- margin: auto;
- position: absolute;
- text-align: center;
- top: 0;
- width: 100% !important;
-}
-
-.slideshow-slide img {
- vertical-align: middle;
-}
-
-.slideshow-line-height-hack {
- overflow: hidden;
- width: 0px;
- font-size: 0px;
-}
-
-.slideshow-slide-caption {
- font-size: 13px;
- font-family: "Helvetica Neue", sans-serif;
- color: #f6f7f7;
- text-shadow: #222 -1px 1px 2px;
- line-height: 25px;
- height: 25px;
- position: absolute;
- bottom: 5px;
- right: 0;
- z-index: 100;
- width: 100%;
- text-align: center;
-}
-
-.slideshow-controls {
- z-index: 1000;
- position: absolute;
- bottom: 30px;
- margin: auto;
- text-align: center;
- width: 100%;
- -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
- opacity: 0.5;
- direction:ltr;
- transition: 300ms opacity ease-out;
-}
-
-.slideshow-window:hover .slideshow-controls {
- -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
- opacity: 1;
-}
-
-body div div.slideshow-controls a,
-body div div.slideshow-controls a:hover {
- border:2px solid rgba(255,255,255,0.1) !important;
- background-color: #000 !important;
- background-color: rgba(0,0,0,0.6) !important;
- background-image: url('../img/slideshow-controls.png') !important;
- background-repeat: no-repeat;
- background-size: 142px 16px !important;
- background-position: -34px 8px !important;
- color: #222 !important;
- margin: 0 5px !important;
- padding: 0 !important;
- display: inline-block !important;
- *display: inline;
- zoom: 1;
- height: 32px !important;
- width: 32px !important;
- line-height: 32px !important;
- text-align: center !important;
- border-radius: 10em !important;
- transition: 300ms border-color ease-out;
+.jetpack-slideshow-window {
+ background-color: #222;
+ border: 20px solid #222;
+ border-radius: 10px;
+ height: 0;
+ margin-bottom: 20px;
+ overflow: hidden;
+ padding-top: 30px !important;
+ padding-bottom: 56.25% !important;
+ position: relative;
+ z-index: 1;
+}
+
+.jetpack-slideshow-window.jetpack-slideshow-white {
+ background-color: #fff;
+ border-color: #fff;
+}
+
+.jetpack-slideshow-window, .jetpack-slideshow-window * {
+ box-sizing: content-box;
+}
+
+.jetpack-slideshow-loading {
+ height: 100%;
+ text-align: center;
+ margin: auto;
+}
+
+body div.jetpack-slideshow-window * img {
+ /* Override any styles that might be present in the page stylesheet */
+ background-color: transparent !important;
+ background-image: none !important;
+ border-width: 0 !important;
+ display: block;
+ margin: 0 auto;
+ max-width: 100%;
+ max-height: 100%;
+ padding: 0 !important;
+ position: relative;
+ transform: translateY(-50%);
+ top: 50%;
+}
+
+.jetpack-slideshow-loading img {
+ vertical-align: middle;
+}
+
+.jetpack-slideshow-slide {
+ display: none;
+ height: 100% !important;
+ right: 0;
+ margin: auto;
+ position: absolute;
+ text-align: center;
+ top: 0;
+ width: 100% !important;
+}
+
+.jetpack-slideshow-slide img {
+ vertical-align: middle;
+}
+
+.jetpack-slideshow-line-height-hack {
+ overflow: hidden;
+ width: 0px;
+ font-size: 0px;
+}
+
+.jetpack-slideshow-slide-caption {
+ font-size: 13px;
+ font-family: "Helvetica Neue", sans-serif;
+ color: #f6f7f7;
+ text-shadow: #222 -1px 1px 2px;
+ line-height: 25px;
+ height: 25px;
+ position: absolute;
+ bottom: 5px;
+ right: 0;
+ z-index: 100;
+ width: 100%;
+ text-align: center;
+}
+
+.jetpack-slideshow-controls {
+ z-index: 1000;
+ position: absolute;
+ bottom: 30px;
+ margin: auto;
+ text-align: center;
+ width: 100%;
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
+ opacity: 0.5;
+ direction: ltr;
+ transition: 300ms opacity ease-out;
+}
+
+.jetpack-slideshow-window:hover .jetpack-slideshow-controls {
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
+ opacity: 1;
+}
+
+body div div.jetpack-slideshow-controls a,
+body div div.jetpack-slideshow-controls a:hover {
+ border: 2px solid rgba(255, 255, 255, 0.1) !important;
+ background-color: #000 !important;
+ background-color: rgba(0, 0, 0, 0.6) !important;
+ background-image: url(../../../modules/shortcodes/img/slideshow-controls.png) !important;
+ background-repeat: no-repeat;
+ background-size: 142px 16px !important;
+ background-position: -34px 8px !important;
+ color: #222 !important;
+ margin: 0 5px !important;
+ padding: 0 !important;
+ display: inline-block !important;
+ *display: inline;
+ zoom: 1;
+ height: 32px !important;
+ width: 32px !important;
+ line-height: 32px !important;
+ text-align: center !important;
+ border-radius: 10em !important;
+ transition: 300ms border-color ease-out;
}
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
- body div div.slideshow-controls a,
- body div div.slideshow-controls a:hover {
- background-image: url('../img/slideshow-controls-2x.png') !important;
- }
+ body div div.jetpack-slideshow-controls a,
+body div div.jetpack-slideshow-controls a:hover {
+ background-image: url(../../../modules/shortcodes/img/slideshow-controls-2x.png) !important;
+ }
+}
+body div div.jetpack-slideshow-controls a:hover {
+ border-color: white !important;
+}
+
+body div div.jetpack-slideshow-controls a:first-child {
+ background-position: -76px 8px !important;
+}
+
+body div div.jetpack-slideshow-controls a:last-child {
+ background-position: -117px 8px !important;
+}
+
+body div div.jetpack-slideshow-controls a:nth-child(2) {
+ background-position: -34px 8px !important;
}
-body div div.slideshow-controls a:hover {
- border-color: rgba(255,255,255,1) !important;
+body div div.jetpack-slideshow-controls a.running {
+ background-position: -34px 8px !important;
}
-body div div.slideshow-controls a:first-child { background-position: -76px 8px !important;}
-body div div.slideshow-controls a:last-child { background-position: -117px 8px !important;}
-body div div.slideshow-controls a:nth-child(2) { background-position: -34px 8px !important;}
-body div div.slideshow-controls a.running { background-position: -34px 8px !important;}
-body div div.slideshow-controls a.paused { background-position: 9px 8px !important;}
+body div div.jetpack-slideshow-controls a.paused {
+ background-position: 9px 8px !important;
+}
-.slideshow-controls a img {
- border: 50px dotted fuchsia;
+.jetpack-slideshow-controls a img {
+ border: 50px dotted fuchsia;
}
diff --git a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css
index bd65a5ca..302ee2e5 100644
--- a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css
+++ b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css
@@ -1 +1 @@
-.slideshow-window{background-color:#222;border:20px solid #222;border-radius:10px;height:0;margin-bottom:20px;overflow:hidden;padding-top:30px!important;padding-bottom:56.25%!important;position:relative;z-index:1}.slideshow-window.slideshow-white{background-color:#fff;border-color:#fff}.slideshow-window,.slideshow-window *{box-sizing:content-box}.slideshow-loading{height:100%;text-align:center;margin:auto}body div.slideshow-window * img{background-color:transparent!important;background-image:none!important;border-width:0!important;display:block;margin:0 auto;max-width:100%;max-height:100%;padding:0!important;position:relative;transform:translateY(-50%);top:50%}.slideshow-loading img{vertical-align:middle}.slideshow-slide{display:none;height:100%!important;right:0;margin:auto;position:absolute;text-align:center;top:0;width:100%!important}.slideshow-slide img{vertical-align:middle}.slideshow-line-height-hack{overflow:hidden;width:0;font-size:0}.slideshow-slide-caption{font-size:13px;font-family:"Helvetica Neue",sans-serif;color:#f6f7f7;text-shadow:#222 -1px 1px 2px;line-height:25px;height:25px;position:absolute;bottom:5px;right:0;z-index:100;width:100%;text-align:center}.slideshow-controls{z-index:1000;position:absolute;bottom:30px;margin:auto;text-align:center;width:100%;opacity:.5;direction:ltr;transition:.3s opacity ease-out}.slideshow-window:hover .slideshow-controls{opacity:1}body div div.slideshow-controls a,body div div.slideshow-controls a:hover{border:2px solid rgba(255,255,255,.1)!important;background-color:#000!important;background-color:rgba(0,0,0,.6)!important;background-image:url(../img/slideshow-controls.png)!important;background-repeat:no-repeat;background-size:142px 16px!important;background-position:-34px 8px!important;color:#222!important;margin:0 5px!important;padding:0!important;display:inline-block!important;zoom:1;height:32px!important;width:32px!important;line-height:32px!important;text-align:center!important;border-radius:10em!important;transition:.3s border-color ease-out}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body div div.slideshow-controls a,body div div.slideshow-controls a:hover{background-image:url(../img/slideshow-controls-2x.png)!important}}body div div.slideshow-controls a:hover{border-color:#fff!important}body div div.slideshow-controls a:first-child{background-position:-76px 8px!important}body div div.slideshow-controls a:last-child{background-position:-117px 8px!important}body div div.slideshow-controls a:nth-child(2){background-position:-34px 8px!important}body div div.slideshow-controls a.running{background-position:-34px 8px!important}body div div.slideshow-controls a.paused{background-position:9px 8px!important}.slideshow-controls a img{border:50px dotted #f0f} \ No newline at end of file
+.jetpack-slideshow-window{background-color:#222;border:20px solid #222;border-radius:10px;height:0;margin-bottom:20px;overflow:hidden;padding-bottom:56.25%!important;padding-top:30px!important;position:relative;z-index:1}.jetpack-slideshow-window.jetpack-slideshow-white{background-color:#fff;border-color:#fff}.jetpack-slideshow-window,.jetpack-slideshow-window *{box-sizing:content-box}.jetpack-slideshow-loading{height:100%;margin:auto;text-align:center}body div.jetpack-slideshow-window * img{background-color:transparent!important;background-image:none!important;border-width:0!important;display:block;margin:0 auto;max-height:100%;max-width:100%;padding:0!important;position:relative;top:50%;transform:translateY(-50%)}.jetpack-slideshow-loading img{vertical-align:middle}.jetpack-slideshow-slide{display:none;height:100%!important;margin:auto;position:absolute;right:0;text-align:center;top:0;width:100%!important}.jetpack-slideshow-slide img{vertical-align:middle}.jetpack-slideshow-line-height-hack{font-size:0;overflow:hidden;width:0}.jetpack-slideshow-slide-caption{bottom:5px;color:#f6f7f7;font-family:Helvetica Neue,sans-serif;font-size:13px;height:25px;line-height:25px;position:absolute;right:0;text-align:center;text-shadow:#222 -1px 1px 2px;width:100%;z-index:100}.jetpack-slideshow-controls{bottom:30px;direction:ltr;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";margin:auto;opacity:.5;position:absolute;text-align:center;transition:opacity .3s ease-out;width:100%;z-index:1000}.jetpack-slideshow-window:hover .jetpack-slideshow-controls{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";opacity:1}body div div.jetpack-slideshow-controls a,body div div.jetpack-slideshow-controls a:hover{zoom:1;background-color:#000!important;background-color:rgba(0,0,0,.6)!important;background-image:url(../../../modules/shortcodes/img/slideshow-controls.png)!important;background-position:-34px 8px!important;background-repeat:no-repeat;background-size:142px 16px!important;border:2px solid hsla(0,0%,100%,.1)!important;border-radius:10em!important;color:#222!important;display:inline-block!important;*display:inline;height:32px!important;line-height:32px!important;margin:0 5px!important;padding:0!important;text-align:center!important;transition:border-color .3s ease-out;width:32px!important}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body div div.jetpack-slideshow-controls a,body div div.jetpack-slideshow-controls a:hover{background-image:url(../../../modules/shortcodes/img/slideshow-controls-2x.png)!important}}body div div.jetpack-slideshow-controls a:hover{border-color:#fff!important}body div div.jetpack-slideshow-controls a:first-child{background-position:-76px 8px!important}body div div.jetpack-slideshow-controls a:last-child{background-position:-117px 8px!important}body div div.jetpack-slideshow-controls a.running,body div div.jetpack-slideshow-controls a:nth-child(2){background-position:-34px 8px!important}body div div.jetpack-slideshow-controls a.paused{background-position:9px 8px!important}.jetpack-slideshow-controls a img{border:50px dotted #f0f} \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.css b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.css
index 6a02b8f7..753f5874 100644
--- a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.css
+++ b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.css
@@ -1,4 +1,4 @@
-.slideshow-window {
+.jetpack-slideshow-window {
background-color: #222;
border: 20px solid #222;
border-radius: 10px;
@@ -11,24 +11,24 @@
z-index: 1;
}
-.slideshow-window.slideshow-white {
+.jetpack-slideshow-window.jetpack-slideshow-white {
background-color: #fff;
border-color: #fff;
}
-.slideshow-window, .slideshow-window * {
+.jetpack-slideshow-window, .jetpack-slideshow-window * {
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
-.slideshow-loading {
+.jetpack-slideshow-loading {
height: 100%;
text-align: center;
margin: auto;
}
-body div.slideshow-window * img {
+body div.jetpack-slideshow-window * img {
/* Override any styles that might be present in the page stylesheet */
background-color: transparent !important;
background-image: none !important;
@@ -45,11 +45,11 @@ body div.slideshow-window * img {
top: 50%;
}
-.slideshow-loading img {
+.jetpack-slideshow-loading img {
vertical-align: middle;
}
-.slideshow-slide {
+.jetpack-slideshow-slide {
display: none;
height: 100% !important;
left: 0;
@@ -60,17 +60,17 @@ body div.slideshow-window * img {
width: 100% !important;
}
-.slideshow-slide img {
+.jetpack-slideshow-slide img {
vertical-align: middle;
}
-.slideshow-line-height-hack {
+.jetpack-slideshow-line-height-hack {
overflow: hidden;
width: 0px;
font-size: 0px;
}
-.slideshow-slide-caption {
+.jetpack-slideshow-slide-caption {
font-size: 13px;
font-family: "Helvetica Neue", sans-serif;
color: #f6f7f7;
@@ -85,7 +85,7 @@ body div.slideshow-window * img {
text-align: center;
}
-.slideshow-controls {
+.jetpack-slideshow-controls {
z-index: 1000;
position: absolute;
bottom: 30px;
@@ -101,13 +101,13 @@ body div.slideshow-window * img {
transition: 300ms opacity ease-out;
}
-.slideshow-window:hover .slideshow-controls {
+.jetpack-slideshow-window:hover .jetpack-slideshow-controls {
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
opacity: 1;
}
-body div div.slideshow-controls a,
-body div div.slideshow-controls a:hover {
+body div div.jetpack-slideshow-controls a,
+body div div.jetpack-slideshow-controls a:hover {
border:2px solid rgba(255,255,255,0.1) !important;
background-color: #000 !important;
background-color: rgba(0,0,0,0.6) !important;
@@ -136,22 +136,22 @@ body div div.slideshow-controls a:hover {
}
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
- body div div.slideshow-controls a,
- body div div.slideshow-controls a:hover {
+ body div div.jetpack-slideshow-controls a,
+ body div div.jetpack-slideshow-controls a:hover {
background-image: url('../img/slideshow-controls-2x.png') !important;
}
}
-body div div.slideshow-controls a:hover {
+body div div.jetpack-slideshow-controls a:hover {
border-color: rgba(255,255,255,1) !important;
}
-body div div.slideshow-controls a:first-child { background-position: -76px 8px !important;}
-body div div.slideshow-controls a:last-child { background-position: -117px 8px !important;}
-body div div.slideshow-controls a:nth-child(2) { background-position: -34px 8px !important;}
-body div div.slideshow-controls a.running { background-position: -34px 8px !important;}
-body div div.slideshow-controls a.paused { background-position: 9px 8px !important;}
+body div div.jetpack-slideshow-controls a:first-child { background-position: -76px 8px !important;}
+body div div.jetpack-slideshow-controls a:last-child { background-position: -117px 8px !important;}
+body div div.jetpack-slideshow-controls a:nth-child(2) { background-position: -34px 8px !important;}
+body div div.jetpack-slideshow-controls a.running { background-position: -34px 8px !important;}
+body div div.jetpack-slideshow-controls a.paused { background-position: 9px 8px !important;}
-.slideshow-controls a img {
+.jetpack-slideshow-controls a img {
border: 50px dotted fuchsia;
}
diff --git a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css
index e6f06fa0..6d0b3ecf 100644
--- a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css
+++ b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-.slideshow-window{background-color:#222;border:20px solid #222;border-radius:10px;height:0;margin-bottom:20px;overflow:hidden;padding-top:30px!important;padding-bottom:56.25%!important;position:relative;z-index:1}.slideshow-window.slideshow-white{background-color:#fff;border-color:#fff}.slideshow-window,.slideshow-window *{box-sizing:content-box}.slideshow-loading{height:100%;text-align:center;margin:auto}body div.slideshow-window * img{background-color:transparent!important;background-image:none!important;border-width:0!important;display:block;margin:0 auto;max-width:100%;max-height:100%;padding:0!important;position:relative;transform:translateY(-50%);top:50%}.slideshow-loading img{vertical-align:middle}.slideshow-slide{display:none;height:100%!important;left:0;margin:auto;position:absolute;text-align:center;top:0;width:100%!important}.slideshow-slide img{vertical-align:middle}.slideshow-line-height-hack{overflow:hidden;width:0;font-size:0}.slideshow-slide-caption{font-size:13px;font-family:"Helvetica Neue",sans-serif;color:#f6f7f7;text-shadow:#222 1px 1px 2px;line-height:25px;height:25px;position:absolute;bottom:5px;left:0;z-index:100;width:100%;text-align:center}.slideshow-controls{z-index:1000;position:absolute;bottom:30px;margin:auto;text-align:center;width:100%;opacity:.5;direction:ltr;transition:.3s opacity ease-out}.slideshow-window:hover .slideshow-controls{opacity:1}body div div.slideshow-controls a,body div div.slideshow-controls a:hover{border:2px solid rgba(255,255,255,.1)!important;background-color:#000!important;background-color:rgba(0,0,0,.6)!important;background-image:url(../img/slideshow-controls.png)!important;background-repeat:no-repeat;background-size:142px 16px!important;background-position:-34px 8px!important;color:#222!important;margin:0 5px!important;padding:0!important;display:inline-block!important;zoom:1;height:32px!important;width:32px!important;line-height:32px!important;text-align:center!important;border-radius:10em!important;transition:.3s border-color ease-out}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body div div.slideshow-controls a,body div div.slideshow-controls a:hover{background-image:url(../img/slideshow-controls-2x.png)!important}}body div div.slideshow-controls a:hover{border-color:#fff!important}body div div.slideshow-controls a:first-child{background-position:-76px 8px!important}body div div.slideshow-controls a:last-child{background-position:-117px 8px!important}body div div.slideshow-controls a:nth-child(2){background-position:-34px 8px!important}body div div.slideshow-controls a.running{background-position:-34px 8px!important}body div div.slideshow-controls a.paused{background-position:9px 8px!important}.slideshow-controls a img{border:50px dotted #f0f} \ No newline at end of file
+.jetpack-slideshow-window{background-color:#222;border:20px solid #222;border-radius:10px;height:0;margin-bottom:20px;overflow:hidden;padding-bottom:56.25%!important;padding-top:30px!important;position:relative;z-index:1}.jetpack-slideshow-window.jetpack-slideshow-white{background-color:#fff;border-color:#fff}.jetpack-slideshow-window,.jetpack-slideshow-window *{box-sizing:content-box}.jetpack-slideshow-loading{height:100%;margin:auto;text-align:center}body div.jetpack-slideshow-window * img{background-color:transparent!important;background-image:none!important;border-width:0!important;display:block;margin:0 auto;max-height:100%;max-width:100%;padding:0!important;position:relative;top:50%;transform:translateY(-50%)}.jetpack-slideshow-loading img{vertical-align:middle}.jetpack-slideshow-slide{display:none;height:100%!important;left:0;margin:auto;position:absolute;text-align:center;top:0;width:100%!important}.jetpack-slideshow-slide img{vertical-align:middle}.jetpack-slideshow-line-height-hack{font-size:0;overflow:hidden;width:0}.jetpack-slideshow-slide-caption{bottom:5px;color:#f6f7f7;font-family:Helvetica Neue,sans-serif;font-size:13px;height:25px;left:0;line-height:25px;position:absolute;text-align:center;text-shadow:#222 1px 1px 2px;width:100%;z-index:100}.jetpack-slideshow-controls{bottom:30px;direction:ltr;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";margin:auto;opacity:.5;position:absolute;text-align:center;transition:opacity .3s ease-out;width:100%;z-index:1000}.jetpack-slideshow-window:hover .jetpack-slideshow-controls{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";opacity:1}body div div.jetpack-slideshow-controls a,body div div.jetpack-slideshow-controls a:hover{zoom:1;background-color:#000!important;background-color:rgba(0,0,0,.6)!important;background-image:url(../../../modules/shortcodes/img/slideshow-controls.png)!important;background-position:-34px 8px!important;background-repeat:no-repeat;background-size:142px 16px!important;border:2px solid hsla(0,0%,100%,.1)!important;border-radius:10em!important;color:#222!important;display:inline-block!important;*display:inline;height:32px!important;line-height:32px!important;margin:0 5px!important;padding:0!important;text-align:center!important;transition:border-color .3s ease-out;width:32px!important}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body div div.jetpack-slideshow-controls a,body div div.jetpack-slideshow-controls a:hover{background-image:url(../../../modules/shortcodes/img/slideshow-controls-2x.png)!important}}body div div.jetpack-slideshow-controls a:hover{border-color:#fff!important}body div div.jetpack-slideshow-controls a:first-child{background-position:-76px 8px!important}body div div.jetpack-slideshow-controls a:last-child{background-position:-117px 8px!important}body div div.jetpack-slideshow-controls a.running,body div div.jetpack-slideshow-controls a:nth-child(2){background-position:-34px 8px!important}body div div.jetpack-slideshow-controls a.paused{background-position:9px 8px!important}.jetpack-slideshow-controls a img{border:50px dotted #f0f} \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/descript.php b/plugins/jetpack/modules/shortcodes/descript.php
new file mode 100644
index 00000000..302c0681
--- /dev/null
+++ b/plugins/jetpack/modules/shortcodes/descript.php
@@ -0,0 +1,116 @@
+<?php
+/**
+ * Descript.com embed
+ *
+ * Example URL: https://share.descript.com/view/jUxUmel6GyN
+ * Example embed code: <iframe src="https://share.descript.com/embed/jUxUmel6GyN" width="640" height="360" frameborder="0" allowfullscreen></iframe>
+ *
+ * @package automattic/jetpack
+ */
+
+if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
+ add_action( 'init', 'jetpack_descript_enable_embeds' );
+} else {
+ jetpack_descript_enable_embeds();
+}
+
+/**
+ * Register descript as oembed provider. Add filter to reverse iframes to shortcode. Register [descript] shortcode.
+ *
+ * @since 10.4
+ */
+function jetpack_descript_enable_embeds() {
+ // Support their oEmbed Endpoint.
+ wp_oembed_add_provider( '#https?://share.descript.com/(?:view|embed)/\w+#i', 'https://api.descript.com/v2/oembed', true );
+
+ // Allow script to be filtered to short code (so direct copy+paste can be done).
+ add_filter( 'pre_kses', 'jetpack_shortcodereverse_descript' );
+
+ // Actually display the descript Embed.
+ add_shortcode( 'descript', 'jetpack_descript_shortcode' );
+}
+
+/**
+ * Compose shortcode based on Descript iframes.
+ *
+ * @since 10.4
+ *
+ * @param string $content Post content.
+ *
+ * @return mixed
+ */
+function jetpack_shortcodereverse_descript( $content ) {
+ if ( ! is_string( $content ) || false === stripos( $content, 'share.descript.com' ) ) {
+ return $content;
+ }
+
+ $regexp = '/<iframe (?:loading="lazy" )?src="https:\/\/share.descript.com\/embed\/(\w+)" width="(\d+)" height="(\d+)" frameborder="0" allowfullscreen(?:="")?><\/iframe>/i';
+
+ if ( preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) {
+ foreach ( $matches as $match ) {
+ // We need at least a id.
+ if ( isset( $match[1] ) ) {
+ $shortcode = sprintf(
+ '[descript id="%1$s" width="%2$s" height="%3$s"]',
+ esc_attr( $match[1] ),
+ esc_attr( $match[2] ),
+ esc_attr( $match[3] )
+ );
+ $content = str_replace( $match[0], $shortcode, $content );
+ }
+ }
+ }
+
+ /** This action is documented in modules/widgets/social-media-icons.php */
+ do_action( 'jetpack_bump_stats_extras', 'html_to_shortcode', 'descript' );
+
+ return $content;
+}
+
+/**
+ * Parse shortcode arguments and render its output.
+ *
+ * @since 10.4
+ *
+ * @param array $atts Shortcode parameters.
+ *
+ * @return string
+ */
+function jetpack_descript_shortcode( $atts ) {
+ if ( ! empty( $atts['id'] ) ) {
+ $id = $atts['id'];
+ } else {
+ return '<!-- Missing descript id -->';
+ }
+
+ if ( ! empty( $atts['width'] ) ) {
+ $width = $atts['width'];
+ } else {
+ $width = '640';
+ }
+
+ if ( ! empty( $atts['height'] ) ) {
+ $height = $atts['height'];
+ } else {
+ $height = '480';
+ }
+
+ $params = array(
+ 'id' => esc_attr( $id ),
+ 'width' => (int) $width,
+ 'height' => (int) $height,
+ );
+
+ $embed_url = sprintf(
+ 'https://share.descript.com/view/%1$s',
+ esc_attr( $id )
+ );
+
+ $embed_code = wp_oembed_get( $embed_url, array_filter( $params ) );
+
+ // wrap the embed with wp-block-embed__wrapper, otherwise it would be aligned to the very left of the viewport.
+ return sprintf(
+ '<div class="wp-block-embed__wrapper">%1$s</div>',
+ $embed_code
+ );
+}
diff --git a/plugins/jetpack/modules/shortcodes/hulu.php b/plugins/jetpack/modules/shortcodes/hulu.php
deleted file mode 100644
index 38203d4c..00000000
--- a/plugins/jetpack/modules/shortcodes/hulu.php
+++ /dev/null
@@ -1,275 +0,0 @@
-<?php
-/**
- * Hulu Shortcode
- *
- * [hulu 369061]
- * [hulu id=369061]
- * [hulu id=369061 width=512 height=288 start_time="10" end_time="20" thumbnail_frame="10"]
- * [hulu http://www.hulu.com/watch/369061]
- * [hulu id=gQ6Z0I990IWv_VFQI2J7Eg width=512 height=288]
- *
- * <object width="512" height="288">
- * <param name="movie" value="http://www.hulu.com/embed/gQ6Z0I990IWv_VFQI2J7Eg"></param>
- * <param name="allowFullScreen" value="true"></param>
- * <embed src="http://www.hulu.com/embed/gQ6Z0I990IWv_VFQI2J7Eg" type="application/x-shockwave-flash" width="512" height="288" allowFullScreen="true"></embed>
- * </object>
- *
- * @package Jetpack
- */
-
-if ( get_option( 'embed_autourls' ) ) {
-
- // Convert hulu URLS to shortcodes for old comments, saved before comments for shortcodes were enabled.
- add_filter( 'comment_text', 'jetpack_hulu_link', 1 );
-}
-
-add_shortcode( 'hulu', 'jetpack_hulu_shortcode' );
-
-/**
- * Return a Hulu video ID from a given set to attributes.
- *
- * @since 4.5.0
- *
- * @param array $atts Shortcode parameters.
- *
- * @return string $id Hulu video ID.
- */
-function jetpack_shortcode_get_hulu_id( $atts ) {
- // This will catch an id explicitly defined as such, or assume any param without a label is the id. First found is used.
- if ( isset( $atts['id'] ) ) {
- // First we check to see if [hulu id=369061] or [hulu id=gQ6Z0I990IWv_VFQI2J7Eg] was used.
- $id = esc_attr( $atts['id'] );
- } elseif ( isset( $atts[0] ) && preg_match( '|www\.hulu\.com/watch/(\d+)|i', $atts[0], $match ) ) {
- // this checks for [hulu http://www.hulu.com/watch/369061].
- $id = (int) $match[1];
- } elseif ( isset( $atts[0] ) ) {
- // This checks for [hulu 369061] or [hulu 65yppv6xqa45s5n7_m1wng].
- $id = esc_attr( $atts[0] );
- } else {
- $id = 0;
- }
-
- return $id;
-}
-
-/**
- * Convert a Hulu shortcode into an embed code.
- *
- * @since 4.5.0
- *
- * @param array $atts An array of shortcode attributes.
- *
- * @return string The embed code for the Hulu video.
- */
-function jetpack_hulu_shortcode( $atts ) {
- global $content_width;
-
- // Set a default content width, if it's not specified.
- $attr = shortcode_atts(
- array(
- 'id' => '',
- 'width' => $content_width ? $content_width : 640,
- 'start_time' => '',
- 'end_time' => '',
- 'thumbnail_frame' => '',
- ),
- $atts
- );
-
- $id = jetpack_shortcode_get_hulu_id( $atts );
- if ( ! $id ) {
- return '<!-- Hulu Error: Hulu shortcode syntax invalid. -->';
- }
-
- $start_time = 0;
- if ( is_numeric( $attr['start_time'] ) ) {
- $start_time = intval( $attr['start_time'] );
- }
- if ( is_numeric( $attr['end_time'] ) && intval( $attr['end_time'] ) > $start_time ) {
- $end_time = intval( $attr['end_time'] );
- }
- if ( is_numeric( $attr['thumbnail_frame'] ) ) {
- $thumbnail_frame = intval( $attr['thumbnail_frame'] );
- }
-
- // check to see if $id is 76560 else we assume it's gQ6Z0I990IWv_VFQI2J7Eg
- // If id is numeric, we'll send it off to the hulu oembed api to get the embed URL (and non-numeric id).
- if ( is_numeric( $id ) ) {
- $transient_key = "hulu-$id";
- $transient_value = get_transient( $transient_key );
-
- if ( false === $transient_value ) {
- // let's make a cross-site http request out to the hulu oembed api.
- $oembed_url = sprintf(
- 'https://www.hulu.com/api/oembed.json?url=%s',
- rawurlencode( 'https://www.hulu.com/watch/' . esc_attr( $id ) )
- );
- $response = wp_remote_get( $oembed_url );
- $response_code = wp_remote_retrieve_response_code( $response );
- $response_message = wp_remote_retrieve_response_message( $response );
- if ( 200 !== $response_code && ! empty( $response_message ) ) {
- return "<!-- Hulu Error: Hulu shortcode http error $response_message -->";
- } elseif ( 200 !== $response_code ) {
- return "<!-- Hulu Error: Hulu shortcode unknown error occurred, $response_code -->";
- } else {
- $response_body = wp_remote_retrieve_body( $response );
- $json = json_decode( $response_body );
-
- // Pull out id from embed url (from oembed API).
- $embed_url_params = array();
- parse_str( wp_parse_url( $json->embed_url, PHP_URL_QUERY ), $embed_url_params );
-
- if ( isset( $embed_url_params['eid'] ) ) {
- $id = $embed_url_params['eid'];
- }
- // let's cache this response indefinitely.
- set_transient( $transient_key, $id );
- }
- } else {
- $id = $transient_value;
- }
- }
-
- if ( ! $id ) {
- return '<!-- Hulu Error: Not a Hulu video. -->';
- }
-
- $query_args = array();
- $query_args['eid'] = esc_attr( $id );
- if ( isset( $start_time ) ) {
- $query_args['st'] = intval( $start_time );
- }
- if ( isset( $end_time ) ) {
- $query_args['et'] = intval( $end_time );
- }
- if ( isset( $thumbnail_frame ) ) {
- $query_args['it'] = 'i' . intval( $thumbnail_frame );
- }
-
- $iframe_url = add_query_arg( $query_args, 'https://www.hulu.com/embed.html' );
- $width = intval( $attr['width'] );
- $height = round( ( $width / 640 ) * 360 );
-
- $html = sprintf(
- '<div class="embed-hulu" style="text-align: center;"><iframe src="%s" width="%s" height="%s" style="border:0;" scrolling="no" webkitAllowFullScreen
-mozallowfullscreen allowfullscreen></iframe></div>',
- esc_url( $iframe_url ),
- esc_attr( $width ),
- esc_attr( $height )
- );
- $html = apply_filters( 'video_embed_html', $html );
-
- return $html;
-}
-
-/**
- * Callback to convert Hulu links in comments into a embed src.
- *
- * @since 4.5.0
- *
- * @param array $matches Array of matches from regex.
- *
- * @return string
- */
-function jetpack_hulu_link_callback( $matches ) {
- $video_id = $matches[4];
-
- // Make up an embed src to pass to the shortcode reversal function.
- $attrs = array(
- 'src' => 'https://www.hulu.com/embed.html?eid=' . esc_attr( $video_id ),
- );
-
- return wpcom_shortcodereverse_huluhelper( $attrs );
-}
-
-/**
- * Convert Hulu links in comments into a Hulu shortcode.
- *
- * @since 4.5.0
- *
- * @param string $content Post content.
- *
- * @return string
- */
-function jetpack_hulu_link( $content ) {
- $content = preg_replace_callback( '!^(http(s)?://)?(www\.)?hulu\.com\/watch\/([0-9]+)$!im', 'jetpack_hulu_link_callback', $content );
-
- return $content;
-}
-
-/**
- * Makes a Hulu shortcode from $attrs and $pattern
- *
- * @since 4.5.0
- *
- * @param array $attrs Shortcode attributes.
- *
- * @return string
- */
-function wpcom_shortcodereverse_huluhelper( $attrs ) {
- $attrs = wpcom_shortcodereverse_parseattr( $attrs );
-
- $src_attributes = array();
- parse_str( wp_parse_url( $attrs['src'], PHP_URL_QUERY ), $src_attributes );
-
- $attrs = array_merge( $attrs, $src_attributes );
-
- // If we don't have an eid, we can't do anything. Just send back the src string.
- if ( ! isset( $attrs['eid'] ) ) {
- return $attrs['src'];
- }
-
- $shortcode = '[hulu id=' . esc_attr( $attrs['eid'] );
-
- if ( $attrs['width'] ) {
- $shortcode .= ' width=' . intval( $attrs['width'] );
- }
-
- if ( $attrs['height'] ) {
- $shortcode .= ' height=' . intval( $attrs['height'] );
- }
-
- if ( $attrs['st'] ) {
- $shortcode .= ' start_time=' . intval( $attrs['st'] );
- }
-
- if ( $attrs['et'] ) {
- $shortcode .= ' end_time=' . intval( $attrs['et'] );
- }
-
- if ( $attrs['it'] ) {
- // the thumbnail frame attribute comes with an i in front of the value, so we've got to remove that.
- $shortcode .= ' thumbnail_frame=' . intval( ltrim( $attrs['it'], 'i' ) );
- }
- $shortcode .= ']';
-
- return $shortcode;
-}
-
-/**
- * Initiates process to convert iframe HTML into a Hulu shortcode.
- *
- * Example:
- * <iframe width="512" height="288" src="http://www.hulu.com/embed.html?eid=nlg_ios3tutcfrhatkiaow&et=20&st=10&it=i11" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe>
- *
- * Converts to:
- * [hulu id=nlg_ios3tutcfrhatkiaow width=512 height=288 start_time=10 end_time=20 thumbnail_frame=11]
- *
- * @since 4.5.0
- *
- * @param array $attrs Shortcode attributes.
- *
- * @return string
- */
-function wpcom_shortcodereverse_huluembed( $attrs ) {
-
- $shortcode = wpcom_shortcodereverse_huluhelper( $attrs );
-
- if ( '[' === substr( $shortcode, 0, 1 ) ) {
- /** This action is documented in modules/widgets/social-media-icons.php */
- do_action( 'jetpack_bump_stats_extras', 'html_to_shortcode', 'hulu-embed' );
- }
-
- return $shortcode;
-}
-Filter_Embedded_HTML_Objects::register( '#^https?://www.hulu.com/embed.html#i', 'wpcom_shortcodereverse_huluembed', true );
diff --git a/plugins/jetpack/modules/shortcodes/js/gist.js b/plugins/jetpack/modules/shortcodes/js/gist.js
deleted file mode 100644
index d2d704dc..00000000
--- a/plugins/jetpack/modules/shortcodes/js/gist.js
+++ /dev/null
@@ -1,32 +0,0 @@
-( function( $, undefined ) {
- var gistStylesheetLoaded = false,
- gistEmbed = function() {
- $( '.gist-oembed' ).each( function( i, el ) {
- var url = 'https://gist.github.com/' + $( el ).data( 'gist' ),
- ts = Number.parseInt( $( el ).data( 'ts' ), 10 );
-
- $.ajax( {
- url: url,
- dataType: 'jsonp',
- } ).done( function( response ) {
- if ( ts && 8 !== ts ) {
- $( el ).replaceWith( $( response.div ).css( 'tab-size', ts.toString() ) );
- } else {
- $( el ).replaceWith( response.div );
- }
-
- if ( ! gistStylesheetLoaded ) {
- var stylesheet =
- '<link rel="stylesheet" href="' + response.stylesheet + '" type="text/css" />';
-
- $( 'head' ).append( stylesheet );
-
- gistStylesheetLoaded = true;
- }
- } );
- } );
- };
-
- $( document ).ready( gistEmbed );
- $( 'body' ).on( 'post-load', gistEmbed );
-} )( jQuery );
diff --git a/plugins/jetpack/modules/shortcodes/js/instagram.js b/plugins/jetpack/modules/shortcodes/js/instagram.js
deleted file mode 100644
index b0d0d609..00000000
--- a/plugins/jetpack/modules/shortcodes/js/instagram.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/* global window */
-
-( function() {
- var instagramEmbed = function() {
- if (
- 'undefined' !== typeof window.instgrm &&
- window.instgrm.Embeds &&
- 'function' === typeof window.instgrm.Embeds.process
- ) {
- window.instgrm.Embeds.process();
- } else {
- var s = document.createElement( 'script' );
- s.async = true;
- s.defer = true;
- s.src = '//platform.instagram.com/en_US/embeds.js';
- document.getElementsByTagName( 'body' )[ 0 ].appendChild( s );
- }
- };
-
- if ( 'undefined' !== typeof jQuery && 'undefined' !== typeof infiniteScroll ) {
- jQuery( document.body ).on( 'post-load', instagramEmbed );
- }
-
- instagramEmbed();
-} )();
diff --git a/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js b/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js
index 9b0e9d52..be2a9f94 100644
--- a/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js
+++ b/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js
@@ -11,7 +11,7 @@ function JetpackSlideshow( element, transition, autostart ) {
JetpackSlideshow.prototype.showLoadingImage = function ( toggle ) {
if ( toggle ) {
this.loadingImage_ = document.createElement( 'div' );
- this.loadingImage_.className = 'slideshow-loading';
+ this.loadingImage_.className = 'jetpack-slideshow-loading';
var img = document.createElement( 'img' );
img.src = jetpackSlideshowSettings.spinner;
this.loadingImage_.appendChild( img );
@@ -38,11 +38,11 @@ JetpackSlideshow.prototype.init = function () {
img.setAttribute( 'itemprop', 'image' );
img.nopin = 'nopin';
var caption = document.createElement( 'div' );
- caption.className = 'slideshow-slide-caption';
+ caption.className = 'jetpack-slideshow-slide-caption';
caption.setAttribute( 'itemprop', 'caption description' );
caption.innerHTML = imageInfo.caption;
var container = document.createElement( 'div' );
- container.className = 'slideshow-slide';
+ container.className = 'jetpack-slideshow-slide';
container.setAttribute( 'itemprop', 'associatedMedia' );
container.setAttribute( 'itemscope', '' );
container.setAttribute( 'itemtype', 'https://schema.org/ImageObject' );
@@ -73,7 +73,7 @@ JetpackSlideshow.prototype.init = function () {
JetpackSlideshow.prototype.makeZeroWidthSpan = function () {
var emptySpan = document.createElement( 'span' );
- emptySpan.className = 'slideshow-line-height-hack';
+ emptySpan.className = 'jetpack-slideshow-line-height-hack';
// Having a NBSP makes IE act weird during transitions, but other
// browsers ignore a text node with a space in it as whitespace.
if ( -1 !== window.navigator.userAgent.indexOf( 'MSIE ' ) ) {
@@ -96,7 +96,7 @@ JetpackSlideshow.prototype.finishInit_ = function () {
prev: this.controls.prev,
next: this.controls.next,
timeout: jetpackSlideshowSettings.speed,
- slideExpr: '.slideshow-slide',
+ slideExpr: '.jetpack-slideshow-slide',
onPrevNextEvent: function () {
return self.onCyclePrevNextClick_.apply( self, arguments );
},
@@ -136,7 +136,7 @@ JetpackSlideshow.prototype.renderControls_ = function () {
}
var controlsDiv = document.createElement( 'div' );
- controlsDiv.className = 'slideshow-controls';
+ controlsDiv.className = 'jetpack-slideshow-controls';
var controls = [ 'prev', 'stop', 'next' ];
for ( var i = 0; i < controls.length; i++ ) {
diff --git a/plugins/jetpack/modules/shortcodes/quiz.php b/plugins/jetpack/modules/shortcodes/quiz.php
index 3bb0474d..21f6bc50 100644
--- a/plugins/jetpack/modules/shortcodes/quiz.php
+++ b/plugins/jetpack/modules/shortcodes/quiz.php
@@ -111,7 +111,7 @@ class Quiz_Shortcode {
* @return bool|null
*/
private static function is_javascript_unavailable() {
- if ( ! is_null( self::$javascript_unavailable ) ) {
+ if ( self::$javascript_unavailable !== null ) {
return self::$javascript_unavailable;
}
@@ -195,7 +195,7 @@ class Quiz_Shortcode {
$id .= ' data-trackid="' . esc_attr( self::$quiz_params['trackid'] ) . '"';
}
if ( self::is_wpcom() && ! empty( self::$quiz_params['a8ctraining'] ) ) {
- if ( is_null( self::$username ) ) {
+ if ( self::$username === null ) {
self::$username = wp_get_current_user()->user_login;
}
$id .= ' data-a8ctraining="' . esc_attr( self::$quiz_params['a8ctraining'] ) . '" data-username="' . esc_attr( self::$username ) . '"';
diff --git a/plugins/jetpack/modules/shortcodes/slideshow.php b/plugins/jetpack/modules/shortcodes/slideshow.php
index 68357947..e2e780da 100644
--- a/plugins/jetpack/modules/shortcodes/slideshow.php
+++ b/plugins/jetpack/modules/shortcodes/slideshow.php
@@ -191,7 +191,7 @@ class Jetpack_Slideshow_Shortcode {
'ids' => wp_list_pluck( $gallery, 'id' ),
);
- if ( 'true' == $autostart ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- attribute can be stored as boolean or string.
+ if ( 'true' == $autostart ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- attribute can be stored as boolean or string.
$amp_args['autoplay'] = true;
}
@@ -216,42 +216,23 @@ class Jetpack_Slideshow_Shortcode {
// Enqueue scripts.
$this->enqueue_scripts();
- $output = '';
-
- if ( defined( 'JSON_HEX_AMP' ) ) {
- // This is nice to have, but not strictly necessary since we use _wp_specialchars() below.
- $gallery = wp_json_encode( $attr['gallery'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); // phpcs:ignore PHPCompatibility
- } else {
- $gallery = wp_json_encode( $attr['gallery'] );
- }
-
- $output .= '<p class="jetpack-slideshow-noscript robots-nocontent">' . esc_html__( 'This slideshow requires JavaScript.', 'jetpack' ) . '</p>';
+ $output = '<p class="jetpack-slideshow-noscript robots-nocontent">' . esc_html__( 'This slideshow requires JavaScript.', 'jetpack' ) . '</p>';
/*
- * The input to json_encode() above can contain '&quot;'.
- *
- * For calls to json_encode() lacking the JSON_HEX_AMP option,
- * that '&quot;' is left unaltered. Running '&quot;' through esc_attr()
- * also leaves it unaltered since esc_attr() does not double-encode.
- *
- * This means we end up with an attribute like
- * `data-gallery="{&quot;foo&quot;:&quot;&quot;&quot;}"`,
- * which is interpreted by the browser as `{"foo":"""}`,
- * which cannot be JSON decoded.
- *
- * The preferred workaround is to include the JSON_HEX_AMP (and friends)
- * options, but these are not available until 5.3.0.
- * Alternatively, we can use _wp_specialchars( , , , true ) instead of
- * esc_attr(), which will double-encode.
- *
- * Since we can't rely on JSON_HEX_AMP, we do both.
- *
- * @todo Update when minimum is PHP 5.3+
+ * Checking for JSON_HEX_AMP and friends here allows us to get rid of
+ * '&quot;', that can sometimes be included in the JSON input in some languages like French.
*/
- $gallery_attributes = _wp_specialchars( wp_check_invalid_utf8( $gallery ), ENT_QUOTES, false, true );
+ $gallery_attributes = _wp_specialchars(
+ wp_check_invalid_utf8(
+ wp_json_encode( $attr['gallery'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT )
+ ),
+ ENT_QUOTES,
+ false,
+ true
+ );
$output .= sprintf(
- '<div id="%s" class="slideshow-window jetpack-slideshow slideshow-%s" data-trans="%s" data-autostart="%s" data-gallery="%s" itemscope itemtype="https://schema.org/ImageGallery"></div>',
+ '<div id="%s" class="jetpack-slideshow-window jetpack-slideshow jetpack-slideshow-%s" data-trans="%s" data-autostart="%s" data-gallery="%s" itemscope itemtype="https://schema.org/ImageGallery"></div>',
esc_attr( $attr['selector'] . '-slideshow' ),
esc_attr( $attr['color'] ),
esc_attr( $attr['trans'] ),
diff --git a/plugins/jetpack/modules/shortcodes/wufoo.php b/plugins/jetpack/modules/shortcodes/wufoo.php
index 0af8b51a..f399c807 100644
--- a/plugins/jetpack/modules/shortcodes/wufoo.php
+++ b/plugins/jetpack/modules/shortcodes/wufoo.php
@@ -71,7 +71,7 @@ function wufoo_shortcode( $atts ) {
'(function(){try{var wufoo_%1$s = new WufooForm();wufoo_%1$s.initialize({"userName":"%2$s","formHash":"%1$s","autoResize":%3$s,"height":"%4$d","header":"%5$s","ssl":true,"async":true});wufoo_%1$s.display();}catch(e){}})();',
esc_attr( $attr['formhash'] ),
esc_attr( $attr['username'] ),
- 'true' == $attr['autoresize'] ? 'true' : 'false', // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
+ 'true' == $attr['autoresize'] ? 'true' : 'false', // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
absint( $attr['height'] ),
'show' === $attr['header'] ? 'show' : 'hide'
);
diff --git a/plugins/jetpack/modules/shortlinks.php b/plugins/jetpack/modules/shortlinks.php
index 989271d7..fd541a48 100644
--- a/plugins/jetpack/modules/shortlinks.php
+++ b/plugins/jetpack/modules/shortlinks.php
@@ -131,12 +131,25 @@ function wpme_get_shortlink_handler( $shortlink, $id, $context, $allow_slugs ) {
* @uses register_rest_field, wpme_rest_get_shortlink
*/
function wpme_rest_register_shortlinks() {
+ // Post types that support shortlinks by default.
+ $supported_post_types = array(
+ 'attachment',
+ 'page',
+ 'post',
+ );
+
+ // Add any CPT that may have declared support for shortlinks.
+ foreach ( get_post_types() as $post_type ) {
+ if (
+ post_type_supports( $post_type, 'shortlinks' )
+ && post_type_supports( $post_type, 'editor' )
+ ) {
+ $supported_post_types[] = $post_type;
+ }
+ }
+
register_rest_field(
- array(
- 'attachment',
- 'page',
- 'post',
- ),
+ $supported_post_types,
'jetpack_shortlink',
array(
'get_callback' => 'wpme_rest_get_shortlink',
diff --git a/plugins/jetpack/modules/simple-payments/paypal-express-checkout.js b/plugins/jetpack/modules/simple-payments/paypal-express-checkout.js
index 74b14101..16e486ef 100644
--- a/plugins/jetpack/modules/simple-payments/paypal-express-checkout.js
+++ b/plugins/jetpack/modules/simple-payments/paypal-express-checkout.js
@@ -159,6 +159,7 @@ var PaypalExpressCheckout = {
label: 'pay',
shape: 'rect',
color: 'silver',
+ size: 'responsive',
fundingicons: true,
},
diff --git a/plugins/jetpack/modules/simple-payments/simple-payments.css b/plugins/jetpack/modules/simple-payments/simple-payments.css
index 6e5e4136..2b96b355 100644
--- a/plugins/jetpack/modules/simple-payments/simple-payments.css
+++ b/plugins/jetpack/modules/simple-payments/simple-payments.css
@@ -51,6 +51,11 @@ body .jetpack-simple-payments-wrapper .jetpack-simple-payments-product-image .je
display: flex;
}
+.jetpack-simple-payments-button {
+ max-width: 340px;
+ width: 100%;
+}
+
.jetpack-simple-payments-items {
flex: 0 0 auto;
margin-right: 10px;
@@ -63,6 +68,11 @@ input[type="number"].jetpack-simple-payments-items-number {
padding: 4px 8px;
}
+input[type=number].jetpack-simple-payments-items-number::-webkit-inner-spin-button,
+input[type=number].jetpack-simple-payments-items-number::-webkit-outer-spin-button {
+ opacity: 1;
+}
+
.jetpack-simple-payments-button iframe {
margin: 0;
}
@@ -151,6 +161,10 @@ body .jetpack-simple-payments-wrapper .jetpack-simple-payments-purchase-message
margin: 0;
}
+.jetpack-simple-payments-details {
+ width: 100%;
+}
+
.is-email .jetpack-simple-payments-product-image + .jetpack-simple-payments-details {
display: table-cell;
width: 70%;
diff --git a/plugins/jetpack/modules/simple-payments/simple-payments.php b/plugins/jetpack/modules/simple-payments/simple-payments.php
index 321fc1e2..38f0bef8 100644
--- a/plugins/jetpack/modules/simple-payments/simple-payments.php
+++ b/plugins/jetpack/modules/simple-payments/simple-payments.php
@@ -12,22 +12,70 @@
*/
class Jetpack_Simple_Payments {
// These have to be under 20 chars because that is CPT limit.
- static $post_type_order = 'jp_pay_order';
- static $post_type_product = 'jp_pay_product';
- static $shortcode = 'simple-payment';
+ /**
+ * Post type order.
+ *
+ * @var string
+ */
+ public static $post_type_order = 'jp_pay_order';
+
+ /**
+ * Post type product.
+ *
+ * @var string
+ */
+ public static $post_type_product = 'jp_pay_product';
- static $css_classname_prefix = 'jetpack-simple-payments';
+ /**
+ * Define simple payment shortcode.
+ *
+ * @var string
+ */
+ public static $shortcode = 'simple-payment';
- static $required_plan;
+ /**
+ * Define simple payment CSS prefix.
+ *
+ * @var string
+ */
+ public static $css_classname_prefix = 'jetpack-simple-payments';
- // Increase this number each time there's a change in CSS or JS to bust cache.
- static $version = '0.25';
+ /**
+ * Which plan the user is on.
+ *
+ * @var string value_bundle or jetpack_premium
+ */
+ public static $required_plan;
- // Classic singleton pattern:
+ /**
+ * Instance of the class.
+ *
+ * @var Jetpack_Simple_Payments
+ */
private static $instance;
+
+ /**
+ * Construction function.
+ */
private function __construct() {}
- static function getInstance() {
+
+ /**
+ * Original singleton.
+ *
+ * @todo Remove this when nothing calles getInstance anymore.
+ *
+ * @deprecated 10.8
+ */
+ public static function getInstance() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
+ _deprecated_function( __METHOD__, 'Jetpack 10.7.0', 'Jetpack_Simple_Payments::get_instance' );
+ return self::get_instance();
+ }
+
+ /**
+ * Create instance of class.
+ */
+ public static function get_instance() {
if ( ! self::$instance ) {
self::$instance = new self();
self::$instance->register_init_hooks();
@@ -36,31 +84,56 @@ class Jetpack_Simple_Payments {
return self::$instance;
}
+ /**
+ * Register scripts and styles.
+ */
private function register_scripts_and_styles() {
/**
* Paypal heavily discourages putting that script in your own server:
+ *
* @see https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/add-paypal-button/
*/
- wp_register_script( 'paypal-checkout-js', 'https://www.paypalobjects.com/api/checkout.js', array(), null, true );
+ wp_register_script( // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
+ 'paypal-checkout-js',
+ 'https://www.paypalobjects.com/api/checkout.js',
+ array(),
+ null,
+ true
+ );
wp_register_script(
'jetpack-paypal-express-checkout',
plugins_url( '/paypal-express-checkout.js', __FILE__ ),
array( 'jquery', 'paypal-checkout-js' ),
- self::$version,
+ JETPACK__VERSION,
+ false
+ );
+ wp_register_style(
+ 'jetpack-simple-payments',
+ plugins_url( '/simple-payments.css', __FILE__ ),
+ array( 'dashicons' ),
+ JETPACK__VERSION,
false
);
- wp_register_style( 'jetpack-simple-payments', plugins_url( '/simple-payments.css', __FILE__ ), array( 'dashicons' ) );
}
+ /**
+ * Register init hooks.
+ */
private function register_init_hooks() {
add_action( 'init', array( $this, 'init_hook_action' ) );
add_action( 'rest_api_init', array( $this, 'register_meta_fields_in_rest_api' ) );
}
+ /**
+ * Register the shortcode.
+ */
private function register_shortcode() {
add_shortcode( self::$shortcode, array( $this, 'parse_shortcode' ) );
}
+ /**
+ * Actions that are run on init.
+ */
public function init_hook_action() {
add_filter( 'rest_api_allowed_post_types', array( $this, 'allow_rest_api_types' ) );
add_filter( 'jetpack_sync_post_meta_whitelist', array( $this, 'allow_sync_post_meta' ) );
@@ -106,7 +179,12 @@ class Jetpack_Simple_Payments {
);
}
- function remove_auto_paragraph_from_product_description( $content ) {
+ /**
+ * Remove auto paragraph from product description.
+ *
+ * @param string $content - the content of the post.
+ */
+ public function remove_auto_paragraph_from_product_description( $content ) {
if ( get_post_type() === self::$post_type_product ) {
remove_filter( 'the_content', 'wpautop' );
}
@@ -114,7 +192,8 @@ class Jetpack_Simple_Payments {
return $content;
}
- function get_blog_id() {
+ /** Return the blog ID */
+ public function get_blog_id() {
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
return get_current_blog_id();
}
@@ -127,7 +206,7 @@ class Jetpack_Simple_Payments {
*
* @return bool True if Simple Payments are enabled, false otherwise.
*/
- function is_enabled_jetpack_simple_payments() {
+ public function is_enabled_jetpack_simple_payments() {
/**
* Can be used by plugin authors to disable the conflicting output of Simple Payments.
*
@@ -139,38 +218,64 @@ class Jetpack_Simple_Payments {
return false;
}
- // For WPCOM sites
- if ( defined( 'IS_WPCOM' ) && IS_WPCOM && function_exists( 'has_any_blog_stickers' ) ) {
- $site_id = $this->get_blog_id();
- return has_any_blog_stickers( array( 'premium-plan', 'business-plan', 'ecommerce-plan' ), $site_id );
+ return (
+ ( ( defined( 'IS_WPCOM' ) && IS_WPCOM ) || Jetpack::is_connection_ready() ) &&
+ Jetpack_Plan::supports( 'simple-payments' )
+ );
+ }
+
+ /**
+ * Get a WP_Post representation of a product
+ *
+ * @param int $id The ID of the product.
+ *
+ * @return array|false|WP_Post
+ */
+ private function get_product( $id ) {
+ if ( ! $id ) {
+ return false;
}
- // For all Jetpack sites
- return Jetpack::is_connection_ready() && Jetpack_Plan::supports( 'simple-payments' );
+ $product = get_post( $id );
+ if ( ! $product || is_wp_error( $product ) ) {
+ return false;
+ }
+ if ( $product->post_type !== self::$post_type_product || 'publish' !== $product->post_status ) {
+ return false;
+ }
+ return $product;
}
- function parse_shortcode( $attrs, $content = false ) {
+ /**
+ * Creates the content from a shortcode
+ *
+ * @param array $attrs Shortcode attributes.
+ * @param mixed $content unused.
+ *
+ * @return string|void
+ */
+ public function parse_shortcode( $attrs, $content = false ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
if ( empty( $attrs['id'] ) ) {
return;
}
- $product = get_post( $attrs['id'] );
- if ( ! $product || is_wp_error( $product ) ) {
- return;
- }
- if ( $product->post_type !== self::$post_type_product || 'publish' !== $product->post_status ) {
+ $product = $this->get_product( $attrs['id'] );
+ if ( ! $product ) {
return;
}
- // We allow for overriding the presentation labels
- $data = shortcode_atts( array(
- 'blog_id' => $this->get_blog_id(),
- 'dom_id' => uniqid( self::$css_classname_prefix . '-' . $product->ID . '_', true ),
- 'class' => self::$css_classname_prefix . '-' . $product->ID,
- 'title' => get_the_title( $product ),
- 'description' => $product->post_content,
- 'cta' => get_post_meta( $product->ID, 'spay_cta', true ),
- 'multiple' => get_post_meta( $product->ID, 'spay_multiple', true ) || '0'
- ), $attrs );
+ // We allow for overriding the presentation labels.
+ $data = shortcode_atts(
+ array(
+ 'blog_id' => $this->get_blog_id(),
+ 'dom_id' => uniqid( self::$css_classname_prefix . '-' . $product->ID . '_', true ),
+ 'class' => self::$css_classname_prefix . '-' . $product->ID,
+ 'title' => get_the_title( $product ),
+ 'description' => $product->post_content,
+ 'cta' => get_post_meta( $product->ID, 'spay_cta', true ),
+ 'multiple' => get_post_meta( $product->ID, 'spay_multiple', true ) || '0',
+ ),
+ $attrs
+ );
$data['price'] = $this->format_price(
get_post_meta( $product->ID, 'spay_price', true ),
@@ -192,15 +297,22 @@ class Jetpack_Simple_Payments {
return $this->output_shortcode( $data );
}
- function output_admin_warning( $data ) {
+ /**
+ * Output an admin warning if user can't use Pay with PayPal.
+ *
+ * @param array $data unused.
+ */
+ public function output_admin_warning( $data ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
jetpack_require_lib( 'components' );
- return Jetpack_Components::render_upgrade_nudge( array(
- 'plan' => self::$required_plan
- ) );
+ return Jetpack_Components::render_upgrade_nudge(
+ array(
+ 'plan' => self::$required_plan,
+ )
+ );
}
/**
@@ -212,11 +324,12 @@ class Jetpack_Simple_Payments {
* @return string
*/
public function output_purchase_box( $dom_id, $is_multiple ) {
- $items = '';
+ $items = '';
$css_prefix = self::$css_classname_prefix;
if ( $is_multiple ) {
- $items = sprintf( '
+ $items = sprintf(
+ '
<div class="%1$s">
<input class="%2$s" type="number" value="1" min="1" id="%3$s" />
</div>
@@ -247,16 +360,18 @@ class Jetpack_Simple_Payments {
public function output_shortcode( $data ) {
$css_prefix = self::$css_classname_prefix;
- $image = "";
- if( has_post_thumbnail( $data['id'] ) ) {
- $image = sprintf( '<div class="%1$s"><div class="%2$s">%3$s</div></div>',
+ $image = '';
+ if ( has_post_thumbnail( $data['id'] ) ) {
+ $image = sprintf(
+ '<div class="%1$s"><div class="%2$s">%3$s</div></div>',
esc_attr( "${css_prefix}-product-image" ),
esc_attr( "${css_prefix}-image" ),
get_the_post_thumbnail( $data['id'], 'full' )
);
}
- return sprintf( '
+ return sprintf(
+ '
<div class="%1$s">
<div class="%2$s">
%3$s
@@ -301,30 +416,39 @@ class Jetpack_Simple_Payments {
/**
* Allows custom post types to be used by REST API.
- * @param $post_types
+ *
+ * @param array $post_types - the allows post types.
* @see hook 'rest_api_allowed_post_types'
* @return array
*/
- function allow_rest_api_types( $post_types ) {
+ public function allow_rest_api_types( $post_types ) {
$post_types[] = self::$post_type_order;
$post_types[] = self::$post_type_product;
return $post_types;
}
- function allow_sync_post_meta( $post_meta ) {
- return array_merge( $post_meta, array(
- 'spay_paypal_id',
- 'spay_status',
- 'spay_product_id',
- 'spay_quantity',
- 'spay_price',
- 'spay_customer_email',
- 'spay_currency',
- 'spay_cta',
- 'spay_email',
- 'spay_multiple',
- 'spay_formatted_price',
- ) );
+ /**
+ * Merge $post_meta with additional meta information.
+ *
+ * @param array $post_meta - the post's meta information.
+ */
+ public function allow_sync_post_meta( $post_meta ) {
+ return array_merge(
+ $post_meta,
+ array(
+ 'spay_paypal_id',
+ 'spay_status',
+ 'spay_product_id',
+ 'spay_quantity',
+ 'spay_price',
+ 'spay_customer_email',
+ 'spay_currency',
+ 'spay_cta',
+ 'spay_email',
+ 'spay_multiple',
+ 'spay_formatted_price',
+ )
+ );
}
/**
@@ -336,64 +460,90 @@ class Jetpack_Simple_Payments {
* @link https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/
*/
public function register_meta_fields_in_rest_api() {
- register_meta( 'post', 'spay_price', array(
- 'description' => esc_html__( 'Simple payments; price.', 'jetpack' ),
- 'object_subtype' => self::$post_type_product,
- 'sanitize_callback' => array( $this, 'sanitize_price' ),
- 'show_in_rest' => true,
- 'single' => true,
- 'type' => 'number',
- ) );
-
- register_meta( 'post', 'spay_currency', array(
- 'description' => esc_html__( 'Simple payments; currency code.', 'jetpack' ),
- 'object_subtype' => self::$post_type_product,
- 'sanitize_callback' => array( $this, 'sanitize_currency' ),
- 'show_in_rest' => true,
- 'single' => true,
- 'type' => 'string',
- ) );
-
- register_meta( 'post', 'spay_cta', array(
- 'description' => esc_html__( 'Simple payments; text with "Buy" or other CTA', 'jetpack' ),
- 'object_subtype' => self::$post_type_product,
- 'sanitize_callback' => 'sanitize_text_field',
- 'show_in_rest' => true,
- 'single' => true,
- 'type' => 'string',
- ) );
-
- register_meta( 'post', 'spay_multiple', array(
- 'description' => esc_html__( 'Simple payments; allow multiple items', 'jetpack' ),
- 'object_subtype' => self::$post_type_product,
- 'sanitize_callback' => 'rest_sanitize_boolean',
- 'show_in_rest' => true,
- 'single' => true,
- 'type' => 'boolean',
- ) );
-
- register_meta( 'post', 'spay_email', array(
- 'description' => esc_html__( 'Simple payments button; paypal email.', 'jetpack' ),
- 'sanitize_callback' => 'sanitize_email',
- 'show_in_rest' => true,
- 'single' => true,
- 'type' => 'string',
- ) );
-
- register_meta( 'post', 'spay_status', array(
- 'description' => esc_html__( 'Simple payments; status.', 'jetpack' ),
- 'object_subtype' => self::$post_type_product,
- 'sanitize_callback' => 'sanitize_text_field',
- 'show_in_rest' => true,
- 'single' => true,
- 'type' => 'string',
- ) );
+ register_meta(
+ 'post',
+ 'spay_price',
+ array(
+ 'description' => esc_html__( 'Simple payments; price.', 'jetpack' ),
+ 'object_subtype' => self::$post_type_product,
+ 'sanitize_callback' => array( $this, 'sanitize_price' ),
+ 'show_in_rest' => true,
+ 'single' => true,
+ 'type' => 'number',
+ )
+ );
+
+ register_meta(
+ 'post',
+ 'spay_currency',
+ array(
+ 'description' => esc_html__( 'Simple payments; currency code.', 'jetpack' ),
+ 'object_subtype' => self::$post_type_product,
+ 'sanitize_callback' => array( $this, 'sanitize_currency' ),
+ 'show_in_rest' => true,
+ 'single' => true,
+ 'type' => 'string',
+ )
+ );
+
+ register_meta(
+ 'post',
+ 'spay_cta',
+ array(
+ 'description' => esc_html__( 'Simple payments; text with "Buy" or other CTA', 'jetpack' ),
+ 'object_subtype' => self::$post_type_product,
+ 'sanitize_callback' => 'sanitize_text_field',
+ 'show_in_rest' => true,
+ 'single' => true,
+ 'type' => 'string',
+ )
+ );
+
+ register_meta(
+ 'post',
+ 'spay_multiple',
+ array(
+ 'description' => esc_html__( 'Simple payments; allow multiple items', 'jetpack' ),
+ 'object_subtype' => self::$post_type_product,
+ 'sanitize_callback' => 'rest_sanitize_boolean',
+ 'show_in_rest' => true,
+ 'single' => true,
+ 'type' => 'boolean',
+ )
+ );
+
+ register_meta(
+ 'post',
+ 'spay_email',
+ array(
+ 'description' => esc_html__( 'Simple payments button; paypal email.', 'jetpack' ),
+ 'sanitize_callback' => 'sanitize_email',
+ 'show_in_rest' => true,
+ 'single' => true,
+ 'type' => 'string',
+ )
+ );
+
+ register_meta(
+ 'post',
+ 'spay_status',
+ array(
+ 'description' => esc_html__( 'Simple payments; status.', 'jetpack' ),
+ 'object_subtype' => self::$post_type_product,
+ 'sanitize_callback' => 'sanitize_text_field',
+ 'show_in_rest' => true,
+ 'single' => true,
+ 'type' => 'string',
+ )
+ );
}
/**
* Sanitize three-character ISO-4217 Simple payments currency
*
* List has to be in sync with list at the block's client side and widget's backend side:
+ *
+ * @param array $currency - list of currencies.
* @link https://github.com/Automattic/jetpack/blob/31efa189ad223c0eb7ad085ac0650a23facf9ef5/extensions/blocks/simple-payments/constants.js#L9-L39
* @link https://github.com/Automattic/jetpack/blob/31efa189ad223c0eb7ad085ac0650a23facf9ef5/modules/widgets/simple-payments.php#L19-L44
*
@@ -432,7 +582,7 @@ class Jetpack_Simple_Payments {
'THB',
);
- return in_array( $currency, $valid_currencies ) ? $currency : false;
+ return in_array( $currency, $valid_currencies, true ) ? $currency : false;
}
/**
@@ -443,9 +593,10 @@ class Jetpack_Simple_Payments {
* Maximum length: 10.
*
* See `price` from PayPal docs:
+ *
* @link https://developer.paypal.com/docs/api/orders/v1/#definition-item
*
- * @param $value
+ * @param string $price - the price we want to sanitize.
* @return null|string
*/
public static function sanitize_price( $price ) {
@@ -455,8 +606,7 @@ class Jetpack_Simple_Payments {
/**
* Sets up the custom post types for the module.
*/
- function setup_cpts() {
-
+ public function setup_cpts() {
/*
* ORDER data structure. holds:
* title = customer_name | 4xproduct_name
@@ -471,31 +621,31 @@ class Jetpack_Simple_Payments {
* ... (WIP)
*/
$order_capabilities = array(
- 'edit_post' => 'edit_posts',
- 'read_post' => 'read_private_posts',
- 'delete_post' => 'delete_posts',
- 'edit_posts' => 'edit_posts',
- 'edit_others_posts' => 'edit_others_posts',
- 'publish_posts' => 'publish_posts',
- 'read_private_posts' => 'read_private_posts',
+ 'edit_post' => 'edit_posts',
+ 'read_post' => 'read_private_posts',
+ 'delete_post' => 'delete_posts',
+ 'edit_posts' => 'edit_posts',
+ 'edit_others_posts' => 'edit_others_posts',
+ 'publish_posts' => 'publish_posts',
+ 'read_private_posts' => 'read_private_posts',
);
- $order_args = array(
- 'label' => esc_html_x( 'Order', 'noun: a quantity of goods or items purchased or sold', 'jetpack' ),
- 'description' => esc_html__( 'Simple Payments orders', 'jetpack' ),
- 'supports' => array( 'custom-fields', 'excerpt' ),
- 'hierarchical' => false,
- 'public' => false,
- 'show_ui' => false,
- 'show_in_menu' => false,
- 'show_in_admin_bar' => false,
- 'show_in_nav_menus' => false,
- 'can_export' => true,
- 'has_archive' => false,
- 'exclude_from_search' => true,
- 'publicly_queryable' => false,
- 'rewrite' => false,
- 'capabilities' => $order_capabilities,
- 'show_in_rest' => true,
+ $order_args = array(
+ 'label' => esc_html_x( 'Order', 'noun: a quantity of goods or items purchased or sold', 'jetpack' ),
+ 'description' => esc_html__( 'Simple Payments orders', 'jetpack' ),
+ 'supports' => array( 'custom-fields', 'excerpt' ),
+ 'hierarchical' => false,
+ 'public' => false,
+ 'show_ui' => false,
+ 'show_in_menu' => false,
+ 'show_in_admin_bar' => false,
+ 'show_in_nav_menus' => false,
+ 'can_export' => true,
+ 'has_archive' => false,
+ 'exclude_from_search' => true,
+ 'publicly_queryable' => false,
+ 'rewrite' => false,
+ 'capabilities' => $order_capabilities,
+ 'show_in_rest' => true,
);
register_post_type( self::$post_type_order, $order_args );
@@ -514,36 +664,117 @@ class Jetpack_Simple_Payments {
* spay_status - status. { enabled | disabled }
*/
$product_capabilities = array(
- 'edit_post' => 'edit_posts',
- 'read_post' => 'read_private_posts',
- 'delete_post' => 'delete_posts',
- 'edit_posts' => 'publish_posts',
- 'edit_others_posts' => 'edit_others_posts',
- 'publish_posts' => 'publish_posts',
- 'read_private_posts' => 'read_private_posts',
+ 'edit_post' => 'edit_posts',
+ 'read_post' => 'read_private_posts',
+ 'delete_post' => 'delete_posts',
+ 'edit_posts' => 'publish_posts',
+ 'edit_others_posts' => 'edit_others_posts',
+ 'publish_posts' => 'publish_posts',
+ 'read_private_posts' => 'read_private_posts',
);
- $product_args = array(
- 'label' => esc_html__( 'Product', 'jetpack' ),
- 'description' => esc_html__( 'Simple Payments products', 'jetpack' ),
- 'supports' => array( 'title', 'editor','thumbnail', 'custom-fields', 'author' ),
- 'hierarchical' => false,
- 'public' => false,
- 'show_ui' => false,
- 'show_in_menu' => false,
- 'show_in_admin_bar' => false,
- 'show_in_nav_menus' => false,
- 'can_export' => true,
- 'has_archive' => false,
- 'exclude_from_search' => true,
- 'publicly_queryable' => false,
- 'rewrite' => false,
- 'capabilities' => $product_capabilities,
- 'show_in_rest' => true,
+ $product_args = array(
+ 'label' => esc_html__( 'Product', 'jetpack' ),
+ 'description' => esc_html__( 'Simple Payments products', 'jetpack' ),
+ 'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'author' ),
+ 'hierarchical' => false,
+ 'public' => false,
+ 'show_ui' => false,
+ 'show_in_menu' => false,
+ 'show_in_admin_bar' => false,
+ 'show_in_nav_menus' => false,
+ 'can_export' => true,
+ 'has_archive' => false,
+ 'exclude_from_search' => true,
+ 'publicly_queryable' => false,
+ 'rewrite' => false,
+ 'capabilities' => $product_capabilities,
+ 'show_in_rest' => true,
);
register_post_type( self::$post_type_product, $product_args );
}
/**
+ * Validate the block attributes
+ *
+ * @param array $attrs The block attributes, expected to contain:
+ * * email - an email address.
+ * * price - a float between 0.01 and 9999999999.99.
+ * * productId - the ID of the product being paid for.
+ *
+ * @return bool
+ */
+ public function is_valid( $attrs ) {
+ if ( ! $this->validate_paypal_email( $attrs ) ) {
+ return false;
+ }
+
+ if ( ! $this->validate_price( $attrs ) ) {
+ return false;
+ }
+
+ if ( ! $this->validate_product( $attrs ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Check that the email address to make a payment to is valid
+ *
+ * @param array $attrs Key-value array of attributes.
+ *
+ * @return boolean
+ */
+ private function validate_paypal_email( $attrs ) {
+ if ( empty( $attrs['email'] ) ) {
+ return false;
+ }
+ return (bool) filter_var( $attrs['email'], FILTER_VALIDATE_EMAIL );
+ }
+
+ /**
+ * Check that the price is valid
+ *
+ * @param array $attrs Key-value array of attributes.
+ *
+ * @return bool
+ */
+ private function validate_price( $attrs ) {
+ if ( empty( $attrs['price'] ) ) {
+ return false;
+ }
+ return (bool) self::sanitize_price( $attrs['price'] );
+ }
+
+ /**
+ * Check that the stored product is valid
+ *
+ * Valid means it has a title, and the currency is accepted.
+ *
+ * @param array $attrs Key-value array of attributes.
+ *
+ * @return bool
+ */
+ private function validate_product( $attrs ) {
+ if ( empty( $attrs['productId'] ) ) {
+ return false;
+ }
+ $product = $this->get_product( $attrs['productId'] );
+ if ( ! $product ) {
+ return false;
+ }
+ // This title is the one used by paypal, it's set from the title set in the block content, unless the block
+ // content title is blank.
+ if ( ! get_the_title( $product ) ) {
+ return false;
+ }
+
+ $currency = get_post_meta( $product->ID, 'spay_currency', true );
+ return (bool) self::sanitize_currency( $currency );
+ }
+
+ /**
* Format a price for display
*
* Largely taken from WordPress.com Store_Price class
@@ -567,4 +798,4 @@ class Jetpack_Simple_Payments {
return null;
}
}
-Jetpack_Simple_Payments::getInstance();
+Jetpack_Simple_Payments::get_instance();
diff --git a/plugins/jetpack/modules/sitemaps.php b/plugins/jetpack/modules/sitemaps.php
index 27d1a6c2..55c98caf 100644
--- a/plugins/jetpack/modules/sitemaps.php
+++ b/plugins/jetpack/modules/sitemaps.php
@@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
-if ( '1' == get_option( 'blog_public' ) ) { // loose comparison okay.
+if ( '1' == get_option( 'blog_public' ) ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
include_once __DIR__ . '/sitemaps/sitemaps.php';
// Disable WordPress 5.5-era sitemaps.
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-fallback.php
index 7a87aa96..80558f15 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-buffer-fallback.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-fallback.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* The fallback buffer for users with no XML support.
*
@@ -22,6 +22,13 @@ abstract class Jetpack_Sitemap_Buffer_Fallback extends Jetpack_Sitemap_Buffer {
*/
protected $buffer;
+ /**
+ * Jetpack_Sitemap_Buffer_Fallback constructor.
+ *
+ * @param int $item_limit The maximum size of the buffer in items.
+ * @param int $byte_limit The maximum size of the buffer in bytes.
+ * @param string $time The initial datetime of the buffer. Must be in 'YYYY-MM-DD hh:mm:ss' format.
+ */
public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) {
$this->is_full_flag = false;
$this->is_empty_flag = true;
@@ -46,7 +53,7 @@ abstract class Jetpack_Sitemap_Buffer_Fallback extends Jetpack_Sitemap_Buffer {
* @return bool True if the append succeeded, False if not.
*/
public function append( $array ) {
- if ( is_null( $array ) ) {
+ if ( $array === null ) {
return true;
}
@@ -98,10 +105,12 @@ abstract class Jetpack_Sitemap_Buffer_Fallback extends Jetpack_Sitemap_Buffer {
/**
* Legacy implementation of array to XML conversion without using DOMDocument.
*
- * @param array $array
+ * @param array $array Item to append to buffer.
+ * @param DOMElement $parent (optional) an element to which new children should be added.
+ * @param DOMDocument $root (optional) the parent document.
* @return String $result
*/
- public function array_to_xml_string( $array, $parent = null, $root = null ) {
+ public function array_to_xml_string( $array, $parent = null, $root = null ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$string = '';
foreach ( $array as $key => $value ) {
@@ -112,7 +121,7 @@ abstract class Jetpack_Sitemap_Buffer_Fallback extends Jetpack_Sitemap_Buffer {
$string .= "<$tag>";
$string .= $this->array_to_xml_string( $value );
$string .= "</$tag>";
- } elseif ( is_null( $value ) ) {
+ } elseif ( $value === null ) {
$string .= "<$tag />";
} else {
$string .= "<$tag>" . htmlspecialchars( $value ) . "</$tag>";
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-image-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-image-fallback.php
index 2d879570..f211e2b7 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-buffer-image-fallback.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-image-fallback.php
@@ -1,4 +1,5 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+// phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
/**
* Sitemaps (per the protocol) are essentially lists of XML fragments;
* lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Image
@@ -15,7 +16,9 @@
* @since 5.3.0
*/
class Jetpack_Sitemap_Buffer_Image extends Jetpack_Sitemap_Buffer_Fallback {
-
+ /**
+ * Returns a DOM element that contains all image sitemap elements.
+ */
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-image.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-image.php
index 5413a623..eaad5dd8 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-buffer-image.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-image.php
@@ -1,4 +1,5 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+// phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
/**
* Sitemaps (per the protocol) are essentially lists of XML fragments;
* lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Image
@@ -16,6 +17,13 @@
*/
class Jetpack_Sitemap_Buffer_Image extends Jetpack_Sitemap_Buffer {
+ /**
+ * Jetpack_Sitemap_Buffer_Image constructor.
+ *
+ * @param int $item_limit The maximum size of the buffer in items.
+ * @param int $byte_limit The maximum size of the buffer in bytes.
+ * @param string $time The initial datetime of the buffer. Must be in 'YYYY-MM-DD hh:mm:ss' format.
+ */
public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) {
parent::__construct( $item_limit, $byte_limit, $time );
@@ -31,6 +39,9 @@ class Jetpack_Sitemap_Buffer_Image extends Jetpack_Sitemap_Buffer {
);
}
+ /**
+ * Returns a DOM element that contains all image sitemap elements.
+ */
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-master-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-master-fallback.php
index eb62cfe8..2234b31b 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-buffer-master-fallback.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-master-fallback.php
@@ -1,4 +1,5 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+// phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
/**
* Sitemaps (per the protocol) are essentially lists of XML fragments;
* lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Master
@@ -16,6 +17,9 @@
*/
class Jetpack_Sitemap_Buffer_Master extends Jetpack_Sitemap_Buffer_Fallback {
+ /**
+ * Returns a DOM element that contains all master sitemap elements.
+ */
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-master.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-master.php
index 09d18c35..cd5359f2 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-buffer-master.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-master.php
@@ -1,4 +1,5 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+// phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
/**
* Sitemaps (per the protocol) are essentially lists of XML fragments;
* lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Master
@@ -15,7 +16,13 @@
* @since 5.3.0
*/
class Jetpack_Sitemap_Buffer_Master extends Jetpack_Sitemap_Buffer {
-
+ /**
+ * Jetpack_Sitemap_Buffer_Master constructor.
+ *
+ * @param int $item_limit The maximum size of the buffer in items.
+ * @param int $byte_limit The maximum size of the buffer in bytes.
+ * @param string $time The initial datetime of the buffer. Must be in 'YYYY-MM-DD hh:mm:ss' format.
+ */
public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) {
parent::__construct( $item_limit, $byte_limit, $time );
@@ -31,6 +38,9 @@ class Jetpack_Sitemap_Buffer_Master extends Jetpack_Sitemap_Buffer {
);
}
+ /**
+ * Returns a DOM element that contains all master sitemap elements.
+ */
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
$this->root = $this->doc->createElement( 'sitemapindex' );
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-news-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-news-fallback.php
index 013e2535..154c28c8 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-buffer-news-fallback.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-news-fallback.php
@@ -1,4 +1,5 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+// phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
/**
* Sitemaps (per the protocol) are essentially lists of XML fragments;
* lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_News
@@ -10,12 +11,14 @@
*/
/**
- * A buffer for constructing sitemap image xml files for users without libxml support.
+ * A buffer for constructing sitemap news xml files for users without libxml support.
*
* @since 5.3.0
*/
class Jetpack_Sitemap_Buffer_News extends Jetpack_Sitemap_Buffer_Fallback {
-
+ /**
+ * Returns a DOM element that contains all news sitemap elements.
+ */
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-news.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-news.php
index a4504532..b39aed21 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-buffer-news.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-news.php
@@ -1,4 +1,5 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+// phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
/**
* Sitemaps (per the protocol) are essentially lists of XML fragments;
* lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_News
@@ -10,12 +11,18 @@
*/
/**
- * A buffer for constructing sitemap image xml files.
+ * A buffer for constructing sitemap news xml files.
*
* @since 5.3.0
*/
class Jetpack_Sitemap_Buffer_News extends Jetpack_Sitemap_Buffer {
-
+ /**
+ * Jetpack_Sitemap_Buffer_News constructor.
+ *
+ * @param int $item_limit The maximum size of the buffer in items.
+ * @param int $byte_limit The maximum size of the buffer in bytes.
+ * @param string $time The initial datetime of the buffer. Must be in 'YYYY-MM-DD hh:mm:ss' format.
+ */
public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) {
parent::__construct( $item_limit, $byte_limit, $time );
@@ -31,6 +38,9 @@ class Jetpack_Sitemap_Buffer_News extends Jetpack_Sitemap_Buffer {
);
}
+ /**
+ * Returns a DOM element that contains all news sitemap elements.
+ */
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-page-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-page-fallback.php
index 16f1e997..8f742915 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-buffer-page-fallback.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-page-fallback.php
@@ -1,4 +1,5 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+// phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
/**
* Sitemaps (per the protocol) are essentially lists of XML fragments;
* lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Page
@@ -15,7 +16,9 @@
* @since 5.3.0
*/
class Jetpack_Sitemap_Buffer_Page extends Jetpack_Sitemap_Buffer_Fallback {
-
+ /**
+ * Returns a DOM element that contains all single page sitemap elements.
+ */
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-page.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-page.php
index e9ebeb49..545ba8ef 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-buffer-page.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-page.php
@@ -1,4 +1,5 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+// phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
/**
* Sitemaps (per the protocol) are essentially lists of XML fragments;
* lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Page
@@ -15,7 +16,13 @@
* @since 5.3.0
*/
class Jetpack_Sitemap_Buffer_Page extends Jetpack_Sitemap_Buffer {
-
+ /**
+ * Jetpack_Sitemap_Buffer_Page constructor.
+ *
+ * @param int $item_limit The maximum size of the buffer in items.
+ * @param int $byte_limit The maximum size of the buffer in bytes.
+ * @param string $time The initial datetime of the buffer. Must be in 'YYYY-MM-DD hh:mm:ss' format.
+ */
public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) {
parent::__construct( $item_limit, $byte_limit, $time );
@@ -31,6 +38,9 @@ class Jetpack_Sitemap_Buffer_Page extends Jetpack_Sitemap_Buffer {
);
}
+ /**
+ * Returns a DOM element that contains all single page sitemap elements.
+ */
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php
index e4bf0cd6..08aed0fd 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php
@@ -1,4 +1,5 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+// phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
/**
* Sitemaps (per the protocol) are essentially lists of XML fragments;
* lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Video
@@ -15,7 +16,9 @@
* @since 5.3.0
*/
class Jetpack_Sitemap_Buffer_Video extends Jetpack_Sitemap_Buffer_Fallback {
-
+ /**
+ * Returns a DOM element that contains all video sitemap elements.
+ */
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-video.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-video.php
index 04c1a4c9..856f22f5 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-buffer-video.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-video.php
@@ -1,4 +1,5 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+// phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
/**
* Sitemaps (per the protocol) are essentially lists of XML fragments;
* lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Video
@@ -15,7 +16,13 @@
* @since 5.3.0
*/
class Jetpack_Sitemap_Buffer_Video extends Jetpack_Sitemap_Buffer {
-
+ /**
+ * Jetpack_Sitemap_Buffer_Video constructor.
+ *
+ * @param int $item_limit The maximum size of the buffer in items.
+ * @param int $byte_limit The maximum size of the buffer in bytes.
+ * @param string $time The initial datetime of the buffer. Must be in 'YYYY-MM-DD hh:mm:ss' format.
+ */
public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) {
parent::__construct( $item_limit, $byte_limit, $time );
@@ -31,6 +38,9 @@ class Jetpack_Sitemap_Buffer_Video extends Jetpack_Sitemap_Buffer {
);
}
+ /**
+ * Returns a DOM element that contains all video sitemap elements.
+ */
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer.php
index 3596486d..4a24bb12 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-buffer.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Sitemaps (per the protocol) are essentially lists of XML fragments;
* lists which are subject to size constraints. The Jetpack_Sitemap_Buffer
@@ -139,7 +139,7 @@ abstract class Jetpack_Sitemap_Buffer {
* @return bool True if the append succeeded, False if not.
*/
public function append( $array ) {
- if ( is_null( $array ) ) {
+ if ( $array === null ) {
return true;
}
@@ -270,7 +270,8 @@ abstract class Jetpack_Sitemap_Buffer {
if ( null === $parent ) {
$return_string = true;
- $parent = $root = new DOMDocument();
+ $root = new DOMDocument();
+ $parent = $root;
}
if ( is_array( $array ) ) {
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-builder.php b/plugins/jetpack/modules/sitemaps/sitemap-builder.php
index e8719650..7116f1b2 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-builder.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-builder.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Build the sitemap tree.
*
@@ -38,7 +38,9 @@ if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
* Simple class for rendering an empty sitemap with a short TTL
*/
class Jetpack_Sitemap_Buffer_Empty extends Jetpack_Sitemap_Buffer {
-
+ /**
+ * Jetpack_Sitemap_Buffer_Empty constructor.
+ */
public function __construct() {
parent::__construct( JP_SITEMAP_MAX_ITEMS, JP_SITEMAP_MAX_BYTES, '1970-01-01 00:00:00' );
@@ -54,6 +56,9 @@ class Jetpack_Sitemap_Buffer_Empty extends Jetpack_Sitemap_Buffer {
);
}
+ /**
+ * Returns a DOM element for an empty sitemap.
+ */
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
$this->root = $this->doc->createElement( 'sitemapindex' );
@@ -74,7 +79,7 @@ class Jetpack_Sitemap_Buffer_Empty extends Jetpack_Sitemap_Buffer {
*
* @since 4.8.0
*/
-class Jetpack_Sitemap_Builder {
+class Jetpack_Sitemap_Builder { // phpcs:ignore Generic.Files.OneObjectStructurePerFile.MultipleFound,Generic.Classes.OpeningBraceSameLine.ContentAfterBrace
/**
* Librarian object for storing and retrieving sitemap data.
@@ -613,7 +618,7 @@ class Jetpack_Sitemap_Builder {
JP_SITEMAP_BATCH_SIZE
);
- if ( null == $posts ) { // WPCS: loose comparison ok.
+ if ( null == $posts ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- WPCS: loose comparison ok.
$any_posts_left = false;
break;
}
@@ -700,7 +705,7 @@ class Jetpack_Sitemap_Builder {
* @param DOMDocument $doc Data tree for sitemap.
* @param string $last_modified Date of last modification.
*/
- $tree = apply_filters(
+ $tree = apply_filters( // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
'jetpack_print_sitemap',
$buffer->get_document(),
$buffer->last_modified()
@@ -763,7 +768,7 @@ class Jetpack_Sitemap_Builder {
JP_SITEMAP_BATCH_SIZE
);
- if ( null == $posts ) { // WPCS: loose comparison ok.
+ if ( null == $posts ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- WPCS: loose comparison ok.
$any_posts_left = false;
break;
}
@@ -842,7 +847,7 @@ class Jetpack_Sitemap_Builder {
JP_SITEMAP_BATCH_SIZE
);
- if ( null == $posts ) { // WPCS: loose comparison ok.
+ if ( null == $posts ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- WPCS: loose comparison ok.
$any_posts_left = false;
break;
}
@@ -950,7 +955,7 @@ class Jetpack_Sitemap_Builder {
);
// If there were no posts to get, make a note.
- if ( null == $posts ) { // WPCS: loose comparison ok.
+ if ( null == $posts ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- WPCS: loose comparison ok.
$any_sitemaps_left = false;
break;
}
@@ -1023,7 +1028,6 @@ class Jetpack_Sitemap_Builder {
);
}
-
/**
* This is served instead of a 404 when the master sitemap is requested
* but not yet generated.
@@ -1224,7 +1228,7 @@ class Jetpack_Sitemap_Builder {
}
$parent_url = get_permalink( get_post( $post->post_parent ) );
- if ( '' == $parent_url ) { // WPCS: loose comparison ok.
+ if ( '' == $parent_url ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- WPCS: loose comparison ok.
$parent_url = get_permalink( $post );
}
@@ -1308,7 +1312,7 @@ class Jetpack_Sitemap_Builder {
}
$parent_url = esc_url( get_permalink( get_post( $post->post_parent ) ) );
- if ( '' == $parent_url ) { // WPCS: loose comparison ok.
+ if ( '' == $parent_url ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- WPCS: loose comparison ok.
$parent_url = esc_url( get_permalink( $post ) );
}
@@ -1320,7 +1324,7 @@ class Jetpack_Sitemap_Builder {
/** This filter is already documented in core/wp-includes/feed.php */
$content = apply_filters( 'the_content_feed', $content, 'rss2' );
- // Include thumbnails for VideoPress videos, use blank image for others
+ // Include thumbnails for VideoPress videos, use blank image for others.
if ( 'complete' === get_post_meta( $post->ID, 'videopress_status', true ) && has_post_thumbnail( $post ) ) {
$video_thumbnail_url = get_the_post_thumbnail_url( $post );
} else {
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-constants.php b/plugins/jetpack/modules/sitemaps/sitemap-constants.php
index ce732557..706a9501 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-constants.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-constants.php
@@ -15,10 +15,10 @@
* @since 7.7.0
*/
if ( defined( 'JETPACK_DEV_DEBUG' ) && JETPACK_DEV_DEBUG ) {
- if ( ! defined( 'JP_SITEMAP_INTERVAL') ) {
+ if ( ! defined( 'JP_SITEMAP_INTERVAL' ) ) {
define( 'JP_SITEMAP_INTERVAL', 60 );
}
- if ( ! defined( 'JP_NEWS_SITEMAP_INTERVAL') ) {
+ if ( ! defined( 'JP_NEWS_SITEMAP_INTERVAL' ) ) {
define( 'JP_NEWS_SITEMAP_INTERVAL', 60 );
}
}
@@ -147,7 +147,7 @@ if ( ! defined( 'JP_VIDEO_SITEMAP_INDEX_TYPE' ) ) {
* @return string The filename.
*/
function jp_sitemap_filename( $type, $number = null ) {
- if ( is_null( $number ) ) {
+ if ( $number === null ) {
return "error-not-int-$type-$number.xml";
} elseif ( JP_MASTER_SITEMAP_TYPE === $type ) {
return 'sitemap.xml';
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-finder.php b/plugins/jetpack/modules/sitemaps/sitemap-finder.php
index f1a1d773..87d0c2bc 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-finder.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-finder.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* The functions in this class provide an API for handling
* sitemap related URIs.
@@ -32,7 +32,7 @@ class Jetpack_Sitemap_Finder {
$url = jetpack_sitemap_uri( $filename );
if ( pathinfo( $filename, PATHINFO_EXTENSION ) === 'xsl' ) {
- // strip scheme for sites where sitemap could be access via http or https
+ // Strip scheme for sites where sitemap could be access via http or https.
$url = preg_replace( '/^https?:/', '', $url );
}
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-librarian.php b/plugins/jetpack/modules/sitemaps/sitemap-librarian.php
index 018aa36b..f24b6f01 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-librarian.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-librarian.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Sitemaps are stored in the database using a custom table. This class
* provides a small API for storing and retrieving sitemap data so we can
@@ -59,7 +59,7 @@ class Jetpack_Sitemap_Librarian {
'timestamp' => $the_post->post_date,
'name' => $the_post->post_title,
'type' => $the_post->post_type,
- 'text' => base64_decode( $the_post->post_content ),
+ 'text' => base64_decode( $the_post->post_content ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode
);
}
}
@@ -89,9 +89,9 @@ class Jetpack_Sitemap_Librarian {
wp_insert_post(
array(
'post_title' => $name,
- 'post_content' => base64_encode( $contents ),
+ 'post_content' => base64_encode( $contents ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
'post_type' => $type,
- 'post_date' => date( 'Y-m-d H:i:s', strtotime( $timestamp ) ),
+ 'post_date' => gmdate( 'Y-m-d H:i:s', strtotime( $timestamp ) ),
)
);
} else {
@@ -100,9 +100,9 @@ class Jetpack_Sitemap_Librarian {
array(
'ID' => $the_post['id'],
'post_title' => $name,
- 'post_content' => base64_encode( $contents ),
+ 'post_content' => base64_encode( $contents ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
'post_type' => $type,
- 'post_date' => date( 'Y-m-d H:i:s', strtotime( $timestamp ) ),
+ 'post_date' => gmdate( 'Y-m-d H:i:s', strtotime( $timestamp ) ),
)
);
}
@@ -274,6 +274,7 @@ class Jetpack_Sitemap_Librarian {
}
$post_types_list = join( ',', $post_types );
+ // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- WPCS: db call ok; no-cache ok.
return $wpdb->get_results(
$wpdb->prepare(
"SELECT *
@@ -286,7 +287,8 @@ class Jetpack_Sitemap_Librarian {
$from_id,
$num_posts
)
- ); // WPCS: db call ok; no-cache ok.
+ );
+ // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
}
/**
@@ -391,7 +393,7 @@ class Jetpack_Sitemap_Librarian {
public function query_most_recent_posts( $num_posts ) {
global $wpdb;
- $two_days_ago = date( 'Y-m-d', strtotime( '-2 days' ) );
+ $two_days_ago = gmdate( 'Y-m-d', strtotime( '-2 days' ) );
/**
* Filter post types to be included in news sitemap.
@@ -413,6 +415,7 @@ class Jetpack_Sitemap_Librarian {
$post_types_list = join( ',', $post_types );
+ // phpcs:disable WordPress.DB.PreparedSQLPlaceholders.QuotedSimplePlaceholder,WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- WPCS: db call ok; no-cache ok.
return $wpdb->get_results(
$wpdb->prepare(
"SELECT *
@@ -425,7 +428,8 @@ class Jetpack_Sitemap_Librarian {
$two_days_ago,
$num_posts
)
- ); // WPCS: db call ok; no-cache ok.
+ );
+ // phpcs:enable WordPress.DB.PreparedSQLPlaceholders.QuotedSimplePlaceholder,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
}
}
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-logger.php b/plugins/jetpack/modules/sitemaps/sitemap-logger.php
index c6b3d77a..b46c95a8 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-logger.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-logger.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* A message logger for the Jetpack Sitemap module.
*
@@ -46,7 +46,7 @@ class Jetpack_Sitemap_Logger {
public function __construct( $message = null ) {
$this->key = wp_generate_password( 5, false );
$this->starttime = microtime( true );
- if ( ! is_null( $message ) ) {
+ if ( $message !== null ) {
$this->report( $message );
}
}
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-state.php b/plugins/jetpack/modules/sitemaps/sitemap-state.php
index 9420f85e..df2811c6 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-state.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-state.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Abstract sitemap generation state class.
*
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-stylist.php b/plugins/jetpack/modules/sitemaps/sitemap-stylist.php
index 45c1b82f..5179d187 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-stylist.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-stylist.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* The XSL used to style sitemaps is essentially a bunch of
* static strings. This class handles the construction of
@@ -69,6 +69,7 @@ class Jetpack_Sitemap_Stylist {
$header_lastmod = esc_html( ent2ncr( __( 'Last Modified', 'jetpack' ) ) );
$description = self::sanitize_with_links(
+ /* translators: %1$s: jetpack.com URL. %2$s: google.com URL. %3$s: bing.com URL. */
__(
'This is an XML Sitemap generated by <a href="%1$s" rel="noopener noreferrer" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%2$s" rel="noopener noreferrer" target="_blank">Google</a> or <a href="%3$s" rel="noopener noreferrer" target="_blank">Bing</a>.',
'jetpack'
@@ -81,6 +82,7 @@ class Jetpack_Sitemap_Stylist {
);
$more_info = self::sanitize_with_links(
+ /* translators: %1$s: sitemaps.org URL. */
__(
'You can find more information on XML sitemaps at <a href="%1$s" rel="noopener noreferrer" target="_blank">sitemaps.org</a>',
'jetpack'
@@ -91,6 +93,7 @@ class Jetpack_Sitemap_Stylist {
);
$generated_by = self::sanitize_with_links(
+ /* translators: %s: jetpack.com URL. */
__(
'Generated by <a href="%s" rel="noopener noreferrer" target="_blank">Jetpack for WordPress</a>',
'jetpack'
@@ -181,6 +184,7 @@ XSL;
$header_lastmod = esc_html( ent2ncr( __( 'Last Modified', 'jetpack' ) ) );
$description = self::sanitize_with_links(
+ /* translators: %1$s: jetpack.com URL. %2$s: google.com URL. %3$s: bing.com URL. */
__(
'This is an XML Sitemap Index generated by <a href="%1$s" rel="noopener noreferrer" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%2$s" rel="noopener noreferrer" target="_blank">Google</a> or <a href="%3$s" rel="noopener noreferrer" target="_blank">Bing</a>.',
'jetpack'
@@ -201,6 +205,7 @@ XSL;
}
$more_info = self::sanitize_with_links(
+ /* translators: %1$s: sitemaps.org URL. */
__(
'You can find more information on XML sitemaps at <a href="%1$s" rel="noopener noreferrer" target="_blank">sitemaps.org</a>',
'jetpack'
@@ -211,6 +216,7 @@ XSL;
);
$generated_by = self::sanitize_with_links(
+ /* translators: %s: jetpack.com URL. */
__(
'Generated by <a href="%s" rel="noopener noreferrer" target="_blank">Jetpack for WordPress</a>',
'jetpack'
@@ -309,6 +315,7 @@ XSL;
$header_caption = esc_html( ent2ncr( __( 'Caption', 'jetpack' ) ) );
$description = self::sanitize_with_links(
+ /* translators: %1$s: jetpack.com URL. %2$s: google.com URL. %3$s: bing.com URL. */
__(
'This is an XML Image Sitemap generated by <a href="%1$s" rel="noopener noreferrer" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%2$s" rel="noopener noreferrer" target="_blank">Google</a> or <a href="%3$s" rel="noopener noreferrer" target="_blank">Bing</a>.',
'jetpack'
@@ -321,6 +328,7 @@ XSL;
);
$more_info = self::sanitize_with_links(
+ /* translators: %1$s: sitemaps.org URL. */
__(
'You can find more information on XML sitemaps at <a href="%1$s" rel="noopener noreferrer" target="_blank">sitemaps.org</a>',
'jetpack'
@@ -331,6 +339,7 @@ XSL;
);
$generated_by = self::sanitize_with_links(
+ /* translators: %s: jetpack.com URL. */
__(
'Generated by <a href="%s" rel="noopener noreferrer" target="_blank">Jetpack for WordPress</a>',
'jetpack'
@@ -449,6 +458,7 @@ XSL;
$header_description = esc_html( ent2ncr( __( 'Description', 'jetpack' ) ) );
$description = self::sanitize_with_links(
+ /* translators: %1$s: jetpack.com URL. %2$s: google.com URL. %3$s: bing.com URL. */
__(
'This is an XML Video Sitemap generated by <a href="%1$s" rel="noopener noreferrer" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%2$s" rel="noopener noreferrer" target="_blank">Google</a> or <a href="%3$s" rel="noopener noreferrer" target="_blank">Bing</a>.',
'jetpack'
@@ -461,6 +471,7 @@ XSL;
);
$more_info = self::sanitize_with_links(
+ /* translators: %1$s: sitemaps.org URL. */
__(
'You can find more information on XML sitemaps at <a href="%1$s" rel="noopener noreferrer" target="_blank">sitemaps.org</a>',
'jetpack'
@@ -471,6 +482,7 @@ XSL;
);
$generated_by = self::sanitize_with_links(
+ /* translators: %s: jetpack.com URL. */
__(
'Generated by <a href="%s" rel="noopener noreferrer" target="_blank">Jetpack for WordPress</a>',
'jetpack'
@@ -589,6 +601,7 @@ XSL;
$header_pubdate = esc_html( ent2ncr( __( 'Publication Date', 'jetpack' ) ) );
$description = self::sanitize_with_links(
+ /* translators: %1$s: jetpack.com URL. %2$s: google.com URL. %3$s: bing.com URL. */
__(
'This is an XML News Sitemap generated by <a href="%1$s" rel="noopener noreferrer" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%2$s" rel="noopener noreferrer" target="_blank">Google</a> or <a href="%3$s" rel="noopener noreferrer" target="_blank">Bing</a>.',
'jetpack'
@@ -601,6 +614,7 @@ XSL;
);
$more_info = self::sanitize_with_links(
+ /* translators: %1$s: sitemaps.org URL. */
__(
'You can find more information on XML sitemaps at <a href="%1$s" rel="noopener noreferrer" target="_blank">sitemaps.org</a>',
'jetpack'
@@ -611,6 +625,7 @@ XSL;
);
$generated_by = self::sanitize_with_links(
+ /* translators: %s: jetpack.com URL. */
__(
'Generated by <a href="%s" rel="noopener noreferrer" target="_blank">Jetpack for WordPress</a>',
'jetpack'
diff --git a/plugins/jetpack/modules/sso.php b/plugins/jetpack/modules/sso.php
index c5f5538e..16ce1ee1 100644
--- a/plugins/jetpack/modules/sso.php
+++ b/plugins/jetpack/modules/sso.php
@@ -1,12 +1,17 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Jetpack_SSO module main class file.
+ *
+ * @package automattic/jetpack
+ */
use Automattic\Jetpack\Connection\Manager as Connection_Manager;
use Automattic\Jetpack\Roles;
use Automattic\Jetpack\Status;
use Automattic\Jetpack\Tracking;
-require_once( JETPACK__PLUGIN_DIR . 'modules/sso/class.jetpack-sso-helpers.php' );
-require_once( JETPACK__PLUGIN_DIR . 'modules/sso/class.jetpack-sso-notices.php' );
+require_once JETPACK__PLUGIN_DIR . 'modules/sso/class.jetpack-sso-helpers.php';
+require_once JETPACK__PLUGIN_DIR . 'modules/sso/class.jetpack-sso-notices.php';
/**
* Module Name: Secure Sign On
@@ -21,24 +26,32 @@ require_once( JETPACK__PLUGIN_DIR . 'modules/sso/class.jetpack-sso-notices.php'
* Feature: Security
* Additional Search Queries: sso, single sign on, login, log in, 2fa, two-factor
*/
-
class Jetpack_SSO {
- static $instance = null;
+ /**
+ * Jetpack_SSO instance.
+ *
+ * @var Jetpack_SSO
+ */
+ public static $instance = null;
+ /**
+ * Jetpack_SSO constructor.
+ */
private function __construct() {
self::$instance = $this;
- add_action( 'admin_init', array( $this, 'maybe_authorize_user_after_sso' ), 1 );
- add_action( 'admin_init', array( $this, 'register_settings' ) );
- add_action( 'login_init', array( $this, 'login_init' ) );
- add_action( 'delete_user', array( $this, 'delete_connection_for_user' ) );
- add_filter( 'jetpack_xmlrpc_methods', array( $this, 'xmlrpc_methods' ) );
- add_action( 'init', array( $this, 'maybe_logout_user' ), 5 );
- add_action( 'jetpack_modules_loaded', array( $this, 'module_configure_button' ) );
- add_action( 'login_form_logout', array( $this, 'store_wpcom_profile_cookies_on_logout' ) );
- add_action( 'jetpack_unlinked_user', array( $this, 'delete_connection_for_user') );
- add_action( 'wp_login', array( 'Jetpack_SSO', 'clear_cookies_after_login' ) );
+ add_action( 'admin_init', array( $this, 'maybe_authorize_user_after_sso' ), 1 );
+ add_action( 'admin_init', array( $this, 'register_settings' ) );
+ add_action( 'login_init', array( $this, 'login_init' ) );
+ add_action( 'delete_user', array( $this, 'delete_connection_for_user' ) );
+ add_filter( 'jetpack_xmlrpc_methods', array( $this, 'xmlrpc_methods' ) );
+ add_action( 'init', array( $this, 'maybe_logout_user' ), 5 );
+ add_action( 'jetpack_modules_loaded', array( $this, 'module_configure_button' ) );
+ add_action( 'login_form_logout', array( $this, 'store_wpcom_profile_cookies_on_logout' ) );
+ add_action( 'jetpack_unlinked_user', array( $this, 'delete_connection_for_user' ) );
+ add_action( 'jetpack_site_before_disconnected', array( static::class, 'disconnect' ) );
+ add_action( 'wp_login', array( 'Jetpack_SSO', 'clear_cookies_after_login' ) );
// Adding this action so that on login_init, the action won't be sanitized out of the $action global.
add_action( 'login_form_jetpack-sso', '__return_true' );
@@ -51,11 +64,12 @@ class Jetpack_SSO {
* @return Jetpack_SSO
**/
public static function get_instance() {
- if ( ! is_null( self::$instance ) ) {
+ if ( self::$instance !== null ) {
return self::$instance;
}
- return self::$instance = new Jetpack_SSO;
+ self::$instance = new Jetpack_SSO();
+ return self::$instance;
}
/**
@@ -72,7 +86,7 @@ class Jetpack_SSO {
public function maybe_logout_user() {
global $current_user;
- if ( 1 == $current_user->jetpack_force_logout ) {
+ if ( 1 === (int) $current_user->jetpack_force_logout ) {
delete_user_meta( $current_user->ID, 'jetpack_force_logout' );
self::delete_connection_for_user( $current_user->ID );
wp_logout();
@@ -84,7 +98,7 @@ class Jetpack_SSO {
/**
* Adds additional methods the WordPress xmlrpc API for handling SSO specific features
*
- * @param array $methods
+ * @param array $methods API methods.
* @return array
**/
public function xmlrpc_methods( $methods ) {
@@ -95,16 +109,18 @@ class Jetpack_SSO {
/**
* Marks a user's profile for disconnect from WordPress.com and forces a logout
* the next time the user visits the site.
+ *
+ * @param int $user_id User to disconnect from the site.
**/
public function xmlrpc_user_disconnect( $user_id ) {
$user_query = new WP_User_Query(
array(
- 'meta_key' => 'wpcom_user_id',
+ 'meta_key' => 'wpcom_user_id',
'meta_value' => $user_id,
)
);
- $user = $user_query->get_results();
- $user = $user[0];
+ $user = $user_query->get_results();
+ $user = $user[0];
if ( $user instanceof WP_User ) {
$user = wp_set_current_user( $user->ID );
@@ -131,14 +147,14 @@ class Jetpack_SSO {
wp_enqueue_style( 'jetpack-sso-login', plugins_url( 'modules/sso/jetpack-sso-login.css', JETPACK__PLUGIN_FILE ), array( 'login', 'genericons' ), JETPACK__VERSION );
}
- wp_enqueue_script( 'jetpack-sso-login', plugins_url( 'modules/sso/jetpack-sso-login.js', JETPACK__PLUGIN_FILE ), array( 'jquery' ), JETPACK__VERSION );
+ wp_enqueue_script( 'jetpack-sso-login', plugins_url( 'modules/sso/jetpack-sso-login.js', JETPACK__PLUGIN_FILE ), array( 'jquery' ), JETPACK__VERSION, false );
}
/**
* Adds Jetpack SSO classes to login body
*
- * @param array $classes Array of classes to add to body tag
- * @return array Array of classes to add to body tag
+ * @param array $classes Array of classes to add to body tag.
+ * @return array Array of classes to add to body tag.
*/
public function login_body_class( $classes ) {
global $action;
@@ -160,7 +176,7 @@ class Jetpack_SSO {
* The SSO module uses the method to display the default login form if we can not find a user to log in via SSO.
* But, the method could be filtered by a site admin to always show the default login form if that is preferred.
*/
- if ( empty( $_GET['jetpack-sso-show-default-form'] ) && Jetpack_SSO_Helpers::show_sso_login() ) {
+ if ( empty( $_GET['jetpack-sso-show-default-form'] ) && Jetpack_SSO_Helpers::show_sso_login() ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$classes[] = 'jetpack-sso-form-display';
}
}
@@ -168,6 +184,9 @@ class Jetpack_SSO {
return $classes;
}
+ /**
+ * Inlined admin styles for SSO.
+ */
public function print_inline_admin_css() {
?>
<style>
@@ -193,7 +212,7 @@ class Jetpack_SSO {
add_settings_section(
'jetpack_sso_settings',
- __( 'Secure Sign On' , 'jetpack' ),
+ __( 'Secure Sign On', 'jetpack' ),
'__return_false',
'jetpack-sso'
);
@@ -210,7 +229,7 @@ class Jetpack_SSO {
add_settings_field(
'jetpack_sso_require_two_step',
- '', // __( 'Require Two-Step Authentication' , 'jetpack' ),
+ '', // Output done in render $callback: __( 'Require Two-Step Authentication' , 'jetpack' ).
array( $this, 'render_require_two_step' ),
'jetpack-sso',
'jetpack_sso_settings'
@@ -227,7 +246,7 @@ class Jetpack_SSO {
add_settings_field(
'jetpack_sso_match_by_email',
- '', // __( 'Match by Email' , 'jetpack' ),
+ '', // Output done in render $callback: __( 'Match by Email' , 'jetpack' ).
array( $this, 'render_match_by_email' ),
'jetpack-sso',
'jetpack_sso_settings'
@@ -249,13 +268,15 @@ class Jetpack_SSO {
<?php checked( Jetpack_SSO_Helpers::is_two_step_required() ); ?>
<?php disabled( Jetpack_SSO_Helpers::is_require_two_step_checkbox_disabled() ); ?>
>
- <?php esc_html_e( 'Require Two-Step Authentication' , 'jetpack' ); ?>
+ <?php esc_html_e( 'Require Two-Step Authentication', 'jetpack' ); ?>
</label>
<?php
}
/**
- * Validate the require two step checkbox in Settings > General
+ * Validate the require two step checkbox in Settings > General.
+ *
+ * @param bool $input The jetpack_sso_require_two_step option setting.
*
* @since 2.7
* @return boolean
@@ -285,7 +306,9 @@ class Jetpack_SSO {
}
/**
- * Validate the match by email check in Settings > General
+ * Validate the match by email check in Settings > General.
+ *
+ * @param bool $input The jetpack_sso_match_by_email option setting.
*
* @since 2.9
* @return boolean
@@ -308,11 +331,11 @@ class Jetpack_SSO {
private function wants_to_login() {
$wants_to_login = false;
- // Cover default WordPress behavior
- $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login';
+ // Cover default WordPress behavior.
+ $action = isset( $_REQUEST['action'] ) ? filter_var( wp_unslash( $_REQUEST['action'] ) ) : 'login'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- // And now the exceptions
- $action = isset( $_GET['loggedout'] ) ? 'loggedout' : $action;
+ // And now the exceptions.
+ $action = isset( $_GET['loggedout'] ) ? 'loggedout' : $action; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( Jetpack_SSO_Helpers::display_sso_form_for_action( $action ) ) {
$wants_to_login = true;
@@ -321,7 +344,10 @@ class Jetpack_SSO {
return $wants_to_login;
}
- function login_init() {
+ /**
+ * Initialization for a SSO request.
+ */
+ public function login_init() {
global $action;
$tracking = new Tracking();
@@ -349,8 +375,8 @@ class Jetpack_SSO {
}
}
- if ( 'jetpack-sso' === $action ) {
- if ( isset( $_GET['result'], $_GET['user_id'], $_GET['sso_nonce'] ) && 'success' == $_GET['result'] ) {
+ if ( 'jetpack-sso' === $action ) {
+ if ( isset( $_GET['result'], $_GET['user_id'], $_GET['sso_nonce'] ) && 'success' === $_GET['result'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$this->handle_login();
$this->display_sso_login_form();
} else {
@@ -359,7 +385,7 @@ class Jetpack_SSO {
} else {
// Is it wiser to just use wp_redirect than do this runaround to wp_safe_redirect?
add_filter( 'allowed_redirect_hosts', array( 'Jetpack_SSO_Helpers', 'allowed_redirect_hosts' ) );
- $reauth = ! empty( $_GET['force_reauth'] );
+ $reauth = ! empty( $_GET['force_reauth'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$sso_url = $this->get_sso_url_or_die( $reauth );
$tracking->record_user_event( 'sso_login_redirect_success' );
@@ -367,9 +393,9 @@ class Jetpack_SSO {
exit;
}
}
- } else if ( Jetpack_SSO_Helpers::display_sso_form_for_action( $action ) ) {
+ } elseif ( Jetpack_SSO_Helpers::display_sso_form_for_action( $action ) ) {
- // Save cookies so we can handle redirects after SSO
+ // Save cookies so we can handle redirects after SSO.
$this->save_cookies();
/**
@@ -379,7 +405,7 @@ class Jetpack_SSO {
*/
if ( Jetpack_SSO_Helpers::bypass_login_forward_wpcom() && $this->wants_to_login() ) {
add_filter( 'allowed_redirect_hosts', array( 'Jetpack_SSO_Helpers', 'allowed_redirect_hosts' ) );
- $reauth = ! empty( $_GET['force_reauth'] );
+ $reauth = ! empty( $_GET['force_reauth'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$sso_url = $this->get_sso_url_or_die( $reauth );
$tracking->record_user_event( 'sso_login_redirect_bypass_success' );
wp_safe_redirect( $sso_url );
@@ -396,7 +422,7 @@ class Jetpack_SSO {
*/
public function display_sso_login_form() {
add_filter( 'login_body_class', array( $this, 'login_body_class' ) );
- add_action( 'login_head', array( $this, 'print_inline_admin_css' ) );
+ add_action( 'login_head', array( $this, 'print_inline_admin_css' ) );
if ( ( new Status() )->is_staging_site() ) {
add_filter( 'login_message', array( 'Jetpack_SSO_Notices', 'sso_not_allowed_in_staging' ) );
@@ -408,7 +434,7 @@ class Jetpack_SSO {
return;
}
- add_action( 'login_form', array( $this, 'login_form' ) );
+ add_action( 'login_form', array( $this, 'login_form' ) );
add_action( 'login_enqueue_scripts', array( $this, 'login_enqueue_scripts' ) );
}
@@ -424,7 +450,8 @@ class Jetpack_SSO {
setcookie(
'jetpack_sso_original_request',
- esc_url_raw( set_url_scheme( $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) ),
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sniff misses the wrapping esc_url_raw().
+ esc_url_raw( set_url_scheme( ( isset( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : '' ) . ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '' ) ) ),
time() + HOUR_IN_SECONDS,
COOKIEPATH,
COOKIE_DOMAIN,
@@ -432,13 +459,13 @@ class Jetpack_SSO {
true
);
- if ( ! empty( $_GET['redirect_to'] ) ) {
- // If we have something to redirect to
- $url = esc_url_raw( $_GET['redirect_to'] );
+ if ( ! empty( $_GET['redirect_to'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ // If we have something to redirect to.
+ $url = esc_url_raw( wp_unslash( $_GET['redirect_to'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
setcookie( 'jetpack_sso_redirect_to', $url, time() + HOUR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );
} elseif ( ! empty( $_COOKIE['jetpack_sso_redirect_to'] ) ) {
// Otherwise, if it's already set, purge it.
- setcookie( 'jetpack_sso_redirect_to', ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
+ setcookie( 'jetpack_sso_redirect_to', ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );
}
}
@@ -446,17 +473,17 @@ class Jetpack_SSO {
* Outputs the Jetpack SSO button and description as well as the toggle link
* for switching between Jetpack SSO and default login.
*/
- function login_form() {
+ public function login_form() {
$site_name = get_bloginfo( 'name' );
if ( ! $site_name ) {
$site_name = get_bloginfo( 'url' );
}
$display_name = ! empty( $_COOKIE[ 'jetpack_sso_wpcom_name_' . COOKIEHASH ] )
- ? $_COOKIE[ 'jetpack_sso_wpcom_name_' . COOKIEHASH ]
+ ? sanitize_text_field( wp_unslash( $_COOKIE[ 'jetpack_sso_wpcom_name_' . COOKIEHASH ] ) )
: false;
- $gravatar = ! empty( $_COOKIE[ 'jetpack_sso_wpcom_gravatar_' . COOKIEHASH ] )
- ? $_COOKIE[ 'jetpack_sso_wpcom_gravatar_' . COOKIEHASH ]
+ $gravatar = ! empty( $_COOKIE[ 'jetpack_sso_wpcom_gravatar_' . COOKIEHASH ] )
+ ? esc_url_raw( wp_unslash( $_COOKIE[ 'jetpack_sso_wpcom_gravatar_' . COOKIEHASH ] ) )
: false;
?>
@@ -471,16 +498,18 @@ class Jetpack_SSO {
*/
do_action( 'jetpack_sso_login_form_above_wpcom' );
- if ( $display_name && $gravatar ) : ?>
+ if ( $display_name && $gravatar ) :
+ ?>
<div id="jetpack-sso-wrap__user">
<img width="72" height="72" src="<?php echo esc_html( $gravatar ); ?>" />
<h2>
<?php
- echo wp_kses(
- sprintf( __( 'Log in as <span>%s</span>', 'jetpack' ), esc_html( $display_name ) ),
- array( 'span' => true )
- );
+ echo wp_kses(
+ /* translators: %s a user display name. */
+ sprintf( __( 'Log in as <span>%s</span>', 'jetpack' ), esc_html( $display_name ) ),
+ array( 'span' => true )
+ );
?>
</h2>
</div>
@@ -489,7 +518,7 @@ class Jetpack_SSO {
<div id="jetpack-sso-wrap__action">
- <?php echo $this->build_sso_button( array(), 'is_primary' ); ?>
+ <?php echo $this->build_sso_button( array(), 'is_primary' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaping done in build_sso_button() ?>
<?php if ( $display_name && $gravatar ) : ?>
<a rel="nofollow" class="jetpack-sso-wrap__reauth" href="<?php echo esc_url( $this->build_sso_button_url( array( 'force_reauth' => '1' ) ) ); ?>">
@@ -531,20 +560,21 @@ class Jetpack_SSO {
*/
do_action( 'jetpack_sso_login_form_below_wpcom' );
- if ( ! Jetpack_SSO_Helpers::should_hide_login_form() ) : ?>
+ if ( ! Jetpack_SSO_Helpers::should_hide_login_form() ) :
+ ?>
<div class="jetpack-sso-or">
<span><?php esc_html_e( 'Or', 'jetpack' ); ?></span>
</div>
<a href="<?php echo esc_url( add_query_arg( 'jetpack-sso-show-default-form', '1' ) ); ?>" class="jetpack-sso-toggle wpcom">
<?php
- esc_html_e( 'Log in with username and password', 'jetpack' )
+ esc_html_e( 'Log in with username and password', 'jetpack' )
?>
</a>
<a href="<?php echo esc_url( add_query_arg( 'jetpack-sso-show-default-form', '0' ) ); ?>" class="jetpack-sso-toggle default">
<?php
- esc_html_e( 'Log in with WordPress.com', 'jetpack' )
+ esc_html_e( 'Log in with WordPress.com', 'jetpack' )
?>
</a>
<?php endif; ?>
@@ -556,7 +586,7 @@ class Jetpack_SSO {
* Clear the cookies that store the profile information for the last
* WPCOM user to connect.
*/
- static function clear_wpcom_profile_cookies() {
+ public static function clear_wpcom_profile_cookies() {
if ( isset( $_COOKIE[ 'jetpack_sso_wpcom_name_' . COOKIEHASH ] ) ) {
setcookie(
'jetpack_sso_wpcom_name_' . COOKIEHASH,
@@ -564,7 +594,8 @@ class Jetpack_SSO {
time() - YEAR_IN_SECONDS,
COOKIEPATH,
COOKIE_DOMAIN,
- is_ssl()
+ is_ssl(),
+ true
);
}
@@ -575,7 +606,8 @@ class Jetpack_SSO {
time() - YEAR_IN_SECONDS,
COOKIEPATH,
COOKIE_DOMAIN,
- is_ssl()
+ is_ssl(),
+ true
);
}
}
@@ -585,67 +617,92 @@ class Jetpack_SSO {
*
* @since 4.8.0
*/
- static function clear_cookies_after_login() {
+ public static function clear_cookies_after_login() {
self::clear_wpcom_profile_cookies();
- if ( isset( $_COOKIE[ 'jetpack_sso_nonce' ] ) ) {
+ if ( isset( $_COOKIE['jetpack_sso_nonce'] ) ) {
setcookie(
'jetpack_sso_nonce',
' ',
time() - YEAR_IN_SECONDS,
COOKIEPATH,
COOKIE_DOMAIN,
- is_ssl()
+ is_ssl(),
+ true
);
}
- if ( isset( $_COOKIE[ 'jetpack_sso_original_request' ] ) ) {
+ if ( isset( $_COOKIE['jetpack_sso_original_request'] ) ) {
setcookie(
'jetpack_sso_original_request',
' ',
time() - YEAR_IN_SECONDS,
COOKIEPATH,
COOKIE_DOMAIN,
- is_ssl()
+ is_ssl(),
+ true
);
}
- if ( isset( $_COOKIE[ 'jetpack_sso_redirect_to' ] ) ) {
+ if ( isset( $_COOKIE['jetpack_sso_redirect_to'] ) ) {
setcookie(
'jetpack_sso_redirect_to',
' ',
time() - YEAR_IN_SECONDS,
COOKIEPATH,
COOKIE_DOMAIN,
- is_ssl()
+ is_ssl(),
+ true
);
}
}
- static function delete_connection_for_user( $user_id ) {
- if ( ! $wpcom_user_id = get_user_meta( $user_id, 'wpcom_user_id', true ) ) {
+ /**
+ * Clean up after Jetpack gets disconnected.
+ *
+ * @since 10.7
+ */
+ public static function disconnect() {
+ if ( Jetpack::connection()->is_user_connected() ) {
+ static::delete_connection_for_user( get_current_user_id() );
+ }
+ }
+
+ /**
+ * Remove an SSO connection for a user.
+ *
+ * @param int $user_id The local user id.
+ */
+ public static function delete_connection_for_user( $user_id ) {
+ $wpcom_user_id = get_user_meta( $user_id, 'wpcom_user_id', true );
+ if ( ! $wpcom_user_id ) {
return;
}
- $xml = new Jetpack_IXR_Client( array(
- 'wpcom_user_id' => $user_id,
- ) );
+ $xml = new Jetpack_IXR_Client(
+ array(
+ 'wpcom_user_id' => $user_id,
+ )
+ );
$xml->query( 'jetpack.sso.removeUser', $wpcom_user_id );
if ( $xml->isError() ) {
return false;
}
- // Clean up local data stored for SSO
+ // Clean up local data stored for SSO.
delete_user_meta( $user_id, 'wpcom_user_id' );
- delete_user_meta( $user_id, 'wpcom_user_data' );
+ delete_user_meta( $user_id, 'wpcom_user_data' );
self::clear_wpcom_profile_cookies();
return $xml->getResponse();
}
- static function request_initial_nonce() {
- $nonce = ! empty( $_COOKIE[ 'jetpack_sso_nonce' ] )
- ? $_COOKIE[ 'jetpack_sso_nonce' ]
+ /**
+ * Retrieves nonce used for SSO form.
+ */
+ public static function request_initial_nonce() {
+ $nonce = ! empty( $_COOKIE['jetpack_sso_nonce'] )
+ ? sanitize_key( wp_unslash( $_COOKIE['jetpack_sso_nonce'] ) )
: false;
if ( ! $nonce ) {
@@ -656,7 +713,7 @@ class Jetpack_SSO {
return new WP_Error( $xml->getErrorCode(), $xml->getErrorMessage() );
}
- $nonce = $xml->getResponse();
+ $nonce = sanitize_key( $xml->getResponse() );
setcookie(
'jetpack_sso_nonce',
@@ -664,19 +721,20 @@ class Jetpack_SSO {
time() + ( 10 * MINUTE_IN_SECONDS ),
COOKIEPATH,
COOKIE_DOMAIN,
- is_ssl()
+ is_ssl(),
+ true
);
}
- return sanitize_key( $nonce );
+ return $nonce;
}
/**
* The function that actually handles the login!
*/
- function handle_login() {
- $wpcom_nonce = sanitize_key( $_GET['sso_nonce'] );
- $wpcom_user_id = (int) $_GET['user_id'];
+ public function handle_login() {
+ $wpcom_nonce = isset( $_GET['sso_nonce'] ) ? sanitize_key( $_GET['sso_nonce'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $wpcom_user_id = isset( $_GET['user_id'] ) ? (int) $_GET['user_id'] : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.sso.validateResult', $wpcom_nonce, $wpcom_user_id );
@@ -689,7 +747,7 @@ class Jetpack_SSO {
}
$user_data = (object) $user_data;
- $user = null;
+ $user = null;
/**
* Fires before Jetpack's SSO modifies the log in form.
@@ -707,9 +765,12 @@ class Jetpack_SSO {
if ( Jetpack_SSO_Helpers::is_two_step_required() && 0 === (int) $user_data->two_step_enabled ) {
$this->user_data = $user_data;
- $tracking->record_user_event( 'sso_login_failed', array(
- 'error_message' => 'error_msg_enable_two_step'
- ) );
+ $tracking->record_user_event(
+ 'sso_login_failed',
+ array(
+ 'error_message' => 'error_msg_enable_two_step',
+ )
+ );
$error = new WP_Error( 'two_step_required', __( 'You must have Two-Step Authentication enabled on your WordPress.com account.', 'jetpack' ) );
@@ -722,12 +783,19 @@ class Jetpack_SSO {
$user_found_with = '';
if ( empty( $user ) && isset( $user_data->external_user_id ) ) {
$user_found_with = 'external_user_id';
- $user = get_user_by( 'id', (int) $user_data->external_user_id );
+ $user = get_user_by( 'id', (int) $user_data->external_user_id );
if ( $user ) {
$expected_id = get_user_meta( $user->ID, 'wpcom_user_id', true );
- if ( $expected_id && $expected_id != $user_data->ID ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
+ if ( $expected_id && $expected_id != $user_data->ID ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, Universal.Operators.StrictComparisons.LooseNotEqual
$error = new WP_Error( 'expected_wpcom_user', __( 'Something got a little mixed up and an unexpected WordPress.com user logged in.', 'jetpack' ) );
+ $tracking->record_user_event(
+ 'sso_login_failed',
+ array(
+ 'error_message' => 'error_unexpected_wpcom_user',
+ )
+ );
+
/** This filter is documented in core/src/wp-includes/pluggable.php */
do_action( 'wp_login_failed', $user_data->login, $error );
add_filter( 'login_message', array( 'Jetpack_SSO_Notices', 'error_invalid_response_data' ) ); // @todo Need to have a better notice. This is only for the sake of testing the validation.
@@ -740,15 +808,15 @@ class Jetpack_SSO {
// If we don't have one by wpcom_user_id, try by the email?
if ( empty( $user ) && Jetpack_SSO_Helpers::match_by_email() ) {
$user_found_with = 'match_by_email';
- $user = get_user_by( 'email', $user_data->email );
+ $user = get_user_by( 'email', $user_data->email );
if ( $user ) {
update_user_meta( $user->ID, 'wpcom_user_id', $user_data->ID );
}
}
// If we've still got nothing, create the user.
- $new_user_override_role = false;
- if ( empty( $user ) && ( get_option( 'users_can_register' ) || ( $new_user_override_role = Jetpack_SSO_Helpers::new_user_override( $user_data ) ) ) ) {
+ $new_user_override_role = Jetpack_SSO_Helpers::new_user_override( $user_data );
+ if ( empty( $user ) && ( get_option( 'users_can_register' ) || $new_user_override_role ) ) {
/**
* If not matching by email we still need to verify the email does not exist
* or this blows up
@@ -765,9 +833,12 @@ class Jetpack_SSO {
$user = Jetpack_SSO_Helpers::generate_user( $user_data );
if ( ! $user ) {
- $tracking->record_user_event( 'sso_login_failed', array(
- 'error_message' => 'could_not_create_username'
- ) );
+ $tracking->record_user_event(
+ 'sso_login_failed',
+ array(
+ 'error_message' => 'could_not_create_username',
+ )
+ );
add_filter( 'login_message', array( 'Jetpack_SSO_Notices', 'error_unable_to_create_user' ) );
return;
}
@@ -776,9 +847,12 @@ class Jetpack_SSO {
? 'user_created_new_user_override'
: 'user_created_users_can_register';
} else {
- $tracking->record_user_event( 'sso_login_failed', array(
- 'error_message' => 'error_msg_email_already_exists'
- ) );
+ $tracking->record_user_event(
+ 'sso_login_failed',
+ array(
+ 'error_message' => 'error_msg_email_already_exists',
+ )
+ );
$this->user_data = $user_data;
add_action( 'login_message', array( 'Jetpack_SSO_Notices', 'error_msg_email_already_exists' ) );
@@ -799,10 +873,10 @@ class Jetpack_SSO {
do_action( 'jetpack_sso_handle_login', $user, $user_data );
if ( $user ) {
- // Cache the user's details, so we can present it back to them on their user screen
+ // Cache the user's details, so we can present it back to them on their user screen.
update_user_meta( $user->ID, 'wpcom_user_data', $user_data );
- add_filter( 'auth_cookie_expiration', array( 'Jetpack_SSO_Helpers', 'extend_auth_cookie_expiration_for_sso' ) );
+ add_filter( 'auth_cookie_expiration', array( 'Jetpack_SSO_Helpers', 'extend_auth_cookie_expiration_for_sso' ) );
wp_set_auth_cookie( $user->ID, true );
remove_filter( 'auth_cookie_expiration', array( 'Jetpack_SSO_Helpers', 'extend_auth_cookie_expiration_for_sso' ) );
@@ -811,13 +885,14 @@ class Jetpack_SSO {
wp_set_current_user( $user->ID );
- $_request_redirect_to = isset( $_REQUEST['redirect_to'] ) ? esc_url_raw( $_REQUEST['redirect_to'] ) : '';
- $redirect_to = user_can( $user, 'edit_posts' ) ? admin_url() : self::profile_page_url();
+ $_request_redirect_to = isset( $_REQUEST['redirect_to'] ) ? esc_url_raw( wp_unslash( $_REQUEST['redirect_to'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $redirect_to = user_can( $user, 'edit_posts' ) ? admin_url() : self::profile_page_url();
- // If we have a saved redirect to request in a cookie
+ // If we have a saved redirect to request in a cookie.
if ( ! empty( $_COOKIE['jetpack_sso_redirect_to'] ) ) {
- // Set that as the requested redirect to
- $redirect_to = $_request_redirect_to = esc_url_raw( $_COOKIE['jetpack_sso_redirect_to'] );
+ // Set that as the requested redirect to.
+ $redirect_to = esc_url_raw( wp_unslash( $_COOKIE['jetpack_sso_redirect_to'] ) );
+ $_request_redirect_to = $redirect_to;
}
$json_api_auth_environment = Jetpack_SSO_Helpers::get_json_api_auth_environment();
@@ -825,18 +900,21 @@ class Jetpack_SSO {
$is_json_api_auth = ! empty( $json_api_auth_environment );
$is_user_connected = ( new Connection_Manager( 'jetpack' ) )->is_user_connected( $user->ID );
$roles = new Roles();
- $tracking->record_user_event( 'sso_user_logged_in', array(
- 'user_found_with' => $user_found_with,
- 'user_connected' => (bool) $is_user_connected,
- 'user_role' => $roles->translate_current_user_to_role(),
- 'is_json_api_auth' => (bool) $is_json_api_auth,
- ) );
+ $tracking->record_user_event(
+ 'sso_user_logged_in',
+ array(
+ 'user_found_with' => $user_found_with,
+ 'user_connected' => (bool) $is_user_connected,
+ 'user_role' => $roles->translate_current_user_to_role(),
+ 'is_json_api_auth' => (bool) $is_json_api_auth,
+ )
+ );
if ( $is_json_api_auth ) {
Jetpack::init()->verify_json_api_authorization_request( $json_api_auth_environment );
Jetpack::init()->store_json_api_authorization_token( $user->user_login, $user );
- } else if ( ! $is_user_connected ) {
+ } elseif ( ! $is_user_connected ) {
wp_safe_redirect(
add_query_arg(
array(
@@ -861,9 +939,12 @@ class Jetpack_SSO {
add_filter( 'jetpack_sso_default_to_sso_login', '__return_false' );
- $tracking->record_user_event( 'sso_login_failed', array(
- 'error_message' => 'cant_find_user'
- ) );
+ $tracking->record_user_event(
+ 'sso_login_failed',
+ array(
+ 'error_message' => 'cant_find_user',
+ )
+ );
$this->user_data = $user_data;
@@ -874,7 +955,10 @@ class Jetpack_SSO {
add_filter( 'login_message', array( 'Jetpack_SSO_Notices', 'cant_find_user' ) );
}
- static function profile_page_url() {
+ /**
+ * Retreive the admin profile page URL.
+ */
+ public static function profile_page_url() {
return admin_url( 'profile.php' );
}
@@ -882,11 +966,11 @@ class Jetpack_SSO {
* Builds the "Login to WordPress.com" button that is displayed on the login page as well as user profile page.
*
* @param array $args An array of arguments to add to the SSO URL.
- * @param boolean $is_primary Should the button have the `button-primary` class?
+ * @param boolean $is_primary If the button have the `button-primary` class.
* @return string Returns the HTML markup for the button.
*/
- function build_sso_button( $args = array(), $is_primary = false ) {
- $url = $this->build_sso_button_url( $args );
+ public function build_sso_button( $args = array(), $is_primary = false ) {
+ $url = $this->build_sso_button_url( $args );
$classes = $is_primary
? 'jetpack-sso button button-primary'
: 'jetpack-sso button';
@@ -903,18 +987,18 @@ class Jetpack_SSO {
/**
* Builds a URL with `jetpack-sso` action and option args which is used to setup SSO.
*
- * @param array $args An array of arguments to add to the SSO URL.
+ * @param array $args An array of arguments to add to the SSO URL.
* @return string The URL used for SSO.
*/
- function build_sso_button_url( $args = array() ) {
+ public function build_sso_button_url( $args = array() ) {
$defaults = array(
- 'action' => 'jetpack-sso',
+ 'action' => 'jetpack-sso',
);
$args = wp_parse_args( $args, $defaults );
- if ( ! empty( $_GET['redirect_to'] ) ) {
- $args['redirect_to'] = urlencode( esc_url_raw( $_GET['redirect_to'] ) );
+ if ( ! empty( $_GET['redirect_to'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $args['redirect_to'] = rawurlencode( esc_url_raw( wp_unslash( $_GET['redirect_to'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
return add_query_arg( $args, wp_login_url() );
@@ -923,11 +1007,11 @@ class Jetpack_SSO {
/**
* Retrieves a WordPress.com SSO URL with appropriate query parameters or dies.
*
- * @param boolean $reauth Should the user be forced to reauthenticate on WordPress.com?
- * @param array $args Optional query parameters.
+ * @param boolean $reauth If the user be forced to reauthenticate on WordPress.com.
+ * @param array $args Optional query parameters.
* @return string The WordPress.com SSO URL.
*/
- function get_sso_url_or_die( $reauth = false, $args = array() ) {
+ public function get_sso_url_or_die( $reauth = false, $args = array() ) {
$custom_login_url = Jetpack_SSO_Helpers::get_custom_login_url();
if ( $custom_login_url ) {
$args['login_url'] = rawurlencode( $custom_login_url );
@@ -945,11 +1029,14 @@ class Jetpack_SSO {
$error_message = sanitize_text_field(
sprintf( '%s: %s', $sso_redirect->get_error_code(), $sso_redirect->get_error_message() )
);
- $tracking = new Tracking();
- $tracking->record_user_event( 'sso_login_redirect_failed', array(
- 'error_message' => $error_message
- ) );
- wp_die( $error_message );
+ $tracking = new Tracking();
+ $tracking->record_user_event(
+ 'sso_login_redirect_failed',
+ array(
+ 'error_message' => $error_message,
+ )
+ );
+ wp_die( esc_html( $error_message ) );
}
return $sso_redirect;
@@ -989,7 +1076,12 @@ class Jetpack_SSO {
*/
public function build_reauth_and_sso_url( $args = array() ) {
$sso_nonce = ! empty( $args['sso_nonce'] ) ? $args['sso_nonce'] : self::request_initial_nonce();
- $redirect = $this->build_sso_url( array( 'force_auth' => '1', 'sso_nonce' => $sso_nonce ) );
+ $redirect = $this->build_sso_url(
+ array(
+ 'force_auth' => '1',
+ 'sso_nonce' => $sso_nonce,
+ )
+ );
if ( is_wp_error( $redirect ) ) {
return $redirect;
@@ -1000,7 +1092,7 @@ class Jetpack_SSO {
'site_id' => Jetpack_Options::get_option( 'id' ),
'sso_nonce' => $sso_nonce,
'reauth' => '1',
- 'redirect_to' => urlencode( $redirect ),
+ 'redirect_to' => rawurlencode( $redirect ),
'calypso_auth' => '1',
);
@@ -1018,15 +1110,17 @@ class Jetpack_SSO {
*
* @since 2.6.0
*
- * @param int $wpcom_user_id User ID from WordPress.com
+ * @param int $wpcom_user_id User ID from WordPress.com.
* @return object Local user object if found, null if not.
*/
- static function get_user_by_wpcom_id( $wpcom_user_id ) {
- $user_query = new WP_User_Query( array(
- 'meta_key' => 'wpcom_user_id',
- 'meta_value' => (int) $wpcom_user_id,
- 'number' => 1,
- ) );
+ public static function get_user_by_wpcom_id( $wpcom_user_id ) {
+ $user_query = new WP_User_Query(
+ array(
+ 'meta_key' => 'wpcom_user_id',
+ 'meta_value' => (int) $wpcom_user_id,
+ 'number' => 1,
+ )
+ );
$users = $user_query->get_results();
return $users ? array_shift( $users ) : null;
@@ -1039,13 +1133,13 @@ class Jetpack_SSO {
* We redirect here instead of in handle_login() because Jetpack::init()->build_connect_url
* calls menu_page_url() which doesn't work properly until admin menus are registered.
*/
- function maybe_authorize_user_after_sso() {
- if ( empty( $_GET['jetpack-sso-auth-redirect'] ) ) {
+ public function maybe_authorize_user_after_sso() {
+ if ( empty( $_GET['jetpack-sso-auth-redirect'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return;
}
- $redirect_to = ! empty( $_GET['redirect_to'] ) ? esc_url_raw( $_GET['redirect_to'] ) : admin_url();
- $request_redirect_to = ! empty( $_GET['request_redirect_to'] ) ? esc_url_raw( $_GET['request_redirect_to'] ) : $redirect_to;
+ $redirect_to = ! empty( $_GET['redirect_to'] ) ? esc_url_raw( wp_unslash( $_GET['redirect_to'] ) ) : admin_url(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $request_redirect_to = ! empty( $_GET['request_redirect_to'] ) ? esc_url_raw( wp_unslash( $_GET['request_redirect_to'] ) ) : $redirect_to; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
/** This filter is documented in core/src/wp-login.php */
$redirect_after_auth = apply_filters( 'login_redirect', $redirect_to, $request_redirect_to, wp_get_current_user() );
@@ -1075,7 +1169,7 @@ class Jetpack_SSO {
* Cache user's display name and Gravatar so it can be displayed on the login screen. These cookies are
* stored when the user logs out, and then deleted when the user logs in.
*/
- function store_wpcom_profile_cookies_on_logout() {
+ public function store_wpcom_profile_cookies_on_logout() {
if ( ! ( new Connection_Manager( 'jetpack' ) )->is_user_connected( get_current_user_id() ) ) {
return;
}
@@ -1091,19 +1185,24 @@ class Jetpack_SSO {
time() + WEEK_IN_SECONDS,
COOKIEPATH,
COOKIE_DOMAIN,
- is_ssl()
+ is_ssl(),
+ true
);
setcookie(
'jetpack_sso_wpcom_gravatar_' . COOKIEHASH,
get_avatar_url(
$user_data->email,
- array( 'size' => 144, 'default' => 'mystery' )
+ array(
+ 'size' => 144,
+ 'default' => 'mystery',
+ )
),
time() + WEEK_IN_SECONDS,
COOKIEPATH,
COOKIE_DOMAIN,
- is_ssl()
+ is_ssl(),
+ true
);
}
@@ -1111,7 +1210,7 @@ class Jetpack_SSO {
* Determines if a local user is connected to WordPress.com
*
* @since 2.8
- * @param integer $user_id - Local user id
+ * @param integer $user_id - Local user id.
* @return boolean
**/
public function is_user_connected( $user_id ) {
@@ -1122,7 +1221,7 @@ class Jetpack_SSO {
* Retrieves a user's WordPress.com data
*
* @since 2.8
- * @param integer $user_id - Local user id
+ * @param integer $user_id - Local user id.
* @return mixed null or stdClass
**/
public function get_user_data( $user_id ) {
diff --git a/plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php b/plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php
index 921c202b..66a1f118 100644
--- a/plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php
+++ b/plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php
@@ -1,327 +1,348 @@
-<?php
-
-if ( ! class_exists( 'Jetpack_SSO_Helpers' ) ) :
-
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* A collection of helper functions used in the SSO module.
*
- * @since 4.1.0
+ * @package automattic/jetpack
*/
-class Jetpack_SSO_Helpers {
+
+if ( ! class_exists( 'Jetpack_SSO_Helpers' ) ) :
+
/**
- * Determine if the login form should be hidden or not
+ * A collection of helper functions used in the SSO module.
*
- * @return bool
- **/
- static function should_hide_login_form() {
+ * @since 4.1.0
+ */
+ class Jetpack_SSO_Helpers {
/**
- * Remove the default log in form, only leave the WordPress.com log in button.
+ * Determine if the login form should be hidden or not
*
- * @module sso
+ * @return bool
+ **/
+ public static function should_hide_login_form() {
+ /**
+ * Remove the default log in form, only leave the WordPress.com log in button.
+ *
+ * @module sso
+ *
+ * @since 3.1.0
+ *
+ * @param bool get_option( 'jetpack_sso_remove_login_form', false ) Should the default log in form be removed. Default to false.
+ */
+ return (bool) apply_filters( 'jetpack_remove_login_form', get_option( 'jetpack_sso_remove_login_form', false ) );
+ }
+
+ /**
+ * Returns a boolean value for whether logging in by matching the WordPress.com user email to a
+ * Jetpack site user's email is allowed.
*
- * @since 3.1.0
+ * @return bool
+ */
+ public static function match_by_email() {
+ $match_by_email = ( 1 === (int) get_option( 'jetpack_sso_match_by_email', true ) ) ? true : false;
+ $match_by_email = defined( 'WPCC_MATCH_BY_EMAIL' ) ? WPCC_MATCH_BY_EMAIL : $match_by_email;
+
+ /**
+ * Link the local account to an account on WordPress.com using the same email address.
+ *
+ * @module sso
+ *
+ * @since 2.6.0
+ *
+ * @param bool $match_by_email Should we link the local account to an account on WordPress.com using the same email address. Default to false.
+ */
+ return (bool) apply_filters( 'jetpack_sso_match_by_email', $match_by_email );
+ }
+
+ /**
+ * Returns a boolean for whether users are allowed to register on the Jetpack site with SSO,
+ * even though the site disallows normal registrations.
*
- * @param bool get_option( 'jetpack_sso_remove_login_form', false ) Should the default log in form be removed. Default to false.
+ * @param object|null $user_data WordPress.com user information.
+ * @return bool
*/
- return (bool) apply_filters( 'jetpack_remove_login_form', get_option( 'jetpack_sso_remove_login_form', false ) );
- }
+ public static function new_user_override( $user_data = null ) {
+ $new_user_override = defined( 'WPCC_NEW_USER_OVERRIDE' ) ? WPCC_NEW_USER_OVERRIDE : false;
+
+ /**
+ * Allow users to register on your site with a WordPress.com account, even though you disallow normal registrations.
+ * If you return a string that corresponds to a user role, the user will be given that role.
+ *
+ * @module sso
+ *
+ * @since 2.6.0
+ * @since 4.6 $user_data object is now passed to the jetpack_sso_new_user_override filter
+ *
+ * @param bool $new_user_override Allow users to register on your site with a WordPress.com account. Default to false.
+ * @param object|null $user_data An object containing the user data returned from WordPress.com.
+ */
+ $role = apply_filters( 'jetpack_sso_new_user_override', $new_user_override, $user_data );
+
+ if ( $role ) {
+ if ( is_string( $role ) && get_role( $role ) ) {
+ return $role;
+ } else {
+ return get_option( 'default_role' );
+ }
+ }
- /**
- * Returns a boolean value for whether logging in by matching the WordPress.com user email to a
- * Jetpack site user's email is allowed.
- *
- * @return bool
- */
- static function match_by_email() {
- $match_by_email = ( 1 == get_option( 'jetpack_sso_match_by_email', true ) ) ? true: false;
- $match_by_email = defined( 'WPCC_MATCH_BY_EMAIL' ) ? WPCC_MATCH_BY_EMAIL : $match_by_email;
+ return false;
+ }
/**
- * Link the local account to an account on WordPress.com using the same email address.
+ * Returns a boolean value for whether two-step authentication is required for SSO.
*
- * @module sso
- *
- * @since 2.6.0
+ * @since 4.1.0
*
- * @param bool $match_by_email Should we link the local account to an account on WordPress.com using the same email address. Default to false.
+ * @return bool
*/
- return (bool) apply_filters( 'jetpack_sso_match_by_email', $match_by_email );
- }
-
- /**
- * Returns a boolean for whether users are allowed to register on the Jetpack site with SSO,
- * even though the site disallows normal registrations.
- *
- * @return bool
- */
- static function new_user_override( $user_data = null ) {
- $new_user_override = defined( 'WPCC_NEW_USER_OVERRIDE' ) ? WPCC_NEW_USER_OVERRIDE : false;
+ public static function is_two_step_required() {
+ /**
+ * Is it required to have 2-step authentication enabled on WordPress.com to use SSO?
+ *
+ * @module sso
+ *
+ * @since 2.8.0
+ *
+ * @param bool get_option( 'jetpack_sso_require_two_step' ) Does SSO require 2-step authentication?
+ */
+ return (bool) apply_filters( 'jetpack_sso_require_two_step', get_option( 'jetpack_sso_require_two_step', false ) );
+ }
/**
- * Allow users to register on your site with a WordPress.com account, even though you disallow normal registrations.
- * If you return a string that corresponds to a user role, the user will be given that role.
+ * Returns a boolean for whether a user that is attempting to log in will be automatically
+ * redirected to WordPress.com to begin the SSO flow.
*
- * @module sso
+ * @return bool
+ */
+ public static function bypass_login_forward_wpcom() {
+ /**
+ * Redirect the site's log in form to WordPress.com's log in form.
+ *
+ * @module sso
+ *
+ * @since 3.1.0
+ *
+ * @param bool false Should the site's log in form be automatically forwarded to WordPress.com's log in form.
+ */
+ return (bool) apply_filters( 'jetpack_sso_bypass_login_forward_wpcom', false );
+ }
+
+ /**
+ * Returns a boolean for whether the SSO login form should be displayed as the default
+ * when both the default and SSO login form allowed.
*
- * @since 2.6.0
- * @since 4.6 $user_data object is now passed to the jetpack_sso_new_user_override filter
+ * @since 4.1.0
*
- * @param bool $new_user_override Allow users to register on your site with a WordPress.com account. Default to false.
- * @param object|null $user_data An object containing the user data returned from WordPress.com.
+ * @return bool
*/
- $role = apply_filters( 'jetpack_sso_new_user_override', $new_user_override, $user_data );
-
- if ( $role ) {
- if ( is_string( $role ) && get_role( $role ) ) {
- return $role;
- } else {
- return get_option( 'default_role' );
+ public static function show_sso_login() {
+ if ( self::should_hide_login_form() ) {
+ return true;
}
- }
- return false;
- }
+ /**
+ * Display the SSO login form as the default when both the default and SSO login forms are enabled.
+ *
+ * @module sso
+ *
+ * @since 4.1.0
+ *
+ * @param bool true Should the SSO login form be displayed by default when the default login form is also enabled?
+ */
+ return (bool) apply_filters( 'jetpack_sso_default_to_sso_login', true );
+ }
- /**
- * Returns a boolean value for whether two-step authentication is required for SSO.
- *
- * @since 4.1.0
- *
- * @return bool
- */
- static function is_two_step_required() {
/**
- * Is it required to have 2-step authentication enabled on WordPress.com to use SSO?
- *
- * @module sso
+ * Returns a boolean for whether the two step required checkbox, displayed on the Jetpack admin page, should be disabled.
*
- * @since 2.8.0
+ * @since 4.1.0
*
- * @param bool get_option( 'jetpack_sso_require_two_step' ) Does SSO require 2-step authentication?
+ * @return bool
*/
- return (bool) apply_filters( 'jetpack_sso_require_two_step', get_option( 'jetpack_sso_require_two_step', false ) );
- }
+ public static function is_require_two_step_checkbox_disabled() {
+ return (bool) has_filter( 'jetpack_sso_require_two_step' );
+ }
- /**
- * Returns a boolean for whether a user that is attempting to log in will be automatically
- * redirected to WordPress.com to begin the SSO flow.
- *
- * @return bool
- */
- static function bypass_login_forward_wpcom() {
/**
- * Redirect the site's log in form to WordPress.com's log in form.
+ * Returns a boolean for whether the match by email checkbox, displayed on the Jetpack admin page, should be disabled.
*
- * @module sso
- *
- * @since 3.1.0
+ * @since 4.1.0
*
- * @param bool false Should the site's log in form be automatically forwarded to WordPress.com's log in form.
+ * @return bool
*/
- return (bool) apply_filters( 'jetpack_sso_bypass_login_forward_wpcom', false );
- }
-
- /**
- * Returns a boolean for whether the SSO login form should be displayed as the default
- * when both the default and SSO login form allowed.
- *
- * @since 4.1.0
- *
- * @return bool
- */
- static function show_sso_login() {
- if ( self::should_hide_login_form() ) {
- return true;
+ public static function is_match_by_email_checkbox_disabled() {
+ return defined( 'WPCC_MATCH_BY_EMAIL' ) || has_filter( 'jetpack_sso_match_by_email' );
}
/**
- * Display the SSO login form as the default when both the default and SSO login forms are enabled.
+ * Returns an array of hosts that SSO will redirect to.
*
- * @module sso
+ * Instead of accessing JETPACK__API_BASE within the method directly, we set it as the
+ * default for $api_base due to restrictions with testing constants in our tests.
*
- * @since 4.1.0
+ * @since 4.3.0
+ * @since 4.6.0 Added public-api.wordpress.com as an allowed redirect
*
- * @param bool true Should the SSO login form be displayed by default when the default login form is also enabled?
+ * @param array $hosts Allowed redirect hosts.
+ * @param string $api_base Base API URL.
+ *
+ * @return array
*/
- return (bool) apply_filters( 'jetpack_sso_default_to_sso_login', true );
- }
-
- /**
- * Returns a boolean for whether the two step required checkbox, displayed on the Jetpack admin page, should be disabled.
- *
- * @since 4.1.0
- *
- * @return bool
- */
- static function is_require_two_step_checkbox_disabled() {
- return (bool) has_filter( 'jetpack_sso_require_two_step' );
- }
-
- /**
- * Returns a boolean for whether the match by email checkbox, displayed on the Jetpack admin page, should be disabled.
- *
- * @since 4.1.0
- *
- * @return bool
- */
- static function is_match_by_email_checkbox_disabled() {
- return defined( 'WPCC_MATCH_BY_EMAIL' ) || has_filter( 'jetpack_sso_match_by_email' );
- }
-
- /**
- * Returns an array of hosts that SSO will redirect to.
- *
- * Instead of accessing JETPACK__API_BASE within the method directly, we set it as the
- * default for $api_base due to restrictions with testing constants in our tests.
- *
- * @since 4.3.0
- * @since 4.6.0 Added public-api.wordpress.com as an allowed redirect
- *
- * @param array $hosts
- * @param string $api_base
- *
- * @return array
- */
- static function allowed_redirect_hosts( $hosts, $api_base = JETPACK__API_BASE ) {
- if ( empty( $hosts ) ) {
- $hosts = array();
- }
+ public static function allowed_redirect_hosts( $hosts, $api_base = JETPACK__API_BASE ) {
+ if ( empty( $hosts ) ) {
+ $hosts = array();
+ }
- $hosts[] = 'wordpress.com';
- $hosts[] = 'jetpack.wordpress.com';
- $hosts[] = 'public-api.wordpress.com';
- $hosts[] = 'jetpack.com';
+ $hosts[] = 'wordpress.com';
+ $hosts[] = 'jetpack.wordpress.com';
+ $hosts[] = 'public-api.wordpress.com';
+ $hosts[] = 'jetpack.com';
- if ( false === strpos( $api_base, 'jetpack.wordpress.com/jetpack' ) ) {
- $base_url_parts = wp_parse_url( esc_url_raw( $api_base ) );
- if ( $base_url_parts && ! empty( $base_url_parts[ 'host' ] ) ) {
- $hosts[] = $base_url_parts[ 'host' ];
+ if ( false === strpos( $api_base, 'jetpack.wordpress.com/jetpack' ) ) {
+ $base_url_parts = wp_parse_url( esc_url_raw( $api_base ) );
+ if ( $base_url_parts && ! empty( $base_url_parts['host'] ) ) {
+ $hosts[] = $base_url_parts['host'];
+ }
}
- }
- return array_unique( $hosts );
- }
+ return array_unique( $hosts );
+ }
- static function generate_user( $user_data ) {
- $username = $user_data->login;
/**
- * Determines how many times the SSO module can attempt to randomly generate a user.
+ * Generate a new user from a SSO attempt.
*
- * @module sso
- *
- * @since 4.3.2
- *
- * @param int 5 By default, SSO will attempt to random generate a user up to 5 times.
+ * @param object $user_data WordPress.com user information.
*/
- $num_tries = (int) apply_filters( 'jetpack_sso_allowed_username_generate_retries', 5 );
-
- $tries = 0;
- while ( ( $exists = username_exists( $username ) ) && $tries++ < $num_tries ) {
- $username = $user_data->login . '_' . $user_data->ID . '_' . mt_rand();
- }
+ public static function generate_user( $user_data ) {
+ $username = $user_data->login;
+ /**
+ * Determines how many times the SSO module can attempt to randomly generate a user.
+ *
+ * @module sso
+ *
+ * @since 4.3.2
+ *
+ * @param int 5 By default, SSO will attempt to random generate a user up to 5 times.
+ */
+ $num_tries = (int) apply_filters( 'jetpack_sso_allowed_username_generate_retries', 5 );
+
+ $exists = username_exists( $username );
+ $tries = 0;
+ while ( $exists && $tries++ < $num_tries ) {
+ $username = $user_data->login . '_' . $user_data->ID . '_' . wp_rand();
+ $exists = username_exists( $username );
+ }
- if ( $exists ) {
- return false;
- }
+ if ( $exists ) {
+ return false;
+ }
- $user = (object) array();
- $user->user_pass = wp_generate_password( 20 );
- $user->user_login = wp_slash( $username );
- $user->user_email = wp_slash( $user_data->email );
- $user->display_name = $user_data->display_name;
- $user->first_name = $user_data->first_name;
- $user->last_name = $user_data->last_name;
- $user->url = $user_data->url;
- $user->description = $user_data->description;
-
- if ( isset( $user_data->role ) && $user_data->role ) {
- $user->role = $user_data->role;
- }
+ $user = (object) array();
+ $user->user_pass = wp_generate_password( 20 );
+ $user->user_login = wp_slash( $username );
+ $user->user_email = wp_slash( $user_data->email );
+ $user->display_name = $user_data->display_name;
+ $user->first_name = $user_data->first_name;
+ $user->last_name = $user_data->last_name;
+ $user->url = $user_data->url;
+ $user->description = $user_data->description;
+
+ if ( isset( $user_data->role ) && $user_data->role ) {
+ $user->role = $user_data->role;
+ }
- $created_user_id = wp_insert_user( $user );
+ $created_user_id = wp_insert_user( $user );
- update_user_meta( $created_user_id, 'wpcom_user_id', $user_data->ID );
- return get_userdata( $created_user_id );
- }
+ update_user_meta( $created_user_id, 'wpcom_user_id', $user_data->ID );
+ return get_userdata( $created_user_id );
+ }
- static function extend_auth_cookie_expiration_for_sso() {
/**
* Determines how long the auth cookie is valid for when a user logs in with SSO.
*
- * @module sso
+ * @return int result of the jetpack_sso_auth_cookie_expiration filter.
+ */
+ public static function extend_auth_cookie_expiration_for_sso() {
+ /**
+ * Determines how long the auth cookie is valid for when a user logs in with SSO.
+ *
+ * @module sso
+ *
+ * @since 4.4.0
+ * @since 6.1.0 Fixed a typo. Filter was previously jetpack_sso_auth_cookie_expirtation.
+ *
+ * @param int YEAR_IN_SECONDS
+ */
+ return (int) apply_filters( 'jetpack_sso_auth_cookie_expiration', YEAR_IN_SECONDS );
+ }
+
+ /**
+ * Determines if the SSO form should be displayed for the current action.
*
- * @since 4.4.0
- * @since 6.1.0 Fixed a typo. Filter was previously jetpack_sso_auth_cookie_expirtation.
+ * @since 4.6.0
*
- * @param int YEAR_IN_SECONDS
+ * @param string $action SSO action being performed.
+ *
+ * @return bool Is SSO allowed for the current action?
*/
- return (int) apply_filters( 'jetpack_sso_auth_cookie_expiration', YEAR_IN_SECONDS );
- }
+ public static function display_sso_form_for_action( $action ) {
+ /**
+ * Allows plugins the ability to overwrite actions where the SSO form is allowed to be used.
+ *
+ * @module sso
+ *
+ * @since 4.6.0
+ *
+ * @param array $allowed_actions_for_sso
+ */
+ $allowed_actions_for_sso = (array) apply_filters(
+ 'jetpack_sso_allowed_actions',
+ array(
+ 'login',
+ 'jetpack-sso',
+ 'jetpack_json_api_authorization',
+ )
+ );
+ return in_array( $action, $allowed_actions_for_sso, true );
+ }
- /**
- * Determines if the SSO form should be displayed for the current action.
- *
- * @since 4.6.0
- *
- * @param string $action
- *
- * @return bool Is SSO allowed for the current action?
- */
- static function display_sso_form_for_action( $action ) {
/**
- * Allows plugins the ability to overwrite actions where the SSO form is allowed to be used.
- *
- * @module sso
+ * This method returns an environment array that is meant to simulate `$_REQUEST` when the initial
+ * JSON API auth request was made.
*
* @since 4.6.0
*
- * @param array $allowed_actions_for_sso
+ * @return array|bool
*/
- $allowed_actions_for_sso = (array) apply_filters( 'jetpack_sso_allowed_actions', array(
- 'login',
- 'jetpack-sso',
- 'jetpack_json_api_authorization',
- ) );
- return in_array( $action, $allowed_actions_for_sso );
- }
+ public static function get_json_api_auth_environment() {
+ if ( empty( $_COOKIE['jetpack_sso_original_request'] ) ) {
+ return false;
+ }
- /**
- * This method returns an environment array that is meant to simulate `$_REQUEST` when the initial
- * JSON API auth request was made.
- *
- * @since 4.6.0
- *
- * @return array|bool
- */
- static function get_json_api_auth_environment() {
- if ( empty( $_COOKIE['jetpack_sso_original_request'] ) ) {
- return false;
- }
+ $original_request = esc_url_raw( wp_unslash( $_COOKIE['jetpack_sso_original_request'] ) );
- $original_request = esc_url_raw( $_COOKIE['jetpack_sso_original_request'] );
+ $parsed_url = wp_parse_url( $original_request );
+ if ( empty( $parsed_url ) || empty( $parsed_url['query'] ) ) {
+ return false;
+ }
- $parsed_url = wp_parse_url( $original_request );
- if ( empty( $parsed_url ) || empty( $parsed_url['query'] ) ) {
- return false;
- }
+ $args = array();
+ wp_parse_str( $parsed_url['query'], $args );
- $args = array();
- wp_parse_str( $parsed_url['query'], $args );
+ if ( empty( $args ) || empty( $args['action'] ) ) {
+ return false;
+ }
- if ( empty( $args ) || empty( $args['action'] ) ) {
- return false;
- }
+ if ( 'jetpack_json_api_authorization' !== $args['action'] ) {
+ return false;
+ }
- if ( 'jetpack_json_api_authorization' != $args['action'] ) {
- return false;
+ return array_merge(
+ $args,
+ array( 'jetpack_json_api_original_query' => $original_request )
+ );
}
- return array_merge(
- $args,
- array( 'jetpack_json_api_original_query' => $original_request )
- );
- }
-
/**
* Check if the site has a custom login page URL, and return it.
* If default login page URL is used (`wp-login.php`), `null` will be returned.
@@ -346,6 +367,6 @@ class Jetpack_SSO_Helpers {
// Extracting the "path" part of the URL, because we don't need the `site_url` part.
return str_ireplace( $site_url, '', $login_url );
}
-}
+ }
endif;
diff --git a/plugins/jetpack/modules/sso/class.jetpack-sso-notices.php b/plugins/jetpack/modules/sso/class.jetpack-sso-notices.php
index 00a61581..57f9f914 100644
--- a/plugins/jetpack/modules/sso/class.jetpack-sso-notices.php
+++ b/plugins/jetpack/modules/sso/class.jetpack-sso-notices.php
@@ -1,4 +1,9 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * A collection of helper functions used in the SSO module.
+ *
+ * @package automattic/jetpack
+ */
use Automattic\Jetpack\Redirect;
diff --git a/plugins/jetpack/modules/sso/jetpack-sso-login-rtl.css b/plugins/jetpack/modules/sso/jetpack-sso-login-rtl.css
index 3036adba..b9537bce 100644
--- a/plugins/jetpack/modules/sso/jetpack-sso-login-rtl.css
+++ b/plugins/jetpack/modules/sso/jetpack-sso-login-rtl.css
@@ -1,164 +1,161 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
#loginform {
- /* We set !important because sometimes static is added inline */
- position: relative !important;
- padding-bottom: 92px;
+ /* We set !important because sometimes static is added inline */
+ position: relative !important;
+ padding-bottom: 92px;
}
.jetpack-sso-repositioned #loginform {
- padding-bottom: 26px;
+ padding-bottom: 26px;
}
#loginform #jetpack-sso-wrap,
#loginform #jetpack-sso-wrap * {
- box-sizing: border-box;
+ box-sizing: border-box;
}
-
#jetpack-sso-wrap__action,
-#jetpack-sso-wrap__user{
- display: none;
+#jetpack-sso-wrap__user {
+ display: none;
}
.jetpack-sso-form-display #jetpack-sso-wrap__action,
.jetpack-sso-form-display #jetpack-sso-wrap__user {
- display: block;
+ display: block;
}
#jetpack-sso-wrap {
- position: absolute;
- bottom: 20px;
- padding: 0 24px;
- margin-right: -24px;
- margin-left: -24px;
- width: 100%;
+ position: absolute;
+ bottom: 20px;
+ padding: 0 24px;
+ margin-right: -24px;
+ margin-left: -24px;
+ width: 100%;
}
.jetpack-sso-repositioned #jetpack-sso-wrap {
- position: relative;
- bottom: auto;
- padding: 0;
- margin-top: 16px;
- margin-right: 0;
- margin-left: 0;
+ position: relative;
+ bottom: auto;
+ padding: 0;
+ margin-top: 16px;
+ margin-right: 0;
+ margin-left: 0;
}
.jetpack-sso-form-display #jetpack-sso-wrap {
- position: relative;
- bottom: auto;
- padding: 0;
- margin-top: 0;
- margin-right: 0;
- margin-left: 0;
+ position: relative;
+ bottom: auto;
+ padding: 0;
+ margin-top: 0;
+ margin-right: 0;
+ margin-left: 0;
}
#loginform #jetpack-sso-wrap p {
- color: #777777;
- margin-bottom: 16px;
+ color: #777777;
+ margin-bottom: 16px;
}
#jetpack-sso-wrap a {
- display: block;
- width: 100%;
- text-align: center;
- text-decoration: none;
+ display: block;
+ width: 100%;
+ text-align: center;
+ text-decoration: none;
}
#jetpack-sso-wrap .jetpack-sso-toggle.wpcom {
- display: none;
+ display: none;
}
.jetpack-sso-form-display #jetpack-sso-wrap .jetpack-sso-toggle.wpcom {
- display: block;
+ display: block;
}
-
.jetpack-sso-form-display #jetpack-sso-wrap .jetpack-sso-toggle.default {
- display: none;
+ display: none;
}
-
.jetpack-sso-form-display #loginform > p,
.jetpack-sso-form-display #loginform > div {
- display: none;
+ display: none;
}
.jetpack-sso-form-display #loginform #jetpack-sso-wrap {
- display: block;
+ display: block;
}
.jetpack-sso-form-display #loginform {
- padding: 26px 24px;
+ padding: 26px 24px;
}
.jetpack-sso-or {
- margin-bottom: 16px;
- position: relative;
- text-align: center;
+ margin-bottom: 16px;
+ position: relative;
+ text-align: center;
}
.jetpack-sso-or:before {
- background: #dcdcde;
- content: '';
- height: 1px;
- position: absolute;
- right: 0;
- top: 50%;
- width: 100%;
+ background: #dcdcde;
+ content: "";
+ height: 1px;
+ position: absolute;
+ right: 0;
+ top: 50%;
+ width: 100%;
}
+
.jetpack-sso-or span {
- background: #fff;
- color: #777;
- position: relative;
- padding: 0 8px;
- text-transform: uppercase
+ background: #fff;
+ color: #777;
+ position: relative;
+ padding: 0 8px;
+ text-transform: uppercase;
}
#jetpack-sso-wrap .button {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 36px;
- margin-bottom: 16px;
- width: 100%;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ height: 36px;
+ margin-bottom: 16px;
+ width: 100%;
}
#jetpack-sso-wrap .button .genericon-wordpress {
- font-size: 24px;
- margin-left: 4px;
+ font-size: 24px;
+ margin-left: 4px;
}
#jetpack-sso-wrap__user img {
- border-radius: 50%;
- display: block;
- margin: 0 auto 16px;
+ border-radius: 50%;
+ display: block;
+ margin: 0 auto 16px;
}
#jetpack-sso-wrap__user h2 {
- font-size: 21px;
- font-weight: 300;
- margin-bottom: 16px;
- text-align: center;
+ font-size: 21px;
+ font-weight: 300;
+ margin-bottom: 16px;
+ text-align: center;
}
#jetpack-sso-wrap__user h2 span {
- font-weight: bold;
+ font-weight: bold;
}
.jetpack-sso-wrap__reauth {
- margin-bottom: 16px;
+ margin-bottom: 16px;
}
.jetpack-sso-form-display #nav {
- display: none;
+ display: none;
}
.jetpack-sso-form-display #backtoblog {
- margin: 24px 0 0;
+ margin: 24px 0 0;
}
.jetpack-sso-clear:after {
- content: "";
- display: table;
- clear: both;
+ content: "";
+ display: table;
+ clear: both;
}
diff --git a/plugins/jetpack/modules/sso/jetpack-sso-login-rtl.min.css b/plugins/jetpack/modules/sso/jetpack-sso-login-rtl.min.css
index 5eaaa8c3..3e6224fb 100644
--- a/plugins/jetpack/modules/sso/jetpack-sso-login-rtl.min.css
+++ b/plugins/jetpack/modules/sso/jetpack-sso-login-rtl.min.css
@@ -1 +1 @@
-#loginform{position:relative!important;padding-bottom:92px}.jetpack-sso-repositioned #loginform{padding-bottom:26px}#loginform #jetpack-sso-wrap,#loginform #jetpack-sso-wrap *{box-sizing:border-box}#jetpack-sso-wrap__action,#jetpack-sso-wrap__user{display:none}.jetpack-sso-form-display #jetpack-sso-wrap__action,.jetpack-sso-form-display #jetpack-sso-wrap__user{display:block}#jetpack-sso-wrap{position:absolute;bottom:20px;padding:0 24px;margin-right:-24px;margin-left:-24px;width:100%}.jetpack-sso-repositioned #jetpack-sso-wrap{position:relative;bottom:auto;padding:0;margin-top:16px;margin-right:0;margin-left:0}.jetpack-sso-form-display #jetpack-sso-wrap{position:relative;bottom:auto;padding:0;margin-top:0;margin-right:0;margin-left:0}#loginform #jetpack-sso-wrap p{color:#777;margin-bottom:16px}#jetpack-sso-wrap a{display:block;width:100%;text-align:center;text-decoration:none}#jetpack-sso-wrap .jetpack-sso-toggle.wpcom{display:none}.jetpack-sso-form-display #jetpack-sso-wrap .jetpack-sso-toggle.wpcom{display:block}.jetpack-sso-form-display #jetpack-sso-wrap .jetpack-sso-toggle.default{display:none}.jetpack-sso-form-display #loginform>div,.jetpack-sso-form-display #loginform>p{display:none}.jetpack-sso-form-display #loginform #jetpack-sso-wrap{display:block}.jetpack-sso-form-display #loginform{padding:26px 24px}.jetpack-sso-or{margin-bottom:16px;position:relative;text-align:center}.jetpack-sso-or:before{background:#dcdcde;content:'';height:1px;position:absolute;right:0;top:50%;width:100%}.jetpack-sso-or span{background:#fff;color:#777;position:relative;padding:0 8px;text-transform:uppercase}#jetpack-sso-wrap .button{display:flex;justify-content:center;align-items:center;height:36px;margin-bottom:16px;width:100%}#jetpack-sso-wrap .button .genericon-wordpress{font-size:24px;margin-left:4px}#jetpack-sso-wrap__user img{border-radius:50%;display:block;margin:0 auto 16px}#jetpack-sso-wrap__user h2{font-size:21px;font-weight:300;margin-bottom:16px;text-align:center}#jetpack-sso-wrap__user h2 span{font-weight:700}.jetpack-sso-wrap__reauth{margin-bottom:16px}.jetpack-sso-form-display #nav{display:none}.jetpack-sso-form-display #backtoblog{margin:24px 0 0}.jetpack-sso-clear:after{content:"";display:table;clear:both} \ No newline at end of file
+#loginform{padding-bottom:92px;position:relative!important}.jetpack-sso-repositioned #loginform{padding-bottom:26px}#loginform #jetpack-sso-wrap,#loginform #jetpack-sso-wrap *{box-sizing:border-box}#jetpack-sso-wrap__action,#jetpack-sso-wrap__user{display:none}.jetpack-sso-form-display #jetpack-sso-wrap__action,.jetpack-sso-form-display #jetpack-sso-wrap__user{display:block}#jetpack-sso-wrap{bottom:20px;margin-left:-24px;margin-right:-24px;padding:0 24px;position:absolute;width:100%}.jetpack-sso-repositioned #jetpack-sso-wrap{bottom:auto;margin-left:0;margin-right:0;margin-top:16px;padding:0;position:relative}.jetpack-sso-form-display #jetpack-sso-wrap{bottom:auto;margin-left:0;margin-right:0;margin-top:0;padding:0;position:relative}#loginform #jetpack-sso-wrap p{color:#777;margin-bottom:16px}#jetpack-sso-wrap a{display:block;text-align:center;text-decoration:none;width:100%}#jetpack-sso-wrap .jetpack-sso-toggle.wpcom{display:none}.jetpack-sso-form-display #jetpack-sso-wrap .jetpack-sso-toggle.wpcom{display:block}.jetpack-sso-form-display #jetpack-sso-wrap .jetpack-sso-toggle.default,.jetpack-sso-form-display #loginform>div,.jetpack-sso-form-display #loginform>p{display:none}.jetpack-sso-form-display #loginform #jetpack-sso-wrap{display:block}.jetpack-sso-form-display #loginform{padding:26px 24px}.jetpack-sso-or{margin-bottom:16px;position:relative;text-align:center}.jetpack-sso-or:before{background:#dcdcde;content:"";height:1px;position:absolute;right:0;top:50%;width:100%}.jetpack-sso-or span{background:#fff;color:#777;padding:0 8px;position:relative;text-transform:uppercase}#jetpack-sso-wrap .button{align-items:center;display:flex;height:36px;justify-content:center;margin-bottom:16px;width:100%}#jetpack-sso-wrap .button .genericon-wordpress{font-size:24px;margin-left:4px}#jetpack-sso-wrap__user img{border-radius:50%;display:block;margin:0 auto 16px}#jetpack-sso-wrap__user h2{font-size:21px;font-weight:300;margin-bottom:16px;text-align:center}#jetpack-sso-wrap__user h2 span{font-weight:700}.jetpack-sso-wrap__reauth{margin-bottom:16px}.jetpack-sso-form-display #nav{display:none}.jetpack-sso-form-display #backtoblog{margin:24px 0 0}.jetpack-sso-clear:after{clear:both;content:"";display:table} \ No newline at end of file
diff --git a/plugins/jetpack/modules/sso/jetpack-sso-login.min.css b/plugins/jetpack/modules/sso/jetpack-sso-login.min.css
index ef854000..ac5e5c77 100644
--- a/plugins/jetpack/modules/sso/jetpack-sso-login.min.css
+++ b/plugins/jetpack/modules/sso/jetpack-sso-login.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-#loginform{position:relative!important;padding-bottom:92px}.jetpack-sso-repositioned #loginform{padding-bottom:26px}#loginform #jetpack-sso-wrap,#loginform #jetpack-sso-wrap *{box-sizing:border-box}#jetpack-sso-wrap__action,#jetpack-sso-wrap__user{display:none}.jetpack-sso-form-display #jetpack-sso-wrap__action,.jetpack-sso-form-display #jetpack-sso-wrap__user{display:block}#jetpack-sso-wrap{position:absolute;bottom:20px;padding:0 24px;margin-left:-24px;margin-right:-24px;width:100%}.jetpack-sso-repositioned #jetpack-sso-wrap{position:relative;bottom:auto;padding:0;margin-top:16px;margin-left:0;margin-right:0}.jetpack-sso-form-display #jetpack-sso-wrap{position:relative;bottom:auto;padding:0;margin-top:0;margin-left:0;margin-right:0}#loginform #jetpack-sso-wrap p{color:#777;margin-bottom:16px}#jetpack-sso-wrap a{display:block;width:100%;text-align:center;text-decoration:none}#jetpack-sso-wrap .jetpack-sso-toggle.wpcom{display:none}.jetpack-sso-form-display #jetpack-sso-wrap .jetpack-sso-toggle.wpcom{display:block}.jetpack-sso-form-display #jetpack-sso-wrap .jetpack-sso-toggle.default{display:none}.jetpack-sso-form-display #loginform>div,.jetpack-sso-form-display #loginform>p{display:none}.jetpack-sso-form-display #loginform #jetpack-sso-wrap{display:block}.jetpack-sso-form-display #loginform{padding:26px 24px}.jetpack-sso-or{margin-bottom:16px;position:relative;text-align:center}.jetpack-sso-or:before{background:#dcdcde;content:'';height:1px;position:absolute;left:0;top:50%;width:100%}.jetpack-sso-or span{background:#fff;color:#777;position:relative;padding:0 8px;text-transform:uppercase}#jetpack-sso-wrap .button{display:flex;justify-content:center;align-items:center;height:36px;margin-bottom:16px;width:100%}#jetpack-sso-wrap .button .genericon-wordpress{font-size:24px;margin-right:4px}#jetpack-sso-wrap__user img{border-radius:50%;display:block;margin:0 auto 16px}#jetpack-sso-wrap__user h2{font-size:21px;font-weight:300;margin-bottom:16px;text-align:center}#jetpack-sso-wrap__user h2 span{font-weight:700}.jetpack-sso-wrap__reauth{margin-bottom:16px}.jetpack-sso-form-display #nav{display:none}.jetpack-sso-form-display #backtoblog{margin:24px 0 0}.jetpack-sso-clear:after{content:"";display:table;clear:both} \ No newline at end of file
+#loginform{padding-bottom:92px;position:relative!important}.jetpack-sso-repositioned #loginform{padding-bottom:26px}#loginform #jetpack-sso-wrap,#loginform #jetpack-sso-wrap *{box-sizing:border-box}#jetpack-sso-wrap__action,#jetpack-sso-wrap__user{display:none}.jetpack-sso-form-display #jetpack-sso-wrap__action,.jetpack-sso-form-display #jetpack-sso-wrap__user{display:block}#jetpack-sso-wrap{bottom:20px;margin-left:-24px;margin-right:-24px;padding:0 24px;position:absolute;width:100%}.jetpack-sso-repositioned #jetpack-sso-wrap{bottom:auto;margin-left:0;margin-right:0;margin-top:16px;padding:0;position:relative}.jetpack-sso-form-display #jetpack-sso-wrap{bottom:auto;margin-left:0;margin-right:0;margin-top:0;padding:0;position:relative}#loginform #jetpack-sso-wrap p{color:#777;margin-bottom:16px}#jetpack-sso-wrap a{display:block;text-align:center;text-decoration:none;width:100%}#jetpack-sso-wrap .jetpack-sso-toggle.wpcom{display:none}.jetpack-sso-form-display #jetpack-sso-wrap .jetpack-sso-toggle.wpcom{display:block}.jetpack-sso-form-display #jetpack-sso-wrap .jetpack-sso-toggle.default,.jetpack-sso-form-display #loginform>div,.jetpack-sso-form-display #loginform>p{display:none}.jetpack-sso-form-display #loginform #jetpack-sso-wrap{display:block}.jetpack-sso-form-display #loginform{padding:26px 24px}.jetpack-sso-or{margin-bottom:16px;position:relative;text-align:center}.jetpack-sso-or:before{background:#dcdcde;content:"";height:1px;left:0;position:absolute;top:50%;width:100%}.jetpack-sso-or span{background:#fff;color:#777;padding:0 8px;position:relative;text-transform:uppercase}#jetpack-sso-wrap .button{align-items:center;display:flex;height:36px;justify-content:center;margin-bottom:16px;width:100%}#jetpack-sso-wrap .button .genericon-wordpress{font-size:24px;margin-right:4px}#jetpack-sso-wrap__user img{border-radius:50%;display:block;margin:0 auto 16px}#jetpack-sso-wrap__user h2{font-size:21px;font-weight:300;margin-bottom:16px;text-align:center}#jetpack-sso-wrap__user h2 span{font-weight:700}.jetpack-sso-wrap__reauth{margin-bottom:16px}.jetpack-sso-form-display #nav{display:none}.jetpack-sso-form-display #backtoblog{margin:24px 0 0}.jetpack-sso-clear:after{clear:both;content:"";display:table} \ No newline at end of file
diff --git a/plugins/jetpack/modules/stats.php b/plugins/jetpack/modules/stats.php
index cb28c431..99698541 100644
--- a/plugins/jetpack/modules/stats.php
+++ b/plugins/jetpack/modules/stats.php
@@ -131,7 +131,7 @@ function stats_ignore_db_version( $version ) {
if (
is_admin() &&
isset( $_GET['page'] ) && 'stats' === $_GET['page'] && // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- isset( $_GET['chart'] ) && strpos( $_GET['chart'], 'admin-bar-hours' ) === 0 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ isset( $_GET['chart'] ) && strpos( $_GET['chart'], 'admin-bar-hours' ) === 0 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput
) {
global $wp_db_version;
return $wp_db_version;
@@ -198,6 +198,28 @@ function stats_template_redirect() {
}
}
+ /**
+ * Allow excluding specific IP addresses from being tracked in Stats.
+ * Note: for this to work well, visitors' IP addresses must:
+ * - be stored and returned properly in IP address headers;
+ * - not be impacted by any caching setup on your site.
+ *
+ * @module stats
+ *
+ * @since 10.6
+ *
+ * @param array $excluded_ips An array of IP address strings to exclude from tracking.
+ */
+ $excluded_ips = (array) apply_filters( 'jetpack_stats_excluded_ips', array() );
+
+ // Should we be counting views for this IP address?
+ if (
+ ! empty( $excluded_ips )
+ && in_array( Jetpack::current_user_ip( true ), $excluded_ips, true )
+ ) {
+ return;
+ }
+
add_action( 'wp_footer', 'stats_footer', 101 );
add_action( 'web_stories_print_analytics', 'stats_footer' );
@@ -251,8 +273,30 @@ function stats_build_view_data() {
function stats_footer() {
$data = stats_build_view_data();
if ( Jetpack_AMP_Support::is_amp_request() ) {
+
+ /**
+ * Filter the parameters added to the AMP pixel tracking code.
+ *
+ * @module stats
+ *
+ * @since 10.9
+ *
+ * @param array $data Array of options about the site and page you're on.
+ */
+ $data = (array) apply_filters( 'jetpack_stats_footer_amp_data', $data );
stats_render_amp_footer( $data );
} else {
+
+ /**
+ * Filter the parameters added to the JavaScript stats tracking code.
+ *
+ * @module stats
+ *
+ * @since 10.9
+ *
+ * @param array $data Array of options about the site and page you're on.
+ */
+ $data = (array) apply_filters( 'jetpack_stats_footer_js_data', $data );
stats_render_footer( $data );
}
@@ -285,7 +329,7 @@ END;
/**
* Render the stats footer for AMP output.
*
- * @param array $data Array of data for the JS stats tracker.
+ * @param array $data Array of data for the AMP pixel tracker.
*/
function stats_render_amp_footer( $data ) {
$data['host'] = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : ''; // input var ok.
@@ -442,7 +486,7 @@ function stats_admin_menu() {
// If we're at an old Stats URL, redirect to the new one.
// Don't even bother with caps, menu_page_url(), etc. Just do it.
if ( 'index.php' === $pagenow && isset( $_GET['page'] ) && 'stats' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $redirect_url = str_replace( array( '/wp-admin/index.php?', '/wp-admin/?' ), '/wp-admin/admin.php?', $_SERVER['REQUEST_URI'] );
+ $redirect_url = str_replace( array( '/wp-admin/index.php?', '/wp-admin/?' ), '/wp-admin/admin.php?', isset( $_SERVER['REQUEST_URI'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : null );
$relative_pos = strpos( $redirect_url, '/wp-admin/' );
if ( false !== $relative_pos ) {
wp_safe_redirect( admin_url( substr( $redirect_url, $relative_pos + 10 ) ) );
@@ -481,13 +525,13 @@ function stats_reports_load() {
Jetpack_Admin_Page::load_wrapper_styles();
add_action( 'admin_print_styles', 'stats_reports_css' );
- if ( isset( $_GET['nojs'] ) && $_GET['nojs'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ if ( ! empty( $_GET['nojs'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$parsed = wp_parse_url( admin_url() );
// Remember user doesn't want JS.
- setcookie( 'stnojs', '1', time() + 172800, $parsed['path'] ); // 2 days.
+ setcookie( 'stnojs', '1', time() + 172800, $parsed['path'], COOKIE_DOMAIN, is_ssl(), true ); // 2 days.
}
- if ( isset( $_COOKIE['stnojs'] ) && $_COOKIE['stnojs'] ) {
+ if ( ! empty( $_COOKIE['stnojs'] ) ) {
// Detect if JS is on. If so, remove cookie so next page load is via JS.
add_action( 'admin_print_footer_scripts', 'stats_js_remove_stnojs_cookie' );
} elseif ( ! isset( $_GET['noheader'] ) && empty( $_GET['nojs'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
@@ -636,7 +680,7 @@ function stats_reports_page( $main_chart_only = false ) {
return;
}
- $day = isset( $_GET['day'] ) && preg_match( '/^\d{4}-\d{2}-\d{2}$/', $_GET['day'] ) ? $_GET['day'] : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $day = isset( $_GET['day'] ) && preg_match( '/^\d{4}-\d{2}-\d{2}$/', $_GET['day'] ) ? $_GET['day'] : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput
$q = array(
'noheader' => 'true',
'proxy' => '',
@@ -675,28 +719,29 @@ function stats_reports_page( $main_chart_only = false ) {
if ( ! isset( $_REQUEST[ $var ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
continue;
}
+ $val = wp_unslash( $_REQUEST[ $var ] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
if ( is_array( $vals ) ) {
- if ( in_array( $_REQUEST[ $var ], $vals, true ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $q[ $var ] = $_REQUEST[ $var ]; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ if ( in_array( $val, $vals, true ) ) {
+ $q[ $var ] = $val;
}
} elseif ( 'int' === $vals ) {
- $q[ $var ] = (int) $_REQUEST[ $var ]; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $q[ $var ] = (int) $val;
} elseif ( 'date' === $vals ) {
- if ( preg_match( '/^\d{4}-\d{2}-\d{2}$/', $_REQUEST[ $var ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $q[ $var ] = $_REQUEST[ $var ]; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ if ( preg_match( '/^\d{4}-\d{2}-\d{2}$/', $val ) ) {
+ $q[ $var ] = $val;
}
} elseif ( null === $vals ) {
$q[ $var ] = '';
} elseif ( 'data' === $vals ) {
- if ( 'index.php' === substr( $_REQUEST[ $var ], 0, 9 ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $q[ $var ] = $_REQUEST[ $var ];// phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ if ( 'index.php' === substr( $val, 0, 9 ) ) {
+ $q[ $var ] = $val;
}
}
}
if ( isset( $_GET['chart'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- if ( preg_match( '/^[a-z0-9-]+$/', $_GET['chart'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $chart = sanitize_title( $_GET['chart'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ if ( preg_match( '/^[a-z0-9-]+$/', $_GET['chart'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput
+ $chart = sanitize_title( $_GET['chart'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput
$url = 'https://' . STATS_DASHBOARD_SERVER . "/wp-includes/charts/{$chart}.php";
}
} else {
@@ -847,7 +892,7 @@ function stats_convert_post_title( $matches ) {
*/
function stats_hide_smile_css() {
?>
-<style type='text/css'>img#wpstats{display:none}</style>
+<style>img#wpstats{display:none}</style>
<?php
}
@@ -1081,13 +1126,13 @@ function stats_dashboard_widget_control() {
$options = stats_dashboard_widget_options();
- if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['widget_id'] ) && 'dashboard_stats' === $_POST['widget_id'] ) { // phpcs:ignore WordPress.Security.NonceVerification
+ if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'post' === strtolower( filter_var( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) ) && isset( $_POST['widget_id'] ) && 'dashboard_stats' === $_POST['widget_id'] ) { // phpcs:ignore WordPress.Security.NonceVerification
if ( isset( $periods[ $_POST['chart'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
- $options['chart'] = $_POST['chart']; // phpcs:ignore WordPress.Security.NonceVerification
+ $options['chart'] = filter_var( wp_unslash( $_POST['chart'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
}
foreach ( array( 'top', 'search' ) as $key ) {
if ( isset( $intervals[ $_POST[ $key ] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
- $options[ $key ] = $_POST[ $key ]; // phpcs:ignore WordPress.Security.NonceVerification
+ $options[ $key ] = filter_var( wp_unslash( $_POST[ $key ] ) ); // phpcs:ignore WordPress.Security.NonceVerification
} else {
$options[ $key ] = $defaults[ $key ];
}
@@ -1226,8 +1271,8 @@ jQuery( function($) {
* @return void
*/
function stats_dashboard_widget_content() {
- $width = isset( $_GET['width'] ) ? (int) ( $_GET['width'] / 2 ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $height = isset( $_GET['height'] ) ? (int) $_GET['height'] - 36 : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $width = isset( $_GET['width'] ) ? intval( $_GET['width'] ) / 2 : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $height = isset( $_GET['height'] ) ? intval( $_GET['height'] ) - 36 : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( ! $width || $width < 250 ) {
$width = 370;
}
@@ -1408,8 +1453,8 @@ function stats_print_wp_remote_error( $get, $url ) {
?>
</p>
<pre>
- User Agent: "<?php echo esc_html( $_SERVER['HTTP_USER_AGENT'] ); ?>"
- Page URL: "http<?php echo ( is_ssl() ? 's' : '' ) . '://' . esc_html( $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); ?>"
+ User Agent: "<?php echo isset( $_SERVER['HTTP_USER_AGENT'] ) ? esc_html( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>"
+ Page URL: "http<?php echo ( is_ssl() ? 's' : '' ) . '://' . esc_html( ( isset( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : '' ) . ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '' ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>"
API URL: "<?php echo esc_url( $url ); ?>"
<?php
if ( is_wp_error( $get ) ) {
@@ -1659,11 +1704,20 @@ function jetpack_stats_post_table( $columns ) {
if ( ! current_user_can( 'view_stats' ) || ! ( new Connection_Manager( 'jetpack' ) )->is_user_connected() ) {
return $columns;
}
+
// Array-Fu to add before comments.
$pos = array_search( 'comments', array_keys( $columns ), true );
+
+ // Fallback to the last position if the post type does not support comments.
+ if ( ! is_int( $pos ) ) {
+ $pos = count( $columns );
+ }
+
+ // Final fallback, if the array was malformed by another plugin for example.
if ( ! is_int( $pos ) ) {
return $columns;
}
+
$chunks = array_chunk( $columns, $pos, true );
$chunks[0]['stats'] = esc_html__( 'Stats', 'jetpack' );
diff --git a/plugins/jetpack/modules/stats/class-jetpack-stats-upgrade-nudges.php b/plugins/jetpack/modules/stats/class-jetpack-stats-upgrade-nudges.php
index 6557f972..a403929f 100644
--- a/plugins/jetpack/modules/stats/class-jetpack-stats-upgrade-nudges.php
+++ b/plugins/jetpack/modules/stats/class-jetpack-stats-upgrade-nudges.php
@@ -7,11 +7,10 @@
use Automattic\Jetpack\Connection\Manager;
use Automattic\Jetpack\Jetpack_CRM_Data;
+use Automattic\Jetpack\Plugins_Installer;
use Automattic\Jetpack\Redirect;
use Automattic\Jetpack\Tracking;
-jetpack_require_lib( 'plugins' );
-
/**
* Class that adds a new section to the Stats Report page
*/
@@ -65,7 +64,7 @@ class Jetpack_Stats_Upgrade_Nudges {
* @return boolean
*/
private static function is_plugin_installed( $plugin_file ) {
- $plugins = Jetpack_Plugins::get_plugins();
+ $plugins = Plugins_Installer::get_plugins();
return isset( $plugins[ $plugin_file ] );
}
@@ -76,7 +75,7 @@ class Jetpack_Stats_Upgrade_Nudges {
* @return boolean
*/
private static function is_plugin_active( $plugin_file ) {
- $plugins = Jetpack_Plugins::get_plugins();
+ $plugins = Plugins_Installer::get_plugins();
return isset( $plugins[ $plugin_file ] ) && isset( $plugins[ $plugin_file ]['active'] ) && $plugins[ $plugin_file ]['active'];
}
@@ -364,7 +363,7 @@ class Jetpack_Stats_Upgrade_Nudges {
$additional_classes = $subitem ? 'jp-stats-report-upgrade-subitem' : '';
$button_class = $subitem ? 'is-secondary' : 'is-primary';
$icon_url = plugins_url( '', JETPACK__PLUGIN_FILE ) . '/images/products/' . $icon;
- $button_label = is_null( $button_label ) ? __( 'Upgrade', 'jetpack' ) : $button_label;
+ $button_label = $button_label === null ? __( 'Upgrade', 'jetpack' ) : $button_label;
$view_event = "stats_nudges_view_$tracks_id";
$click_event = "stats_nudges_click_$tracks_id";
$learn_more_event = "stats_nudges_learn_more_$tracks_id";
@@ -529,7 +528,7 @@ class Jetpack_Stats_Upgrade_Nudges {
}
if ( $print ) {
$learn_link = self::get_upgrade_link( 'stats-nudges-crm-learn' );
- $text = __( 'Sell more and get more leads with the Jetpack CRM plugin built specifically for WordPress.', 'jetpack' );
+ $text = __( 'Sell more and get more leads with the free Jetpack CRM plugin built specifically for WordPress.', 'jetpack' );
self::print_item( __( 'CRM', 'jetpack' ), $text, 'product-jetpack-crm.svg', $link, 'crm', $learn_link, false, $label );
}
return true;
diff --git a/plugins/jetpack/modules/subscriptions.php b/plugins/jetpack/modules/subscriptions.php
index a3986a49..4a4a717b 100644
--- a/plugins/jetpack/modules/subscriptions.php
+++ b/plugins/jetpack/modules/subscriptions.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName)
/**
* Module Name: Subscriptions
* Module Description: Let visitors subscribe to new posts and comments via email
@@ -17,6 +17,9 @@ use Automattic\Jetpack\Connection\XMLRPC_Async_Call;
add_action( 'jetpack_modules_loaded', 'jetpack_subscriptions_load' );
+/**
+ * Loads the Subscriptions module.
+ */
function jetpack_subscriptions_load() {
Jetpack::enable_module_configurable( __FILE__ );
}
@@ -44,50 +47,68 @@ function jetpack_subscriptions_cherry_pick_server_data() {
return $data;
}
+/**
+ * Main class file for the Subscriptions module.
+ */
class Jetpack_Subscriptions {
+ /**
+ * Whether Jetpack has been instantiated or not.
+ *
+ * @var bool
+ */
public $jetpack = false;
+ /**
+ * Hash of the siteurl option.
+ *
+ * @var string
+ */
public static $hash;
/**
* Singleton
+ *
* @static
*/
- static function init() {
+ public static function init() {
static $instance = false;
- if ( !$instance ) {
- $instance = new Jetpack_Subscriptions;
+ if ( ! $instance ) {
+ $instance = new Jetpack_Subscriptions();
}
return $instance;
}
- function __construct() {
+ /**
+ * Jetpack_Subscriptions constructor.
+ */
+ public function __construct() {
$this->jetpack = Jetpack::init();
// Don't use COOKIEHASH as it could be shared across installs && is non-unique in multisite.
- // @see: https://twitter.com/nacin/status/378246957451333632
+ // @see: https://twitter.com/nacin/status/378246957451333632 .
self::$hash = md5( get_option( 'siteurl' ) );
add_filter( 'jetpack_xmlrpc_methods', array( $this, 'xmlrpc_methods' ) );
// @todo remove sync from subscriptions and move elsewhere...
- // Add Configuration Page
+ // Add Configuration Page.
add_action( 'admin_init', array( $this, 'configure' ) );
- // Catch subscription widget submits
- if ( isset( $_REQUEST['jetpack_subscriptions_widget'] ) )
+ // Catch subscription widget submits.
+ if ( isset( $_REQUEST['jetpack_subscriptions_widget'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce checked in widget_submit() for logged in users.
add_action( 'template_redirect', array( $this, 'widget_submit' ) );
+ }
- // Set up the comment subscription checkboxes
+ // Set up the comment subscription checkboxes.
add_filter( 'comment_form_submit_field', array( $this, 'comment_subscribe_init' ), 10, 2 );
// Catch comment posts and check for subscriptions.
add_action( 'comment_post', array( $this, 'comment_subscribe_submit' ), 50, 2 );
- // Adds post meta checkbox in the post submit metabox
+ // Adds post meta checkbox in the post submit metabox.
add_action( 'post_submitbox_misc_actions', array( $this, 'subscription_post_page_metabox' ) );
add_action( 'transition_post_status', array( $this, 'maybe_send_subscription_email' ), 10, 3 );
@@ -97,16 +118,17 @@ class Jetpack_Subscriptions {
add_filter( 'post_updated_messages', array( $this, 'update_published_message' ), 18, 1 );
// Set "social_notifications_subscribe" option during the first-time activation.
- add_action( 'jetpack_activate_module_subscriptions', array( $this, 'set_social_notifications_subscribe' ) );
+ add_action( 'jetpack_activate_module_subscriptions', array( $this, 'set_social_notifications_subscribe' ) );
}
/**
* Jetpack_Subscriptions::xmlrpc_methods()
*
* Register subscriptions methods with the Jetpack XML-RPC server.
- * @param array $methods
+ *
+ * @param array $methods Methods being registered.
*/
- function xmlrpc_methods( $methods ) {
+ public function xmlrpc_methods( $methods ) {
return array_merge(
$methods,
array(
@@ -115,11 +137,11 @@ class Jetpack_Subscriptions {
);
}
- /*
+ /**
* Disable Subscribe on Single Post
* Register post meta
*/
- function subscription_post_page_metabox() {
+ public function subscription_post_page_metabox() {
if (
/**
* Filter whether or not to show the per-post subscription option.
@@ -130,8 +152,7 @@ class Jetpack_Subscriptions {
*
* @param bool true = show checkbox option on all new posts | false = hide the option.
*/
- ! apply_filters( 'jetpack_allow_per_post_subscriptions', false ) )
- {
+ ! apply_filters( 'jetpack_allow_per_post_subscriptions', false ) ) {
return;
}
@@ -142,16 +163,17 @@ class Jetpack_Subscriptions {
global $post;
$disable_subscribe_value = get_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', true );
// only show checkbox if post hasn't been published and is a 'post' post type.
- if ( get_post_status( $post->ID ) !== 'publish' && get_post_type( $post->ID ) == 'post' ) :
- // Nonce it
+ if ( get_post_status( $post->ID ) !== 'publish' && get_post_type( $post->ID ) === 'post' ) :
+ // Nonce it.
wp_nonce_field( 'disable_subscribe', 'disable_subscribe_nonce' );
?>
<div class="misc-pub-section">
- <label for="_jetpack_dont_email_post_to_subs"><?php _e( 'Jetpack Subscriptions:', 'jetpack' ); ?></label><br>
+ <label for="_jetpack_dont_email_post_to_subs"><?php esc_html_e( 'Jetpack Subscriptions:', 'jetpack' ); ?></label><br>
<input type="checkbox" name="_jetpack_dont_email_post_to_subs" id="jetpack-per-post-subscribe" value="1" <?php checked( $disable_subscribe_value, 1, true ); ?> />
- <?php _e( 'Don&#8217;t send this to subscribers', 'jetpack' ); ?>
+ <?php esc_html_e( 'Don&#8217;t send this to subscribers', 'jetpack' ); ?>
</div>
- <?php endif;
+ <?php
+ endif;
}
/**
@@ -164,30 +186,36 @@ class Jetpack_Subscriptions {
*
* Only one of these can be used at any given time.
*
- * @param $new_status string - the "new" post status of the transition when saved
- * @param $old_status string - the "old" post status of the transition when saved
- * @param $post obj - The post object
+ * @param string $new_status Tthe "new" post status of the transition when saved.
+ * @param string $old_status The "old" post status of the transition when saved.
+ * @param object $post obj The post object.
*/
- function maybe_send_subscription_email( $new_status, $old_status, $post ) {
+ public function maybe_send_subscription_email( $new_status, $old_status, $post ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
- // Make sure that the checkbox is preseved
- if ( ! empty( $_POST['disable_subscribe_nonce'] ) && wp_verify_nonce( $_POST['disable_subscribe_nonce'], 'disable_subscribe' ) ) {
+ // Make sure that the checkbox is preseved.
+ if ( ! empty( $_POST['disable_subscribe_nonce'] ) && wp_verify_nonce( $_POST['disable_subscribe_nonce'], 'disable_subscribe' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- WP Core doesn't unslash or sanitize nonces either.
$set_checkbox = isset( $_POST['_jetpack_dont_email_post_to_subs'] ) ? 1 : 0;
update_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', $set_checkbox );
}
}
- function update_published_message( $messages ) {
+ /**
+ * Message used when publishing a post.
+ *
+ * @param array $messages Message array for a post.
+ */
+ public function update_published_message( $messages ) {
global $post;
if ( ! $this->should_email_post_to_subscribers( $post ) ) {
return $messages;
}
- $view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
+ $view_post_link_html = sprintf(
+ ' <a href="%1$s">%2$s</a>',
esc_url( get_permalink( $post ) ),
__( 'View post', 'jetpack' )
);
@@ -195,18 +223,23 @@ class Jetpack_Subscriptions {
$messages['post'][6] = sprintf(
/* translators: Message shown after a post is published */
esc_html__( 'Post published and sending emails to subscribers.', 'jetpack' )
- ) . $view_post_link_html;
+ ) . $view_post_link_html;
return $messages;
}
+ /**
+ * Determine if a post should notifiy subscribers via email.
+ *
+ * @param object $post The post.
+ */
public function should_email_post_to_subscribers( $post ) {
$should_email = true;
if ( get_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', true ) ) {
return false;
}
- // Only posts are currently supported
- if ( $post->post_type !== 'post' ) {
+ // Only posts are currently supported.
+ if ( 'post' !== $post->post_type ) {
return false;
}
@@ -228,7 +261,7 @@ class Jetpack_Subscriptions {
*/
$excluded_categories = apply_filters( 'jetpack_subscriptions_exclude_these_categories', array() );
- // Never email posts from these categories
+ // Never email posts from these categories.
if ( ! empty( $excluded_categories ) && in_category( $excluded_categories, $post->ID ) ) {
$should_email = false;
}
@@ -246,7 +279,7 @@ class Jetpack_Subscriptions {
*/
$only_these_categories = apply_filters( 'jetpack_subscriptions_exclude_all_categories_except', array() );
- // Only emails posts from these categories
+ // Only emails posts from these categories.
if ( ! empty( $only_these_categories ) && ! in_category( $only_these_categories, $post->ID ) ) {
$should_email = false;
}
@@ -254,7 +287,13 @@ class Jetpack_Subscriptions {
return $should_email;
}
- function set_post_flags( $flags, $post ) {
+ /**
+ * Retrieve which flags should be added to a particular post.
+ *
+ * @param array $flags Flags to be added.
+ * @param object $post A post object.
+ */
+ public function set_post_flags( $flags, $post ) {
$flags['send_subscription'] = $this->should_email_post_to_subscribers( $post );
return $flags;
}
@@ -264,8 +303,8 @@ class Jetpack_Subscriptions {
*
* Jetpack Subscriptions configuration screen.
*/
- function configure() {
- // Create the section
+ public function configure() {
+ // Create the section.
add_settings_section(
'jetpack_subscriptions',
__( 'Jetpack Subscriptions Settings', 'jetpack' ),
@@ -273,7 +312,7 @@ class Jetpack_Subscriptions {
'discussion'
);
- /** Subscribe to Posts ***************************************************/
+ /** Subscribe to Posts */
add_settings_field(
'jetpack_subscriptions_post_subscribe',
@@ -288,7 +327,7 @@ class Jetpack_Subscriptions {
'stb_enabled'
);
- /** Subscribe to Comments ******************************************************/
+ /** Subscribe to Comments */
add_settings_field(
'jetpack_subscriptions_comment_subscribe',
@@ -303,7 +342,7 @@ class Jetpack_Subscriptions {
'stc_enabled'
);
- /** Email me whenever: Someone follows my blog ***************************************************/
+ /** Email me whenever: Someone follows my blog */
/* @since 8.1 */
add_settings_section(
@@ -327,7 +366,7 @@ class Jetpack_Subscriptions {
array( $this, 'social_notifications_subscribe_validate' )
);
- /** Subscription Messaging Options ******************************************************/
+ /** Subscription Messaging Options */
register_setting(
'reading',
@@ -360,45 +399,60 @@ class Jetpack_Subscriptions {
}
/**
- * Discussions setting section blurb
- *
+ * Discussions setting section blurb.
*/
- function subscriptions_settings_section() {
- ?>
- <p id="jetpack-subscriptions-settings"><?php _e( 'Change whether your visitors can subscribe to your posts or comments or both.', 'jetpack' ); ?></p>
+ public function subscriptions_settings_section() {
+ ?>
+ <p id="jetpack-subscriptions-settings"><?php esc_html_e( 'Change whether your visitors can subscribe to your posts or comments or both.', 'jetpack' ); ?></p>
- <?php
+ <?php
}
/**
- * Post Subscriptions Toggle
- *
+ * Post Subscriptions Toggle.
*/
- function subscription_post_subscribe_setting() {
+ public function subscription_post_subscribe_setting() {
- $stb_enabled = get_option( 'stb_enabled', 1 ); ?>
+ $stb_enabled = get_option( 'stb_enabled', 1 );
+ ?>
<p class="description">
<input type="checkbox" name="stb_enabled" id="jetpack-post-subscribe" value="1" <?php checked( $stb_enabled, 1 ); ?> />
- <?php _e( "Show a <em>'follow blog'</em> option in the comment form", 'jetpack' ); ?>
+ <?php
+ echo wp_kses(
+ __(
+ "Show a <em>'follow blog'</em> option in the comment form",
+ 'jetpack'
+ ),
+ array( 'em' => array() )
+ );
+ ?>
</p>
- <?php
+ <?php
}
/**
- * Comments Subscriptions Toggle
- *
+ * Comments Subscriptions Toggle.
*/
- function subscription_comment_subscribe_setting() {
+ public function subscription_comment_subscribe_setting() {
- $stc_enabled = get_option( 'stc_enabled', 1 ); ?>
+ $stc_enabled = get_option( 'stc_enabled', 1 );
+ ?>
<p class="description">
<input type="checkbox" name="stc_enabled" id="jetpack-comment-subscribe" value="1" <?php checked( $stc_enabled, 1 ); ?> />
- <?php _e( "Show a <em>'follow comments'</em> option in the comment form", 'jetpack' ); ?>
+ <?php
+ echo wp_kses(
+ __(
+ "Show a <em>'follow comments'</em> option in the comment form",
+ 'jetpack'
+ ),
+ array( 'em' => array() )
+ );
+ ?>
</p>
- <?php
+ <?php
}
/**
@@ -407,7 +461,7 @@ class Jetpack_Subscriptions {
* @since 8.1
*/
public function social_notifications_subscribe_section() {
- // Atypical usage here. We emit jquery to move subscribe notification checkbox to be with the rest of the email notification settings
+ // Atypical usage here. We emit jquery to move subscribe notification checkbox to be with the rest of the email notification settings.
?>
<script type="text/javascript">
jQuery( function( $ ) {
@@ -464,50 +518,76 @@ class Jetpack_Subscriptions {
return 'on';
}
- function validate_settings( $settings ) {
+ /**
+ * Validate settings for the Subscriptions module.
+ *
+ * @param array $settings Settings to be validated.
+ */
+ public function validate_settings( $settings ) {
global $allowedposttags;
$default = $this->get_default_settings();
- // Blog Follow
+ // Blog Follow.
$settings['invitation'] = trim( wp_kses( $settings['invitation'], $allowedposttags ) );
- if ( empty( $settings['invitation'] ) )
+ if ( empty( $settings['invitation'] ) ) {
$settings['invitation'] = $default['invitation'];
+ }
- // Comments Follow (single post)
+ // Comments Follow (single post).
$settings['comment_follow'] = trim( wp_kses( $settings['comment_follow'], $allowedposttags ) );
- if ( empty( $settings['comment_follow'] ) )
+ if ( empty( $settings['comment_follow'] ) ) {
$settings['comment_follow'] = $default['comment_follow'];
+ }
return $settings;
}
+ /**
+ * HTML output helper for Reading section.
+ */
public function reading_section() {
echo '<p id="follower-settings">';
- _e( 'These settings change emails sent from your blog to followers.', 'jetpack' );
+ esc_html_e( 'These settings change emails sent from your blog to followers.', 'jetpack' );
echo '</p>';
}
+ /**
+ * HTML output helper for Invitation section.
+ */
public function setting_invitation() {
$settings = $this->get_settings();
echo '<textarea name="subscription_options[invitation]" class="large-text" cols="50" rows="5">' . esc_textarea( $settings['invitation'] ) . '</textarea>';
- echo '<p><span class="description">'.__( 'Introduction text sent when someone follows your blog. (Site and confirmation details will be automatically added for you.)', 'jetpack' ).'</span></p>';
+ echo '<p><span class="description">' . esc_html__( 'Introduction text sent when someone follows your blog. (Site and confirmation details will be automatically added for you.)', 'jetpack' ) . '</span></p>';
}
+ /**
+ * HTML output helper for Comment Follow section.
+ */
public function setting_comment_follow() {
$settings = $this->get_settings();
echo '<textarea name="subscription_options[comment_follow]" class="large-text" cols="50" rows="5">' . esc_textarea( $settings['comment_follow'] ) . '</textarea>';
- echo '<p><span class="description">'.__( 'Introduction text sent when someone follows a post on your blog. (Site and confirmation details will be automatically added for you.)', 'jetpack' ).'</span></p>';
+ echo '<p><span class="description">' . esc_html__( 'Introduction text sent when someone follows a post on your blog. (Site and confirmation details will be automatically added for you.)', 'jetpack' ) . '</span></p>';
}
- function get_default_settings() {
+ /**
+ * Get default settings for the Subscriptions module.
+ */
+ public function get_default_settings() {
+ $site_url = get_home_url();
+ $display_url = preg_replace( '(^https?://)', '', untrailingslashit( $site_url ) );
+
return array(
- 'invitation' => __( "Howdy.\n\nYou recently followed this blog's posts. This means you will receive each new post by email.\n\nTo activate, click confirm below. If you believe this is an error, ignore this message and we'll never bother you again.", 'jetpack' ),
- 'comment_follow' => __( "Howdy.\n\nYou recently followed one of my posts. This means you will receive an email when new comments are posted.\n\nTo activate, click confirm below. If you believe this is an error, ignore this message and we'll never bother you again.", 'jetpack' )
+ /* translators: Both %1$s and %2$s is site address */
+ 'invitation' => sprintf( __( "Howdy,\nYou recently subscribed to <a href='%1\$s'>%2\$s</a> and we need to verify the email you provided. Once you confirm below, you'll be able to receive and read new posts.\n\nIf you believe this is an error, ignore this message and nothing more will happen.", 'jetpack' ), $site_url, $display_url ),
+ 'comment_follow' => __( "Howdy.\n\nYou recently followed one of my posts. This means you will receive an email when new comments are posted.\n\nTo activate, click confirm below. If you believe this is an error, ignore this message and we'll never bother you again.", 'jetpack' ),
);
}
- function get_settings() {
+ /**
+ * Reeturn merged `subscription_options` option with module default settings.
+ */
+ public function get_settings() {
return wp_parse_args( (array) get_option( 'subscription_options', array() ), $this->get_default_settings() );
}
@@ -516,27 +596,28 @@ class Jetpack_Subscriptions {
*
* Send a synchronous XML-RPC subscribe to blog posts or subscribe to post comments request.
*
- * @param string $email
- * @param array $post_ids (optional) defaults to 0 for blog posts only: array of post IDs to subscribe to blog's posts
+ * @param string $email being subscribed.
+ * @param array $post_ids (optional) defaults to 0 for blog posts only: array of post IDs to subscribe to blog's posts.
* @param bool $async (optional) Should the subscription be performed asynchronously? Defaults to true.
+ * @param array $extra_data Additional data passed to the `jetpack.subscribeToSite` call.
*
* @return true|WP_Error true on success
- * invalid_email : not a valid email address
- * invalid_post_id : not a valid post ID
- * unknown_post_id : unknown post
- * not_subscribed : strange error. Jetpack servers at WordPress.com could subscribe the email.
- * disabled : Site owner has disabled subscriptions.
- * active : Already subscribed.
- * pending : Tried to subscribe before but the confirmation link is never clicked. No confirmation email is sent.
- * unknown : strange error. Jetpack servers at WordPress.com returned something malformed.
- * unknown_status : strange error. Jetpack servers at WordPress.com returned something I didn't understand.
+ * invalid_email : not a valid email address
+ * invalid_post_id : not a valid post ID
+ * unknown_post_id : unknown post
+ * not_subscribed : strange error. Jetpack servers at WordPress.com could subscribe the email.
+ * disabled : Site owner has disabled subscriptions.
+ * active : Already subscribed.
+ * pending : Tried to subscribe before but the confirmation link is never clicked. No confirmation email is sent.
+ * unknown : strange error. Jetpack servers at WordPress.com returned something malformed.
+ * unknown_status : strange error. Jetpack servers at WordPress.com returned something I didn't understand.
*/
- function subscribe( $email, $post_ids = 0, $async = true, $extra_data = array() ) {
- if ( !is_email( $email ) ) {
+ public function subscribe( $email, $post_ids = 0, $async = true, $extra_data = array() ) {
+ if ( ! is_email( $email ) ) {
return new WP_Error( 'invalid_email' );
}
- if ( !$async ) {
+ if ( ! $async ) {
$xml = new Jetpack_IXR_ClientMulticall();
}
@@ -544,14 +625,14 @@ class Jetpack_Subscriptions {
$post_id = (int) $post_id;
if ( $post_id < 0 ) {
return new WP_Error( 'invalid_post_id' );
- } else if ( $post_id && !$post = get_post( $post_id ) ) {
+ } elseif ( $post_id && ! get_post( $post_id ) ) {
return new WP_Error( 'unknown_post_id' );
}
if ( $async ) {
XMLRPC_Async_Call::add_call( 'jetpack.subscribeToSite', 0, $email, $post_id, serialize( $extra_data ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
} else {
- $xml->addCall( 'jetpack.subscribeToSite', $email, $post_id, serialize( $extra_data ) );
+ $xml->addCall( 'jetpack.subscribeToSite', $email, $post_id, serialize( $extra_data ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
}
}
@@ -559,7 +640,7 @@ class Jetpack_Subscriptions {
return;
}
- // Call
+ // Call.
$xml->query();
if ( $xml->isError() ) {
@@ -575,7 +656,7 @@ class Jetpack_Subscriptions {
continue;
}
- if ( !is_array( $response[0] ) || empty( $response[0]['status'] ) ) {
+ if ( ! is_array( $response[0] ) || empty( $response[0]['status'] ) ) {
$r[] = new WP_Error( 'unknown' );
continue;
}
@@ -610,33 +691,34 @@ class Jetpack_Subscriptions {
*
* When a user submits their email via the blog subscription widget, check the details and call the subsribe() method.
*/
- function widget_submit() {
+ public function widget_submit() {
// Check the nonce.
if ( is_user_logged_in() ) {
check_admin_referer( 'blogsub_subscribe_' . get_current_blog_id() );
}
- if ( empty( $_REQUEST['email'] ) || ! is_string( $_REQUEST['email'] ) )
+ if ( empty( $_REQUEST['email'] ) || ! is_string( $_REQUEST['email'] ) ) {
return false;
+ }
$redirect_fragment = false;
if ( isset( $_REQUEST['redirect_fragment'] ) ) {
- $redirect_fragment = preg_replace( '/[^a-z0-9_-]/i', '', $_REQUEST['redirect_fragment'] );
+ $redirect_fragment = preg_replace( '/[^a-z0-9_-]/i', '', $_REQUEST['redirect_fragment'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- This is manually unslashing and sanitizing.
}
- if ( !$redirect_fragment || ! is_string( $redirect_fragment ) ) {
+ if ( ! $redirect_fragment || ! is_string( $redirect_fragment ) ) {
$redirect_fragment = 'subscribe-blog';
}
- $subscribe = Jetpack_Subscriptions::subscribe(
- $_REQUEST['email'],
- 0,
- false,
- array(
- 'source' => 'widget',
- 'widget-in-use' => is_active_widget( false, false, 'blog_subscription', true ) ? 'yes' : 'no',
- 'comment_status' => '',
- 'server_data' => jetpack_subscriptions_cherry_pick_server_data(),
- )
+ $subscribe = self::subscribe(
+ isset( $_REQUEST['email'] ) ? wp_unslash( $_REQUEST['email'] ) : null, // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated inside self::subscribe().
+ 0,
+ false,
+ array(
+ 'source' => 'widget',
+ 'widget-in-use' => is_active_widget( false, false, 'blog_subscription', true ) ? 'yes' : 'no',
+ 'comment_status' => '',
+ 'server_data' => jetpack_subscriptions_cherry_pick_server_data(),
+ )
);
if ( is_wp_error( $subscribe ) ) {
@@ -698,9 +780,8 @@ class Jetpack_Subscriptions {
* Set up and add the comment subscription checkbox to the comment form.
*
* @param string $submit_button HTML markup for the submit field.
- * @param array $args Arguments passed to `comment_form()`.
*/
- function comment_subscribe_init( $submit_button, $args ) {
+ public function comment_subscribe_init( $submit_button ) {
global $post;
$comments_checked = '';
@@ -715,18 +796,18 @@ class Jetpack_Subscriptions {
$blog_checked = ' checked="checked"';
}
- // Some themes call this function, don't show the checkbox again
+ // Some themes call this function, don't show the checkbox again.
remove_action( 'comment_form', 'subscription_comment_form' );
- // Check if Mark Jaquith's Subscribe to Comments plugin is active - if so, suppress Jetpack checkbox
+ // Check if Mark Jaquith's Subscribe to Comments plugin is active - if so, suppress Jetpack checkbox.
$str = '';
- if ( FALSE === has_filter( 'comment_form', 'show_subscription_checkbox' ) && 1 == get_option( 'stc_enabled', 1 ) && empty( $post->post_password ) && 'post' == get_post_type() ) {
- // Subscribe to comments checkbox
- $str .= '<p class="comment-subscription-form"><input type="checkbox" name="subscribe_comments" id="subscribe_comments" value="subscribe" style="width: auto; -moz-appearance: checkbox; -webkit-appearance: checkbox;"' . $comments_checked . ' /> ';
+ if ( false === has_filter( 'comment_form', 'show_subscription_checkbox' ) && 1 === (int) get_option( 'stc_enabled', 1 ) && empty( $post->post_password ) && 'post' === get_post_type() ) {
+ // Subscribe to comments checkbox.
+ $str .= '<p class="comment-subscription-form"><input type="checkbox" name="subscribe_comments" id="subscribe_comments" value="subscribe" style="width: auto; -moz-appearance: checkbox; -webkit-appearance: checkbox;"' . $comments_checked . ' /> ';
$comment_sub_text = __( 'Notify me of follow-up comments by email.', 'jetpack' );
- $str .= '<label class="subscribe-label" id="subscribe-label" for="subscribe_comments">' . esc_html(
+ $str .= '<label class="subscribe-label" id="subscribe-label" for="subscribe_comments">' . esc_html(
/**
* Filter the Subscribe to comments text appearing below the comment form.
*
@@ -741,11 +822,11 @@ class Jetpack_Subscriptions {
$str .= '</p>';
}
- if ( 1 == get_option( 'stb_enabled', 1 ) ) {
- // Subscribe to blog checkbox
- $str .= '<p class="comment-subscription-form"><input type="checkbox" name="subscribe_blog" id="subscribe_blog" value="subscribe" style="width: auto; -moz-appearance: checkbox; -webkit-appearance: checkbox;"' . $blog_checked . ' /> ';
+ if ( 1 === (int) get_option( 'stb_enabled', 1 ) ) {
+ // Subscribe to blog checkbox.
+ $str .= '<p class="comment-subscription-form"><input type="checkbox" name="subscribe_blog" id="subscribe_blog" value="subscribe" style="width: auto; -moz-appearance: checkbox; -webkit-appearance: checkbox;"' . $blog_checked . ' /> ';
$blog_sub_text = __( 'Notify me of new posts by email.', 'jetpack' );
- $str .= '<label class="subscribe-label" id="subscribe-blog-label" for="subscribe_blog">' . esc_html(
+ $str .= '<label class="subscribe-label" id="subscribe-blog-label" for="subscribe_blog">' . esc_html(
/**
* Filter the Subscribe to blog text appearing below the comment form.
*
@@ -778,8 +859,11 @@ class Jetpack_Subscriptions {
* Jetpack_Subscriptions::comment_subscribe_init()
*
* When a user checks the comment subscribe box and submits a comment, subscribe them to the comment thread.
+ *
+ * @param int|string $comment_id Comment thread being subscribed to.
+ * @param string $approved Comment status.
*/
- function comment_subscribe_submit( $comment_id, $approved ) {
+ public function comment_subscribe_submit( $comment_id, $approved ) {
if ( 'spam' === $approved ) {
return;
}
@@ -789,30 +873,33 @@ class Jetpack_Subscriptions {
return;
}
- // Set cookies for this post/comment
- $this->set_cookies( isset( $_REQUEST['subscribe_comments'] ), $comment->comment_post_ID, isset( $_REQUEST['subscribe_blog'] ) );
+ // Set cookies for this post/comment.
+ $this->set_cookies( isset( $_REQUEST['subscribe_comments'] ), $comment->comment_post_ID, isset( $_REQUEST['subscribe_blog'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- if ( !isset( $_REQUEST['subscribe_comments'] ) && !isset( $_REQUEST['subscribe_blog'] ) )
+ if ( ! isset( $_REQUEST['subscribe_comments'] ) && ! isset( $_REQUEST['subscribe_blog'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return;
+ }
$post_ids = array();
- if ( isset( $_REQUEST['subscribe_comments'] ) )
+ if ( isset( $_REQUEST['subscribe_comments'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$post_ids[] = $comment->comment_post_ID;
+ }
- if ( isset( $_REQUEST['subscribe_blog'] ) )
+ if ( isset( $_REQUEST['subscribe_blog'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$post_ids[] = 0;
+ }
- $result = Jetpack_Subscriptions::subscribe(
- $comment->comment_author_email,
- $post_ids,
- true,
- array(
- 'source' => 'comment-form',
- 'widget-in-use' => is_active_widget( false, false, 'blog_subscription', true ) ? 'yes' : 'no',
- 'comment_status' => $approved,
- 'server_data' => jetpack_subscriptions_cherry_pick_server_data(),
- )
+ $result = self::subscribe(
+ $comment->comment_author_email,
+ $post_ids,
+ true,
+ array(
+ 'source' => 'comment-form',
+ 'widget-in-use' => is_active_widget( false, false, 'blog_subscription', true ) ? 'yes' : 'no',
+ 'comment_status' => $approved,
+ 'server_data' => jetpack_subscriptions_cherry_pick_server_data(),
+ )
);
/**
@@ -834,14 +921,14 @@ class Jetpack_Subscriptions {
* Set a cookie to save state on the comment and post subscription checkboxes.
*
* @param bool $subscribe_to_post Whether the user chose to subscribe to subsequent comments on this post.
- * @param int $post_id If $subscribe_to_post is true, the post ID they've subscribed to.
+ * @param int $post_id If $subscribe_to_post is true, the post ID they've subscribed to.
* @param bool $subscribe_to_blog Whether the user chose to subscribe to all new posts on the blog.
*/
- function set_cookies( $subscribe_to_post = false, $post_id = null, $subscribe_to_blog = false ) {
+ public function set_cookies( $subscribe_to_post = false, $post_id = null, $subscribe_to_blog = false ) {
$post_id = (int) $post_id;
/** This filter is already documented in core/wp-includes/comment-functions.php */
- $cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
+ $cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
/**
* Filter the Jetpack Comment cookie path.
@@ -852,7 +939,7 @@ class Jetpack_Subscriptions {
*
* @param string COOKIEPATH Cookie path.
*/
- $cookie_path = apply_filters( 'jetpack_comment_cookie_path', COOKIEPATH );
+ $cookie_path = apply_filters( 'jetpack_comment_cookie_path', COOKIEPATH );
/**
* Filter the Jetpack Comment cookie domain.
@@ -863,18 +950,18 @@ class Jetpack_Subscriptions {
*
* @param string COOKIE_DOMAIN Cookie domain.
*/
- $cookie_domain = apply_filters( 'jetpack_comment_cookie_domain', COOKIE_DOMAIN );
+ $cookie_domain = apply_filters( 'jetpack_comment_cookie_domain', COOKIE_DOMAIN );
if ( $subscribe_to_post && $post_id >= 0 ) {
- setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, 1, time() + $cookie_lifetime, $cookie_path, $cookie_domain );
+ setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, 1, time() + $cookie_lifetime, $cookie_path, $cookie_domain, is_ssl(), true );
} else {
- setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, '', time() - 3600, $cookie_path, $cookie_domain );
+ setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, '', time() - 3600, $cookie_path, $cookie_domain, is_ssl(), true );
}
if ( $subscribe_to_blog ) {
- setcookie( 'jetpack_blog_subscribe_' . self::$hash, 1, time() + $cookie_lifetime, $cookie_path, $cookie_domain );
+ setcookie( 'jetpack_blog_subscribe_' . self::$hash, 1, time() + $cookie_lifetime, $cookie_path, $cookie_domain, is_ssl(), true );
} else {
- setcookie( 'jetpack_blog_subscribe_' . self::$hash, '', time() - 3600, $cookie_path, $cookie_domain );
+ setcookie( 'jetpack_blog_subscribe_' . self::$hash, '', time() - 3600, $cookie_path, $cookie_domain, is_ssl(), true );
}
}
@@ -883,9 +970,9 @@ class Jetpack_Subscriptions {
*
* @since 8.1
*
- * @return null
+ * @return void
*/
- function set_social_notifications_subscribe() {
+ public function set_social_notifications_subscribe() {
if ( false === get_option( 'social_notifications_subscribe' ) ) {
add_option( 'social_notifications_subscribe', 'off' );
}
@@ -895,4 +982,4 @@ class Jetpack_Subscriptions {
Jetpack_Subscriptions::init();
-include dirname( __FILE__ ) . '/subscriptions/views.php';
+require __DIR__ . '/subscriptions/views.php';
diff --git a/plugins/jetpack/modules/subscriptions/views.php b/plugins/jetpack/modules/subscriptions/views.php
index 85806e74..f1518587 100644
--- a/plugins/jetpack/modules/subscriptions/views.php
+++ b/plugins/jetpack/modules/subscriptions/views.php
@@ -1,13 +1,23 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Jetpack_Subscriptions_Widget main view class.
+ */
class Jetpack_Subscriptions_Widget extends WP_Widget {
const ID_BASE = 'blog_subscription';
- static $instance_count = 0;
+ /**
+ * Track number of rendered Subscription widgets. The count is used for class names and widget IDs.
+ *
+ * @var int
+ */
+ public static $instance_count = 0;
/**
- * @var array When printing the submit button, what tags are allowed
+ * When printing the submit button, what tags are allowed.
+ *
+ * @var array
*/
public static $allowed_html_tags_for_submit_button = array(
'br' => array(),
@@ -31,7 +41,10 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
'br' => array(),
);
- function __construct() {
+ /**
+ * Jetpack_Subscriptions_Widget constructor.
+ */
+ public function __construct() {
$widget_ops = array(
'classname' => 'widget_blog_subscription jetpack_subscription_widget',
'description' => __( 'Add an email signup form to allow people to subscribe to your blog.', 'jetpack' ),
@@ -51,11 +64,11 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
);
if ( self::is_jetpack() &&
- (
- is_active_widget( false, false, $this->id_base ) ||
- is_active_widget( false, false, 'monster' ) ||
- is_customize_preview()
- )
+ (
+ is_active_widget( false, false, $this->id_base ) ||
+ is_active_widget( false, false, 'monster' ) ||
+ is_customize_preview()
+ )
) {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) );
}
@@ -95,10 +108,10 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
* @param array $args Display arguments including 'before_title', 'after_title', 'before_widget', and 'after_widget'.
* @param array $instance The settings for the particular instance of the widget.
*/
- function widget( $args, $instance ) {
+ public function widget( $args, $instance ) {
if ( self::is_jetpack() &&
- /** This filter is documented in modules/contact-form/grunion-contact-form.php */
- false === apply_filters( 'jetpack_auto_fill_logged_in_user', false )
+ /** This filter is documented in modules/contact-form/grunion-contact-form.php */
+ false === apply_filters( 'jetpack_auto_fill_logged_in_user', false )
) {
$subscribe_email = '';
} else {
@@ -118,9 +131,9 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
$before_widget = isset( $args['before_widget'] ) ? $args['before_widget'] : '';
$instance = wp_parse_args( (array) $instance, $this->defaults() );
- echo $before_widget;
+ echo $before_widget; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- Jetpack_Subscriptions_Widget::$instance_count ++;
+ self::$instance_count ++;
self::render_widget_title( $args, $instance );
@@ -128,7 +141,7 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
self::render_widget_subscription_form( $args, $instance, $subscribe_email );
- echo "\n" . $after_widget;
+ echo "\n" . $after_widget; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
@@ -137,7 +150,7 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
* @param array $args Display arguments including 'before_title', 'after_title', 'before_widget', and 'after_widget'.
* @param array $instance The settings for the particular instance of the widget.
*/
- static function render_widget_title( $args, $instance ) {
+ public static function render_widget_title( $args, $instance ) {
$show_only_email_and_button = $instance['show_only_email_and_button'];
$before_title = isset( $args['before_title'] ) ? $args['before_title'] : '';
$after_title = isset( $args['after_title'] ) ? $args['after_title'] : '';
@@ -164,26 +177,50 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
*
* @param array $instance The settings for the particular instance of the widget.
*/
- static function render_widget_status_messages( $instance ) {
- if ( self::is_jetpack() && isset( $_GET['subscribe'] ) ) {
+ public static function render_widget_status_messages( $instance ) {
+ if ( self::is_jetpack() && isset( $_GET['subscribe'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Non-sensitive informational output.
$success_message = isset( $instance['success_message'] ) ? stripslashes( $instance['success_message'] ) : '';
$subscribers_total = self::fetch_subscriber_count();
- switch ( $_GET['subscribe'] ) :
- case 'invalid_email' : ?>
- <p class="error"><?php esc_html_e( 'The email you entered was invalid. Please check and try again.', 'jetpack' ); ?></p>
- <?php break;
- case 'opted_out' : ?>
- <p class="error"><?php printf( __( 'The email address has opted out of subscription emails. <br /> You can manage your preferences at <a href="%1$s" title="%2$s" target="_blank">subscribe.wordpress.com</a>', 'jetpack' ),
- 'https://subscribe.wordpress.com/',
- __( 'Manage your email preferences.', 'jetpack' )
- ); ?></p>
- <?php break;
- case 'already' : ?>
- <p class="error"><?php printf( __( 'You have already subscribed to this site. Please check your inbox. <br /> You can manage your preferences at <a href="%1$s" title="%2$s" target="_blank">subscribe.wordpress.com</a>', 'jetpack' ),
- 'https://subscribe.wordpress.com/',
- __( 'Manage your email preferences.', 'jetpack' )
- ); ?></p>
- <?php break;
+ switch ( $_GET['subscribe'] ) : // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ case 'invalid_email':
+ ?>
+ <p class="error"><?php esc_html_e( 'The email you entered was invalid. Please check and try again.', 'jetpack' ); ?></p>
+ <?php
+ break;
+ case 'opted_out':
+ ?>
+ <p class="error">
+ <?php
+ printf(
+ wp_kses(
+ /* translators: 1: Link to Subscription Management page https://subscribe.wordpress.com/, 2: Description of this link. */
+ __( 'The email address has opted out of subscription emails. <br /> You can manage your preferences at <a href="%1$s" title="%2$s" target="_blank">subscribe.wordpress.com</a>', 'jetpack' ),
+ self::$allowed_html_tags_for_message
+ ),
+ 'https://subscribe.wordpress.com/',
+ esc_attr__( 'Manage your email preferences.', 'jetpack' )
+ );
+ ?>
+ </p>
+ <?php
+ break;
+ case 'already':
+ ?>
+ <p class="error">
+ <?php
+ printf(
+ wp_kses(
+ /* translators: 1: Link to Subscription Management page https://subscribe.wordpress.com/, 2: Description of this link. */
+ __( 'You have already subscribed to this site. Please check your inbox. <br /> You can manage your preferences at <a href="%1$s" title="%2$s" target="_blank">subscribe.wordpress.com</a>', 'jetpack' ),
+ self::$allowed_html_tags_for_message
+ ),
+ 'https://subscribe.wordpress.com/',
+ esc_attr__( 'Manage your email preferences.', 'jetpack' )
+ );
+ ?>
+ </p>
+ <?php
+ break;
case 'many_pending_subs':
?>
<p class="error">
@@ -199,7 +236,8 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
);
?>
</p>
- <?php break;
+ <?php
+ break;
case 'pending':
?>
<p class="error">
@@ -207,7 +245,7 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
printf(
wp_kses(
/* translators: 1: Link to Subscription Management page https://subscribe.wordpress.com/, 2: Description of this link */
- __( 'You subscribed this site before but you have not clicked the confirmation link yet. Please check your inbox. <br /> Otherwise, you can manage your preferences at <a href="%1$s" title="%2$s" target="_blank" rel="noopener noreferrer">subscribe.wordpress.com</a>.', 'jetpack' ),
+ __( 'You subscribed to this site before but you have not clicked the confirmation link yet. Please check your inbox. <br /> Otherwise, you can manage your preferences at <a href="%1$s" title="%2$s" target="_blank" rel="noopener noreferrer">subscribe.wordpress.com</a>.', 'jetpack' ),
self::$allowed_html_tags_for_message
),
'https://subscribe.wordpress.com/',
@@ -217,12 +255,16 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
</p>
<?php
break;
- case 'success' : ?>
- <div class="success"><?php echo wpautop( str_replace( '[total-subscribers]', number_format_i18n( $subscribers_total['value'] ), $success_message ) ); ?></div>
- <?php break;
- default : ?>
- <p class="error"><?php esc_html_e( 'There was an error when subscribing. Please try again.', 'jetpack' ); ?></p>
- <?php break;
+ case 'success':
+ ?>
+ <div class="success"><?php echo wp_kses( wpautop( str_replace( '[total-subscribers]', number_format_i18n( $subscribers_total['value'] ), $success_message ) ), 'post' ); ?></div>
+ <?php
+ break;
+ default:
+ ?>
+ <p class="error"><?php esc_html_e( 'There was an error when subscribing. Please try again.', 'jetpack' ); ?></p>
+ <?php
+ break;
endswitch;
}
@@ -230,7 +272,7 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
global $themecolors;
$message = '';
- switch ( $_GET['blogsub'] ) {
+ switch ( $_GET['blogsub'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
case 'confirming':
$message = __( 'Thanks for subscribing! You&rsquo;ll get an email with a link to confirm your subscription. If you don&rsquo;t get it, please <a href="https://en.support.wordpress.com/contact/">contact us</a>.', 'jetpack' );
break;
@@ -273,7 +315,7 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
* @param string $id is the specific id that will appear in the redirect fragment. If none is provided self::$instance_count will be used.
*/
protected static function get_redirect_fragment( $id = null ) {
- if ( is_null( $id ) ) {
+ if ( $id === null ) {
return 'subscribe-blog' . ( self::$instance_count > 1 ? '-' . self::$instance_count : '' );
}
@@ -283,17 +325,17 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
/**
* Renders a form allowing folks to subscribe to the blog.
*
- * @param array $args Display arguments including 'before_title', 'after_title', 'before_widget', and 'after_widget'.
- * @param array $instance The settings for the particular instance of the widget.
+ * @param array $args Display arguments including 'before_title', 'after_title', 'before_widget', and 'after_widget'.
+ * @param array $instance The settings for the particular instance of the widget.
* @param string $subscribe_email The email to use to prefill the form.
*/
- static function render_widget_subscription_form( $args, $instance, $subscribe_email ) {
+ public static function render_widget_subscription_form( $args, $instance, $subscribe_email ) {
$show_only_email_and_button = $instance['show_only_email_and_button'];
$show_subscribers_total = (bool) $instance['show_subscribers_total'];
$subscribe_text = empty( $instance['show_only_email_and_button'] ) ?
stripslashes( $instance['subscribe_text'] ) :
false;
- $referer = ( is_ssl() ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+ $referer = esc_url_raw( ( is_ssl() ? 'https' : 'http' ) . '://' . ( isset( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : '' ) . ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '' ) );
$source = 'widget';
$widget_id = ! empty( $args['widget_id'] ) ? $args['widget_id'] : self::$instance_count;
$subscribe_button = ! empty( $instance['submit_button_text'] ) ? $instance['submit_button_text'] : $instance['subscribe_button'];
@@ -378,31 +420,31 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
<p id="subscribe-submit"
<?php if ( ! empty( $submit_button_wrapper_styles ) ) { ?>
style="<?php echo esc_attr( $submit_button_wrapper_styles ); ?>"
- <?php }; ?>
+ <?php } ?>
>
- <input type="hidden" name="action" value="subscribe"/>
- <input type="hidden" name="blog_id" value="<?php echo (int) $current_blog->blog_id; ?>"/>
- <input type="hidden" name="source" value="<?php echo esc_url( $referer ); ?>"/>
- <input type="hidden" name="sub-type" value="<?php echo esc_attr( $source ); ?>"/>
+ <input type="hidden" name="action" value="subscribe"/>
+ <input type="hidden" name="blog_id" value="<?php echo (int) $current_blog->blog_id; ?>"/>
+ <input type="hidden" name="source" value="<?php echo esc_url( $referer ); ?>"/>
+ <input type="hidden" name="sub-type" value="<?php echo esc_attr( $source ); ?>"/>
<input type="hidden" name="redirect_fragment" value="<?php echo esc_attr( $form_id ); ?>"/>
<?php wp_nonce_field( 'blogsub_subscribe_' . $current_blog->blog_id, '_wpnonce', false ); ?>
- <button type="submit"
- <?php if ( ! empty( $submit_button_classes ) ) { ?>
- class="<?php echo esc_attr( $submit_button_classes ); ?>"
- <?php }; ?>
- <?php if ( ! empty( $submit_button_styles ) ) { ?>
- style="<?php echo esc_attr( $submit_button_styles ); ?>"
- <?php }; ?>
- >
- <?php
- echo wp_kses(
- $subscribe_button,
- self::$allowed_html_tags_for_submit_button
- );
- ?>
- </button>
- </p>
- </form>
+ <button type="submit"
+ <?php if ( ! empty( $submit_button_classes ) ) { ?>
+ class="<?php echo esc_attr( $submit_button_classes ); ?>"
+ <?php } ?>
+ <?php if ( ! empty( $submit_button_styles ) ) { ?>
+ style="<?php echo esc_attr( $submit_button_styles ); ?>"
+ <?php } ?>
+ >
+ <?php
+ echo wp_kses(
+ $subscribe_button,
+ self::$allowed_html_tags_for_submit_button
+ );
+ ?>
+ </button>
+ </p>
+ </form>
<?php
}
@@ -423,9 +465,10 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
?>
<form action="#" method="post" accept-charset="utf-8" id="<?php echo esc_attr( $form_id ); ?>">
<?php
- if ( $subscribe_text && ( ! isset ( $_GET['subscribe'] ) || 'success' != $_GET['subscribe'] ) ) {
+ if ( $subscribe_text && ( ! isset( $_GET['subscribe'] ) || 'success' !== $_GET['subscribe'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Non-sensitive informational output.
?>
- <div id="subscribe-text"><?php echo wpautop( str_replace( '[total-subscribers]', number_format_i18n( $subscribers_total['value'] ), $subscribe_text ) ); ?></div><?php
+ <div id="subscribe-text"><?php echo wp_kses( wpautop( str_replace( '[total-subscribers]', number_format_i18n( $subscribers_total['value'] ), $subscribe_text ) ), 'post' ); ?></div>
+ <?php
}
if ( $show_subscribers_total && 0 < $subscribers_total['value'] ) {
@@ -440,59 +483,62 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
</div>
<?php
}
- if ( ! isset ( $_GET['subscribe'] ) || 'success' != $_GET['subscribe'] ) { ?>
- <p id="subscribe-email">
- <label id="jetpack-subscribe-label"
+ if ( ! isset( $_GET['subscribe'] ) || 'success' !== $_GET['subscribe'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display of unsubmitted form.
+ ?>
+ <p id="subscribe-email">
+ <label id="jetpack-subscribe-label"
class="screen-reader-text"
for="<?php echo esc_attr( $subscribe_field_id . '-' . $widget_id ); ?>">
<?php echo ! empty( $subscribe_placeholder ) ? esc_html( $subscribe_placeholder ) : esc_html__( 'Email Address:', 'jetpack' ); ?>
- </label>
- <input type="email" name="email" required="required"
- <?php if ( ! empty( $email_field_classes ) ) { ?>
- class="<?php echo esc_attr( $email_field_classes ); ?> required"
- <?php }; ?>
- <?php if ( ! empty( $email_field_styles ) ) { ?>
- style="<?php echo esc_attr( $email_field_styles ); ?>"
- <?php }; ?>
- value="<?php echo esc_attr( $subscribe_email ); ?>"
+ </label>
+ <input type="email" name="email" required="required"
+ <?php if ( ! empty( $email_field_classes ) ) { ?>
+ class="<?php echo esc_attr( $email_field_classes ); ?> required"
+ <?php } ?>
+ <?php if ( ! empty( $email_field_styles ) ) { ?>
+ style="<?php echo esc_attr( $email_field_styles ); ?>"
+ <?php } ?>
+ value="<?php echo esc_attr( $subscribe_email ); ?>"
id="<?php echo esc_attr( $subscribe_field_id . '-' . $widget_id ); ?>"
- placeholder="<?php echo esc_attr( $subscribe_placeholder ); ?>"
- />
- </p>
+ placeholder="<?php echo esc_attr( $subscribe_placeholder ); ?>"
+ />
+ </p>
<p id="subscribe-submit"
<?php if ( ! empty( $submit_button_wrapper_styles ) ) { ?>
style="<?php echo esc_attr( $submit_button_wrapper_styles ); ?>"
- <?php }; ?>
+ <?php } ?>
>
- <input type="hidden" name="action" value="subscribe"/>
- <input type="hidden" name="source" value="<?php echo esc_url( $referer ); ?>"/>
- <input type="hidden" name="sub-type" value="<?php echo esc_attr( $source ); ?>"/>
+ <input type="hidden" name="action" value="subscribe"/>
+ <input type="hidden" name="source" value="<?php echo esc_url( $referer ); ?>"/>
+ <input type="hidden" name="sub-type" value="<?php echo esc_attr( $source ); ?>"/>
<input type="hidden" name="redirect_fragment" value="<?php echo esc_attr( $form_id ); ?>"/>
<?php
if ( is_user_logged_in() ) {
wp_nonce_field( 'blogsub_subscribe_' . get_current_blog_id(), '_wpnonce', false );
}
?>
- <button type="submit"
- <?php if ( ! empty( $submit_button_classes ) ) { ?>
- class="<?php echo esc_attr( $submit_button_classes ); ?>"
- <?php }; ?>
- <?php if ( ! empty( $submit_button_styles ) ) { ?>
- style="<?php echo esc_attr( $submit_button_styles ); ?>"
- <?php }; ?>
- name="jetpack_subscriptions_widget"
- >
- <?php
- echo wp_kses(
- $subscribe_button,
- self::$allowed_html_tags_for_submit_button
- ); ?>
- </button>
- </p>
+ <button type="submit"
+ <?php if ( ! empty( $submit_button_classes ) ) { ?>
+ class="<?php echo esc_attr( $submit_button_classes ); ?>"
+ <?php } ?>
+ <?php if ( ! empty( $submit_button_styles ) ) { ?>
+ style="<?php echo esc_attr( $submit_button_styles ); ?>"
+ <?php } ?>
+ name="jetpack_subscriptions_widget"
+ >
+ <?php
+ echo wp_kses(
+ $subscribe_button,
+ self::$allowed_html_tags_for_submit_button
+ );
+ ?>
+ </button>
+ </p>
<?php } ?>
- </form>
- <?php }
+ </form>
+ <?php
+ }
}
/**
@@ -500,8 +546,8 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
*
* @return bool Is the person already subscribed.
*/
- static function is_current_user_subscribed() {
- $subscribed = isset( $_GET['subscribe'] ) && 'success' == $_GET['subscribe'];
+ public static function is_current_user_subscribed() {
+ $subscribed = isset( $_GET['subscribe'] ) && 'success' === $_GET['subscribe']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( self::is_wpcom() && class_exists( 'Blog_Subscription' ) && class_exists( 'Blog_Subscriber' ) ) {
$subscribed = is_user_logged_in() && Blog_Subscription::is_subscribed( new Blog_Subscriber() );
@@ -515,7 +561,7 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
*
* @return bool
*/
- static function is_wpcom() {
+ public static function is_wpcom() {
return defined( 'IS_WPCOM' ) && IS_WPCOM;
}
@@ -524,7 +570,7 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
*
* @return bool
*/
- static function is_jetpack() {
+ public static function is_jetpack() {
return ! self::is_wpcom();
}
@@ -533,20 +579,21 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
*
* @return bool
*/
- static function wpcom_has_status_message() {
- return isset( $_GET['blogsub'] ) &&
- in_array(
- $_GET['blogsub'],
- array(
- 'confirming',
- 'blocked',
- 'flooded',
- 'spammed',
- 'subscribed',
- 'pending',
- 'confirmed',
- )
- );
+ public static function wpcom_has_status_message() {
+ return isset( $_GET['blogsub'] ) && // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ in_array(
+ $_GET['blogsub'], // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ array(
+ 'confirming',
+ 'blocked',
+ 'flooded',
+ 'spammed',
+ 'subscribed',
+ 'pending',
+ 'confirmed',
+ ),
+ true
+ );
}
/**
@@ -554,17 +601,17 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
*
* @return int|array
*/
- static function fetch_subscriber_count() {
+ public static function fetch_subscriber_count() {
$subs_count = 0;
if ( self::is_jetpack() ) {
$subs_count = get_transient( 'wpcom_subscribers_total' );
- if ( false === $subs_count || 'failed' == $subs_count['status'] ) {
+ if ( false === $subs_count || 'failed' === $subs_count['status'] ) {
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.fetchSubscriberCount' );
- if ( $xml->isError() ) { // if we get an error from .com, set the status to failed so that we will try again next time the data is requested
+ if ( $xml->isError() ) { // If we get an error from .com, set the status to failed so that we will try again next time the data is requested.
$subs_count = array(
'status' => 'failed',
'code' => $xml->getErrorCode(),
@@ -578,7 +625,7 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
);
}
- set_transient( 'wpcom_subscribers_total', $subs_count, 3600 ); // try to cache the result for at least 1 hour
+ set_transient( 'wpcom_subscribers_total', $subs_count, 3600 ); // Try to cache the result for at least 1 hour.
}
}
@@ -592,12 +639,12 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
/**
* Updates a particular instance of a widget when someone saves it in wp-admin.
*
- * @param array $new_instance
- * @param array $old_instance
+ * @param array $new_instance New widget instance settings.
+ * @param array $old_instance Old widget instance settings.
*
* @return array
*/
- function update( $new_instance, $old_instance ) {
+ public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
if ( self::is_jetpack() ) {
@@ -608,10 +655,10 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
}
if ( self::is_wpcom() ) {
- $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) );
- $instance['title_following'] = strip_tags( stripslashes( $new_instance['title_following'] ) );
+ $instance['title'] = wp_strip_all_tags( stripslashes( $new_instance['title'] ) );
+ $instance['title_following'] = wp_strip_all_tags( stripslashes( $new_instance['title_following'] ) );
$instance['subscribe_logged_in'] = wp_filter_post_kses( stripslashes( $new_instance['subscribe_logged_in'] ) );
- $instance['subscribe_button'] = strip_tags( stripslashes( $new_instance['subscribe_button'] ) );
+ $instance['subscribe_button'] = wp_strip_all_tags( stripslashes( $new_instance['subscribe_button'] ) );
}
$instance['show_subscribers_total'] = isset( $new_instance['show_subscribers_total'] ) && $new_instance['show_subscribers_total'];
@@ -626,10 +673,10 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
*
* @return array
*/
- static function defaults() {
+ public static function defaults() {
$defaults = array(
'show_subscribers_total' => true,
- 'show_only_email_and_button' => false
+ 'show_only_email_and_button' => false,
);
$defaults['title'] = esc_html__( 'Subscribe to Blog via Email', 'jetpack' );
@@ -644,13 +691,12 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
/**
* Renders the widget's options form in wp-admin.
*
- * @param array $instance
+ * @param array $instance Widget instance.
*/
- function form( $instance ) {
+ public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, $this->defaults() );
$show_subscribers_total = checked( $instance['show_subscribers_total'], true, false );
-
if ( self::is_wpcom() ) {
$title = esc_attr( stripslashes( $instance['title'] ) );
$title_following = esc_attr( stripslashes( $instance['title_following'] ) );
@@ -667,113 +713,123 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
$subscribe_button = stripslashes( $instance['subscribe_button'] );
$success_message = stripslashes( $instance['success_message'] );
$subs_fetch = self::fetch_subscriber_count();
- if ( 'failed' == $subs_fetch['status'] ) {
+ if ( 'failed' === $subs_fetch['status'] ) {
printf( '<div class="error inline"><p>%s: %s</p></div>', esc_html( $subs_fetch['code'] ), esc_html( $subs_fetch['message'] ) );
}
$subscribers_total = number_format_i18n( $subs_fetch['value'] );
}
- if ( self::is_wpcom() ) : ?>
- <p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>">
- <?php _e( 'Widget title for non-followers:' ); ?>
- <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>"
- name="<?php echo $this->get_field_name( 'title' ); ?>" type="text"
- value="<?php echo $title; ?>"/>
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'title_following' ); ?>">
- <?php _e( 'Widget title for followers:' ); ?>
- <input class="widefat" id="<?php echo $this->get_field_id( 'title_following' ); ?>"
- name="<?php echo $this->get_field_name( 'title_following' ); ?>" type="text"
- value="<?php echo $title_following; ?>"/>
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'subscribe_logged_in' ); ?>">
- <?php _e( 'Optional text to display to logged in WordPress.com users:' ); ?>
- <textarea style="width: 95%" id="<?php echo $this->get_field_id( 'subscribe_logged_in' ); ?>"
- name="<?php echo $this->get_field_name( 'subscribe_logged_in' ); ?>"
- type="text"><?php echo $subscribe_logged_in; ?></textarea>
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'subscribe_text' ); ?>">
- <?php _e( 'Optional text to display to non-WordPress.com users:' ); ?>
- <textarea style="width: 95%" id="<?php echo $this->get_field_id( 'subscribe_text' ); ?>"
- name="<?php echo $this->get_field_name( 'subscribe_text' ); ?>"
- type="text"><?php echo $subscribe_text; ?></textarea>
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'subscribe_button' ); ?>">
- <?php _e( 'Follow Button Text:' ); ?>
- <input class="widefat" id="<?php echo $this->get_field_id( 'subscribe_button' ); ?>"
- name="<?php echo $this->get_field_name( 'subscribe_button' ); ?>" type="text"
- value="<?php echo $subscribe_button; ?>"/>
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'show_subscribers_total' ); ?>">
- <input type="checkbox" id="<?php echo $this->get_field_id( 'show_subscribers_total' ); ?>"
- name="<?php echo $this->get_field_name( 'show_subscribers_total' ); ?>"
- value="1"<?php echo $show_subscribers_total; ?> />
- <?php echo esc_html( sprintf( _n( 'Show total number of followers? (%s follower)', 'Show total number of followers? (%s followers)', $subscribers_total ), number_format_i18n( $subscribers_total ) ) ); ?>
- </label>
- </p>
- <?php endif;
-
- if ( self::is_jetpack() ) : ?>
- <p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>">
- <?php _e( 'Widget title:', 'jetpack' ); ?>
- <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>"
- name="<?php echo $this->get_field_name( 'title' ); ?>" type="text"
- value="<?php echo esc_attr( $title ); ?>"/>
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'subscribe_text' ); ?>">
- <?php _e( 'Optional text to display to your readers:', 'jetpack' ); ?>
- <textarea class="widefat" id="<?php echo $this->get_field_id( 'subscribe_text' ); ?>"
- name="<?php echo $this->get_field_name( 'subscribe_text' ); ?>"
- rows="3"><?php echo esc_html( $subscribe_text ); ?></textarea>
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'subscribe_placeholder' ); ?>">
+ if ( self::is_wpcom() ) :
+ ?>
+ <p>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
+ <?php esc_html_e( 'Widget title for non-followers:', 'jetpack' ); ?>
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text"
+ value="<?php echo esc_attr( $title ); ?>"/>
+ </label>
+ </p>
+ <p>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title_following' ) ); ?>">
+ <?php esc_html_e( 'Widget title for followers:', 'jetpack' ); ?>
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title_following' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'title_following' ) ); ?>" type="text"
+ value="<?php echo esc_attr( $title_following ); ?>"/>
+ </label>
+ </p>
+ <p>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'subscribe_logged_in' ) ); ?>">
+ <?php esc_html_e( 'Optional text to display to logged in WordPress.com users:', 'jetpack' ); ?>
+ <textarea style="width: 95%" id="<?php echo esc_attr( $this->get_field_id( 'subscribe_logged_in' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'subscribe_logged_in' ) ); ?>"
+ type="text"><?php echo esc_html( $subscribe_logged_in ); ?></textarea>
+ </label>
+ </p>
+ <p>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'subscribe_text' ) ); ?>">
+ <?php esc_html_e( 'Optional text to display to non-WordPress.com users:', 'jetpack' ); ?>
+ <textarea style="width: 95%" id="<?php echo esc_attr( $this->get_field_id( 'subscribe_text' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'subscribe_text' ) ); ?>"
+ type="text"><?php echo esc_html( $subscribe_text ); ?></textarea>
+ </label>
+ </p>
+ <p>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'subscribe_button' ) ); ?>">
+ <?php esc_html_e( 'Follow Button Text:', 'jetpack' ); ?>
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'subscribe_button' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'subscribe_button' ) ); ?>" type="text"
+ value="<?php echo esc_attr( $subscribe_button ); ?>"/>
+ </label>
+ </p>
+ <p>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_subscribers_total' ) ); ?>">
+ <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'show_subscribers_total' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'show_subscribers_total' ) ); ?>"
+ value="1"<?php echo esc_attr( $show_subscribers_total ); ?> />
+ <?php
+ /* translators: %s: Number of followers. */
+ echo esc_html( sprintf( _n( 'Show total number of followers? (%s follower)', 'Show total number of followers? (%s followers)', $subscribers_total, 'jetpack' ), number_format_i18n( $subscribers_total ) ) );
+ ?>
+ </label>
+ </p>
+ <?php
+ endif;
+
+ if ( self::is_jetpack() ) :
+ ?>
+ <p>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
+ <?php esc_html_e( 'Widget title:', 'jetpack' ); ?>
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text"
+ value="<?php echo esc_attr( $title ); ?>"/>
+ </label>
+ </p>
+ <p>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'subscribe_text' ) ); ?>">
+ <?php esc_html_e( 'Optional text to display to your readers:', 'jetpack' ); ?>
+ <textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'subscribe_text' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'subscribe_text' ) ); ?>"
+ rows="3"><?php echo esc_html( $subscribe_text ); ?></textarea>
+ </label>
+ </p>
+ <p>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'subscribe_placeholder' ) ); ?>">
<?php esc_html_e( 'Subscribe Placeholder:', 'jetpack' ); ?>
- <input class="widefat" id="<?php echo $this->get_field_id( 'subscribe_placeholder' ); ?>"
- name="<?php echo $this->get_field_name( 'subscribe_placeholder' ); ?>" type="text"
- value="<?php echo esc_attr( $subscribe_placeholder ); ?>"/>
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'subscribe_button' ); ?>">
- <?php _e( 'Subscribe Button:', 'jetpack' ); ?>
- <input class="widefat" id="<?php echo $this->get_field_id( 'subscribe_button' ); ?>"
- name="<?php echo $this->get_field_name( 'subscribe_button' ); ?>" type="text"
- value="<?php echo esc_attr( $subscribe_button ); ?>"/>
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'success_message' ); ?>">
- <?php _e( 'Success Message Text:', 'jetpack' ); ?>
- <textarea class="widefat" id="<?php echo $this->get_field_id( 'success_message' ); ?>"
- name="<?php echo $this->get_field_name( 'success_message' ); ?>"
- rows="5"><?php echo esc_html( $success_message ); ?></textarea>
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'show_subscribers_total' ); ?>">
- <input type="checkbox" id="<?php echo $this->get_field_id( 'show_subscribers_total' ); ?>"
- name="<?php echo $this->get_field_name( 'show_subscribers_total' ); ?>"
- value="1"<?php echo $show_subscribers_total; ?> />
- <?php echo esc_html( sprintf( _n( 'Show total number of subscribers? (%s subscriber)', 'Show total number of subscribers? (%s subscribers)', $subscribers_total, 'jetpack' ), $subscribers_total ) ); ?>
- </label>
- </p>
- <?php endif;
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'subscribe_placeholder' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'subscribe_placeholder' ) ); ?>" type="text"
+ value="<?php echo esc_attr( $subscribe_placeholder ); ?>"/>
+ </label>
+ </p>
+ <p>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'subscribe_button' ) ); ?>">
+ <?php esc_html_e( 'Subscribe Button:', 'jetpack' ); ?>
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'subscribe_button' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'subscribe_button' ) ); ?>" type="text"
+ value="<?php echo esc_attr( $subscribe_button ); ?>"/>
+ </label>
+ </p>
+ <p>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'success_message' ) ); ?>">
+ <?php esc_html_e( 'Success Message Text:', 'jetpack' ); ?>
+ <textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'success_message' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'success_message' ) ); ?>"
+ rows="5"><?php echo esc_html( $success_message ); ?></textarea>
+ </label>
+ </p>
+ <p>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_subscribers_total' ) ); ?>">
+ <input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'show_subscribers_total' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'show_subscribers_total' ) ); ?>"
+ value="1"<?php echo esc_attr( $show_subscribers_total ); ?> />
+ <?php
+ /* translators: %s: Number of subscribers. */
+ echo esc_html( sprintf( _n( 'Show total number of subscribers? (%s subscriber)', 'Show total number of subscribers? (%s subscribers)', $subscribers_total, 'jetpack' ), $subscribers_total ) );
+ ?>
+ </label>
+ </p>
+ <?php
+ endif;
}
}
@@ -781,12 +837,22 @@ if ( defined( 'IS_WPCOM' ) && IS_WPCOM && function_exists( 'class_alias' ) ) {
class_alias( 'Jetpack_Subscriptions_Widget', 'Blog_Subscription_Widget' );
}
+/**
+ * Classname / shortcode tag to use for the Subscriptions widget.
+ *
+ * @return string
+ */
function get_jetpack_blog_subscriptions_widget_classname() {
return ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ?
'Blog_Subscription_Widget' :
'Jetpack_Subscriptions_Widget';
}
+/**
+ * Subscriptions widget form HTML output.
+ *
+ * @param array $instance Widget instance data.
+ */
function jetpack_do_subscription_form( $instance ) {
if ( empty( $instance ) || ! is_array( $instance ) ) {
$instance = array();
@@ -798,10 +864,10 @@ function jetpack_do_subscription_form( $instance ) {
$instance['show_subscribers_total'] = true;
}
- $show_only_email_and_button = isset( $instance['show_only_email_and_button'] ) ? $instance['show_only_email_and_button'] : false;
- $submit_button_text = isset( $instance['submit_button_text'] ) ? $instance['submit_button_text'] : '';
+ $show_only_email_and_button = isset( $instance['show_only_email_and_button'] ) ? $instance['show_only_email_and_button'] : false;
+ $submit_button_text = isset( $instance['submit_button_text'] ) ? $instance['submit_button_text'] : '';
- // Build up a string with the submit button's classes and styles and set it on the instance
+ // Build up a string with the submit button's classes and styles and set it on the instance.
$submit_button_classes = isset( $instance['submit_button_classes'] ) ? $instance['submit_button_classes'] : '';
$email_field_classes = isset( $instance['email_field_classes'] ) ? $instance['email_field_classes'] : '';
$style = '';
@@ -887,7 +953,7 @@ function jetpack_do_subscription_form( $instance ) {
'jetpack_subscription_form'
);
- // These must come after the call to shortcode_atts()
+ // These must come after the call to shortcode_atts().
$instance['submit_button_text'] = $submit_button_text;
$instance['show_only_email_and_button'] = $show_only_email_and_button;
if ( ! empty( $submit_button_classes ) ) {
@@ -923,6 +989,9 @@ function jetpack_do_subscription_form( $instance ) {
add_shortcode( 'jetpack_subscription_form', 'jetpack_do_subscription_form' );
add_shortcode( 'blog_subscription_form', 'jetpack_do_subscription_form' );
+/**
+ * Register the Subscriptions widget.
+ */
function jetpack_blog_subscriptions_init() {
register_widget( get_jetpack_blog_subscriptions_widget_classname() );
}
diff --git a/plugins/jetpack/modules/theme-tools.php b/plugins/jetpack/modules/theme-tools.php
index a0cc3b13..10e8cf55 100644
--- a/plugins/jetpack/modules/theme-tools.php
+++ b/plugins/jetpack/modules/theme-tools.php
@@ -1,10 +1,17 @@
<?php
-/*
+/**
+ * Module: Theme Tools
+ *
* Load code specific to themes or theme tools
* This file is special, and is not an actual `module` as such.
* It is included by ./module-extras.php
+ *
+ * @package automattic/jetpack
*/
+/**
+ * Conditionally require the Tonesque lib depending on theme support.
+ */
function jetpack_load_theme_tools() {
if ( current_theme_supports( 'tonesque' ) ) {
jetpack_require_lib( 'tonesque' );
@@ -55,14 +62,13 @@ function jetpack_load_theme_compat() {
}
add_action( 'after_setup_theme', 'jetpack_load_theme_compat', -1 );
-
/**
* Requires a file once, if the passed key exists in the files array.
*
* @access private
- * @param string $key
- * @param array $files
- * @return void
+ * @param string $key The key to check.
+ * @param array $files Array of files to check in.
+ * @return void|WP_Error
*/
function _jetpack_require_compat_file( $key, $files ) {
if ( ! is_string( $key ) ) {
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentyfifteen.css b/plugins/jetpack/modules/theme-tools/compat/twentyfifteen.css
index cd343681..cc3f5009 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentyfifteen.css
+++ b/plugins/jetpack/modules/theme-tools/compat/twentyfifteen.css
@@ -67,7 +67,7 @@
}
/* Gallery Widget */
-.widget-gallery .slideshow-window {
+.widget-gallery .jetpack-slideshow-window {
border-radius: 0;
}
@@ -225,7 +225,7 @@
}
/* Slideshow */
-.site .slideshow-window {
+.site .jetpack-slideshow-window {
border-radius: 0;
margin-bottom: 1.6em;
}
@@ -408,7 +408,7 @@ iframe[id*="twitter-widget-"] {
.hentry .CSS_Poll,
.site .hentry .presentation-wrapper,
.site .hentry .jetpack-recipe,
- .site .hentry .slideshow-window,
+ .site .hentry .jetpack-slideshow-window,
.site .hentry .video-player {
margin-bottom: 1.6471em;
}
@@ -419,7 +419,7 @@ iframe[id*="twitter-widget-"] {
.widget .CSS_Poll,
.site .widget .presentation-wrapper,
.site .widget .jetpack-recipe,
- .site .widget .slideshow-window,
+ .site .widget .jetpack-slideshow-window,
.site .widget .video-player {
margin-bottom: 1.5em;
}
@@ -511,7 +511,7 @@ iframe[id*="twitter-widget-"] {
.hentry .CSS_Poll,
.site .hentry .presentation-wrapper,
.site .hentry .jetpack-recipe,
- .site .hentry .slideshow-window,
+ .site .hentry .jetpack-slideshow-window,
.site .hentry .video-player {
margin-bottom: 1.6842em;
}
@@ -582,7 +582,7 @@ iframe[id*="twitter-widget-"] {
.hentry .CSS_Poll,
.site .hentry .presentation-wrapper,
.site .hentry .jetpack-recipe,
- .site .hentry .slideshow-window,
+ .site .hentry .jetpack-slideshow-window,
.site .hentry .video-player {
margin-bottom: 1.6em;
}
@@ -656,7 +656,7 @@ iframe[id*="twitter-widget-"] {
.hentry .CSS_Poll,
.site .hentry .presentation-wrapper,
.site .hentry .jetpack-recipe,
- .site .hentry .slideshow-window,
+ .site .hentry .jetpack-slideshow-window,
.site .hentry .video-player {
margin-bottom: 1.6471em;
}
@@ -726,7 +726,7 @@ iframe[id*="twitter-widget-"] {
.hentry .CSS_Poll,
.site .hentry .presentation-wrapper,
.site .hentry .jetpack-recipe,
- .site .hentry .slideshow-window,
+ .site .hentry .jetpack-slideshow-window,
.site .hentry .video-player {
margin-bottom: 1.6842em;
}
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentyfifteen.php b/plugins/jetpack/modules/theme-tools/compat/twentyfifteen.php
index b51149c6..7e70c88b 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentyfifteen.php
+++ b/plugins/jetpack/modules/theme-tools/compat/twentyfifteen.php
@@ -2,8 +2,13 @@
/**
* Jetpack Compatibility File
* See: https://jetpack.com/
+ *
+ * @package automattic/jetpack
*/
+/**
+ * Add Jetpack theme supports for Twenty Fifteen.
+ */
function twentyfifteen_jetpack_setup() {
/**
* Add theme support for Responsive Videos.
@@ -17,6 +22,9 @@ function twentyfifteen_jetpack_setup() {
}
add_action( 'after_setup_theme', 'twentyfifteen_jetpack_setup' );
+/**
+ * Enqueue Jetpack compat styles for Twenty Fifteen.
+ */
function twentyfifteen_init_jetpack() {
/**
* Add our compat CSS file for custom widget stylings and such.
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentyfourteen.css b/plugins/jetpack/modules/theme-tools/compat/twentyfourteen.css
index 903bc3de..b6e21b1d 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentyfourteen.css
+++ b/plugins/jetpack/modules/theme-tools/compat/twentyfourteen.css
@@ -39,7 +39,7 @@
.wp-multiplayer,
.PDS_Poll,
.CSS_Poll,
-.entry-content .slideshow-window {
+.entry-content .jetpack-slideshow-window {
margin-bottom: 24px;
}
@@ -47,7 +47,7 @@
margin-bottom: 0;
}
-.entry-content .slideshow-window {
+.entry-content .jetpack-slideshow-window {
border-radius: 0;
}
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentyfourteen.php b/plugins/jetpack/modules/theme-tools/compat/twentyfourteen.php
index 202dfbf3..3bc907db 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentyfourteen.php
+++ b/plugins/jetpack/modules/theme-tools/compat/twentyfourteen.php
@@ -1,9 +1,15 @@
<?php
+/**
+ * Jetpack Compatibility File
+ * See: https://jetpack.com/
+ *
+ * @package automattic/jetpack
+ */
/**
* A last try to show posts, in case the Featured Content plugin returns no IDs.
*
- * @param array $featured_ids
+ * @param array $featured_ids Array of 'featured' post IDs.
* @return array
*/
function twentyfourteen_featured_content_post_ids( $featured_ids ) {
@@ -29,7 +35,7 @@ add_action( 'customize_register', 'twentyfourteen_customizer_default' );
/**
* Sets a default tag of 'featured' for Featured Content.
*
- * @param array $settings
+ * @param array $settings Featured content settings.
* @return array
*/
function twentyfourteen_featured_content_default_settings( $settings ) {
@@ -56,6 +62,9 @@ function twentyfourteen_mute_content_filters( $show, $post ) {
}
add_filter( 'sharing_show', 'twentyfourteen_mute_content_filters', 10, 2 );
+/**
+ * Enqueue Jetpack compat styles for Twenty Fourteen.
+ */
function twentyfourteen_init_jetpack() {
/**
* Add our compat CSS file for custom widget stylings and such.
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentynineteen-rtl.css b/plugins/jetpack/modules/theme-tools/compat/twentynineteen-rtl.css
index e2065083..d53681fa 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentynineteen-rtl.css
+++ b/plugins/jetpack/modules/theme-tools/compat/twentynineteen-rtl.css
@@ -1 +1 @@
-.infinite-scroll .pagination,.infinite-scroll .posts-navigation,.infinite-scroll.neverending .site-footer{display:none}.infinity-end.neverending .site-footer{display:block}.infinite-loader{margin:calc(3 * 1rem) auto}.infinite-loader .spinner{margin:0 auto;right:inherit!important}.site-main #infinite-handle{margin:calc(2 * 1rem) auto}.site-main #infinite-handle span{background:100% 0;display:block;font-size:.8888888889em;text-align:center}.site-main #infinite-handle span button,.site-main #infinite-handle span button:focus,.site-main #infinite-handle span button:hover{transition:background 150ms ease-in-out;background:#2271b1;border:none;border-radius:5px;box-sizing:border-box;color:#fff;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:.8888888889em;font-weight:600;line-height:1.2;outline:0;padding:.66rem 1rem}.site-main #infinite-handle span button:hover{cursor:pointer}.site-main #infinite-handle span button:focus,.site-main #infinite-handle span button:hover{background:#111}.site-main #infinite-handle span button:focus{outline:thin dotted;outline-offset:-4px}.site-main .infinite-wrap .entry:first-of-type{margin-top:calc(6 * 1rem)}.entry .jetpack-video-wrapper{margin-bottom:1.75em}.sd-block{line-height:1}.entry div.sharedaddy h3.sd-title,.entry h3.sd-title{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:1.125em;font-weight:700;letter-spacing:-.02em;line-height:1.2;margin-bottom:.5em;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.entry div.sharedaddy h3.sd-title:before,.entry h3.sd-title:before{background:#767676;border-top:none;content:"\020";display:block;height:2px;margin:1rem 0;width:1em;min-width:inherit}.sd-social-icon-text .sd-content ul,.sd-social-text .sd-content ul{margin-bottom:-.3125em!important}.sd-social-icon .sd-content ul,.sd-social-official .sd-content ul{margin-bottom:0!important}.entry #sharing_email .sharing_send,.entry .sd-content ul li .option a.share-ustom,.entry .sd-content ul li a.sd-button,.entry .sd-content ul li.advanced a.share-more,.entry .sd-content ul li.preview-item div.option.option-smart-off a,.entry .sd-social-icon .sd-content ul li a.sd-button,.entry .sd-social-icon-text .sd-content ul li a.sd-button,.entry .sd-social-official .sd-content>ul>li .digg_button>a,.entry .sd-social-official .sd-content>ul>li>a.sd-button,.entry .sd-social-text .sd-content ul li a.sd-button{box-shadow:none}.entry #jp-relatedposts{padding-top:0;margin-top:32px;margin-bottom:32px}.entry #jp-relatedposts h3.jp-relatedposts-headline{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:1.125em;font-weight:700;letter-spacing:-.02em;line-height:1.2;margin-bottom:.5em;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.entry #jp-relatedposts h3.jp-relatedposts-headline:before{background:#767676;border-top:none;content:"\020";display:block;height:2px;margin:1rem 0;width:1em;min-width:inherit}.entry #jp-relatedposts h3.jp-relatedposts-headline em:before{display:none}.entry #jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post{opacity:1}.entry #jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post,.entry #jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:1em;letter-spacing:-.02em;line-height:1.2;margin-bottom:.5em;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.entry #jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post span a,.entry #jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title a{font-weight:700}.entry #jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-excerpt,.entry #jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-title{margin-top:.5em;margin-bottom:.5em}.entry #jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-context,.entry #jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-date{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:13px;font-weight:500}.entry #jp-relatedposts .jp-relatedposts-items p,.entry #jp-relatedposts .jp-relatedposts-items-visual .entry h4.jp-relatedposts-post-title{letter-spacing:normal}#wpstats{display:none}.comments-area .comments-title-wrap+.comment-respond .comment-reply-title{display:none}.widget_author_grid ul,.widget_authors ul,.widget_jp_blogs_i_follow ul,.widget_links ul,.widget_rss_links ul{list-style:none;padding-right:0;padding-left:0}.widget_jp_blogs_i_follow li,.widget_links li,.widget_rss_links li{color:#767676;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:calc(22px * 1.125);font-weight:700;line-height:1.2;margin-top:.5rem;margin-bottom:.5rem}.widget.widget_authors ul li>ul{list-style-type:disc;padding-right:4.25rem}.rtl .widget.widget_authors ul li>ul{padding-right:0;padding-left:1rem}.widget_authors>ul>li>a{display:block;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;position:relative}.widget.widget_authors li a strong{line-height:1.2;position:absolute;top:0}.widget.widget_authors .avatar{float:right;margin-left:1em}.widget_authors li>ul{clear:both}.widget_jetpack_display_posts_widget .jetpack-display-remote-posts h4{font-size:100%;margin:1rem 0}.widget_goodreads div[class^=gr_custom_container]{border:none}.widget_goodreads div[class^=gr_custom_each_container]{border-bottom:none;margin-bottom:1rem;padding-bottom:0}.widget_goodreads div[class^=gr_custom_author],.widget_goodreads h2[class^=gr_custom_header]{font-size:inherit;line-height:1.15}.widget_eu_cookie_law_widget #eu-cookie-law{border-color:#ccc;color:#767676;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:.68182em;padding:.5rem 1rem}.widget_eu_cookie_law_widget #eu-cookie-law .accept{font-size:1em;padding:10px 12px}.widget_rss li a.rsswidget{display:block;margin:1rem 0 .5rem}.widget_rss .rssSummary{font-family:NonBreakingSpaceOverride,"Hoefler Text","Baskerville Old Face",Garamond,"Times New Roman",serif;font-weight:400;font-size:22px}.widget_rss .rss-date,.widget_rss cite{color:#9c9c9c;display:block;font-size:.71111em;font-weight:500;margin:.5rem 0}.widget_rss cite{font-style:normal}.widget_rss cite:before{content:"\2014\00a0"}.widget_top-posts .widgets-list-layout-links{float:inherit;margin-right:calc(40px + 1rem);width:inherit}@media only screen and (min-width:600px){.widget.widget_search .search-field{max-width:calc(50vw - 20%)}}.twentynineteen-customizer .entry .entry-footer>span,.twentynineteen-customizer .entry .entry-meta>span{display:inline} \ No newline at end of file
+@charset "UTF-8";.infinite-scroll .pagination,.infinite-scroll .posts-navigation,.infinite-scroll.neverending .site-footer{display:none}.infinity-end.neverending .site-footer{display:block}.infinite-loader{margin:3rem auto}.infinite-loader .spinner{margin:0 auto;right:inherit!important}.site-main #infinite-handle{margin:2rem auto}.site-main #infinite-handle span{background:transparent;display:block;font-size:.8888888889em;text-align:center}.site-main #infinite-handle span button,.site-main #infinite-handle span button:focus,.site-main #infinite-handle span button:hover{background:#2271b1;border:none;border-radius:5px;box-sizing:border-box;color:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:.8888888889em;font-weight:600;line-height:1.2;outline:none;padding:.66rem 1rem;transition:background .15s ease-in-out}.site-main #infinite-handle span button:hover{cursor:pointer}.site-main #infinite-handle span button:focus,.site-main #infinite-handle span button:hover{background:#111}.site-main #infinite-handle span button:focus{outline:thin dotted;outline-offset:-4px}.site-main .infinite-wrap .entry:first-of-type{margin-top:6rem}.entry .jetpack-video-wrapper{margin-bottom:1.75em}.sd-block{line-height:1}.entry div.sharedaddy h3.sd-title,.entry h3.sd-title{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:1.125em;font-weight:700;letter-spacing:-.02em;line-height:1.2;margin-bottom:.5em}.entry div.sharedaddy h3.sd-title:before,.entry h3.sd-title:before{background:#767676;border-top:none;content:" ";display:block;height:2px;margin:1rem 0;min-width:inherit;width:1em}.sd-social-icon-text .sd-content ul,.sd-social-text .sd-content ul{margin-bottom:-.3125em!important}.sd-social-icon .sd-content ul,.sd-social-official .sd-content ul{margin-bottom:0!important}.entry #sharing_email .sharing_send,.entry .sd-content ul li .option a.share-ustom,.entry .sd-content ul li a.sd-button,.entry .sd-content ul li.advanced a.share-more,.entry .sd-content ul li.preview-item div.option.option-smart-off a,.entry .sd-social-icon .sd-content ul li a.sd-button,.entry .sd-social-icon-text .sd-content ul li a.sd-button,.entry .sd-social-official .sd-content>ul>li .digg_button>a,.entry .sd-social-official .sd-content>ul>li>a.sd-button,.entry .sd-social-text .sd-content ul li a.sd-button{box-shadow:none}.entry #jp-relatedposts{margin-bottom:32px;margin-top:32px;padding-top:0}.entry #jp-relatedposts h3.jp-relatedposts-headline{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:1.125em;font-weight:700;letter-spacing:-.02em;line-height:1.2;margin-bottom:.5em}.entry #jp-relatedposts h3.jp-relatedposts-headline:before{background:#767676;border-top:none;content:" ";display:block;height:2px;margin:1rem 0;min-width:inherit;width:1em}.entry #jp-relatedposts h3.jp-relatedposts-headline em:before{display:none}.entry #jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post{opacity:1}.entry #jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post,.entry #jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:1em;letter-spacing:-.02em;line-height:1.2;margin-bottom:.5em}.entry #jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post span a,.entry #jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title a{font-weight:700}.entry #jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-excerpt,.entry #jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-title{margin-bottom:.5em;margin-top:.5em}.entry #jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-context,.entry #jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-date{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:13px;font-weight:500}.entry #jp-relatedposts .jp-relatedposts-items p,.entry #jp-relatedposts .jp-relatedposts-items-visual .entry h4.jp-relatedposts-post-title{letter-spacing:normal}#wpstats,.comments-area .comments-title-wrap+.comment-respond .comment-reply-title{display:none}.widget_author_grid ul,.widget_authors ul,.widget_jp_blogs_i_follow ul,.widget_links ul,.widget_rss_links ul{list-style:none;padding-left:0;padding-right:0}.widget_jp_blogs_i_follow li,.widget_links li,.widget_rss_links li{color:#767676;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:24.75px;font-weight:700;line-height:1.2;margin-bottom:.5rem;margin-top:.5rem}.widget.widget_authors ul li>ul{list-style-type:disc;padding-right:4.25rem}.rtl .widget.widget_authors ul li>ul{padding-left:1rem;padding-right:0}.widget_authors>ul>li>a{display:block;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;position:relative}.widget.widget_authors li a strong{line-height:1.2;position:absolute;top:0}.widget.widget_authors .avatar{float:right;margin-left:1em}.widget_authors li>ul{clear:both}.widget_jetpack_display_posts_widget .jetpack-display-remote-posts h4{font-size:100%;margin:1rem 0}.widget_goodreads div[class^=gr_custom_container]{border:none}.widget_goodreads div[class^=gr_custom_each_container]{border-bottom:none;margin-bottom:1rem;padding-bottom:0}.widget_goodreads div[class^=gr_custom_author],.widget_goodreads h2[class^=gr_custom_header]{font-size:inherit;line-height:1.15}.widget_eu_cookie_law_widget #eu-cookie-law{border-color:#ccc;color:#767676;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:.68182em;padding:.5rem 1rem}.widget_eu_cookie_law_widget #eu-cookie-law .accept{font-size:1em;padding:10px 12px}.widget_rss li a.rsswidget{display:block;margin:1rem 0 .5rem}.widget_rss .rssSummary{font-family:NonBreakingSpaceOverride,Hoefler Text,Baskerville Old Face,Garamond,Times New Roman,serif;font-size:22px;font-weight:400}.widget_rss .rss-date,.widget_rss cite{color:#9c9c9c;display:block;font-size:.71111em;font-weight:500;margin:.5rem 0}.widget_rss cite{font-style:normal}.widget_rss cite:before{content:"— "}.widget_top-posts .widgets-list-layout-links{float:inherit;margin-right:calc(40px + 1rem);width:inherit}@media only screen and (min-width:600px){.widget.widget_search .search-field{max-width:calc(50vw - 20%)}}.twentynineteen-customizer .entry .entry-footer>span,.twentynineteen-customizer .entry .entry-meta>span{display:inline} \ No newline at end of file
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentynineteen.php b/plugins/jetpack/modules/theme-tools/compat/twentynineteen.php
index 23692325..c7afd055 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentynineteen.php
+++ b/plugins/jetpack/modules/theme-tools/compat/twentynineteen.php
@@ -2,21 +2,29 @@
/**
* Jetpack Compatibility File
* See: https://jetpack.com/
+ *
+ * @package automattic/jetpack
*/
+/**
+ * Add Jetpack theme supports for Twenty Nineteen.
+ */
function twentynineteen_jetpack_setup() {
/**
- * Add theme support for Infinite Scroll.
+ * Add theme support for Infinite Scroll.
*/
- add_theme_support( 'infinite-scroll', array(
- 'type' => 'click',
- 'container' => 'main',
- 'render' => 'twentynineteen_infinite_scroll_render',
- 'footer' => 'page',
- ) );
-
- /**
+ add_theme_support(
+ 'infinite-scroll',
+ array(
+ 'type' => 'click',
+ 'container' => 'main',
+ 'render' => 'twentynineteen_infinite_scroll_render',
+ 'footer' => 'page',
+ )
+ );
+
+ /**
* Add theme support for Responsive Videos.
*/
add_theme_support( 'jetpack-responsive-videos' );
@@ -29,22 +37,25 @@ function twentynineteen_jetpack_setup() {
/**
* Add theme support for Content Options.
*/
- add_theme_support( 'jetpack-content-options', array(
- 'blog-display' => array( 'content', 'excerpt' ),
- 'post-details' => array(
- 'stylesheet' => 'twentynineteen-style',
- 'date' => '.posted-on',
- 'categories' => '.cat-links',
- 'tags' => '.tags-links',
- 'author' => '.byline',
- 'comment' => '.comments-link',
- ),
- 'featured-images' => array(
- 'archive' => true,
- 'post' => true,
- 'page' => true,
- ),
- ) );
+ add_theme_support(
+ 'jetpack-content-options',
+ array(
+ 'blog-display' => array( 'content', 'excerpt' ),
+ 'post-details' => array(
+ 'stylesheet' => 'twentynineteen-style',
+ 'date' => '.posted-on',
+ 'categories' => '.cat-links',
+ 'tags' => '.tags-links',
+ 'author' => '.byline',
+ 'comment' => '.comments-link',
+ ),
+ 'featured-images' => array(
+ 'archive' => true,
+ 'post' => true,
+ 'page' => true,
+ ),
+ )
+ );
}
add_action( 'after_setup_theme', 'twentynineteen_jetpack_setup' );
@@ -58,6 +69,9 @@ function twentynineteen_infinite_scroll_render() {
}
}
+/**
+ * Enqueue Jetpack compat styles for Twenty Nineteen.
+ */
function twentynineteen_init_jetpack() {
/**
* Add our compat CSS file for Infinite Scroll and custom widget stylings and such.
@@ -78,7 +92,7 @@ add_action( 'init', 'twentynineteen_init_jetpack' );
/**
* Alter gallery widget default width.
*/
-function twentynineteen_gallery_widget_content_width( $width ) {
+function twentynineteen_gallery_widget_content_width() {
return 390;
}
add_filter( 'gallery_widget_content_width', 'twentynineteen_gallery_widget_content_width' );
@@ -86,7 +100,7 @@ add_filter( 'gallery_widget_content_width', 'twentynineteen_gallery_widget_conte
/**
* Alter featured-image default visibility for content-options.
*/
-function twentynineteen_override_post_thumbnail( $width ) {
+function twentynineteen_override_post_thumbnail() {
$options = get_theme_support( 'jetpack-content-options' );
$featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null;
@@ -95,10 +109,13 @@ function twentynineteen_override_post_thumbnail( $width ) {
'page-default' => ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1,
);
- $settings = array_merge( $settings, array(
- 'post-option' => get_option( 'jetpack_content_featured_images_post', $settings['post-default'] ),
- 'page-option' => get_option( 'jetpack_content_featured_images_page', $settings['page-default'] ),
- ) );
+ $settings = array_merge(
+ $settings,
+ array(
+ 'post-option' => get_option( 'jetpack_content_featured_images_post', $settings['post-default'] ),
+ 'page-option' => get_option( 'jetpack_content_featured_images_page', $settings['page-default'] ),
+ )
+ );
if ( ( ! $settings['post-option'] && is_single() )
|| ( ! $settings['page-option'] && is_singular() && is_page() ) ) {
@@ -116,7 +133,7 @@ add_filter( 'twentynineteen_can_show_post_thumbnail', 'twentynineteen_override_p
* @return array
*/
function twentynineteen_jetpack_body_classes( $classes ) {
- // Adds a class if we're in the Customizer
+ // Adds a class if we're in the Customizer.
if ( is_customize_preview() ) :
$classes[] = 'twentynineteen-customizer';
endif;
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentyseventeen.php b/plugins/jetpack/modules/theme-tools/compat/twentyseventeen.php
index 284b54a4..6d5f6853 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentyseventeen.php
+++ b/plugins/jetpack/modules/theme-tools/compat/twentyseventeen.php
@@ -2,8 +2,13 @@
/**
* Jetpack Compatibility File
* See: https://jetpack.com/
+ *
+ * @package automattic/jetpack
*/
+/**
+ * Add Jetpack theme supports for Twenty Seventeen.
+ */
function twentyseventeen_jetpack_setup() {
/**
* Add theme support for geo-location.
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentysixteen.css b/plugins/jetpack/modules/theme-tools/compat/twentysixteen.css
index acc056cf..58df562e 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentysixteen.css
+++ b/plugins/jetpack/modules/theme-tools/compat/twentysixteen.css
@@ -65,7 +65,7 @@
}
/* Gallery Widget */
-.widget-gallery .slideshow-window {
+.widget-gallery .jetpack-slideshow-window {
border-radius: 0;
}
@@ -446,7 +446,7 @@ iframe[src^="http://api.mixcloud.com/"] {
}
/* Slideshow */
-.entry-content .slideshow-window {
+.entry-content .jetpack-slideshow-window {
border-radius: 0;
margin-bottom: 1.75em;
}
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php b/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php
index 439a3e95..2d841e86 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php
+++ b/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php
@@ -2,8 +2,13 @@
/**
* Jetpack Compatibility File
* See: https://jetpack.com/
+ *
+ * @package automattic/jetpack
*/
+/**
+ * Add Jetpack theme supports for Twenty Sixteen.
+ */
function twentysixteen_jetpack_setup() {
/**
* Add theme support for Responsive Videos.
@@ -17,6 +22,9 @@ function twentysixteen_jetpack_setup() {
}
add_action( 'after_setup_theme', 'twentysixteen_jetpack_setup' );
+/**
+ * Enqueue Jetpack compat styles for Twenty Sixteen.
+ */
function twentysixteen_init_jetpack() {
/**
* Add our compat CSS file for custom widget stylings and such.
@@ -37,7 +45,7 @@ add_action( 'init', 'twentysixteen_init_jetpack' );
/**
* Alter gallery widget default width.
*/
-function twentysixteen_gallery_widget_content_width( $width ) {
+function twentysixteen_gallery_widget_content_width() {
return 390;
}
add_filter( 'gallery_widget_content_width', 'twentysixteen_gallery_widget_content_width' );
@@ -55,6 +63,9 @@ function twentysixteen_remove_share() {
}
add_action( 'loop_start', 'twentysixteen_remove_share' );
+/**
+ * Add inline script for lazy load compat in Twenty Sixteen.
+ */
function twentysixteen_jetpack_lazy_images_compat() {
// Since TwentySixteen outdents when window is resized, let's trigger a window resize
// every time we lazy load an image on the TwentySixteen theme.
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentytwenty-rtl.css b/plugins/jetpack/modules/theme-tools/compat/twentytwenty-rtl.css
index b8d95c0d..0e9f51e9 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentytwenty-rtl.css
+++ b/plugins/jetpack/modules/theme-tools/compat/twentytwenty-rtl.css
@@ -1 +1 @@
-#infinite-footer{z-index:1}.infinite-scroll .pagination-wrapper,.infinite-scroll.neverending #site-footer,.infinite-scroll.neverending .footer-nav-widgets-wrapper{display:none}.infinite-end.neverending .footer-nav-widgets-wrapper,.infinity-end.neverending #site-footer{display:block}.infinity-end.neverending #site-footer{margin:8rem 0 0}.infinite-loader{margin:5rem auto}.infinite-loader .spinner{margin:0 auto;right:inherit!important}#site-content #infinite-handle{margin:5rem auto;max-width:58rem;width:calc(100% - 8rem)}#site-content #infinite-handle span{background:100% 0;display:block;font-size:1.7rem;text-align:center}#site-content #infinite-handle span button,#site-content #infinite-handle span button:focus,#site-content #infinite-handle span button:hover{-webkit-appearance:none;-moz-appearance:none;border:none;background:#cd2653;border-radius:0;color:#fff;cursor:pointer;display:inline-block;font-size:1.5rem;font-weight:600;letter-spacing:.0333em;line-height:1.25;margin:0;opacity:1;padding:1.1em 1.44em;text-align:center;text-decoration:none;text-transform:uppercase;transition:opacity .15s linear}#site-content #infinite-handle span button:hover{text-decoration:underline}#site-content .infinite-wrap .hentry:first-of-type{padding:4rem 0 0}.entry-content #jp-relatedposts h3.jp-relatedposts-headline,.entry-content div.sharedaddy h3.sd-title,.entry-content h3.sd-title{font-size:2.8rem;font-weight:700;letter-spacing:-.016875em;line-height:1.5}@media (min-width:700px){.entry-content #jp-relatedposts h3.jp-relatedposts-headline,.entry-content div.sharedaddy h3.sd-title,.entry-content h3.sd-title{font-size:4rem}}.entry-content div.sharedaddy h3.sd-title:before,.entry-content h3.sd-title:before{border:0 none}.entry-content #jp-relatedposts h3.jp-relatedposts-headline em:before{border:0 none}.widget_authors ul{list-style:none;margin-right:0}.widget_authors li{margin-top:1rem;list-style:none}.widget_authors li:first-child{margin-top:2rem}.widget_flickr .flickr-size-thumbnail .flickr-images{justify-content:left}.widget_eu_cookie_law_widget #eu-cookie-law,.widget_eu_cookie_law_widget #eu-cookie-law .accept{font-size:1.6rem;font-weight:500;padding:2rem}.widget_eu_cookie_law_widget #eu-cookie-law .accept{font-size:1.4rem;font-weight:600;letter-spacing:.0333em;line-height:1.25;padding:1.1em 1.44em;text-decoration:none;text-transform:uppercase;transition:opacity .15s linear}@media (max-width:600px){.widget_eu_cookie_law_widget #eu-cookie-law{font-size:1.4rem;padding:1.5rem 1.5rem 6.5rem}.widget_eu_cookie_law_widget #eu-cookie-law .accept{font-size:1.2rem;bottom:1.5rem;left:auto;right:1.5rem;padding:1rem;margin:0}}.jetpack_subscription_widget .widget-title label{font-size:2.8rem;font-weight:700;margin:0}@media (min-width:700px){.jetpack_subscription_widget .widget-title label{font-size:4rem}}.widget_blog_subscription form p:not(#subscribe-email) input[type=text]{padding:1.5rem 1.8rem!important;width:100%!important}.entry-content #jp-relatedposts{max-width:120rem;margin:1em auto;width:calc(100% - 4rem)}@media (min-width:700px){.entry-content #jp-relatedposts{width:calc(100% - 8rem)}}#jp-relatedposts .jp-relatedposts-grid{display:flex;flex-grow:1;flex-basis:0;justify-content:space-between;box-sizing:border-box}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post,#jp-relatedposts .jp-relatedposts-post{width:calc(33% - 2rem);margin-right:0;margin-left:0}@media only screen and (max-width:640px){#jp-relatedposts .jp-relatedposts-grid{flex-direction:column}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post,#jp-relatedposts .jp-relatedposts-post{width:100%}}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post{padding-left:0}#jp-relatedposts#jp-relatedposts .jp-relatedposts-items p,#jp-relatedposts#jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title{font-size:inherit;line-height:1.5}#jp-relatedposts .jp-relatedposts-items-visual{margin-left:0}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post img.jp-relatedposts-post-img{width:100%}.entry-content .tiled-gallery{margin:0 auto 1.5em}.entry-content .jetpack-recipe{margin:1em auto}.entry-content .fb-video{display:block}.jp-related-posts-i2__post li{margin:0}.wp-block-jetpack-gif{margin:1em auto!important}.entry-content img.latex{display:inline}iframe#wpnt-notes-iframe2.wide{width:auto!important}.admin-bar{position:unset!important}.screen-reader-text{position:absolute} \ No newline at end of file
+#infinite-footer{z-index:1}.infinite-scroll .pagination-wrapper,.infinite-scroll.neverending #site-footer,.infinite-scroll.neverending .footer-nav-widgets-wrapper{display:none}.infinite-end.neverending .footer-nav-widgets-wrapper,.infinity-end.neverending #site-footer{display:block}.infinity-end.neverending #site-footer{margin:8rem 0 0}.infinite-loader{margin:5rem auto}.infinite-loader .spinner{margin:0 auto;right:inherit!important}#site-content #infinite-handle{margin:5rem auto;max-width:58rem;width:calc(100% - 8rem)}#site-content #infinite-handle span{background:transparent;display:block;font-size:1.7rem;text-align:center}#site-content #infinite-handle span button,#site-content #infinite-handle span button:focus,#site-content #infinite-handle span button:hover{-webkit-appearance:none;-moz-appearance:none;background:#cd2653;border:none;border-radius:0;color:#fff;cursor:pointer;display:inline-block;font-size:1.5rem;font-weight:600;letter-spacing:.0333em;line-height:1.25;margin:0;opacity:1;padding:1.1em 1.44em;text-align:center;text-decoration:none;text-transform:uppercase;transition:opacity .15s linear}#site-content #infinite-handle span button:hover{text-decoration:underline}#site-content .infinite-wrap .hentry:first-of-type{padding:4rem 0 0}.entry-content #jp-relatedposts h3.jp-relatedposts-headline,.entry-content div.sharedaddy h3.sd-title,.entry-content h3.sd-title{font-size:2.8rem;font-weight:700;letter-spacing:-.016875em;line-height:1.5}@media (min-width:700px){.entry-content #jp-relatedposts h3.jp-relatedposts-headline,.entry-content div.sharedaddy h3.sd-title,.entry-content h3.sd-title{font-size:4rem}}.entry-content #jp-relatedposts h3.jp-relatedposts-headline em:before,.entry-content div.sharedaddy h3.sd-title:before,.entry-content h3.sd-title:before{border:0}.widget_authors ul{list-style:none;margin-right:0}.widget_authors li{list-style:none;margin-top:1rem}.widget_authors li:first-child{margin-top:2rem}.widget_flickr .flickr-size-thumbnail .flickr-images{justify-content:left}.widget_eu_cookie_law_widget #eu-cookie-law,.widget_eu_cookie_law_widget #eu-cookie-law .accept{font-size:1.6rem;font-weight:500;padding:2rem}.widget_eu_cookie_law_widget #eu-cookie-law .accept{font-size:1.4rem;font-weight:600;letter-spacing:.0333em;line-height:1.25;padding:1.1em 1.44em;text-decoration:none;text-transform:uppercase;transition:opacity .15s linear}@media (max-width:600px){.widget_eu_cookie_law_widget #eu-cookie-law{font-size:1.4rem;padding:1.5rem 1.5rem 6.5rem}.widget_eu_cookie_law_widget #eu-cookie-law .accept{bottom:1.5rem;font-size:1.2rem;left:auto;margin:0;padding:1rem;right:1.5rem}}.jetpack_subscription_widget .widget-title label{font-size:2.8rem;font-weight:700;margin:0}@media (min-width:700px){.jetpack_subscription_widget .widget-title label{font-size:4rem}}.widget_blog_subscription form p:not(#subscribe-email) input[type=text]{padding:1.5rem 1.8rem!important;width:100%!important}.entry-content #jp-relatedposts{margin:1em auto;max-width:120rem;width:calc(100% - 4rem)}@media (min-width:700px){.entry-content #jp-relatedposts{width:calc(100% - 8rem)}}#jp-relatedposts .jp-relatedposts-grid{box-sizing:border-box;display:flex;flex-basis:0;flex-grow:1;justify-content:space-between}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post,#jp-relatedposts .jp-relatedposts-post{margin-left:0;margin-right:0;width:calc(33% - 2rem)}@media only screen and (max-width:640px){#jp-relatedposts .jp-relatedposts-grid{flex-direction:column}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post,#jp-relatedposts .jp-relatedposts-post{width:100%}}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post{padding-left:0}#jp-relatedposts#jp-relatedposts .jp-relatedposts-items p,#jp-relatedposts#jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title{font-size:inherit;line-height:1.5}#jp-relatedposts .jp-relatedposts-items-visual{margin-left:0}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post img.jp-relatedposts-post-img{width:100%}.entry-content .tiled-gallery{margin:0 auto 1.5em}.entry-content .jetpack-recipe{margin:1em auto}.entry-content .fb-video{display:block}.jp-related-posts-i2__post li{margin:0}.wp-block-jetpack-gif{margin:1em auto!important}.entry-content img.latex{display:inline}iframe#wpnt-notes-iframe2.wide{width:auto!important}.admin-bar{position:unset!important}.screen-reader-text{position:absolute} \ No newline at end of file
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentytwenty.css b/plugins/jetpack/modules/theme-tools/compat/twentytwenty.css
index 9d88c7fe..674f63af 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentytwenty.css
+++ b/plugins/jetpack/modules/theme-tools/compat/twentytwenty.css
@@ -273,7 +273,7 @@
/* GIF Block */
.wp-block-jetpack-gif {
- /* !important because the gif block styles are loaded in the footer after this file */
+ /* Uses !important because the gif block styles are loaded in the footer after this file */
margin: 1em auto !important;
}
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentytwentyone-rtl.css b/plugins/jetpack/modules/theme-tools/compat/twentytwentyone-rtl.css
index e130386d..2109929f 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentytwentyone-rtl.css
+++ b/plugins/jetpack/modules/theme-tools/compat/twentytwentyone-rtl.css
@@ -1 +1 @@
-.entry-content #jp-relatedposts{max-width:var(--responsive--aligndefault-width);margin-right:auto;margin-left:auto}.infinite-scroll .pagination,.infinite-scroll.neverending .widget-area,.infinite-scroll.neverending footer#colophon{display:none}.infinity-end.neverending .widget-area,.infinity-end.neverending footer#colophon{display:block}body[class*=" infinity-"] main#main>article:last-of-type .entry-footer{border-bottom:var(--separator--height) solid var(--separator--border-color)}body.infinity-end .site-main>div:last-of-type>article:last-of-type .entry-footer,body:not(.infinity-end) .site-main>div:nth-last-child(2)>article:last-of-type .entry-footer{border:none}.site-main>.infinite-wrap>article>.entry-footer{margin-top:var(--global--spacing-vertical);padding-top:var(--global--spacing-unit);padding-bottom:calc(3 * var(--global--spacing-vertical));border-bottom:var(--separator--height) solid var(--separator--border-color)}.site-main>.infinite-wrap>*{margin-top:calc(3 * var(--global--spacing-vertical));margin-bottom:calc(3 * var(--global--spacing-vertical))}#infinite-handle{text-align:center}.infinite-loader{margin:calc(3 * 1rem) auto}#infinite-handle span{color:var(--global--color-background);background-color:var(--global--color-secondary);font-family:var(--global--font-primary);font-size:var(--global--font-size-base);font-weight:500;line-height:1.5;border-width:3px;border-radius:0;padding:15px calc(2 * var(--button--padding-vertical));max-width:170px;margin:auto}#infinite-handle span:hover{color:var(--global--color-secondary);background-color:var(--global--color-background);border-color:var(--global--color-secondary);border-style:solid}#infinite-handle span:active{color:var(--global--color-secondary);background-color:var(--global--color-background);border-color:var(--global--color-secondary)}.widget-area .widget_block{min-width:0}@media only screen and (min-width:1024px){.widget-area{grid-template-columns:repeat(3,minmax(0,1fr))}} \ No newline at end of file
+.entry-content #jp-relatedposts{margin-left:auto;margin-right:auto;max-width:var(--responsive--aligndefault-width)}.infinite-scroll .pagination,.infinite-scroll.neverending .widget-area,.infinite-scroll.neverending footer#colophon{display:none}.infinity-end.neverending .widget-area,.infinity-end.neverending footer#colophon{display:block}body[class*=" infinity-"] main#main>article:last-of-type .entry-footer{border-bottom:var(--separator--height) solid var(--separator--border-color)}body.infinity-end .site-main>div:last-of-type>article:last-of-type .entry-footer,body:not(.infinity-end) .site-main>div:nth-last-child(2)>article:last-of-type .entry-footer{border:none}.site-main>.infinite-wrap>article>.entry-footer{border-bottom:var(--separator--height) solid var(--separator--border-color);margin-top:var(--global--spacing-vertical);padding-bottom:calc(var(--global--spacing-vertical)*3);padding-top:var(--global--spacing-unit)}.site-main>.infinite-wrap>*{margin-bottom:calc(var(--global--spacing-vertical)*3);margin-top:calc(var(--global--spacing-vertical)*3)}#infinite-handle{text-align:center}.infinite-loader{margin:3rem auto}#infinite-handle span{background-color:var(--global--color-secondary);border-radius:0;border-width:3px;color:var(--global--color-background);font-family:var(--global--font-primary);font-size:var(--global--font-size-base);font-weight:500;line-height:1.5;margin:auto;max-width:170px;padding:15px calc(var(--button--padding-vertical)*2)}#infinite-handle span:hover{border-style:solid}#infinite-handle span:active,#infinite-handle span:hover{background-color:var(--global--color-background);border-color:var(--global--color-secondary);color:var(--global--color-secondary)}.widget-area .widget_block{min-width:0}@media only screen and (min-width:1024px){.widget-area{grid-template-columns:repeat(3,minmax(0,1fr))}} \ No newline at end of file
diff --git a/plugins/jetpack/modules/theme-tools/content-options.php b/plugins/jetpack/modules/theme-tools/content-options.php
index 118e31db..888d34ad 100644
--- a/plugins/jetpack/modules/theme-tools/content-options.php
+++ b/plugins/jetpack/modules/theme-tools/content-options.php
@@ -1,5 +1,12 @@
<?php
/**
+ * Jetpack Compatibility File
+ * See: https://jetpack.com/
+ *
+ * @package automattic/jetpack
+ */
+
+/**
* Content Options.
*
* This feature will only be activated for themes that declare their support.
@@ -46,29 +53,32 @@ function jetpack_content_options_init() {
}
// Load the Customizer options.
- require dirname( __FILE__ ) . '/content-options/customizer.php';
+ require __DIR__ . '/content-options/customizer.php';
// Load Blog Display function.
- require dirname( __FILE__ ) . '/content-options/blog-display.php';
+ require __DIR__ . '/content-options/blog-display.php';
// Load Author Bio function.
- require dirname( __FILE__ ) . '/content-options/author-bio.php';
+ require __DIR__ . '/content-options/author-bio.php';
// Load Post Details function.
- require dirname( __FILE__ ) . '/content-options/post-details.php';
+ require __DIR__ . '/content-options/post-details.php';
// Load Featured Images function.
if ( jetpack_featured_images_should_load() ) {
- require dirname( __FILE__ ) . '/content-options/featured-images.php';
+ require __DIR__ . '/content-options/featured-images.php';
}
// Load Featured Images Fallback function.
if ( jetpack_featured_images_fallback_should_load() ) {
- require dirname( __FILE__ ) . '/content-options/featured-images-fallback.php';
+ require __DIR__ . '/content-options/featured-images-fallback.php';
}
}
add_action( 'init', 'jetpack_content_options_init' );
+/**
+ * Get featured images settings using the jetpack-content-options theme support.
+ */
function jetpack_featured_images_get_settings() {
$options = get_theme_support( 'jetpack-content-options' );
@@ -101,6 +111,9 @@ function jetpack_featured_images_get_settings() {
return $settings;
}
+/**
+ * Determine if the Jetpack Featured Images should be load.
+ */
function jetpack_featured_images_should_load() {
// If the theme doesn't support post thumbnails, don't continue.
if ( ! current_theme_supports( 'post-thumbnails' ) ) {
@@ -120,6 +133,9 @@ function jetpack_featured_images_should_load() {
return true;
}
+/**
+ * Determine if the Jetpack Featured Images fallback should load.
+ */
function jetpack_featured_images_fallback_should_load() {
// If the theme doesn't support post thumbnails, don't continue.
if ( ! current_theme_supports( 'post-thumbnails' ) ) {
diff --git a/plugins/jetpack/modules/theme-tools/content-options/author-bio.php b/plugins/jetpack/modules/theme-tools/content-options/author-bio.php
index 89d4603c..956cba46 100644
--- a/plugins/jetpack/modules/theme-tools/content-options/author-bio.php
+++ b/plugins/jetpack/modules/theme-tools/content-options/author-bio.php
@@ -1,5 +1,11 @@
<?php
/**
+ * Theme Tools: Author Bio functions.
+ *
+ * @package automattic/jetpack
+ */
+
+/**
* The function to display Author Bio in a theme.
*/
function jetpack_author_bio() {
@@ -46,13 +52,21 @@ function jetpack_author_bio() {
</div><!-- .author-avatar -->
<div class="author-heading">
- <h2 class="author-title"><?php printf( esc_html__( 'Published by %s', 'jetpack' ), '<span class="author-name">' . get_the_author() . '</span>' ); ?></h2>
+ <h2 class="author-title">
+ <?php
+ /* translators: %s: post author */
+ printf( esc_html__( 'Published by %s', 'jetpack' ), '<span class="author-name">' . get_the_author() . '</span>' );
+ ?>
+ </h2>
</div><!-- .author-heading -->
<p class="author-bio">
<?php the_author_meta( 'description' ); ?>
<a class="author-link" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
- <?php printf( esc_html__( 'View all posts by %s', 'jetpack' ), get_the_author() ); ?>
+ <?php
+ /* translators: %s: post author */
+ printf( esc_html__( 'View all posts by %s', 'jetpack' ), get_the_author() );
+ ?>
</a>
</p><!-- .author-bio -->
</div><!-- .entry-auhtor -->
diff --git a/plugins/jetpack/modules/theme-tools/content-options/blog-display.php b/plugins/jetpack/modules/theme-tools/content-options/blog-display.php
index 66273b12..6b9ff3fe 100644
--- a/plugins/jetpack/modules/theme-tools/content-options/blog-display.php
+++ b/plugins/jetpack/modules/theme-tools/content-options/blog-display.php
@@ -1,6 +1,8 @@
<?php
/**
- * The functions to display Content or Excerpt in a theme.
+ * Theme Tools: the functions to display Content or Excerpt in a theme.
+ *
+ * @package automattic/jetpack
*/
/**
@@ -24,7 +26,7 @@ $blog_display = ( 'content, excerpt' === $blog_display ) ? 'mixed' : $blog_displ
/**
* If the theme doesn't support 'jetpack-content-options[ 'blog-display' ]', don't continue.
*/
-if ( ! in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ) ) ) {
+if ( ! in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ), true ) ) {
return;
}
@@ -52,11 +54,11 @@ function jetpack_blog_display_custom_excerpt( $content = '' ) {
if ( empty( $post->post_excerpt ) ) {
$text = strip_shortcodes( $post->post_content );
$text = str_replace( ']]>', ']]&gt;', $text );
- $text = strip_tags( $text );
+ $text = wp_strip_all_tags( $text );
/** This filter is documented in wp-includes/formatting.php */
$excerpt_length = apply_filters( 'excerpt_length', 55 );
/** This filter is documented in wp-includes/formatting.php */
- $excerpt_more = apply_filters( 'excerpt_more', ' ' . '[...]' );
+ $excerpt_more = apply_filters( 'excerpt_more', ' [...]' );
/*
* translators: If your word count is based on single characters (e.g. East Asian characters),
@@ -88,6 +90,8 @@ function jetpack_blog_display_custom_excerpt( $content = '' ) {
/**
* Display Excerpt instead of Content.
+ *
+ * @param string $content Post content.
*/
function jetpack_the_content_to_the_excerpt( $content ) {
if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
@@ -106,6 +110,8 @@ function jetpack_the_content_to_the_excerpt( $content ) {
/**
* Display Content instead of Excerpt.
+ *
+ * @param string $content The post excerpt.
*/
function jetpack_the_excerpt_to_the_content( $content ) {
if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
@@ -131,6 +137,8 @@ function jetpack_the_excerpt_to_the_content( $content ) {
/**
* Display both Content and Excerpt instead of Content in the Customizer so live preview can switch between them.
+ *
+ * @param string $content The post content.
*/
function jetpack_the_content_customizer( $content ) {
$class = jetpack_the_content_customizer_class();
@@ -150,6 +158,8 @@ function jetpack_the_content_customizer( $content ) {
/**
* Display both Content and Excerpt instead of Excerpt in the Customizer so live preview can switch between them.
+ *
+ * @param string $excerpt The post excerpt.
*/
function jetpack_the_excerpt_customizer( $excerpt ) {
if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
@@ -179,6 +189,8 @@ function jetpack_the_excerpt_customizer( $excerpt ) {
/**
* Display Content instead of Excerpt in the Customizer when theme uses a 'Mixed' display.
+ *
+ * @param string $content The post excerpt.
*/
function jetpack_the_excerpt_mixed_customizer( $content ) {
if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
@@ -193,6 +205,8 @@ function jetpack_the_excerpt_mixed_customizer( $content ) {
/**
* Returns a class value, `output-the-content` by default.
* Used for themes with a 'Mixed' Blog Display so we can tell which output is by default.
+ *
+ * @param string|null $new_class CSS class added to content container.
*/
function jetpack_the_content_customizer_class( $new_class = null ) {
static $class;
diff --git a/plugins/jetpack/modules/theme-tools/content-options/customizer.php b/plugins/jetpack/modules/theme-tools/content-options/customizer.php
index 844e5074..38ae4a08 100644
--- a/plugins/jetpack/modules/theme-tools/content-options/customizer.php
+++ b/plugins/jetpack/modules/theme-tools/content-options/customizer.php
@@ -1,4 +1,10 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Theme Tools: functions for Customizer enhancements.
+ *
+ * @package automattic/jetpack
+ */
+
/**
* Add Content section to the Theme Customizer.
*
@@ -32,7 +38,7 @@ function jetpack_content_options_customize_register( $wp_customize ) {
$fi_fallback_default = ( isset( $featured_images['fallback-default'] ) && false === $featured_images['fallback-default'] ) ? '' : 1;
// If the theme doesn't support 'jetpack-content-options[ 'blog-display' ]', 'jetpack-content-options[ 'author-bio' ]', 'jetpack-content-options[ 'post-details' ]' and 'jetpack-content-options[ 'featured-images' ]', don't continue.
- if ( ( ! in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ) ) )
+ if ( ( ! in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ), true ) )
&& ( true !== $author_bio )
&& ( ( empty( $post_details['stylesheet'] ) )
&& ( empty( $date )
@@ -44,11 +50,21 @@ function jetpack_content_options_customize_register( $wp_customize ) {
return;
}
- // New control type: Title.
+ /**
+ * New Customizer control type: Title.
+ */
class Jetpack_Customize_Control_Title extends WP_Customize_Control {
+ /**
+ * Customizer control type.
+ *
+ * @var string
+ */
public $type = 'title';
- public function render_content() {
+ /**
+ * Render the control's content.
+ */
+ public function render_content() { // phpcs:ignore MediaWiki.Usage.NestedFunctions.NestedFunction
?>
<span class="customize-control-title"><?php echo wp_kses_post( $this->label ); ?></span>
<?php
@@ -66,7 +82,7 @@ function jetpack_content_options_customize_register( $wp_customize ) {
);
// Add Blog Display option.
- if ( in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ) ) ) {
+ if ( in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ), true ) ) {
if ( 'mixed' === $blog_display ) {
$blog_display_choices = array(
'content' => esc_html__( 'Full post', 'jetpack' ),
@@ -167,7 +183,7 @@ function jetpack_content_options_customize_register( $wp_customize ) {
)
);
- // Post Details: Date
+ // Post Details: Date.
if ( ! empty( $date ) ) {
$wp_customize->add_setting(
'jetpack_content_post_details_date',
@@ -189,7 +205,7 @@ function jetpack_content_options_customize_register( $wp_customize ) {
);
}
- // Post Details: Categories
+ // Post Details: Categories.
if ( ! empty( $categories ) ) {
$wp_customize->add_setting(
'jetpack_content_post_details_categories',
@@ -211,7 +227,7 @@ function jetpack_content_options_customize_register( $wp_customize ) {
);
}
- // Post Details: Tags
+ // Post Details: Tags.
if ( ! empty( $tags ) ) {
$wp_customize->add_setting(
'jetpack_content_post_details_tags',
@@ -233,7 +249,7 @@ function jetpack_content_options_customize_register( $wp_customize ) {
);
}
- // Post Details: Author
+ // Post Details: Author.
if ( ! empty( $author ) ) {
$wp_customize->add_setting(
'jetpack_content_post_details_author',
@@ -255,7 +271,7 @@ function jetpack_content_options_customize_register( $wp_customize ) {
);
}
- // Post Details: Comment link
+ // Post Details: Comment link.
if ( ! empty( $comment ) ) {
$wp_customize->add_setting(
'jetpack_content_post_details_comment',
@@ -295,7 +311,7 @@ function jetpack_content_options_customize_register( $wp_customize ) {
)
);
- // Featured Images: Archive
+ // Featured Images: Archive.
if ( true === $fi_archive ) {
$wp_customize->add_setting(
'jetpack_content_featured_images_archive',
@@ -317,7 +333,7 @@ function jetpack_content_options_customize_register( $wp_customize ) {
);
}
- // Featured Images: Post
+ // Featured Images: Post.
if ( true === $fi_post ) {
$wp_customize->add_setting(
'jetpack_content_featured_images_post',
@@ -339,7 +355,7 @@ function jetpack_content_options_customize_register( $wp_customize ) {
);
}
- // Featured Images: Page
+ // Featured Images: Page.
if ( true === $fi_page ) {
$wp_customize->add_setting(
'jetpack_content_featured_images_page',
@@ -361,7 +377,7 @@ function jetpack_content_options_customize_register( $wp_customize ) {
);
}
- // Featured Images: Portfolio
+ // Featured Images: Portfolio.
if ( true === $fi_portfolio && post_type_exists( 'jetpack-portfolio' ) ) {
$wp_customize->add_setting(
'jetpack_content_featured_images_portfolio',
@@ -383,7 +399,7 @@ function jetpack_content_options_customize_register( $wp_customize ) {
);
}
- // Featured Images: Fallback
+ // Featured Images: Fallback.
if ( true === $fi_fallback ) {
$wp_customize->add_setting(
'jetpack_content_featured_images_fallback',
@@ -418,21 +434,21 @@ function jetpack_post_thumbnail_supports() {
/**
* Sanitize the checkbox.
*
- * @param int $input.
+ * @param int $input The unsanitized value from the setting.
* @return boolean|string
*/
function jetpack_content_options_sanitize_checkbox( $input ) {
- return ( 1 == $input ) ? 1 : '';
+ return ( 1 === (int) $input ) ? 1 : '';
}
/**
* Sanitize the Display value.
*
- * @param string $display.
+ * @param string $display The unsanitized value from the setting.
* @return string.
*/
function jetpack_content_options_sanitize_blog_display( $display ) {
- if ( ! in_array( $display, array( 'content', 'excerpt', 'mixed' ) ) ) {
+ if ( ! in_array( $display, array( 'content', 'excerpt', 'mixed' ), true ) ) {
$display = 'content';
}
return $display;
diff --git a/plugins/jetpack/modules/theme-tools/content-options/featured-images-fallback.php b/plugins/jetpack/modules/theme-tools/content-options/featured-images-fallback.php
index dc8d92d6..5140914f 100644
--- a/plugins/jetpack/modules/theme-tools/content-options/featured-images-fallback.php
+++ b/plugins/jetpack/modules/theme-tools/content-options/featured-images-fallback.php
@@ -1,5 +1,11 @@
<?php
/**
+ * Theme Tools: functions for Featured Images fallback.
+ *
+ * @package automattic/jetpack
+ */
+
+/**
* Get one image from a specified post in the following order:
* Featured Image then first image from the_content HTML
* and filter the post_thumbnail_html
@@ -12,7 +18,7 @@
*
* @return string $html Thumbnail image with markup.
*/
-function jetpack_featured_images_fallback_get_image( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
+function jetpack_featured_images_fallback_get_image( $html, $post_id, $post_thumbnail_id, $size, $attr ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$opts = jetpack_featured_images_get_settings();
if ( ! empty( $html ) || (bool) 1 !== (bool) $opts['fallback-option'] ) {
@@ -54,10 +60,10 @@ function jetpack_featured_images_fallback_get_image( $html, $post_id, $post_thum
$image_src = Jetpack_PostImages::fit_image_url( $image['src'], $image['width'], $image['height'] );
- // Use the theme's crop setting rather than forcing to true
+ // Use the theme's crop setting rather than forcing to true.
$image_src = add_query_arg( 'crop', $image['crop'], $image_src );
- $html = '<img src="' . esc_url( $image_src ) . '" title="' . esc_attr( strip_tags( get_the_title() ) ) . '" class="attachment-' . esc_attr( $size ) . ' wp-post-image" />';
+ $html = '<img src="' . esc_url( $image_src ) . '" title="' . esc_attr( wp_strip_all_tags( get_the_title() ) ) . '" class="attachment-' . esc_attr( $size ) . ' wp-post-image" />';
return trim( $html );
}
@@ -118,7 +124,7 @@ function jetpack_featured_images_fallback_get_image_src( $post_id, $post_thumbna
$image_src = Jetpack_PostImages::fit_image_url( $image['src'], $image['width'], $image['height'] );
- // Use the theme's crop setting rather than forcing to true
+ // Use the theme's crop setting rather than forcing to true.
$image_src = add_query_arg( 'crop', $image['crop'], $image_src );
return esc_url( $image_src );
@@ -144,7 +150,7 @@ function jetpack_has_featured_image( $post = null ) {
*
* @param array $classes Classes for the post element.
* @param array $class Optional. Comma separated list of additional classes.
- * @param array $post_id Unique The post ID to check
+ * @param array $post_id Unique The post ID to check.
*
* @return array $classes
*/
diff --git a/plugins/jetpack/modules/theme-tools/content-options/featured-images.php b/plugins/jetpack/modules/theme-tools/content-options/featured-images.php
index af2dd585..1e602f87 100644
--- a/plugins/jetpack/modules/theme-tools/content-options/featured-images.php
+++ b/plugins/jetpack/modules/theme-tools/content-options/featured-images.php
@@ -1,8 +1,18 @@
<?php
/**
+ * Theme Tools: functions for Featured Images.
+ *
+ * @package automattic/jetpack
+ */
+
+/**
* The function to prevent for Featured Images to be displayed in a theme.
+ *
+ * @param array $metadata Post metadata.
+ * @param int $object_id Post ID.
+ * @param string $meta_key Metadata key.
*/
-function jetpack_featured_images_remove_post_thumbnail( $metadata, $object_id, $meta_key, $single ) {
+function jetpack_featured_images_remove_post_thumbnail( $metadata, $object_id, $meta_key ) {
$opts = jetpack_featured_images_get_settings();
/**
@@ -64,7 +74,7 @@ function jetpack_featured_images_remove_post_thumbnail( $metadata, $object_id, $
return $metadata;
}
}
-add_filter( 'get_post_metadata', 'jetpack_featured_images_remove_post_thumbnail', true, 4 );
+add_filter( 'get_post_metadata', 'jetpack_featured_images_remove_post_thumbnail', true, 3 );
/**
* Check if we are in a WooCommerce Product in order to exclude it from the is_single check.
@@ -89,7 +99,7 @@ function jetpack_is_shop_page() {
$is_static_front_page = 'page' === get_option( 'show_on_front' );
if ( $is_static_front_page && $front_page_id === $current_page_id ) {
- $is_shop_page = ( $current_page_id === wc_get_page_id( 'shop' ) ) ? true : false;
+ $is_shop_page = ( wc_get_page_id( 'shop' ) === $current_page_id ) ? true : false;
} else {
$is_shop_page = is_shop();
}
diff --git a/plugins/jetpack/modules/theme-tools/content-options/post-details.php b/plugins/jetpack/modules/theme-tools/content-options/post-details.php
index b5f5c64a..25220fbd 100644
--- a/plugins/jetpack/modules/theme-tools/content-options/post-details.php
+++ b/plugins/jetpack/modules/theme-tools/content-options/post-details.php
@@ -1,5 +1,11 @@
<?php
/**
+ * Theme Tools: functions for Post Details.
+ *
+ * @package automattic/jetpack
+ */
+
+/**
* The function to include Post Details in a theme's stylesheet.
*/
function jetpack_post_details_enqueue_scripts() {
@@ -16,27 +22,27 @@ function jetpack_post_details_enqueue_scripts() {
$elements = array();
// If date option is unticked, add it to the list of classes.
- if ( 1 != $date_option && ! empty( $date ) ) {
+ if ( 1 !== (int) $date_option && ! empty( $date ) ) {
$elements[] = $date;
}
// If categories option is unticked, add it to the list of classes.
- if ( 1 != $categories_option && ! empty( $categories ) ) {
+ if ( 1 !== (int) $categories_option && ! empty( $categories ) ) {
$elements[] = $categories;
}
// If tags option is unticked, add it to the list of classes.
- if ( 1 != $tags_option && ! empty( $tags ) ) {
+ if ( 1 !== (int) $tags_option && ! empty( $tags ) ) {
$elements[] = $tags;
}
// If author option is unticked, add it to the list of classes.
- if ( 1 != $author_option && ! empty( $author ) ) {
+ if ( 1 !== (int) $author_option && ! empty( $author ) ) {
$elements[] = $author;
}
// If comment option is unticked, add it to the list of classes.
- if ( 1 != $comment_option && ! empty( $comment ) ) {
+ if ( 1 !== (int) $comment_option && ! empty( $comment ) ) {
$elements[] = $comment;
}
@@ -58,6 +64,8 @@ add_action( 'wp_enqueue_scripts', 'jetpack_post_details_enqueue_scripts' );
/**
* Adds custom classes to the array of body classes.
+ *
+ * @param array $classes Classes for the body element.
*/
function jetpack_post_details_body_classes( $classes ) {
// Make sure we can proceed.
@@ -71,27 +79,27 @@ function jetpack_post_details_body_classes( $classes ) {
list( $date, $categories, $tags, $author, $comment ) = $definied;
// If date option is unticked, add a class of 'date-hidden' to the body.
- if ( 1 != $date_option && ! empty( $date ) ) {
+ if ( 1 !== (int) $date_option && ! empty( $date ) ) {
$classes[] = 'date-hidden';
}
// If categories option is unticked, add a class of 'categories-hidden' to the body.
- if ( 1 != $categories_option && ! empty( $categories ) ) {
+ if ( 1 !== (int) $categories_option && ! empty( $categories ) ) {
$classes[] = 'categories-hidden';
}
// If tags option is unticked, add a class of 'tags-hidden' to the body.
- if ( 1 != $tags_option && ! empty( $tags ) ) {
+ if ( 1 !== (int) $tags_option && ! empty( $tags ) ) {
$classes[] = 'tags-hidden';
}
// If author option is unticked, add a class of 'author-hidden' to the body.
- if ( 1 != $author_option && ! empty( $author ) ) {
+ if ( 1 !== (int) $author_option && ! empty( $author ) ) {
$classes[] = 'author-hidden';
}
// If comment option is unticked, add a class of 'comment-hidden' to the body.
- if ( 1 != $comment_option && ! empty( $comment ) ) {
+ if ( 1 !== (int) $comment_option && ! empty( $comment ) ) {
$classes[] = 'comment-hidden';
}
diff --git a/plugins/jetpack/modules/theme-tools/featured-content.php b/plugins/jetpack/modules/theme-tools/featured-content.php
index 5eca3369..d6b17a10 100644
--- a/plugins/jetpack/modules/theme-tools/featured-content.php
+++ b/plugins/jetpack/modules/theme-tools/featured-content.php
@@ -1,4 +1,9 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Theme Tools: functions for Featured Content enhancements.
+ *
+ * @package automattic/jetpack
+ */
use Automattic\Jetpack\Constants;
@@ -34,6 +39,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
* add_theme_support( 'featured-content' ).
*
* @see Featured_Content::init()
+ * @var int
*/
public static $max_posts = 15;
@@ -44,6 +50,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
* add_theme_support( 'featured-content' ).
*
* @see Featured_Content::init()
+ * @var array
*/
public static $post_types = array( 'post' );
@@ -52,6 +59,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
* a custom tag name that will be stored in this variable.
*
* @see Featured_Content::hide_featured_term
+ * @var string
*/
public static $tag;
@@ -125,12 +133,12 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
unset( $theme_support[0]['additional_post_types'] );
}
- // Themes can allow Featured Content pages
+ // Themes can allow Featured Content pages.
if ( isset( $theme_support[0]['post_types'] ) ) {
self::$post_types = array_merge( self::$post_types, (array) $theme_support[0]['post_types'] );
self::$post_types = array_unique( self::$post_types );
- // register post_tag support for each post type
+ // register post_tag support for each post type.
foreach ( self::$post_types as $post_type ) {
register_taxonomy_for_object_type( 'post_tag', $post_type );
}
@@ -147,7 +155,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
if ( self::get_setting( 'hide-tag' ) ) {
$settings = self::get_setting();
- // This is done before setting filters for get_terms in order to avoid an infinite filter loop
+ // This is done before setting filters for get_terms in order to avoid an infinite filter loop.
self::$tag = get_term_by( 'name', $settings['tag-name'], 'post_tag' );
add_filter( 'get_terms', array( __CLASS__, 'hide_featured_term' ), 10, 3 );
@@ -178,7 +186,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
$featured_posts = get_posts(
array(
'include' => $post_ids,
- 'posts_per_page' => count( $post_ids ),
+ 'posts_per_page' => count( $post_ids ), // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
'post_type' => self::$post_types,
'suppress_filters' => false,
)
@@ -280,6 +288,9 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
* Flush the Post Tag relationships cache.
*
* Hooks in the "update_option_featured-content" action.
+ *
+ * @param array $prev Previous option data.
+ * @param array $opts New option data.
*/
public static function flush_post_tag_cache( $prev, $opts ) {
if ( ! empty( $opts ) && ! empty( $opts['tag-id'] ) ) {
@@ -305,7 +316,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
*
* @uses Featured_Content::get_featured_post_ids();
* @uses Featured_Content::get_setting();
- * @param WP_Query $query
+ * @param WP_Query $query WP_Query object.
* @return WP_Query Possibly modified WP_Query
*/
public static function pre_get_posts( $query ) {
@@ -330,7 +341,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
$settings = self::get_setting();
// Bail if the user wants featured posts always displayed.
- if ( true == $settings['show-all'] ) {
+ if ( $settings['show-all'] ) {
return;
}
@@ -362,7 +373,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
public static function delete_post_tag( $tag_id ) {
$settings = self::get_setting();
- if ( empty( $settings['tag-id'] ) || $tag_id != $settings['tag-id'] ) {
+ if ( empty( $settings['tag-id'] ) || $tag_id != $settings['tag-id'] ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual
return;
}
@@ -381,6 +392,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
*
* @param array $terms A list of term objects. This is the return value of get_terms().
* @param array $taxonomies An array of taxonomy slugs.
+ * @param array $args Array of get_terms() arguments.
* @return array $terms
*/
public static function hide_featured_term( $terms, $taxonomies, $args ) {
@@ -397,7 +409,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
}
// We only want to hide the featured tag.
- if ( ! in_array( 'post_tag', $taxonomies ) ) {
+ if ( ! in_array( 'post_tag', $taxonomies, true ) ) {
return $terms;
}
@@ -407,7 +419,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
}
// Bail if term objects are unavailable.
- if ( 'all' != $args['fields'] ) {
+ if ( 'all' !== $args['fields'] ) {
return $terms;
}
@@ -451,7 +463,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
}
// Make sure we are in the correct taxonomy.
- if ( 'post_tag' != $taxonomy ) {
+ if ( 'post_tag' !== $taxonomy ) {
return $terms;
}
@@ -499,7 +511,12 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
'featured_content',
array(
'title' => esc_html__( 'Featured Content', 'jetpack' ),
- 'description' => sprintf( __( 'Easily feature all posts with the <a href="%1$s">"featured" tag</a> or a tag of your choice. Your theme supports up to %2$s posts in its featured content area.', 'jetpack' ), admin_url( '/edit.php?tag=featured' ), absint( self::$max_posts ) ),
+ 'description' => sprintf(
+ /* translators: %1$s: Link to 'featured' admin tag view. %2$s: Max number of posts shown by theme in featured content area. */
+ __( 'Easily feature all posts with the <a href="%1$s">"featured" tag</a> or a tag of your choice. Your theme supports up to %2$s posts in its featured content area.', 'jetpack' ),
+ admin_url( '/edit.php?tag=featured' ),
+ absint( self::$max_posts )
+ ),
'priority' => 130,
'theme_supports' => 'featured-content',
)
@@ -578,7 +595,16 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
* Renders all form fields on the Settings -> Reading screen.
*/
public static function render_form() {
- printf( __( 'The settings for Featured Content have <a href="%s">moved to Appearance &rarr; Customize</a>.', 'jetpack' ), admin_url( 'customize.php?#accordion-section-featured_content' ) );
+ printf(
+ wp_kses(
+ /* translators: %s: Link to the Featured Content settings in the Customizer. */
+ __( 'The settings for Featured Content have <a href="%s">moved to Appearance &rarr; Customize</a>.', 'jetpack' ),
+ array(
+ 'a' => array( 'href' => array() ),
+ )
+ ),
+ esc_url( admin_url( 'customize.php?#accordion-section-featured_content' ) )
+ );
}
/**
@@ -626,7 +652,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
$options = wp_parse_args( $saved, $defaults );
$options = array_intersect_key( $options, $defaults );
- if ( 'all' != $key ) {
+ if ( 'all' !== $key ) {
return isset( $options[ $key ] ) ? $options[ $key ] : false;
}
@@ -642,7 +668,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
*
* @uses Featured_Content::delete_transient()
*
- * @param array $input
+ * @param array $input Array of settings input.
* @return array $output
*/
public static function validate_settings( $input ) {
@@ -689,11 +715,19 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
}
}
+ /**
+ * Update Featured Content term data as necessary when a shared term is split.
+ *
+ * @param int $old_term_id ID of the formerly shared term.
+ * @param int $new_term_id ID of the new term created for the $term_taxonomy_id.
+ * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split.
+ * @param string $taxonomy Taxonomy for the split term.
+ */
public static function jetpack_update_featured_content_for_split_terms( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
$featured_content_settings = get_option( 'featured-content', array() );
// Check to see whether the stored tag ID is the one that's just been split.
- if ( isset( $featured_content_settings['tag-id'] ) && $old_term_id == $featured_content_settings['tag-id'] && 'post_tag' == $taxonomy ) {
+ if ( isset( $featured_content_settings['tag-id'] ) && $old_term_id == $featured_content_settings['tag-id'] && 'post_tag' === $taxonomy ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
// We have a match, so we swap out the old tag ID for the new one and resave the option.
$featured_content_settings['tag-id'] = $new_term_id;
update_option( 'featured-content', $featured_content_settings );
@@ -705,7 +739,7 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
* Adds the featured content plugin to the set of files for which action
* handlers should be copied when the theme context is loaded by the REST API.
*
- * @param array $copy_dirs Copy paths with actions to be copied
+ * @param array $copy_dirs Copy paths with actions to be copied.
* @return array Copy paths with featured content plugin
*/
function wpcom_rest_api_featured_content_copy_plugin_actions( $copy_dirs ) {
@@ -716,6 +750,8 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
/**
* Delayed initialization for API Requests.
+ *
+ * @param object $request REST request object.
*/
function wpcom_rest_request_before_callbacks( $request ) {
Featured_Content::init();
@@ -723,8 +759,8 @@ if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'pl
}
if ( Constants::is_true( 'IS_WPCOM' ) && Constants::is_true( 'REST_API_REQUEST' ) ) {
- add_filter( 'rest_request_before_callbacks', 'wpcom_rest_request_before_callbacks');
+ add_filter( 'rest_request_before_callbacks', 'wpcom_rest_request_before_callbacks' );
}
Featured_Content::setup();
-} // end if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {
+}
diff --git a/plugins/jetpack/modules/theme-tools/infinite-scroll.php b/plugins/jetpack/modules/theme-tools/infinite-scroll.php
index ac5a0aa8..57bb1f8b 100644
--- a/plugins/jetpack/modules/theme-tools/infinite-scroll.php
+++ b/plugins/jetpack/modules/theme-tools/infinite-scroll.php
@@ -1,6 +1,8 @@
<?php
/**
- * INFINITE SCROLL
+ * Theme Tools: Infinite Scroll functions.
+ *
+ * @package automattic/jetpack
*/
/**
@@ -14,20 +16,20 @@
* @return null
*/
function jetpack_load_infinite_scroll_annotation() {
- if ( is_admin() && isset( $_GET['page'] ) && 'jetpack' == $_GET['page'] ) {
- $theme = wp_get_theme();
+ if ( is_admin() && isset( $_GET['page'] ) && 'jetpack' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Function loads theme specific IS file provided by Jetpack if possible.
+ $theme = wp_get_theme();
if ( ! is_a( $theme, 'WP_Theme' ) && ! is_array( $theme ) ) {
return;
}
/** This filter is already documented in modules/infinite-scroll/infinity.php */
- $customization_file = apply_filters( 'infinite_scroll_customization_file', dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Stylesheet']}.php", $theme['Stylesheet'] );
+ $customization_file = apply_filters( 'infinite_scroll_customization_file', __DIR__ . "/infinite-scroll/themes/{$theme['Stylesheet']}.php", $theme['Stylesheet'] );
if ( is_readable( $customization_file ) ) {
require_once $customization_file;
} elseif ( ! empty( $theme['Template'] ) ) {
- $customization_file = dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Template']}.php";
+ $customization_file = __DIR__ . "/infinite-scroll/themes/{$theme['Template']}.php";
if ( is_readable( $customization_file ) ) {
require_once $customization_file;
@@ -40,7 +42,6 @@ add_action( 'setup_theme', 'jetpack_load_infinite_scroll_annotation' );
/**
* Prevent IS from being activated if theme doesn't support it
*
- * @param bool $can_activate
* @filter jetpack_can_activate_infinite-scroll
* @return bool
*/
diff --git a/plugins/jetpack/modules/theme-tools/random-redirect.php b/plugins/jetpack/modules/theme-tools/random-redirect.php
index e78e0277..dbebad12 100644
--- a/plugins/jetpack/modules/theme-tools/random-redirect.php
+++ b/plugins/jetpack/modules/theme-tools/random-redirect.php
@@ -1,13 +1,21 @@
<?php
-/*
-Plugin Name: Random Redirect
-Plugin URI: https://wordpress.org/extend/plugins/random-redirect/
-Description: Allows you to create a link to yourblog.example.com/?random which will redirect someone to a random post on your blog, in a StumbleUpon-like fashion.
-Version: 1.2-wpcom
-Author: Matt Mullenweg
-Author URI: https://ma.tt/
-*/
+/**
+ * Plugin Name: Random Redirect
+ * Plugin URI: https://wordpress.org/extend/plugins/random-redirect/
+ * Description: Allows you to create a link to yourblog.example.com/?random which will redirect someone to a random post on your blog, in a StumbleUpon-like fashion.
+ * Version: 1.2-wpcom
+ * Author: Matt Mullenweg
+ * Author URI: https://ma.tt/
+ * Text Domain: jetpack
+ *
+ * @package automattic/jetpack
+ */
+// phpcs:disable WordPress.Security.NonceVerification -- No changes to the site here, it just redirects.
+
+/**
+ * Redirects to a random post on the site.
+ */
function jetpack_matt_random_redirect() {
// Verify that the Random Redirect plugin this code is from is not active
// See https://plugins.trac.wordpress.org/ticket/1898
@@ -18,27 +26,8 @@ function jetpack_matt_random_redirect() {
}
}
- // Set default post type.
- $post_type = get_post_type();
-
- // Set default category type
- if ( is_category() ) {
- $category = get_the_category();
- if ( isset( $category ) && ! empty( $category ) ) {
- $random_cat_id = $category[0]->term_id;
- }
- }
-
- // Set author name if we're on an author archive.
- if ( is_author() ) {
- $random_author_name = get_the_author_meta( 'user_login' );
- $random_author_query = 'AND user_login = "' . $random_author_name . '"';
- } else {
- $random_author_query = '';
- }
-
// Acceptable URL formats: /[...]/?random=[post type], /?random, /&random, /&random=1
- if ( ! isset( $_GET['random'] ) && ! in_array( strtolower( $_SERVER['REQUEST_URI'] ), array( '/&random', '/&random=1' ) ) ) {
+ if ( ! isset( $_GET['random'] ) && ! ( isset( $_SERVER['REQUEST_URI'] ) && in_array( strtolower( $_SERVER['REQUEST_URI'] ), array( '/&random', '/&random=1' ), true ) ) ) {
return;
}
@@ -48,18 +37,22 @@ function jetpack_matt_random_redirect() {
}
// Persistent AppEngine abuse. ORDER BY RAND is expensive.
- if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'AppEngine-Google' ) ) {
+ if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && strstr( filter_var( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ), 'AppEngine-Google' ) ) {
wp_die( 'Please <a href="https://en.support.wordpress.com/contact/" rel="noopener noreferrer" target="_blank">contact support</a>' );
}
- // Set the category ID if the parameter is set.
- if ( isset( $_GET['random_cat_id'] ) ) {
- $random_cat_id = (int) $_GET['random_cat_id'];
- }
+ $where = array(
+ "post_password = ''",
+ "post_status = 'publish'",
+ );
+ $where_args = array();
+
+ // Set default post type.
+ $post_type = get_post_type();
// Change the post type if the parameter is set.
- if ( isset( $_GET['random_post_type'] ) && post_type_exists( $_GET['random_post_type'] ) ) {
- $post_type = $_GET['random_post_type'];
+ if ( isset( $_GET['random_post_type'] ) && post_type_exists( sanitize_key( $_GET['random_post_type'] ) ) ) {
+ $post_type = sanitize_key( $_GET['random_post_type'] );
}
// Don't show a random page if 'page' isn't specified as the post type specifically.
@@ -67,12 +60,37 @@ function jetpack_matt_random_redirect() {
$post_type = 'post';
}
+ $where[] = 'p.post_type = %s';
+ $where_args[] = $post_type;
+
+ // Set author name if we're on an author archive.
+ if ( is_author() ) {
+ $where[] = 'post_author = %s';
+ $where_args[] = get_the_author_meta( 'ID' );
+ }
+
+ // Set default category type
+ if ( is_category() ) {
+ $category = get_the_category();
+ if ( isset( $category ) && ! empty( $category ) ) {
+ $random_cat_id = $category[0]->term_id;
+ }
+ }
+
+ // Set the category ID if the parameter is set.
+ if ( isset( $_GET['random_cat_id'] ) ) {
+ $random_cat_id = (int) $_GET['random_cat_id'];
+ }
+
global $wpdb;
+ $where = join( ' AND ', $where );
if ( isset( $random_cat_id ) ) {
- $random_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts AS p INNER JOIN $wpdb->term_relationships AS tr ON (p.ID = tr.object_id AND tr.term_taxonomy_id = %s) INNER JOIN $wpdb->term_taxonomy AS tt ON(tr.term_taxonomy_id = tt.term_taxonomy_id AND taxonomy = 'category') WHERE p.post_type = %s AND post_password = '' AND post_status = 'publish' %s ORDER BY RAND() LIMIT 1", $random_cat_id, $post_type, $random_author_query ) );
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber
+ $random_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts AS p INNER JOIN $wpdb->term_relationships AS tr ON (p.ID = tr.object_id AND tr.term_taxonomy_id = %s) INNER JOIN $wpdb->term_taxonomy AS tt ON(tr.term_taxonomy_id = tt.term_taxonomy_id AND taxonomy = 'category') WHERE $where ORDER BY RAND() LIMIT 1", $random_cat_id, ...$where_args ) );
} else {
- $random_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_password = '' AND post_status = 'publish' %s ORDER BY RAND() LIMIT 1", $post_type, $random_author_query ) );
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
+ $random_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts AS p WHERE $where ORDER BY RAND() LIMIT 1", ...$where_args ) );
}
$permalink = get_permalink( $random_id );
diff --git a/plugins/jetpack/modules/theme-tools/responsive-videos.php b/plugins/jetpack/modules/theme-tools/responsive-videos.php
index 32cee5e9..b4e9da71 100644
--- a/plugins/jetpack/modules/theme-tools/responsive-videos.php
+++ b/plugins/jetpack/modules/theme-tools/responsive-videos.php
@@ -1,4 +1,9 @@
<?php
+/**
+ * Theme Tools: Responsive videos enhancements.
+ *
+ * @package automattic/jetpack
+ */
/**
* Load the Responsive videos plugin
@@ -31,10 +36,10 @@ function jetpack_responsive_videos_init() {
}
add_action( 'after_setup_theme', 'jetpack_responsive_videos_init', 99 );
-
/**
* Adds a wrapper to videos and enqueue script
*
+ * @param string $html The video embed HTML.
* @return string
*/
function jetpack_responsive_videos_embed_html( $html ) {
@@ -59,14 +64,19 @@ function jetpack_responsive_videos_embed_html( $html ) {
return $html;
}
- if ( defined( 'SCRIPT_DEBUG' ) && true == SCRIPT_DEBUG ) {
+ if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
wp_enqueue_script( 'jetpack-responsive-videos-script', plugins_url( 'responsive-videos/responsive-videos.js', __FILE__ ), array( 'jquery' ), '1.3', true );
} else {
wp_enqueue_script( 'jetpack-responsive-videos-min-script', plugins_url( 'responsive-videos/responsive-videos.min.js', __FILE__ ), array( 'jquery' ), '1.3', true );
}
// Enqueue CSS to ensure compatibility with all themes
- wp_enqueue_style( 'jetpack-responsive-videos-style', plugins_url( 'responsive-videos/responsive-videos.css', __FILE__ ) );
+ wp_enqueue_style(
+ 'jetpack-responsive-videos-style',
+ plugins_url( 'responsive-videos/responsive-videos.css', __FILE__ ),
+ array(),
+ JETPACK__VERSION
+ );
return '<div class="jetpack-video-wrapper">' . $html . '</div>';
}
@@ -99,7 +109,7 @@ function jetpack_responsive_videos_maybe_wrap_oembed( $html, $url = null ) {
}
/**
- * oEmbed Video Providers.
+ * The oEmbed video providers.
*
* An allowed list of oEmbed video provider Regex patterns to check against before wrapping the output.
*
diff --git a/plugins/jetpack/modules/theme-tools/site-logo.php b/plugins/jetpack/modules/theme-tools/site-logo.php
index 78f69ba1..12193752 100644
--- a/plugins/jetpack/modules/theme-tools/site-logo.php
+++ b/plugins/jetpack/modules/theme-tools/site-logo.php
@@ -1,6 +1,7 @@
<?php
-/*
- * Site Logo.
+/**
+ * Theme Tools: Site Logo.
+ *
* @see https://jetpack.com/support/site-logo/
*
* This feature will only be activated for themes that declare their support.
@@ -8,14 +9,15 @@
* 'after_setup_theme' action:
*
* $args = array(
- * 'header-text' => array(
- * 'site-title',
- * 'site-description',
- * ),
- * 'size' => 'medium',
+ * 'header-text' => array(
+ * 'site-title',
+ * 'site-description',
+ * ),
+ * 'size' => 'medium',
* );
* add_theme_support( 'site-logo', $args );
*
+ * @package automattic/jetpack
*/
/**
@@ -29,13 +31,13 @@ function site_logo_init() {
// Only load our code if our theme declares support, and the standalone plugin is not activated.
if ( current_theme_supports( 'site-logo' ) && ! class_exists( 'Site_Logo', false ) ) {
// Load our class for namespacing.
- require dirname( __FILE__ ) . '/site-logo/inc/class-site-logo.php';
+ require __DIR__ . '/site-logo/inc/class-site-logo.php';
// Load template tags.
- require dirname( __FILE__ ) . '/site-logo/inc/functions.php';
+ require __DIR__ . '/site-logo/inc/functions.php';
// Load backwards-compatible template tags.
- require dirname( __FILE__ ) . '/site-logo/inc/compat.php';
+ require __DIR__ . '/site-logo/inc/compat.php';
}
}
add_action( 'init', 'site_logo_init' );
diff --git a/plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control-rtl.css b/plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control-rtl.css
deleted file mode 100644
index e0d9a2c4..00000000
--- a/plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control-rtl.css
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-/**
- * Styles for the Site Logo control.
- */
-#customize-control-site_logo .current {
- margin-bottom: 6px;
-}
-
-#customize-control-site_logo .current span {
- border: 1px solid #eee;
- border-radius: 2px;
- color: #555;
- display: block;
- overflow: hidden;
- line-height: 40px;
- min-height: 40px;
- padding: 0 6px;
- text-align: center;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-#customize-control-site_logo .current img {
- max-width: 100%;
-}
-
-#customize-control-site_logo button.new,
-#customize-control-site_logo button.change,
-#customize-control-site_logo button.remove {
- height: auto;
- width: 48%;
- white-space: normal;
-}
-
-#customize-control-site_logo .remove {
- float: right;
- margin-left: 3px;
-}
-
-#customize-control-site_logo .new,
-#customize-control-site_logo .change {
- float: left;
-}
-
-#customize-control-site_logo .customize-control-description {
- display: block;
- clear: both;
- margin-bottom: 10px;
-} \ No newline at end of file
diff --git a/plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control-rtl.min.css b/plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control-rtl.min.css
deleted file mode 100644
index f07c2f74..00000000
--- a/plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control-rtl.min.css
+++ /dev/null
@@ -1 +0,0 @@
-#customize-control-site_logo .current{margin-bottom:6px}#customize-control-site_logo .current span{border:1px solid #eee;border-radius:2px;color:#555;display:block;overflow:hidden;line-height:40px;min-height:40px;padding:0 6px;text-align:center;text-overflow:ellipsis;white-space:nowrap}#customize-control-site_logo .current img{max-width:100%}#customize-control-site_logo button.change,#customize-control-site_logo button.new,#customize-control-site_logo button.remove{height:auto;width:48%;white-space:normal}#customize-control-site_logo .remove{float:right;margin-left:3px}#customize-control-site_logo .change,#customize-control-site_logo .new{float:left}#customize-control-site_logo .customize-control-description{display:block;clear:both;margin-bottom:10px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control.css b/plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control.css
deleted file mode 100644
index b9a10fe6..00000000
--- a/plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control.css
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Styles for the Site Logo control.
- */
-#customize-control-site_logo .current {
- margin-bottom: 6px;
-}
-
-#customize-control-site_logo .current span {
- border: 1px solid #eee;
- -webkit-border-radius: 2px;
- border-radius: 2px;
- color: #555;
- display: block;
- overflow: hidden;
- line-height: 40px;
- min-height: 40px;
- padding: 0 6px;
- text-align: center;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-#customize-control-site_logo .current img {
- max-width: 100%;
-}
-
-#customize-control-site_logo button.new,
-#customize-control-site_logo button.change,
-#customize-control-site_logo button.remove {
- height: auto;
- width: 48%;
- white-space: normal;
-}
-
-#customize-control-site_logo .remove {
- float: left;
- margin-right: 3px;
-}
-
-#customize-control-site_logo .new,
-#customize-control-site_logo .change {
- float: right;
-}
-
-#customize-control-site_logo .customize-control-description {
- display: block;
- clear: both;
- margin-bottom: 10px;
-} \ No newline at end of file
diff --git a/plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control.min.css b/plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control.min.css
deleted file mode 100644
index 0c1eede3..00000000
--- a/plugins/jetpack/modules/theme-tools/site-logo/css/site-logo-control.min.css
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-#customize-control-site_logo .current{margin-bottom:6px}#customize-control-site_logo .current span{border:1px solid #eee;border-radius:2px;color:#555;display:block;overflow:hidden;line-height:40px;min-height:40px;padding:0 6px;text-align:center;text-overflow:ellipsis;white-space:nowrap}#customize-control-site_logo .current img{max-width:100%}#customize-control-site_logo button.change,#customize-control-site_logo button.new,#customize-control-site_logo button.remove{height:auto;width:48%;white-space:normal}#customize-control-site_logo .remove{float:left;margin-right:3px}#customize-control-site_logo .change,#customize-control-site_logo .new{float:right}#customize-control-site_logo .customize-control-description{display:block;clear:both;margin-bottom:10px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo-control.php b/plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo-control.php
deleted file mode 100644
index 209cc000..00000000
--- a/plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo-control.php
+++ /dev/null
@@ -1,128 +0,0 @@
-<?php
-/**
- * Custom logo uploader control for the Customizer.
- *
- * @package Jetpack
- */
-class Site_Logo_Image_Control extends WP_Customize_Control {
- /**
- * Constructor for our custom control.
- *
- * @param object $wp_customize
- * @param string $control_id
- * @param array $args
- * @uses Site_Logo_Image_Control::l10n()
- */
- public function __construct( $wp_customize, $control_id, $args = array() ) {
- // declare these first so they can be overridden
- $this->l10n = array(
- 'upload' => __( 'Add logo', 'jetpack' ),
- 'set' => __( 'Set as logo', 'jetpack' ),
- 'choose' => __( 'Choose logo', 'jetpack' ),
- 'change' => __( 'Change logo', 'jetpack' ),
- 'remove' => __( 'Remove logo', 'jetpack' ),
- 'placeholder' => __( 'No logo set', 'jetpack' ),
- );
-
- parent::__construct( $wp_customize, $control_id, $args );
- }
-
- /**
- * This will be critical for our JS constructor.
- */
- public $type = 'site_logo';
-
- /**
- * Allows overriding of global labels by a specific control.
- */
- public $l10n = array();
-
- /**
- * The type of files that should be allowed by the media modal.
- */
- public $mime_type = 'image';
-
- /**
- * Enqueue our media manager resources, scripts, and styles.
- *
- * @uses wp_enqueue_media()
- * @uses wp_enqueue_style()
- * @uses wp_enqueue_script()
- * @uses plugins_url()
- */
- public function enqueue() {
- // Enqueues all needed media resources.
- wp_enqueue_media();
-
- /*
- * Enqueue our control script and styles.
- */
-
- // We only enqueue a minified version of the file on prod. Jetpack.
- $min = (
- ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )
- || ( defined( 'IS_WPCOM' ) && IS_WPCOM )
- )
- ? ''
- : '.min';
-
- wp_enqueue_style(
- 'site-logo-control',
- plugins_url( '../css/site-logo-control.css', __FILE__ ),
- array(),
- JETPACK__VERSION
- );
- wp_style_add_data( 'site-logo-control', 'rtl', 'replace' );
- wp_style_add_data( 'site-logo-control', 'suffix', $min );
-
- wp_enqueue_script( 'site-logo-control', plugins_url( '../js/site-logo-control.js', __FILE__ ), array( 'media-views', 'customize-controls', 'underscore' ), '', true );
- }
-
- /**
- * Check if we have an active site logo.
- *
- * @uses get_option()
- * @return boolean
- */
- public function has_site_logo() {
- $logo = get_option( 'site_logo' );
-
- if ( empty( $logo['url'] ) ) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Display our custom control in the Customizer.
- *
- * @uses Site_Logo_Image_Control::l10n()
- * @uses Site_Logo_Image_Control::mime_type()
- * @uses Site_Logo_Image_Control::label()
- * @uses Site_Logo_Image_Control::description()
- * @uses esc_attr()
- * @uses esc_html()
- */
- public function render_content() {
- // We do this to allow the upload control to specify certain labels
- $l10n = json_encode( $this->l10n );
-
- // Control title
- printf(
- '<span class="customize-control-title" data-l10n="%s" data-mime="%s">%s</span>',
- esc_attr( $l10n ),
- esc_attr( $this->mime_type ),
- esc_html( $this->label )
- );
-
- // Control description
- if ( ! empty( $this->description ) ) : ?>
- <span class="description customize-control-description"><?php echo $this->description; ?></span>
- <?php endif; ?>
-
- <div class="current"></div>
- <div class="actions"></div>
- <?php
- }
-}
diff --git a/plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo.php b/plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo.php
index 6793bf0a..66e77102 100644
--- a/plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo.php
+++ b/plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo.php
@@ -1,17 +1,25 @@
<?php
/**
- * Our Site Logo class for managing a theme-agnostic logo through the Customizer.
+ * Site Logo class main class file.
*
* @package automattic/jetpack
*/
+
+/**
+ * Site Logo class for managing a theme-agnostic logo through the Customizer.
+ */
class Site_Logo {
/**
* Stores our single instance.
+ *
+ * @var Site_Logo
*/
private static $instance;
/**
* Stores the attachment ID of the site logo.
+ *
+ * @var int
*/
public $logo;
@@ -173,7 +181,13 @@ class Site_Logo {
// Don't bother passing in header text classes if the theme supports custom headers.
if ( ! current_theme_supports( 'custom-header' ) ) {
$classes = jetpack_sanitize_header_text_classes( $this->header_text_classes() );
- wp_enqueue_script( 'site-logo-header-text', plugins_url( '../js/site-logo-header-text.js', __FILE__ ), array( 'media-views' ), '', true );
+ wp_enqueue_script(
+ 'site-logo-header-text',
+ plugins_url( '../js/site-logo-header-text.js', __FILE__ ),
+ array( 'media-views' ),
+ JETPACK__VERSION,
+ true
+ );
wp_localize_script( 'site-logo-header-text', 'site_logo_header_classes', array( 'classes' => $classes ) );
}
}
@@ -228,7 +242,7 @@ class Site_Logo {
?>
<!-- Site Logo: hide header text -->
<style type="text/css">
- <?php echo jetpack_sanitize_header_text_classes( $classes ); ?> {
+ <?php echo jetpack_sanitize_header_text_classes( $classes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> {
position: absolute;
clip: rect(1px, 1px, 1px, 1px);
}
@@ -251,7 +265,7 @@ class Site_Logo {
$valid_sizes[] = 'full';
// If the size declared in add_theme_support is valid, use it; otherwise, just go with 'thumbnail'.
- $size = ( isset( $args[0]['size'] ) && in_array( $args[0]['size'], $valid_sizes ) ) ? $args[0]['size'] : 'thumbnail';
+ $size = ( isset( $args[0]['size'] ) && in_array( $args[0]['size'], $valid_sizes, true ) ) ? $args[0]['size'] : 'thumbnail';
return $size;
}
@@ -259,7 +273,7 @@ class Site_Logo {
/**
* Make custom image sizes available to the media manager.
*
- * @param array $sizes
+ * @param array $sizes List of image sizes.
* @uses get_intermediate_image_sizes()
* @return array All default and registered custom image sizes.
*/
@@ -269,7 +283,7 @@ class Site_Logo {
// Have we got anything fun to work with?
if ( is_array( $intermediate ) && ! empty( $intermediate ) ) {
- foreach ( $intermediate as $key => $size ) {
+ foreach ( $intermediate as $size ) {
// If the size isn't already in the $sizes array, add it.
if ( ! array_key_exists( $size, $sizes ) ) {
$sizes[ $size ] = $size;
@@ -283,6 +297,8 @@ class Site_Logo {
/**
* Add site logos to media states in the Media Manager.
*
+ * @param array $media_states An array of media states.
+ *
* @return array The current attachment's media states.
*/
public function add_media_state( $media_states ) {
@@ -302,7 +318,7 @@ class Site_Logo {
/**
* Reset the site logo if the current logo is deleted in the media manager.
*
- * @param int $site_id
+ * @param int $post_id Attachment ID.
* @uses Site_Logo::remove_site_logo()
*/
public function reset_on_attachment_delete( $post_id ) {
@@ -334,6 +350,7 @@ class Site_Logo {
* Adds custom classes to the array of body classes.
*
* @uses Site_Logo::has_site_logo()
+ * @param array $classes Classes for the body element.
* @return array Array of <body> classes
*/
public function body_classes( $classes ) {
@@ -348,18 +365,18 @@ class Site_Logo {
/**
* Sanitize our header text Customizer setting.
*
- * @param $input
- * @return mixed 1 if checked, empty string if not checked.
+ * @param any $input The input value to sanitize.
+ * @return bool|string 1 if checked, empty string if not checked.
*/
public function sanitize_checkbox( $input ) {
- return ( 1 == $input ) ? 1 : '';
+ return ( 1 === (int) $input ) ? 1 : '';
}
/**
* Validate and sanitize a new site logo setting.
*
- * @param $input
- * @return mixed 1 if checked, empty string if not checked.
+ * @param any $input Logo setting value to sanitize.
+ * @return int Attachment post ID, or 0 if invalid.
*/
public function sanitize_logo_setting( $input ) {
$input = absint( $input );
diff --git a/plugins/jetpack/modules/theme-tools/site-logo/inc/functions.php b/plugins/jetpack/modules/theme-tools/site-logo/inc/functions.php
index 22e6c942..0d7881ae 100644
--- a/plugins/jetpack/modules/theme-tools/site-logo/inc/functions.php
+++ b/plugins/jetpack/modules/theme-tools/site-logo/inc/functions.php
@@ -1,6 +1,6 @@
<?php
/**
- * Functions and template tags for using site logos.
+ * Functions and template tags for Site Logo theme tool.
*
* @package automattic/jetpack
*/
@@ -11,6 +11,7 @@
* @uses get_option()
* @uses esc_url_raw()
* @uses set_url_scheme()
+ * @param string $show 'url' or 'id' for site logo.
* @return mixed The URL or ID of our site logo, false if not set
* @since 1.0
*/
@@ -55,7 +56,7 @@ function jetpack_get_site_logo_dimensions() {
// If the size is the default `thumbnail`, get its dimensions. Otherwise, get them from $_wp_additional_image_sizes
if ( empty( $size ) ) {
return false;
- } elseif ( 'thumbnail' == $size ) {
+ } elseif ( 'thumbnail' === $size ) {
$dimensions = array(
'width' => get_option( 'thumbnail_size_w' ),
'height' => get_option( 'thumbnail_size_h' ),
@@ -197,6 +198,7 @@ function jetpack_is_customize_preview() {
* Sanitize the string of classes used for header text.
* Limit to A-Z,a-z,0-9,(space),(comma),_,-
*
+ * @param string $classes Unsanitized string of CSS classes.
* @return string Sanitized string of CSS classes.
*/
function jetpack_sanitize_header_text_classes( $classes ) {
diff --git a/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo-control.js b/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo-control.js
deleted file mode 100644
index c4cce6c2..00000000
--- a/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo-control.js
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * JS for handling the Site Logo Customizer control.
- */
-( function( wp, $ ) {
- // nice shortcut
- var api = wp.customize;
- /**
- * The Customizer looks for wp.customizer.controlConstructor[type] functions
- * where type == the type member of a WP_Customize_Control
- */
- api.controlConstructor.site_logo = api.Control.extend( {
- /**
- * This method is called when the control is ready to run.
- * Do all of your setup and event binding here.
- */
- ready: function() {
- // this.container is a jQuery object of your container
-
- // grab the bits of data from the title for specifying this control
- var data = this.container.find( '.customize-control-title' ).data();
-
- // Use specific l10n data for this control where available
- this.l10n = data.l10n;
- // Grab mime type
- this.mime = data.mime;
-
- // Set up image container and button elements. Cache for re-use.
- this.$imgContainer = $( '#customize-control-site_logo .current' );
- this.$btnContainer = $( '#customize-control-site_logo .actions' );
- this.$img = $( '<img class="site-logo-thumbnail" />' ).prependTo( this.$imgContainer );
- this.$placeholder = $( '<span>' + this.l10n.placeholder + '</span>' ).prependTo(
- this.$imgContainer
- );
- this.$btnAdd = $(
- '<button type="button" class="button new">' + this.l10n.upload + '</button>'
- ).prependTo( this.$btnContainer );
- this.$btnChange = $(
- '<button type="button" class="button change">' + this.l10n.change + '</button>'
- ).prependTo( this.$btnContainer );
- this.$btnRemove = $(
- '<button type="button" class="button remove">' + this.l10n.remove + '</button>'
- ).prependTo( this.$btnContainer );
-
- // handy shortcut so we don't have to us _.bind every time we add a callback
- _.bindAll( this, 'removeImg', 'upload', 'render', 'pick' );
-
- this.$btnAdd.on( 'click', this.upload );
- this.$btnChange.on( 'click', this.upload );
- this.$btnRemove.on( 'click', this.removeImg );
-
- // Call render method whenever setting is changed.
- this.setting.bind( 'change', this.render );
- // Do initial rendering.
- this.render();
- },
- /**
- * Remember that _.bind was used to maintain `this` as the control
- * object rather than the usual jQuery way of binding to the DOM element.
- */
- upload: function( event ) {
- event.preventDefault();
-
- if ( ! this.frame ) {
- this.initFrame();
- }
-
- this.frame.open();
- },
- /**
- * Set the media frame so that it can be reused and accessed when needed.
- */
- initFrame: function() {
- this.frame = wp.media( {
- // The title of the media modal
- title: this.l10n.choose,
- // restrict to specified mime type
- library: {
- type: this.mime,
- },
- // Customize the submit button.
- button: {
- // Set the text of the button.
- text: this.l10n.set,
- },
- // Just one, thanks.
- multiple: false,
- } );
-
- // When an image is selected, run a callback.
- this.frame.on( 'select', this.pick );
- },
- /**
- * Fired when an image is selected in the media modal. Gets the selected
- * image information, and sets it within the control.
- */
- pick: function() {
- // get the attachment from the modal frame
- var attachment = this.frame
- .state()
- .get( 'selection' )
- .single();
- if ( 'image' === attachment.get( 'type' ) ) {
- // set the setting - the callback will take care of rendering
- this.setting( this.reduceMembers( attachment.toJSON() ) );
- }
- },
- /**
- * Reduces the attachment object to just the few desired members.
- * @param {object} attachment An attachment object provided by the
- * medial modal.
- * @return {object} A reduced media object.
- */
- reduceMembers: function( attachment ) {
- var desired = [ 'id', 'sizes', 'url' ],
- output = {};
- $.each( desired, function( i, key ) {
- output[ key ] = attachment[ key ];
- } );
- return output;
- },
- /**
- * Called on init and whenever a setting is changed. Shows the thumbnail
- * when there is one or the upload button when there isn't.
- */
- render: function() {
- var value = this.setting();
-
- if ( value && value.url ) {
- this.$placeholder.hide();
- if ( ! value.sizes || ! value.sizes.medium ) {
- this.$img.attr( 'src', value.url );
- } else {
- this.$img.attr( 'src', value.sizes.medium.url );
- }
- this.$img.show();
- this.$btnRemove.show();
- this.$btnChange.show();
- this.$btnAdd.hide();
- } else {
- this.$img.hide();
- this.$placeholder.show();
- this.$btnRemove.hide();
- this.$btnChange.hide();
- this.$btnAdd.show();
- }
- },
- /**
- * Called when the "Remove Image" link is clicked. Sets thes setting back
- * to its default state.
- * @param {object} event jQuery Event object from click event
- */
- removeImg: function( event ) {
- event.preventDefault();
- this.setting( {
- url: '',
- id: 0,
- } );
- },
- } );
-} )( this.wp, jQuery );
diff --git a/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo-control.min.js b/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo-control.min.js
deleted file mode 100644
index 171d98e8..00000000
--- a/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo-control.min.js
+++ /dev/null
@@ -1 +0,0 @@
-(function(a,c){var b=a.customize;b.controlConstructor.site_logo=b.Control.extend({ready:function(){var d=this.container.find(".customize-control-title").data();this.l10n=d.l10n;this.mime=d.mime;this.$imgContainer=c("#customize-control-site_logo .current");this.$btnContainer=c("#customize-control-site_logo .actions");this.$img=c('<img class="site-logo-thumbnail" />').prependTo(this.$imgContainer);this.$placeholder=c("<span>"+this.l10n.placeholder+"</span>").prependTo(this.$imgContainer);this.$btnAdd=c('<button type="button" class="button new">'+this.l10n.upload+"</button>").prependTo(this.$btnContainer);this.$btnChange=c('<button type="button" class="button change">'+this.l10n.change+"</button>").prependTo(this.$btnContainer);this.$btnRemove=c('<button type="button" class="button remove">'+this.l10n.remove+"</button>").prependTo(this.$btnContainer);_.bindAll(this,"removeImg","upload","render","pick");this.$btnAdd.on("click",this.upload);this.$btnChange.on("click",this.upload);this.$btnRemove.on("click",this.removeImg);this.setting.bind("change",this.render);this.render()},upload:function(d){d.preventDefault();if(!this.frame){this.initFrame()}this.frame.open()},initFrame:function(){this.frame=a.media({title:this.l10n.choose,library:{type:this.mime},button:{text:this.l10n.set},multiple:false});this.frame.on("select",this.pick)},pick:function(){var d=this.frame.state().get("selection").first().toJSON();d=this.reduceMembers(d);this.setting(d)},reduceMembers:function(f){var e=["id","sizes","url"],d={};c.each(e,function(h,g){d[g]=f[g]});return d},render:function(){var d=this.setting();if(d&&d.url){this.$placeholder.hide();if(!d.sizes||!d.sizes.medium){this.$img.attr("src",d.url)}else{this.$img.attr("src",d.sizes.medium.url)}this.$img.show();this.$btnRemove.show();this.$btnChange.show();this.$btnAdd.hide()}else{this.$img.hide();this.$placeholder.show();this.$btnRemove.hide();this.$btnChange.hide();this.$btnAdd.show()}},removeImg:function(d){d.preventDefault();this.setting({url:"",id:0})}})})(this.wp,jQuery); \ No newline at end of file
diff --git a/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo.js b/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo.js
deleted file mode 100644
index 6c959c0c..00000000
--- a/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo.js
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * JS for handling the Site Logo real-time display in the Customizer preview frame.
- */
-( function( $ ) {
- var api = wp.customize,
- $body,
- $anchor,
- $logo,
- size;
-
- function cacheSelectors() {
- $body = $( 'body' );
- $anchor = $( '.site-logo-link' );
- $logo = $( '.site-logo' );
- size = $logo.attr( 'data-size' );
- }
-
- api( 'site_logo', function( value ) {
- value.bind( function( newVal ) {
- // grab selectors the first time through
- if ( ! $body ) {
- cacheSelectors();
- }
-
- // Let's update our preview logo.
- if ( newVal && newVal.url ) {
- // If the source was smaller than the size required by the theme, give the biggest we've got.
- if ( ! newVal.sizes[ size ] ) {
- size = 'full';
- }
-
- $logo.attr( {
- height: newVal.sizes[ size ].height,
- width: newVal.sizes[ size ].width,
- src: newVal.sizes[ size ].url,
- } );
-
- $anchor.show();
- $body.addClass( 'has-site-logo' );
- } else {
- $anchor.hide();
- $body.removeClass( 'has-site-logo' );
- }
- } );
- } );
-} )( jQuery );
diff --git a/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo.min.js b/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo.min.js
deleted file mode 100644
index a6fe41eb..00000000
--- a/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo.min.js
+++ /dev/null
@@ -1 +0,0 @@
-(function(d){var e=wp.customize,c,f,g,a;e("site_logo",function(e){e.bind(function(b){c||(c=d("body"),f=d(".site-logo-link"),g=d(".site-logo"),a=g.attr("data-size"));b&&b.url?(b.sizes[a]||(a="full"),g.attr({height:b.sizes[a].height,width:b.sizes[a].width,src:b.sizes[a].url}),f.show(),c.addClass("has-site-logo")):(f.hide(),c.removeClass("has-site-logo"))})})})(jQuery); \ No newline at end of file
diff --git a/plugins/jetpack/modules/theme-tools/social-links.php b/plugins/jetpack/modules/theme-tools/social-links.php
index 98bac2d4..b11215a2 100644
--- a/plugins/jetpack/modules/theme-tools/social-links.php
+++ b/plugins/jetpack/modules/theme-tools/social-links.php
@@ -1,6 +1,6 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
- * Social Links.
+ * Theme Tools: Social Links.
*
* This feature will only be activated for themes that declare their support.
* This can be done by adding code similar to the following during the
@@ -9,8 +9,13 @@
* add_theme_support( 'social-links', array(
* 'facebook', 'twitter', 'linkedin', 'tumblr',
* ) );
+ *
+ * @package automattic/jetpack
*/
+/**
+ * Init Social_Links if the theme declares support.
+ */
function jetpack_theme_supports_social_links() {
if ( current_theme_supports( 'social-links' ) && function_exists( 'publicize_init' ) ) {
new Social_Links();
@@ -20,6 +25,9 @@ add_action( 'init', 'jetpack_theme_supports_social_links', 30 );
if ( ! class_exists( 'Social_Links' ) ) {
+ /**
+ * Social_Links main class.
+ */
class Social_Links {
/**
@@ -74,11 +82,14 @@ if ( ! class_exists( 'Social_Links' ) ) {
add_filter( 'jetpack_get_social_links', array( $this, 'get_social_links' ) );
foreach ( $theme_support[0] as $service ) {
- add_filter( "pre_option_jetpack-$service", array( $this, 'get_social_link_filter' ) ); // get_option( 'jetpack-service' );
- add_filter( "theme_mod_jetpack-$service", array( $this, 'get_social_link_filter' ) ); // get_theme_mod( 'jetpack-service' );
+ add_filter( "pre_option_jetpack-$service", array( $this, 'get_social_link_filter' ) ); // - `get_option( 'jetpack-service' );`
+ add_filter( "theme_mod_jetpack-$service", array( $this, 'get_social_link_filter' ) ); // - `get_theme_mod( 'jetpack-service' );`
}
}
+ /**
+ * Init the admin setup.
+ */
public function admin_setup() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
@@ -249,4 +260,4 @@ if ( ! class_exists( 'Social_Links' ) ) {
}
}
-} // end if ( ! class_exists( 'Social_Links' )
+} // - end if ( ! class_exists( 'Social_Links' )
diff --git a/plugins/jetpack/modules/theme-tools/social-menu.php b/plugins/jetpack/modules/theme-tools/social-menu.php
index abb5070c..df241b89 100644
--- a/plugins/jetpack/modules/theme-tools/social-menu.php
+++ b/plugins/jetpack/modules/theme-tools/social-menu.php
@@ -7,6 +7,8 @@
* 'after_setup_theme' action:
*
* add_theme_support( 'jetpack-social-menu' );
+ *
+ * @package automattic/jetpack
*/
/**
@@ -45,7 +47,7 @@ function jetpack_social_menu_init() {
// Load SVG icons related functions and filters
if ( 'svg' === jetpack_social_menu_get_type() ) {
- require dirname( __FILE__ ) . '/social-menu/icon-functions.php';
+ require __DIR__ . '/social-menu/icon-functions.php';
}
}
add_action( 'after_setup_theme', 'jetpack_social_menu_init', 99 );
@@ -100,7 +102,7 @@ function jetpack_social_menu() {
if ( 'svg' === $menu_type ) {
$link_after .= jetpack_social_menu_get_svg( array( 'icon' => 'chain' ) );
} ?>
- <nav class="jetpack-social-navigation jetpack-social-navigation-<?php echo esc_attr( $menu_type ); ?>" role="navigation" aria-label="<?php esc_html_e( 'Social Links Menu', 'jetpack' ); ?>">
+ <nav class="jetpack-social-navigation jetpack-social-navigation-<?php echo esc_attr( $menu_type ); ?>" aria-label="<?php esc_html_e( 'Social Links Menu', 'jetpack' ); ?>">
<?php
wp_nav_menu(
array(
diff --git a/plugins/jetpack/modules/tiled-gallery.php b/plugins/jetpack/modules/tiled-gallery.php
index 19e2068d..d44dad26 100644
--- a/plugins/jetpack/modules/tiled-gallery.php
+++ b/plugins/jetpack/modules/tiled-gallery.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Module Name: Tiled Galleries
* Module Description: Display image galleries in a variety of elegant arrangements.
@@ -10,14 +9,22 @@
* Feature: Appearance
* Sort Order: 24
* Additional Search Queries: gallery, tiles, tiled, grid, mosaic, images
+ *
+ * @package jetpack
*/
+/**
+ * Include the tiled gallery for loading.
+ */
function jetpack_load_tiled_gallery() {
- include dirname( __FILE__ ) . "/tiled-gallery/tiled-gallery.php";
+ include __DIR__ . '/tiled-gallery/tiled-gallery.php';
}
add_action( 'jetpack_modules_loaded', 'jetpack_tiled_gallery_loaded' );
+/**
+ * Enable the tiled gallery module.
+ */
function jetpack_tiled_gallery_loaded() {
Jetpack::enable_module_configurable( __FILE__ );
add_filter( 'jetpack_module_configuration_url_tiled-gallery', 'jetpack_tiled_gallery_configuration_url' );
diff --git a/plugins/jetpack/modules/tiled-gallery/math/class-constrained-array-rounding.php b/plugins/jetpack/modules/tiled-gallery/math/class-constrained-array-rounding.php
index d01a114a..7aa7e8de 100644
--- a/plugins/jetpack/modules/tiled-gallery/math/class-constrained-array-rounding.php
+++ b/plugins/jetpack/modules/tiled-gallery/math/class-constrained-array-rounding.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Lets you round the numeric elements of an array to integers while preserving their sum.
@@ -14,6 +14,14 @@
* If $sum is less than the sum of the floor of the elements of the array, the class defaults to using the sum of the array elements.
*/
class Jetpack_Constrained_Array_Rounding {
+ /**
+ * Get the rounded constrained array.
+ *
+ * @param array $bound_array - the array we're rounding.
+ * @param int $sum - the sum of the array.
+ *
+ * @return array
+ */
public static function get_rounded_constrained_array( $bound_array, $sum = false ) {
// Convert associative arrays before working with them and convert them back before returning the values
$keys = array_keys( $bound_array );
@@ -34,6 +42,13 @@ class Jetpack_Constrained_Array_Rounding {
return array_combine( $keys, $bound_array_fin );
}
+ /**
+ * Get int floor of array values.
+ *
+ * @param array $bound_array - the array we're getting floor values for.
+ *
+ * @return array
+ */
private static function get_int_floor_array( $bound_array ) {
$bound_array_int_floor = array();
foreach ( $bound_array as $i => $value ) {
@@ -47,6 +62,12 @@ class Jetpack_Constrained_Array_Rounding {
return $bound_array_int_floor;
}
+ /**
+ * Adjust the constrained array.
+ *
+ * @param array $bound_array_int - the array we're adjusting.
+ * @param int $adjustment - how much we're adjusting the array.
+ */
private static function adjust_constrained_array( &$bound_array_int, $adjustment ) {
usort( $bound_array_int, array( 'self', 'cmp_desc_fraction' ) );
@@ -61,15 +82,31 @@ class Jetpack_Constrained_Array_Rounding {
usort( $bound_array_int, array( 'self', 'cmp_asc_index' ) );
}
+ /**
+ * Compare fraction values of two arrays.
+ *
+ * @param array $a - the first array we're comparing.
+ * @param array $b - the second array we're comparing.
+ *
+ * @return int
+ */
private static function cmp_desc_fraction( $a, $b ) {
- if ( $a['fraction'] == $b['fraction'] ) {
+ if ( $a['fraction'] === $b['fraction'] ) {
return 0;
}
return $a['fraction'] > $b['fraction'] ? -1 : 1;
}
+ /**
+ * Compare index values of two arrays.
+ *
+ * @param array $a - the first array.
+ * @param array $b - the second array.
+ *
+ * @return int
+ */
private static function cmp_asc_index( $a, $b ) {
- if ( $a['index'] == $b['index'] ) {
+ if ( $a['index'] === $b['index'] ) {
return 0;
}
return $a['index'] < $b['index'] ? -1 : 1;
diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery.php
index 768f8749..fcb5d89e 100644
--- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery.php
+++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery.php
@@ -1,31 +1,51 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Assets;
use Automattic\Jetpack\Status;
// Include the class file containing methods for rounding constrained array elements.
// Here the constrained array element is the dimension of a row, group or an image in the tiled gallery.
-require_once dirname( __FILE__ ) . '/math/class-constrained-array-rounding.php';
+require_once __DIR__ . '/math/class-constrained-array-rounding.php';
// Layouts
-require_once dirname( __FILE__ ) . '/tiled-gallery/tiled-gallery-rectangular.php';
-require_once dirname( __FILE__ ) . '/tiled-gallery/tiled-gallery-square.php';
-require_once dirname( __FILE__ ) . '/tiled-gallery/tiled-gallery-circle.php';
+require_once __DIR__ . '/tiled-gallery/tiled-gallery-rectangular.php';
+require_once __DIR__ . '/tiled-gallery/tiled-gallery-square.php';
+require_once __DIR__ . '/tiled-gallery/tiled-gallery-circle.php';
+/**
+ * Jetpack tiled gallery class.
+ */
class Jetpack_Tiled_Gallery {
+ /**
+ * Supported gallery design types.
+ *
+ * @var array
+ */
private static $talaveras = array( 'rectangular', 'square', 'circle', 'rectangle', 'columns' );
+ /**
+ * Class constructor.
+ */
public function __construct() {
add_action( 'admin_init', array( $this, 'settings_api_init' ) );
add_filter( 'jetpack_gallery_types', array( $this, 'jetpack_gallery_types' ), 9 );
add_filter( 'jetpack_default_gallery_type', array( $this, 'jetpack_default_gallery_type' ) );
}
+ /**
+ * Check whether tiling is enabled.
+ *
+ * @return bool
+ */
public function tiles_enabled() {
- // Check the setting status
- return '' != Jetpack_Options::get_option_and_ensure_autoload( 'tiled_galleries', '' );
+ return '' !== Jetpack_Options::get_option_and_ensure_autoload( 'tiled_galleries', '' );
}
+ /**
+ * Set attributes.
+ *
+ * @param array $atts - the attributes.
+ */
public function set_atts( $atts ) {
global $post;
@@ -49,8 +69,8 @@ class Jetpack_Tiled_Gallery {
$this->float = is_rtl() ? 'right' : 'left';
// Default to rectangular is tiled galleries are checked
- if ( $this->tiles_enabled() && ( ! $this->atts['type'] || 'default' == $this->atts['type'] ) ) {
- /** This filter is already documented in functions.gallery.php */
+ if ( $this->tiles_enabled() && ( ! $this->atts['type'] || 'default' === $this->atts['type'] ) ) {
+ /** This filter is already documented in class-jetpack-gallery-settings.php */
$this->atts['type'] = apply_filters( 'jetpack_default_gallery_type', 'rectangular' );
}
@@ -61,7 +81,7 @@ class Jetpack_Tiled_Gallery {
}
}
- if ( 'rand' == strtolower( $this->atts['order'] ) ) {
+ if ( 'rand' === strtolower( $this->atts['order'] ) ) {
$this->atts['orderby'] = 'rand';
}
@@ -71,6 +91,11 @@ class Jetpack_Tiled_Gallery {
}
}
+ /**
+ * Get the media attachments.
+ *
+ * @return WP_Post[]
+ */
public function get_attachments() {
$atts = $this->atts;
@@ -130,6 +155,9 @@ class Jetpack_Tiled_Gallery {
return $attachments;
}
+ /**
+ * Enqueue the default scripts and styles.
+ */
public static function default_scripts_and_styles() {
wp_enqueue_script(
'tiled-gallery',
@@ -137,19 +165,27 @@ class Jetpack_Tiled_Gallery {
'_inc/build/tiled-gallery/tiled-gallery/tiled-gallery.min.js',
'modules/tiled-gallery/tiled-gallery/tiled-gallery.js'
),
- array()
+ array(),
+ JETPACK__VERSION,
+ false
);
wp_enqueue_style( 'tiled-gallery', plugins_url( 'tiled-gallery/tiled-gallery.css', __FILE__ ), array(), '2012-09-21' );
wp_style_add_data( 'tiled-gallery', 'rtl', 'replace' );
}
+ /**
+ * The gallery shortcode.
+ *
+ * @param mixed $val - the value.
+ * @param array $atts - the attributes.
+ *
+ * @return string
+ */
public function gallery_shortcode( $val, $atts ) {
if ( ! empty( $val ) ) { // something else is overriding post_gallery, like a custom VIP shortcode
return $val;
}
- global $post;
-
$this->set_atts( $atts );
$attachments = $this->get_attachments();
@@ -161,21 +197,18 @@ class Jetpack_Tiled_Gallery {
return '';
}
- if (
- in_array(
- $this->atts['type'],
- /**
- * Filters the permissible Tiled Gallery types.
- *
- * @module tiled-gallery
- *
- * @since 3.7.0
- *
- * @param array Array of allowed types. Default: 'rectangular', 'square', 'circle', 'rectangle', 'columns'.
- */
- $talaveras = apply_filters( 'jetpack_tiled_gallery_types', self::$talaveras )
- )
- ) {
+ /**
+ * Filters the permissible Tiled Gallery types.
+ *
+ * @module tiled-gallery
+ *
+ * @since 3.7.0
+ *
+ * @param array Array of allowed types. Default: 'rectangular', 'square', 'circle', 'rectangle', 'columns'.
+ */
+ $talaveras = apply_filters( 'jetpack_tiled_gallery_types', self::$talaveras );
+
+ if ( in_array( $this->atts['type'], $talaveras, true ) ) {
// Enqueue styles and scripts
self::default_scripts_and_styles();
@@ -198,6 +231,11 @@ class Jetpack_Tiled_Gallery {
return '';
}
+ /**
+ * See if gallery is already defined.
+ *
+ * @return bool
+ */
public static function gallery_already_redefined() {
global $shortcode_tags;
$redefined = false;
@@ -218,6 +256,9 @@ class Jetpack_Tiled_Gallery {
return apply_filters( 'jetpack_tiled_gallery_shortcode_redefined', $redefined );
}
+ /**
+ * Initialize the tiled gallery.
+ */
public static function init() {
if ( self::gallery_already_redefined() ) {
return;
@@ -227,6 +268,11 @@ class Jetpack_Tiled_Gallery {
add_filter( 'post_gallery', array( $gallery, 'gallery_shortcode' ), 1001, 2 );
}
+ /**
+ * Get the width of the gallery.
+ *
+ * @return int
+ */
public static function get_content_width() {
$tiled_gallery_content_width = Jetpack::get_content_width();
@@ -248,8 +294,12 @@ class Jetpack_Tiled_Gallery {
/**
* Media UI integration
+ *
+ * @param array $types - the type of gallery.
+ *
+ * @return array
*/
- function jetpack_gallery_types( $types ) {
+ public function jetpack_gallery_types( $types ) {
if ( get_option( 'tiled_galleries' ) && isset( $types['default'] ) ) {
// Tiled is set as the default, meaning that type='default'
// will still display the mosaic.
@@ -265,11 +315,21 @@ class Jetpack_Tiled_Gallery {
return $types;
}
- function jetpack_default_gallery_type() {
+ /**
+ * Get the default gallery type.
+ *
+ * @return string
+ */
+ public function jetpack_default_gallery_type() {
return ( get_option( 'tiled_galleries' ) ? 'rectangular' : 'default' );
}
- static function get_talaveras() {
+ /**
+ * Get the talaveras.
+ *
+ * @return array
+ */
+ public static function get_talaveras() {
return self::$talaveras;
}
@@ -277,7 +337,7 @@ class Jetpack_Tiled_Gallery {
* Add a checkbox field to the Carousel section in Settings > Media
* for setting tiled galleries as the default.
*/
- function settings_api_init() {
+ public function settings_api_init() {
global $wp_settings_sections;
// Add the setting field [tiled_galleries] and place it in Settings > Media
@@ -291,10 +351,13 @@ class Jetpack_Tiled_Gallery {
register_setting( 'media', 'tiled_galleries', 'esc_attr' );
}
- function setting_html() {
+ /**
+ * Render the settings HTML.
+ */
+ public function setting_html() {
echo '<label><input name="tiled_galleries" type="checkbox" value="1" ' .
- checked( 1, '' != get_option( 'tiled_galleries' ), false ) . ' /> ' .
- __( 'Display all your gallery pictures in a cool mosaic.', 'jetpack' ) . '</br></label>';
+ checked( 1, '' !== get_option( 'tiled_galleries' ), false ) . ' /> ' .
+ esc_html__( 'Display all your gallery pictures in a cool mosaic.', 'jetpack' ) . '</br></label>';
}
}
diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/carousel-container.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/carousel-container.php
index 6fb74a20..43850d18 100644
--- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/carousel-container.php
+++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/carousel-container.php
@@ -1,20 +1,20 @@
<?php
-if ( defined( 'JSON_HEX_AMP' ) ) {
- // see shortcodes/slideshow.php
- // This is nice to have, but not strictly necessary since we use _wp_specialchars() below
- // phpcs:ignore PHPCompatibility
- $extra = json_encode( $this->get_container_extra_data(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT );
-} else {
- $extra = json_encode( $this->get_container_extra_data() );
-}
+/**
+ * Encode extra carousel container data.
+ *
+ * @package jetpack
+ */
+
+// Using JSON_HEX_AMP avoids breakage due to `esc_attr()` refusing to double-encode.
+$extra = wp_json_encode( $this->get_container_extra_data(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
?>
<div
- class="tiled-gallery type-<?php echo $this->type; ?> tiled-gallery-unresized"
+ class="tiled-gallery type-<?php echo esc_html( $this->type ); // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable ?> tiled-gallery-unresized"
data-original-width="<?php echo esc_attr( Jetpack_Tiled_Gallery::get_content_width() ); ?>"
<?php if ( isset( $extra ) ) : ?>
- data-carousel-extra='<?php echo _wp_specialchars( wp_check_invalid_utf8( $extra ), ENT_QUOTES, false, true ); ?>'
+data-carousel-extra='<?php echo esc_attr( $extra ); ?>'
<?php endif; ?>
itemscope itemtype="http://schema.org/ImageGallery"
>
- <?php $this->template( "$this->type-layout", $context ); ?>
+ <?php $this->template( "$this->type-layout", $context ); // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable ?>
</div>
diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/carousel-image-args.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/carousel-image-args.php
index 44d6f3e3..6d25a0fa 100644
--- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/carousel-image-args.php
+++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/carousel-image-args.php
@@ -11,20 +11,15 @@ if ( isset( $fuzzy_image_meta['keywords'] ) ) {
unset( $fuzzy_image_meta['keywords'] );
}
-if ( defined( 'JSON_HEX_AMP' ) ) {
- // see shortcodes/slideshow.php
- // This is nice to have, but not strictly necessary since we use _wp_specialchars() below
- // phpcs:ignore PHPCompatibility
- $fuzzy_image_meta = json_encode( array_map( 'strval', $fuzzy_image_meta ), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT );
-} else {
- $fuzzy_image_meta = json_encode( array_map( 'strval', $fuzzy_image_meta ) );
-}
+// Using JSON_HEX_AMP avoids breakage due to `esc_attr()` refusing to double-encode.
+$fuzzy_image_meta = wp_json_encode( array_map( 'strval', $fuzzy_image_meta ), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT );
+
?>
data-attachment-id="<?php echo esc_attr( $item->image->ID ); ?>"
data-orig-file="<?php echo esc_url( wp_get_attachment_url( $item->image->ID ) ); ?>"
data-orig-size="<?php echo esc_attr( $item->meta_width() ); ?>,<?php echo esc_attr( $item->meta_height() ); ?>"
data-comments-opened="<?php echo esc_attr( comments_open( $item->image->ID ) ); ?>"
-data-image-meta="<?php echo _wp_specialchars( wp_check_invalid_utf8( $fuzzy_image_meta ), ENT_QUOTES, false, true ); ?>"
+data-image-meta="<?php echo esc_attr( $fuzzy_image_meta ); ?>"
data-image-title="<?php echo esc_attr( htmlspecialchars( wptexturize( $item->image->post_title ) ) ); ?>"
data-image-description="<?php echo esc_attr( htmlspecialchars( wpautop( wptexturize( $item->image->post_content ) ) ) ); ?>"
data-medium-file="<?php echo esc_url( $item->medium_file() ); ?>"
diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/item.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/item.php
index 2f8a9e7c..8872f452 100644
--- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/item.php
+++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/item.php
@@ -1,6 +1,12 @@
<?php
+/**
+ * Handles more photo metadata.
+ *
+ * @package jetpack
+ */
+
$item = $context['item']; // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
-$add_link = 'none' !== $this->link;
+$add_link = 'none' !== $this->link; // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
// We do this for accessibility. Titles without alt's break screen readers.
if ( empty( $item->image_alt ) && ! empty( $item->image_title ) ) {
@@ -10,16 +16,16 @@ if ( empty( $item->image_alt ) && ! empty( $item->image_title ) ) {
<div class="tiled-gallery-item
<?php
if ( isset( $item->size ) ) {
- echo " tiled-gallery-item-$item->size";}
+ echo esc_attr( " tiled-gallery-item-$item->size" );}
?>
" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<?php if ( $add_link ) : ?>
- <a href="<?php echo $item->link; ?>" border="0" itemprop="url">
+ <a href="<?php echo esc_url( $item->link ); ?>" border="0" itemprop="url">
<?php endif; ?>
<meta itemprop="width" content="<?php echo esc_attr( $item->image->width ); ?>">
<meta itemprop="height" content="<?php echo esc_attr( $item->image->height ); ?>">
<img
- <?php $this->partial( 'carousel-image-args', array( 'item' => $item ) ); ?>
+ <?php $this->partial( 'carousel-image-args', array( 'item' => $item ) ); // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable ?>
src="<?php echo esc_url( $item->img_src ); ?>"
width="<?php echo esc_attr( $item->image->width ); ?>"
height="<?php echo esc_attr( $item->image->height ); ?>"
@@ -34,9 +40,9 @@ if ( isset( $item->size ) ) {
</a>
<?php endif; ?>
- <?php if ( $this->grayscale == true ) : ?>
+ <?php if ( ! empty( $this->grayscale ) ) : ?>
<?php if ( $add_link ) : ?>
- <a href="<?php echo $item->link; ?>" border="0" itemprop="url">
+ <a href="<?php echo esc_url( $item->link ); ?>" border="0" itemprop="url">
<?php endif; ?>
<meta itemprop="width" content="<?php echo esc_attr( $item->image->width ); ?>">
<meta itemprop="height" content="<?php echo esc_attr( $item->image->height ); ?>">
@@ -60,7 +66,7 @@ if ( isset( $item->size ) ) {
<?php if ( trim( $item->image->post_excerpt ) ) : ?>
<div class="tiled-gallery-caption" itemprop="caption description">
- <?php echo wptexturize( $item->image->post_excerpt ); ?>
+ <?php echo wptexturize( $item->image->post_excerpt ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<?php endif; ?>
</div>
diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-circle.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-circle.php
index 1addcb91..b1baf72a 100644
--- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-circle.php
+++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-circle.php
@@ -1,7 +1,15 @@
-<?php
-require_once dirname( __FILE__ ) . '/tiled-gallery-square.php';
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+require_once __DIR__ . '/tiled-gallery-square.php';
+/**
+ * Jetpack tiled gallery layout circle class.
+ */
class Jetpack_Tiled_Gallery_Layout_Circle extends Jetpack_Tiled_Gallery_Layout_Square {
+ /**
+ * Type of tiled gallery.
+ *
+ * @var string
+ */
protected $type = 'circle';
}
diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-item.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-item.php
index cdf5305e..d1f0dcd7 100644
--- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-item.php
+++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-item.php
@@ -1,7 +1,24 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+
+/**
+ * Jetpack Tiled Gallery Item class.
+ */
abstract class Jetpack_Tiled_Gallery_Item {
+
+ /**
+ * The image data.
+ *
+ * @var object
+ */
public $image;
+ /**
+ * Constructor function.
+ *
+ * @param object $attachment_image - the attachment image.
+ * @param string $needs_attachment_link - the attachment link.
+ * @param bool $grayscale - if the image is in grayscale.
+ */
public function __construct( $attachment_image, $needs_attachment_link, $grayscale ) {
$this->image = $attachment_image;
$this->grayscale = $grayscale;
@@ -11,11 +28,11 @@ abstract class Jetpack_Tiled_Gallery_Item {
$this->image_alt = get_post_meta( $this->image->ID, '_wp_attachment_image_alt', true );
// If no Alt value, use the caption
if ( empty( $this->image_alt ) && ! empty( $this->image->post_excerpt ) ) {
- $this->image_alt = trim( strip_tags( $this->image->post_excerpt ) );
+ $this->image_alt = trim( wp_strip_all_tags( $this->image->post_excerpt ) );
}
// If still no Alt value, use the title
if ( empty( $this->image_alt ) && ! empty( $this->image->post_title ) ) {
- $this->image_alt = trim( strip_tags( $this->image->post_title ) );
+ $this->image_alt = trim( wp_strip_all_tags( $this->image->post_title ) );
}
$this->orig_file = wp_get_attachment_url( $this->image->ID );
@@ -29,7 +46,7 @@ abstract class Jetpack_Tiled_Gallery_Item {
'h' => $this->image->height,
);
// If h and w are the same, there's a reasonably good chance the image will need cropping to avoid being stretched.
- if ( $this->image->height == $this->image->width ) {
+ if ( $this->image->height === $this->image->width ) {
$img_args['crop'] = true;
}
// The function will always photonoize the URL (even if Photon is
@@ -37,12 +54,17 @@ abstract class Jetpack_Tiled_Gallery_Item {
$this->img_src = jetpack_photon_url( $this->orig_file, $img_args );
}
+ /**
+ * Handle the fuzzy image meta.
+ *
+ * @return array
+ */
public function fuzzy_image_meta() {
$meta = wp_get_attachment_metadata( $this->image->ID );
$img_meta = ( ! empty( $meta['image_meta'] ) ) ? (array) $meta['image_meta'] : array();
if ( ! empty( $img_meta ) ) {
foreach ( $img_meta as $k => $v ) {
- if ( 'latitude' == $k || 'longitude' == $k ) {
+ if ( 'latitude' === $k || 'longitude' === $k ) {
unset( $img_meta[ $k ] );
}
}
@@ -51,22 +73,42 @@ abstract class Jetpack_Tiled_Gallery_Item {
return $img_meta;
}
+ /**
+ * Return the meta width.
+ *
+ * @return int|string
+ */
public function meta_width() {
$meta = wp_get_attachment_metadata( $this->image->ID );
return isset( $meta['width'] ) ? (int) $meta['width'] : '';
}
+ /**
+ * Return the meta height.
+ *
+ * @return int|string
+ */
public function meta_height() {
$meta = wp_get_attachment_metadata( $this->image->ID );
return isset( $meta['height'] ) ? (int) $meta['height'] : '';
}
+ /**
+ * Return the medium file info.
+ *
+ * @return array|string
+ */
public function medium_file() {
$medium_file_info = wp_get_attachment_image_src( $this->image->ID, 'medium' );
$medium_file = isset( $medium_file_info[0] ) ? $medium_file_info[0] : '';
return $medium_file;
}
+ /**
+ * Return large file info.
+ *
+ * @return array|string
+ */
public function large_file() {
$large_file_info = wp_get_attachment_image_src( $this->image->ID, 'large' );
$large_file = isset( $large_file_info[0] ) ? $large_file_info[0] : '';
@@ -74,7 +116,17 @@ abstract class Jetpack_Tiled_Gallery_Item {
}
}
-class Jetpack_Tiled_Gallery_Rectangular_Item extends Jetpack_Tiled_Gallery_Item {
+/**
+ * Tiled gallery rectangular item class.
+ */
+class Jetpack_Tiled_Gallery_Rectangular_Item extends Jetpack_Tiled_Gallery_Item { // phpcs:ignore Generic.Files.OneObjectStructurePerFile.MultipleFound, Generic.Classes.OpeningBraceSameLine.ContentAfterBrace
+ /**
+ * Constructor function.
+ *
+ * @param object $attachment_image - the attachment image.
+ * @param string $needs_attachment_link - the attachment link.
+ * @param bool $grayscale - if the image is in grayscale.
+ */
public function __construct( $attachment_image, $needs_attachment_link, $grayscale ) {
parent::__construct( $attachment_image, $needs_attachment_link, $grayscale );
$this->img_src_grayscale = jetpack_photon_url( $this->img_src, array( 'filter' => 'grayscale' ) );
@@ -87,7 +139,17 @@ class Jetpack_Tiled_Gallery_Rectangular_Item extends Jetpack_Tiled_Gallery_Item
}
}
-class Jetpack_Tiled_Gallery_Square_Item extends Jetpack_Tiled_Gallery_Item {
+/**
+ * Tiled gallery square item class.
+ */
+class Jetpack_Tiled_Gallery_Square_Item extends Jetpack_Tiled_Gallery_Item { // phpcs:ignore Generic.Files.OneObjectStructurePerFile.MultipleFound, Generic.Classes.OpeningBraceSameLine.ContentAfterBrace
+ /**
+ * Constructor function.
+ *
+ * @param object $attachment_image - the attachment image.
+ * @param string $needs_attachment_link - the attachment link.
+ * @param bool $grayscale - if the image is in grayscale.
+ */
public function __construct( $attachment_image, $needs_attachment_link, $grayscale ) {
parent::__construct( $attachment_image, $needs_attachment_link, $grayscale );
$this->img_src_grayscale = jetpack_photon_url(
@@ -103,5 +165,8 @@ class Jetpack_Tiled_Gallery_Square_Item extends Jetpack_Tiled_Gallery_Item {
}
}
-class Jetpack_Tiled_Gallery_Circle_Item extends Jetpack_Tiled_Gallery_Square_Item {
+/**
+ * Tiled gallery circle item class.
+ */
+class Jetpack_Tiled_Gallery_Circle_Item extends Jetpack_Tiled_Gallery_Square_Item { // phpcs:ignore Generic.Files.OneObjectStructurePerFile.MultipleFound, Generic.Classes.OpeningBraceSameLine.ContentAfterBrace
}
diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-layout.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-layout.php
index 11699c7c..f7541cc5 100644
--- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-layout.php
+++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-layout.php
@@ -1,24 +1,81 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+
+/**
+ * Tiled gallery layout class.
+ */
abstract class Jetpack_Tiled_Gallery_Layout {
- // Template allow list.
+ /**
+ * Template allow list.
+ *
+ * @var array
+ */
private static $templates = array( 'carousel-container', 'circle-layout', 'rectangular-layout', 'square-layout' );
- private static $partials = array( 'carousel-image-args', 'item' );
- protected $type; // Defined in child classes
+ /**
+ * Partial list.
+ *
+ * @var array
+ */
+ private static $partials = array( 'carousel-image-args', 'item' );
+
+ /**
+ * Type of gallery - defined in parent class.
+ *
+ * @var string
+ */
+ protected $type;
+
+ /**
+ * The attachments.
+ *
+ * @var object
+ */
public $attachments;
+
+ /**
+ * The attachment link.
+ *
+ * @var string
+ */
public $link;
+
+ /**
+ * If the image is in grayscale.
+ *
+ * @var bool
+ */
public $grayscale;
+
+ /**
+ * How many columns.
+ *
+ * @var int
+ */
public $columns;
- public function __construct( $attachments, $link, $grayscale, $columns ) {
+ /**
+ * Constructor function.
+ *
+ * @param object $attachments - the attachmed image.
+ * @param string $link - the attachment link.
+ * @param bool $grayscale - if the image is in grayscale.
+ * @param int $columns - how many columns.
+ */
+ public function __construct( $attachments, $link, $grayscale, $columns ) {
$this->attachments = $attachments;
$this->link = $link;
- $this->needs_attachment_link = ! ( isset( $link ) && $link == 'file' );
+ $this->needs_attachment_link = $link !== 'file';
$this->grayscale = $grayscale;
$this->columns = $columns;
}
- public function HTML( $context = array() ) {
+ /**
+ * Render carousel container template.
+ *
+ * @param array $context - the context.
+ * @return string HTML
+ */
+ public function HTML( $context = array() ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
// Render the carousel container template, which will take the
// appropriate strategy to fill it
ob_start();
@@ -39,8 +96,14 @@ abstract class Jetpack_Tiled_Gallery_Layout {
return $html;
}
+ /**
+ * Handle tiled gallery template path.
+ *
+ * @param string $name Template name.
+ * @param array $context Context array passed to the template.
+ */
private function template( $name, $context = null ) {
- if ( ! in_array( $name, self::$templates ) ) {
+ if ( ! in_array( $name, self::$templates, true ) ) {
return;
}
@@ -54,11 +117,17 @@ abstract class Jetpack_Tiled_Gallery_Layout {
* @param string $path Template name.
* @param array $context Context array passed to the template.
*/
- require apply_filters( 'jetpack_tiled_gallery_template', dirname( __FILE__ ) . "/templates/$name.php", $name, $context );
+ require apply_filters( 'jetpack_tiled_gallery_template', __DIR__ . "/templates/$name.php", $name, $context );
}
+ /**
+ * Handle tiled gallery partial path.
+ *
+ * @param string $name - the name.
+ * @param array $context Context array passed to the partial.
+ */
private function partial( $name, $context = null ) {
- if ( ! in_array( $name, self::$partials ) ) {
+ if ( ! in_array( $name, self::$partials, true ) ) {
return;
}
@@ -72,9 +141,12 @@ abstract class Jetpack_Tiled_Gallery_Layout {
* @param string $path Partial name.
* @param array $context Context array passed to the partial.
*/
- require apply_filters( 'jetpack_tiled_gallery_partial', dirname( __FILE__ ) . "/templates/partials/$name.php", $name, $context );
+ require apply_filters( 'jetpack_tiled_gallery_partial', __DIR__ . "/templates/partials/$name.php", $name, $context );
}
+ /**
+ * Get extra container data.
+ */
protected function get_container_extra_data() {
global $post;
@@ -86,7 +158,7 @@ abstract class Jetpack_Tiled_Gallery_Layout {
$likes_blog_id = Jetpack_Options::get_option( 'id' );
}
- if ( class_exists( 'Jetpack_Carousel' ) || in_array( 'carousel', Jetpack::get_active_modules() ) || 'carousel' == $this->link ) {
+ if ( class_exists( 'Jetpack_Carousel' ) || in_array( 'carousel', Jetpack::get_active_modules(), true ) || 'carousel' === $this->link ) {
$extra_data = array(
'blog_id' => $blog_id,
'permalink' => get_permalink( isset( $post->ID ) ? $post->ID : 0 ),
diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-rectangular.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-rectangular.php
index 9ea272fc..cd687eb8 100644
--- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-rectangular.php
+++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-rectangular.php
@@ -1,12 +1,28 @@
-<?php
-require_once dirname( __FILE__ ) . '/tiled-gallery-layout.php';
-require_once dirname( __FILE__ ) . '/tiled-gallery-shape.php';
-require_once dirname( __FILE__ ) . '/tiled-gallery-item.php';
-
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+require_once __DIR__ . '/tiled-gallery-layout.php';
+require_once __DIR__ . '/tiled-gallery-shape.php';
+require_once __DIR__ . '/tiled-gallery-item.php';
+
+// phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound
+/**
+ * Tiled gallery rectangular layout.
+ */
class Jetpack_Tiled_Gallery_Layout_Rectangular extends Jetpack_Tiled_Gallery_Layout {
+
+ /**
+ * The layout type.
+ *
+ * @var string
+ */
protected $type = 'rectangular';
- public function HTML( $context = array() ) {
+ /**
+ * The HTML function.
+ *
+ * @param array $context - the context array, unused.
+ * @return string HTML
+ */
+ public function HTML( $context = array() ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$grouper = new Jetpack_Tiled_Gallery_Grouper( $this->attachments );
Jetpack_Tiled_Gallery_Shape::reset_last_shape();
@@ -14,24 +30,54 @@ class Jetpack_Tiled_Gallery_Layout_Rectangular extends Jetpack_Tiled_Gallery_Lay
}
}
+/**
+ * Tiled gallery layout columns class.
+ */
class Jetpack_Tiled_Gallery_Layout_Columns extends Jetpack_Tiled_Gallery_Layout {
+
+ /**
+ * The layout type.
+ *
+ * @var string
+ */
protected $type = 'rectangular'; // It doesn't need separate template for now
- public function HTML( $context = array() ) {
+ /**
+ * The HTML function.
+ *
+ * @param array $context - the context array, unused.
+ * @return string HTML
+ */
+ public function HTML( $context = array() ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$grouper = new Jetpack_Tiled_Gallery_Grouper( $this->attachments, array( 'Three_Columns', 'Two' ) );
return parent::HTML( array( 'rows' => $grouper->grouped_images ) );
}
}
-// Alias
+/**
+ * Gallery layout rectangle alis.
+ */
class Jetpack_Tiled_Gallery_Layout_Rectangle extends Jetpack_Tiled_Gallery_Layout_Rectangular {}
-// Image grouping and HTML generation logic
+/**
+ * Image grouping and HTML generation logic class.
+ */
class Jetpack_Tiled_Gallery_Grouper {
+
+ /**
+ * The margin.
+ *
+ * @var int
+ */
public $margin = 4;
- // This list is ordered. If you put a shape that's likely to occur on top, it will happen all the time.
+ /**
+ * Shapes array.
+ * This list is ordered. If you put a shape that's likely to occur on top, it will happen all the time.
+ *
+ * @var array
+ */
public $shapes = array(
'Reverse_Symmetric_Row',
'Long_Symmetric_Row',
@@ -46,6 +92,12 @@ class Jetpack_Tiled_Gallery_Grouper {
'Panoramic',
);
+ /**
+ * Constructor function.
+ *
+ * @param object $attachments - the attachments.
+ * @param array $shapes - the shapes.
+ */
public function __construct( $attachments, $shapes = array() ) {
$content_width = Jetpack_Tiled_Gallery::get_content_width();
@@ -56,12 +108,22 @@ class Jetpack_Tiled_Gallery_Grouper {
$this->apply_content_width( $content_width );
}
+ /**
+ * Overwrite the shapes.
+ *
+ * @param array $shapes - the shapes.
+ */
public function overwrite_shapes( $shapes ) {
if ( ! empty( $shapes ) ) {
$this->shapes = $shapes;
}
}
+ /**
+ * Get the current row size.
+ *
+ * @return array
+ */
public function get_current_row_size() {
$images_left = count( $this->images );
if ( $images_left < 3 ) {
@@ -81,6 +143,13 @@ class Jetpack_Tiled_Gallery_Grouper {
return array( 1, 1 );
}
+ /**
+ * Get images with sizes.
+ *
+ * @param object $attachments - the attachments.
+ *
+ * @return array
+ */
public function get_images_with_sizes( $attachments ) {
$images_with_sizes = array();
@@ -96,6 +165,11 @@ class Jetpack_Tiled_Gallery_Grouper {
return $images_with_sizes;
}
+ /**
+ * Get the current row size.
+ *
+ * @return array
+ */
public function read_row() {
$vector = $this->get_current_row_size();
@@ -107,6 +181,11 @@ class Jetpack_Tiled_Gallery_Grouper {
return $row;
}
+ /**
+ * Get grouped images.
+ *
+ * @return array
+ */
public function get_grouped_images() {
$grouped_images = array();
@@ -117,8 +196,14 @@ class Jetpack_Tiled_Gallery_Grouper {
return $grouped_images;
}
- // todo: split in functions
- // todo: do not stretch images
+ /**
+ * Apply content width.
+ *
+ * @param int $width - the width.
+ *
+ * @todo split in functions
+ * @todo do not stretch images
+ */
public function apply_content_width( $width ) {
foreach ( $this->grouped_images as $row ) {
$row->width = $width;
@@ -129,6 +214,11 @@ class Jetpack_Tiled_Gallery_Grouper {
}
}
+ /**
+ * Calculate group sizes.
+ *
+ * @param object $row - the row.
+ */
public function calculate_group_sizes( $row ) {
// Storing the calculated group heights in an array for rounding them later while preserving their sum
// This fixes the rounding error that can lead to a few ugly pixels sticking out in the gallery
@@ -147,6 +237,11 @@ class Jetpack_Tiled_Gallery_Grouper {
}
}
+ /**
+ * Calculate image sizes.
+ *
+ * @param object $group - the group of images.
+ */
public function calculate_image_sizes( $group ) {
// Storing the calculated image heights in an array for rounding them later while preserving their sum
// This fixes the rounding error that can lead to a few ugly pixels sticking out in the gallery
@@ -167,13 +262,27 @@ class Jetpack_Tiled_Gallery_Grouper {
}
}
+/**
+ * Jetpack tiled row class.
+ */
class Jetpack_Tiled_Gallery_Row {
+
+ /**
+ * Constructor class.
+ *
+ * @param object $groups - the group of images.
+ */
public function __construct( $groups ) {
$this->groups = $groups;
$this->ratio = $this->get_ratio();
$this->weighted_ratio = $this->get_weighted_ratio();
}
+ /**
+ * Get the ratio.
+ *
+ * @return int
+ */
public function get_ratio() {
$ratio = 0;
foreach ( $this->groups as $group ) {
@@ -182,6 +291,11 @@ class Jetpack_Tiled_Gallery_Row {
return $ratio > 0 ? $ratio : 1;
}
+ /**
+ * Get weighted ratio.
+ *
+ * @return int
+ */
public function get_weighted_ratio() {
$weighted_ratio = 0;
foreach ( $this->groups as $group ) {
@@ -191,12 +305,25 @@ class Jetpack_Tiled_Gallery_Row {
}
}
+/**
+ * Tiled gallery group class.
+ */
class Jetpack_Tiled_Gallery_Group {
+ /**
+ * Constructor class.
+ *
+ * @param object $images - the images.
+ */
public function __construct( $images ) {
$this->images = $images;
$this->ratio = $this->get_ratio();
}
+ /**
+ * Get the ratio.
+ *
+ * @return int
+ */
public function get_ratio() {
$ratio = 0;
foreach ( $this->images as $image ) {
@@ -211,6 +338,14 @@ class Jetpack_Tiled_Gallery_Group {
return 1 / $ratio;
}
+ /**
+ * The items.
+ *
+ * @param string $needs_attachment_link - the attachment link.
+ * @param bool $grayscale - if the image is in grayscale.
+ *
+ * @return array
+ */
public function items( $needs_attachment_link, $grayscale ) {
$items = array();
foreach ( $this->images as $image ) {
diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-rtl.css b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-rtl.css
index f54f744c..c331bda7 100644
--- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-rtl.css
+++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-rtl.css
@@ -1 +1 @@
-.tiled-gallery{clear:both;margin:0 0 20px;overflow:hidden}.tiled-gallery img{margin:2px!important}.tiled-gallery .gallery-group{float:right;position:relative}.tiled-gallery .tiled-gallery-item{float:right;margin:0;position:relative;width:inherit}.tiled-gallery .gallery-row{overflow:hidden}.tiled-gallery .tiled-gallery-item a{background:100% 0;border:none;color:inherit;margin:0;padding:0;text-decoration:none;width:auto}.tiled-gallery .tiled-gallery-item img,.tiled-gallery .tiled-gallery-item img:hover{background:100% 0;border:none;box-shadow:none;max-width:100%;padding:0;vertical-align:middle}.tiled-gallery-caption{background:#f0f0f1;background:rgba(255,255,255,.8);color:#333;font-size:13px;font-weight:400;overflow:hidden;padding:10px 0;position:absolute;bottom:0;text-indent:10px;text-overflow:ellipsis;width:100%;white-space:nowrap}.tiled-gallery .tiled-gallery-item-small .tiled-gallery-caption{font-size:11px}.widget-gallery .tiled-gallery-unresized{visibility:hidden;height:0;overflow:hidden}.tiled-gallery .tiled-gallery-item img.grayscale{position:absolute;right:0;top:0}.tiled-gallery .tiled-gallery-item img.grayscale:hover{opacity:0}.tiled-gallery.type-circle .tiled-gallery-item img{border-radius:50%!important;-o-object-fit:cover;object-fit:cover}.tiled-gallery.type-circle .tiled-gallery-caption{display:none}.tiled-gallery.type-square .tiled-gallery-item img{-o-object-fit:cover;object-fit:cover} \ No newline at end of file
+.tiled-gallery{clear:both;margin:0 0 20px;overflow:hidden}.tiled-gallery img{margin:2px!important}.tiled-gallery .gallery-group{float:right;position:relative}.tiled-gallery .tiled-gallery-item{float:right;margin:0;position:relative;width:inherit}.tiled-gallery .gallery-row{overflow:hidden}.tiled-gallery .tiled-gallery-item a{background:transparent;border:none;color:inherit;margin:0;padding:0;text-decoration:none;width:auto}.tiled-gallery .tiled-gallery-item img,.tiled-gallery .tiled-gallery-item img:hover{background:none;border:none;box-shadow:none;max-width:100%;padding:0;vertical-align:middle}.tiled-gallery-caption{background:#f0f0f1;background:hsla(0,0%,100%,.8);bottom:0;color:#333;font-size:13px;font-weight:400;overflow:hidden;padding:10px 0;position:absolute;text-indent:10px;text-overflow:ellipsis;white-space:nowrap;width:100%}.tiled-gallery .tiled-gallery-item-small .tiled-gallery-caption{font-size:11px}.widget-gallery .tiled-gallery-unresized{height:0;overflow:hidden;visibility:hidden}.tiled-gallery .tiled-gallery-item img.grayscale{position:absolute;right:0;top:0}.tiled-gallery .tiled-gallery-item img.grayscale:hover{opacity:0}.tiled-gallery.type-circle .tiled-gallery-item img{border-radius:50%!important;-o-object-fit:cover;object-fit:cover}.tiled-gallery.type-circle .tiled-gallery-caption{display:none}.tiled-gallery.type-square .tiled-gallery-item img{-o-object-fit:cover;object-fit:cover} \ No newline at end of file
diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-shape.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-shape.php
index bc243966..2294bd1a 100644
--- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-shape.php
+++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-shape.php
@@ -1,102 +1,249 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+// phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound
+/**
+ * Jetpack tiled gallery shape class.
+ */
class Jetpack_Tiled_Gallery_Shape {
- static $shapes_used = array();
+ /**
+ * Shapes used.
+ *
+ * @var array
+ */
+ public static $shapes_used = array();
+
+ /**
+ * Constructor class.
+ *
+ * @param object $images - the images.
+ */
public function __construct( $images ) {
$this->images = $images;
$this->images_left = count( $images );
}
+ /**
+ * Return the sum of ratio images.
+ *
+ * @param int $number_of_images - the number of images.
+ *
+ * @return int
+ */
public function sum_ratios( $number_of_images = 3 ) {
return array_sum( array_slice( wp_list_pluck( $this->images, 'ratio' ), 0, $number_of_images ) );
}
+ /**
+ * Check that the next images are symmetric
+ *
+ * @return bool
+ */
public function next_images_are_symmetric() {
- return $this->images_left > 2 && $this->images[0]->ratio == $this->images[2]->ratio;
+ return $this->images_left > 2 && $this->images[0]->ratio === $this->images[2]->ratio;
}
+ /**
+ * Is not as previous.
+ *
+ * @param int $n - the previous image.
+ *
+ * @return bool
+ */
public function is_not_as_previous( $n = 1 ) {
- return ! in_array( get_class( $this ), array_slice( self::$shapes_used, -$n ) );
+ return ! in_array( get_class( $this ), array_slice( self::$shapes_used, -$n ), true );
}
+ /**
+ * Check if the theme is wide.
+ *
+ * @return bool
+ */
public function is_wide_theme() {
return Jetpack::get_content_width() > 1000;
}
+ /**
+ * Check if the image is landscape.
+ *
+ * @param object $image - the image.
+ *
+ * @return bool
+ */
public function image_is_landscape( $image ) {
return $image->ratio >= 1 && $image->ratio < 2;
}
+ /**
+ * Check if the image is portrait.
+ *
+ * @param object $image - the image.
+ *
+ * @return bool
+ */
public function image_is_portrait( $image ) {
return $image->ratio < 1;
}
+ /**
+ * Check if the image is panoramic.
+ *
+ * @param object $image - the image.
+ *
+ * @return bool
+ */
public function image_is_panoramic( $image ) {
return $image->ratio >= 2;
}
+ /**
+ * Set the last shape.
+ *
+ * @param string $last_shape - the last shape.
+ */
public static function set_last_shape( $last_shape ) {
self::$shapes_used[] = $last_shape;
}
+ /**
+ * Reset the last shape.
+ */
public static function reset_last_shape() {
self::$shapes_used = array();
}
}
+/**
+ * Jetpack tiled gallery three class.
+ */
class Jetpack_Tiled_Gallery_Three extends Jetpack_Tiled_Gallery_Shape {
+
+ /**
+ * The shape.
+ *
+ * @var array
+ */
public $shape = array( 1, 1, 1 );
+ /**
+ * Checks if there's enough images.
+ *
+ * @return array
+ */
public function is_possible() {
$ratio = $this->sum_ratios( 3 );
- $has_enough_images = $this->images_left >= 3 && ! in_array( $this->images_left, array( 4, 6 ) );
+ $has_enough_images = $this->images_left >= 3 && ! in_array( $this->images_left, array( 4, 6 ), true );
return $has_enough_images && $this->is_not_as_previous( 3 ) &&
( ( $ratio < 2.5 ) || ( $ratio < 5 && $this->next_images_are_symmetric() ) || $this->is_wide_theme() );
}
}
+/**
+ * Jetpack tiled gallery four class.
+ */
class Jetpack_Tiled_Gallery_Four extends Jetpack_Tiled_Gallery_Shape {
+ /**
+ * The shape.
+ *
+ * @var array
+ */
public $shape = array( 1, 1, 1, 1 );
+ /**
+ * Check if it's possible.
+ *
+ * @return bool
+ */
public function is_possible() {
return $this->is_not_as_previous() &&
(
( $this->sum_ratios( 4 ) < 3.5 && $this->images_left > 5 ) ||
- ( $this->sum_ratios( 4 ) < 7 && $this->images_left == 4 )
+ ( $this->sum_ratios( 4 ) < 7 && $this->images_left === 4 )
);
}
}
+/**
+ * Jetpack tiled gallery five class.
+ */
class Jetpack_Tiled_Gallery_Five extends Jetpack_Tiled_Gallery_Shape {
+ /**
+ * The shape.
+ *
+ * @var array
+ */
public $shape = array( 1, 1, 1, 1, 1 );
+ /**
+ * Check if it's possible.
+ *
+ * @return bool
+ */
public function is_possible() {
return $this->is_wide_theme() && $this->is_not_as_previous() && $this->sum_ratios( 5 ) < 5 &&
- ( $this->images_left == 5 || ( $this->images_left != 10 && $this->images_left > 6 ) );
+ ( $this->images_left === 5 || ( $this->images_left !== 10 && $this->images_left > 6 ) );
}
}
+/**
+ * Jetpack tiled gallery two one class.
+ */
class Jetpack_Tiled_Gallery_Two_One extends Jetpack_Tiled_Gallery_Shape {
+ /**
+ * The shape.
+ *
+ * @var array
+ */
public $shape = array( 2, 1 );
+ /**
+ * Check if it's possible.
+ *
+ * @return bool
+ */
public function is_possible() {
return $this->is_not_as_previous( 3 ) && $this->images_left >= 2 &&
$this->images[2]->ratio < 1.6 && $this->images[0]->ratio >= 0.9 && $this->images[0]->ratio < 2.0 && $this->images[1]->ratio >= 0.9 && $this->images[1]->ratio < 2.0;
}
}
+/**
+ * Jetpack tiled gallery one two class.
+ */
class Jetpack_Tiled_Gallery_One_Two extends Jetpack_Tiled_Gallery_Shape {
+ /**
+ * The shape.
+ *
+ * @var array
+ */
public $shape = array( 1, 2 );
+ /**
+ * Check if it's possible.
+ *
+ * @return bool
+ */
public function is_possible() {
return $this->is_not_as_previous( 3 ) && $this->images_left >= 2 &&
$this->images[0]->ratio < 1.6 && $this->images[1]->ratio >= 0.9 && $this->images[1]->ratio < 2.0 && $this->images[2]->ratio >= 0.9 && $this->images[2]->ratio < 2.0;
}
}
+/**
+ * Jetpack tiled gallery one three class.
+ */
class Jetpack_Tiled_Gallery_One_Three extends Jetpack_Tiled_Gallery_Shape {
+ /**
+ * The shape.
+ *
+ * @var array
+ */
public $shape = array( 1, 3 );
+ /**
+ * Check if it's possible.
+ *
+ * @return bool
+ */
public function is_possible() {
return $this->is_not_as_previous( 3 ) && $this->images_left > 3 &&
$this->image_is_portrait( $this->images[0] ) &&
@@ -106,9 +253,22 @@ class Jetpack_Tiled_Gallery_One_Three extends Jetpack_Tiled_Gallery_Shape {
}
}
+/**
+ * Jetpack tiled gallery three one class.
+ */
class Jetpack_Tiled_Gallery_Three_One extends Jetpack_Tiled_Gallery_Shape {
+ /**
+ * The shape.
+ *
+ * @var array
+ */
public $shape = array( 3, 1 );
+ /**
+ * Check if it's possible.
+ *
+ * @return bool
+ */
public function is_possible() {
return $this->is_not_as_previous( 3 ) && $this->images_left > 3 &&
$this->image_is_portrait( $this->images[3] ) &&
@@ -118,30 +278,70 @@ class Jetpack_Tiled_Gallery_Three_One extends Jetpack_Tiled_Gallery_Shape {
}
}
+/**
+ * Jetpack tiled gallery panoramic class.
+ */
class Jetpack_Tiled_Gallery_Panoramic extends Jetpack_Tiled_Gallery_Shape {
+ /**
+ * The shape.
+ *
+ * @var array
+ */
public $shape = array( 1 );
+ /**
+ * Check if it's possible.
+ *
+ * @return bool
+ */
public function is_possible() {
return $this->image_is_panoramic( $this->images[0] );
}
}
+/**
+ * Jetpack tiled gallery symmetric class.
+ */
class Jetpack_Tiled_Gallery_Symmetric_Row extends Jetpack_Tiled_Gallery_Shape {
+ /**
+ * The shape.
+ *
+ * @var array
+ */
public $shape = array( 1, 2, 1 );
+ /**
+ * Check if it's possible.
+ *
+ * @return bool
+ */
public function is_possible() {
return $this->is_not_as_previous( 5 ) &&
$this->images_left > 3 &&
- $this->images_left != 5 &&
+ $this->images_left !== 5 &&
$this->image_is_portrait( $this->images[0] ) &&
$this->image_is_landscape( $this->images[1] ) &&
$this->image_is_landscape( $this->images[2] ) &&
$this->image_is_portrait( $this->images[3] );
}
}
+
+/**
+ * Jetpack tiled gallery reverse symmetric row class.
+ */
class Jetpack_Tiled_Gallery_Reverse_Symmetric_Row extends Jetpack_Tiled_Gallery_Shape {
+ /**
+ * The shape.
+ *
+ * @var array
+ */
public $shape = array( 2, 1, 2 );
+ /**
+ * Check if it's possible.
+ *
+ * @return bool
+ */
public function is_possible() {
return $this->is_not_as_previous( 5 ) && $this->images_left > 15 &&
$this->image_is_landscape( $this->images[0] ) &&
@@ -152,9 +352,22 @@ class Jetpack_Tiled_Gallery_Reverse_Symmetric_Row extends Jetpack_Tiled_Gallery_
}
}
+/**
+ * Jetpack tiled gallery long symmetric row class.
+ */
class Jetpack_Tiled_Gallery_Long_Symmetric_Row extends Jetpack_Tiled_Gallery_Shape {
+ /**
+ * The shape.
+ *
+ * @var array
+ */
public $shape = array( 3, 1, 3 );
+ /**
+ * Check if it's possible.
+ *
+ * @return bool
+ */
public function is_possible() {
return $this->is_not_as_previous( 5 ) && $this->images_left > 15 &&
$this->image_is_landscape( $this->images[0] ) &&
@@ -167,15 +380,31 @@ class Jetpack_Tiled_Gallery_Long_Symmetric_Row extends Jetpack_Tiled_Gallery_Sha
}
}
+/**
+ * Jetpack tiled gallery three columns class.
+ */
class Jetpack_Tiled_Gallery_Three_Columns extends Jetpack_Tiled_Gallery_Shape {
+ /**
+ * The shape.
+ *
+ * @var array
+ */
public $shape = array();
+ /**
+ * Constructor class.
+ *
+ * @param object $images - the images.
+ */
public function __construct( $images ) {
parent::__construct( $images );
$total_ratio = $this->sum_ratios( $this->images_left );
$approximate_column_ratio = $total_ratio / 3;
- $column_one_images = $column_two_images = $column_three_images = $sum = 0;
+ $column_one_images = 0;
+ $column_two_images = 0;
+ $column_three_images = 0;
+ $sum = 0;
foreach ( $this->images as $image ) {
if ( $sum <= $approximate_column_ratio ) {
@@ -203,6 +432,11 @@ class Jetpack_Tiled_Gallery_Three_Columns extends Jetpack_Tiled_Gallery_Shape {
}
}
+ /**
+ * Check if it's possible.
+ *
+ * @return bool
+ */
public function is_possible() {
return ! empty( $this->shape );
}
diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-square.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-square.php
index 735c19eb..467f2747 100644
--- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-square.php
+++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-square.php
@@ -1,19 +1,32 @@
-<?php
-require_once dirname( __FILE__ ) . '/tiled-gallery-layout.php';
-require_once dirname( __FILE__ ) . '/tiled-gallery-item.php';
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+require_once __DIR__ . '/tiled-gallery-layout.php';
+require_once __DIR__ . '/tiled-gallery-item.php';
+/**
+ * Jetpack tiled gallery square layout class.
+ */
class Jetpack_Tiled_Gallery_Layout_Square extends Jetpack_Tiled_Gallery_Layout {
+
+ /**
+ * Layout type.
+ *
+ * @var string
+ */
protected $type = 'square';
+ /**
+ * Compute the items.
+ */
private function compute_items() {
$content_width = Jetpack_Tiled_Gallery::get_content_width();
$images_per_row = ( $this->columns > 1 ? $this->columns : 1 );
$margin = 2;
- $margin_space = ( $images_per_row * $margin ) * 2;
- $size = floor( ( $content_width - $margin_space ) / $images_per_row );
- $img_size = $remainder_size = $size;
- $remainder = count( $this->attachments ) % $images_per_row;
+ $margin_space = ( $images_per_row * $margin ) * 2;
+ $size = floor( ( $content_width - $margin_space ) / $images_per_row );
+ $remainder_size = $size;
+ $img_size = $remainder_size;
+ $remainder = count( $this->attachments ) % $images_per_row;
if ( $remainder > 0 ) {
$remainder_space = ( $remainder * $margin ) * 2;
$remainder_size = floor( ( $content_width - $remainder_space ) / $remainder );
@@ -31,7 +44,8 @@ class Jetpack_Tiled_Gallery_Layout_Square extends Jetpack_Tiled_Gallery_Layout {
$img_size = $size;
}
- $image->width = $image->height = $img_size;
+ $image->width = $img_size;
+ $image->height = $image->width;
$item = new Jetpack_Tiled_Gallery_Square_Item( $image, $this->needs_attachment_link, $this->grayscale );
@@ -39,7 +53,7 @@ class Jetpack_Tiled_Gallery_Layout_Square extends Jetpack_Tiled_Gallery_Layout {
$c ++;
$items_in_row++;
- if ( $images_per_row === $items_in_row || $remainder + 1 == $c ) {
+ if ( $images_per_row === $items_in_row || $remainder + 1 === $c ) {
$rows[] = $row;
$items_in_row = 0;
@@ -63,7 +77,13 @@ class Jetpack_Tiled_Gallery_Layout_Square extends Jetpack_Tiled_Gallery_Layout {
return $rows;
}
- public function HTML( $context = array() ) {
+ /**
+ * The html.
+ *
+ * @param array $context - the context, unused.
+ * @return string HTML
+ */
+ public function HTML( $context = array() ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
return parent::HTML( array( 'rows' => $this->compute_items() ) );
}
}
diff --git a/plugins/jetpack/modules/vaultpress.php b/plugins/jetpack/modules/vaultpress.php
index aeeb0219..0555d8ff 100644
--- a/plugins/jetpack/modules/vaultpress.php
+++ b/plugins/jetpack/modules/vaultpress.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:disable WordPress.WP.CapitalPDangit.Misspelled
/**
* Module Name: Backups and Scanning
* Module Description: Protect your site with daily or real-time backups and automated virus scanning and threat detection.
@@ -15,6 +15,9 @@
add_action( 'jetpack_modules_loaded', 'vaultpress_jetpack_stub' );
+/**
+ * Conditionally enable module configuration.
+ */
function vaultpress_jetpack_stub() {
if ( class_exists( 'VaultPress' ) || function_exists( 'vaultpress_contact_service' ) ) {
Jetpack::enable_module_configurable( __FILE__ );
@@ -23,11 +26,17 @@ function vaultpress_jetpack_stub() {
}
}
+/**
+ * Text for filter jetpack_module_free_text_vaultpress.
+ */
function vaultpress_jetpack_module_free_text() {
return __( 'Active', 'jetpack' );
}
+/**
+ * URL for filter jetpack_module_configuration_url_vaultpress.
+ */
function vaultpress_jetpack_configure_url() {
- include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
+ include_once ABSPATH . '/wp-admin/includes/plugin.php';
return menu_page_url( 'vaultpress', false );
}
diff --git a/plugins/jetpack/modules/verification-tools/blog-verification-tools.php b/plugins/jetpack/modules/verification-tools/blog-verification-tools.php
index e3f0dbac..09778c2c 100644
--- a/plugins/jetpack/modules/verification-tools/blog-verification-tools.php
+++ b/plugins/jetpack/modules/verification-tools/blog-verification-tools.php
@@ -1,6 +1,16 @@
<?php
+/**
+ * Handles site verification services.
+ *
+ * @package jetpack
+ */
-// Edit here to add new services
+/**
+ * Return an array of supported verification services.
+ * Add new services to this function.
+ *
+ * @return array - an array of supported services.
+ */
function jetpack_verification_services() {
return array(
'google' => array(
@@ -36,6 +46,9 @@ function jetpack_verification_services() {
);
}
+/**
+ * Register Jetpack verification settings.
+ */
function jetpack_verification_options_init() {
register_setting(
'verification_services_codes_fields',
@@ -46,6 +59,9 @@ function jetpack_verification_options_init() {
add_action( 'admin_init', 'jetpack_verification_options_init' );
add_action( 'rest_api_init', 'jetpack_verification_options_init' );
+/**
+ * Print the site verification meta in the page head.
+ */
function jetpack_verification_print_meta() {
$verification_services_codes = Jetpack_Options::get_option_and_ensure_autoload( 'verification_services_codes', '0' );
if ( is_array( $verification_services_codes ) ) {
@@ -71,7 +87,7 @@ function jetpack_verification_print_meta() {
$ver_output .= "\n";
}
}
- echo $ver_output;
+ echo $ver_output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
add_action( 'wp_head', 'jetpack_verification_print_meta', 1 );
diff --git a/plugins/jetpack/modules/verification-tools/verification-tools-utils.php b/plugins/jetpack/modules/verification-tools/verification-tools-utils.php
index 6faec481..1f916e96 100644
--- a/plugins/jetpack/modules/verification-tools/verification-tools-utils.php
+++ b/plugins/jetpack/modules/verification-tools/verification-tools-utils.php
@@ -1,14 +1,20 @@
<?php
-
-/*
+/**
* Helper functions that are called from API even when module is inactive should be added here.
* This file will be included in module-extras.php.
+ *
+ * @package jetpack
*/
if ( ! function_exists( 'jetpack_verification_validate' ) ) {
+ /**
+ * Validate jetpack verification codes.
+ *
+ * @param array $verification_services_codes - array of verification codes.
+ */
function jetpack_verification_validate( $verification_services_codes ) {
foreach ( $verification_services_codes as $key => $code ) {
- // Parse html meta tag if it does not look like a valid code
+ // Parse html meta tag if it does not look like a valid code.
if ( ! preg_match( '/^[a-z0-9_-]+$/i', $code ) ) {
$code = jetpack_verification_get_code( $code );
}
@@ -37,6 +43,11 @@ if ( ! function_exists( 'jetpack_verification_validate' ) ) {
}
if ( ! function_exists( 'jetpack_verification_get_code' ) ) {
+ /**
+ * Return the code we're trying to verify after decoding.
+ *
+ * @param string $code - the code we need to parse.
+ */
function jetpack_verification_get_code( $code ) {
$pattern = '/content=["\']?([^"\' ]*)["\' ]/is';
preg_match( $pattern, $code, $match );
diff --git a/plugins/jetpack/modules/videopress.php b/plugins/jetpack/modules/videopress.php
index eafc1b67..4709658f 100644
--- a/plugins/jetpack/modules/videopress.php
+++ b/plugins/jetpack/modules/videopress.php
@@ -8,19 +8,24 @@
* Module Tags: Photos and Videos
* Feature: Writing
* Additional Search Queries: video, videos, videopress, video gallery, video player, videoplayer, mobile video, vimeo, youtube, html5 video, stream
+ *
+ * @package automattic/jetpack
*/
-include_once dirname( __FILE__ ) . '/videopress/shortcode.php';
-include_once dirname( __FILE__ ) . '/videopress/class.videopress-options.php';
-include_once dirname( __FILE__ ) . '/videopress/class.videopress-scheduler.php';
-include_once dirname( __FILE__ ) . '/videopress/class.videopress-xmlrpc.php';
-include_once dirname( __FILE__ ) . '/videopress/class.videopress-cli.php';
-include_once dirname( __FILE__ ) . '/videopress/class.jetpack-videopress.php';
+/**
+ * Require the VideoPress files.
+ */
+require_once __DIR__ . '/videopress/shortcode.php';
+require_once __DIR__ . '/videopress/class.videopress-options.php';
+require_once __DIR__ . '/videopress/class.videopress-scheduler.php';
+require_once __DIR__ . '/videopress/class.videopress-xmlrpc.php';
+require_once __DIR__ . '/videopress/class.videopress-cli.php';
+require_once __DIR__ . '/videopress/class.jetpack-videopress.php';
require_once __DIR__ . '/videopress/class-videopress-attachment-metadata.php';
if ( is_admin() ) {
- include_once dirname( __FILE__ ) . '/videopress/editor-media-view.php';
- include_once dirname( __FILE__ ) . '/videopress/class.videopress-edit-attachment.php';
- include_once dirname( __FILE__ ) . '/videopress/class.videopress-ajax.php';
+ include_once __DIR__ . '/videopress/editor-media-view.php';
+ include_once __DIR__ . '/videopress/class.videopress-edit-attachment.php';
+ include_once __DIR__ . '/videopress/class.videopress-ajax.php';
}
diff --git a/plugins/jetpack/modules/videopress/class-videopress-attachment-metadata.php b/plugins/jetpack/modules/videopress/class-videopress-attachment-metadata.php
index c745350b..9a50ef31 100644
--- a/plugins/jetpack/modules/videopress/class-videopress-attachment-metadata.php
+++ b/plugins/jetpack/modules/videopress/class-videopress-attachment-metadata.php
@@ -15,18 +15,19 @@ class Videopress_Attachment_Metadata {
/**
* Persist the VideoPress metadata information, including rating and display_embed.
*
- * @param string|int $post_id The post id.
- * @param string $guid VideoPress Guid.
- * @param string $post_title The post title.
- * @param string $caption Video caption.
- * @param string $post_excerpt The post excerpt.
- * @param string $rating The rating.
- * @param int $display_embed The display_embed.
- * @param int $allow_download Allow video downloads.
+ * @param string|int $post_id The post id.
+ * @param string $guid VideoPress Guid.
+ * @param string $post_title The post title.
+ * @param string $caption Video caption.
+ * @param string $post_excerpt The post excerpt.
+ * @param string $rating The rating.
+ * @param int $display_embed The display_embed.
+ * @param int $allow_download Allow video downloads.
+ * @param int $privacy_setting The video privacy setting.
*
* @return bool|\WP_Error
*/
- public static function persist_metadata( $post_id, $guid, $post_title, $caption, $post_excerpt, $rating, $display_embed, $allow_download ) {
+ public static function persist_metadata( $post_id, $guid, $post_title, $caption, $post_excerpt, $rating, $display_embed, $allow_download, $privacy_setting ) {
$post_id = absint( $post_id );
$args = array(
@@ -35,10 +36,11 @@ class Videopress_Attachment_Metadata {
);
// Keep null values to avoid accidental unset.
- $display_embed = null === $display_embed ? null : (int) $display_embed;
- $allow_download = null === $allow_download ? null : (int) $allow_download;
+ $display_embed = null === $display_embed ? null : (int) $display_embed;
+ $allow_download = null === $allow_download ? null : (int) $allow_download;
+ $privacy_setting = null === $privacy_setting ? null : (int) $privacy_setting;
- $values = self::build_wpcom_api_request_values( $post_title, $caption, $post_excerpt, $rating, $display_embed, $allow_download );
+ $values = self::build_wpcom_api_request_values( $post_title, $caption, $post_excerpt, $rating, $display_embed, $allow_download, $privacy_setting );
$endpoint = 'videos';
$values['guid'] = $guid;
@@ -68,6 +70,10 @@ class Videopress_Attachment_Metadata {
$meta['videopress']['rating'] = $values['rating'];
}
+ if ( isset( $values['privacy_setting'] ) ) {
+ $meta['videopress']['privacy_setting'] = $values['privacy_setting'];
+ }
+
wp_update_attachment_metadata( $post_id, $meta );
return true;
@@ -111,6 +117,16 @@ class Videopress_Attachment_Metadata {
}
/**
+ * Check if privacy_setting has valid values
+ *
+ * @param mixed $privacy_setting The value to test.
+ * @return bool
+ */
+ private static function is_privacy_setting_valid( $privacy_setting ) {
+ return in_array( $privacy_setting, array( VIDEOPRESS_PRIVACY::IS_PUBLIC, VIDEOPRESS_PRIVACY::IS_PRIVATE, VIDEOPRESS_PRIVACY::SITE_DEFAULT ), true );
+ }
+
+ /**
* Validate the response received from WPCOM.
*
* @param array|\WP_Error $result The result returned by the client.
@@ -147,10 +163,11 @@ class Videopress_Attachment_Metadata {
* @param string $rating The video rating.
* @param string $display_embed The video display_embed.
* @param int $allow_download The video allow_download.
+ * @param int $privacy_setting The video privacy setting.
*
* @return array
*/
- private static function build_wpcom_api_request_values( $post_title, $caption, $post_excerpt, $rating, $display_embed, $allow_download ) {
+ private static function build_wpcom_api_request_values( $post_title, $caption, $post_excerpt, $rating, $display_embed, $allow_download, $privacy_setting ) {
$values = array();
// Add the video title & description in, so that we save it properly.
@@ -178,6 +195,10 @@ class Videopress_Attachment_Metadata {
$values['allow_download'] = $allow_download;
}
+ if ( self::is_privacy_setting_valid( $privacy_setting ) ) {
+ $values['privacy_setting'] = $privacy_setting;
+ }
+
return $values;
}
}
diff --git a/plugins/jetpack/modules/videopress/class.jetpack-videopress.php b/plugins/jetpack/modules/videopress/class.jetpack-videopress.php
index 0d02cbe0..2f79fc0d 100644
--- a/plugins/jetpack/modules/videopress/class.jetpack-videopress.php
+++ b/plugins/jetpack/modules/videopress/class.jetpack-videopress.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Assets;
use Automattic\Jetpack\Connection\Client;
@@ -7,11 +7,19 @@ use Automattic\Jetpack\Connection\Client;
* VideoPress in Jetpack
*/
class Jetpack_VideoPress {
- /** @var string */
+ /**
+ * Module name.
+ *
+ * @var string
+ */
public $module = 'videopress';
- /** @var int */
- public $version = 5;
+ /**
+ * Version number used for cache busting.
+ *
+ * @var string
+ */
+ const VERSION = '6';
/**
* Singleton
@@ -32,7 +40,6 @@ class Jetpack_VideoPress {
* Sets up the initializer and makes sure that videopress activates and deactivates properly.
*/
private function __construct() {
- // $this->version = time(); // <s>ghost</s> cache busters!
add_action( 'init', array( $this, 'on_init' ) );
add_action( 'jetpack_deactivate_module_videopress', array( $this, 'jetpack_module_deactivated' ) );
}
@@ -62,10 +69,43 @@ class Jetpack_VideoPress {
if ( $this->is_videopress_enabled() ) {
add_action( 'admin_notices', array( $this, 'media_new_page_admin_notice' ) );
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_jwt_token_bridge' ) );
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_jwt_token_bridge' ), 1 );
}
}
/**
+ * Enqueues the jwt bridge script.
+ */
+ public function enqueue_jwt_token_bridge() {
+ global $post;
+ $post_id = isset( $post->ID ) ? absint( $post->ID ) : 0;
+
+ $bridge_url = Assets::get_file_url_for_environment(
+ 'modules/videopress/js/videopress-token-bridge.js',
+ 'modules/videopress/js/videopress-token-bridge.js'
+ );
+
+ wp_enqueue_script(
+ 'media-video-jwt-bridge',
+ $bridge_url,
+ array(),
+ self::VERSION,
+ false
+ );
+
+ wp_localize_script(
+ 'media-video-jwt-bridge',
+ 'videopressAjax',
+ array(
+ 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
+ 'bridgeUrl' => $bridge_url,
+ 'post_id' => $post_id,
+ )
+ );
+ }
+
+ /**
* The media-new.php page isn't supported for uploading to VideoPress.
*
* There is either a technical reason for this (bulk uploader isn't overridable),
@@ -100,10 +140,11 @@ class Jetpack_VideoPress {
}
/**
- * A can of coke
+ * Similar to current_user_can, but internal to VideoPress.
*
- * Similar to current_user_can, but internal to VideoPress. Returns
- * true if the given VideoPress capability is allowed by the given user.
+ * @param string $cap Capability name.
+ * @param int $user_id User ID.
+ * @return bool Returns true if the given VideoPress capability is allowed by the given user.
*/
public function can( $cap, $user_id = false ) {
if ( ! $user_id ) {
@@ -120,11 +161,11 @@ class Jetpack_VideoPress {
return false;
}
- if ( 'edit_videos' == $cap && ! user_can( $user_id, 'edit_others_posts' ) ) {
+ if ( 'edit_videos' === $cap && ! user_can( $user_id, 'edit_others_posts' ) ) {
return false;
}
- if ( 'delete_videos' == $cap && ! user_can( $user_id, 'delete_others_posts' ) ) {
+ if ( 'delete_videos' === $cap && ! user_can( $user_id, 'delete_others_posts' ) ) {
return false;
}
@@ -135,7 +176,7 @@ class Jetpack_VideoPress {
* Register and enqueue VideoPress admin styles.
*/
public function enqueue_admin_styles() {
- wp_register_style( 'videopress-admin', plugins_url( 'videopress-admin.css', __FILE__ ), array(), $this->version );
+ wp_register_style( 'videopress-admin', plugins_url( 'videopress-admin.css', __FILE__ ), array(), self::VERSION );
wp_enqueue_style( 'videopress-admin' );
}
@@ -215,7 +256,8 @@ class Jetpack_VideoPress {
'jquery',
'wp-plupload',
),
- $this->version
+ self::VERSION,
+ true
);
wp_enqueue_script(
@@ -227,7 +269,8 @@ class Jetpack_VideoPress {
array(
'videopress-plupload',
),
- $this->version
+ self::VERSION,
+ true
);
wp_enqueue_script(
@@ -237,7 +280,7 @@ class Jetpack_VideoPress {
'modules/videopress/js/media-video-widget-extensions.js'
),
array(),
- $this->version,
+ self::VERSION,
true
);
}
@@ -269,7 +312,9 @@ class Jetpack_VideoPress {
}
/**
- * Modify the default plupload config to turn on videopress specific filters.
+ * Modify the default plupload config to turn on VideoPress specific filters.
+ *
+ * @param array $config The plupload config.
*/
public function videopress_pluploder_config( $config ) {
@@ -285,7 +330,6 @@ class Jetpack_VideoPress {
return $config;
}
-
/**
* Helper function to determine if the media uploader should be overridden.
*
@@ -309,7 +353,7 @@ class Jetpack_VideoPress {
);
// Only load on the post, new post, or upload pages.
- if ( ! in_array( $pagenow, $acceptable_pages ) ) {
+ if ( ! in_array( $pagenow, $acceptable_pages, true ) ) {
return false;
}
@@ -344,7 +388,7 @@ class Jetpack_VideoPress {
return false;
}
- if ( ! isset( $_GET['action'] ) || $_GET['action'] !== 'add-new' ) {
+ if ( ! isset( $_GET['action'] ) || $_GET['action'] !== 'add-new' ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return false;
}
@@ -363,7 +407,7 @@ class Jetpack_VideoPress {
/**
* Makes sure that all video mimes are added in, as multi site installs can remove them.
*
- * @param array $existing_mimes
+ * @param array $existing_mimes Mime types to extend/filter.
* @return array
*/
public function add_video_upload_mimes( $existing_mimes = array() ) {
@@ -383,7 +427,7 @@ class Jetpack_VideoPress {
/**
* Filter designed to get rid of non video mime types.
*
- * @param string $value
+ * @param string $value Mime type to filter.
* @return int
*/
public function filter_video_mimes( $value ) {
@@ -391,9 +435,11 @@ class Jetpack_VideoPress {
}
/**
- * @param string $icon
- * @param string $mime
- * @param int $post_id
+ * Filter the mime type icon.
+ *
+ * @param string $icon Icon path.
+ * @param string $mime Mime type.
+ * @param int $post_id Post ID.
*
* @return string
*/
@@ -413,7 +459,9 @@ class Jetpack_VideoPress {
}
/**
- * @param array $extensions
+ * Filter the list of supported video formats.
+ *
+ * @param array $extensions Supported video formats.
*
* @return array
*/
diff --git a/plugins/jetpack/modules/videopress/class.videopress-ajax.php b/plugins/jetpack/modules/videopress/class.videopress-ajax.php
index 620605a9..a554e89b 100644
--- a/plugins/jetpack/modules/videopress/class.videopress-ajax.php
+++ b/plugins/jetpack/modules/videopress/class.videopress-ajax.php
@@ -1,10 +1,15 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Connection\Client;
+/**
+ * VideoPress AJAX action handlers and utilities.
+ */
class VideoPress_AJAX {
/**
+ * Singleton VideoPress_AJAX instance.
+ *
* @var VideoPress_AJAX
**/
private static $instance = null;
@@ -16,6 +21,9 @@ class VideoPress_AJAX {
*/
private function __construct() {
add_action( 'wp_ajax_videopress-get-upload-token', array( $this, 'wp_ajax_videopress_get_upload_token' ) );
+ add_action( 'wp_ajax_videopress-get-upload-jwt', array( $this, 'wp_ajax_videopress_get_upload_jwt' ) );
+ add_action( 'wp_ajax_nopriv_videopress-get-playback-jwt', array( $this, 'wp_ajax_videopress_get_playback_jwt' ) );
+ add_action( 'wp_ajax_videopress-get-playback-jwt', array( $this, 'wp_ajax_videopress_get_playback_jwt' ) );
add_action(
'wp_ajax_videopress-update-transcoding-status',
@@ -33,7 +41,7 @@ class VideoPress_AJAX {
* @return VideoPress_AJAX
*/
public static function init() {
- if ( is_null( self::$instance ) ) {
+ if ( self::$instance === null ) {
self::$instance = new VideoPress_AJAX();
}
@@ -41,6 +49,180 @@ class VideoPress_AJAX {
}
/**
+ * Validate a guid.
+ *
+ * @param string $guid The guid to validate.
+ *
+ * @return bool
+ **/
+ private function is_valid_guid( $guid ) {
+ if ( empty( $guid ) ) {
+ return false;
+ }
+
+ preg_match( '/^[a-z0-9]+$/i', $guid, $matches );
+
+ if ( empty( $matches ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Ajax method that is used by the VideoPress player to get a token to play a video.
+ *
+ * This is used for both logged in and logged out users.
+ *
+ * @return void
+ */
+ public function wp_ajax_videopress_get_playback_jwt() {
+ $guid = filter_input( INPUT_POST, 'guid' );
+ $embedded_post_id = filter_input( INPUT_POST, 'post_id', FILTER_VALIDATE_INT );
+
+ if ( empty( $embedded_post_id ) ) {
+ $embedded_post_id = 0;
+ }
+
+ if ( empty( $guid ) || ! $this->is_valid_guid( $guid ) ) {
+ wp_send_json_error( array( 'message' => __( 'need a guid', 'jetpack' ) ) );
+ return;
+ }
+
+ if ( ! $this->is_current_user_authed_for_video( $guid, $embedded_post_id ) ) {
+ wp_send_json_error( array( 'message' => __( 'You cannot view this video.', 'jetpack' ) ) );
+ return;
+ }
+
+ $token = $this->request_jwt_from_wpcom( $guid );
+
+ if ( empty( $token ) ) {
+ wp_send_json_error( array( 'message' => __( 'Could not obtain a VideoPress playback JWT. Please try again later. (empty upload token)', 'jetpack' ) ) );
+ return;
+ }
+
+ if ( is_wp_error( $token ) ) {
+ wp_send_json_error( array( 'message' => __( 'Could not obtain a VideoPress upload JWT. Please try again later.', 'jetpack' ) ) );
+ return;
+ }
+
+ wp_send_json_success( array( 'jwt' => $token ) );
+ }
+
+ /**
+ * Determines if the current user can view the provided video. Only ever gets fired if site-wide private videos are enabled.
+ *
+ * Filterable for 3rd party plugins.
+ *
+ * @param string $guid The video id being checked.
+ * @param int $embedded_post_id The post id the video is embedded in or 0.
+ */
+ private function is_current_user_authed_for_video( $guid, $embedded_post_id ) {
+ $attachment = videopress_get_post_by_guid( $guid );
+ if ( ! $attachment ) {
+ return false;
+ }
+
+ $video_info = video_get_info_by_blogpostid( get_current_blog_id(), $attachment->ID );
+ if ( null === $video_info->guid ) {
+ return false;
+ }
+
+ $is_user_authed = false;
+ // Determine if video is public, private or use site default.
+ switch ( $video_info->privacy_setting ) {
+ case VIDEOPRESS_PRIVACY::IS_PUBLIC:
+ $is_user_authed = true;
+ break;
+ case VIDEOPRESS_PRIVACY::IS_PRIVATE:
+ $is_user_authed = current_user_can( 'read' );
+ break;
+ case VIDEOPRESS_PRIVACY::SITE_DEFAULT:
+ default:
+ $is_videopress_private_for_site = get_option( 'videopress_private_enabled_for_site', false );
+ $is_user_authed = false === $is_videopress_private_for_site || ( $is_videopress_private_for_site && current_user_can( 'read' ) );
+ break;
+ }
+
+ /**
+ * Overrides video view authorization for current user.
+ *
+ * Example of making all videos public:
+ *
+ * function jp_example_override_video_auth( $is_user_authed, $guid ) {
+ * return true
+ * };
+ * add_filter( 'videopress_is_current_user_authed_for_video', 'jp_example_override_video_auth', 10, 2 );
+ *
+ * @param bool $is_user_authed The current user authorization state.
+ * @param string $guid The video's unique identifier.
+ * @param int|null $embedded_post_id The post the video is embedded..
+ *
+ * @return bool
+ */
+ return (bool) apply_filters( 'videopress_is_current_user_authed_for_video', $is_user_authed, $guid, $embedded_post_id );
+ }
+
+ /**
+ * Requests JWT from wpcom.
+ *
+ * @param string $guid The video id being checked.
+ */
+ private function request_jwt_from_wpcom( $guid ) {
+ $options = VideoPress_Options::get_options();
+
+ $args = array(
+ 'method' => 'POST',
+ );
+
+ $endpoint = "sites/{$options['shadow_blog_id']}/media/videopress-playback-jwt/{$guid}";
+ $result = Client::wpcom_json_api_request_as_blog( $endpoint, 'v2', $args, null, 'wpcom' );
+ if ( is_wp_error( $result ) ) {
+ return $result;
+ }
+
+ $response = json_decode( $result['body'], true );
+
+ if ( empty( $response['metadata_token'] ) ) {
+ return false;
+ }
+
+ return $response['metadata_token'];
+ }
+
+ /**
+ * Ajax method that is used by the VideoPress uploader to get a token to upload a file to the wpcom api.
+ *
+ * @return void
+ */
+ public function wp_ajax_videopress_get_upload_jwt() {
+
+ $options = VideoPress_Options::get_options();
+
+ $args = array(
+ 'method' => 'POST',
+ );
+
+ $endpoint = "sites/{$options['shadow_blog_id']}/media/videopress-upload-jwt";
+ $result = Client::wpcom_json_api_request_as_blog( $endpoint, 'v2', $args, null, 'wpcom' );
+ if ( is_wp_error( $result ) ) {
+ wp_send_json_error( array( 'message' => __( 'Could not obtain a VideoPress upload JWT. Please try again later.', 'jetpack' ) ) );
+ return;
+ }
+
+ $response = json_decode( $result['body'], true );
+
+ if ( empty( $response['upload_token'] ) ) {
+ wp_send_json_error( array( 'message' => __( 'Could not obtain a VideoPress upload JWT. Please try again later. (empty upload token)', 'jetpack' ) ) );
+ return;
+ }
+
+ $response['upload_action_url'] = videopress_make_resumable_upload_path( $options['shadow_blog_id'] );
+
+ wp_send_json_success( $response );
+ }
+
+ /**
* Ajax method that is used by the VideoPress uploader to get a token to upload a file to the wpcom api.
*
* @return void
@@ -51,7 +233,6 @@ class VideoPress_AJAX {
$args = array(
'method' => 'POST',
- // 'sslverify' => false,
);
$endpoint = "sites/{$options['shadow_blog_id']}/media/token";
@@ -80,12 +261,12 @@ class VideoPress_AJAX {
* @return void
*/
public function wp_ajax_update_transcoding_status() {
- if ( ! isset( $_POST['post_id'] ) ) {
+ if ( ! isset( $_POST['post_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Informational AJAX response.
wp_send_json_error( array( 'message' => __( 'A valid post_id is required.', 'jetpack' ) ) );
return;
}
- $post_id = (int) $_POST['post_id'];
+ $post_id = (int) $_POST['post_id']; // phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( ! videopress_update_meta_data( $post_id ) ) {
wp_send_json_error( array( 'message' => __( 'That post does not have a VideoPress video associated to it.', 'jetpack' ) ) );
diff --git a/plugins/jetpack/modules/videopress/class.videopress-cli.php b/plugins/jetpack/modules/videopress/class.videopress-cli.php
index e1200da0..e8d2a912 100644
--- a/plugins/jetpack/modules/videopress/class.videopress-cli.php
+++ b/plugins/jetpack/modules/videopress/class.videopress-cli.php
@@ -1,4 +1,9 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName
+/**
+ * VideoPress CLI
+ *
+ * @package automattic/jetpack
+ */
if ( defined( 'WP_CLI' ) && WP_CLI ) {
@@ -16,11 +21,14 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
* ## EXAMPLES
*
* wp videopress import kUJmAcSf
+ *
+ * @param array $args CLI arguments.
*/
public function import( $args ) {
$guid = $args[0];
$attachment_id = create_local_media_library_for_videopress_guid( $guid );
if ( $attachment_id && ! is_wp_error( $attachment_id ) ) {
+ /* translators: %d: attachment id */
WP_CLI::success( sprintf( __( 'The video has been imported as Attachment ID %d', 'jetpack' ), $attachment_id ) );
} else {
WP_CLI::error( __( 'An error has been encountered.', 'jetpack' ) );
@@ -37,6 +45,7 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
public function cleanup_videos() {
$num_cleaned = videopress_cleanup_media_library();
+ /* translators: %d: number of videos cleaned */
WP_CLI::success( sprintf( _n( 'Cleaned up %d video.', 'Cleaned up a total of %d videos.', $num_cleaned, 'jetpack' ), $num_cleaned ) );
}
@@ -58,6 +67,7 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::success( __( 'Found no available cron jobs.', 'jetpack' ) );
} else {
+ /* translators: %d is the number of crons */
WP_CLI::success( sprintf( _n( 'Found %d available cron job.', 'Found %d available cron jobs.', count( $crons ), 'jetpack' ), count( $crons ) ) );
}
@@ -83,6 +93,8 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
* ## EXAMPLES
*
* wp videopress cron_status cleanup
+ *
+ * @param array $args CLI args.
*/
public function cron_status( $args ) {
@@ -93,7 +105,8 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
$scheduler = VideoPress_Scheduler::init();
if ( ! $scheduler->is_cron_valid( $args[0] ) ) {
- return WP_CLI::error( sprintf( __( 'There is no cron named %s.', 'jetpack' ), $args[0] ) );
+ /* translators: name of a cron job */
+ WP_CLI::error( sprintf( __( 'There is no cron named %s.', 'jetpack' ), $args[0] ) );
}
$time = $scheduler->check_cron( $args[0] );
@@ -102,6 +115,7 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::success( __( 'The cron is not scheduled to run.', 'jetpack' ) );
} else {
+ /* translators: date/time */
WP_CLI::success( sprintf( __( 'Cron will run at: %s GMT', 'jetpack' ), gmdate( 'Y-m-d H:i:s', $time ) ) );
}
}
@@ -116,6 +130,8 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
* ## EXAMPLES
*
* wp videopress activate_cron cleanup
+ *
+ * @param array $args CLI args.
*/
public function activate_cron( $args ) {
@@ -126,11 +142,13 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
$scheduler = VideoPress_Scheduler::init();
if ( ! $scheduler->is_cron_valid( $args[0] ) ) {
- return WP_CLI::error( sprintf( __( 'There is no cron named %s.', 'jetpack' ), $args[0] ) );
+ /* translators: name of a cron job */
+ WP_CLI::error( sprintf( __( 'There is no cron named %s.', 'jetpack' ), $args[0] ) );
}
$scheduler->activate_cron( $args[0] );
+ /* translators: name of a cron job */
WP_CLI::success( sprintf( __( 'The cron named `%s` was scheduled.', 'jetpack' ), $args[0] ) );
}
@@ -144,6 +162,8 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
* ## EXAMPLES
*
* wp videopress deactivate_cron cleanup
+ *
+ * @param array $args CLI args.
*/
public function deactivate_cron( $args ) {
@@ -154,11 +174,13 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
$scheduler = VideoPress_Scheduler::init();
if ( ! $scheduler->is_cron_valid( $args[0] ) ) {
- return WP_CLI::error( sprintf( __( 'There is no cron named %s.', 'jetpack' ), $args[0] ) );
+ /* translators: name of a cron job */
+ WP_CLI::error( sprintf( __( 'There is no cron named %s.', 'jetpack' ), $args[0] ) );
}
$scheduler->deactivate_cron( $args[0] );
+ /* translators: name of a cron job */
WP_CLI::success( sprintf( __( 'The cron named `%s` was removed from the schedule.', 'jetpack' ), $args[0] ) );
}
}
diff --git a/plugins/jetpack/modules/videopress/class.videopress-edit-attachment.php b/plugins/jetpack/modules/videopress/class.videopress-edit-attachment.php
index ce4688b0..64b38cbd 100644
--- a/plugins/jetpack/modules/videopress/class.videopress-edit-attachment.php
+++ b/plugins/jetpack/modules/videopress/class.videopress-edit-attachment.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Connection\Client;
@@ -39,15 +39,17 @@ class VideoPress_Edit_Attachment {
}
/**
- * @param string $post_type
- * @param object $post
+ * Add VideoPress meta box.
+ *
+ * @param string $post_type Post type.
+ * @param object $post Post object.
*/
public function configure_meta_boxes( $post_type = 'unknown', $post = null ) {
- if ( null == $post ) {
+ if ( null === $post ) {
$post = (object) array( 'ID' => 0 );
}
- if ( 'attachment' != $post_type ) {
+ if ( 'attachment' !== $post_type ) {
return;
}
@@ -60,17 +62,17 @@ class VideoPress_Edit_Attachment {
}
/**
- * @param array $post
- * @param array|null $attachment
+ * Filter attachment fields data to save.
*
- * Disable phpcs rule for nonce verification since it's already done by Core.
- * @phpcs:disable WordPress.Security.NonceVerification
+ * @param array $post Post data.
+ * @param array|null $attachment Attachment metadata.
*
* @return array
*/
public function save_fields( $post, $attachment = null ) {
+ // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verification already done by core.
if ( null === $attachment && isset( $_POST['attachment'] ) ) {
- $attachment = $_POST['attachment'];
+ $attachment = filter_var( wp_unslash( $_POST['attachment'] ) );
}
if ( ! isset( $attachment['is_videopress_attachment'] ) || 'yes' !== $attachment['is_videopress_attachment'] ) {
@@ -83,11 +85,12 @@ class VideoPress_Edit_Attachment {
return $post;
}
- $post_title = isset( $_POST['post_title'] ) ? $_POST['post_title'] : null;
- $post_excerpt = isset( $_POST['post_excerpt'] ) ? $_POST['post_excerpt'] : null;
- $rating = isset( $attachment['rating'] ) ? $attachment['rating'] : null;
- $display_embed = isset( $attachment['display_embed'] ) ? $attachment['display_embed'] : 0;
- $allow_download = isset( $attachment['allow_download'] ) ? $attachment['allow_download'] : 0;
+ $post_title = isset( $_POST['post_title'] ) ? sanitize_text_field( wp_unslash( $_POST['post_title'] ) ) : null;
+ $post_excerpt = isset( $_POST['post_excerpt'] ) ? sanitize_textarea_field( wp_unslash( $_POST['post_excerpt'] ) ) : null;
+ $rating = isset( $attachment['rating'] ) ? $attachment['rating'] : null;
+ $display_embed = isset( $attachment['display_embed'] ) ? $attachment['display_embed'] : 0;
+ $allow_download = isset( $attachment['allow_download'] ) ? $attachment['allow_download'] : 0;
+ $privacy_setting = isset( $attachment['privacy_setting'] ) ? $attachment['privacy_setting'] : VIDEOPRESS_PRIVACY::SITE_DEFAULT;
$result = Videopress_Attachment_Metadata::persist_metadata(
$post['ID'],
@@ -97,7 +100,8 @@ class VideoPress_Edit_Attachment {
$post_excerpt,
$rating,
$this->normalize_checkbox_value( $display_embed ),
- $this->normalize_checkbox_value( $allow_download )
+ $this->normalize_checkbox_value( $allow_download ),
+ $privacy_setting
);
if ( is_wp_error( $result ) ) {
@@ -106,6 +110,7 @@ class VideoPress_Edit_Attachment {
}
return $post;
+ // phpcs:enable WordPress.Security.NonceVerification.Missing
}
/**
@@ -122,7 +127,7 @@ class VideoPress_Edit_Attachment {
/**
* Get the upload api path.
*
- * @param string $guid
+ * @param string $guid The guid of the video.
* @return string
*/
public function make_video_api_path( $guid ) {
@@ -134,12 +139,11 @@ class VideoPress_Edit_Attachment {
);
}
-
/**
* Creates an array of video fields to edit based on transcoded videos.
*
- * @param array $fields video fields of interest
- * @param stdClass $post post object
+ * @param array $fields video fields of interest.
+ * @param stdClass $post Post object.
* @return array modified version of video fields for administrative interface display
*/
public function fields_to_edit( $fields, $post ) {
@@ -210,11 +214,19 @@ class VideoPress_Edit_Attachment {
'html' => $this->display_rating( $info ),
);
+ $fields['privacy_setting'] = array(
+ 'label' => _x( 'Privacy Setting', 'A header for the video privacy setting area.', 'jetpack' ),
+ 'input' => 'html',
+ 'html' => $this->display_privacy_setting( $info ),
+ );
+
return $fields;
}
/**
- * @param stdClass $post
+ * Meta box output.
+ *
+ * @param stdClass $post Post object.
*/
public function videopress_information_box( $post ) {
$post_id = absint( $post->ID );
@@ -260,7 +272,7 @@ class VideoPress_Edit_Attachment {
</div>
HTML;
- echo $html;
+ echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Variables built above.
}
/**
@@ -285,8 +297,8 @@ HTML;
/**
* Build HTML to display a form checkbox for embedcode display preference
*
- * @param object $info database row from the videos table
- * @return string input element of type checkbox set to checked state based on stored embed preference
+ * @param object $info Database row from the videos table.
+ * @return string Input element of type checkbox set to checked state based on stored embed preference.
*/
protected function display_embed_choice( $info ) {
return $this->create_checkbox_for_option(
@@ -308,15 +320,46 @@ HTML;
"attachments-{$info->post_id}-allowdownload",
"attachments[{$info->post_id}][allow_download]",
__( 'Display download option and allow viewers to download this video', 'jetpack' ),
- $info->allow_download
+ isset( $info->allow_download ) && $info->allow_download
+ );
+ }
+
+ /**
+ * Build HTML to display a form input radio button for video ratings
+ *
+ * @param object $info Database row from the videos table.
+ *
+ * @return string Input Elements of type radio with existing stored value selected.
+ */
+ protected function display_privacy_setting( $info ) {
+ $privacy_settings = array(
+ VIDEOPRESS_PRIVACY::SITE_DEFAULT => __( 'Site Default', 'jetpack' ),
+ VIDEOPRESS_PRIVACY::IS_PUBLIC => __( 'Public', 'jetpack' ),
+ VIDEOPRESS_PRIVACY::IS_PRIVATE => __( 'Private', 'jetpack' ),
);
+
+ $displayed_privacy_setting = intval( isset( $info->privacy_setting ) ? $info->privacy_setting : VIDEOPRESS_PRIVACY::SITE_DEFAULT );
+
+ $out = "<select name='attachments[{$info->post_id}][privacy_setting]'>";
+ foreach ( $privacy_settings as $r => $label ) {
+ $out .= "<option value=\"$r\"";
+ if ( intval( $r ) === $displayed_privacy_setting ) {
+ $out .= ' selected';
+ }
+
+ $out .= ">$label</option>";
+ }
+
+ $out .= '</select>';
+
+ return $out;
}
/**
* Build HTML to display a form input radio button for video ratings
*
- * @param object $info database row from the videos table
- * @return string input elements of type radio with existing stored value selected
+ * @param object $info Database row from the videos table.
+ * @return string Input elements of type radio with existing stored value selected.
*/
protected function display_rating( $info ) {
$out = '';
diff --git a/plugins/jetpack/modules/videopress/class.videopress-gutenberg.php b/plugins/jetpack/modules/videopress/class.videopress-gutenberg.php
index 19a29699..34aa1b60 100644
--- a/plugins/jetpack/modules/videopress/class.videopress-gutenberg.php
+++ b/plugins/jetpack/modules/videopress/class.videopress-gutenberg.php
@@ -35,6 +35,7 @@ class VideoPress_Gutenberg {
add_action( 'init', array( $this, 'register_video_block_with_videopress' ) );
add_action( 'jetpack_register_gutenberg_extensions', array( $this, 'set_extension_availability' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'override_video_upload' ) );
+ add_action( 'enqueue_block_editor_assets', array( $this, 'add_resumable_upload_support' ) );
}
/**
@@ -69,58 +70,30 @@ class VideoPress_Gutenberg {
* unavailable (key `unavailable_reason`)
*/
public function check_videopress_availability() {
- if (
- defined( 'IS_WPCOM' ) && IS_WPCOM &&
- function_exists( 'require_lib' )
- ) {
- require_lib( 'wpforteams' );
-
- if ( WPForTeams\Workspace\is_part_of_active_workspace( self::get_blog_id() ) ) {
- return array( 'available' => true );
- }
+ if ( ! Jetpack_Plan::supports( 'videopress' ) ) {
+ return array(
+ 'available' => false,
+ 'unavailable_reason' => 'missing_plan',
+ );
}
- // It is available on Simple Sites having the appropriate a plan.
- if (
- defined( 'IS_WPCOM' ) && IS_WPCOM
- && method_exists( 'Store_Product_List', 'get_site_specific_features_data' )
- ) {
- $features = Store_Product_List::get_site_specific_features_data();
- if ( in_array( 'videopress', $features['active'], true ) ) {
- return array( 'available' => true );
+ if ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) {
+ if ( Jetpack::is_connection_ready() ) {
+ if ( ! Jetpack::is_module_active( 'videopress' ) ) {
+ return array(
+ 'available' => false,
+ 'unavailable_reason' => 'missing_module',
+ );
+ }
} else {
return array(
'available' => false,
- 'unavailable_reason' => 'missing_plan',
+ 'unavailable_reason' => 'unknown',
);
}
}
- // It is available on Jetpack Sites having the module active.
- if (
- method_exists( 'Jetpack', 'is_connection_ready' ) && Jetpack::is_connection_ready()
- && method_exists( 'Jetpack', 'is_module_active' )
- && method_exists( 'Jetpack_Plan', 'supports' )
- ) {
- if ( Jetpack::is_module_active( 'videopress' ) ) {
- return array( 'available' => true );
- } elseif ( ! Jetpack_Plan::supports( 'videopress' ) ) {
- return array(
- 'available' => false,
- 'unavailable_reason' => 'missing_plan',
- );
- } else {
- return array(
- 'available' => false,
- 'unavailable_reason' => 'missing_module',
- );
- }
- }
-
- return array(
- 'available' => false,
- 'unavailable_reason' => 'unknown',
- );
+ return array( 'available' => true );
}
/**
@@ -192,6 +165,19 @@ class VideoPress_Gutenberg {
}
/**
+ * Temporary method to enable resumable uploads for testing by Automatticians
+ */
+ public function add_resumable_upload_support() {
+ wp_enqueue_script(
+ 'videopress-add-resumable-upload-support',
+ plugins_url( 'js/videopress-add-resumable-upload-support.js', __FILE__ ),
+ null,
+ '1',
+ false
+ );
+ }
+
+ /**
* Replaces the video uploaded in the block editor.
*
* Enqueues a script that registers an API fetch middleware replacing the video uploads in Gutenberg so they are
@@ -213,6 +199,17 @@ class VideoPress_Gutenberg {
JETPACK__VERSION,
false
);
+
+ wp_enqueue_script(
+ 'jetpack-videopress-gutenberg-playback-jwt',
+ Assets::get_file_url_for_environment(
+ 'modules/videopress/js/videopress-token-bridge.js',
+ 'modules/videopress/js/videopress-token-bridge.js'
+ ),
+ array(),
+ JETPACK__VERSION,
+ false
+ );
}
}
diff --git a/plugins/jetpack/modules/videopress/class.videopress-options.php b/plugins/jetpack/modules/videopress/class.videopress-options.php
index b8049e37..e6e71e60 100644
--- a/plugins/jetpack/modules/videopress/class.videopress-options.php
+++ b/plugins/jetpack/modules/videopress/class.videopress-options.php
@@ -1,15 +1,33 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName
+/**
+ * VideoPress Options
+ *
+ * @package automattic/jetpack
+ */
+/**
+ * VideoPress Options class.
+ */
class VideoPress_Options {
- /** @var string */
+ /**
+ * Option name.
+ *
+ * @var string $option_name The 'videopress' option name
+ */
public static $option_name = 'videopress';
- /** @var array */
+ /**
+ * VideoPress Options.
+ *
+ * @var array $options An array of associated VideoPress options (default empty)
+ */
protected static $options = array();
/**
* Get VideoPress options
+ *
+ * @return array An array of VideoPress options.
*/
public static function get_options() {
// Make sure we only get options from the database and services once per connection.
@@ -30,7 +48,7 @@ class VideoPress_Options {
// associated shadow blog id, if videopress is enabled.
self::$options['shadow_blog_id'] = 0;
- // Use the Jetpack ID for the shadow blog ID if we have a plan that supports VideoPress
+ // Use the Jetpack ID for the shadow blog ID if we have a plan that supports VideoPress.
if ( Jetpack_Plan::supports( 'videopress' ) ) {
self::$options['shadow_blog_id'] = Jetpack_Options::get_option( 'id' );
}
@@ -40,6 +58,8 @@ class VideoPress_Options {
/**
* Update VideoPress options
+ *
+ * @param mixed $options VideoPress options.
*/
public static function update_options( $options ) {
Jetpack_Options::update_option( self::$option_name, $options );
diff --git a/plugins/jetpack/modules/videopress/class.videopress-player.php b/plugins/jetpack/modules/videopress/class.videopress-player.php
index 2640e19a..27532d07 100644
--- a/plugins/jetpack/modules/videopress/class.videopress-player.php
+++ b/plugins/jetpack/modules/videopress/class.videopress-player.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* VideoPress playback module markup generator.
*
@@ -40,6 +40,8 @@ class VideoPress_Player {
/**
* Array of video GUIDs shown and their counts,
* moved from the old VideoPress class.
+ *
+ * @var array
*/
public static $shown = array();
@@ -47,9 +49,9 @@ class VideoPress_Player {
* Initiate a player object based on shortcode values and possible blog-level option overrides
*
* @since 1.3
- * @var string $guid VideoPress unique identifier
- * @var int $maxwidth maximum desired width of the video player if specified
- * @var array $options player customizations
+ * @param string $guid VideoPress unique identifier.
+ * @param int $maxwidth Maximum desired width of the video player if specified.
+ * @param array $options Player customizations.
*/
public function __construct( $guid, $maxwidth = 0, $options = array() ) {
if ( empty( self::$shown[ $guid ] ) ) {
@@ -116,22 +118,22 @@ class VideoPress_Player {
unset( $expires_diff );
}
- wp_cache_set( $cache_key, serialize( $this->video ), 'video', $expire );
+ wp_cache_set( $cache_key, serialize( $this->video ), 'video', $expire ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
unset( $expire );
}
} else {
- $this->video = unserialize( $cached_video );
+ $this->video = unserialize( $cached_video ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize -- Make sure to unserialize as VideoPress_Video class.
}
unset( $cache_key );
unset( $cached_video );
}
/**
- * Wrap output in a VideoPress player container
+ * Wrap output in a VideoPress player container.
*
* @since 1.3
- * @var string $content HTML string
- * @return string HTML string or blank string if nothing to wrap
+ * @param string $content HTML string.
+ * @return string HTML string or blank string if nothing to wrap.
*/
private function html_wrapper( $content ) {
if ( empty( $content ) ) {
@@ -149,7 +151,7 @@ class VideoPress_Player {
* @since 1.3
* @return string HTML string or empty string if error
*/
- public function asXML() {
+ public function as_xml() {
if ( empty( $this->video ) || is_wp_error( $this->video ) ) {
return '';
}
@@ -170,7 +172,7 @@ class VideoPress_Player {
* @since 1.3
* @return string HTML markup string or empty string if no video property found
*/
- public function asHTML() {
+ public function as_html() {
if ( empty( $this->video ) ) {
$content = '';
@@ -202,8 +204,8 @@ class VideoPress_Player {
* Display an error message to users capable of doing something about the error
*
* @since 1.3
- * @uses current_user_can() to test if current user has edit_posts capability
- * @var WP_Error $error WordPress error
+ * @uses current_user_can() to test if current user has edit_posts capability.
+ * @param WP_Error $error WordPress error.
* @return string HTML string
*/
private function error_message( $error ) {
@@ -211,7 +213,8 @@ class VideoPress_Player {
return '';
}
- $html = '<div class="videopress-error" style="background-color:rgb(255,0,0);color:rgb(255,255,255);font-family:font-family:\'Helvetica Neue\',Arial,Helvetica,\'Nimbus Sans L\',sans-serif;font-size:140%;min-height:10em;padding-top:1.5em;padding-bottom:1.5em">';
+ $html = '<div class="videopress-error" style="background-color:rgb(255,0,0);color:rgb(255,255,255);font-family:font-family:\'Helvetica Neue\',Arial,Helvetica,\'Nimbus Sans L\',sans-serif;font-size:140%;min-height:10em;padding-top:1.5em;padding-bottom:1.5em">';
+ /* translators: %s is 'VideoPress' */
$html .= '<h1 style="font-size:180%;font-style:bold;line-height:130%;text-decoration:underline">' . esc_html( sprintf( __( '%s Error', 'jetpack' ), 'VideoPress' ) ) . '</h1>';
foreach ( $error->get_error_messages() as $message ) {
$html .= $message;
@@ -273,7 +276,7 @@ class VideoPress_Player {
$html .= '</select>';
/**
- * todo: numdays variance by month
+ * Todo: numdays variance by month.
*/
$html .= '<select name="day" style="' . $inputs_style . '">';
for ( $i = 1; $i < 32; $i++ ) {
@@ -287,7 +290,7 @@ class VideoPress_Player {
* Default to 13
*/
$html .= '<select name="year" style="' . $inputs_style . '">';
- $start_year = date( 'Y' ) - 2;
+ $start_year = gmdate( 'Y' ) - 2;
$default_year = $start_year - 11;
$end_year = $start_year - 128;
for ( $year = $start_year; $year > $end_year; $year-- ) {
@@ -359,6 +362,7 @@ class VideoPress_Player {
}
$html .= '" src="' . $thumbnail . '" width="' . $this->video->calculated_width . '" height="' . $this->video->calculated_height . '" /></div>';
if ( isset( $this->options['freedom'] ) && $this->options['freedom'] === true ) {
+ /* translators: %s url to the gnu.org website */
$html .= '<p class="robots-nocontent">' . sprintf( __( 'You do not have sufficient <a rel="nofollow noopener noreferrer" href="%s" target="_blank">freedom levels</a> to view this video. Support free software and upgrade.', 'jetpack' ), 'https://www.gnu.org/philosophy/free-sw.html' ) . '</p>';
} elseif ( isset( $this->video->title ) ) {
$html .= '<p>' . esc_html( $this->video->title ) . '</p>';
@@ -445,6 +449,7 @@ class VideoPress_Player {
}
$html .= '<img class="videopress-poster" alt="';
if ( ! empty( $this->video->title ) ) {
+ /* translators: %s is the video title */
$html .= esc_attr( $this->video->title ) . '" title="' . esc_attr( sprintf( _x( 'Watch: %s', 'watch a video title', 'jetpack' ), $this->video->title ) );
}
$html .= '" src="' . esc_url( $this->video->poster_frame_uri, array( 'http', 'https' ) ) . '" width="' . $width . '" height="' . $height . '" />' . PHP_EOL;
@@ -495,16 +500,16 @@ class VideoPress_Player {
unset( $locale );
$guid = $this->video->guid;
- $guid_js = json_encode( $guid );
+ $guid_js = wp_json_encode( $guid );
$html .= '<script type="text/javascript">' . PHP_EOL;
$html .= 'jQuery(document).ready(function() {';
- $html .= 'if ( !jQuery.VideoPress.data[' . json_encode( $guid ) . '] ) { jQuery.VideoPress.data[' . json_encode( $guid ) . '] = new Array(); }' . PHP_EOL;
- $html .= 'jQuery.VideoPress.data[' . json_encode( $guid ) . '][' . self::$shown[ $guid ] . ']=' . json_encode( $data ) . ';' . PHP_EOL;
+ $html .= 'if ( !jQuery.VideoPress.data[' . wp_json_encode( $guid ) . '] ) { jQuery.VideoPress.data[' . wp_json_encode( $guid ) . '] = new Array(); }' . PHP_EOL;
+ $html .= 'jQuery.VideoPress.data[' . wp_json_encode( $guid ) . '][' . self::$shown[ $guid ] . ']=' . wp_json_encode( $data ) . ';' . PHP_EOL;
unset( $data );
- $jq_container = json_encode( '#' . $this->video_container_id );
- $jq_placeholder = json_encode( '#' . $video_placeholder_id );
+ $jq_container = wp_json_encode( '#' . $this->video_container_id );
+ $jq_placeholder = wp_json_encode( '#' . $video_placeholder_id );
$player_config = "{width:{$width},height:{$height},";
if ( isset( $this->options['freedom'] ) && $this->options['freedom'] === true ) {
$player_config .= 'freedom:"true",';
@@ -516,15 +521,17 @@ class VideoPress_Player {
if ( $age_gate_required ) {
$html .= 'if ( jQuery.VideoPress.support.flash() ) {' . PHP_EOL;
/**
+ * Insert alternative content for Flash players.
+ *
* @link https://github.com/swfobject/swfobject/wiki/SWFObject-API#swfobjectembedswfswfurlstr-replaceelemidstr-widthstr-heightstr-swfversionstr-xiswfurlstr-flashvarsobj-parobj-attobj-callbackfn
*/
$html .= 'swfobject.embedSWF(' . implode(
',',
array(
'jQuery.VideoPress.video.flash.player_uri',
- json_encode( $this->video_container_id ),
- json_encode( $width ),
- json_encode( $height ),
+ wp_json_encode( $this->video_container_id ),
+ wp_json_encode( $width ),
+ wp_json_encode( $height ),
'jQuery.VideoPress.video.flash.min_version',
'jQuery.VideoPress.video.flash.expressinstall', // attempt to upgrade the Flash player if less than min_version. requires a 310x137 container or larger but we will always try to include
'{guid:' . $guid_js . '}', // FlashVars
@@ -535,9 +542,9 @@ class VideoPress_Player {
) . ');';
$html .= '} else {' . PHP_EOL;
$html .= "if ( jQuery.VideoPress.video.prepare({$guid_js},{$player_config}," . self::$shown[ $guid ] . ') ) {' . PHP_EOL;
- $html .= 'if ( jQuery(' . $jq_container . ').data( "player" ) === "flash" ){jQuery.VideoPress.video.play(jQuery(' . json_encode( '#' . $this->video_container_id ) . '));}else{';
- $html .= 'jQuery(' . $jq_placeholder . ').html(' . json_encode( $this->html_age_date() ) . ');' . PHP_EOL;
- $html .= 'jQuery(' . json_encode( '#' . $video_placeholder_id . ' input[type=submit]' ) . ').one("click", function(event){jQuery.VideoPress.requirements.isSufficientAge(jQuery(' . $jq_container . '),' . absint( $this->video->age_rating ) . ')});' . PHP_EOL;
+ $html .= 'if ( jQuery(' . $jq_container . ').data( "player" ) === "flash" ){jQuery.VideoPress.video.play(jQuery(' . wp_json_encode( '#' . $this->video_container_id ) . '));}else{';
+ $html .= 'jQuery(' . $jq_placeholder . ').html(' . wp_json_encode( $this->html_age_date() ) . ');' . PHP_EOL;
+ $html .= 'jQuery(' . wp_json_encode( '#' . $video_placeholder_id . ' input[type=submit]' ) . ').one("click", function(event){jQuery.VideoPress.requirements.isSufficientAge(jQuery(' . $jq_container . '),' . absint( $this->video->age_rating ) . ')});' . PHP_EOL;
$html .= '}}}' . PHP_EOL;
} else {
$html .= "if ( jQuery.VideoPress.video.prepare({$guid_js}, {$player_config}," . self::$shown[ $guid ] . ') ) {' . PHP_EOL;
@@ -590,16 +597,20 @@ class VideoPress_Player {
}
unset( $vid_type );
}
+ /* translators: %s video title or generic 'this video' string */
$html .= '<noscript><p>' . sprintf( _x( 'JavaScript required to play %s.', 'Play as in playback or view a movie', 'jetpack' ), $noun ) . '</p></noscript>';
return $html;
}
- function html5_dynamic_next() {
+ /**
+ * Output for the non-legacy HTML5 player.
+ */
+ public function html5_dynamic_next() {
$video_container_id = 'v-' . $this->video->guid;
// Must not use iframes for IE11 due to a fullscreen bug
- if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && stristr( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0' ) ) {
+ if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && stristr( sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ), 'Trident/7.0; rv:11.0' ) ) {
$iframe_embed = false;
} else {
@@ -638,16 +649,21 @@ class VideoPress_Player {
}
break;
case 'autoplay':
- $option = 'autoPlay';
+ $option = 'autoPlay'; // Fall-through ok.
case 'hd':
case 'loop':
case 'permalink':
case 'cover':
- if ( in_array( $value, array( 1, 'true' ) ) ) {
+ case 'muted':
+ case 'controls':
+ case 'playsinline':
+ case 'useAverageColor':
+ if ( in_array( $value, array( true, 1, 'true' ), true ) ) {
$videopress_options[ $option ] = true;
- } elseif ( in_array( $value, array( 0, 'false' ) ) ) {
+ } elseif ( in_array( $value, array( false, 0, 'false' ), true ) ) {
$videopress_options[ $option ] = false;
}
+ // phpcs:enable
break;
case 'defaultlangcode':
$option = 'defaultLangCode';
@@ -662,7 +678,7 @@ class VideoPress_Player {
$iframe_url = "https://videopress.com/embed/{$this->video->guid}";
foreach ( $videopress_options as $option => $value ) {
- if ( ! in_array( $option, array( 'width', 'height' ) ) ) {
+ if ( ! in_array( $option, array( 'width', 'height' ), true ) ) {
// add_query_arg ignores false as a value, so replacing it with 0
$iframe_url = add_query_arg( $option, ( false === $value ) ? 0 : $value, $iframe_url );
@@ -670,15 +686,17 @@ class VideoPress_Player {
}
$js_url = 'https://s0.wp.com/wp-content/plugins/video/assets/js/next/videopress-iframe.js';
-
- return "<iframe width='" . esc_attr( $videopress_options['width'] )
+ // phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript
+ return "<iframe title='" . __( 'VideoPress Video Player', 'jetpack' )
+ . "' aria-label='" . __( 'VideoPress Video Player', 'jetpack' )
+ . "' width='" . esc_attr( $videopress_options['width'] )
. "' height='" . esc_attr( $videopress_options['height'] )
. "' src='" . esc_attr( $iframe_url )
. "' frameborder='0' allowfullscreen></iframe>"
. "<script src='" . esc_attr( $js_url ) . "'></script>";
} else {
- $videopress_options = json_encode( $videopress_options );
+ $videopress_options = wp_json_encode( $videopress_options );
$js_url = 'https://s0.wp.com/wp-content/plugins/video/assets/js/next/videopress.js';
return "<div id='{$video_container_id}'></div>
@@ -686,6 +704,7 @@ class VideoPress_Player {
<script>
videopress('{$this->video->guid}', document.querySelector('#{$video_container_id}'), {$videopress_options});
</script>";
+ // phpcs:enable WordPress.WP.EnqueuedResources.NonEnqueuedScript
}
}
@@ -698,7 +717,7 @@ class VideoPress_Player {
* @link https://helpx.adobe.com/flash/kb/control-access-scripts-host-web.html allowscriptaccess
* @link https://www.adobe.com/devnet/flashplayer/articles/full_screen_mode.html full screen mode
* @link https://help.adobe.com/en_US/as3/dev/WS1EFE2EDA-026D-4d14-864E-79DFD56F87C6.html allownetworking
- * @param array $flash_params Flash parameters expressed in key-value form
+ * @param array $flash_params Flash parameters expressed in key-value form.
* @return array validated Flash parameters
*/
public static function esc_flash_params( $flash_params ) {
@@ -731,10 +750,10 @@ class VideoPress_Player {
continue;
}
$param = strtolower( $param );
- if ( in_array( $param, $allowed_params_keys ) ) {
+ if ( in_array( $param, $allowed_params_keys, true ) ) {
if ( isset( $allowed_params[ $param ] ) && is_array( $allowed_params[ $param ] ) ) {
$value = strtolower( $value );
- if ( in_array( $value, $allowed_params[ $param ] ) ) {
+ if ( in_array( $value, $allowed_params[ $param ], true ) ) {
$filtered_params[ $param ] = $value;
}
} else {
@@ -854,6 +873,7 @@ class VideoPress_Player {
foreach ( $this->get_flash_parameters() as $attribute => $value ) {
$flash_params .= '<param name="' . esc_attr( $attribute ) . '" value="' . esc_attr( $value ) . '" />';
}
+ /* translators: %s url to the Adobe Flash Player website */
$flash_help = sprintf( __( 'This video requires <a rel="nofollow noopener noreferrer" href="%s" target="_blank">Adobe Flash</a> for playback.', 'jetpack' ), 'https://get.adobe.com/flashplayer/' );
$flash_player_url = esc_url( $this->video->players->swf->url, array( 'http', 'https' ) );
$description = '';
diff --git a/plugins/jetpack/modules/videopress/class.videopress-scheduler.php b/plugins/jetpack/modules/videopress/class.videopress-scheduler.php
index bff33684..d8ac4610 100644
--- a/plugins/jetpack/modules/videopress/class.videopress-scheduler.php
+++ b/plugins/jetpack/modules/videopress/class.videopress-scheduler.php
@@ -1,8 +1,12 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName
/**
- * VideoPress playback module markup generator.
+ * VideoPress cron scheduler.
*
- * @since 1.3
+ * @package automattic/jetpack
+ */
+
+/**
+ * VideoPress Cron Scheduler.
*/
class VideoPress_Scheduler {
@@ -12,7 +16,9 @@ class VideoPress_Scheduler {
const CLEANUP_CRON_METHOD = 'videopress_cleanup_media_library';
/**
- * @var VideoPress_Scheduler
+ * Singleton instance.
+ *
+ * @var VideoPress_Scheduler $instance A VideoPress_Scheduler singleton instance (default null)
**/
private static $instance = null;
@@ -22,13 +28,13 @@ class VideoPress_Scheduler {
* @var array
*/
protected $crons = array(
+ // phpcs:ignore Squiz.PHP.CommentedOutCode.Found
// 'cleanup' => array(
// 'method' => self::CLEANUP_CRON_METHOD,
// 'interval' => 'minutes_30',
// ),
);
-
/**
* Private VideoPress_Scheduler constructor.
*
@@ -53,7 +59,7 @@ class VideoPress_Scheduler {
* @return VideoPress_Scheduler
*/
public static function init() {
- if ( is_null( self::$instance ) ) {
+ if ( self::$instance === null ) {
self::$instance = new VideoPress_Scheduler();
}
@@ -83,7 +89,7 @@ class VideoPress_Scheduler {
/**
* Activate a single cron
*
- * @param string $cron_name
+ * @param string $cron_name The name of the cron to activate.
*
* @return bool
*/
@@ -117,7 +123,7 @@ class VideoPress_Scheduler {
/**
* Only activate the crons if it is Jetpack that was activated.
*
- * @param string $plugin_file_name
+ * @param string $plugin_file_name The name of the plugin that was activated.
*/
public function activate_crons_on_jetpack_activation( $plugin_file_name ) {
@@ -129,6 +135,8 @@ class VideoPress_Scheduler {
/**
* Deactivates any crons associated with the VideoPress module.
*
+ * @param string $cron_name Name of the cron to deactivate.
+ *
* @return bool
*/
public function deactivate_cron( $cron_name ) {
@@ -158,7 +166,7 @@ class VideoPress_Scheduler {
*
* If so, return when it will next run,
*
- * @param string $cron_name
+ * @param string $cron_name Cron job name.
*
* @return int|bool Timestamp of the next run time OR false.
*/
@@ -173,7 +181,7 @@ class VideoPress_Scheduler {
/**
* Check that the given cron job name is valid.
*
- * @param string $cron_name
+ * @param string $cron_name Cron job name.
*
* @return bool
*/
diff --git a/plugins/jetpack/modules/videopress/class.videopress-video.php b/plugins/jetpack/modules/videopress/class.videopress-video.php
index f12c5fba..26f14007 100644
--- a/plugins/jetpack/modules/videopress/class.videopress-video.php
+++ b/plugins/jetpack/modules/videopress/class.videopress-video.php
@@ -1,10 +1,15 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* VideoPress video object retrieved from VideoPress servers and parsed.
*
* @since 1.3
*/
class VideoPress_Video {
+ /**
+ * VideoPress version.
+ *
+ * @var int
+ */
public $version = 3;
/**
@@ -13,7 +18,7 @@ class VideoPress_Video {
* @var string
* @since 1.3
*/
- const manifest_version = '1.5';
+ const manifest_version = '1.5'; // phpcs:ignore Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
/**
* Expiration of the video expressed in Unix time
@@ -172,8 +177,8 @@ class VideoPress_Video {
* Request video information from VideoPress servers and process the response.
*
* @since 1.3
- * @var string $guid VideoPress unique identifier
- * @var int $maxwidth maximum requested video width. final width and height are calculated on VideoPress servers based on the aspect ratio of the original video upload.
+ * @param string $guid VideoPress unique identifier.
+ * @param int $maxwidth maximum requested video width. final width and height are calculated on VideoPress servers based on the aspect ratio of the original video upload.
*/
public function __construct( $guid, $maxwidth = 640 ) {
$this->guid = $guid;
@@ -278,10 +283,10 @@ class VideoPress_Video {
}
/**
- * Convert an Expires HTTP header value into Unix time for use in WP Cache
+ * Convert an Expires HTTP header value into Unix time for use in WP Cache.
*
* @since 1.3
- * @var string $expires_header
+ * @param string $expires_header Expires header value.
* @return int|bool Unix time or false
*/
public static function calculate_expiration( $expires_header ) {
@@ -289,19 +294,9 @@ class VideoPress_Video {
return false;
}
- if (
- class_exists( 'DateTimeZone' )
- && method_exists( 'DateTime', 'createFromFormat' )
- ) {
- $expires_date = DateTime::createFromFormat( 'D, d M Y H:i:s T', $expires_header, new DateTimeZone( 'UTC' ) );
- if ( $expires_date instanceof DateTime ) {
- return date_format( $expires_date, 'U' );
- }
- } else {
- $expires_array = strptime( $expires_header, '%a, %d %b %Y %H:%M:%S %Z' );
- if ( is_array( $expires_array ) && isset( $expires_array['tm_hour'] ) && isset( $expires_array['tm_min'] ) && isset( $expires_array['tm_sec'] ) && isset( $expires_array['tm_mon'] ) && isset( $expires_array['tm_mday'] ) && isset( $expires_array['tm_year'] ) ) {
- return gmmktime( $expires_array['tm_hour'], $expires_array['tm_min'], $expires_array['tm_sec'], 1 + $expires_array['tm_mon'], $expires_array['tm_mday'], 1900 + $expires_array['tm_year'] );
- }
+ $expires_date = DateTime::createFromFormat( 'D, d M Y H:i:s T', $expires_header, new DateTimeZone( 'UTC' ) );
+ if ( $expires_date instanceof DateTime ) {
+ return date_format( $expires_date, 'U' );
}
return false;
}
@@ -310,14 +305,13 @@ class VideoPress_Video {
* Extract the site's host domain for statistics and comparison against an allowed site list in the case of restricted embeds.
*
* @since 1.2
- * @param string $url absolute URL
- * @return bool|string host component of the URL, or false if none found
+ * @param string $url absolute URL.
+ * @return bool|string host component of the URL, or false if none found.
*/
public static function hostname( $url ) {
return wp_parse_url( esc_url_raw( $url ), PHP_URL_HOST );
}
-
/**
* Request data from WordPress.com for the given guid, maxwidth, and calculated blog hostname.
*
@@ -356,8 +350,10 @@ class VideoPress_Video {
} elseif ( $response_code === 400 ) {
return new WP_Error( 'bad_config', __( 'The VideoPress plugin could not communicate with the VideoPress servers. This error is most likely caused by a misconfigured plugin. Please reinstall or upgrade.', 'jetpack' ) );
} elseif ( $response_code === 403 ) {
+ /* translators: %s URL of site trying to embed a VideoPress video */
return new WP_Error( 'http_forbidden', '<p>' . sprintf( __( '<strong>%s</strong> is not an allowed embed site.', 'jetpack' ), esc_html( $domain ) ) . '</p><p>' . __( 'Publisher limits playback of video embeds.', 'jetpack' ) . '</p>' );
} elseif ( $response_code === 404 ) {
+ /* translators: %s VideoPress object identifier */
return new WP_Error( 'http_not_found', '<p>' . sprintf( __( 'No data found for VideoPress identifier: <strong>%s</strong>.', 'jetpack' ), $this->guid ) . '</p>' );
} elseif ( $response_code !== 200 || empty( $response_body ) ) {
return;
diff --git a/plugins/jetpack/modules/videopress/class.videopress-xmlrpc.php b/plugins/jetpack/modules/videopress/class.videopress-xmlrpc.php
index b5e508ef..8b6984c5 100644
--- a/plugins/jetpack/modules/videopress/class.videopress-xmlrpc.php
+++ b/plugins/jetpack/modules/videopress/class.videopress-xmlrpc.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* VideoPress playback module markup generator.
*
@@ -7,6 +7,8 @@
class VideoPress_XMLRPC {
/**
+ * Singleton VideoPress_XMLRPC instance.
+ *
* @var VideoPress_XMLRPC
**/
private static $instance = null;
@@ -33,7 +35,7 @@ class VideoPress_XMLRPC {
* @return VideoPress_XMLRPC
*/
public static function init() {
- if ( is_null( self::$instance ) ) {
+ if ( self::$instance === null ) {
self::$instance = new VideoPress_XMLRPC();
}
@@ -69,7 +71,7 @@ class VideoPress_XMLRPC {
* Note: This method technically handles the creation of multiple media objects, though
* in practice this is never done.
*
- * @param array $media
+ * @param array $media Media items being uploaded.
* @return array
*/
public function create_media_item( $media ) {
@@ -97,7 +99,9 @@ class VideoPress_XMLRPC {
}
/**
- * @param array $request
+ * Update VideoPress metadata for a media item.
+ *
+ * @param array $request Media item to update.
*
* @return bool
*/
@@ -109,7 +113,8 @@ class VideoPress_XMLRPC {
$format = $request['format'];
$info = $request['info'];
- if ( ! $attachment = get_post( $id ) ) {
+ $attachment = get_post( $id );
+ if ( ! $attachment ) {
return false;
}
@@ -154,7 +159,9 @@ class VideoPress_XMLRPC {
}
/**
- * @param array $request
+ * Update poster image for a VideoPress media item.
+ *
+ * @param array $request The media item to update.
* @return bool
*/
public function update_poster_image( $request ) {
@@ -163,7 +170,8 @@ class VideoPress_XMLRPC {
$post_id = $request['post_id'];
$poster = $request['poster'];
- if ( ! $attachment = get_post( $post_id ) ) {
+ $attachment = get_post( $post_id );
+ if ( ! $attachment ) {
return false;
}
diff --git a/plugins/jetpack/modules/videopress/css/editor-rtl.css b/plugins/jetpack/modules/videopress/css/editor-rtl.css
index 08beb376..05097545 100644
--- a/plugins/jetpack/modules/videopress/css/editor-rtl.css
+++ b/plugins/jetpack/modules/videopress/css/editor-rtl.css
@@ -1,60 +1,60 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
/* VideoPress Settings Modal style overrides */
.mce-videopress-field-guid,
.mce-videopress-field-freedom,
.mce-videopress-field-flashonly {
- display: none;
+ display: none;
}
.mce-videopress-checkbox .mce-checkbox {
- right: 120px !important;
- width: 100% !important; /* assigning a full width so the label area is clickable */
+ right: 120px !important;
+ width: 100% !important;
+ /* assigning a full width so the label area is clickable */
}
.mce-videopress-checkbox .mce-label {
- right: 150px !important;
+ right: 150px !important;
}
.mce-videopress-checkbox .mce-label-unit {
- position: absolute;
- right: 210px;
- top: 5px;
+ position: absolute;
+ right: 210px;
+ top: 5px;
}
.mce-videopress-checkbox i.mce-i-checkbox {
- background-color: #fff;
- color: #4f94d4;
+ background-color: #fff;
+ color: #4f94d4;
}
.mce-videopress-checkbox .mce-i-checkbox:before {
- display: inline-block;
- vertical-align: middle;
- width: 16px;
- font: 400 21px/1 dashicons;
- speak: none;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- margin: -3px -3px 0 0;
- content: "\f147";
+ display: inline-block;
+ vertical-align: middle;
+ width: 16px;
+ font: 400 21px/1 dashicons;
+ speak: none;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ margin: -3px -3px 0 0;
+ content: "\f147";
}
.mce-videopress-checkbox .mce-i-checkbox.mce-checked:before {
- content: "\f147";
+ content: "\f147";
}
div[class*=mce-videopress-field] input[type=number] {
- width: 70px !important;
- right: 120px !important;
+ width: 70px !important;
+ right: 120px !important;
}
.mce-videopress-field-w .mce-label,
.mce-videopress-field-at .mce-label {
- width: 115px !important;
- text-align: left;
+ width: 115px !important;
+ text-align: left;
}
.mce-videopress-field-unit {
- position: absolute;
- right: 210px;
- top: 5px;
+ position: absolute;
+ right: 210px;
+ top: 5px;
}
diff --git a/plugins/jetpack/modules/videopress/css/editor-rtl.min.css b/plugins/jetpack/modules/videopress/css/editor-rtl.min.css
index 4ca3dafd..5e0fa13a 100644
--- a/plugins/jetpack/modules/videopress/css/editor-rtl.min.css
+++ b/plugins/jetpack/modules/videopress/css/editor-rtl.min.css
@@ -1 +1 @@
-.mce-videopress-field-flashonly,.mce-videopress-field-freedom,.mce-videopress-field-guid{display:none}.mce-videopress-checkbox .mce-checkbox{right:120px!important;width:100%!important}.mce-videopress-checkbox .mce-label{right:150px!important}.mce-videopress-checkbox .mce-label-unit{position:absolute;right:210px;top:5px}.mce-videopress-checkbox i.mce-i-checkbox{background-color:#fff;color:#4f94d4}.mce-videopress-checkbox .mce-i-checkbox:before{display:inline-block;vertical-align:middle;width:16px;font:400 21px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:-3px -3px 0 0;content:"\f147"}.mce-videopress-checkbox .mce-i-checkbox.mce-checked:before{content:"\f147"}div[class*=mce-videopress-field] input[type=number]{width:70px!important;right:120px!important}.mce-videopress-field-at .mce-label,.mce-videopress-field-w .mce-label{width:115px!important;text-align:left}.mce-videopress-field-unit{position:absolute;right:210px;top:5px} \ No newline at end of file
+.mce-videopress-field-flashonly,.mce-videopress-field-freedom,.mce-videopress-field-guid{display:none}.mce-videopress-checkbox .mce-checkbox{right:120px!important;width:100%!important}.mce-videopress-checkbox .mce-label{right:150px!important}.mce-videopress-checkbox .mce-label-unit{position:absolute;right:210px;top:5px}.mce-videopress-checkbox i.mce-i-checkbox{background-color:#fff;color:#4f94d4}.mce-videopress-checkbox .mce-i-checkbox:before{speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:"\f147";display:inline-block;font:400 21px/1 dashicons;margin:-3px -3px 0 0;vertical-align:middle;width:16px}.mce-videopress-checkbox .mce-i-checkbox.mce-checked:before{content:"\f147"}div[class*=mce-videopress-field] input[type=number]{right:120px!important;width:70px!important}.mce-videopress-field-at .mce-label,.mce-videopress-field-w .mce-label{text-align:left;width:115px!important}.mce-videopress-field-unit{position:absolute;right:210px;top:5px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/videopress/css/editor.min.css b/plugins/jetpack/modules/videopress/css/editor.min.css
index a840ae60..74a4dab6 100644
--- a/plugins/jetpack/modules/videopress/css/editor.min.css
+++ b/plugins/jetpack/modules/videopress/css/editor.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-.mce-videopress-field-flashonly,.mce-videopress-field-freedom,.mce-videopress-field-guid{display:none}.mce-videopress-checkbox .mce-checkbox{left:120px!important;width:100%!important}.mce-videopress-checkbox .mce-label{left:150px!important}.mce-videopress-checkbox .mce-label-unit{position:absolute;left:210px;top:5px}.mce-videopress-checkbox i.mce-i-checkbox{background-color:#fff;color:#4f94d4}.mce-videopress-checkbox .mce-i-checkbox:before{display:inline-block;vertical-align:middle;width:16px;font:400 21px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:-3px 0 0 -3px;content:"\f147"}.mce-videopress-checkbox .mce-i-checkbox.mce-checked:before{content:"\f147"}div[class*=mce-videopress-field] input[type=number]{width:70px!important;left:120px!important}.mce-videopress-field-at .mce-label,.mce-videopress-field-w .mce-label{width:115px!important;text-align:right}.mce-videopress-field-unit{position:absolute;left:210px;top:5px} \ No newline at end of file
+.mce-videopress-field-flashonly,.mce-videopress-field-freedom,.mce-videopress-field-guid{display:none}.mce-videopress-checkbox .mce-checkbox{left:120px!important;width:100%!important}.mce-videopress-checkbox .mce-label{left:150px!important}.mce-videopress-checkbox .mce-label-unit{left:210px;position:absolute;top:5px}.mce-videopress-checkbox i.mce-i-checkbox{background-color:#fff;color:#4f94d4}.mce-videopress-checkbox .mce-i-checkbox:before{speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:"\f147";display:inline-block;font:400 21px/1 dashicons;margin:-3px 0 0 -3px;vertical-align:middle;width:16px}.mce-videopress-checkbox .mce-i-checkbox.mce-checked:before{content:"\f147"}div[class*=mce-videopress-field] input[type=number]{left:120px!important;width:70px!important}.mce-videopress-field-at .mce-label,.mce-videopress-field-w .mce-label{text-align:right;width:115px!important}.mce-videopress-field-unit{left:210px;position:absolute;top:5px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/videopress/css/videopress-editor-style-rtl.css b/plugins/jetpack/modules/videopress/css/videopress-editor-style-rtl.css
index c3af72cf..c83feae5 100644
--- a/plugins/jetpack/modules/videopress/css/videopress-editor-style-rtl.css
+++ b/plugins/jetpack/modules/videopress/css/videopress-editor-style-rtl.css
@@ -1,22 +1,23 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
/**
* VideoPress styles for Editor
*/
.videopress-editor-wrapper {
- position: relative;
- max-width: 100%;
- padding: 56.25% 0 0;
- height: 0;
- overflow: hidden;
+ position: relative;
+ max-width: 100%;
+ padding: 56.25% 0 0;
+ height: 0;
+ overflow: hidden;
}
+
.tmpl-videopress_iframe_next iframe {
- position: absolute;
- top: 0;
- right: 0;
- max-width: 100%;
- max-height: 100%;
+ position: absolute;
+ top: 0;
+ right: 0;
+ max-width: 100%;
+ max-height: 100%;
}
+
body.rtl .tmpl-videopress_iframe_next iframe {
- right: auto;
- left: 0;
-} \ No newline at end of file
+ right: auto;
+ left: 0;
+}
diff --git a/plugins/jetpack/modules/videopress/css/videopress-editor-style-rtl.min.css b/plugins/jetpack/modules/videopress/css/videopress-editor-style-rtl.min.css
index 53c667e8..381a6bb8 100644
--- a/plugins/jetpack/modules/videopress/css/videopress-editor-style-rtl.min.css
+++ b/plugins/jetpack/modules/videopress/css/videopress-editor-style-rtl.min.css
@@ -1 +1 @@
-.videopress-editor-wrapper{position:relative;max-width:100%;padding:56.25% 0 0;height:0;overflow:hidden}.tmpl-videopress_iframe_next iframe{position:absolute;top:0;right:0;max-width:100%;max-height:100%}body.rtl .tmpl-videopress_iframe_next iframe{right:auto;left:0} \ No newline at end of file
+.videopress-editor-wrapper{height:0;max-width:100%;overflow:hidden;padding:56.25% 0 0;position:relative}.tmpl-videopress_iframe_next iframe{max-height:100%;max-width:100%;position:absolute;right:0;top:0}body.rtl .tmpl-videopress_iframe_next iframe{left:0;right:auto} \ No newline at end of file
diff --git a/plugins/jetpack/modules/videopress/css/videopress-editor-style.min.css b/plugins/jetpack/modules/videopress/css/videopress-editor-style.min.css
index 546cfc5c..6fa1a781 100644
--- a/plugins/jetpack/modules/videopress/css/videopress-editor-style.min.css
+++ b/plugins/jetpack/modules/videopress/css/videopress-editor-style.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-.videopress-editor-wrapper{position:relative;max-width:100%;padding:56.25% 0 0;height:0;overflow:hidden}.tmpl-videopress_iframe_next iframe{position:absolute;top:0;left:0;max-width:100%;max-height:100%}body.rtl .tmpl-videopress_iframe_next iframe{left:auto;right:0} \ No newline at end of file
+.videopress-editor-wrapper{height:0;max-width:100%;overflow:hidden;padding:56.25% 0 0;position:relative}.tmpl-videopress_iframe_next iframe{left:0;max-height:100%;max-width:100%;position:absolute;top:0}body.rtl .tmpl-videopress_iframe_next iframe{left:auto;right:0} \ No newline at end of file
diff --git a/plugins/jetpack/modules/videopress/editor-media-view.php b/plugins/jetpack/modules/videopress/editor-media-view.php
index 9fffaafa..aced7c89 100644
--- a/plugins/jetpack/modules/videopress/editor-media-view.php
+++ b/plugins/jetpack/modules/videopress/editor-media-view.php
@@ -1,4 +1,9 @@
<?php
+/**
+ * VideoPress admin media-view functions.
+ *
+ * @package automattic/jetpack
+ */
use Automattic\Jetpack\Assets;
@@ -14,7 +19,12 @@ function videopress_handle_editor_view_js() {
add_action( 'admin_print_footer_scripts', 'videopress_editor_view_js_templates' );
- wp_enqueue_style( 'videopress-editor-ui', plugins_url( 'css/editor.css', __FILE__ ) );
+ wp_enqueue_style(
+ 'videopress-editor-ui',
+ plugins_url( 'css/editor.css', __FILE__ ),
+ array(),
+ Jetpack_VideoPress::VERSION
+ );
wp_enqueue_script(
'videopress-editor-view',
Assets::get_file_url_for_environment(
@@ -22,7 +32,7 @@ function videopress_handle_editor_view_js() {
'modules/videopress/js/editor-view.js'
),
array( 'wp-util', 'jquery' ),
- false,
+ Jetpack_VideoPress::VERSION,
true
);
wp_localize_script(
@@ -89,8 +99,9 @@ function videopress_editor_view_js_templates() {
* Media Grid:
* Filter out any videopress video posters that we've downloaded,
* so that they don't seem to display twice.
+ *
+ * @param array $args Query variables.
*/
-add_filter( 'ajax_query_attachments_args', 'videopress_ajax_query_attachments_args' );
function videopress_ajax_query_attachments_args( $args ) {
$meta_query = array(
array(
@@ -109,17 +120,19 @@ function videopress_ajax_query_attachments_args( $args ) {
return $args;
}
+add_filter( 'ajax_query_attachments_args', 'videopress_ajax_query_attachments_args' );
/**
* Media List:
- * Do the same as ^^ but for the list view.
+ * Do the same as `videopress_ajax_query_attachments_args()` but for the list view.
+ *
+ * @param array $query WP_Query instance.
*/
-add_action( 'pre_get_posts', 'videopress_media_list_table_query' );
function videopress_media_list_table_query( $query ) {
if (
! function_exists( 'get_current_screen' )
- || is_null( get_current_screen() )
+ || get_current_screen() === null
) {
return;
}
@@ -132,18 +145,21 @@ function videopress_media_list_table_query( $query ) {
),
);
- if ( $old_meta_query = $query->get( 'meta_query' ) ) {
+ $old_meta_query = $query->get( 'meta_query' );
+ if ( $old_meta_query ) {
$meta_query[] = $old_meta_query;
}
$query->set( 'meta_query', $meta_query );
}
}
+add_action( 'pre_get_posts', 'videopress_media_list_table_query' );
/**
* Make sure that any Video that has a VideoPress GUID passes that data back.
+ *
+ * @param WP_Post $post Attachment object.
*/
-add_filter( 'wp_prepare_attachment_for_js', 'videopress_prepare_attachment_for_js' );
function videopress_prepare_attachment_for_js( $post ) {
if ( 'video' === $post['type'] ) {
$guid = get_post_meta( $post['id'], 'videopress_guid' );
@@ -153,14 +169,15 @@ function videopress_prepare_attachment_for_js( $post ) {
}
return $post;
}
+add_filter( 'wp_prepare_attachment_for_js', 'videopress_prepare_attachment_for_js' );
/**
* Wherever the Media Modal is deployed, also deploy our overrides.
*/
-add_action( 'wp_enqueue_media', 'add_videopress_media_overrides' );
function add_videopress_media_overrides() {
add_action( 'admin_print_footer_scripts', 'videopress_override_media_templates', 11 );
}
+add_action( 'wp_enqueue_media', 'add_videopress_media_overrides' );
/**
* Our video overrides!
@@ -228,9 +245,12 @@ function videopress_override_media_templates() {
/**
* Properly inject VideoPress data into Core shortcodes, and
* generate videopress shortcodes for purely remote videos.
+ *
+ * @param string $html HTML markup for a media item sent to the editor.
+ * @param int $id Attachment ID.
+ * @param array $attachment Attachment metadata.
*/
-add_filter( 'media_send_to_editor', 'videopress_media_send_to_editor', 10, 3 );
-function videopress_media_send_to_editor( $html, $id, $attachment ) {
+function videopress_media_send_to_editor( $html, $id, $attachment ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$videopress_guid = get_post_meta( $id, 'videopress_guid', true );
if ( $videopress_guid && videopress_is_valid_guid( $videopress_guid ) ) {
if ( '[video ' === substr( $html, 0, 7 ) ) {
@@ -246,3 +266,4 @@ function videopress_media_send_to_editor( $html, $id, $attachment ) {
}
return $html;
}
+add_filter( 'media_send_to_editor', 'videopress_media_send_to_editor', 10, 3 );
diff --git a/plugins/jetpack/modules/videopress/js/gutenberg-video-upload.js b/plugins/jetpack/modules/videopress/js/gutenberg-video-upload.js
index dfd558be..8afd1f2a 100644
--- a/plugins/jetpack/modules/videopress/js/gutenberg-video-upload.js
+++ b/plugins/jetpack/modules/videopress/js/gutenberg-video-upload.js
@@ -80,7 +80,6 @@ wp.apiFetch.use( function ( options, next ) {
var path = options.path;
var method = options.method;
var body = options.body;
- var file = body ? body.get( 'file' ) : null;
// Override only requests to the WP REST API media endpoint uploading new videos.
if ( ! path || path.indexOf( '/wp/v2/media' ) === -1 ) {
@@ -89,6 +88,7 @@ wp.apiFetch.use( function ( options, next ) {
if ( ! method || 'post' !== method.toLowerCase() ) {
return next( options );
}
+ var file = body ? body.get( 'file' ) : null;
if ( ! file || file.type.indexOf( 'video/' ) !== 0 ) {
return next( options );
}
diff --git a/plugins/jetpack/modules/videopress/js/videopress-add-resumable-upload-support.js b/plugins/jetpack/modules/videopress/js/videopress-add-resumable-upload-support.js
new file mode 100644
index 00000000..16567f23
--- /dev/null
+++ b/plugins/jetpack/modules/videopress/js/videopress-add-resumable-upload-support.js
@@ -0,0 +1 @@
+window.videoPressResumableEnabled = true;
diff --git a/plugins/jetpack/modules/videopress/js/videopress-token-bridge.js b/plugins/jetpack/modules/videopress/js/videopress-token-bridge.js
new file mode 100644
index 00000000..75b763c0
--- /dev/null
+++ b/plugins/jetpack/modules/videopress/js/videopress-token-bridge.js
@@ -0,0 +1,54 @@
+( function () {
+ window.addEventListener( 'message', function ( event ) {
+ var allowed_origins = [ 'https://videopress.com', 'https://video.wordpress.com' ];
+ if ( -1 === allowed_origins.indexOf( event.origin ) ) {
+ return;
+ }
+
+ if ( event.data.event !== 'videopress_token_request' ) {
+ return;
+ }
+
+ if ( ! window.videopressAjax ) {
+ return;
+ }
+
+ var fetchData = {
+ action: 'videopress-get-playback-jwt',
+ guid: event.data.guid,
+ post_id: window.videopressAjax.post_id || 0,
+ };
+
+ fetch( window.videopressAjax.ajaxUrl, {
+ method: 'POST',
+ credentials: 'same-origin',
+ body: new URLSearchParams( fetchData ),
+ } )
+ .then( function ( response ) {
+ if ( response.ok ) {
+ return response.json();
+ }
+ throw Error( 'Response is not ok' );
+ } )
+ .then( function ( jsonResponse ) {
+ if ( !! jsonResponse.success && jsonResponse.data ) {
+ event.source.postMessage(
+ {
+ event: 'videopress_token_received',
+ guid: fetchData.guid,
+ jwt: jsonResponse.data.jwt,
+ },
+ '*'
+ );
+ } else {
+ event.source.postMessage(
+ {
+ event: 'videopress_token_error',
+ guid: fetchData.guid,
+ },
+ '*'
+ );
+ }
+ } );
+ } );
+} )();
diff --git a/plugins/jetpack/modules/videopress/shortcode.php b/plugins/jetpack/modules/videopress/shortcode.php
index 1d7dcc53..7ce3147b 100644
--- a/plugins/jetpack/modules/videopress/shortcode.php
+++ b/plugins/jetpack/modules/videopress/shortcode.php
@@ -1,15 +1,21 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* VideoPress Shortcode Handler
*
* This file may or may not be included from the Jetpack VideoPress module.
*/
-
class VideoPress_Shortcode {
- /** @var VideoPress_Shortcode */
+ /**
+ * Singleton VideoPress_Shortcode instance.
+ *
+ * @var VideoPress_Shortcode
+ */
protected static $instance;
+ /**
+ * VideoPress_Shortcode constructor.
+ */
protected function __construct() {
// By explicitly declaring the provider here, we can speed things up by not relying on oEmbed discovery.
@@ -27,6 +33,8 @@ class VideoPress_Shortcode {
}
/**
+ * VideoPress_Shortcode initialization.
+ *
* @return VideoPress_Shortcode
*/
public static function initialize() {
@@ -46,7 +54,7 @@ class VideoPress_Shortcode {
* [wpvideo OcobLTqC]
*
* @link https://codex.wordpress.org/Shortcode_API Shortcode API
- * @param array $attr shortcode attributes
+ * @param array $attr shortcode attributes.
* @return string HTML markup or blank string on fail
*/
public function shortcode_callback( $attr ) {
@@ -82,6 +90,10 @@ class VideoPress_Shortcode {
'flashonly' => false, // Whether to support the Flash player exclusively
'defaultlangcode' => false, // Default language code
'cover' => true, // Whether to scale the video to its container.
+ 'muted' => false, // Whether the video should start without sound.
+ 'controls' => true, // Whether the video should display controls.
+ 'playsinline' => false, // Whether the video should be allowed to play inline (for browsers that support this).
+ 'useaveragecolor' => false, // Whether the video should use the seekbar automatic average color.
);
$attr = shortcode_atts( $defaults, $attr, 'videopress' );
@@ -118,6 +130,11 @@ class VideoPress_Shortcode {
$attr['width'] --;
}
+ // Make sure "false" being passed as useaveragecolor will be actually false.
+ if ( is_string( $attr['useaveragecolor'] ) && 'false' === strtolower( $attr['useaveragecolor'] ) ) {
+ $attr['useaveragecolor'] = false;
+ }
+
/**
* Filter the default VideoPress shortcode options.
*
@@ -139,23 +156,27 @@ class VideoPress_Shortcode {
'permalink' => $attr['permalink'],
'force_flash' => (bool) $attr['flashonly'],
'defaultlangcode' => $attr['defaultlangcode'],
- 'forcestatic' => false, // This used to be a displayed option, but now is only
+ 'forcestatic' => false, // This used to be a displayed option, but now is only.
+ 'muted' => $attr['muted'],
+ 'controls' => $attr['controls'],
+ 'playsinline' => $attr['playsinline'],
+ 'useAverageColor' => (bool) $attr['useaveragecolor'], // The casing is intentional, shortcode params are lowercase, but player expects useAverageColor
// accessible via the `videopress_shortcode_options` filter.
)
);
// Register VideoPress scripts
- wp_register_script( 'videopress', 'https://v0.wordpress.com/js/videopress.js', array( 'jquery', 'swfobject' ), '1.09' );
+ wp_register_script( 'videopress', 'https://v0.wordpress.com/js/videopress.js', array( 'jquery', 'swfobject' ), '1.09', false );
- require_once dirname( __FILE__ ) . '/class.videopress-video.php';
- require_once dirname( __FILE__ ) . '/class.videopress-player.php';
+ require_once __DIR__ . '/class.videopress-video.php';
+ require_once __DIR__ . '/class.videopress-player.php';
$player = new VideoPress_Player( $guid, $attr['width'], $options );
if ( is_feed() ) {
- return $player->asXML();
+ return $player->as_xml();
} else {
- return $player->asHTML();
+ return $player->as_html();
}
}
@@ -172,7 +193,7 @@ class VideoPress_Shortcode {
*
* @return string
*/
- public function video_shortcode_override( $html, $attr, $content, $instance ) {
+ public function video_shortcode_override( $html, $attr, $content, $instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$videopress_guid = null;
@@ -228,7 +249,7 @@ class VideoPress_Shortcode {
/**
* Adds a `for` query parameter to the oembed provider request URL.
*
- * @param String $oembed_provider
+ * @param String $oembed_provider URL of the oEmbed provider.
* @return String $ehnanced_oembed_provider
*/
public function add_oembed_for_parameter( $oembed_provider ) {
diff --git a/plugins/jetpack/modules/videopress/utility-functions.php b/plugins/jetpack/modules/videopress/utility-functions.php
index 3dad98ab..f7f98735 100644
--- a/plugins/jetpack/modules/videopress/utility-functions.php
+++ b/plugins/jetpack/modules/videopress/utility-functions.php
@@ -1,17 +1,26 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Connection\Client;
/**
* We won't have any videos less than sixty pixels wide. That would be silly.
*/
-defined( 'VIDEOPRESS_MIN_WIDTH' ) or define( 'VIDEOPRESS_MIN_WIDTH', 60 );
+defined( 'VIDEOPRESS_MIN_WIDTH' ) || define( 'VIDEOPRESS_MIN_WIDTH', 60 );
+
+/**
+ * VideoPress Privacy constants.
+ */
+abstract class VIDEOPRESS_PRIVACY {
+ const IS_PUBLIC = 0;
+ const IS_PRIVATE = 1;
+ const SITE_DEFAULT = 2;
+}
/**
* Validate user-supplied guid values against expected inputs
*
* @since 1.1
- * @param string $guid video identifier
+ * @param string $guid video identifier.
* @return bool true if passes validation test
*/
function videopress_is_valid_guid( $guid ) {
@@ -24,7 +33,7 @@ function videopress_is_valid_guid( $guid ) {
/**
* Get details about a specific video by GUID:
*
- * @param $guid string
+ * @param string $guid Video GUID.
* @return object
*/
function videopress_get_video_details( $guid ) {
@@ -70,8 +79,8 @@ function videopress_get_video_details( $guid ) {
/**
* Similar to `media_sideload_image` -- but returns an ID.
*
- * @param $url
- * @param $attachment_id
+ * @param string $url Image URL.
+ * @param int $attachment_id Post ID.
*
* @return int|mixed|object|WP_Error
*/
@@ -103,8 +112,8 @@ function videopress_download_poster_image( $url, $attachment_id ) {
/**
* Creates a local media library item of a remote VideoPress video.
*
- * @param $guid
- * @param int $parent_id
+ * @param string $guid Video GUID.
+ * @param int $parent_id Parent post ID.
*
* @return int|object
*/
@@ -151,7 +160,7 @@ function create_local_media_library_for_videopress_guid( $guid, $parent_id = 0 )
* @return int The number of items that were cleaned up.
*/
function videopress_cleanup_media_library() {
-
+ // phpcs:disable Squiz.PHP.NonExecutableCode.Unreachable -- Function is disabled currently.
// Disable this job for now.
return 0;
$query_args = array(
@@ -170,7 +179,7 @@ function videopress_cleanup_media_library() {
$cleaned = 0;
- $now = current_time( 'timestamp' );
+ $now = current_time( 'timestamp' ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested -- Probably should refactor, but this function is disabled.
if ( $query->have_posts() ) {
foreach ( $query->posts as $post ) {
@@ -187,14 +196,15 @@ function videopress_cleanup_media_library() {
}
return $cleaned;
+ // phpcs:enable Squiz.PHP.NonExecutableCode.Unreachable
}
/**
* Return an absolute URI for a given filename and guid on the CDN.
* No check is performed to ensure the guid exists or the file is present. Simple centralized string builder.
*
- * @param string $guid VideoPress identifier
- * @param string $filename name of file associated with the guid (video file name or thumbnail file name)
+ * @param string $guid VideoPress identifier.
+ * @param string $filename name of file associated with the guid (video file name or thumbnail file name).
*
* @return string Absolute URL of VideoPress file for the given guid.
*/
@@ -206,7 +216,7 @@ function videopress_cdn_file_url( $guid, $filename ) {
* Get an array of the transcoding status for the given video post.
*
* @since 4.4
- * @param int $post_id
+ * @param int $post_id Post ID.
* @return array|bool Returns an array of statuses if this is a VideoPress post, otherwise it returns false.
*/
function videopress_get_transcoding_status( $post_id ) {
@@ -233,7 +243,7 @@ function videopress_get_transcoding_status( $post_id ) {
* Get the direct url to the video.
*
* @since 4.4
- * @param string $guid
+ * @param string $guid VideoPress GUID.
* @return string
*/
function videopress_build_url( $guid ) {
@@ -251,7 +261,8 @@ function videopress_build_url( $guid ) {
* callback from the VideoPress servers.
*
* @since 4.4
- * @param string $title
+ * @param string $title The post_title.
+ * @param string $guid The VideoPress guid.
* @return int|WP_Error
*/
function videopress_create_new_media_item( $title, $guid = null ) {
@@ -272,10 +283,11 @@ function videopress_create_new_media_item( $title, $guid = null ) {
return $media_id;
}
-
/**
- * @param array $current_status
- * @param array $new_meta
+ * Merge VideoPress file status metadata.
+ *
+ * @param array $current_status The current status of the video.
+ * @param array $new_meta The new meta data to merge with the current status.
* @return array
*/
function videopress_merge_file_status( $current_status, $new_meta ) {
@@ -315,7 +327,7 @@ function videopress_merge_file_status( $current_status, $new_meta ) {
* Check to see if a video has completed processing.
*
* @since 4.4
- * @param int $post_id
+ * @param int $post_id Post ID.
* @return bool
*/
function videopress_is_finished_processing( $post_id ) {
@@ -333,12 +345,11 @@ function videopress_is_finished_processing( $post_id ) {
return $meta['videopress']['finished'];
}
-
/**
* Update the meta information status for the given video post.
*
* @since 4.4
- * @param int $post_id
+ * @param int $post_id Post ID.
* @return bool
*/
function videopress_update_meta_data( $post_id ) {
@@ -352,11 +363,7 @@ function videopress_update_meta_data( $post_id ) {
$info = (object) $meta['videopress'];
- $args = array(
- // 'sslverify' => false,
- );
-
- $result = wp_remote_get( videopress_make_video_get_path( $info->guid ), $args );
+ $result = Client::wpcom_json_api_request_as_blog( 'videos/' . $info->guid );
if ( is_wp_error( $result ) ) {
return false;
@@ -375,7 +382,7 @@ function videopress_update_meta_data( $post_id ) {
/**
* Check to see if this is a VideoPress post that hasn't had a guid set yet.
*
- * @param int $post_id
+ * @param int $post_id Post ID.
* @return bool
*/
function videopress_is_attachment_without_guid( $post_id ) {
@@ -401,7 +408,7 @@ function videopress_is_attachment_without_guid( $post_id ) {
/**
* Check to see if this is a VideoPress attachment.
*
- * @param int $post_id
+ * @param int $post_id Post ID.
* @return bool
*/
function is_videopress_attachment( $post_id ) {
@@ -422,7 +429,7 @@ function is_videopress_attachment( $post_id ) {
* Get the video update path
*
* @since 4.4
- * @param string $guid
+ * @param string $guid VideoPress GUID.
* @return string
*/
function videopress_make_video_get_path( $guid ) {
@@ -450,6 +457,20 @@ function videopress_make_media_upload_path( $blog_id ) {
}
/**
+ * Get the resumable upload api path.
+ *
+ * @since 4.4
+ * @param int $blog_id The id of the blog we're uploading to.
+ * @return string
+ */
+function videopress_make_resumable_upload_path( $blog_id ) {
+ return sprintf(
+ 'https://public-api.wordpress.com/rest/v1.1/video-uploads/%s/',
+ $blog_id
+ );
+}
+
+/**
* This is a mock of the internal VideoPress method, which is meant to duplicate the functionality
* of the WPCOM API, so that the Jetpack REST API returns the same data with no modifications.
*
@@ -480,18 +501,19 @@ function video_get_info_by_blogpostid( $blog_id, $post_id ) {
$meta = wp_get_attachment_metadata( $post_id );
if ( $meta && isset( $meta['videopress'] ) ) {
- $videopress_meta = $meta['videopress'];
- $video_info->rating = $videopress_meta['rating'];
+ $videopress_meta = $meta['videopress'];
+ $video_info->rating = isset( $videopress_meta['rating'] ) ? $videopress_meta['rating'] : null;
+ $video_info->allow_download = isset( $videopress_meta['allow_download'] ) ? $videopress_meta['allow_download'] : 0;
+ $video_info->privacy_setting = ! isset( $videopress_meta['privacy_setting'] ) ? VIDEOPRESS_PRIVACY::SITE_DEFAULT : $videopress_meta['privacy_setting'];
}
if ( videopress_is_finished_processing( $post_id ) ) {
- $video_info->finish_date_gmt = date( 'Y-m-d H:i:s' );
+ $video_info->finish_date_gmt = gmdate( 'Y-m-d H:i:s' );
}
return $video_info;
}
-
/**
* Check that a VideoPress video format has finished processing.
*
@@ -503,8 +525,8 @@ function video_get_info_by_blogpostid( $blog_id, $post_id ) {
* Note: This mimics the WPCOM function of the same name and helps the media
* API endpoint add all needed VideoPress data.
*
- * @param stdClass $info
- * @param string $format
+ * @param stdClass $info Info object.
+ * @param string $format Video format.
* @return bool
*/
function video_format_done( $info, $format ) {
@@ -546,11 +568,11 @@ function video_format_done( $info, $format ) {
* Note: This mimics the WPCOM function of the same name and helps the media
* API endpoint add all needed VideoPress data.
*
- * @param string $guid
- * @param string $format
+ * @param string $guid VideoPress GUID.
+ * @param string $format Video format.
* @return string
*/
-function video_image_url_by_guid( $guid, $format ) {
+function video_image_url_by_guid( $guid, $format ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$post = videopress_get_post_by_guid( $guid );
@@ -684,7 +706,7 @@ function jetpack_videopress_flash_embed_filter( $content ) {
$regex = '%<embed[^>]*+>(?:\s*</embed>)?%i';
$content = preg_replace_callback(
$regex,
- function( $matches, $orig_html = null ) {
+ function ( $matches ) {
$embed_code = $matches[0];
$url_matches = array();
diff --git a/plugins/jetpack/modules/videopress/videopress-admin-rtl.css b/plugins/jetpack/modules/videopress/videopress-admin-rtl.css
index fd171890..1bac1f72 100644
--- a/plugins/jetpack/modules/videopress/videopress-admin-rtl.css
+++ b/plugins/jetpack/modules/videopress/videopress-admin-rtl.css
@@ -1,107 +1,106 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
/**
* VideoPress admin media styles
*/
.videopress-modal-backdrop {
- background: #000;
- opacity: 0.7;
- position: absolute;
- top: 0;
- width: 100%;
- height: 100%;
- overflow: hidden;
- z-index: 100;
+ background: #000;
+ opacity: 0.7;
+ position: absolute;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ overflow: hidden;
+ z-index: 100;
}
.videopress-modal {
- padding: 10px 20px;
- background: white;
- position: absolute;
- top: 0;
- width: 440px;
- overflow: hidden;
- right: 50%;
- margin-right: -220px;
- z-index: 101;
- box-shadow: -2px 2px 5px 2px rgba( 0, 0, 0, 0.5 );
- -webkit-border-bottom-left-radius: 2px;
- -webkit-border-bottom-right-radius: 2px;
- border-bottom-left-radius: 2px;
- border-bottom-right-radius: 2px;
+ padding: 10px 20px;
+ background: white;
+ position: absolute;
+ top: 0;
+ width: 440px;
+ overflow: hidden;
+ right: 50%;
+ margin-right: -220px;
+ z-index: 101;
+ box-shadow: -2px 2px 5px 2px rgba(0, 0, 0, 0.5);
+ -webkit-border-bottom-left-radius: 2px;
+ -webkit-border-bottom-right-radius: 2px;
+ border-bottom-left-radius: 2px;
+ border-bottom-right-radius: 2px;
}
.videopress-modal .submit {
- text-align: left;
- padding: 10px 0 5px;
+ text-align: left;
+ padding: 10px 0 5px;
}
.videopress-preview {
- display: block;
- float: left;
- width: 65%;
- margin-top: 18px;
- background: black;
- min-height: 97px;
- text-decoration: none;
+ display: block;
+ float: left;
+ width: 65%;
+ margin-top: 18px;
+ background: black;
+ min-height: 97px;
+ text-decoration: none;
}
.vp-preview span.videopress-preview-unavailable {
- width: 65%;
- float: left;
- text-align: right;
- margin-left: 0;
+ width: 65%;
+ float: left;
+ text-align: right;
+ margin-left: 0;
}
.videopress-preview img {
- float: right;
- width: 100%;
+ float: right;
+ width: 100%;
}
.videopress-preview span {
- display: block;
- padding-top: 40px;
- color: white !important;
- text-align: center;
+ display: block;
+ padding-top: 40px;
+ color: white !important;
+ text-align: center;
}
.vp-setting .help {
- margin: 0 35% 4px 0;
+ margin: 0 35% 4px 0;
}
-.media-sidebar .vp-setting input[type="checkbox"] {
- float: right;
- margin-top: 10px;
+.media-sidebar .vp-setting input[type=checkbox] {
+ float: right;
+ margin-top: 10px;
}
.vp-setting label {
- float: right;
- margin: 8px 5px 0 8px;
- max-width: 135px;
+ float: right;
+ margin: 8px 5px 0 8px;
+ max-width: 135px;
}
-.vp-setting input[type='radio'] {
- float: right;
- margin-top: 9px;
- width: auto;
+.vp-setting input[type=radio] {
+ float: right;
+ margin-top: 9px;
+ width: auto;
}
.vp-preview span {
- margin-top: 18px;
+ margin-top: 18px;
}
.uploader-videopress {
- margin: 16px;
+ margin: 16px;
}
.uploader-videopress .videopress-errors div {
- margin: 16px 0;
+ margin: 16px 0;
}
-.compat-field-video-rating input[type="radio"],
-.compat-field-display_embed input[type="checkbox"],
-.compat-field-allow_download input[type="checkbox"] {
- margin-top: -1px !important;
- margin-left: 5px !important;
- margin-right: 5px !important;
- vertical-align: middle;
+.compat-field-video-rating input[type=radio],
+.compat-field-display_embed input[type=checkbox],
+.compat-field-allow_download input[type=checkbox] {
+ margin-top: -1px !important;
+ margin-left: 5px !important;
+ margin-right: 5px !important;
+ vertical-align: middle;
}
diff --git a/plugins/jetpack/modules/videopress/videopress-admin-rtl.min.css b/plugins/jetpack/modules/videopress/videopress-admin-rtl.min.css
index 8f8246d8..0fbbb420 100644
--- a/plugins/jetpack/modules/videopress/videopress-admin-rtl.min.css
+++ b/plugins/jetpack/modules/videopress/videopress-admin-rtl.min.css
@@ -1 +1 @@
-.videopress-modal-backdrop{background:#000;opacity:.7;position:absolute;top:0;width:100%;height:100%;overflow:hidden;z-index:100}.videopress-modal{padding:10px 20px;background:#fff;position:absolute;top:0;width:440px;overflow:hidden;right:50%;margin-right:-220px;z-index:101;box-shadow:-2px 2px 5px 2px rgba(0,0,0,.5);-webkit-border-bottom-left-radius:2px;-webkit-border-bottom-right-radius:2px;border-bottom-left-radius:2px;border-bottom-right-radius:2px}.videopress-modal .submit{text-align:left;padding:10px 0 5px}.videopress-preview{display:block;float:left;width:65%;margin-top:18px;background:#000;min-height:97px;text-decoration:none}.vp-preview span.videopress-preview-unavailable{width:65%;float:left;text-align:right;margin-left:0}.videopress-preview img{float:right;width:100%}.videopress-preview span{display:block;padding-top:40px;color:#fff!important;text-align:center}.vp-setting .help{margin:0 35% 4px 0}.media-sidebar .vp-setting input[type=checkbox]{float:right;margin-top:10px}.vp-setting label{float:right;margin:8px 5px 0 8px;max-width:135px}.vp-setting input[type=radio]{float:right;margin-top:9px;width:auto}.vp-preview span{margin-top:18px}.uploader-videopress{margin:16px}.uploader-videopress .videopress-errors div{margin:16px 0}.compat-field-allow_download input[type=checkbox],.compat-field-display_embed input[type=checkbox],.compat-field-video-rating input[type=radio]{margin-top:-1px!important;margin-left:5px!important;margin-right:5px!important;vertical-align:middle} \ No newline at end of file
+.videopress-modal-backdrop{background:#000;height:100%;opacity:.7;overflow:hidden;position:absolute;top:0;width:100%;z-index:100}.videopress-modal{background:#fff;-webkit-border-bottom-left-radius:2px;border-bottom-left-radius:2px;-webkit-border-bottom-right-radius:2px;border-bottom-right-radius:2px;box-shadow:-2px 2px 5px 2px rgba(0,0,0,.5);margin-right:-220px;overflow:hidden;padding:10px 20px;position:absolute;right:50%;top:0;width:440px;z-index:101}.videopress-modal .submit{padding:10px 0 5px;text-align:left}.videopress-preview{background:#000;display:block;float:left;margin-top:18px;min-height:97px;text-decoration:none;width:65%}.vp-preview span.videopress-preview-unavailable{float:left;margin-left:0;text-align:right;width:65%}.videopress-preview img{float:right;width:100%}.videopress-preview span{color:#fff!important;display:block;padding-top:40px;text-align:center}.vp-setting .help{margin:0 35% 4px 0}.media-sidebar .vp-setting input[type=checkbox]{float:right;margin-top:10px}.vp-setting label{float:right;margin:8px 5px 0 8px;max-width:135px}.vp-setting input[type=radio]{float:right;margin-top:9px;width:auto}.vp-preview span{margin-top:18px}.uploader-videopress{margin:16px}.uploader-videopress .videopress-errors div{margin:16px 0}.compat-field-allow_download input[type=checkbox],.compat-field-display_embed input[type=checkbox],.compat-field-video-rating input[type=radio]{margin-left:5px!important;margin-right:5px!important;margin-top:-1px!important;vertical-align:middle} \ No newline at end of file
diff --git a/plugins/jetpack/modules/videopress/videopress-admin.min.css b/plugins/jetpack/modules/videopress/videopress-admin.min.css
index 4a6c119c..b113044c 100644
--- a/plugins/jetpack/modules/videopress/videopress-admin.min.css
+++ b/plugins/jetpack/modules/videopress/videopress-admin.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-.videopress-modal-backdrop{background:#000;opacity:.7;position:absolute;top:0;width:100%;height:100%;overflow:hidden;z-index:100}.videopress-modal{padding:10px 20px;background:#fff;position:absolute;top:0;width:440px;overflow:hidden;left:50%;margin-left:-220px;z-index:101;box-shadow:2px 2px 5px 2px rgba(0,0,0,.5);-webkit-border-bottom-right-radius:2px;-webkit-border-bottom-left-radius:2px;border-bottom-right-radius:2px;border-bottom-left-radius:2px}.videopress-modal .submit{text-align:right;padding:10px 0 5px}.videopress-preview{display:block;float:right;width:65%;margin-top:18px;background:#000;min-height:97px;text-decoration:none}.vp-preview span.videopress-preview-unavailable{width:65%;float:right;text-align:left;margin-right:0}.videopress-preview img{float:left;width:100%}.videopress-preview span{display:block;padding-top:40px;color:#fff!important;text-align:center}.vp-setting .help{margin:0 0 4px 35%}.media-sidebar .vp-setting input[type=checkbox]{float:left;margin-top:10px}.vp-setting label{float:left;margin:8px 8px 0 5px;max-width:135px}.vp-setting input[type=radio]{float:left;margin-top:9px;width:auto}.vp-preview span{margin-top:18px}.uploader-videopress{margin:16px}.uploader-videopress .videopress-errors div{margin:16px 0}.compat-field-allow_download input[type=checkbox],.compat-field-display_embed input[type=checkbox],.compat-field-video-rating input[type=radio]{margin-top:-1px!important;margin-right:5px!important;margin-left:5px!important;vertical-align:middle} \ No newline at end of file
+.videopress-modal-backdrop{background:#000;height:100%;opacity:.7;overflow:hidden;position:absolute;top:0;width:100%;z-index:100}.videopress-modal{background:#fff;-webkit-border-bottom-left-radius:2px;border-bottom-left-radius:2px;-webkit-border-bottom-right-radius:2px;border-bottom-right-radius:2px;box-shadow:2px 2px 5px 2px rgba(0,0,0,.5);left:50%;margin-left:-220px;overflow:hidden;padding:10px 20px;position:absolute;top:0;width:440px;z-index:101}.videopress-modal .submit{padding:10px 0 5px;text-align:right}.videopress-preview{background:#000;display:block;float:right;margin-top:18px;min-height:97px;text-decoration:none;width:65%}.vp-preview span.videopress-preview-unavailable{float:right;margin-right:0;text-align:left;width:65%}.videopress-preview img{float:left;width:100%}.videopress-preview span{color:#fff!important;display:block;padding-top:40px;text-align:center}.vp-setting .help{margin:0 0 4px 35%}.media-sidebar .vp-setting input[type=checkbox]{float:left;margin-top:10px}.vp-setting label{float:left;margin:8px 8px 0 5px;max-width:135px}.vp-setting input[type=radio]{float:left;margin-top:9px;width:auto}.vp-preview span{margin-top:18px}.uploader-videopress{margin:16px}.uploader-videopress .videopress-errors div{margin:16px 0}.compat-field-allow_download input[type=checkbox],.compat-field-display_embed input[type=checkbox],.compat-field-video-rating input[type=radio]{margin-left:5px!important;margin-right:5px!important;margin-top:-1px!important;vertical-align:middle} \ No newline at end of file
diff --git a/plugins/jetpack/modules/waf.php b/plugins/jetpack/modules/waf.php
new file mode 100644
index 00000000..110513de
--- /dev/null
+++ b/plugins/jetpack/modules/waf.php
@@ -0,0 +1,13 @@
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Module Name: Firewall
+ * Module Description: Protect your site with Jetpack's Web Application Firewall
+ * Sort Order: 5
+ * First Introduced: 10.9
+ * Requires Connection: Yes
+ * Auto Activate: No
+ * Module Tags: Firewall, WAF
+ * Feature: Security
+ *
+ * @package automattic/jetpack
+ */
diff --git a/plugins/jetpack/modules/widget-visibility.php b/plugins/jetpack/modules/widget-visibility.php
index 253a9ee1..b5afc3ab 100644
--- a/plugins/jetpack/modules/widget-visibility.php
+++ b/plugins/jetpack/modules/widget-visibility.php
@@ -1,5 +1,11 @@
<?php
/**
+ * Module: Widget Visibility
+ *
+ * @package automattic/jetpack
+ */
+
+/**
* Module Name: Widget Visibility
* Module Description: Control where widgets appear on your site.
* First Introduced: 2.4
@@ -11,4 +17,4 @@
* Additional Search Queries: widget visibility, logic, conditional, widgets, widget
*/
-include dirname( __FILE__ ) . "/widget-visibility/widget-conditions.php";
+require __DIR__ . '/widget-visibility/widget-conditions.php';
diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions.php b/plugins/jetpack/modules/widget-visibility/widget-conditions.php
index 9120157c..2553f912 100644
--- a/plugins/jetpack/modules/widget-visibility/widget-conditions.php
+++ b/plugins/jetpack/modules/widget-visibility/widget-conditions.php
@@ -1,4 +1,9 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Main class file for the Widget Visibility module.
+ *
+ * @package automattic/jetpack
+ */
use Automattic\Jetpack\Assets;
@@ -19,8 +24,16 @@ use Automattic\Jetpack\Assets;
* An introduction to the API endpoints can be found here: https://make.wordpress.org/core/2021/06/29/rest-api-changes-in-wordpress-5-8/
*/
class Jetpack_Widget_Conditions {
- static $passed_template_redirect = false;
+ /**
+ * Stores condition for template_redirect action.
+ *
+ * @var bool
+ */
+ public static $passed_template_redirect = false;
+ /**
+ * Class initializer.
+ */
public static function init() {
global $pagenow;
@@ -40,7 +53,7 @@ class Jetpack_Widget_Conditions {
}
// API call to *list* the widget types doesn't use editing visibility or display widgets.
- if ( false !== strpos( $_SERVER['REQUEST_URI'], '/widget-types?' ) ) {
+ if ( isset( $_SERVER['REQUEST_URI'] ) && false !== strpos( $_SERVER['REQUEST_URI'], '/widget-types?' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
return;
}
@@ -71,7 +84,7 @@ class Jetpack_Widget_Conditions {
}
// Encoding for a particular widget end point.
- if ( 1 === preg_match( '|/widget-types/.*/encode|', $_SERVER['REQUEST_URI'] ) ) {
+ if ( isset( $_SERVER['REQUEST_URI'] ) && 1 === preg_match( '|/widget-types/.*/encode|', $_SERVER['REQUEST_URI'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$add_html_to_form = true;
$handle_widget_updates = true;
}
@@ -84,7 +97,7 @@ class Jetpack_Widget_Conditions {
}
// Saving widgets via non-batch API. This isn't used within WordPress but could be used by third parties in theory.
- if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'GET' !== $_SERVER['REQUEST_METHOD'] && false !== strpos( $_SERVER['REQUEST_URI'], '/wp/v2/widgets' ) ) {
+ if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'GET' !== $_SERVER['REQUEST_METHOD'] && false !== strpos( $_SERVER['REQUEST_URI'], '/wp/v2/widgets' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$handle_widget_updates = true;
$add_html_to_form = true;
}
@@ -217,15 +230,17 @@ class Jetpack_Widget_Conditions {
$widget_conditions_data['author'] = array();
$widget_conditions_data['author'][] = array( '', __( 'All author pages', 'jetpack' ) );
- // Only users with publish caps
- $authors = get_users(
- array(
- 'orderby' => 'name',
- 'who' => 'authors',
- 'fields' => array( 'ID', 'display_name' ),
- )
+ /*
+ * Query for users with publish caps.
+ */
+ $authors_args = array(
+ 'orderby' => 'name',
+ 'capability' => array( 'edit_posts' ),
+ 'fields' => array( 'ID', 'display_name' ),
);
+ $authors = get_users( $authors_args );
+
foreach ( $authors as $author ) {
$widget_conditions_data['author'][] = array( (string) $author->ID, $author->display_name );
}
@@ -305,7 +320,7 @@ class Jetpack_Widget_Conditions {
'option_none_value' => '',
'value_field' => 'ID',
);
- $pages_dropdown = walk_page_dropdown_tree( $pages, 0, $dropdown_tree_args );
+ $pages_dropdown = walk_page_dropdown_tree( $pages, 0, $dropdown_tree_args );
preg_match_all( '/value=.([0-9]+).[^>]*>([^<]+)</', $pages_dropdown, $page_ids_and_titles, PREG_SET_ORDER );
$static_pages = array();
@@ -471,8 +486,8 @@ class Jetpack_Widget_Conditions {
// display the visibility panel open, e.g. when saving. In the gutenberg widget experience the POST
// value will always be empty, but this is fine - it doesn't rerender the HTML when saving anyway.
if (
- empty( $_POST['widget-conditions-visible'] )
- || $_POST['widget-conditions-visible'] == '0'
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ empty( $_POST['widget-conditions-visible'] ) || '0' === $_POST['widget-conditions-visible']
) {
?>
widget-conditional-hide
@@ -493,12 +508,15 @@ class Jetpack_Widget_Conditions {
">
<input type="hidden" name="widget-conditions-visible" value="
<?php
- if ( isset( $_POST['widget-conditions-visible'] ) ) {
- echo esc_attr( $_POST['widget-conditions-visible'] ); } else {
- ?>
- 0<?php } ?>" />
+ if ( isset( $_POST['widget-conditions-visible'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ echo esc_attr( filter_var( wp_unslash( $_POST['widget-conditions-visible'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ } else {
+ echo 0;
+ }
+ ?>
+ " />
<?php
- if ( ! isset( $_POST['widget-conditions-visible'] ) ) {
+ if ( ! isset( $_POST['widget-conditions-visible'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
?>
<a href="#" class="button display-options"><?php esc_html_e( 'Visibility', 'jetpack' ); ?></a><?php } ?>
<div class="widget-conditional-inner">
@@ -535,7 +553,7 @@ class Jetpack_Widget_Conditions {
<option value="category" <?php selected( 'category', $rule['major'] ); ?>><?php esc_html_e( 'Category', 'jetpack' ); ?></option>
<option value="author" <?php selected( 'author', $rule['major'] ); ?>><?php echo esc_html_x( 'Author', 'Noun, as in: "The author of this post is..."', 'jetpack' ); ?></option>
- <?php if ( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) { // this doesn't work on .com because of caching ?>
+ <?php if ( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) { // this doesn't work on .com because of caching. ?>
<option value="loggedin" <?php selected( 'loggedin', $rule['major'] ); ?>><?php echo esc_html_x( 'User', 'Noun', 'jetpack' ); ?></option>
<option value="role" <?php selected( 'role', $rule['major'] ); ?>><?php echo esc_html_x( 'Role', 'Noun, as in: "The user role of that can access this widget is..."', 'jetpack' ); ?></option>
<?php } ?>
@@ -548,18 +566,21 @@ class Jetpack_Widget_Conditions {
<?php endif; ?>
</select>
- <?php _ex( 'is', 'Widget Visibility: {Rule Major [Page]} is {Rule Minor [Search results]}', 'jetpack' ); ?>
+ <?php echo esc_html_x( 'is', 'Widget Visibility: {Rule Major [Page]} is {Rule Minor [Search results]}', 'jetpack' ); ?>
<select class="conditions-rule-minor" name="<?php echo esc_attr( $widget->get_field_name( 'conditions[rules_minor][]' ) ); ?>"
<?php
if ( ! $rule['major'] ) {
- ?>
- disabled="disabled"<?php } ?>>
+ echo ' disabled="disabled"';
+ }
+ ?>
+ >
<?php
/*
Include the currently selected value so that if the widget is saved without
- expanding the Visibility section, we don't lose the minor part of the rule.
- If it is opened, this list is cleared out and populated with all the values. */
+ expanding the Visibility section, we don't lose the minor part of the rule.
+ If it is opened, this list is cleared out and populated with all the values.
+ */
?>
<option value="<?php echo esc_attr( $rule['minor'] ); ?>" selected="selected"></option>
</select>
@@ -567,8 +588,10 @@ class Jetpack_Widget_Conditions {
<span class="conditions-rule-has-children"
<?php
if ( ! $rule['has_children'] ) {
- ?>
- style="display: none;"<?php } ?>>
+ echo ' style="display: none;"';
+ }
+ ?>
+ >
<label>
<input type="checkbox" name="<?php echo esc_attr( $widget->get_field_name( "conditions[page_children][$rule_index]" ) ); ?>" value="has" <?php checked( $rule['has_children'], true ); ?> />
<?php echo esc_html_x( 'Include children', 'Checkbox on Widget Visibility if children of the selected page should be included in the visibility rule.', 'jetpack' ); ?>
@@ -652,7 +675,7 @@ class Jetpack_Widget_Conditions {
(
isset( $instance['conditions'], $old_instance['conditions'] )
&&
- serialize( $instance['conditions'] ) != serialize( $old_instance['conditions'] )
+ serialize( $instance['conditions'] ) !== serialize( $old_instance['conditions'] ) // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
)
) {
@@ -697,7 +720,7 @@ class Jetpack_Widget_Conditions {
continue;
}
- if ( 'wp_inactive_widgets' == $widget_area ) {
+ if ( 'wp_inactive_widgets' === $widget_area ) {
continue;
}
@@ -715,15 +738,12 @@ class Jetpack_Widget_Conditions {
$settings[ $id_base ] = get_option( 'widget_' . $id_base );
}
- // New multi widget (WP_Widget)
- if ( ! is_null( $widget_number ) ) {
+ // New multi widget (WP_Widget).
+ if ( $widget_number !== null ) {
if ( isset( $settings[ $id_base ][ $widget_number ] ) && false === self::filter_widget( $settings[ $id_base ][ $widget_number ] ) ) {
unset( $widget_areas[ $widget_area ][ $position ] );
}
- }
-
- // Old single widget
- elseif ( ! empty( $settings[ $id_base ] ) && false === self::filter_widget( $settings[ $id_base ] ) ) {
+ } elseif ( ! empty( $settings[ $id_base ] ) && false === self::filter_widget( $settings[ $id_base ] ) ) { // Old single widget.
unset( $widget_areas[ $widget_area ][ $position ] );
}
}
@@ -732,17 +752,20 @@ class Jetpack_Widget_Conditions {
return $widget_areas;
}
+ /**
+ * Set field $passed_template_redirect to true.
+ */
public static function template_redirect() {
self::$passed_template_redirect = true;
}
/**
- * Generates a condition key based on the rule array
+ * Generates a condition key based on the rule array.
*
- * @param array $rule
+ * @param array $rule rule data.
* @return string key used to retrieve the condition.
*/
- static function generate_condition_key( $rule ) {
+ public static function generate_condition_key( $rule ) {
if ( isset( $rule['has_children'] ) ) {
return $rule['major'] . ':' . $rule['minor'] . ':' . $rule['has_children'];
}
@@ -758,7 +781,7 @@ class Jetpack_Widget_Conditions {
public static function filter_widget( $instance ) {
// Don't filter widgets from the REST API when it's called via the widgets admin page - otherwise they could get
// filtered out and become impossible to edit.
- if ( strpos( wp_get_raw_referer(), '/wp-admin/widgets.php' ) && false !== strpos( $_SERVER['REQUEST_URI'], '/wp-json/' ) ) {
+ if ( strpos( wp_get_raw_referer(), '/wp-admin/widgets.php' ) && isset( $_SERVER['REQUEST_URI'] ) && false !== strpos( filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/wp-json/' ) ) {
return $instance;
}
// WordPress.com specific check - here, referer ends in /rest-proxy/ and doesn't tell us what's requesting.
@@ -835,7 +858,7 @@ class Jetpack_Widget_Conditions {
break;
case 'page':
// Previously hardcoded post type options.
- if ( 'post' == $rule['minor'] ) {
+ if ( 'post' === $rule['minor'] ) {
$rule['minor'] = 'post_type-post';
} elseif ( ! $rule['minor'] ) {
$rule['minor'] = 'post_type-page';
@@ -865,20 +888,20 @@ class Jetpack_Widget_Conditions {
}
break;
default:
- if ( substr( $rule['minor'], 0, 10 ) == 'post_type-' ) {
+ if ( substr( $rule['minor'], 0, 10 ) === 'post_type-' ) {
$condition_result = is_singular( substr( $rule['minor'], 10 ) );
- } elseif ( substr( $rule['minor'], 0, 18 ) == 'post_type_archive-' ) {
+ } elseif ( substr( $rule['minor'], 0, 18 ) === 'post_type_archive-' ) {
$condition_result = is_post_type_archive( substr( $rule['minor'], 18 ) );
- } elseif ( $rule['minor'] == get_option( 'page_for_posts' ) ) {
- // If $rule['minor'] is a page ID which is also the posts page
+ } elseif ( get_option( 'page_for_posts' ) === $rule['minor'] ) {
+ // If $rule['minor'] is a page ID which is also the posts page.
$condition_result = $wp_query->is_posts_page;
} else {
// $rule['minor'] is a page ID
- $condition_result = is_page() && ( $rule['minor'] == get_the_ID() );
+ $condition_result = is_page() && ( get_the_ID() === (int) $rule['minor'] );
- // Check if $rule['minor'] is parent of page ID
+ // Check if $rule['minor'] is parent of page ID.
if ( ! $condition_result && isset( $rule['has_children'] ) && $rule['has_children'] ) {
- $condition_result = wp_get_post_parent_id( get_the_ID() ) == $rule['minor'];
+ $condition_result = wp_get_post_parent_id( get_the_ID() ) === (int) $rule['minor'];
}
}
break;
@@ -890,7 +913,7 @@ class Jetpack_Widget_Conditions {
if ( is_tag() ) {
$condition_result = true;
} elseif ( is_singular() ) {
- if ( in_array( 'post_tag', get_post_taxonomies() ) ) {
+ if ( in_array( 'post_tag', get_post_taxonomies(), true ) ) {
$condition_result = true;
}
}
@@ -910,7 +933,7 @@ class Jetpack_Widget_Conditions {
if ( is_category() ) {
$condition_result = true;
} elseif ( is_singular() ) {
- if ( in_array( 'category', get_post_taxonomies() ) ) {
+ if ( in_array( 'category', get_post_taxonomies(), true ) ) {
$condition_result = true;
}
}
@@ -936,7 +959,7 @@ class Jetpack_Widget_Conditions {
$condition_result = true;
} elseif ( $rule['minor'] && is_author( $rule['minor'] ) ) {
$condition_result = true;
- } elseif ( is_singular() && $rule['minor'] && $rule['minor'] == $post->post_author ) {
+ } elseif ( is_singular() && $rule['minor'] && $rule['minor'] === $post->post_author ) {
$condition_result = true;
}
break;
@@ -946,7 +969,7 @@ class Jetpack_Widget_Conditions {
$user_roles = $current_user->roles;
- if ( in_array( $rule['minor'], $user_roles ) ) {
+ if ( in_array( $rule['minor'], $user_roles, true ) ) {
$condition_result = true;
} else {
$condition_result = false;
@@ -956,9 +979,9 @@ class Jetpack_Widget_Conditions {
}
break;
case 'post_type':
- if ( substr( $rule['minor'], 0, 10 ) == 'post_type-' ) {
+ if ( substr( $rule['minor'], 0, 10 ) === 'post_type-' ) {
$condition_result = is_singular( substr( $rule['minor'], 10 ) );
- } elseif ( substr( $rule['minor'], 0, 18 ) == 'post_type_archive-' ) {
+ } elseif ( substr( $rule['minor'], 0, 18 ) === 'post_type_archive-' ) {
$condition_result = is_post_type_archive( substr( $rule['minor'], 18 ) );
}
break;
@@ -977,7 +1000,7 @@ class Jetpack_Widget_Conditions {
}
// Specified taxonomy page.
- $term = explode( '_tax_', $rule['minor'] ); // $term[0] = taxonomy name; $term[1] = term id
+ $term = explode( '_tax_', $rule['minor'] ); // $term[0] is taxonomy name; $term[1] is term id.
if ( isset( $term[0] ) && isset( $term[1] ) ) {
$term[1] = self::maybe_get_split_term( $term[1], $term[0] );
}
@@ -987,7 +1010,7 @@ class Jetpack_Widget_Conditions {
if ( is_tax( $term[0] ) ) {
$condition_result = true;
} elseif ( is_singular() ) {
- if ( in_array( $term[0], get_post_taxonomies() ) ) {
+ if ( in_array( $term[0], get_post_taxonomies(), true ) ) {
$condition_result = true;
}
}
@@ -1017,7 +1040,7 @@ class Jetpack_Widget_Conditions {
&& ! $condition_result
) {
- // In case the match_all flag was set we quit on first failed condition
+ // In case the match_all flag was set we quit on first failed condition.
break;
} elseif (
(
@@ -1027,7 +1050,7 @@ class Jetpack_Widget_Conditions {
&& $condition_result
) {
- // Only quit on first condition if the match_all flag was not set
+ // Only quit on first condition if the match_all flag was not set.
break;
}
}
@@ -1047,18 +1070,31 @@ class Jetpack_Widget_Conditions {
return true;
}
+ /**
+ * Helper function wrapping strcasecmp to compare term names.
+ *
+ * @param string $a str1.
+ * @param string $b str2.
+ */
public static function strcasecmp_name( $a, $b ) {
return strcasecmp( $a->name, $b->name );
}
+ /**
+ * Determine if provided term has been split.
+ *
+ * @param int $old_term_id Old term id to test.
+ * @param string $taxonomy Taxonmy that $old_term_id belongs to.
+ */
public static function maybe_get_split_term( $old_term_id = '', $taxonomy = '' ) {
$term_id = $old_term_id;
- if ( 'tag' == $taxonomy ) {
+ if ( 'tag' === $taxonomy ) {
$taxonomy = 'post_tag';
}
- if ( $new_term_id = wp_get_split_term( $old_term_id, $taxonomy ) ) {
+ $new_term_id = wp_get_split_term( $old_term_id, $taxonomy );
+ if ( $new_term_id ) {
$term_id = $new_term_id;
}
@@ -1071,18 +1107,18 @@ class Jetpack_Widget_Conditions {
*
* @since 4.7.1
*/
- static function migrate_post_type_rules() {
+ public static function migrate_post_type_rules() {
global $wp_registered_widgets;
$sidebars_widgets = get_option( 'sidebars_widgets' );
- // Going through all sidebars and through inactive and orphaned widgets
- foreach ( $sidebars_widgets as $s => $sidebar ) {
+ // Going through all sidebars and through inactive and orphaned widgets.
+ foreach ( $sidebars_widgets as $sidebar ) {
if ( ! is_array( $sidebar ) ) {
continue;
}
- foreach ( $sidebar as $w => $widget ) {
+ foreach ( $sidebar as $widget ) {
// $widget is the id of the widget
if ( empty( $wp_registered_widgets[ $widget ] ) ) {
continue;
@@ -1091,7 +1127,11 @@ class Jetpack_Widget_Conditions {
$opts = $wp_registered_widgets[ $widget ];
$instances = get_option( $opts['callback'][0]->option_name );
- // Going through each instance of the widget
+ if ( ! is_array( $instances ) || empty( $instances ) ) {
+ continue;
+ }
+
+ // Going through each instance of the widget.
foreach ( $instances as $number => $instance ) {
if (
! is_array( $instance ) ||
@@ -1101,17 +1141,17 @@ class Jetpack_Widget_Conditions {
continue;
}
- // Going through all visibility rules
+ // Going through all visibility rules.
foreach ( $instance['conditions']['rules'] as $index => $rule ) {
- // We only need Post Type rules
+ // We only need Post Type rules.
if ( 'post_type' !== $rule['major'] ) {
continue;
}
$rule_type = false;
- // Post type or type archive rule
+ // Post type or type archive rule.
if ( 0 === strpos( $rule['minor'], 'post_type_archive' ) ) {
$rule_type = 'post_type_archive';
} elseif ( 0 === strpos( $rule['minor'], 'post_type' ) ) {
diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.css b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.css
index 70846d82..c28b7587 100644
--- a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.css
+++ b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.css
@@ -1,211 +1,229 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-.wp-customizer .expanded .widget-conditional .widget-conditional-inner {
- width: 98%; /* Safari/Chrome, other WebKit */ /* Firefox, other Gecko */
- box-sizing: border-box;
+.wp-customizer .expanded .widget-conditional .widget-conditional-inner {
+ width: 98%;
+ /* Safari/Chrome, other WebKit */
+ /* Firefox, other Gecko */
+ box-sizing: border-box;
}
-.wp-customizer .expanded .widget-conditional .form{
- overflow: scroll;
- margin-bottom: 20px;
+.wp-customizer .expanded .widget-conditional .form {
+ overflow: scroll;
+ margin-bottom: 20px;
}
+
.widget-liquid-right .widget.expanded {
- overflow: visible;
+ overflow: visible;
}
+
.widget-conditional-hide {
- display: none;
+ display: none;
}
-.widget-conditional .widget-conditional-inner {
- background: #f6f7f7;
- border: 1px solid #dcdcde;
- padding: 12px 10px 0;
+.widget-conditional .widget-conditional-inner {
+ background: #f6f7f7;
+ border: 1px solid #dcdcde;
+ padding: 12px 10px 0;
}
+
.widget-conditional {
- margin-bottom: 12px;
- margin-top: 10px;
+ margin-bottom: 12px;
+ margin-top: 10px;
}
-.widget-conditional .conditions{
- margin-bottom: 12px;
+
+.widget-conditional .conditions {
+ margin-bottom: 12px;
}
+
.widget-conditional .condition,
.widget-conditional .condition-top {
- clear:both;
+ clear: both;
}
+
.widget-conditional .condition {
- padding-top: 12px;
- position: relative;
+ padding-top: 12px;
+ position: relative;
}
+
.widget-conditional .condition select {
- width: 120px;
- position: relative;
- z-index: 2;
+ width: 120px;
+ position: relative;
+ z-index: 2;
}
+
.widget-conditional .condition-top select {
- width: auto;
+ width: auto;
}
+
.widget-conditional .condition-control {
- padding-top: 4px;
- clear: both;
- margin-top: -20px;
+ padding-top: 4px;
+ clear: both;
+ margin-top: -20px;
}
+
.widget-conditional .selection {
- margin-left: 50px;
- margin-right: 20px;
+ margin-left: 50px;
+ margin-right: 20px;
}
+
.widget-conditional .conditions-rule-has-children {
- display: block;
+ display: block;
}
+
+.widget-conditional .condition .actions {
+ margin-top: -28px;
+}
+
.widget-conditional .condition .actions {
- margin-top: -28px;
-}.widget-conditional .condition .actions {
- margin-top: -28px;
+ margin-top: -28px;
}
.widget-conditional .condition-control a {
- text-decoration: none;
- position: absolute;
- top: 17px;
- text-indent: -9999px;
- z-index: 1;
+ text-decoration: none;
+ position: absolute;
+ top: 17px;
+ text-indent: -9999px;
+ z-index: 1;
}
.wp-block-legacy-widget__edit-form .widget-conditional .condition-control a {
- top: 20px;
+ top: 20px;
}
.widget-conditional .condition-control a:before {
- position: absolute;
- text-indent: 0;
- top: 0;
- right: 0;
+ position: absolute;
+ text-indent: 0;
+ top: 0;
+ right: 0;
}
+
.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .condition-control .delete-condition,
.widget-conditional .condition-control .delete-condition {
- right: 0;
- color: #f11;
+ right: 0;
+ color: #f11;
}
+
.widget-conditional .condition-control .add-condition {
- left: 0;
+ left: 0;
}
.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .widget-conditional-inner a.dashicons {
- font-family: dashicons;
+ font-family: dashicons;
}
.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional-inner select {
- display:initial;
- width:auto;
- background-color: #fff;
+ display: initial;
+ width: auto;
+ background-color: #fff;
}
.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .widget-conditional-inner select:disabled {
- color: #a7aaad;
- border-color: #dcdcde;
- background-color: #f6f7f7;
+ color: #a7aaad;
+ border-color: #dcdcde;
+ background-color: #f6f7f7;
}
-.editor-styles-wrapper .wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .alignleft {
- margin-right:20px
+.editor-styles-wrapper .wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .alignleft {
+ margin-right: 20px;
}
.widget-conditional .condition:last-child .condition-conjunction,
.widget-conditional .condition:last-child .condition-intersection {
- display: none;
+ display: none;
}
.widget-conditional.conjunction .condition-intersection {
- display: none;
+ display: none;
}
.widget-conditional.intersection .condition-conjunction {
- display: none;
+ display: none;
}
.wp-core-ui .button.display-options {
- margin-left: 5px;
+ margin-left: 5px;
}
+
.wp-core-ui .button.display-options:hover {
- text-decoration: none;
+ text-decoration: none;
}
.wp-customizer .widget-conditional select {
- min-width: 0;
- max-width: none;
- height: auto;
+ min-width: 0;
+ max-width: none;
+ height: auto;
}
+
.wp-customizer .widget-conditional .condition-control a {
- top: 15px;
-}
-@media screen and ( max-width: 782px ) {
- .widget-conditional .condition-control a {
- top: 20px;
- }
+ top: 15px;
}
+@media screen and (max-width: 782px) {
+ .widget-conditional .condition-control a {
+ top: 20px;
+ }
+}
.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional-inner {
- /*
- * fonts of labels are reset to 13px in gutenberg editor for legacy widgets, ensure a consistent look on non-labels
- */
- font-size: 13px;
+ /*
+ * fonts of labels are reset to 13px in gutenberg editor for legacy widgets, ensure a consistent look on non-labels
+ */
+ font-size: 13px;
}
/*
* Rules for gutenberg advanced panel
*/
-
- .widget-vis__wrapper .components-base-control,
- .widget-vis__rule .components-base-control {
- margin-bottom: 12px;
- }
+.widget-vis__wrapper .components-base-control,
+.widget-vis__rule .components-base-control {
+ margin-bottom: 12px;
+}
.widget-vis__rule {
- padding: 12px;
- border: 1px solid #dcdcde;
- display: flex;
- flex-direction: column;
- margin-bottom: 12px;
+ padding: 12px;
+ border: 1px solid #dcdcde;
+ display: flex;
+ flex-direction: column;
+ margin-bottom: 12px;
}
.widget-vis__rule-major,
.widget-vis__rule-minor {
- display: flex;
- justify-content: stretch;
- align-items: center;
+ display: flex;
+ justify-content: stretch;
+ align-items: center;
}
.widget-vis__if,
.widget-vis__is {
- margin-left: 8px;
- width: 10px;
+ margin-left: 8px;
+ width: 10px;
}
.widget-vis__show-hide {
- margin-bottom: 0;
+ margin-bottom: 0;
}
.components-button.widget-vis__add-new-rule {
- display: block;
+ display: block;
}
.widget-vis__delete-rule {
- margin-top: 6px;
- text-align: left;
+ margin-top: 6px;
+ text-align: left;
}
.widget-vis__match-all {
- margin-top: 12px;
+ margin-top: 12px;
}
.widget-vis__select {
- width: 100%;
+ width: 100%;
}
.widget-vis__select .components-input-control__container {
- position: relative;
- top: 4px;
+ position: relative;
+ top: 4px;
}
.widget-vis__select-multi-level select option:disabled {
- font-size: 18px;
- font-weight: 600;
+ font-size: 18px;
+ font-weight: 600;
}
diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.min.css b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.min.css
index 4c394d18..36cc9cd6 100644
--- a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.min.css
+++ b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.min.css
@@ -1 +1 @@
-.wp-customizer .expanded .widget-conditional .widget-conditional-inner{width:98%;box-sizing:border-box}.wp-customizer .expanded .widget-conditional .form{overflow:scroll;margin-bottom:20px}.widget-liquid-right .widget.expanded{overflow:visible}.widget-conditional-hide{display:none}.widget-conditional .widget-conditional-inner{background:#f6f7f7;border:1px solid #dcdcde;padding:12px 10px 0}.widget-conditional{margin-bottom:12px;margin-top:10px}.widget-conditional .conditions{margin-bottom:12px}.widget-conditional .condition,.widget-conditional .condition-top{clear:both}.widget-conditional .condition{padding-top:12px;position:relative}.widget-conditional .condition select{width:120px;position:relative;z-index:2}.widget-conditional .condition-top select{width:auto}.widget-conditional .condition-control{padding-top:4px;clear:both;margin-top:-20px}.widget-conditional .selection{margin-left:50px;margin-right:20px}.widget-conditional .conditions-rule-has-children{display:block}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition-control a{text-decoration:none;position:absolute;top:17px;text-indent:-9999px;z-index:1}.wp-block-legacy-widget__edit-form .widget-conditional .condition-control a{top:20px}.widget-conditional .condition-control a:before{position:absolute;text-indent:0;top:0;right:0}.widget-conditional .condition-control .delete-condition,.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .condition-control .delete-condition{right:0;color:#f11}.widget-conditional .condition-control .add-condition{left:0}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .widget-conditional-inner a.dashicons{font-family:dashicons}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional-inner select{display:initial;width:auto;background-color:#fff}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .widget-conditional-inner select:disabled{color:#a7aaad;border-color:#dcdcde;background-color:#f6f7f7}.editor-styles-wrapper .wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .alignleft{margin-right:20px}.widget-conditional .condition:last-child .condition-conjunction,.widget-conditional .condition:last-child .condition-intersection{display:none}.widget-conditional.conjunction .condition-intersection{display:none}.widget-conditional.intersection .condition-conjunction{display:none}.wp-core-ui .button.display-options{margin-left:5px}.wp-core-ui .button.display-options:hover{text-decoration:none}.wp-customizer .widget-conditional select{min-width:0;max-width:none;height:auto}.wp-customizer .widget-conditional .condition-control a{top:15px}@media screen and (max-width:782px){.widget-conditional .condition-control a{top:20px}}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional-inner{font-size:13px}.widget-vis__rule .components-base-control,.widget-vis__wrapper .components-base-control{margin-bottom:12px}.widget-vis__rule{padding:12px;border:1px solid #dcdcde;display:flex;flex-direction:column;margin-bottom:12px}.widget-vis__rule-major,.widget-vis__rule-minor{display:flex;justify-content:stretch;align-items:center}.widget-vis__if,.widget-vis__is{margin-left:8px;width:10px}.widget-vis__show-hide{margin-bottom:0}.components-button.widget-vis__add-new-rule{display:block}.widget-vis__delete-rule{margin-top:6px;text-align:left}.widget-vis__match-all{margin-top:12px}.widget-vis__select{width:100%}.widget-vis__select .components-input-control__container{position:relative;top:4px}.widget-vis__select-multi-level select option:disabled{font-size:18px;font-weight:600} \ No newline at end of file
+.wp-customizer .expanded .widget-conditional .widget-conditional-inner{box-sizing:border-box;width:98%}.wp-customizer .expanded .widget-conditional .form{margin-bottom:20px;overflow:scroll}.widget-liquid-right .widget.expanded{overflow:visible}.widget-conditional-hide{display:none}.widget-conditional .widget-conditional-inner{background:#f6f7f7;border:1px solid #dcdcde;padding:12px 10px 0}.widget-conditional{margin-bottom:12px;margin-top:10px}.widget-conditional .conditions{margin-bottom:12px}.widget-conditional .condition,.widget-conditional .condition-top{clear:both}.widget-conditional .condition{padding-top:12px;position:relative}.widget-conditional .condition select{position:relative;width:120px;z-index:2}.widget-conditional .condition-top select{width:auto}.widget-conditional .condition-control{clear:both;margin-top:-20px;padding-top:4px}.widget-conditional .selection{margin-left:50px;margin-right:20px}.widget-conditional .conditions-rule-has-children{display:block}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition-control a{position:absolute;text-decoration:none;text-indent:-9999px;top:17px;z-index:1}.wp-block-legacy-widget__edit-form .widget-conditional .condition-control a{top:20px}.widget-conditional .condition-control a:before{position:absolute;right:0;text-indent:0;top:0}.widget-conditional .condition-control .delete-condition,.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .condition-control .delete-condition{color:#f11;right:0}.widget-conditional .condition-control .add-condition{left:0}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .widget-conditional-inner a.dashicons{font-family:dashicons}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional-inner select{background-color:#fff;display:initial;width:auto}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .widget-conditional-inner select:disabled{background-color:#f6f7f7;border-color:#dcdcde;color:#a7aaad}.editor-styles-wrapper .wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .alignleft{margin-right:20px}.widget-conditional .condition:last-child .condition-conjunction,.widget-conditional .condition:last-child .condition-intersection,.widget-conditional.conjunction .condition-intersection,.widget-conditional.intersection .condition-conjunction{display:none}.wp-core-ui .button.display-options{margin-left:5px}.wp-core-ui .button.display-options:hover{text-decoration:none}.wp-customizer .widget-conditional select{height:auto;max-width:none;min-width:0}.wp-customizer .widget-conditional .condition-control a{top:15px}@media screen and (max-width:782px){.widget-conditional .condition-control a{top:20px}}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional-inner{font-size:13px}.widget-vis__rule,.widget-vis__rule .components-base-control,.widget-vis__wrapper .components-base-control{margin-bottom:12px}.widget-vis__rule{border:1px solid #dcdcde;display:flex;flex-direction:column;padding:12px}.widget-vis__rule-major,.widget-vis__rule-minor{align-items:center;display:flex;justify-content:stretch}.widget-vis__if,.widget-vis__is{margin-left:8px;width:10px}.widget-vis__show-hide{margin-bottom:0}.components-button.widget-vis__add-new-rule{display:block}.widget-vis__delete-rule{margin-top:6px;text-align:left}.widget-vis__match-all{margin-top:12px}.widget-vis__select{width:100%}.widget-vis__select .components-input-control__container{position:relative;top:4px}.widget-vis__select-multi-level select option:disabled{font-size:18px;font-weight:600} \ No newline at end of file
diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.min.css b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.min.css
index f03127fb..a0a0ecc4 100644
--- a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.min.css
+++ b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-.wp-customizer .expanded .widget-conditional .widget-conditional-inner{width:98%;box-sizing:border-box}.wp-customizer .expanded .widget-conditional .form{overflow:scroll;margin-bottom:20px}.widget-liquid-right .widget.expanded{overflow:visible}.widget-conditional-hide{display:none}.widget-conditional .widget-conditional-inner{background:#f6f7f7;border:1px solid #dcdcde;padding:12px 10px 0}.widget-conditional{margin-bottom:12px;margin-top:10px}.widget-conditional .conditions{margin-bottom:12px}.widget-conditional .condition,.widget-conditional .condition-top{clear:both}.widget-conditional .condition{padding-top:12px;position:relative}.widget-conditional .condition select{width:120px;position:relative;z-index:2}.widget-conditional .condition-top select{width:auto}.widget-conditional .condition-control{padding-top:4px;clear:both;margin-top:-20px}.widget-conditional .selection{margin-right:50px;margin-left:20px}.widget-conditional .conditions-rule-has-children{display:block}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition-control a{text-decoration:none;position:absolute;top:17px;text-indent:-9999px;z-index:1}.wp-block-legacy-widget__edit-form .widget-conditional .condition-control a{top:20px}.widget-conditional .condition-control a:before{position:absolute;text-indent:0;top:0;left:0}.widget-conditional .condition-control .delete-condition,.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .condition-control .delete-condition{left:0;color:#f11}.widget-conditional .condition-control .add-condition{right:0}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .widget-conditional-inner a.dashicons{font-family:dashicons}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional-inner select{display:initial;width:auto;background-color:#fff}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .widget-conditional-inner select:disabled{color:#a7aaad;border-color:#dcdcde;background-color:#f6f7f7}.editor-styles-wrapper .wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .alignleft{margin-left:20px}.widget-conditional .condition:last-child .condition-conjunction,.widget-conditional .condition:last-child .condition-intersection{display:none}.widget-conditional.conjunction .condition-intersection{display:none}.widget-conditional.intersection .condition-conjunction{display:none}.wp-core-ui .button.display-options{margin-right:5px}.wp-core-ui .button.display-options:hover{text-decoration:none}.wp-customizer .widget-conditional select{min-width:0;max-width:none;height:auto}.wp-customizer .widget-conditional .condition-control a{top:15px}@media screen and (max-width:782px){.widget-conditional .condition-control a{top:20px}}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional-inner{font-size:13px}.widget-vis__rule .components-base-control,.widget-vis__wrapper .components-base-control{margin-bottom:12px}.widget-vis__rule{padding:12px;border:1px solid #dcdcde;display:flex;flex-direction:column;margin-bottom:12px}.widget-vis__rule-major,.widget-vis__rule-minor{display:flex;justify-content:stretch;align-items:center}.widget-vis__if,.widget-vis__is{margin-right:8px;width:10px}.widget-vis__show-hide{margin-bottom:0}.components-button.widget-vis__add-new-rule{display:block}.widget-vis__delete-rule{margin-top:6px;text-align:right}.widget-vis__match-all{margin-top:12px}.widget-vis__select{width:100%}.widget-vis__select .components-input-control__container{position:relative;top:4px}.widget-vis__select-multi-level select option:disabled{font-size:18px;font-weight:600} \ No newline at end of file
+.wp-customizer .expanded .widget-conditional .widget-conditional-inner{box-sizing:border-box;width:98%}.wp-customizer .expanded .widget-conditional .form{margin-bottom:20px;overflow:scroll}.widget-liquid-right .widget.expanded{overflow:visible}.widget-conditional-hide{display:none}.widget-conditional .widget-conditional-inner{background:#f6f7f7;border:1px solid #dcdcde;padding:12px 10px 0}.widget-conditional{margin-bottom:12px;margin-top:10px}.widget-conditional .conditions{margin-bottom:12px}.widget-conditional .condition,.widget-conditional .condition-top{clear:both}.widget-conditional .condition{padding-top:12px;position:relative}.widget-conditional .condition select{position:relative;width:120px;z-index:2}.widget-conditional .condition-top select{width:auto}.widget-conditional .condition-control{clear:both;margin-top:-20px;padding-top:4px}.widget-conditional .selection{margin-left:20px;margin-right:50px}.widget-conditional .conditions-rule-has-children{display:block}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition-control a{position:absolute;text-decoration:none;text-indent:-9999px;top:17px;z-index:1}.wp-block-legacy-widget__edit-form .widget-conditional .condition-control a{top:20px}.widget-conditional .condition-control a:before{left:0;position:absolute;text-indent:0;top:0}.widget-conditional .condition-control .delete-condition,.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .condition-control .delete-condition{color:#f11;left:0}.widget-conditional .condition-control .add-condition{right:0}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .widget-conditional-inner a.dashicons{font-family:dashicons}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional-inner select{background-color:#fff;display:initial;width:auto}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .widget-conditional-inner select:disabled{background-color:#f6f7f7;border-color:#dcdcde;color:#a7aaad}.editor-styles-wrapper .wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional .alignleft{margin-left:20px}.widget-conditional .condition:last-child .condition-conjunction,.widget-conditional .condition:last-child .condition-intersection,.widget-conditional.conjunction .condition-intersection,.widget-conditional.intersection .condition-conjunction{display:none}.wp-core-ui .button.display-options{margin-right:5px}.wp-core-ui .button.display-options:hover{text-decoration:none}.wp-customizer .widget-conditional select{height:auto;max-width:none;min-width:0}.wp-customizer .widget-conditional .condition-control a{top:15px}@media screen and (max-width:782px){.widget-conditional .condition-control a{top:20px}}.wp-block-legacy-widget__edit-form .widget-inside.widget-inside .widget-conditional-inner{font-size:13px}.widget-vis__rule,.widget-vis__rule .components-base-control,.widget-vis__wrapper .components-base-control{margin-bottom:12px}.widget-vis__rule{border:1px solid #dcdcde;display:flex;flex-direction:column;padding:12px}.widget-vis__rule-major,.widget-vis__rule-minor{align-items:center;display:flex;justify-content:stretch}.widget-vis__if,.widget-vis__is{margin-right:8px;width:10px}.widget-vis__show-hide{margin-bottom:0}.components-button.widget-vis__add-new-rule{display:block}.widget-vis__delete-rule{margin-top:6px;text-align:right}.widget-vis__match-all{margin-top:12px}.widget-vis__select{width:100%}.widget-vis__select .components-input-control__container{position:relative;top:4px}.widget-vis__select-multi-level select option:disabled{font-size:18px;font-weight:600} \ No newline at end of file
diff --git a/plugins/jetpack/modules/widgets.php b/plugins/jetpack/modules/widgets.php
index 84ad7cd0..83231dbc 100644
--- a/plugins/jetpack/modules/widgets.php
+++ b/plugins/jetpack/modules/widgets.php
@@ -9,12 +9,17 @@
* Module Tags: Social, Appearance
* Feature: Appearance
* Additional Search Queries: widget, widgets, facebook, gallery, twitter, gravatar, image, rss
+ *
+ * @package automattic/jetpack
*/
+/**
+ * Load Jetpack widget files.
+ */
function jetpack_load_widgets() {
$widgets_include = array();
- foreach ( Jetpack::glob_php( dirname( __FILE__ ) . '/widgets' ) as $file ) {
+ foreach ( Jetpack::glob_php( __DIR__ . '/widgets' ) as $file ) {
$widgets_include[] = $file;
}
/**
@@ -28,16 +33,18 @@ function jetpack_load_widgets() {
*/
$widgets_include = apply_filters( 'jetpack_widgets_to_include', $widgets_include );
- foreach( $widgets_include as $include ) {
+ foreach ( $widgets_include as $include ) {
include_once $include;
}
- include_once dirname( __FILE__ ) . '/widgets/migrate-to-core/image-widget.php';
- include_once dirname( __FILE__ ) . '/widgets/migrate-to-core/gallery-widget.php';
+ include_once __DIR__ . '/widgets/migrate-to-core/image-widget.php';
+ include_once __DIR__ . '/widgets/migrate-to-core/gallery-widget.php';
}
add_action( 'jetpack_modules_loaded', 'jetpack_widgets_loaded' );
-
+/**
+ * Actions to perform after Jetpack widgets are loaded.
+ */
function jetpack_widgets_loaded() {
Jetpack::enable_module_configurable( __FILE__ );
add_filter( 'jetpack_module_configuration_url_widgets', 'jetpack_widgets_configuration_url' );
@@ -61,7 +68,13 @@ jetpack_load_widgets();
* @since 4.4.0
*/
function jetpack_widgets_customizer_assets_preview() {
- wp_enqueue_script( 'jetpack-customizer-widget-utils', plugins_url( '/widgets/customizer-utils.js', __FILE__ ), array( 'customize-base' ) );
+ wp_enqueue_script(
+ 'jetpack-customizer-widget-utils',
+ plugins_url( '/widgets/customizer-utils.js', __FILE__ ),
+ array( 'customize-base' ),
+ JETPACK__VERSION,
+ false
+ );
}
add_action( 'customize_preview_init', 'jetpack_widgets_customizer_assets_preview' );
@@ -71,10 +84,18 @@ add_action( 'customize_preview_init', 'jetpack_widgets_customizer_assets_preview
* @since 4.4.0
*/
function jetpack_widgets_customizer_assets_controls() {
- wp_enqueue_style( 'jetpack-customizer-widget-controls', plugins_url( '/widgets/customizer-controls.css', __FILE__ ), array( 'customize-widgets' ) );
+ wp_enqueue_style(
+ 'jetpack-customizer-widget-controls',
+ plugins_url( '/widgets/customizer-controls.css', __FILE__ ),
+ array( 'customize-widgets' ),
+ JETPACK__VERSION
+ );
}
add_action( 'customize_controls_enqueue_scripts', 'jetpack_widgets_customizer_assets_controls' );
+/**
+ * Cleanup old Jetpack widgets data.
+ */
function jetpack_widgets_remove_old_widgets() {
$old_widgets = array(
'googleplus-badge',
diff --git a/plugins/jetpack/modules/widgets/authors.php b/plugins/jetpack/modules/widgets/authors.php
index 402794fc..d56f2ec3 100644
--- a/plugins/jetpack/modules/widgets/authors.php
+++ b/plugins/jetpack/modules/widgets/authors.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Disable direct access/execution to/of the widget code.
*/
@@ -17,6 +17,9 @@ if ( ! defined( 'ABSPATH' ) ) {
* @since 4.5.0
*/
class Jetpack_Widget_Authors extends WP_Widget {
+ /**
+ * Jetpack_Widget_Authors contructor.
+ */
public function __construct() {
parent::__construct(
'authors',
@@ -43,22 +46,32 @@ class Jetpack_Widget_Authors extends WP_Widget {
*
* @since 4.5.0
*/
- function enqueue_style() {
+ public function enqueue_style() {
wp_register_style( 'jetpack-authors-widget', plugins_url( 'authors/style.css', __FILE__ ), array(), '20161228' );
wp_enqueue_style( 'jetpack-authors-widget' );
}
+ /**
+ * Flush Authors widget cached data.
+ */
public static function flush_cache() {
wp_cache_delete( 'widget_authors', 'widget' );
wp_cache_delete( 'widget_authors_ssl', 'widget' );
}
+ /**
+ * Echoes the widget content.
+ *
+ * @param array $args Display arguments.
+ * @param array $instance Widget settings for the instance.
+ */
public function widget( $args, $instance ) {
$cache_bucket = is_ssl() ? 'widget_authors_ssl' : 'widget_authors';
- if ( '%BEG_OF_TITLE%' != $args['before_title'] ) {
- if ( $output = wp_cache_get( $cache_bucket, 'widget' ) ) {
- echo $output;
+ if ( '%BEG_OF_TITLE%' !== $args['before_title'] ) {
+ $output = wp_cache_get( $cache_bucket, 'widget' );
+ if ( $output ) {
+ echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Cached widget display.
return;
}
@@ -66,7 +79,8 @@ class Jetpack_Widget_Authors extends WP_Widget {
}
$instance = wp_parse_args(
- $instance, array(
+ $instance,
+ array(
'title' => __( 'Authors', 'jetpack' ),
'all' => false,
'number' => 5,
@@ -75,7 +89,7 @@ class Jetpack_Widget_Authors extends WP_Widget {
);
$instance['number'] = min( 10, max( 0, (int) $instance['number'] ) );
- // We need to query at least one post to determine whether an author has written any posts or not
+ // We need to query at least one post to determine whether an author has written any posts or not.
$query_number = max( $instance['number'], 1 );
/**
@@ -106,14 +120,14 @@ class Jetpack_Widget_Authors extends WP_Widget {
$get_author_params = apply_filters(
'jetpack_widget_authors_params',
array(
- 'who' => 'authors',
- 'exclude' => (array) $excluded_authors,
+ 'capability' => array( 'edit_posts' ),
+ 'exclude' => (array) $excluded_authors,
)
);
$authors = get_users( $get_author_params );
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/** This filter is documented in core/src/wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', $instance['title'] );
echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -149,9 +163,9 @@ class Jetpack_Widget_Authors extends WP_Widget {
echo '<li>';
- // Display avatar and author name
+ // Display avatar and author name.
if ( $r->have_posts() ) {
- echo '<a href="' . get_author_posts_url( $author->ID ) . '">';
+ echo '<a href="' . esc_url( get_author_posts_url( $author->ID ) ) . '">';
if ( $instance['avatar_size'] > 1 ) {
echo ' ' . get_avatar( $author->ID, $instance['avatar_size'], '', true ) . ' ';
@@ -167,7 +181,7 @@ class Jetpack_Widget_Authors extends WP_Widget {
echo '<strong>' . esc_html( $author->display_name ) . '</strong>';
}
- if ( 0 == $instance['number'] ) {
+ if ( 0 === (int) $instance['number'] ) {
echo '</li>';
continue;
}
@@ -195,11 +209,11 @@ class Jetpack_Widget_Authors extends WP_Widget {
}
echo '</ul>';
- echo $args['after_widget'];
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
wp_reset_postdata();
- if ( '%BEG_OF_TITLE%' != $args['before_title'] ) {
+ if ( '%BEG_OF_TITLE%' !== $args['before_title'] ) {
wp_cache_add( $cache_bucket, ob_get_flush(), 'widget' );
}
@@ -207,9 +221,15 @@ class Jetpack_Widget_Authors extends WP_Widget {
do_action( 'jetpack_stats_extra', 'widget_view', 'authors' );
}
+ /**
+ * Outputs the widget settings form.
+ *
+ * @param array $instance Current settings.
+ */
public function form( $instance ) {
$instance = wp_parse_args(
- $instance, array(
+ $instance,
+ array(
'title' => '',
'all' => false,
'avatar_size' => 48,
@@ -220,27 +240,27 @@ class Jetpack_Widget_Authors extends WP_Widget {
?>
<p>
<label>
- <?php _e( 'Title:', 'jetpack' ); ?>
- <input class="widefat" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
+ <?php esc_html_e( 'Title:', 'jetpack' ); ?>
+ <input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
</label>
</p>
<p>
<label>
- <input class="checkbox" type="checkbox" <?php checked( $instance['all'] ); ?> name="<?php echo $this->get_field_name( 'all' ); ?>" />
- <?php _e( 'Display all authors (including those who have not written any posts)', 'jetpack' ); ?>
+ <input class="checkbox" type="checkbox" <?php checked( $instance['all'] ); ?> name="<?php echo esc_attr( $this->get_field_name( 'all' ) ); ?>" />
+ <?php esc_html_e( 'Display all authors (including those who have not written any posts)', 'jetpack' ); ?>
</label>
</p>
<p>
<label>
- <?php _e( 'Number of posts to show for each author:', 'jetpack' ); ?>
- <input style="width: 50px; text-align: center;" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo esc_attr( $instance['number'] ); ?>" />
- <?php _e( '(at most 10)', 'jetpack' ); ?>
+ <?php esc_html_e( 'Number of posts to show for each author:', 'jetpack' ); ?>
+ <input style="width: 50px; text-align: center;" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['number'] ); ?>" />
+ <?php esc_html_e( '(at most 10)', 'jetpack' ); ?>
</label>
</p>
<p>
<label>
- <?php _e( 'Avatar Size (px):', 'jetpack' ); ?>
- <select name="<?php echo $this->get_field_name( 'avatar_size' ); ?>">
+ <?php esc_html_e( 'Avatar Size (px):', 'jetpack' ); ?>
+ <select name="<?php echo esc_attr( $this->get_field_name( 'avatar_size' ) ); ?>">
<?php
foreach ( array(
'1' => __( 'No Avatars', 'jetpack' ),
@@ -250,7 +270,7 @@ class Jetpack_Widget_Authors extends WP_Widget {
'96' => '96x96',
'128' => '128x128',
) as $value => $label ) {
-?>
+ ?>
<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, $instance['avatar_size'] ); ?>><?php echo esc_html( $label ); ?></option>
<?php } ?>
</select>
@@ -262,23 +282,26 @@ class Jetpack_Widget_Authors extends WP_Widget {
/**
* Updates the widget on save and flushes cache.
*
- * @param array $new_instance
- * @param array $old_instance
+ * @param array $new_instance New widget instance data.
+ * @param array $old_instance Old widget instance data.
* @return array
*/
- public function update( $new_instance, $old_instance ) {
- $new_instance['title'] = strip_tags( $new_instance['title'] );
+ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
+ $new_instance['title'] = wp_strip_all_tags( $new_instance['title'] );
$new_instance['all'] = isset( $new_instance['all'] );
$new_instance['number'] = (int) $new_instance['number'];
$new_instance['avatar_size'] = (int) $new_instance['avatar_size'];
- Jetpack_Widget_Authors::flush_cache();
+ self::flush_cache();
return $new_instance;
}
}
add_action( 'widgets_init', 'jetpack_register_widget_authors' );
+/**
+ * Register the Authors widget.
+ */
function jetpack_register_widget_authors() {
register_widget( 'Jetpack_Widget_Authors' );
-};
+}
diff --git a/plugins/jetpack/modules/widgets/blog-stats.php b/plugins/jetpack/modules/widgets/blog-stats.php
index 7265d114..5fb03e8b 100644
--- a/plugins/jetpack/modules/widgets/blog-stats.php
+++ b/plugins/jetpack/modules/widgets/blog-stats.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileNam
/**
* Blog Stats Widget.
*
@@ -26,7 +26,7 @@ class Jetpack_Blog_Stats_Widget extends WP_Widget {
/**
* Constructor
*/
- function __construct() {
+ public function __construct() {
$widget_ops = array(
'classname' => 'blog-stats',
'description' => esc_html__( 'Show a hit counter for your blog.', 'jetpack' ),
@@ -85,7 +85,7 @@ class Jetpack_Blog_Stats_Widget extends WP_Widget {
*
* @return void
*/
- function form( $instance ) {
+ public function form( $instance ) {
$instance = wp_parse_args( $instance, $this->defaults() );
?>
@@ -112,7 +112,7 @@ class Jetpack_Blog_Stats_Widget extends WP_Widget {
*
* @return array Updated safe values to be saved.
*/
- function update( $new_instance, $old_instance ) {
+ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$instance = array();
$instance['title'] = wp_kses( $new_instance['title'], array() );
$instance['hits'] = wp_kses( $new_instance['hits'], array() );
@@ -128,13 +128,13 @@ class Jetpack_Blog_Stats_Widget extends WP_Widget {
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
- function widget( $args, $instance ) {
+ public function widget( $args, $instance ) {
$instance = wp_parse_args( $instance, $this->defaults() );
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
$title = apply_filters( 'widget_title', $instance['title'] );
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( ! empty( $title ) ) {
echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -155,7 +155,7 @@ class Jetpack_Blog_Stats_Widget extends WP_Widget {
esc_html_e( 'There was an issue retrieving stats. Please try again later.', 'jetpack' );
}
- echo $args['after_widget'];
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/** This action is already documented in modules/widgets/gravatar-profile.php */
do_action( 'jetpack_stats_extra', 'widget_view', 'blog_stats' );
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law.php b/plugins/jetpack/modules/widgets/class-jetpack-eu-cookie-law-widget.php
index fffc9724..3207c85f 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law.php
+++ b/plugins/jetpack/modules/widgets/class-jetpack-eu-cookie-law-widget.php
@@ -1,4 +1,9 @@
<?php
+/**
+ * Main class file for EU Cookie Law Widget.
+ *
+ * @package automattic/jetpack
+ */
use Automattic\Jetpack\Assets;
@@ -77,7 +82,7 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
/**
* Constructor.
*/
- function __construct() {
+ public function __construct() {
parent::__construct(
'eu_cookie_law_widget',
/** This filter is documented in modules/widgets/facebook-likebox.php */
@@ -97,7 +102,7 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
/**
* Enqueue scripts and styles.
*/
- function enqueue_frontend_scripts() {
+ public function enqueue_frontend_scripts() {
wp_enqueue_style( 'eu-cookie-law-style', plugins_url( 'eu-cookie-law/style.css', __FILE__ ), array(), JETPACK__VERSION );
if ( ! class_exists( 'Jetpack_AMP_Support' ) || ! Jetpack_AMP_Support::is_amp_request() ) {
@@ -160,7 +165,7 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
$instance = wp_parse_args( $instance, $this->defaults() );
if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
- require dirname( __FILE__ ) . '/eu-cookie-law/widget-amp.php';
+ require __DIR__ . '/eu-cookie-law/widget-amp.php';
return;
}
@@ -196,9 +201,9 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
return;
}
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
require_once __DIR__ . '/eu-cookie-law/widget.php';
- echo $args['after_widget'];
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/** This action is already documented in modules/widgets/gravatar-profile.php */
do_action( 'jetpack_stats_extra', 'widget_view', 'eu_cookie_law' );
@@ -222,20 +227,21 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
'modules/widgets/eu-cookie-law/eu-cookie-law-admin.js'
),
array( 'jquery' ),
- 20180417
+ 20180417,
+ false
);
- require( dirname( __FILE__ ) . '/eu-cookie-law/form.php' );
+ require __DIR__ . '/eu-cookie-law/form.php';
}
/**
* Sanitize widget form values as they are saved.
*
- * @param array $new_instance Values just sent to be saved.
- * @param array $old_instance Previously saved values from database.
+ * @param array $new_instance Values just sent to be saved.
+ * @param array $old_instance Previously saved values from database.
* @return array Updated safe values to be saved.
*/
- public function update( $new_instance, $old_instance ) {
+ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$instance = array();
$defaults = $this->defaults();
@@ -285,7 +291,7 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
$instance['policy-link-text'] = trim( mb_substr( wp_kses( $new_instance['policy-link-text'], array() ), 0, 100 ) );
}
- if ( empty( $instance['policy-link-text'] ) || $instance['policy-link-text'] == $defaults['policy-link-text'] ) {
+ if ( empty( $instance['policy-link-text'] ) || $instance['policy-link-text'] === $defaults['policy-link-text'] ) {
unset( $instance['policy-link-text'] );
}
@@ -293,12 +299,12 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
$instance['button'] = trim( mb_substr( wp_kses( $new_instance['button'], array() ), 0, 100 ) );
}
- if ( empty( $instance['button'] ) || $instance['button'] == $defaults['button'] ) {
+ if ( empty( $instance['button'] ) || $instance['button'] === $defaults['button'] ) {
unset( $instance['button'] );
}
// Show the banner again if a setting has been changed.
- setcookie( self::$cookie_name, '', time() - 86400, '/' );
+ setcookie( self::$cookie_name, '', time() - 86400, '/', COOKIE_DOMAIN, is_ssl(), false ); // phpcs:ignore Jetpack.Functions.SetCookie -- Fine to have accessible.
return $instance;
}
@@ -311,19 +317,21 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
*
* @return string $value if pass the check or first value from allowed values.
*/
- function filter_value( $value, $allowed = array() ) {
+ public function filter_value( $value, $allowed = array() ) {
$allowed = (array) $allowed;
- if ( empty( $value ) || ( ! empty( $allowed ) && ! in_array( $value, $allowed ) ) ) {
+ if ( empty( $value ) || ( ! empty( $allowed ) && ! in_array( $value, $allowed, true ) ) ) {
$value = $allowed[0];
}
return $value;
}
}
- // Register Jetpack_EU_Cookie_Law_Widget widget.
+ /**
+ * Register Jetpack_EU_Cookie_Law_Widget widget.
+ */
function jetpack_register_eu_cookie_law_widget() {
register_widget( 'Jetpack_EU_Cookie_Law_Widget' );
- };
+ }
add_action( 'widgets_init', 'jetpack_register_eu_cookie_law_widget' );
}
diff --git a/plugins/jetpack/modules/widgets/contact-info.php b/plugins/jetpack/modules/widgets/contact-info.php
index de9afc9d..4f53ac18 100644
--- a/plugins/jetpack/modules/widgets/contact-info.php
+++ b/plugins/jetpack/modules/widgets/contact-info.php
@@ -483,7 +483,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
public function ajax_check_api_key() {
if ( isset( $_POST['apikey'] ) ) {
if ( check_ajax_referer( 'customize_contact_info_api_key' ) && current_user_can( 'customize' ) ) {
- $apikey = wp_kses( $_POST['apikey'], array() );
+ $apikey = wp_kses( wp_unslash( $_POST['apikey'] ), array() );
$default_instance = $this->defaults();
$default_instance['apikey'] = $apikey;
wp_send_json( array( 'result' => esc_html( $this->has_good_map( $default_instance ) ) ) );
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/form.php b/plugins/jetpack/modules/widgets/eu-cookie-law/form.php
index d4f3bad2..7eb487e8 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law/form.php
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/form.php
@@ -1,7 +1,13 @@
<?php
+/**
+ * EU Cookie Law Widget form.
+ *
+ * @package automattic/jetpack
+ */
use Automattic\Jetpack\Redirect;
+// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
?>
<p>
<strong>
@@ -84,10 +90,21 @@ use Automattic\Jetpack\Redirect;
<span class="notice notice-warning custom-policy" style="display: none;">
<span style="display: block; margin: .5em 0;">
<strong><?php esc_html_e( 'Caution:', 'jetpack' ); ?></strong>
- <?php echo sprintf(
- __( 'For GDPR compliance, please make sure your policy contains <a href="%s" target="_blank">privacy information relating to Jetpack Ads</a>.', 'jetpack' ),
+ <?php
+ echo sprintf(
+ wp_kses(
+ /* Translators: %s is the URL to a Jetpack support article. */
+ __( 'For GDPR compliance, please make sure your policy contains <a href="%s" target="_blank">privacy information relating to WordAds</a>.', 'jetpack' ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'target' => array(),
+ ),
+ )
+ ),
esc_url( Redirect::get_url( 'jetpack-support-ads', array( 'anchor' => 'privacy' ) ) )
- ); ?>
+ );
+ ?>
</span>
</span>
<?php endif; ?>
@@ -102,7 +119,7 @@ use Automattic\Jetpack\Redirect;
<label>
<input
class="widefat"
- name="<?php echo $this->get_field_name( 'policy-link-text' ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'policy-link-text' ) ); ?>"
type="text"
value="<?php echo esc_attr( $instance['policy-link-text'] ); ?>"
/>
@@ -118,7 +135,7 @@ use Automattic\Jetpack\Redirect;
<label>
<input
class="widefat"
- name="<?php echo $this->get_field_name( 'button' ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'button' ) ); ?>"
type="text"
value="<?php echo esc_attr( $instance['button'] ); ?>"
/>
@@ -129,7 +146,7 @@ use Automattic\Jetpack\Redirect;
<p>
<strong>
- <?php _ex( 'Capture consent & hide the banner', 'action', 'jetpack' ); ?>
+ <?php esc_html_x( 'Capture consent & hide the banner', 'action', 'jetpack' ); ?>
</strong>
<ul>
<li>
@@ -181,7 +198,7 @@ use Automattic\Jetpack\Redirect;
<?php if ( Jetpack::is_module_active( 'wordads' ) ) : ?>
<span class="notice notice-warning" style="display: block;">
<span style="display: block; margin: .5em 0;">
- <?php esc_html_e( 'Visitors must provide consent by clicking the dismiss button when Jetpack Ads is turned on.', 'jetpack' ); ?>
+ <?php esc_html_e( 'Visitors must provide consent by clicking the dismiss button when WordAds is turned on.', 'jetpack' ); ?>
</span>
</span>
<?php endif; ?>
@@ -191,7 +208,7 @@ use Automattic\Jetpack\Redirect;
<p>
<strong>
- <?php _ex( 'Consent expires after', 'action', 'jetpack' ); ?>
+ <?php esc_html_x( 'Consent expires after', 'action', 'jetpack' ); ?>
</strong>
<ul>
<li>
@@ -212,7 +229,7 @@ use Automattic\Jetpack\Redirect;
<p>
<strong>
- <?php _e( 'Color scheme', 'jetpack' ); ?>
+ <?php esc_html_e( 'Color scheme', 'jetpack' ); ?>
</strong>
<ul>
<li>
@@ -244,7 +261,7 @@ use Automattic\Jetpack\Redirect;
<p>
<strong>
- <?php _e( 'Position', 'jetpack' ); ?>
+ <?php esc_html_e( 'Position', 'jetpack' ); ?>
</strong>
<ul>
<li>
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/widget.php b/plugins/jetpack/modules/widgets/eu-cookie-law/widget.php
index ef540452..c1b3e328 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law/widget.php
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/widget.php
@@ -7,7 +7,7 @@
?>
<div
- class="<?php echo implode( ' ', $classes ); ?>"
+ class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>"
data-hide-timeout="<?php echo (int) $instance['hide-timeout']; ?>"
data-consent-expiration="<?php echo (int) $instance['consent-expiration']; ?>"
id="eu-cookie-law"
@@ -16,11 +16,13 @@
<input type="submit" value="<?php echo esc_attr( $instance['button'] ); ?>" class="accept" />
</form>
- <?php if ( 'default' == $instance['text'] || empty( $instance['customtext'] ) ) {
- echo nl2br( $instance['default-text'] );
+ <?php
+ if ( 'default' === $instance['text'] || empty( $instance['customtext'] ) ) {
+ echo nl2br( esc_html( $instance['default-text'] ) );
} else {
echo nl2br( esc_html( $instance['customtext'] ) );
- } ?>
+ }
+ ?>
<?php
$is_default_policy = 'default' === $instance['policy-url'] || empty( $instance['custom-policy-url'] );
diff --git a/plugins/jetpack/modules/widgets/facebook-likebox.php b/plugins/jetpack/modules/widgets/facebook-likebox.php
index c7e38e64..a9466c42 100644
--- a/plugins/jetpack/modules/widgets/facebook-likebox.php
+++ b/plugins/jetpack/modules/widgets/facebook-likebox.php
@@ -1,10 +1,9 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+add_action( 'widgets_init', 'jetpack_facebook_likebox_init' );
/**
* Register the widget for use in Appearance -> Widgets
*/
-add_action( 'widgets_init', 'jetpack_facebook_likebox_init' );
-
function jetpack_facebook_likebox_init() {
register_widget( 'WPCOM_Widget_Facebook_LikeBox' );
}
@@ -15,15 +14,52 @@ function jetpack_facebook_likebox_init() {
* https://developers.facebook.com/docs/plugins/page-plugin
*/
class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
-
+ /**
+ * Default height.
+ *
+ * @var int
+ */
private $default_height = 580;
- private $default_width = 340;
- private $max_width = 500;
- private $min_width = 180;
- private $max_height = 9999;
- private $min_height = 130;
- function __construct() {
+ /**
+ * Default width.
+ *
+ * @var int
+ */
+ private $default_width = 340;
+
+ /**
+ * Max width.
+ *
+ * @var int
+ */
+ private $max_width = 500;
+
+ /**
+ * Min width.
+ *
+ * @var int
+ */
+ private $min_width = 180;
+
+ /**
+ * Max height.
+ *
+ * @var int
+ */
+ private $max_height = 9999;
+
+ /**
+ * Min height/
+ *
+ * @var int
+ */
+ private $min_height = 130;
+
+ /**
+ * WPCOM_Widget_Facebook_LikeBox constructor.
+ */
+ public function __construct() {
parent::__construct(
'facebook-likebox',
/**
@@ -53,7 +89,12 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
*/
public function enqueue_scripts() {
wp_enqueue_script( 'jetpack-facebook-embed' );
- wp_enqueue_style( 'jetpack_facebook_likebox', plugins_url( 'facebook-likebox/style.css', __FILE__ ) );
+ wp_enqueue_style(
+ 'jetpack_facebook_likebox',
+ plugins_url( 'facebook-likebox/style.css', __FILE__ ),
+ array(),
+ JETPACK__VERSION
+ );
wp_style_add_data( 'jetpack_facebook_likebox', 'jetpack-inline', true );
}
@@ -158,14 +199,22 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
do_action( 'jetpack_stats_extra', 'widget_view', 'facebook-likebox' );
}
- function update( $new_instance, $old_instance ) {
+ /**
+ * Update widget.
+ *
+ * @see WP_Widget::update()
+ *
+ * @param array $new_instance New widget instance data.
+ * @param array $old_instance Old widget instance data.
+ */
+ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$instance = array();
- $instance['title'] = trim( strip_tags( stripslashes( $new_instance['title'] ) ) );
+ $instance['title'] = trim( wp_strip_all_tags( stripslashes( $new_instance['title'] ) ) );
// Set up widget values.
$instance['like_args'] = array(
- 'href' => trim( strip_tags( stripslashes( $new_instance['href'] ) ) ),
+ 'href' => trim( wp_strip_all_tags( stripslashes( $new_instance['href'] ) ) ),
'width' => (int) $new_instance['width'],
'height' => (int) $new_instance['height'],
'show_faces' => isset( $new_instance['show_faces'] ),
@@ -182,9 +231,15 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
return $instance;
}
- function form( $instance ) {
+ /**
+ * Outputs the widget settings form.
+ *
+ * @param array $instance Current settings.
+ */
+ public function form( $instance ) {
$instance = wp_parse_args(
- (array) $instance, array(
+ (array) $instance,
+ array(
'title' => '',
'like_args' => $this->get_default_args(),
)
@@ -212,7 +267,25 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
<label for="<?php echo esc_attr( $this->get_field_id( 'width' ) ); ?>">
<?php esc_html_e( 'Width in pixels', 'jetpack' ); ?>
<input type="number" class="smalltext" min="<?php echo esc_attr( $this->min_width ); ?>" max="<?php echo esc_attr( $this->max_width ); ?>" maxlength="3" name="<?php echo esc_attr( $this->get_field_name( 'width' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'width' ) ); ?>" value="<?php echo esc_attr( $like_args['width'] ); ?>" style="text-align: center;" />
- <small><?php echo sprintf( __( 'Minimum: %s', 'jetpack' ), $this->min_width ); ?> / <?php echo sprintf( __( 'Maximum: %s', 'jetpack' ), $this->max_width ); ?></small>
+ <small>
+ <?php
+ echo esc_html(
+ sprintf(
+ /* translators: %s is the minimum pixel width */
+ __( 'Minimum: %s', 'jetpack' ),
+ $this->min_width
+ )
+ );
+ echo ' / ';
+ echo esc_html(
+ sprintf(
+ /* translators: %s is the maximum pixel width */
+ __( 'Maximum: %s', 'jetpack' ),
+ $this->max_width
+ )
+ );
+ ?>
+ </small>
</label>
</p>
@@ -220,7 +293,25 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
<label for="<?php echo esc_attr( $this->get_field_id( 'height' ) ); ?>">
<?php esc_html_e( 'Height in pixels', 'jetpack' ); ?>
<input type="number" class="smalltext" min="<?php echo esc_attr( $this->min_height ); ?>" max="<?php echo esc_attr( $this->max_height ); ?>" maxlength="3" name="<?php echo esc_attr( $this->get_field_name( 'height' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'height' ) ); ?>" value="<?php echo esc_attr( $like_args['height'] ); ?>" style="text-align: center;" />
- <small><?php echo sprintf( __( 'Minimum: %s', 'jetpack' ), $this->min_height ); ?> / <?php echo sprintf( __( 'Maximum: %s', 'jetpack' ), $this->max_height ); ?></small>
+ <small>
+ <?php
+ echo esc_html(
+ sprintf(
+ /* translators: %s is the minimum pixel height */
+ __( 'Minimum: %s', 'jetpack' ),
+ $this->min_height
+ )
+ );
+ echo ' / ';
+ echo esc_html(
+ sprintf(
+ /* translators: %s is the maximum pixel height */
+ __( 'Maximum: %s', 'jetpack' ),
+ $this->max_height
+ )
+ );
+ ?>
+ </small>
</label>
</p>
@@ -261,7 +352,10 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
<?php
}
- function get_default_args() {
+ /**
+ * Facebook Likebox default options.
+ */
+ public function get_default_args() {
$defaults = array(
'href' => '',
'width' => $this->default_width,
@@ -284,10 +378,15 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
return apply_filters( 'jetpack_facebook_likebox_defaults', $defaults );
}
- function normalize_facebook_args( $args ) {
+ /**
+ * Normalize the Facebook Likebox options.
+ *
+ * @param array $args Array of arguments.
+ */
+ public function normalize_facebook_args( $args ) {
$args = wp_parse_args( (array) $args, $this->get_default_args() );
- // Validate the Facebook Page URL
+ // Validate the Facebook Page URL.
if ( $this->is_valid_facebook_url( $args['href'] ) ) {
$temp = explode( '?', $args['href'] );
$args['href'] = str_replace( array( 'http://facebook.com', 'https://facebook.com' ), array( 'http://www.facebook.com', 'https://www.facebook.com' ), $temp[0] );
@@ -295,8 +394,8 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
$args['href'] = '';
}
- $args['width'] = $this->normalize_int_value( (int) $args['width'], $this->default_width, $this->max_width, $this->min_width );
- $args['height'] = $this->normalize_int_value( (int) $args['height'], $this->default_height, $this->max_height, $this->min_height );
+ $args['width'] = $this->normalize_int_value( (int) $args['width'], $this->max_width, $this->min_width );
+ $args['height'] = $this->normalize_int_value( (int) $args['height'], $this->max_height, $this->min_height );
$args['show_faces'] = (bool) $args['show_faces'];
$args['stream'] = (bool) $args['stream'];
$args['cover'] = (bool) $args['cover'];
@@ -305,7 +404,7 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
// The height used to be dependent on other widget settings
// If the user changes those settings but doesn't customize the height,
// let's intelligently assign a new height.
- if ( in_array( $args['height'], array( 580, 110, 432 ) ) ) {
+ if ( in_array( $args['height'], array( 580, 110, 432 ), true ) ) {
if ( $args['show_faces'] && $args['stream'] ) {
$args['height'] = 580;
} elseif ( ! $args['show_faces'] && ! $args['stream'] ) {
@@ -318,11 +417,25 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
return $args;
}
- function is_valid_facebook_url( $url ) {
+ /**
+ * Check if URL is a valid Facebook Page URL.
+ *
+ * @param string $url URL to check.
+ */
+ public function is_valid_facebook_url( $url ) {
return ( false !== strpos( $url, 'facebook.com' ) ) ? true : false;
}
- function normalize_int_value( $value, $default = 0, $max = 0, $min = 0 ) {
+ /**
+ * Normalize an integer value within a given range.
+ *
+ * @param int $value Value to normalize.
+ * @param int $max Maximum value.
+ * @param int $min Minimum value.
+ *
+ * @return int Normalized value.
+ */
+ public function normalize_int_value( $value, $max = 0, $min = 0 ) {
$value = (int) $value;
if ( $value > $max ) {
@@ -333,14 +446,4 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
return (int) $value;
}
-
- function normalize_text_value( $value, $default = '', $allowed = array() ) {
- $allowed = (array) $allowed;
-
- if ( empty( $value ) || ( ! empty( $allowed ) && ! in_array( $value, $allowed ) ) ) {
- $value = $default;
- }
-
- return $value;
- }
}
diff --git a/plugins/jetpack/modules/widgets/flickr.php b/plugins/jetpack/modules/widgets/flickr.php
index 9fb80962..36b524da 100644
--- a/plugins/jetpack/modules/widgets/flickr.php
+++ b/plugins/jetpack/modules/widgets/flickr.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Disable direct access/execution to/of the widget code.
*/
@@ -16,7 +16,7 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
/**
* Constructor.
*/
- function __construct() {
+ public function __construct() {
parent::__construct(
'flickr',
/** This filter is documented in modules/widgets/facebook-likebox.php */
@@ -36,7 +36,7 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
/**
* Enqueue style.
*/
- function enqueue_style() {
+ public function enqueue_style() {
wp_enqueue_style( 'flickr-widget-style', plugins_url( 'flickr/style.css', __FILE__ ), array(), '20170405' );
}
@@ -66,10 +66,7 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
public function widget( $args, $instance ) {
$instance = wp_parse_args( $instance, $this->defaults() );
- $image_size_string = 'small' == $instance['flickr_image_size'] ? '_m.jpg' : '_t.jpg';
-
if ( ! empty( $instance['flickr_rss_url'] ) ) {
-
/*
* Parse the URL, and rebuild a URL that's sure to display images.
* Some Flickr Feeds do not display images by default.
@@ -105,7 +102,7 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
);
}
}
- } // End if().
+ }
// Still no RSS feed URL? Get a default feed from Flickr to grab interesting photos.
if ( empty( $rss_url ) ) {
@@ -143,10 +140,10 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
$photos = Jetpack_Photon::filter_the_content( $photos );
}
- $flickr_home = $rss->get_link();
+ $flickr_home = $rss->get_link(); // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- Used in flickr/widget.php template file.
}
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( empty( $photos ) ) {
if ( current_user_can( 'edit_theme_options' ) ) {
printf(
@@ -157,9 +154,9 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
}
} else {
echo $args['before_title'] . $instance['title'] . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- require( dirname( __FILE__ ) . '/flickr/widget.php' );
+ require __DIR__ . '/flickr/widget.php';
}
- echo $args['after_widget'];
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/** This action is already documented in modules/widgets/gravatar-profile.php */
do_action( 'jetpack_stats_extra', 'widget_view', 'flickr' );
}
@@ -171,7 +168,7 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
*/
public function form( $instance ) {
$instance = wp_parse_args( $instance, $this->defaults() );
- require( dirname( __FILE__ ) . '/flickr/form.php' );
+ require __DIR__ . '/flickr/form.php';
}
/**
@@ -181,9 +178,8 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
* @param array $old_instance Previously saved values from database.
* @return array Updated safe values to be saved.
*/
- public function update( $new_instance, $old_instance ) {
+ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$instance = array();
- $defaults = $this->defaults();
if ( isset( $new_instance['title'] ) ) {
$instance['title'] = wp_kses( $new_instance['title'], array() );
@@ -199,7 +195,7 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
if (
isset( $new_instance['flickr_image_size'] ) &&
- in_array( $new_instance['flickr_image_size'], array( 'thumbnail', 'small', 'large' ) )
+ in_array( $new_instance['flickr_image_size'], array( 'thumbnail', 'small', 'large' ), true )
) {
$instance['flickr_image_size'] = $new_instance['flickr_image_size'];
} else {
@@ -218,7 +214,9 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
}
}
- // Register Jetpack_Flickr_Widget widget.
+ /**
+ * Register Jetpack_Flickr_Widget widget.
+ */
function jetpack_register_flickr_widget() {
register_widget( 'Jetpack_Flickr_Widget' );
}
diff --git a/plugins/jetpack/modules/widgets/flickr/form.php b/plugins/jetpack/modules/widgets/flickr/form.php
index 0dfc5c9a..a1bd08dd 100644
--- a/plugins/jetpack/modules/widgets/flickr/form.php
+++ b/plugins/jetpack/modules/widgets/flickr/form.php
@@ -1,3 +1,12 @@
+<?php
+/**
+ * Jetpack_Flickr_Widget settings form output.
+ *
+ * @package automattic/jetpack
+ */
+
+//phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
+?>
<p>
<label>
<?php esc_html_e( 'Title:', 'jetpack' ); ?>
@@ -28,10 +37,21 @@
</p>
<p>
<small>
- <?php printf(
- __( 'Leave the Flickr RSS URL field blank to display <a target="_blank" href="%s">interesting</a> Flickr photos.', 'jetpack' ),
+ <?php
+ echo sprintf(
+ wp_kses(
+ /* Translators: %s is the URL to an example Flickr RSS feed. */
+ __( 'Leave the Flickr RSS URL field blank to display <a target="_blank" href="%s">interesting</a> Flickr photos.', 'jetpack' ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'target' => array(),
+ ),
+ )
+ ),
'https://www.flickr.com/explore/interesting'
- ); ?>
+ );
+ ?>
</small>
</p>
@@ -43,9 +63,9 @@
<?php for ( $i = 1; $i <= 10; ++$i ) { ?>
<option
<?php selected( $instance['items'], $i ); ?>
- value="<?php echo $i; ?>"
+ value="<?php echo esc_attr( $i ); ?>"
>
- <?php echo $i; ?>
+ <?php echo esc_html( $i ); ?>
</option>
<?php } ?>
</select>
diff --git a/plugins/jetpack/modules/widgets/flickr/widget.php b/plugins/jetpack/modules/widgets/flickr/widget.php
index 0c45f3f0..e3bd118b 100644
--- a/plugins/jetpack/modules/widgets/flickr/widget.php
+++ b/plugins/jetpack/modules/widgets/flickr/widget.php
@@ -1,7 +1,16 @@
+<?php
+/**
+ * Jetpack_Flickr_Widget frontend widget output.
+ *
+ * @package automattic/jetpack
+ */
+
+//phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
+?>
<!-- Start of Flickr Widget -->
<div class="flickr-wrapper flickr-size-<?php echo esc_attr( $instance['flickr_image_size'] ); ?>">
<div class="flickr-images">
- <?php echo $photos; ?>
+ <?php echo $photos; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaping handled in Jetpack_Flickr_Widget class. ?>
</div>
<?php if ( isset( $flickr_home ) ) { ?>
diff --git a/plugins/jetpack/modules/widgets/gallery.php b/plugins/jetpack/modules/widgets/gallery.php
index 65c3a60c..44e2ecbf 100644
--- a/plugins/jetpack/modules/widgets/gallery.php
+++ b/plugins/jetpack/modules/widgets/gallery.php
@@ -1,21 +1,30 @@
-<?php
-
-/*
-Plugin Name: Gallery
-Description: Gallery widget
-Author: Automattic Inc.
-Version: 1.0
-Author URI: https://automattic.com
-*/
+<?php // phpcs:ignore eWordPress.Files.FileName.InvalidClassFileName
+/**
+ * Module Name: Gallery widget
+ *
+ * @package automattic/jetpack
+ */
use Automattic\Jetpack\Assets;
+/**
+ * Jetpack_Gallery_Widget main class.
+ */
class Jetpack_Gallery_Widget extends WP_Widget {
const THUMB_SIZE = 45;
const DEFAULT_WIDTH = 265;
- protected $_instance_width;
+ /**
+ * The width of the gallery widget.
+ * May be customized by the 'gallery_widget_content_width' filter.
+ *
+ * @var int
+ */
+ protected $instance_width;
+ /**
+ * Jetpack_Gallery_Widget constructor.
+ */
public function __construct() {
$widget_ops = array(
'classname' => 'widget-gallery',
@@ -125,7 +134,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
* @param string $args Display arguments including before_title, after_title, before_widget, and after_widget.
* @param array $instance The settings for the particular instance of the widget.
*/
- $this->_instance_width = apply_filters( 'gallery_widget_content_width', self::DEFAULT_WIDTH, $args, $instance );
+ $this->instance_width = apply_filters( 'gallery_widget_content_width', self::DEFAULT_WIDTH, $args, $instance );
// Register a filter to modify the tiled_gallery_content_width, so Jetpack_Tiled_Gallery
// can appropriately size the tiles.
@@ -135,8 +144,8 @@ class Jetpack_Gallery_Widget extends WP_Widget {
echo $this->$method( $args, $instance ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
- // Remove the stored $_instance_width, as it is no longer needed.
- $this->_instance_width = null;
+ // Remove the stored $instance_width, as it is no longer needed.
+ $this->instance_width = null;
// Remove the filter, so any Jetpack_Tiled_Gallery in a post is not affected.
remove_filter( 'tiled_gallery_content_width', array( $this, 'tiled_gallery_content_width' ) );
@@ -152,13 +161,13 @@ class Jetpack_Gallery_Widget extends WP_Widget {
/**
* Fetch the images attached to the gallery Widget
*
- * @param array $instance The Widget instance for which you'd like attachments
+ * @param array $instance The Widget instance for which you'd like attachments.
* @return array Array of attachment objects for the Widget in $instance
*/
public function get_attachments( $instance ) {
$ids = explode( ',', $instance['ids'] );
- if ( isset( $instance['random'] ) && 'on' == $instance['random'] ) {
+ if ( isset( $instance['random'] ) && 'on' === $instance['random'] ) {
shuffle( $ids );
}
@@ -184,7 +193,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
* Generate HTML for a rectangular, tiled Widget
*
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
- * @param array $instance The Widget instance to generate HTML for
+ * @param array $instance The Widget instance to generate HTML for.
* @return string String of HTML representing a rectangular gallery
*/
public function rectangular_widget( $args, $instance ) {
@@ -203,7 +212,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
* Generate HTML for a square (grid style) Widget
*
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
- * @param array $instance The Widget instance to generate HTML for
+ * @param array $instance The Widget instance to generate HTML for.
* @return string String of HTML representing a square gallery
*/
public function square_widget( $args, $instance ) {
@@ -222,7 +231,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
* Generate HTML for a circular (grid style) Widget
*
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
- * @param array $instance The Widget instance to generate HTML for
+ * @param array $instance The Widget instance to generate HTML for.
* @return string String of HTML representing a circular gallery
*/
public function circle_widget( $args, $instance ) {
@@ -240,14 +249,16 @@ class Jetpack_Gallery_Widget extends WP_Widget {
/**
* Generate HTML for a slideshow Widget
*
+ * @todo Is slideshow_widget() still used?
+ *
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
- * @param array $instance The Widget instance to generate HTML for
+ * @param array $instance The Widget instance to generate HTML for.
* @return string String of HTML representing a slideshow gallery
*/
public function slideshow_widget( $args, $instance ) {
global $content_width;
- require_once plugin_dir_path( realpath( dirname( __FILE__ ) . '/../shortcodes/slideshow.php' ) ) . 'slideshow.php';
+ require_once plugin_dir_path( realpath( __DIR__ . '/../shortcodes/slideshow.php' ) ) . 'slideshow.php';
if ( ! class_exists( 'Jetpack_Slideshow_Shortcode' ) ) {
return;
@@ -267,9 +278,9 @@ class Jetpack_Gallery_Widget extends WP_Widget {
foreach ( $instance['attachments'] as $attachment ) {
$attachment_image_src = wp_get_attachment_image_src( $attachment->ID, 'full' );
- $attachment_image_src = jetpack_photon_url( $attachment_image_src[0], array( 'w' => $this->_instance_width ) ); // [url, width, height]
+ $attachment_image_src = jetpack_photon_url( $attachment_image_src[0], array( 'w' => $this->instance_width ) ); /** [url, width, height] */
- $caption = wptexturize( strip_tags( $attachment->post_excerpt ) );
+ $caption = wptexturize( wp_strip_all_tags( $attachment->post_excerpt ) );
$gallery[] = (object) array(
'src' => (string) esc_url_raw( $attachment_image_src ),
@@ -286,7 +297,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
}
$color = Jetpack_Options::get_option( 'slideshow_background_color', 'black' );
- $autostart = isset( $attr['autostart'] ) ? $attr['autostart'] : true;
+ $autostart = isset( $attr['autostart'] ) ? $attr['autostart'] : true; // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- Todo: should read off the $instance? Also not sure if slideshow_widget() is used still.
$js_attr = array(
'gallery' => $gallery,
@@ -304,29 +315,38 @@ class Jetpack_Gallery_Widget extends WP_Widget {
}
/**
- * tiled_gallery_content_width filter
- *
* Used to adjust the content width of Jetpack_Tiled_Gallery's in sidebars
*
- * $this->_instance_width is filtered in widget() and this filter is added then removed in widget()
+ * $this->instance_width is filtered in widget() and this filter is added then removed in widget()
*
- * @param int $width int The original width value
* @return int The filtered width
*/
- public function tiled_gallery_content_width( $width ) {
- return $this->_instance_width;
+ public function tiled_gallery_content_width() {
+ return $this->instance_width;
}
+ /**
+ * Outputs the widget settings form.
+ *
+ * @param array $instance Current settings.
+ */
public function form( $instance ) {
$defaults = $this->defaults();
- $allowed_values = $this->allowed_values();
+ $allowed_values = $this->allowed_values(); // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- Used in included form template.
$instance = wp_parse_args( (array) $instance, $defaults );
- include dirname( __FILE__ ) . '/gallery/templates/form.php';
+ include __DIR__ . '/gallery/templates/form.php';
}
- public function update( $new_instance, $old_instance ) {
+ /**
+ * Save the widget options.
+ *
+ * @param array $new_instance The new instance options.
+ * @param array $old_instance The old instance options.
+ * @return array The saved options.
+ */
+ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$instance = $this->sanitize( $new_instance );
return $instance;
@@ -338,7 +358,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
*
* Helps keep things nice and secure by listing only allowed values.
*
- * @param array $instance The Widget instance to sanitize values for
+ * @param array $instance The Widget instance to sanitize values for.
* @return array $instance The Widget instance with values sanitized
*/
public function sanitize( $instance ) {
@@ -346,6 +366,11 @@ class Jetpack_Gallery_Widget extends WP_Widget {
$defaults = $this->defaults();
foreach ( $instance as $key => $value ) {
+ if ( ! is_scalar( $value ) ) {
+ // $instance may hold an Array value type for the Jetpack widget visibility feature.
+ continue;
+ }
+
$value = trim( $value );
if ( isset( $allowed_values[ $key ] ) && $allowed_values[ $key ] && ! array_key_exists( $value, $allowed_values[ $key ] ) ) {
@@ -370,7 +395,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
$max_columns = 5;
// Create an associative array of allowed column values. This just automates the generation of
- // column <option>s, from 1 to $max_columns
+ // column <option>s, from 1 to $max_columns.
$allowed_columns = array_combine( range( 1, $max_columns ), range( 1, $max_columns ) );
return array(
@@ -407,22 +432,31 @@ class Jetpack_Gallery_Widget extends WP_Widget {
);
}
+ /**
+ * Enqueue frontend scripts.
+ */
public function enqueue_frontend_scripts() {
wp_register_script(
'gallery-widget',
Assets::get_file_url_for_environment(
'_inc/build/widgets/gallery/js/gallery.min.js',
'modules/widgets/gallery/js/gallery.js'
- )
+ ),
+ array(),
+ JETPACK__VERSION,
+ false
);
wp_enqueue_script( 'gallery-widget' );
}
+ /**
+ * Enqueue admin scripts and styles.
+ */
public function enqueue_admin_scripts() {
global $pagenow;
- if ( 'widgets.php' == $pagenow || 'customize.php' == $pagenow ) {
+ if ( 'widgets.php' === $pagenow || 'customize.php' === $pagenow ) {
wp_enqueue_media();
wp_enqueue_script(
@@ -435,7 +469,8 @@ class Jetpack_Gallery_Widget extends WP_Widget {
'media-models',
'media-views',
),
- '20150501'
+ '20150501',
+ false
);
$js_settings = array(
@@ -443,7 +478,12 @@ class Jetpack_Gallery_Widget extends WP_Widget {
);
wp_localize_script( 'gallery-widget-admin', '_wpGalleryWidgetAdminSettings', $js_settings );
- wp_enqueue_style( 'gallery-widget-admin', plugins_url( '/gallery/css/admin.css', __FILE__ ) );
+ wp_enqueue_style(
+ 'gallery-widget-admin',
+ plugins_url( '/gallery/css/admin.css', __FILE__ ),
+ array(),
+ JETPACK__VERSION
+ );
wp_style_add_data( 'gallery-widget-admin', 'rtl', 'replace' );
}
}
@@ -451,6 +491,9 @@ class Jetpack_Gallery_Widget extends WP_Widget {
add_action( 'widgets_init', 'jetpack_gallery_widget_init' );
+/**
+ * Jetpack Gallery widget init; the widget is conditionally registered.
+ */
function jetpack_gallery_widget_init() {
/**
* Allow the Gallery Widget to be enabled even when Core supports the Media Gallery Widget
diff --git a/plugins/jetpack/modules/widgets/gallery/css/admin-rtl.css b/plugins/jetpack/modules/widgets/gallery/css/admin-rtl.css
index afd9550d..709e6d6a 100644
--- a/plugins/jetpack/modules/widgets/gallery/css/admin-rtl.css
+++ b/plugins/jetpack/modules/widgets/gallery/css/admin-rtl.css
@@ -1,12 +1,11 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
.gallery-widget-thumbs-wrapper {
- margin: -5px 0 0.3em 0;
+ margin: -5px 0 0.3em 0;
}
.gallery-widget-thumbs img {
- border: 1px solid #ccc;
- padding: 2px;
- background-color: #fff;
- margin: 0 0 5px 5px;
- float: right;
-} \ No newline at end of file
+ border: 1px solid #ccc;
+ padding: 2px;
+ background-color: #fff;
+ margin: 0 0 5px 5px;
+ float: right;
+}
diff --git a/plugins/jetpack/modules/widgets/gallery/css/admin-rtl.min.css b/plugins/jetpack/modules/widgets/gallery/css/admin-rtl.min.css
index de937320..6bee5b53 100644
--- a/plugins/jetpack/modules/widgets/gallery/css/admin-rtl.min.css
+++ b/plugins/jetpack/modules/widgets/gallery/css/admin-rtl.min.css
@@ -1 +1 @@
-.gallery-widget-thumbs-wrapper{margin:-5px 0 .3em 0}.gallery-widget-thumbs img{border:1px solid #ccc;padding:2px;background-color:#fff;margin:0 0 5px 5px;float:right} \ No newline at end of file
+.gallery-widget-thumbs-wrapper{margin:-5px 0 .3em}.gallery-widget-thumbs img{background-color:#fff;border:1px solid #ccc;float:right;margin:0 0 5px 5px;padding:2px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/widgets/gallery/css/admin.min.css b/plugins/jetpack/modules/widgets/gallery/css/admin.min.css
index 743791f9..0e996e08 100644
--- a/plugins/jetpack/modules/widgets/gallery/css/admin.min.css
+++ b/plugins/jetpack/modules/widgets/gallery/css/admin.min.css
@@ -1,2 +1 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-.gallery-widget-thumbs-wrapper{margin:-5px 0 .3em 0}.gallery-widget-thumbs img{border:1px solid #ccc;padding:2px;background-color:#fff;margin:0 5px 5px 0;float:left} \ No newline at end of file
+.gallery-widget-thumbs-wrapper{margin:-5px 0 .3em}.gallery-widget-thumbs img{background-color:#fff;border:1px solid #ccc;float:left;margin:0 5px 5px 0;padding:2px} \ No newline at end of file
diff --git a/plugins/jetpack/modules/widgets/gallery/templates/form.php b/plugins/jetpack/modules/widgets/gallery/templates/form.php
index f24cf1c2..799f3eef 100644
--- a/plugins/jetpack/modules/widgets/gallery/templates/form.php
+++ b/plugins/jetpack/modules/widgets/gallery/templates/form.php
@@ -1,6 +1,15 @@
+<?php
+/**
+ * Jetpack_Gallery_Widget backend settings form output.
+ *
+ * @package automattic/jetpack
+ */
+
+// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
+?>
<p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?>
- <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>"
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?>
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
</label>
</p>
@@ -15,20 +24,23 @@
<div class="gallery-widget-thumbs">
<?php
- // Add the thumbnails to the widget box
+ // Add the thumbnails to the widget box.
$attachments = $this->get_attachments( $instance );
- foreach( $attachments as $attachment ){
- $url = add_query_arg( array(
- 'w' => self::THUMB_SIZE,
- 'h' => self::THUMB_SIZE,
- 'crop' => 'true'
- ), wp_get_attachment_url( $attachment->ID ) );
+ foreach ( $attachments as $attachment ) {
+ $url = add_query_arg(
+ array(
+ 'w' => self::THUMB_SIZE,
+ 'h' => self::THUMB_SIZE,
+ 'crop' => 'true',
+ ),
+ wp_get_attachment_url( $attachment->ID )
+ );
?>
<img src="<?php echo esc_url( $url ); ?>" title="<?php echo esc_attr( $attachment->post_title ); ?>" alt="<?php echo esc_attr( $attachment->post_title ); ?>"
- width="<?php echo self::THUMB_SIZE; ?>" height="<?php echo self::THUMB_SIZE; ?>" class="thumb" />
+ width="<?php echo esc_attr( self::THUMB_SIZE ); ?>" height="<?php echo esc_attr( self::THUMB_SIZE ); ?>" class="thumb" />
<?php } ?>
</div>
@@ -40,50 +52,28 @@
</p>
<p class="gallery-widget-link-wrapper">
- <label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php esc_html_e( 'Link To:', 'jetpack' ); ?></label>
- <select name="<?php echo $this->get_field_name( 'link' ); ?>" id="<?php echo $this->get_field_id( 'link' ); ?>" class="widefat">
- <?php foreach ( $allowed_values['link'] as $key => $label ) {
- $selected = '';
-
- if ( $instance['link'] == $key ) {
- $selected = "selected='selected' ";
- } ?>
-
- <option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo esc_html( $label, 'jetpack' ); ?></option>
- <?php } ?>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>"><?php esc_html_e( 'Link To:', 'jetpack' ); ?></label>
+ <select name="<?php echo esc_attr( $this->get_field_name( 'link' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>" class="widefat">
+ <?php foreach ( $allowed_values['link'] as $key => $label ) : ?>
+ <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $instance['link'], $key ); ?>><?php echo esc_html( $label ); ?></option>
+ <?php endforeach; ?>
</select>
</p>
<p>
- <label for="<?php echo $this->get_field_id( 'random' ); ?>"><?php esc_html_e( 'Random Order:', 'jetpack' ); ?></label>
- <?php $checked = '';
-
- if ( isset( $instance['random'] ) && $instance['random'] )
- $checked = 'checked="checked"';
-
- ?>
- <input name="<?php echo $this->get_field_name( 'random' ); ?>" id="<?php echo $this->get_field_id( 'random' ); ?>" type="checkbox" <?php echo $checked; ?>>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'random' ) ); ?>"><?php esc_html_e( 'Random Order:', 'jetpack' ); ?></label>
+ <input name="<?php echo esc_attr( $this->get_field_name( 'random' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'random' ) ); ?>" type="checkbox"<?php checked( ! empty( $instance['random'] ) ); ?>>
</p>
<p class="gallery-widget-style-wrapper">
- <label for="<?php echo $this->get_field_id( 'type' ); ?>"><?php esc_html_e( 'Style:', 'jetpack' ); ?></label>
- <select name="<?php echo $this->get_field_name( 'type' ); ?>" id="<?php echo $this->get_field_id( 'type' ); ?>" class="widefat gallery-widget-style">
- <?php foreach ( $allowed_values['type'] as $key => $label ) {
- $selected = '';
-
- if ( $instance['type'] == $key ) {
- $selected = "selected='selected' ";
- } ?>
-
- <option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo esc_html( $label, 'jetpack' ); ?></option>
- <?php } ?>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'type' ) ); ?>"><?php esc_html_e( 'Style:', 'jetpack' ); ?></label>
+ <select name="<?php echo esc_attr( $this->get_field_name( 'type' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'type' ) ); ?>" class="widefat gallery-widget-style">
+ <?php foreach ( $allowed_values['type'] as $key => $label ) : ?>
+ <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $instance['type'], $key ); ?>><?php echo esc_html( $label ); ?></option>
+ <?php endforeach; ?>
</select>
</p>
-<?php
-
-
-?>
-<?php // Hidden input to hold the selected image ids as a csv list ?>
-<input type="hidden" class="gallery-widget-ids" name="<?php echo $this->get_field_name( 'ids' ); ?>" id="<?php echo $this->get_field_id( 'ids' ); ?>" value="<?php echo esc_attr( $instance['ids'] ); ?>" />
+<?php // Hidden input to hold the selected image ids as a csv list. ?>
+<input type="hidden" class="gallery-widget-ids" name="<?php echo esc_attr( $this->get_field_name( 'ids' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'ids' ) ); ?>" value="<?php echo esc_attr( $instance['ids'] ); ?>" />
diff --git a/plugins/jetpack/modules/widgets/goodreads.php b/plugins/jetpack/modules/widgets/goodreads.php
index f9b3db76..369908d5 100644
--- a/plugins/jetpack/modules/widgets/goodreads.php
+++ b/plugins/jetpack/modules/widgets/goodreads.php
@@ -1,9 +1,9 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+
+add_action( 'widgets_init', 'jetpack_goodreads_widget_init' );
/**
* Register the widget for use in Appearance -> Widgets
*/
-add_action( 'widgets_init', 'jetpack_goodreads_widget_init' );
-
function jetpack_goodreads_widget_init() {
register_widget( 'WPCOM_Widget_Goodreads' );
}
@@ -12,13 +12,19 @@ function jetpack_goodreads_widget_init() {
* Goodreads widget class
* Display a user's Goodreads shelf.
* Customize user_id, title, and shelf
- *
*/
class WPCOM_Widget_Goodreads extends WP_Widget {
-
+ /**
+ * Widget ID based on Goodreads user ID and shelf.
+ *
+ * @var int
+ */
private $goodreads_widget_id = 0;
- function __construct() {
+ /**
+ * WPCOM_Widget_Goodreads constructor.
+ */
+ public function __construct() {
parent::__construct(
'wpcom-goodreads',
/** This filter is documented in modules/widgets/facebook-likebox.php */
@@ -29,7 +35,7 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
'customize_selective_refresh' => true,
)
);
- // For user input sanitization and display
+ // For user input sanitization and display.
$this->shelves = array(
'read' => _x( 'Read', 'past participle: books I have read', 'jetpack' ),
'currently-reading' => __( 'Currently Reading', 'jetpack' ),
@@ -41,12 +47,26 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
}
}
- function enqueue_style() {
- wp_enqueue_style( 'goodreads-widget', plugins_url( 'goodreads/css/goodreads.css', __FILE__ ) );
+ /**
+ * Enqueue widget styles.
+ */
+ public function enqueue_style() {
+ wp_enqueue_style(
+ 'goodreads-widget',
+ plugins_url( 'goodreads/css/goodreads.css', __FILE__ ),
+ array(),
+ JETPACK__VERSION
+ );
wp_style_add_data( 'goodreads-widget', 'rtl', 'replace' );
}
- function widget( $args, $instance ) {
+ /**
+ * Display the widget.
+ *
+ * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
+ * @param array $instance The settings for the particular instance of the widget.
+ */
+ public function widget( $args, $instance ) {
/** This action is documented in modules/widgets/gravatar-profile.php */
do_action( 'jetpack_stats_extra', 'widget_view', 'goodreads' );
@@ -55,13 +75,22 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
if ( empty( $instance['user_id'] ) || 'invalid' === $instance['user_id'] ) {
if ( current_user_can( 'edit_theme_options' ) ) {
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<p>' . sprintf(
- __( 'You need to enter your numeric user ID for the <a href="%1$s">Goodreads Widget</a> to work correctly. <a href="%2$s" target="_blank">Full instructions</a>.', 'jetpack' ),
+ wp_kses(
+ /* translators: %1$s: link to the widget settings page. %2$s: support article URL for Goodreads widget. */
+ __( 'You need to enter your numeric user ID for the <a href="%1$s">Goodreads Widget</a> to work correctly. <a href="%2$s" target="_blank">Full instructions</a>.', 'jetpack' ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'target' => array(),
+ ),
+ )
+ ),
esc_url( admin_url( 'widgets.php' ) ),
- 'https://support.wordpress.com/widgets/goodreads-widget/#goodreads-user-id'
+ 'https://wordpress.com/support/widgets/goodreads-widget/#set-up-the-widget'
) . '</p>';
- echo $args['after_widget'];
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
return;
}
@@ -79,21 +108,27 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
$title = esc_html__( 'Goodreads', 'jetpack' );
}
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- $goodreads_url = 'https://www.goodreads.com/review/custom_widget/' . urlencode( $instance['user_id'] ) . '.' . urlencode( $instance['title'] ) . ':%20' . urlencode( $instance['shelf'] ) . '?cover_position=&cover_size=small&num_books=5&order=d&shelf=' . urlencode( $instance['shelf'] ) . '&sort=date_added&widget_bg_transparent=&widget_id=' . esc_attr( $this->goodreads_widget_id );
+ $goodreads_url = 'https://www.goodreads.com/review/custom_widget/' . rawurlencode( $instance['user_id'] ) . '.' . rawurlencode( $instance['title'] ) . ':%20' . rawurlencode( $instance['shelf'] ) . '?cover_position=&cover_size=small&num_books=5&order=d&shelf=' . rawurlencode( $instance['shelf'] ) . '&sort=date_added&widget_bg_transparent=&widget_id=' . rawurlencode( $this->goodreads_widget_id );
echo '<div class="gr_custom_widget" id="gr_custom_widget_' . esc_attr( $this->goodreads_widget_id ) . '"></div>' . "\n";
- echo '<script src="' . esc_url( $goodreads_url ) . '"></script>' . "\n";
+ echo '<script src="' . esc_url( $goodreads_url ) . '"></script>' . "\n"; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript
- echo $args['after_widget'];
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
- function goodreads_user_id_exists( $user_id ) {
+ /**
+ * Check if given Goodreads user ID exists.
+ *
+ * @param string $user_id User ID.
+ */
+ public function goodreads_user_id_exists( $user_id ) {
$url = "https://www.goodreads.com/user/show/$user_id/";
$response = wp_remote_head(
- $url, array(
+ $url,
+ array(
'httpversion' => '1.1',
'timeout' => 10,
'redirection' => 2,
@@ -106,7 +141,15 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
}
}
- function update( $new_instance, $old_instance ) {
+ /**
+ * Update widget.
+ *
+ * @see WP_Widget::update()
+ *
+ * @param array $new_instance New widget instance data.
+ * @param array $old_instance Old widget instance data.
+ */
+ public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['user_id'] = trim( wp_kses( stripslashes( $new_instance['user_id'] ), array() ) );
@@ -124,10 +167,16 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
return $instance;
}
- function form( $instance ) {
- //Defaults
+ /**
+ * Outputs the widget settings form.
+ *
+ * @param array $instance Current settings.
+ */
+ public function form( $instance ) {
+ // Defaults.
$instance = wp_parse_args(
- (array) $instance, array(
+ (array) $instance,
+ array(
'user_id' => '',
'title' => 'Goodreads',
'shelf' => 'read',
@@ -138,9 +187,21 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
<input class="widefat" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" type="text" value="' . esc_attr( $instance['title'] ) . '" />
</label></p>
<p><label for="' . esc_attr( $this->get_field_id( 'user_id' ) ) . '">';
- printf( __( 'Goodreads numeric user ID <a href="%s" target="_blank">(instructions)</a>:', 'jetpack' ), 'https://en.support.wordpress.com/widgets/goodreads-widget/#goodreads-user-id' );
+ printf(
+ wp_kses(
+ /* translators: %s: support article URL for Goodreads widget. */
+ __( 'Goodreads numeric user ID <a href="%s" target="_blank">(instructions)</a>:', 'jetpack' ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'target' => array(),
+ ),
+ )
+ ),
+ 'https://wordpress.com/support/widgets/goodreads-widget/#set-up-the-widget'
+ );
if ( 'invalid' === $instance['user_id'] ) {
- printf( '<br /><small class="error">%s</small>&nbsp;', __( 'Invalid User ID, please verify and re-enter your Goodreads numeric user ID.', 'jetpack' ) );
+ printf( '<br /><small class="error">%s</small>&nbsp;', esc_html( __( 'Invalid User ID, please verify and re-enter your Goodreads numeric user ID.', 'jetpack' ) ) );
$instance['user_id'] = '';
}
echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'user_id' ) ) . '" name="' . esc_attr( $this->get_field_name( 'user_id' ) ) . '" type="text" value="' . esc_attr( $instance['user_id'] ) . '" />
@@ -148,7 +209,7 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
<p><label for="' . esc_attr( $this->get_field_id( 'shelf' ) ) . '">' . esc_html__( 'Shelf:', 'jetpack' ) . '
<select class="widefat" id="' . esc_attr( $this->get_field_id( 'shelf' ) ) . '" name="' . esc_attr( $this->get_field_name( 'shelf' ) ) . '" >';
foreach ( $this->shelves as $_shelf_value => $_shelf_display ) {
- echo "\t<option value='" . esc_attr( $_shelf_value ) . "'" . selected( $_shelf_value, $instance['shelf'] ) . '>' . $_shelf_display . "</option>\n";
+ echo "\t<option value='" . esc_attr( $_shelf_value ) . "'" . selected( $_shelf_value, $instance['shelf'], false ) . '>' . $_shelf_display . "</option>\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo '</select>
</label></p>
diff --git a/plugins/jetpack/modules/widgets/google-translate.php b/plugins/jetpack/modules/widgets/google-translate.php
index 0e270677..d6f0e88d 100644
--- a/plugins/jetpack/modules/widgets/google-translate.php
+++ b/plugins/jetpack/modules/widgets/google-translate.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Assets;
@@ -15,20 +15,28 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
+/**
+ * Jetpack_Google_Translate_Widget main class.
+ */
class Jetpack_Google_Translate_Widget extends WP_Widget {
- static $instance = null;
+ /**
+ * Singleton instance of the widget, not to show more than once.
+ *
+ * @var array
+ */
+ public static $instance = null;
/**
* Default widget title.
*
* @var string $default_title
*/
- var $default_title;
+ public $default_title;
/**
* Register widget with WordPress.
*/
- function __construct() {
+ public function __construct() {
parent::__construct(
'google_translate_widget',
/** This filter is documented in modules/widgets/facebook-likebox.php */
@@ -52,13 +60,22 @@ class Jetpack_Google_Translate_Widget extends WP_Widget {
Assets::get_file_url_for_environment(
'_inc/build/widgets/google-translate/google-translate.min.js',
'modules/widgets/google-translate/google-translate.js'
- )
+ ),
+ array(),
+ JETPACK__VERSION,
+ false
+ );
+ wp_register_script(
+ 'google-translate',
+ '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit',
+ array( 'google-translate-init' ),
+ JETPACK__VERSION,
+ false
);
- wp_register_script( 'google-translate', '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit', array( 'google-translate-init' ) );
// Admin bar is also displayed on top of the site which causes google translate bar to hide beneath.
// Overwrite position of body.admin-bar
// This is a hack to show google translate bar a bit lower.
- $lowerTranslateBar = '
+ $lower_translate_bar = '
.admin-bar {
position: inherit !important;
top: auto !important;
@@ -77,8 +94,8 @@ class Jetpack_Google_Translate_Widget extends WP_Widget {
}
}
';
- wp_add_inline_style( 'admin-bar', $lowerTranslateBar );
- wp_add_inline_style( 'wpcom-admin-bar', $lowerTranslateBar );
+ wp_add_inline_style( 'admin-bar', $lower_translate_bar );
+ wp_add_inline_style( 'wpcom-admin-bar', $lower_translate_bar );
}
/**
@@ -93,7 +110,8 @@ class Jetpack_Google_Translate_Widget extends WP_Widget {
// We never should show more than 1 instance of this.
if ( null === self::$instance ) {
$instance = wp_parse_args(
- $instance, array(
+ $instance,
+ array(
'title' => $this->default_title,
)
);
@@ -144,12 +162,12 @@ class Jetpack_Google_Translate_Widget extends WP_Widget {
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
$title = apply_filters( 'widget_title', $title );
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( ! empty( $title ) ) {
echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo '<div id="google_translate_element"></div>';
- echo $args['after_widget'];
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
self::$instance = $instance;
/** This action is documented in modules/widgets/gravatar-profile.php */
do_action( 'jetpack_stats_extra', 'widget_view', 'google-translate' );
@@ -186,11 +204,11 @@ class Jetpack_Google_Translate_Widget extends WP_Widget {
*
* @return array $instance Updated safe values to be saved.
*/
- public function update( $new_instance, $old_instance ) {
+ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$instance = array();
$instance['title'] = wp_kses( $new_instance['title'], array() );
if ( $instance['title'] === $this->default_title ) {
- $instance['title'] = false; // Store as false in case of language change
+ $instance['title'] = false; // Store as false in case of language change.
}
return $instance;
}
diff --git a/plugins/jetpack/modules/widgets/gravatar-profile.php b/plugins/jetpack/modules/widgets/gravatar-profile.php
index d2b13d12..14f8f78a 100644
--- a/plugins/jetpack/modules/widgets/gravatar-profile.php
+++ b/plugins/jetpack/modules/widgets/gravatar-profile.php
@@ -1,10 +1,10 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+
+add_action( 'widgets_init', 'jetpack_gravatar_profile_widget_init' );
/**
* Register the widget for use in Appearance -> Widgets
*/
-add_action( 'widgets_init', 'jetpack_gravatar_profile_widget_init' );
-
function jetpack_gravatar_profile_widget_init() {
register_widget( 'Jetpack_Gravatar_Profile_Widget' );
}
@@ -14,8 +14,10 @@ function jetpack_gravatar_profile_widget_init() {
* https://blog.gravatar.com/2010/03/26/gravatar-profiles/
*/
class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
-
- function __construct() {
+ /**
+ * Jetpack_Gravatar_Profile_Widget constructor.
+ */
+ public function __construct() {
parent::__construct(
'grofile',
/** This filter is documented in modules/widgets/facebook-likebox.php */
@@ -36,7 +38,15 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
}
}
- function widget( $args, $instance ) {
+ /**
+ * Display the Widget.
+ *
+ * @see WP_Widget::widget()
+ *
+ * @param array $args Display arguments.
+ * @param array $instance The settings for the particular instance of the widget.
+ */
+ public function widget( $args, $instance ) {
/**
* Fires when an item is displayed on the front end.
*
@@ -52,7 +62,8 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
do_action( 'jetpack_stats_extra', 'widget_view', 'grofile' );
$instance = wp_parse_args(
- $instance, array(
+ $instance,
+ array(
'title' => '',
'email' => '',
)
@@ -63,26 +74,38 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
if ( ! $instance['email'] ) {
if ( current_user_can( 'edit_theme_options' ) ) {
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( ! empty( $title ) ) {
echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
- echo '<p>' . sprintf( __( 'You need to select what to show in this <a href="%s">Gravatar Profile widget</a>.', 'jetpack' ), admin_url( 'widgets.php' ) ) . '</p>';
- echo $args['after_widget'];
+ echo '<p>' . wp_kses(
+ sprintf(
+ /* translators: %s is a link to the widget settings page. */
+ __( 'You need to select what to show in this <a href="%s">Gravatar Profile widget</a>.', 'jetpack' ),
+ admin_url( 'widgets.php' )
+ ),
+ array(
+ 'a' => array(
+ 'href' => true,
+ ),
+ )
+ ) . '</p>';
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
return;
}
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( ! empty( $title ) ) {
- echo $args['before_title'] . $title . $args['after_title'];
+ echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
$profile = $this->get_profile( $instance['email'] );
if ( ! empty( $profile ) ) {
$profile = wp_parse_args(
- $profile, array(
+ $profile,
+ array(
'thumbnailUrl' => '',
'profileUrl' => '',
'displayName' => '',
@@ -91,7 +114,7 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
'accounts' => array(),
)
);
- $gravatar_url = add_query_arg( 's', 320, $profile['thumbnailUrl'] ); // the default grav returned by grofiles is super small
+ $gravatar_url = add_query_arg( 's', 320, $profile['thumbnailUrl'] ); // The default grav returned by grofiles is super small.
// Enqueue front end assets.
$this->enqueue_scripts();
@@ -142,10 +165,15 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
}
}
- echo $args['after_widget'];
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
- function display_personal_links( $personal_links = array() ) {
+ /**
+ * Displays the "Personal Links" section.
+ *
+ * @param array $personal_links Array of links.
+ */
+ public function display_personal_links( $personal_links = array() ) {
if ( empty( $personal_links ) ) {
return;
}
@@ -168,7 +196,7 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
__( 'Personal Links', 'jetpack' )
)
);
- ?>
+ ?>
</h4>
<ul class="grofile-urls grofile-links">
@@ -187,7 +215,12 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
<?php
}
- function display_accounts( $accounts = array() ) {
+ /**
+ * Displays the "Verified Services" accounts.
+ *
+ * @param array $accounts Array of social accounts.
+ */
+ public function display_accounts( $accounts = array() ) {
if ( empty( $accounts ) ) {
return;
}
@@ -197,34 +230,40 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
<?php
echo esc_html(
/**
- * Filter the Gravatar Profile widget's "Verified Services" section title.
- *
- * @module widgets
- *
- * @since 2.8.0
- *
- * @param string $str "Verified Services" section title.
- */
- apply_filters(
- 'jetpack_gravatar_verified_services_title',
- __( 'Verified Services', 'jetpack' )
- )
+ * Filter the Gravatar Profile widget's "Verified Services" section title.
+ *
+ * @module widgets
+ *
+ * @since 2.8.0
+ *
+ * @param string $str "Verified Services" section title.
+ */
+ apply_filters(
+ 'jetpack_gravatar_verified_services_title',
+ __( 'Verified Services', 'jetpack' )
+ )
);
- ?>
+ ?>
</h4>
<ul class="grofile-urls grofile-accounts">
<?php
foreach ( $accounts as $account ) :
- if ( $account['verified'] != 'true' ) {
+ if ( 'true' !== $account['verified'] ) {
continue;
}
$sanitized_service_name = $this->get_sanitized_service_name( $account['shortname'] );
+ $link_title = sprintf(
+ /* translators: %1$s: service username. %2$s: service name ( Facebook, Twitter, etc.) */
+ _x( '%1$s on %2$s', '1: User Name, 2: Service Name (Facebook, Twitter, ...)', 'jetpack' ),
+ esc_html( $account['display'] ),
+ esc_html( $sanitized_service_name )
+ );
?>
<li>
- <a href="<?php echo esc_url( $account['url'] ); ?>" title="<?php echo sprintf( _x( '%1$s on %2$s', '1: User Name, 2: Service Name (Facebook, Twitter, ...)', 'jetpack' ), esc_html( $account['display'] ), esc_html( $sanitized_service_name ) ); ?>">
+ <a href="<?php echo esc_url( $account['url'] ); ?>" title="<?php echo esc_html( $link_title ); ?>">
<span class="grofile-accounts-logo grofile-accounts-<?php echo esc_attr( $account['shortname'] ); ?> accounts_<?php echo esc_attr( $account['shortname'] ); ?>"></span>
</a>
</li>
@@ -240,7 +279,7 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
*
* @since 4.0.0
*/
- function enqueue_scripts() {
+ public function enqueue_scripts() {
wp_enqueue_style(
'gravatar-profile-widget',
plugins_url( 'gravatar-profile.css', __FILE__ ),
@@ -256,7 +295,12 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
);
}
- function form( $instance ) {
+ /**
+ * Outputs the widget settings form.
+ *
+ * @param array $instance Current settings.
+ */
+ public function form( $instance ) {
$title = isset( $instance['title'] ) ? $instance['title'] : '';
$email = isset( $instance['email'] ) ? $instance['email'] : '';
$email_user = isset( $instance['email_user'] ) ? $instance['email_user'] : get_current_user_id();
@@ -267,19 +311,19 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
$profile_url = admin_url( 'profile.php' );
- if ( isset( $_REQUEST['calypso'] ) ) {
+ if ( isset( $_REQUEST['calypso'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$profile_url = 'https://wordpress.com/me';
}
}
?>
<p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>">
- <?php esc_html_e( 'Title', 'jetpack' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
+ <?php esc_html_e( 'Title', 'jetpack' ); ?> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</label>
</p>
<p>
- <label for="<?php echo $this->get_field_id( 'email_user' ); ?>">
+ <label for="<?php echo esc_attr( $this->get_field_id( 'email_user' ) ); ?>">
<?php esc_html_e( 'Select a user or pick "custom" and enter a custom email address.', 'jetpack' ); ?>
<br />
@@ -297,15 +341,15 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
</label>
</p>
- <p class="gprofile-email-container <?php echo empty( $email_user ) || $email_user == -1 ? '' : 'hidden'; ?>">
- <label for="<?php echo $this->get_field_id( 'email' ); ?>"><?php esc_html_e( 'Custom Email Address', 'jetpack' ); ?>
- <input class="widefat" id="<?php echo $this->get_field_id( 'email' ); ?>" name="<?php echo $this->get_field_name( 'email' ); ?>" type="text" value="<?php echo esc_attr( $email ); ?>" />
+ <p class="gprofile-email-container <?php echo empty( $email_user ) || -1 === (int) $email_user ? '' : 'hidden'; ?>">
+ <label for="<?php echo esc_attr( $this->get_field_id( 'email' ) ); ?>"><?php esc_html_e( 'Custom Email Address', 'jetpack' ); ?>
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'email' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'email' ) ); ?>" type="text" value="<?php echo esc_attr( $email ); ?>" />
</label>
</p>
<p>
- <label for="<?php echo $this->get_field_id( 'show_personal_links' ); ?>">
- <input type="checkbox" name="<?php echo $this->get_field_name( 'show_personal_links' ); ?>" id="<?php echo $this->get_field_id( 'show_personal_links' ); ?>" <?php checked( $show_personal_links ); ?> />
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_personal_links' ) ); ?>">
+ <input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_personal_links' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'show_personal_links' ) ); ?>" <?php checked( $show_personal_links ); ?> />
<?php esc_html_e( 'Show Personal Links', 'jetpack' ); ?>
<br />
<small><?php esc_html_e( 'Links to your websites, blogs, or any other sites that help describe who you are.', 'jetpack' ); ?></small>
@@ -313,8 +357,8 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
</p>
<p>
- <label for="<?php echo $this->get_field_id( 'show_account_links' ); ?>">
- <input type="checkbox" name="<?php echo $this->get_field_name( 'show_account_links' ); ?>" id="<?php echo $this->get_field_id( 'show_account_links' ); ?>" <?php checked( $show_account_links ); ?> />
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_account_links' ) ); ?>">
+ <input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_account_links' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'show_account_links' ) ); ?>" <?php checked( $show_account_links ); ?> />
<?php esc_html_e( 'Show Account Links', 'jetpack' ); ?>
<br />
<small><?php esc_html_e( 'Links to services that you use across the web.', 'jetpack' ); ?></small>
@@ -326,7 +370,10 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
<?php
}
- function admin_script() {
+ /**
+ * Inline admin script.
+ */
+ public function admin_script() {
?>
<script>
jQuery( function( $ ) {
@@ -343,8 +390,15 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
<?php
}
- function update( $new_instance, $old_instance ) {
-
+ /**
+ * Update widget.
+ *
+ * @see WP_Widget::update()
+ *
+ * @param array $new_instance New widget instance data.
+ * @param array $old_instance Old widget instance data.
+ */
+ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$instance = array();
$instance['title'] = isset( $new_instance['title'] ) ? wp_kses( $new_instance['title'], array() ) : '';
@@ -365,11 +419,17 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
return $instance;
}
+ /**
+ * Get the Gravatar profile for a given email address.
+ *
+ * @param string $email Email address.
+ */
private function get_profile( $email ) {
$hashed_email = md5( strtolower( trim( $email ) ) );
$cache_key = 'grofile-' . $hashed_email;
+ $profile = get_transient( $cache_key );
- if ( ! $profile = get_transient( $cache_key ) ) {
+ if ( ! $profile ) {
$profile_url = sprintf(
'https://secure.gravatar.com/%s.json',
$hashed_email
@@ -381,19 +441,19 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
array( 'User-Agent' => 'WordPress.com Gravatar Profile Widget' )
);
$response_code = wp_remote_retrieve_response_code( $response );
- if ( 200 == $response_code ) {
+ if ( 200 === $response_code ) {
$profile = wp_remote_retrieve_body( $response );
$profile = json_decode( $profile, true );
if ( is_array( $profile ) && ! empty( $profile['entry'] ) && is_array( $profile['entry'] ) ) {
- $expire = 900; // cache for 15 minutes
+ $expire = 900; // Cache for 15 minutes.
$profile = $profile['entry'][0];
} else {
// Something strange happened. Cache for 5 minutes.
$profile = array();
}
} else {
- $expire = 900; // cache for 15 minutes
+ $expire = 900; // Cache for 15 minutes.
$profile = array();
}
@@ -402,8 +462,15 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
return $profile;
}
+ /**
+ * Return properly capitalized service name.
+ *
+ * @param string $shortname The service.
+ *
+ * @return string
+ */
private function get_sanitized_service_name( $shortname ) {
- // Some services have stylized or mixed cap names *cough* WP *cough*
+ // Some services have stylized or mixed cap names *cough* WP *cough*.
switch ( $shortname ) {
case 'friendfeed':
return 'FriendFeed';
@@ -425,11 +492,9 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
case 'google':
return 'Google+';
default:
- // Others don't
+ // Others don't.
$shortname = ucwords( $shortname );
}
return $shortname;
}
}
-
-// END
diff --git a/plugins/jetpack/modules/widgets/image-widget.php b/plugins/jetpack/modules/widgets/image-widget.php
index e498f577..6bfa3178 100644
--- a/plugins/jetpack/modules/widgets/image-widget.php
+++ b/plugins/jetpack/modules/widgets/image-widget.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Module Name: Image Widget
* Module Description: Easily add images to your theme's sidebar.
@@ -6,10 +6,10 @@
* First Introduced: 1.2
*/
-/**
-* Register the widget for use in Appearance -> Widgets
-*/
add_action( 'widgets_init', 'jetpack_image_widget_init', 11 );
+/**
+ * Register the widget for use in Appearance -> Widgets
+ */
function jetpack_image_widget_init() {
if ( class_exists( 'WP_Widget_Media_Image' ) && Jetpack_Options::get_option( 'image_widget_migration' ) ) {
return;
@@ -17,10 +17,13 @@ function jetpack_image_widget_init() {
register_widget( 'Jetpack_Image_Widget' );
}
+/**
+ * Jetpack_Image_Widget main class.
+ */
class Jetpack_Image_Widget extends WP_Widget {
/**
- * Register widget with WordPress.
- */
+ * Register widget with WordPress.
+ */
public function __construct() {
parent::__construct(
'image',
@@ -39,27 +42,28 @@ class Jetpack_Image_Widget extends WP_Widget {
}
/**
- * Loads file for front-end widget style.
- *
- * @uses wp_enqueue_style(), plugins_url()
- */
+ * Loads file for front-end widget style.
+ *
+ * @uses wp_enqueue_style(), plugins_url()
+ */
public function enqueue_style() {
wp_enqueue_style( 'jetpack_image_widget', plugins_url( 'image-widget/style.css', __FILE__ ), array(), '20140808' );
}
/**
- * Front-end display of widget.
- *
- * @see WP_Widget::widget()
- *
- * @param array $args Widget arguments.
- * @param array $instance Saved values from database.
- */
+ * Front-end display of widget.
+ *
+ * @see WP_Widget::widget()
+ *
+ * @param array $args Widget arguments.
+ * @param array $instance Saved values from database.
+ */
public function widget( $args, $instance ) {
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$instance = wp_parse_args(
- $instance, array(
+ $instance,
+ array(
'title' => '',
'img_url' => '',
)
@@ -71,23 +75,23 @@ class Jetpack_Image_Widget extends WP_Widget {
echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
- if ( '' != $instance['img_url'] ) {
+ if ( $instance['img_url'] ) {
$output = '<img src="' . esc_url( $instance['img_url'] ) . '" ';
- if ( '' != $instance['alt_text'] ) {
+ if ( '' !== (string) $instance['alt_text'] ) {
$output .= 'alt="' . esc_attr( $instance['alt_text'] ) . '" ';
}
- if ( '' != $instance['img_title'] ) {
+ if ( '' !== (string) $instance['img_title'] ) {
$output .= 'title="' . esc_attr( $instance['img_title'] ) . '" ';
}
- if ( '' == $instance['caption'] ) {
+ if ( '' !== (string) $instance['caption'] ) {
$output .= 'class="align' . esc_attr( $instance['align'] ) . '" ';
}
- if ( '' != $instance['img_width'] ) {
+ if ( '' !== (string) $instance['img_width'] ) {
$output .= 'width="' . esc_attr( $instance['img_width'] ) . '" ';
}
- if ( '' != $instance['img_height'] ) {
+ if ( '' !== (string) $instance['img_height'] ) {
$output .= 'height="' . esc_attr( $instance['img_height'] ) . '" ';
}
$output .= '/>';
@@ -96,29 +100,40 @@ class Jetpack_Image_Widget extends WP_Widget {
$output = Jetpack_Photon::filter_the_content( $output );
}
- if ( '' != $instance['link'] ) {
+ if ( $instance['link'] ) {
$target = ! empty( $instance['link_target_blank'] )
? 'target="_blank"'
: '';
$output = '<a ' . $target . ' href="' . esc_url( $instance['link'] ) . '">' . $output . '</a>';
}
- if ( '' != $instance['caption'] ) {
+ if ( '' !== (string) $instance['caption'] ) {
/** This filter is documented in core/src/wp-includes/default-widgets.php */
$caption = apply_filters( 'widget_text', $instance['caption'] );
$img_width = ( ! empty( $instance['img_width'] ) ? 'style="width: ' . esc_attr( $instance['img_width'] ) . 'px"' : '' );
$output = '<figure ' . $img_width . ' class="wp-caption align' . esc_attr( $instance['align'] ) . '">
' . $output . '
<figcaption class="wp-caption-text">' . $caption . '</figcaption>
- </figure>'; // wp_kses_post caption on update
+ </figure>'; // wp_kses_post caption on update.
}
echo '<div class="jetpack-image-container">' . do_shortcode( $output ) . '</div>';
} else {
if ( current_user_can( 'edit_theme_options' ) ) {
- echo '<p>' . sprintf( __( 'Image missing or invalid URL. Please check the Image widget URL in your <a href="%s">widget settings</a>.', 'jetpack' ), admin_url( 'widgets.php' ) ) . '</p>';
+ echo '<p>' . wp_kses(
+ sprintf(
+ /* translators: %s link to the widget settings page. */
+ __( 'Image missing or invalid URL. Please check the Image widget URL in your <a href="%s">widget settings</a>.', 'jetpack' ),
+ admin_url( 'widgets.php' )
+ ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ ),
+ )
+ ) . '</p>';
}
}
- echo "\n" . $args['after_widget'];
+ echo "\n" . $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/** This action is documented in modules/widgets/gravatar-profile.php */
do_action( 'jetpack_stats_extra', 'widget_view', 'image' );
@@ -135,24 +150,24 @@ class Jetpack_Image_Widget extends WP_Widget {
* @return array Updated safe values to be saved.
*/
public function update( $new_instance, $old_instance ) {
- $allowed_caption_html = array(
- 'a' => array(
- 'href' => array(),
- 'title' => array(),
- ),
- 'b' => array(),
- 'em' => array(),
- 'i' => array(),
- 'p' => array(),
- 'strong' => array(),
- );
+ $allowed_caption_html = array(
+ 'a' => array(
+ 'href' => array(),
+ 'title' => array(),
+ ),
+ 'b' => array(),
+ 'em' => array(),
+ 'i' => array(),
+ 'p' => array(),
+ 'strong' => array(),
+ );
$instance = $old_instance;
- $instance['title'] = strip_tags( $new_instance['title'] );
+ $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
$instance['img_url'] = esc_url( trim( $new_instance['img_url'] ) );
- $instance['alt_text'] = strip_tags( $new_instance['alt_text'] );
- $instance['img_title'] = strip_tags( $new_instance['img_title'] );
+ $instance['alt_text'] = wp_strip_all_tags( $new_instance['alt_text'] );
+ $instance['img_title'] = wp_strip_all_tags( $new_instance['img_title'] );
$instance['caption'] = wp_kses( stripslashes( $new_instance['caption'] ), $allowed_caption_html );
$instance['align'] = $new_instance['align'];
$instance['link'] = esc_url( trim( $new_instance['link'] ) );
@@ -161,8 +176,8 @@ class Jetpack_Image_Widget extends WP_Widget {
$new_img_width = absint( $new_instance['img_width'] );
$new_img_height = absint( $new_instance['img_height'] );
- if ( ! empty( $instance['img_url'] ) && '' == $new_img_width && '' == $new_img_height ) {
- // Download the url to a local temp file and then process it with getimagesize so we can optimize browser layout
+ if ( ! empty( $instance['img_url'] ) && 0 === $new_img_width && 0 === $new_img_height ) {
+ // Download the url to a local temp file and then process it with getimagesize so we can optimize browser layout.
$tmp_file = download_url( $instance['img_url'], 10 );
if ( ! is_wp_error( $tmp_file ) ) {
$size = getimagesize( $tmp_file );
@@ -187,16 +202,17 @@ class Jetpack_Image_Widget extends WP_Widget {
}
/**
- * Back end widget form.
- *
- * @see WP_Widget::form()
- *
- * @param array $instance Previously saved values from database.
- */
+ * Back end widget form.
+ *
+ * @see WP_Widget::form()
+ *
+ * @param array $instance Previously saved values from database.
+ */
public function form( $instance ) {
- // Defaults
+ // Defaults.
$instance = wp_parse_args(
- (array) $instance, array(
+ (array) $instance,
+ array(
'title' => '',
'img_url' => '',
'alt_text' => '',
@@ -222,20 +238,20 @@ class Jetpack_Image_Widget extends WP_Widget {
$link = esc_url( $instance['link'], null, 'display' );
- echo '<p><label for="' . $this->get_field_id( 'title' ) . '">' . esc_html__( 'Widget title:', 'jetpack' ) . '
- <input class="widefat" id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" type="text" value="' . $title . '" />
+ echo '<p><label for="' . esc_attr( $this->get_field_id( 'title' ) ) . '">' . esc_html__( 'Widget title:', 'jetpack' ) . '
+ <input class="widefat" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" type="text" value="' . esc_attr( $title ) . '" />
</label></p>
- <p><label for="' . $this->get_field_id( 'img_url' ) . '">' . esc_html__( 'Image URL:', 'jetpack' ) . '
- <input class="widefat" id="' . $this->get_field_id( 'img_url' ) . '" name="' . $this->get_field_name( 'img_url' ) . '" type="text" value="' . $img_url . '" />
+ <p><label for="' . esc_attr( $this->get_field_id( 'img_url' ) ) . '">' . esc_html__( 'Image URL:', 'jetpack' ) . '
+ <input class="widefat" id="' . esc_attr( $this->get_field_id( 'img_url' ) ) . '" name="' . esc_attr( $this->get_field_name( 'img_url' ) ) . '" type="text" value="' . esc_attr( $img_url ) . '" />
</label></p>
- <p><label for="' . $this->get_field_id( 'alt_text' ) . '">' . esc_html__( 'Alternate text:', 'jetpack' ) . ' <a href="https://support.wordpress.com/widgets/image-widget/#image-widget-alt-text" target="_blank">( ? )</a>
- <input class="widefat" id="' . $this->get_field_id( 'alt_text' ) . '" name="' . $this->get_field_name( 'alt_text' ) . '" type="text" value="' . $alt_text . '" />
+ <p><label for="' . esc_attr( $this->get_field_id( 'alt_text' ) ) . '">' . esc_html__( 'Alternate text:', 'jetpack' ) . ' <a href="https://support.wordpress.com/widgets/image-widget/#image-widget-alt-text" target="_blank">( ? )</a>
+ <input class="widefat" id="' . esc_attr( $this->get_field_id( 'alt_text' ) ) . '" name="' . esc_attr( $this->get_field_name( 'alt_text' ) ) . '" type="text" value="' . esc_attr( $alt_text ) . '" />
</label></p>
- <p><label for="' . $this->get_field_id( 'img_title' ) . '">' . esc_html__( 'Image title:', 'jetpack' ) . ' <a href="https://support.wordpress.com/widgets/image-widget/#image-widget-title" target="_blank">( ? )</a>
- <input class="widefat" id="' . $this->get_field_id( 'img_title' ) . '" name="' . $this->get_field_name( 'img_title' ) . '" type="text" value="' . $img_title . '" />
+ <p><label for="' . esc_attr( $this->get_field_id( 'img_title' ) ) . '">' . esc_html__( 'Image title:', 'jetpack' ) . ' <a href="https://support.wordpress.com/widgets/image-widget/#image-widget-title" target="_blank">( ? )</a>
+ <input class="widefat" id="' . esc_attr( $this->get_field_id( 'img_title' ) ) . '" name="' . esc_attr( $this->get_field_name( 'img_title' ) ) . '" type="text" value="' . esc_attr( $img_title ) . '" />
</label></p>
- <p><label for="' . $this->get_field_id( 'caption' ) . '">' . esc_html__( 'Caption:', 'jetpack' ) . ' <a href="https://support.wordpress.com/widgets/image-widget/#image-widget-caption" target="_blank">( ? )</a>
- <textarea class="widefat" id="' . $this->get_field_id( 'caption' ) . '" name="' . $this->get_field_name( 'caption' ) . '" rows="2" cols="20">' . $caption . '</textarea>
+ <p><label for="' . esc_attr( $this->get_field_id( 'caption' ) ) . '">' . esc_html__( 'Caption:', 'jetpack' ) . ' <a href="https://support.wordpress.com/widgets/image-widget/#image-widget-caption" target="_blank">( ? )</a>
+ <textarea class="widefat" id="' . esc_attr( $this->get_field_id( 'caption' ) ) . '" name="' . esc_attr( $this->get_field_name( 'caption' ) ) . '" rows="2" cols="20">' . esc_textarea( $caption ) . '</textarea>
</label></p>';
$alignments = array(
@@ -244,29 +260,29 @@ class Jetpack_Image_Widget extends WP_Widget {
'center' => __( 'Center', 'jetpack' ),
'right' => __( 'Right', 'jetpack' ),
);
- echo '<p><label for="' . $this->get_field_id( 'align' ) . '">' . esc_html__( 'Image Alignment:', 'jetpack' ) . '
- <select id="' . $this->get_field_id( 'align' ) . '" name="' . $this->get_field_name( 'align' ) . '">';
+ echo '<p><label for="' . esc_attr( $this->get_field_id( 'align' ) ) . '">' . esc_html__( 'Image Alignment:', 'jetpack' ) . '
+ <select id="' . esc_attr( $this->get_field_id( 'align' ) ) . '" name="' . esc_attr( $this->get_field_name( 'align' ) ) . '">';
foreach ( $alignments as $alignment => $alignment_name ) {
- echo '<option value="' . esc_attr( $alignment ) . '" ';
- if ( $alignment == $align ) {
+ echo '<option value="' . esc_attr( $alignment ) . '" ';
+ if ( $alignment === $align ) {
echo 'selected="selected" ';
}
echo '>' . esc_html( $alignment_name ) . "</option>\n";
}
echo '</select></label></p>';
- echo '<p><label for="' . $this->get_field_id( 'img_width' ) . '">' . esc_html__( 'Width in pixels:', 'jetpack' ) . '
- <input size="3" id="' . $this->get_field_id( 'img_width' ) . '" name="' . $this->get_field_name( 'img_width' ) . '" type="text" value="' . $img_width . '" />
+ echo '<p><label for="' . esc_attr( $this->get_field_id( 'img_width' ) ) . '">' . esc_html__( 'Width in pixels:', 'jetpack' ) . '
+ <input size="3" id="' . esc_attr( $this->get_field_id( 'img_width' ) ) . '" name="' . esc_attr( $this->get_field_name( 'img_width' ) ) . '" type="text" value="' . esc_attr( $img_width ) . '" />
</label>
- <label for="' . $this->get_field_id( 'img_height' ) . '">' . esc_html__( 'Height in pixels:', 'jetpack' ) . '
- <input size="3" id="' . $this->get_field_id( 'img_height' ) . '" name="' . $this->get_field_name( 'img_height' ) . '" type="text" value="' . $img_height . '" />
+ <label for="' . esc_attr( $this->get_field_id( 'img_height' ) ) . '">' . esc_html__( 'Height in pixels:', 'jetpack' ) . '
+ <input size="3" id="' . esc_attr( $this->get_field_id( 'img_height' ) ) . '" name="' . esc_attr( $this->get_field_name( 'img_height' ) ) . '" type="text" value="' . esc_attr( $img_height ) . '" />
</label><br />
<small>' . esc_html__( 'If empty, we will attempt to determine the image size.', 'jetpack' ) . '</small></p>
- <p><label for="' . $this->get_field_id( 'link' ) . '">' . esc_html__( 'Link URL (when the image is clicked):', 'jetpack' ) . '
- <input class="widefat" id="' . $this->get_field_id( 'link' ) . '" name="' . $this->get_field_name( 'link' ) . '" type="text" value="' . $link . '" />
+ <p><label for="' . esc_attr( $this->get_field_id( 'link' ) ) . '">' . esc_html__( 'Link URL (when the image is clicked):', 'jetpack' ) . '
+ <input class="widefat" id="' . esc_attr( $this->get_field_id( 'link' ) ) . '" name="' . esc_attr( $this->get_field_name( 'link' ) ) . '" type="text" value="' . esc_attr( $link ) . '" />
</label>
- <label for="' . $this->get_field_id( 'link_target_blank' ) . '">
- <input type="checkbox" name="' . $this->get_field_name( 'link_target_blank' ) . '" id="' . $this->get_field_id( 'link_target_blank' ) . '" value="1"' . $link_target_blank . '/>
+ <label for="' . esc_attr( $this->get_field_id( 'link_target_blank' ) ) . '">
+ <input type="checkbox" name="' . esc_attr( $this->get_field_name( 'link_target_blank' ) ) . '" id="' . esc_attr( $this->get_field_id( 'link_target_blank' ) ) . '" value="1"' . esc_attr( $link_target_blank ) . '/>
' . esc_html__( 'Open link in a new window/tab', 'jetpack' ) . '
</label></p>';
}
diff --git a/plugins/jetpack/modules/widgets/internet-defense-league.php b/plugins/jetpack/modules/widgets/internet-defense-league.php
index ba4170fa..bb0404ca 100644
--- a/plugins/jetpack/modules/widgets/internet-defense-league.php
+++ b/plugins/jetpack/modules/widgets/internet-defense-league.php
@@ -1,20 +1,65 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Jetpack_Internet_Defense_League_Widget main class.
+ */
class Jetpack_Internet_Defense_League_Widget extends WP_Widget {
-
+ /**
+ * Default widget settings.
+ *
+ * @var array
+ */
public $defaults = array();
+ /**
+ * Selected display variant.
+ *
+ * @var string
+ */
public $variant;
+ /**
+ * Display variants.
+ *
+ * @var array
+ */
public $variants = array();
+ /**
+ * Selected campaign.
+ *
+ * @var string
+ */
public $campaign;
- public $campaigns = array();
+ /**
+ * Campaign options.
+ *
+ * @var array
+ */
+ public $campaigns = array();
+ /**
+ * False when enabling campaigns other than 'none' or empty.
+ *
+ * @var bool
+ */
public $no_current = true;
+ /**
+ * Selected badge to display.
+ *
+ * @var string
+ */
public $badge;
+ /**
+ * Badge display options.
+ *
+ * @var array
+ */
public $badges = array();
- function __construct() {
+ /**
+ * Jetpack_Internet_Defense_League_Widget constructor.
+ */
+ public function __construct() {
parent::__construct(
'internet_defense_league_widget',
/** This filter is documented in modules/widgets/facebook-likebox.php */
@@ -42,7 +87,7 @@ class Jetpack_Internet_Defense_League_Widget extends WP_Widget {
'side_bar_badge' => esc_html__( 'Red Cat Badge', 'jetpack' ),
);
- if ( $this->no_current === false ) {
+ if ( false === $this->no_current ) {
$this->badges['none'] = esc_html__( 'Don\'t display a badge (just the campaign)', 'jetpack' );
}
@@ -51,24 +96,45 @@ class Jetpack_Internet_Defense_League_Widget extends WP_Widget {
'variant' => key( $this->variants ),
'badge' => key( $this->badges ),
);
+
+ add_filter( 'widget_types_to_hide_from_legacy_widget_block', array( $this, 'hide_widget_in_block_editor' ) );
}
+ /**
+ * Remove the "Internet Defense League" widget from the Legacy Widget block
+ *
+ * @param array $widget_types List of widgets that are currently removed from the Legacy Widget block.
+ * @return array $widget_types New list of widgets that will be removed.
+ */
+ public function hide_widget_in_block_editor( $widget_types ) {
+ $widget_types[] = 'internet_defense_league_widget';
+ return $widget_types;
+ }
+
+ /**
+ * Display the Widget.
+ *
+ * @see WP_Widget::widget()
+ *
+ * @param array $args Display arguments.
+ * @param array $instance The settings for the particular instance of the widget.
+ */
public function widget( $args, $instance ) {
$instance = wp_parse_args( $instance, $this->defaults );
- if ( 'none' != $instance['badge'] ) {
+ if ( 'none' !== $instance['badge'] ) {
if ( ! isset( $this->badges[ $instance['badge'] ] ) ) {
$instance['badge'] = $this->defaults['badge'];
}
$badge_url = esc_url( 'https://www.internetdefenseleague.org/images/badges/final/' . $instance['badge'] . '.png' );
$photon_badge_url = jetpack_photon_url( $badge_url );
$alt_text = esc_html__( 'Member of The Internet Defense League', 'jetpack' );
- echo $args['before_widget'];
- echo '<p><a href="https://www.internetdefenseleague.org/"><img src="' . $photon_badge_url . '" alt="' . $alt_text . '" style="max-width: 100%; height: auto;" /></a></p>';
- echo $args['after_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ echo '<p><a href="https://www.internetdefenseleague.org/"><img src="' . esc_url( $photon_badge_url ) . '" alt="' . esc_attr( $alt_text ) . '" style="max-width: 100%; height: auto;" /></a></p>';
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
- if ( 'none' != $instance['campaign'] ) {
+ if ( 'none' !== $instance['campaign'] ) {
$this->campaign = $instance['campaign'];
$this->variant = $instance['variant'];
add_action( 'wp_footer', array( $this, 'footer_script' ) );
@@ -78,6 +144,9 @@ class Jetpack_Internet_Defense_League_Widget extends WP_Widget {
do_action( 'jetpack_stats_extra', 'widget_view', 'internet_defense_league' );
}
+ /**
+ * Inline footer script.
+ */
public function footer_script() {
if ( ! isset( $this->campaigns[ $this->campaign ] ) ) {
$this->campaign = $this->defaults['campaign'];
@@ -107,6 +176,13 @@ class Jetpack_Internet_Defense_League_Widget extends WP_Widget {
<?php
}
+ /**
+ * Widget form in the dashboard.
+ *
+ * @see WP_Widget::form()
+ *
+ * @param array $instance Previously saved values from database.
+ */
public function form( $instance ) {
$instance = wp_parse_args( $instance, $this->defaults );
@@ -128,29 +204,57 @@ class Jetpack_Internet_Defense_League_Widget extends WP_Widget {
$this->select( 'badge', $this->badges, $instance['badge'] );
echo '</label></p>';
- /* translators: %s is a name of an internet campaign called the "Internet Defense League" */
- echo '<p>' . sprintf( _x( 'Learn more about the %s', 'the Internet Defense League', 'jetpack' ), '<a href="https://www.internetdefenseleague.org/">Internet Defense League</a>' ) . '</p>';
+ echo '<p>' . wp_kses(
+ sprintf(
+ /* translators: %s is an HTML link to the website of an internet campaign called the "Internet Defense League" */
+ _x( 'Learn more about the %s', 'the Internet Defense League', 'jetpack' ),
+ '<a href="https://www.internetdefenseleague.org/">Internet Defense League</a>'
+ ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ ),
+ )
+ ) . '</p>';
}
+ /**
+ * Display a select form field.
+ *
+ * @param string $field_name Name of the field.
+ * @param array $options Array of options.
+ * @param string $default Default option.
+ */
public function select( $field_name, $options, $default = null ) {
- echo '<select class="widefat" name="' . $this->get_field_name( $field_name ) . '">';
+ echo '<select class="widefat" name="' . esc_attr( $this->get_field_name( $field_name ) ) . '">';
foreach ( $options as $option_slug => $option_name ) {
echo '<option value="' . esc_attr( $option_slug ) . '"' . selected( $option_slug, $default, false ) . '>' . esc_html( $option_name ) . '</option>';
}
echo '</select>';
}
- public function update( $new_instance, $old_instance ) {
+ /**
+ * Update widget.
+ *
+ * @see WP_Widget::update()
+ *
+ * @param array $new_instance New widget instance data.
+ * @param array $old_instance Old widget instance data.
+ */
+ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$instance = array();
$instance['campaign'] = ( isset( $new_instance['campaign'] ) && isset( $this->campaigns[ $new_instance['campaign'] ] ) ) ? $new_instance['campaign'] : $this->defaults['campaign'];
- $instance['variant'] = ( isset( $new_instance['variant'] ) && isset( $this->variants[ $new_instance['variant'] ] ) ) ? $new_instance['variant'] : $this->defaults['variant'];
- $instance['badge'] = ( isset( $new_instance['badge'] ) && isset( $this->badges[ $new_instance['badge'] ] ) ) ? $new_instance['badge'] : $this->defaults['badge'];
+ $instance['variant'] = ( isset( $new_instance['variant'] ) && isset( $this->variants[ $new_instance['variant'] ] ) ) ? $new_instance['variant'] : $this->defaults['variant'];
+ $instance['badge'] = ( isset( $new_instance['badge'] ) && isset( $this->badges[ $new_instance['badge'] ] ) ) ? $new_instance['badge'] : $this->defaults['badge'];
return $instance;
}
}
+/**
+ * Register the widget.
+ */
function jetpack_internet_defense_league_init() {
register_widget( 'Jetpack_Internet_Defense_League_Widget' );
}
diff --git a/plugins/jetpack/modules/widgets/mailchimp.php b/plugins/jetpack/modules/widgets/mailchimp.php
index 6f43b4db..3a8ec7a1 100644
--- a/plugins/jetpack/modules/widgets/mailchimp.php
+++ b/plugins/jetpack/modules/widgets/mailchimp.php
@@ -40,6 +40,19 @@ if ( ! class_exists( 'Jetpack_MailChimp_Subscriber_Popup_Widget' ) ) {
'customize_selective_refresh' => true,
)
);
+
+ add_filter( 'widget_types_to_hide_from_legacy_widget_block', array( $this, 'hide_widget_in_block_editor' ) );
+ }
+
+ /**
+ * Remove the "Mailchimp Subscriber Popup" widget from the Legacy Widget block
+ *
+ * @param array $widget_types List of widgets that are currently removed from the Legacy Widget block.
+ * @return array $widget_types New list of widgets that will be removed.
+ */
+ public function hide_widget_in_block_editor( $widget_types ) {
+ $widget_types[] = 'widget_mailchimp_subscriber_popup';
+ return $widget_types;
}
/**
diff --git a/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php b/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php
index 06f317ff..9acdb337 100644
--- a/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php
+++ b/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php
@@ -155,8 +155,8 @@ function jetpack_migrate_image_widget() {
// Set correct size if dimensions fit.
if (
- $media_image[ $id ]['width'] == $image_meta['width'] || // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
- $media_image[ $id ]['height'] == $image_meta['height'] // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
+ $media_image[ $id ]['width'] == $image_meta['width'] || // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
+ $media_image[ $id ]['height'] == $image_meta['height'] // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
) {
$media_image[ $id ]['size'] = 'full';
}
@@ -170,8 +170,8 @@ function jetpack_migrate_image_widget() {
// Set correct size if dimensions fit.
if (
- $media_image[ $id ]['width'] == $image['width'] || // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
- $media_image[ $id ]['height'] == $image['height'] // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
+ $media_image[ $id ]['width'] == $image['width'] || // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
+ $media_image[ $id ]['height'] == $image['height'] // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
) {
$media_image[ $id ]['size'] = $size;
}
diff --git a/plugins/jetpack/modules/widgets/my-community.php b/plugins/jetpack/modules/widgets/my-community.php
index c16baf21..cbd515aa 100644
--- a/plugins/jetpack/modules/widgets/my-community.php
+++ b/plugins/jetpack/modules/widgets/my-community.php
@@ -49,6 +49,19 @@ class Jetpack_My_Community_Widget extends WP_Widget {
}
$this->default_title = esc_html__( 'Community', 'jetpack' );
+
+ add_filter( 'widget_types_to_hide_from_legacy_widget_block', array( $this, 'hide_widget_in_block_editor' ) );
+ }
+
+ /**
+ * Remove the "My Community" widget from the Legacy Widget block
+ *
+ * @param array $widget_types List of widgets that are currently removed from the Legacy Widget block.
+ * @return array $widget_types New list of widgets that will be removed.
+ */
+ public function hide_widget_in_block_editor( $widget_types ) {
+ $widget_types[] = 'jetpack_my_community';
+ return $widget_types;
}
/**
diff --git a/plugins/jetpack/modules/widgets/search.php b/plugins/jetpack/modules/widgets/search.php
deleted file mode 100644
index 291649f2..00000000
--- a/plugins/jetpack/modules/widgets/search.php
+++ /dev/null
@@ -1,1083 +0,0 @@
-<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
-/**
- * Jetpack Search: Jetpack_Search_Widget class
- *
- * @package Jetpack
- * @subpackage Jetpack Search
- * @since 5.0.0
- */
-
-use Automattic\Jetpack\Redirect;
-use Automattic\Jetpack\Search\Helper;
-use Automattic\Jetpack\Search\Options;
-use Automattic\Jetpack\Status;
-use Automattic\Jetpack\Tracking;
-
-add_action( 'widgets_init', 'jetpack_search_widget_init' );
-
-/**
- * Register the widget if Jetpack Search is available and enabled.
- */
-function jetpack_search_widget_init() {
- if (
- ! Jetpack::is_connection_ready()
- || ( method_exists( 'Jetpack_Plan', 'supports' ) && ! Jetpack_Plan::supports( 'search' ) )
- || ! Jetpack::is_module_active( 'search' )
- ) {
- return;
- }
-
- register_widget( 'Jetpack_Search_Widget' );
-}
-
-/**
- * Provides a widget to show available/selected filters on searches.
- *
- * @since 5.0.0
- *
- * @see WP_Widget
- */
-class Jetpack_Search_Widget extends WP_Widget {
-
- /**
- * The Jetpack_Search instance.
- *
- * @since 5.7.0
- * @var Jetpack_Search
- */
- protected $jetpack_search;
-
- /**
- * Number of aggregations (filters) to show by default.
- *
- * @since 5.8.0
- * @var int
- */
- const DEFAULT_FILTER_COUNT = 5;
-
- /**
- * Default sort order for search results.
- *
- * @since 5.8.0
- * @var string
- */
- const DEFAULT_SORT = 'relevance_desc';
-
- /**
- * Jetpack_Search_Widget constructor.
- *
- * @since 5.0.0
- *
- * @param string $name Widget name.
- */
- public function __construct( $name = null ) {
- if ( empty( $name ) ) {
- $name = esc_html__( 'Search', 'jetpack' );
- }
- parent::__construct(
- Helper::FILTER_WIDGET_BASE,
- /** This filter is documented in modules/widgets/facebook-likebox.php */
- apply_filters( 'jetpack_widget_name', $name ),
- array(
- 'classname' => 'jetpack-filters widget_search',
- 'description' => __( 'Instant search and filtering to help visitors quickly find relevant answers and explore your site.', 'jetpack' ),
- )
- );
-
- if (
- Helper::is_active_widget( $this->id ) &&
- ! $this->is_search_active()
- ) {
- $this->activate_search();
- }
-
- if ( is_admin() ) {
- add_action( 'sidebar_admin_setup', array( $this, 'widget_admin_setup' ) );
- } else {
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_scripts' ) );
- }
-
- add_action( 'jetpack_search_render_filters_widget_title', array( 'Automattic\Jetpack\Search\Template_Tags', 'render_widget_title' ), 10, 3 );
- if ( Options::is_instant_enabled() ) {
- add_action( 'jetpack_search_render_filters', array( 'Automattic\Jetpack\Search\Template_Tags', 'render_instant_filters' ), 10, 2 );
- } else {
- add_action( 'jetpack_search_render_filters', array( 'Automattic\Jetpack\Search\Template_Tags', 'render_available_filters' ), 10, 2 );
- }
- }
-
- /**
- * Check whether search is currently active
- *
- * @since 6.3
- */
- public function is_search_active() {
- return Jetpack::is_module_active( 'search' );
- }
-
- /**
- * Activate search
- *
- * @since 6.3
- */
- public function activate_search() {
- Jetpack::activate_module( 'search', false, false );
- }
-
- /**
- * Enqueues the scripts and styles needed for the customizer.
- *
- * @since 5.7.0
- */
- public function widget_admin_setup() {
- wp_enqueue_style(
- 'widget-jetpack-search-filters',
- plugins_url( 'search/css/search-widget-admin-ui.css', __FILE__ ),
- array(),
- JETPACK__VERSION
- );
-
- // Register jp-tracks and jp-tracks-functions.
- Tracking::register_tracks_functions_scripts();
-
- wp_register_script(
- 'jetpack-search-widget-admin',
- plugins_url( 'search/js/search-widget-admin.js', __FILE__ ),
- array( 'jquery', 'jquery-ui-sortable', 'jp-tracks-functions' ),
- JETPACK__VERSION,
- false
- );
-
- wp_localize_script(
- 'jetpack-search-widget-admin',
- 'jetpack_search_filter_admin',
- array(
- 'defaultFilterCount' => self::DEFAULT_FILTER_COUNT,
- 'tracksUserData' => Jetpack_Tracks_Client::get_connected_user_tracks_identity(),
- 'tracksEventData' => array(
- 'is_customizer' => (int) is_customize_preview(),
- ),
- 'i18n' => array(
- 'month' => Helper::get_date_filter_type_name( 'month', false ),
- 'year' => Helper::get_date_filter_type_name( 'year', false ),
- 'monthUpdated' => Helper::get_date_filter_type_name( 'month', true ),
- 'yearUpdated' => Helper::get_date_filter_type_name( 'year', true ),
- ),
- )
- );
-
- wp_enqueue_script( 'jetpack-search-widget-admin' );
- }
-
- /**
- * Enqueue scripts and styles for the frontend.
- *
- * @since 5.8.0
- */
- public function enqueue_frontend_scripts() {
- if ( ! is_active_widget( false, false, $this->id_base, true ) || Options::is_instant_enabled() ) {
- return;
- }
-
- wp_enqueue_script(
- 'jetpack-search-widget',
- plugins_url( 'search/js/search-widget.js', __FILE__ ),
- array(),
- JETPACK__VERSION,
- true
- );
-
- wp_enqueue_style(
- 'jetpack-search-widget',
- plugins_url( 'search/css/search-widget-frontend.css', __FILE__ ),
- array(),
- JETPACK__VERSION
- );
- }
-
- /**
- * Get the list of valid sort types/orders.
- *
- * @since 5.8.0
- *
- * @return array The sort orders.
- */
- private function get_sort_types() {
- return array(
- 'relevance|DESC' => is_admin() ? esc_html__( 'Relevance (recommended)', 'jetpack' ) : esc_html__( 'Relevance', 'jetpack' ),
- 'date|DESC' => esc_html__( 'Newest first', 'jetpack' ),
- 'date|ASC' => esc_html__( 'Oldest first', 'jetpack' ),
- );
- }
-
- /**
- * Callback for an array_filter() call in order to only get filters for the current widget.
- *
- * @see Jetpack_Search_Widget::widget()
- *
- * @since 5.7.0
- *
- * @param array $item Filter item.
- *
- * @return bool Whether the current filter item is for the current widget.
- */
- public function is_for_current_widget( $item ) {
- return isset( $item['widget_id'] ) && $this->id == $item['widget_id']; // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
- }
-
- /**
- * This method returns a boolean for whether the widget should show site-wide filters for the site.
- *
- * This is meant to provide backwards-compatibility for VIP, and other professional plan users, that manually
- * configured filters via `Jetpack_Search::set_filters()`.
- *
- * @since 5.7.0
- *
- * @return bool Whether the widget should display site-wide filters or not.
- */
- public function should_display_sitewide_filters() {
- $filter_widgets = get_option( 'widget_jetpack-search-filters' );
-
- // This shouldn't be empty, but just for sanity.
- if ( empty( $filter_widgets ) ) {
- return false;
- }
-
- // If any widget has any filters, return false.
- foreach ( $filter_widgets as $number => $widget ) {
- $widget_id = sprintf( '%s-%d', $this->id_base, $number );
- if ( ! empty( $widget['filters'] ) && is_active_widget( false, $widget_id, $this->id_base ) ) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Widget defaults.
- *
- * @param array $instance Previously saved values from database.
- */
- public function jetpack_search_populate_defaults( $instance ) {
- $instance = wp_parse_args(
- (array) $instance,
- array(
- 'title' => '',
- 'search_box_enabled' => true,
- 'user_sort_enabled' => true,
- 'sort' => self::DEFAULT_SORT,
- 'filters' => array( array() ),
- 'post_types' => array(),
- )
- );
-
- return $instance;
- }
-
- /**
- * Populates the instance array with appropriate default values.
- *
- * @since 8.6.0
- * @param array $instance Previously saved values from database.
- * @return array Instance array with default values approprate for instant search
- */
- public function populate_defaults_for_instant_search( $instance ) {
- return wp_parse_args(
- (array) $instance,
- array(
- 'title' => '',
- 'filters' => array(),
- )
- );
- }
-
- /**
- * Responsible for rendering the widget on the frontend.
- *
- * @since 5.0.0
- *
- * @param array $args Widgets args supplied by the theme.
- * @param array $instance The current widget instance.
- */
- public function widget( $args, $instance ) {
- $instance = $this->jetpack_search_populate_defaults( $instance );
-
- if ( ( new Status() )->is_offline_mode() ) {
- echo $args['before_widget']; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- ?><div id="<?php echo esc_attr( $this->id ); ?>-wrapper">
- <div class="jetpack-search-sort-wrapper">
- <label>
- <?php esc_html_e( 'Jetpack Search not supported in Offline Mode', 'jetpack' ); ?>
- </label>
- </div>
- </div>
- <?php
- echo $args['after_widget']; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- return;
- }
-
- if ( Options::is_instant_enabled() ) {
- if ( array_key_exists( 'id', $args ) && 'jetpack-instant-search-sidebar' === $args['id'] ) {
- $this->widget_empty_instant( $args, $instance );
- } else {
- $this->widget_instant( $args, $instance );
- }
- } else {
- $this->widget_non_instant( $args, $instance );
- }
- }
-
- /**
- * Render the non-instant frontend widget.
- *
- * @since 8.3.0
- *
- * @param array $args Widgets args supplied by the theme.
- * @param array $instance The current widget instance.
- */
- public function widget_non_instant( $args, $instance ) {
- $display_filters = false;
-
- if ( is_search() ) {
- if ( Helper::should_rerun_search_in_customizer_preview() ) {
- Jetpack_Search::instance()->update_search_results_aggregations();
- }
-
- $filters = Jetpack_Search::instance()->get_filters();
-
- if ( ! Helper::are_filters_by_widget_disabled() && ! $this->should_display_sitewide_filters() ) {
- $filters = array_filter( $filters, array( $this, 'is_for_current_widget' ) );
- }
-
- if ( ! empty( $filters ) ) {
- $display_filters = true;
- }
- }
-
- if ( ! $display_filters && empty( $instance['search_box_enabled'] ) && empty( $instance['user_sort_enabled'] ) ) {
- return;
- }
-
- $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
-
- /** This filter is documented in core/src/wp-includes/default-widgets.php */
- $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
-
- echo $args['before_widget']; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- ?>
- <div id="<?php echo esc_attr( $this->id ); ?>-wrapper" >
- <?php
-
- if ( ! empty( $title ) ) {
- /**
- * Responsible for displaying the title of the Jetpack Search filters widget.
- *
- * @module search
- *
- * @since 5.7.0
- *
- * @param string $title The widget's title
- * @param string $args['before_title'] The HTML tag to display before the title
- * @param string $args['after_title'] The HTML tag to display after the title
- */
- do_action( 'jetpack_search_render_filters_widget_title', $title, $args['before_title'], $args['after_title'] );
- }
-
- $default_sort = isset( $instance['sort'] ) ? $instance['sort'] : self::DEFAULT_SORT;
- list( $orderby, $order ) = $this->sorting_to_wp_query_param( $default_sort );
- $current_sort = "{$orderby}|{$order}";
-
- // we need to dynamically inject the sort field into the search box when the search box is enabled, and display
- // it separately when it's not.
- if ( ! empty( $instance['search_box_enabled'] ) ) {
- Automattic\Jetpack\Search\Template_Tags::render_widget_search_form( $instance['post_types'], $orderby, $order );
- }
-
- if ( ! empty( $instance['search_box_enabled'] ) && ! empty( $instance['user_sort_enabled'] ) ) :
- ?>
- <div class="jetpack-search-sort-wrapper">
- <label>
- <?php esc_html_e( 'Sort by', 'jetpack' ); ?>
- <select class="jetpack-search-sort">
- <?php foreach ( $this->get_sort_types() as $sort => $label ) { ?>
- <option value="<?php echo esc_attr( $sort ); ?>" <?php selected( $current_sort, $sort ); ?>>
- <?php echo esc_html( $label ); ?>
- </option>
- <?php } ?>
- </select>
- </label>
- </div>
- <?php
- endif;
-
- if ( $display_filters ) {
- /**
- * Responsible for rendering filters to narrow down search results.
- *
- * @module search
- *
- * @since 5.8.0
- *
- * @param array $filters The possible filters for the current query.
- * @param array $post_types An array of post types to limit filtering to.
- */
- do_action(
- 'jetpack_search_render_filters',
- $filters,
- isset( $instance['post_types'] ) ? $instance['post_types'] : null
- );
- }
-
- $this->maybe_render_sort_javascript( $instance, $order, $orderby );
-
- echo '</div>';
- echo $args['after_widget']; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- }
-
- /**
- * Render the instant frontend widget.
- *
- * @since 8.3.0
- *
- * @param array $args Widgets args supplied by the theme.
- * @param array $instance The current widget instance.
- */
- public function widget_instant( $args, $instance ) {
- if ( Helper::should_rerun_search_in_customizer_preview() ) {
- Jetpack_Search::instance()->update_search_results_aggregations();
- }
-
- $filters = Jetpack_Search::instance()->get_filters();
- if ( ! Helper::are_filters_by_widget_disabled() && ! $this->should_display_sitewide_filters() ) {
- $filters = array_filter( $filters, array( $this, 'is_for_current_widget' ) );
- }
-
- $display_filters = ! empty( $filters );
-
- $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
-
- /** This filter is documented in core/src/wp-includes/default-widgets.php */
- $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
-
- echo $args['before_widget']; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- ?>
- <div id="<?php echo esc_attr( $this->id ); ?>-wrapper" class="jetpack-instant-search-wrapper">
- <?php
-
- if ( ! empty( $title ) ) {
- /**
- * Responsible for displaying the title of the Jetpack Search filters widget.
- *
- * @module search
- *
- * @since 5.7.0
- *
- * @param string $title The widget's title
- * @param string $args['before_title'] The HTML tag to display before the title
- * @param string $args['after_title'] The HTML tag to display after the title
- */
- do_action( 'jetpack_search_render_filters_widget_title', $title, $args['before_title'], $args['after_title'] );
- }
-
- Automattic\Jetpack\Search\Template_Tags::render_widget_search_form( array(), '', '' );
-
- if ( $display_filters ) {
- /**
- * Responsible for rendering filters to narrow down search results.
- *
- * @module search
- *
- * @since 5.8.0
- *
- * @param array $filters The possible filters for the current query.
- * @param array $post_types An array of post types to limit filtering to.
- */
- do_action(
- 'jetpack_search_render_filters',
- $filters,
- null
- );
- }
-
- echo '</div>';
- echo $args['after_widget']; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- }
-
- /**
- * Render the instant widget for the overlay.
- *
- * @since 8.3.0
- *
- * @param array $args Widgets args supplied by the theme.
- * @param array $instance The current widget instance.
- */
- public function widget_empty_instant( $args, $instance ) {
- $title = isset( $instance['title'] ) ? $instance['title'] : '';
-
- if ( empty( $title ) ) {
- $title = '';
- }
-
- /** This filter is documented in core/src/wp-includes/default-widgets.php */
- $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
-
- echo $args['before_widget']; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- ?>
- <div id="<?php echo esc_attr( $this->id ); ?>-wrapper" class="jetpack-instant-search-wrapper">
- <?php
-
- if ( ! empty( $title ) ) {
- /**
- * Responsible for displaying the title of the Jetpack Search filters widget.
- *
- * @module search
- *
- * @since 5.7.0
- *
- * @param string $title The widget's title
- * @param string $args['before_title'] The HTML tag to display before the title
- * @param string $args['after_title'] The HTML tag to display after the title
- */
- do_action( 'jetpack_search_render_filters_widget_title', $title, $args['before_title'], $args['after_title'] );
- }
-
- echo '</div>';
- echo $args['after_widget']; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- }
-
- /**
- * Renders JavaScript for the sorting controls on the frontend.
- *
- * This JS is a bit complicated, but here's what it's trying to do:
- * - find the search form
- * - find the orderby/order fields and set default values
- * - detect changes to the sort field, if it exists, and use it to set the order field values
- *
- * @since 5.8.0
- *
- * @param array $instance The current widget instance.
- * @param string $order The order to initialize the select with.
- * @param string $orderby The orderby to initialize the select with.
- */
- private function maybe_render_sort_javascript( $instance, $order, $orderby ) {
- if ( Options::is_instant_enabled() ) {
- return;
- }
-
- if ( ! empty( $instance['user_sort_enabled'] ) ) :
- ?>
- <script type="text/javascript">
- var jetpackSearchModuleSorting = function() {
- var orderByDefault = '<?php echo 'date' === $orderby ? 'date' : 'relevance'; ?>',
- orderDefault = '<?php echo 'ASC' === $order ? 'ASC' : 'DESC'; ?>',
- widgetId = decodeURIComponent( '<?php echo rawurlencode( $this->id ); ?>' ),
- searchQuery = decodeURIComponent( '<?php echo rawurlencode( get_query_var( 's', '' ) ); ?>' ),
- isSearch = <?php echo (int) is_search(); ?>;
-
- var container = document.getElementById( widgetId + '-wrapper' ),
- form = container.querySelector( '.jetpack-search-form form' ),
- orderBy = form.querySelector( 'input[name=orderby]' ),
- order = form.querySelector( 'input[name=order]' ),
- searchInput = form.querySelector( 'input[name="s"]' ),
- sortSelectInput = container.querySelector( '.jetpack-search-sort' );
-
- orderBy.value = orderByDefault;
- order.value = orderDefault;
-
- // Some themes don't set the search query, which results in the query being lost
- // when doing a sort selection. So, if the query isn't set, let's set it now. This approach
- // is chosen over running a regex over HTML for every search query performed.
- if ( isSearch && ! searchInput.value ) {
- searchInput.value = searchQuery;
- }
-
- searchInput.classList.add( 'show-placeholder' );
-
- sortSelectInput.addEventListener( 'change', function( event ) {
- var values = event.target.value.split( '|' );
- orderBy.value = values[0];
- order.value = values[1];
-
- form.submit();
- } );
- }
-
- if ( document.readyState === 'interactive' || document.readyState === 'complete' ) {
- jetpackSearchModuleSorting();
- } else {
- document.addEventListener( 'DOMContentLoaded', jetpackSearchModuleSorting );
- }
- </script>
- <?php
- endif;
- }
-
- /**
- * Convert a sort string into the separate order by and order parts.
- *
- * @since 5.8.0
- *
- * @param string $sort A sort string.
- *
- * @return array Order by and order.
- */
- private function sorting_to_wp_query_param( $sort ) {
- // phpcs:disable WordPress.Security.NonceVerification.Recommended
- $parts = explode( '|', $sort );
- $orderby = isset( $_GET['orderby'] )
- ? $_GET['orderby']
- : $parts[0];
-
- $order = isset( $_GET['order'] )
- ? strtoupper( $_GET['order'] )
- : ( ( isset( $parts[1] ) && 'ASC' === strtoupper( $parts[1] ) ) ? 'ASC' : 'DESC' );
-
- // phpcs:enable WordPress.Security.NonceVerification.Recommended
-
- return array( $orderby, $order );
- }
-
- /**
- * Updates a particular instance of the widget. Validates and sanitizes the options.
- *
- * @since 5.0.0
- *
- * @param array $new_instance New settings for this instance as input by the user via Jetpack_Search_Widget::form().
- * @param array $old_instance Old settings for this instance.
- *
- * @return array Settings to save.
- */
- public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
- $new_instance = $this->maybe_reformat_widget( $new_instance );
- $instance = array();
-
- $instance['title'] = sanitize_text_field( $new_instance['title'] );
- $instance['search_box_enabled'] = empty( $new_instance['search_box_enabled'] ) ? '0' : '1';
- $instance['user_sort_enabled'] = empty( $new_instance['user_sort_enabled'] ) ? '0' : '1';
- $instance['sort'] = $new_instance['sort'];
- $instance['post_types'] = empty( $new_instance['post_types'] ) || empty( $instance['search_box_enabled'] )
- ? array()
- : array_map( 'sanitize_key', $new_instance['post_types'] );
-
- $filters = array();
- if ( isset( $new_instance['filter_type'] ) ) {
- foreach ( (array) $new_instance['filter_type'] as $index => $type ) {
- $count = (int) $new_instance['num_filters'][ $index ];
- $count = min( 50, $count ); // Set max boundary at 50.
- $count = max( 1, $count ); // Set min boundary at 1.
-
- switch ( $type ) {
- case 'taxonomy':
- $filters[] = array(
- 'name' => sanitize_text_field( $new_instance['filter_name'][ $index ] ),
- 'type' => 'taxonomy',
- 'taxonomy' => sanitize_key( $new_instance['taxonomy_type'][ $index ] ),
- 'count' => $count,
- );
- break;
- case 'post_type':
- $filters[] = array(
- 'name' => sanitize_text_field( $new_instance['filter_name'][ $index ] ),
- 'type' => 'post_type',
- 'count' => $count,
- );
- break;
- case 'date_histogram':
- $filters[] = array(
- 'name' => sanitize_text_field( $new_instance['filter_name'][ $index ] ),
- 'type' => 'date_histogram',
- 'count' => $count,
- 'field' => sanitize_key( $new_instance['date_histogram_field'][ $index ] ),
- 'interval' => sanitize_key( $new_instance['date_histogram_interval'][ $index ] ),
- );
- break;
- }
- }
- }
-
- if ( ! empty( $filters ) ) {
- $instance['filters'] = $filters;
- }
-
- return $instance;
- }
-
- /**
- * Reformats the widget instance array to one that is recognized by the `update` function.
- * This is only necessary when handling changes from the block-based widget editor.
- *
- * @param array $widget_instance - Jetpack Search widget instance.
- *
- * @return array - Potentially reformatted instance compatible with the save function.
- */
- protected function maybe_reformat_widget( $widget_instance ) {
- if ( isset( $widget_instance['filter_type'] ) || ! isset( $widget_instance['filters'] ) || ! is_array( $widget_instance['filters'] ) ) {
- return $widget_instance;
- }
-
- $instance = $widget_instance;
- foreach ( $widget_instance['filters'] as $filter ) {
- $instance['filter_type'][] = isset( $filter['type'] ) ? $filter['type'] : '';
- $instance['taxonomy_type'][] = isset( $filter['taxonomy'] ) ? $filter['taxonomy'] : '';
- $instance['filter_name'][] = isset( $filter['name'] ) ? $filter['name'] : '';
- $instance['num_filters'][] = isset( $filter['count'] ) ? $filter['count'] : 5;
- $instance['date_histogram_field'][] = isset( $filter['field'] ) ? $filter['field'] : '';
- $instance['date_histogram_interval'][] = isset( $filter['interval'] ) ? $filter['interval'] : '';
- }
- unset( $instance['filters'] );
- return $instance;
- }
-
- /**
- * Outputs the settings update form.
- *
- * @since 5.0.0
- *
- * @param array $instance Previously saved values from database.
- */
- public function form( $instance ) {
- if ( Options::is_instant_enabled() ) {
- return $this->form_for_instant_search( $instance );
- }
-
- $instance = $this->jetpack_search_populate_defaults( $instance );
-
- $title = wp_strip_all_tags( $instance['title'] );
-
- $hide_filters = Helper::are_filters_by_widget_disabled();
-
- $classes = sprintf(
- 'jetpack-search-filters-widget %s %s %s',
- $hide_filters ? 'hide-filters' : '',
- $instance['search_box_enabled'] ? '' : 'hide-post-types',
- $this->id
- );
- ?>
- <div class="<?php echo esc_attr( $classes ); ?>">
- <p>
- <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
- <?php esc_html_e( 'Title (optional):', 'jetpack' ); ?>
- </label>
- <input
- class="widefat"
- id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
- name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
- type="text"
- value="<?php echo esc_attr( $title ); ?>"
- />
- </p>
-
- <p>
- <label>
- <input
- type="checkbox"
- class="jetpack-search-filters-widget__search-box-enabled"
- name="<?php echo esc_attr( $this->get_field_name( 'search_box_enabled' ) ); ?>"
- <?php checked( $instance['search_box_enabled'] ); ?>
- />
- <?php esc_html_e( 'Show search box', 'jetpack' ); ?>
- </label>
- </p>
-
- <p>
- <label>
- <input
- type="checkbox"
- class="jetpack-search-filters-widget__sort-controls-enabled"
- name="<?php echo esc_attr( $this->get_field_name( 'user_sort_enabled' ) ); ?>"
- <?php checked( $instance['user_sort_enabled'] ); ?>
- <?php disabled( ! $instance['search_box_enabled'] ); ?>
- />
- <?php esc_html_e( 'Show sort selection dropdown', 'jetpack' ); ?>
- </label>
- </p>
-
- <p class="jetpack-search-filters-widget__post-types-select">
- <label><?php esc_html_e( 'Post types to search (minimum of 1):', 'jetpack' ); ?></label>
- <?php foreach ( get_post_types( array( 'exclude_from_search' => false ), 'objects' ) as $post_type ) : ?>
- <label>
- <input
- type="checkbox"
- value="<?php echo esc_attr( $post_type->name ); ?>"
- name="<?php echo esc_attr( $this->get_field_name( 'post_types' ) ); ?>[]"
- <?php checked( empty( $instance['post_types'] ) || in_array( $post_type->name, $instance['post_types'], true ) ); ?>
- />&nbsp;
- <?php echo esc_html( $post_type->label ); ?>
- </label>
- <?php endforeach; ?>
- </p>
-
- <p>
- <label>
- <?php esc_html_e( 'Default sort order:', 'jetpack' ); ?>
- <select
- name="<?php echo esc_attr( $this->get_field_name( 'sort' ) ); ?>"
- class="widefat jetpack-search-filters-widget__sort-order">
- <?php foreach ( $this->get_sort_types() as $sort_type => $label ) { ?>
- <option value="<?php echo esc_attr( $sort_type ); ?>" <?php selected( $instance['sort'], $sort_type ); ?>>
- <?php echo esc_html( $label ); ?>
- </option>
- <?php } ?>
- </select>
- </label>
- </p>
-
- <?php if ( ! $hide_filters ) : ?>
- <script class="jetpack-search-filters-widget__filter-template" type="text/template">
- <?php
- echo $this->render_widget_edit_filter( array(), true ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- ?>
- </script>
- <div class="jetpack-search-filters-widget__filters">
- <?php foreach ( (array) $instance['filters'] as $filter ) : ?>
- <?php $this->render_widget_edit_filter( $filter ); ?>
- <?php endforeach; ?>
- </div>
- <p class="jetpack-search-filters-widget__add-filter-wrapper">
- <a class="button jetpack-search-filters-widget__add-filter" href="#">
- <?php esc_html_e( 'Add a filter', 'jetpack' ); ?>
- </a>
- </p>
- <noscript>
- <p class="jetpack-search-filters-help">
- <?php echo esc_html_e( 'Adding filters requires JavaScript!', 'jetpack' ); ?>
- </p>
- </noscript>
- <?php if ( is_customize_preview() ) : ?>
- <p class="jetpack-search-filters-help">
- <a href="<?php echo esc_url( Redirect::get_url( 'jetpack-support-search', array( 'anchor' => 'filters-not-showing-up' ) ) ); ?>" target="_blank">
- <?php esc_html_e( "Why aren't my filters appearing?", 'jetpack' ); ?>
- </a>
- </p>
- <?php endif; ?>
- <?php endif; ?>
- </div>
- <?php
- }
-
- /**
- * Outputs the widget update form to be used in the Customizer for Instant Search.
- *
- * @since 8.6.0
- *
- * @param array $instance Previously saved values from database.
- */
- private function form_for_instant_search( $instance ) {
- $instance = $this->populate_defaults_for_instant_search( $instance );
- $classes = sprintf( 'jetpack-search-filters-widget %s', $this->id );
-
- ?>
- <div class="<?php echo esc_attr( $classes ); ?>">
- <!-- Title control -->
- <p>
- <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
- <?php esc_html_e( 'Title (optional):', 'jetpack' ); ?>
- </label>
- <input
- class="widefat"
- id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
- name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
- type="text"
- value="<?php echo esc_attr( wp_strip_all_tags( $instance['title'] ) ); ?>"
- />
- </p>
-
- <!-- Filters control -->
- <?php if ( ! Helper::are_filters_by_widget_disabled() ) : ?>
- <div class="jetpack-search-filters-widget__filters">
- <?php foreach ( (array) $instance['filters'] as $filter ) : ?>
- <?php $this->render_widget_edit_filter( $filter ); ?>
- <?php endforeach; ?>
- </div>
- <p class="jetpack-search-filters-widget__add-filter-wrapper">
- <a class="button jetpack-search-filters-widget__add-filter" href="#">
- <?php esc_html_e( 'Add a filter', 'jetpack' ); ?>
- </a>
- </p>
- <script class="jetpack-search-filters-widget__filter-template" type="text/template">
- <?php $this->render_widget_edit_filter( array(), true ); ?>
- </script>
- <noscript>
- <p class="jetpack-search-filters-help">
- <?php echo esc_html_e( 'Adding filters requires JavaScript!', 'jetpack' ); ?>
- </p>
- </noscript>
- <?php endif; ?>
- </div>
- <?php
- }
-
- /**
- * We need to render HTML in two formats: an Underscore template (client-side)
- * and native PHP (server-side). This helper function allows for easy rendering
- * of attributes in both formats.
- *
- * @since 5.8.0
- *
- * @param string $name Attribute name.
- * @param string $value Attribute value.
- * @param bool $is_template Whether this is for an Underscore template or not.
- */
- private function render_widget_attr( $name, $value, $is_template ) {
- echo $is_template ? "<%= $name %>" : esc_attr( $value ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- }
-
- /**
- * We need to render HTML in two formats: an Underscore template (client-size)
- * and native PHP (server-side). This helper function allows for easy rendering
- * of the "selected" attribute in both formats.
- *
- * @since 5.8.0
- *
- * @param string $name Attribute name.
- * @param string $value Attribute value.
- * @param string $compare Value to compare to the attribute value to decide if it should be selected.
- * @param bool $is_template Whether this is for an Underscore template or not.
- */
- private function render_widget_option_selected( $name, $value, $compare, $is_template ) {
- $compare_js = rawurlencode( $compare );
- echo $is_template ? "<%= decodeURIComponent( '$compare_js' ) === $name ? 'selected=\"selected\"' : '' %>" : selected( $value, $compare ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- }
-
- /**
- * Responsible for rendering a single filter in the customizer or the widget administration screen in wp-admin.
- *
- * We use this method for two purposes - rendering the fields server-side, and also rendering a script template for Underscore.
- *
- * @since 5.7.0
- *
- * @param array $filter The filter to render.
- * @param bool $is_template Whether this is for an Underscore template or not.
- */
- public function render_widget_edit_filter( $filter, $is_template = false ) {
- $args = wp_parse_args(
- $filter,
- array(
- 'name' => '',
- 'type' => 'taxonomy',
- 'taxonomy' => '',
- 'post_type' => '',
- 'field' => '',
- 'interval' => '',
- 'count' => self::DEFAULT_FILTER_COUNT,
- )
- );
-
- $args['name_placeholder'] = Helper::generate_widget_filter_name( $args );
-
- ?>
- <div class="jetpack-search-filters-widget__filter is-<?php $this->render_widget_attr( 'type', $args['type'], $is_template ); ?>">
- <p class="jetpack-search-filters-widget__type-select">
- <label>
- <?php esc_html_e( 'Filter Type:', 'jetpack' ); ?>
- <select name="<?php echo esc_attr( $this->get_field_name( 'filter_type' ) ); ?>[]" class="widefat filter-select">
- <option value="taxonomy" <?php $this->render_widget_option_selected( 'type', $args['type'], 'taxonomy', $is_template ); ?>>
- <?php esc_html_e( 'Taxonomy', 'jetpack' ); ?>
- </option>
- <option value="post_type" <?php $this->render_widget_option_selected( 'type', $args['type'], 'post_type', $is_template ); ?>>
- <?php esc_html_e( 'Post Type', 'jetpack' ); ?>
- </option>
- <option value="date_histogram" <?php $this->render_widget_option_selected( 'type', $args['type'], 'date_histogram', $is_template ); ?>>
- <?php esc_html_e( 'Date', 'jetpack' ); ?>
- </option>
- </select>
- </label>
- </p>
-
- <p class="jetpack-search-filters-widget__taxonomy-select">
- <label>
- <?php
- esc_html_e( 'Choose a taxonomy:', 'jetpack' );
- $seen_taxonomy_labels = array();
- ?>
- <select name="<?php echo esc_attr( $this->get_field_name( 'taxonomy_type' ) ); ?>[]" class="widefat taxonomy-select">
- <?php foreach ( get_taxonomies( array( 'public' => true ), 'objects' ) as $taxonomy ) : ?>
- <option value="<?php echo esc_attr( $taxonomy->name ); ?>" <?php $this->render_widget_option_selected( 'taxonomy', $args['taxonomy'], $taxonomy->name, $is_template ); ?>>
- <?php
- $label = in_array( $taxonomy->label, $seen_taxonomy_labels, true )
- ? sprintf(
- /* translators: %1$s is the taxonomy name, %2s is the name of its type to help distinguish between several taxonomies with the same name, e.g. category and tag. */
- _x( '%1$s (%2$s)', 'A label for a taxonomy selector option', 'jetpack' ),
- $taxonomy->label,
- $taxonomy->name
- )
- : $taxonomy->label;
- echo esc_html( $label );
- $seen_taxonomy_labels[] = $taxonomy->label;
- ?>
- </option>
- <?php endforeach; ?>
- </select>
- </label>
- </p>
-
- <p class="jetpack-search-filters-widget__date-histogram-select">
- <label>
- <?php esc_html_e( 'Choose a field:', 'jetpack' ); ?>
- <select name="<?php echo esc_attr( $this->get_field_name( 'date_histogram_field' ) ); ?>[]" class="widefat date-field-select">
- <option value="post_date" <?php $this->render_widget_option_selected( 'field', $args['field'], 'post_date', $is_template ); ?>>
- <?php esc_html_e( 'Date', 'jetpack' ); ?>
- </option>
- <option value="post_date_gmt" <?php $this->render_widget_option_selected( 'field', $args['field'], 'post_date_gmt', $is_template ); ?>>
- <?php esc_html_e( 'Date GMT', 'jetpack' ); ?>
- </option>
- <option value="post_modified" <?php $this->render_widget_option_selected( 'field', $args['field'], 'post_modified', $is_template ); ?>>
- <?php esc_html_e( 'Modified', 'jetpack' ); ?>
- </option>
- <option value="post_modified_gmt" <?php $this->render_widget_option_selected( 'field', $args['field'], 'post_modified_gmt', $is_template ); ?>>
- <?php esc_html_e( 'Modified GMT', 'jetpack' ); ?>
- </option>
- </select>
- </label>
- </p>
-
- <p class="jetpack-search-filters-widget__date-histogram-select">
- <label>
- <?php esc_html_e( 'Choose an interval:', 'jetpack' ); ?>
- <select name="<?php echo esc_attr( $this->get_field_name( 'date_histogram_interval' ) ); ?>[]" class="widefat date-interval-select">
- <option value="month" <?php $this->render_widget_option_selected( 'interval', $args['interval'], 'month', $is_template ); ?>>
- <?php esc_html_e( 'Month', 'jetpack' ); ?>
- </option>
- <option value="year" <?php $this->render_widget_option_selected( 'interval', $args['interval'], 'year', $is_template ); ?>>
- <?php esc_html_e( 'Year', 'jetpack' ); ?>
- </option>
- </select>
- </label>
- </p>
-
- <p class="jetpack-search-filters-widget__title">
- <label>
- <?php esc_html_e( 'Title:', 'jetpack' ); ?>
- <input
- class="widefat"
- type="text"
- name="<?php echo esc_attr( $this->get_field_name( 'filter_name' ) ); ?>[]"
- value="<?php $this->render_widget_attr( 'name', $args['name'], $is_template ); ?>"
- placeholder="<?php $this->render_widget_attr( 'name_placeholder', $args['name_placeholder'], $is_template ); ?>"
- />
- </label>
- </p>
-
- <p>
- <label>
- <?php esc_html_e( 'Maximum number of filters (1-50):', 'jetpack' ); ?>
- <input
- class="widefat filter-count"
- name="<?php echo esc_attr( $this->get_field_name( 'num_filters' ) ); ?>[]"
- type="number"
- value="<?php $this->render_widget_attr( 'count', $args['count'], $is_template ); ?>"
- min="1"
- max="50"
- step="1"
- required
- />
- </label>
- </p>
-
- <p class="jetpack-search-filters-widget__controls">
- <a href="#" class="delete"><?php esc_html_e( 'Remove', 'jetpack' ); ?></a>
- </p>
- </div>
- <?php
- }
-}
diff --git a/plugins/jetpack/modules/widgets/search/css/search-widget-admin-ui.css b/plugins/jetpack/modules/widgets/search/css/search-widget-admin-ui.css
deleted file mode 100644
index b5f4544a..00000000
--- a/plugins/jetpack/modules/widgets/search/css/search-widget-admin-ui.css
+++ /dev/null
@@ -1,87 +0,0 @@
-.jetpack-search-filters-widget__filter {
- background: #f6f7f7;
- border: 1px solid #dcdcde;
- padding: 0 12px;
- margin-bottom: 12px;
- cursor: move;
-}
-
-.jetpack-search-filters-widget__controls {
- text-align: right;
-}
-
-.jetpack-search-filters-widget .jetpack-search-filters-widget__sort-controls-enabled {
- margin-left: 24px;
-}
-
-.jetpack-search-filters-widget__controls .delete {
- color: #d63638;
-}
-
-.jetpack-search-filters-widget.hide-filters .jetpack-search-filters-widget__filter {
- display: none;
-}
-
-.button.jetpack-search-filters-widget__add-filter {
- margin-bottom: 10px;
-}
-
-/* Assume that taxonomy select is the default selected. Other controls should be hidden here. */
-.jetpack-search-filters-widget__post-type-select {
- display: none;
-}
-
-.jetpack-search-filters-widget__date-histogram-select {
- display: none;
-}
-
-.jetpack-search-filters-widget__filter-placeholder {
- border: 1px #555 dashed;
- background-color: #f0f0f1;
- height: 286px;
- margin-bottom: 12px;
-}
-
-/* When post type is selected, remove the other controls */
-.jetpack-search-filters-widget__filter.is-post_type .jetpack-search-filters-widget__taxonomy-select {
- display: none;
-}
-
-/* When date is selected, remove the other controls */
-.jetpack-search-filters-widget__filter.is-date_histogram .jetpack-search-filters-widget__date-histogram-select {
- display: inline;
-}
-
-.jetpack-search-filters-widget__filter.is-date_histogram .jetpack-search-filters-widget__taxonomy-select {
- display: none;
-}
-
-.jetpack-search-filters-widget.hide-post-types .jetpack-search-filters-widget__post-types-select {
- display: none;
-}
-
-.jetpack-search-filters-help:before {
- display: inline-block;
- position: relative;
- font-family: dashicons;
- font-size: 20px;
- top: 5px;
- line-height: 1px;
- content:"\f223";
-}
-.jetpack-search-filters-help {
- padding: 5px 5px 15px 0;
-}
-
-.jetpack-search-filters-widget__post-types-select label {
- display: block;
- margin-bottom: 4px;
-}
-
-.jetpack-search-filters-widget__post-types-select input[type="checkbox"] {
- margin-left: 24px;
-}
-
-body.no-js .jetpack-search-filters-widget__add-filter-wrapper {
- display: none;
-}
diff --git a/plugins/jetpack/modules/widgets/search/css/search-widget-frontend.css b/plugins/jetpack/modules/widgets/search/css/search-widget-frontend.css
deleted file mode 100644
index 58c7cf3e..00000000
--- a/plugins/jetpack/modules/widgets/search/css/search-widget-frontend.css
+++ /dev/null
@@ -1,66 +0,0 @@
-.jetpack-search-filters-widget__sub-heading {
- font-size: inherit;
- font-weight: bold;
- margin: 0 0 .5em;
- padding: 0;
-}
-
-/* The first heading after the form */
-.jetpack-search-form + .jetpack-search-filters-widget__sub-heading {
- margin-top: 1.5em;
- margin-bottom: 0.5em !important;
-}
-
-.jetpack-search-filters-widget__clear {
- margin-top: 0.5em;
- margin-bottom: 0.5em;
-}
-
-.jetpack-search-sort-wrapper {
- margin-top: 1em;
- margin-bottom: 1.5em;
-}
-
-.jetpack-search-sort-wrapper label {
- display: inherit;
-}
-
-.widget_search .jetpack-search-filters-widget__filter-list input[type="checkbox"] {
- width: auto;
- height: auto;
-}
-
-ul.jetpack-search-filters-widget__filter-list li {
- border: none;
- padding: 0;
- list-style: none;
-}
-
-ul.jetpack-search-filters-widget__filter-list li a {
- text-decoration: none;
-}
-
-ul.jetpack-search-filters-widget__filter-list li a:hover {
- box-shadow: none;
-}
-
-ul.jetpack-search-filters-widget__filter-list li label {
- font-weight: inherit;
- display: inherit;
-}
-
-.jetpack-search-filters-widget__filter-list {
- list-style: none;
-}
-
-ul.jetpack-search-filters-widget__filter-list {
- margin-bottom: 1.5em;
-}
-
-body.search .jetpack-search-form input[name="s"]::placeholder {
- color: transparent;
-}
-
-body.search .jetpack-search-form input[name="s"].show-placeholder::placeholder {
- color: inherit;
-}
diff --git a/plugins/jetpack/modules/widgets/search/js/search-widget-admin.js b/plugins/jetpack/modules/widgets/search/js/search-widget-admin.js
deleted file mode 100644
index d4ae235f..00000000
--- a/plugins/jetpack/modules/widgets/search/js/search-widget-admin.js
+++ /dev/null
@@ -1,358 +0,0 @@
-/* globals jetpack_search_filter_admin, jQuery, analytics */
-
-( function( $, args ) {
- var defaultFilterCount = ( 'undefined' !== typeof args && args.defaultFilterCount ) ?
- args.defaultFilterCount :
- 5; // Just in case we couldn't find the defaultFiltercount arg
-
- $( document ).ready( function() {
- setListeners();
-
- window.JetpackSearch = window.JetpackSearch || {};
- window.JetpackSearch.addFilter = addFilter;
-
- // Initialize Tracks
- if ( 'undefined' !== typeof analytics && args.tracksUserData ) {
- analytics.initialize( args.tracksUserData.userid, args.tracksUserData.username );
- }
- } );
-
- function generateFilterTitlePlaceholder( container ) {
- var placeholder = null,
- isModified = null,
- isMonth = null,
- type = container.find( '.filter-select' ).val();
-
- if ( 'taxonomy' === type ) {
- placeholder = container.find('.taxonomy-select option:selected').text().trim();
- } else if ( 'date_histogram' === type && args && args.i18n ) {
- isModified = ( -1 !== container.find( '.date-field-select' ).val().indexOf( 'modified' ) );
- isMonth = ( 'month' === container.find( '.date-interval-select' ).val() );
-
- if ( isMonth ) {
- placeholder = isModified ?
- args.i18n.monthUpdated :
- args.i18n.month;
- } else {
- placeholder = isModified ?
- args.i18n.yearUpdated :
- args.i18n.year;
- }
- } else {
- placeholder = container.find('.filter-select option:selected').text().trim();
- }
-
- $( container ).find('.jetpack-search-filters-widget__title input').prop( 'placeholder', placeholder );
- }
-
- var addFilter = function( filtersContainer, args ) {
- var template = _.template(
- filtersContainer
- .closest( '.jetpack-search-filters-widget' )
- .find( '.jetpack-search-filters-widget__filter-template' )
- .html()
- );
- generateFilterTitlePlaceholder( filtersContainer.append( template( args ) ) );
- };
-
- var setListeners = function( widget ) {
- widget = ( 'undefined' === typeof widget ) ?
- $( '.jetpack-search-filters-widget' ):
- widget;
-
- var getContainer = function( el ) {
- return $( el ).closest('.jetpack-search-filters-widget__filter');
- };
-
- widget.on( 'change', '.filter-select', function() {
- var select = $( this ),
- selectVal = select.val(),
- eventArgs = {
- is_customizer: args.tracksEventData.is_customizer
- };
-
- eventArgs.type = selectVal;
-
- select
- .closest( '.jetpack-search-filters-widget__filter' )
- .attr( 'class', 'jetpack-search-filters-widget__filter' )
- .addClass( 'is-' + selectVal );
-
- generateFilterTitlePlaceholder( getContainer( this ) );
-
- trackAndBumpMCStats( 'changed_filter_type', eventArgs );
- } );
-
- // enable showing sort controls only if showing search box is enabled
- widget.on( 'change', '.jetpack-search-filters-widget__search-box-enabled', function() {
- var checkbox = $( this ),
- checkboxVal = checkbox.is(':checked'),
- filterParent = checkbox.closest( '.jetpack-search-filters-widget' ),
- sortControl = filterParent.find( '.jetpack-search-filters-widget__sort-controls-enabled' );
-
- filterParent.toggleClass( 'hide-post-types' );
-
- if ( checkboxVal ) {
- sortControl.removeAttr( 'disabled' );
- trackAndBumpMCStats( 'enabled_search_box', args.tracksEventData );
- } else {
- sortControl.prop( 'checked', false );
- sortControl.prop( 'disabled', true );
- trackAndBumpMCStats( 'disabled_search_box', args.tracksEventData );
- }
- } );
-
- widget.on( 'change', '.jetpack-search-filters-widget__sort-controls-enabled', function() {
- if ( $( this ).is( ':checked' ) ) {
- trackAndBumpMCStats( 'enabled_sort_controls', args.tracksEventData );
- } else {
- trackAndBumpMCStats( 'disabled_sort_controls', args.tracksEventData );
- }
- } );
-
- widget.on( 'click', '.jetpack-search-filters-widget__post-types-select input[type="checkbox"]', function( e ) {
- var t = $( this );
- var siblingsChecked = t.closest( '.jetpack-search-filters-widget' )
- .find( '.jetpack-search-filters-widget__post-types-select input[type="checkbox"]:checked' );
-
- if ( 0 === siblingsChecked.length ) {
- e.preventDefault();
- e.stopPropagation();
-
- trackAndBumpMCStats( 'attempted_no_post_types', args.tracksEventData );
- }
- } );
-
- widget.on( 'change', '.jetpack-search-filters-widget__post-types-select input[type="checkbox"]', function() {
- var t = $( this );
- var eventArgs = {
- is_customizer: args.tracksEventData.is_customizer,
- post_type: t.val()
- };
-
- if ( wp && wp.customize ) {
- wp.customize.state( 'saved' ).set( false );
- }
-
- if ( t.is( ':checked' ) ) {
- trackAndBumpMCStats( 'added_post_type', eventArgs );
- } else {
- trackAndBumpMCStats( 'removed_post_type', eventArgs );
- }
- } );
-
- widget.on( 'change', '.jetpack-search-filters-widget__sort-order', function() {
- var eventArgs = {
- is_customizer: args.tracksEventData.is_customizer
- };
-
- eventArgs.order = $( this ).val();
-
- if ( wp && wp.customize ) {
- wp.customize.state( 'saved' ).set( false );
- }
-
- trackAndBumpMCStats( 'changed_sort_order', eventArgs );
- } );
-
- widget.on( 'change', '.jetpack-search-filters-widget__taxonomy-select select', function() {
- var eventArgs = {
- is_customizer: args.tracksEventData.is_customizer
- };
-
- eventArgs.taxonomy = $( this ).val();
-
- generateFilterTitlePlaceholder( getContainer( this ) );
-
- if ( wp && wp.customize ) {
- wp.customize.state( 'saved' ).set( false );
- }
-
- trackAndBumpMCStats( 'changed_taxonomy', eventArgs );
- } );
-
- widget.on( 'change', 'select.date-field-select', function() {
- var eventArgs = {
- is_customizer: args.tracksEventData.is_customizer
- };
-
- eventArgs.field = $( this ).val();
-
- generateFilterTitlePlaceholder( getContainer( this ) );
-
- if ( wp && wp.customize ) {
- wp.customize.state( 'saved' ).set( false );
- }
-
- trackAndBumpMCStats( 'changed_date_field', eventArgs );
- } );
-
- widget.on( 'change', 'select.date-interval-select', function() {
- var eventArgs = {
- is_customizer: args.tracksEventData.is_customizer
- };
-
- eventArgs.interval = $( this ).val();
-
- generateFilterTitlePlaceholder( getContainer( this ) );
-
- if ( wp && wp.customize ) {
- wp.customize.state( 'saved' ).set( false );
- }
-
- trackAndBumpMCStats( 'changed_date_interval', eventArgs );
- } );
-
- widget.on( 'change', 'input.filter-count', function() {
- var eventArgs = {
- is_customizer: args.tracksEventData.is_customizer
- };
-
- eventArgs.count = $( this ).val();
-
- if ( wp && wp.customize ) {
- wp.customize.state( 'saved' ).set( false );
- }
-
- trackAndBumpMCStats( 'changed_filter_count', eventArgs );
- } );
-
- // add filter button
- widget.on( 'click', '.jetpack-search-filters-widget__add-filter', function( e ) {
- e.preventDefault();
-
- var filtersContainer = $( this )
- .closest( '.jetpack-search-filters-widget' )
- .find( '.jetpack-search-filters-widget__filters' );
-
- addFilter( filtersContainer, {
- type: 'taxonomy',
- taxonomy: '',
- post_type: '',
- field: '',
- interval: '',
- count: defaultFilterCount,
- name_placeholder: '',
- name: ''
- } );
-
- if ( wp && wp.customize ) {
- wp.customize.state( 'saved' ).set( false );
- }
-
- // Trigger change event to let legacy widget admin know the widget state is "dirty"
- filtersContainer
- .find( '.jetpack-search-filters-widget__filter' )
- .find( 'input, textarea, select' )
- .change();
-
- trackAndBumpMCStats( 'added_filter', args.tracksEventData );
- } );
-
- widget.on( 'click', '.jetpack-search-filters-widget__controls .delete', function( e ) {
- e.preventDefault();
- var filter = $( this ).closest( '.jetpack-search-filters-widget__filter' ),
- eventArgs = {
- is_customizer: args.tracksEventData.is_customizer
- };
-
- eventArgs.type = filter.find( '.filter-select' ).val();
-
- switch ( eventArgs.type ) {
- case 'taxonomy':
- eventArgs.taxonomy = filter.find( '.jetpack-search-filters-widget__taxonomy-select select' ).val();
- break;
- case 'date_histogram':
- eventArgs.dateField = filter.find( '.jetpack-search-filters-widget__date-histogram-select:first select' ).val();
- eventArgs.dateInterval = filter.find( '.jetpack-search-filters-widget__date-histogram-select:nth-child( 2 ) select' ).val();
- break;
- }
-
- eventArgs.filterCount = filter.find( '.filter-count' ).val();
-
- trackAndBumpMCStats( 'deleted_filter', eventArgs );
-
- filter.find( 'input, textarea, select' ).change();
- filter.remove();
-
- if ( wp && wp.customize ) {
- wp.customize.state( 'saved' ).set( false );
- }
- } );
-
- // make the filters sortable
- $( '.jetpack-search-filters-widget__filters' ).sortable( {
- placeholder: 'jetpack-search-filters-widget__filter-placeholder',
- axis: 'y',
- revert: true,
- cancel: 'input,textarea,button,select,option,.jetpack-search-filters-widget__controls a',
- change: function() {
- if ( wp && wp.customize ) {
- wp.customize.state( 'saved' ).set( false );
- }
- },
- update: function( e, ui ) {
- $( ui.item ).find( 'input, textarea, select' ).change();
- }
- } )
- .disableSelection();
- };
-
- // When widgets are updated, remove and re-add listeners
- $( document ).on( 'widget-updated widget-added', function( e, widget ) {
- var idBase = $( widget ).find('.id_base').val(),
- isJetpackSearch = ( idBase && ( 'jetpack-search-filters' === idBase ) );
-
- if ( ! isJetpackSearch ) {
- return;
- }
-
- // Intentionally not tracking widget additions and updates here as these events
- // seem noisy in the customizer. We'll track those via PHP.
-
- widget.off( 'change', '.filter-select' );
- widget.off( 'click', '.jetpack-search-filters-widget__controls .delete' );
- widget.off( 'change', '.jetpack-search-filters-widget__use-filters' );
- widget.off( 'change', '.jetpack-search-filters-widget__search-box-enabled' );
- widget.off( 'change', '.jetpack-search-filters-widget__sort-controls-enabled' );
- widget.off( 'change', '.jetpack-search-filters-widget__sort-controls-enabled' );
- widget.off( 'change', '.jetpack-search-filters-widget__post-type-selector' );
- widget.off( 'change', '.jetpack-search-filters-widget__sort-order' );
- widget.off( 'change', '.jetpack-search-filters-widget__taxonomy-select' );
- widget.off( 'change', '.jetpack-search-filters-widget__date-histogram-select:first select' );
- widget.off( 'change', '.jetpack-search-filters-widget__date-histogram-select:eq(1) select' );
- widget.off( 'click', '.jetpack-search-filters-widget__post-types-select input[type="checkbox"]' );
- widget.off( 'click', '.jetpack-search-filters-widget__add-filter');
-
- setListeners( widget );
- } );
-
- /**
- * This function will fire both a Tracks and MC stat.
- *
- * Tracks: Will be prefixed by 'jetpack_widget_search_' and use underscores.
- * MC: Will not be prefixed, and will use dashes.
- *
- * Logic borrowed from `idc-notice.js`.
- *
- * @param eventName string
- * @param extraProps object
- */
- function trackAndBumpMCStats( eventName, extraProps ) {
- if ( 'undefined' === typeof extraProps || 'object' !== typeof extraProps ) {
- extraProps = {};
- }
-
- if ( eventName && eventName.length && 'undefined' !== typeof analytics && analytics.tracks && analytics.mc ) {
- // Format for Tracks
- eventName = eventName.replace( /-/g, '_' );
- eventName = eventName.indexOf( 'jetpack_widget_search_' ) !== 0 ? 'jetpack_widget_search_' + eventName : eventName;
- analytics.tracks.recordEvent( eventName, extraProps );
-
- // Now format for MC stats
- eventName = eventName.replace( 'jetpack_widget_search_', '' );
- eventName = eventName.replace( /_/g, '-' );
- analytics.mc.bumpStat( 'jetpack-search-widget', eventName );
- }
- }
-} )( jQuery, jetpack_search_filter_admin );
diff --git a/plugins/jetpack/modules/widgets/search/js/search-widget.js b/plugins/jetpack/modules/widgets/search/js/search-widget.js
deleted file mode 100644
index 0f47e8e8..00000000
--- a/plugins/jetpack/modules/widgets/search/js/search-widget.js
+++ /dev/null
@@ -1,47 +0,0 @@
-var jetpackSearchModule = function () {
- var i,
- j,
- checkboxes,
- filter_list = document.querySelectorAll( '.jetpack-search-filters-widget__filter-list' );
-
- for ( i = 0; i < filter_list.length; i++ ) {
- filter_list[ i ].addEventListener( 'click', function ( event ) {
- var target = event.target;
- var precedingCheckbox;
- var nextAnchor;
-
- // If the target is an anchor, we want to toggle the checkbox.
- if ( target.nodeName && 'a' === target.nodeName.toLowerCase() ) {
- precedingCheckbox = target.previousElementSibling;
- if (
- precedingCheckbox &&
- precedingCheckbox.type &&
- 'checkbox' === precedingCheckbox.type
- ) {
- precedingCheckbox.checked = ! precedingCheckbox.checked;
- }
- }
-
- // If the target is a checkbox, we want to navigate.
- if ( target.type && 'checkbox' === target.type ) {
- nextAnchor = target.nextElementSibling;
- if ( nextAnchor && 'a' === nextAnchor.nodeName.toLowerCase() ) {
- window.location.href = nextAnchor.getAttribute( 'href' );
- }
- }
- } );
-
- // Enable checkboxes now that we're setup.
- checkboxes = filter_list[ i ].querySelectorAll( 'input[type="checkbox"]' );
- for ( j = 0; j < checkboxes.length; j++ ) {
- checkboxes[ j ].disabled = false;
- checkboxes[ j ].style.cursor = 'inherit';
- }
- }
-};
-
-if ( document.readyState === 'interactive' || document.readyState === 'complete' ) {
- jetpackSearchModule();
-} else {
- document.addEventListener( 'DOMContentLoaded', jetpackSearchModule );
-}
diff --git a/plugins/jetpack/modules/widgets/simple-payments.php b/plugins/jetpack/modules/widgets/simple-payments.php
index 6c721f91..4662d9d2 100644
--- a/plugins/jetpack/modules/widgets/simple-payments.php
+++ b/plugins/jetpack/modules/widgets/simple-payments.php
@@ -1,4 +1,4 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Tracking;
/**
@@ -17,6 +17,8 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
class Jetpack_Simple_Payments_Widget extends WP_Widget {
/**
* Currencies should be supported by PayPal:
+ *
+ * @var array $supported_currency_list
* @link https://developer.paypal.com/docs/api/reference/currency-codes/
*
* List has to be in sync with list at the block's client side and API's backend side:
@@ -58,7 +60,7 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
/**
* Constructor.
*/
- function __construct() {
+ public function __construct() {
parent::__construct(
'jetpack_simple_payments_widget',
/** This filter is documented in modules/widgets/facebook-likebox.php */
@@ -75,7 +77,7 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_styles' ) );
}
- $jetpack_simple_payments = Jetpack_Simple_Payments::getInstance();
+ $jetpack_simple_payments = Jetpack_Simple_Payments::get_instance();
if ( is_customize_preview() && $jetpack_simple_payments->is_enabled_jetpack_simple_payments() ) {
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
@@ -138,29 +140,54 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
* @param array $nonces Array of nonces.
* @return array $nonces Modified array of nonces.
*/
- function filter_nonces( $nonces ) {
+ public function filter_nonces( $nonces ) {
$nonces['customize-jetpack-simple-payments'] = wp_create_nonce( 'customize-jetpack-simple-payments' );
return $nonces;
}
- function enqueue_style() {
+ /**
+ * Enqueue styles.
+ */
+ public function enqueue_style() {
wp_enqueue_style( 'jetpack-simple-payments-widget-style', plugins_url( 'simple-payments/style.css', __FILE__ ), array(), '20180518' );
}
- function admin_enqueue_styles() {
- wp_enqueue_style( 'jetpack-simple-payments-widget-customizer', plugins_url( 'simple-payments/customizer.css', __FILE__ ) );
+ /**
+ * Enqueue admin styles.
+ */
+ public function admin_enqueue_styles() {
+ wp_enqueue_style(
+ 'jetpack-simple-payments-widget-customizer',
+ plugins_url( 'simple-payments/customizer.css', __FILE__ ),
+ array(),
+ JETPACK__VERSION
+ );
}
- function admin_enqueue_scripts() {
+ /**
+ * Enqueue admin scripts.
+ */
+ public function admin_enqueue_scripts() {
wp_enqueue_media();
- wp_enqueue_script( 'jetpack-simple-payments-widget-customizer', plugins_url( '/simple-payments/customizer.js', __FILE__ ), array( 'jquery' ), false, true );
+ wp_enqueue_script(
+ 'jetpack-simple-payments-widget-customizer',
+ plugins_url( '/simple-payments/customizer.js', __FILE__ ),
+ array( 'jquery' ),
+ JETPACK__VERSION,
+ true
+ );
wp_localize_script(
- 'jetpack-simple-payments-widget-customizer', 'jpSimplePaymentsStrings', array(
+ 'jetpack-simple-payments-widget-customizer',
+ 'jpSimplePaymentsStrings',
+ array(
'deleteConfirmation' => __( 'Are you sure you want to delete this item? It will be disabled and removed from all locations where it currently appears.', 'jetpack' ),
)
);
}
+ /**
+ * Get payment buttons.
+ */
public function ajax_get_payment_buttons() {
if ( ! check_ajax_referer( 'customize-jetpack-simple-payments', 'customize-jetpack-simple-payments-nonce', false ) ) {
wp_send_json_error( 'bad_nonce', 400 );
@@ -184,11 +211,16 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
)
);
- $formatted_products = array_map( array( $this, 'format_product_post_for_ajax_reponse' ), $product_posts );
+ $formatted_products = array_map( array( $this, 'format_product_post_for_ajax_reponse' ), $product_posts );
- wp_send_json_success( $formatted_products );
+ wp_send_json_success( $formatted_products );
}
+ /**
+ * Format product_post object.
+ *
+ * @param object $product_post - info about the post the product is on.
+ */
public function format_product_post_for_ajax_reponse( $product_post ) {
return array(
'ID' => $product_post->ID,
@@ -196,6 +228,9 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
);
}
+ /**
+ * Handle saving the simple payments widget.
+ */
public function ajax_save_payment_button() {
if ( ! check_ajax_referer( 'customize-jetpack-simple-payments', 'customize-jetpack-simple-payments-nonce', false ) ) {
wp_send_json_error( 'bad_nonce', 400 );
@@ -214,7 +249,7 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
wp_send_json_error( 'missing_params', 400 );
}
- $params = wp_unslash( $_POST['params'] );
+ $params = wp_unslash( $_POST['params'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Manually validated by validate_ajax_params().
$errors = $this->validate_ajax_params( $params );
if ( ! empty( $errors->errors ) ) {
wp_send_json_error( $errors );
@@ -266,6 +301,9 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
);
}
+ /**
+ * Handle deleting the simple payment widget.
+ */
public function ajax_delete_payment_button() {
if ( ! check_ajax_referer( 'customize-jetpack-simple-payments', 'customize-jetpack-simple-payments-nonce', false ) ) {
wp_send_json_error( 'bad_nonce', 400 );
@@ -279,7 +317,7 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
wp_send_json_error( 'missing_params', 400 );
}
- $params = wp_unslash( $_POST['params'] );
+ $params = wp_unslash( $_POST['params'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Manually validated just below.
$illegal_params = array_diff( array_keys( $params ), array( 'product_post_id' ) );
if ( ! empty( $illegal_params ) ) {
wp_send_json_error( 'illegal_params', 400 );
@@ -316,6 +354,11 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
return isset( $parts[1] ) ? strlen( $parts[1] ) : 0;
}
+ /**
+ * Validate ajax parameters.
+ *
+ * @param array $params - the parameters.
+ */
public function validate_ajax_params( $params ) {
$errors = new WP_Error();
@@ -335,7 +378,7 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
// Japan's Yen is the only supported currency with a zero decimal precision.
$precision = strtoupper( $params['currency'] ) === 'JPY' ? 0 : 2;
$price_decimal_places = $this->get_decimal_places( $params['price'] );
- if ( is_null( $price_decimal_places ) || $price_decimal_places > $precision ) {
+ if ( $price_decimal_places === null || $price_decimal_places > $precision ) {
$errors->add( 'price', __( 'Invalid price', 'jetpack' ) );
}
@@ -346,7 +389,10 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
return $errors;
}
- function get_first_product_id() {
+ /**
+ * Get the id of the first product.
+ */
+ public function get_first_product_id() {
$product_posts = get_posts(
array(
'numberposts' => 1,
@@ -367,37 +413,37 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
- function widget( $args, $instance ) {
+ public function widget( $args, $instance ) {
$instance = wp_parse_args( $instance, $this->defaults() );
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/** This filter is documented in core/src/wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', $instance['title'] );
if ( ! empty( $title ) ) {
- echo $args['before_title'] . $title . $args['after_title'];
+ echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo '<div class="jetpack-simple-payments-content">';
- if ( ! empty( $instance['form_action'] ) && in_array( $instance['form_action'], array( 'add', 'edit' ) ) && is_customize_preview() ) {
- require( dirname( __FILE__ ) . '/simple-payments/widget.php' );
+ if ( ! empty( $instance['form_action'] ) && in_array( $instance['form_action'], array( 'add', 'edit' ), true ) && is_customize_preview() ) {
+ require __DIR__ . '/simple-payments/widget.php';
} else {
- $jsp = Jetpack_Simple_Payments::getInstance();
+ $jsp = Jetpack_Simple_Payments::get_instance();
$simple_payments_button = $jsp->parse_shortcode(
array(
'id' => $instance['product_post_id'],
)
);
- if ( ! is_null( $simple_payments_button ) || is_customize_preview() ) {
- echo $simple_payments_button;
+ if ( $simple_payments_button !== null || is_customize_preview() ) {
+ echo $simple_payments_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
echo '</div><!--simple-payments-->';
- echo $args['after_widget'];
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/** This action is already documented in modules/widgets/gravatar-profile.php */
do_action( 'jetpack_stats_extra', 'widget_view', 'simple_payments' );
@@ -406,9 +452,9 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
/**
* Gets the latests field value from either the old instance or the new instance.
*
- * @param array $mixed Array of values for the new form instance.
- * @param array $mixed Array of values for the old form instance.
- * @return mixed $mixed Field value.
+ * @param array $new_instance mixed Array of values for the new form instance.
+ * @param array $old_instance mixed Array of values for the old form instance.
+ * @param mixed $field mixed Field value.
*/
private function get_latest_field_value( $new_instance, $old_instance, $field ) {
return ! empty( $new_instance[ $field ] )
@@ -420,7 +466,7 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
* Gets the product fields from the product post. If no post found
* it returns the default values.
*
- * @param int Product Post ID.
+ * @param int $product_post_id Product Post ID.
* @return array $fields Product Fields from the Product Post.
*/
private function get_product_from_post( $product_post_id ) {
@@ -448,9 +494,9 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
/**
* Record a Track event and bump a MC stat.
*
- * @param string $stat_name
- * @param string $event_action
- * @param array $event_properties
+ * @param string $stat_name - the name of the stat.
+ * @param string $event_action - the action we're recording.
+ * @param array $event_properties - proprties of the event.
*/
private function record_event( $stat_name, $event_action, $event_properties = array() ) {
$current_user = wp_get_current_user();
@@ -482,9 +528,9 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
*
* @return array Updated safe values to be saved.
*/
- function update( $new_instance, $old_instance ) {
+ public function update( $new_instance, $old_instance ) {
$defaults = $this->defaults();
- //do not overrite `product_post_id` for `$new_instance` with the defaults
+ // do not overrite `product_post_id` for `$new_instance` with the defaults.
$new_instance = wp_parse_args( $new_instance, array_diff_key( $defaults, array( 'product_post_id' => 0 ) ) );
$old_instance = wp_parse_args( $old_instance, $defaults );
@@ -495,11 +541,11 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
);
if ( strcmp( $new_instance['form_action'], $old_instance['form_action'] ) !== 0 ) {
- if ( $new_instance['form_action'] == 'edit' ) {
+ if ( 'edit' === $new_instance['form_action'] ) {
return array_merge( $this->get_product_from_post( (int) $old_instance['product_post_id'] ), $required_widget_props );
}
- if ( $new_instance['form_action'] == 'clear' ) {
+ if ( 'clear' === $new_instance['form_action'] ) {
return array_merge( $this->defaults(), $required_widget_props );
}
}
@@ -511,7 +557,8 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
: $defaults['form_product_email'];
return array_merge(
- $required_widget_props, array(
+ $required_widget_props,
+ array(
'form_product_id' => (int) $new_instance['form_product_id'],
'form_product_title' => sanitize_text_field( $new_instance['form_product_title'] ),
'form_product_description' => sanitize_text_field( $new_instance['form_product_description'] ),
@@ -532,19 +579,19 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
*
* @param array $instance Previously saved values from database.
*/
- function form( $instance ) {
- $jetpack_simple_payments = Jetpack_Simple_Payments::getInstance();
+ public function form( $instance ) {
+ $jetpack_simple_payments = Jetpack_Simple_Payments::get_instance();
if ( ! method_exists( $jetpack_simple_payments, 'is_enabled_jetpack_simple_payments' ) ) {
return;
}
if ( ! $jetpack_simple_payments->is_enabled_jetpack_simple_payments() ) {
- require dirname( __FILE__ ) . '/simple-payments/admin-warning.php';
+ require __DIR__ . '/simple-payments/admin-warning.php';
return;
}
$instance = wp_parse_args( $instance, $this->defaults() );
- $product_posts = get_posts(
+ $product_posts = get_posts( // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
array(
'numberposts' => 100,
'orderby' => 'date',
@@ -553,17 +600,19 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
)
);
- require dirname( __FILE__ ) . '/simple-payments/form.php';
+ require __DIR__ . '/simple-payments/form.php';
}
}
- // Register Jetpack_Simple_Payments_Widget widget.
+ /**
+ * Register Jetpack_Simple_Payments_Widget widget.
+ */
function register_widget_jetpack_simple_payments() {
if ( ! class_exists( 'Jetpack_Simple_Payments' ) ) {
return;
}
- $jetpack_simple_payments = Jetpack_Simple_Payments::getInstance();
+ $jetpack_simple_payments = Jetpack_Simple_Payments::get_instance();
if ( ! $jetpack_simple_payments->is_enabled_jetpack_simple_payments() ) {
return;
}
diff --git a/plugins/jetpack/modules/widgets/simple-payments/admin-warning.php b/plugins/jetpack/modules/widgets/simple-payments/admin-warning.php
index 8e4690db..4cf81728 100644
--- a/plugins/jetpack/modules/widgets/simple-payments/admin-warning.php
+++ b/plugins/jetpack/modules/widgets/simple-payments/admin-warning.php
@@ -1,16 +1,29 @@
<div class='jetpack-simple-payments-disabled-error'>
<p>
<?php
+ /**
+ * Show error and help if Pay with PayPal is disabled.
+ *
+ * @package automattic/jetpack
+ */
+
$support_url = ( defined( 'IS_WPCOM' ) && IS_WPCOM )
? 'https://wordpress.com/support/pay-with-paypal/'
: 'https://jetpack.com/support/pay-with-paypal/';
printf(
wp_kses(
+ // translators: variable is a link to the support page.
__( 'Your plan doesn\'t include Pay with PayPal. <a href="%s" rel="noopener noreferrer" target="_blank">Learn more and upgrade</a>.', 'jetpack' ),
- array( 'a' => array( 'href' => array(), 'rel' => array(), 'target' => array() ) )
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'rel' => array(),
+ 'target' => array(),
+ ),
+ )
),
esc_url( $support_url )
);
- ?>
+ ?>
</p>
</div>
diff --git a/plugins/jetpack/modules/widgets/simple-payments/form.php b/plugins/jetpack/modules/widgets/simple-payments/form.php
index 41c0971e..ae1dbdde 100644
--- a/plugins/jetpack/modules/widgets/simple-payments/form.php
+++ b/plugins/jetpack/modules/widgets/simple-payments/form.php
@@ -3,6 +3,7 @@
* Display the Pay with PayPal Form.
*
* @package automattic/jetpack
+ * @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
*/
?>
@@ -17,7 +18,13 @@
name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
value="<?php echo esc_attr( $instance['title'] ); ?>" />
</p>
-<p class="jetpack-simple-payments-products-fieldset" <?php if ( empty( $product_posts ) ) { echo 'style="display:none;"'; } ?>>
+<p class="jetpack-simple-payments-products-fieldset"
+<?php
+if ( empty( $product_posts ) ) {
+ echo 'style="display:none;"';
+}
+?>
+>
<label for="<?php echo esc_attr( $this->get_field_id( 'product_post_id' ) ); ?>">
<?php esc_html_e( 'Select a Pay with PayPal button:', 'jetpack' ); ?>
</label>
@@ -33,7 +40,13 @@
</select>
</p>
<?php if ( is_customize_preview() ) { ?>
-<p class="jetpack-simple-payments-products-warning" <?php if ( ! empty( $product_posts ) ) { echo 'style="display:none;"'; } ?>>
+<p class="jetpack-simple-payments-products-warning"
+ <?php
+ if ( ! empty( $product_posts ) ) {
+ echo 'style="display:none;"';
+ }
+ ?>
+>
<?php esc_html_e( "Looks like you don't have any products. You can create one using the Add New button below.", 'jetpack' ); ?>
</p>
<p>
@@ -90,10 +103,22 @@
</p>
<div class="jetpack-simple-payments-image-fieldset">
<label><?php esc_html_e( 'Product image', 'jetpack' ); ?></label>
- <div class="placeholder" <?php if ( ! empty( $instance['form_product_image_id'] ) ) echo 'style="display:none;"'; ?>>
+ <div class="placeholder"
+ <?php
+ if ( ! empty( $instance['form_product_image_id'] ) ) {
+ echo 'style="display:none;"';
+ }
+ ?>
+ >
<?php esc_html_e( 'Select an image', 'jetpack' ); ?>
</div>
- <div class="jetpack-simple-payments-image" <?php if ( empty( $instance['form_product_image_id'] ) ) echo 'style="display:none;"'; ?>>
+ <div class="jetpack-simple-payments-image"
+ <?php
+ if ( empty( $instance['form_product_image_id'] ) ) {
+ echo 'style="display:none;"';
+ }
+ ?>
+ >
<img src="<?php echo esc_url( $instance['form_product_image_src'] ); ?>" />
<button class="button jetpack-simple-payments-remove-image"><?php esc_html_e( 'Remove image', 'jetpack' ); ?></button>
</div>
diff --git a/plugins/jetpack/modules/widgets/simple-payments/widget.php b/plugins/jetpack/modules/widgets/simple-payments/widget.php
index 46ca3382..24b1cc2c 100644
--- a/plugins/jetpack/modules/widgets/simple-payments/widget.php
+++ b/plugins/jetpack/modules/widgets/simple-payments/widget.php
@@ -3,12 +3,19 @@
* Display the Pay with PayPal Widget.
*
* @package automattic/jetpack
+ * @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
*/
?>
<div class='jetpack-simple-payments-wrapper'>
<div class='jetpack-simple-payments-product'>
- <div class='jetpack-simple-payments-product-image' <?php if ( empty( $instance['form_product_image_id'] ) ) echo 'style="display:none;"'; ?>>
+ <div class='jetpack-simple-payments-product-image'
+ <?php
+ if ( empty( $instance['form_product_image_id'] ) ) {
+ echo 'style="display:none;"';
+ }
+ ?>
+ >
<div class='jetpack-simple-payments-image'>
<?php echo wp_get_attachment_image( $instance['form_product_image_id'], 'full' ); ?>
</div>
diff --git a/plugins/jetpack/modules/widgets/top-posts.php b/plugins/jetpack/modules/widgets/top-posts.php
index 4f3fe912..5dd7b266 100644
--- a/plugins/jetpack/modules/widgets/top-posts.php
+++ b/plugins/jetpack/modules/widgets/top-posts.php
@@ -281,6 +281,7 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
if ( false === $title ) {
$title = $this->default_title;
}
+
/** This filter is documented in core/src/wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', $title );
@@ -315,6 +316,7 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
$display = 'text';
}
+ $get_image_options = array();
if ( 'text' !== $display ) {
$get_image_options = array(
'fallback_to_avatars' => true,
@@ -352,42 +354,28 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
$posts = $this->get_by_views( $count, $args, $types );
}
- if ( ! $posts ) {
- $posts = $this->get_fallback_posts( $count, $types );
- }
-
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+
if ( ! empty( $title ) ) {
echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
+ /*
+ * If we have no posts, add some fallback posts
+ * and display a fallback message for admins.
+ */
if ( ! $posts ) {
- $link = esc_url( Redirect::get_url( 'jetpack-support-getting-more-views-and-traffic' ) );
- if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
- $link = 'https://en.support.wordpress.com/getting-more-site-traffic/';
- }
-
if ( current_user_can( 'edit_theme_options' ) ) {
- echo '<p>' . sprintf(
- wp_kses(
- /* Translators: Placeholder: link to the Jetpack support article. */
- __( 'There are no posts to display. <a href="%s" target="_blank">Want more traffic?</a>', 'jetpack' ),
- array(
- 'a' => array(
- 'href' => array(),
- 'target' => array(),
- ),
- )
- ),
- esc_url( $link )
- ) . '</p>';
+ echo $this->fallback_message(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
- echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
-
- return;
+ $posts = $this->get_fallback_posts( $count, $types );
}
+ /*
+ * Display our posts.
+ */
+
/**
* Filter the layout of the Top Posts Widget
*
@@ -395,15 +383,13 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
*
* @since 6.4.0
*
- * @param string $layout layout of the Top Posts Widget (empty string)
- * @param array $posts IDs of the posts to be displayed
- * @param array $display Display option from widget form
+ * @param string $layout layout of the Top Posts Widget (empty string).
+ * @param array $posts IDs of the posts to be displayed.
+ * @param array $display Display option from widget form.
*/
$layout = apply_filters( 'jetpack_top_posts_widget_layout', '', $posts, $display );
if ( ! empty( $layout ) ) {
echo $layout; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- return;
}
switch ( $display ) {
@@ -438,15 +424,13 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
$post['image'] = jetpack_photon_url( $post['image'], array( 'resize' => "$width,$height" ) );
}
}
-
unset( $post );
if ( 'grid' === $display ) {
echo "<div class='widgets-grid-layout no-grav'>\n";
- foreach ( $posts as $post ) :
- ?>
- <div class="widget-grid-view-image">
- <?php
+ foreach ( $posts as $post ) {
+ echo '<div class="widget-grid-view-image">';
+
/**
* Fires before each Top Post result, inside <li>.
*
@@ -490,17 +474,15 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
* @param string $post['post_id'] Post ID.
*/
do_action( 'jetpack_widget_top_posts_after_post', $post['post_id'] );
- ?>
- </div>
- <?php
- endforeach;
+
+ echo '</div>';
+ }
echo "</div>\n";
} else {
echo "<ul class='widgets-list-layout no-grav'>\n";
- foreach ( $posts as $post ) :
- ?>
- <li>
- <?php
+ foreach ( $posts as $post ) {
+ echo '<li>';
+
/** This action is documented in modules/widgets/top-posts.php */
do_action( 'jetpack_widget_top_posts_before_post', $post['post_id'] );
@@ -526,19 +508,18 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
/** This action is documented in modules/widgets/top-posts.php */
do_action( 'jetpack_widget_top_posts_after_post', $post['post_id'] );
- ?>
- </li>
- <?php
- endforeach;
+
+ echo '</li>';
+ }
echo "</ul>\n";
}
break;
default:
echo '<ul>';
- foreach ( $posts as $post ) :
- ?>
- <li>
- <?php
+
+ foreach ( $posts as $post ) {
+ echo '<li>';
+
/** This action is documented in modules/widgets/top-posts.php */
do_action( 'jetpack_widget_top_posts_before_post', $post['post_id'] );
@@ -554,17 +535,48 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
/** This action is documented in modules/widgets/top-posts.php */
do_action( 'jetpack_widget_top_posts_after_post', $post['post_id'] );
- ?>
- </li>
- <?php
- endforeach;
+
+ echo '</li>';
+ }
+
echo '</ul>';
+ break;
}
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
+ * Display a message with recommendations when there are no recorded top posts.
+ *
+ * @return string $fallback_message
+ */
+ private static function fallback_message() {
+ $link = esc_url( Redirect::get_url( 'jetpack-support-getting-more-views-and-traffic' ) );
+ if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
+ $link = 'https://en.support.wordpress.com/getting-more-site-traffic/';
+ }
+
+ $fallback_message = '<p>';
+ $fallback_message .= sprintf(
+ wp_kses(
+ /* Translators: Placeholder: link to the Jetpack support article. */
+ __( 'There are no popular posts to display. Instead, your visitors will see a list of your recent posts below. <a href="%s" target="_blank">Want more traffic?</a>', 'jetpack' ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'target' => array(),
+ ),
+ )
+ ),
+ esc_url( $link )
+ );
+ $fallback_message .= '<p>';
+
+ return $fallback_message;
+ }
+
+ /**
* Widget default option values.
*/
public static function defaults() {
@@ -678,10 +690,6 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
* @return array
*/
public function get_fallback_posts( $count = 10, $types = array( 'post', 'page' ) ) {
- if ( current_user_can( 'edit_theme_options' ) ) {
- return array();
- }
-
$post_query = new WP_Query();
if ( ! is_array( $types ) || empty( $types ) ) {
@@ -765,7 +773,7 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
$posts[] = compact( 'title', 'permalink', 'post_id', 'post_type' );
$counter++;
- if ( $counter == $count ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
+ if ( $counter == $count ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
break; // only need to load and show x number of likes.
}
}
diff --git a/plugins/jetpack/modules/widgets/wordpress-post-widget.php b/plugins/jetpack/modules/widgets/wordpress-post-widget.php
index fb9ffa7a..3cbd6015 100644
--- a/plugins/jetpack/modules/widgets/wordpress-post-widget.php
+++ b/plugins/jetpack/modules/widgets/wordpress-post-widget.php
@@ -6,6 +6,9 @@
* Author: Brad Angelcyk, Kathryn Presner, Justin Shreve, Carolyn Sonnek
* Author URI: https://automattic.com
* License: GPL2
+ * Text Domain: jetpack
+ *
+ * @package automattic/jetpack
*/
/**
@@ -15,20 +18,22 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
-require dirname( __FILE__ ) . '/wordpress-post-widget/class.jetpack-display-posts-widget-base.php';
-require dirname( __FILE__ ) . '/wordpress-post-widget/class.jetpack-display-posts-widget.php';
+require __DIR__ . '/wordpress-post-widget/class.jetpack-display-posts-widget-base.php';
+require __DIR__ . '/wordpress-post-widget/class.jetpack-display-posts-widget.php';
add_action( 'widgets_init', 'jetpack_display_posts_widget' );
+/**
+ * Registers widget Jetpack_Display_Posts_Widget
+ */
function jetpack_display_posts_widget() {
register_widget( 'Jetpack_Display_Posts_Widget' );
}
-
/**
* Cron tasks
*/
-add_filter( 'cron_schedules', 'jetpack_display_posts_widget_cron_intervals' );
+add_filter( 'cron_schedules', 'jetpack_display_posts_widget_cron_intervals' ); // phpcs:ignore WordPress.WP.CronInterval.CronSchedulesInterval
/**
* Adds 10 minute running interval to the cron schedules.
@@ -56,6 +61,9 @@ function jetpack_display_posts_widget_cron_intervals( $current_schedules ) {
* Execute the cron task
*/
add_action( 'jetpack_display_posts_widget_cron_update', 'jetpack_display_posts_update_cron_action' );
+/**
+ * Run the Jetpack_Display_Posts_Widget cron task.
+ */
function jetpack_display_posts_update_cron_action() {
$widget = new Jetpack_Display_Posts_Widget();
$widget->cron_task();
@@ -70,7 +78,6 @@ function jetpack_display_posts_update_cron_action() {
* `jetpack_activate_module_widgets` - Activate the cron when the Extra Sidebar widgets are activated.
*
* `activated_plugin` - Activate the cron when Jetpack gets activated.
- *
*/
add_action( 'updating_jetpack_version', 'jetpack_display_posts_widget_conditionally_activate_cron' );
add_action( 'jetpack_activate_module_widgets', 'Jetpack_Display_Posts_Widget::activate_cron' );
@@ -89,6 +96,7 @@ function jetpack_conditionally_activate_cron_on_plugin_activation( $plugin_file_
/**
* Activates the cron only when needed.
+ *
* @see Jetpack_Display_Posts_Widget::should_cron_be_running
*/
function jetpack_display_posts_widget_conditionally_activate_cron() {
@@ -104,7 +112,6 @@ function jetpack_display_posts_widget_conditionally_activate_cron() {
* End of cron activation handling.
*/
-
/**
* Handle deactivation procedures where they are needed.
*
diff --git a/plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget-base.php b/plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget-base.php
index e89df68e..0d9c3d67 100644
--- a/plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget-base.php
+++ b/plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget-base.php
@@ -1,6 +1,6 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
-/*
+/**
* For back-compat, the final widget class must be named
* Jetpack_Display_Posts_Widget.
*
@@ -16,21 +16,30 @@
*
* That this widget is currently implemented as these two classes
* is an implementation detail and should not be depended on :)
+ *
+ * phpcs:disable PEAR.NamingConventions.ValidClassName.Invalid
*/
abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
+ // phpcs:enable PEAR.NamingConventions.ValidClassName.Invalid
+
/**
- * @var string Remote service API URL prefix.
+ * Remote service API URL prefix.
+ *
+ * @var string
*/
public $service_url = 'https://public-api.wordpress.com/rest/v1.1/';
+ /**
+ * Jetpack_Display_Posts_Widget__Base constructor.
+ */
public function __construct() {
parent::__construct(
- // internal id
+ // Internal id.
'jetpack_display_posts_widget',
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', __( 'Display WordPress Posts', 'jetpack' ) ),
array(
- 'description' => __( 'Displays a list of recent posts from another WordPress.com or Jetpack-enabled blog.', 'jetpack' ),
+ 'description' => __( 'Displays a list of recent posts from another WordPress.com or Jetpack-enabled blog.', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
@@ -46,16 +55,20 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
* @since 4.0.0
*/
public function enqueue_scripts() {
- wp_enqueue_style( 'jetpack_display_posts_widget', plugins_url( 'style.css', __FILE__ ) );
+ wp_enqueue_style(
+ 'jetpack_display_posts_widget',
+ plugins_url( 'style.css', __FILE__ ),
+ array(),
+ JETPACK__VERSION
+ );
}
-
- // DATA STORE: Must implement
+ // DATA STORE: Must implement.
/**
* Gets blog data from the cache.
*
- * @param string $site
+ * @param string $site Site.
*
* @return array|WP_Error
*/
@@ -70,14 +83,13 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
*/
abstract public function update_instance( $site );
-
- // WIDGET API
+ // WIDGET API.
/**
* Set up the widget display on the front end.
*
- * @param array $args
- * @param array $instance
+ * @param array $args Widget args.
+ * @param array $instance Widget instance.
*/
public function widget( $args, $instance ) {
/** This action is documented in modules/widgets/gravatar-profile.php */
@@ -97,17 +109,17 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
}
$content .= $args['after_widget'];
- echo $content;
+ echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
return;
}
$data = $this->get_blog_data( $instance['url'] );
- // check for errors
+ // Check for errors.
if ( is_wp_error( $data ) || empty( $data['site_info']['data'] ) ) {
$content .= '<p>' . __( 'Cannot load blog information at this time.', 'jetpack' ) . '</p>';
$content .= $args['after_widget'];
- echo $content;
+ echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
return;
}
@@ -117,8 +129,7 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
/** This filter is documented in core/src/wp-includes/default-widgets.php */
$instance['title'] = apply_filters( 'widget_title', $instance['title'] );
$content .= $args['before_title'] . $instance['title'] . ': ' . $site_info->name . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- }
- else {
+ } else {
$content .= $args['before_title'] . esc_html( $site_info->name ) . $args['after_title'];
}
@@ -129,7 +140,7 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
$content .= '</div><!-- .jetpack-display-remote-posts -->';
$content .= $args['after_widget'];
- echo $content;
+ echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
return;
}
@@ -146,11 +157,11 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
$post_title = ( $single_post['title'] ) ? $single_post['title'] : '( No Title )';
$target = '';
- if ( isset( $instance['open_in_new_window'] ) && $instance['open_in_new_window'] == true ) {
+ if ( isset( $instance['open_in_new_window'] ) && true === $instance['open_in_new_window'] ) {
$target = ' target="_blank" rel="noopener"';
}
$content .= '<h4><a href="' . esc_url( $single_post['url'] ) . '"' . $target . '>' . esc_html( $post_title ) . '</a></h4>' . "\n";
- if ( ( $instance['featured_image'] == true ) && ( ! empty ( $single_post['featured_image'] ) ) ) {
+ if ( ( true === $instance['featured_image'] ) && ( ! empty( $single_post['featured_image'] ) ) ) {
$featured_image = $single_post['featured_image'];
/**
* Allows setting up custom Photon parameters to manipulate the image output in the Display Posts widget.
@@ -164,10 +175,10 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
* @param array $args Array of Photon Parameters.
*/
$image_params = apply_filters( 'jetpack_display_posts_widget_image_params', array() );
- $content .= '<a title="' . esc_attr( $post_title ) . '" href="' . esc_url( $single_post['url'] ) . '"' . $target . '><img src="' . jetpack_photon_url( $featured_image, $image_params ) . '" alt="' . esc_attr( $post_title ) . '"/></a>';
+ $content .= '<a title="' . esc_attr( $post_title ) . '" href="' . esc_url( $single_post['url'] ) . '"' . $target . '><img src="' . jetpack_photon_url( $featured_image, $image_params ) . '" alt="' . esc_attr( $post_title ) . '"/></a>';
}
- if ( $instance['show_excerpts'] == true ) {
+ if ( true === $instance['show_excerpts'] ) {
$content .= $single_post['excerpt'];
}
}
@@ -184,7 +195,7 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
*
* @param string $content Widget content.
*/
- echo apply_filters( 'jetpack_display_posts_widget_content', $content );
+ echo apply_filters( 'jetpack_display_posts_widget_content', $content ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
@@ -206,7 +217,6 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
$featured_image = ( isset( $instance['featured_image'] ) ) ? $instance['featured_image'] : false;
$show_excerpts = ( isset( $instance['show_excerpts'] ) ) ? $instance['show_excerpts'] : false;
-
/**
* Check if the widget instance has errors available.
*
@@ -221,15 +231,15 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
?>
<p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'jetpack' ); ?></label>
- <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?></label>
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<p>
- <label for="<?php echo $this->get_field_id( 'url' ); ?>"><?php _e( 'Blog URL:', 'jetpack' ); ?></label>
- <input class="widefat" id="<?php echo $this->get_field_id( 'url' ); ?>" name="<?php echo $this->get_field_name( 'url' ); ?>" type="text" value="<?php echo esc_attr( $url ); ?>" />
+ <label for="<?php echo esc_attr( $this->get_field_id( 'url' ) ); ?>"><?php esc_html_e( 'Blog URL:', 'jetpack' ); ?></label>
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'url' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'url' ) ); ?>" type="text" value="<?php echo esc_attr( $url ); ?>" />
<i>
- <?php _e( "Enter a WordPress.com or Jetpack WordPress site URL.", 'jetpack' ); ?>
+ <?php esc_html_e( 'Enter a WordPress.com or Jetpack WordPress site URL.', 'jetpack' ); ?>
</i>
<?php
/**
@@ -240,32 +250,32 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
if ( empty( $url ) && ! preg_match( '/__i__|%i%/', $this->id ) ) {
?>
<br />
- <i class="error-message"><?php echo __( 'You must specify a valid blog URL!', 'jetpack' ); ?></i>
+ <i class="error-message"><?php esc_html_e( 'You must specify a valid blog URL!', 'jetpack' ); ?></i>
<?php
}
?>
</p>
<p>
- <label for="<?php echo $this->get_field_id( 'number_of_posts' ); ?>"><?php _e( 'Number of Posts to Display:', 'jetpack' ); ?></label>
- <select name="<?php echo $this->get_field_name( 'number_of_posts' ); ?>">
+ <label for="<?php echo esc_attr( $this->get_field_id( 'number_of_posts' ) ); ?>"><?php esc_html_e( 'Number of Posts to Display:', 'jetpack' ); ?></label>
+ <select name="<?php echo esc_attr( $this->get_field_name( 'number_of_posts' ) ); ?>">
<?php
for ( $i = 1; $i <= 10; $i ++ ) {
- echo '<option value="' . $i . '" ' . selected( $number_of_posts, $i ) . '>' . $i . '</option>';
+ echo '<option value="' . esc_attr( $i ) . '" ' . selected( $number_of_posts, $i ) . '>' . esc_html( $i ) . '</option>';
}
?>
</select>
</p>
<p>
- <label for="<?php echo $this->get_field_id( 'open_in_new_window' ); ?>"><?php _e( 'Open links in new window/tab:', 'jetpack' ); ?></label>
- <input type="checkbox" name="<?php echo $this->get_field_name( 'open_in_new_window' ); ?>" <?php checked( $open_in_new_window, 1 ); ?> />
+ <label for="<?php echo esc_attr( $this->get_field_id( 'open_in_new_window' ) ); ?>"><?php esc_html_e( 'Open links in new window/tab:', 'jetpack' ); ?></label>
+ <input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'open_in_new_window' ) ); ?>" <?php checked( $open_in_new_window, 1 ); ?> />
</p>
<p>
- <label for="<?php echo $this->get_field_id( 'featured_image' ); ?>"><?php _e( 'Show Featured Image:', 'jetpack' ); ?></label>
- <input type="checkbox" name="<?php echo $this->get_field_name( 'featured_image' ); ?>" <?php checked( $featured_image, 1 ); ?> />
+ <label for="<?php echo esc_attr( $this->get_field_id( 'featured_image' ) ); ?>"><?php esc_html_e( 'Show Featured Image:', 'jetpack' ); ?></label>
+ <input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'featured_image' ) ); ?>" <?php checked( $featured_image, 1 ); ?> />
</p>
<p>
- <label for="<?php echo $this->get_field_id( 'show_excerpts' ); ?>"><?php _e( 'Show Excerpts:', 'jetpack' ); ?></label>
- <input type="checkbox" name="<?php echo $this->get_field_name( 'show_excerpts' ); ?>" <?php checked( $show_excerpts, 1 ); ?> />
+ <label for="<?php echo esc_attr( $this->get_field_id( 'show_excerpts' ) ); ?>"><?php esc_html_e( 'Show Excerpts:', 'jetpack' ); ?></label>
+ <input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_excerpts' ) ); ?>" <?php checked( $show_excerpts, 1 ); ?> />
</p>
<?php
@@ -323,15 +333,20 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
}
}
- public function update( $new_instance, $old_instance ) {
+ /**
+ * Widget update function.
+ *
+ * @param array $new_instance New instance widget settings.
+ * @param array $old_instance Old instance widget settings.
+ */
+ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$instance = array();
- $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
- $instance['url'] = ( ! empty( $new_instance['url'] ) ) ? strip_tags( trim( $new_instance['url'] ) ) : '';
- $instance['url'] = preg_replace( "!^https?://!is", "", $instance['url'] );
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? wp_strip_all_tags( $new_instance['title'] ) : '';
+ $instance['url'] = ( ! empty( $new_instance['url'] ) ) ? wp_strip_all_tags( trim( $new_instance['url'] ) ) : '';
+ $instance['url'] = preg_replace( '!^https?://!is', '', $instance['url'] );
$instance['url'] = untrailingslashit( $instance['url'] );
-
/**
* Check if the URL should be with or without the www prefix before saving.
*/
@@ -366,8 +381,7 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
return $instance;
}
-
- // DATA PROCESSING
+ // DATA PROCESSING.
/**
* Expiring transients have a name length maximum of 45 characters,
@@ -443,14 +457,12 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
);
}
-
/**
* Extract service response body from the request.
*/
$service_response_body = wp_remote_retrieve_body( $service_response );
-
/**
* No body has been set in the response. This should be pretty bad.
*/
@@ -470,7 +482,7 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
/**
* If there is a problem with parsing the posts return an empty array.
*/
- if ( is_null( $parsed_data ) ) {
+ if ( $parsed_data === null ) {
return new WP_Error(
'no_body',
__( 'Invalid remote response.', 'jetpack' ),
@@ -504,7 +516,7 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
*/
public function fetch_site_info( $site ) {
- $response = $this->fetch_service_endpoint( sprintf( '/sites/%s', urlencode( $site ) ) );
+ $response = $this->fetch_service_endpoint( sprintf( '/sites/%s', rawurlencode( $site ) ) );
return $response;
}
@@ -629,7 +641,7 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
'title' => $single_post->title ? $single_post->title : '',
'excerpt' => $single_post->excerpt ? $single_post->excerpt : '',
'featured_image' => $single_post->featured_image ? $single_post->featured_image : '',
- 'url' => $single_post->URL,
+ 'url' => $single_post->URL, // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
);
/**
@@ -659,8 +671,7 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
*/
if ( ! empty( $original_data ) ) {
$widget_data = $original_data;
- }
- else {
+ } else {
$widget_data = array(
'site_info' => array(
'last_check' => null,
@@ -673,7 +684,7 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
'last_update' => null,
'error' => null,
'data' => array(),
- )
+ ),
);
}
@@ -685,7 +696,6 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
$site_info_raw_data = $this->fetch_site_info( $site );
$site_info_parsed_data = $this->parse_site_info_response( $site_info_raw_data );
-
/**
* If there is an error with the fetched site info, save the error and update the checked time.
*/
@@ -693,21 +703,18 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
$widget_data['site_info']['error'] = $site_info_parsed_data;
return $widget_data;
- }
- /**
- * If data is fetched successfully, update the data and set the proper time.
- *
- * Data is only updated if we have valid results. This is done this way so we can show
- * something if external service is down.
- *
- */
- else {
+ } else {
+ /**
+ * If data is fetched successfully, update the data and set the proper time.
+ *
+ * Data is only updated if we have valid results. This is done this way so we can show
+ * something if external service is down.
+ */
$widget_data['site_info']['last_update'] = time();
$widget_data['site_info']['data'] = $site_info_parsed_data;
$widget_data['site_info']['error'] = null;
}
-
/**
* If only site data is needed, return it here, don't fetch posts data.
*/
@@ -723,7 +730,6 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
$site_posts_raw_data = $this->fetch_posts_for_site( $site_info_parsed_data->ID );
$site_posts_parsed_data = $this->parse_posts_response( $site_posts_raw_data );
-
/**
* If there is an error with the fetched posts, save the error and update the checked time.
*/
@@ -731,15 +737,13 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
$widget_data['posts']['error'] = $site_posts_parsed_data;
return $widget_data;
- }
- /**
- * If data is fetched successfully, update the data and set the proper time.
- *
- * Data is only updated if we have valid results. This is done this way so we can show
- * something if external service is down.
- *
- */
- else {
+ } else {
+ /**
+ * If data is fetched successfully, update the data and set the proper time.
+ *
+ * Data is only updated if we have valid results. This is done this way so we can show
+ * something if external service is down.
+ */
$widget_data['posts']['last_update'] = time();
$widget_data['posts']['data'] = $site_posts_parsed_data;
$widget_data['posts']['error'] = null;
@@ -763,7 +767,6 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
'where' => '',
);
-
/**
* When the cache result is an error. Usually when the cache is empty.
* This is not an error case for now.
@@ -801,14 +804,12 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
$extra_data = $blog_data[ $info_key ]['error']->get_error_data();
if ( is_array( $extra_data ) ) {
$errors['debug'] = implode( '; ', $extra_data );
- }
- else {
+ } else {
$errors['debug'] = $extra_data;
}
break;
- }
- elseif ( is_array( $blog_data[ $info_key ]['error'] ) ) {
+ } elseif ( is_array( $blog_data[ $info_key ]['error'] ) ) {
/**
* In this case we don't have debug information, because
* we have no way to know the format. The widget works with
@@ -830,7 +831,7 @@ abstract class Jetpack_Display_Posts_Widget__Base extends WP_Widget {
/**
* This is just to make method mocks in the unit tests easier.
*
- * @param string $url The URL to fetch
+ * @param string $url The URL to fetch.
* @param array $args Optional. Request arguments.
*
* @return array|WP_Error
diff --git a/plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget.php b/plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget.php
index d0a155a2..10d66b7f 100644
--- a/plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget.php
+++ b/plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget.php
@@ -1,34 +1,36 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Status;
-/*
+/**
* Display a list of recent posts from a WordPress.com or Jetpack-enabled blog.
*/
-
class Jetpack_Display_Posts_Widget extends Jetpack_Display_Posts_Widget__Base {
/**
- * @var string Widget options key prefix.
+ * Widget options key prefix.
+ *
+ * @var string
*/
public $widget_options_key_prefix = 'display_posts_site_data_';
/**
- * @var string The name of the cron that will update widget data.
+ * The name of the cron that will update widget data.
+ *
+ * @var string
*/
public static $cron_name = 'jetpack_display_posts_widget_cron_update';
-
- // DATA STORE
+ // DATA STORE.
/**
* Gets blog data from the cache.
*
- * @param string $site
+ * @param string $site Site.
*
* @return array|WP_Error
*/
public function get_blog_data( $site ) {
- // load from cache, if nothing return an error
+ // Load from cache, if nothing return an error.
$site_hash = $this->get_site_hash( $site );
$cached_data = $this->wp_get_option( $this->widget_options_key_prefix . $site_hash );
@@ -75,17 +77,21 @@ class Jetpack_Display_Posts_Widget extends Jetpack_Display_Posts_Widget__Base {
*/
if ( false === $instance_data ) {
$this->wp_add_option( $option_key, $new_data );
- }
- else {
+ } else {
$this->wp_update_option( $option_key, $new_data );
}
return $new_data;
}
+ // WIDGET API.
- // WIDGET API
-
+ /**
+ * Widget update function.
+ *
+ * @param array $new_instance New instance widget settings.
+ * @param array $old_instance Old instance widget settings.
+ */
public function update( $new_instance, $old_instance ) {
$instance = parent::update( $new_instance, $old_instance );
@@ -99,8 +105,7 @@ class Jetpack_Display_Posts_Widget extends Jetpack_Display_Posts_Widget__Base {
return $instance;
}
-
- // CRON
+ // CRON.
/**
* Activates widget update cron task.
@@ -230,13 +235,12 @@ class Jetpack_Display_Posts_Widget extends Jetpack_Display_Posts_Widget__Base {
}
-
- // MOCKABLES
+ // MOCKABLES.
/**
* This is just to make method mocks in the unit tests easier.
*
- * @param string $param Option key to get
+ * @param string $param Option key to get.
*
* @return mixed
*
@@ -249,8 +253,8 @@ class Jetpack_Display_Posts_Widget extends Jetpack_Display_Posts_Widget__Base {
/**
* This is just to make method mocks in the unit tests easier.
*
- * @param string $option_name Option name to be added
- * @param mixed $option_value Option value
+ * @param string $option_name Option name to be added.
+ * @param mixed $option_value Option value.
*
* @return mixed
*
@@ -263,8 +267,8 @@ class Jetpack_Display_Posts_Widget extends Jetpack_Display_Posts_Widget__Base {
/**
* This is just to make method mocks in the unit tests easier.
*
- * @param string $option_name Option name to be updated
- * @param mixed $option_value Option value
+ * @param string $option_name Option name to be updated.
+ * @param mixed $option_value Option value.
*
* @return mixed
*
diff --git a/plugins/jetpack/modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-universal.php b/plugins/jetpack/modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-universal.php
index f1eb36b9..f47804db 100644
--- a/plugins/jetpack/modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-universal.php
+++ b/plugins/jetpack/modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-universal.php
@@ -457,7 +457,7 @@ class Jetpack_WooCommerce_Analytics_Universal {
* @param array $cart_item_data Other cart data.
*/
public function capture_add_to_cart( $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
- $referer_postid = isset( $_SERVER['HTTP_REFERER'] ) ? url_to_postid( $_SERVER['HTTP_REFERER'] ) : 0;
+ $referer_postid = isset( $_SERVER['HTTP_REFERER'] ) ? url_to_postid( esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) ) : 0;
// if the referring post is not a product OR the product being added is not the same as post.
// (eg. related product list on single product page) then include a product view event.
$product_by_referer_postid = wc_get_product( $referer_postid );
diff --git a/plugins/jetpack/modules/woocommerce-analytics/classes/wp-woocommerce-analytics-universal.php b/plugins/jetpack/modules/woocommerce-analytics/classes/wp-woocommerce-analytics-universal.php
deleted file mode 100644
index f8ee1912..00000000
--- a/plugins/jetpack/modules/woocommerce-analytics/classes/wp-woocommerce-analytics-universal.php
+++ /dev/null
@@ -1,403 +0,0 @@
-<?php
-/**
- * Jetpack_WooCommerce_Analytics_Universal
- *
- * @package Jetpack
- * @author Automattic
- */
-
-/**
- * Bail if accessed directly
- */
-if ( ! defined( 'ABSPATH' ) ) {
- exit;
-}
-
-/**
- * Class Jetpack_WooCommerce_Analytics_Universal
- * Filters and Actions added to Store pages to perform analytics
- */
-class Jetpack_WooCommerce_Analytics_Universal {
- /**
- * Jetpack_WooCommerce_Analytics_Universal constructor.
- */
- public function __construct() {
- // loading _wca
- add_action( 'wp_head', array( $this, 'wp_head_top' ), 1 );
-
- // add to carts from non-product pages or lists (search, store etc.)
- add_action( 'wp_head', array( $this, 'loop_session_events' ), 2 );
-
- // loading s.js.
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_tracking_script' ) );
-
- // Capture cart events
- add_action( 'woocommerce_add_to_cart', array( $this, 'capture_add_to_cart' ), 10, 6 );
-
- // single product page view
- add_action( 'woocommerce_after_single_product', array( $this, 'capture_product_view' ) );
-
- add_action( 'woocommerce_after_cart', array( $this, 'remove_from_cart' ) );
- add_action( 'woocommerce_after_mini_cart', array( $this, 'remove_from_cart' ) );
- add_action( 'wcct_before_cart_widget', array( $this, 'remove_from_cart' ) );
- add_filter( 'woocommerce_cart_item_remove_link', array( $this, 'remove_from_cart_attributes' ), 10, 2 );
-
- // cart checkout
- add_action( 'woocommerce_after_checkout_form', array( $this, 'checkout_process' ) );
-
- // order confirmed
- add_action( 'woocommerce_thankyou', array( $this, 'order_process' ), 10, 1 );
- add_action( 'woocommerce_after_cart', array( $this, 'remove_from_cart_via_quantity' ), 10, 1 );
- }
-
- /**
- * Make _wca available to queue events
- */
- public function wp_head_top() {
- if ( is_cart() || is_checkout() || is_checkout_pay_page() || is_order_received_page() || is_add_payment_method_page() ) {
- $prevent_referrer_code = '<script>window._wca_prevent_referrer = true;</script>';
- echo "$prevent_referrer_code\r\n";
- }
- $wca_code = '<script>window._wca = window._wca || [];</script>';
- echo "$wca_code\r\n";
- }
-
-
- /**
- * Place script to call s.js, Store Analytics.
- */
- public function enqueue_tracking_script() {
- $filename = sprintf(
- 'https://stats.wp.com/s-%d.js',
- gmdate( 'YW' )
- );
-
- // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
- wp_enqueue_script( 'woocommerce-analytics', esc_url( $filename ), array(), null, false );
- }
-
- /**
- * On product lists or other non-product pages, add an event listener to "Add to Cart" button click
- */
- public function loop_session_events() {
- $blogid = Jetpack::get_option( 'id' );
-
- // check for previous add-to-cart cart events
- if ( is_object( WC()->session ) ) {
- $data = WC()->session->get( 'wca_session_data' );
- if ( ! empty( $data ) ) {
- foreach ( $data as $data_instance ) {
- $product = wc_get_product( $data_instance['product_id'] );
- if ( ! $product ) {
- continue;
- }
- $product_details = $this->get_product_details( $product );
- wc_enqueue_js(
- "_wca.push( {
- '_en': '" . esc_js( $data_instance['event'] ) . "',
- 'blog_id': '" . esc_js( $blogid ) . "',
- 'pi': '" . esc_js( $data_instance['product_id'] ) . "',
- 'pn': '" . esc_js( $product_details['name'] ) . "',
- 'pc': '" . esc_js( $product_details['category'] ) . "',
- 'pp': '" . esc_js( $product_details['price'] ) . "',
- 'pq': '" . esc_js( $data_instance['quantity'] ) . "',
- 'pt': '" . esc_js( $product_details['type'] ) . "',
- 'ui': '" . esc_js( $this->get_user_id() ) . "',
- } );"
- );
- }
- // clear data
- WC()->session->set( 'wca_session_data', '' );
- }
- }
- }
-
- /**
- * On the cart page, add an event listener for removal of product click
- */
- public function remove_from_cart() {
-
- // We listen at div.woocommerce because the cart 'form' contents get forcibly
- // updated and subsequent removals from cart would then not have this click
- // handler attached.
- $blogid = Jetpack::get_option( 'id' );
- wc_enqueue_js(
- "jQuery( 'div.woocommerce' ).on( 'click', 'a.remove', function() {
- var productID = jQuery( this ).data( 'product_id' );
- var quantity = jQuery( this ).parent().parent().find( '.qty' ).val()
- var productDetails = {
- 'id': productID,
- 'quantity': quantity ? quantity : '1',
- };
- _wca.push( {
- '_en': 'woocommerceanalytics_remove_from_cart',
- 'blog_id': '" . esc_js( $blogid ) . "',
- 'pi': productDetails.id,
- 'pq': productDetails.quantity,
- 'ui': '" . esc_js( $this->get_user_id() ) . "',
- } );
- } );"
- );
- }
-
- /**
- * Adds the product ID to the remove product link (for use by remove_from_cart above) if not present
- *
- * @param string $url Full HTML a tag of the link to remove an item from the cart.
- * @param string $key Unique Key ID for a cart item.
- *
- * @return mixed.
- */
- public function remove_from_cart_attributes( $url, $key ) {
- if ( false !== strpos( $url, 'data-product_id' ) ) {
- return $url;
- }
-
- $item = WC()->cart->get_cart_item( $key );
- $product = $item['data'];
-
- $new_attributes = sprintf(
- '" data-product_id="%s">',
- esc_attr( $product->get_id() )
- );
-
- $url = str_replace( '">', $new_attributes, $url );
- return $url;
- }
-
- /**
- * Gather relevant product information
- *
- * @param array $product product
- * @return array
- */
- public function get_product_details( $product ) {
- return array(
- 'id' => $product->get_id(),
- 'name' => $product->get_title(),
- 'category' => $this->get_product_categories_concatenated( $product ),
- 'price' => $product->get_price(),
- 'type' => $product->get_type(),
- );
- }
-
- /**
- * Track a product page view
- */
- public function capture_product_view() {
-
- global $product;
- $blogid = Jetpack::get_option( 'id' );
- $product_details = $this->get_product_details( $product );
-
- wc_enqueue_js(
- "_wca.push( {
- '_en': 'woocommerceanalytics_product_view',
- 'blog_id': '" . esc_js( $blogid ) . "',
- 'pi': '" . esc_js( $product_details['id'] ) . "',
- 'pn': '" . esc_js( $product_details['name'] ) . "',
- 'pc': '" . esc_js( $product_details['category'] ) . "',
- 'pp': '" . esc_js( $product_details['price'] ) . "',
- 'pt': '" . esc_js( $product_details['type'] ) . "',
- 'ui': '" . esc_js( $this->get_user_id() ) . "',
- } );"
- );
- }
-
- /**
- * On the Checkout page, trigger an event for each product in the cart
- */
- public function checkout_process() {
-
- $universal_commands = array();
- $cart = WC()->cart->get_cart();
- $blogid = Jetpack::get_option( 'id' );
-
- foreach ( $cart as $cart_item_key => $cart_item ) {
- /**
- * This filter is already documented in woocommerce/templates/cart/cart.php
- */
- $product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
-
- if ( ! $product ) {
- continue;
- }
-
- $product_details = $this->get_product_details( $product );
-
- $universal_commands[] = "_wca.push( {
- '_en': 'woocommerceanalytics_product_checkout',
- 'blog_id': '" . esc_js( $blogid ) . "',
- 'pi': '" . esc_js( $product_details['id'] ) . "',
- 'pn': '" . esc_js( $product_details['name'] ) . "',
- 'pc': '" . esc_js( $product_details['category'] ) . "',
- 'pp': '" . esc_js( $product_details['price'] ) . "',
- 'pq': '" . esc_js( $cart_item['quantity'] ) . "',
- 'pt': '" . esc_js( $product_details['type'] ) . "',
- 'ui': '" . esc_js( $this->get_user_id() ) . "',
- } );";
- }
-
- wc_enqueue_js( implode( "\r\n", $universal_commands ) );
- }
-
- /**
- * After the checkout process, fire an event for each item in the order
- *
- * @param string $order_id Order Id.
- */
- public function order_process( $order_id ) {
- $order = wc_get_order( $order_id );
- $universal_commands = array();
- $blogid = Jetpack::get_option( 'id' );
-
- // loop through products in the order and queue a purchase event.
- foreach ( $order->get_items() as $order_item_id => $order_item ) {
- $product = $order->get_product_from_item( $order_item );
-
- $product_details = $this->get_product_details( $product );
-
- $universal_commands[] = "_wca.push( {
- '_en': 'woocommerceanalytics_product_purchase',
- 'blog_id': '" . esc_js( $blogid ) . "',
- 'pi': '" . esc_js( $product_details['id'] ) . "',
- 'pn': '" . esc_js( $product_details['name'] ) . "',
- 'pc': '" . esc_js( $product_details['category'] ) . "',
- 'pp': '" . esc_js( $product_details['price'] ) . "',
- 'pq': '" . esc_js( $order_item->get_quantity() ) . "',
- 'pt': '" . esc_js( $product_details['type'] ) . "',
- 'oi': '" . esc_js( $order->get_order_number() ) . "',
- 'ui': '" . esc_js( $this->get_user_id() ) . "',
- } );";
- }
-
- wc_enqueue_js( implode( "\r\n", $universal_commands ) );
- }
-
- /**
- * Listen for clicks on the "Update Cart" button to know if an item has been removed by
- * updating its quantity to zero
- */
- public function remove_from_cart_via_quantity() {
- $blogid = Jetpack::get_option( 'id' );
-
- wc_enqueue_js(
- "
- jQuery( 'button[name=update_cart]' ).on( 'click', function() {
- var cartItems = jQuery( '.cart_item' );
- cartItems.each( function( item ) {
- var qty = jQuery( this ).find( 'input.qty' );
- if ( qty && qty.val() === '0' ) {
- var productID = jQuery( this ).find( '.product-remove a' ).data( 'product_id' );
- _wca.push( {
- '_en': 'woocommerceanalytics_remove_from_cart',
- 'blog_id': '" . esc_js( $blogid ) . "',
- 'pi': productID,
- 'ui': '" . esc_js( $this->get_user_id() ) . "',
- } );
- }
- } );
- } );
- "
- );
- }
-
- /**
- * Get the current user id
- *
- * @return int
- */
- public function get_user_id() {
- if ( is_user_logged_in() ) {
- $blogid = Jetpack::get_option( 'id' );
- $userid = get_current_user_id();
- return $blogid . ':' . $userid;
- }
- return 'null';
- }
-
- /**
- * @param $cart_item_key
- * @param $product_id
- * @param $quantity
- * @param $variation_id
- * @param $variation
- * @param $cart_item_data
- */
- public function capture_add_to_cart( $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data ) {
- $referer_postid = isset( $_SERVER['HTTP_REFERER'] ) ? url_to_postid( $_SERVER['HTTP_REFERER'] ) : 0;
- // if the referring post is not a product OR the product being added is not the same as post
- // (eg. related product list on single product page) then include a product view event
- if ( ! wc_get_product( $referer_postid ) || $product_id != $referer_postid ) {
- $this->capture_event_in_session_data( $product_id, $quantity, 'woocommerceanalytics_product_view' );
- }
- // add cart event to the session data
- $this->capture_event_in_session_data( $product_id, $quantity, 'woocommerceanalytics_add_to_cart' );
- }
-
- /**
- * @param $product_id
- * @param $quantity
- * @param $event
- */
- public function capture_event_in_session_data( $product_id, $quantity, $event ) {
-
- $product = wc_get_product( $product_id );
- if ( ! $product ) {
- return;
- }
-
- $quantity = ( $quantity == 0 ) ? 1 : $quantity;
-
- // check for existing data
- if ( is_object( WC()->session ) ) {
- $data = WC()->session->get( 'wca_session_data' );
- if ( empty( $data ) || ! is_array( $data ) ) {
- $data = array();
- }
- } else {
- $data = array();
- }
-
- // extract new event data
- $new_data = array(
- 'event' => $event,
- 'product_id' => (string) $product_id,
- 'quantity' => (string) $quantity,
- );
-
- // append new data
- $data[] = $new_data;
-
- WC()->session->set( 'wca_session_data', $data );
- }
-
- /**
- * Gets product categories or varation attributes as a formatted concatenated string
- *
- * @param object $product WC_Product.
- * @return string
- */
- public function get_product_categories_concatenated( $product ) {
-
- if ( ! $product ) {
- return '';
- }
-
- $variation_data = $product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product->get_id() ) : '';
- if ( is_array( $variation_data ) && ! empty( $variation_data ) ) {
- $line = wc_get_formatted_variation( $variation_data, true );
- } else {
- $out = array();
- $categories = get_the_terms( $product->get_id(), 'product_cat' );
- if ( $categories ) {
- foreach ( $categories as $category ) {
- $out[] = $category->name;
- }
- }
- $line = join( '/', $out );
- }
- return $line;
- }
-
-}
diff --git a/plugins/jetpack/modules/woocommerce-analytics/wp-woocommerce-analytics.php b/plugins/jetpack/modules/woocommerce-analytics/wp-woocommerce-analytics.php
deleted file mode 100644
index d078af40..00000000
--- a/plugins/jetpack/modules/woocommerce-analytics/wp-woocommerce-analytics.php
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-/**
- * Jetpack_WooCommerce_Analytics is ported from the Jetpack_Google_Analytics code.
- *
- * @package Jetpack
- */
-
-if ( ! defined( 'ABSPATH' ) ) {
- exit;
-}
-
-require_once plugin_basename( 'classes/wp-woocommerce-analytics-universal.php' );
-
-/**
- * Class Jetpack_WooCommerce_Analytics
- * Instantiate WooCommerce Analytics
- */
-class Jetpack_WooCommerce_Analytics {
-
- /**
- * Instance of this class
- *
- * @var Jetpack_WooCommerce_Analytics - Static property to hold our singleton instance
- */
- private static $instance = false;
-
- /**
- * Instance of the Universal functions
- *
- * @var Static property to hold concrete analytics impl that does the work (universal or legacy)
- */
- private static $analytics = false;
-
- /**
- * WooCommerce Analytics is only available to Jetpack connected WooCommerce stores with both plugins set to active
- * and WooCommerce version 3.0 or higher
- *
- * @return bool
- */
- public static function shouldTrackStore() {
- /**
- * Make sure WooCommerce is installed and active
- *
- * This action is documented in https://docs.woocommerce.com/document/create-a-plugin
- */
- if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', Jetpack::get_active_plugins() ) ) ) {
- return false;
- }
- // Tracking only Site pages
- if ( is_admin() ) {
- return false;
- }
- // Don't track site admins
- if ( is_user_logged_in() && in_array( 'administrator', wp_get_current_user()->roles ) ) {
- return false;
- }
- // Make sure Jetpack is installed and active
- if ( ! Jetpack::is_active() ) {
- return false;
- }
- // Ensure the WooCommerce class exists and is a valid version
- $minimum_woocommerce_active = class_exists( 'WooCommerce' ) && version_compare( WC_VERSION, '3.0', '>=' );
- if ( ! $minimum_woocommerce_active ) {
- return false;
- }
- return true;
- }
-
- /**
- * This is our constructor, which is private to force the use of get_instance()
- *
- * @return void
- */
- private function __construct() {
- $analytics = new Jetpack_WooCommerce_Analytics_Universal();
- }
-
- /**
- * Function to instantiate our class and make it a singleton
- */
- public static function get_instance() {
- if ( ! self::shouldTrackStore() ) {
- return;
- }
- if ( ! self::$instance ) {
- self::$instance = new self();
- }
-
- return self::$instance;
- }
-}
-
-global $jetpack_woocommerce_analytics;
-$jetpack_woocommerce_analytics = Jetpack_WooCommerce_Analytics::get_instance();
diff --git a/plugins/jetpack/modules/wordads/class-wordads.php b/plugins/jetpack/modules/wordads/class-wordads.php
index 0cb0df9d..4a73322b 100644
--- a/plugins/jetpack/modules/wordads/class-wordads.php
+++ b/plugins/jetpack/modules/wordads/class-wordads.php
@@ -207,13 +207,14 @@ class WordAds {
WordAds_California_Privacy::init();
}
- if ( '/ads.txt' === $_SERVER['REQUEST_URI'] ) {
+ if ( isset( $_SERVER['REQUEST_URI'] ) && '/ads.txt' === $_SERVER['REQUEST_URI'] ) {
- $ads_txt_transient = get_transient( 'jetpack_ads_txt' );
+ $ads_txt_transient = get_transient( 'wordads_ads_txt' );
if ( false === ( $ads_txt_transient ) ) {
- $ads_txt_transient = ! is_wp_error( WordAds_API::get_wordads_ads_txt() ) ? WordAds_API::get_wordads_ads_txt() : '';
- set_transient( 'jetpack_ads_txt', $ads_txt_transient, DAY_IN_SECONDS );
+ $wordads_ads_txt = WordAds_API::get_wordads_ads_txt();
+ $ads_txt_transient = is_wp_error( $wordads_ads_txt ) ? '' : $wordads_ads_txt;
+ set_transient( 'wordads_ads_txt', $ads_txt_transient, DAY_IN_SECONDS );
}
/**
@@ -359,9 +360,10 @@ class WordAds {
$data_tags = ( $this->params->cloudflare ) ? ' data-cfasync="false"' : '';
$site_id = $this->params->blog_id;
$consent = (int) isset( $_COOKIE['personalized-ads-consent'] );
+ $is_logged_in = is_user_logged_in() ? '1' : '0';
?>
<script<?php echo esc_attr( $data_tags ); ?> type="text/javascript">
- var __ATA_PP = { pt: <?php echo esc_js( $pagetype ); ?>, ht: <?php echo esc_js( $hosting_type ); ?>, tn: '<?php echo esc_js( get_stylesheet() ); ?>', amp: false, siteid: <?php echo esc_js( $site_id ); ?>, consent: <?php echo esc_js( $consent ); ?>, ad: { label: { text: '<?php echo esc_js( __( 'Advertisements', 'jetpack' ) ); ?>' }, reportAd: { text: '<?php echo esc_js( __( 'Report this ad', 'jetpack' ) ); ?>' } } };
+ var __ATA_PP = { pt: <?php echo esc_js( $pagetype ); ?>, ht: <?php echo esc_js( $hosting_type ); ?>, tn: '<?php echo esc_js( get_stylesheet() ); ?>', uloggedin: <?php echo esc_js( $is_logged_in ); ?>, amp: false, siteid: <?php echo esc_js( $site_id ); ?>, consent: <?php echo esc_js( $consent ); ?>, ad: { label: { text: '<?php echo esc_js( __( 'Advertisements', 'jetpack' ) ); ?>' }, reportAd: { text: '<?php echo esc_js( __( 'Report this ad', 'jetpack' ) ); ?>' } } };
var __ATA = __ATA || {};
__ATA.cmd = __ATA.cmd || [];
__ATA.criteo = __ATA.criteo || {};
diff --git a/plugins/jetpack/modules/wordads/php/admin.php b/plugins/jetpack/modules/wordads/php/admin.php
deleted file mode 100644
index b7071666..00000000
--- a/plugins/jetpack/modules/wordads/php/admin.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-/**
- * The standard set of admin pages for the user if Jetpack is installed
- */
-class WordAds_Admin {
-
- /**
- * @since 4.5.0
- */
- function __construct() {
- global $wordads;
-
- if ( current_user_can( 'manage_options' ) && isset( $_GET['ads_debug'] ) ) {
- WordAds_API::update_wordads_status_from_api();
- add_action( 'admin_notices', array( $this, 'debug_output' ) );
- }
- }
-
- /**
- * Output the API connection debug
- *
- * @since 4.5.0
- */
- function debug_output() {
- global $wordads, $wordads_status_response;
- $response = $wordads_status_response;
- if ( empty( $response ) ) {
- $response = 'No response from API :(';
- } else {
- $response = print_r( $response, 1 );
- }
-
- $status = $wordads->option( 'wordads_approved' ) ?
- '<span style="color:green;">Yes</span>' :
- '<span style="color:red;">No</span>';
-
- $type = $wordads->option( 'wordads_approved' ) ? 'updated' : 'error';
- echo <<<HTML
- <div class="notice $type is-dismissible">
- <p>Status: $status</p>
- <pre>$response</pre>
- </div>
-HTML;
- }
-}
-
-global $wordads_admin;
-$wordads_admin = new WordAds_Admin();
diff --git a/plugins/jetpack/modules/wordads/php/api.php b/plugins/jetpack/modules/wordads/php/api.php
deleted file mode 100644
index f2308523..00000000
--- a/plugins/jetpack/modules/wordads/php/api.php
+++ /dev/null
@@ -1,146 +0,0 @@
-<?php
-
-use Automattic\Jetpack\Connection\Client;
-use Automattic\Jetpack\Status;
-
-/**
- * Methods for accessing data through the WPCOM REST API
- *
- * @since 4.5.0
- */
-class WordAds_API {
-
- private static $wordads_status = null;
-
- /**
- * Returns site's WordAds status
- *
- * @return array boolean values for 'approved' and 'active'
- *
- * @since 4.5.0
- */
- public static function get_wordads_status() {
- global $wordads_status_response;
- if ( ( new Status() )->is_development_mode() ) {
- self::$wordads_status = array(
- 'approved' => true,
- 'active' => true,
- 'house' => true,
- 'unsafe' => false,
- );
-
- return self::$wordads_status;
- }
-
- $endpoint = sprintf( '/sites/%d/wordads/status', Jetpack::get_option( 'id' ) );
- $wordads_status_response = $response = Client::wpcom_json_api_request_as_blog( $endpoint );
- if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
- return new WP_Error( 'api_error', __( 'Error connecting to API.', 'jetpack' ), $response );
- }
-
- $body = json_decode( wp_remote_retrieve_body( $response ) );
- self::$wordads_status = array(
- 'approved' => $body->approved,
- 'active' => $body->active,
- 'house' => $body->house,
- 'unsafe' => $body->unsafe,
- );
-
- return self::$wordads_status;
- }
-
- /**
- * Returns the ads.txt content needed to run WordAds.
- *
- * @return array string contents of the ads.txt file.
- *
- * @since 6.1.0
- */
- public static function get_wordads_ads_txt() {
- $endpoint = sprintf( '/sites/%d/wordads/ads-txt', Jetpack::get_option( 'id' ) );
- $wordads_status_response = $response = Client::wpcom_json_api_request_as_blog( $endpoint );
- if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
- return new WP_Error( 'api_error', __( 'Error connecting to API.', 'jetpack' ), $response );
- }
-
- $body = json_decode( wp_remote_retrieve_body( $response ) );
- $ads_txt = str_replace( '\\n', PHP_EOL, $body->adstxt );
- return $ads_txt;
- }
-
- /**
- * Returns status of WordAds approval.
- *
- * @return boolean true if site is WordAds approved
- *
- * @since 4.5.0
- */
- public static function is_wordads_approved() {
- if ( is_null( self::$wordads_status ) ) {
- self::get_wordads_status();
- }
-
- return self::$wordads_status['approved'] ? '1' : '0';
- }
-
- /**
- * Returns status of WordAds active.
- *
- * @return boolean true if ads are active on site
- *
- * @since 4.5.0
- */
- public static function is_wordads_active() {
- if ( is_null( self::$wordads_status ) ) {
- self::get_wordads_status();
- }
-
- return self::$wordads_status['active'] ? '1' : '0';
- }
-
- /**
- * Returns status of WordAds house ads.
- *
- * @return boolean true if WP.com house ads should be shown
- *
- * @since 4.5.0
- */
- public static function is_wordads_house() {
- if ( is_null( self::$wordads_status ) ) {
- self::get_wordads_status();
- }
-
- return self::$wordads_status['house'] ? '1' : '0';
- }
-
-
- /**
- * Returns whether or not this site is safe to run ads on.
- *
- * @return boolean true if ads shown not be shown on this site.
- *
- * @since 6.5.0
- */
- public static function is_wordads_unsafe() {
- if ( is_null( self::$wordads_status ) ) {
- self::get_wordads_status();
- }
-
- return self::$wordads_status['unsafe'] ? '1' : '0';
- }
-
- /**
- * Grab WordAds status from WP.com API and store as option
- *
- * @since 4.5.0
- */
- static function update_wordads_status_from_api() {
- $status = self::get_wordads_status();
- if ( ! is_wp_error( $status ) ) {
- update_option( 'wordads_approved', self::is_wordads_approved(), true );
- update_option( 'wordads_active', self::is_wordads_active(), true );
- update_option( 'wordads_house', self::is_wordads_house(), true );
- update_option( 'wordads_unsafe', self::is_wordads_unsafe(), true );
- }
- }
-}
diff --git a/plugins/jetpack/modules/wordads/php/class-wordads-api.php b/plugins/jetpack/modules/wordads/php/class-wordads-api.php
index a5e565e8..15b4e8e7 100644
--- a/plugins/jetpack/modules/wordads/php/class-wordads-api.php
+++ b/plugins/jetpack/modules/wordads/php/class-wordads-api.php
@@ -16,48 +16,61 @@ use Automattic\Jetpack\Status;
class WordAds_API {
/**
- * WordAds status.
+ * Get the site's WordAds status
*
- * @var null|array
- */
- private static $wordads_status = null;
-
- /**
- * Returns site's WordAds status
- *
- * @return array boolean values for 'approved' and 'active'
+ * @return array|WP_Error Array of site status values, or WP_Error if no response from the API.
*
* @since 4.5.0
*/
public static function get_wordads_status() {
global $wordads_status_response;
+
+ // If the site is not connected, we can put it in a safe "house ad" mode.
if ( ( new Status() )->is_offline_mode() ) {
- self::$wordads_status = array(
+ return array(
'approved' => true,
'active' => true,
'house' => true,
'unsafe' => false,
);
-
- return self::$wordads_status;
}
+ // Fetch the status from WPCOM endpoint.
$endpoint = sprintf( '/sites/%d/wordads/status', Jetpack::get_option( 'id' ) );
$response = Client::wpcom_json_api_request_as_blog( $endpoint );
$wordads_status_response = $response;
+
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
return new WP_Error( 'api_error', __( 'Error connecting to API.', 'jetpack' ), $response );
}
- $body = json_decode( wp_remote_retrieve_body( $response ) );
- self::$wordads_status = array(
- 'approved' => $body->approved,
- 'active' => $body->active,
- 'house' => $body->house,
- 'unsafe' => $body->unsafe,
+ $body = json_decode( wp_remote_retrieve_body( $response ) );
+
+ return array(
+ 'approved' => (bool) $body->approved,
+ 'active' => (bool) $body->active,
+ 'house' => (bool) $body->house,
+ 'unsafe' => (bool) $body->unsafe,
);
+ }
+
+ /**
+ * Grab WordAds status from WP.com API and store as option
+ *
+ * @since 4.5.0
+ */
+ public static function update_wordads_status_from_api() {
+ $status = self::get_wordads_status();
- return self::$wordads_status;
+ if ( ! is_wp_error( $status ) ) {
+
+ // Convert boolean options to string first to work around update_option not setting the option if the value is false.
+ // This sets the option to either '1' if true or '' if false.
+ update_option( 'wordads_approved', (string) $status['approved'], true );
+ update_option( 'wordads_active', (string) $status['active'], true );
+ update_option( 'wordads_house', (string) $status['house'], true );
+ update_option( 'wordads_unsafe', (string) $status['unsafe'], true );
+ }
}
/**
@@ -79,81 +92,7 @@ class WordAds_API {
$body = json_decode( wp_remote_retrieve_body( $response ) );
$ads_txt = str_replace( '\\n', PHP_EOL, $body->adstxt );
- return $ads_txt;
- }
- /**
- * Returns status of WordAds approval.
- *
- * @return boolean true if site is WordAds approved
- *
- * @since 4.5.0
- */
- public static function is_wordads_approved() {
- if ( is_null( self::$wordads_status ) ) {
- self::get_wordads_status();
- }
-
- return (bool) self::$wordads_status['approved'];
- }
-
- /**
- * Returns status of WordAds active.
- *
- * @return boolean true if ads are active on site
- *
- * @since 4.5.0
- */
- public static function is_wordads_active() {
- if ( is_null( self::$wordads_status ) ) {
- self::get_wordads_status();
- }
-
- return (bool) self::$wordads_status['active'];
- }
-
- /**
- * Returns status of WordAds house ads.
- *
- * @return boolean true if WP.com house ads should be shown
- *
- * @since 4.5.0
- */
- public static function is_wordads_house() {
- if ( is_null( self::$wordads_status ) ) {
- self::get_wordads_status();
- }
-
- return (bool) self::$wordads_status['house'];
- }
-
- /**
- * Returns whether or not this site is safe to run ads on.
- *
- * @return boolean true if ads shown not be shown on this site.
- *
- * @since 6.5.0
- */
- public static function is_wordads_unsafe() {
- if ( is_null( self::$wordads_status ) ) {
- self::get_wordads_status();
- }
-
- return (bool) self::$wordads_status['unsafe'];
- }
-
- /**
- * Grab WordAds status from WP.com API and store as option
- *
- * @since 4.5.0
- */
- public static function update_wordads_status_from_api() {
- $status = self::get_wordads_status();
- if ( ! is_wp_error( $status ) ) {
- update_option( 'wordads_approved', self::is_wordads_approved(), true );
- update_option( 'wordads_active', self::is_wordads_active(), true );
- update_option( 'wordads_house', self::is_wordads_house(), true );
- update_option( 'wordads_unsafe', self::is_wordads_unsafe(), true );
- }
+ return $ads_txt;
}
}
diff --git a/plugins/jetpack/modules/wordads/php/class-wordads-california-privacy.php b/plugins/jetpack/modules/wordads/php/class-wordads-california-privacy.php
index b2e9135c..2cfa54a6 100644
--- a/plugins/jetpack/modules/wordads/php/class-wordads-california-privacy.php
+++ b/plugins/jetpack/modules/wordads/php/class-wordads-california-privacy.php
@@ -136,7 +136,7 @@ class WordAds_California_Privacy {
$host = 'localhost';
if ( isset( $_SERVER['HTTP_HOST'] ) ) {
- $host = $_SERVER['HTTP_HOST'];
+ $host = filter_var( wp_unslash( $_SERVER['HTTP_HOST'] ) );
}
return '.wordpress.com' === substr( $host, -strlen( '.wordpress.com' ) ) ? '.wordpress.com' : '.' . $host;
@@ -166,7 +166,7 @@ class WordAds_California_Privacy {
* @return bool True if the cookie could be set.
*/
private static function set_optout_cookie() {
- return setcookie( self::get_cookie_name(), self::get_optout_cookie_string(), time() + ( 5 * YEAR_IN_SECONDS ), '/', self::get_cookie_domain() );
+ return setcookie( self::get_cookie_name(), self::get_optout_cookie_string(), time() + ( 5 * YEAR_IN_SECONDS ), '/', self::get_cookie_domain(), is_ssl(), false ); // phpcs:ignore Jetpack.Functions.SetCookie -- Want this accessible.
}
/**
@@ -175,7 +175,7 @@ class WordAds_California_Privacy {
* @return bool True if the cookie could be set.
*/
private static function set_optin_cookie() {
- return setcookie( self::get_cookie_name(), self::get_optin_cookie_string(), time() + YEAR_IN_SECONDS, '/', self::get_cookie_domain() );
+ return setcookie( self::get_cookie_name(), self::get_optin_cookie_string(), time() + YEAR_IN_SECONDS, '/', self::get_cookie_domain(), is_ssl(), false ); // phpcs:ignore Jetpack.Functions.SetCookie -- Want this accessible.
}
/**
@@ -184,7 +184,7 @@ class WordAds_California_Privacy {
public static function handle_optout_request() {
check_ajax_referer( 'ccpa_optout', 'security' );
- $optout = 'true' === $_POST['optout'];
+ $optout = isset( $_POST['optout'] ) && 'true' === $_POST['optout'];
$optout ? self::set_optout_cookie() : self::set_optin_cookie();
wp_send_json_success( $optout );
diff --git a/plugins/jetpack/modules/wordads/php/class-wordads-params.php b/plugins/jetpack/modules/wordads/php/class-wordads-params.php
index 5aa798d5..9c450f19 100644
--- a/plugins/jetpack/modules/wordads/php/class-wordads-params.php
+++ b/plugins/jetpack/modules/wordads/php/class-wordads-params.php
@@ -38,31 +38,30 @@ class WordAds_Params {
'wordads_ccpa_privacy_policy_url' => get_option( 'wp_page_for_privacy_policy' ) ? get_permalink( (int) get_option( 'wp_page_for_privacy_policy' ) ) : '',
);
- // grab settings, or set as default if it doesn't exist.
+ // Grab settings, or set as default if it doesn't exist.
$this->options = array();
+
foreach ( $settings as $setting => $default ) {
$option = get_option( $setting, null );
- if ( is_null( $option ) ) {
+ if ( $option === null ) {
// Handle retroactively setting wordads_custom_adstxt_enabled to true if custom ads.txt content is already entered.
if ( 'wordads_custom_adstxt_enabled' === $setting ) {
$default = get_option( 'wordads_custom_adstxt' ) !== '';
}
- update_option( $setting, $default, true );
+ // Convert boolean options to string first to work around update_option not setting the option if the value is false.
+ // This sets the option to either '1' if true or '' if false.
+ update_option( $setting, (string) $default, true );
+
$option = $default;
}
$this->options[ $setting ] = is_bool( $default ) ? (bool) $option : $option;
}
- $host = 'localhost';
- if ( isset( $_SERVER['HTTP_HOST'] ) ) {
- $host = $_SERVER['HTTP_HOST'];
- }
-
- $this->url = ( is_ssl() ? 'https' : 'http' ) . '://' . $host . $_SERVER['REQUEST_URI'];
+ $this->url = esc_url_raw( ( is_ssl() ? 'https' : 'http' ) . '://' . ( isset( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : 'localhost' ) . ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '' ) );
if ( ! ( false === strpos( $this->url, '?' ) ) && ! isset( $_GET['p'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$this->url = substr( $this->url, 0, strpos( $this->url, '?' ) );
}
diff --git a/plugins/jetpack/modules/wordads/php/class-wordads-sidebar-widget.php b/plugins/jetpack/modules/wordads/php/class-wordads-sidebar-widget.php
index 5d59737a..226204d1 100644
--- a/plugins/jetpack/modules/wordads/php/class-wordads-sidebar-widget.php
+++ b/plugins/jetpack/modules/wordads/php/class-wordads-sidebar-widget.php
@@ -39,6 +39,20 @@ class WordAds_Sidebar_Widget extends WP_Widget {
'customize_selective_refresh' => true,
)
);
+
+ add_filter( 'widget_types_to_hide_from_legacy_widget_block', array( $this, 'hide_widget_in_block_editor' ) );
+ }
+
+ /**
+ * Remove the Ad widget from the Legacy Widget block
+ *
+ * @param array $widget_types List of widgets that are currently removed from the Legacy Widget block.
+ *
+ * @return array $widget_types New list of widgets that will be removed.
+ */
+ public function hide_widget_in_block_editor( $widget_types ) {
+ $widget_types[] = 'wordads_sidebar_widget';
+ return $widget_types;
}
/**
diff --git a/plugins/jetpack/modules/wordads/php/cron.php b/plugins/jetpack/modules/wordads/php/cron.php
deleted file mode 100644
index 88677e53..00000000
--- a/plugins/jetpack/modules/wordads/php/cron.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-/**
- * WordAds cron tasks
- *
- * @since 4.5.0
- */
-class WordAds_Cron {
-
- /**
- * Add the actions the cron tasks will use
- *
- * @since 4.5.0
- */
- function __construct() {
- add_action( 'wordads_cron_status', array( $this, 'update_wordads_status' ) );
- }
-
- /**
- * Registered scheduled events on activation
- *
- * @since 4.5.0
- */
- static function activate() {
- wp_schedule_event( time(), 'daily', 'wordads_cron_status' );
- }
-
- /**
- * Clear scheduled hooks on deactivation
- *
- * @since 4.5.0
- */
- static function deactivate() {
- wp_clear_scheduled_hook( 'wordads_cron_status' );
- }
-
- /**
- * Grab WordAds status from WP.com API
- *
- * @since 4.5.0
- */
- static function update_wordads_status() {
- WordAds_API::update_wordads_status_from_api();
- }
-}
-
-global $wordads_cron;
-$wordads_cron = new WordAds_Cron();
diff --git a/plugins/jetpack/modules/wordads/php/params.php b/plugins/jetpack/modules/wordads/php/params.php
deleted file mode 100644
index 30c86648..00000000
--- a/plugins/jetpack/modules/wordads/php/params.php
+++ /dev/null
@@ -1,228 +0,0 @@
-<?php
-
-use Automattic\Jetpack\Status;
-
-class WordAds_Params {
-
- /**
- * Setup parameters for serving the ads
- *
- * @since 4.5.0
- */
- public function __construct() {
- // WordAds setting => default
- $settings = array(
- 'wordads_approved' => false,
- 'wordads_active' => false,
- 'wordads_house' => true,
- 'wordads_unsafe' => false,
- 'enable_header_ad' => true,
- 'wordads_second_belowpost' => true,
- 'wordads_display_front_page' => true,
- 'wordads_display_post' => true,
- 'wordads_display_page' => true,
- 'wordads_display_archive' => true,
- 'wordads_custom_adstxt' => '',
- );
-
- // grab settings, or set as default if it doesn't exist
- $this->options = array();
- foreach ( $settings as $setting => $default ) {
- $option = get_option( $setting, null );
-
- if ( is_null( $option ) ) {
- update_option( $setting, $default, true );
- $option = $default;
- }
-
- $this->options[ $setting ] = 'wordads_custom_adstxt' !== $setting ? (bool) $option : $option;
- }
-
- $host = 'localhost';
- if ( isset( $_SERVER['HTTP_HOST'] ) ) {
- $host = $_SERVER['HTTP_HOST'];
- }
-
- $this->url = ( is_ssl() ? 'https' : 'http' ) . '://' . $host . $_SERVER['REQUEST_URI'];
- if ( ! ( false === strpos( $this->url, '?' ) ) && ! isset( $_GET['p'] ) ) {
- $this->url = substr( $this->url, 0, strpos( $this->url, '?' ) );
- }
-
- $this->cloudflare = self::is_cloudflare();
- $this->blog_id = Jetpack::get_option( 'id', 0 );
- $this->mobile_device = jetpack_is_mobile( 'any', true );
- $this->targeting_tags = array(
- 'WordAds' => 1,
- 'BlogId' => ( new Status() )->is_development_mode() ? 0 : Jetpack_Options::get_option( 'id' ),
- 'Domain' => esc_js( wp_parse_url( home_url(), PHP_URL_HOST ) ),
- 'PageURL' => esc_js( $this->url ),
- 'LangId' => false !== strpos( get_bloginfo( 'language' ), 'en' ) ? 1 : 0, // TODO something else?
- 'AdSafe' => 1, // TODO
- );
- }
-
- /**
- * @return boolean true if the user is browsing on a mobile device (iPad not included)
- *
- * @since 4.5.0
- */
- public function is_mobile() {
- return ! empty( $this->mobile_device );
- }
-
- /**
- * @return boolean true if site is being served via CloudFlare
- *
- * @since 4.5.0
- */
- public static function is_cloudflare() {
- if (
- defined( 'WORDADS_CLOUDFLARE' )
- || isset( $_SERVER['HTTP_CF_CONNECTING_IP'] )
- || isset( $_SERVER['HTTP_CF_IPCOUNTRY'] )
- || isset( $_SERVER['HTTP_CF_VISITOR'] )
- ) {
- return true;
- }
-
- return false;
- }
-
- /**
- * @return boolean true if user is browsing in iOS device
- *
- * @since 4.5.0
- */
- public function is_ios() {
- return in_array( $this->get_device(), array( 'ipad', 'iphone', 'ipod' ) );
- }
-
- /**
- * Returns the user's device (see user-agent.php) or 'desktop'
- *
- * @return string user device
- *
- * @since 4.5.0
- */
- public function get_device() {
- global $agent_info;
-
- if ( ! empty( $this->mobile_device ) ) {
- return $this->mobile_device;
- }
-
- if ( $agent_info->is_ipad() ) {
- return 'ipad';
- }
-
- return 'desktop';
- }
-
- /**
- * @return string The type of page that is being loaded
- *
- * @since 4.5.0
- */
- public function get_page_type() {
- if ( ! empty( $this->page_type ) ) {
- return $this->page_type;
- }
-
- if ( self::is_static_home() ) {
- $this->page_type = 'static_home';
- } elseif ( is_home() ) {
- $this->page_type = 'home';
- } elseif ( is_page() ) {
- $this->page_type = 'page';
- } elseif ( is_single() ) {
- $this->page_type = 'post';
- } elseif ( is_search() ) {
- $this->page_type = 'search';
- } elseif ( is_category() ) {
- $this->page_type = 'category';
- } elseif ( is_archive() ) {
- $this->page_type = 'archive';
- } else {
- $this->page_type = 'wtf';
- }
-
- return $this->page_type;
- }
-
- /**
- * @return int The page type code for ipw config
- *
- * @since 5.6.0
- */
- public function get_page_type_ipw() {
- if ( ! empty( $this->page_type_ipw ) ) {
- return $this->page_type_ipw;
- }
-
- $page_type_ipw = 6;
- if ( self::is_static_home() || is_home() || is_front_page() ) {
- $page_type_ipw = 0;
- } elseif ( is_page() ) {
- $page_type_ipw = 2;
- } elseif ( is_singular() ) {
- $page_type_ipw = 1;
- } elseif ( is_search() ) {
- $page_type_ipw = 4;
- } elseif ( is_category() || is_tag() || is_archive() || is_author() ) {
- $page_type_ipw = 3;
- } elseif ( is_404() ) {
- $page_type_ipw = 5;
- }
-
- $this->page_type_ipw = $page_type_ipw;
- return $page_type_ipw;
- }
-
- /**
- * Returns true if page is static home
- *
- * @return boolean true if page is static home
- *
- * @since 4.5.0
- */
- public static function is_static_home() {
- return is_front_page() &&
- 'page' == get_option( 'show_on_front' ) &&
- get_option( 'page_on_front' );
- }
-
- /**
- * Logic for if we should show an ad
- *
- * @since 4.5.0
- */
- public function should_show() {
- global $wp_query;
- if ( ( is_front_page() || is_home() ) && ! $this->options['wordads_display_front_page'] ) {
- return false;
- }
-
- if ( is_single() && ! $this->options['wordads_display_post'] ) {
- return false;
- }
-
- if ( is_page() && ! $this->options['wordads_display_page'] ) {
- return false;
- }
-
- if ( ( is_archive() || is_search() ) && ! $this->options['wordads_display_archive'] ) {
- return false;
- }
-
- if ( is_single() || ( is_page() && ! is_home() ) ) {
- return true;
- }
-
- // TODO this would be a good place for allowing the user to specify
- if ( ( is_home() || is_archive() || is_search() ) && 0 == $wp_query->current_post ) {
- return true;
- }
-
- return false;
- }
-}
diff --git a/plugins/jetpack/modules/wordads/php/widgets.php b/plugins/jetpack/modules/wordads/php/widgets.php
deleted file mode 100644
index 782c2dcd..00000000
--- a/plugins/jetpack/modules/wordads/php/widgets.php
+++ /dev/null
@@ -1,115 +0,0 @@
-<?php
-
-/**
- * Widget for inserting an ad into your sidebar
- *
- * @since 4.5.0
- */
-class WordAds_Sidebar_Widget extends WP_Widget {
-
- private static $allowed_tags = array( 'mrec', 'wideskyscraper' );
- private static $num_widgets = 0;
-
- function __construct() {
- parent::__construct(
- 'wordads_sidebar_widget',
- /** This filter is documented in modules/widgets/facebook-likebox.php */
- apply_filters( 'jetpack_widget_name', 'Ads' ),
- array(
- 'description' => __( 'Insert an ad unit wherever you can place a widget.', 'jetpack' ),
- 'customize_selective_refresh' => true,
- )
- );
- }
-
- public function widget( $args, $instance ) {
- global $wordads;
- if ( $wordads->should_bail() ) {
- return false;
- }
-
- if ( ! isset( $instance['unit'] ) ) {
- $instance['unit'] = 'mrec';
- }
-
- self::$num_widgets++;
- $about = __( 'Advertisements', 'jetpack' );
- $width = WordAds::$ad_tag_ids[ $instance['unit'] ]['width'];
- $height = WordAds::$ad_tag_ids[ $instance['unit'] ]['height'];
- $unit_id = 1 == self::$num_widgets ? 3 : self::$num_widgets + 3; // 2nd belowpost is '4'
- $section_id = 0 === $wordads->params->blog_id ?
- WORDADS_API_TEST_ID :
- $wordads->params->blog_id . $unit_id;
-
- $snippet = '';
- if ( $wordads->option( 'wordads_house', true ) ) {
- $unit = 'mrec';
- if ( 'leaderboard' == $instance['unit'] && ! $this->params->mobile_device ) {
- $unit = 'leaderboard';
- } elseif ( 'wideskyscraper' == $instance['unit'] ) {
- $unit = 'widesky';
- }
-
- $snippet = $wordads->get_house_ad( $unit );
- } else {
- $snippet = $wordads->get_ad_snippet( $section_id, $height, $width, 'widget' );
- }
-
- echo <<< HTML
- <div class="wpcnt">
- <div class="wpa">
- <span class="wpa-about">$about</span>
- <div class="u {$instance['unit']}">
- $snippet
- </div>
- </div>
- </div>
-HTML;
- }
-
- public function form( $instance ) {
- // ad unit type
- if ( isset( $instance['unit'] ) ) {
- $unit = $instance['unit'];
- } else {
- $unit = 'mrec';
- }
- ?>
- <p>
- <label for="<?php echo esc_attr( $this->get_field_id( 'unit' ) ); ?>"><?php _e( 'Tag Dimensions:', 'jetpack' ); ?></label>
- <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'unit' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'unit' ) ); ?>">
- <?php
- foreach ( WordAds::$ad_tag_ids as $ad_unit => $properties ) {
- if ( ! in_array( $ad_unit, self::$allowed_tags ) ) {
- continue;
- }
-
- $splits = explode( '_', $properties['tag'] );
- $unit_pretty = "{$splits[0]} {$splits[1]}";
- $selected = selected( $ad_unit, $unit, false );
- echo "<option value='", esc_attr( $ad_unit ) ,"' ", $selected, '>', esc_html( $unit_pretty ) , '</option>';
- }
- ?>
- </select>
- </p>
- <?php
- }
-
- public function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
-
- if ( in_array( $new_instance['unit'], self::$allowed_tags ) ) {
- $instance['unit'] = $new_instance['unit'];
- } else {
- $instance['unit'] = 'mrec';
- }
-
- return $instance;
- }
-}
-
-function jetpack_wordads_widgets_init_callback() {
- return register_widget( 'WordAds_Sidebar_Widget' );
-}
-
-add_action( 'widgets_init', 'jetpack_wordads_widgets_init_callback' );
diff --git a/plugins/jetpack/modules/wordads/wordads.php b/plugins/jetpack/modules/wordads/wordads.php
deleted file mode 100644
index fee0520d..00000000
--- a/plugins/jetpack/modules/wordads/wordads.php
+++ /dev/null
@@ -1,717 +0,0 @@
-<?php
-
-define( 'WORDADS_ROOT', dirname( __FILE__ ) );
-define( 'WORDADS_BASENAME', plugin_basename( __FILE__ ) );
-define( 'WORDADS_FILE_PATH', WORDADS_ROOT . '/' . basename( __FILE__ ) );
-define( 'WORDADS_URL', plugins_url( '/', __FILE__ ) );
-define( 'WORDADS_API_TEST_ID', '26942' );
-define( 'WORDADS_API_TEST_ID2', '114160' );
-
-require_once WORDADS_ROOT . '/php/widgets.php';
-require_once WORDADS_ROOT . '/php/api.php';
-require_once WORDADS_ROOT . '/php/cron.php';
-
-class WordAds {
-
- public $params = null;
-
- public $ads = array();
-
- /**
- * Array of supported ad types.
- *
- * @var array
- */
- public static $ad_tag_ids = array(
- 'mrec' => array(
- 'tag' => '300x250_mediumrectangle',
- 'height' => '250',
- 'width' => '300',
- ),
- 'leaderboard' => array(
- 'tag' => '728x90_leaderboard',
- 'height' => '90',
- 'width' => '728',
- ),
- 'mobile_leaderboard' => array(
- 'tag' => '320x50_mobileleaderboard',
- 'height' => '50',
- 'width' => '320',
- ),
- 'wideskyscraper' => array(
- 'tag' => '160x600_wideskyscraper',
- 'height' => '600',
- 'width' => '160',
- ),
- );
-
- /**
- * Mapping array of location slugs to placement ids
- *
- * @var array
- */
- public static $ad_location_ids = array(
- 'top' => 110,
- 'belowpost' => 120,
- 'belowpost2' => 130,
- 'sidebar' => 140,
- 'widget' => 150,
- 'gutenberg' => 200,
- 'inline' => 310,
- 'inline-plugin' => 320,
- );
-
- /**
- * Counter to enable unique, sequential section IDs for all amp-ad units
- *
- * @var int
- */
- public static $amp_section_id = 1;
-
- /**
- * Checks for AMP support and returns true iff active & AMP request
- * @return boolean True if supported AMP request
- *
- * @since 7.5.0
- */
- public static function is_amp() {
- return class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request();
- }
-
- /**
- * Increment the AMP section ID and return the value
- *
- * @return int
- */
- public static function get_amp_section_id() {
- return self::$amp_section_id++;
- }
-
- public static $SOLO_UNIT_CSS = 'float:left;margin-right:5px;margin-top:0px;';
-
- /**
- * Convenience function for grabbing options from params->options
- *
- * @param string $option the option to grab
- * @param mixed $default (optional)
- * @return option or $default if not set
- *
- * @since 4.5.0
- */
- function option( $option, $default = false ) {
- if ( ! isset( $this->params->options[ $option ] ) ) {
- return $default;
- }
-
- return $this->params->options[ $option ];
- }
-
- /**
- * Returns the ad tag property array for supported ad types.
- * @return array array with ad tags
- *
- * @since 7.1.0
- */
- function get_ad_tags() {
- return self::$ad_tag_ids;
- }
-
- /**
- * Returns the solo css for unit
- * @return string the special css for solo units
- *
- * @since 7.1.0
- */
- function get_solo_unit_css() {
- return self::$SOLO_UNIT_CSS;
- }
-
- /**
- * Instantiate the plugin
- *
- * @since 4.5.0
- */
- function __construct() {
- add_action( 'wp', array( $this, 'init' ) );
- add_action( 'rest_api_init', array( $this, 'init' ) );
- }
-
- /**
- * Code to run on WordPress 'init' hook
- *
- * @since 4.5.0
- */
- function init() {
- require_once WORDADS_ROOT . '/php/params.php';
- $this->params = new WordAds_Params();
-
- if ( $this->should_bail() || self::is_infinite_scroll() ) {
- return;
- }
-
- if ( is_admin() ) {
- require_once WORDADS_ROOT . '/php/admin.php';
- return;
- }
-
- $this->insert_adcode();
-
- if ( '/ads.txt' === $_SERVER['REQUEST_URI'] ) {
-
- if ( false === ( $ads_txt_transient = get_transient( 'jetpack_ads_txt' ) ) ) {
- $ads_txt_transient = ! is_wp_error( WordAds_API::get_wordads_ads_txt() ) ? WordAds_API::get_wordads_ads_txt() : '';
- set_transient( 'jetpack_ads_txt', $ads_txt_transient, DAY_IN_SECONDS );
- }
-
- /**
- * Provide plugins a way of modifying the contents of the automatically-generated ads.txt file.
- *
- * @module wordads
- *
- * @since 6.1.0
- *
- * @param string WordAds_API::get_wordads_ads_txt() The contents of the ads.txt file.
- */
- $ads_txt_content = apply_filters( 'wordads_ads_txt', $ads_txt_transient );
-
- http_response_code( 200 );
- header( 'Content-Type: text/plain; charset=utf-8' );
- echo esc_html( $ads_txt_content );
- die();
- }
- }
-
- /**
- * Check for Jetpack's The_Neverending_Home_Page and use got_infinity
- *
- * @return boolean true if load came from infinite scroll
- *
- * @since 4.5.0
- */
- public static function is_infinite_scroll() {
- return class_exists( 'The_Neverending_Home_Page' ) && The_Neverending_Home_Page::got_infinity();
- }
-
- /**
- * Add the actions/filters to insert the ads. Checks for mobile or desktop.
- *
- * @since 4.5.0
- */
- private function insert_adcode() {
- add_filter( 'wp_resource_hints', array( $this, 'resource_hints' ), 10, 2 );
- add_action( 'wp_head', array( $this, 'insert_head_meta' ), 20 );
- add_action( 'wp_head', array( $this, 'insert_head_iponweb' ), 30 );
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
- add_filter( 'wordads_ads_txt', array( $this, 'insert_custom_adstxt' ) );
-
- /**
- * Filters enabling ads in `the_content` filter
- *
- * @see https://jetpack.com/support/ads/
- *
- * @module wordads
- *
- * @since 5.8.0
- *
- * @param bool True to disable ads in `the_content`
- */
- if ( ! apply_filters( 'wordads_content_disable', false ) ) {
- add_filter( 'the_content', array( $this, 'insert_ad' ) );
- }
-
- /**
- * Filters enabling ads in `the_excerpt` filter
- *
- * @see https://jetpack.com/support/ads/
- *
- * @module wordads
- *
- * @since 5.8.0
- *
- * @param bool True to disable ads in `the_excerpt`
- */
- if ( ! apply_filters( 'wordads_excerpt_disable', false ) ) {
- add_filter( 'the_excerpt', array( $this, 'insert_ad' ) );
- }
-
- if ( $this->option( 'enable_header_ad', true ) ) {
- if ( self::is_amp() ) {
- add_filter( 'the_content', array( $this, 'insert_header_ad_amp' ) );
- } else {
- switch ( get_stylesheet() ) {
- case 'twentyseventeen':
- case 'twentyfifteen':
- case 'twentyfourteen':
- add_action( 'wp_footer', array( $this, 'insert_header_ad_special' ) );
- break;
- default:
- add_action( 'wp_head', array( $this, 'insert_header_ad' ), 100 );
- break;
- }
- }
- }
- }
-
- /**
- * Register desktop scripts and styles
- *
- * @since 4.5.0
- */
- function enqueue_scripts() {
- wp_enqueue_style(
- 'wordads',
- WORDADS_URL . 'css/style.css',
- array(),
- '2015-12-18'
- );
- }
-
- /**
- * Add the IPW resource hints
- *
- * @since 7.9
- */
- public function resource_hints( $hints, $relation_type ) {
- if ( 'dns-prefetch' === $relation_type ) {
- $hints[] = '//s.pubmine.com';
- $hints[] = '//x.bidswitch.net';
- $hints[] = '//static.criteo.net';
- $hints[] = '//ib.adnxs.com';
- $hints[] = '//aax.amazon-adsystem.com';
- $hints[] = '//bidder.criteo.com';
- $hints[] = '//cas.criteo.com';
- $hints[] = '//gum.criteo.com';
- $hints[] = '//ads.pubmatic.com';
- $hints[] = '//gads.pubmatic.com';
- $hints[] = '//tpc.googlesyndication.com';
- $hints[] = '//ad.doubleclick.net';
- $hints[] = '//googleads.g.doubleclick.net';
- $hints[] = '//www.googletagservices.com';
- $hints[] = '//cdn.switchadhub.com';
- $hints[] = '//delivery.g.switchadhub.com';
- $hints[] = '//delivery.swid.switchadhub.com';
- }
-
- return $hints;
- }
-
- /**
- * IPONWEB metadata used by the various scripts
- *
- * @return [type] [description]
- */
- function insert_head_meta() {
- if ( self::is_amp() ) {
- return;
- }
- $themename = esc_js( get_stylesheet() );
- $pagetype = intval( $this->params->get_page_type_ipw() );
- $data_tags = ( $this->params->cloudflare ) ? ' data-cfasync="false"' : '';
- $site_id = $this->params->blog_id;
- $consent = intval( isset( $_COOKIE['personalized-ads-consent'] ) );
- echo <<<HTML
- <script$data_tags type="text/javascript">
- var __ATA_PP = { pt: $pagetype, ht: 2, tn: '$themename', amp: false, siteid: $site_id, consent: $consent };
- var __ATA = __ATA || {};
- __ATA.cmd = __ATA.cmd || [];
- __ATA.criteo = __ATA.criteo || {};
- __ATA.criteo.cmd = __ATA.criteo.cmd || [];
- </script>
-HTML;
- }
-
- /**
- * IPONWEB scripts in <head>
- *
- * @since 4.5.0
- */
- function insert_head_iponweb() {
- if ( self::is_amp() ) {
- return;
- }
- $data_tags = ( $this->params->cloudflare ) ? ' data-cfasync="false"' : '';
- echo <<<HTML
- <script$data_tags type="text/javascript">
- (function(){function g(a,c){a:{for(var b=a.length,d="string"==typeof a?a.split(""):a,e=0;e<b;e++)if(e in d&&c.call(void 0,d[e],e,a)){c=e;break a}c=-1}return 0>c?null:"string"==typeof a?a.charAt(c):a[c]};function h(a,c,b){b=null!=b?"="+encodeURIComponent(String(b)):"";if(c+=b){b=a.indexOf("#");0>b&&(b=a.length);var d=a.indexOf("?");if(0>d||d>b){d=b;var e=""}else e=a.substring(d+1,b);a=[a.substr(0,d),e,a.substr(b)];b=a[1];a[1]=c?b?b+"&"+c:c:b;a=a[0]+(a[1]?"?"+a[1]:"")+a[2]}return a};var k=0;function l(a,c){var b=document.createElement("script");b.src=a;b.onload=function(){c&&c(void 0)};b.onerror=function(){c("error")};a=document.getElementsByTagName("head");var d;a&&0!==a.length?d=a[0]:d=document.documentElement;d.appendChild(b)}function m(a){return"string"==typeof a&&0<a.length}
- function p(a,c,b){c=void 0===c?"":c;b=void 0===b?".":b;var d=[];Object.keys(a).forEach(function(e){var f=a[e],n=typeof f;"object"==n&&null!=f||"function"==n?d.push(p(f,c+e+b)):null!==f&&void 0!==f&&(e=encodeURIComponent(c+e),d.push(e+"="+encodeURIComponent(f)))});return d.filter(m).join("&")}function q(){return window.__ATA||{}}function r(a,c){a||(q().config=c.c,l(c.url))}var t=Math.floor(1E13*Math.random());q().rid=t;
- var u=q().pageParams,v="//"+(q().serverDomain||"s.pubmine.com")+"/conf",w=window.top===window,x;try{var y=JSON.parse(document.getElementById("oil-configuration").innerText);if("boolean"!==typeof y.gdpr_applies)throw Error("Config doesn't contain gdpr_applies");x=y.gdpr_applies?1:0}catch(a){x=null}
- var z=x,A=window.__ATA_PP||u||null,B=w?document.referrer?document.referrer:null:null,C=w?null:document.referrer?document.referrer:null,D=function(){var a=void 0===a?document.cookie:a;return(a=g(a.split("; "),function(c){return-1!=c.indexOf("__ATA_tuuid=")}))?a.split("=")[1]:""}(),E=p({gdpr:z,pp:A,rid:t,src:B,ref:C,tuuid:D?D:null,vp:window.innerWidth+"x"+window.innerHeight},"",".");
- (function(a){var c;k++;var b="callback__"+Date.now().toString(36)+"_"+k.toString(36);a=h(a,void 0===c?"cb":c,b);window[b]=function(d){r(void 0,d)};l(a,function(d){d&&r(d)})})(v+"?"+E);}).call(this);
- </script>
-HTML;
- }
-
- /**
- * Insert the ad onto the page
- *
- * @since 4.5.0
- */
- function insert_ad( $content ) {
- // Don't insert ads in feeds, or for anything but the main display. (This is required for compatibility with the Publicize module).
- if ( is_feed() || ! is_main_query() || ! in_the_loop() ) {
- return $content;
- }
- /**
- * Allow third-party tools to disable the display of in post ads.
- *
- * @module wordads
- *
- * @since 4.5.0
- *
- * @param bool true Should the in post unit be disabled. Default to false.
- */
- $disable = apply_filters( 'wordads_inpost_disable', false );
- if ( ! $this->params->should_show() || $disable ) {
- return $content;
- }
-
- $ad_type = $this->option( 'wordads_house' ) ? 'house' : 'iponweb';
- return $content . $this->get_ad( 'belowpost', $ad_type );
- }
-
- /**
- * Insert an inline ad into a post content
- * Used for rendering the `wordads` shortcode.
- *
- * @since 6.1.0
- */
- function insert_inline_ad( $content ) {
- // Ad JS won't work in XML feeds.
- if ( is_feed() ) {
- return $content;
- }
- /**
- * Allow third-party tools to disable the display of in post ads.
- *
- * @module wordads
- *
- * @since 4.5.0
- *
- * @param bool true Should the in post unit be disabled. Default to false.
- */
- $disable = apply_filters( 'wordads_inpost_disable', false );
- if ( $disable ) {
- return $content;
- }
-
- $ad_type = $this->option( 'wordads_house' ) ? 'house' : 'iponweb';
- $content .= $this->get_ad( 'inline', $ad_type );
- return $content;
- }
-
- /**
- * Inserts ad into header
- *
- * @since 4.5.0
- */
- function insert_header_ad() {
- /**
- * Allow third-party tools to disable the display of header ads.
- *
- * @module wordads
- *
- * @since 4.5.0
- *
- * @param bool true Should the header unit be disabled. Default to false.
- */
- if ( apply_filters( 'wordads_header_disable', false ) ) {
- return;
- }
-
- $ad_type = $this->option( 'wordads_house' ) ? 'house' : 'iponweb';
- echo $this->get_ad( 'top', $ad_type );
- }
-
- /**
- * Special cases for inserting header unit via jQuery
- *
- * @since 4.5.0
- */
- function insert_header_ad_special() {
- /**
- * Allow third-party tools to disable the display of header ads.
- *
- * @module wordads
- *
- * @since 4.5.0
- *
- * @param bool true Should the header unit be disabled. Default to false.
- */
- if ( apply_filters( 'wordads_header_disable', false ) ) {
- return;
- }
-
- $selector = '#content';
- switch ( get_stylesheet() ) {
- case 'twentyseventeen':
- $selector = '#content';
- break;
- case 'twentyfifteen':
- $selector = '#main';
- break;
- case 'twentyfourteen':
- $selector = 'article:first';
- break;
- }
-
- $ad_type = $this->option( 'wordads_house' ) ? 'house' : 'iponweb';
- echo $this->get_ad( 'top', $ad_type );
- if ( ! self::is_amp() ) {
- echo <<<HTML
- <script type="text/javascript">
- jQuery('.wpcnt-header').insertBefore('$selector');
- </script>
-HTML;
- }
- }
-
- /**
- * Header unit for AMP
- *
- * @param string $content Content of the page.
- *
- * @since 7.5.0
- */
- public function insert_header_ad_amp( $content ) {
-
- $ad_type = $this->option( 'wordads_house' ) ? 'house' : 'iponweb';
- if ( 'house' === $ad_type ) {
- return $content;
- }
- return $this->get_ad( 'top_amp', $ad_type ) . $content;
-
- }
-
- /**
- * Filter the latest ads.txt to include custom user entries. Strips any tags or whitespace.
- *
- * @param string $adstxt The ads.txt being filtered
- * @return string Filtered ads.txt with custom entries, if applicable
- *
- * @since 6.5.0
- */
- function insert_custom_adstxt( $adstxt ) {
- $custom_adstxt = trim( wp_strip_all_tags( $this->option( 'wordads_custom_adstxt' ) ) );
- if ( $custom_adstxt ) {
- $adstxt .= "\n\n#Jetpack - User Custom Entries\n";
- $adstxt .= $custom_adstxt . "\n";
- }
-
- return $adstxt;
- }
-
- /**
- * Get the ad for the spot and type.
- *
- * @param string $spot top, side, inline, or belowpost
- * @param string $type iponweb or adsense
- */
- function get_ad( $spot, $type = 'iponweb' ) {
- $snippet = '';
- if ( 'iponweb' == $type ) {
- // Default to mrec
- $width = 300;
- $height = 250;
-
- $section_id = WORDADS_API_TEST_ID;
- $second_belowpost = '';
- $snippet = '';
- if ( 'top' == $spot ) {
- // mrec for mobile, leaderboard for desktop
- $section_id = 0 === $this->params->blog_id ? WORDADS_API_TEST_ID : $this->params->blog_id . '2';
- $width = $this->params->mobile_device ? 300 : 728;
- $height = $this->params->mobile_device ? 250 : 90;
- $snippet = $this->get_ad_snippet( $section_id, $height, $width, $spot );
- } elseif ( 'belowpost' == $spot ) {
- $section_id = 0 === $this->params->blog_id ? WORDADS_API_TEST_ID : $this->params->blog_id . '1';
- $width = 300;
- $height = 250;
-
- $snippet = $this->get_ad_snippet( $section_id, $height, $width, $spot, self::$SOLO_UNIT_CSS );
- if ( $this->option( 'wordads_second_belowpost', true ) ) {
- $section_id2 = 0 === $this->params->blog_id ? WORDADS_API_TEST_ID2 : $this->params->blog_id . '4';
- $snippet .= $this->get_ad_snippet( $section_id2, $height, $width, $spot . '2', 'float:left;margin-top:0px;' );
- }
- } elseif ( 'inline' === $spot ) {
- $section_id = 0 === $this->params->blog_id ? WORDADS_API_TEST_ID : $this->params->blog_id . '5';
- $snippet = $this->get_ad_snippet( $section_id, $height, $width, $spot, self::$SOLO_UNIT_CSS );
- } elseif ( 'top_amp' === $spot ) {
- // 320x50 unit which can safely be inserted below title, above content in a variety of themes.
- $width = 320;
- $height = 50;
- $snippet = $this->get_ad_snippet( null, $height, $width );
- }
- } elseif ( 'house' == $type ) {
- $leaderboard = 'top' == $spot && ! $this->params->mobile_device;
- $snippet = $this->get_house_ad( $leaderboard ? 'leaderboard' : 'mrec' );
- if ( 'belowpost' == $spot && $this->option( 'wordads_second_belowpost', true ) ) {
- $snippet .= $this->get_house_ad( $leaderboard ? 'leaderboard' : 'mrec' );
- }
- }
-
- return $this->get_ad_div( $spot, $snippet );
- }
-
-
- /**
- * Returns the snippet to be inserted into the ad unit
- *
- * @param int $section_id
- * @param int $height
- * @param int $width
- * @param int $location
- * @param string $css
- * @return string
- *
- * @since 5.7
- */
- public function get_ad_snippet( $section_id, $height, $width, $location = '', $css = '' ) {
- $this->ads[] = array(
- 'location' => $location,
- 'width' => $width,
- 'height' => $height,
- );
-
- if ( self::is_amp() ) {
- $height = esc_attr( $height + 15 ); // this will ensure enough padding for "Report this ad"
- $width = esc_attr( $width );
- $amp_section_id = esc_attr( self::get_amp_section_id() );
- $site_id = esc_attr( $this->params->blog_id );
- return <<<HTML
- <amp-ad width="$width" height="$height"
- type="pubmine"
- data-siteid="$site_id"
- data-section="$amp_section_id">
- </amp-ad>
-HTML;
- }
-
- $ad_number = count( $this->ads ) . '-' . uniqid();
- $data_tags = $this->params->cloudflare ? ' data-cfasync="false"' : '';
- $css = esc_attr( $css );
-
- $loc_id = 100;
- if ( ! empty( self::$ad_location_ids[ $location ] ) ) {
- $loc_id = self::$ad_location_ids[ $location ];
- }
-
- return <<<HTML
- <div style="padding-bottom:15px;width:{$width}px;height:{$height}px;$css">
- <div id="atatags-{$ad_number}">
- <script$data_tags type="text/javascript">
- __ATA.cmd.push(function() {
- __ATA.initSlot('atatags-{$ad_number}', {
- collapseEmpty: 'before',
- sectionId: '{$section_id}',
- location: {$loc_id},
- width: {$width},
- height: {$height}
- });
- });
- </script>
- </div>
- </div>
-HTML;
- }
-
- /**
- * Returns the complete ad div with snippet to be inserted into the page
- *
- * @param string $spot top, side, inline, or belowpost
- * @param string $snippet The snippet to insert into the div
- * @param array $css_classes
- * @return string The supporting ad unit div
- *
- * @since 7.1
- */
- function get_ad_div( $spot, $snippet, array $css_classes = array() ) {
- if ( empty( $css_classes ) ) {
- $css_classes = array();
- }
-
- $css_classes[] = 'wpcnt';
- if ( 'top' == $spot ) {
- $css_classes[] = 'wpcnt-header';
- }
-
- $spot = esc_attr( $spot );
- $classes = esc_attr( implode( ' ', $css_classes ) );
- $about = esc_html__( 'Advertisements', 'jetpack' );
- return <<<HTML
- <div class="$classes">
- <div class="wpa">
- <span class="wpa-about">$about</span>
- <div class="u $spot">
- $snippet
- </div>
- </div>
- </div>
-HTML;
- }
-
- /**
- * Check the reasons to bail before we attempt to insert ads.
- *
- * @return true if we should bail (don't insert ads)
- *
- * @since 4.5.0
- */
- public function should_bail() {
- return ! $this->option( 'wordads_approved' ) || (bool) $this->option( 'wordads_unsafe' );
- }
-
- /**
- * Returns markup for HTML5 house ad base on unit
- *
- * @param string $unit mrec, widesky, or leaderboard
- * @return string markup for HTML5 house ad
- *
- * @since 4.7.0
- */
- public function get_house_ad( $unit = 'mrec' ) {
-
- switch ( $unit ) {
- case 'widesky':
- $width = 160;
- $height = 600;
- break;
- case 'leaderboard':
- $width = 728;
- $height = 90;
- break;
- case 'mrec':
- default:
- $width = 300;
- $height = 250;
- break;
- }
-
- return <<<HTML
- <iframe
- src="https://s0.wp.com/wp-content/blog-plugins/wordads/house/html5/$unit/index.html"
- width="$width"
- height="$height"
- frameborder="0"
- scrolling="no"
- marginheight="0"
- marginwidth="0">
- </iframe>
-HTML;
- }
-
- /**
- * Activation hook actions
- *
- * @since 4.5.0
- */
- public static function activate() {
- WordAds_API::update_wordads_status_from_api();
- }
-}
-
-add_action( 'jetpack_activate_module_wordads', array( 'WordAds', 'activate' ) );
-add_action( 'jetpack_activate_module_wordads', array( 'WordAds_Cron', 'activate' ) );
-add_action( 'jetpack_deactivate_module_wordads', array( 'WordAds_Cron', 'deactivate' ) );
-
-global $wordads;
-$wordads = new WordAds();
diff --git a/plugins/jetpack/modules/wpcom-block-editor/class-jetpack-wpcom-block-editor.php b/plugins/jetpack/modules/wpcom-block-editor/class-jetpack-wpcom-block-editor.php
index 6fc48967..799b8272 100644
--- a/plugins/jetpack/modules/wpcom-block-editor/class-jetpack-wpcom-block-editor.php
+++ b/plugins/jetpack/modules/wpcom-block-editor/class-jetpack-wpcom-block-editor.php
@@ -91,8 +91,8 @@ class Jetpack_WPCOM_Block_Editor {
* Prevents frame options header from firing if this is a allowed iframe request.
*/
public function disable_send_frame_options_header() {
- // phpcs:ignore WordPress.Security.NonceVerification
- if ( $this->framing_allowed( $_GET['frame-nonce'] ) ) {
+ // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput
+ if ( isset( $_GET['frame-nonce'] ) && $this->framing_allowed( $_GET['frame-nonce'] ) ) {
remove_action( 'admin_init', 'send_frame_options_header' );
}
}
@@ -104,8 +104,8 @@ class Jetpack_WPCOM_Block_Editor {
* @return string
*/
public function add_iframed_body_class( $classes ) {
- // phpcs:ignore WordPress.Security.NonceVerification
- if ( $this->framing_allowed( $_GET['frame-nonce'] ) ) {
+ // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput
+ if ( isset( $_GET['frame-nonce'] ) && $this->framing_allowed( $_GET['frame-nonce'] ) ) {
$classes .= ' is-iframed ';
}
@@ -118,12 +118,12 @@ class Jetpack_WPCOM_Block_Editor {
* force the editor to break out of the iFrame.
*/
private function check_iframe_cookie_setting() {
- if ( ! isset( $_SERVER['QUERY_STRING'] ) || ! strpos( $_SERVER['QUERY_STRING'], 'calypsoify%3D1%26block-editor' ) || isset( $_COOKIE['wordpress_test_cookie'] ) ) {
+ if ( ! isset( $_SERVER['QUERY_STRING'] ) || ! strpos( filter_var( wp_unslash( $_SERVER['QUERY_STRING'] ) ), 'calypsoify%3D1%26block-editor' ) || isset( $_COOKIE['wordpress_test_cookie'] ) ) {
return;
}
- if ( empty( $_GET['calypsoify_cookie_check'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- header( 'Location: ' . esc_url_raw( $_SERVER['REQUEST_URI'] . '&calypsoify_cookie_check=true' ) );
+ if ( isset( $_SERVER['REQUEST_URI'] ) && empty( $_GET['calypsoify_cookie_check'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ header( 'Location: ' . esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) . '&calypsoify_cookie_check=true' ) );
exit;
}
@@ -140,11 +140,12 @@ class Jetpack_WPCOM_Block_Editor {
if ( empty( $_REQUEST['redirect_to'] ) ) {
return;
}
+ // phpcs:ignore WordPress.Security.NonceVerification
+ $redirect_to = esc_url_raw( wp_unslash( $_REQUEST['redirect_to'] ) );
$this->check_iframe_cookie_setting();
- // phpcs:ignore WordPress.Security.NonceVerification
- $query = wp_parse_url( urldecode( $_REQUEST['redirect_to'] ), PHP_URL_QUERY );
+ $query = wp_parse_url( urldecode( $redirect_to ), PHP_URL_QUERY );
$args = wp_parse_args( $query );
// Check nonce and make sure this is a Gutenframe request.
@@ -188,7 +189,7 @@ class Jetpack_WPCOM_Block_Editor {
*/
public function add_login_html() {
?>
- <input type="hidden" name="redirect_to" value="<?php echo esc_url( $_REQUEST['redirect_to'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>" />
+ <input type="hidden" name="redirect_to" value="<?php echo isset( $_REQUEST['redirect_to'] ) ? esc_url( wp_unslash( $_REQUEST['redirect_to'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>" />
<script type="application/javascript">
document.getElementById( 'loginform' ).addEventListener( 'submit' , function() {
document.getElementById( 'wp-submit' ).setAttribute( 'disabled', 'disabled' );
@@ -414,7 +415,7 @@ class Jetpack_WPCOM_Block_Editor {
global $post;
if ( ! $post instanceof WP_Post ) {
return false;
- };
+ }
if ( ! has_blocks( $post ) ) {
return false;