Plugin Directory

Changeset 3451281


Ignore:
Timestamp:
02/01/2026 08:40:56 AM (3 weeks ago)
Author:
ali7ali
Message:

New optional placeholder

Location:
alpha-single-product-for-elementor/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • alpha-single-product-for-elementor/trunk/README.md

    r3276980 r3451281  
    1616**Tags**: single-product, elementor, woocommerce, product, page builder 
    1717**Requires at least**: 6.0 
    18 **Tested up to**: 6.8 
     18**Tested up to**: 6.9 
    1919**Requires PHP**: 7.4 
    20 **Stable tag**: 1.1
     20**Stable tag**: 1.2.0
    2121**License**: GPLv3 
    2222**License URI**: [GPLv3 License](https://www.gnu.org/licenses/gpl-3.0.html)
     
    8888## Upgrade Notice
    8989
     90### 1.2.0
     91- New optional placeholder state so pages don’t appear blank when no product is selected.
     92
    9093### 1.1
    91 
    9294- Compatibility for WP 6.8
  • alpha-single-product-for-elementor/trunk/alpha-single-product-for-elementor.php

    r3276980 r3451281  
    66 * Author:      Ali Ali
    77 * Author URI:  https://github.com/Ali7Ali
    8  * Version:     1.1
     8 * Version:     1.2.0
    99 * Text Domain: alpha-single-product-for-elementor
    1010 * Domain Path: /languages
     
    3636}
    3737
    38 define( 'ALPHASP_VERSION', '1.1' );
     38define( 'ALPHASP_VERSION', '1.2.0' );
    3939define( 'ALPHASP_PLUGIN_FILE', __FILE__ );
    4040define( 'ALPHASP_PLUGIN_URL', plugins_url( '/', ALPHASP_PLUGIN_FILE ) );
     
    5353 * @return void
    5454 */
    55 function alpha_single_product_addon() {
     55function alphasp_single_product_addon() {
    5656    // Load the main plugin class.
    5757    \Elementor_Alpha_Single_Product_Addon\Alpha_Single_Product_For_Elementor::instance();
    5858}
    59 add_action( 'plugins_loaded', 'alpha_single_product_addon' );
     59add_action( 'plugins_loaded', 'alphasp_single_product_addon' );
  • alpha-single-product-for-elementor/trunk/assets/css/alpha-sp-widget.css

    r2932965 r3451281  
    1 .alpha-sp-product{box-sizing:border-box;display:flex;flex:0 1 auto;flex-direction:row;flex-wrap:wrap;width:100%;justify-content:center;}.sp-product-wrapper{position:relative}.sp-product-image{max-width:none!important}.sp-product-action{bottom:15px;left:0;right:0;top:auto;transform:translateY(0);display:flex;flex-direction:row;justify-content:space-between;position:absolute;z-index:9}.sp-product-action .cta-bt,.sp-product-action .elementor-button,.sp-product-action .sp-cart-button{background-color:#00000000}.sp-product-info,.sp-product-info2{max-width: 50%;}.sp-product-action,.sp-product-action2{display: flex; justify-content: space-between;}.sp-cart-button{position:relative}.sp-cart-button a{width:100%}.sp-product-info{position:relative}.sp-cart-button a.added{display:none}
     1.alpha-sp-product{box-sizing:border-box;display:flex;flex:0 1 auto;flex-direction:row;flex-wrap:wrap;width:100%;justify-content:center;}.sp-product-wrapper{position:relative}.sp-product-image{max-width:none!important}.sp-product-action{bottom:15px;left:0;right:0;top:auto;transform:translateY(0);display:flex;flex-direction:row;justify-content:space-between;position:absolute;z-index:9}.sp-product-action .cta-bt,.sp-product-action .elementor-button,.sp-product-action .sp-cart-button{background-color:#00000000}.sp-product-info,.sp-product-info2{max-width: 50%;}.sp-product-action,.sp-product-action2{display: flex; justify-content: space-between;}.sp-cart-button{position:relative}.sp-cart-button a{width:100%}.sp-product-info{position:relative}.sp-cart-button a.added{display:none}.alpha-sp-placeholder{border:1px dashed #c7c7c7;padding:16px;text-align:center;width:100%;display:flex;align-items:center;justify-content:center}.alpha-sp-placeholder .sp-placeholder-message{color:#555;font-size:14px;line-height:1.5;margin:0}
  • alpha-single-product-for-elementor/trunk/include/class-alpha-single-product-widget.php

    r3276980 r3451281  
    9797                'multiple'    => false,
    9898                'options'     => $this->alphasp_post_name( 'product' ),
     99            )
     100        );
     101
     102        $this->add_control(
     103            'show_placeholder',
     104            array(
     105                'label'        => __( 'Placeholder When Empty', 'alpha-single-product-for-elementor' ),
     106                'type'         => Controls_Manager::SWITCHER,
     107                'label_on'     => esc_html__( 'Show', 'alpha-single-product-for-elementor' ),
     108                'label_off'    => esc_html__( 'Hide', 'alpha-single-product-for-elementor' ),
     109                'return_value' => 'yes',
     110                'default'      => 'yes',
     111                'description'  => __( 'Display a placeholder when no product is selected or the product is unavailable.', 'alpha-single-product-for-elementor' ),
     112            )
     113        );
     114
     115        $this->add_control(
     116            'placeholder_text',
     117            array(
     118                'label'       => __( 'Placeholder Message', 'alpha-single-product-for-elementor' ),
     119                'type'        => Controls_Manager::TEXTAREA,
     120                'default'     => __( 'Select a product to display.', 'alpha-single-product-for-elementor' ),
     121                'condition'   => array(
     122                    'show_placeholder' => 'yes',
     123                ),
     124                'rows'        => 3,
     125                'placeholder' => __( 'Select a product to display.', 'alpha-single-product-for-elementor' ),
    99126            )
    100127        );
     
    620647            return $options;
    621648        }
     649
     650        return $options;
    622651    }
    623652
     
    643672        $per_page = 1;
    644673
    645         $cart_action_classes = 'class="sp-cart-button ' . esc_attr( $settings['product_action_button_class'] ) . '"';
     674        $product_id = isset( $settings['alphasp_product_id'] ) ? absint( $settings['alphasp_product_id'] ) : 0;
     675
     676        if ( ! $product_id ) {
     677            $this->render_placeholder( $settings, true );
     678            return;
     679        }
     680
     681        $cart_button_class   = isset( $settings['product_action_button_class'] ) ? $settings['product_action_button_class'] : '';
     682        $cart_action_classes = 'class="sp-cart-button ' . esc_attr( $cart_button_class ) . '"';
    646683
    647684        add_filter(
     
    669706        );
    670707
    671         $args['p'] = $settings['alphasp_product_id'];
     708        $args['p'] = $product_id;
    672709
    673710        // Action Button.
     
    678715        }
    679716
    680         if ( $settings['product_action_button_text'] ) {
     717        if ( ! empty( $settings['product_action_button_text'] ) ) {
    681718            // To change add to cart text on single product page.
    682719            add_filter( 'woocommerce_product_single_add_to_cart_text', array( $this, 'add_to_cart_text' ) );
     
    690727            $products = new \WP_Query( $args );
    691728            if ( $products->have_posts() ) :
    692                 ?>
    693                 <?php
    694729                while ( $products->have_posts() ) :
    695730                    $products->the_post();
     
    708743                            </a>
    709744                        </div>
    710                         <?php if ( 'yes' !== $settings['product_info_location'] ) : ?>
     745                        <?php if ( ! isset( $settings['product_info_location'] ) || 'yes' !== $settings['product_info_location'] ) : ?>
    711746                            <div class="sp-product-action">
    712747                                <div class="sp-product-info">
     
    730765                endwhile;
    731766                wp_reset_postdata();
    732                 ?>
    733             <?php endif; ?>
     767            else :
     768                $this->render_placeholder( $settings, false );
     769            endif;
     770            ?>
    734771        </div>
    735772        <?php
    736773    }
     774
     775    /**
     776     * Render placeholder when no product is selected or available.
     777     *
     778     * @param array $settings      Widget settings.
     779     * @param bool  $with_wrapper  Whether to wrap with the widget container.
     780     * @return void
     781     */
     782    protected function render_placeholder( $settings, $with_wrapper = true ) {
     783        if ( ! isset( $settings['show_placeholder'] ) || 'yes' !== $settings['show_placeholder'] ) {
     784            return;
     785        }
     786
     787        $placeholder_text = ! empty( $settings['placeholder_text'] ) ? $settings['placeholder_text'] : __( 'Select a product to display.', 'alpha-single-product-for-elementor' );
     788        ?>
     789        <div class="<?php echo esc_attr( true === $with_wrapper ? 'alpha-sp-product alpha-sp-placeholder' : 'alpha-sp-placeholder' ); ?>">
     790            <div class="sp-placeholder-message"><?php echo wp_kses_post( $placeholder_text ); ?></div>
     791        </div>
     792        <?php
     793    }
    737794}
  • alpha-single-product-for-elementor/trunk/include/class-alpha-single-product.php

    r3276980 r3451281  
    8181
    8282    /**
    83      * Load the plugin text domain.
    84      */
    85     public function i18n() {
    86         load_plugin_textdomain( 'alpha-single-product-for-elementor', false, ALPHASP_PLUGIN_LANGUAGES );
    87     }
    88 
    89     /**
    9083     * Compatibility Checks
    9184     *
     
    129122     */
    130123    public function init() {
    131 
    132         $this->i18n();
    133 
    134124        add_action( 'elementor/frontend/after_enqueue_styles', array( $this, 'frontend_styles' ) );
    135125        add_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) );
  • alpha-single-product-for-elementor/trunk/languages/alpha-single-product-for-elementor.pot

    r3190431 r3451281  
    1 # Copyright (C) 2024 Ali Ali
     1# Copyright (C) 2026 Ali Ali
    22# This file is distributed under the GPLv3.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Alpha Single Product For Elementor 1.0.6\n"
     5"Project-Id-Version: Alpha Single Product For Elementor 1.2.0\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/alpha-single-product-for-elementor\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2024-11-15T23:27:12+00:00\n"
     12"POT-Creation-Date: 2026-02-01T08:38:24+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.11.0\n"
     
    4040msgstr ""
    4141
    42 #: include/class-alpha-single-product-widget.php:41
     42#: include/class-alpha-single-product-widget.php:44
    4343msgid "Alpha SP Widget"
    4444msgstr ""
     
    5757msgstr ""
    5858
     59#: include/class-alpha-single-product-widget.php:105
     60msgid "Placeholder When Empty"
     61msgstr ""
     62
     63#: include/class-alpha-single-product-widget.php:107
     64msgid "Show"
     65msgstr ""
     66
    5967#: include/class-alpha-single-product-widget.php:108
     68msgid "Hide"
     69msgstr ""
     70
     71#: include/class-alpha-single-product-widget.php:111
     72msgid "Display a placeholder when no product is selected or the product is unavailable."
     73msgstr ""
     74
     75#: include/class-alpha-single-product-widget.php:118
     76msgid "Placeholder Message"
     77msgstr ""
     78
     79#: include/class-alpha-single-product-widget.php:120
     80#: include/class-alpha-single-product-widget.php:125
     81#: include/class-alpha-single-product-widget.php:787
     82msgid "Select a product to display."
     83msgstr ""
     84
     85#: include/class-alpha-single-product-widget.php:135
    6086msgid "Product Settings"
    6187msgstr ""
    6288
    63 #: include/class-alpha-single-product-widget.php:115
     89#: include/class-alpha-single-product-widget.php:142
    6490msgid "Title, Price, and Button Location"
    6591msgstr ""
    6692
    67 #: include/class-alpha-single-product-widget.php:117
     93#: include/class-alpha-single-product-widget.php:144
    6894msgid "Under"
    6995msgstr ""
    7096
    71 #: include/class-alpha-single-product-widget.php:118
     97#: include/class-alpha-single-product-widget.php:145
    7298msgid "Above"
    7399msgstr ""
    74100
    75 #: include/class-alpha-single-product-widget.php:127
     101#: include/class-alpha-single-product-widget.php:154
    76102msgid "Hide Title"
    77103msgstr ""
    78104
    79 #: include/class-alpha-single-product-widget.php:139
     105#: include/class-alpha-single-product-widget.php:166
    80106msgid "Hide Price"
    81107msgstr ""
    82108
    83 #: include/class-alpha-single-product-widget.php:151
     109#: include/class-alpha-single-product-widget.php:178
    84110msgid "Action Button Text"
    85111msgstr ""
    86112
    87 #: include/class-alpha-single-product-widget.php:153
     113#: include/class-alpha-single-product-widget.php:180
    88114msgid "ADD TO CART"
    89115msgstr ""
    90116
    91 #: include/class-alpha-single-product-widget.php:160
     117#: include/class-alpha-single-product-widget.php:187
    92118msgid "Add CSS Class"
    93119msgstr ""
    94120
    95 #: include/class-alpha-single-product-widget.php:168
     121#: include/class-alpha-single-product-widget.php:195
    96122msgid "Product Image Size"
    97123msgstr ""
    98124
    99 #: include/class-alpha-single-product-widget.php:177
     125#: include/class-alpha-single-product-widget.php:204
    100126msgid "Width PX"
    101127msgstr ""
    102128
    103 #: include/class-alpha-single-product-widget.php:191
     129#: include/class-alpha-single-product-widget.php:218
    104130msgid "Height PX"
    105131msgstr ""
    106132
    107 #: include/class-alpha-single-product-widget.php:206
     133#: include/class-alpha-single-product-widget.php:233
    108134msgid "Style"
    109135msgstr ""
    110136
    111 #: include/class-alpha-single-product-widget.php:223
    112 #: include/class-alpha-single-product-widget.php:476
     137#: include/class-alpha-single-product-widget.php:250
     138#: include/class-alpha-single-product-widget.php:508
    113139msgid "Border Radius"
    114140msgstr ""
    115141
    116 #: include/class-alpha-single-product-widget.php:243
    117 #: include/class-alpha-single-product-widget.php:496
    118 #: include/class-alpha-single-product-widget.php:581
     142#: include/class-alpha-single-product-widget.php:270
     143#: include/class-alpha-single-product-widget.php:528
     144#: include/class-alpha-single-product-widget.php:613
    119145msgid "Border Color"
    120146msgstr ""
    121147
    122 #: include/class-alpha-single-product-widget.php:255
     148#: include/class-alpha-single-product-widget.php:282
    123149msgid "Padding"
    124150msgstr ""
    125151
    126 #: include/class-alpha-single-product-widget.php:267
    127 #: include/class-alpha-single-product-widget.php:324
    128 #: include/class-alpha-single-product-widget.php:377
     152#: include/class-alpha-single-product-widget.php:294
     153#: include/class-alpha-single-product-widget.php:353
     154#: include/class-alpha-single-product-widget.php:408
    129155msgid "Margin"
    130156msgstr ""
    131157
    132 #: include/class-alpha-single-product-widget.php:280
     158#: include/class-alpha-single-product-widget.php:307
    133159msgid "Product Title"
    134160msgstr ""
    135161
    136 #: include/class-alpha-single-product-widget.php:298
     162#: include/class-alpha-single-product-widget.php:327
    137163msgid "Title Color"
    138164msgstr ""
    139165
    140 #: include/class-alpha-single-product-widget.php:311
     166#: include/class-alpha-single-product-widget.php:340
    141167msgid "Title Hover Color"
    142168msgstr ""
    143169
    144 #: include/class-alpha-single-product-widget.php:346
     170#: include/class-alpha-single-product-widget.php:375
    145171msgid "Product Price"
    146172msgstr ""
    147173
    148 #: include/class-alpha-single-product-widget.php:355
     174#: include/class-alpha-single-product-widget.php:384
    149175msgid "Price Color"
    150176msgstr ""
    151177
    152 #: include/class-alpha-single-product-widget.php:401
     178#: include/class-alpha-single-product-widget.php:432
    153179msgid "Action Button Style"
    154180msgstr ""
    155181
    156 #: include/class-alpha-single-product-widget.php:409
     182#: include/class-alpha-single-product-widget.php:440
    157183msgid "Button"
    158184msgstr ""
    159185
    160 #: include/class-alpha-single-product-widget.php:423
     186#: include/class-alpha-single-product-widget.php:454
    161187msgid "Normal"
    162188msgstr ""
    163189
    164 #: include/class-alpha-single-product-widget.php:430
    165 #: include/class-alpha-single-product-widget.php:557
     190#: include/class-alpha-single-product-widget.php:461
     191#: include/class-alpha-single-product-widget.php:589
    166192msgid "Text Color"
    167193msgstr ""
    168194
    169 #: include/class-alpha-single-product-widget.php:451
    170 #: include/class-alpha-single-product-widget.php:569
     195#: include/class-alpha-single-product-widget.php:484
     196#: include/class-alpha-single-product-widget.php:601
    171197msgid "Background Color"
    172198msgstr ""
    173199
    174 #: include/class-alpha-single-product-widget.php:508
     200#: include/class-alpha-single-product-widget.php:540
    175201msgid "Button Padding"
    176202msgstr ""
    177203
    178 #: include/class-alpha-single-product-widget.php:528
     204#: include/class-alpha-single-product-widget.php:560
    179205msgid "Button Margin"
    180206msgstr ""
    181207
    182 #: include/class-alpha-single-product-widget.php:550
     208#: include/class-alpha-single-product-widget.php:582
    183209msgid "Hover"
    184210msgstr ""
    185211
    186 #: include/class-alpha-single-product-widget.php:604
     212#: include/class-alpha-single-product-widget.php:635
    187213msgid "Select"
    188214msgstr ""
    189215
    190 #: include/class-alpha-single-product-widget.php:624
     216#: include/class-alpha-single-product-widget.php:658
    191217msgid "Add to Cart"
    192218msgstr ""
    193219
    194 #: include/class-alpha-single-product-widget.php:651
    195 #: include/class-alpha-single-product.php:144
     220#: include/class-alpha-single-product-widget.php:693
     221#: include/class-alpha-single-product.php:136
    196222msgid "Go to cart"
    197223msgstr ""
    198224
    199225#. translators: 1: Plugin name 2: Elementor
    200 #: include/class-alpha-single-product.php:163
    201 #: include/class-alpha-single-product.php:199
     226#. translators: 1: Plugin name 2: WooCommerce
     227#: include/class-alpha-single-product.php:155
     228#: include/class-alpha-single-product.php:219
    202229msgid "\"%1$s\" requires \"%2$s\" to be installed and activated."
    203230msgstr ""
    204231
    205 #: include/class-alpha-single-product.php:164
    206 #: include/class-alpha-single-product.php:200
    207 #: include/class-alpha-single-product.php:236
    208 #: include/class-alpha-single-product.php:258
     232#: include/class-alpha-single-product.php:156
     233#: include/class-alpha-single-product.php:220
     234#: include/class-alpha-single-product.php:284
     235#: include/class-alpha-single-product.php:317
    209236msgid "Alpha Single Product Widget for Elementor"
    210237msgstr ""
    211238
    212 #: include/class-alpha-single-product.php:165
    213 #: include/class-alpha-single-product.php:237
     239#: include/class-alpha-single-product.php:157
     240#: include/class-alpha-single-product.php:285
    214241msgid "Elementor"
    215242msgstr ""
    216243
    217 #: include/class-alpha-single-product.php:174
     244#: include/class-alpha-single-product.php:170
    218245msgid "Activate Elementor"
    219246msgstr ""
     
    223250msgstr ""
    224251
    225 #: include/class-alpha-single-product.php:201
     252#: include/class-alpha-single-product.php:221
    226253msgid "WooCommerce"
    227254msgstr ""
    228255
    229 #: include/class-alpha-single-product.php:210
     256#: include/class-alpha-single-product.php:234
    230257msgid "Activate WooCommerce"
    231258msgstr ""
    232259
    233 #: include/class-alpha-single-product.php:213
     260#: include/class-alpha-single-product.php:241
    234261msgid "Install WooCommerce"
    235262msgstr ""
    236263
    237 #. translators: 1: Plugin name 2: Elementor 3: Required Elementor version
    238 #: include/class-alpha-single-product.php:235
     264#. translators: 1: Plugin name, 2: Elementor, 3: Required Elementor version
     265#: include/class-alpha-single-product.php:283
    239266msgid "\"%1$s\" requires the \"%2$s\" plugin version %3$s or greater."
    240267msgstr ""
    241268
    242 #. translators: 1: Plugin name 2: PHP 3: Required PHP version
    243 #: include/class-alpha-single-product.php:257
     269#. translators: 1: Plugin name, 2: PHP, 3: Required PHP version
     270#: include/class-alpha-single-product.php:316
    244271msgid "\"%1$s\" requires \"%2$s\" version %3$s or greater."
    245272msgstr ""
    246273
    247 #: include/class-alpha-single-product.php:259
     274#: include/class-alpha-single-product.php:318
    248275msgid "PHP"
    249276msgstr ""
  • alpha-single-product-for-elementor/trunk/readme.txt

    r3276980 r3451281  
    44Tags: single-product, elementor,  woocommerce, product, page builder
    55Requires at least: 6.0
    6 Tested up to: 6.8
     6Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 1.1
     8Stable tag: 1.2.0
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    5757== Upgrade Notice ==
    5858
     59= 1.2.0 =
     60* Optional placeholder state so pages don’t appear blank when no product is selected.
     61
    5962= 1.1 =
    6063* Compatibility for WP 6.8
Note: See TracChangeset for help on using the changeset viewer.