i m not very good with oop but know little bit of it.
Well i am trying to extend a class.. actually i want to add some additional functionality to class method…
This is the class, I am trying to extend
https://github.com/tammyhart/Reusable-Custom-WordPress-Meta-Boxes/blob/master/metaboxes/meta_box.php
with the following code in save_box()
method
if ( ! wp_is_post_revision( $post_id ) && 'testimonials' == get_post_type( $post_id ) ) {
remove_action( 'save_post', 'testimonials_save_post' );
wp_update_post( array(
'ID' => $post_id,
'post_title' => 'Testimonial - ' . $post_id
) );
add_action( 'save_post', 'testimonials_save_post' );
}
It’s a matter of instantiating the child class which contains only the new method. Considering the sample file:
And
my-class.php
would contain: