Skip to content

Instantly share code, notes, and snippets.

View alinademi's full-sized avatar

Ali Demi alinademi

  • Vancouver
View GitHub Profile
@gziolo
gziolo / dev-note-5.8-block-editor.md
Last active March 7, 2023 00:50
Block Editor filter changes in WordPress 5.8

Block Editor Changes

We have reached the first WordPress core release where the post editor is no longer the only screen that uses the block editor. In the middle of the development process, we found out that several WordPress hooks defined on the server depended on the $post object that isn’t present on the updated screen that lets users edit widgets using blocks. Therefore, we decided to deprecate some of the existing filters and introduce their context-aware replacements. This way, we ensure that we can continue iteratively enabling the block-based paradigm on different screens like the navigation editor screen by leveraging the new WP_Block_Editor_Context class that will receive more capabilities over time. There are also new methods introduced that allow code reuse for the functionality that needs to be shared between the screen that uses the block editor.

Related Trac ticket: #52920.

Class

WP_Block_Editor_Context

@gmmedia
gmmedia / functions.php
Last active December 7, 2024 02:00
Add featured image column to WP admin panel - posts AND pages
<?php
/**
* Add featured image column to WP admin panel - posts AND pages
* See: https://bloggerpilot.com/featured-image-admin/
*/
// Set thumbnail size
add_image_size( 'j0e_admin-featured-image', 60, 60, false );
@ajvillegas
ajvillegas / 01-custom-block.js
Last active November 13, 2025 08:16
Sample custom WordPress editor block and sidebar controls using using ES5 JavaScript syntax.
/**
* Custom WordPress block boilerplate.
*
* @package My_Block_Package
* @author Alexis J. Villegas
* @link http://www.alexisvillegas.com
* @license GPL-2.0+
*/
( function( blocks, editor, element ) {
@abdorah
abdorah / HttpCrudRequests.js
Last active September 25, 2022 18:07
async fetch class that make it easy to perform http crud request in vanilla js.
class HttpCrudRequests {
async get(url) {
const res = await fetch(url)
const data = await res.json()
return data
}
async post(url, post) {
const res = await fetch(url, {
@morgyface
morgyface / add_the_categories.php
Created November 25, 2020 17:21
WordPress | Add categories programmatically on theme activation
<?php
// Sets the default categories
function add_the_categories() {
$categories = array(
'Case Study',
'Blog',
'Article'
);
foreach( $categories as $category ) {
$exists = term_exists( $category, 'category' );
@ahmadawais
ahmadawais / notion2blog.js
Created November 3, 2020 15:12 — forked from mayneyao/notion2blog.js
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@SerhatTeker
SerhatTeker / clean-ubuntu
Last active November 27, 2024 03:37 — forked from Iman/clean.sh
Free up disk space on Ubuntu - clean log, cache, archive packages/apt archives, orphaned packages, old kernel and remove the trash
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
# vim: set ft=sh et ts=4 sw=4 sts=4:
# INFO
# --------------------------------------------------------------------------------------
# Free up disk space on Debian, Ubuntu - clean log, cache, archive packages/apt archives,
# orphaned packages, old kernel and remove the trash
#
# Gist repo:
@br3ndonland
br3ndonland / github-actions-notes.md
Last active November 25, 2025 23:54
Getting the Gist of GitHub Actions
@them-es
them-es / functions.php
Last active November 22, 2020 05:17
Ninja Forms: Server side spam protection using WordPress comment blacklist keys
<?php
/**
* [Update] This Gist has been integrated into the WordPress Plugin "I don't like Spam!" which supports more WordPress Contact Forms:
* https://wordpress.org/plugins/i-dont-like-spam
*
* Ninja Forms: Server side spam protection making use of the WordPress Comment Blocklist
* https://developer.ninjaforms.com/codex/custom-server-side-validation
*
* Enter your blocklist here: Settings > Discussion > Comment Blocklist
* https://developer.wordpress.org/reference/functions/wp_blacklist_check
@florianbrinkmann
florianbrinkmann / index.js
Last active October 24, 2024 11:59
Gutenberg FormTokenField block with posts as source
/**
* External dependencies
*/
const { isUndefined, pickBy } = lodash;
/**
* WordPress dependencies
*/
const {
registerBlockType,