Examples

Estimated reading: 1 minute 308 views

// Filter Exported Snippets

function ps_export( $snippets )

{

  $snippets = unserialize( $snippets );

  foreach ( $snippets as &$snippet ) {

    // Do something here. Example below search and replaces in snippets

    $snippet[‘snippet’] = str_replace(‘search’,’replace’, $snippet[‘snippet’]);

  }

  return serialize( $snippets );

}

add_filter( ‘post_snippets_export’, ‘ps_export’ );

Post_snippets_import

// Filter Imported Snippets

function ps_import( $snippets )

{

  $snippets = unserialize( $snippets );

  foreach ( $snippets as &$snippet ) {

    // Do something here. Example below search and replaces in variables

    $snippet[‘vars’] = str_replace(‘search’, ‘replace’, $snippet[‘vars’]);

  }

  return serialize( $snippets );

}

add_filter( ‘post_snippets_import’, ‘ps_import’ );

Leave a Reply

Your email address will not be published. Required fields are marked *

Share this Doc

Examples

Or copy link

CONTENTS
Scroll to Top