bootstrap.php 0000644 00000003327 15073233517 0007305 0 ustar 00 get_site_suffix();
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
require_once __DIR__ . '/additional-css/class-wpcom-additional-css-manager.php';
$manager = new WPCOM_Additional_CSS_Manager( $domain );
} elseif ( ( new Host() )->is_woa_site() ) {
require_once __DIR__ . '/additional-css/class-atomic-additional-css-manager.php';
$manager = new Atomic_Additional_CSS_Manager( $domain );
}
if ( ! isset( $manager ) ) {
return;
}
$manager->register_nudge( $customize_manager );
}
/**
* Load the bootstrap on init action.
*
* We need to load on init because otherwise the filter will not be set to true in WPCOM (since the add_filter is set on init).
*/
function load_bootstrap_on_init() {
/**
* Disable Additional CSS section from Customizer in WPCOM and Atomic and replace it with a nudge.
*
* @module masterbar
*
* @since 9.9.0
*
* @param bool
*/
if ( \apply_filters( 'jetpack_customize_enable_additional_css_nudge', false ) ) {
\add_action( 'customize_register', __NAMESPACE__ . '\register_css_nudge_control' );
}
}
add_action( 'init', __NAMESPACE__ . '\load_bootstrap_on_init' );
additional-css/css/additional-css.css 0000644 00000000406 15073233517 0013650 0 ustar 00 .customize-control-cssNudge .nudge-container {
width: 100%;
padding: 50px 0;
}
.customize-control-cssNudge .nudge-container p {
text-align: center;
}
.customize-control-cssNudge .nudge-container .button-container {
margin-top: 20px;
text-align: center;
}
additional-css/js/additional-css.js 0000644 00000002267 15073233517 0013327 0 ustar 00 ( function ( $ ) {
'use strict';
var cssNudge = {
init: function () {
this.clickifyNavigateToButtons();
},
clickifyNavigateToButtons: function () {
var navButton = document.querySelector( '.navigate-to' );
if ( ! navButton ) {
return;
}
navButton.addEventListener( 'click', function () {
// Get destination.
var destination = this.getAttribute( 'data-navigate-to-page' );
if ( ! destination ) {
return;
}
// Fire Tracks click event.
window._tkq = window._tkq || [];
window._tkq.push( [
'recordEvent',
'calypso_upgrade_nudge_cta_click',
{
cta_name: 'customizer_css',
},
] );
// Navigate to a different page.
if (
window.location.search.match( /calypso=true/ ) &&
window.parent.location !== window.location
) {
// Calypso.
window.top.postMessage(
JSON.stringify( {
calypso: true,
command: 'navigateTo',
destination: destination,
} ),
'*'
);
} else {
// Non-Calypso.
window.location = 'https://wordpress.com' + destination;
}
} );
},
};
$( document ).ready( function () {
cssNudge.init();
} );
} )( jQuery );
additional-css/class-css-nudge-customize-control.php 0000644 00000002204 15073233517 0016650 0 ustar 00 cta_url;
$nudge_copy = $this->nudge_copy;
$nudge_button_copy = __( 'Upgrade Now', 'jetpack' );
echo '
' . wp_kses( $nudge_copy, array( 'br' => array() ) ) . '
';
}
}
additional-css/class-atomic-additional-css-manager.php 0000644 00000003446 15073233517 0017053 0 ustar 00 domain = $domain;
}
/**
* Replace the Additional CSS section from Customiz¡er with an upgrade nudge.
*
* @param \WP_Customize_Manager $wp_customize_manager Core customize manager.
*/
public function register_nudge( \WP_Customize_Manager $wp_customize_manager ) {
$nudge_url = $this->get_nudge_url();
$nudge_text = __( 'Purchase a Business Plan to
activate CSS customization', 'jetpack' );
if (
( defined( 'ENABLE_PRO_PLAN' ) && ENABLE_PRO_PLAN ) ||
! empty( $_GET['enable_pro_plan'] ) || // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only used to customize output.
! empty( $_COOKIE['enable_pro_plan'] )
) {
$nudge_text = __( 'Purchase a Pro Plan to
activate CSS customization', 'jetpack' );
$nudge_url = preg_replace( '/premium$/', 'pro', $nudge_url );
}
$nudge = new CSS_Customizer_Nudge(
$nudge_url,
$nudge_text
);
$wp_customize_manager->remove_control( 'custom_css' );
$wp_customize_manager->remove_section( 'custom_css' );
$nudge->customize_register_nudge( $wp_customize_manager );
}
/**
* Get the Nudge URL.
*
* @return string
*/
private function get_nudge_url() {
return '/checkout/' . $this->domain . '/business';
}
}
additional-css/class-css-customizer-nudge.php 0000644 00000006144 15073233517 0015363 0 ustar 00 cta_url = $cta_url;
$this->nudge_copy = $nudge_copy;
$this->control_name = $control_name;
}
/**
* Register the assets required for the CSS nudge page from the Customizer.
*/
public function customize_controls_enqueue_scripts_nudge() {
\wp_enqueue_script(
'additional-css-js',
plugins_url( 'js/additional-css.js', __FILE__ ),
array(),
JETPACK__VERSION,
true
);
\wp_enqueue_style(
'additional-css',
plugins_url( 'css/additional-css.css', __FILE__ ),
array(),
JETPACK__VERSION
);
}
/**
* Register the CSS nudge in the Customizer.
*
* @param \WP_Customize_Manager $wp_customize The customize manager.
*/
public function customize_register_nudge( \WP_Customize_Manager $wp_customize ) {
// Show a nudge in place of the normal CSS section.
\add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_controls_enqueue_scripts_nudge' ) );
$wp_customize->add_setting(
$this->control_name . '[dummy_setting]',
array(
'type' => $this->control_name . '_dummy_setting',
'default' => '',
'transport' => 'refresh',
)
);
$wp_customize->add_section( $this->create_css_nudge_section( $wp_customize ) );
$wp_customize->add_control( $this->create_css_nudge_control( $wp_customize ) );
}
/**
* Create a nudge control object.
*
* @param \WP_Customize_Manager $wp_customize The Core Customize Manager.
*
* @return CSS_Nudge_Customize_Control
*/
public function create_css_nudge_control( \WP_Customize_Manager $wp_customize ) {
return new CSS_Nudge_Customize_Control(
$wp_customize,
$this->control_name . '_control',
array(
'cta_url' => $this->cta_url,
'nudge_copy' => $this->nudge_copy,
'label' => __( 'Custom CSS', 'jetpack' ),
'section' => $this->control_name,
'settings' => $this->control_name . '[dummy_setting]',
)
);
}
/**
* Create the nudge section.
*
* @param \WP_Customize_Manager $wp_customize The core Customize Manager.
*
* @return \WP_Customize_Section
*/
public function create_css_nudge_section( \WP_Customize_Manager $wp_customize ) {
return new \WP_Customize_Section(
$wp_customize,
$this->control_name,
array(
'title' => __( 'Additional CSS', 'jetpack' ),
'priority' => 200,
)
);
}
}
additional-css/class-wpcom-additional-css-manager.php 0000644 00000003224 15073233517 0016716 0 ustar 00 domain = $domain;
}
/**
* Register the Additional CSS nudge.
*
* @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 Premium Plan to
activate CSS customization', 'jetpack' );
if (
( defined( 'ENABLE_PRO_PLAN' ) && ENABLE_PRO_PLAN ) ||
! empty( $_GET['enable_pro_plan'] ) || // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only used to customize output.
! empty( $_COOKIE['enable_pro_plan'] )
) {
$nudge_text = __( 'Purchase a Pro Plan to
activate CSS customization', 'jetpack' );
$nudge_url = preg_replace( '/premium$/', 'pro', $nudge_url );
}
$nudge = new CSS_Customizer_Nudge(
$nudge_url,
$nudge_text,
'jetpack_custom_css'
);
$nudge->customize_register_nudge( $wp_customize_manager );
}
/**
* Get the nudge URL in WPCOM.
*
* @return string
*/
private function get_nudge_url() {
return '/checkout/' . $this->domain . '/premium';
}
}