/** * musart functions and definitions. * * @link https://developer.wordpress.org/themes/basics/theme-functions/ * * @package musart */ if (!function_exists('musart_setup')) : /** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which * runs before the init hook. The init hook is too late for some features, such * as indicating support for post thumbnails. */ function musart_setup() { /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on musart, use a find and replace * to change 'musart' to the name of your theme in all the template files. */ load_theme_textdomain('musart', get_template_directory() . '/languages'); // Add Editor styles. add_editor_style(); // Add default posts and comments RSS feed links to head. add_theme_support('automatic-feed-links'); add_theme_support( 'post-formats', array( 'image' ) ); add_post_type_support( 'post', 'post-formats' ); /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support('title-tag'); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support('post-thumbnails'); // This theme uses wp_nav_menu() in one location. register_nav_menus(array( 'primary' => esc_html__('Main Menu', 'musart'), 'side_navigation_menu' => esc_html__('Side Navigation Menu', 'musart') )); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support('html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', )); // Set up the WordPress core custom background feature. add_theme_support('custom-background', apply_filters('musart_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ))); // Add default image sizes add_theme_support('post-thumbnails'); add_image_size('musart_48x48_crop', 48, 48, true); add_image_size('musart_48x48', 48); add_image_size('musart_90x90_crop', 90, 90, true); add_image_size('musart_90x90', 90); add_image_size('musart_300x300_crop', 300, 300, true); add_image_size('musart_300x300', 300); add_image_size('musart_500x375_crop', 500, 375, true); add_image_size('musart_500x375', 500); add_image_size('musart_600x600_crop', 600, 600, true); add_image_size('musart_600x600', 600); add_image_size('musart_800x600_crop', 800, 600, true); add_image_size('musart_800x600', 800); add_image_size('musart_1280x720_crop', 1280, 720, true); add_image_size('musart_1280x720', 1280); add_image_size('musart_1920x1080_crop', 1920, 1080, true); add_image_size('musart_1920x1080', 1920); // Register the three useful image sizes for use in Add Media modal add_filter('image_size_names_choose', 'musart_custom_sizes'); if (!function_exists('musart_custom_sizes')) : function musart_custom_sizes($sizes) { return array_merge($sizes, array( 'musart_48x48_crop' => '48x48 crop', 'musart_48x48' => '48x48', 'musart_90x90_crop' => '90x90 crop', 'musart_90x90' => '90x90', 'musart_300x300_crop' => '300x300 crop', 'musart_300x300' => '300x300', 'musart_500x375_crop' => '500x375 crop', 'musart_500x375' => '500x375', 'musart_600x600_crop' => '600x600 crop', 'musart_600x600' => '600x600', 'musart_800x600_crop' => '800x600 crop', 'musart_800x600' => '800x600', 'musart_1280x720_crop' => '1280x720 crop', 'musart_1280x720' => '1280x720', 'musart_1920x1080_crop' => '1920x1080 crop', 'musart_1920x1080' => '1920x1080', )); } endif; } endif; add_action('after_setup_theme', 'musart_setup'); if ( ! isset( $content_width ) ) $content_width = 1140; /** * Register widget area. * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ if (!function_exists('musart_widgets_init')) : function musart_widgets_init() { register_sidebar(array( 'name' => esc_html__('Pages Sidebar', 'musart'), 'id' => 'sidebar-page', 'description' => esc_html__('For single pages.', 'musart'), 'before_widget' => '<div id="%1$s" class="nk-widget">', 'after_widget' => '</div>', 'before_title' => '<h4 class="nk-widget-title">', 'after_title' => '</h4>', )); register_sidebar(array( 'name' => esc_html__('Posts Sidebar', 'musart'), 'id' => 'sidebar-post', 'description' => esc_html__('For posts pages.', 'musart'), 'before_widget' => '<div id="%1$s" class="nk-widget">', 'after_widget' => '</div>', 'before_title' => '<h4 class="nk-widget-title">', 'after_title' => '</h4>', )); } endif; add_action('widgets_init', 'musart_widgets_init'); /** * Enqueue scripts and styles. */ if (!function_exists('musart_scripts')) : function musart_scripts() { // Styles wp_enqueue_style('musart-style', get_template_directory_uri() . '/style.css', array(), '1.1.4'); wp_enqueue_style('bootstrap', get_template_directory_uri() . '/assets/bower_components/bootstrap/dist/css/bootstrap.min.css'); wp_enqueue_style('fontawesome', get_template_directory_uri() . '/assets/bower_components/font-awesome/css/all.min.css'); wp_enqueue_style('ionicons', get_template_directory_uri() . '/assets/bower_components/ionicons/css/ionicons.min.css'); // Photoswipe wp_enqueue_style('photoswipe', get_template_directory_uri() . '/assets/bower_components/photoswipe/dist/photoswipe.css'); wp_enqueue_style('photoswipedefault-skin', get_template_directory_uri() . '/assets/bower_components/photoswipe/dist/default-skin/default-skin.css'); // DateTimePicker wp_enqueue_style('datetimepicker', get_template_directory_uri() . '/assets/bower_components/datetimepicker/build/jquery.datetimepicker.min.css'); wp_enqueue_style('musart', get_template_directory_uri() . '/assets/css/musart.css'); //scripts wp_register_script('musart-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true); wp_register_script('musart-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true); // GSAP wp_register_script('tween-max', get_template_directory_uri() . '/assets/bower_components/gsap/src/minified/TweenMax.min.js', '', '', true); wp_register_script('gsap-scroll-to-plugin', get_template_directory_uri() . '/assets/bower_components/gsap/src/minified/plugins/ScrollToPlugin.min.js', array('tween-max'), '', true); // Bootstrap wp_register_script('tether', get_template_directory_uri() . '/assets/bower_components/tether/dist/js/tether.min.js', array('jquery'), '', true); wp_register_script('bootstrap', get_template_directory_uri() . '/assets/bower_components/bootstrap/dist/js/bootstrap.min.js', array('jquery'), '', true); // Sticky Kit wp_register_script('sticky-kit', get_template_directory_uri() . '/assets/bower_components/sticky-kit/dist/sticky-kit.min.js', array('jquery'), '', true); // Jarallax wp_register_script('jarallax', get_template_directory_uri() . '/assets/bower_components/jarallax/dist/jarallax.min.js', '', '', true); wp_register_script('jarallax-video', get_template_directory_uri() . '/assets/bower_components/jarallax/dist/jarallax-video.min.js', array('jarallax'), '', true); // Isotope wp_register_script('isotope', get_template_directory_uri() . '/assets/bower_components/isotope/dist/isotope.pkgd.min.js', array('jquery'), '', true); // Photoswipe wp_register_script('photoswipe', get_template_directory_uri() . '/assets/bower_components/photoswipe/dist/photoswipe.min.js', '', '', true); wp_register_script('photoswipe-ui-default', get_template_directory_uri() . '/assets/bower_components/photoswipe/dist/photoswipe-ui-default.min.js', array('photoswipe'), '', true); // Jquery Validation wp_register_script('jquery-validate', get_template_directory_uri() . '/assets/bower_components/jquery-validation/dist/jquery.validate.min.js', array('jquery'), '', true); // Jquery Countdown + Moment wp_register_script('jquery-countdown', get_template_directory_uri() . '/assets/bower_components/jquery.countdown/dist/jquery.countdown.min.js', array('jquery'), '', true); wp_register_script('moment', get_template_directory_uri() . '/assets/bower_components/moment/min/moment.min.js', '', '', true); wp_register_script('moment-timezone', get_template_directory_uri() . '/assets/bower_components/moment-timezone/builds/moment-timezone-with-data.js', array('moment'), '', true); // Hammer.js wp_register_script('hammer', get_template_directory_uri() . '/assets/bower_components/hammer.js/hammer.min.js', '', '', true); // NanoSroller wp_register_script('nanoscroller', get_template_directory_uri() . '/assets/bower_components/nanoscroller/bin/javascripts/jquery.nanoscroller.min.js', array('jquery'), '', true); // SoundManager2 wp_register_script('soundmanager2', get_template_directory_uri() . '/assets/bower_components/SoundManager2/script/soundmanager2-nodebug-jsmin.js', '', '', true); // DateTimePicker wp_register_script('datetimepicker', get_template_directory_uri() . '/assets/bower_components/datetimepicker/build/jquery.datetimepicker.full.min.js', array('jquery'), '', true); // musart wp_register_script('musart', get_template_directory_uri() . '/assets/js/musart.js', array('jquery', 'tween-max', 'gsap-scroll-to-plugin', 'tether', 'bootstrap', 'sticky-kit', 'jarallax', 'jarallax-video', 'isotope', 'imagesloaded', 'photoswipe', 'photoswipe-ui-default', 'jquery-form', 'jquery-validate', 'jquery-countdown', 'moment', 'moment-timezone', 'hammer', 'nanoscroller', 'soundmanager2', 'datetimepicker'), '1.1.4', true); wp_enqueue_script('musart-init', get_template_directory_uri() . '/assets/js/musart-init.js', array('musart'), '1.1.4', true); $dataInit = array( 'enableSearchAutofocus' => musart_get_theme_mod('enable_search_autofocus'), 'enableFadeBetweenPages' => true, 'scrollToAnchorSpeed' => musart_get_theme_mod('scroll_to_anchor_speed'), 'parallaxSpeed' => 0.8, 'plainVideoIcon' => esc_attr(musart_get_theme_mod('plain_video_icon')), 'gifIcon' => esc_attr(musart_get_theme_mod('gif_icon')), 'secondaryNavbarBackItem' => esc_html__('Back', 'musart'), 'days' => esc_html__('Days', 'musart'), 'hours' => esc_html__('Hours', 'musart'), 'minutes' => esc_html__('Minutes', 'musart'), 'seconds' => esc_html__('Seconds', 'musart'), 'url' => esc_url( admin_url( 'admin-ajax.php' ) ), 'nonce' => wp_create_nonce( 'ajax-nonce' ) ); wp_localize_script('musart-init', 'musartInitOptions', $dataInit); // musart WP wp_enqueue_script('musart-wp', get_template_directory_uri() . '/assets/js/musart-wp.js', array('musart'), '', true); if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } } endif; add_action('wp_enqueue_scripts', 'musart_scripts'); // Fixed Select2 conflict with Advanced Custom Fields. TODO: delete filter later add_filter( 'acf/settings/select2_version', 'musart_fix_acf_select2' ); function musart_fix_acf_select2 () { return 4; } // Prevent Kirki to load shitty FontAwesome script, that breaks some theme things. add_filter('kirki_load_fontawesome', '__return_false'); /** * Admin References */ require get_template_directory() . '/admin/admin.php'; /** * Implement the Custom Header feature. */ require get_template_directory() . '/inc/custom-header.php'; /** * Custom functions that act independently of the theme templates. */ require get_template_directory() . '/inc/extras.php'; /** * Custom template tags for this theme. */ require get_template_directory() . '/inc/template-tags.php'; /** * Load Jetpack compatibility file. */ require get_template_directory() . '/inc/jetpack.php'; /** * Comments walker */ require get_template_directory() . '/inc/comments-walker.php'; /** * Infinite Scroll for Posts */ require get_template_directory() . '/inc/lib/nk-infinite-scroll/nk-infinite-scroll.php'; /** * Inicial custom posts (portfolios, eventsm, playlist etc..) * */ require get_template_directory() . '/inc/custom-posts.php';