Initial commit: WordPress wp-content (themes, plugins, languages)
- Theme: momentry (custom theme with REST API routes) - Plugins: code-snippets (contains all API proxies) - Languages: zh_TW translations - Excludes: cache, backups, uploads, logs
This commit is contained in:
76
plugins/code-snippets/php/views/partials/cloud-search.php
Normal file
76
plugins/code-snippets/php/views/partials/cloud-search.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* HTML for the cloud search tab
|
||||
*
|
||||
* @package Code_Snippets
|
||||
* @subpackage Views
|
||||
*/
|
||||
|
||||
namespace Code_Snippets;
|
||||
|
||||
/**
|
||||
* Loaded from manage menu.
|
||||
*
|
||||
* @var Manage_Menu $this
|
||||
*/
|
||||
|
||||
$search_query = isset( $_REQUEST['cloud_search'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['cloud_search'] ) ) : '';
|
||||
$cloud_select = sanitize_key( wp_unslash( $_REQUEST['cloud_select'] ?? '' ) );
|
||||
|
||||
?>
|
||||
|
||||
<p class="cloud-search-info">
|
||||
<?php esc_html_e( 'Use the search bar below to search cloud snippets by entering either the name of a codevault or keywords.', 'code-snippets' ); ?>
|
||||
|
||||
<small>
|
||||
<?php esc_html_e( '(Note: codevault name is case and spelling sensitive and only public snippets will be shown)', 'code-snippets' ); ?>
|
||||
</small>
|
||||
</p>
|
||||
|
||||
<form method="get" action="" id="cloud-search-form">
|
||||
<?php List_Table::required_form_fields( 'search_box' ); ?>
|
||||
<label class="screen-reader-text" for="cloud_search">
|
||||
<?php esc_html_e( 'Search cloud snippets', 'code-snippets' ); ?>
|
||||
</label>
|
||||
<?php
|
||||
if ( isset( $_REQUEST['type'] ) ) {
|
||||
printf( '<input type="hidden" name="type" value="%s">', esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['type'] ) ) ) );
|
||||
}
|
||||
?>
|
||||
<div class="heading-box">
|
||||
<p class="cloud-search-heading">
|
||||
<label for="cloud-select-prepend"><?php esc_html_e( 'Search Cloud', 'code-snippets' ); ?></label>
|
||||
</p>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<select id="cloud-select-prepend" class="select-prepend" name="cloud_select">
|
||||
<option value="term"<?php selected( $cloud_select, 'term' ); ?>>
|
||||
<?php esc_html_e( 'Search by keyword(s)', 'code-snippets' ); ?>
|
||||
</option>
|
||||
<option value="codevault"<?php selected( $cloud_select, 'codevault' ); ?>>
|
||||
<?php esc_html_e( 'Name of codevault', 'code-snippets' ); ?>
|
||||
</option>
|
||||
</select>
|
||||
<input type="text" id="cloud_search" name="cloud_search" class="cloud_search"
|
||||
value="<?php echo esc_html( $search_query ); ?>"
|
||||
placeholder="<?php esc_attr_e( 'e.g. Remove unused javascript…', 'code-snippets' ); ?>">
|
||||
|
||||
<button type="submit" id="cloud-search-submit" class="button">
|
||||
<?php esc_html_e( 'Search Cloud', 'code-snippets' ); ?>
|
||||
<span class="dashicons dashicons-search cloud-search"></span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<form method="post" action="" id="cloud-search-results">
|
||||
<input type="hidden"
|
||||
id="code_snippets_ajax_nonce"
|
||||
value="<?php echo esc_attr( wp_create_nonce( 'code_snippets_manage_ajax' ) ); ?>">
|
||||
<?php
|
||||
List_Table::required_form_fields();
|
||||
|
||||
if ( $search_query ) {
|
||||
$this->cloud_search_list_table->display();
|
||||
}
|
||||
|
||||
?>
|
||||
</form>
|
||||
112
plugins/code-snippets/php/views/partials/list-table-notices.php
Normal file
112
plugins/code-snippets/php/views/partials/list-table-notices.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* HTML for displaying notices for the manage table.
|
||||
*
|
||||
* @package Code_Snippets
|
||||
* @subpackage Views
|
||||
*/
|
||||
|
||||
namespace Code_Snippets;
|
||||
|
||||
/**
|
||||
* Loaded from the manage menu.
|
||||
*
|
||||
* @var Manage_Menu $this
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constant existence is checked with defined().
|
||||
*
|
||||
* @noinspection PhpUndefinedConstantInspection
|
||||
*/
|
||||
if ( defined( 'CODE_SNIPPETS_SAFE_MODE' ) && CODE_SNIPPETS_SAFE_MODE ) {
|
||||
?>
|
||||
<div id="message" class="notice notice-error fade is-dismissible">
|
||||
<p>
|
||||
<strong><?php esc_html_e( 'Warning:', 'code-snippets' ); ?></strong>
|
||||
<?php
|
||||
// translators: 1: constant name, 2: file name.
|
||||
$text = __( 'Safe mode is active and snippets will not execute! Remove the %1$s constant from %2$s file to turn off safe mode.', 'code-snippets' );
|
||||
printf( esc_html( $text ), '<code>CODE_SNIPPETS_SAFE_MODE</code>', '<code>wp-config.php</code>' );
|
||||
?>
|
||||
|
||||
<a href="https://codesnippets.pro/doc/safe-mode/" target="_blank">
|
||||
<?php esc_html_e( 'Help', 'code-snippets' ); ?>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( empty( $_REQUEST['result'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$result = sanitize_key( $_REQUEST['result'] );
|
||||
|
||||
$result_messages = [
|
||||
'executed' => __( 'Snippet <strong>executed</strong>.', 'code-snippets' ),
|
||||
'activated' => __( 'Snippet <strong>activated</strong>.', 'code-snippets' ),
|
||||
'activated-multi' => __( 'Selected snippets <strong>activated</strong>.', 'code-snippets' ),
|
||||
'deactivated' => __( 'Snippet <strong>deactivated</strong>.', 'code-snippets' ),
|
||||
'deactivated-multi' => __( 'Selected snippets <strong>deactivated</strong>.', 'code-snippets' ),
|
||||
'deleted' => __( 'Snippet <strong>trashed</strong>.', 'code-snippets' ),
|
||||
'deleted-multi' => __( 'Selected snippets <strong>trashed</strong>.', 'code-snippets' ),
|
||||
'deleted_permanently' => __( 'Snippet <strong>permanently deleted</strong>.', 'code-snippets' ),
|
||||
'deleted-permanently-multi' => __( 'Selected snippets <strong>permanently deleted</strong>.', 'code-snippets' ),
|
||||
'restored' => __( 'Snippet <strong>restored</strong>.', 'code-snippets' ),
|
||||
'restored-multi' => __( 'Selected snippets <strong>restored</strong>.', 'code-snippets' ),
|
||||
'cloned' => __( 'Snippet <strong>cloned</strong>.', 'code-snippets' ),
|
||||
'cloned-multi' => __( 'Selected snippets <strong>cloned</strong>.', 'code-snippets' ),
|
||||
'cloud-refreshed' => __( 'Synced cloud data has been <strong>successfully</strong> refreshed.', 'code-snippets' ),
|
||||
];
|
||||
|
||||
// Add undo link for single snippet trash action
|
||||
if ( 'deleted' === $result && ! empty( $_REQUEST['ids'] ) ) {
|
||||
$deleted_ids = sanitize_text_field( $_REQUEST['ids'] );
|
||||
$undo_url = wp_nonce_url(
|
||||
add_query_arg(
|
||||
[
|
||||
'action' => 'restore',
|
||||
'ids' => $deleted_ids,
|
||||
]
|
||||
),
|
||||
'bulk-snippets'
|
||||
);
|
||||
|
||||
// translators: %s: Undo URL.
|
||||
$undo_message = __( 'Snippet <strong>trashed</strong>. <a href="%s">Undo</a>', 'code-snippets' );
|
||||
$result_messages['deleted'] = sprintf( $undo_message, esc_url( $undo_url ) );
|
||||
}
|
||||
|
||||
// Add undo link for bulk snippet trash action
|
||||
if ( 'deleted-multi' === $result && ! empty( $_REQUEST['ids'] ) ) {
|
||||
$deleted_ids = sanitize_text_field( $_REQUEST['ids'] );
|
||||
$undo_url = wp_nonce_url(
|
||||
add_query_arg( array(
|
||||
'action' => 'restore',
|
||||
'ids' => $deleted_ids,
|
||||
) ),
|
||||
'bulk-snippets'
|
||||
);
|
||||
|
||||
// translators: %s: Undo URL.
|
||||
$undo_message = __( 'Selected snippets <strong>trashed</strong>. <a href="%s">Undo</a>', 'code-snippets' );
|
||||
$result_messages['deleted-multi'] = sprintf( $undo_message, esc_url( $undo_url ) );
|
||||
}
|
||||
|
||||
$result_messages = apply_filters( 'code_snippets/manage/result_messages', $result_messages );
|
||||
|
||||
if ( isset( $result_messages[ $result ] ) ) {
|
||||
$result_kses = [
|
||||
'strong' => [],
|
||||
'a' => [
|
||||
'href' => [],
|
||||
],
|
||||
];
|
||||
|
||||
printf(
|
||||
'<div id="message" class="notice notice-success fade is-dismissible"><p>%s</p></div>',
|
||||
wp_kses( $result_messages[ $result ], $result_kses )
|
||||
);
|
||||
}
|
||||
33
plugins/code-snippets/php/views/partials/list-table.php
Normal file
33
plugins/code-snippets/php/views/partials/list-table.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* HTML for the all snippets and codevault list table
|
||||
*
|
||||
* @package Code_Snippets
|
||||
* @subpackage Views
|
||||
*/
|
||||
|
||||
namespace Code_Snippets;
|
||||
|
||||
/**
|
||||
* Loaded from the manage menu.
|
||||
*
|
||||
* @var Manage_Menu $this
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<form method="get" action="">
|
||||
<?php
|
||||
List_Table::required_form_fields( 'search_box' );
|
||||
$this->list_table->search_box( __( 'Search Snippets', 'code-snippets' ), 'search_id' );
|
||||
?>
|
||||
</form>
|
||||
|
||||
<form method="post" action="">
|
||||
<input type="hidden" id="code_snippets_ajax_nonce"
|
||||
value="<?php echo esc_attr( wp_create_nonce( 'code_snippets_manage_ajax' ) ); ?>">
|
||||
<?php
|
||||
List_Table::required_form_fields();
|
||||
$this->list_table->display();
|
||||
?>
|
||||
</form>
|
||||
Reference in New Issue
Block a user