Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Benjamin Intal bfintal

🎯
Focusing
Block or report user

Report or block bfintal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bfintal
bfintal / query.sql
Created Feb 25, 2020
Remove duplicate entries in MySQL table when you have no unique IDs. Change `mytable` to the name of your table.
View query.sql
CREATE TABLE `temp` like `mytable`;
INSERT `temp` SELECT DISTINCT * FROM `mytable`;
DROP TABLE `mytable`;
ALTER TABLE `temp` RENAME `mytable`;
View index.js
import { registerPlugin } from '@wordpress/plugins'
import { useEffect } from '@wordpress/element'
const doSomething = () => {
useEffect( () => {
// Do whatever when the block editor is initialized.
}, [] )
return null
}
View index.js
import domReady from '@wordpress/dom-ready'
domReady( () => {
if ( window._wpLoadBlockEditor ) {
window._wpLoadBlockEditor.then( function() {
// Do whatever when the block editor is initialized.
} )
}
} )
View gist:df55dc8868ff89518c844badc051552d
add_action( 'wp_head', function () { ?>
<script>
window.addEventListener( 'scroll', function() {
const limit = document.body.classList.contains( 'home' ) ? 300 : 50
if ( ( window.pageYOffset || document.body.scrollTop ) > limit ) {
if ( ! document.body.classList.contains( 'is-scrolling' ) ) {
document.body.classList.add( 'is-scrolling' )
}
} else {
if ( document.body.classList.contains( 'is-scrolling' ) ) {
@bfintal
bfintal / functions.php
Created Nov 12, 2019
Stackable child theme
View functions.php
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( 'parent-style' ),
wp_get_theme()->get( 'Version' )
);
}
@bfintal
bfintal / functions.php
Created Sep 30, 2019
Add this in your theme's functions.php to disable blog post image size generation in Stackable
View functions.php
<?php
// Disable blog post image size generation in Stackable.
remove_action( 'after_setup_theme', 'stackable_blog_posts_image_sizes' );
?>
View gist:d711cd81b36a41cd4d25a1012eeb3a82
.ugb-image-upload-has-placeholder[data-is-placeholder-visible="true"] {
display: flex !important;
}
View gist:b653fa49d2c7b2c8ff11d21f029390ec
setTimeout( function() {
var ttes = document.querySelectorAll( '.tte_wrapper' );
Array.prototype.forEach.call( ttes, function( el ) {
var typeAttr = el.getAttribute( 'data-effect' );
// Make the element visible and remove original text.
// Original text is for SEO.
var mid = el.querySelector( '.tte_mid' );
mid.innerHTML = '';
mid.style.opacity = '';
@bfintal
bfintal / cheatsheet.js
Created Feb 6, 2019
Gutenberg Cheat Sheet
View cheatsheet.js
// Get the data of a block
wp.data.select( 'core/editor' ).getBlocks()[0]
// Update attributes of another block
// wp.data.dispatch( 'core/editor' ).updateBlockAttributes( clientID, attributes )
wp.data.dispatch( 'core/editor' ).updateBlockAttributes( '10d88a6d-95d6-4e07-8293-5f59c83a26c0', { heading: 'New Heading' } )
// Get currently selected block.
wp.data.select( 'core/editor' ).getBlockSelectionStart()
@bfintal
bfintal / Development.md
Last active Apr 8, 2019
Creating a Custom Client WordPress Website from A PSD Design - A Gambit Technologies, Inc. Developer Guide
View Development.md

Creating a Custom Client WordPress Website from A PSD Design

(This is a Gambit Technologies, Inc. Developer Guide)

Development of a website from scratch is done by:

  1. Creating a customized WordPress theme using Sage by Roots,
  2. Creating the pages then creating the content either using a page builder, or by adding pure HTML content, then adding styles into the customized theme,
  3. Installing plugins from the WordPress plugin directory for added functionality, configuring them and customizing their styles.

We will use the following tools/projects/code bases:

You can’t perform that action at this time.