diff --git a/build/form/index.asset.php b/build/form/index.asset.php index 0f67afc0..397817ea 100644 --- a/build/form/index.asset.php +++ b/build/form/index.asset.php @@ -1,9 +1,9 @@ array( - 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', + 'wp-element', 'wp-i18n' ), - 'version' => 'e056a17c669416c21348' + 'version' => '43b24c15aeddfa9be3e0' ); diff --git a/build/form/index.js b/build/form/index.js index f4f606f3..4b1a6386 100644 --- a/build/form/index.js +++ b/build/form/index.js @@ -1 +1 @@ -(()=>{"use strict";const e=window.wp.blocks,n=window.wp.blockEditor,o=window.wp.i18n,s=JSON.parse('{"UU":"webmention/form"}'),t=window.ReactJSXRuntime;(0,e.registerBlockType)(s.UU,{edit:()=>{const e=(0,n.useBlockProps)({className:"webmention-form"});return(0,t.jsxs)("div",{...e,children:[(0,t.jsxs)("p",{className:"webmention-form__source",children:[(0,t.jsx)("label",{htmlFor:"webmention-source-preview",children:(0,o.__)("Replied on your own website? Enter the URL of your post to let me know:","webmention")}),(0,t.jsx)("input",{id:"webmention-source-preview",className:"webmention-source",type:"url",placeholder:"https://",disabled:!0})]}),(0,t.jsxs)("div",{className:"webmention-form__submit",children:[(0,t.jsx)("button",{className:"webmention-submit wp-element-button wp-block-button__link",type:"button",disabled:!0,children:(0,o.__)("Ping me!","webmention")}),(0,t.jsx)("details",{className:"webmention-form__help",children:(0,t.jsx)("summary",{children:(0,o.__)("How does this work?","webmention")})})]})]})}})})(); \ No newline at end of file +(()=>{"use strict";const e=window.wp.blocks,t=window.wp.element,n=window.wp.blockEditor,o=window.wp.i18n,m=JSON.parse('{"UU":"webmention/form"}');(0,e.registerBlockType)(m.UU,{edit:()=>{const e=(0,n.useBlockProps)({className:"webmention-form"});return(0,t.createElement)("div",e,(0,t.createElement)("p",{className:"webmention-form__source"},(0,t.createElement)("label",{htmlFor:"webmention-source-preview"},(0,o.__)("Replied on your own website? Enter the URL of your post to let me know:","webmention")),(0,t.createElement)("input",{id:"webmention-source-preview",className:"webmention-source",type:"url",placeholder:"https://",disabled:!0})),(0,t.createElement)("div",{className:"webmention-form__submit"},(0,t.createElement)("button",{className:"webmention-submit wp-element-button wp-block-button__link",type:"button",disabled:!0},(0,o.__)("Ping me!","webmention")),(0,t.createElement)("details",{className:"webmention-form__help"},(0,t.createElement)("summary",null,(0,o.__)("How does this work?","webmention")))))}})})(); \ No newline at end of file diff --git a/includes/class-webmention.php b/includes/class-webmention.php index 7da9a272..b3492e66 100644 --- a/includes/class-webmention.php +++ b/includes/class-webmention.php @@ -188,7 +188,7 @@ public function register_constants() { * Enqueue scripts. */ public function enqueue_scripts() { - if ( is_singular() ) { + if ( is_singular() || is_home() || is_archive() ) { wp_enqueue_style( self::TEXT_DOMAIN, WEBMENTION_PLUGIN_URL . 'assets/css/webmention.css', array(), $this->get_version() ); } } diff --git a/src/form/index.js b/src/form/index.js index 5343bfab..c5a0669b 100644 --- a/src/form/index.js +++ b/src/form/index.js @@ -1,3 +1,8 @@ +/* + * @jsxRuntime classic + * @jsx createElement + */ + /** * Webmention Form block. * @@ -5,6 +10,7 @@ * the editor only shows a static preview. */ import { registerBlockType } from '@wordpress/blocks'; +import { createElement } from '@wordpress/element'; import { useBlockProps } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; diff --git a/tests/phpunit/tests/class-test-webmention.php b/tests/phpunit/tests/class-test-webmention.php index 91447504..b28f4bad 100644 --- a/tests/phpunit/tests/class-test-webmention.php +++ b/tests/phpunit/tests/class-test-webmention.php @@ -9,6 +9,30 @@ * Test Webmention class. */ class Test_Webmention extends WP_UnitTestCase { + /** + * Test that post content keeps its styles on singular, home, and archive views. + */ + public function test_content_styles_are_enqueued() { + $category_id = self::factory()->category->create(); + $post_id = self::factory()->post->create( array( 'post_category' => array( $category_id ) ) ); + $urls = array( + get_permalink( $post_id ), + home_url( '/?post_type=post' ), + get_category_link( $category_id ), + ); + + try { + foreach ( $urls as $url ) { + wp_dequeue_style( 'webmention' ); + $this->go_to( $url ); + \Webmention\Webmention::get_instance()->enqueue_scripts(); + $this->assertTrue( wp_style_is( 'webmention', 'enqueued' ), $url ); + } + } finally { + wp_dequeue_style( 'webmention' ); + } + } + /** * Test that constants are registered. */