Skip to content

Commit

Permalink
added filters for wc_options, wc_triggers, wc_varyparams
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejmackowiak committed Feb 20, 2020
1 parent 9616a53 commit b607cec
Showing 1 changed file with 97 additions and 90 deletions.
187 changes: 97 additions & 90 deletions widget-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,105 +58,108 @@ function __construct()
'widget_cache_warning'
));
} else {
$this->__wgc_load_opts();

if ($this->wgcEnabled) {
if ($this->wgcAutoExpireEnabled) {
$this->triggerActions = array(
"category" => array(
"add_category",
"create_category",
"edit_category",
"delete_category"
),
"comment" => array(
"comment_post",
"edit_comment",
"delete_comment",
"pingback_post",
"trackback_post",
"wp_set_comment_status"
),
"link" => array(
"add_link",
"edit_link",
"delete_link"
),
"post" => array(
"publish_post",
"publish_to_draft",
"publish_to_pending",
"publish_to_trash",
"publish_to_future"
),
"tag" => array(
"create_term",
"edit_term",
"delete_term"
)
);
}
if ($this->wgcVaryParamsEnabled) {
$this->varyParams = array(
"userLevel" => array(
&$this,
'get_user_level'
),
"userLoggedIn" => array(
&$this,
'get_is_user_logged_in'
),
"userAgent" => array(
&$this,
'get_user_agent'
),
"currentCategory" => array(
&$this,
'get_current_category'
),
"amp" => array(
&$this,
'get_amp_vary_param'
)
);
}
add_action('wp_head', array(
&$this,
'widget_cache_redirect_callback'
), 99999);
}

if (is_admin()) {
add_action('admin_menu', array(
&$this,
'wp_add_options_page'
));
add_action('dashmenu', array(
&$this,
'dashboard_delete_wg_cache'
));

add_action('init', function(){
$this->__wgc_load_opts();

if ($this->wgcEnabled) {
add_action('sidebar_admin_page',
array(
&$this,
'widget_cache_options_filter'
));
if ($this->wgcAutoExpireEnabled) {
$this->triggerActions = array(
"category" => array(
"add_category",
"create_category",
"edit_category",
"delete_category"
),
"comment" => array(
"comment_post",
"edit_comment",
"delete_comment",
"pingback_post",
"trackback_post",
"wp_set_comment_status"
),
"link" => array(
"add_link",
"edit_link",
"delete_link"
),
"post" => array(
"publish_post",
"publish_to_draft",
"publish_to_pending",
"publish_to_trash",
"publish_to_future"
),
"tag" => array(
"create_term",
"edit_term",
"delete_term"
)
);
}
if ($this->wgcVaryParamsEnabled) {
$this->varyParams = array(
"userLevel" => array(
&$this,
'get_user_level'
),
"userLoggedIn" => array(
&$this,
'get_is_user_logged_in'
),
"userAgent" => array(
&$this,
'get_user_agent'
),
"currentCategory" => array(
&$this,
'get_current_category'
),
"amp" => array(
&$this,
'get_amp_vary_param'
)
);
}
add_action('wp_head', array(
&$this,
'widget_cache_redirect_callback'
), 99999);
}

add_action('sidebar_admin_setup',
array(
if (is_admin()) {
add_action('admin_menu', array(
&$this,
'widget_cache_expand_control'
'wp_add_options_page'
));

if (isset ($_GET ["wgdel"])) {
add_action('admin_notices', array(
add_action('dashmenu', array(
&$this,
'widget_wgdel_notice'
'dashboard_delete_wg_cache'
));

if ($this->wgcEnabled) {
add_action('sidebar_admin_page',
array(
&$this,
'widget_cache_options_filter'
));
}

add_action('sidebar_admin_setup',
array(
&$this,
'widget_cache_expand_control'
));

if (isset ($_GET ["wgdel"])) {
add_action('admin_notices', array(
&$this,
'widget_wgdel_notice'
));
}
}
}
});
}
}

Expand Down Expand Up @@ -207,6 +210,10 @@ function __wgc_load_opts()
$this->wgcTriggers = $this->wgc_get_option('widget_cache_action_trigger');
$this->wgcVaryParams = $this->wgc_get_option('widget_cache_vary_param');

$this->wgcOptions = apply_filters('wc_options', $this->wgc_get_option('widget_cache'));
$this->wgcTriggers = apply_filters('wc_triggers', $this->wgc_get_option('widget_cache_action_trigger'));
$this->wgcVaryParams = apply_filters('wc_varyparams', $this->wgc_get_option('widget_cache_vary_param'));

$this->wgcEnabled = $this->wgcSettings ["wgc_disabled"] != "1";

$this->wgcAutoExpireEnabled = $this->wgcSettings ["wgc_ae_ops_disabled"] != "1";
Expand Down

0 comments on commit b607cec

Please sign in to comment.