Version Description
- [fixed] warning on admin dashboard
Download this release
Release Info
Developer | intoxstudio |
Plugin | Content Aware Sidebars – Unlimited Widget Areas |
Version | 3.16.1 |
Comparing to | |
See all releases |
Code changes from version 3.15.2 to 3.16.1
- admin/admin_bar.php +45 -4
- admin/db-updates.php +40 -36
- admin/settings.php +93 -0
- admin/sidebar-edit.php +0 -1
- admin/sidebar-list-table.php +4 -4
- admin/sidebar-overview.php +1 -4
- app.php +7 -1
- conditions/placeholder.php +0 -11
- content-aware-sidebars.php +4 -3
- freemius.php +13 -9
- lib/wp-content-aware-engine/assets/js/condition_groups.min.js +3 -3
- lib/wp-content-aware-engine/bootstrap.php +3 -3
- lib/wp-content-aware-engine/core.php +46 -60
- lib/wp-content-aware-engine/meta.php +2 -2
- lib/wp-content-aware-engine/module/author.php +6 -23
- lib/wp-content-aware-engine/module/base.php +10 -7
- lib/wp-content-aware-engine/module/bbpress.php +6 -18
- lib/wp-content-aware-engine/module/bp_member.php +7 -26
- lib/wp-content-aware-engine/module/date.php +3 -6
- lib/wp-content-aware-engine/module/page_template.php +5 -20
- lib/wp-content-aware-engine/module/pods.php +7 -22
- lib/wp-content-aware-engine/module/polylang.php +9 -16
- lib/wp-content-aware-engine/module/post_type.php +20 -52
- lib/wp-content-aware-engine/module/qtranslate.php +9 -20
- lib/wp-content-aware-engine/module/static.php +5 -19
- lib/wp-content-aware-engine/module/taxonomy.php +117 -74
- lib/wp-content-aware-engine/module/translatepress.php +6 -16
- lib/wp-content-aware-engine/module/transposh.php +6 -21
- lib/wp-content-aware-engine/module/wpml.php +6 -20
- lib/wp-content-aware-engine/modulemanager.php +2 -2
- lib/wp-content-aware-engine/objectmanager.php +2 -2
- lib/wp-content-aware-engine/typemanager.php +2 -2
- lib/wp-content-aware-engine/view.php +2 -2
- lib/wp-content-aware-engine/view/condition_options.php +2 -2
- lib/wp-content-aware-engine/view/condition_template.php +2 -2
- lib/wp-content-aware-engine/view/group_template.php +2 -2
- lib/wp-content-aware-engine/view/meta_box.php +19 -19
- readme.txt +23 -3
- sidebar.php +20 -11
admin/admin_bar.php
CHANGED
@@ -48,8 +48,7 @@ class CAS_Admin_Bar
|
|
48 |
|
49 |
public function initiate()
|
50 |
{
|
51 |
-
|
52 |
-
if (is_admin() || !current_user_can($post_type_object->cap->create_posts)) {
|
53 |
return;
|
54 |
}
|
55 |
|
@@ -69,6 +68,15 @@ class CAS_Admin_Bar
|
|
69 |
top:2px;
|
70 |
margin:0!important;
|
71 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
#wp-admin-bar-wpcas-tool #wp-admin-bar-wpcas-tool-condition-types .ab-icon {
|
73 |
float:right!important;
|
74 |
margin-right:0!important;
|
@@ -128,12 +136,31 @@ class CAS_Admin_Bar
|
|
128 |
'title' => __('Theme Areas', 'content-aware-sidebars')
|
129 |
]);
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
$args = [];
|
132 |
foreach (WPCACore::get_conditional_modules('sidebar') as $module) {
|
133 |
$title = $module->get_name();
|
134 |
$link = '';
|
135 |
if (array_key_exists($module->get_id(), self::DOCS_MAP)) {
|
136 |
-
$title
|
137 |
$link = self::DOCS_MAP[$module->get_id()].'?utm_source=plugin&utm_medium=admin_bar&utm_campaign=cas';
|
138 |
}
|
139 |
$args[] = [
|
@@ -232,7 +259,7 @@ class CAS_Admin_Bar
|
|
232 |
*/
|
233 |
private function sort_nodes($a, $b)
|
234 |
{
|
235 |
-
return strcasecmp($a['
|
236 |
}
|
237 |
|
238 |
/**
|
@@ -250,6 +277,11 @@ class CAS_Admin_Bar
|
|
250 |
$this->detect_sidebar_target($has_widgets, $index);
|
251 |
}
|
252 |
|
|
|
|
|
|
|
|
|
|
|
253 |
private function detect_sidebar_target($has_widgets, $index)
|
254 |
{
|
255 |
$host_map = CAS_App::instance()->manager()->get_replacement_map();
|
@@ -257,4 +289,13 @@ class CAS_Admin_Bar
|
|
257 |
$this->detect_sidebar($has_widgets, $host_map[$index]);
|
258 |
}
|
259 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
}
|
48 |
|
49 |
public function initiate()
|
50 |
{
|
51 |
+
if (!$this->authorize_user()) {
|
|
|
52 |
return;
|
53 |
}
|
54 |
|
68 |
top:2px;
|
69 |
margin:0!important;
|
70 |
}
|
71 |
+
#wp-admin-bar-wpcas-tool .wpcas-ok .ab-item {
|
72 |
+
color:#8c8!important;
|
73 |
+
}
|
74 |
+
#wp-admin-bar-wpcas-tool .wpcas-warn .ab-item {
|
75 |
+
color:#dba617!important;
|
76 |
+
}
|
77 |
+
#wp-admin-bar-wpcas-tool #wp-admin-bar-wpcas-tool-condition-types .ab-sub-wrapper {
|
78 |
+
min-width:100%;
|
79 |
+
}
|
80 |
#wp-admin-bar-wpcas-tool #wp-admin-bar-wpcas-tool-condition-types .ab-icon {
|
81 |
float:right!important;
|
82 |
margin-right:0!important;
|
136 |
'title' => __('Theme Areas', 'content-aware-sidebars')
|
137 |
]);
|
138 |
|
139 |
+
$cache = get_option(WPCACore::OPTION_CONDITION_TYPE_CACHE, []);
|
140 |
+
if (isset($cache[CAS_App::TYPE_SIDEBAR]) && !empty($cache[CAS_App::TYPE_SIDEBAR])) {
|
141 |
+
$title = __('Cache Active', 'content-aware-sidebars');
|
142 |
+
$link = null;
|
143 |
+
$class = 'wpcas-ok';
|
144 |
+
} else {
|
145 |
+
$title = __('Activate Cache Now', 'content-aware-sidebars');
|
146 |
+
$link = wp_nonce_url(admin_url('admin.php?page=wpcas-settings&action=update_condition_type_cache'), 'update_condition_type_cache');
|
147 |
+
$class = 'wpcas-warn';
|
148 |
+
}
|
149 |
+
$this->add_node($admin_bar, [
|
150 |
+
'id' => 'condition_cache',
|
151 |
+
'title' => $title.' ⏺',
|
152 |
+
'href' => $link,
|
153 |
+
'meta' => [
|
154 |
+
'class' => $class,
|
155 |
+
]
|
156 |
+
], self::NODE_CONDITION_TYPES);
|
157 |
+
|
158 |
$args = [];
|
159 |
foreach (WPCACore::get_conditional_modules('sidebar') as $module) {
|
160 |
$title = $module->get_name();
|
161 |
$link = '';
|
162 |
if (array_key_exists($module->get_id(), self::DOCS_MAP)) {
|
163 |
+
$title = '<span class="ab-icon dashicons dashicons-external"></span> '.$title;
|
164 |
$link = self::DOCS_MAP[$module->get_id()].'?utm_source=plugin&utm_medium=admin_bar&utm_campaign=cas';
|
165 |
}
|
166 |
$args[] = [
|
259 |
*/
|
260 |
private function sort_nodes($a, $b)
|
261 |
{
|
262 |
+
return strcasecmp($a['id'], $b['id']);
|
263 |
}
|
264 |
|
265 |
/**
|
277 |
$this->detect_sidebar_target($has_widgets, $index);
|
278 |
}
|
279 |
|
280 |
+
/**
|
281 |
+
* @param bool $has_widgets
|
282 |
+
* @param string $index
|
283 |
+
* @return void
|
284 |
+
*/
|
285 |
private function detect_sidebar_target($has_widgets, $index)
|
286 |
{
|
287 |
$host_map = CAS_App::instance()->manager()->get_replacement_map();
|
289 |
$this->detect_sidebar($has_widgets, $host_map[$index]);
|
290 |
}
|
291 |
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* @return bool
|
295 |
+
*/
|
296 |
+
private function authorize_user()
|
297 |
+
{
|
298 |
+
$post_type_object = get_post_type_object(CAS_App::TYPE_SIDEBAR);
|
299 |
+
return current_user_can($post_type_object->cap->create_posts);
|
300 |
+
}
|
301 |
}
|
admin/db-updates.php
CHANGED
@@ -16,53 +16,24 @@ $cas_db_updater->register_version_update('3.1', 'cas_update_to_31');
|
|
16 |
$cas_db_updater->register_version_update('3.4', 'cas_update_to_34');
|
17 |
$cas_db_updater->register_version_update('3.5.1', 'cas_update_to_351');
|
18 |
$cas_db_updater->register_version_update('3.8', 'cas_update_to_38');
|
19 |
-
$cas_db_updater->register_version_update('3.15', 'cas_update_to_315');
|
20 |
$cas_db_updater->register_version_update('3.15.2', 'cas_update_to_3152');
|
|
|
21 |
|
22 |
-
/**
|
23 |
-
* Add -1 to condition groups with select terms
|
24 |
-
*
|
25 |
-
* @since 3.15.2
|
26 |
-
*
|
27 |
-
* @return bool
|
28 |
-
*/
|
29 |
-
function cas_update_to_3152()
|
30 |
-
{
|
31 |
-
$taxonomies = array_map(function ($value) {
|
32 |
-
return "'" . esc_sql($value) . "'";
|
33 |
-
}, get_taxonomies(['public' => true]));
|
34 |
-
|
35 |
-
if (empty($taxonomies)) {
|
36 |
-
return true;
|
37 |
-
}
|
38 |
-
|
39 |
-
global $wpdb;
|
40 |
-
|
41 |
-
$condition_group_ids = array_unique((array)$wpdb->get_col("
|
42 |
-
SELECT p.ID FROM $wpdb->posts p
|
43 |
-
INNER JOIN $wpdb->term_relationships r ON r.object_id = p.ID
|
44 |
-
INNER JOIN $wpdb->term_taxonomy t ON t.term_taxonomy_id = r.term_taxonomy_id
|
45 |
-
WHERE p.post_type = 'condition_group'
|
46 |
-
AND t.taxonomy IN (".implode(',', $taxonomies).')
|
47 |
-
'));
|
48 |
-
|
49 |
-
foreach ($condition_group_ids as $id) {
|
50 |
-
add_post_meta($id, '_ca_taxonomy', '-1');
|
51 |
-
}
|
52 |
-
|
53 |
-
return true;
|
54 |
-
}
|
55 |
|
56 |
/**
|
57 |
* Enable legacy date module and
|
58 |
* negated conditions if in use
|
59 |
*
|
60 |
-
*
|
|
|
|
|
61 |
*
|
62 |
* @return bool
|
63 |
*/
|
64 |
-
function
|
65 |
{
|
|
|
|
|
66 |
global $wpdb;
|
67 |
|
68 |
$types = WPCACore::types()->get_all();
|
@@ -98,6 +69,39 @@ function cas_update_to_315()
|
|
98 |
return true;
|
99 |
}
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
/**
|
103 |
* Update to version 3.8
|
16 |
$cas_db_updater->register_version_update('3.4', 'cas_update_to_34');
|
17 |
$cas_db_updater->register_version_update('3.5.1', 'cas_update_to_351');
|
18 |
$cas_db_updater->register_version_update('3.8', 'cas_update_to_38');
|
|
|
19 |
$cas_db_updater->register_version_update('3.15.2', 'cas_update_to_3152');
|
20 |
+
$cas_db_updater->register_version_update('3.16.1', 'cas_update_to_3161');
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
/**
|
24 |
* Enable legacy date module and
|
25 |
* negated conditions if in use
|
26 |
*
|
27 |
+
* Clear condition type cache
|
28 |
+
*
|
29 |
+
* @since 3.16.1
|
30 |
*
|
31 |
* @return bool
|
32 |
*/
|
33 |
+
function cas_update_to_3161()
|
34 |
{
|
35 |
+
update_option('_ca_condition_type_cache', []);
|
36 |
+
|
37 |
global $wpdb;
|
38 |
|
39 |
$types = WPCACore::types()->get_all();
|
69 |
return true;
|
70 |
}
|
71 |
|
72 |
+
/**
|
73 |
+
* Add -1 to condition groups with select terms
|
74 |
+
*
|
75 |
+
* @since 3.15.2
|
76 |
+
*
|
77 |
+
* @return bool
|
78 |
+
*/
|
79 |
+
function cas_update_to_3152()
|
80 |
+
{
|
81 |
+
$taxonomies = array_map(function ($value) {
|
82 |
+
return "'" . esc_sql($value) . "'";
|
83 |
+
}, get_taxonomies(['public' => true]));
|
84 |
+
|
85 |
+
if (empty($taxonomies)) {
|
86 |
+
return true;
|
87 |
+
}
|
88 |
+
|
89 |
+
global $wpdb;
|
90 |
+
|
91 |
+
$condition_group_ids = array_unique((array)$wpdb->get_col("
|
92 |
+
SELECT p.ID FROM $wpdb->posts p
|
93 |
+
INNER JOIN $wpdb->term_relationships r ON r.object_id = p.ID
|
94 |
+
INNER JOIN $wpdb->term_taxonomy t ON t.term_taxonomy_id = r.term_taxonomy_id
|
95 |
+
WHERE p.post_type = 'condition_group'
|
96 |
+
AND t.taxonomy IN (".implode(',', $taxonomies).')
|
97 |
+
'));
|
98 |
+
|
99 |
+
foreach ($condition_group_ids as $id) {
|
100 |
+
add_post_meta($id, '_ca_taxonomy', '-1');
|
101 |
+
}
|
102 |
+
|
103 |
+
return true;
|
104 |
+
}
|
105 |
|
106 |
/**
|
107 |
* Update to version 3.8
|
admin/settings.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Content Aware Sidebars
|
4 |
+
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
+
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
+
*/
|
8 |
+
|
9 |
+
defined('ABSPATH') || exit;
|
10 |
+
|
11 |
+
class CAS_Admin_Settings extends CAS_Admin
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* @inheritDoc
|
15 |
+
*/
|
16 |
+
public function admin_hooks()
|
17 |
+
{
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @inheritDoc
|
22 |
+
*/
|
23 |
+
public function get_screen()
|
24 |
+
{
|
25 |
+
$screen = add_submenu_page(
|
26 |
+
CAS_App::BASE_SCREEN.'-bogus', //dont add menu item
|
27 |
+
null,
|
28 |
+
null,
|
29 |
+
$this->authorize_user(),
|
30 |
+
CAS_App::BASE_SCREEN.'-settings',
|
31 |
+
[$this,'render_screen']
|
32 |
+
);
|
33 |
+
return $screen;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @inheritDoc
|
38 |
+
*/
|
39 |
+
public function authorize_user()
|
40 |
+
{
|
41 |
+
$post_type_object = $this->get_sidebar_type();
|
42 |
+
return $post_type_object->cap->edit_posts;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @inheritDoc
|
47 |
+
*/
|
48 |
+
public function prepare_screen()
|
49 |
+
{
|
50 |
+
$this->process_actions();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @inheritDoc
|
55 |
+
*/
|
56 |
+
public function process_actions()
|
57 |
+
{
|
58 |
+
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
|
59 |
+
|
60 |
+
if (!$action) {
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
|
64 |
+
check_admin_referer($action);
|
65 |
+
|
66 |
+
$sendback = wp_get_referer();
|
67 |
+
|
68 |
+
switch ($action) {
|
69 |
+
case 'update_condition_type_cache':
|
70 |
+
WPCACore::cache_condition_types();
|
71 |
+
break;
|
72 |
+
default:
|
73 |
+
break;
|
74 |
+
}
|
75 |
+
|
76 |
+
wp_safe_redirect($sendback);
|
77 |
+
exit();
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @inheritDoc
|
82 |
+
*/
|
83 |
+
public function render_screen()
|
84 |
+
{
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @inheritDoc
|
89 |
+
*/
|
90 |
+
public function add_scripts_styles()
|
91 |
+
{
|
92 |
+
}
|
93 |
+
}
|
admin/sidebar-edit.php
CHANGED
@@ -186,7 +186,6 @@ final class CAS_Sidebar_Edit extends CAS_Admin
|
|
186 |
}
|
187 |
|
188 |
if ($action && $post_id) {
|
189 |
-
//wp_reset_vars( array( 'action' ) );
|
190 |
$sendback = wp_get_referer();
|
191 |
$sendback = remove_query_arg(
|
192 |
['action','trashed', 'untrashed', 'deleted', 'ids'],
|
186 |
}
|
187 |
|
188 |
if ($action && $post_id) {
|
|
|
189 |
$sendback = wp_get_referer();
|
190 |
$sendback = remove_query_arg(
|
191 |
['action','trashed', 'untrashed', 'deleted', 'ids'],
|
admin/sidebar-list-table.php
CHANGED
@@ -460,9 +460,9 @@ class CAS_Sidebar_List_Table extends WP_List_Table
|
|
460 |
|
461 |
if ($action) {
|
462 |
switch ($action->get_data($post->ID)) {
|
463 |
-
case
|
464 |
-
case
|
465 |
-
case
|
466 |
$return = $action->get_list_data($post->ID);
|
467 |
$data = [];
|
468 |
$hosts = $metadata->get('host')->get_data($post->ID, false, false);
|
@@ -491,7 +491,7 @@ class CAS_Sidebar_List_Table extends WP_List_Table
|
|
491 |
}
|
492 |
echo $return;
|
493 |
break;
|
494 |
-
case
|
495 |
echo "<input type='text' value='[ca-sidebar id=\"$post->ID\"]' readonly />";
|
496 |
break;
|
497 |
default:
|
460 |
|
461 |
if ($action) {
|
462 |
switch ($action->get_data($post->ID)) {
|
463 |
+
case CAS_App::ACTION_REPLACE:
|
464 |
+
case CAS_App::ACTION_MERGE:
|
465 |
+
case CAS_App::ACTION_REPLACE_FORCED:
|
466 |
$return = $action->get_list_data($post->ID);
|
467 |
$data = [];
|
468 |
$hosts = $metadata->get('host')->get_data($post->ID, false, false);
|
491 |
}
|
492 |
echo $return;
|
493 |
break;
|
494 |
+
case CAS_App::ACTION_SHORTCODE:
|
495 |
echo "<input type='text' value='[ca-sidebar id=\"$post->ID\"]' readonly />";
|
496 |
break;
|
497 |
default:
|
admin/sidebar-overview.php
CHANGED
@@ -37,10 +37,7 @@ final class CAS_Sidebar_Overview extends CAS_Admin
|
|
37 |
*/
|
38 |
public function get_screen()
|
39 |
{
|
40 |
-
global $_wp_last_object_menu;
|
41 |
-
|
42 |
$post_type_object = $this->get_sidebar_type();
|
43 |
-
|
44 |
$notification_label = $this->notification_count ? sprintf(' <span class="awaiting-mod">%d</span>', $this->notification_count) : '';
|
45 |
|
46 |
add_menu_page(
|
@@ -50,7 +47,7 @@ final class CAS_Sidebar_Overview extends CAS_Admin
|
|
50 |
CAS_App::BASE_SCREEN,
|
51 |
[$this,'render_screen'],
|
52 |
$post_type_object->menu_icon,
|
53 |
-
|
54 |
);
|
55 |
|
56 |
return add_submenu_page(
|
37 |
*/
|
38 |
public function get_screen()
|
39 |
{
|
|
|
|
|
40 |
$post_type_object = $this->get_sidebar_type();
|
|
|
41 |
$notification_label = $this->notification_count ? sprintf(' <span class="awaiting-mod">%d</span>', $this->notification_count) : '';
|
42 |
|
43 |
add_menu_page(
|
47 |
CAS_App::BASE_SCREEN,
|
48 |
[$this,'render_screen'],
|
49 |
$post_type_object->menu_icon,
|
50 |
+
60 //after Appearance
|
51 |
);
|
52 |
|
53 |
return add_submenu_page(
|
app.php
CHANGED
@@ -11,7 +11,7 @@ defined('ABSPATH') || exit;
|
|
11 |
final class CAS_App
|
12 |
{
|
13 |
const PLUGIN_VERSION_KEY = 'cas_db_version';
|
14 |
-
const PLUGIN_VERSION = '3.
|
15 |
|
16 |
/**
|
17 |
* Prefix for sidebar id
|
@@ -30,6 +30,11 @@ final class CAS_App
|
|
30 |
const STATUS_INACTIVE = 'draft';
|
31 |
const STATUS_SCHEDULED = 'future';
|
32 |
|
|
|
|
|
|
|
|
|
|
|
33 |
/**
|
34 |
* Capability to manage sidebars
|
35 |
*/
|
@@ -84,6 +89,7 @@ final class CAS_App
|
|
84 |
new CAS_Sidebar_Edit();
|
85 |
new CAS_Quick_Select();
|
86 |
new CAS_Admin_Screen_Widgets();
|
|
|
87 |
} else {
|
88 |
new CAS_Admin_Bar();
|
89 |
}
|
11 |
final class CAS_App
|
12 |
{
|
13 |
const PLUGIN_VERSION_KEY = 'cas_db_version';
|
14 |
+
const PLUGIN_VERSION = '3.16.1';
|
15 |
|
16 |
/**
|
17 |
* Prefix for sidebar id
|
30 |
const STATUS_INACTIVE = 'draft';
|
31 |
const STATUS_SCHEDULED = 'future';
|
32 |
|
33 |
+
const ACTION_REPLACE = 0;
|
34 |
+
const ACTION_MERGE = 1;
|
35 |
+
const ACTION_SHORTCODE = 2;
|
36 |
+
const ACTION_REPLACE_FORCED = 3;
|
37 |
+
|
38 |
/**
|
39 |
* Capability to manage sidebars
|
40 |
*/
|
89 |
new CAS_Sidebar_Edit();
|
90 |
new CAS_Quick_Select();
|
91 |
new CAS_Admin_Screen_Widgets();
|
92 |
+
new CAS_Admin_Settings();
|
93 |
} else {
|
94 |
new CAS_Admin_Bar();
|
95 |
}
|
conditions/placeholder.php
CHANGED
@@ -106,17 +106,6 @@ final class CASConditionPlaceholder extends WPCAModule_Base
|
|
106 |
return [];
|
107 |
}
|
108 |
|
109 |
-
/**
|
110 |
-
* @since 3.9
|
111 |
-
* @param array $posts
|
112 |
-
*
|
113 |
-
* @return array
|
114 |
-
*/
|
115 |
-
public function filter_excluded_context($posts)
|
116 |
-
{
|
117 |
-
return $posts;
|
118 |
-
}
|
119 |
-
|
120 |
/**
|
121 |
* @since 3.9
|
122 |
*/
|
106 |
return [];
|
107 |
}
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
/**
|
110 |
* @since 3.9
|
111 |
*/
|
content-aware-sidebars.php
CHANGED
@@ -9,17 +9,17 @@
|
|
9 |
Plugin Name: Content Aware Sidebars
|
10 |
Plugin URI: https://dev.institute/wordpress-sidebars/
|
11 |
Description: Unlimited custom sidebars and widget areas for any post, page, category etc.
|
12 |
-
Version: 3.
|
13 |
Author: Joachim Jensen - DEV Institute
|
14 |
Author URI: https://dev.institute
|
15 |
-
Requires at least:
|
16 |
Requires PHP: 5.6
|
17 |
Text Domain: content-aware-sidebars
|
18 |
Domain Path: /lang/
|
19 |
License: GPLv3
|
20 |
|
21 |
Content Aware Sidebars Plugin
|
22 |
-
Copyright (C) 2011-
|
23 |
|
24 |
This program is free software: you can redistribute it and/or modify
|
25 |
it under the terms of the GNU General Public License as published by
|
@@ -59,6 +59,7 @@ if (!class_exists('CAS_App')) {
|
|
59 |
require($cas_dir_path.'admin/sidebar-overview.php');
|
60 |
require($cas_dir_path.'admin/sidebar-edit.php');
|
61 |
require($cas_dir_path.'admin/screen_widgets.php');
|
|
|
62 |
require($cas_dir_path.'sidebar.php');
|
63 |
require($cas_dir_path.'freemius.php');
|
64 |
require($cas_dir_path.'admin/db-updates.php');
|
9 |
Plugin Name: Content Aware Sidebars
|
10 |
Plugin URI: https://dev.institute/wordpress-sidebars/
|
11 |
Description: Unlimited custom sidebars and widget areas for any post, page, category etc.
|
12 |
+
Version: 3.16.1
|
13 |
Author: Joachim Jensen - DEV Institute
|
14 |
Author URI: https://dev.institute
|
15 |
+
Requires at least: 5.0
|
16 |
Requires PHP: 5.6
|
17 |
Text Domain: content-aware-sidebars
|
18 |
Domain Path: /lang/
|
19 |
License: GPLv3
|
20 |
|
21 |
Content Aware Sidebars Plugin
|
22 |
+
Copyright (C) 2011-2021 Joachim Jensen - jv@intox.dk
|
23 |
|
24 |
This program is free software: you can redistribute it and/or modify
|
25 |
it under the terms of the GNU General Public License as published by
|
59 |
require($cas_dir_path.'admin/sidebar-overview.php');
|
60 |
require($cas_dir_path.'admin/sidebar-edit.php');
|
61 |
require($cas_dir_path.'admin/screen_widgets.php');
|
62 |
+
require($cas_dir_path.'admin/settings.php');
|
63 |
require($cas_dir_path.'sidebar.php');
|
64 |
require($cas_dir_path.'freemius.php');
|
65 |
require($cas_dir_path.'admin/db-updates.php');
|
freemius.php
CHANGED
@@ -94,17 +94,21 @@ function cas_fs_upgrade()
|
|
94 |
}
|
95 |
|
96 |
add_action( 'admin_init', 'cas_fs_upgrade', 999 );
|
97 |
-
function cas_fs_uninstall()
|
98 |
-
{
|
99 |
-
require plugin_dir_path( __FILE__ ) . '/cas_uninstall.php';
|
100 |
-
}
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
-
if ( $cas_fs->is_on() ) {
|
104 |
-
$cas_fs->add_action( 'after_uninstall', 'cas_fs_uninstall' );
|
105 |
-
} elseif ( is_admin() ) {
|
106 |
-
//after_uninstall is only run for new users
|
107 |
-
register_uninstall_hook( plugin_dir_path( __FILE__ ) . 'content-aware-sidebars.php', 'cas_fs_uninstall' );
|
108 |
}
|
109 |
|
110 |
// Signal that SDK was initiated.
|
94 |
}
|
95 |
|
96 |
add_action( 'admin_init', 'cas_fs_upgrade', 999 );
|
|
|
|
|
|
|
|
|
97 |
|
98 |
+
if ( !$cas_fs->can_use_premium_code() ) {
|
99 |
+
function cas_fs_uninstall()
|
100 |
+
{
|
101 |
+
require plugin_dir_path( __FILE__ ) . '/cas_uninstall.php';
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
if ( $cas_fs->is_on() ) {
|
106 |
+
$cas_fs->add_action( 'after_uninstall', 'cas_fs_uninstall' );
|
107 |
+
} elseif ( is_admin() ) {
|
108 |
+
//after_uninstall is only run for new users
|
109 |
+
register_uninstall_hook( plugin_dir_path( __FILE__ ) . 'content-aware-sidebars.php', 'cas_fs_uninstall' );
|
110 |
+
}
|
111 |
|
|
|
|
|
|
|
|
|
|
|
112 |
}
|
113 |
|
114 |
// Signal that SDK was initiated.
|
lib/wp-content-aware-engine/assets/js/condition_groups.min.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/*!
|
2 |
-
* @package
|
3 |
* @author Joachim Jensen <joachim@dev.institute>
|
4 |
* @license GPLv3
|
5 |
-
* @copyright
|
6 |
*/
|
7 |
-
var CAE=CAE||{};!function($,CAE){"use strict";CAE.settings={views:{}},CAE.Models={},CAE.Models.Alert=Backbone.Model.extend({defaults:{text:"",success:!0},sync:function(){return!1},url:"",reset:function(){this.set(this.defaults)}}),CAE.Models.Condition=Backbone.Model.extend({unsaved:{prompt:WPCA.unsaved,unloadWindowPrompt:!0},defaults:{module:null,label:"",placeholder:"",values:[],default_value:null},initialize:function(){this.startTracking(),this.on("destroy",this.stopTracking,this)},sync:function(){return!1},url:""}),CAE.Models.Group=Backbone.Model.extend({unsaved:{prompt:WPCA.unsaved,unloadWindowPrompt:!0},defaults:function(){var e=WPCA.meta_default;return e.id=null,e.status="wpca_or",e.exposure=1,e},initialize:function(){this.startTracking(),this.on("destroy",this.stopTracking,this),this.conditions||(this.conditions=new CAE.Models.ConditionCollection)},parse:function(e){var t=[];if(_.has(e,"conditions")){for(var n in e.conditions)if(e.conditions.hasOwnProperty(n)){var i=[],o=e.conditions[n];for(var s in o.data)o.data.hasOwnProperty(s)&&i.push({text:"object"==typeof o.data[s]?o.data[s].text:o.data[s],id:s});delete o.data,o.module=n,o.values=i,t.push(o)}delete e.conditions}return this.conditions=new CAE.Models.ConditionCollection(t),e},sync:function(){return!1},url:""}),CAE.Models.GroupCollection=Backbone.Collection.extend({model:CAE.Models.Group,parse:function(e){return e}}),CAE.Models.ConditionCollection=Backbone.Collection.extend({model:CAE.Models.Condition}),CAE.Views={},CAE.Views.Alert=Backbone.Epoxy.View.extend({bindings:"data-vm",tagName:"div",className:"wpca-alert",template:"<div data-vm=\"classes:{'wpca-success':success,'wpca-error':not(success)},text:text\"></div>",timer:4e3,success:function(e){this.model.set({text:e,success:!0})},failure:function(e){this.model.set({text:e,success:!1})},dismiss:function(){var e=this;this.$el.fadeOut("slow",function(){e.model.reset()})},initialize:function(){this.listenTo(this.model,"change:text",this.show),this.$el.appendTo("body").hide().html(this.template)},show:function(){if(""!==this.model.get("text")){this.$el.fadeIn("slow");var e=this;setTimeout(function(){e.dismiss()},this.timer)}}}),CAE.Views.Condition=Backbone.Epoxy.View.extend({bindings:"data-vm",model:CAE.Models.Condition,tagName:"div",className:"cas-condition",templateName:"#wpca-template-condition",events:{"click .js-wpca-condition-remove":"removeModel"},initialize:function(){this.listenTo(this.model,"destroy",this.remove);var e=$(this.templateName);e.length?(this.template=e.html(),this.$el.append(this.template),this.createSuggestInput()):this.model.destroy()},removeModel:function(e){var t=this;this.$el.slideUp(300,function(){t.model.destroy()})},createSuggestInput:function(){var n=this.$el.find(".js-wpca-suggest");if(n.length){var i=this.model,e=this.model.get("values"),t=$("<div></div>").html(i.get("placeholder")).text();n.select2({cachedResults:{},quietMillis:400,searchTimer:null,type:i.get("module"),theme:"wpca",dir:WPCA.text_direction,placeholder:t,minimumInputLength:0,closeOnSelect:!0,width:"100%",language:{noResults:function(){return WPCA.noResults},searching:function(){return WPCA.searching+"..."},loadingMore:function(){return WPCA.loadingMore+"..."}},nextSearchTerm:function(e,t){return t},templateResult:function(e){return e.level?$('<span class="wpca-level-'+e.level+'">'+e.text+"</span>"):e.text},data:e,dataAdapter:l.wpcaDataAdapter,ajax:{}}).on("select2:selecting",function(e){n.data("forceOpen",!0)}).on("select2:closing",function(e){n.data("forceOpen")&&(e.preventDefault(),n.data("forceOpen",!1))}),e.length&&n.val(_.map(e,function(e){return e.id})).trigger("change"),n.on("change",function(e){var t=n.select2("data");i.set("values",t)})}}}),CAE.Views.Group=Backbone.Epoxy.View.extend({bindings:"data-vm",model:CAE.Models.Group,tagName:"li",className:"cas-group-single",template:$("#wpca-template-group").html(),itemView:function(e){return CAE.Views[e.model.get("module")]?new(CAE.Views[e.model.get("module")])(e):new CAE.Views.Condition(e)},events:{"click .js-wpca-save-group":"saveGroup","click .js-wpca-options":"showOptions"},computeds:{statusNegated:{deps:["status"],get:function(e){return"negated"==e},set:function(e){var t=e?"negated":"wpca_or";this.setBinding("status",t)}},statusExcept:{deps:["status"],get:function(e){return"wpca_except"==e},set:function(e){var t=e?"wpca_except":"wpca_or";this.setBinding("status",t)}},statusLabel:function(){switch(this.getBinding("status")){case"wpca_except":return WPCA.condition_except;case"negated":return WPCA.condition_not;default:return WPCA.condition_or}}},bindingFilters:{int:{get:function(e){return e?1:0},set:function(e){return e?1:0}},binary:{get:function(e){return e?1:0},set:function(e){return e?1:0}},hasModule:function(e){for(var t={},n=1;n<arguments.length;n++)t[arguments[n]]=!0;return e.filter(function(e){return t.hasOwnProperty(e.get("module"))}).length==arguments.length-1},hasAnyModule:function(e){for(var t={},n=1;n<arguments.length;n++)t[arguments[n]]=!0;return!!e.find(function(e){return t.hasOwnProperty(e.get("module"))})}},initialize:function(){this.collection=this.model.conditions,this.$el.hide().html(this.template).fadeIn(300),this.listenTo(this.model,"destroy",this.remove),this.listenTo(this.model,"unsavedChanges",this.saveChanges),this.listenTo(this.model.conditions,"unsavedChanges",this.saveChanges),this.listenTo(this.model.conditions,"add remove",this.saveAddRemove);var i=this,o=$(".js-wpca-add-and",this.$el);o.select2({theme:"wpca",placeholder:"+ "+WPCA.newCondition,minimumInputLength:0,closeOnSelect:!0,allowClear:!1,width:"resolve",matcher:l.wpcaModuleMatcher,nextSearchTerm:function(e,t){return t},data:WPCA.conditions}).on("select2:select",function(e){var t=e.params.data;if(!i.model.conditions.findWhere({module:t.id})){var n=new CAE.Models.Condition({module:t.id,label:t.text,placeholder:t.placeholder,default_value:t.default_value});i.model.conditions.add(n)}o.val(null).trigger("change")})},showOptions:function(e){$(e.delegateTarget).find(".cas-group-options").slideToggle(200),$(e.currentTarget).toggleClass("active")},saveChanges:function(e,t){e&&i.start(this)},saveAddRemove:function(e,t,n){t.length?n.add?""!==e.get("default_value")&&i.start(this):this.model.get("id")&&i.start(this):(i.clear(this),this.model.get("id")?this.saveGroup():this.removeModel())},removeModel:function(){var e=this;this.$el.slideUp(400,function(){e.model.destroy()})},saveGroup:function(e){var i=this.$el.find(".spinner"),o=this.$el.find(".js-wpca-save-group"),t=this,n=_.clone(this.model.attributes);n.action="wpca/add-rule",n.token=l.nonce,n.current_id=l.sidebarID,n.post_type=WPCA.post_type,n.conditions={},this.model.conditions.each(function(e){e.get("values").length?n.conditions[e.get("module")]=e.get("values").map(function(e){return e.id}):""!==e.get("default_value")&&(n.conditions[e.get("module")]=[e.get("default_value")])}),o.attr("disabled",!0),i.addClass("is-active"),$.ajax({url:ajaxurl,data:n,dataType:"JSON",type:"POST",success:function(e){l.alert.success(e.message),e.removed?t.removeModel():e.new_post_id&&t.model.set("id",e.new_post_id,{silent:!0}),e.removed||(o.hide(),i.removeClass("is-active"),t.model.restartTracking(),t.model.conditions.each(function(e){e.restartTracking()}))},error:function(e,t,n){o.attr("disabled",!1).show(),i.removeClass("is-active"),l.alert.failure(e.responseJSON.data)}})},slideRemove:function(){this.$el.slideUp(400,function(){this.remove()})}}),CAE.Views.GroupCollection=Backbone.Epoxy.View.extend({bindings:"data-vm",el:"#cas-groups",collection:CAE.Models.GroupCollection,events:{"click .js-wpca-add-quick":"addGroupQuick","click .js-wpca-save":"saveAll"},conditionsById:{},initialize:function(){var o=this;this.conditionsById=_.chain(WPCA.conditions).pluck(["children"]).flatten().indexBy("id").value();var s=$(".js-wpca-add-or",this.$el);s.select2({theme:"wpca",placeholder:"+ "+WPCA.newGroup,minimumInputLength:0,closeOnSelect:!0,allowClear:!1,width:"auto",matcher:l.wpcaModuleMatcher,nextSearchTerm:function(e,t){return t},data:WPCA.conditions}).on("select2:select",function(e){var t=e.params.data,n=new CAE.Models.Group,i=new CAE.Models.Condition({module:t.id,label:t.text,placeholder:t.placeholder,default_value:t.default_value});o.collection.add(n),n.conditions.add(i),s.val(null).trigger("change")})},itemView:function(e){return new CAE.Views.Group(e)},addGroupQuick:function(e){e.preventDefault();var t=$(e.currentTarget).data("config"),n=new CAE.Models.Group;for(var i in n.set(t.options),this.collection.add(n),t.modules)if(this.conditionsById.hasOwnProperty(t.modules[i])){var o=this.conditionsById[t.modules[i]],s=new CAE.Models.Condition({module:o.id,label:o.text,placeholder:o.placeholder,default_value:o.default_value});n.conditions.add(s)}}}),$.fn.select2.amd.require(["select2/selection/search"],function(e){e.prototype.searchRemoveChoice=function(e,t){this.trigger("unselect",{data:t}),this.$search.val(""),this.handleSearch()}},null,!0),$.fn.select2.amd.require(["select2/results"],function(e){e.prototype.ensureHighlightVisible=function(){this.$results.resize()}},null,!0),$.fn.select2.amd.define("select2/wpca/conditionData",["select2/data/array","select2/utils"],function(e,t){function n(e,t){n.__super__.constructor.call(this,e,t)}return t.Extend(n,e),n.prototype.query=function(n,i){n.term=n.term||"";var o=this.options.options,s=o.cachedResults[n.term],a=n.page||1;if(s&&s.page>=a){if(!(1<a))return void i({results:s.items,pagination:{more:s.more}});a=s.page}clearTimeout(o.searchTimer),o.searchTimer=setTimeout(function(){$.ajax({url:ajaxurl,data:{search:n.term,paged:a,limit:20,action:"wpca/module/"+o.type,sidebar_id:l.sidebarID,nonce:l.nonce},dataType:"JSON",type:"POST",success:function(e){var t=20<=e.length;o.cachedResults[n.term]={page:a,more:t,items:s?o.cachedResults[n.term].items.concat(e):e},i({results:e,pagination:{more:t}})}})},o.quietMillis)},n}),$.fn.select2.amd.define("select2/wpca/moduleMatcher",["select2/diacritics"],function(t){function l(e){return e.replace(/[^\u0000-\u007E]/g,function(e){return t[e]||e})}return function e(t,n){if(null==t.term||""===t.term.trim())return n;var i=l(n.text).toUpperCase(),o=l(t.term).toUpperCase();if(-1<i.indexOf(o))return n;if(n.children&&0<n.children.length){for(var s=$.extend(!0,{},n),a=n.children.length-1;0<=a;a--)null==e(t,n.children[a])&&s.children.splice(a,1);return 0<s.children.length?s:e(t,s)}return null}});var i={treshold:2e3,timerQueue:{},start:function(e){this.clear(e);var t=this;this.timerQueue[e.cid]=window.setTimeout(function(){t.set(e)},this.treshold)},set:function(e){e.saveGroup()},clear:function(e){e&&this.timerQueue[e.cid]&&window.clearInterval(this.timerQueue[e.cid])}},l={nonce:$("#_ca_nonce").val(),sidebarID:$("#post_ID").val(),alert:null,wpcaDataAdapter:$.fn.select2.amd.require("select2/wpca/conditionData"),wpcaModuleMatcher:$.fn.select2.amd.require("select2/wpca/moduleMatcher"),init:function(){this.alert=new CAE.Views.Alert({model:new CAE.Models.Alert}),CAE.conditionGroups=new CAE.Views.GroupCollection({collection:new CAE.Models.GroupCollection(WPCA.groups,{parse:!0})})}};$(function(){l.init()})}(jQuery,CAE);
|
1 |
/*!
|
2 |
+
* @package wp-content-aware-engine
|
3 |
* @author Joachim Jensen <joachim@dev.institute>
|
4 |
* @license GPLv3
|
5 |
+
* @copyright 2021 by Joachim Jensen
|
6 |
*/
|
7 |
+
var CAE=CAE||{};!function($,CAE){"use strict";CAE.settings={views:{}},CAE.Models={},CAE.Models.Alert=Backbone.Model.extend({defaults:{text:"",success:!0},sync:function(){return!1},url:"",reset:function(){this.set(this.defaults)}}),CAE.Models.Condition=Backbone.Model.extend({unsaved:{prompt:WPCA.unsaved,unloadWindowPrompt:!0},defaults:{module:null,label:"",placeholder:"",values:[],default_value:null},initialize:function(){this.startTracking(),this.on("destroy",this.stopTracking,this)},sync:function(){return!1},url:""}),CAE.Models.Group=Backbone.Model.extend({unsaved:{prompt:WPCA.unsaved,unloadWindowPrompt:!0},defaults:function(){var e=WPCA.meta_default;return e.id=null,e.status="wpca_or",e.exposure=1,e},initialize:function(){this.startTracking(),this.on("destroy",this.stopTracking,this),this.conditions||(this.conditions=new CAE.Models.ConditionCollection)},parse:function(e){var t=[];if(_.has(e,"conditions")){for(var n in e.conditions)if(e.conditions.hasOwnProperty(n)){var i,o=[],s=e.conditions[n];for(i in s.data)s.data.hasOwnProperty(i)&&o.push({text:"object"==typeof s.data[i]?s.data[i].text:s.data[i],id:i});delete s.data,s.module=n,s.values=o,t.push(s)}delete e.conditions}return this.conditions=new CAE.Models.ConditionCollection(t),e},sync:function(){return!1},url:""}),CAE.Models.GroupCollection=Backbone.Collection.extend({model:CAE.Models.Group,parse:function(e){return e}}),CAE.Models.ConditionCollection=Backbone.Collection.extend({model:CAE.Models.Condition}),CAE.Views={},CAE.Views.Alert=Backbone.Epoxy.View.extend({bindings:"data-vm",tagName:"div",className:"wpca-alert",template:"<div data-vm=\"classes:{'wpca-success':success,'wpca-error':not(success)},text:text\"></div>",timer:4e3,success:function(e){this.model.set({text:e,success:!0})},failure:function(e){this.model.set({text:e,success:!1})},dismiss:function(){var e=this;this.$el.fadeOut("slow",function(){e.model.reset()})},initialize:function(){this.listenTo(this.model,"change:text",this.show),this.$el.appendTo("body").hide().html(this.template)},show:function(){var e;""!==this.model.get("text")&&(this.$el.fadeIn("slow"),e=this,setTimeout(function(){e.dismiss()},this.timer))}}),CAE.Views.Condition=Backbone.Epoxy.View.extend({bindings:"data-vm",model:CAE.Models.Condition,tagName:"div",className:"cas-condition",templateName:"#wpca-template-condition",events:{"click .js-wpca-condition-remove":"removeModel"},initialize:function(){this.listenTo(this.model,"destroy",this.remove);var e=$(this.templateName);e.length?(this.template=e.html(),this.$el.append(this.template),this.createSuggestInput()):this.model.destroy()},removeModel:function(e){var t=this;this.$el.slideUp(300,function(){t.model.destroy()})},createSuggestInput:function(){var n,e,t,i=this.$el.find(".js-wpca-suggest");i.length&&(n=this.model,e=this.model.get("values"),t=$("<div></div>").html(n.get("placeholder")).text(),i.select2({cachedResults:{},quietMillis:400,searchTimer:null,type:n.get("module"),theme:"wpca",dir:WPCA.text_direction,placeholder:t,minimumInputLength:0,closeOnSelect:!0,width:"100%",language:{noResults:function(){return WPCA.noResults},searching:function(){return WPCA.searching+"..."},loadingMore:function(){return WPCA.loadingMore+"..."}},nextSearchTerm:function(e,t){return t},templateResult:function(e){return e.level?$('<span class="wpca-level-'+e.level+'">'+e.text+"</span>"):e.text},data:e,dataAdapter:l.wpcaDataAdapter,ajax:{}}).on("select2:selecting",function(e){i.data("forceOpen",!0)}).on("select2:closing",function(e){i.data("forceOpen")&&(e.preventDefault(),i.data("forceOpen",!1))}),e.length&&i.val(_.map(e,function(e){return e.id})).trigger("change"),i.on("change",function(e){var t=i.select2("data");n.set("values",t)}))}}),CAE.Views.Group=Backbone.Epoxy.View.extend({bindings:"data-vm",model:CAE.Models.Group,tagName:"li",className:"cas-group-single",template:$("#wpca-template-group").html(),itemView:function(e){return new(CAE.Views[e.model.get("module")]?CAE.Views[e.model.get("module")]:CAE.Views.Condition)(e)},events:{"click .js-wpca-save-group":"saveGroup","click .js-wpca-options":"showOptions"},computeds:{statusNegated:{deps:["status"],get:function(e){return"negated"==e},set:function(e){this.setBinding("status",e?"negated":"wpca_or")}},statusExcept:{deps:["status"],get:function(e){return"wpca_except"==e},set:function(e){this.setBinding("status",e?"wpca_except":"wpca_or")}},statusLabel:function(){switch(this.getBinding("status")){case"wpca_except":return WPCA.condition_except;case"negated":return WPCA.condition_not;default:return WPCA.condition_or}}},bindingFilters:{int:{get:function(e){return e?1:0},set:function(e){return e?1:0}},binary:{get:function(e){return e?1:0},set:function(e){return e?1:0}},hasModule:function(e){for(var t={},n=1;n<arguments.length;n++)t[arguments[n]]=!0;return e.filter(function(e){return t.hasOwnProperty(e.get("module"))}).length==arguments.length-1},hasAnyModule:function(e){for(var t={},n=1;n<arguments.length;n++)t[arguments[n]]=!0;return!!e.find(function(e){return t.hasOwnProperty(e.get("module"))})}},initialize:function(){this.collection=this.model.conditions,this.$el.hide().html(this.template).fadeIn(300),this.listenTo(this.model,"destroy",this.remove),this.listenTo(this.model,"unsavedChanges",this.saveChanges),this.listenTo(this.model.conditions,"unsavedChanges",this.saveChanges),this.listenTo(this.model.conditions,"add remove",this.saveAddRemove);var t=this,n=$(".js-wpca-add-and",this.$el);n.select2({theme:"wpca",placeholder:"+ "+WPCA.newCondition,minimumInputLength:0,closeOnSelect:!0,allowClear:!1,width:"resolve",matcher:l.wpcaModuleMatcher,nextSearchTerm:function(e,t){return t},data:WPCA.conditions}).on("select2:select",function(e){e=e.params.data;t.model.conditions.findWhere({module:e.id})||(e=new CAE.Models.Condition({module:e.id,label:e.text,placeholder:e.placeholder,default_value:e.default_value}),t.model.conditions.add(e)),n.val(null).trigger("change")})},showOptions:function(e){$(e.delegateTarget).find(".cas-group-options").slideToggle(200),$(e.currentTarget).toggleClass("active")},saveChanges:function(e,t){e&&i.start(this)},saveAddRemove:function(e,t,n){t.length?n.add?""!==e.get("default_value")&&i.start(this):this.model.get("id")&&i.start(this):(i.clear(this),this.model.get("id")?this.saveGroup():this.removeModel())},removeModel:function(){var e=this;this.$el.slideUp(400,function(){e.model.destroy()})},saveGroup:function(e){var i=this.$el.find(".spinner"),o=this.$el.find(".js-wpca-save-group"),t=this,n=_.clone(this.model.attributes);n.action="wpca/add-rule",n.token=l.nonce,n.current_id=l.sidebarID,n.post_type=WPCA.post_type,n.conditions={},this.model.conditions.each(function(e){e.get("values").length?n.conditions[e.get("module")]=e.get("values").map(function(e){return e.id}):""!==e.get("default_value")&&(n.conditions[e.get("module")]=[e.get("default_value")])}),o.attr("disabled",!0),i.addClass("is-active"),$.ajax({url:ajaxurl,data:n,dataType:"JSON",type:"POST",success:function(e){l.alert.success(e.message),e.removed?t.removeModel():e.new_post_id&&t.model.set("id",e.new_post_id,{silent:!0}),e.removed||(o.hide(),i.removeClass("is-active"),t.model.restartTracking(),t.model.conditions.each(function(e){e.restartTracking()}))},error:function(e,t,n){o.attr("disabled",!1).show(),i.removeClass("is-active"),l.alert.failure(e.responseJSON.data)}})},slideRemove:function(){this.$el.slideUp(400,function(){this.remove()})}}),CAE.Views.GroupCollection=Backbone.Epoxy.View.extend({bindings:"data-vm",el:"#cas-groups",collection:CAE.Models.GroupCollection,events:{"click .js-wpca-add-quick":"addGroupQuick","click .js-wpca-save":"saveAll"},conditionsById:{},initialize:function(){var n=this;this.conditionsById=_.chain(WPCA.conditions).pluck(["children"]).flatten().indexBy("id").value();var i=$(".js-wpca-add-or",this.$el);i.select2({theme:"wpca",placeholder:"+ "+WPCA.newGroup,minimumInputLength:0,closeOnSelect:!0,allowClear:!1,width:"auto",matcher:l.wpcaModuleMatcher,nextSearchTerm:function(e,t){return t},data:WPCA.conditions}).on("select2:select",function(e){var t=e.params.data,e=new CAE.Models.Group,t=new CAE.Models.Condition({module:t.id,label:t.text,placeholder:t.placeholder,default_value:t.default_value});n.collection.add(e),e.conditions.add(t),i.val(null).trigger("change")})},itemView:function(e){return new CAE.Views.Group(e)},addGroupQuick:function(e){e.preventDefault();var t,n,i=$(e.currentTarget).data("config"),o=new CAE.Models.Group;for(t in o.set(i.options),this.collection.add(o),i.modules)this.conditionsById.hasOwnProperty(i.modules[t])&&(n=this.conditionsById[i.modules[t]],n=new CAE.Models.Condition({module:n.id,label:n.text,placeholder:n.placeholder,default_value:n.default_value}),o.conditions.add(n))}}),$.fn.select2.amd.require(["select2/selection/search"],function(e){e.prototype.searchRemoveChoice=function(e,t){this.trigger("unselect",{data:t}),this.$search.val(""),this.handleSearch()}},null,!0),$.fn.select2.amd.require(["select2/results"],function(e){e.prototype.ensureHighlightVisible=function(){this.$results.resize()}},null,!0),$.fn.select2.amd.define("select2/wpca/conditionData",["select2/data/array","select2/utils"],function(e,t){function n(e,t){n.__super__.constructor.call(this,e,t)}return t.Extend(n,e),n.prototype.query=function(n,i){n.term=n.term||"";var o=this.options.options,s=o.cachedResults[n.term],a=n.page||1;if(s&&s.page>=a){if(!(1<a))return void i({results:s.items,pagination:{more:s.more}});a=s.page}clearTimeout(o.searchTimer),o.searchTimer=setTimeout(function(){$.ajax({url:ajaxurl,data:{search:n.term,paged:a,limit:20,action:"wpca/module/"+o.type,sidebar_id:l.sidebarID,nonce:l.nonce},dataType:"JSON",type:"POST",success:function(e){var t=20<=e.length;o.cachedResults[n.term]={page:a,more:t,items:s?o.cachedResults[n.term].items.concat(e):e},i({results:e,pagination:{more:t}})}})},o.quietMillis)},n}),$.fn.select2.amd.define("select2/wpca/moduleMatcher",["select2/diacritics"],function(t){function l(e){return e.replace(/[^\u0000-\u007E]/g,function(e){return t[e]||e})}return function e(t,n){if(null==t.term||""===t.term.trim())return n;var i=l(n.text).toUpperCase(),o=l(t.term).toUpperCase();if(-1<i.indexOf(o))return n;if(n.children&&0<n.children.length){for(var s=$.extend(!0,{},n),a=n.children.length-1;0<=a;a--)null==e(t,n.children[a])&&s.children.splice(a,1);return 0<s.children.length?s:e(t,s)}return null}});var i={treshold:2e3,timerQueue:{},start:function(e){this.clear(e);var t=this;this.timerQueue[e.cid]=window.setTimeout(function(){t.set(e)},this.treshold)},set:function(e){e.saveGroup()},clear:function(e){e&&this.timerQueue[e.cid]&&window.clearInterval(this.timerQueue[e.cid])}},l={nonce:$("#_ca_nonce").val(),sidebarID:$("#post_ID").val(),alert:null,wpcaDataAdapter:$.fn.select2.amd.require("select2/wpca/conditionData"),wpcaModuleMatcher:$.fn.select2.amd.require("select2/wpca/moduleMatcher"),init:function(){this.alert=new CAE.Views.Alert({model:new CAE.Models.Alert}),CAE.conditionGroups=new CAE.Views.GroupCollection({collection:new CAE.Models.GroupCollection(WPCA.groups,{parse:!0})})}};$(function(){l.init()})}(jQuery,CAE);
|
lib/wp-content-aware-engine/bootstrap.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -12,7 +12,7 @@ defined('ABSPATH') || exit;
|
|
12 |
* Version of this WPCA
|
13 |
* @var string
|
14 |
*/
|
15 |
-
$this_wpca_version = '9.
|
16 |
|
17 |
/**
|
18 |
* Class to make sure the latest
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
12 |
* Version of this WPCA
|
13 |
* @var string
|
14 |
*/
|
15 |
+
$this_wpca_version = '9.4a';
|
16 |
|
17 |
/**
|
18 |
* Class to make sure the latest
|
lib/wp-content-aware-engine/core.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -205,7 +205,6 @@ if (!class_exists('WPCACore')) {
|
|
205 |
{
|
206 |
$all_modules = [];
|
207 |
$modules_by_type = [];
|
208 |
-
$ignored_modules = ['taxonomy' => 1];
|
209 |
$cache = [];
|
210 |
|
211 |
$types = self::types();
|
@@ -213,10 +212,6 @@ if (!class_exists('WPCACore')) {
|
|
213 |
$modules_by_type[$type] = [];
|
214 |
$cache[$type] = [];
|
215 |
foreach ($modules as $module) {
|
216 |
-
if (isset($ignored_modules[$module->get_id()])) {
|
217 |
-
continue;
|
218 |
-
}
|
219 |
-
|
220 |
$modules_by_type[$type][$module->get_data_key()] = $module->get_id();
|
221 |
$all_modules[$module->get_data_key()] = $module->get_data_key();
|
222 |
}
|
@@ -229,14 +224,14 @@ if (!class_exists('WPCACore')) {
|
|
229 |
|
230 |
global $wpdb;
|
231 |
|
232 |
-
$query = '
|
233 |
-
SELECT p.post_type, m.meta_key
|
234 |
-
FROM '.$wpdb->posts.' p
|
235 |
-
INNER JOIN '.$wpdb->posts.' c ON c.post_parent = p.ID
|
236 |
-
INNER JOIN '.$wpdb->postmeta.' m ON m.post_id = c.ID
|
237 |
-
WHERE p.post_type IN ('.self::sql_prepare_in(array_keys($modules_by_type)).')
|
238 |
-
AND m.meta_key IN ('.self::sql_prepare_in($all_modules).')
|
239 |
-
GROUP BY p.post_type, m.meta_key
|
240 |
';
|
241 |
|
242 |
$results = (array) $wpdb->get_results($query);
|
@@ -409,7 +404,7 @@ GROUP BY p.post_type, m.meta_key
|
|
409 |
{
|
410 |
global $wpdb, $wp_query, $post;
|
411 |
|
412 |
-
if ((!$wp_query->query && !$post) || is_admin()) {
|
413 |
return [];
|
414 |
}
|
415 |
|
@@ -418,7 +413,6 @@ GROUP BY p.post_type, m.meta_key
|
|
418 |
return self::$condition_cache[$post_type];
|
419 |
}
|
420 |
|
421 |
-
$excluded = [];
|
422 |
$where = [];
|
423 |
$join = [];
|
424 |
|
@@ -441,19 +435,20 @@ GROUP BY p.post_type, m.meta_key
|
|
441 |
|
442 |
self::fix_wp_query();
|
443 |
|
|
|
444 |
foreach ($modules as $module) {
|
445 |
$id = $module->get_id();
|
446 |
$name = $module->get_query_name();
|
447 |
-
|
448 |
-
|
|
|
|
|
449 |
$data = $module->get_context_data();
|
450 |
if (is_array($data)) {
|
451 |
-
$data = "($name.meta_value IS NULL OR $name.meta_value IN (
|
452 |
}
|
453 |
$where[$id] = apply_filters("wpca/module/$id/db-where", $data);
|
454 |
self::$filtered_modules[$post_type][] = $module;
|
455 |
-
} else {
|
456 |
-
$excluded[] = $module;
|
457 |
}
|
458 |
}
|
459 |
|
@@ -471,13 +466,13 @@ GROUP BY p.post_type, m.meta_key
|
|
471 |
if ($use_negated_conditions) {
|
472 |
$post_status[] = self::STATUS_NEGATED;
|
473 |
}
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
|
|
478 |
//Syntax changed in MySQL 5.5 and MariaDB 10.0 (reports as version 5.5)
|
479 |
$wpdb->query('SET'.(version_compare($wpdb->db_version(), '5.5', '>=') ? ' SESSION' : ' OPTION').' SQL_BIG_SELECTS = 1');
|
480 |
-
$chunk_size = count($join);
|
481 |
}
|
482 |
|
483 |
$joins = array_chunk($join, $chunk_size);
|
@@ -489,7 +484,6 @@ GROUP BY p.post_type, m.meta_key
|
|
489 |
$where2 = [];
|
490 |
$where2[] = "p.post_type = '".self::TYPE_CONDITION_GROUP."'";
|
491 |
$where2[] = "p.post_status IN ('".implode("','", $post_status)."')";
|
492 |
-
//exposure
|
493 |
$where2[] = 'p.menu_order '.(is_archive() || is_home() ? '>=' : '<=').' 1';
|
494 |
|
495 |
foreach ($joins as $i => $join) {
|
@@ -497,9 +491,9 @@ GROUP BY p.post_type, m.meta_key
|
|
497 |
$groups_in_context = $wpdb->get_results(
|
498 |
'SELECT p.ID, p.post_parent, p.post_status '.
|
499 |
"FROM $wpdb->posts p ".
|
500 |
-
implode(' ', $join).'
|
501 |
-
WHERE
|
502 |
-
'.implode(' AND ', $wheres[$i]).'
|
503 |
AND '.implode(' AND ', $where2).
|
504 |
(!empty($group_ids) ? ' AND p.id IN ('.implode(',', $group_ids).')' : ''),
|
505 |
OBJECT_K
|
@@ -510,9 +504,9 @@ GROUP BY p.post_type, m.meta_key
|
|
510 |
$group_ids = array_merge($group_ids, $wpdb->get_col(
|
511 |
'SELECT p.ID '.
|
512 |
"FROM $wpdb->posts p ".
|
513 |
-
implode(' ', $join).'
|
514 |
-
WHERE
|
515 |
-
'.implode(' AND ', $wheres[$i]).'
|
516 |
AND '.implode(' AND ', $where2)
|
517 |
));
|
518 |
}
|
@@ -535,28 +529,26 @@ GROUP BY p.post_type, m.meta_key
|
|
535 |
update_meta_cache('post', array_keys($groups_in_context + $groups_negated));
|
536 |
}
|
537 |
|
538 |
-
//condition group => type
|
539 |
-
$valid = [];
|
540 |
-
foreach ($groups_in_context as $group) {
|
541 |
-
$valid[$group->ID] = $group->post_parent;
|
542 |
-
}
|
543 |
-
|
544 |
//Exclude types that have unrelated content in same group
|
545 |
-
foreach ($
|
546 |
-
$
|
|
|
|
|
|
|
547 |
}
|
548 |
|
549 |
//exclude exceptions
|
550 |
$excepted = [];
|
551 |
-
foreach ($
|
552 |
-
|
553 |
-
|
554 |
-
continue;
|
555 |
}
|
|
|
556 |
|
557 |
-
|
558 |
-
|
559 |
-
|
|
|
560 |
}
|
561 |
|
562 |
foreach ($valid as $group_id => $parent_id) {
|
@@ -595,26 +587,21 @@ GROUP BY p.post_type, m.meta_key
|
|
595 |
* Get filtered posts from a post type
|
596 |
*
|
597 |
* @since 1.0
|
598 |
-
* @global type $wpdb
|
599 |
-
* @global WP_Query $wp_query
|
600 |
-
* @global WP_Post $post
|
601 |
* @return array
|
602 |
*/
|
603 |
public static function get_posts($post_type)
|
604 |
{
|
605 |
-
global $wp_query, $post;
|
606 |
-
|
607 |
-
// Return cache if present
|
608 |
if (isset(self::$post_cache[$post_type])) {
|
609 |
return self::$post_cache[$post_type];
|
610 |
}
|
611 |
|
612 |
-
|
|
|
|
|
|
|
613 |
return false;
|
614 |
}
|
615 |
|
616 |
-
$valid = self::get_conditions($post_type);
|
617 |
-
|
618 |
self::$post_cache[$post_type] = [];
|
619 |
|
620 |
$results = [];
|
@@ -1198,12 +1185,11 @@ GROUP BY p.post_type, m.meta_key
|
|
1198 |
return $modules;
|
1199 |
}
|
1200 |
|
1201 |
-
$ignored_modules = ['taxonomy' => 1];
|
1202 |
$included_conditions_lookup = array_flip($included_conditions[$type]);
|
1203 |
$filtered_modules = [];
|
1204 |
|
1205 |
foreach ($modules as $module) {
|
1206 |
-
if (isset($
|
1207 |
$filtered_modules[] = $module;
|
1208 |
}
|
1209 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
205 |
{
|
206 |
$all_modules = [];
|
207 |
$modules_by_type = [];
|
|
|
208 |
$cache = [];
|
209 |
|
210 |
$types = self::types();
|
212 |
$modules_by_type[$type] = [];
|
213 |
$cache[$type] = [];
|
214 |
foreach ($modules as $module) {
|
|
|
|
|
|
|
|
|
215 |
$modules_by_type[$type][$module->get_data_key()] = $module->get_id();
|
216 |
$all_modules[$module->get_data_key()] = $module->get_data_key();
|
217 |
}
|
224 |
|
225 |
global $wpdb;
|
226 |
|
227 |
+
$query = '
|
228 |
+
SELECT p.post_type, m.meta_key
|
229 |
+
FROM '.$wpdb->posts.' p
|
230 |
+
INNER JOIN '.$wpdb->posts.' c ON c.post_parent = p.ID
|
231 |
+
INNER JOIN '.$wpdb->postmeta.' m ON m.post_id = c.ID
|
232 |
+
WHERE p.post_type IN ('.self::sql_prepare_in(array_keys($modules_by_type)).')
|
233 |
+
AND m.meta_key IN ('.self::sql_prepare_in($all_modules).')
|
234 |
+
GROUP BY p.post_type, m.meta_key
|
235 |
';
|
236 |
|
237 |
$results = (array) $wpdb->get_results($query);
|
404 |
{
|
405 |
global $wpdb, $wp_query, $post;
|
406 |
|
407 |
+
if (!self::types()->has($post_type) || (!$wp_query->query && !$post) || is_admin()) {
|
408 |
return [];
|
409 |
}
|
410 |
|
413 |
return self::$condition_cache[$post_type];
|
414 |
}
|
415 |
|
|
|
416 |
$where = [];
|
417 |
$join = [];
|
418 |
|
435 |
|
436 |
self::fix_wp_query();
|
437 |
|
438 |
+
$in_context_by_module_id = [];
|
439 |
foreach ($modules as $module) {
|
440 |
$id = $module->get_id();
|
441 |
$name = $module->get_query_name();
|
442 |
+
$in_context = apply_filters("wpca/module/$id/in-context", $module->in_context());
|
443 |
+
$in_context_by_module_id[$id] = $in_context;
|
444 |
+
if ($in_context) {
|
445 |
+
$join[$id] = $module->db_join();
|
446 |
$data = $module->get_context_data();
|
447 |
if (is_array($data)) {
|
448 |
+
$data = "($name.meta_value IS NULL OR $name.meta_value IN (".self::sql_prepare_in($data).'))';
|
449 |
}
|
450 |
$where[$id] = apply_filters("wpca/module/$id/db-where", $data);
|
451 |
self::$filtered_modules[$post_type][] = $module;
|
|
|
|
|
452 |
}
|
453 |
}
|
454 |
|
466 |
if ($use_negated_conditions) {
|
467 |
$post_status[] = self::STATUS_NEGATED;
|
468 |
}
|
469 |
+
|
470 |
+
$chunk_size = count($join);
|
471 |
+
if (defined('WPCA_SQL_JOIN_SIZE') && is_integer(WPCA_SQL_JOIN_SIZE) && WPCA_SQL_JOIN_SIZE > 0) {
|
472 |
+
$chunk_size = WPCA_SQL_JOIN_SIZE;
|
473 |
+
} elseif (defined('WPCA_SQL_COMPATIBILITY_MODE') && WPCA_SQL_COMPATIBILITY_MODE === true) {
|
474 |
//Syntax changed in MySQL 5.5 and MariaDB 10.0 (reports as version 5.5)
|
475 |
$wpdb->query('SET'.(version_compare($wpdb->db_version(), '5.5', '>=') ? ' SESSION' : ' OPTION').' SQL_BIG_SELECTS = 1');
|
|
|
476 |
}
|
477 |
|
478 |
$joins = array_chunk($join, $chunk_size);
|
484 |
$where2 = [];
|
485 |
$where2[] = "p.post_type = '".self::TYPE_CONDITION_GROUP."'";
|
486 |
$where2[] = "p.post_status IN ('".implode("','", $post_status)."')";
|
|
|
487 |
$where2[] = 'p.menu_order '.(is_archive() || is_home() ? '>=' : '<=').' 1';
|
488 |
|
489 |
foreach ($joins as $i => $join) {
|
491 |
$groups_in_context = $wpdb->get_results(
|
492 |
'SELECT p.ID, p.post_parent, p.post_status '.
|
493 |
"FROM $wpdb->posts p ".
|
494 |
+
implode(' ', $join).'
|
495 |
+
WHERE
|
496 |
+
'.implode(' AND ', $wheres[$i]).'
|
497 |
AND '.implode(' AND ', $where2).
|
498 |
(!empty($group_ids) ? ' AND p.id IN ('.implode(',', $group_ids).')' : ''),
|
499 |
OBJECT_K
|
504 |
$group_ids = array_merge($group_ids, $wpdb->get_col(
|
505 |
'SELECT p.ID '.
|
506 |
"FROM $wpdb->posts p ".
|
507 |
+
implode(' ', $join).'
|
508 |
+
WHERE
|
509 |
+
'.implode(' AND ', $wheres[$i]).'
|
510 |
AND '.implode(' AND ', $where2)
|
511 |
));
|
512 |
}
|
529 |
update_meta_cache('post', array_keys($groups_in_context + $groups_negated));
|
530 |
}
|
531 |
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
//Exclude types that have unrelated content in same group
|
533 |
+
foreach ($modules as $module) {
|
534 |
+
$groups_in_context = $module->filter_excluded_context(
|
535 |
+
$groups_in_context,
|
536 |
+
$in_context_by_module_id[$module->get_id()]
|
537 |
+
);
|
538 |
}
|
539 |
|
540 |
//exclude exceptions
|
541 |
$excepted = [];
|
542 |
+
foreach ($groups_in_context as $group_id => $group) {
|
543 |
+
if ($group->post_status == self::STATUS_EXCEPT) {
|
544 |
+
$excepted[$group->post_parent] = 1;
|
|
|
545 |
}
|
546 |
+
}
|
547 |
|
548 |
+
//condition group => type
|
549 |
+
$valid = [];
|
550 |
+
foreach ($groups_in_context as $group) {
|
551 |
+
$valid[$group->ID] = $group->post_parent;
|
552 |
}
|
553 |
|
554 |
foreach ($valid as $group_id => $parent_id) {
|
587 |
* Get filtered posts from a post type
|
588 |
*
|
589 |
* @since 1.0
|
|
|
|
|
|
|
590 |
* @return array
|
591 |
*/
|
592 |
public static function get_posts($post_type)
|
593 |
{
|
|
|
|
|
|
|
594 |
if (isset(self::$post_cache[$post_type])) {
|
595 |
return self::$post_cache[$post_type];
|
596 |
}
|
597 |
|
598 |
+
$valid = self::get_conditions($post_type);
|
599 |
+
|
600 |
+
//if cache hasn't been set, method was called too early
|
601 |
+
if (!isset(self::$condition_cache[$post_type])) {
|
602 |
return false;
|
603 |
}
|
604 |
|
|
|
|
|
605 |
self::$post_cache[$post_type] = [];
|
606 |
|
607 |
$results = [];
|
1185 |
return $modules;
|
1186 |
}
|
1187 |
|
|
|
1188 |
$included_conditions_lookup = array_flip($included_conditions[$type]);
|
1189 |
$filtered_modules = [];
|
1190 |
|
1191 |
foreach ($modules as $module) {
|
1192 |
+
if (isset($included_conditions_lookup[$module->get_id()])) {
|
1193 |
$filtered_modules[] = $module;
|
1194 |
}
|
1195 |
}
|
lib/wp-content-aware-engine/meta.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
lib/wp-content-aware-engine/module/author.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -19,10 +19,6 @@ defined('ABSPATH') || exit;
|
|
19 |
*/
|
20 |
class WPCAModule_author extends WPCAModule_Base
|
21 |
{
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Constructor
|
25 |
-
*/
|
26 |
public function __construct()
|
27 |
{
|
28 |
parent::__construct('author', __('Authors', WPCA_DOMAIN));
|
@@ -32,10 +28,7 @@ class WPCAModule_author extends WPCAModule_Base
|
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
*
|
36 |
-
*
|
37 |
-
* @since 1.0
|
38 |
-
* @return boolean
|
39 |
*/
|
40 |
public function in_context()
|
41 |
{
|
@@ -43,11 +36,7 @@ class WPCAModule_author extends WPCAModule_Base
|
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
-
*
|
47 |
-
*
|
48 |
-
* @global WP_Post $post
|
49 |
-
* @since 1.0
|
50 |
-
* @return array
|
51 |
*/
|
52 |
public function get_context_data()
|
53 |
{
|
@@ -59,9 +48,7 @@ class WPCAModule_author extends WPCAModule_Base
|
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
-
* @
|
63 |
-
*
|
64 |
-
* @return array
|
65 |
*/
|
66 |
protected function parse_query_args($args)
|
67 |
{
|
@@ -89,11 +76,7 @@ class WPCAModule_author extends WPCAModule_Base
|
|
89 |
}
|
90 |
|
91 |
/**
|
92 |
-
*
|
93 |
-
*
|
94 |
-
* @since 1.0
|
95 |
-
* @param array $args
|
96 |
-
* @return array
|
97 |
*/
|
98 |
protected function _get_content($args = [])
|
99 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
19 |
*/
|
20 |
class WPCAModule_author extends WPCAModule_Base
|
21 |
{
|
|
|
|
|
|
|
|
|
22 |
public function __construct()
|
23 |
{
|
24 |
parent::__construct('author', __('Authors', WPCA_DOMAIN));
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
+
* @inheritDoc
|
|
|
|
|
|
|
32 |
*/
|
33 |
public function in_context()
|
34 |
{
|
36 |
}
|
37 |
|
38 |
/**
|
39 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
40 |
*/
|
41 |
public function get_context_data()
|
42 |
{
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
+
* @inheritDoc
|
|
|
|
|
52 |
*/
|
53 |
protected function parse_query_args($args)
|
54 |
{
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
80 |
*/
|
81 |
protected function _get_content($args = [])
|
82 |
{
|
lib/wp-content-aware-engine/module/base.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -262,14 +262,17 @@ abstract class WPCAModule_Base
|
|
262 |
* other contexts (meaning conditions arent met)
|
263 |
*
|
264 |
* @since 3.2
|
265 |
-
* @param
|
|
|
266 |
* @return array
|
267 |
*/
|
268 |
-
public function filter_excluded_context($posts)
|
269 |
{
|
270 |
-
|
271 |
-
|
272 |
-
|
|
|
|
|
273 |
}
|
274 |
}
|
275 |
return $posts;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
262 |
* other contexts (meaning conditions arent met)
|
263 |
*
|
264 |
* @since 3.2
|
265 |
+
* @param array $posts
|
266 |
+
* @param boolean $in_context
|
267 |
* @return array
|
268 |
*/
|
269 |
+
public function filter_excluded_context($posts, $in_context = false)
|
270 |
{
|
271 |
+
if (!$in_context) {
|
272 |
+
foreach ($posts as $id => $group) {
|
273 |
+
if (get_post_custom_values($this->get_data_key(), $id) !== null) {
|
274 |
+
unset($posts[$id]);
|
275 |
+
}
|
276 |
}
|
277 |
}
|
278 |
return $posts;
|
lib/wp-content-aware-engine/module/bbpress.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -19,15 +19,11 @@ defined('ABSPATH') || exit;
|
|
19 |
*/
|
20 |
class WPCAModule_bbpress extends WPCAModule_author
|
21 |
{
|
22 |
-
|
23 |
/**
|
24 |
* @var string
|
25 |
*/
|
26 |
protected $category = 'plugins';
|
27 |
|
28 |
-
/**
|
29 |
-
* Constructor
|
30 |
-
*/
|
31 |
public function __construct()
|
32 |
{
|
33 |
parent::__construct();
|
@@ -35,15 +31,11 @@ class WPCAModule_bbpress extends WPCAModule_author
|
|
35 |
$this->name = __('bbPress User Profiles', WPCA_DOMAIN);
|
36 |
$this->placeholder = __('All Profiles', WPCA_DOMAIN);
|
37 |
$this->default_value = $this->id;
|
38 |
-
|
39 |
$this->query_name = 'cbb';
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
-
*
|
44 |
-
*
|
45 |
-
* @since 2.0
|
46 |
-
* @return void
|
47 |
*/
|
48 |
public function initiate()
|
49 |
{
|
@@ -55,7 +47,7 @@ class WPCAModule_bbpress extends WPCAModule_author
|
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
-
* @
|
59 |
*/
|
60 |
public function can_enable()
|
61 |
{
|
@@ -66,8 +58,7 @@ class WPCAModule_bbpress extends WPCAModule_author
|
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
-
* @
|
70 |
-
* @return boolean
|
71 |
*/
|
72 |
public function in_context()
|
73 |
{
|
@@ -75,10 +66,7 @@ class WPCAModule_bbpress extends WPCAModule_author
|
|
75 |
}
|
76 |
|
77 |
/**
|
78 |
-
*
|
79 |
-
*
|
80 |
-
* @since 1.0
|
81 |
-
* @return array
|
82 |
*/
|
83 |
public function get_context_data()
|
84 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
19 |
*/
|
20 |
class WPCAModule_bbpress extends WPCAModule_author
|
21 |
{
|
|
|
22 |
/**
|
23 |
* @var string
|
24 |
*/
|
25 |
protected $category = 'plugins';
|
26 |
|
|
|
|
|
|
|
27 |
public function __construct()
|
28 |
{
|
29 |
parent::__construct();
|
31 |
$this->name = __('bbPress User Profiles', WPCA_DOMAIN);
|
32 |
$this->placeholder = __('All Profiles', WPCA_DOMAIN);
|
33 |
$this->default_value = $this->id;
|
|
|
34 |
$this->query_name = 'cbb';
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
+
* @inheritDoc
|
|
|
|
|
|
|
39 |
*/
|
40 |
public function initiate()
|
41 |
{
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* @inheritDoc
|
51 |
*/
|
52 |
public function can_enable()
|
53 |
{
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
+
* @inheritDoc
|
|
|
62 |
*/
|
63 |
public function in_context()
|
64 |
{
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
+
* @inheritDoc
|
|
|
|
|
|
|
70 |
*/
|
71 |
public function get_context_data()
|
72 |
{
|
lib/wp-content-aware-engine/module/bp_member.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -19,7 +19,6 @@ defined('ABSPATH') || exit;
|
|
19 |
*/
|
20 |
class WPCAModule_bp_member extends WPCAModule_Base
|
21 |
{
|
22 |
-
|
23 |
/**
|
24 |
* @var string
|
25 |
*/
|
@@ -31,20 +30,16 @@ class WPCAModule_bp_member extends WPCAModule_Base
|
|
31 |
*/
|
32 |
protected $search_string;
|
33 |
|
34 |
-
/**
|
35 |
-
* Constructor
|
36 |
-
*/
|
37 |
public function __construct()
|
38 |
{
|
39 |
parent::__construct('bp_member', __('BuddyPress Profiles', WPCA_DOMAIN));
|
40 |
$this->default_value = 0;
|
41 |
$this->placeholder = __('All Sections', WPCA_DOMAIN);
|
42 |
-
|
43 |
$this->query_name = 'cbp';
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
* @
|
48 |
*/
|
49 |
public function can_enable()
|
50 |
{
|
@@ -52,10 +47,7 @@ class WPCAModule_bp_member extends WPCAModule_Base
|
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
-
*
|
56 |
-
*
|
57 |
-
* @since 2.0
|
58 |
-
* @return void
|
59 |
*/
|
60 |
public function initiate()
|
61 |
{
|
@@ -67,12 +59,7 @@ class WPCAModule_bp_member extends WPCAModule_Base
|
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
-
*
|
71 |
-
*
|
72 |
-
* @global object $bp
|
73 |
-
* @since 1.0
|
74 |
-
* @param array $args
|
75 |
-
* @return array
|
76 |
*/
|
77 |
protected function _get_content($args = [])
|
78 |
{
|
@@ -127,9 +114,7 @@ class WPCAModule_bp_member extends WPCAModule_Base
|
|
127 |
}
|
128 |
|
129 |
/**
|
130 |
-
* @
|
131 |
-
* @since 1.0
|
132 |
-
* @return boolean
|
133 |
*/
|
134 |
public function in_context()
|
135 |
{
|
@@ -138,11 +123,7 @@ class WPCAModule_bp_member extends WPCAModule_Base
|
|
138 |
}
|
139 |
|
140 |
/**
|
141 |
-
*
|
142 |
-
*
|
143 |
-
* @global object $bp
|
144 |
-
* @since 1.0
|
145 |
-
* @return array
|
146 |
*/
|
147 |
public function get_context_data()
|
148 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
19 |
*/
|
20 |
class WPCAModule_bp_member extends WPCAModule_Base
|
21 |
{
|
|
|
22 |
/**
|
23 |
* @var string
|
24 |
*/
|
30 |
*/
|
31 |
protected $search_string;
|
32 |
|
|
|
|
|
|
|
33 |
public function __construct()
|
34 |
{
|
35 |
parent::__construct('bp_member', __('BuddyPress Profiles', WPCA_DOMAIN));
|
36 |
$this->default_value = 0;
|
37 |
$this->placeholder = __('All Sections', WPCA_DOMAIN);
|
|
|
38 |
$this->query_name = 'cbp';
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
+
* @inheritDoc
|
43 |
*/
|
44 |
public function can_enable()
|
45 |
{
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* @inheritDoc
|
|
|
|
|
|
|
51 |
*/
|
52 |
public function initiate()
|
53 |
{
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
|
|
63 |
*/
|
64 |
protected function _get_content($args = [])
|
65 |
{
|
114 |
}
|
115 |
|
116 |
/**
|
117 |
+
* @inheritDoc
|
|
|
|
|
118 |
*/
|
119 |
public function in_context()
|
120 |
{
|
123 |
}
|
124 |
|
125 |
/**
|
126 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
127 |
*/
|
128 |
public function get_context_data()
|
129 |
{
|
lib/wp-content-aware-engine/module/date.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -34,10 +34,7 @@ class WPCAModule_date extends WPCAModule_Base
|
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
-
*
|
38 |
-
*
|
39 |
-
* @since 1.0
|
40 |
-
* @return boolean
|
41 |
*/
|
42 |
public function in_context()
|
43 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
+
* @inheritDoc
|
|
|
|
|
|
|
38 |
*/
|
39 |
public function in_context()
|
40 |
{
|
lib/wp-content-aware-engine/module/page_template.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -19,30 +19,22 @@ defined('ABSPATH') || exit;
|
|
19 |
*/
|
20 |
class WPCAModule_page_template extends WPCAModule_Base
|
21 |
{
|
22 |
-
|
23 |
/**
|
24 |
* Cached search string
|
25 |
* @var string
|
26 |
*/
|
27 |
protected $search_string;
|
28 |
|
29 |
-
/**
|
30 |
-
* Constructor
|
31 |
-
*/
|
32 |
public function __construct()
|
33 |
{
|
34 |
parent::__construct('page_template', __('Page Templates', WPCA_DOMAIN));
|
35 |
$this->placeholder = __('All Templates', WPCA_DOMAIN);
|
36 |
$this->default_value = $this->id;
|
37 |
-
|
38 |
$this->query_name = 'cpt';
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
-
*
|
43 |
-
*
|
44 |
-
* @since 1.0
|
45 |
-
* @return boolean
|
46 |
*/
|
47 |
public function in_context()
|
48 |
{
|
@@ -54,10 +46,7 @@ class WPCAModule_page_template extends WPCAModule_Base
|
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
-
*
|
58 |
-
*
|
59 |
-
* @since 1.0
|
60 |
-
* @return array
|
61 |
*/
|
62 |
public function get_context_data()
|
63 |
{
|
@@ -68,11 +57,7 @@ class WPCAModule_page_template extends WPCAModule_Base
|
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
-
*
|
72 |
-
*
|
73 |
-
* @since 1.0
|
74 |
-
* @param array $args
|
75 |
-
* @return array
|
76 |
*/
|
77 |
protected function _get_content($args = [])
|
78 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
19 |
*/
|
20 |
class WPCAModule_page_template extends WPCAModule_Base
|
21 |
{
|
|
|
22 |
/**
|
23 |
* Cached search string
|
24 |
* @var string
|
25 |
*/
|
26 |
protected $search_string;
|
27 |
|
|
|
|
|
|
|
28 |
public function __construct()
|
29 |
{
|
30 |
parent::__construct('page_template', __('Page Templates', WPCA_DOMAIN));
|
31 |
$this->placeholder = __('All Templates', WPCA_DOMAIN);
|
32 |
$this->default_value = $this->id;
|
|
|
33 |
$this->query_name = 'cpt';
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
+
* @inheritDoc
|
|
|
|
|
|
|
38 |
*/
|
39 |
public function in_context()
|
40 |
{
|
46 |
}
|
47 |
|
48 |
/**
|
49 |
+
* @inheritDoc
|
|
|
|
|
|
|
50 |
*/
|
51 |
public function get_context_data()
|
52 |
{
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
61 |
*/
|
62 |
protected function _get_content($args = [])
|
63 |
{
|
lib/wp-content-aware-engine/module/pods.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -19,26 +19,21 @@ defined('ABSPATH') || exit;
|
|
19 |
*/
|
20 |
class WPCAModule_pods extends WPCAModule_Base
|
21 |
{
|
22 |
-
|
23 |
/**
|
24 |
* @var string
|
25 |
*/
|
26 |
protected $category = 'plugins';
|
27 |
|
28 |
-
/**
|
29 |
-
* Constructor
|
30 |
-
*/
|
31 |
public function __construct()
|
32 |
{
|
33 |
parent::__construct('pods', __('Pods Pages', WPCA_DOMAIN));
|
34 |
$this->placeholder = __('All Pods Pages', WPCA_DOMAIN);
|
35 |
$this->default_value = $this->id;
|
36 |
-
|
37 |
$this->query_name = 'cpo';
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
-
* @
|
42 |
*/
|
43 |
public function can_enable()
|
44 |
{
|
@@ -49,8 +44,7 @@ class WPCAModule_pods extends WPCAModule_Base
|
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
-
* @
|
53 |
-
* @return boolean
|
54 |
*/
|
55 |
public function in_context()
|
56 |
{
|
@@ -58,10 +52,7 @@ class WPCAModule_pods extends WPCAModule_Base
|
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
-
*
|
62 |
-
*
|
63 |
-
* @since 2.0
|
64 |
-
* @return array
|
65 |
*/
|
66 |
public function get_context_data()
|
67 |
{
|
@@ -74,9 +65,7 @@ class WPCAModule_pods extends WPCAModule_Base
|
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
-
* @
|
78 |
-
*
|
79 |
-
* @return array
|
80 |
*/
|
81 |
protected function parse_query_args($args)
|
82 |
{
|
@@ -89,11 +78,7 @@ class WPCAModule_pods extends WPCAModule_Base
|
|
89 |
}
|
90 |
|
91 |
/**
|
92 |
-
*
|
93 |
-
*
|
94 |
-
* @since 2.0
|
95 |
-
* @param array $args
|
96 |
-
* @return array
|
97 |
*/
|
98 |
protected function _get_content($args = [])
|
99 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
19 |
*/
|
20 |
class WPCAModule_pods extends WPCAModule_Base
|
21 |
{
|
|
|
22 |
/**
|
23 |
* @var string
|
24 |
*/
|
25 |
protected $category = 'plugins';
|
26 |
|
|
|
|
|
|
|
27 |
public function __construct()
|
28 |
{
|
29 |
parent::__construct('pods', __('Pods Pages', WPCA_DOMAIN));
|
30 |
$this->placeholder = __('All Pods Pages', WPCA_DOMAIN);
|
31 |
$this->default_value = $this->id;
|
|
|
32 |
$this->query_name = 'cpo';
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
+
* @inheritDoc
|
37 |
*/
|
38 |
public function can_enable()
|
39 |
{
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* @inheritDoc
|
|
|
48 |
*/
|
49 |
public function in_context()
|
50 |
{
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
+
* @inheritDoc
|
|
|
|
|
|
|
56 |
*/
|
57 |
public function get_context_data()
|
58 |
{
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
+
* @inheritDoc
|
|
|
|
|
69 |
*/
|
70 |
protected function parse_query_args($args)
|
71 |
{
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
82 |
*/
|
83 |
protected function _get_content($args = [])
|
84 |
{
|
lib/wp-content-aware-engine/module/polylang.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -31,10 +31,12 @@ class WPCAModule_polylang extends WPCAModule_Base
|
|
31 |
public function __construct()
|
32 |
{
|
33 |
parent::__construct('language', __('Languages', WPCA_DOMAIN));
|
34 |
-
|
35 |
$this->query_name = 'cl';
|
36 |
}
|
37 |
|
|
|
|
|
|
|
38 |
public function initiate()
|
39 |
{
|
40 |
parent::initiate();
|
@@ -45,7 +47,7 @@ class WPCAModule_polylang extends WPCAModule_Base
|
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
-
* @
|
49 |
*/
|
50 |
public function can_enable()
|
51 |
{
|
@@ -54,8 +56,7 @@ class WPCAModule_polylang extends WPCAModule_Base
|
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
-
* @
|
58 |
-
* @return boolean
|
59 |
*/
|
60 |
public function in_context()
|
61 |
{
|
@@ -63,10 +64,7 @@ class WPCAModule_polylang extends WPCAModule_Base
|
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
-
*
|
67 |
-
*
|
68 |
-
* @since 1.0
|
69 |
-
* @return array
|
70 |
*/
|
71 |
public function get_context_data()
|
72 |
{
|
@@ -76,12 +74,7 @@ class WPCAModule_polylang extends WPCAModule_Base
|
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
-
*
|
80 |
-
*
|
81 |
-
* @global object $polylang
|
82 |
-
* @since 1.0
|
83 |
-
* @param array $args
|
84 |
-
* @return array
|
85 |
*/
|
86 |
protected function _get_content($args = [])
|
87 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
31 |
public function __construct()
|
32 |
{
|
33 |
parent::__construct('language', __('Languages', WPCA_DOMAIN));
|
|
|
34 |
$this->query_name = 'cl';
|
35 |
}
|
36 |
|
37 |
+
/**
|
38 |
+
* @inheritDoc
|
39 |
+
*/
|
40 |
public function initiate()
|
41 |
{
|
42 |
parent::initiate();
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* @inheritDoc
|
51 |
*/
|
52 |
public function can_enable()
|
53 |
{
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
+
* @inheritDoc
|
|
|
60 |
*/
|
61 |
public function in_context()
|
62 |
{
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
+
* @inheritDoc
|
|
|
|
|
|
|
68 |
*/
|
69 |
public function get_context_data()
|
70 |
{
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
|
|
78 |
*/
|
79 |
protected function _get_content($args = [])
|
80 |
{
|
lib/wp-content-aware-engine/module/post_type.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -20,7 +20,6 @@ defined('ABSPATH') || exit;
|
|
20 |
*/
|
21 |
class WPCAModule_post_type extends WPCAModule_Base
|
22 |
{
|
23 |
-
|
24 |
/**
|
25 |
* @var string
|
26 |
*/
|
@@ -39,21 +38,14 @@ class WPCAModule_post_type extends WPCAModule_Base
|
|
39 |
*/
|
40 |
private $_post_ancestor_conditions;
|
41 |
|
42 |
-
/**
|
43 |
-
* Constructor
|
44 |
-
*/
|
45 |
public function __construct()
|
46 |
{
|
47 |
parent::__construct('post_type', __('Post Types', WPCA_DOMAIN));
|
48 |
-
|
49 |
$this->query_name = 'cp';
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
-
*
|
54 |
-
*
|
55 |
-
* @since 2.0
|
56 |
-
* @return void
|
57 |
*/
|
58 |
public function initiate()
|
59 |
{
|
@@ -77,11 +69,7 @@ class WPCAModule_post_type extends WPCAModule_Base
|
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
*
|
81 |
-
*
|
82 |
-
* @since 1.0
|
83 |
-
* @param array $args
|
84 |
-
* @return array
|
85 |
*/
|
86 |
protected function _get_content($args = [])
|
87 |
{
|
@@ -118,15 +106,15 @@ class WPCAModule_post_type extends WPCAModule_Base
|
|
118 |
//Using unprepared (safe) exclude because WP is not good at parsing arrays
|
119 |
global $wpdb;
|
120 |
$posts = $wpdb->get_results($wpdb->prepare(
|
121 |
-
"
|
122 |
-
SELECT ID, post_title, post_type, post_parent, post_status, post_password
|
123 |
-
FROM {$wpdb->posts}
|
124 |
-
WHERE (".implode(' OR ', $where).")
|
125 |
-
AND post_status IN('".implode("','", $args['post_status'])."')
|
126 |
-
AND post_type = '%s'
|
127 |
-
$exclude_query
|
128 |
-
ORDER BY post_title ASC
|
129 |
-
LIMIT %d,%d
|
130 |
",
|
131 |
array_merge($values, [
|
132 |
$args['post_type'],
|
@@ -218,12 +206,7 @@ class WPCAModule_post_type extends WPCAModule_Base
|
|
218 |
}
|
219 |
|
220 |
/**
|
221 |
-
*
|
222 |
-
*
|
223 |
-
* @since 2.0
|
224 |
-
* @param array $group_data
|
225 |
-
* @param int $post_id
|
226 |
-
* @return array
|
227 |
*/
|
228 |
public function get_group_data($group_data, $post_id)
|
229 |
{
|
@@ -269,10 +252,7 @@ class WPCAModule_post_type extends WPCAModule_Base
|
|
269 |
}
|
270 |
|
271 |
/**
|
272 |
-
*
|
273 |
-
*
|
274 |
-
* @since 1.0
|
275 |
-
* @return boolean
|
276 |
*/
|
277 |
public function in_context()
|
278 |
{
|
@@ -280,10 +260,7 @@ class WPCAModule_post_type extends WPCAModule_Base
|
|
280 |
}
|
281 |
|
282 |
/**
|
283 |
-
*
|
284 |
-
*
|
285 |
-
* @since 1.0
|
286 |
-
* @return array
|
287 |
*/
|
288 |
public function get_context_data()
|
289 |
{
|
@@ -308,10 +285,8 @@ class WPCAModule_post_type extends WPCAModule_Base
|
|
308 |
}
|
309 |
|
310 |
/**
|
311 |
-
|
312 |
-
|
313 |
-
* @return array
|
314 |
-
*/
|
315 |
protected function parse_query_args($args)
|
316 |
{
|
317 |
if (isset($args['item_object'])) {
|
@@ -356,10 +331,7 @@ class WPCAModule_post_type extends WPCAModule_Base
|
|
356 |
}
|
357 |
|
358 |
/**
|
359 |
-
* @
|
360 |
-
* @param array $list
|
361 |
-
*
|
362 |
-
* @return array
|
363 |
*/
|
364 |
public function list_module($list)
|
365 |
{
|
@@ -439,11 +411,7 @@ class WPCAModule_post_type extends WPCAModule_Base
|
|
439 |
}
|
440 |
|
441 |
/**
|
442 |
-
*
|
443 |
-
*
|
444 |
-
* @since 1.0
|
445 |
-
* @param int $post_id
|
446 |
-
* @return void
|
447 |
*/
|
448 |
public function save_data($post_id)
|
449 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
20 |
*/
|
21 |
class WPCAModule_post_type extends WPCAModule_Base
|
22 |
{
|
|
|
23 |
/**
|
24 |
* @var string
|
25 |
*/
|
38 |
*/
|
39 |
private $_post_ancestor_conditions;
|
40 |
|
|
|
|
|
|
|
41 |
public function __construct()
|
42 |
{
|
43 |
parent::__construct('post_type', __('Post Types', WPCA_DOMAIN));
|
|
|
44 |
$this->query_name = 'cp';
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* @inheritDoc
|
|
|
|
|
|
|
49 |
*/
|
50 |
public function initiate()
|
51 |
{
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
73 |
*/
|
74 |
protected function _get_content($args = [])
|
75 |
{
|
106 |
//Using unprepared (safe) exclude because WP is not good at parsing arrays
|
107 |
global $wpdb;
|
108 |
$posts = $wpdb->get_results($wpdb->prepare(
|
109 |
+
"
|
110 |
+
SELECT ID, post_title, post_type, post_parent, post_status, post_password
|
111 |
+
FROM {$wpdb->posts}
|
112 |
+
WHERE (".implode(' OR ', $where).")
|
113 |
+
AND post_status IN('".implode("','", $args['post_status'])."')
|
114 |
+
AND post_type = '%s'
|
115 |
+
$exclude_query
|
116 |
+
ORDER BY post_title ASC
|
117 |
+
LIMIT %d,%d
|
118 |
",
|
119 |
array_merge($values, [
|
120 |
$args['post_type'],
|
206 |
}
|
207 |
|
208 |
/**
|
209 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
|
|
210 |
*/
|
211 |
public function get_group_data($group_data, $post_id)
|
212 |
{
|
252 |
}
|
253 |
|
254 |
/**
|
255 |
+
* @inheritDoc
|
|
|
|
|
|
|
256 |
*/
|
257 |
public function in_context()
|
258 |
{
|
260 |
}
|
261 |
|
262 |
/**
|
263 |
+
* @inheritDoc
|
|
|
|
|
|
|
264 |
*/
|
265 |
public function get_context_data()
|
266 |
{
|
285 |
}
|
286 |
|
287 |
/**
|
288 |
+
* @inheritDoc
|
289 |
+
*/
|
|
|
|
|
290 |
protected function parse_query_args($args)
|
291 |
{
|
292 |
if (isset($args['item_object'])) {
|
331 |
}
|
332 |
|
333 |
/**
|
334 |
+
* @inheritDoc
|
|
|
|
|
|
|
335 |
*/
|
336 |
public function list_module($list)
|
337 |
{
|
411 |
}
|
412 |
|
413 |
/**
|
414 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
415 |
*/
|
416 |
public function save_data($post_id)
|
417 |
{
|
lib/wp-content-aware-engine/module/qtranslate.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -19,22 +19,20 @@ defined('ABSPATH') || exit;
|
|
19 |
*/
|
20 |
class WPCAModule_qtranslate extends WPCAModule_Base
|
21 |
{
|
22 |
-
|
23 |
/**
|
24 |
* @var string
|
25 |
*/
|
26 |
protected $category = 'plugins';
|
27 |
|
28 |
-
/**
|
29 |
-
* Constructor
|
30 |
-
*/
|
31 |
public function __construct()
|
32 |
{
|
33 |
parent::__construct('language', __('Languages', WPCA_DOMAIN));
|
34 |
-
|
35 |
$this->query_name = 'cl';
|
36 |
}
|
37 |
|
|
|
|
|
|
|
38 |
public function initiate()
|
39 |
{
|
40 |
parent::initiate();
|
@@ -51,7 +49,7 @@ class WPCAModule_qtranslate extends WPCAModule_Base
|
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
* @
|
55 |
*/
|
56 |
public function can_enable()
|
57 |
{
|
@@ -60,8 +58,7 @@ class WPCAModule_qtranslate extends WPCAModule_Base
|
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
-
* @
|
64 |
-
* @return boolean
|
65 |
*/
|
66 |
public function in_context()
|
67 |
{
|
@@ -69,10 +66,7 @@ class WPCAModule_qtranslate extends WPCAModule_Base
|
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
-
*
|
73 |
-
*
|
74 |
-
* @since 1.0
|
75 |
-
* @return array
|
76 |
*/
|
77 |
public function get_context_data()
|
78 |
{
|
@@ -82,12 +76,7 @@ class WPCAModule_qtranslate extends WPCAModule_Base
|
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
-
*
|
86 |
-
*
|
87 |
-
* @global array $q_config
|
88 |
-
* @since 1.0
|
89 |
-
* @param array $args
|
90 |
-
* @return array
|
91 |
*/
|
92 |
protected function _get_content($args = [])
|
93 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
19 |
*/
|
20 |
class WPCAModule_qtranslate extends WPCAModule_Base
|
21 |
{
|
|
|
22 |
/**
|
23 |
* @var string
|
24 |
*/
|
25 |
protected $category = 'plugins';
|
26 |
|
|
|
|
|
|
|
27 |
public function __construct()
|
28 |
{
|
29 |
parent::__construct('language', __('Languages', WPCA_DOMAIN));
|
|
|
30 |
$this->query_name = 'cl';
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
+
* @inheritDoc
|
35 |
+
*/
|
36 |
public function initiate()
|
37 |
{
|
38 |
parent::initiate();
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
+
* @inheritDoc
|
53 |
*/
|
54 |
public function can_enable()
|
55 |
{
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
+
* @inheritDoc
|
|
|
62 |
*/
|
63 |
public function in_context()
|
64 |
{
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
+
* @inheritDoc
|
|
|
|
|
|
|
70 |
*/
|
71 |
public function get_context_data()
|
72 |
{
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
|
|
80 |
*/
|
81 |
protected function _get_content($args = [])
|
82 |
{
|
lib/wp-content-aware-engine/module/static.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -27,22 +27,14 @@ class WPCAModule_static extends WPCAModule_Base
|
|
27 |
*/
|
28 |
protected $search_string;
|
29 |
|
30 |
-
/**
|
31 |
-
* Constructor
|
32 |
-
*/
|
33 |
public function __construct()
|
34 |
{
|
35 |
parent::__construct('static', __('Special Pages', WPCA_DOMAIN));
|
36 |
-
|
37 |
$this->query_name = 'cs';
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
-
*
|
42 |
-
*
|
43 |
-
* @since 1.0
|
44 |
-
* @param array $args
|
45 |
-
* @return array
|
46 |
*/
|
47 |
protected function _get_content($args = [])
|
48 |
{
|
@@ -74,10 +66,7 @@ class WPCAModule_static extends WPCAModule_Base
|
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
-
*
|
78 |
-
*
|
79 |
-
* @since 1.0
|
80 |
-
* @return boolean
|
81 |
*/
|
82 |
public function in_context()
|
83 |
{
|
@@ -85,10 +74,7 @@ class WPCAModule_static extends WPCAModule_Base
|
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
-
*
|
89 |
-
*
|
90 |
-
* @since 1.0
|
91 |
-
* @return array
|
92 |
*/
|
93 |
public function get_context_data()
|
94 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
27 |
*/
|
28 |
protected $search_string;
|
29 |
|
|
|
|
|
|
|
30 |
public function __construct()
|
31 |
{
|
32 |
parent::__construct('static', __('Special Pages', WPCA_DOMAIN));
|
|
|
33 |
$this->query_name = 'cs';
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
38 |
*/
|
39 |
protected function _get_content($args = [])
|
40 |
{
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
+
* @inheritDoc
|
|
|
|
|
|
|
70 |
*/
|
71 |
public function in_context()
|
72 |
{
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
+
* @inheritDoc
|
|
|
|
|
|
|
78 |
*/
|
79 |
public function get_context_data()
|
80 |
{
|
lib/wp-content-aware-engine/module/taxonomy.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -43,24 +43,23 @@ class WPCAModule_taxonomy extends WPCAModule_Base
|
|
43 |
*
|
44 |
* @var array
|
45 |
*/
|
46 |
-
private $post_terms;
|
47 |
|
48 |
/**
|
49 |
* Taxonomies for a given singular
|
50 |
* @var array
|
51 |
*/
|
52 |
-
private $post_taxonomies;
|
53 |
|
54 |
-
/**
|
55 |
-
* Constructor
|
56 |
-
*/
|
57 |
public function __construct()
|
58 |
{
|
59 |
parent::__construct('taxonomy', __('Taxonomies', WPCA_DOMAIN));
|
60 |
-
|
61 |
$this->query_name = 'ct';
|
62 |
}
|
63 |
|
|
|
|
|
|
|
64 |
public function initiate()
|
65 |
{
|
66 |
parent::initiate();
|
@@ -82,18 +81,27 @@ class WPCAModule_taxonomy extends WPCAModule_Base
|
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
-
*
|
86 |
-
*
|
87 |
-
* @since 1.0
|
88 |
-
* @return boolean
|
89 |
*/
|
90 |
public function in_context()
|
91 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
if (is_singular()) {
|
93 |
$tax = $this->_get_taxonomies();
|
94 |
-
$this->post_terms = [];
|
95 |
-
$this->post_taxonomies = [];
|
96 |
-
|
97 |
// Check if content has any taxonomies supported
|
98 |
foreach (get_object_taxonomies(get_post_type()) as $taxonomy) {
|
99 |
//Only want taxonomies selectable in admin
|
@@ -110,59 +118,105 @@ class WPCAModule_taxonomy extends WPCAModule_Base
|
|
110 |
}
|
111 |
}
|
112 |
}
|
113 |
-
|
|
|
|
|
|
|
114 |
}
|
115 |
-
return is_tax() || is_category() || is_tag();
|
116 |
-
}
|
117 |
|
118 |
-
|
119 |
-
* Query join
|
120 |
-
*
|
121 |
-
* @since 1.0
|
122 |
-
* @return string
|
123 |
-
*/
|
124 |
-
public function db_join()
|
125 |
-
{
|
126 |
-
global $wpdb;
|
127 |
-
$joins = parent::db_join();
|
128 |
-
$joins .= "LEFT JOIN $wpdb->term_relationships term ON term.object_id = p.ID ";
|
129 |
-
return $joins;
|
130 |
}
|
131 |
|
132 |
/**
|
133 |
-
*
|
134 |
-
*
|
135 |
-
* @since 1.0
|
136 |
-
* @return array
|
137 |
*/
|
138 |
-
public function
|
139 |
{
|
140 |
-
$
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
$terms = [];
|
146 |
foreach ($this->post_terms as $term) {
|
147 |
-
$
|
148 |
}
|
149 |
-
$tax = $this->post_taxonomies;
|
150 |
-
} else {
|
151 |
-
$term = get_queried_object();
|
152 |
-
$terms = [$term->term_taxonomy_id];
|
153 |
-
$tax = [$term->taxonomy];
|
154 |
-
}
|
155 |
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
}
|
159 |
|
160 |
/**
|
161 |
-
*
|
162 |
-
*
|
163 |
-
* @since 1.0
|
164 |
-
* @param array $args
|
165 |
-
* @return array
|
166 |
*/
|
167 |
protected function _get_content($args = [])
|
168 |
{
|
@@ -265,12 +319,7 @@ class WPCAModule_taxonomy extends WPCAModule_Base
|
|
265 |
}
|
266 |
|
267 |
/**
|
268 |
-
*
|
269 |
-
*
|
270 |
-
* @since 2.0
|
271 |
-
* @param array $group_data
|
272 |
-
* @param int $post_id
|
273 |
-
* @return array
|
274 |
*/
|
275 |
public function get_group_data($group_data, $post_id)
|
276 |
{
|
@@ -331,6 +380,9 @@ class WPCAModule_taxonomy extends WPCAModule_Base
|
|
331 |
return $title_count;
|
332 |
}
|
333 |
|
|
|
|
|
|
|
334 |
protected function get_list_data($taxonomy, $title_count)
|
335 |
{
|
336 |
$placeholder = '/'.sprintf(__('%s Archives', WPCA_DOMAIN), $taxonomy->labels->singular_name);
|
@@ -350,10 +402,7 @@ class WPCAModule_taxonomy extends WPCAModule_Base
|
|
350 |
}
|
351 |
|
352 |
/**
|
353 |
-
* @
|
354 |
-
* @param array $list
|
355 |
-
*
|
356 |
-
* @return array
|
357 |
*/
|
358 |
public function list_module($list)
|
359 |
{
|
@@ -367,10 +416,8 @@ class WPCAModule_taxonomy extends WPCAModule_Base
|
|
367 |
}
|
368 |
|
369 |
/**
|
370 |
-
|
371 |
-
|
372 |
-
* @return array
|
373 |
-
*/
|
374 |
protected function parse_query_args($args)
|
375 |
{
|
376 |
if (isset($args['item_object'])) {
|
@@ -395,11 +442,7 @@ class WPCAModule_taxonomy extends WPCAModule_Base
|
|
395 |
}
|
396 |
|
397 |
/**
|
398 |
-
*
|
399 |
-
*
|
400 |
-
* @since 1.0
|
401 |
-
* @param int $post_id
|
402 |
-
* @return void
|
403 |
*/
|
404 |
public function save_data($post_id)
|
405 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
43 |
*
|
44 |
* @var array
|
45 |
*/
|
46 |
+
private $post_terms = [];
|
47 |
|
48 |
/**
|
49 |
* Taxonomies for a given singular
|
50 |
* @var array
|
51 |
*/
|
52 |
+
private $post_taxonomies = [];
|
53 |
|
|
|
|
|
|
|
54 |
public function __construct()
|
55 |
{
|
56 |
parent::__construct('taxonomy', __('Taxonomies', WPCA_DOMAIN));
|
|
|
57 |
$this->query_name = 'ct';
|
58 |
}
|
59 |
|
60 |
+
/**
|
61 |
+
* @inheritDoc
|
62 |
+
*/
|
63 |
public function initiate()
|
64 |
{
|
65 |
parent::initiate();
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
+
* @inheritDoc
|
|
|
|
|
|
|
85 |
*/
|
86 |
public function in_context()
|
87 |
{
|
88 |
+
//check if post_taxonomies contains more than self::VALUE_HAS_TERMS
|
89 |
+
return count($this->get_context_data()) > 1;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* @inheritDoc
|
94 |
+
*/
|
95 |
+
public function get_context_data()
|
96 |
+
{
|
97 |
+
if (!empty($this->post_taxonomies)) {
|
98 |
+
return $this->post_taxonomies;
|
99 |
+
}
|
100 |
+
|
101 |
+
$this->post_taxonomies[] = self::VALUE_HAS_TERMS;
|
102 |
+
|
103 |
if (is_singular()) {
|
104 |
$tax = $this->_get_taxonomies();
|
|
|
|
|
|
|
105 |
// Check if content has any taxonomies supported
|
106 |
foreach (get_object_taxonomies(get_post_type()) as $taxonomy) {
|
107 |
//Only want taxonomies selectable in admin
|
118 |
}
|
119 |
}
|
120 |
}
|
121 |
+
} elseif (is_tax() || is_category() || is_tag()) {
|
122 |
+
$term = get_queried_object();
|
123 |
+
$this->post_taxonomies[] = $term->taxonomy;
|
124 |
+
$this->post_terms[] = $term;
|
125 |
}
|
|
|
|
|
126 |
|
127 |
+
return $this->post_taxonomies;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
}
|
129 |
|
130 |
/**
|
131 |
+
* @inheritDoc
|
|
|
|
|
|
|
132 |
*/
|
133 |
+
public function filter_excluded_context($posts, $in_context = false)
|
134 |
{
|
135 |
+
$posts = parent::filter_excluded_context($posts, $in_context);
|
136 |
+
if ($in_context) {
|
137 |
+
$post_terms_by_tax = [];
|
138 |
+
//@todo archive pages should be migrated to use AND as well, keep OR for now
|
139 |
+
$legacy_use_or = is_archive();
|
|
|
140 |
foreach ($this->post_terms as $term) {
|
141 |
+
$post_terms_by_tax[$term->taxonomy][$term->term_taxonomy_id] = $term->term_taxonomy_id;
|
142 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
|
144 |
+
$check_terms = [];
|
145 |
+
$keep_archive = [];
|
146 |
+
$unset = [];
|
147 |
+
|
148 |
+
//1. group's taxonomies must match all in post
|
149 |
+
foreach ($posts as $condition_id => $condition_group) {
|
150 |
+
$condition_taxonomies = get_post_meta($condition_id, '_ca_taxonomy', false);
|
151 |
+
foreach ($condition_taxonomies as $taxonomy) {
|
152 |
+
//if value==-1, group has individual terms, so goto 2
|
153 |
+
if ($taxonomy == '-1') {
|
154 |
+
$check_terms[$condition_id] = $condition_group;
|
155 |
+
} elseif (isset($post_terms_by_tax[$taxonomy])) {
|
156 |
+
//if on archive page, bail after 1st match
|
157 |
+
if ($legacy_use_or) {
|
158 |
+
$keep_archive[$condition_id] = 1;
|
159 |
+
break;
|
160 |
+
}
|
161 |
+
} else {
|
162 |
+
//if group has more taxonomies than post, unset
|
163 |
+
$unset[$condition_id] = 1;
|
164 |
+
//break;
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
//2. group's terms must match with minimum 1 in each taxonomy in post
|
170 |
+
if (!empty($check_terms)) {
|
171 |
+
//eager load groups terms
|
172 |
+
$conditions_terms = wp_get_object_terms(array_keys($check_terms), array_keys($this->_get_taxonomies()), [
|
173 |
+
'fields' => 'all_with_object_id',
|
174 |
+
'orderby' => 'none',
|
175 |
+
'update_term_meta_cache' => false
|
176 |
+
]);
|
177 |
+
|
178 |
+
$conditions_to_unset = [];
|
179 |
+
foreach ($conditions_terms as $term) {
|
180 |
+
if (!isset($conditions_to_unset[$term->object_id][$term->taxonomy])) {
|
181 |
+
$conditions_to_unset[$term->object_id][$term->taxonomy] = 0;
|
182 |
+
}
|
183 |
+
$has_tax_term = isset($post_terms_by_tax[$term->taxonomy][$term->term_taxonomy_id]);
|
184 |
+
$conditions_to_unset[$term->object_id][$term->taxonomy] |= $has_tax_term;
|
185 |
+
if ($legacy_use_or && $has_tax_term) {
|
186 |
+
$keep_archive[$term->object_id] = 1;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
foreach ($check_terms as $condition_id => $condition_group) {
|
191 |
+
|
192 |
+
//if group has no terms in these taxonomies, it has terms in others, so unset
|
193 |
+
if (!isset($conditions_to_unset[$condition_id])) {
|
194 |
+
$unset[$condition_id] = 1;
|
195 |
+
continue;
|
196 |
+
}
|
197 |
+
|
198 |
+
foreach ($conditions_to_unset[$condition_id] as $taxonomy => $should_keep) {
|
199 |
+
//if group has a taxonomy with no term match, unset
|
200 |
+
if (!$should_keep) {
|
201 |
+
$unset[$condition_id] = 1;
|
202 |
+
break;
|
203 |
+
}
|
204 |
+
}
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
foreach ($unset as $id => $value) {
|
209 |
+
if (!isset($keep_archive[$id])) {
|
210 |
+
unset($posts[$id]);
|
211 |
+
}
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
return $posts;
|
216 |
}
|
217 |
|
218 |
/**
|
219 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
220 |
*/
|
221 |
protected function _get_content($args = [])
|
222 |
{
|
319 |
}
|
320 |
|
321 |
/**
|
322 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
|
|
323 |
*/
|
324 |
public function get_group_data($group_data, $post_id)
|
325 |
{
|
380 |
return $title_count;
|
381 |
}
|
382 |
|
383 |
+
/**
|
384 |
+
* @inheritDoc
|
385 |
+
*/
|
386 |
protected function get_list_data($taxonomy, $title_count)
|
387 |
{
|
388 |
$placeholder = '/'.sprintf(__('%s Archives', WPCA_DOMAIN), $taxonomy->labels->singular_name);
|
402 |
}
|
403 |
|
404 |
/**
|
405 |
+
* @inheritDoc
|
|
|
|
|
|
|
406 |
*/
|
407 |
public function list_module($list)
|
408 |
{
|
416 |
}
|
417 |
|
418 |
/**
|
419 |
+
* @inheritDoc
|
420 |
+
*/
|
|
|
|
|
421 |
protected function parse_query_args($args)
|
422 |
{
|
423 |
if (isset($args['item_object'])) {
|
442 |
}
|
443 |
|
444 |
/**
|
445 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
446 |
*/
|
447 |
public function save_data($post_id)
|
448 |
{
|
lib/wp-content-aware-engine/module/translatepress.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -18,7 +18,6 @@ defined('ABSPATH') || exit;
|
|
18 |
*/
|
19 |
class WPCAModule_translatepress extends WPCAModule_Base
|
20 |
{
|
21 |
-
|
22 |
/**
|
23 |
* @var string
|
24 |
*/
|
@@ -27,13 +26,11 @@ class WPCAModule_translatepress extends WPCAModule_Base
|
|
27 |
public function __construct()
|
28 |
{
|
29 |
parent::__construct('language', __('Languages', WPCA_DOMAIN));
|
30 |
-
|
31 |
$this->query_name = 'cl';
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
* @
|
36 |
-
* @return boolean
|
37 |
*/
|
38 |
public function in_context()
|
39 |
{
|
@@ -41,7 +38,7 @@ class WPCAModule_translatepress extends WPCAModule_Base
|
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
-
* @
|
45 |
*/
|
46 |
public function can_enable()
|
47 |
{
|
@@ -50,10 +47,7 @@ class WPCAModule_translatepress extends WPCAModule_Base
|
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
-
*
|
54 |
-
*
|
55 |
-
* @since 9.0
|
56 |
-
* @return array
|
57 |
*/
|
58 |
public function get_context_data()
|
59 |
{
|
@@ -66,11 +60,7 @@ class WPCAModule_translatepress extends WPCAModule_Base
|
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
-
*
|
70 |
-
*
|
71 |
-
* @since 9.0
|
72 |
-
* @param array $args
|
73 |
-
* @return array
|
74 |
*/
|
75 |
protected function _get_content($args = [])
|
76 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
18 |
*/
|
19 |
class WPCAModule_translatepress extends WPCAModule_Base
|
20 |
{
|
|
|
21 |
/**
|
22 |
* @var string
|
23 |
*/
|
26 |
public function __construct()
|
27 |
{
|
28 |
parent::__construct('language', __('Languages', WPCA_DOMAIN));
|
|
|
29 |
$this->query_name = 'cl';
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
+
* @inheritDoc
|
|
|
34 |
*/
|
35 |
public function in_context()
|
36 |
{
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* @inheritDoc
|
42 |
*/
|
43 |
public function can_enable()
|
44 |
{
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* @inheritDoc
|
|
|
|
|
|
|
51 |
*/
|
52 |
public function get_context_data()
|
53 |
{
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
64 |
*/
|
65 |
protected function _get_content($args = [])
|
66 |
{
|
lib/wp-content-aware-engine/module/transposh.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -19,25 +19,19 @@ defined('ABSPATH') || exit;
|
|
19 |
*/
|
20 |
class WPCAModule_transposh extends WPCAModule_Base
|
21 |
{
|
22 |
-
|
23 |
/**
|
24 |
* @var string
|
25 |
*/
|
26 |
protected $category = 'plugins';
|
27 |
|
28 |
-
/**
|
29 |
-
* Constructor
|
30 |
-
*/
|
31 |
public function __construct()
|
32 |
{
|
33 |
parent::__construct('language', __('Languages', WPCA_DOMAIN));
|
34 |
-
|
35 |
$this->query_name = 'cl';
|
36 |
}
|
37 |
|
38 |
-
|
39 |
/**
|
40 |
-
* @
|
41 |
*/
|
42 |
public function can_enable()
|
43 |
{
|
@@ -48,8 +42,7 @@ class WPCAModule_transposh extends WPCAModule_Base
|
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
-
* @
|
52 |
-
* @return boolean
|
53 |
*/
|
54 |
public function in_context()
|
55 |
{
|
@@ -57,10 +50,7 @@ class WPCAModule_transposh extends WPCAModule_Base
|
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
-
*
|
61 |
-
*
|
62 |
-
* @since 1.0
|
63 |
-
* @return array
|
64 |
*/
|
65 |
public function get_context_data()
|
66 |
{
|
@@ -70,12 +60,7 @@ class WPCAModule_transposh extends WPCAModule_Base
|
|
70 |
}
|
71 |
|
72 |
/**
|
73 |
-
*
|
74 |
-
*
|
75 |
-
* @global object $my_transposh_plugin
|
76 |
-
* @since 1.0
|
77 |
-
* @param array $args
|
78 |
-
* @return array
|
79 |
*/
|
80 |
protected function _get_content($args = [])
|
81 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
19 |
*/
|
20 |
class WPCAModule_transposh extends WPCAModule_Base
|
21 |
{
|
|
|
22 |
/**
|
23 |
* @var string
|
24 |
*/
|
25 |
protected $category = 'plugins';
|
26 |
|
|
|
|
|
|
|
27 |
public function __construct()
|
28 |
{
|
29 |
parent::__construct('language', __('Languages', WPCA_DOMAIN));
|
|
|
30 |
$this->query_name = 'cl';
|
31 |
}
|
32 |
|
|
|
33 |
/**
|
34 |
+
* @inheritDoc
|
35 |
*/
|
36 |
public function can_enable()
|
37 |
{
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
+
* @inheritDoc
|
|
|
46 |
*/
|
47 |
public function in_context()
|
48 |
{
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* @inheritDoc
|
|
|
|
|
|
|
54 |
*/
|
55 |
public function get_context_data()
|
56 |
{
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
|
|
64 |
*/
|
65 |
protected function _get_content($args = [])
|
66 |
{
|
lib/wp-content-aware-engine/module/wpml.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
@@ -19,25 +19,19 @@ defined('ABSPATH') || exit;
|
|
19 |
*/
|
20 |
class WPCAModule_wpml extends WPCAModule_Base
|
21 |
{
|
22 |
-
|
23 |
/**
|
24 |
* @var string
|
25 |
*/
|
26 |
protected $category = 'plugins';
|
27 |
|
28 |
-
/**
|
29 |
-
* Constructor
|
30 |
-
*/
|
31 |
public function __construct()
|
32 |
{
|
33 |
parent::__construct('language', __('Languages', WPCA_DOMAIN));
|
34 |
-
|
35 |
$this->query_name = 'cl';
|
36 |
}
|
37 |
|
38 |
-
|
39 |
/**
|
40 |
-
* @
|
41 |
*/
|
42 |
public function can_enable()
|
43 |
{
|
@@ -47,8 +41,7 @@ class WPCAModule_wpml extends WPCAModule_Base
|
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
* @
|
51 |
-
* @return boolean
|
52 |
*/
|
53 |
public function in_context()
|
54 |
{
|
@@ -56,10 +49,7 @@ class WPCAModule_wpml extends WPCAModule_Base
|
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
-
*
|
60 |
-
*
|
61 |
-
* @since 1.0
|
62 |
-
* @return array
|
63 |
*/
|
64 |
public function get_context_data()
|
65 |
{
|
@@ -69,11 +59,7 @@ class WPCAModule_wpml extends WPCAModule_Base
|
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
-
*
|
73 |
-
*
|
74 |
-
* @since 1.0
|
75 |
-
* @param array $args
|
76 |
-
* @return array
|
77 |
*/
|
78 |
protected function _get_content($args = [])
|
79 |
{
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
19 |
*/
|
20 |
class WPCAModule_wpml extends WPCAModule_Base
|
21 |
{
|
|
|
22 |
/**
|
23 |
* @var string
|
24 |
*/
|
25 |
protected $category = 'plugins';
|
26 |
|
|
|
|
|
|
|
27 |
public function __construct()
|
28 |
{
|
29 |
parent::__construct('language', __('Languages', WPCA_DOMAIN));
|
|
|
30 |
$this->query_name = 'cl';
|
31 |
}
|
32 |
|
|
|
33 |
/**
|
34 |
+
* @inheritDoc
|
35 |
*/
|
36 |
public function can_enable()
|
37 |
{
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
+
* @inheritDoc
|
|
|
45 |
*/
|
46 |
public function in_context()
|
47 |
{
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
+
* @inheritDoc
|
|
|
|
|
|
|
53 |
*/
|
54 |
public function get_context_data()
|
55 |
{
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
+
* @inheritDoc
|
|
|
|
|
|
|
|
|
63 |
*/
|
64 |
protected function _get_content($args = [])
|
65 |
{
|
lib/wp-content-aware-engine/modulemanager.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
lib/wp-content-aware-engine/objectmanager.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
lib/wp-content-aware-engine/typemanager.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
lib/wp-content-aware-engine/view.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
defined('ABSPATH') || exit;
|
lib/wp-content-aware-engine/view/condition_options.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
?>
|
9 |
<li>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
?>
|
9 |
<li>
|
lib/wp-content-aware-engine/view/condition_template.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
?>
|
9 |
<script type="text/template" id="wpca-template-condition">
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
?>
|
9 |
<script type="text/template" id="wpca-template-condition">
|
lib/wp-content-aware-engine/view/group_template.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
?>
|
9 |
<script type="text/template" id="wpca-template-group">
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
?>
|
9 |
<script type="text/template" id="wpca-template-group">
|
lib/wp-content-aware-engine/view/meta_box.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @package
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
-
* @copyright
|
7 |
*/
|
8 |
|
9 |
$quick_links = [
|
@@ -29,25 +29,25 @@ if (post_type_exists('product')) {
|
|
29 |
}
|
30 |
|
31 |
echo $nonce; ?>
|
32 |
-
<div id="cas-groups">
|
33 |
<?php do_action('wpca/meta_box/before', $post_type); ?>
|
34 |
-
<ul data-vm="collection:$collection"></ul>
|
35 |
-
<div class="cas-group-sep" data-vm="toggle:length($collection)">
|
36 |
-
<span><?php _e('Or', WPCA_DOMAIN); ?></span>
|
37 |
-
</div>
|
38 |
-
<div class="cas-group-new">
|
39 |
-
<div>
|
40 |
-
<select class="wpca-conditions-add js-wpca-add-or">
|
41 |
-
<option></option>
|
42 |
-
</select>
|
43 |
-
<span style="vertical-align: middle;"><em>or</em> <strong>Quick Add:</strong></span>
|
44 |
-
</div>
|
45 |
-
<div>
|
46 |
<?php foreach ($quick_links as $label => $conditions) : ?>
|
47 |
-
<a class="js-wpca-add-quick" href="#"
|
48 |
-
data-config='<?php echo json_encode($conditions); ?>'><?php echo $label; ?></a>
|
49 |
<?php endforeach; ?>
|
50 |
-
</div>
|
51 |
-
</div>
|
52 |
<?php do_action('wpca/meta_box/after', $post_type); ?>
|
53 |
</div>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @package wp-content-aware-engine
|
4 |
* @author Joachim Jensen <joachim@dev.institute>
|
5 |
* @license GPLv3
|
6 |
+
* @copyright 2021 by Joachim Jensen
|
7 |
*/
|
8 |
|
9 |
$quick_links = [
|
29 |
}
|
30 |
|
31 |
echo $nonce; ?>
|
32 |
+
<div id="cas-groups">
|
33 |
<?php do_action('wpca/meta_box/before', $post_type); ?>
|
34 |
+
<ul data-vm="collection:$collection"></ul>
|
35 |
+
<div class="cas-group-sep" data-vm="toggle:length($collection)">
|
36 |
+
<span><?php _e('Or', WPCA_DOMAIN); ?></span>
|
37 |
+
</div>
|
38 |
+
<div class="cas-group-new">
|
39 |
+
<div>
|
40 |
+
<select class="wpca-conditions-add js-wpca-add-or">
|
41 |
+
<option></option>
|
42 |
+
</select>
|
43 |
+
<span style="vertical-align: middle;"><em>or</em> <strong>Quick Add:</strong></span>
|
44 |
+
</div>
|
45 |
+
<div>
|
46 |
<?php foreach ($quick_links as $label => $conditions) : ?>
|
47 |
+
<a class="js-wpca-add-quick" href="#"
|
48 |
+
data-config='<?php echo json_encode($conditions); ?>'><?php echo $label; ?></a>
|
49 |
<?php endforeach; ?>
|
50 |
+
</div>
|
51 |
+
</div>
|
52 |
<?php do_action('wpca/meta_box/after', $post_type); ?>
|
53 |
</div>
|
readme.txt
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
Contributors: intoxstudio, devinstitute, freemius
|
3 |
Donate link: #
|
4 |
Tags: custom sidebars, sidebar, hide sidebar, display widgets, widget, bbpress, buddypress, sidebar manager
|
5 |
-
Requires at least:
|
6 |
Requires PHP: 5.6
|
7 |
-
Tested up to: 5.
|
8 |
-
Stable tag: 3.
|
9 |
License: GPLv3
|
10 |
|
11 |
Display new sidebars and widget areas on any post, page, category etc. Works with all themes, no code required.
|
@@ -184,6 +184,26 @@ Of course! Check out the links below:
|
|
184 |
|
185 |
####Highlights
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
= 3.15.2 =
|
188 |
|
189 |
* [new] performance improvements
|
2 |
Contributors: intoxstudio, devinstitute, freemius
|
3 |
Donate link: #
|
4 |
Tags: custom sidebars, sidebar, hide sidebar, display widgets, widget, bbpress, buddypress, sidebar manager
|
5 |
+
Requires at least: 5.0
|
6 |
Requires PHP: 5.6
|
7 |
+
Tested up to: 5.8
|
8 |
+
Stable tag: 3.16.1
|
9 |
License: GPLv3
|
10 |
|
11 |
Display new sidebars and widget areas on any post, page, category etc. Works with all themes, no code required.
|
184 |
|
185 |
####Highlights
|
186 |
|
187 |
+
= 3.16.1 =
|
188 |
+
|
189 |
+
* [fixed] warning on admin dashboard
|
190 |
+
|
191 |
+
= 3.16 =
|
192 |
+
|
193 |
+
* [new] enable condition type cache in toolbar menu
|
194 |
+
* [new] performance improvements
|
195 |
+
* [new] taxonomy condition added to cache system (all condition types supported now)
|
196 |
+
* [new] wordpress 5.8 support
|
197 |
+
* [new] minimum wordpress version 5.0
|
198 |
+
* [fixed] multiple taxonomy conditions now use AND properly on singular pages (long-standing bug)
|
199 |
+
* [updated] wp-content-aware-engine library
|
200 |
+
|
201 |
+
**Pro Plan:**
|
202 |
+
|
203 |
+
* [new] totem - display widgets in floating button
|
204 |
+
* [new] option to display container widget only if conditions are met
|
205 |
+
* [new] sticky support for ajax powered themes such as woodmart
|
206 |
+
|
207 |
= 3.15.2 =
|
208 |
|
209 |
* [new] performance improvements
|
sidebar.php
CHANGED
@@ -160,13 +160,13 @@ final class CAS_Sidebar_Manager
|
|
160 |
->add(new WPCAMeta(
|
161 |
'handle',
|
162 |
_x('Action', 'option', 'content-aware-sidebars'),
|
163 |
-
|
164 |
'select',
|
165 |
[
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
],
|
171 |
__('Replace host sidebar, merge with it or add sidebar manually.', 'content-aware-sidebars')
|
172 |
), 'handle')
|
@@ -229,6 +229,7 @@ final class CAS_Sidebar_Manager
|
|
229 |
$action_list = $actions->get_input_list();
|
230 |
$action_list['__infuse'] = __('Infuse', 'content-aware-sidebars').$pro_label;
|
231 |
$action_list['__after_paragraph'] = __('After Paragraph', 'content-aware-sidebars').$pro_label;
|
|
|
232 |
$actions->set_input_list($action_list);
|
233 |
}
|
234 |
|
@@ -337,7 +338,11 @@ final class CAS_Sidebar_Manager
|
|
337 |
'before_title' => '<h4 class="widget-title">',
|
338 |
'after_title' => '</h4>'
|
339 |
];
|
340 |
-
$has_host = [
|
|
|
|
|
|
|
|
|
341 |
$metadata = $this->metadata();
|
342 |
|
343 |
foreach ($this->sidebars as $id => $post) {
|
@@ -426,7 +431,11 @@ final class CAS_Sidebar_Manager
|
|
426 |
|
427 |
if ($posts) {
|
428 |
$metadata = $this->metadata();
|
429 |
-
$has_host = [
|
|
|
|
|
|
|
|
|
430 |
|
431 |
//replace and merge widgets, build replacement map
|
432 |
foreach ($posts as $post) {
|
@@ -454,10 +463,10 @@ final class CAS_Sidebar_Manager
|
|
454 |
}
|
455 |
|
456 |
// If handle is merge or if handle is replace and host has already been replaced
|
457 |
-
if ($post->handle ==
|
458 |
//do not merge forced replace
|
459 |
//todo: maybe reverse order of fetched sidebars instead?
|
460 |
-
if (isset($handled_already[$host]) && $handled_already[$host] ==
|
461 |
continue;
|
462 |
}
|
463 |
if ($metadata->get('merge_pos')->get_data($post->ID)) {
|
@@ -540,7 +549,7 @@ final class CAS_Sidebar_Manager
|
|
540 |
$id = CAS_App::SIDEBAR_PREFIX . $post->ID;
|
541 |
|
542 |
// Check for manual handling, if sidebar exists and if id should be included
|
543 |
-
if ($post->handle !=
|
544 |
continue;
|
545 |
}
|
546 |
|
@@ -583,7 +592,7 @@ final class CAS_Sidebar_Manager
|
|
583 |
return $content;
|
584 |
}
|
585 |
|
586 |
-
if ($this->metadata()->get('handle')->get_data($a['id']) !=
|
587 |
return $content;
|
588 |
}
|
589 |
|
160 |
->add(new WPCAMeta(
|
161 |
'handle',
|
162 |
_x('Action', 'option', 'content-aware-sidebars'),
|
163 |
+
CAS_App::ACTION_REPLACE,
|
164 |
'select',
|
165 |
[
|
166 |
+
CAS_App::ACTION_REPLACE => __('Replace', 'content-aware-sidebars'),
|
167 |
+
CAS_App::ACTION_MERGE => __('Merge', 'content-aware-sidebars'),
|
168 |
+
CAS_App::ACTION_REPLACE_FORCED => __('Forced replace', 'content-aware-sidebars'),
|
169 |
+
CAS_App::ACTION_SHORTCODE => __('Shortcode')
|
170 |
],
|
171 |
__('Replace host sidebar, merge with it or add sidebar manually.', 'content-aware-sidebars')
|
172 |
), 'handle')
|
229 |
$action_list = $actions->get_input_list();
|
230 |
$action_list['__infuse'] = __('Infuse', 'content-aware-sidebars').$pro_label;
|
231 |
$action_list['__after_paragraph'] = __('After Paragraph', 'content-aware-sidebars').$pro_label;
|
232 |
+
$action_list['__totem'] = __('Totem - Floating Button', 'content-aware-sidebars').$pro_label;
|
233 |
$actions->set_input_list($action_list);
|
234 |
}
|
235 |
|
338 |
'before_title' => '<h4 class="widget-title">',
|
339 |
'after_title' => '</h4>'
|
340 |
];
|
341 |
+
$has_host = [
|
342 |
+
CAS_App::ACTION_REPLACE => 1,
|
343 |
+
CAS_App::ACTION_MERGE => 1,
|
344 |
+
CAS_App::ACTION_REPLACE_FORCED => 1
|
345 |
+
];
|
346 |
$metadata = $this->metadata();
|
347 |
|
348 |
foreach ($this->sidebars as $id => $post) {
|
431 |
|
432 |
if ($posts) {
|
433 |
$metadata = $this->metadata();
|
434 |
+
$has_host = [
|
435 |
+
CAS_App::ACTION_REPLACE => 1,
|
436 |
+
CAS_App::ACTION_MERGE => 1,
|
437 |
+
CAS_App::ACTION_REPLACE_FORCED => 1
|
438 |
+
];
|
439 |
|
440 |
//replace and merge widgets, build replacement map
|
441 |
foreach ($posts as $post) {
|
463 |
}
|
464 |
|
465 |
// If handle is merge or if handle is replace and host has already been replaced
|
466 |
+
if ($post->handle == CAS_App::ACTION_MERGE || ($post->handle == CAS_App::ACTION_REPLACE && isset($handled_already[$host]))) {
|
467 |
//do not merge forced replace
|
468 |
//todo: maybe reverse order of fetched sidebars instead?
|
469 |
+
if (isset($handled_already[$host]) && $handled_already[$host] == CAS_App::ACTION_REPLACE_FORCED) {
|
470 |
continue;
|
471 |
}
|
472 |
if ($metadata->get('merge_pos')->get_data($post->ID)) {
|
549 |
$id = CAS_App::SIDEBAR_PREFIX . $post->ID;
|
550 |
|
551 |
// Check for manual handling, if sidebar exists and if id should be included
|
552 |
+
if ($post->handle != CAS_App::ACTION_SHORTCODE || !isset($_wp_sidebars_widgets[$id]) || (!empty($include) && !isset($include[$post->ID]))) {
|
553 |
continue;
|
554 |
}
|
555 |
|
592 |
return $content;
|
593 |
}
|
594 |
|
595 |
+
if ($this->metadata()->get('handle')->get_data($a['id']) != CAS_App::ACTION_SHORTCODE) {
|
596 |
return $content;
|
597 |
}
|
598 |
|