PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 9.7
Jetpack – WP Security, Backup, Speed, & Growth v9.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 / modules / masterbar / inline-help / class-inline-help.php

class-inline-help.php in Jetpack – WP Security, Backup, Speed, & Growth 9.7, at modules/masterbar/inline-help/class-inline-help.php

113 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Inline Help.
4 *
5 * Handles providing a LiveChat icon within WPAdmin until such time
6 * as the full live chat experience can be run in a non-Calypso environment.
7 *
8 * @package automattic/jetpack
9 */
10
11 namespace Automattic\Jetpack\Dashboard_Customizations;
12
13 /**
14 * Class Inline_Help.
15 */
16 class Inline_Help {
17
18 /**
19 * Inline_Help constructor.
20 */
21 public function __construct() {
22 $this->register_actions();
23 }
24
25 /**
26 * Registers actions.
27 *
28 * @return void
29 */
30 public function register_actions() {
31 // phpcs:disable WordPress.Security.NonceVerification.Recommended
32 // Do not inject the FAB icon on embedded screens since the parent window may already contain a FAB icon.
33 $is_framed = ! empty( $_GET['frame-nonce'] );
34
35 if ( $is_framed ) {
36 return;
37 }
38 // phpcs:enable WordPress.Security.NonceVerification.Recommended
39
40 add_action( 'admin_footer', array( $this, 'add_fab_icon' ) );
41
42 add_action( 'admin_enqueue_scripts', array( $this, 'add_fab_styles' ) );
43 }
44
45 /**
46 * Outputs "FAB" icon markup and SVG.
47 *
48 * @return void|string the HTML markup for the FAB or early exit.
49 */
50 public function add_fab_icon() {
51
52 if ( wp_doing_ajax() ) {
53 return;
54 }
55
56 $svg_allowed = array(
57 'svg' => array(
58 'id' => true,
59 'class' => true,
60 'aria-hidden' => true,
61 'aria-labelledby' => true,
62 'role' => true,
63 'xmlns' => true,
64 'width' => true,
65 'height' => true,
66 'viewbox' => true, // <= Must be lower case!
67 ),
68 'g' => array( 'fill' => true ),
69 'title' => array( 'title' => true ),
70 'path' => array(
71 'd' => true,
72 'fill' => true,
73 ),
74 );
75
76 $gridicon_help = file_get_contents( __DIR__ . '/gridicon-help.svg', true );
77
78 // Add tracking data to link to be picked up by Calypso for GA and Tracks usage.
79 $tracking_href = add_query_arg(
80 array(
81 'utm_source' => 'wp_admin',
82 'utm_medium' => 'other',
83 'utm_content' => 'jetpack_masterbar_inline_help_click',
84 'flags' => 'a8c-analytics.on',
85 ),
86 'https://wordpress.com/help'
87 );
88
89 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
90 // We trust that output in the template has been escaped.
91 echo load_template(
92 __DIR__ . '/inline-help-template.php',
93 true,
94 array(
95 'href' => $tracking_href,
96 'icon' => $gridicon_help,
97 'svg_allowed' => $svg_allowed,
98 )
99 );
100 // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
101
102 }
103
104 /**
105 * Enqueues FAB CSS styles.
106 *
107 * @return void
108 */
109 public function add_fab_styles() {
110 wp_enqueue_style( 'a8c-faux-inline-help', plugins_url( 'inline-help.css', __FILE__ ), array(), JETPACK__VERSION );
111 }
112 }
113