/** * Callback-function for [row], [row_inner] shortcode. */ public function row($atts = null, $content = null) { $original_atts = $atts; $atts = shortcode_atts(array('type' => 'full-width', 'bg_type' => 'none', 'anchor' => '', 'class' => '', 'preset' => '', 'bg_color' => '', 'bg_image' => '', 'bg_position' => 'center', 'bg_repeat' => 'no-repeat', 'bg_attachment' => 'scroll', 'bg_size' => 'auto', 'speed' => '1.5', 'invert' => 'no', 'min_height' => '300', 'poster' => '', 'mp4' => '', 'webm' => '', 'ogv' => ''), $atts, 'row'); $type = sanitize_key($atts['type']); $bg_type = sanitize_key($atts['bg_type']); $class = 'fixed-width' == $type ? '' : cherry_esc_class_attr($atts); $anchor_data = ''; $row_class = apply_filters('cherry_shortcodes_output_row_class', 'row', $atts); $output = false; $id = ''; $anchor_data = ''; if ($atts['anchor']) { $anchor = preg_replace('/[^A-Za-z0-9-_]/', '', $atts['anchor']); $anchor = str_replace(' ', '-', $anchor); $id = 'data-id="' . $anchor . '" '; $anchor_data = 'data-anchor="true"'; wp_localize_script('page-anchor', 'anchor_scroll_speed', array(apply_filters('cherry_anchor_scroll_speed', 300))); cherry_query_asset('js', 'page-anchor'); } $container = 'fixed-width' == $type ? '<div class="container"><div class="%2$s">%1$s</div></div>' : '<div class="container-fluid"><div class="%2$s">%1$s</div></div>'; $default_bg_type = false; switch ($bg_type) { case 'image': $_atts = $atts; if (!empty($_atts['class'])) { $_atts['class'] = ''; } $_content = Cherry_Shortcodes_Handler::box($_atts, sprintf($container, $content, $row_class)); break; case 'parallax_image': if (!empty($original_atts['image_src'])) { $atts['bg_image'] = $original_atts['image_src']; } if (!empty($original_atts['parallax_speed'])) { $atts['speed'] = $original_atts['parallax_speed']; } if (!empty($original_atts['parallax_invert'])) { $atts['invert'] = $original_atts['parallax_invert']; } $_content = Cherry_Shortcodes_Handler::paralax_image($atts, sprintf($container, $content, $row_class)); break; case 'parallax_video': $_content = Cherry_Shortcodes_Handler::paralax_html_video($atts, sprintf($container, $content, $row_class)); break; default: $default_bg_type = true && 'full-width' == $type; $container = 'fixed-width' == $type ? '<div class="container"><div class="%2$s">%1$s</div></div>' : '%s'; $_content = sprintf($container, do_shortcode($content), $row_class); break; } $output = '<div class="' . ($default_bg_type ? $row_class : 'row') . cherry_esc_class_attr($atts) . '" ' . $id . $anchor_data . '>' . $_content . '</div>'; return apply_filters('cherry_shortcodes_output', $output, $atts, 'row'); }