| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 |
?> |
| 4 |
|
| 5 |
<h2>PHP Code</h2> |
| 6 |
|
| 7 |
<p> |
| 8 |
<?php _e('Snippets defined as shortcodes can optionally also be evaluated as PHP Code by enabling the PHP checkbox. PHP snippets is only available when treating the snippet as a shortcode.', 'post-snippets'); ?> |
| 9 |
</p> |
| 10 |
|
| 11 |
<p> |
| 12 |
<?php _e('Check this image for an example PHP snippet:', 'post-snippets'); ?> |
| 13 |
</p> |
| 14 |
|
| 15 |
<img src="<?php echo plugins_url('assets/img/help/php-snippet.jpg', \PostSnippets::FILE); ?>" /> |
| 16 |
|
| 17 |
<p> |
| 18 |
<?php _e('With a snippet defined like the one above, you can call it with its shortcode definition in a post. Let\'s pretend that the example snippet is named phpcode and have one variable defined loop_me, then it would be called like this from a post:', 'post-snippets'); ?> |
| 19 |
</p> |
| 20 |
|
| 21 |
<code>[phpcode loop_me="post snippet with PHP!"]</code> |
| 22 |
|
| 23 |
<p> |
| 24 |
<?php _e('When the shortcode is executed the loop_me variable will be replaced with the string supplied in the shortcode and then the PHP code will be evaluated. (Outputting the string five times in this case. Wow!)', 'post-snippets'); ?> |
| 25 |
</p> |
| 26 |
|
| 27 |
<p> |
| 28 |
<?php _e('Note the evaluation order, any snippet variables will be replaced before the snippet is evaluated as PHP code. Also note that a PHP snippet don\'t need to be wrapped in <?php #code; ?>.', 'post-snippets'); ?> |
| 29 |
</p> |
| 30 |
|