WooCommerce Wishlist Plugin - Version 1.12.0

Version Description

Release Date - 22 April 2019

  • Greatly improved frontend performance
  • Fixed wishlist analytics issues
  • Code cleanup
Download this release

Release Info

Developer templateinvaders
Plugin Icon 128x128 WooCommerce Wishlist Plugin
Version 1.12.0
Comparing to
See all releases

Code changes from version 1.11.1 to 1.12.0

admin/basestyle.helper.php CHANGED
@@ -23,12 +23,12 @@ abstract class TInvWL_Admin_BaseStyle extends TInvWL_Admin_BaseSection {
23
  */
24
  function prepare_sections() {
25
  $fields_data = array();
26
- $fields = $this->default_style_settings();
27
- $theme_file = TINVWL_PATH . implode( DIRECTORY_SEPARATOR, array( 'assets', 'css', 'theme.css' ) );
28
  if ( file_exists( $theme_file ) ) {
29
  $fields_data = $this->break_css( file_get_contents( $theme_file ) ); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.file_get_contents
30
  }
31
- $_fields = $this->prepare_fields( $fields, $fields_data );
32
  foreach ( $_fields as &$_field ) {
33
  if ( ! array_key_exists( 'skin', $_field ) ) {
34
  switch ( $_field['type'] ) {
@@ -42,6 +42,7 @@ abstract class TInvWL_Admin_BaseStyle extends TInvWL_Admin_BaseSection {
42
  }
43
  }
44
  }
 
45
  return $_fields;
46
  }
47
 
@@ -53,77 +54,77 @@ abstract class TInvWL_Admin_BaseStyle extends TInvWL_Admin_BaseSection {
53
  function constructor_data() {
54
  return array(
55
  array(
56
- 'id' => 'style',
57
- 'title' => __( 'Templates', 'ti-woocommerce-wishlist' ),
58
- 'desc' => '',
59
  'show_names' => false,
60
- 'fields' => array(
61
  array(
62
- 'type' => 'checkboxonoff',
63
- 'name' => 'customstyle',
64
- 'text' => __( 'Use Theme style', 'ti-woocommerce-wishlist' ),
65
- 'std' => true,
66
- 'extra' => array( 'tiwl-hide' => '.tinvwl-style-options' ),
67
- 'class' => 'tinvwl-header-row',
68
  ),
69
  ),
70
  ),
71
  array(
72
- 'id' => 'style_options',
73
- 'title' => __( 'Template Options', 'ti-woocommerce-wishlist' ),
74
  'show_names' => true,
75
- 'class' => 'tinvwl-style-options',
76
- 'fields' => $this->prepare_sections(),
77
- 'skin' => 'section-general',
78
  ),
79
  array(
80
- 'id' => 'style_plain',
81
- 'title' => __( 'Template Custom CSS', 'ti-woocommerce-wishlist' ),
82
- 'desc' => '',
83
  'show_names' => false,
84
- 'fields' => array(
85
  array(
86
- 'type' => 'checkboxonoff',
87
- 'name' => 'allow',
88
- 'text' => __( 'Template Custom CSS', 'ti-woocommerce-wishlist' ),
89
- 'std' => false,
90
- 'extra' => array( 'tiwl-show' => '.tiwl-style-custom-allow' ),
91
- 'class' => 'tinvwl-header-row',
92
  ),
93
  array(
94
- 'type' => 'group',
95
- 'id' => 'custom',
96
- 'class' => 'tiwl-style-custom-allow',
97
  ),
98
  array(
99
- 'type' => 'textarea',
100
- 'name' => 'css',
101
- 'text' => '',
102
- 'std' => '',
103
  ),
104
  ),
105
  ),
106
  array(
107
- 'id' => 'save_buttons',
108
- 'class' => 'only-button',
109
  'noform' => true,
110
  'fields' => array(
111
  array(
112
- 'type' => 'button_submit',
113
- 'name' => 'setting_save',
114
- 'std' => '<span><i class="ftinvwl ftinvwl-check"></i></span>' . __( 'Save Settings', 'ti-woocommerce-wishlist' ),
115
- 'extra' => array( 'class' => 'tinvwl-btn split status-btn-ok' ),
116
  ),
117
  array(
118
- 'type' => 'button_submit',
119
- 'name' => 'setting_reset',
120
- 'std' => '<span><i class="ftinvwl ftinvwl-times"></i></span>' . __( 'Reset', 'ti-woocommerce-wishlist' ),
121
- 'extra' => array( 'class' => 'tinvwl-btn split status-btn-ok tinvwl-confirm-reset' ),
122
  ),
123
  array(
124
- 'type' => 'button_submit_quick',
125
- 'name' => 'setting_save_quick',
126
- 'std' => '<span><i class="ftinvwl ftinvwl-floppy-o"></i></span>' . __( 'Save', 'ti-woocommerce-wishlist' ),
127
  ),
128
  ),
129
  ),
@@ -144,6 +145,7 @@ abstract class TInvWL_Admin_BaseStyle extends TInvWL_Admin_BaseSection {
144
  *
145
  * @param array $fields Array of fields list.
146
  * @param array $data Array of default values for fields.
 
147
  * @return array
148
  */
149
  function prepare_fields( $fields = array(), $data = array() ) {
@@ -158,13 +160,13 @@ abstract class TInvWL_Admin_BaseStyle extends TInvWL_Admin_BaseSection {
158
  if ( isset( $data[ $field['selector'] ][ $field['element'] ] ) ) {
159
  $value = $data[ $field['selector'] ][ $field['element'] ];
160
  if ( array_key_exists( 'format', (array) $field ) ) {
161
- $pregx = preg_replace( '/(\[|\]|\\|\/|\^|\$|\%|\.|\||\?|\*|\+|\(|\)|\{|\})/', '\\\${1}', $field['format'] );
162
- $pregx = str_replace( '\{0\}', '(.*?)', $pregx );
163
- $pregx = '/^' . $pregx . '$/i';
164
  if ( preg_match( $pregx, $value, $matches ) ) {
165
  if ( isset( $matches[1] ) ) {
166
- $field['std'] = trim( $matches[1] );
167
- $field['std'] = preg_replace( '/^\.\.\//', TINVWL_URL . 'assets/', $field['std'] );
168
  }
169
  }
170
  } else {
@@ -173,6 +175,7 @@ abstract class TInvWL_Admin_BaseStyle extends TInvWL_Admin_BaseSection {
173
  }
174
  unset( $field['selector'], $field['element'], $field['format'] );
175
  }
 
176
  return $fields;
177
  }
178
 
@@ -180,6 +183,7 @@ abstract class TInvWL_Admin_BaseStyle extends TInvWL_Admin_BaseSection {
180
  * Save value to database
181
  *
182
  * @param array $data Post section data.
 
183
  * @return boolean
184
  */
185
  function constructor_save( $data ) {
@@ -203,7 +207,7 @@ abstract class TInvWL_Admin_BaseStyle extends TInvWL_Admin_BaseSection {
203
  }
204
  }
205
  if ( filter_input( INPUT_POST, 'save_buttons-setting_reset' ) ) {
206
- foreach ( $data as $key => $value ) {
207
  if ( ! in_array( $key, array( 'style' ) ) ) {
208
  $data[ $key ] = array();
209
  }
@@ -218,8 +222,9 @@ abstract class TInvWL_Admin_BaseStyle extends TInvWL_Admin_BaseSection {
218
  /**
219
  * Generate fields name for form
220
  *
221
- * @param string $selector Selector for fields.
222
  * @param string $element Attribute name.
 
223
  * @return string
224
  */
225
  function create_selectorkey( $selector, $element ) {
@@ -230,22 +235,24 @@ abstract class TInvWL_Admin_BaseStyle extends TInvWL_Admin_BaseSection {
230
  * Create array of css attributes
231
  *
232
  * @param string $css CSS content.
 
233
  * @return array
234
  */
235
  function break_css( $css ) {
236
  $results = array();
237
- $css = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css );
238
- $css = preg_replace( '/(\r|\n|\t| {2,})/', '', $css );
239
- $css = str_replace( array( '{', '}' ), array( ' { ', ' } ' ), $css );
240
  preg_match_all( '/(.+?)\s*?\{\s*?(.+?)\s*?\}/', $css, $matches );
241
- foreach ( $matches[0] as $i => $original ) {
242
  foreach ( explode( ';', $matches[2][ $i ] ) as $attr ) {
243
  if ( strlen( trim( $attr ) ) > 0 ) {
244
- list($name, $value) = explode( ':', $attr );
245
  $results[ trim( $matches[1][ $i ] ) ][ trim( $name ) ] = trim( $value );
246
  }
247
  }
248
  }
 
249
  return $results;
250
  }
251
 
@@ -253,6 +260,7 @@ abstract class TInvWL_Admin_BaseStyle extends TInvWL_Admin_BaseSection {
253
  * Convert settings to css
254
  *
255
  * @param array $style Array of style attributes.
 
256
  * @return string
257
  */
258
  function convert_styles( $style = array() ) {
@@ -275,10 +283,11 @@ abstract class TInvWL_Admin_BaseStyle extends TInvWL_Admin_BaseSection {
275
  foreach ( $elements as $key => &$element ) {
276
  $element = sprintf( '%s:%s;', $key, $element );
277
  }
278
- $elements = implode( '', $elements );
279
- $elements = sprintf( '%s {%s}', $selector, $elements );
280
  }
281
  $styles = implode( ' ', $styles );
 
282
  return $styles;
283
  }
284
  }
23
  */
24
  function prepare_sections() {
25
  $fields_data = array();
26
+ $fields = $this->default_style_settings();
27
+ $theme_file = TINVWL_PATH . implode( DIRECTORY_SEPARATOR, array( 'assets', 'css', 'theme.css' ) );
28
  if ( file_exists( $theme_file ) ) {
29
  $fields_data = $this->break_css( file_get_contents( $theme_file ) ); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.file_get_contents
30
  }
31
+ $_fields = $this->prepare_fields( $fields, $fields_data );
32
  foreach ( $_fields as &$_field ) {
33
  if ( ! array_key_exists( 'skin', $_field ) ) {
34
  switch ( $_field['type'] ) {
42
  }
43
  }
44
  }
45
+
46
  return $_fields;
47
  }
48
 
54
  function constructor_data() {
55
  return array(
56
  array(
57
+ 'id' => 'style',
58
+ 'title' => __( 'Templates', 'ti-woocommerce-wishlist' ),
59
+ 'desc' => '',
60
  'show_names' => false,
61
+ 'fields' => array(
62
  array(
63
+ 'type' => 'checkboxonoff',
64
+ 'name' => 'customstyle',
65
+ 'text' => __( 'Use Theme style', 'ti-woocommerce-wishlist' ),
66
+ 'std' => true,
67
+ 'extra' => array( 'tiwl-hide' => '.tinvwl-style-options' ),
68
+ 'class' => 'tinvwl-header-row',
69
  ),
70
  ),
71
  ),
72
  array(
73
+ 'id' => 'style_options',
74
+ 'title' => __( 'Template Options', 'ti-woocommerce-wishlist' ),
75
  'show_names' => true,
76
+ 'class' => 'tinvwl-style-options',
77
+ 'fields' => $this->prepare_sections(),
78
+ 'skin' => 'section-general',
79
  ),
80
  array(
81
+ 'id' => 'style_plain',
82
+ 'title' => __( 'Template Custom CSS', 'ti-woocommerce-wishlist' ),
83
+ 'desc' => '',
84
  'show_names' => false,
85
+ 'fields' => array(
86
  array(
87
+ 'type' => 'checkboxonoff',
88
+ 'name' => 'allow',
89
+ 'text' => __( 'Template Custom CSS', 'ti-woocommerce-wishlist' ),
90
+ 'std' => false,
91
+ 'extra' => array( 'tiwl-show' => '.tiwl-style-custom-allow' ),
92
+ 'class' => 'tinvwl-header-row',
93
  ),
94
  array(
95
+ 'type' => 'group',
96
+ 'id' => 'custom',
97
+ 'class' => 'tiwl-style-custom-allow',
98
  ),
99
  array(
100
+ 'type' => 'textarea',
101
+ 'name' => 'css',
102
+ 'text' => '',
103
+ 'std' => '',
104
  ),
105
  ),
106
  ),
107
  array(
108
+ 'id' => 'save_buttons',
109
+ 'class' => 'only-button',
110
  'noform' => true,
111
  'fields' => array(
112
  array(
113
+ 'type' => 'button_submit',
114
+ 'name' => 'setting_save',
115
+ 'std' => '<span><i class="ftinvwl ftinvwl-check"></i></span>' . __( 'Save Settings', 'ti-woocommerce-wishlist' ),
116
+ 'extra' => array( 'class' => 'tinvwl-btn split status-btn-ok' ),
117
  ),
118
  array(
119
+ 'type' => 'button_submit',
120
+ 'name' => 'setting_reset',
121
+ 'std' => '<span><i class="ftinvwl ftinvwl-times"></i></span>' . __( 'Reset', 'ti-woocommerce-wishlist' ),
122
+ 'extra' => array( 'class' => 'tinvwl-btn split status-btn-ok tinvwl-confirm-reset' ),
123
  ),
124
  array(
125
+ 'type' => 'button_submit_quick',
126
+ 'name' => 'setting_save_quick',
127
+ 'std' => '<span><i class="ftinvwl ftinvwl-floppy-o"></i></span>' . __( 'Save', 'ti-woocommerce-wishlist' ),
128
  ),
129
  ),
130
  ),
145
  *
146
  * @param array $fields Array of fields list.
147
  * @param array $data Array of default values for fields.
148
+ *
149
  * @return array
150
  */
151
  function prepare_fields( $fields = array(), $data = array() ) {
160
  if ( isset( $data[ $field['selector'] ][ $field['element'] ] ) ) {
161
  $value = $data[ $field['selector'] ][ $field['element'] ];
162
  if ( array_key_exists( 'format', (array) $field ) ) {
163
+ $pregx = preg_replace( '/(\[|\]|\\|\/|\^|\$|\%|\.|\||\?|\*|\+|\(|\)|\{|\})/', '\\\${1}', $field['format'] );
164
+ $pregx = str_replace( '\{0\}', '(.*?)', $pregx );
165
+ $pregx = '/^' . $pregx . '$/i';
166
  if ( preg_match( $pregx, $value, $matches ) ) {
167
  if ( isset( $matches[1] ) ) {
168
+ $field['std'] = trim( $matches[1] );
169
+ $field['std'] = preg_replace( '/^\.\.\//', TINVWL_URL . 'assets/', $field['std'] );
170
  }
171
  }
172
  } else {
175
  }
176
  unset( $field['selector'], $field['element'], $field['format'] );
177
  }
178
+
179
  return $fields;
180
  }
181
 
183
  * Save value to database
184
  *
185
  * @param array $data Post section data.
186
+ *
187
  * @return boolean
188
  */
189
  function constructor_save( $data ) {
207
  }
208
  }
209
  if ( filter_input( INPUT_POST, 'save_buttons-setting_reset' ) ) {
210
+ foreach ( array_keys( $data ) as $key ) {
211
  if ( ! in_array( $key, array( 'style' ) ) ) {
212
  $data[ $key ] = array();
213
  }
222
  /**
223
  * Generate fields name for form
224
  *
225
+ * @param string $selector Selector for fields.
226
  * @param string $element Attribute name.
227
+ *
228
  * @return string
229
  */
230
  function create_selectorkey( $selector, $element ) {
235
  * Create array of css attributes
236
  *
237
  * @param string $css CSS content.
238
+ *
239
  * @return array
240
  */
241
  function break_css( $css ) {
242
  $results = array();
243
+ $css = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css );
244
+ $css = preg_replace( '/(\r|\n|\t| {2,})/', '', $css );
245
+ $css = str_replace( array( '{', '}' ), array( ' { ', ' } ' ), $css );
246
  preg_match_all( '/(.+?)\s*?\{\s*?(.+?)\s*?\}/', $css, $matches );
247
+ foreach ( array_keys( $matches[0] ) as $i ) {
248
  foreach ( explode( ';', $matches[2][ $i ] ) as $attr ) {
249
  if ( strlen( trim( $attr ) ) > 0 ) {
250
+ list( $name, $value ) = explode( ':', $attr );
251
  $results[ trim( $matches[1][ $i ] ) ][ trim( $name ) ] = trim( $value );
252
  }
253
  }
254
  }
255
+
256
  return $results;
257
  }
258
 
260
  * Convert settings to css
261
  *
262
  * @param array $style Array of style attributes.
263
+ *
264
  * @return string
265
  */
266
  function convert_styles( $style = array() ) {
283
  foreach ( $elements as $key => &$element ) {
284
  $element = sprintf( '%s:%s;', $key, $element );
285
  }
286
+ $elements = implode( '', $elements );
287
+ $elements = sprintf( '%s {%s}', $selector, $elements );
288
  }
289
  $styles = implode( ' ', $styles );
290
+
291
  return $styles;
292
  }
293
  }
admin/settings/general.class.php CHANGED
@@ -864,7 +864,7 @@ class TInvWL_Admin_Settings_General extends TInvWL_Admin_BaseSection {
864
  tinv_update_option( 'processing', 'redirect_checkout', $data['general']['processing_redirect_checkout'] );
865
  tinv_update_option( 'processing', 'autoremove_status', 'tinvwl-addcart' );
866
  if ( filter_input( INPUT_POST, 'save_buttons-setting_reset' ) ) {
867
- foreach ( $data as $key => $value ) {
868
  if ( ! in_array( $key, array( 'page' ) ) ) {
869
  $data[ $key ] = array();
870
  }
864
  tinv_update_option( 'processing', 'redirect_checkout', $data['general']['processing_redirect_checkout'] );
865
  tinv_update_option( 'processing', 'autoremove_status', 'tinvwl-addcart' );
866
  if ( filter_input( INPUT_POST, 'save_buttons-setting_reset' ) ) {
867
+ foreach ( array_keys( $data ) as $key ) {
868
  if ( ! in_array( $key, array( 'page' ) ) ) {
869
  $data[ $key ] = array();
870
  }
admin/tinvwl.class.php CHANGED
@@ -53,9 +53,9 @@ class TInvWL_Admin_TInvWL extends TInvWL_Admin_Base {
53
  $files = scandir( $dir );
54
  foreach ( $files as $value ) {
55
  if ( preg_match( '/\.class\.php$/i', $value ) ) {
56
- $file = preg_replace( '/\.class\.php$/i', '', $value );
57
- $class = 'TInvWL_Admin_Settings_' . ucfirst( $file );
58
- $settings = new $class( $this->_name, $this->_version );
59
  }
60
  }
61
 
@@ -190,7 +190,7 @@ class TInvWL_Admin_TInvWL extends TInvWL_Admin_Base {
190
  wp_enqueue_script( $this->_name . '-bootstrap', TINVWL_URL . 'assets/js/bootstrap' . $suffix . '.js', array( 'jquery' ), $this->_version, 'all' );
191
  wp_register_script( $this->_name, TINVWL_URL . 'assets/js/admin' . $suffix . '.js', array(
192
  'jquery',
193
- 'wp-color-picker'
194
  ), $this->_version, 'all' );
195
  wp_localize_script( $this->_name, 'tinvwl_comfirm', array(
196
  'text_comfirm_reset' => __( 'Are you sure you want to reset the settings?', 'ti-woocommerce-wishlist' ),
53
  $files = scandir( $dir );
54
  foreach ( $files as $value ) {
55
  if ( preg_match( '/\.class\.php$/i', $value ) ) {
56
+ $file = preg_replace( '/\.class\.php$/i', '', $value );
57
+ $class = 'TInvWL_Admin_Settings_' . ucfirst( $file );
58
+ new $class( $this->_name, $this->_version );
59
  }
60
  }
61
 
190
  wp_enqueue_script( $this->_name . '-bootstrap', TINVWL_URL . 'assets/js/bootstrap' . $suffix . '.js', array( 'jquery' ), $this->_version, 'all' );
191
  wp_register_script( $this->_name, TINVWL_URL . 'assets/js/admin' . $suffix . '.js', array(
192
  'jquery',
193
+ 'wp-color-picker',
194
  ), $this->_version, 'all' );
195
  wp_localize_script( $this->_name, 'tinvwl_comfirm', array(
196
  'text_comfirm_reset' => __( 'Are you sure you want to reset the settings?', 'ti-woocommerce-wishlist' ),
assets/css/admin.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.11.1
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
1
  /**
2
  * WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.12.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
assets/css/public.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.11.1
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
1
  /**
2
  * WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.12.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  @font-face{font-family:'tinvwl-webfont';src:url("../fonts/tinvwl-webfont.eot?xu2uyi");src:url("../fonts/tinvwl-webfont.eot?xu2uyi#iefix") format("embedded-opentype"),url("../fonts/tinvwl-webfont.ttf?xu2uyi") format("truetype"),url("../fonts/tinvwl-webfont.woff?xu2uyi") format("woff"),url("../fonts/tinvwl-webfont.svg?xu2uyi#tinvwl-webfont") format("svg");font-weight:normal;font-style:normal}
assets/css/theme.min.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.11.1
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
1
  /**
2
  * WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.12.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  .tinv-wishlist,.tinv-wishlist input,.tinv-wishlist select,.tinv-wishlist textarea,.tinv-wishlist button,.tinv-wishlist input[type="button"],.tinv-wishlist input[type="reset"],.tinv-wishlist input[type="submit"]{font-family:Georgia,serif;font-size:14px;font-weight:400;text-transform:none;line-height:1.75}
assets/js/admin.min.js CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.11.1
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  "use strict";function TInvWL($,h){this.pf="tinvwl",this.g="_",this.ho=h||!1,this.n="TInvWL",this.aj_act=function(t){return[this.pf,t].join(this.g)},this._csel=function(t,n){return"{0}{1}{2}".format(n=n||".",this.pf,t)},this._tm=function(t){var n=$("script#{0}[type='text/template']".format(t));return n.length?n.html():""},this.formElm=function(){if($(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker){var e=function(t){var n=t.substring(1),i=parseInt(n,16);return.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i>>0&255)},n=this._csel("-form-color");$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){$(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)).iris("hide"):$(n).iris("hide")})}},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),e=t.parents("form").eq(0);i&&("-1"===i.val()?n.preventDefault():e.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){var i=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");i&&""===i.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t=this.n;if(this.ho){var n=new Date;t=t+n.getFullYear()+n.getMonth()+n.getDate()}window[t]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})}),function(o){var n=o.n,ho=o.ho,c="";for(var i in ho&&(c="t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),"),o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}(this)}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.attr("type","checkbox").hide().removeAttr("class").wrap(e).before(t),e=n.parent(),n.on("change",function(t){if(e.hasClass("disabled"))return t.preventDefault();e.toggleClass("checked",s(this).is(":checked"))}),e.on("click",function(t){if(e.hasClass("disabled"))return t.preventDefault();n.is(":enabled")&&e.hasClass("checked")===n.is(":checked")&&n.click()})),n})},s.fn.tiwl_onoffblock=function(t){var n={onEachElm:function(){},isChecked:function(){return s(this).is(":checked")}},c=s.extend(!0,{},n,t);return s(this).each(function(){var t=s(this),n=function(){var t=s(this),n=t.attr("tiwl-show"),i=t.attr("tiwl-hide"),e=c.isChecked.call(t),o=function(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})};return"string"==typeof n&&o(n,e),"string"==typeof i&&o(i,!e),t};return t.is("input")&&"checkbox"==t.attr("type")?(s(this).on("change",n),n.call(t)):t})},s.fn.tiwl_byvalueblock=function(t){var n={onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},i=s.extend(!0,{},n,t);return s(this).each(function(){var t=s(this),n=function(e){var t=s(this),n=t.attr("tiwl-show"),i=t.attr("tiwl-hide"),o=e.onClick.call(t),c=function(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})};return"string"==typeof n&&c(n,o),"string"==typeof i&&c(i,!o),t};return t.is("input")||t.is("select")?(s(this).on("change",function(){n.call(this,i)}),n.call(t,i)):t})};var n=new TInvWL(s);s(document).ready(function(){if(n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover){var t=s(".tinvwl-help");t.popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})}s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})})}(jQuery);
1
  /**
2
  * WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.12.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  "use strict";function TInvWL($,h){this.pf="tinvwl",this.g="_",this.ho=h||!1,this.n="TInvWL",this.aj_act=function(t){return[this.pf,t].join(this.g)},this._csel=function(t,n){return"{0}{1}{2}".format(n=n||".",this.pf,t)},this._tm=function(t){var n=$("script#{0}[type='text/template']".format(t));return n.length?n.html():""},this.formElm=function(){if($(this._csel("-form-onoff")).tiwl_onoff(),$("input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]").tiwl_onoffblock(),$("[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]").tiwl_byvalueblock(),void 0!==$.fn.wpColorPicker){var e=function(t){var n=t.substring(1),i=parseInt(n,16);return.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i>>0&255)},n=this._csel("-form-color");$(n).each(function(){var n=$(this),t=$(this).closest(".tinvwl-color-picker"),i=t.find(".tinvwl-eyedropper");n.css("background-color",n.val()),175<e(n.val())&&n.css("color","#000000"),n.iris({mode:"hsv",target:$(this).parent().parent(),change:function(t,n){175<e(n.color.toCSS())?$(this).css("color","#000000"):$(this).css("color",""),$(this).css("background-color",n.color.toCSS())}}),t.on("click",".iris-square-value",function(t){t.preventDefault(),n.iris("toggle")}),i.on("click",function(t){t.preventDefault(),n.iris("show")}),n.on("focusin",function(){n.iris("show")})}),$(document).on("click",function(t){$(t.target).is(n+", .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper")?$(n).not($(t.target).closest(".tinvwl-color-picker").find(n)).iris("hide"):$(n).iris("hide")})}},this.wizard_page=function(t){$(t).find("select").change(this._wizard_page_ch),this.wizard_page_ch($(t).find("select"))},this.wizard_page_ch=function(t){var n=(t=$(t)).parent(this._csel("-page-select")),i=n.find("input[type=hidden]").val(),e=n.find(this._csel("-error-icon")),o=n.find(this._csel("-error-desc"));""!==t.val()?(n.removeClass("tinvwl-error"),e.hide(),o.hide()):0==i&&(n.addClass("tinvwl-error"),e.show(),o.show())},this.pageElm=function(){$(this._csel("-header","div.")).prependTo("#wpbody-content"),$(this._csel("-page-select")).each(this._wizard_page),$(".bulkactions [type=submit]").each(this._control_bulkactions),$(".action-search [type=submit]").each(this._control_search)},this.control_bulkactions=function(t){$(t).on("click",this._control_bulkactions_ck)},this.control_bulkactions_ck=function(t,n){var i=(t=$(t)).parents(".bulkactions").eq(0).find("[name=action]"),e=t.parents("form").eq(0);i&&("-1"===i.val()?n.preventDefault():e.find("input[type=checkbox]:checked").length||n.preventDefault())},this.control_search=function(t){$(t).on("click",this._control_search_ck)},this.control_search_ck=function(t,n){var i=(t=$(t)).parents(".action-search").eq(0).find("[name=s]");i&&""===i.val()&&n.preventDefault()},this.Run=function(){this.formElm(),this.pageElm()},this.cg=function(){var t=this.n;if(this.ho){var n=new Date;t=t+n.getFullYear()+n.getMonth()+n.getDate()}window[t]=this},this.cg(),String.prototype.format||(String.prototype.format=function(){var i=arguments;return this.replace(/{(\d+)}/g,function(t,n){return void 0!==i[n]?i[n]:t})}),function(o){var n=o.n,ho=o.ho,c="";for(var i in ho&&(c="t=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),"),o)"function"!=typeof o[i]||"_"===i[0]||o.hasOwnProperty("_"+i)||eval("o._"+i+"=function(a,b,c,d){var n='"+n+"',"+c+"o=window[n]||null;if (o) {return o."+i+"(this,a,b,c,d);};};")}(this)}!function(s){s.fn.tiwl_onoff=function(t){var o=s.extend(!0,{},{value:{on:"",off:""},class:"tiwlform-onoff",wrap:"container",button:"button"},t);return s(this).each(function(){var n=s(this),t=s("<div>").attr({class:o.class+"-"+o.button}),i=o.class+"-"+o.wrap,e=s("<div>").attr({id:n.attr("id")+"_"+o.wrap,class:i});return n.is("input")&&(e.attr("class",e.attr("class")+" "+n.attr("class")),n.is(":disabled")&&(e.toggleClass("disabled",n.is(":disabled")),n.prop("disabled",!1)),e.toggleClass("checked",n.is(":checked")),n.attr("type","checkbox").hide().removeAttr("class").wrap(e).before(t),e=n.parent(),n.on("change",function(t){if(e.hasClass("disabled"))return t.preventDefault();e.toggleClass("checked",s(this).is(":checked"))}),e.on("click",function(t){if(e.hasClass("disabled"))return t.preventDefault();n.is(":enabled")&&e.hasClass("checked")===n.is(":checked")&&n.click()})),n})},s.fn.tiwl_onoffblock=function(t){var n={onEachElm:function(){},isChecked:function(){return s(this).is(":checked")}},c=s.extend(!0,{},n,t);return s(this).each(function(){var t=s(this),n=function(){var t=s(this),n=t.attr("tiwl-show"),i=t.attr("tiwl-hide"),e=c.isChecked.call(t),o=function(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){c.onEachElm.call(s(n).toggle(i))})};return"string"==typeof n&&o(n,e),"string"==typeof i&&o(i,!e),t};return t.is("input")&&"checkbox"==t.attr("type")?(s(this).on("change",n),n.call(t)):t})},s.fn.tiwl_byvalueblock=function(t){var n={onEachElm:function(){},onClick:function(){return s(this).val()==s(this).attr("tiwl-value")}},i=s.extend(!0,{},n,t);return s(this).each(function(){var t=s(this),n=function(e){var t=s(this),n=t.attr("tiwl-show"),i=t.attr("tiwl-hide"),o=e.onClick.call(t),c=function(t,i){t=t.match(/[\w\d-\>\.\#\:\=\[\]]+/gim)||[],s.each(t,function(t,n){e.onEachElm.call(s(n).toggle(i))})};return"string"==typeof n&&c(n,o),"string"==typeof i&&c(i,!o),t};return t.is("input")||t.is("select")?(s(this).on("change",function(){n.call(this,i)}),n.call(t,i)):t})};var n=new TInvWL(s);s(document).ready(function(){if(n.Run(),jQuery('input[name="general-show_notice"]').change(function(){var t=!jQuery(this).is(":checked"),n=jQuery('input[name="general-redirect_require_login"]');t&&!n.is(":checked")&&n.click().trigger("change"),n.closest(".tiwlform-onoff-container").toggleClass("disabled",t)}).change(),s(".tablenav").each(function(){var t=s(this);s.trim(t.find(".alignleft").html()).length||t.find(".alignleft").remove(),s.trim(t.find(".alignright").html()).length&&!t.find(".tablenav-pages").hasClass("one-page")||(t.find(".alignright").remove(),t.find(".tinv-wishlist-clear").remove()),s.trim(t.html()).length||t.remove()}),s(".tablenav .bulkactions select").addClass("tinvwl-select grey").wrap('<span class="tinvwl-select-wrap">').parent().append('<span class="tinvwl-caret"><span></span></span>'),s(".tablenav .bulkactions .button.action, .tablenav #search-submit").removeClass("button").addClass("tinvwl-btn grey"),s(".tinvwl-modal-btn").on("click",function(){s(this).next(".tinvwl-modal").addClass("tinvwl-modal-open")}),s(".tinvwl-overlay, .tinvwl-close-modal, .tinvwl_button_close").on("click",function(t){t.preventDefault(),s(this).parents(".tinvwl-modal:first").removeClass("tinvwl-modal-open")}),void 0!==s.fn.popover){var t=s(".tinvwl-help");t.popover({content:function(){return s(this).closest(".tinvwl-info-wrap").find(".tinvwl-info-desc").html()}}),t.on("click",function(){s(this).popover("toggle")}),t.on("focusout",function(){s(this).popover("hide")}),s(window).on("resize",function(){t.popover("hide")})}s("body").on("click",".tinvwl-confirm-reset",function(t){t.preventDefault(),confirm(tinvwl_comfirm.text_comfirm_reset)&&s(this).removeClass("tinvwl-confirm-reset").trigger("click")})})}(jQuery);
assets/js/public.min.js CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  * WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
- * @version 1.11.1
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  "use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function update_cart_hash(){jQuery(document.body).on("wc_fragments_loaded.wishlist wc_fragments_refreshed.wishlist",function(){if("undefined"==typeof wc_cart_fragments_params)return!1;var t=wc_cart_fragments_params.cart_hash_key;localStorage.setItem(t,localStorage.getItem(t)+(new Date).getTime()),sessionStorage.setItem(t,sessionStorage.getItem(t)+(new Date).getTime()),jQuery(document.body).off("wc_fragments_loaded.wishlist wc_fragments_refreshed.wishlist")})}function showTooltip(t,i){t.setAttribute("class","social social-clipboard tooltipped tooltipped-s"),t.setAttribute("aria-label",i)}function clearTooltip(t){t.currentTarget.setAttribute("class","social social-clipboard "),t.currentTarget.removeAttribute("aria-label")}!function(r){r.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href,text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){r(this).append(r("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){r(t).addClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){r(t).removeClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(r(this).is(".disabled-add-wishlist"))return!1;r(this).is(".ftinvwl-animated")&&r(this).addClass("ftinvwl-pulse"),this.tinvwl_dialog?this.tinvwl_dialog.show_list.call(this):o.onActionProduct.call(this),update_cart_hash()},onPrepareDataAction:function(){},filterProductAlreadyIn:function(t){t=t||[];var n={};return r("form.cart[method=post], .woocommerce-variation-add-to-cart").find("input, select").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),e=r(this).val();"checkbox"===i||"radio"===i?r(this).is(":checked")&&(n["form"+t]=e):n["form"+t]=e}),n=n.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof n)return t.in;var i=parseInt(n);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=o.onPrepareList.call(t)||t,t=o.filterProductAlreadyIn.call(this,t)||t,r(this).parent().parent().find(".already-in").remove();var e="";switch(t.length){case 0:break;default:e=r("<ul>");r.each(t,function(t,i){e.append(r("<li>").html(r("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}e.length&&r(this).closest(".tinv-modal-inner").find("img").after(r("<div>").addClass("already-in").html(o.text_already_in+" ").append(e))},onAction:{redirect:function(t){o.redirectTimer&&clearTimeout(o.redirectTimer),o.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(t){r(this).attr("data-tinv-wl-list",t)},msg:function(t){if(!t)return!1;var i=r(t).eq(0);r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r("body > .tinv-wishlist").append(i),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),o.redirectTimer&&clearTimeout(o.redirectTimer)})},status:function(t){t&&r(this).addClass("tinvwl-product-in-list")},removed:function(t){t&&r(this).removeClass("tinvwl-product-in-list").removeClass("tinvwl-product-make-remove").attr("data-tinv-wl-action","addto")},make_remove:function(t){r(this).toggleClass("tinvwl-product-make-remove",t).attr("data-tinv-wl-action",t?"remove":"addto")},fragments:function(t){if("undefined"==typeof wc_cart_fragments_params)return r.each(t,function(t,i){r(t).replaceWith(i)}),!1;var i;try{i="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc"),window.localStorage.setItem("wc","test"),window.localStorage.removeItem("wc")}catch(t){i=!1}if(i)try{var e=r.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),n=wc_cart_fragments_params.ajax_url.toString()+"-wc_cart_hash",o=sessionStorage.getItem(n),a=Cookies.get("woocommerce_cart_hash"),l=sessionStorage.getItem("wc_cart_created");if(null!=o&&""!==o||(o=""),null!=a&&""!==a||(a=""),o&&(null==l||""===l))throw"No cart_created";if(r.each(t,function(t,i){e[t]=i}),localStorage.setItem(n,localStorage.getItem(n)+(new Date).getTime()),sessionStorage.setItem(n,sessionStorage.getItem(n)+(new Date).getTime()),sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(e)),!e||!e["div.widget_shopping_cart_content"]||o!==a)throw"No fragment";r.each(e,function(t,i){r(t).replaceWith(i)}),r(document.body).trigger("wc_fragments_loaded")}catch(t){r(document.body).trigger("wc_fragment_refresh")}}},onActionProduct:function(t,i){var s={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:r(this).attr("data-tinv-wl-producttype"),product_id:r(this).attr("data-tinv-wl-product")||0,product_variation:r(this).attr("data-tinv-wl-productvariation")||0,product_action:r(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},e=this;r(e).closest("form.cart[method=post], .tinvwl-loop-button-wrapper").find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),e=r(this).val(),n=10,o=function t(i,e){if("object"!==_typeof(e))return e;for(var n in void 0===i&&(i={}),e)if(""===n){var o=-1;for(o in i)o=o;i[o=parseInt(o)+1]=t(i[n],e[n])}else i[n]=t(i[n],e[n]);return i};if("button"!==i&&void 0!==t&&"attribute_"!=t.substr(0,10)){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<n;){var a=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===a.length){var l={};l[a[2]]=e,e=l}t=a[1],n--}"checkbox"===i||"radio"===i?r(this).is(":checked")&&(e.length||"object"===_typeof(e)||(e=!0),s.form[t]=o(s.form[t],e)):s.form[t]=o(s.form[t],e)}}),s=o.onPrepareDataAction.call(e,s)||s,r.post(o.api_url,s,function(t){if(o.onDialogHide.call(e.tinvwl_dialog,e),"object"===_typeof(t))for(var i in t)"function"==typeof o.onAction[i]&&o.onAction[i].call(e,t[i]);else"function"==typeof o.onAction.msg&&o.onAction.msg.call(e,t)})}},o=r.extend(!0,{},i,t);return r(this).each(function(){if(!r(this).attr("data-tinv-wl-list"))return!1;if(o.dialogbox&&o.dialogbox.length&&(this.tinvwl_dialog=o.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=o.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=r(this).nextAll(o.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){o.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var e=r(this).find(o.class.select).eq(0);r(this).find(o.class.newtitle).hide().val(""),e.html(""),r.each(t,function(t,i){o.onCreateWishList.call(e,i)}),o.text_create&&o.onCreateWishList.call(e,{ID:"",title:o.text_create,in:!1}),o.onMultiProductAlreadyIn.call(e,t),o.onSelectWishList.call(e,t),r(this).find(o.class.newtitle).toggle(""===e.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=r.parseJSON(r(this).attr("data-tinv-wl-list"))||[];t.length?(t=o.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),o.onDialogShow.call(this.tinvwl_dialog,this)):o.onActionProduct.call(this)});var n=this;r(this.tinvwl_dialog).find(o.class.dialogbutton).off("click").on("click",function(){var t,i=r(n.tinvwl_dialog).find(o.class.select),e=r(n.tinvwl_dialog).find(o.class.newtitle);i.val()||e.val()?o.onActionProduct.call(n,i.val(),e.val()):((t=e.is(":visible")?e:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}r(this).off("click").on("click",o.onClick),o.onInited.call(this,o)})},r(document).ready(function(){r("body").on("click",".tinvwl_add_to_wishlist_button",function(t){if(r(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);r(this).is(".inited-add-wishlist")||r(this).tinvwl_to_wishlist({onInited:function(t){r(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),r(document).on("hide_variation",".variations_form",function(t){var i=r(this).find(".tinvwl_add_to_wishlist_button");i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),r(document).on("show_variation",".variations_form",function(t,i,e){var n=r(this).find(".tinvwl_add_to_wishlist_button");if(n.length){var o=JSON.parse(n.attr("data-tinv-wl-list")),a=!1,l="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in o)o[s].hasOwnProperty("in")&&Array.isArray(o[s].in)&&-1<(o[s].in||[]).indexOf(i.variation_id)&&(a=!0);n.toggleClass("tinvwl-product-in-list",a).toggleClass("tinvwl-product-make-remove",a&&l).attr("data-tinv-wl-action",a&&l?"remove":"addto"),t.preventDefault(),n.removeClass("disabled-add-wishlist")}})})}(jQuery),function(n){n(document).ready(function(){if(n("#tinvwl_manage_actions, #tinvwl_product_actions").addClass("form-control").parent().wrapInner('<div class="tinvwl-input-group tinvwl-no-full">').find("button").wrap('<span class="tinvwl-input-group-btn">'),n(".tinv-lists-nav").each(function(){n.trim(n(this).html()).length||n(this).remove()}),n("body").on("click",".social-buttons .social[title!=email][title!=whatsapp][title!=clipboard]",function(t){var i=window.open(n(this).attr("href"),n(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}n("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),n("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),n(this).parents(".tinv-modal:first").removeClass("tinv-modal-open")}),n("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){n(this).data("url")&&(t.preventDefault(),window.location=n(this).data("url"))});var e=n(".tinv-wishlist .navigation-button");e.length&&e.each(function(){var t=n(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),n(".tinv-login .showlogin").unbind("click").on("click",function(t){t.preventDefault(),n(this).closest(".tinv-login").find(".login").toggle()}),n(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){n(this).toggle(!!n(this).children().not(".look_in").length||!!n(this).children(".look_in").children().length)})}),n(document.body).on("wc_fragments_refreshed wc_fragments_loaded",function(){var t=!("0"==n(".wishlist_products_counter_number").html()||""==n(".wishlist_products_counter_number").html());n(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",t)}),update_cart_hash()}(jQuery),function(n){n.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return n(this).val()},rule:function(){var t=n(this).parents("form").eq(0).find(e.selector),i=e.invert;return 0===t.length?e.ifempty:(t.each(function(){i&&!e.invert||!i&&e.invert||(i=Boolean(e.validate.call(n(this))))}),i)}},e=n.extend(!0,{},i,t);return n(this).each(function(){n(this).on("click",function(t){e.rule.call(n(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},n(document).ready(function(){n(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),n(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return n(this).is(":checked")}}),n(".global-cb").on("click",function(){n(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",n(this).is(":checked"))})})}(jQuery);
1
  /**
2
  * WooCommerce Wishlist Plugin - Allow your store guests and customers to add products to Wishlist. Add Wishlist functionality to your store for free.
3
+ * @version 1.12.0
4
  * @link https://wordpress.org/plugins/ti-woocommerce-wishlist/
5
  */
6
  "use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function update_cart_hash(){jQuery(document.body).on("wc_fragments_loaded.wishlist wc_fragments_refreshed.wishlist",function(){if("undefined"==typeof wc_cart_fragments_params)return!1;var t=wc_cart_fragments_params.cart_hash_key;localStorage.setItem(t,localStorage.getItem(t)+(new Date).getTime()),sessionStorage.setItem(t,sessionStorage.getItem(t)+(new Date).getTime()),jQuery(document.body).off("wc_fragments_loaded.wishlist wc_fragments_refreshed.wishlist")})}function showTooltip(t,i){t.setAttribute("class","social social-clipboard tooltipped tooltipped-s"),t.setAttribute("aria-label",i)}function clearTooltip(t){t.currentTarget.setAttribute("class","social social-clipboard "),t.currentTarget.removeAttribute("aria-label")}!function(r){r.fn.tinvwl_to_wishlist=function(t){var i={api_url:window.location.href,text_create:window.tinvwl_add_to_wishlist.text_create,text_already_in:window.tinvwl_add_to_wishlist.text_already_in,class:{dialogbox:".tinvwl_add_to_select_wishlist",select:".tinvwl_wishlist",newtitle:".tinvwl_new_input",dialogbutton:".tinvwl_button_add"},redirectTimer:null,onPrepareList:function(){},onGetDialogBox:function(){},onPrepareDialogBox:function(){r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r(this).appendTo("body > .tinv-wishlist")},onCreateWishList:function(t){r(this).append(r("<option>").html(t.title).val(t.ID).toggleClass("tinv_in_wishlist",t.in))},onSelectWishList:function(){},onDialogShow:function(t){r(t).addClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onDialogHide:function(t){r(t).removeClass("tinv-modal-open"),r(t).removeClass("ftinvwl-pulse")},onInited:function(){},onClick:function(){if(r(this).is(".disabled-add-wishlist"))return!1;r(this).is(".ftinvwl-animated")&&r(this).addClass("ftinvwl-pulse"),this.tinvwl_dialog?this.tinvwl_dialog.show_list.call(this):o.onActionProduct.call(this),update_cart_hash()},onPrepareDataAction:function(){},filterProductAlreadyIn:function(t){t=t||[];var n={};return r("form.cart[method=post], .woocommerce-variation-add-to-cart").find("input, select").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),e=r(this).val();"checkbox"===i||"radio"===i?r(this).is(":checked")&&(n["form"+t]=e):n["form"+t]=e}),n=n.formvariation_id,t.filter(function(t){if("object"!==_typeof(t.in)||"string"!=typeof n)return t.in;var i=parseInt(n);return 0<=t.in.indexOf(i)})},onMultiProductAlreadyIn:function(t){t=t||[];t=o.onPrepareList.call(t)||t,t=o.filterProductAlreadyIn.call(this,t)||t,r(this).parent().parent().find(".already-in").remove();var e="";switch(t.length){case 0:break;default:e=r("<ul>");r.each(t,function(t,i){e.append(r("<li>").html(r("<a>").html(i.title).attr({href:i.url})).val(i.ID))})}e.length&&r(this).closest(".tinv-modal-inner").find("img").after(r("<div>").addClass("already-in").html(o.text_already_in+" ").append(e))},onAction:{redirect:function(t){o.redirectTimer&&clearTimeout(o.redirectTimer),o.redirectTimer=window.setTimeout(function(){window.location.href=t},4e3)},force_redirect:function(t){window.location.href=t},wishlists:function(t){r(this).attr("data-tinv-wl-list",t)},msg:function(t){if(!t)return!1;var i=r(t).eq(0);r("body > .tinv-wishlist").length||r("body").append(r("<div>").addClass("tinv-wishlist")),r("body > .tinv-wishlist").append(i),i.on("click",".tinv-close-modal, .tinvwl_button_close, .tinv-overlay",function(t){t.preventDefault(),i.remove(),o.redirectTimer&&clearTimeout(o.redirectTimer)})},status:function(t){t&&r(this).addClass("tinvwl-product-in-list")},removed:function(t){t&&r(this).removeClass("tinvwl-product-in-list").removeClass("tinvwl-product-make-remove").attr("data-tinv-wl-action","addto")},make_remove:function(t){r(this).toggleClass("tinvwl-product-make-remove",t).attr("data-tinv-wl-action",t?"remove":"addto")},fragments:function(t){if("undefined"==typeof wc_cart_fragments_params)return r.each(t,function(t,i){r(t).replaceWith(i)}),!1;var i;try{i="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc"),window.localStorage.setItem("wc","test"),window.localStorage.removeItem("wc")}catch(t){i=!1}if(i)try{var e=r.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),n=wc_cart_fragments_params.ajax_url.toString()+"-wc_cart_hash",o=sessionStorage.getItem(n),a=Cookies.get("woocommerce_cart_hash"),l=sessionStorage.getItem("wc_cart_created");if(null!=o&&""!==o||(o=""),null!=a&&""!==a||(a=""),o&&(null==l||""===l))throw"No cart_created";if(r.each(t,function(t,i){e[t]=i}),localStorage.setItem(n,localStorage.getItem(n)+(new Date).getTime()),sessionStorage.setItem(n,sessionStorage.getItem(n)+(new Date).getTime()),sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(e)),!e||!e["div.widget_shopping_cart_content"]||o!==a)throw"No fragment";r.each(e,function(t,i){r(t).replaceWith(i)}),r(document.body).trigger("wc_fragments_loaded")}catch(t){r(document.body).trigger("wc_fragment_refresh")}}},onActionProduct:function(t,i){var s={form:{},tinv_wishlist_id:t||"",tinv_wishlist_name:i||"",product_type:r(this).attr("data-tinv-wl-producttype"),product_id:r(this).attr("data-tinv-wl-product")||0,product_variation:r(this).attr("data-tinv-wl-productvariation")||0,product_action:r(this).attr("data-tinv-wl-action")||"addto",redirect:window.location.href},e=this;r(e).closest("form.cart[method=post], .tinvwl-loop-button-wrapper").find("input:not(:disabled), select:not(:disabled), textarea:not(:disabled)").each(function(){var t=r(this).attr("name"),i=r(this).attr("type"),e=r(this).val(),n=10,o=function t(i,e){if("object"!==_typeof(e))return e;for(var n in void 0===i&&(i={}),e)if(""===n){var o=-1;for(o in i)o=o;i[o=parseInt(o)+1]=t(i[n],e[n])}else i[n]=t(i[n],e[n]);return i};if("button"!==i&&void 0!==t&&"attribute_"!=t.substr(0,10)){for(;/^(.+)\[([^\[\]]*?)\]$/.test(t)&&0<n;){var a=t.match(/^(.+)\[([^\[\]]*?)\]$/);if(3===a.length){var l={};l[a[2]]=e,e=l}t=a[1],n--}"checkbox"===i||"radio"===i?r(this).is(":checked")&&(e.length||"object"===_typeof(e)||(e=!0),s.form[t]=o(s.form[t],e)):s.form[t]=o(s.form[t],e)}}),s=o.onPrepareDataAction.call(e,s)||s,r.post(o.api_url,s,function(t){if(o.onDialogHide.call(e.tinvwl_dialog,e),"object"===_typeof(t))for(var i in t)"function"==typeof o.onAction[i]&&o.onAction[i].call(e,t[i]);else"function"==typeof o.onAction.msg&&o.onAction.msg.call(e,t)})}},o=r.extend(!0,{},i,t);return r(this).each(function(){if(!r(this).attr("data-tinv-wl-list"))return!1;if(o.dialogbox&&o.dialogbox.length&&(this.tinvwl_dialog=o.dialogbox),this.tinvwl_dialog||(this.tinvwl_dialog=o.onGetDialogBox.call(this)),!this.tinvwl_dialog){var t=r(this).nextAll(o.class.dialogbox).eq(0);t.length&&(this.tinvwl_dialog=t)}if(this.tinvwl_dialog){o.onPrepareDialogBox.call(this.tinvwl_dialog),"function"!=typeof this.tinvwl_dialog.update_list&&(this.tinvwl_dialog.update_list=function(t){var e=r(this).find(o.class.select).eq(0);r(this).find(o.class.newtitle).hide().val(""),e.html(""),r.each(t,function(t,i){o.onCreateWishList.call(e,i)}),o.text_create&&o.onCreateWishList.call(e,{ID:"",title:o.text_create,in:!1}),o.onMultiProductAlreadyIn.call(e,t),o.onSelectWishList.call(e,t),r(this).find(o.class.newtitle).toggle(""===e.val())}),"function"!=typeof this.tinvwl_dialog.show_list&&(this.tinvwl_dialog.show_list=function(){var t=r.parseJSON(r(this).attr("data-tinv-wl-list"))||[];t.length?(t=o.onPrepareList.call(t)||t,this.tinvwl_dialog.update_list(t),o.onDialogShow.call(this.tinvwl_dialog,this)):o.onActionProduct.call(this)});var n=this;r(this.tinvwl_dialog).find(o.class.dialogbutton).off("click").on("click",function(){var t,i=r(n.tinvwl_dialog).find(o.class.select),e=r(n.tinvwl_dialog).find(o.class.newtitle);i.val()||e.val()?o.onActionProduct.call(n,i.val(),e.val()):((t=e.is(":visible")?e:i).addClass("empty-name-wishlist"),window.setTimeout(function(){t.removeClass("empty-name-wishlist")},1e3))})}r(this).off("click").on("click",o.onClick),o.onInited.call(this,o)})},r(document).ready(function(){r("body").on("click",".tinvwl_add_to_wishlist_button",function(t){if(r(this).is(".disabled-add-wishlist"))return t.preventDefault(),void window.alert(tinvwl_add_to_wishlist.i18n_make_a_selection_text);r(this).is(".inited-add-wishlist")||r(this).tinvwl_to_wishlist({onInited:function(t){r(this).addClass("inited-add-wishlist"),t.onClick.call(this)}})}),r(document).on("hide_variation",".variations_form",function(t){var i=r(this).find(".tinvwl_add_to_wishlist_button");i.length&&!tinvwl_add_to_wishlist.allow_parent_variable&&(t.preventDefault(),i.addClass("disabled-add-wishlist"))}),r(document).on("show_variation",".variations_form",function(t,i,e){var n=r(this).find(".tinvwl_add_to_wishlist_button");if(n.length){var o=JSON.parse(n.attr("data-tinv-wl-list")),a=!1,l="1"==window.tinvwl_add_to_wishlist.simple_flow;for(var s in o)o[s].hasOwnProperty("in")&&Array.isArray(o[s].in)&&-1<(o[s].in||[]).indexOf(i.variation_id)&&(a=!0);n.toggleClass("tinvwl-product-in-list",a).toggleClass("tinvwl-product-make-remove",a&&l).attr("data-tinv-wl-action",a&&l?"remove":"addto"),t.preventDefault(),n.removeClass("disabled-add-wishlist")}})})}(jQuery),function(n){n(document).ready(function(){if(n("#tinvwl_manage_actions, #tinvwl_product_actions").addClass("form-control").parent().wrapInner('<div class="tinvwl-input-group tinvwl-no-full">').find("button").wrap('<span class="tinvwl-input-group-btn">'),n(".tinv-lists-nav").each(function(){n.trim(n(this).html()).length||n(this).remove()}),n("body").on("click",".social-buttons .social[title!=email][title!=whatsapp][title!=clipboard]",function(t){var i=window.open(n(this).attr("href"),n(this).attr("title"),"width=420,height=320,resizable=yes,scrollbars=yes,status=yes");i&&(i.focus(),t.preventDefault())}),"undefined"!=typeof ClipboardJS){new ClipboardJS(".social-buttons .social.social-clipboard",{text:function(t){return t.getAttribute("href")}}).on("success",function(t){showTooltip(t.trigger,tinvwl_add_to_wishlist.tinvwl_clipboard)});for(var t=document.querySelectorAll(".social-buttons .social.social-clipboard"),i=0;i<t.length;i++)t[i].addEventListener("mouseleave",clearTooltip),t[i].addEventListener("blur",clearTooltip)}n("body").on("click",".social-buttons .social.social-clipboard",function(t){t.preventDefault()}),n("body").on("click",".tinv-wishlist .tinv-overlay, .tinv-wishlist .tinv-close-modal, .tinv-wishlist .tinvwl_button_close",function(t){t.preventDefault(),n(this).parents(".tinv-modal:first").removeClass("tinv-modal-open")}),n("body").on("click",".tinv-wishlist .tinvwl-btn-onclick",function(t){n(this).data("url")&&(t.preventDefault(),window.location=n(this).data("url"))});var e=n(".tinv-wishlist .navigation-button");e.length&&e.each(function(){var t=n(this).find("> li");t.length<5&&t.parent().addClass("tinvwl-btns-count-"+t.length)}),n(".tinv-login .showlogin").unbind("click").on("click",function(t){t.preventDefault(),n(this).closest(".tinv-login").find(".login").toggle()}),n(".tinv-wishlist table.tinvwl-table-manage-list tfoot td").each(function(){n(this).toggle(!!n(this).children().not(".look_in").length||!!n(this).children(".look_in").children().length)})}),n(document.body).on("wc_fragments_refreshed wc_fragments_loaded",function(){var t=!("0"==n(".wishlist_products_counter_number").html()||""==n(".wishlist_products_counter_number").html());n(".wishlist_products_counter").toggleClass("wishlist-counter-with-products",t)}),update_cart_hash()}(jQuery),function(n){n.fn.tinvwl_break_submit=function(t){var i={selector:"input, select, textarea",ifempty:!0,invert:!1,validate:function(){return n(this).val()},rule:function(){var t=n(this).parents("form").eq(0).find(e.selector),i=e.invert;return 0===t.length?e.ifempty:(t.each(function(){i&&!e.invert||!i&&e.invert||(i=Boolean(e.validate.call(n(this))))}),i)}},e=n.extend(!0,{},i,t);return n(this).each(function(){n(this).on("click",function(t){e.rule.call(n(this))||(alert(window.tinvwl_add_to_wishlist.tinvwl_break_submit),t.preventDefault())})})},n(document).ready(function(){n(".tinvwl-break-input").tinvwl_break_submit({selector:".tinvwl-break-input-filed"}),n(".tinvwl-break-checkbox").tinvwl_break_submit({selector:"table td input[type=checkbox]",validate:function(){return n(this).is(":checked")}}),n(".global-cb").on("click",function(){n(this).closest("table").eq(0).find(".product-cb input[type=checkbox], .wishlist-cb input[type=checkbox]").prop("checked",n(this).is(":checked"))})})}(jQuery);
includes/activator.class.php CHANGED
@@ -302,7 +302,7 @@ class TInvWL_Activator {
302
  public static function field( $name, $newformat ) {
303
  $format = array( 'TEXT', null, false, null, false );
304
 
305
- foreach ( $format as $key => $value ) {
306
  if ( array_key_exists( $key, $newformat ) ) {
307
  $format[ $key ] = $newformat[ $key ];
308
  }
@@ -548,17 +548,17 @@ class TInvWL_Activator {
548
  * Apply upgrade action
549
  * Add table index
550
  *
551
- * @global wpdb $wpdb
552
- *
553
  * @param string $name Table name.
554
  * @param array $table Table array.
 
 
 
555
  */
556
  public static function upgrade_action_add_index( $name, $table ) {
557
  global $wpdb;
558
 
559
  $indexes = $table['index'];
560
 
561
-
562
  foreach ( $indexes as $index => $columns ) {
563
 
564
  $sql = sprintf( 'ALTER TABLE `%s` ADD INDEX %s (%s);', $name, $index, $columns );
302
  public static function field( $name, $newformat ) {
303
  $format = array( 'TEXT', null, false, null, false );
304
 
305
+ foreach ( array_keys( $format ) as $key ) {
306
  if ( array_key_exists( $key, $newformat ) ) {
307
  $format[ $key ] = $newformat[ $key ];
308
  }
548
  * Apply upgrade action
549
  * Add table index
550
  *
 
 
551
  * @param string $name Table name.
552
  * @param array $table Table array.
553
+ *
554
+ * @global wpdb $wpdb
555
+ *
556
  */
557
  public static function upgrade_action_add_index( $name, $table ) {
558
  global $wpdb;
559
 
560
  $indexes = $table['index'];
561
 
 
562
  foreach ( $indexes as $index => $columns ) {
563
 
564
  $sql = sprintf( 'ALTER TABLE `%s` ADD INDEX %s (%s);', $name, $index, $columns );
includes/analytics.class.php CHANGED
@@ -100,22 +100,6 @@ class TInvWL_Analytics {
100
  return $product_data;
101
  }
102
 
103
- /**
104
- * Add views analitycs
105
- *
106
- * @param integer $wishlist_id If exist wishlist object, you can put 0.
107
- * @param boolean $author is author wislist.
108
- *
109
- * @return boolean
110
- */
111
- function wishlist_view( $wishlist_id = 0, $author = null ) {
112
- if ( empty( $wishlist_id ) ) {
113
- $wishlist_id = $this->wishlist_id();
114
- }
115
- $this->view_products( $wishlist_id, $author );
116
-
117
- return $this->add( ( $author ? 'author' : 'visite' ), $wishlist_id );
118
- }
119
 
120
  /**
121
  * Add views analitycs
@@ -123,26 +107,19 @@ class TInvWL_Analytics {
123
  * @param integer $wishlist_id If exist wishlist object, you can put 0.
124
  * @param boolean $author is author wislist.
125
  *
126
- * @return boolean
127
  */
128
- function view_products( $wishlist_id = 0, $author = null ) {
129
- if ( empty( $wishlist_id ) ) {
130
- $wishlist_id = $this->wishlist_id();
131
- }
132
- $wishlist_id = absint( $wishlist_id );
133
- $wlp = new TInvWL_Product( array(), $this->_name );
134
- $products = $wlp->get_wishlist( array(
135
- 'wishlist_id' => $wishlist_id,
136
- 'external' => false,
137
- ) );
138
  if ( empty( $products ) || ! is_array( $products ) ) {
139
  return false;
140
  }
141
- foreach ( $products as $product ) {
142
- $this->add( ( $author ? 'author' : 'visite' ), $wishlist_id, $product['product_id'], $product['variation_id'] );
 
 
143
  }
144
 
145
- return true;
146
  }
147
 
148
  /**
@@ -247,7 +224,7 @@ class TInvWL_Analytics {
247
  * @param integer $wishlist_id If exist wishlist object, you can put 0.
248
  * @param integer $product_id Product id.
249
  * @param integer $variation_id Product variation id.
250
- * @param integer $quantity Quantity applyed actions.
251
  *
252
  * @return boolean
253
  * @global wpdb $wpdb
@@ -260,7 +237,7 @@ class TInvWL_Analytics {
260
  'click',
261
  'gift',
262
  'visite',
263
- 'wishlist'
264
  ) ) ) { // @codingStandardsIgnoreLine WordPress.PHP.StrictInArray.MissingTrueStrict
265
  return false;
266
  }
@@ -270,21 +247,37 @@ class TInvWL_Analytics {
270
  if ( empty( $wishlist_id ) ) {
271
  return false;
272
  }
 
 
 
273
  if ( empty( $product_id ) && ! empty( $variation_id ) ) {
274
- $product_data = $this->product_data( $product_id, $variation_id );
275
- if ( $product_data ) {
276
- $product_id = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
277
- $variation_id = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
278
- } else {
 
 
 
 
279
  return false;
280
  }
 
 
281
  }
282
- $data = array(
283
  'wishlist_id' => $wishlist_id,
284
  'product_id' => $product_id,
285
  'variation_id' => $variation_id,
286
  );
287
- $data['ID'] = md5( implode( '|', $data ) );
 
 
 
 
 
 
 
288
 
289
  if ( 'visite' == $type ) { // WPCS: loose comparison ok.
290
  $user = wp_get_current_user();
@@ -326,27 +319,43 @@ class TInvWL_Analytics {
326
  $fields = array();
327
  $values = array();
328
  $duplicates = array();
329
- foreach ( $data as $key => $value ) {
330
- $fields[] = $key;
331
- $values[] = $value;
332
- if ( in_array( $key, array(
333
- 'cart',
334
- 'sell_as_gift',
335
- 'click_author',
336
- 'click',
337
- 'sell_of_wishlist',
338
- 'visite',
339
- 'visite_author'
340
- ) ) ) { // @codingStandardsIgnoreLine WordPress.PHP.StrictInArray.MissingTrueStrict
341
- $duplicates[] = sprintf( '`%s`=`%s`+%d', $key, $key, $value );
 
 
 
 
 
 
 
 
 
 
342
  }
343
  }
344
- $fields = '`' . implode( '`,`', $fields ) . '`';
345
- $values = "'" . implode( "','", $values ) . "'";
 
 
 
 
 
346
  $duplicates = implode( ',', $duplicates );
 
347
  global $wpdb;
348
 
349
- return $wpdb->query( "INSERT INTO `$this->table` ($fields) VALUES ($values) ON DUPLICATE KEY UPDATE $duplicates" ); // WPCS: db call ok; no-cache ok; unprepared SQL ok.
350
  }
351
 
352
  /**
@@ -368,7 +377,7 @@ class TInvWL_Analytics {
368
  'sql' => '',
369
  );
370
 
371
- foreach ( $default as $_k => $_version ) {
372
  if ( array_key_exists( $_k, $data ) ) {
373
  $default[ $_k ] = $data[ $_k ];
374
  unset( $data[ $_k ] );
@@ -455,7 +464,7 @@ class TInvWL_Analytics {
455
  $wishlist_id = $this->wishlist_id();
456
  }
457
  global $wpdb;
458
- $analytics = array();
459
  if ( empty( $wishlist_id ) ) {
460
  $analytics = $wpdb->get_results( $wpdb->prepare( "SELECT `wishlist_id`,`visite`, `visite_author` FROM `$this->table` WHERE `product_id`=%d AND `variation_id`=%d;", 0, 0 ), ARRAY_A ); // WPCS: db call ok; no-cache ok; unprepared SQL ok.
461
  } else {
100
  return $product_data;
101
  }
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
  /**
105
  * Add views analitycs
107
  * @param integer $wishlist_id If exist wishlist object, you can put 0.
108
  * @param boolean $author is author wislist.
109
  *
 
110
  */
111
+ function view_products( $wishlist, $author = null ) {
112
+ $products = TInvWL_Public_Wishlist_View::instance()->get_current_products_query();
 
 
 
 
 
 
 
 
113
  if ( empty( $products ) || ! is_array( $products ) ) {
114
  return false;
115
  }
116
+ $data = array();
117
+ foreach ( $products as $key => $product ) {
118
+ $data['product_ids'][ $key ] = $product['product_id'];
119
+ $data['variation_ids'][ $key ] = $product['variation_id'];
120
  }
121
 
122
+ $this->add( ( $author ? 'author' : 'visite' ), $wishlist['ID'], $data['product_ids'], $data['variation_ids'] );
123
  }
124
 
125
  /**
224
  * @param integer $wishlist_id If exist wishlist object, you can put 0.
225
  * @param integer $product_id Product id.
226
  * @param integer $variation_id Product variation id.
227
+ * @param integer $quantity Quantity applied actions.
228
  *
229
  * @return boolean
230
  * @global wpdb $wpdb
237
  'click',
238
  'gift',
239
  'visite',
240
+ 'wishlist',
241
  ) ) ) { // @codingStandardsIgnoreLine WordPress.PHP.StrictInArray.MissingTrueStrict
242
  return false;
243
  }
247
  if ( empty( $wishlist_id ) ) {
248
  return false;
249
  }
250
+
251
+ $product_id = ( is_array( $product_id ) ) ? $product_id : array( $product_id );
252
+ $variation_id = ( is_array( $variation_id ) ) ? $variation_id : array( $variation_id );
253
  if ( empty( $product_id ) && ! empty( $variation_id ) ) {
254
+ $ids = array();
255
+ foreach ( $product_id as $key => $id ) {
256
+ $product_data = $this->product_data( $id, $variation_id[ $key ] );
257
+ if ( $product_data ) {
258
+ $ids['product_id'][ $key ] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
259
+ $ids['variation_id'][ $key ] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
260
+ }
261
+ }
262
+ if ( empty( $ids ) ) {
263
  return false;
264
  }
265
+ $product_id = $ids['product_id'];
266
+ $variation_id = $ids['variation_id'];
267
  }
268
+ $data = array(
269
  'wishlist_id' => $wishlist_id,
270
  'product_id' => $product_id,
271
  'variation_id' => $variation_id,
272
  );
273
+
274
+ foreach ( $product_id as $key => $id ) {
275
+ $data['ID'][ $key ] = md5( implode( '|', array(
276
+ 'wishlist_id' => $wishlist_id,
277
+ 'product_id' => $id,
278
+ 'variation_id' => $variation_id{$key},
279
+ ) ) );
280
+ }
281
 
282
  if ( 'visite' == $type ) { // WPCS: loose comparison ok.
283
  $user = wp_get_current_user();
319
  $fields = array();
320
  $values = array();
321
  $duplicates = array();
322
+
323
+ foreach ( array_keys( $product_id ) as $index ) {
324
+ foreach ( $data as $key => $value ) {
325
+ if ( 0 === $index ) {
326
+ $fields[] = $key;
327
+ if ( in_array( $key, array(
328
+ 'cart',
329
+ 'sell_as_gift',
330
+ 'click_author',
331
+ 'click',
332
+ 'sell_of_wishlist',
333
+ 'visite',
334
+ 'visite_author',
335
+ ) ) ) { // @codingStandardsIgnoreLine WordPress.PHP.StrictInArray.MissingTrueStrict
336
+ $duplicates[] = sprintf( '`%s`=`%s`+%d', $key, $key, $value );
337
+ }
338
+ }
339
+
340
+ if ( in_array( $key, array( 'product_id', 'variation_id', 'ID' ) ) ) {
341
+ $values[ $index ][] = $value[ $index ];
342
+ } else {
343
+ $values[ $index ][] = $value;
344
+ }
345
  }
346
  }
347
+
348
+ $fields = '`' . implode( '`,`', $fields ) . '`';
349
+ $data = array();
350
+ foreach ( $values as $value ) {
351
+ $data[] = "('" . implode( "','", $value ) . "')";
352
+ }
353
+ $data = implode( ",", $data );
354
  $duplicates = implode( ',', $duplicates );
355
+
356
  global $wpdb;
357
 
358
+ return $wpdb->query( "INSERT INTO `$this->table` ($fields) VALUES $data ON DUPLICATE KEY UPDATE $duplicates" ); // WPCS: db call ok; no-cache ok; unprepared SQL ok.
359
  }
360
 
361
  /**
377
  'sql' => '',
378
  );
379
 
380
+ foreach ( array_keys( $default ) as $_k ) {
381
  if ( array_key_exists( $_k, $data ) ) {
382
  $default[ $_k ] = $data[ $_k ];
383
  unset( $data[ $_k ] );
464
  $wishlist_id = $this->wishlist_id();
465
  }
466
  global $wpdb;
467
+
468
  if ( empty( $wishlist_id ) ) {
469
  $analytics = $wpdb->get_results( $wpdb->prepare( "SELECT `wishlist_id`,`visite`, `visite_author` FROM `$this->table` WHERE `product_id`=%d AND `variation_id`=%d;", 0, 0 ), ARRAY_A ); // WPCS: db call ok; no-cache ok; unprepared SQL ok.
470
  } else {
includes/api/yoasti18n/i18n-module.php CHANGED
@@ -96,13 +96,6 @@ class TInvWL_Yoast_I18n_V2 {
96
  */
97
  private $register_url;
98
 
99
- /**
100
- * Your plugins textdomain
101
- *
102
- * @var string
103
- */
104
- private $textdomain;
105
-
106
  /**
107
  * Indicates whether there's a translation available at all.
108
  *
@@ -231,7 +224,7 @@ class TInvWL_Yoast_I18n_V2 {
231
 
232
  echo '<div style="overflow: hidden;padding:20px 10px 10px">';
233
 
234
- if ( isset( $this->glotpress_logo ) && '' != $this->glotpress_logo ) {
235
  echo '<a href="' . esc_url( $this->register_url ) . '"><img class="alignleft" style="margin:0 15px 10px 0;max-width:200px;" src="' . esc_url( $this->glotpress_logo ) . '" alt="' . esc_attr( $this->glotpress_name ) . '"/></a>';
236
  }
237
  echo '<h2>' . sprintf( __( 'Translation of %s', 'ti-woocommerce-wishlist' ), $this->plugin_name ) . '</h2>'; // @codingStandardsIgnoreLine WordPress.WP.I18n.NonSingularStringLiteralDomain
96
  */
97
  private $register_url;
98
 
 
 
 
 
 
 
 
99
  /**
100
  * Indicates whether there's a translation available at all.
101
  *
224
 
225
  echo '<div style="overflow: hidden;padding:20px 10px 10px">';
226
 
227
+ if ( isset( $this->glotpress_logo ) && '' !== $this->glotpress_logo ) {
228
  echo '<a href="' . esc_url( $this->register_url ) . '"><img class="alignleft" style="margin:0 15px 10px 0;max-width:200px;" src="' . esc_url( $this->glotpress_logo ) . '" alt="' . esc_attr( $this->glotpress_name ) . '"/></a>';
229
  }
230
  echo '<h2>' . sprintf( __( 'Translation of %s', 'ti-woocommerce-wishlist' ), $this->plugin_name ) . '</h2>'; // @codingStandardsIgnoreLine WordPress.WP.I18n.NonSingularStringLiteralDomain
includes/checkerhook.helper.php DELETED
@@ -1,252 +0,0 @@
1
- <?php
2
- /**
3
- * Checker hook plugin class
4
- *
5
- * @since 1.0.0
6
- * @package TInvWishlist\Helper
7
- */
8
-
9
- // If this file is called directly, abort.
10
- if ( ! defined( 'ABSPATH' ) ) {
11
- die;
12
- }
13
-
14
- /**
15
- * Checker hook plugin class
16
- */
17
- class TInvWL_CheckerHook {
18
-
19
- /**
20
- * Filter current
21
- *
22
- * @var string
23
- */
24
- private $filter;
25
- /**
26
- * Filter list
27
- *
28
- * @var array
29
- */
30
- private $filters;
31
- /**
32
- * Filter message list
33
- *
34
- * @var array
35
- */
36
- private $filters_message;
37
- /**
38
- * Default message
39
- *
40
- * @var string
41
- */
42
- public $message = '';
43
- /**
44
- * This class
45
- *
46
- * @var \TInvWL_CheckerHook
47
- */
48
- protected static $_instance = null;
49
-
50
-
51
- /**
52
- * Get this class object
53
- *
54
- * @return \TInvWL_CheckerHook
55
- */
56
- public static function instance() {
57
- if ( is_null( self::$_instance ) ) {
58
- self::$_instance = new self();
59
- }
60
- self::$_instance->clear_action();
61
- return self::$_instance;
62
- }
63
-
64
- /**
65
- * Creating class
66
- */
67
- function __construct() {
68
- $this->define_hook();
69
- }
70
-
71
- /**
72
- * Define hook for check current hook.
73
- */
74
- function define_hook() {
75
- $filters = get_option( 'ti_checker_hooks', array() );
76
- if ( ! empty( $filters ) && is_array( $filters ) ) {
77
- $checker = new TInvWL_CheckerHook_Checker();
78
- foreach ( $filters as $tag ) {
79
- $result = get_option( 'ti_checker__' . $tag );
80
- if ( ! empty( $result ) ) {
81
- add_filter( $tag, array( $checker, $tag ) );
82
- }
83
- }
84
- }
85
- }
86
-
87
- /**
88
- * Default callback function
89
- *
90
- * @param array $data Array data.
91
- * @return mixed
92
- */
93
- public static function get_remote_data( $data ) {
94
- $result = false;
95
- if ( array_key_exists( 'template', $data ) && ! empty( $data['template'] ) ) {
96
- $args = array();
97
- if ( array_key_exists( 'template_args', $data ) && is_array( $data['template_args'] ) ) {
98
- $args = $data['template_args'];
99
- }
100
- if ( is_array( $data['template'] ) ) {
101
- foreach ( $data['template'] as $template ) {
102
- if ( wc_get_template_html( $template, $args ) ) {
103
- $result = true;
104
- }
105
- }
106
- } else {
107
- if ( wc_get_template_html( $data['template'], $args ) ) {
108
- $result = true;
109
- }
110
- }
111
- }
112
- if ( array_key_exists( 'function', $data ) && ! empty( $data['function'] ) ) {
113
- if ( function_exists( $data['function'] ) ) {
114
- $args = array();
115
- if ( array_key_exists( 'function_args', $data ) && is_array( $data['function_args'] ) ) {
116
- $args = $data['function_args'];
117
- }
118
- ob_start();
119
- call_user_func_array( $data['function'], $args );
120
- ob_get_clean();
121
- $result = true;
122
- }
123
- }
124
- if ( array_key_exists( 'url', $data ) && ! empty( $data['url'] ) ) {
125
- $response = wp_remote_get( $data['url'] );
126
- if ( ! is_wp_error( $response ) ) {
127
- $result = $result || 200 === $response['response']['code'];
128
- }
129
- }
130
- return $result;
131
- }
132
-
133
- /**
134
- * Add action for checking
135
- *
136
- * @param string $tag Name action for checking.
137
- * @param string $message Message for error.
138
- * @return \TInvWL_CheckerHook
139
- */
140
- function add_action( $tag, $message = null ) {
141
- if ( is_array( $tag ) ) {
142
- foreach ( $tag as $_tag ) {
143
- $this->filters[ $_tag ] = $message;
144
- }
145
- } else {
146
- $this->filters[ $tag ] = $message;
147
- }
148
- return $this;
149
- }
150
-
151
- /**
152
- * Clear checking filters.
153
- *
154
- * @return \TInvWL_CheckerHook
155
- */
156
- function clear_action() {
157
- $this->filters = array();
158
- return $this;
159
- }
160
-
161
- /**
162
- * Set default message error.
163
- *
164
- * @param string $message Message.
165
- * @return \TInvWL_CheckerHook
166
- */
167
- function set_message( $message ) {
168
- $this->message = $message;
169
- return $this;
170
- }
171
-
172
- /**
173
- * Show message
174
- *
175
- * @param string $message Message.
176
- * @param string $action Name hook.
177
- * @return string
178
- */
179
- function show_message( $message, $action = '' ) {
180
- return sprintf( $message, $action );
181
- }
182
-
183
- /**
184
- * Run checking
185
- *
186
- * @param array $arg Array data for callback function.
187
- * @return array
188
- */
189
- /**
190
- * Run checking
191
- *
192
- * @param array $arg Array data for callback function.
193
- * @param mixed $fuction_to_check Function for run check hooks.
194
- * @return type
195
- */
196
- function run( $arg = array(), $fuction_to_check = null ) {
197
- if ( empty( $fuction_to_check ) ) {
198
- $fuction_to_check = array( __CLASS__, 'get_remote_data' );
199
- }
200
-
201
- $tags = array_keys( $this->filters );
202
-
203
- update_option( 'ti_checker_hooks', $tags, false );
204
- $checker = new TInvWL_CheckerHook_Checker();
205
- foreach ( $tags as $tag ) {
206
- update_option( 'ti_checker__' . $tag, 1, false );
207
- wp_cache_delete( 'ti_checker__' . $tag, 'options' );
208
- add_filter( $tag, array( $checker, $tag ) );
209
- }
210
- wp_cache_delete( 'alloptions', 'options' );
211
- $return = call_user_func( $fuction_to_check, $arg );
212
- delete_option( 'ti_checker_hooks' );
213
- $result = array();
214
- if ( $return ) {
215
- foreach ( $tags as $tag ) {
216
- remove_filter( $tag, array( $checker, $tag ) );
217
- $_result = absint( get_option( 'ti_checker__' . $tag, 1 ) );
218
- if ( $_result ) {
219
- $message = empty( $this->filters[ $tag ] ) ? $this->message : $this->filters[ $tag ] ;
220
- $result[ $tag ] = $this->show_message( $message, $tag );
221
- }
222
- delete_option( 'ti_checker__' . $tag );
223
- }
224
- }
225
- return $result;
226
- }
227
-
228
- }
229
-
230
- if ( ! class_exists( 'TInvWL_CheckerHook_Checker' ) ) {
231
-
232
- /**
233
- * Class for apply check hook
234
- */
235
- class TInvWL_CheckerHook_Checker {
236
-
237
- /**
238
- * Run check actions
239
- *
240
- * @param string $name Hook name.
241
- * @param array $arguments Argument for hook.
242
- * @return mixed
243
- */
244
- public function __call( $name, $arguments ) {
245
- update_option( 'ti_checker__' . $name, 0, false );
246
- return array_shift( $arguments );
247
- }
248
-
249
- }
250
- }
251
-
252
- TInvWL_CheckerHook::instance();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/form.helper.php CHANGED
@@ -61,7 +61,7 @@ class TInvWL_Form {
61
  2 => null,
62
  3 => null,
63
  );
64
- foreach ( $_arg as $key => $value ) {
65
  $_arg[ $key ] = array_shift( $arg );
66
  }
67
  $arg = $_arg;
@@ -99,7 +99,7 @@ class TInvWL_Form {
99
  2 => null,
100
  3 => null,
101
  );
102
- foreach ( $_arg as $key => $value ) {
103
  $_arg[ $key ] = array_shift( $arg );
104
  }
105
  $arg = $_arg;
@@ -179,13 +179,13 @@ class TInvWL_Form {
179
  /**
180
  * Create color picker
181
  *
182
- * @see colorpicker
183
- *
184
  * @param mixed $data Name field or array attributes.
185
  * @param string $value Value.
186
  * @param mixed $extra Styling or Custom variable.
187
  *
188
  * @return string
 
 
189
  */
190
  public static function _color( $data = '', $value = '', $extra = '' ) {
191
  $class = sprintf( ' %s-form-color', self::$_name );
@@ -218,13 +218,13 @@ class TInvWL_Form {
218
  /**
219
  * Create date input
220
  *
221
- * @see jquery-ui-datepicker
222
- *
223
  * @param mixed $data Name field or array attributes.
224
  * @param string $value Value.
225
  * @param mixed $extra Styling or Custom variable.
226
  *
227
  * @return string
 
 
228
  */
229
  public static function _date( $data = '', $value = '', $extra = '' ) {
230
  if ( ! is_array( $data ) ) {
@@ -1084,7 +1084,7 @@ class TInvWL_Form {
1084
  public static function setvalue( $data, $value = '' ) {
1085
  $_value = $value;
1086
  if ( is_array( $data ) ) {
1087
- foreach ( self::$value as $key => $val ) {
1088
  if ( isset( $data[ $key ] ) ) {
1089
  self::$value[ $key ] = $data[ $key ];
1090
  unset( $data[ $key ] );
@@ -1149,7 +1149,7 @@ class TInvWL_Form {
1149
  public static function setoptions( $data, $option = array() ) {
1150
  $_option = $option;
1151
  if ( is_array( $data ) ) {
1152
- foreach ( self::$option as $key => $val ) {
1153
  if ( isset( $data[ $key ] ) ) {
1154
  self::$option[ $key ] = $data[ $key ];
1155
  unset( $data[ $key ] );
61
  2 => null,
62
  3 => null,
63
  );
64
+ foreach ( array_keys( $_arg ) as $key ) {
65
  $_arg[ $key ] = array_shift( $arg );
66
  }
67
  $arg = $_arg;
99
  2 => null,
100
  3 => null,
101
  );
102
+ foreach ( array_keys( $_arg ) as $key ) {
103
  $_arg[ $key ] = array_shift( $arg );
104
  }
105
  $arg = $_arg;
179
  /**
180
  * Create color picker
181
  *
 
 
182
  * @param mixed $data Name field or array attributes.
183
  * @param string $value Value.
184
  * @param mixed $extra Styling or Custom variable.
185
  *
186
  * @return string
187
+ * @see colorpicker
188
+ *
189
  */
190
  public static function _color( $data = '', $value = '', $extra = '' ) {
191
  $class = sprintf( ' %s-form-color', self::$_name );
218
  /**
219
  * Create date input
220
  *
 
 
221
  * @param mixed $data Name field or array attributes.
222
  * @param string $value Value.
223
  * @param mixed $extra Styling or Custom variable.
224
  *
225
  * @return string
226
+ * @see jquery-ui-datepicker
227
+ *
228
  */
229
  public static function _date( $data = '', $value = '', $extra = '' ) {
230
  if ( ! is_array( $data ) ) {
1084
  public static function setvalue( $data, $value = '' ) {
1085
  $_value = $value;
1086
  if ( is_array( $data ) ) {
1087
+ foreach ( array_keys( self::$value ) as $key ) {
1088
  if ( isset( $data[ $key ] ) ) {
1089
  self::$value[ $key ] = $data[ $key ];
1090
  unset( $data[ $key ] );
1149
  public static function setoptions( $data, $option = array() ) {
1150
  $_option = $option;
1151
  if ( is_array( $data ) ) {
1152
+ foreach ( array_keys( self::$option ) as $key ) {
1153
  if ( isset( $data[ $key ] ) ) {
1154
  self::$option[ $key ] = $data[ $key ];
1155
  unset( $data[ $key ] );
includes/notice.helper.php CHANGED
@@ -150,7 +150,7 @@ class TInvWL_Notice {
150
  if ( is_array( self::$shownotices[ $name ] ) ) {
151
  if ( array_key_exists( $name, self::$shownotices ) ) {
152
  if ( empty( $tag ) ) {
153
- foreach ( self::$shownotices[ $name ] as $tag => $value ) {
154
  self::hide( $name, $tag );
155
  }
156
  } else {
@@ -197,7 +197,7 @@ class TInvWL_Notice {
197
  }
198
  self::add( $name );
199
  $_notice = get_option( 'ti_admin_notice_' . $name, array() );
200
- foreach ( $notice as $key => $value ) {
201
  $_value = wp_kses_post( $value );
202
  if ( ! in_array( $_value, $_notice ) ) {
203
  $_notice[ $index ] = $_value;
150
  if ( is_array( self::$shownotices[ $name ] ) ) {
151
  if ( array_key_exists( $name, self::$shownotices ) ) {
152
  if ( empty( $tag ) ) {
153
+ foreach ( array_keys( self::$shownotices[ $name ] ) as $tag ) {
154
  self::hide( $name, $tag );
155
  }
156
  } else {
197
  }
198
  self::add( $name );
199
  $_notice = get_option( 'ti_admin_notice_' . $name, array() );
200
+ foreach ( $notice as $value ) {
201
  $_value = wp_kses_post( $value );
202
  if ( ! in_array( $_value, $_notice ) ) {
203
  $_notice[ $index ] = $_value;
includes/pluginextend.helper.php CHANGED
@@ -82,15 +82,15 @@ class TInvWL_PluginExtend {
82
  public function __construct( $plugin, $root_file = null, $plugin_name = TINVWL_PREFIX ) {
83
  $this->_name = $plugin_name;
84
  if ( empty( $plugin ) ) {
85
- $this->transient = plugin_basename( $root_file );
86
- $this->plugin_path = trailingslashit( plugin_dir_path( dirname( $root_file ) ) );
87
  } else {
88
- $this->transient = $plugin;
89
- $this->plugin_path = trailingslashit( dirname( TINVWL_PATH ) );
90
  }
91
- $this->dependency = array();
92
- $this->plugin_data = array();
93
- $this->message = array();
94
  }
95
 
96
  /**
@@ -102,9 +102,12 @@ class TInvWL_PluginExtend {
102
 
103
  $plugins = $this->get_dependency_plugins();
104
 
105
- foreach ( $plugins as $plugin => $data ) {
106
  add_filter( 'plugin_action_links_' . $plugin, array( $this, 'plugin_action_links_maybe_deactivate' ) );
107
- add_filter( 'network_admin_plugin_action_links_' . $plugin, array( $this, 'plugin_action_links_maybe_deactivate' ) );
 
 
 
108
  }
109
 
110
  add_action( 'after_plugin_row_' . $this->transient, array( $this, 'plugin_row' ), 10 );
@@ -119,11 +122,13 @@ class TInvWL_PluginExtend {
119
  *
120
  * @param string $plugin Plugin transient name.
121
  * @param string $nice_name Plugin nice name.
 
122
  * @return \TInvWL_PluginExtend
123
  */
124
  public function set_dependency( $plugin, $nice_name ) {
125
- $this->dependency_current = $plugin;
126
- $this->dependency_current_nice_name = $nice_name;
 
127
  return $this;
128
  }
129
 
@@ -134,6 +139,7 @@ class TInvWL_PluginExtend {
134
  */
135
  public function reset_dependency() {
136
  $this->dependency_current = null;
 
137
  return $this;
138
  }
139
 
@@ -141,11 +147,12 @@ class TInvWL_PluginExtend {
141
  * Set dependency version by index rules
142
  *
143
  * @param integer $index Index rules.
144
- * 0 Min version.
145
- * 1 Max version.
146
- * 2 Need plugin verion.
147
- * 3 Conflict plugin verion.
148
- * @param string $version Version dependency.
 
149
  * @return boolean
150
  */
151
  private function set_dependency_version( $index, $version = '1.0.0' ) {
@@ -164,6 +171,7 @@ class TInvWL_PluginExtend {
164
  * Set minimal dependency version
165
  *
166
  * @param string $version Version dependency.
 
167
  * @return \TInvWL_PluginExtend
168
  */
169
  public function min( $version = '1.0.0' ) {
@@ -171,6 +179,7 @@ class TInvWL_PluginExtend {
171
  $version = '';
172
  }
173
  $this->set_dependency_version( 0, $version );
 
174
  return $this;
175
  }
176
 
@@ -178,6 +187,7 @@ class TInvWL_PluginExtend {
178
  * Set maximum dependency version
179
  *
180
  * @param string $version Version dependency.
 
181
  * @return \TInvWL_PluginExtend
182
  */
183
  public function max( $version = '1.0.0' ) {
@@ -185,6 +195,7 @@ class TInvWL_PluginExtend {
185
  $version = '';
186
  }
187
  $this->set_dependency_version( 1, $version );
 
188
  return $this;
189
  }
190
 
@@ -192,10 +203,12 @@ class TInvWL_PluginExtend {
192
  * Set need plugin dependency version
193
  *
194
  * @param string $version Version dependency. Can use '*' for check any version.
 
195
  * @return \TInvWL_PluginExtend
196
  */
197
  public function need( $version = '*' ) {
198
  $this->set_dependency_version( 2, $version );
 
199
  return $this;
200
  }
201
 
@@ -203,10 +216,12 @@ class TInvWL_PluginExtend {
203
  * Set conflict plugin dependency version
204
  *
205
  * @param string $version Version dependency. Can use '*' for check any version.
 
206
  * @return \TInvWL_PluginExtend
207
  */
208
  public function conflict( $version = '*' ) {
209
  $this->set_dependency_version( 3, $version );
 
210
  return $this;
211
  }
212
 
@@ -214,24 +229,27 @@ class TInvWL_PluginExtend {
214
  * Get dependency array
215
  *
216
  * @param string $plugin Plugin transient name.
 
217
  * @return array
218
  */
219
  private function get_dependency( $plugin ) {
220
  if ( array_key_exists( $plugin, $this->dependency ) ) {
221
  return $this->dependency[ $plugin ];
222
  }
 
223
  return array();
224
  }
225
 
226
  /**
227
  * Get dependency version from array.
228
  *
229
- * @param string $plugin Plugin transient name.
230
- * @param integer $index Index rules.
231
- * 0 Min version.
232
- * 1 Max version.
233
- * 2 Need plugin verion.
234
- * 3 Conflict plugin verion.
 
235
  * @return array
236
  */
237
  private function get_dep_ver( $plugin, $index ) {
@@ -239,6 +257,7 @@ class TInvWL_PluginExtend {
239
  if ( array_key_exists( $index, $dependency ) ) {
240
  return $dependency[ $index ];
241
  }
 
242
  return null;
243
  }
244
 
@@ -257,9 +276,9 @@ class TInvWL_PluginExtend {
257
  * @return boolean
258
  */
259
  public function status_dependency() {
260
- $this->message = array();
261
- $plugins = $this->get_dependency_plugins();
262
- $status = true;
263
 
264
  foreach ( $plugins as $plugin => $data ) {
265
  if ( is_plugin_active( $plugin ) && ! $this->is_plugin_at_conflict_version( $plugin ) ) {
@@ -274,6 +293,7 @@ class TInvWL_PluginExtend {
274
  $status = $this->set_message( 'activate', $data['nice_name'] );
275
  }
276
  }
 
277
  return $status;
278
  }
279
 
@@ -281,6 +301,7 @@ class TInvWL_PluginExtend {
281
  * Check plugin minimal version dependency.
282
  *
283
  * @param string $plugin Plugin transient name.
 
284
  * @return boolean
285
  */
286
  private function is_plugin_at_min_version( $plugin ) {
@@ -291,6 +312,7 @@ class TInvWL_PluginExtend {
291
  * Check plugin maximal version dependency.
292
  *
293
  * @param string $plugin Plugin transient name.
 
294
  * @return boolean
295
  */
296
  private function is_plugin_at_max_version( $plugin ) {
@@ -301,6 +323,7 @@ class TInvWL_PluginExtend {
301
  * Check plugin need version dependency.
302
  *
303
  * @param string $plugin Plugin transient name.
 
304
  * @return boolean
305
  */
306
  private function is_plugin_at_need_version( $plugin ) {
@@ -311,6 +334,7 @@ class TInvWL_PluginExtend {
311
  * Check plugin conflict version dependency.
312
  *
313
  * @param string $plugin Plugin transient name.
 
314
  * @return boolean
315
  */
316
  private function is_plugin_at_conflict_version( $plugin ) {
@@ -321,32 +345,33 @@ class TInvWL_PluginExtend {
321
  * Check plugin version dependency.
322
  *
323
  * @param integer $i Index rules.
324
- * 0 Min version.
325
- * 1 Max version.
326
- * 2 Need plugin verion.
327
- * 3 Conflict plugin verion.
328
- * @param string $plugin Plugin transient name.
 
329
  * @return boolean
330
  */
331
  private function is_plugin_at_version( $i = 0, $plugin ) {
332
 
333
  switch ( $i ) {
334
  case 3:
335
- $type = 'ne';
336
- $i = 3;
337
  break;
338
  case 2:
339
- $type = 'eq';
340
- $i = 2;
341
  break;
342
  case 1:
343
- $type = 'le';
344
- $i = 1;
345
  break;
346
  case 0:
347
  default:
348
- $type = 'ge';
349
- $i = 0;
350
  }
351
  $version = $this->get_dep_ver( $plugin, $i );
352
  if ( is_null( $version ) ) {
@@ -360,6 +385,7 @@ class TInvWL_PluginExtend {
360
  return ! empty( $version_plugin );
361
  }
362
  }
 
363
  return version_compare( $version_plugin, $version, $type );
364
  }
365
 
@@ -367,17 +393,20 @@ class TInvWL_PluginExtend {
367
  * Get error messages
368
  *
369
  * @param boolean $first Get first or all error messages.
 
370
  * @return string
371
  */
372
  public function get_messages( $first = false ) {
373
  if ( $first ) {
374
- $message = array_shift( $this->message );
375
- $this->message = array();
 
376
  return $message;
377
  }
378
 
379
- $message = '<p>' . implode( '</p><p>', $this->message ) . '</p>';
380
- $this->message = array();
 
381
  return $message;
382
  }
383
 
@@ -386,6 +415,7 @@ class TInvWL_PluginExtend {
386
  *
387
  * @param string $old_value Not used.
388
  * @param string $value Not used.
 
389
  * @return string
390
  */
391
  public function maybe_deactivate( $old_value, $value ) {
@@ -413,12 +443,14 @@ class TInvWL_PluginExtend {
413
  * Deactivation plugin
414
  *
415
  * @param string $actions Not used.
 
416
  * @return string
417
  */
418
  public function plugin_action_links_maybe_deactivate( $actions ) {
419
  if ( ! $this->status_dependency() ) {
420
  self::deactivate_self( $this->transient );
421
  }
 
422
  return $actions;
423
  }
424
 
@@ -432,13 +464,14 @@ class TInvWL_PluginExtend {
432
  $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
433
  ?>
434
  <tr class="plugin-update-tr installer-plugin-update-tr">
435
- <td colspan="<?php echo $wp_list_table->get_column_count(); // WPCS: xss ok. ?>" class="plugin-update colspanchange">
436
- <div class="notice inline notice-warning notice-alt">
437
- <p class="installer-q-icon">
438
- <?php echo $this->get_messages( true ); // WPCS: xss ok. ?>
439
- </p>
440
- </div>
441
- </td>
 
442
  </tr>
443
  <?php
444
  }
@@ -447,7 +480,7 @@ class TInvWL_PluginExtend {
447
  /**
448
  * Deactivation plugin
449
  *
450
- * @param string $file Plugin file path.
451
  * @param boolean $network_wide Network wide.
452
  */
453
  public static function deactivate_self( $file, $network_wide = false ) {
@@ -463,12 +496,13 @@ class TInvWL_PluginExtend {
463
  *
464
  * @param string $type Type error message.
465
  * @param string $plugin Plugin transient name.
 
466
  * @return boolean
467
  */
468
  private function set_message( $type, $plugin ) {
469
- $current = $this->get_plugin_data( 'current', 'Name' ) ? $this->get_plugin_data( 'current', 'Name' ) : $this->transient;
470
- $version = $this->get_plugin_data( 'current', 'Version' );
471
- $plugname = $this->get_plugin_data( $plugin, 'Name' ) ? $this->get_plugin_data( $plugin, 'Name' ) : $plugin;
472
 
473
  $message = '';
474
  switch ( $type ) {
@@ -521,6 +555,7 @@ class TInvWL_PluginExtend {
521
  $message = sprintf( $message, $current, $plugname, $version );
522
 
523
  $this->message[] = $message;
 
524
  return false;
525
  }
526
 
@@ -538,6 +573,7 @@ class TInvWL_PluginExtend {
538
  *
539
  * @param string $plugin Plugin transient name.
540
  * @param string $attr Plugin attribute name.
 
541
  * @return mixed
542
  */
543
  public function get_plugin_data( $plugin, $attr = null ) {
@@ -562,6 +598,7 @@ class TInvWL_PluginExtend {
562
  if ( array_key_exists( $attr, (array) $this->plugin_data[ $plugin ] ) ) {
563
  return $this->plugin_data[ $plugin ][ $attr ];
564
  }
 
565
  return null;
566
  }
567
  }
82
  public function __construct( $plugin, $root_file = null, $plugin_name = TINVWL_PREFIX ) {
83
  $this->_name = $plugin_name;
84
  if ( empty( $plugin ) ) {
85
+ $this->transient = plugin_basename( $root_file );
86
+ $this->plugin_path = trailingslashit( plugin_dir_path( dirname( $root_file ) ) );
87
  } else {
88
+ $this->transient = $plugin;
89
+ $this->plugin_path = trailingslashit( dirname( TINVWL_PATH ) );
90
  }
91
+ $this->dependency = array();
92
+ $this->plugin_data = array();
93
+ $this->message = array();
94
  }
95
 
96
  /**
102
 
103
  $plugins = $this->get_dependency_plugins();
104
 
105
+ foreach ( array_keys( $plugins ) as $plugin ) {
106
  add_filter( 'plugin_action_links_' . $plugin, array( $this, 'plugin_action_links_maybe_deactivate' ) );
107
+ add_filter( 'network_admin_plugin_action_links_' . $plugin, array(
108
+ $this,
109
+ 'plugin_action_links_maybe_deactivate',
110
+ ) );
111
  }
112
 
113
  add_action( 'after_plugin_row_' . $this->transient, array( $this, 'plugin_row' ), 10 );
122
  *
123
  * @param string $plugin Plugin transient name.
124
  * @param string $nice_name Plugin nice name.
125
+ *
126
  * @return \TInvWL_PluginExtend
127
  */
128
  public function set_dependency( $plugin, $nice_name ) {
129
+ $this->dependency_current = $plugin;
130
+ $this->dependency_current_nice_name = $nice_name;
131
+
132
  return $this;
133
  }
134
 
139
  */
140
  public function reset_dependency() {
141
  $this->dependency_current = null;
142
+
143
  return $this;
144
  }
145
 
147
  * Set dependency version by index rules
148
  *
149
  * @param integer $index Index rules.
150
+ * 0 Min version.
151
+ * 1 Max version.
152
+ * 2 Need plugin verion.
153
+ * 3 Conflict plugin verion.
154
+ * @param string $version Version dependency.
155
+ *
156
  * @return boolean
157
  */
158
  private function set_dependency_version( $index, $version = '1.0.0' ) {
171
  * Set minimal dependency version
172
  *
173
  * @param string $version Version dependency.
174
+ *
175
  * @return \TInvWL_PluginExtend
176
  */
177
  public function min( $version = '1.0.0' ) {
179
  $version = '';
180
  }
181
  $this->set_dependency_version( 0, $version );
182
+
183
  return $this;
184
  }
185
 
187
  * Set maximum dependency version
188
  *
189
  * @param string $version Version dependency.
190
+ *
191
  * @return \TInvWL_PluginExtend
192
  */
193
  public function max( $version = '1.0.0' ) {
195
  $version = '';
196
  }
197
  $this->set_dependency_version( 1, $version );
198
+
199
  return $this;
200
  }
201
 
203
  * Set need plugin dependency version
204
  *
205
  * @param string $version Version dependency. Can use '*' for check any version.
206
+ *
207
  * @return \TInvWL_PluginExtend
208
  */
209
  public function need( $version = '*' ) {
210
  $this->set_dependency_version( 2, $version );
211
+
212
  return $this;
213
  }
214
 
216
  * Set conflict plugin dependency version
217
  *
218
  * @param string $version Version dependency. Can use '*' for check any version.
219
+ *
220
  * @return \TInvWL_PluginExtend
221
  */
222
  public function conflict( $version = '*' ) {
223
  $this->set_dependency_version( 3, $version );
224
+
225
  return $this;
226
  }
227
 
229
  * Get dependency array
230
  *
231
  * @param string $plugin Plugin transient name.
232
+ *
233
  * @return array
234
  */
235
  private function get_dependency( $plugin ) {
236
  if ( array_key_exists( $plugin, $this->dependency ) ) {
237
  return $this->dependency[ $plugin ];
238
  }
239
+
240
  return array();
241
  }
242
 
243
  /**
244
  * Get dependency version from array.
245
  *
246
+ * @param string $plugin Plugin transient name.
247
+ * @param integer $index Index rules.
248
+ * 0 Min version.
249
+ * 1 Max version.
250
+ * 2 Need plugin verion.
251
+ * 3 Conflict plugin verion.
252
+ *
253
  * @return array
254
  */
255
  private function get_dep_ver( $plugin, $index ) {
257
  if ( array_key_exists( $index, $dependency ) ) {
258
  return $dependency[ $index ];
259
  }
260
+
261
  return null;
262
  }
263
 
276
  * @return boolean
277
  */
278
  public function status_dependency() {
279
+ $this->message = array();
280
+ $plugins = $this->get_dependency_plugins();
281
+ $status = true;
282
 
283
  foreach ( $plugins as $plugin => $data ) {
284
  if ( is_plugin_active( $plugin ) && ! $this->is_plugin_at_conflict_version( $plugin ) ) {
293
  $status = $this->set_message( 'activate', $data['nice_name'] );
294
  }
295
  }
296
+
297
  return $status;
298
  }
299
 
301
  * Check plugin minimal version dependency.
302
  *
303
  * @param string $plugin Plugin transient name.
304
+ *
305
  * @return boolean
306
  */
307
  private function is_plugin_at_min_version( $plugin ) {
312
  * Check plugin maximal version dependency.
313
  *
314
  * @param string $plugin Plugin transient name.
315
+ *
316
  * @return boolean
317
  */
318
  private function is_plugin_at_max_version( $plugin ) {
323
  * Check plugin need version dependency.
324
  *
325
  * @param string $plugin Plugin transient name.
326
+ *
327
  * @return boolean
328
  */
329
  private function is_plugin_at_need_version( $plugin ) {
334
  * Check plugin conflict version dependency.
335
  *
336
  * @param string $plugin Plugin transient name.
337
+ *
338
  * @return boolean
339
  */
340
  private function is_plugin_at_conflict_version( $plugin ) {
345
  * Check plugin version dependency.
346
  *
347
  * @param integer $i Index rules.
348
+ * 0 Min version.
349
+ * 1 Max version.
350
+ * 2 Need plugin verion.
351
+ * 3 Conflict plugin verion.
352
+ * @param string $plugin Plugin transient name.
353
+ *
354
  * @return boolean
355
  */
356
  private function is_plugin_at_version( $i = 0, $plugin ) {
357
 
358
  switch ( $i ) {
359
  case 3:
360
+ $type = 'ne';
361
+ $i = 3;
362
  break;
363
  case 2:
364
+ $type = 'eq';
365
+ $i = 2;
366
  break;
367
  case 1:
368
+ $type = 'le';
369
+ $i = 1;
370
  break;
371
  case 0:
372
  default:
373
+ $type = 'ge';
374
+ $i = 0;
375
  }
376
  $version = $this->get_dep_ver( $plugin, $i );
377
  if ( is_null( $version ) ) {
385
  return ! empty( $version_plugin );
386
  }
387
  }
388
+
389
  return version_compare( $version_plugin, $version, $type );
390
  }
391
 
393
  * Get error messages
394
  *
395
  * @param boolean $first Get first or all error messages.
396
+ *
397
  * @return string
398
  */
399
  public function get_messages( $first = false ) {
400
  if ( $first ) {
401
+ $message = array_shift( $this->message );
402
+ $this->message = array();
403
+
404
  return $message;
405
  }
406
 
407
+ $message = '<p>' . implode( '</p><p>', $this->message ) . '</p>';
408
+ $this->message = array();
409
+
410
  return $message;
411
  }
412
 
415
  *
416
  * @param string $old_value Not used.
417
  * @param string $value Not used.
418
+ *
419
  * @return string
420
  */
421
  public function maybe_deactivate( $old_value, $value ) {
443
  * Deactivation plugin
444
  *
445
  * @param string $actions Not used.
446
+ *
447
  * @return string
448
  */
449
  public function plugin_action_links_maybe_deactivate( $actions ) {
450
  if ( ! $this->status_dependency() ) {
451
  self::deactivate_self( $this->transient );
452
  }
453
+
454
  return $actions;
455
  }
456
 
464
  $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
465
  ?>
466
  <tr class="plugin-update-tr installer-plugin-update-tr">
467
+ <td colspan="<?php echo $wp_list_table->get_column_count(); // WPCS: xss ok. ?>"
468
+ class="plugin-update colspanchange">
469
+ <div class="notice inline notice-warning notice-alt">
470
+ <p class="installer-q-icon">
471
+ <?php echo $this->get_messages( true ); // WPCS: xss ok. ?>
472
+ </p>
473
+ </div>
474
+ </td>
475
  </tr>
476
  <?php
477
  }
480
  /**
481
  * Deactivation plugin
482
  *
483
+ * @param string $file Plugin file path.
484
  * @param boolean $network_wide Network wide.
485
  */
486
  public static function deactivate_self( $file, $network_wide = false ) {
496
  *
497
  * @param string $type Type error message.
498
  * @param string $plugin Plugin transient name.
499
+ *
500
  * @return boolean
501
  */
502
  private function set_message( $type, $plugin ) {
503
+ $current = $this->get_plugin_data( 'current', 'Name' ) ? $this->get_plugin_data( 'current', 'Name' ) : $this->transient;
504
+ $version = $this->get_plugin_data( 'current', 'Version' );
505
+ $plugname = $this->get_plugin_data( $plugin, 'Name' ) ? $this->get_plugin_data( $plugin, 'Name' ) : $plugin;
506
 
507
  $message = '';
508
  switch ( $type ) {
555
  $message = sprintf( $message, $current, $plugname, $version );
556
 
557
  $this->message[] = $message;
558
+
559
  return false;
560
  }
561
 
573
  *
574
  * @param string $plugin Plugin transient name.
575
  * @param string $attr Plugin attribute name.
576
+ *
577
  * @return mixed
578
  */
579
  public function get_plugin_data( $plugin, $attr = null ) {
598
  if ( array_key_exists( $attr, (array) $this->plugin_data[ $plugin ] ) ) {
599
  return $this->plugin_data[ $plugin ][ $attr ];
600
  }
601
+
602
  return null;
603
  }
604
  }
includes/product.helper.php CHANGED
@@ -203,7 +203,7 @@ class TInvWL_Product {
203
  *
204
  * @return array
205
  */
206
- function get_wishlist( $data = array() ) {
207
  if ( ! array_key_exists( 'wishlist_id', $data ) ) {
208
  $data['wishlist_id'] = $this->wishlist_id();
209
  }
@@ -211,7 +211,7 @@ class TInvWL_Product {
211
  return array();
212
  }
213
 
214
- return $this->get( $data );
215
  }
216
 
217
  /**
@@ -261,20 +261,21 @@ class TInvWL_Product {
261
  * Get products
262
  *
263
  * @param array $data Request.
 
264
  *
265
  * @return array
266
  * @global wpdb $wpdb
267
  *
268
  */
269
- function get( $data = array() ) {
270
  global $wpdb;
271
 
272
  $default = array(
273
  'count' => 10,
274
  'field' => null,
275
  'offset' => 0,
276
- 'order' => 'ASC',
277
- 'order_by' => 'in_stock',
278
  'external' => true,
279
  'sql' => '',
280
  );
@@ -296,8 +297,11 @@ class TInvWL_Product {
296
  } else {
297
  $default['field'] = '*';
298
  }
299
- $sql = "SELECT {$default[ 'field' ]} FROM `{$this->table}`";
 
 
300
 
 
301
  $where = '1';
302
  if ( ! empty( $data ) && is_array( $data ) ) {
303
  if ( array_key_exists( 'meta', $data ) ) {
@@ -347,10 +351,14 @@ class TInvWL_Product {
347
  }
348
  $products = $wpdb->get_results( $sql, ARRAY_A ); // WPCS: db call ok; no-cache ok; unprepared SQL ok.
349
 
350
- if ( empty( $products ) ) {
351
  return array();
352
  }
353
 
 
 
 
 
354
  foreach ( $products as $k => $product ) {
355
  if ( empty( $default['sql'] ) ) {
356
  $product = filter_var_array( $product, array(
@@ -368,7 +376,7 @@ class TInvWL_Product {
368
  $product['quantity'] = 1;
369
  }
370
  if ( $default['external'] ) {
371
- $product_data = $this->product_data( $product['product_id'], $product['variation_id'] );
372
  if ( $product_data ) {
373
  $product['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
374
  $product['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
@@ -403,11 +411,6 @@ class TInvWL_Product {
403
  $product_id = absint( $product_id );
404
  $variation_id = absint( $variation_id );
405
 
406
- if ( 'product_variation' == get_post_type( $product_id ) ) { // WPCS: loose comparison ok.
407
- $variation_id = $product_id;
408
- $product_id = wp_get_post_parent_id( $variation_id );
409
- }
410
-
411
  $product_data = apply_filters( 'tinvwl_product_data', wc_get_product( $variation_id ? $variation_id : $product_id ), $product_id, $variation_id );
412
 
413
  if ( ! $product_data || 'trash' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->post->post_status : get_post( $product_data->get_id() )->post_status ) ) {
@@ -616,7 +619,7 @@ class TInvWL_Product {
616
  'variation_id',
617
  'quantity',
618
  'undefined',
619
- 'product_sku'
620
  ) as $field
621
  ) {
622
  if ( array_key_exists( $field, $meta ) ) {
203
  *
204
  * @return array
205
  */
206
+ function get_wishlist( $data = array(), $count = false ) {
207
  if ( ! array_key_exists( 'wishlist_id', $data ) ) {
208
  $data['wishlist_id'] = $this->wishlist_id();
209
  }
211
  return array();
212
  }
213
 
214
+ return $this->get( $data, $count );
215
  }
216
 
217
  /**
261
  * Get products
262
  *
263
  * @param array $data Request.
264
+ * @param bool $count COUNT QUERY.
265
  *
266
  * @return array
267
  * @global wpdb $wpdb
268
  *
269
  */
270
+ function get( $data = array(), $count = false ) {
271
  global $wpdb;
272
 
273
  $default = array(
274
  'count' => 10,
275
  'field' => null,
276
  'offset' => 0,
277
+ 'order' => 'DESC',
278
+ 'order_by' => 'date',
279
  'external' => true,
280
  'sql' => '',
281
  );
297
  } else {
298
  $default['field'] = '*';
299
  }
300
+ if ( $count ) {
301
+ $default['field'] = 'COUNT(`ID`) as `count`';
302
+ }
303
 
304
+ $sql = "SELECT {$default[ 'field' ]} FROM `{$this->table}`";
305
  $where = '1';
306
  if ( ! empty( $data ) && is_array( $data ) ) {
307
  if ( array_key_exists( 'meta', $data ) ) {
351
  }
352
  $products = $wpdb->get_results( $sql, ARRAY_A ); // WPCS: db call ok; no-cache ok; unprepared SQL ok.
353
 
354
+ if ( empty( $products ) || is_wp_error( $products ) ) {
355
  return array();
356
  }
357
 
358
+ if ( $count ) {
359
+ return $products[0]['count'];
360
+ }
361
+
362
  foreach ( $products as $k => $product ) {
363
  if ( empty( $default['sql'] ) ) {
364
  $product = filter_var_array( $product, array(
376
  $product['quantity'] = 1;
377
  }
378
  if ( $default['external'] ) {
379
+ $product_data = $this->product_data( $product['product_id'], $product['variation_id'] );
380
  if ( $product_data ) {
381
  $product['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
382
  $product['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
411
  $product_id = absint( $product_id );
412
  $variation_id = absint( $variation_id );
413
 
 
 
 
 
 
414
  $product_data = apply_filters( 'tinvwl_product_data', wc_get_product( $variation_id ? $variation_id : $product_id ), $product_id, $variation_id );
415
 
416
  if ( ! $product_data || 'trash' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->post->post_status : get_post( $product_data->get_id() )->post_status ) ) {
619
  'variation_id',
620
  'quantity',
621
  'undefined',
622
+ 'product_sku',
623
  ) as $field
624
  ) {
625
  if ( array_key_exists( $field, $meta ) ) {
includes/product/legacy.class.php CHANGED
@@ -45,12 +45,14 @@ class TInvWL_Product_Legacy {
45
  * Get this class object
46
  *
47
  * @param string $plugin_name Plugin name.
 
48
  * @return \TInvWL_Product_Local
49
  */
50
  public static function instance( $plugin_name = TINVWL_PREFIX ) {
51
  if ( is_null( self::$_instance ) ) {
52
  self::$_instance = new self( $plugin_name );
53
  }
 
54
  return self::$_instance;
55
  }
56
 
@@ -61,14 +63,14 @@ class TInvWL_Product_Legacy {
61
  */
62
  function __construct( $plugin_name = TINVWL_PREFIX ) {
63
 
64
- $this->_name = $plugin_name;
65
- $this->products = array();
66
- $this->products_autoinc = 0;
67
 
68
  $products = filter_input( INPUT_COOKIE, 'tinv_wishlist' );
69
  if ( ! empty( $products ) ) {
70
- $products = urldecode( $products );
71
- $products = @json_decode( $products, true ); // @codingStandardsIgnoreLine Generic.PHP.NoSilencedErrors.Discouraged
72
  if ( is_array( $products ) ) {
73
  $this->products = $products;
74
  }
@@ -80,20 +82,22 @@ class TInvWL_Product_Legacy {
80
  }
81
  }
82
  }
83
- $this->products_autoinc++;
84
  }
85
 
86
  /**
87
  * Add product in cookies
88
  *
89
  * @param array $data New product.
 
90
  * @return integer
91
  */
92
  function add_cookies( $data ) {
93
- $data['ID'] = $this->products_autoinc;
94
- $this->products[] = $data;
95
  $this->update_cookie();
96
- $this->products_autoinc++;
 
97
  return $data['ID'];
98
  }
99
 
@@ -102,6 +106,7 @@ class TInvWL_Product_Legacy {
102
  *
103
  * @param array $data Product.
104
  * @param array $where requset.
 
105
  * @return boolean
106
  */
107
  function update_cookies( $data, $where = array() ) {
@@ -125,8 +130,10 @@ class TInvWL_Product_Legacy {
125
  }
126
  if ( $_update ) {
127
  $this->update_cookie();
 
128
  return true;
129
  }
 
130
  return false;
131
  }
132
 
@@ -141,13 +148,14 @@ class TInvWL_Product_Legacy {
141
  * Add\Update product
142
  *
143
  * @param array $data Object product.
 
144
  * @return boolean
145
  */
146
  function add_product( $data = array() ) {
147
  $_data = filter_var_array( $data, array(
148
- 'product_id' => FILTER_VALIDATE_INT,
149
- 'variation_id' => FILTER_VALIDATE_INT,
150
- 'quantity' => FILTER_VALIDATE_INT,
151
  ) );
152
  if ( empty( $_data['quantity'] ) ) {
153
  $_data['quantity'] = 1;
@@ -159,6 +167,7 @@ class TInvWL_Product_Legacy {
159
  }
160
  if ( $product_data ) {
161
  $data['quantity'] = $product_data['quantity'] + $_data['quantity'];
 
162
  return $this->update( $data );
163
  } else {
164
  return $this->add( $data );
@@ -169,22 +178,23 @@ class TInvWL_Product_Legacy {
169
  * Add product
170
  *
171
  * @param array $data Object product.
 
172
  * @return boolean
173
  */
174
  function add( $data = array() ) {
175
  $default = array(
176
- 'date' => current_time( 'Y-m-d H:i:s' ),
177
- 'product_id' => 0,
178
- 'quantity' => 1,
179
- 'variation_id' => 0,
180
  );
181
 
182
- $data = filter_var_array( $data, apply_filters( 'tinvwl_wishlist_product_add_field', array(
183
- 'product_id' => FILTER_VALIDATE_INT,
184
- 'quantity' => FILTER_VALIDATE_INT,
185
- 'variation_id' => FILTER_VALIDATE_INT,
186
  ) ) );
187
- $data = array_filter( $data );
188
 
189
  $data = tinv_array_merge( $default, $data );
190
 
@@ -202,9 +212,9 @@ class TInvWL_Product_Legacy {
202
  $data['quantity'] = 1;
203
  }
204
 
205
- $data = apply_filters( 'tinvwl_wishlist_product_add', $data );
206
- $data['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
207
- $data['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
208
 
209
  $this->add_cookies( $data );
210
 
@@ -215,6 +225,7 @@ class TInvWL_Product_Legacy {
215
  * Get products by wishlist
216
  *
217
  * @param array $data Request.
 
218
  * @return array
219
  */
220
  function get_wishlist( $data = array() ) {
@@ -226,11 +237,12 @@ class TInvWL_Product_Legacy {
226
  *
227
  * @param integer $product_id Product id.
228
  * @param integer $variation_id Product variaton id.
 
229
  * @return mixed
230
  */
231
  function check_product( $product_id, $variation_id = 0 ) {
232
- $product_id = absint( $product_id );
233
- $variation_id = absint( $variation_id );
234
 
235
  $product_data = $this->product_data( $product_id, $variation_id );
236
 
@@ -239,10 +251,10 @@ class TInvWL_Product_Legacy {
239
  }
240
 
241
  $products = $this->get( array(
242
- 'product_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) ),
243
- 'variation_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ),
244
- 'count' => 1,
245
- 'external' => false,
246
  ) );
247
 
248
  return array_shift( $products );
@@ -252,16 +264,17 @@ class TInvWL_Product_Legacy {
252
  * Get products
253
  *
254
  * @param array $data Request.
 
255
  * @return array
256
  */
257
  function get( $data = array() ) {
258
  $default = array(
259
- 'count' => 10,
260
- 'offset' => 0,
261
- 'external' => true,
262
  );
263
 
264
- foreach ( $default as $_k => $_v ) {
265
  if ( array_key_exists( $_k, $data ) ) {
266
  $default[ $_k ] = $data[ $_k ];
267
  unset( $data[ $_k ] );
@@ -302,28 +315,29 @@ class TInvWL_Product_Legacy {
302
 
303
  foreach ( $products as $k => $product ) {
304
  $product = filter_var_array( $product, array(
305
- 'ID' => FILTER_VALIDATE_INT,
306
- 'wishlist_id' => FILTER_VALIDATE_INT,
307
- 'product_id' => FILTER_VALIDATE_INT,
308
- 'variation_id' => FILTER_VALIDATE_INT,
309
- 'author' => FILTER_VALIDATE_INT,
310
- 'date' => FILTER_SANITIZE_STRING,
311
- 'quantity' => FILTER_VALIDATE_INT,
312
- 'price' => FILTER_SANITIZE_NUMBER_FLOAT,
313
- 'in_stock' => FILTER_VALIDATE_BOOLEAN,
314
  ) );
315
 
316
  $product['wishlist_id'] = 0;
317
  if ( $default['external'] ) {
318
  $product_data = $this->product_data( $product['variation_id'], $product['product_id'] );
319
  if ( $product_data ) {
320
- $product['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
321
- $product['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
322
  }
323
  $product['data'] = $product_data;
324
  }
325
  $products[ $k ] = apply_filters( 'tinvwl_wishlist_product_get', $product );
326
  }
 
327
  return $products;
328
  }
329
 
@@ -332,15 +346,16 @@ class TInvWL_Product_Legacy {
332
  *
333
  * @param integer $product_id Product id.
334
  * @param integer $variation_id Product variation id.
 
335
  * @return mixed
336
  */
337
  function product_data( $product_id, $variation_id = 0 ) {
338
- $product_id = absint( $product_id );
339
- $variation_id = absint( $variation_id );
340
 
341
  if ( 'product_variation' == get_post_type( $product_id ) ) { // WPCS: loose comparison ok.
342
- $variation_id = $product_id;
343
- $product_id = wp_get_post_parent_id( $variation_id );
344
  }
345
 
346
  $product_data = wc_get_product( $variation_id ? $variation_id : $product_id );
@@ -350,6 +365,7 @@ class TInvWL_Product_Legacy {
350
  }
351
 
352
  $product_data->variation_id = absint( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ) );
 
353
  return $product_data;
354
  }
355
 
@@ -357,15 +373,16 @@ class TInvWL_Product_Legacy {
357
  * Update product
358
  *
359
  * @param array $data Object product.
 
360
  * @return boolean
361
  */
362
  function update( $data = array() ) {
363
- $data = filter_var_array( $data, apply_filters( 'tinvwl_wishlist_product_update_field', array(
364
- 'product_id' => FILTER_VALIDATE_INT,
365
- 'quantity' => FILTER_VALIDATE_INT,
366
- 'variation_id' => FILTER_VALIDATE_INT,
367
  ) ) );
368
- $data = array_filter( $data );
369
 
370
  if ( ! array_key_exists( 'variation_id', $data ) ) {
371
  $data['variation_id'] = 0;
@@ -383,11 +400,14 @@ class TInvWL_Product_Legacy {
383
  $data['quantity'] = 1;
384
  }
385
 
386
- $data = apply_filters( 'tinvwl_wishlist_product_update', $data );
387
- $data['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
388
- $data['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
389
 
390
- return $this->update_cookies( $data, array( 'product_id' => $data['product_id'], 'variation_id' => $data['variation_id'] ) );
 
 
 
391
  }
392
 
393
  /**
@@ -396,6 +416,7 @@ class TInvWL_Product_Legacy {
396
  * @param integer $wishlist_id Not Used.
397
  * @param integer $product_id Product id.
398
  * @param integer $variation_id Product variation id.
 
399
  * @return boolean
400
  */
401
  function remove_product_from_wl( $wishlist_id = 0, $product_id = 0, $variation_id = 0 ) {
@@ -423,6 +444,7 @@ class TInvWL_Product_Legacy {
423
  $this->update_cookie();
424
  do_action( 'tinvwl_wishlist_product_removed_from_wishlist', $wishlist_id, ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ) );
425
  }
 
426
  return true;
427
  }
428
 
@@ -430,6 +452,7 @@ class TInvWL_Product_Legacy {
430
  * Remove product
431
  *
432
  * @param integer $product_id Product id.
 
433
  * @return boolean
434
  */
435
  function remove_product( $product_id = 0 ) {
@@ -451,6 +474,7 @@ class TInvWL_Product_Legacy {
451
  $this->update_cookie();
452
  do_action( 'tinvwl_wishlist_product_removed_by_product', $product_id );
453
  }
 
454
  return true;
455
  }
456
 
@@ -458,6 +482,7 @@ class TInvWL_Product_Legacy {
458
  * Remove product by ID
459
  *
460
  * @param integer $id Product id.
 
461
  * @return boolean
462
  */
463
  function remove( $id = 0 ) {
@@ -471,13 +496,14 @@ class TInvWL_Product_Legacy {
471
  }
472
  }
473
 
474
- $c = count( $this->products );
475
  $this->products = array_filter( $this->products );
476
 
477
  if ( count( $this->products ) < $c ) {
478
  $this->update_cookie();
479
  do_action( 'tinvwl_wishlist_product_removed_by_id', $id );
480
  }
 
481
  return true;
482
  }
483
  }
45
  * Get this class object
46
  *
47
  * @param string $plugin_name Plugin name.
48
+ *
49
  * @return \TInvWL_Product_Local
50
  */
51
  public static function instance( $plugin_name = TINVWL_PREFIX ) {
52
  if ( is_null( self::$_instance ) ) {
53
  self::$_instance = new self( $plugin_name );
54
  }
55
+
56
  return self::$_instance;
57
  }
58
 
63
  */
64
  function __construct( $plugin_name = TINVWL_PREFIX ) {
65
 
66
+ $this->_name = $plugin_name;
67
+ $this->products = array();
68
+ $this->products_autoinc = 0;
69
 
70
  $products = filter_input( INPUT_COOKIE, 'tinv_wishlist' );
71
  if ( ! empty( $products ) ) {
72
+ $products = urldecode( $products );
73
+ $products = @json_decode( $products, true ); // @codingStandardsIgnoreLine Generic.PHP.NoSilencedErrors.Discouraged
74
  if ( is_array( $products ) ) {
75
  $this->products = $products;
76
  }
82
  }
83
  }
84
  }
85
+ $this->products_autoinc ++;
86
  }
87
 
88
  /**
89
  * Add product in cookies
90
  *
91
  * @param array $data New product.
92
+ *
93
  * @return integer
94
  */
95
  function add_cookies( $data ) {
96
+ $data['ID'] = $this->products_autoinc;
97
+ $this->products[] = $data;
98
  $this->update_cookie();
99
+ $this->products_autoinc ++;
100
+
101
  return $data['ID'];
102
  }
103
 
106
  *
107
  * @param array $data Product.
108
  * @param array $where requset.
109
+ *
110
  * @return boolean
111
  */
112
  function update_cookies( $data, $where = array() ) {
130
  }
131
  if ( $_update ) {
132
  $this->update_cookie();
133
+
134
  return true;
135
  }
136
+
137
  return false;
138
  }
139
 
148
  * Add\Update product
149
  *
150
  * @param array $data Object product.
151
+ *
152
  * @return boolean
153
  */
154
  function add_product( $data = array() ) {
155
  $_data = filter_var_array( $data, array(
156
+ 'product_id' => FILTER_VALIDATE_INT,
157
+ 'variation_id' => FILTER_VALIDATE_INT,
158
+ 'quantity' => FILTER_VALIDATE_INT,
159
  ) );
160
  if ( empty( $_data['quantity'] ) ) {
161
  $_data['quantity'] = 1;
167
  }
168
  if ( $product_data ) {
169
  $data['quantity'] = $product_data['quantity'] + $_data['quantity'];
170
+
171
  return $this->update( $data );
172
  } else {
173
  return $this->add( $data );
178
  * Add product
179
  *
180
  * @param array $data Object product.
181
+ *
182
  * @return boolean
183
  */
184
  function add( $data = array() ) {
185
  $default = array(
186
+ 'date' => current_time( 'Y-m-d H:i:s' ),
187
+ 'product_id' => 0,
188
+ 'quantity' => 1,
189
+ 'variation_id' => 0,
190
  );
191
 
192
+ $data = filter_var_array( $data, apply_filters( 'tinvwl_wishlist_product_add_field', array(
193
+ 'product_id' => FILTER_VALIDATE_INT,
194
+ 'quantity' => FILTER_VALIDATE_INT,
195
+ 'variation_id' => FILTER_VALIDATE_INT,
196
  ) ) );
197
+ $data = array_filter( $data );
198
 
199
  $data = tinv_array_merge( $default, $data );
200
 
212
  $data['quantity'] = 1;
213
  }
214
 
215
+ $data = apply_filters( 'tinvwl_wishlist_product_add', $data );
216
+ $data['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
217
+ $data['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
218
 
219
  $this->add_cookies( $data );
220
 
225
  * Get products by wishlist
226
  *
227
  * @param array $data Request.
228
+ *
229
  * @return array
230
  */
231
  function get_wishlist( $data = array() ) {
237
  *
238
  * @param integer $product_id Product id.
239
  * @param integer $variation_id Product variaton id.
240
+ *
241
  * @return mixed
242
  */
243
  function check_product( $product_id, $variation_id = 0 ) {
244
+ $product_id = absint( $product_id );
245
+ $variation_id = absint( $variation_id );
246
 
247
  $product_data = $this->product_data( $product_id, $variation_id );
248
 
251
  }
252
 
253
  $products = $this->get( array(
254
+ 'product_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) ),
255
+ 'variation_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ),
256
+ 'count' => 1,
257
+ 'external' => false,
258
  ) );
259
 
260
  return array_shift( $products );
264
  * Get products
265
  *
266
  * @param array $data Request.
267
+ *
268
  * @return array
269
  */
270
  function get( $data = array() ) {
271
  $default = array(
272
+ 'count' => 10,
273
+ 'offset' => 0,
274
+ 'external' => true,
275
  );
276
 
277
+ foreach ( array_keys( $default ) as $_k ) {
278
  if ( array_key_exists( $_k, $data ) ) {
279
  $default[ $_k ] = $data[ $_k ];
280
  unset( $data[ $_k ] );
315
 
316
  foreach ( $products as $k => $product ) {
317
  $product = filter_var_array( $product, array(
318
+ 'ID' => FILTER_VALIDATE_INT,
319
+ 'wishlist_id' => FILTER_VALIDATE_INT,
320
+ 'product_id' => FILTER_VALIDATE_INT,
321
+ 'variation_id' => FILTER_VALIDATE_INT,
322
+ 'author' => FILTER_VALIDATE_INT,
323
+ 'date' => FILTER_SANITIZE_STRING,
324
+ 'quantity' => FILTER_VALIDATE_INT,
325
+ 'price' => FILTER_SANITIZE_NUMBER_FLOAT,
326
+ 'in_stock' => FILTER_VALIDATE_BOOLEAN,
327
  ) );
328
 
329
  $product['wishlist_id'] = 0;
330
  if ( $default['external'] ) {
331
  $product_data = $this->product_data( $product['variation_id'], $product['product_id'] );
332
  if ( $product_data ) {
333
+ $product['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
334
+ $product['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
335
  }
336
  $product['data'] = $product_data;
337
  }
338
  $products[ $k ] = apply_filters( 'tinvwl_wishlist_product_get', $product );
339
  }
340
+
341
  return $products;
342
  }
343
 
346
  *
347
  * @param integer $product_id Product id.
348
  * @param integer $variation_id Product variation id.
349
+ *
350
  * @return mixed
351
  */
352
  function product_data( $product_id, $variation_id = 0 ) {
353
+ $product_id = absint( $product_id );
354
+ $variation_id = absint( $variation_id );
355
 
356
  if ( 'product_variation' == get_post_type( $product_id ) ) { // WPCS: loose comparison ok.
357
+ $variation_id = $product_id;
358
+ $product_id = wp_get_post_parent_id( $variation_id );
359
  }
360
 
361
  $product_data = wc_get_product( $variation_id ? $variation_id : $product_id );
365
  }
366
 
367
  $product_data->variation_id = absint( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ) );
368
+
369
  return $product_data;
370
  }
371
 
373
  * Update product
374
  *
375
  * @param array $data Object product.
376
+ *
377
  * @return boolean
378
  */
379
  function update( $data = array() ) {
380
+ $data = filter_var_array( $data, apply_filters( 'tinvwl_wishlist_product_update_field', array(
381
+ 'product_id' => FILTER_VALIDATE_INT,
382
+ 'quantity' => FILTER_VALIDATE_INT,
383
+ 'variation_id' => FILTER_VALIDATE_INT,
384
  ) ) );
385
+ $data = array_filter( $data );
386
 
387
  if ( ! array_key_exists( 'variation_id', $data ) ) {
388
  $data['variation_id'] = 0;
400
  $data['quantity'] = 1;
401
  }
402
 
403
+ $data = apply_filters( 'tinvwl_wishlist_product_update', $data );
404
+ $data['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
405
+ $data['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
406
 
407
+ return $this->update_cookies( $data, array(
408
+ 'product_id' => $data['product_id'],
409
+ 'variation_id' => $data['variation_id'],
410
+ ) );
411
  }
412
 
413
  /**
416
  * @param integer $wishlist_id Not Used.
417
  * @param integer $product_id Product id.
418
  * @param integer $variation_id Product variation id.
419
+ *
420
  * @return boolean
421
  */
422
  function remove_product_from_wl( $wishlist_id = 0, $product_id = 0, $variation_id = 0 ) {
444
  $this->update_cookie();
445
  do_action( 'tinvwl_wishlist_product_removed_from_wishlist', $wishlist_id, ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ) );
446
  }
447
+
448
  return true;
449
  }
450
 
452
  * Remove product
453
  *
454
  * @param integer $product_id Product id.
455
+ *
456
  * @return boolean
457
  */
458
  function remove_product( $product_id = 0 ) {
474
  $this->update_cookie();
475
  do_action( 'tinvwl_wishlist_product_removed_by_product', $product_id );
476
  }
477
+
478
  return true;
479
  }
480
 
482
  * Remove product by ID
483
  *
484
  * @param integer $id Product id.
485
+ *
486
  * @return boolean
487
  */
488
  function remove( $id = 0 ) {
496
  }
497
  }
498
 
499
+ $c = count( $this->products );
500
  $this->products = array_filter( $this->products );
501
 
502
  if ( count( $this->products ) < $c ) {
503
  $this->update_cookie();
504
  do_action( 'tinvwl_wishlist_product_removed_by_id', $id );
505
  }
506
+
507
  return true;
508
  }
509
  }
includes/tinvwl.class.php CHANGED
@@ -109,7 +109,7 @@ class TInvWL {
109
  function define_hooks() {
110
  add_filter( 'plugin_action_links_' . plugin_basename( TINVWL_PATH . 'ti-woocommerce-wishlist.php' ), array(
111
  $this,
112
- 'action_links'
113
  ) );
114
  add_action( 'after_setup_theme', 'tinvwl_set_utm', 100 );
115
  }
@@ -118,10 +118,6 @@ class TInvWL {
118
  * Load function
119
  */
120
  function load_function() {
121
- if ( tinv_get_option( 'template_checker', 'checked' ) ) {
122
- return;
123
- }
124
- TInvWL_CheckerHook::instance();
125
  }
126
 
127
  /**
109
  function define_hooks() {
110
  add_filter( 'plugin_action_links_' . plugin_basename( TINVWL_PATH . 'ti-woocommerce-wishlist.php' ), array(
111
  $this,
112
+ 'action_links',
113
  ) );
114
  add_action( 'after_setup_theme', 'tinvwl_set_utm', 100 );
115
  }
118
  * Load function
119
  */
120
  function load_function() {
 
 
 
 
121
  }
122
 
123
  /**
includes/update.helper.php CHANGED
@@ -163,7 +163,7 @@ class TInvWL_Update {
163
  $wishlists_table = sprintf( '%s%s_%s', $wpdb->prefix, $this->_name, 'lists' );
164
  $wishlists_items_table = sprintf( '%s%s_%s', $wpdb->prefix, $this->_name, 'items' );
165
  $sql = "DELETE FROM wl USING `{$wishlists_table}` AS wl WHERE NOT EXISTS( SELECT * FROM `{$wishlists_items_table}` WHERE {$wishlists_items_table}.wishlist_id = wl.ID ) AND wl.type='default'";
166
- $cleanup = $wpdb->get_results( $sql, ARRAY_A ); // WPCS: db call ok; no-cache ok; unprepared SQL ok.
167
  }
168
 
169
  /**
163
  $wishlists_table = sprintf( '%s%s_%s', $wpdb->prefix, $this->_name, 'lists' );
164
  $wishlists_items_table = sprintf( '%s%s_%s', $wpdb->prefix, $this->_name, 'items' );
165
  $sql = "DELETE FROM wl USING `{$wishlists_table}` AS wl WHERE NOT EXISTS( SELECT * FROM `{$wishlists_items_table}` WHERE {$wishlists_items_table}.wishlist_id = wl.ID ) AND wl.type='default'";
166
+ $wpdb->get_results( $sql, ARRAY_A ); // WPCS: db call ok; no-cache ok; unprepared SQL ok.
167
  }
168
 
169
  /**
includes/viewsection.helper.php CHANGED
@@ -182,7 +182,6 @@ class TInvWL_ViewSection extends TInvWL_View {
182
  return $groups;
183
  }
184
 
185
-
186
  /**
187
  * Create show group
188
  *
182
  return $groups;
183
  }
184
 
 
185
  /**
186
  * Create show group
187
  *
includes/wizard.class.php CHANGED
@@ -178,7 +178,7 @@ class TInvWL_Wizard {
178
  wp_enqueue_style( $this->_name . '-form', TINVWL_URL . 'assets/css/admin-form.css', array(), $this->_version, 'all' );
179
  wp_enqueue_style( $this->_name . '-setup', TINVWL_URL . 'assets/css/admin-setup.css', array(
180
  'dashicons',
181
- 'install'
182
  ), $this->_version, 'all' );
183
  }
184
 
@@ -324,7 +324,7 @@ class TInvWL_Wizard {
324
  $data = array(
325
  'general_default_title' => FILTER_SANITIZE_STRING,
326
  );
327
- foreach ( $title_pages as $key => $text ) {
328
  $data[ 'page_' . $key ] = FILTER_VALIDATE_INT;
329
  $data[ 'page_' . $key . '_new' ] = FILTER_SANITIZE_STRING;
330
  $data[ 'page_' . $key . '_auto' ] = FILTER_VALIDATE_BOOLEAN;
178
  wp_enqueue_style( $this->_name . '-form', TINVWL_URL . 'assets/css/admin-form.css', array(), $this->_version, 'all' );
179
  wp_enqueue_style( $this->_name . '-setup', TINVWL_URL . 'assets/css/admin-setup.css', array(
180
  'dashicons',
181
+ 'install',
182
  ), $this->_version, 'all' );
183
  }
184
 
324
  $data = array(
325
  'general_default_title' => FILTER_SANITIZE_STRING,
326
  );
327
+ foreach ( array_keys( $title_pages ) as $key ) {
328
  $data[ 'page_' . $key ] = FILTER_VALIDATE_INT;
329
  $data[ 'page_' . $key . '_new' ] = FILTER_SANITIZE_STRING;
330
  $data[ 'page_' . $key . '_auto' ] = FILTER_VALIDATE_BOOLEAN;
languages/ti-woocommerce-wishlist.pot CHANGED
@@ -1,8 +1,8 @@
1
- # Copyright (C) 2019 WooCommerce Wishlist Plugin - 1.11.1
2
- # This file is distributed under the same license as the WooCommerce Wishlist Plugin - 1.11.1 package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WooCommerce Wishlist Plugin - 1.11.1\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
@@ -16,31 +16,31 @@ msgstr ""
16
  "X-Poedit-SourceCharset: UTF-8\n"
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
 
19
- #: admin/basestyle.helper.php:57
20
  msgid "Templates"
21
  msgstr ""
22
 
23
- #: admin/basestyle.helper.php:64
24
  msgid "Use Theme style"
25
  msgstr ""
26
 
27
- #: admin/basestyle.helper.php:73
28
  msgid "Template Options"
29
  msgstr ""
30
 
31
- #: admin/basestyle.helper.php:81, admin/basestyle.helper.php:88
32
  msgid "Template Custom CSS"
33
  msgstr ""
34
 
35
- #: admin/basestyle.helper.php:114, admin/settings/general.class.php:814
36
  msgid "Save Settings"
37
  msgstr ""
38
 
39
- #: admin/basestyle.helper.php:120, admin/settings/general.class.php:820
40
  msgid "Reset"
41
  msgstr ""
42
 
43
- #: admin/basestyle.helper.php:126, admin/settings/general.class.php:826
44
  msgid "Save"
45
  msgstr ""
46
 
@@ -744,23 +744,23 @@ msgstr ""
744
  msgid "<strong>Your theme (%1$s) contains outdated copies of some WooCommerce Wishlist Plugin template files.</strong><br> These files may need updating to ensure they are compatible with the current version of WooCommerce Wishlist Plugin.<br> You can see which files are affected from the <a href=\"%2$s\">system status page</a>.<br> If in doubt, check with the author of the theme."
745
  msgstr ""
746
 
747
- #: includes/api/yoasti18n/i18n-module.php:207
748
  msgid "As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help complete the translation to %1$s!"
749
  msgstr ""
750
 
751
- #: includes/api/yoasti18n/i18n-module.php:209
752
  msgid "You're using WordPress in <strong>%1$s</strong>. While %2$s has been translated to %1$s for <strong>%3$d%%</strong>, it's not been shipped with the plugin yet.<br> You can help! Register at %4$s to help complete the translation to %1$s!"
753
  msgstr ""
754
 
755
- #: includes/api/yoasti18n/i18n-module.php:211
756
  msgid "You're using WordPress in a language we don't support yet. We'd love for %2$s to be translated in that language too, but unfortunately, it isn't right now. You can change that! Register at %4$s to help translate it!"
757
  msgstr ""
758
 
759
- #: includes/api/yoasti18n/i18n-module.php:237
760
  msgid "Translation of %s"
761
  msgstr ""
762
 
763
- #: includes/api/yoasti18n/i18n-module.php:239
764
  msgid "Register now &raquo;"
765
  msgstr ""
766
 
@@ -768,43 +768,43 @@ msgstr ""
768
  msgid "Preview"
769
  msgstr ""
770
 
771
- #: includes/pluginextend.helper.php:477
772
  msgid "%2$s %3$s is required for %1$s. Deactivating %1$s."
773
  msgstr ""
774
 
775
- #: includes/pluginextend.helper.php:486
776
  msgid "%1$s is confilcted with %2$s %3$s. Deactivating %1$s."
777
  msgstr ""
778
 
779
- #: includes/pluginextend.helper.php:495
780
  msgid "%2$s %3$s is required. Please update it before activating this plugin."
781
  msgstr ""
782
 
783
- #: includes/pluginextend.helper.php:500
784
  msgid "%2$s %3$s is required. Please downgrade it before activating this plugin."
785
  msgstr ""
786
 
787
- #: includes/pluginextend.helper.php:504
788
  msgid "%2$s %3$s is required. Please activate it before activating this plugin."
789
  msgstr ""
790
 
791
- #: includes/pluginextend.helper.php:508
792
  msgid "%1$s is conflicted with %2$s %3$s. Please disable it before activating this plugin."
793
  msgstr ""
794
 
795
- #: includes/pluginextend.helper.php:512
796
  msgid "%1$s %3$s is required. Please activate it before activating this plugin."
797
  msgstr ""
798
 
799
- #: includes/tinvwl.class.php:154
800
  msgid "Settings"
801
  msgstr ""
802
 
803
- #: includes/tinvwl.class.php:155
804
  msgid "Premium Version"
805
  msgstr ""
806
 
807
- #: includes/tinvwl.class.php:156
808
  msgid "Live Demo"
809
  msgstr ""
810
 
@@ -832,7 +832,7 @@ msgstr ""
832
  msgid "Page Setup"
833
  msgstr ""
834
 
835
- #: includes/wizard.class.php:288, includes/wizard.class.php:319, public/tinvwl.class.php:646
836
  msgid "Wishlist"
837
  msgstr ""
838
 
@@ -868,31 +868,27 @@ msgstr ""
868
  msgid "Ready!"
869
  msgstr ""
870
 
871
- #: public/addtowishlist.class.php:173
872
  msgid "Please, login to add products to Wishlist"
873
  msgstr ""
874
 
875
- #: public/addtowishlist.class.php:175
876
  msgid "Login"
877
  msgstr ""
878
 
879
- #: public/tinvwl.class.php:384
880
- msgid "%1$s by %2$s"
881
- msgstr ""
882
-
883
- #: public/tinvwl.class.php:543
884
  msgid "Create New"
885
  msgstr ""
886
 
887
- #: public/tinvwl.class.php:546
888
  msgid "Please select some product options before adding this product to your wishlist."
889
  msgstr ""
890
 
891
- #: public/tinvwl.class.php:547
892
  msgid "No items or actions are selected."
893
  msgstr ""
894
 
895
- #: public/tinvwl.class.php:548
896
  msgid "Copied!"
897
  msgstr ""
898
 
@@ -924,12 +920,12 @@ msgstr ""
924
  msgid "Action"
925
  msgstr ""
926
 
927
- #: public/wishlist/buttons.class.php:306, public/wishlist/buttons.class.php:438
928
  msgctxt "Item name in quotes"
929
  msgid "&ldquo;%s&rdquo;"
930
  msgstr ""
931
 
932
- #: public/wishlist/buttons.class.php:309, public/wishlist/buttons.class.php:441
933
  msgid "Product %s could not be added to cart because some requirements are not met."
934
  msgid_plural "Products: %s could not be added to cart because some requirements are not met."
935
  msgstr[0] ""
@@ -943,33 +939,37 @@ msgstr ""
943
  msgid "Remove"
944
  msgstr ""
945
 
946
- #: public/wishlist/buttons.class.php:495, public/wishlist/view.class.php:364
947
  msgid "&ldquo;%s&rdquo;"
948
  msgstr ""
949
 
950
- #: public/wishlist/buttons.class.php:508
951
  msgid "%s has been successfully removed from wishlist."
952
  msgid_plural "%s have been successfully removed from wishlist."
953
  msgstr[0] ""
954
  msgstr[1] ""
955
 
956
- #: public/wishlist/view.class.php:374
 
 
 
 
957
  msgid "%s has been removed from wishlist."
958
  msgstr ""
959
 
960
- #: public/wishlist/view.class.php:376
961
  msgid "%s has not been removed from wishlist."
962
  msgstr ""
963
 
964
- #: public/wishlist/view.class.php:519
965
  msgid "Return to Wishlist"
966
  msgstr ""
967
 
968
- #: public/wishlist/view.class.php:617
969
  msgid "Previous Page"
970
  msgstr ""
971
 
972
- #: public/wishlist/view.class.php:643
973
  msgid "Next Page"
974
  msgstr ""
975
 
@@ -1021,7 +1021,7 @@ msgstr ""
1021
  msgid "Select for bulk action"
1022
  msgstr ""
1023
 
1024
- #: templates/ti-wishlist-user.php:132, templates/ti-wishlist.php:140, tinv-wishlists-function-integration.php:774, tinv-wishlists-function-integration.php:931, tinv-wishlists-function-integration.php:1093, tinv-wishlists-function-integration.php:1307
1025
  msgid "In stock"
1026
  msgstr ""
1027
 
@@ -1029,71 +1029,71 @@ msgstr ""
1029
  msgid "Select options"
1030
  msgstr ""
1031
 
1032
- #: tinv-wishlists-function-integration.php:483
1033
  msgid "Note"
1034
  msgstr ""
1035
 
1036
- #: tinv-wishlists-function-integration.php:486
1037
  msgid "To"
1038
  msgstr ""
1039
 
1040
- #: tinv-wishlists-function-integration.php:489
1041
  msgid "To Email"
1042
  msgstr ""
1043
 
1044
- #: tinv-wishlists-function-integration.php:492
1045
  msgid "Address"
1046
  msgstr ""
1047
 
1048
- #: tinv-wishlists-function-integration.php:495
1049
  msgid "Reload existing Gift Card"
1050
  msgstr ""
1051
 
1052
- #: tinv-wishlists-function-integration.php:1246
1053
  msgid "Out of stock"
1054
  msgstr ""
1055
 
1056
- #: tinv-wishlists-function-integration.php:1655
1057
  msgid "Base price"
1058
  msgstr ""
1059
 
1060
- #: tinv-wishlists-function-integration.php:2336
1061
  msgid "WooCommerce Wishlist"
1062
  msgstr ""
1063
 
1064
- #: tinv-wishlists-function-integration.php:2337
1065
  msgid "Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist."
1066
  msgstr ""
1067
 
1068
- #: tinv-wishlists-function-integration.php:2484
1069
  msgid "Adding Product to Wishlist"
1070
  msgstr ""
1071
 
1072
- #: tinv-wishlists-function-integration.php:2489, tinv-wishlists-function-integration.php:2534
1073
  msgid "Points"
1074
  msgstr ""
1075
 
1076
- #: tinv-wishlists-function-integration.php:2502, tinv-wishlists-function-integration.php:2547
1077
  msgid "Limit"
1078
  msgstr ""
1079
 
1080
- #: tinv-wishlists-function-integration.php:2515, tinv-wishlists-function-integration.php:2560
1081
  msgid "Log Template"
1082
  msgstr ""
1083
 
1084
- #: tinv-wishlists-function-integration.php:2519, tinv-wishlists-function-integration.php:2564
1085
  msgid "required"
1086
  msgstr ""
1087
 
1088
- #: tinv-wishlists-function-integration.php:2529
1089
  msgid "Purchasing Product from Wishlist"
1090
  msgstr ""
1091
 
1092
- #: tinv-wishlists-function-integration.php:2615
1093
  msgid "Purchased From Wishlist"
1094
  msgstr ""
1095
 
1096
- #: tinv-wishlists-function-integration.php:2616
1097
  msgid "Added To Wishlist"
1098
  msgstr ""
1099
 
1
+ # Copyright (C) 2019 WooCommerce Wishlist Plugin - 1.12.0
2
+ # This file is distributed under the same license as the WooCommerce Wishlist Plugin - 1.12.0 package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WooCommerce Wishlist Plugin - 1.12.0\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
 
19
+ #: admin/basestyle.helper.php:58
20
  msgid "Templates"
21
  msgstr ""
22
 
23
+ #: admin/basestyle.helper.php:65
24
  msgid "Use Theme style"
25
  msgstr ""
26
 
27
+ #: admin/basestyle.helper.php:74
28
  msgid "Template Options"
29
  msgstr ""
30
 
31
+ #: admin/basestyle.helper.php:82, admin/basestyle.helper.php:89
32
  msgid "Template Custom CSS"
33
  msgstr ""
34
 
35
+ #: admin/basestyle.helper.php:115, admin/settings/general.class.php:814
36
  msgid "Save Settings"
37
  msgstr ""
38
 
39
+ #: admin/basestyle.helper.php:121, admin/settings/general.class.php:820
40
  msgid "Reset"
41
  msgstr ""
42
 
43
+ #: admin/basestyle.helper.php:127, admin/settings/general.class.php:826
44
  msgid "Save"
45
  msgstr ""
46
 
744
  msgid "<strong>Your theme (%1$s) contains outdated copies of some WooCommerce Wishlist Plugin template files.</strong><br> These files may need updating to ensure they are compatible with the current version of WooCommerce Wishlist Plugin.<br> You can see which files are affected from the <a href=\"%2$s\">system status page</a>.<br> If in doubt, check with the author of the theme."
745
  msgstr ""
746
 
747
+ #: includes/api/yoasti18n/i18n-module.php:200
748
  msgid "As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help complete the translation to %1$s!"
749
  msgstr ""
750
 
751
+ #: includes/api/yoasti18n/i18n-module.php:202
752
  msgid "You're using WordPress in <strong>%1$s</strong>. While %2$s has been translated to %1$s for <strong>%3$d%%</strong>, it's not been shipped with the plugin yet.<br> You can help! Register at %4$s to help complete the translation to %1$s!"
753
  msgstr ""
754
 
755
+ #: includes/api/yoasti18n/i18n-module.php:204
756
  msgid "You're using WordPress in a language we don't support yet. We'd love for %2$s to be translated in that language too, but unfortunately, it isn't right now. You can change that! Register at %4$s to help translate it!"
757
  msgstr ""
758
 
759
+ #: includes/api/yoasti18n/i18n-module.php:230
760
  msgid "Translation of %s"
761
  msgstr ""
762
 
763
+ #: includes/api/yoasti18n/i18n-module.php:232
764
  msgid "Register now &raquo;"
765
  msgstr ""
766
 
768
  msgid "Preview"
769
  msgstr ""
770
 
771
+ #: includes/pluginextend.helper.php:511
772
  msgid "%2$s %3$s is required for %1$s. Deactivating %1$s."
773
  msgstr ""
774
 
775
+ #: includes/pluginextend.helper.php:520
776
  msgid "%1$s is confilcted with %2$s %3$s. Deactivating %1$s."
777
  msgstr ""
778
 
779
+ #: includes/pluginextend.helper.php:529
780
  msgid "%2$s %3$s is required. Please update it before activating this plugin."
781
  msgstr ""
782
 
783
+ #: includes/pluginextend.helper.php:534
784
  msgid "%2$s %3$s is required. Please downgrade it before activating this plugin."
785
  msgstr ""
786
 
787
+ #: includes/pluginextend.helper.php:538
788
  msgid "%2$s %3$s is required. Please activate it before activating this plugin."
789
  msgstr ""
790
 
791
+ #: includes/pluginextend.helper.php:542
792
  msgid "%1$s is conflicted with %2$s %3$s. Please disable it before activating this plugin."
793
  msgstr ""
794
 
795
+ #: includes/pluginextend.helper.php:546
796
  msgid "%1$s %3$s is required. Please activate it before activating this plugin."
797
  msgstr ""
798
 
799
+ #: includes/tinvwl.class.php:150
800
  msgid "Settings"
801
  msgstr ""
802
 
803
+ #: includes/tinvwl.class.php:151
804
  msgid "Premium Version"
805
  msgstr ""
806
 
807
+ #: includes/tinvwl.class.php:152
808
  msgid "Live Demo"
809
  msgstr ""
810
 
832
  msgid "Page Setup"
833
  msgstr ""
834
 
835
+ #: includes/wizard.class.php:288, includes/wizard.class.php:319, public/tinvwl.class.php:580
836
  msgid "Wishlist"
837
  msgstr ""
838
 
868
  msgid "Ready!"
869
  msgstr ""
870
 
871
+ #: public/addtowishlist.class.php:180
872
  msgid "Please, login to add products to Wishlist"
873
  msgstr ""
874
 
875
+ #: public/addtowishlist.class.php:182
876
  msgid "Login"
877
  msgstr ""
878
 
879
+ #: public/tinvwl.class.php:477
 
 
 
 
880
  msgid "Create New"
881
  msgstr ""
882
 
883
+ #: public/tinvwl.class.php:480
884
  msgid "Please select some product options before adding this product to your wishlist."
885
  msgstr ""
886
 
887
+ #: public/tinvwl.class.php:481
888
  msgid "No items or actions are selected."
889
  msgstr ""
890
 
891
+ #: public/tinvwl.class.php:482
892
  msgid "Copied!"
893
  msgstr ""
894
 
920
  msgid "Action"
921
  msgstr ""
922
 
923
+ #: public/wishlist/buttons.class.php:306, public/wishlist/buttons.class.php:437
924
  msgctxt "Item name in quotes"
925
  msgid "&ldquo;%s&rdquo;"
926
  msgstr ""
927
 
928
+ #: public/wishlist/buttons.class.php:309, public/wishlist/buttons.class.php:440
929
  msgid "Product %s could not be added to cart because some requirements are not met."
930
  msgid_plural "Products: %s could not be added to cart because some requirements are not met."
931
  msgstr[0] ""
939
  msgid "Remove"
940
  msgstr ""
941
 
942
+ #: public/wishlist/buttons.class.php:494, public/wishlist/view.class.php:497
943
  msgid "&ldquo;%s&rdquo;"
944
  msgstr ""
945
 
946
+ #: public/wishlist/buttons.class.php:507
947
  msgid "%s has been successfully removed from wishlist."
948
  msgid_plural "%s have been successfully removed from wishlist."
949
  msgstr[0] ""
950
  msgstr[1] ""
951
 
952
+ #: public/wishlist/view.class.php:425
953
+ msgid "%1$s by %2$s"
954
+ msgstr ""
955
+
956
+ #: public/wishlist/view.class.php:507
957
  msgid "%s has been removed from wishlist."
958
  msgstr ""
959
 
960
+ #: public/wishlist/view.class.php:509
961
  msgid "%s has not been removed from wishlist."
962
  msgstr ""
963
 
964
+ #: public/wishlist/view.class.php:652
965
  msgid "Return to Wishlist"
966
  msgstr ""
967
 
968
+ #: public/wishlist/view.class.php:773
969
  msgid "Previous Page"
970
  msgstr ""
971
 
972
+ #: public/wishlist/view.class.php:799
973
  msgid "Next Page"
974
  msgstr ""
975
 
1021
  msgid "Select for bulk action"
1022
  msgstr ""
1023
 
1024
+ #: templates/ti-wishlist-user.php:132, templates/ti-wishlist.php:140, tinv-wishlists-function-integration.php:777, tinv-wishlists-function-integration.php:933, tinv-wishlists-function-integration.php:1095, tinv-wishlists-function-integration.php:1309
1025
  msgid "In stock"
1026
  msgstr ""
1027
 
1029
  msgid "Select options"
1030
  msgstr ""
1031
 
1032
+ #: tinv-wishlists-function-integration.php:485
1033
  msgid "Note"
1034
  msgstr ""
1035
 
1036
+ #: tinv-wishlists-function-integration.php:488
1037
  msgid "To"
1038
  msgstr ""
1039
 
1040
+ #: tinv-wishlists-function-integration.php:491
1041
  msgid "To Email"
1042
  msgstr ""
1043
 
1044
+ #: tinv-wishlists-function-integration.php:494
1045
  msgid "Address"
1046
  msgstr ""
1047
 
1048
+ #: tinv-wishlists-function-integration.php:497
1049
  msgid "Reload existing Gift Card"
1050
  msgstr ""
1051
 
1052
+ #: tinv-wishlists-function-integration.php:1248
1053
  msgid "Out of stock"
1054
  msgstr ""
1055
 
1056
+ #: tinv-wishlists-function-integration.php:1657
1057
  msgid "Base price"
1058
  msgstr ""
1059
 
1060
+ #: tinv-wishlists-function-integration.php:2338
1061
  msgid "WooCommerce Wishlist"
1062
  msgstr ""
1063
 
1064
+ #: tinv-wishlists-function-integration.php:2339
1065
  msgid "Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist."
1066
  msgstr ""
1067
 
1068
+ #: tinv-wishlists-function-integration.php:2485
1069
  msgid "Adding Product to Wishlist"
1070
  msgstr ""
1071
 
1072
+ #: tinv-wishlists-function-integration.php:2490, tinv-wishlists-function-integration.php:2535
1073
  msgid "Points"
1074
  msgstr ""
1075
 
1076
+ #: tinv-wishlists-function-integration.php:2503, tinv-wishlists-function-integration.php:2548
1077
  msgid "Limit"
1078
  msgstr ""
1079
 
1080
+ #: tinv-wishlists-function-integration.php:2516, tinv-wishlists-function-integration.php:2561
1081
  msgid "Log Template"
1082
  msgstr ""
1083
 
1084
+ #: tinv-wishlists-function-integration.php:2520, tinv-wishlists-function-integration.php:2565
1085
  msgid "required"
1086
  msgstr ""
1087
 
1088
+ #: tinv-wishlists-function-integration.php:2530
1089
  msgid "Purchasing Product from Wishlist"
1090
  msgstr ""
1091
 
1092
+ #: tinv-wishlists-function-integration.php:2616
1093
  msgid "Purchased From Wishlist"
1094
  msgstr ""
1095
 
1096
+ #: tinv-wishlists-function-integration.php:2617
1097
  msgid "Added To Wishlist"
1098
  msgstr ""
1099
 
public/addtowishlist.class.php CHANGED
@@ -43,6 +43,13 @@ class TInvWL_Public_AddToWishlist {
43
  */
44
  private $wishlist;
45
 
 
 
 
 
 
 
 
46
  /**
47
  * Check is loop button
48
  *
@@ -301,7 +308,6 @@ class TInvWL_Public_AddToWishlist {
301
  } // End if().
302
  $data['status'] = $status;
303
  $data['wishlist_url'] = tinv_url_wishlist_default();
304
- $wishlist_page_id = apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true );
305
 
306
  if ( ! empty( $wishlist ) ) {
307
  $data['wishlist_url'] = tinv_url_wishlist( $wishlist['ID'] );
@@ -341,8 +347,8 @@ class TInvWL_Public_AddToWishlist {
341
  if ( ! empty( $this->user_wishlist ) ) {
342
  return $this->user_wishlist;
343
  }
344
- $wishlists = array();
345
- $wl = new TInvWL_Wishlist( $this->_name );
346
  if ( is_user_logged_in() ) {
347
  $wishlists = $wl->get_by_user_default();
348
  } else {
@@ -376,15 +382,15 @@ class TInvWL_Public_AddToWishlist {
376
  * @return array
377
  */
378
  function user_wishlist( $product, $wlp = null ) {
379
- $wishlists = $this->wishlist = array();
380
- $vproduct = in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ), array(
381
  'variable',
382
  'variation',
383
  'variable-subscription'
384
  ) );
385
- $wlp = new TInvWL_Product();
386
- $wishlists = $this->user_wishlists();
387
- $ids = array();
388
  foreach ( $wishlists as $key => $wishlist ) {
389
  $ids[] = $wishlist['ID'];
390
  }
@@ -393,12 +399,23 @@ class TInvWL_Public_AddToWishlist {
393
  if ( empty( $ids ) ) {
394
  return $wishlists;
395
  }
396
- $products = $wlp->get( array(
397
- 'product_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ),
398
- 'wishlist_id' => $ids,
399
- 'external' => false,
400
- ) );
401
- $in = array();
 
 
 
 
 
 
 
 
 
 
 
402
  if ( ! empty( $products ) ) {
403
  foreach ( $products as $product ) {
404
  $in[ $product['wishlist_id'] ][] = $product['variation_id'];
@@ -609,7 +626,7 @@ class TInvWL_Public_AddToWishlist {
609
 
610
  $content .= sprintf( '<a href="javascript:void(0)" class="tinvwl_add_to_wishlist_button %s" data-tinv-wl-list="%s" data-tinv-wl-product="%s" data-tinv-wl-productvariation="%s" data-tinv-wl-producttype="%s" data-tinv-wl-action="%s" rel="nofollow">%s</a>', $icon, htmlspecialchars( wp_json_encode( $this->wishlist ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->id : ( $this->product->is_type( 'variation' ) ? $this->product->get_parent_id() : $this->product->get_id() ) ), ( ( $this->is_loop && in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->product_type : $this->product->get_type() ), array(
611
  'variable',
612
- 'variable-subscription'
613
  ) ) ) ? $this->variation_id : ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->variation_id : ( $this->product->is_type( 'variation' ) ? $this->product->get_id() : 0 ) ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->product_type : $this->product->get_type() ), $action, $text );
614
  $content .= apply_filters( 'tinvwl_wishlist_button_after', '' );
615
 
43
  */
44
  private $wishlist;
45
 
46
+ /**
47
+ * This wishlist all products
48
+ *
49
+ * @var array
50
+ */
51
+ private $all_products;
52
+
53
  /**
54
  * Check is loop button
55
  *
308
  } // End if().
309
  $data['status'] = $status;
310
  $data['wishlist_url'] = tinv_url_wishlist_default();
 
311
 
312
  if ( ! empty( $wishlist ) ) {
313
  $data['wishlist_url'] = tinv_url_wishlist( $wishlist['ID'] );
347
  if ( ! empty( $this->user_wishlist ) ) {
348
  return $this->user_wishlist;
349
  }
350
+
351
+ $wl = new TInvWL_Wishlist( $this->_name );
352
  if ( is_user_logged_in() ) {
353
  $wishlists = $wl->get_by_user_default();
354
  } else {
382
  * @return array
383
  */
384
  function user_wishlist( $product, $wlp = null ) {
385
+ $this->wishlist = array();
386
+ $vproduct = in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ), array(
387
  'variable',
388
  'variation',
389
  'variable-subscription'
390
  ) );
391
+ $wlp = new TInvWL_Product();
392
+ $wishlists = $this->user_wishlists();
393
+ $ids = array();
394
  foreach ( $wishlists as $key => $wishlist ) {
395
  $ids[] = $wishlist['ID'];
396
  }
399
  if ( empty( $ids ) ) {
400
  return $wishlists;
401
  }
402
+
403
+ if ( ! $this->all_products ) {
404
+ $this->all_products = $wlp->get( array(
405
+ 'wishlist_id' => $ids,
406
+ 'external' => false,
407
+ 'count' => 9999999,
408
+ ) );
409
+ }
410
+
411
+ $products = array();
412
+ foreach ( $this->all_products as $_product ) {
413
+ if ( $_product['product_id'] === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ) ) {
414
+ $products[] = $_product;
415
+ }
416
+ }
417
+
418
+ $in = array();
419
  if ( ! empty( $products ) ) {
420
  foreach ( $products as $product ) {
421
  $in[ $product['wishlist_id'] ][] = $product['variation_id'];
626
 
627
  $content .= sprintf( '<a href="javascript:void(0)" class="tinvwl_add_to_wishlist_button %s" data-tinv-wl-list="%s" data-tinv-wl-product="%s" data-tinv-wl-productvariation="%s" data-tinv-wl-producttype="%s" data-tinv-wl-action="%s" rel="nofollow">%s</a>', $icon, htmlspecialchars( wp_json_encode( $this->wishlist ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->id : ( $this->product->is_type( 'variation' ) ? $this->product->get_parent_id() : $this->product->get_id() ) ), ( ( $this->is_loop && in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->product_type : $this->product->get_type() ), array(
628
  'variable',
629
+ 'variable-subscription',
630
  ) ) ) ? $this->variation_id : ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->variation_id : ( $this->product->is_type( 'variation' ) ? $this->product->get_id() : 0 ) ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->product_type : $this->product->get_type() ), $action, $text );
631
  $content .= apply_filters( 'tinvwl_wishlist_button_after', '' );
632
 
public/cart.class.php CHANGED
@@ -349,7 +349,6 @@ class TInvWL_Public_Cart {
349
  $wishlist = $wl->get_by_share_key( $share_key );
350
  }
351
 
352
-
353
  /* Run a 3rd party code when product purchased from wishlist.
354
  *
355
  * @param WC_order $order Order object.
@@ -443,7 +442,7 @@ class TInvWL_Public_Cart {
443
 
444
  if ( in_array( $new_status, array(
445
  'processing',
446
- 'completed'
447
  ) ) && empty( get_post_meta( $order_id, '_wishlist_analytics_processed', true ) ) ) {
448
 
449
  $items = $order->get_items();
@@ -458,7 +457,7 @@ class TInvWL_Public_Cart {
458
  if ( $_wishlist_cart ) {
459
  $_quantity = absint( $item['qty'] );
460
  if ( is_array( $_wishlist_cart ) ) {
461
- foreach ( $_wishlist_cart as $key => $quantity ) {
462
  if ( 0 >= $_quantity ) {
463
  break;
464
  }
349
  $wishlist = $wl->get_by_share_key( $share_key );
350
  }
351
 
 
352
  /* Run a 3rd party code when product purchased from wishlist.
353
  *
354
  * @param WC_order $order Order object.
442
 
443
  if ( in_array( $new_status, array(
444
  'processing',
445
+ 'completed',
446
  ) ) && empty( get_post_meta( $order_id, '_wishlist_analytics_processed', true ) ) ) {
447
 
448
  $items = $order->get_items();
457
  if ( $_wishlist_cart ) {
458
  $_quantity = absint( $item['qty'] );
459
  if ( is_array( $_wishlist_cart ) ) {
460
+ foreach ( array_keys( $_wishlist_cart ) as $key ) {
461
  if ( 0 >= $_quantity ) {
462
  break;
463
  }
public/tinvwl.class.php CHANGED
@@ -29,6 +29,13 @@ class TInvWL_Public_TInvWL {
29
  * @var string
30
  */
31
  public $_version;
 
 
 
 
 
 
 
32
  /**
33
  * This class
34
  *
@@ -68,8 +75,7 @@ class TInvWL_Public_TInvWL {
68
  * Create all object and shortcode
69
  */
70
  function pre_load_function() {
71
- add_action( 'init', array( $this, 'apply_rewrite_rules' ), 0 );
72
- add_action( 'init', array( $this, 'add_rewrite_rules' ), 0 );
73
 
74
  add_filter( 'rewrite_rules_array', array( $this, 'add_rewrite_rules_raw' ), 9999999 );
75
 
@@ -97,22 +103,20 @@ class TInvWL_Public_TInvWL {
97
  * @return mixed
98
  */
99
  function add_rewrite_rules_raw( $rules ) {
100
-
101
  if ( tinv_get_option( 'permalinks', 'force' ) ) {
102
- $rules = $this->rules_raw + $rules;
 
103
  }
104
 
105
  return $rules;
106
  }
107
 
108
-
109
  /**
110
  * Define hooks
111
  */
112
  function define_hooks() {
113
  if ( tinv_get_option( 'social', 'facebook' ) || tinv_get_option( 'social', 'google' ) ) {
114
  add_filter( 'language_attributes', array( $this, 'add_ogp' ), 100 );
115
- add_action( 'wp_head', array( $this, 'add_meta_tags' ), 0 );
116
  }
117
 
118
  if ( tinv_get_option( 'general', 'link_in_myaccount' ) ) {
@@ -140,13 +144,9 @@ class TInvWL_Public_TInvWL {
140
  if ( empty( $product_id ) ) {
141
  return false;
142
  }
143
- $wishlist = tinv_wishlist_get();
144
- $wlp = null;
145
- if ( 0 === $wishlist['ID'] ) {
146
- $wlp = TInvWL_Product_Local::instance();
147
- } else {
148
- $wlp = new TInvWL_Product( $wishlist );
149
- }
150
  $items = $wlp->get( array( 'ID' => $product_id ) );
151
  $item = array_shift( $items );
152
  if ( empty( $item ) ) {
@@ -155,6 +155,8 @@ class TInvWL_Public_TInvWL {
155
  if ( empty( $item['data'] ) ) {
156
  return false;
157
  }
 
 
158
  $wla = new TInvWL_Analytics( $wishlist, $this->_name );
159
  if ( $wishlist['is_owner'] ) {
160
  $wla->click_author_product_from_wl( $item['product_id'], $item['variation_id'] );
@@ -218,24 +220,21 @@ class TInvWL_Public_TInvWL {
218
  * Update rewrite url for wishlist
219
  */
220
  public static function update_rewrite_rules() {
221
- set_transient( '_tinvwl_rewrite_rules', 1, 30 );
222
  }
223
 
224
  /**
225
  * Apply rewrite url for wishlist
226
  */
227
- function apply_rewrite_rules() {
228
- if ( ! get_transient( '_tinvwl_rewrite_rules' ) ) {
229
- return;
230
- }
231
- delete_transient( '_tinvwl_rewrite_rules' );
232
  flush_rewrite_rules();
233
  }
234
 
235
  /**
236
  * Create rewrite url for wishlist
237
  */
238
- function add_rewrite_rules() {
239
  $id = tinv_get_option( 'page', 'wishlist' );
240
  $pages = array( $id );
241
  $language_codes = array();
@@ -266,26 +265,29 @@ class TInvWL_Public_TInvWL {
266
 
267
  if ( $language_codes && defined( 'POLYLANG_VERSION' ) ) {
268
  add_rewrite_rule( '^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]', 'top' );
269
- $this->rules_raw[ '^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$' ] = 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]';
270
  add_rewrite_rule( '^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]', 'top' );
271
- $this->rules_raw[ '^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$' ] = 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]';
272
  }
273
 
274
  // Wishlist on frontpage.
275
  $page_on_front = absint( get_option( 'page_on_front' ) );
276
  if ( $page_on_front && 'page' === get_option( 'show_on_front' ) && $page->ID === $page_on_front ) {
277
- add_filter( 'redirect_canonical', array( $this, 'disable_canonical_redirect_for_front_page' ) );
 
 
 
278
  // Match the front page and pass item value as a query var.
279
  add_rewrite_rule( '^([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[1]', 'top' );
280
- $this->rules_raw['^([A-Fa-f0-9]{6})?/{0,1}$'] = 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[1]';
281
  add_rewrite_rule( '^([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[3]&wl_paged=$matches[4]', 'top' );
282
- $this->rules_raw['^([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$'] = 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[3]&wl_paged=$matches[4]';
283
  }
284
 
285
  add_rewrite_rule( '(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]&wl_paged=$matches[4]', 'top' );
286
- $this->rules_raw[ '(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$' ] = 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]&wl_paged=$matches[4]';
287
  add_rewrite_rule( '(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]', 'top' );
288
- $this->rules_raw[ '(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$' ] = 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]';
289
 
290
  // Wishlist on shop page.
291
  $shop_page_id = wc_get_page_id( 'shop' );
@@ -293,11 +295,11 @@ class TInvWL_Public_TInvWL {
293
  $shop = get_post( $shop_page_id );
294
  $shop_slug = $shop->post_name;
295
  add_rewrite_rule( '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?post_type=product&tinvwlID=$matches[3]', 'top' );
296
- $this->rules_raw[ '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$' ] = 'index.php?post_type=product&tinvwlID=$matches[3]';
297
  add_rewrite_rule( '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?post_type=product&tinvwlID=$matches[3]&wl_paged=$matches[4]', 'top' );
298
- $this->rules_raw[ '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$' ] = 'index.php?post_type=product&tinvwlID=$matches[3]&wl_paged=$matches[4]';
299
  add_rewrite_rule( '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/page/([0-9]{1,})/{0,1}$', 'index.php?post_type=product&tinvwlID=$matches[3]&paged=$matches[4]', 'top' );
300
- $this->rules_raw[ '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/page/([0-9]{1,})/{0,1}$' ] = 'index.php?post_type=product&tinvwlID=$matches[3]&paged=$matches[4]';
301
  }
302
  }
303
  }
@@ -310,7 +312,7 @@ class TInvWL_Public_TInvWL {
310
  *
311
  * @return bool
312
  */
313
- public function disable_canonical_redirect_for_front_page( $redirect ) {
314
  $page_on_front = absint( get_option( 'page_on_front' ) );
315
  if ( is_page() && 'page' === get_option( 'show_on_front' ) && $page_on_front ) {
316
  if ( is_page( $page_on_front ) ) {
@@ -331,80 +333,12 @@ class TInvWL_Public_TInvWL {
331
  function add_query_var( $public_var ) {
332
  $public_var[] = 'tinvwlID';
333
  $public_var[] = 'tiws';
 
334
  $public_var[] = 'wl_paged';
335
 
336
  return $public_var;
337
  }
338
 
339
- /**
340
- * Create social meta tags
341
- */
342
- function add_meta_tags() {
343
- if ( is_page( apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ) ) && ( tinv_get_option( 'social', 'facebook' ) || tinv_get_option( 'social', 'google' ) ) ) {
344
- $wishlist = tinv_wishlist_get( '', false );
345
- if ( $wishlist && 0 < $wishlist['ID'] && 'private' !== $wishlist['status'] ) {
346
- if ( is_user_logged_in() ) {
347
- $user = get_user_by( 'id', $wishlist['author'] );
348
- if ( $user ) {
349
- $user_name = trim( sprintf( '%s %s', $user->user_firstname, $user->user_lastname ) );
350
- $user = @$user->display_name; // @codingStandardsIgnoreLine Generic.PHP.NoSilencedErrors.Discouraged
351
- } else {
352
- $user_name = '';
353
- $user = '';
354
- }
355
- } else {
356
- $user_name = '';
357
- $user = '';
358
- }
359
-
360
- $wlp = new TInvWL_Product( $wishlist );
361
- $products = $wlp->get_wishlist( array(
362
- 'count' => 999999,
363
- 'order_by' => 'date',
364
- 'order' => 'DESC',
365
- ) );
366
- $products_title = array();
367
- foreach ( $products as $product ) {
368
- if ( ! empty( $product ) && ! empty( $product['data'] ) ) {
369
- $title = $product['data']->get_title();
370
- if ( ! in_array( $title, $products_title ) ) {
371
- $products_title[] = $title;
372
- }
373
- }
374
- }
375
- $product = array_shift( $products );
376
- $image = '';
377
- if ( ! empty( $product ) && ! empty( $product['data'] ) ) {
378
- list( $image, $width, $height, $is_intermediate ) = wp_get_attachment_image_src( $product['data']->get_image_id(), 'full' );
379
- }
380
-
381
- $meta = apply_filters( 'tinvwl_social_header_meta', array(
382
- 'url' => tinv_url_wishlist( $wishlist['share_key'] ),
383
- 'type' => 'product.group',
384
- 'title' => sprintf( __( '%1$s by %2$s', 'ti-woocommerce-wishlist' ), $wishlist['title'], ( empty( $user_name ) ? $user : $user_name ) ),
385
- 'description' => implode( ', ', $products_title ),
386
- 'image' => $image,
387
- ) );
388
- if ( tinv_get_option( 'social', 'facebook' ) ) {
389
- foreach ( $meta as $name => $content ) {
390
- echo sprintf( '<meta property="og:%s" content="%s" />', esc_attr( $name ), esc_attr( $content ) );
391
- }
392
- echo "\n";
393
- }
394
- if ( tinv_get_option( 'social', 'google' ) ) {
395
- unset( $meta['url'], $meta['type'] );
396
- foreach ( $meta as $name => $content ) {
397
- if ( 'title' === $name ) {
398
- $name = 'name';
399
- }
400
- echo sprintf( '<meta itemprop="%s" content="%s">', esc_attr( $name ), esc_attr( $content ) );
401
- }
402
- echo "\n";
403
- }
404
- } // End if().
405
- } // End if().
406
- }
407
-
408
  /**
409
  * Create ogp namespace
410
  *
@@ -537,7 +471,7 @@ class TInvWL_Public_TInvWL {
537
  wp_register_script( $this->_name, TINVWL_URL . 'assets/js/public' . $suffix . '.js', array(
538
  'jquery',
539
  version_compare( WC_VERSION, '3.0.0', '<' ) ? 'jquery-cookie' : 'js-cookie',
540
- apply_filters( 'tinvwl-wc-cart-fragments', true ) ? 'wc-cart-fragments' : 'jquery'
541
  ), $this->_version, true );
542
  wp_localize_script( $this->_name, 'tinvwl_add_to_wishlist', array(
543
  'text_create' => __( 'Create New', 'ti-woocommerce-wishlist' ),
29
  * @var string
30
  */
31
  public $_version;
32
+
33
+ /**
34
+ * Raw rewrites
35
+ *
36
+ * @var array
37
+ */
38
+ public static $rules_raw;
39
  /**
40
  * This class
41
  *
75
  * Create all object and shortcode
76
  */
77
  function pre_load_function() {
78
+ add_action( 'tinvwl_flush_rewrite_rules', array( __CLASS__, 'apply_rewrite_rules' ) );
 
79
 
80
  add_filter( 'rewrite_rules_array', array( $this, 'add_rewrite_rules_raw' ), 9999999 );
81
 
103
  * @return mixed
104
  */
105
  function add_rewrite_rules_raw( $rules ) {
 
106
  if ( tinv_get_option( 'permalinks', 'force' ) ) {
107
+ self::add_rewrite_rules();
108
+ $rules = self::$rules_raw + $rules;
109
  }
110
 
111
  return $rules;
112
  }
113
 
 
114
  /**
115
  * Define hooks
116
  */
117
  function define_hooks() {
118
  if ( tinv_get_option( 'social', 'facebook' ) || tinv_get_option( 'social', 'google' ) ) {
119
  add_filter( 'language_attributes', array( $this, 'add_ogp' ), 100 );
 
120
  }
121
 
122
  if ( tinv_get_option( 'general', 'link_in_myaccount' ) ) {
144
  if ( empty( $product_id ) ) {
145
  return false;
146
  }
147
+
148
+ $wlp = new TInvWL_Product();
149
+
 
 
 
 
150
  $items = $wlp->get( array( 'ID' => $product_id ) );
151
  $item = array_shift( $items );
152
  if ( empty( $item ) ) {
155
  if ( empty( $item['data'] ) ) {
156
  return false;
157
  }
158
+ $wishlist = tinv_wishlist_get( $item['wishlist_id'] );
159
+
160
  $wla = new TInvWL_Analytics( $wishlist, $this->_name );
161
  if ( $wishlist['is_owner'] ) {
162
  $wla->click_author_product_from_wl( $item['product_id'], $item['variation_id'] );
220
  * Update rewrite url for wishlist
221
  */
222
  public static function update_rewrite_rules() {
223
+ wp_schedule_single_event( time(), 'tinvwl_flush_rewrite_rules' );
224
  }
225
 
226
  /**
227
  * Apply rewrite url for wishlist
228
  */
229
+ public static function apply_rewrite_rules() {
230
+ self::add_rewrite_rules();
 
 
 
231
  flush_rewrite_rules();
232
  }
233
 
234
  /**
235
  * Create rewrite url for wishlist
236
  */
237
+ public static function add_rewrite_rules() {
238
  $id = tinv_get_option( 'page', 'wishlist' );
239
  $pages = array( $id );
240
  $language_codes = array();
265
 
266
  if ( $language_codes && defined( 'POLYLANG_VERSION' ) ) {
267
  add_rewrite_rule( '^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]', 'top' );
268
+ self::$rules_raw[ '^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$' ] = 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]';
269
  add_rewrite_rule( '^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]', 'top' );
270
+ self::$rules_raw[ '^(' . $language_codes . ')/(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$' ] = 'index.php?pagename=$matches[2]&tinvwlID=$matches[4]&wl_paged=$matches[5]&lang=$matches[1]';
271
  }
272
 
273
  // Wishlist on frontpage.
274
  $page_on_front = absint( get_option( 'page_on_front' ) );
275
  if ( $page_on_front && 'page' === get_option( 'show_on_front' ) && $page->ID === $page_on_front ) {
276
+ add_filter( 'redirect_canonical', array(
277
+ 'TInvWL_Public_TInvWL',
278
+ 'disable_canonical_redirect_for_front_page',
279
+ ) );
280
  // Match the front page and pass item value as a query var.
281
  add_rewrite_rule( '^([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[1]', 'top' );
282
+ self::$rules_raw['^([A-Fa-f0-9]{6})?/{0,1}$'] = 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[1]';
283
  add_rewrite_rule( '^([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[3]&wl_paged=$matches[4]', 'top' );
284
+ self::$rules_raw['^([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$'] = 'index.php?page_id=' . $page_on_front . '&tinvwlID=$matches[3]&wl_paged=$matches[4]';
285
  }
286
 
287
  add_rewrite_rule( '(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]&wl_paged=$matches[4]', 'top' );
288
+ self::$rules_raw[ '(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$' ] = 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]&wl_paged=$matches[4]';
289
  add_rewrite_rule( '(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]', 'top' );
290
+ self::$rules_raw[ '(([^/]+/)*' . $page_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$' ] = 'index.php?pagename=$matches[1]&tinvwlID=$matches[3]';
291
 
292
  // Wishlist on shop page.
293
  $shop_page_id = wc_get_page_id( 'shop' );
295
  $shop = get_post( $shop_page_id );
296
  $shop_slug = $shop->post_name;
297
  add_rewrite_rule( '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$', 'index.php?post_type=product&tinvwlID=$matches[3]', 'top' );
298
+ self::$rules_raw[ '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/{0,1}$' ] = 'index.php?post_type=product&tinvwlID=$matches[3]';
299
  add_rewrite_rule( '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$', 'index.php?post_type=product&tinvwlID=$matches[3]&wl_paged=$matches[4]', 'top' );
300
+ self::$rules_raw[ '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/wl_page/([0-9]{1,})/{0,1}$' ] = 'index.php?post_type=product&tinvwlID=$matches[3]&wl_paged=$matches[4]';
301
  add_rewrite_rule( '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/page/([0-9]{1,})/{0,1}$', 'index.php?post_type=product&tinvwlID=$matches[3]&paged=$matches[4]', 'top' );
302
+ self::$rules_raw[ '(([^/]+/)*' . $shop_slug . ')/([A-Fa-f0-9]{6})?/page/([0-9]{1,})/{0,1}$' ] = 'index.php?post_type=product&tinvwlID=$matches[3]&paged=$matches[4]';
303
  }
304
  }
305
  }
312
  *
313
  * @return bool
314
  */
315
+ public static function disable_canonical_redirect_for_front_page( $redirect ) {
316
  $page_on_front = absint( get_option( 'page_on_front' ) );
317
  if ( is_page() && 'page' === get_option( 'show_on_front' ) && $page_on_front ) {
318
  if ( is_page( $page_on_front ) ) {
333
  function add_query_var( $public_var ) {
334
  $public_var[] = 'tinvwlID';
335
  $public_var[] = 'tiws';
336
+ $public_var[] = 'tiwp';
337
  $public_var[] = 'wl_paged';
338
 
339
  return $public_var;
340
  }
341
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
  /**
343
  * Create ogp namespace
344
  *
471
  wp_register_script( $this->_name, TINVWL_URL . 'assets/js/public' . $suffix . '.js', array(
472
  'jquery',
473
  version_compare( WC_VERSION, '3.0.0', '<' ) ? 'jquery-cookie' : 'js-cookie',
474
+ apply_filters( 'tinvwl-wc-cart-fragments', true ) ? 'wc-cart-fragments' : 'jquery',
475
  ), $this->_version, true );
476
  wp_localize_script( $this->_name, 'tinvwl_add_to_wishlist', array(
477
  'text_create' => __( 'Create New', 'ti-woocommerce-wishlist' ),
public/widget/topwishlist.class.php CHANGED
@@ -1,69 +1,69 @@
1
- <?php
2
- /**
3
- * Widget "Popular product"
4
- *
5
- * @since 1.0.0
6
- * @package TInvWishlist\Widget
7
- */
8
-
9
- // If this file is called directly, abort.
10
- if ( ! defined( 'ABSPATH' ) ) {
11
- die;
12
- }
13
-
14
- /**
15
- * Widget "Popular product"
16
- */
17
- class TInvWL_Public_Widget_Topwishlist extends WC_Widget {
18
-
19
- /**
20
- * Constructor.
21
- */
22
- public function __construct() {
23
- $this->widget_cssclass = 'tinvwl widget_wishlist_products_counter';
24
- $this->widget_description = __( 'Displays the number of products in the wishlist on your site.', 'ti-woocommerce-wishlist' );
25
- $this->widget_id = 'widget_top_wishlist';
26
- $this->widget_name = __( 'TI Wishlist Products Counter', 'ti-woocommerce-wishlist' );
27
- $this->settings = array(
28
- 'show_icon' => array(
29
- 'type' => 'checkbox',
30
- 'std' => ( (bool) tinv_get_option( 'topline', 'icon' ) ) ? 1 : 0,
31
- 'label' => __( 'Show counter icon', 'ti-woocommerce-wishlist' ),
32
- ),
33
- 'show_text' => array(
34
- 'type' => 'checkbox',
35
- 'std' => tinv_get_option( 'topline', 'show_text' ) ? 1 : 0,
36
- 'label' => __( 'Show counter text', 'ti-woocommerce-wishlist' ),
37
- ),
38
- 'text' => array(
39
- 'type' => 'text',
40
- 'std' => apply_filters( 'tinvwl-topline-text', tinv_get_option( 'topline', 'text' ) ),
41
- 'label' => __( 'Counter Text', 'ti-woocommerce-wishlist' ),
42
- ),
43
- );
44
-
45
- parent::__construct();
46
- }
47
-
48
- /**
49
- * Output widget.
50
- *
51
- * @param array $args Artguments.
52
- * @param array $instance Instance.
53
- */
54
- public function widget( $args, $instance ) {
55
- global $wpdb;
56
- if ( $this->get_cached_widget( $args ) ) {
57
- return;
58
- }
59
- $this->widget_start( $args, $instance );
60
- $content = tinvwl_shortcode_products_counter( array(
61
- 'show_icon' => isset( $instance['show_icon'] ) ? absint( $instance['show_icon'] ) : $this->settings['show_icon']['std'],
62
- 'show_text' => isset( $instance['show_text'] ) ? absint( $instance['show_text'] ) : $this->settings['show_text']['std'],
63
- 'text' => isset( $instance['text'] ) ? $instance['text'] : $this->settings['text']['std'],
64
- ) );
65
- echo $content; // WPCS: xss ok.
66
- $this->widget_end( $args, $instance );
67
- $this->cache_widget( $args, $content );
68
- }
69
- }
1
+ <?php
2
+ /**
3
+ * Widget "Popular product"
4
+ *
5
+ * @since 1.0.0
6
+ * @package TInvWishlist\Widget
7
+ */
8
+
9
+ // If this file is called directly, abort.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ die;
12
+ }
13
+
14
+ /**
15
+ * Widget "Popular product"
16
+ */
17
+ class TInvWL_Public_Widget_Topwishlist extends WC_Widget {
18
+
19
+ /**
20
+ * Constructor.
21
+ */
22
+ public function __construct() {
23
+ $this->widget_cssclass = 'tinvwl widget_wishlist_products_counter';
24
+ $this->widget_description = __( 'Displays the number of products in the wishlist on your site.', 'ti-woocommerce-wishlist' );
25
+ $this->widget_id = 'widget_top_wishlist';
26
+ $this->widget_name = __( 'TI Wishlist Products Counter', 'ti-woocommerce-wishlist' );
27
+ $this->settings = array(
28
+ 'show_icon' => array(
29
+ 'type' => 'checkbox',
30
+ 'std' => ( (bool) tinv_get_option( 'topline', 'icon' ) ) ? 1 : 0,
31
+ 'label' => __( 'Show counter icon', 'ti-woocommerce-wishlist' ),
32
+ ),
33
+ 'show_text' => array(
34
+ 'type' => 'checkbox',
35
+ 'std' => tinv_get_option( 'topline', 'show_text' ) ? 1 : 0,
36
+ 'label' => __( 'Show counter text', 'ti-woocommerce-wishlist' ),
37
+ ),
38
+ 'text' => array(
39
+ 'type' => 'text',
40
+ 'std' => apply_filters( 'tinvwl-topline-text', tinv_get_option( 'topline', 'text' ) ),
41
+ 'label' => __( 'Counter Text', 'ti-woocommerce-wishlist' ),
42
+ ),
43
+ );
44
+
45
+ parent::__construct();
46
+ }
47
+
48
+ /**
49
+ * Output widget.
50
+ *
51
+ * @param array $args Artguments.
52
+ * @param array $instance Instance.
53
+ */
54
+ public function widget( $args, $instance ) {
55
+
56
+ if ( $this->get_cached_widget( $args ) ) {
57
+ return;
58
+ }
59
+ $this->widget_start( $args, $instance );
60
+ $content = tinvwl_shortcode_products_counter( array(
61
+ 'show_icon' => isset( $instance['show_icon'] ) ? absint( $instance['show_icon'] ) : $this->settings['show_icon']['std'],
62
+ 'show_text' => isset( $instance['show_text'] ) ? absint( $instance['show_text'] ) : $this->settings['show_text']['std'],
63
+ 'text' => isset( $instance['text'] ) ? $instance['text'] : $this->settings['text']['std'],
64
+ ) );
65
+ echo $content; // WPCS: xss ok.
66
+ $this->widget_end( $args, $instance );
67
+ $this->cache_widget( $args, $content );
68
+ }
69
+ }
public/wishlist/buttons.class.php CHANGED
@@ -65,11 +65,11 @@ class TInvWL_Public_Wishlist_Buttons {
65
  );
66
  add_filter( self::$_name . '_prepare_attr__button_product_apply', array(
67
  __CLASS__,
68
- 'add_break_class_input'
69
  ) );
70
  add_filter( self::$_name . '_prepare_attr__button_product_apply', array(
71
  __CLASS__,
72
- 'add_break_class_checkbox'
73
  ) );
74
  }
75
  if ( tinv_get_option( 'table', 'colm_checkbox' ) && tinv_get_option( 'table', 'add_select_to_cart' ) ) {
@@ -81,7 +81,7 @@ class TInvWL_Public_Wishlist_Buttons {
81
  );
82
  add_filter( self::$_name . '_prepare_attr__button_product_selected', array(
83
  __CLASS__,
84
- 'add_break_class_checkbox'
85
  ) );
86
  }
87
  if ( tinv_get_option( 'table', 'add_all_to_cart' ) ) {
@@ -341,7 +341,7 @@ class TInvWL_Public_Wishlist_Buttons {
341
  $options['add_selected'] = apply_filters( 'tinvwl-product_table-text_add_to_cart', tinv_get_option( 'product_table', 'text_add_to_cart' ) );
342
  }
343
 
344
- $wishlist_curent = tinv_wishlist_get();
345
  if ( $wishlist_curent['is_owner'] ) {
346
  $options['remove'] = __( 'Remove', 'ti-woocommerce-wishlist' );
347
  }
@@ -413,7 +413,6 @@ class TInvWL_Public_Wishlist_Buttons {
413
  $redirect_url = $product_data->add_to_cart_url();
414
  remove_filter( 'clean_url', 'tinvwl_clean_url', 10 );
415
 
416
-
417
  // restore global product data.
418
  $product = $_product_tmp;
419
 
@@ -499,11 +498,11 @@ class TInvWL_Public_Wishlist_Buttons {
499
  if ( ! empty( $titles ) ) {
500
  add_action( 'tinvwl_before_wishlist', array(
501
  'TInvWL_Public_Wishlist_View',
502
- 'check_cart_hash'
503
  ), 99, 1 );
504
  add_action( 'woocommerce_set_cart_cookies', array(
505
  'TInvWL_Public_Wishlist_View',
506
- 'reset_cart_hash'
507
  ), 199, 1 );
508
  wc_add_notice( sprintf( _n( '%s has been successfully removed from wishlist.', '%s have been successfully removed from wishlist.', count( $titles ), 'ti-woocommerce-wishlist' ), wc_format_list_of_items( $titles ) ) );
509
  }
65
  );
66
  add_filter( self::$_name . '_prepare_attr__button_product_apply', array(
67
  __CLASS__,
68
+ 'add_break_class_input',
69
  ) );
70
  add_filter( self::$_name . '_prepare_attr__button_product_apply', array(
71
  __CLASS__,
72
+ 'add_break_class_checkbox',
73
  ) );
74
  }
75
  if ( tinv_get_option( 'table', 'colm_checkbox' ) && tinv_get_option( 'table', 'add_select_to_cart' ) ) {
81
  );
82
  add_filter( self::$_name . '_prepare_attr__button_product_selected', array(
83
  __CLASS__,
84
+ 'add_break_class_checkbox',
85
  ) );
86
  }
87
  if ( tinv_get_option( 'table', 'add_all_to_cart' ) ) {
341
  $options['add_selected'] = apply_filters( 'tinvwl-product_table-text_add_to_cart', tinv_get_option( 'product_table', 'text_add_to_cart' ) );
342
  }
343
 
344
+ $wishlist_curent = TInvWL_Public_Wishlist_View::instance()->get_current_wishlist();
345
  if ( $wishlist_curent['is_owner'] ) {
346
  $options['remove'] = __( 'Remove', 'ti-woocommerce-wishlist' );
347
  }
413
  $redirect_url = $product_data->add_to_cart_url();
414
  remove_filter( 'clean_url', 'tinvwl_clean_url', 10 );
415
 
 
416
  // restore global product data.
417
  $product = $_product_tmp;
418
 
498
  if ( ! empty( $titles ) ) {
499
  add_action( 'tinvwl_before_wishlist', array(
500
  'TInvWL_Public_Wishlist_View',
501
+ 'check_cart_hash',
502
  ), 99, 1 );
503
  add_action( 'woocommerce_set_cart_cookies', array(
504
  'TInvWL_Public_Wishlist_View',
505
+ 'reset_cart_hash',
506
  ), 199, 1 );
507
  wc_add_notice( sprintf( _n( '%s has been successfully removed from wishlist.', '%s have been successfully removed from wishlist.', count( $titles ), 'ti-woocommerce-wishlist' ), wc_format_list_of_items( $titles ) ) );
508
  }
public/wishlist/social.class.php CHANGED
@@ -42,29 +42,10 @@ class TInvWL_Public_Wishlist_Social {
42
  return false;
43
  }
44
 
45
- self::prepare( $wishlist );
46
- self::htmloutput( $wishlist );
47
- }
48
 
49
- /**
50
- * Prepare data for social buttons
51
- *
52
- * @param array $wishlist Set from action.
53
- */
54
- public static function prepare( $wishlist ) {
55
- self::$url = tinv_url_wishlist( $wishlist['share_key'] );
56
- $wlp = new TInvWL_Product( $wishlist );
57
- $products = $wlp->get_wishlist( array(
58
- 'count' => 1,
59
- 'order_by' => 'date',
60
- 'order' => 'DESC',
61
- ) );
62
- $product = array_shift( $products );
63
- self::$image = '';
64
- if ( ! empty( $product ) && ! empty( $product['data'] ) ) {
65
- list( $url, $width, $height, $is_intermediate ) = wp_get_attachment_image_src( $product['data']->get_image_id(), 'full' );
66
- self::$image = $url;
67
- }
68
  }
69
 
70
  /**
42
  return false;
43
  }
44
 
45
+ self::$image = TInvWL_Public_Wishlist_View::instance()->social_image;
46
+ self::$url = TInvWL_Public_Wishlist_View::instance()->wishlist_url;
 
47
 
48
+ self::htmloutput( $wishlist );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
 
51
  /**
public/wishlist/view.class.php CHANGED
@@ -1,693 +1,849 @@
1
- <?php
2
- /**
3
- * Wishlist shortcode
4
- *
5
- * @since 1.0.0
6
- * @package TInvWishlist\Public
7
- */
8
-
9
- // If this file is called directly, abort.
10
- if ( ! defined( 'ABSPATH' ) ) {
11
- die;
12
- }
13
-
14
- /**
15
- * Wishlist shortcode
16
- */
17
- class TInvWL_Public_Wishlist_View {
18
-
19
- /**
20
- * Plugin name
21
- *
22
- * @var string
23
- */
24
- private $_name;
25
-
26
- /**
27
- * List per page
28
- *
29
- * @var integer
30
- */
31
- private $lists_per_page;
32
-
33
- /**
34
- * Current wishlist
35
- *
36
- * @var array
37
- */
38
- private $current_wishlist;
39
- /**
40
- * This class
41
- *
42
- * @var \TInvWL_Public_Wishlist_View
43
- */
44
- protected static $_instance = null;
45
-
46
- /**
47
- * Get this class object
48
- *
49
- * @param string $plugin_name Plugin name.
50
- *
51
- * @return \TInvWL_Public_Wishlist_View
52
- */
53
- public static function instance( $plugin_name = TINVWL_PREFIX ) {
54
- if ( is_null( self::$_instance ) ) {
55
- self::$_instance = new self( $plugin_name );
56
- }
57
-
58
- return self::$_instance;
59
- }
60
-
61
- /**
62
- * Constructor
63
- *
64
- * @param string $plugin_name Plugin name.
65
- */
66
- function __construct( $plugin_name ) {
67
- $this->_name = $plugin_name;
68
- $this->define_hooks();
69
- }
70
-
71
- /**
72
- * Defined shortcode and hooks
73
- */
74
- function define_hooks() {
75
- add_action( 'template_redirect', array( $this, 'login_redirect' ) );
76
-
77
- add_action( 'wp_loaded', array( $this, 'login_post_redirect' ), 19 );
78
-
79
- add_action( 'wp', array( $this, 'wishlist_action' ), 0 );
80
-
81
- add_action( 'tinvwl_before_wishlist', array( $this, 'wishlist_header' ) );
82
-
83
- add_action( 'tinvwl_after_wishlist', array( 'TInvWL_Public_Wishlist_Social', 'init' ) );
84
-
85
- add_filter( 'tinvwl_wishlist_item_action_add_to_cart', array( $this, 'product_allow_add_to_cart' ), 10, 3 );
86
- add_filter( 'tinvwl_wishlist_item_add_to_cart', array( $this, 'external_text' ), 10, 3 );
87
- add_filter( 'tinvwl_wishlist_item_add_to_cart', array( $this, 'variable_text' ), 10, 3 );
88
- add_action( 'tinvwl_after_wishlist_table', array( $this, 'get_per_page' ) );
89
-
90
- TInvWL_Public_Wishlist_Buttons::init( $this->_name );
91
- }
92
-
93
- /**
94
- * Redirect back after successful login.
95
- */
96
- public function login_post_redirect() {
97
- $nonce_value = isset( $_REQUEST['woocommerce-login-nonce'] ) ? $_REQUEST['woocommerce-login-nonce'] : ( isset( $_REQUEST['_wpnonce'] ) ? $_REQUEST['_wpnonce'] : '' );
98
- if ( ! empty( $_POST['login'] ) && wp_verify_nonce( $nonce_value, 'woocommerce-login' ) && ! empty( $_GET['tinvwl_redirect'] ) ) {
99
- $_POST['redirect'] = $_GET['tinvwl_redirect']; // Force WC Login form handler to do redirect.
100
- }
101
- }
102
-
103
- /**
104
- * Redirect guests to login page.
105
- */
106
- public function login_redirect() {
107
- if ( ! wc_get_page_id( 'myaccount' ) && is_page( apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ) ) && ! is_user_logged_in() && tinv_get_option( 'general', 'require_login' ) ) {
108
- $full_link = get_permalink();
109
- $share_key = get_query_var( 'tinvwlID', null );
110
- if ( ! empty( $share_key ) ) {
111
- if ( get_option( 'permalink_structure' ) ) {
112
- if ( ! preg_match( '/\/$/', $full_link ) ) {
113
- $full_link .= '/';
114
- }
115
- $full_link .= $share_key . '/';
116
- } else {
117
- $full_link = add_query_arg( 'tinvwlID', $share_key, $full_link );
118
- }
119
- }
120
-
121
- wp_safe_redirect( add_query_arg( 'tinvwl_redirect', esc_url( $full_link ), wc_get_page_permalink( 'myaccount' ) ) );
122
- exit;
123
- }
124
- }
125
-
126
- /**
127
- * Change Text for external product
128
- *
129
- * @param string $text Text for button add to cart.
130
- * @param array $wl_product Wishlist Product.
131
- * @param WC_Product $_product Product.
132
- *
133
- * @return string
134
- */
135
- function external_text( $text, $wl_product, $_product ) {
136
- global $product;
137
- // store global product data.
138
- $_product_tmp = $product;
139
- // override global product data.
140
- $product = $_product;
141
-
142
- if ( 'external' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ) ) {
143
-
144
- $text = $product->single_add_to_cart_text();
145
-
146
- // restore global product data.
147
- $product = $_product_tmp;
148
- }
149
-
150
- return $text;
151
- }
152
-
153
- /**
154
- * Change Text for variable product that requires to select some variations.
155
- *
156
- * @param string $text Text for button add to cart.
157
- * @param array $wl_product Wishlist Product.
158
- * @param WC_Product $_product Product.
159
- *
160
- * @return string
161
- */
162
- function variable_text( $text, $wl_product, $_product ) {
163
- global $product;
164
- // store global product data.
165
- $_product_tmp = $product;
166
- // override global product data.
167
- $product = $_product;
168
- if ( apply_filters( 'tinvwl_product_add_to_cart_need_redirect', false, $product, $product->get_permalink(), $wl_product )
169
- && in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ), array(
170
- 'variable',
171
- 'variable-subscription'
172
- ) ) ) {
173
-
174
- $text = $product->add_to_cart_text();
175
-
176
- // restore global product data.
177
- $product = $_product_tmp;
178
- }
179
-
180
- return $text;
181
- }
182
-
183
- /**
184
- * Get current wishlist
185
- *
186
- * @return array
187
- */
188
- function get_current_wishlist() {
189
- if ( empty( $this->current_wishlist ) ) {
190
- $this->current_wishlist = apply_filters( 'tinvwl_get_current_wishlist', tinv_wishlist_get() );
191
- }
192
-
193
- return $this->current_wishlist;
194
- }
195
-
196
- /**
197
- * Get current products from wishlist
198
- *
199
- * @param array $wishlist Wishlist object.
200
- * @param boolean $external Get woocommerce product info.
201
- * @param integer $lists_per_page Count per page.
202
- *
203
- * @return array
204
- */
205
- function get_current_products( $wishlist = null, $external = true, $lists_per_page = 10 ) {
206
- if ( empty( $wishlist ) ) {
207
- $wishlist = $this->get_current_wishlist();
208
- }
209
- $wlp = null;
210
- if ( isset( $wishlist['ID'] ) && 0 === $wishlist['ID'] ) {
211
- $wlp = TInvWL_Product_Local::instance();
212
- } else {
213
- $wlp = new TInvWL_Product( $wishlist );
214
- }
215
- if ( empty( $wlp ) ) {
216
- return array();
217
- }
218
-
219
- $paged = get_query_var( 'wl_paged', 1 );
220
- $paged = 1 < $paged ? $paged : 1;
221
-
222
- $product_data = array(
223
- 'count' => $lists_per_page,
224
- 'offset' => $lists_per_page * ( $paged - 1 ),
225
- 'external' => $external,
226
- 'order_by' => 'date',
227
- 'order' => 'DESC',
228
- );
229
- $pages = ceil( count( $wlp->get_wishlist( array(
230
- 'count' => 9999999,
231
- 'external' => false,
232
- ) ) ) / absint( $lists_per_page ) );
233
-
234
- if ( 1 < $paged ) {
235
- add_action( 'tinvwl_pagenation_wishlist', array( $this, 'page_prev' ) );
236
- }
237
- if ( 1 < $pages ) {
238
- $this->pages = $pages;
239
- add_action( 'tinvwl_pagenation_wishlist', array( $this, 'pages' ) );
240
- }
241
- if ( $pages > $paged ) {
242
- add_action( 'tinvwl_pagenation_wishlist', array( $this, 'page_next' ) );
243
- }
244
-
245
- $product_data = apply_filters( 'tinvwl_before_get_current_product', $product_data );
246
- $products = $wlp->get_wishlist( $product_data );
247
- $products = apply_filters( 'tinvwl_after_get_current_product', $products );
248
-
249
- return $products;
250
- }
251
-
252
- /**
253
- * Allow show button add to cart
254
- *
255
- * @param boolean $allow Settings flag.
256
- * @param array $wlproduct Wishlist Product.
257
- * @param WC_Product $product Product.
258
- *
259
- * @return boolean
260
- */
261
- function product_allow_add_to_cart( $allow, $wlproduct, $product ) {
262
- if ( ! $allow ) {
263
- return false;
264
- }
265
-
266
- return ( $product->is_purchasable() || 'external' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ) ) && ( $product->is_in_stock() || $product->backorders_allowed() );
267
- }
268
-
269
- /**
270
- * Basic validation actions
271
- *
272
- * @return boolean
273
- */
274
- function wishlist_action() {
275
-
276
- $wishlist_page_id = apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true );
277
-
278
- if ( is_page( $wishlist_page_id )
279
- || ( is_home() && 'page' === get_option( 'show_on_front' ) && absint( get_option( 'page_on_front' ) ) === $wishlist_page_id )
280
- || ( is_shop() && wc_get_page_id( 'shop' ) === $wishlist_page_id ) ) {
281
- $wishlist = $this->get_current_wishlist();
282
- if ( empty( $wishlist ) ) {
283
- return false;
284
- }
285
-
286
- if ( version_compare( WC_VERSION, '3.2.0', '<' ) ) {
287
- if ( ! defined( 'DONOTCACHEPAGE' ) ) {
288
- define( 'DONOTCACHEPAGE', true );
289
- }
290
- if ( ! defined( 'DONOTCACHEOBJECT' ) ) {
291
- define( 'DONOTCACHEOBJECT', true );
292
- }
293
- if ( ! defined( 'DONOTCACHEDB' ) ) {
294
- define( 'DONOTCACHEDB', true );
295
- }
296
- } else {
297
- WC_Cache_Helper::set_nocache_constants( true );
298
- nocache_headers();
299
- }
300
-
301
- $is_owner = is_user_logged_in() ? ( get_current_user_id() === $wishlist['author'] ) : $wishlist['is_owner'];
302
- $nonce = filter_input( INPUT_POST, 'wishlist_nonce' );
303
- if ( $nonce && wp_verify_nonce( $nonce, 'tinvwl_wishlist_owner' ) && $is_owner ) {
304
- do_action( 'tinvwl_before_action_owner', $wishlist );
305
- $this->wishlist_actions( $wishlist, true );
306
- do_action( 'tinvwl_after_action_owner', $wishlist );
307
- }
308
- if ( $nonce && wp_verify_nonce( $nonce, 'tinvwl_wishlist_user' ) && ! $is_owner ) {
309
- do_action( 'tinvwl_before_action_user', $wishlist );
310
- $this->wishlist_actions( $wishlist, false );
311
- do_action( 'tinvwl_after_action_user', $wishlist );
312
- }
313
- }
314
- }
315
-
316
- /**
317
- * Basic actions
318
- *
319
- * @param array $wishlist Wishlist object.
320
- * @param boolean $owner Is Owner.
321
- *
322
- * @return boolean
323
- */
324
- function wishlist_actions( $wishlist, $owner = false ) {
325
- $post = filter_input_array( INPUT_POST, array(
326
- 'wishlist_pr' => array(
327
- 'filter' => FILTER_VALIDATE_INT,
328
- 'flags' => FILTER_FORCE_ARRAY,
329
- ),
330
- 'wishlist_qty' => array(
331
- 'filter' => FILTER_VALIDATE_INT,
332
- 'flags' => FILTER_FORCE_ARRAY,
333
- 'options' => array( 'min_range' => 0, 'default' => 1 ),
334
- ),
335
- 'tinvwl-add-to-cart' => FILTER_VALIDATE_INT,
336
- 'tinvwl-remove' => FILTER_VALIDATE_INT,
337
- 'tinvwl-action' => FILTER_SANITIZE_STRING,
338
- ) );
339
-
340
- if ( ! empty( $post['tinvwl-add-to-cart'] ) ) {
341
- $product = $post['tinvwl-add-to-cart'];
342
- $quantity = array_key_exists( $product, (array) $post['wishlist_qty'] ) ? $post['wishlist_qty'][ $product ] : 1;
343
-
344
- return $this->button_addtocart( $wishlist, $product, $quantity, $owner );
345
- }
346
- if ( ! empty( $post['tinvwl-remove'] ) ) {
347
- if ( ! $wishlist['is_owner'] ) {
348
- return false;
349
- }
350
- $product = $post['tinvwl-remove'];
351
- if ( 0 === $wishlist['ID'] ) {
352
- $wlp = TInvWL_Product_Local::instance();
353
- } else {
354
- $wlp = new TInvWL_Product( $wishlist );
355
- }
356
- if ( empty( $wlp ) ) {
357
- return false;
358
- }
359
- $product_data = $wlp->get_wishlist( array( 'ID' => $product ) );
360
- $product_data = array_shift( $product_data );
361
- if ( empty( $product_data ) ) {
362
- return false;
363
- }
364
- $title = sprintf( __( '&ldquo;%s&rdquo;', 'ti-woocommerce-wishlist' ), $product_data['data']->get_title() );
365
- if ( $wlp->remove( $product_data ) ) {
366
- add_action( 'tinvwl_before_wishlist', array(
367
- 'TInvWL_Public_Wishlist_View',
368
- 'check_cart_hash'
369
- ), 99, 1 );
370
- add_action( 'woocommerce_set_cart_cookies', array(
371
- 'TInvWL_Public_Wishlist_View',
372
- 'reset_cart_hash'
373
- ), 99, 1 );
374
- wc_add_notice( sprintf( __( '%s has been removed from wishlist.', 'ti-woocommerce-wishlist' ), $title ) );
375
- } else {
376
- wc_add_notice( sprintf( __( '%s has not been removed from wishlist.', 'ti-woocommerce-wishlist' ), $title ), 'error' );
377
- }
378
-
379
- return true;
380
- }
381
- do_action( 'tinvwl_action_' . $post['tinvwl-action'], $wishlist, $post['wishlist_pr'], $post['wishlist_qty'], $owner ); // @codingStandardsIgnoreLine WordPress.NamingConventions.ValidHookName.UseUnderscores
382
- }
383
-
384
- /**
385
- * Check cart hash to trigger WC fragments refresh on wishlist update.
386
- *
387
- * @param $wishlist
388
- */
389
- public static function check_cart_hash( $wishlist ) {
390
- wp_add_inline_script( 'woocommerce', "
391
- jQuery(document).ready(function($){
392
- if ( typeof wc_cart_fragments_params === 'undefined' ) {
393
- return false;
394
- }
395
-
396
- var cart_hash_key = wc_cart_fragments_params.cart_hash_key,
397
- cart_hash = sessionStorage.getItem( cart_hash_key );
398
-
399
- if ( cart_hash === null || cart_hash === undefined || cart_hash === '' ) {
400
- sessionStorage.setItem( cart_hash_key, 'empty' );
401
- }
402
- });
403
- " );
404
- }
405
-
406
- /**
407
- * Reset cart hash to trigger WC fragments refresh on wishlist update.
408
- *
409
- * @param bool $set
410
- */
411
- public static function reset_cart_hash( $set ) {
412
- wc_setcookie( 'woocommerce_cart_hash', 'reset', time() - HOUR_IN_SECONDS );
413
- }
414
-
415
- /**
416
- * Apply action add to cart
417
- *
418
- * @param array $wishlist Wishlist object.
419
- * @param integer $id Product id in wishlist.
420
- * @param integer $quantity Product quantity.
421
- * @param boolean $owner Is Owner.
422
- *
423
- * @return boolean
424
- */
425
- function button_addtocart( $wishlist, $id, $quantity = 1, $owner = false ) {
426
- $id = absint( $id );
427
- $quantity = absint( $quantity );
428
- if ( empty( $id ) || empty( $quantity ) ) {
429
- return false;
430
- }
431
-
432
- $wlp = null;
433
- if ( 0 === $wishlist['ID'] ) {
434
- $wlp = TInvWL_Product_Local::instance();
435
- } else {
436
- $wlp = new TInvWL_Product( $wishlist );
437
- }
438
- if ( empty( $wlp ) ) {
439
- return false;
440
- }
441
-
442
- $_product = $wlp->get_wishlist( array( 'ID' => $id ) );
443
- $_product = array_shift( $_product );
444
- if ( empty( $_product ) || empty( $_product['data'] ) ) {
445
- return false;
446
- }
447
-
448
- global $product;
449
- // store global product data.
450
- $_product_tmp = $product;
451
- // override global product data.
452
- $product = $_product['data'];
453
-
454
- add_filter( 'clean_url', 'tinvwl_clean_url', 10, 2 );
455
- $redirect_url = $_product['data']->add_to_cart_url();
456
- remove_filter( 'clean_url', 'tinvwl_clean_url', 10 );
457
-
458
- // restore global product data.
459
- $product = $_product_tmp;
460
-
461
- $quantity = apply_filters( 'tinvwl_product_add_to_cart_quantity', $quantity, $_product['data'] );
462
-
463
- if ( apply_filters( 'tinvwl_product_add_to_cart_need_redirect', false, $_product['data'], $redirect_url, $_product ) ) {
464
- wp_redirect( apply_filters( 'tinvwl_product_add_to_cart_redirect_url', $redirect_url, $_product['data'], $_product ) ); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.wp_redirect
465
- exit;
466
- } elseif ( apply_filters( 'tinvwl_allow_addtocart_in_wishlist', true, $wishlist, $owner ) ) {
467
- $add = TInvWL_Public_Cart::add( $wishlist, $id, $quantity );
468
- if ( $add ) {
469
- wc_add_to_cart_message( $add, true );
470
-
471
- if ( tinv_get_option( 'processing', 'redirect_checkout' ) ) {
472
- wp_safe_redirect( wc_get_checkout_url() );
473
- exit;
474
- }
475
-
476
- if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
477
- wp_safe_redirect( wc_get_cart_url() );
478
- exit;
479
- }
480
-
481
- return true;
482
- }
483
- }
484
-
485
- return false;
486
- }
487
-
488
- /**
489
- * Output page
490
- *
491
- * @param array $atts Array parameter for shortcode.
492
- *
493
- * @return mixed
494
- */
495
- function htmloutput( $atts ) {
496
- $wishlist = $this->get_current_wishlist();
497
-
498
- if ( empty( $wishlist ) ) {
499
- $id = get_query_var( 'tinvwlID', null );
500
- if ( empty( $id ) && ( is_user_logged_in() || ! tinv_get_option( 'general', 'require_login' ) ) ) {
501
- return $this->wishlist_empty( array(), array(
502
- 'ID' => '',
503
- 'author' => get_current_user_id(),
504
- 'title' => apply_filters( 'tinvwl-general-default_title', tinv_get_option( 'general', 'default_title' ) ),
505
- 'status' => 'private',
506
- 'type' => 'default',
507
- 'share_key' => '',
508
- ) );
509
- }
510
-
511
- return $this->wishlist_null();
512
- }
513
-
514
- if ( 'private' === $wishlist['status'] && ! $wishlist['is_owner'] ) {
515
- return $this->wishlist_null();
516
- }
517
- if ( 'default' !== $wishlist['type'] && ! tinv_get_option( 'general', 'multi' ) ) {
518
- if ( $wishlist['is_owner'] ) {
519
- printf( '<p><a href="%s">%s</p><script type="text/javascript">window.location.href="%s"</script>', esc_attr( tinv_url_wishlist_default() ), esc_html__( 'Return to Wishlist', 'ti-woocommerce-wishlist' ), esc_attr( tinv_url_wishlist_default() ) );
520
-
521
- return false;
522
- } else {
523
- return $this->wishlist_null();
524
- }
525
- }
526
-
527
- $products = $this->get_current_products( $wishlist, true, absint( $atts['lists_per_page'] ) );
528
-
529
- $this->lists_per_page = $atts['lists_per_page'];
530
-
531
- $wla = new TInvWL_Analytics( $wishlist, $this->_name );
532
- $wla->wishlist_view( 0, $wishlist['is_owner'] );
533
-
534
- foreach ( $products as $key => $product ) {
535
- if ( ! isset( $product['data'] ) ) {
536
- unset( $products[ $key ] );
537
- }
538
- }
539
-
540
- if ( empty( $products ) ) {
541
- return $this->wishlist_empty( $products, $wishlist );
542
- }
543
-
544
- $wishlist_table_row = tinv_get_option( 'product_table' );
545
- $wishlist_table_row['text_add_to_cart'] = apply_filters( 'tinvwl-product_table-text_add_to_cart', tinv_get_option( 'product_table', 'text_add_to_cart' ) );
546
-
547
- $data = array(
548
- 'products' => $products,
549
- 'wishlist' => $wishlist,
550
- 'wishlist_table' => tinv_get_option( 'table' ),
551
- 'wishlist_table_row' => $wishlist_table_row,
552
- );
553
-
554
- if ( $wishlist['is_owner'] ) {
555
- tinv_wishlist_template( 'ti-wishlist.php', $data );
556
- } else {
557
- if ( class_exists( 'WC_Catalog_Visibility_Options' ) ) {
558
- global $wc_cvo;
559
- if ( 'secured' === $wc_cvo->setting( 'wc_cvo_atc' && isset( $data['wishlist_table_row']['add_to_cart'] ) ) ) {
560
- unset( $data['wishlist_table_row']['add_to_cart'] );
561
- }
562
- if ( 'secured' === $wc_cvo->setting( 'wc_cvo_prices' && isset( $data['wishlist_table_row']['colm_price'] ) ) ) {
563
- unset( $data['wishlist_table_row']['colm_price'] );
564
- }
565
- }
566
-
567
- tinv_wishlist_template( 'ti-wishlist-user.php', $data );
568
- }
569
- }
570
-
571
- /**
572
- * Not Found Wishlist
573
- *
574
- * @param array $wishlist Wishlist object.
575
- */
576
- function wishlist_null( $wishlist = array() ) {
577
- $data = array(
578
- 'wishlist' => $wishlist,
579
- );
580
- tinv_wishlist_template( 'ti-wishlist-null.php', $data );
581
- }
582
-
583
- /**
584
- * Empty Wishlist
585
- *
586
- * @param array $products Products wishlist.
587
- * @param array $wishlist Wishlist object.
588
- */
589
- function wishlist_empty( $products = array(), $wishlist = array() ) {
590
- $data = array(
591
- 'products' => $products,
592
- 'wishlist' => $wishlist,
593
- 'wishlist_table' => tinv_get_option( 'table' ),
594
- );
595
- tinv_wishlist_template( 'ti-wishlist-empty.php', $data );
596
- }
597
-
598
- /**
599
- * Header Wishlist
600
- *
601
- * @param array $wishlist Wishlist object.
602
- */
603
- function wishlist_header( $wishlist ) {
604
-
605
- $data = array(
606
- 'wishlist' => $wishlist,
607
- );
608
- tinv_wishlist_template( 'ti-wishlist-header.php', $data );
609
- }
610
-
611
- /**
612
- * Prev page button
613
- */
614
- function page_prev() {
615
- $paged = get_query_var( 'wl_paged', 1 );
616
- $paged = 1 < $paged ? $paged - 1 : 0;
617
- $this->page( $paged, sprintf( '<i class="ftinvwl ftinvwl-chevron-left"></i><span>%s</span>', __( 'Previous Page', 'ti-woocommerce-wishlist' ) ), array( 'class' => 'button tinv-prev' ) );
618
- }
619
-
620
- /**
621
- * Pages
622
- */
623
- function pages() {
624
-
625
- $paged = get_query_var( 'wl_paged', 1 );
626
- if ( 1 === (int) $paged ) {
627
- echo '<span></span>';
628
- }
629
-
630
- echo '<span>' . $paged . '/' . $this->pages . '</span>';
631
-
632
- if ( (int) $this->pages === (int) $paged ) {
633
- echo '<span></span>';
634
- }
635
- }
636
-
637
- /**
638
- * Next page button
639
- */
640
- function page_next() {
641
- $paged = get_query_var( 'wl_paged', 1 );
642
- $paged = 1 < $paged ? $paged + 1 : 2;
643
- $this->page( $paged, sprintf( '<span>%s</span><i class="ftinvwl ftinvwl-chevron-right"></i>', __( 'Next Page', 'ti-woocommerce-wishlist' ) ), array( 'class' => 'button tinv-next' ) );
644
- }
645
-
646
- /**
647
- * Page button
648
- *
649
- * @param integer $paged Index page.
650
- * @param string $text Text button.
651
- * @param style $style Style attribute.
652
- */
653
- function page( $paged, $text, $style = array() ) {
654
- $paged = absint( $paged );
655
- $wishlist = tinv_wishlist_get();
656
- $link = tinv_url_wishlist( $wishlist['share_key'], $paged, true );
657
- if ( is_array( $style ) ) {
658
- $style = TInvWL_Form::__atrtostr( $style );
659
- }
660
- printf( '<a href="%s" %s>%s</a>', esc_url( $link ), $style, $text ); // WPCS: xss ok.
661
- }
662
-
663
- /**
664
- * Shortcode basic function
665
- *
666
- * @param array $atts Array parameter from shortcode.
667
- *
668
- * @return string
669
- */
670
- function shortcode( $atts = array() ) {
671
- $default = array(
672
- 'lists_per_page' => 10,
673
- );
674
- $atts = shortcode_atts( $default, $atts );
675
-
676
- ob_start();
677
- $this->htmloutput( $atts );
678
-
679
- return ob_get_clean();
680
- }
681
-
682
- /**
683
- * Get per page items for buttons
684
- */
685
- function get_per_page() {
686
- if ( ! empty( $this->lists_per_page ) ) {
687
- echo TInvWL_Form::_text( array( // WPCS: xss ok.
688
- 'type' => 'hidden',
689
- 'name' => 'lists_per_page',
690
- ), $this->lists_per_page );
691
- }
692
- }
693
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Wishlist shortcode
4
+ *
5
+ * @since 1.0.0
6
+ * @package TInvWishlist\Public
7
+ */
8
+
9
+ // If this file is called directly, abort.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ die;
12
+ }
13
+
14
+ /**
15
+ * Wishlist shortcode
16
+ */
17
+ class TInvWL_Public_Wishlist_View {
18
+
19
+ /**
20
+ * Plugin name
21
+ *
22
+ * @var string
23
+ */
24
+ private $_name;
25
+
26
+ /**
27
+ * List per page
28
+ *
29
+ * @var integer
30
+ */
31
+ private $lists_per_page;
32
+
33
+ /**
34
+ * Current wishlist
35
+ *
36
+ * @var array
37
+ */
38
+ private $current_wishlist;
39
+
40
+ /**
41
+ * Current products
42
+ *
43
+ * @var array
44
+ */
45
+ private $current_products_query;
46
+
47
+ /**
48
+ * Social image
49
+ *
50
+ * @var string
51
+ */
52
+ public $social_image;
53
+
54
+ /**
55
+ * Wishlist full URL
56
+ *
57
+ * @var string
58
+ */
59
+ public $wishlist_url;
60
+
61
+ /**
62
+ * Wishlist product helper
63
+ *
64
+ * @var TInvWL_Product
65
+ */
66
+ public $wishlist_products_helper;
67
+
68
+ /**
69
+ * This class
70
+ *
71
+ * @var \TInvWL_Public_Wishlist_View
72
+ */
73
+ protected static $_instance = null;
74
+
75
+ /**
76
+ * Get this class object
77
+ *
78
+ * @param string $plugin_name Plugin name.
79
+ *
80
+ * @return \TInvWL_Public_Wishlist_View
81
+ */
82
+ public static function instance( $plugin_name = TINVWL_PREFIX ) {
83
+ if ( is_null( self::$_instance ) ) {
84
+ self::$_instance = new self( $plugin_name );
85
+ }
86
+
87
+ return self::$_instance;
88
+ }
89
+
90
+ /**
91
+ * Constructor
92
+ *
93
+ * @param string $plugin_name Plugin name.
94
+ */
95
+ function __construct( $plugin_name ) {
96
+ $this->_name = $plugin_name;
97
+ $this->define_hooks();
98
+ }
99
+
100
+ /**
101
+ * Defined shortcode and hooks
102
+ */
103
+ function define_hooks() {
104
+ add_action( 'template_redirect', array( $this, 'login_redirect' ) );
105
+
106
+ add_action( 'wp_loaded', array( $this, 'login_post_redirect' ), 19 );
107
+
108
+ add_action( 'wp', array( $this, 'wishlist_action' ), 0 );
109
+ add_action( 'wp_head', array( $this, 'add_meta_tags' ), 1 );
110
+
111
+ add_action( 'tinvwl_before_wishlist', array( $this, 'wishlist_header' ) );
112
+
113
+ add_action( 'tinvwl_after_wishlist', array( 'TInvWL_Public_Wishlist_Social', 'init' ) );
114
+ add_filter( 'tinvwl_wishlist_item_url', array( $this, 'add_argument' ), 10, 3 );
115
+ add_filter( 'tinvwl_wishlist_item_action_add_to_cart', array( $this, 'product_allow_add_to_cart' ), 10, 3 );
116
+ add_filter( 'tinvwl_wishlist_item_add_to_cart', array( $this, 'external_text' ), 10, 3 );
117
+ add_filter( 'tinvwl_wishlist_item_add_to_cart', array( $this, 'variable_text' ), 10, 3 );
118
+ add_action( 'tinvwl_after_wishlist_table', array( $this, 'get_per_page' ) );
119
+
120
+ TInvWL_Public_Wishlist_Buttons::init( $this->_name );
121
+ }
122
+
123
+ /**
124
+ * Redirect back after successful login.
125
+ */
126
+ public function login_post_redirect() {
127
+ $nonce_value = isset( $_REQUEST['woocommerce-login-nonce'] ) ? $_REQUEST['woocommerce-login-nonce'] : ( isset( $_REQUEST['_wpnonce'] ) ? $_REQUEST['_wpnonce'] : '' );
128
+ if ( ! empty( $_POST['login'] ) && wp_verify_nonce( $nonce_value, 'woocommerce-login' ) && ! empty( $_GET['tinvwl_redirect'] ) ) {
129
+ $_POST['redirect'] = $_GET['tinvwl_redirect']; // Force WC Login form handler to do redirect.
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Redirect guests to login page.
135
+ */
136
+ public function login_redirect() {
137
+ if ( ! wc_get_page_id( 'myaccount' ) && is_page( apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ) ) && ! is_user_logged_in() && tinv_get_option( 'general', 'require_login' ) ) {
138
+ $full_link = get_permalink();
139
+ $share_key = get_query_var( 'tinvwlID', null );
140
+ if ( ! empty( $share_key ) ) {
141
+ if ( get_option( 'permalink_structure' ) ) {
142
+ if ( ! preg_match( '/\/$/', $full_link ) ) {
143
+ $full_link .= '/';
144
+ }
145
+ $full_link .= $share_key . '/';
146
+ } else {
147
+ $full_link = add_query_arg( 'tinvwlID', $share_key, $full_link );
148
+ }
149
+ }
150
+
151
+ wp_safe_redirect( add_query_arg( 'tinvwl_redirect', esc_url( $full_link ), wc_get_page_permalink( 'myaccount' ) ) );
152
+ exit;
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Change Text for external product
158
+ *
159
+ * @param string $text Text for button add to cart.
160
+ * @param array $wl_product Wishlist Product.
161
+ * @param WC_Product $_product Product.
162
+ *
163
+ * @return string
164
+ */
165
+ function external_text( $text, $wl_product, $_product ) {
166
+ global $product;
167
+ // store global product data.
168
+ $_product_tmp = $product;
169
+ // override global product data.
170
+ $product = $_product;
171
+
172
+ if ( 'external' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ) ) {
173
+
174
+ $text = $product->single_add_to_cart_text();
175
+
176
+ // restore global product data.
177
+ $product = $_product_tmp;
178
+ }
179
+
180
+ return $text;
181
+ }
182
+
183
+ /**
184
+ * Change Text for variable product that requires to select some variations.
185
+ *
186
+ * @param string $text Text for button add to cart.
187
+ * @param array $wl_product Wishlist Product.
188
+ * @param WC_Product $_product Product.
189
+ *
190
+ * @return string
191
+ */
192
+ function variable_text( $text, $wl_product, $_product ) {
193
+ global $product;
194
+ // store global product data.
195
+ $_product_tmp = $product;
196
+ // override global product data.
197
+ $product = $_product;
198
+ if ( apply_filters( 'tinvwl_product_add_to_cart_need_redirect', false, $product, $product->get_permalink(), $wl_product )
199
+ && in_array( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ), array(
200
+ 'variable',
201
+ 'variable-subscription',
202
+ ) ) ) {
203
+
204
+ $text = $product->add_to_cart_text();
205
+
206
+ // restore global product data.
207
+ $product = $_product_tmp;
208
+ }
209
+
210
+ return $text;
211
+ }
212
+
213
+ /**
214
+ * Add analytics argument for url
215
+ *
216
+ * @param string $url Product url.
217
+ * @param array $wl_product Wishlist product.
218
+ * @param object $product Product.
219
+ *
220
+ * @return type
221
+ */
222
+ function add_argument( $url, $wl_product, $product ) {
223
+ return add_query_arg( 'tiwp', $wl_product['ID'], $url );
224
+ }
225
+
226
+ /**
227
+ * Get current wishlist
228
+ *
229
+ * @return array
230
+ */
231
+ function get_current_wishlist() {
232
+ if ( empty( $this->current_wishlist ) ) {
233
+ $this->current_wishlist = apply_filters( 'tinvwl_get_current_wishlist', tinv_wishlist_get() );
234
+ }
235
+
236
+ return $this->current_wishlist;
237
+ }
238
+
239
+ /**
240
+ * Get current products query
241
+ *
242
+ * @return array
243
+ */
244
+ function get_current_products_query() {
245
+ if ( ! is_array( $this->current_products_query ) ) {
246
+ return false;
247
+ }
248
+
249
+ return $this->current_products_query;
250
+ }
251
+
252
+
253
+ /**
254
+ * Get current products from wishlist
255
+ *
256
+ * @param array $wishlist Wishlist object.
257
+ * @param boolean $external Get woocommerce product info.
258
+ * @param integer $lists_per_page Count per page.
259
+ *
260
+ * @return array
261
+ */
262
+ function get_current_products( $wishlist = null, $external = true, $lists_per_page = 10 ) {
263
+ if ( empty( $wishlist ) || $wishlist === $this->get_current_wishlist() ) {
264
+ $wishlist = $this->get_current_wishlist();
265
+
266
+ if ( ! $this->wishlist_products_helper ) {
267
+ $wlp = null;
268
+ if ( isset( $wishlist['ID'] ) && 0 === $wishlist['ID'] ) {
269
+ $wlp = TInvWL_Product_Local::instance();
270
+ } else {
271
+ $wlp = new TInvWL_Product( $wishlist );
272
+ }
273
+ $this->wishlist_products_helper = $wlp;
274
+ } else {
275
+ $wlp = $this->wishlist_products_helper;
276
+ }
277
+
278
+ } else {
279
+ $wlp = null;
280
+ if ( isset( $wishlist['ID'] ) && 0 === $wishlist['ID'] ) {
281
+ $wlp = TInvWL_Product_Local::instance();
282
+ } else {
283
+ $wlp = new TInvWL_Product( $wishlist );
284
+ }
285
+ }
286
+
287
+ if ( empty( $wlp ) ) {
288
+ return array();
289
+ }
290
+
291
+ $paged = get_query_var( 'wl_paged', 1 );
292
+ $paged = 1 < $paged ? $paged : 1;
293
+
294
+ $product_data = array(
295
+ 'count' => $lists_per_page,
296
+ 'offset' => $lists_per_page * ( $paged - 1 ),
297
+ 'external' => $external,
298
+ 'order_by' => 'date',
299
+ 'order' => 'DESC',
300
+ );
301
+
302
+ $product_data = apply_filters( 'tinvwl_before_get_current_product', $product_data );
303
+ $products = $wlp->get_wishlist( $product_data );
304
+ $products = apply_filters( 'tinvwl_after_get_current_product', $products );
305
+
306
+ if ( 10 === absint( $lists_per_page ) ) {
307
+ $this->current_products_query = $products;
308
+ }
309
+
310
+ return $products;
311
+ }
312
+
313
+ /**
314
+ * Allow show button add to cart
315
+ *
316
+ * @param boolean $allow Settings flag.
317
+ * @param array $wlproduct Wishlist Product.
318
+ * @param WC_Product $product Product.
319
+ *
320
+ * @return boolean
321
+ */
322
+ function product_allow_add_to_cart( $allow, $wlproduct, $product ) {
323
+ if ( ! $allow ) {
324
+ return false;
325
+ }
326
+
327
+ return ( $product->is_purchasable() || 'external' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ) ) && ( $product->is_in_stock() || $product->backorders_allowed() );
328
+ }
329
+
330
+ /**
331
+ * Basic validation actions
332
+ *
333
+ * @return boolean
334
+ */
335
+ function wishlist_action() {
336
+
337
+ $wishlist_page_id = apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true );
338
+
339
+ if ( is_page( $wishlist_page_id )
340
+ || ( is_home() && 'page' === get_option( 'show_on_front' ) && absint( get_option( 'page_on_front' ) ) === $wishlist_page_id )
341
+ || ( is_shop() && wc_get_page_id( 'shop' ) === $wishlist_page_id ) ) {
342
+ $wishlist = $this->get_current_wishlist();
343
+ if ( empty( $wishlist ) ) {
344
+ return false;
345
+ }
346
+
347
+ if ( version_compare( WC_VERSION, '3.2.0', '<' ) ) {
348
+ if ( ! defined( 'DONOTCACHEPAGE' ) ) {
349
+ define( 'DONOTCACHEPAGE', true );
350
+ }
351
+ if ( ! defined( 'DONOTCACHEOBJECT' ) ) {
352
+ define( 'DONOTCACHEOBJECT', true );
353
+ }
354
+ if ( ! defined( 'DONOTCACHEDB' ) ) {
355
+ define( 'DONOTCACHEDB', true );
356
+ }
357
+ } else {
358
+ WC_Cache_Helper::set_nocache_constants( true );
359
+ nocache_headers();
360
+ }
361
+
362
+ $is_owner = is_user_logged_in() ? ( get_current_user_id() === $wishlist['author'] ) : $wishlist['is_owner'];
363
+ $nonce = filter_input( INPUT_POST, 'wishlist_nonce' );
364
+ if ( $nonce && wp_verify_nonce( $nonce, 'tinvwl_wishlist_owner' ) && $is_owner ) {
365
+ do_action( 'tinvwl_before_action_owner', $wishlist );
366
+ $this->wishlist_actions( $wishlist, true );
367
+ do_action( 'tinvwl_after_action_owner', $wishlist );
368
+ }
369
+ if ( $nonce && wp_verify_nonce( $nonce, 'tinvwl_wishlist_user' ) && ! $is_owner ) {
370
+ do_action( 'tinvwl_before_action_user', $wishlist );
371
+ $this->wishlist_actions( $wishlist, false );
372
+ do_action( 'tinvwl_after_action_user', $wishlist );
373
+ }
374
+ }
375
+ }
376
+
377
+ /**
378
+ * Create social meta tags
379
+ */
380
+ function add_meta_tags() {
381
+ if ( is_page( apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ) ) && ( tinv_get_option( 'social', 'facebook' ) || tinv_get_option( 'social', 'google' ) ) ) {
382
+ $wishlist = $this->get_current_wishlist();
383
+ if ( $wishlist && 0 < $wishlist['ID'] && 'private' !== $wishlist['status'] ) {
384
+ if ( is_user_logged_in() ) {
385
+ $user = get_user_by( 'id', $wishlist['author'] );
386
+ if ( $user && $user->exists() ) {
387
+ $user_name = trim( sprintf( '%s %s', $user->user_firstname, $user->user_lastname ) );
388
+ $user = @$user->display_name; // @codingStandardsIgnoreLine Generic.PHP.NoSilencedErrors.Discouraged
389
+ } else {
390
+ $user_name = '';
391
+ $user = '';
392
+ }
393
+ } else {
394
+ $user_name = '';
395
+ $user = '';
396
+ }
397
+
398
+ if ( is_array( $this->get_current_products_query() ) ) {
399
+ $products = $this->current_products_query;
400
+ } else {
401
+ $products = $this->get_current_products( $wishlist, true );
402
+ }
403
+
404
+ $products_title = array();
405
+ foreach ( $products as $product ) {
406
+ if ( ! empty( $product ) && ! empty( $product['data'] ) ) {
407
+ $title = $product['data']->get_title();
408
+ if ( ! in_array( $title, $products_title ) ) {
409
+ $products_title[] = $title;
410
+ }
411
+ }
412
+ }
413
+ $product = array_shift( $products );
414
+ $image = '';
415
+ if ( ! empty( $product ) && ! empty( $product['data'] ) ) {
416
+ list( $image ) = wp_get_attachment_image_src( $product['data']->get_image_id(), 'full' );
417
+ }
418
+
419
+ $this->social_image = $image;
420
+ $this->wishlist_url = tinv_url_wishlist( $wishlist['share_key'] );
421
+
422
+ $meta = apply_filters( 'tinvwl_social_header_meta', array(
423
+ 'url' => $this->wishlist_url,
424
+ 'type' => 'product.group',
425
+ 'title' => sprintf( __( '%1$s by %2$s', 'ti-woocommerce-wishlist' ), $wishlist['title'], ( empty( $user_name ) ? $user : $user_name ) ),
426
+ 'description' => implode( ', ', $products_title ),
427
+ 'image' => $image,
428
+ ) );
429
+ if ( tinv_get_option( 'social', 'facebook' ) ) {
430
+ foreach ( $meta as $name => $content ) {
431
+ echo sprintf( '<meta property="og:%s" content="%s" />', esc_attr( $name ), esc_attr( $content ) );
432
+ }
433
+ echo "\n";
434
+ }
435
+ if ( tinv_get_option( 'social', 'google' ) ) {
436
+ unset( $meta['url'], $meta['type'] );
437
+ foreach ( $meta as $name => $content ) {
438
+ if ( 'title' === $name ) {
439
+ $name = 'name';
440
+ }
441
+ echo sprintf( '<meta itemprop="%s" content="%s">', esc_attr( $name ), esc_attr( $content ) );
442
+ }
443
+ echo "\n";
444
+ }
445
+ } // End if().
446
+ } // End if().
447
+ }
448
+
449
+ /**
450
+ * Basic actions
451
+ *
452
+ * @param array $wishlist Wishlist object.
453
+ * @param boolean $owner Is Owner.
454
+ *
455
+ * @return boolean
456
+ */
457
+ function wishlist_actions( $wishlist, $owner = false ) {
458
+ $post = filter_input_array( INPUT_POST, array(
459
+ 'wishlist_pr' => array(
460
+ 'filter' => FILTER_VALIDATE_INT,
461
+ 'flags' => FILTER_FORCE_ARRAY,
462
+ ),
463
+ 'wishlist_qty' => array(
464
+ 'filter' => FILTER_VALIDATE_INT,
465
+ 'flags' => FILTER_FORCE_ARRAY,
466
+ 'options' => array( 'min_range' => 0, 'default' => 1 ),
467
+ ),
468
+ 'tinvwl-add-to-cart' => FILTER_VALIDATE_INT,
469
+ 'tinvwl-remove' => FILTER_VALIDATE_INT,
470
+ 'tinvwl-action' => FILTER_SANITIZE_STRING,
471
+ ) );
472
+
473
+ if ( ! empty( $post['tinvwl-add-to-cart'] ) ) {
474
+ $product = $post['tinvwl-add-to-cart'];
475
+ $quantity = array_key_exists( $product, (array) $post['wishlist_qty'] ) ? $post['wishlist_qty'][ $product ] : 1;
476
+
477
+ return $this->button_addtocart( $wishlist, $product, $quantity, $owner );
478
+ }
479
+ if ( ! empty( $post['tinvwl-remove'] ) ) {
480
+ if ( ! $wishlist['is_owner'] ) {
481
+ return false;
482
+ }
483
+ $product = $post['tinvwl-remove'];
484
+ if ( 0 === $wishlist['ID'] ) {
485
+ $wlp = TInvWL_Product_Local::instance();
486
+ } else {
487
+ $wlp = new TInvWL_Product( $wishlist );
488
+ }
489
+ if ( empty( $wlp ) ) {
490
+ return false;
491
+ }
492
+ $product_data = $wlp->get_wishlist( array( 'ID' => $product ) );
493
+ $product_data = array_shift( $product_data );
494
+ if ( empty( $product_data ) ) {
495
+ return false;
496
+ }
497
+ $title = sprintf( __( '&ldquo;%s&rdquo;', 'ti-woocommerce-wishlist' ), $product_data['data']->get_title() );
498
+ if ( $wlp->remove( $product_data ) ) {
499
+ add_action( 'tinvwl_before_wishlist', array(
500
+ 'TInvWL_Public_Wishlist_View',
501
+ 'check_cart_hash',
502
+ ), 99, 1 );
503
+ add_action( 'woocommerce_set_cart_cookies', array(
504
+ 'TInvWL_Public_Wishlist_View',
505
+ 'reset_cart_hash',
506
+ ), 99, 1 );
507
+ wc_add_notice( sprintf( __( '%s has been removed from wishlist.', 'ti-woocommerce-wishlist' ), $title ) );
508
+ } else {
509
+ wc_add_notice( sprintf( __( '%s has not been removed from wishlist.', 'ti-woocommerce-wishlist' ), $title ), 'error' );
510
+ }
511
+
512
+ return true;
513
+ }
514
+ do_action( 'tinvwl_action_' . $post['tinvwl-action'], $wishlist, $post['wishlist_pr'], $post['wishlist_qty'], $owner ); // @codingStandardsIgnoreLine WordPress.NamingConventions.ValidHookName.UseUnderscores
515
+ }
516
+
517
+ /**
518
+ * Check cart hash to trigger WC fragments refresh on wishlist update.
519
+ *
520
+ * @param $wishlist
521
+ */
522
+ public static function check_cart_hash( $wishlist ) {
523
+ wp_add_inline_script( 'woocommerce', "
524
+ jQuery(document).ready(function($){
525
+ if ( typeof wc_cart_fragments_params === 'undefined' ) {
526
+ return false;
527
+ }
528
+
529
+ var cart_hash_key = wc_cart_fragments_params.cart_hash_key,
530
+ cart_hash = sessionStorage.getItem( cart_hash_key );
531
+
532
+ if ( cart_hash === null || cart_hash === undefined || cart_hash === '' ) {
533
+ sessionStorage.setItem( cart_hash_key, 'empty' );
534
+ }
535
+ });
536
+ " );
537
+ }
538
+
539
+ /**
540
+ * Reset cart hash to trigger WC fragments refresh on wishlist update.
541
+ *
542
+ * @param bool $set
543
+ */
544
+ public static function reset_cart_hash( $set ) {
545
+ wc_setcookie( 'woocommerce_cart_hash', 'reset', time() - HOUR_IN_SECONDS );
546
+ }
547
+
548
+ /**
549
+ * Apply action add to cart
550
+ *
551
+ * @param array $wishlist Wishlist object.
552
+ * @param integer $id Product id in wishlist.
553
+ * @param integer $quantity Product quantity.
554
+ * @param boolean $owner Is Owner.
555
+ *
556
+ * @return boolean
557
+ */
558
+ function button_addtocart( $wishlist, $id, $quantity = 1, $owner = false ) {
559
+ $id = absint( $id );
560
+ $quantity = absint( $quantity );
561
+ if ( empty( $id ) || empty( $quantity ) ) {
562
+ return false;
563
+ }
564
+
565
+ $wlp = null;
566
+ if ( 0 === $wishlist['ID'] ) {
567
+ $wlp = TInvWL_Product_Local::instance();
568
+ } else {
569
+ $wlp = new TInvWL_Product( $wishlist );
570
+ }
571
+ if ( empty( $wlp ) ) {
572
+ return false;
573
+ }
574
+
575
+ $_product = $wlp->get_wishlist( array( 'ID' => $id ) );
576
+ $_product = array_shift( $_product );
577
+ if ( empty( $_product ) || empty( $_product['data'] ) ) {
578
+ return false;
579
+ }
580
+
581
+ global $product;
582
+ // store global product data.
583
+ $_product_tmp = $product;
584
+ // override global product data.
585
+ $product = $_product['data'];
586
+
587
+ add_filter( 'clean_url', 'tinvwl_clean_url', 10, 2 );
588
+ $redirect_url = $_product['data']->add_to_cart_url();
589
+ remove_filter( 'clean_url', 'tinvwl_clean_url', 10 );
590
+
591
+ // restore global product data.
592
+ $product = $_product_tmp;
593
+
594
+ $quantity = apply_filters( 'tinvwl_product_add_to_cart_quantity', $quantity, $_product['data'] );
595
+
596
+ if ( apply_filters( 'tinvwl_product_add_to_cart_need_redirect', false, $_product['data'], $redirect_url, $_product ) ) {
597
+ wp_redirect( apply_filters( 'tinvwl_product_add_to_cart_redirect_url', $redirect_url, $_product['data'], $_product ) ); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.wp_redirect
598
+ exit;
599
+ } elseif ( apply_filters( 'tinvwl_allow_addtocart_in_wishlist', true, $wishlist, $owner ) ) {
600
+ $add = TInvWL_Public_Cart::add( $wishlist, $id, $quantity );
601
+ if ( $add ) {
602
+ wc_add_to_cart_message( $add, true );
603
+
604
+ if ( tinv_get_option( 'processing', 'redirect_checkout' ) ) {
605
+ wp_safe_redirect( wc_get_checkout_url() );
606
+ exit;
607
+ }
608
+
609
+ if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
610
+ wp_safe_redirect( wc_get_cart_url() );
611
+ exit;
612
+ }
613
+
614
+ return true;
615
+ }
616
+ }
617
+
618
+ return false;
619
+ }
620
+
621
+ /**
622
+ * Output page
623
+ *
624
+ * @param array $atts Array parameter for shortcode.
625
+ *
626
+ * @return mixed
627
+ */
628
+ function htmloutput( $atts ) {
629
+ $wishlist = $this->get_current_wishlist();
630
+
631
+ if ( empty( $wishlist ) ) {
632
+ $id = get_query_var( 'tinvwlID', null );
633
+ if ( empty( $id ) && ( is_user_logged_in() || ! tinv_get_option( 'general', 'require_login' ) ) ) {
634
+ return $this->wishlist_empty( array(), array(
635
+ 'ID' => '',
636
+ 'author' => get_current_user_id(),
637
+ 'title' => apply_filters( 'tinvwl-general-default_title', tinv_get_option( 'general', 'default_title' ) ),
638
+ 'status' => 'private',
639
+ 'type' => 'default',
640
+ 'share_key' => '',
641
+ ) );
642
+ }
643
+
644
+ return $this->wishlist_null();
645
+ }
646
+
647
+ if ( 'private' === $wishlist['status'] && ! $wishlist['is_owner'] ) {
648
+ return $this->wishlist_null();
649
+ }
650
+ if ( 'default' !== $wishlist['type'] && ! tinv_get_option( 'general', 'multi' ) ) {
651
+ if ( $wishlist['is_owner'] ) {
652
+ printf( '<p><a href="%s">%s</p><script type="text/javascript">window.location.href="%s"</script>', esc_attr( tinv_url_wishlist_default() ), esc_html__( 'Return to Wishlist', 'ti-woocommerce-wishlist' ), esc_attr( tinv_url_wishlist_default() ) );
653
+
654
+ return false;
655
+ } else {
656
+ return $this->wishlist_null();
657
+ }
658
+ }
659
+
660
+ $this->lists_per_page = absint( $atts['lists_per_page'] );
661
+
662
+ if ( 10 === $this->lists_per_page && is_array( $this->get_current_products_query() ) ) {
663
+ $products = $this->current_products_query;
664
+ } else {
665
+ $products = $this->get_current_products( $wishlist, true, $this->lists_per_page );
666
+ }
667
+
668
+ $wla = new TInvWL_Analytics( $wishlist, $this->_name );
669
+ $wla->view_products( $wishlist, $wishlist['is_owner'] );
670
+
671
+ foreach ( $products as $key => $product ) {
672
+ if ( ! isset( $product['data'] ) ) {
673
+ unset( $products[ $key ] );
674
+ }
675
+ }
676
+
677
+ if ( empty( $products ) ) {
678
+ return $this->wishlist_empty( $products, $wishlist );
679
+ }
680
+
681
+ $wishlist_table_row = tinv_get_option( 'product_table' );
682
+ $wishlist_table_row['text_add_to_cart'] = apply_filters( 'tinvwl-product_table-text_add_to_cart', tinv_get_option( 'product_table', 'text_add_to_cart' ) );
683
+
684
+ $data = array(
685
+ 'products' => $products,
686
+ 'wishlist' => $wishlist,
687
+ 'wishlist_table' => tinv_get_option( 'table' ),
688
+ 'wishlist_table_row' => $wishlist_table_row,
689
+ );
690
+
691
+ $paged = get_query_var( 'wl_paged', 1 );
692
+ $paged = 1 < $paged ? $paged : 1;
693
+
694
+ if ( 1 < $paged ) {
695
+ add_action( 'tinvwl_pagenation_wishlist', array( $this, 'page_prev' ) );
696
+ }
697
+ $pages = ceil( absint( $this->wishlist_products_helper->get_wishlist( array(
698
+ 'count' => 9999999,
699
+ 'external' => false,
700
+ ), true ) ) / absint( $this->lists_per_page ) );
701
+
702
+ if ( 1 < $pages ) {
703
+ $this->pages = $pages;
704
+ add_action( 'tinvwl_pagenation_wishlist', array( $this, 'pages' ) );
705
+ }
706
+ if ( $pages > $paged ) {
707
+ add_action( 'tinvwl_pagenation_wishlist', array( $this, 'page_next' ) );
708
+ }
709
+
710
+ if ( $wishlist['is_owner'] ) {
711
+ tinv_wishlist_template( 'ti-wishlist.php', $data );
712
+ } else {
713
+ if ( class_exists( 'WC_Catalog_Visibility_Options' ) ) {
714
+ global $wc_cvo;
715
+ if ( 'secured' === $wc_cvo->setting( 'wc_cvo_atc' && isset( $data['wishlist_table_row']['add_to_cart'] ) ) ) {
716
+ unset( $data['wishlist_table_row']['add_to_cart'] );
717
+ }
718
+ if ( 'secured' === $wc_cvo->setting( 'wc_cvo_prices' && isset( $data['wishlist_table_row']['colm_price'] ) ) ) {
719
+ unset( $data['wishlist_table_row']['colm_price'] );
720
+ }
721
+ }
722
+
723
+ tinv_wishlist_template( 'ti-wishlist-user.php', $data );
724
+ }
725
+ }
726
+
727
+ /**
728
+ * Not Found Wishlist
729
+ *
730
+ * @param array $wishlist Wishlist object.
731
+ */
732
+ function wishlist_null( $wishlist = array() ) {
733
+ $data = array(
734
+ 'wishlist' => $wishlist,
735
+ );
736
+ tinv_wishlist_template( 'ti-wishlist-null.php', $data );
737
+ }
738
+
739
+ /**
740
+ * Empty Wishlist
741
+ *
742
+ * @param array $products Products wishlist.
743
+ * @param array $wishlist Wishlist object.
744
+ */
745
+ function wishlist_empty( $products = array(), $wishlist = array() ) {
746
+ $data = array(
747
+ 'products' => $products,
748
+ 'wishlist' => $wishlist,
749
+ 'wishlist_table' => tinv_get_option( 'table' ),
750
+ );
751
+ tinv_wishlist_template( 'ti-wishlist-empty.php', $data );
752
+ }
753
+
754
+ /**
755
+ * Header Wishlist
756
+ *
757
+ * @param array $wishlist Wishlist object.
758
+ */
759
+ function wishlist_header( $wishlist ) {
760
+
761
+ $data = array(
762
+ 'wishlist' => $wishlist,
763
+ );
764
+ tinv_wishlist_template( 'ti-wishlist-header.php', $data );
765
+ }
766
+
767
+ /**
768
+ * Prev page button
769
+ */
770
+ function page_prev() {
771
+ $paged = get_query_var( 'wl_paged', 1 );
772
+ $paged = 1 < $paged ? $paged - 1 : 0;
773
+ $this->page( $paged, sprintf( '<i class="ftinvwl ftinvwl-chevron-left"></i><span>%s</span>', __( 'Previous Page', 'ti-woocommerce-wishlist' ) ), array( 'class' => 'button tinv-prev' ) );
774
+ }
775
+
776
+ /**
777
+ * Pages
778
+ */
779
+ function pages() {
780
+
781
+ $paged = get_query_var( 'wl_paged', 1 );
782
+ if ( 1 === (int) $paged ) {
783
+ echo '<span></span>';
784
+ }
785
+
786
+ echo '<span>' . $paged . '/' . $this->pages . '</span>';
787
+
788
+ if ( (int) $this->pages === (int) $paged ) {
789
+ echo '<span></span>';
790
+ }
791
+ }
792
+
793
+ /**
794
+ * Next page button
795
+ */
796
+ function page_next() {
797
+ $paged = get_query_var( 'wl_paged', 1 );
798
+ $paged = 1 < $paged ? $paged + 1 : 2;
799
+ $this->page( $paged, sprintf( '<span>%s</span><i class="ftinvwl ftinvwl-chevron-right"></i>', __( 'Next Page', 'ti-woocommerce-wishlist' ) ), array( 'class' => 'button tinv-next' ) );
800
+ }
801
+
802
+ /**
803
+ * Page button
804
+ *
805
+ * @param integer $paged Index page.
806
+ * @param string $text Text button.
807
+ * @param style $style Style attribute.
808
+ */
809
+ function page( $paged, $text, $style = array() ) {
810
+ $paged = absint( $paged );
811
+ $wishlist = $this->get_current_wishlist();
812
+ $link = tinv_url_wishlist( $wishlist['share_key'], $paged, true );
813
+ if ( is_array( $style ) ) {
814
+ $style = TInvWL_Form::__atrtostr( $style );
815
+ }
816
+ printf( '<a href="%s" %s>%s</a>', esc_url( $link ), $style, $text ); // WPCS: xss ok.
817
+ }
818
+
819
+ /**
820
+ * Shortcode basic function
821
+ *
822
+ * @param array $atts Array parameter from shortcode.
823
+ *
824
+ * @return string
825
+ */
826
+ function shortcode( $atts = array() ) {
827
+ $default = array(
828
+ 'lists_per_page' => 10,
829
+ );
830
+ $atts = shortcode_atts( $default, $atts );
831
+
832
+ ob_start();
833
+ $this->htmloutput( $atts );
834
+
835
+ return ob_get_clean();
836
+ }
837
+
838
+ /**
839
+ * Get per page items for buttons
840
+ */
841
+ function get_per_page() {
842
+ if ( ! empty( $this->lists_per_page ) ) {
843
+ echo TInvWL_Form::_text( array( // WPCS: xss ok.
844
+ 'type' => 'hidden',
845
+ 'name' => 'lists_per_page',
846
+ ), $this->lists_per_page );
847
+ }
848
+ }
849
+ }
public/wishlistcounter.class.php CHANGED
@@ -160,8 +160,7 @@ class TInvWL_Public_WishlistCounter {
160
  'post_mime_type' => '',
161
  );
162
 
163
-
164
- foreach ( $items as $key => $item ) {
165
 
166
  if ( $items[ $key ]->menu_order > ( $menu_order - 1 ) ) {
167
  $items[ $key ]->menu_order = $items[ $key ]->menu_order + 1;
160
  'post_mime_type' => '',
161
  );
162
 
163
+ foreach ( array_keys( $items ) as $key ) {
 
164
 
165
  if ( $items[ $key ]->menu_order > ( $menu_order - 1 ) ) {
166
  $items[ $key ]->menu_order = $items[ $key ]->menu_order + 1;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://templateinvaders.com/product/ti-woocommerce-wishlist-wordpr
4
  Tags: wishlist, woocommerce, woocommerce wishlist, e-commerce, ecommerce
5
  Requires at least: 4.5
6
  Tested up to: 5.1
7
- Stable tag: 1.11.1
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -140,6 +140,13 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
140
 
141
 
142
  == Changelog ==
 
 
 
 
 
 
 
143
  = 1.11.1 =
144
  *Release Date - 19 April 2019*
145
 
4
  Tags: wishlist, woocommerce, woocommerce wishlist, e-commerce, ecommerce
5
  Requires at least: 4.5
6
  Tested up to: 5.1
7
+ Stable tag: 1.12.0
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
140
 
141
 
142
  == Changelog ==
143
+ = 1.12.0 =
144
+ *Release Date - 22 April 2019*
145
+
146
+ * Greatly improved frontend performance
147
+ * Fixed wishlist analytics issues
148
+ * Code cleanup
149
+
150
  = 1.11.1 =
151
  *Release Date - 19 April 2019*
152
 
templates/ti-wishlist-user.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * The Template for displaying wishlist if a current user not an owner.
4
  *
5
- * @version 1.11.0
6
  * @package TInvWishlist\Template
7
  */
8
 
@@ -18,7 +18,7 @@ wp_enqueue_script( 'tinvwl' );
18
  } ?>
19
  <?php
20
  $wl_paged = get_query_var( 'wl_paged' );
21
- $form_url = ( $wl_paged ) ? add_query_arg( 'wl_paged', $wl_paged, tinv_url_wishlist() ) : tinv_url_wishlist();
22
  ?>
23
  <form action="<?php echo esc_url( $form_url ); ?>" method="post" autocomplete="off">
24
  <?php do_action( 'tinvwl_before_wishlist_table', $wishlist ); ?>
2
  /**
3
  * The Template for displaying wishlist if a current user not an owner.
4
  *
5
+ * @version 1.12.0
6
  * @package TInvWishlist\Template
7
  */
8
 
18
  } ?>
19
  <?php
20
  $wl_paged = get_query_var( 'wl_paged' );
21
+ $form_url = tinv_url_wishlist( $wishlist['share_key'], $wl_paged, true );
22
  ?>
23
  <form action="<?php echo esc_url( $form_url ); ?>" method="post" autocomplete="off">
24
  <?php do_action( 'tinvwl_before_wishlist_table', $wishlist ); ?>
templates/ti-wishlist.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * The Template for displaying wishlist if a current user is owner.
4
  *
5
- * @version 1.11.0
6
  * @package TInvWishlist\Template
7
  */
8
 
@@ -18,7 +18,7 @@ wp_enqueue_script( 'tinvwl' );
18
  } ?>
19
  <?php
20
  $wl_paged = get_query_var( 'wl_paged' );
21
- $form_url = ( $wl_paged ) ? add_query_arg( 'wl_paged', $wl_paged, tinv_url_wishlist() ) : tinv_url_wishlist();
22
  ?>
23
  <form action="<?php echo esc_url( $form_url ); ?>" method="post" autocomplete="off">
24
  <?php do_action( 'tinvwl_before_wishlist_table', $wishlist ); ?>
2
  /**
3
  * The Template for displaying wishlist if a current user is owner.
4
  *
5
+ * @version 1.12.0
6
  * @package TInvWishlist\Template
7
  */
8
 
18
  } ?>
19
  <?php
20
  $wl_paged = get_query_var( 'wl_paged' );
21
+ $form_url = tinv_url_wishlist( $wishlist['share_key'], $wl_paged, true );
22
  ?>
23
  <form action="<?php echo esc_url( $form_url ); ?>" method="post" autocomplete="off">
24
  <?php do_action( 'tinvwl_before_wishlist_table', $wishlist ); ?>
ti-woocommerce-wishlist.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: TI WooCommerce Wishlist Plugin
5
  * Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
6
  * Description: Wishlist functionality for your WooCommerce store.
7
- * Version: 1.11.1
8
  * Requires at least: 4.5
9
  * Tested up to: 5.1
10
  * WC requires at least: 2.6
@@ -41,7 +41,7 @@ if ( ! defined( 'TINVWL_DOMAIN' ) ) {
41
  }
42
 
43
  if ( ! defined( 'TINVWL_FVERSION' ) ) {
44
- define( 'TINVWL_FVERSION', '1.11.1' );
45
  }
46
 
47
  if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
4
  * Plugin Name: TI WooCommerce Wishlist Plugin
5
  * Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
6
  * Description: Wishlist functionality for your WooCommerce store.
7
+ * Version: 1.12.0
8
  * Requires at least: 4.5
9
  * Tested up to: 5.1
10
  * WC requires at least: 2.6
41
  }
42
 
43
  if ( ! defined( 'TINVWL_FVERSION' ) ) {
44
+ define( 'TINVWL_FVERSION', '1.12.0' );
45
  }
46
 
47
  if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
tinv-wishlists-function-integration.php CHANGED
@@ -66,7 +66,7 @@ if ( ! function_exists( 'tinvwl_wp_fastest_cache_reject' ) ) {
66
 
67
  $rules_std = json_decode( $rules_json, true );
68
  $ex_pages = array();
69
- foreach ( $rules_std as $key => $value ) {
70
  $value['type'] = isset( $value['type'] ) ? $value['type'] : 'page';
71
  if ( 'page' === $value['type'] ) {
72
  $ex_pages[] = $value['content'];
@@ -422,15 +422,14 @@ if ( ! function_exists( 'tinvwl_gift_card_add' ) ) {
422
  * @return boolean
423
  */
424
  function tinvwl_gift_card_add( $redirect, $product ) {
425
- if ( $redirect ) {
426
- return true;
427
- }
428
- $is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
429
 
430
- if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
431
- $is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
432
- if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
433
- return true;
 
434
  }
435
  }
436
 
@@ -452,12 +451,14 @@ if ( ! function_exists( 'tinvwl_gift_card_add_url' ) ) {
452
  * @return boolean
453
  */
454
  function tinvwl_gift_card_add_url( $redirect_url, $product ) {
455
- $is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
 
456
 
457
- if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
458
- $is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
459
- if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
460
- return $product->get_permalink();
 
461
  }
462
  }
463
 
@@ -477,27 +478,29 @@ if ( ! function_exists( 'tinv_wishlist_meta_support_rpgiftcards' ) ) {
477
  * @return array
478
  */
479
  function tinv_wishlist_metasupport_rpgiftcards( $meta ) {
480
- foreach ( $meta as $key => $data ) {
481
- switch ( $data['key'] ) {
482
- case 'rpgc_note':
483
- $meta[ $key ]['key'] = __( 'Note', 'ti-woocommerce-wishlist' );
484
- break;
485
- case 'rpgc_to':
486
- $meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_to' ) <> null ? get_option( 'woocommerce_giftcard_to' ) : __( 'To', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
487
- break;
488
- case 'rpgc_to_email':
489
- $meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_toEmail' ) <> null ? get_option( 'woocommerce_giftcard_toEmail' ) : __( 'To Email', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
490
- break;
491
- case 'rpgc_address':
492
- $meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_address' ) <> null ? get_option( 'woocommerce_giftcard_address' ) : __( 'Address', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
493
- break;
494
- case 'rpgc_reload_card':
495
- $meta[ $key ]['key'] = __( 'Reload existing Gift Card', 'ti-woocommerce-wishlist' );
496
- break;
497
- case 'rpgc_description':
498
- case 'rpgc_reload_check':
499
- unset( $meta[ $key ] );
500
- break;
 
 
501
  }
502
  }
503
 
@@ -517,10 +520,12 @@ if ( ! function_exists( 'tinv_wishlist_metaprepare_rpgiftcards' ) ) {
517
  * @return array
518
  */
519
  function tinv_wishlist_metaprepare_rpgiftcards( $meta ) {
520
- if ( array_key_exists( 'rpgc_reload_check', $meta ) ) {
521
- foreach ( array( 'rpgc_note', 'rpgc_to', 'rpgc_to_email', 'rpgc_address' ) as $value ) {
522
- if ( array_key_exists( $value, $meta ) ) {
523
- unset( $meta[ $value ] );
 
 
524
  }
525
  }
526
  }
@@ -593,8 +598,6 @@ if ( ! function_exists( 'tinvwl_item_price_woocommerce_bookings' ) ) {
593
  return $price;
594
  }
595
 
596
- $tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
597
-
598
  if ( 'incl' === get_option( 'woocommerce_tax_display_shop' ) ) {
599
  if ( function_exists( 'wc_get_price_excluding_tax' ) ) {
600
  $display_price = wc_get_price_including_tax( $product, array( 'price' => $cost ) );
@@ -875,7 +878,6 @@ if ( ! function_exists( 'tinvwl_row_woocommerce_product_bundles' ) ) {
875
  */
876
  function tinvwl_row_woocommerce_product_bundles( $wl_product, $product ) {
877
  if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
878
- $product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
879
 
880
  $product_id = WC_PB_Core_Compatibility::get_id( $product );
881
  $bundled_items = $product->get_bundled_items();
@@ -1910,7 +1912,7 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_fields' ) )
1910
  // Get fields to save values for
1911
  $fields = WCCF_Product_Field_Controller::get_filtered( null, array(
1912
  'item_id' => $product_id,
1913
- 'child_id' => $variation_id
1914
  ) );
1915
 
1916
  // Set quantity
@@ -2104,11 +2106,11 @@ if ( ! function_exists( 'oceanwp_fix_archive_markup' ) ) {
2104
  }
2105
  }
2106
 
2107
- // Google Tag Manager for Wordpress compatibility.
2108
  if ( ! function_exists( 'tinv_wishlist_metaprepare_gtm4wp' ) ) {
2109
 
2110
  /**
2111
- * Prepare save meta for WooCommerce - Google Tag Manager for Wordpress
2112
  *
2113
  * @param array $meta Meta array.
2114
  *
@@ -2116,7 +2118,7 @@ if ( ! function_exists( 'tinv_wishlist_metaprepare_gtm4wp' ) ) {
2116
  */
2117
  function tinv_wishlist_metaprepare_gtm4wp( $meta ) {
2118
 
2119
- foreach ( $meta as $key => $value ) {
2120
  if ( strpos( $key, 'gtm4wp_' ) === 0 ) {
2121
  unset( $meta[ $key ] );
2122
  }
@@ -2176,7 +2178,7 @@ if ( ! function_exists( 'tinv_wishlist_qty_woo_advanced_url' ) ) {
2176
  $args = $advanced_qty->qty_input_args( array(
2177
  'min_value' => 1,
2178
  'max_value' => '',
2179
- 'step' => 1
2180
  ), $product );
2181
 
2182
  $url = preg_replace( '/&quantity=[0-9.]*/', '', $url );
@@ -2221,7 +2223,7 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_product_addo
2221
  'include' => $post_ids,
2222
  'fields' => 'ids',
2223
  'post_type' => WCPA_POST_TYPE,
2224
- 'posts_per_page' => - 1
2225
  ) );
2226
  }
2227
  }
@@ -2236,7 +2238,7 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_product_addo
2236
  }
2237
 
2238
 
2239
- foreach ( $data as $k => $v ) {
2240
 
2241
  $form_data = clone $v;
2242
  unset( $form_data->values ); //avoid saving large number of data
@@ -2250,7 +2252,7 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_product_addo
2250
  if ( is_array( $item_data[ $v->name ] ) ) {
2251
 
2252
  $_values = $item_data[ $v->name ];
2253
- array_walk( $_values, function ( &$a, $b ) {
2254
  sanitize_text_field( $a );
2255
  } ); // using this array_wal method to preserve the keys
2256
  $value = $_values;
@@ -2267,7 +2269,7 @@ if ( ! function_exists( 'tinv_wishlist_item_meta_woocommerce_custom_product_addo
2267
  'label' => ( isset( $v->label ) ) ? $v->label : '',
2268
  'value' => $value['display'],
2269
  'price' => false,
2270
- 'form_data' => $form_data
2271
  ) );
2272
  }
2273
  }
@@ -2335,7 +2337,7 @@ if ( defined( 'myCRED_VERSION' ) ) {
2335
  $installed['tinvwl'] = array(
2336
  'title' => __( 'WooCommerce Wishlist', 'ti-woocommerce-wishlist' ),
2337
  'description' => __( 'Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist.', 'ti-woocommerce-wishlist' ),
2338
- 'callback' => array( 'myCRED_Hook_TinvWL' )
2339
  );
2340
 
2341
  return $installed;
@@ -2371,9 +2373,9 @@ if ( defined( 'myCRED_VERSION' ) ) {
2371
  'tinvwl_purchased' => array(
2372
  'creds' => 1,
2373
  'log' => '%plural% for purchasing a product from a wishlist',
2374
- 'limit' => '0/x'
2375
  ),
2376
- )
2377
  ), $hook_prefs, $type );
2378
 
2379
  }
@@ -2469,7 +2471,6 @@ if ( defined( 'myCRED_VERSION' ) ) {
2469
 
2470
  }
2471
 
2472
-
2473
  }
2474
 
2475
  /**
@@ -2550,7 +2551,7 @@ if ( defined( 'myCRED_VERSION' ) ) {
2550
  'limit'
2551
  ) ), $this->field_id( array(
2552
  'tinvwl_purchased',
2553
- 'limit'
2554
  ) ), $prefs['tinvwl_purchased']['limit'] ); ?>
2555
  </div>
2556
  </div>
@@ -2566,7 +2567,7 @@ if ( defined( 'myCRED_VERSION' ) ) {
2566
  class="form-control"/>
2567
  <span class="description"><?php echo $this->available_template_tags( array(
2568
  'general',
2569
- 'post'
2570
  ) ); ?></span>
2571
  </div>
2572
  </div>
66
 
67
  $rules_std = json_decode( $rules_json, true );
68
  $ex_pages = array();
69
+ foreach ( $rules_std as $value ) {
70
  $value['type'] = isset( $value['type'] ) ? $value['type'] : 'page';
71
  if ( 'page' === $value['type'] ) {
72
  $ex_pages[] = $value['content'];
422
  * @return boolean
423
  */
424
  function tinvwl_gift_card_add( $redirect, $product ) {
425
+ if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
426
+ $is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
 
 
427
 
428
+ if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
429
+ $is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
430
+ if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
431
+ return true;
432
+ }
433
  }
434
  }
435
 
451
  * @return boolean
452
  */
453
  function tinvwl_gift_card_add_url( $redirect_url, $product ) {
454
+ if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
455
+ $is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
456
 
457
+ if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
458
+ $is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
459
+ if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
460
+ return $product->get_permalink();
461
+ }
462
  }
463
  }
464
 
478
  * @return array
479
  */
480
  function tinv_wishlist_metasupport_rpgiftcards( $meta ) {
481
+ if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
482
+ foreach ( $meta as $key => $data ) {
483
+ switch ( $data['key'] ) {
484
+ case 'rpgc_note':
485
+ $meta[ $key ]['key'] = __( 'Note', 'ti-woocommerce-wishlist' );
486
+ break;
487
+ case 'rpgc_to':
488
+ $meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_to' ) <> null ? get_option( 'woocommerce_giftcard_to' ) : __( 'To', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
489
+ break;
490
+ case 'rpgc_to_email':
491
+ $meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_toEmail' ) <> null ? get_option( 'woocommerce_giftcard_toEmail' ) : __( 'To Email', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
492
+ break;
493
+ case 'rpgc_address':
494
+ $meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_address' ) <> null ? get_option( 'woocommerce_giftcard_address' ) : __( 'Address', 'ti-woocommerce-wishlist' ) ); // WPCS: loose comparison ok.
495
+ break;
496
+ case 'rpgc_reload_card':
497
+ $meta[ $key ]['key'] = __( 'Reload existing Gift Card', 'ti-woocommerce-wishlist' );
498
+ break;
499
+ case 'rpgc_description':
500
+ case 'rpgc_reload_check':
501
+ unset( $meta[ $key ] );
502
+ break;
503
+ }
504
  }
505
  }
506
 
520
  * @return array
521
  */
522
  function tinv_wishlist_metaprepare_rpgiftcards( $meta ) {
523
+ if ( class_exists( 'KODIAK_GIFTCARDS' ) ) {
524
+ if ( array_key_exists( 'rpgc_reload_check', $meta ) ) {
525
+ foreach ( array( 'rpgc_note', 'rpgc_to', 'rpgc_to_email', 'rpgc_address' ) as $value ) {
526
+ if ( array_key_exists( $value, $meta ) ) {
527
+ unset( $meta[ $value ] );
528
+ }
529
  }
530
  }
531
  }
598
  return $price;
599
  }
600
 
 
 
601
  if ( 'incl' === get_option( 'woocommerce_tax_display_shop' ) ) {
602
  if ( function_exists( 'wc_get_price_excluding_tax' ) ) {
603
  $display_price = wc_get_price_including_tax( $product, array( 'price' => $cost ) );
878
  */
879
  function tinvwl_row_woocommerce_product_bundles( $wl_product, $product ) {
880
  if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
 
881
 
882
  $product_id = WC_PB_Core_Compatibility::get_id( $product );
883
  $bundled_items = $product->get_bundled_items();
1912
  // Get fields to save values for
1913
  $fields = WCCF_Product_Field_Controller::get_filtered( null, array(
1914
  'item_id' => $product_id,
1915
+ 'child_id' => $variation_id,
1916
  ) );
1917
 
1918
  // Set quantity
2106
  }
2107
  }
2108
 
2109
+ // Google Tag Manager for WordPress compatibility.
2110
  if ( ! function_exists( 'tinv_wishlist_metaprepare_gtm4wp' ) ) {
2111
 
2112
  /**
2113
+ * Prepare save meta for WooCommerce - Google Tag Manager for WordPress
2114
  *
2115
  * @param array $meta Meta array.
2116
  *
2118
  */
2119
  function tinv_wishlist_metaprepare_gtm4wp( $meta ) {
2120
 
2121
+ foreach ( array_keys( $meta ) as $key ) {
2122
  if ( strpos( $key, 'gtm4wp_' ) === 0 ) {
2123
  unset( $meta[ $key ] );
2124
  }
2178
  $args = $advanced_qty->qty_input_args( array(
2179
  'min_value' => 1,
2180
  'max_value' => '',
2181
+ 'step' => 1,
2182
  ), $product );
2183
 
2184
  $url = preg_replace( '/&quantity=[0-9.]*/', '', $url );
2223
  'include' => $post_ids,
2224
  'fields' => 'ids',
2225
  'post_type' => WCPA_POST_TYPE,
2226
+ 'posts_per_page' => - 1,
2227
  ) );
2228
  }
2229
  }
2238
  }
2239
 
2240
 
2241
+ foreach ( $data as $v ) {
2242
 
2243
  $form_data = clone $v;
2244
  unset( $form_data->values ); //avoid saving large number of data
2252
  if ( is_array( $item_data[ $v->name ] ) ) {
2253
 
2254
  $_values = $item_data[ $v->name ];
2255
+ array_walk( $_values, function ( &$a ) {
2256
  sanitize_text_field( $a );
2257
  } ); // using this array_wal method to preserve the keys
2258
  $value = $_values;
2269
  'label' => ( isset( $v->label ) ) ? $v->label : '',
2270
  'value' => $value['display'],
2271
  'price' => false,
2272
+ 'form_data' => $form_data,
2273
  ) );
2274
  }
2275
  }
2337
  $installed['tinvwl'] = array(
2338
  'title' => __( 'WooCommerce Wishlist', 'ti-woocommerce-wishlist' ),
2339
  'description' => __( 'Awards %_plural% for users adding products to their wishlist and purchased products from their wishlist.', 'ti-woocommerce-wishlist' ),
2340
+ 'callback' => array( 'myCRED_Hook_TinvWL' ),
2341
  );
2342
 
2343
  return $installed;
2373
  'tinvwl_purchased' => array(
2374
  'creds' => 1,
2375
  'log' => '%plural% for purchasing a product from a wishlist',
2376
+ 'limit' => '0/x',
2377
  ),
2378
+ ),
2379
  ), $hook_prefs, $type );
2380
 
2381
  }
2471
 
2472
  }
2473
 
 
2474
  }
2475
 
2476
  /**
2551
  'limit'
2552
  ) ), $this->field_id( array(
2553
  'tinvwl_purchased',
2554
+ 'limit',
2555
  ) ), $prefs['tinvwl_purchased']['limit'] ); ?>
2556
  </div>
2557
  </div>
2567
  class="form-control"/>
2568
  <span class="description"><?php echo $this->available_template_tags( array(
2569
  'general',
2570
+ 'post',
2571
  ) ); ?></span>
2572
  </div>
2573
  </div>
tinv-wishlists-function.php CHANGED
@@ -401,7 +401,6 @@ if ( ! function_exists( 'tinv_url_wishlist_by_key' ) ) {
401
  }
402
  }
403
 
404
-
405
  return $link;
406
  }
407
  } // End if().
401
  }
402
  }
403
 
 
404
  return $link;
405
  }
406
  } // End if().