Skip to content

Instantly share code, notes, and snippets.

View WordPress-Handbuch's full-sized avatar

WordPress-Handbuch WordPress-Handbuch

View GitHub Profile
<?php
echo 'basename(dirname(__FILE__)) = ' . basename(dirname(__FILE__)) . "<br/>";
echo '$_SERVER["PHP_SELF"] = ' . $_SERVER["PHP_SELF"] . "<br/>";
echo '$_SERVER["DOCUMENT_ROOT"] = ' . $_SERVER["DOCUMENT_ROOT"] . "<br/>";
echo 'dirname(__FILE__) = ' . dirname(__FILE__) . "<br/>";
echo 'getcwd() = ' . getcwd() . "<br/>";
echo '__FILE__ = ' . __FILE__ . "<br/>";
phpinfo();
?>
@WordPress-Handbuch
WordPress-Handbuch / listing-18-18.php
Created April 23, 2019 06:11
WordPress 5 dropin /wp-content/maintenance.php, a custom maintenance message when using the .maintenance-mechanism in the main directory
<?php
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 3600');
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Website wird gewartet</title>
</head>
@WordPress-Handbuch
WordPress-Handbuch / listing-18-17.php
Created April 23, 2019 06:09
WordPress 5 dropin for db-error.php, a custom error message in case of a failed database connection
<?php ob_start();
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 3600');
mail("info@ihredomain", "Datenbankfehler", "Schon wieder die Datenbank!", "From: Meine Website");
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Website nicht erreichbar</title>
@WordPress-Handbuch
WordPress-Handbuch / listing-21-5.css
Created April 11, 2019 08:20
Example RWD breakpoints
/* CSS Styles ausserhalb der folgenden speziellen Media Querys sind fuer grosse Monitore, breiter als 1199px, vorgesehen */
@media all and (max-width: 1199px) {
/* CSS Styles fuer grosse Displays */
}
@media all and (max-width: 991px) {
/* CSS Styles fuer Tablets hochkant */
}
@media all and (max-width: 768px) {
/* CSS Styles fuer Smartphones, horizontal */
}
@WordPress-Handbuch
WordPress-Handbuch / listing-18-16.php
Created April 11, 2019 06:46
Display new image sizes choices set through add_image_size() also in the backend in the right sidebar when editing an image
function wh_add_image_sizes_to_backend( $existingsizes ) {
$addsizes = array(
"wh-homepage-teaser" => 'WH Homepage Teaser',
"wh-landingpage-stage" => 'WH Landingpage Stage',
"wh-detailpage-feature" => 'WH Detailpage Feature'
);
$newsizes = array_merge( $existingsizes, $addsizes );
return $newsizes;
}
add_filter( 'image_size_names_choose', 'wh_add_image_sizes_to_backend' );
@WordPress-Handbuch
WordPress-Handbuch / listing-18-15.php
Created April 10, 2019 08:12
WordPress 5 Hello Word with translations commands
<?php
/**
* @package WH_Hello_World
* @version 1.1.0
*/
/*
Plugin Name: WH Hello World
Plugin URI: https://wordpress-handbuch.com
Description: Testausgabe in Front- und Backend
Author: Johannes Mustermann
@WordPress-Handbuch
WordPress-Handbuch / listing-22-2.js
Created March 27, 2019 15:26
WordPress 5 plugin admin js code for the backend preview part of the WH Eyecatcher example project https://wordpress.org/plugins/wh-eyecatcher/
jQuery(document).ready(function( $ ){
jQuery('select#wh_eyecatcher_style').on('change', function () {
$("textarea#wh_eyecatcher_css").val(this.value);
$("div#wh-eyecatcher").attr("style",this.value);
});
jQuery('textarea#wh_eyecatcher_css').on('change keyup paste', function () {
$("div#wh-eyecatcher").attr("style",this.value);
});
jQuery('input#wh_eyecatcher_slogan').on('change keyup paste', function () {
$("div#wh-eyecatcher").html($("input#wh_eyecatcher_slogan").attr("value"));
@WordPress-Handbuch
WordPress-Handbuch / listing-22-1.php
Last active February 18, 2020 19:55
WordPress 5 plugin main php code of the WH Eyecatcher example project https://wordpress.org/plugins/wh-eyecatcher/
<?php
/*
Plugin Name: WH Eyecatcher
Plugin URI: https://wordpress-handbuch.com/wh-eyecatcher
Description: Add a floating slogan to eyery page of your website
Version: 1.0.2
Author: WordPress-Handbuch
Author URI: https://wordpress-handbuch.com
License: GPL v2 or later
Copyright 2019 Richard Eisenmenger
@WordPress-Handbuch
WordPress-Handbuch / listing-21-3.php
Created March 26, 2019 08:11
Example functions.php with activated WordPress 5 features
<?php
/**
* WH HTML Vorlage functions and definitions
*
* @link @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package WH_HTML_Vorlage
*/
/**
@WordPress-Handbuch
WordPress-Handbuch / listing-21-4.css
Created March 26, 2019 07:38
Example Gutenberg editor styles to be included via add_editor_style( 'listing-21-4.css' );
body {
background-color: #00ffff;
color: #0000ff;
}
.wp-block {
max-width: 300px;
}
.wp-block[data-align="wide"] {
max-width: 500px;
}