"", "type" => "preview", "html" => "", "datas" => array(), "params" => array() ),$attrs); if (!function_exists('str_get_html')) { include YEEMAIL_PLUGIN_PATH."libs/simple_html_dom.php"; } $id_template = $data_attrs["id_template"]; $datas_check =$data_attrs["datas"]; if ( is_user_logged_in() ) { $datas_check["[yeemail_is_user_logged_in]"] = "true"; }else{ $datas_check["[yeemail_is_user_logged_in]"] = false; } if($data_attrs["html"] != "") { $template_html = $data_attrs["html"]; }else{ $template_html = self::get_html($id_template,$datas_check); } switch($data_attrs["type"]){ case "full": ob_start(); include YEEMAIL_PLUGIN_PATH."email-templates/header.php"; echo self::get_settings_css($id_template); // phpcs:ignore WordPress.Security.EscapeOutput echo do_shortcode($template_html); // phpcs:ignore WordPress.Security.EscapeOutput include YEEMAIL_PLUGIN_PATH."email-templates/footer.php"; $html= ob_get_clean(); return $html; break; case "content_no_shortcode": return $template_html; break; default: return do_shortcode($html); break; } } public static function get_html( $id_template, $datas=""){ $width = get_post_meta( $id_template,'_mail_width',true); if($width < 480 || $width== "" ){ $width = "640"; } $html =""; $data_json = get_post_meta( $id_template,'data_email',true); $data_json = json_decode($data_json,true); if(!$data_json){ return ; } $container = $data_json["container"]; $container_css = self::cover_array_to_css($container); $data_contents = $data_json["rows"]; $datas_builder = apply_filters("yeemail_builder_block_html",array()); $class = "container"; $html = ""; ob_start(); ?>
$row_colunm){ switch ($row_key){ case "background_full": if($row_colunm == "ok" && isset($row_style_array["background-color"]) && $row_style_array["background-color"] != ""){ $container_row_css["background-color"] = $row_style_array["background-color"]; } break; case "responsive": $container_row_class = "yeemail-responsive"; break; } } } $container_row_css = self::cover_array_to_css($container_row_css); $i=0; ?>
Content Email'; } $inner_attr = $element["inner_attr"]; $container_style_array = $element["container_style"]; if(isset($container_style_array["background-image"]) && $container_style_array["background-image"] == "none"){ unset($container_style_array["background-position"]); unset($container_style_array["background-repeat"]); unset($container_style_array["background-size"]); unset($container_style_array["background-image"]); } $container_style = self::cover_array_to_css($container_style_array); $inner_style = $element["inner_style"]; if(isset($element["condition"])){ $element_condition = $element["condition"]; }else{ $element_condition = ''; } $html_el = str_get_html($datas_builder[ $type ]["builder"]); $show = apply_filters( "yeemail_conditional_logic_show", true, $element_condition,$datas ); if( $show ){ $html_el->find('.builder-elements-content',0)->setAttribute("style",$container_style); if($show == "yeemail_show_desktop" || $show == "yeemail_show_mobile"){ $html_el->find('.builder-elements-content',0)->addClass($show); } foreach( $inner_attr as $key => $attrs ){ foreach( $attrs as $k => $v ){ if(!is_array($v)){ $v = do_shortcode($v); } switch( $type ){ case "qrcode": if( $k == "html_hide"){ $html_el->find( $key ,0)->removeClass('hidden'); $html_el->find( $key ,0)->innertext = '
'; }elseif( $k == "html"){ $html_el->find( $key ,0)->remove(); }else{ $html_el->find( $key ,0)->setAttribute($k,$v); } break; case "barcode": if( $k == "html_hide"){ $html_el->find( $key ,0)->removeClass('hidden'); $html_el->find( $key ,0)->innertext = '
'; }elseif( $k == "html"){ $html_el->find( $key ,0)->remove(); }else{ $html_el->find( $key ,0)->setAttribute($k,$v); } break; case "image": if( isset($attrs["data-type"]) && $attrs["data-type"] == 1){ $change_data = str_replace('"',"'",$attrs["data-field"]); $html_el->find( "img" ,0)->setAttribute("src",$change_data); }else{ if( $v != ""){ $html_el->find( $key ,0)->setAttribute($k,$v); } } break; case "signature": if( $attrs["data-field"] != ""){ $change_data = str_replace('"',"'",$attrs["data-field"]); $html_el->find( "img" ,0)->setAttribute("src",$change_data); }else{ if( $v != ""){ $html_el->find( $key ,0)->setAttribute($k,$v); } } break; case "menu": if(is_array($v)){ $table_menu =''; foreach($v as $menu_key => $menu ){ $table_menu .=''; } $table_menu .='
'.$menu["text"].'
'; $html_el->find( $key ,0)->setAttribute("outertext",$table_menu); } break; case "order_detail": if( $k == "html_hide"){ $html_el->find( $key ,0)->removeClass('hidden'); $table = $v; $table= preg_replace('/]*\bhidden\b[^>]*>.*?<\/td>/is', '', $table); $table= preg_replace('/]*\bhidden\b[^>]*>.*?<\/th>/is', '', $table); $html_el->find( $key ,0)->__set("innertext",$table); } elseif( $k == "html"){ $html_el->find( $key ,0)->remove(); } break; default: //text switch ($k){ case "html_hide": $html_el->find( $key ,0)->removeClass('hidden'); $html_el->find( $key ,0)->innertext = $v; break; case "html": $html_el->find( $key ,0)->remove(); break; case "text": $html_el->find( $key ,0)->setAttribute("innertext",$v); break; default: $html_el->find( $key ,0)->setAttribute($k,$v); break; } if( $k == "html_hide"){ $html_el->find( $key ,0)->removeClass('hidden'); $html_el->find( $key ,0)->innertext = $v; }elseif( $k == "html"){ } else{ $html_el->find( $key ,0)->setAttribute($k,$v); } break; } } } $html_el = str_get_html($html_el); foreach( $inner_style as $key => $style ){ $inner_style_array = $style; if(isset($inner_style_array["background-image"]) && $inner_style_array["background-image"] == "none"){ unset($inner_style_array["background-position"]); unset($inner_style_array["background-repeat"]); unset($inner_style_array["background-size"]); unset($inner_style_array["background-image"]); } $in_style = self::cover_array_to_css($inner_style_array); foreach( $html_el->find( $key ) as $html_el_inner ){ $old_style = $html_el_inner->getAttribute ("style"); $html_el_inner->setAttribute("style",$old_style.$in_style); } } return $html_el; } return $html; } }