diff --git a/inc/user/class-user-statistics.php b/inc/user/class-user-statistics.php index cea527da..c52bbf27 100755 --- a/inc/user/class-user-statistics.php +++ b/inc/user/class-user-statistics.php @@ -1,29 +1,39 @@ -user_id = get_current_user_id(); - } - - public function get_count_properties() { - $query = Opalestate_Query::get_properties_by_user( array(), $this->user_id ); - return $query->found_posts; - } - - public function get_count_featured() { - $query = Opalestate_Query::get_properties_by_user( array( - 'featured' => 1 - ), $this->user_id ); - return $query->found_posts; - } - - public function get_count_pending_properties() { - $query = Opalestate_Query::get_properties_by_user( array( - 'post_status' => 'pending' - ), $this->user_id ); - return $query->found_posts; - } +class OpalEstate_User_Statistics { + public $user_id; + public function __construct() { + $this->user_id = get_current_user_id(); } -?> \ No newline at end of file + + public function get_count_properties() { + $query = Opalestate_Query::get_properties_by_user( [], $this->user_id ); + + return $query->found_posts; + } + + public function get_count_featured() { + $query = Opalestate_Query::get_properties_by_user( [ + 'featured' => 1, + ], $this->user_id ); + + return $query->found_posts; + } + + public function get_count_published_properties() { + $query = Opalestate_Query::get_properties_by_user( [ + 'post_status' => 'publish', + ], $this->user_id ); + + return $query->found_posts; + } + + public function get_count_pending_properties() { + $query = Opalestate_Query::get_properties_by_user( [ + 'post_status' => 'pending', + ], $this->user_id ); + + return $query->found_posts; + } +} diff --git a/inc/user/functions.php b/inc/user/functions.php index ae6fc64f..59b281cb 100755 --- a/inc/user/functions.php +++ b/inc/user/functions.php @@ -164,10 +164,12 @@ function opalestate_management_user_menu_tabs() { 'id' => isset( $opalestate_options['submission_page'] ) ? $opalestate_options['submission_page'] : 0, ]; + $statistics = new OpalEstate_User_Statistics(); + $menu['myproperties'] = [ 'icon' => 'fa fa-building', 'link' => 'submission_list', - 'title' => esc_html__( 'My Properties', 'opalestate-pro' ), + 'title' => esc_html__( 'My Properties', 'opalestate-pro' ) . '' . $statistics->get_count_properties() . '', 'id' => isset( $opalestate_options['submission_list_page'] ) ? $opalestate_options['submission_list_page'] : 0, ]; @@ -255,5 +257,3 @@ if ( ! function_exists( 'opalestate_create_user' ) ) { return $user_id; } } - -?> diff --git a/inc/vendors/cmb2-plugins/cmb2/custom-fields/iconpicker/assets/script.js b/inc/vendors/cmb2-plugins/cmb2/custom-fields/iconpicker/assets/script.js new file mode 100755 index 00000000..03d5becb --- /dev/null +++ b/inc/vendors/cmb2-plugins/cmb2/custom-fields/iconpicker/assets/script.js @@ -0,0 +1,49 @@ +(function( $ ) { + 'use strict'; + $( document ).ready( function() { + + + $( ".adduser-team" ).delegate( ".remove-user", "click", function() { + if( confirm( $(this).data('alert') ) ){ + $(this).parents( '.user-team' ).remove(); + } + }); + + $( '.opalestate-add-user-field' ).each( function() { + var $this = $(this); + $('.button', this).click( function () { + + + var user_search = $( '.opalestate-adduser-search', $(this).parent().parent() ).val(); + + + $('.opalestate-ajax').show(); + + var data = { + action: 'opalestate_ajax_search_username', + user_name: user_search, + + }; + + + + $.ajax({ + type: "POST", + data: data, + dataType: "json", + url: ajaxurl, + success: function ( response ) { + if( response.status == true ){ + var template = wp.template( 'adduser-team-template' ); + $('.adduser-team', $this ).append( template( response.user ) ); + }else { + alert( response.message ); + } + } + }); + + } ); + } ); + } ); + +})( jQuery ); \ No newline at end of file diff --git a/inc/vendors/cmb2-plugins/cmb2/custom-fields/iconpicker/assets/style.css b/inc/vendors/cmb2-plugins/cmb2/custom-fields/iconpicker/assets/style.css new file mode 100755 index 00000000..aa9106a3 --- /dev/null +++ b/inc/vendors/cmb2-plugins/cmb2/custom-fields/iconpicker/assets/style.css @@ -0,0 +1,29 @@ +.adduser-team{ + width: 80%; +} +.user-team{ + padding: 12px 10px; + display: block; + border-bottom: solid 1px #f3f3f3 +} +.user-team > div{ + display: inline-block; + width: 33%; + +} + +.user-team > div img{ + width: 30px; + height: 30px; + border: solid 3px #CCC; + border-radius: 50%; + float: left; + margin-right: 6px; +} + +.remove-user { + cursor: pointer; +} +.remove-user:hover { + color: red; +} \ No newline at end of file diff --git a/inc/vendors/cmb2-plugins/cmb2/custom-fields/iconpicker/iconpicker.php b/inc/vendors/cmb2-plugins/cmb2/custom-fields/iconpicker/iconpicker.php new file mode 100755 index 00000000..6e2ad67a --- /dev/null +++ b/inc/vendors/cmb2-plugins/cmb2/custom-fields/iconpicker/iconpicker.php @@ -0,0 +1,95 @@ + + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly +} + +class Opalestate_Field_Iconpicker { + + /** + * Current version number + */ + const VERSION = '1.0.0'; + + /** + * Initialize the plugin by hooking into CMB2 + */ + public static function init() { + add_filter( 'cmb2_render_opal_iconpicker', [ __CLASS__, 'render_iconpicker' ], 10, 5 ); + add_filter( 'cmb2_sanitize_opal_iconpicker', [ __CLASS__, 'sanitize_map' ], 10, 4 ); + } + + /** + * Render field + */ + public static function render_iconpicker( $field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object ) { + self::setup_admin_scripts(); + + $users = $field->value; + + echo '
'; ?> +
+
+
+

+ +
+ +
+
+
+
+
+
+
+ + data ?> +
+ +
+ + user_login; ?>
+
+
+ + + +
+
+ + + + '; + } + + /** + * Optionally save the latitude/longitude values into two custom fields + */ + public static function sanitize_map( $override_value, $value, $object_id, $field_args ) { + return $value; + } + + /** + * Enqueue scripts and styles + */ + public static function setup_admin_scripts() { + wp_enqueue_script( 'opalestate-adduser', plugins_url( 'assets/script.js', __FILE__ ), [], self::VERSION ); + wp_enqueue_style( 'opalestate-adduser', plugins_url( 'assets/style.css', __FILE__ ), [], self::VERSION ); + } +} + +Opalestate_Field_Iconpicker::init(); diff --git a/inc/vendors/cmb2-plugins/cmb2/custom-fields/user/user.php b/inc/vendors/cmb2-plugins/cmb2/custom-fields/user/user.php index 4561f746..61c69561 100755 --- a/inc/vendors/cmb2-plugins/cmb2/custom-fields/user/user.php +++ b/inc/vendors/cmb2-plugins/cmb2/custom-fields/user/user.php @@ -1,20 +1,15 @@ - * @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_Field_Adduser { /** @@ -26,8 +21,8 @@ class Opalestate_Field_Adduser { * Initialize the plugin by hooking into CMB2 */ public static function init() { - add_filter( 'cmb2_render_adduser', array( __CLASS__, 'render_map' ), 10, 5 ); - add_filter( 'cmb2_sanitize_adduser', array( __CLASS__, 'sanitize_map' ), 10, 4 ); + add_filter( 'cmb2_render_adduser', [ __CLASS__, 'render_map' ], 10, 5 ); + add_filter( 'cmb2_sanitize_adduser', [ __CLASS__, 'sanitize_map' ], 10, 4 ); } /** @@ -38,53 +33,53 @@ class Opalestate_Field_Adduser { $users = $field->value; - // echo '
'.print_r( $value, 1 );die;
-		echo '
'; ?> -
-
-
-

- -
+ echo '
'; ?> +
+
+
+

-
-
-
-
-
-
- - - data ?> -
- - -
-
- - - -
-
+
- +
+
+
+
+
+
+
+ + data ?> +
+ + +
+
+ - '; + +
+
+ + + + '; } /** * Optionally save the latitude/longitude values into two custom fields */ public static function sanitize_map( $override_value, $value, $object_id, $field_args ) { - return $value; } @@ -92,8 +87,8 @@ class Opalestate_Field_Adduser { * Enqueue scripts and styles */ public static function setup_admin_scripts() { - wp_enqueue_script( 'opalestate-adduser', plugins_url( 'assets/script.js', __FILE__ ), array( ), self::VERSION ); - wp_enqueue_style( 'opalestate-adduser', plugins_url( 'assets/style.css', __FILE__ ), array(), self::VERSION ); + wp_enqueue_script( 'opalestate-adduser', plugins_url( 'assets/script.js', __FILE__ ), [], self::VERSION ); + wp_enqueue_style( 'opalestate-adduser', plugins_url( 'assets/style.css', __FILE__ ), [], self::VERSION ); } } diff --git a/templates/user/agency/agency-team.php b/templates/user/agency/agency-team.php index 8cf7e8e2..b1c108fd 100755 --- a/templates/user/agency/agency-team.php +++ b/templates/user/agency/agency-team.php @@ -20,6 +20,7 @@ $fields = [ 'required' => 'required', ], ]; + $form = OpalEstate()->html->render_form( $fields ); $id = 'agency-add-member'; ?> diff --git a/templates/user/dashboard.php b/templates/user/dashboard.php index 6053d889..65ff3be4 100755 --- a/templates/user/dashboard.php +++ b/templates/user/dashboard.php @@ -8,31 +8,31 @@ $properties_count = []; $properties_count[] = [ 'icon' => 'fa fa-list', - 'count' => $statistics->get_count_properties(), - 'label' => esc_html__( 'My Properties', 'opalestate-pro' ), - 'class' => '', + 'count' => $statistics->get_count_published_properties(), + 'label' => esc_html__( 'Published Listings', 'opalestate-pro' ), + 'class' => 'dash-published-listings', ]; $properties_count[] = [ 'icon' => 'fa fa-star', 'count' => $statistics->get_count_featured(), - 'label' => esc_html__( 'Featured Properties', 'opalestate-pro' ), - 'class' => '', + 'label' => esc_html__( 'Featured Listings', 'opalestate-pro' ), + 'class' => 'dash-featured-listings', ]; $properties_count[] = [ 'icon' => 'fa fa-file', 'count' => $statistics->get_count_pending_properties(), 'label' => esc_html__( 'Pending Properties', 'opalestate-pro' ), - 'class' => '', + 'class' => 'dash-pending-listings', ]; ?>
-
-
-
+
+
+
@@ -49,9 +49,12 @@ $comments = get_comments( $args ); ?> -
+
-
+
+ +