function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Pages', 'lespaul_domain_adm' ) : $instance['title'], $instance, $this->id_base); $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude']; if ( $sortby == 'menu_order' ) $sortby = 'menu_order, post_title'; $pageIDs = get_all_page_ids(); foreach ( $pageIDs as $pageID ) { if ( ! wm_restriction_page( $pageID ) ) { $exclude .= ( $exclude ) ? ( ',' . $pageID ) : ( $pageID ); } } $out = wp_list_pages( apply_filters('widget_pages_args', array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) ) ); if ( !empty( $out ) ) { echo $before_widget; if ( $title) echo $before_title . $title . $after_title; ?> <ul> <?php echo $out; ?> </ul> <?php echo $after_widget; } }
function wm_page_excerpt() { global $post; if ( is_page() || is_home() ) { $postId = ( is_home() ) ? ( get_option( 'page_for_posts' ) ) : ( $post->ID ); $allowed = ( wm_option( 'access-client-area' ) ) ? ( wm_restriction_page() ) : ( true ); $excerpt = get_post_meta( $postId, 'page_excerpt', true ); if ( $excerpt && $allowed ) { if ( post_password_required() ) $excerpt = '<strong>' . __( 'Password protected', 'lespaul_domain' ) . '</strong>'; echo '<div id="page-excerpt" class="wrap clearfix page-excerpt"><div class="wrap-inner"><div class="twelve pane"><div class="page-excerpt-container clearfix">' . apply_filters( 'wm_default_content_filters', $excerpt ) . '</div></div></div></div>'; } } }
function wm_shortcode_subpages( $atts, $content = null ) { extract( shortcode_atts( array( 'depth' => 0, 'order' => 'menu', 'parents' => false, ), $atts ) ); global $post, $page_exclusions; $sortColumns = array( 'title' => 'post_title', 'menu' => 'menu_order', ); $post = ( is_home() ) ? ( get_post( get_option( 'page_for_posts' ) ) ) : ( $post ); $parents = ( $parents ) ? ( true ) : ( false ); $parentPages = ( isset( $post->ancestors ) && $parents ) ? ( $post->ancestors ) : ( null ); //get all parent pages in array $grandparent = ( ! empty( $parentPages ) ) ? ( end( $parentPages ) ) : ( '' ); //get the first parent page (at the end of the array) $order = ( in_array( trim( $order ), array_flip( $sortColumns ) ) ) ? ( $sortColumns[trim( $order )] ) : ( 'menu_order' ); $depth = absint( $depth ); $pageIDs = get_all_page_ids(); foreach ( $pageIDs as $pageID ) { if ( ! wm_restriction_page( $pageID ) ) { $page_exclusions .= ( $page_exclusions ) ? ( ',' . $pageID ) : ( $pageID ); } } //subpages or siblings if ( $grandparent ) $children = wp_list_pages( 'sort_column=' . $order . '&exclude=' . $page_exclusions . '&title_li=&child_of=' . $grandparent . '&echo=0&depth=' . $depth ); else $children = wp_list_pages( 'sort_column=' . $order . '&exclude=' . $page_exclusions . '&title_li=&child_of=' . $post->ID . '&echo=0&depth=' . $depth ); $out = ( $children ) ? ( '<ul class="sub-pages">' . str_replace( 'page_item', 'page_item', $children ) . '</ul>' ) : ( '' ); //output return do_shortcode( $out ); }
function start_el( &$output, $element, $depth, $args ) { global $wp_query; $class_names = ''; $indent = ( $depth ) ? ( str_repeat( "\t", $depth ) ) : ( '' ); $classes = ( empty( $element->classes ) ) ? ( array() ) : ( (array) $element->classes ); $classes = implode( ' ', $classes ); $classes = str_replace( array( 'alignleft', 'alignright' ), '', $classes ); $classes = explode( ' ', $classes ); if ( 1 === $element->menu_order ) $classes[] = 'first'; $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $element ) ); $class_names = ' class="'. esc_attr( str_replace( 'icon-', 'iconnav-', $class_names ) ) . '"'; //Link attributes $attributes = ( ! empty( $element->attr_title ) ) ? ( ' title="' . esc_attr( $element->attr_title ) . '"' ) : ( '' ); $attributes .= ( ! empty( $element->target ) ) ? ( ' target="' . esc_attr( $element->target ) . '"' ) : ( '' ); $attributes .= ( ! empty( $element->xfn ) ) ? ( ' rel="' . esc_attr( $element->xfn ) . '"' ) : ( '' ); $attributes .= ( ! empty( $element->url ) ) ? ( ' href="' . esc_attr( $element->url ) . '"' ) : ( '' ); //Display desciption $mainItemStart = ''; $mainItemEnd = ''; $outItem = $args->before; if ( ! empty( $element->url ) && 'http://' != $element->url && 'http://-' != $element->url && '-' != $element->url ) $outItem .= '<a'. $attributes .' class="inner">'; else $outItem .= '<span class="inner ' . esc_attr( $class_names ) . '">'; $outItem .= $args->link_before . $mainItemStart . apply_filters( 'the_title', do_shortcode( $element->title ), $element->ID ) . $mainItemEnd . $args->link_after; if ( ! empty( $element->url ) && 'http://' != $element->url && 'http://-' != $element->url && '-' != $element->url ) $outItem .= '</a>'; else $outItem .= '</span>'; $outItem .= $args->after; if ( wm_option( 'access-client-area' ) ) { $pageId = ( isset( $element->object_id ) && $element->object_id ) ? ( $element->object_id ) : ( 0 ); $allowed = wm_restriction_page( $pageId ); } else { $allowed = true; } if ( $allowed ) $output .= $indent . '<li' . $class_names .'>' . apply_filters( 'walker_nav_menu_start_el', $outItem, $element, $depth, $args ); else $output .= '<li class="hide">'; } // /start_el
<?php /* Template Name: Portfolio */ get_header(); ?> <div class="wrap-inner"> <?php //check whether current user can display the page $allowed = ( wm_option( 'access-client-area' ) ) ? ( wm_restriction_page() ) : ( true ); if ( $allowed ) { $sidebarLayout = ( wm_meta_option( 'layout' ) ) ? ( wm_meta_option( 'layout' ) ) : ( 'none' ); $overrideSidebar = ( wm_meta_option( 'sidebar' ) && -1 != wm_meta_option( 'sidebar' ) ) ? ( wm_meta_option( 'sidebar' ) ) : ( WM_SIDEBAR_FALLBACK ); if ( is_active_sidebar( $overrideSidebar ) && 'none' != $sidebarLayout ) { $sidebarPanes = ( wm_option( 'contents-sidebar-width' ) ) ? ( esc_attr( wm_option( 'contents-sidebar-width' ) ) ) : ( WM_SIDEBAR_WIDTH ); $sidebarPanes = ( 2 == count( explode( ';', $sidebarPanes ) ) ) ? ( explode( ';', $sidebarPanes ) ) : ( explode( ';', WM_SIDEBAR_WIDTH ) ); if ( 'left' == $sidebarLayout ) $sidebarPanes[1] .= ' sidebar-left'; } else { $sidebarPanes = array( '', ' twelve pane' ); } ?> <article class="main<?php echo $sidebarPanes[1]; ?>"> <?php do_action( 'wm_start_main_content' ); ?>
function widget( $args, $instance ) { global $post, $page_exclusions; extract( $args ); extract( $instance ); $post = ( is_home() ) ? ( get_post( get_option( 'page_for_posts' ) ) ) : ( $post ); $parents = ( isset( $post->ancestors ) ) ? ( $post->ancestors ) : ( null ); //get all parent pages in array $order = ( isset( $order ) ) ? ( $order ) : ( 'menu_order' ); if ( $parent && ! empty( $parents ) ) $grandparent = $parents[0]; //get direct parent elseif ( ! $parent && ! empty( $parents ) ) $grandparent = end( $parents ); //get the first parent page (at the end of the array) else $grandparent = ''; $titleAlt = ( $grandparent ) ? ( '<a href="' . get_permalink( $grandparent ) . '">' . get_the_title( $grandparent ) . '</a>' ) : ( '<a href="' . get_permalink( $post->ID ) . '">' . get_the_title( $post->ID ) . '</a>' ); $pageIDs = get_all_page_ids(); foreach ( $pageIDs as $pageID ) { if ( ! wm_restriction_page( $pageID ) ) { $page_exclusions .= ( $page_exclusions ) ? ( ',' . $pageID ) : ( $pageID ); } } //subpages or siblings if ( $grandparent ) $children = wp_list_pages( 'sort_column=' . $order . '&exclude=' . $page_exclusions . '&title_li=&child_of=' . $grandparent . '&echo=0&depth=3' ); else $children = wp_list_pages( 'sort_column=' . $order . '&exclude=' . $page_exclusions . '&title_li=&child_of=' . $post->ID . '&echo=0&depth=3' ); //no need to display on archive pages, single post page and when there area no subpages if ( is_search() || is_404() || is_archive() || is_single() || ! $children ) return; echo $before_widget; //if the title is not filled, no title will be displayed if ( isset( $title ) && '' != $title && ' ' != $title ) echo $before_title . apply_filters( 'widget_title', $title ) . $after_title; elseif ( $titleAlt ) echo $before_title . $titleAlt . $after_title; echo '<ul class="sub-nav">' . $children . '</ul> <!-- /sub-nav -->'; echo $after_widget; } // /widget