Skip to content

Instantly share code, notes, and snippets.

View deckerweb's full-sized avatar
🏠
Working from home

David Decker deckerweb

🏠
Working from home
View GitHub Profile
@deckerweb
deckerweb / wp-499-up-fix-csv-upload.php
Created December 18, 2018 22:13 — forked from rmpel/wp-499-up-fix-csv-upload.php
A filter (an mu-plugin) to restore CSV upload functionality to WordPress 4.9.9 and up.
<?php
/**
* Restore CSV upload functionality for WordPress 4.9.9 and up
*/
add_filter('wp_check_filetype_and_ext', function($values, $file, $filename, $mimes) {
if ( extension_loaded( 'fileinfo' ) ) {
// with the php-extension, a CSV file is issues type text/plain so we fix that back to
// text/csv by trusting the file extension.
$finfo = finfo_open( FILEINFO_MIME_TYPE );
$real_mime = finfo_file( $finfo, $file );
@deckerweb
deckerweb / btc-rcl-elementor-my-templates.php
Last active December 13, 2018 12:31
Disable "Builder Template Category" taxonomy for the WP Real Categories Management (RCL) plugin - only for Elementor My Templates post type
<?php
/** Do NOT include the opening php tag */
add_filter( 'RCL/Available', 'btc_rcl_elementor_my_templates', 10, 3 );
/**
* Disable "Builder Template Category" taxonomy for Elementor My Templates for
* the "WP Real Categories Management" plugin (Premium, by Matthias Günter).
*
* @author David Decker - DECKERWEB
@deckerweb
deckerweb / gutenberg-frontpage-only.php
Created November 22, 2018 08:33
Disable Gutenberg except for “Frontpage” page - found via: https://codeshare.io/29Kj8K
<?php
/**
* Disable Gutenberg by Default
* but let others easily override that by changing hook priority to 5
* https://justnorris.com/how-to-dynamically-enable-gutenberg/
*/
add_filter( 'gutenberg_can_edit_post', '__return_false', 5 );
add_filter( 'use_block_editor_for_post', '__return_false', 5 );
@deckerweb
deckerweb / btc-tax-public.php
Created November 8, 2018 12:43
Make the "Builder Template Category" taxonomy public. - For plugin: "Builder Template Taxonomies"
<?php
/** Do NOT include the opening php tag */
add_filter( 'register_taxonomy_args', 'ddw_btc_make_tax_public', 10, 2 );
/**
* Make the "Builder Template Category" taxonomy public.
* For plugin: "Builder Template Taxonomies".
*
* @author David Decker - DECKERWEB
@deckerweb
deckerweb / README-Template.md
Created October 16, 2018 16:07 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@deckerweb
deckerweb / tbex-remove-admin-notices.php
Last active January 15, 2019 13:58
Plugin: Toolbar Extras - Completely remove Admin notices.
<?php
/** Do NOT include the opening php tag */
/**
* Plugin: Toolbar Extras - Completely remove Admin notices.
*
* @author David Decker - DECKERWEB
* @link https://gist.github.com/deckerweb/9113a2d6016fb018b3afba0715a635bb
*/
if ( ! function_exists( 'tbex_remove_admin_notices' ) ) :
@deckerweb
deckerweb / btc-register-integration-wp-pages.php
Last active October 2, 2018 08:30
Plugin: Builder Template Categories - Register regular WordPress Pages as an integration. That means to you categorize even those pages with your template categories ;-).
<?php
/** Do NOT include the opening php tag */
add_filter( 'btc/filter/integrations/all', 'btc_register_integration_wordpress_pages' );
/**
* Plugin: Builder Template Categories - Register custom integration.
*
* @author David Decker - DECKERWEB
* @link https://gist.github.com/deckerweb/dd00884e81783e7d21046ae0a72ed683
@deckerweb
deckerweb / elementor-page-type-to-wp-pages.php
Last active October 2, 2018 08:30
Map the document type "Page" (now labelled as "Content") of Elementor Templates as a submenu to (regular) WordPress Pages. This results in a nice quick jump link in your left-hand admin menu ;-).
<?php
/** Do NOT include the opening php tag */
add_action( 'admin_menu', 'ddw_map_elementor_document_type_page_submenu' );
/**
* Map the Elementor Template document type "Page" as a submenu under WordPress
* regular "Pages".
*
* @author David Decker - DECKERWEB
@deckerweb
deckerweb / get_current_post_type.php
Created September 21, 2018 22:54 — forked from DomenicF/get_current_post_type.php
Get the current post_type context in the WordPress admin.
<?php
/**
* gets the current post type in the WordPress Admin
*/
function get_current_post_type() {
global $post, $typenow, $current_screen;
//we have a post so we can just get the post type from that
if ( $post && $post->post_type ) {
return $post->post_type;
@deckerweb
deckerweb / btc-tweak-integration-args.php
Last active September 25, 2018 09:47
Plugin: Builder Template Categories - Code Snippet for tweaking arguments of one or more integrations: #deckerweb #wordpress #plugin #customization
<?php
/** Do NOT include the opening php tag */
add_filter( 'btc/filter/integrations/all', 'btc_tweak_integration_args', 20, 1 );
/**
* Plugin: Builder Template Categories - Tweak arguments of integrations, for
* example labels.
*
* Note: The priority of the filter needs to be higher than 10, otherwise it