Title: php warnings and solution
Last modified: April 26, 2025

---

# php warnings and solution

 *  [roadlink](https://wordpress.org/support/users/roadlink/)
 * (@roadlink)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/php-warnings-and-solution/)
 * Hi there,
   Plugin creates some warnings as below.The code is trying to access 
   array keys ‘type’ and ‘rows’ without checking if they exist first. 
 *     ```wp-block-code
       Warning: Undefined array key "type" in /wp-content/plugins/gtm-consent-mode-banner/src/Service/SettingsService.php on line 417 Warning: Undefined array key "rows" in /wp-content/plugins/gtm-consent-mode-banner/src/Service/SettingsService.php on line 399
       ```
   
 * Suggested code
 *     ```wp-block-code
       	public function textareaField( $args ): void {		// Get the value of the setting we've registered with register_setting()		$value = $args['value'] ?? get_option( $args['label_for'] );		$rows = isset($args['rows']) ? (int)$args['rows'] : 5; // Default to 5 rows if not specified		?>		<textarea			id="<?php echo esc_attr( $args['label_for'] ); ?>"			class="large-text code"			rows="<?php echo esc_html( $rows ); ?>"			placeholder="<?php echo esc_html( @$args['placeholder'] ); ?>"			name="<?php echo esc_attr( $args['label_for'] ); ?>"><?php echo wp_kses($value, SanitizationUtil::WP_KSES_ALLOWED_HTML, SanitizationUtil::WP_KSES_ALLOWED_PROTOCOLS); ?></textarea>		<?php if (isset($args['description'])) : ?>		<p class="description">			<?php echo esc_html( $args['description'] ); ?>		</p>		<?php endif; ?>		<?php	}	public function inputField( $args ): void {		// Get the value of the setting we've registered with register_setting()		$value = $args['value'] ?? get_option( $args['label_for'] );		$type = isset($args['type']) ? $args['type'] : 'text'; // Default to text if not specified		?>		<input			id="<?php echo esc_attr( $args['label_for'] ); ?>"			class="large-text code"			type="<?php echo esc_html( $type ); ?>"			<?php if (true === @$args['disabled']) : ?>				disabled="disabled"			<?php endif; ?>			value="<?php echo esc_html($value); ?>"			placeholder="<?php echo esc_html( @$args['placeholder'] ); ?>"			name="<?php echo esc_attr( $args['label_for'] ); ?>" />		<?php if (isset($args['description'])) : ?>		<p class="description">			<?php echo esc_html( $args['description'] ); ?>		</p>		<?php endif; ?>		<?php	}
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Chillifish](https://wordpress.org/support/users/chillifish/)
 * (@chillifish)
 * [1 year ago](https://wordpress.org/support/topic/php-warnings-and-solution/#post-18492260)
 * Thanks for that, has worked for me.
 *  [michaloo](https://wordpress.org/support/users/michaloo/)
 * (@michaloo)
 * [9 months, 2 weeks ago](https://wordpress.org/support/topic/php-warnings-and-solution/#post-18621601)
 * Hi [@roadlink](https://wordpress.org/support/users/roadlink/),
 * thank you for reporting the issue and sharing the result. After some time of 
   lack of active development we are going to release a patched version soon.
 * All the best,

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘php warnings and solution’ is closed to new replies.

 * ![](https://ps.w.org/gtm-consent-mode-banner/assets/icon-256x256.png?rev=3080006)
 * [Consent Mode Banner](https://wordpress.org/plugins/gtm-consent-mode-banner/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gtm-consent-mode-banner/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gtm-consent-mode-banner/)
 * [Active Topics](https://wordpress.org/support/plugin/gtm-consent-mode-banner/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gtm-consent-mode-banner/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gtm-consent-mode-banner/reviews/)

 * 2 replies
 * 3 participants
 * Last reply from: [michaloo](https://wordpress.org/support/users/michaloo/)
 * Last activity: [9 months, 2 weeks ago](https://wordpress.org/support/topic/php-warnings-and-solution/#post-18621601)
 * Status: not resolved