PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 7.2.1
Jetpack – WP Security, Backup, Speed, & Growth v7.2.1
12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 14.4.2 All 500 releases
← All changes | modules/custom-css.php +69 -41 13.7.27.2.1 View file →
@@ -1,64 +1,92 @@
1 -<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
1 +<?php
2 2
3 3 /**
4 4 * Module Name: Custom CSS
5 - * Module Description: Adds options for CSS preprocessor use, disabling the theme's CSS, or custom image width.
5 + * Module Description: Tweak your site’s CSS without modifying your theme.
6 6 * Sort Order: 2
7 7 * First Introduced: 1.7
8 8 * Requires Connection: No
9 - * Auto Activate: No
9 + * Auto Activate: Yes
10 10 * Module Tags: Appearance
11 11 * Feature: Appearance
12 12 * Additional Search Queries: css, customize, custom, style, editor, less, sass, preprocessor, font, mobile, appearance, theme, stylesheet
13 13 */
14 14
15 -if ( ! function_exists( 'jetpack_load_custom_css' ) ) {
16 - /**
17 - * Load custom CSS
18 - */
19 - function jetpack_load_custom_css() {
20 - include_once __DIR__ . '/custom-css/custom-css/preprocessors.php';
21 - include_once __DIR__ . '/custom-css/custom-css.php';
15 +function jetpack_load_custom_css() {
16 + // If WordPress has the core version of Custom CSS, load our new version.
17 + // @see https://core.trac.wordpress.org/changeset/38829
18 + if ( function_exists( 'wp_get_custom_css' ) ) {
19 + if ( ! function_exists( 'wp_update_custom_css_post' ) ) {
20 + wp_die( 'Please run a SVN up to get the latest version of trunk, or update to at least 4.7 RC1' );
21 + }
22 + if ( ! Jetpack_Options::get_option( 'custom_css_4.7_migration' ) ) {
23 + include_once dirname( __FILE__ ) . '/custom-css/migrate-to-core.php';
24 + }
25 +
26 + // TODO: DELETE THIS
27 + else {
28 + if ( defined( 'WP_CLI' ) && WP_CLI ) {
29 + function jetpack_custom_css_undo_data_migration_cli() {
30 + Jetpack_Options::delete_option( 'custom_css_4.7_migration' );
31 + WP_CLI::success( __( 'Option deleted, re-migrate via `wp jetpack custom-css migrate`.', 'jetpack' ) );
32 + }
33 + WP_CLI::add_command( 'jetpack custom-css undo-migrate', 'jetpack_custom_css_undo_data_migration_cli' );
34 + }
35 + }
36 + // TODO: END DELETE THIS
37 +
38 + include_once dirname( __FILE__ ) . '/custom-css/custom-css/preprocessors.php';
39 + include_once dirname( __FILE__ ) . '/custom-css/custom-css-4.7.php';
40 + return;
22 41 }
42 +
43 + include_once dirname( __FILE__ ) . "/custom-css/custom-css.php";
44 + add_action( 'init', array( 'Jetpack_Custom_CSS', 'init' ) );
23 45 }
24 46
25 -if ( ! function_exists( 'custom_css_loaded' ) ) {
26 - /**
27 - * Enable CSS module.
28 - */
29 - function custom_css_loaded() {
30 - $message = sprintf(
31 - // translators: %s is a link to the WordPress.org documentation.
32 - __( 'Jetpack no longer supports Custom CSS. Read the WordPress.org documentation to learn how to apply custom styles to your site: %s', 'jetpack' ),
33 - 'https://wordpress.org/documentation/article/styles-overview/#applying-custom-css'
34 - );
47 +add_action( 'jetpack_modules_loaded', 'custom_css_loaded' );
35 48
36 - _deprecated_hook( 'custom_css_loaded', 'jetpack-13.5', 'WordPress Custom CSS', esc_html( $message ) );
49 +function custom_css_loaded() {
50 + Jetpack::enable_module_configurable( __FILE__ );
51 + Jetpack::module_configuration_load( __FILE__, 'custom_css_configuration_load' );
52 + add_filter( 'jetpack_module_configuration_url_custom-css', 'jetpack_custom_css_configuration_url' );
53 +}
37 54
38 - Jetpack::enable_module_configurable( __FILE__ );
39 - add_filter( 'jetpack_module_configuration_url_custom-css', 'jetpack_custom_css_configuration_url' );
55 +/**
56 + * Overrides default configuration url
57 + *
58 + * @uses admin_url
59 + * @return string module settings URL
60 + */
61 +function jetpack_custom_css_configuration_url() {
62 + // Redirect to Core's CSS editor in the customizer if the feature is available.
63 + if ( function_exists( 'wp_get_custom_css' ) ) {
64 + $configuration_link = Jetpack_Custom_CSS_Enhancements::customizer_link(
65 + array(
66 + 'return_url' => wp_get_referer(),
67 + )
68 + );
69 + } else {
70 + $configuration_link = admin_url( 'themes.php?page=editcss#settingsdiv' );
40 71 }
72 +
73 + return $configuration_link;
41 74 }
42 75
43 -if ( ! function_exists( 'jetpack_custom_css_configuration_url' ) ) {
44 - /**
45 - * Overrides default configuration url
46 - *
47 - * @uses admin_url
48 - *
49 - * @param string $default_url - the default URL.
50 - * @return string module settings URL
51 - */
52 - function jetpack_custom_css_configuration_url( $default_url ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
53 - return Jetpack_Custom_CSS_Enhancements::customizer_link(
54 - array( 'return_url' => wp_get_referer() )
76 +function custom_css_configuration_load() {
77 + // Redirect to Core's CSS editor in the customizer if the feature is available.
78 + if ( function_exists( 'wp_get_custom_css' ) ) {
79 + $configuration_link = Jetpack_Custom_CSS_Enhancements::customizer_link(
80 + array(
81 + 'return_url' => wp_get_referer(),
82 + )
55 83 );
84 + } else {
85 + $configuration_link = admin_url( 'themes.php?page=editcss#settingsdiv' );
56 86 }
87 +
88 + wp_safe_redirect( $configuration_link );
89 + exit;
57 90 }
58 91
59 -// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
60 -if ( ! apply_filters( 'jetpack_module_configurable_custom-css', null ) ) {
61 - add_action( 'jetpack_modules_loaded', 'custom_css_loaded' );
62 -
63 - jetpack_load_custom_css();
64 -}
92 +jetpack_load_custom_css();