Skip to content

Instantly share code, notes, and snippets.

View KustomDeveloper's full-sized avatar
:octocat:
Building React Apps

Michael Hicks KustomDeveloper

:octocat:
Building React Apps
View GitHub Profile
@KustomDeveloper
KustomDeveloper / functions.js
Last active August 28, 2020 16:21
Puppeteer script to check if a site has a noindex tag
import {puppeteer} from 'puppeteer';
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://devstaging1.jsabeta.com/');
const meta = await page.$eval("head > meta[name='robots']", element => element.content);
@KustomDeveloper
KustomDeveloper / BB Accordions
Created November 18, 2020 15:06
Accordion Script
$(document).ready(() => {
var panelists = document.getElementsByClassName("guest-name");
var i;
for (i = 0; i < panelists.length; i++) {
panelists[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.display === "block") {
panel.style.display = "none";
@KustomDeveloper
KustomDeveloper / index.html
Last active July 14, 2022 06:39
Simple website with GSAP animations
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AlphaStar</title>
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,400i,600,700,900" rel="stylesheet">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css"> </head>
//Add to functions.php
<?php
function add_number_of_cart_items() {
global $woocommerce;
$cart_count = $woocommerce->cart->cart_contents_count;
?>
<script>
var cartCount = <?php echo $cart_count; ?>;
var node = document.createElement("span");
@KustomDeveloper
KustomDeveloper / commands.md
Last active February 1, 2021 14:13
Browser Syncing using browser-sync on wamp

Browser Sync Setup

Notes

'localhost/bugsy' is the local directory of the website inside the wamp folder

Commands

npm i browser-sync

$ browser-sync start --proxy 'localhost/bugsy' --files '**/*' --no-notify

@KustomDeveloper
KustomDeveloper / functions.php
Created February 11, 2021 20:39
Get data from contact form 7 submission for use in another function like for example: mailchimp, constant contact, etc.
function run_function_with_cf7_data($WPCF7_ContactForm) {
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
// $posted_data = $submission->get_posted_data();
$email = $submission->get_posted_data('your-email');
ob_start();
@KustomDeveloper
KustomDeveloper / functions.php
Created March 24, 2021 15:21
CF7 Error Notifications
/*
* Send Notification if a CF7 Form fails
*/
function cf7_error_notifications() { ?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailfailed', function( event ) {
<?php
wp_mail( 'youremail@gmail.com', 'Form Failed', 'CF7 Form failed to send', array('Content-Type: text/html; charset=UTF-8'));
?>
<?php
/*Add CTA Wp Bakery Component*/
class VcHubspotCta extends WPBakeryShortCode {
function __construct() {
add_action( 'init', array( $this, 'create_shortcode' ), 999 );
add_shortcode( 'vc_hubspot_cta', array( $this, 'render_shortcode' ) );
}
@KustomDeveloper
KustomDeveloper / functions.php
Created December 30, 2021 21:17
Register custom meta box on custom post type to show in wp rest api
/*
* Register custom meta box on custom post type to show in wp rest api
*
* Custom post type must support 'custom-fields' and have the 'show_in_rest' parameter set to true
*/
//Custom post type is 'audio' and custom meta box is 'cloud_url'
add_action( 'rest_api_init', function () {
register_rest_field( 'audio', 'cloud_url', array(
@KustomDeveloper
KustomDeveloper / main.js
Created July 29, 2022 19:20
Load Video On Click
<script>
jQuery(function() {
jQuery('.video-container').on('click', function(e) {
e.preventDefault();
var iframe = j(this).find('iframe');
var url = iframe.attr('data-src');
var srcValue = iframe.attr('src');
if(srcValue == 'about:blank') {