Plugin Directory

Changeset 3297038


Ignore:
Timestamp:
05/20/2025 06:34:00 AM (11 months ago)
Author:
website366
Message:

# Cập nhật 2.2

Location:
wpshare247-elementor-addons/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • wpshare247-elementor-addons/trunk/inc/helper.php

    r3137039 r3297038  
    3636        }
    3737    }
    38 
    3938
    4039    static function get_post_types( $post_type = 'page' ){
  • wpshare247-elementor-addons/trunk/inc/woocommerce.php

    r3137039 r3297038  
    3434    }
    3535
    36     static function get_product(){
     36    static function get_session_product(){
    3737        $ea_product_id = $_SESSION['ea_product_id'];
    3838        $product = wc_get_product( $ea_product_id );
     39        return $product;
     40    }
     41
     42    static function get_product(){
     43        global $product;
     44
     45        if( !is_object($product) ){
     46            $product = self::get_session_product();
     47        }
     48
    3949        return $product;
    4050    }
  • wpshare247-elementor-addons/trunk/includes/plugin.php

    r3137039 r3297038  
    227227     *
    228228     * @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
    229      */
    230     public function register_widgets( $widgets_manager ) {
    231 
    232         $arr_widgets = array(
    233                             'wpshare247_posts_widget',
    234                             'wpshare247_products_widget',
    235                             'wpshare247_product_categories_widget',
    236                             'wpshare247_contact_form7',
    237                             'wpshare247_countdown',
    238                             'wpshare247_product_single_price_widget'
    239                             //'wpshare247_new_widget'
    240                         );
    241 
    242         if($arr_widgets){
    243             foreach ($arr_widgets as $widget) {
    244                 require_once( __DIR__ . '/widgets/'.$widget.'.php' );
    245                 $widgets_manager->register( new $widget() );
     229     *
     230     * add_filter( 'wpshare247_el_addons_custom_widgets', function( $widgets ) {
     231            $widgets[] = [
     232                'file'  => get_stylesheet_directory() . '/my-widgets/my-widget.php',
     233                'class' => 'My_Custom_Widget',
     234            ];
     235            return $widgets;
     236        });
     237     */
     238    public function register_widgets( $widgets_manager ) {
     239        $default_widgets = array(
     240            'wpshare247_posts_widget',
     241            'wpshare247_products_widget',
     242            'wpshare247_product_categories_widget',
     243            'wpshare247_contact_form7',
     244            'wpshare247_countdown',
     245            'wpshare247_product_single_price_widget'
     246        );
     247
     248        $custom_widgets = apply_filters( 'wpshare247_el_addons_custom_widgets', $default_widgets );
     249
     250        foreach ( $custom_widgets as $widget ) {
     251            if ( is_string( $widget ) ) {
     252                $file_path = __DIR__ . '/widgets/' . $widget . '.php';
     253                $class_name = $widget;
     254            }
     255            elseif ( is_array( $widget ) && isset( $widget['file'] ) && isset( $widget['class'] ) ) {
     256                $file_path = $widget['file'];
     257                $class_name = $widget['class'];
     258            } else {
     259                continue;
     260            }
     261
     262            if ( file_exists( $file_path ) ) {
     263                require_once $file_path;
     264
     265                if ( class_exists( $class_name ) ) {
     266                    $widgets_manager->register( new $class_name() );
     267                }
    246268            }
    247269        }
  • wpshare247-elementor-addons/trunk/includes/widgets/wpshare247_posts_widget.php

    r2851642 r3297038  
    578578                        'name' => 'title_style_typography',
    579579                        'selector' => '{{WRAPPER}} .title a',
     580                    ]
     581                );
     582
     583                $this->add_control(
     584                    'title_style_custom',
     585                    [
     586                        'label' => esc_html__( 'Custom', 'elementor' ) . ' '.esc_html__( 'Show', 'elementor' ),
     587                        'type' => \Elementor\Controls_Manager::SWITCHER,
     588                        'label_on' => esc_html__( 'Show', 'elementor' ),
     589                        'label_off' => esc_html__( 'Off', 'elementor' ),
     590                        'return_value' => 'yes',
     591                        'default' => '',
     592                    ]
     593                );
     594
     595                $this->add_control(
     596                    'title_style_custom_line',
     597                    [
     598                        'label' => esc_html__( 'Line', 'elementor' ),
     599                        'type' => \Elementor\Controls_Manager::SLIDER,
     600                        'size_units' => [],
     601                        'range' => [
     602                            'px' => [
     603                                'min' => 1,
     604                                'max' => 5,
     605                                'step' => 1,
     606                            ],
     607                        ],
     608                        'default' => [
     609                            'size' => 2,
     610                        ],
     611                        'selectors' => [
     612                            '{{WRAPPER}} .title a' => 'text-overflow: ellipsis; overflow: hidden; display: -webkit-box; -webkit-line-clamp: {{SIZE}}; -webkit-box-orient: vertical;',
     613                        ],
     614                        'condition' => [
     615                            'title_style_custom' => 'yes',
     616                        ],
     617                    ]
     618                );
     619
     620
     621                $this->add_control(
     622                    'title_style_custom_height',
     623                    [
     624                        'label' => esc_html__( 'Height', 'elementor' ),
     625                        'type' => \Elementor\Controls_Manager::SLIDER,
     626                        'size_units' => [ 'px' ],
     627                        'range' => [
     628                            'px' => [
     629                                'min' => 20,
     630                                'max' => 200,
     631                                'step' => 1,
     632                            ]
     633                        ],
     634                        'default' => [
     635                            'unit' => 'px',
     636                            'size' => 30,
     637                        ],
     638                        'selectors' => [
     639                            '{{WRAPPER}} .title a' => 'height: {{SIZE}}{{UNIT}}; max-height: {{SIZE}}{{UNIT}};',
     640                        ],
     641                        'condition' => [
     642                            'title_style_custom' => 'yes',
     643                        ],
    580644                    ]
    581645                );
  • wpshare247-elementor-addons/trunk/includes/widgets/wpshare247_product_single_price_widget.php

    r3137042 r3297038  
    353353        $diff_price_text = isset($settings['diff_price_text']) ? $settings['diff_price_text'] : 'Tiết kiệm:';
    354354
    355         global $product;
    356 
    357         if( !is_object($product) ){
    358             $product = Ws247_EA_Woocommerce::get_product();
    359         }
     355        $product = Ws247_EA_Woocommerce::get_product();
    360356
    361357        if( is_object($product) ):
  • wpshare247-elementor-addons/trunk/readme.txt

    r3137041 r3297038  
    66Tested up to: 6.6.1
    77Requires PHP: 7.0
    8 Stable tag: 2.1
     8Stable tag: 2.2
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2424Wordpress Share - Học wordpress: [wpshare247.com](https://wpshare247.com)
    2525Web Content - Viết bài chăm sóc web: [vietbaigiare.com](http://vietbaigiare.com)
     26
     27**Cách dùng filter thêm Custom Widget - How to use custom Widget**
     281. Copy folder `wpshare247-custom-widgets` from the plugin path: 
     29   `wpshare247-elementor-addons/your-custom-sample/wpshare247-custom-widgets` 
     30   into your current theme folder, like: 
     31   `wp-content/themes/your-theme/wpshare247-custom-widgets`
     32
     332. Inside that folder, you will find `wpshare247_my_custom.php`. 
     34   This is a sample widget file. You can use it directly, or duplicate and create more widget files.
     35
     363. In your theme's `functions.php`, add the following code to register custom widgets:
     37
     38```php
     39add_filter( 'wpshare247_el_addons_custom_widgets', function( $widgets ) {
     40    $widgets[] = [
     41        'file'  => get_stylesheet_directory() . '/wpshare247-custom-widgets/wpshare247_my_custom.php',
     42        'class' => 'Wpshare247_My_Custom',
     43    ];
     44
     45    /*
     46    // Example: Add more widgets if needed
     47    $widgets[] = [
     48        'file'  => get_stylesheet_directory() . '/wpshare247-custom-widgets/wpshare247_my_custom_new1.php',
     49        'class' => 'Wpshare247_My_Custom_New1',
     50    ];
     51    */
     52
     53    return $widgets;
     54});
     55
     56
    2657
    2758== Installation ==
     
    5687*  Add new widget: Product price
    5788
     89= 2.2 =
     90
     91* Enhanced `wpshare247_posts_widget`: Added custom title styling options including line-clamp control (number of lines) and height adjustment via Elementor controls.
     92* Introduced new filter hook `wpshare247_el_addons_custom_widgets` allowing developers to register additional widgets from theme or other plugins with custom widget class and path.
     93** How to use: Copy folder `wpshare247-custom-widgets` in plugin: wpshare247-elementor-addons/your-custom-sample/wpshare247-custom-widgets to your-theme/wpshare247-custom-widgets
     94
    5895
    5996== Upgrade Notice ==
  • wpshare247-elementor-addons/trunk/wpshare247-elementor-addon.php

    r3137039 r3297038  
    44 * Plugin URI: https://wpshare247.com/
    55 * Description: Widgets (Wpshare247 Addons) for Elementor. Wpshare247 Addons for Elementor plugin includes widgets and addons like Blog Post, Products, Post, Page and Custom Post Type Grid or Carousel, Countdown, Contact Form 7, WooCommerce Product Price.
    6  * Version: 2.1
     6 * Version: 2.2
    77 * Author: Wpshare247.com
    88 * Author URI: https://wpshare247.com/chuyen-muc/elementor
     
    2727        require_once( __DIR__ . '/inc/woocommerce.php' );
    2828    }
    29 
    3029    // Load plugin file
    3130    require_once( __DIR__ . '/includes/plugin.php' );
Note: See TracChangeset for help on using the changeset viewer.