PageRenderTime 30ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/integral/inc/widgets/our_team_widget.php

https://gitlab.com/omarsallah00/ingensrl
PHP | 179 lines | 130 code | 10 blank | 39 comment | 12 complexity | 5adeef769599244a4324726a6016b664 MD5 | raw file
  1. <?php
  2. /**
  3. * new WordPress Widget format
  4. * Wordpress 2.8 and above
  5. * @see http://codex.wordpress.org/Widgets_API#Developing_Widgets
  6. */
  7. class Integral_Our_Team_Widget extends WP_Widget {
  8. /**
  9. * Constructor
  10. *
  11. * @return void
  12. **/
  13. function __construct() {
  14. $widget_ops = array( 'classname' => 'wcp_image', 'description' => 'Add a team member to the homepage Our Team section.' );
  15. parent::__construct( 'Integral_our_team', 'Integral - Team Member Widget', $widget_ops );
  16. //setup default widget data
  17. $this->defaults = array(
  18. 'title' => '',
  19. 'image_url' => '',
  20. 'textarea' => '',
  21. 'position' => '',
  22. 'facebook' => '',
  23. 'twitter' => '',
  24. 'google' => '',
  25. 'github' => '',
  26. 'behance' => '',
  27. 'linkedin' => '',
  28. 'instagram' => '',
  29. );
  30. }
  31. /**
  32. * Outputs the HTML for this widget.
  33. *
  34. * @param array An array of standard parameters for widgets in this theme
  35. * @param array An array of settings for this widget instance
  36. * @return void Echoes it's output
  37. **/
  38. function widget( $args, $instance ) {
  39. wp_reset_query();
  40. extract( $args, EXTR_SKIP );
  41. // these are the widget options
  42. $title = apply_filters('widget_title', $instance['title']);
  43. $image_url = $instance['image_url'];
  44. $textarea = apply_filters( 'widget_textarea', empty( $instance['textarea'] ) ? '' : $instance['textarea'], $instance );
  45. $position = $instance['position'];
  46. $facebook = $instance['facebook'];
  47. $twitter = $instance['twitter'];
  48. $google = $instance['google'];
  49. $github = $instance['github'];
  50. $behance = $instance['behance'];
  51. $linkedin = $instance['linkedin'];
  52. $instagram = $instance['instagram'];
  53. echo $before_widget;
  54. // Display the widget
  55. echo '';
  56. if( $image_url) {
  57. echo '<img src="'.$image_url.'" alt="'.$title.'" class="img-circle img-responsive center-block">';
  58. }
  59. // Check if title is set
  60. if ( $title ) {
  61. echo $before_title . $title . $after_title;
  62. }
  63. echo '<div class="t-type">'.$position.'</div>';
  64. echo '<ul class="socials">';
  65. if ($facebook) { echo '<li><a href="'.$facebook.'"><i class="fa fa-facebook fa-lg"></i></a></li>';}
  66. if ($twitter) { echo '<li><a href="'.$twitter.'"><i class="fa fa-twitter fa-lg"></i></a></li>';}
  67. if ($google) { echo '<li><a href="'.$google.'"><i class="fa fa-google-plus fa-lg"></i></a></li>';}
  68. if ($github) { echo '<li><a href="'.$github.'"><i class="fa fa-github fa-lg"></i></a></li>';}
  69. if ($behance) { echo '<li><a href="'.$behance.'"><i class="fa fa-behance fa-lg"></i></a></li>';}
  70. if ($linkedin) { echo '<li><a href="'.$linkedin.'"><i class="fa fa-linkedin fa-lg"></i></a></li>';}
  71. if ($instagram) { echo '<li><a href="'.$instagram.'"><i class="fa fa-instagram fa-lg"></i></a></li>';}
  72. echo '</ul>';
  73. // Check if textarea is set
  74. if( $textarea ) { echo '' . wpautop($textarea) . ''; }
  75. echo '';
  76. echo $after_widget;
  77. }
  78. /**
  79. * Deals with the settings when they are saved by the admin. Here is
  80. * where any validation should be dealt with.
  81. *
  82. * @param array An array of new settings as submitted by the admin
  83. * @param array An array of the previous settings
  84. * @return array The validated and (if necessary) amended settings
  85. **/
  86. function update( $new_instance, $old_instance ) {
  87. // update logic goes here
  88. $instance = $old_instance;
  89. // Fields
  90. $instance['title'] = strip_tags($new_instance['title']);
  91. $instance['image_url'] = strip_tags($new_instance['image_url']);
  92. $instance['position'] = strip_tags($new_instance['position']);
  93. if ( current_user_can('unfiltered_html') )
  94. $instance['textarea'] = $new_instance['textarea'];
  95. else $instance['textarea'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['textarea']) ) );
  96. $instance['facebook'] = strip_tags($new_instance['facebook']);
  97. $instance['twitter'] = strip_tags($new_instance['twitter']);
  98. $instance['google'] = strip_tags($new_instance['google']);
  99. $instance['github'] = strip_tags($new_instance['github']);
  100. $instance['behance'] = strip_tags($new_instance['behance']);
  101. $instance['linkedin'] = strip_tags($new_instance['linkedin']);
  102. $instance['instagram'] = strip_tags($new_instance['instagram']);
  103. return $instance;
  104. }
  105. /**
  106. * Displays the form for this widget on the Widgets page of the WP Admin area.
  107. *
  108. * @param array An array of the current settings for this widget
  109. * @return void Echoes it's output
  110. **/
  111. function form( $instance ) {
  112. $instance = wp_parse_args( (array) $instance, $this->defaults );
  113. ?>
  114. <p>
  115. <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Name', 'integral'); ?></label>
  116. <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" />
  117. </p>
  118. <p>
  119. <label for="<?php echo $this->get_field_id('image_url'); ?>"><?php _e('Profile Image', 'integral'); ?></label>
  120. <input id="<?php echo $this->get_field_id('image_url'); ?>" type="text" class="image-url" name="<?php echo $this->get_field_name('image_url'); ?>" value="<?php echo $instance['image_url']; ?>" style="width: 100%;" />
  121. <input data-title="Image in Widget" data-btntext="Select it" class="button upload_image_button" type="button" value="<?php _e('Upload','integral') ?>" />
  122. <input data-title="Image in Widget" data-btntext="Select it" class="button clear_image_button" type="button" value="<?php _e('Clear','integral') ?>" />
  123. </p>
  124. <p class="img-prev">
  125. <img src="<?php echo $instance['image_url']; ?>" style="max-width: 100%;">
  126. </p>
  127. <p>
  128. <label for="<?php echo $this->get_field_id('position'); ?>"><?php _e('Position', 'integral'); ?></label>
  129. <input class="widefat" id="<?php echo $this->get_field_id('position'); ?>" name="<?php echo $this->get_field_name('position'); ?>" type="text" value="<?php echo $instance['position']; ?>" />
  130. </p>
  131. <p>
  132. <label for="<?php echo $this->get_field_id('textarea'); ?>"><?php _e('Short Bio', 'integral'); ?></label>
  133. <textarea class="widefat" rows="5" id="<?php echo $this->get_field_id('textarea'); ?>" name="<?php echo $this->get_field_name('textarea'); ?>"><?php echo $instance['textarea']; ?></textarea>
  134. <small><?php _e('No limit on the amount of text and HTML is allowed.', 'integral'); ?></small>
  135. </p>
  136. <p>
  137. <label for="<?php echo $this->get_field_id('facebook'); ?>"><?php _e('Facebook URL', 'integral'); ?></label>
  138. <input class="widefat" id="<?php echo $this->get_field_id('facebook'); ?>" name="<?php echo $this->get_field_name('facebook'); ?>" type="text" value="<?php echo $instance['facebook']; ?>" />
  139. </p>
  140. <p>
  141. <label for="<?php echo $this->get_field_id('twitter'); ?>"><?php _e('Twitter URL', 'integral'); ?></label>
  142. <input class="widefat" id="<?php echo $this->get_field_id('twitter'); ?>" name="<?php echo $this->get_field_name('twitter'); ?>" type="text" value="<?php echo $instance['twitter']; ?>" />
  143. </p>
  144. <p>
  145. <label for="<?php echo $this->get_field_id('google'); ?>"><?php _e('Google+ URL', 'integral'); ?></label>
  146. <input class="widefat" id="<?php echo $this->get_field_id('google'); ?>" name="<?php echo $this->get_field_name('google'); ?>" type="text" value="<?php echo $instance['google']; ?>" />
  147. </p>
  148. <p>
  149. <label for="<?php echo $this->get_field_id('github'); ?>"><?php _e('Github URL', 'integral'); ?></label>
  150. <input class="widefat" id="<?php echo $this->get_field_id('github'); ?>" name="<?php echo $this->get_field_name('github'); ?>" type="text" value="<?php echo $instance['github']; ?>" />
  151. </p>
  152. <p>
  153. <label for="<?php echo $this->get_field_id('behance'); ?>"><?php _e('Behance URL', 'integral'); ?></label>
  154. <input class="widefat" id="<?php echo $this->get_field_id('behance'); ?>" name="<?php echo $this->get_field_name('behance'); ?>" type="text" value="<?php echo $instance['behance']; ?>" />
  155. </p>
  156. <p>
  157. <label for="<?php echo $this->get_field_id('linkedin'); ?>"><?php _e('Linkedin URL', 'integral'); ?></label>
  158. <input class="widefat" id="<?php echo $this->get_field_id('linkedin'); ?>" name="<?php echo $this->get_field_name('linkedin'); ?>" type="text" value="<?php echo $instance['linkedin']; ?>" />
  159. </p>
  160. <p>
  161. <label for="<?php echo $this->get_field_id('instagram'); ?>"><?php _e('Instagram URL', 'integral'); ?></label>
  162. <input class="widefat" id="<?php echo $this->get_field_id('instagram'); ?>" name="<?php echo $this->get_field_name('instagram'); ?>" type="text" value="<?php echo $instance['instagram']; ?>" />
  163. </p>
  164. <?php
  165. }
  166. }
  167. // End of Plugin Class
  168. add_action( 'widgets_init', create_function( '', "register_widget( 'Integral_Our_Team_Widget' );" ) );
  169. ?>