Changeset 3022582
- Timestamp:
- 01/16/2024 06:21:48 PM (6 months ago)
- Location:
- woocommerce-product-tabs
- Files:
-
- 12 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-product-tabs/tags/2.1.0.1/readme.txt
r3019157 r3022582 1 1 === WooCommerce Product Tabs === 2 2 3 Contributors: barn2media 3 Contributors: barn2media 4 4 Tags: tabs, custom tabs, product tabs, woocommerce product tab, product custom tabs, multiple product tabs, woocommerce custom tabs, woocommerce product custom tabs, multiple product tabs, woocommerce tabs, tabs for woocommerce, product tab, woocommerce, product, woocommerce product tabs, custom tab, woo product custom tabs, change tab, product page tabs, woocommerce custom tab, woocommerce tab, tabs plugin, woocommerce tabs plugin 5 5 Requires PHP: 7.4 6 6 Requires at least: 6.0 7 7 Tested up to: 6.4.2 8 Stable tag: 2.1.0 8 Stable tag: 2.1.0 9 9 License: GNU General Public License v3.0 10 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html 11 11 Donate link: https://barn2.com 12 12 13 Discover the easy way to add extra tabs to your WooCommerce product pages. 13 Discover the easy way to add extra tabs to your WooCommerce product pages. 14 14 15 15 == Description == … … 17 17 WooCommerce Product Tabs lets you add an unlimited number of extra tabs to any or all of your product pages. 18 18 19 Each tab has a WYSIWYG editor which you can use to add absolutely any type of information to the product page. You can add HTML code, shortcodes, images, videos, audio embeds - the possibilities are endless! 20 21 Adding extra tabs to product pages is an excellent way to provide more information to customers without adding clutter or affecting the layout. Here are some examples of popular uses for WooCommerce product tabs: 22 23 - **Extra product information** - Add a product specifications tab, downloads tab, FAQ tab, ingredients or materials tab, size guide, assembly/usage instructions, unboxing videos, demos, and 3D models. 24 - **Reassure customers** - Create WooCommerce product page tabs to showcase your certifications, warranty information, 19 Each tab has a WYSIWYG editor which you can use to add absolutely any type of information to the product page. You can add HTML code, shortcodes, images, videos, audio embeds - the possibilities are endless! 20 21 Adding extra tabs to product pages is an excellent way to provide more information to customers without adding clutter or affecting the layout. Here are some examples of popular uses for WooCommerce product tabs: 22 23 - **Extra product information** - Add a product specifications tab, downloads tab, FAQ tab, ingredients or materials tab, size guide, assembly/usage instructions, unboxing videos, demos, and 3D models. 24 - **Reassure customers** - Create WooCommerce product page tabs to showcase your certifications, warranty information, 25 25 - **Add social proof to the WooCommerce product page** - Add customers testimonials with photos and videos, or embed social media feeds. 26 - **Additional order information** - Add a shipping or delivery tab to your product pages, provide location-specific information and maps, or even a product enquiry tab by using WooCommerce Product Tabs with your favorite WordPress contact form plugin. 27 - **Company background** - Customers love knowing who they’re ordering from. Add personality to your brand by adding a charitable causes tab, a sustainability tab, or a tab describing your company story and history. 28 - **Upsell related products** - Display related products or items from the same collection in an extra tab on the product page. This helps to increase your average order value. 29 - **Legal information** - Add extra product page tabs to provide legal information, your returns policy, or financing options. 30 - **Customer support** - Provide information on how customers can get in touch, or even embed a support forum or live chat widget in the extra product page tab. 31 32 Whatever type of extra tabs you want to create, you’ll find that Product Tabs is easily the best WooCommerce tab manager plugin. 26 - **Additional order information** - Add a shipping or delivery tab to your product pages, provide location-specific information and maps, or even a product enquiry tab by using WooCommerce Product Tabs with your favorite WordPress contact form plugin. 27 - **Company background** - Customers love knowing who they’re ordering from. Add personality to your brand by adding a charitable causes tab, a sustainability tab, or a tab describing your company story and history. 28 - **Upsell related products** - Display related products or items from the same collection in an extra tab on the product page. This helps to increase your average order value. 29 - **Legal information** - Add extra product page tabs to provide legal information, your returns policy, or financing options. 30 - **Customer support** - Provide information on how customers can get in touch, or even embed a support forum or live chat widget in the extra product page tab. 31 32 Whatever type of extra tabs you want to create, you’ll find that Product Tabs is easily the best WooCommerce tab manager plugin. 33 33 34 34 [Homepage](https://barn2.com/wordpress-plugins/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) | [Documentation](https://barn2.com/kb/woocommerce-product-tabs-free-documentation/) | [Support](https://wordpress.org/support/plugin/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) | [Buy Pro](https://barn2.com/wordpress-plugins/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg#pricing) … … 36 36 ###WooCommerce Product Tabs (free) includes:### 37 37 38 - Create an unlimited number of WooCommerce product page tabs. 39 - Add flexible tab content using the user-friendly WYSIWYG editor, including shortcodes and HTML. 38 - Create an unlimited number of WooCommerce product page tabs. 39 - Add flexible tab content using the user-friendly WYSIWYG editor, including shortcodes and HTML. 40 40 - Assign tabs based on product category, or set them to appear globally on all products. 41 41 - Re-order tabs by setting priorities. … … 45 45 [View free & pro comparison table](https://barn2.com/kb/woocommerce-product-tabs-free-pro-comparison/) 46 46 47 - Easily re-order tabs using drag-and-drop (both your own custom tabs and the default tabs). 48 - Add an icon to each tab name. 49 - Hide or rename the default WooCommerce tabs (Description, Reviews and Additional Information), and add an icon. 50 - Add tabs to individual products. 51 - Add tabs based on product tags. 52 - Create tabs centrally or directly on the ‘Edit Product’ screen for individual products. 53 - Allow the names and content of your extra product page tabs to appear in the onsite WooCommerce product search results. 47 - Easily re-order tabs using drag-and-drop (both your own custom tabs and the default tabs). 48 - Add an icon to each tab name. 49 - Hide or rename the default WooCommerce tabs (Description, Reviews and Additional Information), and add an icon. 50 - Add tabs to individual products. 51 - Add tabs based on product tags. 52 - Create tabs centrally or directly on the ‘Edit Product’ screen for individual products. 53 - Allow the names and content of your extra product page tabs to appear in the onsite WooCommerce product search results. 54 54 55 55 See the premium version in action on the [plugin demo site](https://producttabs.barn2.com/), and view the plugin documentation in our [knowledge base](https://barn2.com/kb-categories/product-tabs-documentation/). … … 60 60 - [WooCommerce Quick View Pro](https://barn2.com/wordpress-plugins/woocommerce-quick-view-pro/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) - Add quick view buttons to your shop pages, with the extra tabs displayed in a product lightbox. No need for customers to visit separate product pages! 61 61 - [Document Library Pro](https://barn2.com/wordpress-plugins/document-library-pro/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) - Add a structured list of product-related documents to your extra tabs, complete with download buttons and preview buttons. 62 - [WooCommerce Product Table](https://barn2.com/wordpress-plugins/woocommerce-product-table/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) - Easily list related products in a quick order form within your extra product page tabs. 62 - [WooCommerce Product Table](https://barn2.com/wordpress-plugins/woocommerce-product-table/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) - Easily list related products in a quick order form within your extra product page tabs. 63 63 64 64 … … 86 86 = How can I choose which products to display each tab on? = 87 87 88 The free plugin lets you set tabs to appear globally on all products; or assign tabs to all products in a specific category or sub-category. The [premium version](https://barn2.com/wordpress-plugins/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) also lets you add tabs directly to individual products, or assign tabs based on product tags. 88 The free plugin lets you set tabs to appear globally on all products; or assign tabs to all products in a specific category or sub-category. The [premium version](https://barn2.com/wordpress-plugins/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) also lets you add tabs directly to individual products, or assign tabs based on product tags. 89 89 90 90 = Is there a premium version with more features? = … … 94 94 = Where can I find the documentation? = 95 95 96 We have provided a [documentation page](https://barn2.com/kb/woocommerce-product-tabs-free-documentation/) for the free WooCommerce Product Tabs plugin, plus a full [knowledge base](https://barn2.com/kb-categories/product-tabs-documentation/) for the premium version. 96 We have provided a [documentation page](https://barn2.com/kb/woocommerce-product-tabs-free-documentation/) for the free WooCommerce Product Tabs plugin, plus a full [knowledge base](https://barn2.com/kb-categories/product-tabs-documentation/) for the premium version. 97 97 98 98 = Does this plugin work with all themes? = … … 114 114 = How can I set the order of the product page tabs? = 115 115 116 Use the priority field to control the order of the tabs. The lowest number tab will appear first on product pages. Set the priorities bearing in mind that WooCommerce has already assigned a priority of 10 to the Description tab, 20 to the Additional Information tab, and 30 to the Reviews tab. For an easier way to sort the tabs, [upgrade to the premium version](https://barn2.com/wordpress-plugins/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) which has drag-and-drop tab re-ordering. 116 Use the priority field to control the order of the tabs. The lowest number tab will appear first on product pages. Set the priorities bearing in mind that WooCommerce has already assigned a priority of 10 to the Description tab, 20 to the Additional Information tab, and 30 to the Reviews tab. For an easier way to sort the tabs, [upgrade to the premium version](https://barn2.com/wordpress-plugins/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) which has drag-and-drop tab re-ordering. 117 117 118 118 = Where do I report security bugs found in this plugin? = … … 126 126 127 127 == Changelog == 128 129 130 131 132 128 133 129 134 = 2.1.0 = … … 217 222 218 223 = 2.0.6 = 219 Release date 15 July 2021 224 Release date 15 July 2021 220 225 221 226 * Fix: PHP error in PHP 7.1 -
woocommerce-product-tabs/tags/2.1.0.1/src/Admin/Admin_Controller.php
r3019157 r3022582 1 1 <?php 2 2 3 namespace Barn2\Plugin\WC_Product_Tabs_Free\Admin; 3 4 4 use Barn2\Plugin\WC_Product_Tabs_Free\Admin\Wizard\Setup_Wizard, 5 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Util, 6 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Plugin\Plugin, 7 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service_Container, 8 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable, 9 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service, 10 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Admin\Plugin_Promo, 11 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Admin\Settings_API_Helper; 12 use Barn2\Plugin\WC_Product_Tabs_Free\Post_Type; 5 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Admin\Plugin_Promo; 6 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Admin\Settings_API_Helper; 7 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Plugin\Plugin; 8 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable; 9 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service; 10 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service_Container; 13 11 14 12 /** … … 30 28 31 29 public function __construct( Plugin $plugin ) { 32 $this->plugin = $plugin;33 $this->plugin_name 34 $this->version 30 $this->plugin = $plugin; 31 $this->plugin_name = $plugin->get_slug(); 32 $this->version = $plugin->get_version(); 35 33 $this->add_services(); 36 34 } … … 55 53 $this->add_service( 'settings_page', new Settings_Page( $this->plugin ) ); 56 54 $this->add_service( 'single_tab', new Single_Tab() ); 57 $this->add_service( 'product_editor_tabs', new Product_Editor_Tabs( ) );55 $this->add_service( 'product_editor_tabs', new Product_Editor_Tabs() ); 58 56 } 59 57 … … 79 77 * Adds a Pro version link on the Plugins list. 80 78 * 81 * @param array $links79 * @param array $links 82 80 * @param string $file 83 81 * @return array … … 109 107 $screen = get_current_screen(); 110 108 // Main Settings Page 111 112 $screen_ids = [ 'edit-woo_product_tab', 'admin_page_wta_settings', 'woo_product_tab' ]; 109 // TODO: Check this condition later 110 $screen_ids = [ 'edit-woo_product_tab', 'admin_page_wta_settings', 'woo_product_tab' ]; 113 111 if ( in_array( $screen->id, $screen_ids ) ) { 114 112 wp_enqueue_script( $this->plugin_name . '-settings', plugin_dir_url( __DIR__ ) . '../assets/js/admin/settings.js', [ 'jquery', 'wp-element', 'wp-api-fetch' ], $this->version, true ); 115 113 } 116 114 117 115 if ( in_array( $screen->id, $screen_ids ) || ( $screen->id === 'product' && ! isset( $_GET['page'] ) ) ) { 118 116 wp_enqueue_style( $this->plugin_name . '-tab', plugin_dir_url( __DIR__ ) . '../assets/css/admin/tab.css', array(), $this->version, 'all' ); 119 117 120 118 } 121 if ( $screen->id === 'product' && ! isset( $_GET['page'] ) ) {119 if( $screen->id === 'product' && ! isset( $_GET['page'] ) ) { 122 120 wp_enqueue_script( $this->plugin_name . '-product', plugin_dir_url( __DIR__ ) . '../assets/js/admin/product.js', [ 'jquery' ], $this->version, true ); 123 121 } 124 122 125 if ( $screen->id === 'toplevel_page_woocommerce-product-tabs-setup-wizard' ) {123 if( $screen->id === 'toplevel_page_woocommerce-product-tabs-setup-wizard' ) { 126 124 wp_enqueue_style( $this->plugin_name . '-tab', plugin_dir_url( __DIR__ ) . '../assets/css/admin/wizard.css', array(), $this->version, 'all' ); 127 125 wp_enqueue_editor(); -
woocommerce-product-tabs/tags/2.1.0.1/src/Admin/Product_Editor_Tabs.php
r3019157 r3022582 3 3 namespace Barn2\Plugin\WC_Product_Tabs_Free\Admin; 4 4 5 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable ,6 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service;5 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable 6 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service; 7 7 8 8 /** … … 16 16 class Product_Editor_Tabs implements Registerable, Service { 17 17 18 /** 19 * List of the tabs related to the current product 20 */ 21 private $product_tabs_list; 18 private $plugin_dir_path; 22 19 23 public function __construct() { 20 /** 21 * List of the tabs related to the current product 22 */ 23 private $product_tabs_list; 24 25 public function __construct( $dir_path ) { 26 $this->plugin_dir_path = $dir_path; 24 27 $this->product_tabs_list = get_posts( 25 28 [ … … 35 38 } 36 39 } 37 40 } 38 41 39 40 42 public function register() { 43 add_filter( 'woocommerce_product_data_tabs', [ $this, 'product_data_tab' ], 99, 1 ); 41 44 add_action( 'woocommerce_product_data_panels', [ $this, 'product_data_fields' ] ); 42 45 add_action( 'save_post', [ $this, 'save_product_tab_data' ] ); 43 46 add_filter( 'wp_insert_post_data', [ $this, 'insert_tab_menu_order' ], 99, 2 ); 44 47 add_action( 'admin_head', [ $this, 'post_type_menu_active' ] ); 45 } 46 /** 48 } 49 50 /** 47 51 * Add Product Tabs in Product Page. 48 52 * … … 63 67 */ 64 68 function product_data_fields() { 65 66 include(WP_PLUGIN_DIR . '/woocommerce-product-tabs/templates/product-tab-html.php' ); 67 69 include_once $this->plugin_dir_path . 'templates/product-tab-html.php'; 68 70 } 69 71 … … 74 76 */ 75 77 function save_product_tab_data( $post_id ) { 78 76 79 77 if ( ! isset( $_POST['_wpt_product_data_nonce'] ) ) {78 return;79 }80 80 // Verify that the nonce is valid. 81 if ( ! wp_verify_nonce( $_POST['_wpt_product_data_nonce'], 'wpt_product_data' ) ) {81 if ( , 'wpt_product_data' ) ) { 82 82 return; 83 83 } 84 84 85 if ( ( get_post_type( $post_id ) == 'product' ) ) { 85 if ( 'product' !== filter_input( INPUT_POST, 'post_type', FILTER_SANITIZE_SPECIAL_CHARS ) ) { 86 return; 87 } 86 88 87 $tabs = $this->product_tabs_list; 89 if ( empty( $this->product_tabs_list ) ) { 90 return; 91 } 88 92 89 if ( ! empty( $tabs ) ) { 90 foreach ( $_POST as $key => $p ) { 91 $str = substr( $key, 0, 11 ); 92 if ( ( '_wpt_field_' === $str ) ) { 93 $tab_id = intval( substr( $key, 15 ) ); 94 // Update the meta field in the database. 95 $override_value = $_POST[ '_wpt_override_wpt-' . $tab_id ] ?? 'no'; 96 update_post_meta( $post_id, '_wpt_override_wpt-' . $tab_id, $override_value ); 97 if( $override_value === 'yes' ) { 98 // Update the tab content 99 if ( empty( $p ) ) { 100 delete_post_meta( $post_id, $key ); 101 } else { 102 update_post_meta( $post_id, $key, wp_kses_post( $p ) ); 103 } 93 $posted_tab_data = array_filter( 94 $_POST, 95 function ( $key ) { 96 return '_wpt_field_' === substr( $key, 0, 11 ); 97 }, 98 ARRAY_FILTER_USE_KEY 99 ); 104 100 105 // Update the tab icon 106 if( empty( $_POST[ '_wpt_icon_wpt-' . $tab_id ] ) ) { 107 delete_post_meta( $post_id, '_wpt_icon_wpt-' . $tab_id ); 108 } else { 109 update_post_meta( $post_id, '_wpt_icon_wpt-' . $tab_id, $_POST[ '_wpt_icon_wpt-' . $tab_id ] ); 110 } 111 } else { 112 // If the checkbox is not enabled, replace the content and icon with the default 113 delete_post_meta( $post_id, $key ); 114 delete_post_meta( $post_id, '_wpt_icon_wpt-' . $tab_id ); 115 } 116 } 117 } 101 foreach ( $posted_tab_data as $post_key => $tab_content ) { 102 $tab_slug = substr( $post_key, 11 ); 103 $override_value = filter_input( INPUT_POST, '_wpt_override_' . $tab_slug, FILTER_SANITIZE_SPECIAL_CHARS ); 104 105 if ( 'yes' !== $override_value ) { 106 $override_value = 'no'; 107 } 108 109 update_post_meta( $post_id, '_wpt_override_' . $tab_slug, $override_value ); 110 111 if ( 'yes' === $override_value ) { 112 // Update the tab content. 113 update_post_meta( $post_id, $post_key, wp_kses_post( $tab_content ) ); 114 } else { 115 // If the checkbox is not enabled, delete the tab content post meta. 116 delete_post_meta( $post_id, $post_key, '' ); 118 117 } 119 118 } 120 121 119 } 122 120 … … 140 138 if ( $screen->post_type === 'woo_product_tab' ) { 141 139 ?> 142 <script type="text/javascript">143 jQuery(document).ready(function(){144 jQuery('ul.wp-submenu li a[href*="edit.php?post_type=woo_product_tab"]').parent().addClass('current');145 });146 </script>140 <script type="text/javascript"> 141 { 142 ); 143 ); 144 </script> 147 145 <?php 148 146 } -
woocommerce-product-tabs/tags/2.1.0.1/src/Product_Tabs.php
r3019157 r3022582 3 3 namespace Barn2\Plugin\WC_Product_Tabs_Free; 4 4 5 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable ,6 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service;5 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable 6 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service; 7 7 8 8 /** 9 * Show the tabs on the single p eoduct page9 * Show the tabs on the single poduct page 10 10 * 11 11 * @package Barn2/woocommerce-product-tabs … … 16 16 class Product_Tabs implements Registerable, Service { 17 17 18 19 20 21 18 public function register() { 19 // Public custom hooks 20 add_filter( 'woocommerce_product_tabs', [ $this, 'custom_woocommerce_product_tabs' ], 20 ); 21 add_filter( 'wc_quick_view_pro_quick_view_tabs_enabled', [ $this, 'custom_woocommerce_product_tabs' ], 20 ); 22 22 23 23 add_filter( 'wpt_filter_product_tabs', [ $this, 'tab_status_check' ] ); 24 24 25 25 26 26 if ( $this->enable_the_content_filter() ) { 27 27 add_filter( 'wpt_use_the_content_filter', '__return_false' ); 28 28 add_filter( 'wpt_filter_tab_content', array( $this, 'product_tabs_filter_content' ), 10, 1 ); 29 29 } 30 31 32 public function custom_woocommerce_product_tabs( $tabs ){30 } 31 32 { 33 33 global $product; 34 34 … … 43 43 44 44 if ( ! empty( $this->product_tabs_list ) ) { 45 foreach ( $this->product_tabs_list as $key => $t) {46 $this->product_tabs_list[ $key]->post_meta = get_post_meta($this->product_tabs_list[$key]->ID);45 foreach () { 46 $this->product_tabs_list[); 47 47 } 48 48 } … … 53 53 54 54 $wpt_tabs = array(); 55 foreach ( $this->product_tabs_list as $key => $prd) {56 $wpt_tabs[ $key]['id']= $prd->post_name;57 $wpt_tabs[ $key]['title']= esc_attr( $prd->post_title );58 $wpt_tabs[ $key]['priority']= esc_attr( $prd->menu_order );59 $wpt_tabs[ $key]['conditions_category'] = get_post_meta( $prd->ID, '_wpt_conditions_category', true );60 $wpt_tabs[ $key]['display_globally']= esc_attr( get_post_meta( $prd->ID, '_wpt_display_tab_globally', true ) );55 foreach () { 56 $wpt_tabs[ = $prd->post_name; 57 $wpt_tabs[ = esc_attr( $prd->post_title ); 58 $wpt_tabs[ = esc_attr( $prd->menu_order ); 59 $wpt_tabs[]['conditions_category'] = get_post_meta( $prd->ID, '_wpt_conditions_category', true ); 60 $wpt_tabs[ = esc_attr( get_post_meta( $prd->ID, '_wpt_display_tab_globally', true ) ); 61 61 } 62 62 … … 65 65 if ( ! empty( $wpt_tabs ) ) { 66 66 67 foreach ( $wpt_tabs as $key => $tab) {67 foreach () { 68 68 $tab_temp = array(); 69 69 $tab_temp['title'] = $tab['title']; 70 70 $tab_temp['priority'] = $tab['priority']; 71 71 $tab_temp['callback'] = array( $this, 'callback' ); 72 $tabs[ $tab['id']]= $tab_temp;72 $tabs[ = $tab_temp; 73 73 } 74 74 … … 79 79 } 80 80 81 public function tab_status_check( $tabs ){82 83 84 85 86 87 foreach ($tabs as $tab_key => $tab) {88 89 90 91 92 93 // 94 $tab_default_value = $tab_post->post_content;95 96 97 98 81 { 82 83 global $product; 84 85 if ( ! empty( $tabs ) && is_array( $tabs ) ) { 86 87 ) { 88 $key = $tab['id']; 89 90 $tab_post = get_page_by_path( $key, OBJECT, 'woo_product_tab' ); 91 92 if ( ! empty( $tab_post ) ) { 93 94 ; 95 96 $content_to_show = $tab_default_value; 97 98 if ( 'yes' === get_post_meta( $product->get_id(), '_wpt_override_' . $key, true ) ) { 99 99 $tab_value = get_post_meta( $product->get_id(), '_wpt_field_' . $key, true ); 100 100 if ( ! empty( $tab_value ) ) { … … 103 103 } 104 104 105 106 107 108 109 if ( ! empty( $tab['conditions_category'] ) && isset( $tabs[ $tab_key ] ) && $tab[ 'display_globally'] === 'no' ) {105 if ( empty( $content_to_show ) ) { 106 unset( $tabs[ $tab_key ] ); 107 } 108 109 ] === 'no' ) { 110 110 $child_categories = []; 111 foreach ( $tab[ 'conditions_category'] as $category ) {111 foreach] as $category ) { 112 112 $child_terms = get_terms( array( 113 'child_of' =>$category,114 'hide_empty' =>true,115 'taxonomy' =>'product_cat',116 'fields' =>'ids'113 'child_of'$category, 114 'hide_empty'true, 115 'taxonomy''product_cat', 116 'fields''ids' 117 117 ) ); 118 118 119 if ( is_array( $child_terms ) ) {119 if( is_array( $child_terms ) ) { 120 120 $child_categories = array_unique( array_merge( $child_categories, $child_terms ) ); 121 121 } 122 122 } 123 123 124 $conditions_category = array_unique( array_merge( $tab[ 'conditions_category'], $child_categories ) );125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 124 $conditions_category = array_unique( array_merge( $tab[], $child_categories ) ); 125 126 // check category condition 127 $cat_list = wp_get_post_terms( $product->get_id(), 'product_cat', array( 'fields' => 'ids' ) ); 128 129 if ( ! array_intersect( $cat_list, $conditions_category ) ) { 130 unset( $tabs[ $tab_key ] ); 131 } 132 } 133 } 134 135 } // end foreach 136 137 } 138 return $tabs; 139 140 } 141 141 142 142 public function callback( $key, $tab ) { 143 144 143 global $product; 145 144 … … 148 147 return; 149 148 } 150 $override_content = metadata_exists( 'post', $product->get_id(), '_wpt_field_' . $key ); 149 150 $override_meta = get_post_meta( $product->get_id(), '_wpt_override_' . $key, true ); 151 152 // The _wpt_override key doesn't exist in the older version of the plugin and the best way 153 // to check it, is to check for the _wpt_field_ meta for the product 154 if ( empty( $override_meta ) && get_post_meta( $product->get_id(), '_wpt_field_' . $key, true ) ) { 155 $override_meta = 'yes'; 156 } 157 158 $override_content = ( 'yes' === $override_meta ); 159 151 160 if ( ! $override_content ) { 152 // D efault content for all161 // D 153 162 echo $this->get_filter_content( $tab_post->post_content ); 154 163 } else { … … 156 165 echo $this->get_filter_content( $tab_value ); 157 166 } 158 return;159 167 } 160 168 … … 162 170 * Filter the tab content. 163 171 * 164 * @since 2.0.2165 *166 172 * @param string $content Content for the current tab. 167 173 * @return string Tab content. 174 175 168 176 */ 169 public function product_tabs_filter_content( $content ) {177 public function product_tabs_filter_content( $content ){ 170 178 $content = function_exists( 'capital_P_dangit' ) ? capital_P_dangit( $content ) : $content; 171 179 $content = function_exists( 'wptexturize' ) ? wptexturize( $content ) : $content; … … 178 186 179 187 if ( class_exists( 'WP_Embed' ) ) { 180 $embed = new WP_Embed;188 $embed = new WP_Embed; 181 189 $content = method_exists( $embed, 'autoembed' ) ? $embed->autoembed( $content ) : $content; 182 190 } … … 188 196 * Get filter for the content. 189 197 * 190 * @since 2.0.2191 *192 198 * @param string $content Content to apply filter. 193 199 * @return string $content Tab content. 200 201 194 202 */ 195 public function get_filter_content( $content ) {203 public function get_filter_content( $content ){ 196 204 $use_the_content_filter = apply_filters( 'wpt_use_the_content_filter', true ); 197 205 … … 211 219 public function enable_the_content_filter() { 212 220 $disable_the_content_filter = get_option( 'wpt_disable_content_filter' ); 213 $output = false;214 215 if ( empty( $disable_the_content_filter ) ) {221 $output = false; 222 223 if ( empty( $disable_the_content_filter ) ){ 216 224 $disable_the_content_filter = 'no'; 217 225 } 218 226 219 if ( 'yes' === $disable_the_content_filter ) {227 if ( 'yes' === $disable_the_content_filter ){ 220 228 $output = true; 221 229 } -
woocommerce-product-tabs/tags/2.1.0.1/templates/product-tab-html.php
r3019157 r3022582 20 20 if ( 'yes' === $tab->_wpt_display_tab_globally ) { 21 21 $show = true; 22 } 23 else { 22 } else { 24 23 if ( empty( $tab->_wpt_conditions_category ) ) { 25 24 $show = true; 26 25 } else { 27 26 28 27 if ( ! empty( $tab->_wpt_conditions_category ) && is_array( $tab->_wpt_conditions_category ) && array_intersect( $cat_list, $tab->_wpt_conditions_category ) ) { 29 28 $show = true; … … 37 36 unset( $tab ); 38 37 } elseif ( defined( 'ICL_SITEPRESS_VERSION' ) && $lang !== $tab_lang['language_code'] ) { 39 38 unset( $tab ); 40 39 } else { 41 40 … … 50 49 'textarea_name' => '_wpt_field_' . $tab->post_name, 51 50 'editor_height' => '150px', 52 'editor_class' 51 'editor_class'=> 'test-class' 53 52 ]; 54 53 echo '<div class="tab-container hidden">'; 55 54 55 $override_value = get_post_meta( $post_id, '_wpt_override_' . $tab->post_name, true ); 56 56 57 // The _wpt_override key doesn't exist in the older version of the plugin and the best way 57 58 // to check it, is to check for the _wpt_field_ meta for the product 58 if ( get_post_meta( $post_id, '_wpt_override_' . $tab->post_name, true ) === 'yes' || metadata_exists( 'post', $post_id, '_wpt_field_' . $tab->post_name ) ) {59 ife ) ) { 59 60 $override_value = 'yes'; 60 } else { 61 $override_value = get_post_meta( $post_id, '_wpt_override_' . $tab->post_name, true ) ?? 'no'; 61 } 62 63 if ( empty( $override_value ) ) { 64 $override_value = 'no'; 62 65 } 63 66 64 67 // Checking this option would enable the content 65 68 $args = array( 66 'label' => __( 'Override the default tab content for this product','woocommerce-product-tabs' ),67 'id' => '_wpt_override_'. $tab->post_name,68 'name' => '_wpt_override_'. $tab->post_name,69 'class' 70 'wrapper_class' 71 'value' 69 'label' 'woocommerce-product-tabs' ), 70 'id' . $tab->post_name, 71 'name'. $tab->post_name, 72 'class'=> 'override-tab-content', 73 'wrapper_class'=> 'override-tab-content-label', 74 'value'=> $override_value, 72 75 ); 73 76 woocommerce_wp_checkbox( $args ); … … 75 78 wp_editor( $tab_value, '_wpt_field_' . esc_attr( $tab->post_name ), $settings ); 76 79 echo '<div class="edit-tab-product edit-tab-footer">'; 77 echo '<a class="edit-global-tab" target="_blank" href="'. get_edit_post_link( $tab->ID ) .'"><span class="dashicons dashicons-edit"></span> '. __( 'Manage global tab', 'woocommerce-product-tabs' ) .'</a>';80 '</a>'; 78 81 echo '</div></div><br />'; 79 82 } … … 99 102 woocommerce_wp_textarea_input( 100 103 [ 101 'label' 104 'label' => '', 102 105 'id' => 'hidden_duplicate_content', 103 106 'class' => 'tabs_content_field' -
woocommerce-product-tabs/tags/2.1.0.1/woocommerce-product-tabs.php
r3019157 r3022582 1 1 <?php 2 2 /** 3 4 3 5 * @package Barn2\woocommerce-product-tabs 4 6 * @author Barn2 Plugins <support@barn2.com> … … 10 12 * Plugin URI: https://barn2.com/wordpress-plugins/woocommerce-product-tabs/ 11 13 * Description: Boost your product pages by adding custom tabs containing extra information. 12 * Version: 2.1.0 14 * Version: 2.1.0 13 15 * Author: Barn2 Plugins 14 16 * Author URI: https://barn2.com … … 19 21 * Tested up to: 6.4.2 20 22 * WC requires at least: 6.5 21 * WC tested up to: 8. 4.022 * 23 * WC tested up to: 8. 24 * 23 25 * Copyright: Barn2 Media Ltd 24 26 * License: GNU General Public License v3.0 25 27 * License URI: https://www.gnu.org/licenses/gpl.html 26 *27 28 */ 28 29 … … 34 35 } 35 36 36 const PLUGIN_VERSION = '2.1.0 ';37 const PLUGIN_VERSION = '2.1.0'; 37 38 const PLUGIN_FILE = __FILE__; 38 39 -
woocommerce-product-tabs/trunk/readme.txt
r3019157 r3022582 1 1 === WooCommerce Product Tabs === 2 2 3 Contributors: barn2media 3 Contributors: barn2media 4 4 Tags: tabs, custom tabs, product tabs, woocommerce product tab, product custom tabs, multiple product tabs, woocommerce custom tabs, woocommerce product custom tabs, multiple product tabs, woocommerce tabs, tabs for woocommerce, product tab, woocommerce, product, woocommerce product tabs, custom tab, woo product custom tabs, change tab, product page tabs, woocommerce custom tab, woocommerce tab, tabs plugin, woocommerce tabs plugin 5 5 Requires PHP: 7.4 6 6 Requires at least: 6.0 7 7 Tested up to: 6.4.2 8 Stable tag: 2.1.0 8 Stable tag: 2.1.0 9 9 License: GNU General Public License v3.0 10 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html 11 11 Donate link: https://barn2.com 12 12 13 Discover the easy way to add extra tabs to your WooCommerce product pages. 13 Discover the easy way to add extra tabs to your WooCommerce product pages. 14 14 15 15 == Description == … … 17 17 WooCommerce Product Tabs lets you add an unlimited number of extra tabs to any or all of your product pages. 18 18 19 Each tab has a WYSIWYG editor which you can use to add absolutely any type of information to the product page. You can add HTML code, shortcodes, images, videos, audio embeds - the possibilities are endless! 20 21 Adding extra tabs to product pages is an excellent way to provide more information to customers without adding clutter or affecting the layout. Here are some examples of popular uses for WooCommerce product tabs: 22 23 - **Extra product information** - Add a product specifications tab, downloads tab, FAQ tab, ingredients or materials tab, size guide, assembly/usage instructions, unboxing videos, demos, and 3D models. 24 - **Reassure customers** - Create WooCommerce product page tabs to showcase your certifications, warranty information, 19 Each tab has a WYSIWYG editor which you can use to add absolutely any type of information to the product page. You can add HTML code, shortcodes, images, videos, audio embeds - the possibilities are endless! 20 21 Adding extra tabs to product pages is an excellent way to provide more information to customers without adding clutter or affecting the layout. Here are some examples of popular uses for WooCommerce product tabs: 22 23 - **Extra product information** - Add a product specifications tab, downloads tab, FAQ tab, ingredients or materials tab, size guide, assembly/usage instructions, unboxing videos, demos, and 3D models. 24 - **Reassure customers** - Create WooCommerce product page tabs to showcase your certifications, warranty information, 25 25 - **Add social proof to the WooCommerce product page** - Add customers testimonials with photos and videos, or embed social media feeds. 26 - **Additional order information** - Add a shipping or delivery tab to your product pages, provide location-specific information and maps, or even a product enquiry tab by using WooCommerce Product Tabs with your favorite WordPress contact form plugin. 27 - **Company background** - Customers love knowing who they’re ordering from. Add personality to your brand by adding a charitable causes tab, a sustainability tab, or a tab describing your company story and history. 28 - **Upsell related products** - Display related products or items from the same collection in an extra tab on the product page. This helps to increase your average order value. 29 - **Legal information** - Add extra product page tabs to provide legal information, your returns policy, or financing options. 30 - **Customer support** - Provide information on how customers can get in touch, or even embed a support forum or live chat widget in the extra product page tab. 31 32 Whatever type of extra tabs you want to create, you’ll find that Product Tabs is easily the best WooCommerce tab manager plugin. 26 - **Additional order information** - Add a shipping or delivery tab to your product pages, provide location-specific information and maps, or even a product enquiry tab by using WooCommerce Product Tabs with your favorite WordPress contact form plugin. 27 - **Company background** - Customers love knowing who they’re ordering from. Add personality to your brand by adding a charitable causes tab, a sustainability tab, or a tab describing your company story and history. 28 - **Upsell related products** - Display related products or items from the same collection in an extra tab on the product page. This helps to increase your average order value. 29 - **Legal information** - Add extra product page tabs to provide legal information, your returns policy, or financing options. 30 - **Customer support** - Provide information on how customers can get in touch, or even embed a support forum or live chat widget in the extra product page tab. 31 32 Whatever type of extra tabs you want to create, you’ll find that Product Tabs is easily the best WooCommerce tab manager plugin. 33 33 34 34 [Homepage](https://barn2.com/wordpress-plugins/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) | [Documentation](https://barn2.com/kb/woocommerce-product-tabs-free-documentation/) | [Support](https://wordpress.org/support/plugin/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) | [Buy Pro](https://barn2.com/wordpress-plugins/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg#pricing) … … 36 36 ###WooCommerce Product Tabs (free) includes:### 37 37 38 - Create an unlimited number of WooCommerce product page tabs. 39 - Add flexible tab content using the user-friendly WYSIWYG editor, including shortcodes and HTML. 38 - Create an unlimited number of WooCommerce product page tabs. 39 - Add flexible tab content using the user-friendly WYSIWYG editor, including shortcodes and HTML. 40 40 - Assign tabs based on product category, or set them to appear globally on all products. 41 41 - Re-order tabs by setting priorities. … … 45 45 [View free & pro comparison table](https://barn2.com/kb/woocommerce-product-tabs-free-pro-comparison/) 46 46 47 - Easily re-order tabs using drag-and-drop (both your own custom tabs and the default tabs). 48 - Add an icon to each tab name. 49 - Hide or rename the default WooCommerce tabs (Description, Reviews and Additional Information), and add an icon. 50 - Add tabs to individual products. 51 - Add tabs based on product tags. 52 - Create tabs centrally or directly on the ‘Edit Product’ screen for individual products. 53 - Allow the names and content of your extra product page tabs to appear in the onsite WooCommerce product search results. 47 - Easily re-order tabs using drag-and-drop (both your own custom tabs and the default tabs). 48 - Add an icon to each tab name. 49 - Hide or rename the default WooCommerce tabs (Description, Reviews and Additional Information), and add an icon. 50 - Add tabs to individual products. 51 - Add tabs based on product tags. 52 - Create tabs centrally or directly on the ‘Edit Product’ screen for individual products. 53 - Allow the names and content of your extra product page tabs to appear in the onsite WooCommerce product search results. 54 54 55 55 See the premium version in action on the [plugin demo site](https://producttabs.barn2.com/), and view the plugin documentation in our [knowledge base](https://barn2.com/kb-categories/product-tabs-documentation/). … … 60 60 - [WooCommerce Quick View Pro](https://barn2.com/wordpress-plugins/woocommerce-quick-view-pro/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) - Add quick view buttons to your shop pages, with the extra tabs displayed in a product lightbox. No need for customers to visit separate product pages! 61 61 - [Document Library Pro](https://barn2.com/wordpress-plugins/document-library-pro/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) - Add a structured list of product-related documents to your extra tabs, complete with download buttons and preview buttons. 62 - [WooCommerce Product Table](https://barn2.com/wordpress-plugins/woocommerce-product-table/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) - Easily list related products in a quick order form within your extra product page tabs. 62 - [WooCommerce Product Table](https://barn2.com/wordpress-plugins/woocommerce-product-table/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) - Easily list related products in a quick order form within your extra product page tabs. 63 63 64 64 … … 86 86 = How can I choose which products to display each tab on? = 87 87 88 The free plugin lets you set tabs to appear globally on all products; or assign tabs to all products in a specific category or sub-category. The [premium version](https://barn2.com/wordpress-plugins/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) also lets you add tabs directly to individual products, or assign tabs based on product tags. 88 The free plugin lets you set tabs to appear globally on all products; or assign tabs to all products in a specific category or sub-category. The [premium version](https://barn2.com/wordpress-plugins/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) also lets you add tabs directly to individual products, or assign tabs based on product tags. 89 89 90 90 = Is there a premium version with more features? = … … 94 94 = Where can I find the documentation? = 95 95 96 We have provided a [documentation page](https://barn2.com/kb/woocommerce-product-tabs-free-documentation/) for the free WooCommerce Product Tabs plugin, plus a full [knowledge base](https://barn2.com/kb-categories/product-tabs-documentation/) for the premium version. 96 We have provided a [documentation page](https://barn2.com/kb/woocommerce-product-tabs-free-documentation/) for the free WooCommerce Product Tabs plugin, plus a full [knowledge base](https://barn2.com/kb-categories/product-tabs-documentation/) for the premium version. 97 97 98 98 = Does this plugin work with all themes? = … … 114 114 = How can I set the order of the product page tabs? = 115 115 116 Use the priority field to control the order of the tabs. The lowest number tab will appear first on product pages. Set the priorities bearing in mind that WooCommerce has already assigned a priority of 10 to the Description tab, 20 to the Additional Information tab, and 30 to the Reviews tab. For an easier way to sort the tabs, [upgrade to the premium version](https://barn2.com/wordpress-plugins/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) which has drag-and-drop tab re-ordering. 116 Use the priority field to control the order of the tabs. The lowest number tab will appear first on product pages. Set the priorities bearing in mind that WooCommerce has already assigned a priority of 10 to the Description tab, 20 to the Additional Information tab, and 30 to the Reviews tab. For an easier way to sort the tabs, [upgrade to the premium version](https://barn2.com/wordpress-plugins/woocommerce-product-tabs/?utm_source=wporg&utm_medium=freeplugin&utm_campaign=freepluginwporg&utm_content=wta-wporg) which has drag-and-drop tab re-ordering. 117 117 118 118 = Where do I report security bugs found in this plugin? = … … 126 126 127 127 == Changelog == 128 129 130 131 132 128 133 129 134 = 2.1.0 = … … 217 222 218 223 = 2.0.6 = 219 Release date 15 July 2021 224 Release date 15 July 2021 220 225 221 226 * Fix: PHP error in PHP 7.1 -
woocommerce-product-tabs/trunk/src/Admin/Admin_Controller.php
r3019157 r3022582 1 1 <?php 2 2 3 namespace Barn2\Plugin\WC_Product_Tabs_Free\Admin; 3 4 4 use Barn2\Plugin\WC_Product_Tabs_Free\Admin\Wizard\Setup_Wizard, 5 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Util, 6 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Plugin\Plugin, 7 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service_Container, 8 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable, 9 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service, 10 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Admin\Plugin_Promo, 11 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Admin\Settings_API_Helper; 12 use Barn2\Plugin\WC_Product_Tabs_Free\Post_Type; 5 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Admin\Plugin_Promo; 6 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Admin\Settings_API_Helper; 7 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Plugin\Plugin; 8 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable; 9 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service; 10 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service_Container; 13 11 14 12 /** … … 30 28 31 29 public function __construct( Plugin $plugin ) { 32 $this->plugin = $plugin;33 $this->plugin_name 34 $this->version 30 $this->plugin = $plugin; 31 $this->plugin_name = $plugin->get_slug(); 32 $this->version = $plugin->get_version(); 35 33 $this->add_services(); 36 34 } … … 55 53 $this->add_service( 'settings_page', new Settings_Page( $this->plugin ) ); 56 54 $this->add_service( 'single_tab', new Single_Tab() ); 57 $this->add_service( 'product_editor_tabs', new Product_Editor_Tabs( ) );55 $this->add_service( 'product_editor_tabs', new Product_Editor_Tabs() ); 58 56 } 59 57 … … 79 77 * Adds a Pro version link on the Plugins list. 80 78 * 81 * @param array $links79 * @param array $links 82 80 * @param string $file 83 81 * @return array … … 109 107 $screen = get_current_screen(); 110 108 // Main Settings Page 111 112 $screen_ids = [ 'edit-woo_product_tab', 'admin_page_wta_settings', 'woo_product_tab' ]; 109 // TODO: Check this condition later 110 $screen_ids = [ 'edit-woo_product_tab', 'admin_page_wta_settings', 'woo_product_tab' ]; 113 111 if ( in_array( $screen->id, $screen_ids ) ) { 114 112 wp_enqueue_script( $this->plugin_name . '-settings', plugin_dir_url( __DIR__ ) . '../assets/js/admin/settings.js', [ 'jquery', 'wp-element', 'wp-api-fetch' ], $this->version, true ); 115 113 } 116 114 117 115 if ( in_array( $screen->id, $screen_ids ) || ( $screen->id === 'product' && ! isset( $_GET['page'] ) ) ) { 118 116 wp_enqueue_style( $this->plugin_name . '-tab', plugin_dir_url( __DIR__ ) . '../assets/css/admin/tab.css', array(), $this->version, 'all' ); 119 117 120 118 } 121 if ( $screen->id === 'product' && ! isset( $_GET['page'] ) ) {119 if( $screen->id === 'product' && ! isset( $_GET['page'] ) ) { 122 120 wp_enqueue_script( $this->plugin_name . '-product', plugin_dir_url( __DIR__ ) . '../assets/js/admin/product.js', [ 'jquery' ], $this->version, true ); 123 121 } 124 122 125 if ( $screen->id === 'toplevel_page_woocommerce-product-tabs-setup-wizard' ) {123 if( $screen->id === 'toplevel_page_woocommerce-product-tabs-setup-wizard' ) { 126 124 wp_enqueue_style( $this->plugin_name . '-tab', plugin_dir_url( __DIR__ ) . '../assets/css/admin/wizard.css', array(), $this->version, 'all' ); 127 125 wp_enqueue_editor(); -
woocommerce-product-tabs/trunk/src/Admin/Product_Editor_Tabs.php
r3019157 r3022582 3 3 namespace Barn2\Plugin\WC_Product_Tabs_Free\Admin; 4 4 5 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable ,6 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service;5 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable 6 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service; 7 7 8 8 /** … … 16 16 class Product_Editor_Tabs implements Registerable, Service { 17 17 18 /** 19 * List of the tabs related to the current product 20 */ 21 private $product_tabs_list; 18 private $plugin_dir_path; 22 19 23 public function __construct() { 20 /** 21 * List of the tabs related to the current product 22 */ 23 private $product_tabs_list; 24 25 public function __construct( $dir_path ) { 26 $this->plugin_dir_path = $dir_path; 24 27 $this->product_tabs_list = get_posts( 25 28 [ … … 35 38 } 36 39 } 37 40 } 38 41 39 40 42 public function register() { 43 add_filter( 'woocommerce_product_data_tabs', [ $this, 'product_data_tab' ], 99, 1 ); 41 44 add_action( 'woocommerce_product_data_panels', [ $this, 'product_data_fields' ] ); 42 45 add_action( 'save_post', [ $this, 'save_product_tab_data' ] ); 43 46 add_filter( 'wp_insert_post_data', [ $this, 'insert_tab_menu_order' ], 99, 2 ); 44 47 add_action( 'admin_head', [ $this, 'post_type_menu_active' ] ); 45 } 46 /** 48 } 49 50 /** 47 51 * Add Product Tabs in Product Page. 48 52 * … … 63 67 */ 64 68 function product_data_fields() { 65 66 include(WP_PLUGIN_DIR . '/woocommerce-product-tabs/templates/product-tab-html.php' ); 67 69 include_once $this->plugin_dir_path . 'templates/product-tab-html.php'; 68 70 } 69 71 … … 74 76 */ 75 77 function save_product_tab_data( $post_id ) { 78 76 79 77 if ( ! isset( $_POST['_wpt_product_data_nonce'] ) ) {78 return;79 }80 80 // Verify that the nonce is valid. 81 if ( ! wp_verify_nonce( $_POST['_wpt_product_data_nonce'], 'wpt_product_data' ) ) {81 if ( , 'wpt_product_data' ) ) { 82 82 return; 83 83 } 84 84 85 if ( ( get_post_type( $post_id ) == 'product' ) ) { 85 if ( 'product' !== filter_input( INPUT_POST, 'post_type', FILTER_SANITIZE_SPECIAL_CHARS ) ) { 86 return; 87 } 86 88 87 $tabs = $this->product_tabs_list; 89 if ( empty( $this->product_tabs_list ) ) { 90 return; 91 } 88 92 89 if ( ! empty( $tabs ) ) { 90 foreach ( $_POST as $key => $p ) { 91 $str = substr( $key, 0, 11 ); 92 if ( ( '_wpt_field_' === $str ) ) { 93 $tab_id = intval( substr( $key, 15 ) ); 94 // Update the meta field in the database. 95 $override_value = $_POST[ '_wpt_override_wpt-' . $tab_id ] ?? 'no'; 96 update_post_meta( $post_id, '_wpt_override_wpt-' . $tab_id, $override_value ); 97 if( $override_value === 'yes' ) { 98 // Update the tab content 99 if ( empty( $p ) ) { 100 delete_post_meta( $post_id, $key ); 101 } else { 102 update_post_meta( $post_id, $key, wp_kses_post( $p ) ); 103 } 93 $posted_tab_data = array_filter( 94 $_POST, 95 function ( $key ) { 96 return '_wpt_field_' === substr( $key, 0, 11 ); 97 }, 98 ARRAY_FILTER_USE_KEY 99 ); 104 100 105 // Update the tab icon 106 if( empty( $_POST[ '_wpt_icon_wpt-' . $tab_id ] ) ) { 107 delete_post_meta( $post_id, '_wpt_icon_wpt-' . $tab_id ); 108 } else { 109 update_post_meta( $post_id, '_wpt_icon_wpt-' . $tab_id, $_POST[ '_wpt_icon_wpt-' . $tab_id ] ); 110 } 111 } else { 112 // If the checkbox is not enabled, replace the content and icon with the default 113 delete_post_meta( $post_id, $key ); 114 delete_post_meta( $post_id, '_wpt_icon_wpt-' . $tab_id ); 115 } 116 } 117 } 101 foreach ( $posted_tab_data as $post_key => $tab_content ) { 102 $tab_slug = substr( $post_key, 11 ); 103 $override_value = filter_input( INPUT_POST, '_wpt_override_' . $tab_slug, FILTER_SANITIZE_SPECIAL_CHARS ); 104 105 if ( 'yes' !== $override_value ) { 106 $override_value = 'no'; 107 } 108 109 update_post_meta( $post_id, '_wpt_override_' . $tab_slug, $override_value ); 110 111 if ( 'yes' === $override_value ) { 112 // Update the tab content. 113 update_post_meta( $post_id, $post_key, wp_kses_post( $tab_content ) ); 114 } else { 115 // If the checkbox is not enabled, delete the tab content post meta. 116 delete_post_meta( $post_id, $post_key, '' ); 118 117 } 119 118 } 120 121 119 } 122 120 … … 140 138 if ( $screen->post_type === 'woo_product_tab' ) { 141 139 ?> 142 <script type="text/javascript">143 jQuery(document).ready(function(){144 jQuery('ul.wp-submenu li a[href*="edit.php?post_type=woo_product_tab"]').parent().addClass('current');145 });146 </script>140 <script type="text/javascript"> 141 { 142 ); 143 ); 144 </script> 147 145 <?php 148 146 } -
woocommerce-product-tabs/trunk/src/Product_Tabs.php
r3019157 r3022582 3 3 namespace Barn2\Plugin\WC_Product_Tabs_Free; 4 4 5 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable ,6 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service;5 use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable 6 Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service; 7 7 8 8 /** 9 * Show the tabs on the single p eoduct page9 * Show the tabs on the single poduct page 10 10 * 11 11 * @package Barn2/woocommerce-product-tabs … … 16 16 class Product_Tabs implements Registerable, Service { 17 17 18 19 20 21 18 public function register() { 19 // Public custom hooks 20 add_filter( 'woocommerce_product_tabs', [ $this, 'custom_woocommerce_product_tabs' ], 20 ); 21 add_filter( 'wc_quick_view_pro_quick_view_tabs_enabled', [ $this, 'custom_woocommerce_product_tabs' ], 20 ); 22 22 23 23 add_filter( 'wpt_filter_product_tabs', [ $this, 'tab_status_check' ] ); 24 24 25 25 26 26 if ( $this->enable_the_content_filter() ) { 27 27 add_filter( 'wpt_use_the_content_filter', '__return_false' ); 28 28 add_filter( 'wpt_filter_tab_content', array( $this, 'product_tabs_filter_content' ), 10, 1 ); 29 29 } 30 31 32 public function custom_woocommerce_product_tabs( $tabs ){30 } 31 32 { 33 33 global $product; 34 34 … … 43 43 44 44 if ( ! empty( $this->product_tabs_list ) ) { 45 foreach ( $this->product_tabs_list as $key => $t) {46 $this->product_tabs_list[ $key]->post_meta = get_post_meta($this->product_tabs_list[$key]->ID);45 foreach () { 46 $this->product_tabs_list[); 47 47 } 48 48 } … … 53 53 54 54 $wpt_tabs = array(); 55 foreach ( $this->product_tabs_list as $key => $prd) {56 $wpt_tabs[ $key]['id']= $prd->post_name;57 $wpt_tabs[ $key]['title']= esc_attr( $prd->post_title );58 $wpt_tabs[ $key]['priority']= esc_attr( $prd->menu_order );59 $wpt_tabs[ $key]['conditions_category'] = get_post_meta( $prd->ID, '_wpt_conditions_category', true );60 $wpt_tabs[ $key]['display_globally']= esc_attr( get_post_meta( $prd->ID, '_wpt_display_tab_globally', true ) );55 foreach () { 56 $wpt_tabs[ = $prd->post_name; 57 $wpt_tabs[ = esc_attr( $prd->post_title ); 58 $wpt_tabs[ = esc_attr( $prd->menu_order ); 59 $wpt_tabs[]['conditions_category'] = get_post_meta( $prd->ID, '_wpt_conditions_category', true ); 60 $wpt_tabs[ = esc_attr( get_post_meta( $prd->ID, '_wpt_display_tab_globally', true ) ); 61 61 } 62 62 … … 65 65 if ( ! empty( $wpt_tabs ) ) { 66 66 67 foreach ( $wpt_tabs as $key => $tab) {67 foreach () { 68 68 $tab_temp = array(); 69 69 $tab_temp['title'] = $tab['title']; 70 70 $tab_temp['priority'] = $tab['priority']; 71 71 $tab_temp['callback'] = array( $this, 'callback' ); 72 $tabs[ $tab['id']]= $tab_temp;72 $tabs[ = $tab_temp; 73 73 } 74 74 … … 79 79 } 80 80 81 public function tab_status_check( $tabs ){82 83 84 85 86 87 foreach ($tabs as $tab_key => $tab) {88 89 90 91 92 93 // 94 $tab_default_value = $tab_post->post_content;95 96 97 98 81 { 82 83 global $product; 84 85 if ( ! empty( $tabs ) && is_array( $tabs ) ) { 86 87 ) { 88 $key = $tab['id']; 89 90 $tab_post = get_page_by_path( $key, OBJECT, 'woo_product_tab' ); 91 92 if ( ! empty( $tab_post ) ) { 93 94 ; 95 96 $content_to_show = $tab_default_value; 97 98 if ( 'yes' === get_post_meta( $product->get_id(), '_wpt_override_' . $key, true ) ) { 99 99 $tab_value = get_post_meta( $product->get_id(), '_wpt_field_' . $key, true ); 100 100 if ( ! empty( $tab_value ) ) { … … 103 103 } 104 104 105 106 107 108 109 if ( ! empty( $tab['conditions_category'] ) && isset( $tabs[ $tab_key ] ) && $tab[ 'display_globally'] === 'no' ) {105 if ( empty( $content_to_show ) ) { 106 unset( $tabs[ $tab_key ] ); 107 } 108 109 ] === 'no' ) { 110 110 $child_categories = []; 111 foreach ( $tab[ 'conditions_category'] as $category ) {111 foreach] as $category ) { 112 112 $child_terms = get_terms( array( 113 'child_of' =>$category,114 'hide_empty' =>true,115 'taxonomy' =>'product_cat',116 'fields' =>'ids'113 'child_of'$category, 114 'hide_empty'true, 115 'taxonomy''product_cat', 116 'fields''ids' 117 117 ) ); 118 118 119 if ( is_array( $child_terms ) ) {119 if( is_array( $child_terms ) ) { 120 120 $child_categories = array_unique( array_merge( $child_categories, $child_terms ) ); 121 121 } 122 122 } 123 123 124 $conditions_category = array_unique( array_merge( $tab[ 'conditions_category'], $child_categories ) );125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 124 $conditions_category = array_unique( array_merge( $tab[], $child_categories ) ); 125 126 // check category condition 127 $cat_list = wp_get_post_terms( $product->get_id(), 'product_cat', array( 'fields' => 'ids' ) ); 128 129 if ( ! array_intersect( $cat_list, $conditions_category ) ) { 130 unset( $tabs[ $tab_key ] ); 131 } 132 } 133 } 134 135 } // end foreach 136 137 } 138 return $tabs; 139 140 } 141 141 142 142 public function callback( $key, $tab ) { 143 144 143 global $product; 145 144 … … 148 147 return; 149 148 } 150 $override_content = metadata_exists( 'post', $product->get_id(), '_wpt_field_' . $key ); 149 150 $override_meta = get_post_meta( $product->get_id(), '_wpt_override_' . $key, true ); 151 152 // The _wpt_override key doesn't exist in the older version of the plugin and the best way 153 // to check it, is to check for the _wpt_field_ meta for the product 154 if ( empty( $override_meta ) && get_post_meta( $product->get_id(), '_wpt_field_' . $key, true ) ) { 155 $override_meta = 'yes'; 156 } 157 158 $override_content = ( 'yes' === $override_meta ); 159 151 160 if ( ! $override_content ) { 152 // D efault content for all161 // D 153 162 echo $this->get_filter_content( $tab_post->post_content ); 154 163 } else { … … 156 165 echo $this->get_filter_content( $tab_value ); 157 166 } 158 return;159 167 } 160 168 … … 162 170 * Filter the tab content. 163 171 * 164 * @since 2.0.2165 *166 172 * @param string $content Content for the current tab. 167 173 * @return string Tab content. 174 175 168 176 */ 169 public function product_tabs_filter_content( $content ) {177 public function product_tabs_filter_content( $content ){ 170 178 $content = function_exists( 'capital_P_dangit' ) ? capital_P_dangit( $content ) : $content; 171 179 $content = function_exists( 'wptexturize' ) ? wptexturize( $content ) : $content; … … 178 186 179 187 if ( class_exists( 'WP_Embed' ) ) { 180 $embed = new WP_Embed;188 $embed = new WP_Embed; 181 189 $content = method_exists( $embed, 'autoembed' ) ? $embed->autoembed( $content ) : $content; 182 190 } … … 188 196 * Get filter for the content. 189 197 * 190 * @since 2.0.2191 *192 198 * @param string $content Content to apply filter. 193 199 * @return string $content Tab content. 200 201 194 202 */ 195 public function get_filter_content( $content ) {203 public function get_filter_content( $content ){ 196 204 $use_the_content_filter = apply_filters( 'wpt_use_the_content_filter', true ); 197 205 … … 211 219 public function enable_the_content_filter() { 212 220 $disable_the_content_filter = get_option( 'wpt_disable_content_filter' ); 213 $output = false;214 215 if ( empty( $disable_the_content_filter ) ) {221 $output = false; 222 223 if ( empty( $disable_the_content_filter ) ){ 216 224 $disable_the_content_filter = 'no'; 217 225 } 218 226 219 if ( 'yes' === $disable_the_content_filter ) {227 if ( 'yes' === $disable_the_content_filter ){ 220 228 $output = true; 221 229 } -
woocommerce-product-tabs/trunk/templates/product-tab-html.php
r3019157 r3022582 20 20 if ( 'yes' === $tab->_wpt_display_tab_globally ) { 21 21 $show = true; 22 } 23 else { 22 } else { 24 23 if ( empty( $tab->_wpt_conditions_category ) ) { 25 24 $show = true; 26 25 } else { 27 26 28 27 if ( ! empty( $tab->_wpt_conditions_category ) && is_array( $tab->_wpt_conditions_category ) && array_intersect( $cat_list, $tab->_wpt_conditions_category ) ) { 29 28 $show = true; … … 37 36 unset( $tab ); 38 37 } elseif ( defined( 'ICL_SITEPRESS_VERSION' ) && $lang !== $tab_lang['language_code'] ) { 39 38 unset( $tab ); 40 39 } else { 41 40 … … 50 49 'textarea_name' => '_wpt_field_' . $tab->post_name, 51 50 'editor_height' => '150px', 52 'editor_class' 51 'editor_class'=> 'test-class' 53 52 ]; 54 53 echo '<div class="tab-container hidden">'; 55 54 55 $override_value = get_post_meta( $post_id, '_wpt_override_' . $tab->post_name, true ); 56 56 57 // The _wpt_override key doesn't exist in the older version of the plugin and the best way 57 58 // to check it, is to check for the _wpt_field_ meta for the product 58 if ( get_post_meta( $post_id, '_wpt_override_' . $tab->post_name, true ) === 'yes' || metadata_exists( 'post', $post_id, '_wpt_field_' . $tab->post_name ) ) {59 ife ) ) { 59 60 $override_value = 'yes'; 60 } else { 61 $override_value = get_post_meta( $post_id, '_wpt_override_' . $tab->post_name, true ) ?? 'no'; 61 } 62 63 if ( empty( $override_value ) ) { 64 $override_value = 'no'; 62 65 } 63 66 64 67 // Checking this option would enable the content 65 68 $args = array( 66 'label' => __( 'Override the default tab content for this product','woocommerce-product-tabs' ),67 'id' => '_wpt_override_'. $tab->post_name,68 'name' => '_wpt_override_'. $tab->post_name,69 'class' 70 'wrapper_class' 71 'value' 69 'label' 'woocommerce-product-tabs' ), 70 'id' . $tab->post_name, 71 'name'. $tab->post_name, 72 'class'=> 'override-tab-content', 73 'wrapper_class'=> 'override-tab-content-label', 74 'value'=> $override_value, 72 75 ); 73 76 woocommerce_wp_checkbox( $args ); … … 75 78 wp_editor( $tab_value, '_wpt_field_' . esc_attr( $tab->post_name ), $settings ); 76 79 echo '<div class="edit-tab-product edit-tab-footer">'; 77 echo '<a class="edit-global-tab" target="_blank" href="'. get_edit_post_link( $tab->ID ) .'"><span class="dashicons dashicons-edit"></span> '. __( 'Manage global tab', 'woocommerce-product-tabs' ) .'</a>';80 '</a>'; 78 81 echo '</div></div><br />'; 79 82 } … … 99 102 woocommerce_wp_textarea_input( 100 103 [ 101 'label' 104 'label' => '', 102 105 'id' => 'hidden_duplicate_content', 103 106 'class' => 'tabs_content_field' -
woocommerce-product-tabs/trunk/woocommerce-product-tabs.php
r3019157 r3022582 1 1 <?php 2 2 /** 3 4 3 5 * @package Barn2\woocommerce-product-tabs 4 6 * @author Barn2 Plugins <support@barn2.com> … … 10 12 * Plugin URI: https://barn2.com/wordpress-plugins/woocommerce-product-tabs/ 11 13 * Description: Boost your product pages by adding custom tabs containing extra information. 12 * Version: 2.1.0 14 * Version: 2.1.0 13 15 * Author: Barn2 Plugins 14 16 * Author URI: https://barn2.com … … 19 21 * Tested up to: 6.4.2 20 22 * WC requires at least: 6.5 21 * WC tested up to: 8. 4.022 * 23 * WC tested up to: 8. 24 * 23 25 * Copyright: Barn2 Media Ltd 24 26 * License: GNU General Public License v3.0 25 27 * License URI: https://www.gnu.org/licenses/gpl.html 26 *27 28 */ 28 29 … … 34 35 } 35 36 36 const PLUGIN_VERSION = '2.1.0 ';37 const PLUGIN_VERSION = '2.1.0'; 37 38 const PLUGIN_FILE = __FILE__; 38 39
Note: See TracChangeset
for help on using the changeset viewer.