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
/* * Custom input mask for the address field’s international scheme. * * @link https://wpforms.com/developers/how-to-add-an-input-mask-to-the-international-postal-code */ function wpf_dev_address_field_properties( $properties, $field, $form_data ) { if($field[ ‘scheme’ ] === ‘international’) { $properties[ ‘inputs’ ][ ‘postal’ ][ ‘class’ ][] = ‘wpforms-masked-input’; $properties[ ‘inputs’…Continue reading
/** * Use conditional logic with a date field to show or hide another form field * * @link https://wpforms.com/developers/how-to-use-conditional-logic-with-a-date-picker/ */ add_action( ‘wp_head’, function () { ?>Continue reading