jetpack
Last commit date
3rd-party
3 years ago
_inc
3 years ago
css
3 years ago
extensions
3 years ago
images
3 years ago
jetpack_vendor
14 hours ago
json-endpoints
3 years ago
modules
1 year ago
sal
3 years ago
src
3 years ago
vendor
3 years ago
views
3 years ago
CHANGELOG.md
3 years ago
LICENSE.txt
5 years ago
SECURITY.md
5 years ago
class-jetpack-connection-status.php
5 years ago
class-jetpack-connection-widget.php
3 years ago
class-jetpack-gallery-settings.php
3 years ago
class-jetpack-pre-connection-jitms.php
4 years ago
class-jetpack-recommendations-banner.php
3 years ago
class-jetpack-stats-dashboard-widget.php
3 years ago
class-jetpack-wizard-banner.php
5 years ago
class-jetpack-xmlrpc-methods.php
3 years ago
class.frame-nonce-preview.php
4 years ago
class.jetpack-admin.php
3 years ago
class.jetpack-affiliate.php
4 years ago
class.jetpack-autoupdate.php
3 years ago
class.jetpack-bbpress-json-api.compat.php
5 years ago
class.jetpack-cli.php
3 years ago
class.jetpack-client-server.php
4 years ago
class.jetpack-connection-banner.php
3 years ago
class.jetpack-data.php
5 years ago
class.jetpack-gutenberg.php
3 years ago
class.jetpack-heartbeat.php
4 years ago
class.jetpack-idc.php
5 years ago
class.jetpack-modules-list-table.php
3 years ago
class.jetpack-network-sites-list-table.php
4 years ago
class.jetpack-network.php
3 years ago
class.jetpack-plan.php
3 years ago
class.jetpack-post-images.php
3 years ago
class.jetpack-twitter-cards.php
3 years ago
class.jetpack-user-agent.php
3 years ago
class.jetpack.php
3 years ago
class.json-api-endpoints.php
3 years ago
class.json-api.php
3 years ago
class.photon.php
3 years ago
composer.json
3 years ago
enhanced-open-graph.php
3 years ago
functions.compat.php
4 years ago
functions.cookies.php
5 years ago
functions.global.php
3 years ago
functions.is-mobile.php
3 years ago
functions.opengraph.php
3 years ago
functions.photon.php
3 years ago
jetpack.php
14 hours ago
json-api-config.php
3 years ago
json-endpoints.php
3 years ago
load-jetpack.php
3 years ago
locales.php
4 years ago
readme.txt
14 hours ago
uninstall.php
5 years ago
wpml-config.xml
4 years ago
class-jetpack-connection-widget.php
123 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | |
| 3 | use Automattic\Jetpack\Assets; |
| 4 | use Automattic\Jetpack\Assets\Logo; |
| 5 | |
| 6 | /** |
| 7 | * Jetpack connection dashboard widget. |
| 8 | * |
| 9 | * @package automattic/jetpack |
| 10 | */ |
| 11 | class Jetpack_Connection_Widget { |
| 12 | /** |
| 13 | * Static instance |
| 14 | * |
| 15 | * @var Jetpack_Connection_Widget |
| 16 | */ |
| 17 | private static $instance = null; |
| 18 | |
| 19 | /** |
| 20 | * Intiialize the class by calling the setup static function. |
| 21 | * |
| 22 | * @return Jetpack_Connection_Widget |
| 23 | */ |
| 24 | public static function init() { |
| 25 | if ( self::$instance === null ) { |
| 26 | self::$instance = new Jetpack_Connection_Widget(); |
| 27 | } |
| 28 | |
| 29 | return self::$instance; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Jetpack_Connection_Widget constructor. |
| 34 | */ |
| 35 | public function __construct() { |
| 36 | add_action( 'current_screen', array( $this, 'maybe_initialize_hooks' ) ); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Will initialize hooks to display the new connection widget. |
| 41 | */ |
| 42 | public function maybe_initialize_hooks() { |
| 43 | add_action( 'admin_print_styles', array( $this, 'admin_banner_styles' ) ); |
| 44 | add_action( 'wp_dashboard_setup', array( $this, 'wp_dashboard_setup' ) ); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Sets up the Jetpack Connection Widget in the WordPress admin dashboard. |
| 49 | */ |
| 50 | public function wp_dashboard_setup() { |
| 51 | if ( Jetpack_Options::get_option( 'dismissed_connection_banner' ) && |
| 52 | ! Jetpack::is_connection_ready() ) { |
| 53 | $widget_title = sprintf( |
| 54 | __( 'Jetpack - Security, Backup, Speed & Growth', 'jetpack' ) |
| 55 | ); |
| 56 | |
| 57 | wp_add_dashboard_widget( |
| 58 | 'jetpack_connection_widget', |
| 59 | $widget_title, |
| 60 | array( __CLASS__, 'connection_widget' ) |
| 61 | ); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Included the needed styles |
| 67 | */ |
| 68 | public function admin_banner_styles() { |
| 69 | wp_enqueue_style( |
| 70 | 'jetpack-connection-widget', |
| 71 | Assets::get_file_url_for_environment( |
| 72 | 'css/jetpack-connection-widget.min.css', |
| 73 | 'css/jetpack-connection-widget.css' |
| 74 | ), |
| 75 | array(), |
| 76 | JETPACK__VERSION |
| 77 | ); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Builds the connection url for the widget. |
| 82 | * |
| 83 | * @return string |
| 84 | */ |
| 85 | public static function build_connect_url() { |
| 86 | $url = Jetpack::init()->build_connect_url( |
| 87 | true, |
| 88 | false, |
| 89 | 'unconnected-site-widget' |
| 90 | ); |
| 91 | |
| 92 | return add_query_arg( 'auth_approved', 'true', $url ); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Load the widget |
| 97 | */ |
| 98 | public static function connection_widget() { |
| 99 | $connect_url = self::build_connect_url(); |
| 100 | $jetpack_logo = new Logo(); |
| 101 | ?> |
| 102 | <div class="jp-connection-widget"> |
| 103 | <div class="jp-connection-widget__logo"> |
| 104 | <?php echo $jetpack_logo->get_jp_emblem_larger(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 105 | </div> |
| 106 | <img |
| 107 | class="jp-connection-widget__image" |
| 108 | src="<?php echo esc_url( plugins_url( 'images/dashboard-connection-widget-hero.png', JETPACK__PLUGIN_FILE ) ); ?>" /> |
| 109 | <p class="jp-connection-widget__heading"><?php esc_html_e( 'Finish setting up your site', 'jetpack' ); ?></p> |
| 110 | <p class="jp-connection-widget__paragraph"> |
| 111 | <?php esc_html_e( 'Complete your setup to take advantage of security and performance features already installed by Jetpack.', 'jetpack' ); ?> |
| 112 | </p> |
| 113 | <p class="jp-connection-widget__tos-blurb"> |
| 114 | <?php jetpack_render_tos_blurb(); ?> |
| 115 | </p> |
| 116 | <p class="jp-connection_widget__button-container"> |
| 117 | <a class="jp-connection-widget__button" href="<?php echo esc_url( $connect_url ); ?>"><?php esc_html_e( 'Set up Jetpack for free', 'jetpack' ); ?></a> |
| 118 | </p> |
| 119 | </div> |
| 120 | <?php |
| 121 | } |
| 122 | } |
| 123 |