update
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Product Feed PRO for WooCommerce
|
||||
* Version: 12.4.5
|
||||
* Version: 13.3.2
|
||||
* Plugin URI: https://www.adtribes.io/support/?utm_source=wpadmin&utm_medium=plugin&utm_campaign=woosea_product_feed_pro
|
||||
* Description: Configure and maintain your WooCommerce product feeds for Google Shopping, Catalog managers, Remarketing, Bing, Skroutz, Yandex, Comparison shopping websites and over a 100 channels more.
|
||||
* Author: AdTribes.io
|
||||
* Plugin URI: https://wwww.adtribes.io/pro-vs-elite/
|
||||
* Author URI: https://www.adtribes.io
|
||||
* Developer: Joris Verwater
|
||||
* Developer: AdTribes.io
|
||||
* License: GPL3
|
||||
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
* Requires at least: 4.5
|
||||
* Tested up to: 6.1
|
||||
* Tested up to: 6.3
|
||||
*
|
||||
* Text Domain: woo-product-feed-pro
|
||||
* Domain Path: /languages
|
||||
*
|
||||
* WC requires at least: 4.4
|
||||
* WC tested up to: 7.5
|
||||
* WC tested up to: 8.7
|
||||
*
|
||||
* Product Feed PRO for WooCommerce is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -48,7 +48,7 @@ if (!defined('ABSPATH')) {
|
||||
* Plugin versionnumber, please do not override.
|
||||
* Define some constants
|
||||
*/
|
||||
define( 'WOOCOMMERCESEA_PLUGIN_VERSION', '12.4.5' );
|
||||
define( 'WOOCOMMERCESEA_PLUGIN_VERSION', '13.3.2' );
|
||||
define( 'WOOCOMMERCESEA_PLUGIN_NAME', 'woocommerce-product-feed-pro' );
|
||||
define( 'WOOCOMMERCESEA_PLUGIN_NAME_SHORT', 'woo-product-feed-pro' );
|
||||
|
||||
@@ -135,7 +135,7 @@ function woosea_scripts($hook) {
|
||||
wp_enqueue_script( 'woosea_key-js' );
|
||||
}
|
||||
// JS for manage projects page
|
||||
wp_register_script( 'woosea_manage-js', plugin_dir_url( __FILE__ ) . 'js/woosea_manage.js?yo=12', '',WOOCOMMERCESEA_PLUGIN_VERSION, true );
|
||||
wp_register_script( 'woosea_manage-js', plugin_dir_url( __FILE__ ) . 'js/woosea_manage.js?yo=12', array( 'clipboard' ),WOOCOMMERCESEA_PLUGIN_VERSION, true );
|
||||
wp_enqueue_script( 'woosea_manage-js' );
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts' , 'woosea_scripts' );
|
||||
@@ -158,14 +158,13 @@ require plugin_dir_path(__FILE__) . 'classes/class-admin-notifications.php';
|
||||
require plugin_dir_path(__FILE__) . 'classes/class-update-channel.php';
|
||||
require plugin_dir_path(__FILE__) . 'classes/class-attributes.php';
|
||||
require plugin_dir_path(__FILE__) . 'classes/class-google-remarketing.php';
|
||||
require plugin_dir_path(__FILE__) . 'classes/class-caching.php';
|
||||
|
||||
/**
|
||||
* Add links to the plugin page
|
||||
*/
|
||||
function woosea_plugin_action_links($links, $file) {
|
||||
static $this_plugin;
|
||||
|
||||
if (!$this_plugin) {
|
||||
if (!isset($this_plugin)) {
|
||||
$this_plugin = plugin_basename(__FILE__);
|
||||
}
|
||||
|
||||
@@ -183,7 +182,9 @@ function woosea_plugin_action_links($links, $file) {
|
||||
|
||||
// add the links to the list of links already there
|
||||
foreach($plugin_links as $link) {
|
||||
array_unshift($links, $link);
|
||||
if(is_array($links)){
|
||||
array_unshift($links, $link);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $links;
|
||||
@@ -236,14 +237,15 @@ function woosea_add_facebook_pixel( $product = null ){
|
||||
if ( ! is_object( $product ) ) {
|
||||
global $product;
|
||||
}
|
||||
$fb_pagetype = WooSEA_Google_Remarketing::woosea_google_remarketing_pagetype();
|
||||
|
||||
$add_facebook_pixel = get_option ('add_facebook_pixel');
|
||||
$add_facebook_capi = get_option ('add_facebook_capi');
|
||||
$viewContent = "";
|
||||
$event_id = uniqid (rand (),true);
|
||||
$currency = get_woocommerce_currency();
|
||||
|
||||
|
||||
if($add_facebook_pixel == "yes"){
|
||||
$fb_pagetype = WooSEA_Google_Remarketing::woosea_google_remarketing_pagetype();
|
||||
$viewContent = "";
|
||||
$event_id = uniqid (rand (),true);
|
||||
$currency = get_woocommerce_currency();
|
||||
$facebook_pixel_id = get_option("woosea_facebook_pixel_id");
|
||||
$facebook_capi_token = get_option("woosea_facebook_capi_token");
|
||||
|
||||
@@ -634,6 +636,7 @@ function woosea_add_remarketing_tags( $product = null ){
|
||||
|
||||
if($add_remarketing == "yes"){
|
||||
$adwords_conversion_id = get_option("woosea_adwords_conversion_id");
|
||||
|
||||
// Add vulnerability check, unset when no proper comversion ID was inserted
|
||||
if(!is_numeric($adwords_conversion_id)){
|
||||
unset($adwords_conversion_id);
|
||||
@@ -679,7 +682,6 @@ function woosea_add_remarketing_tags( $product = null ){
|
||||
$product_price = $variable_product->get_price();
|
||||
|
||||
// ----- remove HTML TAGs -----
|
||||
//$product_price = preg_replace ('/<[^>]*>/', ' ', $product_price);
|
||||
$ecomm_price = $product_price;
|
||||
} else {
|
||||
// AggregateOffer
|
||||
@@ -829,12 +831,18 @@ register_activation_hook(__FILE__, 'activate_woosea_feed');
|
||||
* Close the get Elite notification
|
||||
**/
|
||||
function woosea_getelite_notification(){
|
||||
$get_elite_notice = array(
|
||||
"show" => "no",
|
||||
"timestamp" => date( 'd-m-Y' )
|
||||
);
|
||||
check_ajax_referer( 'woosea_ajax_nonce', 'security' );
|
||||
|
||||
update_option('woosea_getelite_notification',$get_elite_notice);
|
||||
$user = wp_get_current_user();
|
||||
$allowed_roles = array( 'administrator','editor','author' );
|
||||
|
||||
if ( array_intersect( $allowed_roles, $user->roles ) ) {
|
||||
$get_elite_notice = array(
|
||||
"show" => "no",
|
||||
"timestamp" => date( 'd-m-Y' )
|
||||
);
|
||||
update_option('woosea_getelite_notification',$get_elite_notice);
|
||||
}
|
||||
}
|
||||
add_action( 'wp_ajax_woosea_getelite_notification', 'woosea_getelite_notification' );
|
||||
|
||||
@@ -842,49 +850,28 @@ add_action( 'wp_ajax_woosea_getelite_notification', 'woosea_getelite_notificatio
|
||||
* Close the get Elite activation notification
|
||||
**/
|
||||
function woosea_getelite_active_notification(){
|
||||
$get_elite_notice = array(
|
||||
"show" => "no",
|
||||
"timestamp" => date( 'd-m-Y' )
|
||||
);
|
||||
check_ajax_referer( 'woosea_ajax_nonce', 'security' );
|
||||
|
||||
update_option('woosea_getelite_active_notification',$get_elite_notice);
|
||||
$user = wp_get_current_user();
|
||||
$allowed_roles = array( 'administrator','editor','author' );
|
||||
|
||||
if ( array_intersect( $allowed_roles, $user->roles ) ) {
|
||||
$get_elite_notice = array(
|
||||
"show" => "no",
|
||||
"timestamp" => date( 'd-m-Y' )
|
||||
);
|
||||
update_option('woosea_getelite_active_notification',$get_elite_notice);
|
||||
}
|
||||
}
|
||||
add_action( 'wp_ajax_woosea_getelite_active_notification', 'woosea_getelite_active_notification' );
|
||||
|
||||
/**
|
||||
* Request our plugin users to write a review
|
||||
**/
|
||||
function woosea_request_review(){
|
||||
// Only request for a review when:
|
||||
// Plugin activation has been > 1 week
|
||||
// Active projects > 0
|
||||
|
||||
$cron_projects = get_option( 'cron_projects' );
|
||||
if(!empty( $cron_projects )){
|
||||
$nr_projects = count($cron_projects);
|
||||
$first_activation = get_option ( 'woosea_first_activation' );
|
||||
$notification_interaction = get_option( 'woosea_review_interaction' );
|
||||
$current_time = time();
|
||||
$show_after = 604800; // Show only after one week
|
||||
$is_active = $current_time-$first_activation;
|
||||
$page = sanitize_text_field(basename($_SERVER['REQUEST_URI']));
|
||||
|
||||
if(($nr_projects > 0) AND ($is_active > $show_after) AND ($notification_interaction != "yes")){
|
||||
echo '<div class="notice notice-info review-notification">';
|
||||
echo '<table><tr><td></td><td><font color="green" style="font-weight:normal";><p>Hey, I noticed you have been using our plugin, <u>Product Feed PRO for WooCommerce by AdTribes.io</u>, for over a week now and have created product feed projects with it - that\'s awesome! Could you please do Eva and me a BIG favor and give it a 5-star rating on WordPress? Just to help us spread the word and boost our motivation. We would greatly appreciate if you would do so :)<br/>~ Adtribes.io support team<br><ul><li><span class="ui-icon ui-icon-caret-1-e" style="display: inline-block;"></span><a href="https://wordpress.org/support/plugin/woo-product-feed-pro/reviews?rate=5#new-post" target="_blank" class="dismiss-review-notification">Ok, you deserve it</a></li><li><span class="ui-icon ui-icon-caret-1-e" style="display: inline-block;"></span><a href="#" class="dismiss-review-notification">Nope, maybe later</a></li><li><span class="ui-icon ui-icon-caret-1-e" style="display: inline-block;"></span><a href="#" class="dismiss-review-notification">I already did</a></li></ul></p></font></td></tr></table>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action('admin_notices', 'woosea_request_review');
|
||||
|
||||
/**
|
||||
* Add some JS and mark-up code on every front-end page in order to get the conversion tracking to work
|
||||
*/
|
||||
function woosea_hook_header() {
|
||||
$marker = sprintf('<!-- This website runs the Product Feed PRO for WooCommerce by AdTribes.io plugin - version ' . WOOCOMMERCESEA_PLUGIN_VERSION .' -->');
|
||||
$allowed_tags = array('<!--' => array(), '-->' => array());
|
||||
echo wp_kses("\n${marker}\n",$allowed_tags);
|
||||
echo wp_kses("\n{$marker}\n",$allowed_tags);
|
||||
}
|
||||
add_action('wp_head','woosea_hook_header');
|
||||
|
||||
@@ -953,7 +940,6 @@ add_action( 'wp_ajax_woosea_ajax', 'woosea_ajax' );
|
||||
*/
|
||||
function woosea_categories_dropdown() {
|
||||
$rowCount = absint(esc_attr(sanitize_text_field($_POST['rowCount'])));
|
||||
|
||||
$user = wp_get_current_user();
|
||||
$allowed_roles = array( 'administrator','editor','author' );
|
||||
|
||||
@@ -1012,7 +998,7 @@ function woosea_recursive_sanitize_text_field($array) {
|
||||
* Save Google Dynamic Remarketing Conversion Tracking ID
|
||||
*/
|
||||
function woosea_save_adwords_conversion_id() {
|
||||
check_ajax_referer('woosea_ajax_nonce', 'security2');
|
||||
check_ajax_referer('woosea_ajax_nonce', 'security');
|
||||
|
||||
$user = wp_get_current_user();
|
||||
$allowed_roles = array( 'administrator' );
|
||||
@@ -1572,7 +1558,6 @@ function woosea_product_delete_meta_price( $product = null ) {
|
||||
}
|
||||
return $markup_offer;
|
||||
}
|
||||
//add_filter( 'woocommerce_structured_data_product_offer', 'woosea_product_delete_meta_price', 1000, 1 );
|
||||
|
||||
|
||||
/**
|
||||
@@ -1964,26 +1949,31 @@ add_action( 'wp_ajax_woosea_shipping_zones', 'woosea_shipping_zones' );
|
||||
* Determine if any of the feeds is updating
|
||||
*/
|
||||
function woosea_check_processing(){
|
||||
$processing = "false";
|
||||
check_ajax_referer( 'woosea_ajax_nonce', 'security' );
|
||||
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
$found = false;
|
||||
$user = wp_get_current_user();
|
||||
$allowed_roles = array( 'administrator','editor','author' );
|
||||
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if(array_key_exists('running', $val)){
|
||||
if ( array_intersect( $allowed_roles, $user->roles ) ) {
|
||||
$processing = "false";
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
$found = false;
|
||||
|
||||
if(($val['running'] == "true") OR ($val['running'] == "stopped")){
|
||||
$processing = "true";
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if(array_key_exists('running', $val)){
|
||||
if( in_array($val['running'], array( "true", "processing", "stopped", "not run yet" ) ) ){
|
||||
$processing = "true";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = array (
|
||||
'processing' => $processing,
|
||||
);
|
||||
$data = array (
|
||||
'processing' => $processing,
|
||||
);
|
||||
|
||||
echo json_encode($data);
|
||||
wp_die();
|
||||
echo json_encode($data);
|
||||
wp_die();
|
||||
}
|
||||
}
|
||||
add_action( 'wp_ajax_woosea_check_processing', 'woosea_check_processing' );
|
||||
|
||||
@@ -2022,33 +2012,40 @@ add_action( 'wp_ajax_woosea_channel', 'woosea_channel' );
|
||||
* Delete a project from cron
|
||||
*/
|
||||
function woosea_project_delete(){
|
||||
$project_hash = sanitize_text_field($_POST['project_hash']);
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
$found = false;
|
||||
check_ajax_referer( 'woosea_ajax_nonce', 'security' );
|
||||
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if (isset($val['project_hash']) AND ($val['project_hash'] == $project_hash)){
|
||||
$found = true;
|
||||
$found_key = $key;
|
||||
$user = wp_get_current_user();
|
||||
$allowed_roles = array( 'administrator' );
|
||||
|
||||
$upload_dir = wp_upload_dir();
|
||||
$base = $upload_dir['basedir'];
|
||||
$path = $base . "/woo-product-feed-pro/" . $val['fileformat'];
|
||||
$file = $path . "/" . sanitize_file_name($val['filename']) . "." . $val['fileformat'];
|
||||
if ( array_intersect( $allowed_roles, $user->roles ) ) {
|
||||
|
||||
$project_hash = sanitize_text_field($_POST['project_hash']);
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
$found = false;
|
||||
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if (isset($val['project_hash']) AND ($val['project_hash'] == $project_hash)){
|
||||
$found = true;
|
||||
$found_key = $key;
|
||||
|
||||
$upload_dir = wp_upload_dir();
|
||||
$base = $upload_dir['basedir'];
|
||||
$path = $base . "/woo-product-feed-pro/" . $val['fileformat'];
|
||||
$file = $path . "/" . sanitize_file_name($val['filename']) . "." . $val['fileformat'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($found == "true"){
|
||||
# Remove project from project array
|
||||
unset($feed_config[$found_key]);
|
||||
if ($found == "true"){
|
||||
# Remove project from project array
|
||||
unset($feed_config[$found_key]);
|
||||
|
||||
# Update cron
|
||||
update_option('cron_projects', $feed_config, 'no');
|
||||
|
||||
# Remove project file
|
||||
@unlink($file);
|
||||
}
|
||||
# Update cron
|
||||
update_option('cron_projects', $feed_config, 'no');
|
||||
|
||||
# Remove project file
|
||||
@unlink($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'wp_ajax_woosea_project_delete', 'woosea_project_delete' );
|
||||
|
||||
@@ -2056,29 +2053,37 @@ add_action( 'wp_ajax_woosea_project_delete', 'woosea_project_delete' );
|
||||
* Stop processing of a project
|
||||
*/
|
||||
function woosea_project_cancel(){
|
||||
$project_hash = sanitize_text_field($_POST['project_hash']);
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
check_ajax_referer( 'woosea_ajax_nonce', 'security' );
|
||||
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if ($val['project_hash'] == $project_hash){
|
||||
$user = wp_get_current_user();
|
||||
$allowed_roles = array( 'administrator' );
|
||||
|
||||
$batch_project = "batch_project_".$project_hash;
|
||||
delete_option( $batch_project );
|
||||
if ( array_intersect( $allowed_roles, $user->roles ) ) {
|
||||
|
||||
$project_hash = sanitize_text_field($_POST['project_hash']);
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if ($val['project_hash'] == $project_hash){
|
||||
|
||||
$batch_project = "batch_project_".$project_hash;
|
||||
delete_option( $batch_project );
|
||||
|
||||
$feed_config[$key]['nr_products_processed'] = 0;
|
||||
$feed_config[$key]['nr_products_processed'] = 0;
|
||||
|
||||
// Set processing status on ready
|
||||
$feed_config[$key]['running'] = "stopped";
|
||||
$feed_config[$key]['last_updated'] = date("d M Y H:i");
|
||||
// Set processing status on ready
|
||||
$feed_config[$key]['running'] = "stopped";
|
||||
$feed_config[$key]['last_updated'] = date("d M Y H:i");
|
||||
|
||||
// Delete processed product array for preventing duplicates
|
||||
delete_option('woosea_duplicates');
|
||||
// Delete processed product array for preventing duplicates
|
||||
delete_option('woosea_duplicates');
|
||||
|
||||
// In 1 minute from now check the amount of products in the feed and update the history count
|
||||
wp_schedule_single_event( time() + 60, 'woosea_update_project_stats', array($val['project_hash']) );
|
||||
}
|
||||
}
|
||||
update_option( 'cron_projects', $feed_config, 'no');
|
||||
// In 1 minute from now check the amount of products in the feed and update the history count
|
||||
wp_schedule_single_event( time() + 60, 'woosea_update_project_stats', array($val['project_hash']) );
|
||||
}
|
||||
}
|
||||
update_option( 'cron_projects', $feed_config, 'no');
|
||||
}
|
||||
}
|
||||
add_action( 'wp_ajax_woosea_project_cancel', 'woosea_project_cancel' );
|
||||
|
||||
@@ -2086,32 +2091,43 @@ add_action( 'wp_ajax_woosea_project_cancel', 'woosea_project_cancel' );
|
||||
* Get the processing status of a project feed
|
||||
*/
|
||||
function woosea_project_processing_status(){
|
||||
$project_hash = sanitize_text_field($_POST['project_hash']);
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
$proc_perc = 0;
|
||||
check_ajax_referer( 'woosea_ajax_nonce', 'security' );
|
||||
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if (isset($val['project_hash']) AND ($val['project_hash'] === $project_hash)){
|
||||
$this_feed = $val;
|
||||
$user = wp_get_current_user();
|
||||
$allowed_roles = array( 'administrator','editor','author' );
|
||||
|
||||
if ( array_intersect( $allowed_roles, $user->roles ) ) {
|
||||
|
||||
$project_hash = sanitize_text_field($_POST['project_hash']);
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
$proc_perc = 0;
|
||||
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if (isset($val['project_hash']) AND ($val['project_hash'] === $project_hash)){
|
||||
$this_feed = $val;
|
||||
}
|
||||
}
|
||||
|
||||
if($this_feed['running'] == "ready"){
|
||||
$proc_perc = 100;
|
||||
} elseif($this_feed['running'] == "not run yet"){
|
||||
$proc_perc = 999;
|
||||
} else {
|
||||
if(isset($this_feed['nr_products'])){
|
||||
if($this_feed['nr_products'] > 0){
|
||||
$proc_perc = round(($this_feed['nr_products_processed']/$this_feed['nr_products'])*100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($this_feed['running'] == "ready"){
|
||||
$proc_perc = 100;
|
||||
} elseif($this_feed['running'] == "not run yet"){
|
||||
$proc_perc = 999;
|
||||
} else {
|
||||
$proc_perc = round(($this_feed['nr_products_processed']/$this_feed['nr_products'])*100);
|
||||
$data = array (
|
||||
'project_hash' => $project_hash,
|
||||
'running' => $this_feed['running'],
|
||||
'proc_perc' => $proc_perc,
|
||||
);
|
||||
echo json_encode($data);
|
||||
wp_die();
|
||||
}
|
||||
|
||||
$data = array (
|
||||
'project_hash' => $project_hash,
|
||||
'running' => $this_feed['running'],
|
||||
'proc_perc' => $proc_perc,
|
||||
);
|
||||
echo json_encode($data);
|
||||
wp_die();
|
||||
|
||||
}
|
||||
add_action( 'wp_ajax_woosea_project_processing_status', 'woosea_project_processing_status' );
|
||||
|
||||
@@ -2119,68 +2135,75 @@ add_action( 'wp_ajax_woosea_project_processing_status', 'woosea_project_processi
|
||||
* Copy a project
|
||||
*/
|
||||
function woosea_project_copy(){
|
||||
$project_hash = sanitize_text_field($_POST['project_hash']);
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
check_ajax_referer( 'woosea_ajax_nonce', 'security' );
|
||||
|
||||
$max_key = max(array_keys($feed_config));
|
||||
$add_project = array();
|
||||
$upload_dir = wp_upload_dir();
|
||||
$external_base = $upload_dir['baseurl'];
|
||||
$user = wp_get_current_user();
|
||||
$allowed_roles = array( 'administrator' );
|
||||
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if ($val['project_hash'] == $project_hash){
|
||||
$val['projectname'] = "Copy ". $val['projectname'];
|
||||
if ( array_intersect( $allowed_roles, $user->roles ) ) {
|
||||
|
||||
// New code to create the project hash so dependency on openSSL is removed
|
||||
$keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$pieces = [];
|
||||
$length = 32;
|
||||
$max = mb_strlen($keyspace, '8bit') - 1;
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
$pieces []= $keyspace[random_int(0, $max)];
|
||||
}
|
||||
$val['project_hash'] = implode('', $pieces);
|
||||
//$val['project_hash'] = bin2hex(openssl_random_pseudo_bytes(16));
|
||||
$val['filename'] = $val['project_hash'];
|
||||
$val['utm_campaign'] = "Copy ". $val['utm_campaign'];
|
||||
$val['last_updated'] = "";
|
||||
$val['running'] = "not run yet";
|
||||
$project_hash = sanitize_text_field($_POST['project_hash']);
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
|
||||
// Construct product feed URL
|
||||
$external_path = $external_base . "/woo-product-feed-pro/" . $val['fileformat'];
|
||||
$val['external_file'] = $external_path . "/" . sanitize_file_name($val['filename']) . "." . $val['fileformat'];
|
||||
$max_key = max(array_keys($feed_config));
|
||||
$add_project = array();
|
||||
$upload_dir = wp_upload_dir();
|
||||
$external_base = $upload_dir['baseurl'];
|
||||
|
||||
// To build the new project row on the manage feed page
|
||||
$projecthash = $val['project_hash'];
|
||||
$projectname = $val['projectname'];
|
||||
$channel = $val['name'];
|
||||
$fileformat = $val['fileformat'];
|
||||
$interval = $val['cron'];
|
||||
$external_file = $val['external_file'];
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if ($val['project_hash'] == $project_hash){
|
||||
$val['projectname'] = "Copy ". $val['projectname'];
|
||||
|
||||
// Save the copied project
|
||||
$new_key = $max_key+1;
|
||||
$add_project[$new_key] = $val;
|
||||
array_push($feed_config, $add_project[$new_key]);
|
||||
update_option( 'cron_projects', $feed_config, 'no');
|
||||
// New code to create the project hash so dependency on openSSL is removed
|
||||
$keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$pieces = [];
|
||||
$length = 32;
|
||||
$max = mb_strlen($keyspace, '8bit') - 1;
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
$pieces []= $keyspace[random_int(0, $max)];
|
||||
}
|
||||
$val['project_hash'] = implode('', $pieces);
|
||||
$val['filename'] = $val['project_hash'];
|
||||
$val['utm_campaign'] = "Copy ". $val['utm_campaign'];
|
||||
$val['last_updated'] = "";
|
||||
$val['running'] = "not run yet";
|
||||
|
||||
// Construct product feed URL
|
||||
$external_path = $external_base . "/woo-product-feed-pro/" . $val['fileformat'];
|
||||
$val['external_file'] = $external_path . "/" . sanitize_file_name($val['filename']) . "." . $val['fileformat'];
|
||||
|
||||
// To build the new project row on the manage feed page
|
||||
$projecthash = $val['project_hash'];
|
||||
$projectname = $val['projectname'];
|
||||
$channel = $val['name'];
|
||||
$fileformat = $val['fileformat'];
|
||||
$interval = $val['cron'];
|
||||
$external_file = $val['external_file'];
|
||||
|
||||
// Save the copied project
|
||||
$new_key = $max_key+1;
|
||||
$add_project[$new_key] = $val;
|
||||
array_push($feed_config, $add_project[$new_key]);
|
||||
update_option( 'cron_projects', $feed_config, 'no');
|
||||
|
||||
// Do not start processing, user wants to make changes to the copied project
|
||||
$copy_status = "true";
|
||||
// Do not start processing, user wants to make changes to the copied project
|
||||
$copy_status = "true";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = array (
|
||||
'project_hash' => $projecthash,
|
||||
'channel' => $channel,
|
||||
'projectname' => $projectname,
|
||||
'fileformat' => $fileformat,
|
||||
'interval' => $interval,
|
||||
'external_file' => $external_file,
|
||||
'copy_status' => $copy_status
|
||||
);
|
||||
$data = array (
|
||||
'project_hash' => $projecthash,
|
||||
'channel' => $channel,
|
||||
'projectname' => $projectname,
|
||||
'fileformat' => $fileformat,
|
||||
'interval' => $interval,
|
||||
'external_file' => $external_file,
|
||||
'copy_status' => $copy_status
|
||||
);
|
||||
|
||||
echo json_encode($data);
|
||||
wp_die();
|
||||
echo json_encode($data);
|
||||
wp_die();
|
||||
}
|
||||
}
|
||||
add_action( 'wp_ajax_woosea_project_copy', 'woosea_project_copy' );
|
||||
|
||||
@@ -2188,6 +2211,12 @@ add_action( 'wp_ajax_woosea_project_copy', 'woosea_project_copy' );
|
||||
* Refresh a project
|
||||
*/
|
||||
function woosea_project_refresh(){
|
||||
check_ajax_referer( 'woosea_ajax_nonce', 'security' );
|
||||
|
||||
// Force garbage collection dump
|
||||
gc_enable();
|
||||
gc_collect_cycles();
|
||||
|
||||
$project_hash = sanitize_text_field($_POST['project_hash']);
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
|
||||
@@ -2195,11 +2224,62 @@ function woosea_project_refresh(){
|
||||
$allowed_roles = array( 'administrator','editor','author' );
|
||||
|
||||
if ( array_intersect( $allowed_roles, $user->roles ) ) {
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
|
||||
// Make sure content of feeds is not being cached
|
||||
|
||||
// Make sure feeds are not being cached
|
||||
$no_caching = new WooSEA_Caching();
|
||||
|
||||
// LiteSpeed Caching
|
||||
if (class_exists( 'LiteSpeed\Core' ) || defined( 'LSCWP_DIR' ) ) {
|
||||
$no_caching->litespeed_cache();
|
||||
}
|
||||
|
||||
// WP Fastest Caching
|
||||
if (class_exists( 'WpFastestCache' ) ) {
|
||||
$no_caching->wp_fastest_cache();
|
||||
}
|
||||
|
||||
// WP Super Caching
|
||||
if (function_exists( 'wpsc_init' ) ) {
|
||||
$no_caching->wp_super_cache();
|
||||
}
|
||||
|
||||
// Breeze Caching
|
||||
if (class_exists( 'Breeze_Admin' ) ) {
|
||||
$no_caching->breeze_cache();
|
||||
}
|
||||
|
||||
// WP Optimize Caching
|
||||
if (class_exists( 'WP_Optimize' ) ) {
|
||||
$no_caching->wp_optimize_cache();
|
||||
}
|
||||
|
||||
// Cache Enabler
|
||||
if (class_exists( 'Cache_Enabler' ) ) {
|
||||
$no_caching->cache_enabler_cache();
|
||||
}
|
||||
|
||||
// Swift Performance Lite
|
||||
if (class_exists( 'Swift_Performance_Lite' ) ) {
|
||||
$no_caching->swift_performance_cache();
|
||||
}
|
||||
|
||||
// Comet Cache
|
||||
if (is_plugin_active( 'comet-cache/comet-cache.php' ) ) {
|
||||
$no_caching->comet_cache();
|
||||
}
|
||||
|
||||
// HyperCache
|
||||
if (class_exists( 'HyperCache' ) ) {
|
||||
$no_caching->hyper_cache();
|
||||
}
|
||||
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if (isset($val['project_hash']) AND ($val['project_hash'] == $project_hash)){
|
||||
$batch_project = "batch_project_".$project_hash;
|
||||
if (!get_option( $batch_project )){
|
||||
update_option( $batch_project, $val);
|
||||
update_option( $batch_project, $val, 'no');
|
||||
$final_creation = woosea_continue_batch($project_hash);
|
||||
} else {
|
||||
$final_creation = woosea_continue_batch($project_hash);
|
||||
@@ -2258,37 +2338,44 @@ add_action( 'wp_ajax_woosea_add_attributes', 'woosea_add_attributes' );
|
||||
* Change status of a project from active to inactive or visa versa
|
||||
*/
|
||||
function woosea_project_status() {
|
||||
$project_hash = sanitize_text_field($_POST['project_hash']);
|
||||
$active = sanitize_text_field($_POST['active']);
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
check_ajax_referer( 'woosea_ajax_nonce', 'security' );
|
||||
|
||||
$number_feeds = count($feed_config);
|
||||
$user = wp_get_current_user();
|
||||
$allowed_roles = array( 'administrator','editor','author' );
|
||||
|
||||
if ($number_feeds > 0){
|
||||
if ( array_intersect( $allowed_roles, $user->roles ) ) {
|
||||
$project_hash = sanitize_text_field($_POST['project_hash']);
|
||||
$active = sanitize_text_field($_POST['active']);
|
||||
$feed_config = get_option( 'cron_projects' );
|
||||
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if ($val['project_hash'] == $project_hash){
|
||||
$feed_config[$key]['active'] = $active;
|
||||
$upload_dir = wp_upload_dir();
|
||||
$base = $upload_dir['basedir'];
|
||||
$path = $base . "/woo-product-feed-pro/" . $val['fileformat'];
|
||||
$file = $path . "/" . sanitize_file_name($val['filename']) . "." . $val['fileformat'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$number_feeds = count($feed_config);
|
||||
|
||||
// When project is put on inactive, delete the product feed
|
||||
if($active == "false"){
|
||||
@unlink($file);
|
||||
}
|
||||
if ($number_feeds > 0){
|
||||
|
||||
// Regenerate product feed
|
||||
if($active == "true"){
|
||||
$update_project = woosea_project_refresh($project_hash);
|
||||
}
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
if ($val['project_hash'] == $project_hash){
|
||||
$feed_config[$key]['active'] = $active;
|
||||
$upload_dir = wp_upload_dir();
|
||||
$base = $upload_dir['basedir'];
|
||||
$path = $base . "/woo-product-feed-pro/" . $val['fileformat'];
|
||||
$file = $path . "/" . sanitize_file_name($val['filename']) . "." . $val['fileformat'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update cron with new project status
|
||||
update_option( 'cron_projects', $feed_config, 'no');
|
||||
// When project is put on inactive, delete the product feed
|
||||
if($active == "false"){
|
||||
@unlink($file);
|
||||
}
|
||||
|
||||
// Regenerate product feed
|
||||
if($active == "true"){
|
||||
$update_project = woosea_project_refresh($project_hash);
|
||||
}
|
||||
|
||||
// Update cron with new project status
|
||||
update_option( 'cron_projects', $feed_config, 'no');
|
||||
}
|
||||
}
|
||||
add_action( 'wp_ajax_woosea_project_status', 'woosea_project_status' );
|
||||
|
||||
@@ -2298,7 +2385,13 @@ add_action( 'wp_ajax_woosea_project_status', 'woosea_project_status' );
|
||||
*/
|
||||
function woosea_review_notification() {
|
||||
// Update review notification status
|
||||
update_option( 'woosea_review_interaction', 'yes', 'yes');
|
||||
check_ajax_referer( 'woosea_ajax_nonce', 'security' );
|
||||
$user = wp_get_current_user();
|
||||
$allowed_roles = array( 'administrator','editor','author' );
|
||||
|
||||
if ( array_intersect( $allowed_roles, $user->roles ) ) {
|
||||
update_option( 'woosea_review_interaction', 'yes', 'yes');
|
||||
}
|
||||
}
|
||||
add_action( 'wp_ajax_woosea_review_notification', 'woosea_review_notification' );
|
||||
|
||||
@@ -2631,7 +2724,9 @@ add_action( 'wp_ajax_woosea_add_facebook_capi_setting', 'woosea_add_facebook_cap
|
||||
* This function saves the value that needs to be used in the Facebook pixel content_ids parameter
|
||||
*/
|
||||
function woosea_facebook_content_ids (){
|
||||
$user = wp_get_current_user();
|
||||
check_ajax_referer('woosea_ajax_nonce', 'security');
|
||||
|
||||
$user = wp_get_current_user();
|
||||
$allowed_roles = array( 'administrator' );
|
||||
|
||||
if ( array_intersect( $allowed_roles, $user->roles ) ) {
|
||||
@@ -4140,8 +4235,10 @@ function woosea_update_project_history($project_hash){
|
||||
$nr_products = count($xml->offers->offer);
|
||||
}
|
||||
} else {
|
||||
if ($project['taxonomy'] == "none"){
|
||||
$nr_products = count($xml->product);
|
||||
if ($project['taxonomy'] == "none"){
|
||||
if(is_countable($xml->product)){
|
||||
$nr_products = count($xml->product);
|
||||
}
|
||||
} else {
|
||||
$nr_products = count($xml->channel->item);
|
||||
}
|
||||
@@ -4424,7 +4521,7 @@ function woosea_generate_pages(){
|
||||
|
||||
if (!get_option( $batch_project )) {
|
||||
// Batch project hook expects a multidimentional array
|
||||
update_option( $batch_project, $project_data);
|
||||
update_option( $batch_project, $project_data, 'no');
|
||||
$final_creation = woosea_continue_batch($project_data['project_hash']);
|
||||
} else {
|
||||
$final_creation = woosea_continue_batch($project_data['project_hash']);
|
||||
@@ -4465,9 +4562,6 @@ function woosea_generate_pages(){
|
||||
case 9:
|
||||
load_template( plugin_dir_path( __FILE__ ) . '/pages/admin/woosea-generate-feed-step-9.php' );
|
||||
break;
|
||||
case 11:
|
||||
load_template( plugin_dir_path( __FILE__ ) . '/pages/admin/woosea-gs-analytics.php' );
|
||||
break;
|
||||
case 100:
|
||||
load_template( plugin_dir_path( __FILE__ ) . '/pages/admin/woosea-manage-feed.php' );
|
||||
break;
|
||||
@@ -4505,6 +4599,56 @@ function woosea_create_all_feeds(){
|
||||
$products_changes = "no"; // default value
|
||||
$products_changes = get_option('woosea_allow_update');
|
||||
|
||||
// Make sure content of feeds is not being cached
|
||||
|
||||
// Make sure feeds are not being cached
|
||||
$no_caching = new WooSEA_Caching();
|
||||
|
||||
// LiteSpeed Caching
|
||||
if (class_exists( 'LiteSpeed\Core' ) || defined( 'LSCWP_DIR' ) ) {
|
||||
$no_caching->litespeed_cache();
|
||||
}
|
||||
|
||||
// WP Fastest Caching
|
||||
if (class_exists( 'WpFastestCache' ) ) {
|
||||
$no_caching->wp_fastest_cache();
|
||||
}
|
||||
|
||||
// WP Super Caching
|
||||
if (function_exists( 'wpsc_init' ) ) {
|
||||
$no_caching->wp_super_cache();
|
||||
}
|
||||
|
||||
// Breeze Caching
|
||||
if (class_exists( 'Breeze_Admin' ) ) {
|
||||
$no_caching->breeze_cache();
|
||||
}
|
||||
|
||||
// WP Optimize Caching
|
||||
if (class_exists( 'WP_Optimize' ) ) {
|
||||
$no_caching->wp_optimize_cache();
|
||||
}
|
||||
|
||||
// Cache Enabler
|
||||
if (class_exists( 'Cache_Enabler' ) ) {
|
||||
$no_caching->cache_enabler_cache();
|
||||
}
|
||||
|
||||
// Swift Performance Lite
|
||||
if (class_exists( 'Swift_Performance_Lite' ) ) {
|
||||
$no_caching->swift_performance_cache();
|
||||
}
|
||||
|
||||
// Comet Cache
|
||||
if (is_plugin_active( 'comet-cache/comet-cache.php' ) ) {
|
||||
$no_caching->comet_cache();
|
||||
}
|
||||
|
||||
// HyperCache
|
||||
if (class_exists( 'HyperCache' ) ) {
|
||||
$no_caching->hyper_cache();
|
||||
}
|
||||
|
||||
if(!empty($feed_config)){
|
||||
foreach ( $feed_config as $key => $val ) {
|
||||
|
||||
@@ -4520,11 +4664,10 @@ function woosea_create_all_feeds(){
|
||||
|
||||
// Only process projects that are active
|
||||
if(($val['active'] == "true") AND (!empty($val)) AND($update_this_feed == "yes") AND (isset($val['cron']))){
|
||||
|
||||
if (($val['cron'] == "daily") AND ($hour == 07)){
|
||||
$batch_project = "batch_project_".$val['project_hash'];
|
||||
if (!get_option( $batch_project )){
|
||||
update_option( $batch_project, $val);
|
||||
update_option( $batch_project, $val, 'no');
|
||||
$start_project = woosea_continue_batch($val['project_hash']);
|
||||
} else {
|
||||
$start_project = woosea_continue_batch($val['project_hash']);
|
||||
@@ -4533,7 +4676,7 @@ function woosea_create_all_feeds(){
|
||||
} elseif (($val['cron'] == "twicedaily") AND ($hour == 19 || $hour == 07)){
|
||||
$batch_project = "batch_project_".$val['project_hash'];
|
||||
if (!get_option( $batch_project )){
|
||||
update_option( $batch_project, $val);
|
||||
update_option( $batch_project, $val, 'no');
|
||||
$start_project = woosea_continue_batch($val['project_hash']);
|
||||
} else {
|
||||
$start_project = woosea_continue_batch($val['project_hash']);
|
||||
@@ -4543,7 +4686,7 @@ function woosea_create_all_feeds(){
|
||||
// Re-start daily and twicedaily projects that are hanging
|
||||
$batch_project = "batch_project_".$val['project_hash'];
|
||||
if (!get_option( $batch_project )){
|
||||
update_option( $batch_project, $val);
|
||||
update_option( $batch_project, $val, 'no');
|
||||
$start_project = woosea_continue_batch($val['project_hash']);
|
||||
} else {
|
||||
$start_project = woosea_continue_batch($val['project_hash']);
|
||||
@@ -4554,7 +4697,7 @@ function woosea_create_all_feeds(){
|
||||
} elseif ($val['cron'] == "hourly") {
|
||||
$batch_project = "batch_project_".$val['project_hash'];
|
||||
if (!get_option( $batch_project )){
|
||||
update_option( $batch_project, $val);
|
||||
update_option( $batch_project, $val, 'no');
|
||||
$start_project = woosea_continue_batch($val['project_hash']);
|
||||
} else {
|
||||
$start_project = woosea_continue_batch($val['project_hash']);
|
||||
|
||||
Reference in New Issue
Block a user