admin-site-enhancements
Last commit date
assets
3 years ago
classes
3 years ago
includes
3 years ago
vendor
3 years ago
LICENSE.md
3 years ago
README.md
3 years ago
admin-site-enhancements.php
3 years ago
bootstrap.php
3 years ago
settings.php
3 years ago
settings.php
605 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Register admin menu |
| 5 | * |
| 6 | * @since 1.0.0 |
| 7 | */ |
| 8 | function asenha_register_admin_menu() |
| 9 | { |
| 10 | add_submenu_page( |
| 11 | 'tools.php', |
| 12 | // Parent page/menu |
| 13 | 'Admin and Site Enhancements', |
| 14 | // Browser tab/window title |
| 15 | 'Enhancements', |
| 16 | // Sube menu title |
| 17 | 'manage_options', |
| 18 | // Minimal user capabililty |
| 19 | ASENHA_SLUG, |
| 20 | // Page slug. Shows up in URL. |
| 21 | 'asenha_add_settings_page' |
| 22 | ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Create the settings page of the plugin |
| 27 | * |
| 28 | * @since 1.0.0 |
| 29 | */ |
| 30 | function asenha_add_settings_page() |
| 31 | { |
| 32 | ?> |
| 33 | <div class="wrap asenha"> |
| 34 | |
| 35 | <div id="asenha-header" class="asenha-header"> |
| 36 | <div class="asenha-header-left"> |
| 37 | <h1 class="asenha-heading"><?php |
| 38 | echo get_admin_page_title() ; |
| 39 | ?> <small><?php |
| 40 | esc_html_e( 'by', 'admin-site-enhancements' ); |
| 41 | ?> <a href="https://bowo.io/asenha-bw" target="_blank">Bowo</a></small></h1> |
| 42 | <!-- <a href="https://wordpress.org/plugins/admin-site-enhancements/" target="_blank" class="asenha-header-action"><span>ℹ</span> <?php |
| 43 | // esc_html_e( 'Info', 'admin-site-enhancements' ); |
| 44 | ?></a> --> |
| 45 | </div> |
| 46 | <div class="asenha-header-right"> |
| 47 | <a href="https://bowo.io/asenha-rvw" target="_blank" class="asenha-header-action"><span>★</span> <?php |
| 48 | esc_html_e( 'Review', 'admin-site-enhancements' ); |
| 49 | ?></a> |
| 50 | <a href="https://bowo.io/asenha-fdbk" target="_blank" class="asenha-header-action">✚ <?php |
| 51 | esc_html_e( 'Feedback', 'admin-site-enhancements' ); |
| 52 | ?></a> |
| 53 | <a href="https://bowo.io/asenha-trnslt" target="_blank" class="asenha-header-action">▶ <?php |
| 54 | esc_html_e( 'Translate', 'admin-site-enhancements' ); |
| 55 | ?></a> |
| 56 | <div id="plugin-sponsor" class="button button-primary plugin-sponsor">❤ |
| 57 | <?php |
| 58 | esc_html_e( 'Sponsor', 'admin-site-enhancements' ); |
| 59 | ?> |
| 60 | </div> |
| 61 | <a class="button button-primary asenha-save-button">Save Changes</a> |
| 62 | <div class="asenha-changes-saved" style="display:none;">Changes have been saved.</div> |
| 63 | </div> |
| 64 | </div> |
| 65 | |
| 66 | <div class="asenha-body"> |
| 67 | <form action="options.php" method="post"> |
| 68 | <div class="asenha-vertical-tabs"> |
| 69 | <div class="asenha-tab-buttons"> |
| 70 | <input id="tab-content-management" type="radio" name="tabs" checked><label for="tab-content-management">Content Management</label> |
| 71 | <input id="tab-admin-interface" type="radio" name="tabs"><label for="tab-admin-interface">Admin Interface</label> |
| 72 | <input id="tab-login-logout" type="radio" name="tabs"><label for="tab-login-logout">Log In | Log Out</label> |
| 73 | <input id="tab-custom-code" type="radio" name="tabs"><label for="tab-custom-code">Custom Code</label> |
| 74 | <input id="tab-disable-components" type="radio" name="tabs"><label for="tab-disable-components">Disable Components</label> |
| 75 | <input id="tab-security" type="radio" name="tabs"><label for="tab-security">Security</label> |
| 76 | <input id="tab-optimizations" type="radio" name="tabs"><label for="tab-optimizations">Optimizations</label> |
| 77 | <input id="tab-utilities" type="radio" name="tabs"><label for="tab-utilities">Utilities</label> |
| 78 | </div> |
| 79 | <div class="asenha-tab-contents"> |
| 80 | <section class="asenha-fields fields-content-management"> |
| 81 | <table class="form-table" role="presentation"> |
| 82 | <tbody></tbody> |
| 83 | </table> |
| 84 | </section> |
| 85 | <section class="asenha-fields fields-admin-interface"> |
| 86 | <table class="form-table" role="presentation"> |
| 87 | <tbody></tbody> |
| 88 | </table> |
| 89 | </section> |
| 90 | <section class="asenha-fields fields-login-logout"> |
| 91 | <table class="form-table" role="presentation"> |
| 92 | <tbody></tbody> |
| 93 | </table> |
| 94 | </section> |
| 95 | <section class="asenha-fields fields-custom-code"> |
| 96 | <table class="form-table" role="presentation"> |
| 97 | <tbody></tbody> |
| 98 | </table> |
| 99 | </section> |
| 100 | <section class="asenha-fields fields-disable-components"> |
| 101 | <table class="form-table" role="presentation"> |
| 102 | <tbody></tbody> |
| 103 | </table> |
| 104 | </section> |
| 105 | <section class="asenha-fields fields-security"> |
| 106 | <table class="form-table" role="presentation"> |
| 107 | <tbody></tbody> |
| 108 | </table> |
| 109 | </section> |
| 110 | <section class="asenha-fields fields-optimizations"> |
| 111 | <table class="form-table" role="presentation"> |
| 112 | <tbody></tbody> |
| 113 | </table> |
| 114 | </section> |
| 115 | <section class="asenha-fields fields-utilities"> |
| 116 | <table class="form-table" role="presentation"> |
| 117 | <tbody></tbody> |
| 118 | </table> |
| 119 | </section> |
| 120 | </div> |
| 121 | </div> |
| 122 | <div style="display:none;"><!-- Hide to prevent flash of fields appearing at the bottom of the page --> |
| 123 | <?php |
| 124 | settings_fields( ASENHA_ID ); |
| 125 | ?> |
| 126 | <?php |
| 127 | do_settings_sections( ASENHA_SLUG ); |
| 128 | ?> |
| 129 | <?php |
| 130 | submit_button( |
| 131 | 'Save Changes', |
| 132 | // Button copy |
| 133 | 'primary', |
| 134 | // Type: 'primary', 'small', or 'large' |
| 135 | 'submit', |
| 136 | // The 'name' attribute |
| 137 | true, |
| 138 | // Whether to wrap in <p> tag |
| 139 | array( |
| 140 | 'id' => 'asenha-submit', |
| 141 | ) |
| 142 | ); |
| 143 | ?> |
| 144 | </div> |
| 145 | </form> |
| 146 | </div> |
| 147 | |
| 148 | <div class="asenha-footer"> |
| 149 | </div> |
| 150 | |
| 151 | <div id="asenha-sponsor" class="cta-modal-content sponsorship" style="display:none;"> |
| 152 | <div class="sponsorship-content"> |
| 153 | <div class="sponsorship-header"> |
| 154 | <div class="sponsorship-image"> |
| 155 | <img src="<?php |
| 156 | echo esc_attr( ASENHA_URL . 'assets/img/undraw_Programming_re_kg9v.png' ) ; |
| 157 | ?>" /> |
| 158 | </div> |
| 159 | <h2>Thank you for your interest in sponsoring!</h2> |
| 160 | </div> |
| 161 | <div class="sponsorship-content-sections"> |
| 162 | <div class="sponsorship-info"> |
| 163 | <p class="sponsorship-description">I love building <strong>useful and free <a href="https://bowo.io/asenha-other-plugins" target="_blank">plugins</a></strong>. Your sponsorship will help justify the time and effort I spend in <strong>developing and maintaining this plugin</strong>, so it can remain functional and be more useful for <strong>your personal project(s), paid dev work, client site(s) and/or agency workflow</strong>... hopefully for years to come.</p> |
| 164 | </div> |
| 165 | <div class="sponsorship-methods"> |
| 166 | <p class="sponsorship-amount">Sponsorship can be <strong>as little as USD 1</strong>, monthly or one-time.</p> |
| 167 | <div class="sponsorship-method sponsor-via-github"> |
| 168 | <a href="https://bowo.io/asenha-sp-gth" target="_blank" class="button button-primary button-hero sponsorship-button monthly">Monthly Sponsorship via Github <span class="dashicons dashicons-arrow-right-alt2"></span></a> |
| 169 | </div> |
| 170 | <div class="sponsorship-method sponsor-via-paypal"> |
| 171 | <a href="https://bowo.io/asenha-sp-ppl" target="_blank" class="button button-hero sponsorship-button one-time">One-time Sponsorship via PayPal <span class="dashicons dashicons-arrow-right-alt2"></span></a> |
| 172 | </div> |
| 173 | </div> |
| 174 | </div> |
| 175 | <p>More about me and my work at <a href="https://bowo.io/asenha-bw-sp" target="_blank">bowo.io</a>.</p> |
| 176 | </div> |
| 177 | </div> |
| 178 | </div> |
| 179 | <?php |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Suppress all notices, then add notice for successful settings update |
| 184 | * |
| 185 | * @since 1.1.0 |
| 186 | */ |
| 187 | function asenha_suppress_notices() |
| 188 | { |
| 189 | global $plugin_page ; |
| 190 | // Suppress all notices |
| 191 | if ( ASENHA_SLUG === $plugin_page ) { |
| 192 | remove_all_actions( 'admin_notices' ); |
| 193 | } |
| 194 | // Add notice for successful settings update |
| 195 | if ( isset( $_GET['page'] ) && ASENHA_SLUG == $_GET['page'] && isset( $_GET['settings-updated'] ) && true == $_GET['settings-updated'] ) { |
| 196 | ?> |
| 197 | <script> |
| 198 | jQuery(document).ready( function() { |
| 199 | jQuery('.asenha-changes-saved').fadeIn(400).delay(2500).fadeOut(400); |
| 200 | }); |
| 201 | </script> |
| 202 | |
| 203 | <?php |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Suppress all generic notices on the plugin settings page |
| 209 | * |
| 210 | * @since 2.7.0 |
| 211 | */ |
| 212 | function asenha_suppress_generic_notices() |
| 213 | { |
| 214 | global $plugin_page ; |
| 215 | // Suppress all notices |
| 216 | if ( ASENHA_SLUG === $plugin_page ) { |
| 217 | remove_all_actions( 'all_admin_notices' ); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Enqueue admin scripts |
| 223 | * |
| 224 | * @since 1.0.0 |
| 225 | */ |
| 226 | function asenha_admin_scripts( $hook_suffix ) |
| 227 | { |
| 228 | global |
| 229 | $wp_version, |
| 230 | $pagenow, |
| 231 | $typenow, |
| 232 | $taxnow, |
| 233 | $hook_suffix |
| 234 | ; |
| 235 | $current_screen = get_current_screen(); |
| 236 | // Get all WP Enhancements options, default to empty array in case it's not been created yet |
| 237 | $options = get_option( 'admin_site_enhancements', array() ); |
| 238 | // For main page of this plugin |
| 239 | |
| 240 | if ( is_asenha() ) { |
| 241 | wp_enqueue_style( |
| 242 | 'asenha-jbox', |
| 243 | ASENHA_URL . 'assets/css/jBox.all.min.css', |
| 244 | array(), |
| 245 | ASENHA_VERSION |
| 246 | ); |
| 247 | wp_enqueue_script( |
| 248 | 'asenha-jbox', |
| 249 | ASENHA_URL . 'assets/js/jBox.all.min.js', |
| 250 | array(), |
| 251 | ASENHA_VERSION, |
| 252 | false |
| 253 | ); |
| 254 | wp_enqueue_script( |
| 255 | 'asenha-jsticky', |
| 256 | ASENHA_URL . 'assets/js/jquery.jsticky.mod.min.js', |
| 257 | array( 'jquery' ), |
| 258 | ASENHA_VERSION, |
| 259 | false |
| 260 | ); |
| 261 | wp_enqueue_script( |
| 262 | 'asenha-js-cookie', |
| 263 | ASENHA_URL . 'assets/js/js.cookie.min.js', |
| 264 | array(), |
| 265 | ASENHA_VERSION, |
| 266 | false |
| 267 | ); |
| 268 | // jQuery UI Sortables. In use, e.g. for Admin Interface >> Admin Menu Organizer |
| 269 | // Re-register and re-enqueue jQuery UI Core and plugins required for sortable, draggable and droppable when ordering menu items |
| 270 | wp_deregister_script( 'jquery-ui-core' ); |
| 271 | wp_register_script( |
| 272 | 'jquery-ui-core', |
| 273 | get_site_url() . '/wp-includes/js/jquery/ui/core.min.js', |
| 274 | array( 'jquery' ), |
| 275 | ASENHA_VERSION, |
| 276 | false |
| 277 | ); |
| 278 | wp_enqueue_script( 'jquery-ui-core' ); |
| 279 | |
| 280 | if ( version_compare( $wp_version, '5.6.0', '>=' ) ) { |
| 281 | wp_deregister_script( 'jquery-ui-mouse' ); |
| 282 | wp_register_script( |
| 283 | 'jquery-ui-mouse', |
| 284 | get_site_url() . '/wp-includes/js/jquery/ui/mouse.min.js', |
| 285 | array( 'jquery-ui-core' ), |
| 286 | ASENHA_VERSION, |
| 287 | false |
| 288 | ); |
| 289 | wp_enqueue_script( 'jquery-ui-mouse' ); |
| 290 | } else { |
| 291 | wp_deregister_script( 'jquery-ui-widget' ); |
| 292 | wp_register_script( |
| 293 | 'jquery-ui-widget', |
| 294 | get_site_url() . '/wp-includes/js/jquery/ui/widget.min.js', |
| 295 | array( 'jquery' ), |
| 296 | ASENHA_VERSION, |
| 297 | false |
| 298 | ); |
| 299 | wp_enqueue_script( 'jquery-ui-widget' ); |
| 300 | wp_deregister_script( 'jquery-ui-mouse' ); |
| 301 | wp_register_script( |
| 302 | 'jquery-ui-mouse', |
| 303 | get_site_url() . '/wp-includes/js/jquery/ui/mouse.min.js', |
| 304 | array( 'jquery-ui-core', 'jquery-ui-widget' ), |
| 305 | ASENHA_VERSION, |
| 306 | false |
| 307 | ); |
| 308 | wp_enqueue_script( 'jquery-ui-mouse' ); |
| 309 | } |
| 310 | |
| 311 | wp_deregister_script( 'jquery-ui-sortable' ); |
| 312 | wp_register_script( |
| 313 | 'jquery-ui-sortable', |
| 314 | get_site_url() . '/wp-includes/js/jquery/ui/sortable.min.js', |
| 315 | array( 'jquery-ui-mouse' ), |
| 316 | ASENHA_VERSION, |
| 317 | false |
| 318 | ); |
| 319 | wp_enqueue_script( 'jquery-ui-sortable' ); |
| 320 | wp_deregister_script( 'jquery-ui-draggable' ); |
| 321 | wp_register_script( |
| 322 | 'jquery-ui-draggable', |
| 323 | get_site_url() . '/wp-includes/js/jquery/ui/draggable.min.js', |
| 324 | array( 'jquery-ui-mouse' ), |
| 325 | ASENHA_VERSION, |
| 326 | false |
| 327 | ); |
| 328 | wp_enqueue_script( 'jquery-ui-draggable' ); |
| 329 | wp_deregister_script( 'jquery-ui-droppable' ); |
| 330 | wp_register_script( |
| 331 | 'jquery-ui-droppable', |
| 332 | get_site_url() . '/wp-includes/js/jquery/ui/droppable.min.js', |
| 333 | array( 'jquery-ui-draggable' ), |
| 334 | ASENHA_VERSION, |
| 335 | false |
| 336 | ); |
| 337 | wp_enqueue_script( 'jquery-ui-droppable' ); |
| 338 | // Script to set behaviour and actions of the sortable menu |
| 339 | wp_enqueue_script( |
| 340 | 'asenha-custom-admin-menu', |
| 341 | ASENHA_URL . 'assets/js/custom-admin-menu.js', |
| 342 | array( 'jquery-ui-draggable' ), |
| 343 | ASENHA_VERSION, |
| 344 | false |
| 345 | ); |
| 346 | // CodeMirror. In use, e.g. for Utilities >> Enable Custom Admin / Frontend CSS / ads.txt / app-ads.txt |
| 347 | wp_enqueue_style( |
| 348 | 'asenha-codemirror', |
| 349 | ASENHA_URL . 'assets/css/codemirror/codemirror.min.css', |
| 350 | array(), |
| 351 | ASENHA_VERSION |
| 352 | ); |
| 353 | wp_enqueue_script( |
| 354 | 'asenha-codemirror', |
| 355 | ASENHA_URL . 'assets/js/codemirror/codemirror.min.js', |
| 356 | array(), |
| 357 | ASENHA_VERSION, |
| 358 | true |
| 359 | ); |
| 360 | wp_enqueue_script( |
| 361 | 'asenha-codemirror-htmlmixed-mode', |
| 362 | ASENHA_URL . 'assets/js/codemirror/htmlmixed.js', |
| 363 | array( 'asenha-codemirror' ), |
| 364 | ASENHA_VERSION, |
| 365 | true |
| 366 | ); |
| 367 | wp_enqueue_script( |
| 368 | 'asenha-codemirror-xml-mode', |
| 369 | ASENHA_URL . 'assets/js/codemirror/xml.js', |
| 370 | array( 'asenha-codemirror' ), |
| 371 | ASENHA_VERSION, |
| 372 | true |
| 373 | ); |
| 374 | wp_enqueue_script( |
| 375 | 'asenha-codemirror-javascript-mode', |
| 376 | ASENHA_URL . 'assets/js/codemirror/javascript.js', |
| 377 | array( 'asenha-codemirror' ), |
| 378 | ASENHA_VERSION, |
| 379 | true |
| 380 | ); |
| 381 | wp_enqueue_script( |
| 382 | 'asenha-codemirror-css-mode', |
| 383 | ASENHA_URL . 'assets/js/codemirror/css.js', |
| 384 | array( 'asenha-codemirror' ), |
| 385 | ASENHA_VERSION, |
| 386 | true |
| 387 | ); |
| 388 | wp_enqueue_script( |
| 389 | 'asenha-codemirror-markdown-mode', |
| 390 | ASENHA_URL . 'assets/js/codemirror/markdown.js', |
| 391 | array( 'asenha-codemirror' ), |
| 392 | ASENHA_VERSION, |
| 393 | true |
| 394 | ); |
| 395 | // DataTables. In use, e.g. for Security >> Limit Login Attempts |
| 396 | wp_enqueue_style( |
| 397 | 'asenha-datatables', |
| 398 | ASENHA_URL . 'assets/css/datatables/datatables.min.css', |
| 399 | array(), |
| 400 | ASENHA_VERSION |
| 401 | ); |
| 402 | wp_enqueue_script( |
| 403 | 'asenha-datatables', |
| 404 | ASENHA_URL . 'assets/js/datatables/datatables.min.js', |
| 405 | array( 'jquery' ), |
| 406 | ASENHA_VERSION, |
| 407 | false |
| 408 | ); |
| 409 | // Main style and script for the admin page |
| 410 | wp_enqueue_style( |
| 411 | 'asenha-admin-page', |
| 412 | ASENHA_URL . 'assets/css/admin-page.css', |
| 413 | array( 'asenha-jbox', 'asenha-codemirror', 'asenha-datatables' ), |
| 414 | ASENHA_VERSION |
| 415 | ); |
| 416 | wp_enqueue_script( |
| 417 | 'asenha-admin-page', |
| 418 | ASENHA_URL . 'assets/js/admin-page.js', |
| 419 | array( |
| 420 | 'asenha-jsticky', |
| 421 | 'asenha-jbox', |
| 422 | 'asenha-js-cookie', |
| 423 | 'asenha-codemirror-htmlmixed-mode', |
| 424 | 'asenha-codemirror-xml-mode', |
| 425 | 'asenha-codemirror-javascript-mode', |
| 426 | 'asenha-codemirror-css-mode', |
| 427 | 'asenha-codemirror-markdown-mode', |
| 428 | 'asenha-datatables', |
| 429 | 'asenha-custom-admin-menu' |
| 430 | ), |
| 431 | ASENHA_VERSION, |
| 432 | false |
| 433 | ); |
| 434 | } |
| 435 | |
| 436 | // Enqueue on all wp-admin |
| 437 | wp_enqueue_style( |
| 438 | 'asenha-wp-admin', |
| 439 | ASENHA_URL . 'assets/css/wp-admin.css', |
| 440 | array(), |
| 441 | ASENHA_VERSION |
| 442 | ); |
| 443 | // Content Management >> Show IDs, for list tables in wp-admin, e.g. All Posts page |
| 444 | if ( false !== strpos( $current_screen->base, 'edit' ) || false !== strpos( $current_screen->base, 'users' ) || false !== strpos( $current_screen->base, 'upload' ) ) { |
| 445 | wp_enqueue_style( |
| 446 | 'asenha-list-table', |
| 447 | ASENHA_URL . 'assets/css/list-table.css', |
| 448 | array(), |
| 449 | ASENHA_VERSION |
| 450 | ); |
| 451 | } |
| 452 | // Content Management >> Enable Media Replacement |
| 453 | |
| 454 | if ( $current_screen->base == 'upload' || $current_screen->id == 'attachment' ) { |
| 455 | // wp_enqueue_style( 'asenha-jbox', ASENHA_URL . 'assets/css/jBox.all.min.css', array(), ASENHA_VERSION ); |
| 456 | // wp_enqueue_script( 'asenha-jbox', ASENHA_URL . 'assets/js/jBox.all.min.js', array(), ASENHA_VERSION, false ); |
| 457 | wp_enqueue_style( |
| 458 | 'asenha-media-replace', |
| 459 | ASENHA_URL . 'assets/css/media-replace.css', |
| 460 | array(), |
| 461 | ASENHA_VERSION |
| 462 | ); |
| 463 | wp_enqueue_script( |
| 464 | 'asenha-media-replace', |
| 465 | ASENHA_URL . 'assets/js/media-replace.js', |
| 466 | array(), |
| 467 | ASENHA_VERSION, |
| 468 | false |
| 469 | ); |
| 470 | } |
| 471 | |
| 472 | // Content Management >> Hide Admin Notices |
| 473 | |
| 474 | if ( array_key_exists( 'hide_admin_notices', $options ) && $options['hide_admin_notices'] ) { |
| 475 | wp_enqueue_style( |
| 476 | 'asenha-jbox', |
| 477 | ASENHA_URL . 'assets/css/jBox.all.min.css', |
| 478 | array(), |
| 479 | ASENHA_VERSION |
| 480 | ); |
| 481 | wp_enqueue_script( |
| 482 | 'asenha-jbox', |
| 483 | ASENHA_URL . 'assets/js/jBox.all.min.js', |
| 484 | array(), |
| 485 | ASENHA_VERSION, |
| 486 | false |
| 487 | ); |
| 488 | wp_enqueue_style( |
| 489 | 'asenha-hide-admin-notices', |
| 490 | ASENHA_URL . 'assets/css/hide-admin-notices.css', |
| 491 | array(), |
| 492 | ASENHA_VERSION |
| 493 | ); |
| 494 | wp_enqueue_script( |
| 495 | 'asenha-hide-admin-notices', |
| 496 | ASENHA_URL . 'assets/js/hide-admin-notices.js', |
| 497 | array( 'asenha-jbox' ), |
| 498 | ASENHA_VERSION, |
| 499 | false |
| 500 | ); |
| 501 | } |
| 502 | |
| 503 | // Utilities >> Multiple User Roles |
| 504 | if ( array_key_exists( 'multiple_user_roles', $options ) && $options['multiple_user_roles'] ) { |
| 505 | if ( 'user-edit.php' == $hook_suffix || 'user-new.php' == $hook_suffix ) { |
| 506 | // Only replace roles dropdown with checkboxes for users that can assign roles to other users, e.g. administrators |
| 507 | if ( current_user_can( 'promote_users', get_current_user_id() ) ) { |
| 508 | wp_enqueue_script( |
| 509 | 'asenha-multiple-user-roles', |
| 510 | ASENHA_URL . 'assets/js/multiple-user-roles.js', |
| 511 | array( 'jquery' ), |
| 512 | ASENHA_VERSION, |
| 513 | false |
| 514 | ); |
| 515 | } |
| 516 | } |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | /** |
| 521 | * Enqueue public scripts |
| 522 | * |
| 523 | * @since 3.9.0 |
| 524 | */ |
| 525 | function asenha_public_scripts( $hook_suffix ) |
| 526 | { |
| 527 | // Get all WP Enhancements options, default to empty array in case it's not been created yet |
| 528 | $options = get_option( 'admin_site_enhancements', array() ); |
| 529 | |
| 530 | if ( array_key_exists( 'enable_external_permalinks', $options ) ) { |
| 531 | $enable_external_permalinks = $options['enable_external_permalinks']; |
| 532 | } else { |
| 533 | $enable_external_permalinks = false; |
| 534 | } |
| 535 | |
| 536 | wp_enqueue_script( |
| 537 | 'asenha-public', |
| 538 | ASENHA_URL . 'assets/js/public.js', |
| 539 | array( 'jquery' ), |
| 540 | ASENHA_VERSION, |
| 541 | false |
| 542 | ); |
| 543 | wp_localize_script( 'asenha-public', 'phpVars', array( |
| 544 | 'externalPermalinksEnabled' => $enable_external_permalinks, |
| 545 | ) ); |
| 546 | } |
| 547 | |
| 548 | /** |
| 549 | * Add 'Access now' plugin action link. |
| 550 | * |
| 551 | * @since 1.0.0 |
| 552 | */ |
| 553 | function asenha_plugin_action_links( $links ) |
| 554 | { |
| 555 | $settings_link = '<a href="tools.php?page=' . ASENHA_SLUG . '">Configure now</a>'; |
| 556 | array_unshift( $links, $settings_link ); |
| 557 | return $links; |
| 558 | } |
| 559 | |
| 560 | /** |
| 561 | * Modify footer text |
| 562 | * |
| 563 | * @since 1.0.0 |
| 564 | */ |
| 565 | function asenha_footer_text() |
| 566 | { |
| 567 | if ( is_asenha() ) { |
| 568 | ?> |
| 569 | <a href="https://bowo.io/asenha-dotorg" target="_blank">Admin Site Enhancements</a> is on <a href="https://bowo.io/asenha-gthb" target="_blank">github</a>. |
| 570 | <?php |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | /** |
| 575 | * Change WP version number text in footer |
| 576 | * |
| 577 | * @since 4.8.3 |
| 578 | */ |
| 579 | function asenha_footer_version_text() |
| 580 | { |
| 581 | ?> |
| 582 | Also by Bowo → <a href="https://bowo.io/asenha-wpn" target="_blank">WordPress Newsboard</a>: The latest from 100+ sources |
| 583 | <?php |
| 584 | } |
| 585 | |
| 586 | /** |
| 587 | * Check if current screen is this plugin's main page |
| 588 | * |
| 589 | * @since 1.0.0 |
| 590 | */ |
| 591 | function is_asenha() |
| 592 | { |
| 593 | $request_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] ); |
| 594 | // e.g. /wp-admin/index.php?page=page-slug |
| 595 | |
| 596 | if ( strpos( $request_uri, 'page=' . ASENHA_SLUG ) !== false ) { |
| 597 | return true; |
| 598 | // Yes, this is the plugin's main page |
| 599 | } else { |
| 600 | return false; |
| 601 | // Nope, this is NOT the plugin's page |
| 602 | } |
| 603 | |
| 604 | } |
| 605 |