Esempio n. 1
0
/**
 * Shortcode for paragraph
 * 
 * @param type $attr
 */
function bbpp_thankmelater_shortcode_p($atts, $content = NULL)
{
    extract(Bbpp_ThankMeLater_Shortcoder::atts(array("email_type" => NULL, "comment" => NULL, "force" => 0), $atts));
    // execute shortcodes inside...
    $content = trim(Bbpp_ThankMeLater_Shortcoder::apply($content));
    // empty paragraph?
    if (empty($content) && !$force) {
        return "";
    }
    if ($email_type == "text") {
        return $content . "\n\n";
    } else {
        // elements which cannot appear in a <p>
        $noninline_els_regex = implode("|", array("address", "applet", "area", "base", "basefont", "blockquote", "body", "button", "caption", "center", "col", "colgroup", "dd", "dir", "div", "dl", "dt", "fieldset", "form", "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "hr", "html", "iframe", "ins", "isindex", "legend", "li", "link", "map", "menu", "meta", "noframes", "noscript", "object", "ol", "optgroup", "option", "p", "param", "pre", "style", "table", "tbody", "td", "tfoot", "th", "thead", "title", "tr", "u", "ul", "article", "aside", "audio", "bdi", "canvas", "command", "datalist", "details", "embed", "figcaption", "figure", "header", "hgroup", "keygen", "mark", "output", "progress", "rp", "rt", "ruby", "section", "source", "summary", "time", "track", "video"));
        // if there's any non-inline elements involved, don't put in the paragraph:
        // up to the user to place [p] ... [/p] themselves (around elements which
        // are not block)
        // TODO may consider inserting a paragraph up to the point that the non-inline
        // element occurs
        if (preg_match("#</?({$noninline_els_regex})( |>)#i", $content)) {
            return $content;
        } else {
            return "<p>" . nl2br($content) . "</p>";
        }
    }
}
Esempio n. 2
0
/**
 * Shortcode for a template part (e.g. the sidebar, content, etc)
 * 
 * @param type $attr
 */
function bbpp_thankmelater_shortcode_t_part($atts, $content = NULL)
{
    extract(Bbpp_ThankMeLater_Shortcoder::atts(array("email_type" => NULL, "comment" => NULL, "name" => "main"), $atts));
    $content = trim(Bbpp_ThankMeLater_Shortcoder::apply($content));
    Bbpp_ThankMeLater_TemplateHelper::add_part($name, $content);
    // Show no output. The template must explicity load this part!
    return "";
}
Esempio n. 3
0
/**
 * 
 * @param type $attr
 */
function bbpp_thankmelater_shortcode_htmlonly($atts, $content = NULL)
{
    extract(Bbpp_ThankMeLater_Shortcoder::atts(array("email_type" => NULL, "comment" => NULL, "apply_shortcodes" => 1), $atts));
    $apply_shortcodes = strtolower($apply_shortcodes);
    if ($email_type == "html") {
        if ($apply_shortcodes) {
            return Bbpp_ThankMeLater_Shortcoder::apply($content);
        } else {
            return $content;
        }
    }
    return "";
}
Esempio n. 4
0
/**
 * Shortcode for simple template
 * 
 * @param type $attr
 */
function bbpp_thankmelater_shortcode_t_simple($atts, $content = NULL)
{
    extract(Bbpp_ThankMeLater_Shortcoder::atts(array("email_type" => NULL, "comment" => NULL, "background_color" => "#F6F6F6", "page_background_color" => "#FFFFFF"), $atts));
    if (!preg_match("#^\\#[0-F]{6}\$#i", $background_color)) {
        $background_color = "#F6F6F6";
    }
    if (!preg_match("#^\\#[0-F]{6}\$#i", $page_background_color)) {
        $page_background_color = "#FFFFFF";
    }
    // execute shortcodes inside...
    $content = trim(Bbpp_ThankMeLater_Shortcoder::apply($content));
    $main = Bbpp_ThankMeLater_TemplateHelper::get_part("main");
    if (!$main) {
        $main = $content;
    }
    if ($email_type == "text") {
        $output = "";
        $output .= Bbpp_ThankMeLater_TemplateHelper::get_part("header") . "\n\n";
        $output .= $main . "\n\n";
        $output .= Bbpp_ThankMeLater_TemplateHelper::get_part("footer");
        return $output;
    }
    $output = "";
    $output .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" . " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
    $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
    $output .= "<head>\n";
    $output .= "<style type=\"text/css\">\n";
    $output .= "body { width: 100%; margin: 0px; padding: 0px;" . "font-family: arial, sans-serif; font-size: 14px; line-height: 18px;" . "color: #333333; background: {$background_color};}\n";
    $output .= "#wrap { padding-top: 10px; }\n";
    $output .= "#header-banner { padding: 0px; }\n";
    $output .= "#header { padding-top: 5px; padding-bottom: 5px;" . " padding-left: 20px; padding-right: 20px; }\n";
    $output .= "h1 { font-size: 32px; line-height: 41px; margin: 0px;" . " letter-spacing: -1px;}\n";
    $output .= "h2 { font-size: 18px; line-height: 23px; margin: 0px;" . " letter-spacing: -1px;}\n";
    $output .= "a { color: #0000FF; }\n";
    $output .= "p { padding-top: 0px; padding-bottom: 18px; margin: 0px; }\n";
    $output .= "#header-banner-table { background-color: " . $page_background_color . "; }\n";
    $output .= "#header-table { background-color: " . $page_background_color . "; }\n";
    $output .= "#content-table { background-color: " . $page_background_color . ";" . " padding-bottom: 20px; }\n";
    $output .= "#main { padding-left: 20px; padding-right: 20px; }\n";
    $output .= "#footer { padding-top: 5px; padding-bottom: 5px;" . " padding-left: 20px; padding-right: 20px; }\n";
    $output .= "#footer-table { background-color: " . $page_background_color . "; padding-bottom: 20px; }\n";
    $output .= "</style>\n";
    $output .= "</head>\n";
    $output .= "<body>\n";
    // center
    $output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" " . "width=\"100%\">\n";
    $output .= "<tr>\n";
    $output .= "<td align=\"center\" id=\"wrap\">\n";
    // header banner
    $output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"" . " width=\"600\" id=\"header-banner-table\">\n";
    $output .= "<tr>\n";
    $output .= "<td id=\"header-banner\">\n";
    if ($header_banner = Bbpp_ThankMeLater_TemplateHelper::get_part("header_banner")) {
        $output .= $header_banner . "\n";
    } else {
        $output .= "<img src=\"" . plugins_url('imgs/thank-you-banner.png', dirname(__FILE__)) . "\" width=\"600\" height=\"75\">";
    }
    // end header banner
    $output .= "</td>\n";
    $output .= "</tr>\n";
    $output .= "</table>\n";
    // header
    $output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"" . " width=\"600\" id=\"header-table\">\n";
    $output .= "<tr>\n";
    $output .= "<td id=\"header\">\n";
    $output .= Bbpp_ThankMeLater_TemplateHelper::get_part("header") . "\n";
    // end header
    $output .= "</td>\n";
    $output .= "</tr>\n";
    $output .= "</table>\n";
    // main
    $output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"" . " width=\"600\" id=\"content-table\">\n";
    $output .= "<tr>\n";
    $output .= "<td id=\"main\" valign=\"top\">\n";
    $output .= $main;
    // end main
    $output .= "</td>\n";
    $output .= "</tr>\n";
    $output .= "</table>\n";
    // footer
    $output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"" . " width=\"600\" id=\"footer-table\">\n";
    $output .= "<tr>\n";
    $output .= "<td id=\"footer\">\n";
    $output .= Bbpp_ThankMeLater_TemplateHelper::get_part("footer") . "\n";
    // end footer
    $output .= "</td>\n";
    $output .= "</tr>\n";
    $output .= "</table>\n";
    // end center
    $output .= "</td>\n";
    $output .= "</tr>\n";
    $output .= "</table>\n";
    $output .= "</body>\n";
    $output .= "</html>";
    return Bbpp_ThankMeLater_TemplateHelper::inline_css($output);
}
Esempio n. 5
0
 /**
  * Get the subject of message after shortcodes applied
  * 
  * @param object $comment the result of get_comment($id, OBJECT) for a particular comment.
  * @return string|null the parsed subject, or null if not available.
  */
 public function getParsedSubject($comment)
 {
     if (!class_exists("Bbpp_ThankMeLater_Shortcoder")) {
         require_once BBPP_THANKMELATER_PLUGIN_PATH . "Shortcoder.php";
     }
     if (isset($this->data[$this->pointer], $this->data[$this->pointer]["subject"])) {
         $subject = $this->data[$this->pointer]["subject"];
     } else {
         return NULL;
     }
     $subject_parsed = Bbpp_ThankMeLater_Shortcoder::apply($subject, array("email_type" => "text", "comment" => $comment));
     return $subject_parsed;
 }