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 123 124 125 126 127 128 129 130 131 132
<?php
namespace hji\listingstoblog;
use \hji\ResponsiveIDX\ResponsiveIDX;
use \hji\listingstoblog\controllers\ImportListings;
use \hji\listingstoblog\controllers\Settings;
use \hji\membership\Membership;
new ListingsToBlog;
class ListingsToBlog
{
const NAME = 'HJI Listing Socializer';
public static $slug;
public static $dir;
public static $url;
function __construct()
{
self::$slug = basename(dirname(__FILE__));
self::$dir = WP_PLUGIN_DIR . '/' . self::$slug;
self::$url = WP_PLUGIN_URL . '/' . self::$slug;
add_filter('hji_membership_register_plugin', array($this, 'registerPlugin'));
register_deactivation_hook( __FILE__, array($this, 'doOnPluginDeactivation'));
}
function registerPlugin($plugins)
{
array_push($plugins, array('file' => __FILE__, 'callback' => array($this, 'init')));
return $plugins;
}
function init()
{
require_once(self::$dir . '/classes/controllers/Settings.php');
$this->settingsController = new Settings;
$this->settingsController->setActionHooks();
add_action('dailylistingstoblog', array($this, 'importListings'));
add_action('admin_notices', array($this, 'addRidxNotice'));
}
function addRidxNotice()
{
if (!self::isResponsiveIdxCompatible())
{
echo '<div id="message" class="error"><p><strong style="color: #f00">ERROR (' . self::NAME . '):</strong> <strong>HJI Responsive IDX 2.4 or newer is required.</strong> Please contact our support department at <a href="mailto:help@homejunction.com">help@homejunction.com</a> or at (858) 777-9533 Ext. 4.</p></div>';
}
}
static function isResponsiveIdxCompatible()
{
if (self::isResponsiveIdxActive() && $pluginData = get_plugin_data(WP_PLUGIN_DIR . '/hji-responsive-idx/responsive-idx.php'))
{
return (version_compare($pluginData['Version'], '2.4') >= 0);
}
return false;
}
function doOnPluginDeactivation()
{
wp_clear_scheduled_hook('dailylistingstoblog');
}
static function isResponsiveIdxActive()
{
if (!is_admin())
{
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}
return is_plugin_active('hji-responsive-idx/responsive-idx.php');
}
function importListings()
{
if (self::isResponsiveIdxActive() && self::isResponsiveIdxCompatible())
{
require_once(self::$dir . '/classes/controllers/ImportListings.php');
$controller = new ImportListings();
$controller->importListings();
}
}
}