PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 3.1
Hustle – Email Marketing, Lead Generation, Optins, Popups v3.1
7.8.13 7.8.13.1 trunk 3.0 3.1 3.1.1 3.1.2 3.1.3 3.1.4 4.3.2 4.4.4 4.4.5 4.4.5.1 4.4.5.4 4.6 4.6.1.1 4.6.1.4 4.7.0.2 4.7.0.3 4.7.0.7 4.7.0.9 4.7.1.0 4.7.1.1 4.8.0.0 5.0.0 5.0.1 5.0.1.1 5.0.1.2 5.1 5.1.1 5.1.2 5.1.3 5.1.3.1 5.1.3.2 5.1.4 5.1.5 6.0 6.0.1 6.0.2 6.0.3 6.0.4.2 6.0.5 6.0.6.1 6.0.7 6.0.8.1 6.0.9 7.0.0.1 7.0.2 7.0.3 7.0.4 7.1.0 7.1.1 7.2.0 7.2.1 7.3.0 7.3.1 7.3.3 7.3.5 7.3.6 7.3.7 7.4.0 7.4.1 7.4.11 7.4.13 7.4.13.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.5.1 7.4.5.2 7.4.6 7.4.7 7.5.0 7.6.0 7.6.1 7.6.3 7.6.4 7.6.6 7.7.0 7.7.1 7.8.0 7.8.1 7.8.10 7.8.10.1 7.8.10.2 7.8.11 7.8.12 7.8.12.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.8.9.1 7.8.9.2 7.8.9.3
wordpress-popup / testheadfooter.php
wordpress-popup Last commit date
popoverincludes 15 years ago license.txt 15 years ago popover.php 15 years ago readme.txt 15 years ago testheadfooter.php 15 years ago
testheadfooter.php
87 lines
1 <?php
2 /*
3 Plugin Name: Test Head Footer
4 Plugin URI: http://gist.github.com/378450
5 Description: Tests for the existence and functionality of wp_head and wp_footer in the active theme
6 Author: Matt Martz
7 Author URI: http://sivel.net/
8 Version: 3.1
9
10 Copyright (c) 2010 Matt Martz (http://sivel.net/)
11 Test Head Footer is released under the GNU General Public License (GPL)
12 http://www.gnu.org/licenses/gpl-2.0.txt
13 */
14
15 // Lets not do anything until init
16 add_action( 'init', 'test_head_footer_init' );
17 function test_head_footer_init() {
18 // Hook in at admin_init to perform the check for wp_head and wp_footer
19 add_action( 'admin_init', 'check_head_footer' );
20
21 // If test-head query var exists hook into wp_head
22 if ( isset( $_GET['test-head'] ) )
23 add_action( 'wp_head', 'test_head', 99999 ); // Some obscene priority, make sure we run last
24
25 // If test-footer query var exists hook into wp_footer
26 if ( isset( $_GET['test-footer'] ) )
27 add_action( 'wp_footer', 'test_footer', 99999 ); // Some obscene priority, make sure we run last
28 }
29
30 // Echo a string that we can search for later into the head of the document
31 // This should end up appearing directly before </head>
32 function test_head() {
33 echo '<!--wp_head-->';
34 }
35
36 // Echo a string that we can search for later into the footer of the document
37 // This should end up appearing directly before </body>
38 function test_footer() {
39 echo '<!--wp_footer-->';
40 }
41
42 // Check for the existence of the strings where wp_head and wp_footer should have been called from
43 function check_head_footer() {
44 // Build the url to call, NOTE: uses home_url and thus requires WordPress 3.0
45 $url = add_query_arg( array( 'test-head' => '', 'test-footer' => '' ), home_url() );
46 // Perform the HTTP GET ignoring SSL errors
47 $response = wp_remote_get( $url, array( 'sslverify' => false ) );
48 // Grab the response code and make sure the request was sucessful
49 $code = (int) wp_remote_retrieve_response_code( $response );
50 if ( $code == 200 ) {
51 global $head_footer_errors;
52 $head_footer_errors = array();
53
54 // Strip all tabs, line feeds, carriage returns and spaces
55 $html = preg_replace( '/[\t\r\n\s]/', '', wp_remote_retrieve_body( $response ) );
56
57 // Check to see if we found the existence of wp_head
58 if ( ! strstr( $html, '<!--wp_head-->' ) )
59 $head_footer_errors['nohead'] = 'Is missing the call to <?php wp_head(); ?> which should appear directly before </head>';
60 // Check to see if we found the existence of wp_footer
61 if ( ! strstr( $html, '<!--wp_footer-->' ) )
62 $head_footer_errors['nofooter'] = 'Is missing the call to <?php wp_footer(); ?> which should appear directly before </body>';
63
64 // Check to see if we found wp_head and if was located in the proper spot
65 if ( ! strstr( $html, '<!--wp_head--></head>' ) && ! isset( $head_footer_errors['nohead'] ) )
66 $head_footer_errors[] = 'Has the call to <?php wp_head(); ?> but it is not called directly before </head>';
67 // Check to see if we found wp_footer and if was located in the proper spot
68 if ( ! strstr( $html, '<!--wp_footer--></body>' ) && ! isset( $head_footer_errors['nofooter'] ) )
69 $head_footer_errors[] = 'Has the call to <?php wp_footer(); ?> but it is not called directly before </body>';
70
71 // If we found errors with the existence of wp_head or wp_footer hook into admin_notices to complain about it
72 if ( ! empty( $head_footer_errors ) )
73 add_action ( 'admin_notices', 'test_head_footer_notices' );
74 }
75 }
76
77 // Output the notices
78 function test_head_footer_notices() {
79 global $head_footer_errors;
80
81 // If we made it here it is because there were errors, lets loop through and state them all
82 echo '<div class="error"><p><strong>Your active theme:</strong></p><ul>';
83 foreach ( $head_footer_errors as $error )
84 echo '<li>' . esc_html( $error ) . '</li>';
85 echo '</ul></div>';
86 }
87 ?>