/** * Determines the twitter card type for the current page */ private function determine_card_type() { $this->type = $this->options['twitter_card_type']; if (is_singular()) { // If the current post has a gallery, output a gallery card if (has_shortcode($GLOBALS['post']->post_content, 'gallery')) { $this->images = get_post_gallery_images(); if (count($this->images) > 3) { $this->type = 'gallery'; } } } /** * Filter: 'wpseo_twitter_card_type' - Allow changing the Twitter Card type as output in the Twitter card by WP SEO * * @api string $unsigned The type string */ $this->type = apply_filters('wpseo_twitter_card_type', $this->type); }
/** * Determines the twitter card type for the current page */ private function determine_card_type() { $this->type = $this->options['twitter_card_type']; if (is_singular() && has_shortcode($GLOBALS['post']->post_content, 'gallery')) { $this->images = get_post_gallery_images(); if (count($this->images) > 0) { $this->type = 'summary_large_image'; } } /** * Filter: 'wpseo_twitter_card_type' - Allow changing the Twitter Card type as output in the Twitter card by Yoast SEO * * @api string $unsigned The type string */ $this->type = apply_filters('wpseo_twitter_card_type', $this->type); }
/** * Outputs the HTML for this widget. * * @param array An array of standard parameters for widgets in this theme * @param array An array of settings for this widget instance * @return void Echoes it's output **/ function widget($args, $instance) { extract($args, EXTR_SKIP); $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); $fetch = empty($instance['fetch']) ? ' ' : apply_filters('widget_title', $instance['fetch']); echo $before_widget; echo $before_title; echo $title; // Can set this with a widget option, or omit altogether echo $after_title; // // Widget display logic goes here // /*oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo*/ /* Here We Go, BUild the Gate to prevent headache to find out which the Output*/ /*oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo*/ ?> <div class="row albwidget"> <?php global $wp_query; $args = array('post_type' => 'zl_album', 'post_status' => 'publish', 'orderby' => 'DATE', 'order' => 'DESC', 'posts_per_page' => $fetch, 'ignore_sticky_posts' => 1); $album = new WP_Query($args); ?> <?php if ($album->have_posts()) { while ($album->have_posts()) { $album->the_post(); //Let's Generate the Thumbnail. $thumb = get_post_thumbnail_id(); $img_url = wp_get_attachment_url($thumb, 'full'); $image = zl_theme_thumb($img_url, 100, 100, 'c', true); //Get Gallery Images $gallery = get_post_gallery_images(); //Count Images $items = count($gallery); //Get the First Item if featured image isn't set. $firstimg = reset($gallery); $firstimg = str_replace('-150x150', '', $firstimg); //Crop the first image. $firstimg = zl_theme_thumb($firstimg, 100, 100, 'c', true); ?> <!-- Album Loop --> <div class="small-4 column tooltip" title="<?php the_title(); ?> | <?php echo $items . zl_option('lang_photos', __(' Photos', 'zatolab')); ?> "> <div class="zl_alb_wid" title="<?php the_title(); ?> | <?php echo $items . zl_option('lang_photos', __(' Photos', 'zatolab')); ?> "> <div data-albumlink='<?php the_permalink(); ?> ' data-albumid="album-<?php the_ID(); ?> "> <a href="<?php the_permalink(); ?> " class="abs"> </a> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "> <?php if ($image) { echo '<img src="' . $image . '" alt="' . get_the_title() . '" />'; } else { echo '<img src="' . $firstimg . '" alt="' . get_the_title() . '" />'; } ?> </a> </div> </div> </div><!-- // .zl_album_parent large-3 Album Loop --> <?php } } ?> </div> <?php /*oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo*/ /* </END of: Here We Go, BUild the Gate to prevent headache to find out which the Output*> /*oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo*/ echo $after_widget; }
<?php if (have_posts()) { while (have_posts()) { the_post(); ?> <?php the_content(); ?> <div class="imagegal photos"> <ul> <?php $gallery = get_post_gallery_images($post->ID); foreach ($gallery as $image) { // Loop through each image in each gallery $image_list .= '<li><a rel="prettyPhoto[gal]" href=" ' . str_replace('-150x150', '', $image) . ' "><img src="' . str_replace('-150x150', '', $image) . '" /></li></a>'; } echo $image_list; ?> <div class="clear"></div> </ul> <div class="clear"></div> </div> <?php
/** * Outputs the first 4 images of a gallery as the posts gallery images */ private function gallery_images_output() { $images = get_post_gallery_images(); // If there are no images attached, use the standard single image output if (count($images) === 0) { $this->single_image_output(); return; } $image_counter = 0; foreach ($images as $image) { if ($image_counter > 3) { return; } $this->image_output($image, 'image' . $image_counter); $image_counter++; } }
mode: 'fade', speed: 1500, auto: true, pause: 3000, adaptiveHeight: true, nextText: '', prevText: '', nextSelector: '.slide-next', prevSelector: '.slide-prev', pager: false }); }); </script> <div class="gallery-post-format"> <?php $galleries = get_post_gallery_images($post); $output = '<ul class="gallery-images">'; foreach ($galleries as $gallery) { $output .= '<li>' . '<img src="' . $gallery . '">' . '</li>'; } $output .= '</ul>'; echo $output; ?> </div> <?php } if (has_post_format('video')) { ?> <?php $video_post_url = get_post_meta($post->ID, 'video_url', true); ?>
<div class="fes-product equal"> <?php if (has_post_thumbnail($product->ID)) { ?> <div class="fes-product-image"> <?php echo get_the_post_thumbnail($product->ID, 'portfolio-thumb'); ?> </div> <?php } else { if (has_shortcode($product->post_content, 'gallery')) { // Grab the first image from the gallery if we have one $gallery = get_post_gallery_images($product->ID); $image_list = '<div class="fes-product-image">'; // Grab only the first image from the gallery $i = 0; foreach ($gallery as $image) { if (++$i > 1) { break; } $image_list .= '<div><img src=" ' . $image . ' " /></div>'; } $image_list .= '</div>'; // Display gallery image echo $image_list; } } ?>
function hocwp_post_thumbnail_large_if_not_default($result, $post_id) { if (empty($result)) { $result = get_post_meta($post_id, 'large_thumbnail', true); $result = hocwp_sanitize_media_value($result); $result = $result['url']; if (empty($result)) { $gallery = get_post_gallery_images($post_id); if (hocwp_array_has_value($gallery)) { $result = array_shift($gallery); } } } return $result; }
function carousel_shortcode($atts) { extract(shortcode_atts(array('slug' => 'home-page-vendors', 'category' => 'carousel'), $atts)); $carouselBlock = '<div class="carousel-block"><div class="owl-carousel">'; $carouselModule = get_posts(array('post_type' => 'module', 'module_category' => $category, 'name' => $slug)); if (isset($carouselModule[0])) { $carouselGalleryImages = get_post_gallery_images($carouselModule[0]->ID); foreach ($carouselGalleryImages as $image) { $carouselBlock .= '<div><img src="' . $image . '" /></div>'; } } $carouselBlock .= '</div></div>'; return $carouselBlock; }
<li class="slide"> <a class=""> <!-- <a href="<?php the_permalink(); ?> " rel="bookmark"> --> <?php //if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { ?> <?php //the_post_thumbnail('post-thumb'); if (get_post_gallery()) { $gallery = get_post_gallery(get_the_ID(), false); $galleryImg = get_post_gallery_images(get_the_ID()); /* Loop through all the image and output them one by one */ foreach ($gallery['src'] as $g) { $full = str_replace('-150x150', '', $g); ?> <a class="fancybox" href="<?php echo $full; ?> " rel="<?php echo $post->ID; ?> "> <div class="slider_img_container"> <img src="<?php echo $g; ?>
/** * @param $atts * * @return string * @throws Exception */ function plp_shortcode($atts) { if (get_option('plp_css') == 'yes') { wp_register_style('productlistpages', plugins_url() . '/productlistpages/productlistpages.css'); wp_enqueue_style('productlistpages'); } $permalink = get_permalink(); $content = ''; if (trim(get_option('plp_customcss')) != '') { $content .= "<style>\n" . trim(get_option('plp_customcss')) . "\n</style>"; } $content .= '<div class="woocommerce">'; $fieldOrder = get_option('plp_fieldsorder'); if (!is_array($fieldOrder)) { $fieldOrder = array(); } if (!isset($fieldOrder['name'])) { $fieldOrder['name'] = '1'; } if (!isset($fieldOrder['image'])) { $fieldOrder['image'] = '2'; } if (!isset($fieldOrder['excerpt'])) { $fieldOrder['excerpt'] = '3'; } if (!isset($fieldOrder['content'])) { $fieldOrder['content'] = '4'; } if (!isset($fieldOrder['price'])) { $fieldOrder['price'] = '5'; } if (!isset($fieldOrder['stock'])) { $fieldOrder['stock'] = '6'; } if (!isset($fieldOrder['sku'])) { $fieldOrder['sku'] = '7'; } if (!isset($fieldOrder['variation'])) { $fieldOrder['variation'] = '8'; } asort($fieldOrder); if (isset($atts['posts_per_page'])) { wp_reset_query(); } $added = $no_qty = false; if (isset($_POST['productadd'])) { foreach ($_POST['productadd'] as $productId => $quantity) { $quantity = (int) $quantity; $productId = (int) $productId; if ($quantity > 0) { $added = true; } else { $no_qty = true; } } } if (!isset($atts['titles']) && get_option('plp_displaytitles') == 'yes') { $atts['titles'] = 'true'; } if (!isset($atts['imageintitle'])) { if (get_option('plp_imageintitle') == '1') { $atts['imageintitle'] = 'true'; } else { $atts['imageintitle'] = 'false'; } } if (!isset($atts['producttitle'])) { if (get_option('plp_displayname') == '1') { $atts['producttitle'] = 'true'; } else { $atts['producttitle'] = 'false'; } } if (!isset($atts['image'])) { if (get_option('plp_displayimage') == '1') { $atts['image'] = 'true'; } else { $atts['image'] = 'false'; } } if (!isset($atts['stock'])) { if (get_option('plp_displaystock') == '1') { $atts['stock'] = 'true'; } else { $atts['stock'] = 'false'; } } if (!isset($atts['excerpt'])) { if (get_option('plp_displayexcerpt') == '1') { $atts['excerpt'] = 'true'; } else { $atts['excerpt'] = 'false'; } } if (!isset($atts['content'])) { if (get_option('plp_displaycontent') == '1') { $atts['content'] = 'true'; } else { $atts['content'] = 'false'; } } if (!isset($atts['price'])) { if (get_option('plp_displayprice') == '1') { $atts['price'] = 'true'; } else { $atts['price'] = 'false'; } if (!isset($atts['sku'])) { if (get_option('plp_displaysku') == '1') { $atts['sku'] = 'true'; } else { $atts['sku'] = 'false'; } } if (!isset($atts['variation'])) { if (get_option('plp_display_variation') == '1') { $atts['variation'] = 'true'; } else { $atts['variation'] = 'false'; } } if (!isset($atts['addtocartbutton'])) { $atts['addtocartbutton'] = get_option('addtocartposition'); } $content .= '<div class="woocommerce">'; ob_start(); wc_print_notices(); $content .= ob_get_clean(); $content .= '</div>'; if ($atts['addtocartbutton'] != 'product') { $content .= '<form method="post" action="' . $permalink . '">'; } if ($atts['addtocartbutton'] == 'both' || $atts['addtocartbutton'] == 'top') { $content .= '<div align="center">' . '<p>' . '<input class="checkout-button button alt" type="submit" name="SUBMIT" value="' . __('Add to Cart', 'plp') . '" alt="' . __('Add to Cart', 'plp') . '"> </p><br></div>'; } $content .= '<table class="ProductListShortcode shop_table cart" border="0" width="100%" cellspacing="10" cellpadding="4">'; if (isset($atts['titles']) && $atts['titles'] == 'true') { $content .= '<thead>' . '<tr>'; foreach ($fieldOrder as $field => $order) { switch ($field) { case 'name': if ($atts['producttitle'] == 'true') { if (get_option('plp_namecaption') != '') { $content .= '<th>' . get_option('plp_namecaption') . "</th>\n"; } else { $content .= '<th>' . __('Title', 'plp') . '</th>'; } } break; case 'image': if ($atts['image'] == 'true' && $atts['imageintitle'] != 'true') { if (get_option('plp_imagecaption') != '') { $content .= '<th>' . get_option('plp_imagecaption') . "</th>\n"; } else { $content .= '<th>' . __('Image', 'plp') . '</th>'; } } break; case 'excerpt': if ($atts['excerpt'] == 'true') { if (get_option('plp_excerptcaption') != '') { $content .= '<th>' . get_option('plp_excerptcaption') . "</th>\n"; } else { $content .= '<th>' . __('Description', 'plp') . '</th>'; } } break; case 'content': if ($atts['content'] == 'true') { if (get_option('plp_contentcaption') != '') { $content .= '<th>' . get_option('plp_contentcaption') . "</th>\n"; } else { $content .= '<th>' . __('Content', 'plp') . '</th>'; } } break; case 'price': if ($atts['price'] == 'true') { if (get_option('plp_pricecaption') != '') { $content .= '<th>' . get_option('plp_pricecaption') . "</th>\n"; } else { $content .= '<th>' . __('Price', 'plp') . '</th>'; } } break; case 'stock': if ($atts['stock'] == 'true') { if (get_option('plp_stockcaption') != '') { $content .= '<th>' . get_option('plp_stockcaption') . "</th>\n"; } else { $content .= '<th>' . __('Stock', 'plp') . '</th>'; } } break; case 'sku': if ($atts['sku'] == 'true') { if (get_option('plp_skucaption') != '') { $content .= '<th>' . get_option('plp_skucaption') . "</th>\n"; } else { $content .= '<th>' . __('Sku', 'plp') . '</th>'; } } break; case 'variation': if ($atts['variation'] == 'true') { if (get_option('plp_variation_caption') != '') { $content .= '<th>' . get_option('plp_variation_caption') . "</th>\n"; } else { $content .= '<th>' . __('Variations', 'plp') . '</th>'; } } break; } } $content .= '</tr>' . '</thead>'; } $content . '<tbody>'; $query_args = array('post_status' => 'publish', 'post_type' => 'product'); if (isset($atts['id'])) { $ids = explode(',', $atts['id']); $query_args['post__in'] = $ids; } if (isset($atts['posts_per_page'])) { $paged = get_query_var('paged') ? get_query_var('paged') : 1; $query_args['posts_per_page'] = (int) $atts['posts_per_page']; $query_args['paged'] = $paged; } else { $query_args['posts_per_page'] = 99999; $query_args['nopaging'] = 1; } if (isset($atts['orderby'])) { $query_args['orderby'] = trim($atts['orderby']); } elseif (get_option('plp_orderby') != '') { $query_args['orderby'] = get_option('plp_orderby'); } if (isset($atts['order'])) { $query_args['order'] = trim(strtoupper($atts['order'])); } elseif (get_option('plp_order') != '') { $query_args['order'] = get_option('plp_order'); } if (isset($atts['cat'])) { $field = 'ID'; $catsatt = explode(',', $atts['cat']); foreach ($catsatt as $ca) { //If any category is not given by ID, switch to Slug if (!is_numeric($ca)) { $field = 'slug'; } } $query_args['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => $field, 'terms' => $catsatt, 'operator' => 'IN')); } wp_reset_query(); global $wp_query; $wp_query = new WP_Query(); $poj = new WC_Product_Factory(); $wp_query->query($query_args); if ($wp_query->have_posts()) { while ($wp_query->have_posts()) { $wp_query->the_post(); $product = $poj->get_product(get_the_ID()); //var_dump(get_option('plp_displayvariations') ); if ($product->is_purchasable()) { $hasVariatoon = false; if (get_option('plp_displayvariations') == 'yes') { $variationQuery = new WP_Query(); $attributes = $product->get_attributes(); $args = array('post_status' => 'publish', 'post_type' => 'product_variation', 'post_parent' => $product->ID); $variationQuery->query($args); if ($variationQuery->have_posts()) { $hasVariatoon = true; } } if ($hasVariatoon == true) { $originalTitle = get_the_title(); $varTitle = $originalTitle; $link = get_permalink(); /*$var_atts = array(); while ($variationQuery->have_posts()) : $variationQuery->the_post(); $product = WC_Product_Factory::get_product(get_the_ID()); $varTitle = $originalTitle; $var_atts[] = $product->get_variation_attributes(); if (is_array($var_atts)) { $comma = ' - '; foreach ($var_atts as $data) { $varTitle .= $comma . urldecode($data) . ' '; $comma = ', '; } } endwhile; print_r($var_atts); $var_dropdown = ''; if (is_array($var_atts)) { $var_dropdown .= '<select name="variation">'; foreach ($var_atts as $key => $data) { foreach($data as $varition => $val){ $var_dropdown .= '<option value="'.urldecode($val).'">'.urldecode($val).'</option>'; } $comma = ', '; } $var_dropdown .= '</select>'; } */ $var_dropdown = $cls = ''; $alt = 1; $var_dropdown .= '<table style="border:none;">'; $var_dropdown .= '<tr>'; foreach ($attributes as $attribute) { if (!($attribute['is_taxonomy'] && taxonomy_exists($attribute['name']))) { continue; } else { $has_row = true; } if (($alt = $alt * -1) == 1) { $cls = 'alt'; } $var_dropdown .= '<td class="' . $cls . '" style="border:none; width: 180px;">'; $var_dropdown .= wc_attribute_label($attribute['name']); //$content .= '<td id="variationtd">'; if ($attribute['is_taxonomy']) { $values = wc_get_product_terms($product->id, $attribute['name'], array('fields' => 'names')); $var_dropdown .= '<select name="' . $attribute['name'] . '-' . $product->id . '">'; foreach ($values as $val) { $var_dropdown .= '<option value="' . $val . '">' . $val . '</option>'; } $var_dropdown .= '</select>'; } else { // Convert pipes to commas and display values $values = array_map('trim', explode(WC_DELIMITER, $attribute['value'])); $var_dropdown .= '<select name="' . $attribute['name'] . '[' . $product->id . ']">'; foreach ($values as $val) { $var_dropdown .= '<option value="' . $val . '">' . $val . '</option>'; } $var_dropdown .= '</select>'; } $var_dropdown .= '</td>'; } $var_dropdown .= '</tr>'; $var_dropdown .= '</table>'; $content .= '<tr>'; foreach ($fieldOrder as $field => $order) { switch ($field) { case 'name': if ($atts['producttitle'] == 'true') { if (isset($atts['image']) && $atts['image'] == 'true' && $atts['imageintitle'] == 'true') { $gal_images = get_post_gallery_images(get_the_ID()); $content .= '<td>' . get_the_post_thumbnail(get_the_ID(), array(200, 200)); if ($atts['producttitle'] == 'true') { $content .= '<br />' . $varTitle; } $content .= '</td>'; } else { $content .= '<td>' . $varTitle . '</td>'; } } break; case 'image': if ($atts['image'] == 'true' && $atts['imageintitle'] != 'true') { $attachment_ids = $product->get_gallery_attachment_ids(); $image_links = []; $content .= '<td class="image">'; foreach ($attachment_ids as $attachment_id) { $image_links[] = wp_get_attachment_url($attachment_id); $content .= '<a href="' . wp_get_attachment_url($attachment_id) . '" data-lightbox="image-' . get_the_ID() . '" data-title="' . $product->get_title() . '"><img src="' . wp_get_attachment_url($attachment_id) . '"' . ' alt="picture" /></a>'; // $content .= ; } $content .= '</td>'; } break; case 'excerpt': if ($atts['excerpt'] == 'true') { $content .= '<td>' . pramnos_shortenText(get_the_excerpt(), get_option('plp_excerptlength')) . '</td>'; } break; case 'content': //customized content here - Brian3T if ($atts['content'] == 'true') { $content .= '<td class="content">'; $content .= "<div class='title'><b>{$varTitle}</b></div>"; $content .= "<span class='price'>" . woocommerce_price($product->get_price()) . "</span>"; if ($product->is_in_stock()) { $content .= '<div class="quantity buttons_added">' . '<input type="button" value="-" class="minus"><input class="input-text qty text" type="number" step="1" min="0" max="' . apply_filters('woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product) . '" name="productadd[' . get_the_ID() . ']" id="productadd_' . get_the_ID() . '" value="0" size="2" maxlength="3">' . '<input type="button" value="+" class="plus"></div>' . '<input class="checkout-button button alt enthusiast" type="button" name="add_to_cart" value="Add to Cart" alt="Add to Cart">'; } else { $content .= '<span class="sold">SOLD</span>'; } $content .= "<div class='content'>" . pramnos_shortenText(wpautop(get_the_content(), true), get_option('plp_contentlength')) . "</div>"; $content .= '</td>'; } ////customized content here - Brian3T break; case 'price': if ($atts['price'] == 'true') { $content .= '<td>' . woocommerce_price($product->get_price()) . '</td>'; } break; // case 'stock': // if ($atts['stock'] == 'true') { // $content .= '<td>' . $product->get_stock_quantity() . '</td>'; // } // break; // case 'sku': // if ($atts['sku'] == 'true') { // $content .= '<td>' . $product->get_sku() . '</td>'; // } // break; // case 'variation': // if (strpos($var_dropdown, '</option>') === false) { // $content .= '<td>None</td>'; // } else if ($atts['variation'] == 'true') { // $content .= '<td>' . $var_dropdown . '</td>'; // } // // break; } } if ($atts['addtocartbutton'] != 'product') { // $content .= '<td class="product-quantity">' . '<div class="quantity buttons_added">' . '<input type="button" value="-" class="minus"><input class="input-text qty text" type="number" step="1" min="0" max="' . apply_filters('woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product) . '" name="productadd[' . get_the_ID() . ']" id="productadd_' . get_the_ID() . '" value="0" size="2" maxlength="3">' . '<input type="button" value="+" class="plus"></div></td>'; } else { if ($product->is_purchasable() && $product->is_in_stock()) { $content .= '<td class="product-quantity" style="white-space:nowrap;">' . '<form action="' . esc_url($product->add_to_cart_url()) . '" class="cart" method="post" enctype=\'multipart/form-data\'>'; $attributes = $product->get_variation_attributes(); if (is_array($attributes)) { foreach ($attributes as $attribute => $value) { $content .= '<input type="hidden" name="' . $attribute . '" value="' . implode($value, ',') . '" />' . "\n"; } } $content .= '<input type="hidden" name="product_id" value="' . get_the_ID() . '" />' . "\n"; $content .= '<input type="hidden" name="variation_id" value="' . $product->variation_id . '" />' . "\n"; if (!$product->is_sold_individually() && apply_filters('woocommerce_quantity_input_min', 1, $product) != 1) { $content .= '<div class="quantity buttons_added">' . '<input type="button" value="-" class="minus"><input class="input-text qty text" type="number" step="1" min="' . apply_filters('woocommerce_quantity_input_min', 1, $product) . '" max="' . apply_filters('woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product) . '" name="quantity" id="quantity_' . get_the_ID() . '" value="' . apply_filters('woocommerce_quantity_input_min', 1, $product) . '" size="2" maxlength="3">' . '<input type="button" value="+" class="plus"></div>'; } else { $content .= '<input type="hidden" name="quantity" value="1" />'; } $content .= '<button type="submit" class="single_add_to_cart_button button alt">' . apply_filters('single_add_to_cart_text', __('Add to cart', 'woocommerce'), $product->product_type) . '</button>' . '</form>' . '</td>'; } } $content .= '</tr>'; //endwhile; } else { $content .= '<tr>'; foreach ($fieldOrder as $field => $order) { switch ($field) { case 'name': if ($atts['producttitle'] == 'true') { if (isset($atts['image']) && $atts['image'] == 'true' && $atts['imageintitle'] == 'true') { $content .= '<td>' . '">' . get_the_post_thumbnail(get_the_ID(), array(200, 200)); if ($atts['producttitle'] == 'true') { $content .= '<br />' . get_the_title(); } $content .= '</td>'; } else { $content .= '<td>' . get_the_title() . '</td>'; } } break; case 'image': if ($atts['image'] == 'true' && $atts['imageintitle'] != 'true') { $attachment_ids = $product->get_gallery_attachment_ids(); $image_links = []; $content .= '<td>'; foreach ($attachment_ids as $attachment_id) { $image_links[] = wp_get_attachment_url($attachment_id); $content .= '<img src="' . wp_get_attachment_url($attachment_id) . '"' . ' alt="picture" />'; } $content .= '</td>'; } break; case 'excerpt': if ($atts['excerpt'] == 'true') { $content .= '<td>' . pramnos_shortenText(get_the_excerpt(), get_option('plp_excerptlength')) . '</td>'; } break; case 'content': if ($atts['content'] == 'true') { $content .= '<td>' . pramnos_shortenText(get_the_content(), get_option('plp_contentlength')) . '</td>'; } break; case 'price': if ($atts['price'] == 'true') { $content .= '<td>' . woocommerce_price($product->get_price()) . '</td>'; } break; case 'stock': if ($atts['stock'] == 'true') { $content .= '<td>' . $product->get_stock_quantity() . '</td>'; } break; case 'sku': if ($atts['sku'] == 'true') { $content .= '<td>' . $product->get_sku() . '</td>'; } break; } } // if ($atts['addtocartbutton'] != 'product') { // $content .= '<td class="product-quantity">' . '<div class="quantity buttons_added">' . '<input type="button" value="-" class="minus"><input class="input-text qty text" type="number" step="1" min="0" max="' . apply_filters('woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product) . '" name="productadd[' . $product->id . ']" id="productadd_' . get_the_ID() . '" value="0" size="2" maxlength="3">' . '<input type="button" value="+" class="plus"></div></td>'; // } else { // //add to cart btn // $content .= '<td class="product-quantity" style="white-space:nowrap;">' . '<form action="' . esc_url($product->add_to_cart_url()) . '" class="cart" method="post" enctype=\'multipart/form-data\'>'; // if (! $product->is_sold_individually() && apply_filters('woocommerce_quantity_input_min', 1, $product) != 1) { // $content .= '<div class="quantity buttons_added">' . '<input type="button" value="-" class="minus"><input class="input-text qty text" type="number" step="1" min="' . apply_filters('woocommerce_quantity_input_min', 1, $product) . '" max="' . apply_filters('woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product) . '" name="quantity" id="quantity_' . get_the_ID() . '" value="' . apply_filters('woocommerce_quantity_input_min', 1, $product) . '" size="2" maxlength="3">' . '<input type="button" value="+" class="plus"></div>'; // } else { // $content .= '<input type="hidden" name="quantity" value="1" />'; // } // $content .= '<button type="submit" class="single_add_to_cart_button button alt">' . apply_filters('single_add_to_cart_text', __('Add to cart', 'woocommerce'), $product->product_type) . '</button>' . '</form>' . '</td>'; // } $content .= '</tr>'; } } } } $content .= '</tbody></table>'; if (isset($atts['posts_per_page'])) { $content .= '<div class="navigation clearboth" >' . '<div class="alignleft">' . get_previous_posts_link() . '</div>' . '<div class="alignright">' . get_next_posts_link() . '</div></div>'; } if ($atts['addtocartbutton'] == 'both' || $atts['addtocartbutton'] == 'bottom') { $content .= '<div class="clearboth" align="center">' . '<p>' . '<input class="checkout-button button alt" type="submit" name="SUBMIT" value="' . __('Add to Cart', 'plp') . '" alt="' . __('Add to Cart', 'plp') . '">' . '</p>' . '<br>' . '</div>'; } if ($atts['addtocartbutton'] != 'product') { $content .= '</form>'; } $content .= '</div>'; wp_reset_query(); return $content; } }
function tutannet_gallery_post() { global $post; // Only do this on singular items if (!is_singular()) { return false; } // Retrieve the first gallery in the post $gallery = get_post_gallery_images($post); $image_list = ' <div class="col-sx-12 col-sm-12 col-md-4 col-lg-4 post-desc-wrapper"> <div class="block-poston">' . tutannet_posted_on() . '</div> <h3 class="post-title"><a post-title="' . get_the_title() . '" rel="' . get_the_ID() . '" href="' . get_the_permalink() . '" >' . get_the_title() . '</a></h3> <div class="post-content">' . get_the_excerpt() . '</div> </div> <div class="col-xs-12 col-sm-12 col-md-8 col-lg-8 gallery_post_img_wrapper"> <div class="col-xs-6 col-sm-6 col-md-12 col-lg-12 gallery_post_img_left_wrapper"> <div class="col-sm-12 col-lg-6 gallery_post_img"> <img src="' . $gallery[0] . '"/> </div> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 gallery_post_img"> <img src="' . $gallery[1] . '"/> </div> </div> <div class="col-xs-6 col-sm-6 col-md-12 col-lg-12 gallery_post_img_right_wrapper"> <img src="' . $gallery[2] . '"/> </div> </div>'; $content .= $image_list; echo $content; }
<div id="zl_albums"> <?php $args = array('post_type' => 'zl_album', 'post_status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'DATE', 'order' => 'DESC', 'paged' => $pageds, 'ignore_sticky_posts' => 1); $album = new WP_Query($args); ?> <?php if ($album->have_posts()) { while ($album->have_posts()) { $album->the_post(); //Let's Generate the Thumbnail. $thumb = get_post_thumbnail_id(); $img_url = wp_get_attachment_url($thumb, 'full'); $image = zl_theme_thumb($img_url, 300, 300, 'c', true); //Define Gallery Images $gallery = get_post_gallery_images(); //Count Items $items = count($gallery); //Get First Item if featured image isn't set. $firstimg = reset($gallery); $firstimg = str_replace('-150x150', '', $firstimg); //Crop the first image. $firstimg = zl_theme_thumb($firstimg, 300, 300, 'c', true); ?> <!-- Album Loop --> <div class="zl_album_parent large-4 column"> <div class="zl_album" data-albumlink='<?php the_permalink(); ?> ' data-albumid="<?php the_ID();
/** * Post Format: Gallery * * Get specified number of Gallery images from the first Gallery in a post * Used primarily on index and archive pages */ function jkl_get_gallery_images($num = 3) { // Array to hold all the images we retrieve $images = get_post_gallery_images(); if (!empty($images)) { $size = count($images) > $num ? $num : count($images); if (has_post_thumbnail()) { $size--; } $images = array_slice($images, 0, $size); } return $images; }
/** * Function to display image slider in gallery post formats. */ function modality_gallery_post() { global $post; ?> <div class="flexslider"> <ul class="slides"> <?php //Pull gallery images from custom meta $gallery_image = get_post_gallery_images($post); if ($gallery_image != '') { foreach ($gallery_image as $arr) { echo '<li><img src="' . $arr . '" alt="' . $arr . '" /></li>'; } } ?> </ul> </div> <?php wp_enqueue_script('gallery-slides', get_template_directory_uri() . '/js/gallery-slides.js', array('jquery'), '', true); }
function pw_show_gallery_image_urls($content) { global $post; // Only do this on singular items if (!is_singular()) { return $content; } // Make sure the post has a gallery in it if (!has_shortcode($post->post_content, 'gallery')) { return $content; } // Retrieve the first gallery in the post $gallery = get_post_gallery_images($post); // Get post title $title = get_the_title($post); $image_list = '<div id="image-gallery">'; // Loop through each image in each gallery foreach ($gallery as $image_url) { $image_list .= '<a href="' . $image_url . '" style="background-image: url(' . $image_url . ');" class="gallery-image slide" data-lightbox="' . $title . '">' . '</a>'; } $image_list .= '</div>'; $nav_bar = '<div class="gallery-nav"><div class="gallery-prev"> <img src="' . get_template_directory_uri() . '/img/icons/arrow-prev.png"> </div> <div class="slider-thumbs">'; $smallthumb = ''; if (count($gallery) > 7) { $smallthumb = "smallthumb"; } // Loop through each image in each gallery foreach ($gallery as $thumbnail) { $nav_bar .= '<div class="thumb ' . $smallthumb . '"> <img src="' . $thumbnail . '" alt="" title="' . $title . '"/></div>'; } $nav_bar .= '</div> <div class="gallery-next"> <img src="' . get_template_directory_uri() . '/img/icons/arrow-next.png"> </div> </div>'; // Append our image list to the content of our post $content .= $image_list . $nav_bar; return $content; }
/** * @ticket 22960 */ function test_post_gallery_images() { $ids1 = array(); $ids1_srcs = array(); foreach ( range( 1, 3 ) as $i ) { $attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment' ) ); wp_update_attachment_metadata( $attachment_id, $this->img_dimensions ); $ids1[] = $attachment_id; $ids1_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg"; } $ids2 = array(); $ids2_srcs = array(); foreach ( range( 4, 6 ) as $i ) { $attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array( 'post_mime_type' => 'image/jpeg', 'post_type' => 'attachment' ) ); wp_update_attachment_metadata( $attachment_id, $this->img_dimensions ); $ids2[] = $attachment_id; $ids2_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg"; } $ids1_joined = join( ',', $ids1 ); $ids2_joined = join( ',', $ids2 ); $blob =<<<BLOB [gallery ids="$ids1_joined"] [gallery ids="$ids2_joined"] BLOB; $post_id = $this->factory->post->create( array( 'post_content' => $blob ) ); $srcs = get_post_gallery_images( $post_id ); $this->assertEquals( $srcs, $ids1_srcs ); }