__( 'Shortcode', 'post_grid' ) ) ); } add_filter( 'manage_post_grid_posts_columns' , 'post_grid_add_shortcode_column' ); function post_grid_posts_shortcode_display( $column, $post_id ) { if ($column == 'shortcode'){ ?>
'.var_export($post_grid_post_settings).''; $html_thumb = ''; if($media_source == 'featured_image'){ $thumb = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), $featured_img_size ); //var_dump(); $alt_text = get_post_meta(get_post_thumbnail_id(get_the_ID()), '_wp_attachment_image_alt', true); $thumb_url = $thumb['0']; if(!empty($thumb_url)){ if($thumb_linked=='yes'){ $html_thumb.= ''.$alt_text.''; } else{ $html_thumb.= ''.$alt_text.''; } } else{ $html_thumb.= ''; } } elseif($media_source == 'empty_thumb'){ if($thumb_linked=='yes'){ $html_thumb.= ''; } else{ $html_thumb.= ''; } } elseif($media_source == 'custom_thumb'){ if(!empty($custom_thumb_source)){ if($thumb_linked=='yes'){ $html_thumb.= ''; } else{ $html_thumb.= ''; } } } elseif($media_source == 'font_awesome'){ if(!empty($custom_thumb_source)){ if($thumb_linked=='yes'){ $html_thumb.= ''; } else{ $html_thumb.= ''; } } } elseif($media_source == 'first_image'){ //global $post, $posts; $post = get_post(get_the_ID()); $post_content = $post->post_content; //var_dump('Hello'); $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('//i', $post_content, $matches); if(!empty($matches[1][0])) $first_img = $matches[1][0]; if(empty($first_img)) { $html_thumb.= ''; } else{ if($thumb_linked=='yes'){ $html_thumb.= ''; } else{ $html_thumb.= ''; } } } elseif($media_source == 'first_gallery'){ $gallery = get_post_gallery( get_the_ID(), false ); if(!empty($gallery)){ $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.= ''; } } elseif($media_source == 'custom_vimeo'){ if(!empty($custom_vimeo_id)){ $html_thumb.= ''; } } elseif($media_source == 'custom_dailymotion'){ if(!empty($custom_dailymotion_id)){ $html_thumb.= ''; } } elseif($media_source == 'custom_mp3'){ if(!empty($custom_mp3_url)){ $html_thumb.= do_shortcode('[audio src="'.$custom_mp3_url.'"]'); } } elseif($media_source == 'custom_soundcloud'){ if(!empty($custom_soundcloud_id)){ $html_thumb.= ''; } } return $html_thumb; } function post_grid_remove_content_layout_ajax(){ if(current_user_can('manage_options')){ $layout_id = sanitize_text_field($_POST['layout_id']); $post_grid_layout_content = get_option('post_grid_layout_content'); unset($post_grid_layout_content[$layout_id]); update_option('post_grid_layout_content',$post_grid_layout_content); } die(); } add_action('wp_ajax_post_grid_remove_content_layout_ajax', 'post_grid_remove_content_layout_ajax'); function post_grid_reset_content_layouts(){ if(current_user_can('manage_options')){ $class_post_grid_functions = new class_post_grid_functions(); $layout_content_list = $class_post_grid_functions->layout_content_list(); update_option('post_grid_layout_content', $layout_content_list); } die(); } add_action('wp_ajax_post_grid_reset_content_layouts', 'post_grid_reset_content_layouts'); function post_grid_term_slug_list($post_id){ $term_slug_list = ''; $post_taxonomies = get_post_taxonomies($post_id); foreach($post_taxonomies as $taxonomy){ $term_list[] = wp_get_post_terms(get_the_ID(), $taxonomy, array("fields" => "all")); } if(!empty($term_list)){ foreach($term_list as $term_key=>$term) { foreach($term as $term_id=>$term){ $term_slug_list .= $term->slug.' '; } } } return $term_slug_list; } function post_grid_meta_query_args($meta_query){ foreach($meta_query as $key=>$meta_info){ ?>
Key

Value

Compare

Type

'; $post_types_all = get_post_types( '', 'names' ); foreach ( $post_types_all as $post_type ) { global $wp_post_types; $obj = $wp_post_types[$post_type]; if(in_array($post_type,$post_types)){ $selected = 'selected'; } else{ $selected = ''; } $html .= ''; } $html .= ''; return $html; } function post_grid_layout_content_ajax(){ if(current_user_can('manage_options')){ $layout_key = sanitize_text_field($_POST['layout']); $class_post_grid_functions = new class_post_grid_functions(); $post_grid_layout_content = get_option( 'post_grid_layout_content' ); if(empty($post_grid_layout_content)){ $layout = $class_post_grid_functions->layout_content($layout_key); } else{ $layout = $post_grid_layout_content[$layout_key]; } //$layout = $class_post_grid_functions->layout_content($layout_key); ?>
$item_info){ $item_key = $item_info['key']; ?>
Lorem Ipsum is simply Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text Read more Read more 18/06/2015 PickPlugins 3 Comments $45 - $40 $45 $45 Add to Cart ***** 2 Reviews $45
layout_items(); $html = array(); $html['item'] = ''; $html['item'].= '
'; 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'].= ' '; } elseif($item_key=='tags'){ $html['item'].= ' '; } 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'].= '
'.$layout_items[$item_key].'
'; $html['options'].= '
'; if($item_key=='meta_key'){ $html['options'].= 'Meta Key:


'; $html['options'].= 'Wrapper:
use %s where you want to repalce the meta value. Example
<div>%s</div>



'; } if($item_key=='html'){ $html['options'].= 'Custom HTML:


'; } if($item_key=='read_more'){ $html['options'].= 'Read more text:


'; } if($item_key=='title' || $item_key=='title_link' || $item_key=='excerpt' || $item_key=='excerpt_read_more' ){ $html['options'].= 'Character limit:


'; } if($item_key=='title_link' || $item_key=='read_more' || $item_key=='excerpt_read_more' ){ $html['options'].= 'Link target:


'; } $html['options'].= ' CSS:
Sample css


CSS Hover:
'; $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 '