From 6b8c095d22b87164ca7b8129f1cdc168af17f7ac Mon Sep 17 00:00:00 2001 From: Derrick Koo Date: Thu, 20 Oct 2022 16:07:24 -0600 Subject: [PATCH] feat: render link to terms URL if given --- assets/blocks/reader-registration/edit.js | 5 +++-- assets/blocks/reader-registration/editor.scss | 1 + assets/blocks/reader-registration/index.php | 9 +++++++++ includes/class-blocks.php | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/assets/blocks/reader-registration/edit.js b/assets/blocks/reader-registration/edit.js index 951537e650..bc3c64948a 100644 --- a/assets/blocks/reader-registration/edit.js +++ b/assets/blocks/reader-registration/edit.js @@ -59,7 +59,8 @@ export default function ReaderRegistrationEdit( { } ) { const blockProps = useBlockProps(); const [ editedState, setEditedState ] = useState( editedStateOptions[ 0 ].value ); - const { reader_activation_terms: defaultTermsText } = window.newspack_blocks; + const { reader_activation_terms: defaultTermsText, reader_activation_url: defaultTermsUrl } = + window.newspack_blocks; const innerBlocksProps = useInnerBlocksProps( {}, @@ -315,7 +316,7 @@ export default function ReaderRegistrationEdit( { onChange={ value => setAttributes( { privacyLabel: value } ) } placeholder={ __( 'Terms & Conditions statement…', 'newspack' ) } value={ privacyLabel || defaultTermsText } - tagName="p" + tagName={ defaultTermsUrl ? 'a' : 'p' } /> diff --git a/assets/blocks/reader-registration/editor.scss b/assets/blocks/reader-registration/editor.scss index 80e64c1e1c..acbf2115bf 100644 --- a/assets/blocks/reader-registration/editor.scss +++ b/assets/blocks/reader-registration/editor.scss @@ -92,6 +92,7 @@ &__help-text { margin-top: 1em; + a, p { font-size: 0.55em !important; margin: 0; diff --git a/assets/blocks/reader-registration/index.php b/assets/blocks/reader-registration/index.php index acdd127167..9202fcb9c9 100644 --- a/assets/blocks/reader-registration/index.php +++ b/assets/blocks/reader-registration/index.php @@ -255,9 +255,18 @@ function render_block( $attrs, $content ) {

+ + + + +

diff --git a/includes/class-blocks.php b/includes/class-blocks.php index f5e4058b66..d0b775a3d4 100644 --- a/includes/class-blocks.php +++ b/includes/class-blocks.php @@ -44,6 +44,7 @@ public static function enqueue_block_editor_assets() { 'has_google_oauth' => Google_OAuth::is_oauth_configured(), 'google_logo_svg' => file_get_contents( dirname( NEWSPACK_PLUGIN_FILE ) . '/assets/blocks/reader-registration/icons/google.svg' ), 'reader_activation_terms' => Reader_Activation::get_setting( 'terms_text' ), + 'reader_activation_url' => Reader_Activation::get_setting( 'terms_url' ), ] ); \wp_enqueue_style(