- every
// page on the site showed the identical "GT Max Motors" title. Adding
// this lets WordPress core (and Rank Math's own title settings) generate
// a correct, unique title per page once the hardcoded lines are removed
// from each template.
add_action('after_setup_theme', function () {
add_theme_support('title-tag');
});
function mytheme_enqueue_styles()
{
wp_enqueue_style('mytheme-style', get_stylesheet_uri());
}
add_action('wp_enqueue_scripts', 'mytheme_enqueue_styles');
function mytheme_register_menus() {
register_nav_menus(array(
'header_menu' => __('Header Menu', 'mytheme'),
'footer_menu' => __('Footer Menu', 'mytheme'),
));
}
add_action('init', 'mytheme_register_menus');
function gtmax_enqueue_styles() {
wp_enqueue_style(
'gtmax-style',
get_template_directory_uri() . '/assets/css/style.css',
array(),
filemtime(get_template_directory() . '/assets/css/style.css')
);
}
add_action('wp_enqueue_scripts', 'gtmax_enqueue_styles');
function gtmax_enqueue_scripts() {
wp_enqueue_script('footer-js', get_template_directory_uri() . '/assets/js/footer.js', array(), null, true);
}
add_action('wp_enqueue_scripts', 'gtmax_enqueue_scripts');
add_filter( 'nav_menu_link_attributes', function( $atts, $item, $args ) {
// For example, force all links in "Header" menu to open in a new tab
if ( $item->type === 'custom' ) {
if(str_contains(strtoupper($item->title),'SHOP NOW')){
$atts['target'] = '_blank';
if ( isset( $atts['class'] ) ) {
$atts['class'] .= ' show_now_btn';
} else {
$atts['class'] = 'show_now_btn';
}
}
}
return $atts;
}, 10, 3 );
add_filter( 'nav_menu_item_title', function( $title, $item, $args, $depth ) {
if ( $item->type === 'custom' && stripos( $item->title, 'SHOP NOW' ) !== false ) {
// Add bag icon before the text
$title = '' . $title;
}
return $title;
}, 10, 4 );
add_action('add_meta_boxes', function() {
add_meta_box(
'custom_post_template_box',
'Post Layout Template',
'render_custom_post_template_box',
'post',
'side',
'default'
);
});
// start post php files as categories selection
function render_custom_post_template_box($post) {
$selected_template = get_post_meta($post->ID, '_custom_post_template', true);
$templates_dir = get_stylesheet_directory() . '/posts/';
$files = glob($templates_dir . '*.php');
echo '';
}
add_action('save_post', function($post_id) {
if (isset($_POST['custom_post_template'])) {
update_post_meta($post_id, '_custom_post_template', sanitize_text_field($_POST['custom_post_template']));
}
});
add_filter('single_template', function($template) {
global $post;
$custom_template = get_post_meta($post->ID, '_custom_post_template', true);
if ($custom_template) {
$path = get_stylesheet_directory() . '/posts/' . $custom_template;
if (file_exists($path)) {
return $path;
}
}
return $template;
});
// end post php files as categories selection
function gtmax_breadcrumbs() {
if (is_front_page()) return;
echo '';
}
// add the insurance.js to insurance-page
function gtmax_enqueue_insurance_assets() {
$is_insurance_page = is_page_template('page-Insurance.php')
|| is_page_template('page-insurance.php')
|| is_page('insurance');
if (!$is_insurance_page) {
return;
}
wp_enqueue_script(
'sweetalert2',
'https://cdn.jsdelivr.net/npm/sweetalert2@11',
[],
null,
true
);
wp_enqueue_script(
'gtmax-insurance',
get_template_directory_uri() . '/assets/js/insurance.js',
['jquery', 'sweetalert2'],
filemtime(get_template_directory() . '/assets/js/insurance.js'),
true
);
wp_localize_script('gtmax-insurance', 'GTMAX_CONFIG', [
'apiUrl' => 'https://gtmaxmanagement.gtmax.com.my/api/insurance_registration',
'token' => 'Bearer 5c63174c9bbe98178b95bb8b99d9e8b4b8ea4821c4c06596620652ddd5eefdbf1fd441b0de2ce1b8',
'lang' => get_locale(),
]);
}
add_action('wp_enqueue_scripts', 'gtmax_enqueue_insurance_assets');
https://gtmax.com.my/post-sitemap.xml
2025-12-15T09:28:53+00:00
https://gtmax.com.my/page-sitemap.xml
2026-09-05T03:33:06+00:00
https://gtmax.com.my/category-sitemap.xml
2025-12-15T09:28:53+00:00