/
admin-functions.php
151 lines (119 loc) · 3.77 KB
/
admin-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
<?php
if( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// add_action( 'admin_enqueue_scripts', 'bfg_load_admin_assets' );
/**
* Enqueue admin CSS and JS files.
*
* @since 2.3.2
*/
function bfg_load_admin_assets() {
$use_production_assets = genesis_get_option('bfg_production_on');
$use_production_assets = !empty($use_production_assets);
$assets_version = genesis_get_option('bfg_assets_version');
$assets_version = !empty($assets_version) ? absint($assets_version) : null;
$stylesheet_dir = get_stylesheet_directory_uri();
$src = $use_production_assets ? '/build/css/admin.min.css' : '/build/css/admin.css';
wp_enqueue_style( 'bfg-admin', $stylesheet_dir . $src, array(), $assets_version );
$src = $use_production_assets ? '/build/js/admin.min.js' : '/build/js/admin.js';
wp_enqueue_script( 'bfg-admin', $stylesheet_dir . $src, array('jquery'), $assets_version, true );
}
add_action( 'pre_ping', 'bfg_disable_self_pings' );
/**
* Prevent the child theme from being overwritten by a WordPress.org theme with the same name.
*
* See: http://wp-snippets.com/disable-self-trackbacks/
*
* @since 2.0.0
*/
function bfg_disable_self_pings(&$links) {
foreach ( $links as $l => $link )
if ( 0 === mb_strpos( $link, home_url() ) )
unset($links[$l]);
}
/**
* Change WP JPEG compression (WP default is 90%).
*
* See: http://wpmu.org/how-to-change-jpeg-compression-in-wordpress/
*
* @since 2.0.14
*/
// add_filter( 'jpeg_quality', create_function( '', 'return 80;' ) );
/**
* Add new image sizes.
*
* See: http://wptheming.com/2014/04/features-wordpress-3-9/
*
* @since 2.0.0
*/
// add_image_size( 'desktop-size', 1024, 768, array( 'left', 'top' ) ); // Crop positions are: top, left, right, bottom, center
// add_filter( 'upload_mimes', 'bfg_enable_svg_uploads', 10, 1 );
/**
* Enabled SVG uploads. Note that this could be a security issue, see: https://bjornjohansen.no/svg-in-wordpress.
*
* @since 2.3.38
*/
function bfg_enable_svg_uploads($mimes) {
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
return $mimes;
}
// add_filter( 'image_size_names_choose', 'bfg_image_size_names_choose' );
/**
* Add new image sizes to media size selection menu.
*
* See: http://wpdaily.co/top-10-snippets/
*
* @since 2.0.0
*/
function bfg_image_size_names_choose($sizes) {
$sizes['desktop-size'] = __( 'Desktop', CHILD_THEME_TEXT_DOMAIN );
return $sizes;
}
/*
* Activate the Link Manager
*
* See: http://wordpressexperts.net/how-to-activate-link-manager-in-wordpress-3-5/
*
* @since 2.0.1
*/
// add_filter( 'pre_option_link_manager_enabled', '__return_true' ); // Activate
/*
* Disable pingbacks
*
* See: http://wptavern.com/how-to-prevent-wordpress-from-participating-in-pingback-denial-of-service-attacks
*
* Still having pingback/trackback issues? This post might help: https://wordpress.org/support/topic/disabling-pingbackstrackbacks-on-pages#post-4046256
*
* @since 2.2.3
*/
add_filter( 'xmlrpc_methods', 'bfg_remove_xmlrpc_pingback_ping' );
function bfg_remove_xmlrpc_pingback_ping($methods) {
unset($methods['pingback.ping']);
return $methods;
}
/*
* Disable XML-RPC
*
* See: https://wordpress.stackexchange.com/questions/78780/xmlrpc-enabled-filter-not-called
*
* @since 2.2.12
*/
if( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) exit;
/*
* Automatically remove readme.html (and optionally xmlrpc.php) after a WP core update
*
* @since 2.2.26
*/
add_action( '_core_updated_successfully', 'bfg_remove_files_on_upgrade' );
function bfg_remove_files_on_upgrade() {
if( file_exists(ABSPATH . 'readme.html') )
unlink(ABSPATH . 'readme.html');
if( file_exists(ABSPATH . 'xmlrpc.php') )
unlink(ABSPATH . 'xmlrpc.php');
}
/*
* Force secure cookie
*
* @since 20170608
*/
add_filter( 'secure_signon_cookie', '__return_true' );