__( 'Woo Albums', 'wap' ), 'type' => 'title', 'desc' => '', 'id' => 'wap_options', ); $settings[] = array( 'title' => __( 'Track sample length', 'wap' ), 'desc_tip' => __( 'Length of demo record in album player', 'wap' ), 'id' => 'wap_cut_length', 'type' => 'text', 'css' => 'min-width:300px;', 'std' => '30', // WC < 2.0 'default' => '30', // WC >= 2.0 'desc' => __( 'Set it in seconds', 'wap' ), ); $settings[] = array( 'type' => 'sectionend', 'id' => 'wap_options', ); return $settings; } public function wap_add_attachment_options( $form_fields, $post ){ if( $post->post_mime_type == "audio/mpeg" ){ $data = array(); $data['post_id'] = $post->ID; $data['cut_file'] = esc_attr ( get_post_meta( $post->ID, '_wp_attached_cut_file', true ) ); $form_fields['woo-albums'] = array( 'label' => __( 'Track sample' , 'wap' ), 'input' => 'html', 'html' => $this->get_media_html_content( $data ), 'show_in_edit' => true, 'show_in_modal' => true, ); } return $form_fields; } public function get_media_html_content( $data = array() ){ ob_start(); ?>
:
__( 'Tracks', 'wap' ), 'target' => 'album_variable_product_options', 'class' => array( 'show_if_variable_album' ), ); $tabs[ 'shipping' ][ 'class' ][] = 'hide_if_variable_album'; return $tabs; } public function general_tab_album_price() { global $post; ?>
'_album_regular_price', 'label' => sprintf( __( 'Regular price (%s)', 'wap' ), get_woocommerce_currency_symbol() ), 'placeholder' => '', 'desc_tip' => 'true', 'class' => 'short wc_input_price', 'type' => 'text', 'value' => esc_attr( get_post_meta( $post->ID, '_album_regular_price', true ) ) ) ); woocommerce_wp_text_input( array( 'id' => '_album_sale_price', 'value' => esc_attr( get_post_meta( $post->ID, '_album_sale_price', true ) ), 'data_type' => 'price', 'label' => __( 'Sale price', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')', 'description' => '' . __( 'Schedule', 'woocommerce' ) . '', ) ); $sale_price_dates_from = !empty( $date = get_post_meta( $post->ID, '_sale_price_dates_from', true ) ) ? date_i18n( 'Y-m-d', $date ) : ''; $sale_price_dates_to = !empty( $date = get_post_meta( $post->ID, '_sale_price_dates_to', true ) ) ? date_i18n( 'Y-m-d', $date ) : ''; echo '

' . esc_html__( 'Cancel', 'woocommerce' ) . '' . wc_help_tip( __( 'The sale will end at the beginning of the set date.', 'woocommerce' ) ) . '

'; ?>
ID ); ?>
$data ) { $updated_data = array( 'ID' => $id, 'post_title' => sanitize_title( $_POST['post_title'] . ' - '. $data['_title'] ), 'post_name' => wc_sanitize_taxonomy_name( sanitize_title( $_POST['post_title'] . ' - '. $data['_title'] ) ), 'post_status' => ( isset( $data['_enabled'] ) ? 'publish' : 'draft' ), ); wp_update_post( $updated_data ); update_post_meta( $id, '_variation_description', '' ); update_post_meta( $id, '_sku', esc_attr( $data['_sku'] ) ); update_post_meta( $id, '_regular_price', esc_attr( $data['_price'] ) ); update_post_meta( $id, '_price', esc_attr( $data['_price'] ) ); update_post_meta( $id, '_product_version', '3.5.0' ); update_post_meta( $id, '_sale_price', esc_attr( $data['_sale_price'] ) ); update_post_meta( $id, '_tax_status', 'taxable' ); update_post_meta( $id, '_tax_class', 'parent' ); update_post_meta( $id, '_manage_stock', 'no' ); update_post_meta( $id, '_backorders', 'no' ); update_post_meta( $id, '_sold_individually', 'no' ); update_post_meta( $id, '_weight', '' ); update_post_meta( $id, '_length', '' ); update_post_meta( $id, '_width', '' ); update_post_meta( $id, '_height', '' ); update_post_meta( $id, '_upsell_ids', array() ); update_post_meta( $id, '_crosssell_ids', array() ); update_post_meta( $id, '_purchase_note', '' ); update_post_meta( $id, '_default_attributes', array() ); update_post_meta( $id, '_virtual', 'yes' ); update_post_meta( $id, '_downloadable', 'no' ); update_post_meta( $id, '_product_image_gallery', '' ); update_post_meta( $id, '_download_limit', '-1' ); update_post_meta( $id, '_download_expiry', '-1' ); update_post_meta( $id, '_stock', null ); update_post_meta( $id, '_stock_status', 'instock' ); update_post_meta( $id, '_wc_average_rating', '0' ); update_post_meta( $id, '_wc_rating_count', array() ); update_post_meta( $id, '_wc_review_count', '0' ); update_post_meta( $id, '_downloadable_files', array() ); update_post_meta( $id, '_track_id', esc_attr( $data['_track_id'] ) ); update_post_meta( $id, '_track_name', esc_attr( $data['_title'] ) ); update_post_meta( $id, '_track_author_name', esc_attr( $data['_author'] ) ); update_post_meta( $id, 'attribute_tracks', esc_attr( $data['_title'] ) ); do_action( 'wap_cut_track', $data['_track_id'] ); $tracks[] = $data['_title']; } $attributes['tracks'] = array( 'name' => __( 'Tracks', 'wap' ), 'value' => implode( ' | ', esc_attr( $tracks ) ), 'position' => '1', 'is_visible' => '0', 'is_variation' => '1', 'is_taxonomy' => '0' ); if( isset( $_POST['attribute_names'] ) ){ foreach ($_POST['attribute_names'] as $key => $value) { if( $value == "Tracks" ){ continue; } if( preg_match( '/^pa\_/', $value ) ){ $slug = $value; $is_tax = '1'; }else{ $slug = wc_sanitize_taxonomy_name( $value ); $is_tax = '0'; } $attributes[$slug] = array( 'name' => $value, 'value' => ( !$is_tax ? esc_attr( $_POST['attribute_values'][$key] ) : '' ), 'position' => esc_attr( $_POST['attribute_position'][$key] ), 'is_visible' => esc_attr( $_POST['attribute_visibility'][$key] ), 'is_variation' => '0', 'is_taxonomy' => $is_tax ); } } update_post_meta( $post_id, '_product_attributes', $attributes ); update_post_meta( $post_id, '_virtual', 'yes' ); update_post_meta( $post_id, '_stock_status', 'instock' ); wp_set_object_terms( $post_id, 'variable_album', 'product_type', true ); } } public function album_admin_template( $post_id ){ $arg = array( 'numberposts' => -1, 'hierarchical' => false, 'post_type' => 'product_variation', 'orderby' => 'id', 'order' => 'ASC', 'post_parent' => $post_id, ); global $thepostid; $thepostid = $post_id; $variations = get_posts( $arg ); if( $variations ){ foreach ( $variations as $key => $variation ) { include( WAP_ADMIN . '/templates/html-admin-album-variable.php' ); } } } } $wap_Admin = new wap_Admin();