Undefined variable warning
-
This is filling up our logs:
Undefined variable $is_allowed in wp_tota11y_js called at /code/wp-includes/class-wp-hook.php (324)The culprit:
wp-content/plugins/wp-tota11y/wp-tota11y.php:48/* Load JavaScript. */
function wp_tota11y_js() {
$allowed_roles = array( 'administrator' );
// allow other plugins to modify these in a filter
$allowed_roles = (array) apply_filters( 'wp_tota11y_allowed_roles', $allowed_roles );
if ( is_user_logged_in() ) {
$user = wp_get_current_user();
$user_roles = $user->roles;
foreach ( $user_roles as $role ) {
if ( in_array( $role, $allowed_roles, true ) ) {
$is_allowed = true;
break;
}
}
if ( $is_allowed ) {
// Always load jQuery.
wp_enqueue_script('jquery');
// Load Tota11y.js
wp_enqueue_script( 'wp-tota11y-js', plugins_url( '/js/tota11y.min.js', __FILE__ ), 'jquery', '1.2.0', true );
}
}
}The fix: Define the variable as false, first:
/* Load JavaScript. */
function wp_tota11y_js() {
$is_allowed = false;
$allowed_roles = array( 'administrator' );Can you please resolve in your next update?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Undefined variable warning’ is closed to new replies.