/wp-content/themes/Avada/includes/class-fusion-widget-ad-125-125.php

https://gitlab.com/webkod3r/tripolis · PHP · 110 lines · 90 code · 19 blank · 1 comment · 2 complexity · ebe197917a78bb72ff37eecbcf916b92 MD5 · raw file

  1. <?php
  2. class Fusion_Widget_Ad_125_125 extends WP_Widget {
  3. function __construct() {
  4. $widget_ops = array('classname' => 'ad_125_125', 'description' => 'Add 125x125 ads.');
  5. $control_ops = array('id_base' => 'ad_125_125-widget');
  6. parent::__construct('ad_125_125-widget', 'Avada: 125x125 Ads', $widget_ops, $control_ops);
  7. }
  8. function widget( $args, $instance ) {
  9. extract( $args );
  10. ?>
  11. <div class="img-row">
  12. <?php $ads = array( 1, 2, 3, 4 ); ?>
  13. <?php foreach( $ads as $ad_count ) : ?>
  14. <?php if ( $instance['ad_125_img_' . $ad_count] && $instance['ad_125_link_' . $ad_count] ) : ?>
  15. <div class="img-holder">
  16. <span class="hold">
  17. <a href="<?php echo $instance['ad_125_link_' . $ad_count]; ?>">
  18. <img src="<?php echo $instance['ad_125_img_' . $ad_count]; ?>" alt="" width="123" height="123" />
  19. </a>
  20. </span>
  21. </div>
  22. <?php endif; ?>
  23. <?php endforeach; ?>
  24. </div>
  25. <?php
  26. }
  27. function update( $new_instance, $old_instance ) {
  28. $instance = $old_instance;
  29. $instance['ad_125_img_1'] = $new_instance['ad_125_img_1'];
  30. $instance['ad_125_link_1'] = $new_instance['ad_125_link_1'];
  31. $instance['ad_125_img_2'] = $new_instance['ad_125_img_2'];
  32. $instance['ad_125_link_2'] = $new_instance['ad_125_link_2'];
  33. $instance['ad_125_img_3'] = $new_instance['ad_125_img_3'];
  34. $instance['ad_125_link_3'] = $new_instance['ad_125_link_3'];
  35. $instance['ad_125_img_4'] = $new_instance['ad_125_img_4'];
  36. $instance['ad_125_link_4'] = $new_instance['ad_125_link_4'];
  37. return $instance;
  38. }
  39. function form( $instance ) {
  40. $defaults = array(
  41. 'ad_125_img_1' => '',
  42. 'ad_125_link_1' => '',
  43. 'ad_125_img_2' => '',
  44. 'ad_125_link_2' => '',
  45. 'ad_125_img_3' => '',
  46. 'ad_125_link_3' => '',
  47. 'ad_125_img_4' => '',
  48. 'ad_125_link_4' => ''
  49. );
  50. $instance = wp_parse_args( (array) $instance, $defaults );
  51. ?>
  52. <p><strong><?php printf( __( 'Ad %s', 'Avada' ), '1' ); ?></strong></p>
  53. <p>
  54. <label for="<?php echo $this->get_field_id( 'ad_125_img_1' ); ?>"><?php _e( 'Image Ad Link:', 'Avada' ); ?></label>
  55. <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'ad_125_img_1' ); ?>" name="<?php echo $this->get_field_name( 'ad_125_img_1' ); ?>" value="<?php echo $instance['ad_125_img_1']; ?>" />
  56. </p>
  57. <p>
  58. <label for="<?php echo $this->get_field_id( 'ad_125_link_1' ); ?>"><?php _e( 'Ad Link:', 'Avada' ); ?></label>
  59. <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'ad_125_link_1' ); ?>" name="<?php echo $this->get_field_name( 'ad_125_link_1' ); ?>" value="<?php echo $instance['ad_125_link_1']; ?>" />
  60. </p>
  61. <p><strong><?php printf( __( 'Ad %s', 'Avada' ), '2' ); ?></strong></p>
  62. <p>
  63. <label for="<?php echo $this->get_field_id( 'ad_125_img_2' ); ?>"><?php _e( 'Image Ad Link:', 'Avada' ); ?></label>
  64. <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'ad_125_img_2' ); ?>" name="<?php echo $this->get_field_name( 'ad_125_img_2' ); ?>" value="<?php echo $instance['ad_125_img_2']; ?>" />
  65. </p>
  66. <p>
  67. <label for="<?php echo $this->get_field_id( 'ad_125_link_2' ); ?>"><?php _e( 'Ad Link:', 'Avada' ); ?></label>
  68. <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'ad_125_link_2' ); ?>" name="<?php echo $this->get_field_name( 'ad_125_link_2' ); ?>" value="<?php echo $instance['ad_125_link_2']; ?>" />
  69. </p>
  70. <p><strong><?php printf( __( 'Ad %s', 'Avada' ), '3' ); ?></strong></p>
  71. <p>
  72. <label for="<?php echo $this->get_field_id( 'ad_125_img_3' ); ?>"><?php _e( 'Image Ad Link:', 'Avada' ); ?></label>
  73. <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'ad_125_img_3' ); ?>" name="<?php echo $this->get_field_name( 'ad_125_img_3' ); ?>" value="<?php echo $instance['ad_125_img_3']; ?>" />
  74. </p>
  75. <p>
  76. <label for="<?php echo $this->get_field_id( 'ad_125_link_3' ); ?>"><?php _e( 'Ad Link:', 'Avada' ); ?></label>
  77. <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'ad_125_link_3' ); ?>" name="<?php echo $this->get_field_name( 'ad_125_link_3' ); ?>" value="<?php echo $instance['ad_125_link_3']; ?>" />
  78. </p>
  79. <p><strong><?php printf( __( 'Ad %s', 'Avada' ), '4' ); ?></strong></p>
  80. <p>
  81. <label for="<?php echo $this->get_field_id( 'ad_125_img_4' ); ?>"><?php _e( 'Image Ad Link:', 'Avada' ); ?></label>
  82. <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'ad_125_img_4' ); ?>" name="<?php echo $this->get_field_name( 'ad_125_img_4' ); ?>" value="<?php echo $instance['ad_125_img_4']; ?>" />
  83. </p>
  84. <p>
  85. <label for="<?php echo $this->get_field_id( 'ad_125_link_4' ); ?>"><?php _e( 'Ad Link:', 'Avada' ); ?></label>
  86. <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'ad_125_link_4' ); ?>" name="<?php echo $this->get_field_name( 'ad_125_link_4' ); ?>" value="<?php echo $instance['ad_125_link_4']; ?>" />
  87. </p>
  88. <?php
  89. }
  90. }
  91. // Omit closing PHP tag to avoid "Headers already sent" issues.