Skip to content

Instantly share code, notes, and snippets.

Avatar

WordPress-Handbuch WordPress-Handbuch

View GitHub Profile
@WordPress-Handbuch
WordPress-Handbuch / listing-10-4.php
Created Jan 30, 2019
PHP code extension to display post image thumbnails next to the Previous/Next post links in WordPress
View listing-10-4.php
$previous_post=get_previous_post();
$next_post=get_next_post();
the_post_navigation(
array(
'next_text' => '<span class="meta-nav" aria-hidden="true">Weiter</span> ' .
'<span class="screen-reader-text">Weiter</span> <br/>' .
'<span class="post-title">%title</span>' . get_the_post_thumbnail( $next_post->ID, 'thumbnail' ),
'prev_text' => '<span class="meta-nav" aria-hidden="true">Zurück</span> ' .
'<span class="screen-reader-text">Zurück</span> <br/>' .
'<span class="post-title">%title</span>' . get_the_post_thumbnail( $previous_post->ID, 'thumbnail' ),
@WordPress-Handbuch
WordPress-Handbuch / listing-11-1.php
Created Feb 7, 2019
Example PHP/jQuery Matomo fragment to track form field clicks in the plugin »Quiz and Survey Master« (V6.2.0, class-qmn-quiz-manager.php, insert at line 314)
View listing-11-1.php
$quiz_display .= "<script>\n";
$quiz_display .= " jQuery(document).ready(function () {\n";
$quiz_display .= " jQuery('.qmn_quiz_form input').click(function () {\n";
$quiz_display .= " _paq.push(['trackEvent', 'Quiz', 'Klick', jQuery(this).attr('ID') + '-' + jQuery(this).attr('value')]);\n";
$quiz_display .= " });\n";
$quiz_display .= " });\n";
$quiz_display .= "</script>\n";
@WordPress-Handbuch
WordPress-Handbuch / listing-13-1.php
Last active Apr 5, 2019
functions.php extension to include only specific plugins in the automatic updates
View listing-13-1.php
function auto_update_specific_plugins ( $update, $item ) {
// List your plugins to be updated here
$plugins = array (
'cookie-notice',
'relevanssi',
'updraftplus',
'and-any-other-plugin-slugs'
);
if ( in_array( $item->slug, $plugins ) ) {
return true;
@WordPress-Handbuch
WordPress-Handbuch / listing-13-2.html
Created Feb 19, 2019
Itty bitty HTML page acting as a simple maintenance page
View listing-13-2.html
<html><head><title>Wartung!</title></head><body>Der Welt kleinste Wartungsseite</body></html>
@WordPress-Handbuch
WordPress-Handbuch / listing-13-3
Created Feb 19, 2019
.htaccess fragment for loading a static HTML page except when images are being requested or the user comes from 1.2.3.4 (insert your IP here)
View listing-13-3
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4
RewriteCond %{REQUEST_URI} !/wartung.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /wartung.html [R=302,L]
</IfModule>
@WordPress-Handbuch
WordPress-Handbuch / listing-15-1.html
Created Mar 1, 2019
Dynamic generation of a contact e-mail address as a measure against simple scan bots
View listing-15-1.html
<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 Mar 1, 2019
Dynamic generation (CSS) of a contact e-mail address as a measure against simple scan bots
View listing-15-2.html
<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>
View listing-15-3.htaccess
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@WordPress-Handbuch
WordPress-Handbuch / listing-15-4.htaccess
Last active May 19, 2019
Show all ways to get the current and absolute PHP script folder
View listing-15-4.htaccess
AuthUserFile /AbsoluterPfadZumIhremWordPressAdminOrdner/.htpasswd
AuthType Basic
AuthName "Verhaeltnismaessig geheimer Zugang zur Website"
Require valid-user
@WordPress-Handbuch
WordPress-Handbuch / listing-16-1.htaccess
Created Mar 6, 2019
.htaccess add on to activate GZIP compression on regular Apache servers
View listing-16-1.htaccess
<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