web_buis_adv

The Business Responsive web buis adv class.

Defined (1)

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

/admin/widgets/widget-advert.php  
  1. class web_buis_adv extends WP_Widget 
  2. function web_buis_adv() { 
  3. $widget_ops = array('description' => 'Displays Advertisements'); 
  4. $control_ops = array('width' => 400, 'height' => 500); 
  5. parent::WP_Widget(false, $name='Advertisement', $widget_ops, $control_ops); 
  6.  
  7. /** Displays the Widget in the front-end */ 
  8. function widget($args, $instance) { 
  9. extract($args); 
  10. $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? 'About Me' : esc_html( $instance['title'] ) ); 
  11. $bannerPath=json_decode ($instance['bannerPath'], true); 
  12. $bannerUrl=json_decode ($instance['bannerUrl'], true); 
  13. $bannerTitle=json_decode ($instance['bannerTitle'], true); 
  14. $bannerAlt=json_decode ($instance['bannerAlt'], true); 
  15. echo $before_widget; 
  16. if ( $title ) 
  17. echo $before_title . $title . $after_title; 
  18. ///iner widget html 
  19. if(count($bannerPath)) 
  20. foreach($bannerPath as $key => $value) { 
  21. if ($bannerPath[$key] <> '') { ?> 
  22. <?php if ($bannerTitle[$key] == '') $bannerTitle[$i] = "advertisement"; 
  23. if ($bannerAlt[$key] == '') $bannerAlt[$key] = "advertisement"; ?> 
  24. <a href="<?php echo $bannerUrl[$key] ?>" ><img src="<?php echo $bannerPath[$key]; ?>" alt="<?php echo $bannerAlt[$key]; ?>" title="<?php echo $bannerTitle[$key]; ?>" /></a> 
  25. <?php }; 
  26. echo $after_widget; 
  27.  
  28.  
  29. /**Saves the settings. */ 
  30. function update($new_instance, $old_instance) { 
  31.  
  32. $instance = $old_instance; 
  33. $instance['title'] = stripslashes($new_instance['title']); 
  34. $instance['bannerPath'] = $new_instance['bannerPath']; 
  35. $instance['bannerUrl'] = $new_instance['bannerUrl']; 
  36. $instance['bannerTitle'] = $new_instance['bannerTitle']; 
  37. $instance['bannerAlt'] = $new_instance['bannerAlt']; 
  38. return $instance; 
  39.  
  40.  
  41. /**Creates the form for the widget in the back-end. */ 
  42. function form($instance) { 
  43.  
  44. $instance = wp_parse_args( (array) $instance, array('title'=>'Advertisement', 'bannerPath'=>'', 'bannerUrl'=>'', 'bannerTitle'=>'', 'bannerAlt'=>'') ); 
  45. $title = esc_html($instance['title']); 
  46.  
  47. $bannerPath=json_decode ($instance['bannerPath'], true); 
  48. $bannerUrl=json_decode ($instance['bannerUrl'], true); 
  49. $bannerTitle=json_decode ($instance['bannerTitle'], true); 
  50. $bannerAlt=json_decode ($instance['bannerAlt'], true); 
  51. # Title 
  52.  
  53.  
  54. ?> 
  55. <script> 
  56. /// vercel imput@ split anerl @st pathi url-i titli gtnel max count@ sarqel et qanakov sarqel 
  57. if(typeof(create_inputs)!='function') { 
  58. function get_next_id(main_div) { 
  59. fildsets=jQuery(main_div).find('fieldset'); 
  60. fildsets.each(function(index, element) { 
  61. next_id=parseInt(this.id)+1; 
  62. }); 
  63. return next_id 
  64.  
  65. function get_baner_path_id(main_div) { 
  66. return jQuery(main_div).find('.curent_widget_bannerPath_id').val();  
  67. function get_baner_url_id(main_div) { 
  68. return jQuery(main_div).find('.curent_widget_bannerUrl_id').val();  
  69. function get_baner_title_id(main_div) { 
  70. return jQuery(main_div).find('.curent_widget_bannerTitle_id').val();  
  71. function get_baner_alt_id(main_div) { 
  72. return jQuery(main_div).find('.curent_widget_bannerAlt_id').val();  
  73.  
  74. function add_banner(button) { 
  75.  
  76. var main_div=button.parentNode; 
  77. var next_number=get_next_id(main_div); 
  78. var banner_path_id=get_baner_path_id(main_div); 
  79. var banner_url_id=get_baner_url_id(main_div); 
  80. var banner_title_id=get_baner_title_id(main_div); 
  81. var banner_alt_id=get_baner_alt_id(main_div); 
  82.  
  83. main_div=jQuery("#"+main_div.getAttribute('id')) 
  84.  
  85. fildset=jQuery("<fieldset></fieldset>").attr('id', next_number); 
  86.  
  87. legend=jQuery("<legend></legend>").attr('align', 'left').text('Banner '+next_number); 
  88.  
  89. Remove_div=jQuery("<div class=\"Remove_Banner\" style=\"display: block; float: right; margin-top: -30px; background-color: inherit; padding: 0 5px;\" onclick=\"remove_element(this)\"></div>").attr('class', 'Remove_Banner').text('Remove'); 
  90.  
  91. p_elem_1=jQuery("<p></p>");  
  92. label_elem_1=jQuery("<label></label>").attr("for", banner_path_id+'_'+next_number).text('Path'); 
  93. br_elem_1=jQuery("<br>"); 
  94. inpu_elem_1=jQuery("<input onchange=\"create_inputs(this)\" type=\"text\"/>").attr('id', banner_path_id+'_'+next_number).attr('class', 'widefat banner_path'); 
  95.  
  96. p_elem_2=jQuery("<p></p>");  
  97. label_elem_2=jQuery("<label></label>").attr("for", banner_url_id+'_'+next_number).text('Url'); 
  98. br_elem_2=jQuery("<br>"); 
  99. inpu_elem_2=jQuery("<input onchange=\"create_inputs(this)\" type=\"text\"/>").attr('id', banner_url_id+'_'+next_number).attr('class', 'widefat banner_url'); 
  100.  
  101.  
  102. p_elem_3=jQuery("<p></p>");  
  103. label_elem_3=jQuery("<label></label>").attr("for", banner_title_id+'_'+next_number).text('Title'); 
  104. br_elem_3=jQuery("<br>"); 
  105. inpu_elem_3=jQuery("<input onchange=\"create_inputs(this)\" type=\"text\"/>").attr('id', banner_title_id+'_'+next_number).attr('class', 'widefat banner_title'); 
  106.  
  107. p_elem_4=jQuery("<p></p>");  
  108. label_elem_4=jQuery("<label></label>").attr("for", banner_alt_id+'_'+next_number).text('Alt'); 
  109. br_elem_4=jQuery("<br>"); 
  110. inpu_elem_4=jQuery("<input onchange=\"create_inputs(this)\" type=\"text\"/>").attr('id', banner_alt_id+'_'+next_number).attr('class', 'widefat banner_alt'); 
  111.  
  112.  
  113. p_elem_1.append(label_elem_1); 
  114. p_elem_1.append(br_elem_1); 
  115. p_elem_1.append(inpu_elem_1); 
  116.  
  117. p_elem_2.append(label_elem_2); 
  118. p_elem_2.append(br_elem_2); 
  119. p_elem_2.append(inpu_elem_2); 
  120.  
  121. p_elem_3.append(label_elem_3); 
  122. p_elem_3.append(br_elem_3); 
  123. p_elem_3.append(inpu_elem_3);  
  124.  
  125. p_elem_4.append(label_elem_4); 
  126. p_elem_4.append(br_elem_4); 
  127. p_elem_4.append(inpu_elem_4); 
  128.  
  129. fildset.append(legend);  
  130. fildset.append(Remove_div); 
  131. fildset.append(p_elem_1); 
  132. fildset.append(p_elem_2); 
  133. fildset.append(p_elem_3); 
  134. fildset.append(p_elem_4); 
  135.  
  136. main_div.append(fildset); 
  137. jQuery( fildset ).after(jQuery(button ) ); 
  138.  
  139. function create_inputs(input) { 
  140. main_div=input.parentNode.parentNode.parentNode; 
  141. insert_filling_inputs(main_div);  
  142. function if_last_baner(main_div) {  
  143. if(jQuery(main_div).find('fieldset').length>1) 
  144. return false; 
  145. return true; 
  146.  
  147. function remove_element(baner) { 
  148. par_fildset=baner.parentNode; 
  149. if(!if_last_baner(par_fildset.parentNode)) 
  150. par_fildset.parentNode.removeChild(par_fildset);  
  151.  
  152. function insert_filling_inputs(main_div) { 
  153. var banner_path_id=get_baner_path_id(main_div); 
  154. var banner_url_id=get_baner_url_id(main_div); 
  155. var banner_title_id=get_baner_title_id(main_div); 
  156. var banner_alt_id=get_baner_alt_id(main_div); 
  157.  
  158. var inserted_baner_path={} 
  159. var inserted_baner_url={} 
  160. var inserted_baner_title={} 
  161. var inserted_baner_alt={} 
  162.  
  163. fildsets=jQuery(main_div).find('fieldset'); 
  164.  
  165. fildsets.each(function(index, element) { 
  166. var id_for_cur_inputs=jQuery(this).attr('id'); 
  167. jQuery(this).find('.banner_path').each(function(index, element) {  
  168. inserted_baner_path[''+id_for_cur_inputs+'']=jQuery(this).val();  
  169. }); 
  170. jQuery(this).find('.banner_url').each(function(index, element) { 
  171. inserted_baner_url[''+id_for_cur_inputs+'']=jQuery(this).val();  
  172. }); 
  173. jQuery(this).find('.banner_title').each(function(index, element) { 
  174. inserted_baner_title[''+id_for_cur_inputs+'']=jQuery(this).val();  
  175. }); 
  176. jQuery(this).find('.banner_alt').each(function(index, element) { 
  177. inserted_baner_alt[''+id_for_cur_inputs+'']=jQuery(this).val();  
  178. }); 
  179.  
  180. });  
  181.  
  182. jQuery('#'+banner_path_id).val(JSON.stringify(inserted_baner_path)); 
  183. jQuery('#'+banner_url_id).val(JSON.stringify(inserted_baner_url)); 
  184. jQuery('#'+banner_title_id).val(JSON.stringify(inserted_baner_title)); 
  185. jQuery('#'+banner_alt_id).val(JSON.stringify(inserted_baner_alt)); 
  186.  
  187.  
  188. </script> 
  189. <style> 
  190.  
  191. fieldset{ 
  192. border: 2px solid #4f9bc6 ;/*#CCA383 1462a5*/ 
  193. width: 93%; 
  194. background: #fafbfd; 
  195. padding: 13px; 
  196. margin-top: 20px;  
  197.  
  198. -webkit-border-radius: 8px; 
  199. -moz-border-radius: 8px; 
  200. border-radius: 8px; 
  201. }  
  202. .Remove_Banner{ 
  203. color:#F00; 
  204. font-weight:bold; 
  205. cursor:pointer; 
  206. }  
  207. </style> 
  208. <?php  
  209. echo '<p><label for="' . $this->get_field_id('title') . '">' . 'Title:' . '</label><input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></p>'; ?> 
  210. <div id="<?php echo $this->get_field_id('title') ?>_div"> 
  211. <?php if(count($bannerPath)) {  
  212. foreach($bannerPath as $key =>$value) { 
  213. //var_dump($bannerPath) 
  214. ?> 
  215. <fieldset id="<?php echo $key ?>"> 
  216. <legend align="left">Banner <?php echo $key ?></legend> 
  217. <div class="Remove_Banner" style="display: block; float: right; margin-top: -30px; background-color: inherit; padding: 0 5px;" onclick="remove_element(this)">Remove</div> 
  218. <p><label for="<?php echo $this->get_field_id('bannerPath') ?>_<?php echo $key ?>">Path</label><br /><input abstype='path' class="widefat banner_path" onchange="create_inputs(this)" id="<?php echo $this->get_field_id('bannerPath')?>_<?php echo $key ?>" name="<?php echo $this->get_field_name('bannerPath')?>_<?php echo $key ?>" type="text" value="<?php echo $value ?>" /> 
  219. <p><label for="<?php echo $this->get_field_id('bannerUrl') ?>_<?php echo $key ?>">Url</label><br /><input abstype='url' class="widefat banner_url" onchange="create_inputs(this)" id="<?php echo $this->get_field_id('bannerUrl')?>_<?php echo $key ?>" name="<?php echo $this->get_field_name('bannerPath')?>_<?php echo $key ?>" type="text" value="<?php echo $bannerUrl[$key]; ?>" /> 
  220. <p><label for="<?php echo $this->get_field_id('bannerTitle') ?>_<?php echo $key ?>">Title</label><br /><input abstype='title' class="widefat banner_title" onchange="create_inputs(this)" id="<?php echo $this->get_field_id('bannerTitle'); ?>_<?php echo $key ?>" name="<?php echo $this->get_field_name('bannerPath'); ?>_<?php echo $key ?>" type="text" value="<?php echo $bannerTitle[$key]; ?>" /> 
  221. <p><label for="<?php echo $this->get_field_id('bannerAlt') ?>_<?php echo $key ?>">Alt</label><br /><input abstype='alt' class="widefat banner_alt" onchange="create_inputs(this)" id="<?php echo $this->get_field_id('bannerAlt')?>_<?php echo $key ?>" name="<?php echo $this->get_field_name('bannerPath')?>_<?php echo $key ?>" type="text" value="<?php echo $bannerAlt[$key]; ?>" /> 
  222. </fieldset> 
  223.  
  224. <?php }}else {?> 
  225. <fieldset id="1"> 
  226. <legend align="left">Banner 1</legend> 
  227. <div class="Remove_Banner" style="display: block; float: right; margin-top: -30px; background-color: inherit; padding: 0 5px;" onclick="remove_element(this)">Remove</div> 
  228. <p><label for="<?php echo $this->get_field_id('bannerPath') ?>_1">Path</label><br /><input abstype='path' class="widefat banner_path" onchange="create_inputs(this)" id="<?php echo $this->get_field_id('bannerPath')?>_1" name="<?php echo $this->get_field_name('bannerPath')?>_1" type="text" value="" /> 
  229. <p><label for="<?php echo $this->get_field_id('bannerUrl') ?>_1">Url</label><br /><input abstype='url' class="widefat banner_url" onchange="create_inputs(this)" id="<?php echo $this->get_field_id('bannerUrl')?>_1" name="<?php echo $this->get_field_name('bannerPath')?>_1" type="text" value="" /> 
  230. <p><label for="<?php echo $this->get_field_id('bannerTitle') ?>_1">Title</label><br /><input abstype='title' class="widefat banner_title" onchange="create_inputs(this)" id="<?php echo $this->get_field_id('bannerTitle'); ?>_1" name="<?php echo $this->get_field_name('bannerPath'); ?>_1" type="text" value="" /> 
  231. <p><label for="<?php echo $this->get_field_id('bannerAlt') ?>_1">Alt</label><br /><input abstype='alt' class="widefat banner_alt" onchange="create_inputs(this)" id="<?php echo $this->get_field_id('bannerAlt')?>_1" name="<?php echo $this->get_field_name('bannerPath')?>_1" type="text" value="" /> 
  232. </fieldset> 
  233. <?php } ?> 
  234. <input type="button" onclick="add_banner(this)" value="Add Banner" /> 
  235. <input type="hidden" value="<?php echo $this->get_field_id('bannerPath') ?>" class="curent_widget_bannerPath_id" /> 
  236. <input type="hidden" value="<?php echo $this->get_field_id('bannerUrl') ?>" class="curent_widget_bannerUrl_id" /> 
  237. <input type="hidden" value="<?php echo $this->get_field_id('bannerTitle') ?>" class="curent_widget_bannerTitle_id" /> 
  238. <input type="hidden" value="<?php echo $this->get_field_id('bannerAlt') ?>" class="curent_widget_bannerAlt_id" /> 
  239. </div> 
  240. <?php  
  241. echo '<input class="widefat" id="' . $this->get_field_id('bannerPath') . '" name="' . $this->get_field_name('bannerPath') . '" type="hidden" value=\'' .$instance['bannerPath'] . '\' />'; 
  242. echo '<input class="widefat" id="' . $this->get_field_id('bannerUrl') . '" name="' . $this->get_field_name('bannerUrl') . '" type="hidden" value=\'' . ($instance['bannerUrl']) . '\' />'; 
  243. echo '<input class="widefat" id="' . $this->get_field_id('bannerTitle') . '" name="' . $this->get_field_name('bannerTitle') . '" type="hidden" value=\'' . ($instance['bannerTitle']) . '\' />'; 
  244. echo '<input class="widefat" id="' . $this->get_field_id('bannerAlt') . '" name="' . $this->get_field_name('bannerAlt') . '" type="hidden" value=\'' .( $instance['bannerAlt']) . '\' />'; 
  245.  
  246. }// end web_buis_adv class