Plugin Directory

Changeset 2898156


Ignore:
Timestamp:
04/13/2023 04:05:25 AM (3 years ago)
Author:
Hakik
Message:

v1.1.1: background control, improved script

Location:
ideal-wp-login-logo-changer/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ideal-wp-login-logo-changer/trunk/admin/backend.js

    r2576665 r2898156  
    1 jQuery(document).ready(function($){
    2         $('#iwllc-upload-btn').click(function(e) {
     1
     2(function($){
     3
     4    $(document).ready(function(){
     5
     6        // Depend on saved type to hide/show color/image field
     7        if( iwllc_admin.bg_type === 'color' ){
     8            $('.type_image').hide();
     9            $('.type_color').show();
     10        }
     11        else{
     12            $('.type_color').hide();
     13            $('.type_image').show();
     14        }
     15
     16        $('.iwllc_wp_bg_select').on('change', function(){
     17
     18            // Get the selected value
     19            var selected_type = $(this).find(":selected").val();
     20
     21            if( selected_type === 'color' ){
     22                $('.type_image').hide();
     23                $('.type_color').show();
     24            }
     25            else{
     26                $('.type_color').hide();
     27                $('.type_image').show();
     28            }
     29
     30        });
     31
     32        // Initialize color picker
     33        $('.iwllc_wp_bg_color').wpColorPicker();
     34
     35        // Image Popup Function
     36        $('[id=iwllc-upload-btn]').click(function(e) {
    337            e.preventDefault();
     38            var btn = $(this);
    439            var image = wp.media({
    540                title: 'Upload Logo',
     
    1045                console.log(uploaded_image);
    1146                var image_url = uploaded_image.toJSON().url;
    12                 $('#iwllc_wp_logo_url').val(image_url);
     47                btn.closest('td').find('input[type=text]').val(image_url);
    1348            });
    1449        });
     50
     51
     52
    1553    });
     54
     55})(jQuery);
     56
  • ideal-wp-login-logo-changer/trunk/ideal-wp-login-logo-changer.php

    r2629065 r2898156  
    33Plugin Name: Custom Login Logo For WordPress
    44description: Change the default WordPress logo by uploading your site logo for the login page.
    5 Version: 1.1.0
     5Version: 1.1.1
    66Author: Hakik Zaman
    77Author URI: https://github.com/hakikz
     
    2222
    2323/*Defining Constant*/
    24 define("IWLLC_VERSION", '1.1.0');
     24define("IWLLC_VERSION", '1.1.1');
    2525
    2626
     
    2929{
    3030   register_setting( 'iwllc_change_login_options_group', 'iwllc_wp_logo_url');
     31   register_setting( 'iwllc_change_login_options_group', 'iwllc_wp_set_bg');
     32   register_setting( 'iwllc_change_login_options_group', 'iwllc_wp_bg_color');
     33   register_setting( 'iwllc_change_login_options_group', 'iwllc_wp_bg_img_url');
    3134   register_setting( 'iwllc_change_login_options_group', 'iwllc_wp_logo_link');
    3235   register_setting( 'iwllc_change_login_options_group', 'iwllc_wp_logo_width');
     
    4750
    4851    $cur_logo = esc_attr( get_option('iwllc_wp_logo_url', '') );
     52    $cur_bg_img = esc_attr( get_option('iwllc_wp_bg_img_url', '') );
    4953
    5054    ?>
     
    5660            <?php do_settings_sections( 'iwllc_change_login_options_group' ); ?>
    5761            <table class="form-table">
     62
     63                <!-- Logo Section -->
    5864                <?php if( $cur_logo !== "" ): ?>
    5965                <tr valign="top">
     
    6470                </tr>
    6571                <?php endif; ?>
    66                 <tr valign="top">
    67                     <th scope="row"><?php echo __( 'Set Your Logo' ); ?> </th>
     72               
     73                <tr valign="top">
     74                    <th scope="row"><?php echo __( 'Set Logo' ); ?> </th>
    6875                    <td>
    6976                        <input type="text" id="iwllc_wp_logo_url" name="iwllc_wp_logo_url" value="<?php echo esc_attr( get_option('iwllc_wp_logo_url') ); ?>" />
     
    7279                    </td>
    7380                </tr>
     81
     82                <!-- Choose Background Type Section -->
     83                <tr valign="top">
     84                    <th scope="row"><?php echo __( 'Set Background Type' ); ?></th>
     85                    <td>
     86                        <select class="iwllc_wp_bg_select" name="iwllc_wp_set_bg">
     87                            <option value="color" <?php echo ( empty( get_option('iwllc_wp_set_bg') ) || get_option('iwllc_wp_set_bg') === 'color' ) ? 'selected' : ''  ?> >Color</option>
     88                            <option value="image" <?php echo ( get_option('iwllc_wp_set_bg') === 'image' ) ? 'selected' : ''  ?>>Image</option>
     89                        </select>
     90                        <p class="description"><i><?php echo __( 'Default type is `Color`' ) ?></i></p>
     91                    </td>
     92                </tr>
     93
     94                <!-- Background Color Section -->
     95                <tr class="type_color" valign="top">
     96                    <th scope="row"><?php echo __( 'Set Background Color' ); ?> </th>
     97                    <td>
     98                        <input type="text" class="iwllc_wp_bg_color" id="iwllc_wp_bg_color" name="iwllc_wp_bg_color" value="<?php echo esc_attr( get_option('iwllc_wp_bg_color', '#f0f0f1') ); ?>" data-default-color="#f0f0f1" />
     99                        <p class="description"><i><?php echo __( 'Set your desired color, to change the login page background color' ) ?></i></p>
     100                    </td>
     101                </tr>
     102
     103
     104                <!-- Background Image Section -->
     105                <?php if( $cur_bg_img !== "" ): ?>
     106                <tr class="type_image" valign="top">
     107                    <th>Current Background Image</th>
     108                    <td>
     109                        <img src="<?php echo esc_attr( get_option('iwllc_wp_bg_img_url') ); ?>" alt="Current Background Image" width="220">
     110                    </td>
     111                </tr>
     112                <?php endif; ?>
     113
     114
     115                <tr class="type_image" valign="top">
     116                    <th scope="row"><?php echo __( 'Set Background Image' ); ?> </th>
     117                    <td>
     118                        <input type="text" id="iwllc_wp_bg_img_url" name="iwllc_wp_bg_img_url" value="<?php echo esc_attr( get_option('iwllc_wp_bg_img_url') ); ?>" />
     119                        <input type="button" name="iwllc-upload-btn" id="iwllc-upload-btn" class="button-secondary" value="Upload Logo">
     120                        <p class="description"><i><?php echo __( 'This Image will be displayed as background image of Login Page' ) ?></i></p>
     121                    </td>
     122                </tr>
     123
     124                <!-- Logo Custom Link Section -->
    74125                <tr valign="top">
    75126                    <th scope="row"><?php echo __( 'Set Your Logo Link' ); ?> </th>
     
    79130                    </td>
    80131                </tr>
     132
     133                <!-- Logo Width Settings Section -->
    81134                <tr valign="top">
    82135                    <th scope="row"><?php echo __( 'Width' ); ?></th>
     
    86139                    </td>
    87140                </tr>
     141
     142                <!-- Logo Height Settings Section -->
    88143                <tr valign="top">
    89144                    <th scope="row"><?php echo __( 'Height' ); ?></th>
     
    105160    $screen = get_current_screen();
    106161    if ($screen->id === 'settings_page_change_login_logo') {
     162        wp_enqueue_style( 'wp-color-picker' );
     163        wp_enqueue_script( 'wp-color-picker');
    107164        wp_enqueue_script( 'iwllc-backend', plugins_url( '/admin/backend.js', __FILE__ ), array('jquery'), IWLLC_VERSION, 'true' );
     165        $values = array(
     166            'bg_type' => get_option('iwllc_wp_set_bg', 'color')
     167        );
     168        wp_localize_script( 'iwllc-backend', 'iwllc_admin', $values );
    108169    }
    109170}
     
    115176function iwllc_wordpress_custom_login_logo() {
    116177    $logo_url=get_option('iwllc_wp_logo_url');
     178
     179    $bg_type = get_option('iwllc_wp_set_bg', 'color');
     180
     181    $bg_color=get_option('iwllc_wp_bg_color', '#f0f0f1');
     182
     183    $bg_img_url=get_option('iwllc_wp_bg_img_url');
     184
    117185    $iwllc_wp_logo_height=get_option('iwllc_wp_logo_height');
     186
    118187    $iwllc_wp_logo_width=get_option('iwllc_wp_logo_width');
     188
    119189    if(empty($iwllc_wp_logo_height))
    120190    {
     
    133203        $iwllc_wp_logo_width.='px';
    134204    }
    135     if(!empty($logo_url))
    136     {
    137         echo '<style type="text/css">'.
    138              'h1 a {
    139                 background-image:url('.$logo_url.') !important;
    140                 height:'.$iwllc_wp_logo_height.' !important;
    141                 width:'.$iwllc_wp_logo_width.' !important;
    142                 background-size:100% !important;
    143                 line-height:inherit !important;
    144                 }'.
    145          '</style>';
    146     }
     205
     206    $style = '<style type="text/css">';
     207        if(!empty($logo_url)){
     208            $style .=    'h1 a {
     209                    background-image:url('.$logo_url.') !important;
     210                    height:'.$iwllc_wp_logo_height.' !important;
     211                    width:'.$iwllc_wp_logo_width.' !important;
     212                    background-size:100% !important;
     213                    line-height:inherit !important;
     214                    }';
     215        }
     216
     217        if(!empty($bg_img_url) && $bg_type === "image"){
     218            $style .=    'body.login.login-action-login{
     219                    background-image:url('.$bg_img_url.') !important;
     220                    background-repeat: no-repeat;
     221                    background-size: 100%;
     222                    background-position: center center;
     223                }';
     224        }
     225
     226
     227        $style .= ' body.login.login-action-login{
     228
     229                background-color: '.$bg_color.';
     230
     231            }';
     232
     233    $style .= '</style>';
     234
     235    echo $style;
    147236}
    148237add_action( 'login_head', 'iwllc_wordpress_custom_login_logo' );
  • ideal-wp-login-logo-changer/trunk/readme.txt

    r2677725 r2898156  
    22Contributors: hakik, idealwebguru
    33Tags: Change WP default logo, WordPress Logo change, Login Logo, Custom logo, WP admin logo,
    4 Requires at least: 4.6
    5 Tested up to: 5.9
     4Requires at least: 5.8
     5Tested up to: 6.2
    66Requires PHP: 5.2.4
    7 Stable tag: 1.1.0
     7Stable tag: 1.1.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1919== Feature Highlights Of Custom Login Logo For WordPress  ==
    2020👉 Set your website logo for the login page using **Custom Login Logo For WordPress**
     21👉 Change the background. You can add a color or image for your login page background.
    2122👉 You can set the width and height of the logo from settings panel
    2223👉 By default, the login logo will not redirect to wordpress.org rather than redirect to your site.
     
    6162== Changelog ==
    6263
     64= 1.1.1 [13-04-2023] =
     65* Feature: Change the Backgroud of the login page. Can be added color/image for the background of the login page.
     66* Dev: Improved the script.
     67* Compatibility: WordPress 6.2.
     68
    6369= 1.1.0 =
    6470* Feature: Display current Login Logo in plugin setting page.
Note: See TracChangeset for help on using the changeset viewer.