Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/realpress/app/Controllers/BecomeAgentController.php
+++ b/realpress/app/Controllers/BecomeAgentController.php
@@ -1,205 +1,205 @@
-<?php
-
-namespace RealPressControllers;
-
-use RealPressHelpersValidation;
-use RealPressModelsUserModel;
-use RealPressHelpersRestApi;
-use RealPressHelpersSettings;
-use WP_REST_Server;
-
-/**
- * Class BecomeAgentController
- * @package RealPressControllers
- */
-class BecomeAgentController {
-
- /**
- * BecomeAgentController constructor.
- */
- public function __construct() {
- add_filter( 'views_users', array( $this, 'views_users' ), 10, 1 );
- add_filter( 'user_row_actions', array( $this, 'user_row_actions' ), 10, 2 );
- add_filter( 'users_list_table_query_args', array( $this, 'display_only_pending_requests' ) );
- add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) );
- add_action( 'admin_init', array( $this, 'handle_become_an_agent' ) );
- }
-
- public function handle_become_an_agent() {
- if ( ! current_user_can( 'administrator' ) ) {
- return;
- }
-
- $action = Validation::sanitize_params_submitted( $_GET['realpress-action'] ?? '' );
- $user_id = Validation::sanitize_params_submitted( $_GET['user_id'] ?? '' );
- if ( empty( $action ) || empty( $user_id ) ) {
- return;
- }
-
- if ( ! get_user_by( 'id', $user_id ) ) {
- return;
- }
-
- $nonce_map = [
- 'accept-request' => 'realpress_accept_agent_action',
- 'deny-request' => 'realpress_deny_agent_action',
- ];
-
- if ( ! isset( $nonce_map[ $action ] ) ) {
- return;
- }
-
- if (
- ! isset( $_GET['_wpnonce'] ) ||
- ! wp_verify_nonce( $_GET['_wpnonce'], $nonce_map[ $action ] )
- ) {
- return;
- }
-
- if ( in_array( $action, array( 'accept-request', 'deny-request' ) ) ) {
- delete_user_meta( $user_id, REALPRESS_PREFIX . '_become_an_agent_request' );
-
- if ( $action === 'accept-request' ) {
- $user = new WP_User( $user_id );
- $user->remove_role( 'subscriber' );
- $user->add_role( REALPRESS_AGENT_ROLE );
- do_action( 'realpress/agent/become-an-agent/approve', $user_id );
- wp_redirect( admin_url( 'users.php?realpress-action=accepted-request&user_id=' . $user_id ) );
- } else {
- do_action( 'realpress/agent/become-an-agent/reject', $user_id );
- wp_redirect( admin_url( 'users.php?realpress-action=denied-request&user_id=' . $user_id ) );
- }
- die();
- }
- }
-
- public function views_users( $views ) {
- $pending_requests = UserModel::get_pending_requests();
- if ( $pending_requests ) {
- $action = Validation::sanitize_params_submitted( $_GET['realpress-action'] ?? '' );
- if ( $action === 'pending-request' ) {
- $class = ' class="current"';
- foreach ( $views as $k => $view ) {
- $views[ $k ] = preg_replace( '!class="current"!', '', $view );
- }
- } else {
- $class = '';
- }
-
- $views['pending-request'] = '<a href="' . admin_url( 'users.php?realpress-action=pending-request' ) . '"' . $class . '>'
- . sprintf( __( 'Pending Request <span class="count">(%s)</span>', 'realpress' ), count( $pending_requests ) ) . '</a>';
- }
-
- return $views;
- }
-
- /**
- * @param $actions
- * @param $user
- *
- * @return array|mixed
- */
- public function user_row_actions( $actions, $user ) {
- $pending_request = UserModel::get_pending_requests();
- $action = Validation::sanitize_params_submitted( $_GET['realpress-action'] ?? '' );
- if ( $action === 'pending-request' && $pending_request ) {
- $actions = array();
- if ( in_array( $user->ID, $pending_request ) ) {
- $actions['accept'] = sprintf(
- '<a href="' .wp_nonce_url(
- admin_url( 'users.php?realpress-action=accept-request&user_id=' . $user->ID ),
- 'realpress_accept_agent_action',
- '_wpnonce'
- ) . '">%s</a>',
- _x( 'Accept', 'pending-request', 'realpress' )
- );
- $actions['delete deny'] = sprintf(
- '<a class="submitdelete" href="' .wp_nonce_url(
- admin_url( 'users.php?realpress-action=deny-request&user_id=' . $user->ID ) ,
- 'realpress_deny_agent_action',
- '_wpnonce',
- ). '">%s</a>',
- _x( 'Deny', 'pending-request', 'realpress' )
- );
- }
- }
-
- return $actions;
- }
-
- public function display_only_pending_requests( $args ) {
- $action = Validation::sanitize_params_submitted( $_GET['realpress-action'] ?? '' );
- if ( $action === 'pending-request' ) {
- $args['include'] = UserModel::get_pending_requests();
- }
-
- return $args;
- }
-
- public function register_rest_routes() {
- do_action('realpress/rest-api/before-register');
-
- register_rest_route(
- RestApi::generate_namespace(),
- '/become-an-agent',
- array(
- 'methods' => WP_REST_Server::CREATABLE,
- 'callback' => array( $this, 'become_an_agent' ),
- 'permission_callback' => '__return_true',
- ),
- );
- }
-
- public function become_an_agent( WP_REST_Request $request ) {
- $params = $request->get_params();
- $args = array(
- 'first_name' => $params['first_name'] ?? '',
- 'last_name' => $params['last_name'] ?? '',
- 'agency_name' => $params['agency_name'] ?? '',
- 'phone_number' => $params['phone_number'] ?? '',
- 'additional_info' => $params['additional_info'] ?? '',
- 'terms_and_conditions' => $params['terms_and_conditions'] ?? false,
- );
-
- if ( ! is_user_logged_in() ) {
- return RestApi::error( esc_html__( 'You must log in to submit to become an Agent.', 'realpress' ), 401 );
- }
-
- $user_id = get_current_user_id();
- $user_roles = UserModel::get_field( $user_id, 'roles' );
- if ( ! in_array( 'subscriber', $user_roles ) ) {
- return RestApi::error( esc_html__( 'You don't have permission to do it.', 'realpress' ), 403 );
- }
-
- if ( empty( $args['first_name'] ) ) {
- return RestApi::error( esc_html__( 'The first name is required.', 'realpress' ), 400 );
- }
-
- if ( empty( $args['last_name'] ) ) {
- return RestApi::error( esc_html__( 'The last name is required.', 'realpress' ), 400 );
- }
-
- if ( empty( $args['phone_number'] ) ) {
- return RestApi::error( esc_html__( 'The phone number is required.', 'realpress' ), 400 );
- }
-
- if ( empty( $args['terms_and_conditions'] ) ) {
- return RestApi::error( esc_html__( 'Please accept the Terms and Conditions.', 'realpress' ), 400 );
- }
-
- $user = new WP_User( $user_id );
- $automatic_approve = Settings::get_setting_detail( 'group:agent:fields:automatically_approve' );
- if ( $automatic_approve ) {
- $user->remove_role( 'subscriber' );
- $user->add_role( REALPRESS_AGENT_ROLE );
- do_action( 'realpress/agent/become-an-agent/approve', $user_id );
-
- return RestApi::success( esc_html__( 'Thank you! You became an Agent.', 'realpress' ), array() );
- } else {
- update_user_meta( $user_id, REALPRESS_PREFIX . '_become_an_agent_request', 'yes' );
- do_action( 'realpress/agent/become-an-agent/request', $user_id, $args );
-
- return RestApi::success( esc_html__( 'Thank you! Your request has been sent.', 'realpress' ), array() );
- }
- }
-}
+<?php
+
+namespace RealPressControllers;
+
+use RealPressHelpersValidation;
+use RealPressModelsUserModel;
+use RealPressHelpersRestApi;
+use RealPressHelpersSettings;
+use WP_REST_Server;
+
+/**
+ * Class BecomeAgentController
+ * @package RealPressControllers
+ */
+class BecomeAgentController {
+
+ /**
+ * BecomeAgentController constructor.
+ */
+ public function __construct() {
+ add_filter( 'views_users', array( $this, 'views_users' ), 10, 1 );
+ add_filter( 'user_row_actions', array( $this, 'user_row_actions' ), 10, 2 );
+ add_filter( 'users_list_table_query_args', array( $this, 'display_only_pending_requests' ) );
+ add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) );
+ add_action( 'admin_init', array( $this, 'handle_become_an_agent' ) );
+ }
+
+ public function handle_become_an_agent() {
+ if ( ! current_user_can( 'administrator' ) ) {
+ return;
+ }
+
+ $action = Validation::sanitize_params_submitted( $_GET['realpress-action'] ?? '' );
+ $user_id = Validation::sanitize_params_submitted( $_GET['user_id'] ?? '' );
+ if ( empty( $action ) || empty( $user_id ) ) {
+ return;
+ }
+
+ if ( ! get_user_by( 'id', $user_id ) ) {
+ return;
+ }
+
+ $nonce_map = [
+ 'accept-request' => 'realpress_accept_agent_action',
+ 'deny-request' => 'realpress_deny_agent_action',
+ ];
+
+ if ( ! isset( $nonce_map[ $action ] ) ) {
+ return;
+ }
+
+ if (
+ ! isset( $_GET['_wpnonce'] ) ||
+ ! wp_verify_nonce( $_GET['_wpnonce'], $nonce_map[ $action ] )
+ ) {
+ return;
+ }
+
+ if ( in_array( $action, array( 'accept-request', 'deny-request' ) ) ) {
+ delete_user_meta( $user_id, REALPRESS_PREFIX . '_become_an_agent_request' );
+
+ if ( $action === 'accept-request' ) {
+ $user = new WP_User( $user_id );
+ $user->remove_role( 'subscriber' );
+ $user->add_role( REALPRESS_AGENT_ROLE );
+ do_action( 'realpress/agent/become-an-agent/approve', $user_id );
+ wp_redirect( admin_url( 'users.php?realpress-action=accepted-request&user_id=' . $user_id ) );
+ } else {
+ do_action( 'realpress/agent/become-an-agent/reject', $user_id );
+ wp_redirect( admin_url( 'users.php?realpress-action=denied-request&user_id=' . $user_id ) );
+ }
+ die();
+ }
+ }
+
+ public function views_users( $views ) {
+ $pending_requests = UserModel::get_pending_requests();
+ if ( $pending_requests ) {
+ $action = Validation::sanitize_params_submitted( $_GET['realpress-action'] ?? '' );
+ if ( $action === 'pending-request' ) {
+ $class = ' class="current"';
+ foreach ( $views as $k => $view ) {
+ $views[ $k ] = preg_replace( '!class="current"!', '', $view );
+ }
+ } else {
+ $class = '';
+ }
+
+ $views['pending-request'] = '<a href="' . admin_url( 'users.php?realpress-action=pending-request' ) . '"' . $class . '>'
+ . sprintf( __( 'Pending Request <span class="count">(%s)</span>', 'realpress' ), count( $pending_requests ) ) . '</a>';
+ }
+
+ return $views;
+ }
+
+ /**
+ * @param $actions
+ * @param $user
+ *
+ * @return array|mixed
+ */
+ public function user_row_actions( $actions, $user ) {
+ $pending_request = UserModel::get_pending_requests();
+ $action = Validation::sanitize_params_submitted( $_GET['realpress-action'] ?? '' );
+ if ( $action === 'pending-request' && $pending_request ) {
+ $actions = array();
+ if ( in_array( $user->ID, $pending_request ) ) {
+ $actions['accept'] = sprintf(
+ '<a href="' .wp_nonce_url(
+ admin_url( 'users.php?realpress-action=accept-request&user_id=' . $user->ID ),
+ 'realpress_accept_agent_action',
+ '_wpnonce'
+ ) . '">%s</a>',
+ _x( 'Accept', 'pending-request', 'realpress' )
+ );
+ $actions['delete deny'] = sprintf(
+ '<a class="submitdelete" href="' .wp_nonce_url(
+ admin_url( 'users.php?realpress-action=deny-request&user_id=' . $user->ID ) ,
+ 'realpress_deny_agent_action',
+ '_wpnonce',
+ ). '">%s</a>',
+ _x( 'Deny', 'pending-request', 'realpress' )
+ );
+ }
+ }
+
+ return $actions;
+ }
+
+ public function display_only_pending_requests( $args ) {
+ $action = Validation::sanitize_params_submitted( $_GET['realpress-action'] ?? '' );
+ if ( $action === 'pending-request' ) {
+ $args['include'] = UserModel::get_pending_requests();
+ }
+
+ return $args;
+ }
+
+ public function register_rest_routes() {
+ do_action('realpress/rest-api/before-register');
+
+ register_rest_route(
+ RestApi::generate_namespace(),
+ '/become-an-agent',
+ array(
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => array( $this, 'become_an_agent' ),
+ 'permission_callback' => '__return_true',
+ ),
+ );
+ }
+
+ public function become_an_agent( WP_REST_Request $request ) {
+ $params = $request->get_params();
+ $args = array(
+ 'first_name' => $params['first_name'] ?? '',
+ 'last_name' => $params['last_name'] ?? '',
+ 'agency_name' => $params['agency_name'] ?? '',
+ 'phone_number' => $params['phone_number'] ?? '',
+ 'additional_info' => $params['additional_info'] ?? '',
+ 'terms_and_conditions' => $params['terms_and_conditions'] ?? false,
+ );
+
+ if ( ! is_user_logged_in() ) {
+ return RestApi::error( esc_html__( 'You must log in to submit to become an Agent.', 'realpress' ), 401 );
+ }
+
+ $user_id = get_current_user_id();
+ $user_roles = UserModel::get_field( $user_id, 'roles' );
+ if ( ! in_array( 'subscriber', $user_roles ) ) {
+ return RestApi::error( esc_html__( 'You don't have permission to do it.', 'realpress' ), 403 );
+ }
+
+ if ( empty( $args['first_name'] ) ) {
+ return RestApi::error( esc_html__( 'The first name is required.', 'realpress' ), 400 );
+ }
+
+ if ( empty( $args['last_name'] ) ) {
+ return RestApi::error( esc_html__( 'The last name is required.', 'realpress' ), 400 );
+ }
+
+ if ( empty( $args['phone_number'] ) ) {
+ return RestApi::error( esc_html__( 'The phone number is required.', 'realpress' ), 400 );
+ }
+
+ if ( empty( $args['terms_and_conditions'] ) ) {
+ return RestApi::error( esc_html__( 'Please accept the Terms and Conditions.', 'realpress' ), 400 );
+ }
+
+ $user = new WP_User( $user_id );
+ $automatic_approve = Settings::get_setting_detail( 'group:agent:fields:automatically_approve' );
+ if ( $automatic_approve ) {
+ $user->remove_role( 'subscriber' );
+ $user->add_role( REALPRESS_AGENT_ROLE );
+ do_action( 'realpress/agent/become-an-agent/approve', $user_id );
+
+ return RestApi::success( esc_html__( 'Thank you! You became an Agent.', 'realpress' ), array() );
+ } else {
+ update_user_meta( $user_id, REALPRESS_PREFIX . '_become_an_agent_request', 'yes' );
+ do_action( 'realpress/agent/become-an-agent/request', $user_id, $args );
+
+ return RestApi::success( esc_html__( 'Thank you! Your request has been sent.', 'realpress' ), array() );
+ }
+ }
+}
--- a/realpress/app/Controllers/PropertyController.php
+++ b/realpress/app/Controllers/PropertyController.php
@@ -1,414 +1,414 @@
-<?php
-
-namespace RealPressControllers;
-
-use RealPressHelpersRestApi;
-use RealPressHelpersTemplate;
-use RealPressHelpersConfig;
-use RealPressHelpersSettings;
-use RealPressModelsPropertyMetaModel;
-use RealPressModelsPropertyModel;
-use WP_REST_Server;
-
-/**
- * Class PropertyController
- * @package RealPressControllers
- */
-class PropertyController {
- public function __construct() {
- add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) );
- add_filter(
- 'manage_edit-' . REALPRESS_PROPERTY_CPT . '_columns',
- array(
- $this,
- 'add_header_thumbnail_column',
- )
- );
- add_filter(
- 'manage_' . 'posts' . '_custom_column',
- array(
- $this,
- 'add_content_thumbnail_column',
- ),
- 10,
- 2
- );
- }
-
- /**
- * @param $column
- * @param $post_id
- *
- * @return void
- */
- public function add_content_thumbnail_column( $column, $post_id ) {
- switch ( $column ) {
- case 'realpress-property-thumbnail':
- $image_url = PropertyModel::get_post_thumbnail_url( $post_id );
- ?>
- <img src="<?php echo esc_url_raw( $image_url ); ?>" alt="<?php echo get_the_title( $post_id ); ?>">
- <?php
- break;
- default:
- break;
- }
- }
-
- /**
- * @param $columns
- *
- * @return mixed
- */
- public function add_header_thumbnail_column( $columns ) {
- $columns['realpress-property-thumbnail'] = esc_html__( 'Thumbnail', 'realpress' );
-
- return $columns;
- }
-
- /**
- * @return void
- */
- public function register_rest_routes() {
- do_action('realpress/rest-api/before-register');
-
- register_rest_route(
- RestApi::generate_namespace(),
- '/properties',
- array(
- 'methods' => WP_REST_Server::READABLE,
- 'callback' => array( $this, 'get_properties' ),
- 'args' => array(
- 'posts_per_page' => array(
- 'required' => false,
- 'type' => 'integer',
- 'description' => 'The posts per page must be an integer',
- ),
- 'page' => array(
- 'required' => false,
- 'type' => 'integer',
- 'description' => 'The page must be an integer',
- ),
- ),
- 'permission_callback' => '__return_true',
- ),
- );
- }
-
- /**
- * @param WP_REST_Request $request
- *
- * @return WP_REST_Response
- */
- public function get_properties( WP_REST_Request $request ) {
- $params = $request->get_params();
-
- global $rp_lang;
-
- if ( isset( $params['pll_current_lang'] ) ) {
- $rp_lang = $params['pll_current_lang'];
- }
-
- if ( isset( $params['wpml_current_lang'] ) ) {
- $rp_lang = $params['wpml_current_lang'];
- }
-
- $args = $this->parse_args( $params );
-
- $data = array();
-
- $query = new WP_Query( $args );
-
- $template = Template::instance();
-
- $properties = array();
- //Content
- ob_start();
- if ( $query->have_posts() ) {
- while ( $query->have_posts() ) {
- $query->the_post();
-
- if ( isset( $params['loop-item-id'] ) && $params['loop-item-id'] ) {
- Thim_EL_KitUtilitiesElementor::instance()->render_loop_item_content( $params['loop-item-id'] );
- } else {
- $template->get_frontend_template_type_classic(
- apply_filters( 'realpress/filter/property-list/property-item', 'shared/property-list/property-item.php' ),
- array(
- 'data' => PropertyModel::get_property_list_item_data( get_the_ID() ),
- )
- );
- }
-
- $properties[] = PropertyModel::get_property_list_item_data( get_the_ID() );
- }
- wp_reset_postdata();
- } else {
- return RestApi::success( esc_html__( 'No property found.', 'realpress' ), array() );
- }
-
- $data['content'] = ob_get_clean();
- $data['property'] = $properties;
-
- //Paginate
- $paginate_args = array(
- 'paged' => $args['paged'],
- 'pagination_type' => $params['pagination_type'] ?? '',
- 'max_pages' => $query->max_num_pages,
- 'total' => $query->found_posts,
- 'item_per_page' => $args['posts_per_page'],
- 'type' => 'property',
- );
-
- RestApi::add_pagination_data( $data, $paginate_args );
-
- return RestApi::success( '', $data );
- }
-
- /**
- * @param $params
- *
- * @return array
- */
- public function parse_args( $params ) {
- $args = array(
- 'posts_per_page' => $params['posts_per_page'] ?? Settings::get_property_per_page(),
- 'paged' => $params['page'] ?? 1,
- 'orderby' => $params['orderby'] ?? 'date',
- 'order' => $params['order'] ?? 'asc',
- 'post_type' => REALPRESS_PROPERTY_CPT,
- );
-
- if ( isset( $params['template'] ) ) {
- if ( $params['template'] === 'similar_property' ) {
- $args['post__not_in'] = array( $params['post_id'] );
-
- $types = PropertyMetaModel::instance( $params['post_id'] )->get_property_terms( 'realpress-type' );
- $term_ids = array();
-
- if ( ! empty( $types ) ) {
- $term_ids = array_map(
- function ( $types ) {
- return $types->term_id;
- },
- $types
- );
- }
-
- $args['tax_query'] = array(
- 'relation' => 'AND',
- array(
- 'taxonomy' => 'realpress-type',
- 'field' => 'id',
- 'terms' => $term_ids,
- 'operator' => 'IN',
- ),
- );
- } elseif ( $params['template'] === 'search_suggest' ) {
- $args['posts_per_page'] = $params['posts_per_page'] ?? Settings::get_search_suggest_property_number();
- }
- }
-
- if ( isset( $params['author_id'] ) ) {
- $args['user_id'] = $params['author_id'];
- }
-
- //sort
- if ( $args['orderby'] === 'rating' ) {
- $args['meta_key'] = REALPRESS_PREFIX . '_property_average_review';
- $args['orderby'] = 'meta_value_num';
- }
-
- if ( $args['orderby'] === 'price' ) {
- $args['meta_key'] = REALPRESS_PREFIX . '_group:information:section:general:fields:price';
- $args['orderby'] = 'meta_value_num';
- }
-
- //search
- if ( ! empty( $params['keyword'] ) ) {
- $args['s'] = $params['keyword'];
-
- if ( apply_filters( 'realpress/filter/properties/search_columns/post_title' , false) ) {
- $args['search_columns'] = 'post_title';
- }
- }
-
- if ( isset( $params['room'] ) ) {
- $compare = '=';
- if ( strpos( $params['room'], '+' ) !== false ) {
- $compare = '>=';
- }
-
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:rooms',
- 'type' => 'DECIMAL',
- 'value' => $params['room'],
- 'compare' => $compare,
- );
- }
-
- if ( isset( $params['bath'] ) ) {
- $compare = '=';
- if ( strpos( $params['bath'], '+' ) !== false ) {
- $compare = '>=';
- }
-
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:bathrooms',
- 'type' => 'DECIMAL',
- 'value' => $params['bath'],
- 'compare' => $compare,
- );
- }
-
- if ( isset( $params['bed'] ) ) {
- $compare = '=';
- if ( strpos( $params['bed'], '+' ) !== false ) {
- $compare = '>=';
- }
-
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:bedrooms',
- 'type' => 'DECIMAL',
- 'value' => $params['bed'],
- 'compare' => $compare,
- );
- }
-
- if ( isset( $params['verified'] ) && $params['verified'] === 'yes' ) {
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:verified',
- 'type' => 'CHAR',
- 'value' => 'on',
- 'compare' => '=',
- );
- }
-
- //For taxonomy archive
- if ( isset( $params['term_id'] ) && isset( $params['taxonomy'] ) ) {
- $args['tax_query'][] = array(
- 'taxonomy' => $params['taxonomy'],
- 'terms' => array( $params['term_id'] ),
- 'operator' => 'IN',
- 'include_children' => false,
- );
- }
-
- //Advanced Search
- $taxonomies = array_keys( Config::instance()->get( 'property-type:taxonomies' ) );
-
- foreach ( $taxonomies as $taxonomy ) {
- $key = str_replace( array( 'realpress-', '-' ), array( '', '_' ), $taxonomy );
-
- if ( isset( $params[ $key ] ) ) {
- if ( is_string( $params[ $key ] ) ) {
- $params[ $key ] = explode( ',', $params[ $key ] );
- }
-
- // if is realpress-feature taxonomy, use AND operator, other is IN
- $tax_operator = ( $key === 'feature' ) ? 'AND' : 'IN';
-
- $args['tax_query'][] = array(
- 'taxonomy' => $taxonomy,
- 'terms' => $params[ $key ],
- 'operator' => $tax_operator,
- );
- }
- }
-
- //Price
- if ( isset( $params['min_price'] ) ) {
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:price',
- 'value' => $params['min_price'],
- 'type' => 'DECIMAL',
- 'compare' => '>=',
- );
- }
-
- if ( isset( $params['max_price'] ) ) {
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:price',
- 'value' => $params['max_price'] ,
- 'type' => 'DECIMAL',
- 'compare' => '<=',
- );
- }
-
- if ( isset( $params['min_area'] ) ) {
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:area_size',
- 'value' => $params['min_area'],
- 'type' => 'DECIMAL',
- 'compare' => '>=',
- );
- }
-
- if ( isset( $params['max_area'] ) ) {
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:area_size',
- 'value' => $params['max_area'],
- 'type' => 'DECIMAL',
- 'compare' => '<=',
- );
- }
-
- if ( isset( $params['min_year'] ) ) {
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:year_built',
- 'value' => $params['min_year'],
- 'type' => 'DECIMAL',
- 'compare' => '>=',
- );
- }
-
- if ( isset( $params['max_year'] ) ) {
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:year_built',
- 'value' => $params['max_year'],
- 'type' => 'DECIMAL',
- 'compare' => '<=',
- );
- }
-
- if ( isset( $params['property_id'] ) ) {
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:property_id',
- 'value' => $params['property_id'],
- 'compare' => 'LIKE',
- );
- }
-
- if ( ! empty( $params['has_coordinates'] ) ) {
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:map:section:enable_map:fields:enable',
- 'value' => 'on',
- 'type' => 'CHAR',
- 'compare' => '=',
- );
-
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:map:section:map:fields:lat',
- 'value' => '',
- 'type' => 'CHAR',
- 'compare' => '!=',
- );
-
- $args['meta_query'][] = array(
- 'key' => REALPRESS_PREFIX . '_group:map:section:map:fields:lng',
- 'value' => '',
- 'type' => 'CHAR',
- 'compare' => '!=',
- );
- }
-
- if ( isset( $args['meta_query'] ) ) {
- $args['meta_query']['relation'] = 'AND';
- }
-
- if ( isset( $args['tax_query'] ) ) {
- $args['tax_query']['relation'] = 'AND';
- }
-
-
- return apply_filters( 'realpress/filter/list-property/args', $args, $params );
- }
-}
+<?php
+
+namespace RealPressControllers;
+
+use RealPressHelpersRestApi;
+use RealPressHelpersTemplate;
+use RealPressHelpersConfig;
+use RealPressHelpersSettings;
+use RealPressModelsPropertyMetaModel;
+use RealPressModelsPropertyModel;
+use WP_REST_Server;
+
+/**
+ * Class PropertyController
+ * @package RealPressControllers
+ */
+class PropertyController {
+ public function __construct() {
+ add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) );
+ add_filter(
+ 'manage_edit-' . REALPRESS_PROPERTY_CPT . '_columns',
+ array(
+ $this,
+ 'add_header_thumbnail_column',
+ )
+ );
+ add_filter(
+ 'manage_' . 'posts' . '_custom_column',
+ array(
+ $this,
+ 'add_content_thumbnail_column',
+ ),
+ 10,
+ 2
+ );
+ }
+
+ /**
+ * @param $column
+ * @param $post_id
+ *
+ * @return void
+ */
+ public function add_content_thumbnail_column( $column, $post_id ) {
+ switch ( $column ) {
+ case 'realpress-property-thumbnail':
+ $image_url = PropertyModel::get_post_thumbnail_url( $post_id );
+ ?>
+ <img src="<?php echo esc_url_raw( $image_url ); ?>" alt="<?php echo get_the_title( $post_id ); ?>">
+ <?php
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * @param $columns
+ *
+ * @return mixed
+ */
+ public function add_header_thumbnail_column( $columns ) {
+ $columns['realpress-property-thumbnail'] = esc_html__( 'Thumbnail', 'realpress' );
+
+ return $columns;
+ }
+
+ /**
+ * @return void
+ */
+ public function register_rest_routes() {
+ do_action('realpress/rest-api/before-register');
+
+ register_rest_route(
+ RestApi::generate_namespace(),
+ '/properties',
+ array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array( $this, 'get_properties' ),
+ 'args' => array(
+ 'posts_per_page' => array(
+ 'required' => false,
+ 'type' => 'integer',
+ 'description' => 'The posts per page must be an integer',
+ ),
+ 'page' => array(
+ 'required' => false,
+ 'type' => 'integer',
+ 'description' => 'The page must be an integer',
+ ),
+ ),
+ 'permission_callback' => '__return_true',
+ ),
+ );
+ }
+
+ /**
+ * @param WP_REST_Request $request
+ *
+ * @return WP_REST_Response
+ */
+ public function get_properties( WP_REST_Request $request ) {
+ $params = $request->get_params();
+
+ global $rp_lang;
+
+ if ( isset( $params['pll_current_lang'] ) ) {
+ $rp_lang = $params['pll_current_lang'];
+ }
+
+ if ( isset( $params['wpml_current_lang'] ) ) {
+ $rp_lang = $params['wpml_current_lang'];
+ }
+
+ $args = $this->parse_args( $params );
+
+ $data = array();
+
+ $query = new WP_Query( $args );
+
+ $template = Template::instance();
+
+ $properties = array();
+ //Content
+ ob_start();
+ if ( $query->have_posts() ) {
+ while ( $query->have_posts() ) {
+ $query->the_post();
+
+ if ( isset( $params['loop-item-id'] ) && $params['loop-item-id'] ) {
+ Thim_EL_KitUtilitiesElementor::instance()->render_loop_item_content( $params['loop-item-id'] );
+ } else {
+ $template->get_frontend_template_type_classic(
+ apply_filters( 'realpress/filter/property-list/property-item', 'shared/property-list/property-item.php' ),
+ array(
+ 'data' => PropertyModel::get_property_list_item_data( get_the_ID() ),
+ )
+ );
+ }
+
+ $properties[] = PropertyModel::get_property_list_item_data( get_the_ID() );
+ }
+ wp_reset_postdata();
+ } else {
+ return RestApi::success( esc_html__( 'No property found.', 'realpress' ), array() );
+ }
+
+ $data['content'] = ob_get_clean();
+ $data['property'] = $properties;
+
+ //Paginate
+ $paginate_args = array(
+ 'paged' => $args['paged'],
+ 'pagination_type' => $params['pagination_type'] ?? '',
+ 'max_pages' => $query->max_num_pages,
+ 'total' => $query->found_posts,
+ 'item_per_page' => $args['posts_per_page'],
+ 'type' => 'property',
+ );
+
+ RestApi::add_pagination_data( $data, $paginate_args );
+
+ return RestApi::success( '', $data );
+ }
+
+ /**
+ * @param $params
+ *
+ * @return array
+ */
+ public function parse_args( $params ) {
+ $args = array(
+ 'posts_per_page' => $params['posts_per_page'] ?? Settings::get_property_per_page(),
+ 'paged' => $params['page'] ?? 1,
+ 'orderby' => $params['orderby'] ?? 'date',
+ 'order' => $params['order'] ?? 'asc',
+ 'post_type' => REALPRESS_PROPERTY_CPT,
+ );
+
+ if ( isset( $params['template'] ) ) {
+ if ( $params['template'] === 'similar_property' ) {
+ $args['post__not_in'] = array( $params['post_id'] );
+
+ $types = PropertyMetaModel::instance( $params['post_id'] )->get_property_terms( 'realpress-type' );
+ $term_ids = array();
+
+ if ( ! empty( $types ) ) {
+ $term_ids = array_map(
+ function ( $types ) {
+ return $types->term_id;
+ },
+ $types
+ );
+ }
+
+ $args['tax_query'] = array(
+ 'relation' => 'AND',
+ array(
+ 'taxonomy' => 'realpress-type',
+ 'field' => 'id',
+ 'terms' => $term_ids,
+ 'operator' => 'IN',
+ ),
+ );
+ } elseif ( $params['template'] === 'search_suggest' ) {
+ $args['posts_per_page'] = $params['posts_per_page'] ?? Settings::get_search_suggest_property_number();
+ }
+ }
+
+ if ( isset( $params['author_id'] ) ) {
+ $args['user_id'] = $params['author_id'];
+ }
+
+ //sort
+ if ( $args['orderby'] === 'rating' ) {
+ $args['meta_key'] = REALPRESS_PREFIX . '_property_average_review';
+ $args['orderby'] = 'meta_value_num';
+ }
+
+ if ( $args['orderby'] === 'price' ) {
+ $args['meta_key'] = REALPRESS_PREFIX . '_group:information:section:general:fields:price';
+ $args['orderby'] = 'meta_value_num';
+ }
+
+ //search
+ if ( ! empty( $params['keyword'] ) ) {
+ $args['s'] = $params['keyword'];
+
+ if ( apply_filters( 'realpress/filter/properties/search_columns/post_title' , false) ) {
+ $args['search_columns'] = 'post_title';
+ }
+ }
+
+ if ( isset( $params['room'] ) ) {
+ $compare = '=';
+ if ( strpos( $params['room'], '+' ) !== false ) {
+ $compare = '>=';
+ }
+
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:rooms',
+ 'type' => 'DECIMAL',
+ 'value' => $params['room'],
+ 'compare' => $compare,
+ );
+ }
+
+ if ( isset( $params['bath'] ) ) {
+ $compare = '=';
+ if ( strpos( $params['bath'], '+' ) !== false ) {
+ $compare = '>=';
+ }
+
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:bathrooms',
+ 'type' => 'DECIMAL',
+ 'value' => $params['bath'],
+ 'compare' => $compare,
+ );
+ }
+
+ if ( isset( $params['bed'] ) ) {
+ $compare = '=';
+ if ( strpos( $params['bed'], '+' ) !== false ) {
+ $compare = '>=';
+ }
+
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:bedrooms',
+ 'type' => 'DECIMAL',
+ 'value' => $params['bed'],
+ 'compare' => $compare,
+ );
+ }
+
+ if ( isset( $params['verified'] ) && $params['verified'] === 'yes' ) {
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:verified',
+ 'type' => 'CHAR',
+ 'value' => 'on',
+ 'compare' => '=',
+ );
+ }
+
+ //For taxonomy archive
+ if ( isset( $params['term_id'] ) && isset( $params['taxonomy'] ) ) {
+ $args['tax_query'][] = array(
+ 'taxonomy' => $params['taxonomy'],
+ 'terms' => array( $params['term_id'] ),
+ 'operator' => 'IN',
+ 'include_children' => false,
+ );
+ }
+
+ //Advanced Search
+ $taxonomies = array_keys( Config::instance()->get( 'property-type:taxonomies' ) );
+
+ foreach ( $taxonomies as $taxonomy ) {
+ $key = str_replace( array( 'realpress-', '-' ), array( '', '_' ), $taxonomy );
+
+ if ( isset( $params[ $key ] ) ) {
+ if ( is_string( $params[ $key ] ) ) {
+ $params[ $key ] = explode( ',', $params[ $key ] );
+ }
+
+ // if is realpress-feature taxonomy, use AND operator, other is IN
+ $tax_operator = ( $key === 'feature' ) ? 'AND' : 'IN';
+
+ $args['tax_query'][] = array(
+ 'taxonomy' => $taxonomy,
+ 'terms' => $params[ $key ],
+ 'operator' => $tax_operator,
+ );
+ }
+ }
+
+ //Price
+ if ( isset( $params['min_price'] ) ) {
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:price',
+ 'value' => $params['min_price'],
+ 'type' => 'DECIMAL',
+ 'compare' => '>=',
+ );
+ }
+
+ if ( isset( $params['max_price'] ) ) {
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:price',
+ 'value' => $params['max_price'] ,
+ 'type' => 'DECIMAL',
+ 'compare' => '<=',
+ );
+ }
+
+ if ( isset( $params['min_area'] ) ) {
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:area_size',
+ 'value' => $params['min_area'],
+ 'type' => 'DECIMAL',
+ 'compare' => '>=',
+ );
+ }
+
+ if ( isset( $params['max_area'] ) ) {
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:area_size',
+ 'value' => $params['max_area'],
+ 'type' => 'DECIMAL',
+ 'compare' => '<=',
+ );
+ }
+
+ if ( isset( $params['min_year'] ) ) {
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:year_built',
+ 'value' => $params['min_year'],
+ 'type' => 'DECIMAL',
+ 'compare' => '>=',
+ );
+ }
+
+ if ( isset( $params['max_year'] ) ) {
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:year_built',
+ 'value' => $params['max_year'],
+ 'type' => 'DECIMAL',
+ 'compare' => '<=',
+ );
+ }
+
+ if ( isset( $params['property_id'] ) ) {
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:information:section:general:fields:property_id',
+ 'value' => $params['property_id'],
+ 'compare' => 'LIKE',
+ );
+ }
+
+ if ( ! empty( $params['has_coordinates'] ) ) {
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:map:section:enable_map:fields:enable',
+ 'value' => 'on',
+ 'type' => 'CHAR',
+ 'compare' => '=',
+ );
+
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:map:section:map:fields:lat',
+ 'value' => '',
+ 'type' => 'CHAR',
+ 'compare' => '!=',
+ );
+
+ $args['meta_query'][] = array(
+ 'key' => REALPRESS_PREFIX . '_group:map:section:map:fields:lng',
+ 'value' => '',
+ 'type' => 'CHAR',
+ 'compare' => '!=',
+ );
+ }
+
+ if ( isset( $args['meta_query'] ) ) {
+ $args['meta_query']['relation'] = 'AND';
+ }
+
+ if ( isset( $args['tax_query'] ) ) {
+ $args['tax_query']['relation'] = 'AND';
+ }
+
+
+ return apply_filters( 'realpress/filter/list-property/args', $args, $params );
+ }
+}
--- a/realpress/app/Elementor/modules/single-property/class-init.php
+++ b/realpress/app/Elementor/modules/single-property/class-init.php
@@ -114,7 +114,7 @@
'is_query' => false,
),
array(
- 'label' => esc_html__( 'Select Property', 'thim-elementor-kit' ),
+ 'label' => esc_html__( 'Select Property', 'realpress' ),
'value' => 'property_id',
'is_query' => true,
),
--- a/realpress/app/Elementor/widgets/loop-item/property-detail.php
+++ b/realpress/app/Elementor/widgets/loop-item/property-detail.php
@@ -471,18 +471,18 @@
'type' => Controls_Manager::SELECT,
'default' => '',
'options' => array(
- '100' => '100 ' . esc_html_x( '(Thin)', 'Typography Control', 'elementor' ),
- '200' => '200 ' . esc_html_x( '(Extra Light)', 'Typography Control', 'elementor' ),
- '300' => '300 ' . esc_html_x( '(Light)', 'Typography Control', 'elementor' ),
- '400' => '400 ' . esc_html_x( '(Normal)', 'Typography Control', 'elementor' ),
- '500' => '500 ' . esc_html_x( '(Medium)', 'Typography Control', 'elementor' ),
- '600' => '600 ' . esc_html_x( '(Semi Bold)', 'Typography Control', 'elementor' ),
- '700' => '700 ' . esc_html_x( '(Bold)', 'Typography Control', 'elementor' ),
- '800' => '800 ' . esc_html_x( '(Extra Bold)', 'Typography Control', 'elementor' ),
- '900' => '900 ' . esc_html_x( '(Black)', 'Typography Control', 'elementor' ),
- '' => esc_html_x( 'Default', 'Typography Control', 'elementor' ),
- 'normal' => esc_html_x( 'Normal', 'Typography Control', 'elementor' ),
- 'bold' => esc_html_x( 'Bold', 'Typography Control', 'elementor' ),
+ '100' => '100 ' . esc_html_x( '(Thin)', 'Typography Control', 'realpress' ),
+ '200' => '200 ' . esc_html_x( '(Extra Light)', 'Typography Control', 'realpress' ),
+ '300' => '300 ' . esc_html_x( '(Light)', 'Typography Control', 'realpress' ),
+ '400' => '400 ' . esc_html_x( '(Normal)', 'Typography Control', 'realpress' ),
+ '500' => '500 ' . esc_html_x( '(Medium)', 'Typography Control', 'realpress' ),
+ '600' => '600 ' . esc_html_x( '(Semi Bold)', 'Typography Control', 'realpress' ),
+ '700' => '700 ' . esc_html_x( '(Bold)', 'Typography Control', 'realpress' ),
+ '800' => '800 ' . esc_html_x( '(Extra Bold)', 'Typography Control', 'realpress' ),
+ '900' => '900 ' . esc_html_x( '(Black)', 'Typography Control', 'realpress' ),
+ '' => esc_html_x( 'Default', 'Typography Control', 'realpress' ),
+ 'normal' => esc_html_x( 'Normal', 'Typography Control', 'realpress' ),
+ 'bold' => esc_html_x( 'Bold', 'Typography Control', 'realpress' ),
),
'selectors' => array(
--- a/realpress/app/Elementor/widgets/single-property/property-contact-agent.php
+++ b/realpress/app/Elementor/widgets/single-property/property-contact-agent.php
@@ -50,7 +50,7 @@
'type' => Controls_Manager::SELECT,
'options' => array(
'none' => esc_html__( 'No', 'realpress' ),
- 'block' => esc_html_x( 'Yes', 'realpress' ),
+ 'block' => esc_html__( 'Yes', 'realpress' ),
),
'default' => 'block',
'selectors' => array(
--- a/realpress/app/Elementor/widgets/single-property/property-map.php
+++ b/realpress/app/Elementor/widgets/single-property/property-map.php
@@ -184,7 +184,7 @@
'max' => 500,
'step' => 1,
'selectors' => array(
- '{{WRAPPER}} .btn_opm' => '-webkit-transform: translateY({{VALUE}}px); -ms-transform: translateY({{SIZE}}px); transform: translateY({{SIZE}}px);',
+ '{{WRAPPER}} .btn_opm' => 'transform: translateY({{SIZE}}px);',
),
'condition' => array(
'button_position' => 'absolute',
--- a/realpress/app/Elementor/widgets/single-property/property-similar.php
+++ b/realpress/app/Elementor/widgets/single-property/property-similar.php
@@ -392,7 +392,7 @@
'max' => 500,
'step' => 1,
'selectors' => array(
- '{{WRAPPER}} .realpress-similar-property .slick-arrow' => '-webkit-transform: translateY({{VALUE}}px); -ms-transform: translateY({{SIZE}}px); transform: translateY({{SIZE}}px);',
+ '{{WRAPPER}} .realpress-similar-property .slick-arrow' => 'transform: translateY({{SIZE}}px);',
),
)
);
--- a/realpress/app/Elementor/widgets/single-property/property-thumb.php
+++ b/realpress/app/Elementor/widgets/single-property/property-thumb.php
@@ -906,7 +906,7 @@
'max' => 500,
'step' => 1,
'selectors' => array(
- '{{WRAPPER}} .rp_btn-slide' => '-webkit-transform: translateY({{VALUE}}px); -ms-transform: translateY({{SIZE}}px); transform: translateY({{SIZE}}px);',
+ '{{WRAPPER}} .rp_btn-slide' => 'transform: translateY({{SIZE}}px);',
),
)
);
@@ -1154,8 +1154,8 @@
'max' => 500,
'step' => 1,
'selectors' => array(
- '{{WRAPPER}} .thumb #pager' => '-webkit-transform: translateX(-50%) translateY({{VALUE}}px); -ms-transform: translateX(-50%) translateY({{SIZE}}px); transform: translateX(-50%) translateY({{SIZE}}px);',
- '{{WRAPPER}} .bullets #pager' => '-webkit-transform: translateX(-50%) translateY({{VALUE}}px); -ms-transform: translateX(-50%) translateY({{SIZE}}px); transform: translateX(-50%) translateY({{SIZE}}px);',
+ '{{WRAPPER}} .thumb #pager' => 'transform: translateX(-50%) translateY({{SIZE}}px);',
+ '{{WRAPPER}} .bullets #pager' => 'transform: translateX(-50%) translateY({{SIZE}}px);',
),
'condition' => array(
'prt_show_pagination' => array( 'bullets', 'thumb' ),
--- a/realpress/app/Helpers/Config.php
+++ b/realpress/app/Helpers/Config.php
@@ -86,6 +86,47 @@
}
}
+ /**
+ * Convert a config path into a form field name.
+ *
+ * Config paths are used directly as the name of the inputs of a metabox, and some
+ * CDN and WAF layers reject a multipart request whose part names carry a colon,
+ * with a 403 raised before the request reaches PHP. Swap the separator on the way
+ * out, and swap it back with decode_field_names() when the form is submitted.
+ *
+ * Keys of the config files must not contain '__' for a path to round trip.
+ *
+ * @param string $key | Format key: key_name:key_item:...
+ *
+ * @return string
+ * @version 1.1.3
+ *
+ * @since 1.1.3
+ */
+ public static function encode_field_name( string $key = '' ): string {
+ return str_replace( ':', '__', $key );
+ }
+
+ /**
+ * Restore the config paths of a submitted group of fields.
+ *
+ * @param $fields | Submitted fields keyed by encoded field name
+ *
+ * @return array
+ * @version 1.1.3
+ *
+ * @since 1.1.3
+ */
+ public static function decode_field_names( $fields ): array {
+ $decoded = array();
+
+ foreach ( (array) $fields as $key => $value ) {
+ $decoded[ str_replace( '__', ':', $key ) ] = $value;
+ }
+
+ return $decoded;
+ }
+
private function set_default_data( $config = array(), string $key = '' ) {
foreach ( $config as $k => $values ) {
if ( is_array( $values ) && isset( $values['default'] ) ) {
--- a/realpress/app/Helpers/Fields/Number.php
+++ b/realpress/app/Helpers/Fields/Number.php
@@ -1,14 +1,14 @@
-<?php
-
-namespace RealPressHelpersFields;
-
-/**
- *
- */
-class Number extends AbstractField {
- public $min, $max, $required, $step;
- public $path_view = 'fields/number.php';
-
- public function __construct() {
- }
-}
+<?php
+
+namespace RealPressHelpersFields;
+
+/**
+ *
+ */
+class Number extends AbstractField {
+ public $min, $max, $required, $step;
+ public $path_view = 'fields/number.php';
+
+ public function __construct() {
+ }
+}
--- a/realpress/app/Helpers/General.php
+++ b/realpress/app/Helpers/General.php
@@ -1,66 +1,66 @@
-<?php
-
-namespace RealPressHelpers;
-
-class General {
- public static function get_default_image() {
- return REALPRESS_ASSETS_URL . 'images/no-image.jpg';
- }
-
- public static function get_logo() {
- return REALPRESS_ASSETS_URL . 'images/logo.png';
- }
-
- public static function ksesHTML( $content ) {
- $allowed_html = wp_kses_allowed_html( 'post' );
-
- $allowed_html['iframe'] = array(
- 'src' => 1,
- 'width' => 1,
- 'height' => 1,
- 'style' => 1,
- 'class' => array( 'embed-responsive-item' ),
- 'frameborder' => 1,
- );
-
- $allowed_html['input'] = array(
- 'src' => 1,
- 'width' => 1,
- 'height' => 1,
- 'type' => array(),
- 'placeholder' => 1,
- 'value' => 1,
- 'class' => array( 'embed-responsive-item' ),
- 'frameborder' => 1,
- 'name' => 1,
- 'min' => 1,
- 'max' => 1,
- );
-
- $allowed_html['form'] = array(
- 'class' => 1,
- 'style' => 1,
- );
-
- $allowed_html['textarea'] = array(
- 'placeholder' => 1,
- 'cols' => 1,
- 'rows' => 1,
- 'name' => 1,
- );
-
- $allowed_html['select'] = array(
- 'placeholder' => 1,
- 'cols' => 1,
- 'rows' => 1,
- 'name' => 1,
- 'title' => 1,
- );
-
- $allowed_html['option'] = array(
- 'selected' => 1,
- );
-
- return wp_kses( wp_unslash( $content ), $allowed_html );
- }
-}
+<?php
+
+namespace RealPressHelpers;
+
+class General {
+ public static function get_default_image() {
+ return REALPRESS_ASSETS_URL . 'images/no-image.jpg';
+ }
+
+ public static function get_logo() {
+ return REALPRESS_ASSETS_URL . 'images/logo.png';
+ }
+
+ public static function ksesHTML( $content ) {
+ $allowed_html = wp_kses_allowed_html( 'post' );
+
+ $allowed_html['iframe'] = array(
+ 'src' => 1,
+ 'width' => 1,
+ 'height' => 1,
+ 'style' => 1,
+ 'class' => array( 'embed-responsive-item' ),
+ 'frameborder' => 1,
+ );
+
+ $allowed_html['input'] = array(
+ 'src' => 1,
+ 'width' => 1,
+ 'height' => 1,
+ 'type' => array(),
+ 'placeholder' => 1,
+ 'value' => 1,
+ 'class' => array( 'embed-responsive-item' ),
+ 'frameborder' => 1,
+ 'name' => 1,
+ 'min' => 1,
+ 'max' => 1,
+ );
+
+ $allowed_html['form'] = array(
+ 'class' => 1,
+ 'style' => 1,
+ );
+
+ $allowed_html['textarea'] = array(
+ 'placeholder' => 1,
+ 'cols' => 1,
+ 'rows' => 1,
+ 'name' => 1,
+ );
+
+ $allowed_html['select'] = array(
+ 'placeholder' => 1,
+ 'cols' => 1,
+ 'rows' => 1,
+ 'name' => 1,
+ 'title' => 1,
+ );
+
+ $allowed_html['option'] = array(
+ 'selected' => 1,
+ );
+
+ return wp_kses( wp_unslash( $content ), $allowed_html );
+ }
+}
--- a/realpress/app/Helpers/Taxonomy.php
+++ b/realpress/app/Helpers/Taxonomy.php
@@ -1,15 +1,15 @@
-<?php
-namespace RealPressHelpers;
-
-class Taxonomy {
- /**
- * @return string[]
- */
- public static function get_selected_one_term_taxonomies() {
- return array(
- 'realpress-status',
- 'realpress-energy-class',
- 'realpress-label',
- );
- }
-}
+<?php
+namespace RealPressHelpers;
+
+class Taxonomy {
+ /**
+ * @return string[]
+ */
+ public static function get_selected_one_term_taxonomies() {
+ return array(
+ 'realpress-status',
+ 'realpress-energy-class',
+ 'realpress-label',
+ );
+ }
+}
--- a/realpress/app/MetaBoxes/PropertyMeta.php
+++ b/realpress/app/MetaBoxes/PropertyMeta.php
@@ -119,14 +119,15 @@
$this->set_default( $post_id );
//set default data when save empty data
$old_data = PropertyMetaModel::get_meta_data( $post_id );
- $new_data = array();
+ //Field names are submitted encoded, restore the config paths used to store them
+ $save_data = Config::decode_field_names( $_POST[ REALPRESS_PROPERTY_META_KEY ] ?? array() );
+ $new_data = array();
foreach ( $old_data as $name => $value ) {
$field = Config::instance()->get( 'property-metabox:' . $name );
- $key = Validation::sanitize_params_submitted( isset( $_POST[ REALPRESS_PROPERTY_META_KEY ][ $name ] ) );
+ $key = Validation::sanitize_params_submitted( isset( $save_data[ $name ] ) );
if ( $key ) {
- $save_data = $_POST[ REALPRESS_PROPERTY_META_KEY ];
- $value = $save_data[ $name ];
+ $value = $save_data[ $name ];
if ( ! empty( $value ) ) {
if ( $field['type'] instanceof FileUpload ) {
$value = Validation::validate_file_upload( $value, $field, $post->post_author );
--- a/realpress/app/Register/BlockTemplate/BlockTemplateHandle.php
+++ b/realpress/app/Register/BlockTemplate/BlockTemplateHandle.php
@@ -141,7 +141,7 @@
*
* @return WP_Block_Template|null
*/
- public function edit_block_file_template( WP_Block_Template $template = null, string $id, $template_type ) {
+ public function edit_block_file_template( ?WP_Block_Template $template = null, string $id = '', string $template_type = '' ) {
$realpress_block_templates = Config::instance()->get( 'block-templates' );
foreach ( $realpress_block_templates as $block_template ) {
--- a/realpress/app/Widgets/ContactForm.php
+++ b/realpress/app/Widgets/ContactForm.php
@@ -1,97 +1,97 @@
-<?php
-
-namespace RealPressWidgets;
-
-use RealPressHelpersTemplate;
-use RealPressHelpersValidation;
-use RealPressHelpersConfig;
-use RealPressHelpersFieldsAbstractField;
-use RealPressHelpersGeneral;
-use RealPressHelpersPage;
-use RealPressModelsPropertyMetaModel;
-
-class ContactForm extends WP_Widget {
- private $settings;
-
- public function __construct() {
- $this->settings = Config::instance()->get( 'contact-form', 'widgets' );
- parent::__construct(
- 'realpress-contact-form',
- esc_html__( '(RealPress) Contact Form', 'realpress' ),
- array(
- 'description' => esc_html__(
- 'This widget only work on Single Property page and Agent Detail page.',
- 'realpress'
- ),
- )
- );
- }
-
- /**
- * @param $instance
- *
- * @return string|void
- */
- public function form( $instance ) {
- ?>
- <div class="realpress-widget-group">
- <?php
- foreach ( $this->settings as $field_name => $field_args ) {
- if ( isset( $field_args['type'] ) && $field_args['type'] instanceof AbstractField ) {
- $field_args['value'] = $instance[ $field_name ] ?? $field_args['default'];
- $field_args['name'] = $this->get_field_name( $field_name );
- $field_args['id'] = $this->get_field_id( $field_args['id'] );
- $field_args['type']->set_args( $field_args )->render();
- }
- }
- ?>
- </div>
- <?php
- }
-
- /**
- * @param $args
- * @param $instance
- *
- * @return void
- */
- public function widget( $args, $instance ) {
- ob_start();
- echo General::ksesHTML( $args['before_widget'] );
- if ( ! empty( $instance['title'] ) ) {
- echo General::ksesHTML( $args['before_title'] );
- ?>
- <span><?php echo esc_html( $instance['title'] ); ?></span>
- <?php
- echo General::ksesHTML( $args['after_title'] );
- }
- $term_args = $instance;
- unset( $term_args['title'] );
- $data = array(
- 'cc_admin' => $term_args['cc_admin'] ?? '',
- );
- Template::instance()->get_frontend_template_type_classic( 'widgets/contact-form.php', compact( 'data' ) );
- echo General::ksesHTML( $args['after_widget'] );
- $content = ob_get_clean();
- echo General::ksesHTML( $content );
- }
-
- /**
- * @param $new_instance
- * @param $old_instance
- *
- * @return array
- */
- public function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
-
- foreach ( $new_instance as $key => $value ) {
- $field = $this->settings[ $key ];
- $sanitize = $field['sanitize'] ?? 'text';
- $value = Validation::sanitize_params_submitted( $value, $sanitize );
- $instance[ $key ] = $value;
- }
-
- return $instance;
- }
-}
+<?php
+
+namespace RealPressWidgets;
+
+use RealPressHelpersTemplate;
+use RealPressHelpersValidation;
+use RealPressHelpersConfig;
+use RealPressHelpersFieldsAbstractField;
+use RealPressHelpersGeneral;
+use RealPressHelpersPage;
+use RealPressModelsPropertyMetaModel;
+
+class ContactForm extends WP_Widget {
+ private $settings;
+
+ public function __construct() {
+ $this->settings = Config::instance()->get( 'contact-form', 'widgets' );
+ parent::__construct(
+ 'realpress-contact-form',
+ esc_html__( '(RealPress) Contact Form', 'realpress' ),
+ array(
+ 'description' => esc_html__(
+ 'This widget only work on Single Property page and Agent Detail page.',
+ 'realpress'
+ ),
+ )
+ );
+ }
+
+ /**
+ * @param $instance
+ *
+ * @return string|void
+ */
+ public function form( $instance ) {
+ ?>
+ <div class="realpress-widget-group">
+ <?php
+ foreach ( $this->settings as $field_name => $field_args ) {
+ if ( isset( $field_args['type'] ) && $field_args['type'] instanceof AbstractField ) {
+ $field_args['value'] = $instance[ $field_name ] ?? $field_args['default'];
+ $field_args['name'] = $this->get_field_name( $field_name );
+ $field_args['id'] = $this->get_field_id( $field_args['id'] );
+ $field_args['type']->set_args( $field_args )->render();
+ }
+ }
+ ?>
+ </div>
+ <?php
+ }
+
+ /**
+ * @param $args
+ * @param $instance
+ *
+ * @return void
+ */
+ public function widget( $args, $instance ) {
+ ob_start();
+ echo General::ksesHTML( $args['before_widget'] );
+ if ( ! empty( $instance['title'] ) ) {
+ echo General::ksesHTML( $args['before_title'] );
+ ?>
+ <span><?php echo esc_html( $instance['title'] ); ?></span>
+ <?php
+ echo General::ksesHTML( $args['after_title'] );
+ }
+ $term_args = $instance;
+ unset( $term_args['title'] );
+ $data = array(
+ 'cc_admin' => $term_args['cc_admin'] ?? '',
+ );
+ Template::instance()->get_frontend_template_type_classic( 'widgets/contact-form.php', compact( 'data' ) );
+ echo General::ksesHTML( $args['after_widget'] );
+ $content = ob_get_clean();
+ echo General::ksesHTML( $content );
+ }
+
+ /**
+ * @param $new_instance
+ * @param $old_instance
+ *
+ * @return array
+ */
+ public function update( $new_instance, $old_instance ) {
+ $instance = $old_instance;
+
+ foreach ( $new_instance as $key => $value ) {
+ $field = $this->settings[ $key ];
+ $sanitize = $field['sanitize'] ?? 'text';
+ $value = Validation::sanitize_params_submitted( $value, $sanitize );
+ $instance[ $key ] = $value;
+ }
+
+ return $instance;
+ }
+}
--- a/realpress/assets/dist/js/admin/realpress-edit-block.asset.php
+++ b/realpress/assets/dist/js/admin/realpress-edit-block.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '42e6437ca3466bbce95b');
+<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'baafb75016244b80dd2d');
--- a/realpress/assets/dist/js/admin/realpress-edit-block.min.asset.php
+++ b/realpress/assets/dist/js/admin/realpress-edit-block.min.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '1c93f0a1a253af3fd528');
+<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'd422dea0fb4deff5c39c');
--- a/realpress/assets/dist/js/admin/realpress-global.asset.php
+++ b/realpress/assets/dist/js/admin/realpress-global.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array(), 'version' => '7b878e4a4d3f8f8dd552');
+<?php return array('dependencies' => array(), 'version' => '4668710dd4bbb814bbd7');
--- a/realpress/assets/dist/js/admin/realpress-global.min.asset.php
+++ b/realpress/assets/dist/js/admin/realpress-global.min.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array(), 'version' => '292aef65e8d2faec1756');
+<?php return array('dependencies' => array(), 'version' => '1a28870265929c77c52d');
--- a/realpress/assets/dist/js/admin/realpress-property.asset.php
+++ b/realpress/assets/dist/js/admin/realpress-property.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('wp-url'), 'version' => '0f63b570bcaf9557a23a');
+<?php return array('dependencies' => array('wp-url'), 'version' => '257413ef5d42f2654b98');
--- a/realpress/assets/dist/js/admin/realpress-property.min.asset.php
+++ b/realpress/assets/dist/js/admin/realpress-property.min.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('wp-url'), 'version' => 'd4651ef032c4610f1cb1');
+<?php return array('dependencies' => array('wp-url'), 'version' => 'e08c26d1ce3a5f32da4c');
--- a/realpress/assets/dist/js/admin/realpress-settings.asset.php
+++ b/realpress/assets/dist/js/admin/realpress-settings.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array(), 'version' => '6e6a92d186658805f8a0');
+<?php return array('dependencies' => array(), 'version' => 'fb0382205ed52958adc2');
--- a/realpress/assets/dist/js/admin/realpress-settings.min.asset.php
+++ b/realpress/assets/dist/js/admin/realpress-settings.min.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array(), 'version' => '0b9388ce28d42b3daec5');
+<?php return array('dependencies' => array(), 'version' => 'e4ff9879810a096ab510');
--- a/realpress/assets/dist/js/admin/realpress-setup.asset.php
+++ b/realpress/assets/dist/js/admin/realpress-setup.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('wp-url'), 'version' => '647d6a43438238628f3a');
+<?php return array('dependencies' => array('wp-url'), 'version' => '52f7ee9abef893ffb227');
--- a/realpress/assets/dist/js/admin/realpress-setup.min.asset.php
+++ b/realpress/assets/dist/js/admin/realpress-setup.min.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('wp-url'), 'version' => 'bbbbf8d69c4a461980ef');
+<?php return array('dependencies' => array('wp-url'), 'version' => 'f58e3534d59eb37c1c8e');
--- a/realpress/assets/dist/js/admin/realpress-user-profile.asset.php
+++ b/realpress/assets/dist/js/admin/realpress-user-profile.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array(), 'version' => '1d350df08ee8e511b968');
+<?php return array('dependencies' => array(), 'version' => 'b6dc304dc9a1a6aca324');
--- a/realpress/assets/dist/js/admin/realpress-user-profile.min.asset.php
+++ b/realpress/assets/dist/js/admin/realpress-user-profile.min.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array(), 'version' => '57bbd12492e0159b95f5');
+<?php return array('dependencies' => array(), 'version' => '8a76fcc880cd857cd095');
--- a/realpress/assets/dist/js/app.asset.php
+++ b/realpress/assets/dist/js/app.asset.php
@@ -1 +0,0 @@
-<?php return array('dependencies' => array(), 'version' => 'ac39028c6ee47f2c50ac');
--- a/realpress/assets/dist/js/app.min.asset.php
+++ b/realpress/assets/dist/js/app.min.asset.php
@@ -1 +0,0 @@
-<?php return array('dependencies' => array(), 'versio