' . __( 'Read More', 'materialized-wp' ) . ''; return ' ...'; } /** * Function to Setup materialized-wp * @return null */ function materialized_wp_setup() { //Header image $image = array( 'default-image' => get_template_directory_uri().'/img/logo.png', 'random-default' => false, 'flex-height' => true, 'flex-width' => true, 'default-text-color' => '', 'header-text' => false, 'uploads' => true, 'wp-head-callback' => '', 'admin-head-callback' => '', 'admin-preview-callback' => '', ); //Navigation menus register_nav_menus(array( 'primary' => __('Top Main navigation', 'materialized-wp'), 'footer' => __('Pages in the footer', 'materialized-wp') )); //Featured Images support add_theme_support( 'post-thumbnails' ); add_image_size( 'small-thumbnails', 200, 400, false ); add_image_size( 'banner-thumbnails', 1000, 400, false ); //Post format support add_theme_support('post-formats', array('aside', 'gallery', 'link', 'image', 'quote', 'video', 'status', 'audio')); add_theme_support('automatic-feed-links'); add_theme_support( 'title-tag' ); add_theme_support( "custom-header", $image ); load_theme_textdomain('materialized-wp', get_template_directory() . '/languages'); } /** * Function to resize embeded videos * @return array */ function modify_embed_defaults() { return array( 'width' => 400, 'height' => 375 ); } function set_first_as_featured($attachment_ID){ $post_ID = get_post($attachment_ID)->post_parent; if(!has_post_thumbnail($post_ID)){ set_post_thumbnail($post_ID, $attachment_ID); } } add_action('add_attachment', 'set_first_as_featured'); add_action('edit_attachment', 'set_first_as_featured'); function materialized_wp_widgets_init() { //Sidebar 1 register_sidebar(array( 'name' => __('Sidebar', 'materialized-wp'), 'id' => 'sidebar-1', 'description' => 'This sidebar are displayed in right, and hided in the small devices', 'before_widget' => '
', 'after_widget' => "

", 'before_title' => '

', 'after_title' => "

" )); register_sidebar(array( 'name' => __('Footer sidebar', 'materialized-wp'), 'id' => 'sidebar-2', 'description' => __('This sidebar are displayed in the footer', 'materialized-wp'), 'before_widget' => '
', 'after_widget' => '

', 'before_title' => '

', 'after_title' => "

" )); register_sidebar(array( 'name' => __('Slider', 'materialized-wp'), 'id' => 'slider-1', 'description' => __('This is a simple sidebar for slider/carousel\'s widgets', 'materialized-wp'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '', 'after_title' => '', )); } /** * Plugin recommanded or required in materialized-wp WP theme */ function materialized_wp_required_plugins(){ $plugins = array( array( 'name' => 'Responsive Lightbox', 'slug' => 'responsive-lightbox', 'required' => false, ), ); $config = array( 'id' => 'tgmpa', 'default_path' => '', 'menu' => 'tgmpa-install-plugins', 'parent_slug' => '', 'capability' => 'edit_theme_options', 'has_notices' => true, 'dismissable' => true, 'dismiss_msg' => '', 'is_automatic' => false, 'message' => '', ); tgmpa( $plugins, $config ); } //Filters add_filter( 'embed_defaults', 'modify_embed_defaults' ); add_filter( 'excerpt_more', 'new_excerpt_more' ); add_filter( 'excerpt_length', 'new_excerpt_length' ); //Actions add_action( 'after_setup_theme','materialized_wp_setup'); add_action('wp_enqueue_scripts', 'wp_resources'); add_action('widgets_init', 'materialized_wp_widgets_init'); add_action('tgmpa_register', 'materialized_wp_required_plugins'); class My_Walker_Nav_Menu extends Walker_Nav_Menu { function start_lvl(&$output, $depth = 0, $args = Array()) { $indent = str_repeat("\t", $depth); $output .= "\n$indent