Hello
i have a conrtoller (app\controllers) with this code becouse i want to disable widgets from the admin area,
however the widgets_init function does not execute therefore the unregister_widget call does not run.
what am I doing wrong?
Is it possible to make calls to wordpress functions from controllers?
<?php
namespace App\Controllers;
use Sober\Controller\Controller;
class CustomUserOptions extends Controller
{
public function __construct() {
add_action('widgets_init', [ $this, 'wpdocs_remove_calendar_widget' ], 99);
}
function wpdocs_remove_calendar_widget() {
unregister_widget('WP_Widget_Calendar');
}
}
Thank you so much