Skip to content

Instantly share code, notes, and snippets.

View pixelstorm's full-sized avatar

pixelstorm pixelstorm

View GitHub Profile
@pixelstorm
pixelstorm / image_front_matter.md
Created November 4, 2024 19:25
markdown front matter for fetaured images

image: path: /assets/img/img_name alt: image_alt.

@pixelstorm
pixelstorm / canonical_conditional.js
Created October 16, 2024 05:41
shopify liquid canonical conditional statement
{% if template contains 'collection' and current_tags %}
<meta name="robots" content="noindex" />
<link rel="canonical" href="{{ shop.url }}{{ collection.url }}" />
{% else %}
<link rel="canonical" href="{{ canonical_url }}" />
{% endif %}
@pixelstorm
pixelstorm / add_class_to_submit_btn.php
Created October 12, 2024 21:21
Customise your gravity form submit function by adding this code to your functions php file.
add_filter( 'gform_submit_button', 'add_custom_css_classes', 10, 2 );
function add_custom_css_classes( $button, $form ) {
$dom = new DOMDocument();
$dom->loadHTML( $button );
$input = $dom->getElementsByTagName( 'input' )->item(0);
$classes = $input->getAttribute( 'class' );
$classes .= " btn btn--primary";
$input->setAttribute( 'class', $classes );
return $dom->saveHtml( $input );
}
@pixelstorm
pixelstorm / track-multiple-btn-clicks-on-page.js
Created October 12, 2024 18:47
Track button clicks with a specific classname. The tracking script we are using is for LinkedIn.
// Get all elements with the class "pop-action"
const buttons = document.querySelectorAll('.pop-action');
// Iterate through the NodeList of buttons and attach click event listeners
buttons.forEach(function(button) {
button.addEventListener('click', function() {
// Code to run when a button is clicked
console.log(`Button "${button.textContent}" clicked.`);
@pixelstorm
pixelstorm / start_paragraph_drupal_block.html.twig
Last active August 25, 2024 07:36
starting point for drupal paragraph block, just the html stuff and a twig variable for block_name.
{% set block_name = "example_class" %}
{% set classes = [
'paragraph',
'paragraph--type--' ~ paragraph.bundle|clean_class,
view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
not paragraph.isPublished() ? 'paragraph--unpublished',
block_name
] %}
{% block paragraph %}
{% block content %}
@pixelstorm
pixelstorm / add class to gravity forms submit btn
Created August 25, 2024 00:13
Adds two custom CSS classes to the submit button
add_filter( 'gform_submit_button', 'add_custom_css_classes', 10, 2 );
function add_custom_css_classes( $button, $form ) {
$dom = new DOMDocument();
$dom->loadHTML( $button );
$input = $dom->getElementsByTagName( 'input' )->item(0);
$classes = $input->getAttribute( 'class' );
$classes .= " my-custom-class another-one";
$input->setAttribute( 'class', $classes );
return $dom->saveHtml( $input );
}
@pixelstorm
pixelstorm / Dynamic gravity form emails
Created August 25, 2024 00:08
Using a wordpress posts meta field for dynamic gravity form emails
<?php function agent_notification( $notification, $form) {
//This example is using a form with the id of 1
if($form["id"] == 4){
global $post;
//the example email is stored in a post meta field called "_cmb_email"
//$agent_email = get_post_meta( $post->ID , '_cmb_email', true );
$agent_email = get_field('agent_email');
$notification['to'] = $agent_email;
@pixelstorm
pixelstorm / custom_yoast_schema
Last active August 24, 2024 19:41
schema_cheatsheet
add_filter( 'wpseo_schema_graph_pieces', 'yoast_add_graph_pieces', 11, 2 );
//sample adding the person content type
/**
* Adds Schema pieces to our output.
*
* @param array $pieces Graph pieces to output.
* @param \WPSEO_Schema_Context $context Object with context variables.
*
@pixelstorm
pixelstorm / Compress_html_custom_class
Last active May 20, 2019 21:48
Compress html custom wordpress class
/* -------------------------------------------------------------------------------------------------------- */
/* Customize HTML Compression */
/* -------------------------------------------------------------------------------------------------------- */
class WP_HTML_Compression
{
// Settings
protected $compress_css = true;
protected $compress_js = true;
protected $info_comment = true;
@pixelstorm
pixelstorm / register_custom_post_type
Created January 23, 2019 05:37 — forked from AnkanSoul/register_custom_post_type
Register Custom Post Type
// Register Custom Post Type
function slider() {
$labels = array(
'name' => _x( 'Post Types', 'Post Type General Name', 'Post Types' ),
'singular_name' => _x( 'Post Type', 'Post Type Singular Name', 'Post Types' ),
'menu_name' => __( 'Post Types', 'Post Types' ),
'name_admin_bar' => __( 'Post Type', 'Post Types' ),
'archives' => __( 'Item Archives', 'Post Types' ),
'parent_item_colon' => __( 'Parent Item:', 'Post Types' ),
'all_items' => __( 'All Items', 'Post Types' ),