Plugin Directory

Changeset 3297135


Ignore:
Timestamp:
05/20/2025 09:12:57 AM (11 months ago)
Author:
website366
Message:

# cập nhật 2.4

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

Legend:

Unmodified
Added
Removed
  • wpshare247-elementor-addons/trunk/assets/css/styles.css

    r2856412 r3297135  
    11.elementor-section .elementor-container.wpshare247-flex-wrap{
    22    flex-wrap: wrap;
     3}
     4.elementor-container.wpshare247-flex-wrap{
     5    display: flex;
     6    flex-wrap: wrap;
    37}
    48
  • wpshare247-elementor-addons/trunk/inc/helper.php

    r3297038 r3297135  
    1111
    1212    static function get_public_post_type(){
     13        $args = [];
    1314        $objects = get_post_types( $args, 'objects' );
    1415        if(!$objects) return array();
     
    3233                $arr_labels = $object->labels;
    3334                $arr[$type] = esc_html__( $arr_labels->singular_name, 'wpshare247-elementor-addon' );
     35            }
     36            return $arr;
     37        }
     38    }
     39
     40
     41    static function get_public_terms_by_post_type(){
     42        $post_types = self::get_public_post_type();
     43        $arr = [];
     44        if($post_types){
     45            foreach( $post_types as $post_type => $object ) {
     46                $taxonomies = get_object_taxonomies($post_type, 'objects');
     47                if (!empty($taxonomies)) {
     48                    foreach ($taxonomies as $taxonomy_slug => $taxonomy_obj) {
     49                        $arr[$taxonomy_slug] = $taxonomy_obj->labels->name;
     50                    }
     51                }
     52            }
     53        }
     54        return $arr;
     55    }
     56
     57    static function get_terms_options(){
     58        $arr = self::get_public_terms_by_post_type();
     59        if(empty($arr)){
     60            $arr[''] = esc_html__( 'Not found', 'wpshare247-elementor-addon' );
     61            return $arr;
     62        }else{
     63            foreach( $arr as $post_type => $tax_slug ) {
     64                $arr[$tax_slug] = esc_html__( $tax_slug, 'wpshare247-elementor-addon' );
    3465            }
    3566            return $arr;
  • wpshare247-elementor-addons/trunk/includes/widgets/wpshare247_posts_widget.php

    r3297038 r3297135  
    3131                'default' => 'post',
    3232                'options' => Ws247_EA_Helper::get_post_type_options()
     33            ]
     34        );
     35
     36        /*
     37        $this->add_control(
     38            'post_type_term',
     39            [
     40                'label' => esc_html__( 'Terms', 'elementor' ),
     41                'type' => \Elementor\Controls_Manager::SELECT,
     42                'default' => '',
     43                'options' => Ws247_EA_Helper::get_terms_options()
     44            ]
     45        );
     46        */
     47
     48        $this->add_control(
     49            'post_type_category',
     50            [
     51                'label' => esc_html__( 'Categories', 'elementor' ),
     52                'show_label' => true,
     53                'type' => \Elementor\Controls_Manager::SELECT2,
     54                'label_block' => true,
     55                'multiple' => true,
     56                'options' => Ws247_EA_Helper::get_term_options('category'),
     57                'default' => [],
     58                'condition' => [
     59                    'post_type' => 'post',
     60                ],
     61            ]
     62        );
     63
     64        $this->add_control(
     65            'post_type_tags',
     66            [
     67                'label' => esc_html__( 'Tag', 'elementor' ),
     68                'show_label' => true,
     69                'type' => \Elementor\Controls_Manager::SELECT2,
     70                'label_block' => true,
     71                'multiple' => true,
     72                'options' => Ws247_EA_Helper::get_term_options('post_tag'),
     73                'default' => [],
     74                'condition' => [
     75                    'post_type' => 'post',
     76                ],
    3377            ]
    3478        );
     
    11381182        $settings = $this->get_settings_for_display();
    11391183       
    1140         $post_type = $settings['post_type'];
     1184        $post_type = $settings['post_type']; 
    11411185        $post_per_page = $settings['post_per_page'];
    11421186        $slider_on = ($settings['slider_on']==='yes') ? true : false;
     
    11521196            'order'                => $order
    11531197        );
     1198
     1199       
     1200        if ( $post_type === 'post' ) {
     1201            $post_type_category = $settings['post_type_category'];
     1202            $post_type_tags = $settings['post_type_tags'];
     1203
     1204            $tax_query = array('relation' => 'AND');
     1205
     1206            if ( !empty($post_type_category) ) {
     1207                $tax_query[] = array(
     1208                    'taxonomy' => 'category',
     1209                    'field'    => 'slug',
     1210                    'terms'    => $post_type_category,
     1211                );
     1212            }
     1213
     1214            if ( !empty($post_type_tags) ) {
     1215                $tax_query[] = array(
     1216                    'taxonomy' => 'post_tag',
     1217                    'field'    => 'slug',
     1218                    'terms'    => $post_type_tags,
     1219                );
     1220            }
     1221
     1222            if ( count($tax_query) > 1 ) {
     1223                $args_filter['tax_query'] = $tax_query;
     1224            }
     1225        }
     1226       
     1227
    11541228        $the_query = new WP_query($args_filter);
    11551229
  • wpshare247-elementor-addons/trunk/readme.txt

    r3297048 r3297135  
    66Tested up to: 6.6.1
    77Requires PHP: 7.0
    8 Stable tag: 2.3
     8Stable tag: 2.4
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9696*  Fix: Missing file 2.2
    9797
     98= 2.4 =
     99* Filter post by category, tags
     100* Fix css: wpshare247-flex-wrap, display: flex;
     101
    98102
    99103== Upgrade Notice ==
  • wpshare247-elementor-addons/trunk/wpshare247-elementor-addon.php

    r3297048 r3297135  
    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.3
     6 * Version: 2.4
    77 * Author: Wpshare247.com
    88 * Author URI: https://wpshare247.com/chuyen-muc/elementor
Note: See TracChangeset for help on using the changeset viewer.