Changeset 2061283
- Timestamp:
- 04/02/2019 02:44:35 AM (7 years ago)
- Location:
- advanced-elementor/trunk
- Files:
-
- 3 added
- 1 deleted
- 5 edited
-
README.txt (modified) (2 diffs)
-
functions.php (modified) (2 diffs)
-
includes/class-awelementor-elementor.php (modified) (1 diff)
-
includes/controls/acf-rows.php (deleted)
-
includes/controls/awe-acf-subfield.php (added)
-
includes/controls/awe-post-status.php (added)
-
includes/controls/awe-post-type.php (added)
-
includes/widgets/acf-form.php (modified) (2 diffs)
-
includes/widgets/advanced-posts.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
advanced-elementor/trunk/README.txt
r2059996 r2061283 4 4 Requires at least: 4.0 5 5 Tested up to: 5.1.1 6 Stable tag: 1.0. 46 Stable tag: 1.0.5 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 85 85 * Renamed plugin to "Advanced Widgets for Elementor" 86 86 * 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 11 11 * Plugin URI: https://wordpress.org/plugins/awelementor/ 12 12 * Description: Advanced Widgets for Elementor Page Builder. 13 * Version: 1.0. 413 * Version: 1.0.5 14 14 * Author: Mae Company 15 15 * Author URI: https://mae.company/ … … 27 27 * Current plugin version. 28 28 */ 29 define( 'AWELEMENTOR_VERSION', '1.0. 4' );29 define( 'AWELEMENTOR_VERSION', '1.0.5' ); 30 30 31 31 /** -
advanced-elementor/trunk/includes/class-awelementor-elementor.php
r2059994 r2061283 34 34 */ 35 35 public function __construct() { 36 $this->add_category('advanced', __( 'Advanced', 'awelementor' )); 37 38 $this->add_control('acf-rows', 'ACF_Rows', [ 36 $control_deps = [ 39 37 'Elementor\Controls_Manager', 40 38 'Elementor\Core\DynamicTags\Data_Tag', 41 ]); 42 43 $common_deps = [ 39 ]; 40 $widget_deps = [ 44 41 'Elementor\Widget_Base', 45 42 'Elementor\Element_Base', 46 43 ]; 47 44 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' )); 50 46 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); 57 53 } 58 54 -
advanced-elementor/trunk/includes/widgets/acf-form.php
r2059388 r2061283 237 237 [ 238 238 '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', 253 240 ] 254 241 ); … … 258 245 [ 259 246 'label' => __( 'Post Status', 'awelementor' ), 260 'type' => Controls_Manager::SELECT, 261 'options' => get_post_stati(), 247 'type' => 'awe-post-status', 262 248 'default' => 'pending', 263 249 ] -
advanced-elementor/trunk/includes/widgets/advanced-posts.php
r2059388 r2061283 62 62 private function get_source_types() { 63 63 $source_types = [ 64 'query' => __( 'Query', 'awelementor' ), 64 'global_query' => __( 'Current Query', 'awelementor' ), 65 'query' => __( 'Custom Query', 'awelementor' ), 65 66 ]; 66 67 … … 100 101 ]); 101 102 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 102 126 if ( $this->have_acf() ) { 103 127 $this->add_control('acf_field_key', [ 104 128 'label' => __( 'ACF Field', 'awelementor' ), 105 'type' => 'a cf-rows',129 'type' => 'awe-acf-subfield', 106 130 'condition' => [ 107 131 'source_type' => 'acf', … … 124 148 125 149 $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 127 166 $this->start_controls_section('no_posts_section', [ 128 167 'label' => __( 'No Posts Found', 'awelementor' ), … … 175 214 'groove' => __( 'Groove', 'awelementor' ), 176 215 ], 216 'separator' => 'before', 177 217 'selectors' => [ 178 218 '{{WRAPPER}} > .elementor-widget-container > .awelementor-posts > .awelementor-post' => 'border-style: {{VALUE}};', … … 213 253 ], 214 254 ], 255 'separator' => 'after', 215 256 'selectors' => [ 216 257 '{{WRAPPER}} > .elementor-widget-container > .awelementor-posts > .awelementor-post' => 'border-radius: {{SIZE}}{{UNIT}}', … … 222 263 'label' => __( 'Shadow', 'awelementor' ), 223 264 '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 ], 224 318 ]); 225 319 … … 247 341 248 342 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; 249 353 case 'acf': 250 354 $acf_field_key = $this->get_settings( 'acf_field_key' ); 355 if (empty($acf_field_key)) { 356 break; 357 } 251 358 $post_ids = []; 252 359 $post_meta = get_post_meta(get_queried_object_id()); … … 258 365 $args['post__in'] = empty($post_ids) ? [0] : $post_ids; 259 366 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 } 267 376 268 377 return new \WP_Query($args); … … 288 397 echo $this->get_posts_header(); 289 398 290 /* *@var \WP_Query $query */399 /* @var \WP_Query $query */ 291 400 $query = $this->get_query(); 292 401 … … 296 405 } 297 406 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')}>"; 299 413 300 414 if ( $query->in_the_loop ) { 301 415 $this->render_post($template); 302 416 } else { 303 while ( $query->have_posts()) {417 while ( $query->have_posts() ) { 304 418 $query->the_post(); 305 419 $this->render_post($template);
Note: See TracChangeset
for help on using the changeset viewer.