_folder = $current_dir; $this->_path = '/wp-content/plugins/' . $this->_folder . '/'; $this->init(); } /* * Initialization function, called by plugin_loaded action. */ function init() { add_action('template_redirect', array(&$this, 'template_redirect')); add_filter("plugin_action_links_$plugin", array(&$this, 'link')); load_plugin_textdomain($this->_folder, false, $this->_folder); if (!function_exists('register_sidebar_widget') || !function_exists('register_widget_control')) return; register_sidebar_widget($this->_name, array(&$this, "widget")); register_widget_control($this->_name, array(&$this, "control"), $this->_width, $this->_height); } /* * Inserts the style into the head section. */ function template_redirect() { $options = get_option($this->_folder); $this->validate_options($options); if ($options['social_media'] == 'facebook') wp_enqueue_script('fbshare', $_facebook_fbshare_api); if (!isset($options['use_style']) || $options['use_style'] != 'checked') wp_enqueue_style($this->_folder, $this->_path . 'style.css', null, '1.1'); } /* * Options validation. */ function validate_options(&$options) { if (!is_array($options)) { $options = array( 'title' => 'Latest Posts', 'num_of_posts' => '5', 'social_media' => 'facebook', 'twitter_username' => '', 'bitly_username' => '', 'bitly_apikey' => '', 'show_in_home' => '', 'use_style' => '', 'link_to_us' => ''); } // validations and defaults if (intval($options['num_of_posts']) == 0) $options['num_of_posts'] = '5'; } /* * Get time diff between 2 times. */ function get_time_diff($time) { $difference = time() - strtotime($time); $weeks = round($difference / 604800); $difference = $difference % 604800; $days = round($difference / 86400); $difference = $difference % 86400; $hours = round($difference / 3600); $difference = $difference % 3600; $minutes = round($difference / 60); $difference = $difference % 60; $seconds = $difference; if ($weeks > 0) return $weeks . ' ' . __('weeks', $this->_folder); else if ($days > 0) return $days . ' ' . __('days', $this->_folder); else if ($hours > 0) return $hours . ' ' . __('hours', $this->_folder); else if ($minutes > 0) return $minutes . ' ' . __('minutes', $this->_folder); else if ($seconds > 0) return $seconds . ' ' . __('seconds', $this->_folder); } /* * Called by register_sidebar_widget() function. * Rendering of the widget happens here. */ function widget($args) { extract($args); $options = get_option($this->_folder); $this->validate_options($options); if (is_home() && $options['show_in_home'] != 'checked') return; echo $before_widget; echo $before_title; echo $options['title']; echo $after_title; echo '
(_folder) ?>) (?)
(?)
/> _folder) ?> (?)
/> _folder) ?> (?)
/> _folder) ?> (?)
Plugin Home', $this->_folder), $this->_link) ?>
_link . '">' . __('Donate', $this->_folder) . ''; array_unshift($links, $options_link); return $links; } } ?>