Smart convert images to webp (copy)

function convert_to_webp($file) { $file_path = $file[‘file’]; $file_type = $file[‘type’]; // Only for JPEG, PNG, and GIF images if (in_array($file_type, [‘image/jpeg’, ‘image/png’, ‘image/gif’, ‘image/jpg’])) { $webp_path = preg_replace(‘/.(jpe?g|png|gif)$/i’, ‘.webp’, $file_path); // Check if the GD library is available if (!function_exists(‘gd_info’)) {…Continue reading

wp_redirect

if ( ! is_ssl() ) { wp_redirect( ‘https://’ . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’], 301 ); exit(); }Continue reading

Disable Password Change Notification

/** * Disable the password change notification email. * – Prevents admin notifications when users change their passwords. */ add_filter(‘wp_password_change_notification_email’, ‘__return_false’);Continue reading

Custom Login Styles

/** * Add custom CSS styles for the WordPress login page. * – Styles include a custom registration button and login field adjustments. */ function add_custom_login_styles() { echo ‘ ‘; } add_action(‘login_head’, ‘add_custom_login_styles’); /** * Disable the language dropdown on…Continue reading

Child Theme Translation Loader

function buddyboss_theme_child_languages() { load_theme_textdomain(‘buddyboss-theme’, get_stylesheet_directory() . ‘/languages’); } add_action(‘after_setup_theme’, ‘buddyboss_theme_child_languages’);Continue reading

Update Donation Summary

add_filter(‘charitable_donation_summary’, ‘charitable_custom_donation_summary’, 10, 4 ); /** * Custom donation summary output. * * @param string $ret The default donation summary output. * @param Charitable_Campaign $campaign The campaign object. * @param int $amount The amount raised. * @param int $goal The…Continue reading

Modern CSS Reset

/* 1. Use a more-intuitive box-sizing model */ *, *::before, *::after { box-sizing: border-box; } /* 2. Remove default margin */ * { margin: 0; } body { /* 3. Add accessible line-height */ line-height: 1.5; /* 4. Improve text…Continue reading

PHP: Phot.ai API

function generate_photai_image() { // Check if the ‘prompt’ parameter is provided if (!isset($_POST[‘prompt’]) || empty(trim($_POST[‘prompt’]))) { wp_send_json_error([‘message’ => ‘Prompt is required.’]); return; } // Retrieve and validate additional styling information $style = isset($_POST[‘style’]) ? sanitize_text_field($_POST[‘style’]) : ‘cinematic’; // Retrieve and…Continue reading

PHP: Freepik

function generate_freepik_image() { // Vérification du paramètre ‘prompt’ if (!isset($_POST[‘prompt’]) || empty(trim($_POST[‘prompt’]))) { wp_send_json_error([‘message’ => ‘Prompt is required.’]); return; } // Récupération et validation des données de style $style = isset($_POST[‘style’]) ? sanitize_text_field($_POST[‘style’]) : ‘photo’; $color = isset($_POST[‘color’]) ? sanitize_text_field($_POST[‘color’])…Continue reading