public function on_add_scripts() { parent::on_add_scripts(); // default scripts: jquery, backbone, underscore $this->add_existed_script('jquery'); $this->add_existed_script('underscore'); $this->add_existed_script('backbone'); $this->add_script('site-core', ae_get_url() . '/assets/js/appengine.js', array('jquery', 'backbone', 'underscore', 'plupload')); $this->add_script('site-functions', TEMPLATEURL . '/js/functions.js', array('jquery', 'backbone', 'underscore')); $this->add_script('bootstrap', TEMPLATEURL . '/js/libs/bootstrap.min.js'); $this->add_script('modernizr', TEMPLATEURL . '/js/libs/modernizr.js', array('jquery')); //$this->add_script('adjector', TEMPLATEURL . '/js/libs/adjector.js','jquery'); $this->add_script('rotator', TEMPLATEURL . '/js/libs/jquery.simple-text-rotator.min.js', 'jquery'); $this->add_script('jquery-validator', TEMPLATEURL . '/js/libs/jquery.validate.min.js', 'jquery'); $this->add_existed_script('jquery-ui-autocomplete'); //enqueue google recaptcha scripts if (ae_get_option('gg_captcha')) { $this->add_script('recaptcha', '//www.google.com/recaptcha/api.js'); } if (et_load_mobile()) { return; } else { if (ae_get_option('qa_live_notifications')) { $this->add_existed_script('heartbeat'); } $this->add_script('waypoints', TEMPLATEURL . '/js/libs/waypoints.min.js', array('jquery')); $this->add_script('waypoints-sticky', TEMPLATEURL . '/js/libs/waypoints-sticky.js', array('jquery', 'waypoints')); $this->add_script('chosen', TEMPLATEURL . '/js/libs/chosen.jquery.min.js', array('jquery')); $this->add_script('classie', TEMPLATEURL . '/js/libs/classie.js', array('jquery')); $this->add_script('site-script', TEMPLATEURL . '/js/scripts.js', 'jquery'); $this->add_script('site-front', TEMPLATEURL . '/js/front.js', array('jquery', 'underscore', 'backbone', 'site-functions')); //localize scripts wp_localize_script('site-front', 'qa_front', qa_static_texts()); if (is_singular('question') || is_singular('answer')) { $this->add_script('qa-shcore', TEMPLATEURL . '/js/libs/syntaxhighlighter/shCore.js', array('jquery')); $this->add_script('qa-brush-js', TEMPLATEURL . '/js/libs/syntaxhighlighter/shBrushJScript.js', array('jquery', 'qa-shcore')); $this->add_script('qa-brush-php', TEMPLATEURL . '/js/libs/syntaxhighlighter/shBrushPhp.js', array('jquery', 'qa-shcore')); $this->add_script('qa-brush-css', TEMPLATEURL . '/js/libs/syntaxhighlighter/shBrushCss.js', array('jquery', 'qa-shcore')); $this->add_script('single-question', TEMPLATEURL . '/js/single-question.js', array('jquery', 'underscore', 'backbone', 'site-functions', 'site-front')); } if (is_single()) { //enqueue magnific-popup $this->add_script('magnific-popup', TEMPLATEURL . '/js/libs/jquery.magnific-popup.min.js', array('jquery')); } if (is_page_template('page-intro.php')) { $this->add_script('intro', TEMPLATEURL . '/js/intro.js', array('jquery', 'underscore', 'backbone', 'site-functions', 'site-front')); } if (is_author()) { $this->add_existed_script('plupload_all'); $this->add_script('profile', TEMPLATEURL . '/js/profile.js', array('jquery', 'underscore', 'backbone', 'site-functions', 'site-front')); } if (is_page_template('page-pending.php')) { $this->add_script('pending', TEMPLATEURL . '/js/pending.js', array('jquery', 'underscore', 'backbone', 'site-functions', 'site-front')); } } }
function qa_mobile_scripts_styles() { /* ==== PRINT SCRIPTS ==== */ wp_enqueue_script('mobile-front', TEMPLATEURL . '/mobile/js/front.js', array('jquery', 'underscore', 'backbone', 'site-functions')); wp_enqueue_script('mouseweel', TEMPLATEURL . '/mobile/js/jquery.mouseweel.js', array('jquery')); wp_enqueue_script('mobile-script', TEMPLATEURL . '/mobile/js/script-mobile.js', array('jquery')); wp_enqueue_script('mobile-script', TEMPLATEURL . '/js/libs/adjector.js', array('jquery')); //localize scripts wp_localize_script('mobile-front', 'qa_front', qa_static_texts()); if (is_singular('question')) { wp_enqueue_script('mobile-single-question', TEMPLATEURL . '/mobile/js/single-question.js', array('jquery', 'underscore', 'backbone', 'site-functions', 'mobile-front')); } /* ==== PRINT STYLES ==== */ wp_enqueue_style('mobile-style', TEMPLATEURL . '/mobile/css/main.css', array('bootstrap')); }
/** * Perform login ajax request * @param username (or email) * @param password */ public function login() { $args = $_POST['content']; $user_facetory = QA_Member::get_instance(); // find user by username $userdata = get_user_by('login', $args['username']); // if no username found, find by email if ($userdata == false) { $userdata = get_user_by('email', $args['username']); } // user is still not found, return error if ($userdata == false) { return array('success' => false, 'code' => 401, 'msg' => __('Your login information was incorrect. Please try again.', ET_DOMAIN)); } if (get_user_meta($userdata->ID, 'register_status', true) == "unconfirm") { $static = qa_static_texts(); return array('success' => false, 'code' => 401, 'msg' => $static['texts']['confirm_account']); } // if user is banned, return error if ($user_facetory->is_ban($userdata->ID)) { $ban_info = $user_facetory->get_ban_info($userdata->ID); return array('success' => false, 'code' => 401, 'banned' => true, 'msg' => sprintf(__('Your account has been banned. Reason "%s". Expired on "%s".', ET_DOMAIN), $ban_info['note'], $ban_info['expired'])); } $remember = $args['remember'] == 1 ? true : false; // if nothing wrong, continue $user = et_login($args['username'], $args['password'], $remember); if (is_wp_error($user)) { // apply login by email here $user = et_login_by_email($args['username'], $args['password'], $remember); } // get new data of user if (!is_wp_error($user)) { $userdata = QA_Member::convert($user); } // generate new nonces $nonce = array('reply_thread' => wp_create_nonce('insert_reply'), 'upload_img' => wp_create_nonce('et_upload_images')); if (!is_wp_error($user)) { $resp = array('success' => true, 'code' => 200, 'msg' => __('You have logged in successfully', ET_DOMAIN), 'redirect' => get_post_type_archive_link('question'), 'data' => array('user' => $userdata, 'nonce' => $nonce)); } else { $resp = array('success' => false, 'code' => 401, 'msg' => __('Your login information was incorrect. Please try again.', ET_DOMAIN)); } return $resp; }