Example #1
0
 /**
  * Sets up the extended comments class
  *
  * @param string comment_type	The custom comment type
  *
  * @return void
  */
 public static function init($comment_type)
 {
     if (!$comment_type) {
         trigger_error('No custom comment type defined.', E_USER_WARNING);
     }
     self::$comment_type = $comment_type;
     add_filter('comment_notification_recipients', array(__CLASS__, 'notify_email_recipients'), 999, 2);
     add_filter('comment_moderation_recipients', array(__CLASS__, 'notify_email_recipients'), 999, 2);
     add_filter('comment_notification_headers', array(__CLASS__, 'notify_email_headers'), 999, 2);
     add_filter('comment_moderation_headers', array(__CLASS__, 'notify_email_headers'), 999, 2);
     add_filter('comment_notification_subject', array(__CLASS__, 'notify_email_subject'), 999, 2);
     add_filter('comment_moderation_subject', array(__CLASS__, 'notify_email_subject'), 999, 2);
     add_filter('comment_notification_text', array(__CLASS__, 'notify_email_text'), 999, 2);
     add_filter('comment_moderation_text', array(__CLASS__, 'notify_email_text'), 999, 2);
 }
Example #2
0
 /**
  * Handles adding reports via ajax
  *
  * @return void
  */
 public static function ajax_add_report()
 {
     if ('POST' != $_SERVER['REQUEST_METHOD']) {
         die(json_encode(array('success' => false, 'message' => __('Sorry, only post method allowed.', APP_TD))));
     }
     $id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
     if ($id < 1) {
         die(json_encode(array('success' => false, 'message' => __('Sorry, item does not exist.', APP_TD))));
     }
     if (!isset($_POST['type']) || !in_array($_POST['type'], array('post', 'user'))) {
         die(json_encode(array('success' => false, 'message' => __('Sorry, invalid item type.', APP_TD))));
     }
     if ($_POST['type'] == 'user' && !appthemes_reports_get_args('users')) {
         die(json_encode(array('success' => false, 'message' => __('Sorry, invalid item type.', APP_TD))));
     }
     if (!isset($_POST['report']) || appthemes_clean($_POST['report']) != $_POST['report']) {
         die(json_encode(array('success' => false, 'message' => __('Sorry, invalid report message.', APP_TD))));
     }
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'add-report')) {
         die(json_encode(array('success' => false, 'message' => __('Sorry, invalid request.', APP_TD))));
     }
     $item = $_POST['type'] == 'post' ? get_post($id) : get_userdata($id);
     if (!$item) {
         die(json_encode(array('success' => false, 'message' => __('Sorry, item does not exist.', APP_TD))));
     }
     $options = appthemes_load_reports_options();
     if ($options->get(array('reports', 'users_only')) && !is_user_logged_in()) {
         die(json_encode(array('success' => false, 'message' => __('Sorry, only registered users can report.', APP_TD))));
     }
     $comment = array('comment_content' => appthemes_clean($_POST['report']));
     if ($_POST['type'] == 'post') {
         $comment['comment_post_ID'] = $id;
         $report = appthemes_create_report($comment);
         if (!$report) {
             die(json_encode(array('success' => false, 'message' => __('Sorry, could not create report.', APP_TD))));
         }
         APP_Report_Comments_Email_Notify::notify_admin($report);
     } else {
         $report = appthemes_create_user_report($id, $comment);
         if (!$report) {
             die(json_encode(array('success' => false, 'message' => __('Sorry, could not create report.', APP_TD))));
         }
     }
     die(json_encode(array('success' => true, 'message' => __('Thank you. Report has been submitted.', APP_TD))));
 }