-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new UI Config panel for Host Exclusion Patterns; See: websharks/comet-cache#754 #250
Conversation
@jaswsinc @raamdev Need some help with the wording and the conditional for the |
Lookin' great! :-) I suggest these opening paragraphs in this panel:
I would ditch the Tip: underneath the panel, but leave the Note: as-is. |
@@ -697,6 +697,28 @@ public function __construct() | |||
|
|||
echo '<div class="plugin-menu-page-panel">'."\n"; | |||
|
|||
if (is_multisite() && $this->plugin->applyWpFilters(GLOBAL_NS.'_exclude_hosts_option_enable', is_multisite())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be:
if ($this->plugin->applyWpFilters(GLOBAL_NS.'_exclude_hosts_option_enable', is_multisite())) {
Meaning, the filter is true
on a network by default, and the panel is shown. On a standard install, is_multisite()
is false and the filter will default to being off. In either case, a developer can override by attaching to and altering the filtered value used in the conditional.
@kristineds I suggest adding a logging routine while you're debugging this so that you can see more about what's happening internally. For instance, in the updateOptions() routine you could log what occurs there and take a closer look. file_put_contents(WP_CONTENT_DIR.'/debug.log', print_r(get_defined_vars(), true)."\n\n", FILE_APPEND); Instead of
just to help improve clarity with respect to The |
@jaswsinc @raamdev Added the debugging routine here. bac2103 Tested this on a multisite, but the domain still doesn't get save on the field when I save the options. Looking at my
Could you point me in the right direction on what I'm doing wrong? :)
Updated here. 8af5937 |
@@ -94,6 +94,9 @@ protected function fromLte151107() | |||
if (!empty($existing_options['cache_clear_xml_sitemap_patterns']) && strpos($existing_options['cache_clear_xml_sitemap_patterns'], '**') === false) { | |||
$this->plugin->options['cache_clear_xml_sitemap_patterns'] = str_replace('*', '**', $existing_options['cache_clear_xml_sitemap_patterns']); | |||
} | |||
if (!empty($existing_options['exclude_hosts']) && strpos($existing_options['exclude_hosts'], '**') === false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You won't need these lines, because this option did not exist prior; i.e., nothing to upgrade.
@kristineds Awesome work! 😀 I just put this through a couple of tests and it's working GREAT. @jaswsinc I noticed that the Host Exclusion Patterns panel shows up even when the Multisite Network is configured to use sub-directories ( Also, just to confirm: When using multisite with sub-directories, the existing URI Exclusion Patterns feature should be used, correct? (I confirmed that it works with sub-directories; I just want to confirm that's expected.) If so, I think we should do an additional things there:
|
Not really, no. An exception might be for sites running a domain-mapping plugin though. I would show that panel if ... if ((defined('SUBDOMAIN_INSTALL') && SUBDOMAIN_INSTALL) || $this->plugin->canConsiderDomainMapping()) {
}
Correct, yes.
Agree. |
@kristineds So, in the context of these changes where we have the filter. The filter could look like this. $exclude_hosts_option_enable = is_multisite() &&
((defined('SUBDOMAIN_INSTALL') && SUBDOMAIN_INSTALL) || $this->plugin->canConsiderDomainMapping());
if ($this->plugin->applyWpFilters(GLOBAL_NS.'_exclude_hosts_option_enable', $exclude_hosts_option_enable)) {
...
} |
@jaswsinc Like this? 7516eb9 |
Perfect, yes. |
@kristineds Is this ready for another review, or are you still working on this? |
@raamdev This is ready for review. :) |
@@ -62,6 +62,8 @@ public function updateOptions(array $options) | |||
$this->options = array_intersect_key($this->options, $this->default_options); | |||
update_site_option(GLOBAL_NS.'_options', $this->options); | |||
|
|||
file_put_contents(WP_CONTENT_DIR.'/debug.log', print_r(get_defined_vars(), true)."\n\n", FILE_APPEND); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kristineds Please remove this line before submitting a PR. This is for local debugging only and should never be included in any merge into the dev branch where it could end up on a live site and create a huge log file over time.
@kristineds I just ran this through a few more tests. The automatic hiding of the new Host Exclusion Patterns works great. There's only one thing left to do:
|
@kristineds I tested this (did you test after committing your change?) and I'm getting a notice at the bottom: It looks like there was a bug in my code example. I suggest searching elsewhere in the codebase for a similar check to see how it should be done and then running a test to make sure the code works as expected. |
@kristineds |
@kristineds I see in 2a3bf73 that you're not using However, |
@kristineds So the questions that need to be asked here are:
|
@raamdev Should it be |
@kristineds writes...
Yes, that looks correct to me. If you could test that on a multisite network with sub-directories (see https://codex.wordpress.org/Multisite_Network_Administration#Switching_network_types), that would be great. The note should NOT show up when a Multisite Network is using Sub-Domains, since that note is only applicable when using Sub-Directories. |
@kristineds FYI, I just merged the latest from |
@kristineds FYI, you had the note about Multisite Networks w/ Sub-Directories in the wrong panel; it should've gone in the URI Exclusion Patterns panel, not the Host Exclusion Patterns (in the scenario in which that note appears, the Host Exclusion Patterns panel is hidden, so it would never be seen). I fixed this in c181f9c. |
@raamdev Yikes. 😥 Thanks for catching that. |
Add new UI Config panel for Host Exclusion Patterns;
See: wpsharks/comet-cache#754