Skip to content

Instantly share code, notes, and snippets.

View shawnkfinn's full-sized avatar

Shawn Finn shawnkfinn

  • USA
View GitHub Profile
@shawnkfinn
shawnkfinn / WordPress_Conditional-Load-Contact-Form-7-Assets.php
Created July 24, 2016 00:27
Conditional Load WPCF7 assets - use this if globally disabling them first
<?php // Copy and Paste snippet below into child-theme functions or custom plugin -- DELETE THIS LINE
// Conditional Load WPCF7 assets - use this if globally disabling them first
if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
wpcf7_enqueue_scripts();
}
if ( function_exists( 'wpcf7_enqueue_styles' ) ) {
wpcf7_enqueue_styles();
}
@shawnkfinn
shawnkfinn / WordPress_Disable-Contact-Form-7-Assets.php
Created July 24, 2016 00:25
Contact Form 7, version 3.9+ : Disable loading of CSS & JS
<?php // Copy and Paste snippet below into child-theme functions or custom plugin -- DELETE THIS LINE
// Globally disables WPCF7 JS & CSS
add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );
@shawnkfinn
shawnkfinn / WordPress_Disable-X-Pingback-Header.php
Created July 22, 2016 19:40
WordPress v4.4+ : Remove X-Pingback from Header. Note: You have to hook this as late as possible.
<?php // Copy and Paste snippet below into child-theme functions or custom plugin -- DELETE THIS LINE
// Remove X-Pingback from Header
add_action('wp', function() {
header_remove('X-Pingback');
}, 1000);
@shawnkfinn
shawnkfinn / WordPress_Disable-Parent-Theme-Scripts-and-Styles.php
Created July 22, 2016 02:58
This dequeue's and unregisters styles/scripts from WordPress. You may then load your own. This is handy when changing handles/sources, concatenating and minifying through your child theme.
<?php // Copy and Paste snippet below into child-theme functions -- DELETE THIS LINE
add_action( 'wp_enqueue_scripts', 'skf_custom_scripts', 100 );
function skf_custom_scripts()
{
// Stylesheets
wp_dequeue_style( 'bootstrap' );
wp_deregister_style( 'bootstrap' );
@shawnkfinn
shawnkfinn / WordPress_Disable_VC_MetaData.php
Created July 22, 2016 02:56
Remove Visual Composer Meta Data from source code
<?php // Copy and Paste snippet below into child-theme functions or custom plugin -- DELETE THIS LINE
// Remove Visual Composer Meta Data from source code
add_action('init', 'skf_remove_vc_metadata', 100);
function skf_remove_vc_metadata() {
remove_action('wp_head', array(visual_composer(), 'addMetaData'));
}
@shawnkfinn
shawnkfinn / WordPress_Disable-JSON-REST-API.php
Created July 22, 2016 02:55
Disable WordPress JSON/REST API and remove lines from source code / header
<?php // Copy and Paste snippet below into child-theme functions or custom plugin -- DELETE THIS LINE
// Disable WordPress JSON-REST API
function disable_json_api () {
// Remove the REST API lines from the HTML Header
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
// Filters for WP-API version 1.x
@shawnkfinn
shawnkfinn / wp-config-local.php
Created April 28, 2016 02:30
Pantheon Sample Local WP Config
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
@shawnkfinn
shawnkfinn / class-your-custom-plugin-cpt.php
Last active August 29, 2015 14:26
wppb.io - Add description, menu icon, menu order and custom slug
// Public Function (Replace lines 39-58 of wppb.io's default class-your-custom-post-type.php)
public function __construct ( $post_type = '', $plural = '', $single = '', $description = '', $menu_position = '', $menu_icon = '', $slug = '' ) {
if ( ! $post_type || ! $plural || ! $single ) return;
// Post type name and labels
$this->post_type = $post_type;
$this->plural = $plural;
$this->single = $single;
@shawnkfinn
shawnkfinn / your-custom-plugin-cpts.php
Last active August 29, 2015 14:26
Register custom post types with wppb.io
/**
* Register Custom Post Types
*
* How this works: Paste the line below in your plugin's main cpts.php file
*
* Your_Plugin_CPTS()->register_post_type( 'SAMPLE_POST_TYPE', __( 'SAMPLE_PLURAL_NAME', 'your-plugin-name-cpts' ), __( 'SAMPLE_DESCRIPTION Page', 'your-plugin-name-cpts' ), __( 'SAMPLE_MENU_POSITION', 'your-plugin-name-cpts' ), __( 'SAMPLE_DASHICON', 'your-plugin-name-cpts' ), __( 'SAMPLE_SLUG', 'your-plugin-name-cpts' ) );Your_Plugin_CPTS()->register_post_type('SAMPLEPOSTTYPE', __)
*
* Replace all "SAMPLE_BLAH_BLAH" with desired options.
*/