/** * Author: Ole Fredrik Lie * URL: http://olefredrik.com * * FoundationPress functions and definitions * * Set up the theme and provides some helper functions, which are used in the * theme as custom template tags. Others are attached to action and filter * hooks in WordPress to change core functionality. * * @link https://codex.wordpress.org/Theme_Development * @package WordPress * @subpackage FoundationPress * @since FoundationPress 1.0.0 */ /** Various clean up functions */ require_once( 'library/cleanup.php' ); /** Required for Foundation to work properly */ require_once( 'library/foundation.php' ); /** Register all navigation menus */ require_once( 'library/navigation.php' ); /** Add desktop menu walker */ require_once( 'library/menu-walker.php' ); /** Add off-canvas menu walker */ require_once( 'library/offcanvas-walker.php' ); /** Create widget areas in sidebar and footer */ require_once( 'library/widget-areas.php' ); /** Return entry meta information for posts */ require_once( 'library/entry-meta.php' ); /** Enqueue scripts */ require_once( 'library/enqueue-scripts.php' ); /** Add theme support */ require_once( 'library/theme-support.php' ); /** Add Header image */ require_once( 'library/custom-header.php' ); /** Add Nav Options to Customer */ require_once( 'library/custom-nav.php' ); /** Add protocol relative theme assets */ require_once( 'library/protocol-relative-theme-assets.php' ); /** Lorem Ipsum Text **/ require_once( 'library/lorem-ipsum.php' ); /** ACF Options Pages **/ require_once( 'library/acf-options-pages.php' ); /** ACF Custom Admin **/ require_once( 'library/acf-custom-admin.php' ); function wp_get_most_parent() { global $post; if ($post->post_parent) { $ancestors=get_post_ancestors($post->ID); $root=count($ancestors)-1; $parent = $ancestors[$root]; } else { $parent = $post->ID; } return $parent; }; /** * Get excerpt from string * * @param String $str String to get an excerpt from * @param Integer $startPos Position int string to start excerpt from * @param Integer $maxLength Maximum length the excerpt may be * @return String excerpt */ function getExcerpt($str, $startPos=0, $maxLength=100) { if(strlen($str) > $maxLength) { $excerpt = substr($str, $startPos, $maxLength-3); $lastSpace = strrpos($excerpt, ' '); $excerpt = substr($excerpt, 0, $lastSpace); $excerpt .= '...'; } else { $excerpt = $str; } return $excerpt; } /* add_action( 'init', 'cd_add_editor_styles' ); function cd_add_editor_styles() { add_editor_style( get_stylesheet_directory_uri().'/assets/stylesheets/foundation.css' ); } function my_theme_add_editor_styles() { global $post; $post_type = get_post_type( $post->ID ); $editor_style = get_stylesheet_directory_uri().'/assets/stylesheets/foundation.css'; add_editor_style( $editor_style ); } add_action( 'pre_get_posts', 'my_theme_add_editor_styles' ); var_dump( get_stylesheet_directory_uri().'/assets/stylesheets/foundation.css' ); */ function wpb_list_child_pages($child_type) { global $post; $childpages = wp_list_pages( array( 'sort_column' => 'menu_order', 'title_li' => '', 'child_of' => wp_get_most_parent(), 'echo' => 0, 'depth' => 1 ) ); if ( $childpages ) { $string = '