<?php 
/**
 * @package WordPress
 * @subpackage Campoal
 */

global $campoal_options;


$minimum_signature = isset($campoal_options['conikal_minimum_signature_field']) ? $campoal_options['conikal_minimum_signature_field'] : 0;
$home_header = isset($campoal_options['conikal_home_header_field']) ? $campoal_options['conikal_home_header_field'] : 'slideshow';
$home_header_hight = isset($campoal_options['conikal_hieght_slideshow_field']) ? $campoal_options['conikal_hieght_slideshow_field'] : '675';
$home_header_hight = intval($home_header_hight) - 130;
$home_header_hide_logined = isset($campoal_options['conikal_home_header_hide_logined_field']) ? $campoal_options['conikal_home_header_hide_logined_field'] : 0; 

$args = array(
        'posts_per_page'   => 7,
        'post_type'        => 'petition',
        'orderby'          => 'post_date',
        'order'            => 'DESC',
        'meta_key'         => 'petition_victory',
        'meta_value'       => '1',
        'post_status'      => 'publish' );

$args['meta_query'] = array('relation' => 'AND');

if ($minimum_signature != 0) {
    array_push($args['meta_query'], array(
        'key'     => 'petition_sign',
        'value'   => $minimum_signature,
        'type'    => 'NUMERIC',
        'compare' => '>='
    ));
}
    array_push($args['meta_query'], array(
        'key'     => 'petition_status',
        'value'   => '2',
        'compare' => '!='
    ));

$victorys = get_posts($args);


// hight slideshow
$home_feature_class = ' none-hero';
$hight_slideshow = '';
if ($home_header != 'none' && $home_header_hide_logined == 0) {
    if (!is_user_logged_in()) {
        $home_feature_class = '';
    }
} elseif ($home_header != 'none') {
    $home_feature_class = '';
}
?>
<?php if ($victorys) { ?>
<div class="ui grid tablet computer only home-feature-section carousel-v1">
	<div class="home-feature<?php echo esc_attr($home_feature_class) ?> height">
		<div class="sixteen wide column">
			<div class="ui container">
				<div class="ui raised segment feature-card">
					<div class="feature-petition">
						<img class="ui wireframe image" alt="<?php esc_attr_e('Wireframe featured loader', 'campoal') ?>" src="<?php echo esc_url(conikal_lazy_load_placeholder('wireframe-featured-loader')) ?>">
				    </div>
			    </div>
			    <div class="feature-navigation">
			    	<img class="ui wireframe image" alt="<?php esc_attr_e('Wireframe naviation loader', 'campoal') ?>" src="<?php echo esc_url(conikal_lazy_load_placeholder('wireframe-navigation-loader')) ?>">
			    </div>
			</div>
		</div>
	</div>
</div>
<?php wp_nonce_field('load_victory_petitions_ajax_nonce', 'securityVictoryPetitions', true); ?>
<?php } ?>