[wp-trac] [WordPress Trac] #25239: $_SERVER['SERVER_NAME'] not a reliable when generating email host names

WordPress Trac noreply at wordpress.org
Wed Aug 17 09:05:28 UTC 2016


#25239: $_SERVER['SERVER_NAME'] not a reliable when generating email host names
-------------------------------------------------+-------------------------
 Reporter:  layotte                              |       Owner:
     Type:  defect (bug)                         |  SergeyBiryukov
 Priority:  normal                               |      Status:  reviewing
Component:  Mail                                 |   Milestone:  Future
 Severity:  normal                               |  Release
 Keywords:  has-patch dev-feedback needs-        |     Version:  3.8
  testing                                        |  Resolution:
                                                 |     Focuses:
-------------------------------------------------+-------------------------

Comment (by mensmaximus):

 To make the function more flexible and to strip the subdomain for email
 addresses we could pass some arguments:

 {{{
 #!php
 function get_current_domain( $strip_subdomain = true, $blog_id = '' ) {
         $blog_id = empty( $blog_id ) ? get_current_blog_id() : $blog_id;
         $domain = parse_url( get_home_url( $blog_id ), PHP_URL_HOST );
         if ( true === $strip_subdomain ) {
                 $domain_parts = explode ( ".", $domain );
                 array_shift( $domain_parts );
                 $domain = implode( '.', $domain_parts );
         }
         return $domain;
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/25239#comment:22>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list