%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/pn/beta/64801_wp-content/themes/intosai/lib/
Upload File :
Create Path :
Current File : /var/www/pn/beta/64801_wp-content/themes/intosai/lib/setup.php

<?php
namespace Roots\Sage\Setup;
use Roots\Sage\Assets;

// TEMA INSTÄLLNINGAR
// Registrerar menyer
// Aktiverar Thumbnails
//*********************************************************************
function setup() {
    //Menyer
    //***************************
    register_nav_menus([
        'mainNav' => __('Huvudnavigation', 'sage'),
        'secondNav' => __('Extra navigation', 'sage')
    ]);

    //Thumbnails
    //***************************
    add_theme_support('post-thumbnails');
    add_image_size('large', 700, '', true);
    add_image_size('medium', 250, '', true);
    add_image_size('small', 120, '', true);
    add_image_size('newsThumb', 414, 216, true);
    add_image_size('bannerimg', 2000, 700, true);
    add_image_size('bannerimgsmall', 2000, 350, true);
    add_image_size('partnerLogo', 250, 196, true);
    add_image_size('newsSmall', 650, 350, true);
    add_image_size('newsLarge', 1300, 350, true);
    // add_image_size('custom-size', xxx, '', true); // Custom Thumbnail
}
add_action('after_setup_theme', __NAMESPACE__ . '\\setup');

function body_class($classes) {
    // Add page slug if it doesn't exist
    if (is_single() || is_page() && !is_front_page()) {
        if (!in_array(basename(get_permalink()), $classes)) {
            $classes[] = basename(get_permalink());
        }
    }
    // Add class if sidebar is active
    if (display_sidebar()) {
        $classes[] = 'sidebar-active';
    }
    return $classes;
}
add_filter('body_class', __NAMESPACE__ . '\\body_class');

// Ange vilka sidor sidebaren SKA visas på.
//*********************************************************************
function display_sidebar() {
    static $display;
    isset($display) || $display = in_array(true, [
        //Ange de sidor du vill att sidebaren SKA synas på.
        // @link https://codex.wordpress.org/Conditional_Tags
        is_404(),
        // is_singular('post_type'),
        // is_page(),
        is_search(),
        // is_front_page(),
    ]);
    return apply_filters('sage/display_sidebar', $display);
}

// Lägg till en ändelse efter de retunerade orden på the_excerpt
//*********************************************************************
function excerpt_more() { return '...'; }
function excerpt_length_custom( $length ) { return 25; } // Retunerar 15 ord
add_filter( 'excerpt_length', __NAMESPACE__ . '\\excerpt_length_custom', 999 );
add_filter('excerpt_more', __NAMESPACE__ . '\\excerpt_more');

/*------------------------------------*\
    INNITIERA ACF-OPTIONS
\*------------------------------------*/
if( function_exists('acf_add_options_page') ) {
    // lägg till menyalternativ i Admin
    $parent = acf_add_options_page(array(
        'page_title'    => 'Global settings for the site',
        'menu_title'    => 'Global settings',
        'icon_url'      => 'dashicons-admin-site',
        'post_id'       => 'global',
        'capability'    => 'edit_posts',
        'redirect'      => false
    ));

    // Lägg till undersida till ovanstående
    acf_add_options_sub_page(array(
        'page_title'    => 'New project options',
        'menu_title'    => 'New project options',
        'post_id'       => 'project_option',
        'parent_slug'   => $parent['menu_slug'],
    ));

    acf_add_options_sub_page(array(
        'page_title'    => 'New project tooltips',
        'menu_title'    => 'New project tooltips',
        'post_id'       => 'project_tooltip',
        'parent_slug'   => $parent['menu_slug'],
    ));

    acf_add_options_page(array(
        'page_title'    => 'Email settings',
        'menu_title'    => 'Email settings',
        'menu_slug'     => 'custom-email-settings',
        'icon_url'      => 'dashicons-email-alt',
        'post_id'       => 'epost',
        'capability'    => 'edit_posts',
        'redirect'      => false
    ));
}

/*------------------------------------*\
    WIDGETS
\*------------------------------------*/
function widgets_init() {
    // register_sidebar([
    //     'name'          => __('Widget Namn', 'sage'),
    //     'id'            => 'sidebar-primary',
    //     'before_widget' => '<div class="widget %1$s %2$s">',
    //     'after_widget'  => '</div>',
    //     'before_title'  => '<h3>',
    //     'after_title'   => '</h3>'
    // ]);
}
add_action('widgets_init', __NAMESPACE__ . '\\widgets_init');

/*------------------------------------*\
    CUSTOM POST TYPES
\*------------------------------------*/
add_action( 'init',__NAMESPACE__ . '\\create_projects' );
function create_projects() {
    $posttype = 'project';
    register_post_type($posttype,
        array(
            'labels'=> array(
                'name'                  => __('Projects', $posttype),
                'singular_name'         => __('Project', $posttype),
                'add_new'               => __('Add new', $posttype),
                'add_new_item'          => __('Add new', $posttype),
                'edit'                  => __('Edit', $posttype),
                'edit_item'             => __('Edit', $posttype),
                'new_item'              => __('New', $posttype),
                'view'                  => __('View', $posttype),
                'view_item'             => __('View', $posttype),
                'search_items'          => __('Search', $posttype),
                'not_found'             => __('Nothing found', $posttype),
                'not_found_in_trash'    => __('Trash is empty', $posttype)
            ),
            'public'              => true,
            'hierarchical'        => false,
            'has_archive'         => true,
            'menu_icon'           => 'dashicons-feedback',
            'supports' => array(
                'title',
                'editor',
                'author',
                //'revisions',
                //'excerpt',
                //'thumbnail'
            ),
            'can_export' => true,
            'taxonomies' => array(
                'wdi'
            )
        )
    );
    flush_rewrite_rules();
}

add_action( 'init',__NAMESPACE__ . '\\wdi_database' );
function wdi_database() {

    $taxonomy = 'wdi';

    $labels = array(
        'name'              => _x( 'WDI Database', 'WDI Database', $taxonomy),
        'singular_name'     => _x( 'WDI Database', 'WDI Database', $taxonomy),
        'search_items'      => __( 'Search SAIs', $taxonomy),
        'all_items'         => __( 'All SAIs', $taxonomy),
        'parent_item'       => __( 'Parent SAI', $taxonomy),
        'parent_item_colon' => __( 'Parent SAI:', $taxonomy),
        'edit_item'         => __( 'Edit SAI', $taxonomy),
        'update_item'       => __( 'Update SAI', $taxonomy),
        'add_new_item'      => __( 'Add New SAI', $taxonomy),
        'new_item_name'     => __( 'New SAI Name', $taxonomy),
        'menu_name'         => __( 'WDI Database', $taxonomy),
        'not_found'         => __( 'No SAIs found.', $taxonomy),
    );

	register_taxonomy(
		'wdi',
		array(
            'project',
            'project_revisions'
        ),
		array(
			'labels' => $labels,
			'rewrite' => array( 'slug' => 'wdi' ),
            'hierarchical' => true,
		)
	);
}

add_action( 'init',__NAMESPACE__ . '\\create_project_revisions' );
function create_project_revisions() {
    $posttype = 'project_revisions';
    register_post_type($posttype,
        array(
            'labels'=> array(
                'name'                  => __('Project Revisions', $posttype),
                'singular_name'         => __('Project Revisions', $posttype),
                'add_new'               => __('Add new', $posttype),
                'add_new_item'          => __('Add new', $posttype),
                'edit'                  => __('Edit', $posttype),
                'edit_item'             => __('Edit', $posttype),
                'new_item'              => __('New', $posttype),
                'view'                  => __('View', $posttype),
                'view_item'             => __('View', $posttype),
                'search_items'          => __('Search', $posttype),
                'not_found'             => __('Nothing found', $posttype),
                'not_found_in_trash'    => __('Trash is empty', $posttype)
            ),
            'public'              => false,
            'show_ui'             => true,
            'hierarchical'        => false,
            'has_archive'         => false,
            'menu_icon'           => 'dashicons-lock',
            'supports' => array(
                'title',
                'editor',
                'author',
            ),
            'can_export' => true,
            'taxonomies' => array(
                'wdi'
            )
        )
    );
    flush_rewrite_rules();
}


add_action( 'init',__NAMESPACE__ . '\\create_partners' );
function create_partners() {
    $posttype = 'partners';
    register_post_type($posttype,
        array(
            'labels'=> array(
                'name'                  => __('Partners', $posttype),
                'singular_name'         => __('Partners', $posttype),
                'add_new'               => __('Add new', $posttype),
                'add_new_item'          => __('Add new', $posttype),
                'edit'                  => __('Edit', $posttype),
                'edit_item'             => __('Edit', $posttype),
                'new_item'              => __('New', $posttype),
                'view'                  => __('View', $posttype),
                'view_item'             => __('View', $posttype),
                'search_items'          => __('Search', $posttype),
                'not_found'             => __('Nothing found', $posttype),
                'not_found_in_trash'    => __('Trash is empty', $posttype)
            ),
            'public'              => true,
            'hierarchical'        => false,
            'has_archive'         => false,
            'exclude_from_search' => true,
            'menu_icon'           => 'dashicons-groups',
            'supports' => array(
                'title',
                'editor',
                'excerpt',
                'thumbnail'
            ),
            'can_export' => true,
            'taxonomies' => array(
                //'post_tag',
                //'category'
            )
        )
    );
    flush_rewrite_rules();
}

add_action( 'init',__NAMESPACE__ . '\\create_success' );
function create_success() {
    $posttype = 'storys';
    register_post_type($posttype,
        array(
            'labels'=> array(
                'name'                  => __('Success Stories', $posttype),
                'singular_name'         => __('Success Stories', $posttype),
                'add_new'               => __('Add new', $posttype),
                'add_new_item'          => __('Add new', $posttype),
                'edit'                  => __('Edit', $posttype),
                'edit_item'             => __('Edit', $posttype),
                'new_item'              => __('New', $posttype),
                'view'                  => __('View', $posttype),
                'view_item'             => __('View', $posttype),
                'search_items'          => __('Search', $posttype),
                'not_found'             => __('Nothing found', $posttype),
                'not_found_in_trash'    => __('Trash is empty', $posttype)
            ),
            'public'              => true,
            'hierarchical'        => false,
            'has_archive'         => true,
            'menu_icon'           => 'dashicons-testimonial',
            'rewrite'             => array('slug' => 'stories'),
            'supports' => array(
                'title',
                'editor',
                //'excerpt',
                'thumbnail'
            ),
            'can_export' => true,
            'taxonomies' => array(
                //'post_tag',
                'story-categories'
            )
        )
    );
    flush_rewrite_rules();
}

add_action( 'init',__NAMESPACE__ . '\\story_cat' );
function story_cat() {
	register_taxonomy(
		'story-categories',
		'storys',
		array(
			'label' => __( 'Story Categories' ),
			'rewrite' => array( 'slug' => 'story-category' ),
            'hierarchical' => true,
			// 'capabilities' => array(
			// 	'assign_terms' => 'edit_guides',
			// 	'edit_terms' => 'publish_guides'
			// )
		)
	);
}

Zerion Mini Shell 1.0