Advanced (for developers)

Estimated reading: 1 minute 348 views

You can add constants to wp-config.php or the theme’s functions.php file to control some aspects of the plugin. Available constants to set are:

// Allow users with edit_posts capability access to the Post Snippets admin.

define(‘POST_SNIPPETS_ALLOW_EDIT_POSTS’, true);


// Disable PHP Execution in snippets and removes the options from admin.

define(‘POST_SNIPPETS_DISABLE_PHP’, true);

You can retrieve a Post Snippet directly from PHP, in a theme, for instance, by using the PostSnippets::getSnippet() method.

Usage

<?php $my_snippet = PostSnippets::getSnippet( $snippet_name, $snippet_vars ); ?>

Parameters

$snippet_name

(string) (required) The name of the snippet to retrieve.

$snippet_vars

(string) The variables to pass to the snippet, formatted as a query string.

Example

// Use query string for variables

$mySnippet = PostSnippets::getSnippet(‘internal-link’, ‘title=Awesome&url=2011/02/awesome/’);

echo $mySnippet;

// Use array for variables

$mySnippet = PostSnippets::getSnippet(‘internal-link’, array(‘title’ => ‘Awesome’, ‘url’ => ‘2011/02/awesome/’);

echo $mySnippet;

Leave a Reply

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

Share this Doc

Advanced (for developers)

Or copy link

CONTENTS
Scroll to Top