Skip to content

Instantly share code, notes, and snippets.

View nextab's full-sized avatar

nexTab - Oliver Gehrmann nextab

View GitHub Profile
/* #region max-width 980px */
@media only screen and ( max-width: 980px ) {
header#main-header .et_mobile_menu {
left: 0;
max-height: calc(100vh - 95px);
overflow: scroll;
position: fixed;
top: 95px !important;
width: 100%;
}
/****************/
/***** PHP *****/
/**************/
#region Content Blocker Shortcode
function agreement_shortcode( $atts, $content = null ) {
$a = shortcode_atts([
'class' => 'wide-player',
'hinweis' => 'Um den Podcast hier anzuzeigen, müssen Dateien von einem externen Server geladen werden. Bitte gestatte die Anzeige externer Inhalte (hierzu wird deine IP-Adresse an den externen Dienst weitergeleitet, der mit ihr zwar eigentlich nichts anstellen kann, trotzdem schreibt das Gesetz vor, dass ich zunächst dein Einverständnis einhole).',
], $atts);
.parent-container {
display: grid;
gap: 0 2.5rem;
grid-auto-flow: row;
grid-auto-rows: 0px;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
grid-template-rows: repeat(1, auto);
overflow: hidden;
}
/* Usage:
$custom_taxonomies = ['elektromobil-hersteller', 'elektromobil-kategorie'];
$article_classes = apply_filters('afp_article_classes', $article_classes, $nxt_post_id, $custom_taxonomies);
=> will output "manufacturer mobile-category" (the slugs of the 2 custom taxonomies that the post is assigned to)
Do not forget the apply_filters call, e.g.:
add_filter('afp_article_classes', 'afp_custom_article_classes', 99, 3);
*/
@nextab
nextab / Toggle - accordion with details and summary shortcode for WordPress
Created January 27, 2023 15:07
With this shortcode, you can hide content behind a headline and only after clicking the headline, the rest of the content will become visible. Similar to a toggle or an accordion, just without JavaScript.
#region Shortcode read more
function read_more_shortcode( $atts, $content = null ) {
$a = shortcode_atts( array(
'class' => '',
'text' => 'Weiterlesen...',
'wrapper' => 'ja',
), $atts );
if(empty($content)) return; // No content has been submitted
$return_string = '';
if($a["wrapper"] != "nein") {
.et_pb_section.wavey > div[class*="_inside_divider"] {
animation:scaleAnimation 4s infinite;animation-timing-function:cubic-bezier(.36,.45,.63,.53)
}
@keyframes scaleAnimation{
0%,to { transform:scale(1,1) }
50% { transform:scale(1,1.4)}
}
<?php
# Ermöglicht es uns, zu regulären PHP-Funktionen auch WP-Funktionen zu verwenden, die für die Validierung entscheidend sind. Wie z. B., ob der Nutzer eingeloggt ist oder ob er eine bestimmte Role oder Cap hat.
require_once( 'wp-load.php' );
# Wenn wir keinen "file"-Parameter in der URL haben, beende das Skript.
$qv_file = $_GET[ 'file' ];
if( ! isset( $qv_file ) ) exit;
parse_str( parse_url( $_SERVER[ 'REQUEST_URI' ], PHP_URL_QUERY ) ?? '', $query_string );
#region Protected File Download
function shortcodes_protected_upload_url() {
$dir = wp_upload_dir();
return $dir[ 'baseurl' ] . '/gesichert/';
}
add_shortcode( 'protected-upload-url', 'shortcodes_protected_upload_url' );
#endregion Protected File Download
@nextab
nextab / htaccess protected file handler
Last active June 22, 2024 22:19
This little snippet allows the system to have a php script (in the example edg-protected-file.php) handle a URL IF it's for a file (!) that's located under /wp-content/uploads/gesichert/
<IfModule mod_rewrite.c>
# Überprüfe, ob die Anfrage für eine Datei gilt.
RewriteCond %{REQUEST_FILENAME} -f
# Anstatt die Datei direkt per URL auszuliefern, übermittle die Anfrage an ein PHP-Skript, das die Validierung erledigt.
RewriteRule ^wp-content/uploads/gesichert/(.*)$ edg-protected-file.php?file=$1 [QSA,L]
</IfModule>
@nextab
nextab / Elemente auf identische Höhe setzen mit JavaScript.js
Created September 2, 2022 13:05
childString und parentString auf die eigenen Bedürfnisse anpassen und ab geht's! ;-)
/** Original code by Webdevtrick ( https://webdevtrick.com ) **/
(function () {
equalHeight(false);
})();
window.onresize = function(){
equalHeight(true);
}
function equalHeight(resize) {