| Server IP : 104.21.80.248 / Your IP : 172.71.28.156 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Inetpub/www/training/wp-content/themes/flatsome/inc/shortcodes/ |
Upload File : |
<?php
function ux_navigation($atts) {
extract(shortcode_atts(array(
'class' => '',
'visibility' => '',
'parent' => '',
'align' => 'left',
'style' => 'line',
'type' => 'vertical', // horizontal / vertical
'size' => '',
'case' => 'uppercase',
//'bg_color' => '',
//'height' => '',
//'sticky' => '',
), $atts));
ob_start();
global $post;
$current = get_the_ID($post->ID);
$classes = array('nav');
if($class) $classes[] = $class;
if($visibility) $classes[] = $visibility;
if($case) $classes[] = 'nav-'.$case;
if($type) $classes[] = 'nav-'.$type;
if($size) $classes[] = 'nav-size-'.$size;
if($style) $classes[] = 'nav-'.$style;
if($align) $classes[] = 'text-'.$align.' nav-'.$align;
echo '<div class="nav-wrapper">';
echo '<ul class="'.implode(' ',$classes).'">';
if ( is_page() && $post->post_parent && !$parent ){
$childpages = get_pages( array( 'child_of' => $post->post_parent, 'sort_column' => 'menu_order' ) );
} else {
$post_id = $post->ID;
if($parent) {
if(!is_numeric($parent)){
$id = get_page_by_path( $parent );
$parent = $id->ID;
}
$post_id = $parent;
}
$childpages = get_pages( array( 'child_of' => $post_id, 'sort_column' => 'menu_order' ) );
if(!$childpages) echo '<p class="lead shortcode-error text-center">Sorry, no pages was found</p>';
}
foreach ( $childpages as $page ) {
$classes = '';
if($page->ID == $current) $classes = 'active';
echo '<li class='.$classes.'><a href="'.get_the_permalink($page->ID).'">'.$page->post_title.'</a></li>';
}
echo '</ul>';
echo '</div>';
$content = ob_get_contents();
ob_end_clean();
return $content;
}
add_shortcode("ux_nav", "ux_navigation");