admin-site-enhancements
Last commit date
assets
2 years ago
classes
2 years ago
includes
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
1090 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() ); |
| 10 | } |
| 11 | if ( false === get_option( ASENHA_SLUG_U . '_stats' ) ) { |
| 12 | add_option( ASENHA_SLUG_U . '_stats', array() ); |
| 13 | } |
| 14 | if ( false === get_option( ASENHA_SLUG_U . '_extra' ) ) { |
| 15 | add_option( ASENHA_SLUG_U . '_extra', array() ); |
| 16 | } |
| 17 | /** |
| 18 | * Register admin menu |
| 19 | * |
| 20 | * @since 1.0.0 |
| 21 | */ |
| 22 | function asenha_register_admin_menu() |
| 23 | { |
| 24 | add_submenu_page( |
| 25 | 'tools.php', |
| 26 | // Parent page/menu |
| 27 | 'Admin and Site Enhancements', |
| 28 | // Browser tab/window title |
| 29 | 'Enhancements', |
| 30 | // Sube menu title |
| 31 | 'manage_options', |
| 32 | // Minimal user capabililty |
| 33 | ASENHA_SLUG, |
| 34 | // Page slug. Shows up in URL. |
| 35 | 'asenha_add_settings_page' |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Create the settings page of the plugin |
| 41 | * |
| 42 | * @since 1.0.0 |
| 43 | */ |
| 44 | function asenha_add_settings_page() |
| 45 | { |
| 46 | ?> |
| 47 | <div class="wrap asenha"> |
| 48 | |
| 49 | <div id="asenha-header" class="asenha-header"> |
| 50 | <div class="asenha-header-left"> |
| 51 | <img src="<?php |
| 52 | echo ASENHA_URL . 'assets/img/ase_icon.png' ; |
| 53 | ?>" class="asenha-icon"/> |
| 54 | <h1 class="asenha-heading"> |
| 55 | <?php |
| 56 | echo get_admin_page_title() ; |
| 57 | ?> |
| 58 | (ASE) |
| 59 | <?php |
| 60 | ?> |
| 61 | </h1> |
| 62 | <!-- <a href="https://wordpress.org/plugins/admin-site-enhancements/" target="_blank" class="asenha-header-action"><span>ℹ</span> <?php |
| 63 | // esc_html_e( 'Info', 'admin-site-enhancements' ); |
| 64 | ?></a> --> |
| 65 | </div> |
| 66 | <div class="asenha-header-right"> |
| 67 | <?php |
| 68 | // https://icon-sets.iconify.design/iconamoon/star-bold/ |
| 69 | $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>'; |
| 70 | // https://icon-sets.iconify.design/octicon/question-16/ |
| 71 | $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>'; |
| 72 | // https://icon-sets.iconify.design/octicon/comment-16/ |
| 73 | $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>'; |
| 74 | // https://icon-sets.iconify.design/iconamoon/file-document/ |
| 75 | $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>'; |
| 76 | // https://icon-sets.iconify.design/pajamas/heart/ |
| 77 | $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>'; |
| 78 | ?> |
| 79 | <a href="https://wordpress.org/plugins/admin-site-enhancements/#reviews" target="_blank" class="asenha-header-action review"><?php |
| 80 | echo $svg_star . esc_html( 'Review', 'admin-site-enhancements' ) ; |
| 81 | ?></a> |
| 82 | <a href="https://wordpress.org/support/plugin/admin-site-enhancements/" target="_blank" class="asenha-header-action feedback"><?php |
| 83 | echo $svg_feedback . esc_html( 'Feedback', 'admin-site-enhancements' ) ; |
| 84 | ?></a> |
| 85 | <!--<a href="https://www.wpasenha.com/docs/" target="_blank" class="asenha-header-action docs"><?php |
| 86 | // echo $svg_docs . esc_html( 'Docs', 'admin-site-enhancements' ); |
| 87 | ?></a>--> |
| 88 | <!--<a id="plugin-sponsor" href="#" class="asenha-header-action sponsor"><?php |
| 89 | // echo $svg_sponsor . esc_html( 'Sponsor', 'admin-site-enhancements' ); |
| 90 | ?></a>--> |
| 91 | <a href="https://www.wpase.com/upgrade-btn" target="_blank" id="plugin-upgrade" class="button button-primary plugin-upgrade">Get ASE Pro</a> |
| 92 | <?php |
| 93 | ?> |
| 94 | <a class="button button-primary asenha-save-button">Save Changes</a> |
| 95 | <!-- https://icon-sets.iconify.design/svg-spinners/180-ring-with-bg/ --> |
| 96 | <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> |
| 97 | <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> |
| 98 | </div> |
| 99 | </div> |
| 100 | |
| 101 | <div class="asenha-body"> |
| 102 | <?php |
| 103 | ?> |
| 104 | <div class="asenha-upgrade-nudge" style="display: none;"> |
| 105 | <div class="asenha-upgrade-nudge__message">The Pro version of ASE is here! Lifetime Deal (LTD) available.</div> |
| 106 | <a href="https://www.wpase.com/upgrade-ndg" class="button asenha-upgrade-nudge__button" target="_blank">Find Out More</a> |
| 107 | <a href="#" id="dismiss-upgrade-nudge" class="asenha-upgrade-nudge__dismiss"> |
| 108 | <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> |
| 109 | </a> |
| 110 | </div> |
| 111 | <div class="asenha-sponsorship-nudge nudge-show-more is-enabled" style="display: none;"> |
| 112 | <h3>Looks like some of these free enhancements have been useful for your site?</h3> |
| 113 | <p class="nudge-description intro">Please consider supporting ASE.</p> |
| 114 | <a id="sponsorship-nudge-show-moreless" class="nudge-show-more-less show-more-less show-more" href="#">Find Out How ▼</a> |
| 115 | <div class="nudge-wrapper-show-more"> |
| 116 | <?php |
| 117 | // Quotes on sponsorship |
| 118 | $sponsorship_quotes = array( |
| 119 | '"A very very useful plugin. I have made a little sponsorship and encourage other users to do the same as it is so much deserved. Thank you Bowo!" ~<a href="https://wordpress.org/support/topic/very-very-useful-54/" target="_blank">@pgrand83</a>', |
| 120 | '"Please consider supporting it if you use it on multiple sites / it saves you a lot of time, we as a community need to keep good devs like this and gems like this plugin alive." ~<a href="https://wordpress.org/support/topic/you-need-this-19/" target="_blank">@kiikiikii</a>', |
| 121 | '"Tried it and was blown away with all the options! How is this free? I will sponsor you because this is simply... [insert your favorite superlative here]" ~<a href="https://wordpress.org/support/topic/installed-on-all-my-sites-3/" target="_blank">@mgjaltema</a>', |
| 122 | '"This replaces so many plugins and snippets! Support the developer (reviews, donations etc.)" ~<a href="https://wordpress.org/support/topic/this-relpaces-many-plugins-and-snippets/" target="_blank">Max Ziebell</a>', |
| 123 | '"Not only free, but worth a donation. This plugins does so many little things that there\'s bound to be a bunch that will make your life easier." ~<a href="https://wordpress.org/support/topic/not-only-free-but-worth-a-donation/" target="_blank">Darryl</a>', |
| 124 | '"Replaced 6 plugins with this. Very easy plugin and great support. Found a bug and was fixed in hours!" ~<a href="https://wordpress.org/support/topic/replaced-6-plugins-with-this/" target="_blank">@dagaloni</a>', |
| 125 | '"Amazing plugin that has replaced at least 10 plugins for me. Lightweight, clean and easy to use. The developer is also very helpful and responsive." ~<a href="https://wordpress.org/support/topic/replaced-atleast-10-plugins-for-me/" target="_blank">@sk209</a>', |
| 126 | '"Very handy plugin by a great dev. Reported a bug yesterday, it was fixed today. Can’t ask for better than that." ~<a href="https://wordpress.org/support/topic/very-handy-plugin-by-a-great-dev/" target="_blank">Greg Mount</a>', |
| 127 | '"Excellent and very well-supported plugin. I had a small issue, posted a support comment, and the developer had things sorted in a couple of days with a patch upgrade." ~<a href="https://wordpress.org/support/topic/excellent-and-very-well-supported-plugin-saves-me-a-lot-of-work/" target="_blank">@grizdev</a>', |
| 128 | '"Bowo is awesome! Thanks to his great plugin my WP backend UI is cleaned up and organized, and I was able to uninstall other plugins too. Super useful, really recommended!" ~<a href="https://wordpress.org/support/topic/love-that-plugin-2/" target="_blank">@adminmax</a>', |
| 129 | '"A very useful plugin that also has great support. Amazing that this plugin is free too. Great work and thanks to the author." ~<a href="https://wordpress.org/support/topic/very-helpful-1357/" target="_blank">@tomo55555</a>', |
| 130 | '"Great plugin! I will definitely support it’s development because I know it will save me time and frustration on all of the websites I set up." ~<a href="https://wordpress.org/support/topic/great-plugin-clear-useful-and-a-joy-to-use/" target="_blank">@toddneufeld</a>', |
| 131 | '"Love the work you’ve done with this plugin! Incredibly powerful and well organized. It’s a real accomplishment to put this many features into a plugin and still make it easy to navigate." ~<a href="https://wordpress.org/support/topic/holy-cow-this-is-excellent/" target="_blank">Nathan Ingram</a>', |
| 132 | '"I must express gratitude to the author for the exceptional effort invested in developing this plugin... it nearly aligns entirely with the options I typically apply to each website." ~<a href="https://wordpress.org/support/topic/excellent-features-selection/" target="_blank">@cvladan</a>', |
| 133 | '"The support is awesome – I had an issue which I was able to pin down with the creator. Very fast response time, polite conversation and successful in the end 🙂. Fully recommended!" ~<a href="https://wordpress.org/support/topic/simple-yet-powerful-103/" target="_blank">@gulpman</a>', |
| 134 | '"I\'ve started installing this plugin as part of my \'standard\' set up. It is continually improving and seems very stable and reliable. I have made 6 installations so far and I am very impressed. Thanks Bowo." ~<a href="https://wordpress.org/support/topic/excellent-plugin-8681/" target="_blank">@jacalakie</a>', |
| 135 | '"I\'ve been looking for something like this for a long time. The developer is also very friendly and helpful. Highly recommended!" ~<a href="https://wordpress.org/support/topic/must-have-684/" target="_blank">@jdudi</a>', |
| 136 | '"A must have plugin for most sites, So many useful features. along with a great developer who is open to suggestions." ~<a href="https://wordpress.org/support/topic/amazing-plugin-2443/" target="_blank">@akgt</a>', |
| 137 | '"Great plugin and awesome developer!" ~<a href="https://wordpress.org/support/topic/awesome-9998/" target="_blank">@mrgy05</a>', |
| 138 | '"This one plug-in has replaced at the very least four other plug-ins I was using regularly. I can’t thank you enough for your work. Amazing job!" ~<a href="https://wordpress.org/support/topic/amazing-work-63/" target="_blank">@tbutcher</a>', |
| 139 | '"Technical support? Unbelievable, one problem and quick response with immediate solution. It has become one of my essential plugins. Just amazing!" ~<a href="https://wordpress.org/support/topic/there-are-no-words-just-amazing/" target="_blank">@samirhp</a>', |
| 140 | '"I just can’t believe I’ll be able to start using this single plugin instead of all the separate ones... what a relief! Thanks man for this great plugin, it’s like you’ve read my mind 🙂" ~<a href="https://wordpress.org/support/topic/amazing-how-many-separate-plugins-this-replaces/" target="_blank">@yudayuda</a>', |
| 141 | '"Awesome plugin! What a time saver and workflow improvements. Having all these setting in one place, one plugin. Replaces many free and paid for plugins." ~<a href="https://wordpress.org/support/topic/awesome-plugin-replaces-so-many-other-plugins/" target="_blank">@greggwatson</a>', |
| 142 | '"This plugin has quickly become my go-to solution for all my projects. It\'s a game-changer, saving me valuable time and sparing me the frustration of dealing with bloated plugins. " ~<a href="https://wordpress.org/support/topic/must-have-plugin-for-every-website-2/" target="_blank">Aronu</a>' |
| 143 | ); |
| 144 | $random_sponsorship_quote = $sponsorship_quotes[rand( 0, count( $sponsorship_quotes ) - 1 )]; |
| 145 | // Quotes on general support |
| 146 | $support_quotes = array( |
| 147 | '“Simply the best! Still looking for the sixth star for you. Don’t stop developing… We are supporting you!“ ~<a href="https://wordpress.org/support/topic/too-good-to-be-true-22/" target="_blank">@springbreak</a>', |
| 148 | '"Amazing job – premium functions in free plugin. Everything is clear, fast, consistent and lightweight. Best possible rating." ~<a href="https://wordpress.org/support/topic/amazing-job-premium-functions-in-free-plugin/" target="_blank">@pijag</a>', |
| 149 | '"Really grateful and impressed at the pace of development and adding new features including some I have suggested, so feedback is really worthwhile." ~<a href="https://wordpress.org/support/topic/fantastic-plugin-replacing-many-other-plugins/" target="_blank">Dale Reardon</a>', |
| 150 | '"Greatest plugin ever. All in one solution to most of my problems. Thank you very much." ~<a href="https://wordpress.org/support/topic/greatest-plugin-ever-11/" target="_blank">@angelaustr</a>', |
| 151 | '"It’s worth 10 stars (or more). This plugin eliminates the need to install many other plugins and also makes functions.php smaller since I have to insert fewer code snippets." ~<a href="https://wordpress.org/support/topic/its-worth-10-stars-or-more/" target="_blank">Angelika Reisiger</a>', |
| 152 | '"This plugin is a real Swiss Army knife... combines multiple plugins and is still lightweight. Also Bowo, the developer, is friendly and replies quite quickly!" ~<a href="https://wordpress.org/support/topic/amazing-3728/" target="_blank">@olpo24</a>', |
| 153 | '"Great job! Saved me lots of time to add lots of plugins to get ready for my work. It’s a relief to have everything streamlined and ready to go." ~<a href="https://wordpress.org/support/topic/super-2817/" target="_blank">Tao Sheng</a>', |
| 154 | '"Very powerful tool. With this plugin, I can remove tons of plugins to reduce the possibility of plugin conflicts." ~<a href="https://wordpress.org/support/topic/very-powerful-tool-13/" target="_blank">@chiehliniceday</a>', |
| 155 | '"Very useful! Great compilation of settings and options. It had quickly become one of my essential plugins." ~<a href="https://wordpress.org/support/topic/very-useful-3276/" target="_blank">@unapersona</a>', |
| 156 | '"This plugin easily replaces a dozen or more plugins I install on every website project... and support has been wonderful and responsive. Highly recommended!" ~<a href="https://wordpress.org/support/topic/amazing-must-have-plugin-2/" target="_blank">@netzzjd</a>', |
| 157 | '"I love that the whole plugin is smaller in file-size than some of the plugins that it replaces, which do only one of these things. Thank you for the great work!" ~<a href="https://wordpress.org/support/topic/very-useful-swiss-army-knife/" target="_blank">@dvaer</a>', |
| 158 | '"This is a great plugin, it replaces many single purpose plugins which bloat up the site and the admin area. Great idea, good work!" ~<a href="https://wordpress.org/support/topic/replaces-a-lot-of-single-purpose-plugins/" target="_blank">@tageins</a>', |
| 159 | '"Probably the best WP swiss army knife I’ve ever come across... Has noticeably improved performance on many of my sites. Keep up the great work!" ~<a href="https://wordpress.org/support/topic/im-replacing-so-many-plugins-with-this/" target="_blank">@instadesign</a>', |
| 160 | '"ASE’s enhanced admin dashboard, improved site performance, and robust security features have truly transformed our website management." ~<a href="https://wordpress.org/support/topic/this-has-reduced-my-plugin-list-by-6-7/" target="_blank">@tomhung</a>', |
| 161 | '"I love your plugin! All this needed functionality in one place is very helpful and saves me from writing (pasting) a lot of custom code every time." ~<a href="https://wordpress.org/support/topic/lifesaver-this-saves-so-much-time-and-custom-coding/" target="_blank">@prosite</a>', |
| 162 | '"Amazingly good... you can easily replace several plugins with this easy-to-use one. It’s well thought out and offers features I didn’t even realize I needed." ~<a href="https://wordpress.org/support/topic/amazingly-good-8/" target="_blank">@brenteades</a>', |
| 163 | '"Favorite!!! It has replaced several plugins I had in the past. This has become one of the first plugins I install." ~<a href="https://wordpress.org/support/topic/favorite-11/" target="_blank">@cck23</a>', |
| 164 | '"ASE has been a game-changer for us... we were able to remove numerous duplicate plugins, reducing clutter and improving efficiency." ~<a href="https://wordpress.org/support/topic/this-has-reduced-my-plugin-list-by-6-7/" target="_blank">@tomhung</a>', |
| 165 | '"This plugin is amazing. It replaces so many plugins and still removes bloat. For efficiency, security, flexibility and speed, it doesn’t get better." ~<a href="https://wordpress.org/support/topic/covers-all-manner-of-wp-sins/" target="_blank">Mary C. Dunford</a>', |
| 166 | '"This plugin is what I have been waiting for to see for years! It has so many useful options that previously you needed to google to find snippets for and it was hard to keep track of all of them." ~<a href="https://wordpress.org/support/topic/amazing-swiss-army-tool-for-wordpress/" target="_blank">@alexgraphicd</a>', |
| 167 | '"I’m already in love with this plugin... it will make my WP-life a lot easier 🙂" ~<a href="https://wordpress.org/support/topic/im-allready-in-love-with-this-plugin/" target="_blank">@medieskolen</a>', |
| 168 | '"This plugin allows you to install and maintain one plugin instead of a host of smaller ones. My tests were all successful and I was happy to simplify my maintenance with fewer plugins." ~<a href="https://wordpress.org/support/topic/replaced-4-plugins-worked-well-a/" target="_blank">Vic Drover</a>', |
| 169 | '"So many useful features it blows my mind, as well as enabling me to ditch so many other plugins." ~<a href="https://wordpress.org/support/topic/amazing-plugin-2441/" target="_blank">@simonclay</a>', |
| 170 | '"One of those plugins that feels like it should be part of the core, lots of useful features without the bloat." ~<a href="https://wordpress.org/support/topic/great-contribution-5/" target="_blank">@mohobook</a>', |
| 171 | '"One of the best and feature-rich plugins to add simple functions without using all sorts of separate plugins." ~<a href="https://wordpress.org/support/topic/amazing-all-purpose-plugin/" target="_blank">@toineenzo</a>' |
| 172 | ); |
| 173 | $random_support_quote = $support_quotes[rand( 0, count( $support_quotes ) - 1 )]; |
| 174 | $share_quotes = array( |
| 175 | '"Will recommend to everyone! A nice plugin, which will grow and become the best plugin ever made!!" ~<a href="https://wordpress.org/support/topic/will-recommend-to-everyone/" target="_blank">@simonvinther</a>', |
| 176 | '"It’s very honorable that you created this intentionally to give back to the WP community! I’ll be sure to share this plugin with all the freelance WP-builders at my shared office space!" ~<a href="https://wordpress.org/support/topic/installed-on-all-my-sites-3/" target="_blank">@mgjaltema</a>', |
| 177 | '"Simple and gold. This plugin so awesome and it should be known by more people." ~<a href="https://wordpress.org/support/topic/simple-and-gold/" target="_blank">Julian Song</a>', |
| 178 | '"ASE is a must-have plugin for anyone looking to optimize their WordPress site and streamline their workflow." ~<a href="https://wordpress.org/support/topic/this-has-reduced-my-plugin-list-by-6-7/" target="_blank">@tomhung</a>', |
| 179 | '"Admin Site Enhancements has made my list of \'must install\' plug-ins, since it makes so many other tasks much easier." ~<a href="https://wordpress.org/support/topic/excellent-and-very-well-supported-plugin-saves-me-a-lot-of-work/" target="_blank">@grizdev</a>', |
| 180 | '"I was super skeptical that this plugin could do so much without any problems, but i was wrong... 100% recommended!" ~<a href="https://wordpress.org/support/topic/the-all-in-one-plugin-you-need-in-your-arsenal/" target="_blank">@scarlywebs</a>', |
| 181 | '"The selection of tools... nearly aligns entirely with the options I typically apply to each website. This plugin is commendable." ~<a href="https://wordpress.org/support/topic/excellent-features-selection/" target="_blank">@cvladan</a>', |
| 182 | '"This plugin is amazing. So much useful functionality packed in. This is now a must-use plugin in my development stack. Thank you! ~<a href="https://wordpress.org/support/topic/amazing-now-part-of-my-must-use-dev-stack/" target="_blank">@phillcoxon</a>"', |
| 183 | '"Very good, must use plugin, that makes life easier for everyone." ~<a href="https://wordpress.org/support/topic/very-good-6977/" target="_blank">@alexeerma</a>', |
| 184 | '"Must-have plugin for every website. It\'s a game-changer." ~<a href="https://wordpress.org/support/topic/must-have-plugin-for-every-website-2/" target="_blank">Aronu</a>', |
| 185 | '"This plugin has quickly become my go-to solution for all my projects." ~<a href="https://wordpress.org/support/topic/must-have-plugin-for-every-website-2/" target="_blank">Aronu</a>', |
| 186 | '"Awesome plugin, it\'s an all in one solution!" ~<a href="https://wordpress.org/support/topic/everything-in-one-place-3/" target="_blank">@gabikod</a>', |
| 187 | '"This is one of the best utility plugins that eliminates the need to use multiple plugins. It has become a standard plugin used in my WP site blueprint." ~<a href="https://wordpress.org/support/topic/must-have-wp-utility-tool/" target="_blank">Ken Sim</a>', |
| 188 | '"Necessary plugin to every WordPress site." ~<a href="https://wordpress.org/support/topic/its-a-very-useful-plugin/" target="_blank">@ntamas</a>', |
| 189 | '"ASE is a highly recommended plugin for anyone looking to improve the functionality and usability of their WordPress site" ~<a href="https://wordpress.org/support/topic/amazing-plugin-in-place-of-multiple-plugins/" target="_blank">Ayyaz Ahmad</a>' |
| 190 | ); |
| 191 | $random_share_quote = $share_quotes[rand( 0, count( $share_quotes ) - 1 )]; |
| 192 | ?> |
| 193 | <div class="nudge-quotes"> |
| 194 | <div class="user-quote"><?php |
| 195 | echo $random_sponsorship_quote ; |
| 196 | ?></div> |
| 197 | <div class="user-quote"><?php |
| 198 | echo $random_support_quote ; |
| 199 | ?></div> |
| 200 | </div> |
| 201 | <div class="nudge-content"> |
| 202 | <div class="nudge-primary"> |
| 203 | <h4>Sponsor ASE from as little as USD 1, monthly or one-time</h4> |
| 204 | <div class="nudge-info"> |
| 205 | <p class="nudge-description">Please consider sponsoring ASE's ongoing development and maintenance so it can remain functional and useful for years to come. Thank you!</p> |
| 206 | </div> |
| 207 | <div class="nudge-ctas"> |
| 208 | <a href="https://bowo.io/asenha-sp-gth-ndg" class="button button-primary sponsorship-button monthly" target="_blank">Sponsor Monthly</a> |
| 209 | <a href="https://bowo.io/asenha-sp-ppl-ndg" class="button sponsorship-button one-time" target="_blank">Sponsor One-Time</a> |
| 210 | <a href="#" id="have-sponsored" class="asenha-have-sponsored">I've sponsored ASE</a> |
| 211 | </div> |
| 212 | <div class="nudge-stats"> |
| 213 | <p class="nudge-description">This free version of ASE has consumed more than <a href="https://wordpress.org/plugins/admin-site-enhancements/#developers" target="_blank">250 hours of dev time</a>. At v6.9.1 (released on March 7, 2024) and 50,000+ active installs, there have been <a href="https://bowo.io/asenha-sp-gth-ndg" target="_blank">6 monthly sponsors</a> and <a href="https://bowo.io/asenha-sp-ppl-ndg" target="_blank">59 one-time sponsors</a>. You can be one today!</p> |
| 214 | </div> |
| 215 | </div> |
| 216 | <div class="nudge-secondary"> |
| 217 | <h4>Give ASE your 5-star review or provide detailed feedback</h4> |
| 218 | <p class="nudge-description">If financial sponsorship is not something you can provide at the moment, you can always <a href="https://wordpress.org/plugins/admin-site-enhancements/#reviews" target="_blank">add a quick, 5-star review</a>.</p> |
| 219 | <p class="nudge-description">Or, if you find something is lacking or not working as you expect it to, you can provide a good and detailed <a href="https://wordpress.org/support/plugin/admin-site-enhancements/" target="_blank">feature request or feedback</a>, which is much more appreciated than a 4-star review or less. This is how we can work together to improve ASE.</p> |
| 220 | </div> |
| 221 | </div> |
| 222 | <div class="user-quote share-quote"><?php |
| 223 | echo $random_share_quote ; |
| 224 | ?></div> |
| 225 | <p class="nudge-description">Do <a href="https://wordpress.org/plugins/admin-site-enhancements/" target="_blank">share about ASE</a> with your colleagues and/or community.</p> |
| 226 | <a href="https://bowo.io" target="_blank" class="nudge-photo-link"><img src="<?php |
| 227 | echo esc_attr( ASENHA_URL . 'assets/img/bowo.jpg' ) ; |
| 228 | ?>" class="nudge-photo" /></a> |
| 229 | <h3>Thank you!</h3> |
| 230 | <p class="nudge-description nudge-closing">I hope you continue to benefit from ASE. ~<a href="https://bowo.io" target="_blank">Bowo</a></p> |
| 231 | <div class="dismiss-sponsorship-nudge"><a id="sponsorship-nudge-show-less" href="#">Show less</a> • <a href="#" id="sponsorship-nudge-dismiss" class="asenha-sponsorship-nudge-dismiss">Dismiss</a></div> |
| 232 | </div> |
| 233 | </div> |
| 234 | <?php |
| 235 | ?> |
| 236 | <form action="options.php" method="post"> |
| 237 | <div class="asenha-vertical-tabs"> |
| 238 | <div class="asenha-tab-buttons"> |
| 239 | <?php |
| 240 | // https://icon-sets.iconify.design/mdi/database-check-outline/ -- db check |
| 241 | // https://icon-sets.iconify.design/mdi/file-document-box-multiple-outline/ -- docs |
| 242 | // https://icon-sets.iconify.design/fluent/content-view-28-regular/ -- content |
| 243 | // https://icon-sets.iconify.design/lucide/shapes/ -- shapes |
| 244 | $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>'; |
| 245 | // https://icon-sets.iconify.design/mingcute/layout-line/ |
| 246 | $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>'; |
| 247 | // https://icon-sets.iconify.design/ri/login-circle-line/ |
| 248 | $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>'; |
| 249 | // https://icon-sets.iconify.design/mingcute/code-line/ |
| 250 | $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>'; |
| 251 | // https://icon-sets.iconify.design/mdi/forbid/ |
| 252 | $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>'; |
| 253 | // https://icon-sets.iconify.design/jam/shield-check/ |
| 254 | $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>'; |
| 255 | // https://icon-sets.iconify.design/streamline/image-flash-1-flash-power-connect-charge-electricity-lightning/ |
| 256 | $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>'; |
| 257 | // https://icon-sets.iconify.design/iconoir/tools/ |
| 258 | $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>'; |
| 259 | ?> |
| 260 | <input id="tab-content-management" type="radio" name="tabs" checked><label for="tab-content-management"><?php |
| 261 | echo $icon_content_management ; |
| 262 | ?>Content Management</label> |
| 263 | <input id="tab-admin-interface" type="radio" name="tabs"><label for="tab-admin-interface"><?php |
| 264 | echo $icon_admin_interface ; |
| 265 | ?>Admin Interface</label> |
| 266 | <input id="tab-login-logout" type="radio" name="tabs"><label for="tab-login-logout"><?php |
| 267 | echo $icon_login_logout ; |
| 268 | ?>Log In | Log Out</label> |
| 269 | <input id="tab-custom-code" type="radio" name="tabs"><label for="tab-custom-code"><?php |
| 270 | echo $icon_custom_code ; |
| 271 | ?>Custom Code</label> |
| 272 | <input id="tab-disable-components" type="radio" name="tabs"><label for="tab-disable-components"><?php |
| 273 | echo $icon_disable_components ; |
| 274 | ?>Disable Components</label> |
| 275 | <input id="tab-security" type="radio" name="tabs"><label for="tab-security"><?php |
| 276 | echo $icon_security ; |
| 277 | ?>Security</label> |
| 278 | <input id="tab-optimizations" type="radio" name="tabs"><label for="tab-optimizations"><?php |
| 279 | echo $icon_optimizations ; |
| 280 | ?>Optimizations</label> |
| 281 | <input id="tab-utilities" type="radio" name="tabs"><label for="tab-utilities"><?php |
| 282 | echo $icon_utilities ; |
| 283 | ?>Utilities</label> |
| 284 | </div> |
| 285 | <div class="asenha-tab-contents"> |
| 286 | <section class="asenha-fields fields-content-management"> |
| 287 | <table class="form-table" role="presentation"> |
| 288 | <tbody></tbody> |
| 289 | </table> |
| 290 | </section> |
| 291 | <section class="asenha-fields fields-admin-interface"> |
| 292 | <table class="form-table" role="presentation"> |
| 293 | <tbody></tbody> |
| 294 | </table> |
| 295 | </section> |
| 296 | <section class="asenha-fields fields-login-logout"> |
| 297 | <table class="form-table" role="presentation"> |
| 298 | <tbody></tbody> |
| 299 | </table> |
| 300 | </section> |
| 301 | <section class="asenha-fields fields-custom-code"> |
| 302 | <table class="form-table" role="presentation"> |
| 303 | <tbody></tbody> |
| 304 | </table> |
| 305 | </section> |
| 306 | <section class="asenha-fields fields-disable-components"> |
| 307 | <table class="form-table" role="presentation"> |
| 308 | <tbody></tbody> |
| 309 | </table> |
| 310 | </section> |
| 311 | <section class="asenha-fields fields-security"> |
| 312 | <table class="form-table" role="presentation"> |
| 313 | <tbody></tbody> |
| 314 | </table> |
| 315 | </section> |
| 316 | <section class="asenha-fields fields-optimizations"> |
| 317 | <table class="form-table" role="presentation"> |
| 318 | <tbody></tbody> |
| 319 | </table> |
| 320 | </section> |
| 321 | <section class="asenha-fields fields-utilities"> |
| 322 | <table class="form-table" role="presentation"> |
| 323 | <tbody></tbody> |
| 324 | </table> |
| 325 | </section> |
| 326 | </div> |
| 327 | </div> |
| 328 | <div style="display:none;"><!-- Hide to prevent flash of fields appearing at the bottom of the page --> |
| 329 | <?php |
| 330 | settings_fields( ASENHA_ID ); |
| 331 | ?> |
| 332 | <?php |
| 333 | do_settings_sections( ASENHA_SLUG ); |
| 334 | ?> |
| 335 | <?php |
| 336 | submit_button( |
| 337 | 'Save Changes', |
| 338 | // Button copy |
| 339 | 'primary', |
| 340 | // Type: 'primary', 'small', or 'large' |
| 341 | 'submit', |
| 342 | // The 'name' attribute |
| 343 | true, |
| 344 | // Whether to wrap in <p> tag |
| 345 | array( |
| 346 | 'id' => 'asenha-submit', |
| 347 | ) |
| 348 | ); |
| 349 | ?> |
| 350 | </div> |
| 351 | </form> |
| 352 | <?php |
| 353 | ?> |
| 354 | <div id="bottom-upgrade-nudge" class="asenha-upgrade-nudge-bottom" style="display:none;"> |
| 355 | <div class="asenha-upgrade-nudge-bottom__message">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>.</div> |
| 356 | </div> |
| 357 | <?php |
| 358 | ?> |
| 359 | </div> |
| 360 | |
| 361 | <?php |
| 362 | ?> |
| 363 | |
| 364 | </div> |
| 365 | <?php |
| 366 | // Record the number of times changes were saved as well as the date of last save |
| 367 | $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() ); |
| 368 | $changes_saved = ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ? true : false ); |
| 369 | |
| 370 | if ( $changes_saved ) { |
| 371 | $current_date = date( 'Y-m-d', time() ); |
| 372 | |
| 373 | if ( !isset( $asenha_stats['first_save_date'] ) ) { |
| 374 | $asenha_stats['first_save_date'] = $current_date; |
| 375 | $asenha_stats['last_save_date'] = $current_date; |
| 376 | $asenha_stats['save_count'] = 1; |
| 377 | $asenha_stats['have_sponsored'] = false; |
| 378 | $asenha_stats['sponsorship_nudge_dismissed'] = false; |
| 379 | $asenha_stats['sponsorship_nudge_last_shown_date'] = ''; |
| 380 | $asenha_stats['sponsorship_nudge_last_shown_save_count'] = 0; |
| 381 | } else { |
| 382 | $asenha_stats['last_save_date'] = $current_date; |
| 383 | $save_count = $asenha_stats['save_count']; |
| 384 | $save_count++; |
| 385 | $asenha_stats['save_count'] = $save_count; |
| 386 | } |
| 387 | |
| 388 | update_option( ASENHA_SLUG_U . '_stats', $asenha_stats ); |
| 389 | } |
| 390 | |
| 391 | } |
| 392 | |
| 393 | /** |
| 394 | * Suppress all notices, then add notice for successful settings update |
| 395 | * |
| 396 | * @since 1.1.0 |
| 397 | */ |
| 398 | function asenha_suppress_add_notices() |
| 399 | { |
| 400 | global $plugin_page ; |
| 401 | // Suppress all notices |
| 402 | if ( ASENHA_SLUG === $plugin_page ) { |
| 403 | remove_all_actions( 'admin_notices' ); |
| 404 | } |
| 405 | // Add notice for successful settings update |
| 406 | if ( isset( $_GET['page'] ) && ASENHA_SLUG == $_GET['page'] && isset( $_GET['settings-updated'] ) && true == $_GET['settings-updated'] ) { |
| 407 | ?> |
| 408 | <script> |
| 409 | jQuery(document).ready( function() { |
| 410 | jQuery('.asenha-changes-saved').fadeIn(400).delay(2500).fadeOut(400); |
| 411 | }); |
| 412 | </script> |
| 413 | |
| 414 | <?php |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Suppress all generic notices on the plugin settings page |
| 420 | * |
| 421 | * @since 2.7.0 |
| 422 | */ |
| 423 | function asenha_suppress_generic_notices() |
| 424 | { |
| 425 | global $plugin_page ; |
| 426 | // Suppress all notices |
| 427 | if ( ASENHA_SLUG === $plugin_page ) { |
| 428 | remove_all_actions( 'all_admin_notices' ); |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | /** |
| 433 | * Enqueue admin scripts |
| 434 | * |
| 435 | * @since 1.0.0 |
| 436 | */ |
| 437 | function asenha_admin_scripts( $hook_suffix ) |
| 438 | { |
| 439 | global |
| 440 | $wp_version, |
| 441 | $pagenow, |
| 442 | $typenow, |
| 443 | $taxnow, |
| 444 | $hook_suffix, |
| 445 | $current_user |
| 446 | ; |
| 447 | $current_screen = get_current_screen(); |
| 448 | // Get all WP Enhancements options, default to empty array in case it's not been created yet |
| 449 | $options = get_option( 'admin_site_enhancements', array() ); |
| 450 | // For main page of this plugin |
| 451 | |
| 452 | if ( is_asenha() ) { |
| 453 | wp_enqueue_style( |
| 454 | 'asenha-jbox', |
| 455 | ASENHA_URL . 'assets/css/jBox.all.min.css', |
| 456 | array(), |
| 457 | ASENHA_VERSION |
| 458 | ); |
| 459 | wp_enqueue_script( |
| 460 | 'asenha-jbox', |
| 461 | ASENHA_URL . 'assets/js/jBox.all.min.js', |
| 462 | array(), |
| 463 | ASENHA_VERSION, |
| 464 | false |
| 465 | ); |
| 466 | wp_enqueue_script( |
| 467 | 'asenha-jsticky', |
| 468 | ASENHA_URL . 'assets/js/jquery.jsticky.mod.min.js', |
| 469 | array( 'jquery' ), |
| 470 | ASENHA_VERSION, |
| 471 | false |
| 472 | ); |
| 473 | wp_enqueue_script( |
| 474 | 'asenha-js-cookie', |
| 475 | ASENHA_URL . 'assets/js/js.cookie.min.js', |
| 476 | array(), |
| 477 | ASENHA_VERSION, |
| 478 | false |
| 479 | ); |
| 480 | // jQuery UI Sortables. In use, e.g. for Admin Interface >> Admin Menu Organizer |
| 481 | // Re-register and re-enqueue jQuery UI Core and plugins required for sortable, draggable and droppable when ordering menu items |
| 482 | wp_deregister_script( 'jquery-ui-core' ); |
| 483 | wp_register_script( |
| 484 | 'jquery-ui-core', |
| 485 | get_site_url() . '/wp-includes/js/jquery/ui/core.min.js', |
| 486 | array( 'jquery' ), |
| 487 | ASENHA_VERSION, |
| 488 | false |
| 489 | ); |
| 490 | wp_enqueue_script( 'jquery-ui-core' ); |
| 491 | |
| 492 | if ( version_compare( $wp_version, '5.6.0', '>=' ) ) { |
| 493 | wp_deregister_script( 'jquery-ui-mouse' ); |
| 494 | wp_register_script( |
| 495 | 'jquery-ui-mouse', |
| 496 | get_site_url() . '/wp-includes/js/jquery/ui/mouse.min.js', |
| 497 | array( 'jquery-ui-core' ), |
| 498 | ASENHA_VERSION, |
| 499 | false |
| 500 | ); |
| 501 | wp_enqueue_script( 'jquery-ui-mouse' ); |
| 502 | } else { |
| 503 | wp_deregister_script( 'jquery-ui-widget' ); |
| 504 | wp_register_script( |
| 505 | 'jquery-ui-widget', |
| 506 | get_site_url() . '/wp-includes/js/jquery/ui/widget.min.js', |
| 507 | array( 'jquery' ), |
| 508 | ASENHA_VERSION, |
| 509 | false |
| 510 | ); |
| 511 | wp_enqueue_script( 'jquery-ui-widget' ); |
| 512 | wp_deregister_script( 'jquery-ui-mouse' ); |
| 513 | wp_register_script( |
| 514 | 'jquery-ui-mouse', |
| 515 | get_site_url() . '/wp-includes/js/jquery/ui/mouse.min.js', |
| 516 | array( 'jquery-ui-core', 'jquery-ui-widget' ), |
| 517 | ASENHA_VERSION, |
| 518 | false |
| 519 | ); |
| 520 | wp_enqueue_script( 'jquery-ui-mouse' ); |
| 521 | } |
| 522 | |
| 523 | wp_deregister_script( 'jquery-ui-sortable' ); |
| 524 | wp_register_script( |
| 525 | 'jquery-ui-sortable', |
| 526 | get_site_url() . '/wp-includes/js/jquery/ui/sortable.min.js', |
| 527 | array( 'jquery-ui-mouse' ), |
| 528 | ASENHA_VERSION, |
| 529 | false |
| 530 | ); |
| 531 | wp_enqueue_script( 'jquery-ui-sortable' ); |
| 532 | wp_deregister_script( 'jquery-ui-draggable' ); |
| 533 | wp_register_script( |
| 534 | 'jquery-ui-draggable', |
| 535 | get_site_url() . '/wp-includes/js/jquery/ui/draggable.min.js', |
| 536 | array( 'jquery-ui-mouse' ), |
| 537 | ASENHA_VERSION, |
| 538 | false |
| 539 | ); |
| 540 | wp_enqueue_script( 'jquery-ui-draggable' ); |
| 541 | wp_deregister_script( 'jquery-ui-droppable' ); |
| 542 | wp_register_script( |
| 543 | 'jquery-ui-droppable', |
| 544 | get_site_url() . '/wp-includes/js/jquery/ui/droppable.min.js', |
| 545 | array( 'jquery-ui-draggable' ), |
| 546 | ASENHA_VERSION, |
| 547 | false |
| 548 | ); |
| 549 | wp_enqueue_script( 'jquery-ui-droppable' ); |
| 550 | // Script to set behaviour and actions of the sortable menu |
| 551 | wp_enqueue_script( |
| 552 | 'asenha-custom-admin-menu', |
| 553 | ASENHA_URL . 'assets/js/custom-admin-menu.js', |
| 554 | array( 'jquery-ui-draggable' ), |
| 555 | ASENHA_VERSION, |
| 556 | false |
| 557 | ); |
| 558 | // First, we unload the CodeMirror libraries included in WP core |
| 559 | wp_deregister_script( 'wp-codemirror' ); |
| 560 | wp_deregister_script( 'code-editor' ); |
| 561 | wp_deregister_script( 'htmlhint' ); |
| 562 | wp_deregister_script( 'csslint' ); |
| 563 | wp_deregister_script( 'esprima' ); |
| 564 | wp_deregister_script( 'jshint' ); |
| 565 | // Then, we load ASENHA's CodeMirror libraries. In use, e.g. for Utilities >> Enable Custom Admin / Frontend CSS / ads.txt / app-ads.txt |
| 566 | wp_enqueue_style( |
| 567 | 'asenha-codemirror', |
| 568 | ASENHA_URL . 'assets/css/codemirror/codemirror.min.css', |
| 569 | array(), |
| 570 | ASENHA_VERSION |
| 571 | ); |
| 572 | wp_enqueue_script( |
| 573 | 'asenha-codemirror', |
| 574 | ASENHA_URL . 'assets/js/codemirror/codemirror.min.js', |
| 575 | array( 'jquery' ), |
| 576 | ASENHA_VERSION, |
| 577 | true |
| 578 | ); |
| 579 | wp_enqueue_script( |
| 580 | 'asenha-codemirror-htmlmixed-mode', |
| 581 | ASENHA_URL . 'assets/js/codemirror/htmlmixed.js', |
| 582 | array( 'asenha-codemirror' ), |
| 583 | ASENHA_VERSION, |
| 584 | true |
| 585 | ); |
| 586 | wp_enqueue_script( |
| 587 | 'asenha-codemirror-xml-mode', |
| 588 | ASENHA_URL . 'assets/js/codemirror/xml.js', |
| 589 | array( 'asenha-codemirror' ), |
| 590 | ASENHA_VERSION, |
| 591 | true |
| 592 | ); |
| 593 | wp_enqueue_script( |
| 594 | 'asenha-codemirror-javascript-mode', |
| 595 | ASENHA_URL . 'assets/js/codemirror/javascript.js', |
| 596 | array( 'asenha-codemirror' ), |
| 597 | ASENHA_VERSION, |
| 598 | true |
| 599 | ); |
| 600 | wp_enqueue_script( |
| 601 | 'asenha-codemirror-css-mode', |
| 602 | ASENHA_URL . 'assets/js/codemirror/css.js', |
| 603 | array( 'asenha-codemirror' ), |
| 604 | ASENHA_VERSION, |
| 605 | true |
| 606 | ); |
| 607 | wp_enqueue_script( |
| 608 | 'asenha-codemirror-markdown-mode', |
| 609 | ASENHA_URL . 'assets/js/codemirror/markdown.js', |
| 610 | array( 'asenha-codemirror' ), |
| 611 | ASENHA_VERSION, |
| 612 | true |
| 613 | ); |
| 614 | // DataTables. In use, e.g. for Security >> Limit Login Attempts |
| 615 | wp_enqueue_style( |
| 616 | 'asenha-datatables', |
| 617 | ASENHA_URL . 'assets/css/datatables/datatables.min.css', |
| 618 | array(), |
| 619 | ASENHA_VERSION |
| 620 | ); |
| 621 | wp_enqueue_script( |
| 622 | 'asenha-datatables', |
| 623 | ASENHA_URL . 'assets/js/datatables/datatables.min.js', |
| 624 | array( 'jquery' ), |
| 625 | ASENHA_VERSION, |
| 626 | false |
| 627 | ); |
| 628 | // Add WP media library assets |
| 629 | wp_enqueue_media(); |
| 630 | // Add WP color picker assets |
| 631 | wp_enqueue_style( 'wp-color-picker' ); |
| 632 | wp_enqueue_script( 'wp-color-picker' ); |
| 633 | // Main style and script for the admin page |
| 634 | wp_enqueue_style( |
| 635 | 'asenha-admin-page', |
| 636 | ASENHA_URL . 'assets/css/admin-page.css', |
| 637 | array( |
| 638 | 'asenha-jbox', |
| 639 | 'asenha-codemirror', |
| 640 | 'asenha-datatables', |
| 641 | 'wp-color-picker' |
| 642 | ), |
| 643 | ASENHA_VERSION |
| 644 | ); |
| 645 | wp_enqueue_script( |
| 646 | 'asenha-admin-page', |
| 647 | ASENHA_URL . 'assets/js/admin-page.js', |
| 648 | array( |
| 649 | 'asenha-jsticky', |
| 650 | 'asenha-jbox', |
| 651 | 'asenha-js-cookie', |
| 652 | 'asenha-codemirror-htmlmixed-mode', |
| 653 | 'asenha-codemirror-xml-mode', |
| 654 | 'asenha-codemirror-javascript-mode', |
| 655 | 'asenha-codemirror-css-mode', |
| 656 | 'asenha-codemirror-markdown-mode', |
| 657 | 'asenha-datatables', |
| 658 | 'asenha-custom-admin-menu', |
| 659 | 'wp-color-picker' |
| 660 | ), |
| 661 | ASENHA_VERSION, |
| 662 | false |
| 663 | ); |
| 664 | wp_localize_script( 'asenha-admin-page', 'adminPageVars', array( |
| 665 | 'mediaFrameTitle' => 'Select an Image', |
| 666 | 'mediaFrameButtonText' => 'Use Selected Image', |
| 667 | 'resetMenuNonce' => wp_create_nonce( 'reset-menu-nonce' ), |
| 668 | ) ); |
| 669 | } |
| 670 | |
| 671 | // Enqueue on all wp-admin |
| 672 | wp_enqueue_style( |
| 673 | 'asenha-wp-admin', |
| 674 | ASENHA_URL . 'assets/css/wp-admin.css', |
| 675 | array(), |
| 676 | ASENHA_VERSION |
| 677 | ); |
| 678 | // Content Management >> Show IDs, for list tables in wp-admin, e.g. All Posts page |
| 679 | if ( false !== strpos( $current_screen->base, 'edit' ) || false !== strpos( $current_screen->base, 'users' ) || false !== strpos( $current_screen->base, 'upload' ) ) { |
| 680 | wp_enqueue_style( |
| 681 | 'asenha-list-table', |
| 682 | ASENHA_URL . 'assets/css/list-table.css', |
| 683 | array(), |
| 684 | ASENHA_VERSION |
| 685 | ); |
| 686 | } |
| 687 | // Content Management >> Enable Media Replacement |
| 688 | |
| 689 | if ( $current_screen->base == 'upload' || $current_screen->id == 'attachment' ) { |
| 690 | // wp_enqueue_style( 'asenha-jbox', ASENHA_URL . 'assets/css/jBox.all.min.css', array(), ASENHA_VERSION ); |
| 691 | // wp_enqueue_script( 'asenha-jbox', ASENHA_URL . 'assets/js/jBox.all.min.js', array(), ASENHA_VERSION, false ); |
| 692 | wp_enqueue_style( |
| 693 | 'asenha-media-replace', |
| 694 | ASENHA_URL . 'assets/css/media-replace.css', |
| 695 | array(), |
| 696 | ASENHA_VERSION |
| 697 | ); |
| 698 | wp_enqueue_script( |
| 699 | 'asenha-media-replace', |
| 700 | ASENHA_URL . 'assets/js/media-replace.js', |
| 701 | array(), |
| 702 | ASENHA_VERSION, |
| 703 | false |
| 704 | ); |
| 705 | } |
| 706 | |
| 707 | // Utilities >> Image Sizes Panel |
| 708 | |
| 709 | if ( 'post' == $current_screen->base && 'attachment' == $current_screen->id ) { |
| 710 | global $post ; |
| 711 | // Only enqueue if the attachment is an image |
| 712 | if ( property_exists( $post, 'post_mime_type' ) && false !== strpos( $post->post_mime_type, 'image' ) ) { |
| 713 | wp_enqueue_style( 'asenha-image-sizes-panel', ASENHA_URL . 'assets/css/image-sizes-panel.css' ); |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | // Content Management >> Hide Admin Notices |
| 718 | |
| 719 | if ( array_key_exists( 'hide_admin_notices', $options ) && $options['hide_admin_notices'] ) { |
| 720 | $hide_for_nonadmins = ( isset( $options['hide_admin_notices_for_nonadmins'] ) ? $options['hide_admin_notices_for_nonadmins'] : false ); |
| 721 | $minimum_capability = 'manage_options'; |
| 722 | if ( function_exists( 'bwasenha_fs' ) ) { |
| 723 | if ( $hide_for_nonadmins && bwasenha_fs()->can_use_premium_code__premium_only() ) { |
| 724 | $minimum_capability = 'read'; |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | if ( current_user_can( $minimum_capability ) ) { |
| 729 | wp_enqueue_style( |
| 730 | 'asenha-jbox', |
| 731 | ASENHA_URL . 'assets/css/jBox.all.min.css', |
| 732 | array(), |
| 733 | ASENHA_VERSION |
| 734 | ); |
| 735 | wp_enqueue_script( |
| 736 | 'asenha-jbox', |
| 737 | ASENHA_URL . 'assets/js/jBox.all.min.js', |
| 738 | array(), |
| 739 | ASENHA_VERSION, |
| 740 | false |
| 741 | ); |
| 742 | wp_enqueue_style( |
| 743 | 'asenha-hide-admin-notices', |
| 744 | ASENHA_URL . 'assets/css/hide-admin-notices.css', |
| 745 | array(), |
| 746 | ASENHA_VERSION |
| 747 | ); |
| 748 | wp_enqueue_script( |
| 749 | 'asenha-hide-admin-notices', |
| 750 | ASENHA_URL . 'assets/js/hide-admin-notices.js', |
| 751 | array( 'asenha-jbox' ), |
| 752 | ASENHA_VERSION, |
| 753 | false |
| 754 | ); |
| 755 | } |
| 756 | |
| 757 | } |
| 758 | |
| 759 | // Utilities >> Multiple User Roles |
| 760 | if ( array_key_exists( 'multiple_user_roles', $options ) && $options['multiple_user_roles'] ) { |
| 761 | if ( 'user-edit.php' == $hook_suffix || 'user-new.php' == $hook_suffix ) { |
| 762 | // Only replace roles dropdown with checkboxes for users that can assign roles to other users, e.g. administrators |
| 763 | if ( current_user_can( 'promote_users', get_current_user_id() ) ) { |
| 764 | wp_enqueue_script( |
| 765 | 'asenha-multiple-user-roles', |
| 766 | ASENHA_URL . 'assets/js/multiple-user-roles.js', |
| 767 | array( 'jquery' ), |
| 768 | ASENHA_VERSION, |
| 769 | false |
| 770 | ); |
| 771 | } |
| 772 | } |
| 773 | } |
| 774 | // Pass on ASENHA stats to admin-page.js to determine whether to show sponsorship nudge |
| 775 | $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() ); |
| 776 | $current_date = date( 'Y-m-d', time() ); |
| 777 | $show_sponsorship_nudge = false; |
| 778 | $hide_upgrade_nudge = false; |
| 779 | $asenha_stats_localized = array( |
| 780 | 'firstSaveDate' => '', |
| 781 | 'lastSaveDate' => '', |
| 782 | 'saveCount' => 0, |
| 783 | 'hideUpgradeNudge' => false, |
| 784 | 'showSponsorshipNudge' => false, |
| 785 | 'saveChangesJsonpUrl' => 'https://bowo.io/asenha-save-btn', |
| 786 | ); |
| 787 | |
| 788 | if ( !empty($asenha_stats) ) { |
| 789 | $hide_upgrade_nudge = ( isset( $asenha_stats['upgrade_nudge_dismissed'] ) ? $asenha_stats['upgrade_nudge_dismissed'] : false ); |
| 790 | $have_sponsored = ( isset( $asenha_stats['have_sponsored'] ) ? $asenha_stats['have_sponsored'] : false ); |
| 791 | $changes_saved = ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ? true : false ); |
| 792 | $save_count = ( isset( $asenha_stats['save_count'] ) ? $asenha_stats['save_count'] : 0 ); |
| 793 | // Compensate for redirect from settings-updated=true URL |
| 794 | |
| 795 | if ( $changes_saved ) { |
| 796 | $save_count = $save_count + 1; |
| 797 | } else { |
| 798 | $save_count = $save_count; |
| 799 | } |
| 800 | |
| 801 | $saves_to_nudge_sponsorship = 10; |
| 802 | |
| 803 | if ( $save_count < $saves_to_nudge_sponsorship ) { |
| 804 | $save_count_modulo = -1; |
| 805 | } else { |
| 806 | $save_count_modulo = $save_count % $saves_to_nudge_sponsorship; |
| 807 | } |
| 808 | |
| 809 | // User have not sponsored ASE |
| 810 | if ( false === $have_sponsored ) { |
| 811 | // Sponsorship nudge have not been dismissed |
| 812 | |
| 813 | if ( false === $asenha_stats['sponsorship_nudge_dismissed'] ) { |
| 814 | // Show sponsorship nudge after every x saves |
| 815 | |
| 816 | if ( $save_count_modulo >= 0 ) { |
| 817 | $show_sponsorship_nudge = true; |
| 818 | } else { |
| 819 | $show_sponsorship_nudge = false; |
| 820 | } |
| 821 | |
| 822 | |
| 823 | if ( $show_sponsorship_nudge && $save_count_modulo >= 0 ) { |
| 824 | $asenha_stats['sponsorship_nudge_last_shown_date'] = $current_date; |
| 825 | $asenha_stats['sponsorship_nudge_last_shown_save_count'] = $save_count; |
| 826 | update_option( ASENHA_SLUG_U . '_stats', $asenha_stats ); |
| 827 | } |
| 828 | |
| 829 | } else { |
| 830 | |
| 831 | if ( $save_count_modulo == 0 ) { |
| 832 | |
| 833 | if ( $save_count > $asenha_stats['sponsorship_nudge_last_shown_save_count'] ) { |
| 834 | $asenha_stats['sponsorship_nudge_dismissed'] = false; |
| 835 | update_option( ASENHA_SLUG_U . '_stats', $asenha_stats ); |
| 836 | $show_sponsorship_nudge = true; |
| 837 | } else { |
| 838 | $show_sponsorship_nudge = false; |
| 839 | } |
| 840 | |
| 841 | } else { |
| 842 | $show_sponsorship_nudge = false; |
| 843 | } |
| 844 | |
| 845 | } |
| 846 | |
| 847 | } |
| 848 | $first_save_date = ( isset( $asenha_stats['first_save_date'] ) ? $asenha_stats['first_save_date'] : '' ); |
| 849 | $last_save_date = ( isset( $asenha_stats['last_save_date'] ) ? $asenha_stats['last_save_date'] : '' ); |
| 850 | $asenha_stats_localized = array( |
| 851 | 'firstSaveDate' => $first_save_date, |
| 852 | 'lastSaveDate' => $last_save_date, |
| 853 | 'saveCount' => $save_count, |
| 854 | 'hideUpgradeNudge' => $hide_upgrade_nudge, |
| 855 | 'showSponsorshipNudge' => $show_sponsorship_nudge, |
| 856 | 'saveChangesJsonpUrl' => 'https://bowo.io/asenha-save-btn', |
| 857 | ); |
| 858 | } |
| 859 | |
| 860 | wp_localize_script( 'asenha-admin-page', 'asenhaStats', $asenha_stats_localized ); |
| 861 | } |
| 862 | |
| 863 | /** |
| 864 | * Dequeue scripts that prevents ASE settings page from working properly. Usually from plugins. |
| 865 | * |
| 866 | * @since 6.3.3 |
| 867 | */ |
| 868 | function asenha_dequeue_scritps() |
| 869 | { |
| 870 | // https://wordpress.org/plugins/user-activity-log/ |
| 871 | wp_dequeue_script( 'chats-js' ); |
| 872 | wp_dequeue_script( 'custom_wp_admin_js' ); |
| 873 | // https://wordpress.org/plugins/print-invoices-packing-slip-labels-for-woocommerce/ |
| 874 | wp_dequeue_script( 'print-invoices-packing-slip-labels-for-woocommerce' ); |
| 875 | wp_dequeue_script( 'print-invoices-packing-slip-labels-for-woocommerce-form-wizard' ); |
| 876 | // https://wordpress.org/plugins/wp-reading-progress/ |
| 877 | wp_dequeue_script( 'ruigehond006_admin_javascript' ); |
| 878 | // WordPress Mentions Légales plugin v1.2.3 by Jean-Baptiste Aramendy - http://jba-development.fr/ |
| 879 | wp_dequeue_script( 'jquery-ui' ); |
| 880 | wp_dequeue_script( 'wordpress-mentions-legales' ); |
| 881 | // https://wordpress.org/plugins/us-weather-widget-willyweather/ |
| 882 | wp_dequeue_script( 'self' ); |
| 883 | } |
| 884 | |
| 885 | /** |
| 886 | * Enqueue public scripts |
| 887 | * |
| 888 | * @since 3.9.0 |
| 889 | */ |
| 890 | function asenha_public_scripts( $hook_suffix ) |
| 891 | { |
| 892 | // Get all WP Enhancements options, default to empty array in case it's not been created yet |
| 893 | $options = get_option( 'admin_site_enhancements', array() ); |
| 894 | // External Permalinks |
| 895 | $enable_external_permalinks = ( array_key_exists( 'enable_external_permalinks', $options ) ? $options['enable_external_permalinks'] : false ); |
| 896 | |
| 897 | if ( $enable_external_permalinks ) { |
| 898 | wp_enqueue_script( |
| 899 | 'asenha-public', |
| 900 | ASENHA_URL . 'assets/js/external-permalinks.js', |
| 901 | array(), |
| 902 | ASENHA_VERSION, |
| 903 | false |
| 904 | ); |
| 905 | wp_localize_script( 'asenha-public', 'phpVars', array( |
| 906 | 'externalPermalinksEnabled' => $enable_external_permalinks, |
| 907 | ) ); |
| 908 | } |
| 909 | |
| 910 | // Media Categories |
| 911 | $enable_media_categories = ( array_key_exists( 'enable_media_categories', $options ) ? $options['enable_media_categories'] : false ); |
| 912 | if ( $enable_media_categories && !is_admin() && is_user_logged_in() ) { |
| 913 | wp_enqueue_style( |
| 914 | 'asenha-media-categories-frontend', |
| 915 | ASENHA_URL . 'assets/css/media-categories-frontend.css', |
| 916 | array(), |
| 917 | ASENHA_VERSION |
| 918 | ); |
| 919 | } |
| 920 | // Media Replacement |
| 921 | $enable_media_replacement = ( array_key_exists( 'enable_media_replacement', $options ) ? $options['enable_media_replacement'] : false ); |
| 922 | if ( $enable_media_replacement && is_user_logged_in() ) { |
| 923 | wp_enqueue_style( |
| 924 | 'asenha-media-replace-frontend', |
| 925 | ASENHA_URL . 'assets/css/media-replace-frontend.css', |
| 926 | array(), |
| 927 | ASENHA_VERSION |
| 928 | ); |
| 929 | } |
| 930 | } |
| 931 | |
| 932 | /** |
| 933 | * Add admin bar styles for wp-admin and frontend |
| 934 | * |
| 935 | * @since 6.2.1 |
| 936 | */ |
| 937 | function asenha_admin_bar_item_js_css() |
| 938 | { |
| 939 | if ( is_user_logged_in() ) { |
| 940 | ?> |
| 941 | <!--<script></script>--> |
| 942 | <style> |
| 943 | #wp-admin-bar-user-info .avatar { |
| 944 | object-fit: cover; |
| 945 | } |
| 946 | </style> |
| 947 | <?php |
| 948 | } |
| 949 | } |
| 950 | |
| 951 | /** |
| 952 | * Add 'Access now' plugin action link. |
| 953 | * |
| 954 | * @since 1.0.0 |
| 955 | */ |
| 956 | function asenha_plugin_action_links( $links ) |
| 957 | { |
| 958 | $settings_link = '<a href="tools.php?page=' . ASENHA_SLUG . '">Configure</a>'; |
| 959 | array_unshift( $links, $settings_link ); |
| 960 | return $links; |
| 961 | } |
| 962 | |
| 963 | /** |
| 964 | * Modify footer text |
| 965 | * |
| 966 | * @since 1.0.0 |
| 967 | */ |
| 968 | function asenha_footer_text() |
| 969 | { |
| 970 | // Show nothing |
| 971 | ?> |
| 972 | <?php |
| 973 | } |
| 974 | |
| 975 | /** |
| 976 | * Change WP version number text in footer |
| 977 | * |
| 978 | * @since 4.8.3 |
| 979 | */ |
| 980 | function asenha_footer_version_text() |
| 981 | { |
| 982 | ?> |
| 983 | ASE <a href="https://www.wpase.com/documentation/changelog/" target="_blank">v<?php |
| 984 | echo ASENHA_VERSION ; |
| 985 | ?></a> |
| 986 | <?php |
| 987 | } |
| 988 | |
| 989 | /** |
| 990 | * Check if current screen is this plugin's main page |
| 991 | * |
| 992 | * @since 1.0.0 |
| 993 | */ |
| 994 | function is_asenha() |
| 995 | { |
| 996 | $request_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] ); |
| 997 | // e.g. /wp-admin/index.php?page=page-slug |
| 998 | |
| 999 | if ( strpos( $request_uri, 'page=' . ASENHA_SLUG ) !== false ) { |
| 1000 | return true; |
| 1001 | // Yes, this is the plugin's main page |
| 1002 | } else { |
| 1003 | return false; |
| 1004 | // Nope, this is NOT the plugin's page |
| 1005 | } |
| 1006 | |
| 1007 | } |
| 1008 | |
| 1009 | /** |
| 1010 | * Mark that user have sponsored ASE |
| 1011 | * |
| 1012 | * @since 5.2.7 |
| 1013 | */ |
| 1014 | function asenha_have_sponsored() |
| 1015 | { |
| 1016 | |
| 1017 | if ( isset( $_REQUEST ) ) { |
| 1018 | $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() ); |
| 1019 | $asenha_stats['have_sponsored'] = true; |
| 1020 | $asenha_stats['sponsorship_nudge_dismissed'] = true; |
| 1021 | $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats ); |
| 1022 | |
| 1023 | if ( $success ) { |
| 1024 | echo json_encode( array( |
| 1025 | 'success' => true, |
| 1026 | ) ) ; |
| 1027 | } else { |
| 1028 | echo json_encode( array( |
| 1029 | 'success' => false, |
| 1030 | ) ) ; |
| 1031 | } |
| 1032 | |
| 1033 | } |
| 1034 | |
| 1035 | } |
| 1036 | |
| 1037 | /** |
| 1038 | * Dismiss sponsorship nudge |
| 1039 | * |
| 1040 | * @since 5.8.2 |
| 1041 | */ |
| 1042 | function asenha_dismiss_upgrade_nudge() |
| 1043 | { |
| 1044 | |
| 1045 | if ( isset( $_REQUEST ) ) { |
| 1046 | $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() ); |
| 1047 | $asenha_stats['upgrade_nudge_dismissed'] = true; |
| 1048 | $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats ); |
| 1049 | |
| 1050 | if ( $success ) { |
| 1051 | echo json_encode( array( |
| 1052 | 'success' => true, |
| 1053 | ) ) ; |
| 1054 | } else { |
| 1055 | echo json_encode( array( |
| 1056 | 'success' => false, |
| 1057 | ) ) ; |
| 1058 | } |
| 1059 | |
| 1060 | } |
| 1061 | |
| 1062 | } |
| 1063 | |
| 1064 | /** |
| 1065 | * Dismiss sponsorship nudge |
| 1066 | * |
| 1067 | * @since 5.2.7 |
| 1068 | */ |
| 1069 | function asenha_dismiss_sponsorship_nudge() |
| 1070 | { |
| 1071 | |
| 1072 | if ( isset( $_REQUEST ) ) { |
| 1073 | $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() ); |
| 1074 | $asenha_stats['sponsorship_nudge_dismissed'] = true; |
| 1075 | $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats ); |
| 1076 | |
| 1077 | if ( $success ) { |
| 1078 | echo json_encode( array( |
| 1079 | 'success' => true, |
| 1080 | ) ) ; |
| 1081 | } else { |
| 1082 | echo json_encode( array( |
| 1083 | 'success' => false, |
| 1084 | ) ) ; |
| 1085 | } |
| 1086 | |
| 1087 | } |
| 1088 | |
| 1089 | } |
| 1090 |