Add display mode setting

This commit is contained in:
Hoang Huu 2020-03-03 10:57:04 +07:00
parent e5991913ed
commit dc14e74e6d
11 changed files with 77 additions and 53 deletions

View File

@ -1,3 +1,6 @@
= 1.3.7 - 2020-03-03 =
* Added - Display mode setting
= 1.3.6 - 2020-02-29 =
* Fixes - User register form & User roles

View File

@ -85,6 +85,13 @@ class Opalestate_Settings_Property_Tab extends Opalestate_Settings_Base_Tab {
'options' => $checkes,
];
$fields[] = [
'name' => esc_html__( 'Default Display mode', 'opalestate-pro' ),
'id' => 'displaymode',
'type' => 'select',
'options' => opalestate_display_modes(),
];
$fields[] = [
'name' => esc_html__( 'Archive Grid layout', 'opalestate-pro' ),
'id' => 'property_archive_grid_layout',

View File

@ -179,7 +179,7 @@ class Opalestate_Admin_API_Keys_Table_List extends WP_List_Table {
public function column_last_access( $key ) {
if ( ! empty( $key['last_access'] ) ) {
/* translators: 1: last access date 2: last access time */
$date = sprintf( __( '%1$s at %2$s', 'opalestate-pro' ), date_i18n( wc_date_format(), strtotime( $key['last_access'] ) ),
$date = sprintf( __( '%1$s at %2$s', 'opalestate-pro' ), date_i18n( get_option( 'date_format' ), strtotime( $key['last_access'] ) ),
date_i18n( get_option( 'time_format' ), strtotime( $key['last_access'] ) ) );
return apply_filters( 'opalestate_api_key_last_access_datetime', $date, $key['last_access'] );

View File

@ -237,6 +237,18 @@ function opalestate_get_loop_property_layouts() {
] );
}
/**
* Gets display modes.
*
* @return array
*/
function opalestate_display_modes() {
return apply_filters( 'opalestate_display_modes', [
'grid' => esc_html__( 'Grid', 'opalestate-pro' ),
'list' => esc_html__( 'List', 'opalestate-pro' ),
] );
}
/**
* Gets loop property grid layouts.
*

View File

@ -245,12 +245,12 @@ function opalestate_render_sortable_dropdown( $selected = '' ) {
/**
*
* Display modes
*/
function opalestate_show_display_modes( $default = 'list' ) {
function opalestate_show_display_modes( $default = '' ) {
$op_display = opalestate_get_display_mode( $default );
$modes = apply_filters( 'opalestate_listing_display_mode', [
$modes = apply_filters( 'opalestate_listing_display_modes', [
'grid' => [
'icon' => 'fa fa-th',
'title' => esc_html__( 'Grid', 'opalestate-pro' ),
@ -259,20 +259,14 @@ function opalestate_show_display_modes( $default = 'list' ) {
'icon' => 'fa fa-th-list',
'title' => esc_html__( 'List', 'opalestate-pro' ),
],
/* 'map' => array(
'icon' => 'fa fa-map-marker',
'title' => esc_html__('Map','opalestate-pro')
), */
] );
echo '<div class="display-mode">';
foreach ( $modes as $key => $mode ) {
echo '<a href="' . opalestate_get_url_sort_mode( $key ) . '" aria-label="' . $mode['title'] . '" class="hint--top btn ' . ( $op_display == $key ? 'active' : '' ) . '" data-mode="' . $key . '"><i class="' . $mode['icon'] . '"></i></a>';
}
echo '</div>';
}
if ( ! function_exists( 'opalestate_pagination' ) ) {
@ -364,8 +358,15 @@ function opalestate_show_display_status() {
<?php
}
/**
* Get display mode.
*
* @param string $default
* @return string
*/
function opalestate_get_display_mode( $default = '' ) {
$op_display = $default ? $default : opalestate_options( 'displaymode', 'grid' );
if ( isset( $_GET['display'] ) ) {
$op_display = sanitize_text_field( $_GET['display'] );
}
@ -428,8 +429,13 @@ function opalestate_get_favorite_page_uri() {
return apply_filters( 'opalestate_get_favorite_page_uri', $favorite_page );
}
/**
* Single layout templates
*
* @param $layout
* @return array
*/
function opalestate_single_layout_templates( $layout ) {
$layout['v2'] = esc_html__( 'Vesion 2', 'opalestate-pro' );
$layout['v3'] = esc_html__( 'Vesion 3', 'opalestate-pro' );
$layout['v4'] = esc_html__( 'Vesion 4', 'opalestate-pro' );

View File

@ -3,7 +3,7 @@
* Plugin Name: Opal Estate Pro
* Plugin URI: https://wpdocs.gitbook.io/opal-estate/
* Description: Opal Real Estate Plugin is an ideal solution and brilliant choice for you to set up a professional estate website.
* Version: 1.3.6
* Version: 1.3.7
* Author: WPOPAL
* Author URI: http://www.wpopal.com
* Requires at least: 4.9
@ -150,7 +150,7 @@ if ( ! class_exists( 'OpalEstate' ) ) {
*/
public function __clone() {
// Cloning instances of the class is forbidden
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'opalestate-pro' ), '1.3.6' );
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'opalestate-pro' ), '1.3.7' );
}
/**
@ -159,7 +159,7 @@ if ( ! class_exists( 'OpalEstate' ) ) {
public function setup_constants() {
// Plugin version
if ( ! defined( 'OPALESTATE_VERSION' ) ) {
define( 'OPALESTATE_VERSION', '1.3.6' );
define( 'OPALESTATE_VERSION', '1.3.7' );
}
// Plugin Folder Path

View File

@ -4,7 +4,7 @@ Donate link: https://wpdocs.gitbook.io/opal-estate/
Tags: estate, property, opalestate, house for rent, agency for lease, estate submission, agents estate property, property marketplace
Requires at least: 4.9
Tested up to: 5.3.2
Stable tag: 1.3.6
Stable tag: 1.3.7
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@ -156,6 +156,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")
== Changelog ==
= 1.3.7 - 2020-03-03 =
* Added - Display mode setting
= 1.3.6 - 2020-02-29 =
* Fixes - User register form & User roles

View File

@ -26,7 +26,7 @@ $grid_layout = 'content-property-' . opalestate_get_option( 'property_archive_gr
<div class="opalesate-archive-bottom opalestate-rows opalestate-collection">
<div class="opal-row">
<?php if ( ( isset( $_GET['display'] ) && $_GET['display'] == 'list' ) || opalestate_get_display_mode( 'list' ) == 'list' ) : ?>
<?php if ( ( isset( $_GET['display'] ) && $_GET['display'] == 'list' ) || opalestate_get_display_mode( opalestate_options( 'displaymode', 'grid' ) ) == 'list' ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="col-lg-12 col-md-12 col-sm-12">
<?php echo opalestate_load_template_path( $list_layout ); ?>

View File

@ -1,20 +1,10 @@
<?php
$selected = '';
$mode = isset($mode)?$mode:'';
?>
<div class="opalesate-archive-top">
<div class="<?php echo apply_filters( 'opalestate_row_container_class', 'opal-row' ); ?>">
<div class="col-lg-8 col-md-7 col-sm-6">
<?php opalestate_show_display_status();
?>
<?php opalestate_show_display_status(); ?>
</div>
<div class="col-lg-4 col-md-5 col-sm-6 space-margin-top-10p">
@ -22,7 +12,7 @@
<?php echo opalestate_render_sortable_dropdown( $selected ); ?>
</div>
<div class="pull-right">
<?php opalestate_show_display_modes( $mode ); ?>
<?php opalestate_show_display_modes(); ?>
</div>
</div>
</div>

View File

@ -7,8 +7,11 @@ if ( ! class_exists( 'OpalEstate_Search' ) ) {
}
$query = OpalEstate_Search::get_search_results_query();
$show = opalestate_options( 'displaymode', 'grid' );
$show = ( isset( $_GET['display'] ) && $_GET['display'] == 'list' ) || ( opalestate_options( 'displaymode', 'grid' ) == 'list' ) || ( isset( $style ) && $style == 'list' ) ? 'list' : 'grid';
if ( isset( $_GET['display'] ) && $_GET['display'] && in_array( sanitize_text_field( $_GET['display'] ), [ 'grid', 'list' ] ) ) {
$show = sanitize_text_field( $_GET['display'] );
}
?>
<div class="opaleslate-ajax-search-results-container">
<div class="opalesate-archive-top">
@ -26,7 +29,7 @@ $show = ( isset( $_GET['display'] ) && $_GET['display'] == 'list' ) || ( opalest
<div class="opalestate-sortable">
<?php echo opalestate_render_sortable_dropdown(); ?>
</div>
<?php opalestate_show_display_modes( 'grid' ); ?>
<?php opalestate_show_display_modes(); ?>
</div>
</div>
</div>