Version Description
Released: Jul, 18 - 2019 =
Update: internal plugin framework
Tweak: improved performance on wishlist page, when user is a guest and store has huge catalog (thanks to Dave)
Dev: add filter yith_wcwl_wishlist_correctly_created on add_wishlist function
Download this release
Release Info
Developer | yithemes |
Plugin | YITH WooCommerce Wishlist |
Version | 2.2.12 |
Comparing to | |
See all releases |
Code changes from version 2.2.11 to 2.2.12
- README.txt +11 -3
- includes/class.yith-wcwl.php +22 -9
- init.php +1 -1
- plugin-fw/assets/css/admin.css +112 -33
- plugin-fw/assets/css/yith-fields.css +66 -33
- plugin-fw/assets/js/yit-plugin-panel.js +2 -3
- plugin-fw/assets/js/yit-plugin-panel.min.js +2 -2
- plugin-fw/assets/js/yith-fields.js +443 -419
- plugin-fw/assets/js/yith-fields.min.js +27 -1
- plugin-fw/assets/js/yith-system-info.js +13 -0
- plugin-fw/assets/js/yith-system-info.min.js +13 -0
- plugin-fw/init.php +2 -2
- plugin-fw/lib/yit-assets.php +8 -9
- plugin-fw/lib/yit-plugin-panel-wc.php +81 -114
- plugin-fw/lib/yith-system-status.php +383 -0
- plugin-fw/templates/fields/colorpicker.php +1 -0
- plugin-fw/templates/fields/list-table.php +5 -2
- plugin-fw/templates/fields/radio.php +1 -1
- plugin-fw/templates/sysinfo/system-information-panel.php +135 -0
- plugin-fw/yit-functions.php +11 -0
- plugin-fw/yit-plugin.php +2 -0
README.txt
CHANGED
@@ -4,7 +4,7 @@ Contributors: yithemes
|
|
4 |
Tags: wishlist, woocommerce, products, yit, e-commerce, shop, ecommerce wishlist, yith, woocommerce wishlist, shop wishlist
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 5.2
|
7 |
-
Stable tag: 2.2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -109,6 +109,12 @@ you should ask theme developers to update custom templates and replace the old t
|
|
109 |
|
110 |
== Changelog ==
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
= 2.2.11 - Released: Jun, 13 - 2019 =
|
113 |
|
114 |
* Update: internal plugin framework
|
@@ -532,6 +538,8 @@ Full documentation is available [here](http://yithemes.com/docs-plugins/yith-woo
|
|
532 |
|
533 |
== Upgrade notice ==
|
534 |
|
535 |
-
= 2.2.
|
536 |
|
537 |
-
* Update: internal plugin framework
|
|
|
|
4 |
Tags: wishlist, woocommerce, products, yit, e-commerce, shop, ecommerce wishlist, yith, woocommerce wishlist, shop wishlist
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 5.2
|
7 |
+
Stable tag: 2.2.12
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
109 |
|
110 |
== Changelog ==
|
111 |
|
112 |
+
= 2.2.12 - Released: Jul, 18 - 2019 =
|
113 |
+
|
114 |
+
* Update: internal plugin framework
|
115 |
+
* Tweak: improved performance on wishlist page, when user is a guest and store has huge catalog (thanks to Dave)
|
116 |
+
* Dev: add filter yith_wcwl_wishlist_correctly_created on add_wishlist function
|
117 |
+
|
118 |
= 2.2.11 - Released: Jun, 13 - 2019 =
|
119 |
|
120 |
* Update: internal plugin framework
|
538 |
|
539 |
== Upgrade notice ==
|
540 |
|
541 |
+
= 2.2.12 - Released: Jul, 18 - 2019 =
|
542 |
|
543 |
+
* Update: internal plugin framework
|
544 |
+
* Tweak: improved performance on wishlist page, when user is a guest and store has huge catalog (thanks to Dave)
|
545 |
+
* Dev: add filter yith_wcwl_wishlist_correctly_created on add_wishlist function
|
includes/class.yith-wcwl.php
CHANGED
@@ -566,29 +566,42 @@ if ( ! class_exists( 'YITH_WCWL' ) ) {
|
|
566 |
else{
|
567 |
$wishlist = yith_getcookie( 'yith_wcwl_products' );
|
568 |
$hidden_products = yith_wcwl_get_hidden_products();
|
|
|
569 |
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
|
574 |
-
$
|
575 |
-
'
|
576 |
-
'
|
577 |
-
|
|
|
|
|
578 |
|
579 |
-
|
|
|
|
|
580 |
|
581 |
foreach( $wishlist as $key => $cookie ){
|
582 |
-
|
|
|
|
|
|
|
|
|
|
|
583 |
unset( $wishlist[ $key ] );
|
|
|
584 |
}
|
585 |
|
586 |
if( ! empty( $product_id ) && $cookie['prod_id'] != $product_id ){
|
587 |
unset( $wishlist[ $key ] );
|
|
|
588 |
}
|
589 |
|
590 |
if( ( ! empty( $wishlist_id ) && $wishlist_id != 'all' ) && $cookie['wishlist_id'] != $wishlist_id ){
|
591 |
unset( $wishlist[ $key ] );
|
|
|
592 |
}
|
593 |
}
|
594 |
|
566 |
else{
|
567 |
$wishlist = yith_getcookie( 'yith_wcwl_products' );
|
568 |
$hidden_products = yith_wcwl_get_hidden_products();
|
569 |
+
$items = is_array( $wishlist ) ? wp_list_pluck( $wishlist, 'prod_id' ) : false;
|
570 |
|
571 |
+
if( empty( $items ) ){
|
572 |
+
return array();
|
573 |
+
}
|
574 |
|
575 |
+
$valid_products = wc_get_products( array(
|
576 |
+
'status' => 'publish',
|
577 |
+
'include' => $items,
|
578 |
+
'limit' => -1,
|
579 |
+
'return' => 'ids'
|
580 |
+
) );
|
581 |
|
582 |
+
if( empty( $valid_products ) ){
|
583 |
+
return array();
|
584 |
+
}
|
585 |
|
586 |
foreach( $wishlist as $key => $cookie ){
|
587 |
+
if( in_array( $cookie['prod_id'], $hidden_products ) ){
|
588 |
+
unset( $wishlist[ $key ] );
|
589 |
+
continue;
|
590 |
+
}
|
591 |
+
|
592 |
+
if( ! in_array( $cookie['prod_id'], $valid_products ) ){
|
593 |
unset( $wishlist[ $key ] );
|
594 |
+
continue;
|
595 |
}
|
596 |
|
597 |
if( ! empty( $product_id ) && $cookie['prod_id'] != $product_id ){
|
598 |
unset( $wishlist[ $key ] );
|
599 |
+
continue;
|
600 |
}
|
601 |
|
602 |
if( ( ! empty( $wishlist_id ) && $wishlist_id != 'all' ) && $cookie['wishlist_id'] != $wishlist_id ){
|
603 |
unset( $wishlist[ $key ] );
|
604 |
+
continue;
|
605 |
}
|
606 |
}
|
607 |
|
init.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: YITH WooCommerce Wishlist
|
4 |
* Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-wishlist/
|
5 |
* Description: <code><strong>YITH WooCommerce Wishlist</strong></code> gives your users the possibility to create, fill, manage and share their wishlists allowing you to analyze their interests and needs to improve your marketing strategies. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce on <strong>YITH</strong></a>
|
6 |
-
* Version: 2.2.
|
7 |
* Author: YITH
|
8 |
* Author URI: https://yithemes.com/
|
9 |
* Text Domain: yith-woocommerce-wishlist
|
3 |
* Plugin Name: YITH WooCommerce Wishlist
|
4 |
* Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-wishlist/
|
5 |
* Description: <code><strong>YITH WooCommerce Wishlist</strong></code> gives your users the possibility to create, fill, manage and share their wishlists allowing you to analyze their interests and needs to improve your marketing strategies. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce on <strong>YITH</strong></a>
|
6 |
+
* Version: 2.2.12
|
7 |
* Author: YITH
|
8 |
* Author URI: https://yithemes.com/
|
9 |
* Text Domain: yith-woocommerce-wishlist
|
plugin-fw/assets/css/admin.css
CHANGED
@@ -3,51 +3,51 @@
|
|
3 |
------------------------*/
|
4 |
#wpadminbar .yith-debug-admin-bar div,
|
5 |
#wpadminbar .yith-debug-admin-bar:hover div {
|
6 |
-
background
|
7 |
-
color
|
8 |
}
|
9 |
|
10 |
#wpadminbar .yith-debug-admin-bar a,
|
11 |
#wpadminbar .yith-debug-admin-bar strong {
|
12 |
-
color
|
13 |
}
|
14 |
|
15 |
#wpadminbar .yith-debug-admin-bar strong {
|
16 |
-
font-weight
|
17 |
}
|
18 |
|
19 |
#wpadminbar .yith-debug-admin-bar-post-meta .ab-empty-item,
|
20 |
#wpadminbar .yith-debug-admin-bar-option .ab-empty-item {
|
21 |
-
display
|
22 |
}
|
23 |
|
24 |
#wpadminbar #wp-admin-bar-yith-debug-admin-bar-post-meta-default,
|
25 |
#wpadminbar #wp-admin-bar-yith-debug-admin-bar-option-default {
|
26 |
-
padding
|
27 |
-
max-height
|
28 |
-
overflow-y
|
29 |
}
|
30 |
|
31 |
#wpadminbar .yith-debug-admin-bar pre {
|
32 |
-
padding
|
33 |
-
line-height
|
34 |
}
|
35 |
|
36 |
-
.notice-yith{
|
37 |
margin-left: 0;
|
38 |
border-left-color: #acc327;
|
39 |
}
|
40 |
|
41 |
-
.notice-yith.notice-alt{
|
42 |
background-color: #ecf7ed;
|
43 |
}
|
44 |
|
45 |
-
.yith-promo-banner-image-link{
|
46 |
display: block;
|
47 |
margin-bottom: 15px;
|
48 |
}
|
49 |
|
50 |
-
.yith-promo-banner-image{
|
51 |
max-width: 100%;
|
52 |
margin: 0 auto;
|
53 |
display: block;
|
@@ -57,7 +57,7 @@
|
|
57 |
YITH FEEDS
|
58 |
------------------------*/
|
59 |
|
60 |
-
.yith-feeds-logo{
|
61 |
display: table-cell;
|
62 |
background: #005b7c;
|
63 |
padding: 5px;
|
@@ -69,7 +69,7 @@
|
|
69 |
vertical-align: middle;
|
70 |
}
|
71 |
|
72 |
-
.yith-feeds-plugin-name{
|
73 |
display: table-cell;
|
74 |
vertical-align: middle;
|
75 |
}
|
@@ -77,41 +77,120 @@
|
|
77 |
/*-----------------------
|
78 |
YITH Plugins Columns
|
79 |
------------------------*/
|
80 |
-
@media screen and (min-width
|
81 |
|
82 |
.auto-fold #adminmenu .yith-plugin-fw-menu-2-columns.wp-not-current-submenu .wp-submenu-head {
|
83 |
-
width
|
84 |
}
|
85 |
|
86 |
#adminmenu .yith-plugin-fw-menu-2-columns.wp-not-current-submenu .wp-submenu {
|
87 |
-
min-width
|
88 |
-
display
|
89 |
-
flex-flow
|
90 |
}
|
91 |
|
92 |
#adminmenu .yith-plugin-fw-menu-2-columns.wp-not-current-submenu .wp-submenu li:not(.wp-submenu-head) {
|
93 |
-
width
|
94 |
-
border-left
|
95 |
-
box-sizing
|
96 |
}
|
97 |
|
98 |
#adminmenu .yith-plugin-fw-menu-2-columns.wp-not-current-submenu .wp-submenu li:not(.wp-submenu-head):nth-child(2n) {
|
99 |
-
border-left
|
100 |
}
|
101 |
|
102 |
#adminmenu .yith-plugin-fw-menu-3-columns.wp-not-current-submenu .wp-submenu {
|
103 |
-
min-width
|
104 |
-
display
|
105 |
-
flex-flow
|
106 |
}
|
107 |
|
108 |
#adminmenu .yith-plugin-fw-menu-3-columns.wp-not-current-submenu .wp-submenu li:not(.wp-submenu-head) {
|
109 |
-
width
|
110 |
-
border-left
|
111 |
-
box-sizing
|
112 |
}
|
113 |
|
114 |
#adminmenu .yith-plugin-fw-menu-3-columns.wp-not-current-submenu .wp-submenu li:not(.wp-submenu-head):nth-child(3n + 2) {
|
115 |
-
border-left
|
116 |
}
|
117 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
------------------------*/
|
4 |
#wpadminbar .yith-debug-admin-bar div,
|
5 |
#wpadminbar .yith-debug-admin-bar:hover div {
|
6 |
+
background: #05789c !important;
|
7 |
+
color: #fff !important;
|
8 |
}
|
9 |
|
10 |
#wpadminbar .yith-debug-admin-bar a,
|
11 |
#wpadminbar .yith-debug-admin-bar strong {
|
12 |
+
color: #fff !important;
|
13 |
}
|
14 |
|
15 |
#wpadminbar .yith-debug-admin-bar strong {
|
16 |
+
font-weight: 600;
|
17 |
}
|
18 |
|
19 |
#wpadminbar .yith-debug-admin-bar-post-meta .ab-empty-item,
|
20 |
#wpadminbar .yith-debug-admin-bar-option .ab-empty-item {
|
21 |
+
display: none;
|
22 |
}
|
23 |
|
24 |
#wpadminbar #wp-admin-bar-yith-debug-admin-bar-post-meta-default,
|
25 |
#wpadminbar #wp-admin-bar-yith-debug-admin-bar-option-default {
|
26 |
+
padding: 0;
|
27 |
+
max-height: 500px;
|
28 |
+
overflow-y: auto;
|
29 |
}
|
30 |
|
31 |
#wpadminbar .yith-debug-admin-bar pre {
|
32 |
+
padding: 10px;
|
33 |
+
line-height: 1.5em;
|
34 |
}
|
35 |
|
36 |
+
.notice-yith {
|
37 |
margin-left: 0;
|
38 |
border-left-color: #acc327;
|
39 |
}
|
40 |
|
41 |
+
.notice-yith.notice-alt {
|
42 |
background-color: #ecf7ed;
|
43 |
}
|
44 |
|
45 |
+
.yith-promo-banner-image-link {
|
46 |
display: block;
|
47 |
margin-bottom: 15px;
|
48 |
}
|
49 |
|
50 |
+
.yith-promo-banner-image {
|
51 |
max-width: 100%;
|
52 |
margin: 0 auto;
|
53 |
display: block;
|
57 |
YITH FEEDS
|
58 |
------------------------*/
|
59 |
|
60 |
+
.yith-feeds-logo {
|
61 |
display: table-cell;
|
62 |
background: #005b7c;
|
63 |
padding: 5px;
|
69 |
vertical-align: middle;
|
70 |
}
|
71 |
|
72 |
+
.yith-feeds-plugin-name {
|
73 |
display: table-cell;
|
74 |
vertical-align: middle;
|
75 |
}
|
77 |
/*-----------------------
|
78 |
YITH Plugins Columns
|
79 |
------------------------*/
|
80 |
+
@media screen and (min-width: 783px) {
|
81 |
|
82 |
.auto-fold #adminmenu .yith-plugin-fw-menu-2-columns.wp-not-current-submenu .wp-submenu-head {
|
83 |
+
width: 100%;
|
84 |
}
|
85 |
|
86 |
#adminmenu .yith-plugin-fw-menu-2-columns.wp-not-current-submenu .wp-submenu {
|
87 |
+
min-width: 320px;
|
88 |
+
display: flex;
|
89 |
+
flex-flow: row wrap;
|
90 |
}
|
91 |
|
92 |
#adminmenu .yith-plugin-fw-menu-2-columns.wp-not-current-submenu .wp-submenu li:not(.wp-submenu-head) {
|
93 |
+
width: 50%;
|
94 |
+
border-left: 1px solid #555;
|
95 |
+
box-sizing: border-box;
|
96 |
}
|
97 |
|
98 |
#adminmenu .yith-plugin-fw-menu-2-columns.wp-not-current-submenu .wp-submenu li:not(.wp-submenu-head):nth-child(2n) {
|
99 |
+
border-left: none;
|
100 |
}
|
101 |
|
102 |
#adminmenu .yith-plugin-fw-menu-3-columns.wp-not-current-submenu .wp-submenu {
|
103 |
+
min-width: 480px;
|
104 |
+
display: flex;
|
105 |
+
flex-flow: row wrap;
|
106 |
}
|
107 |
|
108 |
#adminmenu .yith-plugin-fw-menu-3-columns.wp-not-current-submenu .wp-submenu li:not(.wp-submenu-head) {
|
109 |
+
width: calc(100% / 3);
|
110 |
+
border-left: 1px solid #555;
|
111 |
+
box-sizing: border-box;
|
112 |
}
|
113 |
|
114 |
#adminmenu .yith-plugin-fw-menu-3-columns.wp-not-current-submenu .wp-submenu li:not(.wp-submenu-head):nth-child(3n + 2) {
|
115 |
+
border-left: none;
|
116 |
}
|
117 |
+
}
|
118 |
+
|
119 |
+
/*---------------------------
|
120 |
+
YITH System Information
|
121 |
+
----------------------------*/
|
122 |
+
.yith-phpinfo img {
|
123 |
+
float: right;
|
124 |
+
border: 0;
|
125 |
+
}
|
126 |
+
|
127 |
+
#yith-system-alert span.yith-logo,
|
128 |
+
.yith-system-info h1 span.yith-logo {
|
129 |
+
border-radius: 50%;
|
130 |
+
background: #265b7a;
|
131 |
+
height: 30px;
|
132 |
+
width: 30px;
|
133 |
+
display: flex;
|
134 |
+
text-align: center;
|
135 |
+
margin: 0 10px 0 0;
|
136 |
+
float: left;
|
137 |
+
align-items: center;
|
138 |
+
justify-content: center;
|
139 |
+
}
|
140 |
+
|
141 |
+
.yith-system-info table {
|
142 |
+
margin: 20px 0;
|
143 |
+
}
|
144 |
+
|
145 |
+
.yith-system-info table th {
|
146 |
+
font-weight: bold;
|
147 |
+
width: 25%;
|
148 |
+
padding: 20px 12px;
|
149 |
+
}
|
150 |
+
|
151 |
+
.yith-system-info table td {
|
152 |
+
word-break: break-all;
|
153 |
+
padding: 20px 12px;
|
154 |
+
}
|
155 |
+
|
156 |
+
.yith-system-info table td.requirement-value {
|
157 |
+
font-size: 14px;
|
158 |
+
vertical-align: middle;
|
159 |
+
text-align: left;
|
160 |
+
color: #5da726;
|
161 |
+
line-height: 19px;
|
162 |
+
width: 90px;
|
163 |
+
}
|
164 |
+
|
165 |
+
.yith-system-info table td.requirement-value.has-errors {
|
166 |
+
color: #a00;
|
167 |
+
}
|
168 |
+
|
169 |
+
.yith-system-info table td.requirement-value.has-warnings {
|
170 |
+
color: #ffa200;
|
171 |
+
}
|
172 |
+
|
173 |
+
.yith-system-info table td.requirement-messages ul {
|
174 |
+
margin: 0;
|
175 |
+
padding: 0 0 10px 0;
|
176 |
+
list-style: none!important;
|
177 |
+
}
|
178 |
+
|
179 |
+
.yith-system-info table td.requirement-messages ul li {
|
180 |
+
margin-bottom: 3px;
|
181 |
+
}
|
182 |
+
|
183 |
+
.yith-system-info table td.requirement-messages ul li span.error {
|
184 |
+
color: #a00;
|
185 |
+
font-weight: bold;
|
186 |
+
}
|
187 |
+
|
188 |
+
.yith-system-info table td.requirement-messages ul li span.warning {
|
189 |
+
color: #a00;
|
190 |
+
font-weight: bold;
|
191 |
+
}
|
192 |
+
|
193 |
+
.yith-system-info-menu {
|
194 |
+
font-weight: bold;
|
195 |
+
font-size: 11px !important;
|
196 |
+
}
|
plugin-fw/assets/css/yith-fields.css
CHANGED
@@ -205,8 +205,8 @@ ul.yit-icons-manager-list li.active {
|
|
205 |
text-indent: -9999px;
|
206 |
display: block;
|
207 |
width: 36px;
|
208 |
-
height: 20px;
|
209 |
line-height: 1;
|
|
|
210 |
background: #a4a4a4;
|
211 |
border-radius: 24px;
|
212 |
position: relative;
|
@@ -570,7 +570,7 @@ YITH UI
|
|
570 |
margin-right: 2px;
|
571 |
background-color: #336374;
|
572 |
color: #fff;
|
573 |
-
font-size:
|
574 |
padding: 7px 20px;
|
575 |
border: 0;
|
576 |
}
|
@@ -598,14 +598,24 @@ YITH UI
|
|
598 |
padding: 15px 20px;
|
599 |
}
|
600 |
|
601 |
-
.yith-plugin-ui label{
|
602 |
color: #33373b;
|
603 |
-
font-size:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
604 |
}
|
605 |
|
606 |
.yith-plugin-ui span.description{
|
607 |
color: #716269;
|
608 |
-
font-size:
|
609 |
font-style: normal;
|
610 |
font-weight: 400;
|
611 |
margin-top: 15px;
|
@@ -635,7 +645,7 @@ YITH UI
|
|
635 |
|
636 |
.yith-plugin-ui h2 {
|
637 |
color: #2a8db0;
|
638 |
-
font-size:
|
639 |
text-transform: uppercase;
|
640 |
border: 1px solid #d8d8d8;
|
641 |
border-bottom: 0;
|
@@ -663,7 +673,7 @@ YITH UI
|
|
663 |
|
664 |
.yith-plugin-ui #plugin-fw-wc h2 + div p, .yith-plugin-ui p.info-box{
|
665 |
background: #f1f1f1;
|
666 |
-
font-size:
|
667 |
font-weight: 700;
|
668 |
width: 40%;
|
669 |
display:block;
|
@@ -749,7 +759,7 @@ YITH UI
|
|
749 |
.woocommerce .yith-plugin-ui table.form-table select,
|
750 |
.yith-plugin-ui select{
|
751 |
-webkit-appearance: none;
|
752 |
-
line-height: 1;
|
753 |
min-height: 35px;
|
754 |
background: url("../images/arrow_down.svg") no-repeat right center;
|
755 |
background-size: 35px 13px;
|
@@ -982,7 +992,7 @@ YITH UI
|
|
982 |
border-radius: 12px;
|
983 |
padding: 3px 11px;
|
984 |
border-color: #33937e;
|
985 |
-
font-size:
|
986 |
}
|
987 |
|
988 |
.yith-plugin-ui .select2-container--default .select2-selection--single .select2-selection__arrow:before{
|
@@ -1115,7 +1125,7 @@ YITH UI
|
|
1115 |
line-height: 20px;
|
1116 |
display: inline-block;
|
1117 |
color: #716269;
|
1118 |
-
font-size:
|
1119 |
}
|
1120 |
.yith-plugin-ui [type="radio"]:checked + label:before,
|
1121 |
.yith-plugin-ui [type="radio"]:not(:checked) + label:before {
|
@@ -1123,8 +1133,8 @@ YITH UI
|
|
1123 |
position: absolute;
|
1124 |
left: 0;
|
1125 |
top: 0;
|
1126 |
-
width:
|
1127 |
-
height:
|
1128 |
border: 1px solid #d8d8d8;
|
1129 |
border-radius: 100%;
|
1130 |
background: #fff;
|
@@ -1132,8 +1142,8 @@ YITH UI
|
|
1132 |
.yith-plugin-ui [type="radio"]:checked + label:after,
|
1133 |
.yith-plugin-ui [type="radio"]:not(:checked) + label:after {
|
1134 |
content: '';
|
1135 |
-
width:
|
1136 |
-
height:
|
1137 |
background: #4e8ba2;
|
1138 |
position: absolute;
|
1139 |
top: 4px;
|
@@ -1194,7 +1204,8 @@ YITH UI
|
|
1194 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input + span{
|
1195 |
border: 1px solid #d8d8d8;
|
1196 |
background-color: #fff;
|
1197 |
-
width:
|
|
|
1198 |
}
|
1199 |
|
1200 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input + span:before{
|
@@ -1204,16 +1215,17 @@ YITH UI
|
|
1204 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input + span:before {
|
1205 |
width: 14px;
|
1206 |
height: 14px;
|
1207 |
-
top:
|
1208 |
-
left:
|
1209 |
background-color: #d8d8d8;
|
1210 |
}
|
1211 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input + span:after{
|
1212 |
content: 'OFF';
|
1213 |
width: 14px;
|
1214 |
height: 14px;
|
1215 |
-
font-size:
|
1216 |
-
|
|
|
1217 |
color: #979797;
|
1218 |
margin-top: 5px;
|
1219 |
display: inline-block;
|
@@ -1228,7 +1240,7 @@ YITH UI
|
|
1228 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input:checked + span:before,
|
1229 |
.yith-plugin-ui.yith-plugin-fw-onoff-container input.onoffchecked + span:before{
|
1230 |
background-color: #98aa36;
|
1231 |
-
left:
|
1232 |
}
|
1233 |
|
1234 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input:checked + span:after,
|
@@ -1238,10 +1250,10 @@ YITH UI
|
|
1238 |
width: 14px;
|
1239 |
height: 14px;
|
1240 |
display: inline-block;
|
1241 |
-
font-size:
|
|
|
1242 |
padding: 0 10px;
|
1243 |
margin-top: 5px;
|
1244 |
-
|
1245 |
}
|
1246 |
|
1247 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input + span{
|
@@ -1381,15 +1393,15 @@ DATEPICKER
|
|
1381 |
}
|
1382 |
|
1383 |
/** colorpicker **/
|
1384 |
-
.yith-plugin-ui .yith-plugin-fw-
|
1385 |
-
.yith-plugin-ui .yith-plugin-fw-
|
1386 |
display: none !important;
|
1387 |
}
|
1388 |
-
.yith-plugin-ui .yith-plugin-fw-
|
1389 |
display: inline !important;
|
1390 |
}
|
1391 |
-
.yith-plugin-ui .yith-plugin-fw-
|
1392 |
-
.yith-plugin-ui .yith-plugin-fw-
|
1393 |
display: block !important;
|
1394 |
}
|
1395 |
.woocommerce .yith-plugin-ui .iris-picker{
|
@@ -1547,6 +1559,9 @@ DATEPICKER
|
|
1547 |
box-sizing: border-box;
|
1548 |
background: white;
|
1549 |
}
|
|
|
|
|
|
|
1550 |
.yith-plugin-ui .yith-add-box{
|
1551 |
padding: 30px 25px;
|
1552 |
display: none;
|
@@ -1558,6 +1573,7 @@ DATEPICKER
|
|
1558 |
.yith-plugin-ui .yith-toggle-title h3{
|
1559 |
padding: 0px 20px 0px 25px;
|
1560 |
margin: 0;
|
|
|
1561 |
display: inline-block;
|
1562 |
position: relative;
|
1563 |
min-width: 173px;
|
@@ -1579,7 +1595,7 @@ DATEPICKER
|
|
1579 |
display: block;
|
1580 |
cursor: pointer;
|
1581 |
left: 0px;
|
1582 |
-
top:
|
1583 |
bottom: 0;
|
1584 |
}
|
1585 |
.yith-plugin-ui .yith-toggle > span:before{
|
@@ -1617,7 +1633,7 @@ DATEPICKER
|
|
1617 |
width: 250px;
|
1618 |
padding-right:40px;
|
1619 |
color: #33373b;
|
1620 |
-
font-size:
|
1621 |
vertical-align: top;
|
1622 |
font-weight: 600;
|
1623 |
}
|
@@ -1737,12 +1753,20 @@ DATEPICKER
|
|
1737 |
float: left;
|
1738 |
}
|
1739 |
|
|
|
|
|
|
|
|
|
1740 |
.yith-plugin-ui td.forminp-checkbox.three-cols fieldset {
|
1741 |
-
width: calc(33% -
|
1742 |
-
padding-right:
|
1743 |
float: left;
|
1744 |
}
|
1745 |
|
|
|
|
|
|
|
|
|
1746 |
|
1747 |
.yith-plugin-fw-checkbox-field-wrapper {
|
1748 |
display: inline-block !important;
|
@@ -1792,10 +1816,18 @@ DATEPICKER
|
|
1792 |
}
|
1793 |
|
1794 |
.yith-plugin-ui td.forminp-checkbox.three-cols fieldset {
|
1795 |
-
width: calc(50% -
|
1796 |
-
padding-right:
|
1797 |
float: left;
|
1798 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1799 |
}
|
1800 |
@media screen and (max-width: 782px){
|
1801 |
.yith-plugin-fw-banner.yith-plugin-fw-banner-free{
|
@@ -1822,6 +1854,7 @@ DATEPICKER
|
|
1822 |
.yith-plugin-ui td.forminp-checkbox.two-cols fieldset,
|
1823 |
.yith-plugin-ui td.forminp-checkbox.three-cols fieldset{
|
1824 |
width: 100%;
|
|
|
1825 |
}
|
1826 |
|
1827 |
}
|
205 |
text-indent: -9999px;
|
206 |
display: block;
|
207 |
width: 36px;
|
|
|
208 |
line-height: 1;
|
209 |
+
height: 20px;
|
210 |
background: #a4a4a4;
|
211 |
border-radius: 24px;
|
212 |
position: relative;
|
570 |
margin-right: 2px;
|
571 |
background-color: #336374;
|
572 |
color: #fff;
|
573 |
+
font-size: 15px;
|
574 |
padding: 7px 20px;
|
575 |
border: 0;
|
576 |
}
|
598 |
padding: 15px 20px;
|
599 |
}
|
600 |
|
601 |
+
.yith-plugin-ui.metaboxes-tab label{
|
602 |
color: #33373b;
|
603 |
+
font-size: 15px;
|
604 |
+
margin-left: -310px;
|
605 |
+
}
|
606 |
+
.yith-plugin-ui.metaboxes-tab .the-metabox{
|
607 |
+
margin: 40px 0 40px 290px;
|
608 |
+
margin-left:327px;
|
609 |
+
|
610 |
+
}
|
611 |
+
.yith-plugin-ui.metaboxes-tab label{
|
612 |
+
width:250px;
|
613 |
+
font-weight: 600;
|
614 |
}
|
615 |
|
616 |
.yith-plugin-ui span.description{
|
617 |
color: #716269;
|
618 |
+
font-size: 14px;
|
619 |
font-style: normal;
|
620 |
font-weight: 400;
|
621 |
margin-top: 15px;
|
645 |
|
646 |
.yith-plugin-ui h2 {
|
647 |
color: #2a8db0;
|
648 |
+
font-size: 15px;
|
649 |
text-transform: uppercase;
|
650 |
border: 1px solid #d8d8d8;
|
651 |
border-bottom: 0;
|
673 |
|
674 |
.yith-plugin-ui #plugin-fw-wc h2 + div p, .yith-plugin-ui p.info-box{
|
675 |
background: #f1f1f1;
|
676 |
+
font-size: 14px;
|
677 |
font-weight: 700;
|
678 |
width: 40%;
|
679 |
display:block;
|
759 |
.woocommerce .yith-plugin-ui table.form-table select,
|
760 |
.yith-plugin-ui select{
|
761 |
-webkit-appearance: none;
|
762 |
+
line-height: 1.2em;
|
763 |
min-height: 35px;
|
764 |
background: url("../images/arrow_down.svg") no-repeat right center;
|
765 |
background-size: 35px 13px;
|
992 |
border-radius: 12px;
|
993 |
padding: 3px 11px;
|
994 |
border-color: #33937e;
|
995 |
+
font-size: 13px;
|
996 |
}
|
997 |
|
998 |
.yith-plugin-ui .select2-container--default .select2-selection--single .select2-selection__arrow:before{
|
1125 |
line-height: 20px;
|
1126 |
display: inline-block;
|
1127 |
color: #716269;
|
1128 |
+
font-size: 14px;
|
1129 |
}
|
1130 |
.yith-plugin-ui [type="radio"]:checked + label:before,
|
1131 |
.yith-plugin-ui [type="radio"]:not(:checked) + label:before {
|
1133 |
position: absolute;
|
1134 |
left: 0;
|
1135 |
top: 0;
|
1136 |
+
width: 19px;
|
1137 |
+
height: 19px;
|
1138 |
border: 1px solid #d8d8d8;
|
1139 |
border-radius: 100%;
|
1140 |
background: #fff;
|
1142 |
.yith-plugin-ui [type="radio"]:checked + label:after,
|
1143 |
.yith-plugin-ui [type="radio"]:not(:checked) + label:after {
|
1144 |
content: '';
|
1145 |
+
width: 13px;
|
1146 |
+
height: 13px;
|
1147 |
background: #4e8ba2;
|
1148 |
position: absolute;
|
1149 |
top: 4px;
|
1204 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input + span{
|
1205 |
border: 1px solid #d8d8d8;
|
1206 |
background-color: #fff;
|
1207 |
+
width: 60px;
|
1208 |
+
height: 24px;
|
1209 |
}
|
1210 |
|
1211 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input + span:before{
|
1215 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input + span:before {
|
1216 |
width: 14px;
|
1217 |
height: 14px;
|
1218 |
+
top: 5px;
|
1219 |
+
left: 6px;
|
1220 |
background-color: #d8d8d8;
|
1221 |
}
|
1222 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input + span:after{
|
1223 |
content: 'OFF';
|
1224 |
width: 14px;
|
1225 |
height: 14px;
|
1226 |
+
font-size: 13px;
|
1227 |
+
font-weight: 600;
|
1228 |
+
padding-left: 27px;
|
1229 |
color: #979797;
|
1230 |
margin-top: 5px;
|
1231 |
display: inline-block;
|
1240 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input:checked + span:before,
|
1241 |
.yith-plugin-ui.yith-plugin-fw-onoff-container input.onoffchecked + span:before{
|
1242 |
background-color: #98aa36;
|
1243 |
+
left: 41px;
|
1244 |
}
|
1245 |
|
1246 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input:checked + span:after,
|
1250 |
width: 14px;
|
1251 |
height: 14px;
|
1252 |
display: inline-block;
|
1253 |
+
font-size: 13px;
|
1254 |
+
font-weight: 600;
|
1255 |
padding: 0 10px;
|
1256 |
margin-top: 5px;
|
|
|
1257 |
}
|
1258 |
|
1259 |
.yith-plugin-ui .yith-plugin-fw-onoff-container input + span{
|
1393 |
}
|
1394 |
|
1395 |
/** colorpicker **/
|
1396 |
+
.yith-plugin-ui .yith-plugin-fw-field-wrapper .iris-picker,
|
1397 |
+
.yith-plugin-ui .yith-plugin-fw-field-wrapper .wp-picker-holder {
|
1398 |
display: none !important;
|
1399 |
}
|
1400 |
+
.yith-plugin-ui .yith-plugin-fw-field-wrapper .wp-picker-input-wrap {
|
1401 |
display: inline !important;
|
1402 |
}
|
1403 |
+
.yith-plugin-ui .yith-plugin-fw-field-wrapper .wp-picker-active .iris-picker,
|
1404 |
+
.yith-plugin-ui .yith-plugin-fw-field-wrapper .wp-picker-active .wp-picker-holder {
|
1405 |
display: block !important;
|
1406 |
}
|
1407 |
.woocommerce .yith-plugin-ui .iris-picker{
|
1559 |
box-sizing: border-box;
|
1560 |
background: white;
|
1561 |
}
|
1562 |
+
.yith-plugin-ui .yith-toggle-row{
|
1563 |
+
cursor: pointer;
|
1564 |
+
}
|
1565 |
.yith-plugin-ui .yith-add-box{
|
1566 |
padding: 30px 25px;
|
1567 |
display: none;
|
1573 |
.yith-plugin-ui .yith-toggle-title h3{
|
1574 |
padding: 0px 20px 0px 25px;
|
1575 |
margin: 0;
|
1576 |
+
margin-top: 4px;
|
1577 |
display: inline-block;
|
1578 |
position: relative;
|
1579 |
min-width: 173px;
|
1595 |
display: block;
|
1596 |
cursor: pointer;
|
1597 |
left: 0px;
|
1598 |
+
top: 4px;
|
1599 |
bottom: 0;
|
1600 |
}
|
1601 |
.yith-plugin-ui .yith-toggle > span:before{
|
1633 |
width: 250px;
|
1634 |
padding-right:40px;
|
1635 |
color: #33373b;
|
1636 |
+
font-size: 15px;
|
1637 |
vertical-align: top;
|
1638 |
font-weight: 600;
|
1639 |
}
|
1753 |
float: left;
|
1754 |
}
|
1755 |
|
1756 |
+
.yith-plugin-ui td.forminp-checkbox.two-cols fieldset:nth-child(2n+1){
|
1757 |
+
clear: both;
|
1758 |
+
}
|
1759 |
+
|
1760 |
.yith-plugin-ui td.forminp-checkbox.three-cols fieldset {
|
1761 |
+
width: calc(33% - 10px);
|
1762 |
+
padding-right: 10px;
|
1763 |
float: left;
|
1764 |
}
|
1765 |
|
1766 |
+
.yith-plugin-ui td.forminp-checkbox.three-cols fieldset:nth-child(3n+1){
|
1767 |
+
clear: both;
|
1768 |
+
}
|
1769 |
+
|
1770 |
|
1771 |
.yith-plugin-fw-checkbox-field-wrapper {
|
1772 |
display: inline-block !important;
|
1816 |
}
|
1817 |
|
1818 |
.yith-plugin-ui td.forminp-checkbox.three-cols fieldset {
|
1819 |
+
width: calc(50% - 10px);
|
1820 |
+
padding-right: 10px;
|
1821 |
float: left;
|
1822 |
}
|
1823 |
+
|
1824 |
+
.yith-plugin-ui td.forminp-checkbox.two-cols fieldset:nth-child(2n+1){
|
1825 |
+
clear: both;
|
1826 |
+
}
|
1827 |
+
|
1828 |
+
.yith-plugin-ui td.forminp-checkbox.three-cols fieldset:nth-child(3n+1){
|
1829 |
+
clear: initial;
|
1830 |
+
}
|
1831 |
}
|
1832 |
@media screen and (max-width: 782px){
|
1833 |
.yith-plugin-fw-banner.yith-plugin-fw-banner-free{
|
1854 |
.yith-plugin-ui td.forminp-checkbox.two-cols fieldset,
|
1855 |
.yith-plugin-ui td.forminp-checkbox.three-cols fieldset{
|
1856 |
width: 100%;
|
1857 |
+
clear: initial;
|
1858 |
}
|
1859 |
|
1860 |
}
|
plugin-fw/assets/js/yit-plugin-panel.js
CHANGED
@@ -7,8 +7,7 @@
|
|
7 |
* http://www.gnu.org/licenses/gpl-3.0.txt
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
(function ( $ ) {
|
12 |
//dependencies handler
|
13 |
$( '[data-dep-target]' ).each( function () {
|
14 |
var t = $( this );
|
@@ -150,4 +149,4 @@
|
|
150 |
// prevents the WC message for changes when leaving the panel page
|
151 |
$( '.yith-plugin-fw-panel .woo-nav-tab-wrapper' ).removeClass( 'woo-nav-tab-wrapper' ).addClass( 'yith-nav-tab-wrapper' );
|
152 |
|
153 |
-
}
|
7 |
* http://www.gnu.org/licenses/gpl-3.0.txt
|
8 |
*/
|
9 |
|
10 |
+
jQuery( function ( $ ) {
|
|
|
11 |
//dependencies handler
|
12 |
$( '[data-dep-target]' ).each( function () {
|
13 |
var t = $( this );
|
149 |
// prevents the WC message for changes when leaving the panel page
|
150 |
$( '.yith-plugin-fw-panel .woo-nav-tab-wrapper' ).removeClass( 'woo-nav-tab-wrapper' ).addClass( 'yith-nav-tab-wrapper' );
|
151 |
|
152 |
+
} );
|
plugin-fw/assets/js/yit-plugin-panel.min.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,e,b){a instanceof String&&(a=String(a));for(var c=a.length,d=0;d<c;d++){var g=a[d];if(e.call(b,g,d,a))return{i:d,v:g}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,e,b){a!=Array.prototype&&a!=Object.prototype&&(a[e]=b.value)};
|
2 |
$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(a,e,b,c){if(e){b=$jscomp.global;a=a.split(".");for(c=0;c<a.length-1;c++){var d=a[c];d in b||(b[d]={});b=b[d]}a=a[a.length-1];c=b[a];e=e(c);e!=c&&null!=e&&$jscomp.defineProperty(b,a,{configurable:!0,writable:!0,value:e})}};
|
3 |
$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,b){return $jscomp.findInternal(this,a,b).v}},"es6","es3");
|
4 |
-
(function(a){function e(b,c,d,e){var f=!0;if("string"==typeof c){":radio"==c.substr(0,6)&&(c+=":checked");var h=a(c).val();"checkbox"==a(c).attr("type")&&(h=a(c).is(":checked")?"yes":"no");d=d.split(",");for(c=0;c<d.length;c++)if(h!=d[c])f=!1;else{f=!0;break}}d=a(b);b=a(b+"-container").closest("tr");1>b.length&&(b=d.closest(".yith-plugin-fw-panel-wc-row"));e=e.split("-");for(var g in e)if(h=e[g],f)switch(h){case "disable":b.removeClass("yith-disabled");d.attr("disabled",!1);break;case "hideme":d.show();
|
5 |
break;default:b.show()}else switch(h){case "disable":b.addClass("yith-disabled");d.attr("disabled",!0);break;case "hideme":d.hide();break;default:b.hide()}}a("[data-dep-target]").each(function(){var b=a(this),c="#"+b.data("dep-target"),d="#"+b.data("dep-id"),g=b.data("dep-value"),f=b.data("dep-type");e(c,d,g.toString(),f);a(d).on("change",function(){e(c,d,g.toString(),f)}).change()});a(".rm_connectedlist").each(function(){var b=a(this).find("ul"),c=a(this).find(":hidden");b.sortable({connectWith:b,
|
6 |
update:function(d,e){var f={};b.each(function(){var b={};a(this).children().each(function(){b[a(this).data("option")]=a(this).text()});f[a(this).data("list")]=b});c.val(JSON.stringify(f).replace(/[\\"']/g,"\\$&").replace(/\u0000/g,"\\0"))}}).disableSelection()});a(document).ready(function(){a(".google-analytic-generate").click(function(){var b=a("#"+a(this).data("textarea")).data("codemirrorInstance"),c=a("#"+a(this).data("input")).val(),d=a(this).data("basename");b.replaceRange("(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement( o ),\nm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n"+
|
7 |
-
("ga('create', '"+c+"', '"+d+"');\n")+"ga('send', 'pageview');\n",b.getCursor("start"),b.getCursor("end"))})});a(".yith-plugin-fw-panel .woo-nav-tab-wrapper").removeClass("woo-nav-tab-wrapper").addClass("yith-nav-tab-wrapper")})
|
1 |
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,e,b){a instanceof String&&(a=String(a));for(var c=a.length,d=0;d<c;d++){var g=a[d];if(e.call(b,g,d,a))return{i:d,v:g}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,e,b){a!=Array.prototype&&a!=Object.prototype&&(a[e]=b.value)};
|
2 |
$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(a,e,b,c){if(e){b=$jscomp.global;a=a.split(".");for(c=0;c<a.length-1;c++){var d=a[c];d in b||(b[d]={});b=b[d]}a=a[a.length-1];c=b[a];e=e(c);e!=c&&null!=e&&$jscomp.defineProperty(b,a,{configurable:!0,writable:!0,value:e})}};
|
3 |
$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,b){return $jscomp.findInternal(this,a,b).v}},"es6","es3");
|
4 |
+
jQuery(function(a){function e(b,c,d,e){var f=!0;if("string"==typeof c){":radio"==c.substr(0,6)&&(c+=":checked");var h=a(c).val();"checkbox"==a(c).attr("type")&&(h=a(c).is(":checked")?"yes":"no");d=d.split(",");for(c=0;c<d.length;c++)if(h!=d[c])f=!1;else{f=!0;break}}d=a(b);b=a(b+"-container").closest("tr");1>b.length&&(b=d.closest(".yith-plugin-fw-panel-wc-row"));e=e.split("-");for(var g in e)if(h=e[g],f)switch(h){case "disable":b.removeClass("yith-disabled");d.attr("disabled",!1);break;case "hideme":d.show();
|
5 |
break;default:b.show()}else switch(h){case "disable":b.addClass("yith-disabled");d.attr("disabled",!0);break;case "hideme":d.hide();break;default:b.hide()}}a("[data-dep-target]").each(function(){var b=a(this),c="#"+b.data("dep-target"),d="#"+b.data("dep-id"),g=b.data("dep-value"),f=b.data("dep-type");e(c,d,g.toString(),f);a(d).on("change",function(){e(c,d,g.toString(),f)}).change()});a(".rm_connectedlist").each(function(){var b=a(this).find("ul"),c=a(this).find(":hidden");b.sortable({connectWith:b,
|
6 |
update:function(d,e){var f={};b.each(function(){var b={};a(this).children().each(function(){b[a(this).data("option")]=a(this).text()});f[a(this).data("list")]=b});c.val(JSON.stringify(f).replace(/[\\"']/g,"\\$&").replace(/\u0000/g,"\\0"))}}).disableSelection()});a(document).ready(function(){a(".google-analytic-generate").click(function(){var b=a("#"+a(this).data("textarea")).data("codemirrorInstance"),c=a("#"+a(this).data("input")).val(),d=a(this).data("basename");b.replaceRange("(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement( o ),\nm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n"+
|
7 |
+
("ga('create', '"+c+"', '"+d+"');\n")+"ga('send', 'pageview');\n",b.getCursor("start"),b.getCursor("end"))})});a(".yith-plugin-fw-panel .woo-nav-tab-wrapper").removeClass("woo-nav-tab-wrapper").addClass("yith-nav-tab-wrapper")});
|
plugin-fw/assets/js/yith-fields.js
CHANGED
@@ -1,258 +1,270 @@
|
|
1 |
-
|
|
|
|
|
2 |
/* global yith_framework_fw_fields*/
|
3 |
|
4 |
var yith_fields_init = function () {
|
5 |
-
var $datepicker
|
6 |
-
$colorpicker
|
7 |
-
$upload
|
8 |
-
imgPreviewHandler: '.yith-plugin-fw-upload-img-preview',
|
9 |
uploadButtonHandler: '.yith-plugin-fw-upload-button',
|
10 |
-
imgUrlHandler: '.yith-plugin-fw-upload-img-url',
|
11 |
-
resetButtonHandler: '.yith-plugin-fw-upload-button-reset',
|
12 |
-
imgUrl: $('.yith-plugin-fw-upload-img-url')
|
13 |
},
|
14 |
-
$wpAddMedia
|
15 |
$imageGallery = {
|
16 |
-
sliderWrapper: $('.yith-plugin-fw .image-gallery ul.slides-wrapper'),
|
17 |
buttonHandler: '.yith-plugin-fw .image-gallery-button'
|
18 |
},
|
19 |
-
$sidebars
|
20 |
-
$slider
|
21 |
-
$codemirror
|
22 |
-
$icons
|
23 |
-
$checkgroup
|
24 |
|
25 |
/* Datepicker */
|
26 |
-
$datepicker.each(function () {
|
27 |
-
var args = $(this).data();
|
28 |
-
$(this).datepicker(args);
|
29 |
-
});
|
30 |
|
31 |
/* Colorpicker */
|
32 |
-
$colorpicker.wpColorPicker({
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
-
});
|
42 |
-
|
43 |
-
|
44 |
-
$colorpicker.each(function () {
|
45 |
-
var select_label = $(this).data('variations-label'),
|
46 |
-
wrap_main = $(this).closest( '.yith-plugin-fw-field-wrapper' ),
|
47 |
-
wrap = wrap_main.find('.wp-picker-input-wrap');
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
});
|
55 |
-
wrap.find( '.wp-picker-default' ).wrap( button );
|
56 |
}
|
57 |
-
});
|
58 |
-
|
59 |
|
60 |
|
61 |
/* Upload */
|
62 |
-
if (typeof wp !== 'undefined' && typeof wp.media !== 'undefined') {
|
63 |
var _custom_media = true;
|
64 |
// preview
|
65 |
-
$upload.imgUrl.change(function () {
|
66 |
-
var url
|
67 |
-
re
|
68 |
-
preview = $(this).parent().find($upload.imgPreviewHandler).first();
|
69 |
|
70 |
-
if (preview.length < 1)
|
71 |
-
preview = $(this).parent().parent().find($upload.imgPreviewHandler).first();
|
|
|
72 |
|
73 |
-
if (re.test(url)) {
|
74 |
-
preview.html('<img src="' + url + '" style="max-width:100px; max-height:100px;" />');
|
75 |
} else {
|
76 |
-
preview.html('');
|
77 |
}
|
78 |
-
}).trigger('change');
|
79 |
|
80 |
-
$(document).on('click', $upload.uploadButtonHandler, function (e) {
|
81 |
e.preventDefault();
|
82 |
|
83 |
-
var t
|
84 |
custom_uploader,
|
85 |
-
id = t.attr('id').replace(/-button$/, '');
|
86 |
|
87 |
//If the uploader object has already been created, reopen the dialog
|
88 |
-
if (custom_uploader) {
|
89 |
custom_uploader.open();
|
90 |
return;
|
91 |
}
|
92 |
|
93 |
var custom_uploader_states = [
|
94 |
// Main states.
|
95 |
-
new wp.media.controller.Library({
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
];
|
103 |
|
104 |
// Create the media frame.
|
105 |
-
custom_uploader = wp.media.frames.downloadable_file = wp.media({
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
|
118 |
//When a file is selected, grab the URL and set it as the text field's value
|
119 |
-
custom_uploader.on('select', function () {
|
120 |
-
var attachment = custom_uploader.state().get('selection').first().toJSON();
|
121 |
|
122 |
-
$("#" + id).val(attachment.url);
|
123 |
// Save the id of the selected element to an element which name is the same with a suffix "-yith-attachment-id"
|
124 |
-
if ($("#" + id + "-yith-attachment-id")) {
|
125 |
-
$("#" + id + "-yith-attachment-id").val(attachment.id);
|
126 |
}
|
127 |
-
$upload.imgUrl.trigger('change');
|
128 |
-
});
|
129 |
|
130 |
//Open the uploader dialog
|
131 |
custom_uploader.open();
|
132 |
-
});
|
133 |
|
134 |
-
$(document).on('click', $upload.resetButtonHandler, function (e) {
|
135 |
-
var t
|
136 |
-
id
|
137 |
-
input_id
|
138 |
-
default_value = $('#' + id).data('default');
|
139 |
|
140 |
-
$("#" + input_id).val(default_value);
|
141 |
-
$upload.imgUrl.trigger('change');
|
142 |
-
});
|
143 |
}
|
144 |
|
145 |
-
$wpAddMedia.on('click', function () {
|
146 |
_custom_media = false;
|
147 |
-
});
|
148 |
|
149 |
/* Image Gallery */
|
150 |
-
if (typeof wp !== 'undefined' && typeof wp.media !== 'undefined') {
|
151 |
-
$(document).on('click', $imageGallery.buttonHandler, function (e) {
|
152 |
-
var $t
|
153 |
-
$container
|
154 |
-
$image_gallery_ids
|
155 |
-
attachment_ids
|
156 |
-
$gallery_images_wrapper = $container.find('ul.slides-wrapper');
|
157 |
|
158 |
// Create the media frame.
|
159 |
-
var image_gallery_frame = wp.media.frames.image_gallery = wp.media({
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
|
174 |
// When an image is selected, run a callback.
|
175 |
-
image_gallery_frame.on('select', function () {
|
176 |
-
var selection = image_gallery_frame.state().get('selection');
|
177 |
-
selection.map(function (attachment) {
|
178 |
attachment = attachment.toJSON();
|
179 |
|
180 |
-
if (attachment.id) {
|
181 |
attachment_ids = attachment_ids ? attachment_ids + "," + attachment.id : attachment.id;
|
182 |
-
$gallery_images_wrapper.append('<li class="image" data-attachment_id="' + attachment.id + '"><img src="' + attachment.sizes.thumbnail.url + '"/><ul class="actions"><li><a href="#" class="delete" title="' + $t.data('delete') + '">x</a></li></ul></li>');
|
183 |
}
|
184 |
-
});
|
185 |
|
186 |
-
$image_gallery_ids.val(attachment_ids);
|
187 |
-
});
|
188 |
|
189 |
image_gallery_frame.open();
|
190 |
|
191 |
-
});
|
192 |
|
193 |
// Image ordering
|
194 |
-
$imageGallery.sliderWrapper.each(function () {
|
195 |
-
var $t = $(this);
|
196 |
-
$t.sortable({
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
});
|
222 |
|
223 |
// Remove images
|
224 |
-
$imageGallery.sliderWrapper.on('click', 'a.delete', function () {
|
225 |
-
var $wrapper
|
226 |
-
$gallery
|
227 |
-
$image_gallery_ids = $wrapper.find('.image_gallery_ids'),
|
228 |
-
attachment_ids
|
229 |
|
230 |
-
$(this).closest('li.image').remove();
|
231 |
|
232 |
-
$gallery.find('li.image').css('cursor', 'default').each(function () {
|
233 |
-
var attachment_id = $(this).attr('data-attachment_id');
|
234 |
-
attachment_ids
|
235 |
-
});
|
236 |
|
237 |
-
$image_gallery_ids.val(attachment_ids);
|
238 |
-
});
|
239 |
}
|
240 |
|
241 |
|
242 |
/* Sidebars */
|
243 |
-
$sidebars.each(function () {
|
244 |
-
var $images = $(this).find('img');
|
245 |
-
$images.on('click', function () {
|
246 |
-
var $container = $(this).closest('.yith-plugin-fw-sidebar-layout'),
|
247 |
-
$left
|
248 |
-
$right
|
249 |
-
type
|
250 |
-
|
251 |
-
$(this).parent().children(':radio').attr('checked', false);
|
252 |
-
$(this).prev(':radio').attr('checked', true);
|
253 |
-
|
254 |
-
if (typeof type != 'undefined') {
|
255 |
-
switch (type) {
|
256 |
case 'left':
|
257 |
$left.show();
|
258 |
$right.hide();
|
@@ -271,156 +283,156 @@ jQuery(function ($) {
|
|
271 |
break;
|
272 |
}
|
273 |
}
|
274 |
-
});
|
275 |
-
});
|
276 |
|
277 |
/* Slider */
|
278 |
-
$slider.each(function () {
|
279 |
-
var val
|
280 |
-
minValue = $(this).data('min'),
|
281 |
-
maxValue = $(this).data('max'),
|
282 |
-
step
|
283 |
-
labels
|
284 |
-
|
285 |
-
$(this).slider({
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
});
|
304 |
|
305 |
/* codemirror */
|
306 |
-
$codemirror.each(function (i, v) {
|
307 |
-
var editor = CodeMirror.fromTextArea(v, {
|
308 |
-
lineNumbers: 1,
|
309 |
-
mode: 'javascript',
|
310 |
showCursorWhenSelecting: true
|
311 |
-
});
|
312 |
|
313 |
-
$(v).data('codemirrorInstance', editor);
|
314 |
-
});
|
315 |
|
316 |
/* Select All - Deselect All */
|
317 |
-
$(document).on('click', '.yith-plugin-fw-select-all', function () {
|
318 |
-
var $targetSelect = $('#' + $(this).data('select-id'));
|
319 |
-
$targetSelect.find('option').prop('selected', true).trigger('change');
|
320 |
-
});
|
321 |
|
322 |
-
$(document).on('click', '.yith-plugin-fw-deselect-all', function () {
|
323 |
-
var $targetSelect = $('#' + $(this).data('select-id'));
|
324 |
-
$targetSelect.find('option').prop('selected', false).trigger('change');
|
325 |
-
});
|
326 |
|
327 |
|
328 |
-
$icons.each(function () {
|
329 |
-
var $container = $(this),
|
330 |
-
$preview
|
331 |
-
$text
|
332 |
|
333 |
-
$container.on('click', '.yit-icons-manager-list li', function (event) {
|
334 |
-
var $target = $(event.target).closest('li'),
|
335 |
-
font
|
336 |
-
icon
|
337 |
-
key
|
338 |
-
name
|
339 |
|
340 |
-
$preview.attr('data-font', font);
|
341 |
-
$preview.attr('data-icon', icon);
|
342 |
-
$preview.attr('data-key', key);
|
343 |
-
$preview.attr('data-name', name);
|
344 |
|
345 |
-
$text.val(font + ':' + name);
|
346 |
|
347 |
-
$container.find('.yit-icons-manager-list li').removeClass('active');
|
348 |
-
$target.addClass('active');
|
349 |
-
});
|
350 |
|
351 |
-
$container.on('click', '.yit-icons-manager-action-set-default', function () {
|
352 |
-
$container.find('.yit-icons-manager-list li.default').trigger('click');
|
353 |
-
});
|
354 |
-
});
|
355 |
|
356 |
/** Select Images */
|
357 |
-
$(document).on('click', '.yith-plugin-fw-select-images__item', function () {
|
358 |
-
var item
|
359 |
-
key
|
360 |
-
wrapper = item.closest('.yith-plugin-fw-select-images__wrapper'),
|
361 |
-
items
|
362 |
-
select
|
363 |
-
|
364 |
-
if (select.length) {
|
365 |
-
select.val(key);
|
366 |
-
items.removeClass('yith-plugin-fw-select-images__item--selected');
|
367 |
-
item.addClass('yith-plugin-fw-select-images__item--selected');
|
368 |
}
|
369 |
-
});
|
370 |
|
371 |
-
$(document.body).trigger('wc-enhanced-select-init');
|
372 |
|
373 |
-
$(document).find('.ui-sortable .yith-toggle-elements').sortable(
|
374 |
{
|
375 |
-
cursor: 'move',
|
376 |
-
axis: 'y',
|
377 |
-
scrollSensitivity: 40,
|
378 |
forcePlaceholderSize: true,
|
379 |
-
helper: 'clone',
|
380 |
|
381 |
-
stop: function (event, ui) {
|
382 |
-
var keys
|
383 |
-
i
|
384 |
array_keys = new Array();
|
385 |
-
for (i = 0; i < keys.length; i++) {
|
386 |
-
array_keys[i] = $(keys[i]).data('item_key');
|
387 |
}
|
388 |
-
if (array_keys.length > 0) {
|
389 |
-
var toggle = $(this).closest('.toggle-element');
|
390 |
-
toggle.saveToggleElement(null, array_keys);
|
391 |
}
|
392 |
}
|
393 |
}
|
394 |
);
|
395 |
|
396 |
-
$.each($checkgroup, function () {
|
397 |
-
var children = $(this).find('fieldset');
|
398 |
-
if (children.length > 3 && children.length < 6) {
|
399 |
-
$(this).addClass('two-cols')
|
400 |
}
|
401 |
-
if (children.length > 6) {
|
402 |
-
$(this).addClass('three-cols')
|
403 |
}
|
404 |
-
});
|
405 |
|
406 |
-
$(document.body).trigger('yith-framework-enhanced-select-init');
|
407 |
};
|
408 |
|
409 |
yith_fields_init();
|
410 |
|
411 |
/* on-off */
|
412 |
-
$(document).on('click', '.yith-plugin-fw-onoff-container span', function () {
|
413 |
-
var input
|
414 |
-
checked = input.prop('checked');
|
415 |
|
416 |
-
if (checked) {
|
417 |
-
input.prop('checked', false).attr('value', 'no').removeClass('onoffchecked');
|
418 |
} else {
|
419 |
-
input.prop('checked', true).attr('value', 'yes').addClass('onoffchecked');
|
420 |
}
|
421 |
|
422 |
input.change();
|
423 |
-
});
|
424 |
|
425 |
|
426 |
/** Toggle **/
|
@@ -428,222 +440,234 @@ jQuery(function ($) {
|
|
428 |
|
429 |
|
430 |
//TOGGLE ELEMENT
|
431 |
-
$.fn.saveToggleElement = function (spinner, array_keys) {
|
432 |
-
var toggle
|
433 |
-
action
|
434 |
-
formdata
|
435 |
-
id
|
436 |
-
current_tab = $.urlParam('tab');
|
437 |
-
|
438 |
-
if (typeof array_keys != 'undefined' && array_keys.length > 0) {
|
439 |
-
formdata.append('yith_toggle_elements_order_keys', array_keys);
|
440 |
}
|
441 |
|
442 |
-
if (toggle.closest('.metaboxes-tab.yith-plugin-ui').length) {
|
443 |
-
action
|
444 |
-
post_id
|
445 |
-
yit_metaboxes_nonce = $(this).closest('form#post').find('#yit_metaboxes_nonce').val();
|
446 |
-
url
|
447 |
} else {
|
448 |
url = yith_framework_fw_fields.admin_url + '?action=' + action + '&tab=' + current_tab + "&toggle_id=" + id;
|
449 |
}
|
450 |
|
451 |
-
$.ajax({
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
};
|
466 |
|
467 |
$.fn.serializeToggleElement = function () {
|
468 |
-
var obj = $(this);
|
469 |
/* ADD FILE TO PARAM AJAX */
|
470 |
var formData = new FormData();
|
471 |
-
var params
|
472 |
|
473 |
-
$.each(params, function (i, val) {
|
474 |
el_name = val.name;
|
475 |
-
formData.append(val.name, val.value);
|
476 |
-
});
|
477 |
|
478 |
return formData;
|
479 |
};
|
480 |
|
481 |
$.fn.formatToggleTitle = function () {
|
482 |
-
var toggle_el = $(this),
|
483 |
-
fields
|
484 |
-
title
|
485 |
-
subtitle
|
486 |
-
regExp
|
487 |
|
488 |
-
if (typeof title != 'undefined') {
|
489 |
var res = title.match( regExp );
|
490 |
}
|
491 |
|
492 |
-
if (typeof subtitle != 'undefined') {
|
493 |
var ressub = subtitle.match( regExp );
|
494 |
}
|
495 |
|
496 |
-
$.each(fields, function (i, field) {
|
497 |
-
if (typeof $(field).attr('id') != 'undefined') {
|
498 |
-
$field_id
|
499 |
-
$field_array = $field_id.split('_');
|
500 |
$field_array.pop();
|
501 |
-
$field_id
|
502 |
-
$field_val = $(field).val();
|
503 |
|
504 |
-
if (res != null && typeof res != 'undefined' && res.indexOf($field_id) !== -1) {
|
505 |
-
title = title.replace('%%' + $field_id + '%%', $field_val);
|
506 |
}
|
507 |
-
if (ressub != null && typeof ressub != 'undefined' && ressub.indexOf($field_id) !== -1) {
|
508 |
-
subtitle = subtitle.replace('%%' + $field_id + '%%', $field_val);
|
509 |
}
|
510 |
}
|
511 |
-
});
|
512 |
|
513 |
-
if ('' !== title) {
|
514 |
-
toggle_el.find('span.title').html(title);
|
515 |
}
|
516 |
|
517 |
-
if ('' !== subtitle) {
|
518 |
-
toggle_el.find('.subtitle').html(subtitle);
|
519 |
}
|
520 |
|
521 |
-
$(document).trigger('yith-toggle-element-item-title', [toggle_el]);
|
522 |
};
|
523 |
|
524 |
-
$.urlParam = function (name) {
|
525 |
-
var results = new RegExp('[\?&]' + name + '=([^&#]*)')
|
526 |
-
.exec(window.location.search);
|
527 |
|
528 |
-
return (results !== null) ? results[1] || 0 : false;
|
529 |
};
|
530 |
|
531 |
-
$(document).on('click', '.yith-toggle', function (event) {
|
532 |
-
var _toggle
|
533 |
-
_section = _toggle.closest('.yith-toggle-row'),
|
534 |
-
_content = _section.find('.yith-toggle-content');
|
|
|
|
|
|
|
|
|
535 |
|
536 |
-
if (_section.is('.yith-toggle-row-opened')) {
|
537 |
-
_content.slideUp(400);
|
538 |
} else {
|
539 |
-
_content.slideDown(400);
|
540 |
}
|
541 |
-
_section.toggleClass('yith-toggle-row-opened');
|
542 |
-
});
|
543 |
|
544 |
/**Add new box toggle**/
|
545 |
-
$(document).on('click', '.yith-add-box-button', function (event) {
|
546 |
event.preventDefault();
|
547 |
-
var target_id = $(this).data('box_id'),
|
548 |
-
id
|
549 |
-
template
|
550 |
-
if ('' !== target_id) {
|
551 |
-
$('#' + target_id).html(template({index: 'box_id'})).slideToggle();
|
552 |
yith_fields_init();
|
553 |
-
$(document).trigger('yith-add-box-button-toggle', [$(this)]);
|
554 |
}
|
555 |
-
});
|
556 |
|
557 |
-
$(document).on('click', '.yith-add-box-buttons .yith-save-button', function (event) {
|
558 |
event.preventDefault();
|
559 |
-
var add_box
|
560 |
-
id
|
561 |
-
spinner
|
562 |
-
toggle_element = $(this).parents('.toggle-element'),
|
563 |
-
fields
|
564 |
-
counter
|
565 |
-
hidden_obj
|
566 |
-
hidden_obj.val(counter);
|
567 |
-
$(document).trigger('yith-toggle-change-counter', [hidden_obj, add_box]);
|
568 |
-
|
569 |
-
counter
|
570 |
-
var template
|
571 |
-
toggle_el = $(template({index: counter}));
|
572 |
-
|
573 |
-
spinner.addClass('show');
|
574 |
-
|
575 |
-
$.each(fields, function (i, field) {
|
576 |
-
if (typeof $(field).attr('id') != 'undefined') {
|
577 |
-
|
578 |
-
$field_id
|
579 |
-
$field_val = $(field).val();
|
580 |
-
|
581 |
-
if ('radio' == $(field).attr('type')) {
|
582 |
-
$field_id = $field_id.replace('new_', '');
|
583 |
-
$field_id = $field_id.replace('-' + $field_val, '');
|
584 |
$field_id = $field_id + '_dataindex-' + $field_val;
|
585 |
} else {
|
586 |
-
$field_id = $field_id.replace('new_', '') + '_' + counter;
|
587 |
}
|
588 |
|
589 |
-
if ($(field).is(':checked')) {
|
590 |
-
$(toggle_el).find('#' + $field_id).prop('checked', true);
|
591 |
}
|
592 |
|
593 |
-
if ($(field).hasClass('yith-post-search') || $(field).hasClass('yith-term-search')) {
|
594 |
-
$(toggle_el).find('#' + $field_id).html($('#' + $(field).attr('id')).html());
|
595 |
}
|
596 |
|
597 |
-
$(toggle_el).find('#' + $field_id).val($field_val);
|
598 |
|
599 |
}
|
600 |
|
601 |
-
});
|
602 |
|
603 |
-
$(toggle_el).formatToggleTitle();
|
604 |
-
var form_is_valid = $('<input type="hidden">').val('yes');
|
605 |
-
$(document).trigger('yith-toggle-element-item-before-add', [add_box, toggle_el, form_is_valid]);
|
606 |
|
607 |
|
608 |
-
if (form_is_valid.val() === 'yes') {
|
609 |
-
$(toggle_element).find('.yith-toggle-elements').append(toggle_el);
|
610 |
-
$(add_box).find('.yith-plugin-fw-datepicker').datepicker('destroy');
|
611 |
-
$(add_box).html('').toggle();
|
612 |
toggle_element.saveToggleElement();
|
613 |
yith_fields_init();
|
614 |
}
|
615 |
-
});
|
616 |
|
617 |
-
$(document).on('click', '.yith-toggle-row .yith-save-button', function (event) {
|
618 |
event.preventDefault();
|
619 |
-
var toggle
|
620 |
-
toggle_row = $(this).closest('.yith-toggle-row'),
|
621 |
-
spinner
|
622 |
toggle_row.formatToggleTitle();
|
623 |
|
624 |
-
var form_is_valid = $('<input type="hidden">').val('yes');
|
625 |
-
$(document).trigger('yith-toggle-element-item-before-update', [toggle, toggle_row, form_is_valid]);
|
626 |
-
if (form_is_valid.val() === 'yes') {
|
627 |
-
spinner.addClass('show');
|
628 |
-
toggle.saveToggleElement(spinner);
|
629 |
}
|
630 |
-
});
|
631 |
|
632 |
//register remove the dome and save the toggle
|
633 |
-
$(document).on('click', '.yith-toggle-row .yith-delete-button', function (event) {
|
634 |
event.preventDefault();
|
635 |
-
var toggle
|
636 |
-
toggle_row = $(this).closest('.yith-toggle-row');
|
637 |
toggle_row.remove();
|
638 |
toggle.saveToggleElement();
|
639 |
-
});
|
640 |
|
641 |
//register onoff status
|
642 |
-
$(document).on('click', '.yith-toggle-onoff', function (event) {
|
643 |
event.preventDefault();
|
644 |
-
var toggle = $(this).closest('.toggle-element');
|
645 |
toggle.saveToggleElement();
|
646 |
-
});
|
|
|
|
|
|
|
|
|
|
|
647 |
|
|
|
|
|
|
|
648 |
|
649 |
-
});
|
1 |
+
|
2 |
+
jQuery( function ( $ ) {
|
3 |
+
|
4 |
/* global yith_framework_fw_fields*/
|
5 |
|
6 |
var yith_fields_init = function () {
|
7 |
+
var $datepicker = $( '.yith-plugin-fw-datepicker' ),
|
8 |
+
$colorpicker = $( '.yith-plugin-fw-colorpicker' ),
|
9 |
+
$upload = {
|
10 |
+
imgPreviewHandler : '.yith-plugin-fw-upload-img-preview',
|
11 |
uploadButtonHandler: '.yith-plugin-fw-upload-button',
|
12 |
+
imgUrlHandler : '.yith-plugin-fw-upload-img-url',
|
13 |
+
resetButtonHandler : '.yith-plugin-fw-upload-button-reset',
|
14 |
+
imgUrl : $( '.yith-plugin-fw-upload-img-url' )
|
15 |
},
|
16 |
+
$wpAddMedia = $( '.add_media' ),
|
17 |
$imageGallery = {
|
18 |
+
sliderWrapper: $( '.yith-plugin-fw .image-gallery ul.slides-wrapper' ),
|
19 |
buttonHandler: '.yith-plugin-fw .image-gallery-button'
|
20 |
},
|
21 |
+
$sidebars = $( '.yith-plugin-fw-sidebar-layout' ),
|
22 |
+
$slider = $( '.yith-plugin-fw .yith-plugin-fw-slider-container .ui-slider-horizontal' ),
|
23 |
+
$codemirror = $( '.codemirror' ),
|
24 |
+
$icons = $( '.yit-icons-manager-wrapper' ),
|
25 |
+
$checkgroup = $( ".yith-plugin-ui td.forminp-checkbox" );
|
26 |
|
27 |
/* Datepicker */
|
28 |
+
$datepicker.each( function () {
|
29 |
+
var args = $( this ).data();
|
30 |
+
$( this ).datepicker( args );
|
31 |
+
} );
|
32 |
|
33 |
/* Colorpicker */
|
34 |
+
$colorpicker.wpColorPicker( {
|
35 |
+
palettes: false,
|
36 |
+
width : 200,
|
37 |
+
mode : 'hsl',
|
38 |
+
clear : function () {
|
39 |
+
var input = $( this );
|
40 |
+
input.val( input.data( 'default-color' ) );
|
41 |
+
input.change();
|
42 |
+
}
|
43 |
+
} );
|
44 |
+
|
45 |
+
|
46 |
+
$colorpicker.each( function () {
|
47 |
+
var select_label = $( this ).data( 'variations-label' ),
|
48 |
+
wrap_main1 = $( this ).closest( '.yith-plugin-fw-colorpicker-field-wrapper' ),
|
49 |
+
wrap_main2 = $( this ).closest( '.yith-single-colorpicker' ),
|
50 |
+
wrap1 = wrap_main1.find( '.wp-picker-input-wrap' ),
|
51 |
+
wrap2 = wrap_main2.find( '.wp-picker-input-wrap' );
|
52 |
+
|
53 |
+
wrap1.length && wrap_main1.find( 'a.wp-color-result' ).attr( 'title', select_label );
|
54 |
+
wrap_main2.length && wrap_main2.find( 'a.wp-color-result' ).attr( 'title', select_label );
|
55 |
+
|
56 |
+
if ( !wrap1.find( '.wp-picker-clear-custom' ).length ) {
|
57 |
+
var button = $( '<span/>' ).attr( {
|
58 |
+
class: "wp-picker-default-custom"
|
59 |
+
} );
|
60 |
+
wrap1.find( '.wp-picker-default' ).wrap( button );
|
61 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
+
if ( !wrap2.find( '.wp-picker-clear-custom' ).length ) {
|
64 |
+
var button = $( '<span/>' ).attr( {
|
65 |
+
class: "wp-picker-default-custom"
|
66 |
+
} );
|
67 |
+
wrap2.find( '.wp-picker-default' ).wrap( button );
|
|
|
|
|
68 |
}
|
69 |
+
} );
|
|
|
70 |
|
71 |
|
72 |
/* Upload */
|
73 |
+
if ( typeof wp !== 'undefined' && typeof wp.media !== 'undefined' ) {
|
74 |
var _custom_media = true;
|
75 |
// preview
|
76 |
+
$upload.imgUrl.change( function () {
|
77 |
+
var url = $( this ).val(),
|
78 |
+
re = new RegExp( "(http|ftp|https)://[a-zA-Z0-9@?^=%&:/~+#-_.]*.(gif|jpg|jpeg|png|ico)" ),
|
79 |
+
preview = $( this ).parent().find( $upload.imgPreviewHandler ).first();
|
80 |
|
81 |
+
if ( preview.length < 1 ) {
|
82 |
+
preview = $( this ).parent().parent().find( $upload.imgPreviewHandler ).first();
|
83 |
+
}
|
84 |
|
85 |
+
if ( re.test( url ) ) {
|
86 |
+
preview.html( '<img src="' + url + '" style="max-width:100px; max-height:100px;" />' );
|
87 |
} else {
|
88 |
+
preview.html( '' );
|
89 |
}
|
90 |
+
} ).trigger( 'change' );
|
91 |
|
92 |
+
$( document ).on( 'click', $upload.uploadButtonHandler, function ( e ) {
|
93 |
e.preventDefault();
|
94 |
|
95 |
+
var t = $( this ),
|
96 |
custom_uploader,
|
97 |
+
id = t.attr( 'id' ).replace( /-button$/, '' );
|
98 |
|
99 |
//If the uploader object has already been created, reopen the dialog
|
100 |
+
if ( custom_uploader ) {
|
101 |
custom_uploader.open();
|
102 |
return;
|
103 |
}
|
104 |
|
105 |
var custom_uploader_states = [
|
106 |
// Main states.
|
107 |
+
new wp.media.controller.Library( {
|
108 |
+
library : wp.media.query(),
|
109 |
+
multiple : false,
|
110 |
+
title : 'Choose Image',
|
111 |
+
priority : 20,
|
112 |
+
filterable: 'uploaded'
|
113 |
+
} )
|
114 |
];
|
115 |
|
116 |
// Create the media frame.
|
117 |
+
custom_uploader = wp.media.frames.downloadable_file = wp.media( {
|
118 |
+
// Set the title of the modal.
|
119 |
+
title : 'Choose Image',
|
120 |
+
library : {
|
121 |
+
type: ''
|
122 |
+
},
|
123 |
+
button : {
|
124 |
+
text: 'Choose Image'
|
125 |
+
},
|
126 |
+
multiple: false,
|
127 |
+
states : custom_uploader_states
|
128 |
+
} );
|
129 |
|
130 |
//When a file is selected, grab the URL and set it as the text field's value
|
131 |
+
custom_uploader.on( 'select', function () {
|
132 |
+
var attachment = custom_uploader.state().get( 'selection' ).first().toJSON();
|
133 |
|
134 |
+
$( "#" + id ).val( attachment.url );
|
135 |
// Save the id of the selected element to an element which name is the same with a suffix "-yith-attachment-id"
|
136 |
+
if ( $( "#" + id + "-yith-attachment-id" ) ) {
|
137 |
+
$( "#" + id + "-yith-attachment-id" ).val( attachment.id );
|
138 |
}
|
139 |
+
$upload.imgUrl.trigger( 'change' );
|
140 |
+
} );
|
141 |
|
142 |
//Open the uploader dialog
|
143 |
custom_uploader.open();
|
144 |
+
} );
|
145 |
|
146 |
+
$( document ).on( 'click', $upload.resetButtonHandler, function ( e ) {
|
147 |
+
var t = $( this ),
|
148 |
+
id = t.attr( 'id' ),
|
149 |
+
input_id = t.attr( 'id' ).replace( /-button-reset$/, '' ),
|
150 |
+
default_value = $( '#' + id ).data( 'default' );
|
151 |
|
152 |
+
$( "#" + input_id ).val( default_value );
|
153 |
+
$upload.imgUrl.trigger( 'change' );
|
154 |
+
} );
|
155 |
}
|
156 |
|
157 |
+
$wpAddMedia.on( 'click', function () {
|
158 |
_custom_media = false;
|
159 |
+
} );
|
160 |
|
161 |
/* Image Gallery */
|
162 |
+
if ( typeof wp !== 'undefined' && typeof wp.media !== 'undefined' ) {
|
163 |
+
$( document ).on( 'click', $imageGallery.buttonHandler, function ( e ) {
|
164 |
+
var $t = $( this ),
|
165 |
+
$container = $t.closest( '.image-gallery' ),
|
166 |
+
$image_gallery_ids = $container.find( '.image_gallery_ids' ),
|
167 |
+
attachment_ids = $image_gallery_ids.val(),
|
168 |
+
$gallery_images_wrapper = $container.find( 'ul.slides-wrapper' );
|
169 |
|
170 |
// Create the media frame.
|
171 |
+
var image_gallery_frame = wp.media.frames.image_gallery = wp.media( {
|
172 |
+
// Set the title of the modal.
|
173 |
+
title : $t.data( 'choose' ),
|
174 |
+
button: {
|
175 |
+
text: $t.data( 'update' )
|
176 |
+
},
|
177 |
+
states: [
|
178 |
+
new wp.media.controller.Library( {
|
179 |
+
title : $t.data( 'choose' ),
|
180 |
+
filterable: 'all',
|
181 |
+
multiple : true
|
182 |
+
} )
|
183 |
+
]
|
184 |
+
} );
|
185 |
|
186 |
// When an image is selected, run a callback.
|
187 |
+
image_gallery_frame.on( 'select', function () {
|
188 |
+
var selection = image_gallery_frame.state().get( 'selection' );
|
189 |
+
selection.map( function ( attachment ) {
|
190 |
attachment = attachment.toJSON();
|
191 |
|
192 |
+
if ( attachment.id ) {
|
193 |
attachment_ids = attachment_ids ? attachment_ids + "," + attachment.id : attachment.id;
|
194 |
+
$gallery_images_wrapper.append( '<li class="image" data-attachment_id="' + attachment.id + '"><img src="' + attachment.sizes.thumbnail.url + '"/><ul class="actions"><li><a href="#" class="delete" title="' + $t.data( 'delete' ) + '">x</a></li></ul></li>' );
|
195 |
}
|
196 |
+
} );
|
197 |
|
198 |
+
$image_gallery_ids.val( attachment_ids );
|
199 |
+
} );
|
200 |
|
201 |
image_gallery_frame.open();
|
202 |
|
203 |
+
} );
|
204 |
|
205 |
// Image ordering
|
206 |
+
$imageGallery.sliderWrapper.each( function () {
|
207 |
+
var $t = $( this );
|
208 |
+
$t.sortable( {
|
209 |
+
items : 'li.image',
|
210 |
+
cursor : 'move',
|
211 |
+
scrollSensitivity : 40,
|
212 |
+
forcePlaceholderSize: true,
|
213 |
+
forceHelperSize : false,
|
214 |
+
helper : 'clone',
|
215 |
+
opacity : 0.65,
|
216 |
+
start : function ( event, ui ) {
|
217 |
+
ui.item.css( 'background-color', '#f6f6f6' );
|
218 |
+
},
|
219 |
+
stop : function ( event, ui ) {
|
220 |
+
ui.item.removeAttr( 'style' );
|
221 |
+
},
|
222 |
+
update : function ( event, ui ) {
|
223 |
+
var attachment_ids = '';
|
224 |
+
|
225 |
+
$t.find( 'li.image' ).css( 'cursor', 'default' ).each( function () {
|
226 |
+
var attachment_id = $( this ).attr( 'data-attachment_id' );
|
227 |
+
attachment_ids = attachment_ids + attachment_id + ',';
|
228 |
+
} );
|
229 |
+
|
230 |
+
$t.closest( '.image-gallery' ).find( '.image_gallery_ids' ).val( attachment_ids );
|
231 |
+
}
|
232 |
+
} );
|
233 |
+
} );
|
234 |
|
235 |
// Remove images
|
236 |
+
$imageGallery.sliderWrapper.on( 'click', 'a.delete', function () {
|
237 |
+
var $wrapper = $( this ).closest( '.image-gallery' ),
|
238 |
+
$gallery = $( this ).closest( '.image-gallery ul.slides-wrapper' ),
|
239 |
+
$image_gallery_ids = $wrapper.find( '.image_gallery_ids' ),
|
240 |
+
attachment_ids = '';
|
241 |
|
242 |
+
$( this ).closest( 'li.image' ).remove();
|
243 |
|
244 |
+
$gallery.find( 'li.image' ).css( 'cursor', 'default' ).each( function () {
|
245 |
+
var attachment_id = $( this ).attr( 'data-attachment_id' );
|
246 |
+
attachment_ids = attachment_ids + attachment_id + ',';
|
247 |
+
} );
|
248 |
|
249 |
+
$image_gallery_ids.val( attachment_ids );
|
250 |
+
} );
|
251 |
}
|
252 |
|
253 |
|
254 |
/* Sidebars */
|
255 |
+
$sidebars.each( function () {
|
256 |
+
var $images = $( this ).find( 'img' );
|
257 |
+
$images.on( 'click', function () {
|
258 |
+
var $container = $( this ).closest( '.yith-plugin-fw-sidebar-layout' ),
|
259 |
+
$left = $container.find( '.yith-plugin-fw-sidebar-layout-sidebar-left-container' ),
|
260 |
+
$right = $container.find( '.yith-plugin-fw-sidebar-layout-sidebar-right-container' ),
|
261 |
+
type = $( this ).data( 'type' );
|
262 |
+
|
263 |
+
$( this ).parent().children( ':radio' ).attr( 'checked', false );
|
264 |
+
$( this ).prev( ':radio' ).attr( 'checked', true );
|
265 |
+
|
266 |
+
if ( typeof type != 'undefined' ) {
|
267 |
+
switch ( type ) {
|
268 |
case 'left':
|
269 |
$left.show();
|
270 |
$right.hide();
|
283 |
break;
|
284 |
}
|
285 |
}
|
286 |
+
} );
|
287 |
+
} );
|
288 |
|
289 |
/* Slider */
|
290 |
+
$slider.each( function () {
|
291 |
+
var val = $( this ).data( 'val' ),
|
292 |
+
minValue = $( this ).data( 'min' ),
|
293 |
+
maxValue = $( this ).data( 'max' ),
|
294 |
+
step = $( this ).data( 'step' ),
|
295 |
+
labels = $( this ).data( 'labels' );
|
296 |
+
|
297 |
+
$( this ).slider( {
|
298 |
+
value: val,
|
299 |
+
min : minValue,
|
300 |
+
max : maxValue,
|
301 |
+
range: 'min',
|
302 |
+
step : step,
|
303 |
+
|
304 |
+
create: function () {
|
305 |
+
$( this ).find( '.ui-slider-handle' ).text( $( this ).slider( "value" ) );
|
306 |
+
},
|
307 |
+
|
308 |
+
|
309 |
+
slide: function ( event, ui ) {
|
310 |
+
$( this ).find( 'input' ).val( ui.value );
|
311 |
+
$( this ).find( '.ui-slider-handle' ).text( ui.value );
|
312 |
+
$( this ).siblings( '.feedback' ).find( 'strong' ).text( ui.value + labels );
|
313 |
+
}
|
314 |
+
} );
|
315 |
+
} );
|
316 |
|
317 |
/* codemirror */
|
318 |
+
$codemirror.each( function ( i, v ) {
|
319 |
+
var editor = CodeMirror.fromTextArea( v, {
|
320 |
+
lineNumbers : 1,
|
321 |
+
mode : 'javascript',
|
322 |
showCursorWhenSelecting: true
|
323 |
+
} );
|
324 |
|
325 |
+
$( v ).data( 'codemirrorInstance', editor );
|
326 |
+
} );
|
327 |
|
328 |
/* Select All - Deselect All */
|
329 |
+
$( document ).on( 'click', '.yith-plugin-fw-select-all', function () {
|
330 |
+
var $targetSelect = $( '#' + $( this ).data( 'select-id' ) );
|
331 |
+
$targetSelect.find( 'option' ).prop( 'selected', true ).trigger( 'change' );
|
332 |
+
} );
|
333 |
|
334 |
+
$( document ).on( 'click', '.yith-plugin-fw-deselect-all', function () {
|
335 |
+
var $targetSelect = $( '#' + $( this ).data( 'select-id' ) );
|
336 |
+
$targetSelect.find( 'option' ).prop( 'selected', false ).trigger( 'change' );
|
337 |
+
} );
|
338 |
|
339 |
|
340 |
+
$icons.each( function () {
|
341 |
+
var $container = $( this ),
|
342 |
+
$preview = $container.find( '.yit-icons-manager-icon-preview' ).first(),
|
343 |
+
$text = $container.find( '.yit-icons-manager-icon-text' );
|
344 |
|
345 |
+
$container.on( 'click', '.yit-icons-manager-list li', function ( event ) {
|
346 |
+
var $target = $( event.target ).closest( 'li' ),
|
347 |
+
font = $target.data( 'font' ),
|
348 |
+
icon = $target.data( 'icon' ),
|
349 |
+
key = $target.data( 'key' ),
|
350 |
+
name = $target.data( 'name' );
|
351 |
|
352 |
+
$preview.attr( 'data-font', font );
|
353 |
+
$preview.attr( 'data-icon', icon );
|
354 |
+
$preview.attr( 'data-key', key );
|
355 |
+
$preview.attr( 'data-name', name );
|
356 |
|
357 |
+
$text.val( font + ':' + name );
|
358 |
|
359 |
+
$container.find( '.yit-icons-manager-list li' ).removeClass( 'active' );
|
360 |
+
$target.addClass( 'active' );
|
361 |
+
} );
|
362 |
|
363 |
+
$container.on( 'click', '.yit-icons-manager-action-set-default', function () {
|
364 |
+
$container.find( '.yit-icons-manager-list li.default' ).trigger( 'click' );
|
365 |
+
} );
|
366 |
+
} );
|
367 |
|
368 |
/** Select Images */
|
369 |
+
$( document ).on( 'click', '.yith-plugin-fw-select-images__item', function () {
|
370 |
+
var item = $( this ),
|
371 |
+
key = item.data( 'key' ),
|
372 |
+
wrapper = item.closest( '.yith-plugin-fw-select-images__wrapper' ),
|
373 |
+
items = wrapper.find( '.yith-plugin-fw-select-images__item' ),
|
374 |
+
select = wrapper.find( 'select' ).first();
|
375 |
+
|
376 |
+
if ( select.length ) {
|
377 |
+
select.val( key );
|
378 |
+
items.removeClass( 'yith-plugin-fw-select-images__item--selected' );
|
379 |
+
item.addClass( 'yith-plugin-fw-select-images__item--selected' );
|
380 |
}
|
381 |
+
} );
|
382 |
|
383 |
+
$( document.body ).trigger( 'wc-enhanced-select-init' );
|
384 |
|
385 |
+
$( document ).find( '.ui-sortable .yith-toggle-elements' ).sortable(
|
386 |
{
|
387 |
+
cursor : 'move',
|
388 |
+
axis : 'y',
|
389 |
+
scrollSensitivity : 40,
|
390 |
forcePlaceholderSize: true,
|
391 |
+
helper : 'clone',
|
392 |
|
393 |
+
stop: function ( event, ui ) {
|
394 |
+
var keys = jQuery( '.ui-sortable-handle' ),
|
395 |
+
i = 0,
|
396 |
array_keys = new Array();
|
397 |
+
for ( i = 0; i < keys.length; i++ ) {
|
398 |
+
array_keys[ i ] = $( keys[ i ] ).data( 'item_key' );
|
399 |
}
|
400 |
+
if ( array_keys.length > 0 ) {
|
401 |
+
var toggle = $( this ).closest( '.toggle-element' );
|
402 |
+
toggle.saveToggleElement( null, array_keys );
|
403 |
}
|
404 |
}
|
405 |
}
|
406 |
);
|
407 |
|
408 |
+
$.each( $checkgroup, function () {
|
409 |
+
var children = $( this ).find( 'fieldset' );
|
410 |
+
if ( children.length > 3 && children.length < 6 ) {
|
411 |
+
$( this ).addClass( 'two-cols' )
|
412 |
}
|
413 |
+
if ( children.length > 6 ) {
|
414 |
+
$( this ).addClass( 'three-cols' )
|
415 |
}
|
416 |
+
} );
|
417 |
|
418 |
+
$( document.body ).trigger( 'yith-framework-enhanced-select-init' );
|
419 |
};
|
420 |
|
421 |
yith_fields_init();
|
422 |
|
423 |
/* on-off */
|
424 |
+
$( document ).on( 'click', '.yith-plugin-fw-onoff-container span', function () {
|
425 |
+
var input = $( this ).prev( 'input' ),
|
426 |
+
checked = input.prop( 'checked' );
|
427 |
|
428 |
+
if ( checked ) {
|
429 |
+
input.prop( 'checked', false ).attr( 'value', 'no' ).removeClass( 'onoffchecked' );
|
430 |
} else {
|
431 |
+
input.prop( 'checked', true ).attr( 'value', 'yes' ).addClass( 'onoffchecked' );
|
432 |
}
|
433 |
|
434 |
input.change();
|
435 |
+
} );
|
436 |
|
437 |
|
438 |
/** Toggle **/
|
440 |
|
441 |
|
442 |
//TOGGLE ELEMENT
|
443 |
+
$.fn.saveToggleElement = function ( spinner, array_keys ) {
|
444 |
+
var toggle = $( this ),
|
445 |
+
action = 'yith_plugin_fw_save_toggle_element',
|
446 |
+
formdata = toggle.serializeToggleElement(),
|
447 |
+
id = toggle.find( '.yith-toggle_wrapper' ).attr( 'id' ),
|
448 |
+
current_tab = $.urlParam( 'tab' );
|
449 |
+
|
450 |
+
if ( typeof array_keys != 'undefined' && array_keys.length > 0 ) {
|
451 |
+
formdata.append( 'yith_toggle_elements_order_keys', array_keys );
|
452 |
}
|
453 |
|
454 |
+
if ( toggle.closest( '.metaboxes-tab.yith-plugin-ui' ).length ) {
|
455 |
+
action = 'yith_plugin_fw_save_toggle_element_metabox';
|
456 |
+
post_id = $( this ).closest( 'form#post' ).find( '#post_ID' ).val();
|
457 |
+
yit_metaboxes_nonce = $( this ).closest( 'form#post' ).find( '#yit_metaboxes_nonce' ).val();
|
458 |
+
url = yith_framework_fw_fields.ajax_url + '?action=' + action + "&post_ID=" + post_id + '&yit_metaboxes_nonce=' + yit_metaboxes_nonce + "&toggle_id=" + id;
|
459 |
} else {
|
460 |
url = yith_framework_fw_fields.admin_url + '?action=' + action + '&tab=' + current_tab + "&toggle_id=" + id;
|
461 |
}
|
462 |
|
463 |
+
$.ajax( {
|
464 |
+
type : "POST",
|
465 |
+
url : url,
|
466 |
+
data : formdata,
|
467 |
+
contentType: false,
|
468 |
+
processData: false,
|
469 |
+
success : function ( result ) {
|
470 |
+
if ( spinner ) {
|
471 |
+
spinner.removeClass( 'show' );
|
472 |
+
}
|
473 |
|
474 |
+
$( document ).trigger( 'yith_save_toggle_element_done', [ result, toggle ] );
|
475 |
+
}
|
476 |
+
} );
|
477 |
};
|
478 |
|
479 |
$.fn.serializeToggleElement = function () {
|
480 |
+
var obj = $( this );
|
481 |
/* ADD FILE TO PARAM AJAX */
|
482 |
var formData = new FormData();
|
483 |
+
var params = $( obj ).find( ":input" ).serializeArray();
|
484 |
|
485 |
+
$.each( params, function ( i, val ) {
|
486 |
el_name = val.name;
|
487 |
+
formData.append( val.name, val.value );
|
488 |
+
} );
|
489 |
|
490 |
return formData;
|
491 |
};
|
492 |
|
493 |
$.fn.formatToggleTitle = function () {
|
494 |
+
var toggle_el = $( this ),
|
495 |
+
fields = toggle_el.find( ':input' ),
|
496 |
+
title = toggle_el.find( 'span.title' ).data( 'title_format' ),
|
497 |
+
subtitle = toggle_el.find( '.subtitle' ).data( 'subtitle_format' ),
|
498 |
+
regExp = new RegExp( "[^%%]+(?=[%%])", 'g' );
|
499 |
|
500 |
+
if ( typeof title != 'undefined' ) {
|
501 |
var res = title.match( regExp );
|
502 |
}
|
503 |
|
504 |
+
if ( typeof subtitle != 'undefined' ) {
|
505 |
var ressub = subtitle.match( regExp );
|
506 |
}
|
507 |
|
508 |
+
$.each( fields, function ( i, field ) {
|
509 |
+
if ( typeof $( field ).attr( 'id' ) != 'undefined' ) {
|
510 |
+
$field_id = $( field ).attr( 'id' );
|
511 |
+
$field_array = $field_id.split( '_' );
|
512 |
$field_array.pop();
|
513 |
+
$field_id = $field_array.join( '_' );
|
514 |
+
$field_val = $( field ).val();
|
515 |
|
516 |
+
if ( res != null && typeof res != 'undefined' && res.indexOf( $field_id ) !== -1 ) {
|
517 |
+
title = title.replace( '%%' + $field_id + '%%', $field_val );
|
518 |
}
|
519 |
+
if ( ressub != null && typeof ressub != 'undefined' && ressub.indexOf( $field_id ) !== -1 ) {
|
520 |
+
subtitle = subtitle.replace( '%%' + $field_id + '%%', $field_val );
|
521 |
}
|
522 |
}
|
523 |
+
} );
|
524 |
|
525 |
+
if ( '' !== title ) {
|
526 |
+
toggle_el.find( 'span.title' ).html( title );
|
527 |
}
|
528 |
|
529 |
+
if ( '' !== subtitle ) {
|
530 |
+
toggle_el.find( '.subtitle' ).html( subtitle );
|
531 |
}
|
532 |
|
533 |
+
$( document ).trigger( 'yith-toggle-element-item-title', [ toggle_el ] );
|
534 |
};
|
535 |
|
536 |
+
$.urlParam = function ( name ) {
|
537 |
+
var results = new RegExp( '[\?&]' + name + '=([^&#]*)' )
|
538 |
+
.exec( window.location.search );
|
539 |
|
540 |
+
return ( results !== null ) ? results[ 1 ] || 0 : false;
|
541 |
};
|
542 |
|
543 |
+
$( document ).on( 'click', '.yith-toggle-title', function ( event ) {
|
544 |
+
var _toggle = $( event.target ),
|
545 |
+
_section = _toggle.closest( '.yith-toggle-row' ),
|
546 |
+
_content = _section.find( '.yith-toggle-content' );
|
547 |
+
|
548 |
+
if ( _toggle.hasClass( 'yith-plugin-fw-onoff' ) || _toggle.hasClass( 'icon-drag' ) ) {
|
549 |
+
return false;
|
550 |
+
}
|
551 |
|
552 |
+
if ( _section.is( '.yith-toggle-row-opened' ) ) {
|
553 |
+
_content.slideUp( 400 );
|
554 |
} else {
|
555 |
+
_content.slideDown( 400 );
|
556 |
}
|
557 |
+
_section.toggleClass( 'yith-toggle-row-opened' );
|
558 |
+
} );
|
559 |
|
560 |
/**Add new box toggle**/
|
561 |
+
$( document ).on( 'click', '.yith-add-box-button', function ( event ) {
|
562 |
event.preventDefault();
|
563 |
+
var target_id = $( this ).data( 'box_id' ),
|
564 |
+
id = $( this ).closest( '.yith-toggle_wrapper' ).attr( 'id' );
|
565 |
+
template = wp.template( 'yith-toggle-element-add-box-content-' + id );
|
566 |
+
if ( '' !== target_id ) {
|
567 |
+
$( '#' + target_id ).html( template( { index: 'box_id' } ) ).slideToggle();
|
568 |
yith_fields_init();
|
569 |
+
$( document ).trigger( 'yith-add-box-button-toggle', [ $( this ) ] );
|
570 |
}
|
571 |
+
} );
|
572 |
|
573 |
+
$( document ).on( 'click', '.yith-add-box-buttons .yith-save-button', function ( event ) {
|
574 |
event.preventDefault();
|
575 |
+
var add_box = $( this ).parents( '.yith-add-box' ),
|
576 |
+
id = $( this ).closest( '.yith-toggle_wrapper' ).attr( 'id' ),
|
577 |
+
spinner = add_box.find( '.spinner' ),
|
578 |
+
toggle_element = $( this ).parents( '.toggle-element' ),
|
579 |
+
fields = add_box.find( ':input' ),
|
580 |
+
counter = toggle_element.find( '.yith-toggle-row' ).length,
|
581 |
+
hidden_obj = $( '<input type="hidden">' );
|
582 |
+
hidden_obj.val( counter );
|
583 |
+
$( document ).trigger( 'yith-toggle-change-counter', [ hidden_obj, add_box ] );
|
584 |
+
|
585 |
+
counter = hidden_obj.val();
|
586 |
+
var template = wp.template( 'yith-toggle-element-item-' + id ),
|
587 |
+
toggle_el = $( template( { index: counter } ) );
|
588 |
+
|
589 |
+
spinner.addClass( 'show' );
|
590 |
+
|
591 |
+
$.each( fields, function ( i, field ) {
|
592 |
+
if ( typeof $( field ).attr( 'id' ) != 'undefined' ) {
|
593 |
+
|
594 |
+
$field_id = $( field ).attr( 'id' );
|
595 |
+
$field_val = $( field ).val();
|
596 |
+
|
597 |
+
if ( 'radio' == $( field ).attr( 'type' ) ) {
|
598 |
+
$field_id = $field_id.replace( 'new_', '' );
|
599 |
+
$field_id = $field_id.replace( '-' + $field_val, '' );
|
600 |
$field_id = $field_id + '_dataindex-' + $field_val;
|
601 |
} else {
|
602 |
+
$field_id = $field_id.replace( 'new_', '' ) + '_' + counter;
|
603 |
}
|
604 |
|
605 |
+
if ( $( field ).is( ':checked' ) ) {
|
606 |
+
$( toggle_el ).find( '#' + $field_id ).prop( 'checked', true );
|
607 |
}
|
608 |
|
609 |
+
if ( $( field ).hasClass( 'yith-post-search' ) || $( field ).hasClass( 'yith-term-search' ) ) {
|
610 |
+
$( toggle_el ).find( '#' + $field_id ).html( $( '#' + $( field ).attr( 'id' ) ).html() );
|
611 |
}
|
612 |
|
613 |
+
$( toggle_el ).find( '#' + $field_id ).val( $field_val );
|
614 |
|
615 |
}
|
616 |
|
617 |
+
} );
|
618 |
|
619 |
+
$( toggle_el ).formatToggleTitle();
|
620 |
+
var form_is_valid = $( '<input type="hidden">' ).val( 'yes' );
|
621 |
+
$( document ).trigger( 'yith-toggle-element-item-before-add', [ add_box, toggle_el, form_is_valid ] );
|
622 |
|
623 |
|
624 |
+
if ( form_is_valid.val() === 'yes' ) {
|
625 |
+
$( toggle_element ).find( '.yith-toggle-elements' ).append( toggle_el );
|
626 |
+
$( add_box ).find( '.yith-plugin-fw-datepicker' ).datepicker( 'destroy' );
|
627 |
+
$( add_box ).html( '' ).toggle();
|
628 |
toggle_element.saveToggleElement();
|
629 |
yith_fields_init();
|
630 |
}
|
631 |
+
} );
|
632 |
|
633 |
+
$( document ).on( 'click', '.yith-toggle-row .yith-save-button', function ( event ) {
|
634 |
event.preventDefault();
|
635 |
+
var toggle = $( this ).closest( '.toggle-element' ),
|
636 |
+
toggle_row = $( this ).closest( '.yith-toggle-row' ),
|
637 |
+
spinner = toggle_row.find( '.spinner' );
|
638 |
toggle_row.formatToggleTitle();
|
639 |
|
640 |
+
var form_is_valid = $( '<input type="hidden">' ).val( 'yes' );
|
641 |
+
$( document ).trigger( 'yith-toggle-element-item-before-update', [ toggle, toggle_row, form_is_valid ] );
|
642 |
+
if ( form_is_valid.val() === 'yes' ) {
|
643 |
+
spinner.addClass( 'show' );
|
644 |
+
toggle.saveToggleElement( spinner );
|
645 |
}
|
646 |
+
} );
|
647 |
|
648 |
//register remove the dome and save the toggle
|
649 |
+
$( document ).on( 'click', '.yith-toggle-row .yith-delete-button', function ( event ) {
|
650 |
event.preventDefault();
|
651 |
+
var toggle = $( this ).closest( '.toggle-element' ),
|
652 |
+
toggle_row = $( this ).closest( '.yith-toggle-row' );
|
653 |
toggle_row.remove();
|
654 |
toggle.saveToggleElement();
|
655 |
+
} );
|
656 |
|
657 |
//register onoff status
|
658 |
+
$( document ).on( 'click', '.yith-toggle-onoff', function ( event ) {
|
659 |
event.preventDefault();
|
660 |
+
var toggle = $( this ).closest( '.toggle-element' );
|
661 |
toggle.saveToggleElement();
|
662 |
+
} );
|
663 |
+
|
664 |
+
// Radio
|
665 |
+
$( document ).on( 'click', '.yith-plugin-fw-radio input[type=radio]', function () {
|
666 |
+
$( this ).closest( '.yith-plugin-fw-radio' ).val( $( this ).val() ).trigger( 'change' );
|
667 |
+
} );
|
668 |
|
669 |
+
$( '.yith-plugin-fw-radio' ).each( function () {
|
670 |
+
$( this ).val( $( this ).attr( 'value' ) );
|
671 |
+
} );
|
672 |
|
673 |
+
} );
|
plugin-fw/assets/js/yith-fields.min.js
CHANGED
@@ -1 +1,27 @@
|
|
1 |
-
jQuery(function(g){function f(){var e=g(".yith-plugin-fw-datepicker"),t=g(".yith-plugin-fw-colorpicker"),n={imgPreviewHandler:".yith-plugin-fw-upload-img-preview",uploadButtonHandler:".yith-plugin-fw-upload-button",imgUrlHandler:".yith-plugin-fw-upload-img-url",resetButtonHandler:".yith-plugin-fw-upload-button-reset",imgUrl:g(".yith-plugin-fw-upload-img-url")},i=g(".add_media"),a={sliderWrapper:g(".yith-plugin-fw .image-gallery ul.slides-wrapper"),buttonHandler:".yith-plugin-fw .image-gallery-button"},l=g(".yith-plugin-fw-sidebar-layout"),o=g(".yith-plugin-fw .yith-plugin-fw-slider-container .ui-slider-horizontal"),r=g(".codemirror"),d=g(".yit-icons-manager-wrapper"),s=g(".yith-plugin-ui td.forminp-checkbox");if(e.each(function(){var e=g(this).data();g(this).datepicker(e)}),t.wpColorPicker({palettes:!1,width:200,mode:"hsl",clear:function(){var e=g(this);e.val(e.data("default-color")),e.change()}}),t.each(function(){var e=g(this).data("variations-label"),t=g(this).closest(".yith-plugin-fw-field-wrapper"),i=t.find(".wp-picker-input-wrap");if(t.find("a.wp-color-result").attr("title",e),!i.find(".wp-picker-clear-custom").length){var a=g("<span/>").attr({class:"wp-picker-default-custom"});i.find(".wp-picker-default").wrap(a)}}),"undefined"!=typeof wp&&void 0!==wp.media){n.imgUrl.change(function(){var e=g(this).val(),t=new RegExp("(http|ftp|https)://[a-zA-Z0-9@?^=%&:/~+#-_.]*.(gif|jpg|jpeg|png|ico)"),i=g(this).parent().find(n.imgPreviewHandler).first();i.length<1&&(i=g(this).parent().parent().find(n.imgPreviewHandler).first()),t.test(e)?i.html('<img src="'+e+'" style="max-width:100px; max-height:100px;" />'):i.html("")}).trigger("change"),g(document).on("click",n.uploadButtonHandler,function(e){e.preventDefault();var t,i=g(this).attr("id").replace(/-button$/,"");if(t)t.open();else{var a=[new wp.media.controller.Library({library:wp.media.query(),multiple:!1,title:"Choose Image",priority:20,filterable:"uploaded"})];(t=wp.media.frames.downloadable_file=wp.media({title:"Choose Image",library:{type:""},button:{text:"Choose Image"},multiple:!1,states:a})).on("select",function(){var e=t.state().get("selection").first().toJSON();g("#"+i).val(e.url),g("#"+i+"-yith-attachment-id")&&g("#"+i+"-yith-attachment-id").val(e.id),n.imgUrl.trigger("change")}),t.open()}}),g(document).on("click",n.resetButtonHandler,function(e){var t=g(this),i=t.attr("id"),a=t.attr("id").replace(/-button-reset$/,""),l=g("#"+i).data("default");g("#"+a).val(l),n.imgUrl.trigger("change")})}i.on("click",function(){!1}),"undefined"!=typeof wp&&void 0!==wp.media&&(g(document).on("click",a.buttonHandler,function(e){var t=g(this),i=t.closest(".image-gallery"),a=i.find(".image_gallery_ids"),l=a.val(),n=i.find("ul.slides-wrapper"),o=wp.media.frames.image_gallery=wp.media({title:t.data("choose"),button:{text:t.data("update")},states:[new wp.media.controller.Library({title:t.data("choose"),filterable:"all",multiple:!0})]});o.on("select",function(){o.state().get("selection").map(function(e){(e=e.toJSON()).id&&(l=l?l+","+e.id:e.id,n.append('<li class="image" data-attachment_id="'+e.id+'"><img src="'+e.sizes.thumbnail.url+'"/><ul class="actions"><li><a href="#" class="delete" title="'+t.data("delete")+'">x</a></li></ul></li>'))}),a.val(l)}),o.open()}),a.sliderWrapper.each(function(){var a=g(this);a.sortable({items:"li.image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,start:function(e,t){t.item.css("background-color","#f6f6f6")},stop:function(e,t){t.item.removeAttr("style")},update:function(e,t){var i="";a.find("li.image").css("cursor","default").each(function(){var e=g(this).attr("data-attachment_id");i=i+e+","}),a.closest(".image-gallery").find(".image_gallery_ids").val(i)}})}),a.sliderWrapper.on("click","a.delete",function(){var e=g(this).closest(".image-gallery"),t=g(this).closest(".image-gallery ul.slides-wrapper"),i=e.find(".image_gallery_ids"),a="";g(this).closest("li.image").remove(),t.find("li.image").css("cursor","default").each(function(){var e=g(this).attr("data-attachment_id");a=a+e+","}),i.val(a)})),l.each(function(){g(this).find("img").on("click",function(){var e=g(this).closest(".yith-plugin-fw-sidebar-layout"),t=e.find(".yith-plugin-fw-sidebar-layout-sidebar-left-container"),i=e.find(".yith-plugin-fw-sidebar-layout-sidebar-right-container"),a=g(this).data("type");if(g(this).parent().children(":radio").attr("checked",!1),g(this).prev(":radio").attr("checked",!0),void 0!==a)switch(a){case"left":t.show(),i.hide();break;case"right":i.show(),t.hide();break;case"double":t.show(),i.show();break;default:t.hide(),i.hide()}})}),o.each(function(){var e=g(this).data("val"),t=g(this).data("min"),i=g(this).data("max"),a=g(this).data("step"),l=g(this).data("labels");g(this).slider({value:e,min:t,max:i,range:"min",step:a,create:function(){g(this).find(".ui-slider-handle").text(g(this).slider("value"))},slide:function(e,t){g(this).find("input").val(t.value),g(this).find(".ui-slider-handle").text(t.value),g(this).siblings(".feedback").find("strong").text(t.value+l)}})}),r.each(function(e,t){var i=CodeMirror.fromTextArea(t,{lineNumbers:1,mode:"javascript",showCursorWhenSelecting:!0});g(t).data("codemirrorInstance",i)}),g(document).on("click",".yith-plugin-fw-select-all",function(){g("#"+g(this).data("select-id")).find("option").prop("selected",!0).trigger("change")}),g(document).on("click",".yith-plugin-fw-deselect-all",function(){g("#"+g(this).data("select-id")).find("option").prop("selected",!1).trigger("change")}),d.each(function(){var o=g(this),r=o.find(".yit-icons-manager-icon-preview").first(),d=o.find(".yit-icons-manager-icon-text");o.on("click",".yit-icons-manager-list li",function(e){var t=g(e.target).closest("li"),i=t.data("font"),a=t.data("icon"),l=t.data("key"),n=t.data("name");r.attr("data-font",i),r.attr("data-icon",a),r.attr("data-key",l),r.attr("data-name",n),d.val(i+":"+n),o.find(".yit-icons-manager-list li").removeClass("active"),t.addClass("active")}),o.on("click",".yit-icons-manager-action-set-default",function(){o.find(".yit-icons-manager-list li.default").trigger("click")})}),g(document).on("click",".yith-plugin-fw-select-images__item",function(){var e=g(this),t=e.data("key"),i=e.closest(".yith-plugin-fw-select-images__wrapper"),a=i.find(".yith-plugin-fw-select-images__item"),l=i.find("select").first();l.length&&(l.val(t),a.removeClass("yith-plugin-fw-select-images__item--selected"),e.addClass("yith-plugin-fw-select-images__item--selected"))}),g(document.body).trigger("wc-enhanced-select-init"),g(document).find(".ui-sortable .yith-toggle-elements").sortable({cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",stop:function(e,t){var i=jQuery(".ui-sortable-handle"),a=0,l=new Array;for(a=0;a<i.length;a++)l[a]=g(i[a]).data("item_key");0<l.length&&g(this).closest(".toggle-element").saveToggleElement(null,l)}}),g.each(s,function(){var e=g(this).find("fieldset");3<e.length&&e.length<6&&g(this).addClass("two-cols"),6<e.length&&g(this).addClass("three-cols")}),g(document.body).trigger("yith-framework-enhanced-select-init")}f(),g(document).on("click",".yith-plugin-fw-onoff-container span",function(){var e=g(this).prev("input");e.prop("checked")?e.prop("checked",!1).attr("value","no").removeClass("onoffchecked"):e.prop("checked",!0).attr("value","yes").addClass("onoffchecked"),e.change()}),g.fn.saveToggleElement=function(t,e){var i=g(this),a="yith_plugin_fw_save_toggle_element",l=i.serializeToggleElement(),n=i.find(".yith-toggle_wrapper").attr("id"),o=g.urlParam("tab");void 0!==e&&0<e.length&&l.append("yith_toggle_elements_order_keys",e),i.closest(".metaboxes-tab.yith-plugin-ui").length?(a="yith_plugin_fw_save_toggle_element_metabox",post_id=g(this).closest("form#post").find("#post_ID").val(),yit_metaboxes_nonce=g(this).closest("form#post").find("#yit_metaboxes_nonce").val(),url=yith_framework_fw_fields.ajax_url+"?action="+a+"&post_ID="+post_id+"&yit_metaboxes_nonce="+yit_metaboxes_nonce+"&toggle_id="+n):url=yith_framework_fw_fields.admin_url+"?action="+a+"&tab="+o+"&toggle_id="+n,g.ajax({type:"POST",url:url,data:l,contentType:!1,processData:!1,success:function(e){t&&t.removeClass("show"),g(document).trigger("yith_save_toggle_element_done",[e,i])}})},g.fn.serializeToggleElement=function(){var e=g(this),i=new FormData,t=g(e).find(":input").serializeArray();return g.each(t,function(e,t){el_name=t.name,i.append(t.name,t.value)}),i},g.fn.formatToggleTitle=function(){var e=g(this),t=e.find(":input"),i=e.find("span.title").data("title_format"),a=e.find(".subtitle").data("subtitle_format"),l=new RegExp("[^%%]+(?=[%%])","g");if(void 0!==i)var n=i.match(l);if(void 0!==a)var o=a.match(l);g.each(t,function(e,t){void 0!==g(t).attr("id")&&($field_id=g(t).attr("id"),$field_array=$field_id.split("_"),$field_array.pop(),$field_id=$field_array.join("_"),$field_val=g(t).val(),null!=n&&void 0!==n&&-1!==n.indexOf($field_id)&&(i=i.replace("%%"+$field_id+"%%",$field_val)),null!=o&&void 0!==o&&-1!==o.indexOf($field_id)&&(a=a.replace("%%"+$field_id+"%%",$field_val)))}),""!==i&&e.find("span.title").html(i),""!==a&&e.find(".subtitle").html(a),g(document).trigger("yith-toggle-element-item-title",[e])},g.urlParam=function(e){var t=new RegExp("[?&]"+e+"=([^&#]*)").exec(window.location.search);return null!==t&&(t[1]||0)},g(document).on("click",".yith-toggle",function(e){var t=g(e.target).closest(".yith-toggle-row"),i=t.find(".yith-toggle-content");t.is(".yith-toggle-row-opened")?i.slideUp(400):i.slideDown(400),t.toggleClass("yith-toggle-row-opened")}),g(document).on("click",".yith-add-box-button",function(e){e.preventDefault();var t=g(this).data("box_id"),i=g(this).closest(".yith-toggle_wrapper").attr("id");template=wp.template("yith-toggle-element-add-box-content-"+i),""!==t&&(g("#"+t).html(template({index:"box_id"})).slideToggle(),f(),g(document).trigger("yith-add-box-button-toggle",[g(this)]))}),g(document).on("click",".yith-add-box-buttons .yith-save-button",function(e){e.preventDefault();var t=g(this).parents(".yith-add-box"),i=g(this).closest(".yith-toggle_wrapper").attr("id"),a=t.find(".spinner"),l=g(this).parents(".toggle-element"),n=t.find(":input"),o=l.find(".yith-toggle-row").length,r=g('<input type="hidden">');r.val(o),g(document).trigger("yith-toggle-change-counter",[r,t]),o=r.val();var d=wp.template("yith-toggle-element-item-"+i),s=g(d({index:o}));a.addClass("show"),g.each(n,function(e,t){void 0!==g(t).attr("id")&&($field_id=g(t).attr("id"),$field_val=g(t).val(),"radio"==g(t).attr("type")?($field_id=$field_id.replace("new_",""),$field_id=$field_id.replace("-"+$field_val,""),$field_id=$field_id+"_dataindex-"+$field_val):$field_id=$field_id.replace("new_","")+"_"+o,g(t).is(":checked")&&g(s).find("#"+$field_id).prop("checked",!0),(g(t).hasClass("yith-post-search")||g(t).hasClass("yith-term-search"))&&g(s).find("#"+$field_id).html(g("#"+g(t).attr("id")).html()),g(s).find("#"+$field_id).val($field_val))}),g(s).formatToggleTitle();var c=g('<input type="hidden">').val("yes");g(document).trigger("yith-toggle-element-item-before-add",[t,s,c]),"yes"===c.val()&&(g(l).find(".yith-toggle-elements").append(s),g(t).find(".yith-plugin-fw-datepicker").datepicker("destroy"),g(t).html("").toggle(),l.saveToggleElement(),f())}),g(document).on("click",".yith-toggle-row .yith-save-button",function(e){e.preventDefault();var t=g(this).closest(".toggle-element"),i=g(this).closest(".yith-toggle-row"),a=i.find(".spinner");i.formatToggleTitle();var l=g('<input type="hidden">').val("yes");g(document).trigger("yith-toggle-element-item-before-update",[t,i,l]),"yes"===l.val()&&(a.addClass("show"),t.saveToggleElement(a))}),g(document).on("click",".yith-toggle-row .yith-delete-button",function(e){e.preventDefault();var t=g(this).closest(".toggle-element");g(this).closest(".yith-toggle-row").remove(),t.saveToggleElement()}),g(document).on("click",".yith-toggle-onoff",function(e){e.preventDefault(),g(this).closest(".toggle-element").saveToggleElement()})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,g,b){a instanceof String&&(a=String(a));for(var d=a.length,c=0;c<d;c++){var e=a[c];if(g.call(b,e,c,a))return{i:c,v:e}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,g,b){a!=Array.prototype&&a!=Object.prototype&&(a[g]=b.value)};
|
2 |
+
$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(a,g,b,d){if(g){b=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var c=a[d];c in b||(b[c]={});b=b[c]}a=a[a.length-1];d=b[a];g=g(d);g!=d&&null!=g&&$jscomp.defineProperty(b,a,{configurable:!0,writable:!0,value:g})}};
|
3 |
+
$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,b){return $jscomp.findInternal(this,a,b).v}},"es6","es3");
|
4 |
+
jQuery(function(a){var g=function(){var b=a(".yith-plugin-fw-datepicker"),d=a(".yith-plugin-fw-colorpicker"),c=a(".yith-plugin-fw-upload-img-url"),e=a(".add_media"),g=a(".yith-plugin-fw .image-gallery ul.slides-wrapper"),h=a(".yith-plugin-fw-sidebar-layout"),l=a(".yith-plugin-fw .yith-plugin-fw-slider-container .ui-slider-horizontal"),m=a(".codemirror"),p=a(".yit-icons-manager-wrapper"),q=a(".yith-plugin-ui td.forminp-checkbox");b.each(function(){var b=a(this).data();a(this).datepicker(b)});d.wpColorPicker({palettes:!1,
|
5 |
+
width:200,mode:"hsl",clear:function(){var b=a(this);b.val(b.data("default-color"));b.change()}});d.each(function(){var b=a(this).data("variations-label"),f=a(this).closest(".yith-plugin-fw-colorpicker-field-wrapper"),c=a(this).closest(".yith-single-colorpicker"),d=f.find(".wp-picker-input-wrap"),e=c.find(".wp-picker-input-wrap");d.length&&f.find("a.wp-color-result").attr("title",b);c.length&&c.find("a.wp-color-result").attr("title",b);d.find(".wp-picker-clear-custom").length||(b=a("<span/>").attr({class:"wp-picker-default-custom"}),
|
6 |
+
d.find(".wp-picker-default").wrap(b));e.find(".wp-picker-clear-custom").length||(b=a("<span/>").attr({class:"wp-picker-default-custom"}),e.find(".wp-picker-default").wrap(b))});"undefined"!==typeof wp&&"undefined"!==typeof wp.media&&(c.change(function(){var b=a(this).val(),f=a(this).parent().find(".yith-plugin-fw-upload-img-preview").first();1>f.length&&(f=a(this).parent().parent().find(".yith-plugin-fw-upload-img-preview").first());/(http|ftp|https):\/\/[a-zA-Z0-9@?^=%&:/~+#-_.]*.(gif|jpg|jpeg|png|ico)/.test(b)?
|
7 |
+
f.html('<img src="'+b+'" style="max-width:100px; max-height:100px;" />'):f.html("")}).trigger("change"),a(document).on("click",".yith-plugin-fw-upload-button",function(b){b.preventDefault();var f=a(this).attr("id").replace(/-button$/,"");if(!k){b=[new wp.media.controller.Library({library:wp.media.query(),multiple:!1,title:"Choose Image",priority:20,filterable:"uploaded"})];var k=wp.media.frames.downloadable_file=wp.media({title:"Choose Image",library:{type:""},button:{text:"Choose Image"},multiple:!1,
|
8 |
+
states:b});k.on("select",function(){var b=k.state().get("selection").first().toJSON();a("#"+f).val(b.url);a("#"+f+"-yith-attachment-id")&&a("#"+f+"-yith-attachment-id").val(b.id);c.trigger("change")})}k.open()}),a(document).on("click",".yith-plugin-fw-upload-button-reset",function(b){var f=a(this);b=f.attr("id");f=f.attr("id").replace(/-button-reset$/,"");b=a("#"+b).data("default");a("#"+f).val(b);c.trigger("change")}));e.on("click",function(){});"undefined"!==typeof wp&&"undefined"!==typeof wp.media&&
|
9 |
+
(a(document).on("click",".yith-plugin-fw .image-gallery-button",function(b){var f=a(this);b=f.closest(".image-gallery");var k=b.find(".image_gallery_ids"),c=k.val(),d=b.find("ul.slides-wrapper"),e=wp.media.frames.image_gallery=wp.media({title:f.data("choose"),button:{text:f.data("update")},states:[new wp.media.controller.Library({title:f.data("choose"),filterable:"all",multiple:!0})]});e.on("select",function(){e.state().get("selection").map(function(a){a=a.toJSON();a.id&&(c=c?c+","+a.id:a.id,d.append('<li class="image" data-attachment_id="'+
|
10 |
+
a.id+'"><img src="'+a.sizes.thumbnail.url+'"/><ul class="actions"><li><a href="#" class="delete" title="'+f.data("delete")+'">x</a></li></ul></li>'))});k.val(c)});e.open()}),g.each(function(){var b=a(this);b.sortable({items:"li.image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,start:function(a,b){b.item.css("background-color","#f6f6f6")},stop:function(a,b){b.item.removeAttr("style")},update:function(f,c){var k="";b.find("li.image").css("cursor",
|
11 |
+
"default").each(function(){var b=a(this).attr("data-attachment_id");k=k+b+","});b.closest(".image-gallery").find(".image_gallery_ids").val(k)}})}),g.on("click","a.delete",function(){var b=a(this).closest(".image-gallery"),f=a(this).closest(".image-gallery ul.slides-wrapper");b=b.find(".image_gallery_ids");var c="";a(this).closest("li.image").remove();f.find("li.image").css("cursor","default").each(function(){var b=a(this).attr("data-attachment_id");c=c+b+","});b.val(c)}));h.each(function(){a(this).find("img").on("click",
|
12 |
+
function(){var b=a(this).closest(".yith-plugin-fw-sidebar-layout"),c=b.find(".yith-plugin-fw-sidebar-layout-sidebar-left-container");b=b.find(".yith-plugin-fw-sidebar-layout-sidebar-right-container");var d=a(this).data("type");a(this).parent().children(":radio").attr("checked",!1);a(this).prev(":radio").attr("checked",!0);if("undefined"!=typeof d)switch(d){case "left":c.show();b.hide();break;case "right":b.show();c.hide();break;case "double":c.show();b.show();break;default:c.hide(),b.hide()}})});
|
13 |
+
l.each(function(){var b=a(this).data("val"),c=a(this).data("min"),d=a(this).data("max"),e=a(this).data("step"),g=a(this).data("labels");a(this).slider({value:b,min:c,max:d,range:"min",step:e,create:function(){a(this).find(".ui-slider-handle").text(a(this).slider("value"))},slide:function(b,c){a(this).find("input").val(c.value);a(this).find(".ui-slider-handle").text(c.value);a(this).siblings(".feedback").find("strong").text(c.value+g)}})});m.each(function(b,c){b=CodeMirror.fromTextArea(c,{lineNumbers:1,
|
14 |
+
mode:"javascript",showCursorWhenSelecting:!0});a(c).data("codemirrorInstance",b)});a(document).on("click",".yith-plugin-fw-select-all",function(){a("#"+a(this).data("select-id")).find("option").prop("selected",!0).trigger("change")});a(document).on("click",".yith-plugin-fw-deselect-all",function(){a("#"+a(this).data("select-id")).find("option").prop("selected",!1).trigger("change")});p.each(function(){var b=a(this),c=b.find(".yit-icons-manager-icon-preview").first(),d=b.find(".yit-icons-manager-icon-text");
|
15 |
+
b.on("click",".yit-icons-manager-list li",function(e){e=a(e.target).closest("li");var f=e.data("font"),k=e.data("icon"),g=e.data("key"),h=e.data("name");c.attr("data-font",f);c.attr("data-icon",k);c.attr("data-key",g);c.attr("data-name",h);d.val(f+":"+h);b.find(".yit-icons-manager-list li").removeClass("active");e.addClass("active")});b.on("click",".yit-icons-manager-action-set-default",function(){b.find(".yit-icons-manager-list li.default").trigger("click")})});a(document).on("click",".yith-plugin-fw-select-images__item",
|
16 |
+
function(){var b=a(this),c=b.data("key"),d=b.closest(".yith-plugin-fw-select-images__wrapper"),e=d.find(".yith-plugin-fw-select-images__item");d=d.find("select").first();d.length&&(d.val(c),e.removeClass("yith-plugin-fw-select-images__item--selected"),b.addClass("yith-plugin-fw-select-images__item--selected"))});a(document.body).trigger("wc-enhanced-select-init");a(document).find(".ui-sortable .yith-toggle-elements").sortable({cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",
|
17 |
+
stop:function(b,c){b=jQuery(".ui-sortable-handle");var d=[];for(c=0;c<b.length;c++)d[c]=a(b[c]).data("item_key");0<d.length&&a(this).closest(".toggle-element").saveToggleElement(null,d)}});a.each(q,function(){var b=a(this).find("fieldset");3<b.length&&6>b.length&&a(this).addClass("two-cols");6<b.length&&a(this).addClass("three-cols")});a(document.body).trigger("yith-framework-enhanced-select-init")};g();a(document).on("click",".yith-plugin-fw-onoff-container span",function(){var b=a(this).prev("input");
|
18 |
+
b.prop("checked")?b.prop("checked",!1).attr("value","no").removeClass("onoffchecked"):b.prop("checked",!0).attr("value","yes").addClass("onoffchecked");b.change()});a.fn.saveToggleElement=function(b,d){var c=a(this),e="yith_plugin_fw_save_toggle_element",g=c.serializeToggleElement(),h=c.find(".yith-toggle_wrapper").attr("id"),l=a.urlParam("tab");"undefined"!=typeof d&&0<d.length&&g.append("yith_toggle_elements_order_keys",d);c.closest(".metaboxes-tab.yith-plugin-ui").length?(e="yith_plugin_fw_save_toggle_element_metabox",
|
19 |
+
post_id=a(this).closest("form#post").find("#post_ID").val(),yit_metaboxes_nonce=a(this).closest("form#post").find("#yit_metaboxes_nonce").val(),url=yith_framework_fw_fields.ajax_url+"?action="+e+"&post_ID="+post_id+"&yit_metaboxes_nonce="+yit_metaboxes_nonce+"&toggle_id="+h):url=yith_framework_fw_fields.admin_url+"?action="+e+"&tab="+l+"&toggle_id="+h;a.ajax({type:"POST",url:url,data:g,contentType:!1,processData:!1,success:function(d){b&&b.removeClass("show");a(document).trigger("yith_save_toggle_element_done",
|
20 |
+
[d,c])}})};a.fn.serializeToggleElement=function(){var b=a(this),d=new FormData;b=a(b).find(":input").serializeArray();a.each(b,function(a,b){el_name=b.name;d.append(b.name,b.value)});return d};a.fn.formatToggleTitle=function(){var b=a(this),d=b.find(":input"),c=b.find("span.title").data("title_format"),e=b.find(".subtitle").data("subtitle_format"),g=/[^%%]+(?=[%%])/g;if("undefined"!=typeof c)var h=c.match(g);if("undefined"!=typeof e)var l=e.match(g);a.each(d,function(b,d){"undefined"!=typeof a(d).attr("id")&&
|
21 |
+
($field_id=a(d).attr("id"),$field_array=$field_id.split("_"),$field_array.pop(),$field_id=$field_array.join("_"),$field_val=a(d).val(),null!=h&&"undefined"!=typeof h&&-1!==h.indexOf($field_id)&&(c=c.replace("%%"+$field_id+"%%",$field_val)),null!=l&&"undefined"!=typeof l&&-1!==l.indexOf($field_id)&&(e=e.replace("%%"+$field_id+"%%",$field_val)))});""!==c&&b.find("span.title").html(c);""!==e&&b.find(".subtitle").html(e);a(document).trigger("yith-toggle-element-item-title",[b])};a.urlParam=function(a){a=
|
22 |
+
(new RegExp("[?&]"+a+"=([^&#]*)")).exec(window.location.search);return null!==a?a[1]||0:!1};a(document).on("click",".yith-toggle-title",function(b){b=a(b.target);var d=b.closest(".yith-toggle-row"),c=d.find(".yith-toggle-content");if(b.hasClass("yith-plugin-fw-onoff")||b.hasClass("icon-drag"))return!1;d.is(".yith-toggle-row-opened")?c.slideUp(400):c.slideDown(400);d.toggleClass("yith-toggle-row-opened")});a(document).on("click",".yith-add-box-button",function(b){b.preventDefault();b=a(this).data("box_id");
|
23 |
+
var d=a(this).closest(".yith-toggle_wrapper").attr("id");template=wp.template("yith-toggle-element-add-box-content-"+d);""!==b&&(a("#"+b).html(template({index:"box_id"})).slideToggle(),g(),a(document).trigger("yith-add-box-button-toggle",[a(this)]))});a(document).on("click",".yith-add-box-buttons .yith-save-button",function(b){b.preventDefault();b=a(this).parents(".yith-add-box");var d=a(this).closest(".yith-toggle_wrapper").attr("id"),c=b.find(".spinner"),e=a(this).parents(".toggle-element"),n=b.find(":input"),
|
24 |
+
h=e.find(".yith-toggle-row").length,l=a('<input type="hidden">');l.val(h);a(document).trigger("yith-toggle-change-counter",[l,b]);h=l.val();d=wp.template("yith-toggle-element-item-"+d);var m=a(d({index:h}));c.addClass("show");a.each(n,function(b,c){"undefined"!=typeof a(c).attr("id")&&($field_id=a(c).attr("id"),$field_val=a(c).val(),"radio"==a(c).attr("type")?($field_id=$field_id.replace("new_",""),$field_id=$field_id.replace("-"+$field_val,""),$field_id=$field_id+"_dataindex-"+$field_val):$field_id=
|
25 |
+
$field_id.replace("new_","")+"_"+h,a(c).is(":checked")&&a(m).find("#"+$field_id).prop("checked",!0),(a(c).hasClass("yith-post-search")||a(c).hasClass("yith-term-search"))&&a(m).find("#"+$field_id).html(a("#"+a(c).attr("id")).html()),a(m).find("#"+$field_id).val($field_val))});a(m).formatToggleTitle();c=a('<input type="hidden">').val("yes");a(document).trigger("yith-toggle-element-item-before-add",[b,m,c]);"yes"===c.val()&&(a(e).find(".yith-toggle-elements").append(m),a(b).find(".yith-plugin-fw-datepicker").datepicker("destroy"),
|
26 |
+
a(b).html("").toggle(),e.saveToggleElement(),g())});a(document).on("click",".yith-toggle-row .yith-save-button",function(b){b.preventDefault();b=a(this).closest(".toggle-element");var d=a(this).closest(".yith-toggle-row"),c=d.find(".spinner");d.formatToggleTitle();var e=a('<input type="hidden">').val("yes");a(document).trigger("yith-toggle-element-item-before-update",[b,d,e]);"yes"===e.val()&&(c.addClass("show"),b.saveToggleElement(c))});a(document).on("click",".yith-toggle-row .yith-delete-button",
|
27 |
+
function(b){b.preventDefault();b=a(this).closest(".toggle-element");a(this).closest(".yith-toggle-row").remove();b.saveToggleElement()});a(document).on("click",".yith-toggle-onoff",function(b){b.preventDefault();a(this).closest(".toggle-element").saveToggleElement()});a(document).on("click",".yith-plugin-fw-radio input[type=radio]",function(){a(this).closest(".yith-plugin-fw-radio").val(a(this).val()).trigger("change")});a(".yith-plugin-fw-radio").each(function(){a(this).val(a(this).attr("value"))})});
|
plugin-fw/assets/js/yith-system-info.js
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function ($) {
|
2 |
+
$(document).on('click', '.notice-dismiss', function () {
|
3 |
+
var t = $(this),
|
4 |
+
wrapper_id = t.parent().attr('id');
|
5 |
+
|
6 |
+
if (wrapper_id === 'yith-system-alert') {
|
7 |
+
var cname = 'hide_yith_system_alert',
|
8 |
+
cvalue = 'yes';
|
9 |
+
|
10 |
+
document.cookie = cname + "=" + cvalue + ";path=/";
|
11 |
+
}
|
12 |
+
});
|
13 |
+
})(jQuery);
|
plugin-fw/assets/js/yith-system-info.min.js
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function ($) {
|
2 |
+
$(document).on('click', '.notice-dismiss', function () {
|
3 |
+
var t = $(this),
|
4 |
+
wrapper_id = t.parent().attr('id');
|
5 |
+
|
6 |
+
if (wrapper_id === 'yith-system-alert') {
|
7 |
+
var cname = 'hide_yith_system_alert',
|
8 |
+
cvalue = 'yes';
|
9 |
+
|
10 |
+
document.cookie = cname + "=" + cvalue + ";path=/";
|
11 |
+
}
|
12 |
+
});
|
13 |
+
})(jQuery);
|
plugin-fw/init.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Framework Name: YIT Plugin Framework
|
4 |
-
* Version: 3.3.
|
5 |
* Author: YITHEMES
|
6 |
* Text Domain: yith-plugin-fw
|
7 |
* Domain Path: /languages/
|
8 |
*
|
9 |
* @author Your Inspiration Themes
|
10 |
-
* @version 3.3.
|
11 |
*/
|
12 |
/**
|
13 |
* This file belongs to the YIT Plugin Framework.
|
1 |
<?php
|
2 |
/**
|
3 |
* Framework Name: YIT Plugin Framework
|
4 |
+
* Version: 3.3.6
|
5 |
* Author: YITHEMES
|
6 |
* Text Domain: yith-plugin-fw
|
7 |
* Domain Path: /languages/
|
8 |
*
|
9 |
* @author Your Inspiration Themes
|
10 |
+
* @version 3.3.6
|
11 |
*/
|
12 |
/**
|
13 |
* This file belongs to the YIT Plugin Framework.
|
plugin-fw/lib/yit-assets.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* This file belongs to the YIT Plugin Framework.
|
4 |
-
*
|
5 |
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
|
6 |
* that is bundled with this package in the file LICENSE.txt.
|
7 |
* It is also available through the world-wide-web at this URL:
|
@@ -38,7 +37,7 @@ if ( !class_exists( 'YIT_Assets' ) ) {
|
|
38 |
* @author Leanza Francesco <leanzafrancesco@gmail.com>
|
39 |
*/
|
40 |
private function __construct() {
|
41 |
-
|
42 |
add_action( 'admin_enqueue_scripts', array( $this, 'register_styles_and_scripts' ) );
|
43 |
}
|
44 |
|
@@ -51,9 +50,9 @@ if ( !class_exists( 'YIT_Assets' ) ) {
|
|
51 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
52 |
|
53 |
//scripts
|
54 |
-
wp_register_script( 'yith-plugin-fw-fields', YIT_CORE_PLUGIN_URL . '/assets/js/yith-fields' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'wp-color-picker', 'codemirror', 'codemirror-javascript', 'jquery-ui-slider','jquery-ui-sortable' ), $this->version, true );
|
55 |
-
wp_register_script( 'yit-metabox', YIT_CORE_PLUGIN_URL . '/assets/js/metabox' . $suffix . '.js', array( 'jquery', 'wp-color-picker' ), $this->version, true );
|
56 |
-
wp_register_script( 'yit-plugin-panel', YIT_CORE_PLUGIN_URL . '/assets/js/yit-plugin-panel' . $suffix . '.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-sortable' ), $this->version, true );
|
57 |
wp_register_script( 'codemirror', YIT_CORE_PLUGIN_URL . '/assets/js/codemirror/codemirror.js', array( 'jquery' ), $this->version, true );
|
58 |
wp_register_script( 'codemirror-javascript', YIT_CORE_PLUGIN_URL . '/assets/js/codemirror/javascript.js', array( 'jquery', 'codemirror' ), $this->version, true );
|
59 |
wp_register_script( 'colorbox', YIT_CORE_PLUGIN_URL . '/assets/js/jquery.colorbox' . $suffix . '.js', array( 'jquery' ), '1.6.3', true );
|
@@ -88,10 +87,10 @@ if ( !class_exists( 'YIT_Assets' ) ) {
|
|
88 |
'search_terms_nonce' => wp_create_nonce( 'search-terms' ),
|
89 |
) );
|
90 |
|
91 |
-
wp_localize_script('yith-plugin-fw-fields','yith_framework_fw_fields', array(
|
92 |
-
|
93 |
-
|
94 |
-
));
|
95 |
wp_enqueue_style( 'yith-plugin-fw-admin', YIT_CORE_PLUGIN_URL . '/assets/css/admin.css', array(), $this->version );
|
96 |
}
|
97 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* This file belongs to the YIT Plugin Framework.
|
|
|
4 |
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
|
5 |
* that is bundled with this package in the file LICENSE.txt.
|
6 |
* It is also available through the world-wide-web at this URL:
|
37 |
* @author Leanza Francesco <leanzafrancesco@gmail.com>
|
38 |
*/
|
39 |
private function __construct() {
|
40 |
+
defined( 'YITH_PLUGIN_FW_VERSION' ) && $this->version = YITH_PLUGIN_FW_VERSION;
|
41 |
add_action( 'admin_enqueue_scripts', array( $this, 'register_styles_and_scripts' ) );
|
42 |
}
|
43 |
|
50 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
51 |
|
52 |
//scripts
|
53 |
+
wp_register_script( 'yith-plugin-fw-fields', YIT_CORE_PLUGIN_URL . '/assets/js/yith-fields' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'wp-color-picker', 'codemirror', 'codemirror-javascript', 'jquery-ui-slider', 'jquery-ui-sortable' ), $this->version, true );
|
54 |
+
wp_register_script( 'yit-metabox', YIT_CORE_PLUGIN_URL . '/assets/js/metabox' . $suffix . '.js', array( 'jquery', 'wp-color-picker', 'yith-plugin-fw-fields' ), $this->version, true );
|
55 |
+
wp_register_script( 'yit-plugin-panel', YIT_CORE_PLUGIN_URL . '/assets/js/yit-plugin-panel' . $suffix . '.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-sortable', 'yith-plugin-fw-fields' ), $this->version, true );
|
56 |
wp_register_script( 'codemirror', YIT_CORE_PLUGIN_URL . '/assets/js/codemirror/codemirror.js', array( 'jquery' ), $this->version, true );
|
57 |
wp_register_script( 'codemirror-javascript', YIT_CORE_PLUGIN_URL . '/assets/js/codemirror/javascript.js', array( 'jquery', 'codemirror' ), $this->version, true );
|
58 |
wp_register_script( 'colorbox', YIT_CORE_PLUGIN_URL . '/assets/js/jquery.colorbox' . $suffix . '.js', array( 'jquery' ), '1.6.3', true );
|
87 |
'search_terms_nonce' => wp_create_nonce( 'search-terms' ),
|
88 |
) );
|
89 |
|
90 |
+
wp_localize_script( 'yith-plugin-fw-fields', 'yith_framework_fw_fields', array(
|
91 |
+
'admin_url' => admin_url( 'admin.php' ),
|
92 |
+
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
93 |
+
) );
|
94 |
wp_enqueue_style( 'yith-plugin-fw-admin', YIT_CORE_PLUGIN_URL . '/assets/css/admin.css', array(), $this->version );
|
95 |
}
|
96 |
}
|
plugin-fw/lib/yit-plugin-panel-wc.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* This file belongs to the YIT Plugin Framework.
|
4 |
-
*
|
5 |
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
|
6 |
* that is bundled with this package in the file LICENSE.txt.
|
7 |
* It is also available through the world-wide-web at this URL:
|
@@ -15,7 +14,6 @@ if ( !defined( 'ABSPATH' ) ) {
|
|
15 |
if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
16 |
/**
|
17 |
* YIT Plugin Panel for WooCommerce
|
18 |
-
*
|
19 |
* Setting Page to Manage Plugins
|
20 |
*
|
21 |
* @class YIT_Plugin_Panel
|
@@ -47,7 +45,6 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
47 |
public static $body_class = ' yith-plugin-fw-panel ';
|
48 |
|
49 |
|
50 |
-
|
51 |
/**
|
52 |
* @var array
|
53 |
*/
|
@@ -83,7 +80,7 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
83 |
$this->links = $this->settings[ 'links' ];
|
84 |
}
|
85 |
|
86 |
-
|
87 |
add_action( 'admin_menu', array( $this, 'add_setting_page' ) );
|
88 |
add_action( 'admin_menu', array( $this, 'add_premium_version_upgrade_to_menu' ), 100 );
|
89 |
add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_menu' ), 100 );
|
@@ -93,11 +90,10 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
93 |
|
94 |
add_filter( 'woocommerce_admin_settings_sanitize_option', array( $this, 'maybe_unserialize_panel_data' ), 10, 3 );
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
add_filter( 'yith_plugin_fw_wc_panel_pre_field_value', array( $this, 'get_toggle_element_option' ), 10, 2 );
|
101 |
|
102 |
|
103 |
// init actions once to prevent multiple actions
|
@@ -131,7 +127,6 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
131 |
|
132 |
/**
|
133 |
* Show a tabbed panel to setting page
|
134 |
-
*
|
135 |
* a callback function called by add_setting_page => add_submenu_page
|
136 |
*
|
137 |
* @return void
|
@@ -145,7 +140,7 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
145 |
'available_tabs' => $this->settings[ 'admin-tabs' ],
|
146 |
'default_tab' => $this->get_available_tabs( true ), //get default tabs
|
147 |
'page' => $this->settings[ 'page' ],
|
148 |
-
'wrap_class' => isset($this->settings[ 'class' ]) ? $this->settings[ 'class' ] : '',
|
149 |
);
|
150 |
|
151 |
|
@@ -159,7 +154,6 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
159 |
/**
|
160 |
* Show a input fields to upload images
|
161 |
*
|
162 |
-
*
|
163 |
* @return string
|
164 |
* @since 1.0
|
165 |
* @author Emanuela Castorina <emanuela.castorina@yithemes.com>
|
@@ -172,9 +166,7 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
172 |
/**
|
173 |
* Show a input fields to upload images
|
174 |
*
|
175 |
-
*
|
176 |
* @param array $args
|
177 |
-
*
|
178 |
* @since 1.0
|
179 |
* @author Emanuela Castorina <emanuela.castorina@yithemes.com>
|
180 |
*/
|
@@ -192,7 +184,6 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
192 |
* Add the plugin woocommerce page settings in the screen ids of woocommerce
|
193 |
*
|
194 |
* @param $screen_ids
|
195 |
-
*
|
196 |
* @return mixed
|
197 |
* @since 1.0.0
|
198 |
* @author Antonino Scarfì <antonino.scarfi@yithemes.com>
|
@@ -230,11 +221,9 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
230 |
|
231 |
/**
|
232 |
* Return available tabs
|
233 |
-
*
|
234 |
* read all options and show sections and fields
|
235 |
*
|
236 |
* @param bool false for all tabs slug, true for current tab
|
237 |
-
*
|
238 |
* @return mixed Array tabs | String current tab
|
239 |
* @since 1.0
|
240 |
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
@@ -249,7 +238,6 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
249 |
|
250 |
/**
|
251 |
* Add sections and fields to setting panel
|
252 |
-
*
|
253 |
* read all options and show sections and fields
|
254 |
*
|
255 |
* @return void
|
@@ -272,7 +260,6 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
272 |
|
273 |
/**
|
274 |
* Print the panel content
|
275 |
-
*
|
276 |
* check if the tab is a wc options tab or custom tab and print the content
|
277 |
*
|
278 |
* @return void
|
@@ -419,7 +406,6 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
419 |
|
420 |
/**
|
421 |
* Default options
|
422 |
-
*
|
423 |
* Sets up the default options used on the settings page
|
424 |
*
|
425 |
* @access public
|
@@ -460,7 +446,6 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
460 |
* Delete the "default options added" option
|
461 |
*
|
462 |
* @author Leanza Francesco <leanzafrancesco@gmail.com>
|
463 |
-
*
|
464 |
*/
|
465 |
public static function delete_default_options_set_option() {
|
466 |
delete_option( 'yit_plugin_fw_panel_wc_default_options_set' );
|
@@ -471,9 +456,7 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
471 |
*
|
472 |
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
473 |
* @since 2.0
|
474 |
-
*
|
475 |
* @param $classes The body classes
|
476 |
-
*
|
477 |
* @return array Filtered body classes
|
478 |
*/
|
479 |
public static function admin_body_class( $admin_body_classes ) {
|
@@ -491,7 +474,6 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
491 |
* @param $value mixed Option value
|
492 |
* @param $option mixed Option settings array
|
493 |
* @param $raw_value string Raw option value
|
494 |
-
*
|
495 |
* @return mixed Filtered return value
|
496 |
* @author Antonio La Rocca <antonio.larocca@yithemes.com>
|
497 |
* @since 2.0
|
@@ -523,7 +505,6 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
523 |
* @param $value mixed Option value
|
524 |
* @param $option mixed Option settings array
|
525 |
* @param $raw_value string Raw option value
|
526 |
-
*
|
527 |
* @return mixed Filtered return value
|
528 |
* @author Leanza Francesco <leanzafrancesco@gmail.com>
|
529 |
* @since 3.0.0
|
@@ -545,42 +526,42 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
545 |
$value = $raw_value;
|
546 |
}
|
547 |
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
|
554 |
-
|
555 |
|
556 |
-
|
557 |
|
558 |
-
|
559 |
|
560 |
-
|
561 |
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
|
568 |
-
|
569 |
-
|
570 |
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
|
577 |
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
|
582 |
|
583 |
-
|
584 |
$value = call_user_func( $option[ 'yith-sanitize-callback' ], $value );
|
585 |
}
|
586 |
}
|
@@ -592,7 +573,6 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
592 |
* Add YITH Fields
|
593 |
*
|
594 |
* @param array $field
|
595 |
-
*
|
596 |
* @return void
|
597 |
* @since 3.0.0
|
598 |
* @author Leanza Francesco <leanzafrancesco@gmail.com>
|
@@ -608,7 +588,11 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
608 |
|
609 |
$value = apply_filters( 'yith_plugin_fw_wc_panel_pre_field_value', null, $field );
|
610 |
if ( is_null( $value ) ) {
|
611 |
-
|
|
|
|
|
|
|
|
|
612 |
}
|
613 |
$field[ 'value' ] = $value;
|
614 |
|
@@ -616,69 +600,52 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
616 |
}
|
617 |
}
|
618 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
619 |
|
620 |
-
|
621 |
-
* Return the option value for the toggle element to the filter 'yith_plugin_fw_wc_panel_pre_field_value',
|
622 |
-
* it is an array of arrays and could trigger warning if recovered using
|
623 |
-
* WC_Admin_Settings::get_option
|
624 |
-
*
|
625 |
-
* @param $value mixed
|
626 |
-
* @param $field array
|
627 |
-
*
|
628 |
-
* @return $value mixed
|
629 |
-
*
|
630 |
-
* @author Emanuela Castorina
|
631 |
-
*/
|
632 |
-
public function get_toggle_element_option( $value, $field ) {
|
633 |
-
return get_option( $field[ 'id' ], $field[ 'default' ] );
|
634 |
-
}
|
635 |
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
if ( $order_elements ) {
|
667 |
-
$i = 0;
|
668 |
-
$new_value = array();
|
669 |
-
foreach ( $order_elements as $key ) {
|
670 |
-
$index = apply_filters('yith_toggle_elements_index', $i++, $key );
|
671 |
-
$new_value[ $index ] = $value[ $key ];
|
672 |
-
}
|
673 |
-
|
674 |
-
$value = $new_value;
|
675 |
-
}
|
676 |
-
$value = self::sanitize_option( $value, $option_array[ $option_id ], $value );
|
677 |
-
$updated = update_option( $option_id, $value );
|
678 |
-
}
|
679 |
-
}
|
680 |
-
|
681 |
-
return $updated;
|
682 |
-
}
|
683 |
}
|
684 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* This file belongs to the YIT Plugin Framework.
|
|
|
4 |
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
|
5 |
* that is bundled with this package in the file LICENSE.txt.
|
6 |
* It is also available through the world-wide-web at this URL:
|
14 |
if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
15 |
/**
|
16 |
* YIT Plugin Panel for WooCommerce
|
|
|
17 |
* Setting Page to Manage Plugins
|
18 |
*
|
19 |
* @class YIT_Plugin_Panel
|
45 |
public static $body_class = ' yith-plugin-fw-panel ';
|
46 |
|
47 |
|
|
|
48 |
/**
|
49 |
* @var array
|
50 |
*/
|
80 |
$this->links = $this->settings[ 'links' ];
|
81 |
}
|
82 |
|
83 |
+
add_action( 'admin_init', array( $this, 'set_default_options' ) );
|
84 |
add_action( 'admin_menu', array( $this, 'add_setting_page' ) );
|
85 |
add_action( 'admin_menu', array( $this, 'add_premium_version_upgrade_to_menu' ), 100 );
|
86 |
add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_menu' ), 100 );
|
90 |
|
91 |
add_filter( 'woocommerce_admin_settings_sanitize_option', array( $this, 'maybe_unserialize_panel_data' ), 10, 3 );
|
92 |
|
93 |
+
//yith-plugin-ui
|
94 |
+
add_action( 'yith_plugin_fw_get_field_after', array( $this, 'add_yith_ui' ) );
|
95 |
+
add_action( 'yith_plugin_fw_before_woocommerce_panel', array( $this, 'add_plugin_banner' ), 10, 1 );
|
96 |
+
add_action( 'admin_action_yith_plugin_fw_save_toggle_element', array( $this, 'save_toggle_element_options' ) );
|
|
|
97 |
|
98 |
|
99 |
// init actions once to prevent multiple actions
|
127 |
|
128 |
/**
|
129 |
* Show a tabbed panel to setting page
|
|
|
130 |
* a callback function called by add_setting_page => add_submenu_page
|
131 |
*
|
132 |
* @return void
|
140 |
'available_tabs' => $this->settings[ 'admin-tabs' ],
|
141 |
'default_tab' => $this->get_available_tabs( true ), //get default tabs
|
142 |
'page' => $this->settings[ 'page' ],
|
143 |
+
'wrap_class' => isset( $this->settings[ 'class' ] ) ? $this->settings[ 'class' ] : '',
|
144 |
);
|
145 |
|
146 |
|
154 |
/**
|
155 |
* Show a input fields to upload images
|
156 |
*
|
|
|
157 |
* @return string
|
158 |
* @since 1.0
|
159 |
* @author Emanuela Castorina <emanuela.castorina@yithemes.com>
|
166 |
/**
|
167 |
* Show a input fields to upload images
|
168 |
*
|
|
|
169 |
* @param array $args
|
|
|
170 |
* @since 1.0
|
171 |
* @author Emanuela Castorina <emanuela.castorina@yithemes.com>
|
172 |
*/
|
184 |
* Add the plugin woocommerce page settings in the screen ids of woocommerce
|
185 |
*
|
186 |
* @param $screen_ids
|
|
|
187 |
* @return mixed
|
188 |
* @since 1.0.0
|
189 |
* @author Antonino Scarfì <antonino.scarfi@yithemes.com>
|
221 |
|
222 |
/**
|
223 |
* Return available tabs
|
|
|
224 |
* read all options and show sections and fields
|
225 |
*
|
226 |
* @param bool false for all tabs slug, true for current tab
|
|
|
227 |
* @return mixed Array tabs | String current tab
|
228 |
* @since 1.0
|
229 |
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
238 |
|
239 |
/**
|
240 |
* Add sections and fields to setting panel
|
|
|
241 |
* read all options and show sections and fields
|
242 |
*
|
243 |
* @return void
|
260 |
|
261 |
/**
|
262 |
* Print the panel content
|
|
|
263 |
* check if the tab is a wc options tab or custom tab and print the content
|
264 |
*
|
265 |
* @return void
|
406 |
|
407 |
/**
|
408 |
* Default options
|
|
|
409 |
* Sets up the default options used on the settings page
|
410 |
*
|
411 |
* @access public
|
446 |
* Delete the "default options added" option
|
447 |
*
|
448 |
* @author Leanza Francesco <leanzafrancesco@gmail.com>
|
|
|
449 |
*/
|
450 |
public static function delete_default_options_set_option() {
|
451 |
delete_option( 'yit_plugin_fw_panel_wc_default_options_set' );
|
456 |
*
|
457 |
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
458 |
* @since 2.0
|
|
|
459 |
* @param $classes The body classes
|
|
|
460 |
* @return array Filtered body classes
|
461 |
*/
|
462 |
public static function admin_body_class( $admin_body_classes ) {
|
474 |
* @param $value mixed Option value
|
475 |
* @param $option mixed Option settings array
|
476 |
* @param $raw_value string Raw option value
|
|
|
477 |
* @return mixed Filtered return value
|
478 |
* @author Antonio La Rocca <antonio.larocca@yithemes.com>
|
479 |
* @since 2.0
|
505 |
* @param $value mixed Option value
|
506 |
* @param $option mixed Option settings array
|
507 |
* @param $raw_value string Raw option value
|
|
|
508 |
* @return mixed Filtered return value
|
509 |
* @author Leanza Francesco <leanzafrancesco@gmail.com>
|
510 |
* @since 3.0.0
|
526 |
$value = $raw_value;
|
527 |
}
|
528 |
|
529 |
+
// sanitize the option date-format when the user choose the custom option
|
530 |
+
if ( isset( $option[ 'yith-type' ] ) && in_array( $option[ 'yith-type' ], array( 'date-format' ) ) && '\c\u\s\t\o\m' == $raw_value ) {
|
531 |
+
$custom = isset( $_REQUEST[ $option[ 'id' ] . '_text' ] ) ? $_REQUEST[ $option[ 'id' ] . '_text' ] : $option[ 'default' ];
|
532 |
+
$value = $custom;
|
533 |
+
}
|
534 |
|
535 |
+
if ( isset( $option[ 'yith-type' ] ) && in_array( $option[ 'yith-type' ], array( 'toggle-element' ) ) ) {
|
536 |
|
537 |
+
// error_log( print_r( $raw_value, true ) );
|
538 |
|
539 |
+
if ( $value && isset( $option[ 'elements' ] ) && !empty( $option[ 'elements' ] ) ) {
|
540 |
|
541 |
+
foreach ( $value as $index => $single_toggle ) {
|
542 |
|
543 |
+
if ( $value && isset( $option[ 'onoff_field' ] ) && !empty( $option[ 'onoff_field' ] ) ) {
|
544 |
+
$onoff = $option[ 'onoff_field' ];
|
545 |
+
$onoff[ 'type' ] = 'yith-field';
|
546 |
+
$onoff[ 'yith-type' ] = 'onoff';
|
547 |
+
$onoff_id = $onoff[ 'id' ];
|
548 |
|
549 |
+
$value[ $index ][ $onoff_id ] = isset( $single_toggle[ $onoff_id ] ) ? self::sanitize_option( $single_toggle[ $onoff_id ], $onoff, $single_toggle[ $onoff_id ] ) : 'no';
|
550 |
+
}
|
551 |
|
552 |
+
foreach ( $option[ 'elements' ] as $element ) {
|
553 |
+
$value[ $index ][ $element[ 'id' ] ] = self::sanitize_option( $value[ $index ][ $element[ 'id' ] ], $element, $value[ $index ][ $element[ 'id' ] ] );
|
554 |
+
}
|
555 |
+
}
|
556 |
+
}
|
557 |
|
558 |
|
559 |
+
// error_log('sanitizes value');
|
560 |
+
// error_log( print_r( $value, true ) );
|
561 |
+
}
|
562 |
|
563 |
|
564 |
+
if ( !empty( $option[ 'yith-sanitize-callback' ] ) && is_callable( $option[ 'yith-sanitize-callback' ] ) ) {
|
565 |
$value = call_user_func( $option[ 'yith-sanitize-callback' ], $value );
|
566 |
}
|
567 |
}
|
573 |
* Add YITH Fields
|
574 |
*
|
575 |
* @param array $field
|
|
|
576 |
* @return void
|
577 |
* @since 3.0.0
|
578 |
* @author Leanza Francesco <leanzafrancesco@gmail.com>
|
588 |
|
589 |
$value = apply_filters( 'yith_plugin_fw_wc_panel_pre_field_value', null, $field );
|
590 |
if ( is_null( $value ) ) {
|
591 |
+
if ( 'toggle-element' === $field[ 'type' ] ) {
|
592 |
+
$value = get_option( $field[ 'id' ], $field[ 'default' ] );
|
593 |
+
} else {
|
594 |
+
$value = WC_Admin_Settings::get_option( $field[ 'id' ], $field[ 'default' ] );
|
595 |
+
}
|
596 |
}
|
597 |
$field[ 'value' ] = $value;
|
598 |
|
600 |
}
|
601 |
}
|
602 |
|
603 |
+
/**
|
604 |
+
* Save the content of the toggle element present inside the panel.
|
605 |
+
* Called by the action 'admin_action_yith_plugin_fw_save_toggle_element'
|
606 |
+
* via Ajax
|
607 |
+
*
|
608 |
+
* @author Emanuela Castorina
|
609 |
+
*/
|
610 |
+
public function save_toggle_element_options() {
|
611 |
+
$posted = $_POST;
|
612 |
+
$tabs = $this->get_available_tabs();
|
613 |
+
$yit_options = $this->get_main_array_options();
|
614 |
+
$current_tab = isset( $_REQUEST[ 'tab' ] ) && in_array( $_REQUEST[ 'tab' ], $tabs ) ? $_REQUEST[ 'tab' ] : $tabs[ 0 ];
|
615 |
+
$option_id = isset( $_REQUEST[ 'toggle_id' ] ) ? $_REQUEST[ 'toggle_id' ] : '';
|
616 |
+
$updated = false;
|
617 |
|
618 |
+
if ( !empty( $yit_options[ $current_tab ] ) && !empty( $option_id ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
619 |
|
620 |
+
$tab_options = $yit_options[ $current_tab ];
|
621 |
+
foreach ( $tab_options as $key => $item ) {
|
622 |
+
if ( !isset( $item[ 'id' ] ) ) {
|
623 |
+
unset( $tab_options[ $key ] );
|
624 |
+
}
|
625 |
+
}
|
626 |
+
|
627 |
+
$option_array = array_combine( wp_list_pluck( $tab_options, 'id' ), $tab_options );
|
628 |
+
if ( isset( $option_array[ $option_id ] ) ) {
|
629 |
+
$value = isset( $posted[ $option_id ] ) ? $posted[ $option_id ] : '';
|
630 |
+
|
631 |
+
//drag and drop
|
632 |
+
$order_elements = isset( $posted[ 'yith_toggle_elements_order_keys' ] ) ? explode( ',', $posted[ 'yith_toggle_elements_order_keys' ] ) : false;
|
633 |
+
if ( $order_elements ) {
|
634 |
+
$i = 0;
|
635 |
+
$new_value = array();
|
636 |
+
foreach ( $order_elements as $key ) {
|
637 |
+
$index = apply_filters( 'yith_toggle_elements_index', $i++, $key );
|
638 |
+
$new_value[ $index ] = $value[ $key ];
|
639 |
+
}
|
640 |
+
|
641 |
+
$value = $new_value;
|
642 |
+
}
|
643 |
+
$value = self::sanitize_option( $value, $option_array[ $option_id ], $value );
|
644 |
+
$updated = update_option( $option_id, $value );
|
645 |
+
}
|
646 |
+
}
|
647 |
+
|
648 |
+
return $updated;
|
649 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
650 |
}
|
651 |
}
|
plugin-fw/lib/yith-system-status.php
ADDED
@@ -0,0 +1,383 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file belongs to the YIT Plugin Framework.
|
4 |
+
*
|
5 |
+
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
|
6 |
+
* that is bundled with this package in the file LICENSE.txt.
|
7 |
+
* It is also available through the world-wide-web at this URL:
|
8 |
+
* http://www.gnu.org/licenses/gpl-3.0.txt
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
} // Exit if accessed directly
|
14 |
+
|
15 |
+
if ( ! class_exists( 'YITH_System_Status' ) ) {
|
16 |
+
/**
|
17 |
+
* YITH System Status Panel
|
18 |
+
*
|
19 |
+
* Setting Page to Manage Plugins
|
20 |
+
*
|
21 |
+
* @class YITH_System_Status
|
22 |
+
* @package YITH
|
23 |
+
* @since 1.0
|
24 |
+
* @author Alberto Ruggiero
|
25 |
+
*/
|
26 |
+
class YITH_System_Status {
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var array The settings require to add the submenu page "System Status"
|
30 |
+
*/
|
31 |
+
protected $_settings = array();
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @var string the page slug
|
35 |
+
*/
|
36 |
+
protected $_page = 'yith_system_info';
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @var array plugins requirements list
|
40 |
+
*/
|
41 |
+
protected $_plugins_requirements = array();
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @var array requirements labels
|
45 |
+
*/
|
46 |
+
protected $_requirement_labels = array();
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Single instance of the class
|
50 |
+
*
|
51 |
+
* @var \YITH_System_Status
|
52 |
+
* @since 1.0.0
|
53 |
+
*/
|
54 |
+
protected static $_instance = null;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Main plugin Instance
|
58 |
+
*
|
59 |
+
* @since 1.0.0
|
60 |
+
* @return YITH_System_Status
|
61 |
+
* @author Alberto Ruggiero
|
62 |
+
*/
|
63 |
+
public static function instance() {
|
64 |
+
if ( is_null( self::$_instance ) ) {
|
65 |
+
self::$_instance = new self();
|
66 |
+
}
|
67 |
+
|
68 |
+
return self::$_instance;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Constructor
|
73 |
+
*
|
74 |
+
* @since 1.0.0
|
75 |
+
* @return void
|
76 |
+
* @author Alberto Ruggiero
|
77 |
+
*/
|
78 |
+
public function __construct() {
|
79 |
+
|
80 |
+
if ( ! is_admin() ) {
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
|
84 |
+
$system_info = get_option( 'yith_system_info' );
|
85 |
+
$error_notice = ( $system_info['errors'] === true ? ' <span class="yith-system-info-menu update-plugins">!</span>' : '' );
|
86 |
+
|
87 |
+
$this->_settings = array(
|
88 |
+
'parent_page' => 'yith_plugin_panel',
|
89 |
+
'page_title' => __( 'System Status', 'yith-plugin-fw' ),
|
90 |
+
'menu_title' => __( 'System Status', 'yith-plugin-fw' ) . $error_notice,
|
91 |
+
'capability' => 'manage_options',
|
92 |
+
'page' => $this->_page,
|
93 |
+
);
|
94 |
+
|
95 |
+
$this->_requirement_labels = array(
|
96 |
+
'min_wp_version' => __( 'WordPress Version', 'yith-plugin-fw' ),
|
97 |
+
'min_wc_version' => __( 'WooCommerce Version', 'yith-plugin-fw' ),
|
98 |
+
'wp_memory_limit' => __( 'Available Memory', 'yith-plugin-fw' ),
|
99 |
+
'min_php_version' => __( 'PHP Version', 'yith-plugin-fw' ),
|
100 |
+
'min_tls_version' => __( 'TLS Version', 'yith-plugin-fw' ),
|
101 |
+
'wp_cron_enabled' => __( 'WordPress Cron', 'yith-plugin-fw' ),
|
102 |
+
'simplexml_enabled' => __( 'SimpleXML', 'yith-plugin-fw' ),
|
103 |
+
'mbstring_enabled' => __( 'MultiByte String', 'yith-plugin-fw' ),
|
104 |
+
'imagick_version' => __( 'ImageMagick Version', 'yith-plugin-fw' ),
|
105 |
+
'gd_enabled' => __( 'GD Library', 'yith-plugin-fw' ),
|
106 |
+
'opcache_enabled' => __( 'OPCache Save Comments', 'yith-plugin-fw' ),
|
107 |
+
'url_fopen_enabled' => __( 'URL FOpen', 'yith-plugin-fw' ),
|
108 |
+
);
|
109 |
+
|
110 |
+
add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
|
111 |
+
add_action( 'admin_init', array( $this, 'check_system_status' ) );
|
112 |
+
add_action( 'admin_notices', array( $this, 'activate_system_notice' ), 15 );
|
113 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'dismissable_notice' ), 20 );
|
114 |
+
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Add "System Information" submenu page under YITH Plugins
|
120 |
+
*
|
121 |
+
* @since 1.0.0
|
122 |
+
* @return void
|
123 |
+
* @author Alberto Ruggiero
|
124 |
+
*/
|
125 |
+
public function add_submenu_page() {
|
126 |
+
add_submenu_page(
|
127 |
+
$this->_settings['parent_page'],
|
128 |
+
$this->_settings['page_title'],
|
129 |
+
$this->_settings['menu_title'],
|
130 |
+
$this->_settings['capability'],
|
131 |
+
$this->_settings['page'],
|
132 |
+
array( $this, 'show_information_panel' )
|
133 |
+
);
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Add "System Information" page template under YITH Plugins
|
138 |
+
*
|
139 |
+
* @since 1.0.0
|
140 |
+
* @return void
|
141 |
+
* @author Alberto Ruggiero
|
142 |
+
*/
|
143 |
+
public function show_information_panel() {
|
144 |
+
|
145 |
+
$path = defined( 'YIT_CORE_PLUGIN_PATH' ) ? YIT_CORE_PLUGIN_PATH : get_template_directory() . '/core/plugin-fw/';
|
146 |
+
$labels = $this->_requirement_labels;
|
147 |
+
|
148 |
+
require_once( $path . '/templates/sysinfo/system-information-panel.php' );
|
149 |
+
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Perform system status check
|
154 |
+
*
|
155 |
+
* @since 1.0.0
|
156 |
+
* @return void
|
157 |
+
* @author Alberto Ruggiero
|
158 |
+
*/
|
159 |
+
public function check_system_status() {
|
160 |
+
|
161 |
+
if ( '' == get_option( 'yith_system_info' ) || ( isset( $_GET['page'] ) && $_GET['page'] == $this->_page ) ) {
|
162 |
+
|
163 |
+
$this->add_requirements( __( 'YITH License Activation', 'yith-plugin-fw' ), array( 'min_tls_version' => '1.2' ) );
|
164 |
+
$this->add_requirements( __( 'YITH Plugins', 'yith-plugin-fw' ), array( 'min_wp_version' => '4.9', 'min_wc_version' => '3.4', 'min_php_version' => '5.6.20' ) );
|
165 |
+
$this->add_requirements( __( 'WooCommerce', 'yith-plugin-fw' ), array( 'wp_memory_limit' => '64M' ) );
|
166 |
+
|
167 |
+
$system_info = $this->get_system_info();
|
168 |
+
$check_results = array();
|
169 |
+
$errors = false;
|
170 |
+
|
171 |
+
foreach ( $system_info as $key => $value ) {
|
172 |
+
$check_results[ $key ] = array( 'value' => $value );
|
173 |
+
|
174 |
+
if ( isset( $this->_plugins_requirements[ $key ] ) ) {
|
175 |
+
|
176 |
+
foreach ( $this->_plugins_requirements[ $key ] as $plugin_name => $required_value ) {
|
177 |
+
|
178 |
+
switch ( $key ) {
|
179 |
+
case 'wp_cron_enabled' :
|
180 |
+
case 'mbstring_enabled' :
|
181 |
+
case 'simplexml_enabled':
|
182 |
+
case 'gd_enabled':
|
183 |
+
case 'url_fopen_enabled':
|
184 |
+
case 'opcache_enabled' :
|
185 |
+
|
186 |
+
if ( ! $value ) {
|
187 |
+
$check_results[ $key ]['errors'][ $plugin_name ] = $required_value;
|
188 |
+
$errors = true;
|
189 |
+
}
|
190 |
+
break;
|
191 |
+
|
192 |
+
case 'wp_memory_limit' :
|
193 |
+
$required_memory = $this->memory_size_to_num( $required_value );
|
194 |
+
|
195 |
+
if ( $required_memory > $value ) {
|
196 |
+
$check_results[ $key ]['errors'][ $plugin_name ] = $required_value;
|
197 |
+
$errors = true;
|
198 |
+
}
|
199 |
+
break;
|
200 |
+
|
201 |
+
default:
|
202 |
+
if ( ! version_compare( $value, $required_value, '>=' ) ) {
|
203 |
+
$check_results[ $key ]['errors'][ $plugin_name ] = $required_value;
|
204 |
+
$errors = true;
|
205 |
+
}
|
206 |
+
|
207 |
+
}
|
208 |
+
|
209 |
+
}
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
}
|
214 |
+
|
215 |
+
update_option( 'yith_system_info', array( 'system_info' => $check_results, 'errors' => $errors ) );
|
216 |
+
|
217 |
+
}
|
218 |
+
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Handle plugin requirements
|
223 |
+
*
|
224 |
+
* @since 1.0.0
|
225 |
+
*
|
226 |
+
* @param $plugin_name string
|
227 |
+
* @param $requirements array
|
228 |
+
*
|
229 |
+
* @return void
|
230 |
+
* @author Alberto Ruggiero
|
231 |
+
*/
|
232 |
+
public function add_requirements( $plugin_name, $requirements ) {
|
233 |
+
|
234 |
+
$allowed_requirements = array_keys( $this->_requirement_labels );
|
235 |
+
|
236 |
+
foreach ( $requirements as $requirement => $value ) {
|
237 |
+
|
238 |
+
if ( in_array( $requirement, $allowed_requirements ) ) {
|
239 |
+
$this->_plugins_requirements[ $requirement ][ $plugin_name ] = $value;
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Manages notice dismissing
|
247 |
+
*
|
248 |
+
* @since 1.0.0
|
249 |
+
* @return void
|
250 |
+
* @author Alberto Ruggiero
|
251 |
+
*/
|
252 |
+
public function dismissable_notice() {
|
253 |
+
$script_path = defined( 'YIT_CORE_PLUGIN_URL' ) ? YIT_CORE_PLUGIN_URL : get_template_directory_uri() . '/core/plugin-fw';
|
254 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
255 |
+
wp_register_script( 'yith-system-info', $script_path . '/assets/js/yith-system-info' . $suffix . '.js', array( 'jquery' ), '1.0.0', true );
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Show system notice
|
260 |
+
*
|
261 |
+
* @since 1.0.0
|
262 |
+
* @return void
|
263 |
+
* @author Alberto Ruggiero
|
264 |
+
*/
|
265 |
+
public function activate_system_notice() {
|
266 |
+
|
267 |
+
$system_info = get_option( 'yith_system_info', '' );
|
268 |
+
|
269 |
+
if ( ( isset( $_GET['page'] ) && $_GET['page'] == $this->_page ) || ( ! empty( $_COOKIE['hide_yith_system_alert'] ) && 'yes' == $_COOKIE['hide_yith_system_alert'] ) || ( $system_info == '' ) || ( $system_info != '' && $system_info['errors'] === false ) ) {
|
270 |
+
return;
|
271 |
+
}
|
272 |
+
|
273 |
+
$show_notice = true;
|
274 |
+
|
275 |
+
if ( true === $show_notice ) :
|
276 |
+
wp_enqueue_script( 'yith-system-info' );
|
277 |
+
?>
|
278 |
+
<div id="yith-system-alert" class="notice notice-error is-dismissible" style="position: relative;">
|
279 |
+
<p>
|
280 |
+
<span class="yith-logo"><img src="<?php echo yith_plugin_fw_get_default_logo() ?>" /></span>
|
281 |
+
<b><?php echo __( 'Warning!', 'yith-plugin-fw' ) ?></b><br />
|
282 |
+
<?php echo sprintf( __( 'The system check has detected some compatibility issues on your installation. %sClick here%s to know more', 'yith-plugin-fw' ), '<a href="' . esc_url( add_query_arg( array( 'page' => $this->_page ), admin_url( 'admin.php' ) ) ) . '">', '</a>' ) ?>
|
283 |
+
</p>
|
284 |
+
<span class="notice-dismiss"></span>
|
285 |
+
|
286 |
+
</div>
|
287 |
+
<?php endif;
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Get system information
|
292 |
+
*
|
293 |
+
* @since 1.0.0
|
294 |
+
* @return array
|
295 |
+
* @author Alberto Ruggiero
|
296 |
+
*/
|
297 |
+
public function get_system_info() {
|
298 |
+
|
299 |
+
//Get TLS version
|
300 |
+
$ch = curl_init( 'https://www.howsmyssl.com/a/check' );
|
301 |
+
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
302 |
+
$data = curl_exec( $ch );
|
303 |
+
curl_close( $ch );
|
304 |
+
$json = json_decode( $data );
|
305 |
+
$tls = str_replace( 'TLS ', '', $json->tls_version );
|
306 |
+
|
307 |
+
//Get PHP version
|
308 |
+
preg_match( "#^\d+(\.\d+)*#", PHP_VERSION, $match );
|
309 |
+
$php_version = $match[0];
|
310 |
+
|
311 |
+
// WP memory limit.
|
312 |
+
$wp_memory_limit = $this->memory_size_to_num( WP_MEMORY_LIMIT );
|
313 |
+
if ( function_exists( 'memory_get_usage' ) ) {
|
314 |
+
$wp_memory_limit = max( $wp_memory_limit, $this->memory_size_to_num( @ini_get( 'memory_limit' ) ) );
|
315 |
+
}
|
316 |
+
|
317 |
+
$imagick_version = '0.0.0';
|
318 |
+
if ( class_exists( 'Imagick' ) ) {
|
319 |
+
preg_match( "/([0-9]+\.[0-9]+\.[0-9]+)/", Imagick::getVersion()['versionString'], $imatch );
|
320 |
+
$imagick_version = $imatch[0];
|
321 |
+
}
|
322 |
+
|
323 |
+
return apply_filters( 'yith_system_additional_check', array(
|
324 |
+
'min_wp_version' => get_bloginfo( 'version' ),
|
325 |
+
'min_wc_version' => function_exists( 'WC' ) ? WC()->version : __( 'Not installed', 'yith-plugin-fw' ),
|
326 |
+
'wp_memory_limit' => $wp_memory_limit,
|
327 |
+
'min_php_version' => $php_version,
|
328 |
+
'min_tls_version' => $tls,
|
329 |
+
'imagick_version' => $imagick_version,
|
330 |
+
'wp_cron_enabled' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ),
|
331 |
+
'mbstring_enabled' => extension_loaded( 'mbstring' ),
|
332 |
+
'simplexml_enabled' => extension_loaded( 'simplexml' ),
|
333 |
+
'gd_enabled' => extension_loaded( 'gd' ) && function_exists( 'gd_info' ),
|
334 |
+
'opcache_enabled' => ini_get( 'opcache.save_comments' ),
|
335 |
+
'url_fopen_enabled' => ini_get( 'allow_url_fopen' ),
|
336 |
+
) );
|
337 |
+
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Convert site into number
|
342 |
+
*
|
343 |
+
* @since 1.0.0
|
344 |
+
*
|
345 |
+
* @param $memory_size string
|
346 |
+
*
|
347 |
+
* @return integer
|
348 |
+
* @author Alberto Ruggiero
|
349 |
+
*/
|
350 |
+
public function memory_size_to_num( $memory_size ) {
|
351 |
+
$unit = strtoupper( substr( $memory_size, - 1 ) );
|
352 |
+
$size = substr( $memory_size, 0, - 1 );
|
353 |
+
$multiplier = array(
|
354 |
+
'P' => 5,
|
355 |
+
'T' => 4,
|
356 |
+
'G' => 3,
|
357 |
+
'M' => 2,
|
358 |
+
'K' => 1,
|
359 |
+
);
|
360 |
+
for ( $i = 1; $i <= $multiplier[ $unit ]; $i ++ ) {
|
361 |
+
$size *= 1024;
|
362 |
+
}
|
363 |
+
|
364 |
+
return $size;
|
365 |
+
}
|
366 |
+
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Main instance of plugin
|
372 |
+
*
|
373 |
+
* @return YITH_System_Status object
|
374 |
+
* @since 1.0
|
375 |
+
* @author Alberto Ruggiero
|
376 |
+
*/
|
377 |
+
if ( ! function_exists( 'YITH_System_Status' ) ) {
|
378 |
+
function YITH_System_Status() {
|
379 |
+
return YITH_System_Status::instance();
|
380 |
+
}
|
381 |
+
}
|
382 |
+
|
383 |
+
YITH_System_Status();
|
plugin-fw/templates/fields/colorpicker.php
CHANGED
@@ -25,3 +25,4 @@ $class = !empty( $class ) ? $class : 'yith-plugin-fw-colorpicker';
|
|
25 |
class="<?php echo $class ?>"
|
26 |
<?php echo $custom_attributes ?>
|
27 |
<?php if ( isset( $data ) ) echo yith_plugin_fw_html_data_to_string( $data ); ?>/>
|
|
25 |
class="<?php echo $class ?>"
|
26 |
<?php echo $custom_attributes ?>
|
27 |
<?php if ( isset( $data ) ) echo yith_plugin_fw_html_data_to_string( $data ); ?>/>
|
28 |
+
|
plugin-fw/templates/fields/list-table.php
CHANGED
@@ -17,7 +17,7 @@ if ( isset( $add_new_button ) && isset( $post_type ) ) {
|
|
17 |
$show_button = true;
|
18 |
$admin_url = admin_url( 'post-new.php' );
|
19 |
$params['post_type'] = $post_type;
|
20 |
-
$add_new_url = esc_url( add_query_arg( $params, $admin_url ) );
|
21 |
}
|
22 |
|
23 |
if ( isset( $list_table_class ) && ! class_exists( $list_table_class ) && isset( $list_table_class_dir ) ) {
|
@@ -25,7 +25,7 @@ if ( isset( $list_table_class ) && ! class_exists( $list_table_class ) && isset(
|
|
25 |
}
|
26 |
|
27 |
if ( class_exists( $list_table_class ) ):
|
28 |
-
$list_table = new $list_table_class();
|
29 |
?>
|
30 |
|
31 |
<div id="<?php echo $id ?>" class="yith-plugin-fw-list-table <?php echo $class ?>">
|
@@ -49,6 +49,9 @@ if ( class_exists( $list_table_class ) ):
|
|
49 |
$list_table->views();
|
50 |
?>
|
51 |
<form method="post">
|
|
|
|
|
|
|
52 |
<?php
|
53 |
$list_table->display();
|
54 |
?>
|
17 |
$show_button = true;
|
18 |
$admin_url = admin_url( 'post-new.php' );
|
19 |
$params['post_type'] = $post_type;
|
20 |
+
$add_new_url = apply_filters( 'yith_plugin_fw_add_new_post_url', esc_url( add_query_arg( $params, $admin_url ) ), $params, isset( $args ) ? $args : false );
|
21 |
}
|
22 |
|
23 |
if ( isset( $list_table_class ) && ! class_exists( $list_table_class ) && isset( $list_table_class_dir ) ) {
|
25 |
}
|
26 |
|
27 |
if ( class_exists( $list_table_class ) ):
|
28 |
+
$list_table = isset( $args ) ? new $list_table_class( $args ) : new $list_table_class() ;
|
29 |
?>
|
30 |
|
31 |
<div id="<?php echo $id ?>" class="yith-plugin-fw-list-table <?php echo $class ?>">
|
49 |
$list_table->views();
|
50 |
?>
|
51 |
<form method="post">
|
52 |
+
<?php if( isset( $search_form ) ) {
|
53 |
+
$list_table->search_box( $search_form['text'], $search_form['input_id'] );
|
54 |
+
} ?>
|
55 |
<?php
|
56 |
$list_table->display();
|
57 |
?>
|
plugin-fw/templates/fields/radio.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* This file belongs to the YIT Plugin Framework.
|
4 |
-
*
|
5 |
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
|
6 |
* that is bundled with this package in the file LICENSE.txt.
|
7 |
* It is also available through the world-wide-web at this URL:
|
@@ -31,3 +30,4 @@ $class = 'yith-plugin-fw-radio ' . $class;
|
|
31 |
</div>
|
32 |
<?php endforeach; ?>
|
33 |
</div>
|
|
1 |
<?php
|
2 |
/**
|
3 |
* This file belongs to the YIT Plugin Framework.
|
|
|
4 |
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
|
5 |
* that is bundled with this package in the file LICENSE.txt.
|
6 |
* It is also available through the world-wide-web at this URL:
|
30 |
</div>
|
31 |
<?php endforeach; ?>
|
32 |
</div>
|
33 |
+
|
plugin-fw/templates/sysinfo/system-information-panel.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* This file belongs to the YIT Framework.
|
4 |
+
*
|
5 |
+
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
|
6 |
+
* that is bundled with this package in the file LICENSE.txt.
|
7 |
+
* It is also available through the world-wide-web at this URL:
|
8 |
+
* http://www.gnu.org/licenses/gpl-3.0.txt
|
9 |
+
*/
|
10 |
+
|
11 |
+
$system_info = get_option( 'yith_system_info' );
|
12 |
+
$recommended_memory = '128M';
|
13 |
+
|
14 |
+
?>
|
15 |
+
<div id="yith-sysinfo" class="wrap yith-system-info">
|
16 |
+
<h1>
|
17 |
+
<span class="yith-logo"><img src="<?php echo yith_plugin_fw_get_default_logo() ?>" /></span> <?php _e( 'YITH System Information', 'yith-plugin-fw' ) ?>
|
18 |
+
</h1>
|
19 |
+
|
20 |
+
<?php if ( ! isset( $_GET['yith-phpinfo'] ) || $_GET['yith-phpinfo'] != 'true' ): ?>
|
21 |
+
|
22 |
+
<table class="widefat striped">
|
23 |
+
<?php foreach ( $system_info['system_info'] as $key => $item ): ?>
|
24 |
+
<?php
|
25 |
+
$to_be_enabled = strpos( $key, '_enabled' ) !== false;
|
26 |
+
$has_errors = isset( $item['errors'] );
|
27 |
+
$has_warnings = false;
|
28 |
+
|
29 |
+
if ( $key == 'wp_memory_limit' && ! $has_errors ) {
|
30 |
+
$has_warnings = $item['value'] < $recommended_memory;
|
31 |
+
}
|
32 |
+
|
33 |
+
?>
|
34 |
+
<tr>
|
35 |
+
<th class="requirement-name">
|
36 |
+
<?php echo $labels[ $key ]; ?>
|
37 |
+
</th>
|
38 |
+
<td class="requirement-value <?php echo( $has_errors ? 'has-errors' : '' ) ?> <?php echo( $has_warnings ? 'has-warnings' : '' ) ?>">
|
39 |
+
<span class="dashicons dashicons-<?php echo( $has_errors || $has_warnings ? 'warning' : 'yes' ) ?>"></span>
|
40 |
+
|
41 |
+
<?php if ( $to_be_enabled ) {
|
42 |
+
echo $item['value'] ? __( 'Enabled', 'yith-plugin-fw' ) : __( 'Disabled', 'yith-plugin-fw' );
|
43 |
+
} elseif ( $key == 'wp_memory_limit' ) {
|
44 |
+
echo esc_html( size_format( $item['value'] ) );
|
45 |
+
} else {
|
46 |
+
echo $item['value'];
|
47 |
+
} ?>
|
48 |
+
|
49 |
+
</td>
|
50 |
+
<td class="requirement-messages">
|
51 |
+
<?php if ( $has_errors ) : ?>
|
52 |
+
<ul>
|
53 |
+
<?php foreach ( $item['errors'] as $plugin => $requirement ) : ?>
|
54 |
+
<li>
|
55 |
+
<?php if ( $to_be_enabled ) {
|
56 |
+
echo sprintf( __( '%s needs %s enabled', 'yith-plugin-fw' ), '<b>' . $plugin . '</b>', '<b>' . $labels[ $key ] . '</b>' );
|
57 |
+
} elseif ( $key == 'wp_memory_limit' ) {
|
58 |
+
echo sprintf( __( '%s needs at least %s of available memory', 'yith-plugin-fw' ), '<b>' . $plugin . '</b>', '<span class="error">' . esc_html( size_format( YITH_System_Status()->memory_size_to_num( $requirement ) ) ) . '</span>' );
|
59 |
+
echo '<br/>';
|
60 |
+
echo sprintf( __( 'For optimal functioning of our plugins, we suggest setting at least %s of available memory', 'yith-plugin-fw' ), '<span class="error">' . esc_html( size_format( YITH_System_Status()->memory_size_to_num( $recommended_memory ) ) ) . '</span>' );
|
61 |
+
|
62 |
+
} else {
|
63 |
+
echo sprintf( __( '%s needs at least %s version', 'yith-plugin-fw' ), '<b>' . $plugin . '</b>', '<span class="error">' . $requirement . '</span>' );
|
64 |
+
} ?>
|
65 |
+
</li>
|
66 |
+
<?php endforeach; ?>
|
67 |
+
</ul>
|
68 |
+
<?php switch ( $key ) {
|
69 |
+
|
70 |
+
case 'min_wp_version':
|
71 |
+
case 'min_wc_version':
|
72 |
+
echo __( 'Update it to the latest version in order to benefit of all new features and security updates.', 'yith-plugin-fw' );
|
73 |
+
break;
|
74 |
+
case 'min_php_version':
|
75 |
+
case 'min_tls_version':
|
76 |
+
case 'imagick_version':
|
77 |
+
echo __( 'Contact your hosting company in order to update it.', 'yith-plugin-fw' );
|
78 |
+
break;
|
79 |
+
case 'wp_cron_enabled':
|
80 |
+
echo sprintf( __( 'Remove %s from %s file', 'yith-plugin-fw' ), '<code>define( \'DISABLE_WP_CRON\', true );</code>', '<b>wp-config.php</b>' );
|
81 |
+
break;
|
82 |
+
case 'mbstring_enabled':
|
83 |
+
case 'simplexml_enabled':
|
84 |
+
case 'gd_enabled':
|
85 |
+
case 'opcache_enabled':
|
86 |
+
case 'url_fopen_enabled':
|
87 |
+
echo __( 'Contact your hosting company in order to enable it.', 'yith-plugin-fw' );
|
88 |
+
break;
|
89 |
+
case 'wp_memory_limit':
|
90 |
+
echo sprintf( __( 'Read more %s here%s or contact your hosting company in order to increase it.', 'yith-plugin-fw' ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">', '</a>' );
|
91 |
+
break;
|
92 |
+
default:
|
93 |
+
echo apply_filters( 'yith_system_generic_message', '', $item );
|
94 |
+
|
95 |
+
} ?>
|
96 |
+
<?php endif; ?>
|
97 |
+
|
98 |
+
<?php if ( $has_warnings ) : ?>
|
99 |
+
<ul>
|
100 |
+
<li>
|
101 |
+
<?php echo sprintf( __( 'For optimal functioning of our plugins, we suggest setting at least %s of available memory', 'yith-plugin-fw' ), '<span class="warning">' . esc_html( size_format( YITH_System_Status()->memory_size_to_num( $recommended_memory ) ) ) . '</span>' ); ?>
|
102 |
+
</li>
|
103 |
+
</ul>
|
104 |
+
<?php echo sprintf( __( 'Read more %s here%s or contact your hosting company in order to increase it.', 'yith-plugin-fw' ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">', '</a>' ); ?>
|
105 |
+
<?php endif; ?>
|
106 |
+
</td>
|
107 |
+
</tr>
|
108 |
+
<?php endforeach; ?>
|
109 |
+
</table>
|
110 |
+
|
111 |
+
<a href="<?php echo add_query_arg( array( 'yith-phpinfo' => 'true' ) ) ?> "><?php _e( 'Show full PHPInfo', 'yith-plugin-fw' ) ?></a>
|
112 |
+
|
113 |
+
<?php else : ?>
|
114 |
+
|
115 |
+
<a href="<?php echo add_query_arg( array( 'yith-phpinfo' => 'false' ) ) ?> "><?php _e( 'Back to System panel', 'yith-plugin-fw' ) ?></a>
|
116 |
+
|
117 |
+
<?php
|
118 |
+
|
119 |
+
ob_start();
|
120 |
+
phpinfo( 61 );
|
121 |
+
$pinfo = ob_get_contents();
|
122 |
+
ob_end_clean();
|
123 |
+
|
124 |
+
$pinfo = preg_replace( '%^.*<div class="center">(.*)</div>.*$%ms', '$1', $pinfo );
|
125 |
+
$pinfo = preg_replace( '%(^.*)<a name=\".*\">(.*)</a>(.*$)%m', '$1$2$3', $pinfo );
|
126 |
+
$pinfo = str_replace( '<table>', '<table class="widefat striped yith-phpinfo">', $pinfo );
|
127 |
+
$pinfo = str_replace( '<td class="e">', '<th class="e">', $pinfo );
|
128 |
+
echo $pinfo;
|
129 |
+
|
130 |
+
?>
|
131 |
+
|
132 |
+
<a href="#yith-sysinfo"><?php _e( 'Back to top', 'yith-plugin-fw' ) ?></a>
|
133 |
+
|
134 |
+
<?php endif; ?>
|
135 |
+
</div>
|
plugin-fw/yit-functions.php
CHANGED
@@ -1376,4 +1376,15 @@ if ( ! function_exists( 'yith_plugin_fw_remove_duplicate_classes' ) ) {
|
|
1376 |
|
1377 |
return $classes;
|
1378 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1379 |
}
|
1376 |
|
1377 |
return $classes;
|
1378 |
}
|
1379 |
+
}
|
1380 |
+
|
1381 |
+
if ( ! function_exists( 'yith_plugin_fw_add_requirements' ) ) {
|
1382 |
+
|
1383 |
+
function yith_plugin_fw_add_requirements( $plugin_name, $requirements ) {
|
1384 |
+
if ( ! empty( $requirements ) ) {
|
1385 |
+
YITH_System_Status()->add_requirements( $plugin_name, $requirements );
|
1386 |
+
|
1387 |
+
|
1388 |
+
}
|
1389 |
+
}
|
1390 |
}
|
plugin-fw/yit-plugin.php
CHANGED
@@ -40,6 +40,7 @@ include_once( 'lib/yith-dashboard.php' );
|
|
40 |
include_once( 'lib/privacy/yit-privacy.php' );
|
41 |
include_once( 'lib/privacy/yit-privacy-plugin-abstract.php' );
|
42 |
include_once( 'lib/promo/yith-promo.php' );
|
|
|
43 |
|
44 |
/* === Gutenberg Support === */
|
45 |
if( class_exists( 'WP_Block_Type_Registry' ) ){
|
@@ -183,6 +184,7 @@ if( ! function_exists( 'yith_add_action_links' ) ){
|
|
183 |
* @use plugin_action_links_{$plugin_file_name}
|
184 |
*/
|
185 |
function yith_add_action_links( $links, $panel_page = '', $is_premium = false ) {
|
|
|
186 |
if( ! empty( $panel_page ) ){
|
187 |
$links[] = sprintf( '<a href="%s">%s</a>', admin_url( "admin.php?page={$panel_page}" ), _x( 'Settings', 'Action links', 'yith-plugin-fw' ) );
|
188 |
}
|
40 |
include_once( 'lib/privacy/yit-privacy.php' );
|
41 |
include_once( 'lib/privacy/yit-privacy-plugin-abstract.php' );
|
42 |
include_once( 'lib/promo/yith-promo.php' );
|
43 |
+
include_once( 'lib/yith-system-status.php' );
|
44 |
|
45 |
/* === Gutenberg Support === */
|
46 |
if( class_exists( 'WP_Block_Type_Registry' ) ){
|
184 |
* @use plugin_action_links_{$plugin_file_name}
|
185 |
*/
|
186 |
function yith_add_action_links( $links, $panel_page = '', $is_premium = false ) {
|
187 |
+
$links = is_array( $links ) ? $links : array();
|
188 |
if( ! empty( $panel_page ) ){
|
189 |
$links[] = sprintf( '<a href="%s">%s</a>', admin_url( "admin.php?page={$panel_page}" ), _x( 'Settings', 'Action links', 'yith-plugin-fw' ) );
|
190 |
}
|