First create global variables (in functions.php or as a mu-plugin):
<?php
/*
* CUSTOM GLOBAL VARIABLES
*/
function wtnerd_global_vars() {
First create global variables (in functions.php or as a mu-plugin):
<?php
/*
* CUSTOM GLOBAL VARIABLES
*/
function wtnerd_global_vars() {
<?php | |
$attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image') ); | |
if ( $attachments ) { | |
// do conditional stuff here | |
} |
# | |
# Auth filter /etc/fail2ban/filter.d/nginx-auth.conf: | |
# | |
# Blocks IPs that makes too much accesses to the server | |
# | |
[Definition] | |
failregex = ^<HOST> -.*"(GET|POST).*HTTP.*" | |
ignoreregex = |
user web; | |
# One worker process per CPU core. | |
worker_processes 8; | |
# Also set | |
# /etc/security/limits.conf | |
# web soft nofile 65535 | |
# web hard nofile 65535 | |
# /etc/default/nginx |
<?php | |
$array = array( | |
0, | |
'', | |
false, | |
1, | |
'0' | |
); | |
print_r( $array ); | |
print_r( array_filter( $array, 'strlen' ) ); |
<IfModule mod_headers.c> | |
Header add Link "</service-worker.js>; rel=preload;" | |
Header add Link "</favicon-16x16.png>; rel=preload;" | |
Header add Link "</favicon-96x96.png>; rel=preload;" | |
Header add Link "</android-chrome-192x192.png>; rel=preload;" | |
Header add Link "<https://cdn.ampproject.org/v0.js>; rel=preload; crossorigin" | |
Header add Link "<https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface>; rel=preload; crossorigin" | |
Header add Link "<https://cdn.ampproject.org/v0/amp-analytics-0.1.js>; rel=preload; crossorigin" | |
Header add Link "<https://cdn.ampproject.org/v0/amp-install-serviceworker-0.1.js>; rel=preload; crossorigin" | |
Header add Link "<https://fonts.gstatic.com/s/abrilfatface/v8/X1g_KwGeBV3ajZIXQ9VnDgYWpCd0FFfjqwFBDnEN0bM.woff2>; rel=preload; crossorigin" |
<?php | |
//Insert ads after second paragraph of single post content. | |
add_filter( 'the_content', 'prefix_insert_post_ads' ); | |
function prefix_insert_post_ads( $content ) { | |
$ad_code = '<div>Ads code goes here</div>'; | |
if ( is_single() && ! is_admin() ) { | |
return prefix_insert_after_paragraph( $ad_code, 2, $content ); | |
} | |
return $content; | |
} |
<?php | |
/** | |
* Require a featured image to be set before a post can be published. | |
*/ | |
add_filter( 'wp_insert_post_data', function ( $data, $postarr ) { | |
$post_id = $postarr['ID']; | |
$post_status = $data['post_status']; |