public static function initialize() { if (!CMA::isLicenseOk()) { return; } self::addAjaxHandler('cma-follow-new-threads', array(__CLASS__, 'ajaxHandler')); }
/** * Widget options form * @param WP_Widget $instance */ public function form($instance) { if (isset($instance['title'])) { $title = $instance['title']; } else { $title = CMA::__('Login'); } $limit = isset($instance['limit']) ? $instance['limit'] : 10; ?> <p> <label for="<?php echo esc_attr($this->get_field_name('title')); ?> "><?php _e('Title:'); ?> </label> <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?> " name="<?php echo esc_attr($this->get_field_name('title')); ?> " type="text" value="<?php echo esc_attr($title); ?> " /> </p> <?php }
public static function init() { if (!CMA::isLicenseOk()) { return; } add_shortcode('CMA-question-form', array(__CLASS__, 'shortcode')); add_shortcode('cma-question-form', array(__CLASS__, 'shortcode')); }
static function addHeader() { if (!CMA_Thread::canPostQuestions()) { self::addMessage(self::MESSAGE_ERROR, 'You cannot post questions.'); wp_redirect(CMA::getReferer()); } self::loadScripts(); }
/** * settings_screen() is the catch-all method for displaying the content * of the edit, create, and Dashboard admin panels */ function settings_screen($group_id = NULL) { $categories = CMA_Category::getCategoriesTree(null, 0, $onlyVisible = false); $currentCategory = $this->getRelatedCategory(); $options = '<option value="">-- none --</option>'; foreach ($categories as $categoryId => $categoryName) { $options .= sprintf('<option value="%s"%s>%s</option>', esc_attr($categoryId), selected($categoryId, $currentCategory, false), esc_html($categoryName)); } printf('<p><label for="cma-category">%s</label> <select name="cma-category" id="cma-category">%s</select></p>', CMA::__('Related CM Answers category'), $options); }
public static function displayAdminWarning($class = null) { if (empty($class)) { $class = 'error'; } $reasons = ''; foreach (self::$checkConfigFilters as $filter => $msg) { if (!apply_filters($filter, FALSE)) { $reasons .= sprintf('<li>%s</li>', CMA::__($msg)); } } printf('<div class="%s"><p>%s</p><ul style="list-style:disc;margin:0 0 1em 2em;">%s</ul><p>%s</p></div>', esc_attr($class), CMA::__('<strong>CM Answers Pro</strong> would not integrate with the <strong>CM Micropayments</strong> plugin because of the following reasons:'), $reasons, sprintf('<a href="%s" class="button">%s</a>', esc_attr(admin_url('admin.php?page=cm-micropayment-platform-settings')), CMA::__('CM Micropayments Settings'))); }
protected function getLogDefaults() { $defaults = array(self::FIELD_LOG_TYPE => static::LOG_TYPE, self::FIELD_CREATED => Date('Y-m-d H:i:s')); // Add ip addr if (!empty($_SERVER['REMOTE_ADDR'])) { $defaults[self::FIELD_IP_ADDR] = $_SERVER['REMOTE_ADDR']; } // Add current user data if ($userId = CMA::getPostingUserId()) { $user = get_userdata($userId); $defaults[self::FIELD_USER_ID] = $userId; } return $defaults; }
public static function init() { if (!CMA::isLicenseOk()) { return; } add_action('init', array(__CLASS__, 'add_rewrite_endpoint')); add_shortcode('cma-my-questions', array(__CLASS__, 'shortcode_my_questions')); add_shortcode('cma-my-answers', array(__CLASS__, 'shortcode_my_answers')); add_shortcode('cma-answers', array(__CLASS__, 'shortcode_answers')); add_shortcode('cma-questions', array(__CLASS__, 'shortcode_questions')); add_shortcode('cma-comments', array(__CLASS__, 'shortcode_comments')); add_shortcode('cma-categories', array(__CLASS__, 'shortcode_categories')); add_shortcode('cma-categories-list', array(__CLASS__, 'shortcode_categories_list')); add_shortcode('cma-index', array(__CLASS__, 'shortcode_index')); // add_action('wp_enqueue_scripts', array(__CLASS__,'addStyles')); }
public static function initialize() { add_action('cma_category_edit_form_fields', array(__CLASS__, 'categoryEditFormAccess')); add_action('cma_category_add_form_fields', array(__CLASS__, 'categoryEditFormAccess')); add_action('cma_category_edit_form_fields', array(__CLASS__, 'categoryEditFormExperts')); add_action('cma_category_add_form_fields', array(__CLASS__, 'categoryEditFormExperts')); add_action('cma_category_edit_form_fields', array(__CLASS__, 'categoryEditFormFields')); add_action('cma_category_add_form_fields', array(__CLASS__, 'categoryEditFormFields')); add_action('edited_cma_category', array(__CLASS__, 'categoryAfterSave'), 10, 2); add_action('created_cma_category', array(__CLASS__, 'categoryAfterSave'), 10, 2); add_action('cma_question_form_category_custom_fields', array(__CLASS__, 'questionForm'), 10, 2); add_action('cma_question_post_after', array(__CLASS__, 'threadSaveAfter'), 10, 2); add_action('cma_question_update_after', array(__CLASS__, 'threadSaveAfter'), 10, 1); self::addAjaxHandler('cma_load_category_custom_fields', array(__CLASS__, 'loadCustomFields')); if (!CMA::isLicenseOk()) { return; } }
public function getViewData() { return array('question-id' => $this->getId(), 'permalink' => $this->getPermalink(), 'favorite' => intval($this->isFavorite()), 'favorite-enabled' => intval(CMA_Settings::getOption(CMA_Settings::OPTION_ENABLE_MARK_FAVORITE_QUESTIONS)), 'favorite-nonce' => wp_create_nonce('cma_favorite_question'), 'rating' => $this->getPostRating(), 'rating-enabled' => intval(CMA_Settings::getOption(CMA_Settings::OPTION_ENABLE_QUESTION_RATING)), 'rating-nonce' => wp_create_nonce('cma_rate_thread_' . $this->getId()), 'rating-negative-allowed' => intval(CMA_Settings::getOption(CMA_Settings::OPTION_NEGATIVE_RATING_ALLOWED)), 'resolve-enabled' => intval(CMA_Settings::getOption(CMA_Settings::OPTION_RESOLVE_THREAD_ENABLED)), 'can-resolve' => intval($this->canResolve()), 'can-spam' => intval($this->canMarkSpam()), 'spam' => intval($this->isMarkedAsSpam()), 'spam-nonce' => wp_create_nonce('cma_report_spam'), 'can-delete' => intval($this->canDelete()), 'can-subscribe' => intval($this->canSubscribe()), 'is-follower' => intval($this->getFollowersEngine()->isFollower()), 'backlink' => base64_encode(CMA::getReferer())); }
/** * Render widget * * @param array $args * @param WP_Widget $instance */ public function widget($args, $instance) { extract($args, EXTR_SKIP); if (empty($instance['title'])) { $instance['title'] = CMA::__(self::DEFAULT_TITLE); } if (empty($instance['limit'])) { $instance['limit'] = self::DEFAULT_LIMIT; } $title = apply_filters('widget_title', $instance['title']); $limit = $instance['limit']; echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } ?> <div class="cma-tags-container"> <?php $terms = self::get_terms_by_post_type(array('post_tag'), array('cma_thread')); if (!empty($terms)) { $qs = '?'; if (isset($_GET["sort"])) { $qs .= 'sort=' . urlencode($_GET["sort"]) . "&"; } if (isset($_GET["s"])) { $qs .= 's=' . urlencode($_GET["s"]) . "&"; } foreach ($terms as $term) { $url = get_post_type_archive_link(CMA_Thread::POST_TYPE) . $qs . 'cmatag=' . urlencode($term->slug); printf('<div><a href="%s">%s</a> <span>(%d)</span></div>', esc_attr($url), esc_html($term->name), esc_html($term->cnt)); if (--$limit <= 0) { break; } } } else { echo 'No tags'; } ?> </div> <?php echo $after_widget; }
public static function notifyAllUsers() { global $wpdb; if (!empty($_GET['nonce']) and wp_verify_nonce($_GET['nonce'], CMA_BaseController::ADMIN_BP_NOTIFY)) { $usersIds = $wpdb->get_col("SELECT ID FROM {$wpdb->users}"); if (!empty($_GET['post_id']) and $thread = CMA_Thread::getInstance($_GET['post_id'])) { $notification = array('item_id' => $thread->getId(), 'secondary_item_id' => 0, 'component_name' => 'cma_notifier', 'component_action' => self::ACTION_NOTIFICATION_THREAD, 'date_notified' => bp_core_current_time(), 'is_new' => 1, 'allow_duplicate' => true); foreach ($usersIds as $userId) { if ($thread->isVisible($userId)) { $notification['user_id'] = $userId; bp_notifications_add_notification($notification); } } } if (!empty($_GET['comment_id']) and $answer = CMA_Answer::getById($_GET['comment_id'])) { $notification = array('item_id' => $answer->getId(), 'secondary_item_id' => 0, 'component_name' => 'cma_notifier', 'component_action' => self::ACTION_NOTIFICATION_ANSWER, 'date_notified' => bp_core_current_time(), 'is_new' => 1, 'allow_duplicate' => true); foreach ($usersIds as $userId) { if ($answer->isVisible($userId)) { $notification['user_id'] = $userId; bp_notifications_add_notification($notification); } } } } wp_safe_redirect(CMA::getReferer()); exit; }
/** * Get plugin's version. * * @return string|null */ public static function version() { if (!empty(self::$version)) { return self::$version; } else { $readme = file_get_contents(CMA_PATH . '/readme.txt'); preg_match('/Stable tag\\: ([0-9\\.]+)/i', $readme, $match); if (isset($match[1])) { self::$version = $match[1]; return $match[1]; } } }
public static function getLocalized($labelKey) { return CMA::__(self::getLabel($labelKey)); }
\t<div class="form-field"> \t\t<label for="cma_experts">%s</label> \t\t%s \t</div> HTML; } $listItem = <<<HTML <li data-user-id="%d" data-user-login="******"> \t<a href="%s">%s</a> <a href="" class="btn-list-remove">×</a> \t<input type="hidden" name="%s[]" value="%d" /> </li> HTML; $list = ''; foreach ($experts as $userId) { if ($user = get_userdata($userId)) { $list .= sprintf($listItem, intval($userId), $user->user_login, esc_attr(get_edit_user_link($userId)), esc_html($user->user_login), 'cma_experts', intval($userId)); } } $content = <<<HTML \t<div class="cma_experts"> \t\t<div class="suggest-user" data-field-name="%s"> \t\t\t<ul>%s</ul> \t\t\t<div><span>%s:</span><input type="text" /> <input type="button" value="%s" /></div> \t\t\t<input type="hidden" name="cma_experts_nonce" value="%s" /> \t\t</div> \t\t<p class="description">%s</p> \t</div> HTML; $content = sprintf($content, 'cma_experts', $list, CMA::__('Find user'), esc_attr(CMA::__('Add')), wp_create_nonce('cma_experts_nonce'), CMA::__('Experts will receive notifications about new questions.')); printf($template, CMA::__('Select experts'), $content);
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ load_plugin_textdomain('cm-answers', false, dirname(plugin_basename(__FILE__)) . '/lang'); if (version_compare('5.3', phpversion(), '>')) { die(sprintf(__('We are sorry, but you need to have at least PHP 5.3 to run this plugin (currently installed version: %s) - please upgrade or contact your system administrator.'), phpversion())); } //Define constants define('CMA_PREFIX', 'CMA_'); define('CMA_PATH', WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__))); define('CMA_URL', plugins_url('', __FILE__)); define('CMA_PLUGIN_FILE', __FILE__); //Init the plugin require_once CMA_PATH . '/lib/CMA.php'; require_once CMA_PATH . '/lib/models/Labels.php'; require_once CMA_PATH . '/lib/models/Answer.php'; require_once CMA_PATH . '/lib/models/Category.php'; require_once CMA_PATH . '/lib/helpers/BuddyPress.php'; register_activation_hook(__FILE__, array('CMA', 'install')); register_uninstall_hook(__FILE__, array('CMA', 'uninstall')); CMA::init();
static function getLocalized($msg) { return CMA::__($msg); }
public static function getExpertsTermTaxonomyIds($userId = null) { global $wpdb; if (is_null($userId)) { $userId = CMA::getPostingUserId(); } if (empty($userId)) { $userId = 0; } static $results = array(); if (empty($results[$userId])) { $expertsConditions = $wpdb->prepare(" OR o.option_name = CONCAT(%s, tt.term_id, %s)", CMA_Category::OPTION_EXPERTS_PREFIX . '_', '_' . intval(get_current_user_id())); $sql = $wpdb->prepare("SELECT tt.term_taxonomy_id\n \t\t\tFROM {$wpdb->term_taxonomy} tt\n \t\t\tLEFT JOIN {$wpdb->options} o ON o.option_name LIKE CONCAT(%s, tt.term_id, '\\_%%')\n \t\t\tWHERE tt.taxonomy = %s\n \t\t\tAND (o.option_id IS NULL {$expertsConditions})\n \t\t\t", self::OPTION_EXPERTS_PREFIX . '_', self::TAXONOMY); $results[$userId] = $wpdb->get_col($sql); } return $results[$userId]; }
public static function old_update() { global $wpdb; $oldVersion = get_option(CMA::OPTION_VERSION); if (empty($oldVersion)) { return; } $currentVersion = CMA::version(); if (empty($oldVersion) or version_compare($oldVersion, $currentVersion, '<')) { update_option(CMA::OPTION_VERSION, $currentVersion); if (version_compare($oldVersion, '2.1.6', '<')) { // Update comment_type $commentsIds = $wpdb->get_col($wpdb->prepare("SELECT `{$wpdb->comments}`.`comment_ID`\n\t\t\t\t\tFROM `{$wpdb->comments}`\n\t\t\t\t\tLEFT JOIN `{$wpdb->posts}` ON `{$wpdb->comments}`.`comment_post_ID` = `{$wpdb->posts}`.`ID`\n\t\t\t\t\tWHERE `{$wpdb->posts}`.`post_type` = %s AND `{$wpdb->comments}`.`comment_type` = ''", CMA_Thread::POST_TYPE)); $data = array('comment_type' => CMA_Answer::COMMENT_TYPE); foreach ($commentsIds as $comment_ID) { $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID')); } } // Update new post meta: question+answers votes count if (version_compare($oldVersion, '2.1.7', '<')) { $posts = get_posts(array('post_type' => CMA_Thread::POST_TYPE)); foreach ($posts as $post) { $thread = CMA_Thread::getInstance($post->ID); update_post_meta($post->ID, CMA_Thread::$_meta['votes_question'], 0); $thread->updateRatingCache(); } } // Update users counters if (version_compare($oldVersion, '2.1.9', '<=')) { CMA_Thread::updateAllQA(); } if (version_compare($oldVersion, '2.1.13', '<=')) { // Create logs records for old posts $posts = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_type = %s", CMA_Thread::POST_TYPE)); $postsLog = new CMA_QuestionPostLog(); foreach ($posts as $post) { $count = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM ' . $postsLog->getMetaTableName() . ' m JOIN ' . $postsLog->getTableName() . ' l ON l.id = m.log_id WHERE m.meta_name = %s AND m.meta_value = %s AND l.log_type = %s', CMA_QuestionPostLog::META_QUESTION_ID, (string) $post->ID, CMA_QuestionPostLog::LOG_TYPE)); if ($count == 0) { $postsLog->create(array(CMA_Log::FIELD_CREATED => $post->post_date, CMA_Log::FIELD_USER_ID => $post->post_author, CMA_Log::FIELD_IP_ADDR => NULL), array(CMA_QuestionPostLog::META_QUESTION_ID => $post->ID)); } } // Create logs records for old comments $answers = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_type = %s", CMA_Answer::COMMENT_TYPE)); $answersLog = new CMA_AnswerPostLog(); foreach ($answers as $answer) { $count = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM ' . $answersLog->getMetaTableName() . ' m JOIN ' . $answersLog->getTableName() . ' l ON l.id = m.log_id WHERE m.meta_name = %s AND m.meta_value = %s AND l.log_type = %s', CMA_QuestionPostLog::META_QUESTION_ID, (string) $answer->comment_ID, CMA_AnswerPostLog::LOG_TYPE)); if ($count == 0) { $postsLog->create(array(CMA_Log::FIELD_CREATED => $answer->comment_date, CMA_Log::FIELD_USER_ID => $answer->user_id, CMA_Log::FIELD_IP_ADDR => NULL), array(CMA_AnswerPostLog::META_QUESTION_ID => $answer->comment_post_ID, CMA_AnswerPostLog::META_ANSWER_ID => $answer->comment_ID)); } } } if (version_compare($oldVersion, '2.2.2', '<=')) { // Votes for questions $metaKeys = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s", CMA_Thread::$_meta['usersRated'])); foreach ($metaKeys as $mk) { $value = @unserialize($mk->meta_value); if (is_array($value)) { $value = array_filter($value); foreach ($value as $userId) { add_post_meta($mk->post_id, CMA_Thread::$_meta['usersRated'], $userId, $uniq = false); } $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE meta_id = %d", $mk->meta_id)); } } // Votes for answers $metaKeys = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->commentmeta} WHERE meta_key = %s", CMA_Answer::META_USERS_RATED)); foreach ($metaKeys as $mk) { $value = @unserialize($mk->meta_value); if (is_array($value)) { $value = array_filter($value); foreach ($value as $userId) { add_comment_meta($mk->comment_id, CMA_Answer::META_USERS_RATED, $userId, $uniq = false); } $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->commentmeta} WHERE meta_id = %d", $mk->meta_id)); } } } } }
/** * Render widget * * @param array $args * @param WP_Widget $instance */ public function widget($args, $instance) { extract($args, EXTR_SKIP); if (empty($instance['title'])) { $instance['title'] = CMA::__(self::DEFAULT_TITLE); } if (empty($instance['limit'])) { $instance['limit'] = self::DEFAULT_LIMIT; } $title = apply_filters('widget_title', $instance['title']); $limit = $instance['limit']; $displayNumber = isset($instance['displayNumber']) ? $instance['displayNumber'] : self::DISPLAY_NUMBER_ANSWERS; echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } ?> <div class="cma-tags-container"><?php $contributors = $this->getContributors($displayNumber, $limit); foreach ($contributors as $c) { echo '<div>'; if (empty($c->user_id)) { echo $c->display_name; } else { printf('<a href="%s">%s</a>', esc_attr(CMA_BaseController::getContributorUrl($c->user_id)), esc_html($c->display_name)); } if ($displayNumber != self::DISPLAY_NONE) { printf(' <span>%d %s</span>', intval($c->cnt), strtolower(CMA_Labels::getLocalized($displayNumber))); } echo '</div>'; } ?> </div> <?php echo $after_widget; }
static function getDefaultTitle() { return CMA::__('Answers Stats'); }
public function getStatus() { return CMA::__($this->isApproved() ? 'approved' : 'pending'); }
public static function processClearDatabase() { if (isset($_GET['flush_cma_db']) && $_GET['flush_cma_db'] == 1 and !empty($_GET['nonce']) and wp_verify_nonce($_GET['nonce'], self::ADMIN_SETTINGS)) { CMA::flushDatabase(); wp_redirect(admin_url('plugins.php')); exit; } }
public function getAuthorLink($simple = false) { if ($user = $this->getAuthor()) { return $simple ? $user->link : $user->richLink; } else { if ($author = $this->getCommentAuthor()) { return $author; } else { return CMA::__('unknown'); } } }
require_once CMA_PATH . '/lib/helpers/Update.php'; require_once CMA_PATH . '/lib/helpers/Widgets/WidgetAbstract.php'; require_once CMA_PATH . '/lib/helpers/Widgets/CountersWidget.php'; require_once CMA_PATH . '/lib/helpers/Widgets/TagsWidget.php'; require_once CMA_PATH . '/lib/helpers/Widgets/LoginWidget.php'; require_once CMA_PATH . '/lib/helpers/Widgets/RelatedQuestionsWidget.php'; require_once CMA_PATH . '/lib/helpers/Widgets/TopContributorsWidget.php'; require_once CMA_PATH . '/lib/helpers/meta-box/RelatedQuestionsMetaBox.php'; require_once CMA_PATH . '/lib/helpers/shortcodes/QuestionForm.php'; require_once CMA_PATH . '/lib/helpers/StickyQuestion.php'; require_once CMA_PATH . '/lib/helpers/UserRelatedQuestions.php'; require_once CMA_PATH . '/lib/helpers/IPGeolocation.php'; require_once CMA_PATH . '/lib/controllers/BaseController.php'; require_once CMA_PATH . '/lib/controllers/AnswerController.php'; require_once CMA_PATH . '/lib/models/Settings.php'; require_once CMA_PATH . '/lib/models/Labels.php'; require_once CMA_PATH . '/lib/helpers/FollowersEngine.php'; require_once CMA_PATH . '/lib/helpers/VideoHelper.php'; require_once CMA_PATH . '/lib/models/Category.php'; require_once CMA_PATH . '/lib/models/PrivateQuestion.php'; require_once CMA_PATH . '/lib/controllers/LogsController.php'; require_once CMA_PATH . '/lib/models/Thread.php'; require_once CMA_PATH . '/lib/helpers/MicroPayments/MicroPayments.php'; require_once CMA_PATH . '/lib/helpers/SettingsViewAbstract.php'; require_once CMA_PATH . '/lib/helpers/Ads.php'; require_once CMA_PATH . '/lib/helpers/BuddyPress.php'; require_once CMA_PATH . '/lib/controllers/AnswerController.php'; //Init the plugin require_once CMA_PATH . '/lib/CMA.php'; CMA::init(__FILE__);
protected static function _processCommentDelete() { header('content-type: application/json'); $response = array('success' => 0, 'msg' => CMA::__('An error occured.')); $commentId = self::_getParam('cma-comment-id'); if (empty($_POST['nonce']) or !wp_verify_nonce($_POST['nonce'], 'cma_comment_delete')) { $response['msg'] = CMA::__('Invalid nonce.'); } else { if ($commentId and $comment = CMA_Comment::getById($commentId)) { $comment->trash(); $response = array('success' => 1, 'msg' => CMA::__('Comment moved to trash.')); } } echo json_encode(apply_filters('cma_comment_delete_ajax_response', $response)); exit; }
<?php if (!empty($term)) { $template = <<<HTML \t<tr class="form-field"> \t\t<th scope="row"><label for="cma_custom_fields">%s</label></th> \t\t<td>%s</td> \t</tr> HTML; } else { $template = <<<HTML \t<div class="form-field"> \t\t<label for="cma_custom_fields">%s</label> \t\t%s \t</div> HTML; } $items = ''; for ($i = 0; $i < CMA_Category::CUSTOM_FIELDS_NUMBER; $i++) { $items .= sprintf('<label>Custom field %d: <input type="text" name="%s[%d]" value="%s" /></label><br />', $i + 1, CMA_CategoryController::FIELD_CUSTOM_FIELDS, $i, $fields[$i]); } $content = <<<HTML \t<div class="cma_custom_fields"> \t\t%s \t\t<input type="hidden" name="%s" value="%s" /> \t</div> HTML; $content = sprintf($content, $items, CMA_CategoryController::NONCE_CUSTOM_FIELDS, wp_create_nonce(CMA_CategoryController::NONCE_CUSTOM_FIELDS)); printf($template, CMA::__('Custom fields for new questions'), $content);
protected static function _processPrivateQuestionSend() { header('content-type: application/json'); try { $nonce = self::_getParam('nonce'); if (!CMA_Settings::getOption(CMA_Settings::OPTION_PRIVATE_QUESTIONS_ENABLED)) { throw new Exception(serialize(array('global' => CMA::__('Private questions are disabled.')))); } else { if (empty($nonce) or !wp_verify_nonce($nonce, 'private_question')) { throw new Exception(serialize(array('global' => CMA::__('Invalid nonce.')))); } else { if (CMA_PrivateQuestion::send(get_current_user_id(), self::_getParam('user'), self::_getParam('title'), self::_getParam('question'))) { echo json_encode(array('success' => 1, 'msg' => CMA_Labels::getLocalized('private_question_sent_success'))); } else { throw new Exception(serialize(array('email' => CMA::__('Cannot send email. Please try again.')))); } } } } catch (Exception $e) { echo json_encode(array('success' => 0, 'msg' => CMA::__('An error occured.'), 'errors' => unserialize($e->getMessage()))); } exit; }