PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.1.36
Gallery : FooGallery v3.1.36
3.3.2 3.3.3 3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / class-foogallery-attachment.php
foogallery / includes Last commit date
abilities 2 months ago admin 2 months ago compatibility 2 months ago extensions 2 months ago foopluginbase 2 months ago public 2 months ago thumbs 2 months ago asset-manifest.php 2 months ago class-attachment-filters.php 2 months ago class-command-palette.php 2 months ago class-foogallery-animated-gif-support.php 2 months ago class-foogallery-attachment-custom-class.php 2 months ago class-foogallery-attachment-filename.php 2 months ago class-foogallery-attachment-type.php 2 months ago class-foogallery-attachment.php 2 months ago class-foogallery-cache.php 2 months ago class-foogallery-common-fields.php 2 months ago class-foogallery-crop-position.php 2 months ago class-foogallery-datasource-media_library.php 2 months ago class-foogallery-debug.php 2 months ago class-foogallery-delayed-runtime-loader.php 2 months ago class-foogallery-extensions-compatibility.php 2 months ago class-foogallery-force-https.php 2 months ago class-foogallery-lazyload.php 2 months ago class-foogallery-license-constant-handler.php 2 months ago class-foogallery-lightbox.php 2 months ago class-foogallery-paging.php 2 months ago class-foogallery-password-protect.php 2 months ago class-foogallery-sitemaps.php 2 months ago class-foogallery-widget.php 2 months ago class-foogallery.php 2 months ago class-gallery-advanced-settings.php 2 months ago class-il8n.php 2 months ago class-override-thumbnail.php 2 months ago class-posttypes.php 2 months ago class-previews.php 2 months ago class-retina.php 2 months ago class-thumbnail-dimensions.php 2 months ago class-thumbnails.php 2 months ago class-version-check.php 2 months ago constants.php 2 months ago functions.php 2 months ago includes.php 2 months ago index.php 2 months ago render-functions.php 2 months ago
class-foogallery-attachment.php
154 lines
1 <?php
2 /**
3 * Class FooGalleryAttachment
4 *
5 * An easy to use wrapper class for a FooGallery Attachment
6 */
7 if ( ! class_exists( 'FooGalleryAttachment' ) ) {
8
9 class FooGalleryAttachment extends stdClass {
10 /**
11 * public constructor
12 *
13 * @param null $post
14 */
15 public function __construct( $post = null ) {
16 $this->set_defaults();
17
18 if ( $post !== null ) {
19 $this->load( $post );
20 }
21 }
22
23 /**
24 * Sets the default when a new gallery is instantiated
25 */
26 private function set_defaults() {
27 $this->_post = null;
28 $this->ID = 0;
29 $this->type = 'image'; // set the default type to image.
30 $this->title = '';
31 $this->caption = '';
32 $this->description = '';
33 $this->alt = '';
34 $this->url = '';
35 $this->width = 0;
36 $this->height = 0;
37 $this->parent_post_id = 0;
38 $this->parent_post_url = '';
39 $this->custom_url = '';
40 $this->custom_target = '';
41 $this->custom_rel = '';
42 }
43
44 /**
45 * private attachment load function
46 * @param $post | WP_Post
47 */
48 private function load( $post ) {
49 $this->_post = $post;
50 $this->ID = $post->ID;
51 $this->title = trim( $post->post_title );
52 $this->caption = trim( $post->post_excerpt );
53 $this->description = trim( $post->post_content );
54 $this->alt = trim( get_post_meta( $this->ID, '_wp_attachment_image_alt', true ) );
55 $this->custom_url = foogallery_sanitize_attachment_custom_url( get_post_meta( $this->ID, '_foogallery_custom_url', true ) );
56 $this->custom_target = foogallery_sanitize_attachment_custom_target( get_post_meta( $this->ID, '_foogallery_custom_target', true ) );
57 $this->custom_rel = foogallery_sanitize_attachment_custom_rel( get_post_meta( $this->ID, '_foogallery_custom_rel', true ) );
58 $this->parent_post_id = (int) $post->post_parent;
59 if ( $this->parent_post_id > 0 ) {
60 $this->parent_post_url = get_permalink( $this->parent_post_id );
61 }
62 $this->load_attachment_image_data( $this->ID );
63
64 $this->date = !empty( $post->post_date_gmt ) ? $post->post_date_gmt : $post->post_date;
65 $this->modified = !empty( $post->post_modified_gmt ) ? $post->post_modified_gmt : $post->post_modified;
66
67 do_action( 'foogallery_attachment_instance_after_load', $this, $post );
68 }
69
70 public function load_attachment_image_data( $attachment_id ) {
71 $image_attributes = foogallery_get_full_size_image_data( $attachment_id );
72 if ( $image_attributes ) {
73 $this->url = $image_attributes[0];
74 $this->width = $image_attributes[1];
75 $this->height = $image_attributes[2];
76 }
77 }
78
79 /**
80 * Static function to load a FooGalleryAttachment instance by passing in a post object
81 * @static
82 *
83 * @param $post
84 *
85 * @return FooGalleryAttachment
86 */
87 public static function get( $post ) {
88 return new self( $post );
89 }
90
91 /**
92 * Static function to load a FooGalleryAttachment instance by passing in an attachment_id
93 * @static
94 *
95 * @param $attachment_id
96 *
97 * @return FooGalleryAttachment
98 */
99 public static function get_by_id( $attachment_id ) {
100 $post = get_post( $attachment_id );
101 return new self( $post );
102 }
103
104 /**
105 * Returns the image source only
106 *
107 * @param array $args
108 * @return string
109 */
110 public function html_img_src( $args = array() ) {
111 return esc_url( apply_filters( 'foogallery_attachment_resize_thumbnail', $this->url, $args, $this ) );
112 }
113
114 /**
115 * @deprecated 1.9.24 Functions inside render-functions.php should rather be used
116 *
117 * Returns the HTML img tag for the attachment
118 * @param array $args
119 *
120 * @return string
121 */
122 public function html_img( $args = array() ) {
123 return foogallery_attachment_html_image( $this, $args );
124 }
125
126 /**
127 * @deprecated 1.9.24 Functions inside render-functions.php should rather be used
128 *
129 * Returns HTML for the attachment
130 * @param array $args
131 * @param bool $output_image
132 * @param bool $output_closing_tag
133 *
134 * @return string
135 */
136 public function html( $args = array(), $output_image = true, $output_closing_tag = true ) {
137 return foogallery_attachment_html_anchor( $this, $args, $output_image, $output_closing_tag );
138 }
139
140 /**
141 * @deprecated 1.9.24 Functions inside render-functions.php should rather be used
142 *
143 * Returns generic html for captions
144 *
145 * @param $caption_content string Include title, desc, or both
146 *
147 * @return string
148 */
149 public function html_caption( $caption_content ) {
150 return foogallery_attachment_html_caption( $this );
151 }
152 }
153 }
154