WooCommerce PDF Invoices & Packing Slips - Version 2.7.4

Version Description

  • New: Show notice if incompatible MailPoet mailing service is used
  • New: WooCommerce webhook topic for document saves
  • Fix: Don't reverse order of bulk document if already sorted oldest to newest
  • Marked tested up to WooCommerce 4.9
Download this release

Release Info

Developer pomegranate
Plugin Icon 128x128 WooCommerce PDF Invoices & Packing Slips
Version 2.7.4
Comparing to
See all releases

Code changes from version 2.7.3 to 2.7.4

assets/images/mailpoet.svg ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <svg width="100" height="31" viewBox="0 0 100 31" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M7.18525 17.5782C7.85037 17.5782 8.30645 17.4261 8.5535 17.1411C8.80317 16.8581 8.93865 16.4923 8.93357 16.1149V7.43032L12.1623 16.0009C12.3028 16.3986 12.5452 16.7524 12.8654 17.0271C13.1694 17.2741 13.6255 17.4071 14.2336 17.4071C14.6235 17.4115 15.0085 17.3202 15.3548 17.1411C15.7164 16.9332 15.9824 16.5922 16.096 16.1909L19.5356 6.68918V16.0389C19.5117 16.4626 19.655 16.8788 19.9347 17.1981C20.2007 17.4641 20.6378 17.6162 21.2459 17.6162C21.911 17.6162 22.3671 17.4641 22.6142 17.1791C22.8638 16.8961 22.9993 16.5303 22.9942 16.1529V2.29938C23.007 2.05395 22.956 1.80938 22.8461 1.58956C22.7362 1.36973 22.5712 1.18216 22.3671 1.04516C21.968 0.779107 21.4169 0.646083 20.7328 0.646083C20.1149 0.620125 19.5004 0.750868 18.9465 1.02615C18.472 1.31918 18.1258 1.78079 17.9773 2.31839L14.2355 13.3974L10.3398 2.24237C10.1863 1.76922 9.88693 1.35679 9.48467 1.06416C9.08559 0.779107 8.53449 0.646083 7.81236 0.646083C7.22226 0.617212 6.636 0.755543 6.12105 1.04516C5.68397 1.33021 5.45593 1.78629 5.45593 2.4134V16.0009C5.45593 16.533 5.58896 16.913 5.836 17.1791C6.12105 17.4451 6.55813 17.5782 7.18525 17.5782Z" fill="#FF5301"/>
3
+ <path d="M28.5261 17.6922C29.0192 17.6984 29.511 17.6409 29.9893 17.5212C30.373 17.4203 30.743 17.2735 31.0916 17.0841C31.393 16.9237 31.6685 16.7187 31.9087 16.476C32.0227 16.362 32.1367 16.248 32.2318 16.1339V16.1529C32.2318 16.666 32.3838 17.0461 32.7068 17.2741C33.0694 17.5042 33.4941 17.617 33.9231 17.5972C34.5122 17.5972 34.9303 17.4832 35.1963 17.2551C35.4624 17.0271 35.5954 16.647 35.5954 16.1529V9.12166C35.5954 7.58238 35.1773 6.44217 34.3601 5.70104C33.543 4.9599 32.1938 4.59884 30.3504 4.59884C29.5632 4.58952 28.778 4.6789 28.013 4.86488C27.4215 5.00848 26.8525 5.23226 26.3217 5.53C25.9146 5.75126 25.5585 6.05554 25.2765 6.42317C25.0541 6.69108 24.9271 7.02533 24.9154 7.37334C24.9107 7.58041 24.9507 7.78607 25.0327 7.97628C25.1147 8.16649 25.2367 8.33678 25.3905 8.47554C25.5277 8.61969 25.6928 8.73445 25.8758 8.81285C26.0587 8.89125 26.2557 8.93166 26.4547 8.93162C26.7098 8.93474 26.9626 8.88289 27.1958 8.7796C27.3859 8.68458 27.5759 8.55155 27.7849 8.41853C28.0173 8.26051 28.2577 8.11462 28.5052 7.98145C28.6957 7.87485 28.8924 7.77966 29.0943 7.6964C29.2849 7.62574 29.4823 7.5748 29.6834 7.54437C29.9036 7.51226 30.1261 7.49954 30.3485 7.50636C30.6656 7.49926 30.9813 7.5508 31.2797 7.65839C31.5028 7.73643 31.7001 7.87452 31.8498 8.05746C31.9819 8.2266 32.0788 8.42043 32.1348 8.62757C32.1956 8.84413 32.2276 9.06777 32.2299 9.29269V9.59674C31.5837 9.63475 30.9756 9.69176 30.3865 9.74877C29.7974 9.80578 29.1703 9.9008 28.5622 10.0148C28.0208 10.1074 27.4872 10.2408 26.9659 10.4139C26.4728 10.5721 26.0147 10.8238 25.6166 11.155C25.2323 11.4708 24.921 11.8664 24.7045 12.3142C24.4634 12.838 24.3463 13.4102 24.3624 13.9865C24.3624 15.1077 24.7425 16.0199 25.4836 16.704C26.2248 17.3502 27.2528 17.6922 28.5261 17.6922ZM28.07 12.8843C28.279 12.6183 28.7351 12.4093 29.4573 12.2572C29.7233 12.2002 30.1224 12.1242 30.6545 12.0482C31.1486 11.9722 31.6617 11.9152 32.1938 11.8582V12.5613C32.2023 12.8693 32.1399 13.1752 32.0113 13.4553C31.8828 13.7353 31.6917 13.9821 31.4526 14.1766C30.9395 14.5947 30.2174 14.8227 29.2862 14.8227C28.7161 14.8227 28.317 14.7277 28.089 14.5186C27.9767 14.4118 27.8895 14.2814 27.8337 14.1368C27.7778 13.9922 27.7547 13.8371 27.7659 13.6825C27.7616 13.536 27.7862 13.3901 27.8384 13.2531C27.8906 13.1161 27.9693 12.9908 28.07 12.8843V12.8843Z" fill="#FF5301"/>
4
+ <path d="M40.4603 5.16893C40.0967 4.90678 39.6533 4.77914 39.206 4.80787C38.5789 4.80787 38.1038 4.9599 37.7998 5.24495C37.6491 5.40411 37.5325 5.59244 37.4574 5.79834C37.3822 6.00424 37.35 6.22334 37.3627 6.44217V16.1339C37.3627 16.78 37.6857 17.5592 39.187 17.5592C39.6368 17.5814 40.0822 17.4617 40.4603 17.2171C40.7833 16.9891 40.9543 16.609 40.9543 16.0769V6.29014C40.9591 6.07848 40.9173 5.86836 40.8319 5.67463C40.7465 5.48089 40.6197 5.30826 40.4603 5.16893Z" fill="#FF5301"/>
5
+ <path d="M37.7428 3.28758C38.1389 3.64027 38.6571 3.82437 39.187 3.80067C39.7164 3.82118 40.2335 3.63749 40.6313 3.28758C40.8147 3.10749 40.9585 2.89106 41.0534 2.65217C41.1483 2.41328 41.1922 2.15719 41.1824 1.90033C41.1824 1.25421 40.9733 0.779124 40.5363 0.456065C40.1487 0.160206 39.6746 -4.72755e-05 39.187 -1.79269e-05C38.6553 -0.0139559 38.1384 0.176473 37.7428 0.532079V0.532079C37.5643 0.707908 37.4234 0.918174 37.3287 1.15011C37.2339 1.38205 37.1873 1.63082 37.1917 1.88132C37.1801 2.14123 37.2232 2.40067 37.3181 2.64289C37.413 2.88512 37.5577 3.10474 37.7428 3.28758V3.28758Z" fill="#FF5301"/>
6
+ <path d="M44.546 17.5782C44.9958 17.6004 45.4412 17.4807 45.8193 17.2361C46.1423 17.0081 46.3134 16.628 46.3134 16.0959V1.97634C46.3292 1.76003 46.2864 1.54345 46.1894 1.34946C46.0924 1.15546 45.9448 0.991247 45.7623 0.874144C45.4071 0.659208 44.9991 0.547349 44.584 0.551086C43.0638 0.551086 42.7407 1.36823 42.7407 2.07136V16.1339C42.7217 16.799 43.0448 17.5782 44.546 17.5782Z" fill="#FF5301"/>
7
+ <path d="M50.304 17.5782C50.9882 17.5782 51.4443 17.4261 51.6913 17.1221C51.9218 16.8232 52.0426 16.4542 52.0334 16.0769V11.459H54.6938C55.8911 11.459 56.8792 11.288 57.6584 10.946C58.3643 10.6543 58.9946 10.2059 59.5017 9.63472C59.9315 9.13105 60.249 8.54149 60.4329 7.9054C60.5976 7.31778 60.6807 6.71032 60.6799 6.10007C60.6799 4.38976 60.1858 3.05952 59.2167 2.12835C58.2475 1.19718 56.6892 0.722093 54.5798 0.722093H49.924C49.555 0.709357 49.1929 0.82337 48.8978 1.04515C48.7589 1.15579 48.6485 1.29803 48.5758 1.46002C48.5031 1.622 48.4701 1.79902 48.4797 1.97632V16.0199C48.4797 16.742 48.8028 17.5782 50.304 17.5782ZM52.0334 3.74364H54.2948C54.741 3.73241 55.1854 3.80326 55.606 3.95268C55.9162 4.06373 56.1961 4.24597 56.4232 4.48478C56.6223 4.70343 56.7715 4.96281 56.8602 5.24492C56.9535 5.53979 56.9985 5.84784 56.9933 6.15708C56.9984 6.47255 56.9535 6.78685 56.8602 7.08825C56.7705 7.35868 56.6212 7.60548 56.4232 7.81038C56.1921 8.03108 55.9121 8.19389 55.606 8.28547C55.1819 8.4184 54.7392 8.48255 54.2948 8.4755H52.0334V3.74364Z" fill="#FF5301"/>
8
+ <path d="M62.5613 16.0009C63.1369 16.5884 63.8297 17.0481 64.5947 17.3501C65.4506 17.6709 66.3582 17.8319 67.2723 17.8252C68.1683 17.8306 69.0575 17.6695 69.8947 17.3501C70.6548 17.0387 71.3458 16.5802 71.9281 16.0009C72.5115 15.4 72.9587 14.6806 73.2393 13.8915C73.5538 13.014 73.7083 12.0871 73.6954 11.155C73.7067 10.2416 73.5522 9.33374 73.2393 8.47551C72.9583 7.69781 72.5108 6.99088 71.9281 6.40413C71.356 5.83066 70.6697 5.38392 69.9137 5.0929C69.077 4.77186 68.1874 4.6107 67.2913 4.61781C66.3944 4.60306 65.5034 4.76448 64.6688 5.0929C63.9003 5.39019 63.2016 5.84307 62.6164 6.42314C62.0275 7.0159 61.5737 7.72898 61.2862 8.51352C60.9652 9.38329 60.8043 10.3039 60.8111 11.231C60.8032 12.155 60.951 13.0736 61.2482 13.9485C61.5627 14.7041 62.0071 15.3987 62.5613 16.0009V16.0009ZM65.2408 8.55153C65.7349 7.92441 66.419 7.62036 67.2932 7.62036C68.2053 7.62036 68.9085 7.92441 69.4025 8.55153C69.8966 9.17864 70.1437 10.0718 70.1437 11.193C70.1437 12.3142 69.8966 13.2264 69.3835 13.8345C68.8704 14.4426 68.2053 14.7467 67.2932 14.7467C66.9039 14.7634 66.516 14.6897 66.1599 14.5315C65.8038 14.3732 65.4892 14.1347 65.2408 13.8345C64.7467 13.2264 64.4807 12.3332 64.4807 11.193C64.4807 10.0528 64.7277 9.17864 65.2408 8.55153Z" fill="#FF5301"/>
9
+ <path d="M76.6618 16.229C77.2552 16.7764 77.9627 17.1853 78.7332 17.4262C79.6087 17.6866 80.5183 17.8147 81.4317 17.8062C82.1359 17.8074 82.8376 17.7245 83.5221 17.5592C84.1733 17.4157 84.7962 17.1653 85.3654 16.8181C85.6902 16.6367 85.9798 16.3985 86.2206 16.1149C86.4094 15.8776 86.5102 15.5821 86.5056 15.2788C86.5019 14.8528 86.347 14.442 86.0686 14.1196C85.7645 13.7775 85.4414 13.5875 85.0804 13.5875C84.7944 13.5843 84.5126 13.6564 84.2632 13.7965C84.0542 13.9295 83.8451 14.0436 83.6171 14.1766C83.3891 14.3096 83.066 14.4426 82.7239 14.6137C82.3397 14.7765 81.9248 14.8543 81.5077 14.8417C79.7024 14.8417 78.7332 13.9866 78.5242 12.2382H85.1944C85.6308 12.2613 86.065 12.1626 86.4486 11.9532C86.7717 11.7441 86.9237 11.3831 86.9237 10.889C86.9237 8.87462 86.3916 7.29733 85.3654 6.21414C84.3392 5.13094 82.914 4.57984 81.1657 4.57984C80.1888 4.55326 79.2193 4.75498 78.3341 5.16895C77.5708 5.52285 76.8957 6.04215 76.3578 6.68922C75.8381 7.3288 75.4506 8.06516 75.2176 8.85562C74.9729 9.66259 74.8512 10.5018 74.8565 11.3451C74.8347 12.3212 74.9892 13.2933 75.3126 14.2146C75.6312 14.9652 76.089 15.6487 76.6618 16.229V16.229ZM79.4743 7.98146C79.9475 7.60087 80.5396 7.39903 81.1467 7.41135C81.4977 7.40852 81.8461 7.47303 82.1728 7.60139C82.4418 7.71867 82.6771 7.90163 82.857 8.13349C83.0351 8.34955 83.1764 8.59354 83.275 8.85562C83.3466 9.06449 83.3913 9.2816 83.4081 9.50173H78.6952C78.76 8.91667 79.0373 8.37573 79.4743 7.98146V7.98146Z" fill="#FF5301"/>
10
+ <path d="M91.7126 17.8062C92.3012 17.8184 92.8888 17.7545 93.461 17.6162V17.6162C93.898 17.5235 94.3158 17.3564 94.6962 17.1221C94.9238 16.9919 95.1036 16.792 95.2093 16.552C95.3059 16.3173 95.3513 16.0646 95.3423 15.8109C95.3449 15.4309 95.2465 15.0571 95.0572 14.7277C94.9591 14.5496 94.8122 14.4032 94.6338 14.3056C94.4555 14.208 94.253 14.1632 94.0501 14.1766C93.8788 14.1759 93.7096 14.2149 93.556 14.2906L93.1949 14.4616C93.0588 14.5039 92.9256 14.5547 92.7958 14.6137C92.6577 14.6714 92.5083 14.6973 92.3588 14.6897C92.2659 14.7003 92.1719 14.6905 92.0833 14.661C91.9946 14.6314 91.9135 14.5828 91.8457 14.5186C91.7316 14.4046 91.6746 14.1766 91.6746 13.8535V7.6964H93.442C93.917 7.6964 94.4681 7.44935 94.4681 6.29014C94.4711 5.97997 94.3994 5.67363 94.2591 5.39698C94.1813 5.25706 94.0643 5.14294 93.9225 5.06866C93.7807 4.99438 93.6203 4.96318 93.461 4.9789H91.6746V2.39443C91.6856 2.09016 91.5841 1.79251 91.3896 1.55828C91.1995 1.33024 90.8575 1.21622 90.4204 1.21622C90.1644 1.22084 89.9096 1.2527 89.6603 1.31123C89.4084 1.36811 89.165 1.45755 88.9362 1.57728C88.7124 1.70654 88.5182 1.88134 88.3661 2.09038C88.2114 2.32737 88.1319 2.60557 88.1381 2.88852V14.2146C88.1381 15.4308 88.4611 16.343 89.1073 16.9321C89.7534 17.5212 90.6465 17.8062 91.7126 17.8062Z" fill="#FF5301"/>
11
+ <path d="M99.447 22.8041L98.9909 22.4431C98.7329 22.2437 98.4135 22.1403 98.0875 22.1507C97.7616 22.1611 97.4494 22.2847 97.2046 22.5001C96.5442 23.0558 95.7112 23.3648 94.8482 23.3742H55.606C54.6776 23.3732 53.7581 23.5557 52.9004 23.9112C52.0427 24.2666 51.2636 24.7881 50.6081 25.4456L50.3991 25.6547L50.19 25.4456C48.864 24.1207 47.0666 23.3757 45.1921 23.3742H5.13094C4.26788 23.3648 3.4349 23.0558 2.77451 22.5001C2.53159 22.2809 2.21883 22.1548 1.89179 22.1444C1.56475 22.134 1.24459 22.2398 0.988188 22.4431L0.534005 22.8041C0.375248 22.9299 0.245396 23.0883 0.153258 23.2686C0.061121 23.449 0.00885529 23.647 7.84219e-06 23.8493C-0.0100393 24.0525 0.0257342 24.2554 0.104681 24.4429C0.183628 24.6304 0.303727 24.7977 0.456091 24.9325C1.74239 26.0838 3.40475 26.7257 5.13094 26.7379H45.1712C45.987 26.7374 46.7804 27.005 47.4293 27.4994C48.0782 27.9938 48.5468 28.6877 48.7629 29.4744V29.5124C48.7819 29.6454 48.9719 30.3485 50.3782 30.3485C51.7844 30.3485 51.9745 29.6454 51.9935 29.5124V29.4744C52.2096 28.6877 52.6781 27.9938 53.3271 27.4994C53.976 27.005 54.7693 26.7374 55.5851 26.7379H94.8653C96.5915 26.7257 98.2538 26.0838 99.5401 24.9325C99.6896 24.7954 99.8077 24.6276 99.8864 24.4407C99.9651 24.2538 100.003 24.0521 99.9962 23.8493C99.978 23.6475 99.92 23.4513 99.8258 23.272C99.7316 23.0926 99.6028 22.9336 99.447 22.8041V22.8041Z" fill="#FF5301"/>
12
+ </svg>
includes/class-wcpdf-main.php CHANGED
@@ -56,16 +56,14 @@ class Main {
56
  // apply header logo height
57
  add_action( 'wpo_wcpdf_custom_styles', array( $this, 'set_header_logo_height' ), 9, 2 );
58
 
59
- // show notices of missing required directories
60
- if( get_option( 'wpo_wcpdf_no_dir_error' ) ) {
61
- // if all folders exist and are writable delete the option
62
- if( $this->tmp_folders_exist_and_writable() ) {
63
- delete_option( 'wpo_wcpdf_no_dir_error' );
64
- // if not, show notice
65
- } else {
66
- add_action( 'admin_notices', array( $this, 'no_dir_notice' ), 1 );
67
- }
68
- }
69
  }
70
 
71
  /**
@@ -286,13 +284,15 @@ class Main {
286
  $document_type = sanitize_text_field( $_GET['document_type'] );
287
 
288
  $order_ids = (array) array_map( 'absint', explode( 'x', $_GET['order_ids'] ) );
289
- // Process oldest first: reverse $order_ids array
290
- $order_ids = array_reverse( $order_ids );
 
 
 
291
 
292
  // set default is allowed
293
  $allowed = true;
294
 
295
-
296
  if ( $guest_access && isset( $_GET['order_key'] ) ) {
297
  // Guest access with order key
298
  if ( count( $order_ids ) > 1 ) {
@@ -560,23 +560,30 @@ class Main {
560
  }
561
 
562
  public function no_dir_notice() {
563
- $path = get_option( 'wpo_wcpdf_no_dir_error' );
564
- if ( $path ) {
565
- ob_start();
566
- ?>
567
- <div class="error">
568
- <p><?php printf( __( "The %s directory %s couldn't be created or is not writable!", 'woocommerce-pdf-invoices-packing-slips' ), '<strong>WooCommerce PDF Invoices & Packing Slips</strong>' ,'<code>' . $path . '</code>' ); ?></p>
569
- <p><?php _e( 'Please check your directories write permissions or contact your hosting service provider.', 'woocommerce-pdf-invoices-packing-slips' ); ?></p>
570
- <p><a href="<?php echo esc_url( add_query_arg( 'wpo_wcpdf_hide_no_dir_notice', 'true' ) ); ?>"><?php _e( 'Hide this message', 'woocommerce-pdf-invoices-packing-slips' ); ?></a></p>
571
- </div>
572
- <?php
573
- echo ob_get_clean();
574
-
575
- // save option to hide notice
576
- if ( isset( $_GET['wpo_wcpdf_hide_no_dir_notice'] ) ) {
577
- delete_option( 'wpo_wcpdf_no_dir_error', true );
578
- wp_redirect( 'admin.php?page=wpo_wcpdf_options_page' );
579
- exit;
 
 
 
 
 
 
 
580
  }
581
  }
582
  }
@@ -912,6 +919,35 @@ class Main {
912
  ini_set( 'display_errors', 1 );
913
  }
914
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
915
  }
916
 
917
  endif; // class_exists
56
  // apply header logo height
57
  add_action( 'wpo_wcpdf_custom_styles', array( $this, 'set_header_logo_height' ), 9, 2 );
58
 
59
+ // show notice of missing required directories
60
+ add_action( 'admin_notices', array( $this, 'no_dir_notice' ), 1 );
61
+
62
+ // add custom webhook topics for documents
63
+ add_filter( 'woocommerce_webhook_topic_hooks', array( $this, 'wc_webhook_topic_hooks' ), 10, 2 );
64
+ add_filter( 'woocommerce_valid_webhook_events', array( $this, 'wc_webhook_topic_events' ) );
65
+ add_filter( 'woocommerce_webhook_topics', array( $this, 'wc_webhook_topics' ) );
66
+ add_action( 'wpo_wcpdf_save_document', array( $this, 'wc_webhook_trigger' ), 10, 2 );
 
 
67
  }
68
 
69
  /**
284
  $document_type = sanitize_text_field( $_GET['document_type'] );
285
 
286
  $order_ids = (array) array_map( 'absint', explode( 'x', $_GET['order_ids'] ) );
287
+
288
+ // Process oldest first: reverse $order_ids array if required
289
+ if ( count( $order_ids ) > 1 && end( $order_ids ) < reset( $order_ids ) ) {
290
+ $order_ids = array_reverse( $order_ids );
291
+ }
292
 
293
  // set default is allowed
294
  $allowed = true;
295
 
 
296
  if ( $guest_access && isset( $_GET['order_key'] ) ) {
297
  // Guest access with order key
298
  if ( count( $order_ids ) > 1 ) {
560
  }
561
 
562
  public function no_dir_notice() {
563
+ if( is_admin() && ( $path = get_option( 'wpo_wcpdf_no_dir_error' ) ) ) {
564
+ // if all folders exist and are writable delete the option
565
+ if( $this->tmp_folders_exist_and_writable() ) {
566
+ delete_option( 'wpo_wcpdf_no_dir_error' );
567
+ // if not, show notice
568
+ } else {
569
+ if ( $path ) {
570
+ ob_start();
571
+ ?>
572
+ <div class="error">
573
+ <p><?php printf( __( "The %s directory %s couldn't be created or is not writable!", 'woocommerce-pdf-invoices-packing-slips' ), '<strong>WooCommerce PDF Invoices & Packing Slips</strong>' ,'<code>' . $path . '</code>' ); ?></p>
574
+ <p><?php _e( 'Please check your directories write permissions or contact your hosting service provider.', 'woocommerce-pdf-invoices-packing-slips' ); ?></p>
575
+ <p><a href="<?php echo esc_url( add_query_arg( 'wpo_wcpdf_hide_no_dir_notice', 'true' ) ); ?>"><?php _e( 'Hide this message', 'woocommerce-pdf-invoices-packing-slips' ); ?></a></p>
576
+ </div>
577
+ <?php
578
+ echo ob_get_clean();
579
+
580
+ // save option to hide notice
581
+ if ( isset( $_GET['wpo_wcpdf_hide_no_dir_notice'] ) ) {
582
+ delete_option( 'wpo_wcpdf_no_dir_error', true );
583
+ wp_redirect( 'admin.php?page=wpo_wcpdf_options_page' );
584
+ exit;
585
+ }
586
+ }
587
  }
588
  }
589
  }
919
  ini_set( 'display_errors', 1 );
920
  }
921
 
922
+ public function wc_webhook_topic_hooks( $topic_hooks, $wc_webhook ) {
923
+ $documents = WPO_WCPDF()->documents->get_documents();
924
+ foreach ($documents as $document) {
925
+ $topic_hooks["order.{$document->type}-saved"] = array(
926
+ "wpo_wcpdf_webhook_order_{$document->slug}_saved",
927
+ );
928
+ }
929
+ return $topic_hooks;
930
+ }
931
+
932
+ public function wc_webhook_topic_events( $topic_events ) {
933
+ $documents = WPO_WCPDF()->documents->get_documents();
934
+ foreach ($documents as $document) {
935
+ $topic_events[] = "{$document->type}-saved";
936
+ }
937
+ return $topic_events;
938
+ }
939
+
940
+ public function wc_webhook_topics( $topics ) {
941
+ $documents = WPO_WCPDF()->documents->get_documents();
942
+ foreach ($documents as $document) {
943
+ $topics["order.{$document->type}-saved"] = sprintf( __( 'Order %s Saved', 'woocommerce-pdf-invoices-packing-slips' ), $document->get_title() );
944
+ }
945
+ return $topics;
946
+ }
947
+
948
+ public function wc_webhook_trigger( $document, $order ) {
949
+ do_action( "wpo_wcpdf_webhook_order_{$document->slug}_saved", $order->get_id() );
950
+ }
951
  }
952
 
953
  endif; // class_exists
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: woocommerce, pdf, invoices, packing slips, print, delivery notes, invoice,
5
  Requires at least: 3.5
6
  Tested up to: 5.6
7
  Requires PHP: 5.3
8
- Stable tag: 2.7.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -102,6 +102,12 @@ There's a setting on the Status tab of the settings page that allows you to togg
102
 
103
  == Changelog ==
104
 
 
 
 
 
 
 
105
  = 2.7.3 =
106
  * New: Support for line breaks in invoice notes
107
  * Fix: Only pass opened edit fields when regenerating document
5
  Requires at least: 3.5
6
  Tested up to: 5.6
7
  Requires PHP: 5.3
8
+ Stable tag: 2.7.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
102
 
103
  == Changelog ==
104
 
105
+ = 2.7.4 =
106
+ * New: Show notice if incompatible MailPoet mailing service is used
107
+ * New: WooCommerce webhook topic for document saves
108
+ * Fix: Don't reverse order of bulk document if already sorted oldest to newest
109
+ * Marked tested up to WooCommerce 4.9
110
+
111
  = 2.7.3 =
112
  * New: Support for line breaks in invoice notes
113
  * Fix: Only pass opened edit fields when regenerating document
woocommerce-pdf-invoices-packingslips.php CHANGED
@@ -3,14 +3,14 @@
3
  * Plugin Name: WooCommerce PDF Invoices & Packing Slips
4
  * Plugin URI: http://www.wpovernight.com
5
  * Description: Create, print & email PDF invoices & packing slips for WooCommerce orders.
6
- * Version: 2.7.3
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
10
  * License URI: http://www.opensource.org/licenses/gpl-license.php
11
  * Text Domain: woocommerce-pdf-invoices-packing-slips
12
  * WC requires at least: 2.2.0
13
- * WC tested up to: 4.8.0
14
  */
15
 
16
  if ( ! defined( 'ABSPATH' ) ) {
@@ -21,7 +21,7 @@ if ( !class_exists( 'WPO_WCPDF' ) ) :
21
 
22
  class WPO_WCPDF {
23
 
24
- public $version = '2.7.3';
25
  public $plugin_basename;
26
  public $legacy_mode;
27
  public $legacy_textdomain;
@@ -53,6 +53,7 @@ class WPO_WCPDF {
53
  add_action( 'plugins_loaded', array( $this, 'load_classes' ), 9 );
54
  add_action( 'in_plugin_update_message-'.$this->plugin_basename, array( $this, 'in_plugin_update_message' ) );
55
  add_action( 'admin_notices', array( $this, 'nginx_detected' ) );
 
56
 
57
  // legacy textdomain fallback
58
  if ( $this->legacy_textdomain_enabled() === true ) {
@@ -384,6 +385,39 @@ class WPO_WCPDF {
384
  }
385
  }
386
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  /**
388
  * Get the plugin url.
389
  * @return string
3
  * Plugin Name: WooCommerce PDF Invoices & Packing Slips
4
  * Plugin URI: http://www.wpovernight.com
5
  * Description: Create, print & email PDF invoices & packing slips for WooCommerce orders.
6
+ * Version: 2.7.4
7
  * Author: Ewout Fernhout
8
  * Author URI: http://www.wpovernight.com
9
  * License: GPLv2 or later
10
  * License URI: http://www.opensource.org/licenses/gpl-license.php
11
  * Text Domain: woocommerce-pdf-invoices-packing-slips
12
  * WC requires at least: 2.2.0
13
+ * WC tested up to: 4.9.0
14
  */
15
 
16
  if ( ! defined( 'ABSPATH' ) ) {
21
 
22
  class WPO_WCPDF {
23
 
24
+ public $version = '2.7.4';
25
  public $plugin_basename;
26
  public $legacy_mode;
27
  public $legacy_textdomain;
53
  add_action( 'plugins_loaded', array( $this, 'load_classes' ), 9 );
54
  add_action( 'in_plugin_update_message-'.$this->plugin_basename, array( $this, 'in_plugin_update_message' ) );
55
  add_action( 'admin_notices', array( $this, 'nginx_detected' ) );
56
+ add_action( 'admin_notices', array( $this, 'mailpoet_mta_detected' ) );
57
 
58
  // legacy textdomain fallback
59
  if ( $this->legacy_textdomain_enabled() === true ) {
385
  }
386
  }
387
 
388
+ /**
389
+ * Detect MailPoet.
390
+ * @return void
391
+ */
392
+ public function mailpoet_mta_detected() {
393
+ if( is_callable( array( '\\MailPoet\\Settings\\SettingsController', 'getInstance' ) ) ) {
394
+ $settings = \MailPoet\Settings\SettingsController::getInstance();
395
+ if( empty($settings) ) return;
396
+ $mta = $settings->get('mta');
397
+
398
+ if( ! empty($mta) && ! empty($mta['method']) && $mta['method'] == 'MailPoet' && ! get_option('wpo_wcpdf_hide_mailpoet_notice') ) {
399
+ ob_start();
400
+ ?>
401
+ <div class="error">
402
+ <img src="<?php echo $this->plugin_url() . "/assets/images/mailpoet.svg"; ?>" style="margin-top:10px;">
403
+ <p><?php printf( __( 'When sending emails with MailPoet 3 and the active sending method is MailPoet Sending Service, MailPoet does not include the %s attachments in the emails.', 'woocommerce-pdf-invoices-packing-slips' ), '<strong>WooCommerce PDF Invoices & Packing Slips</strong>' ); ?></p>
404
+ <p><?php printf( __( 'To fix this you should select other method like %s or %s.', 'woocommerce-pdf-invoices-packing-slips' ), '<strong>'.__('Your web host / web server', 'woocommerce-pdf-invoices-packing-slips').'</strong>', '<strong>SMTP</strong>' ); ?></p>
405
+ <p><a class="button" href="<?php echo esc_url( admin_url( 'admin.php?page=mailpoet-settings#/mta' ) ); ?>"><?php _e( 'Change MailPoet sending method', 'woocommerce-pdf-invoices-packing-slips' ); ?></a></p>
406
+ <p><a href="<?php echo esc_url( add_query_arg( 'wpo_wcpdf_hide_mailpoet_notice', 'true' ) ); ?>"><?php _e( 'Hide this message', 'woocommerce-pdf-invoices-packing-slips' ); ?></a></p>
407
+ </div>
408
+ <?php
409
+ echo ob_get_clean();
410
+ }
411
+ }
412
+
413
+ // save option to hide mailpoet notice
414
+ if ( isset( $_GET['wpo_wcpdf_hide_mailpoet_notice'] ) ) {
415
+ update_option( 'wpo_wcpdf_hide_mailpoet_notice', true );
416
+ wp_redirect( 'admin.php?page=wpo_wcpdf_options_page' );
417
+ exit;
418
+ }
419
+ }
420
+
421
  /**
422
  * Get the plugin url.
423
  * @return string