. */ /** * ---------------------------------------------------------------------------------------------------------------------- * Enable & Start WP Session * ---------------------------------------------------------------------------------------------------------------------- */ function cp_admin_init() { if (!session_id()) session_start(); } add_action('init', 'cp_admin_init'); /** * ---------------------------------------------------------------------------------------------------------------------- * Set Global variables * ---------------------------------------------------------------------------------------------------------------------- */ /** wp global vars */ global $wpdb; /** Max Execution Time */ if(!ini_get('safe_mode')) { set_time_limit(0); ini_set('max_execution_time', '3600'); // 3600 seconds = 1 hour } /** unlimited memory limit */ ini_set('memory_limit', '-1'); /** Plugin Version */ define('AEM_PLUGIN_Version', "1.0"); /** Plugin DB Table */ define('AEM_PLUGIN_DB_Table', $wpdb->prefix . "aem_properties"); /** Plugin Folder name */ if (!defined('AEM_PLUGIN_FOLDER')) { define('AEM_PLUGIN_FOLDER', 'agenteasy-properties'); } /** Plugin Title/Name */ if (!defined('AEM_PLUGIN_TITLE')) { #define('AEM_PLUGIN_TITLE', 'AgentEasy Properties'); define('AEM_PLUGIN_TITLE', 'AE Search'); } /** Plugin Full URL */ if (!defined('AEM_PLUGIN_URL')) { define('AEM_PLUGIN_URL', get_option('siteurl').'/wp-content/plugins/'.AEM_PLUGIN_FOLDER); } /** Plugin Full DIR Path */ if (!defined('AEM_PLUGIN_PATH')) { define('AEM_PLUGIN_PATH', 'wp-content/plugins/'.AEM_PLUGIN_FOLDER); } /** Plugin Options */ // set here the url where baycentric-web-service.php file is located $baycentric_web_service = 'http://agenteasy.com/ext/property-search/baycentric-web-service.php'; if (!defined('AEM_PLUGIN_OPTION_XML_PARSER')) { define('AEM_PLUGIN_OPTION_XML_PARSER', $baycentric_web_service.'?xml='); } if (!defined('AEM_PLUGIN_OPTION_API_KEY')) { define('AEM_PLUGIN_OPTION_API_KEY', ''); } if (!defined('AEM_PLUGIN_OPTION_XML_LIMIT')) { define('AEM_PLUGIN_OPTION_XML_LIMIT', 30); } if (!defined('AEM_PLUGIN_OPTION_XML_AGENT')) { define('AEM_PLUGIN_OPTION_XML_AGENT', 0); } if (!defined('AEM_PLUGIN_OPTION_XML_AGENT_ENABLE')) { define('AEM_PLUGIN_OPTION_XML_AGENT_ENABLE', 'No'); } if (!defined('AEM_PLUGIN_OPTION_XML_STATUS')) { define('AEM_PLUGIN_OPTION_XML_STATUS', 'active,pending'); } if (!defined('AEM_PLUGIN_OPTION_XML_NEIGHBORHOODS')) { $plugin_aem_option_xml_neighborhoods = array(); $plugin_aem_option_xml_neighborhoods[1010] = array('enable' => 'Yes', 'id' => 1010, 'district' => 'District 1', 'title' => 'Central Richmond'); $plugin_aem_option_xml_neighborhoods[1020] = array('enable' => 'Yes', 'id' => 1020, 'district' => 'District 1', 'title' => 'Inner Richmond'); $plugin_aem_option_xml_neighborhoods[1030] = array('enable' => 'Yes', 'id' => 1030, 'district' => 'District 1', 'title' => 'Jordan Pk/Laurel'); $plugin_aem_option_xml_neighborhoods[1040] = array('enable' => 'Yes', 'id' => 1040, 'district' => 'District 1', 'title' => 'Lake Street'); $plugin_aem_option_xml_neighborhoods[1050] = array('enable' => 'Yes', 'id' => 1050, 'district' => 'District 1', 'title' => 'Outer Richmond'); $plugin_aem_option_xml_neighborhoods[1060] = array('enable' => 'Yes', 'id' => 1060, 'district' => 'District 1', 'title' => 'Sea Cliff'); $plugin_aem_option_xml_neighborhoods[1070] = array('enable' => 'Yes', 'id' => 1070, 'district' => 'District 1', 'title' => 'Lone Mountain'); $plugin_aem_option_xml_neighborhoods[2010] = array('enable' => 'Yes', 'id' => 2010, 'district' => 'District 2', 'title' => 'Golden Gate Hts'); $plugin_aem_option_xml_neighborhoods[2020] = array('enable' => 'Yes', 'id' => 2020, 'district' => 'District 2', 'title' => 'Outer Parkside'); $plugin_aem_option_xml_neighborhoods[2030] = array('enable' => 'Yes', 'id' => 2030, 'district' => 'District 2', 'title' => 'Outer Sunset'); $plugin_aem_option_xml_neighborhoods[2040] = array('enable' => 'Yes', 'id' => 2040, 'district' => 'District 2', 'title' => 'Parkside'); $plugin_aem_option_xml_neighborhoods[2050] = array('enable' => 'Yes', 'id' => 2050, 'district' => 'District 2', 'title' => 'Central Sunset'); $plugin_aem_option_xml_neighborhoods[2060] = array('enable' => 'Yes', 'id' => 2060, 'district' => 'District 2', 'title' => 'Inner Sunset'); $plugin_aem_option_xml_neighborhoods[2070] = array('enable' => 'Yes', 'id' => 2070, 'district' => 'District 2', 'title' => 'Inner Parkside'); $plugin_aem_option_xml_neighborhoods[3010] = array('enable' => 'Yes', 'id' => 3010, 'district' => 'District 3', 'title' => 'Lake Shore'); $plugin_aem_option_xml_neighborhoods[3020] = array('enable' => 'Yes', 'id' => 3020, 'district' => 'District 3', 'title' => 'Merced Heights'); $plugin_aem_option_xml_neighborhoods[3030] = array('enable' => 'Yes', 'id' => 3030, 'district' => 'District 3', 'title' => 'Pine Lake Park'); $plugin_aem_option_xml_neighborhoods[3040] = array('enable' => 'Yes', 'id' => 3040, 'district' => 'District 3', 'title' => 'Stonestown'); $plugin_aem_option_xml_neighborhoods[3050] = array('enable' => 'Yes', 'id' => 3050, 'district' => 'District 3', 'title' => 'Lakeside'); $plugin_aem_option_xml_neighborhoods[3060] = array('enable' => 'Yes', 'id' => 3060, 'district' => 'District 3', 'title' => 'Merced Manor'); $plugin_aem_option_xml_neighborhoods[3070] = array('enable' => 'Yes', 'id' => 3070, 'district' => 'District 3', 'title' => 'Ingleside Heights'); $plugin_aem_option_xml_neighborhoods[3080] = array('enable' => 'Yes', 'id' => 3080, 'district' => 'District 3', 'title' => 'Ingleside'); $plugin_aem_option_xml_neighborhoods[3090] = array('enable' => 'Yes', 'id' => 3090, 'district' => 'District 3', 'title' => 'Oceanview'); $plugin_aem_option_xml_neighborhoods[4010] = array('enable' => 'Yes', 'id' => 4010, 'district' => 'District 4', 'title' => 'Balboa Terrace'); $plugin_aem_option_xml_neighborhoods[4020] = array('enable' => 'Yes', 'id' => 4020, 'district' => 'District 4', 'title' => 'Diamond Heights'); $plugin_aem_option_xml_neighborhoods[4030] = array('enable' => 'Yes', 'id' => 4030, 'district' => 'District 4', 'title' => 'Forest Hill'); $plugin_aem_option_xml_neighborhoods[4040] = array('enable' => 'Yes', 'id' => 4040, 'district' => 'District 4', 'title' => 'Forest Knolls'); $plugin_aem_option_xml_neighborhoods[4050] = array('enable' => 'Yes', 'id' => 4050, 'district' => 'District 4', 'title' => 'Ingleside Terrace'); $plugin_aem_option_xml_neighborhoods[4060] = array('enable' => 'Yes', 'id' => 4060, 'district' => 'District 4', 'title' => 'Midtown Terrace'); $plugin_aem_option_xml_neighborhoods[4070] = array('enable' => 'Yes', 'id' => 4070, 'district' => 'District 4', 'title' => 'St. Francis Wood'); $plugin_aem_option_xml_neighborhoods[4080] = array('enable' => 'Yes', 'id' => 4080, 'district' => 'District 4', 'title' => 'Miraloma Park'); $plugin_aem_option_xml_neighborhoods[4090] = array('enable' => 'Yes', 'id' => 4090, 'district' => 'District 4', 'title' => 'Forest Hill Ext'); $plugin_aem_option_xml_neighborhoods[4100] = array('enable' => 'Yes', 'id' => 4100, 'district' => 'District 4', 'title' => 'Sherwood Forest'); $plugin_aem_option_xml_neighborhoods[4110] = array('enable' => 'Yes', 'id' => 4110, 'district' => 'District 4', 'title' => 'Monterey Heights'); $plugin_aem_option_xml_neighborhoods[4120] = array('enable' => 'Yes', 'id' => 4120, 'district' => 'District 4', 'title' => 'Mount Davidson Manor'); $plugin_aem_option_xml_neighborhoods[4130] = array('enable' => 'Yes', 'id' => 4130, 'district' => 'District 4', 'title' => 'Westwood Highlands'); $plugin_aem_option_xml_neighborhoods[4140] = array('enable' => 'Yes', 'id' => 4140, 'district' => 'District 4', 'title' => 'Westwood Park'); $plugin_aem_option_xml_neighborhoods[4150] = array('enable' => 'Yes', 'id' => 4150, 'district' => 'District 4', 'title' => 'Sunnyside'); $plugin_aem_option_xml_neighborhoods[4160] = array('enable' => 'Yes', 'id' => 4160, 'district' => 'District 4', 'title' => 'West Portal'); $plugin_aem_option_xml_neighborhoods[5010] = array('enable' => 'Yes', 'id' => 5010, 'district' => 'District 5', 'title' => 'Glen Park'); $plugin_aem_option_xml_neighborhoods[5020] = array('enable' => 'Yes', 'id' => 5020, 'district' => 'District 5', 'title' => 'Haight Ashbury'); $plugin_aem_option_xml_neighborhoods[5030] = array('enable' => 'Yes', 'id' => 5030, 'district' => 'District 5', 'title' => 'Noe Valley'); $plugin_aem_option_xml_neighborhoods[5040] = array('enable' => 'Yes', 'id' => 5040, 'district' => 'District 5', 'title' => 'Twin Peaks'); $plugin_aem_option_xml_neighborhoods[5050] = array('enable' => 'Yes', 'id' => 5050, 'district' => 'District 5', 'title' => 'Cole Valley / Parnassus Hts'); $plugin_aem_option_xml_neighborhoods[5060] = array('enable' => 'Yes', 'id' => 5060, 'district' => 'District 5', 'title' => 'Buena Vista / Ashbury Hts'); $plugin_aem_option_xml_neighborhoods[5070] = array('enable' => 'Yes', 'id' => 5070, 'district' => 'District 5', 'title' => 'Corona Heights'); $plugin_aem_option_xml_neighborhoods[5080] = array('enable' => 'Yes', 'id' => 5080, 'district' => 'District 5', 'title' => 'Clarendon Heights'); $plugin_aem_option_xml_neighborhoods[5090] = array('enable' => 'Yes', 'id' => 5090, 'district' => 'District 5', 'title' => 'Duboce Triangle'); $plugin_aem_option_xml_neighborhoods[5100] = array('enable' => 'Yes', 'id' => 5100, 'district' => 'District 5', 'title' => 'Eureka Valley / Dolores'); $plugin_aem_option_xml_neighborhoods[5110] = array('enable' => 'Yes', 'id' => 5110, 'district' => 'District 5', 'title' => 'Mission Dolores'); $plugin_aem_option_xml_neighborhoods[6010] = array('enable' => 'Yes', 'id' => 6010, 'district' => 'District 6', 'title' => 'Anza Vista'); $plugin_aem_option_xml_neighborhoods[6020] = array('enable' => 'Yes', 'id' => 6020, 'district' => 'District 6', 'title' => 'Hayes Valley'); $plugin_aem_option_xml_neighborhoods[6030] = array('enable' => 'Yes', 'id' => 6030, 'district' => 'District 6', 'title' => 'Lwr Pacific Hts'); $plugin_aem_option_xml_neighborhoods[6040] = array('enable' => 'Yes', 'id' => 6040, 'district' => 'District 6', 'title' => 'Western Addition'); $plugin_aem_option_xml_neighborhoods[6050] = array('enable' => 'Yes', 'id' => 6050, 'district' => 'District 6', 'title' => 'Alamo Square'); $plugin_aem_option_xml_neighborhoods[6060] = array('enable' => 'Yes', 'id' => 6060, 'district' => 'District 6', 'title' => 'North Panhandle'); $plugin_aem_option_xml_neighborhoods[7010] = array('enable' => 'Yes', 'id' => 7010, 'district' => 'District 7', 'title' => 'Marina'); $plugin_aem_option_xml_neighborhoods[7020] = array('enable' => 'Yes', 'id' => 7020, 'district' => 'District 7', 'title' => 'Pacific Heights'); $plugin_aem_option_xml_neighborhoods[7030] = array('enable' => 'Yes', 'id' => 7030, 'district' => 'District 7', 'title' => 'Presidio Heights'); $plugin_aem_option_xml_neighborhoods[7040] = array('enable' => 'Yes', 'id' => 7040, 'district' => 'District 7', 'title' => 'Cow Hollow'); $plugin_aem_option_xml_neighborhoods[8010] = array('enable' => 'Yes', 'id' => 8010, 'district' => 'District 8', 'title' => 'Downtown'); $plugin_aem_option_xml_neighborhoods[8020] = array('enable' => 'Yes', 'id' => 8020, 'district' => 'District 8', 'title' => 'Financial District / Barbary Coast'); $plugin_aem_option_xml_neighborhoods[8030] = array('enable' => 'Yes', 'id' => 8030, 'district' => 'District 8', 'title' => 'Nob Hill'); $plugin_aem_option_xml_neighborhoods[8040] = array('enable' => 'Yes', 'id' => 8040, 'district' => 'District 8', 'title' => 'North Beach'); $plugin_aem_option_xml_neighborhoods[8050] = array('enable' => 'Yes', 'id' => 8050, 'district' => 'District 8', 'title' => 'Russian Hill'); $plugin_aem_option_xml_neighborhoods[8060] = array('enable' => 'Yes', 'id' => 8060, 'district' => 'District 8', 'title' => 'Van Ness/Civ Ctr'); $plugin_aem_option_xml_neighborhoods[8070] = array('enable' => 'Yes', 'id' => 8070, 'district' => 'District 8', 'title' => 'Telegraph Hill'); $plugin_aem_option_xml_neighborhoods[8080] = array('enable' => 'Yes', 'id' => 8080, 'district' => 'District 8', 'title' => 'North Waterfront'); $plugin_aem_option_xml_neighborhoods[8090] = array('enable' => 'Yes', 'id' => 8090, 'district' => 'District 8', 'title' => 'Tenderloin'); $plugin_aem_option_xml_neighborhoods[9010] = array('enable' => 'Yes', 'id' => 9010, 'district' => 'District 9', 'title' => 'Bernal Heights'); $plugin_aem_option_xml_neighborhoods[9020] = array('enable' => 'Yes', 'id' => 9020, 'district' => 'District 9', 'title' => 'Inner Mission'); $plugin_aem_option_xml_neighborhoods[9030] = array('enable' => 'Yes', 'id' => 9030, 'district' => 'District 9', 'title' => 'Mission Bay'); $plugin_aem_option_xml_neighborhoods[9040] = array('enable' => 'Yes', 'id' => 9040, 'district' => 'District 9', 'title' => 'Potrero Hill'); $plugin_aem_option_xml_neighborhoods[9050] = array('enable' => 'Yes', 'id' => 9050, 'district' => 'District 9', 'title' => 'South of Market'); $plugin_aem_option_xml_neighborhoods[9060] = array('enable' => 'Yes', 'id' => 9060, 'district' => 'District 9', 'title' => 'South Beach'); $plugin_aem_option_xml_neighborhoods[9070] = array('enable' => 'Yes', 'id' => 9070, 'district' => 'District 9', 'title' => 'Ctrl Waterfront / Dogpatch'); $plugin_aem_option_xml_neighborhoods[9080] = array('enable' => 'Yes', 'id' => 9080, 'district' => 'District 9', 'title' => 'Yerba Buena'); $plugin_aem_option_xml_neighborhoods[10010] = array('enable' => 'Yes', 'id' => 10010, 'district' => 'District 10', 'title' => 'Bayview'); $plugin_aem_option_xml_neighborhoods[10020] = array('enable' => 'Yes', 'id' => 10020, 'district' => 'District 10', 'title' => 'Crocker Amazon'); $plugin_aem_option_xml_neighborhoods[10030] = array('enable' => 'Yes', 'id' => 10030, 'district' => 'District 10', 'title' => 'Excelsior'); $plugin_aem_option_xml_neighborhoods[10040] = array('enable' => 'Yes', 'id' => 10040, 'district' => 'District 10', 'title' => 'Outer Mission'); $plugin_aem_option_xml_neighborhoods[10050] = array('enable' => 'Yes', 'id' => 10050, 'district' => 'District 10', 'title' => 'Visitacion Valley'); $plugin_aem_option_xml_neighborhoods[10060] = array('enable' => 'Yes', 'id' => 10060, 'district' => 'District 10', 'title' => 'Portola'); $plugin_aem_option_xml_neighborhoods[10070] = array('enable' => 'Yes', 'id' => 10070, 'district' => 'District 10', 'title' => 'Silver Terrace'); $plugin_aem_option_xml_neighborhoods[10080] = array('enable' => 'Yes', 'id' => 10080, 'district' => 'District 10', 'title' => 'Mission Terrace'); $plugin_aem_option_xml_neighborhoods[10090] = array('enable' => 'Yes', 'id' => 10090, 'district' => 'District 10', 'title' => 'Hunters Point'); $plugin_aem_option_xml_neighborhoods[10100] = array('enable' => 'Yes', 'id' => 10100, 'district' => 'District 10', 'title' => 'Bayview Heights'); $plugin_aem_option_xml_neighborhoods[10110] = array('enable' => 'Yes', 'id' => 10110, 'district' => 'District 10', 'title' => 'Candlestick Point'); $plugin_aem_option_xml_neighborhoods[10120] = array('enable' => 'Yes', 'id' => 10120, 'district' => 'District 10', 'title' => 'Little Hollywood'); $plugin_aem_option_xml_neighborhoods[11010] = array('enable' => 'Yes', 'id' => 11010, 'district' => 'District 11', 'title' => 'Original Daly City'); $plugin_aem_option_xml_neighborhoods[11020] = array('enable' => 'Yes', 'id' => 11020, 'district' => 'District 11', 'title' => 'Serramonte'); $plugin_aem_option_xml_neighborhoods[11030] = array('enable' => 'Yes', 'id' => 11030, 'district' => 'District 11', 'title' => 'Southern Hills'); $plugin_aem_option_xml_neighborhoods[11040] = array('enable' => 'Yes', 'id' => 11040, 'district' => 'District 11', 'title' => 'Westlake #1 / Olympic'); $plugin_aem_option_xml_neighborhoods[11050] = array('enable' => 'Yes', 'id' => 11050, 'district' => 'District 11', 'title' => 'Westlake Highlands'); $plugin_aem_option_xml_neighborhoods[11060] = array('enable' => 'Yes', 'id' => 11060, 'district' => 'District 11', 'title' => 'Westlake Knolls'); $plugin_aem_option_xml_neighborhoods[11070] = array('enable' => 'Yes', 'id' => 11070, 'district' => 'District 11', 'title' => 'Broadmoor'); $plugin_aem_option_xml_neighborhoods[11080] = array('enable' => 'Yes', 'id' => 11080, 'district' => 'District 11', 'title' => 'Westlake Terrace'); $plugin_aem_option_xml_neighborhoods[11090] = array('enable' => 'Yes', 'id' => 11090, 'district' => 'District 11', 'title' => 'St. Francis Hts'); $plugin_aem_option_xml_neighborhoods[11100] = array('enable' => 'Yes', 'id' => 11000, 'district' => 'District 11', 'title' => 'Westlake Palisades'); $plugin_aem_option_xml_neighborhoods[11110] = array('enable' => 'Yes', 'id' => 11110, 'district' => 'District 11', 'title' => 'Blossom Valley'); $plugin_aem_option_xml_neighborhoods[11120] = array('enable' => 'Yes', 'id' => 11120, 'district' => 'District 11', 'title' => 'Crown Colony'); $plugin_aem_option_xml_neighborhoods[11130] = array('enable' => 'Yes', 'id' => 11130, 'district' => 'District 11', 'title' => 'Colma'); $plugin_aem_option_xml_neighborhoods[11140] = array('enable' => 'Yes', 'id' => 11140, 'district' => 'District 11', 'title' => 'Brisbane'); $plugin_aem_option_xml_neighborhoods[11150] = array('enable' => 'Yes', 'id' => 11150, 'district' => 'District 11', 'title' => 'Bayridge / Linda Vista'); if(count($plugin_aem_option_xml_neighborhoods) > 0) { $plugin_aem_option_xml_neighborhoods_serialize = serialize($plugin_aem_option_xml_neighborhoods); $plugin_aem_option_xml_neighborhoods_serialize = htmlentities($plugin_aem_option_xml_neighborhoods_serialize,ENT_QUOTES); } else { $plugin_aem_option_xml_neighborhoods_serialize = ""; } define('AEM_PLUGIN_OPTION_XML_NEIGHBORHOODS', $plugin_aem_option_xml_neighborhoods_serialize); } /** Plugin Miscellaneous Settings */ if (!defined('AEM_PLUGIN_TEMPLATE_PAGE_PARENT')) { define('AEM_PLUGIN_TEMPLATE_PAGE_PARENT', 'Properties'); } if (!defined('AEM_THEME_ACTIVE')) { $aem_plugin_template_page_slug = sanitize_title(AEM_PLUGIN_TEMPLATE_PAGE_PARENT); if(plugin_aem_get_ID_by_slug($aem_plugin_template_page_slug) > 0) { define('AEM_THEME_ACTIVE', TRUE); } else { define('AEM_THEME_ACTIVE', FALSE); } } if (!defined('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_PARENT')) { if(AEM_THEME_ACTIVE == true) { define('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_PARENT', AEM_PLUGIN_TEMPLATE_PAGE_PARENT); } else { define('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_PARENT', ''); } } if (!defined('AEM_PLUGIN_TEMPLATE_PAGE_SLUG_PARENT')) { define('AEM_PLUGIN_TEMPLATE_PAGE_SLUG_PARENT', sanitize_title(AEM_PLUGIN_TEMPLATE_PAGE_TITLE_PARENT)); } if (!defined('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_SEARCH')) { define('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_SEARCH', 'Search Property'); } if (!defined('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_RESULTS')) { define('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_RESULTS', 'Search Results'); } if (!defined('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_DETAILS')) { define('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_DETAILS', 'Property Details'); } if (!defined('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_MY_ACTIVE_PROPERTIES')) { define('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_MY_ACTIVE_PROPERTIES', 'My Active Properties'); } if (!defined('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_MY_SOLD_PROPERTIES')) { define('AEM_PLUGIN_TEMPLATE_PAGE_TITLE_MY_SOLD_PROPERTIES', 'My Sold Properties'); } if (!defined('AEM_PLUGIN_SHORTCODE_SEARCH')) { define('AEM_PLUGIN_SHORTCODE_SEARCH', '[plugin_aem_template_search]'); } if (!defined('AEM_PLUGIN_SHORTCODE_RESULTS')) { define('AEM_PLUGIN_SHORTCODE_RESULTS', '[plugin_aem_template_results]'); } if (!defined('AEM_PLUGIN_SHORTCODE_DETAILS')) { define('AEM_PLUGIN_SHORTCODE_DETAILS', '[plugin_aem_template_details]'); } if (!defined('AEM_PLUGIN_SHORTCODE_MY_ACTIVE_PROPERTIES')) { define('AEM_PLUGIN_SHORTCODE_MY_ACTIVE_PROPERTIES', '[plugin_aem_template_my_active_properties]'); } if (!defined('AEM_PLUGIN_SHORTCODE_MY_SOLD_PROPERTIES')) { define('AEM_PLUGIN_SHORTCODE_MY_SOLD_PROPERTIES', '[plugin_aem_template_my_sold_properties]'); } /** * ---------------------------------------------------------------------------------------------------------------------- * Plugin Install/Remove * ---------------------------------------------------------------------------------------------------------------------- */ // Runs when plugin is activated register_activation_hook(__FILE__,'plugin_aem_plugin_install'); // Runs on plugin deactivation register_deactivation_hook( __FILE__, 'plugin_aem_plugin_remove' ); /** * ---------------------------------------------------------------------------------------------------------------------- * Plugin Database: Properties >> Create Database Table if NOT exists * ---------------------------------------------------------------------------------------------------------------------- */ if($wpdb->get_var("SHOW TABLES LIKE '".AEM_PLUGIN_DB_Table."'") != AEM_PLUGIN_DB_Table) { $sql = "CREATE TABLE IF NOT EXISTS `".AEM_PLUGIN_DB_Table."` ( `id` int(100) NOT NULL AUTO_INCREMENT, `Represented` varchar(255) DEFAULT 'Both', `MLS` int(100) DEFAULT 0, `Title` varchar(255) DEFAULT NULL, `URL` varchar(255) DEFAULT NULL, `DefaultImageURL` varchar(255) DEFAULT NULL, `DefaultThumbnailURL` varchar(255) DEFAULT NULL, `PropertyType` varchar(255) DEFAULT NULL, `Address` text, `Bedrooms` varchar(255) DEFAULT 0, `Bathrooms` varchar(255) DEFAULT 0, `ListingPrice` varchar(255) DEFAULT 0, `ListingDate` varchar(255) DEFAULT NULL, `SellingPrice` varchar(255) DEFAULT 0, `SoldDate` varchar(255) DEFAULT NULL, `Description` text, `Status` varchar(255) DEFAULT NULL, `ListingAgent` varchar(255) DEFAULT NULL, `ListingOffice` varchar(255) DEFAULT NULL, `Comment` text, `full_property_details` longtext, `date_added` date DEFAULT NULL, `date_updated` date DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;"; $wpdb->query($sql); if($wpdb->get_var("SHOW TABLES LIKE '".AEM_PLUGIN_DB_Table."'") == AEM_PLUGIN_DB_Table) { $plugin_aem_db_creation[AEM_PLUGIN_DB_Table] = '
\s*[(.*)]\s*<\/p>/i', "[$1]", $content); if (strpos($content, AEM_PLUGIN_SHORTCODE_SEARCH) !== FALSE) { $content = str_replace(AEM_PLUGIN_SHORTCODE_SEARCH, wp_plugin_aem_template_page('template-search.php'), $content); } if (strpos($content, AEM_PLUGIN_SHORTCODE_RESULTS) !== FALSE){ $content = str_replace(AEM_PLUGIN_SHORTCODE_RESULTS, wp_plugin_aem_template_page('template-results.php'), $content); } if (strpos($content, AEM_PLUGIN_SHORTCODE_DETAILS) !== FALSE) { $content = str_replace(AEM_PLUGIN_SHORTCODE_DETAILS, wp_plugin_aem_template_page('template-details.php'), $content); } if (strpos($content, AEM_PLUGIN_SHORTCODE_MY_ACTIVE_PROPERTIES) !== FALSE) { $content = str_replace(AEM_PLUGIN_SHORTCODE_MY_ACTIVE_PROPERTIES, wp_plugin_aem_template_page('template-my-active-properties.php'), $content); } if (strpos($content, AEM_PLUGIN_SHORTCODE_MY_SOLD_PROPERTIES) !== FALSE) { $content = str_replace(AEM_PLUGIN_SHORTCODE_MY_SOLD_PROPERTIES, wp_plugin_aem_template_page('template-my-sold-properties.php'), $content); } return $content; } add_filter('the_content', 'plugin_aem_property_templates'); /** * ---------------------------------------------------------------------------------------------------------------------- * Custom Rewrite Rule for the "Property" Detail Page (Clean/SEO friendly URL) * ---------------------------------------------------------------------------------------------------------------------- * Example: http://myblogsite.com/detail-page/376072/2450-bush-st-san-francisco-ca-94115/ * * -> Template page : detail-page * -> MLS Listing# : 376072 * -> Property Address : 2450-bush-st-san-francisco-ca-94115 * ---------------------------------------------------------------------------------------------------------------------- */ function property_search_flush_rewrite() { global $wp_rewrite; $wp_rewrite->flush_rules(); } function property_search_vars($public_query_vars) { $public_query_vars[] = 'aem_property_details'; return $public_query_vars; } function property_search_add_rewrite_rules($wp_rewrite) { $template_page = get_option('plugin_aem_option_template_page_base_details').'/'.get_option('plugin_aem_option_template_page_details'); $template_base = get_option( 'siteurl' ).'/'; $template_page_details = str_replace($template_base, "", $template_page); $new_rules = array($template_page_details.'/(.+)' => 'index.php?pagename='.$template_page_details.'&aem_property_details=' . $wp_rewrite->preg_index(1)); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_action('init', 'property_search_flush_rewrite'); add_filter('query_vars', 'property_search_vars'); add_action('generate_rewrite_rules', 'property_search_add_rewrite_rules'); /** * ---------------------------------------------------------------------------------------------------------------------- * Pagination string * ---------------------------------------------------------------------------------------------------------------------- */ function plugin_aem_getPaginationString($frontText = "", $page = 1, $totalitems, $limit = 10, $adjacents = 1, $targetpage = "/", $pagestring = "?pg=") { //defaults if(!$adjacents) $adjacents = 1; if(!$limit) $limit = 10; if(!$page) $page = 1; if(!$targetpage) $targetpage = "/"; //other vars $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($totalitems / $limit); //lastpage is = total items / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 // Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. $pagination = ""; if($lastpage > 1){ $pagination .= "
'; echo 'Error Saving Agent MLSID setting. MLSID is empty.'; echo '
'; echo 'Error Saving LIMIT setting. Value should have a minimum value of 10 and maximum value of 100.'; echo '
'; echo 'Settings Saved.'; echo '
'; echo 'Neighborhoods Updated.'; echo '
'; echo 'Settings Saved.'; echo '
| Shortcodes | Description |
|---|---|
| When the Agent MLSID is supplied in the Plugin Settings and the Shortcode is on a page, it will display the auto feed of the Agents Active Listings. | |
| When the Agent MLSID is supplied in the Plugin Settings and the Shortcode is on a page, it will display the auto feed of the Agents Sold Listings. |
Teams
Agent #1 (left)
Agent #1 (right)
get_var("SELECT ID FROM {$wpdb->posts} WHERE guid = '$image_src' LIMIT 1"); if($attachment_id == null){ $image_src = basename ( $image_src ); $id = $wpdb->get_var("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE '%$image_src%' LIMIT 1"); } if($attachment_id == null){ $attachment_id = 0; } return $attachment_id; } /** * ---------------------------------------------------------------------------------------------------------------------- * Custom Post Type >> Property Listings * ---------------------------------------------------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------------------------------------------------ * Custom Post Type >> Property Listings >> Enable WYSIWYG & WP Media Library editor in plugin * ------------------------------------------------------------------------------------------------------------------ */ if($_GET['post'] > 0 && $_GET['action'] == "edit" || $_GET['post_type'] == "property_listings") { add_action( 'init', 'ae_property_listings_plugin_init' ); } function ae_property_listings_plugin_init(){ if(current_user_can('upload_files')) { add_action('admin_print_scripts', 'ae_property_listings_load_jquery'); add_action('admin_print_styles', 'ae_property_listings_load_styles' ); add_action( 'admin_head', 'wp_tiny_mce' ); } } function ae_property_listings_load_jquery(){ wp_enqueue_script('editor'); wp_enqueue_script('thickbox'); wp_enqueue_script('media-upload'); $ae_fileupload_dir = plugins_url('/agenteasy-properties/', dirname(__FILE__)); wp_enqueue_script('jquery'); wp_enqueue_script('ae-fileupload', $ae_fileupload_dir . 'jquery.fileupload.js'); wp_enqueue_script('ae-fileupload-ui', $ae_fileupload_dir . 'jquery.fileupload-ui.js'); } function ae_property_listings_load_styles(){ $ae_fileupload_dir = plugins_url('/agenteasy-properties/', dirname(__FILE__)); wp_enqueue_style('ae-fileupload-style', $ae_fileupload_dir . 'jquery.fileupload-ui.css'); } /** * ------------------------------------------------------------------------------------------------------------------ * Custom Post Type >> Property Listings >> Register/Setup Post Type * ------------------------------------------------------------------------------------------------------------------ */ add_action('init', 'ae_register_property_listings'); function ae_register_property_listings() { $labels = array( 'name' => _x('AE Listings', 'post type general name'), 'singular_name' => _x('Property Listing Item', 'post type singular name'), 'add_new' => _x('Add New', 'property_listing item'), 'add_new_item' => __('Add New Property Listing Item'), 'edit_item' => __('Edit Property Listing Item'), 'new_item' => __('New Property Listing Item'), 'view_item' => __('View Property Listing Item'), 'search_items' => __('Search Property Listing'), 'not_found' => __('Nothing found'), 'not_found_in_trash' => __('Nothing found in Trash'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array('slug' => 'property-listings', 'with_front' => true), 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => 100, 'supports' => array('title'), #array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'post-formats'), 'has_archive' => false, 'can_export' => true ); register_post_type( 'property_listings' , $args ); flush_rewrite_rules(); } /** * ------------------------------------------------------------------------------------------------------------------ * tells WP to overwrite existing images without changing the filenames * ------------------------------------------------------------------------------------------------------------------ */ add_filter('wp_handle_upload_overrides','noneUniqueFilename'); function noneUniqueFilename($overrides){ $overrides['test_form'] = false; $overrides['unique_filename_callback'] = 'nonUniqueFilenameCallback'; return $overrides; } function nonUniqueFilenameCallback($directory, $name, $extension){ $filename = $name . strtolower($extension); removeOldAttach($filename); return $filename; } function removeOldAttach($filename){ $arguments = array( 'numberposts' => -1, 'meta_key' => '_wp_attached_file', 'meta_value' => $filename, 'post_type' => 'attachment' ); $Attachments_to_remove = get_posts($arguments); foreach($Attachments_to_remove as $a) { wp_delete_attachment($a->ID, true); } } /** * ---------------------------------------------------------------------------------------------------------------------- * Function To Process Image Uploading into WP Media Library * ---------------------------------------------------------------------------------------------------------------------- */ function add_xml_img_to_wp_media_ibrary($image, $post_id, $imgURLname) { require_once(ABSPATH . '/wp-admin/includes/file.php'); require_once(ABSPATH . '/wp-admin/includes/media.php'); require_once(ABSPATH . '/wp-admin/includes/image.php'); $results = array(); $name = basename($image); // name $binary_data = @file_get_contents($image); $getimagesize = @getimagesize($image_url); // type $type = $getimagesize['mime']; $tmp_name = tempnam(dirname(__FILE__)."/tmp", $img_name); // tmp_name $handle = @fopen($tmp_name, "w"); @fwrite($handle, $binary_data); @fclose($handle); $size = @filesize($tmp_name); // size if(isset($name) && !empty($name)) { // nothing to do... } else { $name = $imgURLname; // name } if(isset($name) && !empty($name)) { // nothing to do... } else { $name = time(); //$imgURLname; // name } //array to mimic $_FILES $file_array = array( 'name' => $name, 'type' => $type, 'tmp_name' => $tmp_name, 'error' => 0, 'size' => $size ); //the actual image processing, that is, move to upload directory, generate thumbnails and image sizes and writing into the database happens here #$mhs = media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()); $mhs = media_handle_sideload($file_array, $post_id, $name); // store thr processing result/details into an array $results = array('file' => $file_array, 'id' => $mhs); @unlink($tmp_name); return $results; } /** * ------------------------------------------------------------------------------------------------------------------ * Custom Post Type >> Property Listings >> Save Fields * ------------------------------------------------------------------------------------------------------------------ */ add_action('save_post', 'save_details_property_listings'); function save_details_property_listings() { global $post; // Stop WP from clearing custom fields on autosave, and also during ajax requests (e.g. quick edit) and bulk edits. if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { return; } // Clean, Validate and Save Custom Fields $listing = array(); // Property Details $listing['Represented'] = 'Seller'; $listing['Address'] = ''; $listing['MLS'] = ''; $listing['Bedrooms'] = ''; $listing['Bathrooms'] = ''; $listing['PropertyType'] = ''; $listing['Neighborhood'] = ''; $listing['Description'] = ''; $listing['ListingPrice'] = ''; $listing['SellingPrice'] = ''; $listing['SoldDate'] = ''; $listing['ListingAgent'] = ''; $listing['ListingOffice'] = ''; $listing['Status'] = ''; // PrimaryDetails $listing['CrossStreet'] = ''; $listing['ApproximateSqFt'] = ''; $listing['PricePerSqFt'] = ''; $listing['YearBuilt'] = ''; $listing['TotalRooms'] = ''; $listing['HOADues'] = ''; // AdditionalDetails $listing['Parking'] = ''; $listing['Type'] = ''; $listing['Style'] = ''; $listing['Floors'] = ''; $listing['BathTypeIncludes'] = ''; $listing['Kitchen'] = ''; $listing['DiningRoom'] = ''; $listing['LivingRoom'] = ''; $listing['HeatingCoolingSystem']= ''; $listing['LaundryAppliances'] = ''; $listing['SpecialFeatures'] = ''; $listing['CommonAreas'] = ''; $listing['Transportation'] = ''; $listing['Shopping'] = ''; //$listing['Comment'] = ''; // photos/images $listing['FeaturedImage'] = ''; $listing['Photos'] = ''; foreach($listing as $listing_key => $listing_value) { if($listing_key == 'Photos') { if(!isset($_POST['Photos'])) { $_POST['Photos'] = array(); } if(count($_POST['Photos']) > 0) { foreach($_POST['Photos'] as $photos_key => $photos_val) { if(isset($_POST['removedPhoto'][$photos_key])) { // don't add photo } else { $ignore_image = false; $image = $_POST['Photos'][$photos_key]; /* // ------------------------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------------------------- */ if(isset($_POST['MID']) && !empty($_POST['MID'])) { if($image != AEM_PLUGIN_URL."/images/no_image_available.jpg") { #if(@fopen($image,'r') !== false) { // upload into wp media library $imgURLname = basename($image); // name $add_to_wpml_result = add_xml_img_to_wp_media_ibrary($image, $post->ID, $imgURLname); #echo ''; print_r($add_to_wpml_result); echo ''; // check if added into wp media library if(is_int($add_to_wpml_result['id'])) { if($add_to_wpml_result['id'] > 0) { // Image added into WP Media Library. // get image @list( $img_src, $width, $height ) = image_downsize($add_to_wpml_result['id'], 'full'); // update the value of the image url $image = $img_src; #if(@fopen($img_src,'r') !== false) { #echo '
Image retrived from WP Media Library. ('.$image.')
'; #} else { #echo 'Failed getting Image URL from WP Media Library.
'; #} } else { $ignore_image = true; // Failed adding image into WP Media Library } } else { $ignore_image = true; // Failed adding image into WP Media Library } #} else { #$ignore_image = true; // Image doesn't exists #} } else { $ignore_image = true; // Image is ignore } } if($ignore_image == false) { $listing['Photos'][] = $image; update_post_meta($post->ID, 'Photos', $listing['Photos']); } } } } } else { update_post_meta($post->ID, $listing_key, $_POST[$listing_key]); } } if(!isset($_POST['Represented']) || empty($_POST['Represented'])) { update_post_meta($post->ID, 'Represented', 'Seller'); } update_post_meta($post->ID, "Description", $_POST["content"]); } /** * ------------------------------------------------------------------------------------------------------------------ * Custom Post Type >> Property Listings >> Main Post Type List Columns * ------------------------------------------------------------------------------------------------------------------ */ // Add to admin_init function add_filter('manage_edit-property_listings_columns', 'add_new_property_listings_columns'); function add_new_property_listings_columns($property_listings_columns) { $new_columns['cb'] = ''; $new_columns['title'] = _x('Title', 'column name'); $new_columns['Address'] = __('Address'); $new_columns['Status'] = __('Status'); $new_columns['Represented'] = __('Represented'); $new_columns['ListingPrice'] = __('ListingPrice'); $new_columns['SellingPrice'] = __('SellingPrice'); $new_columns['FeaturedImage']= __('Featured Image'); $new_columns['ID'] = __('ID'); return $new_columns; } /** * ------------------------------------------------------------------------------------------------------------------ * Custom Post Type >> Property Listings >> Function to echo the selected field * ------------------------------------------------------------------------------------------------------------------ */ add_action("manage_posts_custom_column", "property_listings_custom_columns"); function property_listings_custom_columns($field){ global $post; $wp_plugin_aem_params = wp_plugin_aem_params(); switch ($field){ case "ID": $value = get_the_ID(); echo $value; break; case "title": $value = get_the_title(); echo $value; break; case "description": $value = get_the_content(); echo $value; break; case "excerpt": $value = get_the_excerpt(); echo $value; break; case "FeaturedImage": $value = '
';
$fields = get_post_custom($post->ID);
if(isset($fields[$field][0]) && !empty($fields[$field][0])) {
$FeaturedImage = $fields['FeaturedImage'][0];
if(!empty($FeaturedImage)) {
$value = '| Property MLSID: | ||
|
Get MLSID Property details from XML and
fills out the 'Property Details' form fields.
|
||
'; echo 'Property details successfully retrieved. Click the \'Publish\' or \'Save Draft\' button to save the property details.'; echo '
'; print_r($arr["Listing"]); echo '
'; echo 'Failed retrieving property details. MLSID doesn\'t exists'; echo '
| : | /> /> /> |
| : |
|
| : | |
| : | 0) { ?> |
| : | 0) { ?> |
| : | YYYY-mm-dd |
| Property Photos: | |
|---|---|
|
|
|
| : |
Photos
1) { ?>Location
| Shortcode | Usage |
|---|---|
| [AE_PROPERTY_LISTINGS] | Add the trigger text (shortcode) to the page/post content to display the property listings. |
| Shortcode Options | Description | Example |
|---|---|---|
| num | The number of records to display. By default it is set to display All records. | [AE_PROPERTY_LISTINGS num="5"] |
| show_pagination |
Set this to 'no' if you don't want to display the pagination. By default it is set to 'yes'.
The pagination is automatically hidden if 'num' option is not set and if all records are already displayed. |
[AE_PROPERTY_LISTINGS show_pagination="no"] |
| sort_order | The sort order of records ('ASC' or 'DESC'). By default it is set it sort in 'ASC'. | [AE_PROPERTY_LISTINGS order_sort="ASC"] |
| sort_by | Sort records by 'post_title', 'Status', 'Address', 'ListingPrice', 'SellingPrice', 'SoldDate'. By default it is sorted by 'post_title'. | [AE_PROPERTY_LISTINGS order_by="title"] |
| id | Filter records to display based on ID (comma separated IDs). Display only the records with specific IDs: | [AE_PROPERTY_LISTINGS id="1,2,3"] |
| exclude_id | Filter records to display based on ID (comma separated IDs). Display all records but NOT the specified IDs. | [AE_PROPERTY_LISTINGS exclude_id="1,2,3"] |
| status | Filter records to display based on status: . | [AE_PROPERTY_LISTINGS status="Active"] |
| Example | Shortcode |
|---|---|
| All Property Listings | [AE_PROPERTY_LISTINGS num="10" show_pagination="yes" sort_order="ASC" sort_by="post_title" id="" exclude_id="" status=""] |
| Active Property Listings | [AE_PROPERTY_LISTINGS num="10" show_pagination="yes" sort_order="ASC" sort_by="ListingPrice" id="" exclude_id="" status="Active"] |
| Sold Property Listings | [AE_PROPERTY_LISTINGS num="10" show_pagination="yes" sort_order="DESC" sort_by="SoldDate" id="" exclude_id="" status="Sold"] |