-
Notifications
You must be signed in to change notification settings - Fork 1
/
if-widget.php
executable file
·44 lines (33 loc) · 1.18 KB
/
if-widget.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/*
Plugin Name: If Widget - Visibility control for Widgets
Plugin URI: https://layered.market/plugins/if-widget
Description: Control what widgets your site’s visitors see, with custom visibility rules
Version: 0.5
Text Domain: if-widget
Author: Layered
Author URI: https://layered.market
License: GPL-3.0-or-later
License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/
require plugin_dir_path(__FILE__) . 'vendor/autoload.php';
// Prepare visibility rules (common in all IF plugins)
if (!function_exists('ifVisibilityRulesPrepare')) {
function ifVisibilityRulesPrepare(array $rules) {
return array_map(function(array $rule) {
if (!isset($rule['type'])) {
$rule['type'] = 'bool';
}
if (!isset($rule['group'])) {
$rule['group'] = __('Other', 'if-widget');
}
return $rule;
}, $rules);
}
}
// start the plugin
add_filter('if_visibility_rules', 'ifVisibilityRulesPrepare', 500);
add_filter('if_visibility_rules', '\Layered\IfWidget\VisibilityRules::rules');
add_action('plugins_loaded', '\Layered\IfWidget\WidgetVisibility::start');
add_action('plugins_loaded', '\Layered\IfWidget\Admin::start');
add_action('plugins_loaded', '\Layered\IfWidget\Addon::start');