build_connect_url( true, false, sprintf( 'connect-banner-%s-%s', $jp_version_banner_added, $current_screen->base ) ); // Add a tracks event corresponding to the A/B version displayed $ab_test = Jetpack_Options::get_option( 'ab_connect_banner_green_bar' ); if ( in_array( $ab_test, array( 'a', 'b' ), true ) ) { $url = add_query_arg( 'ab_connect_banner_green_bar', $ab_test, $url ); } return add_query_arg( 'auth_approved', 'true', $url ); } /** * Will initialize hooks to display the new (as of 4.4) connection banner if the current user can * connect Jetpack, if Jetpack has not been deactivated, and if the current page is the plugins page. * * This method should not be called if the site is connected to WordPress.com or if the site is in development mode. * * @since 4.4.0 * @since 4.5.0 Made the new (as of 4.4) connection banner display to everyone by default. * @since 5.3.0 Running another split test between 4.4 banner and a new one in 5.3. * @since 7.2 B test was removed. * * @param $current_screen */ function maybe_initialize_hooks( $current_screen ) { // Kill if banner has been dismissed if ( Jetpack_Options::get_option( 'dismissed_connection_banner' ) ) { return; } // Don't show the connect notice anywhere but the plugins.php after activating if ( 'plugins' !== $current_screen->base && 'dashboard' !== $current_screen->base ) { return; } if ( ! current_user_can( 'jetpack_connect' ) ) { return; } add_action( 'admin_notices', array( $this, 'render_banner' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_banner_scripts' ) ); add_action( 'admin_print_styles', array( Jetpack::init(), 'admin_banner_styles' ) ); if ( Jetpack::state( 'network_nag' ) ) { add_action( 'network_admin_notices', array( $this, 'network_connect_notice' ) ); } // Only fires immediately after plugin activation if ( get_transient( 'activated_jetpack' ) ) { add_action( 'admin_notices', array( $this, 'render_connect_prompt_full_screen' ) ); delete_transient( 'activated_jetpack' ); } } /** * Enqueues JavaScript for new connection banner. * * @since 4.4.0 */ public static function enqueue_banner_scripts() { wp_enqueue_script( 'jetpack-connection-banner-js', Assets::get_file_url_for_environment( '_inc/build/jetpack-connection-banner.min.js', '_inc/jetpack-connection-banner.js' ), array( 'jquery' ), JETPACK__VERSION, true ); wp_localize_script( 'jetpack-connection-banner-js', 'jp_banner', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'connectionBannerNonce' => wp_create_nonce( 'jp-connection-banner-nonce' ), ) ); } /** * Enqueues JavaScript and CSS for new connect-in-place flow. * * @since 7.7 */ public static function enqueue_connect_button_scripts() { global $is_safari; wp_enqueue_script( 'jetpack-connect-button', Assets::get_file_url_for_environment( '_inc/build/connect-button.min.js', '_inc/connect-button.js' ), array( 'jquery' ), JETPACK__VERSION, true ); wp_enqueue_style( 'jetpack-connect-button', Assets::get_file_url_for_environment( 'css/jetpack-connect.min.css', 'css/jetpack-connect.css' ) ); $jetpackApiUrl = wp_parse_url( Jetpack::connection()->api_url( '' ) ); // Due to the limitation in how 3rd party cookies are handled in Safari, // we're falling back to the original flow on Safari desktop and mobile. if ( $is_safari ) { $force_variation = 'original'; } elseif ( Constants::is_true( 'JETPACK_SHOULD_USE_CONNECTION_IFRAME' ) ) { $force_variation = 'in_place'; } elseif ( Constants::is_defined( 'JETPACK_SHOULD_USE_CONNECTION_IFRAME' ) ) { $force_variation = 'original'; } else { $force_variation = null; } $tracking = new Automattic\Jetpack\Tracking(); $identity = $tracking->tracks_get_identity( get_current_user_id() ); wp_localize_script( 'jetpack-connect-button', 'jpConnect', array( 'apiBaseUrl' => esc_url_raw( rest_url( 'jetpack/v4' ) ), 'registrationNonce' => wp_create_nonce( 'jetpack-registration-nonce' ), 'apiNonce' => wp_create_nonce( 'wp_rest' ), 'apiSiteDataNonce' => wp_create_nonce( 'wp_rest' ), 'buttonTextRegistering' => __( 'Loading...', 'jetpack' ), 'jetpackApiDomain' => $jetpackApiUrl['scheme'] . '://' . $jetpackApiUrl['host'], 'forceVariation' => $force_variation, 'connectInPlaceUrl' => Jetpack::admin_url( 'page=jetpack#/setup' ), 'dashboardUrl' => Jetpack::admin_url( 'page=jetpack#/dashboard' ), 'plansPromptUrl' => Jetpack::admin_url( 'page=jetpack#/plans-prompt' ), 'identity' => $identity, 'preFetchScript' => plugins_url( '_inc/build/admin.js', JETPACK__PLUGIN_FILE ) . '?ver=' . JETPACK__VERSION, ) ); } /** * Performs an A/B test showing or hiding the green bar at the top of the connection dialog displayed in Dashboard or Plugins. * We save which version we're showing so we always show the same to the same user. * The "A" version displays the green bar at the top. * The "B" version doesn't display it. * * @return void */ function get_ab_banner_top_bar() { $ab_test = Jetpack_Options::get_option( 'ab_connect_banner_green_bar' ); // If it doesn't exist yet, generate it for later use and save it, so we always show the same to this user if ( ! $ab_test ) { $ab_test = 1 === rand( 1, 2 ) ? 'a' : 'b'; Jetpack_Options::update_option( 'ab_connect_banner_green_bar', $ab_test ); } if ( 'a' === $ab_test ) { ?>
get_ab_banner_top_bar(); ?>
base ) { $bottom_connect_url_from = 'full-screen-prompt'; } else { $bottom_connect_url_from = 'landing-page-bottom'; } ?>
base ) : ?> render(); ?> base ) : ?>

Jetpack is activated! Each site on your network must be connected individually by an admin on that site.', 'jetpack' ), array( 'strong' => array() ) ); ?>