Merge pull request #15 from wpopal/develop

Develop
This commit is contained in:
wpopal 2019-11-07 16:27:22 +07:00 committed by GitHub
commit a3220de1e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1803 additions and 1343 deletions

@ -393,6 +393,33 @@ function opalestate_cleanup() {
}
}
wp_reset_postdata();
// Change status expired properties.
$expired_query = new WP_Query( [
'post_type' => 'opalestate_property',
'post_status' => [ 'pending', 'publish' ],
'meta_query' => [
[
'key' => OPALESTATE_PROPERTY_PREFIX . 'expired_time',
'value' => time(),
'compare' => '>=',
'type' => 'NUMERIC',
],
],
] );
if ( $expired_query->have_posts() ) {
while ( $expired_query->have_posts() ) {
$expired_query->the_post();
wp_update_post( [
'ID' => get_the_ID(),
'post_status' => 'expired',
] );
}
}
wp_reset_postdata();
}
/**

@ -98,7 +98,7 @@ class Opalestate_Settings_General_Tab extends Opalestate_Settings_Base_Tab {
],
[
'name' => esc_html__( 'Maximun Upload Image Size', 'opalestate-pro' ),
'name' => esc_html__( 'Maximum Upload Image Size', 'opalestate-pro' ),
'desc' => esc_html__( 'Set maximun volumn size having < x MB', 'opalestate-pro' ),
'id' => 'upload_image_max_size',
@ -106,7 +106,7 @@ class Opalestate_Settings_General_Tab extends Opalestate_Settings_Base_Tab {
'default' => '0.5',
],
[
'name' => esc_html__( 'Maximun Upload Image Files', 'opalestate-pro' ),
'name' => esc_html__( 'Maximum Upload Image Files', 'opalestate-pro' ),
'desc' => esc_html__( 'Set maximun volumn size having < x MB', 'opalestate-pro' ),
'id' => 'upload_image_max_files',
@ -114,7 +114,7 @@ class Opalestate_Settings_General_Tab extends Opalestate_Settings_Base_Tab {
'default' => '10',
],
[
'name' => esc_html__( 'Maximun Upload Other Size', 'opalestate-pro' ),
'name' => esc_html__( 'Maximum Upload Other Size', 'opalestate-pro' ),
'desc' => esc_html__( 'Set maximun volumn size having < x MB for upload docx, pdf...', 'opalestate-pro' ),
'id' => 'upload_other_max_size',
@ -122,7 +122,7 @@ class Opalestate_Settings_General_Tab extends Opalestate_Settings_Base_Tab {
'default' => '0.8',
],
[
'name' => esc_html__( 'Maximun Upload Other Files', 'opalestate-pro' ),
'name' => esc_html__( 'Maximum Upload Other Files', 'opalestate-pro' ),
'desc' => esc_html__( 'Set maximun volumn size having < x MB for upload docx, pdf...', 'opalestate-pro' ),
'id' => 'upload_other_max_files',

@ -195,7 +195,7 @@ abstract class Opalestate_Base_API {
$endpoint = explode( '/', $route );
$endpoint = end( $endpoint );
if ( in_array( $endpoint, [ 'properties', 'agencies', 'agents', 'search-form' ] ) ) {
if ( in_array( $endpoint, [ 'properties', 'agencies', 'agents', 'search-form', 'search' ] ) ) {
return true;
}

@ -119,7 +119,7 @@ class OpalEstate_Nocaptcha_Recaptcha {
[
'name' => esc_html__( 'Site Key', 'opalestate-pro' ),
'desc' => esc_html__( 'Used for displaying the CAPTCHA. Grab it %s', 'opalestate-pro' ),
'desc' => esc_html__( 'Used for displaying the CAPTCHA.', 'opalestate-pro' ),
'id' => 'site_key',
'type' => 'text',
],

@ -72,7 +72,7 @@ class Opalestate_Cache {
self::$instance->is_cache = ( defined( 'GIVE_CACHE' ) ? GIVE_CACHE : opalestate_is_setting_enabled( opalestate_get_option( 'cache', 'enabled' ) ) ) && is_admin();
// weekly delete all expired cache.
Give_Cron::add_weekly_event( array( $this, 'delete_all_expired' ) );
// Give_Cron::add_weekly_event( array( $this, 'delete_all_expired' ) );
add_action( 'save_post_opalestate_forms', array( $this, 'delete_form_related_cache' ) );
add_action( 'save_post_opalestate_payment', array( $this, 'delete_payment_related_cache' ) );

@ -27,6 +27,7 @@ class Opalestate_PostType_Property {
*/
public function __construct() {
add_action( 'init', [ __CLASS__, 'definition' ] );
add_action( 'init', [ __CLASS__, 'register_post_status' ] );
}
/**
@ -74,6 +75,21 @@ class Opalestate_PostType_Property {
] )
);
}
/**
* Register post status.
*/
public static function register_post_status() {
register_post_status( 'expired', [
'label' => _x( 'Expired', 'Expired status', 'opalestate-pro' ),
'public' => false,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
/* translators: %s: number of orders */
'label_count' => _n_noop( 'Expired <span class="count">(%s)</span>', 'Expired <span class="count">(%s)</span>', 'opalestate-pro' ),
] );
}
}
new Opalestate_PostType_Property();

@ -138,7 +138,7 @@ class OpalEstate_Submission {
] ),
],
[
'name' => esc_html__( 'Show Content Use Not Login', 'opalestate-pro' ),
'name' => esc_html__( 'Show Content when User Not Login', 'opalestate-pro' ),
'desc' => esc_html__( 'Show Login/Register form and submission form if the user is not logged in.', 'opalestate-pro' ),
'id' => 'submission_show_content',
'type' => 'select',

@ -218,7 +218,7 @@ function opalestate_management_user_menu_tabs() {
$link = $uri . '?tab=' . $item['link'];
}
$output .= '<li class="account-links-item' . ( $current_tab == $item['link'] ? ' active' : '' ) . '"><a href="' . $link . '"><i class="' . $item['icon'] . '"></i> ' . $item['title'] . '</a></li>';
$output .= '<li class="account-links-item ' . $key . ( $current_tab == $item['link'] ? ' active' : '' ) . '"><a href="' . $link . '"><i class="' . $item['icon'] . '"></i> ' . $item['title'] . '</a></li>';
}
$output .= '<li><a href="' . wp_logout_url( home_url( '/' ) ) . '"> <i class="fa fa-unlock"></i> ' . esc_html__( 'Log out', 'opalestate-pro' ) . '</a></li>';

@ -21,13 +21,14 @@ if ( ! defined( 'ABSPATH' ) ) {
* Count Number of listing following user
*/
function opalesate_get_user_current_listings( $user_id ) {
$args = array(
$args = [
'post_type' => 'opalestate_property',
'post_status' => array( 'pending', 'publish' ),
'post_status' => [ 'pending', 'publish' ],
'author' => $user_id,
);
];
$posts = new WP_Query( $args );
return $posts->found_posts;
wp_reset_postdata();
}
@ -37,19 +38,20 @@ function opalesate_get_user_current_listings( $user_id ){
*/
function opalesate_get_user_current_featured_listings( $user_id ) {
$args = array(
$args = [
'post_type' => 'opalestate_property',
'post_status' => array( 'pending', 'publish' ),
'post_status' => [ 'pending', 'publish' ],
'author' => $user_id,
'meta_query' => array(
array(
'meta_query' => [
[
'key' => OPALESTATE_PROPERTY_PREFIX . 'featured',
'value' => 1,
'meta_compare '=>'='
)
)
);
'meta_compare ' => '=',
],
],
];
$posts = new WP_Query( $args );
return $posts->found_posts;
wp_reset_postdata();
}
@ -104,6 +106,7 @@ function opalesate_check_has_add_listing( $user_id, $package_id=null ){
if ( $package_listings > 0 ) {
return true;
}
return false;
}
@ -121,12 +124,10 @@ function opalesate_get_user_featured_remaining_listing( $user_id ){
*
*/
function opalestate_reset_user_free_package( $user_id ) {
$duration = opalestate_options( 'free_expired_month', 12 );
update_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'package_id', -1 );
update_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'package_listings', opalestate_options( 'free_number_listing', 3 ) );
update_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'package_featured_listings', opalestate_options( 'free_number_featured', 3 ) );
update_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'package_activation', time() );
update_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'package_expired', time() + ( $duration * 60 * 60 * 24 * 30 ) );
@ -175,14 +176,11 @@ function opalesate_is_membership_valid( $user_id = null ){
*
*/
function opalesate_listing_set_to_expire( $post_id ) {
$prop = array(
$prop = [
'ID' => $post_id,
'post_type' => 'opalestate_property',
'post_status' => 'expired'
);
'post_status' => 'expired',
];
wp_update_post( $prop );
@ -192,10 +190,10 @@ function opalesate_listing_set_to_expire($post_id){
$user = get_user_by( 'id', $user_id );
$user_email = $user->user_email;
$args = array(
$args = [
'expired_listing_url' => get_permalink( $post_id ),
'expired_listing_name' => get_the_title($post_id)
);
'expired_listing_name' => get_the_title( $post_id ),
];
opalesate_email_type( $user_email, 'listing_expired', $args );
}

@ -98,6 +98,8 @@ class OpalEstate_Membership {
add_action( 'profile_update', [ __CLASS__, 'on_update_user' ], 10, 1 );
add_action( 'save_post', [ __CLASS__, 'update_property_expired_time' ], 10, 2 );
}
/**
@ -244,6 +246,34 @@ class OpalEstate_Membership {
'description' => esc_html__( 'Number of properties can make featured with this package.', 'opalestate-pro' ),
];
$fields[] = [
'name' => esc_html__( 'Enable Expired for properties ', 'opalestate-pro' ),
'id' => $prefix . 'enable_property_expired',
'type' => 'checkbox',
'description' => esc_html__( 'Do you want enable expired date for properties?', 'opalestate-pro' ),
];
$fields[] = [
'name' => esc_html__( 'Expired Property In', 'opalestate-pro' ),
'id' => $prefix . 'property_duration',
'type' => 'text',
'attributes' => [
'type' => 'number',
'pattern' => '\d*',
'min' => 0,
],
'std' => '1',
'description' => esc_html__( 'Expired a property in. Enter expired number. Example 1, 2, 3', 'opalestate-pro' ),
];
$fields[] = [
'name' => esc_html__( 'Expired property Date Type', 'opalestate-pro' ),
'id' => $prefix . 'property_duration_unit',
'type' => 'select',
'options' => opalmembership_package_expiry_labels(),
'description' => esc_html__( 'Enter expired date type. Example Day(s), Week(s), Month(s), Year(s)', 'opalestate-pro' ),
];
return $fields;
}
@ -358,6 +388,7 @@ class OpalEstate_Membership {
$is_unlimited_listings = get_post_meta( $package_id, OPALMEMBERSHIP_PACKAGES_PREFIX . 'unlimited_listings', true );
$pack_unlimited_listings = $is_unlimited_listings == 'on' ? 0 : 1;
/**
* Get package information with user logined
*/
@ -394,6 +425,14 @@ class OpalEstate_Membership {
*/
update_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'package_listings', $new_listings );
update_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'package_featured_listings', $new_featured_listings );
$enable_property_expired = get_post_meta( $package_id, OPALMEMBERSHIP_PACKAGES_PREFIX . 'enable_property_expired', true );
$property_duration = get_post_meta( $package_id, OPALMEMBERSHIP_PACKAGES_PREFIX . 'property_duration', true );
$property_duration_unit = get_post_meta( $package_id, OPALMEMBERSHIP_PACKAGES_PREFIX . 'property_duration_unit', true );
update_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'enable_property_expired', $enable_property_expired );
update_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'property_duration', $property_duration );
update_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'property_duration_unit', $property_duration_unit );
}
/**
@ -645,6 +684,70 @@ class OpalEstate_Membership {
}
}
}
/**
* @param $user_id
* @param $post_id
*/
public static function update_property_expired_time( $post_id ) {
$post = get_post( $post_id );
$user_id = $post->post_author;
$activated = get_post_meta( $post_id, OPALESTATE_PROPERTY_PREFIX . 'expired_activated', true );
if ( ! $activated ) {
static::handle_property_expired_time( $user_id, $post_id );
}
}
public static function handle_property_expired_time( $user_id, $post_id ) {
$is_valid = Opalmembership_User::is_membership_valid( $user_id );
if ( ! $is_valid ) {
return;
}
$enable_property_expired = get_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'enable_property_expired', true );
$post_status = get_post_status( $post_id );
if ( $enable_property_expired && 'publish' == $post_status ) {
$property_duration = get_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'property_duration', true );
$property_duration_unit = get_user_meta( $user_id, OPALMEMBERSHIP_USER_PREFIX_ . 'property_duration_unit', true );
$expired_time = time() + static::get_expiration_unit_time( $property_duration, $property_duration_unit );
update_post_meta( $post_id, OPALESTATE_PROPERTY_PREFIX . 'expired_time', $expired_time );
update_post_meta( $post_id, OPALESTATE_PROPERTY_PREFIX . 'expired_activated', 1 );
}
}
/**
* @param $duration
* @param $unit
* @return float|int
*/
public static function get_expiration_unit_time( $duration, $unit ) {
if ( ! ( $duration = absint( $duration ) ) ) {
$duration = 1;
}
switch ( $unit ) {
case 'day':
$seconds = 60 * 60 * 24;
break;
case 'week':
$seconds = 60 * 60 * 24 * 7;
break;
case 'month':
$seconds = 60 * 60 * 24 * 30;
break;
case 'year':
$seconds = 60 * 60 * 24 * 365;
break;
}
return $seconds * $duration;
}
}
OpalEstate_Membership::init();

File diff suppressed because it is too large Load Diff

@ -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.1.8
* Version: 1.1.9
* Author: WPOPAL
* Author URI: http://www.wpopal.com
* Requires at least: 4.6
@ -151,7 +151,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.1.8' );
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'opalestate-pro' ), '1.1.9' );
}
/**
@ -160,7 +160,7 @@ if ( ! class_exists( 'OpalEstate' ) ) {
public function setup_constants() {
// Plugin version
if ( ! defined( 'OPALESTATE_VERSION' ) ) {
define( 'OPALESTATE_VERSION', '1.1.8' );
define( 'OPALESTATE_VERSION', '1.1.9' );
}
// Plugin Folder Path

@ -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.6
Tested up to: 5.2.3
Stable tag: 1.1.8
Stable tag: 1.1.9
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@ -156,6 +156,10 @@ 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.1.9 - 2019-11-07 =
* Fixes - Dashboard page.
* Added - Expired properties.
= 1.1.8 - 2019-10-31 =
* Fixes - Submission settings.
* Fixes - Order settings in the search page.

@ -19,6 +19,8 @@ if ( ! class_exists( 'OpalEstate_User' ) ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$roles = $current_user->roles;
$roles_classes = implode( ' ', array_map( 'sanitize_html_class', $roles ) )
?>
<?php if ( $user_id ): ?>
@ -60,7 +62,7 @@ $current_user = wp_get_current_user();
</div>
</div>
<div class="wrapper opalestate-user-management" id="opalestate-user-management">
<div class="wrapper opalestate-user-management <?php echo esc_attr( $roles_classes ); ?>" id="opalestate-user-management">
<div class="container" id="content">
<div class="opal-row-inner">
<div class=" user-dasboard-sidebar">
@ -132,7 +134,7 @@ $current_user = wp_get_current_user();
<?php get_footer( 'header/no-sidebar' ); ?>
<?php else : ?>
<?php get_header(); ?>
<div class="wrapper opalestate-user-management" id="opalestate-user-management">
<div class="wrapper opalestate-user-management <?php echo esc_attr( $roles_classes ); ?>" id="opalestate-user-management">
<div class="container">
<div class="opalestate-panel-myaccount">
<div class="management-header text-center">