Register New Elements

  1. Backend Implementation (PHP) To register new emails, developers should use the following code:

    /**
     * Register new Elements.
     *
     * @param object $element_service The service responsible for registering elements
     * @return void
     */
     function register_new_element( $element_service ) {
    	
    	$element_service->register_element( new \YourNewElement()  );
    
    }
    add_action( 'yaymail_register_elements', 'register_new_element' );
    
    // Enqueue WordPress React scripts
    function enqueue_wp_react_scripts() {
        wp_enqueue_script( 'wp-react' );
    }
    add_action( 'wp_enqueue_scripts', 'enqueue_wp_react_scripts' );

    This code attaches to the yaymail_register_elements action hook. It is used to register new email templates by passing the email instance.

  1. Frontend Implementation (TypeScript/React)

    1. Register Element in Frontend

Last updated

Was this helpful?