Plugin Directory

Changeset 1040056


Ignore:
Timestamp:
12/07/2014 11:08:43 PM (11 years ago)
Author:
rollingWolf
Message:

Small fixes

Location:
sharedaddy-shortcode/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sharedaddy-shortcode/trunk/class.sharedaddy-shortcode.php

    r1040015 r1040056  
    1212
    1313        // register widget
    14         add_action('widgets_init', 'SharedaddyShortcode::_registerWidget');
    1514
     15        remove_filter('the_content', 'sharing_display', 19);
     16        remove_filter('the_excerpt', 'sharing_display', 19);
    1617        // enable shortcode in widgets
    17         if (get_option('SharedaddyShortcode_enableWidgetShortcode')) {
    18             self::_unloadJetpack();
     18        if (get_option(self::$_SETTING)) {
    1919            add_filter('widget_text', 'do_shortcode');
    2020        }
     
    6464        }
    6565    }
    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
    8867}
  • sharedaddy-shortcode/trunk/readme.txt

    r1040015 r1040056  
    11=== Sharedaddy Shortcode ===
    22Contributors: rollingWolf
    3 Tags: jetpack, social
     3Tags: jetpack, social, widget, shortcode
    44Requires at least: 4.0
    55Tested up to: 4.0.1
     
    3636== Changelog ==
    3737
     38= 1.2.1 =
     39Small fixes
     40
    3841= 1.2.0 =
    3942Put everything in a SharedaddyShortcode class and added a widget as an alternative to the shortcode.
     
    5053== Upgrade Notice ==
    5154
     55= 1.2.1 =
     56* Small fixes
     57
    5258= 1.2.0
    5359* Major rewrite
  • sharedaddy-shortcode/trunk/sharedaddy-shortcode.php

    r1040015 r1040056  
    33 * Plugin Name: Sharedaddy Shortcode
    44 * Description: Removes standard sharedaddy and lets you place it with the [sharedaddy] shortcode instead
    5  * Tags: Social, Jetpack
     5 * Tags:  jetpack, social, widget, shortcode
    66 * Author: rollingWolf
    77 * Requires at least: 4.0
    88 * Tested up to: 4.0.1
    9  * Version: 1.2.0
    10  * Stable tag: 1.2.0
     9 * Version: 1.2.1
     10 * Stable tag: 1.2.1
    1111 * License: GPL2+
    1212*/
     
    1515require_once 'widget.sharedaddy-shortcode.php';
    1616
    17 SharedaddyShortcode::init();
     17//$basepath = dirname(dirname(__FILE__));
     18//$sharedaddy = $basepath.'/jetpack/modules/sharedaddy/sharedaddy.php';
     19
     20add_action('init', 'SharedaddyShortcode::init', 9999);
     21add_action('widgets_init', 'sharedaddyShortcode_widgetInit');
     22
     23function sharedaddyShortcode_widgetInit()
     24{
     25    register_widget('SharedaddyShortcode_Widget');
     26}
  • sharedaddy-shortcode/trunk/widget.sharedaddy-shortcode.php

    r1040015 r1040056  
    33class SharedaddyShortcode_Widget extends WP_Widget
    44{
    5     function sharedaddyShortcode_Widget() {
     5    public function __construct()
     6    {
    67        parent::__construct(
    7         // Base ID of your widget
    8         'sharedaddyShortcode_widget',
    9         // Widget name will appear in UI
    10         'SharedaddyShortcode Widget',
    11         // Widget description
    12         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'))
    1314        );
    1415    }
    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']);
    1819        // before and after widget arguments are defined by themes
    1920        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        }
    2224        // This is where you run the code and display the output
    2325        //echo '<p class="navbar-text navbar-right">';
    24         sharedaddyShortcode::display();
     26        SharedaddyShortcode::display();
    2527        echo $args['after_widget'];
    2628    }
    27     function update($new_instance, $old_instance) {
     29    public function update($new_instance, $old_instance)
     30    {
    2831        $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']) : '';
    3033
    3134        return $instance;
    3235    }
    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'])) {
    3541            $title = $instance[ 'title' ];
    36         } else {
    37             $title = __( 'New title', 'wpb_widget_domain' );
    3842        }
    3943        ?>
     
    4246        </p>
    4347        <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        />
    4663        </p>
    4764        <?php
     65
    4866    }
    4967}
Note: See TracChangeset for help on using the changeset viewer.