-
Notifications
You must be signed in to change notification settings - Fork 0
/
blank-utilities.php
207 lines (190 loc) · 5.39 KB
/
blank-utilities.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
/**
* Some utilities for WordPress for my personal and particolar use
*
* PHP version 7
*
* @category Wordpress_Plugin
* @package Blank_Utilities
* @author Corrado Franco <[email protected]>
* @copyright 2016/2020 Corrado Franco
* @license http://www.gnu.org/licenses/old-licenses/gpl-3.0.html GPL-3
* @link https://github.com/conraid/blank-utilities
*/
/*
Plugin Name: Blank Utilities
Plugin URI: https://github.com/conraid/blank-utilities
Description: Some utilities for WordPress for my personal and particolar use
Version: 2.8.1
Author: Corrado Franco <[email protected]>
Author URI: http://conraid.net
License: GPL-3
Text Domain: utility
*/
/**
* Copyright 2016/2020 Corrado Franco <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/*
* Set version number
*
* @since Blank_Utilitities 2.0
*/
define( 'BLANK_UTILITIES_VERSION', '2.8' );
/**
* Show link manager
*
* @since Blank_Utilities 1.0
*/
add_filter( 'pre_option_link_manager_enabled', '__return_true' );
/**
* Remove version number.
*
* @since Blank_Utilities 1.0
*/
remove_action( 'wp_head', 'wp_generator' );
if ( ! function_exists( 'blankuti_remove_wpversion' ) ) {
/**
* Remove versione string from WordPress tag.
*
* @since Blank_Utilities 1.0
*/
function blankuti_remove_wpversion() {
return '';
}
}
add_filter( 'the_generator', 'blankuti_remove_wpversion' );
if ( ! function_exists( 'blankuti_remove_version_css_js' ) ) {
/**
* Remove version string from any enqueued scripts.
*
* @since Blank_Utilities 0.1
*
* @param string $src WordPress scripts.
*
* @return string src without version.
*/
function blankuti_remove_version_css_js( $src ) {
if ( strpos( $src, 'ver=' ) ) {
$src = remove_query_arg( 'ver', $src );
}
return $src;
}
}
add_filter( 'style_loader_src', 'blankuti_remove_version_css_js', 9999 );
add_filter( 'script_loader_src', 'blankuti_remove_version_css_js', 9999 );
if ( ! function_exists( 'blankuti_login_logo' ) ) {
/**
* Show custom_logo if exists, else get blank logo or /images/logo_login.png
*
* @since Blank_Utilities 1.0
*/
function blankuti_login_logo() {
// Show /images/logo_login.png or blank.
if ( file_exists( get_stylesheet_directory() . '/images/logo_login.png' ) ) {
$blankuti_images = get_stylesheet_directory_uri() . '/images/logo_login.png';
} else {
$blankuti_images = plugins_url( 'images/logo_blank.png', __FILE__ );
}
$blankuti_images = str_replace( 'https://', 'http://', $blankuti_images );
list( $width, $height ) = getimagesize( $blankuti_images );
wp_enqueue_style( 'blankuti_login_css', plugins_url( '/css/login_blank.css', __FILE__ ), '', BLANK_UTILITIES_VERSION );
$blankuti_login_css = "#login h1 a, .login h1 a {
background-image:url(\"$blankuti_images\");
background-repeat: no-repeat;
width: {$width}px;
height: {$height}px;
}";
wp_add_inline_style( 'blankuti_login_css', $blankuti_login_css );
}
}
add_action( 'login_enqueue_scripts', 'blankuti_login_logo' );
if ( ! function_exists( 'blankuti_login_logo_url' ) ) {
/**
* Show home page url
*
* @since Blank_Utilities 1.0
*
* @return string Home Page URL
*/
function blankuti_login_logo_url() {
return home_url();
}
}
add_filter( 'login_headerurl', 'blankuti_login_logo_url' );
if ( ! function_exists( 'blankuti_login_logo_url_title' ) ) {
/**
* Show title blank
*
* @since Blank_Utilities 1.0
*
* @return null title home page url
*/
function blankuti_login_logo_url_title() {
return '';
}
}
add_filter( 'login_headertext', 'blankuti_login_logo_url_title' );
if ( ! function_exists( 'blankuti_no_login_errors' ) ) {
/**
* Not show errors
*
* @since Blank_Utilities 2.3
*
* @return string Clean message.
*/
function blankuti_no_login_errors() {
return __( 'An error occurred. Please try again.' );
}
}
add_filter( 'login_errors', 'blankuti_no_login_errors' );
if ( ! function_exists( 'blankuti_svg_mime_types' ) ) {
/**
* Allowed SVG mime types and file extensions
*
* @since Blank_Utilities 2.5
*
* @param array $mimes mime types.
* @return array $mimes Mime types with svg.
*/
function blankuti_svg_mime_types( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'blankuti_svg_mime_types' );
}
if ( ! function_exists( 'blankuti_display_search_form' ) ) {
/**
* Display standard search form
*
* @since Blank_Utilities 2.6
*/
function blankuti_display_search_form() {
return get_search_form( false );
}
}
add_shortcode( 'display_search_form', 'blankuti_display_search_form' );
/**
* Add shortcode to the widgets text
*
* @since Blank_Utilities 2.6
*/
add_filter( 'widget_text', 'do_shortcode' );