.
*
* @copyright 2013-2015
* @license GPL v3
* @version 1.5.0.1
* @package AJAX Manufactory
* @author Epsilon Web Manufactory
*/
define('JX_VERSION', '1.5.0.1');
register_activation_hook(__FILE__, 'wpjxm_activate_plugin');
register_deactivation_hook(__FILE__, 'wpjxm_deactivate_plugin');
function wpjxm_activate_plugin() {
if(!function_exists('register_post_status')) {
deactivate_plugins(basename(dirname( __FILE__ )).'/'.basename (__FILE__));
wp_die( __( "This plugin requires WordPress 3.0 or newer. Please update your WordPress installation to activate this plugin.", 'wpjxm_lang' ));
}
}
function wpjxm_deactivate_plugin() {
}
add_action('init', 'wpjxm_init');
function wpjxm_init() {
wp_enqueue_script('wpjxm_script', plugins_url('js/jx.js', __FILE__), array('jquery'), JX_VERSION);
add_filter('plugin_row_meta', 'wpjxm_plugin_links', 10, 2);
add_action('wp_ajax_nopriv_wpjxm_action', 'wpjxm_action_ajax');
add_action('wp_ajax_wpjxm_action', 'wpjxm_action_ajax');
}
function wpjxm_plugin_links($links, $file) {
if (basename($file) == basename(__FILE__)) {
$links[] = ''.__('Documentation', 'wpjxm_lang').'';
}
return $links;
}
add_action('wp_enqueue_scripts', 'wpjxm_custom_js');
add_action('admin_head', 'wpjxm_custom_js');
function wpjxm_custom_js() {
?>getData()) !== false) {
if (isset($data['jx_action'])) {
if (is_user_logged_in()) {
do_action('jx_'.$data['jx_action'], $jx, $data);
} else {
do_action('jx_nopriv_'.$data['jx_action'], $jx, $data);
}
echo $jx->getJSON();
exit();
}
}
}
if (!class_exists('wpjxmResponse')) {
class wpjxmResponse {
public $data = array();
protected $xresponse = array();
function console($msg) {
$this->xresponse[] = array('cn', $msg);
}
function alert($msg) {
$this->xresponse[] = array('al', $msg);
}
function html($id, $data) {
$this->xresponse[] = array('as', $id, $data);
}
function redirect($url = '', $delay = 0) {
$this->xresponse[] = array('rd', $url, $delay);
}
function reload(){
$this->xresponse[] = array('rl');
}
function script($script = '') {
$this->xresponse[] = array('js', $script);
}
function variable($var, $value) {
$this->xresponse[] = array('vr', $var, $value);
}
function setResponse($a) {
$this->xresponse = $a;
}
function getJSON() {
return json_encode($this->xresponse);
}
function getData() {
if ((isset($_POST['__xr'])) && ($_POST['__xr'] == 1)) {
$post = isset($_POST['z']) ? json_decode(stripslashes($_POST['z']), true) : array();
$this->data = $post;
return $post;
} else {
return false;
}
}
}
}