post_type, 'side', 'high'); add_meta_box('views_template', __('View Template Settings', 'wpv-views'), array($this,'view_settings_meta_box'), $post->post_type, 'side', 'high'); } function view_settings_meta_box() { global $post; $output_mode = get_post_meta($post->ID, '_wpv_view_template_mode', true); if (!$output_mode) { $output_mode = 'WP_mode'; } if ($output_mode == 'raw_mode') { // Simulate a click to the HTML button to get it to show the // control buttons. ?>
| get_view_template_select_box('', $options['views_template_loop_' . $name ]); $template = str_replace('name="views_template" id="views_template"', 'name="views_template_loop_' . $name . '" id="views_template_loop_' . $name . '"', $template); echo $template; $most_popular_term = $wpdb->get_var("SELECT term_id FROM {$wpdb->term_taxonomy} WHERE taxonomy = '{$name}' AND count = (SELECT MAX(count) FROM {$wpdb->term_taxonomy} WHERE taxonomy = '{$name}')"); if ($most_popular_term) { $link = get_term_link(intval($most_popular_term), $name); ?> _e('Preview', 'wpv-views'); ?> |
| get_view_template_select_box('', $options['views_template_for_' . $type ]); $template = str_replace('name="views_template" id="views_template"', 'name="views_template_for_' . $type . '" id="views_template_for_' . $type . '"', $template); echo $template; // add a preview button // preview the latest post of this type. list($join, $cond) = $this->_get_wpml_sql($type); $post_id = $wpdb->get_var("SELECT MAX({$wpdb->posts}.ID) FROM {$wpdb->posts} {$join} WHERE post_type='{$type}' AND post_status in ('publish') {$cond}"); if ($post_id) { $link = get_permalink($post_id); ?> _e('Preview', 'wpv-views'); ?> |
_get_wpml_sql($type);
$posts = $wpdb->get_col("SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} {$join} WHERE post_type='{$type}' {$cond}");
$count = sizeof($posts);
if ($count > 0) {
$posts = "'" . implode("','", $posts) . "'";
$set_count = $wpdb->get_var("SELECT COUNT(post_id) FROM {$wpdb->postmeta} WHERE meta_key='_views_template' AND meta_value='{$options['views_template_for_' . $type ]}' AND post_id IN ({$posts})");
if ($set_count < $count) {
echo ' ';
echo ' ';
$items_found[] = $type;
} else {
echo ''; echo sprintf(__('%d %ss use a different template:', 'wpv-views'), $count - $set_count, $type); echo ''; echo ''; echo ' '; echo ''; echo '' . sprintf(__('All %s are using this template', 'wpv-views'), $post_type->labels->name) . ' '; } } else { echo '' . sprintf(__('There are no %s', 'wpv-views'), $post_type->labels->name) . ' '; } } else { echo '' . sprintf(__('No template selected for %s', 'wpv-views'), $post_type->labels->name) . ' '; } ?> |
get_view_template_select_box('', $options['views_template_archive_for_' . $type ]); $template = str_replace('name="views_template" id="views_template"', 'name="views_template_archive_for_' . $type . '" id="views_template_archive_for_' . $type . '"', $template); echo $template; ?> |