PluginProbe
Polylang / 2.0
Polylang v2.0
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | include/pointer.php +25 -31 2.82.0 View file →
@@ -1,36 +1,32 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 - * A class to manage WP pointers
4 + * a class to manage WP pointers
8 5 * offers the possibility to have customized buttons
9 6 *
10 7 * @since 1.7.7
11 - * @deprecated 2.3.9
12 8 */
13 9 class PLL_Pointer {
14 10 protected $args;
15 11
16 12 /**
17 - * Constructor
13 + * constructor
18 14 * enqueues the pointer script
19 15 *
20 - * List of parameters accepted in $args:
16 + * list of parameters accepted in $args:
21 17 *
22 - * pointer => required, unique identifier of the pointer
23 - * id => required, the pointer will be attached to this html id
24 - * position => optional array, if used both sub parameters are required
25 - * edge => 'top' or 'bottom'
26 - * align => 'right' or 'left'
27 - * width => optional, the width in px
28 - * title => required, title
29 - * content => required, content
30 - * buttons => optional array of arrays, by default the pointer uses the standard dismiss button offered by WP
31 - * label => the label of the button
32 - * link => optional link for the button. By default, the button just dismisses the pointer
18 + * pointer => required, unique identifier of the pointer
19 + * id => required, the pointer will be attached to this html id
20 + * position => optional array, if used both sub parameters are required
21 + * edge => 'top' or 'bottom'
22 + * align => 'right' or 'left'
23 + * width => optional, the width in px
24 + * title => required, title
25 + * content => required, content
26 + * buttons => optional array of arrays, by default the pointer uses the standard dismiss button offered by WP
27 + * label => the label of the button
28 + * link => optional link for the button. By default, the button just dismisses the pointer
33 29 *
34 30 * @since 1.7.7
35 31 *
36 32 * @param array $args
@@ -35,16 +31,14 @@
35 31 *
36 32 * @param array $args
37 33 */
38 34 public function __construct( $args ) {
39 - trigger_error( 'The class PLL_Pointer has been deprecated since Polylang 2.3.9 and will be removed in a future version.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions
40 -
41 35 $this->args = $args;
42 36 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
43 37 }
44 38
45 39 /**
46 - * Enqueue javascripts and styles if the pointer has not been dismissed
40 + * enqueue javascripts and styles if the pointer has not been dismissed
47 41 *
48 42 * @since 1.7.7
49 43 */
50 44 public function enqueue_scripts() {
@@ -60,15 +54,15 @@
60 54 wp_enqueue_script( 'wp-pointer' );
61 55 }
62 56
63 57 /**
64 - * Adds the javascript of our pointer to the page
58 + * adds the javascript of our pointer to the page
65 59 *
66 60 * @since 1.7.7
67 61 */
68 62 public function print_js() {
69 63
70 - // Add optional buttons
64 + // add optional buttons
71 65 if ( ! empty( $this->args['buttons'] ) ) {
72 66 $b = "
73 67 var widget = pointer.pointer( 'widget' );
74 68 var buttons = $( '.wp-pointer-buttons', widget );
@@ -73,12 +67,12 @@
73 67 var widget = pointer.pointer( 'widget' );
74 68 var buttons = $( '.wp-pointer-buttons', widget );
75 69 $( 'a.close', widget ).remove();"; // removes the WP button
76 70
77 - // All the buttons use the standard WP ajax action to remember the pointer has been dismissed
71 + // all the buttons use the standard WP ajax action to remember the pointer has been dismissed
78 72 foreach ( $this->args['buttons'] as $button ) {
79 - $b .= sprintf(
80 - "$( '<a>' ).addClass( '%s' ).html( '%s' ).css( 'margin-left', '10px' ).click( function() {
73 + $b .= sprintf( "
74 + $( '<a>' ).addClass( '%s' ).html( '%s' ).css( 'margin-left', '10px' ).click( function() {
81 75 $.post( ajaxurl, {
82 76 pointer: '%s',
83 77 action: 'dismiss-wp-pointer'
84 78 }, function( response ) {
@@ -85,9 +79,9 @@
85 79 %s
86 80 } );
87 81 } ).appendTo( buttons );",
88 82 empty( $button['link'] ) ? 'button' : 'button button-primary',
89 - esc_html( $button['label'] ),
83 + $button['label'],
90 84 $this->args['pointer'],
91 85 empty( $button['link'] ) ? "pointer.pointer( 'close' )" : sprintf( "location.href = '%s'", $button['link'] )
92 86 );
93 87 }
@@ -92,10 +86,10 @@
92 86 );
93 87 }
94 88 }
95 89
96 - $js = sprintf(
97 - "//<![CDATA[
90 + $js = sprintf( "
91 + //<![CDATA[
98 92 jQuery( document ).ready( function( $ ) {
99 93 var pointer = $( '#%s' ).pointer( {
100 94 content: '%s',
101 95 %s
@@ -105,12 +99,12 @@
105 99 %s
106 100 } );
107 101 // ]]>",
108 102 $this->args['id'],
109 - sprintf( '<h3>%s</h3><p>%s</p>', esc_html( $this->args['title'] ), esc_html( $this->args['content'] ) ),
103 + sprintf( '<h3>%s</h3><p>%s</p>', $this->args['title'], $this->args['content'] ),
110 104 empty( $this->args['position'] ) ? '' : sprintf( 'position: {edge: "%s", align: "%s",},', $this->args['position']['edge'], $this->args['position']['align'] ),
111 105 empty( $this->args['width'] ) ? '' : sprintf( 'pointerWidth: %d,', $this->args['width'] ),
112 106 empty( $b ) ? '' : $b
113 107 );
114 - echo '<script type="text/javascript">' . $js . '</script>'; // phpcs:ignore WordPress.Security.EscapeOutput
108 + echo "<script type='text/javascript'>" .$js. "</script>";
115 109 }
116 110 }