1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
<?php
namespace REL\controllers;
use \REL\Models\rIDXImport as ImportModel;
require_once(REL_MODELS . '/rIDXImport.php');
class rIDXImport
{
function __construct()
{
add_action('admin_init', array($this, 'initrIDXHooks'));
add_action('wp_ajax_importListings', array('\\REL\\Models\\rIDXImport', 'importListings'));
}
function initrIDXHooks()
{
if (is_admin() &&
$this->isResponsiveIdxActive() &&
self::isResponsiveIdxCompatible())
{
add_filter('property_ads_snippet_template', array(
$this, 'property_ads_snippet_template'
), 12, 2);
add_filter('property_ads_thead', array($this, 'property_ads_thead'));
}
}
static function isResponsiveIdxCompatible()
{
if ($pluginData = get_plugin_data(WP_PLUGIN_DIR . '/hji-responsive-idx/responsive-idx.php'))
{
return (version_compare($pluginData['Version'], '2.4') >= 0);
}
return false;
}
function isResponsiveIdxActive()
{
if (!is_admin())
{
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
return is_plugin_active('hji-responsive-idx/responsive-idx.php');
}
function property_ads_snippet_template($admin_snippet, $listing_id)
{
$imported = ((bool)ImportModel::listingExists($listing_id)) ? '<div style="color: #008000;">Imported</div>' : '';
$admin_snippet = '
<tr>
<th scope="row" class="check-column">
<input type="checkbox" name="listing[]" value="' . $listing_id . '">
</th>
<td class="lid_' . $listing_id . '">%s' . $imported . '</td>
<td>%s</td>
<td>%s</td>
<td><table>%s</table></td>
<td><a href="%s" target="_blank" title="Click to view detailed home information.">View Property</a></td>
<td><a href="#" class="get_html" rel="snippet_' . $listing_id . '" title="Get HTML code for pasting.">Get HTML</a></td>
</tr>';
return $admin_snippet;
}
function property_ads_thead()
{
$thead = '
<thead>
<tr>
<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><label class="screen-reader-text" for="cb-select-all-1">Select All</label><input id="cb-select-all-1" type="checkbox"></th>
<th class="manage-column">MLS ID</th>
<th class="manage-column">Price</th>
<th class="manage-column">Photo</th>
<th class="manage-column">Details</th>
<th class="manage-column">Property Link</th>
<th class="manage-column">HTML Code</th>
</tr>
</thead>';
return $thead;
}
}