Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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 May 7 '13 at 18:55
add comment

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
that worked thanks –  Jonathan Beech May 8 '13 at 12:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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