Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @param array $form_options
- * @param type $widget
- * @return array
- */
- function ls_extend_sow_slider_form_add_hide_frame($form_options, $widget) {
- $form_options['frames']['fields']['hide_frame'] = array('type' => 'checkbox',
- 'label' => __('Hide this frame', 'so-widgets-bundle'),
- 'default' => false,);
- return $form_options;
- }
- add_filter('siteorigin_widgets_form_options_sow-slider', 'ls_extend_sow_slider_form_add_hide_frame', 10, 2);
- /**
- *
- * @param type $instance
- * @param type $args
- * @return array
- */
- function ls_slider_hide_the_hidden_frame($instance, $args) {
- $frames = empty($instance['frames']) ? array() : $instance['frames'];
- if (!empty($frames)) {
- foreach ($frames as $i => $frame) {
- if ($frame['hide_frame']) {
- unset($frames[$i]);
- }
- }
- $frames=array_values($frames);
- foreach ($frames as &$frame) {
- $link_atts = array();
- if (!empty($frame['new_window'])) {
- $link_atts['target'] = '_blank';
- $link_atts['rel'] = 'noopener noreferrer';
- }
- $frame['link_attributes'] = $link_atts;
- }
- }
- return array(
- 'controls' => $instance['controls'],
- 'frames' => $frames,
- );
- }
- add_filter('siteorigin_widgets_template_variables_sow-slider', 'ls_slider_hide_the_hidden_frame', 10, 2);
Add Comment
Please, Sign In to add comment