__( 'Price', 'shipping-options' ) . ':', 'product_features' => __( 'Features', 'shipping-options' ), 'product_shipping' => __( 'Shipping', 'shipping-options' ) . ':' ); } return $single_names; } } add_shortcode( 'attributes_table', 'ic_attributes_table_shortcode' ); /** * Defines attributes field table shortcode * * @param type $atts * @return type */ function ic_attributes_table_shortcode( $atts ) { $args = shortcode_atts( array( 'id' => get_the_ID(), ), $atts ); $single_names = get_external_single_names(); return get_product_attributes( $args[ 'id' ], $single_names ); } /** * Shows attributes field * * @param type $id */ function ic_attributes_table( $id = null ) { $id = empty( $id ) ? get_the_ID() : $id; $single_names = get_external_single_names(); echo get_product_attributes( $id, $single_names ); } add_filter( 'the_content', 'show_auto_attributes_table' ); /** * Shows attributes on certain post types * * @param type $content * @return type */ function show_auto_attributes_table( $content ) { $post_type = get_post_type(); $attributes_show_post_type = get_attributes_show_active_post_types(); if ( in_array( $post_type, $attributes_show_post_type ) ) { ic_show_template_file( 'product-page/product-attributes.php', AL_ATTRIBUTES_BASE_PATH ); //$single_names = get_external_single_names(); //$content .= ''; //$content .= get_product_attributes( get_the_ID(), $single_names ); } return $content; } add_action( 'admin_enqueue_scripts', 'ic_enqueue_attr_sep_scripts' ); /** * Adds admin scripts for selected post types * */ function ic_enqueue_attr_sep_scripts() { if ( is_ic_sep_admin_screen() ) { wp_enqueue_script( 'al_product_admin-scripts' ); } } if ( !function_exists( 'is_ic_sep_admin_screen' ) ) { function is_ic_sep_admin_screen() { if ( is_admin() && function_exists( 'get_current_screen' ) ) { $screen = get_current_screen(); if ( isset( $screen->post_type ) ) { $post_types = get_attributes_active_post_types(); if ( in_array( $screen->post_type, $post_types ) ) { return true; } } } return false; } }