@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
3 | - 'version' => '1f8e7cc44e689914940a92a7164b031f', |
|
2 | + 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
3 | + 'version' => '1f8e7cc44e689914940a92a7164b031f', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
2 | + 'dependencies' => array('react', 'react-dom', 'wp-polyfill'), |
|
3 | 3 | 'version' => '1f8e7cc44e689914940a92a7164b031f', |
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
3 | - 'version' => '92f4604d2cfa21a6aba382c15928b02c', |
|
2 | + 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
3 | + 'version' => '92f4604d2cfa21a6aba382c15928b02c', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
2 | + 'dependencies' => array('react', 'react-dom', 'wp-polyfill'), |
|
3 | 3 | 'version' => '92f4604d2cfa21a6aba382c15928b02c', |
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'wp-polyfill', 'wp-rich-text' ), |
|
3 | - 'version' => '18770cde607d785a81b65ef98e409669', |
|
2 | + 'dependencies' => array( 'wp-polyfill', 'wp-rich-text' ), |
|
3 | + 'version' => '18770cde607d785a81b65ef98e409669', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'wp-polyfill', 'wp-rich-text' ), |
|
2 | + 'dependencies' => array('wp-polyfill', 'wp-rich-text'), |
|
3 | 3 | 'version' => '18770cde607d785a81b65ef98e409669', |
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-hooks', 'wp-polyfill' ), |
|
3 | - 'version' => '422a9f1d32f6983d4bb7c971a14c8225', |
|
2 | + 'dependencies' => array( 'react', 'react-dom', 'wp-hooks', 'wp-polyfill' ), |
|
3 | + 'version' => '422a9f1d32f6983d4bb7c971a14c8225', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-hooks', 'wp-polyfill' ), |
|
2 | + 'dependencies' => array('react', 'react-dom', 'wp-hooks', 'wp-polyfill'), |
|
3 | 3 | 'version' => '422a9f1d32f6983d4bb7c971a14c8225', |
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-hooks', 'wp-i18n', 'wp-polyfill' ), |
|
3 | - 'version' => 'e8856addb978d2ab9bef838754938ce8', |
|
2 | + 'dependencies' => array( 'react', 'react-dom', 'wp-hooks', 'wp-i18n', 'wp-polyfill' ), |
|
3 | + 'version' => 'e8856addb978d2ab9bef838754938ce8', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-hooks', 'wp-i18n', 'wp-polyfill' ), |
|
2 | + 'dependencies' => array('react', 'react-dom', 'wp-hooks', 'wp-i18n', 'wp-polyfill'), |
|
3 | 3 | 'version' => 'e8856addb978d2ab9bef838754938ce8', |
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
3 | - 'version' => '0df9b7715acd39056c8ca1e24dedb4b1', |
|
2 | + 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
3 | + 'version' => '0df9b7715acd39056c8ca1e24dedb4b1', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'react', 'react-dom', 'wp-polyfill' ), |
|
2 | + 'dependencies' => array('react', 'react-dom', 'wp-polyfill'), |
|
3 | 3 | 'version' => '0df9b7715acd39056c8ca1e24dedb4b1', |
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'wp-polyfill' ), |
|
3 | - 'version' => 'dc74b50aef496ca5fcca1eda880e38a1', |
|
2 | + 'dependencies' => array( 'wp-polyfill' ), |
|
3 | + 'version' => 'dc74b50aef496ca5fcca1eda880e38a1', |
|
4 | 4 | ); |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php return array( |
2 | - 'dependencies' => array( 'wp-polyfill' ), |
|
2 | + 'dependencies' => array('wp-polyfill'), |
|
3 | 3 | 'version' => 'dc74b50aef496ca5fcca1eda880e38a1', |
4 | 4 | ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Wordlift/includes |
11 | 11 | */ |
12 | 12 | if ( ! class_exists( 'Walker_Category_Checklist' ) ) { |
13 | - require_once ABSPATH . 'wp-admin/includes/template.php'; |
|
13 | + require_once ABSPATH . 'wp-admin/includes/template.php'; |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
@@ -24,113 +24,113 @@ discard block |
||
24 | 24 | // phpcs:ignore Generic.Classes.DuplicateClassName.Found |
25 | 25 | class Wordlift_Entity_Types_Taxonomy_Walker extends Walker_Category_Checklist { |
26 | 26 | |
27 | - /** |
|
28 | - * Entity taxonomy metabox must show exclusive options, no checkboxes. |
|
29 | - * |
|
30 | - * @since 3.1.0 |
|
31 | - * |
|
32 | - * @param $args { |
|
33 | - * An array of arguments. |
|
34 | - * |
|
35 | - * @type string $taxonomy The taxonomy name. |
|
36 | - * } |
|
37 | - * |
|
38 | - * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy. |
|
39 | - */ |
|
40 | - public function terms_checklist_args( $args ) { |
|
41 | - |
|
42 | - if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
43 | - return $args; |
|
44 | - } |
|
45 | - |
|
46 | - // We override the way WP prints the taxonomy metabox HTML. |
|
47 | - $args['walker'] = $this; |
|
48 | - $args['checked_ontop'] = false; |
|
49 | - |
|
50 | - return $args; |
|
51 | - |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Change checkboxes to radios. |
|
56 | - * |
|
57 | - * $max_depth = -1 means flatly display every element. |
|
58 | - * $max_depth = 0 means display all levels. |
|
59 | - * $max_depth > 0 specifies the number of display levels. |
|
60 | - * |
|
61 | - * @since 3.1.0 |
|
62 | - * |
|
63 | - * @param array $elements An array of elements. |
|
64 | - * @param int $max_depth The maximum hierarchical depth. |
|
65 | - * |
|
66 | - * @param array $args Additional arguments. |
|
67 | - * |
|
68 | - * @return string The hierarchical item output. |
|
69 | - */ |
|
70 | - public function walk( $elements, $max_depth, $args = array() ) { |
|
71 | - |
|
72 | - // `max_depth` force to -1 to display a flat taxonomy. |
|
73 | - // |
|
74 | - // See https://github.com/insideout10/wordlift-plugin/issues/305 |
|
75 | - $output = parent::walk( $elements, - 1, $args ); |
|
76 | - |
|
77 | - $output = str_replace( |
|
78 | - array( 'type="checkbox"', "type='checkbox'" ), |
|
79 | - array( 'type="radio"', "type='radio'" ), |
|
80 | - $output |
|
81 | - ); |
|
82 | - |
|
83 | - return $output; |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Start the element output, output nothing in case of article term. |
|
88 | - * |
|
89 | - * @since 3.15.0 |
|
90 | - * |
|
91 | - * @param string $output Passed by reference. Used to append additional content. |
|
92 | - * @param object $category The current term object. |
|
93 | - * @param int $depth Depth of the term in reference to parents. Default 0. |
|
94 | - * @param array $args An array of arguments. @see wp_terms_checklist() |
|
95 | - * @param int $id ID of the current term. |
|
96 | - */ |
|
97 | - public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
|
98 | - global $post; |
|
99 | - |
|
100 | - if ( ! isset( $post ) ) { |
|
101 | - return; |
|
102 | - } |
|
103 | - |
|
104 | - if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
105 | - || 'article' !== $category->slug |
|
106 | - || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
107 | - parent::start_el( $output, $category, $depth, $args, $id ); |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * End the element output, output nothing in case of article term. |
|
113 | - * |
|
114 | - * @since 3.15.0 |
|
115 | - * |
|
116 | - * @param string $output Passed by reference. Used to append additional content. |
|
117 | - * @param object $category The current term object. |
|
118 | - * @param int $depth Depth of the term in reference to parents. Default 0. |
|
119 | - * @param array $args An array of arguments. @see wp_terms_checklist() |
|
120 | - */ |
|
121 | - public function end_el( &$output, $category, $depth = 0, $args = array() ) { |
|
122 | - global $post; |
|
123 | - |
|
124 | - if ( ! isset( $post ) ) { |
|
125 | - return; |
|
126 | - } |
|
127 | - |
|
128 | - if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
129 | - || 'article' !== $category->slug |
|
130 | - || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
131 | - parent::end_el( $output, $category, $depth, $args ); |
|
132 | - } |
|
133 | - |
|
134 | - } |
|
27 | + /** |
|
28 | + * Entity taxonomy metabox must show exclusive options, no checkboxes. |
|
29 | + * |
|
30 | + * @since 3.1.0 |
|
31 | + * |
|
32 | + * @param $args { |
|
33 | + * An array of arguments. |
|
34 | + * |
|
35 | + * @type string $taxonomy The taxonomy name. |
|
36 | + * } |
|
37 | + * |
|
38 | + * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy. |
|
39 | + */ |
|
40 | + public function terms_checklist_args( $args ) { |
|
41 | + |
|
42 | + if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
43 | + return $args; |
|
44 | + } |
|
45 | + |
|
46 | + // We override the way WP prints the taxonomy metabox HTML. |
|
47 | + $args['walker'] = $this; |
|
48 | + $args['checked_ontop'] = false; |
|
49 | + |
|
50 | + return $args; |
|
51 | + |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Change checkboxes to radios. |
|
56 | + * |
|
57 | + * $max_depth = -1 means flatly display every element. |
|
58 | + * $max_depth = 0 means display all levels. |
|
59 | + * $max_depth > 0 specifies the number of display levels. |
|
60 | + * |
|
61 | + * @since 3.1.0 |
|
62 | + * |
|
63 | + * @param array $elements An array of elements. |
|
64 | + * @param int $max_depth The maximum hierarchical depth. |
|
65 | + * |
|
66 | + * @param array $args Additional arguments. |
|
67 | + * |
|
68 | + * @return string The hierarchical item output. |
|
69 | + */ |
|
70 | + public function walk( $elements, $max_depth, $args = array() ) { |
|
71 | + |
|
72 | + // `max_depth` force to -1 to display a flat taxonomy. |
|
73 | + // |
|
74 | + // See https://github.com/insideout10/wordlift-plugin/issues/305 |
|
75 | + $output = parent::walk( $elements, - 1, $args ); |
|
76 | + |
|
77 | + $output = str_replace( |
|
78 | + array( 'type="checkbox"', "type='checkbox'" ), |
|
79 | + array( 'type="radio"', "type='radio'" ), |
|
80 | + $output |
|
81 | + ); |
|
82 | + |
|
83 | + return $output; |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Start the element output, output nothing in case of article term. |
|
88 | + * |
|
89 | + * @since 3.15.0 |
|
90 | + * |
|
91 | + * @param string $output Passed by reference. Used to append additional content. |
|
92 | + * @param object $category The current term object. |
|
93 | + * @param int $depth Depth of the term in reference to parents. Default 0. |
|
94 | + * @param array $args An array of arguments. @see wp_terms_checklist() |
|
95 | + * @param int $id ID of the current term. |
|
96 | + */ |
|
97 | + public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
|
98 | + global $post; |
|
99 | + |
|
100 | + if ( ! isset( $post ) ) { |
|
101 | + return; |
|
102 | + } |
|
103 | + |
|
104 | + if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
105 | + || 'article' !== $category->slug |
|
106 | + || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
107 | + parent::start_el( $output, $category, $depth, $args, $id ); |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * End the element output, output nothing in case of article term. |
|
113 | + * |
|
114 | + * @since 3.15.0 |
|
115 | + * |
|
116 | + * @param string $output Passed by reference. Used to append additional content. |
|
117 | + * @param object $category The current term object. |
|
118 | + * @param int $depth Depth of the term in reference to parents. Default 0. |
|
119 | + * @param array $args An array of arguments. @see wp_terms_checklist() |
|
120 | + */ |
|
121 | + public function end_el( &$output, $category, $depth = 0, $args = array() ) { |
|
122 | + global $post; |
|
123 | + |
|
124 | + if ( ! isset( $post ) ) { |
|
125 | + return; |
|
126 | + } |
|
127 | + |
|
128 | + if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
129 | + || 'article' !== $category->slug |
|
130 | + || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
131 | + parent::end_el( $output, $category, $depth, $args ); |
|
132 | + } |
|
133 | + |
|
134 | + } |
|
135 | 135 | |
136 | 136 | } |
@@ -9,8 +9,8 @@ discard block |
||
9 | 9 | * @package Wordlift |
10 | 10 | * @subpackage Wordlift/includes |
11 | 11 | */ |
12 | -if ( ! class_exists( 'Walker_Category_Checklist' ) ) { |
|
13 | - require_once ABSPATH . 'wp-admin/includes/template.php'; |
|
12 | +if ( ! class_exists('Walker_Category_Checklist')) { |
|
13 | + require_once ABSPATH.'wp-admin/includes/template.php'; |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy. |
39 | 39 | */ |
40 | - public function terms_checklist_args( $args ) { |
|
40 | + public function terms_checklist_args($args) { |
|
41 | 41 | |
42 | - if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
42 | + if ( ! isset($args['taxonomy']) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) { |
|
43 | 43 | return $args; |
44 | 44 | } |
45 | 45 | |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return string The hierarchical item output. |
69 | 69 | */ |
70 | - public function walk( $elements, $max_depth, $args = array() ) { |
|
70 | + public function walk($elements, $max_depth, $args = array()) { |
|
71 | 71 | |
72 | 72 | // `max_depth` force to -1 to display a flat taxonomy. |
73 | 73 | // |
74 | 74 | // See https://github.com/insideout10/wordlift-plugin/issues/305 |
75 | - $output = parent::walk( $elements, - 1, $args ); |
|
75 | + $output = parent::walk($elements, - 1, $args); |
|
76 | 76 | |
77 | 77 | $output = str_replace( |
78 | - array( 'type="checkbox"', "type='checkbox'" ), |
|
79 | - array( 'type="radio"', "type='radio'" ), |
|
78 | + array('type="checkbox"', "type='checkbox'"), |
|
79 | + array('type="radio"', "type='radio'"), |
|
80 | 80 | $output |
81 | 81 | ); |
82 | 82 | |
@@ -94,17 +94,17 @@ discard block |
||
94 | 94 | * @param array $args An array of arguments. @see wp_terms_checklist() |
95 | 95 | * @param int $id ID of the current term. |
96 | 96 | */ |
97 | - public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
|
97 | + public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) { |
|
98 | 98 | global $post; |
99 | 99 | |
100 | - if ( ! isset( $post ) ) { |
|
100 | + if ( ! isset($post)) { |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | |
104 | - if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
104 | + if (Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
105 | 105 | || 'article' !== $category->slug |
106 | - || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
107 | - parent::start_el( $output, $category, $depth, $args, $id ); |
|
106 | + || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) { |
|
107 | + parent::start_el($output, $category, $depth, $args, $id); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
@@ -118,17 +118,17 @@ discard block |
||
118 | 118 | * @param int $depth Depth of the term in reference to parents. Default 0. |
119 | 119 | * @param array $args An array of arguments. @see wp_terms_checklist() |
120 | 120 | */ |
121 | - public function end_el( &$output, $category, $depth = 0, $args = array() ) { |
|
121 | + public function end_el(&$output, $category, $depth = 0, $args = array()) { |
|
122 | 122 | global $post; |
123 | 123 | |
124 | - if ( ! isset( $post ) ) { |
|
124 | + if ( ! isset($post)) { |
|
125 | 125 | return; |
126 | 126 | } |
127 | 127 | |
128 | - if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
128 | + if (Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
129 | 129 | || 'article' !== $category->slug |
130 | - || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
131 | - parent::end_el( $output, $category, $depth, $args ); |
|
130 | + || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) { |
|
131 | + parent::end_el($output, $category, $depth, $args); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | } |
@@ -20,131 +20,131 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class Wordlift_Admin_Post_Edit_Page { |
22 | 22 | |
23 | - /** |
|
24 | - * Constants to be used instead of text inside FAQ |
|
25 | - * helper methods. |
|
26 | - */ |
|
27 | - const GUTENBERG = 'gutenberg'; |
|
28 | - const TINY_MCE = 'tiny_mce'; |
|
29 | - const FAQ_LIST_BOX_ID = 'wl-faq-meta-list-box'; |
|
30 | - |
|
31 | - /** Constant to be used for translation domain */ |
|
32 | - const WORDLIFT_TEXT_DOMAIN = 'wordlift'; |
|
33 | - |
|
34 | - /** |
|
35 | - * The {@link Wordlift} plugin instance. |
|
36 | - * |
|
37 | - * @since 3.11.0 |
|
38 | - * |
|
39 | - * @var \Wordlift $plugin The {@link Wordlift} plugin instance. |
|
40 | - */ |
|
41 | - private $plugin; |
|
42 | - |
|
43 | - /** |
|
44 | - * A {@link Wordlift_Log_Service} instance. |
|
45 | - * |
|
46 | - * @since 3.15.4 |
|
47 | - * |
|
48 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
49 | - */ |
|
50 | - private $log; |
|
51 | - |
|
52 | - /** |
|
53 | - * Create the {@link Wordlift_Admin_Post_Edit_Page} instance. |
|
54 | - * |
|
55 | - * @param \Wordlift $plugin The {@link Wordlift} plugin instance. |
|
56 | - * |
|
57 | - * @since 3.11.0 |
|
58 | - */ |
|
59 | - public function __construct( $plugin ) { |
|
60 | - |
|
61 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
62 | - |
|
63 | - add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_scripts_gutenberg' ) ); |
|
64 | - |
|
65 | - // Bail out if we're in the UX Builder editor. |
|
66 | - if ( $this->is_ux_builder_editor() ) { |
|
67 | - $this->log->info( 'WordLift will not show, since we are in UX Builder editor.' ); |
|
68 | - |
|
69 | - return; |
|
70 | - } |
|
71 | - |
|
72 | - // Define the callbacks. |
|
73 | - $callback = array( $this, 'enqueue_scripts' ); |
|
74 | - // Set a hook to enqueue scripts only when the edit page is displayed. |
|
75 | - add_action( 'admin_print_scripts-post.php', $callback ); |
|
76 | - add_action( 'admin_print_scripts-post-new.php', $callback ); |
|
77 | - |
|
78 | - $this->plugin = $plugin; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Check whether the current post opens with G'berg or not. |
|
83 | - * |
|
84 | - * @return bool True if G'berg is used otherwise false. |
|
85 | - * @since 3.22.3 |
|
86 | - */ |
|
87 | - public function is_gutenberg_page() { |
|
88 | - if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { |
|
89 | - // The Gutenberg plugin is on. |
|
90 | - return true; |
|
91 | - } |
|
92 | - |
|
93 | - $current_screen = get_current_screen(); |
|
94 | - if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) { |
|
95 | - // Gutenberg page on 5+. |
|
96 | - return true; |
|
97 | - } |
|
98 | - |
|
99 | - return false; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Check if we're in UX builder. |
|
104 | - * |
|
105 | - * @see https://github.com/insideout10/wordlift-plugin/issues/691 |
|
106 | - * |
|
107 | - * @since 3.15.4 |
|
108 | - * |
|
109 | - * @return bool True if we're in UX builder, otherwise false. |
|
110 | - */ |
|
111 | - private function is_ux_builder_editor() { |
|
112 | - |
|
113 | - return function_exists( 'ux_builder_is_editor' ) |
|
114 | - && ux_builder_is_editor(); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * Enqueue scripts and styles for the edit page. |
|
119 | - * |
|
120 | - * @since 3.11.0 |
|
121 | - */ |
|
122 | - public function enqueue_scripts() { |
|
123 | - |
|
124 | - // Dequeue potentially conflicting ontrapages angular scripts which any *are not* used on the edit screen. |
|
125 | - // |
|
126 | - // @see https://github.com/insideout10/wordlift-plugin/issues/832 |
|
127 | - wp_dequeue_script( 'ontrapagesAngular' ); |
|
128 | - wp_dequeue_script( 'ontrapagesApp' ); |
|
129 | - wp_dequeue_script( 'ontrapagesController' ); |
|
130 | - |
|
131 | - // Bail out if this is G'berg. |
|
132 | - if ( $this->is_gutenberg_page() ) { |
|
133 | - return; |
|
134 | - } |
|
135 | - |
|
136 | - // If Gutenberg is enabled for the post, do not load the legacy edit.js. |
|
137 | - if ( function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( get_post() ) ) { |
|
138 | - return; |
|
139 | - } |
|
140 | - |
|
141 | - // Bail out if classification sidebar is not enabled via hook |
|
142 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
143 | - if ( ! apply_filters( 'wl_feature__enable__classification-sidebar', true ) ) { |
|
144 | - return; |
|
145 | - } |
|
146 | - |
|
147 | - /* |
|
23 | + /** |
|
24 | + * Constants to be used instead of text inside FAQ |
|
25 | + * helper methods. |
|
26 | + */ |
|
27 | + const GUTENBERG = 'gutenberg'; |
|
28 | + const TINY_MCE = 'tiny_mce'; |
|
29 | + const FAQ_LIST_BOX_ID = 'wl-faq-meta-list-box'; |
|
30 | + |
|
31 | + /** Constant to be used for translation domain */ |
|
32 | + const WORDLIFT_TEXT_DOMAIN = 'wordlift'; |
|
33 | + |
|
34 | + /** |
|
35 | + * The {@link Wordlift} plugin instance. |
|
36 | + * |
|
37 | + * @since 3.11.0 |
|
38 | + * |
|
39 | + * @var \Wordlift $plugin The {@link Wordlift} plugin instance. |
|
40 | + */ |
|
41 | + private $plugin; |
|
42 | + |
|
43 | + /** |
|
44 | + * A {@link Wordlift_Log_Service} instance. |
|
45 | + * |
|
46 | + * @since 3.15.4 |
|
47 | + * |
|
48 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
49 | + */ |
|
50 | + private $log; |
|
51 | + |
|
52 | + /** |
|
53 | + * Create the {@link Wordlift_Admin_Post_Edit_Page} instance. |
|
54 | + * |
|
55 | + * @param \Wordlift $plugin The {@link Wordlift} plugin instance. |
|
56 | + * |
|
57 | + * @since 3.11.0 |
|
58 | + */ |
|
59 | + public function __construct( $plugin ) { |
|
60 | + |
|
61 | + $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
62 | + |
|
63 | + add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_scripts_gutenberg' ) ); |
|
64 | + |
|
65 | + // Bail out if we're in the UX Builder editor. |
|
66 | + if ( $this->is_ux_builder_editor() ) { |
|
67 | + $this->log->info( 'WordLift will not show, since we are in UX Builder editor.' ); |
|
68 | + |
|
69 | + return; |
|
70 | + } |
|
71 | + |
|
72 | + // Define the callbacks. |
|
73 | + $callback = array( $this, 'enqueue_scripts' ); |
|
74 | + // Set a hook to enqueue scripts only when the edit page is displayed. |
|
75 | + add_action( 'admin_print_scripts-post.php', $callback ); |
|
76 | + add_action( 'admin_print_scripts-post-new.php', $callback ); |
|
77 | + |
|
78 | + $this->plugin = $plugin; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Check whether the current post opens with G'berg or not. |
|
83 | + * |
|
84 | + * @return bool True if G'berg is used otherwise false. |
|
85 | + * @since 3.22.3 |
|
86 | + */ |
|
87 | + public function is_gutenberg_page() { |
|
88 | + if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { |
|
89 | + // The Gutenberg plugin is on. |
|
90 | + return true; |
|
91 | + } |
|
92 | + |
|
93 | + $current_screen = get_current_screen(); |
|
94 | + if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) { |
|
95 | + // Gutenberg page on 5+. |
|
96 | + return true; |
|
97 | + } |
|
98 | + |
|
99 | + return false; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Check if we're in UX builder. |
|
104 | + * |
|
105 | + * @see https://github.com/insideout10/wordlift-plugin/issues/691 |
|
106 | + * |
|
107 | + * @since 3.15.4 |
|
108 | + * |
|
109 | + * @return bool True if we're in UX builder, otherwise false. |
|
110 | + */ |
|
111 | + private function is_ux_builder_editor() { |
|
112 | + |
|
113 | + return function_exists( 'ux_builder_is_editor' ) |
|
114 | + && ux_builder_is_editor(); |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * Enqueue scripts and styles for the edit page. |
|
119 | + * |
|
120 | + * @since 3.11.0 |
|
121 | + */ |
|
122 | + public function enqueue_scripts() { |
|
123 | + |
|
124 | + // Dequeue potentially conflicting ontrapages angular scripts which any *are not* used on the edit screen. |
|
125 | + // |
|
126 | + // @see https://github.com/insideout10/wordlift-plugin/issues/832 |
|
127 | + wp_dequeue_script( 'ontrapagesAngular' ); |
|
128 | + wp_dequeue_script( 'ontrapagesApp' ); |
|
129 | + wp_dequeue_script( 'ontrapagesController' ); |
|
130 | + |
|
131 | + // Bail out if this is G'berg. |
|
132 | + if ( $this->is_gutenberg_page() ) { |
|
133 | + return; |
|
134 | + } |
|
135 | + |
|
136 | + // If Gutenberg is enabled for the post, do not load the legacy edit.js. |
|
137 | + if ( function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( get_post() ) ) { |
|
138 | + return; |
|
139 | + } |
|
140 | + |
|
141 | + // Bail out if classification sidebar is not enabled via hook |
|
142 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
143 | + if ( ! apply_filters( 'wl_feature__enable__classification-sidebar', true ) ) { |
|
144 | + return; |
|
145 | + } |
|
146 | + |
|
147 | + /* |
|
148 | 148 | * Enqueue the edit screen JavaScript. The `wordlift-admin.bundle.js` file |
149 | 149 | * is scheduled to replace the older `wordlift-admin.min.js` once client-side |
150 | 150 | * code is properly refactored. |
@@ -153,178 +153,178 @@ discard block |
||
153 | 153 | * |
154 | 154 | * @since 3.20.0 edit.js has been migrated to the new webpack configuration. |
155 | 155 | */ |
156 | - $script_name = plugin_dir_url( __DIR__ ) . 'js/dist/edit'; |
|
157 | - |
|
158 | - /** |
|
159 | - * Scripts_Helper introduced. |
|
160 | - * |
|
161 | - * @since 3.25.0 Scripts are loaded using script helper to ensure WP 4.4 compatibiility. |
|
162 | - * @since 3.25.1 The handle is used to hook the wp_localize_script for the _wlEntityTypes global object. |
|
163 | - */ |
|
164 | - Scripts_Helper::enqueue_based_on_wordpress_version( |
|
165 | - 'wl-classic-editor', |
|
166 | - $script_name, |
|
167 | - array( |
|
168 | - $this->plugin->get_plugin_name(), |
|
169 | - 'jquery', |
|
170 | - // Require wp.ajax. |
|
171 | - 'wp-util', |
|
172 | - // @@todo: provide the following dependencies when we're in WP < 5.0 (i.e. when these dependencies aren't already defined). |
|
173 | - 'react', |
|
174 | - 'react-dom', |
|
175 | - 'wp-element', |
|
176 | - 'wp-polyfill', |
|
177 | - /* |
|
156 | + $script_name = plugin_dir_url( __DIR__ ) . 'js/dist/edit'; |
|
157 | + |
|
158 | + /** |
|
159 | + * Scripts_Helper introduced. |
|
160 | + * |
|
161 | + * @since 3.25.0 Scripts are loaded using script helper to ensure WP 4.4 compatibiility. |
|
162 | + * @since 3.25.1 The handle is used to hook the wp_localize_script for the _wlEntityTypes global object. |
|
163 | + */ |
|
164 | + Scripts_Helper::enqueue_based_on_wordpress_version( |
|
165 | + 'wl-classic-editor', |
|
166 | + $script_name, |
|
167 | + array( |
|
168 | + $this->plugin->get_plugin_name(), |
|
169 | + 'jquery', |
|
170 | + // Require wp.ajax. |
|
171 | + 'wp-util', |
|
172 | + // @@todo: provide the following dependencies when we're in WP < 5.0 (i.e. when these dependencies aren't already defined). |
|
173 | + 'react', |
|
174 | + 'react-dom', |
|
175 | + 'wp-element', |
|
176 | + 'wp-polyfill', |
|
177 | + /* |
|
178 | 178 | * Angular isn't loaded anymore remotely, but it is loaded within wordlift-reloaded.js. |
179 | 179 | * |
180 | 180 | * See https://github.com/insideout10/wordlift-plugin/issues/865. |
181 | 181 | * |
182 | 182 | * @since 3.19.6 |
183 | 183 | */ |
184 | - // Require Angular. |
|
185 | - // 'wl-angular', |
|
186 | - // 'wl-angular-geolocation', |
|
187 | - // 'wl-angular-touch', |
|
188 | - // 'wl-angular-animate', |
|
189 | - /** |
|
190 | - * We need the `wp.hooks` global to allow the edit.js script to send actions. |
|
191 | - * |
|
192 | - * @since 3.23.0 |
|
193 | - */ |
|
194 | - 'wp-hooks', |
|
195 | - ) |
|
196 | - ); |
|
197 | - |
|
198 | - wp_enqueue_style( 'wl-classic-editor', "$script_name.css", array(), $this->plugin->get_version() ); |
|
199 | - // Disable Faq Editor. |
|
200 | - // $this->load_faq_scripts_and_styles(); |
|
201 | - // $this->load_faq_settings( self::TINY_MCE ); |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Enqueue the scripts and styles needed for FAQ |
|
206 | - */ |
|
207 | - private function load_faq_scripts_and_styles() { |
|
208 | - wp_enqueue_style( |
|
209 | - 'wl-faq-metabox-style', |
|
210 | - plugin_dir_url( __DIR__ ) . 'js/dist/faq.css', |
|
211 | - array(), |
|
212 | - WORDLIFT_VERSION |
|
213 | - ); |
|
214 | - Scripts_Helper::enqueue_based_on_wordpress_version( |
|
215 | - 'wl-faq-metabox-script', |
|
216 | - plugin_dir_url( __DIR__ ) . 'js/dist/faq', |
|
217 | - array( 'wp-polyfill' ), |
|
218 | - true |
|
219 | - ); |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * Get FAQ settings array |
|
224 | - * |
|
225 | - * @return array |
|
226 | - */ |
|
227 | - public function get_faq_settings() { |
|
228 | - return array( |
|
229 | - 'restUrl' => get_rest_url( null, WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faq' ), |
|
230 | - 'listBoxId' => self::FAQ_LIST_BOX_ID, |
|
231 | - 'nonce' => wp_create_nonce( 'wp_rest' ), |
|
232 | - 'postId' => get_the_ID(), |
|
233 | - // Translation for warning, error message. |
|
234 | - /* translators: %s: The invalid tag. */ |
|
235 | - 'invalidTagMessage' => sprintf( __( 'Invalid tags %s is present in answer', 'wordlift' ), '{INVALID_TAGS}' ), |
|
236 | - /* translators: %s: The word count limit warning. */ |
|
237 | - 'invalidWordCountMessage' => sprintf( __( 'Answer word count must not exceed %s words', 'wordlift' ), '{ANSWER_WORD_COUNT_WARNING_LIMIT}' ), |
|
238 | - 'questionText' => __( 'Question', 'wordlift' ), |
|
239 | - 'answerText' => __( 'Answer', 'wordlift' ), |
|
240 | - 'addQuestionOrAnswerText' => __( 'Add Question / Answer', 'wordlift' ), |
|
241 | - 'addQuestionText' => __( 'Add Question', 'wordlift' ), |
|
242 | - 'addAnswerText' => __( 'Add Answer', 'wordlift' ), |
|
243 | - 'noFaqItemsText' => __( 'Highlight a question in content, then click Add Question.', 'wordlift' ), |
|
244 | - 'updatingText' => __( 'Updating...', 'wordlift' ), |
|
245 | - ); |
|
246 | - } |
|
247 | - |
|
248 | - /** |
|
249 | - * Load FAQ settings to the add/edit post page |
|
250 | - * |
|
251 | - * @param $editor string specifying which text editor needed to be used. |
|
252 | - */ |
|
253 | - private function load_faq_settings( $editor ) { |
|
254 | - // This script also provides translations to gutenberg. |
|
255 | - wp_localize_script( 'wl-faq-metabox-script', '_wlFaqSettings', $this->get_faq_settings() ); |
|
256 | - |
|
257 | - // Enqueue the FAQ style |
|
258 | - if ( self::GUTENBERG === $editor ) { |
|
259 | - Scripts_Helper::enqueue_based_on_wordpress_version( |
|
260 | - 'wl-faq-gutenberg-plugin', |
|
261 | - plugin_dir_url( __DIR__ ) . 'js/dist/block-editor-faq-plugin', |
|
262 | - array( 'wp-polyfill' ), |
|
263 | - true |
|
264 | - ); |
|
265 | - } |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * Enqueue scripts and styles for the gutenberg edit page. |
|
270 | - * |
|
271 | - * @since 3.21.0 |
|
272 | - */ |
|
273 | - public function enqueue_scripts_gutenberg() { |
|
274 | - // Load FAQ settings. - Disabled for now |
|
275 | - // $this->load_faq_scripts_and_styles(); |
|
276 | - // $this->load_faq_settings( self::GUTENBERG ); |
|
277 | - |
|
278 | - wp_register_script( |
|
279 | - 'wl-block-editor', |
|
280 | - plugin_dir_url( __DIR__ ) . 'js/dist/block-editor.js', |
|
281 | - array( |
|
282 | - 'react', |
|
283 | - 'wordlift', |
|
284 | - 'wp-hooks', |
|
285 | - 'wp-data', |
|
286 | - 'wp-rich-text', |
|
287 | - 'wp-blocks', |
|
288 | - 'wp-plugins', |
|
289 | - 'wp-edit-post', |
|
290 | - ), |
|
291 | - $this->plugin->get_version(), |
|
292 | - false |
|
293 | - ); |
|
294 | - wp_localize_script( |
|
295 | - 'wl-block-editor', |
|
296 | - '_wlBlockEditorSettings', |
|
297 | - array( |
|
298 | - 'root' => esc_url_raw( rest_url() ), |
|
299 | - 'nonce' => wp_create_nonce( 'wp_rest' ), |
|
300 | - ) |
|
301 | - ); |
|
302 | - |
|
303 | - /* |
|
184 | + // Require Angular. |
|
185 | + // 'wl-angular', |
|
186 | + // 'wl-angular-geolocation', |
|
187 | + // 'wl-angular-touch', |
|
188 | + // 'wl-angular-animate', |
|
189 | + /** |
|
190 | + * We need the `wp.hooks` global to allow the edit.js script to send actions. |
|
191 | + * |
|
192 | + * @since 3.23.0 |
|
193 | + */ |
|
194 | + 'wp-hooks', |
|
195 | + ) |
|
196 | + ); |
|
197 | + |
|
198 | + wp_enqueue_style( 'wl-classic-editor', "$script_name.css", array(), $this->plugin->get_version() ); |
|
199 | + // Disable Faq Editor. |
|
200 | + // $this->load_faq_scripts_and_styles(); |
|
201 | + // $this->load_faq_settings( self::TINY_MCE ); |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Enqueue the scripts and styles needed for FAQ |
|
206 | + */ |
|
207 | + private function load_faq_scripts_and_styles() { |
|
208 | + wp_enqueue_style( |
|
209 | + 'wl-faq-metabox-style', |
|
210 | + plugin_dir_url( __DIR__ ) . 'js/dist/faq.css', |
|
211 | + array(), |
|
212 | + WORDLIFT_VERSION |
|
213 | + ); |
|
214 | + Scripts_Helper::enqueue_based_on_wordpress_version( |
|
215 | + 'wl-faq-metabox-script', |
|
216 | + plugin_dir_url( __DIR__ ) . 'js/dist/faq', |
|
217 | + array( 'wp-polyfill' ), |
|
218 | + true |
|
219 | + ); |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * Get FAQ settings array |
|
224 | + * |
|
225 | + * @return array |
|
226 | + */ |
|
227 | + public function get_faq_settings() { |
|
228 | + return array( |
|
229 | + 'restUrl' => get_rest_url( null, WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faq' ), |
|
230 | + 'listBoxId' => self::FAQ_LIST_BOX_ID, |
|
231 | + 'nonce' => wp_create_nonce( 'wp_rest' ), |
|
232 | + 'postId' => get_the_ID(), |
|
233 | + // Translation for warning, error message. |
|
234 | + /* translators: %s: The invalid tag. */ |
|
235 | + 'invalidTagMessage' => sprintf( __( 'Invalid tags %s is present in answer', 'wordlift' ), '{INVALID_TAGS}' ), |
|
236 | + /* translators: %s: The word count limit warning. */ |
|
237 | + 'invalidWordCountMessage' => sprintf( __( 'Answer word count must not exceed %s words', 'wordlift' ), '{ANSWER_WORD_COUNT_WARNING_LIMIT}' ), |
|
238 | + 'questionText' => __( 'Question', 'wordlift' ), |
|
239 | + 'answerText' => __( 'Answer', 'wordlift' ), |
|
240 | + 'addQuestionOrAnswerText' => __( 'Add Question / Answer', 'wordlift' ), |
|
241 | + 'addQuestionText' => __( 'Add Question', 'wordlift' ), |
|
242 | + 'addAnswerText' => __( 'Add Answer', 'wordlift' ), |
|
243 | + 'noFaqItemsText' => __( 'Highlight a question in content, then click Add Question.', 'wordlift' ), |
|
244 | + 'updatingText' => __( 'Updating...', 'wordlift' ), |
|
245 | + ); |
|
246 | + } |
|
247 | + |
|
248 | + /** |
|
249 | + * Load FAQ settings to the add/edit post page |
|
250 | + * |
|
251 | + * @param $editor string specifying which text editor needed to be used. |
|
252 | + */ |
|
253 | + private function load_faq_settings( $editor ) { |
|
254 | + // This script also provides translations to gutenberg. |
|
255 | + wp_localize_script( 'wl-faq-metabox-script', '_wlFaqSettings', $this->get_faq_settings() ); |
|
256 | + |
|
257 | + // Enqueue the FAQ style |
|
258 | + if ( self::GUTENBERG === $editor ) { |
|
259 | + Scripts_Helper::enqueue_based_on_wordpress_version( |
|
260 | + 'wl-faq-gutenberg-plugin', |
|
261 | + plugin_dir_url( __DIR__ ) . 'js/dist/block-editor-faq-plugin', |
|
262 | + array( 'wp-polyfill' ), |
|
263 | + true |
|
264 | + ); |
|
265 | + } |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * Enqueue scripts and styles for the gutenberg edit page. |
|
270 | + * |
|
271 | + * @since 3.21.0 |
|
272 | + */ |
|
273 | + public function enqueue_scripts_gutenberg() { |
|
274 | + // Load FAQ settings. - Disabled for now |
|
275 | + // $this->load_faq_scripts_and_styles(); |
|
276 | + // $this->load_faq_settings( self::GUTENBERG ); |
|
277 | + |
|
278 | + wp_register_script( |
|
279 | + 'wl-block-editor', |
|
280 | + plugin_dir_url( __DIR__ ) . 'js/dist/block-editor.js', |
|
281 | + array( |
|
282 | + 'react', |
|
283 | + 'wordlift', |
|
284 | + 'wp-hooks', |
|
285 | + 'wp-data', |
|
286 | + 'wp-rich-text', |
|
287 | + 'wp-blocks', |
|
288 | + 'wp-plugins', |
|
289 | + 'wp-edit-post', |
|
290 | + ), |
|
291 | + $this->plugin->get_version(), |
|
292 | + false |
|
293 | + ); |
|
294 | + wp_localize_script( |
|
295 | + 'wl-block-editor', |
|
296 | + '_wlBlockEditorSettings', |
|
297 | + array( |
|
298 | + 'root' => esc_url_raw( rest_url() ), |
|
299 | + 'nonce' => wp_create_nonce( 'wp_rest' ), |
|
300 | + ) |
|
301 | + ); |
|
302 | + |
|
303 | + /* |
|
304 | 304 | * @since 3.25.1 The hook is used by the wp_localize_script to register the _wlEntityTypes global object. |
305 | 305 | */ |
306 | - wp_enqueue_style( |
|
307 | - 'wl-block-editor', |
|
308 | - plugin_dir_url( __DIR__ ) . 'js/dist/block-editor.css', |
|
309 | - array(), |
|
310 | - $this->plugin->get_version() |
|
311 | - ); |
|
312 | - |
|
313 | - wp_enqueue_script( |
|
314 | - 'wl-autocomplete-select', |
|
315 | - plugin_dir_url( __DIR__ ) . 'js/dist/autocomplete-select.js', |
|
316 | - array(), |
|
317 | - $this->plugin->get_version(), |
|
318 | - true |
|
319 | - ); |
|
320 | - |
|
321 | - wp_enqueue_style( |
|
322 | - 'wl-autocomplete-select', |
|
323 | - plugin_dir_url( __DIR__ ) . 'js/dist/autocomplete-select.css', |
|
324 | - array(), |
|
325 | - $this->plugin->get_version() |
|
326 | - ); |
|
327 | - |
|
328 | - } |
|
306 | + wp_enqueue_style( |
|
307 | + 'wl-block-editor', |
|
308 | + plugin_dir_url( __DIR__ ) . 'js/dist/block-editor.css', |
|
309 | + array(), |
|
310 | + $this->plugin->get_version() |
|
311 | + ); |
|
312 | + |
|
313 | + wp_enqueue_script( |
|
314 | + 'wl-autocomplete-select', |
|
315 | + plugin_dir_url( __DIR__ ) . 'js/dist/autocomplete-select.js', |
|
316 | + array(), |
|
317 | + $this->plugin->get_version(), |
|
318 | + true |
|
319 | + ); |
|
320 | + |
|
321 | + wp_enqueue_style( |
|
322 | + 'wl-autocomplete-select', |
|
323 | + plugin_dir_url( __DIR__ ) . 'js/dist/autocomplete-select.css', |
|
324 | + array(), |
|
325 | + $this->plugin->get_version() |
|
326 | + ); |
|
327 | + |
|
328 | + } |
|
329 | 329 | |
330 | 330 | } |
@@ -56,24 +56,24 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @since 3.11.0 |
58 | 58 | */ |
59 | - public function __construct( $plugin ) { |
|
59 | + public function __construct($plugin) { |
|
60 | 60 | |
61 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
61 | + $this->log = Wordlift_Log_Service::get_logger(get_class()); |
|
62 | 62 | |
63 | - add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_scripts_gutenberg' ) ); |
|
63 | + add_action('enqueue_block_editor_assets', array($this, 'enqueue_scripts_gutenberg')); |
|
64 | 64 | |
65 | 65 | // Bail out if we're in the UX Builder editor. |
66 | - if ( $this->is_ux_builder_editor() ) { |
|
67 | - $this->log->info( 'WordLift will not show, since we are in UX Builder editor.' ); |
|
66 | + if ($this->is_ux_builder_editor()) { |
|
67 | + $this->log->info('WordLift will not show, since we are in UX Builder editor.'); |
|
68 | 68 | |
69 | 69 | return; |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Define the callbacks. |
73 | - $callback = array( $this, 'enqueue_scripts' ); |
|
73 | + $callback = array($this, 'enqueue_scripts'); |
|
74 | 74 | // Set a hook to enqueue scripts only when the edit page is displayed. |
75 | - add_action( 'admin_print_scripts-post.php', $callback ); |
|
76 | - add_action( 'admin_print_scripts-post-new.php', $callback ); |
|
75 | + add_action('admin_print_scripts-post.php', $callback); |
|
76 | + add_action('admin_print_scripts-post-new.php', $callback); |
|
77 | 77 | |
78 | 78 | $this->plugin = $plugin; |
79 | 79 | } |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | * @since 3.22.3 |
86 | 86 | */ |
87 | 87 | public function is_gutenberg_page() { |
88 | - if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { |
|
88 | + if (function_exists('is_gutenberg_page') && is_gutenberg_page()) { |
|
89 | 89 | // The Gutenberg plugin is on. |
90 | 90 | return true; |
91 | 91 | } |
92 | 92 | |
93 | 93 | $current_screen = get_current_screen(); |
94 | - if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) { |
|
94 | + if (method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor()) { |
|
95 | 95 | // Gutenberg page on 5+. |
96 | 96 | return true; |
97 | 97 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | private function is_ux_builder_editor() { |
112 | 112 | |
113 | - return function_exists( 'ux_builder_is_editor' ) |
|
113 | + return function_exists('ux_builder_is_editor') |
|
114 | 114 | && ux_builder_is_editor(); |
115 | 115 | } |
116 | 116 | |
@@ -124,23 +124,23 @@ discard block |
||
124 | 124 | // Dequeue potentially conflicting ontrapages angular scripts which any *are not* used on the edit screen. |
125 | 125 | // |
126 | 126 | // @see https://github.com/insideout10/wordlift-plugin/issues/832 |
127 | - wp_dequeue_script( 'ontrapagesAngular' ); |
|
128 | - wp_dequeue_script( 'ontrapagesApp' ); |
|
129 | - wp_dequeue_script( 'ontrapagesController' ); |
|
127 | + wp_dequeue_script('ontrapagesAngular'); |
|
128 | + wp_dequeue_script('ontrapagesApp'); |
|
129 | + wp_dequeue_script('ontrapagesController'); |
|
130 | 130 | |
131 | 131 | // Bail out if this is G'berg. |
132 | - if ( $this->is_gutenberg_page() ) { |
|
132 | + if ($this->is_gutenberg_page()) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // If Gutenberg is enabled for the post, do not load the legacy edit.js. |
137 | - if ( function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( get_post() ) ) { |
|
137 | + if (function_exists('use_block_editor_for_post') && use_block_editor_for_post(get_post())) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | 140 | |
141 | 141 | // Bail out if classification sidebar is not enabled via hook |
142 | 142 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
143 | - if ( ! apply_filters( 'wl_feature__enable__classification-sidebar', true ) ) { |
|
143 | + if ( ! apply_filters('wl_feature__enable__classification-sidebar', true)) { |
|
144 | 144 | return; |
145 | 145 | } |
146 | 146 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * |
154 | 154 | * @since 3.20.0 edit.js has been migrated to the new webpack configuration. |
155 | 155 | */ |
156 | - $script_name = plugin_dir_url( __DIR__ ) . 'js/dist/edit'; |
|
156 | + $script_name = plugin_dir_url(__DIR__).'js/dist/edit'; |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * Scripts_Helper introduced. |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | ) |
196 | 196 | ); |
197 | 197 | |
198 | - wp_enqueue_style( 'wl-classic-editor', "$script_name.css", array(), $this->plugin->get_version() ); |
|
198 | + wp_enqueue_style('wl-classic-editor', "$script_name.css", array(), $this->plugin->get_version()); |
|
199 | 199 | // Disable Faq Editor. |
200 | 200 | // $this->load_faq_scripts_and_styles(); |
201 | 201 | // $this->load_faq_settings( self::TINY_MCE ); |
@@ -207,14 +207,14 @@ discard block |
||
207 | 207 | private function load_faq_scripts_and_styles() { |
208 | 208 | wp_enqueue_style( |
209 | 209 | 'wl-faq-metabox-style', |
210 | - plugin_dir_url( __DIR__ ) . 'js/dist/faq.css', |
|
210 | + plugin_dir_url(__DIR__).'js/dist/faq.css', |
|
211 | 211 | array(), |
212 | 212 | WORDLIFT_VERSION |
213 | 213 | ); |
214 | 214 | Scripts_Helper::enqueue_based_on_wordpress_version( |
215 | 215 | 'wl-faq-metabox-script', |
216 | - plugin_dir_url( __DIR__ ) . 'js/dist/faq', |
|
217 | - array( 'wp-polyfill' ), |
|
216 | + plugin_dir_url(__DIR__).'js/dist/faq', |
|
217 | + array('wp-polyfill'), |
|
218 | 218 | true |
219 | 219 | ); |
220 | 220 | } |
@@ -226,22 +226,22 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function get_faq_settings() { |
228 | 228 | return array( |
229 | - 'restUrl' => get_rest_url( null, WL_REST_ROUTE_DEFAULT_NAMESPACE . '/faq' ), |
|
229 | + 'restUrl' => get_rest_url(null, WL_REST_ROUTE_DEFAULT_NAMESPACE.'/faq'), |
|
230 | 230 | 'listBoxId' => self::FAQ_LIST_BOX_ID, |
231 | - 'nonce' => wp_create_nonce( 'wp_rest' ), |
|
231 | + 'nonce' => wp_create_nonce('wp_rest'), |
|
232 | 232 | 'postId' => get_the_ID(), |
233 | 233 | // Translation for warning, error message. |
234 | 234 | /* translators: %s: The invalid tag. */ |
235 | - 'invalidTagMessage' => sprintf( __( 'Invalid tags %s is present in answer', 'wordlift' ), '{INVALID_TAGS}' ), |
|
235 | + 'invalidTagMessage' => sprintf(__('Invalid tags %s is present in answer', 'wordlift'), '{INVALID_TAGS}'), |
|
236 | 236 | /* translators: %s: The word count limit warning. */ |
237 | - 'invalidWordCountMessage' => sprintf( __( 'Answer word count must not exceed %s words', 'wordlift' ), '{ANSWER_WORD_COUNT_WARNING_LIMIT}' ), |
|
238 | - 'questionText' => __( 'Question', 'wordlift' ), |
|
239 | - 'answerText' => __( 'Answer', 'wordlift' ), |
|
240 | - 'addQuestionOrAnswerText' => __( 'Add Question / Answer', 'wordlift' ), |
|
241 | - 'addQuestionText' => __( 'Add Question', 'wordlift' ), |
|
242 | - 'addAnswerText' => __( 'Add Answer', 'wordlift' ), |
|
243 | - 'noFaqItemsText' => __( 'Highlight a question in content, then click Add Question.', 'wordlift' ), |
|
244 | - 'updatingText' => __( 'Updating...', 'wordlift' ), |
|
237 | + 'invalidWordCountMessage' => sprintf(__('Answer word count must not exceed %s words', 'wordlift'), '{ANSWER_WORD_COUNT_WARNING_LIMIT}'), |
|
238 | + 'questionText' => __('Question', 'wordlift'), |
|
239 | + 'answerText' => __('Answer', 'wordlift'), |
|
240 | + 'addQuestionOrAnswerText' => __('Add Question / Answer', 'wordlift'), |
|
241 | + 'addQuestionText' => __('Add Question', 'wordlift'), |
|
242 | + 'addAnswerText' => __('Add Answer', 'wordlift'), |
|
243 | + 'noFaqItemsText' => __('Highlight a question in content, then click Add Question.', 'wordlift'), |
|
244 | + 'updatingText' => __('Updating...', 'wordlift'), |
|
245 | 245 | ); |
246 | 246 | } |
247 | 247 | |
@@ -250,16 +250,16 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @param $editor string specifying which text editor needed to be used. |
252 | 252 | */ |
253 | - private function load_faq_settings( $editor ) { |
|
253 | + private function load_faq_settings($editor) { |
|
254 | 254 | // This script also provides translations to gutenberg. |
255 | - wp_localize_script( 'wl-faq-metabox-script', '_wlFaqSettings', $this->get_faq_settings() ); |
|
255 | + wp_localize_script('wl-faq-metabox-script', '_wlFaqSettings', $this->get_faq_settings()); |
|
256 | 256 | |
257 | 257 | // Enqueue the FAQ style |
258 | - if ( self::GUTENBERG === $editor ) { |
|
258 | + if (self::GUTENBERG === $editor) { |
|
259 | 259 | Scripts_Helper::enqueue_based_on_wordpress_version( |
260 | 260 | 'wl-faq-gutenberg-plugin', |
261 | - plugin_dir_url( __DIR__ ) . 'js/dist/block-editor-faq-plugin', |
|
262 | - array( 'wp-polyfill' ), |
|
261 | + plugin_dir_url(__DIR__).'js/dist/block-editor-faq-plugin', |
|
262 | + array('wp-polyfill'), |
|
263 | 263 | true |
264 | 264 | ); |
265 | 265 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | |
278 | 278 | wp_register_script( |
279 | 279 | 'wl-block-editor', |
280 | - plugin_dir_url( __DIR__ ) . 'js/dist/block-editor.js', |
|
280 | + plugin_dir_url(__DIR__).'js/dist/block-editor.js', |
|
281 | 281 | array( |
282 | 282 | 'react', |
283 | 283 | 'wordlift', |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | 'wl-block-editor', |
296 | 296 | '_wlBlockEditorSettings', |
297 | 297 | array( |
298 | - 'root' => esc_url_raw( rest_url() ), |
|
299 | - 'nonce' => wp_create_nonce( 'wp_rest' ), |
|
298 | + 'root' => esc_url_raw(rest_url()), |
|
299 | + 'nonce' => wp_create_nonce('wp_rest'), |
|
300 | 300 | ) |
301 | 301 | ); |
302 | 302 | |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | */ |
306 | 306 | wp_enqueue_style( |
307 | 307 | 'wl-block-editor', |
308 | - plugin_dir_url( __DIR__ ) . 'js/dist/block-editor.css', |
|
308 | + plugin_dir_url(__DIR__).'js/dist/block-editor.css', |
|
309 | 309 | array(), |
310 | 310 | $this->plugin->get_version() |
311 | 311 | ); |
312 | 312 | |
313 | 313 | wp_enqueue_script( |
314 | 314 | 'wl-autocomplete-select', |
315 | - plugin_dir_url( __DIR__ ) . 'js/dist/autocomplete-select.js', |
|
315 | + plugin_dir_url(__DIR__).'js/dist/autocomplete-select.js', |
|
316 | 316 | array(), |
317 | 317 | $this->plugin->get_version(), |
318 | 318 | true |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | |
321 | 321 | wp_enqueue_style( |
322 | 322 | 'wl-autocomplete-select', |
323 | - plugin_dir_url( __DIR__ ) . 'js/dist/autocomplete-select.css', |
|
323 | + plugin_dir_url(__DIR__).'js/dist/autocomplete-select.css', |
|
324 | 324 | array(), |
325 | 325 | $this->plugin->get_version() |
326 | 326 | ); |