Product Feed PRO for WooCommerce - Version 11.0.7

Version Description

Added missing capability checks on plugin settings that could influence product feeds. Only administrators are allowed to make these changes

Download this release

Release Info

Developer jorisverwater
Plugin Icon 128x128 Product Feed PRO for WooCommerce
Version 11.0.7
Comparing to
See all releases

Code changes from version 11.0.6 to 11.0.7

classes/class-get-products.php CHANGED
@@ -4126,7 +4126,7 @@ class WooSEA_Get_Products {
4126
  if(array_key_exists('fields', $project_config)){
4127
  if(is_array($allowed_channel_parents)){
4128
  if (!in_array($project_config['fields'], $allowed_channel_parents)){
4129
- if(($product->is_type('variable')) AND ($product_data['item_group_id'] == 0)){
4130
  $product_data = array();
4131
  $product_data = null;
4132
  }
@@ -4254,7 +4254,7 @@ class WooSEA_Get_Products {
4254
  $variations = $product_skroutz->get_available_variations();
4255
  $variations_id = wp_list_pluck( $variations, 'variation_id' );
4256
 
4257
- $size_array_raw = explode(",", $product_data[$sz_attribute]);
4258
  $size_array = array_map('trim', $size_array_raw);
4259
  $enabled_sizes = array();
4260
  foreach($variations_id as $var_id){
4126
  if(array_key_exists('fields', $project_config)){
4127
  if(is_array($allowed_channel_parents)){
4128
  if (!in_array($project_config['fields'], $allowed_channel_parents)){
4129
+ if(($product->is_type('variable')) AND ( isset($product_data['item_group_id'] ))){
4130
  $product_data = array();
4131
  $product_data = null;
4132
  }
4254
  $variations = $product_skroutz->get_available_variations();
4255
  $variations_id = wp_list_pluck( $variations, 'variation_id' );
4256
 
4257
+ $size_array_raw = @explode(",", $product_data[$sz_attribute]);
4258
  $size_array = array_map('trim', $size_array_raw);
4259
  $enabled_sizes = array();
4260
  foreach($variations_id as $var_id){
js/woosea_key.js CHANGED
@@ -26,7 +26,7 @@ jQuery(document).ready(function($) {
26
  var license_key = $('#license-key').val();
27
 
28
  jQuery.ajax({
29
- url: 'https://www.adtribes.io/check/license.php?key=' + license_key + '&email=' + license_email + '&domain=' + root_domain + '&version=11.0.6',
30
  jsonp: 'callback',
31
  dataType: 'jsonp',
32
  type: 'GET',
26
  var license_key = $('#license-key').val();
27
 
28
  jQuery.ajax({
29
+ url: 'https://www.adtribes.io/check/license.php?key=' + license_key + '&email=' + license_email + '&domain=' + root_domain + '&version=11.0.7',
30
  jsonp: 'callback',
31
  dataType: 'jsonp',
32
  type: 'GET',
readme.txt CHANGED
@@ -5,7 +5,7 @@ License URI: http://www.gnu.org/licenses/gpl.html
5
  Tags: Google Shopping Feed, WooCommerce Product Feed, Facebook Product Feed, Bing Shopping Feed, Bing Product Feed, Google Merchant Feed, Skroutz, Google Product Feed, Pinterest, Idealo, Facebook Pixel, Facebook Conversion API
6
  Requires at least: 4.5
7
  Tested up to: 5.8
8
- Stable tag: 11.0.6
9
 
10
  == Description ==
11
 
@@ -215,7 +215,6 @@ Some of the above mentioned feature can only be used by users who upgraded to th
215
  * Hintaseuranta
216
  * Connexity
217
  * <a href="https://www.katoni.dk" target="_blank">Katoni.dk</a>
218
- * Cdiscount
219
  * Fnac
220
  * ManoMano
221
  * <a href="https://www.fruugo.co.uk" target="_blank">Fruugo.co.uk</a>
@@ -233,7 +232,6 @@ Some of the above mentioned feature can only be used by users who upgraded to th
233
  * Webgains
234
  * Crowdfox
235
  * <a href="https://www.salidzini.lv" target="_blank">Salidzini.lv</a>
236
- * Real.de
237
  * Allyouneed
238
  * Apomio
239
  * <a href="http://developer.skroutz.gr/feedspec/" target="_blank" rel="nofollow">Skroutz.gr</a>
@@ -254,7 +252,6 @@ Some of the above mentioned feature can only be used by users who upgraded to th
254
  * <a href="https://www.compari.ro" target="_blank">Compari.ro</a>
255
  * My Best Brands
256
  * Preis.de
257
- * Rakuten
258
  * Restposten.de
259
  * Sparmedo.de
260
  * Stylelounge.de
@@ -339,6 +336,9 @@ Questions left or unanswered? Please do not hesitate to contact us at support@ad
339
 
340
  === Changelog ===
341
 
 
 
 
342
  = 11.0.6 (2021-12-22) =
343
  * Added htaccess files to the feed directories so they no longer will be cached (thanks @Anders!)
344
  * Added downloadable and virtual attribute data so those can be added to feeds and filtered on
@@ -3536,6 +3536,9 @@ Questions left or unanswered? Please do not hesitate to contact us at support@ad
3536
 
3537
  == Upgrade Notice ==
3538
 
 
 
 
3539
  = 11.0.6 =
3540
  Added htaccess files to the feed directories so they no longer will be cached (thanks @Anders!)
3541
  Fixed an issue where disabled product variations still made it into the size attribute
5
  Tags: Google Shopping Feed, WooCommerce Product Feed, Facebook Product Feed, Bing Shopping Feed, Bing Product Feed, Google Merchant Feed, Skroutz, Google Product Feed, Pinterest, Idealo, Facebook Pixel, Facebook Conversion API
6
  Requires at least: 4.5
7
  Tested up to: 5.8
8
+ Stable tag: 11.0.7
9
 
10
  == Description ==
11
 
215
  * Hintaseuranta
216
  * Connexity
217
  * <a href="https://www.katoni.dk" target="_blank">Katoni.dk</a>
 
218
  * Fnac
219
  * ManoMano
220
  * <a href="https://www.fruugo.co.uk" target="_blank">Fruugo.co.uk</a>
232
  * Webgains
233
  * Crowdfox
234
  * <a href="https://www.salidzini.lv" target="_blank">Salidzini.lv</a>
 
235
  * Allyouneed
236
  * Apomio
237
  * <a href="http://developer.skroutz.gr/feedspec/" target="_blank" rel="nofollow">Skroutz.gr</a>
252
  * <a href="https://www.compari.ro" target="_blank">Compari.ro</a>
253
  * My Best Brands
254
  * Preis.de
 
255
  * Restposten.de
256
  * Sparmedo.de
257
  * Stylelounge.de
336
 
337
  === Changelog ===
338
 
339
+ = 11.0.7 (2021-12-23) =
340
+ * Added missing capability checks on plugin settings that could influence product feeds. Only administrators are allowed to make these changes.
341
+
342
  = 11.0.6 (2021-12-22) =
343
  * Added htaccess files to the feed directories so they no longer will be cached (thanks @Anders!)
344
  * Added downloadable and virtual attribute data so those can be added to feeds and filtered on
3536
 
3537
  == Upgrade Notice ==
3538
 
3539
+ = 11.0.7 =
3540
+ Added missing capability checks on plugin settings that could influence product feeds. Only administrators are allowed to make these changes
3541
+
3542
  = 11.0.6 =
3543
  Added htaccess files to the feed directories so they no longer will be cached (thanks @Anders!)
3544
  Fixed an issue where disabled product variations still made it into the size attribute
woocommerce-sea.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Plugin Name: Product Feed PRO for WooCommerce
4
- * Version: 11.0.6
5
  * Plugin URI: https://www.adtribes.io/support/?utm_source=wpadmin&utm_medium=plugin&utm_campaign=woosea_product_feed_pro
6
  * Description: Configure and maintain your WooCommerce product feeds for Google Shopping, Facebook, Remarketing, Bing, Yandex, Comparison shopping websites and over a 100 channels more.
7
  * Author: AdTribes.io
@@ -48,7 +48,7 @@ if (!defined('ABSPATH')) {
48
  * Plugin versionnumber, please do not override.
49
  * Define some constants
50
  */
51
- define( 'WOOCOMMERCESEA_PLUGIN_VERSION', '11.0.6' );
52
  define( 'WOOCOMMERCESEA_PLUGIN_NAME', 'woocommerce-product-feed-pro' );
53
  define( 'WOOCOMMERCESEA_PLUGIN_NAME_SHORT', 'woo-product-feed-pro' );
54
 
@@ -140,17 +140,6 @@ function woosea_scripts($hook) {
140
  }
141
  add_action( 'admin_enqueue_scripts' , 'woosea_scripts' );
142
 
143
- /**
144
- * Enqueue front end scripts
145
- */
146
- function woosea_fe_scripts($hook) {
147
- // JS for managing addToCart event
148
- wp_enqueue_script( 'ajax-script', get_template_directory_uri() . 'js/my-ajax-script.js', array('jquery') );
149
- wp_register_script( 'woosea_addcart-js', plugin_dir_url( __FILE__ ) . 'js/woosea_add_cart.js', '',WOOCOMMERCESEA_PLUGIN_VERSION, true );
150
- wp_enqueue_script( 'woosea_addcart-js' );
151
- }
152
- //add_action('wp_enqueue_scripts', 'woosea_fe_scripts');
153
-
154
  /**
155
  * Internationalisation of plugin
156
  */
@@ -958,22 +947,28 @@ function woosea_menu_addition(){
958
  */
959
  function woosea_ajax() {
960
  check_ajax_referer('woosea_ajax_nonce', 'security');
961
- $rowCount = sanitize_text_field($_POST['rowCount']);
 
 
962
 
963
- $attributes_dropdown = get_option('attributes_dropdown');
964
- if (!is_array($attributes_dropdown)){
965
- $attributes_obj = new WooSEA_Attributes;
966
- $attributes_dropdown = $attributes_obj->get_product_attributes_dropdown();
967
- update_option( 'attributes_dropdown', $attributes_dropdown, 'yes');
968
- }
969
 
970
- $data = array (
971
- 'rowCount' => $rowCount,
972
- 'dropdown' => $attributes_dropdown
973
- );
 
 
974
 
975
- echo json_encode($data);
976
- wp_die();
 
 
 
 
 
 
977
  }
978
  add_action( 'wp_ajax_woosea_ajax', 'woosea_ajax' );
979
 
@@ -1037,9 +1032,15 @@ function woosea_recursive_sanitize_text_field($array) {
1037
  */
1038
  function woosea_save_adwords_conversion_id() {
1039
  check_ajax_referer('woosea_ajax_nonce', 'security');
1040
- $adwords_conversion_id = sanitize_text_field($_POST['adwords_conversion_id']);
1041
- $adwords_conversion_id = woosea_sanitize_xss($adwords_conversion_id);
1042
- update_option("woosea_adwords_conversion_id", $adwords_conversion_id);
 
 
 
 
 
 
1043
  }
1044
  add_action( 'wp_ajax_woosea_save_adwords_conversion_id', 'woosea_save_adwords_conversion_id' );
1045
 
@@ -1048,8 +1049,14 @@ add_action( 'wp_ajax_woosea_save_adwords_conversion_id', 'woosea_save_adwords_co
1048
  */
1049
  function woosea_save_batch_size() {
1050
  check_ajax_referer('woosea_ajax_nonce', 'security');
1051
- $batch_size = sanitize_text_field($_POST['batch_size']);
1052
- update_option("woosea_batch_size", $batch_size);
 
 
 
 
 
 
1053
  }
1054
  add_action( 'wp_ajax_woosea_save_batch_size', 'woosea_save_batch_size' );
1055
 
@@ -1058,9 +1065,15 @@ add_action( 'wp_ajax_woosea_save_batch_size', 'woosea_save_batch_size' );
1058
  */
1059
  function woosea_save_facebook_pixel_id() {
1060
  check_ajax_referer('woosea_ajax_nonce', 'security');
1061
- $facebook_pixel_id = sanitize_text_field($_POST['facebook_pixel_id']);
1062
- $facebook_pixel_id = woosea_sanitize_xss($facebook_pixel_id);
1063
- update_option("woosea_facebook_pixel_id", $facebook_pixel_id);
 
 
 
 
 
 
1064
  }
1065
  add_action( 'wp_ajax_woosea_save_facebook_pixel_id', 'woosea_save_facebook_pixel_id' );
1066
 
@@ -1069,9 +1082,15 @@ add_action( 'wp_ajax_woosea_save_facebook_pixel_id', 'woosea_save_facebook_pixel
1069
  */
1070
  function woosea_save_facebook_capi_token() {
1071
  check_ajax_referer('woosea_ajax_nonce', 'security');
1072
- $facebook_capi_token = sanitize_text_field($_POST['facebook_capi_token']);
1073
- $facebook_capi_token = woosea_sanitize_xss($facebook_capi_token);
1074
- update_option("woosea_facebook_capi_token", $facebook_capi_token);
 
 
 
 
 
 
1075
  }
1076
  add_action( 'wp_ajax_woosea_save_facebook_capi_token', 'woosea_save_facebook_capi_token' );
1077
 
@@ -1080,52 +1099,55 @@ add_action( 'wp_ajax_woosea_save_facebook_capi_token', 'woosea_save_facebook_cap
1080
  */
1081
  function woosea_add_mass_cat_mapping(){
1082
  check_ajax_referer('woosea_ajax_nonce', 'security');
1083
- $project_hash = sanitize_text_field($_POST['project_hash']);
1084
- $catMappings = woosea_recursive_sanitize_text_field($_POST['catMappings']);
1085
-
1086
- // I need to sanitize the catMappings Array
1087
- $mappings = array();
1088
- foreach ($catMappings as $mKey => $mVal){
1089
- $mKey = sanitize_text_field($mKey);
1090
- $mVal = sanitize_text_field($mVal);
1091
- $piecesVal = explode("||", $mVal);
1092
- $mappings[$piecesVal[1]] = array(
1093
- "rowCount" => $piecesVal[1],
1094
- "categoryId" => $piecesVal[1],
1095
- "criteria" => $piecesVal[0],
1096
- "map_to_category" => $piecesVal[2],
1097
 
1098
- );
1099
- }
1100
-
1101
- $project = WooSEA_Update_Project::get_project_data(sanitize_text_field($project_hash));
1102
- // This happens during configuration of a new feed
1103
- if(empty($project)){
1104
- $project_temp = get_option( 'channel_project' );
1105
- if(array_key_exists('mappings', $project_temp)){
1106
- $project_temp['mappings'] = $mappings + $project_temp['mappings'];
1107
- } else {
1108
- $project_temp['mappings'] = $mappings;
 
 
 
 
 
 
 
 
1109
  }
1110
- update_option( 'channel_project',$project_temp,'yes');
1111
- } else {
1112
- // Only update the ones that changed
1113
- foreach ($mappings as $categoryId => $catArray){
1114
- if (array_key_exists($categoryId, $project['mappings'])){
1115
- $project['mappings'][$categoryId] = $catArray;
 
1116
  } else {
1117
- $project['mappings'][$categoryId] = $catArray;
 
 
 
 
 
 
 
 
 
 
1118
  }
 
1119
  }
1120
- $project_updated = WooSEA_Update_Project::update_project_data($project);
 
 
 
 
1121
  }
1122
- $data = array (
1123
- 'status_mapping' => "true",
1124
- );
1125
-
1126
- echo json_encode($data);
1127
- wp_die();
1128
-
1129
  }
1130
  add_action( 'wp_ajax_woosea_add_mass_cat_mapping', 'woosea_add_mass_cat_mapping' );
1131
 
@@ -2194,36 +2216,41 @@ add_action( 'wp_ajax_woosea_project_refresh', 'woosea_project_refresh' );
2194
  function woosea_add_attributes() {
2195
  check_ajax_referer( 'woosea_ajax_nonce', 'security' );
2196
 
2197
- $attribute_name = sanitize_text_field($_POST['attribute_name']);
2198
- $attribute_value = sanitize_text_field($_POST['attribute_value']);
2199
- $active = sanitize_text_field($_POST['active']);
2200
 
2201
- if(!get_option( 'woosea_extra_attributes' )){
2202
- if($active == "true"){
2203
- $extra_attributes = array(
2204
- $attribute_value => $attribute_name
2205
- );
2206
- update_option ( 'woosea_extra_attributes', $extra_attributes, 'yes');
2207
- }
2208
- } else {
2209
- $extra_attributes = get_option( 'woosea_extra_attributes' );
2210
- if(!in_array($attribute_name, $extra_attributes,TRUE)){
2211
  if($active == "true"){
2212
- $add_attribute = array (
2213
  $attribute_value => $attribute_name
2214
  );
2215
- $extra_attributes = array_merge ($extra_attributes, $add_attribute);
2216
  update_option ( 'woosea_extra_attributes', $extra_attributes, 'yes');
2217
  }
2218
- } else {
2219
- if($active == "false"){
2220
- // remove from extra attributes array
2221
- $extra_attributes = array_diff($extra_attributes, array($attribute_value => $attribute_name));
2222
- update_option ( 'woosea_extra_attributes', $extra_attributes, 'yes');
 
 
 
 
 
 
 
 
 
 
 
2223
  }
2224
- }
 
2225
  }
2226
- $extra_attributes = get_option( 'woosea_extra_attributes' );
2227
  }
2228
  add_action( 'wp_ajax_woosea_add_attributes', 'woosea_add_attributes' );
2229
 
@@ -2458,11 +2485,13 @@ add_action( 'wp_ajax_woosea_add_woosea_cdata', 'woosea_add_woosea_cdata' );
2458
  */
2459
  function woosea_add_facebook_pixel_setting (){
2460
  check_ajax_referer('woosea_ajax_nonce', 'security');
2461
- $status = sanitize_text_field($_POST['status']);
2462
 
2463
- // Only admin users are allowed to make changes that impact the front-end
2464
  $user = wp_get_current_user();
2465
- if ( in_array( 'administrator', (array) $user->roles ) ) {
 
 
 
 
2466
  if ($status == "off"){
2467
  update_option( 'add_facebook_pixel', 'no', 'yes');
2468
  } else {
@@ -2478,11 +2507,13 @@ add_action( 'wp_ajax_woosea_add_facebook_pixel_setting', 'woosea_add_facebook_pi
2478
  */
2479
  function woosea_add_facebook_capi_setting (){
2480
  check_ajax_referer('woosea_ajax_nonce', 'security');
2481
- $status = sanitize_text_field($_POST['status']);
2482
 
2483
- // Only admin users are allowed to make changes that impact the front-end
2484
  $user = wp_get_current_user();
2485
- if ( in_array( 'administrator', (array) $user->roles ) ) {
 
 
 
 
2486
  if ($status == "off"){
2487
  update_option( 'add_facebook_capi', 'no', 'yes');
2488
  } else {
@@ -2496,13 +2527,18 @@ add_action( 'wp_ajax_woosea_add_facebook_capi_setting', 'woosea_add_facebook_cap
2496
  * This function saves the value that needs to be used in the Facebook pixel content_ids parameter
2497
  */
2498
  function woosea_facebook_content_ids (){
2499
- $content_ids = sanitize_text_field($_POST['content_ids']);
 
2500
 
2501
- if ($content_ids == "variable"){
2502
- update_option( 'add_facebook_pixel_content_ids', 'variable', 'yes');
2503
- } else {
2504
- update_option( 'add_facebook_pixel_content_ids', 'variation', 'yes');
2505
- }
 
 
 
 
2506
  }
2507
  add_action( 'wp_ajax_woosea_facebook_content_ids', 'woosea_facebook_content_ids' );
2508
 
@@ -2512,11 +2548,13 @@ add_action( 'wp_ajax_woosea_facebook_content_ids', 'woosea_facebook_content_ids'
2512
  */
2513
  function woosea_add_remarketing (){
2514
  check_ajax_referer('woosea_ajax_nonce', 'security');
2515
- $status = sanitize_text_field($_POST['status']);
2516
-
2517
- // Only admin users are allowed to make changes that impact the front-end
2518
  $user = wp_get_current_user();
2519
- if ( in_array( 'administrator', (array) $user->roles ) ) {
 
 
 
 
2520
  if ($status == "off"){
2521
  update_option( 'add_remarketing', 'no', 'yes');
2522
  } else {
@@ -2531,11 +2569,12 @@ add_action( 'wp_ajax_woosea_add_remarketing', 'woosea_add_remarketing' );
2531
  * a new batch size
2532
  */
2533
  function woosea_add_batch (){
2534
- $status = sanitize_text_field($_POST['status']);
 
2535
 
2536
- // Only admin users are allowed to make changes that impact the performance
2537
- $user = wp_get_current_user();
2538
- if ( in_array( 'administrator', (array) $user->roles ) ) {
2539
  if ($status == "off"){
2540
  update_option( 'add_batch', 'no', 'yes');
2541
  } else {
@@ -4094,39 +4133,45 @@ add_action( 'wp_ajax_woosea_fieldmapping_dialog_helptext', 'woosea_fieldmapping_
4094
  */
4095
  function woosea_fieldmapping_dropdown(){
4096
  check_ajax_referer('woosea_ajax_nonce', 'security');
4097
- $channel_hash = sanitize_text_field($_POST['channel_hash']);
4098
- $rowCount = sanitize_text_field($_POST['rowCount']);
4099
- $channel_data = WooSEA_Update_Project::get_channel_data($channel_hash);
4100
 
4101
- require plugin_dir_path(__FILE__) . '/classes/channels/class-'.$channel_data['fields'].'.php';
4102
- $obj = "WooSEA_".$channel_data['fields'];
4103
- $fields_obj = new $obj;
4104
- $attributes = $fields_obj->get_channel_attributes();
4105
- $field_options = "<option selected></option>";
 
 
 
 
 
 
 
 
4106
 
4107
- foreach($attributes as $key => $value){
4108
- $field_options .= "<option></option>";
4109
- $field_options .= "<optgroup label='$key'><strong>$key</strong>";
4110
- foreach($value as $k => $v){
4111
- $field_options .= "<option value='$v[feed_name]'>$k ($v[name])</option>";
 
4112
  }
4113
- }
4114
 
4115
- $attributes_obj = new WooSEA_Attributes;
4116
- $attribute_dropdown = $attributes_obj->get_product_attributes();
4117
 
4118
- $attribute_options = "<option selected></option>";
4119
- foreach($attribute_dropdown as $drop_key => $drop_value){
4120
- $attribute_options .= "<option value='$drop_key'>$drop_value</option>";
4121
- }
4122
 
4123
- $data = array (
4124
- 'field_options' => $field_options,
4125
- 'attribute_options' => $attribute_options,
4126
- );
4127
 
4128
- echo json_encode($data);
4129
- wp_die();
 
4130
  }
4131
  add_action( 'wp_ajax_woosea_fieldmapping_dropdown', 'woosea_fieldmapping_dropdown' );
4132
 
1
  <?php
2
  /**
3
  * Plugin Name: Product Feed PRO for WooCommerce
4
+ * Version: 11.0.7
5
  * Plugin URI: https://www.adtribes.io/support/?utm_source=wpadmin&utm_medium=plugin&utm_campaign=woosea_product_feed_pro
6
  * Description: Configure and maintain your WooCommerce product feeds for Google Shopping, Facebook, Remarketing, Bing, Yandex, Comparison shopping websites and over a 100 channels more.
7
  * Author: AdTribes.io
48
  * Plugin versionnumber, please do not override.
49
  * Define some constants
50
  */
51
+ define( 'WOOCOMMERCESEA_PLUGIN_VERSION', '11.0.7' );
52
  define( 'WOOCOMMERCESEA_PLUGIN_NAME', 'woocommerce-product-feed-pro' );
53
  define( 'WOOCOMMERCESEA_PLUGIN_NAME_SHORT', 'woo-product-feed-pro' );
54
 
140
  }
141
  add_action( 'admin_enqueue_scripts' , 'woosea_scripts' );
142
 
 
 
 
 
 
 
 
 
 
 
 
143
  /**
144
  * Internationalisation of plugin
145
  */
947
  */
948
  function woosea_ajax() {
949
  check_ajax_referer('woosea_ajax_nonce', 'security');
950
+
951
+ $user = wp_get_current_user();
952
+ $allowed_roles = array( 'administrator' );
953
 
954
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
955
+ $rowCount = sanitize_text_field($_POST['rowCount']);
 
 
 
 
956
 
957
+ $attributes_dropdown = get_option('attributes_dropdown');
958
+ if (!is_array($attributes_dropdown)){
959
+ $attributes_obj = new WooSEA_Attributes;
960
+ $attributes_dropdown = $attributes_obj->get_product_attributes_dropdown();
961
+ update_option( 'attributes_dropdown', $attributes_dropdown, 'yes');
962
+ }
963
 
964
+ $data = array (
965
+ 'rowCount' => $rowCount,
966
+ 'dropdown' => $attributes_dropdown
967
+ );
968
+
969
+ echo json_encode($data);
970
+ wp_die();
971
+ }
972
  }
973
  add_action( 'wp_ajax_woosea_ajax', 'woosea_ajax' );
974
 
1032
  */
1033
  function woosea_save_adwords_conversion_id() {
1034
  check_ajax_referer('woosea_ajax_nonce', 'security');
1035
+
1036
+ $user = wp_get_current_user();
1037
+ $allowed_roles = array( 'administrator' );
1038
+
1039
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
1040
+ $adwords_conversion_id = sanitize_text_field($_POST['adwords_conversion_id']);
1041
+ $adwords_conversion_id = woosea_sanitize_xss($adwords_conversion_id);
1042
+ update_option("woosea_adwords_conversion_id", $adwords_conversion_id);
1043
+ }
1044
  }
1045
  add_action( 'wp_ajax_woosea_save_adwords_conversion_id', 'woosea_save_adwords_conversion_id' );
1046
 
1049
  */
1050
  function woosea_save_batch_size() {
1051
  check_ajax_referer('woosea_ajax_nonce', 'security');
1052
+
1053
+ $user = wp_get_current_user();
1054
+ $allowed_roles = array( 'administrator' );
1055
+
1056
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
1057
+ $batch_size = sanitize_text_field($_POST['batch_size']);
1058
+ update_option("woosea_batch_size", $batch_size);
1059
+ }
1060
  }
1061
  add_action( 'wp_ajax_woosea_save_batch_size', 'woosea_save_batch_size' );
1062
 
1065
  */
1066
  function woosea_save_facebook_pixel_id() {
1067
  check_ajax_referer('woosea_ajax_nonce', 'security');
1068
+
1069
+ $user = wp_get_current_user();
1070
+ $allowed_roles = array( 'administrator' );
1071
+
1072
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
1073
+ $facebook_pixel_id = sanitize_text_field($_POST['facebook_pixel_id']);
1074
+ $facebook_pixel_id = woosea_sanitize_xss($facebook_pixel_id);
1075
+ update_option("woosea_facebook_pixel_id", $facebook_pixel_id);
1076
+ }
1077
  }
1078
  add_action( 'wp_ajax_woosea_save_facebook_pixel_id', 'woosea_save_facebook_pixel_id' );
1079
 
1082
  */
1083
  function woosea_save_facebook_capi_token() {
1084
  check_ajax_referer('woosea_ajax_nonce', 'security');
1085
+
1086
+ $user = wp_get_current_user();
1087
+ $allowed_roles = array( 'administrator' );
1088
+
1089
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
1090
+ $facebook_capi_token = sanitize_text_field($_POST['facebook_capi_token']);
1091
+ $facebook_capi_token = woosea_sanitize_xss($facebook_capi_token);
1092
+ update_option("woosea_facebook_capi_token", $facebook_capi_token);
1093
+ }
1094
  }
1095
  add_action( 'wp_ajax_woosea_save_facebook_capi_token', 'woosea_save_facebook_capi_token' );
1096
 
1099
  */
1100
  function woosea_add_mass_cat_mapping(){
1101
  check_ajax_referer('woosea_ajax_nonce', 'security');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1102
 
1103
+ $user = wp_get_current_user();
1104
+ $allowed_roles = array( 'administrator' );
1105
+
1106
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
1107
+ $project_hash = sanitize_text_field($_POST['project_hash']);
1108
+ $catMappings = woosea_recursive_sanitize_text_field($_POST['catMappings']);
1109
+
1110
+ // I need to sanitize the catMappings Array
1111
+ $mappings = array();
1112
+ foreach ($catMappings as $mKey => $mVal){
1113
+ $mKey = sanitize_text_field($mKey);
1114
+ $mVal = sanitize_text_field($mVal);
1115
+ $piecesVal = explode("||", $mVal);
1116
+ $mappings[$piecesVal[1]] = array(
1117
+ "rowCount" => $piecesVal[1],
1118
+ "categoryId" => $piecesVal[1],
1119
+ "criteria" => $piecesVal[0],
1120
+ "map_to_category" => $piecesVal[2],
1121
+ );
1122
  }
1123
+
1124
+ $project = WooSEA_Update_Project::get_project_data(sanitize_text_field($project_hash));
1125
+ // This happens during configuration of a new feed
1126
+ if(empty($project)){
1127
+ $project_temp = get_option( 'channel_project' );
1128
+ if(array_key_exists('mappings', $project_temp)){
1129
+ $project_temp['mappings'] = $mappings + $project_temp['mappings'];
1130
  } else {
1131
+ $project_temp['mappings'] = $mappings;
1132
+ }
1133
+ update_option( 'channel_project',$project_temp,'yes');
1134
+ } else {
1135
+ // Only update the ones that changed
1136
+ foreach ($mappings as $categoryId => $catArray){
1137
+ if (array_key_exists($categoryId, $project['mappings'])){
1138
+ $project['mappings'][$categoryId] = $catArray;
1139
+ } else {
1140
+ $project['mappings'][$categoryId] = $catArray;
1141
+ }
1142
  }
1143
+ $project_updated = WooSEA_Update_Project::update_project_data($project);
1144
  }
1145
+ $data = array (
1146
+ 'status_mapping' => "true",
1147
+ );
1148
+ echo json_encode($data);
1149
+ wp_die();
1150
  }
 
 
 
 
 
 
 
1151
  }
1152
  add_action( 'wp_ajax_woosea_add_mass_cat_mapping', 'woosea_add_mass_cat_mapping' );
1153
 
2216
  function woosea_add_attributes() {
2217
  check_ajax_referer( 'woosea_ajax_nonce', 'security' );
2218
 
2219
+ $user = wp_get_current_user();
2220
+ $allowed_roles = array( 'administrator' );
 
2221
 
2222
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
2223
+ $attribute_name = sanitize_text_field($_POST['attribute_name']);
2224
+ $attribute_value = sanitize_text_field($_POST['attribute_value']);
2225
+ $active = sanitize_text_field($_POST['active']);
2226
+
2227
+ if(!get_option( 'woosea_extra_attributes' )){
 
 
 
 
2228
  if($active == "true"){
2229
+ $extra_attributes = array(
2230
  $attribute_value => $attribute_name
2231
  );
 
2232
  update_option ( 'woosea_extra_attributes', $extra_attributes, 'yes');
2233
  }
2234
+ } else {
2235
+ $extra_attributes = get_option( 'woosea_extra_attributes' );
2236
+ if(!in_array($attribute_name, $extra_attributes,TRUE)){
2237
+ if($active == "true"){
2238
+ $add_attribute = array (
2239
+ $attribute_value => $attribute_name
2240
+ );
2241
+ $extra_attributes = array_merge ($extra_attributes, $add_attribute);
2242
+ update_option ( 'woosea_extra_attributes', $extra_attributes, 'yes');
2243
+ }
2244
+ } else {
2245
+ if($active == "false"){
2246
+ // remove from extra attributes array
2247
+ $extra_attributes = array_diff($extra_attributes, array($attribute_value => $attribute_name));
2248
+ update_option ( 'woosea_extra_attributes', $extra_attributes, 'yes');
2249
+ }
2250
  }
2251
+ }
2252
+ $extra_attributes = get_option( 'woosea_extra_attributes' );
2253
  }
 
2254
  }
2255
  add_action( 'wp_ajax_woosea_add_attributes', 'woosea_add_attributes' );
2256
 
2485
  */
2486
  function woosea_add_facebook_pixel_setting (){
2487
  check_ajax_referer('woosea_ajax_nonce', 'security');
 
2488
 
 
2489
  $user = wp_get_current_user();
2490
+ $allowed_roles = array( 'administrator' );
2491
+
2492
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
2493
+ $status = sanitize_text_field($_POST['status']);
2494
+
2495
  if ($status == "off"){
2496
  update_option( 'add_facebook_pixel', 'no', 'yes');
2497
  } else {
2507
  */
2508
  function woosea_add_facebook_capi_setting (){
2509
  check_ajax_referer('woosea_ajax_nonce', 'security');
 
2510
 
 
2511
  $user = wp_get_current_user();
2512
+ $allowed_roles = array( 'administrator' );
2513
+
2514
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
2515
+ $status = sanitize_text_field($_POST['status']);
2516
+
2517
  if ($status == "off"){
2518
  update_option( 'add_facebook_capi', 'no', 'yes');
2519
  } else {
2527
  * This function saves the value that needs to be used in the Facebook pixel content_ids parameter
2528
  */
2529
  function woosea_facebook_content_ids (){
2530
+ $user = wp_get_current_user();
2531
+ $allowed_roles = array( 'administrator' );
2532
 
2533
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
2534
+ $content_ids = sanitize_text_field($_POST['content_ids']);
2535
+
2536
+ if ($content_ids == "variable"){
2537
+ update_option( 'add_facebook_pixel_content_ids', 'variable', 'yes');
2538
+ } else {
2539
+ update_option( 'add_facebook_pixel_content_ids', 'variation', 'yes');
2540
+ }
2541
+ }
2542
  }
2543
  add_action( 'wp_ajax_woosea_facebook_content_ids', 'woosea_facebook_content_ids' );
2544
 
2548
  */
2549
  function woosea_add_remarketing (){
2550
  check_ajax_referer('woosea_ajax_nonce', 'security');
2551
+
 
 
2552
  $user = wp_get_current_user();
2553
+ $allowed_roles = array( 'administrator' );
2554
+
2555
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
2556
+ $status = sanitize_text_field($_POST['status']);
2557
+
2558
  if ($status == "off"){
2559
  update_option( 'add_remarketing', 'no', 'yes');
2560
  } else {
2569
  * a new batch size
2570
  */
2571
  function woosea_add_batch (){
2572
+ $user = wp_get_current_user();
2573
+ $allowed_roles = array( 'administrator' );
2574
 
2575
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
2576
+ $status = sanitize_text_field($_POST['status']);
2577
+
2578
  if ($status == "off"){
2579
  update_option( 'add_batch', 'no', 'yes');
2580
  } else {
4133
  */
4134
  function woosea_fieldmapping_dropdown(){
4135
  check_ajax_referer('woosea_ajax_nonce', 'security');
 
 
 
4136
 
4137
+ $user = wp_get_current_user();
4138
+ $allowed_roles = array( 'administrator' );
4139
+
4140
+ if ( array_intersect( $allowed_roles, $user->roles ) ) {
4141
+ $channel_hash = sanitize_text_field($_POST['channel_hash']);
4142
+ $rowCount = sanitize_text_field($_POST['rowCount']);
4143
+ $channel_data = WooSEA_Update_Project::get_channel_data($channel_hash);
4144
+
4145
+ require plugin_dir_path(__FILE__) . '/classes/channels/class-'.$channel_data['fields'].'.php';
4146
+ $obj = "WooSEA_".$channel_data['fields'];
4147
+ $fields_obj = new $obj;
4148
+ $attributes = $fields_obj->get_channel_attributes();
4149
+ $field_options = "<option selected></option>";
4150
 
4151
+ foreach($attributes as $key => $value){
4152
+ $field_options .= "<option></option>";
4153
+ $field_options .= "<optgroup label='$key'><strong>$key</strong>";
4154
+ foreach($value as $k => $v){
4155
+ $field_options .= "<option value='$v[feed_name]'>$k ($v[name])</option>";
4156
+ }
4157
  }
 
4158
 
4159
+ $attributes_obj = new WooSEA_Attributes;
4160
+ $attribute_dropdown = $attributes_obj->get_product_attributes();
4161
 
4162
+ $attribute_options = "<option selected></option>";
4163
+ foreach($attribute_dropdown as $drop_key => $drop_value){
4164
+ $attribute_options .= "<option value='$drop_key'>$drop_value</option>";
4165
+ }
4166
 
4167
+ $data = array (
4168
+ 'field_options' => $field_options,
4169
+ 'attribute_options' => $attribute_options,
4170
+ );
4171
 
4172
+ echo json_encode($data);
4173
+ wp_die();
4174
+ }
4175
  }
4176
  add_action( 'wp_ajax_woosea_fieldmapping_dropdown', 'woosea_fieldmapping_dropdown' );
4177