예제 #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);
             }
         }
     }
 }
			
			<select id="select-maxgallery" style="clear: both; display: block; margin-bottom: 1em;">
				<option value="">-- <?php 
    _e('Select Gallery', 'maxgalleria');
    ?>
 --</option>
				<optgroup label="<?php 
    _e('Image Galleries', 'maxgalleria');
    ?>
">
				<?php 
    foreach ($galleries as $gallery) {
        ?>
					<?php 
        $maxgallery = new MaxGalleryOptions($gallery->ID);
        if ($maxgallery->is_image_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 images', 'maxgalleria');
            }
            if (count($attachments) == 1) {
                $number = __('1 image', 'maxgalleria');
            }
            if (count($attachments) > 1) {
                $number = sprintf(__('%d images', 'maxgalleria'), count($attachments));
            }
            echo '<option value="' . $gallery->ID . '">' . $gallery->post_title . ' (' . $number . ', ' . $template_name . ')</option>';
예제 #3
0
											
											<input type="radio" id="maxgalleria_gallery_existing" name="maxgalleria_gallery_where" value="existing" />
											<label for="maxgalleria_gallery_existing"><?php 
        _e('Existing MaxGalleria gallery', 'maxgalleria');
        ?>
</label>
											
											<br />
											
											<select id="maxgalleria_gallery_id" name="maxgalleria_gallery_id">
											<?php 
        foreach ($maxgalleria_galleries as $gallery) {
            ?>
												<?php 
            $options = new MaxGalleryOptions($gallery->ID);
            if ($options->is_image_gallery()) {
                $args = array('post_parent' => $gallery->ID, 'post_type' => 'attachment', 'numberposts' => -1);
                $attachments = get_posts($args);
                $number = '';
                if (count($attachments) == 0) {
                    $number = __(' (0 images)', 'maxgalleria');
                }
                if (count($attachments) == 1) {
                    $number = __(' (1 image)', 'maxgalleria');
                }
                if (count($attachments) > 1) {
                    $number = sprintf(__(' (%d images)', 'maxgalleria'), count($attachments));
                }
                echo '<option value="' . $gallery->ID . '">' . $gallery->post_title . $number . '</option>';
            }
            ?>
예제 #4
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;
     }
 }