Skip to content

Instantly share code, notes, and snippets.

View nextab's full-sized avatar

nexTab - Oliver Gehrmann nextab

View GitHub Profile
// Konkretes Beispiel: Alle <h2> in single posts werden über die Funktion span_headers replaced und es kommt <h2 class="yellow_highlight"><span> ... raus.
function fdp_highlight_headers ( $content ) {
if ( is_single() ) {
// $content = str_replace('Rico Apitz', 'Oliver Gehrmann', $content);
return span_headers('h2', $content);
}
return $content;
}
add_filter( 'the_content', 'fdp_highlight_headers', 99);
@nextab
nextab / style.css
Created June 26, 2021 10:50
CSS Code für unsichtbare Zeilen, die bei Klasse "active" sichtbar werden und rein animieren
.hidden-row {
height: 0;
opacity: 0;
padding: 0;
position: absolute;
transition: opacity 0s ease, padding 500ms ease, visibility ease 500ms;
visibility: hidden;
}
.hidden-row:not(.active) {
left: 50%;
@nextab
nextab / JavaScript korrekt in WordPress einbinden
Created June 28, 2021 10:46
Eigenes JavaScript File (my-script-filename.js), das im Ordner /js innerhalb des Child Theme Ordners liegt, sauber im Footer in WordPress einbinden.
// Add JavaScript file 'my-script-filename.js' (located in the child theme directory /js) to WordPress (in the footer)
function add_my_own_scripts() {
wp_register_script('my-script', get_stylesheet_directory_uri() . '/js/my-script-filename.js', '', '1.0', true);
wp_enqueue_script('my-script');
}
add_action( 'wp_enqueue_scripts', 'add_my_own_scripts' );
@nextab
nextab / Bilder Resizing in Blog-Modul überschreiben
Created July 6, 2021 11:30
Copy & Paste the code into your child theme's functions.php
// Per Filter in der functions.php den max-Wert für die Bildauflösungen im Blog-Modul anpassen:
function nxt_overwrite_divi_cropping($width) {
return 2600;
}
add_filter( 'et_pb_blog_image_width', 'nxt_overwrite_divi_cropping' );
add_filter( 'et_pb_blog_image_height', 'nxt_overwrite_divi_cropping' );
@nextab
nextab / Add_polylang_to_Divi_Library_Window.php
Last active May 8, 2024 09:16
Add polylang to Divi Library Window
/** Add polylang to Divi Library Window */
function cedura_pll_get_post_types($types) {
return array_merge($types, ['et_pb_layout' => 'et_pb_layout']);
}
add_filter('pll_get_post_types', 'cedura_pll_get_post_types');
@nextab
nextab / Metabox mit Auswahl einer Header-Variante und Filter auf body_class.php
Created July 19, 2021 10:56
Fügt eine Metabox (für Seiten) im WordPress Backend hinzu und falls nicht der Standardwert (weißer Header) ausgewählt wurde, so wird der body Klasse im Frontend der Wert "frosted_blue_header" hinzugefügt. (Default-Wert wird NICHT in DB gespeichert.)
// Add a Metabox to the backend
function frosted_add_custom_header_metabox() {
add_meta_box("frosted-custom-header", "Hintergrundfarbe der Navigation", "frosted_custom_header", "page", "side", "high", null);
}
add_action("add_meta_boxes", "frosted_add_custom_header_metabox");
// Fill Metabox with our custom variable
function frosted_custom_header() {
wp_nonce_field(basename(__FILE__), "frosted-custom-header-metabox-nonce");
if(get_post_meta(get_the_ID(), '_frosted_header_selection', true) != '') {
@nextab
nextab / deactivate-gutenberg-widget-editor.php
Created July 27, 2021 09:50
Just a quick code snippet for your theme's functions.php to deativate the Gutenberg Widget Editor.
// Disables the block editor from managing widgets in the Gutenberg plugin.
add_filter( 'gutenberg_use_widgets_block_editor', '__return_false', 100 );
// Disables the block editor from managing widgets.
add_filter( 'use_widgets_block_editor', '__return_false' );
@nextab
nextab / Add custom bulk actions (in dropdown) for a custom post type in WordPress Backend
Created August 16, 2021 10:47
In this example, we're using the custom post type "message" that is being used for a front end form powered by the Plugin "Advanced Custom Fields" to generate custom posts in our backend. We have now added a functionality to bulk edit the message status.
// We are adding custom bulk actions in the WP Admin Backend for the post type "message"
function dc_custom_bulk_actions( $bulk_array ) {
$message_status_fields = get_field_object('field_5f3ba86a9409e');
// echo '<!-- nxt debug --><pre>'; print_r($message_status_fields); echo '</pre>';
foreach($message_status_fields['choices'] as $status_option_key => $status_option_value) {
$bulk_array[$status_option_key] = 'Set message status to ' . $status_option_key;
}
return $bulk_array;
}
add_filter( 'bulk_actions-edit-message', 'dc_custom_bulk_actions' );
@nextab
nextab / Add more columns to WordPress backend
Created August 16, 2021 10:57
We're adding a couple of columns to the WordPress backend that are getting populated with values saved in custom fields.
/**
* Add more colums to the listing of messages in the backend
*/
function nxt_more_columns($columns) {
$columns = [
'cb' => '<input type="checkbox" />',
'title' => __('Title', 'nxt-acf-forms'),
'cf_category' => __('Category', 'nxt-acf-forms'),
'cf_email' => __('E-Mail', 'nxt-acf-forms'),
'cf_tel' => __('Telephone', 'nxt-acf-forms'),
@nextab
nextab / User Styles für Joplin
Created August 16, 2021 14:17
Erzeugt mehr Abstände zwischen den gerenderten Elementen in einer Joplin-Notiz => weniger Sachen "kleben" aneinander.
/* For styling the rendered Markdown */
h1 { margin-top: 45px; }
ul + *, * + table { margin-top: 30px; }
hr { margin: 30px 0; }
ul li.md-checkbox label.checkbox-label-checked { text-decoration: line-through; }