PluginProbe ʕ •ᴥ•ʔ
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel / 3.0.6
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel v3.0.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-debug.php
foogallery / includes Last commit date
admin 8 months ago compatibility 8 months ago extensions 8 months ago foopluginbase 8 months ago public 8 months ago thumbs 8 months ago class-attachment-filters.php 8 months ago class-foogallery-animated-gif-support.php 8 months ago class-foogallery-attachment-custom-class.php 8 months ago class-foogallery-attachment-type.php 8 months ago class-foogallery-attachment.php 8 months ago class-foogallery-cache.php 8 months ago class-foogallery-common-fields.php 8 months ago class-foogallery-crop-position.php 8 months ago class-foogallery-datasource-media_library.php 8 months ago class-foogallery-debug.php 8 months ago class-foogallery-extensions-compatibility.php 8 months ago class-foogallery-force-https.php 8 months ago class-foogallery-lazyload.php 8 months ago class-foogallery-lightbox.php 8 months ago class-foogallery-paging.php 8 months ago class-foogallery-password-protect.php 8 months ago class-foogallery-sitemaps.php 8 months ago class-foogallery-widget.php 8 months ago class-foogallery.php 8 months ago class-gallery-advanced-settings.php 8 months ago class-il8n.php 8 months ago class-override-thumbnail.php 8 months ago class-posttypes.php 8 months ago class-retina.php 8 months ago class-thumbnail-dimensions.php 8 months ago class-thumbnails.php 8 months ago class-version-check.php 8 months ago constants.php 8 months ago functions.php 8 months ago includes.php 8 months ago index.php 8 months ago render-functions.php 8 months ago
class-foogallery-debug.php
171 lines
1 <?php
2 /**
3 * Class used to help with debugging issues in FooGallery
4 *
5 * @package foogallery
6 *
7 * Date: 03/05/2021
8 */
9
10 if ( ! class_exists( 'FooGallery_Debug' ) ) {
11
12 /**
13 * Class FooGallery_Debug
14 */
15 class FooGallery_Debug {
16
17 /**
18 * FooGallery_Debug constructor.
19 */
20 public function __construct() {
21 if ( is_admin() ) {
22 add_action( 'add_meta_boxes_' . FOOGALLERY_CPT_GALLERY, array( $this, 'add_meta_boxes_to_gallery' ) );
23 }
24
25 add_action( 'foogallery_loaded_template_after', array( $this, 'output_gallery_debug_info' ), 10, 1 );
26
27 add_filter( 'foogallery_build_class_attribute', array( $this, 'add_debug_class' ), 10, 2 );
28 }
29
30 /**
31 * Add a debug class onto the container if in debug
32 *
33 * @param array $classes The list of classes.
34 * @param FooGallery $gallery The gallery we are working with.
35 *
36 * @return array
37 */
38 public function add_debug_class( $classes, $gallery ) {
39 if ( foogallery_is_debug() ) {
40 $classes[] = 'fg-debug';
41 }
42
43 return $classes;
44 }
45
46 /**
47 * Output an HTML comment containing some debug info for the gallery
48 *
49 * @param FooGallery $gallery the current gallery being output.
50 */
51 public function output_gallery_debug_info( $gallery ) {
52 if ( ! foogallery_is_debug() ) {
53 return; // Get out early if we are not in debug mode!
54 }
55 echo '<!-- FooGallery Debug Info : Start';
56 echo "\r\n";
57 echo "\r\n";
58 $main = array(
59 'ID' => $gallery->ID,
60 'Template' => $gallery->gallery_template,
61 'Datasource' => $gallery->datasource_name,
62 );
63 if ( isset( $gallery->datasource_value ) ) {
64 $main['Datasource Value'] = $gallery->datasource_value;
65 }
66 foogallery_render_debug_array( $main );
67 echo "\r\n";
68 echo 'FooGallery Settings';
69 echo "\r\n";
70 echo '===================';
71 echo "\r\n";
72 $settings = $gallery->settings;
73 if ( is_array( $settings ) ) {
74 ksort( $settings );
75 }
76 foogallery_render_debug_array( $settings );
77 echo "\r\n";
78
79 echo 'Attachment Info';
80 echo "\r\n";
81 echo '===============';
82 echo "\r\n";
83 $dimensions = array();
84 foreach ( $gallery->attachments() as $attachment ) {
85 $dimension = array(
86 'url' => $attachment->url,
87 'type' => $attachment->type,
88 );
89 if ( isset( $attachment->has_thumbnail_dimensions ) && $attachment->has_thumbnail_dimensions ) {
90 $dimension['width'] = $attachment->thumb_width;
91 $dimension['height'] = $attachment->thumb_height;
92 }
93 if ( $attachment->ID > 0 ) {
94 $dimensions[ $attachment->ID ] = $dimension;
95 } else {
96 $dimensions[] = $dimension;
97 }
98 }
99 foogallery_render_debug_array( $dimensions );
100 echo "\r\n";
101
102
103 do_action( 'foogallery_gallery_debug_output', $gallery );
104 echo 'FooGallery Debug Info : End -->';
105 }
106
107 /**
108 * Add debug metabox to foogallery edit screen in admin
109 *
110 * @param WP_Post $post the current post being edited.
111 */
112 public function add_meta_boxes_to_gallery( $post ) {
113
114 if ( foogallery_is_debug() ) {
115 add_meta_box(
116 'foogallery_debug',
117 __( 'Gallery Debugging', 'foogallery' ),
118 array( $this, 'render_upgrade_debug_metabox' ),
119 FOOGALLERY_CPT_GALLERY,
120 'normal',
121 'low'
122 );
123 }
124 }
125
126 /**
127 * Render the debug metabox
128 *
129 * @param WP_Post $post the current post being edited.
130 */
131 public function render_upgrade_debug_metabox( $post ) {
132 ?>
133 <div class="foogallery-help">
134 <i class="dashicons dashicons-editor-help"></i>
135 <h4><?php _e( 'Why am I seeing this?', 'foogallery' ); ?></h4>
136 <p><?php _e( 'This is a debugging tool that will output some information about the gallery being edited. This information is sometimes requested for support queries or used for developement purposes only. To hide this, disable debugging under Settings -> Advanced.', 'foogallery' ); ?></p>
137 </div>
138 <?php
139
140 $gallery = FooGallery::get( $post );
141
142 if ( ! $gallery->is_new() ) {
143 $settings = $gallery->settings;
144
145 if ( is_array( $settings ) ) {
146 ksort( $settings );
147 }
148 ?>
149 <style>
150 #foogallery_debug .inside { overflow: scroll; }
151 #foogallery_debug table { font-size: 0.8em; }
152 #foogallery_debug td { vertical-align: top; }
153 </style>
154 <h3>Template</h3>
155 <?php echo esc_html( $gallery->gallery_template ); ?>
156 <h3>Datasource</h3>
157 <?php echo esc_html( $gallery->datasource_name ); ?>
158 <h3>Attachments</h3>
159 <?php echo esc_html( $gallery->attachment_id_csv() ); ?>
160 <h3>Settings</h3>
161 <div style="width:100%; height: 300px; overflow: scroll">
162 <?php var_dump( $settings ); ?>
163 </div>
164 <?php
165 }
166
167 do_action( 'foogallery_admin_gallery_debug_output', $gallery );
168 }
169 }
170 }
171