jeudi 1 janvier 2015

Widgets won't save


I have almost no experience in creating widget area's and I am stuck at saving the widgets in the widget area 'red menu'. I have searched a dozen posts but I can't seem to get it working.


I am currently working in Wordpress 4.0.1 and this is the code I have:


Widgets.php:



class Red_Menu_Widget extends WP_Widget {
function redmenu_widget( $args, $instance ) {
$widget_ops = array(
'classname' => 'redmenu_widget',
'description' => __('Description in here')
$control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'redmenu_widget' );

$this->WP_Widget( 'redmenu_widget', __('Rood menu rechts', 'redmenu_widget'), $widget_ops, $control_ops );
);
//parent::WP_Widget(false, 'Rood menu (rechts)', $widget_ops );
}
function widget() {
$title = 'Rood menu (rechts)';

echo $before_widget;
echo $title;
echo '<p>This is my widget output</p>';
echo $after_widget;
}
}
add_action( 'widgets_init', 'prefix_register_widgets' );
function prefix_register_widgets() {
register_widget( 'redmenu_widget' );
}


Functions.php:



function pfp_widgets_init() {

register_sidebar( array (
'name' => __( 'Rood menu (rechts)', 'powerforpaws' ),
'id' => 'redmenu_widget',
'description' => __( 'Descriptionhere', 'powerforpaws' ),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => "</li>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
} // end pfp_widgets_init

add_action( 'widgets_init', 'pfp_widgets_init' );

// Pre-set Widgets
$preset_widgets = array (
'redmenu_widget' => array( 'search', 'pages', 'categories', 'archives' )
);

if ( !isset( $_GET['activated'] ) ) {
update_option( 'sidebars_widgets', $preset_widgets );
}


Sidebar.php:



<aside id="widgets">
<?php if ( !function_exists('redmenu_widget') || !dynamic_sidebar('redmenu_widget') ) : ?>
<div id="primary" class="widget-area">
<ul class="xoxo">
<?php dynamic_sidebar('redmenu_widget'); ?>
</ul>
</div><!-- #primary .widget-area -->
<?php endif; ?>
</aside>


What am I doing wrong?


Thanks in advance!





Aucun commentaire:

Enregistrer un commentaire