-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
executable file
·185 lines (165 loc) · 5.67 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
/**
* Adjust Advanced Custom Fields Options
*/
// Page menu title
if( function_exists('acf_set_options_page_menu') )
{
acf_set_options_page_menu( __('Website opties') );
}
// Page title
if( function_exists('acf_set_options_page_title') )
{
acf_set_options_page_title( __('Website opties') );
}
// Sub page titles
if( function_exists('acf_add_options_sub_page') )
{
acf_add_options_sub_page( 'Opties A' );
acf_add_options_sub_page( 'Opties B' );
acf_add_options_sub_page( 'Opties C' );
}
/**
* Wordpress improvements & fixes
*/
// Disable XMLRPC
add_filter( 'xmlrpc_methods', function( $methods ) {
unset( $methods['pingback.ping'] );
return $methods;
});
// Wordpress Admin > Disable admin bar
add_filter( 'show_admin_bar', '__return_false' );
//remove_action( 'personal_options', '_admin_bar_preferences' );
// Wordpress Admin > Enable support for post-thumbnails
add_theme_support('post-thumbnails');
// Wordpress Admin > Enable menus
add_theme_support( 'menus' );
// Remove container around wp_nav_menu
function my_wp_nav_menu_args( $args = '' ) {
$args['container'] = false;
return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
// Wordpress Admin > Remove junk from head
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
// Wordpress Admin > Page Slug Body Class
function add_slug_body_class( $classes )
{
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
return $classes;
}
add_filter( 'body_class', 'add_slug_body_class' );
// Wordpress Admin > Translate pagination url
function my_custom_page_word() {
global $wp_rewrite;
$wp_rewrite->pagination_base = 'pagina';
}
add_action( 'init', 'my_custom_page_word' );
// Wordpress Admin > Empty search fix
function my_request_filter( $query_vars )
{
if( isset( $_GET['s'] ) && empty( $_GET['s'] ) )
{
$query_vars['s'] = " ";
}
return $query_vars;
}
add_filter( 'request', 'my_request_filter' );
// Wordpress Admin > Remove menus
function remove_menus () {
global $menu;
$restricted = array(__('Comments'));
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
}
}
add_action('admin_menu', 'remove_menus');
// Wordpress Admin > Custom Excerpt length
function excerpt($limit) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).' ...';
} else {
$excerpt = implode(" ",$excerpt).'...';
}
$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
return $excerpt;
}
// Wordpress Admin > Custom Content length
function content($limit) {
$content = explode(' ', get_the_content(), $limit);
if (count($content)>=$limit) {
array_pop($content);
$content = implode(" ",$content).'...';
} else {
$content = implode(" ",$content);
}
$content = preg_replace('/\[.+\]/','', $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return $content;
}
// Wordpress Admin > Add Custom Post Type to WP-ADMIN Right Now Widget
// Ref Link: http://wpsnipp.com/index.php/functions-php/include-custom-post-types-in-right-now-admin-dashboard-widget/
// http://wordpress.org/support/topic/dashboard-at-a-glance-custom-post-types
// http://halfelf.org/2012/my-custom-posttypes-live-in-mu/
function vm_right_now_content_table_end() {
$args = array(
'public' => true ,
'_builtin' => false
);
$output = 'object';
$operator = 'and';
$post_types = get_post_types( $args , $output , $operator );
foreach( $post_types as $post_type ) {
$num_posts = wp_count_posts( $post_type->name );
$num = number_format_i18n( $num_posts->publish );
$text = _n( $post_type->labels->name, $post_type->labels->name , intval( $num_posts->publish ) );
if ( current_user_can( 'edit_posts' ) ) {
$cpt_name = $post_type->name;
}
echo '<li class="post-count"><tr><a href="edit.php?post_type='.$cpt_name.'"><td class="first b b-' . $post_type->name . '"></td>' . $num . ' <td class="t ' . $post_type->name . '">' . $text . '</td></a></tr></li>';
}
$taxonomies = get_taxonomies( $args , $output , $operator );
foreach( $taxonomies as $taxonomy ) {
$num_terms = wp_count_terms( $taxonomy->name );
$num = number_format_i18n( $num_terms );
$text = _n( $taxonomy->labels->name, $taxonomy->labels->name , intval( $num_terms ));
if ( current_user_can( 'manage_categories' ) ) {
$cpt_tax = $taxonomy->name;
}
echo '<li class="post-count"><tr><a href="edit-tags.php?taxonomy='.$cpt_tax.'"><td class="first b b-' . $taxonomy->name . '"></td>' . $num . ' <td class="t ' . $taxonomy->name . '">' . $text . '</td></a></tr></li>';
}
}
add_action( 'dashboard_glance_items' , 'vm_right_now_content_table_end' );
/**
* Shortcode to include custom elements
*/
function include_element( $atts )
{
ob_start();
include('element.'. $atts['type'] .'.php');
$content = ob_get_clean();
return $content;
}
add_shortcode( 'element', 'include_element' );
/**
* All custom functions for this theme are placed in functions.theme.php
*/
// Include theme functions
include_once('functions.theme.php');
?>