Skip to content

Commit e43d7d1

Browse files
committed
fixed php code
1 parent bb1d26e commit e43d7d1

4 files changed

Lines changed: 8 additions & 4 deletions

File tree

common/code/boost_filter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function extract_html_body($text) {
5757
if (!isset($body_begin[0]))
5858
{
5959
//~ Attempt to recover some content from illegal HTML that is missing the body tag.
60-
preg_match('@<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script></head>@i',$text,$body_begin,PREG_OFFSET_CAPTURE);
60+
preg_match('@</head>@i',$text,$body_begin,PREG_OFFSET_CAPTURE);
6161
}
6262
if (!isset($body_begin[0]))
6363
{
@@ -153,6 +153,7 @@ function template_params($content) {
153153

154154
$head = "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\" />\n";
155155
$head .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=${charset}\" />\n";
156+
$head .= "<script defer data-domain=\"original.boost.org\" src=\"https://plausible.io/js/script.js\"></script>\n";
156157

157158
if (!empty($this->noindex))
158159
$head .= "<meta name=\"robots\" content=\"noindex\">\n";

common/code/boost_filter_basic.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function echo_filtered()
1313

1414
$match = null;
1515

16-
if(preg_match('@(?:<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script></head>\s*)?<body[^>]*>@is', $text, $match, PREG_OFFSET_CAPTURE)) {
16+
if(preg_match('@(?:</head>\s*)?<body[^>]*>@is', $text, $match, PREG_OFFSET_CAPTURE)) {
1717
$is_xhtml = preg_match('@<!DOCTYPE[^>]*xhtml@i', $match[0][0]);
1818
$tag_end = $is_xhtml ? '/>' : '>';
1919

@@ -22,6 +22,7 @@ function echo_filtered()
2222
echo $this->alter_title($head);
2323
echo '<link rel="icon" href="/favicon.ico" type="image/ico"'.$tag_end;
2424
echo '<link rel="stylesheet" type="text/css" href="/style-v2/section-basic.css"'.$tag_end;
25+
echo '<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script>';
2526
if ($is_asciidoctor) {
2627
echo str_replace('class="', 'class="boost-asciidoctor ', $match[0][0]);
2728
} else {

common/code/boost_filter_boost_book_basic.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ function echo_filtered()
1313

1414
$match = null;
1515

16-
$pos1 = strpos($text, '<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script></head>');
16+
$pos1 = strpos($text, '</head>');
1717
$pos2 = strpos($text, '<body', $pos1);
1818
$pos3 = strpos($text, '>', $pos2) + 1;
1919
$pos4 = strpos($text, '<div class="spirit-nav">', $pos3);
2020
$head = $this->alter_title(substr($text, 0, $pos1));
2121
echo $head;
2222
echo '<link rel="icon" href="/favicon.ico" type="image/ico"/>';
2323
echo '<link rel="stylesheet" type="text/css" href="/style-v2/section-basic.css"/>';
24+
echo '<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script>';
2425
if (!preg_match('@<meta\b[^<>]*\bname\s*=\s*["\']?viewport\b@', $head)) {
2526
echo '<meta name="viewport" content="width=device-width,initial-scale=1.0"/>';
2627
}

common/code/boost_filter_develop_box.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ function echo_filtered()
1111
{
1212
$text = $this->content;
1313
$box = latest_link($this->data);
14-
if ($box && preg_match('@(?:<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script></head>\s*)?<body[^>]*>@is', $text, $match, PREG_OFFSET_CAPTURE)) {
14+
if ($box && preg_match('@(?:</head>\s*)?<body[^>]*>@is', $text, $match, PREG_OFFSET_CAPTURE)) {
1515
$is_xhtml = preg_match('@<!DOCTYPE[^>]*xhtml@i', $match[0][0]);
1616
$tag_end = $is_xhtml ? '/>' : '>';
1717
$head = substr($text, 0, $match[0][1]);
1818
echo $this->alter_title($head);
1919
echo '<link rel="icon" href="/favicon.ico" type="image/ico"'.$tag_end;
2020
echo '<link rel="stylesheet" type="text/css" href="/style-v2/section-basic.css"'.$tag_end;
21+
echo '<script defer data-domain="original.boost.org" src="https://plausible.io/js/script.js"></script>';
2122
echo $match[0][0];
2223
echo $box;
2324
echo $this->prepare_html(substr($text, $match[0][1] + strlen($match[0][0])));

0 commit comments

Comments
 (0)