Plugin Directory

Changeset 712951


Ignore:
Timestamp:
05/14/2013 01:40:00 PM (13 years ago)
Author:
Sanskript
Message:

Beta 1 Build

Location:
soldpress/branches/0.9.5A
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • soldpress/branches/0.9.5A/adapter.php

    r712619 r712951  
    111111        global $wpdb;
    112112        $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);
    114114        if($syncenabled != true){
    115115            $this->WriteLog('Sync Disabled');
  • soldpress/branches/0.9.5A/settings.php

    r712619 r712951  
    123123                            foreach ($jobs as $job => $value) {
    124124                                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                                }
    143144                            }
    144145                        }
     
    148149    <?php } ?>
    149150    <?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>
    151154     <div class = "postbox">
    152155                <div class = "handlediv">
     
    201204       
    202205    <?php
     206        //Process Get Actions First
    203207        if (isset($_GET["spa"])) {
    204208            $sp_action = $_GET["spa"];
     
    206210                    switch ($sp_action) {
    207211                        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'])));
    210215                            exit();
    211216                            break;
     
    228233                           
    229234        }
    230        
     235        //Process Data Post Actions
    231236        if (isset($_POST["test_connection"])) { 
    232237               
  • soldpress/branches/0.9.5A/soldpress.php

    r712619 r712951  
    44Plugin URI: http://www.sanskript.com/products/soldpress
    55Description: 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 M1
     6Version:  0.9.5 Beta
    77Author: Amer Gill
    88Author URI: http://www.sanskript.com
     
    1010*/
    1111
    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);
    1515
    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');
    1818
    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');
    2323
    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 )
    7225    {
    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;
    7629    }
    7730
    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');
    8536    }
    86    
    8737
    88 }
     38    register_activation_hook(__FILE__, 'soldpress_activation');
    8939
    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       
    9667    }
    97 }
    9868
    99 add_filter( 'template_include', 'include_template_function', 1 );
     69    function soldpress_listintgs() {       
    10070
    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        }
    10286
    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        }
    122131    return $template_path;
    123132}
    124133
    125134    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    }
    133139
    134140?>
Note: See TracChangeset for help on using the changeset viewer.