Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function theme_enqueue_styles() {
- wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'avada-stylesheet' ) );
- }
- add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
- function avada_lang_setup() {
- $lang = get_stylesheet_directory() . '/languages';
- load_child_theme_textdomain( 'Avada', $lang );
- }
- add_action( 'after_setup_theme', 'avada_lang_setup' );
- register_sidebar( array(
- 'name' => 'After Single Post',
- 'id' => 'after-single',
- 'before_widget' => '<div>',
- 'after_widget' => '</div>',
- 'before_title' => '<h2 class="related-post-title">',
- 'after_title' => '</h2>',
- ) );
- /** Customized **/
- //remove excerpt from Product
- remove_action('woocommerce_single_product_summary','woocommerce_template_single_excerpt', 20);
- // move SKU below the price
- remove_action('woocommerce_single_product_summary','woocommerce_template_single_meta', 40);
- add_action('woocommerce_single_product_summary','woocommerce_template_single_meta', 20);
- add_filter( 'avada_blog_read_more_excerpt', 'my_read_more_symbol' );
- function my_read_more_symbol( $read_more ) {
- $read_more = "Read more";
- return $read_more;
- }
- //removing reviews tab from products page
- add_filter( 'woocommerce_product_tabs', 'wcs_woo_remove_reviews_tab', 98 );
- function wcs_woo_remove_reviews_tab($tabs) {
- unset($tabs['reviews']);
- return $tabs;
- }
- // Add Variation Settings
- add_action( 'woocommerce_product_after_variable_attributes', 'variation_settings_fields', 10, 3 );
- // Save Variation Settings
- add_action( 'woocommerce_save_product_variation', 'save_variation_settings_fields', 10, 2 );
- /**
- * Create new fields for variations
- *
- */
- function variation_settings_fields( $loop, $variation_data, $variation ) {
- // Text Field
- woocommerce_wp_text_input(
- array(
- 'id' => '_text_field[' . $variation->ID . ']',
- 'name' => 'Text Field 1',
- 'label' => __( 'My Text Field', 'woocommerce' ),
- 'placeholder' => 'http://',
- 'desc_tip' => 'true',
- 'description' => __( 'Enter the custom value here.', 'woocommerce' ),
- 'value' => get_post_meta( $variation->ID, '_text_field', true )
- )
- );
- // Number Field
- woocommerce_wp_text_input(
- array(
- 'id' => '_number_field[' . $variation->ID . ']',
- 'label' => __( 'My Number Field', 'woocommerce' ),
- 'desc_tip' => 'true',
- 'description' => __( 'Enter the custom number here.', 'woocommerce' ),
- 'value' => get_post_meta( $variation->ID, '_number_field', true ),
- 'custom_attributes' => array(
- 'step' => 'any',
- 'min' => '0'
- )
- )
- );
- // Textarea
- woocommerce_wp_textarea_input(
- array(
- 'id' => '_textarea[' . $variation->ID . ']',
- 'label' => __( 'My Textarea', 'woocommerce' ),
- 'placeholder' => '',
- 'description' => __( 'Enter the custom value here.', 'woocommerce' ),
- 'value' => get_post_meta( $variation->ID, '_textarea', true ),
- )
- );
- // Select
- woocommerce_wp_select(
- array(
- 'id' => '_select[' . $variation->ID . ']',
- 'label' => __( 'My Select Field', 'woocommerce' ),
- 'description' => __( 'Choose a value.', 'woocommerce' ),
- 'value' => get_post_meta( $variation->ID, '_select', true ),
- 'options' => array(
- 'one' => __( 'Option 1', 'woocommerce' ),
- 'two' => __( 'Option 2', 'woocommerce' ),
- 'three' => __( 'Option 3', 'woocommerce' )
- )
- )
- );
- // Checkbox
- woocommerce_wp_checkbox(
- array(
- 'id' => '_checkbox[' . $variation->ID . ']',
- 'label' => __('My Checkbox Field', 'woocommerce' ),
- 'description' => __( 'Check me!', 'woocommerce' ),
- 'value' => get_post_meta( $variation->ID, '_checkbox', true ),
- )
- );
- // Hidden field
- woocommerce_wp_hidden_input(
- array(
- 'id' => '_hidden_field[' . $variation->ID . ']',
- 'value' => 'hidden_value'
- )
- );
- }
- /**
- * Save new fields for variations
- *
- */
- function save_variation_settings_fields( $post_id ) {
- // Text Field
- $text_field = $_POST['_text_field'][ $post_id ];
- if( ! empty( $text_field ) ) {
- update_post_meta( $post_id, '_text_field', esc_attr( $text_field ) );
- }
- // Number Field
- $number_field = $_POST['_number_field'][ $post_id ];
- if( ! empty( $number_field ) ) {
- update_post_meta( $post_id, '_number_field', esc_attr( $number_field ) );
- }
- // Textarea
- $textarea = $_POST['_textarea'][ $post_id ];
- if( ! empty( $textarea ) ) {
- update_post_meta( $post_id, '_textarea', esc_attr( $textarea ) );
- }
- // Select
- $select = $_POST['_select'][ $post_id ];
- if( ! empty( $select ) ) {
- update_post_meta( $post_id, '_select', esc_attr( $select ) );
- }
- // Checkbox
- $checkbox = isset( $_POST['_checkbox'][ $post_id ] ) ? 'yes' : 'no';
- update_post_meta( $post_id, '_checkbox', $checkbox );
- // Hidden field
- $hidden = $_POST['_hidden_field'][ $post_id ];
- if( ! empty( $hidden ) ) {
- update_post_meta( $post_id, '_hidden_field', esc_attr( $hidden ) );
- }
- }
- // Add New Variation Settings
- add_filter( 'woocommerce_available_variation', 'load_variation_settings_fields' );
- /**
- * Add custom fields for variations
- *
- */
- function load_variation_settings_fields( $variations ) {
- // duplicate the line for each field
- $variations['text_field'] = get_post_meta( $variations[ 'variation_id' ], '_text_field', true );
- return $variations;
- }
- //remove the tabs
- //remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
- /** * Hook in each tabs callback function after single content. */
- //add_action( 'woocommerce_after_single_product_summary', 'woocommerce_product_description_tab' );
- //add_action( 'woocommerce_after_single_product_summary', 'woocommerce_product_additional_information_tab' );
- //add_action( 'woocommerce_after_single_product_summary', 'comments_template' );
- function woocommerce_template_single_product_summary() {
- return '<div class="test-class">This is a test to relocate some text into the product summary area</div>';
- }
- add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_single_product_summary', 10 );
- add_action( 'woocommerce_single_product_summary', '_woocommerce_single_product_summary_', 20 );
- //
- //remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
- //
- //// add them under short description
- //// note: this will need a bit of CSS customization!
- //
- //add_action( 'woocommerce_after_single_product_summary', 'woocommerce_show_product_thumbnails', 50 );
- function list_hooked_functions($tag='woocommerce_single_product_summary'){
- global $wp_filter;
- if ($tag) {
- $hook[$tag]=$wp_filter[$tag];
- if (!is_array($hook[$tag])) {
- trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
- return;
- }
- }
- else {
- $hook=$wp_filter;
- ksort($hook);
- }
- echo "<!--\n\n";
- foreach($hook as $tag => $priority){
- echo ">>>>>>>>>> $tag\n\n";
- ksort($priority);
- foreach($priority as $priority => $function){
- echo $priority;
- foreach($function as $name => $properties) echo "\t$name\n\n";
- }
- }
- echo "\n\n-->";
- return;
- }
- add_action('wp_head', 'list_hooked_functions');
Advertisement
Add Comment
Please, Sign In to add comment