Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Jeffrey Carandang phpbits

🎯
Focusing
View GitHub Profile
@phpbits
phpbits / gist.html
Created Nov 19, 2019
CoBlocks Gist Block Demo.
View gist.html
CoBlocks Github Gist Block Demo.
View custom_shortcode.php
<?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/
View add_body_class.php
<?php
/**
** Add custom body class
**/
add_filter('body_class', 'custom_body_class');
function custom_body_class( $classes ) {
$classes[] = 'new-body-class';
return $classes;
}
?>
View add_action_scripts.php
<?php
/**
** Add custom scripts
**/
add_action( 'wp_enqueue_scripts', 'my_custom_scripts' );
function my_custom_scripts(){
wp_enqueue_script( 'custom_js', plugins_url( 'js/custom.js', __FILE__ ), array(), '1.0.0', true );
wp_register_style( 'custom_css', plugins_url( 'style.css', __FILE__ ), false, '1.0.0', true );
wp_enqueue_style ( 'custom_css' );
View style.scss
.entry-content {
.wp-block-custom-block-container {
padding: 30px 50px;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}
}
View editor.scss
.wp-block[data-type="custom-block/container"] {
> .block-editor-block-list__block-edit {
padding: 30px 50px;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}
}
View style.scss
@import "./blocks/container/style.scss";
View editor.scss
@import "./blocks/container/editor.scss";
View index.js
/**
* WordPress dependencies
*/
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const { InnerBlocks } = wp.blockEditor;
registerBlockType( 'custom-block/container', {
title: __( 'Custom Container' ),
View index.js
/**
* Internal dependencies
*/
import './blocks/container';
You can’t perform that action at this time.