Created
January 20, 2020 22:53
-
-
Save garretthyder/91d1bdb5ce641c44c543e82a6cb745da to your computer and use it in GitHub Desktop.
BlockController for WPMVC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyApp\Controllers; | |
use WPMVC\MVC\Controller; | |
/** | |
* BlockController controller. | |
* | |
* | |
* @author Alejandro Mostajo <http://about.me/amostajo> | |
* @copyright 10Quality <http://www.10quality.com> | |
* @license MIT | |
* @package WPMVC\MyApp | |
* @version 1.0.0 | |
*/ | |
class BlockController extends Controller | |
{ | |
/** | |
* Renders the block. | |
* @since 1.0.0 | |
* | |
* @global WPMVC\Main $wpmvc | |
*/ | |
public function register() | |
{ | |
// Main app object | |
global $wpmvc; | |
// Register block script. | |
wp_register_script( | |
'wpmvc-block', | |
PLUGIN_URL . '/assets/blocks/wpmvc/editor.js', | |
[ 'wp-blocks', 'wp-element', 'wp-i18n', 'wp-api-fetch' ], | |
$wpmvc->config->get( 'version' ) | |
); | |
// Register block stylesheet. | |
wp_register_style( | |
'wpmvc-block', | |
PLUGIN_URL . '/assets/blocks/wpmvc/editor.css', | |
[ 'wp-edit-blocks' ], | |
$wpmvc->config->get( 'version' ) | |
); | |
// Register wpmvc block | |
register_block_type( 'wpmvc/block', [ | |
'editor_script' => 'wpmvc-block', | |
'editor_style' => 'wpmvc-block', | |
] ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment