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