Plugin Directory

Changeset 3326426


Ignore:
Timestamp:
07/11/2025 04:59:39 PM (9 months ago)
Author:
abdullahart
Message:

Added Text and wishlist icon option in version 1.0.7

Location:
wishlist-everywhere
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • wishlist-everywhere/tags/1.0.6/README.txt

    r3326402 r3326426  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 1.0.6
     6Stable tag: 1.0.7
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • wishlist-everywhere/tags/1.0.6/admin/partials/wishlist-everywhere-plugin-admin-display.php

    r3326402 r3326426  
    115115    ];
    116116
     117    $wishlist_icons = [
     118        'icon_only' => 'Icon Only',
     119        'text_only' => 'Text Only',
     120        'icon_text' => 'Text + Icon',
     121    ];
     122
    117123
    118124    unset($wishlist_post_types['attachment']);
     
    143149        }       
    144150   
     151        if (!empty($_POST['wishlist_custom_icon'])) {
     152            $wishlist_custom_icon = sanitize_text_field(wp_unslash($_POST['wishlist_custom_icon']));
     153            update_option('wishlist_custom_icon', $wishlist_custom_icon, true);
     154        }
     155
    145156        if (isset($_POST['wishlist_archive']) && $_POST['wishlist_archive'] === 'archive') {
    146157            update_option('wishlist_for_archive', 'archive');
     
    193204    $wishlist_position = get_option('wishlist_archive_position');
    194205    $wishlist_single_position = get_option('wishlist_single_position');
     206    $wishlist_icon_option = get_option('wishlist_custom_icon');
    195207
    196208    unset($wishlist_post_types[$wishlist_post_name]);
     
    200212    $archive_position_val = '';
    201213    $single_position_val = '';
     214    $wishlist_custom_icon = '';
    202215
    203216    // Start building dropdown only if post types are available
     
    237250    }
    238251
     252
     253    if (!empty($wishlist_icons)) {
     254        foreach ($wishlist_icons as $value => $label) {
     255            $wishlist_custom_icon .= sprintf(
     256                '<option value="%s"%s>%s</option>',
     257                esc_attr($value),
     258                selected($wishlist_icon_option, $value, false),
     259                esc_html($label)
     260            );
     261        }
     262    }   
    239263
    240264 echo '
     
    422446      <div class = "row_wrapper">     
    423447      <div class = "group-wrapper">
    424         <h2>Wishlist Button Text</h2>
     448        <h2>Wishlist Button Settings</h2>
     449         <div class="form-group">
     450            <label>Display Style</label>
     451            <select id="wishlist_custom_icon" name="wishlist_custom_icon">
     452                ' . $wishlist_custom_icon . '
     453            </select>         
     454            </div>       
    425455         <div class="form-group">
    426456            <label>Wishlist Button Label</label>
     
    434464      <div class = "detail-wrapper">
    435465         <ol>
     466         <li>
     467         <strong>Display Style</strong><br>
     468         Choose how the wishlist button appears on products: icon only, text only, or both.
     469         </li>
    436470         <li>
    437471            <strong>Wishlist Button Label</strong><br>
  • wishlist-everywhere/tags/1.0.6/includes/class-wishlist-everywhere-plugin.php

    r3326402 r3326426  
    105105            add_shortcode('wishlist_everywhere_single', array($this, 'add_wishlist_icon_to_product_single'));
    106106        }
     107
    107108        $wishlist_position = get_option('wishlist_archive_position');
    108109        if($wishlist_position == 'above_thumbnail') {
     
    113114            add_shortcode('wishlist_everywhere_archive', array($this, 'add_wishlist_icon_to_product_archive'));
    114115        }
     116       
    115117        add_filter('woocommerce_add_to_cart_redirect', array($this, 'custom_redirect_after_add_to_cart'), 10, 1);
    116118        add_shortcode('wishlist_everywhere', [$this, 'display_wishlist_page']);
     
    124126        }
    125127        add_action('wp_head',[$this,'add_wishlist_custom_css']);
     128        add_action('wp_footer',[$this,'wishlist_everywhere_js_data']);
    126129
    127130    }
     
    584587    // Choose class for position
    585588    $position_class = $wishlist_position === 'above_thumbnail' ? 'above_thumbnail' : 'no_thumbnail';
    586 
     589    $wishlist_icon_option = get_option('wishlist_custom_icon');
    587590    if ($required_login === 'required_login') {
    588591        // Only for logged-in users
    589592        if (is_user_logged_in()) {
    590             $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
    591                 <a href="#" class="wishlist-icon archive" data-post-id="' . esc_attr(get_the_ID()) . '">' . esc_html($wishlist_title) . '</a>
    592             </div>';
    593             echo wp_kses_post($wishlist_icon);
     593            if($wishlist_icon_option === 'text_only'){
     594                $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
     595                    <a href="#" class="wishlist-icon archive" data-post-id="' . esc_attr(get_the_ID()) . '">' . esc_html($wishlist_title) . '</a>
     596                </div>';
     597                echo wp_kses_post($wishlist_icon);
     598            }else if($wishlist_icon_option === 'icon_only'){
     599                $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
     600                    <a href="#" class="wishlist-icon archive" data-post-id="' . esc_attr(get_the_ID()) . '"><i class="fa-regular fa-heart"></i></a>
     601                </div>';
     602                echo wp_kses_post($wishlist_icon);
     603            }else{
     604                $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
     605                    <a href="#" class="wishlist-icon archive" data-post-id="' . esc_attr(get_the_ID()) . '"> <i class="fa-regular fa-heart"></i>' . esc_html($wishlist_title) . '</a>
     606                </div>';
     607                echo wp_kses_post($wishlist_icon);
     608            }
     609
     610
    594611        } else {
    595612    // Get the current URL to redirect back after login
     
    619636            $added_class = ' added';
    620637        }
    621 
    622         $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
    623             <a href="#" class="wishlist-icon archive' . esc_attr($added_class) . '" data-post-id="' . esc_attr(get_the_ID()) . '">' . esc_html($wishlist_title) . '</a>
    624         </div>';
    625 
    626         echo wp_kses_post($wishlist_icon);
     638        if($wishlist_icon_option === 'text_only'){
     639            $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
     640                <a href="#" class="wishlist-icon archive' . esc_attr($added_class) . '" data-post-id="' . esc_attr(get_the_ID()) . '">' . esc_html($wishlist_title) . '</a>
     641            </div>';
     642            echo wp_kses_post($wishlist_icon);
     643        }else if($wishlist_icon_option === 'icon_only'){
     644            $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
     645                <a href="#" class="wishlist-icon archive' . esc_attr($added_class) . '" data-post-id="' . esc_attr(get_the_ID()) . '"><i class="fa-regular fa-heart"></i></a>
     646            </div>';
     647            echo wp_kses_post($wishlist_icon);
     648        }else{
     649            $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
     650                <a href="#" class="wishlist-icon archive' . esc_attr($added_class) . '" data-post-id="' . esc_attr(get_the_ID()) . '"> <i class="fa-regular fa-heart"></i> ' . esc_html($wishlist_title) . '</a>
     651            </div>';
     652            echo wp_kses_post($wishlist_icon);
     653        }
     654
    627655    }
    628656}
     
    823851    echo do_shortcode('[wishlist_everywhere post_type = "product"]');
    824852}
     853
     854function wishlist_everywhere_js_data() {
     855    if (is_user_logged_in()) {
     856        global $wpdb;
     857        $user_id = get_current_user_id();
     858        $table = $wpdb->prefix . 'cstmwishlist';
     859
     860        $ids = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM {$table} WHERE user_id = %d", $user_id));
     861        echo '<script>var wishlistPostIds = ' . json_encode($ids) . ';</script>';
     862    } else {
     863        echo '<script>var wishlistPostIds = [];</script>';
     864    }
    825865}
     866}
  • wishlist-everywhere/tags/1.0.6/public/css/wishlist-everywhere-plugin-public.css

    r3326402 r3326426  
    266266    margin-top: 0;
    267267    position: relative;
     268    display: flex;
     269    align-items: center;
     270    gap: 7px;
    268271}
    269272.no_thumbnail .wishlist-icon.archive {
     
    272275    margin-top: 10px;
    273276}
     277
     278@media screen and (max-width:767px) {
     279  .wishlist-tab-content {
     280    overflow: scroll;
     281}
     282.wishlist-table th, .wishlist-table td {
     283    width: max-content;
     284    white-space: nowrap;
     285
     286}
  • wishlist-everywhere/tags/1.0.6/public/js/wishlist-everywhere-plugin-public.js

    r3326402 r3326426  
    3131        );
    3232
     33            if (typeof wishlistPostIds !== 'undefined') {
     34        wishlistPostIds.forEach(function(postId) {
     35            $('ul.products .post-' + postId + ' i.fa-heart')
     36                .removeClass('fa-regular')
     37                .addClass('fa-solid');
     38        });
     39    }
     40
    3341        // Add to Wishlist AJAX function
    3442        function addToWishlist(postId)
     
    4553                    success: function (response) {
    4654                        if (response.success) {
    47                             // jQuery('ul.products').find('i.fa-heart').removeClass('fa-regular');
    48                             // jQuery('ul.products').find('i.fa-heart').addClass('fa-solid');
    4955                            Swal.fire(
    5056                                {
     
    5864                                {
    5965                                    if (result.isConfirmed) {
    60                                     window.location.href = window.location.href + `?post-${postId}`;   
    61                                         // $('.wishlist-icon').removeClass('fa-regular');                               
    62                                         // $('.wishlist-icon').addClass('fa-solid');                               
     66                                        // window.location.href = window.location.href + `?post-${postId}`;   
     67                jQuery(`ul.products .post-${postId} i.fa-heart`)
     68                    .removeClass('fa-regular')
     69                    .addClass('fa-solid');                           
    6370                                    }
    6471                                }
     
    119126                            );
    120127                            //   window.location.href = window.location.href+'?sd';
    121                               jQuery('.wishlist-icon').removeClass("wishlist-added");
     128                            //   jQuery('.wishlist-icon').removeClass("wishlist-added");
    122129                            // You can perform additional actions here after successful removal from the wishlist
    123130                        } else {
  • wishlist-everywhere/tags/1.0.6/wishlist-everywhere.php

    r3326402 r3326426  
    2020 * Plugin URI:        https://github.com/abdullahnart/wishlist-everywhere
    2121 * Description:       A simple yet flexible plugin that enables wishlist functionality for all post types — including products, blog posts, or custom post types. Easily customize labels and manage user wishlists across your WordPress site.
    22  * Version:           1.0.6
     22 * Version:           1.0.7
    2323 * Author:            Abdullah Naseem
    2424 * Author URI:        https://github.com/abdullahnart/wishlist-everywhere/
  • wishlist-everywhere/trunk/README.txt

    r3325822 r3326426  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 1.0.6
     6Stable tag: 1.0.7
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • wishlist-everywhere/trunk/admin/partials/wishlist-everywhere-plugin-admin-display.php

    r3325822 r3326426  
    115115    ];
    116116
     117    $wishlist_icons = [
     118        'icon_only' => 'Icon Only',
     119        'text_only' => 'Text Only',
     120        'icon_text' => 'Text + Icon',
     121    ];
     122
    117123
    118124    unset($wishlist_post_types['attachment']);
     
    143149        }       
    144150   
     151        if (!empty($_POST['wishlist_custom_icon'])) {
     152            $wishlist_custom_icon = sanitize_text_field(wp_unslash($_POST['wishlist_custom_icon']));
     153            update_option('wishlist_custom_icon', $wishlist_custom_icon, true);
     154        }
     155
    145156        if (isset($_POST['wishlist_archive']) && $_POST['wishlist_archive'] === 'archive') {
    146157            update_option('wishlist_for_archive', 'archive');
     
    193204    $wishlist_position = get_option('wishlist_archive_position');
    194205    $wishlist_single_position = get_option('wishlist_single_position');
     206    $wishlist_icon_option = get_option('wishlist_custom_icon');
    195207
    196208    unset($wishlist_post_types[$wishlist_post_name]);
     
    200212    $archive_position_val = '';
    201213    $single_position_val = '';
     214    $wishlist_custom_icon = '';
    202215
    203216    // Start building dropdown only if post types are available
     
    237250    }
    238251
     252
     253    if (!empty($wishlist_icons)) {
     254        foreach ($wishlist_icons as $value => $label) {
     255            $wishlist_custom_icon .= sprintf(
     256                '<option value="%s"%s>%s</option>',
     257                esc_attr($value),
     258                selected($wishlist_icon_option, $value, false),
     259                esc_html($label)
     260            );
     261        }
     262    }   
    239263
    240264 echo '
     
    422446      <div class = "row_wrapper">     
    423447      <div class = "group-wrapper">
    424         <h2>Wishlist Button Text</h2>
     448        <h2>Wishlist Button Settings</h2>
     449         <div class="form-group">
     450            <label>Display Style</label>
     451            <select id="wishlist_custom_icon" name="wishlist_custom_icon">
     452                ' . $wishlist_custom_icon . '
     453            </select>         
     454            </div>       
    425455         <div class="form-group">
    426456            <label>Wishlist Button Label</label>
     
    434464      <div class = "detail-wrapper">
    435465         <ol>
     466         <li>
     467         <strong>Display Style</strong><br>
     468         Choose how the wishlist button appears on products: icon only, text only, or both.
     469         </li>
    436470         <li>
    437471            <strong>Wishlist Button Label</strong><br>
  • wishlist-everywhere/trunk/includes/class-wishlist-everywhere-plugin.php

    r3325822 r3326426  
    105105            add_shortcode('wishlist_everywhere_single', array($this, 'add_wishlist_icon_to_product_single'));
    106106        }
     107
    107108        $wishlist_position = get_option('wishlist_archive_position');
    108109        if($wishlist_position == 'above_thumbnail') {
     
    113114            add_shortcode('wishlist_everywhere_archive', array($this, 'add_wishlist_icon_to_product_archive'));
    114115        }
     116       
    115117        add_filter('woocommerce_add_to_cart_redirect', array($this, 'custom_redirect_after_add_to_cart'), 10, 1);
    116118        add_shortcode('wishlist_everywhere', [$this, 'display_wishlist_page']);
     
    124126        }
    125127        add_action('wp_head',[$this,'add_wishlist_custom_css']);
     128        add_action('wp_footer',[$this,'wishlist_everywhere_js_data']);
    126129
    127130    }
     
    584587    // Choose class for position
    585588    $position_class = $wishlist_position === 'above_thumbnail' ? 'above_thumbnail' : 'no_thumbnail';
    586 
     589    $wishlist_icon_option = get_option('wishlist_custom_icon');
    587590    if ($required_login === 'required_login') {
    588591        // Only for logged-in users
    589592        if (is_user_logged_in()) {
    590             $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
    591                 <a href="#" class="wishlist-icon archive" data-post-id="' . esc_attr(get_the_ID()) . '">' . esc_html($wishlist_title) . '</a>
    592             </div>';
    593             echo wp_kses_post($wishlist_icon);
     593            if($wishlist_icon_option === 'text_only'){
     594                $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
     595                    <a href="#" class="wishlist-icon archive" data-post-id="' . esc_attr(get_the_ID()) . '">' . esc_html($wishlist_title) . '</a>
     596                </div>';
     597                echo wp_kses_post($wishlist_icon);
     598            }else if($wishlist_icon_option === 'icon_only'){
     599                $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
     600                    <a href="#" class="wishlist-icon archive" data-post-id="' . esc_attr(get_the_ID()) . '"><i class="fa-regular fa-heart"></i></a>
     601                </div>';
     602                echo wp_kses_post($wishlist_icon);
     603            }else{
     604                $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
     605                    <a href="#" class="wishlist-icon archive" data-post-id="' . esc_attr(get_the_ID()) . '"> <i class="fa-regular fa-heart"></i>' . esc_html($wishlist_title) . '</a>
     606                </div>';
     607                echo wp_kses_post($wishlist_icon);
     608            }
     609
     610
    594611        } else {
    595612    // Get the current URL to redirect back after login
     
    619636            $added_class = ' added';
    620637        }
    621 
    622         $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
    623             <a href="#" class="wishlist-icon archive' . esc_attr($added_class) . '" data-post-id="' . esc_attr(get_the_ID()) . '">' . esc_html($wishlist_title) . '</a>
    624         </div>';
    625 
    626         echo wp_kses_post($wishlist_icon);
     638        if($wishlist_icon_option === 'text_only'){
     639            $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
     640                <a href="#" class="wishlist-icon archive' . esc_attr($added_class) . '" data-post-id="' . esc_attr(get_the_ID()) . '">' . esc_html($wishlist_title) . '</a>
     641            </div>';
     642            echo wp_kses_post($wishlist_icon);
     643        }else if($wishlist_icon_option === 'icon_only'){
     644            $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
     645                <a href="#" class="wishlist-icon archive' . esc_attr($added_class) . '" data-post-id="' . esc_attr(get_the_ID()) . '"><i class="fa-regular fa-heart"></i></a>
     646            </div>';
     647            echo wp_kses_post($wishlist_icon);
     648        }else{
     649            $wishlist_icon = '<div class="shop_wishlist_wrap ' . esc_attr($position_class) . '">
     650                <a href="#" class="wishlist-icon archive' . esc_attr($added_class) . '" data-post-id="' . esc_attr(get_the_ID()) . '"> <i class="fa-regular fa-heart"></i> ' . esc_html($wishlist_title) . '</a>
     651            </div>';
     652            echo wp_kses_post($wishlist_icon);
     653        }
     654
    627655    }
    628656}
     
    823851    echo do_shortcode('[wishlist_everywhere post_type = "product"]');
    824852}
     853
     854function wishlist_everywhere_js_data() {
     855    if (is_user_logged_in()) {
     856        global $wpdb;
     857        $user_id = get_current_user_id();
     858        $table = $wpdb->prefix . 'cstmwishlist';
     859
     860        $ids = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM {$table} WHERE user_id = %d", $user_id));
     861        echo '<script>var wishlistPostIds = ' . json_encode($ids) . ';</script>';
     862    } else {
     863        echo '<script>var wishlistPostIds = [];</script>';
     864    }
    825865}
     866}
  • wishlist-everywhere/trunk/public/css/wishlist-everywhere-plugin-public.css

    r3325822 r3326426  
    266266    margin-top: 0;
    267267    position: relative;
     268    display: flex;
     269    align-items: center;
     270    gap: 7px;
    268271}
    269272.no_thumbnail .wishlist-icon.archive {
     
    272275    margin-top: 10px;
    273276}
     277
     278@media screen and (max-width:767px) {
     279  .wishlist-tab-content {
     280    overflow: scroll;
     281}
     282.wishlist-table th, .wishlist-table td {
     283    width: max-content;
     284    white-space: nowrap;
     285
     286}
  • wishlist-everywhere/trunk/public/js/wishlist-everywhere-plugin-public.js

    r3325822 r3326426  
    3131        );
    3232
     33            if (typeof wishlistPostIds !== 'undefined') {
     34        wishlistPostIds.forEach(function(postId) {
     35            $('ul.products .post-' + postId + ' i.fa-heart')
     36                .removeClass('fa-regular')
     37                .addClass('fa-solid');
     38        });
     39    }
     40
    3341        // Add to Wishlist AJAX function
    3442        function addToWishlist(postId)
     
    4553                    success: function (response) {
    4654                        if (response.success) {
    47                             // jQuery('ul.products').find('i.fa-heart').removeClass('fa-regular');
    48                             // jQuery('ul.products').find('i.fa-heart').addClass('fa-solid');
    4955                            Swal.fire(
    5056                                {
     
    5864                                {
    5965                                    if (result.isConfirmed) {
    60                                     window.location.href = window.location.href + `?post-${postId}`;   
    61                                         // $('.wishlist-icon').removeClass('fa-regular');                               
    62                                         // $('.wishlist-icon').addClass('fa-solid');                               
     66                                        // window.location.href = window.location.href + `?post-${postId}`;   
     67                jQuery(`ul.products .post-${postId} i.fa-heart`)
     68                    .removeClass('fa-regular')
     69                    .addClass('fa-solid');                           
    6370                                    }
    6471                                }
     
    119126                            );
    120127                            //   window.location.href = window.location.href+'?sd';
    121                               jQuery('.wishlist-icon').removeClass("wishlist-added");
     128                            //   jQuery('.wishlist-icon').removeClass("wishlist-added");
    122129                            // You can perform additional actions here after successful removal from the wishlist
    123130                        } else {
  • wishlist-everywhere/trunk/wishlist-everywhere.php

    r3325822 r3326426  
    2020 * Plugin URI:        https://github.com/abdullahnart/wishlist-everywhere
    2121 * Description:       A simple yet flexible plugin that enables wishlist functionality for all post types — including products, blog posts, or custom post types. Easily customize labels and manage user wishlists across your WordPress site.
    22  * Version:           1.0.6
     22 * Version:           1.0.7
    2323 * Author:            Abdullah Naseem
    2424 * Author URI:        https://github.com/abdullahnart/wishlist-everywhere/
Note: See TracChangeset for help on using the changeset viewer.