Skip to content

Commit 583ccdf

Browse files
committed
Menus: Add main-menus.
1 parent 808594e commit 583ccdf

5 files changed

Lines changed: 113 additions & 8 deletions

File tree

functions.php

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@
99

1010
require get_stylesheet_directory() . '/includes/utils.php';
1111
require get_stylesheet_directory() . '/includes/settings.php';
12+
require get_stylesheet_directory() . '/includes/overrides.php';
13+
14+
define('CHILD_THEME_URI', get_stylesheet_directory_uri());
15+
define('WHITE_LABEL', true);
16+
17+
function nordcom_load_theme_textdomain() {
18+
load_theme_textdomain('betheme-wordpress-headless-theme', get_stylesheet_directory() .'/languages');
19+
}
20+
add_action('after_setup_theme', 'nordcom_load_theme_textdomain');
21+
22+
23+
if (get_theme_mod("headless_embeded_enable", true)) {
24+
if (!function_exists('nordcom_theme_query_vars')) {
25+
function nordcom_theme_query_vars($vars) {
26+
$vars[] = "iframe";
27+
return $vars;
28+
}
29+
}
30+
add_filter('query_vars', 'nordcom_theme_query_vars');
31+
get_query_var('iframe');
32+
}
1233

1334
if (!function_exists('nordcom_theme_head')) {
1435
function nordcom_theme_head() {
@@ -31,13 +52,61 @@ function nordcom_theme_enqueue_styles() {
3152
}
3253
add_action('wp_enqueue_scripts', 'nordcom_theme_enqueue_styles');
3354

34-
if (get_theme_mod("headless_embeded_enable", true)) {
35-
if (!function_exists('nordcom_theme_query_vars')) {
36-
function nordcom_theme_query_vars($vars) {
37-
$vars[] = "iframe";
38-
return $vars;
55+
if (!function_exists('nordcom_disable_builtin')) {
56+
// Based on https://dykraf.com/blog/wordpress-set-up-for-different-home-url-and-site-url
57+
function nordcom_disable_builtin() {
58+
remove_action('wp_head', 'rest_output_link_wp_head');
59+
remove_action('wp_head', 'wp_resource_hints', 2);
60+
remove_action('wp_head', 'print_emoji_detection_script', 7);
61+
remove_action('wp_head', 'rsd_link');
62+
remove_action('wp_head', 'wlwmanifest_link');
63+
remove_action('admin_print_scripts', 'print_emoji_detection_script');
64+
remove_action('wp_print_styles', 'print_emoji_styles');
65+
remove_action('admin_print_styles', 'print_emoji_styles');
66+
remove_filter('the_content_feed', 'wp_staticize_emoji');
67+
remove_filter('comment_text_rss', 'wp_staticize_emoji');
68+
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
69+
remove_action('wp_head', 'wp_generator');
70+
71+
function nordcom_disable_emojis_tinymce( $plugins ) {
72+
if (is_array($plugins))
73+
return array_diff($plugins, array('wpemoji'));
74+
75+
return array();
76+
}
77+
add_filter('tiny_mce_plugins', 'nordcom_disable_emojis_tinymce');
78+
79+
function nordcom_disable_emojis_dns( $urls, $relation_type ) {
80+
if ('dns-prefetch' === $relation_type) {
81+
/** This filter is documented in wp-includes/formatting.php */
82+
$emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' );
83+
$urls = array_diff( $urls, array( $emoji_svg_url ) );
84+
}
85+
86+
return $urls;
3987
}
88+
add_filter( 'wp_resource_hints', 'nordcom_disable_emojis_dns', 10, 2 );
89+
}
90+
}
91+
add_action('init', 'nordcom_disable_builtin');
92+
93+
if (!function_exists('nordcom_dequeue_builtin')) {
94+
function nordcom_dequeue_builtin(){
95+
wp_dequeue_style('wp-block-library');
96+
wp_dequeue_style('wp-block-library-theme');
4097
}
41-
add_filter('query_vars', 'nordcom_theme_query_vars');
42-
get_query_var('iframe');
4398
}
99+
add_action('wp_enqueue_scripts', 'nordcom_dequeue_builtin');
100+
101+
function nordcom_disable_admin_menus() {
102+
if(is_admin()){
103+
remove_menu_page('edit.php?post_type=client');
104+
remove_menu_page('edit.php?post_type=offer');
105+
remove_menu_page('edit.php?post_type=slide');
106+
remove_menu_page('edit.php?post_type=testimonial');
107+
remove_menu_page('edit.php?post_type=layout');
108+
remove_menu_page('edit.php?post_type=template');
109+
}
110+
}
111+
112+
add_action('admin_menu', 'nordcom_disable_admin_menus', 999);

functions/theme-menu.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Menu handling, functions and filters.
4+
*
5+
* @package @nordcom/betheme-wordpress-headless-theme
6+
* @author Nordcom Group Inc.
7+
* @link https://nordcom.io/
8+
*/
9+
10+
// Register headless menus
11+
register_nav_menu('authenticated-main-menu', __('Authenticated Main Menu', 'betheme-wordpress-headless-theme'));
12+
register_nav_menu('unauthenticated-main-menu', __('Unauthenticated Main Menu', 'betheme-wordpress-headless-theme'));
13+
14+
// Functions we're required to stub
15+
function mfn_wp_nav_menu() { return null; }
16+
function mfn_wp_page_menu() { return null; }
17+
function mfn_wp_mobile_menu() { return null; }
18+
function mfn_wp_split_menu() { return null; }
19+
function mfn_wp_overlay_menu() { return null; }
20+
function mfn_wp_secondary_menu() { return null; }
21+
function mfn_wp_lang_menu() { return null; }
22+
function mfn_wp_social_menu() { return null; }
23+
function mfn_wp_social_menu_bottom() { return null; }
24+
function mfn_wp_accessibility_skip_links() { return null; }

header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
if (is_embeded_mode()) {
1818
if ($target) {
19-
header("Content-Security-Policy: frame-ancestors 'self' {$target};");
19+
header("Content-Security-Policy: frame-ancestors 'self' http://localhost:3000 {$target};");
2020
}
2121

2222
ob_start();

includes/overrides.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* General functions to override
4+
*
5+
* @package @nordcom/betheme-wordpress-headless-theme
6+
* @author Nordcom Group Inc.
7+
* @link https://nordcom.io/
8+
*/
9+
10+
function mfn_seo() {
11+
echo '<meta name="robots" content="noindex"/>' . "\n";
12+
}

languages/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)