Changeset 712951
- Timestamp:
- 05/14/2013 01:40:00 PM (13 years ago)
- Location:
- soldpress/branches/0.9.5A
- Files:
-
- 3 edited
-
adapter.php (modified) (1 diff)
-
settings.php (modified) (5 diffs)
-
soldpress.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
soldpress/branches/0.9.5A/adapter.php
r712619 r712951 111 111 global $wpdb; 112 112 $wpdb->query("set wait_timeout = 1200"); //Thank You (johnorourke) http://stackoverflow.com/questions/14782494/keep-losing-the-database-in-wordpress 113 $syncenabled = get_option("sc-sync-enabled", true);113 $syncenabled = get_option("sc-sync-enabled",false); 114 114 if($syncenabled != true){ 115 115 $this->WriteLog('Sync Disabled'); -
soldpress/branches/0.9.5A/settings.php
r712619 r712951 123 123 foreach ($jobs as $job => $value) { 124 124 if($job == 'soldpress_photo_sync' || $job == 'soldpress_listing_sync'){ 125 echo '<tr>'; 126 //echo '<th scope="row" class="check-column"><input type="checkbox" name="schedules[]" class="entries" value="1"></th>'; 127 echo '<td><strong>'.$job.'</strong><div class="row-actions" style="margin:0; padding:0;"><a href="/wp-admin/options-general.php?page=soldpress&tab=sync_options&spa=runevt&job='.$job.'">Run Now</a> || <a href="/wp-admin/options-general.php?page=soldpress&tab=sync_options">Disable</a></div></td>'; 128 129 echo '<td>'.date("r", $key).'</td>'; 130 $schedule = $value[key($value)]; 131 echo '<td>'.(isset($schedule["schedule"]) ? $schedule["schedule"] : "").'</td>'; 132 echo '<td class="aright">'.(isset($schedule["interval"]) ? $schedule["interval"] : "").'</td>'; 133 echo '<td class="aright">'. Date('r',get_option('sc-'.$job.'-start' )) ; 134 echo '</td>'; 135 echo '<td class="aright">'. Date('r',get_option('sc-'.$job.'-end' )) ; 136 echo '</td>'; 137 echo '</tr>'; 138 if ($tr_class == "") 139 $tr_class = "entry-row alternate "; 140 else 141 $tr_class = "entry-row"; 142 } 125 echo '<tr>'; 126 //echo '<th scope="row" class="check-column"><input type="checkbox" name="schedules[]" class="entries" value="1"></th>'; 127 echo '<td><strong>'.$job.'</strong><div class="row-actions" style="margin:0; padding:0;"><a href="/wp-admin/options-general.php?page=soldpress&tab=sync_options&spa=runevt&job='.$job.'">Run Now</a> || <a href="/wp-admin/options-general.php?page=soldpress&tab=sync_options">Disable</a></div></td>'; 128 echo '<td>'.date("r", $key).'</td>'; 129 $schedule = $value[key($value)]; 130 echo '<td>'.(isset($schedule["schedule"]) ? $schedule["schedule"] : "").'</td>'; 131 echo '<td class="aright">'.(isset($schedule["interval"]) ? $schedule["interval"] : "").'</td>'; 132 echo '<td class="aright">'. Date('r',get_option('sc-'.$job.'-start' )) ; 133 echo '</td>'; 134 echo '<td class="aright">'. Date('r',get_option('sc-'.$job.'-end' )) ; 135 echo '</td>'; 136 echo '</tr>'; 137 if ($tr_class == ""){ 138 $tr_class = "entry-row alternate "; 139 } 140 else{ 141 $tr_class = "entry-row"; 142 } 143 } 143 144 } 144 145 } … … 148 149 <?php } ?> 149 150 <?php if( $active_tab == 'debug_options' ) { ?> 150 <a href="/wp-content/uploads/soldpress/soldpress-log.txt">debug log</a> 151 <h3 class="title">Log File</h3> 152 <a target="_blank" href="/wp-content/uploads/soldpress/soldpress-log.txt">debug log</a> 153 <h3 class="title">Debug</h3> 151 154 <div class = "postbox"> 152 155 <div class = "handlediv"> … … 201 204 202 205 <?php 206 //Process Get Actions First 203 207 if (isset($_GET["spa"])) { 204 208 $sp_action = $_GET["spa"]; … … 206 210 switch ($sp_action) { 207 211 case "unsevt": 208 209 // wp_redirect(remove_query_arg(array('time', 'job', 'spa', 'key'), stripslashes($_SERVER['REQUEST_URI']))); 212 $job = $_GET['job']; 213 wp_clear_scheduled_hook($job); 214 wp_redirect(remove_query_arg(array('job', 'spa'), stripslashes($_SERVER['REQUEST_URI']))); 210 215 exit(); 211 216 break; … … 228 233 229 234 } 230 235 //Process Data Post Actions 231 236 if (isset($_POST["test_connection"])) { 232 237 -
soldpress/branches/0.9.5A/soldpress.php
r712619 r712951 4 4 Plugin URI: http://www.sanskript.com/products/soldpress 5 5 Description: SoldPress is a WordPress plugin to enable CREA’s members to easily disseminate MLS® listing content on WordPress Sites. 6 Version: 0.9.5 A M16 Version: 0.9.5 Beta 7 7 Author: Amer Gill 8 8 Author URI: http://www.sanskript.com … … 10 10 */ 11 11 12 ini_set('max_execution_time', 600);13 ini_set('mysql.connect_timeout', 600);14 ini_set('default_socket_timeout', 600);12 ini_set('max_execution_time', 600); 13 ini_set('mysql.connect_timeout', 600); 14 ini_set('default_socket_timeout', 600); 15 15 16 add_filter( 'query_vars','soldpress_query_vars' );17 //add_theme_support('post-thumbnails');16 add_filter( 'query_vars','soldpress_query_vars' ); 17 //add_theme_support('post-thumbnails'); 18 18 19 require_once(dirname(__FILE__)."/adapter.php");20 require_once(dirname(__FILE__)."/shortcodes.php");21 include_once(dirname(__FILE__).'/settings.php');22 include_once(dirname(__FILE__).'/custom_field_types.php');19 require_once(dirname(__FILE__)."/adapter.php"); 20 require_once(dirname(__FILE__)."/shortcodes.php"); 21 include_once(dirname(__FILE__).'/settings.php'); 22 include_once(dirname(__FILE__).'/custom_field_types.php'); 23 23 24 function soldpress_query_vars( $vars ) 25 { 26 array_push($vars, 'listingid'); 27 array_push($vars, 'listingkey'); 28 return $vars; 29 } 30 31 register_deactivation_hook(__FILE__,'deactivate_cron_hook'); 32 33 function deactivate_cron_hook(){ 34 wp_clear_scheduled_hook('soldpress_listing_sync'); 35 wp_clear_scheduled_hook('soldpress_photo_sync'); 36 } 37 38 register_activation_hook(__FILE__, 'soldpress_activation'); 39 40 add_action('soldpress_listing_sync', 'soldpress_listintgs'); 41 add_action('soldpress_photo_sync', 'soldpress_photo'); 42 43 function soldpress_activation() { 44 45 update_option( 'sc-status', ''); 46 update_option( 'sc-sync-start','' ); 47 update_option( 'sc-sync-end','' ); 48 49 //Create SoldPress Directory 50 $wp_upload_dir = wp_upload_dir(); 51 $target = $wp_upload_dir['basedir']. '/soldpress/'; 52 // if ( wp_mkdir_p( $target ) === TRUE ) //Future Error 53 wp_mkdir_p( $target ); 54 55 //Schedule The Events 56 wp_schedule_event( time(), 'daily', 'soldpress_listing_sync'); 57 wp_schedule_event( time(), 'hourly', 'soldpress_photo_sync'); 58 } 59 60 function soldpress_listintgs() { 61 62 date_default_timezone_set('UTC'); 63 $lastupdate = get_option('sc-lastupdate'); 64 65 if(!$lastupdate){ 66 //Sync Last 90 days 67 $days = 90; 68 $date = new DateTime(); 69 $date->sub(new DateInterval('P' . $days . 'D')); 70 update_option( 'sc-lastupdate', new DateTime()); 71 }else 24 function soldpress_query_vars( $vars ) 72 25 { 73 $date = $lastupdate;74 $date->add(new DateInterval('P' . 1 . 'D'));75 update_option( 'sc-lastupdate', $date);26 array_push($vars, 'listingid'); 27 array_push($vars, 'listingkey'); 28 return $vars; 76 29 } 77 30 78 //Do a future check/ if the date time is before now don't do any thing the usemay have reactivate the plugin. 79 $adapter= new soldpress_adapter(); 80 81 if($adapter->connect()) 82 { 83 return $adapter-> sync_residentialproperty("LastUpdated=2011-05-08T22:00:17Z"); 84 //return $adapter-> sync_residentialproperty("LastUpdated=" . $date->format('Y-m-d')); 31 register_deactivation_hook(__FILE__,'deactivate_cron_hook'); 32 33 function deactivate_cron_hook(){ 34 wp_clear_scheduled_hook('soldpress_listing_sync'); 35 wp_clear_scheduled_hook('soldpress_photo_sync'); 85 36 } 86 87 37 88 } 38 register_activation_hook(__FILE__, 'soldpress_activation'); 89 39 90 function soldpress_photo() { 91 echo 'soldpress_photo'; 92 $adapter= new soldpress_adapter(); 93 if($adapter->connect()) 94 { 95 return $adapter-> sync_pictures(); 40 add_action('soldpress_listing_sync', 'soldpress_listintgs'); 41 add_action('soldpress_photo_sync', 'soldpress_photo'); 42 43 function soldpress_activation() { 44 45 update_option( 'sc-status', ''); 46 update_option( 'sc-sync-start','' ); 47 update_option( 'sc-sync-end','' ); 48 49 //Deactive Sync 50 update_option( 'sc-sync-enabled',false ); 51 52 //Create SoldPress Directory 53 $wp_upload_dir = wp_upload_dir(); 54 $target = $wp_upload_dir['basedir']. '/soldpress/'; 55 // if ( wp_mkdir_p( $target ) === TRUE ) //Future Error 56 wp_mkdir_p( $target ); 57 58 //Remove Old Jobs 59 wp_clear_scheduled_hook('soldpress_listing_sync'); 60 wp_clear_scheduled_hook('soldpress_photo_sync'); 61 62 //Schedule The Events 63 wp_schedule_event( time(), 'twicedaily', 'soldpress_listing_sync'); 64 wp_schedule_event( time(), 'hourly', 'soldpress_photo_sync'); 65 66 96 67 } 97 }98 68 99 add_filter( 'template_include', 'include_template_function', 1 ); 69 function soldpress_listintgs() { 100 70 101 function include_template_function( $template_path ) { 71 date_default_timezone_set('UTC'); 72 $lastupdate = get_option('sc-lastupdate'); 73 74 if(!$lastupdate){ 75 //Sync Last 90 days 76 $days = 90; 77 $date = new DateTime(); 78 $date->sub(new DateInterval('P' . $days . 'D')); 79 update_option( 'sc-lastupdate', new DateTime()); 80 }else 81 { 82 $date = $lastupdate ; 83 $date->add(new DateInterval('P' . 1 . 'D')); 84 update_option( 'sc-lastupdate', $date); 85 } 102 86 103 //Thanks Brother : http://wp.tutsplus.com/tutorials/plugins/a-guide-to-wordpress-custom-post-types-taxonomies-admin-columns-filters-and-archives/ 104 if ( get_post_type() == 'sp_property' ) { 105 if ( is_single() ) { 106 // checks if the file exists in the theme first, 107 // otherwise serve the file from the plugin 108 if ( $theme_file = locate_template( array ( 'single-sp_property.php' ) ) ) { 109 $template_path = $theme_file; 110 } else { 111 $template_path = plugin_dir_path( __FILE__ ) . '/single-sp_property.php'; 112 } 113 } 114 elseif ( is_archive() ) { 115 if ( $theme_file = locate_template( array ( 'archive-sp_property.php' ) ) ) { 116 $template_path = $theme_file; 117 } else { $template_path = plugin_dir_path( __FILE__ ) . '/archive-sp_property.php'; 118 119 } 120 } 121 } 87 //TODO:Do a future check/ if the date time is before now don't do any thing the usemay have reactivate the plugin. 88 //We Can Only Check Once Per Hour So Make Sure This Not Call 89 $adapter= new soldpress_adapter(); 90 91 if($adapter->connect()) 92 { 93 $loginURL = get_option("sc-url","http://sample.data.crea.ca/Login.svc/Login"); 94 if($loginURL == "http://sample.data.crea.ca/Login.svc/Login"){ 95 return $adapter-> sync_residentialproperty("LastUpdated=2011-05-08T22:00:17Z"); 96 } 97 else{ 98 return $adapter-> sync_residentialproperty("LastUpdated=" . $date->format('Y-m-d')); 99 } 100 } 101 } 102 103 function soldpress_photo() { 104 echo 'soldpress_photo'; 105 $adapter= new soldpress_adapter(); 106 if($adapter->connect()) 107 { 108 return $adapter-> sync_pictures(); 109 } 110 } 111 112 add_filter( 'template_include', 'include_template_function', 1 ); 113 114 function include_template_function( $template_path ) { 115 if ( get_post_type() == 'sp_property' ) { 116 if ( is_single() ) { 117 if ( $theme_file = locate_template( array ( 'single-sp_property.php' ) ) ) { 118 $template_path = $theme_file; 119 } else { 120 $template_path = plugin_dir_path( __FILE__ ) . '/single-sp_property.php'; 121 } 122 } 123 elseif ( is_archive() ) { 124 if ( $theme_file = locate_template( array ( 'archive-sp_property.php' ) ) ) { 125 $template_path = $theme_file; 126 } else { $template_path = plugin_dir_path( __FILE__ ) . '/archive-sp_property.php'; 127 128 } 129 } 130 } 122 131 return $template_path; 123 132 } 124 133 125 134 add_action( 'in_admin_footer', 'admin_footer' ); 126 /** 127 * Adds Footer links. Based on http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/ 128 */ 129 function admin_footer() { 130 $plugin_data = get_plugin_data( __FILE__ ); 131 printf('%1$s ' . __("plugin", 'SoldPress') .' | ' . __("Version", 'SoldPress') . ' %2$s | '. __('by', 'SoldPress') . ' %3$s<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']); 132 } 135 function admin_footer() { 136 $plugin_data = get_plugin_data( __FILE__ ); 137 printf('%1$s ' . __("plugin", 'SoldPress') .' | ' . __("Version", 'SoldPress') . ' %2$s | '. __('by', 'SoldPress') . ' %3$s | Not for Distribution<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']); 138 } 133 139 134 140 ?>
Note: See TracChangeset
for help on using the changeset viewer.