I have been currently building a custom widget in WordPress based on the text widget as a starting point. It seems that within the function __construct part of the widget, the class name is a hard coded string.

I would like to make this hard coded string more dynamic by calling a separate file which has a bunch of if else statements that get chosen depending on the select option chosen by the user. This would clearly change the class on the widget front end to allow for different styling.

parent::__construct('one_in_four_widget', __('LCPS Custom Widget'), $widget_ops, $control_ops);

I tried replacing the hard coded string with an include file

parent::__construct(include( get_template_directory_uri() . '/views/one-in-four-admin.php' ), __('LCPS Custom Widget'), $widget_ops, $control_ops);

However this seems to break the admin area with numerous warnings eg

Warning: include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in /Users/jonbeech/Sites/lancscps 2nd site/lancscps.dev/wp-content/themes/lancscpstheme/functions/one-in-four-widget.php on line 33

Any thoughts would be appreciated? Is it a case of my syntax being incorrect?

  • The class name within the constructor is not exposed on the front-end. You can add whatever classes you like to the widget from within the 'widget' function.
    – vancoder
    Commented May 7, 2013 at 18:55

1 Answer 1


Your problem is due to your trying to include a file over the http protocol. That kind of include is disabled on your server-- hence the message saying pretty much just that.

Use get_template_directory instead, which will give you a filesystem path.

If that does not solve it, post your code in more context. Disjointed like that, it is near impossible to test anything.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.