Last active
January 20, 2017 15:05
-
-
Save websupporter/10a4dc7dc9b46fbfdc993e639e4806c5 to your computer and use it in GitHub Desktop.
For my blogpost http://websupporter.net/blog/de/starter-content-fuer-themes/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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