191 lines
7.4 KiB
PHP
191 lines
7.4 KiB
PHP
<?php define( 'OSTAL_VERSION', 6.2 );
|
|
|
|
add_theme_support( 'automatic-feed-links' );
|
|
add_theme_support( 'post-thumbnails' );
|
|
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
/* Register main menu for Wordpress use
|
|
/*-----------------------------------------------------------------------------------*/
|
|
register_nav_menus(
|
|
array(
|
|
'primary' => __( 'Primary Menu', 'ostal' ),
|
|
)
|
|
);
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
/* Set filter for nav_menu_css_class.
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
function add_additional_class_on_li($classes, $item, $args) {
|
|
if(isset($args->add_li_class)) {
|
|
$classes[] = $args->add_li_class;
|
|
}
|
|
return $classes;
|
|
}
|
|
add_filter('nav_menu_css_class', 'add_additional_class_on_li', 1, 3);
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
/* Enqueue Styles and Scripts
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
function add_custom_fonts() {
|
|
wp_enqueue_style( 'custom-fonts', get_template_directory_uri() . '/fonts/fonts.css', array(), null );
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'add_custom_fonts' );
|
|
|
|
function ostal_scripts() {
|
|
|
|
wp_enqueue_style('ostal-styles', get_theme_file_uri() . '/ostal-front/dist/assets/main.css',array(), OSTAL_VERSION, 'all');
|
|
wp_enqueue_style('style.css', get_stylesheet_directory_uri() . '/style.css');
|
|
|
|
// wp_enqueue_script( 'ostal-js', get_theme_file_uri() . '/ostal-front/dist/assets/main.js', array( 'jquery' ), OSTAL_VERSION, true );
|
|
|
|
wp_enqueue_script( 'main-js', get_stylesheet_directory_uri().'/js/main.js', array(), filemtime(get_stylesheet_directory() . '/js/main.js'), true );
|
|
|
|
if(is_page_template( 'page-templates/template-about.php' )) {
|
|
wp_enqueue_style('video-js-styles', 'https://vjs.zencdn.net/7.11.4/video-js.css');
|
|
wp_enqueue_script( 'video-js', 'https://vjs.zencdn.net/7.11.4/video.min.js', array( ), OSTAL_VERSION, true );
|
|
}
|
|
|
|
// if(is_singular('realizacje')) {
|
|
// wp_enqueue_script( 'vue', 'https://unpkg.com/vue@next', array( ), NULL, true );
|
|
// wp_enqueue_script( 'vue-lightbox', 'https://unpkg.com/vue-easy-lightbox@next/dist/vue-easy-lightbox.umd.min.js', array( ), NULL, true );
|
|
// // wp_enqueue_script( 'vue-slider', get_theme_file_uri() . '/ostal-front/dist/assets/vue-slider.js', array( ), OSTAL_VERSION, true );
|
|
// }
|
|
|
|
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'ostal_scripts' );
|
|
|
|
// Allow SVG
|
|
function cc_mime_types($mimes) {
|
|
$mimes['svg'] = 'image/svg+xml';
|
|
return $mimes;
|
|
}
|
|
add_filter('upload_mimes', 'cc_mime_types');
|
|
|
|
// remove extra p and br on contact form 7
|
|
add_filter( 'wpcf7_autop_or_not', '__return_false' );
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
/* Custom post types
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
function realizacje() {
|
|
|
|
$labels = array(
|
|
'name' => _x( 'Realizacje', 'Post Type General Name', 'text_domain' ),
|
|
'singular_name' => _x( 'Realizacja', 'Post Type Singular Name', 'text_domain' ),
|
|
'menu_name' => __( 'Realizacje', 'text_domain' ),
|
|
'name_admin_bar' => __( 'Realizacje', 'text_domain' ),
|
|
'archives' => __( 'Item Archives', 'text_domain' ),
|
|
'attributes' => __( 'Item Attributes', 'text_domain' ),
|
|
'parent_item_colon' => __( 'Parent Item:', 'text_domain' ),
|
|
'all_items' => __( 'All Items', 'text_domain' ),
|
|
'add_new_item' => __( 'Add New Item', 'text_domain' ),
|
|
'add_new' => __( 'Add New', 'text_domain' ),
|
|
'new_item' => __( 'New Item', 'text_domain' ),
|
|
'edit_item' => __( 'Edit Item', 'text_domain' ),
|
|
'update_item' => __( 'Update Item', 'text_domain' ),
|
|
'view_item' => __( 'View Item', 'text_domain' ),
|
|
'view_items' => __( 'View Items', 'text_domain' ),
|
|
'search_items' => __( 'Search Item', 'text_domain' ),
|
|
'not_found' => __( 'Not found', 'text_domain' ),
|
|
'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ),
|
|
'featured_image' => __( 'Featured Image', 'text_domain' ),
|
|
'set_featured_image' => __( 'Set featured image', 'text_domain' ),
|
|
'remove_featured_image' => __( 'Remove featured image', 'text_domain' ),
|
|
'use_featured_image' => __( 'Use as featured image', 'text_domain' ),
|
|
'insert_into_item' => __( 'Insert into item', 'text_domain' ),
|
|
'uploaded_to_this_item' => __( 'Uploaded to this item', 'text_domain' ),
|
|
'items_list' => __( 'Items list', 'text_domain' ),
|
|
'items_list_navigation' => __( 'Items list navigation', 'text_domain' ),
|
|
'filter_items_list' => __( 'Filter items list', 'text_domain' ),
|
|
);
|
|
$args = array(
|
|
'label' => __( 'Realizacja', 'text_domain' ),
|
|
'description' => __( 'Post Type Description', 'text_domain' ),
|
|
'labels' => $labels,
|
|
'supports' => array( 'title','thumbnail' ),
|
|
// 'taxonomies' => array( 'category', 'post_tag' ),
|
|
'hierarchical' => false,
|
|
'public' => true,
|
|
'show_ui' => true,
|
|
'show_in_menu' => true,
|
|
'menu_position' => 5,
|
|
'show_in_admin_bar' => true,
|
|
'show_in_nav_menus' => true,
|
|
'can_export' => true,
|
|
'has_archive' => true,
|
|
'exclude_from_search' => false,
|
|
'publicly_queryable' => true,
|
|
'capability_type' => 'page',
|
|
'show_in_rest' => true,
|
|
);
|
|
register_post_type( 'realizacje', $args );
|
|
|
|
}
|
|
add_action( 'init', 'realizacje', 0 );
|
|
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
/* Dashboard
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
function remove_admin_menus () {
|
|
global $menu;
|
|
$removed = array(
|
|
//__('Posts'),
|
|
__('Comments')
|
|
);
|
|
end ($menu);
|
|
while (prev($menu)){
|
|
$value = explode(
|
|
' ',
|
|
$menu[key($menu)][0]);
|
|
if(in_array($value[0] != NULL?$value[0]:"" , $removed)){
|
|
unset($menu[key($menu)]);
|
|
}
|
|
}
|
|
}
|
|
//add_action('admin_menu', 'remove_admin_menus');
|
|
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
/* Options page
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
if( function_exists('acf_add_options_page') ) {
|
|
|
|
acf_add_options_page(array(
|
|
'page_title' => 'Ostal ustawienia',
|
|
'menu_title' => 'Ostal',
|
|
'menu_slug' => 'ostal-settings',
|
|
'capability' => 'edit_posts',
|
|
'redirect' => false
|
|
));
|
|
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
/* Sierotki
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
function acf_orphans($value, $post_id, $field) {
|
|
if ( class_exists( 'iworks_orphan' ) ) {
|
|
$orphan = new \iworks_orphan();
|
|
$value = $orphan->replace( $value );
|
|
}
|
|
return $value;
|
|
}
|
|
add_filter('acf/format_value/type=textarea', 'acf_orphans', 10, 3);
|
|
add_filter('acf/format_value/type=wysiwyg', 'acf_orphans', 10, 3);
|
|
|
|
function my_theme_enqueue_styles() {
|
|
wp_enqueue_style('custom', get_stylesheet_directory_uri() . '/css/custom.css', array(), '1.0.0', 'all');
|
|
}
|
|
|
|
add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles');
|