Preview API

This is a technical summary of what is offered by our Preview API and how to create your own Preview integration.

  1. Before Preview Frame
  2. Preview is Rendering
  3. Preview Output Zone Priority

The Preview refers to the display of the page or document in Cornerstone.

Before Preview Frame

cs_before_preview_frame is the action that is fired before the Preview starts rendering. This is a useful action to hook into if you have special scripts or flags to call to better integrate into Cornerstone. The following is a sample of our WooCommerce integration that adds in the WooCommerce cart fragments.

add_action('cs_before_preview_frame', function() { if (class_exists( 'WooCommerce' )) { wp_enqueue_script( 'wc-cart-fragments' ); } });

Preview is Rendering

The checking the action cs_element_rendering will determine if you are in the preview. This can be useful if you are displaying a different look and feel to an element when the preview is where the element is being viewed.

$isPreview = did_action('cs_element_rendering');

Preview Output Zone Priority

cs_preview_output_zone_priority is the filter to change to alter the Preview content zone overwrite. Certain plugins might need to also hook into the_content and with this filter you can change that priority. The default is -9999999.

add_filter('cs_preview_output_zone_priority', function() { return 11; });

See something inaccurate? Let us know