Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @package LiTK WP Test Bellisia
- */
- // Register the widget
- add_action( 'widgets_init', function(){
- register_widget( 'litk_widget' );
- });
- // Creating the class for the widget
- class litk_widget extends WP_Widget {
- // Creating the constructor for the widget to register it and att an id, name and description to it
- function __construct() {
- parent::__construct(
- 'litk_widget',
- __('LiTK WP Test Bellisia', 'text_domain'),
- array( 'description' => __( 'A work test for front end developers', 'text_domain' ), )
- );
- }
- public function widget( $args, $instance ) {
- echo $args['before_widget'];
- if ( ! empty( $instance['title'] ) ) {
- echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
- }
- require_once( LITK__PLUGIN_DIR . 'source/php/index.php' );
- echo $args['after_widget'];
- }
- public function form( $instance ) {
- if ( isset( $instance[ 'title' ] ) ) {
- $title = $instance[ 'title' ];
- }
- else {
- $title = __( 'LiTK WP Test Bellisia', 'text_domain' );
- }
- require_once( LITK__PLUGIN_DIR . 'source/php/widget_appearance.php' );
- }
- public function update( $new_instance, $old_instance ) {
- $instance = array();
- $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
- return $instance;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement