Skip to content

Instantly share code, notes, and snippets.

View phpbits's full-sized avatar
🎯
Focusing

Jeffrey Carandang phpbits

🎯
Focusing
View GitHub Profile
<?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/
<?php
/**
** Add custom body class
**/
add_filter('body_class', 'custom_body_class');
function custom_body_class( $classes ) {
$classes[] = 'new-body-class';
return $classes;
}
?>
<?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' );
.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);
}
}
.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);
}
}
@import "./blocks/container/style.scss";
@import "./blocks/container/editor.scss";
/**
* WordPress dependencies
*/
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const { InnerBlocks } = wp.blockEditor;
registerBlockType( 'custom-block/container', {
title: __( 'Custom Container' ),
/**
* Internal dependencies
*/
import './blocks/container';
<?php
/**
* Plugin Name: My Custom Block
* Plugin URI: https://github.com/phpbits/my-custom-block
* Description: Custom Gutenberg block for tutorial purposes
* Version: 1.0
* Author: Jeffrey Carandang
* Author URI: https://jeffreycarandang.com/
*
* @category Gutenberg