WPDK  1.5.0
WordPress Development Kit
 All Data Structures Files Functions Variables Pages
wpdk-widget.php
Go to the documentation of this file.
1 <?php
13 class WPDKWidget extends WP_Widget {
14 
34  public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() )
35  {
36  $this->id_base = $id_base;
37 
38  /* Load scripts and styles for admin page */
39  add_action( 'widgets_admin_page', array( $this, 'willWidgetsAdminPage') );
40 
41  /* Load scripts and styles for admin page */
42  add_action( 'admin_print_styles-widgets.php', array( $this, 'admin_print_styles' ) );
43 
44  /* Create the widget */
45  parent::__construct( $id_base, $name, $widget_options, $control_options );
46  }
47 
53  public function admin_print_styles( )
54  {
55  $logo = isset( $this->control_options['wpdk_icon'] ) ? $this->control_options['wpdk_icon'] : '';
56  $version = isset( $this->control_options['wpdk_version'] ) ? $this->control_options['wpdk_version'] : '';
57 
58  /* If no wpdk extends info set exit. */
59  if ( empty( $logo ) && empty( $version ) ) {
60  return;
61  }
62 
64  ?>
65  <style id="wpdk-inline-styles-<?php echo $this->id_base ?>" type="text/css">
66  <?php if( !empty( $logo ) ) : ?>
67  div[id*=<?php echo $this->id_base ?>] .widget-title h4
68  {
69  padding-left : 28px;
70  line-height : 150%;
71  background-image : url(<?php echo $logo ?>) !important;
72  background-repeat : no-repeat;
73  background-position : 6px center;
74  }
75  <?php endif ?>
76 
77  <?php if( !empty( $logo ) ) : ?>
78  div[id*=<?php echo $this->id_base ?>] .widget-title h4 span.in-widget-title:before
79  {
80  content : ' <?php echo $version ?>';
81  }
82  <?php endif ?>
83  </style>
84  <?php
86  $this->willWidgetsHeadAdminPage();
87  }
88 
94  public function willWidgetsHeadAdminPage()
95  {
96  /* You can override this delegate method */
97  }
98 
104  public function willWidgetsAdminPage()
105  {
106  /* You can override this delegate method */
107  }
108 
109 }