-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
113 lines (96 loc) · 3.41 KB
/
functions.php
File metadata and controls
113 lines (96 loc) · 3.41 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/**
* Main functions file.
* This file contains all functions to add theme support and remove default WordPress functionality.
*/
/**
* Sets up the main theme functionality (menus, html5, featured-images etc...).
* @return void
*/
function twx_theme_setup() {
// Adding Menu Support.
add_theme_support( 'menus' );
// Support for HTML5 Markup.
add_theme_support( 'html5', ['search-form', 'comment-form', 'comment-list', 'gallery', 'caption'] );
// Adding Featured Image Support.
add_theme_support( 'post-thumbnails', ['post'] );
// Remove admin bar for non-administrators.
if( ! current_user_can( 'manage_options' ) && ! is_admin() ) show_admin_bar( false );
// if( function_exists( 'acf_add_options_page' ) ) acf_add_options_page([
// 'menu_title' => 'Sitewide Options',
// 'position' => 4.5
// ]);
//Add shortcode button to main WP editor
add_filter( 'mce_external_plugins', 'twx_register_tinymce_javascript' );
add_filter( 'mce_buttons', 'twx_register_mce_button' );
}
add_action( 'after_setup_theme', 'twx_theme_setup' );
add_action( 'init', 'cp_change_post_object' );
// Change dashboard Posts to News
function cp_change_post_object() {
$get_post_type = get_post_type_object('post');
$labels = $get_post_type->labels;
$labels->name = 'Resources';
$labels->singular_name = 'Resource';
$labels->add_new = 'Add Resource';
$labels->add_new_item = 'Add Resource';
$labels->edit_item = 'Edit Resource';
$labels->new_item = 'Resource';
$labels->view_item = 'View Resource';
$labels->search_items = 'Search Resources';
$labels->not_found = 'No Resources found';
$labels->not_found_in_trash = 'No Resources found in Trash';
$labels->all_items = 'All Resources';
$labels->menu_name = 'Resources';
$labels->name_admin_bar = 'Resource';
}
// Add new WYSIWYG editor buttons to insert custom shortcode examples:
function twx_register_tinymce_javascript( $plugins ) {
$plugins['twx_btn_shortcode'] = get_stylesheet_directory_uri() . '/dist/js/twx-mce-shortcodes-plugin.js';
$plugins['twx_modalbtn_shortcode'] = get_stylesheet_directory_uri() . '/dist/js/twx-mce-shortcodes-plugin.js';
return $plugins;
}
function twx_register_mce_button( $buttons ) {
$buttons = array_merge( $buttons, [
'twx_btn_shortcode',
'twx_modalbtn_shortcode'
] );
return $buttons;
}
/**
* Removes customize option from admin bar.
* @return void
*/
function twx_remove_admin_bar_customize() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu( 'customize' );
}
add_action( 'wp_before_admin_bar_render', 'twx_remove_admin_bar_customize' );
/**
* Adds "Kitchen Sink" to admin bar.
* Don't forget to make a Kitchen Sink page!
* And to noindex it!
* @return void
*/
add_action( 'admin_bar_menu', 'twx_add_toolbar_items', 100 );
function twx_add_toolbar_items( $admin_bar ){
$admin_bar->add_menu([
'id' => 'kitchen-sink',
'title' => 'Kitchen Sink',
'href' => home_url( '/kitchen-sink/' ),
'meta' => ['title' => __( 'Kitchen Sink' )]
]);
}
/**
* Including other theme functionality in separate files.
*/
require_once( 'lib/helpers.php' );
require_once( 'lib/filters.php' );
require_once( 'lib/post-types.php' );
require_once( 'lib/taxonomies.php' );
require_once( 'lib/widgets.php' );
require_once( 'lib/scripts-styles.php' );
require_once( 'lib/shortcodes.php' );
require_once( 'lib/forms.php' );
require_once( 'lib/ajax.php' );
if( is_admin() ) require_once( 'lib/admin/functions.php' );