SZGoogleWidgetPlusFollowers

The SZ - Google SZGoogleWidgetPlusFollowers class.

Defined (1)

The class is defined in the following location(s).

/classes/widget/SZGoogleWidgetPlusFollowers.php  
  1. class SZGoogleWidgetPlusFollowers extends SZGoogleWidget  
  2. /** 
  3. * Definition the constructor function, which is called 
  4. * at the time of the creation of an instance of this class 
  5. */ 
  6.  
  7. function __construct()  
  8. parent::__construct('SZ-Google-Followers', __('SZ-Google - G+ Followers', 'szgoogleadmin'), array( 
  9. 'classname' => 'sz-widget-google sz-widget-google-plus sz-widget-google-plus-followers',  
  10. 'description' => ucfirst(__('google+ followers.', 'szgoogleadmin')) 
  11. )); 
  12.  
  13. /** 
  14. * Generation of the HTML code of the widget 
  15. * for the full display in the sidebar associated 
  16. */ 
  17.  
  18. function widget($args, $instance)  
  19. // Checking whether there are the variables that are used during the processing 
  20. // the script and check the default values **in case they were not specified 
  21.  
  22. $options = $this->common_empty(array( 
  23. 'id' => '', // default value 
  24. 'width' => '', // default value 
  25. 'height' => '', // default value 
  26. 'align' => '', // default value 
  27. ), $instance); 
  28.  
  29. // Definition of the control variables of the widget, these values* 
  30. // do not affect the items of basic but affect some aspects 
  31.  
  32. $controls = $this->common_empty(array( 
  33. 'method' => '1', // default value 
  34. 'specific' => '', // default value 
  35. 'width_auto' => '', // default value 
  36. 'height_auto' => '', // default value 
  37. ), $instance); 
  38.  
  39. // Correction of the value of size is specified in 
  40. // the case the automatically and then use javascript 
  41.  
  42. if ($controls['method'] != '1') $options['id'] = $controls['specific'];  
  43. if ($controls['method'] == '1') $options['id'] = '';  
  44. if ($controls['width_auto'] == '1') $options['width'] = 'auto'; 
  45. if ($controls['height_auto'] == '1') $options['height'] = 'auto'; 
  46.  
  47. // Create the HTML code for the current widget recalling the basic 
  48. // function which is also invoked by the corresponding shortcode 
  49.  
  50. if ($object = SZGoogleModule::getObject('SZGoogleModulePlus')) { 
  51. $HTML = $object->getPlusFollowersShortcode($options); 
  52.  
  53. // Output HTML code linked to the widget to 
  54. // display call to the general standard for wrap 
  55.  
  56. echo $this->common_widget($args, $instance, $HTML); 
  57.  
  58. /** 
  59. * Changing parameters related to the widget FORM  
  60. * with storing the values **directly in the database 
  61. */ 
  62.  
  63. function update($new_instance, $old_instance)  
  64. // Performing additional operations on fields of the 
  65. // form widget before it is stored in the database 
  66.  
  67. return $this->common_update(array( 
  68. 'title' => '0', // strip_tags 
  69. 'method' => '1', // strip_tags 
  70. 'specific' => '1', // strip_tags 
  71. 'width' => '1', // strip_tags 
  72. 'width_auto' => '1', // strip_tags 
  73. 'height' => '1', // strip_tags 
  74. 'height_auto' => '1', // strip_tags 
  75. 'align' => '1', // strip_tags 
  76. ), $new_instance, $old_instance); 
  77.  
  78. /** 
  79. * FORM display the widget in the management of  
  80. * sidebar in the administration panel of wordpress 
  81. */ 
  82.  
  83. function form($instance)  
  84. // Creating arrays for list fields that must be 
  85. // present in the form before calling wp_parse_args() 
  86.  
  87. $array = array( 
  88. 'title' => '', // default value 
  89. 'method' => '', // default value 
  90. 'specific' => '', // default value 
  91. 'width' => '', // default value 
  92. 'width_auto' => '', // default value 
  93. 'height' => '', // default value 
  94. 'height_auto' => '', // default value 
  95. 'align' => '', // default value 
  96. ); 
  97.  
  98. // Creating arrays for list of fields to be retrieved FORM 
  99. // and loading the file with the HTML template to display 
  100.  
  101. extract(wp_parse_args($instance, $array), EXTR_OVERWRITE); 
  102.  
  103. // Reading of the options for the control of default values 
  104. // be assigned to the widget when it is placed in the sidebar 
  105.  
  106. if ($object = SZGoogleModule::getObject('SZGoogleModulePlus'))  
  107. $options = (object) $object->getOptions(); 
  108.  
  109. if (!ctype_digit($width) and $width != 'auto') { 
  110. $width = $options->plus_widget_size_landscape; 
  111.  
  112. // Setting any of the default parameters for the 
  113. // fields that contain invalid values **or inconsistent 
  114.  
  115. $DEFAULT = include(dirname(SZ_PLUGIN_GOOGLE_MAIN)."/options/sz_google_options_plus.php"); 
  116.  
  117. if (!ctype_digit($method) or $method == 0) { $method = '1'; } 
  118.  
  119. if (!ctype_digit($width) or $width == 0) {  
  120. $width = $DEFAULT['plus_widget_size_landscape']['value'];  
  121. $width_auto = '1'; 
  122.  
  123. if (!ctype_digit($height) or $height == 0) { $height = 'auto'; $height_auto = '1'; } 
  124. if (!ctype_digit($height) and $height != 'auto') $height = 'auto'; 
  125.  
  126. // Calling the template for displaying the part  
  127. // that concerns the administration panel (admin) 
  128.  
  129. @include(dirname(SZ_PLUGIN_GOOGLE_MAIN).'/admin/widgets/SZGoogleWidget.php'); 
  130. @include(dirname(SZ_PLUGIN_GOOGLE_MAIN).'/admin/widgets/' .__CLASS__.'.php');