Saving widget gets an undefined variable

I am willing to be that since you have not initialized the widgets pool it cannot be duplicated. So within your main class or plugin file you would add this: For Class: add_action ( ‘widgets_init’, array ( &$this, ‘my_widgets’ ) ); For .php file add_action ( ‘widgets_init’, ‘my_widgets’); then create your function public function my_widgets(){ … Read more

How to test if the widgetized area has any widgets?

I would use the is_active_sidebar() conditional: <?php if ( is_active_sidebar( ‘footer’ ) ) { ?> <div id=”sidebar-footer”> <?php dynamic_sidebar( ‘footer’ ); ?> </div> <?php } ?> That way, you can conditionally output the styled container itself.

Widget where it can make changes to the container

I would not recommend that. Much easier to use a clearfix hack to force clearing and just add that style to your widget. Clearfix hacks are transparent: it doesn’t matter if they happen on all elements there is no visible difference, other than clear floats. Somewhere in your themes style.css: .widget:before, .widget:after { content: ” … Read more

How to add Ajax to the default widget calendar to support next/previous months loading?

Interesting task indeed. Here’s what I would do: Create my own plugin with a widget. You can always use plugin boilerplate or widget boilerplate as starting points. My widget would look like the default calendar, except it would also have the ‘prev”https://wordpress.stackexchange.com/”next’ links, as you mentioned. I would then copy-paste and adjust the get_calendar() function … Read more

accessing wordpress serialized data outside wp

Use PHP’s unserialize function: <?php $data=”a:2:{i:0;s:12:”Sample array”;i:1;a:2:{i:0;s:5:”Apple”;i:1;s:6:”Orange”;}}”; $unserialized = unserialize($data); echo ‘<pre>’; print_r($unserialized); echo ‘</pre>’; ?> Result: Array ( [0] => Sample array [1] => Array ( [0] => Apple [1] => Orange ) ) Got the sample data over at unserialize.com, a handy little site if you want to quickly check what’s inside that … Read more

Add a select-option to the default widgets

The default widgets do not offer any hooks for that. You have to replace the default widget and add your field to the new class. The other option would be using JavaScript to insert the field, and a filter for ‘update_option_widget_’ . $widget->id_base to save the value. I think the separate class is the cleaner … Read more

Creating a dynamic class name in my custom widget

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 … Read more

Widget to show posts in the sidebar basing on its IDs

Try to replace ‘post__in’ => array($instance[‘postsToShow’]), with ‘post__in’ => explode(“,”, $instance[‘postsToShow’]), to feed the post__in with an array. Your current array looks like array(“123,456,789”) but should be like array(“123”, “456”, “789”)