Plugin Directory

Changeset 3433570


Ignore:
Timestamp:
01/06/2026 12:22:22 PM (3 months ago)
Author:
userlog45
Message:

version 1.0.6

Location:
post-types-slider
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • post-types-slider/tags/1.0.4/README.txt

    r3367949 r3433570  
    55Tested up to: 6.7
    66Requires PHP: 7.4
    7 Stable tag:  1.0.5
     7Stable tag:  1.0.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • post-types-slider/tags/1.0.4/post-types-slider.php

    r3367949 r3433570  
    1717 * Plugin URI:        https://clickysoft.com
    1818 * Description:       Post Type Slider can easily create responsive sliders from any post type, including posts, pages, or custom post types. It’s perfect for showcasing blog posts, products, portfolios, or featured content with smooth navigation and customizable display options.
    19  * Version:           1.0.5
     19 * Version:           1.0.4
    2020 * Author:            Clickysoft
    2121 * Author URI:        https://clickysoft.com/
  • post-types-slider/trunk/README.txt

    r3369600 r3433570  
    55Tested up to: 6.7
    66Requires PHP: 7.4
    7 Stable tag:  1.0.5
     7Stable tag:  1.0.6
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7777== Changelog ==
    7878
     79= 1.0.6 =
     80* Improved: Data validation & formatting
     81* Request handling validation
     82* Tabs functions
     83
    7984= 1.0.5 =
    8085* Improved: Improvements on the slider functionality.
  • post-types-slider/trunk/admin/class-post-type-slider-admin.php

    r3369600 r3433570  
    6767        add_action("admin_menu", [$this, 'posttysl_add_admin_menu']);
    6868        add_action('admin_init', [$this, 'postslider_save_options']);
     69        add_action('wp_ajax_post_slider_add_to_cart', [$this, 'post_slider_add_to_cart']);
     70        add_action('wp_ajax_nopriv_post_slider_add_to_cart', [$this, 'post_slider_add_to_cart']);
    6971
    7072    }
     
    170172
    171173
    172     }   
     174    }
    173175
    174176    /**
     
    189191    {
    190192
    191         add_meta_box(
    192             'slider_details',
    193             'Slider Options',
    194             [$this, 'postslider_metabox'],
    195             'posttysl_slide',
    196             'advanced',
    197             'default'
    198         );
    199193        add_meta_box(
    200194            'slider_display2',
     
    205199            'default'
    206200        );
     201        add_meta_box(
     202            'slider_detail',
     203            'Slider Options',
     204            [$this, 'postslider_metabox'],
     205            'posttysl_slide',
     206            'advanced',
     207            'default'
     208        );
    207209    }
    208210
     
    215217        // ob_start();
    216218        if ($post->ID) {
     219
    217220
    218221            include plugin_dir_path(__FILE__) . 'partials/post-type-slider-admin-metabox-shortcode.php';
     
    335338        $slider_category = get_post_meta($post->ID, '_slider_category', true);
    336339        $post_order = get_post_meta($post->ID, '_post_order', true);
     340        $grid_layout = get_post_meta($post->ID, '_grid_layout', true);
    337341        $post_categery_term = get_post_meta($post->ID, '_post_category_term', true);
    338342        $taxonomies = get_object_taxonomies($slider_posttype, 'objects');
    339343        $terms = get_terms(['taxonomy' => $slider_post_category, 'hide_empty' => false]);
    340         $opts = get_post_meta($post->ID, $this->option_name)[0];
     344        $opts = get_post_meta($post->ID, $this->option_name);
     345        if (isset($opts[0])) {
     346            $opts = $opts[0];
     347        }
     348
    341349        // var_dump($opts);
    342350        $post_type = get_post_types(
     
    368376    }
    369377
     378
     379    /**
     380     * Ajax Call for add to cart product
     381     *
     382     */
     383    public function post_slider_add_to_cart()
     384    {
     385
     386        if (!isset($_POST['product_id']) || !isset($_POST['quantity']) || !isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'product_nonce')) {
     387            wp_send_json_error(['message' => 'Invalid request']);
     388        }
     389
     390        $product_id = intval($_POST['product_id']);
     391        $quantity = intval($_POST['quantity']);
     392
     393        if ($product_id <= 0 || $quantity <= 0) {
     394            wp_send_json_error(['message' => 'Invalid product or quantity']);
     395        }
     396
     397        if (!class_exists('WC_Cart')) {
     398            wp_send_json_error(['message' => 'WooCommerce is not active']);
     399        }
     400
     401        $added = WC()->cart->add_to_cart($product_id, $quantity);
     402
     403        if ($added) {
     404            wp_send_json_success(['success' => true, 'message' => 'Product added to cart']);
     405        } else {
     406            wp_send_json_error(['success' => false, 'message' => 'Failed to add product to cart']);
     407        }
     408    }
     409
    370410    /**
    371411     * Save post meta data
     
    419459            if (isset($_POST['post_order'])) {
    420460                update_post_meta($post_id, '_post_order', sanitize_text_field(wp_unslash($_POST['post_order'])));
     461            }
     462            if (isset($_POST['post_order'])) {
     463                update_post_meta($post_id, '_grid_layout', sanitize_text_field(wp_unslash($_POST['grid_layout'])));
    421464            }
    422465
     
    433476            $data['show_image'] = isset($_POST['show_image']) ? '1' : '0';
    434477            $data['show_button'] = isset($_POST['show_button']) ? '1' : '0';
     478            $data['ajax_button'] = isset($_POST['ajax_button']) ? '1' : '0';
    435479            $data['show_date'] = isset($_POST['show_date']) ? '1' : '0';
    436480            $data['show_category'] = isset($_POST['show_category']) ? '1' : '0';
     
    455499            $data['button_style'] = sanitize_text_field($_POST['button_style']);
    456500            $data['button_padding'] = sanitize_text_field($_POST['button_padding']);
     501            $data['button_text'] = sanitize_text_field($_POST['button_text']);
    457502            $data['cards_per_row'] = sanitize_text_field($_POST['cards_per_row']);
    458503            $data['grid_gap'] = sanitize_text_field($_POST['grid_gap']);
     
    465510
    466511            update_post_meta($post_id, $this->option_name, $data);
     512
    467513
    468514            // if (isset($_POST['s_title'])) {
     
    517563        $data['button_style'] = sanitize_text_field($_POST['button_style']);
    518564        $data['button_padding'] = sanitize_text_field($_POST['button_padding']);
     565        $data['button_text'] = sanitize_text_field($_POST['button_text']);
    519566        $data['cards_per_row'] = sanitize_text_field($_POST['cards_per_row']);
    520567        $data['grid_gap'] = sanitize_text_field($_POST['grid_gap']);
     
    650697            if ($taxonomies) {
    651698                foreach ($taxonomies as $tax) {
    652                     if (!in_array($tax->name, $exclude)){
    653                     // Append the taxonomy name and label to the array
    654                     $taxonomy_data[] = [
    655                         'name' => esc_attr($tax->name),
    656                         'label' => esc_html($tax->label),
    657                     ];
    658                 }
     699                    if (!in_array($tax->name, $exclude)) {
     700                        // Append the taxonomy name and label to the array
     701                        $taxonomy_data[] = [
     702                            'name' => esc_attr($tax->name),
     703                            'label' => esc_html($tax->label),
     704                        ];
     705                    }
    659706                }
    660707            }
     
    723770        $all_category = get_post_meta($id, '_all_category', true);
    724771        $order = get_post_meta($id, '_post_order', true);
    725 
    726         $button_text = $post_type == 'product' ? 'Shop Now' : 'Read More';
     772        $layout = get_post_meta($id, '_grid_layout', true);
     773
     774        $button_text = $slider_settings['button_text'] ? $slider_settings['button_text'] : 'Read More';
    727775        $post_column = $slider_settings['cards_per_row'];
    728776        $s_dots = $slider_settings['dots'];
     
    759807        $posts = get_posts($args);
    760808
    761 
    762809        if ($posts) {
    763810
    764             $html .= "<div class='" . $class . "'>";
     811
     812            $html .= '';
     813            $html .= apply_filters('post_slider_before_grid', $html);
     814            $html .= "<div class='" . $class . " slider_layout" . $layout . "'>";
    765815            foreach ($posts as $post) {
    766816
    767                 $date= get_the_date('d-M-Y');
    768                 $terms = wp_get_post_terms($post->ID,  $slider_post_category, ['fields'=> 'names']) ? wp_get_post_terms($post->ID,  $slider_post_category, ['fields'=> 'names']) : '';
     817                $date = get_the_date('d-M-Y');
     818                $terms = wp_get_post_terms($post->ID, $slider_post_category, ['fields' => 'names']) ? wp_get_post_terms($post->ID, $slider_post_category, ['fields' => 'names']) : '';
    769819                $post_terms = '';
    770                 foreach($terms as $term){
    771 
    772                     $post_terms.="<span>".$term."</span>";
     820                $class = $slider_settings['ajax_button'] == '1' && $post_type == 'product' ? 'ajax_add_to_cart' : '';
     821
     822                if (is_array($terms)) {
     823
     824                    foreach ($terms as $term) {
     825
     826                        $post_terms .= "<span>" . $term . "</span>";
     827                    }
    773828                }
    774829                $html .= "<div class='post_slide' style='" . $grid_style . "border:" . $slider_settings['border_width'] . "px solid " . $slider_settings['border_color'] . "; border-radius:" . $slider_settings['border_radius'] . "px; '>";
     
    780835                $html .= "
    781836                            <div class='post_content'>";
    782 
    783837                if ($slider_settings['show_title'] == '1') {
    784                     $html .= "<h2 style='font-size:" . $slider_settings['font_title'] . "px; color:" . $slider_settings['title_color'] . "'>" . get_the_title($post->ID) . "</h2>";
     838                    $html .= "<h2 style='font-size:" . $slider_settings['font_title'] . "px; color:" . $slider_settings['title_color'] . "'>" . substr(get_the_title($post->ID), 0, 60) . "</h2>";
    785839                }
    786840
    787                 $html .="<div class='post_meta'>";
    788                 $slider_settings['show_date'] == '1'  ? $html .= "<p class='meta_date'>Date: ".$date."</p>" : '';
    789                 $slider_settings['show_category'] == '1' && $terms ?    $html .= "<p class='meta_category'>".$post_terms."</p>" : '';
    790                 $html .="</div>";
    791 
     841                $html .= "<div class='post_meta'>";
     842                $slider_settings['show_date'] == '1' ? $html .= "<p class='meta_date'>Date: " . $date . "</p>" : '';
     843                $slider_settings['show_category'] == '1' && $terms ? $html .= "<p class='meta_category'>" . $post_terms . "</p>" : '';
     844                $html .= "</div>";
     845
     846                if ($post_type == 'product') {
     847                    $price = get_post_meta($post->ID, '_price', true);
     848                    $currency = get_woocommerce_currency_symbol();
     849                    $html .= "<p class='product_price'>Price: {$currency}{$price} </p>";
     850                }
    792851                if ($slider_settings['show_description'] == '1') {
    793852                    $html .= "  <p style='font-size:" . $slider_settings['font_desc'] . "px; color:" . $slider_settings['desc_color'] . "'>" . mb_strimwidth(get_the_excerpt($post->ID), 0, 100, '....') . "</p>";
     
    795854
    796855                if ($slider_settings['show_button'] == '1') {
    797                 $html .= "<div class='readmore'><a href='" . get_the_permalink($post->ID) . "'
     856                    $html .= "<div class='readmore'><a class='" . $class . "' data-id='" . $post->ID . "' href='" . get_the_permalink($post->ID) . "'
    798857                style='color: " . $slider_settings['button_text_color'] . "; background-color:" . $slider_settings['button_color'] . "; padding:" . $slider_settings['button_padding'] . "; border-radius:" . ($slider_settings['button_style'] == 'rounded' ? '25px' : '4px') . ";'>
    799858                " . $button_text . "</a></div>";
    800859                }
    801860
    802                 $html .="</div>
     861                $html .= "</div>
    803862                        </div>";
    804             }
    805 
     863
     864            }
    806865            $html .= "</div>";
    807         }
    808 
     866            $html = apply_filters('post_slider_after_grid', $html);
     867        }
     868
     869        ob_start();
    809870        ?>
    810871        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
     
    814875                background:
    815876                    <?php echo $arrow_color; ?>
    816                 ;
     877                    !important;
    817878
    818879            }
     
    870931
    871932        <?php
    872         return $html;
     933
     934        return $html . ob_get_clean();
    873935
    874936    }
  • post-types-slider/trunk/admin/css/post-type-slider-admin.css

    r3369600 r3433570  
    1616    margin-top: 10px;
    1717}
     18
    1819
    1920
  • post-types-slider/trunk/admin/js/post-type-slider-admin.js

    r3369600 r3433570  
    194194    // });
    195195
     196
     197    // const value= jQuery(document).find(".postysl_metaboxes #slider_type").val();
     198    // if(value == 'grid'){
     199
     200    //     jQuery(".horizontal_tabs button[data-tab='template']").fadeIn();
     201    // }else{
     202    //     jQuery(".horizontal_tabs button[data-tab='template']").fadeOut();
     203    // }
     204
     205    jQuery(document).on("change", "#slider_type", function () {
     206
     207        const value = jQuery(this).val();
     208        console.log(value);
     209        if (value == 'grid') {
     210
     211            jQuery(".horizontal_tabs button[data-tab='template']").fadeIn();
     212        } else {
     213            jQuery(".horizontal_tabs button[data-tab='template']").fadeOut();
     214        }
     215    })
     216
     217    // AJax call for product add to cart
     218
    196219})(jQuery);
  • post-types-slider/trunk/admin/partials/post-type-slider-admin-metaboxes.php

    r3369600 r3433570  
    22    <div class="pt-tabs">
    33        <nav class="tab-nav horizontal_tabs">
    4             <button class="tab-btn <?php echo empty($_GET['tab']) || $_GET['tab'] == 'type' ? 'active' : '' ?>"
     4            <button class="tab-btn <?php echo isset($_GET['tab']) && ($_GET['tab'] == 'type' || empty($_GET['tab'])) ? 'active' : '' ?>"
    55                data-tab="type">Type</button>
    6             <button class="tab-btn <?php echo $_GET['tab'] == 'posttype' ? 'active' : '' ?>" data-tab="posttype">Post
     6            <button class="tab-btn <?php echo isset($_GET['tab']) && $_GET['tab'] == 'posttype' ? 'active' : '' ?>" data-tab="posttype">Post
    77                Type</button>
    8             <button class="tab-btn <?php echo $_GET['tab'] == 'categories' ? 'active' : '' ?>"
     8            <button class="tab-btn <?php echo isset($_GET['tab']) && $_GET['tab'] == 'categories' ? 'active' : '' ?>"
    99                data-tab="categories">Categories</button>
    10             <button class="tab-btn <?php echo $_GET['tab'] == 'sorting' ? 'active' : '' ?>"
     10            <button class="tab-btn <?php echo isset($_GET['tab']) && $_GET['tab'] == 'sorting' ? 'active' : '' ?>"
    1111                data-tab="sorting">Sorting</button>
    12             <button class="tab-btn <?php echo $_GET['tab'] == 'customize' ? 'active' : '' ?>"
     12            <button class="tab-btn <?php echo isset($_GET['tab']) && $_GET['tab'] == 'customize' ? 'active' : '' ?>"
    1313                data-tab="customize">Customize</button>
    14                
     14            <button style="display:<?php echo $slider_type == 'grid' ? 'block' : 'none'; ?>"  class="tab-btn <?php echo isset($_GET['tab']) && $_GET['tab'] == 'template' ? 'active' : '' ?>"
     15                data-tab="template">Template</button>
     16            <?php do_action('pt_slider_admin_more_tabs', $post); ?>
    1517        </nav>
    1618
     
    3739        </section>
    3840
    39         <section class="tab-panel <?php echo $_GET['tab'] == 'posttype' ? 'active' : '' ?>" id="tab-posttype">
     41        <section class="tab-panel <?php echo isset($_GET['tab']) && $_GET['tab'] == 'posttype' ? 'active' : '' ?>" id="tab-posttype">
    4042            <!-- <h2>Post Type</h2> -->
    4143            <table class="form-table">
     
    6163        </section>
    6264
    63         <section class="tab-panel  <?php echo $_GET['tab'] == 'categories' ? 'active' : '' ?>" id="tab-categories">
     65        <section class="tab-panel  <?php echo isset($_GET['tab']) && $_GET['tab'] == 'categories' ? 'active' : '' ?>" id="tab-categories">
    6466            <!-- <h2>Categories</h2> -->
    6567            <table class="form-table">
     
    107109        </section>
    108110
    109         <section class="tab-panel <?php echo $_GET['tab'] == 'sorting' ? 'active' : '' ?>" id="tab-sorting">
     111        <section class="tab-panel <?php echo isset($_GET['tab']) && $_GET['tab'] == 'sorting' ? 'active' : '' ?>" id="tab-sorting">
    110112            <!-- <h2>Sorting</h2> -->
    111113            <table class="form-table">
     
    124126            </table>
    125127        </section>
    126         <section class="tab-panel <?php echo $_GET['tab'] == 'customize' ? 'active' : '' ?>" id="tab-customize">
     128        <section class="tab-panel <?php echo isset($_GET['tab']) && $_GET['tab'] == 'customize' ? 'active' : '' ?>" id="tab-customize">
    127129            <div class="pt-tabs">
    128130                <nav class="tab-nav">
     
    152154                                <td><label><input type="checkbox" name="show_image" <?php echo (!isset($opts['show_image']) || $opts['show_image'] == '1') ? 'checked="checked"' : ''; ?> /> Enable</label></td>
    153155                            </tr>
    154                              <tr>
     156                            <tr>
    155157                                <th>Show Button</th>
    156158                                <td><label><input type="checkbox" name="show_button" <?php echo (!isset($opts['show_button']) || $opts['show_button'] == '1') ? 'checked="checked"' : ''; ?> /> Enable</label></td>
    157159                            </tr>
     160                            <tr style="display:<?php echo $slider_posttype == 'product' ? 'contents': 'none'; ?>;">
     161                                <th>Enable Ajax</th>
     162                                <td><label><input type="checkbox" name="ajax_button" <?php echo (!isset($opts['ajax_button']) || $opts['ajax_button'] == '1') ? 'checked="checked"' : ''; ?> /> Enable</label></td>
     163                            </tr>
     164                           
    158165                            <tr>
    159166                                <th>Show Category</th>
    160                                 <td><label><input type="checkbox" name="show_category" <?php checked('1', $opts['show_category']); ?> /> Enable</label></td>
     167                                <td><label><input type="checkbox" name="show_category" <?php echo (!isset($opts['show_category']) || $opts['show_category'] == '1') ? 'checked="checked"' : ''; ?> /> Enable</label></td>
    161168                            </tr>
    162169                            <tr>
    163170                                <th>Show Date</th>
    164                                 <td><label><input type="checkbox" name="show_date" <?php checked('1', $opts['show_date']); ?> /> Enable</label></td>
     171                                <td><label><input type="checkbox" name="show_date" <?php echo (!isset($opts['show_date']) || $opts['show_date'] == '1') ? 'checked="checked"' : ''; ?> /> Enable</label></td>
    165172                            </tr>
    166173                            <tr>
     
    302309                                </td>
    303310                            </tr>
     311                            <tr>
     312                                <th>Button Text</th>
     313                                <td><input type="text" name="button_text"
     314                                        value="<?php echo !isset($opts['button_text']) ? 'Read More' : esc_attr($opts['button_text']); ?>" />
     315                                </td>
     316                            </tr>
    304317                        </table>
    305318                    </section>
     
    307320            </div>
    308321        </section>
     322        <section class="tab-panel <?php echo isset($_GET['tab']) && $_GET['tab'] == 'template' ? 'active' : '' ?>" id="tab-template">
     323            <h2>Display</h2>
     324            <div class="display_presets">
     325                <div class="layout-options">
     326                    <label class="layout-option">
     327                        <input type="radio" name="grid_layout" value="1" <?php echo $grid_layout == '1' ? 'checked="checked"' : ''; ?>>
     328                        <span class="layout-1">
     329                            <div></div>
     330                        </span>
     331                    </label>
     332
     333                    <label class="layout-option">
     334                        <input type="radio" name="grid_layout" value="2" <?php echo $grid_layout == '2' ? 'checked="checked"' : ''; ?>>
     335                        <span class="layout-2">
     336                            <div></div>
     337                            <div></div>
     338                        </span>
     339                    </label>
     340
     341                    <label class="layout-option">
     342                        <input type="radio" name="grid_layout" value="3" <?php echo $grid_layout == '3' ? 'checked="checked"' : ''; ?>>
     343                        <span class="layout-3">
     344                            <div></div>
     345                            <div></div>
     346                        </span>
     347                    </label>
     348
     349                    <label class="layout-option">
     350                        <input type="radio" name="grid_layout" value="4" <?php echo $grid_layout == '4' ? 'checked="checked"' : ''; ?>>
     351                        <span class="layout-4">
     352                            <div></div>
     353                            <div></div>
     354                        </span>
     355                    </label>
     356
     357                    <label class="layout-option">
     358                        <input type="radio" name="grid_layout" value="5" <?php echo $grid_layout == '5' ? 'checked="checked"' : ''; ?>>
     359                        <span class="layout-5">
     360                            <div></div>
     361                            <div></div>
     362                            <div></div>
     363                        </span>
     364                    </label>
     365
     366                    <label class="layout-option">
     367                        <input type="radio" name="grid_layout" value="6" <?php echo $grid_layout == '6' ? 'checked="checked"' : ''; ?>>
     368                        <span class="layout-6">
     369                            <div></div>
     370                            <div></div>
     371                            <div></div>
     372                            <div></div>
     373                        </span>
     374                    </label>
     375
     376                    <label class="layout-option">
     377                        <input type="radio" name="grid_layout" value="7" <?php echo $grid_layout == '7' ? 'checked="checked"' : ''; ?>>
     378                        <span class="layout-7">
     379                            <div></div>
     380                            <div></div>
     381                            <div></div>
     382                            <div></div>
     383                            <div></div>
     384                        </span>
     385                    </label>
     386
     387                    <label class="layout-option">
     388                        <input type="radio" name="grid_layout" value="8" <?php echo $grid_layout == '8' ? 'checked="checked"' : ''; ?>>
     389                        <span class="layout-8">
     390                            <div></div>
     391                            <div></div>
     392                            <div></div>
     393                        </span>
     394                    </label>
     395                </div>
     396            </div>
     397        </section>
     398        <?php  do_action('pt_slider_admin_more_tab_content', $post); ?>
    309399    </div>
    310400</div>
     
    486576        width: 70% !important;
    487577    }
     578
     579    .layout-options {
     580        display: flex;
     581        flex-wrap: wrap;
     582        gap: 15px;
     583    }
     584
     585    .layout-option {
     586        position: relative;
     587        width: 22%;
     588        height: 100px;
     589        border: 2px solid #00aaff;
     590        display: grid;
     591        cursor: pointer;
     592        transition: 0.2s ease;
     593    }
     594
     595    .layout-option input {
     596        display: none;
     597    }
     598
     599    .layout-option span div {
     600
     601        border: 1px solid #00aaff;
     602    }
     603
     604    .layout-option span {
     605        width: 100%;
     606        height: 100%;
     607        display: grid;
     608    }
     609
     610    .layout-option input:checked+span {
     611        border: 2px solid orange;
     612        box-shadow: 0 0 5px rgba(255, 165, 0, 0.7);
     613    }
     614
     615    /* Different grid styles */
     616    .layout-1 {
     617        grid-template-columns: 1fr;
     618    }
     619
     620    .layout-2 {
     621        grid-template-columns: 1fr 1fr;
     622    }
     623
     624    .layout-3 {
     625        grid-template-columns: 1fr 2fr;
     626    }
     627
     628    .layout-4 {
     629        grid-template-columns: 2fr 1fr;
     630    }
     631
     632    .layout-5 {
     633        grid-template-columns: 1fr 1fr 1fr;
     634    }
     635
     636    .layout-6 {
     637        grid-template-columns: 1fr 1fr 1fr 1fr;
     638    }
     639
     640    .layout-7 {
     641        grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
     642    }
     643
     644    .layout-8 {
     645        grid-template-columns: 1fr 2fr 1fr;
     646    }
    488647</style>
    489648
     
    539698        //     frame.open();
    540699        // });
     700
     701        const value = jQuery("#slider_type").val();
     702        if (value == 'grid') {
     703
     704            jQuery(".horizontal_tabs button[data-tab='template']").fadeIn();
     705        } else {
     706            jQuery(".horizontal_tabs button[data-tab='template']").fadeOut();
     707        }
     708
    541709    });
    542710
  • post-types-slider/trunk/includes/class-post-type-slider-loader.php

    r3284786 r3433570  
    8282    }
    8383
     84    public function add_shortcode( $hook, $component, $callback ) {
     85        $this->filters = $this->add( $this->filters, $hook, $component, $callback, 10, 1 );
     86    }
     87
    8488    /**
    8589     * A utility function that is used to register the actions and hooks into a single
  • post-types-slider/trunk/post-types-slider.php

    r3367949 r3433570  
    1717 * Plugin URI:        https://clickysoft.com
    1818 * Description:       Post Type Slider can easily create responsive sliders from any post type, including posts, pages, or custom post types. It’s perfect for showcasing blog posts, products, portfolios, or featured content with smooth navigation and customizable display options.
    19  * Version:           1.0.5
     19 * Version:           1.0.6
    2020 * Author:            Clickysoft
    2121 * Author URI:        https://clickysoft.com/
     
    2727
    2828// If this file is called directly, abort.
    29 if (! defined('WPINC')) {
     29if (!defined('WPINC')) {
    3030    die;
    3131}
  • post-types-slider/trunk/public/class-post-type-slider-public.php

    r3284786 r3433570  
    103103         wp_enqueue_script('slick-js', plugin_dir_url(__FILE__) . 'js/slick.js', array('jquery'), $this->version, true);
    104104         wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/post-type-slider-public.js', array('jquery', 'slick-js'), $this->version, false);
    105     }
     105         wp_localize_script($this->plugin_name, 'post_handler', ['ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('product_nonce'), 'post_loader'=> plugin_dir_url(__FILE__).'images/loader.gif']);
     106       
     107        }
    106108
    107109    /**
     
    110112     */
    111113
    112     public function post_slider_shortcode($atts)
    113     {
     114    // public function post_slider_shortcode($atts)
     115    // {
    114116
    115         ob_start();
    116         $atts = shortcode_atts(
    117             [
    118                 'id' => 1
    119             ],
    120             $atts,
    121             'ptslider'
    122         );
     117    //  // ob_start();
     118    //  // $atts = shortcode_atts(
     119    //  // [
     120    //  //      'id' => 1
     121    //  // ],
     122    //  // $atts,
     123    //  // 'ptslider'
     124    //  // );
    123125
    124         if ($atts['id']) {
     126    //  // if ($atts['id']) {
    125127
    126             $posts = get_post($atts['id']);
     128    //  //  $posts = get_post($atts['id']);
     129    //  //  var_dump($posts);
    127130
    128         }
     131    //  // }
    129132
    130         ob_end_clean();
    131     }
     133    //  echo "hello woeld";
     134    //  // ob_end_clean();
     135    // }
    132136}
  • post-types-slider/trunk/public/css/post-type-slider-public.css

    r3369600 r3433570  
    4444    color: black;
    4545    font-size: 24px;
    46     line-height: 33px;
     46    line-height: 27px;
    4747    margin: 0 !important;
    4848    padding: 10px 0;
    4949}
    5050
     51
     52/* Common grid wrapper */
     53.post_type_grid {
     54    display: grid !important;
     55    gap: 20px; /* space between cards */
     56}
     57
     58/* Layout styles */
     59.slider_layout1 {
     60    grid-template-columns: 1fr;
     61}
     62
     63.slider_layout2 {
     64    grid-template-columns: 1fr 1fr;
     65}
     66
     67.slider_layout3 {
     68    grid-template-columns: 1fr 2fr;
     69}
     70
     71.slider_layout4 {
     72    grid-template-columns: 2fr 1fr;
     73}
     74
     75.slider_layout5 {
     76    grid-template-columns: 1fr 1fr 1fr;
     77}
     78
     79.slider_layout6 {
     80    grid-template-columns: 1fr 1fr 1fr 1fr;
     81}
     82
     83.slider_layout7 {
     84    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
     85}
     86
     87.slider_layout8 {
     88    grid-template-columns: 1fr 2fr 1fr;
     89}
     90
     91
    5192ul.slick-dots {
    5293    list-style: none;
     
    5495    justify-content: center;
    5596    align-items: center;
    56     gap: 20px;
     97    gap: 15px;
    5798    margin: 14px 0;
    5899}
     
    66107ul.slick-dots li button {
    67108    border: none;
    68     padding: 5px 10px;
     109    padding: 0px 4px;
    69110    color: white !important;
    70111}
     
    76117    gap: 20px;
    77118    /* justify-content: center; */
    78     align-items: center;
    79 }
    80 
     119    align-items: start;
     120}
     121
     122
     123.ajax_add_to_cart img {
     124
     125    width: 20px !important;
     126    height: 20px !important;
     127}
     128
     129.ajax_add_to_cart {
     130    align-items:center;
     131    gap:5px;
     132    display:flex;
     133}
     134
     135
     136
     137p.product_price {
     138    font-size:18px;
     139    color:black;
     140    font-weight:600;
     141}
    81142.post_type_grid .post_slide {
    82     width: 32%;
     143    /* width: 32%; */
     144    width: 100%;
    83145    padding: 10px;
    84146    box-shadow: 0px 2px 6px 2px #d3d3d34d;
  • post-types-slider/trunk/public/js/post-type-slider-public.js

    r3366379 r3433570  
    6464        //  centerMode: true,  // Centers the active slide
    6565        // });
     66
     67        jQuery(document).on("click", ".readmore .ajax_add_to_cart", function (e) {
     68            e.preventDefault();
     69            var $this = jQuery(this);
     70            var id = jQuery(this).data("id");
     71            var loder = post_handler.post_loader;
     72            // console.log(id);
     73            var nonce = post_handler.nonce;
     74            if (id) {
     75                jQuery.ajax({
     76                    type: "POST",
     77                    url: post_handler.ajax_url,
     78                    data: {
     79                        action: 'post_slider_add_to_cart',
     80                        product_id: id,
     81                        nonce: nonce,
     82                        quantity: 1
     83                    },
     84                    beforeSend: function () {
     85                       
     86                        $this.html('Adding <img src="' + loder + '" alt="Loading..." style="width:20px;height:20px;"/>');
     87                        // $this.text("Adding...");
     88                    },
     89                    success: function (response) {
     90
     91                        if (response.success) {
     92
     93                            $this.text("Added");
     94                            setTimeout(() => {
     95                                $this.text("Add to Cart");
     96                            }, 2000);
     97                        }
     98                    },
     99                    complete: function () {
     100
     101                        // Reset flag if re-triggering is allowed after completion
     102                    }
     103                });
     104            }
     105        })
     106
    66107    })
    67108
Note: See TracChangeset for help on using the changeset viewer.