File: /home/aashishs/manishjhanepal.com.np/wp-content/themes/nm_portfolio/functions.php
<?php
add_theme_support( 'post-thumbnails' );
add_theme_support( 'widgets' );
add_theme_support( 'title-tag' );
add_theme_support( 'custom-logo', array(
'height' => 200,
'width' => 200,
) );
add_theme_support( 'automatic-feed-links' );
function nextmorse_stylesheets() {
wp_enqueue_style( 'poppins-font', 'https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700', array(), null, 'all' );
wp_enqueue_style( 'montserrat', 'https://fonts.googleapis.com/css?family=Montserrat:300,400,500,700', array(), null, 'all' );
wp_enqueue_style( 'extra-font', 'https://fonts.googleapis.com/css?family=Herr+Von+Muellerhoff', array(), null, 'all' );
wp_enqueue_style( 'open-iconic-bootstrap', get_template_directory_uri() .'/assets/css/open-iconic-bootstrap.min.css', array(), null, 'all' );
wp_enqueue_style( 'bootstrap-min', get_template_directory_uri() .'/assets/css/bootstrap.min.css', array(), null, 'all' );
wp_enqueue_style( 'animate', get_template_directory_uri() .'/assets/css/animate.css', array(), null, 'all' );
wp_enqueue_style( 'owl-carousel-min', get_template_directory_uri() .'/assets/css/owl.carousel.min.css', array(), null, 'all' );
wp_enqueue_style( 'owl-theme-default-min', get_template_directory_uri() .'/assets/css/owl.theme.default.min.css', array(), null, 'all' );
wp_enqueue_style( 'magnific-popup', get_template_directory_uri() .'/assets/css/magnific-popup.css', array(), null, 'all' );
wp_enqueue_style( 'aos', get_template_directory_uri() .'/assets/css/aos.css', array(), null, 'all' );
wp_enqueue_style( 'ionicons-min', get_template_directory_uri() .'/assets/css/ionicons.min.css', array(), null, 'all' );
wp_enqueue_style( 'bootstrap-datepicker', get_template_directory_uri() .'/assets/css/bootstrap-datepicker.css', array(), null, 'all' );
wp_enqueue_style( 'jquery-timepicker', get_template_directory_uri() .'/assets/css/jquery.timepicker.css', array(), null, 'all' );
wp_enqueue_style( 'flaticon', get_template_directory_uri() .'/assets/css/flaticon.css', array(), null, 'all' );
wp_enqueue_style( 'icomoon', get_template_directory_uri() .'/assets/css/icomoon.css', array(), null, 'all' );
wp_enqueue_style( 'main-style', get_template_directory_uri() .'/assets/css/main-style.css', array(), null, 'all' );
}
add_action( 'wp_enqueue_scripts', 'nextmorse_stylesheets' );
function nextmorse_scripts(){
wp_enqueue_script( 'jquery-min', get_template_directory_uri() . '/assets/js/jquery.min.js', array (), null, false );
wp_enqueue_script( 'jquery-migrate', get_template_directory_uri() . '/assets/js/jquery-migrate-3.0.1.min.js',array (), '3.0.1', true );
wp_enqueue_script( 'popper-min', get_template_directory_uri() . '/assets/js/popper.min.js', array (), null, true );
wp_enqueue_script( 'bootstrap-min', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array (), null, true );
wp_enqueue_script( 'jquery-easing', get_template_directory_uri() . '/assets/js/jquery.easing.1.3.js', array (), null, true );
wp_enqueue_script( 'jquery-waypoints-min', get_template_directory_uri() . '/assets/js/jquery.waypoints.min.js', array (), null, true );
wp_enqueue_script( 'jquery-stellar-min', get_template_directory_uri() . '/assets/js/jquery.stellar.min.js', array (), null, true );
wp_enqueue_script( 'owl-carousel-min', get_template_directory_uri() . '/assets/js/owl.carousel.min.js', array (), null, true );
wp_enqueue_script( 'jquery-magnific-popup-min', get_template_directory_uri() . '/assets/js/jquery.magnific-popup.min.js', array (), null, true );
wp_enqueue_script( 'aos', get_template_directory_uri() . '/assets/js/aos.js', array (), null, true );
wp_enqueue_script( 'jquery-animateNumber-min-js', get_template_directory_uri() . '/assets/js/jquery.animateNumber.min.js', array (), null, true );
wp_enqueue_script( 'bootstrap-datepicker', get_template_directory_uri() . '/assets/js/bootstrap-datepicker.js', array (), null, true );
wp_enqueue_script( 'scrollax-min', get_template_directory_uri() . '/assets/js/scrollax.min.js', array (), null, true );
wp_enqueue_script( 'main', get_template_directory_uri() . '/assets/js/main.js', array (), null, true );
}
add_action( 'wp_enqueue_scripts', 'nextmorse_scripts' );
function special_nav_class ($classes, $item) {
if (in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
// comments_template( '/comments.php',false );
function invonvement_custom_post_type() {
$labels = array(
'name' => _x( 'Involvements', 'Post Type General Name', 'twentytwenty' ),
'singular_name' => _x( 'Involvement', 'Post Type Singular Name', 'twentytwenty' ),
'menu_name' => __( 'Involvement', 'twentytwenty' ),
'parent_item_colon' => __( 'Parent Involvement', 'twentytwenty' ),
'all_items' => __( 'All Involvement', 'twentytwenty' ),
'view_item' => __( 'View Involvement', 'twentytwenty' ),
'add_new_item' => __( 'Add New Involvement', 'twentytwenty' ),
'add_new' => __( 'Add New', 'twentytwenty' ),
'edit_item' => __( 'Edit Involvement', 'twentytwenty' ),
'update_item' => __( 'Update Involvement', 'twentytwenty' ),
'search_items' => __( 'Search Involvement', 'twentytwenty' ),
'not_found' => __( 'Not Found', 'twentytwenty' ),
'not_found_in_trash' => __( 'Not found in Trash', 'twentytwenty' ),
);
$args = array(
'label' => __( 'involvement', 'twentytwenty' ),
'description' => __( 'Involvements ', 'twentytwenty' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
'taxonomies' => array( 'genres' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
register_post_type( 'involvement', $args );
}
add_action( 'init', 'invonvement_custom_post_type', 0 );
function journey_custom_post_type() {
$labels = array(
'name' => _x( 'Journeys', 'Post Type General Name', 'twentytwenty' ),
'singular_name' => _x( 'Journey', 'Post Type Singular Name', 'twentytwenty' ),
'menu_name' => __( 'Journey', 'twentytwenty' ),
'parent_item_colon' => __( 'Parent Journey', 'twentytwenty' ),
'all_items' => __( 'All Journey', 'twentytwenty' ),
'view_item' => __( 'View Journey', 'twentytwenty' ),
'add_new_item' => __( 'Add New Journey', 'twentytwenty' ),
'add_new' => __( 'Add New', 'twentytwenty' ),
'edit_item' => __( 'Edit Journey', 'twentytwenty' ),
'update_item' => __( 'Update Journey', 'twentytwenty' ),
'search_items' => __( 'Search Journey', 'twentytwenty' ),
'not_found' => __( 'Not Found', 'twentytwenty' ),
'not_found_in_trash' => __( 'Not found in Trash', 'twentytwenty' ),
);
$args = array(
'label' => __( 'journey', 'twentytwenty' ),
'description' => __( 'Journeys ', 'twentytwenty' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields' ),
'taxonomies' => array( 'career' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
register_post_type( 'journey', $args );
}
add_action( 'init', 'journey_custom_post_type', 0 );
// ----------------------------------------------------------------------
function my_world_custom_post_type() {
$labels = array(
'name' => _x( 'My World', 'Post Type General Name', 'twentytwenty' ),
'singular_name' => _x( 'World', 'Post Type Singular Name', 'twentytwenty' ),
'menu_name' => __( 'World', 'twentytwenty' ),
'parent_item_colon' => __( 'Parent World', 'twentytwenty' ),
'all_items' => __( 'All World', 'twentytwenty' ),
'view_item' => __( 'View World', 'twentytwenty' ),
'add_new_item' => __( 'Add New World', 'twentytwenty' ),
'add_new' => __( 'Add New', 'twentytwenty' ),
'edit_item' => __( 'Edit World', 'twentytwenty' ),
'update_item' => __( 'Update World', 'twentytwenty' ),
'search_items' => __( 'Search World', 'twentytwenty' ),
'not_found' => __( 'Not Found', 'twentytwenty' ),
'not_found_in_trash' => __( 'Not found in Trash', 'twentytwenty' ),
);
$args = array(
'label' => __( 'world', 'twentytwenty' ),
'description' => __( 'My World ', 'twentytwenty' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields' ),
// 'taxonomies' => array( 'career' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
register_post_type( 'world', $args );
}
add_action( 'init', 'my_world_custom_post_type', 0 );
// ----------------------------------------------------------------------
function nm_portfolio_customize_register( $wp_customize ) {
$wp_customize->add_section( 'nm_portfolio_company_section' , array(
'title' => __( 'Additional Info', 'nm_portfolio' ),
'priority' => 30,
));
$wp_customize->add_setting( 'nm-portfolio-address', array());
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'nm_portfolio_control_address',
array(
'label' => __( 'Address 1', 'nm_portfolio' ),
'section' => 'nm_portfolio_company_section',
'settings' => 'nm-portfolio-address',
'priority' => 1
)
),
);
$wp_customize->add_setting( 'nm-portfolio-address-2', array());
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'nm_portfolio_control_address_2',
array(
'label' => __( 'Address 2', 'nm_portfolio' ),
'section' => 'nm_portfolio_company_section',
'settings' => 'nm-portfolio-address-2',
'priority' => 1
)
),
);
$wp_customize->add_setting( 'nm-portfolio-email', array());
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'nm_portfolio_control_email',
array(
'label' => __( 'Email', 'nm_portfolio' ),
'section' => 'nm_portfolio_company_section',
'settings' => 'nm-portfolio-email',
'priority' => 1
)
),
);
$wp_customize->add_setting( 'nm-portfolio-phone', array());
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'nm_portfolio_control_phone',
array(
'label' => __( 'Phone Number 1', 'nm_portfolio' ),
'section' => 'nm_portfolio_company_section',
'settings' => 'nm-portfolio-phone',
'priority' => 1
)
),
);
$wp_customize->add_setting( 'nm-portfolio-phone-2', array());
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'nm_portfolio_control_phone_2',
array(
'label' => __( 'Phone Number 2', 'nm_portfolio' ),
'section' => 'nm_portfolio_company_section',
'settings' => 'nm-portfolio-phone-2',
'priority' => 1
)
),
);
$wp_customize->add_setting( 'nm-portfolio-facebook', array());
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'nm_portfolio_control_facebook',
array(
'label' => __( 'Facebook Link', 'nm_portfolio' ),
'section' => 'nm_portfolio_company_section',
'settings' => 'nm-portfolio-facebook',
'priority' => 1
)
),
);
$wp_customize->add_setting( 'nm-portfolio-twitter', array());
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'nm_portfolio_control_twitter',
array(
'label' => __( 'Twitter Link', 'nm_portfolio' ),
'section' => 'nm_portfolio_company_section',
'settings' => 'nm-portfolio-twitter',
'priority' => 1
)
),
);
$wp_customize->add_setting( 'nm-portfolio-linkedin', array());
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'nm_portfolio_control_linkedin',
array(
'label' => __( 'Linkedin Link', 'nm_portfolio' ),
'section' => 'nm_portfolio_company_section',
'settings' => 'nm-portfolio-linkedin',
'priority' => 1
)
),
);
$wp_customize->add_setting( 'nm-portfolio-youtube', array());
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'nm_portfolio_control_youtube',
array(
'label' => __( 'Youtube Link', 'nm_portfolio' ),
'section' => 'nm_portfolio_company_section',
'settings' => 'nm-portfolio-youtube',
'priority' => 1
)
),
);
$wp_customize->add_setting( 'nm-portfolio-instagram', array());
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'nm_portfolio_control_instagram',
array(
'label' => __( 'Instagram Link', 'nm_portfolio' ),
'section' => 'nm_portfolio_company_section',
'settings' => 'nm-portfolio-instagram',
'priority' => 1
)
),
);
$wp_customize->add_setting( 'nm-portfolio-google-map', array());
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'nm_portfolio_control_google_map',
array(
'label' => __( 'Google Map Iframe', 'nm_portfolio' ),
'section' => 'nm_portfolio_company_section',
'settings' => 'nm-portfolio-google-map',
'priority' => 1
)
),
);
}
add_action( 'customize_register', 'nm_portfolio_customize_register' );
//hook into the init action and call create_topics_nonhierarchical_taxonomy when it fires
add_action( 'init', 'create_topics_nonhierarchical_taxonomy', 0 );
function create_topics_nonhierarchical_taxonomy() {
// Labels part for the GUI
$labels = array(
'name' => _x( 'careers', 'taxonomy general name' ),
'singular_name' => _x( 'Career', 'taxonomy singular name' ),
'search_items' => __( 'Search Careers' ),
'popular_items' => __( 'Popular Careers' ),
'all_items' => __( 'All Careers' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Career' ),
'update_item' => __( 'Update Career' ),
'add_new_item' => __( 'Add New Career' ),
'new_item_name' => __( 'New Career Name' ),
'separate_items_with_commas' => __( 'Separate career with commas' ),
'add_or_remove_items' => __( 'Add or remove career' ),
'choose_from_most_used' => __( 'Choose from the most used career' ),
'menu_name' => __( 'Career Type' ),
);
// Now register the non-hierarchical taxonomy like tag
register_taxonomy('career','journey',array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'careers' ),
));
}
function wpdocs_get_paginated_links( $query ) {
$currentPage = max( 1, get_query_var( 'paged', 1 ) );
$pages = range( 1, max( 1, $query->max_num_pages ) );
return array_map( function( $page ) use ( $currentPage ) {
return ( object ) array(
"isCurrent" => $page == $currentPage,
"page" => $page,
"url" => get_pagenum_link( $page )
);
}, $pages );
}