Guest User

Untitled

a guest
Mar 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. *
  5. * @param array $form_options
  6. * @param type $widget
  7. * @return array
  8. */
  9. function ls_extend_sow_slider_form_add_hide_frame($form_options, $widget) {
  10. $form_options['frames']['fields']['hide_frame'] = array('type' => 'checkbox',
  11. 'label' => __('Hide this frame', 'so-widgets-bundle'),
  12. 'default' => false,);
  13. return $form_options;
  14. }
  15.  
  16. add_filter('siteorigin_widgets_form_options_sow-slider', 'ls_extend_sow_slider_form_add_hide_frame', 10, 2);
  17.  
  18. /**
  19. *
  20. * @param type $instance
  21. * @param type $args
  22. * @return array
  23. */
  24. function ls_slider_hide_the_hidden_frame($instance, $args) {
  25. $frames = empty($instance['frames']) ? array() : $instance['frames'];
  26. if (!empty($frames)) {
  27. foreach ($frames as $i => $frame) {
  28. if ($frame['hide_frame']) {
  29. unset($frames[$i]);
  30. }
  31. }
  32. $frames=array_values($frames);
  33.  
  34. foreach ($frames as &$frame) {
  35. $link_atts = array();
  36. if (!empty($frame['new_window'])) {
  37. $link_atts['target'] = '_blank';
  38. $link_atts['rel'] = 'noopener noreferrer';
  39. }
  40. $frame['link_attributes'] = $link_atts;
  41. }
  42. }
  43.  
  44. return array(
  45. 'controls' => $instance['controls'],
  46. 'frames' => $frames,
  47. );
  48. }
  49.  
  50. add_filter('siteorigin_widgets_template_variables_sow-slider', 'ls_slider_hide_the_hidden_frame', 10, 2);
Add Comment
Please, Sign In to add comment