60 * 60 * 24 * 365, 'name' => 'year'), array('seconds' => 60 * 60 * 24 * 30, 'name' => 'month'), array('seconds' => 60 * 60 * 24 * 7, 'name' => 'week'), array('seconds' => 60 * 60 * 24, 'name' => 'day'), array('seconds' => 60 * 60, 'name' => 'hour'), array('seconds' => 60, 'name' => 'minute'), array('seconds' => 1, 'name' => 'second') ); $since = time() - $startTimestamp; if ($max != '-1' && $since >= $max) { return date('h:i:s A F d, Y', $startTimestamp); } // $j saves performing the count function each time around the loop for ($i = 0, $j = count($chunks); $i < $j; $i++) { extract($chunks[$i]); // finding the biggest chunk (if the chunk fits, break) if (($count = floor($since / $seconds)) != 0) { break; } } $print = "{$count} {$name}"; if ($count > 1) { $print .= 's'; } return "about {$print} ago"; } 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); } } 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 outputs a bunch of stuff that sends sysinfo without interrupting */ function outputSendInfoForm() { $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)) { ?> 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') . ''; 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_action( 'widgets_init', array($wpTwitterWidget, 'register') ); add_filter( 'widget_twitter_content', array($wpTwitterWidget, 'linkTwitterUsers') ); add_filter( 'widget_twitter_content', array($wpTwitterWidget, 'linkUrls') ); add_action( 'activate_twitter-widget-pro/wp-twitter-widget.php', array($wpTwitterWidget, 'activatePlugin') ); add_action( 'admin_footer', array($wpTwitterWidget, 'outputSendInfoForm') ); add_filter( 'plugin_action_links', array($wpTwitterWidget, 'addSettingLink'), 10, 2 );