Plugin Directory

Changeset 1039972


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

Added options to enable shortcode in widgets

Location:
sharedaddy-shortcode/trunk
Files:
2 edited

Legend:

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

    r1037385 r1039972  
    1111
    1212== Description ==
    13 Sharedaddy is a social sharing button plugin that nowadays ships with the Jetpack wordpress plugin re-labeled
    14 as Sharing Buttons. It doesn't offer much options on where to place it though so theres where this plugin
    15 comes in. It removes the default Jetpack trigger to place the sharebuttons and instead places it inside
    16 the [sharedaddy] shortcode.
     13Sharedaddy is a social sharing button plugin that nowadays ships with the Jetpack wordpress plugin re-labeled as Sharing Buttons. It doesn't offer much options on where to place it though so theres where this plugin comes in. It removes the default Jetpack trigger to place the sharebuttons and instead places it inside the [sharedaddy] shortcode.
    1714
    1815== Installation ==
     
    21183. Enable the plugin
    22194. Use the [sharedaddy] shortcode where you now want the social sharing buttons to appear instead
     205. (optional) enable widget shortcode in Settings -> General -> Sharedaddy Shortcode
    2321
    2422== Frequently Asked Questions ==
     
    2826and called Sharing Buttons. This plugin doesn't do anything unless Jetpack is installed.
    2927
     28= How do I enable shortcode in widgets =
     29Under Settings -> General theres a section called Sharedaddy Shortcode there you can enable widget shortcodes. This is global and not just for Sharedaddy Shortcode.
     30
    3031== Screenshots ==
    3132
    3233== Changelog ==
     34
     35= 1.1.0 =
     36Added settings in General to enable/disable shortcode in widgets
    3337
    3438= 1.0.1 =
     
    4044== Upgrade Notice ==
    4145
     46= 1.1.0 =
     47* Settings added to
     48
    4249= 1.0.1 =
    4350* Now displays properly even with no post
  • sharedaddy-shortcode/trunk/sharedaddy-shortcode.php

    r1037383 r1039972  
    77 * Requires at least: 4.0
    88 * Tested up to: 4.0.1
    9  * Version: 20141202
    10  * Stable tag: 1.0.1
     9 * Version: 1.1.0
     10 * Stable tag: 1.1.0
    1111 * License: GPL2+
    1212*/
    1313
    14 function func_shareDaddyShortcode_display() {
     14function func_shareDaddyShortcode_display()
     15{
    1516    global $post;
    1617    if (function_exists('sharing_display')) {
    1718        if (!$post) {
     19            $_post = $post;
    1820            $post = 'temp_sharedaddy';
    1921        }
     
    2123        if ($post == 'temp_sharedaddy') {
    2224            unset($post);
     25            $post = $_post;
    2326        }
    2427    }
    2528}
    26 function func_shareDaddyShortcode_removeOld() {
     29function func_shareDaddyShortcode_removeOld()
     30{
    2731    if (has_filter('the_content', 'sharing_display')) {
    2832        remove_filter('the_content', 'sharing_display', 19);
     
    3236    }
    3337}
     38function func_shareDaddyShortcode_enableShortcode()
     39{
     40    if (get_option('settings_shareDaddyShortCode_enableWidgetShortcode')) {
     41        add_filter('widget_text', 'do_shortcode');
     42    }
     43}
     44function settings_shareDaddyShortcode()
     45{
     46    add_settings_section(
     47        'settings_section_shareDaddyShortcode',
     48        'Sharedaddy Shortcode',
     49        'settings_section_callback_shareDaddyShortcode',
     50        'general'
     51    );
    3452
     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}
     63function settings_section_callback_shareDaddyShortcode()
     64{
     65    echo '<p>Enable shortcode in widgets (not just for Sharedaddy Shortcode)</p>';
     66}
     67function 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
     74add_action('admin_init', 'settings_shareDaddyShortCode');
     75
     76// Enable shortcode in widgets if needed
     77add_action('widgets_init', 'func_shareDaddyShortcode_enableShortcode', 1);
     78
     79// Remove normal Jetpack Sharedaddy filters
    3580add_filter('the_content', 'func_shareDaddyShortcode_removeOld', 1);
    3681add_filter('the_excerpt', 'func_shareDaddyShortcode_removeOld', 1);
     82
     83// Add [sharedaddy] as available shortcode
    3784add_shortcode('sharedaddy', 'func_shareDaddyShortcode_display');
Note: See TracChangeset for help on using the changeset viewer.