From a749f09bc0f6b3169e37020e01388c667a3f7a0f Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Mon, 30 Mar 2020 06:26:56 -0700 Subject: [PATCH] Shortcodes: enable inline PDFs (#14960) * Shortcodes: enable inline PDFs * Fix sprintf replacement * Add unit tests and fix lint errors * Fix lint errors, add prefix, and other fixes Add unit test * Fix unit test Co-authored-by: Jeremy Herve --- modules/shortcodes/inline-pdfs.php | 30 ++++++++++++++ .../shortcodes/test-class.inline-pdf.php | 40 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 modules/shortcodes/inline-pdfs.php create mode 100644 tests/php/modules/shortcodes/test-class.inline-pdf.php diff --git a/modules/shortcodes/inline-pdfs.php b/modules/shortcodes/inline-pdfs.php new file mode 100644 index 0000000000000..8e1c475af386c --- /dev/null +++ b/modules/shortcodes/inline-pdfs.php @@ -0,0 +1,30 @@ + +

%1$s

+ ', + esc_attr( $url ) + ); +} diff --git a/tests/php/modules/shortcodes/test-class.inline-pdf.php b/tests/php/modules/shortcodes/test-class.inline-pdf.php new file mode 100644 index 0000000000000..a18208f7839f0 --- /dev/null +++ b/tests/php/modules/shortcodes/test-class.inline-pdf.php @@ -0,0 +1,40 @@ +factory()->post->create_and_get( array( 'post_content' => $url ) ); + + setup_postdata( $post ); + + // Test HTML version. + ob_start(); + the_content(); + $actual = ob_get_clean(); + + wp_reset_postdata(); + + $this->assertContains( + sprintf( + '

%1$s

' . "\n", + $url + ), + $actual + ); + } +}