Skip to content

Instantly share code, notes, and snippets.

/**
* Add Page Terms (Taxonomy) to Body Tag
*/
function pro_page_taxonomy_class_to_body( $classes ){
if ( $pageTaxonomy = get_the_terms( get_the_ID(), 'my_taxonomy_slug' ) ) {
foreach( $taxonomyTerm as $term ){
if(is_array($term)){
if(!empty($term['slug'])){
$termClass = 'mytaxonomy-' . $term['slug'];
array_push( $classes, $termClass );
<script>
var time = new Date();
var dayOfWeek = time.getDay();
// Set office opening time to 8:15am
var startTime = new Date().setHours(8,15);
// Set office closing time to 4:15pm
var endTime = new Date().setHours(16,15);
function make_star_bar( $atts ) {
$value = shortcode_atts( array(
'stars' =>5,
'color' => '#f00'
),$atts);
$prefix = 'star-bar-';
$uniqueClass = uniqid($prefix);
$percentage = 100 * $value['stars'] / 5;
$html = '<span class="'.$uniqueClass.'">&#9733;&#9733;&#9733;&#9733;&#9733;</span>
<style>
@tomusborne
tomusborne / gist:e45f6e9d51e980f72b586e2a143324a7
Created June 13, 2020 00:32
Set GenerateBlocks Container padding to 0 by default.
add_filter( 'generateblocks_defaults', function( $defaults ) {
$defaults['container']['paddingTop'] = '';
$defaults['container']['paddingRight'] = '';
$defaults['container']['paddingBottom'] = '';
$defaults['container']['paddingLeft'] = '';
return $defaults;
} );
@psahalot
psahalot / generatepress-elementor-locations.php
Last active March 20, 2020 10:10
Elementor Locations integration for GeneratePress
<?php
/**
* Elementor Pro integration.
*
* @package GeneratePress
* @subpackage Integration
*/
defined( 'ABSPATH' ) || die( "Can't access directly" );
@generatepress
generatepress / gist:2bb2667c9413e29579288687add966de
Created July 18, 2019 17:26
Integrate the Custom Fonts (https://wordpress.org/plugins/custom-fonts/) plugin with the GP Customizer.
add_filter( 'generate_typography_default_fonts', function( $fonts ) {
if ( ! class_exists( 'Bsf_Custom_Fonts_Taxonomy' ) ) {
return $fonts;
}
$all_fonts = Bsf_Custom_Fonts_Taxonomy::get_fonts();
if ( ! empty( $all_fonts ) ) {
foreach ( $all_fonts as $font_family_name => $fonts_url ) {
$fonts[] = $font_family_name;
@westcoastdigital
westcoastdigital / gf-readonly-fields.php
Created June 8, 2019 03:49
Enable option to make GF fields readonly
<?php
add_filter('gform_field_content', function ($field_content, $field) {
$fieldtype = $field['type'];
if( $fieldtype == 'text' || $fieldtype == 'email' || $fieldtype == 'number' || $fieldtype == 'phone' ) {
$readonlySupport = 'true';
} else {
$readonlySupport = 'false';
}
@rcg4u
rcg4u / gist:6e40e2738d24472e033f99203bcaee81
Created June 1, 2019 19:47
this is from Sridhar Katakam, this allows seopress to read Oxygen builder content. Get code snippets and add as a function.
add_filter( 'seopress_content_analysis_content', 'sp_content_analysis_content', 10, 2 );
/**
* Filter the analyzed content to add content from Oxygen editor.
* @param string $content Current content in the WordPress editor.
* @param int $id ID of the current entry.
* @return string Modified content.
*/
function sp_content_analysis_content( $content, $id ) {
// HTML of Oxygen's content.
@jan-koch
jan-koch / git-create-repo.sh
Last active May 24, 2019 13:06
A simple bash script to create a repository from the console. Be sure to replace "USERNAME" with your Github user name. This script utilizes nodegh.io.
#! /usr/bin/bash
NAME=$1
TYPE=$2
echo "Creating the repository"
gh re --browser false --new "$NAME" --type "$TYPE"
mkdir "$NAME"
cd "$NAME"
@megclaypool
megclaypool / Block Names.md
Last active August 16, 2021 00:50
[Setting up custom GUI style options for blocks in WP Gutenberg] Bill Erickson's [Block Styles in Gutenberg](https://www.billerickson.net/block-styles-in-gutenberg/) see Contra Costa backend for example :)

List of block names You need to know the full block name in order to attach or remove styles from it. Here’s a list of all the core blocks (excluding all the embed ones):

core/paragraph
core/image
core/heading
core/gallery
core/list
core/quote
core/audio