Sindbad~EG File Manager

Current Path : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/functions/helper/
Upload File :
Current File : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/functions/helper/comments.php

<?php
/*
 * Security 	: blocking direct access
 * Source		: http://codex.wordpress.org/Theme_Development#Template_Files
*/
defined('ABSPATH') or die("Access Restricted");

/*
 * Function Description	: Custom Comments Display
 * Author Name			: Wordpress Codex 
 * Developed by			: Mouad Achemli
 * Function Source		: http://codex.wordpress.org/Function_Reference/wp_list_comments#Comments_Only_With_A_Custom_Comment_Display
 * Comments Count by	: TheDeadMedic 
 * Source Count fix		: http://stackoverflow.com/questions/3153794/getting-comment-count-to-work-on-new-wordpress-3-0-theme-loop-setup/
 * Note					: this function is important do not remove from here
 *
*/	
function mwp_comment($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment;
	extract($args, EXTR_SKIP);	
	if ( 'div' == $args['style'] ) {
		$tag = 'div';
		$add_below = 'comment';
	} else {
		$tag = 'li';
		$add_below = 'comment';
	}
	
	$hentry = mwp_option('seo-hentry');
	if ($hentry == 1) {
		$comment_fn = '';
		$comment_vcard = '';
	} else {
		$comment_fn = 'fn';
		$comment_vcard = ' vcard';
	}
	
	?>
		<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' :'parent') ?> id="comment-<?php comment_ID() ?>">
			<div class="comment-author gravatar<?php echo $comment_vcard; ?>">
				<?php 
				if (mwp_option('disable-avatar') == 0) {
					if (mwp_option('lazyload-mobile') == 1) {
						?><img alt="<?php comment_author(); ?>" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" width="50" height="50" class="lazy" data-src="<?php echo get_avatar_url(get_avatar( $comment, 50 )); ?>"/><?php
					} else {
						echo get_avatar( $comment, 50 ); 
					}
				} else {
					?><img alt="<?php comment_author(); ?>" width="50" height="50" class="lazy" src="<?php echo MWP_PATH_URL; ?>/images/avatar.jpg"/><?php		
				}
				?>
				<span style="display:none" class="<?php echo $comment_fn; ?>"><?php comment_author(); ?></span>
			</div>
			<div class="comment-meta post-meta" role="complementary">
				<h3 class="comment-author">
						<?php 
						$comment_author = get_comment_author_url($comment->comment_ID);
						if (!empty($comment_author)) {
							$html_author_name = sprintf( '<a class="comment-author-link" href="%1$s">%2$s</a>', 
								esc_url(get_comment_author_url($comment->comment_ID)),
								esc_attr(get_comment_author($comment->comment_ID))
							);
						} else {
							$html_author_name = sprintf( '<cite class="'.mwp_csa_color().' comment-author-link">%1$s</cite>',
								esc_attr(get_comment_author($comment->comment_ID))
							);
						}
						echo $html_author_name; 
						?>
					<span title="<?php comment_date('Y-m-d') ?> <?php comment_time('H:iP') ?>"><?php mwp_comment_posted_on(); ?></span>
				</h3>
			</div>
			<div class="comment-content post-content">
				<?php comment_text(); ?>
				<?php if ($comment->comment_approved == '0') : ?>
				<br><p class="comment-moderation"><?php _e('Your comment is awaiting moderation.', MWP_TEXT_DOMAIN ); ?></p>
				<?php endif; ?>
				<div class="comment-metadata">
					<?php edit_comment_link('<div class="comment-meta-item">'. __('Edit this comment', MWP_TEXT_DOMAIN ).'</div>','',''); ?>
					<div class="comment-reply">
						<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
					</div>
				</div>
			</div>
			
	<?php 
}
// end of awesome semantic comment
function mwp_comment_close() {
	echo '</li>';
}
/*
 * Commont Meta Helper
 * 
 * human readable format such as "1 hour", "5 mins", "2 days".
*/
function mwp_comment_posted_on() {
	$time_string = sprintf( '<time class="comment-meta-item" datetime="%1$s">%2$s</time>',
		esc_attr( get_comment_time( 'c' ) ),
		esc_html( get_comment_date('j F Y') )
	);
	$posted_on = sprintf(
    _x( '%s ago', '%s = human-readable time difference', MWP_TEXT_DOMAIN ),
    human_time_diff(get_comment_time("U"), current_time("timestamp") )
	);
	echo $posted_on;
}

/*
 * Comments List
 * Fix For Reverse Comments order in wordpress
 *
*/
add_filter('comments_array', 'mwp_reverse_comments');
function mwp_reverse_comments($comments) {
	return array_reverse($comments);
}
/**
 * Comment Form
 * Filter default fields input
 *
*/
add_filter('comment_form_default_fields', 'bootstrap3_comment_form_fields');
function bootstrap3_comment_form_fields( $fields ) {
    $commenter = wp_get_current_commenter(); 
    $req      = get_option( 'require_name_email' );
    $aria_req = ( $req ? " aria-required='true'" : '' );
    $html5    = current_theme_supports( 'html5', 'comment-form' ) ? 1 : 0;
    $fields   =  array(
        'author' => '<div class="form-group comment-form-author"><label for="author"><span class="meta-hidden">' . __( 'Name' ) . '</span><input class="form-control required" aria-labelledby="author" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' placeholder="' . __( 'Name' ) . '*' . '" /></label></div>',
        'email'  => '<div class="form-group comment-form-email"><label for="email"><span class="meta-hidden">' . __( 'Email' ) . '</span><input class="form-control email-valid required" aria-labelledby="email" id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' placeholder="' . __( 'Email' ) . '*' . '" /></label></div>',
        'url'    => '<div class="form-group comment-form-url"><label for="url"><span class="meta-hidden">' . __( 'Website' ) . '</span><input class="form-control" aria-labelledby="url" id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" placeholder="' . __( 'Website' ) . '" /></label></div>'        
    );
    return $fields;
}
/**
 * Comments Filters
 * Filter default reply title
 *
*/
add_filter('comment_form_defaults', 'bootstrap3_comment_head');
function bootstrap3_comment_head( $args ) {
    $args['title_reply_before'] = '<h2 id="reply-title" class="comment-reply-title '.mwp_csa_color().'">';
    $args['title_reply_after'] = '</h2>';
	return $args;
}
function bootstrap3_comment_form_reply_title($arg) {
	$arg['title_reply'] = __( 'Leave a Comment', MWP_TEXT_DOMAIN );
	return $arg;
}
add_filter('comment_form_defaults', 'bootstrap3_comment_form_reply_title');
/**
 * Comment Form
 * Filter default Button
 *
*/
add_filter('comment_form_defaults', 'bootstrap3_comment_form');
function bootstrap3_comment_form( $args ) {
    $args['comment_field'] = '<br><div class="form-group comment-form-comment"><label for="comment"><span class="meta-hidden">' . __( 'Comment', MWP_TEXT_DOMAIN ) .  '</span><textarea class="form-control required" aria-labelledby="comment" id="comment" name="comment" cols="45" rows="4" aria-required="true" placeholder="' . _x( 'Comment', 'noun' ) .  '*' . '"></textarea></label></div>';
    $args['class_submit'] = 'btn btn-color';
	return $args;
}

function bootstrap3_comment_form_submit_label($arg) {
	$arg['label_submit'] = __( 'Submit', MWP_TEXT_DOMAIN );
	return $arg;
}
add_filter('comment_form_defaults', 'bootstrap3_comment_form_submit_label');
/**
 * Comment Form
 *
 * Social Login Helper
 *
*/
function wordpress_social_login_fix( ) {
    if (has_action('wordpress_social_login', false)) {
		ob_start();
		do_action( 'wordpress_social_login' );
		return ob_get_clean();
	}
}
/**
 * Comment Form
 * Filter default Login Link
 *
*/
add_filter('comment_form_defaults', 'must_login_comment_form');
function must_login_comment_form( $args ) {
	$args['must_log_in'] = '<div class="clearfix"></div>';
	$args['must_log_in'] .= '<div class="alert alert-gray">';
	$args['must_log_in'] .= '<p>' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.', MWP_TEXT_DOMAIN ), wp_login_url( apply_filters( 'the_permalink', get_permalink() ) ) ) . '</p>';
	if (has_action('wordpress_social_login', false)) {
		$args['must_log_in'] .= '<div class="or-sep"><span>'.__( 'OR', MWP_TEXT_DOMAIN ).'</span></div>';
	}
	$args['must_log_in'] .= wordpress_social_login_fix();
	$args['must_log_in'] .= '</div>';
	
    return $args;
}
/*
 * Comment Form
 * Display Rules
*/
add_filter('comment_form_after_fields', 'comments_rules_field');
function comments_rules_field() {
	
	if(mwp_option('comments-rules-chk') == 1) {
		echo '<div class="comments-rules"><strong>'. __( 'Comments Rules : ', MWP_TEXT_DOMAIN ).'</strong>';
		if (mwp_option('comments-rules') <> "") { 
			echo stripslashes(stripslashes(mwp_option('comments-rules'))); 
		} else { 
			if (is_rtl()) {
				echo '<p>عدم الإساءة للكاتب أو للأشخاص أو للمقدسات أو مهاجمة الأديان أو الذات الالهية. والابتعاد عن التحريض الطائفي والعنصري والشتائم.</p>'; 
			} else {
				echo '<p>You can edit this text from "NewsBT Panel" to match the comments rules on your site</p>';
			}
		}
		echo '</div>';
	}
}

/**
 * Setting up the ALT tag for Gravatar
 * http://ianjgough.com/blog/setting-up-the-alt-tag-for-gravatar-in-wordpress/
 *
*/
add_filter('get_avatar','mwp_replace_content');
function mwp_replace_content($text) {
	if (is_singular()) {
		$alt = get_comment_author();
		$text = str_replace('alt=\'\'', 'alt=\''.$alt.'\'',$text);
		return $text;
	}
}

/*
 * Function Description	: Load More Comments with AJAX
 * Author				: Mouad Achemli
 * Function Source		: http://www.mwordpress.net
 * Note					: this function is important do not remove from here
 * Ajax call in			: /comments.php 
*/
function load_more_comments(){
	$cpaged = $_GET['cpaged'] + 1;
	$postid = $_GET['postid'];
	query_posts( array( 'p' => $postid) );
	while (have_posts()) : the_post();
		set_query_var( 'cpage', intval( $cpaged ) );
		$output = comments_template('/comments.php');
	endwhile;
	die();
}
add_action( MWP_AJAX_PREFIX . '_load_more_comments', 'load_more_comments');
add_action( MWP_AJAX_PREFIX . '_nopriv_load_more_comments', 'load_more_comments');

/*
 * Function Description	: Comment Ajax
 * Author Name			: Misha
 * Function Source		: https://rudrastyh.com/wordpress/ajax-comments.html
 * Note					: this function is important do not remove from here
 *
*/
add_action(  MWP_AJAX_PREFIX . '_load_ajax_comments', 'load_ajax_comments' ); // mwpajax_{action} for registered user
add_action(  MWP_AJAX_PREFIX . '_nopriv_load_ajax_comments', 'load_ajax_comments' ); // mwpajax_nopriv_{action} for not registered users
function load_ajax_comments(){
	$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
	if ( is_wp_error( $comment ) ) {
		$error_data = intval( $comment->get_error_data() );
		if ( ! empty( $error_data ) ) {
			wp_die( '<span class="alert-n alert alert-danger">' . $comment->get_error_message() . '</span>', __( 'Error in processing your form.', MWP_TEXT_DOMAIN ), array( 'response' => $error_data, 'back_link' => true ) );
		} else {
			wp_die( '<span class="alert-n alert alert-danger">Unknown error</span>' );
		}
	}
	$user = wp_get_current_user();
	do_action('set_comment_cookies', $comment, $user);
	$comment_depth = 1;
	$comment_parent = $comment->comment_parent;
	while( $comment_parent ){
		$comment_depth++;
		$parent_comment = get_comment( $comment_parent );
		$comment_parent = $parent_comment->comment_parent;
	}
	$GLOBALS['comment'] = $comment;
	$GLOBALS['comment_depth'] = $comment_depth;
	?>
	<li <?php comment_class(empty( $args['has_children'] ) ? '' :'parent'); ?> id="comment-<?php comment_ID() ?>">
		<div class="comment-author vcard gravatar">
			<?php 
			if (mwp_option('disable-avatar') == 0) {
				if (mwp_option('lazyload-mobile') == 1) {
					?><img alt="" src="data:image/gif;base64,R0lGODlhAQABAHAAACH5BAEAAPwALAAAAAABAAEAhwAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCqmQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzNVZjNVmTNVzDNV/zOAADOAMzOAZjOAmTOAzDOA/zOqADOqMzOqZjOqmTOqzDOq/zPVADPVMzPVZjPVmTPVzDPV/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YrAGYrM2YrZmYrmWYrzGYr/2ZVAGZVM2ZVZmZVmWZVzGZV/2aAAGaAM2aAZmaAmWaAzGaA/2aqAGaqM2aqZmaqmWaqzGaq/2bVAGbVM2bVZmbVmWbVzGbV/2b/AGb/M2b/Zmb/mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5krAJkrM5krZpkrmZkrzJkr/5lVAJlVM5lVZplVmZlVzJlV/5mAAJmAM5mAZpmAmZmAzJmA/5mqAJmqM5mqZpmqmZmqzJmq/5nVAJnVM5nVZpnVmZnVzJnV/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwAM8wAZswAmcwAzMwA/8wrAMwrM8wrZswrmcwrzMwr/8xVAMxVM8xVZsxVmcxVzMxV/8yAAMyAM8yAZsyAmcyAzMyA/8yqAMyqM8yqZsyqmcyqzMyq/8zVAMzVM8zVZszVmczVzMzV/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8Amf8AzP8A//8rAP8rM/8rZv8rmf8rzP8r//9VAP9VM/9VZv9Vmf9VzP9V//+AAP+AM/+AZv+Amf+AzP+A//+qAP+qM/+qZv+qmf+qzP+q///VAP/VM//VZv/Vmf/VzP/V////AP//M///Zv//mf//zP///wAAAAAAAAAAAAAAAAgEAPcFBAA7" width="50" height="50" class="lazy" data-src="<?php echo get_avatar_url(get_avatar( $comment, 50 )); ?>"/><?php
				} else {
					echo get_avatar( $comment, 50 );
				}
			} else {
				?><img alt="" src="<?php echo MWP_PATH_URL; ?>/images/avatar.jpg"/><?php	
			} ?>
			<span style="display:none" class="fn"><?php comment_author(); ?></span>
		</div>
		<div class="comment-meta post-meta" role="complementary">
			<h3 class="comment-author">
				<?php 
				$comment_author = get_comment_author_url($comment->comment_ID);
				if (!empty($comment_author)) {
					$html_author_name = sprintf( '<a class="comment-author-link" href="%1$s">%2$s</a>', 
						esc_url(get_comment_author_url($comment->comment_ID)),
						esc_attr(get_comment_author($comment->comment_ID))
					);
				} else {
					$html_author_name = sprintf( '<cite class="'.mwp_csa_color().' comment-author-link">%1$s</cite>',
						esc_attr(get_comment_author($comment->comment_ID))
					);
				}
				echo $html_author_name; 
				?>
				<span title="<?php comment_date('Y-m-d') ?> <?php comment_time('H:iP') ?>"><?php mwp_comment_posted_on(); ?></span>
			</h3>
		</div>
		<div class="comment-content post-content">
			<?php comment_text(); ?>
			<?php if ($comment->comment_approved == '0') : ?>
			<br><p class="comment-moderation"><?php esc_html_e('Your comment is awaiting moderation.', MWP_TEXT_DOMAIN ); ?></p>
			<?php endif; ?>
			<div class="comment-metadata">
				<?php edit_comment_link('<div class="comment-meta-item">'. __('Edit this comment', MWP_TEXT_DOMAIN ).'</div>','',''); ?>
			</div>
		</div>
	</li>
	<?php
	die();
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists