• xeonz

    (@xeonz)


    Hello Comrades,

    I want to use some ACF-fields (Create this with WPUF) and create a new completely Clean HTML file with inline CSS. (Need to be clean because I want create a E-mail signature) Attached also the link to the template I was created with my code. Design is ok. But many SPAM-filters doesn’t like this signature when put in mail.

    How do I do this the most simple way?

    I Using Elementor and Hello Theme Elementor but code gets really messy with js-files and scripts, long elementor tags etc. I need code to be really Clean and minimal.

    This is what I done myself (added a new theme function in childtheme) but have no idea if this is the way to go. I was in my code done a function inside a function and I dont know if this is correct.

    My code works to create the new HTML-file, BUT the code not clean. I need to clean this code or do create a completely new HTML without theme css, styles, scripts etc.

    Thanks in advise.

    Code below or also in this URL: https://pastebin.com/ATKQJWR4

    function vgsign( $post_id ) {
           $post_type = get_post_type($post_id);
            // only update the attorneys custom post type on save
            if ( "card" != $post_type ) return;
            $vpost = get_post($post_id);
            $filename = $vpost->post_name.".html";
            header('Content-Description: File Transfer');
            header('Content-Type: text/html');
           // header('Content-Disposition: attachment; filename=signature.html');
            header('Content-Transfer-Encoding: binary');
           // header('Expires: 0');
           // header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
           // header('Pragma: public');
            $urlcard = $vpost->post_name;
            $data=null;
            
          //  $data.="PHOTO;TYPE=JPEG:" .$_POST['html5_1dp5ookdu861fkf1eq21qlu1j93']."\n";
            
            //$data.="COPY THIS CODE BELOW TO HTML SIGNATURE:"."\n";
            
            $data.= file_get_contents("https://mysite.io/a/".$urlcard."/?theme_template_id=1164");
            
            //$data.="END:COPY THIS CODE ABOVE TO HTML SIGNATURE";
            $filePath = get_template_directory()."/mailsign/".$filename; // you can specify path here where you want to store file.
            $file = fopen($filePath,"w");
           fwrite($file,$data);
           fclose($file);
    
    // BEGINNING EXTRA FUNCTION IN FUNCTION - THIS CODE BELOW TO END-TAG I DONT KNOW IF YOU CAN PUT IN EXISTING function?
    add_action('after_setup_theme', 'cleanup');
     
    function cleanup() {
      remove_action('wp_head', 'rsd_link');
      remove_action('wp_head', 'wp_generator');
      remove_action('wp_head', 'feed_links', 2);
      remove_action('wp_head', 'feed_links_extra', 3);
      remove_action('wp_head', 'index_rel_link');
      remove_action('wp_head', 'wlwmanifest_link');
      remove_action('wp_head', 'start_post_rel_link', 10, 0);
      remove_action('wp_head', 'parent_post_rel_link', 10, 0);
      remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
      remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
      remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
      remove_action('wp_head', 'print_emoji_detection_script', 7);
      remove_action('wp_head', 'rel_canonical');
      remove_action('wp_head', 'rel_alternate');
      remove_action('wp_head', 'wp_oembed_add_discovery_links');
      remove_action('wp_head', 'wp_oembed_add_host_js');
      remove_action('wp_head', 'rest_output_link_wp_head');
       
      remove_action('rest_api_init', 'wp_oembed_register_route');
      remove_action('wp_print_styles', 'print_emoji_styles');
       
      remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10);
      remove_filter('pre_oembed_result', 'wp_filter_pre_oembed_result', 10);
       
      add_filter('embed_oembed_discover', '__return_false');
      add_filter('show_admin_bar', '__return_false');
    }
    // END EXTRA FUNCTION IN FUNCTION
           }
    add_action( 'save_post', 'vgsign', 101, 3 );

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    In order to generate such a “clean” page in WP, I suggest utilizing a custom page template. Check out “Template Hierarchy” in the Theme Handbook for template file naming conventions.

    Most templates call get_header() and get_footer() to accomplish the usual theme skinning that goes with all site pages. You cannot do so because doing so also triggers all of the JS and CSS external references that you want to avoid. This means your template will need to replicate all the usual <html> and <head> section code that is usually in theme header and footer templates. By doing this, you are essentially “de-themeing” the page, so it will not look like much unless you provide all the inline CSS needed to accomplish the appearance you want.

    Thread Starter xeonz

    (@xeonz)

    Hi,

    Thank you, but can I have 2 templates activated at same time?

    I was think to write a very long function where I create a new HTML- user specific file for every post.

    The template I want to create for all post look like this:

    The only things I want to change is images and contactinfo. The user can download his HTML-clean template or just open and copy the information/ e-signature.

    Here is one HTML-template I want to use:

    <!DOCTYPE html>
    <html lang="sv-SE">
        <meta charset="UTF-8">
        <title>Title</title>
    <br><br>
        <div class="ecocard-signature" style="margin: 5px auto; padding:10px;">
            <table style="font-family: 'Helvetica Neue', Helvetica, Arial,sans-serif;" border="0" cellpadding="0" cellspacing="0" width="650">
                <tbody>
                    <tr>
                        <td width="70" style="padding-right: 15px;"><img src="3on-logo.png" alt="logo" max-height="150px" width="150" style="padding: 2px; border-radius: 8%; border: solid 1px #e4e4dc; "></td>
                        <td style="padding-left:20px; border-left: solid 2px #cecece;" width="400">
                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                <tbody>
    								   <tr>
    									<td style="font-size:12px; color:#8bc34a; font-weight:bold;text-transform:uppercase;">Firstname Lastname <span style="font-size:14px;color:#4b5662; text-transform:lowercase;">ceo</span></td>
    									</tr>						
    									<tr>
                                  <td style="font-size:14px; line-height:18px;"><span style="color:#000000;font-weight: 600;text-transform:uppercase;">c</span> Company.</td>
                                  </tr>
    									<tr>
    									  <td style="font-size:14px; line-height:18px; padding: 10px 0px 10px 0px;"><a href="tel:+46733729898" style="padding: 0px 10px 0px 10px;"><img alt="Phone" src="ecocard-phone.png" height="38" width="38"></a>
    												<a href="sms:+46733729898" style="padding: 0px 10px 0px 0px;"><img alt="Message" src="ecocard-direct-message.png"  height="38" width="38"></a>
                                            <a href="https://url-to-card/" style="padding: 0px 10px 10px 0px;"><img alt="url.card" src="ecocard-io-my-business-card.png" height="38" width="38"></a>                                        
                                            <a href="https://url.se" style="padding: 10px 0px 10px 0px;"><img alt="google+" src="website-ecocard-link.png"  height="38" width="38"></a></td>
    							  </tr>
    									<tr>
                                    <td style="font-size:14px; line-height:18px;"><span style="color:#000000;font-weight: 600;text-transform:uppercase;">t </span><a href="tel:+46733729898" style="color:#080808;text-decoration:none;">+46123123 </a> | <span style="color:#000000;font-weight: 600;text-transform:uppercase;">p </span><a href="tel:+46123" style="color:#080808;text-decoration:none;"> +46 123 20 150</a></td>
                                </tr>
    						           
    						           <tr>
                                    <td style="font-size:14px;line-height:18px;"><span style="color:#000000;font-weight: 600;">E </span><a href="mailto:[email protected]" style="color:#080808; text-decoration:none;">[email protected]</a> | <span style="color:#000000;font-weight: 600;text-transform:uppercase;">w </span><a href="https://3on.se/" style="color:#080808; text-decoration:none;">3on.se</a></td>
    									   
                                </tr>
    								<tr>
    							          <td style="font-size:14px;line-height:18px;"><span style="color:#666;font-weight: 600;">View </span><a href="https://url#/" style="color:#999; text-decoration:none;">my online business card</a></td>
    					          </tr>
                                </tbody>
                            </table>
                        </td>
                        <td style="padding-left:20px; border-left: solid 2px #cecece;" width="180"><br>
    					<img src="image.jpg" alt="logo" height="150" width="150px" style="padding: 2px; border-radius: 50%; border: solid 1px #e4e4dc; ">
    					</td>
                    </tr>
    				<tr>
    				<td colspan="3" style="padding-top:10px;" width="470">
                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                <tbody>
                                    <tr>
                                        <td style="text-align: left;padding-left: 180px;" width="100%">
                                            <a href="https://download-url-for.vcf" style="padding: 2px;"><button style="background-color: white; color: black; padding: 5px 22px; text-align: center; text-decoration: none; display: inline-block; font-size: 10px; margin: 4px 2px; cursor: pointer; border: 2px solid #e7e7e7;">Get my VCARD</button></a>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </td>
    				</tr>
                </tbody>
            </table>
    	</div>
    </html>
    
    • This reply was modified 5 years ago by xeonz.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Create a new clean HTML-file with with no .js scripts etc’ is closed to new replies.