Plugin Directory

Changeset 2057285


Ignore:
Timestamp:
03/26/2019 04:57:47 AM (7 years ago)
Author:
pangol
Message:

font, background setting is added using color picker

Location:
sewol-count/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sewol-count/trunk/readme.txt

    r2056552 r2057285  
    44Requires at least: 3.0.1
    55Tested up to: 5.1.1
    6 Stable tag: 1.1.1
     6Stable tag: 1.1.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6464= 1.1.0 =
    6565* fixed error
     66
     67= 1.1.1 =
     68* adding font color
     69
     70= 1.1.2 =
     71* adding color picker in font, background color
  • sewol-count/trunk/sewol-count.php

    r2056552 r2057285  
    44Plugin URI: http://parkyong.com
    55Description: count day after Sewol Ferry Disaster
    6 Version: 1.1.1
     6Version: 1.1.2
    77Author: Park Yong
    88Author URI: http://parkyong.com
     
    3030add_action( 'widgets_init', 'sewol_register_widgets' );
    3131add_action('plugins_loaded', 'sewol_load_textdomain');
     32add_action( 'load-widgets.php', 'color_picker_load' );
     33
     34function color_picker_load() {   
     35    wp_enqueue_style( 'wp-color-picker' );       
     36    wp_enqueue_script( 'wp-color-picker' );   
     37}
    3238
    3339function sewol_load_textdomain() {
     
    4854
    4955    function form ( $instance ) {
    50         $defaults = array( 'title' => __('Sewol', 'sewol-count'));
     56        $defaults = array( 'title' => __('Sewol', 'sewol-count'),
     57            'fontColor' => 'yellow',
     58            'backGroundColor' => 'white');
    5159
    5260        $instance = wp_parse_args( (array)$instance, $defaults );
    5361        $title = strip_tags( $instance['title'] );
    5462        $fontColor = strip_tags( $instance['fontColor']);
     63        $backGroundColor = strip_tags( $instance['backGroundColor']);
    5564        ?>
    5665        <p>
     66            <script type='text/javascript'>
     67                ( function( $ ) {
     68                    $(document).on( 'ready widget-added widget-updated', function(event, widget) {
     69                        var params = {
     70                            change: function(e, ui) {
     71                                $( e.target ).val( ui.color.toString() );
     72                                $( e.target ).trigger('change'); // enable widget "Save" button
     73                            },
     74                        }
     75                        $('.font-color-picker').not('[id*="__i__"]').wpColorPicker(params);
     76                        $('.background-color-picker').not('[id*="__i__"]').wpColorPicker(params);
     77                    });
     78                })( jQuery );
     79            </script>
    5780            <?php _e('Title', 'pp-plugin' ) ?>:
    58             <input class="widefat"name="<?php echo $this->get_field_name('title'); ?>"
     81            <input class="widefat" name="<?php echo $this->get_field_name('title'); ?>"
    5982            type="text" value="<?php echo esc_attr($title); ?>" />
    6083            <br />
    6184            <?php _e('Font Color', 'pp-plugin' ) ?>:
    62             <input class="widefat"name="<?php echo $this->get_field_name('fontColor'); ?>"
     85            <input class="widefat font-color-picker" name="<?php echo $this->get_field_name('fontColor'); ?>"
    6386            type="text" value="<?php echo esc_attr($fontColor); ?>" />
     87            <br />
     88            <?php _e('Background Color', 'pp-plugin' ) ?>:
     89            <input type="text" class="widefat background-color-picker" name="<?php echo $this->get_field_name('backGroundColor'); ?>" value="<?php echo esc_attr($backGroundColor); ?>" />
    6490        </p>
    6591    <?php
     
    7096        $instance['title'] = strip_tags(esc_attr($new_instance['title']));
    7197        $instance['fontColor'] = strip_tags(esc_attr($new_instance['fontColor']));
    72 
     98        $instance['backGroundColor'] = strip_tags(esc_attr($new_instance['backGroundColor']));
    7399        return $instance;
    74100    }
     
    81107        $title = apply_filters('widget_title', $instance['title']);
    82108        $fontColor = apply_filters('widget_fontColor', $instance['fontColor']);
     109        $backGroundColor = apply_filters('widget_backGroundColor', $instance['backGroundColor']);
    83110
    84111        if ( !empty( $title ) ) {
     
    89116        $dday = mktime(0,0,0,4,16,2014);
    90117        $xday = ceil(($now-$dday)/(60*60*24));
    91         echo "<p id='sewol' style='color:$fontColor'>" . $xday . "</p>";
     118        echo "<p id='sewol' style='color:$fontColor; background-color:$backGroundColor'>" . $xday . "</p>";
    92119        echo "</aside>";
    93120    }
Note: See TracChangeset for help on using the changeset viewer.