• Resolved SoLoGHoST

    (@sologhost)


    Looking through the broadcasting.php file, if I edit the code manually to unset the following variable $temp_post_data->post_excerpt before wp_update_post and wp_insert_post happen in the broadcast_post method, this than ignores broadcasting of the post excerpt and acts exactly how I want it to. But is there a way to edit the $bcd and remove the post_excerpt from being linked from the parent a better way, without editing the core file? Could there be an action or filter for this perhaps?

    Thanks

    • This topic was modified 2 years, 10 months ago by SoLoGHoST.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author edward_plainview

    (@edward_plainview)

    Action threewp_broadcast_broadcasting_started( $action )

    unset $action->post->post_excerpt

    Try that.

    Thread Starter SoLoGHoST

    (@sologhost)

    Ok, perhaps I’m not doing something right here. Does $action need to be globalized first or perhaps it’s a filter instead?

    add_action('threewp_broadcast_broadcasting_started', 'maybe_not_broadcast_post_excerpt', 10, 1);
    
    function maybe_not_broadcast_post_excerpt(&$action) {
    
        if ($action->post->post_type == 'product')
            unset($action->post->post_excerpt);
    }

    This code doesn’t remove post_excerpt from being broadcasted unfortunately.

    • This reply was modified 2 years, 10 months ago by SoLoGHoST.
    • This reply was modified 2 years, 10 months ago by SoLoGHoST.
    Plugin Author edward_plainview

    (@edward_plainview)

    My bad. I forgot that the post is in the broadcasting_data object.

    Try this:

    add_action('threewp_broadcast_broadcasting_started', 'maybe_not_broadcast_post_excerpt' );
    function maybe_not_broadcast_post_excerpt( $action )
    {
        if ( $action->broadcasting_data->post->post_type == 'product' )
            unset( $action->broadcasting_data->post->post_excerpt );
    }
    Thread Starter SoLoGHoST

    (@sologhost)

    That did it exactly! Wow, thanks, so just learning that when new_action method is used, it adds an action with threewp_broadcast_ and whatever parameter is added to it there. Super cool. Thanks very much for your help on this!

    Plugin Author edward_plainview

    (@edward_plainview)

    You’re welcome, me hearties!

    Thread Starter SoLoGHoST

    (@sologhost)

    And here is some code if anyone’s interested that adds an option to Exclude Post Excerpt or Product Short Description (for woocommerce products) within the Broadcast Metabox when broadcasting posts that are supported:

    add_action('threewp_broadcast_broadcasting_started', 'maybe_not_broadcast_post_excerpt');
    
    function maybe_not_broadcast_post_excerpt($action) {
        if (isset($action->broadcasting_data->_POST['broadcast'], $action->broadcasting_data->_POST['broadcast']['exclude_post_excerpt']))
            unset($action->broadcasting_data->post->post_excerpt);
    }
    
    add_action('threewp_broadcast_prepare_meta_box', 'add_option_to_exclude_post_excerpt');
    
    function add_option_to_exclude_post_excerpt($action) {
    
        $action->meta_box_data->html->put('horizontal_rule', '<hr />');
    
        $label = $action->meta_box_data->post->post_type == 'product' ? __('Exclude Product Short Description') : __('Exclude Post Excerpt');
    
        $action->meta_box_data->form->checkbox('exclude_post_excerpt')->checked(isset($action->meta_box_data->last_used_settings['exclude_post_excerpt']))->label($label)->title('Exclude Post Excerpt from being broadcasted');
        $action->meta_box_data->convert_form_input_later('exclude_post_excerpt');
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Anyway to exclude broadcasting of post_excerpt?’ is closed to new replies.