function check_delete_comments()
 {
     global $rtmedia_query;
     if ($rtmedia_query->action_query->action != 'delete-comment') {
         return;
     }
     if (count($_POST)) {
         /**
          * /media/id/delete-comment [POST]
          * Delete Comment by Comment ID
          */
         if (empty($_POST['comment_id'])) {
             return false;
         }
         $comment = new RTMediaComment();
         $id = $_POST['comment_id'];
         $activity_id = get_comment_meta($id, 'activity_id', true);
         if (!empty($activity_id)) {
             if (function_exists('bp_activity_delete_comment')) {
                 //if buddypress is active
                 $activity_deleted = bp_activity_delete_comment($activity_id, $id);
                 $delete = bp_activity_delete(array('id' => $activity_id, 'type' => 'activity_comment'));
             }
         }
         $comment_deleted = $comment->remove($id);
         echo $comment_deleted;
         exit;
     }
 }
function rtmedia_comment_form()
{
    if (is_user_logged_in()) {
        ?>
		<form method="post" id="rt_media_comment_form" class="rt_media_comment_form"
			  action="<?php 
        echo esc_url(get_rtmedia_permalink(rtmedia_id()));
        ?>
comment/">

			<textarea style="width:100%" placeholder="<?php 
        _e('Type Comment...', 'rtmedia');
        ?>
" name="comment_content" id="comment_content"></textarea>
			<input type="submit" id="rt_media_comment_submit" class="rt_media_comment_submit" value="<?php 
        _e('Comment', 'rtmedia');
        ?>
">

			<?php 
        RTMediaComment::comment_nonce_generator();
        ?>
		</form>
		<?php 
    }
}
 function comment_sync($comment_id, $param)
 {
     $user_id = '';
     $comment_author = '';
     extract($param);
     if (!empty($user_id)) {
         $user_data = get_userdata($user_id);
         $comment_author = $user_data->data->user_login;
     }
     $mediamodel = new RTMediaModel();
     $media = $mediamodel->get(array('activity_id' => $param['activity_id']));
     // if there is only single media in activity
     if (1 == sizeof($media) && isset($media[0]->media_id)) {
         $media_id = $media[0]->media_id;
         $comment = new RTMediaComment();
         $id = $comment->add(array('comment_content' => $param['content'], 'comment_post_ID' => $media_id, 'user_id' => $user_id, 'comment_author' => $comment_author));
         update_comment_meta($id, 'activity_id', $comment_id);
     }
 }
示例#4
0
 function check_delete_comments()
 {
     global $rtmedia_query;
     if ('delete-comment' !== $rtmedia_query->action_query->action) {
         return;
     }
     if (count($_POST)) {
         // @codingStandardsIgnoreLine
         /**
          * /media/id/delete-comment [POST]
          * Delete Comment by Comment ID
          */
         $_comment_id = filter_input(INPUT_POST, 'comment_id', FILTER_SANITIZE_NUMBER_INT);
         if (empty($_comment_id)) {
             return false;
         }
         $comment = new RTMediaComment();
         $id = $_comment_id;
         $activity_id = get_comment_meta($id, 'activity_id', true);
         if (!empty($activity_id)) {
             if (function_exists('bp_activity_delete_comment')) {
                 //if buddypress is active
                 $activity_deleted = bp_activity_delete_comment($activity_id, $id);
                 $delete = bp_activity_delete(array('id' => $activity_id, 'type' => 'activity_comment'));
             }
         }
         $comment_deleted = $comment->remove($id);
         echo $comment_deleted;
         // @codingStandardsIgnoreLine
         exit;
     }
 }
 function comment_sync($comment_id, $param)
 {
     $default_args = array('user_id' => '', 'comment_author' => '');
     $param = wp_parse_args($param, $default_args);
     $user_id = $param['user_id'];
     $comment_author = $param['comment_author'];
     if (!empty($user_id)) {
         $user_data = get_userdata($user_id);
         $comment_author = $user_data->data->user_login;
     }
     $mediamodel = new RTMediaModel();
     $media = $mediamodel->get(array('activity_id' => $param['activity_id']));
     // if there is only single media in activity
     if (1 === count($media) && isset($media[0]->media_id)) {
         $media_id = $media[0]->media_id;
         $comment = new RTMediaComment();
         $id = $comment->add(array('comment_content' => $param['content'], 'comment_post_ID' => $media_id, 'user_id' => $user_id, 'comment_author' => $comment_author));
         update_comment_meta($id, 'activity_id', $comment_id);
     }
 }