Skip to content

Instantly share code, notes, and snippets.

View phpbits's full-sized avatar
🎯
Focusing

Jeffrey Carandang phpbits

🎯
Focusing
View GitHub Profile
@phpbits
phpbits / editorskit.php
Created August 2, 2019 12:15
Using EditorsKit Utility Classes Filter
<?php
/**
* Add Support for EditorsKit Plugin
*
* @package Jarvis
* @subpackage EditorsKit
* @author Jeffrey Carandang <jeffreycarandang.com>
* @link https://editorskit.com/
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License
*/
@phpbits
phpbits / full-codes.js
Last active July 1, 2022 11:32
Extend core Gutenberg blocks with custom attributes and settings. View full tutorials here : https://jeffreycarandang.com/extending-gutenberg-core-blocks-with-custom-attributes-and-controls/
/**
* External Dependencies
*/
import classnames from 'classnames';
/**
* WordPress Dependencies
*/
const { __ } = wp.i18n;
const { addFilter } = wp.hooks;
@phpbits
phpbits / advanced-settings.js
Last active March 11, 2022 21:07
Add custom toggle control on Gutenberg Advanced Block Panel. View full tutorials at https://jeffreycarandang.com/extending-gutenberg-core-blocks-with-custom-attributes-and-controls/
/**
* WordPress Dependencies
*/
const { __ } = wp.i18n;
const { addFilter } = wp.hooks;
const { Fragment } = wp.element;
const { InspectorAdvancedControls } = wp.editor;
const { createHigherOrderComponent } = wp.compose;
const { ToggleControl } = wp.components;
@phpbits
phpbits / style.css
Last active February 5, 2022 09:28
Custom Image Block Style Variations
.is-style-circular-image img{
border-radius: 9999px !important;
object-fit: cover;
overflow: hidden;
}
.is-style-rounded-corners img{
border-radius: 0.5em;
overflow: hidden;
}
@phpbits
phpbits / format-underline.js
Last active April 27, 2021 17:45
Create custom Underline rich text format for Gutenberg editor. Learn more at https://jeffreycarandang.com/how-to-create-custom-text-formats-for-gutenberg-block-editor/
/**
* WordPress dependencies
*/
const { __ } = wp.i18n;
const { Fragment } = wp.element;
const { toggleFormat } = wp.richText;
const { RichTextToolbarButton, RichTextShortcut } = wp.editor;
const { registerFormatType } = wp.richText;
/**
@phpbits
phpbits / block-styles.js
Last active April 22, 2021 20:22
Create Custom Image Block Styles
/**
* WordPress dependencies
*/
const { __ } = wp.i18n;
const { registerBlockStyle } = wp.blocks;
registerBlockStyle( 'core/image' , {
name: 'default',
label: __( 'Default' ),
isDefault: true,
<?php
/**
* Plugin Name: My Custom Shortcodes
* Plugin URI: https://wordpress.org/plugins/my-custom-shortcodes/
* Description: Custom shortcode for plugin development talk
* Version: 1.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Jeffrey Carandang
* Author URI: https://jeffreycarandang.com/
/**
* External Dependencies
*/
import classnames from 'classnames';
/**
* Add custom element class in save element.
*
* @param {Object} extraProps Block element.
* @param {Object} blockType Blocks object.
@phpbits
phpbits / apiRequest.js
Created October 3, 2018 06:42
Using wp.apiRequest to access custom endpoints.
wp.apiRequest( { path: '/phpbits/test-blocks/v1/user-roles/' } )
.then(
( obj ) => {
console.log( obj );
}
);
@phpbits
phpbits / CitiesArray
Created February 20, 2014 07:48
USA States and Cities PHP Array
$cities = array(
'ALABAMA'=>
array("ABBEVILLE","ADAMSVILLE","ADDISON","AKRON","ALABASTER","ALBERTVILLE","ALEXANDER CITY","ALEXANDRIA","ALICEVILLE","ALLGOOD","ALTOONA","ANDALUSIA","ANDERSON","ANNISTON","ARAB","ARDMORE","ARGO","ARITON","ARLEY","ASHFORD","ASHLAND","ASHVILLE","ATHENS","ATMORE","ATTALLA","AUBURN","AUTAUGAVILLE","AVON","BABBIE","BAILEYTON","BANKS","BAY MINETTE","BAYOU LA BATRE","BEAR CREEK","BEATRICE","BEAVERTON","BELK","BENTON","BERRY","BESSEMER","BILLINGSLEY","BIRMINGHAM","BLACK","BLOUNTSVILLE","BLUE MOUNTAIN","BLUE RIDGE","BLUE SPRINGS","BOAZ","BOLIGEE","BON AIR","BRANCHVILLE","BRANTLEY","BRENT","BREWTON","BRIDGEPORT","BRIGHTON","BRILLIANT","BROOKSIDE","BROOKWOOD","BRUNDIDGE","BUTLER","BYNUM","CAHABA HEIGHTS","CALERA","CAMDEN","CAMP HILL","CARBON HILL","CARDIFF","CAROLINA","CARROLLTON","CASTLEBERRY","CEDAR BLUFF","CENTER POINT","CENTRE","CENTREVILLE","CHALKVILLE","CHATOM","CHELSEA","CHEROKEE","CHICKASAW","CHILDERSBURG","CITRONELLE","CLANTON","CLAY","CLAYHATCHEE","CLAYTON","CLEVELAND","CLIO