Content Aware Sidebars – Unlimited Widget Areas - Version 3.12.2

Version Description

  • [fixed] sidebars inserted with shortcode can now be replaced/merged

Pro Plan:

  • [fixed] acf condition now works with relational fields
  • [fixed] ensure sticky js is only loaded once
Download this release

Release Info

Developer intoxstudio
Plugin Icon 128x128 Content Aware Sidebars – Unlimited Widget Areas
Version 3.12.2
Comparing to
See all releases

Code changes from version 3.12 to 3.12.2

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.12';
15
 
16
  /**
17
  * Prefix for sidebar id
11
  final class CAS_App
12
  {
13
  const PLUGIN_VERSION_KEY = 'cas_db_version';
14
+ const PLUGIN_VERSION = '3.12.2';
15
 
16
  /**
17
  * Prefix for sidebar id
content-aware-sidebars.php CHANGED
@@ -9,7 +9,7 @@
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.12
13
  Author: Joachim Jensen - DEV Institute
14
  Author URI: https://dev.institute
15
  Text Domain: content-aware-sidebars
@@ -49,17 +49,13 @@ if (!class_exists('CAS_App')) {
49
  require($cas_dir_path.'lib/wp-content-aware-engine/bootstrap.php');
50
  require($cas_dir_path.'lib/wp-db-updater/wp-db-updater.php');
51
  require($cas_dir_path.'app.php');
52
-
53
- if (is_admin()) {
54
- require($cas_dir_path.'lib/wp-pointer-tour/wp-pointer-tour.php');
55
- require($cas_dir_path.'admin/admin.php');
56
- require($cas_dir_path.'admin/quick_select.php');
57
- require($cas_dir_path.'admin/sidebar-list-table.php');
58
- require($cas_dir_path.'admin/sidebar-overview.php');
59
- require($cas_dir_path.'admin/sidebar-edit.php');
60
- require($cas_dir_path.'admin/screen_widgets.php');
61
- }
62
-
63
  require($cas_dir_path.'sidebar.php');
64
  require($cas_dir_path.'freemius.php');
65
  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.12.2
13
  Author: Joachim Jensen - DEV Institute
14
  Author URI: https://dev.institute
15
  Text Domain: content-aware-sidebars
49
  require($cas_dir_path.'lib/wp-content-aware-engine/bootstrap.php');
50
  require($cas_dir_path.'lib/wp-db-updater/wp-db-updater.php');
51
  require($cas_dir_path.'app.php');
52
+ require($cas_dir_path.'lib/wp-pointer-tour/wp-pointer-tour.php');
53
+ require($cas_dir_path.'admin/admin.php');
54
+ require($cas_dir_path.'admin/quick_select.php');
55
+ require($cas_dir_path.'admin/sidebar-list-table.php');
56
+ require($cas_dir_path.'admin/sidebar-overview.php');
57
+ require($cas_dir_path.'admin/sidebar-edit.php');
58
+ require($cas_dir_path.'admin/screen_widgets.php');
 
 
 
 
59
  require($cas_dir_path.'sidebar.php');
60
  require($cas_dir_path.'freemius.php');
61
  require($cas_dir_path.'admin/db-updates.php');
freemius.php CHANGED
@@ -40,8 +40,6 @@ function cas_fs()
40
 
41
  // Init Freemius.
42
  cas_fs();
43
- // Signal that SDK was initiated.
44
- do_action( 'cas_fs_loaded' );
45
  global $cas_fs ;
46
  function cas_fs_connect_message_update(
47
  $message,
@@ -107,3 +105,6 @@ if ( $cas_fs->is_on() ) {
107
  //after_uninstall is only run for new users
108
  register_uninstall_hook( plugin_dir_path( __FILE__ ) . 'content-aware-sidebars.php', 'cas_fs_uninstall' );
109
  }
 
 
 
40
 
41
  // Init Freemius.
42
  cas_fs();
 
 
43
  global $cas_fs ;
44
  function cas_fs_connect_message_update(
45
  $message,
105
  //after_uninstall is only run for new users
106
  register_uninstall_hook( plugin_dir_path( __FILE__ ) . 'content-aware-sidebars.php', 'cas_fs_uninstall' );
107
  }
108
+
109
+ // Signal that SDK was initiated.
110
+ do_action( 'cas_fs_loaded' );
lib/wp-content-aware-engine/assets/css/condition_groups.css CHANGED
@@ -1,6 +1,6 @@
1
- /*!
2
- * @package WP Content Aware Engine
3
- * @author Joachim Jensen <joachim@dev.institute>
4
- * @license GPLv3
5
- * @copyright 2020 by Joachim Jensen
6
  */.wpca-pull-left{float:left}.rtl .wpca-pull-left,.wpca-pull-right{float:right}.rtl .wpca-pull-right{float:left}.wpca-alert{position:fixed;top:0;font-weight:700;color:#fff;font-size:1.3em;width:100%}.wpca-alert .wpca-error,.wpca-alert .wpca-success{box-sizing:border-box;text-align:center;box-shadow:0 1px 4px rgba(0,0,0,.3),inset 0 0 0 3px rgba(0,0,0,.1);padding:18px 30px}.wpca-alert .wpca-success{background-color:#46b450}.wpca-alert .wpca-error{background-color:#ff7058}@media (min-width:601px){.wpca-alert{width:auto;top:auto;bottom:30px;right:30px}.wpca-error,.wpca-success{min-width:320px;position:relative;border-radius:40px}.rtl .wpca-alert{left:30px;right:auto}}#cas-groups{padding:6px 0 0}#cas-groups .button-small .dashicons{vertical-align:text-top}#cas-groups>ul{position:relative;margin:0;transition:all 1s ease;max-height:9999px;height:auto}.cas-group-body,.cas-group-new{box-sizing:border-box;border-width:1px;border-style:solid;border-color:#ccd0d4;background-color:#f1f1f1;overflow:hidden;position:relative;margin-bottom:0;border-radius:4px;box-shadow:0 1px 1px 1px rgba(0,0,0,.04)}.cas-group-body .cas-group-cell{padding:10px;background-color:#fff;border-top:1px solid #ccd0d4}.cas-group-body .cas-group-actions{padding:5px;overflow:hidden;vertical-align:middle;color:#888}.cas-group-body .cas-group-actions .dashicons{vertical-align:middle}.cas-group-body .cas-group-actions .spinner{float:none}.cas-group-body .cas-group-options{overflow:hidden;margin:0}.cas-group-body .cas-group-options li{overflow:hidden;margin:0;padding:8px 5px;border-top:#ddd 1px solid}.cas-group-actions .wpca-conditions-add+.select2-container.select2-container--wpca .select2-selection{height:26px;font-size:11px}.cas-group-actions .wpca-conditions-add+.select2-container.select2-container--wpca .select2-selection .select2-selection__arrow{height:26px}.cas-group-actions .wpca-conditions-add+.select2-container.select2-container--wpca .select2-selection .select2-selection__rendered{line-height:26px}.wpca-conditions-add+.select2-container.select2-container--wpca .select2-selection{background-color:#f3f5f6;border-color:#0071a1;padding:0 6px 1px;border-radius:3px;vertical-align:top}.wpca-conditions-add+.select2-container.select2-container--wpca .select2-selection:hover{border-color:#016087;background-color:#f1f1f1}.wpca-conditions-add+.select2-container.select2-container--wpca .select2-selection .select2-selection__placeholder{color:#0071a1}.cas-group-single{margin:0}.cas-condition:first-of-type>.cas-group-sep,.cas-group-single:first-of-type>.cas-group-sep{display:none}.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate{display:table}.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate .wpca-sep-or-not,.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate:before{display:none}.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate .wpca-sep-not{display:inline-block}.cas-group-sep.wpca-group-negate .wpca-sep-or{display:none}.cas-group-sep.wpca-group-negate .wpca-sep-or-not{display:inline-block}.cas-group-sep{display:table;margin:0 auto;color:#fff;text-transform:uppercase;font-size:.8em;font-weight:700;line-height:1;clear:both;direction:ltr}.cas-group-sep:after,.cas-group-sep:before{position:relative;display:block;content:'';width:2px;height:8px;margin:0 auto;background-color:#ccd0d4}.cas-group-sep .wpca-sep-not,.cas-group-sep .wpca-sep-or-not{display:none}.cas-group-sep span{background:#777;display:inline-block;padding:3px 5px 4px;border-radius:4px;vertical-align:middle}.cas-group-body .cas-group-sep{display:block;overflow:hidden;text-align:center;margin:5px -10px}.cas-group-body .cas-group-sep:after,.cas-group-body .cas-group-sep:before{background-color:transparent;border-top:1px solid #eee;content:"";display:inline-block;height:1px;position:relative;vertical-align:middle;width:50%}.cas-group-body .cas-group-sep:before{right:0;margin-left:-50%}.cas-group-body .cas-group-sep:after{left:0;margin-right:-50%}.cas-group-label{font-weight:700;margin:0 0 6px}.wpca-condition-remove{cursor:pointer;margin:0 8px 0 0;color:#aaa;transition:color .3s ease}.wpca-condition-remove:hover{color:#444}.cas-group-new{background-color:#fff}.cas-group-new>div:first-of-type{background-color:#f1f1f1;border-right:#ccd0d4 1px solid}.cas-group-new>div{padding:5px;display:inline-block;vertical-align:middle}.cas-group-new a{padding:0 10px}label.cae-toggle{vertical-align:top}label.cae-toggle input{display:none}label.cae-toggle .cae-toggle-bar{overflow:hidden;cursor:pointer;position:relative;padding-right:34px;height:22px;line-height:22px;display:inline-block;vertical-align:middle}label.cae-toggle .cae-toggle-bar:before{top:0;right:0;position:absolute;display:inline-block;width:34px;content:"";padding:0;height:inherit;line-height:inherit;border-radius:22px;background-color:#bbb;box-shadow:0 0 2px rgba(0,0,0,.2) inset;transition:background-color .2s ease-in}label.cae-toggle .cae-toggle-bar:after{content:"";display:block;width:18px;height:18px;margin:0;background:#FFF;position:absolute;top:2px;right:14px;border-radius:22px;transition:right .2s ease-in 0s;box-shadow:0 1px 2px rgba(0,0,0,.2)}label.cae-toggle input:checked+.cae-toggle-bar:before{background-color:#7ad03a}label.cae-toggle input:checked+.cae-toggle-bar:after{right:2px}@media (min-width:783px){#cas-groups .button-small .dashicons{font-size:14px;height:14px;width:14px}.cas-group-body .cas-group-options input[type=number],.cas-group-body .cas-group-options input[type=text],.cas-group-body .cas-group-options select{font-size:.9em;min-height:24px}}@media (min-width:1041px){.cas-group-label{float:left;width:220px;margin:5px 0 0}.wpca-group-description{float:left}.cas-group-input{margin-left:221px;white-space:nowrap;overflow:hidden}.cas-group-body .cas-group-options li{padding:8px 10%}.rtl .cas-group-label{float:right}.rtl .cas-group-input{margin-right:221px;margin-left:auto}}.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir=rtl] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:#fff;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0!important;clip:rect(0 0 0 0)!important;-webkit-clip-path:inset(50%)!important;clip-path:inset(50%)!important;height:1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;width:1px!important;white-space:nowrap!important}.select2-container--wpca.select2-container .select2-selection--single{background-color:#fff;border:1px solid #ddd;border-radius:0}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:700}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent;border-style:solid;border-width:5px 4px 0;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--single .select2-selection__clear{float:left}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--wpca.select2-container.select2-container--open .select2-selection--single{border:1px solid #5b9dd9}.select2-container--wpca.select2-container.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888;border-width:0 4px 5px}.select2-container--wpca.select2-container .select2-selection--multiple{background-color:#fff;color:#444;border:1px solid #ddd;border-radius:0;cursor:text;min-height:32px;line-height:1}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px 3px;width:100%}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:700;margin-top:5px;margin-right:10px}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__choice{background-color:#bfe7f1;color:#23282d;border:1px solid #439eb4;border-radius:2px;cursor:default;float:left;margin:4px 4px 0 0;padding:2px 6px 4px;max-width:100%;overflow:hidden;text-overflow:ellipsis;box-sizing:border-box;box-shadow:0 1px 0 0 rgba(255,255,255,.9) inset,0 1px 1px rgba(0,0,0,.1)}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__choice__remove{color:#439eb4;cursor:pointer;font-size:16px;display:inline-block;font-weight:700;margin-right:6px}.select2-container--wpca .select2-results__option[aria-selected=true],.select2-container--wpca.select2-container.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__choice__remove:hover{color:#444}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-search--inline,.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__choice,.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__placeholder{float:right}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__choice{margin:4px 0 0 4px}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--wpca.select2-container.select2-container--focus .select2-selection--multiple{border:1px solid #5b9dd9;background-color:#fafafa;outline:0}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--wpca.select2-container .select2-dropdown{overflow:hidden;border-color:#5b9dd9}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-1{padding-left:10px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-2{padding-left:20px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-3{padding-left:30px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-4{padding-left:40px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-5{padding-left:50px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-6{padding-left:60px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-7{padding-left:70px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-8{padding-left:80px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-9{padding-left:90px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-10{padding-left:100px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-1{padding-right:10px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-2{padding-right:20px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-3{padding-right:30px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-4{padding-right:40px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-5{padding-right:50px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-6{padding-right:60px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-7{padding-right:70px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-8{padding-right:80px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-9{padding-right:90px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-10{padding-right:100px}.select2-container--wpca.select2-container .select2-dropdown.select2-dropdown--below{box-shadow:0 2px 5px rgba(0,0,0,.15)}.select2-container--wpca.select2-container .select2-dropdown.select2-dropdown--above{box-shadow:0 -2px 5px rgba(0,0,0,.15)}.select2-container--wpca.select2-container--open.select2-container--above .select2-selection--multiple,.select2-container--wpca.select2-container--open.select2-container--above .select2-selection--single{border-top-left-radius:0;border-top-right-radius:0;border-top:1px solid #ddd}.select2-container--wpca.select2-container--open.select2-container--below .select2-selection--multiple,.select2-container--wpca.select2-container--open.select2-container--below .select2-selection--single{border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom:1px solid #ddd}.select2-container--wpca .select2-search--dropdown .select2-search__field{border:1px solid #5b9dd9;line-height:normal}.select2-container--wpca .select2-search--inline{width:auto;margin:0;z-index:1030}.select2-container--wpca .select2-search--inline .select2-search__field{font-family:inherit;padding:0;background:0 0!important;min-height:auto;border:none;outline:0;box-shadow:none!important;-webkit-appearance:textfield;margin-top:6px!important;line-height:normal}.select2-container--wpca .select2-search--inline .select2-search__field:not([placeholder='']){width:100%!important;margin-right:9999px}.select2-container--wpca[dir=rtl] .select2-search--inline .select2-search__field:not([placeholder='']){margin-left:9999px;margin-right:auto}.select2-container--wpca .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--wpca .select2-results__option[role=group]{padding:0}.select2-container--wpca .select2-results__option[aria-disabled=true]{color:#999}.select2-container--wpca .select2-results__option .select2-results__option{padding-left:20px;margin:0}.select2-container--wpca .select2-results__option--highlighted[aria-selected]{background-color:#f2f2f2}.select2-container--wpca .select2-results__group{cursor:default;display:block;padding:6px}
1
+ /*!
2
+ * @package WP Content Aware Engine
3
+ * @author Joachim Jensen <joachim@dev.institute>
4
+ * @license GPLv3
5
+ * @copyright 2020 by Joachim Jensen
6
  */.wpca-pull-left{float:left}.rtl .wpca-pull-left,.wpca-pull-right{float:right}.rtl .wpca-pull-right{float:left}.wpca-alert{position:fixed;top:0;font-weight:700;color:#fff;font-size:1.3em;width:100%}.wpca-alert .wpca-error,.wpca-alert .wpca-success{box-sizing:border-box;text-align:center;box-shadow:0 1px 4px rgba(0,0,0,.3),inset 0 0 0 3px rgba(0,0,0,.1);padding:18px 30px}.wpca-alert .wpca-success{background-color:#46b450}.wpca-alert .wpca-error{background-color:#ff7058}@media (min-width:601px){.wpca-alert{width:auto;top:auto;bottom:30px;right:30px}.wpca-error,.wpca-success{min-width:320px;position:relative;border-radius:40px}.rtl .wpca-alert{left:30px;right:auto}}#cas-groups{padding:6px 0 0}#cas-groups .button-small .dashicons{vertical-align:text-top}#cas-groups>ul{position:relative;margin:0;transition:all 1s ease;max-height:9999px;height:auto}.cas-group-body,.cas-group-new{box-sizing:border-box;border-width:1px;border-style:solid;border-color:#ccd0d4;background-color:#f1f1f1;overflow:hidden;position:relative;margin-bottom:0;border-radius:4px;box-shadow:0 1px 1px 1px rgba(0,0,0,.04)}.cas-group-body .cas-group-cell{padding:10px;background-color:#fff;border-top:1px solid #ccd0d4}.cas-group-body .cas-group-actions{padding:5px;overflow:hidden;vertical-align:middle;color:#888}.cas-group-body .cas-group-actions .dashicons{vertical-align:middle}.cas-group-body .cas-group-actions .spinner{float:none}.cas-group-body .cas-group-options{overflow:hidden;margin:0}.cas-group-body .cas-group-options li{overflow:hidden;margin:0;padding:8px 5px;border-top:#ddd 1px solid}.cas-group-actions .wpca-conditions-add+.select2-container.select2-container--wpca .select2-selection{height:26px;font-size:11px}.cas-group-actions .wpca-conditions-add+.select2-container.select2-container--wpca .select2-selection .select2-selection__arrow{height:26px}.cas-group-actions .wpca-conditions-add+.select2-container.select2-container--wpca .select2-selection .select2-selection__rendered{line-height:26px}.wpca-conditions-add+.select2-container.select2-container--wpca .select2-selection{background-color:#f3f5f6;border-color:#0071a1;padding:0 6px 1px;border-radius:3px;vertical-align:top}.wpca-conditions-add+.select2-container.select2-container--wpca .select2-selection:hover{border-color:#016087;background-color:#f1f1f1}.wpca-conditions-add+.select2-container.select2-container--wpca .select2-selection .select2-selection__placeholder{color:#0071a1}.cas-group-single{margin:0}.cas-condition:first-of-type>.cas-group-sep,.cas-group-single:first-of-type>.cas-group-sep{display:none}.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate{display:table}.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate .wpca-sep-or-not,.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate:before{display:none}.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate .wpca-sep-not{display:inline-block}.cas-group-sep.wpca-group-negate .wpca-sep-or{display:none}.cas-group-sep.wpca-group-negate .wpca-sep-or-not{display:inline-block}.cas-group-sep{display:table;margin:0 auto;color:#fff;text-transform:uppercase;font-size:.8em;font-weight:700;line-height:1;clear:both;direction:ltr}.cas-group-sep:after,.cas-group-sep:before{position:relative;display:block;content:'';width:2px;height:8px;margin:0 auto;background-color:#ccd0d4}.cas-group-sep .wpca-sep-not,.cas-group-sep .wpca-sep-or-not{display:none}.cas-group-sep span{background:#777;display:inline-block;padding:3px 5px 4px;border-radius:4px;vertical-align:middle}.cas-group-body .cas-group-sep{display:block;overflow:hidden;text-align:center;margin:5px -10px}.cas-group-body .cas-group-sep:after,.cas-group-body .cas-group-sep:before{background-color:transparent;border-top:1px solid #eee;content:"";display:inline-block;height:1px;position:relative;vertical-align:middle;width:50%}.cas-group-body .cas-group-sep:before{right:0;margin-left:-50%}.cas-group-body .cas-group-sep:after{left:0;margin-right:-50%}.cas-group-label{font-weight:700;margin:0 0 6px}.wpca-condition-remove{cursor:pointer;margin:0 8px 0 0;color:#aaa;transition:color .3s ease}.wpca-condition-remove:hover{color:#444}.cas-group-new{background-color:#fff}.cas-group-new>div:first-of-type{background-color:#f1f1f1;border-right:#ccd0d4 1px solid}.cas-group-new>div{padding:5px;display:inline-block;vertical-align:middle}.cas-group-new a{padding:0 10px}label.cae-toggle{vertical-align:top}label.cae-toggle input{display:none}label.cae-toggle .cae-toggle-bar{overflow:hidden;cursor:pointer;position:relative;padding-right:34px;height:22px;line-height:22px;display:inline-block;vertical-align:middle}label.cae-toggle .cae-toggle-bar:before{top:0;right:0;position:absolute;display:inline-block;width:34px;content:"";padding:0;height:inherit;line-height:inherit;border-radius:22px;background-color:#bbb;box-shadow:0 0 2px rgba(0,0,0,.2) inset;transition:background-color .2s ease-in}label.cae-toggle .cae-toggle-bar:after{content:"";display:block;width:18px;height:18px;margin:0;background:#FFF;position:absolute;top:2px;right:14px;border-radius:22px;transition:right .2s ease-in 0s;box-shadow:0 1px 2px rgba(0,0,0,.2)}label.cae-toggle input:checked+.cae-toggle-bar:before{background-color:#7ad03a}label.cae-toggle input:checked+.cae-toggle-bar:after{right:2px}@media (min-width:783px){#cas-groups .button-small .dashicons{font-size:14px;height:14px;width:14px}.cas-group-body .cas-group-options input[type=number],.cas-group-body .cas-group-options input[type=text],.cas-group-body .cas-group-options select{font-size:.9em;min-height:24px}}@media (min-width:1041px){.cas-group-label{float:left;width:220px;margin:5px 0 0}.wpca-group-description{float:left}.cas-group-input{margin-left:221px;white-space:nowrap;overflow:hidden}.cas-group-body .cas-group-options li{padding:8px 10%}.rtl .cas-group-label{float:right}.rtl .cas-group-input{margin-right:221px;margin-left:auto}}.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir=rtl] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:#fff;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0!important;clip:rect(0 0 0 0)!important;-webkit-clip-path:inset(50%)!important;clip-path:inset(50%)!important;height:1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;width:1px!important;white-space:nowrap!important}.select2-container--wpca.select2-container .select2-selection--single{background-color:#fff;border:1px solid #ddd;border-radius:0}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:700}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent;border-style:solid;border-width:5px 4px 0;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--single .select2-selection__clear{float:left}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--wpca.select2-container.select2-container--open .select2-selection--single{border:1px solid #5b9dd9}.select2-container--wpca.select2-container.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888;border-width:0 4px 5px}.select2-container--wpca.select2-container .select2-selection--multiple{background-color:#fff;color:#444;border:1px solid #ddd;border-radius:0;cursor:text;min-height:32px;line-height:1}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px 3px;width:100%}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:700;margin-top:5px;margin-right:10px}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__choice{background-color:#bfe7f1;color:#23282d;border:1px solid #439eb4;border-radius:2px;cursor:default;float:left;margin:4px 4px 0 0;padding:2px 6px 4px;max-width:100%;overflow:hidden;text-overflow:ellipsis;box-sizing:border-box;box-shadow:0 1px 0 0 rgba(255,255,255,.9) inset,0 1px 1px rgba(0,0,0,.1)}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__choice__remove{color:#439eb4;cursor:pointer;font-size:16px;display:inline-block;font-weight:700;margin-right:6px}.select2-container--wpca .select2-results__option[aria-selected=true],.select2-container--wpca.select2-container.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__choice__remove:hover{color:#444}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-search--inline,.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__choice,.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__placeholder{float:right}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__choice{margin:4px 0 0 4px}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--wpca.select2-container.select2-container--focus .select2-selection--multiple{border:1px solid #5b9dd9;background-color:#fafafa;outline:0}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--wpca.select2-container .select2-dropdown{overflow:hidden;border-color:#5b9dd9}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-1{padding-left:10px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-2{padding-left:20px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-3{padding-left:30px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-4{padding-left:40px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-5{padding-left:50px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-6{padding-left:60px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-7{padding-left:70px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-8{padding-left:80px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-9{padding-left:90px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-10{padding-left:100px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-1{padding-right:10px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-2{padding-right:20px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-3{padding-right:30px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-4{padding-right:40px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-5{padding-right:50px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-6{padding-right:60px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-7{padding-right:70px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-8{padding-right:80px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-9{padding-right:90px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-10{padding-right:100px}.select2-container--wpca.select2-container .select2-dropdown.select2-dropdown--below{box-shadow:0 2px 5px rgba(0,0,0,.15)}.select2-container--wpca.select2-container .select2-dropdown.select2-dropdown--above{box-shadow:0 -2px 5px rgba(0,0,0,.15)}.select2-container--wpca.select2-container--open.select2-container--above .select2-selection--multiple,.select2-container--wpca.select2-container--open.select2-container--above .select2-selection--single{border-top-left-radius:0;border-top-right-radius:0;border-top:1px solid #ddd}.select2-container--wpca.select2-container--open.select2-container--below .select2-selection--multiple,.select2-container--wpca.select2-container--open.select2-container--below .select2-selection--single{border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom:1px solid #ddd}.select2-container--wpca .select2-search--dropdown .select2-search__field{border:1px solid #5b9dd9;line-height:normal}.select2-container--wpca .select2-search--inline{width:auto;margin:0;z-index:1030}.select2-container--wpca .select2-search--inline .select2-search__field{font-family:inherit;padding:0;background:0 0!important;min-height:auto;border:none;outline:0;box-shadow:none!important;-webkit-appearance:textfield;margin-top:6px!important;line-height:normal}.select2-container--wpca .select2-search--inline .select2-search__field:not([placeholder='']){width:100%!important;margin-right:9999px}.select2-container--wpca[dir=rtl] .select2-search--inline .select2-search__field:not([placeholder='']){margin-left:9999px;margin-right:auto}.select2-container--wpca .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--wpca .select2-results__option[role=group]{padding:0}.select2-container--wpca .select2-results__option[aria-disabled=true]{color:#999}.select2-container--wpca .select2-results__option .select2-results__option{padding-left:20px;margin:0}.select2-container--wpca .select2-results__option--highlighted[aria-selected]{background-color:#f2f2f2}.select2-container--wpca .select2-results__group{cursor:default;display:block;padding:6px}
lib/wp-content-aware-engine/assets/js/condition_groups.min.js CHANGED
@@ -1,7 +1,7 @@
1
- /*!
2
- * @package WP Content Aware Engine
3
- * @author Joachim Jensen <joachim@dev.institute>
4
- * @license GPLv3
5
- * @copyright 2020 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="publish",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){if(CAE.Views[e.model.get("module")])var t=new(CAE.Views[e.model.get("module")])(e);else t=new CAE.Views.Condition(e);return t},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":"publish";this.setBinding("status",t)}}},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",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",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/data/wpcaAdapter",["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,action:"wpca/module/"+o.type,sidebar_id:l.sidebarID,nonce:l.nonce},dataType:"JSON",type:"POST",success:function(e){var t=!(e.length<20);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});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/data/wpcaAdapter"),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})})}};$(document).ready(function(){l.init()})}(jQuery,CAE);
1
+ /*!
2
+ * @package WP Content Aware Engine
3
+ * @author Joachim Jensen <joachim@dev.institute>
4
+ * @license GPLv3
5
+ * @copyright 2020 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="publish",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){if(CAE.Views[e.model.get("module")])var t=new(CAE.Views[e.model.get("module")])(e);else t=new CAE.Views.Condition(e);return t},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":"publish";this.setBinding("status",t)}}},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",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",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/data/wpcaAdapter",["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,action:"wpca/module/"+o.type,sidebar_id:l.sidebarID,nonce:l.nonce},dataType:"JSON",type:"POST",success:function(e){var t=!(e.length<20);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});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/data/wpcaAdapter"),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})})}};$(document).ready(function(){l.init()})}(jQuery,CAE);
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: custom sidebars, sidebar, hide sidebar, display widgets, widget, bbpress,
5
  Requires at least: 4.8
6
  Requires PHP: 5.6
7
  Tested up to: 5.4
8
- Stable tag: 3.12
9
  License: GPLv3
10
 
11
  Display new sidebars and widget areas on any post, page, category etc. Works with all themes, no code required.
@@ -173,6 +173,21 @@ Of course! Check out the links below:
173
 
174
  ####Highlights
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  = 3.12 =
177
 
178
  * [new] translatepress display condition
5
  Requires at least: 4.8
6
  Requires PHP: 5.6
7
  Tested up to: 5.4
8
+ Stable tag: 3.12.2
9
  License: GPLv3
10
 
11
  Display new sidebars and widget areas on any post, page, category etc. Works with all themes, no code required.
173
 
174
  ####Highlights
175
 
176
+ = 3.12.2 =
177
+
178
+ * [fixed] sidebars inserted with shortcode can now be replaced/merged
179
+
180
+ **Pro Plan:**
181
+
182
+ * [fixed] acf condition now works with relational fields
183
+ * [fixed] ensure sticky js is only loaded once
184
+
185
+ = 3.12.1 =
186
+
187
+ **Pro Plan:**
188
+
189
+ * [fixed] acf condition loaded improperly without acf installed
190
+
191
  = 3.12 =
192
 
193
  * [new] translatepress display condition
sidebar.php CHANGED
@@ -223,8 +223,8 @@ final class CAS_Sidebar_Manager
223
  $pro_label = ' (Pro)';
224
  $actions = $this->metadata->get('handle');
225
  $action_list = $actions->get_input_list();
226
- $action_list['__infuse'] = __('Infuse', 'content-aware-sidebars').$pro;
227
- $action_list['__after_paragraph'] = __('After Paragraph', 'content-aware-sidebars').$pro;
228
  $actions->set_input_list($action_list);
229
  }
230
 
@@ -240,8 +240,6 @@ final class CAS_Sidebar_Manager
240
  */
241
  public function init_sidebar_type()
242
  {
243
-
244
- // Register the sidebar type
245
  register_post_type(CAS_App::TYPE_SIDEBAR, array(
246
  'labels' => array(
247
  'name' => __('Sidebars', 'content-aware-sidebars'),
@@ -504,9 +502,15 @@ final class CAS_Sidebar_Manager
504
 
505
  $id = CAS_App::SIDEBAR_PREFIX.esc_attr($a['id']);
506
 
507
- //if sidebar is in replacement map, shortcode is called wrongly
508
- //todo: check for handle instead?
509
- if (isset($this->sidebars[$id]) && $this->sidebars[$id]->post_status == CAS_App::STATUS_ACTIVE && !isset($this->replace_map[$id]) && is_active_sidebar($id) && apply_filters('cas/shortcode/display', true, $a['id'])) {
 
 
 
 
 
 
510
  ob_start();
511
  do_action('cas/shortcode/before', $a['id']);
512
  dynamic_sidebar($id);
223
  $pro_label = ' (Pro)';
224
  $actions = $this->metadata->get('handle');
225
  $action_list = $actions->get_input_list();
226
+ $action_list['__infuse'] = __('Infuse', 'content-aware-sidebars').$pro_label;
227
+ $action_list['__after_paragraph'] = __('After Paragraph', 'content-aware-sidebars').$pro_label;
228
  $actions->set_input_list($action_list);
229
  }
230
 
240
  */
241
  public function init_sidebar_type()
242
  {
 
 
243
  register_post_type(CAS_App::TYPE_SIDEBAR, array(
244
  'labels' => array(
245
  'name' => __('Sidebars', 'content-aware-sidebars'),
502
 
503
  $id = CAS_App::SIDEBAR_PREFIX.esc_attr($a['id']);
504
 
505
+ if (!isset($this->sidebars[$id]) || $this->sidebars[$id]->post_status != CAS_App::STATUS_ACTIVE) {
506
+ return $content;
507
+ }
508
+
509
+ if ($this->metadata()->get('handle')->get_data($a['id']) != 2) {
510
+ return $content;
511
+ }
512
+
513
+ if (is_active_sidebar($id) && apply_filters('cas/shortcode/display', true, $a['id'])) {
514
  ob_start();
515
  do_action('cas/shortcode/before', $a['id']);
516
  dynamic_sidebar($id);