/** * Theme Functions * * @package arkhitekton * @author NeuronThemes * @link http://neuronthemes.com */ /** * Global Variables * * Defining global variables to make * usage easier. */ define('ARKHITEKTON_THEME_DIR', get_template_directory()); define('ARKHITEKTON_THEME_URI', get_template_directory_uri()); define('ARKHITEKTON_THEME_STYLESHEET', get_stylesheet_uri()); define('ARKHITEKTON_THEME_PLACEHOLDER', get_template_directory_uri() . '/assets/images/placeholder.png'); define('ARKHITEKTON_THEME_NAME', 'arkhitekton'); define('ARKHITEKTON_THEME_VERSION', wp_get_theme()->get('Version')); /** * Content Width * * Maximum content width is set at 1920, * larger images or videos will be cropped * to that resolution. */ !isset($content_width) ? $content_width = 1920 : ''; /** * Text Domain * * Makes theme available for translation, * translations can be found in the /languages/ directory. */ load_theme_textdomain('arkhitekton', ARKHITEKTON_THEME_DIR . '/languages'); // Action to call init add_action('after_setup_theme', 'arkhitekton_init'); /** * Init * * Global function which adds theme support, * register nav menus and call actions for * different php, js and css files. */ function arkhitekton_init() { // Theme Support add_theme_support('post-thumbnails'); add_theme_support('automatic-feed-links'); add_theme_support('title-tag'); /** * WooCommerce Theme Support * * Theme fully supports plugin WooCommerce * also it's features in single product * as zoom, lightbox and slider. */ if (class_exists('WooCommerce')) { add_theme_support('woocommerce'); add_theme_support('wc-product-gallery-zoom'); add_theme_support('wc-product-gallery-lightbox'); add_theme_support('wc-product-gallery-slider'); } // Image Sizes $arkhitekton_general_image_sizes = get_theme_mod('general_image_sizes'); if ($arkhitekton_general_image_sizes) { $index = 1; foreach ($arkhitekton_general_image_sizes as $image_size) { add_image_size('arkhitekton_image_size_' . $index, isset($image_size['image_size_width']) ? $image_size['image_size_width'] : '', isset($image_size['image_size_height']) ? $image_size['image_size_height'] : 9999, true); $index++; } } // Include custom files include(ARKHITEKTON_THEME_DIR . '/includes/functions/neuron-functions.php'); include(ARKHITEKTON_THEME_DIR . '/includes/functions/style-functions.php'); include(ARKHITEKTON_THEME_DIR . '/includes/admin/extra.php'); include_once(ARKHITEKTON_THEME_DIR . '/includes/tgm/class-tgm-plugin-activation.php'); include_once(ARKHITEKTON_THEME_DIR . '/includes/admin/acf/fields.php'); get_theme_mod('custom_fields_panel', '2') == '2' ? define('ACF_LITE' , true) : ''; // Theme actions within init function add_action('tgmpa_register', 'arkhitekton_plugins'); add_action('wp_enqueue_scripts', 'arkhitekton_external_css'); add_action('wp_enqueue_scripts', 'arkhitekton_external_js'); add_action('admin_enqueue_scripts', 'arkhitekton_add_extra_scripts'); add_action('widgets_init', 'arkhitekton_widgets_init'); // Theme Filters if (class_exists('Kirki')){ add_filter('kirki_telemetry', '__return_false'); } // Register Menus register_nav_menus( array( 'main-menu' => esc_html__('Main Menu', 'arkhitekton') ) ); } /** * TGMPA * * An addon which helps theme to install * and activate different plugins. */ function arkhitekton_plugins() { $plugins = array( array( 'name' => esc_html__('Advanced Custom Fields', 'arkhitekton'), 'slug' => 'advanced-custom-fields', 'required' => true ), array( 'name' => esc_html__('Elementor', 'arkhitekton'), 'slug' => 'elementor', 'required' => true ), array( 'name' => esc_html__('Neuron Core', 'arkhitekton'), 'slug' => 'neuron-core-arkhitekton', 'source' => get_template_directory() . '/includes/plugins/neuron-core-arkhitekton.zip', 'required' => true, ), array( 'name' => esc_html__('Revolution Slider', 'arkhitekton'), 'slug' => 'revslider', 'source' => get_template_directory() . '/includes/plugins/revslider.zip', 'required' => false ), array( 'name' => esc_html__('WooCommerce', 'arkhitekton'), 'slug' => 'woocommerce', 'required' => false ), array( 'name' => esc_html__('One Click Demo Import', 'arkhitekton'), 'slug' => 'one-click-demo-import', 'required' => false ), array( 'name' => esc_html__('Contact Form 7', 'arkhitekton'), 'slug' => 'contact-form-7', 'required' => false ) ); $config = array( 'id' => 'tgmpa', 'default_path' => '', 'menu' => 'tgmpa-install-plugins', 'parent_slug' => 'themes.php', 'capability' => 'edit_theme_options', 'has_notices' => true, 'dismissable' => true, 'dismiss_msg' => '', 'is_automatic' => false, 'message' => '' ); tgmpa($plugins, $config); } // External CSS function arkhitekton_external_css() { wp_enqueue_style('arkhitekton-main-style', ARKHITEKTON_THEME_URI . '/assets/styles/arkhitekton.css', false, ARKHITEKTON_THEME_VERSION, null); wp_enqueue_style('magnific-popup', ARKHITEKTON_THEME_URI . '/assets/styles/magnific-popup.css', false, ARKHITEKTON_THEME_VERSION, null); wp_enqueue_style('owl-carousel', ARKHITEKTON_THEME_URI . '/assets/styles/owl.carousel.min.css', false, ARKHITEKTON_THEME_VERSION, null); wp_enqueue_style('perfect-scrollbar', ARKHITEKTON_THEME_URI . '/assets/styles/perfect-scrollbar.css', false, ARKHITEKTON_THEME_VERSION, null); wp_enqueue_style('arkhitekton-wp-style', ARKHITEKTON_THEME_STYLESHEET); wp_enqueue_style('arkhitekton-fonts', arkhitekton_fonts_url(), array(), ARKHITEKTON_THEME_VERSION); // Custom Style and Fonts if (function_exists('neuron_color_lightness') && function_exists('neuron_hexToRgb')) { wp_add_inline_style('arkhitekton-wp-style', arkhitekton_custom_style()); } wp_add_inline_style('arkhitekton-wp-style', arkhitekton_body_offset()); } // External Javascript function arkhitekton_external_js() { if (!is_admin()) { wp_enqueue_script('isotope', ARKHITEKTON_THEME_URI . '/assets/scripts/isotope.pkgd.min.js', array('jquery'), ARKHITEKTON_THEME_VERSION, TRUE); wp_enqueue_script('packery-mode', ARKHITEKTON_THEME_URI . '/assets/scripts/packery-mode.pkgd.min.js', array('jquery'), ARKHITEKTON_THEME_VERSION, TRUE); wp_enqueue_script('magnific-popup', ARKHITEKTON_THEME_URI . '/assets/scripts/jquery.magnific-popup.min.js', array('jquery'), ARKHITEKTON_THEME_VERSION, TRUE); wp_enqueue_script('owl-carousel', ARKHITEKTON_THEME_URI . '/assets/scripts/owl.carousel.min.js', array('jquery'), ARKHITEKTON_THEME_VERSION, TRUE); wp_enqueue_script('typed', ARKHITEKTON_THEME_URI . '/assets/scripts/typed.min.js', array('jquery'), ARKHITEKTON_THEME_VERSION, TRUE); wp_enqueue_script('wow', ARKHITEKTON_THEME_URI . '/assets/scripts/wow.min.js', array('jquery'), ARKHITEKTON_THEME_VERSION, TRUE); wp_enqueue_script('theia-sticky-sidebar', ARKHITEKTON_THEME_URI . '/assets/scripts/theia-sticky-sidebar.js', array('jquery'), ARKHITEKTON_THEME_VERSION, TRUE); wp_enqueue_script('headroom', ARKHITEKTON_THEME_URI . '/assets/scripts/headroom.js', array('jquery'), ARKHITEKTON_THEME_VERSION, TRUE); wp_enqueue_script('headroom-zepto', ARKHITEKTON_THEME_URI . '/assets/scripts/jQuery.headroom.js', array('jquery'), ARKHITEKTON_THEME_VERSION, TRUE); wp_enqueue_script('perfect-scrollbar', ARKHITEKTON_THEME_URI . '/assets/scripts/perfect-scrollbar.min.js', array('jquery'), ARKHITEKTON_THEME_VERSION, TRUE); wp_enqueue_script('arkhitekton-scripts', ARKHITEKTON_THEME_URI . '/assets/scripts/arkhitekton.js', array('jquery'), ARKHITEKTON_THEME_VERSION, TRUE); is_singular() ? wp_enqueue_script('comment-reply') : ''; } } // Enqueue Extra Scripts function arkhitekton_add_extra_scripts() { wp_enqueue_style('arkhitekton-admin-style', ARKHITEKTON_THEME_URI . '/includes/admin/style.css', false, ARKHITEKTON_THEME_VERSION, null); wp_enqueue_script('arkhitekton-admin-script', ARKHITEKTON_THEME_URI . '/includes/admin/script.js', array('jquery'), ARKHITEKTON_THEME_VERSION, TRUE); } // Init Widgets function arkhitekton_widgets_init() { $arkhitekton_sidebars = [ [ 'name' => esc_html__('Main Sidebar', 'arkhitekton'), 'description' => esc_html__('Widgets on this sidebar are displayed in Blog Page.', 'arkhitekton'), 'id' => 'main-sidebar' ], [ 'name' => esc_html__('Shop Sidebar', 'arkhitekton'), 'description' => esc_html__('Widgets on this sidebar are displayed in Shop Pages.', 'arkhitekton'), 'id' => 'shop-sidebar', 'condition' => class_exists('WooCommerce') ], [ 'name' => esc_html__('Footer Sidebar 1', 'arkhitekton'), 'description' => esc_html__('Widgets on this sidebar are placed on the first column of footer.', 'arkhitekton'), 'id' => 'sidebar-footer-1' ], [ 'name' => esc_html__('Footer Sidebar 2', 'arkhitekton'), 'description' => esc_html__('Widgets on this sidebar are placed on the second column of footer.', 'arkhitekton'), 'id' => 'sidebar-footer-2' ], [ 'name' => esc_html__('Footer Sidebar 3', 'arkhitekton'), 'description' => esc_html__('Widgets on this sidebar are placed on the third column of footer.', 'arkhitekton'), 'id' => 'sidebar-footer-3' ], [ 'name' => esc_html__('Footer Sidebar 4', 'arkhitekton'), 'description' => esc_html__('Widgets on this sidebar are placed on the fourth column of footer.', 'arkhitekton'), 'id' => 'sidebar-footer-4' ], [ 'name' => esc_html__('Footer Sidebar 5', 'arkhitekton'), 'description' => esc_html__('Widgets on this sidebar are placed on the fifth column of footer.', 'arkhitekton'), 'id' => 'sidebar-footer-5' ], [ 'name' => esc_html__('Footer Sidebar 6', 'arkhitekton'), 'description' => esc_html__('Widgets on this sidebar are placed on the sixth column of footer.', 'arkhitekton'), 'id' => 'sidebar-footer-6' ], [ 'name' => esc_html__('Sliding Bar Sidebar', 'arkhitekton'), 'description' => esc_html__('Widgets on this sidebar are placed on the sliding bar of header.', 'arkhitekton'), 'id' => 'sliding-bar', ], ]; if (get_theme_mod('general_sidebars')) { foreach (get_theme_mod('general_sidebars') as $sidebar) { $arkhitekton_sidebars[] = [ 'name' => esc_html__($sidebar['sidebar_title'], 'arkhitekton'), 'description' => esc_html__($sidebar['sidebar_description'], 'arkhitekton'), 'id' => strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $sidebar['sidebar_title']))), ]; } } foreach ($arkhitekton_sidebars as $sidebar) { $sidebar['condition'] = isset($sidebar['condition']) ? $sidebar['condition'] : true; if ($sidebar['condition'] == false) { continue; } register_sidebar( [ 'name' => esc_html($sidebar['name']), 'description' => esc_html($sidebar['description']), 'id' => esc_attr($sidebar['id']), 'before_widget' => '
', 'before_title' => ' ' ] ); } } /** * Mega Menu Classes * * Add classes to the menu item when * mega menu option is clicked. */ add_filter('wp_nav_menu_objects', 'arkhitekton_mega_menu_class', 10, 2); function arkhitekton_mega_menu_class($items, $args) { foreach ($items as $item) { // Activate if (get_field('mega_menu', $item)) { $item->classes[] = 'm-mega-menu'; } // Columns switch (get_field('mega_menu_columns', $item)) { case '1': $item->classes[] = 'm-mega-menu--two'; break; case '2': $item->classes[] = 'm-mega-menu--three'; break; case '3': $item->classes[] = 'm-mega-menu--four'; break; case '4': $item->classes[] = 'm-mega-menu--five'; break; } // Unclickable if (get_field('menu_unclickable', $item)) { $item->classes[] = 'disabled'; } } return $items; } /** * Remove Mega Menu Classes * * Remove clases from the menu * items, useful for builder. */ function arkhitekton_remove_mega_menu_class($items, $args) { foreach ($items as $item) { foreach($item->classes as $key => $class) { if(strpos($class, 'm-mega-menu') !== false) { unset($item->classes[$key]); } } } return $items; } /** * Rewrite the ACF functions incase ACF fails to activate */ if (!function_exists('get_field') && !is_admin() && !function_exists('get_sub_field')) { function get_field($field_id, $post_id = null) { return null; } function get_sub_field($field_id, $post_id = null){ return null; } } /** * Portfolio Arguments * * Rewrite the url of portfolio * and remove the archive page. */ add_filter('portfolioposttype_args', 'arkhitekton_change_portfolio_labels'); function arkhitekton_change_portfolio_labels(array $args) { if (get_theme_mod('portfolio_prefix')) { $args['rewrite'] = array('slug' => get_theme_mod('portfolio_prefix')); } $args['has_archive'] = false; return $args; } /** * Register Fonts */ function arkhitekton_fonts_url() { $font_url = ''; if ('off' !== _x('on', 'Google font: on or off', 'arkhitekton')) { $font_url = add_query_arg('family', urlencode('Poppins:300,400,400i,500,600'), '//fonts.googleapis.com/css'); } return $font_url; } /** * Custom Template */ function arkhitekton_get_custom_template($id) { if (!class_exists('Elementor\Plugin')) { return; } if (empty($id)) { return; } $content = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display($id, true); return $content; } /** * Body Offset */ function arkhitekton_body_offset() { if (arkhitekton_inherit_option('general_body_offset', 'body_offset', '2') == '2' || is_search()) { return; } $arkhitekton_offset_output = []; $arkhitekton_body_offset_padding = [ 'theme-options' => get_theme_mod('body_offset_padding'), 'acf' => [ 'padding-left' => get_field('general_body_offset_padding_left', get_queried_object()), 'padding-right' => get_field('general_body_offset_padding_right', get_queried_object()) ] ]; if (get_field('general_body_offset', get_queried_object()) == '2') { $arkhitekton_body_offset_values = $arkhitekton_body_offset_padding['acf']; } else { $arkhitekton_body_offset_values = $arkhitekton_body_offset_padding['theme-options']; } $arkhitekton_offset_output[] = isset($arkhitekton_body_offset_values['padding-left']) && $arkhitekton_body_offset_values['padding-left'] != 0 ? 'padding-left:' . $arkhitekton_body_offset_values['padding-left'] : ''; $arkhitekton_offset_output[] = isset($arkhitekton_body_offset_values['padding-right']) && $arkhitekton_body_offset_values['padding-right'] != 0 ? 'padding-right:' . $arkhitekton_body_offset_values['padding-right'] : ''; // Offset Breakpoint if (arkhitekton_inherit_option('general_body_offset_breakpoint', 'body_offset_breakpoint', '1') == '1') { $arkhitekton_offset_media_query = '1039px'; } else { $arkhitekton_offset_media_query = '745px'; } return $arkhitekton_offset_output ? '@media (min-width: '. $arkhitekton_offset_media_query .'){ body, .l-primary-header--sticky .l-primary-header {' . implode('; ', $arkhitekton_offset_output) . '}}' : ''; } /** * Demo Importer * * Import the content, widgets and * the customizer settings via the * plugin one click demo importer. */ add_filter('pt-ocdi/import_files', 'arkhitekton_ocdi_import_files'); function arkhitekton_ocdi_import_files() { return array( array( 'import_file_name' => esc_html__('Main Demo', 'arkhitekton'), 'categories' => array('Demo'), 'import_file_url' => 'https://neuronthemes.com/arkhitekton/demo-importer/content.xml', 'import_widget_file_url' => 'https://neuronthemes.com/arkhitekton/demo-importer/widgets.json', 'import_customizer_file_url' => 'https://neuronthemes.com/arkhitekton/demo-importer/customizer.dat', 'import_notice' => esc_html__('Everything that is listed in our demo will be imported.', 'arkhitekton'), ), array( 'import_file_name' => esc_html__('Header Templates', 'arkhitekton'), 'categories' => array('Templates'), 'import_file_url' => 'https://neuronthemes.com/arkhitekton/demo-importer/header-templates.xml', 'import_preview_image_url' => ARKHITEKTON_THEME_URI . '/assets/images/header-templates.png', 'import_notice' => esc_html__('Only the Header Templates will be imported.', 'arkhitekton'), ), ); } /** * After Import Setup * * Set the Classic Home Page as front * page and assign the menu to * the main menu location. */ add_action('pt-ocdi/after_import', 'arkhitekton_ocdi_after_import_setup'); function arkhitekton_ocdi_after_import_setup() { // Main Menu $main_menu = get_term_by('name', 'Main Menu', 'nav_menu'); if ($main_menu) { set_theme_mod('nav_menu_locations', array('main-menu' => $main_menu->term_id)); } // Front Page $front_page_id = get_page_by_title('Design Agency'); if ($front_page_id) { update_option('page_on_front', $front_page_id->ID); update_option('show_on_front', 'page'); } // Blog Page $blog_page_id = get_page_by_title('Blog'); if ($blog_page_id) { update_option('page_for_posts', $blog_page_id->ID); } } add_filter('woocommerce_gallery_thumbnail_size', 'arkhitekton_woocommerce_gallery_thumbnail_size'); function arkhitekton_woocommerce_gallery_thumbnail_size() { return 'medium'; }