Plugin Directory

Changeset 1545989


Ignore:
Timestamp:
12/05/2016 04:01:48 PM (9 years ago)
Author:
timph
Message:

adding color controls and wp 4.7 compat code

Location:
customizer-social-icons/trunk
Files:
18 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • customizer-social-icons/trunk/assets/js/customizer-social-icons-live-preview.js

    r1541221 r1545989  
    1313    var self = CustomizerSocialIcons.LivePreview;
    1414
     15
    1516    /**
    1617     * Initialize Social Media Icon Controls.
    1718     *
    18      * @since 1.1.0
     19     * @since 0.1
    1920     */
    2021    self.initialize = function() {
     22        $( document ).ready( self.onReady );
    2123        self.iconSize();
    2224        self.iconText();
     25        self.iconColor();
     26        self.iconColorSecondary();
     27        self.iconHoverColor();
     28        self.iconHoverColorSecondary();
    2329        self.iconSpacing();
     30
     31    };
     32
     33    self.onReady = function() {
     34        self.getSettings();
     35    };
     36
     37    self.getSettings = function() {
     38        wp.customize.bind( 'ready', _.defer( function() {
     39            self.configs = {
     40                iconStyle : api( 'customizer_social_icons_type_setting' )(),
     41                hoverColor : api( 'customizer_social_icons_hover_color_setting' )(),
     42                hoverColorSecondary : api( 'customizer_social_icons_hover_color_secondary_setting' )(),
     43                currentColor : api( 'customizer_social_icons_color_setting' )(),
     44                currentColorSecondary : api( 'customizer_social_icons_color_secondary_setting' )(),
     45            };
     46        } ) );
     47    };
     48
     49    /**
     50     * Listen for hover.
     51     *
     52     * @since 0.3
     53     */
     54    self.hover = function() {
     55        $( '.menu-social' );
     56        var $icons, $stack, $openStack, selector, currentColor;
     57        // Define selector for stacks or standard icons.
     58        $icons = $( '.menu-social a' );
     59        $stack = $( '.menu-social' ).find( 'span.stack-closed' ).parent( 'a' );
     60        $openStack = $( '.menu-social' ).find( 'span.stack-open' ).parent( 'a' );
     61        if ( $stack.length ) {
     62            selector = $stack;
     63            selector.hover(
     64                function( e ) {
     65                    // Set hover color.
     66                    $( e.currentTarget ).find( '.fa-inverse' ).css( 'color', self.configs.hoverColor );
     67                    // Set hover color.
     68                    $( e.currentTarget ).find( 'i.fa:first-child' ).css( 'color', self.configs.hoverColorSecondary );
     69                },
     70                function( e ) {
     71                    // Reassign to the current secondary color.
     72                    $( e.currentTarget ).find( '.fa-inverse' ).css( 'color', self.configs.currentColor );
     73                    // Set hover color.
     74                    $( e.currentTarget ).find( 'i.fa:first-child' ).css( 'color', self.configs.currentColorSecondary );
     75                }
     76            );
     77            return;
     78        }
     79        selector = $icons;
     80        if ( $openStack.length ) selector = $openStack;
     81        selector.hover(
     82            function( e ) {
     83                // Set hover color.
     84                $( e.currentTarget ).find( 'i.fa' ).css( 'color', self.configs.hoverColor );
     85            },
     86            function( e ) {
     87                // Reassign to the current color.
     88                $( e.currentTarget ).find( 'i.fa' ).css( 'color', self.configs.currentColor );
     89            }
     90        );
    2491    };
    2592
     
    2794     * Adjust Social Media Icon Size.
    2895     *
    29      * @since 1.1.0
     96     * @since 0.2
    3097     */
    3198    self.iconSize = function() {
     
    34101            value.bind( function( to ) {
    35102                var $icons, $stack, selector;
    36 
    37103                // Define selector for stacks or standard icons.
    38104                $icons = $( '.menu-social' ).find( 'i.fa' );
     
    58124     * Hide or Show Social Media Icon Text.
    59125     *
    60      * @since 1.1.0
     126     * @since 0.2
    61127     */
    62128    self.iconText = function() {
     
    82148
    83149    /**
     150     * Adjust Social Media Icon Color.
     151     *
     152     * @since 0.3
     153     */
     154    self.iconColor = function() {
     155        // Set logo letter spacing on site title text live
     156        api( 'customizer_social_icons_color_setting', function( value ) {
     157            value.bind( function( to ) {
     158                self.configs.currentColor = to;
     159                var $icons = self.configs.iconStyle, selector;
     160
     161                if ( $icons === 'icon' ) {
     162                    selector = $( '.menu-social' ).find( 'i.fa' );
     163                } else if ( $icons === 'icon-square' || $icons === 'icon-circle' ) {
     164                    selector = $( '.menu-social' ).find( 'span.stack-closed > .fa-inverse' );
     165                } else {
     166                    selector = $( '.menu-social' ).find( 'span.fa-stack' );
     167                }
     168
     169                // Add color to selector.
     170                selector.css( 'color', to );
     171                self.hover();
     172            } );
     173        } );
     174    };
     175
     176    self.iconColorSecondary = function() {
     177        // Set logo letter spacing on site title text live
     178        api( 'customizer_social_icons_color_secondary_setting', function( value ) {
     179            value.bind( function( to ) {
     180                self.configs.currentColorSecondary = to;
     181                var $icons = self.configs.iconStyle, selector;
     182                selector = $( '.menu-social' ).find( 'span.stack-closed > i.fa:not(.fa-inverse)' );
     183
     184                // Add color to selector.
     185                selector.css( 'color', to );
     186                self.hover();
     187            } );
     188        } );
     189    };
     190
     191    /**
     192     * Adjust Social Media Icon Hover Color.
     193     *
     194     * @since 0.3
     195     */
     196    self.iconHoverColor = function() {
     197        // Set logo letter spacing on site title text live
     198        api( 'customizer_social_icons_hover_color_setting', function( value ) {
     199            value.bind( function( to ) {
     200                // Update hover color.
     201                self.configs.hoverColor = to;
     202                self.hover();
     203            } );
     204        } );
     205    };
     206
     207    /**
     208     * Adjust Social Media Icon Hover Color.
     209     *
     210     * @since 0.3
     211     */
     212    self.iconHoverColorSecondary = function() {
     213        // Set logo letter spacing on site title text live
     214        api( 'customizer_social_icons_hover_color_secondary_setting', function( value ) {
     215            value.bind( function( to ) {
     216                // Update hover color.
     217                self.configs.hoverColorSecondary = to;
     218                self.hover();
     219            } );
     220        } );
     221    };
     222
     223    /**
    84224     * Adjust Social Media Icon Spacing.
    85225     *
    86      * @since 1.1.0
     226     * @since 0.2
    87227     */
    88228    self.iconSpacing = function() {
  • customizer-social-icons/trunk/customizer-social-icons.php

    r1540892 r1545989  
    2828 * @package CustomizerSocialIcons
    2929 */
     30// Include the autoloader
     31include_once wp_normalize_path( plugin_dir_path( __FILE__ ) . '/autoload.php' );
    3032
    31 require_once __DIR__ . '/class-customizer-social-icons.php';
    32 new Customizer_Social_Icons();
     33$customizer_social_icons = new Customizer_Social_Icons();
     34$customizer_social_icons->run();
  • customizer-social-icons/trunk/readme.txt

    r1541221 r1545989  
    44Tags: customizer, social media icons, social icons, social media, social, customize, customize social
    55Requires at least: 4.3
    6 Tested up to: 4.6
    7 Stable tag: 0.2
     6Tested up to: 4.7
     7Stable tag: 0.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1515Customizer Social Icons aims to bring one of the most implemented features across websites into your WordPress Customizer.  It helps to bridge the gap of not having a native Social Media Icon tool available in WordPress directly, and gives you the features you need without the overhead of a clunky non-native interface.
    1616
    17 You can control the style, size, and spacing of your icons to fit your website's needs hassle free inside of the WordPress Customizer.  Any of your social media network urls found in your menus will automatically be transformed into the corresponding social media icons for you.
     17You can control the style of icon, colors, size, and spacing of your icons to fit your website's needs hassle free inside of the WordPress Customizer.  Any of your social media network urls found in your menus will automatically be transformed into the corresponding social media icons for you.
    1818
    1919Available Social Media Icons:
     
    85851. Click on "Customize" to get to the WordPress Customizer.
    86862. Click on the tab that says "Menus".
    87 3. Next, click on "Menu Locations," and you will see a new panel slide in that will display all of your theme's available menu locations.  The menu locations are locations your theme has designated as being locations you can stick a menu inside.  These will be the locations you can add Social Media Icons to with this plugin. 
     873. Next, click on "Menu Locations," and you will see a new panel slide in that will display all of your theme's available menu locations.  The menu locations are locations your theme has designated as being locations you can stick a menu inside.  These will be the locations you can add Social Media Icons to with this plugin.
    88884. Click on "Edit Menu" if you have a menu assigned to a location, or select a menu from the dropdown to add icons to that.
    89895. Press "Add Items," and a panel will slide out with some options of things you can add.
     
    9696
    9797**A**: Yes! This plugin has a configuration filter, so you can just inspect the 'networks' array for how to prepare the data and filter to suit your needs!
    98 
    9998
    10099= Q: How can I add this to my own theme and set defaults? =
     
    1101095. **Social Icon Styles** - Various Icon Styles are available to make the icons fit better with your overall design.
    1111106. **Social Icon Sizes** - You can change the size of your social icons right in the customizer to give a different look to your chosen icons.
     1117. **Social Icon Colors** - Colors can be changed for your social icons in the WordPress customizer controls as well.
    112112
    113113== Changelog ==
     114
     115= 0.3 =
     116* New Feature: Added color selections for icons in customizer.
     117* Update: Changed control styles to look more modern.
     118* Update: Added and checked compatibility for WordPress 4.7.
     119* Update: Classes now use autoloader, expanded configs.
    114120
    115121= 0.2 =
Note: See TracChangeset for help on using the changeset viewer.