Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <?php
  2. /**
  3. * @package LiTK WP Test Bellisia
  4. */
  5.  
  6.  
  7. // Register the widget
  8. add_action( 'widgets_init', function(){
  9. register_widget( 'litk_widget' );
  10. });
  11.  
  12. // Creating the class for the widget
  13. class litk_widget extends WP_Widget {
  14.  
  15. // Creating the constructor for the widget to register it and att an id, name and description to it
  16. function __construct() {
  17. parent::__construct(
  18. 'litk_widget',
  19. __('LiTK WP Test Bellisia', 'text_domain'),
  20. array( 'description' => __( 'A work test for front end developers', 'text_domain' ), )
  21. );
  22. }
  23.  
  24.  
  25. public function widget( $args, $instance ) {
  26.  
  27. echo $args['before_widget'];
  28. if ( ! empty( $instance['title'] ) ) {
  29. echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
  30. }
  31.  
  32. require_once( LITK__PLUGIN_DIR . 'source/php/index.php' );
  33.  
  34. echo $args['after_widget'];
  35. }
  36.  
  37.  
  38. public function form( $instance ) {
  39. if ( isset( $instance[ 'title' ] ) ) {
  40. $title = $instance[ 'title' ];
  41. }
  42. else {
  43. $title = __( 'LiTK WP Test Bellisia', 'text_domain' );
  44. }
  45.  
  46. require_once( LITK__PLUGIN_DIR . 'source/php/widget_appearance.php' );
  47. }
  48.  
  49.  
  50. public function update( $new_instance, $old_instance ) {
  51. $instance = array();
  52. $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
  53. return $instance;
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement