*/ class Aretk_Crea_Admin { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function aretkcrea_enqueue_styles() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Aretk_Crea_Loader as all of the hooks are defined * in that particular class. * * The Aretk_Crea_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_style( 'jquery.bxslider-css', plugin_dir_url( __FILE__ ) . 'css/jquery.bxslider.css', array(), $this->version, 'all' ); wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/aretk-crea-admin.css', array(), $this->version, 'all' ); wp_enqueue_style( 'media-css', plugin_dir_url( __FILE__ ) . 'css/media.css', array(), $this->version, 'all' ); wp_enqueue_style( 'jQuery-ui-style', plugin_dir_url( __FILE__ ) . 'css/jquery-ui.css', array(), $this->version, 'all' ); wp_enqueue_style( 'jQuery-imageupload.js', plugin_dir_url( __FILE__ ) . 'css/imageupload.css', array(), $this->version, 'all' ); wp_enqueue_style( 'jquery.dataTables', plugin_dir_url( __FILE__ ) . 'css/jquery.dataTables.css', array(), $this->version, 'all' ); wp_enqueue_style( 'jquery-choosen-css', plugin_dir_url( __FILE__ ) . 'css/chosen.css', array(), $this->version, 'all' ); wp_enqueue_style( 'jquery-simple-dtpicker-css', plugin_dir_url( __FILE__ ) . 'css/jquery.simple-dtpicker.css', array(), 'all' ); wp_enqueue_style( 'lightcase-css', plugin_dir_url( __FILE__ ) . 'css/lightcase.css',array(), $this->version, 'all' ); } /** * Register JavaScripts for the admin area. * * @since 1.0.0 */ public function aretkcrea_enqueue_scripts() { wp_enqueue_script('jquery-ui'); wp_enqueue_script('jquery-ui-slider'); wp_enqueue_script('jquery-ui-tabs'); wp_enqueue_script('jquery-ui-dialog'); wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_script( 'jquery-ui-sortable'); wp_enqueue_script( 'jquery-ui-accordion'); $google_map_api = get_option('google-map-api-name'); $google_map_script_loaded_or_not = get_option('crea_google_map_script_load_or_not'); $google_map_api_key_pass = ''; if( isset( $google_map_api ) && !empty( $google_map_api) ) { $google_map_api_results = $google_map_api; $google_map_api_key_pass .= "?key=$google_map_api_results"; } wp_enqueue_script( 'jquery.dataTables.min', plugin_dir_url( __FILE__ ) . 'js/jquery.dataTables.min.js', array( 'jquery' ), $this->version, false ); wp_enqueue_script( 'bxlsider-public', plugin_dir_url( __FILE__ ) . 'js/jquery.bxslider.js', array( 'jquery' ), $this->version); if( $google_map_script_loaded_or_not === 'Yes' || empty( $google_map_script_loaded_or_not ) ) { wp_enqueue_script( 'google-map-js', "https://maps.googleapis.com/maps/api/js$google_map_api_key_pass", array( 'jquery' )); wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/aretk-crea-admin.js', array( 'jquery', 'google-map-js' ), $this->version, false ); } else { wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/aretk-crea-admin.js', array( 'jquery' ), $this->version, false ); } wp_enqueue_script( 'accordion-aretk', plugin_dir_url( __FILE__ ) . 'js/accordion.js', array( 'jquery' ), $this->version); wp_enqueue_script( 'validate-new', plugin_dir_url( __FILE__ ) . 'js/jquery.validate.min.js', array( 'jquery' ), $this->version); if(isset($_GET['page']) && !empty($_GET['page'])) { if(isset($_GET['page']) && $_GET['page'] == 'create_new_leads') { wp_enqueue_script('lead-form', plugin_dir_url( __FILE__ ) . 'js/lead-form.js', array( 'jquery' ), false ); } } wp_localize_script( $this->plugin_name, 'cancelicon', array('cancelurl' => ARETK_CREA_PLUGIN_URL.'admin/images/delete-icon.png')); wp_localize_script( $this->plugin_name, 'adminajaxjs', array('adminajaxjsurl' => admin_url( 'admin-ajax.php' ))); wp_localize_script( $this->plugin_name, 'refreshicon', array('refreshurl' => ARETK_CREA_PLUGIN_URL.'admin/images/refresh-animated.gif' )); wp_localize_script( $this->plugin_name, 'ajaxicon', array('loderurl' => ARETK_CREA_PLUGIN_URL.'admin/images/ajax-loader.gif') ); wp_localize_script( $this->plugin_name, 'refreshimagejs', array('refreshimagejsurl' => ARETK_CREA_PLUGIN_URL.'admin/js/imageupload.js' )); wp_enqueue_script( 'mousewheel', plugin_dir_url( __FILE__ ) . 'js/jquery.mousewheel-3.0.6.pack.js', array( 'jquery' ), $this->version); wp_enqueue_script( 'imageupload', plugin_dir_url( __FILE__ ) . 'js/imageupload.js', array( 'jquery' ), $this->version); wp_enqueue_script( 'colorpicker1', plugin_dir_url( __FILE__ ) . 'js/jscolor.js', array( 'jquery' ), $this->version); wp_enqueue_script( 'colorpicker2', plugin_dir_url( __FILE__ ) . 'js/jscolor.min.js', array( 'jquery' ), $this->version); wp_enqueue_script( 'jquery.dataTables', plugin_dir_url( __FILE__ ) . 'js/jquery.dataTables.min.js', array( 'jquery' ), $this->version); wp_enqueue_script( 'choosen', plugin_dir_url( __FILE__ ) . 'js/chosen.jquery.js', array( 'jquery' ),$this->version); wp_enqueue_script( 'jquery-simple-dtpicker-js', plugin_dir_url( __FILE__ ) . 'js/jquery.simple-dtpicker.js', array( 'jquery' )); wp_enqueue_script( 'copytoclipboard', plugin_dir_url( __FILE__ ) . 'js/clipboard.min.js', array( 'jquery' ), $this->version); wp_enqueue_script( 'lightcase', plugin_dir_url( __FILE__ ) . 'js/lightcase.js', array( 'jquery' ), $this->version); wp_enqueue_script( 'loader-js', plugin_dir_url( __FILE__ ) . 'js/modernizr.js', array( 'jquery' ), $this->version); } /** * create aretk crea admin menu * */ public function aretkcrea_crea_custom_menu() { if ($_GET['new_menu'] !== 'true'){ $aretk_plugin_slug = 'listings_settings'; add_menu_page('crea-plugin','Real Estate','manage_options',$aretk_plugin_slug,'aretkcrea_custom_listings_settings_function', ARETK_CREA_PLUGIN_URL.'admin/images/icon-main-menu.png'); add_submenu_page($aretk_plugin_slug, 'Listings', 'Listings', 'manage_options', $aretk_plugin_slug, 'aretkcrea_custom_listings_settings_function' ); $listings_settings_form = sanitize_text_field ( isset( $_GET['page'] ) ? $_GET['page'] : '' ); if( $listings_settings_form === 'listings_settings' || $listings_settings_form === 'create_new_listings' ) { add_submenu_page($aretk_plugin_slug,'create-new-listing',' - Add New Listing','manage_options','create_new_listings','aretkcrea_custom_create_new_listings_function'); } add_submenu_page($aretk_plugin_slug,'showcase-settings','Showcases','manage_options','showcase_settings','aretkcrea_custom_showcase_settings_function'); $showcase_form = sanitize_text_field ( isset( $_GET['page'] ) ? $_GET['page'] : '' ); if( $showcase_form === 'showcase_settings' || $showcase_form === 'create_new_showcase' || $showcase_form === 'listing_details_settings' || $showcase_form === 'search_listing_settings_showcase' || $showcase_form === 'default_listing_settings_showcase' ){ add_submenu_page($aretk_plugin_slug,'create-new-showcase',' - Add New Showcase','manage_options','create_new_showcase','aretkcrea_custom_create_new_showcase_function'); add_submenu_page('null','default-listing-settings-showcase','DEFAULT LISTING SETTING SHOWCASE','manage_options','default_listing_settings_showcase','aretkcrea_default_listing_settings_fn'); add_submenu_page('null','search-listing-settings-showcase','SEARCH LISTING SETTING SHOWCASE','manage_options','search_listing_settings_showcase','aretkcrea_search_listing_settings_fn'); add_submenu_page('null','listing-details-settings','LISTING DETAILS SETTING','manage_options','listing_details_settings','aretkcrea_custom_listing_details_settings'); } add_submenu_page($aretk_plugin_slug,'leads-settings','Leads','manage_options','leads_settings','aretkcrea_custom_leads_settings_function'); //add submenu for LEADS Settings $lead_form = sanitize_text_field ( isset( $_GET['post_type'] ) ? $_GET['post_type'] :'' ); $lead_form_page = sanitize_text_field ( isset( $_GET['page'] ) ? $_GET['page'] :'' ); $lead_form_category_rexonomy = sanitize_text_field ( isset( $_GET['taxonomy'] ) ? $_GET['taxonomy'] :'' ); if( $lead_form_page === 'leads_form' || $lead_form === 'aretk_lead' || $lead_form_page === 'leads_settings' || $lead_form_page === 'create_new_leads' || $lead_form_page === 'send_email_leads' || $lead_form_page === 'import_leads' || $lead_form_category_rexonomy === 'lead-category' || $lead_form_page === 'create_new_lead_category'){ add_submenu_page($aretk_plugin_slug,'create-new-leads',' - Add New Lead','manage_options','create_new_leads','aretkcrea_custom_create_new_leads_function'); add_submenu_page($aretk_plugin_slug,'send-email-leads',' - Send Email','manage_options','send_email_leads','aretkcrea_custom_send_email_leads_function'); add_submenu_page($aretk_plugin_slug,'create-new-lead-category',' - Lead Categories','manage_options','create_new_lead_category','aretkcrea_custom_create_new_lead_category_function'); add_submenu_page($aretk_plugin_slug,'leads-form',' - Lead Forms','manage_options','leads_form','aretkcrea_custom_leads_form_function'); add_submenu_page($aretk_plugin_slug,'import-leads',' - Import Leads','manage_options','import_leads','aretkcrea_custom_import_leads_function'); } add_submenu_page($aretk_plugin_slug,'crea-plugin','Datafeed Subscription','manage_options','crea-plugin','aretkcrea_custom_crea_plugins_function'); $getSubscriptionStatus = get_option('crea_subscription_status', true); if (isset( $getSubscriptionStatus ) && !empty( $getSubscriptionStatus) && $getSubscriptionStatus === 'valid') { add_submenu_page($aretk_plugin_slug,'crea-settings','CREA DDF® Settings','manage_options','crea_settings','aretkcrea_custom_crea_settings_function'); } add_submenu_page($aretk_plugin_slug,'plugin-settings','Plugin Settings','manage_options','plugin_settings','aretkcrea_custom_plugin_settings_function'); add_submenu_page($aretk_plugin_slug,'support-settings','Support','manage_options','support_settings','aretkcrea_custom_support_settings_function'); } else { //add admin main Crea plugins menu add_menu_page( 'crea-plugin','ARETK', 'manage_options','crea_plugins', 'aretkcrea_custom_crea_plugins_function',ARETK_CREA_PLUGIN_URL.'admin/images/icon.png'); /** * add admin sub menu in plugins * crea_settings ,listings_settings,showcase_settings,leads_settings,support_settings ,plugin_settings */ $getSubscriptionStatus = get_option('crea_subscription_status', true); if (isset( $getSubscriptionStatus ) && !empty( $getSubscriptionStatus) && $getSubscriptionStatus === 'valid') { add_submenu_page('crea_plugins','crea-settings','CREA DDF® Settings','manage_options','crea_settings','aretkcrea_custom_crea_settings_function'); } add_submenu_page('crea_plugins','listings-settings','LISTINGS','manage_options','listings_settings','aretkcrea_custom_listings_settings_function'); //add submenu for Listings settings $listings_settings_form = sanitize_text_field ( isset( $_GET['page'] ) ? $_GET['page'] :'' ); if( isset( $listings_settings_form ) && !empty( $listings_settings_form ) ) { if( $listings_settings_form === 'listings_settings' || $listings_settings_form === 'create_new_listings' ) { add_submenu_page('crea_plugins','create-new-listings','Add New Listing','manage_options','create_new_listings','aretkcrea_custom_create_new_listings_function'); } } add_submenu_page('crea_plugins','showcase-settings','SHOWCASES','manage_options','showcase_settings','aretkcrea_custom_showcase_settings_function'); $showcase_form = sanitize_text_field ( isset( $_GET['page'] ) ? $_GET['page'] :'' ); if( isset($showcase_form) && !empty($showcase_form)) { if( $showcase_form === 'showcase_settings' || $showcase_form === 'create_new_showcase' || $showcase_form === 'listing_details_settings' || $showcase_form === 'search_listing_settings_showcase' || $showcase_form === 'default_listing_settings_showcase' ){ add_submenu_page('crea_plugins','create-new-showcase','ADD NEW SHOWCASE','manage_options','create_new_showcase','aretkcrea_custom_create_new_showcase_function'); add_submenu_page('null','listing-details-settings','LISTING DETAILS SETTING','manage_options','listing_details_settings','aretkcrea_custom_listing_details_settings'); add_submenu_page('null','search-listing-settings-showcase','SEARCH LISTING SETTING SHOWCASE','manage_options','search_listing_settings_showcase','aretkcrea_search_listing_settings_fn'); add_submenu_page('null','default-listing-settings-showcase','DEFAULT LISTING SETTING SHOWCASE','manage_options','default_listing_settings_showcase','aretkcrea_default_listing_settings_fn'); } } add_submenu_page('crea_plugins','leads-settings','LEADS','manage_options','leads_settings','aretkcrea_custom_leads_settings_function'); //add submenu for LEADS Settings $lead_form = sanitize_text_field ( isset( $_GET['post_type'] ) ? $_GET['post_type'] :'' ); $lead_form_page = sanitize_text_field ( isset( $_GET['page'] ) ? $_GET['page'] :'' ); $lead_form_category_rexonomy = sanitize_text_field ( isset( $_GET['taxonomy'] ) ? $_GET['taxonomy'] :'' ); if( $lead_form_page === 'leads_form' || $lead_form === 'aretk_lead' || $lead_form_page === 'leads_settings' || $lead_form_page === 'create_new_leads' || $lead_form_page === 'send_email_leads' || $lead_form_page === 'import_leads' || $lead_form_category_rexonomy === 'lead-category' || $lead_form_page === 'create_new_lead_category'){ add_submenu_page('crea_plugins','leads-form','LEADS forms','manage_options','leads_form','aretkcrea_custom_leads_form_function'); add_submenu_page('crea_plugins','create-new-leads','ADD New LEAD','manage_options','create_new_leads','aretkcrea_custom_create_new_leads_function'); add_submenu_page('crea_plugins','send-email-leads','SEND EMAIL','manage_options','send_email_leads','aretkcrea_custom_send_email_leads_function'); add_submenu_page('crea_plugins','import-leads','IMPORT LEADS','manage_options','import_leads','aretkcrea_custom_import_leads_function'); add_submenu_page('crea_plugins','create-new-lead-category','ADD NEW LEAD CATEGORY','manage_options','create_new_lead_category','aretkcrea_custom_create_new_lead_category_function'); } add_submenu_page('crea_plugins','plugin-settings','SETTINGS','manage_options','plugin_settings','aretkcrea_custom_plugin_settings_function'); add_submenu_page('crea_plugins','support-settings','SUPPORT','manage_options','support_settings','aretkcrea_custom_support_settings_function'); } /** * create function for aretkcrea_custom_crea_plugins_function */ function aretkcrea_custom_crea_plugins_function () { esc_html(aretkcrea_custom_crea_plugin_html()); } /** * create function for aretkcrea_custom_crea_settings_function */ function aretkcrea_custom_crea_settings_function () { esc_html(aretkcrea_custom_crea_settings_html()); } /** * create function for aretkcrea_custom_listings_settings_function */ function aretkcrea_custom_listings_settings_function () { esc_html(aretkcrea_custom_listings_settings_html()); } function aretkcrea_custom_create_new_listings_function() { esc_html(aretkcrea_custom_create_listings_settings_html()); } /** * create function for aretkcrea_custom_showcase_settings_function */ function aretkcrea_custom_showcase_settings_function () { esc_html(aretkcrea_custom_showcase_settings_html()); } /** * create function for aretkcrea_custom_create_new_showcase_function */ function aretkcrea_custom_create_new_showcase_function() { esc_html(aretkcrea_custom_new_create_showcase_html()); } /** * create function for aretkcrea_custom_leads_settings_function */ function aretkcrea_custom_leads_settings_function () { esc_html(aretkcrea_custom_leads_settings_html()); } /** * create function for custom new lead category */ function aretkcrea_custom_create_new_lead_category_function () { esc_html(aretkcrea_custom_create_new_lead_category_html()); } /** * create function for aretkcrea_custom_support_settings_function */ function aretkcrea_custom_support_settings_function () { esc_html(aretkcrea_custom_support_settings_html()); } /** * create function for aretkcrea_search_listing_settings_fn */ function aretkcrea_search_listing_settings_fn() { esc_html(aretkcrea_search_listing_settings_html()); } /** * create function for aretkcrea_default_listing_settings_fn */ function aretkcrea_default_listing_settings_fn() { esc_html(aretkcrea_default_listing_settings_html()); } /** * create function for aretkcrea_custom_plugin_settings_function */ function aretkcrea_custom_plugin_settings_function () { esc_html(aretkcrea_custom_plugin_settings_html()); } /** * create function for aretkcrea_custom_plugin_lead_form_function */ function aretkcrea_custom_leads_form_function () { esc_html(aretkcrea_custom_lead_form_listing()); } /** * create function for aretkcrea_custom_create_new_leads_function */ function aretkcrea_custom_create_new_leads_function () { esc_html(aretkcrea_custom_create_new_leads_form()); } /** * create function for aretkcrea_custom_send_email_leads_function */ function aretkcrea_custom_send_email_leads_function () { esc_html(aretkcrea_custom_send_email_leads_form()); } /** * create function for aretkcrea_custom_listing_details_settings */ function aretkcrea_custom_listing_details_settings () { esc_html(aretkcrea_custom_showcase_listing_detail_settings()); } /** * create function for aretkcrea_custom_import_leads_function */ function aretkcrea_custom_import_leads_function() { esc_html(aretkcrea_custom_import_leads_html()); } } /** * Remove Custom post type Lead from Admin Menu * * @return Remove custome post type Lead * @package Phase 1 * @since Phase 1 * @version * @author Aretk Inc * @param null */ public function aretkcrea_remove_custom_post_lead_from_admin_menu(){ remove_menu_page( 'edit.php?post_type=aretk_lead' ); remove_menu_page( 'edit.php?post_type=aretk_listing' ); remove_menu_page( 'edit.php?post_type=aretk_showcase' ); } /** * Add/Remove appropriate CSS classes to Menu so Submenu displays open and the Menu link is styled appropriately. * * @return Remove custome post type Lead * @package Phase 1 * @since Phase 1 * @version * @author Aretk Inc. * @param null */ public function aretkcrea_current_menu( ) { $screen = get_current_screen(); if ( $screen->id == 'edit-lead-category') { add_action( 'all_admin_notices', 'aretkcrea_action_all_admin_notices', 10, 2 ); function aretkcrea_action_all_admin_notices (){ echo '
'; } } if ( $screen->id == 'edit-aretk_lead') { add_action( 'all_admin_notices', 'aretkcrea_action_lead_post_content_admin_notices', 10, 2 ); function aretkcrea_action_lead_post_content_admin_notices () { echo '

Manage all your Leads in one place!

'; echo ''; } } } /** * function for remove post count tab in lead category * * @param get lead category table column $columns * @return return category column list */ function aretkcrea_remove_lead_category_post_count($columns){ //unset category post count unset($columns['posts']); //return category column return $columns; } /** * Remove Custom Post type feature like Quick edit, view etc * * @return $actions * @package Phase 1 * @since Phase 1 * @version * @author Aretk Inc. * @param null */ public function aretkcrea_post_row_actions_custom( $actions, $post ){ global $current_screen; if( $current_screen->post_type == 'aretk_lead' ) { unset( $actions['view'] ); unset( $actions['inline hide-if-no-js'] ); } elseif ( $post->post_title == "Advance Search" || $post->post_title == "Listings Detail"){ unset( $actions['edit'] ); unset( $actions['view'] ); unset( $actions['trash'] ); unset( $actions['inline hide-if-no-js'] ); } return $actions; } /** * Register Custom post type Listing * * @return return showcase custom post type * @package Phase 1 * @since Phase 1 * @version * @author Aretk Inc. * @param null */ public function aretkcrea_register_custom_post_type_listing(){ register_post_type( 'aretk_listing', array( 'labels' => array( 'name' => __( 'Listing', ARETKCREA_PLUGIN_SLUG ), 'singular_name' => __( 'Listing', ARETKCREA_PLUGIN_SLUG ), 'add_new' => __( 'Add New', ARETKCREA_PLUGIN_SLUG ), 'add_new_item' => __( 'Add New Listing', ARETKCREA_PLUGIN_SLUG ), 'edit' => __( 'Edit', ARETKCREA_PLUGIN_SLUG ), 'edit_item' => __( 'Edit Listing', ARETKCREA_PLUGIN_SLUG ), 'new_item' => __( 'New Listing', ARETKCREA_PLUGIN_SLUG ), 'view' => __( 'View', ARETKCREA_PLUGIN_SLUG ), 'view_item' => __( 'View Listing', ARETKCREA_PLUGIN_SLUG ), 'search_items' => __( 'Search Listing', ARETKCREA_PLUGIN_SLUG ), 'not_found' => __( 'No Listing found', ARETKCREA_PLUGIN_SLUG ), 'not_found_in_trash' => __( 'No Listing found in Trash', ARETKCREA_PLUGIN_SLUG ), 'parent' => __( 'Parent Listing', ARETKCREA_PLUGIN_SLUG ) ), 'public' => true, 'menu_position' => 15, 'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ), 'taxonomies' => array( '' ), //'menu_icon' => plugins_url( 'images/image.png', __FILE__ ), 'has_archive' => true ) ); } /** * Register Listing texoomy * * @return return custom texonomy for showcase * @package Phase 1 * @since Phase 1 * @version * @author Aretk Inc. * @param null */ public function aretkcrea_register_listing_taxonomy(){ $labels = array( 'name' => __( 'Listing Category', ARETKCREA_PLUGIN_SLUG ), 'singular_name' => __( 'Listing Category', ARETKCREA_PLUGIN_SLUG ), 'search_items' => __( 'Search Listings Category',ARETKCREA_PLUGIN_SLUG ), 'all_items' => __( 'All Listings Category',ARETKCREA_PLUGIN_SLUG ), 'parent_item' => __( 'Parent Listing Category',ARETKCREA_PLUGIN_SLUG ), 'parent_item_colon' => __( 'Parent Listing Category:',ARETKCREA_PLUGIN_SLUG ), 'edit_item' => __( 'Edit Listing Category',ARETKCREA_PLUGIN_SLUG ), 'update_item' => __( 'Update Listing Category',ARETKCREA_PLUGIN_SLUG ), 'add_new_item' => __( 'Add New Listing Category',ARETKCREA_PLUGIN_SLUG ), 'new_item_name' => __( 'New Listing Name Category',ARETKCREA_PLUGIN_SLUG ), 'menu_name' => __( 'Listing Category',ARETKCREA_PLUGIN_SLUG ), ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'listing' ), ); register_taxonomy( 'listing', array( 'aretk_listing' ), $args ); } /** * Register Custom post type Showcase * * @return return showcase custom post type * @package Phase 1 * @since Phase 1 * @version * @author Aretk Inc. * @param null */ public function aretkcrea_register_custom_post_type_showcase(){ register_post_type( 'aretk_showcase', array( 'labels' => array( 'name' => __( 'Showcase', ARETKCREA_PLUGIN_SLUG ), 'singular_name' => __( 'Showcase', ARETKCREA_PLUGIN_SLUG ), 'add_new' => __( 'Add New', ARETKCREA_PLUGIN_SLUG ), 'add_new_item' => __( 'Add New Showcase', ARETKCREA_PLUGIN_SLUG ), 'edit' => __( 'Edit', ARETKCREA_PLUGIN_SLUG ), 'edit_item' => __( 'Edit Showcase', ARETKCREA_PLUGIN_SLUG ), 'new_item' => __( 'New Showcase', ARETKCREA_PLUGIN_SLUG ), 'view' => __( 'View', ARETKCREA_PLUGIN_SLUG ), 'view_item' => __( 'View Showcase', ARETKCREA_PLUGIN_SLUG ), 'search_items' => __( 'Search Showcases', ARETKCREA_PLUGIN_SLUG ), 'not_found' => __( 'No Showcase found', ARETKCREA_PLUGIN_SLUG ), 'not_found_in_trash' => __( 'No Showcase found in Trash', ARETKCREA_PLUGIN_SLUG ), 'parent' => __( 'Parent Showcase', ARETKCREA_PLUGIN_SLUG ) ), 'public' => true, 'menu_position' => 15, 'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ), 'taxonomies' => array( '' ), 'has_archive' => true ) ); } /** * Register Listing showcase * * @return return custom texonomy for showcase * @package Phase 1 * @since Phase 1 * @version * @author Aretk Inc. * @param null */ public function aretkcrea_register_listing_showcase_taxonomy() { $labels = array( 'name' => __( 'Listing showcase', ARETKCREA_PLUGIN_SLUG ), 'singular_name' => __( 'Listing showcase', ARETKCREA_PLUGIN_SLUG ), 'search_items' => __( 'Search Listing showcases',ARETKCREA_PLUGIN_SLUG ), 'all_items' => __( 'All Listing showcases',ARETKCREA_PLUGIN_SLUG ), 'parent_item' => __( 'Parent Listing showcase',ARETKCREA_PLUGIN_SLUG ), 'parent_item_colon' => __( 'Parent Listing showcase:',ARETKCREA_PLUGIN_SLUG ), 'edit_item' => __( 'Edit Listing showcase',ARETKCREA_PLUGIN_SLUG ), 'update_item' => __( 'Update Listing showcase',ARETKCREA_PLUGIN_SLUG ), 'add_new_item' => __( 'Add New Listing showcase',ARETKCREA_PLUGIN_SLUG ), 'new_item_name' => __( 'New Listing showcase Name',ARETKCREA_PLUGIN_SLUG ), 'menu_name' => __( 'Listing showcase',ARETKCREA_PLUGIN_SLUG ), ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'listing-showcase' ), ); register_taxonomy( 'listing-showcase', array( 'aretk_showcase' ), $args ); } public function aretkcrea_create_listing_showcase_category() { $terms = get_terms( 'listing-showcase', array('hide_empty' => false)); if( empty($terms) ) { wp_insert_term( 'Listing Details Showcase', 'listing-showcase', array( 'slug' => 'listing-details-showcase' ) ); } } /** * Register Custom post type Lead * * @return return custom post type lead * @package Phase 1 * @package Phase 1 * @since Phase 1 * @version * @author Aretk Inc. * @param null */ public function aretkcrea_register_custom_post_type_leads(){ register_post_type( 'aretk_lead', array( 'labels' => array( 'name' => __( 'LEADS', ARETKCREA_PLUGIN_SLUG ), 'singular_name' => __( 'LEADS', ARETKCREA_PLUGIN_SLUG ), 'edit' => __( 'Edit', ARETKCREA_PLUGIN_SLUG ), 'edit_item' => __( 'Edit Lead', ARETKCREA_PLUGIN_SLUG ), 'search_items' => __( 'Search Lead', ARETKCREA_PLUGIN_SLUG ), 'not_found' => __( 'No Lead found', ARETKCREA_PLUGIN_SLUG ), 'parent' => __( 'Parent Lead', ARETKCREA_PLUGIN_SLUG ), 'capabilities' => array( 'create_posts' => true, ) ), 'public' => true, 'menu_position' => 15, 'hierarchical' => true, 'query_var' => true, 'taxonomies' => array( '' ), 'supports' => array('title', 'custom-fields'), 'has_archive' => true ) ); } function aretkcrea_register_create_new_lead_taxonomy(){ $labels = array( 'name' => __( 'LEAD CATEGORIES', ARETKCREA_PLUGIN_SLUG ), 'singular_name' => __( 'LEAD CATEGORY', ARETKCREA_PLUGIN_SLUG ), 'search_items' => __( 'Search Lead Category',ARETKCREA_PLUGIN_SLUG ), 'all_items' => __( 'All Lead Category',ARETKCREA_PLUGIN_SLUG ), 'parent_item' => __( 'Parent Lead Category',ARETKCREA_PLUGIN_SLUG ), 'parent_item_colon' => __( 'Parent Lead Category:',ARETKCREA_PLUGIN_SLUG ), 'edit_item' => __( 'Edit Lead Category',ARETKCREA_PLUGIN_SLUG ), 'update_item' => __( 'Update Lead Category',ARETKCREA_PLUGIN_SLUG ), 'add_new_item' => __( 'Add Lead Category',ARETKCREA_PLUGIN_SLUG ), 'new_item_name' => __( 'New Lead Category Name',ARETKCREA_PLUGIN_SLUG ), 'menu_name' => __( 'Create New Lead Category',ARETKCREA_PLUGIN_SLUG ), ); $args = array( 'hierarchical' => false, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'lead-category' ), ); register_taxonomy( 'lead-category', array( 'aretk_lead' ), $args ); } /** * This function will use for the ajax request for lead send mail * * @param null * @return null * @author Aretk Inc. * @since Phase 1 */ public function aretkcrea_lead_email_send() { global $wpdb; $admin_email_address = get_option('admin_email'); $allow_file_type = array("jpg","jpeg","png","gif","ico","mpg","mpeg","zip","rar","txt","ppt","doc","docx","xls","pdf","csv"); $send_email_subject = isset( $_POST['send_email_subject'] ) ?stripslashes($_POST['send_email_subject']): ''; $send_email_to = isset( $_POST['send_email_to'] ) ? $_POST['send_email_to'] : ''; $send_email_cc = isset( $_POST['send_email_cc'] ) ? $_POST['send_email_cc'] : ''; $send_email_bcc = isset( $_POST['send_email_bcc'] ) ? $_POST['send_email_bcc'] : ''; $send_email_text = isset( $_POST['send_email_text'] ) ? $_POST['send_email_text'] : ''; $send_email_lead_id = isset( $_POST['send_email_lead_id'] ) ? $_POST['send_email_lead_id'] : ''; $send_email_text2 = stripslashes($send_email_text); $send_email_text2 = str_replace('"', '\"', $send_email_text2); $send_email_text2 = json_encode($send_email_text2); $send_email_text2 = str_replace('\r\n', '', $send_email_text2); $send_email_text2 = json_decode($send_email_text2); if ( !empty($_FILES['file']['name']) ){ $get_file_type = explode('.', basename($_FILES['file']['name'])); // Explode file name from dot(.) $file_extension = end($get_file_type); $uploads_dir = $_SERVER['DOCUMENT_ROOT'].'/uploads/'; $sourcePath = isset($_FILES['file']['tmp_name']) ? $_FILES['file']['tmp_name'] :''; // Storing source path of the file in a variable $targetPath = isset($_FILES['file']['name']) ? "upload/".$_FILES['file']['name'] :''; // Target path where file is to be stored $attachement_arr = array(); if( in_array($file_extension,$allow_file_type) ) { if( $sourcePath != '' && $targetPath != '' ){ move_uploaded_file($sourcePath,$uploads_dir.$_FILES['file']['name']); $attachement_arr[] = $uploads_dir.$_FILES['file']['name']; } } } else { $attachement_arr = array(); } if (empty($send_email_to)){ $send_email_to = $admin_email_address; } $Mesaage = ''; $Mesaage .= '

'.str_replace('\"', '"', $send_email_text2).'


'; $headers = "From: ".get_bloginfo( 'name' )." <".$admin_email_address."> \r\n"; $headers .= "bcc: ".$send_email_bcc."\r\n"; if( !empty($send_email_cc) && $send_email_cc !="" ) { $headers .= "cc: ".$send_email_cc."\r\n"; } $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'content-type: text/html; charset=utf-8' . "\r\n"; $mailResponse = wp_mail($send_email_to,$send_email_subject,$Mesaage,$headers,$attachement_arr); $bulk_lead_ids = get_option('crea_bulk_email_lead_ids'); $explode_lead_ids = json_decode($bulk_lead_ids); $current_date = date_i18n( 'Y-m-d H:i' ); if( $explode_lead_ids !='' && !empty($explode_lead_ids)) { foreach ( $explode_lead_ids as $explode_lead_ids_key=>$explode_lead_ids_value ) { $new_corrsponding_key = 'crea_lead_corrsponding_text'.rand(100,999); $new_corrsponding_array = array(); $new_corrsponding_array[] = ''; $new_corrsponding_array[] = $send_email_text2; # message content $new_corrsponding_array[] = $current_date; # Sent date $new_corrsponding_array[] = str_replace('"', '\"', $send_email_subject); # message subject $new_corrsponding_array[] = 'emailed'; # message type: emailed, buyer inquiry, seller inquiry, general inquiry update_post_meta($explode_lead_ids_key,$new_corrsponding_key,json_encode($new_corrsponding_array)); } } update_option('crea_bulk_email_lead_ids',''); update_option('selected_lead_post_email_to_bcc',''); if( $mailResponse === true) { echo "Your email has been sent successfully."; } else { echo "Your Email not sent."; } if ( is_numeric($send_email_lead_id) ){ wp_safe_redirect(site_url("/wp-admin/admin.php?page=create_new_leads&ID=$send_email_lead_id&action=edit")); } die(); } /** * create function for aretkcrea_new_import_lead_user * * ajax callback function aretkcrea_new_import_lead_user * * @return return crea add import lead * @package Phase 1 * @since Phase 1 * @version 1.0.0 * @author Aretk Inc * @param null */ function aretkcrea_new_import_lead_user () { global $wpdb; $uploadDirr = $_SERVER['DOCUMENT_ROOT'].'/uploads/'; if (!file_exists($uploadDirr)) { mkdir($uploadDirr,0777,true); } if (!file_exists($uploadDirr.'lead/')) { mkdir($uploadDirr.'lead/',0777,true); } $uploads_dir = $uploadDirr.'lead/'; $sourcePath = $_FILES['crea_import_lead']['tmp_name']; $targetPath = "uploads/lead".$_FILES['crea_import_lead']['name']; move_uploaded_file($sourcePath,$uploads_dir.$_FILES['crea_import_lead']['name']); $import_lead_csv = fopen($_SERVER['DOCUMENT_ROOT'].'/uploads/lead/'.$_FILES['crea_import_lead']['name'], 'r'); while (($import_lead_csv_get_data = fgetcsv($import_lead_csv)) !== FALSE) { $import_lead_username = $import_lead_csv_get_data[0]; $import_lead_email = $import_lead_csv_get_data[1]; $import_lead_phone_no = $import_lead_csv_get_data[2]; $import_lead_comment = $import_lead_csv_get_data[3]; if( $import_lead_username != 'Name'){ $existing_import_lead_username = $import_lead_username; } if( $import_lead_email != 'Email Address'){ $existing_import_lead_email = $import_lead_email; } if( $import_lead_phone_no != 'Phone Number'){ $existing_import_lead_phone_no = $import_lead_phone_no; } if( $import_lead_comment != 'Comment'){ $existing_import_lead_comment = $import_lead_comment; } $post_table = $wpdb->prefix.'posts'; $post_meta_table = $wpdb->prefix.'postmeta'; $getAgentidResults = "SELECT * FROM $post_meta_table WHERE `meta_key`='lead_primary_email'"; $getAgentidResultsarray = $wpdb->get_results($getAgentidResults); $getAgentemailResults = "SELECT * FROM $post_meta_table WHERE `meta_key`='lead_phone_email'"; $getAgentemailResultsarray = $wpdb->get_results($getAgentemailResults); $add_primary_email_array = array(); foreach ( $getAgentidResultsarray as $getAgentidResultskey=>$getAgentidResultsvalue) { if( $getAgentidResultsvalue->meta_value != '' ){ $add_primary_email_array [$getAgentidResultsvalue->post_id]= $getAgentidResultsvalue->meta_value; } } $add_non_primary_email_array = array(); foreach ( $getAgentemailResultsarray as $getAgentemailResultkey=>$getAgentemailResultsvalue) { $implode_array = maybe_unserialize($getAgentemailResultsvalue->meta_value); $unserialize_array = maybe_unserialize($implode_array); $lead_phone_email =''; if( is_array($unserialize_array)) { $lead_phone_email = $unserialize_array[0]; } else{ $lead_phone_email =$unserialize_array; } $add_non_primary_email_array[$getAgentemailResultsvalue->post_id] = $lead_phone_email; } $merge_email_array_duplicate = $add_primary_email_array + $add_non_primary_email_array; if( !empty( $merge_email_array_duplicate) && $merge_email_array_duplicate !='' ) { foreach ( $merge_email_array_duplicate as $merge_email_array_key=>$merge_email_array_value ) { if( $merge_email_array_value == $import_lead_email) { $new_corrsponding_array = array(); $new_corrsponding_key = 'lead_primary_email'; $new_corrsponding_array[] = $get_contact_page_url; $new_corrsponding_array[] = $get_contact_message; update_post_meta($merge_email_array_key,'lead_primary_email',$existing_import_lead_email); update_post_meta($merge_email_array_key,'crea_agent_id',$existing_import_lead_agent_id); update_post_meta($merge_email_array_key,'lead_phone_no',$existing_import_lead_phone_no); echo"sucessfullyadded"; } } } if( !in_array($import_lead_email,$merge_email_array_duplicate)) { if ( isset($import_lead_username) && !empty($import_lead_username) && isset($import_lead_email) && !empty($import_lead_email) && isset($import_lead_phone_no) && !empty($import_lead_phone_no) && isset($import_lead_comment) && !empty($import_lead_comment) ){ if( $import_lead_username != 'Name' && $import_lead_email != 'Email Address' && $import_lead_phone_no != 'Phone Number' && $import_lead_comment !='Comment'){ $new_lead = array( 'post_title' => $existing_import_lead_username, 'post_content' => $existing_import_lead_comment, 'post_status' => 'publish', 'post_type' => 'aretk_lead' ); $import_lead_post_id = wp_insert_post($new_lead); update_post_meta($import_lead_post_id,'lead_primary_email',$existing_import_lead_email); update_post_meta($import_lead_post_id,'lead_phone_email',$existing_import_lead_email); update_post_meta($import_lead_post_id,'lead_phone_no',$existing_import_lead_phone_no); } } } } die(); } /** * This function will return the array with the subscription is valid or not * * @param unknown_type $subscriptionKey * @param unknown_type $domainName * @return array * @author Aretk Inc. * @since Phase 1 */ public static function aretkcrea_check_subscription_key_valid_api($subscriptionKey,$domainName){ global $wpdb; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ARETKCREA_SUBSCRIPTIONENDPOINT."/?api-key=$subscriptionKey&domain_name=$domainName"); curl_setopt($ch, CURLOPT_HEADER ,0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_REFERER,$domainName); $data = curl_exec($ch); curl_close($ch); $resultSetAPI = json_decode($data); if ( isset($resultSetAPI) && !empty($resultSetAPI) ) { if ( $resultSetAPI->code === 'success' ) { global $wpdb; update_option('crea_subscription_status','valid'); update_option('crea_subscription_key',"$subscriptionKey"); //code for subscription status in-active stored data record switch in aretk-api server $getSubscriptionKey = get_option('crea_subscription_key', ''); $subscriptionKey = !empty($getSubscriptionKey) ? $getSubscriptionKey : ''; $getSubscriptionStatus = get_option('crea_subscription_status', ''); $user_ID = get_current_user_id(); $post_meta_table = $wpdb->prefix."postmeta"; $InactiveStoredData = "SELECT post_id FROM $post_meta_table WHERE `meta_key`='crea_listing_subscription_states' AND `meta_value`='not-valid' "; $InactiveStoredDataResults = $wpdb->get_results($InactiveStoredData); $InactiveStoredDataResults_PostId = array(); foreach ( $InactiveStoredDataResults as $InactiveStoredDataResults_display ) { $postId = $InactiveStoredDataResults_display->post_id; $action = NULL; $InactiveStoredDataResults_PostId[] = $postId; $get_option = json_decode(get_option('crea_subscription_active_stored_Id')); $aretk_listing_id = get_post_meta($postId,'aretk_server_listing_id',true); if ( in_array($InactiveStoredDataResults_display->post_id,$get_option) && !empty($aretk_listing_id) ) { $action = 'edit'; } else { $action = 'add'; } if ($action === 'add' || $action === 'edit') { $listingAgentID = get_post_meta($postId,'listingAgentId',true); $listingAddress = get_post_meta($postId,'listingAddress',true); $listingcity = get_post_meta($postId,'listingcity',true); $listingProvince = get_post_meta($postId,'listingProvince',true); $listingAgentStatus = get_post_meta($postId,'listingAgentStatus',true); $listingPrice = get_post_meta($postId,'listingPrice',true); $listingPropertyType = get_post_meta($postId,'listingPropertyType',true); $listingStructureType = get_post_meta($postId,'listingStructureType',true); $listingBedRooms = get_post_meta($postId,'listingBedRooms',true); $listingBathrooms = get_post_meta($postId,'listingBathrooms',true); $listingBathroomsPartial = get_post_meta($postId,'listingBathroomsPartial',true); $listingFinishedBasement = get_post_meta($postId,'listingFinishedBasement',true); $listingFeatureArr = get_post_meta($postId,'listingFeatureArr',true); $listingParkinggarage = get_post_meta($postId,'listingParkinggarage',true); $listingParkingSlot = get_post_meta($postId,'listingParkingSlot',true); $listingTourUrl = get_post_meta($postId,'listingTourUrl',true); $listingUtilityArr = get_post_meta($postId,'listingUtilityArr',true); $listingopenhosedatetimeArr = get_post_meta($postId,'listingopenhosedatetimeArr',true); $listingGoogleMapLatitude = get_post_meta($postId,'crea_google_map_latitude',true); $listingGoogleMapLongitude = get_post_meta($postId,'crea_google_map_longitude',true); $listing_full_address_path = ''; if ( !empty( $listingAddress) ) { $listing_full_address_path.=sanitize_title($listingAddress); } if ( !empty( $listingcity ) ) { $listing_full_address_path.='-'.sanitize_title($listingcity); } if ( !empty( $listingProvince ) ) { $listing_full_address_path.='-'.sanitize_title($listingProvince); } $content_post = get_post($postId); $content = $content_post->post_content; $listing_public_remarks = $content; $agentFeaturesDecodeArrValue =''; //get agent ids array $agentsIDArr = array(); $agentsDecodeArr = json_decode($listingAgentID); $implode_agent_id =''; if( $agentsDecodeArr !='' && !empty($agentsDecodeArr) ) { $agent_id_counter = 1; foreach ( $agentsDecodeArr as $agentsDecodekey=>$agentsDecodeArrValue ){ $agentFeaturesDecodeArrValue = trim($agentFeaturesDecodeArrValue); if ( !empty( $agentsDecodeArrValue ) ){ $agentsIDArr[] = array("sequence_id" => $agent_id_counter , "agent_id" => $agentsDecodeArrValue ); } $agent_id_counter = $agent_id_counter + 1; } } // get agent features $agentFeaturesArr = array(); $agentFeaturesFinaleArr = ''; $agentFeaturesDecodeArr = json_decode($listingFeatureArr); if( $agentFeaturesDecodeArr != '' && !empty($agentFeaturesDecodeArr) ) { foreach ( $agentFeaturesDecodeArr as $agentFeaturesDecodeArrValue ) { $agentFeaturesDecodeArrValue = trim($agentFeaturesDecodeArrValue); if ( !empty( $agentFeaturesDecodeArrValue ) ){ $agentFeaturesArr[] = trim($agentFeaturesDecodeArrValue); } } $agentFeaturesFinaleArr = implode(",",$agentFeaturesArr); } // get agents utilitees $agentUtilitiesArr = array(); $agentUtilitiesDecodeArr = json_decode($listingUtilityArr); if( $agentUtilitiesDecodeArr != '' && !empty($agentUtilitiesDecodeArr) ) { $utitlity_counter = 1; foreach ($agentUtilitiesDecodeArr as $agentUtilitiesDecodeArrValue ) { $agentUtilitiesDecodeArrValue = trim($agentUtilitiesDecodeArrValue); if ( !empty( $agentUtilitiesDecodeArrValue ) ) { $agentUtilitiesArr[] = array("sequence_id" => $utitlity_counter , "type" => $agentUtilitiesDecodeArrValue ); } $utitlity_counter = $utitlity_counter + 1; } } // get agent images $agentPhotoArr = array(); $photoGelleryTable = $wpdb->prefix.'crea_listing_images_detail'; $photoQuery = "SELECT * FROM `$photoGelleryTable` WHERE `unique_id`= $postId ORDER BY `image_position` ASC"; $photoResultsArr = $wpdb->get_results($photoQuery); if( $photoResultsArr != '' && !empty($photoResultsArr) ) { $photo_counter = 1; foreach ( $photoResultsArr as $photoResultsArrValue ) { $agentPhotoArr[] = array("sequence_id" => $photo_counter , "url" => $photoResultsArrValue->image_url ); $photo_counter = $photo_counter + 1; } } // get agent externaldocument $agentDocumentArr = array(); $agentDocumentFinalArr = ''; $agentDocumentTable = $wpdb->prefix.'crea_listing_document_detail'; $agentDocumentQuery ="SELECT * FROM `$agentDocumentTable` WHERE `unique_id` = $postId ORDER BY `id`"; $agentDocumentResults = $wpdb->get_results($agentDocumentQuery); if( $agentDocumentResults != '' && !empty($agentDocumentResults) ) { foreach ( $agentDocumentResults as $agentDocumentResultsValue ) { $agentDocumentArr[] = $agentDocumentResultsValue->document_url; } $agentDocumentFinalArr = implode(",",$agentDocumentArr); } // agent Open House date and time $agentOpenHouseArr = array(); $agentOpenHouseDecodeArr = json_decode($listingopenhosedatetimeArr); if( $agentOpenHouseDecodeArr !='' && !empty($agentOpenHouseDecodeArr) ) { $openHouse_Counter = 1; foreach ( $agentOpenHouseDecodeArr as $agentOpenHouseDecodeArrKey=>$agentOpenHouseDecodeArrValue ){ $startDate = strtotime($agentOpenHouseDecodeArrValue->date); $startTime = $agentOpenHouseDecodeArrValue->start_time; $endTime =$agentOpenHouseDecodeArrValue->end_time; $agentStartDate = date('m/d/Y', $startDate)." ".date('h:i:s A', strtotime($startTime)); $agentEndDate = date('m/d/Y', $startDate)." ".date('h:i:s A', strtotime($endTime)); $agentFormatStartDate = $agentStartDate; $agentFormatEndDate = $agentEndDate; if( $agentFormatStartDate != "01/01/1970 12:00:00 AM" && $agentFormatEndDate != "01/01/1970 12:00:00 AM" ){ $agentOpenHouseArr[] = array("sequence_id" => $openHouse_Counter,"start_date" => $agentFormatStartDate,"end_date" => $agentFormatEndDate); } else { $agentOpenHouseArr = ""; } $openHouse_Counter = $openHouse_Counter + 1; } } if( $postId != '') { $add_listing_settinges_array = array(); $add_listing_settinges_array = array ( "street_address" => $listingAddress, "city" => $listingcity, "province" => $listingProvince, "transaction_type" => $listingAgentStatus, "price" => $listingPrice, "property_type" => $listingPropertyType, "structure" => $listingStructureType, "bedrooms_total" => $listingBedRooms, "bathroom_total" => $listingBathrooms, "halfbath_total" => $listingBathroomsPartial, "basement_type" => $listingFinishedBasement, "public_remarks" => $listing_public_remarks, "features" => $agentFeaturesFinaleArr, "garage" => $listingParkinggarage, "no_of_parking_spot" => $listingParkingSlot, "moreInformation_link" => $listingTourUrl, "utilities" => $agentUtilitiesArr, "photo" =>$agentPhotoArr, "external_document" => $agentDocumentFinalArr, "open_house" => $agentOpenHouseArr, "generated_address" => $listing_full_address_path, "geocoded_latitude" => $listingGoogleMapLatitude, "geocoded_longitude" => $listingGoogleMapLongitude, ); $post_string = http_build_query($add_listing_settinges_array); $exclusive_property_id = array(); $exclusive_property_id[] = (string)$postId; if ($action === 'add') { if (isset( $getSubscriptionStatus ) && !empty( $getSubscriptionStatus) && $getSubscriptionStatus === 'valid') { $addListing = curl_init(); curl_setopt($addListing, CURLOPT_HEADER, 0); curl_setopt($addListing, CURLOPT_VERBOSE, 0); curl_setopt($addListing, CURLOPT_URL, ARETKCREA_LISTING_BASEDONSERVER_API."/?key=$subscriptionKey&request=insert_listing"); curl_setopt($addListing, CURLOPT_POST, true); curl_setopt($addListing, CURLOPT_POSTFIELDS, $post_string); curl_setopt($addListing, CURLOPT_RETURNTRANSFER,true); curl_setopt($addListing, CURLOPT_REFERER,$domainName); $addListingCurlExecute = curl_exec($addListing); curl_close($addListing); $addListingCurlExecuteResponse = ($addListingCurlExecute) . PHP_EOL; $responseDecode = json_decode($addListingCurlExecuteResponse); if ( isset($responseDecode->code) && !empty($responseDecode->code) ) { if ($responseDecode->code === 200 && $responseDecode->status === 'success') { if (isset($responseDecode->data->insert_id)) { update_post_meta($postId,'aretk_server_listing_id',$responseDecode->data->insert_id); } } else { $exclusive_old_property_id_array = array(); $mergerd_property_id_array = array(); $exclusive_stored_add_id_result = get_option("exclusive_stored_add_id"); if ( !empty( $exclusive_stored_add_id_result ) ) { $exclusive_old_property_id_array = json_decode($exclusive_stored_add_id_result); } $mergerd_property_id_array = array_merge($exclusive_old_property_id_array,$exclusive_property_id); $mergerd_property_id_array = array_unique($mergerd_property_id_array); $mergerd_property_id_array = json_encode($mergerd_property_id_array); update_option("exclusive_stored_add_id",$mergerd_property_id_array); } } else { $exclusive_old_property_id_array = array(); $mergerd_property_id_array = array(); $exclusive_stored_add_id_result = get_option("exclusive_stored_add_id"); if ( !empty( $exclusive_stored_add_id_result ) ) { $exclusive_old_property_id_array = json_decode($exclusive_stored_add_id_result); } $mergerd_property_id_array = array_merge($exclusive_old_property_id_array,$exclusive_property_id); $mergerd_property_id_array = array_unique($mergerd_property_id_array); $mergerd_property_id_array = json_encode($mergerd_property_id_array); update_option("exclusive_stored_add_id",$mergerd_property_id_array); } } } else if ($action === 'edit' && $getSubscriptionStatus === 'valid') { $last_aretk_server_insert_id = get_post_meta($postId,'aretk_server_listing_id',true); $edit_listing_settinges_array = array(); if ( !empty( $last_aretk_server_insert_id ) ) { $edit_listing_settinges_array = array ( "id" => $last_aretk_server_insert_id, "agent_id" => $agentsIDArr, "street_address" => $listingAddress, "city" => $listingcity, "province" => $listingProvince, "transaction_type" => $listingAgentStatus, "price" => $listingPrice, "property_type" => $listingPropertyType, "structure" => $listingStructureType, "bedrooms_total" => $listingBedRooms, "bathroom_total" => $listingBathrooms, "halfbath_total" => $listingBathroomsPartial, "basement_type" => $listingFinishedBasement, "public_remarks" => $listing_public_remarks, "features" => $agentFeaturesFinaleArr, "garage" => $listingParkinggarage, "no_of_parking_spot" => $listingParkingSlot, "moreInformation_link" => $listingTourUrl, "utilities" => $agentUtilitiesArr, "photo" =>$agentPhotoArr, "external_document" => $agentDocumentFinalArr, "open_house" => $agentOpenHouseArr, "generated_address" => $listing_full_address_path, "geocoded_latitude" => $listingGoogleMapLatitude, "geocoded_longitude" => $listingGoogleMapLongitude, ); $post_string = http_build_query($edit_listing_settinges_array); $editListing = curl_init(); curl_setopt($editListing, CURLOPT_HEADER, 0); curl_setopt($editListing, CURLOPT_VERBOSE, 0); curl_setopt($editListing, CURLOPT_RETURNTRANSFER, true); curl_setopt($editListing, CURLOPT_URL, ARETKCREA_LISTING_BASEDONSERVER_API."/?key=$subscriptionKey&request=edit_listing"); curl_setopt($editListing, CURLOPT_POST, true); curl_setopt($editListing, CURLOPT_POSTFIELDS, $post_string); curl_setopt($editListing, CURLOPT_REFERER,$domainName); $editListingCurlExecute = curl_exec($editListing); curl_close($editListing); $editListingCurlExecuteResponse = ($editListingCurlExecute) . PHP_EOL; $responseDecode = json_decode($editListingCurlExecuteResponse); if ( isset($responseDecode->code) && !empty($responseDecode->code) ) { if ($responseDecode->code === 200 && $responseDecode->status === 'success') { if ( isset( $responseDecode->data->updated_id ) ) { update_post_meta($postId,'aretk_server_listing_id',$responseDecode->data->updated_id); } } } } } } } } $InActive_record_real_results = json_encode($InactiveStoredDataResults_PostId); update_option("crea_subscription_active_stored_Id",$InActive_record_real_results); $getSubscriptionStatus = get_option('crea_subscription_status', ''); $domainName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; if (empty($domainName)){ $domainName = get_site_url(); $domainName = parse_url($domainName, PHP_URL_HOST); } if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } //Delete Exclusive property from server $exclusive_deleted_id_result = get_option("exclusive_deleted_ids"); if ( !empty( $exclusive_deleted_id_result ) && $exclusive_deleted_id_result != 'null' ) { $exclusive_old_property_id_array = json_decode($exclusive_deleted_id_result); if ( isset($exclusive_old_property_id_array) && !empty($exclusive_old_property_id_array) ) { foreach ( $exclusive_old_property_id_array as $exclusive_old_property_id ) { if (isset( $getSubscriptionStatus ) && $getSubscriptionStatus === 'valid') { $delete_listing = array ( "id" => (int)$exclusive_old_property_id ); $post_string = http_build_query($delete_listing); $deleteListing = curl_init(); curl_setopt($deleteListing, CURLOPT_HEADER, 0); curl_setopt($deleteListing, CURLOPT_VERBOSE, 0); curl_setopt($deleteListing, CURLOPT_RETURNTRANSFER, true); curl_setopt($deleteListing, CURLOPT_URL, ARETKCREA_LISTING_BASEDONSERVER_API."/?key=$subscriptionKey&request=delete_listing"); curl_setopt($deleteListing, CURLOPT_POST, true); curl_setopt($deleteListing, CURLOPT_POSTFIELDS, $post_string); curl_setopt($deleteListing, CURLOPT_REFERER,$domainName); $deleteListingCurlExecute = curl_exec($deleteListing); curl_close($deleteListing); $deleteListingCurlExecuteResponse = ($deleteListingCurlExecute) . PHP_EOL; $responseDecode = json_decode($deleteListingCurlExecuteResponse); $crea_api_log_table_name = $wpdb->prefix.ARETKCREA_API_LOG_EXCLUSIVE; $user_ID = get_current_user_id(); } } $deleted_array = array(); $deleted_array = json_encode($deleted_array); update_option("exclusive_deleted_ids",$deleted_array); } } return 'valid'; } else { update_option('crea_subscription_status','not-valid'); update_option('crea_subscription_key',""); return 'not-valid'; } } else { update_option('crea_subscription_status','not-valid'); update_option('crea_subscription_key',""); return 'not-valid'; } } /** * This function will use for the ajax request to check key is valid or not. * * @param null * @return not-valid / valid * @author Aretk Inc. * @since Phase 1 */ public function aretkcrea_check_subscription_key_valid_ajax() { $pieces = parse_url(base64_decode(sanitize_text_field($_REQUEST['domain']))); $domainName = isset($pieces['host']) ? $pieces['host'] : ''; $SubscriptionKey = base64_decode(sanitize_text_field($_POST['subscriptionKey'])); echo Aretk_Crea_Admin::aretkcrea_check_subscription_key_valid_api($SubscriptionKey,$domainName); die(); } /** * This function will use for the ajax request to store the data of plgin settings tab * * @param null * @return null * @author Aretk Inc. * @since Phase 1 */ public function aretkcrea_save_plugin_settings_tab_data_ajax(){ $googleMapApiKey = base64_decode($_REQUEST['googleMapApiKey']); $walkScoreApiKey = base64_decode($_REQUEST['walkScoreApiKey']); $googlemapscriptloadornot = base64_decode($_REQUEST['googlemapscriptloadornot']); if( $googlemapscriptloadornot == 1 ) { $googlemapscriptloadornot_results = 'Yes'; }else { $googlemapscriptloadornot_results = 'No'; } $flagKeyUpdated = 0; str_replace(' ', '', $googleMapApiKey); update_option('crea_google_map_script_load_or_not',$googlemapscriptloadornot_results); $googleMapApiKey_results = str_replace(' ', '', $googleMapApiKey); $walkScoreApiKey_results = str_replace(' ', '', $walkScoreApiKey); if ($walkScoreApiKey_results != '' && !empty( $walkScoreApiKey_results ) && isset( $walkScoreApiKey_results )) { update_option('walk-score-api-name',"$walkScoreApiKey"); $flagKeyUpdated = 1; } if ($googleMapApiKey_results != '' && !empty( $googleMapApiKey_results ) && isset( $googleMapApiKey_results )) { update_option('google-map-api-name',"$googleMapApiKey"); $flagKeyUpdated = 1; } echo ARETKCREA_PLUGIN_SETTINGS_PAGE_BTN_SUCESS; die(); } /** * This function will return the array with the user data * * @param unknown_type $domainName * @return array * @author Aretk Inc. * @since Phase 1 */ public static function aretkcrea_get_user_listing_data_by_username($userName){ global $wpdb; $user_ID = get_current_user_id(); $getSubscriptionKey = get_option('crea_subscription_key', ''); $key = !empty($getSubscriptionKey) ? $getSubscriptionKey : ''; $domainName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; if (empty($domainName)){ $domainName = get_site_url(); $domainName = parse_url($domainName, PHP_URL_HOST); } if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ARETKCREA_LISTING_BASEDONSERVER_API."/?key=$key&request=feeds&feed=$userName"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_REFERER,$domainName); $data = curl_exec($ch); curl_close($ch); return $data; #$resultSet = json_decode($data); #return $resultSet; } /** * This function will add, edit and delete listing into the aretk database * * @param1 unknown_type $postId * @param2 unknown_type $action * @return array * @author Aretk Inc. * @since Phase 1 */ public static function aretkcrea_listing_update_to_aretk_server($postId,$action) { global $wpdb; $getSubscriptionKey = get_option('crea_subscription_key', ''); $subscriptionKey = !empty($getSubscriptionKey) ? $getSubscriptionKey : ''; $user_ID = get_current_user_id(); $getSubscriptionStatus = get_option('crea_subscription_status', ''); $domainName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; if (empty($domainName)){ $domainName = get_site_url(); $domainName = parse_url($domainName, PHP_URL_HOST); } if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } if ($action === 'add' || $action === 'edit') { /** * get listing post metavalue by listing id */ $listingAgentID = get_post_meta($postId,'listingAgentId',true); $listingAddress = get_post_meta($postId,'listingAddress',true); $listingcity = get_post_meta($postId,'listingcity',true); $listingProvince = get_post_meta($postId,'listingProvince',true); $listingAgentStatus = get_post_meta($postId,'listingAgentStatus',true); $listingPrice = get_post_meta($postId,'listingPrice',true); $listingPropertyType = get_post_meta($postId,'listingPropertyType',true); $listingStructureType = get_post_meta($postId,'listingStructureType',true); $listingBedRooms = get_post_meta($postId,'listingBedRooms',true); $listingBathrooms = get_post_meta($postId,'listingBathrooms',true); $listingBathroomsPartial = get_post_meta($postId,'listingBathroomsPartial',true); $listingFinishedBasement = get_post_meta($postId,'listingFinishedBasement',true); $listingFeatureArr = get_post_meta($postId,'listingFeatureArr',true); $listingParkinggarage = get_post_meta($postId,'listingParkinggarage',true); $listingParkingSlot = get_post_meta($postId,'listingParkingSlot',true); $listingTourUrl = get_post_meta($postId,'listingTourUrl',true); $listingUtilityArr = get_post_meta($postId,'listingUtilityArr',true); $listingopenhosedatetimeArr = get_post_meta($postId,'listingopenhosedatetimeArr',true); $listingGoogleMapLatitude = get_post_meta($postId,'crea_google_map_latitude',true); $listingGoogleMapLongitude = get_post_meta($postId,'crea_google_map_longitude',true); $listing_full_address_path = ''; if ( !empty( $listingAddress) ) { $listing_full_address_path.=sanitize_title($listingAddress); } if ( !empty( $listingcity ) ) { $listing_full_address_path.='-'.sanitize_title($listingcity); } if ( !empty( $listingProvince ) ) { $listing_full_address_path.='-'.sanitize_title($listingProvince); } $content_post = get_post($postId); $content = $content_post->post_content; $listing_public_remarks = $content; $agentFeaturesDecodeArrValue =''; //get agent ids array $agentsIDArr = array(); $agentsDecodeArr = json_decode($listingAgentID); $implode_agent_id =''; if( $agentsDecodeArr !='' && !empty($agentsDecodeArr) ) { $agent_id_counter = 1; foreach ( $agentsDecodeArr as $agentsDecodekey=>$agentsDecodeArrValue ){ $agentFeaturesDecodeArrValue = trim($agentFeaturesDecodeArrValue); if ( !empty( $agentsDecodeArrValue ) ){ $agentsIDArr[] = array("sequence_id" => $agent_id_counter , "agent_id" => $agentsDecodeArrValue ); } $agent_id_counter = $agent_id_counter + 1; } } // get agent features $agentFeaturesArr = array(); $agentFeaturesFinaleArr = ''; $agentFeaturesDecodeArr = json_decode($listingFeatureArr); if( $agentFeaturesDecodeArr != '' && !empty($agentFeaturesDecodeArr) ) { foreach ( $agentFeaturesDecodeArr as $agentFeaturesDecodeArrValue ) { $agentFeaturesDecodeArrValue = trim($agentFeaturesDecodeArrValue); if ( !empty( $agentFeaturesDecodeArrValue ) ){ $agentFeaturesArr[] = trim($agentFeaturesDecodeArrValue); } } $agentFeaturesFinaleArr = implode(",",$agentFeaturesArr); } // get agents utilitees $agentUtilitiesArr = array(); $agentUtilitiesDecodeArr = json_decode($listingUtilityArr); if( $agentUtilitiesDecodeArr != '' && !empty($agentUtilitiesDecodeArr) ) { $utitlity_counter = 1; foreach ($agentUtilitiesDecodeArr as $agentUtilitiesDecodeArrValue ) { $agentUtilitiesDecodeArrValue = trim($agentUtilitiesDecodeArrValue); if ( !empty( $agentUtilitiesDecodeArrValue ) ) { $agentUtilitiesArr[] = array("sequence_id" => $utitlity_counter , "type" => $agentUtilitiesDecodeArrValue ); } $utitlity_counter = $utitlity_counter + 1; } } // get agent images $agentPhotoArr = array(); $photoGelleryTable = $wpdb->prefix.'crea_listing_images_detail'; $photoQuery = "SELECT * FROM `$photoGelleryTable` WHERE `unique_id`= $postId ORDER BY `image_position` ASC"; $photoResultsArr = $wpdb->get_results($photoQuery); if( $photoResultsArr != '' && !empty($photoResultsArr) ) { $photo_counter = 1; foreach ( $photoResultsArr as $photoResultsArrValue ) { $agentPhotoArr[] = array("sequence_id" => $photo_counter , "url" => $photoResultsArrValue->image_url ); $photo_counter = $photo_counter + 1; } } // get agent externaldocument $agentDocumentArr = array(); $agentDocumentFinalArr = ''; $agentDocumentTable = $wpdb->prefix.'crea_listing_document_detail'; $agentDocumentQuery ="SELECT * FROM `$agentDocumentTable` WHERE `unique_id` = $postId ORDER BY `id`"; $agentDocumentResults = $wpdb->get_results($agentDocumentQuery); if( $agentDocumentResults != '' && !empty($agentDocumentResults) ) { foreach ( $agentDocumentResults as $agentDocumentResultsValue ) { $agentDocumentArr[] = $agentDocumentResultsValue->document_url; } $agentDocumentFinalArr = implode(",",$agentDocumentArr); } // agent Open House date and time $agentOpenHouseArr = array(); $agentOpenHouseDecodeArr = json_decode($listingopenhosedatetimeArr); if( $agentOpenHouseDecodeArr !='' && !empty($agentOpenHouseDecodeArr) ) { $openHouse_Counter = 1; foreach ( $agentOpenHouseDecodeArr as $agentOpenHouseDecodeArrKey=>$agentOpenHouseDecodeArrValue ){ //$startDate = date("d/m/Y", strtotime($agentOpenHouseDecodeArrValue->date)); $startDate = strtotime($agentOpenHouseDecodeArrValue->date); $startTime = $agentOpenHouseDecodeArrValue->start_time; $endTime =$agentOpenHouseDecodeArrValue->end_time; $agentStartDate = date('m/d/Y', $startDate)." ".date('h:i:s A', strtotime($startTime)); $agentEndDate = date('m/d/Y', $startDate)." ".date('h:i:s A', strtotime($endTime)); $agentFormatStartDate = $agentStartDate; $agentFormatEndDate = $agentEndDate; if( $agentFormatStartDate != "01/01/1970 12:00:00 AM" && $agentFormatEndDate != "01/01/1970 12:00:00 AM" ){ $agentOpenHouseArr[] = array("sequence_id" => $openHouse_Counter,"start_date" => $agentFormatStartDate,"end_date" => $agentFormatEndDate); } else { $agentOpenHouseArr = ""; } $openHouse_Counter = $openHouse_Counter + 1; } } if( $postId != '') { if ( $listingGoogleMapLatitude == '57.678079218156' ) { $listingGoogleMapLatitude = ''; } if ( $listingGoogleMapLongitude == '-101.8051686875' ) { $listingGoogleMapLongitude = ''; } $add_listing_settinges_array = array(); $add_listing_settinges_array = array ( "agent_id" => $agentsIDArr, "street_address" => $listingAddress, "city" => $listingcity, "province" => $listingProvince, "transaction_type" => $listingAgentStatus, "price" => $listingPrice, "property_type" => $listingPropertyType, "structure" => $listingStructureType, "bedrooms_total" => $listingBedRooms, "bathroom_total" => $listingBathrooms, "halfbath_total" => $listingBathroomsPartial, "basement_type" => $listingFinishedBasement, "public_remarks" => $listing_public_remarks, "features" => $agentFeaturesFinaleArr, "garage" => $listingParkinggarage, "no_of_parking_spot" => $listingParkingSlot, "moreInformation_link" => $listingTourUrl, "utilities" => $agentUtilitiesArr, "photo" =>$agentPhotoArr, "external_document" => $agentDocumentFinalArr, "open_house" => $agentOpenHouseArr, "generated_address" => $listing_full_address_path, "geocoded_latitude" => $listingGoogleMapLatitude, "geocoded_longitude" => $listingGoogleMapLongitude, ); $post_string = http_build_query($add_listing_settinges_array); $exclusive_property_id = array(); $exclusive_property_id[] = (string)$postId; if ($action === 'add') { if (isset( $getSubscriptionStatus ) && !empty( $getSubscriptionStatus) && $getSubscriptionStatus === 'valid') { $addListing = curl_init(); curl_setopt($addListing, CURLOPT_HEADER, 0); curl_setopt($addListing, CURLOPT_VERBOSE, 0); curl_setopt($addListing, CURLOPT_URL, ARETKCREA_LISTING_BASEDONSERVER_API."/?key=$subscriptionKey&request=insert_listing"); curl_setopt($addListing, CURLOPT_POST, true); curl_setopt($addListing, CURLOPT_POSTFIELDS, $post_string); curl_setopt($addListing, CURLOPT_RETURNTRANSFER,true); curl_setopt($addListing, CURLOPT_REFERER,$domainName); $addListingCurlExecute = curl_exec($addListing); curl_close($addListing); $addListingCurlExecuteResponse = ($addListingCurlExecute) . PHP_EOL; $responseDecode = json_decode($addListingCurlExecuteResponse); if ( isset($responseDecode->code) && !empty($responseDecode->code) ) { if ($responseDecode->code === 200 && $responseDecode->status === 'success') { if (isset($responseDecode->data->insert_id)) { update_post_meta($postId,'aretk_server_listing_id',$responseDecode->data->insert_id); } } else { $exclusive_old_property_id_array = array(); $mergerd_property_id_array = array(); $exclusive_stored_add_id_result = get_option("exclusive_stored_add_id"); if ( !empty( $exclusive_stored_add_id_result ) ) { $exclusive_old_property_id_array = json_decode($exclusive_stored_add_id_result); } $mergerd_property_id_array = array_merge($exclusive_old_property_id_array,$exclusive_property_id); $mergerd_property_id_array = array_unique($mergerd_property_id_array); $mergerd_property_id_array = json_encode($mergerd_property_id_array); update_option("exclusive_stored_add_id",$mergerd_property_id_array); } } else { $exclusive_old_property_id_array = array(); $mergerd_property_id_array = array(); $exclusive_stored_add_id_result = get_option("exclusive_stored_add_id"); if ( !empty( $exclusive_stored_add_id_result ) ) { $exclusive_old_property_id_array = json_decode($exclusive_stored_add_id_result); } $mergerd_property_id_array = array_merge($exclusive_old_property_id_array,$exclusive_property_id); $mergerd_property_id_array = array_unique($mergerd_property_id_array); $mergerd_property_id_array = json_encode($mergerd_property_id_array); update_option("exclusive_stored_add_id",$mergerd_property_id_array); } } } else if ($action === 'edit') { if (isset( $getSubscriptionStatus ) && !empty( $getSubscriptionStatus) && $getSubscriptionStatus === 'valid') { if ( $listingGoogleMapLatitude == '57.678079218156' ) { $listingGoogleMapLatitude = ''; } if ( $listingGoogleMapLongitude == '-101.8051686875' ) { $listingGoogleMapLongitude = ''; } $last_aretk_server_insert_id = get_post_meta($postId,'aretk_server_listing_id',true); $edit_listing_settinges_array = array(); $edit_listing_settinges_array = array ( "id" => $last_aretk_server_insert_id, "agent_id" => $agentsIDArr, "street_address" => $listingAddress, "city" => $listingcity, "province" => $listingProvince, "transaction_type" => $listingAgentStatus, "price" => $listingPrice, "property_type" => $listingPropertyType, "structure" => $listingStructureType, "bedrooms_total" => $listingBedRooms, "bathroom_total" => $listingBathrooms, "halfbath_total" => $listingBathroomsPartial, "basement_type" => $listingFinishedBasement, "public_remarks" => $listing_public_remarks, "features" => $agentFeaturesFinaleArr, "garage" => $listingParkinggarage, "no_of_parking_spot" => $listingParkingSlot, "moreInformation_link" => $listingTourUrl, "utilities" => $agentUtilitiesArr, "photo" =>$agentPhotoArr, "external_document" => $agentDocumentFinalArr, "open_house" => $agentOpenHouseArr, "generated_address" => $listing_full_address_path, "geocoded_latitude" => $listingGoogleMapLatitude, "geocoded_longitude" => $listingGoogleMapLongitude, ); $post_string = http_build_query($edit_listing_settinges_array); $editListing = curl_init(); curl_setopt($editListing, CURLOPT_HEADER, 0); curl_setopt($editListing, CURLOPT_VERBOSE, 0); curl_setopt($editListing, CURLOPT_RETURNTRANSFER, true); curl_setopt($editListing, CURLOPT_URL, ARETKCREA_LISTING_BASEDONSERVER_API."/?key=$subscriptionKey&request=edit_listing"); curl_setopt($editListing, CURLOPT_POST, true); curl_setopt($editListing, CURLOPT_POSTFIELDS, $post_string); curl_setopt($editListing, CURLOPT_REFERER,$domainName); $editListingCurlExecute = curl_exec($editListing); curl_close($editListing); $editListingCurlExecuteResponse = ($editListingCurlExecute) . PHP_EOL; $responseDecode = json_decode($editListingCurlExecuteResponse); if ( isset($responseDecode->code) && !empty($responseDecode->code) ) { if ($responseDecode->code === 200 && $responseDecode->status === 'success') { if ( isset( $responseDecode->data->updated_id ) ) { update_post_meta($postId,'aretk_server_listing_id',$responseDecode->data->updated_id); } } } } } } } elseif ($action === 'delete') { if (isset( $getSubscriptionStatus ) && $getSubscriptionStatus === 'valid') { $last_aretk_server_insert_id = get_post_meta($postId,'aretk_server_listing_id',true); $delete_listing = array ( "id" => $postId ); $post_string = http_build_query($delete_listing); $deleteListing = curl_init(); curl_setopt($deleteListing, CURLOPT_HEADER, 0); curl_setopt($deleteListing, CURLOPT_VERBOSE, 0); curl_setopt($deleteListing, CURLOPT_RETURNTRANSFER, true); curl_setopt($deleteListing, CURLOPT_URL, ARETKCREA_LISTING_BASEDONSERVER_API."/?key=$subscriptionKey&request=delete_listing"); curl_setopt($deleteListing, CURLOPT_POST, true); curl_setopt($deleteListing, CURLOPT_POSTFIELDS, $post_string); curl_setopt($deleteListing, CURLOPT_REFERER,$domainName); $deleteListingCurlExecute = curl_exec($deleteListing); curl_close($deleteListing); $deleteListingCurlExecuteResponse = ($deleteListingCurlExecute) . PHP_EOL; $responseDecode = json_decode($deleteListingCurlExecuteResponse); } } } /** * This function will return the array with the user data * * @param unknown_type userName,result_type ,agent_ids * @return array */ /* public static function aretkcrea_get_user_listing_records_by_username_by_filter_view_type( $userName,$result_type,$filter_array ){ global $wpdb; $user_ID = get_current_user_id(); $getSubscriptionKey = get_option('crea_subscription_key', ''); $subscriptionKey = !empty($getSubscriptionKey) ? $getSubscriptionKey : ''; $filter_array_results = ""; if(!empty( $filter_array ) && isset($filter_array)){ $filter_array_openhouse = !empty($filter_array['showcse_crea_filter_inclue_open_house'])? $filter_array['showcse_crea_filter_inclue_open_house'] :''; $filter_array_other_day = !empty($filter_array['showcse_crea_filter_by_other_day'])? $filter_array['showcse_crea_filter_by_other_day'] :''; $filter_array_map_km = !empty($filter_array['showcse_crea_filter_by_map_km']) ? $filter_array['showcse_crea_filter_by_map_km'] :'' ; $filter_showcse_crea_filter_google_map_latitude = !empty($filter_array['showcse_crea_filter_google_map_latitude']) ? $filter_array['showcse_crea_filter_google_map_latitude'] :'' ; $filter_showcse_crea_filter_google_map_longitude = !empty($filter_array['showcse_crea_filter_google_map_longitude']) ? $filter_array['showcse_crea_filter_google_map_longitude'] :'' ; $filter_array_price_sorting = !empty($filter_array['showcse_crea_filter_price_sorting']) ? $filter_array['showcse_crea_filter_price_sorting'] :'price-desc'; $filter_array_office_id = !empty($filter_array['showcse_crea_filter_office_id']) ? $filter_array['showcse_crea_filter_office_id'] :''; $filter_array_board_id = !empty($filter_array['showcse_crea_filter_board_id']) ? $filter_array['showcse_crea_filter_board_id'] :''; $filter_array_agent_id = !empty($filter_array['showcse_crea_filter_agent_id']) ? $filter_array['showcse_crea_filter_agent_id'] :''; //Advance search filter $filter_array_keyword = !empty($filter_array['keyword']) ? $filter_array['keyword'] :''; $filter_array_property_types = !empty($filter_array['property_types']) ? $filter_array['property_types'] :''; $filter_array_structure_types = !empty($filter_array['structure_types']) ? $filter_array['structure_types'] :''; $filter_array_transaction_type = !empty($filter_array['transaction_type']) ? $filter_array['transaction_type'] :''; $filter_array_bedrooms = !empty($filter_array['bedrooms']) ? $filter_array['bedrooms'] :''; $filter_array_bathrooms = !empty($filter_array['bathrooms']) ? $filter_array['bathrooms'] :''; $filter_array_city = !empty($filter_array['city']) ? $filter_array['city'] :''; $filter_min_amount = !empty($filter_array['min_amount']) ? $filter_array['min_amount'] :''; $filter_max_amount = !empty($filter_array['max_amount']) ? $filter_array['max_amount'] :''; $filter_include_exclusive = !empty($filter_array['include_exclusive']) ? $filter_array['include_exclusive'] :''; if(isset( $filter_array_keyword ) && !empty( $filter_array_keyword )) { $filter_array_results.= '&keyword='.rawurlencode($filter_array_keyword); } if(isset( $filter_array_property_types ) && !empty( $filter_array_property_types )) { $filter_array_results.= '&property_types='.rawurlencode($filter_array_property_types); } if(isset( $filter_array_structure_types ) && !empty( $filter_array_structure_types )) { $filter_array_results.= '&structure_types='.rawurlencode($filter_array_structure_types); } if(isset( $filter_array_transaction_type ) && !empty( $filter_array_transaction_type )) { $filter_array_results.= '&transaction_type='.rawurlencode($filter_array_transaction_type); } if(isset( $filter_array_bedrooms ) && !empty( $filter_array_bedrooms )) { $filter_array_results .="&bed_min=$filter_array_bedrooms"; } if(isset( $filter_array_bathrooms ) && !empty( $filter_array_bathrooms )) { $filter_array_results .="&bath_min=$filter_array_bathrooms"; } if(isset( $filter_array_city ) && !empty( $filter_array_city )) { $filter_array_results .="&city=".rawurlencode($filter_array_city); } if(isset( $filter_min_amount ) && !empty( $filter_min_amount )) { $filter_array_results .="&price_min=$filter_min_amount"; } if( isset( $filter_max_amount ) && $filter_max_amount !='' ) { $filter_array_results .="&price_max=$filter_max_amount"; } if( isset( $filter_include_exclusive ) && $filter_include_exclusive !='' ) { $filter_array_results .="&exclusive=$filter_include_exclusive"; } $record_limit = isset($filter_array['record_limit']) ? $filter_array['record_limit'] :'20'; $record_offset = isset($filter_array['record_offset']) ? $filter_array['record_offset'] :'0'; $showcase_view = isset($filter_array['showcase_view']) ? $filter_array['showcase_view'] :''; $showcase_mapviewlat_sw = isset($filter_array['mapviewlat_sw']) ? $filter_array['mapviewlat_sw'] :''; $showcase_mapviewlong_sw = isset($filter_array['mapviewlong_sw']) ? $filter_array['mapviewlong_sw'] :''; $showcase_mapviewlat_ne = isset($filter_array['mapviewlat_ne']) ? $filter_array['mapviewlat_ne'] :''; $showcase_mapviewlong_ne = isset($filter_array['mapviewlong_ne']) ? $filter_array['mapviewlong_ne'] :''; if(isset( $filter_array_openhouse ) && !empty( $filter_array_openhouse )){ if( $filter_array_openhouse === 'yes'){ $filter_array_openhouse = "true"; $filter_array_results .= '&openhouse='.$filter_array_openhouse; } } if(isset( $filter_array_other_day ) && !empty( $filter_array_other_day )) { $filter_array_results.= '&daysactive='.$filter_array_other_day; } //Map readius pass if(isset( $filter_array_map_km ) && !empty( $filter_array_map_km ) && !empty( $filter_showcse_crea_filter_google_map_latitude ) && isset( $filter_showcse_crea_filter_google_map_latitude ) && !empty( $filter_showcse_crea_filter_google_map_longitude ) && isset( $filter_showcse_crea_filter_google_map_longitude ) ) { $filter_array_results.= '&area='.$filter_array_map_km.'('.$filter_showcse_crea_filter_google_map_latitude.','.$filter_showcse_crea_filter_google_map_longitude.')'; } //Order by if(isset( $filter_array_price_sorting ) && !empty( $filter_array_price_sorting )) { $filter_array_results.= '&order='.$filter_array_price_sorting; } //Office id if(isset( $filter_array_office_id ) && !empty( $filter_array_office_id )) { $filter_array_results.= '&office_ids='.$filter_array_office_id; } //Board id if(isset( $filter_array_board_id ) && !empty( $filter_array_board_id )) { $filter_array_results.= '&board='.$filter_array_board_id; } //Agent id if(isset( $filter_array_agent_id ) && !empty( $filter_array_agent_id )) { $filter_array_results.= '&agent_ids='.$filter_array_agent_id; } if( !empty($showcase_view) && $showcase_view == "Listing View" ) { //API Record Limit if ( !empty($record_limit) ) { $filter_array_results.= '&limit='.$record_limit; } if ( !empty($record_offset) ) { $filter_array_results.= '&offset='.$record_offset; } } elseif ( $showcase_view == "Grid View"){ //API Record Limit if ( !empty($record_limit) ) { $filter_array_results.= '&limit='.$record_limit; } if ( !empty($record_offset) ) { $filter_array_results.= '&offset='.$record_offset; } } elseif ( $showcase_view == "Slider" ){ //API Record Limit if ( !empty($record_limit) ) { $filter_array_results.= '&limit='.$record_limit; } if ( !empty($record_offset) ) { $filter_array_results.= '&offset='.$record_offset; } } elseif ( $showcase_view == "Carousel" ){ //API Record Limit if ( !empty($record_limit) ) { $filter_array_results.= '&limit='.$record_limit; } if ( !empty($record_offset) ) { $filter_array_results.= '&offset='.$record_offset; } } else if( $showcase_view == "Map"){ $filter_array_results.= '&result_type=mapmarkers'; } } $userNameFilter = ''; if ( !empty($userName) && $userName != 'Exclusive Listing' ) { $userNameFilter .= '&feed='.$userName; } $domainName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; if (empty($domainName)){ $domainName = get_site_url(); $domainName = parse_url($domainName, PHP_URL_HOST); } if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ARETKCREA_SUBSCRIPTIONENDPOINT."/?key=$subscriptionKey&request=listings$userNameFilter$filter_array_results"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_REFERER,$domainName); $data = curl_exec($ch); curl_close($ch); $resultSet = json_decode($data); $user_ID = get_current_user_id(); $agent_ids = ''; return $resultSet; } */ /** * This function will return the array with the user data * * @param unknown_type $domainName * @return array * @author Aretk Inc. * @since Phase 1 */ public static function aretkcrea_get_user_listing_records_by_username_by_view_type($userName,$result_type){ global $wpdb; $domainName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; if (empty($domainName)){ $domainName = get_site_url(); $domainName = parse_url($domainName, PHP_URL_HOST); } if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; }; $user_ID = get_current_user_id(); $getSubscriptionKey = get_option('crea_subscription_key', ''); $subscriptionKey = !empty($getSubscriptionKey) ? $getSubscriptionKey : ''; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ARETKCREA_LISTING_BASEDONSERVER_API."/?key=$subscriptionKey&request=listings&feed=$userName&result_type=$result_type&limit=20&offset=0"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_REFERER,$domainName); $data = curl_exec($ch); curl_close($ch); $resultSet = json_decode($data); $agent_ids = ''; return $resultSet; } /** * This function will return the array with property data * * @return array * @author Aretk Inc. * @since Phase 1 */ /* public static function aretkcrea_get_default_listing_records($userName,$result_type,$filter_array){ global $wpdb; $user_ID = get_current_user_id(); $getSubscriptionKey = get_option('crea_subscription_key', ''); $subscriptionKey = !empty($getSubscriptionKey) ? $getSubscriptionKey : ''; $record_limit = isset($filter_array['record_limit']) ? $filter_array['record_limit'] :'20'; $record_offset = isset($filter_array['record_offset']) ? $filter_array['record_offset'] :'0'; //API Record Limit $filter_array_results = ''; if ( !empty($record_limit) ) { $filter_array_results.= '&limit='.$record_limit; } if ( !empty($record_offset) ) { $filter_array_results.= '&offset='.$record_offset; } $userNameFilter = ''; if ( !empty($userName) ) { $userNameFilter .= '&feed='.$userName; } $domainName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; if (empty($domainName)){ $domainName = get_site_url(); $domainName = parse_url($domainName, PHP_URL_HOST); } if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ARETKCREA_SUBSCRIPTIONENDPOINT."/?key=$subscriptionKey&request=listings&exclusive=true$userNameFilter&result_type=$result_type$filter_array_results"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_REFERER,$domainName); $data = curl_exec($ch); curl_close($ch); $resultSet = json_decode($data); $agent_ids = ''; return $resultSet; } */ public static function aretkcrea_get_listing_records_based_on_agents($userName,$result_type,$agent_ids){ global $wpdb; $user_ID = get_current_user_id(); $getSubscriptionKey = get_option('crea_subscription_key', ''); $subscriptionKey = !empty($getSubscriptionKey) ? $getSubscriptionKey : ''; $filter_results = ''; if ( !empty($agent_ids) && $agent_ids != null ){ $filter_results .= '&agent_ids='.$agent_ids; } $domainName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; if (empty($domainName)){ $domainName = get_site_url(); $domainName = parse_url($domainName, PHP_URL_HOST); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ARETKCREA_LISTING_BASEDONSERVER_API."/?key=$subscriptionKey&request=listings&feed=$userName$filter_results&result_type=$result_type&limit=100&viewcount=true"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_REFERER,$domainName); $data = curl_exec($ch); curl_close($ch); $resultSet = json_decode($data); $agent_ids = ''; return $resultSet; } public static function aretkcrea_get_property_detail_page_result( $userName,$result_type,$property_id ){ global $wpdb; $user_ID = get_current_user_id(); $getSubscriptionKey = get_option('crea_subscription_key', ''); $subscriptionKey = !empty($getSubscriptionKey) ? $getSubscriptionKey : ''; $result_type = 'full'; if ( !empty($property_id) && $property_id != null ) { $property_id = '&ids='.$property_id; } $domainName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; if (empty($domainName)){ $domainName = get_site_url(); $domainName = parse_url($domainName, PHP_URL_HOST); } if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ARETKCREA_LISTING_BASEDONSERVER_API."/?key=$subscriptionKey&request=listings&exclusive=true&viewcount=true&feed=$userName&result_type=$result_type$property_id"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_REFERER,$domainName); $data = curl_exec($ch); curl_close($ch); $resultSet = json_decode($data, true); return $resultSet; } public static function aretkcrea_get_property_detail_page_result_for_exclusive( $property_id , $return_array = false){ global $wpdb; $user_ID = get_current_user_id(); $getSubscriptionKey = get_option('crea_subscription_key', ''); $subscriptionKey = !empty($getSubscriptionKey) ? $getSubscriptionKey : ''; $result_type = 'full'; if ( !empty($property_id) && $property_id != null ) { $property_id = '&ids='.$property_id; } $domainName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; if (empty($domainName)){ $domainName = get_site_url(); $domainName = parse_url($domainName, PHP_URL_HOST); } if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ARETKCREA_LISTING_BASEDONSERVER_API."/?key=$subscriptionKey&request=listings&exclusive=true&viewcount=true&result_type=$result_type$property_id"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_REFERER,$domainName); $data = curl_exec($ch); curl_close($ch); $resultSet = json_decode($data, true); return $resultSet; } /** * This function will use for the ajax request to display updated data of partcular username crea settings tab * * @param null * @return null * @author Aretk Inc. * @since Phase 1 */ public function aretkcrea_fetch_total_records_of_username_ajax() { global $wpdb; $usernameAndDdfTypeArr = $_REQUEST['usernameAndDdfTypeArr']; $crea_user_listing_detail_table_name = $wpdb->prefix.ARETKCREA_USER_LISTING_DETAILS; $truncateTableQuery = "TRUNCATE TABLE $crea_user_listing_detail_table_name"; $wpdb->query($truncateTableQuery); $tempUserNameArr = array(); foreach ($usernameAndDdfTypeArr as $singleUser) { $Username = $singleUser[0]; $ddfType = $singleUser[1]; if ($Username != '' && $ddfType != '') { if (!in_array($Username,$tempUserNameArr)) { $tempUserNameArr[] = $Username; $resultSet = Aretk_Crea_Admin::aretkcrea_get_user_listing_data_by_username($Username); if (isset($resultSet) && $resultSet != null && $resultSet != ''){ $user_listing_details_obj_merged = (object) array_merge((array) $resultSet[0], (array) $resultSet[1]); if ($user_listing_details_obj_merged != '' && isset($user_listing_details_obj_merged) && $user_listing_details_obj_merged != null){ $user_ID = get_current_user_id(); $checkExistsQuery = "SELECT `id` FROM $crea_user_listing_detail_table_name WHERE `username` = '$Username' AND `ddf_type` = '$ddfType'"; $resultSetCheckExists = $wpdb->get_results($checkExistsQuery); if (isset($resultSetCheckExists) && $resultSetCheckExists != null && $resultSetCheckExists != '') { $wpdb->update( "$crea_user_listing_detail_table_name", array( 'user_id' => $user_ID, 'username' => "$Username", 'ddf_type' => "$ddfType", 'updated_time' => current_time('mysql', 1) ), array( 'id' => $resultSetCheckExists[0]->id ), array( '%d', '%s', '%s', '%s', ), array( '%d' ) ); } else { $wpdb->insert( "$crea_user_listing_detail_table_name", array( 'user_id' => $user_ID, 'username' => "$Username", 'ddf_type' => "$ddfType", 'created_time' => current_time('mysql', 1), 'updated_time' => current_time('mysql', 1), ), array( '%d', '%s', '%s', '%s', '%s', ) ); } } } } } unset($singleUser); } unset($usernameAndDdfTypeArr); $crea_user_listing_detail_table_name = $wpdb->prefix.ARETKCREA_USER_LISTING_DETAILS; $getUsername = "SELECT `username`, `ddf_type` FROM $crea_user_listing_detail_table_name"; $resultUsernameSetArr = $wpdb->get_results($getUsername); $firstUserName = isset($resultUsernameSetArr[0]->username) ? $resultUsernameSetArr[0]->username : '' ; $secondUserName = isset($resultUsernameSetArr[1]->username) ? $resultUsernameSetArr[1]->username : '' ; $thirdUserName = isset($resultUsernameSetArr[2]->username) ? $resultUsernameSetArr[2]->username : '' ; $fourthUserName = isset($resultUsernameSetArr[3]->username) ? $resultUsernameSetArr[3]->username : '' ; $fifthUserName = isset($resultUsernameSetArr[4]->username) ? $resultUsernameSetArr[4]->username : '' ; if ($firstUserName != '') { $datafirstUserName = Aretk_Crea_Admin::aretkcrea_get_user_listing_data_by_username($firstUserName); update_option('firstUserNameresultSet',""); update_option('firstUserNameresultSet',$datafirstUserName); } if ($secondUserName != '') { $datasecondUserName = Aretk_Crea_Admin::aretkcrea_get_user_listing_data_by_username($secondUserName); update_option('secondUserNameresultSet',""); update_option('secondUserNameresultSet',$datasecondUserName); } if ($thirdUserName != '') { $datathirdUserName = Aretk_Crea_Admin::aretkcrea_get_user_listing_data_by_username($thirdUserName); update_option('thirdUserNameresultSet',""); update_option('thirdUserNameresultSet',$datathirdUserName); } if ($fourthUserName != '') { $datafourthUserName = Aretk_Crea_Admin::aretkcrea_get_user_listing_data_by_username($fourthUserName); update_option('fourthUserNameresultSet',""); update_option('fourthUserNameresultSet',$datafourthUserName); } if ($fifthUserName != '') { $datafifthUserName = Aretk_Crea_Admin::aretkcrea_get_user_listing_data_by_username($fifthUserName); update_option('fifthUserNameresultSet',""); update_option('fifthUserNameresultSet',$datafifthUserName); } Aretk_Crea_Admin::aretkcrea_answer_expiration_event_admin(); return 'success'; die(); } public static function aretkcrea_answer_expiration_event_admin( ) { global $wpdb; $getSubscriptionStatus = get_option('crea_subscription_status', ''); update_option('cron_run',""); update_option('cron_run_time',""); update_option('cron_run_time',date("h:i:sa")); if( isset( $getSubscriptionStatus ) && !empty( $getSubscriptionStatus ) && $getSubscriptionStatus === 'valid' ) { $crea_user_name_table_name = $wpdb->prefix.ARETKCREA_USER_LISTING_DETAILS; $getAllUsername = $wpdb->get_results("SELECT `username` FROM $crea_user_name_table_name"); $allListingArr = array(); //get all agent ids from database $crea_agent_table_name = $wpdb->prefix . ARETKCREA_AGENT_TABLE; $getAllAgentIds = $wpdb->get_results("SELECT `crea_agent_id` FROM $crea_agent_table_name"); $getAllAgentIdArray = array(); if ( isset($getAllAgentIds) && !empty($getAllAgentIds) ){ foreach ($getAllAgentIds as $agent_key => $agent ) { $getAllAgentIdArray[] = $agent->crea_agent_id; } } if ( isset($getAllAgentIdArray) && !empty($getAllAgentIdArray)) { $agent_ids = implode(',',$getAllAgentIdArray); } else { $agent_ids = null; } $allListingArr = array(); $userNameList = ''; if (isset($getAllUsername) && !empty($getAllUsername)) { foreach ($getAllUsername as $singleUsername) { $userName = $singleUsername->username; if ( !empty( $userName ) ){ $userNameList.=$userName.','; } unset($singleUsername); } unset($getAllUsername); $userNameList = rtrim($userNameList,','); $result_type = 'full'; if ( $agent_ids != null ){ $listings = Aretk_Crea_Admin::aretkcrea_get_listing_records_based_on_agents($userNameList, $result_type,$agent_ids); if ( isset($listings) && !empty($listings)) { foreach ($listings as $listing_key => $listing ){ if ( !isset( $listing->TotalRecords ) && empty( $listing->TotalRecords ) ) { $allListingArr[$listing->mlsID] = $listing; } } } } } $args = array( 'posts_per_page' => -1, 'post_type' => 'aretk_listing', 'post_status' => 'publish' ); $posts_array = (array) get_posts( $args ); $exclusiveArr = array(); foreach ($posts_array as $singlePost) { $singlePost1 = (array) $singlePost; $singlePost2 = (object) $singlePost1; $exclusiveArr[] = $singlePost2; } $allListingFinalArr = array(); $allListingFinalArr = array_merge($allListingArr,$exclusiveArr); $data = json_encode($allListingFinalArr); update_option('cron_run',""); update_option('cron_run',"$data"); $crea_user_listing_detail_table_name = $wpdb->prefix.ARETKCREA_USER_LISTING_DETAILS; $getUsername = "SELECT `username`, `ddf_type` FROM $crea_user_listing_detail_table_name"; $resultUsernameSetArr = $wpdb->get_results($getUsername); $firstUserName = isset($resultUsernameSetArr[0]->username) ? $resultUsernameSetArr[0]->username : '' ; $secondUserName = isset($resultUsernameSetArr[1]->username) ? $resultUsernameSetArr[1]->username : '' ; $thirdUserName = isset($resultUsernameSetArr[2]->username) ? $resultUsernameSetArr[2]->username : '' ; $fourthUserName = isset($resultUsernameSetArr[3]->username) ? $resultUsernameSetArr[3]->username : '' ; $fifthUserName = isset($resultUsernameSetArr[4]->username) ? $resultUsernameSetArr[4]->username : '' ; if ($firstUserName != '') { $firstUserNameresultSet = Aretk_Crea_Admin::aretkcrea_get_user_listing_data_by_username($firstUserName); update_option('firstUserNameresultSet',""); update_option('firstUserNameresultSet',"$firstUserNameresultSet"); } if ($secondUserName != '') { $secondUserNameresultSet = Aretk_Crea_Admin::aretkcrea_get_user_listing_data_by_username($secondUserName); update_option('secondUserNameresultSet',""); update_option('secondUserNameresultSet',"$secondUserNameresultSet"); } if ($thirdUserName != '') { $thirdUserNameresultSet = Aretk_Crea_Admin::aretkcrea_get_user_listing_data_by_username($thirdUserName); update_option('thirdUserNameresultSet',""); update_option('thirdUserNameresultSet',"$thirdUserNameresultSet"); } if ($fourthUserName != '') { $fourthUserNameresultSet = Aretk_Crea_Admin::aretkcrea_get_user_listing_data_by_username($fourthUserName); update_option('fourthUserNameresultSet',""); update_option('fourthUserNameresultSet',"$fourthUserNameresultSet"); } if ($fifthUserName != '') { $fifthUserNameresultSet = Aretk_Crea_Admin::aretkcrea_get_user_listing_data_by_username($fifthUserName); update_option('fifthUserNameresultSet',""); update_option('fifthUserNameresultSet',"$fifthUserNameresultSet"); } } else { $args = array( 'posts_per_page' => -1, 'post_type' => 'aretk_listing', 'post_status' => 'publish' ); $posts_array = (array) get_posts( $args ); $exclusiveArr = array(); foreach ($posts_array as $singlePost) { $singlePost1 = (array) $singlePost; $singlePost2 = (object) $singlePost1; $exclusiveArr[] = $singlePost2; } $allListingFinalArr = array(); $allListingFinalArr = $exclusiveArr; $data = json_encode($allListingFinalArr); update_option('cron_run',""); update_option('cron_run',"$data"); } } public function aretkcrea_listing_filter_based_on_agent_or_mlsid() { global $wpdb; $mlsId = sanitize_text_field( $_POST['mlsId'] ); $agentName = $_POST['agentName']; $getSubscriptionStatus = get_option('crea_subscription_status', ''); //get all agent ids from database $crea_agent_table_name = $wpdb->prefix . ARETKCREA_AGENT_TABLE; $getAllAgentIds = $wpdb->get_results("SELECT `crea_agent_id` FROM $crea_agent_table_name"); $getAllAgentIdArray = array(); if ( isset($getAllAgentIds) && !empty($getAllAgentIds) ){ foreach ($getAllAgentIds as $agent_key => $agent ) { $getAllAgentIdArray[] = $agent->crea_agent_id; } } if ( isset($getAllAgentIdArray) && !empty($getAllAgentIdArray)) { $agent_ids = implode(',',$getAllAgentIdArray); } else { $agent_ids = null; } $tempArr = array(); $resultArr = array(); $getAllListingData = get_option('cron_run'); if (isset($getAllListingData) && !empty($getAllListingData) && isset( $getSubscriptionStatus ) && !empty( $getSubscriptionStatus ) && $getSubscriptionStatus === 'valid' ) { $allListingFinalArr = json_decode($getAllListingData); } else { if( isset( $getSubscriptionStatus ) && !empty( $getSubscriptionStatus ) && $getSubscriptionStatus === 'valid' ){ //get all feeds from crea settings $crea_user_name_table_name = $wpdb->prefix . ARETKCREA_USER_LISTING_DETAILS; $getAllUsername = $wpdb->get_results("SELECT username FROM $crea_user_name_table_name"); $allListingArr = array(); //get all agent ids from database $crea_agent_table_name = $wpdb->prefix . ARETKCREA_AGENT_TABLE; $getAllAgentIds = $wpdb->get_results("SELECT crea_agent_id FROM $crea_agent_table_name"); $getAllAgentIdArray = array(); if ( isset($getAllAgentIds) && !empty($getAllAgentIds) ){ foreach ($getAllAgentIds as $agent_key => $agent ) { $getAllAgentIdArray[] = $agent->crea_agent_id; } } if ( isset($getAllAgentIdArray) && !empty($getAllAgentIdArray)) { $agent_ids = implode(',',$getAllAgentIdArray); } else { $agent_ids = null; } $allListingArr = array(); $userNameList = ''; if (isset($getAllUsername) && !empty($getAllUsername)) { foreach ($getAllUsername as $singleUsername) { $userName = $singleUsername->username; if ( !empty( $userName ) ){ $userNameList.=$userName.','; } unset($singleUsername); } unset($getAllUsername); $userNameList = rtrim($userNameList,','); $result_type = 'full'; if ( $agent_ids != null ){ $listings = Aretk_Crea_Admin::aretkcrea_get_listing_records_based_on_agents($userNameList, $result_type,$agent_ids); if ( isset($listings) && !empty($listings)) { foreach ($listings as $listing_key => $listing ){ if ( !isset( $listing->TotalRecords ) && empty( $listing->TotalRecords ) ) { $allListingArr[$listing->mlsID] = $listing; } } } } } $args = array( 'posts_per_page' => -1, 'post_type' => 'aretk_listing', 'post_status' => 'publish' ); $posts_array = (array) get_posts($args); $exclusiveArr = array(); foreach ($posts_array as $singlePost) { $singlePost1 = (array) $singlePost; $singlePost2 = (object) $singlePost1; $exclusiveArr[] = $singlePost2; } $allListingFinalArr = array_merge($allListingArr, $exclusiveArr); } else { //For Exlusive listing $args = array( 'posts_per_page' => -1, 'post_type' => 'aretk_listing', 'post_status' => 'publish' ); $posts_array = (array) get_posts($args); $exclusiveArr = array(); foreach ($posts_array as $singlePost) { $singlePost1 = (array) $singlePost; $singlePost2 = (object) $singlePost1; $exclusiveArr[] = $singlePost2; } $allListingFinalArr = $exclusiveArr; } } $tempMlsId = array(); if ($agentName != '' && $mlsId != '') { $temp = 0; foreach ($allListingFinalArr as $singleListing) { $listing_mlsID = isset($singleListing->mlsID) ? $singleListing->mlsID :''; if($listing_mlsID == $mlsId){ foreach ($singleListing->listing_agents as $agent) { if ($agent->ID == $agentName) { $tempArr[] = $singleListing; $tempMlsId[] = $singleListing->mlsID; break; } } } } } elseif ($agentName == '' && $mlsId != '') { $temp = 0; foreach ($allListingFinalArr as $singleListing) { if (isset($singleListing->post_author) && !empty($singleListing->post_author)) { continue; } else { if($singleListing->mlsID == $mlsId){ if ($temp == 0) { $tempArr[] = $singleListing; $temp = 1; } } } } } elseif ($agentName != '' && $mlsId == '') { $temp = 0; foreach ($allListingFinalArr as $singleListing) { if (isset($singleListing->post_author) && !empty($singleListing->post_author)) { $agentArrDecoded = get_post_meta($singleListing->ID,'listingAgentId',true); $agentArr = json_decode($agentArrDecoded); if (isset($agentArr) && !empty($agentArr)) { if (in_array($agentName,$agentArr)) { $tempArr[] = $singleListing; } else { continue; } } else { continue; } } else { foreach ($singleListing->listing_agents as $agent) { if ($agent->ID == $agentName) { $tempArr[] = $singleListing; break; } } } } } elseif ( $agentName == '' && $mlsId == '' ) { if( (string)$_POST['mlsId'] ) { $tempArr = array(); } else{ $tempArr = $allListingFinalArr; } } $resultArr = array_merge($resultArr,$tempArr); $html = ''; $html .= ''; foreach ($resultArr as $singleListing) { if (isset($singleListing->post_author) && !empty($singleListing->post_author)) { $ListingAddress = get_post_meta($singleListing->ID,'listingAddress',true); $ListingCity = get_post_meta($singleListing->ID,'listingcity',true); $ListingPrice = get_post_meta($singleListing->ID,'listingPrice',true); $date = date('d-m-Y',strtotime($singleListing->post_date)); $crea_listing_images_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_IMAGES_HISTORY; $querySelectFirstImage = "SELECT image_url FROM $crea_listing_images_detail_table_name WHERE image_position =1 AND unique_id = $singleListing->ID"; $resultSet = $wpdb->get_results($querySelectFirstImage); if (isset($resultSet) && !empty($resultSet)) { $path = $resultSet[0]->image_url; } else { $path = ARETK_CREA_PLUGIN_URL.'admin/images/dummy_image.png'; } $agentArrDecoded = get_post_meta($singleListing->ID,'listingAgentId',true); $listingpageval = get_post_meta($singleListing->ID,'crea_aretk_db_listing_page_count',true); $listingpagecount = 0; if( !empty( $listingpageval ) && $listingpageval !='' ) { $listingpagecount = $listingpageval; } else { $listingpagecount = 0; } $agentArr = json_decode($agentArrDecoded); if (isset($agentArr) && !empty($agentArr)) { $htmlAgent = ''; foreach ($agentArr as $singleAgent) { $crea_agent_table_name = $wpdb->prefix.ARETKCREA_AGENT_TABLE; $queryGetAgentName = "SELECT crea_agent_name FROM $crea_agent_table_name WHERE crea_agent_id='$singleAgent'"; $resultAgentArr = $wpdb->get_results($queryGetAgentName); if ( isset($resultAgentArr) && !empty($resultAgentArr) ){ $htmlAgent .= $resultAgentArr[0]->crea_agent_name . ', '; } } } $html .= ''; } else { $htmlAgent = ''; foreach ($singleListing->listing_agents as $singleAgent) { $htmlAgent .= $singleAgent->Name.', '; } if (is_object ($singleListing->listing_photos)) { if ($singleListing->listing_photos->URL == '' || $singleListing->listing_photos->URL == null) { $apiListingImageURL = ARETK_CREA_PLUGIN_URL.'admin/images/dummy_image.png'; } else { $apiListingImageURL = $singleListing->listing_photos->URL; } } else { $apiListingImageURL = ARETK_CREA_PLUGIN_URL.'admin/images/dummy_image.png'; } $mlsId = isset($singleListing->mlsID) ? $singleListing->mlsID : '-'; $dates = isset($singleListing->ListingContractDate) ? $singleListing->ListingContractDate : '-'; $listingpagecount = isset( $singleListing->ViewCount ) ? $singleListing->ViewCount : 0; $html .= ''; } } $html .= '
'.__(ARETKCREA_ADD_LISTING_TABLE_PHOTO,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_MLS,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_ADDRESS,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_CITY,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_PRICE,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_AGENT_NAME,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_VIEWS,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_DATE,ARETKCREA_PLUGIN_SLUG).'
Exclusive Listing
Edit | Trash
'.$ListingAddress.' '.$ListingCity.' $'.$ListingPrice.' '.rtrim($htmlAgent,', ').' '.$listingpagecount.' '.$date.'
'.$mlsId.' '.$singleListing->StreetAddress.' '.$singleListing->StreetNumber.' '.$singleListing->City.' $'.$singleListing->Price.' '.rtrim($htmlAgent,', ').' '.$listingpagecount.' '.$dates.'
'.__(ARETKCREA_ADD_LISTING_TABLE_PHOTO,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_MLS,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_ADDRESS,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_CITY,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_PRICE,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_AGENT_NAME,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_VIEWS,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_DATE,ARETKCREA_PLUGIN_SLUG).'
'; echo $html; die(); } /** * This function will use for submit the create listing form data * * @param null * @return null * @author Aretk Inc. * @since Phase 1 */ public function aretkcrea_handle_create_listing_form_action() { global $wpdb, $wp; if (isset($_POST['posttype'])&& $_POST['posttype'] == 'list') { $post_unique_title = rand (111111, 999999); if (isset($_POST) && $_POST['action'] == 'submit-form' && $_POST['action-which'] == 'add' && $_POST['posttype'] == 'list') { // General Tab $listingTitle = isset($post_unique_title) ? $post_unique_title : ''; $listingAgentIds = array(); $listingAgentIdArray = isset($_POST['listing_view_agent_id']) ? $_POST['listing_view_agent_id'] : array(); if( !empty($listingAgentIdArray) && $listingAgentIdArray !='' ){ foreach ( $listingAgentIdArray as $listingAgentIdArraykey ){ if( $listingAgentIdArraykey != '' ){ $listingAgentIds[] = $listingAgentIdArraykey; } } } $listingAgentId = json_encode($listingAgentIds); $listingAddress = isset($_POST['agent_listing_tab_address']) ? sanitize_text_field( ltrim( rtrim( $_POST['agent_listing_tab_address'] ," ") ," ") ) : ''; $listingcity = isset($_POST['agent_listing_tab_city']) ? sanitize_text_field( ltrim( rtrim( $_POST['agent_listing_tab_city'] ," ") ," ") ) : ''; $listingProvince = isset($_POST['agent_listing_tab_Province']) ? sanitize_text_field( ltrim( rtrim( $_POST['agent_listing_tab_Province'] ," ") ," ") ) : ''; $listingAgentStatus = isset($_POST['listing_view_agent_status']) ? $_POST['listing_view_agent_status'] : ''; $listingPrice = isset($_POST['agent_listing_tab_price']) ? sanitize_text_field( ltrim( rtrim( $_POST['agent_listing_tab_price'] ," ") ," ") ) : ''; $listingPropertyType = isset($_POST['listing-view-agent-property-type']) ? $_POST['listing-view-agent-property-type'] : ''; $listingStructureType = isset($_POST['listing-view-agent-structure-type']) ? $_POST['listing-view-agent-structure-type'] : ''; $listingBedRooms = isset($_POST['listing-view-agent-bedrooms']) ? $_POST['listing-view-agent-bedrooms'] : ''; $listingBathrooms = isset($_POST['listing-view-agent-bathrooms-full']) ? $_POST['listing-view-agent-bathrooms-full'] : ''; $listingBathroomsPartial = isset($_POST['listing-view-agent-bathrooms-partial']) ? $_POST['listing-view-agent-bathrooms-partial'] : ''; $listingFinishedBasement = isset($_POST['listing-view-agent-finished-basement']) ? $_POST['listing-view-agent-finished-basement'] : ''; $listingDescription = isset($_POST['listing-view-agent-descriptions']) ? sanitize_text_field( $_POST['listing-view-agent-descriptions'] ) : ''; $crea_google_map_latitude = isset($_POST['crea_google_map_latitude']) ? $_POST['crea_google_map_latitude'] : ''; $crea_google_map_longitude = isset($_POST['crea_google_map_longitude']) ? $_POST['crea_google_map_longitude'] : ''; $crea_google_map_geo_address = isset($_POST['crea_google_map_geo_address']) ? sanitize_text_field( $_POST['crea_google_map_geo_address'] ) : ''; // PARKING/GARAGE Tab $listingParkingSlot = isset($_POST['listing-view-pa-ga-parking-slot']) ? $_POST['listing-view-pa-ga-parking-slot'] : ''; $listingParkinggarage = isset($_POST['listing-view-pa-ga-garage']) ? $_POST['listing-view-pa-ga-garage'] : ''; // VIRTUAL TOUR Tab $listingTourUrl = isset($_POST['listing_virtual_tor_add_url']) ? sanitize_text_field( ltrim( rtrim( $_POST['listing_virtual_tor_add_url'] ," ") ," ") ): ''; // UTILITIES Tab $listingAgentUtilityarray = array(); $listingUtilityArray = isset($_POST['crea-utilities-input']) ? $_POST['crea-utilities-input'] : array(); if( !empty($listingUtilityArray) && $listingUtilityArray !='' ){ foreach ( $listingUtilityArray as $listingUtilityArray_results ){ if( $listingUtilityArray_results != '' ){ $listingAgentUtilityarray[] = sanitize_text_field( ltrim( rtrim( $listingUtilityArray_results," ") ," ") ); } } $listingUtilityArr = isset($listingAgentUtilityarray) ? json_encode($listingAgentUtilityarray) : json_encode(array()); } // FEATURES Tab $listingagentsFeatureArray = array(); $listingFeatureArray = isset($_POST['crea-features-input']) ? $_POST['crea-features-input'] : array(); if( !empty($listingFeatureArray) && $listingFeatureArray !='' ){ foreach ( $listingFeatureArray as $listingFeatureArray_results ){ if( $listingFeatureArray_results != '' ){ $listingagentsFeatureArray[] = sanitize_text_field( ltrim( rtrim( $listingFeatureArray_results," ") ," ") ); } } $listingFeatureArr = isset($listingagentsFeatureArray) ? json_encode($listingagentsFeatureArray) : json_encode(array()); } // PHOTOS Tab $listingPhotosArr = isset($_FILES['file']) ? $_FILES['file'] : ''; // EXTERNAL DOCUMENTS Tab $listingDpcumentArr = isset($_FILES['extdocfileinput']) ? $_FILES['extdocfileinput'] : ''; $listingDpcumentArr1 = isset($_POST['crea_listing_multiplefile_document_array']) ? $_POST['crea_listing_multiplefile_document_array'] : array(); // OPEN HOUSE Date $listingopenhosedateArr = isset($_POST['crea_home_date_picker']) ? $_POST['crea_home_date_picker'] : array(); // OPEN HOUSE START Time $listingstarttimeArr = isset($_POST['crea-open-house-start-time']) ? $_POST['crea-open-house-start-time'] : array(); // OPEN HOUSE END Time $listingendtimeArr = isset($_POST['crea-open-house-end-time']) ? $_POST['crea-open-house-end-time'] : array(); $merge_listing_open_house = array(); $op_counter = 0; foreach ( $listingopenhosedateArr as $listingopenhosedatevalue ) { $listing_open_house_start_time = $listingstarttimeArr[$op_counter]; $listing_open_house_end_time = $listingendtimeArr[$op_counter]; $merge_listing_open_house[] = array('date'=>$listingopenhosedatevalue,'start_time'=>$listing_open_house_start_time,'end_time'=>$listing_open_house_end_time); $op_counter++; } if( $listingAgentId != '' && !empty($listingAgentId) && !empty($listingAddress) && $listingAddress !='' && !empty($listingcity) && $listingcity !='' && !empty($listingProvince) && $listingProvince !='' && !empty($listingAgentStatus) && $listingAgentStatus !='' && !empty($listingPrice) && $listingPrice !='' && !empty($listingPhotosArr) && $listingPhotosArr !='' ) { $guid = microtime( true ); $guidd = preg_replace( "/\./", "", $guid); $new_post = array( 'post_title' => $listingTitle, 'post_content' => $listingDescription, 'post_status' => 'publish', 'post_type' => 'aretk_listing' ); $listingId = wp_insert_post($new_post); update_post_meta($listingId,'uniqueId',"$guidd"); update_post_meta($listingId,'listingAgentId'," $listingAgentId"); update_post_meta($listingId,'listingAddress',"$listingAddress"); update_post_meta($listingId,'listingcity',"$listingcity"); update_post_meta($listingId,'listingProvince',"$listingProvince"); update_post_meta($listingId,'listingPrice',"$listingPrice"); update_post_meta($listingId,'listingAgentStatus',"$listingAgentStatus"); update_post_meta($listingId,'listingPropertyType',"$listingPropertyType"); update_post_meta($listingId,'listingStructureType',"$listingStructureType"); update_post_meta($listingId,'listingBedRooms',"$listingBedRooms"); update_post_meta($listingId,'listingBathrooms',"$listingBathrooms"); update_post_meta($listingId,'listingBathroomsPartial',"$listingBathroomsPartial"); update_post_meta($listingId,'listingFinishedBasement',"$listingFinishedBasement"); update_post_meta($listingId,'listingParkingSlot',"$listingParkingSlot"); update_post_meta($listingId,'listingParkinggarage',"$listingParkinggarage"); update_post_meta($listingId,'listingTourUrl',"$listingTourUrl"); update_post_meta($listingId,'listingUtilityArr',"$listingUtilityArr"); update_post_meta($listingId,'listingFeatureArr',"$listingFeatureArr"); update_post_meta($listingId,'listingopenhosedatetimeArr',json_encode($merge_listing_open_house)); update_post_meta($listingId,'listing_type',"exclusive"); update_post_meta($listingId,'crea_google_map_latitude',$crea_google_map_latitude); update_post_meta($listingId,'crea_google_map_longitude',$crea_google_map_longitude); update_post_meta($listingId,'crea_google_map_geo_address',$crea_google_map_geo_address); $getSubscriptionStatus = get_option('crea_subscription_status', ''); if( isset( $getSubscriptionStatus ) && !empty( $getSubscriptionStatus ) && $getSubscriptionStatus === 'valid' ){ update_post_meta($listingId,'crea_listing_subscription_states',$getSubscriptionStatus); }else { update_post_meta($listingId,'crea_listing_subscription_states',$getSubscriptionStatus); } $uploadDirr =""; if( $_SERVER['SERVER_NAME'] =="localhost" ) { $explodeDir = explode('/',site_url()); $explodeDir = end($explodeDir); $uploadDirr = $_SERVER['DOCUMENT_ROOT'].$explodeDir.'/uploads/'; } else { $uploadDirr = $_SERVER['DOCUMENT_ROOT'].'/uploads/'; } if (!file_exists($uploadDirr)) { mkdir($uploadDirr,0777,true); } if (!file_exists($uploadDirr.'listing/')) { mkdir($uploadDirr.'listing/',0777,true); } $uploadDirr1 = $uploadDirr.'listing/'; $author_id = get_current_user_id(); $filename = $uploadDirr1.$author_id.'/'; if (!file_exists($filename)) { mkdir($filename,0777,true); } $filename1 = $filename.'images/'; if (!file_exists($filename1)) { mkdir($filename1,0777,true); } if (!file_exists($filename1.$guidd.'/')) { mkdir($filename1.$guidd.'/',0777,true); } $target_path = $filename1.$guidd.'/'; $j = 0; // Variable for indexing uploaded image. $photo_upload_db_url = array(); if (isset($listingPhotosArr) && !empty($listingPhotosArr) && $listingPhotosArr != '') { for ($i = 0; $i < count($_FILES['file']['name']); $i++) { $target_path = $filename1.$guidd.'/'; $validextensions = array("jpeg", "jpg", "png"); // Extensions which are allowed. $ext = explode('.', basename($_FILES['file']['name'][$i])); // Explode file name from dot(.) $file_extension = end($ext); // Store extensions in the variable. if (in_array($file_extension, $validextensions)) { if ($ext[count($ext) - 1] != '') { $imageName = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $imageName; // Set the target path with a new name of image. $j = $j + 1; // Increment the number of uploaded images according to the files in array. move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path); $imageUrl = site_url().'/uploads/listing/'.$author_id.'/images/'.$guidd.'/'.$imageName; $photo_upload_db_url [] = $imageUrl; $crea_listing_images_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_IMAGES_HISTORY; $wpdb->insert( "$crea_listing_images_detail_table_name", array( 'user_id' => $author_id, 'unique_id' => $listingId, 'image_position' => $j, 'image_url' => "$imageUrl", 'created_time' => current_time('mysql', 1), 'updated_time' => current_time('mysql', 1), ), array( '%d', '%d', '%d', '%s', '%s', '%s', ) ); unset($imageUrl); unset($imageName); unset($target_path); } } } } $filename2 = $filename.'documents/'; if (!file_exists($filename2)) { mkdir($filename2,0777,true); } if (!file_exists($filename2.$guidd.'/')) { mkdir($filename2.$guidd.'/',0777,true); } $target_path_document = $filename2.$guidd.'/'; $d = 0; // Variable for indexing uploaded image. $document_upload_db_url = array(); if (isset($listingDpcumentArr) && !empty($listingDpcumentArr) && $listingDpcumentArr != '') { for ($k = 0; $k < count($_FILES['extdocfileinput']['name']); $k++) { if( in_array($_FILES['extdocfileinput']['name'][$k],$listingDpcumentArr1) ) { $file_ext = explode('.',$_FILES['extdocfileinput']['name'][$k]); $file_ext = end($file_ext); $file_ext = strtolower($file_ext); $expensions= array("png","jpg","jpeg","doc","docx","csv","pdf","txt"); if( in_array($file_ext,$expensions)) { if($_FILES['extdocfileinput']['size'][$k] <= '5000000' ) { $target_path_document = $filename2.$guidd.'/'; $ext = explode('.', basename($_FILES['extdocfileinput']['name'][$k])); $file_extension = end($ext); // Store extensions in the variable. if ($ext[count($ext) - 1] != '') { $documentName = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path_document = $target_path_document . $documentName; // Set the target path with a new name of image. $d = $d + 1; // Increment number of uploaded images according to files in array. move_uploaded_file($_FILES['extdocfileinput']['tmp_name'][$k], $target_path_document); $documentUrl = site_url().'/uploads/listing/'.$author_id.'/documents/'.$guidd.'/'.$documentName; $document_upload_db_url [] = $documentUrl; $crea_listing_document_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_DOCUMENT_HISTORY; $originalName= basename($_FILES['extdocfileinput']['name'][$k]); $wpdb->insert( "$crea_listing_document_detail_table_name", array( 'user_id' => $author_id, 'unique_id' => $listingId, 'document_url' => "$documentUrl", 'document_name' => "$originalName", 'created_time' => current_time('mysql', 1), 'updated_time' => current_time('mysql', 1), ), array( '%d', '%d', '%s', '%s', '%s', '%s', ) ); unset($originalName); unset($documentUrl); unset($documentName); unset($target_path_document); } } } } } } Aretk_Crea_Admin::aretkcrea_listing_update_to_aretk_server($listingId,'add'); } } if (isset($_POST) && $_POST['action'] == 'submit-form' && $_POST['action-which'] == 'edit' && $_POST['posttype'] == 'list') { $updatelistingId = isset($_POST['aretk-listing-id']) ? $_POST['aretk-listing-id'] :''; $updatelistingAgentIds = array(); $updatelistingAgentIdArray = isset($_POST['listing_view_agent_id']) ? $_POST['listing_view_agent_id'] : array(); if( !empty($updatelistingAgentIdArray) && $updatelistingAgentIdArray !='' ){ foreach ( $updatelistingAgentIdArray as $updatelistingAgentIdArraykey ){ if( $updatelistingAgentIdArraykey != '' ){ $updatelistingAgentIds[] = $updatelistingAgentIdArraykey; } } } $updatelistingAgentId = json_encode($updatelistingAgentIds); $updatelistingAddress = isset($_POST['agent_listing_tab_address']) ? ltrim( rtrim( $_POST['agent_listing_tab_address'] ," ") ," ") : ''; $updatelistingcity = isset($_POST['agent_listing_tab_city']) ? ltrim( rtrim( $_POST['agent_listing_tab_city'] ," ") ," ") : ''; $updatelistingProvince = isset($_POST['agent_listing_tab_Province']) ? ltrim( rtrim( $_POST['agent_listing_tab_Province'] ," ") ," ") : ''; $updatelistingAgentStatus = isset($_POST['listing_view_agent_status']) ? $_POST['listing_view_agent_status'] : ''; $updatelistingPrice = isset($_POST['agent_listing_tab_price']) ? ltrim( rtrim( $_POST['agent_listing_tab_price'] ," ") ," ") : ''; $updatelistingPropertyType = isset($_POST['listing-view-agent-property-type']) ? $_POST['listing-view-agent-property-type'] : ''; $updatelistingStructureType = isset($_POST['listing-view-agent-structure-type']) ? $_POST['listing-view-agent-structure-type'] : ''; $updatelistingBedRooms = isset($_POST['listing-view-agent-bedrooms']) ? $_POST['listing-view-agent-bedrooms'] : ''; $updatelistingBathrooms = isset($_POST['listing-view-agent-bathrooms-full']) ? $_POST['listing-view-agent-bathrooms-full'] : ''; $updatelistingBathroomsPartial = isset($_POST['listing-view-agent-bathrooms-partial']) ? $_POST['listing-view-agent-bathrooms-partial'] : ''; $updatelistingFinishedBasement = isset($_POST['listing-view-agent-finished-basement']) ? $_POST['listing-view-agent-finished-basement'] : ''; $updatelistingDescription = isset($_POST['listing-view-agent-descriptions']) ? $_POST['listing-view-agent-descriptions'] : ''; $crea_google_map_latitude = isset($_POST['crea_google_map_latitude']) ? $_POST['crea_google_map_latitude'] : ''; $crea_google_map_longitude = isset($_POST['crea_google_map_longitude']) ? $_POST['crea_google_map_longitude'] : ''; $crea_google_map_geo_address = isset($_POST['crea_google_map_geo_address']) ? $_POST['crea_google_map_geo_address'] : ''; // PARKING/GARAGE Tab $updatelistingParkingSlot = isset($_POST['listing-view-pa-ga-parking-slot']) ? $_POST['listing-view-pa-ga-parking-slot'] : ''; $updatelistingParkinggarage = isset($_POST['listing-view-pa-ga-garage']) ? $_POST['listing-view-pa-ga-garage'] : ''; // VIRTUAL TOUR Tab $updatelistingTourUrl = isset($_POST['listing_virtual_tor_add_url']) ? $_POST['listing_virtual_tor_add_url'] : ''; $updatelistingUtilityArr = array(); $listingUtilityArray = isset($_POST['crea-utilities-input']) ? $_POST['crea-utilities-input'] : array(); if( !empty($listingUtilityArray) && $listingUtilityArray !='' ){ foreach ( $listingUtilityArray as $listingUtilityArray_results ){ if( $listingUtilityArray_results != '' ){ $listingAgentUtilityarray[] = ltrim( rtrim( $listingUtilityArray_results ," ") ," "); } } $updatelistingUtilityArr = isset($listingAgentUtilityarray) ? json_encode($listingAgentUtilityarray) : json_encode(array()); } // FEATURES Tab $updatelistingFeatureArr = array(); $listingFeatureArray = isset($_POST['crea-features-input']) ? $_POST['crea-features-input'] : array(); if( !empty($listingFeatureArray) && $listingFeatureArray !='' ){ foreach ( $listingFeatureArray as $listingFeatureArray_results ){ if( $listingFeatureArray_results != '' ){ $listingagentsFeatureArray[] = ltrim( rtrim( $listingFeatureArray_results ," ") ," "); } } $updatelistingFeatureArr = isset($listingagentsFeatureArray) ? json_encode($listingagentsFeatureArray) : json_encode(array()); } // PHOTOS Tab $updatelistingPhotosArr = isset($_FILES['file']) ? $_FILES['file'] : ''; // EXTERNAL DOCUMENTS Tab $updatelistingDpcumentArr = isset($_FILES['extdocfileinput']) ? $_FILES['extdocfileinput'] : ''; $updatelistingDpcumentArr1 = isset($_POST['crea_listing_multiplefile_document_array']) ? $_POST['crea_listing_multiplefile_document_array'] : array(); // OPEN HOUSE Date $updatelistingopenhosedateArr = isset($_POST['crea_home_date_picker']) ? $_POST['crea_home_date_picker'] : array(); $finalUpdateDocumentArray = array(); // OPEN HOUSE START Time $updatelistingstarttimeArr = isset($_POST['crea-open-house-start-time']) ? $_POST['crea-open-house-start-time'] : array(); // OPEN HOUSE END Time $updatelistingendtimeArr = isset($_POST['crea-open-house-end-time']) ? $_POST['crea-open-house-end-time'] : array(); $updatemerge_listing_open_house = array(); $updateop_counter = 0; foreach ( $updatelistingopenhosedateArr as $updatelistingopenhosedatevalue ) { $updatelisting_open_house_start_time = $updatelistingstarttimeArr[$updateop_counter]; $updatelisting_open_house_end_time = $updatelistingendtimeArr[$updateop_counter]; $updatemerge_listing_open_house[] = array('date'=>$updatelistingopenhosedatevalue,'start_time'=>$updatelisting_open_house_start_time,'end_time'=>$updatelisting_open_house_end_time); $updateop_counter++; } $update_listing_post_content = array('ID' => $updatelistingId,'post_content' => $updatelistingDescription); wp_update_post( $update_listing_post_content ); update_post_meta($updatelistingId,'listingAgentId',"$updatelistingAgentId"); update_post_meta($updatelistingId,'listingAddress',"$updatelistingAddress"); update_post_meta($updatelistingId,'listingcity',"$updatelistingcity"); update_post_meta($updatelistingId,'listingProvince',"$updatelistingProvince"); update_post_meta($updatelistingId,'listingPrice',"$updatelistingPrice"); update_post_meta($updatelistingId,'listingAgentStatus',"$updatelistingAgentStatus"); update_post_meta($updatelistingId,'listingPropertyType',"$updatelistingPropertyType"); update_post_meta($updatelistingId,'listingStructureType',"$updatelistingStructureType"); update_post_meta($updatelistingId,'listingBedRooms',"$updatelistingBedRooms"); update_post_meta($updatelistingId,'listingBathrooms',"$updatelistingBathrooms"); update_post_meta($updatelistingId,'listingBathroomsPartial',"$updatelistingBathroomsPartial"); update_post_meta($updatelistingId,'listingFinishedBasement',"$updatelistingFinishedBasement"); update_post_meta($updatelistingId,'listingParkingSlot',"$updatelistingParkingSlot"); update_post_meta($updatelistingId,'listingParkinggarage',"$updatelistingParkinggarage"); update_post_meta($updatelistingId,'listingTourUrl',"$updatelistingTourUrl"); update_post_meta($updatelistingId,'listingUtilityArr',"$updatelistingUtilityArr"); update_post_meta($updatelistingId,'listingFeatureArr',"$updatelistingFeatureArr"); update_post_meta($updatelistingId,'listingopenhosedatetimeArr',json_encode($updatemerge_listing_open_house)); update_post_meta($updatelistingId,'listing_type',"exclusive"); update_post_meta($updatelistingId,'crea_google_map_latitude',$crea_google_map_latitude); update_post_meta($updatelistingId,'crea_google_map_longitude',$crea_google_map_longitude); update_post_meta($updatelistingId,'crea_google_map_geo_address',$crea_google_map_geo_address); $guidd = get_post_meta($updatelistingId,'uniqueId',true); $uploadDirr =""; if( $_SERVER['SERVER_NAME'] =="localhost" ) { $explodeDir = explode('/',site_url()); $explodeDir = end($explodeDir); $uploadDirr = $_SERVER['DOCUMENT_ROOT'].$explodeDir.'/uploads/'; } else { $uploadDirr = $_SERVER['DOCUMENT_ROOT'].'/uploads/'; } if (!file_exists($uploadDirr)) { mkdir($uploadDirr,0777,true); } if (!file_exists($uploadDirr.'listing/')) { mkdir($uploadDirr.'listing/',0777,true); } $uploadDirr1 = $uploadDirr.'listing/'; $author_id = get_current_user_id(); $filename = $uploadDirr1.$author_id.'/'; if (!file_exists($filename)) { mkdir($filename,0777,true); } $filename1 = $filename.'images/'; if (!file_exists($filename1)) { mkdir($filename1,0777,true); } if (!file_exists($filename1.$guidd.'/')) { mkdir($filename1.$guidd.'/',0777,true); } $target_path = $filename1.$guidd.'/'; $crea_listing_images_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_IMAGES_HISTORY; $getLastPostionOfImageQuery = "SELECT `image_position` FROM `$crea_listing_images_detail_table_name` WHERE `unique_id` = $updatelistingId ORDER BY `image_position` DESC LIMIT 1"; $getPostionResult = $wpdb->get_results($getLastPostionOfImageQuery); if (isset($getPostionResult) && !empty($getPostionResult)) { $j = (int) $getPostionResult[0]->image_position; // Variable for indexing uploaded image. } else { $j = 0; // Variable for indexing uploaded image. } $photo_upload_db_url = array(); if (isset($updatelistingPhotosArr) && !empty($updatelistingPhotosArr) && $updatelistingPhotosArr != '') { for ($i = 0; $i < count($_FILES['file']['name']); $i++) { $target_path = $filename1.$guidd.'/'; $validextensions = array("jpeg", "jpg", "png"); // Extensions which are allowed. $ext = explode('.', basename($_FILES['file']['name'][$i])); // Explode file name from dot(.) $file_extension = end($ext); // Store extensions in the variable. if (in_array($file_extension, $validextensions)) { if ($ext[count($ext) - 1] != '') { $imageName = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $imageName; // Set the target path with a new name of image. $j = $j + 1; // Increment the number of uploaded images according to the files in array. move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path); $imageUrl = site_url().'/uploads/listing/'.$author_id.'/images/'.$guidd.'/'.$imageName; $photo_upload_db_url[] = $imageUrl; $crea_listing_images_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_IMAGES_HISTORY; $wpdb->insert( "$crea_listing_images_detail_table_name", array( 'user_id' => $author_id, 'unique_id' => $updatelistingId, 'image_position' => $j, 'image_url' => "$imageUrl", 'created_time' => current_time('mysql', 1), 'updated_time' => current_time('mysql', 1), ), array( '%d', '%d', '%d', '%s', '%s', '%s', ) ); unset($imageUrl); unset($imageName); unset($target_path); } } } } $filename2 = $filename.'documents/'; if (!file_exists($filename2)) { mkdir($filename2,0777,true); } if (!file_exists($filename2.$guidd.'/')) { mkdir($filename2.$guidd.'/',0777,true); } $target_path_document = $filename2.$guidd.'/'; $d = 0; // Variable for indexing uploaded image. $document_upload_db_url = array(); if (isset($updatelistingDpcumentArr) && !empty($updatelistingDpcumentArr) && $updatelistingDpcumentArr != '') { for ($k = 0; $k < count($_FILES['extdocfileinput']['name']); $k++) { $file_ext = explode('.',$_FILES['extdocfileinput']['name'][$k]); $file_ext = end($file_ext); $file_ext = strtolower($file_ext); $expensions= array("png","jpg","jpeg","doc","docx","csv","pdf","txt"); if( in_array($file_ext,$expensions)) { if($_FILES['extdocfileinput']['size'][$k] <= '5000000' ) { $target_path_document = $filename2.$guidd.'/'; $ext = explode('.', basename($_FILES['extdocfileinput']['name'][$k])); // Explode file name from dot(.) $file_extension = end($ext); // Store extensions in the variable. if ($ext[count($ext) - 1] != '') { $documentName = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path_document = $target_path_document . $documentName; // Set the target path with a new name of image. $d = $d + 1; // Increment the number of uploaded images according to the files in array. move_uploaded_file($_FILES['extdocfileinput']['tmp_name'][$k], $target_path_document); $documentUrl = site_url().'/uploads/listing/'.$author_id.'/documents/'.$guidd.'/'.$documentName; $document_upload_db_url[] = $documentUrl; $crea_listing_document_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_DOCUMENT_HISTORY; $originalName= basename($_FILES['extdocfileinput']['name'][$k]); $wpdb->insert( "$crea_listing_document_detail_table_name", array( 'user_id' => $author_id, 'unique_id' => $updatelistingId, 'document_url' => "$documentUrl", 'document_name' => "$originalName", 'created_time' => current_time('mysql', 1), 'updated_time' => current_time('mysql', 1), ), array( '%d', '%d', '%s', '%s', '%s', '%s', ) ); unset($originalName); unset($documentUrl); unset($documentName); unset($target_path_document); } } } } } Aretk_Crea_Admin::aretkcrea_listing_update_to_aretk_server($updatelistingId,'edit'); } $crea_user_name_table_name = $wpdb->prefix.ARETKCREA_USER_LISTING_DETAILS; $getAllUsername = $wpdb->get_results("SELECT username FROM $crea_user_name_table_name"); $allListingArr = array(); //get all agent ids from database $crea_agent_table_name = $wpdb->prefix . ARETKCREA_AGENT_TABLE; $getAllAgentIds = $wpdb->get_results("SELECT crea_agent_id FROM $crea_agent_table_name",ARRAY_A); if ( isset($getAllAgentIds) && !empty($getAllAgentIds)) { $agent_id_array = array(); foreach ( $getAllAgentIds as $getAllAgentId ){ $agent_id_array[] = $getAllAgentId['crea_agent_id']; } $agent_id = implode(',',$agent_id_array); } else { $agent_id = null; } if (isset($getAllUsername) && !empty($getAllUsername)) { foreach ($getAllUsername as $singleUsername ) { $userName = $singleUsername->username; $result_type = 'full'; $listing = Aretk_Crea_Admin::aretkcrea_get_user_listing_records_by_username_by_view_type($userName,$result_type,$agent_id); $listingRecords = isset( $listing[0]->TotalRecords ) ? $listing[0]->TotalRecords : 0; if( $listingRecords > 0 ) { array_shift($listing); $allListingArr = array_merge($allListingArr,$listing); } unset($singleUsername); } unset($getAllUsername); } $args = array( 'posts_per_page' => -1, 'post_type' => 'aretk_listing', 'post_status' => 'publish' ); $posts_array = (array) get_posts( $args ); $exclusiveArr = array(); foreach ($posts_array as $singlePost) { $singlePost1 = (array) $singlePost; $singlePost2 = (object) $singlePost1; $exclusiveArr[] = $singlePost2; } $allListingFinalArr = array(); $allListingFinalArr = array_merge($allListingArr,$exclusiveArr); $data = json_encode($allListingFinalArr); update_option('cron_run',""); update_option('cron_run',"$data"); wp_safe_redirect(site_url('/wp-admin/admin.php?page=listings_settings')); } } /** * function for aretk_crea_disclaimer_update * * ajax callback function aretk_crea_disclaimer_update * set disclaimer specifics * @return NULL * @package Phase 1 * @since Phase 1 * @version 1.0.0 * @author ARETK Inc. * @param null */ function aretk_crea_disclaimer_update() { $pluralize = isset( $_POST['disclaimer_pluralize'] ) ? base64_decode($_POST['disclaimer_pluralize']): 'I am'; $salestype = isset( $_POST['disclaimer_salestype'] ) ? base64_decode($_POST['disclaimer_salestype']) : 'an agent'; $licensetype = isset( $_POST['disclaimer_licensetype'] ) ? base64_decode($_POST['disclaimer_licensetype']): 'residential and commercial'; $province = isset( $_POST['disclaimer_province'] ) ? base64_decode($_POST['disclaimer_province']) : ''; $disclaimer = $pluralize .' '. $salestype .' licensed to trade '. $licensetype .' real estate'; if ( !empty($province) ){ $disclaimer .= ' in '. $province; } $disclaimer .= '. The out of province listing content on this website is not intended to solicit a trade in real estate. Any consumers interested in out of province listings must contact a person who is licensed to trade in real estate in that province.'; $disclaimer_array = array( 'disclaimer' => $disclaimer, 'pluralize' => $pluralize, 'salestype' => $salestype, 'licensetype' => $licensetype, 'province' => $province ); update_option('aretk_crea_disclaimer1',$disclaimer_array); echo ARETKCREA_PLUGIN_SETTINGS_PAGE_BTN_SUCESS; exit; } /** * function for aretk_crea_add_new_agents * * ajax callback function aretk_crea_add_new_agents * add new agent id or email * @return return crea agent details * @package Phase 1 * @since Phase 1 * @version 1.0.0 * @author Aretk Inc. * @param null */ function aretk_crea_add_new_agents () { global $wpdb; $crea_agent_table_name = $wpdb->prefix.ARETKCREA_AGENT_TABLE; $agent_id_array = array(); $valid_agent_id = isset( $_POST['encoded_agent_id'] ) ? base64_decode($_POST['encoded_agent_id']): ''; $valid_agent_email = isset( $_POST['encoded_agent_email'] ) ? base64_decode($_POST['encoded_agent_email']) : ''; $valid_agent_name = isset( $_POST['encoded_agent_name'] ) ? base64_decode($_POST['encoded_agent_name']) : ''; $get_agent_ids = $wpdb->get_results("SELECT `crea_agent_id` FROM $crea_agent_table_name"); if( !empty( $get_agent_ids ) && $get_agent_ids !='' ) { foreach ( $get_agent_ids as $get_agent_key=>$get_agent_val ) { $agent_id_array[] = $get_agent_val->crea_agent_id; } } if( !in_array($valid_agent_id,$agent_id_array ) ) { if( !empty( $valid_agent_id ) && $valid_agent_id !='' && !empty( $valid_agent_email ) && $valid_agent_email !='' ) { $wpdb->insert($crea_agent_table_name, array('crea_agent_name'=>$valid_agent_name,'crea_agent_id' => $valid_agent_id, 'crea_agent_email' => $valid_agent_email,'crea_agent_created_date'=>current_time('mysql', 1),'crea_agent_modified_date'=>current_time('mysql', 1))); $get_agents_results= $wpdb->get_results("SELECT `crea_id`,`crea_agent_name`,`crea_agent_id`,`crea_agent_email`,`crea_agent_modified_date` FROM $crea_agent_table_name ORDER BY `crea_id` ASC"); if( !empty( $get_agents_results ) && $get_agents_results !='' ) { $counter = 0; foreach ( $get_agents_results as $get_agents_key=>$get_agents_value ) { $counter = $counter + 1; echo''; echo''.$counter.''; echo'

'.$get_agents_value->crea_agent_name.'

'; echo'

'.$get_agents_value->crea_agent_id.'

'; echo'

'.$get_agents_value->crea_agent_email.'

'; echo'

'.$get_agents_value->crea_agent_modified_date.'

'; echo'editdelete'; echo''; } } } } else { echo"already_exsits"; } die(); } /** * create function for aretkcrea_delete_selected_agent_records * * ajax callback function aretkcrea_delete_selected_agent_records * Delete selected agent records * * @return return crea delete agent details * @package Phase 1 * @since Phase 1 * @version 1.0.0 * @author Aretk Inc. * @param null */ function aretkcrea_delete_selected_agent_records() { global $wpdb; $crea_agent_table_name = $wpdb->prefix.ARETKCREA_AGENT_TABLE; $crea_agent_id = isset( $_POST['crea_agent_id'] ) ? base64_decode($_POST['crea_agent_id']) :''; if( !empty( $crea_agent_id ) && $crea_agent_id !='' ) { $delete_recod = $wpdb->query( "DELETE FROM $crea_agent_table_name WHERE `crea_id` = $crea_agent_id" ); if( $delete_recod == 1 ) { $get_agents_results = $wpdb->get_results("SELECT `crea_id`,`crea_agent_name`,`crea_agent_id`,`crea_agent_email`,`crea_agent_modified_date` FROM $crea_agent_table_name ORDER BY `crea_id` ASC" ); if( !empty( $get_agents_results ) && $get_agents_results !='' ) { $counter = 0; foreach ( $get_agents_results as $get_agents_key=>$get_agents_value ) { $counter = $counter + 1; echo''; echo''.$counter.''; echo'

'.$get_agents_value->crea_agent_name.'

'; echo'

'.$get_agents_value->crea_agent_id.'

'; echo'

'.$get_agents_value->crea_agent_email.'

'; echo'

'.$get_agents_value->crea_agent_modified_date.'

'; echo'editdelete'; echo''; } } } } die(); } /** * create function for aretkcrea_get_google_map_address_lat_long * * ajax callback function aretkcrea_get_google_map_address_lat_long * get address lat long * * @return return crea address lat long * @package Phase 1 * @since Phase 1 * @version 1.0.0 * @author Aretk Inc. * @param null */ function aretkcrea_get_google_map_address_lat_long () { $google_map_address = base64_decode($_POST['google_map_address']); $geo_location_address = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address='.urlencode($google_map_address).'&sensor=false'); $geo_location_address = json_decode($geo_location_address, true); if( $google_map_address != '' ) { if ($geo['status'] = 'OK') { $latitude = isset( $geo_location_address['results'][0]['geometry']['location']['lat']) ? $geo_location_address['results'][0]['geometry']['location']['lat'] :''; $longitude = isset($geo_location_address['results'][0]['geometry']['location']['lng']) ? $geo_location_address['results'][0]['geometry']['location']['lng'] :''; $address = isset($geo_location_address['results'][0]['formatted_address']) ? $geo_location_address['results'][0]['formatted_address'] :''; $sucessfully_callback = base64_encode('sucessfully'.'|'.$latitude.'|'.$longitude.'|'.$address); echo $sucessfully_callback; } } die(); } function aretkcrea_update_crea_listing_images_order_with_upload() { global $wpdb; $listingId = (int) $_POST['listingId']; $guidd = get_post_meta($listingId,'uniqueId',true); $uploadDirr =""; if( $_SERVER['SERVER_NAME'] =="localhost" ) { $explodeDir = explode('/',site_url()); $explodeDir = end($explodeDir); $uploadDirr = $_SERVER['DOCUMENT_ROOT'].$explodeDir.'/uploads/'; } else { $uploadDirr = $_SERVER['DOCUMENT_ROOT'].'/uploads/'; } if (!file_exists($uploadDirr)) { mkdir($uploadDirr,0777,true); } if (!file_exists($uploadDirr.'listing/')) { mkdir($uploadDirr.'listing/',0777,true); } $uploadDirr1 = $uploadDirr.'listing/'; $author_id = get_current_user_id(); $filename = $uploadDirr1.$author_id.'/'; if (!file_exists($filename)) { mkdir($filename,0777,true); } $filename1 = $filename.'images/'; if (!file_exists($filename1)) { mkdir($filename1,0777,true); } if (!file_exists($filename1.$guidd.'/')) { mkdir($filename1.$guidd.'/',0777,true); } $crea_listing_images_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_IMAGES_HISTORY; $getLastPostionOfImageQuery = "SELECT `image_position` FROM `$crea_listing_images_detail_table_name` WHERE `unique_id` = $listingId ORDER BY `image_position` DESC LIMIT 1"; $getPostionResult = $wpdb->get_results($getLastPostionOfImageQuery); if (isset($getPostionResult) && !empty($getPostionResult)) { $j = (int) $getPostionResult[0]->image_position; // Variable for indexing uploaded image. } else { $j = 0; // Variable for indexing uploaded image. } if (isset($_FILES) && !empty($_FILES)) { for ($i = 0; $i < count($_FILES); $i++) { $target_path = $filename1.$guidd.'/'; $validextensions = array("jpeg", "jpg", "png"); // Extensions which are allowed. $ext = explode('.', basename($_FILES[$i]['name'])); // Explode file name from dot(.) $file_extension = end($ext); // Store extensions in the variable. if( in_array($file_extension,$validextensions)) { $imageName = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $imageName; // Set the target path with a new name of image. $j = $j + 1; // Increment the number of uploaded images according to the files in array. move_uploaded_file($_FILES[$i]['tmp_name'], $target_path); $imageUrl = site_url().'/uploads/listing/'.$author_id.'/images/'.$guidd.'/'.$imageName; $crea_listing_images_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_IMAGES_HISTORY; $wpdb->insert( "$crea_listing_images_detail_table_name", array( 'user_id' => $author_id, 'unique_id' => $listingId, 'image_position' => $j, 'image_url' => "$imageUrl", 'created_time' => current_time('mysql', 1), 'updated_time' => current_time('mysql', 1), ), array( '%d', '%d', '%d', '%s', '%s', '%s', ) ); unset($imageUrl); unset($imageName); unset($target_path); } } } $html = ''; $html .= 'reorder photos '; echo $html; die(); } function aretkcrea_delete_listing_image_edit_page_from_listing_ajax() { global $wpdb; $imageId = base64_decode($_POST['id']); if ($imageId != '') { $crea_listing_images_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_IMAGES_HISTORY; $getImagePostIdQuery = "SELECT unique_id,image_url FROM $crea_listing_images_detail_table_name WHERE id=$imageId"; $resultPostIdArr = $wpdb->get_results($getImagePostIdQuery); $postId = $resultPostIdArr[0]->unique_id; if (isset($postId) && !empty($postId)) { $imagePath = parse_url($resultPostIdArr[0]->image_url, PHP_URL_PATH); $imageName = basename($imagePath); $deleteQueryFromTable = "DELETE FROM $crea_listing_images_detail_table_name WHERE id=$imageId"; $wpdb->query($deleteQueryFromTable); $author_id = get_current_user_id(); $folderUniqueId = get_post_meta($postId,'uniqueId',true); if(file_exists($_SERVER['DOCUMENT_ROOT'].'/uploads/listing/'.$author_id.'/images/'.$folderUniqueId.'/'.$imageName)) { unlink($_SERVER['DOCUMENT_ROOT'].'/uploads/listing/'.$author_id.'/images/'.$folderUniqueId.'/'.$imageName); } // reset all images position $getAllImagesQuery = "SELECT * FROM $crea_listing_images_detail_table_name WHERE unique_id=$postId ORDER BY image_position ASC"; $resultSetArr = $wpdb->get_results($getAllImagesQuery); $count = 1; foreach ($resultSetArr as $singleImage){ $wpdb->update( "$crea_listing_images_detail_table_name", array( 'image_position' => $count ), array( 'id' => $singleImage->id ), array( '%d', ), array( '%d' ) ); $count ++; } Aretk_Crea_Admin::aretkcrea_listing_update_to_aretk_server($postId,'deleteimage'); $html = ''; $html .= 'reorder photos '; echo $html; } } die(); } function aretkcrea_delete_listing_document_edit_page_from_listing_ajax() { global $wpdb; $documentId = base64_decode($_POST['documentID']); if ($documentId != '') { $crea_listing_document_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_DOCUMENT_HISTORY; $getDocumentPostIdQuery = "SELECT unique_id,document_url FROM $crea_listing_document_detail_table_name WHERE id=$documentId"; $resultPostIdArr = $wpdb->get_results($getDocumentPostIdQuery); $postId = $resultPostIdArr[0]->unique_id; if (isset($postId) && !empty($postId)) { $imagePath = parse_url($resultPostIdArr[0]->document_url, PHP_URL_PATH); $imageName = basename($imagePath); $deleteQueryFromTable = "DELETE FROM $crea_listing_document_detail_table_name WHERE id=$documentId"; $wpdb->query($deleteQueryFromTable); $author_id = get_current_user_id(); $folderUniqueId = get_post_meta($postId,'uniqueId',true); if(file_exists($_SERVER['DOCUMENT_ROOT'].'/uploads/listing/'.$author_id.'/documents/'.$folderUniqueId.'/'.$imageName)) { unlink($_SERVER['DOCUMENT_ROOT'].'/uploads/listing/'.$author_id.'/documents/'.$folderUniqueId.'/'.$imageName); } $html = ''; $crea_listing_document_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_DOCUMENT_HISTORY; $queryGetAllDocuments = "SELECT * FROM $crea_listing_document_detail_table_name WHERE unique_id = $postId ORDER BY id ASC"; $documentSet = $wpdb->get_results($queryGetAllDocuments); if (isset($documentSet) && !empty($documentSet)) { foreach ($documentSet as $documentSetKey=>$documentSetValue) { $html .='
'; $html .='document_icon.png'; $html .='document_icon.png'; $html .='

'.$documentSetValue->document_name.'

'; $html .=''; $html .='
'; } } echo $html; } } die(); } /** * create function for update listing images order * * ajax callback function update_crea_listing_images_order * * @return return crea agent update records * @package Phase 1 * @since Phase 1 * @version 1.0.0 * @author Aretk Inc. * @param null */ function aretkcrea_update_crea_listing_images_order() { global $wpdb; $idArray = explode(",",$_POST['ids']); $crea_listing_images_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_IMAGES_HISTORY; $count = 1; foreach ($idArray as $id){ $wpdb->update( "$crea_listing_images_detail_table_name", array( 'image_position' => $count ), array( 'id' => $id ), array( '%d', ), array( '%d' ) ); $count ++; } $pageId = $_POST['pageId']; Aretk_Crea_Admin::aretkcrea_listing_update_to_aretk_server($pageId,'reorder'); $html = ''; $html .= 'reorder photos '; echo $html; die(); } /** * create function for aretkcrea_update_crea_agents_records * * ajax callback function aretkcrea_update_crea_agents_records * * @return return crea agent update records * @package Phase 1 * @since Phase 1 * @version 1.0.0 * @author Aretk Inc. * @param null */ function aretkcrea_update_crea_agents_records() { global $wpdb; $crea_agent_table_name = $wpdb->prefix.ARETKCREA_AGENT_TABLE; $get_agent_ids = array(); $agent_id_array = array(); $crea_agent_auto_id = isset( $_POST['crea_agent_auto_id'] ) ? base64_decode($_POST['crea_agent_auto_id']) :''; $crea_agent_id = isset( $_POST['crea_agent_id'] ) ? base64_decode($_POST['crea_agent_id']) :''; $crea_agent_name = isset( $_POST['crea_agent_name'] ) ? base64_decode($_POST['crea_agent_name']) :''; $crea_agent_email = isset( $_POST['crea_agent_email'] ) ? base64_decode($_POST['crea_agent_email']) :''; $get_agent_ids = $wpdb->get_results("SELECT `crea_agent_id` FROM $crea_agent_table_name"); if( !empty( $get_agent_ids ) && $get_agent_ids !='' ) { foreach ( $get_agent_ids as $get_agent_key=>$get_agent_val ) { $agent_id_array[] = $get_agent_val->crea_agent_id; } } if( !in_array($crea_agent_id,$agent_id_array ) ) { $update_data_array = array('crea_agent_name' => $crea_agent_name,'crea_agent_id' => $crea_agent_id, 'crea_agent_email' => $crea_agent_email, 'crea_agent_modified_date' => current_time('mysql', 1)); $where = array('crea_id' => $crea_agent_auto_id); $update_agent_record = $wpdb->update( $crea_agent_table_name, $update_data_array, $where ); if( $update_agent_record == 1 ) { $get_agents_results = $wpdb->get_results("SELECT `crea_id`,`crea_agent_name`,`crea_agent_id`,`crea_agent_email`,`crea_agent_modified_date` FROM $crea_agent_table_name WHERE `crea_id` = '$crea_agent_auto_id'" ); if( !empty( $get_agents_results ) && $get_agents_results !='' ) { foreach ( $get_agents_results as $get_agents_key=>$get_agents_value ) { echo $get_agents_value->crea_id .','. $get_agents_value->crea_agent_id .','. $get_agents_value->crea_agent_email.','.$get_agents_value->crea_agent_modified_date.','.$get_agents_value->crea_agent_name; } } } } else { $update_data_array = array('crea_agent_name' => $crea_agent_name,'crea_agent_email' => $crea_agent_email, 'crea_agent_modified_date' => current_time('mysql', 1)); $where = array('crea_id' => $crea_agent_auto_id); $update_agent_record = $wpdb->update( $crea_agent_table_name, $update_data_array, $where ); $get_agents_id_results = $wpdb->get_results("SELECT `crea_agent_id`,`crea_agent_name`,`crea_agent_email`,`crea_agent_modified_date` FROM $crea_agent_table_name WHERE `crea_id` = '$crea_agent_auto_id'" ); echo $get_agents_id_results[0]->crea_agent_id.",agent_id_already_exsits,".$crea_agent_auto_id.','.$get_agents_id_results[0]->crea_agent_email.','.$get_agents_id_results[0]->crea_agent_modified_date.','.$get_agents_id_results[0]->crea_agent_name; } die(); } /** * create function for aretkcrea_add_new_correspondence_content * * ajax callback function aretkcrea_add_new_correspondence_content * * @return return crea agent correspondence content * @package Phase 1 * @since Phase 1 * @version 1.0.0 * @author Aretk Inc. * @param null */ function aretkcrea_add_new_correspondence_content() { global $wpdb; $postsTableName = $wpdb->prefix.'postmeta'; $crea_lead_agent_ids = !empty( $_POST['crea_lead_agent_ids']) ? $_POST['crea_lead_agent_ids'] :''; $crea_corrspondin_content = !empty( $_POST['crea_corrsponding_content']) ? $_POST['crea_corrsponding_content'] :''; if( !empty($crea_lead_agent_ids) && $crea_lead_agent_ids !='' ) { if( !empty($crea_corrspondin_content) && $crea_corrspondin_content !='') { $crea_corrspondin_content = stripslashes($crea_corrspondin_content); $crea_corrspondin_content = str_replace('"', '\"', $crea_corrspondin_content); $crea_corrspondin_content = json_encode($crea_corrspondin_content); $crea_corrspondin_content = str_replace('\r\n', '
', $crea_corrspondin_content); $crea_corrspondin_content = str_replace('\n', '
', $crea_corrspondin_content); $crea_corrspondin_content = json_decode($crea_corrspondin_content); $current_date = date_i18n( 'Y-m-d H:i' ); $new_corrsponding_key = 'crea_lead_corrsponding_text'.rand(100,999); $new_corrsponding_array = array(); $new_corrsponding_array[] = ""; $new_corrsponding_array[] = $crea_corrspondin_content; $new_corrsponding_array[] = $current_date; $new_corrsponding_array[] = ''; # message subject $new_corrsponding_array[] = 'note'; # message type: emailed, buyer inquiry, seller inquiry, update_post_meta($crea_lead_agent_ids,$new_corrsponding_key,json_encode($new_corrsponding_array)); $current_date = date_i18n( 'Y-m-d H:i' ); update_post_meta($crea_lead_agent_ids,"lead_contact_date",$current_date); $get_lead_corrsponding_ids_count = $wpdb->get_results("SELECT `meta_id`,`meta_key`,`meta_value` FROM $postsTableName WHERE `meta_key` LIKE 'crea_lead_corrsponding_text%' AND `post_id` = $crea_lead_agent_ids ORDER BY `meta_id` DESC" ); if( !empty($get_lead_corrsponding_ids_count) && $get_lead_corrsponding_ids_count != '' ) { $html =''; $html .= '
'; $html .= '
Correspondence History
'; $html .= '
'; foreach ( $get_lead_corrsponding_ids_count as $get_lead_corrsponding_ids_key=>$get_lead_corrsponding_ids_value ){ $corrsponding_messages = json_decode( $get_lead_corrsponding_ids_value->meta_value); if( is_array($corrsponding_messages) ) { $corrsponding_message = $corrsponding_messages[1]; $correspondace_date = $corrsponding_messages[2]; $corrsponding_subject = $corrsponding_messages[3]; $corrsponding_type = $corrsponding_messages[4]; } else { $corrsponding_message = $corrsponding_messages; $correspondace_date = ''; $corrsponding_subject = ''; $corrsponding_type = ''; } $html .= '
delete
'. $correspondace_date.'
'. $corrsponding_type .'
'; if ($corrsponding_type !== 'note'){ $html .= '
Subject:'. $corrsponding_subject.'
[ view ]
'; } $html .= '
'; $html .= '
'. $corrsponding_message .'
'; $html .= '
'; } $html .='
'; $crea_agent_id = get_post_meta ($crea_lead_agent_ids , 'crea_agent_id', true ); $lead_phone_email = maybe_unserialize( get_post_meta ($crea_lead_agent_ids , 'lead_phone_email', true ) ); $PrimaryEmail = get_post_meta ($crea_lead_agent_ids , 'PrimaryEmail', true ); $from = ''; if( !empty( $PrimaryEmail ) && isset( $PrimaryEmail ) ) { $from = $PrimaryEmail; } else { $from = $lead_phone_email[0]; } echo $html; } } else{ echo'Please add correspondence text'; } } die(); } /** * create function for aretkcrea_crea_remove_correspondence_content * * ajax callback function aretkcrea_crea_remove_correspondence_content * * @return return crea remove correspondence content * @package Phase 1 * @since Phase 1 * @version 1.0.0 * @author Aretk Inc * @param null */ function aretkcrea_remove_correspondence_content() { global $wpdb; $remove_id = isset( $_POST['remove_id'] ) ? $_POST['remove_id'] : ''; $crea_lead_post_id = isset( $_POST['crea_lead_post_id'] ) ? $_POST['crea_lead_post_id'] : ''; $table_name = $wpdb->prefix.'postmeta'; if( !empty( $crea_lead_post_id) && $crea_lead_post_id !='') { if( !empty($remove_id) && $remove_id !='' ) { $deleteCorrspondingvalues = "DELETE FROM $table_name WHERE `meta_id`= $remove_id"; $wpdb->query($deleteCorrspondingvalues); $get_lead_corrsponding_ids_count = $wpdb->get_results("SELECT `meta_id`,`meta_key`,`meta_value` FROM `$table_name` WHERE `meta_key` LIKE 'crea_lead_corrsponding_text%' AND `post_id` = $crea_lead_post_id ORDER BY `meta_id` DESC" ); if( !empty($get_lead_corrsponding_ids_count) && $get_lead_corrsponding_ids_count != '' ) { $html =''; $html .= '
'; $html .= '
Correspondence History
'; $html .= '
'; foreach ( $get_lead_corrsponding_ids_count as $get_lead_corrsponding_ids_key=>$get_lead_corrsponding_ids_value ){ $corrsponding_messages = json_decode( $get_lead_corrsponding_ids_value->meta_value); if( is_array($corrsponding_messages) ) { $corrsponding_message = $corrsponding_messages[1]; $correspondace_date = $corrsponding_messages[2]; $corrsponding_subject = $corrsponding_messages[3]; $corrsponding_type = $corrsponding_messages[4]; } else { $corrsponding_message = $corrsponding_messages; $correspondace_date = ''; $corrsponding_subject = ''; $corrsponding_type = ''; } $html .= '
delete
'. $correspondace_date.'
'. $corrsponding_type .'
'; if ($corrsponding_type !== 'note'){ $html .= '
Subject:'. $corrsponding_subject.'
[ view ]
'; } $html .= '
'; $html .= '
'. $corrsponding_message .'
'; $html .= '
'; /* $corrsponding_messages = json_decode( $get_lead_corrsponding_ids_value->meta_value); $html .='
'; if( is_array($corrsponding_messages) ) { $html .='

'. $corrsponding_messages[1].'

'; } else { $html .='

'.$get_lead_corrsponding_ids_value->meta_value.'

'; } $html .='delete'; if( is_array($corrsponding_messages) && $corrsponding_messages[0] !='') { $html .='Return to Lead'; } $current_date_results = ''; if(is_array($corrsponding_messages) && $corrsponding_messages[2] !='' ) { $current_date_results = $corrsponding_messages[2]; $html.='
'.$current_date_results.'
'; } $html .='
'; */ } $html .='
'; echo $html; } } } die(); } /** * Function for Add button in Listing Lead section * * @param unknown_type $views * @return unknown */ function aretkcrea_custom_button_for_lead_list( $views ) { $views['add-new-lead'] =''. strtoupper(__(ARETKCREA_LEADS_BTN_TXT_ADD_NEW_LEAD, ARETKCREA_PLUGIN_SLUG)) .''; $views['send-email-leads'] =''. strtoupper(__(ARETKCREA_LEADS_BTN_TXT_SEND_EMAIL, ARETKCREA_PLUGIN_SLUG)) .''; $views['lead-category'] =''; $views['leadforms'] =''. strtoupper(__(ARETKCREA_LEADS_BTN_TXT_LEAD_FORMS, ARETKCREA_PLUGIN_SLUG)) .''; $views['import-lead'] =''. strtoupper(__(ARETKCREA_LEADS_BTN_TXT_IMPORT_LEADS, ARETKCREA_PLUGIN_SLUG)) .''; $views['export-lead'] =''; $views['download-lead'] =''; return $views; } /** * Change aretk_lead edit link * */ function aretkcrea_edit_aretk_post_link ( $url, $post_id, $context) { $aretk_lead = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] :''; if( $aretk_lead == 'aretk_lead' ) { $url = site_url().'/wp-admin/admin.php?page=create_new_leads&ID='.$post_id.'&action=edit'; return $url; } elseif ( $aretk_lead =='aretk_listing' ) { $url = site_url().'/wp-admin/admin.php?page=create_new_listings&id='.$post_id; return $url; } else{ return $url; } } /** * Function is used for create lead from admin side */ public function aretkcrea_handle_create_lead_form_action() { global $wpdb, $wp; if (isset($_POST['posttype']) && $_POST['posttype'] =='lead') { if (isset($_POST) && $_POST['action'] == 'lead-form' && $_POST['action-which'] == 'add' && $_POST['posttype'] == 'lead') { // General Tab $create_lead_name = isset($_POST['create_lead_name'])? sanitize_text_field( $_POST['create_lead_name'] ):''; if (isset($create_lead_name) && !empty($_POST['create_lead_name'])) { $crea_agent_id = isset($_POST['crea_agent_id'])? ($_POST['crea_agent_id']):''; $crea_new_lead_category = isset($_POST['new_lead_category'])? $_POST['new_lead_category'] :array(); $crea_agent_phone_type = isset($_POST['crea_agent_phone_type'])? $_POST['crea_agent_phone_type']:array(); $create_lead_phone_no = isset($_POST['create_lead_phone_no'])? $_POST['create_lead_phone_no'] :array(); $create_lead_phone_email = isset($_POST['create_lead_phone_email'])? $_POST['create_lead_phone_email'] :array(); $PrimaryEmail = isset($_POST['PrimaryEmail'])? $_POST['PrimaryEmail'] :''; $create_lead_company = isset($_POST['create_lead_company'])? $_POST['create_lead_company'] :''; $create_lead_address_line1 = isset($_POST['create_lead_address_line1'])? $_POST['create_lead_address_line1'] :''; $create_lead_province = isset($_POST['create_lead_province'])? $_POST['create_lead_province'] :''; $create_lead_city = isset($_POST['create_lead_city'])? $_POST['create_lead_city'] :''; $create_lead_country = isset($_POST['create_lead_country'])? $_POST['create_lead_country'] :''; $create_lead_social_url = isset($_POST['create_lead_social_url'])? $_POST['create_lead_social_url'] :array(); $crea_agent_social_type = isset($_POST['crea_agent_social_type'])? ($_POST['crea_agent_social_type']):array(); $comment = isset($_POST['comment'])? sanitize_text_field($_POST['comment']):array(); $merge_phonetype = array(); $op_counter = 0; foreach ( $crea_agent_phone_type as $crea_agent_phone_type_val ) { $phonetype = $crea_agent_phone_type[$op_counter]; $phoneno = $create_lead_phone_no[$op_counter]; $merge_phonetype[] = array('PhoneType'=>$phonetype,'PhoneNo'=>$phoneno); $op_counter++; } $merge_social = array(); $op_counter_new = 0; foreach ( $crea_agent_social_type as $crea_agent_social_type_val ) { $socialtype = $crea_agent_social_type[$op_counter_new]; $sociallink = $create_lead_social_url[$op_counter_new]; $merge_social[] = array('SocialType'=>$socialtype,'SocialLink'=>$sociallink); $op_counter_new++; } $new_post = array( 'post_title' => $create_lead_name, 'post_content' => $comment, 'post_status' => 'publish', 'post_type' => 'aretk_lead' ); $leadId = wp_insert_post($new_post); update_post_meta($leadId,'lead_id',$leadId); update_post_meta($leadId,'crea_agent_id',$crea_agent_id); update_post_meta($leadId,'lead_phone_no',maybe_serialize($merge_phonetype)); update_post_meta($leadId,'lead_phone_email',maybe_serialize($create_lead_phone_email)); update_post_meta($leadId,'create_lead_company',$create_lead_company); update_post_meta($leadId,'lead_address_line',$create_lead_address_line1); update_post_meta($leadId,'lead_province',$create_lead_province); update_post_meta($leadId,'lead_city',$create_lead_city); update_post_meta($leadId,'create_lead_country',$create_lead_country); update_post_meta($leadId,'agent_social_type',maybe_serialize($merge_social)); update_post_meta($leadId,'lead_form_type','other'); update_post_meta($leadId,'lead_primary_email',$PrimaryEmail); update_post_meta($leadId,'lead_comment',$comment); wp_set_object_terms( $leadId, $crea_new_lead_category, 'lead-category'); $from = ''; if( !empty( $PrimaryEmail ) && isset( $PrimaryEmail ) ) { $from = $PrimaryEmail; } else { $from = $create_lead_phone_email[0]; } wp_safe_redirect(site_url('/wp-admin/admin.php?page=create_new_leads&ID='.$leadId.'&action=edit')); } else { wp_safe_redirect(site_url('/wp-admin/admin.php?page=create_new_leads')); } } /** * edit leads */ if (isset($_POST) && $_POST['action'] == 'lead-form' && $_POST['action-which'] == 'edit' && $_POST['posttype'] == 'lead') { // General Tab $create_lead_name = isset($_POST['create_lead_name'])? sanitize_text_field($_POST['create_lead_name']):''; if (isset($create_lead_name) && !empty($_POST['create_lead_name'])) { $crea_edit_lead_id = isset($_POST['aretk-lead-id'])? ($_POST['aretk-lead-id']):''; $crea_new_lead_category = isset($_POST['new_lead_category'])? $_POST['new_lead_category'] :array(); $crea_edit_lead_name = isset($_POST['create_lead_name'])? sanitize_text_field($_POST['create_lead_name']):''; $crea_agent_id = isset($_POST['crea_agent_id'])? $_POST['crea_agent_id']:''; $crea_agent_phone_type = isset($_POST['crea_agent_phone_type'])? $_POST['crea_agent_phone_type']:array(); $create_lead_phone_no = isset($_POST['create_lead_phone_no'])? $_POST['create_lead_phone_no'] :array(); $create_lead_phone_email = isset($_POST['create_lead_phone_email'])? $_POST['create_lead_phone_email'] :array(); $PrimaryEmail = isset($_POST['PrimaryEmail'])? $_POST['PrimaryEmail'] :''; $create_lead_company = isset($_POST['create_lead_company'])? $_POST['create_lead_company'] :''; $create_lead_address_line1 = isset($_POST['create_lead_address_line1'])? $_POST['create_lead_address_line1'] :''; $create_lead_address_line2 = isset($_POST['create_lead_address_line2'])? $_POST['create_lead_address_line2'] :''; $create_lead_province = isset($_POST['create_lead_province'])? $_POST['create_lead_province'] :''; $create_lead_city = isset($_POST['create_lead_city'])? $_POST['create_lead_city'] :''; $create_lead_country = isset($_POST['create_lead_country'])? $_POST['create_lead_country'] :''; $create_lead_social_url = isset($_POST['create_lead_social_url'])? $_POST['create_lead_social_url']:array(); $crea_agent_social_type = isset($_POST['crea_agent_social_type'])? $_POST['crea_agent_social_type']:array(); $comment = isset($_POST['comment'])? $_POST['comment'] :array(); $merge_phonetype = array(); $op_counter = 0; foreach ( $crea_agent_phone_type as $crea_agent_phone_type_val ) { $phonetype = $crea_agent_phone_type[$op_counter]; $phoneno = $create_lead_phone_no[$op_counter]; $merge_phonetype[] = array('PhoneType'=>$phonetype,'PhoneNo'=>$phoneno); $op_counter++; } $merge_social = array(); $op_counter_new = 0; foreach ( $crea_agent_social_type as $crea_agent_social_type_val ) { $socialtype = $crea_agent_social_type[$op_counter_new]; $sociallink = $create_lead_social_url[$op_counter_new]; $merge_social[] = array('SocialType'=>$socialtype,'SocialLink'=>$sociallink); $op_counter_new++; } $update_lead_post_content = array('ID' => $crea_edit_lead_id,'post_title'=> $crea_edit_lead_name,'post_content' => $comment); wp_update_post( $update_lead_post_content ); $lead_form_type = get_post_meta( $crea_edit_lead_id, 'lead_form_type', $single = false ); foreach ( $lead_form_type as $current_user_lead_form) { $current_user_lead_form_type = $current_user_lead_form; } update_post_meta($crea_edit_lead_id,'crea_agent_id',$crea_agent_id); update_post_meta($crea_edit_lead_id,'lead_phone_no',maybe_serialize($merge_phonetype)); update_post_meta($crea_edit_lead_id,'lead_phone_email',maybe_serialize($create_lead_phone_email)); update_post_meta($crea_edit_lead_id,'create_lead_company',$create_lead_company); update_post_meta($crea_edit_lead_id,'lead_address_line',$create_lead_address_line1); update_post_meta($crea_edit_lead_id,'lead_address_line2',$create_lead_address_line2); update_post_meta($crea_edit_lead_id,'lead_province',$create_lead_province); update_post_meta($crea_edit_lead_id,'lead_city',$create_lead_city); update_post_meta($crea_edit_lead_id,'create_lead_country',$create_lead_country); update_post_meta($crea_edit_lead_id,'agent_social_type',maybe_serialize($merge_social)); update_post_meta($crea_edit_lead_id,'lead_form_type',$current_user_lead_form_type); update_post_meta($crea_edit_lead_id,'lead_primary_email',$PrimaryEmail); update_post_meta($crea_edit_lead_id,'lead_comment',$comment); wp_set_object_terms( $crea_edit_lead_id, $crea_new_lead_category, 'lead-category'); wp_safe_redirect(site_url('/wp-admin/admin.php?page=create_new_leads&ID='.$crea_edit_lead_id.'&action=edit')); } else { wp_safe_redirect(site_url('/wp-admin/admin.php?page=create_new_leads')); } } } } // Function to creat necassary plugin pages. public function aretkcrea_create_listing_detail_page() { $pages = get_pages(); $listings_page = array( 'slug' => 'listing-details', 'title' => 'Listing Details', 'content' => '[ARETK-LDS]' ); $search_results_page = array( 'slug' => 'search-results', 'title' => 'Search Results', 'content' => '[ARTEK-DLS]' ); // search results page foreach ($pages as $page) { $apage = $page->post_name; if ( $apage == 'search-results') { $search_results_page_found = '1'; break; } else { $search_results_page_found = '0'; } } if($search_results_page_found != '1'){ $page_id = wp_insert_post(array( 'post_title' => $search_results_page['title'], 'post_type' =>'page', 'post_name' => $search_results_page['slug'], 'post_content' => $search_results_page['content'], 'post_status' => 'publish', )); } // listing detail page foreach ($pages as $page) { $apage = $page->post_name; if ( $apage == 'listing-details') { $listing_detail_found = '1'; break; } else { $listing_detail_found = '0'; } } if($listing_detail_found != '1'){ $page_id = wp_insert_post(array( 'post_title' => $listings_page['title'], 'post_type' =>'page', 'post_name' => $listings_page['slug'], 'post_content' => $listings_page['content'], 'post_status' => 'publish', )); } $post_id = !empty( $_GET['post'] ) ? $_GET['post'] : ''; if ( !empty( $post_id ) && is_numeric( $post_id ) ) { $post = get_post($post_id); $slug = $post->post_name; if ( $slug === 'listing-details' || $slug === 'search-results') { remove_post_type_support('page', 'editor'); remove_meta_box( 'authordiv' , 'page' , 'normal' ); // removes comments status remove_meta_box( 'categorydiv' , 'page' , 'normal' ); // removes comments remove_meta_box( 'commentstatusdiv' , 'page' , 'normal' ); // removes author remove_meta_box( 'commentsdiv' , 'page' , 'normal' ); // removes Comments metabox remove_meta_box( 'postexcerpt' , 'page' , 'normal' ); // removes Excerpt metabox remove_meta_box( 'postimagediv' , 'page' , 'side' ); // removes Featured image metabox remove_meta_box( 'slugdiv' , 'page' , 'normal' ); // removes Slug metabox remove_meta_box( 'trackbacksdiv' , 'page' , 'normal' ); // removes Trackbacks metabox } } } public function aretkcrea_restrict_post_deletion($post_id) { $property_detail = get_post($post_id); $property_detail_slug = $property_detail->post_name; if( $property_detail_slug == 'listing-details' || $property_detail_slug == 'search-results' ) { die('The page you were trying to delete is protected. Click the back button to return to the previous page.'); } } function aretkcrea_add_listing_showcase_changes(){ $get_include_information = isset($_POST['get_include_information']) ? $_POST['get_include_information'] : ''; $get_include_contact_form = isset($_POST['get_include_contact_form']) ? $_POST['get_include_contact_form'] : ''; $get_include_map = isset($_POST['get_include_map']) ? $_POST['get_include_map'] : ''; $get_include_walk_score = isset($_POST['get_include_walk_score']) ? $_POST['get_include_walk_score'] : ''; $get_include_print_button = isset($_POST['get_include_print_button']) ? $_POST['get_include_print_button'] : ''; $get_crea_listing_price_color_id = isset($_POST['get_crea_listing_price_color_id']) ? $_POST['get_crea_listing_price_color_id'] : ''; $get_crea_listing_send_btn_color_id = isset($_POST['get_crea_listing_send_btn_color_id']) ? $_POST['get_crea_listing_send_btn_color_id'] : ''; $get_crea_listing_email_address_of_agent = isset($_POST['get_include_email_address_of_agent']) ? $_POST['get_include_email_address_of_agent'] : ''; update_option('crea_listing_include_information', $get_include_information); update_option('crea_listing_include_contact_form', $get_include_contact_form); update_option('crea_listing_include_map', $get_include_map); update_option('crea_listing_include_walk_score', $get_include_walk_score); update_option('crea_listing_include_print_btn', $get_include_print_button); update_option('crea_listing_include_email_address_of_agent', $get_crea_listing_email_address_of_agent); update_option('crea_listing_include_price_color', $get_crea_listing_price_color_id); update_option('crea_listing_include_send_btn_color', $get_crea_listing_send_btn_color_id); die(); } //function ajax call default listing setting function aretkcrea_add_default_listing_setting(){ $DefaultlistingTextColor = isset($_POST['DefaultlistingTextColor']) ? $_POST['DefaultlistingTextColor'] : ''; $DefaultlistingAddressbarColor = isset($_POST['DefaultlistingAddressbarColor']) ? $_POST['DefaultlistingAddressbarColor'] : ''; $DefaultlistingPriceColor = isset($_POST['DefaultlistingPriceColor']) ? $_POST['DefaultlistingPriceColor'] : ''; $DefaultlistingStatusColor = isset($_POST['DefaultlistingStatusColor']) ? $_POST['DefaultlistingStatusColor'] : ''; $DefaultlistingopenhouseColor = isset($_POST['DefaultlistingopenhouseColor']) ? $_POST['DefaultlistingopenhouseColor'] : ''; $DefaultlistingStatusTextColor = isset($_POST['DefaultlistingStatusTextColor']) ? $_POST['DefaultlistingStatusTextColor'] : ''; $DefaultlistingopenhouseTextColor = isset($_POST['DefaultlistingopenhouseTextColor']) ? $_POST['DefaultlistingopenhouseTextColor'] : ''; $Defaultlistinglisting_pagination_color_id = isset($_POST['DefaultlistingpaginationColor']) ? $_POST['DefaultlistingpaginationColor'] : ''; $Defaultlistinglisting_pagination_text_color_id = isset($_POST['DefaultlistingpaginationtextColor']) ? $_POST['DefaultlistingpaginationtextColor'] : ''; $Defaultlisting_Openhouseyes_or_not = isset($_POST['get_openHouse']) ? $_POST['get_openHouse'] : ''; $Defaultlistingstatus_yes_or_not = isset($_POST['get_status']) ? $_POST['get_status'] : ''; $Defaultlistingsearchbar_yes_or_not = isset($_POST['get_search']) ? $_POST['get_search'] : ''; update_option('crea_default_listing_text',$DefaultlistingTextColor); update_option('crea_default_listing_address_bar_listing_include',$DefaultlistingAddressbarColor); update_option('crea_default_listing_price_color',$DefaultlistingPriceColor); update_option('crea_default_listing_status_color',$DefaultlistingStatusColor); update_option('crea_default_listing_openhouse_color',$DefaultlistingopenhouseColor); update_option('crea_default_listing_status_text_color',$DefaultlistingStatusTextColor); update_option('crea_default_listing_openhouse_text_color',$DefaultlistingopenhouseTextColor); update_option('crea_default_listing_status_yes_or_not',$Defaultlistingstatus_yes_or_not); update_option('crea_default_listing_openhouse_yes_or_not',$Defaultlisting_Openhouseyes_or_not); update_option('crea_default_listing_searchbar_yes_or_not',$Defaultlistingsearchbar_yes_or_not); update_option('crea_default_listing_pagination_color_id_yes_or_not',$Defaultlistinglisting_pagination_color_id); update_option('crea_default_listing_pagination_text_color_id_yes_or_not',$Defaultlistinglisting_pagination_text_color_id); die(); } //function for ajax call search detail setting changes function aretkcrea_add_search_listing_detail_showcase_changes(){ $search_feed_id = isset($_POST['search_feed_id']) ? $_POST['search_feed_id'] : ''; $get_crea_search_inc_exc_listing_feed = isset($_POST['search_inc_exc_listing_feed']) ? $_POST['search_inc_exc_listing_feed'] : ''; $get_crea_search_exclude_field_property_type = isset($_POST['search_exclude_field_property_type']) ? $_POST['search_exclude_field_property_type'] : ''; $get_search_exclude_field_structure = isset($_POST['search_exclude_field_structure']) ? $_POST['search_exclude_field_structure'] : ''; $get_search_exclude_field_status = isset($_POST['search_exclude_field_status']) ? $_POST['search_exclude_field_status'] : ''; $get_search_exclude_field_bedrooms = isset($_POST['search_exclude_field_bedrooms']) ? $_POST['search_exclude_field_bedrooms'] : ''; $get_search_exclude_field_bathrooms_full = isset($_POST['search_exclude_field_bathrooms_full']) ? $_POST['search_exclude_field_bathrooms_full'] : ''; $get_search_exclude_field_finished_basement = isset($_POST['search_exclude_field_finished_basement']) ? $_POST['search_exclude_field_finished_basement'] : ''; $get_search_exclude_field_select_city = isset($_POST['search_exclude_field_select_city']) ? $_POST['search_exclude_field_select_city'] : ''; $get_crea_max_price_range = !empty( $_POST['search_max_price_ranger_value'] ) ? sanitize_text_field( $_POST['search_max_price_ranger_value'] ):''; $get_crea_search_detail_title_color_id = isset($_POST['crea_search_detail_title_color_id']) ? $_POST['crea_search_detail_title_color_id'] : ''; $get_crea_search_detail_button_color_id = isset($_POST['crea_search_detail_button_color_id']) ? $_POST['crea_search_detail_button_color_id'] : ''; $get_crea_select_result_layout = isset($_POST['select_result_layout']) ? $_POST['select_result_layout'] : ''; $search_list_count = isset( $_POST['search_list_count'] ) ? $_POST['search_list_count'] :''; $aretkcrea_showcase_search_advancefilterclosed = isset( $_POST['aretkcrea_showcase_search_advancefilterclosed'] ) ? $_POST['aretkcrea_showcase_search_advancefilterclosed'] : 'no'; update_option('crea_search_feed_id',$search_feed_id); update_option('crea_search_inc_exc_listing_feed',$get_crea_search_inc_exc_listing_feed); update_option('crea_search_exclude_field_property_type',$get_crea_search_exclude_field_property_type); update_option('crea_search_exclude_field_structure',$get_search_exclude_field_structure); update_option('crea_search_exclude_field_status',$get_search_exclude_field_status); update_option('crea_search_exclude_field_bedrooms',$get_search_exclude_field_bedrooms); update_option('crea_search_exclude_field_bathrooms_full',$get_search_exclude_field_bathrooms_full); update_option('crea_search_exclude_field_finished_basement',$get_search_exclude_field_finished_basement); update_option('crea_search_exclude_field_select_city',$get_search_exclude_field_select_city); update_option('crea_search_max_price_slider_range',$get_crea_max_price_range); update_option('crea_search_detail_title_color_id',$get_crea_search_detail_title_color_id); update_option('crea_search_detail_button_color_id',$get_crea_search_detail_button_color_id); update_option('crea_select_result_layout',$get_crea_select_result_layout); update_option('select_result_layout_counter',$search_list_count); update_option('aretkcrea_showcase_search_advancefilterclosed',$aretkcrea_showcase_search_advancefilterclosed); die(); } /** * Disable Month Dropdown from Custom Lead * * @param unknown_type $status * @param unknown_type $post_type * @return unknown */ public function aretkcrea_filter_disable_months_dropdown_custom( $status, $post_type ) { if ( $post_type == 'aretk_lead' ){ $status = true; } else { $status = false; } return $status; } /** * Add Select Form option * */ public function aretkcrea_restrict_manage_posts_custom_for_lead( ){ //execute only on the 'aretk_lead' content type global $wpdb,$post, $typenow, $wp_query; $crea_agent_table_name = $wpdb->prefix . ARETKCREA_AGENT_TABLE; $lead_form_type_general_selected = ''; $lead_form_type_seller_selected = ''; $lead_form_type_buyer_selected = ''; $lead_form_type_selected = ''; $lead_agent_selected = ''; $selected_category_name = ''; if( $typenow == 'aretk_lead'){ if ( !empty( $_GET['lead_form_type'] ) && isset( $_GET['lead_form_type'] ) ) { if( $_GET['lead_form_type'] == 'general' ) { $lead_form_type_general_selected = 'selected'; } elseif ( $_GET['lead_form_type'] == 'seller' ) { $lead_form_type_seller_selected = 'selected'; } elseif ( $_GET['lead_form_type'] == 'buyer' ) { $lead_form_type_buyer_selected = 'selected'; } else { $lead_form_type_selected = 'selected'; } } $output = ''; $output.= ''; // start subscription status condition $getSubscriptionStatus = get_option('crea_subscription_status', ''); if( isset( $getSubscriptionStatus ) && !empty( $getSubscriptionStatus ) && $getSubscriptionStatus === 'valid' ){ $output.=''; } // end subscription status condition $get_lead_agent_name = $wpdb->get_results("SELECT * FROM $crea_agent_table_name"); $taxonomy = 'lead-category'; $term_args=array( 'hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC', 'post_type' => 'aretk_lead', ); $tax_terms = get_terms($taxonomy,$term_args); $output.=''; echo $output; } } /** * Prepare Query based on Select form * */ public function aretkcrea_pre_get_posts_custom_for_lead( $query ){ global $post_type, $pagenow; //if we are currently on the edit screen of the post type listings if($pagenow == 'edit.php' && $post_type == 'aretk_lead'){ if(isset($_GET['lead_form_type'])){ //get the lead form type $lead_form_type = !empty( $_GET['lead_form_type'] ) ? sanitize_text_field($_GET['lead_form_type']) : ''; //get the agent name $lead_agent_name = !empty( $_GET['lead_agent_name'] ) ? sanitize_text_field($_GET['lead_agent_name']) : ''; //get the category name $lead_category_name =!empty( $_GET['lead_category_name'] ) ? sanitize_text_field($_GET['lead_category_name']) : ''; //if the post format is not 0 (which means all) if( $lead_form_type != 'selectform' && $lead_form_type != '' ){ $query->query_vars['meta_query'] = array( array( 'key' => 'lead_form_type', 'value' => $lead_form_type, 'compare' => '=' ) ); } if( $lead_category_name !='selectcategoryname' && $lead_category_name !='') { $query->query_vars['tax_query'] = array( array( 'taxonomy' => 'lead-category', 'field' => 'name', 'terms' => $lead_category_name ) ); } //set meta query for filter agent id if( $lead_agent_name != 'selectagentid' && $lead_agent_name != '' ){ $query->query_vars['meta_query'] = array( array( 'key' => 'crea_agent_id', 'value' => $lead_agent_name, 'compare' => '=' ) ); } //filter both query agent and form if( $lead_agent_name != 'selectagentid' && $lead_form_type != 'selectform' && $lead_form_type != '' && $lead_agent_name != '' ){ $query->query_vars['meta_query'] = array( 'relation' => 'AND', array( 'key' => 'lead_form_type', 'value' => $lead_form_type, 'compare' => '=' ), array( 'key' => 'crea_agent_id', 'value' => $lead_agent_name, 'compare' => '=' ) ); } if( $lead_agent_name != 'selectagentid' && $lead_category_name != 'selectcategoryname' && $lead_agent_name != '' && $lead_category_name != '' ){ $query->query_vars['meta_query'] = array( array( 'key' => 'crea_agent_id', 'value' => $lead_agent_name, 'compare' => '=' ) ); $query->query_vars['tax_query'] = array( array( 'taxonomy' => 'lead-category', 'field' => 'name', 'terms' => $lead_category_name ) ); } // two table lead form and category form is selected if( $lead_form_type != 'selectform' && $lead_form_type != '' && $lead_category_name != 'selectcategoryname' && $lead_category_name != '' ){ $query->query_vars['meta_query'] = array( array( 'key' => 'lead_form_type', 'value' => $lead_form_type, 'compare' => '=' ) ); $query->query_vars['tax_query'] = array( array( 'taxonomy' => 'lead-category', 'field' => 'name', 'terms' => $lead_category_name ) ); } // if three box are selected if( $lead_form_type != 'selectform' && $lead_form_type != '' && $lead_category_name != 'selectcategoryname' && $lead_category_name != '' && $lead_agent_name != 'selectagentid' && $lead_agent_name != '' ){ $query->query_vars['meta_query'] = array( 'relation' => 'AND', array( 'key' => 'lead_form_type', 'value' => $lead_form_type, 'compare' => '=' ), array( 'key' => 'crea_agent_id', 'value' => $lead_agent_name, 'compare' => '=' ) ); $query->query_vars['tax_query'] = array( array( 'taxonomy' => 'lead-category', 'field' => 'name', 'terms' => $lead_category_name ) ); } } } } /** * Bulk Edit action * */ public function aretkcrea_custom_bulk_edit_action_for_aretk_lead( $actions ){ $actions[ 'email' ] = 'Email'; unset( $actions[ 'edit' ] ); return $actions; } /** * Custom Lead Admin footer * */ public function aretkcrea_custom_lead_admin_footer(){ global $post_type; if($post_type == 'aretk_lead') { /* // Commented out as this is already set, keeping for now in case scenario found where this is needed.. ?> query['post_type']) ? $wp_query->query['post_type'] :''; $post_type_results = isset($post_type ) ? $post_type :''; if( $post_type_results == 'aretk_lead'){ if ( $post_type == 'aretk_lead') { if( !empty( $_GET['orderby'] ) && !empty( $_GET['order'] ) ){ $wp_query->set('orderby', $_GET['orderby']); $wp_query->set('order', $_GET['order']); } else { $wp_query->set('orderby', 'post_modified'); $wp_query->set('order', 'DESC'); } } } } /** * Custom Email Bulk action * */ public function aretkcrea_custom_email_bulk_action () { global $wpdb; $request_all_email = isset($_REQUEST['post_type'])?$_REQUEST['post_type']:''; $request_all_email_post_id = isset($_REQUEST['post'])?$_REQUEST['post']:''; $wp_list_table = _get_list_table('WP_Posts_List_Table'); $action = $wp_list_table->current_action(); if(isset($action ) && $action == 'email' ){ $all_selected_email = isset($_REQUEST['post'])?$_REQUEST['post']:''; if($all_selected_email !='') { $all_bcc_email = array(); foreach ( $all_selected_email as $all_custom_selected_email ) { $all_bcc_email[] = $all_custom_selected_email; } $all_custom_post_selected_email_bcc = $all_bcc_email; update_option('selected_lead_post_email_to_bcc' , $all_custom_post_selected_email_bcc); wp_safe_redirect(site_url('/wp-admin/admin.php?page=send_email_leads&&email=bcc')); exit(); } } } /** * Delete Exclusive Listing * */ public function aretkcrea_delete_excusive_listing() { global $wpdb; $exclusiveListingId = $_POST['mlsId']; if (isset($exclusiveListingId) && !empty($exclusiveListingId)) { $inactiveStoredDataExclusiveDeletedPostId = array(); $last_aretk_server_insert_id = get_post_meta($exclusiveListingId,'aretk_server_listing_id',true); if ( !empty( $last_aretk_server_insert_id ) && $last_aretk_server_insert_id != '' ) { $exclusiveListingIdResult = array(); $exclusiveListingIdResult[] = (string)$last_aretk_server_insert_id; $exclusive_old_property_id_array = array(); $mergerd_property_id_array = array(); $exclusive_deleted_id_result = get_option("exclusive_deleted_ids"); if ( !empty( $exclusive_deleted_id_result ) && $exclusive_deleted_id_result != 'null' ) { $exclusive_old_property_id_array = json_decode($exclusive_deleted_id_result); } $mergerd_property_id_array = array_merge($exclusive_old_property_id_array,$exclusiveListingIdResult); $mergerd_property_id_array = array_unique($mergerd_property_id_array); $mergerd_property_id_array = json_encode($mergerd_property_id_array); update_option("exclusive_deleted_ids",$mergerd_property_id_array); } $crea_listing_images_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_IMAGES_HISTORY; $deleteImageHistoryQuery = "DELETE FROM $crea_listing_images_detail_table_name WHERE unique_id=$exclusiveListingId"; $wpdb->query($deleteImageHistoryQuery); $author_id = get_current_user_id(); $guidd = get_post_meta($exclusiveListingId,'uniqueId',true); $imagePath = $_SERVER['DOCUMENT_ROOT'].'/uploads/listing/'.$author_id.'/images/'.$guidd; Aretk_Crea_Admin::aretkcrea_deleteDirectory($imagePath); $documentPath = $_SERVER['DOCUMENT_ROOT'].'/uploads/listing/'.$author_id.'/documents/'.$guidd; Aretk_Crea_Admin::aretkcrea_deleteDirectory($documentPath); $getAretkServerListingIdPostMeta = get_post_meta($exclusiveListingId,'aretk_server_listing_id',true); if (isset($getAretkServerListingIdPostMeta) && !empty($getAretkServerListingIdPostMeta)) { $listingId = (int) $getAretkServerListingIdPostMeta; Aretk_Crea_Admin::aretkcrea_listing_update_to_aretk_server($listingId,'delete'); } wp_delete_post($exclusiveListingId); $crea_user_name_table_name = $wpdb->prefix.ARETKCREA_USER_LISTING_DETAILS; $getAllUsername = $wpdb->get_results("SELECT username FROM $crea_user_name_table_name"); $allListingArr = array(); $crea_agent_table_name = $wpdb->prefix . ARETKCREA_AGENT_TABLE; $getAllAgentIds = $wpdb->get_results("SELECT crea_agent_id FROM $crea_agent_table_name",ARRAY_A); if ( isset($getAllAgentIds) && !empty($getAllAgentIds)) { $agent_id_array = array(); foreach ( $getAllAgentIds as $getAllAgentId ){ $agent_id_array[] = $getAllAgentId['crea_agent_id']; } $agent_id = implode(',',$agent_id_array); } else { $agent_id = null; } if (isset($getAllUsername) && !empty($getAllUsername)) { foreach ($getAllUsername as $singleUsername ) { $userName = $singleUsername->username; $result_type = 'full'; $listing = Aretk_Crea_Admin::aretkcrea_get_user_listing_records_by_username_by_view_type($userName,$result_type,$agent_id); if($listing[0]->TotalRecords > 0 ) { array_shift($listing); $allListingArr = array_merge($allListingArr,$listing); } unset($singleUsername); } unset($getAllUsername); } $args = array( 'posts_per_page' => -1, 'post_type' => 'aretk_listing', 'post_status' => 'publish' ); $posts_array = (array) get_posts( $args ); $exclusiveArr = array(); foreach ($posts_array as $singlePost) { $singlePost1 = (array) $singlePost; $singlePost2 = (object) $singlePost1; $exclusiveArr[] = $singlePost2; } $allListingFinalArr = array(); $allListingFinalArr = array_merge($allListingArr,$exclusiveArr); $data = json_encode($allListingFinalArr); update_option('cron_run',""); update_option('cron_run',"$data"); $getAllListingData = get_option('cron_run'); if (isset($getAllListingData) && !empty($getAllListingData)) { $allListingFinalArr = json_decode($getAllListingData); } else { $crea_user_name_table_name = $wpdb->prefix.ARETKCREA_USER_LISTING_DETAILS; $getAllUsername = $wpdb->get_results("SELECT username FROM $crea_user_name_table_name"); //get all agent ids from database $crea_agent_table_name = $wpdb->prefix . ARETKCREA_AGENT_TABLE; $getAllAgentIds = $wpdb->get_results("SELECT crea_agent_id FROM $crea_agent_table_name",ARRAY_A); if ( isset($getAllAgentIds) && !empty($getAllAgentIds)) { $agent_id_array = array(); foreach ( $getAllAgentIds as $getAllAgentId ){ $agent_id_array[] = $getAllAgentId['crea_agent_id']; } $agent_id = implode(',',$agent_id_array); } else { $agent_id = null; } $allListingArr = array(); $userNameList = ''; if (isset($getAllUsername) && !empty($getAllUsername)) { foreach ($getAllUsername as $singleUsername) { $userName = $singleUsername->username; if ( !empty( $userName ) ){ $userNameList.=$userName.','; } unset($singleUsername); } unset($getAllUsername); $userNameList = rtrim($userNameList,','); $result_type = 'full'; if ( $agent_ids != null ){ $listings = Aretk_Crea_Admin::aretkcrea_get_user_listing_records_by_username_by_view_type($userNameList, $result_type,$agent_ids); if ( isset($listings) && !empty($listings)) { foreach ($listings as $listing_key => $listing ){ if ( !isset( $listing->TotalRecords ) && empty( $listing->TotalRecords ) ) { $allListingArr[$listing->mlsID] = $listing; } } } } } $args = array( 'posts_per_page' => -1, 'post_type' => 'aretk_listing', 'post_status' => 'publish' ); $posts_array = (array) get_posts( $args ); $exclusiveArr = array(); foreach ($posts_array as $singlePost) { $singlePost1 = (array) $singlePost; $singlePost2 = (object) $singlePost1; $exclusiveArr[] = $singlePost2; } $allListingFinalArr = array(); $allListingFinalArr = array_merge($allListingArr,$exclusiveArr); } $html = ''; $html .= ''; if (isset($allListingFinalArr) && !empty($allListingFinalArr)) { foreach ($allListingFinalArr as $singleListing) { if (isset($singleListing->post_author) && !empty($singleListing->post_author)) { $ListingAddress = get_post_meta($singleListing->ID,'listingAddress',true); $ListingCity = get_post_meta($singleListing->ID,'listingcity',true); $ListingPrice = get_post_meta($singleListing->ID,'listingPrice',true); $date = date('d-m-Y',strtotime($singleListing->post_date)); $crea_listing_images_detail_table_name = $wpdb->prefix.ARETKCREA_LISTING_IMAGES_HISTORY; $querySelectFirstImage = "SELECT image_url FROM $crea_listing_images_detail_table_name WHERE image_position =1 AND unique_id = $singleListing->ID"; $resultSet = $wpdb->get_results($querySelectFirstImage); if (isset($resultSet) && !empty($resultSet)) { $path = $resultSet[0]->image_url; } else { $path = ARETK_CREA_PLUGIN_URL.'admin/images/dummy_image.png'; } $agentArrDecoded = get_post_meta($singleListing->ID,'listingAgentId',true); $agentArr = json_decode($agentArrDecoded); if (isset($agentArr) && !empty($agentArr)) { $htmlAgent = ''; foreach ($agentArr as $singleAgent) { $crea_agent_table_name = $wpdb->prefix.ARETKCREA_AGENT_TABLE; $queryGetAgentName = "SELECT crea_agent_name FROM $crea_agent_table_name WHERE crea_agent_id='$singleAgent'"; $resultAgentArr = $wpdb->get_results($queryGetAgentName); if ( isset( $resultAgentArr ) && !empty( $resultAgentArr ) ) { $htmlAgent .= $resultAgentArr[0]->crea_agent_name . ', '; } } } $listingpagecount = 0; $getSubscriptionStatus = get_option('crea_subscription_status', ''); if( isset( $getSubscriptionStatus ) && !empty( $getSubscriptionStatus ) && $getSubscriptionStatus === 'valid' ) { $aretk_server_listing_id = get_post_meta($singleListing->ID,'aretk_server_listing_id',true); if( !empty( $aretk_server_listing_id ) && $aretk_server_listing_id !='' ) { $listingpageRecords = Aretk_Crea_Admin::aretkcrea_get_property_detail_page_result_for_exclusive($aretk_server_listing_id); if ( $listingpageRecords[0]->TotalRecords != 0 ){ $listingpagecount = isset( $listingpageRecords[1]->ViewCount ) ? $listingpageRecords[1]->ViewCount : 0; } else { $listingpagecount = 0; } } else{ $listingpagecount = 0; } } else { $listingpageval = get_post_meta($singleListing->ID,'crea_aretk_db_listing_page_count',true); if( !empty( $listingpageval ) && $listingpageval !='' ) { $listingpagecount = $listingpageval; } else { $listingpagecount = 0; } } $html .= ''; } else { $htmlAgent = ''; foreach ($singleListing->listing_agents as $singleAgent) { $htmlAgent .= $singleAgent->Name.', '; } if (is_object ($singleListing->listing_photos)) { if ($singleListing->listing_photos->URL == '' || $singleListing->listing_photos->URL == null) { $apiListingImageURL = ARETK_CREA_PLUGIN_URL.'admin/images/dummy_image.png'; } else { $apiListingImageURL = $singleListing->listing_photos->URL; } } else { $apiListingImageURL = ARETK_CREA_PLUGIN_URL.'admin/images/dummy_image.png'; } $mlsId = isset($singleListing->mlsID) ? $singleListing->mlsID : '-'; $dates = isset($singleListing->ListingContractDate) ? $singleListing->ListingContractDate : '-'; $listingpagecount = isset( $singleListing->ViewCount ) ? $singleListing->ViewCount : 0; $html .= ''; } } } $html .= '
'.__(ARETKCREA_ADD_LISTING_TABLE_PHOTO,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_MLS,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_ADDRESS,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_CITY,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_PRICE,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_AGENT_NAME,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_VIEWS,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_DATE,ARETKCREA_PLUGIN_SLUG).'
Exclusive Listing
Edit | Trash
'.$ListingAddress.' '.$ListingCity.' $'.$ListingPrice.' '.$htmlAgent.' '.$listingpagecount.' '.$date.'
'.$mlsId.' '.$singleListing->StreetAddress.' '.$singleListing->StreetNumber.' '.$singleListing->City.' $'.$singleListing->Price.' '.rtrim($htmlAgent,', ').' '.$listingpagecount.' '.$dates.'
'.__(ARETKCREA_ADD_LISTING_TABLE_PHOTO,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_MLS,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_ADDRESS,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_CITY,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_PRICE,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_AGENT_NAME,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_VIEWS,ARETKCREA_PLUGIN_SLUG).' '.__(ARETKCREA_ADD_LISTING_TABLE_DATE,ARETKCREA_PLUGIN_SLUG).'
'; echo $html; } die(); } /** * Function for deleting the album directory from uploads folder * @author Aretk Inc. * @package Aretk * @subpackage Phase 1 * */ public static function aretkcrea_deleteDirectory($dirPath) { if (is_dir($dirPath)) { $objects = scandir($dirPath); foreach ($objects as $object) { if ($object != "." && $object !="..") { if (filetype($dirPath . DIRECTORY_SEPARATOR . $object) == "dir") { aretkcrea_deleteDirectory($dirPath . DIRECTORY_SEPARATOR . $object); } else { unlink($dirPath . DIRECTORY_SEPARATOR . $object); } } } reset($objects); rmdir($dirPath); } } /** * This function will save/update the showcase settings * * @param null * @return null * @since Phase 1 */ public function aretkcrea_handle_create_new_showcase_form_action () { global $wpdb, $wp; # only proceed if postype is showcase if (isset($_POST['posttype'])&& $_POST['posttype'] == 'showcase') { // Showcase title $crea_showcase_title = isset($_POST['crea_showcase_title']) ? sanitize_text_field( $_POST['crea_showcase_title'] ) : ''; // Shocwase Display type $crea_showcase_display_theams_option = isset($_POST['crea_showcase_theams_option']) ? sanitize_text_field($_POST['crea_showcase_theams_option']) :'Listing View'; // showcase CREA feed $crea_feed_ddf_type = isset($_POST['crea_showcase_feed_ddf_option']) ? sanitize_text_field($_POST['crea_showcase_feed_ddf_option']) :''; // Include exclusive listings $crea_feed_include_exclude = isset($_POST['crea_showcase_inc_exc_listing_feed']) ? sanitize_text_field($_POST['crea_showcase_inc_exc_listing_feed']) :'no'; // Filter listings by date listed $crea_showcase_filter_by_other_day = isset($_POST['crea_showcase_filter_by_other_days']) ? sanitize_text_field($_POST['crea_showcase_filter_by_other_days']) :''; // Filter Open houses $crea_showcase_filter_inclue_open_house = isset($_POST['crea_checkbox_open_house_filter']) ? sanitize_text_field($_POST['crea_checkbox_open_house_filter']) :''; // Filter Price Min $showcase_filter_price_min = isset($_POST['showcase_filter_price_min']) ? sanitize_text_field($_POST['showcase_filter_price_min']) :''; // Filter Price Max $showcase_filter_price_max = isset($_POST['showcase_filter_price_max']) ? sanitize_text_field($_POST['showcase_filter_price_max']) :''; // Filter Property Types $showcase_filter_property_types = !empty($_POST['showcase_filter_property_types']) ? $_POST['showcase_filter_property_types'] : array(); $showcase_filter_property_types_results = implode(",",$showcase_filter_property_types); // Filter Listing Status $showcase_filter_property_status = !empty($_POST['showcase_filter_property_status']) ? $_POST['showcase_filter_property_status'] : array(); $showcase_filter_property_status_results = implode(",",$showcase_filter_property_status); // Filter Brokerage $crea_filter_brokerage = isset($_POST['crea_filter_brokerage']) ? $_POST['crea_filter_brokerage'] : array(); $crea_filter_brokerage_results = implode(",",$crea_filter_brokerage); // Filter Office $crea_filter_office = isset($_POST['crea_filter_office']) ? $_POST['crea_filter_office'] :array(); $crea_filter_office_results = implode(",",$crea_filter_office); // Filter Agents method 1 $crea_filter_agent_name = isset($_POST['crea_filter_agent_name']) ? $_POST['crea_filter_agent_name'] :array(); $crea_filter_agent_name_results = implode(",",$crea_filter_agent_name); // Filter Agents method 2 $showcase_filter_listing_agent_ids = !empty($_POST['showcase_filter_listing_agent_ids']) ? $_POST['showcase_filter_listing_agent_ids'] : array(); $showcase_filter_listing_agent_ids_results = implode(",",$showcase_filter_listing_agent_ids); //------------------------ // Filter map settings $crea_showcase_filter_by_map_km = isset($_POST['crea_filter_by_map_km']) ? sanitize_text_field($_POST['crea_filter_by_map_km']) :''; if ( isset($_POST['showcase_filter_google_map_zoom']) && is_numeric($_POST['showcase_filter_google_map_zoom']) && $_POST['showcase_filter_google_map_zoom'] !== '0' ){ $showcse_crea_filter_google_map_zoom = sanitize_text_field($_POST['showcase_filter_google_map_zoom']); } else { $showcse_crea_filter_google_map_zoom = ''; } $crea_filter_google_map_latitude = isset($_POST['crea_filter_google_map_latitude']) ? sanitize_text_field($_POST['crea_filter_google_map_latitude']) :''; $crea_filter_google_map_longitude = isset($_POST['crea_filter_google_map_longitude']) ? sanitize_text_field($_POST['crea_filter_google_map_longitude']) :''; // End Map Settings //------------------------ //------------------------------------- $crea_filter_brokerage_hidden_name = isset($_POST['crea_filter_brokerage_hidden_name']) ? $_POST['crea_filter_brokerage_hidden_name'] :""; $crea_showcse_office_filter_hidden_name = isset($_POST['crea_showcse_office_filter_hidden_name']) ? $_POST['crea_showcse_office_filter_hidden_name'] :""; $crea_showcse_agent_name_filter_hidden_name = isset($_POST['crea_showcse_agent_name_filter_hidden_name']) ? $_POST['crea_showcse_agent_name_filter_hidden_name'] :""; $crea_filter_listing = isset($_POST['crea_filter_listing']) ? sanitize_text_field($_POST['crea_filter_listing']) :''; //------------------------------------- //======================================== // Display Settings // create Serializable settings array $Serializable_listing_array = array(); $Serializable_grid_array = array(); $Serializable_carousel_array = array(); $Serializable_map_array = array(); $Serializable_slider_array = array(); if( $crea_showcase_display_theams_option == "Listing View" ) { $crea_sorting_showcase_name = isset($_POST['crea_sorting_listing_showcase_name']) ? sanitize_text_field($_POST['crea_sorting_listing_showcase_name']) :''; $listing_view_setiing = isset($_POST['listing_view_setiing']) ? sanitize_text_field($_POST['listing_view_setiing']) :''; $listing_search_position = isset($_POST['listing_search_position']) ? sanitize_text_field($_POST['listing_search_position']) :''; $listing_view_top = isset($_POST['listing_view_top']) ? sanitize_text_field( $_POST['listing_view_top']) :''; $listing_view_right = isset($_POST['listing_view_right']) ? sanitize_text_field($_POST['listing_view_right']) :''; $Max_listings_on_a_page = isset($_POST['Max_listings_on_a_page']) ? sanitize_text_field($_POST['Max_listings_on_a_page']) :''; $Listing_search_simple_enable_or_disable = isset($_POST['listing_view_setiing_status_of_search']) ? sanitize_text_field($_POST['listing_view_setiing_status_of_search']) :''; $listing_view_open_house_or_not = isset($_POST['listing_view_setiing_open_house']) ? sanitize_text_field($_POST['listing_view_setiing_open_house']) :''; $listing_view_status_or_not = isset($_POST['listing_view_setiing_status']) ? sanitize_text_field($_POST['listing_view_setiing_status']) :''; $Serializable_listing_array = array( "listingshowcasename" =>$crea_sorting_showcase_name, "listingviewsearchbar" =>$listing_view_setiing, "listingsearchposition" =>$listing_search_position, "listingviewtop" =>$listing_view_top, "listingviewright" =>$listing_view_right, "maxlistingonpage" =>$Max_listings_on_a_page, "listingopenhouse" =>$listing_view_open_house_or_not, "listingstatus" =>$listing_view_status_or_not , "Listing_search_simple_enable_or_disable"=>$Listing_search_simple_enable_or_disable ); } if( $crea_showcase_display_theams_option == "Grid View" ) { $crea_sorting_showcase_name = isset($_POST['crea_sorting_showcase_grid_name']) ? $_POST['crea_sorting_showcase_grid_name'] :''; $listing_view_setiing = isset($_POST['grid_search_view_setiing']) ? $_POST['grid_search_view_setiing'] :''; $listing_search_position = isset($_POST['listing_search_position']) ? $_POST['listing_search_position'] :''; $listing_view_top = isset($_POST['listing_view_top']) ? $_POST['listing_view_top'] :''; $listing_view_right = isset($_POST['listing_view_right']) ? $_POST['listing_view_right'] :''; $crea_max_grid_selected_row = isset($_POST['crea_max_grid_selected_row']) ? $_POST['crea_max_grid_selected_row'] :''; $crea_max_grid_selected_column = isset($_POST['crea_max_grid_selected_column']) ? $_POST['crea_max_grid_selected_column'] :''; $grid_view_open_house_or_not = isset($_POST['grid_view_setiing_open_house']) ? $_POST['grid_view_setiing_open_house'] :''; $grid_view_status_or_not = isset($_POST['grid_view_setiing_status']) ? $_POST['grid_view_setiing_status'] :''; $grid_view_setiing_status_search = isset($_POST['grid_view_setiing_status_search']) ? $_POST['grid_view_setiing_status_search'] :''; $Serializable_grid_array = array( "gridviewshowcasename"=>$crea_sorting_showcase_name, "gridviewsearchbar"=>$listing_view_setiing, "gridviewsearchpostion"=>$listing_search_position, "gridviewtop"=>$listing_view_top, "gridviewright"=>$listing_view_right, "maxgridviewselectedrow"=>$crea_max_grid_selected_row, "maxgridviewselectedcolumn"=>$crea_max_grid_selected_column, "gridviewopenhouse"=>$grid_view_open_house_or_not, "gridviewstatus"=>$grid_view_status_or_not , "grid_view_setiing_status_search_simple_or_datail"=>$grid_view_setiing_status_search ); } if( $crea_showcase_display_theams_option == "Carousel" ) { $crea_sorting_showcase_name = !empty($_POST['crea_sorting_showcase_carousel_name']) ? $_POST['crea_sorting_showcase_carousel_name'] :''; $listing_carousel_show_price = !empty($_POST['listing_carousel_show_price']) ? $_POST['listing_carousel_show_price'] :'yes'; $listing_carousel_show_status = !empty($_POST['listing_carousel_show_status']) ? $_POST['listing_carousel_show_status'] :'yesy'; $listing_carousel_show_open_house_info = !empty($_POST['listing_carousel_show_open_house_info']) ? $_POST['listing_carousel_show_open_house_info'] :'yes'; $crea_min_of_listing_carousel = !empty($_POST['crea_min_of_listing_carousel']) ? $_POST['crea_min_of_listing_carousel'] :'4'; $Max_of_listings_for_Carousel = !empty($_POST['Max_of_listings_for_Carousel']) ? $_POST['Max_of_listings_for_Carousel'] :'20'; $listing_carousel_display_prevnext = !empty($_POST['listing_carousel_display_prevnext']) ? $_POST['listing_carousel_display_prevnext'] :'false'; $listing_carousel_scroll_speed = !empty($_POST['listing_carousel_scroll_speed']) ? $_POST['listing_carousel_scroll_speed'] :'3000'; $listing_carousel_pagination_dots = !empty($_POST['listing_carousel_pagination_dots']) ? $_POST['listing_carousel_pagination_dots'] :'true'; $Serializable_carousel_array = array( "carouselshowcasename"=>$crea_sorting_showcase_name, "carouselshowcasenameprice"=>$listing_carousel_show_price, "carouselshowcasenamestatus"=>$listing_carousel_show_status, "carouselshowcasenameopenhouseinfo"=>$listing_carousel_show_open_house_info, "minlistingcarouselshowcasename"=>$crea_min_of_listing_carousel, "maxlistingcarouselshowcasename"=>$Max_of_listings_for_Carousel, "listing_carousel_display_prevnext"=>$listing_carousel_display_prevnext, "listing_carousel_scroll_speed"=>$listing_carousel_scroll_speed, "listing_carousel_pagination_dots"=>$listing_carousel_pagination_dots, ); } if( $crea_showcase_display_theams_option == "Map" ){ $map_search_bar_view = isset($_POST['map_search_view_setiing']) ? $_POST['map_search_view_setiing'] :''; $map_view_setiing_status_search = isset($_POST['map_view_setiing_status_search']) ? $_POST['map_view_setiing_status_search'] :''; $crea_showcase_google_map_latitude = isset($_POST['crea_showcase_google_map_latitude']) ? $_POST['crea_showcase_google_map_latitude'] :''; $crea_showcase_google_map_longitude = isset($_POST['crea_showcase_google_map_longitude']) ? $_POST['crea_showcase_google_map_longitude'] :''; $google_image_zoom = isset($_POST['google_image_zoom']) ? $_POST['google_image_zoom'] :'6'; $mapviewopenhouse_yes_or_not = isset($_POST['map_view_setiing_open_house']) ? $_POST['map_view_setiing_open_house'] :''; $mapviewstatus_yes_or_not = isset($_POST['map_view_setiing_status']) ? $_POST['map_view_setiing_status'] :''; $only_map_view_display_hight = isset($_POST['only_map_view_display_hight']) ? $_POST['only_map_view_display_hight'] :''; $Serializable_map_array = array( "mapfilterlatitude" => $crea_showcase_google_map_latitude, "mapfilterlongitude" => $crea_showcase_google_map_longitude, "showcasemapimagezoom" => $google_image_zoom, "mapopenhouse" => $mapviewopenhouse_yes_or_not, "mapstatus" => $mapviewstatus_yes_or_not, "mapviewdisplayhight" => $only_map_view_display_hight, "mapviewdisplaysearch" => $map_search_bar_view, "mapviewdisplaysearch_simple_or_detail" => $map_view_setiing_status_search, ); } if( $crea_showcase_display_theams_option == "Slider" ) { $crea_sorting_showcase_slider_display_name = isset($_POST['crea_sorting_showcase_slider_display_name']) ? $_POST['crea_sorting_showcase_slider_display_name'] :''; $listing_slider_show_price = isset($_POST['listing_slider_show_price']) ? $_POST['listing_slider_show_price'] :'no'; $listing_slider_show_status = isset($_POST['listing_slider_show_status']) ? $_POST['listing_slider_show_status'] :'no'; $listing_slider_show_open_house_info = isset($_POST['listing_slider_show_open_house_info']) ? $_POST['listing_slider_show_open_house_info'] :'no'; $min_of_listing_slider = isset($_POST['min_of_listing_slider']) ? $_POST['min_of_listing_slider'] :''; $max_of_listings_for_slider = isset($_POST['max_of_listings_for_slider']) ? $_POST['max_of_listings_for_slider'] :''; $Serializable_slider_array = array( "sildersortingshowcasename"=> $crea_sorting_showcase_slider_display_name, "slidershowcaseshowprice"=> $listing_slider_show_price, "slidershowcaseshowstatus"=> $listing_slider_show_status, "slidershowcaseopenhouseinfo"=> $listing_slider_show_open_house_info, "minslidershowcaselisting"=> $min_of_listing_slider, "maxslidershowcaselisting"=> $max_of_listings_for_slider, ); } // End Display Settings //======================================== //======================================== // Showcase color settings // list view color $crea_listing_showcase_text_color =''; $crea_listing_showcase_address_bar_color =''; $crea_listing_showcase_price_color =''; $crea_listing_showcase_status_color =''; $crea_listing_showcase_open_house_color =''; $crea_listing_view_color_array = array(); if( $crea_showcase_display_theams_option == "Listing View" ) { $crea_listing_showcase_text_color = isset($_POST['crea_listing_showcase_text_color']) ? $_POST['crea_listing_showcase_text_color'] : ''; $crea_listing_showcase_address_bar_color = isset($_POST['crea_listing_showcase_address_bar_color']) ? $_POST['crea_listing_showcase_address_bar_color'] : ''; $crea_listing_showcase_price_color = isset($_POST['crea_listing_showcase_price_color']) ? $_POST['crea_listing_showcase_price_color'] : ''; $crea_listing_showcase_status_color = isset($_POST['crea_listing_showcase_status_color']) ? $_POST['crea_listing_showcase_status_color'] : ''; $crea_listing_showcase_open_house_color = isset($_POST['crea_listing_showcase_open_house_color']) ? $_POST['crea_listing_showcase_open_house_color'] : ''; $crea_listing_showcase_status_text_color = isset($_POST['crea_listing_showcase_status_text_color']) ? $_POST['crea_listing_showcase_status_text_color'] : ''; $crea_listing_showcase_open_house_text_color = isset($_POST['crea_listing_showcase_open_house_text_color']) ? $_POST['crea_listing_showcase_open_house_text_color'] : ''; $crea_listing_showcase_pagination_color = isset($_POST['crea_listing_showcase_pagination_color']) ? $_POST['crea_listing_showcase_pagination_color'] : ''; $crea_listing_showcase_pagination_text_color = isset($_POST['crea_listing_showcase_pagination_text_color']) ? $_POST['crea_listing_showcase_pagination_text_color'] : ''; $crea_listing_view_color_array = array( "listingShowcaseTextColor"=>$crea_listing_showcase_text_color, "listingShowcaseAddressBarColor"=>$crea_listing_showcase_address_bar_color, "listingShowcasePriceColor"=>$crea_listing_showcase_price_color, "listingShowcaseStatusColor"=>$crea_listing_showcase_status_color, "listingShowcaseOpenHouseColor"=>$crea_listing_showcase_open_house_color, "listingShowcaseOpenHouseTextColor"=>$crea_listing_showcase_open_house_text_color, "listingShowcaseStatusTextColor"=>$crea_listing_showcase_status_text_color, "listingShowcasepaginationColor"=>$crea_listing_showcase_pagination_color, "listingShowcasepaginationtextColor"=>$crea_listing_showcase_pagination_text_color, ); } // Grid view color $crea_grid_showcase_text_color = ''; $crea_grid_showcase_text_bgcolor = ''; $crea_grid_showcase_oh_color_txt = ''; $crea_grid_showcase_oh_color_bg = ''; $crea_showcase_status_box_text_color = ''; $crea_showcase_status_box_color = ''; $crea_showcase_pagination_text_color = ''; $crea_showcase_pagination_color = ''; $crea_grid_view_color_array = array(); if( $crea_showcase_display_theams_option == "Grid View" ) { $crea_grid_showcase_text_color = isset($_POST['crea_grid_showcase_text_color']) ? $_POST['crea_grid_showcase_text_color'] : ''; $crea_grid_showcase_text_bgcolor = isset($_POST['crea_grid_showcase_text_bgcolor']) ? $_POST['crea_grid_showcase_text_bgcolor'] : ''; $crea_grid_showcase_oh_color_txt = isset($_POST['crea_grid_showcase_oh_color_txt']) ? $_POST['crea_grid_showcase_oh_color_txt'] : ''; $crea_grid_showcase_oh_color_bg = isset($_POST['crea_grid_showcase_oh_color_bg']) ? $_POST['crea_grid_showcase_oh_color_bg'] : ''; $crea_showcase_status_box_text_color = isset($_POST['crea_showcase_status_box_text_color']) ? $_POST['crea_showcase_status_box_text_color'] : ''; $crea_showcase_status_box_color = isset($_POST['crea_showcase_status_box_color']) ? $_POST['crea_showcase_status_box_color'] : ''; $crea_showcase_pagination_text_color = isset($_POST['crea_showcase_status_pagination_gird_text_color']) ? $_POST['crea_showcase_status_pagination_gird_text_color'] : ''; $crea_showcase_pagination_color = isset($_POST['crea_showcase_status_pagination_gird_color']) ? $_POST['crea_showcase_status_pagination_gird_color'] : ''; $crea_grid_view_color_array = array( "gridShowcaseTextColor" => $crea_grid_showcase_text_color, "gridShowcase_TextBgColor" => $crea_grid_showcase_text_bgcolor, "gridShowcase_oh_color_txt" => $crea_grid_showcase_oh_color_txt, "gridShowcase_oh_color_bg" => $crea_grid_showcase_oh_color_bg, "gridShowcaseStatusBoxTextColor" => $crea_showcase_status_box_text_color, "gridShowcaseStatusBoxColor" => $crea_showcase_status_box_color, "gridShowcasePaginationColor" => $crea_showcase_pagination_color, "gridShowcasePaginationTextColor" => $crea_showcase_pagination_text_color, ); } // Carousel view color $crea_carousel_showcase_text_color =''; $crea_carousel_showcase_background_color =''; $crea_carousel_showcase_oh_color_txt = ''; $crea_carousel_showcase_oh_color_bg = ''; $crea_carousel_view_color_array = array(); if( $crea_showcase_display_theams_option == "Carousel" ) { $crea_carousel_showcase_text_color = isset($_POST['crea_carousel_showcase_text_color']) ? $_POST['crea_carousel_showcase_text_color'] : ''; $crea_carousel_showcase_background_color = isset($_POST['crea_carousel_showcase_background_color']) ? $_POST['crea_carousel_showcase_background_color'] : ''; $crea_carousel_showcase_oh_color_txt = isset($_POST['crea_carousel_showcase_oh_color_txt']) ? $_POST['crea_carousel_showcase_oh_color_txt'] : ''; $crea_carousel_showcase_oh_color_bg = isset($_POST['crea_carousel_showcase_oh_color_bg']) ? $_POST['crea_carousel_showcase_oh_color_bg'] : ''; $crea_carousel_view_color_array = array( "carouselShowcaseTextColor"=>$crea_carousel_showcase_text_color, "carouselShowcaseBackgroundColor"=>$crea_carousel_showcase_background_color, "crea_carousel_showcase_oh_color_txt"=>$crea_carousel_showcase_oh_color_txt, "crea_carousel_showcase_oh_color_bg"=>$crea_carousel_showcase_oh_color_bg ); } // Map view color $crea_map_showcase_text_color =''; $crea_map_showcase_button_color =''; $crea_map_showcase_reset_button_color =''; $crea_map_showcase_listing_hover_color =''; $crea_map_showcase_top_picture_color =''; $crea_map_view_color_array = array(); if( $crea_showcase_display_theams_option == "Map" ) { $crea_map_showcase_text_color = isset($_POST['crea_map_showcase_text_color']) ? $_POST['crea_map_showcase_text_color'] : ''; $crea_map_showcase_button_color = isset($_POST['crea_map_showcase_button_color']) ? $_POST['crea_map_showcase_button_color'] : ''; $crea_map_showcase_reset_button_color = isset($_POST['crea_map_showcase_reset_button_color']) ? $_POST['crea_map_showcase_reset_button_color'] : ''; $crea_map_showcase_listing_hover_color = isset($_POST['crea_map_showcase_listing_hover_color']) ? $_POST['crea_map_showcase_listing_hover_color'] : ''; $crea_map_showcase_top_picture_color = isset($_POST['crea_map_showcase_top_picture_color']) ? $_POST['crea_map_showcase_top_picture_color'] : ''; $crea_map_showcase_top_picture_text_color = isset($_POST['crea_map_showcase_top_picture_text_color']) ? $_POST['crea_map_showcase_top_picture_text_color'] : ''; $crea_map_showcase_price_color = isset($_POST['crea_map_showcase_price_color']) ? $_POST['crea_map_showcase_price_color'] : ''; $crea_map_showcase_price_text_color = isset($_POST['crea_map_showcase_price_text_color']) ? $_POST['crea_map_showcase_price_text_color'] : ''; $crea_map_view_color_array = array( "mapShowcaseTextColor"=>$crea_map_showcase_text_color, "mapShowcaseButtonColor"=>$crea_map_showcase_button_color, "mapShowcaseResetButtonColor"=>$crea_map_showcase_reset_button_color, "mapShowcaseListingHoverColor"=>$crea_map_showcase_listing_hover_color, "mapShowcaseTopPictureColor"=>$crea_map_showcase_top_picture_color, "mapShowcaseTopPictureTextColor"=>$crea_map_showcase_top_picture_text_color, "mapShowcasePriceColor"=>$crea_map_showcase_price_color, "mapShowcasePriceTextColor"=>$crea_map_showcase_price_text_color ); } // crea showcase slider view color $crea_slider_showcase_text_color =''; $crea_slider_showcase_tab_button_color =''; $crea_slider_showcase_more_info_button_color =''; $crea_slider_view_color_array = array(); if( $crea_showcase_display_theams_option == "Slider" ) { $crea_slider_showcase_text_color = isset($_POST['crea_slider_showcase_text_color']) ? $_POST['crea_slider_showcase_text_color'] : ''; $crea_slider_showcase_tab_button_color = isset($_POST['crea_slider_showcase_tab_button_color']) ? $_POST['crea_slider_showcase_tab_button_color'] : ''; $crea_slider_showcase_more_info_button_color = isset($_POST['crea_slider_showcase_more_info_button_color']) ? $_POST['crea_slider_showcase_more_info_button_color'] : ''; $crea_slider_showcase_oh_color_txt = isset($_POST['crea_slider_showcase_oh_color_txt']) ? $_POST['crea_slider_showcase_oh_color_txt'] : ''; $crea_slider_showcase_oh_color_bg = isset($_POST['crea_slider_showcase_oh_color_bg']) ? $_POST['crea_slider_showcase_oh_color_bg'] : ''; $crea_slider_view_color_array = array( "sliderShowcaseTextColor"=>$crea_slider_showcase_text_color, "sliderShowcaseTabBtnColor"=>$crea_slider_showcase_tab_button_color, "sliderShowcaseMoreInfoBtnColor"=>$crea_slider_showcase_more_info_button_color, "crea_slider_showcase_oh_color_txt"=>$crea_slider_showcase_oh_color_txt, "crea_slider_showcase_oh_color_bg"=>$crea_slider_showcase_oh_color_bg ); } // END Showcase color settings //======================================== //======================================== // save new showcase settings if( $_POST['action-which'] == "add" && $_POST['posttype'] == "showcase" ) { if( empty($crea_showcase_title) || $crea_showcase_title == '' ) { $crea_showcase_title = 'No title ['. sprintf('%04d', rand(0, 99999)) .']'; } $new_showcase_args = array( 'post_title' => $crea_showcase_title, 'post_content' => '', 'category_name' => '', 'post_status' => 'publish', 'post_type' => 'aretk_showcase' ); $import_showcase_post_id = wp_insert_post($new_showcase_args); update_post_meta($import_showcase_post_id,'showcse_crea_feed_ddf_type',maybe_serialize($crea_feed_ddf_type)); update_post_meta($import_showcase_post_id,'showcse_crea_feed_include_exclude',maybe_serialize($crea_feed_include_exclude)); update_post_meta($import_showcase_post_id,'showcse_crea_display_theams_option',maybe_serialize($crea_showcase_display_theams_option)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_brokerage',maybe_serialize($crea_filter_brokerage_results)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_office',maybe_serialize($crea_filter_office_results)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_agent_name',maybe_serialize($crea_filter_agent_name_results)); update_post_meta($import_showcase_post_id,'showcase_filter_listing_agent_ids',maybe_serialize($showcase_filter_listing_agent_ids_results)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_brokerage_hidden_name',maybe_serialize($crea_filter_brokerage_hidden_name)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_office_hidden_name',maybe_serialize($crea_showcse_office_filter_hidden_name)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_agents_hidden_name',maybe_serialize($crea_showcse_agent_name_filter_hidden_name)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_listing',maybe_serialize($crea_filter_listing)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_by_map_km',maybe_serialize($crea_showcase_filter_by_map_km)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_by_other_day',maybe_serialize($crea_showcase_filter_by_other_day)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_inclue_open_house',maybe_serialize($crea_showcase_filter_inclue_open_house)); update_post_meta($import_showcase_post_id,'showcse_filter_price_min',maybe_serialize($showcase_filter_price_min)); update_post_meta($import_showcase_post_id,'showcse_filter_price_max',maybe_serialize($showcase_filter_price_max)); update_post_meta($import_showcase_post_id,'showcase_filter_property_types',maybe_serialize($showcase_filter_property_types_results)); update_post_meta($import_showcase_post_id,'showcase_filter_property_status',maybe_serialize($showcase_filter_property_status_results)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_google_map_latitude',maybe_serialize($crea_filter_google_map_latitude)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_google_map_longitude',maybe_serialize($crea_filter_google_map_longitude)); update_post_meta($import_showcase_post_id,'showcse_crea_filter_google_map_zoom',maybe_serialize($showcse_crea_filter_google_map_zoom)); update_post_meta($import_showcase_post_id,'showcse_crea_serializable_listing_array',maybe_serialize($Serializable_listing_array)); update_post_meta($import_showcase_post_id,'showcse_crea_serializable_grid_array',maybe_serialize($Serializable_grid_array)); update_post_meta($import_showcase_post_id,'showcse_crea_serializable_carousel_array',maybe_serialize($Serializable_carousel_array)); update_post_meta($import_showcase_post_id,'showcse_crea_serializable_map_array',maybe_serialize($Serializable_map_array)); update_post_meta($import_showcase_post_id,'showcse_crea_serializable_slider_array',maybe_serialize($Serializable_slider_array)); update_post_meta($import_showcase_post_id,'Showcase_crea_listing_view_color_array',maybe_serialize($crea_listing_view_color_array)); update_post_meta($import_showcase_post_id,'Showcase_crea_grid_view_color_array',maybe_serialize($crea_grid_view_color_array)); update_post_meta($import_showcase_post_id,'Showcase_crea_carousel_view_color_array',maybe_serialize($crea_carousel_view_color_array)); update_post_meta($import_showcase_post_id,'Showcase_crea_map_view_color_array',maybe_serialize($crea_map_view_color_array)); update_post_meta($import_showcase_post_id,'Showcase_crea_slider_view_color_array',maybe_serialize($crea_slider_view_color_array)); update_post_meta($import_showcase_post_id,'showcse_crea_save_short_code',maybe_serialize("[ARETK-LS-$import_showcase_post_id ls_id=$import_showcase_post_id]")); wp_set_object_terms($import_showcase_post_id, 'listing-details-showcase', 'listing-showcase', true); wp_safe_redirect(site_url("/wp-admin/admin.php?page=create_new_showcase&showcase_id=$import_showcase_post_id#crea_showcase_save_tab")); } // Update showcase settings elseif ( $_POST['action-which'] == "edit" && $_POST['posttype'] == "showcase" ) { $showcase_ids = isset($_POST['showcase_ids']) ? $_POST['showcase_ids'] : ''; $update_showcase_post = array('ID' => $showcase_ids,'post_title'=> $crea_showcase_title); wp_update_post( $update_showcase_post ); update_post_meta($showcase_ids,'showcse_crea_feed_ddf_type',maybe_serialize($crea_feed_ddf_type)); update_post_meta($showcase_ids,'showcse_crea_feed_include_exclude',maybe_serialize($crea_feed_include_exclude)); update_post_meta($showcase_ids,'showcse_crea_display_theams_option',maybe_serialize($crea_showcase_display_theams_option)); update_post_meta($showcase_ids,'showcse_crea_filter_brokerage',maybe_serialize($crea_filter_brokerage_results)); update_post_meta($showcase_ids,'showcse_crea_filter_office',maybe_serialize($crea_filter_office_results)); update_post_meta($showcase_ids,'showcse_crea_filter_agent_name',maybe_serialize($crea_filter_agent_name_results)); update_post_meta($showcase_ids,'showcase_filter_listing_agent_ids',maybe_serialize($showcase_filter_listing_agent_ids_results)); update_post_meta($showcase_ids,'showcse_crea_filter_brokerage_hidden_name',maybe_serialize($crea_filter_brokerage_hidden_name)); update_post_meta($showcase_ids,'showcse_crea_filter_office_hidden_name',maybe_serialize($crea_showcse_office_filter_hidden_name)); update_post_meta($showcase_ids,'showcse_crea_filter_agents_hidden_name',maybe_serialize($crea_showcse_agent_name_filter_hidden_name)); update_post_meta($showcase_ids,'showcse_crea_filter_listing',maybe_serialize($crea_filter_listing)); update_post_meta($showcase_ids,'showcse_crea_filter_by_map_km',maybe_serialize($crea_showcase_filter_by_map_km)); update_post_meta($showcase_ids,'showcse_crea_filter_by_other_day',maybe_serialize($crea_showcase_filter_by_other_day)); update_post_meta($showcase_ids,'showcse_crea_filter_inclue_open_house',maybe_serialize($crea_showcase_filter_inclue_open_house)); update_post_meta($showcase_ids,'showcse_filter_price_min',maybe_serialize($showcase_filter_price_min)); update_post_meta($showcase_ids,'showcse_filter_price_max',maybe_serialize($showcase_filter_price_max)); update_post_meta($showcase_ids,'showcase_filter_property_types',maybe_serialize($showcase_filter_property_types_results)); update_post_meta($showcase_ids,'showcase_filter_property_status',maybe_serialize($showcase_filter_property_status_results)); update_post_meta($showcase_ids,'showcse_crea_filter_google_map_latitude',maybe_serialize($crea_filter_google_map_latitude)); update_post_meta($showcase_ids,'showcse_crea_filter_google_map_longitude',maybe_serialize($crea_filter_google_map_longitude)); update_post_meta($showcase_ids,'showcse_crea_filter_google_map_zoom',maybe_serialize($showcse_crea_filter_google_map_zoom)); update_post_meta($showcase_ids,'mapfilterlat_sw',maybe_serialize($crea_showcase_google_mapbound_lat_sw)); update_post_meta($showcase_ids,'mapfilterlong_sw',maybe_serialize($crea_showcase_google_mapbound_lng_sw)); update_post_meta($showcase_ids,'mapfilterlat_ne',maybe_serialize($crea_showcase_google_mapbound_lat_ne)); update_post_meta($showcase_ids,'mapfilterlong_ne',maybe_serialize($crea_showcase_google_mapbound_lng_ne)); update_post_meta($showcase_ids,'showcse_crea_serializable_listing_array',maybe_serialize($Serializable_listing_array)); update_post_meta($showcase_ids,'showcse_crea_serializable_grid_array',maybe_serialize($Serializable_grid_array)); update_post_meta($showcase_ids,'showcse_crea_serializable_carousel_array',maybe_serialize($Serializable_carousel_array)); update_post_meta($showcase_ids,'showcse_crea_serializable_map_array',maybe_serialize($Serializable_map_array)); update_post_meta($showcase_ids,'showcse_crea_serializable_slider_array',maybe_serialize($Serializable_slider_array)); update_post_meta($showcase_ids,'Showcase_crea_listing_view_color_array',maybe_serialize($crea_listing_view_color_array)); update_post_meta($showcase_ids,'Showcase_crea_grid_view_color_array',maybe_serialize($crea_grid_view_color_array)); update_post_meta($showcase_ids,'Showcase_crea_carousel_view_color_array',maybe_serialize($crea_carousel_view_color_array)); update_post_meta($showcase_ids,'Showcase_crea_map_view_color_array',maybe_serialize($crea_map_view_color_array)); update_post_meta($showcase_ids,'Showcase_crea_slider_view_color_array',maybe_serialize($crea_slider_view_color_array)); wp_set_object_terms($showcase_ids, 'listing-details-showcase', 'listing-showcase', true); wp_safe_redirect(site_url("/wp-admin/admin.php?page=create_new_showcase&showcase_id=$showcase_ids#crea_showcase_save_tab")); } # END save showcase settings //======================================== } } // END Function aretkcrea_handle_create_new_showcase_form_action //******************************************************** /** * Function for aretkcrea_delete_showcase_custom_post_records * * @return return showcase post records * */ function aretkcrea_delete_showcase_custom_post_records() { global $wpdb; $showcase_id = isset($_POST['showcase_id']) ? $_POST['showcase_id'] : ''; if ( $showcase_id != '' && !empty($showcase_id) || $showcase_id != 0 ) { $post_table = $wpdb->prefix.'posts'; $post_meta_table = $wpdb->prefix.'postmeta'; $delete_recod = $wpdb->query( "DELETE FROM $post_table WHERE `ID` = $showcase_id" ); $delete_recod = $wpdb->query( "DELETE FROM $post_meta_table WHERE `post_id` = $showcase_id" ); echo"sucessfullydelete"; } die(); } /** * Function for create custom post type lead column name * * @param unknown_type $columns * @param unknown_type $defaults * @return return coulum name of lead post type * */ function aretkcrea_set_custom_edit_aretk_lead_columns($columns) { $getSubscriptionLeadcolumn = get_option('crea_subscription_status', true); if( isset( $getSubscriptionLeadcolumn ) && !empty( $getSubscriptionLeadcolumn ) && $getSubscriptionLeadcolumn === 'valid' ) { $columns = array( 'cb' => '', 'title' => __( 'Name' ), 'email' => __( 'Email' ), 'Phone_no' => __( 'Phone No' ) , 'Agent Name' =>__('Agent Name'), 'date' => __( 'Date' ), 'post_modified_date' => __( 'Modified Date' ), ); } else { $columns = array( 'cb' => '', 'title' => __( 'Name' ), 'email' => __( 'Email' ), 'Phone_no' => __( 'Phone No' ) , 'date' => __( 'Date' ), 'post_modified_date' => __( 'Modified Date' ), ); } return $columns; } function aretkcrea_custom_aretk_lead_sortable( $columns ) { $columns['post_modified_date'] = 'post_modified'; return $columns; } /** * Function for create custom post type content * * @param unknown_type $column_name * @param unknown_type $post_ID * @return return coulum content of lead post type * */ function aretkcrea_set_custom_edit_aretk_lead_content( $column_name, $post_ID ) { global $wpdb; if($column_name == 'email' ) { $Lead_email_primary = get_post_meta($post_ID,'lead_primary_email',$single = false); $Email_name= implode(" ",$Lead_email_primary); if( isset( $Email_name ) && !empty($Email_name) ) { echo $Email_name; } else { $Lead_email = get_post_meta($post_ID,'lead_phone_email',$single = false); if( isset($Lead_email ) && !empty( $Lead_email )) { $email_not_primary = implode(" ",$Lead_email); $lead_email_title = maybe_unserialize($email_not_primary); if( is_array($lead_email_title )) { echo $lead_email_title[0]; } else { echo $lead_email_title; } } else { echo ' - '; } } } if($column_name == 'Phone_no' ) { $phone_no = get_post_meta($post_ID,'lead_phone_no',$single = false); if(isset( $phone_no ) && !empty( $phone_no )){ if( is_array( $phone_no )){ $Lead_phone = implode(" ",$phone_no); $var1 = maybe_unserialize($Lead_phone); if( is_array($var1)) { echo $var1[0]['PhoneNo']; } else{ echo $var1; } } } else { echo " - "; } } if($column_name == 'Agent Name') { $crea_listingAgentId = get_post_meta($post_ID, 'crea_agent_id', true); $agents_id = maybe_serialize($crea_listingAgentId); $agents_name = json_decode($agents_id, true); if( isset( $agents_name) && !empty( $agents_name)) { $listing_agents_name = $agents_name; $listing_detail_agents_name = ''; $post_meta_table = $wpdb->prefix.'crea_agent'; if( isset($listing_agents_name) && !empty( $listing_agents_name ) ) { $get_agent_ids = $wpdb->get_results("SELECT `crea_agent_id` ,`crea_agent_name` FROM $post_meta_table where crea_agent_id = $listing_agents_name"); foreach ( $get_agent_ids as $listing_get_agents_name ) { $listing_detail_agents_name = $listing_get_agents_name->crea_agent_name; } } echo $listing_detail_agents_name ; } else { echo " - "; } } if($column_name == 'post_modified_date') { $ptest = get_posts($post_ID); echo "Modified

".get_the_modified_date('Y/m/d ')."

"; } } /** * Function for create emport functionality * * @return return download link message. * */ function aretkcrea_emport_lead_download () { global $post, $wpdb; $data_array = array('Name','Email Address','Phone Number','Comment'); $uploadDirr = WP_CONTENT_DIR.'/uploads/'; if (!file_exists($uploadDirr)) { if (!mkdir($uploadDirr, 0777, true)){ echo "

Failed to create uploads folders.Please create uploads folder.

"; die(); } } $date = 'lead-export'; $excel = new ExcelWriter(WP_CONTENT_DIR."/uploads/$date.xls"); if($excel==false) echo $excel->error; $excel->writeLine($data_array); $post_table = $wpdb->prefix.'posts'; $query = "SELECT * from $post_table where post_type ='aretk_lead'"; $customer_orders = $wpdb->get_results($query); $i = 1; foreach ($customer_orders as $customer_order) { echo $excel->error; $id = $customer_order->ID; $Lead_email_primary = get_post_meta($id,'lead_primary_email',$single = false); $Email_name= implode(" ",$Lead_email_primary); if( isset( $Email_name ) && !empty($Email_name) ) { $lead_eamil_results = $Email_name; } else { $Lead_email = get_post_meta($id,'lead_phone_email',$single = false); if( isset($Lead_email ) && !empty( $Lead_email )) { $email_not_primary = implode(" ",$Lead_email); $lead_email_title = maybe_unserialize($email_not_primary); if( is_array( $lead_email_title )) { $lead_eamil_results = $lead_email_title[0]; } else { $lead_eamil_results = $lead_email_title; } } else { $lead_eamil_results = ''; } } $phone_no = get_post_meta($id,'lead_phone_no',$single = false); if(isset( $phone_no ) && !empty( $phone_no )){ if( is_array( $phone_no )){ $Lead_phone = implode(" ",$phone_no); $var1 = maybe_unserialize($Lead_phone); if( is_array($var1)) { $lead_phone_result = $var1[0]['PhoneNo']; } else{ $lead_phone_result = $var1; } } } else { $lead_phone_result = " - "; } $lead_post_title = $customer_order->post_content; $excel->writeLine(array( $customer_order->post_title,$lead_eamil_results ,$lead_phone_result,$lead_post_title) ); echo $excel->error; $i++; } $excel->close(); $upload_dir = wp_upload_dir(); $downloadpath = $upload_dir['baseurl']."/$date.xls"; echo "

Click here for download .xls file

"; die(); } /** * Unlink Document * */ function aretkcrea_unlink_listing_document_edit_page_from_listing_ajax() { $parent_document = isset( $_POST['inputfilename'] ) ? $_POST['inputfilename'] : ''; $documentfile = $_FILES; $tempLocPath = ''; foreach ( $documentfile as $documentfileKey=>$documentfileValue ) { if( $documentfileValue['name'] == $parent_document ) { $tempLocPath = $documentfileValue['tmp_name']; } } $imagefile = isset( $_POST['inputfilename'] ) ? $_POST['inputfilename'] : ''; $imagepath = "Users/mp4_thumbnails-".$imagefile; unlink($imagepath); if( unlink($tempLocPath) ) { echo 'Success'; $fileArr = array(); $doc_counter =0; foreach ($documentfile as $documentfileKey=>$documentfileValue ){ if( $documentfileValue['tmp_name'] != $tempLocPath ) { $fileArr[$doc_counter] = array( 'error'=>$documentfileValue['error'], 'name'=>$documentfileValue['name'], 'size'=>$documentfileValue['size'], 'tmp_name'=>$documentfileValue['tmp_name'], 'type'=>$documentfileValue['type'], ); $doc_counter = $doc_counter + 1; } } } else { echo 'Fail'; } die(); } /** * Function for add new lead reminder * @package Aretk * @subpackage Phase 1 * @return add lead reminder record */ function aretkcrea_add_new_lead_reminder() { global $wpdb; $get_lead_id = isset($_POST['get_lead_id'])? $_POST['get_lead_id']:''; $reminderName = isset($_POST['reminderName'])? sanitize_text_field ( $_POST['reminderName'] ) :''; $reminderSubject = isset($_POST['reminderSubject'])? sanitize_text_field ( $_POST['reminderSubject'] ) :''; $reminderEmail = isset($_POST['reminderEmail'])? sanitize_email ( $_POST['reminderEmail'] ) :''; $reminderComment = isset($_POST['reminderComment'])? sanitize_text_field ( $_POST['reminderComment'] ) :''; $reminderDateTime = isset($_POST['reminderDateTime'])?$_POST['reminderDateTime']:''; $reminderRepeat = isset($_POST['reminderRepeat'])?$_POST['reminderRepeat']:''; $reminderTableName = $wpdb->prefix.ARETKCREA_LEAD_REMINDER_HISTORY; $wpdb->insert( "$reminderTableName", array('reminder_lead_id' => $get_lead_id,'reminder_name' => $reminderName,'reminder_subject' => $reminderSubject,'reminder_email' => $reminderEmail,'reminder_comment' => $reminderComment,'reminder_time' => $reminderDateTime,'reminder_repeat' => $reminderRepeat,'created_time' => current_time('mysql', 1),'updated_time' => current_time('mysql', 1),), array('%d','%s','%s','%s','%s','%s','%s','%s','%s',)); $html =''; $reminderQuery = "select * from $reminderTableName WHERE reminder_lead_id = $get_lead_id ORDER BY `id` ASC "; $getReminderResults = $wpdb->get_results($reminderQuery); if( !empty( $getReminderResults ) && $getReminderResults !='' ) { /*Start all lead reminder*/ $reminderCounter = 1; foreach ( $getReminderResults as $getReminderResultsValues) { $html .='
'; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .='

Email*

Subject*

Comment

Date and Time*

Repeat

'; // check reminder repeat values $norepleatcheckdValues =''; if( $getReminderResultsValues->reminder_repeat == 'no-repeat') { $norepleatcheckdValues = 'checked'; } else { $norepleatcheckdValues =''; } $dailycheckdValues =''; if( $getReminderResultsValues->reminder_repeat == 'daily') { $dailycheckdValues = 'checked'; } else { $dailycheckdValues =''; } $weeklycheckdValues =''; if( $getReminderResultsValues->reminder_repeat == 'weekly') { $weeklycheckdValues = 'checked'; } else { $weeklycheckdValues =''; } $monthlycheckdValues =''; if( $getReminderResultsValues->reminder_repeat == 'monthly') { $monthlycheckdValues = 'checked'; } else { $monthlycheckdValues =''; } $yearlycheckdValues =''; if( $getReminderResultsValues->reminder_repeat == 'yearly') { $yearlycheckdValues = 'checked'; } else { $yearlycheckdValues =''; } $html .='No Repeat
'; $html .='Daily
'; $html .='Weekly
'; $html .='Monthly
'; $html .='Yearly
'; $html .='
'; $html .='
'; $html .='Update'; $html .='Remove Reminder'; $html .=''; $html .=''; $html .='
'; $html .='
'; $reminderCounter = $reminderCounter +1; } } echo $html; die(); } /** * Function for update lead reminder * @package Aretk * @subpackage Phase 1 * @return update lead reminder record */ function aretkcrea_update_crea_lead_reminder () { global $wpdb; $hiddenReminderValue = isset( $_POST['hiddenReminderValue'] ) ? $_POST['hiddenReminderValue'] :''; $hiddenReminderTableValue = isset( $_POST['hiddenReminderTableValue'] ) ? $_POST['hiddenReminderTableValue'] :''; $reminderName = isset( $_POST['reminderName'] ) ? sanitize_text_field ( $_POST['reminderName'] ) :''; $reminderSubject = isset( $_POST['reminderSubject'] ) ? sanitize_text_field ( $_POST['reminderSubject'] ) :''; $reminderEmail = isset( $_POST['reminderEmail'] ) ? sanitize_email( $_POST['reminderEmail'] ):''; $reminderComment = isset( $_POST['reminderComment'] ) ? sanitize_text_field( $_POST['reminderComment'] ):''; $reminderDateTime = isset( $_POST['reminderDateTime'] ) ? $_POST['reminderDateTime']:''; $reminderRepeat = isset( $_POST['reminderRepeat'] ) ? $_POST['reminderRepeat']:''; $reminderTableName = $wpdb->prefix.ARETKCREA_LEAD_REMINDER_HISTORY; $wpdb->update( "$reminderTableName", array( 'reminder_name' => "$reminderName", 'reminder_subject' => "$reminderSubject", 'reminder_email' => "$reminderEmail", 'reminder_comment' => "$reminderComment", 'reminder_time' => "$reminderDateTime", 'reminder_repeat' => "$reminderRepeat", 'updated_time' => current_time('mysql', 1) ), array( 'id' => $hiddenReminderTableValue ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', ), array( '%d' ) ); die(); } /** * Function for Remove lead reminder * @package Aretk * @subpackage Phase 1 * @return remove lead reminder record */ function aretkcrea_remove_crea_lead_reminder() { global $wpdb; $hiddenLeadID = isset( $_POST['hiddenLeadID'] ) ? $_POST['hiddenLeadID'] :''; $removeReminderID = isset( $_POST['removeReminderID'] ) ? $_POST['removeReminderID'] :''; if( !empty( $hiddenLeadID ) && $hiddenLeadID !='' && !empty( $removeReminderID ) && $removeReminderID !='' ) { $reminderTableName = $wpdb->prefix.ARETKCREA_LEAD_REMINDER_HISTORY; $reminderDeleteQuery = "DELETE FROM $reminderTableName WHERE `id` = $removeReminderID AND `reminder_lead_id` = $hiddenLeadID " ; $delete_recod = $wpdb->query( $reminderDeleteQuery ); $html =''; $reminderQuery = "SELECT * from `$reminderTableName` WHERE `reminder_lead_id` = $hiddenLeadID ORDER BY `id` ASC "; $getReminderResults = $wpdb->get_results($reminderQuery); if( !empty( $getReminderResults ) && $getReminderResults !='' ) { /*Start all lead reminder*/ $reminderCounter = 1; foreach ( $getReminderResults as $getReminderResultsValues) { $html .='
'; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .=''; $html .='

Email - The address of the person receiving the reminder

Email*

Subject*

Comment

Date and Time*

Repeat

'; $dailycheckdValues =''; if( $getReminderResultsValues->reminder_repeat == 'daily') { $dailycheckdValues = 'checked'; } else { $dailycheckdValues =''; } $weeklycheckdValues =''; if( $getReminderResultsValues->reminder_repeat == 'weekly') { $weeklycheckdValues = 'checked'; } else { $weeklycheckdValues =''; } $monthlycheckdValues =''; if( $getReminderResultsValues->reminder_repeat == 'monthly') { $monthlycheckdValues = 'checked'; } else { $monthlycheckdValues =''; } $yearlycheckdValues =''; if( $getReminderResultsValues->reminder_repeat == 'yearly') { $yearlycheckdValues = 'checked'; } else { $yearlycheckdValues =''; } $html .='Daily
'; $html .='Weekly
'; $html .='Monthly
'; $html .='Yearly
'; $html .='
'; $html .='
'; $html .='Update'; $html .='Remove Reminder'; $html .=''; $html .=''; $html .='
'; $html .='
'; $reminderCounter = $reminderCounter +1; } } echo $html; } die(); } /** * Ajax Call Function For get select agents name and id for feed section * * */ function aretkcrea_get_the_select_board_name(){ $getSubscriptionListingFilter = $_POST['getSubscriptionKey']; $getFeed = $_POST['getFeed']; if( isset( $getSubscriptionListingFilter ) && !empty( $getSubscriptionListingFilter ) && isset( $getFeed ) && !empty( $getFeed ) ){ $getSubscriptionKey = get_option('crea_subscription_key', ''); $subscriptionKey = !empty($getSubscriptionKey) ? $getSubscriptionKey : ''; $domainName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; if (empty($domainName)){ $domainName = get_site_url(); $domainName = parse_url($domainName, PHP_URL_HOST); } if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ARETKCREA_LISTING_BASEDONSERVER_API."/?key=$subscriptionKey&request=boards&feed=$getFeed"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_REFERER,$domainName); $data = curl_exec($ch); curl_close($ch); $resultSet = json_decode($data); if ( $resultSet !='' && !empty( $resultSet ) ) { foreach ( $resultSet as $resultSetKey => $resultSetValues ) { if ( !isset( $resultSetValues->TotalRecords ) && empty( $resultSetValues->TotalRecords ) ) { $select_board_name = $resultSetValues->BoardName; $select_board_Id = $resultSetValues->Board_ID; ?> $resultSetValues ) { if ( !isset( $resultSetValues->TotalRecords ) && empty( $resultSetValues->TotalRecords ) ) { $select_office_name = $resultSetValues->Name; $select_office_Id = $resultSetValues->OfficeID; ?> $resultSetValues ) { if ( !isset( $resultSetValues->TotalRecords ) && empty( $resultSetValues->TotalRecords ) ) { $select_agent_name = $resultSetValues->Name; $select_agent_Id = $resultSetValues->AgentID; ?>