mattyfezzer
Forum Replies Created
-
Thank you this will reduce complaints and adhere to UK law 😉
Also following on when changes do take affect in dashboard, the user cannot select admin or any admin names or usernames for security reasons and to prevent brute force attacks as in the Uk due to lucy law they have to use full name or first name when listing pets as I can get into trouble to allow someone to sell live pets under name like spiderman lol 🙂
I think implementing into dashboard would be perfect, On registration form they have to use a first and last name to continue I wondered if was possible in plugin settings it says first and last name could we have a first name option also because the first and last name I understand is taking it from the registartion form ?
I am using petlist theme, I have been told its not good practice to show usernames on listings as this leaves open to brute force attacks do you agree ?
Sure I used a snippet that forces all RTCL into sitemap in Yeost, anyone can use this snippet and then clear cache and open sitemap and should see all listed then upload to google console
<?php
/**
* RTCL Taxonomy Sitemap (REST API)
* Provides a read-only sitemap of RTCL Locations & Categories
* and automatically adds it to Yoast's sitemap index.
*
* URL: /wp-json/rtcl/v1/sitemap
*/
if (!defined('ABSPATH')) exit;
/**
* REST: /wp-json/rtcl/v1/sitemap
*/
add_action('rest_api_init', function () {
register_rest_route('rtcl/v1', '/sitemap', [
'methods' => 'GET',
'callback' => function () {
// Use a transient cache to prevent DB overload
$cached = get_transient('rtcl_rest_sitemap_xml');
if ($cached !== false) {
nocache_headers();
header('Content-Type: application/xml; charset=' . get_bloginfo('charset'), true);
header('Cache-Control: public, max-age=3600');
echo $cached;
return null;
}
// Get public taxonomies only, skip empty terms
$terms = get_terms([
'taxonomy' => ['rtcl_location', 'rtcl_category'],
'hide_empty' => true,
'number' => 0,
'update_term_meta_cache' => false,
]);
if (is_wp_error($terms)) $terms = [];
$charset = get_bloginfo('charset');
$lastmod = gmdate('c');
// Build XML
$xml = '<?xml version="1.0" encoding="' . esc_attr($charset) . "\"?>\n";
$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
foreach ($terms as $term) {
$loc = get_term_link($term);
if (is_wp_error($loc)) continue;
$xml .= " <url>\n";
$xml .= ' <loc>' . esc_url($loc) . "</loc>\n";
$xml .= ' <lastmod>' . $lastmod . "</lastmod>\n";
$xml .= " </url>\n";
}
$xml .= "</urlset>";
// Cache XML for 1 hour
set_transient('rtcl_rest_sitemap_xml', $xml, HOUR_IN_SECONDS);
// Output XML
nocache_headers();
header('Content-Type: application/xml; charset=' . $charset, true);
header('Cache-Control: public, max-age=3600');
echo $xml;
return null;
},
'permission_callback' => '__return_true', // Public read-only access
]);
});
/**
* Add this sitemap to Yoast's sitemap index
*/
add_filter('wpseo_sitemap_index_links', function ($links) {
$links[] = [
'loc' => home_url('/wp-json/rtcl/v1/sitemap'),
'lastmod' => gmdate('c'),
];
return $links;
});
/**
* Optional: redirect /sitemap-rtcl.xml to REST URL
*/
add_action('template_redirect', function () {
$path = isset($_SERVER['REQUEST_URI']) ? parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) : '';
if ($path && rtrim($path, '/') === '/sitemap-rtcl.xml') {
wp_redirect(home_url('/wp-json/rtcl/v1/sitemap'), 301);
exit;
}
});
/**
* Optional: add sitemap to robots.txt
*/
add_filter('robots_txt', function ($output, $public) {
$output .= "\nSitemap: " . home_url('/wp-json/rtcl/v1/sitemap');
return $output;
}, 10, 2);Thank you for getting back to me, I generated my own sitemap in the end to include all categories and locations, I think its because some categories and locations have no content, I was able to include them all and force google to index 🙂
Worked like a charm 🙂
Thank you will try