public function save_new_gallery_type()
 {
     $options = new MaxGalleryOptions($_POST['post_ID']);
     $options->save_post_meta($options->type_key);
     $options->save_post_meta($options->template_key);
     echo $_POST['post_ID'];
     die;
 }
Esempio n. 2
0
 public function save_gallery_options()
 {
     global $post;
     if (isset($post)) {
         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
             return $post->ID;
         }
         if (!current_user_can('edit_post', $post->ID)) {
             return $post->ID;
         }
         $options = new MaxGalleryOptions($post->ID);
         $options->save_options();
     }
 }
 public function maxgallery_shortcode($atts)
 {
     extract(shortcode_atts(array('id' => '', 'name' => ''), $atts));
     $gallery_id = sanitize_text_field("{$id}");
     $gallery_name = sanitize_text_field("{$name}");
     $output = '';
     $gallery = null;
     if ($gallery_id != '' && $gallery_name != '') {
         // If both given, the id wins
         $gallery = get_post($gallery_id);
     }
     if ($gallery_id != '' && $gallery_name == '') {
         // Get the gallery by id
         $gallery = get_post($gallery_id);
     }
     if ($gallery_id == '' && $gallery_name != '') {
         // Get the gallery by name
         $query = new WP_Query(array('name' => $gallery_name, 'post_type' => MAXGALLERIA_POST_TYPE));
         $gallery = $query->get_queried_object();
     }
     if (isset($gallery) && $gallery->post_status == 'publish') {
         $args = array('post_parent' => $gallery->ID, 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'asc', 'numberposts' => -1);
         $attachments = get_posts($args);
         if (count($attachments) > 0) {
             $options = new MaxGalleryOptions($gallery->ID);
             global $maxgalleria;
             $templates = $maxgalleria->get_template_addons();
             foreach ($templates as $template) {
                 if ($template['key'] == $options->get_template()) {
                     $output = call_user_func($template['output'], $gallery, $attachments);
                 }
             }
         }
     }
     return $output;
 }
Esempio n. 4
0
<?php

global $post;
$options = new MaxGalleryOptions($post->ID);
$description_positions = array(__('Above Gallery', 'maxgalleria') => 'above', __('Below Gallery', 'maxgalleria') => 'below');
?>

<div class="meta-options">
	<table>
		<tr>
			<td width="80">
				<label for="<?php 
echo $options->description_enabled_key;
?>
"><?php 
_e('Enabled:', 'maxgalleria');
?>
</label>
			</td>
			<td>
				<input type="checkbox" id="<?php 
echo $options->description_enabled_key;
?>
" name="<?php 
echo $options->description_enabled_key;
?>
" <?php 
echo $options->get_description_enabled() == 'on' ? 'checked' : '';
?>
 />
			</td>
Esempio n. 5
0
<?php

global $post;
$maxgallery_options = new MaxGalleryOptions($post->ID);
?>

<div class="meta-options">
	<table>
		<tr>
			<td colspan="2">
				<strong><?php 
_e('Custom Styles', 'maxgalleria');
?>
</strong>
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<div style="color: #808080; font-style: italic; padding-bottom: 5px;"><?php 
_e('Add custom styles by using another stylesheet. This stylesheet will be loaded after all other gallery styles.', 'maxgalleria');
?>
</div>
			</td>
		</tr>
		<tr>
			<td width="60">
				<label for="<?php 
echo $maxgallery_options->custom_styles_enabled_key;
?>
"><?php 
_e('Enabled:', 'maxgalleria');
        }
        ?>
				<?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));
            }
Esempio n. 7
0
											<br /><br />
											
											<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>';
            }
 public function save_options($options = null)
 {
     if ($this->get_template() == 'image-tiles') {
         $options = $this->get_options();
         parent::save_options($options);
     }
 }
Esempio n. 9
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. 10
0
<?php

global $post;
$options = new MaxGalleryOptions($post->ID);
// Get all templates
global $maxgalleria;
$all_templates = $maxgalleria->get_template_addons();
// Filter for image templates
$image_templates = array();
foreach ($all_templates as $template) {
    if ($template['subtype'] == 'image') {
        $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);
?>