Skip to content

Instantly share code, notes, and snippets.

View erickarbe's full-sized avatar

Erick Arbé erickarbe

View GitHub Profile
@erickarbe
erickarbe / square-website-builder-custom-css.js
Created April 11, 2022 15:29
How to add custom css to a square website
<script>
var parentWindow = window.parent;
// Create our stylesheet
var style = parentWindow.document.createElement('style');
style.innerHTML = `#YOUR_SELECTOR_HERE {max-width: 100% !important; padding: 0; overflow: hidden; }`;
// Get the first script tag
var ref = parentWindow.document.querySelector('script');
@erickarbe
erickarbe / functions.php
Created February 7, 2022 18:31
add netlify tags to gravity forms
//Add Netflify tag to GForms
add_filter( 'gform_form_tag', 'form_tag_netlify', 10, 2 );
function form_tag_netlify( $form_tag, $form ) {
$form_name = $form['title'];
$form_tag = str_replace( "<form ", "<form name='{$form_name}' data-netlify='true' action='/pages/success' ", $form_tag );
return $form_tag;
}
@erickarbe
erickarbe / functions.php
Created October 28, 2021 16:53
Send Gravity Form Data to a Custom Post Type with Advanced Custom Fields (ACF)
// Change "_2" to the ID of the form
add_action( 'gform_after_submission_2', 'add_to_awardpost', 10, 2 );
function add_to_awardpost($entry, $form) {
// Create the variables
$facility_name = rgar($entry, '1' );
$primary_contact_name = rgar($entry, '2' );
$primary_contact_title = rgar($entry, '3');
$primary_contact_email = rgar($entry, '4');
<?php
// Click to tweet functionality. Look for the username and hashtags at the end of the string.
$main_question = get_the_title();
$twitter_quote = get_field('twitter_quote');
?>
<div class="tweet-this">
<a class="click-tweet" href="http://twitter.com/share?text=<?php echo html_entity_decode($main_question); ?> &#34;<?php if($twitter_quote) { echo urlencode($twitter_quote); } ?>&#34; via <?php echo $fullname . ' ' . $twitter_handle; ?>&url=<?php echo $roundup_permalink; ?>&hashtags=backswing @getbackswing" target="_blank">
Click to Tweet
</a>
@erickarbe
erickarbe / Matchlink.txt
Created July 1, 2020 13:40
Regular Expression to match a link
@erickarbe
erickarbe / WooCommerce Price Next to Variation
Created January 15, 2018 15:59
Add the price next to the variation name on WooCommerce product
add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' );
function display_price_in_variation_option_name( $term ) {
global $wpdb, $product, $woocommerce;
if ( empty( $term ) ) return $term;
if ( empty( $product->get_id() ) ) return $term;
$result = $wpdb->get_col( "SELECT slug FROM {$wpdb->prefix}terms WHERE name = '$term'" );
@erickarbe
erickarbe / new_gist_file_0
Created June 29, 2017 14:21
Multi Toggle JS
jQuery( document ).ready( function( $ ) {
var $menu = $('#menu'),
$menulink = $('.menu-link'),
$menuTrigger = $('.has-submenu > a');
$menulink.click(function(e) {
e.preventDefault();
$menulink.toggleClass('active');
$menu.toggleClass('active');
@erickarbe
erickarbe / 0_reuse_code.js
Created June 13, 2017 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@erickarbe
erickarbe / gist:5ad0f24cc68f1061e46d506b2f25b4fe
Created March 28, 2017 15:06
Add rel="nofollow" to only PDF links in Wordpress content and excerpt
add_filter('the_content', 'my_nofollow');
add_filter('the_excerpt', 'my_nofollow');
function my_nofollow($content) {
return preg_replace_callback('/<a[^>]+\\.pdf/', 'my_nofollow_callback', $content);
}
function my_nofollow_callback($matches) {
$link = $matches[0];
$link = preg_replace("%(href=\S(?!$link))%i", 'rel="nofollow" $1', $link);
return $link;
}
@erickarbe
erickarbe / gist:8700464
Created January 30, 2014 00:46
Simple pagination for WordPress loops
<?php
function simple_pagination($pages = '', $range = 2){
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{