function check_return_comments() { global $rtmedia_query; if ($rtmedia_query->action_query->action != 'comment') { return; } if (isset($rtmedia_query->action_query->id) && count($_POST)) { /** * /media/comments [POST] * Post a comment to the album by post id */ $nonce = $_REQUEST['rtmedia_comment_nonce']; if (wp_verify_nonce($nonce, 'rtmedia_comment_nonce')) { if (empty($_POST['comment_content'])) { return false; } $comment = new RTMediaComment(); $attr = $_POST; $mediaModel = new RTMediaModel(); $result = $mediaModel->get(array('id' => $rtmedia_query->action_query->id)); if (!isset($attr['comment_post_ID'])) { $attr['comment_post_ID'] = $result[0]->media_id; } $id = $comment->add($attr); if ($result[0]->activity_id != null) { global $rtmedia_buddypress_activity; remove_action("bp_activity_comment_posted", array($rtmedia_buddypress_activity, "comment_sync"), 10, 2); if (function_exists('bp_activity_new_comment')) { $comment_activity_id = bp_activity_new_comment(array('content' => $_POST['comment_content'], 'activity_id' => $result[0]->activity_id)); } } if (!empty($comment_activity_id)) { update_comment_meta($id, 'activity_id', $comment_activity_id); } if (isset($_POST["rtajax"])) { global $wpdb; $comments = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $id), ARRAY_A); echo rmedia_single_comment($comments); exit; } } else { _e('Ooops !!! Invalid access. No nonce was found !!', 'buddypress-media'); } } }
/** * rendering comments section */ function rtmedia_comments($echo = true) { $html = '<ul id="rtmedia_comment_ul" class="rtm-comment-list" data-action="' . get_rtmedia_permalink(rtmedia_id()) . 'delete-comment/">'; global $wpdb, $rtmedia_media; $comments = get_comments(array('post_id' => $rtmedia_media->media_id, 'order' => 'ASC')); $comment_list = ""; foreach ($comments as $comment) { $comment_list .= rmedia_single_comment((array) $comment); } if ($comment_list != "") { $html .= $comment_list; } else { $html .= "<li id='rtmedia-no-comments' class='rtmedia-no-comments'>" . __(apply_filters('rtmedia_single_media_no_comment_messege', __('There are no comments on this media yet.', 'rtmedia'))) . "</li>"; } $html .= '</ul>'; if ($html) { echo $html; } else { return $html; } }
/** * rendering comments section */ function rtmedia_comments($echo = true) { $html = '<ul id="rtmedia_comment_ul" class="large-block-grid-1" data-action="' . get_rtmedia_permalink(rtmedia_id()) . 'delete-comment/">'; global $wpdb, $rtmedia_media; $comments = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = '" . $rtmedia_media->media_id . "'", ARRAY_A); $comment_list = ""; foreach ($comments as $comment) { $comment_list .= rmedia_single_comment($comment); } if ($comment_list != "") { $html .= $comment_list; } else { $html .= "<li id='rtmedia-no-comments' class='rtmedia-no-comments'>" . __(apply_filters('rtmedia_single_media_no_comment_messege', __('There are no comments on this media yet.', 'rtmedia'))) . "</li>"; } $html .= '</ul>'; if ($html) { echo $html; } else { return $html; } }
function check_return_comments() { global $rtmedia_query; if ('comment' !== $rtmedia_query->action_query->action) { return; } if (isset($rtmedia_query->action_query->id) && count($_POST)) { // @codingStandardsIgnoreLine /** * /media/comments [POST] * Post a comment to the album by post id */ $nonce = isset($_REQUEST['rtmedia_comment_nonce']) ? wp_unslash($_REQUEST['rtmedia_comment_nonce']) : ''; $comment_content = isset($_REQUEST['comment_content']) ? sanitize_text_field(wp_unslash($_REQUEST['comment_content'])) : ''; if (wp_verify_nonce($nonce, 'rtmedia_comment_nonce')) { if (empty($comment_content)) { return false; } $comment = new RTMediaComment(); $attr = $_POST; $media_model = new RTMediaModel(); $result = $media_model->get(array('id' => $rtmedia_query->action_query->id)); if (!isset($attr['comment_post_ID'])) { $attr['comment_post_ID'] = $result[0]->media_id; } $id = $comment->add($attr); if (!is_null($result[0]->activity_id)) { global $rtmedia_buddypress_activity; remove_action('bp_activity_comment_posted', array($rtmedia_buddypress_activity, 'comment_sync'), 10, 2); if (function_exists('bp_activity_new_comment')) { $comment_activity_id = bp_activity_new_comment(array('content' => $comment_content, 'activity_id' => $result[0]->activity_id)); do_action('rtm_bp_activity_comment_posted', $comment_activity_id, $result[0]); } } if (!empty($comment_activity_id)) { $rtmedia_activity_comment = rtmedia_activity_comment($comment_activity_id); if ($rtmedia_activity_comment['content']) { update_comment_meta($id, 'activity_comment_content', $rtmedia_activity_comment['content']); } update_comment_meta($id, 'activity_id', $comment_activity_id); } $_rt_ajax = filter_input(INPUT_POST, 'rtajax', FILTER_SANITIZE_STRING); if (!empty($_rt_ajax)) { global $wpdb; $comments = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d limit 100", $id), ARRAY_A); echo rmedia_single_comment($comments); // @codingStandardsIgnoreLine exit; } } else { esc_html_e('Ooops !!! Invalid access. No nonce was found !!', 'buddypress-media'); } } }
/** * Rendering comments section * * @global object $rtmedia_media * * @param bool $echo * * @return string */ function rtmedia_comments($echo = true) { global $rtmedia_media; $html = '<ul id="rtmedia_comment_ul" class="rtm-comment-list" data-action="' . esc_url(get_rtmedia_permalink(rtmedia_id())) . 'delete-comment/">'; $comments = get_comments(array('post_id' => $rtmedia_media->media_id, 'order' => 'ASC')); $comment_list = ''; $count = count($comments); $i = 0; foreach ($comments as $comment) { $comment_list .= rmedia_single_comment((array) $comment, $count, $i); $i++; } if (!empty($comment_list)) { $html .= $comment_list; } else { $html .= "<li id='rtmedia-no-comments' class='rtmedia-no-comments'>" . apply_filters('rtmedia_single_media_no_comment_messege', esc_html__('There are no comments on this media yet.', 'buddypress-media')) . '</li>'; } $html .= '</ul>'; if ($html) { echo $html; // @codingStandardsIgnoreLine } else { return $html; } }