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
<?php
namespace hji\ResponsiveIDX\tinymce;
use hji\membership\Membership;
use \hji\ResponsiveIDX\controllers\Settings as Settings;
use \hji\ResponsiveIDX\ResponsiveIDX as rIDX;
use hji\ResponsiveIDX\ResponsiveIDX;
class FeaturedListings
{
function __construct()
{
if (!is_admin())
{
return;
}
add_action('init', array($this, 'init'));
add_action('wp_ajax_' . rIDX::PREFIX . 'tinymce', array($this, 'loadWindow'));
}
function init()
{
if (!current_user_can('edit_posts') && !current_user_can('edit_pages'))
{
return;
}
if (get_user_option('rich_editing') == 'true')
{
add_filter('mce_external_plugins', array($this, 'registerPlugin'));
add_filter('hji_mce_buttons', array($this, 'registerButton'));
}
}
function registerPlugin($plugin_array)
{
$plugin_array['FeaturedListings'] = rIDX::$scripts . '/tinymce-featured-listings.js';
return $plugin_array;
}
function registerButton($buttons)
{
array_push($buttons, "|", "FeaturedListings");
return $buttons;
}
function loadWindow()
{
if (!current_user_can('edit_pages') && !current_user_can('edit_posts'))
{
die(__("You are not allowed to be here"));
}
if (!$_REQUEST['plugin'])
{
die();
}
$view = new \hji\common\utils\Views(ResponsiveIDX::$views);
echo $view->render($_REQUEST['plugin']);
die();
}
}