dw-guten.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. Plugin Name: DW Guten
  4. Description: Block-editor "Post Meta" sidebar (og:video / og:image / meta description) and sup/sub text formats.
  5. Author: windhamdavid
  6. Version: 0.4
  7. Author URI: https://davidawindham.com
  8. */
  9. defined( 'ABSPATH' ) or die( 'yeah right' );
  10. // Register the post meta consumed by the theme's OpenGraph / description output.
  11. include_once __DIR__ . '/metabox.php';
  12. /**
  13. * Block-editor assets. Both scripts are plain (no build step) and use the
  14. * global wp.* runtime, versioned by filemtime so a stale browser cache can't
  15. * pin an old copy across edits.
  16. */
  17. function dw_guten_block_editor_assets() {
  18. // sup / sub RichText toolbar formats.
  19. wp_enqueue_script(
  20. 'dw-guten-formats',
  21. plugins_url( 'dw-guten.js', __FILE__ ),
  22. array( 'wp-rich-text', 'wp-element', 'wp-editor' ),
  23. filemtime( __DIR__ . '/dw-guten.js' ),
  24. true
  25. );
  26. // Post Meta sidebar.
  27. wp_enqueue_script(
  28. 'dw-guten-sidebar',
  29. plugins_url( 'sidebar.js', __FILE__ ),
  30. array( 'wp-plugins', 'wp-editor', 'wp-element', 'wp-components', 'wp-data', 'wp-i18n' ),
  31. filemtime( __DIR__ . '/sidebar.js' ),
  32. true
  33. );
  34. }
  35. add_action( 'enqueue_block_editor_assets', 'dw_guten_block_editor_assets' );