Plugin Directory

Changeset 2088844


Ignore:
Timestamp:
05/16/2019 06:19:27 AM (7 years ago)
Author:
sharpay
Message:

Font and background color options for static button.

Location:
sharpay
Files:
20 added
6 edited

Legend:

Unmodified
Added
Removed
  • sharpay/trunk/assets/css/admin.css

    r1865952 r2088844  
    5555}
    5656
     57
     58#sharpay-settings .colors {
     59    margin-top: 10px;
     60}
     61
     62
    5763/* Widget Settings -----------------------------------------------------------*/
    5864
  • sharpay/trunk/assets/js/admin.js

    r1865952 r2088844  
    3434            $(e.target).parent().siblings('.group').not('.always-visible').toggle();
    3535        });
     36
     37        $('body').on('change', '.use-custom-colors', function(e) {
     38            $(e.target).siblings('.colors').toggle();
     39        });
    3640    });
    3741
  • sharpay/trunk/includes/sharpay-admin.php

    r2063466 r2088844  
    4646        'share_counter' => false,
    4747        'share_counter_mode' => 'page',
     48        'use_custom_colors' => false,
     49        'color_font' => 'ffffff',
     50        'color_bg' => 'ff9933',
    4851        'image' => '',
    4952        'use_custom_markup' => false,
     
    6871
    6972    $sharpay_options = get_option('sharpay_options');
     73
    7074    if ( empty($sharpay_options) ) {
    7175        $sharpay_options = sharpay_default_options();
     76    }
     77
     78    $static_buttons = array('before_content_options', 'after_content_options', 'shortcode_options');
     79    foreach($static_buttons as $sb) {
     80        if (! isset($sharpay_options[$sb]['use_custom_colors'])) {
     81            $sharpay_options[$sb]['use_custom_colors'] = false;
     82        }
     83        if (! isset($sharpay_options[$sb]['color_font'])) {
     84            $sharpay_options[$sb]['color_font'] = 'ffffff';
     85        }
     86        if (! isset($sharpay_options[$sb]['color_bg'])) {
     87            $sharpay_options[$sb]['color_bg'] = 'ff9933';
     88        }
    7289    }
    7390
     
    240257
    241258    <div class="group">
     259        <input type="checkbox" name="<?php echo $options; ?>[use_custom_colors]"
     260               id="<?php echo "{$prop}-use-custom-colors" ?>" class="use-custom-colors"
     261            <?php echo $sharpay_options[$prop]['use_custom_colors'] === true ? 'checked' : '' ?> >
     262        <label for="<?php echo "{$prop}-use-custom-colors" ?>">
     263            <?php echo __('Would you like to use custom colors for Sharpay button?', 'sharpay-plugin'); ?></label>
     264
     265        <div class="colors" style="<?php echo $sharpay_options[$prop]['use_custom_colors'] === true ? '' : 'display:none;' ?>">
     266            <label for="<?php echo "{$prop}-font-color" ?>">
     267                <?php echo __('Font color', 'sharpay-plugin'); ?>
     268            </label>
     269            <span>#</span>
     270            <input type="text" value="<?php echo $sharpay_options[$prop]['color_font'] ?>"
     271                   name="<?php echo $options; ?>[color_font]"
     272                   id="<?php echo "{$prop}-font-color" ?>">
     273
     274            <label for="<?php echo "{$prop}-bg-color" ?>">
     275                <?php echo __('Background color', 'sharpay-plugin'); ?>
     276            </label>
     277            <span>#</span>
     278            <input type="text" value="<?php echo $sharpay_options[$prop]['color_bg'] ?>"
     279                   name="<?php echo $options; ?>[color_bg]"
     280                   id="<?php echo "{$prop}-bg-color" ?>">
     281        </div>
     282
     283    </div>
     284
     285    <div class="group">
    242286        <input type="checkbox" name="<?php echo $options; ?>[use_custom_markup]" id="<?php echo "{$prop}-use-custom-markup" ?>" class="use-custom-markup"
    243287            <?php echo $sharpay_options[$prop]['use_custom_markup'] === true ? 'checked' : '' ?> >
     
    246290
    247291    <div class="group" style="<?php echo $sharpay_options[$prop]['use_custom_markup'] === true ? '' : 'display:none;' ?>">
    248         <textarea name="<?php echo $options; ?>[custom_markup]" rows="5"><?php echo $sharpay_options[$prop]['custom_markup']; ?></textarea>
     292        <textarea name="<?php echo $options; ?>[custom_markup]" rows="5">
     293            <?php echo $sharpay_options[$prop]['custom_markup']; ?></textarea>
    249294        <p class="description"><?php echo __('Enter HTML markup which represents your custom multishare button.', 'sharpay-plugin'); ?></p>
    250295    </div>
     
    267312
    268313    $input['before_content'] = sharpay_sanitize_checkbox($input, 'before_content');
    269     $input['before_content_options'] = sharpay_sanitize_static_options($input['before_content_options']);
     314    $input['before_content_options'] = sharpay_sanitize_static_options($input['before_content_options'], 'before');
    270315
    271316    $input['after_content'] = sharpay_sanitize_checkbox($input, 'after_content');
    272     $input['after_content_options'] = sharpay_sanitize_static_options($input['after_content_options']);
     317    $input['after_content_options'] = sharpay_sanitize_static_options($input['after_content_options'], 'after');
    273318
    274319    $input['shortcode'] = sharpay_sanitize_checkbox($input, 'shortcode');
    275     $input['shortcode_options'] = sharpay_sanitize_static_options($input['shortcode_options']);
     320    $input['shortcode_options'] = sharpay_sanitize_static_options($input['shortcode_options'], 'shortcode');
    276321
    277322    return $input;
     
    297342}
    298343
    299 function sharpay_sanitize_static_options( $input ) {
    300 
     344function sharpay_sanitize_static_options( $input, $tag )
     345{
    301346    $input = sharpay_sanitize_common_options( $input );
    302347
     
    307352    $input['height'] = $height;
    308353
    309     $input['use_custom_markup'] = isset($input['use_custom_markup'])
    310         && sanitize_text_field($input['use_custom_markup']) === 'on' ? true : false;
     354    if (isset($input['use_custom_colors'])) {
     355        $val = $input['use_custom_colors'];
     356        $input['use_custom_colors'] = ($val === 'on' || $val === true) ? true : false;
     357    }
     358    else {
     359        $input['use_custom_colors'] = false;
     360    }
     361
     362    $input['color_font'] = sanitize_text_field($input['color_font']);
     363    $input['color_bg'] = sanitize_text_field($input['color_bg']);
     364
     365    if (isset($input['use_custom_markup'])) {
     366        $val = $input['use_custom_markup'];
     367        $input['use_custom_markup'] = ($val === 'on' || $val === true) ? true : false;
     368    }
     369    else {
     370        $input['use_custom_markup'] = false;
     371    }
    311372
    312373    return $input;
  • sharpay/trunk/includes/sharpay-public.php

    r2024832 r2088844  
    9595    }
    9696
     97    if ($is_static && isset($options['use_custom_colors']) && $options['use_custom_colors']) {
     98        $src .= "data-color-font=\"{$options['color_font']}\" data-color-bg=\"{$options['color_bg']}\"";
     99    }
     100
    97101    if ( $lang != 'en' ) {
    98102        $src .= "data-lang=\"{$lang}\" ";
  • sharpay/trunk/readme.txt

    r2063469 r2088844  
    44Tags: social, sharing
    55Requires at least: 3.5
    6 Tested up to: 5.1
     6Tested up to: 5.2
    77Stable tag: "trunk"
    88Requires PHP: 5.2.4
     
    3636== Changelog ==
    3737
     38= 1.5 =
     39* Font and background color options for static button.
     40
    3841= 1.4 =
    3942* Updated translation
  • sharpay/trunk/sharpay.php

    r2063472 r2088844  
    2121Plugin URI: https://github.com/sharpay-io/wordpress
    2222Description: Sharpay is multisharing button with blockchain profit. It allows you to reward site's visitors for sharing content to their audience via Facebook, Twitter, Medium, Reddit and many other social networks.
    23 Version: 1.4
     23Version: 1.5
    2424Author: Sharpay Inc
    2525Author URI: https://sharpay.io
     
    2929*/
    3030
    31 define('SHARPAY_PLUGIN_VERSION', '1.4');
     31define('SHARPAY_PLUGIN_VERSION', '1.5');
    3232
    3333register_activation_hook(__FILE__, 'sharpay_activate');
Note: See TracChangeset for help on using the changeset viewer.