Esempio n. 1
0
 public function add_gallery_meta_boxes()
 {
     global $post;
     global $maxgalleria;
     $new_gallery = $maxgalleria->new_gallery;
     $image_gallery = $maxgalleria->image_gallery;
     $video_gallery = $maxgalleria->video_gallery;
     if (isset($post)) {
         $options = new MaxGalleryOptions($post->ID);
         if ($options->is_new_gallery()) {
             $this->add_normal_meta_box('meta-new', __('New Gallery', 'maxgalleria'), array($new_gallery, 'show_meta_box_new'));
         }
         if ($options->is_image_gallery()) {
             $this->add_side_meta_box('meta-shortcodes', __('Shortcodes', 'maxgalleria'), array($image_gallery, 'show_meta_box_shortcodes'));
             // Only show if a template has been chosen
             if ($options->get_template() != '') {
                 do_action(MAXGALLERIA_ACTION_BEFORE_TEMPLATE_META_BOXES);
                 $this->add_normal_meta_box('meta-image-gallery', __('Gallery', 'maxgalleria'), array($image_gallery, 'show_meta_box_gallery'));
                 do_action(MAXGALLERIA_ACTION_AFTER_TEMPLATE_META_BOXES);
             }
         }
         if ($options->is_video_gallery()) {
             $this->add_side_meta_box('meta-shortcodes', __('Shortcodes', 'maxgalleria'), array($video_gallery, 'show_meta_box_shortcodes'));
             // Only show if a template has been chosen
             if ($options->get_template() != '') {
                 do_action(MAXGALLERIA_ACTION_BEFORE_TEMPLATE_META_BOXES);
                 $this->add_normal_meta_box('meta-video-gallery', __('Gallery', 'maxgalleria'), array($video_gallery, 'show_meta_box_gallery'));
                 do_action(MAXGALLERIA_ACTION_AFTER_TEMPLATE_META_BOXES);
             }
         }
     }
 }
        ?>
				<?php 
    }
    ?>
				</optgroup>
				
				<optgroup label="<?php 
    _e('Video Galleries', 'maxgalleria');
    ?>
">
				<?php 
    foreach ($galleries as $gallery) {
        ?>
					<?php 
        $maxgallery = new MaxGalleryOptions($gallery->ID);
        if ($maxgallery->is_video_gallery()) {
            $args = array('post_parent' => $gallery->ID, 'post_type' => 'attachment', 'numberposts' => -1);
            $attachments = get_posts($args);
            $template_key = $maxgallery->get_template();
            $template_name = $maxgalleria->get_template_name($template_key);
            $number = '';
            if (count($attachments) == 0) {
                $number = __('0 videos', 'maxgalleria');
            }
            if (count($attachments) == 1) {
                $number = __('1 video', 'maxgalleria');
            }
            if (count($attachments) > 1) {
                $number = sprintf(__('%d videos', 'maxgalleria'), count($attachments));
            }
            echo '<option value="' . $gallery->ID . '">' . $gallery->post_title . ' (' . $number . ', ' . $template_name . ')</option>';
Esempio n. 3
0
 public function create_gallery_columns($column)
 {
     // The Title and Date columns are standard, so we don't have to explicitly provide output for them
     global $post;
     $maxgallery = new MaxGalleryOptions($post->ID);
     // Get all the attachments (the -1 gets all of them)
     $args = array('post_parent' => $post->ID, 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'asc', 'numberposts' => -1);
     $attachments = get_posts($args);
     // Rounded borders
     $style = 'border-radius: 2px; -moz-border-radius: 2px; -webkit-border-radius: 2px;';
     switch ($column) {
         case 'type':
             if ($maxgallery->is_image_gallery()) {
                 echo '<img src="' . MAXGALLERIA_PLUGIN_URL . '/images/image-32.png" alt="' . __('Image', 'maxgalleria') . '" title="' . __('Image', 'maxgalleria') . '" style="' . $style . '" />';
             }
             if ($maxgallery->is_video_gallery()) {
                 echo '<img src="' . MAXGALLERIA_PLUGIN_URL . '/images/video-32.png" alt="' . __('Video', 'maxgalleria') . '" title="' . __('Video', 'maxgalleria') . '" style="' . $style . '" />';
             }
             break;
         case 'thumbnail':
             if (has_post_thumbnail($post->ID)) {
                 echo get_the_post_thumbnail($post->ID, array(32, 32), array('style' => $style));
             } else {
                 // Show the first thumb
                 foreach ($attachments as $attachment) {
                     $no_media_icon = 0;
                     echo wp_get_attachment_image($attachment->ID, array(32, 32), $no_media_icon, array('style' => $style));
                     break;
                 }
             }
             break;
         case 'template':
             $template_key = $maxgallery->get_template();
             echo $this->get_template_name($template_key);
             break;
         case 'number':
             if ($maxgallery->is_image_gallery()) {
                 if (count($attachments) == 0) {
                     _e('0 images', 'maxgalleria');
                 }
                 if (count($attachments) == 1) {
                     _e('1 image', 'maxgalleria');
                 }
                 if (count($attachments) > 1) {
                     printf(__('%d images', 'maxgalleria'), count($attachments));
                 }
             }
             if ($maxgallery->is_video_gallery()) {
                 if (count($attachments) == 0) {
                     _e('0 videos', 'maxgalleria');
                 }
                 if (count($attachments) == 1) {
                     _e('1 video', 'maxgalleria');
                 }
                 if (count($attachments) > 1) {
                     printf(__('%d videos', 'maxgalleria'), count($attachments));
                 }
             }
             break;
         case 'shortcode':
             echo '[maxgallery id="' . $post->ID . '"]';
             if ($post->post_status == 'publish') {
                 echo '<br />';
                 echo '[maxgallery name="' . $post->post_name . '"]';
             }
             break;
     }
 }
Esempio n. 4
0
        $arr = array($template['key'] => array('name' => $template['name'], 'image' => $template['image']));
        $image_templates = array_merge($image_templates, $arr);
    }
}
// Filter for video templates
$video_templates = array();
foreach ($all_templates as $template) {
    if ($template['subtype'] == 'video') {
        $arr = array($template['key'] => array('name' => $template['name'], 'image' => $template['image']));
        $video_templates = array_merge($video_templates, $arr);
    }
}
// Default to image templates
$templates = $image_templates;
// But check to see if it should use video templates
if ($options->is_video_gallery()) {
    $templates = $video_templates;
}
asort($templates);
?>

<script type="text/javascript">		
	jQuery(document).ready(function() {
		jQuery(".meta-options .meta-template img").click(function() {
			var images = jQuery(".meta-options .meta-template img");
			jQuery.each(images, function() {
				jQuery(this).removeClass("selected");
			});
			
			jQuery(this).addClass("selected");
			jQuery(this).next().attr("checked", true);