-
Notifications
You must be signed in to change notification settings - Fork 7
/
functions.php
90 lines (81 loc) · 3.31 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
require_once 'class-tgm-plugin-activation.php';
/**
* Enqueues the required scripts for the theme.
*/
function enqueue_scripts() {
wp_register_script( 'jquery', 'https://code.jquery.com/jquery-1.12.4.js', array(), NULL, true );
wp_register_script( 'react_theme', trailingslashit( get_template_directory_uri() ) . 'assets/js/index.js', ['jquery'], NULL, true );
wp_register_style( 'bootstrap_css', trailingslashit( get_template_directory_uri() ) . 'assets/css/bootstrap.min.css', NULL );
$translation_array = array(
'constants' => array(
'SITE_TITLE' => get_bloginfo( 'name' ),
'SITE_DESCRIPTION' => get_bloginfo( 'description' ),
'SITE_URL' => get_bloginfo( 'url' ),
'WP_VERSION' => get_bloginfo( 'version' ),
'API' => '/wp-json/wp/v2/',
'MENU_API' => '/wp-json/wp-api-menus/v2/',
'POSTS_PER_PAGE' => get_option( 'posts_per_page' ),
'FRONT_PAGE' => get_option( 'page_on_front' )
)
);
wp_localize_script( 'react_theme', 'phpData', $translation_array );
wp_enqueue_script( 'react_theme' );
wp_enqueue_style( 'react_theme_css', trailingslashit( get_template_directory_uri() ) . 'style.css', ['bootstrap_css' ] );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts' );
/**
* Sets the permalink structure required by the theme. This can not be changed by the user otherwise the theme might break.
*/
function set_permalink(){
global $wp_rewrite;
$wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
}
add_action('init', 'set_permalink');
/**
* Registering Navigation Menu and Sidebar for the theme.
*/
function blackhawk_setup() {
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'blackhawk' ),
) );
register_sidebar( array(
'name' => __( 'Sidebar', 'blackhawk' ),
'id' => 'sidebar-1',
'description' => __( 'Sidebar to Display all the Widgets', 'blackhawk' ),
'before_widget' => '<section id="%1$s" class="widget %2$s clearfix">',
'after_widget' => '</section>'
) );
}
add_action( 'after_setup_theme', 'blackhawk_setup' );
/**
* Prompts for downloading and installing the required plugins on which the theme depends upon.
*/
function blackhawk_register_required_plugins() {
$plugins = array(
array(
'name' => 'WP Rest API Sidebars',
'slug' => 'wp-rest-api-sidebars',
'required' => true,
),
array(
'name' => 'WP API Menus',
'slug' => 'wp-api-menus',
'required' => true,
),
);
$config = array(
'id' => 'blackhawk', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'parent_slug' => 'themes.php', // Parent menu slug.
'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa($plugins, $config);
}
add_action( 'tgmpa_register', 'blackhawk_register_required_plugins' );