1. Home
  2. Docs
  3. Pro Version Documentation
  4. Examples

Examples

// 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’ );

Was this article helpful to you? Yes No

How can we help?