...php
if (!defined('ABSPATH')) {
exit;
}
function velveted_enqueue_assets() {
wp_enqueue_style(
'velveted-fonts',
'https://fonts.googleapis.com/css2...family=Cormorant+Garamond:wght@400;600&family=Manrope:wght@300;400;500;600&display=swap',
array(),
null
);
wp_enqueue_style('velveted-styles', get_stylesheet_directory_uri() . '/assets/css/styles.css', array(), '1.0.1');
wp_enqueue_script('velveted-scripts', get_stylesheet_directory_uri() . '/assets/js/main.js', array(), '1.0.1', true);
}
add_action('wp_enqueue_scripts', 'velveted_enqueue_assets');
function velveted_theme_setup() {
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
add_theme_support('woocommerce');
register_nav_menus(array(
'primary' => 'Primary Menu',
));
}
add_action('after_setup_theme', 'velveted_theme_setup');
function velveted_menu_fallback() {
echo 'Shop';
echo 'Collections';
echo 'Beginner Guide';
echo 'About';
echo 'FAQ';
}
function velveted_resource_hints($hints, $relation_type) {
if ($relation_type === 'preconnect') {
$hints[] = array('href' => 'https://fonts.googleapis.com');
$hints[] = array('href' => 'https://fonts.gstatic.com', 'crossorigin' => '');
}
return $hints;
}
add_filter('wp_resource_hints', 'velveted_resource_hints', 10, 2);
function velveted_disable_emojis() {
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('admin_print_styles', 'print_emoji_styles');
remove_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
}
add_action('init', 'velveted_disable_emojis');
function velveted_disable_wp_embed() {
wp_deregister_script('wp-embed');
}
add_action('wp_footer', 'velveted_disable_wp_embed');
function velveted_output_tracking() {
$gtm_id = trim(get_option('velveted_gtm_id', ''));
$ga4_id = trim(get_option('velveted_ga4_id', ''));
$ads_id = trim(get_option('velveted_gads_id', ''));
if ($gtm_id) {
echo "\n";
echo "\n";
echo "\n";
return;
}
if (!$ga4_id && !$ads_id) {
return;
}
$config_ids = array();
if ($ga4_id) {
$config_ids[] = $ga4_id;
}
if ($ads_id) {
$config_ids[] = $ads_id;
}
echo "\n";
echo "\n";
}
add_action('wp_head', 'velveted_output_tracking', 4);
function velveted_output_gtm_noscript() {
$gtm_id = trim(get_option('velveted_gtm_id', ''));
if (!$gtm_id) {
return;
}
echo '';
}
add_action('wp_body_open', 'velveted_output_gtm_noscript');
function velveted_placeholder_img_src($src) {
return get_stylesheet_directory_uri() . '/assets/images/placeholder.svg';
}
add_filter('woocommerce_placeholder_img_src', 'velveted_placeholder_img_src');
function velveted_meta_tags() {
if (is_admin()) {
return;
}
$site_name = get_bloginfo('name');
$default_desc = 'Premium, discreet intimacy essentials curated for comfort, confidence, and body-positive pleasure.';
$title = wp_get_document_title();
$desc = $default_desc;
$url = is_singular() ... get_permalink() : home_url();
$image = 'https://images.unsplash.com/photo-1524504388940-b1c1722653e1...auto=format&fit=crop&w=1600&q=80';
if (is_singular('product') && function_exists('wc_get_product')) {
$product = wc_get_product(get_the_ID());
if ($product) {
$raw_desc = $product->get_short_description() ...: $product->get_description();
$raw_desc = str_replace('', '. ', $raw_desc);
$raw_desc = str_replace(array('
', '
', '
'), ' ', $raw_desc);
$desc = wp_strip_all_tags($raw_desc);
$desc = preg_replace('/\\s+/', ' ', $desc);
$desc = wp_trim_words($desc, 28, '...');
$product_image = wp_get_attachment_image_url($product->get_image_id(), 'full');
if ($product_image) {
$image = $product_image;
}
}
} elseif (is_page()) {
$page_desc = wp_strip_all_tags(get_the_excerpt() ...: get_the_content());
if ($page_desc) {
$desc = wp_trim_words($page_desc, 26, '...');
}
}
echo '\n";
echo '\n";
echo '\n";
echo '\n";
echo '' . "\n";
echo '\n";
echo '\n";
echo '' . "\n";
echo '' . "\n";
$schema = array(
'@context' => 'https://schema.org',
'@graph' => array(
array(
'@type' => 'Organization',
'name' => $site_name,
'url' => home_url(),
'logo' => $image,
),
array(
'@type' => 'WebSite',
'name' => $site_name,
'url' => home_url(),
'potentialAction' => array(
'@type' => 'SearchAction',
'target' => home_url('/...s={search_term_string}&post_type=product'),
'query-input' => 'required name=search_term_string',
),
),
),
);
echo '\n";
}
add_action('wp_head', 'velveted_meta_tags', 1);
function velveted_product_trust_block() {
if (!is_product()) {
return;
}
echo '';
echo '- Discreet packaging and neutral billing by default.
';
echo '- Body-safe materials with clear care guidance.
';
echo '- Worldwide-ready support within 24 hours.
';
echo '
';
}
add_action('woocommerce_single_product_summary', 'velveted_product_trust_block', 25);
function velveted_handle_contact_form() {
if (!isset($_POST['velveted_contact_nonce']) || !wp_verify_nonce($_POST['velveted_contact_nonce'], 'velveted_contact')) {
wp_safe_redirect(home_url('/contact...error=1'));
exit;
}
$name = sanitize_text_field($_POST['name'] ...... '');
$email = sanitize_email($_POST['email'] ...... '');
$message = sanitize_textarea_field($_POST['message'] ...... '');
if (!$name || !$email || !$message || !is_email($email)) {
wp_safe_redirect(home_url('/contact...error=1'));
exit;
}
$to = get_option('velveted_support_email', 'support@bluenight.store');
$subject = 'New contact message from ' . $name;
$body = "Name: {$name}\nEmail: {$email}\n\n{$message}";
$headers = array('Reply-To: ' . $name . ' <' . $email . '>');
wp_mail($to, $subject, $body, $headers);
wp_safe_redirect(home_url('/contact...sent=1'));
exit;
}
add_action('admin_post_nopriv_velveted_contact', 'velveted_handle_contact_form');
add_action('admin_post_velveted_contact', 'velveted_handle_contact_form');
function velveted_output_purchase_event($order_id) {
if (!$order_id || !function_exists('wc_get_order')) {
return;
}
$order = wc_get_order($order_id);
if (!$order) {
return;
}
$items = array();
foreach ($order->get_items() as $item) {
$product = $item->get_product();
$items[] = array(
'item_id' => $product ... $product->get_id() : $item->get_product_id(),
'item_name' => $item->get_name(),
'price' => (float) $order->get_item_total($item, false),
'quantity' => (int) $item->get_quantity(),
);
}
$payload = array(
'transaction_id' => (string) $order->get_id(),
'value' => (float) $order->get_total(),
'tax' => (float) $order->get_total_tax(),
'shipping' => (float) $order->get_shipping_total(),
'currency' => $order->get_currency(),
'items' => $items,
);
$gtm_id = trim(get_option('velveted_gtm_id', ''));
$ga4_id = trim(get_option('velveted_ga4_id', ''));
$ads_id = trim(get_option('velveted_gads_id', ''));
$ads_label = trim(get_option('velveted_gads_label', ''));
echo "";
}
add_action('woocommerce_thankyou', 'velveted_output_purchase_event', 20);
XML-RPC server accepts POST requests only.