[PHP Snippets] Fix

Discussion in 'General InkThemes Discussion and Feedback' started by eriexl, Feb 9, 2015.

  1. eriexl

    eriexl New Member

    Joined:
    Feb 17, 2013
    Messages:
    1
    Likes Received:
    0
    Some of the code used to develop the Contact Page template for (I believe) all of the themes on InkThemes was originally written by one of the developers at PHP Snippets a long long time ago. As a result all of the emails received show the "[PHP Snippets] From" in the subject line. They had their site name hard coded in so they could see what website their emails were coming from. A pretty useful feature. However its probably inconvenient for those who don't know how to change it.

    I believe what would be more useful to everyone using your themes would be for it to use THEIR site name. Luckily this is a pretty easy fix provided by a function in WordPress.

    Simply replace the following code in the Contact Page template for all of the themes (it should be the same for all of them).

    Replace this code...

    Code:
        if (!isset($hasError)) {
            $emailTo = get_option('tz_email');
            if (!isset($emailTo) || ($emailTo == '')) {
                $emailTo = get_option('admin_email');
            }
            $subject = '[PHP Snippets] From ' . $name;
            $body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
            $headers = 'From: ' . $name . ' <' . $emailTo . '>' . "\r\n" . 'Reply-To: ' . $email;
            mail($emailTo, $subject, $body, $headers);
            $emailSent = true;
        }
    with this code...

    Code:
        if (!isset($hasError)) {
            if (!isset($emailTo) || ($emailTo == '')) {
                $emailTo = get_option('admin_email');
            }
            if (!isset($blogName) || ($blogName == '')) {
                $blogName = get_bloginfo('name');
            }
            $subject = '[' . $blogName . '] From ' . $name;
            $body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
            $headers = 'From: ' . $name . ' <' . $emailTo . '>' . "\r\n" . 'Reply-To: ' . $email;
            mail($emailTo, $subject, $body, $headers);
            $emailSent = true;
        }
    The
    Code:
    get_bloginfo('name')
    displays the "Site Title" set in Settings > General. This data is retrieved from the "blogname" record in the wp_options table. I have no idea what the
    Code:
    $emailTo = get_option('tz_email');
    was for so I removed that as well. Its nowhere in the codex or the themes. I assume it was another statement the original PHP Snippets developer had written specific to their site.


    Anyway, hope this helps someone.
     
  2. Pramod

    Pramod Guest

    Joined:
    Aug 8, 2014
    Messages:
    2,847
    Likes Received:
    63
    Hello !

    Good work ,
    This will helpful for other people who want to make changes in their contact us email heading.

    Thanks & Regards
    Pramod
     

Share This Page