Changeset 1040056
- Timestamp:
- 12/07/2014 11:08:43 PM (11 years ago)
- Location:
- sharedaddy-shortcode/trunk
- Files:
-
- 4 edited
-
class.sharedaddy-shortcode.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
-
sharedaddy-shortcode.php (modified) (2 diffs)
-
widget.sharedaddy-shortcode.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sharedaddy-shortcode/trunk/class.sharedaddy-shortcode.php
r1040015 r1040056 12 12 13 13 // register widget 14 add_action('widgets_init', 'SharedaddyShortcode::_registerWidget');15 14 15 remove_filter('the_content', 'sharing_display', 19); 16 remove_filter('the_excerpt', 'sharing_display', 19); 16 17 // enable shortcode in widgets 17 if (get_option('SharedaddyShortcode_enableWidgetShortcode')) { 18 self::_unloadJetpack(); 18 if (get_option(self::$_SETTING)) { 19 19 add_filter('widget_text', 'do_shortcode'); 20 20 } … … 64 64 } 65 65 } 66 public static function _unloadJetpack() 67 { 68 add_filter('the_content', 'SharedaddyShortcode::_removeOld', 1); 69 add_filter('the_excerpt', 'SharedaddyShortcode::_removeOld', 1); 70 } 71 public static function _removeOld() 72 { 73 if (has_filter('the_content', 'sharing_display')) { 74 remove_filter('the_content', 'sharing_display', 19); 75 } 76 if (has_filter('the_excerpt', 'sharing_display')) { 77 remove_filter('the_excerpt', 'sharing_display', 19); 78 } 79 } 80 public static function _registerWidget() 81 { 82 register_widget('SharedaddyShortcode_widget'); 83 } 84 public static function _enableShortcode() 85 { 86 add_filter('widget_text', 'do_shortcode'); 87 } 66 88 67 } -
sharedaddy-shortcode/trunk/readme.txt
r1040015 r1040056 1 1 === Sharedaddy Shortcode === 2 2 Contributors: rollingWolf 3 Tags: jetpack, social 3 Tags: jetpack, social, widget, shortcode 4 4 Requires at least: 4.0 5 5 Tested up to: 4.0.1 … … 36 36 == Changelog == 37 37 38 = 1.2.1 = 39 Small fixes 40 38 41 = 1.2.0 = 39 42 Put everything in a SharedaddyShortcode class and added a widget as an alternative to the shortcode. … … 50 53 == Upgrade Notice == 51 54 55 = 1.2.1 = 56 * Small fixes 57 52 58 = 1.2.0 53 59 * Major rewrite -
sharedaddy-shortcode/trunk/sharedaddy-shortcode.php
r1040015 r1040056 3 3 * Plugin Name: Sharedaddy Shortcode 4 4 * Description: Removes standard sharedaddy and lets you place it with the [sharedaddy] shortcode instead 5 * Tags: Social, Jetpack5 * Tags: jetpack, social, widget, shortcode 6 6 * Author: rollingWolf 7 7 * Requires at least: 4.0 8 8 * Tested up to: 4.0.1 9 * Version: 1.2. 010 * Stable tag: 1.2. 09 * Version: 1.2.1 10 * Stable tag: 1.2.1 11 11 * License: GPL2+ 12 12 */ … … 15 15 require_once 'widget.sharedaddy-shortcode.php'; 16 16 17 SharedaddyShortcode::init(); 17 //$basepath = dirname(dirname(__FILE__)); 18 //$sharedaddy = $basepath.'/jetpack/modules/sharedaddy/sharedaddy.php'; 19 20 add_action('init', 'SharedaddyShortcode::init', 9999); 21 add_action('widgets_init', 'sharedaddyShortcode_widgetInit'); 22 23 function sharedaddyShortcode_widgetInit() 24 { 25 register_widget('SharedaddyShortcode_Widget'); 26 } -
sharedaddy-shortcode/trunk/widget.sharedaddy-shortcode.php
r1040015 r1040056 3 3 class SharedaddyShortcode_Widget extends WP_Widget 4 4 { 5 function sharedaddyShortcode_Widget() { 5 public function __construct() 6 { 6 7 parent::__construct( 7 // Base ID of your widget8 'sharedaddyShortcode_widget',9 // Widget name will appear in UI10 'SharedaddyShortcode Widget',11 // Widget description12 array( 'description' => __( 'Place sharedaddy widget' ),)8 // Base ID of your widget 9 'sharedaddyShortcode_widget', 10 // Widget name will appear in UI 11 'SharedaddyShortcode Widget', 12 // Widget description 13 array('description' => __('Place sharedaddy widget')) 13 14 ); 14 15 } 15 function widget($args, $instance) {16 global $post;17 $title = apply_filters( 'widget_title', $instance['title']);16 public function widget($args, $instance) 17 { 18 $title = apply_filters('widget_title', $instance['title']); 18 19 // before and after widget arguments are defined by themes 19 20 echo $args['before_widget']; 20 if ( ! empty( $title ) ) 21 echo $args['before_title'] . $title . $args['after_title']; 21 if (!empty($title)) { 22 echo $args['before_title'].$title.$args['after_title']; 23 } 22 24 // This is where you run the code and display the output 23 25 //echo '<p class="navbar-text navbar-right">'; 24 sharedaddyShortcode::display();26 SharedaddyShortcode::display(); 25 27 echo $args['after_widget']; 26 28 } 27 function update($new_instance, $old_instance) { 29 public function update($new_instance, $old_instance) 30 { 28 31 $instance = array(); 29 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title']) : '';32 $instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : ''; 30 33 31 34 return $instance; 32 35 } 33 function form( $instance ) { 34 if ( isset( $instance[ 'title' ] ) ) { 36 public function form($instance) 37 { 38 39 $title = __('New title', 'wpb_widget_domain'); 40 if (isset($instance['title'])) { 35 41 $title = $instance[ 'title' ]; 36 } else {37 $title = __( 'New title', 'wpb_widget_domain' );38 42 } 39 43 ?> … … 42 46 </p> 43 47 <p> 44 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> 45 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> 48 <label for="<?php echo $this->get_field_id('title'); 49 ?>"> 50 <?php _e('Title:'); 51 ?> 52 </label> 53 <input 54 class="widefat" 55 id="<?php echo $this->get_field_id('title'); 56 ?>" 57 name="<?php echo $this->get_field_name('title'); 58 ?>" 59 type="text" 60 value="<?php echo esc_attr($title); 61 ?>" 62 /> 46 63 </p> 47 64 <?php 65 48 66 } 49 67 }
Note: See TracChangeset
for help on using the changeset viewer.