gravityflow_print_styles

Description

The gravityflow_print_styles filter can be used to add custom stylesheets to the print entry screen.

Parameters

ParameterTypeDetails
$valueArray or BooleanAn array of stylesheets to be enqueued for the printed page
Defaults to false.
$entry_idsArrayAn array of entry ID(s) that are selected for print.

Examples

Add a custom stylesheet from the current theme directory based on form

This snippet adds the custom stylesheet print_entry.css which is located in the current theme directory to the print entry page when the form id for one of the selected entry(ies) is 13.

add_filter( 'gravityflow_print_styles', 'add_styles', 10, 2 );
function add_styles( $value, $entry_ids ) {
    $customize = false;
    if ( ! empty( $entry_ids ) ) {
        foreach ( $entry_ids as $entry_id ) {
            $entry = GFAPI::get_entry( $entry_id );
            //If you want to check for multiple form IDs use: if ( ! in_array( $form['id'], array( '13', '7', '12') ) ) {	
            if ( $entry['form_id'] == '13' ) {
                $customize = true;
            }
        }
    }
    if ( $customize ) {
        wp_register_style( 'print_entry', get_stylesheet_directory_uri() . '/print_entry.css' );      
        return array( 'print_entry' ); 
    }
    return $value;
}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?