diff options
Diffstat (limited to 'plugins/jetpack/modules/custom-css.php')
-rw-r--r-- | plugins/jetpack/modules/custom-css.php | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/plugins/jetpack/modules/custom-css.php b/plugins/jetpack/modules/custom-css.php index fba7b470..ede1f529 100644 --- a/plugins/jetpack/modules/custom-css.php +++ b/plugins/jetpack/modules/custom-css.php @@ -13,7 +13,35 @@ */ function jetpack_load_custom_css() { - include dirname( __FILE__ ) . "/custom-css/custom-css.php"; + // If WordPress has the core version of Custom CSS, load our new version. + // @see https://core.trac.wordpress.org/changeset/38829 + if ( function_exists( 'wp_get_custom_css' ) ) { + if ( ! function_exists( 'wp_update_custom_css_post' ) ) { + 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 { + 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' ); + } + } + // 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'; + return; + } + + include_once dirname( __FILE__ ) . "/custom-css/custom-css.php"; + add_action( 'init', array( 'Jetpack_Custom_CSS', 'init' ) ); } add_action( 'jetpack_modules_loaded', 'custom_css_loaded' ); |