function add_js($hook) { //needed in all the wordpress admin pages including wysija's ones $jstrans = array(); wp_register_script('wysija-charts', 'https://www.google.com/jsapi', array('jquery'), true); wp_register_script('wysija-admin-list', WYSIJA_URL . 'js/admin-listing.js', array('jquery'), true, WYSIJA::get_version()); wp_register_script('wysija-base-script-64', WYSIJA_URL . 'js/base-script-64.js', array('jquery'), true, WYSIJA::get_version()); wp_enqueue_style('wysija-admin-css-widget', WYSIJA_URL . 'css/admin-widget.css', array(), WYSIJA::get_version()); // If Cron enabled sending, send Mixpanel data and reset flag. $model_config = WYSIJA::get('config', 'model'); if ($model_config->getValue('send_analytics_now') == 1) { $analytics = new WJ_Analytics(); $analytics->generate_data(); $analytics->send(); // Reset sending flag. $model_config->save(array('send_analytics_now' => 0)); } //we are in wysija's admin interface if (WYSIJA_ITF) { wp_enqueue_style('wysija-admin-css-global', WYSIJA_URL . 'css/admin-global.css', array(), WYSIJA::get_version()); wp_enqueue_script('wysija-admin-js-global', WYSIJA_URL . 'js/admin-wysija-global.js', array(), WYSIJA::get_version()); $pagename = str_replace('wysija_', '', $_REQUEST['page']); $backloader = WYSIJA::get('backloader', 'helper'); $backloader->init($this->controller); //$this->controller->jsTrans["ignoremsg"]=__('Are you sure you want to ignore this message?.',WYSIJA); $jstrans = $this->controller->jsTrans; //if(!in_array('wysija-admin-ajax-proto',$this->controller->js)) $this->controller->js[]='wysija-admin-ajax'; $jstrans['gopremium'] = __('Go Premium!', WYSIJA); //enqueue all the scripts that have been declared in the controller $backloader->parse_js($this->controller, $pagename, WYSIJA_URL); //this will load automatically existing scripts and stylesheets based on the page and action parameters $backloader->load_assets($pagename, WYSIJA_DIR, WYSIJA_URL, $this->controller); //add some translation $backloader->localize($pagename, WYSIJA_DIR, WYSIJA_URL, $this->controller); // add rtl support if (is_rtl()) { wp_enqueue_style('wysija-admin-rtl', WYSIJA_URL . 'css/rtl.css', array(), WYSIJA::get_version()); } } $jstrans['newsletters'] = __('Newsletters', WYSIJA); $jstrans['urlpremium'] = 'admin.php?page=wysija_config#tab-premium'; if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'wysija_config') { $jstrans['urlpremium'] = '#tab-premium'; } wp_localize_script('wysija-admin', 'wysijatrans', $jstrans); }
function add_js($hook) { $jstrans = array(); wp_register_script('wysija-charts', 'https://www.google.com/jsapi', array('jquery'), true); wp_register_script('wysija-admin-list', WYSIJA_URL . 'js/admin-listing.js', array('jquery'), true, WYSIJA::get_version()); wp_register_script('wysija-base-script-64', WYSIJA_URL . 'js/base-script-64.js', array('jquery'), true, WYSIJA::get_version()); wp_enqueue_style('wysija-admin-css-widget', WYSIJA_URL . 'css/admin-widget.css', array(), WYSIJA::get_version()); $model_config =& WYSIJA::get('config', 'model'); if ($model_config->getValue('send_analytics_now') == 1) { require_once WYSIJA_CLASSES . 'autoloader.php'; $analytics = new WJ_Analytics(); $analytics->generate_data(); $analytics->send(); $model_config->save(array('send_analytics_now' => 0)); } if (WYSIJA_ITF) { wp_enqueue_style('wysija-admin-css-global', WYSIJA_URL . 'css/admin-global.css', array(), WYSIJA::get_version()); wp_enqueue_script('wysija-admin-js-global', WYSIJA_URL . 'js/admin-wysija-global.js', array(), WYSIJA::get_version()); $pagename = str_replace('wysija_', '', $_REQUEST['page']); $backloader =& WYSIJA::get('backloader', 'helper'); $backloader->initLoad($this->controller); $jstrans = $this->controller->jsTrans; $jstrans['gopremium'] = __('Go Premium!', WYSIJA); $backloader->jsParse($this->controller, $pagename, WYSIJA_URL); $backloader->loadScriptsStyles($pagename, WYSIJA_DIR, WYSIJA_URL, $this->controller); $backloader->localize($pagename, WYSIJA_DIR, WYSIJA_URL, $this->controller); } $jstrans['newsletters'] = __('Newsletters', WYSIJA); $jstrans['urlpremium'] = 'admin.php?page=wysija_config#tab-premium'; if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'wysija_config') { $jstrans['urlpremium'] = '#tab-premium'; } wp_localize_script('wysija-admin', 'wysijatrans', $jstrans); }