| 1 |
<?php |
| 2 |
/** |
| 3 |
* HTML for the snippet scope selector. |
| 4 |
* |
| 5 |
* @package Code_Snippets |
| 6 |
* @subpackage Views |
| 7 |
* |
| 8 |
* @var Edit_Menu $this |
| 9 |
*/ |
| 10 |
|
| 11 |
namespace Code_Snippets; |
| 12 |
|
| 13 |
$snippet = $this->snippet; |
| 14 |
|
| 15 |
|
| 16 |
echo '<h2 class="screen-reader-text">', esc_html__( 'Scope', 'code-snippets' ), '</h2>'; |
| 17 |
|
| 18 |
if ( ! $snippet->id || 'php' === $snippet->type ) { |
| 19 |
echo '<p class="snippet-scope php-scopes-list">'; |
| 20 |
|
| 21 |
$this->print_scopes_list( |
| 22 |
array( |
| 23 |
'global' => __( 'Run snippet everywhere', 'code-snippets' ), |
| 24 |
'admin' => __( 'Only run in administration area', 'code-snippets' ), |
| 25 |
'front-end' => __( 'Only run on site front-end', 'code-snippets' ), |
| 26 |
'single-use' => __( 'Only run once', 'code-snippets' ), |
| 27 |
) |
| 28 |
); |
| 29 |
|
| 30 |
echo '</p>'; |
| 31 |
} |
| 32 |
|
| 33 |
if ( ! $snippet->id || 'css' === $snippet->type ) { |
| 34 |
echo '<p class="snippet-scope css-scopes-list">'; |
| 35 |
|
| 36 |
$this->print_scopes_list( |
| 37 |
array( |
| 38 |
'site-css' => __( 'Site front-end styles', 'code-snippets' ), |
| 39 |
'admin-css' => __( 'Administration area styles', 'code-snippets' ), |
| 40 |
) |
| 41 |
); |
| 42 |
|
| 43 |
echo '</p>'; |
| 44 |
} |
| 45 |
|
| 46 |
if ( ! $snippet->id || 'js' === $snippet->type ) { |
| 47 |
echo '<p class="snippet-scope js-scopes-list">'; |
| 48 |
|
| 49 |
$this->print_scopes_list( |
| 50 |
array( |
| 51 |
'site-footer-js' => __( 'Load JS at the end of the <body> section', 'code-snippets' ), |
| 52 |
'site-head-js' => __( 'Load JS in the <head> section', 'code-snippets' ), |
| 53 |
) |
| 54 |
); |
| 55 |
|
| 56 |
echo '</p>'; |
| 57 |
} |
| 58 |
|
| 59 |
if ( ! $snippet->id || 'html' === $snippet->type ) { |
| 60 |
?> |
| 61 |
<div class="snippet-scope html-scopes-list"> |
| 62 |
<p> |
| 63 |
<?php |
| 64 |
$this->print_scopes_list( |
| 65 |
array( |
| 66 |
'content' => __( 'Only display when inserted into a post or page.', 'code-snippets' ), |
| 67 |
) |
| 68 |
); |
| 69 |
?> |
| 70 |
</p> |
| 71 |
|
| 72 |
<?php |
| 73 |
if ( ! $snippet->id || 'content' === $snippet->scope ) { |
| 74 |
/* translators: %s: snippet shortcode tag */ |
| 75 |
$text = $snippet->id ? __( 'You can use the %s shortcode to insert your content into a post or page.', 'code-snippets' ) : __( 'After saving, you will be able to use the %s shortcode to insert your content into a post or page.', 'code-snippets' ); |
| 76 |
|
| 77 |
$shortcode_atts = ( $snippet->id ? ' id=' . $snippet->id : '' ) . ( $snippet->network ? ' network=true' : '' ); |
| 78 |
|
| 79 |
if ( false !== stripos( $snippet->code, '<?' ) ) { |
| 80 |
$shortcode_atts .= ' php=true'; |
| 81 |
} |
| 82 |
|
| 83 |
printf( '<p>' . esc_html( $text ) . '</p>', |
| 84 |
'<code class="shortcode-tag">[code_snippet' . esc_html( $shortcode_atts ) . ']</code>' |
| 85 |
); |
| 86 |
|
| 87 |
if ( $snippet->id ) { ?> |
| 88 |
<p class="html-shortcode-options"> |
| 89 |
<strong><?php esc_html_e( 'Shortcode Options: ', 'code-snippets' ); ?></strong> |
| 90 |
<label> |
| 91 |
<input type="checkbox" |
| 92 |
value="php"<?php checked( false !== stripos( $snippet->code, '<?' ) ); ?>> |
| 93 |
<?php esc_html_e( 'Evaluate PHP code', 'code-snippets' ); ?> |
| 94 |
</label> |
| 95 |
<label> |
| 96 |
<input type="checkbox" value="format"> |
| 97 |
<?php esc_html_e( 'Add paragraphs and formatting', 'code-snippets' ); ?> |
| 98 |
</label> |
| 99 |
<label> |
| 100 |
<input type="checkbox" value="shortcodes"> |
| 101 |
<?php esc_html_e( 'Evaluate additional shortcode tags', 'code-snippets' ); ?> |
| 102 |
</label> |
| 103 |
</p> |
| 104 |
<?php } |
| 105 |
} ?> |
| 106 |
</div> |
| 107 |
<?php } |
| 108 |
|