--- a/webappick-product-feed-for-woocommerce/V5/API/RestController.php
+++ b/webappick-product-feed-for-woocommerce/V5/API/RestController.php
@@ -86,26 +86,51 @@
* @@ -86,7 +86,16 @@ public static function instance() {
* @see https://github.com/WP-API/Basic-Auth
*/
- public function get_item_permissions_check( $request ) {
- $user = wp_get_current_user();
- $mange_ctx_feed = apply_filters( 'ctx_feed_api_accessed_users', [
- 'manage_options',
- 'manage_woocommerce'
- ] );
- $current_user_roles = $user->get_role_caps();
- $current_user_roles = array_keys( $current_user_roles );
- $current_user_can_manage_ctx_feed = false;
- foreach ( $mange_ctx_feed as $role ) {
- if ( in_array( $role, $current_user_roles ) ) {
- $current_user_can_manage_ctx_feed = true;
- }
- }
+// public function get_item_permissions_check( $request ) {
+//
+// $user = wp_get_current_user();
+// $mange_ctx_feed = apply_filters( 'ctx_feed_api_accessed_users', [
+// 'manage_options',
+// 'manage_woocommerce'
+// ] );
+// $current_user_roles = $user->get_role_caps();
+// $current_user_roles = array_keys( $current_user_roles );
+// $current_user_can_manage_ctx_feed = false;
+// foreach ( $mange_ctx_feed as $role ) {
+// if ( in_array( $role, $current_user_roles ) ) {
+// $current_user_can_manage_ctx_feed = true;
+// }
+// }
+//
+// return apply_filters( 'ctx_feed_current_user_can_manage_api', $current_user_can_manage_ctx_feed, $user, $current_user_roles, $mange_ctx_feed, $request );
+//
+// }
- return apply_filters( 'ctx_feed_current_user_can_manage_api', $current_user_can_manage_ctx_feed, $user, $current_user_roles, $mange_ctx_feed, $request );
+ public function get_item_permissions_check( $request ) {
- }
+ // Must be logged in
+ if ( ! is_user_logged_in() ) {
+ return new WP_Error(
+ 'ctxfeed_rest_forbidden',
+ __( 'Authentication required.', 'woo-feed' ),
+ [ 'status' => 401 ]
+ );
+ }
- /**
+ // Must have proper capability
+ if ( ! current_user_can( 'manage_woocommerce' ) && ! current_user_can( 'manage_options' ) ) {
+ return new WP_Error(
+ 'ctxfeed_rest_forbidden',
+ __( 'You are not allowed to access this resource.', 'woo-feed' ),
+ [ 'status' => 403 ]
+ );
+ }
+
+ return true;
+ }
+
+
+ /**
* Register routes according to $_SERVER['REQUEST_URI'].
* After 'wp-json' value will be considered as namespace.
* After that v1/v2 will be as api version number.
--- a/webappick-product-feed-for-woocommerce/V5/Common/DownloadFiles.php
+++ b/webappick-product-feed-for-woocommerce/V5/Common/DownloadFiles.php
@@ -29,6 +29,11 @@
* @throw RuntimeException
*/
public function download_log() {
+ // Verify user has permission
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ wp_die( esc_html__( 'You do not have permission to download logs.', 'woo-feed' ), 403 );
+ }
+
if (
isset( $_REQUEST['feed'], $_REQUEST['_wpnonce'] )
&& wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'wpf-log-download' )
@@ -61,6 +66,11 @@
* @return void
*/
public function download_feed() {
+ // Verify user has permission
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ wp_die( esc_html__( 'You do not have permission to download feeds.', 'woo-feed' ), 403 );
+ }
+
if (
isset( $_REQUEST['feed'], $_REQUEST['_wpnonce'] )
&& wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'wpf-download-feed' )
--- a/webappick-product-feed-for-woocommerce/V5/Common/ExportFeed.php
+++ b/webappick-product-feed-for-woocommerce/V5/Common/ExportFeed.php
@@ -17,6 +17,11 @@
* @return void
*/
public function export_feed() {
+ // Verify user has permission
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ wp_die( esc_html__( 'You do not have permission to export feeds.', 'woo-feed' ), 403 );
+ }
+
if ( isset( $_REQUEST['feed'], $_REQUEST['_wpnonce'] ) && ! empty( $_REQUEST['feed'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'wpf-export' ) ) {
$feed = sanitize_text_field( wp_unslash( $_REQUEST['feed'] ) );
$feed_info = Feed::get_single_feed( $feed );
--- a/webappick-product-feed-for-woocommerce/V5/Common/ImportFeed.php
+++ b/webappick-product-feed-for-woocommerce/V5/Common/ImportFeed.php
@@ -16,6 +16,11 @@
* @throws Exception
*/
public function import_feed() {
+ // Verify user has permission
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ wp_die( esc_html__( 'You do not have permission to import feeds.', 'woo-feed' ), 403 );
+ }
+
check_admin_referer( 'wpf_import' );
$wpf_import_file = isset( $_FILES['wpf_import_file'] ) ? $_FILES['wpf_import_file'] : '';
--- a/webappick-product-feed-for-woocommerce/V5/Notice/Dismiss.php
+++ b/webappick-product-feed-for-woocommerce/V5/Notice/Dismiss.php
@@ -134,6 +134,12 @@
*/
public function ajax_maybe_dismiss_notice() {
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
// Sanity check: Early exit if we're not on a pressmodo_dismiss_notice action.
if ( ! isset( $_POST['action'] ) || 'pressmodo_dismiss_notice' !== $_POST['action'] ) {
return;
--- a/webappick-product-feed-for-woocommerce/V5/Tracker/FacebookTracker.php
+++ b/webappick-product-feed-for-woocommerce/V5/Tracker/FacebookTracker.php
@@ -20,7 +20,7 @@
// Ajax adds to cart
add_action( 'wp_ajax_add_to_cart_facebook_pixel', [ $this, 'ajax_add_to_cart_data' ] );
- add_action( 'wp_ajax_nopriv_add_to_cart_facebook_pixel', [ $this, 'ajax_add_to_cart_data' ] );
+ //add_action( 'wp_ajax_nopriv_add_to_cart_facebook_pixel', [ $this, 'ajax_add_to_cart_data' ] );
}
/**
@@ -42,6 +42,10 @@
'jquery',
'wp-util'
], '1.0.0', true );
+
+ wp_localize_script( 'woo-feed-facebook-pixel,', 'woo_feed_facebook_pixel_params', array(
+ 'nonce' => wp_create_nonce( 'woo_feed_facebook_pixel_nonce' ),
+ ) );
}
/**
@@ -238,8 +242,18 @@
* @since 4.4.27
*/
public function ajax_add_to_cart_data() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
+ // Verify nonce for security
+ check_ajax_referer( 'woo_feed_facebook_pixel_nonce', 'nonce' );
+
$data = [];
-
+
$product_id = sanitize_text_field( isset( $_POST['product_id'] ) ? $_POST['product_id'] : '' );
if ( ! empty( $product_id ) ) {
$data = $this->get_content_info( [ $product_id ] );
--- a/webappick-product-feed-for-woocommerce/V5/Tracker/GoogleTracker.php
+++ b/webappick-product-feed-for-woocommerce/V5/Tracker/GoogleTracker.php
@@ -24,7 +24,7 @@
// Ajax adds to cart
add_action( 'wp_ajax_add_to_cart_facebook_pixel', [ $this, 'ajax_add_to_cart_data' ] );
- add_action( 'wp_ajax_nopriv_add_to_cart_facebook_pixel', [ $this, 'ajax_add_to_cart_data' ] );
+ //add_action( 'wp_ajax_nopriv_add_to_cart_facebook_pixel', [ $this, 'ajax_add_to_cart_data' ] );
}
/**
@@ -46,6 +46,10 @@
'jquery',
'wp-util'
], '1.0.0', true );
+
+ wp_localize_script( 'woo-feed-google-remarketing,', 'woo_feed_google_remarketing_params', array(
+ 'nonce' => wp_create_nonce( 'woo_feed_google_remarketing_nonce' ),
+ ) );
}
/**
@@ -216,13 +220,22 @@
* @since 4.4.27
*/
public function ajax_add_to_cart_data() {
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ), 403 );
+ die();
+ }
+
+ // Verify nonce for security
+ check_ajax_referer( 'woo_feed_google_remarketing_nonce', 'nonce' );
+
$data = [];
-
+
$product_id = sanitize_text_field( isset( $_POST['product_id'] ) ? $_POST['product_id'] : '' );
if ( ! empty( $product_id ) ) {
$data = $this->get_content_info( [ $product_id ] );
}
-
+
wp_send_json_success( json_encode( $data ) );
}
--- a/webappick-product-feed-for-woocommerce/V5/Tracker/PinterestTracker.php
+++ b/webappick-product-feed-for-woocommerce/V5/Tracker/PinterestTracker.php
@@ -18,7 +18,7 @@
// Ajax adds to cart
add_action( 'wp_ajax_add_to_cart_pinterest_tag', [ $this, 'ajax_add_to_cart_data' ] );
- add_action( 'wp_ajax_nopriv_add_to_cart_pinterest_tag', [ $this, 'ajax_add_to_cart_data' ] );
+ //add_action( 'wp_ajax_nopriv_add_to_cart_pinterest_tag', [ $this, 'ajax_add_to_cart_data' ] );
}
/**
@@ -40,6 +40,10 @@
'jquery',
'wp-util'
], '1.0.0', true );
+
+ wp_localize_script( 'woo-feed-pinterest-tag,', 'woo_feed_pinterest_tag_params', array(
+ 'nonce' => wp_create_nonce( 'woo_feed_pinterest_tag_nonce' ),
+ ) );
}
/**
@@ -271,8 +275,18 @@
* @since 4.4.27
*/
public function ajax_add_to_cart_data() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
+ // Verify nonce for security
+ check_ajax_referer( 'woo_feed_pinterest_tag_nonce', 'nonce' );
+
$data = [];
-
+
$product_id = sanitize_text_field( isset( $_POST['product_id'] ) ? $_POST['product_id'] : '' );
if ( ! empty( $product_id ) ) {
$data = $this->get_content_info( [ $product_id ] );
--- a/webappick-product-feed-for-woocommerce/V5/Tracker/TiktokTracker.php
+++ b/webappick-product-feed-for-woocommerce/V5/Tracker/TiktokTracker.php
@@ -17,7 +17,7 @@
// Ajax adds to cart
add_action( 'wp_ajax_add_to_cart_facebook_pixel', [ &$this, 'ajax_add_to_cart_data' ] );
- add_action( 'wp_ajax_nopriv_add_to_cart_facebook_pixel', [ &$this, 'ajax_add_to_cart_data' ] );
+ //add_action( 'wp_ajax_nopriv_add_to_cart_facebook_pixel', [ &$this, 'ajax_add_to_cart_data' ] );
}
/**
@@ -39,6 +39,10 @@
'jquery',
'wp-util'
], '1.0.0', true );
+
+ wp_localize_script( 'woo-feed-facebook-pixel,', 'woo_feed_facebook_pixel_params', array(
+ 'nonce' => wp_create_nonce( 'woo_feed_facebook_pixel_nonce' ),
+ ) );
}
/**
@@ -218,6 +222,16 @@
* @since 4.4.27
*/
public function ajax_add_to_cart_data() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
+ // Verify nonce for security
+ check_ajax_referer( 'woo_feed_facebook_pixel_nonce', 'nonce' );
+
$data = [];
$product_id = sanitize_text_field( isset( $_POST['product_id'] ) ? $_POST['product_id'] : '' );
--- a/webappick-product-feed-for-woocommerce/includes/Tracker/Facebook/Pixel.php
+++ b/webappick-product-feed-for-woocommerce/includes/Tracker/Facebook/Pixel.php
@@ -34,7 +34,7 @@
// Ajax add to cart
add_action( 'wp_ajax_add_to_cart_facebook_pixel', array( &$this, 'product_add_to_cart_data' ) );
- add_action( 'wp_ajax_nopriv_add_to_cart_facebook_pixel', array( &$this, 'product_add_to_cart_data' ) );
+ //add_action( 'wp_ajax_nopriv_add_to_cart_facebook_pixel', array( &$this, 'product_add_to_cart_data' ) );
}
@@ -62,6 +62,10 @@
wp_enqueue_script( 'woo-feed-facebook-pixel,', WOO_FEED_PLUGIN_URL . 'admin/js/woo-feed-facebook-pixel.min.js', array( 'jquery', 'wp-util' ), '1.0.0', true );
+ wp_localize_script( 'woo-feed-facebook-pixel,', 'woo_feed_facebook_pixel_params', array(
+ 'nonce' => wp_create_nonce( 'woo_feed_facebook_pixel_nonce' ),
+ ) );
+
}
/**
@@ -155,6 +159,16 @@
* @since 4.4.27
*/
public function product_add_to_cart_data() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
+ // Verify nonce for security
+ check_ajax_referer( 'woo_feed_facebook_pixel_nonce', 'nonce' );
+
$data = array();
$product_id = sanitize_text_field( isset( $_POST['product_id'] ) ? $_POST['product_id'] : '' );
--- a/webappick-product-feed-for-woocommerce/includes/Tracker/Google/Remarketing.php
+++ b/webappick-product-feed-for-woocommerce/includes/Tracker/Google/Remarketing.php
@@ -42,7 +42,7 @@
// Ajax add to cart
add_action( 'wp_ajax_add_to_cart_google_remarketing', [ &$this, 'product_add_to_cart_data' ] );
- add_action( 'wp_ajax_nopriv_add_to_cart_google_remarketing', [ &$this, 'product_add_to_cart_data' ] );
+ //add_action( 'wp_ajax_nopriv_add_to_cart_google_remarketing', [ &$this, 'product_add_to_cart_data' ] );
}
/*
@@ -104,6 +104,10 @@
wp_enqueue_script( 'woo-feed-google-remarketing,', WOO_FEED_PLUGIN_URL . 'admin/js/woo-feed-google-remarketing.min.js', [ 'jquery', 'wp-util' ], '1.0.0', true );
+ wp_localize_script( 'woo-feed-google-remarketing,', 'woo_feed_google_remarketing_params', array(
+ 'nonce' => wp_create_nonce( 'woo_feed_google_remarketing_nonce' ),
+ ) );
+
}
/**
@@ -164,6 +168,16 @@
* @since 4.4.34
*/
public function product_add_to_cart_data(){
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
+ // Verify nonce for security
+ check_ajax_referer( 'woo_feed_google_remarketing_nonce', 'nonce' );
+
$data = [];
if( isset( $_POST['product_id'] ) ){
$product_id = intval( esc_attr( $_POST['product_id'] ) );
--- a/webappick-product-feed-for-woocommerce/includes/action-handler.php
+++ b/webappick-product-feed-for-woocommerce/includes/action-handler.php
@@ -120,7 +120,7 @@
// Check user permission
if ( ! current_user_can( 'manage_woocommerce' ) ) {
Logs::write_debug_log( 'User doesnt have enough permission.' );
- wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
wp_die();
}
@@ -226,7 +226,7 @@
// Check user permission
if ( ! current_user_can( 'manage_woocommerce' ) ) {
Logs::write_debug_log( 'User doesnt have enough permission.' );
- wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
wp_die();
}
--- a/webappick-product-feed-for-woocommerce/includes/classes/class-woo-feed-constants.php
+++ b/webappick-product-feed-for-woocommerce/includes/classes/class-woo-feed-constants.php
@@ -24,7 +24,7 @@
* @since 3.1.6
*/
- define( 'WOO_FEED_FREE_VERSION', '6.6.18' );
+ define( 'WOO_FEED_FREE_VERSION', '6.6.19' );
}
--- a/webappick-product-feed-for-woocommerce/includes/classes/class-woo-feed-webappick-api.php
+++ b/webappick-product-feed-for-woocommerce/includes/classes/class-woo-feed-webappick-api.php
@@ -329,6 +329,7 @@
?>
<div class="woo-feed-notice notice notice-info" style="line-height:1.5;" data-which="rating" data-nonce="<?php echo esc_attr( $nonce ); ?>">
<form method="post">
+ <?php wp_nonce_field( 'woo_feed_pro_notice_nonce', '_wpnonce' ); ?>
<p>
<?php
printf(
@@ -428,6 +429,31 @@
* Show Review request admin notice
*/
public function woo_feed_save_review_notice() {
+ // Check if there's any form submission or AJAX request to process
+ $has_form_data = isset( $_POST['woo_feed_review_notice_submit'] ) ||
+ isset( $_POST['woo_feed_review_notice_btn_given'] ) ||
+ isset( $_POST['woo_feed_review_notice_btn_never'] ) ||
+ isset( $_POST['woo_feed_review_notice_btn_done'] ) ||
+ isset( $_POST['woo_feed_review_notice_btn_later'] ) ||
+ isset( $_POST['notice'] ); // AJAX request
+
+ // If no data to process, return early
+ if ( ! $has_form_data ) {
+ return;
+ }
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ), 403 );
+ die();
+ }
+
+ // Verify nonce for security - handles both form (_wpnonce) and AJAX (_ajax_nonce) requests
+ if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ?? $_POST['_ajax_nonce'] ?? '' ) ), 'woo_feed_pro_notice_nonce' ) ) {
+ wp_send_json_error( esc_html__( 'Security check failed.', 'woo-feed' ), 403 );
+ die();
+ }
+
$user_id = get_current_user_id();
$woo_feed_review_notice_submit = isset( $_POST['woo_feed_review_notice_submit'] ) ? 1 : '';
@@ -471,6 +497,11 @@
*/
public function woo_feed_hide_notice() {
check_ajax_referer( 'woo_feed_pro_notice_nonce' );
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
$notices = array( 'rp-wcdpd', 'wpml', 'rating', 'product_limit' );
if ( isset( $_REQUEST['which'] ) && ! empty( $_REQUEST['which'] ) && in_array( $_REQUEST['which'], $notices ) ) {
$which = sanitize_text_field( $_REQUEST['which'] ); //phpcs:ignore
--- a/webappick-product-feed-for-woocommerce/includes/helper.php
+++ b/webappick-product-feed-for-woocommerce/includes/helper.php
@@ -1027,6 +1027,13 @@
if ( ! function_exists( 'woo_feed_ajax_merchant_info' ) ) {
add_action( 'wp_ajax_woo_feed_get_merchant_info', 'woo_feed_ajax_merchant_info' );
function woo_feed_ajax_merchant_info() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
if ( isset( $_REQUEST['nonce'] ) && wp_verify_nonce(
sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) ),
'wpf_feed_nonce'
@@ -2942,6 +2949,13 @@
* This function is called when product attribute swicher click.
*/
function woo_feed_product_attribute_cache_remove_cb() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
$is_nonce_valid = isset( $_POST['nonce'] ) && wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), 'wpf_feed_nonce' );
if ( $is_nonce_valid ) {
@@ -2960,6 +2974,13 @@
* This AJAX callback function is called when custom fields on/off switched
*/
function woo_feed_custom_fields_status_change_cb() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
$is_nonce_valid = isset( $_POST['nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'wpf_feed_nonce' );
if ( $is_nonce_valid && isset(
@@ -3377,6 +3398,13 @@
* @since 4.1.2
*/
function woo_feed_clear_cache_data() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
if ( isset( $_REQUEST['_ajax_clean_nonce'] ) ) {
if ( isset( $_POST['type'] ) ) {
@@ -3581,6 +3609,13 @@
* @author Nazrul Islam Nayan
*/
function woo_feed_save_summer_sale_notice() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
if ( isset( $_REQUEST['_wp_ajax_nonce'] ) && wp_verify_nonce( wp_unslash( $_REQUEST['_wp_ajax_nonce'] ), 'woo-feed-to-ctx-feed-notice' ) ) { //phpcs:ignore
$user_id = get_current_user_id();
if ( isset( $_REQUEST['clicked'] ) ) {
@@ -3610,6 +3645,13 @@
* @author Nazrul Islam Nayan
*/
function woo_feed_save_black_friday_notice() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
if ( isset( $_REQUEST['_wp_ajax_nonce'] ) && wp_verify_nonce( wp_unslash( $_REQUEST['_wp_ajax_nonce'] ), 'woo-feed-to-ctx-feed-notice' ) ) { //phpcs:ignore
$user_id = get_current_user_id();
if ( isset( $_REQUEST['clicked'] ) ) {
@@ -3640,6 +3682,13 @@
* @author Nashir Uddin
*/
function woo_feed_save_halloween_notice() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
if ( isset( $_REQUEST['_wp_ajax_nonce'] ) && wp_verify_nonce( wp_unslash( $_REQUEST['_wp_ajax_nonce'] ), 'woo-feed-to-ctx-feed-halloween-nonce' ) ) { //phpcs:ignore
$user_id = get_current_user_id();
if ( isset( $_REQUEST['clicked'] ) ) {
@@ -3670,6 +3719,13 @@
* @author Md. Nashir Uddin
*/
function woo_feed_save_christmas_notice() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
if ( isset( $_REQUEST['_wp_ajax_nonce'] ) && wp_verify_nonce( wp_unslash( $_REQUEST['_wp_ajax_nonce'] ), 'woo-feed-to-ctx-feed-notice' ) ) { //phpcs:ignore
$user_id = get_current_user_id();
if ( isset( $_REQUEST['clicked'] ) ) {
@@ -3699,18 +3755,24 @@
* @since 5.1.7
*/
function woo_feed_hide_promotion() {
- if ( isset( $_REQUEST['_ajax_nonce'] ) ) {
- $hide_promotion = update_option( 'woo_feed_hide_promotion', 1 );
- $data = array(
- 'msg' => 'Hide promotion updated successfully.',
- );
- if ( $hide_promotion ) {
- wp_send_json_success( $data );
- } else {
- wp_send_json_error( esc_html__( 'Something is wrong.', 'woo-feed' ) );
- }
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
+ // Verify nonce for security
+ check_ajax_referer( 'wpf_feed_nonce' );
+
+ $hide_promotion = update_option( 'woo_feed_hide_promotion', 1 );
+ $data = array(
+ 'msg' => 'Hide promotion updated successfully.',
+ );
+ if ( $hide_promotion ) {
+ wp_send_json_success( $data );
} else {
- wp_send_json_error( esc_html__( 'Invalid Request.', 'woo-feed' ) );
+ wp_send_json_error( esc_html__( 'Something is wrong.', 'woo-feed' ) );
}
wp_die();
}
@@ -5102,6 +5164,13 @@
* @return mixed array | error
*/
function woo_feed_filter_count_cb() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
$is_nonce_valid = isset( $_GET['nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['nonce'] ) ), 'wpf_feed_nonce' );
if ( $is_nonce_valid ) {
@@ -6054,7 +6123,15 @@
}
}
if ( ! function_exists( 'woo_feed_add_product_attribute_is_highlighted' ) ) {
+
function woo_feed_add_product_attribute_is_highlighted( $attribute, $i = 0 ) {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
$value = get_woo_feed_attribute_highlighted( $attribute->get_name(), $i );
?>
<tr>
@@ -6082,6 +6159,12 @@
function woo_feed_ajax_woocommerce_save_attributes() {
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
check_ajax_referer( 'save-attributes', 'security' );
parse_str( $_POST['data'], $data );
--- a/webappick-product-feed-for-woocommerce/libs/WebAppick/AppServices/Insights.php
+++ b/webappick-product-feed-for-woocommerce/libs/WebAppick/AppServices/Insights.php
@@ -557,6 +557,10 @@
*/
public function handle_optIn_optOut() {
if ( isset( $_REQUEST['_wpnonce'] ) && ( isset( $_GET[ $this->client->getSlug() . '_tracker_optIn' ] ) || isset( $_GET[ $this->client->getSlug() . '_tracker_optOut' ] ) ) ) {
+ // Verify user has permission to manage options
+ if ( ! current_user_can( 'manage_options' ) ) {
+ return;
+ }
check_admin_referer( $this->client->getSlug() . '_insight_action' );
if ( isset( $_GET[ $this->client->getSlug() . '_tracker_optIn' ] ) && 'true' == $_GET[ $this->client->getSlug() . '_tracker_optIn' ] ) {
$this->optIn();
@@ -858,6 +862,13 @@
* @return void
*/
public function uninstall_reason_submission() {
+
+ if ( ! current_user_can( 'manage_options' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
check_ajax_referer( $this->client->getSlug() . '_insight_action' );
if ( ! isset( $_POST['reason_id'] ) ) {
wp_send_json_error( esc_html__( 'Invalid Request', 'woo-feed' ) );
@@ -905,6 +916,13 @@
* @return void
*/
public function support_ticket_submission() {
+
+ if ( ! current_user_can( 'manage_options' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
check_ajax_referer( $this->client->getSlug() . '_insight_action' );
if ( empty( $this->ticketTemplate ) || empty( $this->ticketRecipient ) || empty( $this->supportURL ) ) {
wp_send_json_error(
--- a/webappick-product-feed-for-woocommerce/libs/WebAppick/AppServices/Promotions.php
+++ b/webappick-product-feed-for-woocommerce/libs/WebAppick/AppServices/Promotions.php
@@ -350,6 +350,13 @@
* @return void
*/
public function __webappick_dismiss_promo() {
+
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
+ woo_feed_log_debug_message( 'User doesnt have enough permission.' );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
+ die();
+ }
+
if (
isset( $_REQUEST['dismissed'], $_REQUEST['hash'], $_REQUEST['_wpnonce'] ) &&
'true' == $_REQUEST['dismissed'] && ! empty( $_REQUEST['hash'] ) &&
--- a/webappick-product-feed-for-woocommerce/woo-feed.php
+++ b/webappick-product-feed-for-woocommerce/woo-feed.php
@@ -10,7 +10,7 @@
* Plugin Name: CTX Feed
* Plugin URI: https://webappick.com/
* Description: Easily generate woocommerce product feed for any marketing channel like Google Shopping(Merchant), Facebook Remarketing, Bing, eBay & more. Support 100+ Merchants.
- * Version: 6.6.18
+ * Version: 6.6.19
* Author: WebAppick
* Author URI: https://webappick.com/
* License: GPL v2
@@ -265,7 +265,7 @@
check_ajax_referer( 'wpf_feed_nonce' );
if ( ! current_user_can( 'manage_woocommerce' ) ) {
woo_feed_log_debug_message( 'User doesnt have enough permission.' );
- wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
die();
}
if ( ! isset( $_REQUEST['feed'] ) ) {
@@ -340,7 +340,7 @@
check_ajax_referer( 'wpf_feed_nonce' );
if ( ! current_user_can( 'manage_woocommerce' ) ) {
woo_feed_log_debug_message( 'User doesnt have enough permission.' );
- wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
die();
}
if ( ! isset( $_REQUEST['feed'] ) ) {
@@ -494,7 +494,7 @@
* @return bool
*/
function woo_feed_generate_batch_data( $info, $feedSlug ) {
- // parse rules.
+ // parse rules.
$info = woo_feed_parse_feed_rules( isset( $info['feedrules'] ) ? $info['feedrules'] : $info );
try {
@@ -581,6 +581,7 @@
}
}
if ( ! function_exists( 'woo_feed_manage_feed' ) ) {
+
/**
* Manage Feeds
*/
@@ -684,7 +685,7 @@
check_ajax_referer( 'wpf_feed_nonce' );
if ( ! current_user_can( 'manage_woocommerce' ) ) {
woo_feed_log_debug_message( 'User doesnt have enough permission.' );
- wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) ,403);
die();
}
global $feedRules, $wooFeedDropDown, $merchant, $provider;
@@ -724,7 +725,7 @@
check_ajax_referer( 'wpf_feed_nonce' );
if ( ! current_user_can( 'manage_woocommerce' ) ) {
woo_feed_log_debug_message( 'User doesnt have enough permission.' );
- wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
wp_die();
}
$wooFeedDropDown = new Woo_Feed_Dropdown();
@@ -744,7 +745,7 @@
check_ajax_referer( 'wpf_feed_nonce' );
if ( ! current_user_can( 'manage_woocommerce' ) ) {
woo_feed_log_debug_message( 'User doesnt have enough permission.' );
- wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
wp_die();
}
$wooFeedDropDown = new Woo_Feed_Dropdown();
@@ -764,7 +765,7 @@
check_ajax_referer( 'wpf_feed_nonce' );
if ( ! current_user_can( 'manage_woocommerce' ) ) {
woo_feed_log_debug_message( 'User doesnt have enough permission.' );
- wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
wp_die();
}
if ( extension_loaded( 'ssh2' ) ) {
@@ -790,7 +791,7 @@
check_ajax_referer( 'wpf_feed_nonce' );
if ( ! current_user_can( 'manage_woocommerce' ) ) {
woo_feed_log_debug_message( 'User doesnt have enough permission.' );
- wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ) );
+ wp_send_json_error( esc_html__( 'Unauthorized Action.', 'woo-feed' ),403 );
wp_die();
}