3v4l.org

run code in 300+ PHP versions simultaneously
<?php add_action('widgets_init', 'my_widget_plugin_td_load'); function my_widget_plugin_td_load() { register_widget('my_widget_plugin_td'); } class my_widget_plugin_td extends WP_Widget { function __construct() { parent::__construct( 'my-widget-plugin-vdj', 'Время и Дата', array('description' => 'Время и дата на Java',) ); } /** * Настройка виджета. В данном случае заголовок. * @param array $instance * @return string|void */ public function form($instance) { if (isset($instance['title'])) { $title = $instance['title']; } else { $title = 'Здесь можно указать заголовок виджета'; } ?> <p> <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>"/> </p> <?php } /** * Вывод виджета * @param array $args * @param array $instance */ public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); echo $args['before_widget']; if (!empty($title)) echo $args['before_title'] . $title . $args['after_title']; // здесь выводим содержимое (форму) echo <<<HTML <div class="cleanslate w24tz-current-time w24tz-small" style="display: inline-block !important; visibility: hidden !important; min-width:100px !important; width:100% !important; min-height:100px !important; text-align:center !important;"><p><a href="//24timezones.com/world_directory/time_in_moscow.php" style="text-decoration: none" class="clock24" id="tz24-1539074187-c1166-eyJob3VydHlwZSI6IjI0Iiwic2hvd2RhdGUiOiIxIiwic2hvd3NlY29uZHMiOiIxIiwiY29udGFpbmVyX2lkIjoiY2xvY2tfYmxvY2tfY2I1YmJjNjg4YmJjZjE1IiwidHlwZSI6ImRiIiwibGFuZyI6InJ1In0=" title="часовой пояс Moscow" target="_blank" rel="nofollow">Текущее время</a></p> <div id="clock_block_cb5bbc688bbcf15"></div> </div> <script type="text/javascript" src="//w.24timezones.com/l.js" async></script> HTML; // конец формы echo $args['after_widget']; } public function update($new_instance, $old_instance) { $instance = array(); $instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : ''; return $instance; } } ?>
based on lijqm
Output for 7.3.0 - 7.3.27, 7.4.0 - 7.4.16, 8.0.0 - 8.0.3
Fatal error: Uncaught Error: Call to undefined function add_action() in /in/bAqLU:3 Stack trace: #0 {main} thrown in /in/bAqLU on line 3
Process exited with code 255.