Auto convert photos to WEBP (jpg, png)

/** * Konwertuj przesłane obrazy na format WebP * * Ten fragment kodu automatycznie konwertuje przesłane obrazy (JPEG, PNG, GIF) * do formatu WebP w WordPress. Idealny do umieszczenia w pliku functions.php motywu * lub do korzystania z wtyczek takich…Continue reading

redirect facebookjoin role to facebook-join page at every session with cookie

add_action(‘init’, ‘grimoire_check_facebookjoin_role_every_visit’); function grimoire_check_facebookjoin_role_every_visit() { if (is_user_logged_in() && !is_admin()) { $user = wp_get_current_user(); $should_redirect = in_array(‘facebookjoin’, (array) $user->roles) && empty($_COOKIE[‘facebookjoin_redirected’]); if ($should_redirect) { // Set a cookie to prevent future redirects until the session ends. setcookie(‘facebookjoin_redirected’, ‘1’, 0, COOKIEPATH, COOKIE_DOMAIN,…Continue reading

custom_tawkto_user_info_js 1

function custom_tawkto_user_info_js() { // Check if the user is logged in if (is_user_logged_in()) { // Get the current user’s information $current_user = wp_get_current_user(); // Output the user’s name and email in JavaScript variables echo ” “; } } // Hook…Continue reading

Allow SVG Files Upload (copy)

/** * Allow SVG uploads for administrator users. * * @param array $upload_mimes Allowed mime types. * * @return mixed */ add_filter( ‘upload_mimes’, function ( $upload_mimes ) { // By default, only administrator users are allowed to add SVGs. //…Continue reading

Untitled Snippet

add_action( ‘plugins_loaded’, ‘ht_force_header_for_site_search_spam’ ); /** * Targets common search spam queries and sets a 410 Gone header * to get them out of Google Search Console. * * @since 1.0.0 */ function ht_force_header_for_site_search_spam() { // If we can’t find the…Continue reading