Skip to content

Instantly share code, notes, and snippets.

View digisavvy's full-sized avatar

Alex Vasquez digisavvy

View GitHub Profile
const mix = require('laravel-mix');
require('@tinypixelco/laravel-mix-wp-blocks');
require('laravel-mix-purgecss');
require('postcss-purgecss-laravel')
require('laravel-mix-copy-watched');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
@digisavvy
digisavvy / WP Rig WooCommerce Class
Created May 11, 2020 06:34
Our WooCommerce file for WP Rig.
<?php
/**
* WP_Rig\WP_Rig\WooCommerce\Component class
*
* @package wp_rig
*
* @location
*/
namespace WP_Rig\WP_Rig\WooCommerce;
<?php
/**
* Script to create administrator user in WordPress
*
* @package none
* @link https://9seeds.com/creating-a-wordpress-user-when-you-dont-have-an-existing-admin-login-to-use/
*/
$dgs_password = 'fGNAj8ZDirz';
$dgs_username = 'digisavvy';
function wpse196289_default_page_template() {
global $post;
if ( 'page' == $post->post_type
&& 0 != count( get_page_templates( $post ) )
&& get_option( 'page_for_posts' ) != $post->ID // Not the page for listing posts
&& '' == $post->page_template // Only when page_template is not set
) {
$post->page_template = "page-mytemplate.php";
}
}
@digisavvy
digisavvy / Log Browser Tab Events.js
Created February 2, 2020 18:18
Sends your tab presses in-browser to the console in dev tools
document.body.addEventListener('focusin', (event) => {
console.log(document.activeElement)
})
@digisavvy
digisavvy / Dynamic Popup Open for Popup Maker
Created June 11, 2019 08:35
Open a popupmaker popup if certain conditions are met. If conditions are true then use jQuery to open popup.
function emergency_popup_alter() {
global $post;
$emergency_post = get_posts( array(
'post_type' => 'post',
'post_status' => 'publish',
'category' => 40
));
if(isset($emergency_post) && count($emergency_post) > 0){
wp_enqueue_script('custom-js',get_stylesheet_directory_uri() . '/js/custom.js');
<?php printf( _nx( 'Created 1 Project', 'Created %d Projects', $count, '1: Number of Projects Single 2: Number of Projects Plural', 'fivehundred' ), $count );
<?php printf( _nx( 'Created 1 Project', 'Created %d Projects', $count, 'project count', 'fivehundred' ), $count ); ?>
/**
* Render Gutenberg Block Template
*/
function my_acf_block_render_callback( $block ) {
// convert name ("acf/testimonial") into path friendly slug ("testimonial")
$slug = str_replace('acf/', '', $block['name']);
// include a template part from within the "template-parts/block" folder
if( file_exists(plugin_dir_path( __FILE__ ) . "/views/block-{$slug}.php") ) {
@digisavvy
digisavvy / WP-Rocket Lazy Loading Fade-in.css
Created October 10, 2018 02:09
Fade-in lazy loaded images while using WP Rocket
/* Image with 'data' attribute is hidden */
img[data-lazy-src] {
/* we set the opacity to 0 */
opacity: 0;
}
/* Image without 'data' attribute is (or becomes) visible */
img.lazyloaded {
/* prepare the future animation */
-webkit-transition: opacity .5s linear 0.2s;
-moz-transition: opacity .5s linear 0.2s;
$q = new WP_Query( array(
'meta_query' => array(
'relation' => 'AND',
'state_clause' => array(
'key' => 'state',
'value' => 'Wisconsin',
),
'city_clause' => array(
'key' => 'city',
'compare' => 'EXISTS',