PluginProbe
Code Profiler – WordPress Performance Profiling and Debugging Made Easy / 1.7.4
Code Profiler – WordPress Performance Profiling and Debugging Made Easy v1.7.4
1.9.5 1.9.4 1.9.3 trunk 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.6 1.6.1 1.6.10 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 All 40 releases
← All changes | lib/menu_view_plugins.php +58 -0 1.9.41.7.4 View file →
@@ -54,8 +54,13 @@
54 54 } else {
55 55 $chart_max_plugins = $cp_options['chart_max_plugins'];
56 56 }
57 57
58 +// Check if we should warn about composer
59 +if (! empty( $cp_options['warn_composer'] ) ) {
60 + $composer_warning = code_profiler_composer_warning( $profile_path, $cp_options['display_name'] );
61 +}
62 +
58 63 $label = [];
59 64 $data = '';
60 65 $theme = esc_attr__('theme', 'code-profiler');
61 66 $total_time = 0;
@@ -154,6 +159,59 @@
154 159 $save_png = 1;
155 160 $rotate_img = 1;
156 161 $type = 'slugs';
157 162
163 +// ===================================================================== 2023-11-17
164 +// Warn if multiple plugins are using composer
165 +
166 +function code_profiler_composer_warning( $profile_path, $display_name ) {
167 +
168 + if (! file_exists( "$profile_path.composer.profile" ) ) {
169 + return;
170 + }
171 + $res = json_decode( file_get_contents( "$profile_path.composer.profile" ), true );
172 + // Make sure there are at least two items (free version only)
173 + if ( $res === false || count( $res ) < 2 ) {
174 + return;
175 + }
176 +
177 + $list = '';
178 + $first = '';
179 + $count = 1;
180 + foreach( $res as $slug => $name ) {
181 + if ( $display_name == 'full') {
182 + $list .= "$count: <strong>". esc_html( $name ) .'</strong>, ';
183 + if ( empty( $first ) ) {
184 + $first = '<strong>'. esc_html( $name ) .'</strong>';
185 + }
186 + } else {
187 + $list .= "$count: <strong>". esc_html( $slug ) .'</strong>, ';
188 + if ( empty( $first ) ) {
189 + $first = '<strong>'. esc_html( $slug ) .'</strong>';
190 + }
191 + }
192 + $count++;
193 + }
194 + $list = rtrim( $list, ', ') .'.';
195 +
196 + $msg = esc_html__('Code Profiler has detected that the following components, sorted by execution'.
197 + ' order, are using Composer dependency manager:', 'code-profiler') . "<br />$list<br />".
198 + sprintf(
199 + esc_html__(
200 + 'As that may increase the execution time of %s, make sure to consult the following FAQ: '.
201 + '%s%s%s', 'code-profiler'
202 + ),
203 + $first,
204 + '<a href="?page=code-profiler&cptab=faq#composerwarning" target="_blank" rel="noopener '.
205 + 'noreferrer">',
206 + esc_html__(
207 + 'Why does Code Profiler warn me that I have multiple plugins using Composer?',
208 + 'code-profiler'
209 + ),
210 + '</a>'
211 + );
212 +
213 + return '<div class="cp-notice cp-notice-orange"><p>'. $msg .'</p></div>';
214 +
215 +}
158 216 // =====================================================================
159 217 // EOF