WP Simple Pay – Add Customer Shipping Address to Payment Metadata

/** * @link https://library.wpcode.com/snippet/m5ljwkl2/ */ add_filter( ‘simpay_get_paymentintent_args_from_payment_form_request’, function( $args, $form ) { $customer = \SimplePay\Core\API\Customers\retrieve( $args[‘customer’], $form->get_api_request_args() ); $shipping_address = $customer->shipping->address; $shipping_name = $customer->shipping->name; $shipping_phone = $customer->shipping->phone; $args[‘metadata’][‘Shipping-name’] = $shipping_name; $args[‘metadata’][‘Shipping-phone’] = $shipping_phone; foreach ( $shipping_address->toArray() as $key => $value…Continue reading

display_iframe_shortcode, hide outer contaer with ID, with checkbox

function display_iframe_shortcode() { $user_id = get_current_user_id(); $iframe_toggle = get_user_meta($user_id, ‘iframe_toggle’, true); // Determine the display style based on the user’s preference. $display_style = isset($iframe_toggle) && $iframe_toggle === ‘1’ ? ” : ‘style=”display: none;”‘; // Build the output with conditional visibility.…Continue reading

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