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
add_filter( 'do_shortcode_tag', function ( $output, $tag, $attr ) {
if ( 'jet_engine' !== $tag ) {
return $output;
}
if ( empty( $attr['component'] ) || 'meta_field' !== $attr['component'] ) {
return $output;
}
@petertwise
petertwise / acf-install-license
Last active January 19, 2024 14:48 — forked from polevaultweb/acf_pro_license_constant.php
Define the Advanced Custom Fields Pro license key with a constant
#!/bin/bash
# Setup ACF Pro to use a license key in wp-config
#
# 1. Place your license key in a file called .acf-license-key somewhere your ssh user has access to it.
# Default is in your home directory: ~/.acf-license-key
# Change the setting below if you need to put it somewhere else
# 2. install this file in /usr/local/bin or someplace in your PATH
# 3. make sure you have WP CLI installed
# 4. run acf-install-license from the root of your wordpress install
@swinggraphics
swinggraphics / oxy-save-rendered-content.php
Last active June 15, 2022 21:56
Copy compiled Oxygen page content to post_content for search
/* Copy compiled Oxygen page content to post_content for search */
function sg_save_rendered_page_content( $meta_id, $object_id, $meta_key, $meta_value ) {
// Debugging
// $debug .= preg_replace( '#(\[/[^\]]+?\])#', "$1\n", $meta_value );
// file_put_contents( plugin_dir_path( __FILE__ ) . 'debug.html', $debug );
if ( 'ct_builder_shortcodes' != $meta_key ) return;
// Don't try to render anything with inner content
if ( false !== strpos( $meta_value, '[ct_inner_content' ) ) return;
@deckerweb
deckerweb / maybe-add-post-states-for-blocks.php
Last active November 8, 2019 10:51
Adds optional new post states if a Post has Blocks, has the "Classic" Block or no Blocks at all. *** Note: This respects also the popular "Disable Gutenberg" plugin (free, by Jeff Starr) which allows for disabling the "Block Editor" for entire post types.
<?php
/** Do NOT include the opening php tag */
if ( ! function_exists( 'ddw_cf_maybe_add_post_state_blocks' ) ) :
add_filter( 'display_post_states', 'ddw_cf_maybe_add_post_state_blocks', 10, 2 );
/**
* Adds optional new post states if a Post has Blocks, has the "Classic" Block or no Blocks at all.
*
@MjHead
MjHead / get-jet-engine-gallery-images.php
Created September 26, 2019 08:37
Example how to get an array of images stored in JetEngine gallery field
@heyfletch
heyfletch / make-elementor-default-editor.php
Last active September 26, 2021 14:50
Make Elementor the Default Editor, Not the WordPress Editor (Gutenberg or Classic)
<?php
/**
* Make Elementor the default editor, not the WordPress Editor (Gutenberg or Classic)
* Clicking the page title will take you to the Elementor editor directly
* Even non-Elementor-edited pages will become Elementor-edited pages now
* You can revert by clicking the "Back to WordPress Editor" button
*
* Author: Joe Fletcher, https://fletcherdigital.com
* URL: https://gist.github.com/heyfletch/7c59d1c0c9c56cbad51ef80290d86df7
@nickcernis
nickcernis / functions.php
Created January 16, 2019 11:11
Wrap Custom HTML WordPress blocks in a div wrapper
<?php
add_filter( 'render_block', 'custom_wrap_html_block_output', 10, 2 );
/**
* Wrap output of HTML blocks.
*
* @param string $block_content Original block content.
* @param array $block Block info.
* @return string The block content with a wrapper.
*/
@wpsmith
wpsmith / composer.json
Last active October 11, 2022 21:42
PHP: Hide User Mu-Plugin
{
"name": "wpsmith/hide-user",
"description": "Hides user in WordPress Admin.",
"type": "project",
"license": "GPLv2+",
"authors": [
{
"name": "Travis Smith",
"email": "t@wpsmith.net"
}
@rmpel
rmpel / wp-499-up-fix-csv-upload.php
Last active January 2, 2022 15:01
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 );
@polevaultweb
polevaultweb / acf_pro_license_constant.php
Last active March 22, 2023 03:06
Define the Advanced Custom Fields Pro license key with a constant
<?php
function my_filter_acf_pro_license_option( $pre ) {
if ( ! defined( 'ACF_PRO_LICENSE' ) || empty( ACF_PRO_LICENSE ) ) {
return $pre;
}
$data = array(
'key' => ACF_PRO_LICENSE,
'url' => home_url(),