Skip to content

Instantly share code, notes, and snippets.

View nextab's full-sized avatar

nexTab - Oliver Gehrmann nextab

View GitHub Profile
@nextab
nextab / Icon-Shortcode für Divi.php
Created August 20, 2021 10:56
Mit Hilfe eines Shortcodes können Icons aus der in Divi mitglieferten Iconfont ausgegeben werden.
/* Anwendungsbeispiel:
[nxticon id=""]
-> erzeugt ein E-Mail-Icon
[nxticon id="" size="50px"]
-> erzeugt das E-Mail-Icon mit Schriftgröße 50px
*/
{
// Place your snippets for scss here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
{
"shorty": {
"prefix": "shorty",
"body": [
"function ${2:function_name}(\\$atts, \\$content = null) {",
"\t\\$a = shortcode_atts([",
"\t\t'title'\t=> 'My Title',",
"\t\t'class'\t=> 'myClass'",
"\t], \\$atts);",
"\t\\$return_string = '';",
@nextab
nextab / FadeOut & remove Element via JavaScript (+ Event Listener).js
Created October 13, 2021 21:30
This code snippets generates a global event listener that can then be used to trigger a function that fades out and removes an element.
// Global event listener that can register a click on any event, but in our case, we need it to listen to ".fg_close_button"
document.addEventListener('click', function (event) {
// console.log(event);
if (!event.target.matches('.fg_close_button')) return;
const message_container = event.target.closest(".woocommerce-message");
removeFadeOut(message_container, 2000);
}, false);
// Function to fade out and remove an element - credit goes to alvarodms - https://stackoverflow.com/questions/33424138/how-to-remove-a-div-with-fade-out-effect-in-javascript
function removeFadeOut( el, speed ) {
@nextab
nextab / WooCommerce Success Message Template mit Button
Created October 13, 2021 22:32
Place in /woocommerce/notices/ inside your child theme's folder to overwrite the default template of WooCommerce.
<?php
/**
* Show messages
*
* This template can be overridden by copying it to yourtheme/woocommerce/notices/success.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
.woocommerce-message .fg_button_container {
position: absolute;
right: 5px;
top: 5px;
}
.woocommerce-message .fg_button_container button {
background: transparent;
border: none;
color: #fff;
cursor: pointer;
@nextab
nextab / truncate function for number of words in WordPress
Created October 21, 2021 12:53
Return no. of words for a given string (with option to strip tags or not)
// this function returns the string $text shortened to the number of words defined in the second attribute $length. It does not break words.
function nxt_truncate($text, $length = 30, $more = '...', $striptags = false) {
if ($striptags)
return force_balance_tags(html_entity_decode(wp_trim_words((wpautop($text)), $length, $more)));
else
return force_balance_tags(html_entity_decode(wp_trim_words(htmlentities(wpautop($text)), $length, $more)));
}
@nextab
nextab / Divi Kommentare aufhübschen - Fix Divi Comments.css
Created October 27, 2021 15:04
Dieser CSS Code sorgt dafür, dass die Anzeige der Kommentare auf WordPress Seiten mit Divi wesentlich vernünftiger aussieht.
/* #region Fix Divi Comments */
.commentlist .comment-body {
padding-right: 0;
}
.commentlist .comment-body .comment_avatar {
top: 0;
}
.commentlist .comment-body .comment_avatar img {
border-radius: 50%;
}
@nextab
nextab / Contact Form 7 Styles und Scripten nur selektiv einbinden.php
Created November 5, 2021 12:23
Mit Hilfe dieser kurzen Funktion werden die von Contact Form 7 erzeugten Script- und Style-Dateien nur noch auf bestimmten Seiten in WordPress eingebunden.
// Remove Contact Form 7 stylesheet and javascript from most pages
function nxt_remove_cf7() {
// change the id in the following line to match the page where you want to include the Contact Form 7 styles & scripts; use [1, 123, 456] if you want to do so for several pages / posts.
if(!is_page(382)) {
add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );
}
}
add_action('template_redirect', 'nxt_remove_cf7');
@nextab
nextab / PHP Mailer Configuration for WordPress.php
Created November 12, 2021 13:52
Just define the globals in wp-config.php and add the code snippet in your functions.php to send e-mails via SMTP instead of the regular php mailer.
Folgenden Code unter übliche wp-config-.php-Befehle einfügen: (Auf All-Inkl angewandt - andere Host-Daten müssten dementsprechend angepasst werden...)
define( 'SMTP_USER', 'm05f2ew1' ); // Postfach-Benutzer
define( 'SMTP_PASS', 't3stpwd' ); // Postfach-Passwort
define( 'SMTP_HOST', 'w01c1234.kasserver.com' ); // Postein- und Ausgangsserver
define( 'SMTP_FROM', 'mail@example.com' ); // Gewünschte E-Mail-Adresse zum Versenden
define( 'SMTP_NAME', 'Example Website' ); // Webseiten-Name
define( 'SMTP_PORT', '465' ); // SMTP-Port - häufig 465 oder 587 (auch 25, aber unsicher)
define( 'SMTP_SECURE', 'ssl' ); // Verschlüsselungstyp (auch tls möglich)
define( 'SMTP_AUTH', true ); // SMTP-Authentifikation