Skip to content

Instantly share code, notes, and snippets.

@websupporter
Last active January 20, 2017 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save websupporter/10a4dc7dc9b46fbfdc993e639e4806c5 to your computer and use it in GitHub Desktop.
Save websupporter/10a4dc7dc9b46fbfdc993e639e4806c5 to your computer and use it in GitHub Desktop.
<?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