Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
class Mein_Widget extends WP_Widget {
function __construct() {
// Instantiate the parent object
parent::__construct( 'meine-base-id', _x( 'My widget', 'theme-slug' ) );
}
function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', $instance['title'] );
echo $args['before_widget'];
if ( ! empty( $title ) ) {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
}
echo '<pre>';print_r( $instance );echo '</pre>';
echo $args['after_widget'];
}
function update( $new_instance, $old_instance ) {
// Save widget options
}
function form( $instance ) {
// Output admin widget options form
}
}
function myplugin_register_widgets() {
register_widget( 'Mein_Widget' );
}
add_action( 'widgets_init', 'myplugin_register_widgets' );
add_action( 'after_setup_theme', 'theme_start_content' );
function theme_starter_content() {
add_theme_support( 'starter-content', array(
'widgets' => array(
'sidebar-1' => array(
'text_business_info',
'search',
array(
'meine-base-id',
array(
'title' => _x( 'My own title', 'theme-slug' ),
'something' => _x( 'Everything could be here.', 'theme-slug' ),
),
)
),
),
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment