Skip to content

Instantly share code, notes, and snippets.

View bpmore's full-sized avatar

Brent Passmore bpmore

View GitHub Profile
@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 / 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 / sort-tabs.txt
Created June 9, 2016 17:41
Sort Tabs in Google Spreadsheets
1. Copy/Paste the information below to the clipboard
2. Open the spreadsheet whose sheets need to be alphabetised
3. Choose Tools > Script editor > Blank (this opens a new tab in the browser)
4. Press Control+A followed by Control+V copy and paste the script in
5. Press Control+S to save the script
6. Choose Run > sortSheets
7. Go back to the spreadsheet tab to view the new sorted tab order
--Copy everything below this line--
function sortSheets () {
@bpmore
bpmore / array.txt
Created August 27, 2015 16:42
Function to print the $menu and $submenu array in WordPress.
//Found here: https://wordpress.org/support/topic/how-to-rename-the-admin-sub-menu-name-of-a-custom-post-category-or-tag
function wptutsplus_change_post_menu_label() {
global $menu;
global $submenu;
echo "<pre>";
print_r($menu);
print_r($submenu);
echo "</pre>";
}
add_action( 'admin_menu', 'wptutsplus_change_post_menu_label' );
@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 / 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 / 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 / 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 / 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;
}