Skip to content

Add advanced fragment handling #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions html-api-debugger/html-api-debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Plugin Name: HTML API Debugger
* Plugin URI: https://github.com/sirreal/html-api-debugger
* Description: Add a page to wp-admin for debugging the HTML API.
* Version: 2.1
* Requires at least: 6.6
* Tested up to: 6.7
* Version: 2.2
* Requires at least: 6.7
* Tested up to: 6.8
* Author: Jon Surrell
* Author URI: https://profiles.wordpress.org/jonsurrell/
* License: GPLv2 or later
Expand All @@ -22,7 +22,7 @@
require_once __DIR__ . '/html-api-integration.php';

const SLUG = 'html-api-debugger';
const VERSION = '2.1';
const VERSION = '2.2';

/** Set up the plugin. */
function init() {
Expand All @@ -44,8 +44,7 @@ function () {
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
$html = $request->get_json_params()['html'] ?: '';
$options = array(
'quirks_mode' => $request->get_json_params()['quirksMode'] ?? false,
'full_parser' => $request->get_json_params()['fullParser'] ?? false,
'context_html' => $request->get_json_params()['contextHTML'] ?: null,
);
return prepare_html_result_object( $html, $options );
},
Expand Down Expand Up @@ -111,14 +110,19 @@ function () {
function () {
require_once __DIR__ . '/interactivity.php';

$options = array(
'context_html' => null,
);

$html = '';
// phpcs:disable WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['html'] ) && is_string( $_GET['html'] ) ) {
$html = stripslashes( $_GET['html'] );
}

$options = array();
// @todo Add query args for other options
if ( isset( $_GET['contextHTML'] ) && is_string( $_GET['contextHTML'] ) ) {
$options['context_html'] = stripslashes( $_GET['contextHTML'] );
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended

// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo namespace\Interactivity\generate_page( $html, $options );
Expand All @@ -141,7 +145,7 @@ function prepare_html_result_object( string $html, array $options = null ): arra
'html' => $html,
'error' => null,
'result' => null,
'normalizedHtml' => HTML_API_Integration\get_normalized_html( $html ),
'normalizedHtml' => HTML_API_Integration\get_normalized_html( $html, $options ),
);

try {
Expand Down
Loading