60 * 60 * 24 * 365, // 31,536,000 seconds 'month' => 60 * 60 * 24 * 7, // 2,592,000 seconds 'week' => 60 * 60 * 24 * 7, // 604,800 seconds 'day' => 60 * 60 * 24, // 86,400 seconds 'hour' => 60 * 60, // 3600 seconds 'minute' => 60, // 60 seconds 'second' => 1 // 1 second ); $since = time() - $startTimestamp; if ($max != '-1' && $since >= $max) { return date_i18n('h:i:s A F d, Y', $startTimestamp); } foreach ( $chunks as $key => $seconds ) { // finding the biggest chunk (if the chunk fits, break) if (($count = floor($since / $seconds)) != 0) { break; } } $messages = array( 'year' => _n('about %s year ago', 'about %s years ago', $count, 'twitter-widget-pro'), 'month' => _n('about %s month ago', 'about %s months ago', $count, 'twitter-widget-pro'), 'week' => _n('about %s week ago', 'about %s weeks ago', $count, 'twitter-widget-pro'), 'day' => _n('about %s day ago', 'about %s days ago', $count, 'twitter-widget-pro'), 'hour' => _n('about %s hour ago', 'about %s hours ago', $count, 'twitter-widget-pro'), 'minute' => _n('about %s minute ago', 'about %s minutes ago', $count, 'twitter-widget-pro'), 'second' => _n('about %s second ago', 'about %s seconds ago', $count, 'twitter-widget-pro'), ); return sprintf($messages[$key], $count); } public function activatePlugin() { // If the wga-id has not been generated, generate one and store it. $id = $this->get_id(); $o = get_option('twitter_widget_pro'); if (!isset($o['user_agreed_to_send_system_information'])) { $o['user_agreed_to_send_system_information'] = 'true'; update_option('twitter_widget_pro', $o); } } public function get_id() { $id = get_option('twitter_widget_pro-id'); if ($id === false) { $id = sha1( get_bloginfo('url') . mt_rand() ); update_option('twitter_widget_pro-id', $id); } return $id; } /** * if user agrees to send system information and the last sent info is * outdated then send the stats */ public function sendSysInfo() { $o = get_option('twitter_widget_pro'); if ($o['user_agreed_to_send_system_information'] == 'true') { $lastSent = get_option('twp-sysinfo'); $sysinfo = $this->_get_sysinfo(); if (serialize($lastSent) != serialize($sysinfo)) { $params = array( 'method' => 'POST', 'blocking' => false, 'body' => $sysinfo, ); $resp = wp_remote_request( 'http://xavisys.com/plugin-info.php', $params ); update_option( 'twp-sysinfo', $sysinfo ); } } } private function _get_sysinfo() { global $wpdb; $s = array(); $s['plugin'] = 'Twitter Widget Pro'; $s['id'] = $this->get_id(); $s['version'] = TWP_VERSION; $s['php_version'] = phpversion(); $s['mysql_version'] = @mysql_get_server_info($wpdb->dbh); $s['server_software'] = $_SERVER["SERVER_SOFTWARE"]; $s['memory_limit'] = ini_get('memory_limit'); return $s; } public function addSettingLink( $links, $file ){ if ( empty($this->_pluginBasename) ) { $this->_pluginBasename = plugin_basename(__FILE__); } if ( $file == $this->_pluginBasename ) { // Add settings link to our plugin $link = '' . __('Settings', 'twitter-widget-pro') . ''; array_unshift( $links, $link ); } return $links; } } // Instantiate our class $wpTwitterWidget = new wpTwitterWidget(); /** * Add filters and actions */ add_action( 'admin_menu', array($wpTwitterWidget,'admin_menu') ); add_filter( 'init', array( $wpTwitterWidget, 'init_locale') ); add_filter( 'admin_init', array( $wpTwitterWidget, 'sendSysInfo') ); add_action( 'widgets_init', array($wpTwitterWidget, 'register') ); add_filter( 'widget_twitter_content', array($wpTwitterWidget, 'linkTwitterUsers') ); add_filter( 'widget_twitter_content', array($wpTwitterWidget, 'linkUrls') ); add_filter( 'widget_twitter_content', array($wpTwitterWidget, 'linkHashtags') ); add_filter( 'widget_twitter_content', 'convert_chars' ); add_filter( 'plugin_action_links', array($wpTwitterWidget, 'addSettingLink'), 10, 2 ); register_activation_hook(__FILE__, array($wpTwitterWidget,'activatePlugin'));