Skip to content

Instantly share code, notes, and snippets.

View WordPress-Handbuch's full-sized avatar

WordPress-Handbuch WordPress-Handbuch

View GitHub Profile
@WordPress-Handbuch
WordPress-Handbuch / listing-17-3.htaccess
Created March 11, 2019 12:57
Disallow XMLRPC call in WordPress 5 by denying access through .htaccess configuration
<Files xmlrpc.php>
order allow,deny
deny from all
</Files>
@WordPress-Handbuch
WordPress-Handbuch / listing-17-2.php
Created March 11, 2019 12:55
Removes WordPress 5 RPC service itself and the <link> from the HTML header
add_filter( 'xmlrpc_enabled', '__return_false' );
remove_action('wp_head', 'rsd_link');
@WordPress-Handbuch
WordPress-Handbuch / listing-17-1.sh
Created March 11, 2019 09:46
Four WP-CLI commands to install and test the tool, and to test the checksums of the WordPress core and all plugins
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
php wp-cli.phar core verify-checksums
php wp-cli.phar plugin verify-checksums --all
@WordPress-Handbuch
WordPress-Handbuch / listing-16-5.php
Created March 10, 2019 12:42
PHP/HTML code fragment to include Yoast SEO's breadcrumbs into any template (e. g. page.php or single.php)
<?php
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb( '<p id="breadcrumbs">','</p>' );
}
?>
@WordPress-Handbuch
WordPress-Handbuch / listing-16-4.php
Created March 7, 2019 13:24
404 handler for WordPress search showing posts alternatives related to the page not found, and a search form
<?php
global $wp;
$urlquery = $wp->request;
$urlquery = preg_replace("/(\.*)(html|htm|php)$/","",$urlquery);
$parts = explode('/', $urlquery);
$keyword = end($parts);
echo 'Mal sehen, ob es zum Thema "' . $keyword . '" Blogbeiträge gibt...';
$query = new WP_Query( array( 's' => $keyword ) );
@WordPress-Handbuch
WordPress-Handbuch / listing-16-3.php
Last active March 7, 2019 07:38
Code example to output cached and uncached content through the fragment cache in W3 Total Cache (WordPress plugin)
<?php
if (!defined('W3TC_DYNAMIC_SECURITY')) {
define('W3TC_DYNAMIC_SECURITY', 'geheimesgeheimnis');
}
?>
<!--mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> echo 'Gecachter Inhalt: ' . date("Y-m-d", time()); -->
<?php echo 'Live-Inhalt: ' . date("Y-m-d", time()); ?>
<!--/mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> -->
@WordPress-Handbuch
WordPress-Handbuch / listing-16-2.htaccess
Last active May 8, 2019 06:11
Take Control of the HTTP Expiration Headers and disable ETags
<IfModule mod_expires.c>
ExpiresActive On
FileETag None
Header unset ETag
ExpiresDefault "access plus 1 month"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rdf+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
@WordPress-Handbuch
WordPress-Handbuch / listing-16-1.htaccess
Created March 6, 2019 06:13
.htaccess add on to activate GZIP compression on regular Apache servers
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
@WordPress-Handbuch
WordPress-Handbuch / listing-15-4.htaccess
Last active May 19, 2019 09:36
Show all ways to get the current and absolute PHP script folder
AuthUserFile /AbsoluterPfadZumIhremWordPressAdminOrdner/.htpasswd
AuthType Basic
AuthName "Verhaeltnismaessig geheimer Zugang zur Website"
Require valid-user
@WordPress-Handbuch
WordPress-Handbuch / listing-15-3.htaccess
Created March 4, 2019 08:02
Simple HTTP to HTTPS redirect
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]