';
if(!empty($gallery['ids'])){
$ids = $gallery['ids'];
$ids = explode(',',$ids);
}
else{
$ids = array();
}
//var_dump($ids);
foreach($ids as $id ){
$src = wp_get_attachment_url( $id);
$alt_text = get_post_meta($id, '_wp_attachment_image_alt', true);
$html_thumb .= '
';
}
$html_thumb.= '
';
}
}
elseif($media_source == 'first_youtube'){
$post = get_post(get_the_ID());
$post_type = $post->post_type;
//var_dump($post_type);
if($post_type=='page'){
$content = '';
$html_thumb.= '';
}
else{
$content = do_shortcode( $post->post_content );
}
$embeds = get_media_embedded_in_content( $content );
foreach($embeds as $key=>$embed){
if(strchr($embed,'youtube')){
$embed_youtube = $embed;
}
}
if(!empty($embed_youtube) ){
$html_thumb.= $embed_youtube;
}
else{
$html_thumb.= '';
}
}
elseif($media_source == 'first_vimeo'){
$post = get_post(get_the_ID());
$post_type = $post->post_type;
//var_dump($post_type);
if($post_type=='page'){
$content = '';
$html_thumb.= '';
}
else{
$content = do_shortcode( $post->post_content );
}
$embeds = get_media_embedded_in_content( $content );
foreach($embeds as $key=>$embed){
if(strchr($embed,'vimeo')){
$embed_youtube = $embed;
}
}
if(!empty($embed_youtube) ){
$html_thumb.= $embed_youtube;
}
else{
$html_thumb.= '';
}
}
elseif($media_source == 'first_dailymotion'){
$post = get_post(get_the_ID());
$post_type = $post->post_type;
//var_dump($post_type);
if($post_type=='page'){
$content = '';
$html_thumb.= '';
}
else{
$content = do_shortcode( $post->post_content );
}
$embeds = get_media_embedded_in_content( $content );
foreach($embeds as $key=>$embed){
if(strchr($embed,'dailymotion')){
$embed_youtube = $embed;
}
}
if(!empty($embed_youtube) ){
$html_thumb.= $embed_youtube;
}
else{
$html_thumb.= '';
}
}
elseif($media_source == 'first_mp3'){
$post = get_post(get_the_ID());
$post_type = $post->post_type;
//var_dump($post_type);
if($post_type=='page'){
$content = '';
$html_thumb.= '';
}
else{
$content = do_shortcode( $post->post_content );
}
$embeds = get_media_embedded_in_content( $content );
foreach($embeds as $key=>$embed){
if(strchr($embed,'mp3')){
$embed_youtube = $embed;
}
}
if(!empty($embed_youtube) ){
$html_thumb.= $embed_youtube;
}
else{
$html_thumb.= '';
}
}
elseif($media_source == 'first_soundcloud'){
$post = get_post(get_the_ID());
$post_type = $post->post_type;
//var_dump($post_type);
if($post_type=='page'){
$content = '';
$html_thumb.= '';
}
else{
$content = do_shortcode( $post->post_content );
}
$embeds = get_media_embedded_in_content( $content );
foreach($embeds as $key=>$embed){
if(strchr($embed,'soundcloud')){
$embed_youtube = $embed;
}
}
if(!empty($embed_youtube) ){
$html_thumb.= $embed_youtube;
}
else{
$html_thumb.= '';
}
}
elseif($media_source == 'custom_youtube'){
if(!empty($custom_youtube_id)){
$html_thumb.= '';
if($item_key=='thumb'){
$html['item'].= '
';
}
elseif($item_key=='thumb_link'){
$html['item'].= '
';
}
elseif($item_key=='title'){
$html['item'].= 'Lorem Ipsum is simply';
}
elseif($item_key=='title_link'){
$html['item'].= '
Lorem Ipsum is simply ';
}
elseif($item_key=='excerpt'){
$html['item'].= 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text';
}
elseif($item_key=='excerpt_read_more'){
$html['item'].= 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text
Read more ';
}
elseif($item_key=='read_more'){
$html['item'].= '
Read more ';
}
elseif($item_key=='post_date'){
$html['item'].= '18/06/2015';
}
elseif($item_key=='author'){
$html['item'].= 'PickPlugins';
}
elseif($item_key=='categories'){
$html['item'].= '
Category 1 Category 2 ';
}
elseif($item_key=='tags'){
$html['item'].= '
Tags 1 Tags 2 ';
}
elseif($item_key=='comments_count'){
$html['item'].= '3 Comments';
}
// WooCommerce
elseif($item_key=='wc_full_price'){
$html['item'].= '
$45 -
$40 ';
}
elseif($item_key=='wc_sale_price'){
$html['item'].= '$45';
}
elseif($item_key=='wc_regular_price'){
$html['item'].= '$45';
}
elseif($item_key=='wc_add_to_cart'){
$html['item'].= 'Add to Cart';
}
elseif($item_key=='wc_rating_star'){
$html['item'].= '*****';
}
elseif($item_key=='wc_rating_text'){
$html['item'].= '2 Reviews';
}
elseif($item_key=='wc_categories'){
$html['item'].= '
Category 1 Category 2 ';
}
elseif($item_key=='wc_tags'){
$html['item'].= '
Tags 1 Tags 2 ';
}
/* WP eCommerce Stuff*/
elseif($item_key=='WPeC_old_price'){
$html['item'].= '$45';
}
elseif($item_key=='WPeC_sale_price'){
$html['item'].= '$40';
}
elseif($item_key=='WPeC_add_to_cart'){
$html['item'].= 'Add to Cart';
}
elseif($item_key=='WPeC_rating_star'){
$html['item'].= '*****';
}
elseif($item_key=='WPeC_categories'){
$html['item'].= '
Category 1 Category 2 ';
}
elseif($item_key=='meta_key'){
$html['item'].= 'Meta Key';
}
elseif($item_key=='html'){
$html['item'].= 'HTML';
}
else{
echo '';
}
$html['item'].= '
';
$html['options'] = '';
$html['options'].= '';
$html['options'].= '';
$html['options'].= '
';
$html['options'].= '
';
echo json_encode($html);
}
die();
}
add_action('wp_ajax_post_grid_layout_add_elements', 'post_grid_layout_add_elements');
function post_grid_get_categories($post_id){
if(current_user_can('manage_options')){
if(isset($_POST['post_types'])){
//var_dump($_POST['post_types']);
$post_types = stripslashes_deep($_POST['post_types']);
//var_dump($post_types);
$post_id = sanitize_text_field($_POST['post_id']);
$post_grid_meta_options = get_post_meta( $post_id, 'post_grid_meta_options', true );
//$categories = $post_grid_meta_options['categories'];
if(!empty($post_grid_meta_options['categories'])){
$categories = $post_grid_meta_options['categories'];
}
else{
$categories = array();
}
}
else{
$post_grid_meta_options = get_post_meta( $post_id, 'post_grid_meta_options', true );
if(!empty($post_grid_meta_options['post_types'])){
$post_types = $post_grid_meta_options['post_types'];
}
else{
$post_types = array();
}
//$post_types = $post_grid_meta_options['post_types'];
if(!empty($post_grid_meta_options['categories'])){
$categories = $post_grid_meta_options['categories'];
}
else{
$categories = array();
}
//$categories = $post_grid_meta_options['categories'];
}
if(isset($_POST['post_id'])){
$post_id = sanitize_text_field($_POST['post_id']);
}
$taxonomies = get_object_taxonomies( $post_types );
if(!empty($taxonomies)){
echo '';
foreach ($taxonomies as $taxonomy ) {
$the_taxonomy = get_taxonomy($taxonomy);
$args=array(
'orderby' => 'name',
'order' => 'ASC',
'taxonomy' => $taxonomy,
'hide_empty' => false,
);
$categories_all = get_categories($args);
if(!empty($categories_all)){
?>
- - - labels->name; ?> - - -
cat_ID, $categories)){
$selected = 'selected';
}
else{
$selected = '';
}
?>
value="cat_ID; ?>" >cat_name; echo ' (Total Post: '.$category_info->count.')'; ?>
';
}
else{
echo 'No categories found.';
}
}
if(isset($_POST['post_types'])){
die();
}
}
add_action('wp_ajax_post_grid_get_categories', 'post_grid_get_categories');
function post_grid_ajax_load_more(){
$html = '';
$post_id = sanitize_text_field($_POST['grid_id']);
$per_page = sanitize_text_field($_POST['per_page']);
$terms = sanitize_text_field($_POST['terms']);
include post_grid_plugin_dir.'/grid-items/variables.php';
$paged = sanitize_text_field($_POST['paged']);
include post_grid_plugin_dir.'/grid-items/query.php';
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) : $wp_query->the_post();
$html.='';
include post_grid_plugin_dir.'/grid-items/layer-media.php';
include post_grid_plugin_dir.'/grid-items/layer-content.php';
include post_grid_plugin_dir.'/grid-items/layer-hover.php';
$html.='
'; // .item
endwhile;
wp_reset_query();
else:
if($pagination_type=='load_more'){
$html.= '';
}
endif;
echo $html;
die();
}
add_action('wp_ajax_post_grid_ajax_load_more', 'post_grid_ajax_load_more');
add_action('wp_ajax_nopriv_post_grid_ajax_load_more', 'post_grid_ajax_load_more');
function post_grid_ajax_search(){
$html = '';
$post_id = sanitize_text_field($_POST['grid_id']);
include post_grid_plugin_dir.'/grid-items/variables.php';
$keyword = sanitize_text_field($_POST['keyword']);
include post_grid_plugin_dir.'/grid-items/query.php';
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) : $wp_query->the_post();
$html.='';
include post_grid_plugin_dir.'/grid-items/layer-media.php';
include post_grid_plugin_dir.'/grid-items/layer-content.php';
include post_grid_plugin_dir.'/grid-items/layer-hover.php';
$html.='
'; // .item
endwhile;
wp_reset_query();
else:
$html.='';
$html.=__('No Post found',post_grid_textdomain); // .item
$html.='
'; // .item
endif;
echo $html;
die();
}
add_action('wp_ajax_post_grid_ajax_search', 'post_grid_ajax_search');
add_action('wp_ajax_nopriv_post_grid_ajax_search', 'post_grid_ajax_search');
function post_grid_export_content_layouts(){
if(current_user_can('manage_options')){
$upload_dir = wp_upload_dir();
$basedir = $upload_dir['basedir'];
$baseurl = $upload_dir['baseurl'];
$export_layout_content_dir = $basedir.'/post-grid';
if ( ! file_exists( $export_layout_content_dir ) ) {
wp_mkdir_p( $export_layout_content_dir );
}
$post_grid_layout_content = get_option('post_grid_layout_content');
$export_data = serialize($post_grid_layout_content);
$layout_content_file = fopen($export_layout_content_dir."/export-layout-content-".date('Y-m-d-h').'-'.time().".txt", "w");
fwrite($layout_content_file, $export_data);
$file_url = $baseurl."/post-grid/export-layout-content-".date('Y-m-d-h').'-'.time().".txt";
//$file_url = post_grid_plugin_url."export/export-layout-content-".date('Y-m-d-h').'-'.time().".txt";
echo $file_url;
fclose($layout_content_file);
}
die();
}
add_action('wp_ajax_post_grid_export_content_layouts', 'post_grid_export_content_layouts');
function post_grid_ajax_remove_export_content_layout(){
if(current_user_can('manage_options')){
$file_url = sanitize_text_field($_POST['file_url']);
unlink($file_url);
}
die();
}
add_action('wp_ajax_post_grid_ajax_remove_export_content_layout', 'post_grid_ajax_remove_export_content_layout');
function post_grid_share_plugin(){
?>