PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 8.6.2
Admin and Site Enhancements (ASE) v8.6.2
9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 8.3.2 8.4.0 8.4.1 8.4.2 8.5.0 8.5.1 8.5.2 8.6.0 8.6.1 8.6.2 8.7.0 5.0.1 5.0.2 5.0.2.1 5.0.2.2 5.0.2.3 5.0.2.4 5.1.0 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1 5.5.0 5.5.1 5.5.2 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.8.0 5.8.1 6.0.0 6.0.3 6.0.4 6.0.5 6.0.5.1 6.0.6 6.0.7 6.0.8.1 6.1.0 6.1.3 6.2.0 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.3.0 6.3.1 6.3.2 6.4.0 6.5.0 6.5.1 6.6.0 6.7.0 6.8.0 6.8.2 6.8.3 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13.1 6.9.13.2 6.9.2 6.9.3 6.9.4 6.9.5 6.9.6 6.9.7 6.9.8 6.9.9 7.0.0 7.0.2 7.0.2.1 7.0.2.2 7.0.2.3 7.0.3 7.1.0 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2.0 7.2.1 7.3.0 7.3.1 7.3.2 7.3.3 7.4.0 7.4.2 7.4.4 7.4.5 7.4.6 7.4.7 7.4.8 7.5.0 7.5.1 7.5.2 7.5.3 7.5.4 7.6.0 7.6.1 7.6.1.1 7.6.10 7.6.11 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.7.1 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / settings.php
admin-site-enhancements Last commit date
assets 4 months ago classes 4 months ago includes 4 months ago languages 4 months ago vendor 4 months ago CHANGELOG.md 4 months ago LICENSE.md 4 months ago README.md 4 months ago admin-site-enhancements.php 4 months ago bootstrap.php 4 months ago functions.php 4 months ago settings.php 4 months ago
settings.php
1550 lines
1 <?php
2
3 /**
4 * Initialize options. [TODO] Move this into activation class at v7.
5 *
6 * @since 6.4.1
7 */
8 /**
9 * Get an ASE option as an array and normalize malformed values.
10 *
11 * Some sites may store malformed option payloads (e.g. strings), which can
12 * trigger fatal errors on PHP 8+ when string offsets are accessed as arrays.
13 *
14 * @since 8.4.2
15 *
16 * @param string $option_name Option name.
17 * @param bool|null $autoload Whether to autoload option.
18 * @return array
19 */
20 function asenha_get_option_array( $option_name, $autoload = null ) {
21 $option_value = get_option( $option_name, array() );
22 if ( is_array( $option_value ) ) {
23 return $option_value;
24 }
25 $normalized_value = array();
26 if ( is_object( $option_value ) ) {
27 $normalized_value = (array) $option_value;
28 } elseif ( is_string( $option_value ) && '' !== trim( $option_value ) ) {
29 $maybe_unserialized = maybe_unserialize( $option_value );
30 if ( is_array( $maybe_unserialized ) ) {
31 $normalized_value = $maybe_unserialized;
32 } elseif ( is_object( $maybe_unserialized ) ) {
33 $normalized_value = (array) $maybe_unserialized;
34 } elseif ( is_string( $maybe_unserialized ) && '' !== trim( $maybe_unserialized ) ) {
35 $maybe_json = json_decode( $maybe_unserialized, true );
36 if ( is_array( $maybe_json ) ) {
37 $normalized_value = $maybe_json;
38 }
39 }
40 }
41 if ( null === $autoload ) {
42 update_option( $option_name, $normalized_value );
43 } else {
44 update_option( $option_name, $normalized_value, $autoload );
45 }
46 return $normalized_value;
47 }
48
49 if ( false === get_option( ASENHA_SLUG_U ) ) {
50 add_option(
51 ASENHA_SLUG_U,
52 array(),
53 '',
54 true
55 );
56 }
57 if ( false === get_option( ASENHA_SLUG_U . '_stats' ) ) {
58 add_option(
59 ASENHA_SLUG_U . '_stats',
60 array(),
61 '',
62 false
63 );
64 }
65 if ( false === get_option( ASENHA_SLUG_U . '_extra' ) ) {
66 add_option(
67 ASENHA_SLUG_U . '_extra',
68 array(),
69 '',
70 true
71 );
72 }
73 // Bugfix in v7.1.2 for Custom Content Type module
74 $options_extra = asenha_get_option_array( ASENHA_SLUG_U . '_extra', true );
75 if ( !isset( $options_extra['cfgroup_next_field_id'] ) ) {
76 $options_extra['cfgroup_next_field_id'] = 1;
77 update_option( ASENHA_SLUG_U . '_extra', $options_extra, true );
78 }
79 // Move Admin Menu Organizer options storage to extra table since v7.8.5
80 if ( !isset( $options_extra['admin_menu'] ) ) {
81 $options = asenha_get_option_array( ASENHA_SLUG_U, true );
82 $options_extra['admin_menu']['custom_menu_order'] = ( isset( $options['custom_menu_order'] ) ? $options['custom_menu_order'] : '' );
83 unset($options['custom_menu_order']);
84 $options_extra['admin_menu']['custom_menu_titles'] = ( isset( $options['custom_menu_titles'] ) ? $options['custom_menu_titles'] : '' );
85 unset($options['custom_menu_titles']);
86 $options_extra['admin_menu']['custom_menu_hidden'] = ( isset( $options['custom_menu_hidden'] ) ? trim( $options['custom_menu_hidden'], ',' ) : '' );
87 unset($options['custom_menu_hidden']);
88 update_option( ASENHA_SLUG_U . '_extra', $options_extra, true );
89 update_option( ASENHA_SLUG_U, $options, true );
90 }
91 /**
92 * Get the SMTP password storage status with backward-compatible fallbacks.
93 *
94 * This avoids fatal errors during mixed-version deployments where newer
95 * settings code may temporarily run against an older Email_Delivery class
96 * definition that does not yet provide the newer helper method/constants.
97 *
98 * @since 8.5.1
99 *
100 * @param string|null $stored_password Stored option value.
101 * @return string
102 */
103 function asenha_get_smtp_password_status_compat( $stored_password = null ) {
104 if ( null === $stored_password ) {
105 $options = asenha_get_option_array( ASENHA_SLUG_U, true );
106 $stored_password = ( isset( $options['smtp_password'] ) ? $options['smtp_password'] : '' );
107 }
108 $email_delivery = new \ASENHA\Classes\Email_Delivery();
109 if ( method_exists( $email_delivery, 'get_smtp_password_status' ) ) {
110 return $email_delivery->get_smtp_password_status( $stored_password );
111 }
112 if ( empty( $stored_password ) ) {
113 return 'empty';
114 }
115 if ( is_string( $stored_password ) && 0 === strpos( $stored_password, 'asenha_encrypted::smtp_password::v1::' ) ) {
116 return 'encrypted_valid';
117 }
118 return 'legacy_plaintext';
119 }
120
121 /**
122 * Encrypt the SMTP password when the runtime supports the newer helper.
123 *
124 * @since 8.5.1
125 *
126 * @param \ASENHA\Classes\Email_Delivery $email_delivery Email delivery instance.
127 * @param string $password Plaintext SMTP password.
128 * @return string Encrypted payload or empty string when unsupported.
129 */
130 function asenha_encrypt_smtp_password_compat( $email_delivery, $password ) {
131 if ( !method_exists( $email_delivery, 'encrypt_smtp_password' ) ) {
132 return '';
133 }
134 return $email_delivery->encrypt_smtp_password( $password );
135 }
136
137 /**
138 * Encrypt legacy SMTP password storage after pluggable functions are available.
139 *
140 * @since 8.5.1
141 */
142 function asenha_migrate_legacy_smtp_password_storage() {
143 $options = asenha_get_option_array( ASENHA_SLUG_U, true );
144 if ( empty( $options['smtp_password'] ) ) {
145 return;
146 }
147 $email_delivery = new \ASENHA\Classes\Email_Delivery();
148 if ( 'legacy_plaintext' !== asenha_get_smtp_password_status_compat( $options['smtp_password'] ) ) {
149 return;
150 }
151 $encrypted_smtp_password = asenha_encrypt_smtp_password_compat( $email_delivery, $options['smtp_password'] );
152 if ( !empty( $encrypted_smtp_password ) ) {
153 $options['smtp_password'] = $encrypted_smtp_password;
154 update_option( ASENHA_SLUG_U, $options, true );
155 }
156 }
157
158 if ( did_action( 'plugins_loaded' ) ) {
159 asenha_migrate_legacy_smtp_password_storage();
160 } else {
161 add_action( 'plugins_loaded', 'asenha_migrate_legacy_smtp_password_storage' );
162 }
163 /**
164 * Register admin menu
165 *
166 * @since 1.0.0
167 */
168 function asenha_register_admin_menu() {
169 add_submenu_page(
170 'tools.php',
171 // Parent page/menu
172 'Admin and Site Enhancements',
173 // Browser tab/window title
174 __( 'Enhancements', 'admin-site-enhancements' ),
175 // Sube menu title
176 'manage_options',
177 // Minimal user capabililty
178 ASENHA_SLUG,
179 // Page slug. Shows up in URL.
180 'asenha_add_settings_page'
181 );
182 }
183
184 /**
185 * Create the settings page of the plugin
186 *
187 * @since 1.0.0
188 */
189 function asenha_add_settings_page() {
190 $options = asenha_get_option_array( ASENHA_SLUG_U, true );
191 ?>
192 <div class="wrap asenha">
193
194 <div id="asenha-header" class="asenha-header">
195 <div class="asenha-header-left">
196 <img src="<?php
197 echo esc_html( ASENHA_URL ) . 'assets/img/ase_icon.png';
198 ?>" class="asenha-icon"/>
199 <h1 class="asenha-heading">
200 <?php
201 echo esc_html( get_admin_page_title() );
202 ?>
203 (ASE)
204 <?php
205 ?>
206 </h1>
207 <input id="module-search-input" type="search" placeholder="<?php
208 echo esc_attr__( 'Search...', 'admin-site-enhancements' );
209 ?>" />
210 <!-- <a href="https://wordpress.org/plugins/admin-site-enhancements/" target="_blank" class="asenha-header-action"><span>&#8505;</span> <?php
211 // esc_html_e( 'Info', 'admin-site-enhancements' );
212 ?></a> -->
213 </div>
214 <div class="asenha-header-right">
215 <?php
216 // https://icon-sets.iconify.design/iconamoon/star-bold/
217 $svg_star = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="2.5" d="m12 2l3.104 6.728l7.358.873l-5.44 5.03l1.444 7.268L12 18.28L5.534 21.9l1.444-7.268L1.538 9.6l7.359-.873L12 2Z"/></svg>';
218 // https://icon-sets.iconify.design/octicon/question-16/
219 $svg_support = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill="currentColor" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13a6.5 6.5 0 0 0 0-13ZM6.92 6.085h.001a.749.749 0 1 1-1.342-.67c.169-.339.436-.701.849-.977C6.845 4.16 7.369 4 8 4a2.756 2.756 0 0 1 1.637.525c.503.377.863.965.863 1.725c0 .448-.115.83-.329 1.15c-.205.307-.47.513-.692.662c-.109.072-.22.138-.313.195l-.006.004a6.24 6.24 0 0 0-.26.16a.952.952 0 0 0-.276.245a.75.75 0 0 1-1.248-.832c.184-.264.42-.489.692-.661c.103-.067.207-.132.313-.195l.007-.004c.1-.061.182-.11.258-.161a.969.969 0 0 0 .277-.245C8.96 6.514 9 6.427 9 6.25a.612.612 0 0 0-.262-.525A1.27 1.27 0 0 0 8 5.5c-.369 0-.595.09-.74.187a1.01 1.01 0 0 0-.34.398ZM9 11a1 1 0 1 1-2 0a1 1 0 0 1 2 0Z"/></svg>';
220 // https://icon-sets.iconify.design/octicon/comment-16/
221 $svg_feedback = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 16 16"><path fill="currentColor" d="M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"/></svg>';
222 // https://icon-sets.iconify.design/ic/baseline-translate/
223 $svg_translate = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="m12.87 15.07l-2.54-2.51l.03-.03A17.52 17.52 0 0 0 14.07 6H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35C8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5l3.11 3.11zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2zm-2.62 7l1.62-4.33L19.12 17z"/></svg>';
224 // https://icon-sets.iconify.design/iconamoon/file-document/
225 $svg_docs = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="2"><path stroke-linecap="round" d="M7 21a2 2 0 0 1-2-2V3h9l5 5v11a2 2 0 0 1-2 2H7Z"/><path d="M13 3v6h6"/><path stroke-linecap="round" d="M9 13h6m-6 4h6"/></g></svg>';
226 // https://icon-sets.iconify.design/pajamas/heart/
227 $svg_sponsor = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M8.753 2.247L8 3l-.753-.753A4.243 4.243 0 0 0 1.25 8.25l5.69 5.69L8 15l1.06-1.06l5.69-5.69a4.243 4.243 0 0 0-5.997-6.003ZM8 12.879l5.69-5.69a2.743 2.743 0 0 0-3.877-3.881l-.752.753L8 5.12L6.94 4.06l-.753-.752v-.001A2.743 2.743 0 0 0 2.31 7.189L8 12.88Z" clip-rule="evenodd"/></svg>';
228 ?>
229 <a href="https://wordpress.org/plugins/admin-site-enhancements/#reviews" target="_blank" class="asenha-header-action review"><?php
230 echo wp_kses( $svg_star, get_kses_with_svg_ruleset() ) . esc_html__( 'Review', 'admin-site-enhancements' );
231 ?></a>
232 <a href="https://wordpress.org/support/plugin/admin-site-enhancements/" target="_blank" class="asenha-header-action feedback"><?php
233 echo wp_kses( $svg_feedback, get_kses_with_svg_ruleset() ) . esc_html__( 'Feedback', 'admin-site-enhancements' );
234 ?></a>
235 <a href="https://www.wpase.com/trnslt-plgnhdr" target="_blank" class="asenha-header-action translate"><?php
236 echo wp_kses( $svg_translate, get_kses_with_svg_ruleset() ) . esc_html__( 'Translate', 'admin-site-enhancements' );
237 ?></a>
238 <!--<a href="https://www.wpasenha.com/docs/" target="_blank" class="asenha-header-action docs"><?php
239 // echo $svg_docs . esc_html__( 'Docs', 'admin-site-enhancements' );
240 ?></a>-->
241 <!--<a id="plugin-sponsor" href="#" class="asenha-header-action sponsor"><?php
242 // echo $svg_sponsor . esc_html__( 'Sponsor', 'admin-site-enhancements' );
243 ?></a>-->
244 <a href="https://www.wpase.com/upgrade-btn" target="_blank" id="plugin-upgrade" class="button button-primary plugin-upgrade"><?php
245 echo esc_html__( 'Get ASE Pro', 'admin-site-enhancements' );
246 ?></a>
247 <?php
248 ?>
249 <a class="button button-primary asenha-save-button"><?php
250 echo esc_html__( 'Save Changes', 'admin-site-enhancements' );
251 ?></a>
252 <!-- https://icon-sets.iconify.design/svg-spinners/180-ring-with-bg/ -->
253 <div class="asenha-saving-changes" style="display:none;"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="#2271b1" d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z" opacity=".25"/><path fill="#2271b1" d="M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"><animateTransform attributeName="transform" dur="0.75s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></svg></div>
254 <div class="asenha-changes-saved" style="display:none;"><svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24"><path fill="seagreen" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2zM9.29 16.29L5.7 12.7a.996.996 0 1 1 1.41-1.41L10 14.17l6.88-6.88a.996.996 0 1 1 1.41 1.41l-7.59 7.59a.996.996 0 0 1-1.41 0z"/></svg></div>
255 </div>
256 </div>
257
258 <div class="asenha-body">
259 <?php
260 $is_yearend_promo_period = is_yearend_promo_period();
261 ?>
262 <?php
263 if ( $is_yearend_promo_period ) {
264 ?>
265 <!-- <div class="asenha-upgrade-nudge" style="display: none;">
266 <div class="asenha-upgrade-nudge__message"><?php
267 // echo esc_html__( 'Lifetime Deal (LTD) is available for the Pro version of ASE.', 'admin-site-enhancements' );
268 ?></div>
269 <a href="https://www.wpase.com/upgrade-ndg" class="button asenha-upgrade-nudge__button" target="_blank"><?php
270 // echo esc_html__( 'Find Out More', 'admin-site-enhancements' );
271 ?></a>
272 <a href="#" id="dismiss-upgrade-nudge" class="asenha-upgrade-nudge__dismiss">
273 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"><path fill="currentColor" d="M24 2.4L21.6 0L12 9.6L2.4 0L0 2.4L9.6 12L0 21.6L2.4 24l9.6-9.6l9.6 9.6l2.4-2.4l-9.6-9.6z"/></svg>
274 </a>
275 </div> -->
276 <div class="asenha-promo-nudge" style="display: none;">
277 <div class="asenha-promo-nudge__message"><?php
278 echo esc_html__( 'ASE Pro YEAR-END SALE! 20% DISCOUNT. Lifetime Deal (LTD) available.', 'admin-site-enhancements' );
279 ?></div>
280 <a href="https://www.wpase.com/promo-ndg" class="button asenha-promo-nudge__button" target="_blank"><?php
281 echo esc_html__( 'Get It Now', 'admin-site-enhancements' );
282 ?></a>
283 <a href="#" id="dismiss-promo-nudge" class="asenha-promo-nudge__dismiss">
284 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"><path fill="currentColor" d="M24 2.4L21.6 0L12 9.6L2.4 0L0 2.4L9.6 12L0 21.6L2.4 24l9.6-9.6l9.6 9.6l2.4-2.4l-9.6-9.6z"/></svg>
285 </a>
286 </div>
287 <?php
288 } else {
289 ?>
290 <div class="asenha-upgrade-nudge" style="display: none;">
291 <div class="asenha-upgrade-nudge__message"><?php
292 echo esc_html__( 'Lifetime Deal (LTD) is available for the Pro version of ASE.', 'admin-site-enhancements' );
293 ?></div>
294 <a href="https://www.wpase.com/upgrade-ndg" class="button asenha-upgrade-nudge__button" target="_blank"><?php
295 echo esc_html__( 'Find Out More', 'admin-site-enhancements' );
296 ?></a>
297 <a href="#" id="dismiss-upgrade-nudge" class="asenha-upgrade-nudge__dismiss">
298 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"><path fill="currentColor" d="M24 2.4L21.6 0L12 9.6L2.4 0L0 2.4L9.6 12L0 21.6L2.4 24l9.6-9.6l9.6 9.6l2.4-2.4l-9.6-9.6z"/></svg>
299 </a>
300 </div>
301 <?php
302 }
303 ?>
304 <?php
305 ?>
306 <div class="asenha-support-nudge nudge-show-more is-enabled" style="display: none;">
307 <h3><?php
308 _e( 'Looks like some of these free enhancements have been useful for your site?', 'admin-site-enhancements' );
309 ?></h3>
310 <p class="nudge-description intro"><?php
311 _e( 'Please consider supporting ASE.', 'admin-site-enhancements' );
312 ?></p>
313 <div class="nudge-content">
314 <div class="nudge-primary">
315 <h4><?php
316 _e( 'Write a quick, 5-star review for ASE', 'admin-site-enhancements' );
317 ?></h4>
318 <div class="nudge-ctas">
319 <a href="https://wordpress.org/plugins/admin-site-enhancements/#reviews" target="_blank" class="button button-outline asenha-review-button"><?php
320 _e( 'Add Your Review', 'admin-site-enhancements' );
321 ?></a>
322 <a href="#" id="have-reviewed" class="asenha-have-supported"><?php
323 _e( 'I\'ve reviewed', 'admin-site-enhancements' );
324 ?></a>
325 </div>
326 <p class="nudge-description"><?php
327 _e( 'Or, help improve ASE by <a href="https://wordpress.org/support/plugin/admin-site-enhancements/" target="_blank">providing feedback</a>.', 'admin-site-enhancements' );
328 ?></p>
329 </div>
330 <div class="nudge-secondary">
331 <h4><?php
332 _e( 'Share about ASE on:', 'admin-site-enhancements' );
333 ?></h4>
334 <div class="nudge-ctas">
335 <a href="https://www.facebook.com/sharer.php?u=<?php
336 echo urlencode( 'https://www.wpase.com' );
337 ?>" target="_blank" class="button button-outline asenha-share-button"><?php
338 _e( 'Facebook', 'admin-site-enhancements' );
339 ?></a>
340 <a href="https://twitter.com/intent/post?url=<?php
341 echo urlencode( 'https://www.wpase.com' );
342 ?>&text=<?php
343 echo esc_attr( urlencode( 'Admin and Site Enhancements (ASE)' ) );
344 ?>" target="_blank" class="button button-outline asenha-share-button"><?php
345 _e( 'X / Twitter', 'admin-site-enhancements' );
346 ?></a>
347 <a href="https://www.wpase.com/video-reviews/" target="_blank" class="button button-outline asenha-share-button"><?php
348 _e( 'YouTube', 'admin-site-enhancements' );
349 ?></a>
350 <a href="#" id="have-shared" class="asenha-have-supported"><?php
351 _e( 'I\'ve shared', 'admin-site-enhancements' );
352 ?></a>
353 </div>
354 <div class="nudge-info">
355 <p class="nudge-description"><?php
356 _e( 'Help others discover ASE and maybe <a href="https://www.wpase.com/trnslt-plgnndg" target="_blank">translate</a> to your language.', 'admin-site-enhancements' );
357 ?></p>
358 </div>
359 </div>
360 </div>
361 <div class="dismiss-support-nudge"><a href="#" id="support-nudge-dismiss" class="asenha-support-nudge-dismiss"><?php
362 _e( 'Dismiss', 'admin-site-enhancements' );
363 ?></a></div>
364 </div>
365 <?php
366 ?>
367 <form action="options.php" method="post">
368 <div class="asenha-vertical-tabs">
369 <div class="asenha-tab-buttons">
370 <?php
371 // https://icon-sets.iconify.design/mdi/database-check-outline/ -- db check
372 // https://icon-sets.iconify.design/mdi/file-document-box-multiple-outline/ -- docs
373 // https://icon-sets.iconify.design/fluent/content-view-28-regular/ -- content
374 // https://icon-sets.iconify.design/lucide/shapes/ -- shapes
375 $icon_content_management = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z"/><rect width="7" height="7" x="3" y="14" rx="1"/><circle cx="17.5" cy="17.5" r="3.5"/></g></svg>';
376 // https://icon-sets.iconify.design/mingcute/layout-line/
377 $icon_admin_interface = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0h24ZM12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035c-.01-.004-.019-.001-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427c-.002-.01-.009-.017-.017-.018Zm.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093c.012.004.023 0 .029-.008l.004-.014l-.034-.614c-.003-.012-.01-.02-.02-.022Zm-.715.002a.023.023 0 0 0-.027.006l-.006.014l-.034.614c0 .012.007.02.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01l-.184-.092Z"/><path fill="currentColor" d="M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm16 0H5v3h14V5ZM5 19v-9h4v9H5Zm6 0h8v-9h-8v9Z"/></g></svg>';
378 // https://icon-sets.iconify.design/ri/login-circle-line/
379 $icon_login_logout = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="m10.998 16l5-4l-5-4v3h-9v2h9z"/><path fill="currentColor" d="M12.999 2.999a8.938 8.938 0 0 0-6.364 2.637L8.049 7.05c1.322-1.322 3.08-2.051 4.95-2.051s3.628.729 4.95 2.051S20 10.13 20 12s-.729 3.628-2.051 4.95s-3.08 2.051-4.95 2.051s-3.628-.729-4.95-2.051l-1.414 1.414c1.699 1.7 3.959 2.637 6.364 2.637s4.665-.937 6.364-2.637C21.063 16.665 22 14.405 22 12s-.937-4.665-2.637-6.364a8.938 8.938 0 0 0-6.364-2.637z"/></svg>';
380 // https://icon-sets.iconify.design/mingcute/code-line/
381 $icon_custom_code = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none"><path d="M0 0h24v24H0z"/><path fill="currentColor" d="M14.486 3.143a1 1 0 0 1 .692 1.233l-4.43 15.788a1 1 0 0 1-1.926-.54l4.43-15.788a1 1 0 0 1 1.234-.693ZM7.207 7.05a1 1 0 0 1 0 1.414L3.672 12l3.535 3.535a1 1 0 1 1-1.414 1.415L1.55 12.707a1 1 0 0 1 0-1.414L5.793 7.05a1 1 0 0 1 1.414 0Zm9.586 1.414a1 1 0 1 1 1.414-1.414l4.243 4.243a1 1 0 0 1 0 1.414l-4.243 4.242a1 1 0 0 1-1.414-1.414L20.328 12l-3.535-3.536Z"/></g></svg>';
382 // https://icon-sets.iconify.design/mdi/forbid/
383 $icon_disable_components = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2c5.5 0 10 4.5 10 10s-4.5 10-10 10S2 17.5 2 12S6.5 2 12 2m0 2c-1.9 0-3.6.6-4.9 1.7l11.2 11.2c1-1.4 1.7-3.1 1.7-4.9c0-4.4-3.6-8-8-8m4.9 14.3L5.7 7.1C4.6 8.4 4 10.1 4 12c0 4.4 3.6 8 8 8c1.9 0 3.6-.6 4.9-1.7Z"/></svg>';
384 // https://icon-sets.iconify.design/jam/shield-check/
385 $icon_security = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 16 16"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"><path d="m8 1.75l5.25 2v5c0 2.25-2 4.5-5.25 5.5c-3.25-1-5.25-3-5.25-5.5v-5z"/><path d="m5.75 7.75l1.5 1.5l3-3.5"/></g></svg>';
386 // https://icon-sets.iconify.design/streamline/image-flash-1-flash-power-connect-charge-electricity-lightning/
387 $icon_optimizations = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 14 14"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" d="M4.25.5L2 5.81a.5.5 0 0 0 .46.69h2.79l-2 7l8.59-8.14a.5.5 0 0 0-.34-.86H7.75l2-4Z"/></svg>';
388 // https://icon-sets.iconify.design/iconoir/tools/
389 $icon_utilities = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"><path d="m10.05 10.607l-7.07 7.07a2 2 0 0 0 0 2.83v0a2 2 0 0 0 2.828 0l7.07-7.072m4.315.365l3.878 3.878a2 2 0 0 1 0 2.828v0a2 2 0 0 1-2.828 0l-6.209-6.208M6.733 5.904L4.61 6.61L2.49 3.075l1.414-1.414L7.44 3.782l-.707 2.122Zm0 0l2.83 2.83"/><path d="M10.05 10.607c-.844-2.153-.679-4.978 1.061-6.718c1.74-1.74 4.95-2.121 6.717-1.06l-3.04 3.04l-.283 3.111l3.111-.282l3.04-3.041c1.062 1.768.68 4.978-1.06 6.717c-1.74 1.74-4.564 1.905-6.717 1.061"/></g></svg>';
390 ?>
391 <input id="tab-content-management" type="radio" name="tabs" checked><label for="tab-content-management" class="modules-tab"><?php
392 echo wp_kses( $icon_content_management, get_kses_with_svg_ruleset() );
393 ?><span><?php
394 echo esc_html__( 'Content Management', 'admin-site-enhancements' );
395 ?></span></label>
396 <input id="tab-admin-interface" type="radio" name="tabs"><label for="tab-admin-interface" class="modules-tab"><?php
397 echo wp_kses( $icon_admin_interface, get_kses_with_svg_ruleset() );
398 ?><span><?php
399 echo esc_html__( 'Admin Interface', 'admin-site-enhancements' );
400 ?></span></label>
401 <input id="tab-login-logout" type="radio" name="tabs"><label for="tab-login-logout" class="modules-tab"><?php
402 echo wp_kses( $icon_login_logout, get_kses_with_svg_ruleset() );
403 ?><span><?php
404 echo esc_html__( 'Log In/Out | Register', 'admin-site-enhancements' );
405 ?></span></label>
406 <input id="tab-custom-code" type="radio" name="tabs"><label for="tab-custom-code" class="modules-tab"><?php
407 echo wp_kses( $icon_custom_code, get_kses_with_svg_ruleset() );
408 ?><span><?php
409 echo esc_html__( 'Custom Code', 'admin-site-enhancements' );
410 ?></span></label>
411 <input id="tab-disable-components" type="radio" name="tabs"><label for="tab-disable-components" class="modules-tab"><?php
412 echo wp_kses( $icon_disable_components, get_kses_with_svg_ruleset() );
413 ?><span><?php
414 echo esc_html__( 'Disable Components', 'admin-site-enhancements' );
415 ?></span></label>
416 <input id="tab-security" type="radio" name="tabs"><label for="tab-security" class="modules-tab"><?php
417 echo wp_kses( $icon_security, get_kses_with_svg_ruleset() );
418 ?><span><?php
419 echo esc_html__( 'Security', 'admin-site-enhancements' );
420 ?></span></label>
421 <input id="tab-optimizations" type="radio" name="tabs"><label for="tab-optimizations" class="modules-tab"><?php
422 echo wp_kses( $icon_optimizations, get_kses_with_svg_ruleset() );
423 ?><span><?php
424 echo esc_html__( 'Optimizations', 'admin-site-enhancements' );
425 ?></span></label>
426 <input id="tab-utilities" type="radio" name="tabs"><label for="tab-utilities" class="modules-tab"><?php
427 echo wp_kses( $icon_utilities, get_kses_with_svg_ruleset() );
428 ?><span><?php
429 echo esc_html__( 'Utilities', 'admin-site-enhancements' );
430 ?></span></label>
431 <label for="tab-search" class="search-tab" style="display:none;height:52px;"><span><?php
432 echo esc_html__( 'Search results:', 'admin-site-enhancements' );
433 ?></span></label>
434 </div>
435 <div class="asenha-tab-contents">
436 <section class="asenha-fields fields-content-management">
437 <table class="form-table" role="presentation">
438 <tbody></tbody>
439 </table>
440 </section>
441 <section class="asenha-fields fields-admin-interface">
442 <table class="form-table" role="presentation">
443 <tbody></tbody>
444 </table>
445 </section>
446 <section class="asenha-fields fields-login-logout">
447 <table class="form-table" role="presentation">
448 <tbody></tbody>
449 </table>
450 </section>
451 <section class="asenha-fields fields-custom-code">
452 <table class="form-table" role="presentation">
453 <tbody></tbody>
454 </table>
455 </section>
456 <section class="asenha-fields fields-disable-components">
457 <table class="form-table" role="presentation">
458 <tbody></tbody>
459 </table>
460 </section>
461 <section class="asenha-fields fields-security">
462 <table class="form-table" role="presentation">
463 <tbody></tbody>
464 </table>
465 </section>
466 <section class="asenha-fields fields-optimizations">
467 <table class="form-table" role="presentation">
468 <tbody></tbody>
469 </table>
470 </section>
471 <section class="asenha-fields fields-utilities">
472 <table class="form-table" role="presentation">
473 <tbody></tbody>
474 </table>
475 </section>
476 </div>
477 </div>
478 <div style="display:none;"><!-- Hide to prevent flash of fields appearing at the bottom of the page -->
479 <?php
480 settings_fields( ASENHA_ID );
481 ?>
482 <?php
483 do_settings_sections( ASENHA_SLUG );
484 ?>
485 <?php
486 submit_button(
487 __( 'Save Changes', 'admin-site-enhancements' ),
488 // Button copy
489 'primary',
490 // Type: 'primary', 'small', or 'large'
491 'submit',
492 // The 'name' attribute
493 true,
494 // Whether to wrap in <p> tag
495 array(
496 'id' => 'asenha-submit',
497 )
498 );
499 ?>
500 </div>
501 </form>
502 <?php
503 ?>
504 <div id="bottom-upgrade-nudge" class="asenha-upgrade-nudge-bottom" style="display:none;">
505 <div class="asenha-upgrade-nudge-bottom__message"><?php
506 echo __( 'Do more with <a href="https://www.wpase.com/upgrade-ndg-btm" target="_blank">ASE Pro</a>. Lifetime deal (LTD) <a href="https://www.wpase.com/upgrade-ndg-btm-prc" target="_blank">available</a>.', 'admin-site-enhancements' );
507 ?> <?php
508 if ( $is_yearend_promo_period ) {
509 echo __( 'Currently on YEAR-END SALE. <a href="https://www.wpase.com/promo-ndg" target="_blank">20% discount</a>.', 'admin-site-enhancements' );
510 }
511 ?></div>
512 </div>
513 <?php
514 ?>
515 </div>
516
517 <?php
518 ?>
519
520 </div>
521 <?php
522 // Record the number of times changes were saved as well as the date of last save
523 $asenha_stats = asenha_get_option_array( ASENHA_SLUG_U . '_stats', false );
524 $changes_saved = ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ? true : false );
525 if ( $changes_saved ) {
526 $current_date = date( 'Y-m-d', time() );
527 if ( !isset( $asenha_stats['first_save_date'] ) ) {
528 $asenha_stats['first_save_date'] = $current_date;
529 $asenha_stats['last_save_date'] = $current_date;
530 $asenha_stats['save_count'] = 1;
531 $asenha_stats['have_supported'] = false;
532 $asenha_stats['support_nudge_dismissed'] = false;
533 $asenha_stats['support_nudge_last_shown_date'] = '';
534 $asenha_stats['support_nudge_last_shown_save_count'] = 0;
535 } else {
536 $asenha_stats['last_save_date'] = $current_date;
537 $save_count = $asenha_stats['save_count'];
538 $save_count++;
539 $asenha_stats['save_count'] = $save_count;
540 }
541 update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
542 }
543 }
544
545 /**
546 * Check whether it's the year-end promo period
547 *
548 * @since 7.8.11
549 */
550 function is_yearend_promo_period() {
551 // For year end promo between October 1 to December 31
552 $current_month = intval( date( 'n', time() ) );
553 // n is for numeric value of month, 1 to 12
554 if ( $current_month >= 10 ) {
555 $is_yearend_promo_period = true;
556 // Clear out last year's promo nudge dismissal data
557 $current_year = date( 'Y', time() );
558 $asenha_stats = asenha_get_option_array( ASENHA_SLUG_U . '_stats', false );
559 if ( isset( $asenha_stats['promo_nudge_dismissed'] ) && $asenha_stats['promo_nudge_dismissed'] ) {
560 $last_dismissed_year = date( 'Y', strtotime( $asenha_stats['promo_nudge_dismissed_date'] ) );
561 if ( $current_year > $last_dismissed_year ) {
562 $asenha_stats['promo_nudge_dismissed'] = false;
563 $asenha_stats['promo_nudge_dismissed_date'] = '';
564 update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
565 }
566 }
567 } else {
568 $is_yearend_promo_period = false;
569 }
570 // For year end promo between November 15 to December 31
571 // $tz = wp_timezone(); // WordPress timezone; or: new DateTimeZone('UTC')
572 // $current_date = new DateTimeImmutable('now', $tz);
573 // // $current_date = new DateTimeImmutable('2025-11-15', $tz); // For testing
574 // // $current_date = new DateTimeImmutable('2026-01-01', $tz); // For testing
575 // // $current_date = new DateTimeImmutable('2027-11-15', $tz); // For testing
576 // $year = (int) $current_date->format('Y');
577 // $start = new DateTimeImmutable("$year-11-15 00:00:00", $tz);
578 // $end = new DateTimeImmutable("$year-12-31 23:59:59", $tz);
579 // $is_between = ($current_date >= $start && $current_date <= $end);
580 // if ( $is_between ) {
581 // $is_yearend_promo_period = true;
582 // } else {
583 // $is_yearend_promo_period = false;
584 // }
585 // // Clear out last year's promo nudge dismissal data
586 // if ( $is_yearend_promo_period ) {
587 // $current_year = $year;
588 // $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() );
589 // if ( isset( $asenha_stats['promo_nudge_dismissed'] ) && $asenha_stats['promo_nudge_dismissed'] ) {
590 // $last_dismissed_year = date( 'Y', strtotime( $asenha_stats['promo_nudge_dismissed_date'] ) );
591 // if ( $current_year > $last_dismissed_year ) {
592 // $asenha_stats['promo_nudge_dismissed'] = false;
593 // $asenha_stats['promo_nudge_dismissed_date'] = '';
594 // update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
595 // }
596 // }
597 // }
598 return $is_yearend_promo_period;
599 }
600
601 /**
602 * Suppress all notices, then add notice for successful settings update
603 *
604 * @since 1.1.0
605 */
606 function asenha_suppress_add_notices() {
607 global $plugin_page;
608 // Suppress all notices
609 if ( ASENHA_SLUG === $plugin_page ) {
610 remove_all_actions( 'admin_notices' );
611 }
612 // Add notice for successful settings update
613 if ( isset( $_GET['page'] ) && ASENHA_SLUG == $_GET['page'] && isset( $_GET['settings-updated'] ) && true == $_GET['settings-updated'] ) {
614 ?>
615 <script>
616 jQuery(document).ready( function() {
617 jQuery('.asenha-changes-saved').fadeIn(400).delay(2500).fadeOut(400);
618 });
619 </script>
620
621 <?php
622 }
623 }
624
625 /**
626 * Suppress all generic notices on the plugin settings page
627 *
628 * @since 2.7.0
629 */
630 function asenha_suppress_generic_notices() {
631 global $plugin_page;
632 // Suppress all notices
633 if ( ASENHA_SLUG === $plugin_page ) {
634 remove_all_actions( 'all_admin_notices' );
635 }
636 }
637
638 /**
639 * Enqueue admin scripts
640 *
641 * @since 1.0.0
642 */
643 function asenha_admin_scripts( $hook_suffix ) {
644 global
645 $wp_version,
646 $pagenow,
647 $typenow,
648 $taxnow,
649 $hook_suffix,
650 $current_user
651 ;
652 $current_screen = get_current_screen();
653 // Get all WP Enhancements options, default to empty array in case it's not been created yet
654 $options = asenha_get_option_array( 'admin_site_enhancements', true );
655 // For main page of this plugin
656 if ( is_asenha() ) {
657 wp_enqueue_style(
658 'asenha-jbox',
659 ASENHA_URL . 'assets/css/jBox.all.min.css',
660 array(),
661 ASENHA_VERSION
662 );
663 wp_enqueue_script(
664 'asenha-jbox',
665 ASENHA_URL . 'assets/js/jBox.all.min.js',
666 array(),
667 ASENHA_VERSION,
668 false
669 );
670 wp_enqueue_script(
671 'asenha-jsticky',
672 ASENHA_URL . 'assets/js/jquery.jsticky.mod.min.js',
673 array('jquery'),
674 ASENHA_VERSION,
675 false
676 );
677 wp_enqueue_script(
678 'asenha-js-cookie',
679 ASENHA_URL . 'assets/js/js.cookie.min.js',
680 array(),
681 ASENHA_VERSION,
682 false
683 );
684 // First, we unload the CodeMirror libraries included in WP core
685 wp_deregister_script( 'wp-codemirror' );
686 wp_deregister_script( 'code-editor' );
687 wp_deregister_script( 'htmlhint' );
688 wp_deregister_script( 'csslint' );
689 wp_deregister_script( 'esprima' );
690 wp_deregister_script( 'jshint' );
691 // Then, we load ASENHA's CodeMirror libraries. In use, e.g. for Utilities >> Enable Custom Admin / Frontend CSS / ads.txt / app-ads.txt
692 wp_enqueue_style(
693 'asenha-codemirror',
694 ASENHA_URL . 'assets/css/codemirror/codemirror.min.css',
695 array(),
696 ASENHA_VERSION
697 );
698 wp_enqueue_script(
699 'asenha-codemirror',
700 ASENHA_URL . 'assets/js/codemirror/codemirror.min.js',
701 array('jquery'),
702 ASENHA_VERSION,
703 true
704 );
705 wp_enqueue_script(
706 'asenha-codemirror-htmlmixed-mode',
707 ASENHA_URL . 'assets/js/codemirror/htmlmixed.js',
708 array('asenha-codemirror'),
709 ASENHA_VERSION,
710 true
711 );
712 wp_enqueue_script(
713 'asenha-codemirror-xml-mode',
714 ASENHA_URL . 'assets/js/codemirror/xml.js',
715 array('asenha-codemirror'),
716 ASENHA_VERSION,
717 true
718 );
719 wp_enqueue_script(
720 'asenha-codemirror-javascript-mode',
721 ASENHA_URL . 'assets/js/codemirror/javascript.js',
722 array('asenha-codemirror'),
723 ASENHA_VERSION,
724 true
725 );
726 wp_enqueue_script(
727 'asenha-codemirror-css-mode',
728 ASENHA_URL . 'assets/js/codemirror/css.js',
729 array('asenha-codemirror'),
730 ASENHA_VERSION,
731 true
732 );
733 wp_enqueue_script(
734 'asenha-codemirror-markdown-mode',
735 ASENHA_URL . 'assets/js/codemirror/markdown.js',
736 array('asenha-codemirror'),
737 ASENHA_VERSION,
738 true
739 );
740 // DataTables. In use, e.g. for Security >> Limit Login Attempts
741 wp_enqueue_style(
742 'asenha-datatables',
743 ASENHA_URL . 'assets/css/datatables/datatables.min.css',
744 array(),
745 ASENHA_VERSION
746 );
747 wp_enqueue_script(
748 'asenha-datatables',
749 ASENHA_URL . 'assets/js/datatables/datatables.min.js',
750 array('jquery'),
751 ASENHA_VERSION,
752 false
753 );
754 // Add WP media library assets
755 wp_enqueue_media();
756 // Add WP color picker assets
757 wp_enqueue_style( 'wp-color-picker' );
758 wp_enqueue_script( 'wp-color-picker' );
759 // We force loading the uncompressed version of TinyMCE. This ensures we load 'wp-tinymce-root' and then 'wp-tinymce',
760 // which prevents issue where the Visual tab is unusable in some scenarios
761 $wp_scripts = wp_scripts();
762 $wp_scripts->remove( 'wp-tinymce' );
763 wp_register_tinymce_scripts( $wp_scripts, true );
764 $admin_page_script_dependencies = array(
765 'asenha-jsticky',
766 'asenha-jbox',
767 'asenha-js-cookie',
768 'asenha-codemirror-htmlmixed-mode',
769 'asenha-codemirror-xml-mode',
770 'asenha-codemirror-javascript-mode',
771 'asenha-codemirror-css-mode',
772 'asenha-codemirror-markdown-mode',
773 'asenha-datatables',
774 'wp-color-picker',
775 'wp-mediaelement',
776 'wp-tinymce-root',
777 'wp-tinymce'
778 );
779 // Main style and script for the admin page
780 wp_enqueue_style(
781 'asenha-admin-page',
782 ASENHA_URL . 'assets/css/admin-page.css',
783 array(
784 'asenha-jbox',
785 'asenha-codemirror',
786 'asenha-datatables',
787 'wp-color-picker'
788 ),
789 ASENHA_VERSION
790 );
791 wp_enqueue_script(
792 'asenha-admin-page',
793 ASENHA_URL . 'assets/js/admin-page.js',
794 $admin_page_script_dependencies,
795 ASENHA_VERSION,
796 false
797 );
798 $jsvars = array(
799 'nonce' => wp_create_nonce( 'asenha-' . get_current_user_id() ),
800 'siteUrl' => get_site_url(),
801 'wpcontentUrl' => content_url(),
802 'mediaFrameTitle' => __( 'Select an Image', 'admin-site-enhancements' ),
803 'mediaFrameButtonText' => __( 'Use Selected Image', 'admin-site-enhancements' ),
804 'resetMenuNonce' => wp_create_nonce( 'reset-menu-nonce' ),
805 'sendTestEmailNonce' => wp_create_nonce( 'send-test-email-nonce_' . get_current_user_id() ),
806 'formBuilderSendTestEmailNonce' => wp_create_nonce( 'formbuilder_ajax' ),
807 'expandText' => __( 'Expand', 'admin-site-enhancements' ),
808 'collapseText' => __( 'Collapse', 'admin-site-enhancements' ),
809 'dataTable' => array(
810 'emptyTable' => __( 'No data available in table', 'admin-site-enhancements' ),
811 'info' => __( 'Showing _START_ to _END_ of _TOTAL_ entries', 'admin-site-enhancements' ),
812 'infoEmpty' => __( 'Showing 0 to 0 of 0 entries', 'admin-site-enhancements' ),
813 'infoFiltered' => __( '(filtered from _MAX_ total entries)', 'admin-site-enhancements' ),
814 'lengthMenu' => __( 'Show _MENU_ entries', 'admin-site-enhancements' ),
815 'search' => __( 'Search:', 'admin-site-enhancements' ),
816 'zeroRecords' => __( 'No matching records found', 'admin-site-enhancements' ),
817 'paginate' => array(
818 'first' => __( 'First', 'admin-site-enhancements' ),
819 'last' => __( 'Last', 'admin-site-enhancements' ),
820 'next' => __( 'Next', 'admin-site-enhancements' ),
821 'previous' => __( 'Previous', 'admin-site-enhancements' ),
822 ),
823 ),
824 'limitLoginAttempts' => array(
825 'releaseLockSuccess' => __( 'Lock released for %s.', 'admin-site-enhancements' ),
826 'releaseLockError' => __( 'Could not release lock. Please try again.', 'admin-site-enhancements' ),
827 ),
828 );
829 wp_localize_script( 'asenha-admin-page', 'adminPageVars', $jsvars );
830 }
831 // Enqueue on all wp-admin
832 wp_enqueue_style(
833 'asenha-wp-admin',
834 ASENHA_URL . 'assets/css/wp-admin.css',
835 array(),
836 ASENHA_VERSION
837 );
838 // Content Management >> Show IDs, for list tables in wp-admin, e.g. All Posts page
839 if ( false !== strpos( $current_screen->base, 'edit' ) || false !== strpos( $current_screen->base, 'users' ) || false !== strpos( $current_screen->base, 'upload' ) ) {
840 wp_enqueue_style(
841 'asenha-list-table',
842 ASENHA_URL . 'assets/css/list-table.css',
843 array(),
844 ASENHA_VERSION
845 );
846 }
847 // Content Management >> Enable Media Replacement
848 if ( $current_screen->base == 'upload' || $current_screen->id == 'attachment' ) {
849 // wp_enqueue_style( 'asenha-jbox', ASENHA_URL . 'assets/css/jBox.all.min.css', array(), ASENHA_VERSION );
850 // wp_enqueue_script( 'asenha-jbox', ASENHA_URL . 'assets/js/jBox.all.min.js', array(), ASENHA_VERSION, false );
851 wp_enqueue_style(
852 'asenha-media-replace',
853 ASENHA_URL . 'assets/css/media-replace.css',
854 array(),
855 ASENHA_VERSION
856 );
857 wp_enqueue_script(
858 'asenha-media-replace',
859 ASENHA_URL . 'assets/js/media-replace.js',
860 array(),
861 ASENHA_VERSION,
862 false
863 );
864 $media_replace = array(
865 'selectMediaText' => __( 'Select New Media File', 'admin-site-enhancements' ),
866 'performReplacementText' => __( 'Perform Replacement', 'admin-site-enhancements' ),
867 );
868 wp_localize_script( 'asenha-media-replace', 'mediaReplace', $media_replace );
869 }
870 // Admin Interface >> Admin Menu Organizer
871 if ( 'settings_page_admin-menu-organizer' == $current_screen->base ) {
872 // Re-register and re-enqueue jQuery UI Core and plugins required for sortable, draggable and droppable when ordering menu items
873 wp_deregister_script( 'jquery-ui-core' );
874 wp_register_script(
875 'jquery-ui-core',
876 get_site_url() . '/wp-includes/js/jquery/ui/core.min.js',
877 array('jquery'),
878 ASENHA_VERSION,
879 false
880 );
881 wp_enqueue_script( 'jquery-ui-core' );
882 if ( version_compare( $wp_version, '5.6.0', '>=' ) ) {
883 wp_deregister_script( 'jquery-ui-mouse' );
884 wp_register_script(
885 'jquery-ui-mouse',
886 get_site_url() . '/wp-includes/js/jquery/ui/mouse.min.js',
887 array('jquery-ui-core'),
888 ASENHA_VERSION,
889 false
890 );
891 wp_enqueue_script( 'jquery-ui-mouse' );
892 } else {
893 wp_deregister_script( 'jquery-ui-widget' );
894 wp_register_script(
895 'jquery-ui-widget',
896 get_site_url() . '/wp-includes/js/jquery/ui/widget.min.js',
897 array('jquery'),
898 ASENHA_VERSION,
899 false
900 );
901 wp_enqueue_script( 'jquery-ui-widget' );
902 wp_deregister_script( 'jquery-ui-mouse' );
903 wp_register_script(
904 'jquery-ui-mouse',
905 get_site_url() . '/wp-includes/js/jquery/ui/mouse.min.js',
906 array('jquery-ui-core', 'jquery-ui-widget'),
907 ASENHA_VERSION,
908 false
909 );
910 wp_enqueue_script( 'jquery-ui-mouse' );
911 }
912 wp_deregister_script( 'jquery-ui-sortable' );
913 wp_register_script(
914 'jquery-ui-sortable',
915 get_site_url() . '/wp-includes/js/jquery/ui/sortable.min.js',
916 array('jquery-ui-mouse'),
917 ASENHA_VERSION,
918 false
919 );
920 wp_enqueue_script( 'jquery-ui-sortable' );
921 wp_deregister_script( 'jquery-ui-draggable' );
922 wp_register_script(
923 'jquery-ui-draggable',
924 get_site_url() . '/wp-includes/js/jquery/ui/draggable.min.js',
925 array('jquery-ui-mouse'),
926 ASENHA_VERSION,
927 false
928 );
929 wp_enqueue_script( 'jquery-ui-draggable' );
930 wp_deregister_script( 'jquery-ui-droppable' );
931 wp_register_script(
932 'jquery-ui-droppable',
933 get_site_url() . '/wp-includes/js/jquery/ui/droppable.min.js',
934 array('jquery-ui-draggable'),
935 ASENHA_VERSION,
936 false
937 );
938 wp_enqueue_script( 'jquery-ui-droppable' );
939 // Script to set behaviour and actions of the sortable menu
940 wp_enqueue_script(
941 'asenha-custom-admin-menu',
942 ASENHA_URL . 'assets/js/custom-admin-menu.js',
943 array('jquery-ui-draggable'),
944 ASENHA_VERSION,
945 false
946 );
947 wp_enqueue_style(
948 'asenha-admin-menu-organizer',
949 ASENHA_URL . 'assets/css/admin-menu-organizer.css',
950 array(),
951 ASENHA_VERSION
952 );
953 wp_enqueue_script(
954 'asenha-admin-menu-organizer',
955 ASENHA_URL . 'assets/js/admin-menu-organizer.js',
956 array('asenha-custom-admin-menu'),
957 ASENHA_VERSION,
958 false
959 );
960 $amo_page_vars = array(
961 'saveMenuNonce' => wp_create_nonce( 'save-menu-nonce' ),
962 'strings' => array(
963 'saveChangesError' => __( 'Unable to save changes. Please reload the page and try again.', 'admin-site-enhancements' ),
964 ),
965 );
966 wp_localize_script( 'asenha-custom-admin-menu', 'amoPageVars', $amo_page_vars );
967 }
968 // Admin Interface >> Admin Bar Custom Elements (Pro)
969 if ( $current_screen && 'settings_page_asenha-admin-bar' === $current_screen->base ) {
970 wp_deregister_script( 'jquery-ui-core' );
971 wp_register_script(
972 'jquery-ui-core',
973 get_site_url() . '/wp-includes/js/jquery/ui/core.min.js',
974 array('jquery'),
975 ASENHA_VERSION,
976 false
977 );
978 wp_enqueue_script( 'jquery-ui-core' );
979 if ( version_compare( $wp_version, '5.6.0', '>=' ) ) {
980 wp_deregister_script( 'jquery-ui-mouse' );
981 wp_register_script(
982 'jquery-ui-mouse',
983 get_site_url() . '/wp-includes/js/jquery/ui/mouse.min.js',
984 array('jquery-ui-core'),
985 ASENHA_VERSION,
986 false
987 );
988 wp_enqueue_script( 'jquery-ui-mouse' );
989 } else {
990 wp_deregister_script( 'jquery-ui-widget' );
991 wp_register_script(
992 'jquery-ui-widget',
993 get_site_url() . '/wp-includes/js/jquery/ui/widget.min.js',
994 array('jquery'),
995 ASENHA_VERSION,
996 false
997 );
998 wp_enqueue_script( 'jquery-ui-widget' );
999 wp_deregister_script( 'jquery-ui-mouse' );
1000 wp_register_script(
1001 'jquery-ui-mouse',
1002 get_site_url() . '/wp-includes/js/jquery/ui/mouse.min.js',
1003 array('jquery-ui-core', 'jquery-ui-widget'),
1004 ASENHA_VERSION,
1005 false
1006 );
1007 wp_enqueue_script( 'jquery-ui-mouse' );
1008 }
1009 wp_deregister_script( 'jquery-ui-sortable' );
1010 wp_register_script(
1011 'jquery-ui-sortable',
1012 get_site_url() . '/wp-includes/js/jquery/ui/sortable.min.js',
1013 array('jquery-ui-mouse'),
1014 ASENHA_VERSION,
1015 false
1016 );
1017 wp_enqueue_script( 'jquery-ui-sortable' );
1018 wp_enqueue_style(
1019 'asenha-admin-bar-custom-elements',
1020 ASENHA_URL . 'assets/premium/css/admin-bar-custom-elements.css',
1021 array(),
1022 ASENHA_VERSION
1023 );
1024 wp_enqueue_script(
1025 'asenha-admin-bar-custom-elements',
1026 ASENHA_URL . 'assets/premium/js/admin-bar-custom-elements.js',
1027 array('jquery-ui-sortable'),
1028 ASENHA_VERSION,
1029 false
1030 );
1031 }
1032 // Utilities >> Email Delivery Log
1033 if ( 'tools_page_email-delivery-log' == $hook_suffix ) {
1034 wp_enqueue_style( 'jquery-ui-css', ASENHA_URL . 'assets/premium/css/jquery-ui/jquery-ui.min.css' );
1035 wp_enqueue_style( 'asenha-email-delivery-log', ASENHA_URL . 'assets/premium/css/email-delivery-log.css' );
1036 wp_enqueue_script( 'jquery-ui' );
1037 // wp_enqueue_script( 'jquery-ui-datepicker' );
1038 wp_enqueue_script( 'jquery-ui-tabs' );
1039 wp_enqueue_script( 'asenha-email-delivery-log', ASENHA_URL . 'assets/premium/js/email-delivery-log.js' );
1040 $nonce = wp_create_nonce( 'email-delivery-log' . get_current_user_id() );
1041 wp_localize_script( 'asenha-email-delivery-log', 'emailLog', array(
1042 'nonce' => $nonce,
1043 ) );
1044 }
1045 // Utilities >> Image Sizes Panel∂
1046 if ( 'post' == $current_screen->base && 'attachment' == $current_screen->id ) {
1047 global $post;
1048 // Only enqueue if the attachment is an image
1049 if ( property_exists( $post, 'post_mime_type' ) && false !== strpos( $post->post_mime_type, 'image' ) ) {
1050 wp_enqueue_style( 'asenha-image-sizes-panel', ASENHA_URL . 'assets/css/image-sizes-panel.css' );
1051 }
1052 }
1053 // Code Snippets Manager
1054 if ( 'post' == $current_screen->base && 'asenha_code_snippet' == $current_screen->id || 'edit' == $current_screen->base && 'edit-asenha_code_snippet' == $current_screen->id ) {
1055 }
1056 // Content Management >> Hide Admin Notices
1057 if ( array_key_exists( 'hide_admin_notices', $options ) && $options['hide_admin_notices'] ) {
1058 $hide_for_nonadmins = ( isset( $options['hide_admin_notices_for_nonadmins'] ) ? $options['hide_admin_notices_for_nonadmins'] : false );
1059 $minimum_capability = 'manage_options';
1060 if ( current_user_can( $minimum_capability ) ) {
1061 wp_enqueue_style(
1062 'asenha-jbox',
1063 ASENHA_URL . 'assets/css/jBox.all.min.css',
1064 array(),
1065 ASENHA_VERSION
1066 );
1067 wp_enqueue_script(
1068 'asenha-jbox',
1069 ASENHA_URL . 'assets/js/jBox.all.min.js',
1070 array(),
1071 ASENHA_VERSION,
1072 false
1073 );
1074 wp_enqueue_style(
1075 'asenha-hide-admin-notices',
1076 ASENHA_URL . 'assets/css/hide-admin-notices.css',
1077 array(),
1078 ASENHA_VERSION
1079 );
1080 wp_enqueue_script(
1081 'asenha-hide-admin-notices',
1082 ASENHA_URL . 'assets/js/hide-admin-notices.js',
1083 array('asenha-jbox'),
1084 ASENHA_VERSION,
1085 false
1086 );
1087 }
1088 }
1089 // Utilities >> Multiple User Roles
1090 if ( array_key_exists( 'multiple_user_roles', $options ) && $options['multiple_user_roles'] ) {
1091 if ( 'user-edit.php' == $hook_suffix || 'user-new.php' == $hook_suffix ) {
1092 // Only replace roles dropdown with checkboxes for users that can assign roles to other users, e.g. administrators
1093 if ( current_user_can( 'promote_users', get_current_user_id() ) ) {
1094 wp_enqueue_script(
1095 'asenha-multiple-user-roles',
1096 ASENHA_URL . 'assets/js/multiple-user-roles.js',
1097 array('jquery'),
1098 ASENHA_VERSION,
1099 false
1100 );
1101 }
1102 }
1103 }
1104 $asenha_stats = asenha_get_option_array( ASENHA_SLUG_U . '_stats', false );
1105 $hide_promo_nudge = false;
1106 $is_yearend_promo_period = is_yearend_promo_period();
1107 // Pass on ASENHA stats to admin-page.js to determine whether to show support nudge
1108 $current_date = date( 'Y-m-d', time() );
1109 $show_support_nudge = false;
1110 $asenha_stats_localized = array(
1111 'firstSaveDate' => '',
1112 'lastSaveDate' => '',
1113 'saveCount' => 0,
1114 'hideUpgradeNudge' => false,
1115 'hidePromoNudge' => false,
1116 'showSupportNudge' => false,
1117 );
1118 if ( !empty( $asenha_stats ) ) {
1119 $hide_upgrade_nudge = ( isset( $asenha_stats['upgrade_nudge_dismissed'] ) ? $asenha_stats['upgrade_nudge_dismissed'] : false );
1120 $hide_promo_nudge = ( isset( $asenha_stats['promo_nudge_dismissed'] ) ? $asenha_stats['promo_nudge_dismissed'] : false );
1121 $have_supported = ( isset( $asenha_stats['have_supported'] ) ? $asenha_stats['have_supported'] : false );
1122 $changes_saved = ( isset( $_GET['settings-updated'] ) && 'true' == sanitize_text_field( $_GET['settings-updated'] ) ? true : false );
1123 $save_count = ( isset( $asenha_stats['save_count'] ) ? $asenha_stats['save_count'] : 0 );
1124 // Compensate for redirect from settings-updated=true URL
1125 if ( $changes_saved ) {
1126 $save_count = $save_count + 1;
1127 } else {
1128 $save_count = $save_count;
1129 }
1130 $saves_to_nudge_support = 10;
1131 if ( $save_count < $saves_to_nudge_support ) {
1132 $save_count_modulo = -1;
1133 } else {
1134 $save_count_modulo = $save_count % $saves_to_nudge_support;
1135 }
1136 // User have not supported ASE
1137 if ( false === $have_supported ) {
1138 // Support nudge have not been dismissed
1139 if ( isset( $asenha_stats['support_nudge_dismissed'] ) && false === $asenha_stats['support_nudge_dismissed'] ) {
1140 // Show support nudge after every x saves
1141 if ( $save_count_modulo >= 0 ) {
1142 $show_support_nudge = true;
1143 } else {
1144 $show_support_nudge = false;
1145 }
1146 if ( $show_support_nudge && $save_count_modulo >= 0 ) {
1147 $asenha_stats['support_nudge_last_shown_date'] = $current_date;
1148 $asenha_stats['support_nudge_last_shown_save_count'] = $save_count;
1149 update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
1150 }
1151 } else {
1152 if ( $save_count_modulo == 0 ) {
1153 $support_nudge_last_shown_save_count = ( isset( $asenha_stats['support_nudge_last_shown_save_count'] ) ? $asenha_stats['support_nudge_last_shown_save_count'] : 0 );
1154 if ( $save_count > $support_nudge_last_shown_save_count ) {
1155 $asenha_stats['support_nudge_dismissed'] = false;
1156 update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
1157 $show_support_nudge = true;
1158 } else {
1159 $show_support_nudge = false;
1160 }
1161 } else {
1162 $show_support_nudge = false;
1163 }
1164 }
1165 }
1166 $first_save_date = ( isset( $asenha_stats['first_save_date'] ) ? $asenha_stats['first_save_date'] : '' );
1167 $last_save_date = ( isset( $asenha_stats['last_save_date'] ) ? $asenha_stats['last_save_date'] : '' );
1168 $asenha_stats_localized = array(
1169 'firstSaveDate' => $first_save_date,
1170 'lastSaveDate' => $last_save_date,
1171 'saveCount' => $save_count,
1172 'isYearEndPromoPeriod' => $is_yearend_promo_period,
1173 'hideUpgradeNudge' => $hide_upgrade_nudge,
1174 'hidePromoNudge' => $hide_promo_nudge,
1175 'showSupportNudge' => $show_support_nudge,
1176 );
1177 }
1178 wp_localize_script( 'asenha-admin-page', 'asenhaStats', $asenha_stats_localized );
1179 }
1180
1181 /**
1182 * Enqueue block editor scripts and styles.
1183 *
1184 * Loaded via the `enqueue_block_editor_assets` hook so assets are scoped
1185 * strictly to block-editor post-edit screens (post.php / post-new.php).
1186 *
1187 * @since 7.11.0
1188 */
1189 function asenha_block_editor_scripts() {
1190 $current_screen = get_current_screen();
1191 // Only load on post edit / new post block editor screens.
1192 if ( !$current_screen instanceof \WP_Screen || 'post' !== $current_screen->base || !method_exists( $current_screen, 'is_block_editor' ) || !$current_screen->is_block_editor() ) {
1193 return;
1194 }
1195 wp_enqueue_style(
1196 'asenha-wp-block-editor',
1197 ASENHA_URL . 'assets/css/wp-block-editor.css',
1198 array(),
1199 ASENHA_VERSION
1200 );
1201 }
1202
1203 /**
1204 * Inline CSS for Admin Menu Organizer in all wp-admin pages. Previously loaded externally as part of wp-admin.css file
1205 *
1206 * @since 7.6.11
1207 */
1208 function asenha_admin_menu_organizer_css() {
1209 ?>
1210 <style type="text/css">
1211 /* Admin Interface >> Admin Menu Organizer */
1212 #adminmenuwrap {
1213 height: auto !important;
1214 }
1215
1216 .toplevel_page_wpide #adminmenuwrap {
1217 height: calc(100vh - var(--wpide-admin-bar-height)) !important;
1218 } /* Fix for when in WPIDE plugin's menu / admin page */
1219
1220 /* Hide "Show Less" toggle by default to avoid initial flash before JS runs. */
1221 #toplevel_page_asenha_hide_hidden_menu {
1222 display: none;
1223 }
1224
1225 .current.menu-top.hidden,
1226 .wp-has-current-submenu.hidden {
1227 display: list-item;
1228 }
1229
1230 #adminmenu a.menu-top.hidden,
1231 ul#adminmenu a.wp-has-current-submenu.hidden {
1232 display: block;
1233 }
1234
1235 /*! <fs_premium_only> */
1236 .always-hidden {
1237 display: none !important;
1238 }
1239
1240 #adminmenu .wp-submenu a.hidden {
1241 display: none;
1242 }
1243 /*! </fs_premium_only> */
1244 </style>
1245 <?php
1246 }
1247
1248 /**
1249 * Dequeue scripts that prevents ASE settings page from working properly. Usually from plugins.
1250 *
1251 * @since 6.3.3
1252 */
1253 function asenha_dequeue_scritps() {
1254 if ( is_asenha() ) {
1255 // https://wordpress.org/plugins/user-activity-log/
1256 wp_dequeue_script( 'chats-js' );
1257 wp_dequeue_script( 'custom_wp_admin_js' );
1258 // https://wordpress.org/plugins/print-invoices-packing-slip-labels-for-woocommerce/
1259 wp_dequeue_script( 'print-invoices-packing-slip-labels-for-woocommerce' );
1260 wp_dequeue_script( 'print-invoices-packing-slip-labels-for-woocommerce-form-wizard' );
1261 // https://wordpress.org/plugins/wp-reading-progress/
1262 wp_dequeue_script( 'ruigehond006_admin_javascript' );
1263 // WordPress Mentions Légales plugin v1.2.3 by Jean-Baptiste Aramendy - http://jba-development.fr/
1264 wp_dequeue_script( 'jquery-ui' );
1265 wp_dequeue_script( 'wordpress-mentions-legales' );
1266 // https://wordpress.org/plugins/us-weather-widget-willyweather/
1267 wp_dequeue_script( 'self' );
1268 // iThemes Security Pro / Solid Security Pro
1269 wp_dequeue_script( 'itsec-core-admin-notices' );
1270 // WPML
1271 wp_dequeue_script( 'wpml-ate-jobs-sync-ui' );
1272 wp_dequeue_script( 'wpml-purify' );
1273 wp_dequeue_script( 'sitepress-scripts' );
1274 wp_dequeue_script( 'sitepress' );
1275 wp_dequeue_script( 'wpml-dismiss-notice' );
1276 wp_dequeue_script( 'wpml-tm-scripts' );
1277 wp_dequeue_script( 'otgs-installer-components-save-setting' );
1278 wp_dequeue_script( 'installer-dismiss-nag' );
1279 wp_dequeue_script( 'install-recommended_plugin' );
1280 wp_dequeue_script( 'icl-admin-notifier' );
1281 wp_dequeue_script( 'otgsPopoverTooltip' );
1282 // WPML String Translation
1283 wp_dequeue_script( 'wpml-theme-plugin-localization-scan' );
1284 // Asset Cleanup
1285 wp_dequeue_script( 'wpassetcleanup-script' );
1286 }
1287 }
1288
1289 /**
1290 * Enqueue public scripts
1291 *
1292 * @since 3.9.0
1293 */
1294 function asenha_public_scripts( $hook_suffix ) {
1295 // Get all WP Enhancements options, default to empty array in case it's not been created yet
1296 $options = get_option( 'admin_site_enhancements', array() );
1297 // External Permalinks
1298 $enable_external_permalinks = ( array_key_exists( 'enable_external_permalinks', $options ) ? $options['enable_external_permalinks'] : false );
1299 if ( $enable_external_permalinks ) {
1300 wp_enqueue_script(
1301 'asenha-public',
1302 ASENHA_URL . 'assets/js/external-permalinks.js',
1303 array(),
1304 ASENHA_VERSION,
1305 false
1306 );
1307 wp_localize_script( 'asenha-public', 'phpVars', array(
1308 'externalPermalinksEnabled' => $enable_external_permalinks,
1309 ) );
1310 }
1311 // Media Categories
1312 $enable_media_categories = ( array_key_exists( 'enable_media_categories', $options ) ? $options['enable_media_categories'] : false );
1313 if ( $enable_media_categories && !is_admin() && is_user_logged_in() ) {
1314 wp_enqueue_style(
1315 'asenha-media-categories-frontend',
1316 ASENHA_URL . 'assets/css/media-categories-frontend.css',
1317 array(),
1318 ASENHA_VERSION
1319 );
1320 }
1321 // Media Replacement
1322 $enable_media_replacement = ( array_key_exists( 'enable_media_replacement', $options ) ? $options['enable_media_replacement'] : false );
1323 if ( $enable_media_replacement && !is_admin() && is_user_logged_in() ) {
1324 wp_enqueue_style(
1325 'asenha-media-replace-frontend',
1326 ASENHA_URL . 'assets/css/media-replace-frontend.css',
1327 array(),
1328 ASENHA_VERSION
1329 );
1330 }
1331 }
1332
1333 /**
1334 * Add admin bar styles for wp-admin and frontend
1335 *
1336 * @since 6.2.1
1337 */
1338 function asenha_admin_bar_item_js_css() {
1339 if ( is_user_logged_in() ) {
1340 ?>
1341 <!--<script></script>-->
1342 <style>
1343 #wp-admin-bar-user-info .avatar {
1344 object-fit: cover;
1345 }
1346 </style>
1347 <?php
1348 }
1349 }
1350
1351 /**
1352 * Add 'Access now' plugin action link.
1353 *
1354 * @since 1.0.0
1355 */
1356 function asenha_plugin_action_links( $links ) {
1357 $settings_link = '<a href="tools.php?page=' . ASENHA_SLUG . '">' . __( 'Configure', 'admin-site-enhancements' ) . '</a>';
1358 array_unshift( $links, $settings_link );
1359 return $links;
1360 }
1361
1362 /**
1363 * Modify footer text
1364 *
1365 * @since 1.0.0
1366 */
1367 function asenha_footer_text() {
1368 // Show nothing
1369 ?>
1370 <?php
1371 }
1372
1373 /**
1374 * Change WP version number text in footer
1375 *
1376 * @since 4.8.3
1377 */
1378 function asenha_footer_version_text() {
1379 ?>
1380 ASE <a href="https://www.wpase.com/documentation/changelog/" target="_blank">v<?php
1381 echo esc_html( ASENHA_VERSION );
1382 ?></a>
1383 <?php
1384 }
1385
1386 /**
1387 * Check if current screen is this plugin's main page
1388 *
1389 * @since 1.0.0
1390 */
1391 function is_asenha() {
1392 $request_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] );
1393 // e.g. /wp-admin/index.php?page=page-slug
1394 if ( strpos( $request_uri, 'page=' . ASENHA_SLUG ) !== false ) {
1395 return true;
1396 // Yes, this is the plugin's main page
1397 } else {
1398 return false;
1399 // Nope, this is NOT the plugin's page
1400 }
1401 }
1402
1403 /**
1404 * Mark that user have supported ASE
1405 *
1406 * @since 5.2.7
1407 */
1408 function asenha_have_supported() {
1409 if ( isset( $_REQUEST ) && current_user_can( 'manage_options' ) ) {
1410 if ( wp_verify_nonce( sanitize_text_field( $_REQUEST['nonce'] ), 'asenha-' . get_current_user_id() ) ) {
1411 $asenha_stats = asenha_get_option_array( ASENHA_SLUG_U . '_stats', false );
1412 $asenha_stats['have_supported'] = true;
1413 $asenha_stats['support_nudge_dismissed'] = true;
1414 $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
1415 if ( $success ) {
1416 echo json_encode( array(
1417 'success' => true,
1418 ) );
1419 } else {
1420 echo json_encode( array(
1421 'success' => false,
1422 ) );
1423 }
1424 }
1425 }
1426 }
1427
1428 /**
1429 * Dismiss support nudge
1430 *
1431 * @since 5.8.2
1432 */
1433 function asenha_dismiss_upgrade_nudge() {
1434 if ( isset( $_REQUEST ) && current_user_can( 'manage_options' ) ) {
1435 if ( wp_verify_nonce( sanitize_text_field( $_REQUEST['nonce'] ), 'asenha-' . get_current_user_id() ) ) {
1436 $current_date = date( 'Y-m-d', time() );
1437 $asenha_stats = asenha_get_option_array( ASENHA_SLUG_U . '_stats', false );
1438 $asenha_stats['upgrade_nudge_dismissed'] = true;
1439 $asenha_stats['upgrade_nudge_dismissed_date'] = $current_date;
1440 $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
1441 if ( $success ) {
1442 echo json_encode( array(
1443 'success' => true,
1444 ) );
1445 } else {
1446 echo json_encode( array(
1447 'success' => false,
1448 ) );
1449 }
1450 }
1451 }
1452 }
1453
1454 /**
1455 * Dismiss promo nudge
1456 *
1457 * @since 7.5.1
1458 */
1459 function asenha_dismiss_promo_nudge() {
1460 if ( isset( $_REQUEST ) && current_user_can( 'manage_options' ) ) {
1461 if ( wp_verify_nonce( sanitize_text_field( $_REQUEST['nonce'] ), 'asenha-' . get_current_user_id() ) ) {
1462 $current_date = date( 'Y-m-d', time() );
1463 $asenha_stats = asenha_get_option_array( ASENHA_SLUG_U . '_stats', false );
1464 $asenha_stats['promo_nudge_dismissed'] = true;
1465 $asenha_stats['promo_nudge_dismissed_date'] = $current_date;
1466 $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
1467 if ( $success ) {
1468 echo json_encode( array(
1469 'success' => true,
1470 ) );
1471 } else {
1472 echo json_encode( array(
1473 'success' => false,
1474 ) );
1475 }
1476 }
1477 }
1478 }
1479
1480 /**
1481 * Dismiss support nudge
1482 *
1483 * @since 5.2.7
1484 */
1485 function asenha_dismiss_support_nudge() {
1486 if ( isset( $_REQUEST ) && current_user_can( 'manage_options' ) ) {
1487 if ( wp_verify_nonce( sanitize_text_field( $_REQUEST['nonce'] ), 'asenha-' . get_current_user_id() ) ) {
1488 $asenha_stats = asenha_get_option_array( ASENHA_SLUG_U . '_stats', false );
1489 $asenha_stats['support_nudge_dismissed'] = true;
1490 $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
1491 if ( $success ) {
1492 echo json_encode( array(
1493 'success' => true,
1494 ) );
1495 } else {
1496 echo json_encode( array(
1497 'success' => false,
1498 ) );
1499 }
1500 }
1501 }
1502 }
1503
1504 /**
1505 * Release lock for an IP address in Limit Login Attempts.
1506 *
1507 * Deletes the IP entry from the failed login attempts table, which immediately
1508 * releases the lockout for that IP address.
1509 *
1510 * @since 8.3.1
1511 */
1512 function asenha_release_login_lock() {
1513 if ( !current_user_can( 'manage_options' ) ) {
1514 wp_send_json_error( array(
1515 'message' => __( 'Insufficient permissions.', 'admin-site-enhancements' ),
1516 ) );
1517 }
1518 if ( !isset( $_REQUEST['nonce'] ) || !isset( $_REQUEST['ip_address'] ) ) {
1519 wp_send_json_error( array(
1520 'message' => __( 'Missing required data.', 'admin-site-enhancements' ),
1521 ) );
1522 }
1523 $nonce = sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) );
1524 if ( !wp_verify_nonce( $nonce, 'asenha-' . get_current_user_id() ) ) {
1525 wp_send_json_error( array(
1526 'message' => __( 'Invalid security token.', 'admin-site-enhancements' ),
1527 ) );
1528 }
1529 $ip_address = sanitize_text_field( wp_unslash( $_REQUEST['ip_address'] ) );
1530 $common_methods = new \ASENHA\Classes\Common_Methods();
1531 if ( !$common_methods->is_ip_valid( $ip_address ) ) {
1532 wp_send_json_error( array(
1533 'message' => __( 'Invalid IP address.', 'admin-site-enhancements' ),
1534 ) );
1535 }
1536 global $wpdb;
1537 $table_name = $wpdb->prefix . 'asenha_failed_logins';
1538 $deleted = $wpdb->delete( $table_name, array(
1539 'ip_address' => $ip_address,
1540 ), array('%s') );
1541 if ( false === $deleted ) {
1542 wp_send_json_error( array(
1543 'message' => __( 'Could not release lock.', 'admin-site-enhancements' ),
1544 ) );
1545 }
1546 wp_send_json_success( array(
1547 'deleted' => (int) $deleted,
1548 ) );
1549 }
1550