Changeset 2955372
- Timestamp:
- 08/18/2023 12:40:59 PM (3 years ago)
- Location:
- linkmydeals/trunk
- Files:
-
- 2 edited
-
linkmydeals.php (modified) (3 diffs)
-
pull-feed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
linkmydeals/trunk/linkmydeals.php
r2945805 r2955372 3 3 /** 4 4 * @package LinkMyDeals 5 * @version 1. 45 * @version 1.5.1 6 6 */ 7 7 … … 11 11 * Author URI: https://linkmydeals.com/ 12 12 * Description: LinkMyDeals.com provides Coupon & Deal Feeds from hundreds of Online Stores. You can use this plugin to automate/upload the feeds into your Coupon Theme. 13 * Version: 1. 413 * Version: 1.5.1 14 14 * Author: LinkMyDeals Team 15 15 **/ … … 406 406 function linkmydeals_is_theme_supported($theme_name) 407 407 { 408 $supported = array('clipmydeals', 'clipper', 'couponxl', 'couponxxl', 'couponer', 'rehub', 'rehub-theme', 'wpcoupon', 'wp-coupon', 'wp-coupon-pro', 'CP', 'cp', 'CPq', 'mts_coupon', 'couponis', 'couponhut' );408 $supported = array('clipmydeals', 'clipper', 'couponxl', 'couponxxl', 'couponer', 'rehub', 'rehub-theme', 'wpcoupon', 'wp-coupon', 'wp-coupon-pro', 'CP', 'cp', 'CPq', 'mts_coupon', 'couponis', 'couponhut','coupon-mart'); 409 409 return (in_array($theme_name, $supported) or substr($theme_name, 0, 2) === "CP"); 410 410 } -
linkmydeals/trunk/pull-feed.php
r2945805 r2955372 260 260 elseif ($theme == 'couponis') linkmydeals_couponis_process_batch($coupons, $config); 261 261 elseif ($theme == 'couponhut') linkmydeals_couponhut_process_batch($coupons, $config); 262 elseif ($theme == 'coupon-mart') linkmydeals_couponmart_process_batch($coupons,$config); 262 263 263 264 wp_defer_term_counting(false); … … 1956 1957 1957 1958 1959 function linkmydeals_couponmart_process_batch($coupons,$config){ 1960 global $wpdb; 1961 $wp_prefix = $wpdb->prefix; 1962 1963 1964 $count_new = $count_suspended = $count_updated = 0; 1965 $found_count = (count($coupons) > 0) ? count($coupons) : 0; 1966 1967 $wpdb->query("INSERT INTO " . $wp_prefix . "linkmydeals_logs (microtime,msg_type,message) VALUES (" . microtime(true) . ",'info','Found $found_count coupons to process')"); 1968 1969 foreach ($coupons as $coupon) { 1970 1971 if ($coupon->status == 'new' or $coupon->status == '' or $coupon->status == 'active') { 1972 1973 $wpdb->query("INSERT INTO " . $wp_prefix . "linkmydeals_logs (microtime,msg_type,message) VALUES (" . microtime(true) . ",'debug','Adding New Coupon (" . $coupon->lmd_id . ")')"); 1974 1975 $post_data = array( 1976 'ID' => '', 1977 'post_title' => $coupon->title, 1978 'post_content' => $coupon->description, 1979 'post_status' => 'publish', 1980 'post_type' => 'coupon', 1981 'post_author' => get_current_user_id() 1982 ); 1983 $post_id = wp_insert_post($post_data); 1984 1985 $cat_names = explode(',', $coupon->categories); 1986 $append = false; 1987 foreach ($cat_names as $cat) { 1988 if (!term_exists($cat, 'coupon_category')) { 1989 $term = wp_insert_term($cat, 'coupon_category'); 1990 } 1991 wp_set_object_terms($post_id, $cat, 'coupon_category', $append); 1992 $append = true; 1993 } 1994 1995 $str_names = explode(',', $coupon->store); 1996 $append = false; 1997 foreach ($str_names as $str) { 1998 // Create New Store 1999 if (!term_exists($str, 'coupon_store')) { 2000 $term = wp_insert_term($str, 'coupon_store'); // , $args third parameter 2001 if (!is_wp_error($term)) { // Term did not exist. Got inserted now. 2002 2003 // Update Meta Info 2004 update_term_meta($term['term_id'], '_wpc_store_url', $coupon->homepage_url);//store taxonomy args in wp_options 2005 } 2006 } 2007 wp_set_object_terms($post_id, $str, 'coupon_store', $append); 2008 $append = true; 2009 } 2010 2011 update_post_meta($post_id, 'lmd_id', $coupon->lmd_id); 2012 update_post_meta($post_id, '_wpc_coupon_type', ($coupon->type == 'Code' ? 'code' : 'sale')); 2013 update_post_meta($post_id, '_wpc_coupon_type_code', $coupon->code); 2014 2015 update_post_meta($post_id, '_wpc_destination_url', $coupon->url); 2016 2017 update_post_meta($post_id, '_wpc_start_on', (empty($coupon->start_date) ? '' : strtotime($coupon->start_date))); 2018 update_post_meta($post_id, '_wpc_expires', (empty($coupon->end_date) ? '' : strtotime($coupon->end_date))); 2019 update_post_meta($post_id, '_wpc_coupon_save', $coupon->badge ); 2020 set_post_thumbnail($post_id, $config['import_images'] != 'Off' ? linkmydeals_import_image($coupon->image_url, $coupon->lmd_id) : 0); 2021 2022 $count_new = $count_new + 1; 2023 } elseif ($coupon->status == 'updated') { 2024 2025 $wpdb->query("INSERT INTO " . $wp_prefix . "linkmydeals_logs (microtime,msg_type,message) VALUES (" . microtime(true) . ",'debug','Updating Coupon (" . $coupon->lmd_id . ")')"); 2026 2027 $lmd_id = $coupon->lmd_id; 2028 $sql_id = "SELECT post_id FROM " . $wp_prefix . "postmeta WHERE meta_key = 'lmd_id' AND meta_value = '$lmd_id' LIMIT 0,1"; 2029 $post_id = $wpdb->get_var($sql_id); 2030 $data = get_post($post_id); 2031 $title = (!empty($coupon->title)) ? $coupon->title : $data->post_title; 2032 $description = (!empty($coupon->description)) ? $coupon->description : $data->post_content; 2033 $post_data = array( 2034 'ID' => $post_id, 2035 'post_title' => $title, 2036 'post_content' => $description, 2037 'post_status' => 'publish', 2038 'post_author' => get_current_user_id() 2039 ); 2040 wp_update_post($post_data); 2041 2042 if (!empty($coupon->categories)) { 2043 $cat_names = explode(',', $coupon->categories); 2044 $append = false; 2045 foreach ($cat_names as $cat) { 2046 wp_set_object_terms($post_id, $cat, 'coupon_category', $append); 2047 $append = true; 2048 } 2049 } 2050 2051 if (!empty($coupon->store)) { 2052 $str_names = explode(',', $coupon->store); 2053 $append = false; 2054 foreach ($str_names as $str) { 2055 wp_set_object_terms($post_id, $str, 'coupon_store', $append); 2056 $append = true; 2057 } 2058 } 2059 2060 if (!empty($coupon->type)) { 2061 update_post_meta($post_id, '_wpc_coupon_type', ($coupon->type == 'Code' ? 'code' : 'sale')); 2062 } 2063 if (!empty($coupon->code)) { 2064 update_post_meta($post_id, '_wpc_coupon_type_code', $coupon->code); 2065 } 2066 2067 if (!empty($coupon->url)) { 2068 update_post_meta($post_id, '_wpc_destination_url', $coupon->url); 2069 } 2070 2071 $start_date = (!empty($coupon->start_date)) ? strtotime($coupon->start_date) : get_post_meta($post_id, '_wpc_start_on', true); 2072 $end_date = (!empty($coupon->end_date)) ? strtotime($coupon->end_date) : get_post_meta($post_id, '_wpc_expires', true); 2073 2074 update_post_meta($post_id, '_wpc_start_on', (empty($start_date) ? '' : $start_date)); 2075 if (empty($end_date)) { 2076 update_post_meta($post_id, '_wpc_expires', ''); 2077 } else { 2078 update_post_meta($post_id, '_wpc_expires', $end_date); 2079 } 2080 2081 $count_updated = $count_updated + 1; 2082 } elseif ($coupon->status == 'suspended') { 2083 2084 $wpdb->query("INSERT INTO " . $wp_prefix . "linkmydeals_logs (microtime,msg_type,message) VALUES (" . microtime(true) . ",'debug','Suspending Coupon (" . $coupon->lmd_id . ")')"); 2085 2086 $lmd_id = $coupon->lmd_id; 2087 $sql_id = "SELECT post_id FROM " . $wp_prefix . "postmeta WHERE meta_key = 'lmd_id' AND meta_value = '$lmd_id' LIMIT 0,1"; 2088 $post_id = $wpdb->get_var($sql_id); 2089 2090 wp_delete_post($post_id, true); 2091 2092 $count_suspended = $count_suspended + 1; 2093 } 2094 2095 $wpdb->query("DELETE FROM " . $wp_prefix . "linkmydeals_upload WHERE lmd_id = " . $coupon->lmd_id); 2096 } 2097 2098 $wpdb->query("INSERT INTO " . $wp_prefix . "linkmydeals_logs (microtime,msg_type,message) VALUES (" . microtime(true) . ",'info','Processed Offers - $count_new New , $count_updated Updated , $count_suspended Suspended.')"); 2099 } 2100 2101 1958 2102 function linkmydeals_import_image($image_url, $lmd_id = 0) 1959 2103 {
Note: See TracChangeset
for help on using the changeset viewer.