PHP Deprecated notice when updating to PHP 8
-
New Notice when updating to PHP 8 for all shortcodes – WordPress 5.8.3
Required parameter $shortcode_tag follows optional parameter $content in .../Shortcodes/Stats.php
Looks like PHP 8 wants the parameter with the default value last but the WP Code Reference states the $callback 3 parameters should be in the order they are in the code below. Will removing the default value for $content affect functionality?
<?php namespace Shareholders\Shortcodes; class Stats implements ShortcodeConfig { public function register_hooks() { add_shortcode('stat', [$this, 'render_stats_container']); } public function render_stats_container($atts, $content = null, $shortcode_tag) { $shortcode = shortcode_atts([ 'container_class' => '', 'stat_class' => '', ], $atts); ob_start(); ?> <div class="<?php echo $shortcode['container_class']; ?>"> <div class="<?php echo $shortcode['stat_class']; ?>"> <?php echo do_shortcode(apply_filters('the_content', $content)); ?> </div> </div> <?php return ob_get_clean(); } }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘PHP Deprecated notice when updating to PHP 8’ is closed to new replies.