/wordpress/wp-content/plugins/picasa-express-x2/picasa-express-2.php
PHP | 2467 lines | 1774 code | 277 blank | 416 comment | 280 complexity | 2d5b5ce85bb97567495a9b954e63b1b3 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- Plugin Name: Picasa Express x2
- Plugin URI: http://wott.info/picasa-express
- Description: Browse, search and select photos from any publicly available Google+/Picasa Web Album and add them to your post/pages.
- Version: 2.0.2
- Author: gjanes
- Author URI: http://www.janesfamily.org
- Text Domain: pe2
- Domain Path: /
-
- Thank you to Wott (wotttt@gmail.com | http://wott.info/picasa-express) for plugin
- Picasa Express 2.0. This plugin contained a large re-write and many improvements
- of the plugin: Picasa Image Express 2.0 RC2
-
- Thank you to Scrawl ( scrawl@psytoy.net ) for plugin Picasa Image Express 2.0 RC2
- for main idea and Picasa icons
-
- Copyright 2013 gjanes ( email : gcj.wordpress@janesfamily.org )
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License, version 2, as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
- define( 'PE2_VERSION', '2.0.2' );
-
- if (!class_exists("PicasaExpressX2")) {
- class PicasaExpressX2 {
-
- /**
- * Define options and default values
- * @var array
- */
- var $options = array(
- 'pe2_configured' => false,
- 'pe2_icon' => 1,
- 'pe2_roles' => array('administrator'=>1),
- 'pe2_level' => 'blog',
- 'pe2_user_name' => 'undefined',
-
- 'pe2_caption' => 0,
- 'pe2_video_overlay' => 1,
- 'pe2_title' => 1,
- 'pe2_link' => 'thickbox_custom',
- 'pe2_relate_images' => '1',
-
- 'pe2_img_align' => 'left',
- 'pe2_auto_clear' => '1',
- 'pe2_img_css' => '',
- 'pe2_img_style' => '',
-
- 'pe2_featured_tag' => 1,
- 'pe2_additional_tags' => '',
-
- 'pe2_gal_align' => 'left',
- 'pe2_gal_css' => '',
- 'pe2_gal_style' => '',
-
- 'pe2_img_sort' => 0,
- 'pe2_img_asc' => 1,
- 'pe2_dialog_crop' => 1,
- 'pe2_max_albums_displayed' => '',
-
- 'pe2_gal_order' => 0,
-
- 'pe2_token' => '',
-
- 'pe2_footer_link' => 1,
- 'pe2_donate_link' => 1,
-
- 'pe2_save_state' => 1,
- 'pe2_saved_state' => '',
- 'pe2_last_album' => '',
- 'pe2_saved_user_name' => '',
-
- 'pe2_large_limit' => '',
- 'pe2_single_image_size' => 'w400',
- 'pe2_single_video_size' => 'w400',
- );
-
- /**
- * plugin URL
- * @var string
- */
- var $plugin_URL;
-
- /**
- * Google auth plugin URL
- * @var string
- */
- var $google_authorize_plugin_URL;
-
- /**
- * plugin photos displayed
- * @var array
- */
- var $photos_displayed;
-
- function PicasaExpressX2() {
- // Hook for plugin de/activation
- $multisite = false;
- if (
- (function_exists('is_multisite') && is_multisite()) || // new version check
- (function_exists('activate_sitewide_plugin')) // pre 3.0 version check
- ){
- $multisite = true;
- register_activation_hook( __FILE__, array (&$this, 'init_site_options' ) );
- register_deactivation_hook( __FILE__, array (&$this, 'delete_site_options' ) );
- } else {
- register_activation_hook( __FILE__, array (&$this, 'init_options' ) );
- register_deactivation_hook( __FILE__, array (&$this, 'delete_options' ) );
- }
-
- // Retrieve plugin options from database if plugin configured
- if (!$this->options['pe2_configured']) {
- // get plugin URL
- $this->plugin_URL = plugins_url().'/'.dirname(plugin_basename(__FILE__));
-
- // figure out the authorize URL and capitalize the URL properly to get by
- // the bug in google authorize
- $tmp = parse_url(plugins_url());
- $tmp2 = explode('.', $tmp['host']);
- $tmp2 = array_map('ucwords', $tmp2);
- $tmp_host = implode('.', $tmp2);
- $this->google_authorize_plugin_URL = $tmp['scheme'].'://'.$tmp_host.$tmp['path'].'/'.plugin_basename(__FILE__);
- unset($tmp, $tmp2, $tmp_host);
-
- // define the empty array used to keep track of photos displayed
- // (thus preventing duplicates in lightbox/thickbox/highslide nav
- $this->photos_displayed = array();
-
- foreach ($this->options as $key => $option) {
- $this->options[$key] = get_option($key,$option);
- if (!preg_match('/^[whs]\d+$/',$this->options['pe2_large_limit']))
- $this->options['pe2_large_limit'] = '';
- }
-
- if ($this->options['pe2_configured']) {
- if (is_admin()) {
-
- // loading localization if exist
- add_action('init', array(&$this, 'load_textdomain'));
-
- // Add settings to the plugins management page under
- add_filter('plugin_action_links_'.plugin_basename(__FILE__), array(&$this, 'add_settings_link'));
- // Add a page which will hold the Options form
- add_action('admin_menu', array(&$this, 'add_settings_page'));
- add_filter('contextual_help', array(&$this, 'contextual_help'), 10 , 2);
-
- // Add media button to editor
- add_action('media_buttons', array(&$this, 'add_media_button'), 20);
- // Add iframe page creator
- add_action('media_upload_picasa', array(&$this, 'media_upload_picasa'));
-
- // AJAX request from media_upload_picasa iframe script ( pe2-scripts.js )
- add_action('wp_ajax_pe2_get_gallery', array(&$this, 'get_gallery'));
- add_action('wp_ajax_pe2_get_images', array(&$this, 'get_images'));
- add_action('wp_ajax_pe2_save_state', array(&$this, 'save_state'));
-
- // Add setting for user profile if capable
- add_action('show_user_profile', array(&$this, 'user_profile'));
- add_action('personal_options_update', array(&$this, 'user_update'));
-
- // new site creation
- if ($multisite && function_exists('get_site_option') && get_site_option('pe2_multisite'))
- add_action('wpmu_new_blog', array(&$this, 'wpmu_new_blog') );
-
- } else {
-
- /* Attach stylesheet in the user page
- * you can enable attach styles if define some special
- */
- // add_action('wp_head', array(&$this, 'add_style'));
-
- add_shortcode('pe2-gallery', array(&$this, 'gallery_shortcode'));
- add_shortcode('pe2-image', array(&$this, 'image_shortcode'));
- add_shortcode('clear', array(&$this, 'clear_shortcode'));
-
- if ($this->options['pe2_footer_link']) {
- add_action('wp_footer', array(&$this, 'add_footer_link'));
- }
- }}
- }
-
- }
-
- /**
- * Walk all blogs and apply $func to every founded
- *
- * @global integer $blog_id
- * @param function $func Function to apply changes to blog
- */
- function walk_blogs($func) {
-
- $walk = isset($_GET['networkwide'])||isset($_GET['sitewide']); // (de)activate by command from site admin
-
- if (function_exists('get_site_option')) {
- $active_sitewide_plugins = (array) maybe_unserialize( get_site_option('active_sitewide_plugins') );
- $walk = $walk || isset($active_sitewide_plugins[plugin_basename(__FILE__)]);
- }
-
- if ( $walk && function_exists('switch_to_blog')) {
-
- add_site_option('pe2_multisite', true);
-
- global $blog_id, $switched_stack, $switched;
- $saved_blog_id = $blog_id;
-
- global $wpdb;
- $blogs = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'");
- if( is_array( $blogs ) ) {
- reset( $blogs );
- foreach ( (array) $blogs as $new_blog_id ) {
- switch_to_blog($new_blog_id);
- $this->$func();
- array_pop( $switched_stack ); // clean
- }
- switch_to_blog($saved_blog_id);
- array_pop( $switched_stack ); // clean
- $switched = ( is_array( $switched_stack ) && count( $switched_stack ) > 0 );
- }
- } else {
- $this->$func();
- }
- }
-
- function init_site_options() {
- $this->walk_blogs('init_options');
- }
- function delete_site_options() {
- $this->walk_blogs('delete_options');
- if (function_exists('delete_site_option')) delete_site_option('pe2_multisite');
- }
- function wpmu_new_blog($new_blog_id) {
- switch_to_blog($new_blog_id);
- $this->init_options();
- restore_current_blog();
- }
-
- /**
- * Enable plugin configuration and set roles by config
- */
- function init_options() {
- add_option('pe2_configured',true);
-
- foreach (get_option('pe2_roles',$this->options['pe2_roles']) as $role=>$data) {
- if ($data) {
- $role = get_role($role);
- $role->add_cap('picasa_dialog');
- }
- }
- }
-
- /**
- * Delete plugin configuration flag
- */
- function delete_options() {
- delete_option('pe2_configured');
- }
-
- function load_textdomain() {
- if ( function_exists('load_plugin_textdomain') ) {
- load_plugin_textdomain('pe2', false, dirname( plugin_basename( __FILE__ ) ) );
- }
- }
-
- function add_footer_link() {
- echo "<p class=\"footer-link\" style=\"font-size:75%;text-align:center;\"><a href=\"http://wott.info/\">".__('With Picasa plugin by Geoff Janes & Wott','pe2')."</a></p>";
- }
-
- /**
- * Echo the link with icon to run plugin dialog
- *
- * @param string $id optinal id for link to plugin dialog
- * @return void
- */
- function add_media_button($id = '') {
-
- if (!current_user_can('picasa_dialog')) return;
-
- $plugin_URL = $this->plugin_URL;
- $icon = $this->options['pe2_icon'];
- // 'type=picasa' => 'media_upload_picasa' action above
- $media_picasa_iframe_src = "media-upload.php?type=picasa&tab=type&TB_iframe=true&width=640&height=566";
- $media_picasa_title = __("Add Picasa image or gallery", 'pe2');
- $put_id = ($id)?"id=\"$id-picasa_dialog\"":'';
-
- echo "<a href=\"$media_picasa_iframe_src\" $put_id class=\"thickbox\" title=\"$media_picasa_title\"><img src=\"$plugin_URL/icon_picasa$icon.gif\" alt=\"$media_picasa_title\" /></a>";
-
- }
-
- /**
- * Config scrips and styles and print iframe content for dialog
- *
- */
- function media_upload_picasa() {
-
- if (!current_user_can('picasa_dialog')) return;
-
- // add script and style for dialog
- add_action('admin_print_styles', array(&$this, 'add_style'));
- add_action('admin_print_scripts', array(&$this, 'add_script'));
-
- // we do not need default script for media_upload
- $to_remove = explode(',', 'swfupload-all,swfupload-handlers,image-edit,set-post-thumbnail,imgareaselect');
- foreach ($to_remove as $handle) {
- if (function_exists('wp_dequeue_script')) wp_dequeue_script($handle);
- else wp_deregister_script($handle);
- }
-
- // but still reuse code for make media_upload iframe
- return wp_iframe(array(&$this, 'type_dialog'));
- }
-
- /**
- * Attach script and localisation text in dialog
- * run from action 'admin_print_scripts' from {@link media_upload_picasa()}
- *
- * @global object $wp_scripts
- */
- function add_script() {
- global $wp_scripts;
- $wp_scripts->add('pe2-script', $this->plugin_URL.'/pe2-scripts.js', array('jquery'),PE2_VERSION);
- $options = array(
- 'waiting' => str_replace('%pluginpath%', $this->plugin_URL, __("<img src='%pluginpath%/loading.gif' height='16' width='16' /> Please wait", 'pe2')),
- 'env_error' => __("Error: Can not insert image(s) due wrong envirionment\nCheck script media-upload.js in the parent/editor window", 'pe2'),
- 'image' => __('Image', 'pe2'),
- 'gallery' => __('Gallery', 'pe2'),
- 'reload' => __('Reload', 'pe2'),
- 'options' => __('Options', 'pe2'),
- 'album' => __('Album', 'pe2'),
- 'shortcode' => __('Shortcode', 'pe2'),
- 'thumb_w' => get_option('thumbnail_size_w'),
- 'thumb_h' => get_option('thumbnail_size_h'),
- 'thumb_crop'=> get_option('thumbnail_crop'),
- 'state' => 'albums',
- );
- foreach ( $this->options as $key => $val ) {
- if (!is_array($val)) // skip arrays: pe2_roles
- $options[$key]=$val;
- }
- if ($this->options['pe2_level'] == 'user') {
- global $current_user;
- $options['pe2_save_state'] = get_user_meta($current_user->data->ID,'pe2_save_state',true);
- $options['pe2_saved_state'] = get_user_meta($current_user->data->ID,'pe2_saved_state',true);
- $options['pe2_last_album'] = get_user_meta($current_user->data->ID,'pe2_last_album',true);
- $options['pe2_saved_user_name'] = get_user_meta($current_user->data->ID,'pe2_saved_user_name',true);
- $options['pe2_user_name'] = get_user_meta($current_user->data->ID,'pe2_user_name',true);
- }
-
- if ($options['pe2_save_state']) {
- if ($options['pe2_saved_state']) $options['state'] = $options['pe2_saved_state'];
- if ($options['pe2_saved_user_name']) $options['pe2_user_name'] = $options['pe2_saved_user_name'];
- }
-
- $options['pe2_user_name'] = trim($options['pe2_user_name']);
- if (''==$options['pe2_user_name']) $options['pe2_user_name']='undefined';
- if ('undefined'==$options['pe2_user_name']) $options['state']= 'nouser';
-
- foreach ( $options as $key => $val ) {
- $options[$key] = rawurlencode($val);
- }
- $wp_scripts->localize( 'pe2-script', 'pe2_options', $options );
-
- $wp_scripts->enqueue('pe2-script');
- }
-
- /**
- * Request styles
- * run by action 'admin_print_styles' from {@link media_upload_picasa()}
- *
- * @global boolean $is_IE
- */
- function add_style() {
- global $is_IE;
- wp_enqueue_style('media');
- wp_enqueue_style('pe2-style', $this->plugin_URL.'/picasa-express-2.css',array(),PE2_VERSION,'all');
- if ($is_IE)
- wp_enqueue_style('pe2-style-ie', $this->plugin_URL.'/picasa-express-2-IE.css',array(),PE2_VERSION,'all');
- }
-
- /**
- * Print dialog html
- * run by parameter in (@link wp_iframe()}
- *
- * @global object $current_user
- */
- function type_dialog() {
-
- /*
- <a href="#" class="button alignright">Search</a>
- <form><input type="text" class="alignright" value="Search ..."/></form>
- */
- ?>
- <div id="pe2-nouser" class="pe2-header" style="display:none;">
- <input type="text" class="alignleft" value="user name"/>
- <a id="pe2-change-user" href="#" class="button alignleft pe2-space"><?php _e('Change user', 'pe2')?></a>
- <a id="pe2-cu-cancel" href="#" class="button alignleft pe2-space"><?php _e('Cancel', 'pe2')?></a>
- <div id="pe2-message1" class="alignleft"></div>
- <br style="clear:both;"/>
- </div>
- <div id="pe2-albums" class="pe2-header" style="display:none;">
- <a id="pe2-user" href="#" class="button alignleft"></a>
- <div id="pe2-message2" class="alignleft"><?php _e('Select an Album', 'pe2')?></div>
- <a id="pe2-switch2" href="#" class="button alignleft"><?php _e('Album', 'pe2')?></a>
- <a href="#" class="pe2-options button alignright pe2-space" ><?php _e('Options','pe2'); ?></a>
- <a href="#" class="pe2-reload button alignright" ></a>
- <br style="clear:both;"/>
- </div>
- <div id="pe2-images" class="pe2-header" style="display:none;">
- <a id="pe2-album-name" href="#" class="button alignleft"><?php _e('Select an Album', 'pe2')?></a>
- <div id="pe2-message3" class="alignleft"><?php _e('Select images', 'pe2')?></div>
-
- <a id="pe2-switch" href="#" class="button alignleft"><?php _e('Image', 'pe2')?></a>
- <a id="pe2-insert" href="#" class="button alignleft pe2-space" style="display:none;"><?php _e('Insert', 'pe2')?></a>
- <a href="#" class="pe2-options button alignright pe2-space" ></a>
- <a href="#" class="pe2-reload button alignright" ></a>
- <br style="clear:both;"/>
- </div>
- <div id="pe2-options" style="display:none;">
- <h3><?php _e('Image properties', 'pe2') ?></h3>
- <table class="form-table">
- <?php
- // ---------------------------------------------------------------------
- // single image thunbnail size (override)
- $option = $this->options['pe2_single_image_size'];
- preg_match('/(\w)(\d+)/',$option,$mode);
- if(strpos($option, '-c') !== false)
- $crop = true;
- else
- $crop = false;
- if (!$mode) $mode=array('','','');
- $this->make_settings_row(
- __('Single image thumbnail size', 'pe2'),
- '<input type="hidden" name="pe2_single_image_size" id="pe2_single_image_size" value="'.$option.'" />Scale: [ <label><input type="radio" name="pe2_single_image_size_mode" class="pe2_single_image_size" value="w" '.checked($mode[1], 'w', false).' /> '.__('width','pe2').'</label> '.
- '<label><input type="radio" name="pe2_single_image_size_mode" class="pe2_single_image_size" value="h" '.checked($mode[1], 'h', false).' /> '.__('height','pe2').'</label> '.
- '<label><input type="radio" name="pe2_single_image_size_mode" class="pe2_single_image_size" value="s" '.checked($mode[1], 's', false).' /> '.__('any','pe2').'</label> '.
- __(' ] proportionally to ','pe2').
- '<input type="text" name="pe2_single_image_size_dimension" class="pe2_single_image_size" style="width:60px;" id="pe2_single_image_size_dimension" value="'.$mode[2].'" />'.
- __(' pixels.','pe2').
- '<label> <input type="checkbox" name="pe2_single_image_size_crop" class="pe2_single_image_size" value="-c" '.checked($crop, true, false).' /> '.__(' Crop image into a square.','pe2').'</label> '
- ,
- sprintf(__('Value \'%s\' will be used to set single image thumbnail size'),"<span id=\"pe2_single_image_size_message_option\">$option</span>"),
- '',
- 'id="pe2_single_image_size_message" style="display:'.(($option) ? 'block' : 'none').';"'
- );
- ?>
- <style type="text/css">
- input:disabled {
- background-color: #eee;
- }
- </style>
- <script type="text/javascript">
- function pe2_compute_image_size(mode,value,type) {
- var target_input = jQuery('input[name=pe2_' + type + '_size]');
- if(target_input.length == 0){
- // this is the large image size selection
- target_input = jQuery('input[name=pe2_' + type + '_limit]');
- }
- var val = target_input.val();
-
- // check for the case where it was just enabled after having
- // been disabled and saved
- if((val == '') || (val == 'w')){
- // override with some default
- val = 'w600';
- }
-
- // split into our parts
- var parts = {
- mode : val.substring(0, 1),
- size : val.replace(/^[a-z]*([0-9]*).*$/,'$1'),
- crop : val.replace(/^[a-z]*[0-9]*(.*)$/,'$1')};
-
- // override the particular part that was just changed
- parts[mode] = value;
-
- // store the value back in our target
- target_input.val(parts.mode+parts.size+parts.crop);
-
- // update the text that displays the setting being used
- jQuery('#pe2_' + type + '_size_message_option').text(parts.mode+parts.size+parts.crop);
-
- // if the target inputs type is hidden, then also trigger
- // the .change event (hiddens don't automatically trigger
- // the .change event for some reason)
- if(target_input.attr('type') == 'hidden'){
- target_input.trigger('change');
- }
- }// end function pe2_compute_image_size(..)
- // if mode changes, update image size
- jQuery('input[name=pe2_single_image_size_mode]').change(function(){ if (jQuery(this).attr('checked')) pe2_compute_image_size('mode',jQuery(this).val(), 'single_image'); });
- // if size changes, update image size
- jQuery('input[name=pe2_single_image_size_dimension]').change(function(){
- pe2_compute_image_size('size',jQuery('input[name=pe2_single_image_size_dimension]').val(), 'single_image');
- });
- // if crop changes, update image size
- jQuery('input[name=pe2_single_image_size_crop]').change(function(){
- pe2_determine_crop('single_image', this);
- });
- function pe2_determine_crop(name, obj){
- // use the checked selector to determine if the checkbox is
- // checked or not
- if(jQuery('input[name=pe2_' + name + '_size_crop]:checked').length > 0){
- // the checkbox is checked
- pe2_compute_image_size('crop',jQuery(obj).val(), name);
- }else{
- // the checkbox is not checked
- pe2_compute_image_size('crop','',name);
- }
- }
- </script>
- <?php
- // ---------------------------------------------------------------------
- // single video thunbnail size (override)
- $option = $this->options['pe2_single_video_size'];
- preg_match('/(\w)(\d+)/',$option,$mode);
- if(strpos($option, '-c') !== false)
- $crop = true;
- else
- $crop = false;
- if (!$mode) $mode=array('','','');
- $this->make_settings_row(
- __('Single video thumbnail size', 'pe2'),
- '<input type="hidden" name="pe2_single_video_size" id="pe2_single_video_size" value="'.$option.'" />Scale: [ <label><input type="radio" name="pe2_single_video_size_mode" class="pe2_single_video_size" value="w" '.checked($mode[1], 'w', false).' /> '.__('width','pe2').'</label> '.
- '<label><input type="radio" name="pe2_single_video_size_mode" class="pe2_single_video_size" value="h" '.checked($mode[1], 'h', false).' /> '.__('height','pe2').'</label> '.
- '<label><input type="radio" name="pe2_single_video_size_mode" class="pe2_single_video_size" value="s" '.checked($mode[1], 's', false).' /> '.__('any','pe2').'</label> '.
- __(' ] proportionally to ','pe2').
- '<input type="text" name="pe2_single_video_size_dimension" class="pe2_single_video_size" style="width:60px;" id="pe2_single_video_size_dimension" value="'.$mode[2].'" />'.
- __(' pixels.','pe2').
- '<label> <input type="checkbox" name="pe2_single_video_size_crop" class="pe2_single_video_size" value="-c" '.checked($crop, true, false).' /> '.__(' Crop image into a square.','pe2').'</label> '
- ,
- sprintf(__('Value \'%s\' will be used to set single video thumbnail size'),"<span id=\"pe2_single_video_size_message_option\">$option</span>"),
- '',
- 'id="pe2_single_video_size_message" style="display:'.(($option) ? 'block' : 'none').';"'
- );
- ?>
- <script type="text/javascript">
- // if mode changes, update image size
- jQuery('input[name=pe2_single_video_size_mode]').change(function(){ if (jQuery(this).attr('checked')) pe2_compute_image_size('mode',jQuery(this).val(), 'single_video'); });
- // if size changes, update image size
- jQuery('input[name=pe2_single_video_size_dimension]').change(function(){
- pe2_compute_image_size('size',jQuery('input[name=pe2_single_video_size_dimension]').val(), 'single_video');
- });
- // if crop changes, update image size
- jQuery('input[name=pe2_single_video_size_crop]').change(function(){
- pe2_determine_crop('single_video', this);
- });
- </script>
- <?
-
- $option = $this->options['pe2_caption'];
- $this->make_settings_row(
- __('Display caption', 'pe2'),
- '<label><input type="checkbox" name="pe2_caption" value="1" '.checked($option,'1',false).' /> '.__('Show the caption under thumbnail image', 'pe2').'</label> '
- );
-
- $option = $this->options['pe2_title'];
- $this->make_settings_row(
- __('Add caption as title', 'pe2'),
- '<label><input type="checkbox" name="pe2_title" value="1" '.checked($option,'1',false).' /> '.__('Show the caption by mouse hover tip', 'pe2').'</label> '
- );
-
- $opts = array (
- 'none' => __('No link', 'pe2'),
- 'direct' => __('Direct link', 'pe2'),
- 'picasa' => __('Link to Picasa Web Album', 'pe2'),
- 'lightbox' => __('Lightbox', 'pe2'),
- 'thickbox' => __('Thickbox (External)', 'pe2'),
- 'thickbox_integrated' => __('Thickbox (Integrated Wordpress version)', 'pe2'),
- 'thickbox_custom' => __('Thickbox (Custom from this plugin)', 'pe2'),
- 'highslide'=> __('Highslide', 'pe2'),
- );
- $is_gallery = array (
- 'none' => 'false',
- 'direct' => 'false',
- 'picasa' => 'false',
- 'lightbox' => 'true',
- 'thickbox' => 'true',
- 'thickbox_integrated' => 'true',
- 'thickbox_custom' => 'true',
- 'highslide'=> 'true',
- );
- $is_gallery_js = 'var is_gallery = { ';
- foreach ($is_gallery as $key=>$val) {
- $is_gallery_js .= "$key:$val,";
- }
- $is_gallery_js = trim($is_gallery_js, ',').' };';
- ?>
- <script type="text/javascript">
- function handle_gallery_properties(t) {
- <?php echo $is_gallery_js; ?>
-
- if (is_gallery[t]) {
- jQuery('#gallery_properties').show();
- jQuery('#gallery-message').show();
- jQuery('#nogallery_properties').hide();
- } else {
- jQuery('#gallery_properties').hide();
- jQuery('#gallery-message').hide();
- jQuery('#nogallery_properties').show();
- }
- }
- </script>
- <?php
-
- $out = '<select name="pe2_link" onchange="handle_gallery_properties(this.value);">';
- $option = $this->options['pe2_link'];
- foreach ($opts as $key => $val ) {
- $out .= "<option value=\"$key\" ".selected($option, $key, false ).">$val</option>";
- }
- $out .= '</select>';
- $this->make_settings_row(
- __('Link to larger image', 'pe2'),
- $out,
- __('To use external libraries like Thickbox, Lightbox or Highslide you need to install and integrate the library independently','pe2'),
- '',
- 'id="gallery-message" style="display:'.(($is_gallery[$option]=='true') ? 'block' : 'none').';"'
- );
-
- $option = $this->options['pe2_relate_images'];
- $this->make_settings_row(
- __('Relate all of a post\'s images', 'pe2'),
- '<label><input type="checkbox" name="pe2_relate_images" value="1" '.checked($option,'1',false).' /> '.__('If using Thickbox, Lightbox or Highslide, relate all images in the page/post together for fluid next/prev navigation', 'pe2').'</label> '
- );
-
- $opts = array (
- 'none' => __('None'),
- 'left' => __('Left'),
- 'center' => __('Center'),
- 'right' => __('Right'),
- );
- $option = $this->options['pe2_img_align'];
- $out = '';
- foreach ($opts as $key => $val ) {
- $out .= "<input type=\"radio\" name=\"pe2_img_align\" id=\"img-align$key\" value=\"$key\" ".checked($option, $key, false)." /> ";
- $out .= "<label for=\"img-align$key\" style=\"padding-left:22px;margin-right:13px;\" class=\"image-align-$key-label\">$val</label>";
- }
- $this->make_settings_row(
- __('Image alignment', 'pe2'),
- $out
- );
-
- $option = $this->options['pe2_auto_clear'];
- $this->make_settings_row(
- __('Auto clear: both', 'pe2'),
- '<label><input type="checkbox" name="pe2_auto_clear" value="1" '.checked($option,'1',false).' /> '.__('Automatically add <p class="clear"></p> after groups of images inserted together', 'pe2').'</label> '
- );
-
- $this->make_settings_row(
- __('CSS Class', 'pe2'),
- '<input type="text" name="pe2_img_css" class="regular-text" value="'.esc_attr($this->options['pe2_img_css']).'"/>',
- __("You can define default class for images from theme's style.css", 'pe2')
- );
- $this->make_settings_row(
- __('Style', 'pe2'),
- '<input type="text" name="pe2_img_style" class="regular-text" value="'.esc_attr($this->options['pe2_img_style']).'"/>',
- __('You can hardcode some css attributes', 'pe2')
- );
-
- $this->make_settings_row(
- __('Album thumbnail size'),
- '<label for="thumbnail_size_w">'.__('Width').'</label> '.
- '<input name="thumb_w" type="text" id="thumbnail_size_w" value="'.esc_attr( get_option('thumbnail_size_w')).'" class="small-text" /> '.
- '<label for="thumbnail_size_h">'.__('Height').'</label> '.
- '<input name="thumb_h" type="text" id="thumbnail_size_h" value="'.esc_attr( get_option('thumbnail_size_h')).'" class="small-text" /><br />'.
- '<input name="thumb_crop" type="checkbox" id="thumbnail_crop" value="1" '.checked('1', get_option('thumbnail_crop'),false).'/> '.
- '<label for="thumbnail_crop">'.__('Crop thumbnail to exact dimensions (normally thumbnails are proportional)').'</label>'
- );
- ?>
- </table>
-
- <h3><?php _e('Gallery properties', 'pe2') ?></h3>
-
- <div id="nogallery_properties" style="<?php echo ($is_gallery[$this->options['pe2_link']]=='true') ? 'display:none;' : 'display:block;'?>">
- <p><?php _e('To view and change properties you have to select Thickbox, Lightbox or Highslide support for the images above', 'pe2') ?></p>
- </div>
- <div id="gallery_properties" style="<?php echo ($is_gallery[$this->options['pe2_link']]=='false') ? 'display:none;' : 'display:block;'?>">
-
- <table class="form-table">
- <?php
- // display tag options
- $this->make_settings_row(
- __('Photo tag options', 'pe2'),
- '<input name="pe2_featured_tag" type="checkbox" id="pe2_featured_tag" value="1" '.checked('1', get_option('pe2_featured_tag'),false).'/> '.
- '<label for="pe2_featured_tag">'.__('Include photos from this album only if they contain the "Featured" tag').'</label><br />'.
- '<label for="pe2_additional_tags" style="vertical-align: top;">'.__('Additional tag(s) required').'</label> '.
- '<div style="display: inline-block;"><input type="text" name="pe2_additional_tags" id="pe2_additional_tags" class="regular-text" style="width: 240px;" value="'.esc_attr($this->options['pe2_additional_tags']).'"/><br/><span style="font-size: 9px;">('.__('Separate multiple tags by commas. NOTE: currently Google requires private album access for tags to work').')</span></div>'
- );
-
- $option = $this->options['pe2_gal_align'];
- $out = '';
- foreach ($opts as $key => $val ) {
- $out .= "<input type=\"radio\" name=\"pe2_gal_align\" id=\"gal-align$key\" value=\"$key\" ".checked($option, $key, false)." /> ";
- $out .= "<label for=\"gal-align$key\" style=\"padding-left:22px;margin-right:13px;\" class=\"image-align-$key-label\">$val</label>";
- }
- $this->make_settings_row(
- __('Gallery alignment', 'pe2'),
- $out
- );
-
- $this->make_settings_row(
- __('CSS Class', 'pe2'),
- '<input type="text" name="pe2_gal_css" class="regular-text" value="'.esc_attr($this->options['pe2_gal_css']).'"/>',
- __("You can define default class for images from theme's style.css", 'pe2')
- );
- $this->make_settings_row(
- __('Style', 'pe2'),
- '<input type="text" name="pe2_gal_style" class="regular-text" value="'.esc_attr($this->options['pe2_gal_style']).'"/>',
- __('You can hardcode some css attributes', 'pe2')
- );
- ?>
-
- </table>
- </div>
-
- </div>
- <div id="pe2-main">
- </div>
- <?php
- }
-
- /**
- * Request server with token if defined
- *
- * @param string $url URL for request data
- * @param boolean $token use token from settings
- * @return string received data
- */
- function get_feed($url,$token=false) {
- global $wp_version;
- // add Auth later
- $options = array(
- 'timeout' => 30 ,
- 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
- 'sslverify' => false // prevent some problems with Google in token request
- );
-
- if (!$token) {
- if ($this->options['pe2_level'] == 'user') {
- global $current_user;
- $token = get_user_meta($current_user->data->ID,'pe2_token',true);
- } else {
- $token = $this->options['pe2_token'];
- }
- }
- if ($token) $options['headers'] = array ( 'Authorization' =>"AuthSub token=\"$token\"" );
-
- $response = wp_remote_get($url, $options);
-
- if ( is_wp_error( $response ) )
- return $response;
-
- if ( 200 != $response['response']['code'] )
- return new WP_Error('http_request_failed', __('Response code is ').$response['response']['code']);
-
- // preg sensitive for \n\n, but we not need any formating inside
- return (str_replace("\n",'',trim( $response['body'] )));
- }
-
- /**
- * Find tag in content by attribute
- *
- * @param string $content
- * @param string $tag
- * @param string $attr
- * @return string attribute value or all parameters if not found. false if no tag found
- */
- function get_item_attr($content,$tag,$attr) {
- if (!preg_match("|<$tag\s+([^>]+)/?>|u",$content,$m))
- return false;
- $a = preg_split("/[\s=]/",$m[1]);
- for ($i=0; $i<count($a); $i+=2) {
- if ($a[$i]==$attr) return trim($a[$i+1],"'\" ");
- }
- return join(',',$a);
- }
- /**
- * Find tag in content
- *
- * @param string $content
- * @param string $tag
- * @param boolean $first Search only first. False by default
- * @return bool|string|array content of the found node. false if not found
- */
- function get_item($content,$tag,$first=false) {
- if (!preg_match_all("|<$tag(?:\s[^>]+)?>(.+?)</$tag>|u",$content,$m,PREG_PATTERN_ORDER))
- return false;
- // echo "$tag: ".count($m[1])."<br/>";
- if (count($m[1])>1 && !$first) return ($m[1]);
- else return ($m[1][0]);
- }
-
- /**
- * wp_ajax_pe2_get_gallery
- * print html for gallery
- *
- */
- function get_gallery() {
-
- if (!current_user_can('picasa_dialog')) {
- echo json_encode((object) array('error'=>__('Insufficient privelegies','pe2')));
- die();
- }
-
- $out = (object)array();
-
- if (isset($_POST['user'])) {
- $user = $_POST['user'];
- } else die();
-
- $rss = $this->get_feed("http://picasaweb.google.com/data/feed/base/user/$user?alt=rss&kind=album&hl=en_US");
- if (is_wp_error($rss)) {
- $out->error = $rss->get_error_message();
- } else if (!$this->get_item($rss,'atom:id')) {
- $out->error = __('Invalid picasa username: ', 'pe2').$user;
- } else {
- $items = $this->get_item($rss,'item');
- $output = '';
- if ($items) {
- if (!is_array($items)) $items = array($items);
- $output .= "\n<table><tr>\n";
- $i = 0;
- $max_albums = get_option('pe2_max_albums_displayed');
- foreach($items as $item) {
- // http://picasaweb.google.com/data/entry/base/user/wotttt/albumid/5408701349107410241?alt=rss&hl=en_US
- $guid = str_replace("entry","feed",$this->get_item($item,'guid'))."&kind=photo";
- $title = $this->escape($this->get_item($item,'title'));
- $desc = $this->escape($this->get_item($item,'media:description'));
- $url = $this->get_item_attr($item,'media:thumbnail','url');
- $item_type = (strpos($item, 'medium=\'video\'') !== false ? 'video' : 'image');
-
- // resize the thumbnail URL so that it fits properly in the media
- // window
- $url = str_replace('s160-c', 's140-c', $url);
-
- // generate the output
- $output .= "<td><a href='#$guid'><img src='$url' alt='$desc' type='$item_type'/><span>$title</span></a></td>\n";
-
- // increment the shared image counter for the following
- // two checks
- $i++;
-
- // determine if we need to stop outputting albums
- if(($max_albums > 0) && ($i >= $max_albums)){
- // we've reached our max, break out of the loop
- break;
- }
-
- // determine if we need to break this row and start a new
- // one
- if ($i % 4 == 0) $output .= "</tr><tr>\n";
- }// end foreach album item to output
- $output .= "</tr></table>\n";
- }// end if we have items to output
-
- $out->items = $this->get_item($rss,'openSearch:totalResults');
- $out->title = $this->get_item($rss,'title',true);
- $out->data = $output;
- $out->cache = $_POST['cache'];
- }// end else for if there were any errors
-
- echo json_encode($out);
- die();
- }
-
- /**
- * wp_ajax_pe2_get_images
- * print html for images
- *
- */
- function get_images() {
-
- if (!current_user_can('picasa_dialog')) {
- echo json_encode((object) array('error'=>__('Insufficient privelegies','pe2')));
- die();
- }
-
- $out = (object)array();
-
- if (isset($_POST['guid'])) {
- // determine if this guid is base64 encoded or a straight album URL,
- // decoding if necessary
- if(strpos($_POST['guid'], 'http') !== 0){
- // decode it
- $album = base64_decode($_POST['guid']);
- }else{
- // simply store it after decoding any entities that may have been
- // created by the editor or elsewhere
- $album = html_entity_decode($_POST['guid']);
- }
- } else die();
-
- $rss = $this->get_feed($album);
- if (is_wp_error($rss)) {
- $out->error = $rss->get_error_message();
- } else if (!$this->get_item($rss,'atom:id')) {
- $out->error = __('Invalid album ', 'pe2');
- } else {
- $items = $this->get_item($rss,'item');
- $output = '';
- $key = 1; $images = array();
- $sort = $this->options['pe2_img_sort'];
- $dialog_crop = ($this->options['pe2_dialog_crop'] == 1 ? '-c' : '');
- if ($items) {
- if (!is_array($items)) $items = array($items);
- foreach($items as $item) {
- switch ($sort) {
- case 0: $key++; break;
- case 1: $key = strtotime($this->get_item($item,'pubDate',true)); break;
- case 2: $key = $this->get_item($item,'title',true); break;
- case 3: $key = $this->get_item($item,'media:title',true); break;
- }
- $images[$key] = array (
- 'album' => $this->get_item($item,'link'), // picasa album image
- 'title' => $this->escape($this->get_item($item,'title')),
- 'file' => $this->escape($this->get_item($item,'media:title')),
- 'desc' => $this->escape($this->get_item($item,'media:description')),
- 'item_type' => (strpos($item, 'medium=\'video\'') !== false ? 'video' : 'image'),
- 'url' => str_replace('s72','s144'.$dialog_crop,$this->get_item_attr($item,'media:thumbnail','url')),
- );
- }
- if ($this->options['pe2_img_asc']) ksort($images);
- else krsort($images);
- $output .= "\n<table><tr>\n";
- $i = 0;
- foreach($images as $item) {
- $output .= "<td><a href='{$item['album']}'><img src='{$item['url']}' alt='{$item['file']}' type='{$item['item_type']}' title='{$item['desc']}' /><span>{$item['title']}</span></a></td>\n";
- if ($i++%4==3) $output .= "</tr><tr>\n";
- }
- $output .= "</tr></table>\n";
- }
-
- // do our action for dialog footer
- $output = apply_filters('pe2_get_images_footer', $output);
-
- // add our successful results to the output to return
- $out->items = $this->get_item($rss,'openSearch:totalResults');
- $out->title = $this->get_item($rss,'title',true);
- $out->data = $output;
- $out->cache = $_POST['cache'];
- }// end else for if we had an error getting the images
-
- // output the result and exit
- echo json_encode($out);
- die();
-
- }
-
- /**
- * Escape quotes to html entinty
- *
- * @param <type> $str
- * @return <type>
- */
- function escape($str) {
- $str = preg_replace('/"/', '"', $str);
- $str = preg_replace("/'/", ''', $str);
- return $str;
- }
-
- /**
- * wp_ajax_pe2_save_state
- * save state of dialog
- */
- function save_state() {
- if (!current_user_can('picasa_dialog')) {
- echo json_encode((object) array('error'=>__('Insufficient privelegies','pe2')));
- die();
- }
-
- if (!isset($_POST['state'])) die();
- global $current_user;
-
- switch ( $saved_state = sanitize_text_field($_POST['state']) ) {
- case 'nouser' :
- case 'albums' :
- if ($this->options['pe2_level'] == 'user')
- update_user_meta($current_user->data->ID, 'pe2_saved_user_name', sanitize_text_field($_POST['last_request']) );
- else
- update_option( 'pe2_saved_user_name', sanitize_text_field($_POST['last_request']) );
- break;
- case 'images' :
- if ($this->options['pe2_level'] == 'user')
- update_user_meta($current_user->data->ID, 'pe2_last_album', sanitize_text_field($_POST['last_request']) );
- else
- update_option( 'pe2_last_album', sanitize_text_field($_POST['last_request']) );
- break;
- default:
- die();
- }
- if ($this->options['pe2_level'] == 'user')
- update_user_meta($current_user->data->ID, 'pe2_saved_state', $saved_state );
- else
- update_option( 'pe2_saved_state', $saved_state );
- die();
- }
-
- /**
- * Envelope content with tag
- * used by shortcode 'pe2_gallery'
- *
- * @param array $atts tag, class and style defined. album also
- * @param string $content
- * @return string
- */
- function gallery_shortcode($atts, $content) {
- extract(shortcode_atts(array(
- 'class' => $this->options['pe2_gal_css'],
- 'style' => $this->options['pe2_gal_style'],
- 'align' => $this->options['pe2_gal_align'],
-
- 'tag' => 'div',
- 'album' => '',
-
- 'thumb_w' => get_option('thumbnail_size_w'),
- 'thumb_h' => get_option('thumbnail_size_h'),
- 'thumb_crop' => get_option('thumbnail_crop'),
-
- 'img_align' => $this->options['pe2_img_align'],
- 'img_class' => $this->options['pe2_img_css'],
- 'img_style' => $this->options['pe2_img_style'],
- 'img_sort' => $this->options['pe2_img_sort'],
- 'img_asc' => $this->options['pe2_img_asc'],
-
- 'caption' => $this->options['pe2_caption'],
- 'pe2_title' => $this->options['pe2_title'],
-
- 'link' => $this->options['pe2_link'],
- 'relate_images' => $this->options['pe2_relate_images'],
- 'large_size' => $this->options['pe2_large_limit'],
-
- 'limit' => '',
- 'hide_rest' => ''
- ), $atts ));
-
- if ($album) {
- // request images for album - generate the request URL
- if(strpos($album, 'http') !== 0){
- // for backwards compatibility, decode the base64 encoded album data
- // stored in the tag
- $feed_url = base64_decode($album);
- }else{
- // simply store the album url after decoding any entities created by
- // the visual/HTML editor
- $feed_url = html_entity_decode($album);
- }
-
- // determine if we have any tags to send with the query
- if(isset($atts['tags'])){
- // we also have tags to query, append them
- $feed_url .= '&tag='.urlencode($atts['tags']).'&orderby=date';
- }
-
- // grab the data and process it
- $rss = $this->get_feed($feed_url);
- if (is_wp_error($rss)) {
- $content = $rss->get_error_message();
- } else if ($this->get_item($rss,'atom:id')) {
- $items = $this->get_item($rss,'item');
- $output = '';
-
- // determine if we're relating all images, or just those
- // in this gallery
- if($relate_images){
- // use the per-post unique ID so all images in the post
- // are related
- $uniqid = 'post-'.get_the_ID();
- }else{
- // generate a unique id for this gallery
- $uniqid = uniqid('');
- }
-
- // prepare common image attributes
- $iclass = explode(' ',$img_class);
- $istyle = array($img_style);
-
- // create align vars
- // for caption - align="alignclass" including alignnone also
- $calign = '';
- if ($caption) {
- $calign = 'align="align'.$img_align.'" ';
- }
-
- // new size for thumbnail
- $new_thumb_size = '';
- if ($thumb_w && $thumb_h) {
- // both sizes and crop
- if ($thumb_w == $thumb_h) {
- if ($thumb_crop) $new_thumb_size = '/s'.$thumb_w.'-c';
- else $new_thumb_size = '/s'.$thumb_w;
- }
- else if ($thumb_w > $thumb_h) $new_thumb_size = '/w'.$thumb_w;
- else $new_thumb_size = '/h'.$thumb_h;
- }
- else if ($thumb_w) $new_thumb_size = '/w'.$thumb_w;
- else if ($thumb_h) $new_thumb_size = '/h'.$thumb_h;
-
- // new size for large image
- $new_large_size='/s0';
- if ($large_size) $new_large_size = '/'.$large_size;
-
- $cdim = ($thumb_w)?('width="'.$thumb_w.'" '):'';
-
- // link and gallery additions
- $amore='';
- switch ($link) {
- case 'thickbox':
- case 'thickbox_integrated':
- case 'thickbox_custom':
- $amore = 'class="thickbox" ';
- if (true) $amore .= 'rel="'.$uniqid.'" ';
- break;
- case 'lightbox':
- $amore = (true)?('rel="lightbox-'.$uniqid.'" '):'rel="lightbox" ';
- break;
- case 'highslide':
- $amore = (true)?('class="highslide" onclick="return hs.expand(this,{ slideshowGroup: \''.$uniqid.'\' })"'):
- 'class="highslide" onclick="return hs.expand(this)"';
- break;
- }
-
- $iclass = implode(' ',array_diff($iclass,array(''))); $iclass = ($iclass)?('class="'.$iclass.'" '):'';
- $istyle = implode(' ',array_diff($istyle,array(''))); $istyle = ($istyle)?('style="'.$istyle.'" '):'';
-
- $key = 1; $images = array();
-
- if ($items) {
- if (!is_array($items)) $items = array($items);
-
- // if we're searching by tags, the RSS feed returned the results
- // in the order of most-recent first, which doesn't make very
- // much sense when considering how this works. reverse teh
- // array order
- if(isset($atts['tags'])){
- // we searched for tags and messed up the order, reverse it
- $items = array_reverse($items);
- }
-
- // loop through each and build the HTML
- foreach($items as $item) {
- switch ((string)$img_sort) {
- case 'None':
- case 'none':
- case '0': $key++; break;
- case 'date':
- case '1': $key = strtotime($this->get_item($item,'pubDate',true)); break;
- case 'Title':
- case 'title':
- case '2': $key = $this->get_item($item,'title',true); break;
- case 'File name':
- case 'File':
- case 'file':
- case '3': $key = $this->get_item($item,'media:title',true); break;
- case 'Random':
- case 'random':
- case '4': $key = rand(); break;
- default: $key++; break;
- }
- $url = $this->get_item_attr($item,'media:thumbnail','url');
- $title = $this->escape($this->get_item($item,'title'));
- $picasa_link = $this->get_item($item, 'link');
- $images[$key] = array (
- 'ialbum' => $this->get_item($item,'link'), // picasa album image
- 'icaption' => $title,
- 'ialt' => $this->escape($this->get_item($item,'media:title')),
- 'isrc' => str_replace('/s72',$new_thumb_size,$url),
- 'iorig' => str_replace('/s72',$new_large_size,$url),
- 'ititle' => ($pe2_title)?'title="'.$title.'" ':'',
- 'ilink' => $picasa_link,
- //FIXME - CSS needs to be corrected
- //'itype' => (strpos($item, 'medium=\'video\'') !== false ? 'video' : 'image')
- 'itype' => ''
- );
- if ($limit && !$hide_rest) {
- if (++$count>=$limit) break;
- }
- }// end foreach items to process
- if ($img_asc) ksort($images);
- else krsort($images);
-
- if ($limit && $hide_rest && $limit==absint($limit)) $count=0;
- else $limit=false;
-
- foreach($images as $item) {
- $img = "<img src=\"{$item['isrc']}\" alt=\"{$item['ialt']}\" type=\"{$item['itype']}\" {$item['ititle']}{$iclass}{$istyle} />";
-
- if ($link != 'none') {
- if ($link == 'picasa') $item['iorig'] = $item['ialbum'];
-
- // determine if this particular link has been displayed
- // already or not (to prevent multiple copies related
- // to each other from busting the navigation)
- if(in_array($item['iorig'], $this->photos_displayed)){
- // this photo has already been displayed, skip relating
- // it to the rest and instead make up a new relationship
- // for it so that we don't break the navigation
- $amore_this = str_replace($uniqid, uniqid(), $amore);
- }else{
- // this photo hasn't been displayed yet, it can be related
- // without issue
- $amore_this = $amore;
- }
-
- // store this photo in our list of displayed photos
- $this->photos_displayed[] = $item['iorig'];
-
- // create the image link
- $img = "<a href=\"{$item['iorig']}\" link=\"{$item['ilink']}\" {$item['ititle']}{$amore_this}>$img</a>";
- }
- if ($caption) {
- // add caption
- $img = "[caption id=\"\" {$calign}{$cdim}caption=\"{$item['icaption']}\"]{$img}[/caption] ";
- }
-
- $output .= $img;
-
- if ($limit) {
- if (++$count>=$limit) {
- $istyle=$hstyle;
- $amore .= ' style="display:none;"';
- $caption=false;
- }
- }
- }
-
- $class = array_merge( array(($align!='none')?'align'.$align:''), explode(' ',$class) );
- $class = array_diff($class, array('') );
- $class = implode(' ', $class );
-
- }
- }
- $content .= $output;
- }
-
- $code = "<$tag class=\"pe2-album $pe2_gal_class\" style=\"$pe2_gal_style\">".do_shortcode($content)."</$tag><div class='clear'></div>";
-
- return $code;
- }
-
- /**
- * Envelope content with tag
- * used by shortcode 'pe2_image'
- *
- * @param array $atts tag, class and style defined.
- * @param string $content
- * @return string
- */
- function image_shortcode($atts, $content) {
- // extract all of the variables from defaults/options with
- // any tag attribute overrides
- extract(shortcode_atts(array_merge(array(
- 'src' => '',
- 'href' => '',
- 'caption' => '',
- 'type' => '',
- 'alt' => '',
- 'limit' => '',
- 'hide_rest' => ''
- ), $this->options
- ), $atts )
- );
-
- // create…
Large files files are truncated, but you can click here to view the full file