Fix collection widgets.

This commit is contained in:
Hoang Huu 2019-10-17 10:45:12 +07:00
parent b55d26fcb2
commit e604069ef5
6 changed files with 387 additions and 527 deletions

View File

@ -32,10 +32,10 @@ class Opalestate_Agency_Collection_Elementor_Widget extends Opalestate_Elementor
* *
* Used to set scripts dependencies required to run the widget. * Used to set scripts dependencies required to run the widget.
* *
* @return array Widget scripts dependencies.
* @since 1.3.0 * @since 1.3.0
* @access public * @access public
* *
* @return array Widget scripts dependencies.
*/ */
public function get_script_depends() { public function get_script_depends() {
return [ 'jquery-slick' ]; return [ 'jquery-slick' ];
@ -95,18 +95,18 @@ class Opalestate_Agency_Collection_Elementor_Widget extends Opalestate_Elementor
] ]
); );
$this->add_control( // $this->add_control(
'search_form', // 'search_form',
[ // [
'label' => esc_html__('Search Form', 'opalestate-pro'), // 'label' => esc_html__('Search Form', 'opalestate-pro'),
'type' => \Elementor\Controls_Manager::SELECT, // 'type' => \Elementor\Controls_Manager::SELECT,
'default' => '', // 'default' => '',
'options' => array( // 'options' => array(
'' => esc_html__( 'Advanded', 'opalestate-pro' ), // '' => esc_html__( 'Advanded', 'opalestate-pro' ),
'address' => esc_html__( 'Search By Address', 'opalestate-pro' ), // 'address' => esc_html__( 'Search By Address', 'opalestate-pro' ),
) // )
] // ]
); // );
$this->add_control( $this->add_control(
'enable_sortable_bar', 'enable_sortable_bar',
@ -122,10 +122,10 @@ class Opalestate_Agency_Collection_Elementor_Widget extends Opalestate_Elementor
'label' => esc_html__( 'Item Layout', 'opalestate-pro' ), 'label' => esc_html__( 'Item Layout', 'opalestate-pro' ),
'type' => \Elementor\Controls_Manager::SELECT, 'type' => \Elementor\Controls_Manager::SELECT,
'default' => 'grid', 'default' => 'grid',
'options' => array( 'options' => [
'grid' => esc_html__( 'Grid', 'opalestate-pro' ), 'grid' => esc_html__( 'Grid', 'opalestate-pro' ),
'list' => esc_html__( 'List', 'opalestate-pro' ), 'list' => esc_html__( 'List', 'opalestate-pro' ),
) ],
] ]
); );
$this->add_responsive_control( $this->add_responsive_control(
@ -137,8 +137,8 @@ class Opalestate_Agency_Collection_Elementor_Widget extends Opalestate_Elementor
'options' => [ 1 => 1, 2 => 2, 3 => 3, 4 => 4, 6 => 6 ], 'options' => [ 1 => 1, 2 => 2, 3 => 3, 4 => 4, 6 => 6 ],
'prefix_class' => 'elementor-grid%s-', 'prefix_class' => 'elementor-grid%s-',
'condition' => [ 'condition' => [
'item_layout' => 'grid' 'item_layout' => 'grid',
] ],
] ]
); );
@ -156,12 +156,12 @@ class Opalestate_Agency_Collection_Elementor_Widget extends Opalestate_Elementor
], ],
], ],
'selectors' => [ 'selectors' => [
'{{WRAPPER}} .elementor-items-container' => 'grid-column-gap: {{SIZE}}{{UNIT}}' '{{WRAPPER}} .elementor-items-container' => 'grid-column-gap: {{SIZE}}{{UNIT}}',
], ],
'condition' => [ 'condition' => [
'item_layout' => 'grid' 'item_layout' => 'grid',
] ],
] ]
); );
@ -174,7 +174,7 @@ class Opalestate_Agency_Collection_Elementor_Widget extends Opalestate_Elementor
); );
$this->end_controls_section(); $this->end_controls_section();
$this->add_slick_controls( array('enable_carousel' => 'yes') , ' .agency-slick-carousel ' ); $this->add_slick_controls( [ 'enable_carousel' => 'yes' ], ' .agency-slick-carousel ' );
$this->start_controls_section( $this->start_controls_section(
'section_query', 'section_query',
@ -194,7 +194,6 @@ class Opalestate_Agency_Collection_Elementor_Widget extends Opalestate_Elementor
); );
$this->add_control( $this->add_control(
'advanced', 'advanced',
[ [
@ -253,7 +252,7 @@ class Opalestate_Agency_Collection_Elementor_Widget extends Opalestate_Elementor
'NOT IN' => esc_html__( 'NOT IN', 'opalestate-pro' ), 'NOT IN' => esc_html__( 'NOT IN', 'opalestate-pro' ),
], ],
'condition' => [ 'condition' => [
'categories!' => '' 'categories!' => '',
], ],
] ]
); );
@ -264,24 +263,19 @@ class Opalestate_Agency_Collection_Elementor_Widget extends Opalestate_Elementor
'section_pagination', 'section_pagination',
[ [
'label' => esc_html__( 'Pagination', 'opalestate-pro' ), 'label' => esc_html__( 'Pagination', 'opalestate-pro' ),
'condition' => [
'enable_carousel!' => 'yes'
],
] ]
); );
$this->add_control( $this->add_control(
'pagination_type', 'pagination',
[ [
'label' => esc_html__( 'Pagination', 'opalestate-pro' ), 'label' => esc_html__( 'Pagination', 'opalestate-pro' ),
'type' => Controls_Manager::SELECT, 'type' => Controls_Manager::SELECT,
'default' => '', 'default' => '',
'options' => [ 'options' => [
'' => esc_html__( 'None', 'opalestate-pro' ), '' => esc_html__( 'None', 'opalestate-pro' ),
'numbers' => esc_html__('Numbers', 'opalestate-pro'), 'show' => esc_html__( 'Show', 'opalestate-pro' ),
'prev_next' => esc_html__('Previous/Next', 'opalestate-pro'), ],
'numbers_and_prev_next' => esc_html__('Numbers', 'opalestate-pro') . ' + ' . esc_html__('Previous/Next', 'opalestate-pro'),
]
] ]
); );
@ -289,92 +283,21 @@ class Opalestate_Agency_Collection_Elementor_Widget extends Opalestate_Elementor
'pagination_page_limit', 'pagination_page_limit',
[ [
'label' => esc_html__( 'Page Limit', 'opalestate-pro' ), 'label' => esc_html__( 'Page Limit', 'opalestate-pro' ),
'default' => '5', 'type' => Controls_Manager::NUMBER,
'default' => '3',
'condition' => [ 'condition' => [
'pagination_type!' => '' 'pagination' => 'show',
], ],
] ]
); );
$this->add_control(
'pagination_numbers_shorten',
[
'label' => esc_html__('Shorten', 'opalestate-pro'),
'type' => Controls_Manager::SWITCHER,
'default' => '',
'condition' => [
'pagination_type' => [
'numbers',
'numbers_and_prev_next',
],
],
]
);
$this->add_control(
'pagination_prev_label',
[
'label' => esc_html__('Previous Label', 'opalestate-pro'),
'default' => esc_html__('« Previous', 'opalestate-pro'),
'condition' => [
'pagination_type' => [
'prev_next',
'numbers_and_prev_next',
],
],
]
);
$this->add_control(
'pagination_next_label',
[
'label' => esc_html__('Next Label', 'opalestate-pro'),
'default' => esc_html__('Next »', 'opalestate-pro'),
'condition' => [
'pagination_type' => [
'prev_next',
'numbers_and_prev_next',
],
],
]
);
$this->add_control(
'pagination_align',
[
'label' => esc_html__('Alignment', 'opalestate-pro'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'flex-start' => [
'title' => esc_html__('Left', 'opalestate-pro'),
'icon' => 'fa fa-align-left',
],
'center' => [
'title' => esc_html__('Center', 'opalestate-pro'),
'icon' => 'fa fa-align-center',
],
'flex-end' => [
'title' => esc_html__('Right', 'opalestate-pro'),
'icon' => 'fa fa-align-right',
],
],
'default' => 'flex-start',
'selectors' => [
'{{WRAPPER}} .pagination' => 'justify-content: {{VALUE}};',
],
'condition' => [
'pagination_type!' => '',
],
]
);
$this->end_controls_section(); $this->end_controls_section();
} }
public function get_post_categories() { public function get_post_categories() {
$list = array(); $list = [];
return $list; return $list;
} }
} }

View File

@ -32,10 +32,10 @@ class Opalestate_Agent_Collection_Elementor_Widget extends Opalestate_Elementor_
* *
* Used to set scripts dependencies required to run the widget. * Used to set scripts dependencies required to run the widget.
* *
* @return array Widget scripts dependencies.
* @since 1.3.0 * @since 1.3.0
* @access public * @access public
* *
* @return array Widget scripts dependencies.
*/ */
public function get_script_depends() { public function get_script_depends() {
return [ 'jquery-slick' ]; return [ 'jquery-slick' ];
@ -51,7 +51,7 @@ class Opalestate_Agent_Collection_Elementor_Widget extends Opalestate_Elementor_
* @return string Widget title. * @return string Widget title.
*/ */
public function get_title() { public function get_title() {
return esc_html__( 'Block: Agent Collection', 'opalestate-pro' ); return esc_html__( 'Block: Agents Collection', 'opalestate-pro' );
} }
/** /**
@ -95,18 +95,18 @@ class Opalestate_Agent_Collection_Elementor_Widget extends Opalestate_Elementor_
] ]
); );
$this->add_control( // $this->add_control(
'search_form', // 'search_form',
[ // [
'label' => esc_html__('Search Form', 'opalestate-pro'), // 'label' => esc_html__('Search Form', 'opalestate-pro'),
'type' => \Elementor\Controls_Manager::SELECT, // 'type' => \Elementor\Controls_Manager::SELECT,
'default' => '', // 'default' => '',
'options' => array( // 'options' => array(
'' => esc_html__( 'Advanded', 'opalestate-pro' ), // '' => esc_html__( 'Advanded', 'opalestate-pro' ),
'address' => esc_html__( 'Search By Address', 'opalestate-pro' ), // 'address' => esc_html__( 'Search By Address', 'opalestate-pro' ),
) // )
] // ]
); // );
$this->add_control( $this->add_control(
'enable_sortable_bar', 'enable_sortable_bar',
@ -122,10 +122,10 @@ class Opalestate_Agent_Collection_Elementor_Widget extends Opalestate_Elementor_
'label' => esc_html__( 'Item Layout', 'opalestate-pro' ), 'label' => esc_html__( 'Item Layout', 'opalestate-pro' ),
'type' => \Elementor\Controls_Manager::SELECT, 'type' => \Elementor\Controls_Manager::SELECT,
'default' => 'grid', 'default' => 'grid',
'options' => array( 'options' => [
'grid' => esc_html__( 'Grid', 'opalestate-pro' ), 'grid' => esc_html__( 'Grid', 'opalestate-pro' ),
'list' => esc_html__( 'List', 'opalestate-pro' ), 'list' => esc_html__( 'List', 'opalestate-pro' ),
) ],
] ]
); );
$this->add_responsive_control( $this->add_responsive_control(
@ -137,8 +137,8 @@ class Opalestate_Agent_Collection_Elementor_Widget extends Opalestate_Elementor_
'options' => [ 1 => 1, 2 => 2, 3 => 3, 4 => 4, 6 => 6 ], 'options' => [ 1 => 1, 2 => 2, 3 => 3, 4 => 4, 6 => 6 ],
'prefix_class' => 'elementor-grid%s-', 'prefix_class' => 'elementor-grid%s-',
'condition' => [ 'condition' => [
'item_layout' => 'grid' 'item_layout' => 'grid',
] ],
] ]
); );
@ -156,12 +156,12 @@ class Opalestate_Agent_Collection_Elementor_Widget extends Opalestate_Elementor_
], ],
], ],
'selectors' => [ 'selectors' => [
'{{WRAPPER}} .elementor-items-container' => 'grid-column-gap: {{SIZE}}{{UNIT}}' '{{WRAPPER}} .elementor-items-container' => 'grid-column-gap: {{SIZE}}{{UNIT}}',
], ],
'condition' => [ 'condition' => [
'item_layout' => 'grid' 'item_layout' => 'grid',
] ],
] ]
); );
@ -174,7 +174,7 @@ class Opalestate_Agent_Collection_Elementor_Widget extends Opalestate_Elementor_
); );
$this->end_controls_section(); $this->end_controls_section();
$this->add_slick_controls( array('enable_carousel' => 'yes') , ' .agent-slick-carousel ' ); $this->add_slick_controls( [ 'enable_carousel' => 'yes' ], ' .agent-slick-carousel ' );
$this->start_controls_section( $this->start_controls_section(
'section_query', 'section_query',
@ -194,7 +194,6 @@ class Opalestate_Agent_Collection_Elementor_Widget extends Opalestate_Elementor_
); );
$this->add_control( $this->add_control(
'advanced', 'advanced',
[ [
@ -253,7 +252,7 @@ class Opalestate_Agent_Collection_Elementor_Widget extends Opalestate_Elementor_
'NOT IN' => esc_html__( 'NOT IN', 'opalestate-pro' ), 'NOT IN' => esc_html__( 'NOT IN', 'opalestate-pro' ),
], ],
'condition' => [ 'condition' => [
'categories!' => '' 'categories!' => '',
], ],
] ]
); );
@ -264,24 +263,19 @@ class Opalestate_Agent_Collection_Elementor_Widget extends Opalestate_Elementor_
'section_pagination', 'section_pagination',
[ [
'label' => esc_html__( 'Pagination', 'opalestate-pro' ), 'label' => esc_html__( 'Pagination', 'opalestate-pro' ),
'condition' => [
'enable_carousel!' => 'yes'
],
] ]
); );
$this->add_control( $this->add_control(
'pagination_type', 'pagination',
[ [
'label' => esc_html__( 'Pagination', 'opalestate-pro' ), 'label' => esc_html__( 'Pagination', 'opalestate-pro' ),
'type' => Controls_Manager::SELECT, 'type' => Controls_Manager::SELECT,
'default' => '', 'default' => '',
'options' => [ 'options' => [
'' => esc_html__( 'None', 'opalestate-pro' ), '' => esc_html__( 'None', 'opalestate-pro' ),
'numbers' => esc_html__('Numbers', 'opalestate-pro'), 'show' => esc_html__( 'Show', 'opalestate-pro' ),
'prev_next' => esc_html__('Previous/Next', 'opalestate-pro'), ],
'numbers_and_prev_next' => esc_html__('Numbers', 'opalestate-pro') . ' + ' . esc_html__('Previous/Next', 'opalestate-pro'),
]
] ]
); );
@ -289,92 +283,21 @@ class Opalestate_Agent_Collection_Elementor_Widget extends Opalestate_Elementor_
'pagination_page_limit', 'pagination_page_limit',
[ [
'label' => esc_html__( 'Page Limit', 'opalestate-pro' ), 'label' => esc_html__( 'Page Limit', 'opalestate-pro' ),
'default' => '5', 'type' => Controls_Manager::NUMBER,
'default' => '3',
'condition' => [ 'condition' => [
'pagination_type!' => '' 'pagination' => 'show',
], ],
] ]
); );
$this->add_control(
'pagination_numbers_shorten',
[
'label' => esc_html__('Shorten', 'opalestate-pro'),
'type' => Controls_Manager::SWITCHER,
'default' => '',
'condition' => [
'pagination_type' => [
'numbers',
'numbers_and_prev_next',
],
],
]
);
$this->add_control(
'pagination_prev_label',
[
'label' => esc_html__('Previous Label', 'opalestate-pro'),
'default' => esc_html__('« Previous', 'opalestate-pro'),
'condition' => [
'pagination_type' => [
'prev_next',
'numbers_and_prev_next',
],
],
]
);
$this->add_control(
'pagination_next_label',
[
'label' => esc_html__('Next Label', 'opalestate-pro'),
'default' => esc_html__('Next »', 'opalestate-pro'),
'condition' => [
'pagination_type' => [
'prev_next',
'numbers_and_prev_next',
],
],
]
);
$this->add_control(
'pagination_align',
[
'label' => esc_html__('Alignment', 'opalestate-pro'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'flex-start' => [
'title' => esc_html__('Left', 'opalestate-pro'),
'icon' => 'fa fa-align-left',
],
'center' => [
'title' => esc_html__('Center', 'opalestate-pro'),
'icon' => 'fa fa-align-center',
],
'flex-end' => [
'title' => esc_html__('Right', 'opalestate-pro'),
'icon' => 'fa fa-align-right',
],
],
'default' => 'flex-start',
'selectors' => [
'{{WRAPPER}} .pagination' => 'justify-content: {{VALUE}};',
],
'condition' => [
'pagination_type!' => '',
],
]
);
$this->end_controls_section(); $this->end_controls_section();
} }
public function get_post_categories() { public function get_post_categories() {
$list = array(); $list = [];
return $list; return $list;
} }
} }

View File

@ -3,7 +3,7 @@
* Plugin Name: Opal Estate Pro * Plugin Name: Opal Estate Pro
* Plugin URI: http://www.wpopal.com/product/opal-estate-wordpress-plugin/ * Plugin URI: http://www.wpopal.com/product/opal-estate-wordpress-plugin/
* Description: Opal Real Estate Plugin is an ideal solution and brilliant choice for you to set up a professional estate website. * Description: Opal Real Estate Plugin is an ideal solution and brilliant choice for you to set up a professional estate website.
* Version: 1.1.3 * Version: 1.1.4
* Author: WPOPAL * Author: WPOPAL
* Author URI: http://www.wpopal.com * Author URI: http://www.wpopal.com
* Requires at least: 4.6 * Requires at least: 4.6
@ -151,7 +151,7 @@ if ( ! class_exists( 'OpalEstate' ) ) {
*/ */
public function __clone() { public function __clone() {
// Cloning instances of the class is forbidden // Cloning instances of the class is forbidden
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'opalestate-pro' ), '1.1.3' ); _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'opalestate-pro' ), '1.1.4' );
} }
/** /**
@ -160,7 +160,7 @@ if ( ! class_exists( 'OpalEstate' ) ) {
public function setup_constants() { public function setup_constants() {
// Plugin version // Plugin version
if ( ! defined( 'OPALESTATE_VERSION' ) ) { if ( ! defined( 'OPALESTATE_VERSION' ) ) {
define( 'OPALESTATE_VERSION', '1.1.3' ); define( 'OPALESTATE_VERSION', '1.1.4' );
} }
// Plugin Folder Path // Plugin Folder Path

View File

@ -153,6 +153,9 @@ This section describes how to install the plugin and get it working.
* System tickets support 24/7 available : [free support](https://wpopal.ticksy.com/ "Visit the Plugin support Page") * System tickets support 24/7 available : [free support](https://wpopal.ticksy.com/ "Visit the Plugin support Page")
== Changelog == == Changelog ==
= 1.1.4 - 2019-10-17 =
* Fixes - Properties collection Pagination.
= 1.1.3 - 2019-10-15 = = 1.1.3 - 2019-10-15 =
* Fixes - Submission. * Fixes - Submission.

View File

@ -1,5 +1,6 @@
<?php <?php
$settings = $this->get_settings_for_display(); $settings = $this->get_settings_for_display();
extract( $settings );
$layout = $settings['item_layout']; $layout = $settings['item_layout'];
$attrs = $this->get_render_attribute_string( 'wrapper-style' ); $attrs = $this->get_render_attribute_string( 'wrapper-style' );
if ( isset( $_GET['display'] ) && $_GET['display'] == 'grid' ) { if ( isset( $_GET['display'] ) && $_GET['display'] == 'grid' ) {
@ -9,13 +10,20 @@ if ( isset( $_GET['display'] ) && $_GET['display'] == 'grid' ) {
$layout = 'list'; $layout = 'list';
$attrs = 'class="column-list"'; $attrs = 'class="column-list"';
} }
$onlyfeatured = 0;
if ( isset( $_GET['s_agents'] ) ) { if ( is_front_page() ) {
$query = Opalestate_Agency_Query::get_agencies( [ "posts_per_page" => $limit, 'paged' => $paged ], $onlyfeatured ); $paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
} else { } else {
$query = Opalestate_Agency_Query::get_search_agencies_query(); $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
} }
$onlyfeatured = 0;
// if ( isset( $_GET['s_agents'] ) ) {
$query = Opalestate_Agency_Query::get_agencies( [ 'posts_per_page' => $posts_per_page, 'paged' => $paged ], $onlyfeatured );
// } else {
// $query = Opalestate_Agency_Query::get_search_agencies_query();
// }
$rowcls = apply_filters( 'opalestate_row_container_class', 'opal-row' ); $rowcls = apply_filters( 'opalestate_row_container_class', 'opal-row' );
?> ?>
@ -48,10 +56,8 @@ $rowcls = apply_filters( 'opalestate_row_container_class', 'opal-row' );
<?php endwhile; ?> <?php endwhile; ?>
</div> </div>
</div> </div>
<?php if ( $query->max_num_pages ): ?> <?php if ( isset( $pagination ) && $pagination && ( ! isset( $enable_carousel ) || ! $enable_carousel ) ): ?>
<div class="w-pagination"> <div class="w-pagination"><?php opalestate_pagination( $pagination_page_limit ); ?></div>
<?php opalestate_pagination( $query->max_num_pages ); ?>
</div>
<?php endif; ?> <?php endif; ?>
<?php else: ?> <?php else: ?>
<div class="agency-results"> <div class="agency-results">

View File

@ -1,5 +1,6 @@
<?php <?php
$settings = $this->get_settings_for_display(); $settings = $this->get_settings_for_display();
extract( $settings );
$layout = $settings['item_layout']; $layout = $settings['item_layout'];
$attrs = $this->get_render_attribute_string( 'wrapper-style' ); $attrs = $this->get_render_attribute_string( 'wrapper-style' );
if ( isset( $_GET['display'] ) && $_GET['display'] == 'grid' ) { if ( isset( $_GET['display'] ) && $_GET['display'] == 'grid' ) {
@ -10,13 +11,19 @@ if ( isset( $_GET['display'] ) && $_GET['display'] == 'grid' ) {
$attrs = 'class="column-list"'; $attrs = 'class="column-list"';
} }
if ( is_front_page() ) {
$paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
} else {
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
}
$onlyfeatured = 0; $onlyfeatured = 0;
if ( isset( $_GET['s_agents'] ) ) { // if ( isset( $_GET['s_agents'] ) ) {
$query = Opalestate_Query::get_agents( [ "posts_per_page" => $limit, 'paged' => $paged ], $onlyfeatured ); $query = Opalestate_Query::get_agents( [ "posts_per_page" => $posts_per_page, 'paged' => $paged ], $onlyfeatured );
} else { // } else {
$query = OpalEstate_Search::get_search_agents_query(); // $query = OpalEstate_Search::get_search_agents_query();
} // }
$form = $settings['search_form'] ? "search-agents-form-" . $settings['search_form'] : "search-agents-form"; $form = $settings['search_form'] ? "search-agents-form-" . $settings['search_form'] : "search-agents-form";
$rowcls = apply_filters( 'opalestate_row_container_class', 'opal-row' ); $rowcls = apply_filters( 'opalestate_row_container_class', 'opal-row' );
@ -51,10 +58,8 @@ $rowcls = apply_filters( 'opalestate_row_container_class', 'opal-row' );
<?php endwhile; ?> <?php endwhile; ?>
</div> </div>
</div> </div>
<?php if ( $query->max_num_pages ): ?> <?php if ( isset( $pagination ) && $pagination && ( ! isset( $enable_carousel ) || ! $enable_carousel ) ): ?>
<div class="w-pagination"> <div class="w-pagination"><?php opalestate_pagination( $pagination_page_limit ); ?></div>
<?php opalestate_pagination( $query->max_num_pages ); ?>
</div>
<?php endif; ?> <?php endif; ?>
<?php else: ?> <?php else: ?>
<div class="agents-results"> <div class="agents-results">