ID, 'gallery_post', True); if ($gallery_post > 0) { $gallery_post_content = do_shortcode('[gallery id="'. $gallery_post .'" captiontag="" itemtag="div" icontag="span" ]'); $content .= '
' . $gallery_post_content . '
'; } return $content; } function gallery_post_custom_box() { add_meta_box("gallery-post", __("Gallery Post", "gallery_post"), "gallery_post_innerbox_html", "post", "advanced"); } function gallery_post_innerbox_html() { global $post, $wpdb; // Use nonce for verification wp_nonce_field( plugin_basename(__FILE__), 'gallery_post_noncename' ); // get current gallery post $gallery_post = get_post_meta($post->ID, 'gallery_post', True); if ($gallery_post != '') { $gpost = get_post($gallery_post); } // The actual fields for data entry $category = get_category(get_option('gallery_post_category')); echo "

Gallery Category: " . $category->name . "

"; $posts = get_gallery_post_list($category); $upload_dir = wp_upload_dir(); $plugin_url = GALLERY_POST_URL . 'gallery-post-show.php'; ?>

Search For Gallery Post:

Select the gallery to attach to the post: '; echo '

'; echo '
'; ?> 1) { // check if it's changed $gp = get_post_meta($post_id, 'gallery_post', True); if (!$gp) { $p = get_post($post_id); if ($p->post_type != "post") { return ;} } if ($gp != $gallery_post) { // save the post data update_post_meta($post_id, 'gallery_post', $gallery_post); // update the thumbnail id $thumbnail_id = get_post_thumbnail_id($gallery_post); update_post_meta( $post_id, '_thumbnail_id', $thumbnail_id ); // need to update gallery_post_list $category = get_category(get_option('gallery_post_category')); #update_gallery_post_list($category); } return; } else { // remove post meta data $gp = get_post_meta($post_id, 'gallery_post', True); if ($gp) { delete_post_meta($post_id, 'gallery_post'); delete_post_meta($post_id, '_thumbnail_id'); // need to update gallery_post_list $category = get_category(get_option('gallery_post_category')); #update_gallery_post_list($category); } $cat = get_post($post_id); $gallery_cat = get_category(get_option('gallery_post_category')); } } function gallery_post_publish_post($post_id) { $cat = get_the_category($post_id); $gallery_cat = get_category(get_option('gallery_post_category')); foreach ($cat as $c) { if ($c->term_id == $gallery_cat->term_id) { update_gallery_post_list($gallery_cat); return; } } } function gallery_post_delete_post($post_id) { $cat = get_the_category($post_id); $gallery_cat = get_category(get_option('gallery_post_category')); foreach ($cat as $c) { if ($c->term_id == $gallery_cat->term_id) { update_gallery_post_list($gallery_cat); return; } } } function gallery_post_settings_page() { global $wpdb; ?>

Gallery Post Options

This is the category that empty gallery posts are stored in.

Gallery Category 0, 'name' => 'gallery_post_category', 'orderby' => 'name', 'selected' => get_option('gallery_post_category'), 'hierarchical' => true, 'show_option_none' => __('None'))); ?>

Gallery Post Reports

+ Posts with no gallery or featured image

posts . " l, " . $wpdb->users . " u WHERE l.post_author=u.ID AND l.ID NOT IN (SELECT DISTINCT post_id FROM " . $wpdb->postmeta ." l WHERE meta_key = '_thumbnail_id' OR meta_key='gallery_post') AND l.ID NOT IN (SELECT object_id FROM " . $wpdb->term_relationships . " l WHERE l.term_taxonomy_id = " . $gallery_post_category . ") AND l.post_status='publish' and l.post_type='post' ORDER BY l.post_date DESC"; #print $sql; $results = $wpdb->get_results($sql); print ''; print ''; if ($results) { foreach ($results as $result) { print ''; print edit_post_link($result->post_title, '', $result->ID); print ''; print ''; print ''; print ''; } } else { print ''; } ?>
TitleAuthorStatusDate
', '' . $result->display_name . '' . $result->post_status . '' . $result->post_date . '
None found.

+ Unattached Gallery Posts

term_relationships . " l, ". $wpdb->posts . " p, " . $wpdb->users . " u WHERE p.post_author=u.ID AND l.object_id = p.ID AND l.object_id NOT IN (SELECT l.object_id FROM " . $wpdb->term_relationships . " l, " . $wpdb->postmeta . " p WHERE l.term_taxonomy_id = 61 and p.meta_key = 'gallery_post' and p.meta_value=l.object_id) AND l.term_taxonomy_id=61"; $results = $wpdb->get_results($sql); print ''; print ''; if ($results) { foreach ($results as $result) { print ''; print edit_post_link($result->post_title, '', $result->object_id); print ''; print ''; print ''; print ''; } } else { print ''; } ?>
TitleAuthorStatusDate
', '' . $result->display_name . '' . $result->post_status . '' . $result->post_date . '
None found.

+ Gallery Posts w/o Featured Image

term_relationships . " l, ". $wpdb->posts . " p, ". $wpdb->users . " u WHERE p.post_author = u.ID AND l.object_id = p.ID AND l.object_id NOT IN (SELECT l.object_id FROM " . $wpdb->term_relationships . " l, " . $wpdb->postmeta . " p WHERE l.term_taxonomy_id = 61 and p.meta_key = '_thumbnail_id' and p.post_id=l.object_id) AND l.term_taxonomy_id=61"; $results = $wpdb->get_results($sql); print ''; print ''; if ($results) { foreach ($results as $result) { print ''; print edit_post_link($result->post_title, '', $result->object_id); print ''; print ''; print ''; print ''; } } else { print ''; } ?>
TitleAuthorStatusDate
', '' . $result->display_name . '' . $result->post_status . '' . $result->post_date . '
None found.
prefix . "posts AS p INNER JOIN " . $wpdb->prefix . "term_relationships AS tr ON (p.ID = tr.object_id) WHERE 1=1 AND ( tr.term_taxonomy_id = " . $category->term_taxonomy_id . ") AND p.post_type = 'post' AND (p.post_status = 'publish') GROUP BY p.ID ORDER BY p.post_date DESC"; $posts = $wpdb->get_results($sql, ARRAY_A); update_option('gallery_post_list', serialize($posts)); } ?>