Skip to content

Instantly share code, notes, and snippets.

View misfist's full-sized avatar

Pea Lutz misfist

View GitHub Profile
<?php
//Change error message of AJAX submitted form.
add_filter( 'caldera_forms_render_notices', function( $notices ){
//Will NOT be set (during AJAX return) if there is no error
if( isset( $notices[ 'error' ], $notices[ 'error' ][ 'note' ] ) ){
$notices[ 'error' ][ 'note' ] = 'Form could not be submitted, please correct erorrs or give us a call.';
}
return $notices;
});
@misfist
misfist / media-utilties.php
Last active January 24, 2018 20:31 — forked from claudiosanches/functions.php
WordPress - Get a first image attachment in post
<?php
function prefix_get_first_attachment( $post ) {
$attachment = get_children(
array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'DESC',
'numberposts' => 1,
)
@misfist
misfist / media-utilties.php
Last active January 24, 2018 20:29 — forked from Santel/functions.php
WordPress - Remove first image from single post content
<?php
function prefix_remove_first_image( $content ) {
if ( !is_page() && !is_feed() && !is_home() ){
$content = preg_replace( "/<img[^>]+\>/i", "", $content, 1 );
}
return $content;
}
add_filter( 'the_content', 'prefix_remove_first_image' );
@misfist
misfist / basic-dropdown-usage.php
Created November 27, 2017 21:09 — forked from joshuadavidnelson/basic-dropdown-usage.php
Filter wp_dropdown_categories by post type.
<?php
/**
* Using wp_dropdown_categories with the post type filter applied.
*
* @link https://joshuadnelson.com/category-taxonomy-dropdown-filtered-by-post-type/
*/
// Taxonomy dropdown arguments
$args = array(
'taxonomy' => 'department',
@misfist
misfist / direct_parent.php
Created October 22, 2017 22:01 — forked from levymetal/direct_parent.php
Custom Wordpress function which uses a nav walker to display a list of child pages from a common parent, which can be called from either the parent page (displays children) or any of the child pages (displays siblings). Detailed instructions available on my blog post here: http://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-…
<?php
wp_nav_menu( array(
'menu' => 'Menu Name',
'sub_menu' => true,
'direct_parent' => true
) );
@misfist
misfist / template-functions.php
Last active September 22, 2017 18:13 — forked from bmarshall511/template-functions.php
Adding WordPress plugin template files.
<?php
/**
* Template Loader
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link https://github.com/misfist/template-loader
@misfist
misfist / jetpack.php
Last active January 24, 2018 20:15
WordPress - Disable JetPack CSS
<?php
function prefix_remove_jetpack_styles() {
wp_deregister_style( 'jetpack-carousel' ); // Carousel
wp_deregister_style( 'the-neverending-homepage' ); // Infinite Scroll
wp_deregister_style( 'post-by-email' ); // Post by Email
wp_deregister_style( 'publicize' ); // Publicize
wp_deregister_style( 'sharedaddy' ); // Sharedaddy
wp_deregister_style( 'sharing' ); // Sharedaddy Sharing
wp_deregister_style( 'stats_reports_css' ); // Stats
wp_deregister_style( 'jetpack-widgets' ); // Widgets
# Ignore everything #
**
!wp-content/
wp-content/**
!wp-content/themes/
!wp-content/plugins/
wp-content/themes/**
wp-content/plugins/**
# Add two rules for each Theme or Plugin you want to include:
@misfist
misfist / shortcake-ui-demo.php
Created April 13, 2016 19:20
ShortCake UI Demo Plugin
<?php
/**
* Plugin Name: Shortcake UI Pullquote Demo
* Plugin URI:
* Description: Try Shortcake with pull-quite shortcode
* Version: 1.0.0
* Author: Mte90
* License: GPL2
*/
@misfist
misfist / .gitignore
Created October 27, 2015 02:44 — forked from salcode/.gitignore
WordPress .gitignore - this is my preferred gitignore file when working with WordPress. It ignores almost all files by default.
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20150227
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.