コード例 #1
0
function photoline_modified_post_gallery($output, $attr)
{
    global $post;
    static $instance = 0;
    $instance++;
    //disable all filter
    if (empty($attr['type']) || $attr['type'] != 'slider') {
        return;
    }
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'size' => 'photoline-featured', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $selector = "gallery-{$instance}";
    $size_class = sanitize_html_class($size);
    $gallery_div = "<div id='{$selector}' class='gallery galleryid-{$id} gallery-size-{$size_class} flexslider'>";
    $output = apply_filters('gallery_style', $gallery_div);
    $output .= '<ul class="slides">';
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $caption = !empty($attachment->post_excerpt) ? '<p class="flex-caption wp-caption-text gallery-caption">' . wptexturize($attachment->post_excerpt) . '</p>' : '';
        $image = wp_get_attachment_image($id, $size);
        $output .= '<li>';
        $output .= $image;
        $output .= $caption;
        $output .= '</li>';
    }
    $output .= "\r\n            </ul><!-- .slides -->\r\n        </div>\n";
    return $output;
}
コード例 #2
0
ファイル: gallery.php プロジェクト: altjonK/startpakke
function f5_gallery($output, $attr)
{
    global $post;
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' === $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $attachments_arr = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($attachments_arr as $key => $val) {
            $attachments[$val->ID] = $attachments_arr[$key];
        }
    }
    if (empty($attachments)) {
        return '';
    }
    $output = '<ul class="small-block-grid-2 medium-block-grid-' . $columns . '"  data-clearing>';
    foreach ($attachments as $id => $attachment) {
        $img = wp_get_attachment_image_src($id, $size);
        $img_big = wp_get_attachment_image_src($id, 'full');
        $caption = !$attachment->post_excerpt ? '' : ' data-caption="' . esc_attr($attachment->post_excerpt) . '" ';
        $output .= '<li><a href="' . $img_big[0] . '"><img src="' . $img[0] . '" ' . $caption . ' class="th" alt="' . esc_attr($post->title) . '" /></a></li>';
    }
    $output .= '</ul>';
    return $output;
}
コード例 #3
0
ファイル: tiled-gallery.php プロジェクト: spielhoelle/amnesty
 public function set_atts($atts)
 {
     global $post;
     $this->atts = shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => isset($post->ID) ? $post->ID : 0, 'include' => '', 'exclude' => '', 'type' => '', 'grayscale' => false, 'link' => '', 'columns' => 3), $atts, 'gallery');
     $this->atts['id'] = (int) $this->atts['id'];
     $this->float = is_rtl() ? 'right' : 'left';
     // Default to rectangular is tiled galleries are checked
     if ($this->tiles_enabled() && (!$this->atts['type'] || 'default' == $this->atts['type'])) {
         /** This filter is already documented in functions.gallery.php */
         $this->atts['type'] = apply_filters('jetpack_default_gallery_type', 'rectangular');
     }
     if (!$this->atts['orderby']) {
         $this->atts['orderby'] = sanitize_sql_orderby($this->atts['orderby']);
         if (!$this->atts['orderby']) {
             $this->atts['orderby'] = 'menu_order ID';
         }
     }
     if ('rand' == strtolower($this->atts['order'])) {
         $this->atts['orderby'] = 'rand';
     }
     // We shouldn't have more than 20 columns.
     if (!is_numeric($this->atts['columns']) || 20 < $this->atts['columns']) {
         $this->atts['columns'] = 3;
     }
 }
コード例 #4
0
	public function set_atts( $atts ) {
		global $post;

		$this->atts = shortcode_atts( array(
			'order'      => 'ASC',
			'orderby'    => 'menu_order ID',
			'id'         => $post->ID,
			'include'    => '',
			'exclude'    => '',
			'type'       => '',
			'grayscale'  => false,
			'link'       => '',
		), $atts );

		$this->atts['id'] = (int) $this->atts['id'];
		$this->float = is_rtl() ? 'right' : 'left';

		// Default to rectangular is tiled galleries are checked
		if ( $this->tiles_enabled() && ( ! $this->atts['type'] || 'default' == $this->atts['type'] ) )
			$this->atts['type'] = 'rectangular';

		if ( !$this->atts['orderby'] ) {
			$this->atts['orderby'] = sanitize_sql_orderby( $this->atts['orderby'] );
			if ( !$this->atts['orderby'] )
				$this->atts['orderby'] = 'menu_order ID';
		}

		if ( 'RAND' == $this->atts['order'] )
			$this->atts['orderby'] = 'none';
	}
コード例 #5
0
ファイル: gallery.php プロジェクト: alicam/vanilla-theme
/**
 * OVERRIDES: gallery_shortcode()
 *
 * This implements the functionality of the Gallery Shortcode for displaying
 * WordPress images on a post.
 */
function vanilla_gallery($attr)
{
    global $post, $tpl;
    // BUG: I'm doing something wrong, because $attr is not the array of attributes from gallery_shortcode function. Why not??
    // 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('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail'), $attr));
    $id = intval($id);
    $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, '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;
    }
    $images = array();
    foreach ($attachments as $id => $attachment) {
        $images[] = array("link" => wp_get_attachment_link($id, $size, true), "caption" => $captiontag && trim($attachment->post_excerpt) ? $attachment->post_excerpt : 0);
    }
    // Prepare the template data
    $tpl["gallery"] = array("tpl_file" => "shortcodes/gallery.html", "itemtag" => tag_escape($itemtag), "icontag" => tag_escape($icontag), "captiontag" => tag_escape($captiontag), "columns" => intval($columns), "itemwidth" => $columns > 0 ? floor(100 / $columns) - 1 : 100, "images" => $images);
    // Execute the template
    return vanilla_shortcode("gallery");
}
コード例 #6
0
ファイル: gallery.php プロジェクト: NaszvadiG/roots
/**
 * Clean up gallery_shortcode()
 *
 * Re-create the [gallery] shortcode and use thumbnails styling from Bootstrap
 *
 * @link http://twitter.github.com/bootstrap/components.html#thumbnails
 */
function roots_gallery($attr)
{
    $post = get_post();
    static $instance = 0;
    $instance++;
    if (!empty($attr['ids'])) {
        if (empty($attr['orderby'])) {
            $attr['orderby'] = 'post__in';
        }
        $attr['include'] = $attr['ids'];
    }
    $output = apply_filters('post_gallery', '', $attr);
    if ($output != '') {
        return $output;
    }
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => '', 'icontag' => '', 'captiontag' => '', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '', 'link' => 'file'), $attr));
    $id = intval($id);
    if ($order === 'RAND') {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $output = '<ul class="thumbnails gallery">';
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $image = 'file' == $link ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        $output .= '<li>' . $image;
        if (trim($attachment->post_excerpt)) {
            $output .= '<div class="caption hidden">' . wptexturize($attachment->post_excerpt) . '</div>';
        }
        $output .= '</li>';
    }
    $output .= '</ul>';
    return $output;
}
コード例 #7
0
/**
* Get the attachments from the gallery
* @param  array $attr
* @return array $attachments
*/
function get_gallery_attachments($attr)
{
    global $post;
    if (empty($attr)) {
        return;
    }
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => !empty($attr['orderby']) ? $attr['orderby'] : 'menu_order', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => !empty($attr['columns']) ? $attr['columns'] : '1', 'size' => !empty($attr['size']) ? $attr['size'] : 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    $include = preg_replace('/[^0-9,]+/', '', $include);
    $attachments_query = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    $attachments = array();
    foreach ($attachments_query as $key => $val) {
        $attachments[$val->ID] = $attachments_query[$key];
    }
    return $attachments;
}
コード例 #8
0
 /**
  * A custom function to get the entries and sort them
  *
  * @since 1.2
  * @returns array() $cols SQL results
  */
 function get_forms($orderby = 'form_id', $order = 'ASC', $per_page, $offset = 0, $search = '')
 {
     global $wpdb, $current_user;
     get_currentuserinfo();
     // Save current user ID
     $user_id = $current_user->ID;
     // Get the Form Order type settings, if any
     $user_form_order_type = get_user_meta($user_id, 'vfb-form-order-type', true);
     // Get the Form Order settings, if any
     $user_form_order = get_user_meta($user_id, 'vfb-form-order');
     foreach ($user_form_order as $form_order) {
         $form_order = implode(',', $form_order);
     }
     $where = '';
     // Forms type filter
     $where .= $this->get_form_status() && 'all' !== $this->get_form_status() ? $wpdb->prepare(' AND forms.form_status = %s', $this->get_form_status()) : '';
     // Always display all forms, unless an Form Type filter is set
     if (!$this->get_form_status() || in_array($this->get_form_status(), array('all', 'draft'))) {
         $where .= $wpdb->prepare(' AND forms.form_status IN("%s", "%s")', 'publish', 'draft');
     }
     $sql_order = sanitize_sql_orderby("{$orderby} {$order}");
     if (in_array($user_form_order_type, array('order', ''))) {
         $sql_order = isset($form_order) ? "FIELD( form_id, {$form_order} )" : sanitize_sql_orderby('form_id DESC');
     } else {
         $sql_order = sanitize_sql_orderby('form_title ASC');
     }
     $cols = $wpdb->get_results("SELECT forms.form_id, forms.form_title, forms.form_status FROM {$this->form_table_name} AS forms WHERE 1=1 {$where} {$search} ORDER BY {$sql_order}");
     return $cols;
 }
コード例 #9
0
 /**
  * Gets all images associated with the gallery. This method is lifted almost verbatim from the gallery short-code function provided by WP.
  * We will take the gallery images and do some fun stuff with styling them in other methods. We cannot use the WP function because
  * this code is nested within the gallery_shortcode function and we want to tweak that (there is no hook that executes after
  * the gallery has been retrieved.
  *
  * @param array $attr
  * @return array|bool
  */
 function get_gallery_images($attr = array())
 {
     global $post;
     // 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('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
     $id = intval($id);
     if ('RAND' == $order) {
         $orderby = 'none';
     }
     if (!empty($include)) {
         $include = preg_replace('/[^0-9,]+/', '', $include);
         $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
         $attachments = array();
         foreach ($_attachments as $key => $val) {
             $attachments[$val->ID] = $_attachments[$key];
         }
     } elseif (!empty($exclude)) {
         $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
         $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     } else {
         $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     }
     return $attachments;
 }
コード例 #10
0
function custom_gallery($attr)
{
    $post = get_post();
    static $instance = 0;
    $instance++;
    # hard-coding these values so that they can't be broken
    $attr['columns'] = 1;
    $attr['size'] = 'full';
    $attr['link'] = 'none';
    $attr['orderby'] = 'post__in';
    $attr['include'] = $attr['ids'];
    #Allow plugins/themes to override the default gallery template.
    $output = apply_filters('post_gallery', '', $attr);
    if ($output != '') {
        return $output;
    }
    # 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('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'div', 'icontag' => 'div', 'captiontag' => 'p', 'columns' => 4, 'size' => 'gallery-thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    $gallery_style = $gallery_div = '';
    if (apply_filters('use_default_gallery_style', true)) {
        $gallery_style = "<!-- see gallery_shortcode() in functions.php -->";
    }
    $gallery_div = "<ul class='clearing-thumbs small-block-grid-2 large-block-grid-4' data-clearing>";
    $output = apply_filters('gallery_style', $gallery_style . "\n\t\t" . $gallery_div);
    foreach ($attachments as $id => $attachment) {
        $link = wp_get_attachment_link($id, 'full', false, false);
        $output .= "<li>";
        $output .= "{$link}";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n\t\t\t\t<p class='wp-caption-text homepage-gallery-caption hide'>\n\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\n\t\t\t\t</p>";
        }
        $output .= "</li>";
    }
    $output .= "</ul>\n";
    return $output;
}
コード例 #11
0
 function gallery_shortcode($output, $attr)
 {
     global $post;
     if (!isset($attr['royalslider'])) {
         if (NewRoyalSliderMain::$override_all_default_galleries) {
             $rsid = NewRoyalSliderMain::$override_all_default_galleries;
         } else {
             return $output;
         }
     } else {
         $rsid = $attr['royalslider'];
     }
     // $rsdata = NewRoyalSliderMain::query_slider_data( $rsid );
     // if(!$rsdata || !$rsdata[0]) {
     // 	return NewRoyalSliderMain::frontend_error(__('Incorrect royalslider ID in gallery shortcode (or in Global, or problem with query.', 'new_royalslider'));
     // }
     // $rsdata = $rsdata[0];
     if (isset($attr['orderby'])) {
         $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
         if (!$attr['orderby']) {
             unset($attr['orderby']);
         }
     }
     extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'ids' => '', 'include' => '', 'exclude' => ''), $attr));
     $id = intval($id);
     if ('RAND' == $order) {
         $orderby = 'none';
     }
     if (!empty($ids)) {
         // 'ids' is explicitly ordered
         $orderby = 'post__in';
         $include = $ids;
     }
     if (!empty($include)) {
         $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
         $attachments = array();
         foreach ($_attachments as $key => $val) {
             $attachments[$val->ID] = $_attachments[$key];
         }
     } elseif (!empty($exclude)) {
         $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     } else {
         $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     }
     if (empty($attachments)) {
         return NewRoyalSliderMain::frontend_error(__('No post attachments found.', 'new_royalslider'));
     }
     if (is_feed()) {
         $output = "\n";
         foreach ($attachments as $att_id => $attachment) {
             $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
         }
         return $output;
     }
     require_once 'rsgenerator/NewRoyalSliderGenerator.php';
     return NewRoyalSliderGenerator::generateSlides(true, true, $rsid, 'gallery', null, $attachments, null, null, null, true);
     return $output;
 }
コード例 #12
0
function my_post_gallery($output, $attr)
{
    global $post, $wp_locale;
    static $instance = 0;
    $instance++;
    // 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('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'li', 'icontag' => 'dt', 'captiontag' => 'div', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $float = is_rtl() ? 'right' : 'left';
    $output = '<div class="owl-carousel portfolio-slider custom-controls">';
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        $output .= '<div class="item">' . wp_get_attachment_image($id, 'full');
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n                <{$captiontag} class='caption sfb white-bg small'>\n                " . wpautop($attachment->post_excerpt) . "\n                </{$captiontag}>";
        }
        $output .= '</div>';
    }
    $output .= "</div>\n";
    return $output;
}
コード例 #13
0
function custom_gallery($attr)
{
    $post = get_post();
    static $instance = 0;
    $instance++;
    $attr['columns'] = 1;
    $attr['size'] = 'full';
    $attr['link'] = 'none';
    $attr['orderby'] = 'post__in';
    $attr['include'] = $attr['ids'];
    $output = apply_filters('post_gallery', '', $attr);
    if ($output != '') {
        return $output;
    }
    # 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('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'div', 'icontag' => 'div', 'captiontag' => 'p', 'columns' => 1, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    $gallery_style = $gallery_div = '';
    if (apply_filters('use_default_gallery_style', true)) {
        $gallery_style = "<!-- see gallery_shortcode() in functions.php -->";
    }
    $gallery_div = "<div class='gallery gallery-columns-1 gallery-size-full'>";
    $output = apply_filters('gallery_style', $gallery_style . "\n\t\t" . $gallery_div);
    foreach ($attachments as $id => $attachment) {
        $link = wp_get_attachment_link($id, 'thumbnail', false, false);
        $output .= "\n\t\t\t\n                         <div class='imgc'>\n\t\t\t\t{$link} \n\t\t\t</div>";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n\t\t\t\t<p class='wp-caption-text homepage-gallery-caption'>\n\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\n\t\t\t\t</p>";
        }
        $output .= "";
    }
    $output .= "</div>\n";
    return $output;
}
コード例 #14
0
ファイル: minigallery.php プロジェクト: shimion/stlucks
/**
 * Minigallery
 * 
 * To override this shortcode in a child theme, copy this file to your child theme's
 * theme_config/extensions/shortcodes/shortcodes/ folder.
 * 
 * Optional arguments:
 * id: post/page id
 * order: ASC, DESC
 * orderby:
 * include:
 * exclude:
 * pretty: true/false use or not prettyPhoto
 * icon_plus:
 * class: css class e.g. boxed
 * carousel: jCarousel Configuration. http://sorgalla.com/projects/jcarousel/
 */
function tfuse_minigallery($attr, $content = null)
{
    global $post;
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => isset($post->ID) ? $post->ID : $attr['id'], 'include' => '', 'exclude' => '', 'pretty' => true, 'icon_plus' => '<span></span>', 'carousel' => 'easing: "easeInOutQuint",animation: 600', 'class' => 'boxed'), $attr));
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    $uniq = rand(1, 200);
    $out = '
    <script type="text/javascript">
        jQuery(document).ready(function($) {
        $("#mycarousel' . $uniq . '").jcarousel({
                ' . $carousel . '
            });
        });
    </script>
    ';
    $out .= '
    <div class="minigallery-list minigallery ' . $class . '">
        <ul id="mycarousel' . $uniq . '" class="jcarousel-skin-tango">';
    if ($icon_plus) {
        $out .= '<span></span>';
    }
    foreach ($attachments as $id => $attachment) {
        if ($pretty) {
            $out .= '<li><a href="' . $attachment->guid . '" rel="prettyPhoto[gallery' . $uniq . ']">' . '<img src="' . TF_GET_IMAGE::get_src_link($attachment->guid, 102, 102) . '" alt=' . $attachment->post_title . '>' . $icon_plus . '</a></li>';
        } else {
            $out .= '<li>' . '<img src="' . TF_GET_IMAGE::get_src_link($attachment->guid, 102, 102) . '" alt=' . $attachment->post_title . '>' . '</li>';
        }
    }
    $out .= '
        </ul>
    </div>
    <div class="clear"></div>
    ';
    return $out;
}
コード例 #15
0
 static function get_network_userlabels($order_by = 'cap_title', $order = 'ASC')
 {
     global $wpdb;
     $table_name = $wpdb->base_prefix . WPUND_USERLABEL_TABLE;
     $query = 'SELECT * FROM ' . $table_name . ' WHERE blog_id=0 ';
     if ($sql_orderby = sanitize_sql_orderby("{$order_by} {$order}")) {
         $query .= " ORDER BY {$sql_orderby}";
     }
     return self::_get_cached_result($query);
 }
コード例 #16
0
ファイル: vfbpro.php プロジェクト: solepixel/wp-forms-grabber
function wpfg_lookup_vfbpro($form_id)
{
    global $wpdb;
    $form_table_name = $wpdb->prefix . 'vfb_pro_forms';
    $order = sanitize_sql_orderby('form_id DESC');
    $form = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$form_table_name} WHERE form_id = %d ORDER BY {$order}", $form_id));
    if (isset($form->form_title) && $form->form_title) {
        return $form->form_title;
    }
    return false;
}
コード例 #17
0
function ff_Gallery($output, $attr)
{
    static $instance = 0;
    $instance++;
    global $post;
    // 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('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $gallery_ID = $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    $output = "";
    global $ff_featured_width;
    global $ff_featured_height;
    $output .= '<div class="images-slider-2 blog-article-thumbnail">';
    $output .= '<ul>';
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $url = wp_get_attachment_url($id);
        if (empty($url)) {
            continue;
        }
        $url = fImg::resize($url, $ff_featured_width, $ff_featured_height, true);
        $output .= '<li>';
        $output .= '<img src="' . esc_url($url) . '" alt="">';
        $output .= '</li>' . "\n";
    }
    $output .= '</ul>';
    $output .= '</div>';
    return $output;
}
コード例 #18
0
ファイル: gallery-mod.php プロジェクト: rraval/PressPlay
function pressplay_gallery_shortcode($null, $attr = array())
{
    global $post;
    static $instance = 0;
    $instance++;
    // 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('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail'), $attr));
    $id = intval($id);
    $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    if ($columns >= 4) {
        $galleryItemDimensions = "height:80%;width:80%;";
    } else {
        $galleryItemDimensions = "";
    }
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $itemheight = $itemwidth;
    $selector = "gallery-{$instance}";
    $output = apply_filters('gallery_style', "\r\n\t\t<style type='text/css'>\r\n\t\t\t#{$selector} {\r\n\t\t\t\tmargin: auto;\r\n\t\t\t}\r\n\t\t\t#{$selector} .gallery-item {\r\n\t\t\t\tfloat: left;\r\n\t\t\t\tmargin-top: 10px;\r\n\t\t\t\ttext-align: center;\r\n\t\t\t\twidth: {$itemwidth}%;\r\n\t\t\t\theight: {$itemheight}%;\r\n\t\t\t}\r\n\t\t\t#{$selector} img {\r\n\t\t\t\tborder: 2px solid #cfcfcf;\r\n\t\t\t\t" . $galleryItemDimensions . "\t\t\t\r\n\t\t\t}\r\n\t\t\t#{$selector} .gallery-caption {\r\n\t\t\t\tmargin-left: 0;\r\n\t\t\t}\r\n\t\t</style>\r\n\t\t<!-- see gallery_shortcode() in wp-includes/media.php -->\r\n\t\t<div id='{$selector}' class='gallery galleryid-{$id}'>");
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        $output .= "<{$itemtag} class='gallery-item'>";
        $output .= "\r\n\t\t\t<{$icontag} class='gallery-icon'>\r\n\t\t\t\t{$link}\r\n\t\t\t</{$icontag}>";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\r\n\t\t\t\t<{$captiontag} class='gallery-caption'>\r\n\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\r\n\t\t\t\t</{$captiontag}>";
        }
        $output .= "</{$itemtag}>";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= '<br style="clear: both" />';
        }
    }
    $output .= "\r\n\t\t\t<br style='clear: both;' />\r\n\t\t</div>\n";
    return $output;
}
コード例 #19
0
ファイル: class-widget.php プロジェクト: Vibeosys/VibeosysWeb
    public function form($instance)
    {
        global $wpdb;
        // Query to get all forms
        $order = sanitize_sql_orderby('form_id ASC');
        $where = apply_filters('vfb_pre_get_forms_widget', '');
        $forms = $wpdb->get_results("SELECT * FROM {$this->form_table_name} WHERE 1=1 {$where} ORDER BY {$order}");
        $instance = wp_parse_args((array) $instance);
        $title = isset($instance['title']) ? $instance['title'] : '';
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:');
        ?>
</label>
			<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" />
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('id');
        ?>
"><?php 
        _e('Form to display:', 'visual-form-builder');
        ?>
</label>
			<select id="<?php 
        echo $this->get_field_id('id');
        ?>
" name="<?php 
        echo $this->get_field_name('id');
        ?>
" class="widefat">
			<?php 
        foreach ($forms as $form) {
            echo sprintf('<option value="%1$d" id="%2$s"%3$s>%1$d - %4$s</option>', absint($form->form_id), esc_html($form->form_key), selected($form->form_id, $instance['id'], 1), wp_specialchars_decode(esc_html(stripslashes($form->form_title)), ENT_QUOTES));
        }
        ?>
			</select>
		</p>
		<?php 
    }
コード例 #20
0
ファイル: functions.php プロジェクト: jeremylightsmith/blog
function theme_gallery_shortcode($attr)
{
    global $post;
    // Allow plugins/themes to override the default gallery template.
    $output = apply_filters('post_gallery', '', $attr);
    if ($output != '') {
        return $output;
    }
    // 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('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail'), $attr));
    $id = intval($id);
    $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, '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;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $output = '<div class="gallery">' . "\n";
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        $output .= "\n<" . $itemtag . ' class="gallery-item" style="width:' . $itemwidth . '%;">' . "\n";
        $output .= '<' . $icontag . ' class="gallery-icon">' . $link . '</' . $icontag . '>';
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= '<' . $captiontag . ' class="gallery-caption">' . $attachment->post_excerpt . '</' . $captiontag . '>';
        }
        $output .= '</' . $itemtag . '>' . "\n";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= "\n" . '<br class="clear" />' . "\n";
        }
    }
    $output .= "\n" . '<br class="clear" />' . "</div>\n";
    return $output;
}
コード例 #21
0
ファイル: attachment.php プロジェクト: SymbiSoft/litprojects
function cfct_post_gallery($attr)
{
    global $post;
    // 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('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail'), $attr));
    $id = intval($id);
    $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, '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;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = apply_filters('cfct_post_gallery_columns', intval($columns));
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $output = apply_filters('gallery_style', "\n\t\t<style type='text/css'>\n\t\t\t.gallery {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t.gallery-item {\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: {$itemwidth}%;\t\t\t}\n\t\t\t.gallery img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t.gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t</style>\n\t\t<!-- see gallery_shortcode() in wp-includes/media.php -->\n\t\t<div class='gallery'>");
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        // get full item src
        $item_src = wp_get_attachment_image_src($id, 'full', false);
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        // add full item src as rel
        $link = str_replace('><img', ' class="thickbox" rel="' . $item_src[0] . '"><img', $link);
        $output .= "<{$itemtag} class='gallery-item'>";
        $output .= "\n\t\t\t<{$icontag} class='gallery-icon'>\n\t\t\t\t{$link}\n\t\t\t</{$icontag}>";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n\t\t\t\t<{$captiontag} class='gallery-caption'>\n\t\t\t\t{$attachment->post_excerpt}\n\t\t\t\t</{$captiontag}>";
        }
        $output .= "</{$itemtag}>";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= '<br style="clear: both" />';
        }
    }
    $output .= "\n\t\t\t<br style='clear: both;' />\n\t\t</div>\n";
    return $output;
}
コード例 #22
0
ファイル: gallery.php プロジェクト: peymanslh/MyBlog
function post_gallery_output($output, $attr)
{
    global $post;
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    }
    if (empty($attachments)) {
        return '';
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    // Here's your actual output, you may customize it to your need
    $output = "<div id=\"gallery-{$id}\" class=\"gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}\">\n";
    // Now you loop through each attachment
    foreach ($attachments as $id => $attachment) {
        // Fetch the thumbnail (or full image, it's up to you)
        //      $img = wp_get_attachment_image_src($id, 'medium');
        $img_large = wp_get_attachment_image_src($id, 'large');
        $img = wp_get_attachment_image_src($id, 'thumbnail');
        $output .= "<div class=\"gallery-item\">\n";
        $output .= "<a href=\"{$img_large[0]}\" data-lightbox=\"post-gallery\" data-title=\" {$attachment->post_excerpt} \">\n";
        $output .= "<img src=\"{$img[0]}\" width=\"{$img[1]}\" height=\"{$img[2]}\" alt=\"\" />\n";
        $output .= "</a>\n";
        $output .= "</div>\n";
    }
    $output .= "</div>\n";
    return $output;
}
コード例 #23
0
ファイル: lightbox.php プロジェクト: katstar01/fivebeers
/**
 * Modify Gallery Shortcode Markup for lightbox
 *
*/
function strip_gallery($content, $attr)
{
    global $instance, $post;
    $instance++;
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'figure', 'icontag' => 'div', 'captiontag' => 'figcaption', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if ($include) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif ($exclude) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return;
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $output = "\n" . '<div class="strip_gallery">' . "\n";
    foreach ($attachments as $id => $attachment) {
        $strip_attr = sprintf('class="strip thumbnail" data-strip-group="gallery-%s" data-strip-caption="%s" data-strip-options="side: %s"', $post->ID, $post->post_title, "'right'");
        $output .= '<a href="' . wp_get_attachment_url($id) . '" ' . $strip_attr . '"><img src="' . wp_get_attachment_thumb_url($id) . '" class="strip thumbnail"></a>' . "\n";
    }
    $output .= "</div>" . "\n";
    return $output;
}
コード例 #24
0
ファイル: custom.php プロジェクト: 12sm/allisonveltzmusic
function my_post_gallery($output, $attr)
{
    global $post;
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    }
    if (empty($attachments)) {
        return '';
    }
    // Here's your actual output, you may customize it to your need
    $output = "<div class=\"slideshow-wrapper\">\n";
    $output .= "<div class=\"preloader\"></div>\n";
    $output .= "<ul data-orbit>\n";
    // Now you loop through each attachment
    foreach ($attachments as $id => $attachment) {
        // Fetch the thumbnail (or full image, it's up to you)
        //      $img = wp_get_attachment_image_src($id, 'medium');
        //      $img = wp_get_attachment_image_src($id, 'my-custom-image-size');
        $img = wp_get_attachment_image_src($id, 'full');
        $output .= "<li>\n";
        $output .= "<img src=\"{$img[0]}\" width=\"{$img[1]}\" height=\"{$img[2]}\" alt=\"\" />\n";
        $output .= "</li>\n";
    }
    $output .= "</ul>\n";
    $output .= "</div>\n";
    return $output;
}
コード例 #25
0
ファイル: pics.php プロジェクト: jchck/jchck_
function gallery($output, $attr)
{
    /**
     *
     * This refractors the [gallery] shortcode
     * @link http://stackoverflow.com/a/19804410
     *
     */
    global $post, $img_css;
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    }
    if (empty($attachments)) {
        return '';
    }
    $output = "<div class='flex flex-wrap justify-end'>";
    /* Loop through attachments */
    foreach ($attachments as $id => $attachment) {
        $img = wp_get_attachment_image_src($id, 'full');
        $output .= "<div class='col-12 sm-col-6 pr1 pb1'>";
        $output .= "<img src='{$img[0]}' class='{$img_css}' />";
        $output .= "</div>";
    }
    $output .= "</div>\n";
    return $output;
}
コード例 #26
0
    public function form($instance)
    {
        global $wpdb;
        // Query to get all forms
        $order = sanitize_sql_orderby('form_id ASC');
        $where = apply_filters('vfb_pre_get_forms_widget', '');
        $forms = $wpdb->get_results("SELECT * FROM {$this->form_table_name} WHERE 1=1 {$where} ORDER BY {$order}");
        $instance = wp_parse_args((array) $instance);
        ?>
		<select name="<?php 
        echo $this->get_field_name('id');
        ?>
">
		<?php 
        foreach ($forms as $form) {
            echo sprintf('<option value="%1$d" id="%2$s"%3$s>%4$s</option>', absint($form->form_id), esc_html($form->form_key), selected($form->form_id, $instance['id'], 1), wp_specialchars_decode(esc_html(stripslashes($form->form_title)), ENT_QUOTES));
        }
        ?>
		</select>
		<?php 
    }
コード例 #27
0
ファイル: gallery.php プロジェクト: bogdanpetru/wpAtom
function my_post_gallery($output, $attr)
{
    global $post;
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'full', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    }
    if (empty($attachments)) {
        return '';
    }
    // Here's your actual output, you may customize it to your need
    $output = "<div class=\"gallery-wrapper row\">\n";
    // Now you loop through each attachment
    foreach ($attachments as $id => $attachment) {
        $img = wp_get_attachment_image_src($id, 'full');
        $bfi_args = array('width' => 180, 'height' => 180);
        $bfi_img = bfi_thumb($img[0], $bfi_args);
        $output .= "<div class='gallery-item col-lg-3 col-sm-4 col-xs-2'>";
        $output .= "<a href='{$img['0']}'><img src=\"{$bfi_img}\" /></a>";
        $output .= "</div>";
    }
    $output .= "</div>\n";
    return $output;
}
コード例 #28
0
ファイル: slideshow.php プロジェクト: mostafiz93/PrintfScanf
 function shortcode_callback($attr, $content = null)
 {
     global $post, $content_width;
     $attr = shortcode_atts(array('trans' => 'fade', 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'include' => '', 'exclude' => ''), $attr);
     if ('rand' == strtolower($attr['order'])) {
         $attr['orderby'] = 'none';
     }
     $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
     if (!$attr['orderby']) {
         $attr['orderby'] = 'menu_order ID';
     }
     // Don't restrict to the current post if include
     $post_parent = empty($attr['include']) ? intval($attr['id']) : null;
     $attachments = get_posts(array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'posts_per_page' => -1, 'post_parent' => $post_parent, 'order' => $attr['order'], 'orderby' => $attr['orderby'], 'include' => $attr['include'], 'exclude' => $attr['exclude']));
     if (count($attachments) < 2) {
         return;
     }
     $gallery_instance = sprintf("gallery-%d-%d", $attr['id'], ++$this->instance_count);
     $gallery = array();
     foreach ($attachments as $attachment) {
         $attachment_image_src = wp_get_attachment_image_src($attachment->ID, 'full');
         $attachment_image_src = $attachment_image_src[0];
         // [url, width, height]
         $caption = apply_filters('jetpack_slideshow_slide_caption', wptexturize(strip_tags($attachment->post_excerpt)), $attachment->ID);
         $gallery[] = (object) array('src' => (string) esc_url_raw($attachment_image_src), 'id' => (string) $attachment->ID, 'caption' => (string) $caption);
     }
     $max_width = intval(get_option('large_size_w'));
     $max_height = 450;
     if (intval($content_width) > 0) {
         $max_width = min(intval($content_width), $max_width);
     }
     $js_attr = array('gallery' => $gallery, 'selector' => $gallery_instance, 'width' => $max_width, 'height' => $max_height, 'trans' => $attr['trans'] ? $attr['trans'] : 'fade');
     // Show a link to the gallery in feeds.
     if (is_feed()) {
         return sprintf('<a href="%s">%s</a>', esc_url(get_permalink($post->ID) . '#' . $gallery_instance . '-slideshow'), esc_html__('Click to view slideshow.', 'jetpack'));
     }
     return $this->slideshow_js($js_attr);
 }
コード例 #29
0
ファイル: tiled-gallery.php プロジェクト: shazadmaved/vizblog
 public function set_atts($atts)
 {
     global $post;
     $this->atts = shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => isset($post->ID) ? $post->ID : 0, 'include' => '', 'exclude' => '', 'type' => '', 'grayscale' => false, 'link' => '', 'columns' => 3), $atts, 'gallery');
     $this->atts['id'] = (int) $this->atts['id'];
     $this->float = is_rtl() ? 'right' : 'left';
     // Default to rectangular is tiled galleries are checked
     if ($this->tiles_enabled() && (!$this->atts['type'] || 'default' == $this->atts['type'])) {
         $this->atts['type'] = 'rectangular';
     }
     if (!$this->atts['orderby']) {
         $this->atts['orderby'] = sanitize_sql_orderby($this->atts['orderby']);
         if (!$this->atts['orderby']) {
             $this->atts['orderby'] = 'menu_order ID';
         }
     }
     if ('RAND' == $this->atts['order']) {
         $this->atts['orderby'] = 'none';
     }
     if (!is_numeric($this->atts['columns']) || 20 < $this->atts['columns']) {
         // we shouldn't have more then 30 columns
         $this->atts['columns'] = 3;
     }
 }
コード例 #30
0
ファイル: functions.php プロジェクト: alexward1981/lxword
function sandbox_gallery($attr)
{
    global $post;
    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, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail'), $attr));
    $id = intval($id);
    $orderby = addslashes($orderby);
    $attachments = get_children("post_parent={$id}&post_type=attachment&post_mime_type=image&orderby={$orderby}");
    if (empty($attachments)) {
        return null;
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $id => $attachment) {
            $output .= wp_get_attachment_link($id, $size, true) . "\n";
        }
        return $output;
    }
    $listtag = tag_escape($listtag);
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $output = apply_filters('gallery_style', "\n" . '<div class="gallery">', 9);
    // Available filter: gallery_style
    foreach ($attachments as $id => $attachment) {
        $img_lnk = get_attachment_link($id);
        $img_src = wp_get_attachment_image_src($id, $size);
        $img_src = $img_src[0];
        $img_alt = $attachment->post_excerpt;
        if ($img_alt == null) {
            $img_alt = $attachment->post_title;
        }
        $img_rel = apply_filters('gallery_img_rel', 'attachment');
        // Available filter: gallery_img_rel
        $img_class = apply_filters('gallery_img_class', 'gallery-image');
        // Available filter: gallery_img_class
        $output .= "\n\t" . '<' . $itemtag . ' class="gallery-item gallery-columns-' . $columns . '">';
        $output .= "\n\t\t" . '<' . $icontag . ' class="gallery-icon"><a href="' . $img_lnk . '" title="' . $img_alt . '" rel="' . $img_rel . '"><img src="' . $img_src . '" alt="' . $img_alt . '" class="' . $img_class . ' attachment-' . $size . '" /></a></' . $icontag . '>';
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n\t\t" . '<' . $captiontag . ' class="gallery-caption">' . $attachment->post_excerpt . '</' . $captiontag . '>';
        }
        $output .= "\n\t" . '</' . $itemtag . '>';
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= "\n</div>\n" . '<div class="gallery">';
        }
    }
    $output .= "\n</div>\n";
    return $output;
}