Skip to content

Commit 2bbc674

Browse files
authored
WEBFORM - #100 - Changing Title Not Working (#101)
* Add hidden nonce field and update button to active forms * Refactor header_style method to improve canonical URL generation with added sanitization checks * Refactor canonical URL generation to enhance sanitization order for HTTP host and request URI
1 parent 9e680f9 commit 2bbc674

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

includes/post-type-active-forms.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ public function load_core_fields_metabox( $post ) {
203203
return;
204204
}
205205

206+
echo '<input type="hidden" name="' . esc_attr( $this->post_type ) . '_noonce" id="' . esc_attr( $this->post_type ) . '_noonce" value="' . esc_attr( wp_create_nonce( 'update_dt_webforms' ) ) . '" />';
207+
206208
$core_fields = $this->get_core_fields( $post->ID );
207209
?>
208210
<table class="widefat striped">
@@ -250,6 +252,11 @@ public function load_core_fields_metabox( $post ) {
250252
?>
251253
</tbody>
252254
</table>
255+
<div>
256+
<br clear="all">
257+
<span style="float:right;" id="update_fields_button"><button type="submit" class="button">Update</button> </span>
258+
<br clear="all">
259+
</div>
253260
<?php
254261
}
255262

magic-link/magic-link-webform-app.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,18 @@ public function wp_enqueue_scripts(){
104104
*/
105105
public function header_style(){
106106
// Get the current URL
107-
$canonical_url = (is_ssl() ? 'https://' : 'http://');
108-
$canonical_url .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
107+
$canonical_url = ( is_ssl() ? 'https://' : 'http://' );
108+
if ( isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ) {
109+
$http_host = sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) );
110+
$request_uri = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) );
111+
$canonical_url .= $http_host . $request_uri;
112+
}
109113

110114
// Sanitize it (optional but safer)
111-
$canonical_url = esc_url($canonical_url);
115+
$canonical_url = esc_url( $canonical_url );
112116

113117
// Output the canonical link tag
114-
echo '<link rel="canonical" href="' . $canonical_url . '" />' . "\n";
118+
echo '<link rel="canonical" href="' . esc_url( $canonical_url ) . '" />' . "\n";
115119
}
116120

117121
/**

0 commit comments

Comments
 (0)