Skip to content

Instantly share code, notes, and snippets.

@sunriseweb
sunriseweb / latestposts_twentyten.php
Created November 28, 2011 19:00
List category posts - List category template - TwentyTen theme
<?php
/*
Plugin Name: List Category Posts - Template
Plugin URI: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
Description: Template file for List Category Post Plugin for Wordpress which is used by plugin by argument template=value.php
Version: 0.9
Author: Radek Uldrych & Fernando Briano
Author URI: http://picandocodigo.net http://radoviny.net
Modified by: Brad Trivers
Modified URI: http://sunriseweb.ca
@sunriseweb
sunriseweb / Genesis-page_archive.php-Menu-based-Site-Map
Last active February 26, 2018 17:53
Genesis page_archive.php template for creating Site Map that contains all Menus instead of Page (i.e. get all menus using wp_get_nav_menus and steps through to display each using wp_nav_menu).
<?php
/**
* Template Name: Menu-based Site Map
* This file creates a site map based on existing menus instead of using wp_list_pages.
*
* This file is based on the core Genesis file of the same name.
*
* @category Page Template
* @package Templates
* @author Brad Trivers
@sunriseweb
sunriseweb / profile_builder_pro_custom_taxonomy_checklist.php
Created August 20, 2013 17:50
Profile Builder Pro plugin ntegration to Populate Custom Taxonomy Checkboxes
/** Replace the "hotbuy_regions" checkbox options with terms from the location taxonomy
* see http://www.cozmoslabs.com/forums/topic/checkbox-name-when-filtering-using-wppb_x_checkbox_custom_field_y/#post-19294
*/
add_action( 'create_term', 'replace_hotbuy_regions', 10, 3 );
add_action( 'edit_term', 'replace_hotbuy_regions', 10, 3 );
add_action( 'delete_term', 'replace_hotbuy_regions', 10, 3 );
function replace_hotbuy_regions($term_id, $tt_id, $taxonomy) {
if($taxonomy == 'locations') {
$args = array(
@sunriseweb
sunriseweb / SyncProfileBuilderPro.php
Created October 2, 2013 13:30
AutoChimp WordPress Profile Builder plugin - when placed in the /wp-content/plugins/autochimp/plugins directory will allow sync of extra user fields created with Profile Builder.
<?php
/* Plugin that syncs with WordPress Profile Builder Plugin fields */
define( 'WP88_MC_SYNC_WPPB', 'wp88_mc_sync_wppb' );
define( 'WP88_WPPB_FIELD_MAPPING', 'wp88_mc_wppb_' );
class SyncProfileBuilderPro extends ACSyncPlugin
{
public function SyncProfileBuilderPro()
{
}
@sunriseweb
sunriseweb / wppb.register.php
Last active December 25, 2015 00:09
Profile Builder Pro changes to /wp-content/plugins/profile-builder-pro/front-end/wppb.register.php changes to support AutoChimp integration.
<?php
/* Hook to change auto generated password */
add_filter('random_password', 'signup_password_random_password_filter');
/**
* Function that changes the auto generated password with the one selected by the user.
*/
function signup_password_random_password_filter($password) {
global $wpdb;
if ( ! empty($_GET['key']) ) {
@sunriseweb
sunriseweb / wppb.edit.profile.php
Created October 8, 2013 14:47
Profile Builder Pro changes to /wp-content/plugins/profile-builder-pro/front-end/wppb.edit.profile.php changes to support AutoChimp integration.
<?php
/*
wp_update_user only attempts to clear and reset cookies if it's updating the password.
The php function setcookie(), used in both the cookie-clearing and cookie-resetting functions,
adds to the page headers and therefore must be called within the first php tag on the page, and
before the WordPress get_header() function. Since wp_update_user needs this, it must be at the
beginning of the page as well.
*/
$changesSaved = 'no';
$changesSavedNoMatchingPass = 'no';
@sunriseweb
sunriseweb / acf5_get_acf_field_groups_by_cpt.php
Last active May 18, 2021 08:11
Get ACF (Advanced Custom Field) field groups with their fields for a given custom post type. i.e. where the ACF location rule is "post_type == cpt".
/**
* Returns an array of field groups with fields for the passed CPT, where field group ACF location rule of "post_type == CPT" exists.
* - each field group points at an array of its fields, in turn pointed at an array of that field's detailed information:
* - array of info for each field [ ID, key, label, name, type, menu_order, instructions, required, id, class, conditional_logic[array()], etc. ]
*
* @since 1.0.0
*/
function get_acf_field_groups_by_cpt($cpt) {
// need to create cache or transient for this data?
@sunriseweb
sunriseweb / customize_genesis_search_query.php
Last active January 3, 2016 03:28
Modify search query using pre_get_posts in genesis theme.
<?php
/**
* Customize Search Query
*
* @author Brad Trivers
* @link http://sunriseweb.ca
* @param object $query data
*
*/
add_action( 'pre_get_posts', 'hotbuys_search_query' );
@sunriseweb
sunriseweb / et_postinfo_meta.php
Created April 30, 2014 12:06
Remove trailing pipe from single post meta in Divi child theme by modifing et_postinfo_meta in functions.php
<?php
//* Modify post meta to get rid of trailing pipe
function et_postinfo_meta( $postinfo, $date_format, $comment_zero, $comment_one, $comment_more ){
global $themename;
$postinfo_meta = '';
if ( in_array( 'author', $postinfo ) )
$postinfo_meta .= ' ' . esc_html__('by',$themename) . ' ' . et_get_the_author_posts_link() . ' | ';
@sunriseweb
sunriseweb / show_genesis_archive_title.php
Last active August 29, 2015 14:03
Show Titles on Archive pages and Blog page
<?php
//* Show titles on genesis archive pages - including blog page - is_home()
add_action ( 'genesis_before_loop', 'twpg_show_archive_title' );
function twpg_show_archive_title() {
if (is_category()) {
echo '<h1 class="entry-title">' . single_term_title('Articles in category: <span>', false) . '</span></h1>'; //Display Category or Tag title