Paris 7 – Rue du Bac – high floor
$3,751,6053,300,000 EUR
Rue du Bac, 75007 Paris, France
Located rue du Bac, on the 4th floor of a...
- 2 beds
Rue du Bac, 75007 Paris, France
/* Plugin Name: RealEstate Agent Analytics (Estatik Compatible) Description: Tracks views and leads for Estatik listings and displays them to agents. Version: 1.2 Author: DeveloperGPT */ if (!defined('ABSPATH')) exit; // Exit if accessed directly // 1. Create views table function rea_create_views_table() { global $wpdb; $table_name = $wpdb->prefix . 'property_views'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id BIGINT(20) NOT NULL AUTO_INCREMENT, property_id BIGINT(20) NOT NULL, view_time DATETIME DEFAULT CURRENT_TIMESTAMP, ip_address VARCHAR(100), PRIMARY KEY (id) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); } register_activation_hook(__FILE__, 'rea_create_views_table'); // 2. Track views for Estatik 'properties' function rea_track_estatik_views() { if (is_singular('properties')) { global $post, $wpdb; $table_name = $wpdb->prefix . 'property_views'; $ip = $_SERVER['REMOTE_ADDR']; $wpdb->insert($table_name, [ 'property_id' => $post->ID, 'ip_address' => $ip ]); } } add_action('wp_head', 'rea_track_estatik_views'); // 3. Agent Dashboard Menu (Admin) function rea_register_agent_dashboard() { if (current_user_can('agent')) { add_menu_page('Estatik Analytics', 'My Analytics', 'read', 'rea-agent-analytics', 'rea_render_analytics_page', 'dashicons-chart-bar', 6); } } add_action('admin_menu', 'rea_register_agent_dashboard'); // 4. Analytics Output Function function rea_get_analytics_output() { if (!current_user_can('agent')) return '
You do not have access to this content.
'; global $wpdb; $views_table = $wpdb->prefix . 'property_views'; $current_user_id = get_current_user_id(); $args = [ 'post_type' => 'properties', 'posts_per_page' => -1, 'meta_query' => [ [ 'key' => 'es_property_agent_user', 'value' => $current_user_id, 'compare' => '=' ] ] ]; $properties = get_posts($args); ob_start(); echo '| Property | Views |
|---|---|
| ' . esc_html($property->post_title) . ' | ' . intval($views) . ' |
Enter your email address and we will send you a link to change your password.