PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 12.7
Jetpack – WP Security, Backup, Speed, & Growth v12.7
16.2-beta 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 All 501 releases
jetpack / class-jetpack-connection-widget.php

class-jetpack-connection-widget.php in Jetpack – WP Security, Backup, Speed, & Growth 12.7, at class-jetpack-connection-widget.php

123 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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