<?php
// This code can be used in a hook_update_n to add a custom pane to an existing display in panelizer.
// Example variables used in the code below.
$nid = 1;
$pane_machine_name = 'my_example_custom_pane';
$region = 'content';
$position = 0;
// Load the node and save its display as modified, this is required so panelizer knows there's new stuff.
$node = node_load($nid);
$node->panelizer['page_manager']->display_is_modified = TRUE;
node_save($node);
// Change the display.
$display = panels_load_display($node->panelizer['page_manager']->display->did);
$new_pane = panels_new_pane($pane_machine_name, $pane_machine_name, TRUE);
$new_pane->panel = $region;
$new_pane->position = $position;
$display->panels['main-content'][] = $new_pane->pid;
$display->content[$new_pane->pid] = $new_pane;
panels_save_display($display);