| 1 |
<?php |
| 2 |
/** |
| 3 |
* HTML for the Manage Snippets page. |
| 4 |
* |
| 5 |
* @package Code_Snippets |
| 6 |
* @subpackage Views |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace Code_Snippets; |
| 10 |
|
| 11 |
/* @var Manage_Menu $this */ |
| 12 |
|
| 13 |
/* Bail if accessed directly */ |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
return; |
| 16 |
} |
| 17 |
|
| 18 |
$types = array_merge( [ 'all' => __( 'All Snippets', 'code-snippets' ) ], Plugin::get_types() ); |
| 19 |
|
| 20 |
$current_type = isset( $_GET['type'] ) ? sanitize_text_field( wp_unslash( $_GET['type'] ) ) : 'all'; |
| 21 |
$current_type = isset( $types[ $current_type ] ) ? $current_type : 'all'; |
| 22 |
|
| 23 |
?> |
| 24 |
|
| 25 |
<div class="wrap"> |
| 26 |
<h1> |
| 27 |
<?php |
| 28 |
esc_html_e( 'Snippets', 'code-snippets' ); |
| 29 |
|
| 30 |
$this->page_title_actions( code_snippets()->is_compact_menu() ? [ 'add', 'import', 'settings' ] : [ 'add', 'import' ] ); |
| 31 |
|
| 32 |
$this->list_table->search_notice(); |
| 33 |
?> |
| 34 |
</h1> |
| 35 |
|
| 36 |
<?php $this->print_messages(); ?> |
| 37 |
|
| 38 |
<h2 class="nav-tab-wrapper" id="snippet-type-tabs"> |
| 39 |
<?php |
| 40 |
|
| 41 |
foreach ( $types as $type_name => $label ) { |
| 42 |
Admin::render_snippet_type_tab( $type_name, $label, $current_type ); |
| 43 |
} |
| 44 |
|
| 45 |
?> |
| 46 |
<a class="button button-large nav-tab-button go-pro-button" href="https://codesnippets.pro/pricing/" target="_blank" |
| 47 |
title="Find more about Pro (opens in external tab)"> |
| 48 |
<?php echo wp_kses( __( 'Upgrade to <span class="badge">Pro</span>', 'code-snippets' ), [ 'span' => [ 'class' => 'badge' ] ] ); ?> |
| 49 |
<span class="dashicons dashicons-external"></span> |
| 50 |
</a> |
| 51 |
</h2> |
| 52 |
|
| 53 |
<?php |
| 54 |
$desc = code_snippets()->get_type_description( $current_type ); |
| 55 |
if ( $desc ) { |
| 56 |
echo '<p class="snippet-type-description">', esc_html( $desc ); |
| 57 |
|
| 58 |
$type_names = [ |
| 59 |
'php' => __( 'function snippets', 'code-snippets' ), |
| 60 |
'html' => __( 'content snippets', 'code-snippets' ), |
| 61 |
'css' => __( 'style snippets', 'code-snippets' ), |
| 62 |
'js' => __( 'javascript snippets', 'code-snippets' ), |
| 63 |
]; |
| 64 |
|
| 65 |
$type_names = apply_filters( 'code_snippets/admin/manage/type_names', $type_names ); |
| 66 |
|
| 67 |
/* translators: %s: snippet type name */ |
| 68 |
$learn_more_text = sprintf( __( 'Learn more about %s →', 'code-snippets' ), $type_names[ $current_type ] ); |
| 69 |
|
| 70 |
printf( |
| 71 |
' <a href="%s" target="_blank">%s</a></p>', |
| 72 |
esc_url( "https://codesnippets.pro/learn-$current_type/" ), |
| 73 |
esc_html( $learn_more_text ) |
| 74 |
); |
| 75 |
} |
| 76 |
?> |
| 77 |
|
| 78 |
<?php |
| 79 |
do_action( 'code_snippets/admin/manage/before_list_table' ); |
| 80 |
$this->list_table->views(); |
| 81 |
?> |
| 82 |
|
| 83 |
<form method="get" action=""> |
| 84 |
<?php |
| 85 |
$this->list_table->required_form_fields( 'search_box' ); |
| 86 |
$this->list_table->search_box( __( 'Search Snippets', 'code-snippets' ), 'search_id' ); |
| 87 |
?> |
| 88 |
</form> |
| 89 |
|
| 90 |
<form method="post" action=""> |
| 91 |
<input type="hidden" id="code_snippets_ajax_nonce" |
| 92 |
value="<?php echo esc_attr( wp_create_nonce( 'code_snippets_manage_ajax' ) ); ?>"> |
| 93 |
|
| 94 |
<?php |
| 95 |
$this->list_table->required_form_fields(); |
| 96 |
$this->list_table->display(); |
| 97 |
?> |
| 98 |
</form> |
| 99 |
|
| 100 |
<?php do_action( 'code_snippets/admin/manage' ); ?> |
| 101 |
</div> |
| 102 |
|