Changeset 3177805
- Timestamp:
- 10/29/2024 09:02:22 AM (17 months ago)
- Location:
- linkmydeals/trunk
- Files:
-
- 3 edited
-
linkmydeals.php (modified) (3 diffs)
-
pull-feed.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
linkmydeals/trunk/linkmydeals.php
r3170465 r3177805 3 3 /** 4 4 * @package LinkMyDeals 5 * @version 2. 0.55 * @version 2.1.0 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: 2. 0.513 * Version: 2.1.0 14 14 * Author: LinkMyDeals Team 15 15 **/ … … 414 414 function linkmydeals_is_theme_supported($theme_name) 415 415 { 416 $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' );416 $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','coupon-press'); 417 417 return (in_array($theme_name, $supported) or substr($theme_name, 0, 2) === "CP"); 418 418 } -
linkmydeals/trunk/pull-feed.php
r3170465 r3177805 257 257 elseif ($theme == 'couponhut') linkmydeals_couponhut_process_batch($coupons, $config); 258 258 elseif ($theme == 'coupon-mart') linkmydeals_couponmart_process_batch($coupons,$config); 259 elseif ($theme == 'coupon-press') linkmydeals_coupon_press_process_batch($coupons,$config); 259 260 else linkmydeals_generic_theme_process_batch($coupons,$config); 260 261 … … 2095 2096 } 2096 2097 2098 function linkmydeals_coupon_press_process_batch($coupons,$config) 2099 { 2100 global $wpdb; 2101 $wp_prefix = $wpdb->prefix; 2102 2103 $categories = array(); 2104 $categoryTerms = get_terms(array( 2105 'taxonomy' => 'coupon_category', 2106 'hide_empty' => false 2107 )); 2108 foreach ($categoryTerms as $term) { 2109 $categories[$term->name] = $term->slug; 2110 } 2111 2112 $stores = array(); 2113 $storeTerms = get_terms(array( 2114 'taxonomy' => 'coupon_store', 2115 'hide_empty' => false 2116 )); 2117 foreach ($storeTerms as $term) { 2118 $stores[$term->name] = $term->slug; 2119 } 2120 2121 $count_new = $count_suspended = $count_updated = 0; 2122 $found_count = is_array($coupons) ? count($coupons) : 0; 2123 2124 $wpdb->query("INSERT INTO {$wp_prefix}linkmydeals_logs (microtime,msg_type,message) VALUES (" . microtime(true) . ",'info','Found $found_count coupons to process')"); 2125 2126 foreach ($coupons as $coupon) { 2127 2128 if ($coupon->status == 'new' or $coupon->status == '' or $coupon->status == 'active') { 2129 2130 $wpdb->query("INSERT INTO {$wp_prefix}linkmydeals_logs (microtime,msg_type,message) VALUES (" . microtime(true) . ",'debug','Adding New Coupon ({$coupon->lmd_id})')"); 2131 2132 $post_data = array( 2133 'ID' => '', 2134 'post_title' => $coupon->title, 2135 'post_content' => $coupon->description, 2136 'post_status' => 'publish', 2137 'post_type' => 'coupon', 2138 'post_author' => get_current_user_id() 2139 ); 2140 2141 $post_id = wp_insert_post($post_data); 2142 2143 $cat_names = explode(',', $coupon->categories); 2144 foreach ($cat_names as $cat) { 2145 wp_set_object_terms($post_id, $cat, 'coupon_category', true); 2146 } 2147 2148 $store_names = explode(',', $coupon->store); 2149 $append = false; 2150 foreach ($store_names as $str) { 2151 if (!term_exists($str, 'coupon_store')) { 2152 $term = wp_insert_term($str, 'coupon_store'); // , $args third parameter 2153 if (!is_wp_error($term)) { 2154 update_term_meta($term['term_id'], '_wpc_store_url', $coupon->homepage_url); 2155 update_term_meta($term['term_id'], '_wpc_store_name', $str); 2156 } 2157 } 2158 wp_set_object_terms($post_id, $str, 'coupon_store', $append); 2159 $append = true; 2160 } 2161 2162 update_post_meta($post_id, 'lmd_id', $coupon->lmd_id); 2163 update_post_meta($post_id, '_wpc_percent_success', '100'); 2164 update_post_meta($post_id, '_wpc_used', '0'); 2165 update_post_meta($post_id, '_wpc_today', ''); 2166 update_post_meta($post_id, '_wpc_vote_up', '0'); 2167 update_post_meta($post_id, '_wpc_vote_down', '0'); 2168 update_post_meta($post_id, '_wpc_start_on', $coupon->start_date == '1970-01-01' ? '' : $coupon->start_date); 2169 if (!empty($coupon->end_date)) { 2170 update_post_meta($post_id, '_wpc_expires', strtotime($coupon->end_date)); 2171 } 2172 update_post_meta($post_id, '_wpc_store', ''); 2173 update_post_meta($post_id, '_wpc_coupon_save', $coupon->badge); 2174 update_post_meta($post_id, '_wpc_coupon_type', ($coupon->type == 'Code' ? 'code' : 'sale')); 2175 update_post_meta($post_id, '_wpc_coupon_type_code', $coupon->code); 2176 update_post_meta($post_id, '_wpc_destination_url', $coupon->url); 2177 update_post_meta($post_id, '_wpc_views', '0'); 2178 2179 set_post_thumbnail($post_id, $config['import_images'] != 'Off' ? linkmydeals_import_image($coupon->image_url, $coupon->lmd_id) : 0); 2180 2181 $count_new = $count_new + 1; 2182 } elseif ($coupon->status == 'updated') { 2183 2184 $wpdb->query("INSERT INTO {$wp_prefix}linkmydeals_logs (microtime,msg_type,message) VALUES (" . microtime(true) . ",'debug','Updating Coupon ({$coupon->lmd_id})')"); 2185 2186 $post_id = $wpdb->get_var("SELECT post_id FROM {$wp_prefix}postmeta WHERE meta_key = 'lmd_id' AND meta_value = '{$coupon->lmd_id}' LIMIT 0,1"); 2187 2188 $post_data = array( 2189 'ID' => $post_id, 2190 'post_title' => $coupon->title, 2191 'post_content' => $coupon->description, 2192 'post_status' => 'publish', 2193 'post_author' => get_current_user_id() 2194 ); 2195 2196 wp_update_post($post_data); 2197 2198 $cat_names = explode(',', $coupon->categories); 2199 $append = false; 2200 foreach ($cat_names as $cat) { 2201 wp_set_object_terms($post_id, $cat, 'coupon_category', $append); 2202 $append = true; 2203 } 2204 2205 $store_names = explode(',', $coupon->store); 2206 $append = false; 2207 foreach ($store_names as $str) { 2208 if (!term_exists($str, 'coupon_store')) { 2209 $term = wp_insert_term($str, 'coupon_store'); // , $args third parameter 2210 if (!is_wp_error($term)) { 2211 update_term_meta($term['term_id'], '_wpc_store_url', $coupon->homepage_url); 2212 update_term_meta($term['term_id'], '_wpc_store_name', $str); 2213 } 2214 } 2215 wp_set_object_terms($post_id, $str, 'coupon_store', $append); 2216 $append = true; 2217 } 2218 update_post_meta($post_id, '_wpc_start_on', $coupon->start_date == '1970-01-01' ? '' : $coupon->start_date); 2219 if (!empty($coupon->end_date)) { 2220 update_post_meta($post_id, '_wpc_expires', strtotime($coupon->end_date)); 2221 } 2222 update_post_meta($post_id, '_wpc_coupon_type', ($coupon->type == 'Code' ? 'code' : 'sale')); 2223 update_post_meta($post_id, '_wpc_coupon_type_code', $coupon->code); 2224 update_post_meta($post_id, '_wpc_destination_url', $coupon->url); 2225 2226 $count_updated = $count_updated + 1; 2227 } elseif ($coupon->status == 'suspended') { 2228 2229 $wpdb->query("INSERT INTO {$wp_prefix}linkmydeals_logs (microtime,msg_type,message) VALUES (" . microtime(true) . ",'debug','Suspending Coupon ({$coupon->lmd_id})')"); 2230 2231 $post_id = $wpdb->get_var("SELECT post_id FROM {$wp_prefix}postmeta WHERE meta_key = 'lmd_id' AND meta_value = '{$coupon->lmd_id}' LIMIT 0,1"); 2232 2233 wp_delete_post($post_id, true); 2234 2235 $count_suspended = $count_suspended + 1; 2236 } 2237 2238 $wpdb->query("DELETE FROM {$wp_prefix}linkmydeals_upload WHERE lmd_id = {$coupon->lmd_id}"); 2239 } 2240 2241 $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.')"); 2242 } 2097 2243 2098 2244 function linkmydeals_generic_theme_process_batch($coupons, &$config) -
linkmydeals/trunk/readme.txt
r3170465 r3177805 30 30 * Couponhut 31 31 * WP-Coupon-Pro 32 * CouponPress by Coupon Themes 32 33 * CouponMart 33 34
Note: See TracChangeset
for help on using the changeset viewer.