' . "\n";
$content .= wp_kses_post(
self::replaceSuggestionTemplateToken($rSuggestTitle, 'suggest_title_text',
__('Here are some other great pages', '404-solution')
)) . "\n";
$currentSlug = '';
if (isset($_SERVER['REQUEST_URI']) && is_string($_SERVER['REQUEST_URI'])) {
$currentSlug = $abj404logic->removeHomeDirectory(
$f->regexReplace('\?.*', '', $f->normalizeUrlString($_SERVER['REQUEST_URI'])));
}
$displayed = 0;
$commentPartAndQueryPart = $abj404logic->getCommentPartAndQueryPartOfRequest();
// Check if minimum score filtering is enabled
$minScoreEnabled = isset($options['suggest_minscore_enabled']) && $options['suggest_minscore_enabled'] == '1';
$rMinscoreRaw = isset($options['suggest_minscore']) && is_scalar($options['suggest_minscore']) ? $options['suggest_minscore'] : 25;
$minScore = $minScoreEnabled ? intval($rMinscoreRaw) : 0;
foreach ($permalinkSuggestions as $idAndType => $linkScore) {
$rIdAndTypeStr = is_string($idAndType) ? $idAndType : (string)$idAndType;
$rLinkScoreFloat = is_scalar($linkScore) ? (float)$linkScore : 0.0;
$rRowTypeStr = is_string($rowType) ? $rowType : null;
// Check per-post/per-term exclusion before rendering.
// ABJ404_TYPE_POST=1, ABJ404_TYPE_CAT=2, ABJ404_TYPE_TAG=3.
$idTypeParts = explode('|', $rIdAndTypeStr, 2);
$idInt = isset($idTypeParts[0]) && is_numeric($idTypeParts[0]) ? (int)$idTypeParts[0] : 0;
$typeInt = isset($idTypeParts[1]) && is_numeric($idTypeParts[1]) ? (int)$idTypeParts[1] : 0;
if ($idInt > 0) {
$typePost = defined('ABJ404_TYPE_POST') ? (int)ABJ404_TYPE_POST : 1;
$typeCat = defined('ABJ404_TYPE_CAT') ? (int)ABJ404_TYPE_CAT : 2;
$typeTag = defined('ABJ404_TYPE_TAG') ? (int)ABJ404_TYPE_TAG : 3;
if ($typeInt === $typePost) {
$excludeMeta = get_post_meta($idInt, '_abj404_exclude', true);
if ($excludeMeta === '1') {
continue;
}
} elseif ($typeInt === $typeCat || $typeInt === $typeTag) {
$excludeMeta = get_term_meta($idInt, '_abj404_exclude', true);
if ($excludeMeta === '1') {
continue;
}
}
}
$permalink = ABJ_404_Solution_Functions::permalinkInfoToArray($rIdAndTypeStr, $rLinkScoreFloat,
$rRowTypeStr, $options);
$rPermLink = isset($permalink['link']) && is_string($permalink['link']) ? $permalink['link'] : '';
$rPermTitle = isset($permalink['title']) && is_string($permalink['title']) ? $permalink['title'] : '';
$rPermScore = isset($permalink['score']) && is_numeric($permalink['score']) ? (float)$permalink['score'] : 0.0;
// Skip if we're currently on the page we're about to suggest
if ($currentSlug !== '' && basename($rPermLink) == $currentSlug) {
continue;
}
// Skip if minimum score filtering is enabled and score is below threshold
if ($minScoreEnabled && $rPermScore < $minScore) {
continue;
}
if ($displayed == 0) {
//
$content .= wp_kses_post($rSuggestBefore);
}
// -
$content .= wp_kses_post($rSuggestEntryBefore);
$content .= "" .
esc_attr($rPermTitle) . "";
// Display the score after the page link (admin only)
if ($showExtraAdminData) {
$content .= ' (' . number_format($rPermScore, 4) . ')';
}
//
$content .= wp_kses_post($rSuggestEntryAfter) . "\n";
$displayed++;
$rSuggestMaxOpt = isset($options['suggest_max']) && is_scalar($options['suggest_max']) ? (int)$options['suggest_max'] : 5;
if ($displayed >= $rSuggestMaxOpt) {
break;
}
}
if ($displayed >= 1) {
//
$content .= wp_kses_post($rSuggestAfter) . "\n";
} else {
$content .= wp_kses_post(
self::replaceSuggestionTemplateToken($rSuggestNoresults, 'suggest_noresults_text',
__('No suggestions. :/ ', '404-solution')
));
}
$content .= "\n
";
return $content;
} finally {
self::maybeRestoreFrontendLocale($didSwitchLocale);
}
}
/**
* Render a loading placeholder for async suggestions.
* Shows skeleton loading animation while suggestions are being computed.
*
* @param string $requestedURL The 404 URL being looked up
* @param array