get_id() : (int) get_the_ID(); if ( ! $id || ( ! get_post_meta( $id, Import_Yikes::META_IMPORTED, true ) && ! Import_Yikes::has_custom_tabs( $id ) ) ) { return $tabs; } foreach ( $tabs as $key => $tab ) { $callback = $tab['callback'] ?? null; if ( is_array( $callback ) && isset( $callback[0] ) && $callback[0] instanceof \YIKES_Custom_Product_Tabs_Display ) { unset( $tabs[ $key ] ); } } return $tabs; } /** * Heading of a panel: classes of YIKES added, then its heading filter. * * @param string $html Heading markup. * @param array $data Tab data. * @param string|int $key Tab key. */ public static function heading( $html, $data, $key ) { if ( ! self::enabled() || '' === $html ) { return $html; } $classes = 'prodtabs-heading yikes-custom-woo-tab-title yikes-custom-woo-tab-title-' . sanitize_html_class( urldecode( sanitize_title( $data['title'] ) ) ); $html = str_replace( 'class="prodtabs-heading"', 'class="' . esc_attr( $classes ) . '"', $html ); return apply_filters( 'yikes_woocommerce_custom_repeatable_product_tabs_heading', $html, self::yikes_tab( $data, $key ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- hook of Custom Product Tabs (YIKES), kept for compatibility. } /** * Content of a panel through the content filter of YIKES. * * @param string $html Formatted content. * @param array $data Tab data. */ public static function content( $html, $data ) { if ( ! self::enabled() ) { return $html; } return apply_filters( 'yikes_woocommerce_custom_repeatable_product_tabs_content', $html, self::yikes_tab( $data, '' ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- hook of Custom Product Tabs (YIKES), kept for compatibility. } /** * Whole tab list through the list filter of YIKES, when YIKES no longer applies it itself. * * @param array $tabs Tabs. * @param \WC_Product $product Product. */ public static function all_tabs( $tabs, $product ) { if ( ! self::enabled() || class_exists( 'YIKES_Custom_Product_Tabs_Display' ) ) { return $tabs; } return apply_filters( 'yikes_woo_filter_all_product_tabs', $tabs, $product ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- hook of Custom Product Tabs (YIKES), kept for compatibility. } /** * Tab in the shape YIKES passes to its filters: title, raw content, priority, callback. * * @param array $data Tab data. * @param string|int $key Tab key. */ private static function yikes_tab( array $data, $key ): array { return array( 'title' => $data['title'], 'content' => $data['content'], 'priority' => 25, 'callback' => array( Render::class, 'render_panel' ), 'id' => $key, ); } }