Plugin Directory

Changeset 1040015


Ignore:
Timestamp:
12/07/2014 09:34:53 PM (11 years ago)
Author:
rollingWolf
Message:

Added widget and major code rewrite

Location:
sharedaddy-shortcode/trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • sharedaddy-shortcode/trunk/readme.txt

    r1039972 r1040015  
    2929Under Settings -> General theres a section called Sharedaddy Shortcode there you can enable widget shortcodes. This is global and not just for Sharedaddy Shortcode.
    3030
     31= Another set of sharebuttons doesnt work =
     32Du to limitations in Jetpacks Sharedaddy you can only have one set of sharebuttons.
     33
    3134== Screenshots ==
    3235
    3336== Changelog ==
     37
     38= 1.2.0 =
     39Put everything in a SharedaddyShortcode class and added a widget as an alternative to the shortcode.
    3440
    3541= 1.1.0 =
     
    4450== Upgrade Notice ==
    4551
     52= 1.2.0
     53* Major rewrite
     54* Added widget
     55
    4656= 1.1.0 =
    4757* Settings added to
  • sharedaddy-shortcode/trunk/sharedaddy-shortcode.php

    r1039972 r1040015  
    77 * Requires at least: 4.0
    88 * Tested up to: 4.0.1
    9  * Version: 1.1.0
    10  * Stable tag: 1.1.0
     9 * Version: 1.2.0
     10 * Stable tag: 1.2.0
    1111 * License: GPL2+
    1212*/
    1313
    14 function func_shareDaddyShortcode_display()
    15 {
    16     global $post;
    17     if (function_exists('sharing_display')) {
    18         if (!$post) {
    19             $_post = $post;
    20             $post = 'temp_sharedaddy';
    21         }
    22         sharing_display('', true);
    23         if ($post == 'temp_sharedaddy') {
    24             unset($post);
    25             $post = $_post;
    26         }
    27     }
    28 }
    29 function func_shareDaddyShortcode_removeOld()
    30 {
    31     if (has_filter('the_content', 'sharing_display')) {
    32         remove_filter('the_content', 'sharing_display', 19);
    33     }
    34     if (has_filter('the_excerpt', 'sharing_display')) {
    35         remove_filter('the_excerpt', 'sharing_display', 19);
    36     }
    37 }
    38 function func_shareDaddyShortcode_enableShortcode()
    39 {
    40     if (get_option('settings_shareDaddyShortCode_enableWidgetShortcode')) {
    41         add_filter('widget_text', 'do_shortcode');
    42     }
    43 }
    44 function settings_shareDaddyShortcode()
    45 {
    46     add_settings_section(
    47         'settings_section_shareDaddyShortcode',
    48         'Sharedaddy Shortcode',
    49         'settings_section_callback_shareDaddyShortcode',
    50         'general'
    51     );
     14require_once 'class.sharedaddy-shortcode.php';
     15require_once 'widget.sharedaddy-shortcode.php';
    5216
    53     add_settings_field(
    54         'settings_shareDaddyShortCode_enableWidgetShortcode',
    55         'Enable shortcode in widgets',
    56         'settings_callback_shareDaddyShortcode',
    57         'general',
    58         'settings_section_shareDaddyShortcode'
    59     );
    60 
    61     register_setting('general', 'settings_shareDaddyShortCode_enableWidgetShortcode');
    62 }
    63 function settings_section_callback_shareDaddyShortcode()
    64 {
    65     echo '<p>Enable shortcode in widgets (not just for Sharedaddy Shortcode)</p>';
    66 }
    67 function settings_callback_shareDaddyShortcode()
    68 {
    69     echo '<input name="settings_shareDaddyShortCode_enableWidgetShortcode" id="settings_shareDaddyShortCode_enableWidgetShortcode" value="1" type="checkbox" class="code" ';
    70     echo checked(1, get_option('settings_shareDaddyShortCode_enableWidgetShortcode'), false).'>';
    71 }
    72 
    73 // Add option to Settings -> General
    74 add_action('admin_init', 'settings_shareDaddyShortCode');
    75 
    76 // Enable shortcode in widgets if needed
    77 add_action('widgets_init', 'func_shareDaddyShortcode_enableShortcode', 1);
    78 
    79 // Remove normal Jetpack Sharedaddy filters
    80 add_filter('the_content', 'func_shareDaddyShortcode_removeOld', 1);
    81 add_filter('the_excerpt', 'func_shareDaddyShortcode_removeOld', 1);
    82 
    83 // Add [sharedaddy] as available shortcode
    84 add_shortcode('sharedaddy', 'func_shareDaddyShortcode_display');
     17SharedaddyShortcode::init();
Note: See TracChangeset for help on using the changeset viewer.