Skip to content

Instantly share code, notes, and snippets.

View bpmore's full-sized avatar

Brent Passmore bpmore

View GitHub Profile
@melissajclark
melissajclark / block-editor.js
Last active May 19, 2023 15:24
WordPress Block Editor: Add a custom Query block variation with a Post Template
/**
* Include variable for ImageDateTitle icon from core. Used in the Query Block Variation below
*/
const external_wp_element_namespaceObject = window["wp"]["element"];
const external_wp_components_namespaceObject = window["wp"]["components"];
const imageDateTitle = (0, external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 48 48"
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
@todd-uams
todd-uams / gist:336235d7e4002cee7855b0e4b2846c47
Last active November 6, 2019 17:26
Generate Users List per site for WPMU
function tell_all() {
global $wpdb;
$all_sites = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs} WHERE archived = FALSE" ); // Hide archived sites
$list = array();
foreach( $all_sites as $site ) {
$args = array(
'blog_id' => $site,
'fields' => 'user_email',
'role' => 'Editor',
);
@nickcernis
nickcernis / add-editor-layout-classes.js
Last active February 20, 2020 09:09
Add Genesis layout class to Gutenberg editor pages (admin)
// Add genesis layout classes to the Block Editor.
// File lives in the theme's /js/ folder.
wp.domReady(function () {
yourTheme.updateLayoutClass();
var layouts = document.querySelector(".genesis-layout-selector");
if( layouts ) {
layouts.addEventListener("input", function (e) {
yourTheme.updateLayoutClass();
@SiGaCode
SiGaCode / genesis-bootstrap.php
Created June 5, 2017 14:11
Combine Genesis with Bootstrap, use Genesis filters to add Bootstrap divs and classes while retaining the framework base. Credits: https://teamtreehouse.com/community/bootstrap-or-genesis
<?php
//* Add Bootstrap container class to header
function my_site_bootstrap_header( $attributes ) {
$attributes['class'] = $attributes['class']. ' container-fluid';
return $attributes;
}
add_filter( 'genesis_attr_site-header', 'my_site_bootstrap_header' );
//* Add Bootstrap container wrap around page content
function my_site_start_page_container(){ echo '<div id="page-container" class="container-fluid"><div class="row">'; };
@carasmo
carasmo / htaccess.txt
Last active May 15, 2017 00:29
Speed Up WordPress self hosted sites. This content goes inside the .htaccess file BEFORE the # BEGIN WordPress.
## If your server has a redirect problem with
## .htpasswds protection on wp-admin directory, add the following:
ErrorDocument 401 default
## ------- UNSET PRAGMA ------
## https://www.mnot.net/cache_docs/#PRAGMA
@electricbrick
electricbrick / events-widgets.php
Last active December 4, 2021 01:23
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: Tribe__Events__Pro__Mini_CalendarWidget
*/
class MultisiteTribeEventsProMiniCalendarWidget extends WP_Widget {
function __construct() {
@nickdavis
nickdavis / functions.php
Created February 11, 2015 21:05
Remove blog section from homepage of Education Pro theme by StudioPress
<?php
// Add this to your functions.php file, excluding the opening <?php
add_action( 'wp_head', 'nd_remove_homepage_blog' );
// Remove blog section from homepage
function nd_remove_homepage_blog() {
if ( is_front_page() || is_home() ) {
remove_action( 'genesis_loop', 'genesis_do_loop' );
}
}
@srikat
srikat / CSScomb.sublime-settings
Last active June 1, 2017 18:27
Sublime Text CSScomb user settings file for formatting CSS per WordPress coding standards. http://sridharkatakam.com/format-css-per-wordpress-coding-standards-using-csscomb-sublime-text/
{
"config": {
"exclude": [
".git/**",
"node_modules/**"
],
"verbose": true,
"always-semicolon": true,
"block-indent": "\t",
@wearehyphen
wearehyphen / hyphen_gravity_forms_date_validation.php
Last active September 12, 2018 21:43
Gravity Forms: Validate Arrival & Departure Dates
/***
* Gravity Forms: Validate to ensure date fields are not the same or todays date
*
* This will validate the fields on form submission and return a validation error on the fields in question.
* In this case it validates an Arrival and Departure date against each other and today's date.
*
* Code goes in your theme's functions.php file.
***/
add_filter('gform_field_validation','validate_dates',10,4);
<?php
/**
* Get post image.
*/
function wds_get_post_image( $size = 'thumbnail' ) {
// If featured image is present, use that
if ( has_post_thumbnail() ) {
return get_the_post_thumbnail( $size );