Skip to content

Commit 567b64a

Browse files
committed
added escape func in some output
1 parent b597f8f commit 567b64a

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

presenta-open-graph.php

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,31 @@ function presenta_head_meta_data() {
5252
$post_image = "https://source.unsplash.com/random/800x600/?sky";
5353
}
5454

55-
$url = $PRESENTA_SERVICE_URL . $pTemplateID;
55+
$url = $PRESENTA_SERVICE_URL . esc_attr($pTemplateID);
5656
$url .= "?title=" . $post_title;
5757
$url .= "&subtitle=" . $post_date;
5858
$url .= "&image=" . $post_image;
5959

60-
$output = '<!-- PRESENTA OG start -->
61-
';
60+
$output = "\n" . '<!-- PRESENTA OG start -->' . "\n";
6261

6362
if($hasYoast != '1'){
64-
$output .= '<meta property="og:type" content="website">';
65-
$output .= '<meta property="og:title" content="'.$post_title.'">';
66-
$output .= '<meta property="og:site_name" content="'.$site_name.'">';
67-
$output .= '<meta property="og:description" content="'.$post_excerpt.'">';
68-
$output .= '<meta property="og:url" content="'.$post_url.'">';
69-
70-
$output .= '<meta name="twitter:card" content="summary_large_image" />';
71-
$output .= '<meta name="twitter:title" content="'.$post_title.'" />';
72-
$output .= '<meta name="twitter:site" content="'.$site_name.'" />';
73-
$output .= '<meta name="twitter:description" content="'.$post_excerpt.'" />';
74-
$output .= '<meta name="twitter:url" content="'.$post_url.'" />';
63+
$output .= '<meta property="og:type" content="website">' . "\n";
64+
$output .= '<meta property="og:title" content="' . esc_attr($post_title) . '">' . "\n";
65+
$output .= '<meta property="og:site_name" content="' . esc_attr($site_name) . '">' . "\n";
66+
$output .= '<meta property="og:description" content="' . esc_attr($post_excerpt) . '">' . "\n";
67+
$output .= '<meta property="og:url" content="' . esc_url($post_url) . '">' . "\n";
68+
69+
$output .= '<meta name="twitter:card" content="summary_large_image" />' . "\n";
70+
$output .= '<meta name="twitter:title" content="' . esc_attr($post_title) . '" />' . "\n";
71+
$output .= '<meta name="twitter:site" content="' . esc_attr($site_name) . '" />' . "\n";
72+
$output .= '<meta name="twitter:description" content="' . esc_attr($post_excerpt) . '" />' . "\n";
73+
$output .= '<meta name="twitter:url" content="' . esc_url($post_url) . '" />' . "\n";
7574
}
7675

77-
$output .= '<meta name="twitter:image" content="'.$url.'" />';
78-
$output .= '<meta property="og:image" content="'.$url.'" />
79-
';
76+
$output .= '<meta name="twitter:image" content="' . $url . '" />' . "\n";
77+
$output .= '<meta property="og:image" content="' . $url . '" />' . "\n";
8078

81-
$output .= '<!-- PRESENTA OG end -->';
79+
$output .= '<!-- PRESENTA OG end -->' . "\n\n";
8280

8381
echo $output;
8482

@@ -184,19 +182,19 @@ function presenta_render_plugin_setting_panel(){
184182

185183

186184
<?php $templateID = get_option('presenta_plugin_template_id'); ?>
187-
const actual = "<?php echo $templateID; ?>"
185+
const actual = "<?php echo esc_attr($templateID); ?>"
188186

189187
<?php $yoastFix = get_option('presenta_plugin_template_yoast'); ?>
190188
const checkYoast = document.querySelector('#presenta_yoast_fix')
191-
const hasYoast = "<?php echo $yoastFix; ?>"
189+
const hasYoast = "<?php echo esc_attr($yoastFix); ?>"
192190
if(hasYoast == '1') checkYoast.checked = true
193191
checkYoast.addEventListener('change', e => {
194192
const v = e.target.checked
195193
const field = document.querySelector('[name="presenta_plugin_template_yoast"]')
196194
field.value = v ? 1 : 0
197195
})
198196

199-
const base = '<?php echo $PRESENTA_SERVICE_URL; ?>'
197+
const base = '<?php echo esc_url($PRESENTA_SERVICE_URL); ?>'
200198

201199
const wrapper = document.querySelector('#presenta_gallery_container')
202200

0 commit comments

Comments
 (0)