From bb42be1a8c867743a805d3ba4d441c35ab96e6f2 Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Mon, 6 Jan 2020 09:37:47 +0700 Subject: [PATCH] Add Pages settings. --- inc/admin/class-admin.php | 1 + inc/admin/register-settings.php | 13 +- inc/admin/settings/general.php | 56 ------- inc/admin/settings/pages.php | 176 ++++++++++++++++++++++ inc/user/class-opalestate-user-search.php | 14 +- inc/user/functions.php | 137 +++++++++-------- opal-estate-pro.php | 6 +- readme.txt | 3 + 8 files changed, 272 insertions(+), 134 deletions(-) create mode 100644 inc/admin/settings/pages.php diff --git a/inc/admin/class-admin.php b/inc/admin/class-admin.php index bb649a54..8033b02c 100755 --- a/inc/admin/class-admin.php +++ b/inc/admin/class-admin.php @@ -86,6 +86,7 @@ class Opalestate_Admin { 'settings/searcharea.php', 'settings/general.php', 'settings/property.php', + 'settings/pages.php', ] ); // Get it started diff --git a/inc/admin/register-settings.php b/inc/admin/register-settings.php index 42f11791..2ef35dc2 100755 --- a/inc/admin/register-settings.php +++ b/inc/admin/register-settings.php @@ -115,10 +115,12 @@ class Opalestate_Plugin_Settings { $settings = $this->opalestate_settings( null ); - $tabs = []; - $tabs['general'] = esc_html__( 'General', 'opalestate-pro' ); - - $tabs['property'] = esc_html__( 'Property', 'opalestate-pro' ); + $tabs = []; + $tabs['general'] = esc_html__( 'General', 'opalestate-pro' ); + $tabs['property'] = esc_html__( 'Property', 'opalestate-pro' ); + $tabs['pages'] = esc_html__( 'Pages', 'opalestate-pro' ); + $tabs['3rd_party'] = esc_html__( '3rd Party', 'opalestate-pro' ); + $tabs['api_keys'] = esc_html__( 'API', 'opalestate-pro' ); if ( ! empty( $settings['addons']['fields'] ) ) { $tabs['addons'] = esc_html__( 'Add-ons', 'opalestate-pro' ); @@ -128,9 +130,6 @@ class Opalestate_Plugin_Settings { $tabs['licenses'] = esc_html__( 'Licenses', 'opalestate-pro' ); } - $tabs['api_keys'] = esc_html__( 'API', 'opalestate-pro' ); - $tabs['3rd_party'] = esc_html__( '3rd Party', 'opalestate-pro' ); - return apply_filters( 'opalestate_settings_tabs', $tabs ); } diff --git a/inc/admin/settings/general.php b/inc/admin/settings/general.php index 52f68380..e08f4c64 100755 --- a/inc/admin/settings/general.php +++ b/inc/admin/settings/general.php @@ -32,11 +32,6 @@ class Opalestate_Settings_General_Tab extends Opalestate_Settings_Base_Tab { } public function get_tab_fields( $key = '' ) { - $pages = opalestate_cmb2_get_post_options( [ - 'post_type' => 'page', - 'numberposts' => -1, - ] ); - return apply_filters( 'opalestate_settings_general', [ [ 'name' => esc_html__( 'General Settings', 'opalestate-pro' ), @@ -46,44 +41,6 @@ class Opalestate_Settings_General_Tab extends Opalestate_Settings_Base_Tab { 'before_row' => '
', 'after_row' => '
', ], - [ - 'name' => esc_html__( 'User Management Page', 'opalestate-pro' ), - 'desc' => esc_html__( 'This is page use User Management Page using for show content of management page such as profile, my properties', 'opalestate-pro' ), - 'id' => 'user_management_page', - 'type' => 'select', - 'options' => $pages, - ], - [ - 'name' => esc_html__( 'Dashboard Logo', 'opalestate-pro' ), - 'desc' => esc_html__( 'Upload a logo for user dashboard page.', 'opalestate-pro' ), - 'id' => 'dashboard_logo', - 'type' => 'file', - 'preview_size' => [ 100, 100 ], - 'options' => [ - 'url' => false, - ], - 'query_args' => [ - 'type' => [ - 'image/gif', - 'image/jpeg', - 'image/png', - ], - ], - ], - [ - 'name' => esc_html__( 'My Account Page', 'opalestate-pro' ), - 'desc' => esc_html__( 'This is page used for login and register an account, or reset password.', 'opalestate-pro' ), - 'id' => 'user_myaccount_page', - 'type' => 'select', - 'options' => $pages, - ], - [ - 'name' => esc_html__( 'Terms and Conditions Page', 'opalestate-pro' ), - 'desc' => esc_html__( 'This is page used for terms and conditions.', 'opalestate-pro' ), - 'id' => 'user_terms_page', - 'type' => 'select', - 'options' => $pages, - ], [ 'name' => esc_html__( 'Login and Redirect to Dashboard page', 'opalestate-pro' ), 'desc' => esc_html__( 'Redirect to User Management Dashboard page after login.', 'opalestate-pro' ), @@ -104,19 +61,6 @@ class Opalestate_Settings_General_Tab extends Opalestate_Settings_Base_Tab { 'off' => esc_html__( 'Disable', 'opalestate-pro' ), ], ], - [ - 'name' => esc_html__( 'Enable Message Database', 'opalestate-pro' ), - 'desc' => esc_html__( 'Allow User send message Contact/Equire via email and saved into database to exchange theirs message direct in User Message Management', - 'opalestate-pro' ), - 'id' => 'message_log', - 'type' => 'switch', - 'options' => [ - 'on' => esc_html__( 'Enable', 'opalestate-pro' ), - 'off' => esc_html__( 'Disable', 'opalestate-pro' ), - ], - - ], - [ 'name' => esc_html__( 'Maximum Upload Image Size', 'opalestate-pro' ), 'desc' => esc_html__( 'Set maximum volumn size having < x MB', 'opalestate-pro' ), diff --git a/inc/admin/settings/pages.php b/inc/admin/settings/pages.php new file mode 100644 index 00000000..f06b8f33 --- /dev/null +++ b/inc/admin/settings/pages.php @@ -0,0 +1,176 @@ + + * @copyright Copyright (C) 2019 wpopal.com. All Rights Reserved. + * @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html + * + * @website http://www.wpopal.com + * @support http://www.wpopal.com/support/forum.html + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly +} + +class Opalestate_Settings_Pages_Tab extends Opalestate_Settings_Base_Tab { + + public function get_tabnav() { + + } + + public function get_tab_content( $key = '' ) { + return [ + 'id' => 'options_page', + 'opalestate_title' => esc_html__( 'Pages', 'opalestate-pro' ), + 'show_on' => [ 'key' => 'options-page', 'value' => [ $key, ], ], + 'fields' => $this->get_tab_fields(), + ]; + } + + public function get_tab_fields( $key = '' ) { + $pages = opalestate_cmb2_get_post_options( [ + 'post_type' => 'page', + 'numberposts' => -1, + ] ); + + return apply_filters( 'opalestate_settings_pages', [ + [ + 'name' => esc_html__( 'Pages Settings', 'opalestate-pro' ), + + 'type' => 'opalestate_title', + 'id' => 'opalestate_title_pages_settings', + 'before_row' => '
', + 'after_row' => '
', + ], + [ + 'name' => esc_html__( 'User Management Page', 'opalestate-pro' ), + 'desc' => esc_html__( 'This is page use User Management Page using for show content of management page such as profile, my properties', 'opalestate-pro' ), + 'id' => 'user_management_page', + 'type' => 'select', + 'options' => $pages, + ], + [ + 'name' => esc_html__( 'Dashboard Logo', 'opalestate-pro' ), + 'desc' => esc_html__( 'Upload a logo for user dashboard page.', 'opalestate-pro' ), + 'id' => 'dashboard_logo', + 'type' => 'file', + 'preview_size' => [ 100, 100 ], + 'options' => [ + 'url' => false, + ], + 'query_args' => [ + 'type' => [ + 'image/gif', + 'image/jpeg', + 'image/png', + ], + ], + ], + [ + 'name' => esc_html__( 'My Account Page', 'opalestate-pro' ), + 'desc' => esc_html__( 'This is page used for login and register an account, or reset password.', 'opalestate-pro' ), + 'id' => 'user_myaccount_page', + 'type' => 'select', + 'options' => $pages, + ], + [ + 'name' => esc_html__( 'Terms and Conditions Page', 'opalestate-pro' ), + 'desc' => esc_html__( 'This is page used for terms and conditions.', 'opalestate-pro' ), + 'id' => 'user_terms_page', + 'type' => 'select', + 'options' => $pages, + ], + [ + 'name' => esc_html__( 'Dashboard Settings', 'opalestate-pro' ), + + 'type' => 'opalestate_title', + 'id' => 'opalestate_title_pages_dashboard', + 'desc' => esc_html__( 'Settings for User Management Dashboard.', 'opalestate-pro' ), + 'before_row' => '
', + 'after_row' => '
', + ], + [ + 'name' => esc_html__( 'Show Profile', 'opalestate-pro' ), + 'desc' => esc_html__( 'Show Profile menu page.', 'opalestate-pro' ), + 'id' => 'enable_dashboard_profile', + 'type' => 'switch', + 'options' => [ + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), + ], + 'default' => 'on', + ], + [ + 'name' => esc_html__( 'Show Favorite', 'opalestate-pro' ), + 'desc' => esc_html__( 'Show Favorite menu page.', 'opalestate-pro' ), + 'id' => 'enable_dashboard_favorite', + 'type' => 'switch', + 'options' => [ + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), + ], + 'default' => 'on', + ], + [ + 'name' => esc_html__( 'Show Reviews', 'opalestate-pro' ), + 'desc' => esc_html__( 'Show Reviews menu page.', 'opalestate-pro' ), + 'id' => 'enable_dashboard_reviews', + 'type' => 'switch', + 'options' => [ + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), + ], + 'default' => 'on', + ], + [ + 'name' => esc_html__( 'Enable Message Database', 'opalestate-pro' ), + 'desc' => esc_html__( 'Allow User send message Contact/Equire via email and saved into database to exchange theirs message direct in User Message Management', + 'opalestate-pro' ), + 'id' => 'message_log', + 'type' => 'switch', + 'options' => [ + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), + ], + ], + [ + 'name' => esc_html__( 'Show Submission', 'opalestate-pro' ), + 'desc' => esc_html__( 'Show Submission menu page.', 'opalestate-pro' ), + 'id' => 'enable_dashboard_submission', + 'type' => 'switch', + 'options' => [ + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), + ], + 'default' => 'on', + ], + [ + 'name' => esc_html__( 'Show Properties', 'opalestate-pro' ), + 'desc' => esc_html__( 'Show My Properties menu page.', 'opalestate-pro' ), + 'id' => 'enable_dashboard_properties', + 'type' => 'switch', + 'options' => [ + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), + ], + 'default' => 'on', + ], + [ + 'name' => esc_html__( 'Show Saved Search', 'opalestate-pro' ), + 'desc' => esc_html__( 'Show Saved Search menu page.', 'opalestate-pro' ), + 'id' => 'enable_dashboard_savedsearch', + 'type' => 'switch', + 'options' => [ + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), + ], + 'default' => 'on', + ], + ] + ); + } +} diff --git a/inc/user/class-opalestate-user-search.php b/inc/user/class-opalestate-user-search.php index 406dc1be..828d603c 100755 --- a/inc/user/class-opalestate-user-search.php +++ b/inc/user/class-opalestate-user-search.php @@ -188,12 +188,14 @@ class OpalEstate_User_Search { * */ public function dashboard_menu( $menu ) { - $menu['savedsearch'] = [ - 'icon' => 'fa fa-search', - 'link' => 'saved_search', - 'title' => esc_html__( 'Saved Search', 'opalestate-pro' ), - 'id' => 0, - ]; + if ( 'on' === opalestate_get_option( 'enable_dashboard_savedsearch', 'on' ) ) { + $menu['savedsearch'] = [ + 'icon' => 'fa fa-search', + 'link' => 'saved_search', + 'title' => esc_html__( 'Saved Search', 'opalestate-pro' ), + 'id' => 0, + ]; + } return $menu; } diff --git a/inc/user/functions.php b/inc/user/functions.php index f91c1ca4..76ab8aa3 100755 --- a/inc/user/functions.php +++ b/inc/user/functions.php @@ -69,10 +69,10 @@ function opalestate_get_user_tab_uri( $tab ) { function opalestate_management_show_content_page_tab() { - - $tab = isset( $_GET['tab'] ) && $_GET['tab'] ? sanitize_text_field( $_GET['tab'] ) : 'dashboard'; - - $fnc = 'opalestate_user_content_' . $tab . '_page'; + $tab = isset( $_GET['tab'] ) && $_GET['tab'] ? sanitize_text_field( $_GET['tab'] ) : 'dashboard'; + $tab_hook = $tab; + $tab_hook = apply_filters( 'opalestate_user_content_tab_hook', $tab_hook, $tab ); + $fnc = 'opalestate_user_content_' . $tab_hook . '_page'; $content = apply_filters( $fnc, '' ); @@ -144,64 +144,7 @@ function opalestate_management_user_menu() { function opalestate_management_user_menu_tabs() { - - global $opalestate_options; - $menu = []; - - $menu['dashboard'] = [ - 'icon' => 'fas fa-chart-line', - 'link' => 'dashboard', - 'title' => esc_html__( 'Dashboard', 'opalestate-pro' ), - 'id' => isset( $opalestate_options['profile_page'] ) ? $opalestate_options['profile_page'] : 0, - ]; - - $menu['profile'] = [ - 'icon' => 'far fa-user', - 'link' => 'profile', - 'title' => esc_html__( 'Personal Information', 'opalestate-pro' ), - 'id' => isset( $opalestate_options['profile_page'] ) ? $opalestate_options['profile_page'] : 0, - ]; - - $menu['favorite'] = [ - 'icon' => 'far fa-heart', - 'link' => 'favorite', - 'title' => esc_html__( 'Favorite', 'opalestate-pro' ), - 'id' => isset( $opalestate_options['favorite_page'] ) ? $opalestate_options['favorite_page'] : 0, - ]; - - $menu['reviews'] = [ - 'icon' => 'far fa-star', - 'link' => 'reviews', - 'title' => esc_html__( 'Reviews', 'opalestate-pro' ), - 'id' => isset( $opalestate_options['reviews_page'] ) ? $opalestate_options['reviews_page'] : 0, - ]; - - if ( opalestate_get_option( 'message_log' ) ) { - $menu['messages'] = [ - 'icon' => 'fa fa-envelope', - 'link' => 'messages', - 'title' => esc_html__( 'Messages', 'opalestate-pro' ), - 'id' => isset( $opalestate_options['reviews_page'] ) ? $opalestate_options['reviews_page'] : 0, - ]; - } - - $menu['submission'] = [ - 'icon' => 'fa fa-upload', - 'link' => 'submission', - 'title' => esc_html__( 'Submit Property', 'opalestate-pro' ), - 'id' => isset( $opalestate_options['submission_page'] ) ? $opalestate_options['submission_page'] : 0, - ]; - - $statistics = new OpalEstate_User_Statistics(); - - $menu['myproperties'] = [ - 'icon' => 'fas fa-building', - 'link' => 'submission_list', - 'title' => esc_html__( 'My Properties', 'opalestate-pro' ) . '' . $statistics->get_count_properties() . '', - 'id' => isset( $opalestate_options['submission_list_page'] ) ? $opalestate_options['submission_list_page'] : 0, - ]; - - $menu = apply_filters( 'opalestate_management_user_menu', $menu ); + $menu = opalestate_get_user_dashboard_menus(); $output = '