PluginProbe
MaxGalleria / 2.6
MaxGalleria v2.6
6.5.3 trunk 2.0.0 2.0.1 2.1.0 2.2.0 2.2.1 2.2.2 2.3 2.4 2.5 2.6 2.6.1 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 All 135 releases
maxgalleria / maxgalleria-media-button.php

maxgalleria-media-button.php in MaxGalleria 2.6, at maxgalleria-media-button.php

86 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 global $pagenow;
3 global $maxgalleria;
4 ?>
5
6 <?php // Only run in post/page creation and edit screens ?>
7 <?php if (in_array($pagenow, array('post.php', 'page.php', 'post-new.php', 'post-edit.php'))) { ?>
8 <?php // Get all published galleries ?>
9 <?php $galleries = get_posts(array('post_type' => MAXGALLERIA_POST_TYPE, 'post_status' => 'publish', 'numberposts' => -1)) ?>
10
11 <script type="text/javascript">
12 function insertGalleryShortcode() {
13 // Grab gallery ID
14 var gallery_id = jQuery("#select-maxgallery").val();
15
16 // Check if a gallery was selected
17 if (gallery_id == "") {
18 alert("<?php _e('Please select a gallery.', 'maxgalleria') ?>");
19 return;
20 }
21
22 // Send shortcode to the editor
23 window.send_to_editor('[maxgallery id="' + gallery_id + '"]');
24 }
25 </script>
26
27 <div id="select-maxgallery-container" style="display: none;">
28 <div class="wrap">
29 <h2 style="padding-top: 3px; padding-left: 40px; background: url(<?php echo MAXGALLERIA_PLUGIN_URL . '/images/maxgalleria-icon-32.png' ?>) no-repeat;">
30 <?php _e('Insert Gallery into Editor', 'maxgalleria') ?>
31 </h2>
32
33 <p><?php _e('Select a gallery from the list below, then click "Insert Gallery" to place the gallery shortcode in the editor.', 'maxgalleria') ?></p>
34
35 <select id="select-maxgallery" style="clear: both; display: block; margin-bottom: 1em;">
36 <option value="">-- <?php _e('Select Gallery', 'maxgalleria') ?> --</option>
37 <optgroup label="<?php _e('Image Galleries', 'maxgalleria') ?>">
38 <?php foreach ($galleries as $gallery) { ?>
39 <?php
40 $maxgallery = new MaxGalleryOptions($gallery->ID);
41 if ($maxgallery->is_image_gallery()) {
42 $args = array('post_parent' => $gallery->ID, 'post_type' => 'attachment', 'numberposts' => -1);
43 $attachments = get_posts($args);
44
45 $template_key = $maxgallery->get_template();
46 $template_name = $maxgalleria->get_template_name($template_key);
47
48 $number = '';
49 if (count($attachments) == 0) { $number = __('0 images', 'maxgalleria'); }
50 if (count($attachments) == 1) { $number = __('1 image', 'maxgalleria'); }
51 if (count($attachments) > 1) { $number = sprintf(__('%d images', 'maxgalleria'), count($attachments)); }
52
53 echo '<option value="' . $gallery->ID . '">' . $gallery->post_title . ' (' . $number . ', ' . $template_name . ')</option>';
54 }
55 ?>
56 <?php } ?>
57 </optgroup>
58
59 <optgroup label="<?php _e('Video Galleries', 'maxgalleria') ?>">
60 <?php foreach ($galleries as $gallery) { ?>
61 <?php
62 $maxgallery = new MaxGalleryOptions($gallery->ID);
63 if ($maxgallery->is_video_gallery()) {
64 $args = array('post_parent' => $gallery->ID, 'post_type' => 'attachment', 'numberposts' => -1);
65 $attachments = get_posts($args);
66
67 $template_key = $maxgallery->get_template();
68 $template_name = $maxgalleria->get_template_name($template_key);
69
70 $number = '';
71 if (count($attachments) == 0) { $number = __('0 videos', 'maxgalleria'); }
72 if (count($attachments) == 1) { $number = __('1 video', 'maxgalleria'); }
73 if (count($attachments) > 1) { $number = sprintf(__('%d videos', 'maxgalleria'), count($attachments)); }
74
75 echo '<option value="' . $gallery->ID . '">' . $gallery->post_title . ' (' . $number . ', ' . $template_name . ')</option>';
76 }
77 ?>
78 <?php } ?>
79 </optgroup>
80 </select>
81
82 <input type="button" class="button-primary" value="<?php _e('Insert Gallery', 'maxgalleria') ?>" onclick="insertGalleryShortcode();" />
83 <a class="button-secondary" style="margin-left: 10px;" onclick="tb_remove();"><?php _e('Cancel', 'maxgalleria') ?></a>
84 </div>
85 </div>
86 <?php } ?>