Custom Product Tabs for WooCommerce - Version 1.5.7

Version Description

  • February 27th, 2017 =
  • Duplicating a product now duplicates the corresponding saved tabs correctly
  • Added two filters (yikes_woo_use_the_content_filter and yikes_woo_filter_main_tab_content) to help provide a work-around to using the standard the_content filter which has caused numerous issues due to plugin conflicts.
Download this release

Release Info

Developer yikesitskevin
Plugin Icon 128x128 Custom Product Tabs for WooCommerce
Version 1.5.7
Comparing to
See all releases

Code changes from version 1.5.6 to 1.5.7

readme.txt CHANGED
@@ -6,7 +6,7 @@ Requires at least: 3.8
6
  Tested up to: 4.7.2
7
  Requires WooCommerce at least: 2.0
8
  Tested WooCommerce up to: 2.6.9
9
- Stable tag: 1.5.6
10
  License: GPLv2 or later
11
 
12
  Add custom tabs with content to products in WooCommerce.
@@ -74,6 +74,10 @@ Yes! Since v1.4 we've added the necessary code to ensure the custom tab data is
74
 
75
  == Changelog ==
76
 
 
 
 
 
77
  = 1.5.6 - February 16th, 2017 =
78
  * Fixed an issue where the "Add a Saved Tab" modal was displaying YouTube videos if a saved tab had a YouTube URL in its content
79
 
6
  Tested up to: 4.7.2
7
  Requires WooCommerce at least: 2.0
8
  Tested WooCommerce up to: 2.6.9
9
+ Stable tag: 1.5.7
10
  License: GPLv2 or later
11
 
12
  Add custom tabs with content to products in WooCommerce.
74
 
75
  == Changelog ==
76
 
77
+ = 1.5.7 - February 27th, 2017 =
78
+ * Duplicating a product now duplicates the corresponding saved tabs correctly
79
+ * Added two filters (`yikes_woo_use_the_content_filter` and `yikes_woo_filter_main_tab_content`) to help provide a work-around to using the standard `the_content` filter which has caused numerous issues due to plugin conflicts.
80
+
81
  = 1.5.6 - February 16th, 2017 =
82
  * Fixed an issue where the "Add a Saved Tab" modal was displaying YouTube videos if a saved tab had a YouTube URL in its content
83
 
yikes-inc-easy-custom-woocommerce-product-tabs.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Extend WooCommerce to add and manage custom product tabs. Create as many product tabs as needed per product.
6
  * Author: YIKES, Inc
7
  * Author URI: http://www.yikesinc.com
8
- * Version: 1.5.6
9
  * Text Domain: yikes-inc-easy-custom-woocommerce-product-tabs
10
  * Domain Path: languages/
11
  *
@@ -62,7 +62,7 @@
62
  private $tab_data = false;
63
 
64
  /** plugin version number */
65
- const VERSION = '1.5.6';
66
 
67
  /** plugin text domain */
68
  const TEXT_DOMAIN = 'yikes-inc-easy-custom-woocommerce-product-tabs';
@@ -177,6 +177,9 @@
177
 
178
  // Add settings link to plugin on plugins page
179
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'add_plugin_action_links' ), 10, 1 );
 
 
 
180
  }
181
 
182
  /**
@@ -314,10 +317,18 @@
314
  **/
315
  public function custom_product_tabs_panel_content( $key, $tab ) {
316
 
 
 
317
  // Hardcoding Site Origin Page Builder conflict fix - remove their the_content filter
318
  remove_filter( 'the_content', 'siteorigin_panels_filter_content' );
319
 
320
- $content = apply_filters( 'the_content', $tab['content'] );
 
 
 
 
 
 
321
 
322
  // Hardcoding Site Origin Page Builder conflict fix - re-add their the_content filter
323
  if ( function_exists( 'siteorigin_panels_filter_content' ) ) add_filter( 'the_content', 'siteorigin_panels_filter_content' );
@@ -1152,5 +1163,38 @@
1152
  }
1153
  }
1154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1155
  /* End Misc. */
1156
  }
5
  * Description: Extend WooCommerce to add and manage custom product tabs. Create as many product tabs as needed per product.
6
  * Author: YIKES, Inc
7
  * Author URI: http://www.yikesinc.com
8
+ * Version: 1.5.7
9
  * Text Domain: yikes-inc-easy-custom-woocommerce-product-tabs
10
  * Domain Path: languages/
11
  *
62
  private $tab_data = false;
63
 
64
  /** plugin version number */
65
+ const VERSION = '1.5.7';
66
 
67
  /** plugin text domain */
68
  const TEXT_DOMAIN = 'yikes-inc-easy-custom-woocommerce-product-tabs';
177
 
178
  // Add settings link to plugin on plugins page
179
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'add_plugin_action_links' ), 10, 1 );
180
+
181
+ // Duplicate any saved tabs when a product is duplicated
182
+ add_filter( 'woocommerce_duplicate_product', array( $this, 'yikes_woo_dupe_saved_tabs_on_product_dupe' ), 10, 2 );
183
  }
184
 
185
  /**
317
  **/
318
  public function custom_product_tabs_panel_content( $key, $tab ) {
319
 
320
+ $content = '';
321
+
322
  // Hardcoding Site Origin Page Builder conflict fix - remove their the_content filter
323
  remove_filter( 'the_content', 'siteorigin_panels_filter_content' );
324
 
325
+ $use_the_content_filter = apply_filters( 'yikes_woo_use_the_content_filter', true );
326
+
327
+ if ( $use_the_content_filter === true ) {
328
+ $content = apply_filters( 'the_content', $tab['content'] );
329
+ } else {
330
+ $content = apply_filters( 'yikes_woo_filter_main_tab_content', $tab['content'] );
331
+ }
332
 
333
  // Hardcoding Site Origin Page Builder conflict fix - re-add their the_content filter
334
  if ( function_exists( 'siteorigin_panels_filter_content' ) ) add_filter( 'the_content', 'siteorigin_panels_filter_content' );
1163
  }
1164
  }
1165
 
1166
+ /**
1167
+ * When a WooCommere product is duplicated, check for and duplicate the saved tabs.
1168
+ *
1169
+ * @param int | $post_id | The new post's ID
1170
+ * @param object | $old_post| The old post's post object (the one that was used to duplicate - not the new, duplicated one)
1171
+ */
1172
+ public function yikes_woo_dupe_saved_tabs_on_product_dupe( $post_id, $old_post ) {
1173
+
1174
+ // First, let's grab our applied saved tab options array
1175
+ $saved_tabs_array = get_option( 'yikes_woo_reusable_products_tabs_applied' );
1176
+
1177
+ // Grab the old post's ID
1178
+ $old_post_id = isset( $old_post->ID ) ? $old_post->ID : '';
1179
+
1180
+ // (1) Make sure we have a non-empty array of saved tabs,
1181
+ // (2) Makre sure we have the ID of the old post, and then
1182
+ // (3) Check for the old post's saved tabs. (If we don't find any, do nothing)
1183
+ if ( ! empty( $saved_tabs_array ) && is_array( $saved_tabs_array ) && ! empty( $old_post_id ) && isset( $saved_tabs_array[$old_post_id] ) ) {
1184
+
1185
+ // Loop through the $saved_tabs_array and update the post_id item
1186
+ $new_products_saved_tabs = $saved_tabs_array[$old_post_id];
1187
+ foreach ( $new_products_saved_tabs as $saved_tab_id => $saved_tab ) {
1188
+ $new_products_saved_tabs[$saved_tab_id]['post_id'] = $post_id;
1189
+ }
1190
+
1191
+ // Add the old post's saved tabs, with the new post's ID as the key
1192
+ $saved_tabs_array[$post_id] = $new_products_saved_tabs;
1193
+
1194
+ // Update the saved tab's option
1195
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $saved_tabs_array );
1196
+ }
1197
+ }
1198
+
1199
  /* End Misc. */
1200
  }