Warning: getimagesize(): SSL operation failed with code 1. OpenSSL Error messages: error:0A000086:SSL routines::certificate verify failed in /var/www/vhosts/spacedonkey.de/httpdocs/wp-content/plugins/print-pro-matic/print-pro-matic.php on line 261

Warning: getimagesize(): Failed to enable crypto in /var/www/vhosts/spacedonkey.de/httpdocs/wp-content/plugins/print-pro-matic/print-pro-matic.php on line 261

Warning: getimagesize(https://spacedonkey.de/wp-content/uploads/2021/10/printer-24.png): Failed to open stream: operation failed in /var/www/vhosts/spacedonkey.de/httpdocs/wp-content/plugins/print-pro-matic/print-pro-matic.php on line 261

Print-Pro-Matic Lazy-load Image Test

By default, WordPress will add loading=”lazy” to all img tags that have width and height attributes present. Normally this is desired. However, if a page has many images and is to be printed, often times images further down the page have not yet loaded, leaving large spaces as placeholders for when the user finally scrolls down that far and the image loads. Good for the web, bad for a PDF.

Print-Pro matic now offers the option to selectively turn-off this default loading="lazy" attribute for images for the entire site.

Below is a series of images with width and height defined. By default lazy-load should be enabled, but with the option turned on, the lazy-load is disabled, allowing the images to fully load on the page in preparation for printing.

The New Print View Method

The more advanced method is by using a custom print_view variable that turns off the lazy-load only when the print is triggered. To accomplish this, first add the following to the child-theme’s function.php file: (note, this is no longer required as of version 2.1.2)

function printpromatic_query_var( $vars ) {
	$vars[] = 'print_view';
	return $vars;
}
add_filter( 'query_vars', 'printpromatic_query_var' );

function print_with_no_lazy_load() {
    if ( get_query_var( 'print_view' ) ) {
        return false;
    }
	return true;
}
add_filter( 'wp_lazy_loading_enabled', 'print_with_no_lazy_load' );

Next we add the print-me shortcode with a unique ID and url using the %print_view% placeholder:

[print-me id="donkey" url="%print_view%"/]

Ad of version 2.1.2 there is a new option to add the print_view query var from the plugin options page–so no need to manually add this to the child-theme’s function.php file. This option will also add the print_with_no_lazy_load function. Version 2.1.2 also added a url_target attribute to allow the print version to load in the same tab:

[print-me id="monkey" url="%print_view%" url_target="_self"/]
One, this is the loneliest number, according to some guys from Liverpool living in Hamburg in the late 60’s
Two is pretty bad to, it is often known as the loneliest number since the number one.
Three, oh it’s a Magic number. Just let Blind Melon sing you a song about it – Schoolhouse rock style.
Hollywood Hackers from the 90’s used 4 rather than the letter A, because… cyber?
Number Five is Alive!
“I see dead people”
Donkey!
A donkey in space?
A donkey in space!
Space Donkey!

Quick Test – Collapse by Class

This is a test on how to handle retroactively applying a collapse-expand feature to any element with a defined class.

The idea is to first have an element with a specific class that holds a heaping amount of content, like the one below:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Ok, that’s a lot of text. Now within collapse-pro-matic check for this class, if found append or prepend a trigger and then adjust the target to a defined minimum height.

This is something that would be applied to every element with the defined class, across all posts, future, present and past.

Collapse-O-Matic Button

[expand title="Push me" swaptitle="Push" trigclass="noarrow my_button" tag="div"]this is the hidden content[/expand]
Push me
this is the hidden content

CSS

.my_button {
background-color: white;
color: black;
border-radius: 6px;
font-family: by;
padding: 5px;
width: 99px;
text-align: center;
border: 2px solid #98FB98; /* Green */
}

.my_button.colomat-hover{
background-color: #eb234c; /* red */
color: white;
text-align: center;
}

Collapse-Commander Sub Elements

Simple example of using Collapse-Commander with sub-elements:

[expand cid="3279" /]
Master Blaster
sub item two
this is the second item
sub item one
this is the first item


Since 1.3.3 we can use order and orderby attributes

[expand cid="3279" orderby="title" order="ASC" /]
Master Blaster
sub item one
this is the first item
sub item two
this is the second item

Print-Pro-Matic Print External URL

This is a test to see if print-pro-matic can print an external URL:

[print-me url="https://docs.google.com/spreadsheets/d/e/2PACX-1vSC6kmo4lmXRBc7QHMmg_s2Dq4LBg0FHclszFjAhCW_wYo814nBWM_mQhAryRayPNdQJLCXw0gNVbPo/pubhtml"/]

There will be an issue with cross domain origin, however a url on the same domain can be printed:

[print-me url="https://spacedonkey.de/donkey/donkey-in-a-bucket/"/]

Print-O-Matic External Print Trigger – Target by Class

As of print-o-matic version 2.0.1 the ability to use class to target a print element in external print triggers has been added. Basically it works the same as using the data-print_target attribute but instead uses a unique classname in the format of printtarget-<target_id>.

Step 1

Create a target element. The element below is a div with an id of ‘my_print_target’:

<div id="my_print_target">This is the print target wrapped in a div with an element of 'my_print_target' as explained above</div>
This is the print target wrapped in a div with an element of ‘my_print_target’ as explained above

Step 2

Add an external trigger using the new class-trigger method. We’ll use a simple button like so:

<button id="my_print_button" class="printomatic printtarget-#my_print_target">Print Trigger</button>

Step 3

Like in the original example, we need to add the hidden print trigger using a print-me shortcode with the same id as our external trigger and a printstyle=”external” attribute: 

[print-me id="my_print_button" printstyle="external"/]

Collapse-Pro-Matic Excerpt Adjustment

This is an example of a simple expand element with an excerpt:

[expand title="Trigger Text" excerpt="The excerpt"]Hidden Content[/expand]

Trigger Text
The excerpt
Hidden Content

The excerpt can be repositioned above the trigger by adding excerptpos=”above-trigger” like so:

[expand title="Trigger Text" excerpt="The excerpt" excerptpos="above-trigger"]Hidden Content[/expand]

The excerpt
Trigger Text
Hidden Content

The following CSS can be used to control the vertical spacing between the three components. So that we don’t adjust all expand elements, the first step is to provide a unique class for each component:

[expand title="Trigger Text" excerpt="The excerpt" excerptpos="above-trigger" trigclass="skinny_trig" excerptclass="skinny_excerpt" targclass="skinny_targ" ]Hidden Content[/expand]

Now each can be controlled using the following css classes:

.skinny_trig {
    border: 1px dotted red;
}
.skinny_excerpt {
    border: 1px dotted green;
}
.skinny_targ {
    border: 1px dotted blue;
}

That results in borders around each:

to make things as compact as possible, we remove the following padding and margins:

.skinny_trig {
    /* border: 1px dotted red; */
    padding: 0 0 0 10px;
    line-height: .9;
}
.skinny_excerpt {
    /* border: 1px dotted green; */
    line-height: .8;
}
.skinny_targ {
    /* border: 1px dotted blue; */
    margin: 0;
    line-height: .8;
}

And the final results are:

The excerpt
Trigger Text
Hidden Content

Archive-Pro-Matic Pretty URL Rewrite

The goal is to change an ugly archive url into a pretty url. For example here is a quarterly custom post type archive:

The links are in a format of:

https://spacedonkey.de/date/2012/?q=4&post_type=monkey

And they would look better with something like:

https://spacedonkey.de/monkey/2012/Q4

To accomplish this, first the Add rewrite rules must be checked on the Archive-Pro-Matic settings page:

After the CPT Rewrite Rules has been checked and saved. It might be necessary to flush the rewrite rules by simply navigating to:
Dashboard > Settings > Permalinks – do nothing, and re-save the permalink settings.

Second a custom url rewrite function must be added to the child-theme’s function.php file. This function uses a new filter that has been added to manually overwrite the url that archive-pro-matic uses:

add_filter('apm_archive_link', 'pretty_my_archive_url');
function pretty_my_archive_url($url){
    $url_args = explode('?', $url);
    if(!empty($url_args[1])){
       parse_str($url_args[1], $args);
       if(!empty($args['year']) && !empty($args['q'])){
          $url = $url_args[0].$args['year'].'/Q'.$args['q'].'/';
       }
    }
    return $url;
}

Now, when we display a quarterly archive for a custom post type, the urls are prettier:

[archives type="quarterly" post_type="donkey" /]

And here is a test of just using the standard yearly archive for a custom post type:

[archives post_type="donkey" /]