PluginProbe
Adminimize / 1.9.1
Adminimize v1.9.1
1.11.14 1.11.13 1.11.1 1.11.10 1.11.11 1.11.12 1.11.2 1.11.3 1.11.4 1.11.5 1.11.6 1.11.7 1.11.8 1.11.9 1.3 1.4.7 1.6 1.7.12 1.7.13 1.7.14 1.7.15 1.7.16 1.7.17 1.7.18 1.7.19 All 53 releases
← All changes | inc-setup/helping_hands.php +38 -112 1.11.1 → 1.9.1 View file →
@@ -11,10 +11,10 @@
11 11
12 12 /**
13 13 * Recursive search in array.
14 14 *
15 - * @param string $needle
16 - * @param array $haystack
15 + * @param $needle
16 + * @param $haystack
17 17 *
18 18 * @return bool
19 19 */
20 20 function _mw_adminimize_recursive_in_array( $needle, $haystack ) {
@@ -42,10 +42,10 @@
42 42
43 43 /**
44 44 * Check if array contains all array values from another array.
45 45 *
46 - * @param array $array1
47 - * @param array $array2
46 + * @param $array1
47 + * @param $array2
48 48 *
49 49 * @return bool
50 50 */
51 51 function _mw_adminimize_in_arrays( $array1, $array2 ) {
@@ -52,141 +52,67 @@
52 52
53 53 return (bool) count( array_intersect( $array1, $array2 ) );
54 54 }
55 55
56 -/**
57 - * Check the role with the current user data.
58 - *
59 - * @param string $role
60 - *
61 - * @return bool
62 - */
63 -function _mw_adminimize_current_user_has_role( $role ) {
56 +// Fix some badly enqueued scripts with no sense of HTTPS.
57 +// Kudos to http://snippets.webaware.com.au/snippets/cleaning-up-wordpress-plugin-script-and-stylesheet-loads-over-ssl/
58 +add_action( 'wp_print_scripts', '_mw_adminimize_enqueueScriptsFix', 100 );
59 +add_action( 'wp_print_styles', '_mw_adminimize_enqueueStylesFix', 100 );
64 60
65 - $user = wp_get_current_user();
66 - if ( in_array( $role, (array) $user->roles, FALSE ) ) {
67 - return TRUE;
68 - }
69 -
70 - return FALSE;
71 -}
72 -
73 61 /**
74 - * Simple helper to debug to the console of the browser.
75 - * Set WP_DEBUG_DISPLAY in your wp-config.php to true for view debug messages inside the console.
76 - *
77 - * @param string | array | object
78 - * @param string $description
79 - *
80 - * @return string|void
62 + * Force plugins to load scripts with SSL if page is SSL.
81 63 */
82 -function _mw_adminimize_debug( $data, $description = '' ) {
64 +function _mw_adminimize_enqueueScriptsFix() {
83 65
84 - if ( ! _mw_adminimize_get_option_value( 'mw_adminimize_debug' ) ) {
66 + if ( is_admin() ) {
85 67 return;
86 68 }
87 69
88 - if ( '' === $description ) {
89 - $description = 'Debug in Console via Adminimize Plugin:';
70 + $https_values = array( NULL, 'off' );
71 + if ( ! isset( $_SERVER[ 'HTTPS' ] ) || in_array( $_SERVER[ 'HTTPS' ], $https_values ) ) {
72 + return;
90 73 }
91 74
92 - // Buffering to solve problems with WP core, header() etc.
93 - ob_start();
94 - $output = 'console.info(' . json_encode( $description ) . ');';
95 - $output .= 'console.log(' . json_encode( $data ) . ');';
96 - $output = sprintf( '<script>%s</script>', $output );
97 -
98 - echo $output;
99 -}
100 -
101 -/**
102 - * Return duplicate items from array.
103 - *
104 - * @param $array
105 - *
106 - * @return array
107 - */
108 -function _mw_adminimize_get_duplicate( $array ) {
109 -
110 - return array_unique(
111 - array_diff_assoc( $array, array_unique( $array ) )
112 - );
113 -}
114 -
115 -/**
116 - * Get intersection of a multiple array.
117 - *
118 - * @since 2016-06-28
119 - *
120 - * @param $array array Array with settings of all roles.
121 - *
122 - * @return array Data with only the data, there in each role active.
123 - */
124 -function _mw_adminimize_get_intersection( $array ) {
125 -
126 - return (array) call_user_func_array( 'array_intersect', $array );
127 -}
128 -
129 -/**
130 - * Flatten a multi-dimensional array in a simple array.
131 - *
132 - * @since 2016-11-19
133 - *
134 - * @param array $array
135 - *
136 - * @return array $flat
137 - */
138 -function _mw_adminimize_array_flatten( $array ) {
139 -
140 - $flat = array();
141 - foreach ( $array as $key => $value ) {
142 - if ( is_array( $value ) ) {
143 - $flat = array_merge( $flat, _mw_adminimize_array_flatten( $value ) );
144 - } else {
145 - $flat[ $key ] = $value;
75 + foreach ( (array) $GLOBALS[ 'wp_scripts' ]->registered as $script ) {
76 + if ( FALSE !== stripos( $script->src, 'http://', 0 ) ) {
77 + $script->src = str_replace( 'http://', 'https://', $script->src );
146 78 }
147 79 }
148 -
149 - return $flat;
150 80 }
151 81
152 82 /**
153 - * Break the access to a page.
154 - *
155 - * @wp-hook load-$page_slug
156 - *
157 - * @param string $slug
83 + * Force plugins to load styles with SSL if page is SSL.
158 84 */
159 -function _mw_adminimize_check_page_access( $slug ) {
85 +function _mw_adminimize_enqueueStylesFix() {
160 86
161 - // If this default behavior is deactivated.
162 - if ( _mw_adminimize_get_option_value( 'mw_adminimize_prevent_page_access' ) ) {
87 + if ( is_admin() ) {
163 88 return;
164 89 }
165 90
166 - $uri = esc_url_raw( $_SERVER[ 'REQUEST_URI' ] );
167 - $uri = parse_url( $uri );
168 -
169 - if ( ! isset( $uri[ 'path' ] ) ) {
91 + $https_values = array( NULL, 'off' );
92 + if ( ! isset( $_SERVER[ 'HTTPS' ] ) || in_array( $_SERVER[ 'HTTPS' ], $https_values ) ) {
170 93 return;
171 94 }
172 95
173 - // URI without query parameter, like WP core edit.php.
174 - if ( ! isset( $uri[ 'query' ] ) && strpos( $uri[ 'path' ], $slug ) !== FALSE ) {
175 - add_action( 'load-' . $slug, '_mw_adminimize_block_page_access' );
96 + foreach ( (array) $GLOBALS[ 'wp_styles' ]->registered as $script ) {
97 + if ( FALSE !== stripos( $script->src, 'http://', 0 ) ) {
98 + $script->src = str_replace( 'http://', 'https://', $script->src );
99 + }
176 100 }
177 -
178 - // URI with get parameter, like CPT.
179 - if ( isset( $uri[ 'query' ] ) && strpos( $slug, $uri[ 'query' ] ) !== FALSE ) {
180 - add_action( 'load-' . basename( $uri[ 'path' ] ), '_mw_adminimize_block_page_access' );
181 - }
182 101 }
183 102
184 103 /**
185 - * Break the access to a page.
104 + * Check the role with the current user data.
186 105 *
187 - * @wp-hook load-$page_slug
106 + * @param string $role
107 + *
108 + * @return bool
188 109 */
189 -function _mw_adminimize_block_page_access() {
110 +function _mw_adminimize_current_user_has_role( $role ) {
190 111
191 - wp_die( esc_attr__( 'Cheatin&#8217; uh? Sorry, you are not allowed to access this site.', 'adminimize' ) );
192 -}
112 + $user = wp_get_current_user();
113 + if ( in_array( $role, (array) $user->roles ) ) {
114 + return TRUE;
115 + }
116 +
117 + return FALSE;
118 +}