true, 'strategy' => 'defer', ) ); wp_add_inline_script( 'edonating-embed', 'window.edonatingOrigin = ' . wp_json_encode( EDONATING_ORIGIN ) . ';', 'before' ); } add_action( 'init', 'edonating_register_assets' ); /** * The choices a page can make about how a form looks, and the values each accepts. Anything else is ignored, and an * empty value means "as set in the edonating dashboard". * * @return array */ function edonating_look_options() { return array( 'design' => array( 'soft', 'outline', 'bold' ), 'font' => array( 'modern', 'classic', 'plain' ), 'layout' => array( 'narrow', 'wide' ), 'width' => array( 'narrow', 'wide', 'full' ), 'align' => array( 'left', 'center', 'right' ), ); } /** * Parts of the form a page can leave out. * * @return array */ function edonating_hideable_parts() { return array( 'title', 'impact', 'giftaid', 'fees', 'updates' ); } /** * The markup for one form. Used by the shortcode and the block. * * @param array $args form, mode (inline or button), label, color, design, font, layout, accent, hide, width, align. * @return string HTML. */ function edonating_render( $args ) { $form_id = isset( $args['form'] ) ? trim( (string) $args['form'] ) : ''; // Accept the form's address too (https://edonating.com/f/ID), not only the bare ID. if ( preg_match( '/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i', $form_id, $found ) ) { $form_id = $found[0]; } if ( ! edonating_is_form_id( $form_id ) ) { return current_user_can( 'edit_posts' ) ? '
' . esc_html__( 'edonating: add your form ID or its address. You can copy it from Forms in your edonating dashboard.', 'edonating' ) . '
' : ''; } wp_enqueue_script( 'edonating-embed' ); $is_button = isset( $args['mode'] ) && 'button' === $args['mode']; $label = isset( $args['label'] ) && '' !== trim( (string) $args['label'] ) ? mb_substr( sanitize_text_field( $args['label'] ), 0, 40 ) : __( 'Donate', 'edonating' ); $color = isset( $args['color'] ) ? sanitize_hex_color( $args['color'] ) : ''; $hosted = EDONATING_ORIGIN . '/f/' . rawurlencode( strtolower( $form_id ) ); $html = '