. * * @copyright 2013-2016 * @license GPL v3 * @version 1.6.5 * @package AJAX Manufactory * @author Epsilon Web Manufactory */ define('JX_VERSION', '1.6.5'); 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_0'); add_action('wp_ajax_wpjxm_action', 'wpjxm_action_ajax_1'); } 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() { ?>has_priv = $has_priv; if (($data = $jx->getData()) !== false) { if (isset($data['jx_action'])) { do_action('jx_'.$data['jx_action'], $jx, $data); echo $jx->getJSON(); exit(); } } } function wpjxm_action_ajax_0() { wpjxm_action_ajax(false); } function wpjxm_action_ajax_1() { wpjxm_action_ajax(true); } if (!class_exists('wpjxmResponse')) { class wpjxmResponse { public $data = array(); public $has_priv = false; protected $xresponse = array(); public function console($msg) { $this->xresponse[] = array('cn', $msg); } public function alert($msg) { $this->xresponse[] = array('al', $msg); } public function html($id, $data) { $this->xresponse[] = array('as', $id, $data); } public function redirect($url = '', $delay = 0) { $this->xresponse[] = array('rd', $url, $delay); } public function reload(){ $this->xresponse[] = array('rl'); } public function script($script = '') { $this->xresponse[] = array('js', $script); } public function call($function_name, $params = array()) { $this->xresponse[] = array('cl', $function_name, $params); } public function variable($var, $value) { $this->xresponse[] = array('vr', $var, $value); } public function variables($vars) { $this->xresponse[] = array('vs', $vars); } public function trigger($name, $vars = array()) { $this->xresponse[] = array('tr', $name, $vars); } public function setResponse($a) { $this->xresponse = $a; } public function getJSON() { return json_encode($this->xresponse); } public 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; } } } }