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-15-1.html
Created March 1, 2019 09:18
Dynamic generation of a contact e-mail address as a measure against simple scan bots
<script type="text/javascript">
verschleierteemailadresse('info', 'wordpress-handbuch', 'com', 'Betreffzeile');
function verschleierteemailadresse(eins,zwei,drei,vier) {
document.write('<a href="mailto');
document.write(':' + eins + '@');
document.write(zwei + '.' + drei + '?subject=' + vier + '">' + eins + '@' + zwei + '.' + drei + '</a>');
}
</script>
@WordPress-Handbuch
WordPress-Handbuch / listing-15-2.html
Created March 1, 2019 09:24
Dynamic generation (CSS) of a contact e-mail address as a measure against simple scan bots
<a data-name="info" data-domain="wordpress-handbuch" data-tld="com" data-subject="Betreffzeile" href="#" class="verschleierteemailadresse" onclick="window.location.href = 'mailto:' + this.dataset.name + '@' + this.dataset.domain + '.' + this.dataset.tld + '?subject=' + this.dataset.subject"></a>
<style>
.verschleierteemailadresse:after {
content: attr(data-name) "@" attr(data-domain) "." attr(data-tld);
}
</style>
@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]
@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-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-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-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-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-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-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>