protected function validateVideoComment() { $js_error = ''; // wordpress validation code from wp-comments-post (with slight changes) $comment_author = trim(strip_tags($_GET['author'])); $comment_author_email = trim($_GET['email']); $user = wp_get_current_user(); if ($user->ID) { global $wpdb; $comment_author = $wpdb->escape($user->display_name); $comment_author_email = $wpdb->escape($user->user_email); } else { if (get_option('comment_registration')) { return __('Sorry, you must be logged in to post a comment.'); } } if (get_option('require_name_email') && !$user->ID) { if (6 > strlen($comment_author_email) || '' == $comment_author) { return __('Error: please fill the required fields (name, email).'); } elseif (!is_email($comment_author_email)) { return __('Error: please enter a valid email address.'); } } // end of wordpress validation code if (!KalturaHelpers::videoCommentsEnabled()) { return __('You do not have sufficient permissions to access this page.'); } if (!KalturaHelpers::anonymousCommentsAllowed() && !$user->ID) { return __('You must be logged in to post a comment.'); } $post_id = $_GET['postid']; if (!$post_id) { return __('Invalid post id.'); } return ''; }
public function commentFormAction($post_id) { if (wp_is_mobile()) { return; } $user = wp_get_current_user(); if (!$user->ID && !KalturaHelpers::anonymousCommentsAllowed()) { echo "You must be <a href=" . get_option('siteurl') . "/wp-login.php?redirect_to=" . urlencode(get_permalink()) . ">logged in</a> to post a <br /> video comment."; } else { $js_click_code = "Kaltura.openCommentCW('" . site_url() . '?kaltura_iframe_handler' . "'); "; echo "<input type=\"button\" id=\"kaltura_video_comment\" name=\"kaltura_video_comment\" tabindex=\"6\" value=\"Add Video Comment\" onclick=\"" . $js_click_code . "\" />"; } }