Skip to content

Instantly share code, notes, and snippets.

View bpmore's full-sized avatar

Brent Passmore bpmore

View GitHub Profile
@bpmore
bpmore / clean-post-meta.txt
Last active January 29, 2021 20:46
Delete All Post Meta Except Thumbnail In WordPress Pages and Posts
//Originally found here: https://www.kvcodes.com/2015/12/delete-all-post-meta-except-thumbnail-in-wordpress-posts/
//Copy from line 3 to the end and paste into your theme's function file.
function kv_delete_all_meta_except_featuredimg(){
$args = array( 'posts_per_page' => -1, 'post_status' => 'any', 'post_type' => array('attachment', 'page','post'));
$articles= get_posts( $args );
foreach($articles as $article){
if($article->post_type == 'attachment'){
$myvals = get_post_meta($article->ID);
foreach($myvals as $key=>$val) {
@bpmore
bpmore / limit_editor_widgets.php
Last active May 2, 2019 03:24
Limit access to WordPress and Genesis widgets for the Editor Role.
<?PHP
// Allow Editors to manage Widgets and Menus
function sp_editor_capabilities() {
$editor = get_role( 'editor' );
if (!$editor->has_cap( 'edit_theme_options' ) ) {
$editor->add_cap( 'edit_theme_options' );
}
@bpmore
bpmore / header_switch.php
Last active April 15, 2019 20:38
Header with image or header with image and page title -- work in progress -- for Genesis WordPress.
<?php
// This adds logo to header, adds page title if using special page template, and...
//
// Here goes the logo in Header
//
add_action( 'genesis_header', 'ursidae_site_image', 5 );
function ursidae_site_image() {
if ( is_page_template( array( 'page_special.php', 'page_other_special.php' ) ) ) {
@bpmore
bpmore / dates.txt
Created March 8, 2018 21:08
National & Global Holiday Calendar: 2018-2019
January 2018
2: Science Fiction Day #ScienceFictionDay
4: National Trivia Day #NationalTriviaDay
5: National Bird Day #NationalBirdDay
8: Clean Off Your Desk Day #CleanOffYourDeskDay
11: Human Trafficking Awareness Day #HumanTraffickingDay
13: National Sticker Day #NationalStickerDay
15: Martin Luther King, Jr. Day #MLKDay
National Hat Day #NationalHatDay
18: Get to Know Your Customers Day (third Thursday of every quarter) #GetToKnowYourCustomersDay
@bpmore
bpmore / last-modified.php
Created May 26, 2017 15:00
Add last modified to WordPress admin for page and post listings
/** Andrew Norcross - Date Modified Display - http://andrewnorcross.com/tutorials/modified-date-display/ */
// Post Columns
add_action ( 'manage_posts_custom_column', 'rkv_post_columns_data', 10, 2 );
add_filter ( 'manage_edit-post_columns', 'rkv_post_columns_display' );
function rkv_post_columns_data( $column, $post_id ) {
switch ( $column ) {
case 'modified':
$m_orig = get_post_field( 'post_modified', $post_id, 'raw' );
$m_stamp = strtotime( $m_orig );
$modified = date('n/j/y @ g:i a', $m_stamp );
@bpmore
bpmore / remove-post-title-link-for-category.php
Last active April 25, 2017 20:58
Remove the link from post titles in a specified category or taxonomy.
//* Remove the link from each post titles in a specific category
add_filter( 'genesis_post_title_output', 'uca_post_title_output', 15 );
function uca_post_title_output( $title ) {
if ( in_category( 'uncategorized' ) || in_category( 'category-2' )) {
$title = sprintf( '<h2 class="entry-title">%s</h2> ', apply_filters( 'genesis_post_title_text', get_the_title() ) );
return $title;
}
return $title;
}
@bpmore
bpmore / kill-fusion.php
Created April 6, 2017 03:11
remove fusion builder shortcodes
<?php
add_filter('the_content', 'remove_fusion_shortcodes', 20, 1);
function remove_fusion_shortcodes( $content ) {
$content = preg_replace('/\[\/?fusion.*?\]/', '', $content);
return $content;
}
?>
**Tested with WP All Import and Export**
@bpmore
bpmore / gf-cal
Last active August 6, 2019 04:25
gravity forms calendar picker
Make the date picker start 2 weeks from current date.
Find this in your form:
<input name="input_26" id="input_2_26" type="text" value="" class="datepicker medium mdy datepicker_with_icon hasDatepicker">
The id above equals the formID and fieldID below.
<script type="text/javascript">
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 2 && fieldId == 26 ) {
@bpmore
bpmore / brown-august10.css
Last active August 10, 2016 14:21
Brown Original CSS
body {
font-family: 'Merriweather', serif;
font-weight: 400;
font-style: normal;
}
.et_pb_gutters1 .et_pb_column .et_pb_module {
border: 1px solid #eee;
}
@bpmore
bpmore / events-widgets.php
Created August 2, 2016 18:56 — forked from tomfinitely/events-widgets.php
The Events Calendar Pro - Cross-site Events Widget
<?php
if ( ! defined( 'ABSPATH' ) ) die('-1');
/*
* WDG-customized version of the Events Calendar Pro mini calendar widget.
* Changes are noted inline.
* Replacing class name: TribeEventsMiniCalendarWidget
*/
class MultisiteTribeEventsMiniCalendarWidget extends WP_Widget {
function __construct() {