| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 |
?> |
| 4 |
|
| 5 |
<h2><?php _e('Advanced', 'post-snippets'); ?> (<em><?php _e('for developers', 'post-snippets'); ?></em>)</h2> |
| 6 |
|
| 7 |
<p> |
| 8 |
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: |
| 9 |
</p> |
| 10 |
|
| 11 |
<pre><code>// Allow users with edit_posts capability access to the Post Snippets admin. |
| 12 |
define('POST_SNIPPETS_ALLOW_EDIT_POSTS', true); |
| 13 |
|
| 14 |
// Disable PHP Execution in snippets, and removes the options from admin. |
| 15 |
define('POST_SNIPPETS_DISABLE_PHP', true); |
| 16 |
</code></pre> |
| 17 |
|
| 18 |
<p> |
| 19 |
<?php _e('You can retrieve a Post Snippet directly from PHP, in a theme for instance, by using the PostSnippets::getSnippet() method.', 'post-snippets'); ?> |
| 20 |
</p> |
| 21 |
|
| 22 |
<h2><?php _e('Usage', 'post-snippets'); ?></h2> |
| 23 |
<p> |
| 24 |
<code> |
| 25 |
<?php $my_snippet = PostSnippets::getSnippet( $snippet_name, $snippet_vars ); ?> |
| 26 |
</code></p> |
| 27 |
|
| 28 |
<h2><?php _e('Parameters', 'post-snippets'); ?></h2> |
| 29 |
<p> |
| 30 |
<strong>$snippet_name</strong><br/> |
| 31 |
<?php _e('(string) (required) The name of the snippet to retrieve.', 'post-snippets'); ?> |
| 32 |
<br/><br/> |
| 33 |
<strong>$snippet_vars</strong><br/> |
| 34 |
<?php _e('(string) The variables to pass to the snippet, formatted as a query string.', 'post-snippets'); ?> |
| 35 |
</p> |
| 36 |
|
| 37 |
|
| 38 |
<h2><?php _e('Example', 'post-snippets'); ?></h2> |
| 39 |
|
| 40 |
<pre><code>// Use querystring for variables |
| 41 |
$mySnippet = PostSnippets::getSnippet('internal-link', 'title=Awesome&url=2011/02/awesome/'); |
| 42 |
echo $mySnippet; |
| 43 |
|
| 44 |
// Use array for variables |
| 45 |
$mySnippet = PostSnippets::getSnippet('internal-link', array('title' => 'Awesome', 'url' => '2011/02/awesome/'); |
| 46 |
echo $mySnippet;</code></pre> |
| 47 |
|