Sindbad~EG File Manager

Current Path : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/amp/helper/
Upload File :
Current File : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/amp/helper/gallery-optional.php

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

/*
 * AMP : Print Script for Gallery instead of thumbnail
*/
function mwp_amp_cgallery_head($post) {
	$post 				= get_post($post->ID);
	$get_categories  	= mwp_option('category-gallery');
	$instead_gallery 	= get_post_meta($post->ID, 'instead_gallery' , true);
	if (!empty($instead_gallery) || !empty($get_categories) && in_category($get_categories, $post->ID)) {
		echo "<script async custom-element='amp-carousel' src='https://cdn.ampproject.org/v0/amp-carousel-0.1.js'></script>\n";
	}
}
add_action('amp_post_template_head','mwp_amp_cgallery_head');

/*!
 * Single
 *
 * Gallery Optional
 *
*/
function mwp_gallery_create_ids($postid) {
	$attachments = get_children(array(
		'post_parent' 		=> $postid,
		'post_status' 		=> 'inherit',
		'post_type' 		=> 'attachment',
		'post_mime_type' 	=> 'image',
		'order' 			=> 'ASC',
		'orderby' 			=> 'menu_order ID'
	));
	foreach($attachments as $att_id => $attachment) {
		$image_src 	= wp_get_attachment_image_src($attachment->ID, 'full');
		$image 		= $image_src[0];
		$width 		= $image_src[1];
		$height 	= $image_src[2];
		$gallery[] 	= '<amp-img src="'.$image.'" layout="responsive" height="'.$height.'" width="'.$width.'"></amp-img>';
	}
	return $gallery;
}
function mwp_optional_gallery_amp($postid) {
	
	$get_categories  = mwp_option('category-gallery');
	$instead_gallery = get_post_meta($postid, 'instead_gallery' , true);
	
	if (!empty($instead_gallery) || !empty($get_categories) && in_category($get_categories, $postid)) {
		$data = mwp_gallery_create_ids($postid);
		if (!empty($data) && is_array($data)) {
			echo '<div class="amp-wp-article-thumb"><amp-carousel width="600" height="480" type="slides" layout="responsive">';
			foreach ($data as $index => $img) {
				echo $img;
			}
			echo '</amp-carousel></div>';
		}
	}
}

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