Пример #1
0
 public function gallery_custom_column_content($column)
 {
     global $post;
     switch ($column) {
         case FOOGALLERY_CPT_GALLERY . '_template':
             $gallery = FooGallery::get($post);
             $template = $gallery->gallery_template_details();
             if (false !== $template) {
                 echo $template['name'];
             }
             break;
         case FOOGALLERY_CPT_GALLERY . '_count':
             $gallery = FooGallery::get($post);
             echo $gallery->image_count();
             break;
         case FOOGALLERY_CPT_GALLERY . '_shortcode':
             $gallery = FooGallery::get($post);
             $shortcode = $gallery->shortcode();
             echo '<input type="text" readonly="readonly" size="' . strlen($shortcode) . '" value="' . esc_attr($shortcode) . '" class="foogallery-shortcode" />';
             $this->include_clipboard_script = true;
             break;
         case 'icon':
             $gallery = FooGallery::get($post);
             $img = $gallery->featured_image_html(array(80, 60), true);
             if ($img) {
                 echo $img;
             }
             break;
     }
 }
Пример #2
0
        public function gallery_custom_column_content($column)
        {
            global $post;
            switch ($column) {
                case FOOGALLERY_CPT_GALLERY . '_template':
                    $gallery = FooGallery::get($post);
                    $template = $gallery->gallery_template_details();
                    if (false !== $template) {
                        echo $template['name'];
                    }
                    break;
                case FOOGALLERY_CPT_GALLERY . '_count':
                    $gallery = FooGallery::get($post);
                    echo $gallery->image_count();
                    break;
                case FOOGALLERY_CPT_GALLERY . '_shortcode':
                    $gallery = FooGallery::get($post);
                    $shortcode = $gallery->shortcode();
                    echo '<code id="foogallery-copy-shortcode" data-clipboard-text="' . esc_attr($shortcode) . '"
					  title="' . esc_attr__('Click to copy to your clipboard', 'foogallery') . '"
					  class="foogallery-shortcode">' . $shortcode . '</code>';
                    $this->include_clipboard_script = true;
                    break;
                case 'icon':
                    $gallery = FooGallery::get($post);
                    $img = $gallery->featured_image_html(array(80, 60), true);
                    if ($img) {
                        echo $img;
                    }
                    break;
            }
        }
 function detach_gallery_from_all_posts($post_id)
 {
     $gallery = FooGallery::get_by_id($post_id);
     $posts = $gallery->find_usages();
     foreach ($posts as $post) {
         delete_post_meta($post->ID, FOOGALLERY_META_POST_USAGE_CSS);
     }
 }
Пример #4
0
 function add_images_to_sitemap($images, $post_id)
 {
     //check the content for $post_id contains a foogallery shortcode
     $post = get_post($post_id);
     //get all the foogallery shortcodes in the post
     $gallery_shortcodes = foogallery_extract_gallery_shortcodes($post->post_content);
     foreach ($gallery_shortcodes as $gallery_id => $shortcode) {
         //load each gallery
         $gallery = FooGallery::get_by_id($gallery_id);
         //add each image to the sitemap image array
         foreach ($gallery->attachments() as $attachment) {
             $image = array('src' => $attachment->url, 'title' => $attachment->caption, 'alt' => $attachment->alt);
             $images[] = $image;
         }
     }
     return $images;
 }
Пример #5
0
 /**
  * Parse the URL to get the used page.
  *
  * @since 1.0.0
  *
  * @uses "caldera_magic_tag-post" filter
  *
  * @param array $params
  *
  * @return string|array
  */
 public function permalink($params)
 {
     if (class_exists('FooGallery') && is_string($params) && strpos($params, '?foogallery')) {
         $url = parse_url($params);
         if (isset($url['query'])) {
             parse_str($url['query']);
             if (isset($foogallery)) {
                 $foo = \FooGallery::get_by_slug($foogallery);
                 $usages = $foo->find_usages();
                 if (is_array($usages) && isset($usages[0])) {
                     return esc_url(get_permalink($usages[0]->ID));
                 }
             }
         }
     }
     return $params;
 }
Пример #6
0
<?php

/**
 * FooGallery default responsive album template
 */
global $current_foogallery_album;
global $current_foogallery_album_arguments;
$gallery = foogallery_album_get_current_gallery();
$no_images_text = foogallery_album_template_setting('no_images_text', false);
$single_image_text = foogallery_album_template_setting('single_image_text', false);
$images_text = foogallery_album_template_setting('images_text', false);
$alignment = foogallery_album_template_setting('alignment', 'alignment-left');
$foogallery = false;
if (!empty($gallery)) {
    $foogallery = FooGallery::get_by_slug($gallery);
    //check to see if the gallery belongs to the album
    if (!$current_foogallery_album->includes_gallery($foogallery->ID)) {
        $foogallery = false;
    }
}
if (false !== $foogallery) {
    $album_url = foogallery_album_remove_gallery_from_link();
    echo '<div id="' . $current_foogallery_album->slug . '" class="foogallery-album-header">';
    echo '<p><a href="' . $album_url . '">' . foogallery_album_template_setting('back_to_album_text', '&laquo; back to album') . '</a></p>';
    echo '<h2>' . $foogallery->name . '</h2>';
    echo '</div>';
    echo do_shortcode('[foogallery id="' . $foogallery->ID . '"]');
} else {
    $title_bg = foogallery_album_template_setting('title_bg', '#ffffff');
    $title_font_color = foogallery_album_template_setting('title_font_color', '#000000');
    $args = foogallery_album_template_setting('thumbnail_dimensions', array());
/**
 * Returns all FooGallery galleries
 *
 * @return FooGallery[] array of FooGallery galleries
 */
function foogallery_get_all_galleries($excludes = false)
{
    $args = array('post_type' => FOOGALLERY_CPT_GALLERY, 'post_status' => array('publish', 'draft'), 'cache_results' => false, 'nopaging' => true);
    if (is_array($excludes)) {
        $args['post__not_in'] = $excludes;
    }
    $gallery_posts = get_posts($args);
    if (empty($gallery_posts)) {
        return array();
    }
    $galleries = array();
    foreach ($gallery_posts as $post) {
        $galleries[] = FooGallery::get($post);
    }
    return $galleries;
}
 /**
  * load the gallery based on either the id or slug, passed in via arguments
  *
  * @param $args array       Arguments passed in from the shortcode
  *
  * @return bool|FooGallery  The gallery object we want to render
  */
 function find_gallery($args)
 {
     $id = intval($this->get_arg($args, 'id'), 0);
     if ($id > 0) {
         //load gallery by ID
         return FooGallery::get_by_id($id);
     } else {
         //take into account the cases where id is passed in via the 'gallery' attribute
         $gallery = $this->get_arg($args, 'gallery', 0);
         if (intval($gallery) > 0) {
             //we have an id, so load
             return FooGallery::get_by_id(intval($gallery));
         }
         //we are dealing with a slug
         return FooGallery::get_by_slug($gallery);
     }
 }
 function ajax_get_gallery_info()
 {
     $nonce = safe_get_from_request('nonce');
     wp_verify_nonce($nonce, 'foogallery-timymce-nonce');
     $id = safe_get_from_request('foogallery_id');
     $gallery = FooGallery::get_by_id($id);
     $image_src = $gallery->featured_image_src('thumbnail', true);
     $json_array = array('id' => $id, 'name' => $gallery->name, 'count' => $gallery->image_count(), 'src' => $image_src);
     header('Content-type: application/json');
     echo json_encode($json_array);
     die;
 }
Пример #10
0
 public function ajax_clear_gallery_thumb_cache()
 {
     if (check_admin_referer('foogallery_clear_gallery_thumb_cache', 'foogallery_clear_gallery_thumb_cache_nonce')) {
         $foogallery_id = $_POST['foogallery_id'];
         $foogallery = FooGallery::get_by_id($foogallery_id);
         ob_start();
         //loop through all images, get the full sized file
         foreach ($foogallery->attachments() as $attachment) {
             $meta_data = wp_get_attachment_metadata($attachment->ID);
             $file = $meta_data['file'];
             wpthumb_delete_cache_for_file($file);
         }
         ob_end_clean();
         echo __('The thumbnail cache has been cleared!', 'foogallery');
     }
     die;
 }
        function render_import_form($galleries = false)
        {
            if (false === $galleries) {
                $galleries = $this->get_galleries();
            }
            $has_imports = get_option(self::NEXTGEN_OPTION_IMPORT_PROGRESS);
            $overall_progress = $this->get_overall_progress();
            $all_imports_completed = 100 === $overall_progress;
            $import_has_started = $this->import_in_progress();
            $importing = $import_has_started && defined('DOING_AJAX') && DOING_AJAX;
            $current_nextgen_id = get_option(self::NEXTGEN_OPTION_IMPORT_CURRENT, 0);
            ?>
			<table class="wp-list-table widefat" cellspacing="0">
				<thead>
				<tr>
					<th scope="col" id="cb" class="manage-column column-cb check-column">
						<?php 
            if (!$importing && $all_imports_completed) {
                ?>
						<label class="screen-reader-text"
						       for="cb-select-all-1"><?php 
                _e('Select All', 'foogallery');
                ?>
</label>
						<input id="cb-select-all-1" type="checkbox" <?php 
                echo $importing ? 'disabled="disabled"' : '';
                ?>
 checked="checked">
						<?php 
            }
            ?>
					</th>
					<th scope="col" class="manage-column">
						<span><?php 
            _e('NextGen Gallery', 'foogallery');
            ?>
</span>
					</th>
					<th scope="col" id="title" class="manage-column">
						<span><?php 
            printf(__('%s Name', 'foogallery'), foogallery_plugin_name());
            ?>
</span>
					</th>
					<th scope="col" id="title" class="manage-column">
						<span><?php 
            _e('Import Progress', 'foogallery');
            ?>
</span>
					</th>
				</tr>
				</thead>
				<tbody>
			<?php 
            $counter = 0;
            foreach ($galleries as $gallery) {
                $counter++;
                $progress = $this->get_import_progress($gallery->gid);
                $done = $progress->is_completed();
                $edit_link = '';
                $foogallery = false;
                if ($progress->foogallery_id > 0) {
                    $foogallery = FooGallery::get_by_id($progress->foogallery_id);
                    if ($foogallery) {
                        $edit_link = '<a href="' . admin_url('post.php?post=' . $progress->foogallery_id . '&action=edit') . '">' . $foogallery->name . '</a>';
                    } else {
                        $done = false;
                    }
                }
                ?>
				<tr class="<?php 
                echo $counter % 2 === 0 ? 'alternate' : '';
                ?>
">
					<?php 
                if (!$importing && !$done && $all_imports_completed) {
                    ?>
						<th scope="row" class="column-cb check-column">
							<input name="nextgen-id[]" type="checkbox" checked="checked" value="<?php 
                    echo $gallery->gid;
                    ?>
">
						</th>
					<?php 
                } else {
                    if ($importing && $gallery->gid == $current_nextgen_id) {
                        ?>
						<th>
							<div class="dashicons dashicons-arrow-right"></div>
						</th>
					<?php 
                    } else {
                        ?>
						<th>
						</th>
					<?php 
                    }
                }
                ?>
					<td>
						<?php 
                echo $gallery->title . ' ' . sprintf(__('(%s images)', 'foogallery'), $gallery->image_count);
                ?>
					</td>
					<td>
					<?php 
                if ($foogallery) {
                    echo $edit_link;
                } else {
                    ?>
						<input name="foogallery-name-<?php 
                    echo $gallery->gid;
                    ?>
" value="<?php 
                    echo $gallery->title;
                    ?>
">
					<?php 
                }
                ?>
					</td>
					<td class="nextgen-import-progress nextgen-import-progress-<?php 
                echo $progress->status;
                ?>
">
						<?php 
                echo $progress->message();
                ?>
					</td>
				</tr>
			<?php 
            }
            ?>
				</tbody>
			</table>
			<br/>

			<?php 
            echo '<input type="hidden" id="nextgen_import_progress" value="' . $overall_progress . '" />';
            wp_nonce_field('foogallery_nextgen_import', 'foogallery_nextgen_import');
            wp_nonce_field('foogallery_nextgen_import_refresh', 'foogallery_nextgen_import_refresh', false);
            wp_nonce_field('foogallery_nextgen_import_cancel', 'foogallery_nextgen_import_cancel', false);
            wp_nonce_field('foogallery_nextgen_import_reset', 'foogallery_nextgen_import_reset', false);
            if (!$import_has_started && !$importing) {
                ?>
				<input type="submit" class="button button-primary start_import"
				       value="<?php 
                _e('Start Import', 'foogallery');
                ?>
">
			<?php 
            } else {
                if ($import_has_started && !$importing) {
                    ?>
				<input type="submit" class="button button-primary continue_import" value="<?php 
                    _e('Resume Import', 'foogallery');
                    ?>
">
			<?php 
                } else {
                    ?>
				<input type="submit" class="button cancel_import" value="<?php 
                    _e('Stop Import', 'foogallery');
                    ?>
">
			<?php 
                }
            }
            if ($has_imports && !$importing) {
                ?>
				<input type="submit" name="foogallery_nextgen_reset" class="button reset_import" value="<?php 
                _e('Reset All Gallery Imports', 'foogallery');
                ?>
">
			<?php 
            }
            ?>
			<div id="import_spinner" style="width:20px">
				<span class="spinner"></span>
			</div>
			<?php 
            if ($importing) {
                ?>
				<div class="nextgen-import-progressbar">
					<span style="width:<?php 
                echo $overall_progress;
                ?>
%"></span>
				</div>
				<?php 
                echo intval($overall_progress);
                ?>
%
				<div style="width:20px; display: inline-block;">
					<span class="spinner shown"></span>
				</div>
			<?php 
            }
        }
 public function ajax_create_gallery_page()
 {
     if (check_admin_referer('foogallery_create_gallery_page', 'foogallery_create_gallery_page_nonce')) {
         $foogallery_id = $_POST['foogallery_id'];
         $foogallery = FooGallery::get_by_id($foogallery_id);
         $post = array('post_content' => $foogallery->shortcode(), 'post_title' => $foogallery->name, 'post_status' => 'draft', 'post_type' => 'page');
         wp_insert_post($post);
     }
     die;
 }