admin-site-enhancements
Last commit date
assets
2 years ago
classes
2 years ago
includes
2 years ago
languages
2 years ago
vendor
2 years ago
CHANGELOG.md
2 years ago
LICENSE.md
2 years ago
README.md
2 years ago
admin-site-enhancements.php
2 years ago
bootstrap.php
2 years ago
functions.php
2 years ago
settings.php
2 years ago
settings.php
1042 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Initialize options. [TODO] Move this into activation class at v7. |
| 5 | * |
| 6 | * @since 6.4.1 |
| 7 | */ |
| 8 | if ( false === get_option( ASENHA_SLUG_U ) ) { |
| 9 | add_option( ASENHA_SLUG_U, array(), true ); |
| 10 | } |
| 11 | if ( false === get_option( ASENHA_SLUG_U . '_stats' ) ) { |
| 12 | add_option( ASENHA_SLUG_U . '_stats', array(), false ); |
| 13 | } |
| 14 | if ( false === get_option( ASENHA_SLUG_U . '_extra' ) ) { |
| 15 | add_option( ASENHA_SLUG_U . '_extra', array(), true ); |
| 16 | } |
| 17 | // Bugfix in v7.1.2 for Custom Content Type module |
| 18 | $options_extra = get_option( ASENHA_SLUG_U . '_extra', array() ); |
| 19 | if ( !isset( $options_extra['cfgroup_next_field_id'] ) ) { |
| 20 | $options_extra['cfgroup_next_field_id'] = 1; |
| 21 | update_option( ASENHA_SLUG_U . '_extra', $options_extra, true ); |
| 22 | } |
| 23 | /** |
| 24 | * Register admin menu |
| 25 | * |
| 26 | * @since 1.0.0 |
| 27 | */ |
| 28 | function asenha_register_admin_menu() { |
| 29 | add_submenu_page( |
| 30 | 'tools.php', |
| 31 | // Parent page/menu |
| 32 | 'Admin and Site Enhancements', |
| 33 | // Browser tab/window title |
| 34 | __( 'Enhancements', 'admin-site-enhancements' ), |
| 35 | // Sube menu title |
| 36 | 'manage_options', |
| 37 | // Minimal user capabililty |
| 38 | ASENHA_SLUG, |
| 39 | // Page slug. Shows up in URL. |
| 40 | 'asenha_add_settings_page' |
| 41 | ); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Create the settings page of the plugin |
| 46 | * |
| 47 | * @since 1.0.0 |
| 48 | */ |
| 49 | function asenha_add_settings_page() { |
| 50 | ?> |
| 51 | <div class="wrap asenha"> |
| 52 | |
| 53 | <div id="asenha-header" class="asenha-header"> |
| 54 | <div class="asenha-header-left"> |
| 55 | <img src="<?php |
| 56 | echo esc_html( ASENHA_URL ) . 'assets/img/ase_icon.png'; |
| 57 | ?>" class="asenha-icon"/> |
| 58 | <h1 class="asenha-heading"> |
| 59 | <?php |
| 60 | echo esc_html( get_admin_page_title() ); |
| 61 | ?> |
| 62 | (ASE) |
| 63 | <?php |
| 64 | ?> |
| 65 | </h1> |
| 66 | <!-- <a href="https://wordpress.org/plugins/admin-site-enhancements/" target="_blank" class="asenha-header-action"><span>ℹ</span> <?php |
| 67 | // esc_html_e( 'Info', 'admin-site-enhancements' ); |
| 68 | ?></a> --> |
| 69 | </div> |
| 70 | <div class="asenha-header-right"> |
| 71 | <?php |
| 72 | // https://icon-sets.iconify.design/iconamoon/star-bold/ |
| 73 | $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>'; |
| 74 | // https://icon-sets.iconify.design/octicon/question-16/ |
| 75 | $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>'; |
| 76 | // https://icon-sets.iconify.design/octicon/comment-16/ |
| 77 | $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>'; |
| 78 | // https://icon-sets.iconify.design/ic/baseline-translate/ |
| 79 | $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>'; |
| 80 | // https://icon-sets.iconify.design/iconamoon/file-document/ |
| 81 | $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>'; |
| 82 | // https://icon-sets.iconify.design/pajamas/heart/ |
| 83 | $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>'; |
| 84 | ?> |
| 85 | <a href="https://wordpress.org/plugins/admin-site-enhancements/#reviews" target="_blank" class="asenha-header-action review"><?php |
| 86 | echo wp_kses( $svg_star, get_kses_with_svg_ruleset() ) . esc_html__( 'Review', 'admin-site-enhancements' ); |
| 87 | ?></a> |
| 88 | <a href="https://wordpress.org/support/plugin/admin-site-enhancements/" target="_blank" class="asenha-header-action feedback"><?php |
| 89 | echo wp_kses( $svg_feedback, get_kses_with_svg_ruleset() ) . esc_html__( 'Feedback', 'admin-site-enhancements' ); |
| 90 | ?></a> |
| 91 | <a href="https://www.wpase.com/trnslt-plgnhdr" target="_blank" class="asenha-header-action translate"><?php |
| 92 | echo wp_kses( $svg_translate, get_kses_with_svg_ruleset() ) . esc_html__( 'Translate', 'admin-site-enhancements' ); |
| 93 | ?></a> |
| 94 | <!--<a href="https://www.wpasenha.com/docs/" target="_blank" class="asenha-header-action docs"><?php |
| 95 | // echo $svg_docs . esc_html__( 'Docs', 'admin-site-enhancements' ); |
| 96 | ?></a>--> |
| 97 | <!--<a id="plugin-sponsor" href="#" class="asenha-header-action sponsor"><?php |
| 98 | // echo $svg_sponsor . esc_html__( 'Sponsor', 'admin-site-enhancements' ); |
| 99 | ?></a>--> |
| 100 | <a href="https://www.wpase.com/upgrade-btn" target="_blank" id="plugin-upgrade" class="button button-primary plugin-upgrade"><?php |
| 101 | echo esc_html__( 'Get ASE Pro', 'admin-site-enhancements' ); |
| 102 | ?></a> |
| 103 | <?php |
| 104 | ?> |
| 105 | <a class="button button-primary asenha-save-button"><?php |
| 106 | echo esc_html__( 'Save Changes', 'admin-site-enhancements' ); |
| 107 | ?></a> |
| 108 | <!-- https://icon-sets.iconify.design/svg-spinners/180-ring-with-bg/ --> |
| 109 | <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> |
| 110 | <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> |
| 111 | </div> |
| 112 | </div> |
| 113 | |
| 114 | <div class="asenha-body"> |
| 115 | <?php |
| 116 | ?> |
| 117 | <div class="asenha-upgrade-nudge" style="display: none;"> |
| 118 | <div class="asenha-upgrade-nudge__message"><?php |
| 119 | echo esc_html__( 'The Pro version of ASE is here! Lifetime Deal (LTD) available.', 'admin-site-enhancements' ); |
| 120 | ?></div> |
| 121 | <a href="https://www.wpase.com/upgrade-ndg" class="button asenha-upgrade-nudge__button" target="_blank"><?php |
| 122 | echo esc_html__( 'Find Out More', 'admin-site-enhancements' ); |
| 123 | ?></a> |
| 124 | <a href="#" id="dismiss-upgrade-nudge" class="asenha-upgrade-nudge__dismiss"> |
| 125 | <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> |
| 126 | </a> |
| 127 | </div> |
| 128 | <div class="asenha-support-nudge nudge-show-more is-enabled" style="display: none;"> |
| 129 | <h3><?php |
| 130 | _e( 'Looks like some of these free enhancements have been useful for your site?', 'admin-site-enhancements' ); |
| 131 | ?></h3> |
| 132 | <p class="nudge-description intro"><?php |
| 133 | _e( 'Please consider supporting ASE.', 'admin-site-enhancements' ); |
| 134 | ?></p> |
| 135 | <div class="nudge-content"> |
| 136 | <div class="nudge-primary"> |
| 137 | <h4><?php |
| 138 | _e( 'Write a quick, 5-star review for ASE', 'admin-site-enhancements' ); |
| 139 | ?></h4> |
| 140 | <div class="nudge-ctas"> |
| 141 | <a href="https://wordpress.org/plugins/admin-site-enhancements/#reviews" target="_blank" class="button button-outline asenha-review-button"><?php |
| 142 | _e( 'Add Your Review', 'admin-site-enhancements' ); |
| 143 | ?></a> |
| 144 | <a href="#" id="have-reviewed" class="asenha-have-supported"><?php |
| 145 | _e( 'I\'ve reviewed', 'admin-site-enhancements' ); |
| 146 | ?></a> |
| 147 | </div> |
| 148 | <p class="nudge-description"><?php |
| 149 | _e( 'Or, help improve ASE by <a href="https://wordpress.org/support/plugin/admin-site-enhancements/" target="_blank">providing feedback</a>.', 'admin-site-enhancements' ); |
| 150 | ?></p> |
| 151 | </div> |
| 152 | <div class="nudge-secondary"> |
| 153 | <h4><?php |
| 154 | _e( 'Share about ASE on:', 'admin-site-enhancements' ); |
| 155 | ?></h4> |
| 156 | <div class="nudge-ctas"> |
| 157 | <a href="https://www.facebook.com/sharer.php?u=<?php |
| 158 | echo urlencode( 'https://www.wpase.com' ); |
| 159 | ?>" target="_blank" class="button button-outline asenha-share-button"><?php |
| 160 | _e( 'Facebook', 'admin-site-enhancements' ); |
| 161 | ?></a> |
| 162 | <a href="https://twitter.com/intent/post?url=<?php |
| 163 | echo urlencode( 'https://www.wpase.com' ); |
| 164 | ?>&text=<?php |
| 165 | echo esc_attr( urlencode( 'Admin and Site Enhancements (ASE)' ) ); |
| 166 | ?>" target="_blank" class="button button-outline asenha-share-button"><?php |
| 167 | _e( 'X / Twitter', 'admin-site-enhancements' ); |
| 168 | ?></a> |
| 169 | <a href="https://www.wpase.com/video-reviews/" target="_blank" class="button button-outline asenha-share-button"><?php |
| 170 | _e( 'YouTube', 'admin-site-enhancements' ); |
| 171 | ?></a> |
| 172 | <a href="#" id="have-shared" class="asenha-have-supported"><?php |
| 173 | _e( 'I\'ve shared', 'admin-site-enhancements' ); |
| 174 | ?></a> |
| 175 | </div> |
| 176 | <div class="nudge-info"> |
| 177 | <p class="nudge-description"><?php |
| 178 | _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' ); |
| 179 | ?></p> |
| 180 | </div> |
| 181 | </div> |
| 182 | </div> |
| 183 | <div class="dismiss-support-nudge"><a href="#" id="support-nudge-dismiss" class="asenha-support-nudge-dismiss"><?php |
| 184 | _e( 'Dismiss', 'admin-site-enhancements' ); |
| 185 | ?></a></div> |
| 186 | </div> |
| 187 | <?php |
| 188 | ?> |
| 189 | <form action="options.php" method="post"> |
| 190 | <div class="asenha-vertical-tabs"> |
| 191 | <div class="asenha-tab-buttons"> |
| 192 | <?php |
| 193 | // https://icon-sets.iconify.design/mdi/database-check-outline/ -- db check |
| 194 | // https://icon-sets.iconify.design/mdi/file-document-box-multiple-outline/ -- docs |
| 195 | // https://icon-sets.iconify.design/fluent/content-view-28-regular/ -- content |
| 196 | // https://icon-sets.iconify.design/lucide/shapes/ -- shapes |
| 197 | $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>'; |
| 198 | // https://icon-sets.iconify.design/mingcute/layout-line/ |
| 199 | $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>'; |
| 200 | // https://icon-sets.iconify.design/ri/login-circle-line/ |
| 201 | $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>'; |
| 202 | // https://icon-sets.iconify.design/mingcute/code-line/ |
| 203 | $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>'; |
| 204 | // https://icon-sets.iconify.design/mdi/forbid/ |
| 205 | $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>'; |
| 206 | // https://icon-sets.iconify.design/jam/shield-check/ |
| 207 | $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>'; |
| 208 | // https://icon-sets.iconify.design/streamline/image-flash-1-flash-power-connect-charge-electricity-lightning/ |
| 209 | $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>'; |
| 210 | // https://icon-sets.iconify.design/iconoir/tools/ |
| 211 | $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>'; |
| 212 | ?> |
| 213 | <input id="tab-content-management" type="radio" name="tabs" checked><label for="tab-content-management"><?php |
| 214 | echo wp_kses( $icon_content_management, get_kses_with_svg_ruleset() ); |
| 215 | echo esc_html__( 'Content Management', 'admin-site-enhancements' ); |
| 216 | ?></label> |
| 217 | <input id="tab-admin-interface" type="radio" name="tabs"><label for="tab-admin-interface"><?php |
| 218 | echo wp_kses( $icon_admin_interface, get_kses_with_svg_ruleset() ); |
| 219 | echo esc_html__( 'Admin Interface', 'admin-site-enhancements' ); |
| 220 | ?></label> |
| 221 | <input id="tab-login-logout" type="radio" name="tabs"><label for="tab-login-logout"><?php |
| 222 | echo wp_kses( $icon_login_logout, get_kses_with_svg_ruleset() ); |
| 223 | echo esc_html__( 'Log In | Log Out', 'admin-site-enhancements' ); |
| 224 | ?></label> |
| 225 | <input id="tab-custom-code" type="radio" name="tabs"><label for="tab-custom-code"><?php |
| 226 | echo wp_kses( $icon_custom_code, get_kses_with_svg_ruleset() ); |
| 227 | echo esc_html__( 'Custom Code', 'admin-site-enhancements' ); |
| 228 | ?></label> |
| 229 | <input id="tab-disable-components" type="radio" name="tabs"><label for="tab-disable-components"><?php |
| 230 | echo wp_kses( $icon_disable_components, get_kses_with_svg_ruleset() ); |
| 231 | echo esc_html__( 'Disable Components', 'admin-site-enhancements' ); |
| 232 | ?></label> |
| 233 | <input id="tab-security" type="radio" name="tabs"><label for="tab-security"><?php |
| 234 | echo wp_kses( $icon_security, get_kses_with_svg_ruleset() ); |
| 235 | echo esc_html__( 'Security', 'admin-site-enhancements' ); |
| 236 | ?></label> |
| 237 | <input id="tab-optimizations" type="radio" name="tabs"><label for="tab-optimizations"><?php |
| 238 | echo wp_kses( $icon_optimizations, get_kses_with_svg_ruleset() ); |
| 239 | echo esc_html__( 'Optimizations', 'admin-site-enhancements' ); |
| 240 | ?></label> |
| 241 | <input id="tab-utilities" type="radio" name="tabs"><label for="tab-utilities"><?php |
| 242 | echo wp_kses( $icon_utilities, get_kses_with_svg_ruleset() ); |
| 243 | echo esc_html__( 'Utilities', 'admin-site-enhancements' ); |
| 244 | ?></label> |
| 245 | </div> |
| 246 | <div class="asenha-tab-contents"> |
| 247 | <section class="asenha-fields fields-content-management"> |
| 248 | <table class="form-table" role="presentation"> |
| 249 | <tbody></tbody> |
| 250 | </table> |
| 251 | </section> |
| 252 | <section class="asenha-fields fields-admin-interface"> |
| 253 | <table class="form-table" role="presentation"> |
| 254 | <tbody></tbody> |
| 255 | </table> |
| 256 | </section> |
| 257 | <section class="asenha-fields fields-login-logout"> |
| 258 | <table class="form-table" role="presentation"> |
| 259 | <tbody></tbody> |
| 260 | </table> |
| 261 | </section> |
| 262 | <section class="asenha-fields fields-custom-code"> |
| 263 | <table class="form-table" role="presentation"> |
| 264 | <tbody></tbody> |
| 265 | </table> |
| 266 | </section> |
| 267 | <section class="asenha-fields fields-disable-components"> |
| 268 | <table class="form-table" role="presentation"> |
| 269 | <tbody></tbody> |
| 270 | </table> |
| 271 | </section> |
| 272 | <section class="asenha-fields fields-security"> |
| 273 | <table class="form-table" role="presentation"> |
| 274 | <tbody></tbody> |
| 275 | </table> |
| 276 | </section> |
| 277 | <section class="asenha-fields fields-optimizations"> |
| 278 | <table class="form-table" role="presentation"> |
| 279 | <tbody></tbody> |
| 280 | </table> |
| 281 | </section> |
| 282 | <section class="asenha-fields fields-utilities"> |
| 283 | <table class="form-table" role="presentation"> |
| 284 | <tbody></tbody> |
| 285 | </table> |
| 286 | </section> |
| 287 | </div> |
| 288 | </div> |
| 289 | <div style="display:none;"><!-- Hide to prevent flash of fields appearing at the bottom of the page --> |
| 290 | <?php |
| 291 | settings_fields( ASENHA_ID ); |
| 292 | ?> |
| 293 | <?php |
| 294 | do_settings_sections( ASENHA_SLUG ); |
| 295 | ?> |
| 296 | <?php |
| 297 | submit_button( |
| 298 | __( 'Save Changes', 'admin-site-enhancements' ), |
| 299 | // Button copy |
| 300 | 'primary', |
| 301 | // Type: 'primary', 'small', or 'large' |
| 302 | 'submit', |
| 303 | // The 'name' attribute |
| 304 | true, |
| 305 | // Whether to wrap in <p> tag |
| 306 | array( |
| 307 | 'id' => 'asenha-submit', |
| 308 | ) |
| 309 | ); |
| 310 | ?> |
| 311 | </div> |
| 312 | </form> |
| 313 | <?php |
| 314 | ?> |
| 315 | <div id="bottom-upgrade-nudge" class="asenha-upgrade-nudge-bottom" style="display:none;"> |
| 316 | <div class="asenha-upgrade-nudge-bottom__message"><?php |
| 317 | 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' ); |
| 318 | ?></div> |
| 319 | </div> |
| 320 | <?php |
| 321 | ?> |
| 322 | </div> |
| 323 | |
| 324 | <?php |
| 325 | ?> |
| 326 | |
| 327 | </div> |
| 328 | <?php |
| 329 | // Record the number of times changes were saved as well as the date of last save |
| 330 | $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() ); |
| 331 | $changes_saved = ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ? true : false ); |
| 332 | if ( $changes_saved ) { |
| 333 | $current_date = date( 'Y-m-d', time() ); |
| 334 | if ( !isset( $asenha_stats['first_save_date'] ) ) { |
| 335 | $asenha_stats['first_save_date'] = $current_date; |
| 336 | $asenha_stats['last_save_date'] = $current_date; |
| 337 | $asenha_stats['save_count'] = 1; |
| 338 | $asenha_stats['have_supported'] = false; |
| 339 | $asenha_stats['support_nudge_dismissed'] = false; |
| 340 | $asenha_stats['support_nudge_last_shown_date'] = ''; |
| 341 | $asenha_stats['support_nudge_last_shown_save_count'] = 0; |
| 342 | } else { |
| 343 | $asenha_stats['last_save_date'] = $current_date; |
| 344 | $save_count = $asenha_stats['save_count']; |
| 345 | $save_count++; |
| 346 | $asenha_stats['save_count'] = $save_count; |
| 347 | } |
| 348 | update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false ); |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * Suppress all notices, then add notice for successful settings update |
| 354 | * |
| 355 | * @since 1.1.0 |
| 356 | */ |
| 357 | function asenha_suppress_add_notices() { |
| 358 | global $plugin_page; |
| 359 | // Suppress all notices |
| 360 | if ( ASENHA_SLUG === $plugin_page ) { |
| 361 | remove_all_actions( 'admin_notices' ); |
| 362 | } |
| 363 | // Add notice for successful settings update |
| 364 | if ( isset( $_GET['page'] ) && ASENHA_SLUG == $_GET['page'] && isset( $_GET['settings-updated'] ) && true == $_GET['settings-updated'] ) { |
| 365 | ?> |
| 366 | <script> |
| 367 | jQuery(document).ready( function() { |
| 368 | jQuery('.asenha-changes-saved').fadeIn(400).delay(2500).fadeOut(400); |
| 369 | }); |
| 370 | </script> |
| 371 | |
| 372 | <?php |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | /** |
| 377 | * Suppress all generic notices on the plugin settings page |
| 378 | * |
| 379 | * @since 2.7.0 |
| 380 | */ |
| 381 | function asenha_suppress_generic_notices() { |
| 382 | global $plugin_page; |
| 383 | // Suppress all notices |
| 384 | if ( ASENHA_SLUG === $plugin_page ) { |
| 385 | remove_all_actions( 'all_admin_notices' ); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | /** |
| 390 | * Enqueue admin scripts |
| 391 | * |
| 392 | * @since 1.0.0 |
| 393 | */ |
| 394 | function asenha_admin_scripts( $hook_suffix ) { |
| 395 | global |
| 396 | $wp_version, |
| 397 | $pagenow, |
| 398 | $typenow, |
| 399 | $taxnow, |
| 400 | $hook_suffix, |
| 401 | $current_user |
| 402 | ; |
| 403 | $current_screen = get_current_screen(); |
| 404 | // Get all WP Enhancements options, default to empty array in case it's not been created yet |
| 405 | $options = get_option( 'admin_site_enhancements', array() ); |
| 406 | // For main page of this plugin |
| 407 | if ( is_asenha() ) { |
| 408 | wp_enqueue_style( |
| 409 | 'asenha-jbox', |
| 410 | ASENHA_URL . 'assets/css/jBox.all.min.css', |
| 411 | array(), |
| 412 | ASENHA_VERSION |
| 413 | ); |
| 414 | wp_enqueue_script( |
| 415 | 'asenha-jbox', |
| 416 | ASENHA_URL . 'assets/js/jBox.all.min.js', |
| 417 | array(), |
| 418 | ASENHA_VERSION, |
| 419 | false |
| 420 | ); |
| 421 | wp_enqueue_script( |
| 422 | 'asenha-jsticky', |
| 423 | ASENHA_URL . 'assets/js/jquery.jsticky.mod.min.js', |
| 424 | array('jquery'), |
| 425 | ASENHA_VERSION, |
| 426 | false |
| 427 | ); |
| 428 | wp_enqueue_script( |
| 429 | 'asenha-js-cookie', |
| 430 | ASENHA_URL . 'assets/js/js.cookie.min.js', |
| 431 | array(), |
| 432 | ASENHA_VERSION, |
| 433 | false |
| 434 | ); |
| 435 | // jQuery UI Sortables. In use, e.g. for Admin Interface >> Admin Menu Organizer |
| 436 | // Re-register and re-enqueue jQuery UI Core and plugins required for sortable, draggable and droppable when ordering menu items |
| 437 | wp_deregister_script( 'jquery-ui-core' ); |
| 438 | wp_register_script( |
| 439 | 'jquery-ui-core', |
| 440 | get_site_url() . '/wp-includes/js/jquery/ui/core.min.js', |
| 441 | array('jquery'), |
| 442 | ASENHA_VERSION, |
| 443 | false |
| 444 | ); |
| 445 | wp_enqueue_script( 'jquery-ui-core' ); |
| 446 | if ( version_compare( $wp_version, '5.6.0', '>=' ) ) { |
| 447 | wp_deregister_script( 'jquery-ui-mouse' ); |
| 448 | wp_register_script( |
| 449 | 'jquery-ui-mouse', |
| 450 | get_site_url() . '/wp-includes/js/jquery/ui/mouse.min.js', |
| 451 | array('jquery-ui-core'), |
| 452 | ASENHA_VERSION, |
| 453 | false |
| 454 | ); |
| 455 | wp_enqueue_script( 'jquery-ui-mouse' ); |
| 456 | } else { |
| 457 | wp_deregister_script( 'jquery-ui-widget' ); |
| 458 | wp_register_script( |
| 459 | 'jquery-ui-widget', |
| 460 | get_site_url() . '/wp-includes/js/jquery/ui/widget.min.js', |
| 461 | array('jquery'), |
| 462 | ASENHA_VERSION, |
| 463 | false |
| 464 | ); |
| 465 | wp_enqueue_script( 'jquery-ui-widget' ); |
| 466 | wp_deregister_script( 'jquery-ui-mouse' ); |
| 467 | wp_register_script( |
| 468 | 'jquery-ui-mouse', |
| 469 | get_site_url() . '/wp-includes/js/jquery/ui/mouse.min.js', |
| 470 | array('jquery-ui-core', 'jquery-ui-widget'), |
| 471 | ASENHA_VERSION, |
| 472 | false |
| 473 | ); |
| 474 | wp_enqueue_script( 'jquery-ui-mouse' ); |
| 475 | } |
| 476 | wp_deregister_script( 'jquery-ui-sortable' ); |
| 477 | wp_register_script( |
| 478 | 'jquery-ui-sortable', |
| 479 | get_site_url() . '/wp-includes/js/jquery/ui/sortable.min.js', |
| 480 | array('jquery-ui-mouse'), |
| 481 | ASENHA_VERSION, |
| 482 | false |
| 483 | ); |
| 484 | wp_enqueue_script( 'jquery-ui-sortable' ); |
| 485 | wp_deregister_script( 'jquery-ui-draggable' ); |
| 486 | wp_register_script( |
| 487 | 'jquery-ui-draggable', |
| 488 | get_site_url() . '/wp-includes/js/jquery/ui/draggable.min.js', |
| 489 | array('jquery-ui-mouse'), |
| 490 | ASENHA_VERSION, |
| 491 | false |
| 492 | ); |
| 493 | wp_enqueue_script( 'jquery-ui-draggable' ); |
| 494 | wp_deregister_script( 'jquery-ui-droppable' ); |
| 495 | wp_register_script( |
| 496 | 'jquery-ui-droppable', |
| 497 | get_site_url() . '/wp-includes/js/jquery/ui/droppable.min.js', |
| 498 | array('jquery-ui-draggable'), |
| 499 | ASENHA_VERSION, |
| 500 | false |
| 501 | ); |
| 502 | wp_enqueue_script( 'jquery-ui-droppable' ); |
| 503 | // Script to set behaviour and actions of the sortable menu |
| 504 | wp_enqueue_script( |
| 505 | 'asenha-custom-admin-menu', |
| 506 | ASENHA_URL . 'assets/js/custom-admin-menu.js', |
| 507 | array('jquery-ui-draggable'), |
| 508 | ASENHA_VERSION, |
| 509 | false |
| 510 | ); |
| 511 | // First, we unload the CodeMirror libraries included in WP core |
| 512 | wp_deregister_script( 'wp-codemirror' ); |
| 513 | wp_deregister_script( 'code-editor' ); |
| 514 | wp_deregister_script( 'htmlhint' ); |
| 515 | wp_deregister_script( 'csslint' ); |
| 516 | wp_deregister_script( 'esprima' ); |
| 517 | wp_deregister_script( 'jshint' ); |
| 518 | // Then, we load ASENHA's CodeMirror libraries. In use, e.g. for Utilities >> Enable Custom Admin / Frontend CSS / ads.txt / app-ads.txt |
| 519 | wp_enqueue_style( |
| 520 | 'asenha-codemirror', |
| 521 | ASENHA_URL . 'assets/css/codemirror/codemirror.min.css', |
| 522 | array(), |
| 523 | ASENHA_VERSION |
| 524 | ); |
| 525 | wp_enqueue_script( |
| 526 | 'asenha-codemirror', |
| 527 | ASENHA_URL . 'assets/js/codemirror/codemirror.min.js', |
| 528 | array('jquery'), |
| 529 | ASENHA_VERSION, |
| 530 | true |
| 531 | ); |
| 532 | wp_enqueue_script( |
| 533 | 'asenha-codemirror-htmlmixed-mode', |
| 534 | ASENHA_URL . 'assets/js/codemirror/htmlmixed.js', |
| 535 | array('asenha-codemirror'), |
| 536 | ASENHA_VERSION, |
| 537 | true |
| 538 | ); |
| 539 | wp_enqueue_script( |
| 540 | 'asenha-codemirror-xml-mode', |
| 541 | ASENHA_URL . 'assets/js/codemirror/xml.js', |
| 542 | array('asenha-codemirror'), |
| 543 | ASENHA_VERSION, |
| 544 | true |
| 545 | ); |
| 546 | wp_enqueue_script( |
| 547 | 'asenha-codemirror-javascript-mode', |
| 548 | ASENHA_URL . 'assets/js/codemirror/javascript.js', |
| 549 | array('asenha-codemirror'), |
| 550 | ASENHA_VERSION, |
| 551 | true |
| 552 | ); |
| 553 | wp_enqueue_script( |
| 554 | 'asenha-codemirror-css-mode', |
| 555 | ASENHA_URL . 'assets/js/codemirror/css.js', |
| 556 | array('asenha-codemirror'), |
| 557 | ASENHA_VERSION, |
| 558 | true |
| 559 | ); |
| 560 | wp_enqueue_script( |
| 561 | 'asenha-codemirror-markdown-mode', |
| 562 | ASENHA_URL . 'assets/js/codemirror/markdown.js', |
| 563 | array('asenha-codemirror'), |
| 564 | ASENHA_VERSION, |
| 565 | true |
| 566 | ); |
| 567 | // DataTables. In use, e.g. for Security >> Limit Login Attempts |
| 568 | wp_enqueue_style( |
| 569 | 'asenha-datatables', |
| 570 | ASENHA_URL . 'assets/css/datatables/datatables.min.css', |
| 571 | array(), |
| 572 | ASENHA_VERSION |
| 573 | ); |
| 574 | wp_enqueue_script( |
| 575 | 'asenha-datatables', |
| 576 | ASENHA_URL . 'assets/js/datatables/datatables.min.js', |
| 577 | array('jquery'), |
| 578 | ASENHA_VERSION, |
| 579 | false |
| 580 | ); |
| 581 | // Add WP media library assets |
| 582 | wp_enqueue_media(); |
| 583 | // Add WP color picker assets |
| 584 | wp_enqueue_style( 'wp-color-picker' ); |
| 585 | wp_enqueue_script( 'wp-color-picker' ); |
| 586 | // We force loading the uncompressed version of TinyMCE. This ensures we load 'wp-tinymce-root' and then 'wp-tinymce', |
| 587 | // which prevents issue where the Visual tab is unusable in some scenarios |
| 588 | $wp_scripts = wp_scripts(); |
| 589 | $wp_scripts->remove( 'wp-tinymce' ); |
| 590 | wp_register_tinymce_scripts( $wp_scripts, true ); |
| 591 | // Main style and script for the admin page |
| 592 | wp_enqueue_style( |
| 593 | 'asenha-admin-page', |
| 594 | ASENHA_URL . 'assets/css/admin-page.css', |
| 595 | array( |
| 596 | 'asenha-jbox', |
| 597 | 'asenha-codemirror', |
| 598 | 'asenha-datatables', |
| 599 | 'wp-color-picker' |
| 600 | ), |
| 601 | ASENHA_VERSION |
| 602 | ); |
| 603 | wp_enqueue_script( |
| 604 | 'asenha-admin-page', |
| 605 | ASENHA_URL . 'assets/js/admin-page.js', |
| 606 | array( |
| 607 | 'asenha-jsticky', |
| 608 | 'asenha-jbox', |
| 609 | 'asenha-js-cookie', |
| 610 | 'asenha-codemirror-htmlmixed-mode', |
| 611 | 'asenha-codemirror-xml-mode', |
| 612 | 'asenha-codemirror-javascript-mode', |
| 613 | 'asenha-codemirror-css-mode', |
| 614 | 'asenha-codemirror-markdown-mode', |
| 615 | 'asenha-datatables', |
| 616 | 'asenha-custom-admin-menu', |
| 617 | 'wp-color-picker', |
| 618 | 'wp-mediaelement', |
| 619 | 'wp-tinymce-root', |
| 620 | 'wp-tinymce' |
| 621 | ), |
| 622 | ASENHA_VERSION, |
| 623 | false |
| 624 | ); |
| 625 | wp_localize_script( 'asenha-admin-page', 'adminPageVars', array( |
| 626 | 'siteUrl' => get_site_url(), |
| 627 | 'wpcontentUrl' => content_url(), |
| 628 | 'mediaFrameTitle' => __( 'Select an Image', 'admin-site-enhancements' ), |
| 629 | 'mediaFrameButtonText' => __( 'Use Selected Image', 'admin-site-enhancements' ), |
| 630 | 'resetMenuNonce' => wp_create_nonce( 'reset-menu-nonce' ), |
| 631 | 'expandText' => __( 'Expand', 'admin-site-enhancements' ), |
| 632 | 'collapseText' => __( 'Collapse', 'admin-site-enhancements' ), |
| 633 | 'dataTable' => array( |
| 634 | 'emptyTable' => __( 'No data available in table', 'admin-site-enhancements' ), |
| 635 | 'info' => __( 'Showing _START_ to _END_ of _TOTAL_ entries', 'admin-site-enhancements' ), |
| 636 | 'infoEmpty' => __( 'Showing 0 to 0 of 0 entries', 'admin-site-enhancements' ), |
| 637 | 'infoFiltered' => __( '(filtered from _MAX_ total entries)', 'admin-site-enhancements' ), |
| 638 | 'lengthMenu' => __( 'Show _MENU_ entries', 'admin-site-enhancements' ), |
| 639 | 'search' => __( 'Search:', 'admin-site-enhancements' ), |
| 640 | 'zeroRecords' => __( 'No matching records found', 'admin-site-enhancements' ), |
| 641 | 'paginate' => array( |
| 642 | 'first' => __( 'First', 'admin-site-enhancements' ), |
| 643 | 'last' => __( 'Last', 'admin-site-enhancements' ), |
| 644 | 'next' => __( 'Next', 'admin-site-enhancements' ), |
| 645 | 'previous' => __( 'Previous', 'admin-site-enhancements' ), |
| 646 | ), |
| 647 | ), |
| 648 | ) ); |
| 649 | } |
| 650 | // Enqueue on all wp-admin |
| 651 | wp_enqueue_style( |
| 652 | 'asenha-wp-admin', |
| 653 | ASENHA_URL . 'assets/css/wp-admin.css', |
| 654 | array(), |
| 655 | ASENHA_VERSION |
| 656 | ); |
| 657 | // Content Management >> Show IDs, for list tables in wp-admin, e.g. All Posts page |
| 658 | if ( false !== strpos( $current_screen->base, 'edit' ) || false !== strpos( $current_screen->base, 'users' ) || false !== strpos( $current_screen->base, 'upload' ) ) { |
| 659 | wp_enqueue_style( |
| 660 | 'asenha-list-table', |
| 661 | ASENHA_URL . 'assets/css/list-table.css', |
| 662 | array(), |
| 663 | ASENHA_VERSION |
| 664 | ); |
| 665 | } |
| 666 | // Content Management >> Enable Media Replacement |
| 667 | if ( $current_screen->base == 'upload' || $current_screen->id == 'attachment' ) { |
| 668 | // wp_enqueue_style( 'asenha-jbox', ASENHA_URL . 'assets/css/jBox.all.min.css', array(), ASENHA_VERSION ); |
| 669 | // wp_enqueue_script( 'asenha-jbox', ASENHA_URL . 'assets/js/jBox.all.min.js', array(), ASENHA_VERSION, false ); |
| 670 | wp_enqueue_style( |
| 671 | 'asenha-media-replace', |
| 672 | ASENHA_URL . 'assets/css/media-replace.css', |
| 673 | array(), |
| 674 | ASENHA_VERSION |
| 675 | ); |
| 676 | wp_enqueue_script( |
| 677 | 'asenha-media-replace', |
| 678 | ASENHA_URL . 'assets/js/media-replace.js', |
| 679 | array(), |
| 680 | ASENHA_VERSION, |
| 681 | false |
| 682 | ); |
| 683 | $media_replace = array( |
| 684 | 'selectMediaText' => __( 'Select New Media File', 'admin-site-enhancements' ), |
| 685 | 'performReplacementText' => __( 'Perform Replacement', 'admin-site-enhancements' ), |
| 686 | ); |
| 687 | wp_localize_script( 'asenha-media-replace', 'mediaReplace', $media_replace ); |
| 688 | } |
| 689 | // Utilities >> Email Delivery Log |
| 690 | if ( 'tools_page_email-delivery-log' == $hook_suffix ) { |
| 691 | wp_enqueue_style( 'jquery-ui-css', ASENHA_URL . 'assets/premium/css/jquery-ui/jquery-ui.min.css' ); |
| 692 | wp_enqueue_style( 'asenha-email-delivery-log', ASENHA_URL . 'assets/premium/css/email-delivery-log.css' ); |
| 693 | wp_enqueue_script( 'jquery-ui' ); |
| 694 | // wp_enqueue_script( 'jquery-ui-datepicker' ); |
| 695 | wp_enqueue_script( 'jquery-ui-tabs' ); |
| 696 | wp_enqueue_script( 'asenha-email-delivery-log', ASENHA_URL . 'assets/premium/js/email-delivery-log.js' ); |
| 697 | $nonce = wp_create_nonce( 'email-delivery-log' . get_current_user_id() ); |
| 698 | wp_localize_script( 'asenha-email-delivery-log', 'emailLog', array( |
| 699 | 'nonce' => $nonce, |
| 700 | ) ); |
| 701 | } |
| 702 | // Utilities >> Image Sizes Panel |
| 703 | if ( 'post' == $current_screen->base && 'attachment' == $current_screen->id ) { |
| 704 | global $post; |
| 705 | // Only enqueue if the attachment is an image |
| 706 | if ( property_exists( $post, 'post_mime_type' ) && false !== strpos( $post->post_mime_type, 'image' ) ) { |
| 707 | wp_enqueue_style( 'asenha-image-sizes-panel', ASENHA_URL . 'assets/css/image-sizes-panel.css' ); |
| 708 | } |
| 709 | } |
| 710 | // Content Management >> Hide Admin Notices |
| 711 | if ( array_key_exists( 'hide_admin_notices', $options ) && $options['hide_admin_notices'] ) { |
| 712 | $hide_for_nonadmins = ( isset( $options['hide_admin_notices_for_nonadmins'] ) ? $options['hide_admin_notices_for_nonadmins'] : false ); |
| 713 | $minimum_capability = 'manage_options'; |
| 714 | if ( function_exists( 'bwasenha_fs' ) ) { |
| 715 | if ( $hide_for_nonadmins && bwasenha_fs()->can_use_premium_code__premium_only() ) { |
| 716 | $minimum_capability = 'read'; |
| 717 | } |
| 718 | } |
| 719 | if ( current_user_can( $minimum_capability ) ) { |
| 720 | wp_enqueue_style( |
| 721 | 'asenha-jbox', |
| 722 | ASENHA_URL . 'assets/css/jBox.all.min.css', |
| 723 | array(), |
| 724 | ASENHA_VERSION |
| 725 | ); |
| 726 | wp_enqueue_script( |
| 727 | 'asenha-jbox', |
| 728 | ASENHA_URL . 'assets/js/jBox.all.min.js', |
| 729 | array(), |
| 730 | ASENHA_VERSION, |
| 731 | false |
| 732 | ); |
| 733 | wp_enqueue_style( |
| 734 | 'asenha-hide-admin-notices', |
| 735 | ASENHA_URL . 'assets/css/hide-admin-notices.css', |
| 736 | array(), |
| 737 | ASENHA_VERSION |
| 738 | ); |
| 739 | wp_enqueue_script( |
| 740 | 'asenha-hide-admin-notices', |
| 741 | ASENHA_URL . 'assets/js/hide-admin-notices.js', |
| 742 | array('asenha-jbox'), |
| 743 | ASENHA_VERSION, |
| 744 | false |
| 745 | ); |
| 746 | } |
| 747 | } |
| 748 | // Utilities >> Multiple User Roles |
| 749 | if ( array_key_exists( 'multiple_user_roles', $options ) && $options['multiple_user_roles'] ) { |
| 750 | if ( 'user-edit.php' == $hook_suffix || 'user-new.php' == $hook_suffix ) { |
| 751 | // Only replace roles dropdown with checkboxes for users that can assign roles to other users, e.g. administrators |
| 752 | if ( current_user_can( 'promote_users', get_current_user_id() ) ) { |
| 753 | wp_enqueue_script( |
| 754 | 'asenha-multiple-user-roles', |
| 755 | ASENHA_URL . 'assets/js/multiple-user-roles.js', |
| 756 | array('jquery'), |
| 757 | ASENHA_VERSION, |
| 758 | false |
| 759 | ); |
| 760 | } |
| 761 | } |
| 762 | } |
| 763 | // Pass on ASENHA stats to admin-page.js to determine whether to show support nudge |
| 764 | $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() ); |
| 765 | $current_date = date( 'Y-m-d', time() ); |
| 766 | $show_support_nudge = false; |
| 767 | $hide_upgrade_nudge = false; |
| 768 | $asenha_stats_localized = array( |
| 769 | 'firstSaveDate' => '', |
| 770 | 'lastSaveDate' => '', |
| 771 | 'saveCount' => 0, |
| 772 | 'hideUpgradeNudge' => false, |
| 773 | 'showSupportNudge' => false, |
| 774 | 'saveChangesJsonpUrl' => 'https://bowo.io/asenha-save-btn', |
| 775 | ); |
| 776 | if ( !empty( $asenha_stats ) ) { |
| 777 | $hide_upgrade_nudge = ( isset( $asenha_stats['upgrade_nudge_dismissed'] ) ? $asenha_stats['upgrade_nudge_dismissed'] : false ); |
| 778 | $have_supported = ( isset( $asenha_stats['have_supported'] ) ? $asenha_stats['have_supported'] : false ); |
| 779 | $changes_saved = ( isset( $_GET['settings-updated'] ) && 'true' == sanitize_text_field( $_GET['settings-updated'] ) ? true : false ); |
| 780 | $save_count = ( isset( $asenha_stats['save_count'] ) ? $asenha_stats['save_count'] : 0 ); |
| 781 | // Compensate for redirect from settings-updated=true URL |
| 782 | if ( $changes_saved ) { |
| 783 | $save_count = $save_count + 1; |
| 784 | } else { |
| 785 | $save_count = $save_count; |
| 786 | } |
| 787 | $saves_to_nudge_support = 10; |
| 788 | if ( $save_count < $saves_to_nudge_support ) { |
| 789 | $save_count_modulo = -1; |
| 790 | } else { |
| 791 | $save_count_modulo = $save_count % $saves_to_nudge_support; |
| 792 | } |
| 793 | // User have not supported ASE |
| 794 | if ( false === $have_supported ) { |
| 795 | // Support nudge have not been dismissed |
| 796 | if ( isset( $asenha_stats['support_nudge_dismissed'] ) && false === $asenha_stats['support_nudge_dismissed'] ) { |
| 797 | // Show support nudge after every x saves |
| 798 | if ( $save_count_modulo >= 0 ) { |
| 799 | $show_support_nudge = true; |
| 800 | } else { |
| 801 | $show_support_nudge = false; |
| 802 | } |
| 803 | if ( $show_support_nudge && $save_count_modulo >= 0 ) { |
| 804 | $asenha_stats['support_nudge_last_shown_date'] = $current_date; |
| 805 | $asenha_stats['support_nudge_last_shown_save_count'] = $save_count; |
| 806 | update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false ); |
| 807 | } |
| 808 | } else { |
| 809 | if ( $save_count_modulo == 0 ) { |
| 810 | $support_nudge_last_shown_save_count = ( isset( $asenha_stats['support_nudge_last_shown_save_count'] ) ? $asenha_stats['support_nudge_last_shown_save_count'] : 0 ); |
| 811 | if ( $save_count > $support_nudge_last_shown_save_count ) { |
| 812 | $asenha_stats['support_nudge_dismissed'] = false; |
| 813 | update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false ); |
| 814 | $show_support_nudge = true; |
| 815 | } else { |
| 816 | $show_support_nudge = false; |
| 817 | } |
| 818 | } else { |
| 819 | $show_support_nudge = false; |
| 820 | } |
| 821 | } |
| 822 | } |
| 823 | $first_save_date = ( isset( $asenha_stats['first_save_date'] ) ? $asenha_stats['first_save_date'] : '' ); |
| 824 | $last_save_date = ( isset( $asenha_stats['last_save_date'] ) ? $asenha_stats['last_save_date'] : '' ); |
| 825 | $asenha_stats_localized = array( |
| 826 | 'firstSaveDate' => $first_save_date, |
| 827 | 'lastSaveDate' => $last_save_date, |
| 828 | 'saveCount' => $save_count, |
| 829 | 'hideUpgradeNudge' => $hide_upgrade_nudge, |
| 830 | 'showSupportNudge' => $show_support_nudge, |
| 831 | 'saveChangesJsonpUrl' => 'https://bowo.io/asenha-save-btn', |
| 832 | ); |
| 833 | } |
| 834 | wp_localize_script( 'asenha-admin-page', 'asenhaStats', $asenha_stats_localized ); |
| 835 | } |
| 836 | |
| 837 | /** |
| 838 | * Dequeue scripts that prevents ASE settings page from working properly. Usually from plugins. |
| 839 | * |
| 840 | * @since 6.3.3 |
| 841 | */ |
| 842 | function asenha_dequeue_scritps() { |
| 843 | if ( is_asenha() ) { |
| 844 | // https://wordpress.org/plugins/user-activity-log/ |
| 845 | wp_dequeue_script( 'chats-js' ); |
| 846 | wp_dequeue_script( 'custom_wp_admin_js' ); |
| 847 | // https://wordpress.org/plugins/print-invoices-packing-slip-labels-for-woocommerce/ |
| 848 | wp_dequeue_script( 'print-invoices-packing-slip-labels-for-woocommerce' ); |
| 849 | wp_dequeue_script( 'print-invoices-packing-slip-labels-for-woocommerce-form-wizard' ); |
| 850 | // https://wordpress.org/plugins/wp-reading-progress/ |
| 851 | wp_dequeue_script( 'ruigehond006_admin_javascript' ); |
| 852 | // WordPress Mentions Légales plugin v1.2.3 by Jean-Baptiste Aramendy - http://jba-development.fr/ |
| 853 | wp_dequeue_script( 'jquery-ui' ); |
| 854 | wp_dequeue_script( 'wordpress-mentions-legales' ); |
| 855 | // https://wordpress.org/plugins/us-weather-widget-willyweather/ |
| 856 | wp_dequeue_script( 'self' ); |
| 857 | // iThemes Security Pro / Solid Security Pro |
| 858 | wp_dequeue_script( 'itsec-core-admin-notices' ); |
| 859 | } |
| 860 | } |
| 861 | |
| 862 | /** |
| 863 | * Enqueue public scripts |
| 864 | * |
| 865 | * @since 3.9.0 |
| 866 | */ |
| 867 | function asenha_public_scripts( $hook_suffix ) { |
| 868 | // Get all WP Enhancements options, default to empty array in case it's not been created yet |
| 869 | $options = get_option( 'admin_site_enhancements', array() ); |
| 870 | // External Permalinks |
| 871 | $enable_external_permalinks = ( array_key_exists( 'enable_external_permalinks', $options ) ? $options['enable_external_permalinks'] : false ); |
| 872 | if ( $enable_external_permalinks ) { |
| 873 | wp_enqueue_script( |
| 874 | 'asenha-public', |
| 875 | ASENHA_URL . 'assets/js/external-permalinks.js', |
| 876 | array(), |
| 877 | ASENHA_VERSION, |
| 878 | false |
| 879 | ); |
| 880 | wp_localize_script( 'asenha-public', 'phpVars', array( |
| 881 | 'externalPermalinksEnabled' => $enable_external_permalinks, |
| 882 | ) ); |
| 883 | } |
| 884 | // Media Categories |
| 885 | $enable_media_categories = ( array_key_exists( 'enable_media_categories', $options ) ? $options['enable_media_categories'] : false ); |
| 886 | if ( $enable_media_categories && !is_admin() && is_user_logged_in() ) { |
| 887 | wp_enqueue_style( |
| 888 | 'asenha-media-categories-frontend', |
| 889 | ASENHA_URL . 'assets/css/media-categories-frontend.css', |
| 890 | array(), |
| 891 | ASENHA_VERSION |
| 892 | ); |
| 893 | } |
| 894 | // Media Replacement |
| 895 | $enable_media_replacement = ( array_key_exists( 'enable_media_replacement', $options ) ? $options['enable_media_replacement'] : false ); |
| 896 | if ( $enable_media_replacement && is_user_logged_in() ) { |
| 897 | wp_enqueue_style( |
| 898 | 'asenha-media-replace-frontend', |
| 899 | ASENHA_URL . 'assets/css/media-replace-frontend.css', |
| 900 | array(), |
| 901 | ASENHA_VERSION |
| 902 | ); |
| 903 | } |
| 904 | } |
| 905 | |
| 906 | /** |
| 907 | * Add admin bar styles for wp-admin and frontend |
| 908 | * |
| 909 | * @since 6.2.1 |
| 910 | */ |
| 911 | function asenha_admin_bar_item_js_css() { |
| 912 | if ( is_user_logged_in() ) { |
| 913 | ?> |
| 914 | <!--<script></script>--> |
| 915 | <style> |
| 916 | #wp-admin-bar-user-info .avatar { |
| 917 | object-fit: cover; |
| 918 | } |
| 919 | </style> |
| 920 | <?php |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | /** |
| 925 | * Add 'Access now' plugin action link. |
| 926 | * |
| 927 | * @since 1.0.0 |
| 928 | */ |
| 929 | function asenha_plugin_action_links( $links ) { |
| 930 | $settings_link = '<a href="tools.php?page=' . ASENHA_SLUG . '">' . __( 'Configure', 'admin-site-enhancements' ) . '</a>'; |
| 931 | array_unshift( $links, $settings_link ); |
| 932 | return $links; |
| 933 | } |
| 934 | |
| 935 | /** |
| 936 | * Modify footer text |
| 937 | * |
| 938 | * @since 1.0.0 |
| 939 | */ |
| 940 | function asenha_footer_text() { |
| 941 | // Show nothing |
| 942 | ?> |
| 943 | <?php |
| 944 | } |
| 945 | |
| 946 | /** |
| 947 | * Change WP version number text in footer |
| 948 | * |
| 949 | * @since 4.8.3 |
| 950 | */ |
| 951 | function asenha_footer_version_text() { |
| 952 | ?> |
| 953 | ASE <a href="https://www.wpase.com/documentation/changelog/" target="_blank">v<?php |
| 954 | echo esc_html( ASENHA_VERSION ); |
| 955 | ?></a> |
| 956 | <?php |
| 957 | } |
| 958 | |
| 959 | /** |
| 960 | * Check if current screen is this plugin's main page |
| 961 | * |
| 962 | * @since 1.0.0 |
| 963 | */ |
| 964 | function is_asenha() { |
| 965 | $request_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] ); |
| 966 | // e.g. /wp-admin/index.php?page=page-slug |
| 967 | if ( strpos( $request_uri, 'page=' . ASENHA_SLUG ) !== false ) { |
| 968 | return true; |
| 969 | // Yes, this is the plugin's main page |
| 970 | } else { |
| 971 | return false; |
| 972 | // Nope, this is NOT the plugin's page |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | /** |
| 977 | * Mark that user have supported ASE |
| 978 | * |
| 979 | * @since 5.2.7 |
| 980 | */ |
| 981 | function asenha_have_supported() { |
| 982 | if ( isset( $_REQUEST ) ) { |
| 983 | $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() ); |
| 984 | $asenha_stats['have_supported'] = true; |
| 985 | $asenha_stats['support_nudge_dismissed'] = true; |
| 986 | $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false ); |
| 987 | if ( $success ) { |
| 988 | echo json_encode( array( |
| 989 | 'success' => true, |
| 990 | ) ); |
| 991 | } else { |
| 992 | echo json_encode( array( |
| 993 | 'success' => false, |
| 994 | ) ); |
| 995 | } |
| 996 | } |
| 997 | } |
| 998 | |
| 999 | /** |
| 1000 | * Dismiss support nudge |
| 1001 | * |
| 1002 | * @since 5.8.2 |
| 1003 | */ |
| 1004 | function asenha_dismiss_upgrade_nudge() { |
| 1005 | if ( isset( $_REQUEST ) ) { |
| 1006 | $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() ); |
| 1007 | $asenha_stats['upgrade_nudge_dismissed'] = true; |
| 1008 | $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false ); |
| 1009 | if ( $success ) { |
| 1010 | echo json_encode( array( |
| 1011 | 'success' => true, |
| 1012 | ) ); |
| 1013 | } else { |
| 1014 | echo json_encode( array( |
| 1015 | 'success' => false, |
| 1016 | ) ); |
| 1017 | } |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | /** |
| 1022 | * Dismiss support nudge |
| 1023 | * |
| 1024 | * @since 5.2.7 |
| 1025 | */ |
| 1026 | function asenha_dismiss_support_nudge() { |
| 1027 | if ( isset( $_REQUEST ) ) { |
| 1028 | $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() ); |
| 1029 | $asenha_stats['support_nudge_dismissed'] = true; |
| 1030 | $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false ); |
| 1031 | if ( $success ) { |
| 1032 | echo json_encode( array( |
| 1033 | 'success' => true, |
| 1034 | ) ); |
| 1035 | } else { |
| 1036 | echo json_encode( array( |
| 1037 | 'success' => false, |
| 1038 | ) ); |
| 1039 | } |
| 1040 | } |
| 1041 | } |
| 1042 |