File: /home/z/w/a/zwafgyp/dodolodge-net/wp-content/themes/hotel-wp-child/functions.php
<?php
function thim_child_enqueue_styles() {
if ( is_multisite() ) {
wp_enqueue_style( 'thim-child-style', get_stylesheet_uri() );
} else {
wp_enqueue_style( 'thim-parent-style', get_template_directory_uri() . '/style.css' );
}
}
add_action( 'wp_enqueue_scripts', 'thim_child_enqueue_styles', 100 );
function my_enqueue_front_scripts(){
wp_enqueue_style( 'owl-carousel', get_stylesheet_directory_uri() . '/css/owl.carousel.css');
wp_enqueue_style( 'main-css', get_stylesheet_directory_uri() . '/css/main.css');
wp_enqueue_style( 'standard-css', get_stylesheet_directory_uri() . '/css/standard.css');
wp_enqueue_script('owl-carousel', get_stylesheet_directory_uri().'/js/owl.carousel.min.js', array('jquery'), '0', true);
wp_enqueue_script('main-js', get_stylesheet_directory_uri().'/js/main.js', array('jquery'), '0', true);
wp_enqueue_script('global-js', get_stylesheet_directory_uri().'/js/global.js', array('jquery'), '0', true);
}
add_action('wp_enqueue_scripts', 'my_enqueue_front_scripts');
function shortcode_suivre(){
if ( (ICL_LANGUAGE_CODE=='fr') ) {
$suivre ="Nous suivre";
} else if ( (ICL_LANGUAGE_CODE=='en') ) {
$suivre ="Follow us";
}else if ( (ICL_LANGUAGE_CODE=='de') ) {
$suivre ="Folge uns";
}else if ( (ICL_LANGUAGE_CODE=='it') ) {
$suivre ="Seguici";
}else if ( (ICL_LANGUAGE_CODE=='ru') ) {
$suivre ="Подписывайтесь на нас";
}else if ( (ICL_LANGUAGE_CODE=='es') ) {
$suivre ="Síguenos";
}else if ( (ICL_LANGUAGE_CODE=='ma') ) {
$suivre ="Araho izahay";
}
$facebook__link="target='_blank' href='https://www.facebook.com/Dodolodge-Resort-193438114803502'";
$instagram__link="target='_blank' href='https://www.instagram.com/dodolodge/?hl=fr'";
return "<div class='footer_social'><span>".$suivre."</span><a class='social__links social__in' ".$instagram__link."></a><a class='social__links social__fb' ".$facebook__link."></a></div>";
}
add_shortcode('suivre', 'shortcode_suivre');
/**
* Show list comments
*
* @return string
*/
if ( ! function_exists( 'thim_comment_evoluer' ) ) {
function thim_comment_evoluer( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
//extract( $args, EXTR_SKIP );
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo ent2ncr( $tag );
echo ' '; ?><?php comment_class( 'description_comment' ) ?>
data-comment-date="<?php echo strtotime($comment->comment_date); ?>"
id="comment-<?php comment_ID() ?>">
<?php
/*if ( $args['avatar_size'] != 0 ) {
echo get_avatar( $comment, 100 );
} */ ?>
<div class="content-comment">
<div class="author">
<?php printf( '<span class="author-name">%s</span>', get_comment_author_link() ) ?>
<?php edit_comment_link( esc_html__( 'Edit', 'hotel-wp' ), '', '' ); ?>
</span>
</div>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php esc_html_e( 'Your comment is awaiting moderation.', 'hotel-wp' ) ?></em>
<?php endif; ?>
<div class="message">
<?php comment_text() ?>
</div>
<span class="comment-extra-info">
<?php
printf( get_comment_date('F, Y') );
//printf( get_comment_time() ) ?>
</span>
</div>
<div class="clear"></div>
<?php
}
}
remove_action("wp_head", "wp_generator");
// add_filter('login_errors',create_function('$a', "return null;"));
//Shortcode get last 5 comments
function evoluer_get_last_five_comments() {
global $wpdb;
$lang = ICL_LANGUAGE_CODE;
$results_lang = $wpdb->get_results("
SELECT comments.*
FROM wwhin_comments As comments
INNER JOIN wwhin_posts AS post
ON comments.comment_post_ID = post.ID
INNER JOIN wwhin_icl_translations AS trans
ON post.ID = trans.element_id
WHERE (trans.element_type = 'post_page' AND comments.comment_approved = '1'
AND trans.language_code = '$lang' ) ORDER BY comments.comment_ID DESC LIMIT 5
");
$results_en = array();
if($lang != 'en' && count($results_lang) < 5){
$limit = 5 - count($results_lang);
$results_en = $wpdb->get_results("
SELECT comments.*
FROM wwhin_comments As comments
INNER JOIN wwhin_posts AS post
ON comments.comment_post_ID = post.ID
INNER JOIN wwhin_icl_translations AS trans
ON post.ID = trans.element_id
WHERE (trans.element_type = 'post_page' AND comments.comment_approved = '1'
AND trans.language_code = 'en' ) ORDER BY comments.comment_ID DESC LIMIT $limit
");
}
$results = array_merge($results_lang, $results_en);
ob_start();
if ( $results ) { ?>
<div id="comments_carousel_shortcode" class="comments_carousel owl-carousel">
<?php foreach ( (array) $results as $comment ) { ?>
<div class="comments_item_carousel">
<div class="author">
<em class="left">“</em> <?php printf( '<span class="author-name">%s</span>', get_comment_author_link($comment) ) ?> <em class="right">”</em>
</div>
<?php // echo get_avatar( $comment, 200 ); ?>
<div class="message">
<?php comment_text($comment) ?>
</div>
</div>
<?php } ?>
</div>
<?php
$html = ob_get_contents();
ob_end_clean();
return $html;
}
}
add_shortcode('evoluer-last-comments', 'evoluer_get_last_five_comments');
/*Comment Validation*/
function comment_validation_init() {
if( comments_open() ) { ?>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#commentform').validate({
rules: {
author: {
required: true,
},
email: {
required: true,
},
comment: {
required: true,
},
rating:{
required: true,
}
},
messages: {
author: $('.error-required-form').text(),
email: $('.error-email-form').text(),
comment: $('.error-required-form').text(),
rating: $('.error-required-form').text(),
},
errorElement: "div",
errorPlacement: function(error, element) {
element.after(error);
}
});
});
</script>
<?php
}
}
add_action('wp_footer', 'comment_validation_init');