Support » Plugin: Page Title Splitter » Conflict with Give Donation plugin call to undefined function get_current_screen

  • Resolved sanerdesign

    (@sanerdesign)


    The plugin is great but it is hooked into save_post which is used by plugins like WooCommerce and Give the donation plugin to create new orders/donations which are posts. The plugin cannot access the function get_current_screen() from the front end. There is probably a better way to fix this but for now the following worked for me.

    First remove the original hook from the plugin

    remove_action( ‘save_post’, ‘pt_splitter_save_title’ );

    Now create the replacement function but using the global $current_screen;

    function my_splitter_save_title($post_ID) {
    global $post, $current_screen;
    $screen = ( ! isset( $current_screen ) ) ? null : $current_screen;
    if($screen->base == “post”) {
    if(isset($_POST))
    update_post_meta($post_ID, ‘_pt_splitter_output’, strip_tags($_POST[‘pt-splitter-output’]));
    }
    }
    add_action( ‘save_post’, ‘my_splitter_save_title’ );

    • This topic was modified 3 years, 1 month ago by sanerdesign.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Conflict with Give Donation plugin call to undefined function get_current_screen’ is closed to new replies.