45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Sami Modern Theme Functions
|
|
* Pure HTML/CSS, no Elementor
|
|
*/
|
|
if (!defined('ABSPATH')) exit;
|
|
|
|
add_action('wp_enqueue_scripts', function() {
|
|
wp_enqueue_style('sami-modern', get_stylesheet_uri(), array(), '1.0');
|
|
}, 1);
|
|
|
|
add_filter('body_class', function($c) {
|
|
$c[] = 'sami-modern';
|
|
return $c;
|
|
});
|
|
|
|
// Contact form handler
|
|
add_action('wp_ajax_sami_contact', 'sami_handle_contact');
|
|
add_action('wp_ajax_nopriv_sami_contact', 'sami_handle_contact');
|
|
function sami_handle_contact() {
|
|
$n = sanitize_text_field($_POST['name'] ?? '');
|
|
$e = sanitize_email($_POST['email'] ?? '');
|
|
$m = sanitize_textarea_field($_POST['message'] ?? '');
|
|
if (!empty($_POST['website'])) { wp_send_json_success(array('msg' => 'Thanks!')); }
|
|
if (!$n || !$e || !$m) { wp_send_json_error(array('msg' => 'Please fill in all fields.')); }
|
|
$s = wp_mail('hello@sami-ahmed.net', "Contact from $n via sami-ahmed.net", "Name: $n
|
|
Email: $e
|
|
|
|
$m", array('Reply-To: $e'));
|
|
wp_send_json_success(array('msg' => $s ? 'Message sent!' : 'Mail failed.'));
|
|
}
|
|
|
|
// Fully disable Elementor global header/footer for this theme
|
|
add_action('init', function() {
|
|
if (defined('ELEMENTOR_VERSION')) {
|
|
remove_action('get_header', 'elementor_get_header', 20);
|
|
remove_action('get_footer', 'elementor_get_footer', 20);
|
|
}
|
|
}, 100);
|
|
|
|
// Remove Elementor theme location hooks
|
|
add_action('wp_head', function() {
|
|
remove_action('wp_head', 'elementor_theme_do_location', 0);
|
|
}, 1);
|