This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Featured Custom Post Type Widget | |
Plugin URI: http://www.sennza.com.au | |
Description: Lists out all the custom post type posts in a dropdown so the user can selected a CPT to feature. | |
Version: 1.0 | |
Author: Bronson Quick | |
Author URI: http://www.sennza.com.au | |
License: GPL2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Append the Gravity Forms ID to the end of the filter so that the validation only runs on this form | |
add_filter('gform_validation_1', 'custom_validation'); | |
function custom_validation($validation_result){ | |
$form = $validation_result["form"]; | |
foreach($form['fields'] as &$field){ | |
/* Check that the value of the field that was submitted. e.g. the name="input_1" that is generated by Gravity Forms */ | |
if($_POST['input_1'] == "Your First Name"){ | |
// set the form validation to false | |
$validation_result["is_valid"] = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Learning Seat Homepage Slider Custom Post Type | |
Plugin URI: http://www.sennza.com.au | |
Description: Custom Post Type to populate slider on the homepage | |
Version: 1.0 | |
Author: Bronson Quick | |
Author URI: http://www.sennza.com.au | |
License: GPL2 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php add_filter('the_content', 'shortcode_empty_paragraph_fix'); | |
// Shortcodes | |
function shortcode_empty_paragraph_fix($content) | |
{ | |
$array = array ( | |
'<p>[' => '[', | |
']</p>' => ']', | |
']<br />' => ']' | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//This is a filter to change the default validation message that Gravity Forms generates | |
add_filter('gform_validation_message', 'change_validation_message', 10, 2); | |
function change_validation_message($message, $form) | |
{ | |
return "<div class='validation_error'><strong>Oops!</strong> Looks like there’s something wrong. Please review the form above.</div>"; | |
} | |
// Often forms in Gravity Forms to need to start with default values and we need to check the form in case the user hasn't entered new data and give them a validation message back |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function debthelpline_add_meta_boxes(){ | |
// Add the Subheading meta box | |
add_meta_box( 'debthelpline_banner_subheading', __( 'Banner Subheading', 'debthelpline' ), 'debthelpline_subheading_meta_box', 'page', 'normal', 'high' ); | |
} | |
add_action( 'add_meta_boxes', 'debthelpline_add_meta_boxes' ); | |
function debthelpline_subheading_meta_box( $post ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Quite often we create sites that need a blurb on the homepage that needs to be different than the page content. | |
To get around this we like adding excerpts to pages */ | |
add_post_type_support( 'page', 'excerpt' ); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php /* This code filters the Categories archive widget to include the post count inside the link */ | |
add_filter('wp_list_categories', 'cat_count_span'); | |
function cat_count_span($links) { | |
$links = str_replace('</a> (', ' (', $links); | |
$links = str_replace(')', ')</a>', $links); | |
return $links; | |
} | |
/* This code filters the Archive widget to include the post count inside the link */ | |
add_filter('get_archives_link', 'archive_count_span'); | |
function archive_count_span($links) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* gform_pre_submission will do all forms. gform_pre_submission_1 will do a form with an ID of 1 | |
* Keep an eye on the priority of the filter. In this case I used 9 because the Salesforce plugin we used ran a presubmission filter at 10 so we needed this to happen before it | |
*/ | |
add_filter( "gform_pre_submission_1", "add_salesforce_campaign_id_footer", 9 ); | |
function add_salesforce_campaign_id_footer( $form ){ | |
foreach($form["fields"] as &$field) | |
if($field["id"] == 2){ | |
/* Set the variable you want here - in some cases you might need a switch based on the page ID. | |
* $page_id = get_the_ID(); |