CTX Feed – WooCommerce Product Feed Manager Plugin - Version 3.2.11

Version Description

(2020-01-08) = * Fix logging class not found error. * Update Feed Save Message * Fix Save success message

Download this release

Release Info

Developer wahid0003
Plugin Icon 128x128 CTX Feed – WooCommerce Product Feed Manager Plugin
Version 3.2.11
Comparing to
See all releases

Code changes from version 3.2.10 to 3.2.11

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags:woocommerce,google product feed,facebook product feed,woocommerce product f
5
  Requires at least: 3.6
6
  Tested Up To: 5.4-alpha-46743
7
  Requires PHP: 5.6
8
- Stable tag: 3.2.10
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -305,6 +305,11 @@ Using pro version:
305
 
306
  == Changelog ==
307
 
 
 
 
 
 
308
  = 3.2.10 (2020-01-07) =
309
  * New Hook added before and after product loop.
310
  * Sanitize ajax & optimize request for admin notices.
5
  Requires at least: 3.6
6
  Tested Up To: 5.4-alpha-46743
7
  Requires PHP: 5.6
8
+ Stable tag: 3.2.11
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
305
 
306
  == Changelog ==
307
 
308
+ = 3.2.11 (2020-01-08) =
309
+ * Fix logging class not found error.
310
+ * Update Feed Save Message
311
+ * Fix Save success message
312
+
313
  = 3.2.10 (2020-01-07) =
314
  * New Hook added before and after product loop.
315
  * Sanitize ajax & optimize request for admin notices.
admin/class-woo-feed-admin.php CHANGED
@@ -127,10 +127,15 @@ class Woo_Feed_Admin
127
  wp_register_script($this->woo_feed, plugin_dir_url(__FILE__) . 'js/woo-feed-admin.js', $feedScriptDependency, $this->version, false);
128
 
129
  wp_localize_script($this->woo_feed, 'wpf_ajax_obj', array(
130
- 'wpf_ajax_url' => admin_url('admin-ajax.php'),
131
- 'nonce' => wp_create_nonce('wpf_feed_nonce'),
132
- 'na' => esc_html__( 'N/A', 'woo-feed' ),
133
- 'regenerate' => esc_html__( 'Generating...', 'woo-feed' ),
 
 
 
 
 
134
  ));
135
 
136
  wp_enqueue_script($this->woo_feed);
127
  wp_register_script($this->woo_feed, plugin_dir_url(__FILE__) . 'js/woo-feed-admin.js', $feedScriptDependency, $this->version, false);
128
 
129
  wp_localize_script($this->woo_feed, 'wpf_ajax_obj', array(
130
+ 'wpf_ajax_url' => admin_url( 'admin-ajax.php' ),
131
+ 'nonce' => wp_create_nonce( 'wpf_feed_nonce' ),
132
+ 'na' => esc_html__( 'N/A', 'woo-feed' ),
133
+ 'regenerate' => esc_html__( 'Generating...', 'woo-feed' ),
134
+ 'form' => [
135
+ 'loading_tmpl' => esc_html__( 'Loading Template...', 'woo-feed' ),
136
+ 'generate' => esc_html__( 'Delivering Configuration...', 'woo-feed' ),
137
+ 'save' => esc_html__( 'Saving Configuration...', 'woo-feed' ),
138
+ ],
139
  ));
140
 
141
  wp_enqueue_script($this->woo_feed);
admin/js/woo-feed-admin.js CHANGED
@@ -237,20 +237,23 @@
237
  $(this).validate();
238
  if ($(this).valid()) {
239
  // noinspection SpellCheckingInspection
240
- $(".makeFeedResponse").show().html("<b style='color: darkblue;'><i class='dashicons dashicons-sos wpf_spin'></i> Delivering Configuration...</b>");
241
  }
242
  });
243
 
244
  // Generate Update Feed Form Submit
245
  // noinspection SpellCheckingInspection
246
  $(".updatefeed").validate();
247
- $(document).on('submit', '#updatefeed', function () {
248
- //event.preventDefault();
 
 
 
249
  // Feed Generating form validation
250
  $(this).validate();
251
  if ($(this).valid()) {
252
  // noinspection SpellCheckingInspection
253
- $(".makeFeedResponse").show().html("<b style='color: darkblue;'><i class='dashicons dashicons-sos wpf_spin'></i> Delivering Configuration...</b>");
254
  }
255
  });
256
 
@@ -336,7 +339,7 @@
336
  feedForm = $("#providerPage"),
337
  merchantInfo = $('#feed_merchant_info');
338
  // set loading..
339
- feedForm.html('<h3><span style="float:none;margin: -3px 0 0;" class="spinner is-active"></span> Loading Template...');
340
  merchantInfo.find( '.spinner' ).addClass( 'is-active' );
341
  feedType.disabled( !0 ); // disable dropdown
342
  feedType.parent().find('.spinner').addClass( 'is-active' );
@@ -345,7 +348,7 @@
345
  if( merchantInfoCache.hasOwnProperty( merchant ) ) {
346
  feedEditor.renderMerchantInfo( merchantInfo, feedType, merchantInfoCache[merchant] );
347
  } else {
348
- wp.ajax.send( 'woo_feed_get_merchant_info', {
349
  type: 'GET',
350
  data: { nonce: opts.nonce, action: "get_feed_merchant", provider: merchant }
351
  } ).then( function( r ) {
@@ -357,7 +360,7 @@
357
  if( merchantTemplateCache.hasOwnProperty( merchant ) ) {
358
  feedEditor.renderMerchantTemplate( feedForm, merchantTemplateCache[merchant] );
359
  } else {
360
- wp.ajax.post( 'get_feed_merchant', {
361
  _ajax_nonce: opts.nonce, action: "get_feed_merchant", merchant: merchant
362
  }, )
363
  .then( function( r ) {
@@ -376,7 +379,7 @@
376
  $('.woo_feed_status_input').on('change',function(){
377
  // noinspection ES6ConvertVarToLetConst
378
  var $feedName = $(this).val(), counter = ( $(this)[0].checked ) ? 1 : 0;
379
- wp.ajax.post( 'update_feed_status', { _ajax_nonce: opts.nonce, feedName: $feedName, status: counter }, );
380
  });
381
 
382
  // Adding for Copy-to-Clipboard functionality in the settings page
237
  $(this).validate();
238
  if ($(this).valid()) {
239
  // noinspection SpellCheckingInspection
240
+ $(".makeFeedResponse").show().html( '<b style="color: darkblue;"><i class="dashicons dashicons-sos wpf_spin"></i> '+opts.form.generate+'</b>' );
241
  }
242
  });
243
 
244
  // Generate Update Feed Form Submit
245
  // noinspection SpellCheckingInspection
246
  $(".updatefeed").validate();
247
+ $('[name="save_feed_config"]').on( 'click', function( e ) {
248
+ e.preventDefault();
249
+ $('#updatefeed').trigger( 'submit', { save: true } );
250
+ } );
251
+ $(document).on('submit', '#updatefeed', function ( e, data ) {
252
  // Feed Generating form validation
253
  $(this).validate();
254
  if ($(this).valid()) {
255
  // noinspection SpellCheckingInspection
256
+ $(".makeFeedResponse").show().html( '<b style="color: darkblue;"><i class="dashicons dashicons-sos wpf_spin"></i> '+ ( data && data.save ? opts.form.save : opts.form.generate ) +'</b>' );
257
  }
258
  });
259
 
339
  feedForm = $("#providerPage"),
340
  merchantInfo = $('#feed_merchant_info');
341
  // set loading..
342
+ feedForm.html('<h3><span style="float:none;margin: -3px 0 0;" class="spinner is-active"></span> '+opts.form.loading_tmpl+'</h3>');
343
  merchantInfo.find( '.spinner' ).addClass( 'is-active' );
344
  feedType.disabled( !0 ); // disable dropdown
345
  feedType.parent().find('.spinner').addClass( 'is-active' );
348
  if( merchantInfoCache.hasOwnProperty( merchant ) ) {
349
  feedEditor.renderMerchantInfo( merchantInfo, feedType, merchantInfoCache[merchant] );
350
  } else {
351
+ wpAjax.send( 'woo_feed_get_merchant_info', {
352
  type: 'GET',
353
  data: { nonce: opts.nonce, action: "get_feed_merchant", provider: merchant }
354
  } ).then( function( r ) {
360
  if( merchantTemplateCache.hasOwnProperty( merchant ) ) {
361
  feedEditor.renderMerchantTemplate( feedForm, merchantTemplateCache[merchant] );
362
  } else {
363
+ wpAjax.post( 'get_feed_merchant', {
364
  _ajax_nonce: opts.nonce, action: "get_feed_merchant", merchant: merchant
365
  }, )
366
  .then( function( r ) {
379
  $('.woo_feed_status_input').on('change',function(){
380
  // noinspection ES6ConvertVarToLetConst
381
  var $feedName = $(this).val(), counter = ( $(this)[0].checked ) ? 1 : 0;
382
+ wpAjax.post( 'update_feed_status', { _ajax_nonce: opts.nonce, feedName: $feedName, status: counter }, );
383
  });
384
 
385
  // Adding for Copy-to-Clipboard functionality in the settings page
includes/class-woo-feed.php CHANGED
@@ -91,6 +91,10 @@ class Woo_Feed
91
  * @access private
92
  */
93
  private function load_dependencies() {
 
 
 
 
94
  /**
95
  * Support for older version of WooCommerce
96
  */
91
  * @access private
92
  */
93
  private function load_dependencies() {
94
+ /**
95
+ * Load Error Logger File Handler
96
+ */
97
+ require_once WOO_FEED_FREE_PATH . 'includes/classes/class-woo-feed-log-handler-file.php';
98
  /**
99
  * Support for older version of WooCommerce
100
  */
includes/classes/class-woo-feed-log-handler-file.php ADDED
@@ -0,0 +1,436 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Log file handler
4
+ * @package WooFeed
5
+ * @subpackage LogHandler
6
+ * @version 1.0.0
7
+ * @since WooFeed 3.2.1
8
+ * @copyright 2019 WebAppick
9
+ * @author KD <mhaudul.hk@gmail.com>
10
+ *
11
+ */
12
+ if( ! defined( 'ABSPATH' ) ) die(); // Silence...
13
+
14
+ class Woo_Feed_Log_Handler_File extends WC_Log_Handler {
15
+
16
+ /**
17
+ * Stores open file handles.
18
+ *
19
+ * @var array
20
+ */
21
+ protected $handles = array();
22
+
23
+ /**
24
+ * File size limit for log files in bytes.
25
+ *
26
+ * @var int
27
+ */
28
+ protected $log_size_limit;
29
+
30
+ /**
31
+ * Cache logs that could not be written.
32
+ *
33
+ * If a log is written too early in the request, pluggable functions may be unavailable. These
34
+ * logs will be cached and written on 'plugins_loaded' action.
35
+ *
36
+ * @var array
37
+ */
38
+ protected $cached_logs = array();
39
+
40
+ /**
41
+ * Constructor for the logger.
42
+ *
43
+ * @param int $log_size_limit Optional. Size limit for log files. Default 5mb.
44
+ */
45
+ public function __construct( $log_size_limit = null ) {
46
+ if ( null === $log_size_limit ) {
47
+ $log_size_limit = 5 * 1024 * 1024;
48
+ }
49
+
50
+ $this->log_size_limit = apply_filters( 'woo_feed_log_file_size_limit', $log_size_limit );
51
+
52
+ add_action( 'plugins_loaded', array( $this, 'write_cached_logs' ) );
53
+ }
54
+
55
+ /**
56
+ * Destructor.
57
+ *
58
+ * Cleans up open file handles.
59
+ */
60
+ public function __destruct() {
61
+ foreach ( $this->handles as $handle ) {
62
+ if ( is_resource( $handle ) ) {
63
+ fclose( $handle ); // @codingStandardsIgnoreLine.
64
+ }
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Handle a log entry.
70
+ *
71
+ * @param int $timestamp Log timestamp.
72
+ * @param string $level emergency|alert|critical|error|warning|notice|info|debug.
73
+ * @param string $message Log message.
74
+ * @param array $context {
75
+ * Additional information for log handlers.
76
+ *
77
+ * @type string $source Optional. Determines log file to write to. Default 'log'.
78
+ * @type bool $_legacy Optional. Default false. True to use outdated log format
79
+ * originally used in deprecated WC_Logger::add calls.
80
+ * }
81
+ *
82
+ * @return bool False if value was not handled and true if value was handled.
83
+ */
84
+ public function handle( $timestamp, $level, $message, $context ) {
85
+
86
+ if ( isset( $context['source'] ) && $context['source'] ) {
87
+ $handle = $context['source'];
88
+ } else {
89
+ $handle = 'log';
90
+ }
91
+
92
+ $entry = self::format_entry( $timestamp, $level, $message, $context );
93
+
94
+ return $this->add( $entry, $handle );
95
+ }
96
+
97
+ /**
98
+ * Builds a log entry text from timestamp, level and message.
99
+ *
100
+ * @param int $timestamp Log timestamp.
101
+ * @param string $level emergency|alert|critical|error|warning|notice|info|debug.
102
+ * @param string $message Log message.
103
+ * @param array $context Additional information for log handlers.
104
+ *
105
+ * @return string Formatted log entry.
106
+ */
107
+ protected static function format_entry( $timestamp, $level, $message, $context ) {
108
+
109
+ if ( isset( $context['_legacy'] ) && true === $context['_legacy'] ) {
110
+ if ( isset( $context['source'] ) && $context['source'] ) {
111
+ $handle = $context['source'];
112
+ } else {
113
+ $handle = 'log';
114
+ }
115
+ $message = apply_filters( 'woo_feed_logger_add_message', $message, $handle );
116
+ $time = date_i18n( 'm-d-Y @ H:i:s' );
117
+ $entry = "{$time} - {$message}";
118
+ } else {
119
+ $entry = parent::format_entry( $timestamp, $level, $message, $context );
120
+ }
121
+
122
+ return $entry;
123
+ }
124
+
125
+ /**
126
+ * Open log file for writing.
127
+ *
128
+ * @param string $handle Log handle.
129
+ * @param string $mode Optional. File mode. Default 'a'.
130
+ * @return bool Success.
131
+ */
132
+ protected function open( $handle, $mode = 'a' ) {
133
+ if ( $this->is_open( $handle ) ) {
134
+ return true;
135
+ }
136
+
137
+ $file = self::get_log_file_path( $handle );
138
+
139
+ if ( $file ) {
140
+ if ( ! file_exists( $file ) ) {
141
+ $temphandle = @fopen( $file, 'w+' ); // @codingStandardsIgnoreLine.
142
+ @fclose( $temphandle ); // @codingStandardsIgnoreLine.
143
+
144
+ if ( defined( 'FS_CHMOD_FILE' ) ) {
145
+ @chmod( $file, FS_CHMOD_FILE ); // @codingStandardsIgnoreLine.
146
+ }
147
+ }
148
+
149
+ $resource = @fopen( $file, $mode ); // @codingStandardsIgnoreLine.
150
+
151
+ if ( $resource ) {
152
+ $this->handles[ $handle ] = $resource;
153
+ return true;
154
+ }
155
+ }
156
+
157
+ return false;
158
+ }
159
+
160
+ /**
161
+ * Check if a handle is open.
162
+ *
163
+ * @param string $handle Log handle.
164
+ * @return bool True if $handle is open.
165
+ */
166
+ protected function is_open( $handle ) {
167
+ return array_key_exists( $handle, $this->handles ) && is_resource( $this->handles[ $handle ] );
168
+ }
169
+
170
+ /**
171
+ * Close a handle.
172
+ *
173
+ * @param string $handle Log handle.
174
+ * @return bool success
175
+ */
176
+ protected function close( $handle ) {
177
+ $result = false;
178
+
179
+ if ( $this->is_open( $handle ) ) {
180
+ $result = fclose( $this->handles[ $handle ] ); // @codingStandardsIgnoreLine.
181
+ unset( $this->handles[ $handle ] );
182
+ }
183
+
184
+ return $result;
185
+ }
186
+
187
+ /**
188
+ * Add a log entry to chosen file.
189
+ *
190
+ * @param string $entry Log entry text.
191
+ * @param string $handle Log entry handle.
192
+ *
193
+ * @return bool True if write was successful.
194
+ */
195
+ protected function add( $entry, $handle ) {
196
+ $result = false;
197
+
198
+ if ( $this->should_rotate( $handle ) ) {
199
+ $this->log_rotate( $handle );
200
+ }
201
+
202
+ if ( $this->open( $handle ) && is_resource( $this->handles[ $handle ] ) ) {
203
+ $result = fwrite( $this->handles[ $handle ], $entry . PHP_EOL ); // @codingStandardsIgnoreLine.
204
+ } else {
205
+ $this->cache_log( $entry, $handle );
206
+ }
207
+
208
+ return false !== $result;
209
+ }
210
+
211
+ /**
212
+ * Clear entries from chosen file.
213
+ *
214
+ * @param string $handle Log handle.
215
+ *
216
+ * @return bool
217
+ */
218
+ public function clear( $handle ) {
219
+ $result = false;
220
+
221
+ // Close the file if it's already open.
222
+ $this->close( $handle );
223
+
224
+ /**
225
+ * $this->open( $handle, 'w' ) == Open the file for writing only. Place the file pointer at
226
+ * the beginning of the file, and truncate the file to zero length.
227
+ */
228
+ if ( $this->open( $handle, 'w' ) && is_resource( $this->handles[ $handle ] ) ) {
229
+ $result = true;
230
+ }
231
+
232
+ do_action( 'woo_feed_log_clear', $handle );
233
+
234
+ return $result;
235
+ }
236
+
237
+ /**
238
+ * Remove/delete the chosen file.
239
+ *
240
+ * @param string $handle Log handle.
241
+ *
242
+ * @return bool
243
+ */
244
+ public function remove( $handle ) {
245
+ $removed = false;
246
+ $logs = $this->get_log_files();
247
+ $handle = sanitize_title( $handle );
248
+ if ( isset( $logs[ $handle ] ) && $logs[ $handle ] ) {
249
+ $file = realpath( trailingslashit( WOO_FEED_LOG_DIR ) . $logs[ $handle ] );
250
+ if ( 0 === stripos( $file, realpath( trailingslashit( WOO_FEED_LOG_DIR ) ) ) && is_file( $file ) && is_writable( $file ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable
251
+ $this->close( $file ); // Close first to be certain no processes keep it alive after it is unlinked.
252
+ $removed = unlink( $file ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink
253
+ }
254
+ do_action( 'woo_feed_log_remove', $handle, $removed );
255
+ }
256
+ return $removed;
257
+ }
258
+
259
+ /**
260
+ * Check if log file should be rotated.
261
+ *
262
+ * Compares the size of the log file to determine whether it is over the size limit.
263
+ *
264
+ * @param string $handle Log handle.
265
+ * @return bool True if if should be rotated.
266
+ */
267
+ protected function should_rotate( $handle ) {
268
+ $file = self::get_log_file_path( $handle );
269
+ if ( $file ) {
270
+ if ( $this->is_open( $handle ) ) {
271
+ $file_stat = fstat( $this->handles[ $handle ] );
272
+ return $file_stat['size'] > $this->log_size_limit;
273
+ } elseif ( file_exists( $file ) ) {
274
+ return filesize( $file ) > $this->log_size_limit;
275
+ } else {
276
+ return false;
277
+ }
278
+ } else {
279
+ return false;
280
+ }
281
+ }
282
+
283
+ /**
284
+ * Rotate log files.
285
+ *
286
+ * Logs are rotated by prepending '.x' to the '.log' suffix.
287
+ * The current log plus 10 historical logs are maintained.
288
+ * For example:
289
+ * base.9.log -> [ REMOVED ]
290
+ * base.8.log -> base.9.log
291
+ * ...
292
+ * base.0.log -> base.1.log
293
+ * base.log -> base.0.log
294
+ *
295
+ * @param string $handle Log handle.
296
+ */
297
+ protected function log_rotate( $handle ) {
298
+ for ( $i = 8; $i >= 0; $i-- ) {
299
+ $this->increment_log_infix( $handle, $i );
300
+ }
301
+ $this->increment_log_infix( $handle );
302
+ }
303
+
304
+ /**
305
+ * Increment a log file suffix.
306
+ *
307
+ * @param string $handle Log handle.
308
+ * @param null|int $number Optional. Default null. Log suffix number to be incremented.
309
+ * @return bool True if increment was successful, otherwise false.
310
+ */
311
+ protected function increment_log_infix( $handle, $number = null ) {
312
+ if ( null === $number ) {
313
+ $suffix = '';
314
+ $next_suffix = '.0';
315
+ } else {
316
+ $suffix = '.' . $number;
317
+ $next_suffix = '.' . ( $number + 1 );
318
+ }
319
+
320
+ $rename_from = self::get_log_file_path( "{$handle}{$suffix}" );
321
+ $rename_to = self::get_log_file_path( "{$handle}{$next_suffix}" );
322
+
323
+ if ( $this->is_open( $rename_from ) ) {
324
+ $this->close( $rename_from );
325
+ }
326
+
327
+ if ( is_writable( $rename_from ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable
328
+ return rename( $rename_from, $rename_to ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_rename
329
+ } else {
330
+ return false;
331
+ }
332
+
333
+ }
334
+
335
+ /**
336
+ * Get a log file path.
337
+ *
338
+ * @param string $handle Log name.
339
+ * @return bool|string The log file path or false if path cannot be determined.
340
+ */
341
+ public static function get_log_file_path( $handle ) {
342
+ if ( function_exists( 'wp_hash' ) ) {
343
+ return trailingslashit( WOO_FEED_LOG_DIR ) . self::get_log_file_name( $handle );
344
+ } else {
345
+ woo_feed_doing_it_wrong( __METHOD__, __( 'This method should not be called before plugins_loaded.', 'woo-feed' ), '3.0' );
346
+ return false;
347
+ }
348
+ }
349
+
350
+ /**
351
+ * Get a log file name.
352
+ *
353
+ * File names consist of the handle, followed by the date, followed by a hash, .log.
354
+ *
355
+ * @since 3.3
356
+ * @param string $handle Log name.
357
+ * @return bool|string The log file name or false if cannot be determined.
358
+ */
359
+ public static function get_log_file_name( $handle ) {
360
+ if ( function_exists( 'wp_hash' ) ) {
361
+ $date_suffix = date( 'Y-m-d', current_time( 'timestamp', true ) );
362
+ $hash_suffix = wp_hash( $handle );
363
+ return sanitize_file_name( implode( '-', array( $handle, $date_suffix, $hash_suffix ) ) . '.log' );
364
+ } else {
365
+ woo_feed_doing_it_wrong( __METHOD__, __( 'This method should not be called before plugins_loaded.', 'woo-feed' ), '3.3' );
366
+ return false;
367
+ }
368
+ }
369
+
370
+ /**
371
+ * Cache log to write later.
372
+ *
373
+ * @param string $entry Log entry text.
374
+ * @param string $handle Log entry handle.
375
+ */
376
+ protected function cache_log( $entry, $handle ) {
377
+ $this->cached_logs[] = array(
378
+ 'entry' => $entry,
379
+ 'handle' => $handle,
380
+ );
381
+ }
382
+
383
+ /**
384
+ * Write cached logs.
385
+ */
386
+ public function write_cached_logs() {
387
+ foreach ( $this->cached_logs as $log ) {
388
+ $this->add( $log['entry'], $log['handle'] );
389
+ }
390
+ }
391
+
392
+ /**
393
+ * Delete all logs older than a defined timestamp.
394
+ *
395
+ * @since 3.4.0
396
+ * @param integer $timestamp Timestamp to delete logs before.
397
+ */
398
+ public static function delete_logs_before_timestamp( $timestamp = 0 ) {
399
+ if ( ! $timestamp ) {
400
+ return;
401
+ }
402
+
403
+ $log_files = self::get_log_files();
404
+
405
+ foreach ( $log_files as $log_file ) {
406
+ $last_modified = filemtime( trailingslashit( WOO_FEED_LOG_DIR ) . $log_file );
407
+
408
+ if ( $last_modified < $timestamp ) {
409
+ @unlink( trailingslashit( WOO_FEED_LOG_DIR ) . $log_file ); // @codingStandardsIgnoreLine.
410
+ }
411
+ }
412
+ }
413
+
414
+ /**
415
+ * Get all log files in the log directory.
416
+ *
417
+ * @since 3.4.0
418
+ * @return array
419
+ */
420
+ public static function get_log_files() {
421
+ $files = @scandir( WOO_FEED_LOG_DIR ); // @codingStandardsIgnoreLine.
422
+ $result = array();
423
+
424
+ if ( ! empty( $files ) ) {
425
+ foreach ( $files as $key => $value ) {
426
+ if ( ! in_array( $value, array( '.', '..' ), true ) ) {
427
+ if ( ! is_dir( $value ) && strstr( $value, '.log' ) ) {
428
+ $result[ sanitize_title( $value ) ] = $value;
429
+ }
430
+ }
431
+ }
432
+ }
433
+
434
+ return $result;
435
+ }
436
+ }
includes/classes/class-woo-feed-products-v3.php CHANGED
@@ -14,7 +14,7 @@ class Woo_Feed_Products_v3 {
14
  private $enclosure;
15
  private $delimiter;
16
  private $config;
17
- public $products;
18
  private $queryType = 'wp';
19
  private $google_shipping_tax = array(
20
  'shipping_country',
@@ -122,15 +122,17 @@ class Woo_Feed_Products_v3 {
122
  * @return array|object
123
  */
124
  public function query_products() {
 
125
  if($this->queryType=='wc'){
126
- return $this->get_wc_query_products();
127
  }elseif ($this->queryType=='wp'){
128
- return $this->get_wp_query_products();
129
  }elseif ($this->queryType=='both'){
130
  $wc=$this->get_wc_query_products();
131
  $wp=$this->get_wp_query_products();
132
- return array_unique(array_merge($wc,$wp));
133
  }
 
134
  }
135
 
136
  /**
14
  private $enclosure;
15
  private $delimiter;
16
  private $config;
17
+ public $products = [];
18
  private $queryType = 'wp';
19
  private $google_shipping_tax = array(
20
  'shipping_country',
122
  * @return array|object
123
  */
124
  public function query_products() {
125
+ $products = [];
126
  if($this->queryType=='wc'){
127
+ $products = $this->get_wc_query_products();
128
  }elseif ($this->queryType=='wp'){
129
+ $products = $this->get_wp_query_products();
130
  }elseif ($this->queryType=='both'){
131
  $wc=$this->get_wc_query_products();
132
  $wp=$this->get_wp_query_products();
133
+ $products = array_unique(array_merge($wc,$wp));
134
  }
135
+ return $products;
136
  }
137
 
138
  /**
includes/feeds/class-woo-feed-custom.php CHANGED
@@ -15,7 +15,7 @@ class Woo_Feed_Custom
15
  * This variable is responsible for holding all product attributes and their values
16
  *
17
  * @since 1.0.0
18
- * @var array $products Contains all the product attributes to generate feed
19
  * @access public
20
  */
21
  public $products;
@@ -24,7 +24,7 @@ class Woo_Feed_Custom
24
  * This variable is responsible for holding feed configuration form values
25
  *
26
  * @since 1.0.0
27
- * @var Custom $rules Contains feed configuration form values
28
  * @access public
29
  */
30
  public $rules;
15
  * This variable is responsible for holding all product attributes and their values
16
  *
17
  * @since 1.0.0
18
+ * @var Woo_Feed_Products_v3 $products Contains all the product attributes to generate feed
19
  * @access public
20
  */
21
  public $products;
24
  * This variable is responsible for holding feed configuration form values
25
  *
26
  * @since 1.0.0
27
+ * @var array $rules Contains feed configuration form values
28
  * @access public
29
  */
30
  public $rules;
includes/feeds/class-woo-feed-facebook.php CHANGED
@@ -16,7 +16,7 @@ class Woo_Feed_Facebook
16
  * This variable is responsible for holding all product attributes and their values
17
  *
18
  * @since 1.0.0
19
- * @var array $products Contains all the product attributes to generate feed
20
  * @access public
21
  */
22
  public $products;
16
  * This variable is responsible for holding all product attributes and their values
17
  *
18
  * @since 1.0.0
19
+ * @var Woo_Feed_Products_v3 $products Contains all the product attributes to generate feed
20
  * @access public
21
  */
22
  public $products;
includes/feeds/class-woo-feed-generate.php CHANGED
@@ -2,9 +2,18 @@
2
 
3
  class Woo_Generate_Feed
4
  {
5
-
6
- public $service;
7
-
 
 
 
 
 
 
 
 
 
8
  public function __construct($feedService, $feedRule)
9
  {
10
  $this->service = new $feedService($feedRule);
2
 
3
  class Woo_Generate_Feed
4
  {
5
+ /**
6
+ * Provider Service Class
7
+ * @var Woo_Feed_Google|Woo_Feed_Pinterest|Woo_Feed_Facebook|Woo_Feed_Custom_XML|Woo_Feed_Custom
8
+ */
9
+ public $service;
10
+
11
+ /**
12
+ * Woo_Generate_Feed constructor.
13
+ *
14
+ * @param string $feedService
15
+ * @param array $feedRule
16
+ */
17
  public function __construct($feedService, $feedRule)
18
  {
19
  $this->service = new $feedService($feedRule);
includes/feeds/class-woo-feed-google.php CHANGED
@@ -16,7 +16,7 @@ class Woo_Feed_Google
16
  * This variable is responsible for holding all product attributes and their values
17
  *
18
  * @since 1.0.0
19
- * @var array $products Contains all the product attributes to generate feed
20
  * @access public
21
  */
22
  public $products;
16
  * This variable is responsible for holding all product attributes and their values
17
  *
18
  * @since 1.0.0
19
+ * @var Woo_Feed_Products_v3 $products Contains all the product attributes to generate feed
20
  * @access public
21
  */
22
  public $products;
includes/feeds/class-woo-feed-pinterest.php CHANGED
@@ -16,7 +16,7 @@ class Woo_Feed_Pinterest
16
  * This variable is responsible for holding all product attributes and their values
17
  *
18
  * @since 1.0.0
19
- * @var array $products Contains all the product attributes to generate feed
20
  * @access public
21
  */
22
  public $products;
16
  * This variable is responsible for holding all product attributes and their values
17
  *
18
  * @since 1.0.0
19
+ * @var Woo_Feed_Products_v3 $products Contains all the product attributes to generate feed
20
  * @access public
21
  */
22
  public $products;
includes/helper.php CHANGED
@@ -517,6 +517,11 @@ if( ! function_exists( 'woo_feed_save_feed_config_data' ) ) {
517
  function woo_feed_save_feed_config_data( $data, $fileName = null, $configOnly = true ) {
518
  if( ! is_array( $data ) ) return false;
519
  if( ! isset( $data['filename'], $data['feedType'], $data['provider'], $data['mattributes'] ) ) return false;
 
 
 
 
 
520
  // Sanitize Fields
521
  $data = woo_feed_sanitize_form_fields( $data );
522
  if( empty( $fileName ) ) {
@@ -614,14 +619,14 @@ if( ! function_exists( 'woo_feed_save_batch_feed_info' ) ) {
614
  $file = $path . "/" . $fileName . "." . $ext;
615
  $save = new Woo_Feed_Savefile();
616
  $status = $save->saveFile( $path, $file, $string );
617
- if( woo_feed_is_debugging_enabled() ) {
618
- if( $status ) {
619
- $message = sprintf( 'Batch chunk file (%s) saved.', $fileName );
620
- } else {
621
- $message = sprintf( 'Unable to save batch chunk file %s.', $fileName );
622
- }
623
- woo_feed_log_feed_process( $info['filename'], $message );
624
- }
625
  return $status;
626
  }
627
  }
517
  function woo_feed_save_feed_config_data( $data, $fileName = null, $configOnly = true ) {
518
  if( ! is_array( $data ) ) return false;
519
  if( ! isset( $data['filename'], $data['feedType'], $data['provider'], $data['mattributes'] ) ) return false;
520
+ // unnecessary form fields to remove
521
+ $removables = [ 'closedpostboxesnonce', '_wpnonce', '_wp_http_referer', 'save_feed_config', 'edit-feed' ];
522
+ foreach ( $removables as $removable ) {
523
+ if( isset( $data[$removable] ) ) unset( $data[$removable] );
524
+ }
525
  // Sanitize Fields
526
  $data = woo_feed_sanitize_form_fields( $data );
527
  if( empty( $fileName ) ) {
619
  $file = $path . "/" . $fileName . "." . $ext;
620
  $save = new Woo_Feed_Savefile();
621
  $status = $save->saveFile( $path, $file, $string );
622
+ // if( woo_feed_is_debugging_enabled() ) {
623
+ // if( $status ) {
624
+ // $message = sprintf( 'Batch chunk file (%s) saved.', $fileName );
625
+ // } else {
626
+ // $message = sprintf( 'Unable to save batch chunk file %s.', $fileName );
627
+ // }
628
+ // woo_feed_log_feed_process( $info['filename'], $message );
629
+ // }
630
  return $status;
631
  }
632
  }
woo-feed.php CHANGED
@@ -15,7 +15,7 @@
15
  * Plugin Name: WooCommerce Product Feed
16
  * Plugin URI: https://webappick.com/
17
  * Description: This plugin generate WooCommerce product feed for Shopping Engines like Google Shopping,Facebook Product Feed,eBay,Amazon,Idealo and many more..
18
- * Version: 3.2.10
19
  * Author: WebAppick
20
  * Author URI: https://webappick.com/
21
  * License: GPL v2
@@ -41,7 +41,7 @@ if ( ! defined( 'WOO_FEED_FREE_VERSION' ) ) {
41
  * Plugin Version
42
  * @var string
43
  */
44
- define( 'WOO_FEED_FREE_VERSION', '3.2.10' );
45
  }
46
  if ( ! defined( 'WOO_FEED_FREE_FILE') ) {
47
  /**
@@ -680,9 +680,9 @@ if ( ! function_exists( 'woo_feed_generate_feed' ) ) {
680
  wp_schedule_event(time(), 'woo_feed_corn', 'woo_feed_update_single_feed', $arg );
681
 
682
  wp_redirect( add_query_arg( [
683
- 'feed_created' => false !== $fileName,
684
  'feed_regenerate' => 1,
685
- 'feed_name' => $fileName,
686
  ], admin_url( 'admin.php?page=webappick-manage-feeds' ) ) );
687
  die();
688
 
@@ -722,9 +722,9 @@ if ( ! function_exists( 'woo_feed_manage_feed' ) ) {
722
  // redirect to the feed list with status
723
  // @TODO this should be handled in admin_init action for proper redirection to work...
724
  wp_redirect( add_query_arg( [
725
- 'feed_updated' => false !== $fileName,
726
  'feed_regenerate' => (int) isset( $_POST['edit-feed'] ),
727
- 'feed_name' => $fileName,
728
  ], admin_url( 'admin.php?page=webappick-manage-feeds' ) ) );
729
  die();
730
  }
@@ -838,8 +838,8 @@ if ( ! function_exists( 'woo_feed_config_feed' ) ) {
838
  $queryType = 'wc';
839
  }
840
  update_option( "woo_feed_product_query_type", $queryType,false );
841
- if( isset( $_POST['enable_error_debugging'] ) ) {
842
- update_option( "woo_feed_enable_error_debugging", sanitize_text_field( $_POST['enable_error_debugging'] ), false );
843
  } else {
844
  delete_option( 'woo_feed_enable_error_debugging' );
845
  }
15
  * Plugin Name: WooCommerce Product Feed
16
  * Plugin URI: https://webappick.com/
17
  * Description: This plugin generate WooCommerce product feed for Shopping Engines like Google Shopping,Facebook Product Feed,eBay,Amazon,Idealo and many more..
18
+ * Version: 3.2.11
19
  * Author: WebAppick
20
  * Author URI: https://webappick.com/
21
  * License: GPL v2
41
  * Plugin Version
42
  * @var string
43
  */
44
+ define( 'WOO_FEED_FREE_VERSION', '3.2.11' );
45
  }
46
  if ( ! defined( 'WOO_FEED_FREE_FILE') ) {
47
  /**
680
  wp_schedule_event(time(), 'woo_feed_corn', 'woo_feed_update_single_feed', $arg );
681
 
682
  wp_redirect( add_query_arg( [
683
+ 'feed_created' => (int) false !== $fileName,
684
  'feed_regenerate' => 1,
685
+ 'feed_name' => $fileName ? $fileName : '',
686
  ], admin_url( 'admin.php?page=webappick-manage-feeds' ) ) );
687
  die();
688
 
722
  // redirect to the feed list with status
723
  // @TODO this should be handled in admin_init action for proper redirection to work...
724
  wp_redirect( add_query_arg( [
725
+ 'feed_updated' => (int) false !== $fileName,
726
  'feed_regenerate' => (int) isset( $_POST['edit-feed'] ),
727
+ 'feed_name' => $fileName ? $fileName : '',
728
  ], admin_url( 'admin.php?page=webappick-manage-feeds' ) ) );
729
  die();
730
  }
838
  $queryType = 'wc';
839
  }
840
  update_option( "woo_feed_product_query_type", $queryType,false );
841
+ if( isset( $_POST['enable_error_debugging'] ) && $_POST['enable_error_debugging'] === 'on' ) {
842
+ update_option( "woo_feed_enable_error_debugging", 'on', false );
843
  } else {
844
  delete_option( 'woo_feed_enable_error_debugging' );
845
  }