Photo Gallery



\n”; } // Show only on single posts and pages if ( (!is_admin() && is_single()) || (!is_admin() && is_page()) && ( !is_page_template(‘page-blog.php’) ) ) { echo “\n\n”; } } function photo_galleria_css_head() { $photo_galleria = get_option( ‘photo_galleria’ ); $color = $photo_galleria[‘color’] ; if ($color != ”) echo ‘ ‘; } add_action(‘wp_footer’,’photo_galleria_scripts_head’); add_action(‘wp_head’,’photo_galleria_css_head’); /** * Lets make new gallery shortcode */ function photo_galleria_shortcode($attr) { global $post; $pid = $post->ID; $photo_galleria = get_option( ‘photo_galleria’ ); $image_size = $photo_galleria[‘image’]; // We’re trusting author input, so let’s at least make sure it looks like a valid orderby statement if ( isset( $attr[‘orderby’] ) ) { $attr[‘orderby’] = sanitize_sql_orderby( $attr[‘orderby’] ); if ( !$attr[‘orderby’] ) unset( $attr[‘orderby’] ); } extract(shortcode_atts(array( ‘orderby’ => ‘menu_order ASC, ID ASC’, ‘id’ => $post->ID, ‘size’ => $image_size, ), $attr)); $id = intval($id); $attachments = get_children(“post_parent=$id&post_type=attachment&post_mime_type=image&orderby={$orderby}”); if ( empty($attachments) ) return ”; if ( is_feed() ) { $output = “\n”; foreach ( $attachments as $id => $attachment ) $output .= wp_get_attachment_link($id, $size, true) . “\n”; return $output; } // Build galleria markup $output = apply_filters(‘gallery_style’, ‘

‘); // Loop through each image foreach ( $attachments as $id => $attachment ) { // Attachment page ID $att_page = get_attachment_link($id); // Returns array $img = wp_get_attachment_image_src($id, $image_size); $img = $img[0]; $thumb = wp_get_attachment_image_src($id, ‘thumbnail’); $thumb = $thumb[0]; // Set the image titles $title = $attachment->post_title; // Get the Permalink $permalink = get_permalink(); // Set the image captions $description = htmlspecialchars($attachment->post_content, ENT_QUOTES); if($description == ”) $description = htmlspecialchars($attachment->post_excerpt, ENT_QUOTES); // Build html for each image $output .= “\n\t\t
“; $output .= “\n\t\t\t“; $output .= “\n\t\t\t\t".$description."“; $output .= “\n\t\t“; $output .= “\n\t\t“.$title.”“; $output .= “\n\t\t“.$description.”“; $output .= “\n\t\t
“; // End foreach } // Close galleria markup $output .= “\n\t
“; return $output; } add_action(‘wp_head’,’add_gppphotogalleria_gallery’); function add_gppphotogalleria_gallery() { if( ( is_single() || is_page() ) && ( !is_page_template(‘page-blog.php’) ) ){ remove_shortcode(‘gallery’); add_shortcode(‘gallery’, ‘photo_galleria_shortcode’); } } // Copy Photo Galleria Themes function photo_galleria_copy_themes($source, $dest) { // Check for symlinks if (is_link($source)) { return symlink(readlink($source), $dest); } // Simple copy for a file if (is_file($source)) { return copy($source, $dest); } // Make destination directory if (!is_dir($dest)) { mkdir($dest); } // Loop through the folder $dir = dir($source); while (false !== $entry = $dir->read()) { // Skip pointers if ($entry == ‘.’ || $entry == ‘..’) { continue; } // Deep copy directories photo_galleria_copy_themes(“$source/$entry”, “$dest/$entry”); } // Clean up $dir->close(); return true; } // Backup Themes function photo_galleria_backup_themes() { $to = dirname(__FILE__).”/../photo_galleria_themes_backup/”; $from = dirname(__FILE__).”/themes/”; photo_galleria_copy_themes($from, $to); } // Recover Themes function photo_galleria_recover_themes() { $from = dirname(__FILE__).”/../photo_galleria_themes_backup/”; $to = dirname(__FILE__).”/themes/”; photo_galleria_copy_themes($from, $to); if (is_dir($from)) { rmdir($from); } } //add_filter(‘upgrader_pre_install’, ‘photo_galleria_backup_themes’, 10, 2); //add_filter(‘upgrader_post_install’, ‘photo_galleria_recover_themes’, 10, 2); ?> // ]]>

Comments are closed.