Skip to content

Instantly share code, notes, and snippets.

View gmmedia's full-sized avatar

Jochen Gererstorfer gmmedia

View GitHub Profile
@gmmedia
gmmedia / functions.php
Created January 16, 2023 11:09
WordPress: Add Script to Header in first position/priority
add_action( 'wp_head', function () { ?>
<script></script>
<?php }, -1000 );
@gmmedia
gmmedia / functions.php
Created January 16, 2023 11:08
WordPress Hook: Truendo
add_action( 'wp_head', function () { ?>
<!-- TRUENDO Privacy Center --><script async="" id="truendoAutoBlock" type="text/javascript" src="https://cdn.priv.center/pc/truendo_cmp.pid.js" data-siteid="3dce3136-5f8d-4c4a-b418-cc414d098a34"></script><!-- End TRUENDO Privacy Center -->
<?php }, -1000 );
@gmmedia
gmmedia / functions.php
Last active February 6, 2023 12:56
FluentForms - E-Mail Blacklist - All Forms
<?php
// FluentForms - E-Mail Blacklist
// Need help: https://bloggerpilot.com/en/snippet-fluentforms-email-blacklist/
add_filter('fluentform_validate_input_item_input_email', function ($error, $field, $formData, $fields, $form) {
// These listed domains will fail to submit the form
$blacklistDomains = ['gmail.com', 'hotmail.com', 'test.com'];
@gmmedia
gmmedia / functions.php
Last active December 21, 2022 06:49
Display hidden WordPress plugin and theme update notifications on the update-core screen.
<?php
/**
* Debug Pending Updates
*
* Displays hidden plugin and theme updates on update-core screen.
* Source: https://stackoverflow.com/a/52132227
*/
function debug_pending_updates() {
@gmmedia
gmmedia / PHP Mailer Configuration for WordPress.php
Created November 29, 2022 20:28 — forked from nextab/PHP Mailer Configuration for WordPress.php
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', '[email protected]' ); // 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
@gmmedia
gmmedia / functions.php
Created September 25, 2022 12:28
Kadence Cloud Settings: Pro Tag
/**
* Apply a pro tag based on the cloud library category.
*
* @param boolean $enabled true or false based on if pro.
* @param object $post the current cloud library item post object.
* @param array $request_extras an array of extra information.
* @return Boolean based on if access should be labeled pro.
*/
function custom_kadence_cloud_add_pro_tag( $enabled, $post, $request_extras ) {
if ( has_term( 'pro', 'kadence-cloud-categories', $post ) ) {
@gmmedia
gmmedia / functions.php
Last active August 4, 2022 12:49
WP Glossary - Add Gutenberg Support
<?php
// WP Glossary - Add Gutenberg Support
// Need help: https://bloggerpilot.com/snippet-wp-glossary-gutenberg/
// Add support for Gutenberg
add_filter ( 'wpg_post_type_glossary_args', 'bp_wpg_post_editor' );
function bp_wpg_post_editor ( $args ) {
$args['show_in_rest'] = true; // for Gutenberg Editor
return $args;
}
@gmmedia
gmmedia / functions.php
Created July 27, 2022 12:28
Add Media Library Column: File Size
<?php
// Add Media Library Column: File Size
// Need help: https://bloggerpilot.com/snippet-media-filesize/
add_filter('manage_upload_columns', 'bp_add_column_file_size');
add_action('manage_media_custom_column', 'bp_column_file_size', 10, 2);
add_action('admin_head', 'bp_add_media_styles');
// Create the column
function bp_add_column_file_size($columns)
<?php
/**
* Modify search query to ignore the search term in HTML comments.
*
* @param string $where The WHERE clause of the query.
* @param WP_Query $query The WP_Query instance (passed by reference).
*
* @return string The modified WHERE clause.
*/
@gmmedia
gmmedia / functions.php
Last active March 11, 2023 10:03
Yoast SEO Score column fix
<?php
// Yoast SEO Score column fix
add_action('admin_head', 'bloggerpilot_fix_yoast_score_column');
function bloggerpilot_fix_yoast_score_column() {
echo '<style>#wpseo-score {float: unset;margin: unset;}</style>';
echo '<style>.column-ppc_checklist{width: 12%;}</style>';
}