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