1

I'm struggling to remove this function line without getting a syntax error :

function product_meta_box_content( $post ) {

from the following code :

<?php 
if ( ! class_exists( 'Tax_Meta_Boxes' ) ) :
class Tax_Meta_Boxes {
    public function __construct() {
        add_action( 'save_post', array( $this, 'save_tax_meta_data' ) );
    }



    // I need to remove this function
    function product_meta_box_content( $post ) {

    ?>  

        <?php
    }

    public function save_tax_meta_data( $post_id ) {

        if ( ! isset( $_POST['post_type'] ) or $_POST['post_type'] !== 'product' ) {
            return;
        }       
    }
}
endif;

I've tried commenting the line out, removing the line, adding, removing php tags, but every single time it results in a syntax error.

I'm a little confused in the opening and closing php tags and inserting the curly brackets.

Would someone be able to point me to the right direction and point out how to correctly remove the function line ?

1 Answer 1

1

Here's your code, you just have to pay attention of where the function starts, where the php ends and again, where the php starts and the function ends.

I marked in the comments which lines can be deleted.

Also if you don't have any html content between the <? and the <?php you can remove them altogether.

<?php 
if ( ! class_exists( 'Tax_Meta_Boxes' ) ) :
class Tax_Meta_Boxes {
    public function __construct() {
        add_action( 'save_post', array( $this, 'save_tax_meta_data' ) );
    }

    // I need to get rid of this function
    // delete this - function product_meta_box_content( $post ) {

    ?> <!-- you can remove this line -->
    <!-- if there is nothing here -->
    <?php // also this one

    // delete this - }

    public function save_tax_meta_data( $post_id ) {

        if ( ! isset( $_POST['post_type'] ) or $_POST['post_type'] !== 'product' ) {
            return;
        }       
    }
}
endif;
Sign up to request clarification or add additional context in comments.

2 Comments

Alex, if I need to put in the following line : $deactive = get_post_meta( $post->ID, '_wpbo_deactive', true ); just above the public function save_tax_meta_data( $post_id ) { line now, do I need php tags there ? My syntax error is back ..
you cannot put that kind of statement inside of a class ( above the public function...) also you don't need the php tags since there is no html code that needs to be escaped

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.