/** * shortcode parsing of membership breadcrumbs element * @param array $atts * @return String */ function membership_breadcrumbs($atts) { $page_id = defined('OP_PAGEBUILDER_ID') ? OP_PAGEBUILDER_ID : $post->ID; extract(shortcode_atts(array('style' => '1'), $atts)); if ($page_id > 0) { $post = get_post($page_id); } $ancestors = get_post_ancestors($post->ID); $element_id = 'asset-membership-breadcrumb-' . (!empty($title) ? op_safe_string($title) : op_generate_id()); $breadcrumb_html = ''; if (count($ancestors) > 0) { $ancestors = array_reverse($ancestors); foreach ($ancestors as $ancestor) { $tempObject = get_post($ancestor); $breadcrumb_html .= '<li><a href="' . get_permalink($ancestor) . '">' . $tempObject->post_title . '</a></li>'; } $breadcrumb_html .= '<li><a href="#">' . $post->post_title . '</a></li>'; } else { $breadcrumb_html = '<li><a href="#">' . $post->post_title . '</a></li>'; } return '<ul id="' . $element_id . '" class="breadcrumb-style-' . $style . '">' . $breadcrumb_html . '</ul>'; }
static function navigation($atts) { // Decode encoded chars $atts = op_urldecode($atts); extract(shortcode_atts(array('style' => '1', 'nav_id' => '0', 'title' => '', 'left_margin' => '0', 'right_margin' => '0'), $atts)); $title_styles = array(4, 6, 7, 8, 9, 10); $title_span_styles = array(9, 10); $js_styles = array(6, 7, 8, 9, 10); $left = intval($left_margin); $right = intval($right_margin); $style_str = ''; if ($left > 0) { $style_str .= 'margin-left:' . $left . 'px;'; } if ($right > 0) { $style_str .= 'margin-right:' . $right . 'px;'; } $font = op_asset_font_style($atts); $element_id = 'asset-navigation-' . (!empty($title) ? op_safe_string($title) : op_generate_id()); $title_html = !empty($title) && in_array($style, $title_styles) ? '<li class="title">' . (in_array($style, $title_span_styles) ? '<span>' . $title . '</span>' : '<h2>' . $title . '</h2>') . '</li>' : ''; $nav_html = ' <ul> ' . $title_html . wp_nav_menu(array('menu' => $nav_id, 'items_wrap' => '%3$s', 'container' => false, 'echo' => false, 'depth' => 2)) . ' </ul> '; $inner_html = $style == 5 ? '<div class="navigation-sidebar-inner">' . $nav_html . '</div>' : $nav_html; $js = in_array($style, $js_styles) ? "\n <script type=\"text/javascript\">\n (function (\$) {\n \$( document ).ready(function() {\n \$('.navigation-sidebar-" . $style . " li a').unbind('click').click(function(e) {\n if (\$(this).closest('li').has('ul').length) {\n e.preventDefault();\n\n var li = \$(this).closest('li');\n li.find(' > ul').slideToggle('fast');\n \$(this).toggleClass('active');\n }\n });\n });\n }(opjq));\n </script>\n " : ''; return ' <style>#' . $element_id . '.navigation-sidebar-' . $style . ' > ul > li > a{ ' . $font . ' }</style> <div id="' . $element_id . '" class="navigation-sidebar navigation-sidebar-' . $style . '"' . ($style_str == '' ? '' : ' style=\'' . $style_str . '\'') . '> ' . $inner_html . ' </div> ' . $js; }