Plugin Directory

Changeset 2061283


Ignore:
Timestamp:
04/02/2019 02:44:35 AM (7 years ago)
Author:
maecompany
Message:

Prepare for release 1.0.5

Location:
advanced-elementor/trunk
Files:
3 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • advanced-elementor/trunk/README.txt

    r2059996 r2061283  
    44Requires at least: 4.0
    55Tested up to: 5.1.1
    6 Stable tag: 1.0.4
     6Stable tag: 1.0.5
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    8585* Renamed plugin to "Advanced Widgets for Elementor"
    8686* Fixed and updated translations POT file.
     87
     88= 1.0.5 =
     89* Advanced Posts: Added "Current Query" source type.
     90* Advanced Posts: Added post type/status/page size settings for "Query" source.
     91* Advanced Posts: Added grid settings (columns number, horizontal/vertical alignment).
     92* Misc under the hood improvements.
  • advanced-elementor/trunk/functions.php

    r2059996 r2061283  
    1111 * Plugin URI:        https://wordpress.org/plugins/awelementor/
    1212 * Description:       Advanced Widgets for Elementor Page Builder.
    13  * Version:           1.0.4
     13 * Version:           1.0.5
    1414 * Author:            Mae Company
    1515 * Author URI:        https://mae.company/
     
    2727 * Current plugin version.
    2828 */
    29 define( 'AWELEMENTOR_VERSION', '1.0.4' );
     29define( 'AWELEMENTOR_VERSION', '1.0.5' );
    3030
    3131/**
  • advanced-elementor/trunk/includes/class-awelementor-elementor.php

    r2059994 r2061283  
    3434     */
    3535    public function __construct() {
    36         $this->add_category('advanced', __( 'Advanced', 'awelementor' ));
    37 
    38         $this->add_control('acf-rows', 'ACF_Rows', [
     36        $control_deps = [
    3937            'Elementor\Controls_Manager',
    4038            'Elementor\Core\DynamicTags\Data_Tag',
    41         ]);
    42 
    43         $common_deps = [
     39        ];
     40        $widget_deps = [
    4441            'Elementor\Widget_Base',
    4542            'Elementor\Element_Base',
    4643        ];
    4744
    48         $this->add_widget('Widget_ACF_Form', ['acf-form.php'], $common_deps);
    49         $this->add_widget('Widget_Advanced_Posts', ['advanced-posts.php'], $common_deps);
     45        $this->add_category('advanced', __( 'Advanced', 'awelementor' ));
    5046
    51 //      $this->add_widget('Widget_Advanced_Icons', ['item-list-base.php', 'icon-list.php'], array_merge($common_deps, [
    52 //          'Widget_Item_List_Base',
    53 //      ]));
    54 //      $this->add_widget('Widget_Image_List', ['item-list-base.php', 'image-list.php'], array_merge($common_deps, [
    55 //          'Widget_Item_List_Base',
    56 //      ]));
     47        $this->add_control('awe-acf-subfield', 'AWElementor_ACF_Subfield', $control_deps);
     48        $this->add_control('awe-post-type', 'AWElementor_Post_Type', $control_deps);
     49        $this->add_control('awe-post-status', 'AWElementor_Post_Status', $control_deps);
     50
     51        $this->add_widget('Widget_ACF_Form', ['acf-form.php'], $widget_deps);
     52        $this->add_widget('Widget_Advanced_Posts', ['advanced-posts.php'], $widget_deps);
    5753    }
    5854
  • advanced-elementor/trunk/includes/widgets/acf-form.php

    r2059388 r2061283  
    237237            [
    238238                'label'         => __( 'Post Type', 'awelementor' ),
    239                 'type'          => Controls_Manager::SELECT,
    240                 'options'       => array_reduce(
    241                     get_post_types([
    242                         'public'    => true,
    243                     ]),
    244                     function($options, $post_type) {
    245                         return $options + [
    246                             $post_type => get_post_type_labels(get_post_type_object($post_type))
    247                                 ->singular_name,
    248                         ];
    249                     },
    250                     []
    251                 ),
    252                 'default'       => 'post',
     239                'type'          => 'awe-post-type',
    253240            ]
    254241        );
     
    258245            [
    259246                'label'         => __( 'Post Status', 'awelementor' ),
    260                 'type'          => Controls_Manager::SELECT,
    261                 'options'       => get_post_stati(),
     247                'type'          => 'awe-post-status',
    262248                'default'       => 'pending',
    263249            ]
  • advanced-elementor/trunk/includes/widgets/advanced-posts.php

    r2059388 r2061283  
    6262    private function get_source_types() {
    6363        $source_types = [
    64             'query' => __( 'Query', 'awelementor' ),
     64            'global_query'  => __( 'Current Query', 'awelementor' ),
     65            'query'         => __( 'Custom Query', 'awelementor' ),
    6566        ];
    6667
     
    100101        ]);
    101102
     103        $this->add_control('query_post_type', [
     104            'label'     => __( 'Post Type', 'awelementor' ),
     105            'type'      => 'awe-post-type',
     106            'condition' => [
     107                'source_type'   => 'query',
     108            ],
     109        ]);
     110        $this->add_control('query_post_status', [
     111            'label'     => __( 'Post Status', 'awelementor' ),
     112            'type'      => 'awe-post-status',
     113            'condition' => [
     114                'source_type'   => 'query',
     115            ],
     116        ]);
     117        $this->add_control('query_posts_per_page', [
     118            'label'     => __( 'Page Size', 'awelementor' ),
     119            'type'      => Controls_Manager::NUMBER,
     120            'default'   => get_option( 'posts_per_page' ),
     121            'condition' => [
     122                'source_type'   => 'query',
     123            ],
     124        ]);
     125
    102126        if ( $this->have_acf() ) {
    103127            $this->add_control('acf_field_key', [
    104128                'label'     => __( 'ACF Field', 'awelementor' ),
    105                 'type'      => 'acf-rows',
     129                'type'      => 'awe-acf-subfield',
    106130                'condition' => [
    107131                    'source_type'   => 'acf',
     
    124148
    125149        $this->end_controls_section();
    126        
     150
     151        $this->start_controls_section('grid_section', [
     152            'label'     => __( 'Grid', 'awelementor' ),
     153            'tab'       => Controls_Manager::TAB_CONTENT,
     154        ]);
     155        $this->add_control('grid_columns', [
     156            'label'     => __( 'Columns', 'awelementor' ),
     157            'type'      => Controls_Manager::SELECT,
     158            'default'   => 1,
     159            'options'   => array_combine(range(1, 12), range(1, 12)),
     160            'selectors' => [
     161                '{{WRAPPER}} > .elementor-widget-container > .awelementor-posts'    => 'grid-template-columns: repeat({{VALUE}}, 1fr);',
     162            ],
     163        ]);
     164        $this->end_controls_section();
     165
    127166        $this->start_controls_section('no_posts_section', [
    128167            'label'     => __( 'No Posts Found', 'awelementor' ),
     
    175214                'groove'    => __( 'Groove', 'awelementor' ),
    176215            ],
     216            'separator' => 'before',
    177217            'selectors' => [
    178218                '{{WRAPPER}} > .elementor-widget-container > .awelementor-posts > .awelementor-post'    => 'border-style: {{VALUE}};',
     
    213253                ],
    214254            ],
     255            'separator'     => 'after',
    215256            'selectors'     => [
    216257                '{{WRAPPER}} > .elementor-widget-container > .awelementor-posts > .awelementor-post'    => 'border-radius: {{SIZE}}{{UNIT}}',
     
    222263            'label'     => __( 'Shadow', 'awelementor' ),
    223264            'selector'  => '{{WRAPPER}} .awelementor-post',
     265        ]);
     266
     267        $this->add_responsive_control('post_halign', [
     268            'label'     => __( 'Horizontal Alignment', 'awelementor' ),
     269            'type'      => Controls_Manager::CHOOSE,
     270            'options'   => [
     271                'start' => [
     272                    'title' => __( 'Left', 'awelementor' ),
     273                    'icon'  => 'fa fa-align-left',
     274                ],
     275                'center'    => [
     276                    'title' => __( 'Center', 'awelementor' ),
     277                    'icon'  => 'fa fa-align-center',
     278                ],
     279                'end'       => [
     280                    'title' => __( 'Right', 'awelementor' ),
     281                    'icon'  => 'fa fa-align-right',
     282                ],
     283//              'stretch'   => [
     284//                  'title' => __( 'Fill', 'awelementor' ),
     285//                  'icon'  => 'fa fa-align-justify',
     286//              ],
     287            ],
     288            'separator' => 'before',
     289            'selectors' => [
     290                '{{WRAPPER}} > .elementor-widget-container > .awelementor-posts > .awelementor-post' => 'justify-self: {{VALUE}}',
     291            ],
     292        ]);
     293       
     294        $this->add_responsive_control('post_valign', [
     295            'label'     => __( 'Vertical Alignment', 'awelementor' ),
     296            'type'      => Controls_Manager::CHOOSE,
     297            'options'   => [
     298                'start' => [
     299                    'title' => __( 'Top', 'awelementor' ),
     300                    'icon'  => 'fa fa-arrow-up',
     301                ],
     302                'center'    => [
     303                    'title' => __( 'Middle', 'awelementor' ),
     304                    'icon'  => 'fa fa-circle',
     305                ],
     306                'end'       => [
     307                    'title' => __( 'Bottom', 'awelementor' ),
     308                    'icon'  => 'fa fa-arrow-down',
     309                ],
     310//              'stretch'   => [
     311//                  'title' => __( 'Fill', 'awelementor' ),
     312//                  'icon'  => 'fa fa-arrows-alt',
     313//              ],
     314            ],
     315            'selectors' => [
     316                '{{WRAPPER}} > .elementor-widget-container > .awelementor-posts > .awelementor-post' => 'align-self: {{VALUE}}',
     317            ],
    224318        ]);
    225319
     
    247341
    248342        switch ( $this->get_settings( 'source_type' ) ) {
     343            case 'global_query':
     344                global $wp_query;
     345                return $wp_query;
     346            case 'query':
     347                $args = [
     348                    'post_type'         => $this->get_settings( 'query_post_type' ),
     349                    'post_status'       => $this->get_settings( 'query_post_status' ),
     350                    'posts_per_page'    => $this->get_settings( 'query_posts_per_page' ),
     351                ];
     352                break;
    249353            case 'acf':
    250354                $acf_field_key = $this->get_settings( 'acf_field_key' );
     355                if (empty($acf_field_key)) {
     356                    break;
     357                }
    251358                $post_ids = [];
    252359                $post_meta = get_post_meta(get_queried_object_id());
     
    258365                $args['post__in'] = empty($post_ids) ? [0] : $post_ids;
    259366                break;
    260             case 'query':
    261                 $args = []; // TODO
    262                 break;
    263         }
    264 
    265         $args['post_status'] = 'publish'; // TODO: configurable
    266         $args['post_type'] = 'any'; // TODO: configurable
     367        }
     368
     369        // This part is not ideal... TODO
     370        if (!isset($args['post_type'])) {
     371            $args['post_type'] = 'any';
     372        }
     373        if (!isset($args['post_status'])) {
     374            $args['post_status'] = 'publish';
     375        }
    267376
    268377        return new \WP_Query($args);
     
    288397        echo $this->get_posts_header();
    289398
    290         /** @var \WP_Query $query */
     399        /* @var \WP_Query $query */
    291400        $query = $this->get_query();
    292401
     
    296405        }
    297406
    298         echo '<div class="awelementor-posts">';
     407        $this->add_render_attribute('awelementor-posts', [
     408            'class' => 'awelementor-posts',
     409            'style' => 'display: grid;',
     410        ]);
     411
     412        echo "<div {$this->get_render_attribute_string('awelementor-posts')}>";
    299413
    300414        if ( $query->in_the_loop ) {
    301415            $this->render_post($template);
    302416        } else {
    303             while ($query->have_posts()) {
     417            while ( $query->have_posts() ) {
    304418                $query->the_post();
    305419                $this->render_post($template);
Note: See TracChangeset for help on using the changeset viewer.