function get_email_data_from_options($key, $type) { $values = array(); if (have_rows($key, ‘option’)) while (have_rows($key, ‘option’)) : the_row(); if (get_sub_field(‘type’) == $type) { $values[‘from_email’] = get_sub_field(‘from_email’); $values[‘from_name’] = get_sub_field(‘from_name’); $values[‘subject’] = strip_tags(apply_filters(‘the_content’, get_sub_field(‘subject’))); // $values[‘message’] = apply_filters(‘the_content’, get_sub_field(‘message’)); $values[‘message’] = get_sub_field(‘message’); add_filter(‘wp_mail_from’, function…Continue reading
function render_user_gallery() { if (!is_user_logged_in()) { error_log(“[GALLERY] User not logged in.”); return ‘ You must be logged in to view your gallery. ‘; } // Retrieve user info and directories $current_user = wp_get_current_user(); $user_id = $current_user->ID; $upload_dir = wp_upload_dir(); $user_dir…Continue reading
function display_user_enrolled_courses() { if (!is_user_logged_in()) { return “الرجاء تسجيل الدخول لرؤية دوراتك”; } if (!function_exists(‘tutor’)) { return “النظام غير متاح حاليًا”; } $user_id = get_current_user_id(); $enrolled_courses = tutor_utils()->get_enrolled_courses_by_user($user_id); if (empty($enrolled_courses)) { return “لم تشترك في أي دورة بعد”; } $output…Continue reading
header(‘Content-Type: application/json’); function uploadImageToUploadsFolder() { if (isset($_FILES[‘image’]) && $_FILES[‘image’][‘error’] === UPLOAD_ERR_OK) { $image = $_FILES[‘image’]; $custom_tags = isset($_POST[‘tags’]) ? sanitize_text_field($_POST[‘tags’]) : ”; // Loguez le chemin temporaire pour vérifier où le fichier est initialement téléchargé error_log(‘Chemin temporaire du fichier :…Continue reading
function hide_html_editor_for_shop_manager() { $user = wp_get_current_user(); if (in_array(‘shop_manager’, (array) $user->roles)) { echo ‘ ‘; } } add_action(‘admin_head’, ‘hide_html_editor_for_shop_manager’); function customize_shop_manager_role() { // Get the Shop Manager role object $role = get_role(‘shop_manager’); // Remove ‘publish’ capabilities for products $role->remove_cap(‘publish_products’); // Remove…Continue reading
function get_term_plural_name($term_id, $taxonomy = ‘category’) { $plural = get_term_meta($term_id, ‘plural_name’, true); return $plural ?: get_term($term_id, $taxonomy)>name; } add_filter(‘get_the_terms’, function ($terms, $post_id, $taxonomy) { if (is_archive() || is_home()) { // Only for list contexts foreach ($terms as $term) { $plural =…Continue reading
function add_plural_field_to_taxonomy($term) { $plural = get_term_meta($term->term_id, ‘plural_name’, true); ?> Category Plural NameContinue reading
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
if ( ! is_ssl() ) { wp_redirect( ‘https://’ . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’], 301 ); exit(); }Continue reading
/** * Automatic redirect from login form if a user is already logged in * * @link https://wpforms.com/developers/how-to-automatically-redirect-if-user-is-already-logged-in/ */ function redirect_to_specific_page() { // enter the page ID of the page that contains the login form $page_id = 345; // Change…Continue reading