Category: Php filters

  • pbs_save_style

    pbs_save_style

    A filter to modify the CSS styles being saved for a post. This is called when a save was initiated from the PBS editor.

    Parameters

    $style

    String. The CSS styles sent for saving.

    $post_id

    Int. The post id which we are saving.

  • pbs_add_builder_wrapper

    pbs_add_builder_wrapper

    PBS adds a wrapper to identify the content area of a post. This is called after the wrapper was placed.

    Parameters

    $content

    String. The post content with the wrapper applied.

  • pbs_stats_tracking

    pbs_stats_tracking

    PBS sends usage stats for opted-in users every time they save in PBS’ editor. This filter can be used to stop sending data.

    Parameters

    $true

    Boolean. This is always true.

  • pbs_localize_frontend_scripts

    pbs_localize_frontend_scripts

    Adds Javascript properties to the pbsFrontendParams object in the front-end. The pbsFrontendParams object is available in the front-end regardless when the user is logged in and editing.

    Parameters

    $params

    Array. An array of keys and values which will become available in the window-level Javascript variable pbsFrontendParams

    Example

    Make a variable accessible in the front-end

    add_filter( 'pbs_localize_frontend_scripts, 'add_my_property' );
    
    function add_my_property( $params ) {
    	
    	// This will be available in Javascript under pbsFrontendParams.myProperty
    	$params['myProperty'] = 'My Property';
    	return $params;
    }
  • pbs_localize_scripts

    pbs_localize_scripts

    Adds Javascript properties to the pbsParams object in the front-end. The pbsParams object is available in the front-end when the user is logged in and is capable of editing the page.

    This variable also carries a lot of the properties used by PBS during editing, such as nonces, a list of all loaded shortcodes, and translation strings.

    Parameters

    $params

    Array. An array of keys and values which will become available in the window-level Javascript variable pbsParams

    Example

    Add a non-detected shortcode into the editor

    add_filter( 'pbs_frontend_scripts, 'add_my_shortcode' );
    
    function add_my_shortcode( $params ) {
    	$params['shortcodes'][] = 'my_shortcode';
    	return $params;
    }
  • pbs_save_content_data

    pbs_save_content_data

    A filter to modify the post data to be saved. This is called when a save was initiated from the PBS editor.

    Parameters

    $post_data

    Array. The final post data to be saved, this is passed directly to wp_update_post() afterwards.

    $_POST

    Array. The raw post data sent from the editor for saving. This has already been nonce verified.

    $post_id

    Int. The post id which we are saving.

    Example

    add_filter( 'pbs_save_content_data', 'save_always_as_draft', 10, 3 );
    
    function save_always_as_draft( $post_data, $_post, $post_id ) {
    
    	// For some reason, we always want the post to be a draft.
    	$post_data['post_status'] = 'draft';
    	
    	return $post_data;
    }
  • pbs_save_content

    pbs_save_content

    A filter to modify the post content to be saved. This is called when a save was initiated from the PBS editor.

    Parameters

    $content

    String. The final post content to be saved.

    $post_id

    Int. The post id which we are saving.

  • pbs_is_editable_by_user

    pbs_is_editable_by_user

    PBS >= 4.3

    Override the decision whether or not to load PBS in the front-end and allow the user to use PBS to edit the post.

    Parameters

    $is_editable

    Boolean. True if the post should be editable with PBS. False otherwise

    Example

    Disallow portfolio post_types to be editable with PBS

    add_filter( 'pbs_is_editable_by_user', 'disallow_portfolios' );
    
    function disallow_portfolios( $is_editable ) {
    	global $post;
    	if ( $post ) {
    		if ( 'portfolio' === get_post_type( $post ) ) {
    			return false;
    		}
    	}
    	return $is_editable;
    }
    
  • pbs_add_builder_wrapper_pre

    pbs_add_builder_wrapper_pre

    PBS >= 4.3

    PBS adds a wrapper to identify the content area of a post. This is called before the wrapper is placed.

    Parameters

    $content

    String. The post content with the wrapper applied.

  • pbs_shortcodes_to_hide_in_picker

    pbs_shortcodes_to_hide_in_picker

    A list of shortcode tags to hide in PBS’s shortcode picker. Use this if you have shortcodes that show up in the picker popup which you have already deprecated or just want to hide from users.

    Parameters

    $shortcodes

    Array. An array of shortcode tags.

    Example

    Hide the shortcode from the picker.

    add_filter( 'pbs_shortcodes_to_hide_in_picker, 'hide_embed_shortcode' );
    
    function hide_embed_shortcode( $shortcodes ) {
    	$shortcodes[] = 'embed';
    	return $shortcodes;
    }