ID; } // If there are no items to display, return nothing if ( NULL === $display ) { $display = array( 'date', 'author', 'categories', 'tags' ); } // Allow for filtering of the display elements. $display = apply_filters( 'layers_post_meta_display', $display ); foreach ( $display as $meta ) { switch ( $meta ) { case 'date' : $meta_to_display[] = ' ' . get_the_time( get_option( 'date_format' ) , $post_id ) . ''; break; case 'author' : $meta_to_display[] = ' ' . layers_get_the_author( $post_id ) . ''; break; case 'categories' : $categories = ''; // Use different terms for different post types if( 'post' == get_post_type( $post_id ) ){ $the_categories = get_the_category( $post_id ); } elseif( 'portfolio' == get_post_type( $post_id ) ) { $the_categories = get_the_terms( $post_id , 'portfolio-category' ); } else { $the_categories = FALSE; } // If there are no categories, skip to the next case if( !$the_categories ) continue; foreach ( $the_categories as $category ){ $categories[] = ' name ) ) . '">'.$category->name.''; } $meta_to_display[] = ' ' . implode( __( ', ' , 'layerswp' ), $categories ) . ''; break; case 'tags' : $tags = ''; if( 'post' == get_post_type( $post_id ) ){ $the_tags = get_the_tags( $post_id ); } elseif( 'layers-project' == get_post_type( $post_id ) ) { $the_tags = get_the_terms( $post_id , 'project-tag' ); } else { $the_tags = FALSE; } // If there are no tags, skip to the next case if( !$the_tags ) continue; foreach ( $the_tags as $tag ){ $tags[] = ' name ) ) . '">'.$tag->name.''; } $meta_to_display[] = ' ' . implode( __( ', ' , 'layerswp' ), $tags ) . ''; break; break; } // switch meta } // foreach $display if( !empty( $meta_to_display ) ) { echo '<' , $wrapper , ( ( '' != $wrapper_class ) ? ' class="' . $wrapper_class . '"' : NULL ) , '>'; echo '

'; echo implode( ' ' , $meta_to_display ); echo '

'; echo ''; } } } // layers_post_meta /** * Prints HTML with meta information for the current post-date/time and author. */ if ( ! function_exists( 'layers_get_the_author' ) ) { function layers_get_the_author() { return sprintf( __( '' , 'layerswp' ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'layerswp' ), get_the_author() ) ), esc_attr( get_the_author() ) ); } } // layers_get_the_author /** * Prints Comment HTML * * @param object $comment Comment objext * @param array $args Configuration arguments. * @param int $depth Current depth of comment, for example 2 for a reply * @echo string Comment HTML */ if( !function_exists( 'layers_comment' ) ) { function layers_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment;?>
id="comment-">
','') ?>
comment_approved == '0') : ?>
$depth, 'max_depth' => $args['max_depth']))) ?>
ID ); $page_content = trim( ob_get_clean() ); $page_content = preg_replace('#(.*?)#is', '', $page_content); $page_content = strip_tags( $page_content , '

#is', '', $page_content); $page_content = preg_replace('#(.*?)#is', '', $page_content); $page_content = wp_kses( $page_content, array( 'a' => array( 'href' => array(), 'target' => array(), ), 'img' => array( 'src' => array(), 'width' => array(), 'height' => array(), ), 'p', 'b', 'i', 'strong', 'em', 'quote', 'h1', 'h2', 'h3', 'h4', 'h5', ) ); $page_content = preg_replace('/(?:(?:\r\n|\r|\n)\s*){2}/s', "\n\n", $page_content); $page_content = preg_replace("/(]*>)([^<>]*|.*)(<\\/a>)/m", "$2", $page_content); $page_content = str_replace( ' ', '', $page_content ); return $page_content; } } /** * Conditional check if is Layers page * * @param int $post_id (Optional) ID of post to check. Uses global $post ID if none provided. */ if( ! function_exists( 'layers_is_builder_page' ) ) { function layers_is_builder_page( $post_id = false ){ global $post; // Be sure to set a post id for use if ( !$post_id && isset( $post ) && isset( $post->ID ) ) { $post_id = $post->ID; } // If there is a post_id, check for the builder page if ( isset( $post_id ) ) { if( LAYERS_BUILDER_TEMPLATE == get_post_meta( $post_id, '_wp_page_template', true ) ) { return true; } } // Fallback return false; } } /** * Filter Layers Pages in wp-admin Pages * * @TODO: think about moving this function to it own helpers/admin.php, * especially if more work is to be done on admin list. */ if ( ! function_exists( 'layers_filter_admin_pages' ) ) { function layers_filter_admin_pages() { global $typenow; if ( 'page' == $typenow && isset( $_GET['filter'] ) && 'layers' == $_GET['filter'] ) { set_query_var( 'meta_query', array( 'relation' => 'AND', array( 'key' => '_wp_page_template', 'value' => LAYERS_BUILDER_TEMPLATE, ) ) ); } } } add_filter( 'pre_get_posts', 'layers_filter_admin_pages' ); /** * Change views links on wp-list-table - all, published, draft, etc - to maintain layers page filtering * TODO: some kind of feeback so user knows he is in the Layers filter - maybe h2 to "Layers Pages" */ if ( ! function_exists( 'layers_filter_admin_pages_views' ) ) { function layers_filter_admin_pages_views( $views ) { global $typenow; if ( 'page' == $typenow && isset( $_GET['filter'] ) && 'layers' == $_GET['filter'] ) { foreach ($views as $view_key => $view_value ) { $query_arg = '&filter=layers'; $view_value = preg_replace('/href=\'(http:\/\/[^\/"]+\/?)?([^"]*)\'/', "href='\\2$query_arg'", $view_value); $views[$view_key] = $view_value; } } return $views; } } //add_filter( "views_edit-page", 'layers_filter_admin_pages_views' ); /** * Add builder edit button to the admin bar * * @return null Nothing is returned, the Edit button is added the admin toolbar */ if( ! function_exists( 'layers_edit_layout_admin_menu' ) ) { function layers_edit_layout_admin_menu(){ global $wp_admin_bar, $post, $wp_version; if( !is_admin() && version_compare( $wp_version, '4.2', '<=' ) ){ $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $args = array( 'id' => 'layers-edit-layout', 'title' => '' . __( 'Edit Layout' , 'layerswp' ) . '', 'href' => esc_url( add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ) ), 'meta' => array( 'class' => 'my-toolbar-page' ) ); $wp_admin_bar->add_node( $args ); } } } add_action( 'admin_bar_menu', 'layers_edit_layout_admin_menu', 90 ); /** * Add "Add New Layers Page" to the admin bar * * @return null Nothing is returned, the new button is added the admin toolbar */ if( ! function_exists( 'layers_add_new_page_admin_menu' ) ) { function layers_add_new_page_admin_menu(){ global $wp_admin_bar, $post; $args = array( 'parent' => 'new-content', 'id' => 'layers-add-page', 'title' =>__( 'Layers Page' , 'layerswp' ), 'href' => admin_url( 'admin.php?page=layers-add-new-page' ) ); $wp_admin_bar->add_node( $args ); } } add_action( 'admin_bar_menu', 'layers_add_new_page_admin_menu', 90 ); // Output custom css to add Icon to admin bar edit button. if( ! function_exists( 'layers_add_builder_edit_button_css' ) ) { function layers_add_builder_edit_button_css() { global $pagenow; if ( 'post.php' === $pagenow || ! is_admin() ) : ?> $post->ID, 'wrap' => 'div', 'wrap_class' => 'thumbnail', 'size' => 'medium', 'hide_href' => false ); $args = wp_parse_args( $args, $defaults ); extract( $args, EXTR_SKIP ); $post_meta = get_post_meta( $postid, 'layers', true ); $featured_media = layers_get_feature_media( get_post_thumbnail_id( $postid ), $size, ( isset( $post_meta[ 'video-url' ] ) ? $post_meta[ 'video-url' ] : NULL ), $postid ); if( NULL == $featured_media ) return; $output = ''; if( NULL != $featured_media ){ $output .= $featured_media; } if( TRUE != $hide_href ){ if( has_post_thumbnail() ) { if( !is_single() ){ $output = '' . $output . ''; } } } if( '' != $wrap ) { $output = '<'.$wrap. ( '' != $wrap_class ? ' class="' . $wrap_class . '"' : '' ) . '>' . $output . ''; } return apply_filters('layers_post_featured_media', $output); } } // layers_post_featured_media /** * Post Featured Media * * @param int $postid ID for post * * @return book TRUE or FALSE depending on whether or not a video has been added to the post */ if( !function_exists( 'layers_post_has_video' ) ) { function layers_post_has_video( $postid = FALSE ){ if( FALSE == $postid ) { global $post; $postid = $post->ID; } $post_meta = get_post_meta( $postid, 'layers', true ); return ( isset( $post_meta[ 'video-url' ] ) && '' != $post_meta[ 'video-url' ] ? TRUE : FALSE ); } }