Plugin Directory

Changeset 1344759


Ignore:
Timestamp:
02/06/2016 05:25:41 PM (10 years ago)
Author:
bcole808
Message:

Release 1.6.5

Location:
social-metrics-tracker
Files:
107 added
5 edited

Legend:

Unmodified
Added
Removed
  • social-metrics-tracker/trunk/MetricsUpdater.class.php

    r1335247 r1344759  
    190190        if ((count($types) > 0) && !is_singular($types)) return false; // Allow singular view of enabled post types
    191191
    192         // If TTL has elapsed
    193         if ($this->isPostReadyForNextUpdate($post_id)) {
    194 
    195             // Schedule an update
    196             wp_schedule_single_event( $this->getLocalTime(), 'social_metrics_update_single_post', array( $post_id ) );
    197 
     192        // Block if TTL has not elapsed
     193        if ( !$this->isPostReadyForNextUpdate($post_id) ) {
     194            return false;
     195        }
     196
     197        // Block if restricted by date range
     198        if ( !$this->isPostWithinAllowedRange($post) ) {
     199            return false;
     200        }
     201
     202        // Schedule the update!
     203        switch($this->smt->get_smt_option('update_mode')) {
     204
     205            case 'pageload' :
     206                    add_action('wp_footer', array($this, 'updateCurrentPostNow'), 100);
     207                break;
     208
     209            case 'cron' :
     210                // use default for case 'cron'
     211            default :
     212
     213                // Schedule an update for cron
     214                wp_schedule_single_event( $this->getLocalTime(), 'social_metrics_update_single_post', array( $post_id ) );
     215
     216                break;
    198217        }
    199218
    200219        return true;
    201220    } // end checkThisPost()
     221
     222    public function updateCurrentPostNow() {
     223        global $post;
     224        wp_reset_postdata();
     225        $this->updatePostStats($post->ID);
     226    }
     227
     228
     229    /**
     230     * Checks if the post was published with the date range for auto-updates
     231     *
     232     * @param $post
     233     * @return bool
     234     */
     235    private function isPostWithinAllowedRange($post) {
     236
     237        // See what date range we want to allow auto-updates for
     238        $range = $this->smt->get_smt_option('update_range');
     239
     240        if ($range == 'none') {
     241            return false;
     242        }
     243
     244        if ($range == 'all') {
     245            return true;
     246        }
     247
     248        $cutoff = current_time('timestamp') - ( $range * DAY_IN_SECONDS );
     249
     250        if (strtotime($post->post_date) > $cutoff) {
     251            return true;
     252        } else {
     253            return false;
     254        }
     255
     256    }
    202257
    203258
  • social-metrics-tracker/trunk/SocialMetricsSettings.class.php

    r1335247 r1344759  
    2626
    2727        if (isset($_REQUEST['page']) && in_array($_REQUEST['page'], $pages)) {
    28             $this->section = (isset($_REQUEST['section'])) ? $_REQUEST['section'] : 'general';
    29             $this->wpsf = new WordPressSettingsFramework( plugin_dir_path( __FILE__ ) .'settings/smt-'.$this->section.'.php', 'smt' );
     28            add_action( 'init', array($this, 'setup') );
    3029        }
    3130
    3231        // $this->smt->use_network_settings = get_site_option('smt_use_network_settings_everywhere');
    3332
     33    }
     34
     35    function setup() {
     36        $this->section = (isset($_REQUEST['section'])) ? $_REQUEST['section'] : 'general';
     37        $this->wpsf = new WordPressSettingsFramework( plugin_dir_path( __FILE__ ) .'settings/smt-'.$this->section.'.php', 'smt' );
    3438    }
    3539
     
    223227    function process_general_form() {
    224228        if (!isset($_POST) || count($_POST) == 0) return;
     229        if (!isset($_POST['smt_settings'])) return;
    225230        $this->smt->merge_smt_options($_POST['smt_settings']);
    226231    }
     
    428433        $posts_array = get_posts( $args );
    429434
    430         return $posts_array[0]->ID;
     435        if ($posts_array)
     436            return $posts_array[0]->ID;
    431437
    432438    }
  • social-metrics-tracker/trunk/readme.txt

    r1335247 r1344759  
    55Requires at least: 3.5
    66Tested up to: 4.4.1
    7 Stable tag: 1.6.4
     7Stable tag: 1.6.5
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    108108
    109109== Changelog ==
     110
     111= 1.6.5 =
     112* Added option to run updates in the page footer instead of the cron
     113* Added option to set an update range to disable updating of older posts
     114* Change wording of some options to make them easier to understand
     115* Fixed some PHP errors with WP Multisite
    110116
    111117= 1.6.4 =
     
    244250== Upgrade Notice ==
    245251
     252= 1.6.5 =
     253Added options to help control how and when updates occur
     254
    246255= 1.6.4 =
    247256Minor bug fixes
  • social-metrics-tracker/trunk/settings/smt-general.php

    r1202486 r1344759  
    3434        ),
    3535        array(
     36            'id'    => 'update_mode',
     37            'title' => 'Update Mode',
     38            'desc'  => 'By default, the plugin will connect to social network APIs during the WP Cron (as a background task). This will keep your posts loading fast! If for some reason this is a problem, you can change the it to perform updates during regular page loads instead.',
     39            'type'  => 'select',
     40            'std'   => 'all',
     41            'choices' => array(
     42                'cron'     => 'WP Cron (Default - Runs in the background)',
     43                'pageload' => 'Page Footer (Can make posts load more slowly)',
     44            ),
     45        ),
     46        array(
     47            'id'    => 'update_range',
     48            'title' => 'Update Range',
     49            'desc'  => 'What posts should be automatically kept in sync? You can use this to limit the number of updates that run in case your site has a lot of older posts. It is recommended to track all posts unless you have too many.',
     50            'type'  => 'select',
     51            'std'   => 'all',
     52            'choices' => array(
     53                'all' => 'All posts',
     54                'none'    => 'No posts (Disables automatic updates)',
     55                '7'    => 'Only posts published within 1 week',
     56                '14'   => 'Only posts published within 2 weeks',
     57                '30'   => 'Only posts published within 1 month',
     58                '60'   => 'Only posts published within 2 months',
     59                '90'   => 'Only posts published within 3 months',
     60                '180'  => 'Only posts published within 6 months',
     61                '365'  => 'Only posts published within 1 year',
     62                '730'  => 'Only posts published within 2 years',
     63                '1460' => 'Only posts published within 4 years',
     64            )
     65        ),
     66        array(
     67            'id'    => 'ttl_hours',
     68            'title' => 'Data TTL',
     69            'desc'  => 'Length of time to wait in between checking for new stats on each post. A shorter time will use more server resources. Longer times are recommended for sites with over 500 posts.',
     70            'type'  => 'select',
     71            'std'   => '12',
     72            'choices' => array(
     73                '1'   => '1 Hour',
     74                '2'   => '2 Hours',
     75                '4'   => '4 Hours',
     76                '6'   => '6 Hours',
     77                '8'   => '8 Hours',
     78                '12'  => '12 Hours',
     79                '24'  => '24 Hours',
     80                '36'  => '36 Hours',
     81                '48'  => '2 Days',
     82                '72'  => '3 Days',
     83                '168' => '1 Week',
     84                '720' => '1 Month',
     85            )
     86        ),
     87        array(
    3688            'id'    => 'report_visibility',
    3789            'title' => 'Report Visibility',
     
    49101        ),
    50102        array(
    51             'id'    => 'ttl_hours',
    52             'title' => 'Data TTL',
    53             'desc'  => 'Length of time to store the statistics locally before downloading new data. A lower value will use more server resources. High values are recommended for blogs with over 500 posts.',
    54             'type'  => 'select',
    55             'std'   => '12',
    56             'choices' => array(
    57                 '1'   => '1 Hour',
    58                 '2'   => '2 Hours',
    59                 '4'   => '4 Hours',
    60                 '6'   => '6 Hours',
    61                 '8'   => '8 Hours',
    62                 '12'  => '12 Hours',
    63                 '24'  => '24 Hours',
    64                 '36'  => '36 Hours',
    65                 '48'  => '2 Days',
    66                 '72'  => '3 Days',
    67                 '168' => '1 Week',
    68             )
    69         ),
    70         array(
    71103            'id'    => 'default_sort_column',
    72             'title' => 'Default Sort Order',
     104            'title' => 'Report Sort Order',
    73105            'desc'  => 'Which column should be sorted by default?',
    74106            'type'  => 'select',
     
    83115        array(
    84116            'id'    => 'default_date_range_months',
    85             'title' => 'Default Date Range',
     117            'title' => 'Report Date Range',
    86118            'desc'  => 'Reports should display posts published within this date range.',
    87119            'type'  => 'select',
     
    97129        array(
    98130            'id'    => 'default_posts_per_page',
    99             'title' => 'Default Posts per Page',
     131            'title' => 'Report Posts per Page',
    100132            'desc'  => 'Number of posts per page to display in reports',
    101133            'type'  => 'select',
  • social-metrics-tracker/trunk/social-metrics-tracker.php

    r1339736 r1344759  
    44Plugin URI: https://github.com/ChapmanU/wp-social-metrics-tracker
    55Description: Collect and display social network shares, likes, tweets, and view counts of posts.
    6 Version: 1.6.4
     6Version: 1.6.5
    77Author: Ben Cole
    88Author URI: http://www.bencole.net
     
    3939class SocialMetricsTracker {
    4040
    41     public $version = '1.6.4'; // for db upgrade comparison
     41    public $version = '1.6.5'; // for db upgrade comparison
    4242    public $updater;
    4343    public $options;
     
    5454        if (is_admin()) {
    5555            add_action('admin_menu', array($this,'adminMenuSetup'));
    56             add_action('network_admin_menu', array($this,'networkAdminMenuSetup'));
    5756            add_action('admin_enqueue_scripts', array($this, 'adminHeaderScripts'));
    5857            add_action('plugins_loaded', array($this, 'version_check'));
Note: See TracChangeset for help on using the changeset viewer.