Skip to content

Instantly share code, notes, and snippets.

@benilla
benilla / main.js
Created September 14, 2018 16:59
PHP / WORDPRESS - Mailchimp Sub
jQuery(document).ready(function($) {
function list_sub(form, btn){
input = {
action : 'actionSubscribe',
group_id : $('.form-subscribe input[name=form-subscribe-type]:checked').val(),
fname : form.find('.inputFname').val(),
lname : form.find('.inputLname').val(),
email : form.find('.inputEmail').val(),
@pento
pento / php-block.js
Last active March 20, 2025 14:59
Converting a shortcode to a block: this method is fast to do, but a mediocre UX. You should only use this as a stopgap until you can implement a full block UI.
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.
@wpscholar
wpscholar / .eslintignore
Last active March 14, 2022 10:21
Webpack 4 Config for WordPress plugin, theme, and block development
**/*.min.js
**/*.build.js
**/node_modules/**
**/vendor/**
build
coverage
cypress
node_modules
vendor
@chrismccoy
chrismccoy / gutenberg.txt
Last active March 13, 2025 19:11
Gutenberg Resources
Eliminate All Blocks from Editor
wp.data.dispatch( 'core/block-editor' ).resetBlocks([]);
How to disable and lock Gutenberg blocks
https://kinsta.com/blog/disable-gutenberg-blocks/
Convert group of file blocks to ACF block
https://bdwm.be/gutenberg-case-study-convert-group-of-file-blocks-to-acf-block/
Enabling Gutenberg-Based Custom Post Types and Taxonomies
@zgordon
zgordon / gutenberg-babelrc
Last active July 22, 2021 08:34
An example .babelrc file for working with Gutenberg
{
"presets": [ "@wordpress/default" ],
"plugins": [
"transform-object-rest-spread",
[
"transform-react-jsx",
{
"pragma": "wp.element.createElement"
}
],
@igorbenic
igorbenic / block.js
Last active April 22, 2022 22:25
Gutenberg Select Post - Duplicate Controls
/**
* BLOCK: my-block
*
* Registering a basic block with Gutenberg.
* Simple block, renders and saves the same content without any interactivity.
*/
// Import CSS.
import './style.scss';
import './editor.scss';
@richtabor
richtabor / starter-content-custom-logo.php
Last active December 10, 2023 22:34
Adding a custom logo to a WordPress theme's starter content.
<?php
/**
* Theme defaults and support for WordPress features.
*/
function prefix_setup() {
/*
* Define starter content for the theme.
* See: https://make.wordpress.org/core/2016/11/30/starter-content-for-themes-in-4-7/
*/
@Netzberufler
Netzberufler / scroll-to-top.js
Created September 28, 2017 14:39
Scroll to Top
/**
* Scroll to Top JS
*/
( function( $ ) {
$.fn.scrollToTop = function() {
var scrollButton = $( this );
@kissarat
kissarat / square.html
Last active May 9, 2020 11:40
Change order and sort randomly elements
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Square</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
@Paul-frc
Paul-frc / flex-for-ie-10-and-safari.css
Last active October 1, 2021 09:07
the flexbox equiv. for IE10
/* ==================== */
/* container attributes */
/* ==================== */
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-direction: row | column | row-reverse | column-reverse;
-webkit-flex-direction: row | column | row-reverse | column-reverse;