AddThis Share Plugin installed on your site. * Version: 1.0.2 * * Author: The AddThis Team * Author URI: http://www.addthis.com/blog */ define('PLUGIN_DIR_PATH', plugin_dir_url(__FILE__) ); define('ADDTHIS_TRENDING_PRODUCT_CODE', 'wptcw-102' ); define('ADDTHIS_TRENDING_AT_VERSION', 300 ); class AddThisTrendingWidget { function __construct() { add_action('widgets_init', array($this, 'widgets_init')); //wp_enqueue_script('minicolor', plugins_url('', basename(dirname(__FILE__))).'/addthis-trending/js/jquery.miniColors.js'); wp_enqueue_style('minicolor', PLUGIN_DIR_PATH . '/css/jquery.miniColors.css'); add_action('admin_print_styles-widgets.php', array($this, 'admin_print_styles')); add_action( 'admin_enqueue_scripts', array($this, 'add_this_trending_admin_enqueue_scripts') ); } function widgets_init() { register_widget('AddThisTrendingSidebarWidget'); } function add_this_trending_admin_enqueue_scripts(){ wp_enqueue_script('minicolor', PLUGIN_DIR_PATH .' /js/jquery.miniColors.js'); wp_enqueue_script('widgets-php', PLUGIN_DIR_PATH . '/js/widgets-php.js'); } function admin_print_styles() { $style_location = apply_filters('addthis_trending_files_uri', PLUGIN_DIR_PATH . '/css/widgets-php.css'); $js_location = apply_filters('addthis_trending_files_uri', PLUGIN_DIR_PATH . '/js/widgets-php.js'); wp_enqueue_style('addthis_trending', $style_location, array(), 0); wp_enqueue_script('addthis_trending', $js_location, array('jquery'), 0); } } new AddThisTrendingWidget(); /** * Basic Trending Options class shared by the Trending Plugin and Widget */ class TrendingOptions { private static $_instance = null; private $_styles = null; private function __construct() { $this->_styles = array( 'trending' => array('Trending'), 'shared' => array('Most Shared'), 'clicked' => array('Most Clicked')); $this->_timePeriod = array( 'month' => array('Last Month'), 'week' => array('Last Week'), 'day' => array('Last Day')); $this->_links = array( '1' => array('1'),'2' => array('2'),'3' => array('3'),'4' => array('4'),'5' => array('5'),'6' => array('6'), '7' => array('7'),'8' => array('8'),'9' => array('9'),'10' => array('10'),'11' => array('11'),'12' => array('12'), '13' => array('13'),'14' => array('14'),'15' => array('15'),'16' => array('16'),'17' => array('17'),'18' => array('18'), '19' => array('19'), '20' => array('20')); } public static function getInstance() { if (self::$_instance == null) { self::$_instance = new TrendingOptions(); } return self::$_instance; } public function getStyles() { return $this->_styles; } public function getDefaultStyle() { return $this->_defaultStyle; } public function getTimePeriod(){ return $this->_timePeriod; } public function getDefaultTime() { return $this->_defaultTime; } public function getLinks() { return $this->_links; } } /** * AddThis Trending Plugin and its settings */ class AddThisTrendingPlugin { private $_trendingOptions = null; public function __construct() { $this->_trendingOptions = TrendingOptions::getInstance(); add_filter('admin_menu', array($this, 'admin_menu')); add_action('admin_init', array($this, 'register_trending_settings')); } function register_trending_settings() { register_setting('addthis_trending_settings', 'addthis_trending_settings', array($this, 'save_settings')); } /** * Callback for saving the Trending plugin settings * Sanitize the options and save it * * @param array $input * @return array $options */ function save_settings($input) { $options = array(); $allowedKeys = array('title', 'style', 'time', 'height', 'width', 'links', 'repeated', 'bg_color', 'border'); foreach ($input as $key => $value) { if (in_array($key, $allowedKeys)) { $value = sanitize_text_field($value); $options[$key] = $value; } } return $options; } /** * AddThis Trending Admin menu */ function admin_menu() { if (is_admin()) { $trending = add_options_page('AddThis Plugin Options', 'AddThis Trending Content', 'manage_options', basename(__FILE__), array($this, 'options')); } } /** * AddThis Trending settings page */ function options() { wp_enqueue_style('adminstyles', PLUGIN_DIR_PATH.'css/admin-options.css'); if (version_compare(get_bloginfo('version'), '3.3', '<')) { wp_head(); } $style = $this->_trendingOptions->getDefaultStyle(); $time = $this->_trendingOptions->getDefaultTime(); $commonTrendingOptions = get_option('addthis_trending_settings'); $trendingWidgetOptions = get_option('widget_addthis-trending-widget'); /** * Restore from widget settings if possible */ if (($commonTrendingOptions == false || empty($commonTrendingOptions)) && $trendingWidgetOptions != false) { $restoreOptions = array('title' => $title, 'style' => $style, 'time' => $time); add_option('addthis_trending_settings', $restoreOptions); } $this->displayOptionsForm(); } /** * Display the Trending Options Form * @global AddThis_addjs $addthis_addjs * @param TrendingOptions $buttonOptions * @param string $style * @param string $title */ function displayOptionsForm() { global $addthis_addjs; $getOptionValues = get_option('addthis_trending_settings'); $style = $getOptionValues['style']; $title = $getOptionValues['title']; $time = $getOptionValues['time']; $height = ($getOptionValues['height'])?$getOptionValues['height']:'auto'; $width = ($getOptionValues['width'])?$getOptionValues['width']:'auto'; $links = $getOptionValues['links']; $repeated = $getOptionValues['repeated']; $bg_color = $getOptionValues['bg_color']; $border = $getOptionValues['border']; $bg_color_checked = ''; $bg_color_disabled = 'disabled="disabled"'; if($bg_color){ $bg_color_checked = 'checked="checked"'; $bg_color_disabled = ''; } $border_checked = ''; $border_disabled = 'disabled="disabled"'; if($border){ $border_checked = 'checked="checked"'; $border_disabled = ''; } ?>
getAtPluginPromoText(); ?>
|
|
||||
|
|
||||
|
||||
|
|
||||
|
|
||||
|
|
||||
| '; echo " | ||||