includes/class-freemius.php
private function send_email(
            $to_address,
            $subject,
            $sections = array(),
            $headers = array()
        ) {
            $default_sections = $this->get_email_sections();

            // Insert new sections or replace the default email sections.
            if ( is_array( $sections ) && ! empty( $sections ) ) {
                foreach ( $sections as $section_id => $custom_section ) {
                    if ( ! isset( $default_sections[ $section_id ] ) ) {
                        // If the section does not exist, add it.
                        $default_sections[ $section_id ] = $custom_section;
                    } else {
                        // If the section already exists, override it.
                        $current_section = $default_sections[ $section_id ];

                        // Replace the current section's title if a custom section title exists.
                        if ( isset( $custom_section['title'] ) ) {
                            $current_section['title'] = $custom_section['title'];
                        }

                        // Insert new rows under the current section or replace the default rows.
                        if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) {
                            foreach ( $custom_section['rows'] as $row_id => $row ) {
                                $current_section['rows'][ $row_id ] = $row;
                            }
                        }

                        $default_sections[ $section_id ] = $current_section;
                    }
                }
            }

            $vars    = array( 'sections' => $default_sections );
            $message = fs_get_template( 'email.php', $vars );

            // Set the type of email to HTML.
            $headers[] = 'Content-type: text/html; charset=UTF-8';

            $header_string = implode( "\r\n", $headers );

            return wp_mail(
                $to_address,
                $subject,
                $message,
                $header_string
            );
        }
private function send_email(
            $to_address,
            $subject,
            $sections = array(),
            $headers = array()
        ) {
            $default_sections = $this->get_email_sections();

            // Insert new sections or replace the default email sections.
            if ( is_array( $sections ) && ! empty( $sections ) ) {
                foreach ( $sections as $section_id => $custom_section ) {
                    if ( ! isset( $default_sections[ $section_id ] ) ) {
                        // If the section does not exist, add it.
                        $default_sections[ $section_id ] = $custom_section;
                    } else {
                        // If the section already exists, override it.
                        $current_section = $default_sections[ $section_id ];

                        // Replace the current section's title if a custom section title exists.
                        if ( isset( $custom_section['title'] ) ) {
                            $current_section['title'] = $custom_section['title'];
                        }

                        // Insert new rows under the current section or replace the default rows.
                        if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) {
                            foreach ( $custom_section['rows'] as $row_id => $row ) {
                                $current_section['rows'][ $row_id ] = $row;
                            }
                        }

                        $default_sections[ $section_id ] = $current_section;
                    }
                }
            }

            $vars    = array( 'sections' => $default_sections );
            $message = fs_get_template( 'email.php', $vars );

            // Set the type of email to HTML.
            $headers[] = 'Content-type: text/html; charset=UTF-8';

            $header_string = implode( "\r\n", $headers );

            return wp_mail(
                $to_address,
                $subject,
                $message,
                $header_string
            );
        }
private function send_email ( $ to_address , $ subject , $ sections = array ( ) , $ headers = array ( ) ) { $ default_sections = $ this -> get_email_sections ( ) ; // Insert new sections or replace the default email sections.
 if ( is_array ( $ sections ) && ! empty ( $ sections ) ) { foreach ( $ sections as $ section_id => $ custom_section ) { if ( ! isset ( $ default_sections [ $ section_id ] ) ) { // If the section does not exist, add it.
 $ default_sections [ $ section_id ] = $ custom_section ; } else { // If the section already exists, override it.
 $ current_section = $ default_sections [ $ section_id ] ; // Replace the current section's title if a custom section title exists.
 if ( isset ( $ custom_section [ 'title' ] ) ) { $ current_section [ 'title' ] = $ custom_section [ 'title' ] ; } // Insert new rows under the current section or replace the default rows.
 if ( isset ( $ custom_section [ 'rows' ] ) && is_array ( $ custom_section [ 'rows' ] ) && ! empty ( $ custom_section [ 'rows' ] ) ) { foreach ( $ custom_section [ 'rows' ] as $ row_id => $ row ) { $ current_section [ 'rows' ] [ $ row_id ] = $ row ; } } $ default_sections [ $ section_id ] = $ current_section ; } } } $ vars = array ( 'sections' => $ default_sections ) ; $ message = fs_get_template ( 'email.php' , $ vars ) ; // Set the type of email to HTML.
 $ headers [ ] = 'Content-type: text/html; charset=UTF-8' ; $ header_string = implode ( "\r\n" , $ headers ) ; return wp_mail ( $ to_address , $ subject , $ message , $ header_string ) ; }
Generates and sends an HTML email with customizable sections.

@author Leo Fajardo (@leorw)
@since  1.1.2

@param string $to_address
@param string $subject
@param array  $sections
@param array  $headers

@return bool Whether the email contents were sent successfully.
Generates and sends an HTML email with customizable sections .