// ============================================================
// UK SEO HELPER FUNCTIONS - Added for ukclassifiedhub.co.uk
// ============================================================
/**
* Generate SEO-optimized meta title for homepage
* Includes UK target keywords for better Google.co.uk ranking
*/
function zet_seo_meta_title() {
$title = osc_page_title();
if(osc_is_home_page()) {
$title = 'Free Classified Ads UK | Buy & Sell Locally | ' . osc_page_title();
} else if(osc_is_ad_page()) {
$title = osc_item_title() . ' | ' . osc_item_category() . ' | ' . osc_page_title();
} else if(osc_is_search_page()) {
$cat = osc_search_category();
$pattern = trim(Params::getParam('sPattern'));
if($pattern != '') {
$title = $pattern . ' in UK | ' . ($cat != '' ? $cat . ' | ' : '') . osc_page_title();
} else if($cat != '') {
$title = $cat . ' UK | ' . osc_page_title();
}
} else if(osc_is_static_page()) {
$title = osc_static_page_title() . ' | ' . osc_page_title();
}
return osc_apply_filter('zet_seo_meta_title', $title);
}
/**
* Generate SEO-optimized meta description for homepage
* UK-focused with call-to-action
*/
function zet_seo_meta_description() {
$desc = osc_page_title() . ' - Post your free classified ads in the UK. Buy, sell, or advertise jobs, property, vehicles, and more across London, Manchester, Birmingham, Glasgow and all UK cities. Fast, easy, and 100% free.';
if(osc_is_ad_page()) {
$desc = osc_highlight(osc_item_description(), 150);
$location = implode(', ', array_filter(array(osc_item_city(), osc_item_region())));
if($location != '') {
$desc .= ' Located in ' . $location . ', UK. ';
}
$desc .= 'Post free ads on ' . osc_page_title() . '.';
} else if(osc_is_search_page()) {
$pattern = trim(Params::getParam('sPattern'));
$cat = osc_search_category();
if($pattern != '' || $cat != '') {
$desc = 'Find ' . ($pattern != '' ? $pattern : $cat) . ' in the UK. Browse local listings from sellers across England, Scotland, Wales & Northern Ireland. Free to post, easy to buy and sell on ' . osc_page_title() . '.';
}
}
return osc_apply_filter('zet_seo_meta_description', $desc);
}
/**
* Generate breadcrumb HTML with Schema.org markup
* Usage: echo zet_seo_breadcrumb();
*/
function zet_seo_breadcrumb($separator = '>') {
if(osc_is_home_page()) { return ''; }
$items = array();
$position = 1;
// Home
$items[] = ''
. '' . __('Home', 'zeta') . ''
. '';
if(osc_is_ad_page()) {
if(osc_item_category() != '') {
$items[] = ''
. '' . osc_esc_html(osc_item_category()) . ''
. '';
}
$items[] = ''
. '' . osc_esc_html(osc_highlight(osc_item_title(), 40)) . ''
. '';
} else if(osc_is_search_page()) {
$cat = osc_search_category();
$pattern = trim(Params::getParam('sPattern'));
if($cat != '') {
$items[] = ''
. '' . osc_esc_html($cat) . ''
. '';
} else if($pattern != '') {
$items[] = ''
. '' . osc_esc_html($pattern) . ''
. '';
} else {
$items[] = ''
. '' . __('Search', 'zeta') . ''
. '';
}
} else if(osc_is_static_page()) {
$items[] = ''
. '' . osc_esc_html(osc_static_page_title()) . ''
. '';
}
return '';
}
/**
* Check if current page should be indexed by search engines
* Returns true if page should be indexed, false if noindex
*/
function zet_seo_should_index() {
// Noindex empty search results
if(osc_is_search_page()) {
$pattern = trim(Params::getParam('sPattern'));
if($pattern == '' && !osc_search_category_id() && !Params::getParam('sCity') && !Params::getParam('sRegion')) {
return false;
}
}
// Noindex paginated pages beyond page 1 (optional - comment out if you want all pages indexed)
if(Params::getParam('iPage') > 1) {
return false;
}
return osc_apply_filter('zet_seo_should_index', true);
}
/**
* Output robots meta tag based on page context
* Usage: Call in head section or template header
*/
function zet_seo_robots_meta() {
if(!zet_seo_should_index()) {
echo '' . PHP_EOL;
echo '' . PHP_EOL;
} else {
echo '' . PHP_EOL;
echo '' . PHP_EOL;
}
}
/**
* Get Open Graph image for current page
* Returns featured image URL or logo fallback
*/
function zet_seo_og_image() {
$image = osc_current_web_theme_url('images/logo.png');
if(osc_is_ad_page() && osc_count_item_resources() > 0) {
osc_reset_resources();
osc_get_item_resources();
$image = osc_resource_url();
}
return osc_apply_filter('zet_seo_og_image', $image);
}
// ============================================================
// END UK SEO HELPER FUNCTIONS
// ============================================================