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:
OpenCode
2026-05-29 19:07:56 +08:00
commit 09ef1f000f
6521 changed files with 867163 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
/**
* HTML for the Import Snippets page.
*
* @package Code_Snippets
* @subpackage Views
*/
namespace Code_Snippets;
/**
* Loaded from import menu.
*
* @var Import_Menu $this
*/
if ( ! defined( 'ABSPATH' ) ) {
return;
}
$max_size_bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
?>
<div class="wrap">
<h1>
<?php
esc_html_e( 'Import Snippets', 'code-snippets' );
if ( code_snippets()->is_compact_menu() ) {
$this->render_page_title_actions( [ 'manage', 'add', 'settings' ] );
}
?>
</h1>
<div id="import-container"></div>
</div>

View File

@@ -0,0 +1,129 @@
<?php
/**
* HTML for the Manage Snippets page.
*
* @package Code_Snippets
* @subpackage Views
*/
namespace Code_Snippets;
use function Code_Snippets\Settings\get_setting;
/**
* Loaded from the manage menu class.
*
* @var Manage_Menu $this
*/
if ( ! defined( 'ABSPATH' ) ) {
return;
}
$types = array_merge( [ 'all' => __( 'All Snippets', 'code-snippets' ) ], Plugin::get_types() );
$current_type = $this->get_current_type();
if ( false !== strpos( code_snippets()->version, 'beta' ) ) {
echo '<div class="notice beta-test-notice"><p id="beta-testing">';
echo wp_kses(
__( 'Thank you for testing this <span class="highlight-yellow">beta version of Code Snippets</span>. We would love to hear your thoughts.', 'code-snippets' ),
[ 'span' => [ 'class' => [ 'highlight-yellow' ] ] ]
);
printf(
' <a href="%s" class="button button-secondary" target="_blank">%s</a>',
esc_url( __( 'https://codesnippets.pro/beta-testing/feedback/', 'code-snippets' ) ),
esc_html__( 'Share feedback', 'code-snippets' )
);
echo '</p></div>';
}
?>
<div class="wrap">
<h1>
<?php
esc_html_e( 'Snippets', 'code-snippets' );
$this->render_page_title_actions( code_snippets()->is_compact_menu() ? [ 'add', 'import', 'settings' ] : [ 'add', 'import' ] );
$this->list_table->search_notice();
?>
</h1>
<?php $this->print_messages(); ?>
<h2 class="nav-tab-wrapper" id="snippet-type-tabs">
<?php
Admin::render_snippet_type_tabs( $types, $current_type );
if ( ! get_setting( 'general', 'hide_upgrade_menu' ) ) { ?>
<a class="button button-large nav-tab-button nav-tab-inactive"
href="https://codesnippets.pro/pricing/" target="_blank"
aria-label="<?php esc_attr_e( 'Find more about Pro (opens in external tab)', 'code-snippets' ); ?>">
<?php echo wp_kses( __( 'Upgrade to <span class="badge pro-badge small-badge">Pro</span>', 'code-snippets' ), [ 'span' => [ 'class' => true ] ] ); ?>
<span class="dashicons dashicons-external"></span>
</a>
<?php } ?>
</h2>
<?php
$type_info = [
'php' => [
__( 'Function snippets are run on your site as if there were in a plugin or theme functions.php file.', 'code-snippets' ),
__( 'Learn more about function snippets &rarr;', 'code-snippets' ),
'https://codesnippets.pro/learn-php/',
],
'html' => [
__( 'Content snippets are bits of reusable PHP and HTML content that can be inserted into posts and pages.', 'code-snippets' ),
__( 'Learn more about content snippets &rarr;', 'code-snippets' ),
'https://codesnippets.pro/learn-html/',
],
'css' => [
__( 'Style snippets are written in CSS and loaded in the admin area or on the site front-end, just like the theme style.css.', 'code-snippets' ),
__( 'Learn more about style snippets &rarr;', 'code-snippets' ),
'https://codesnippets.pro/learn-css/',
],
'js' => [
__( 'Script snippets are loaded on the site front-end in a JavaScript file, either in the head or body sections.', 'code-snippets' ),
__( 'Learn more about javascript snippets &rarr;', 'code-snippets' ),
'https://codesnippets.pro/learn-js/',
],
'cloud' => [
__( 'See all your public and private snippets that are stored in your Code Snippet Cloud codevault.', 'code-snippets' ),
__( 'Learn more about Code Snippets Cloud &rarr;', 'code-snippets' ),
'https://codesnippets.cloud/getstarted/',
],
];
if ( isset( $type_info[ $current_type ] ) ) {
$info = $type_info[ $current_type ];
printf(
'<p class="snippet-type-description">%s <a href="%s" target="_blank">%s</a></p>',
esc_html( $info[0] ),
esc_url( $info[2] ),
esc_html( $info[1] )
);
}
do_action( 'code_snippets/admin/manage/before_list_table' );
$this->list_table->views();
switch ( $current_type ) {
case 'cloud_search':
include_once 'partials/cloud-search.php';
break;
default:
include_once 'partials/list-table.php';
break;
}
do_action( 'code_snippets/admin/manage', $current_type );
?>
</div>

View 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>

View 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 )
);
}

View 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>

View File

@@ -0,0 +1,200 @@
<?php
/**
* HTML for the welcome page.
*
* @package Code_Snippets
* @subpackage Views
*/
namespace Code_Snippets;
/**
* Loaded from the Welcome_Menu class.
*
* @var Welcome_Menu $this
*/
if ( ! defined( 'ABSPATH' ) ) {
return;
}
$hero = $this->api->get_hero_item();
$changelog_sections = [
'Added' => [
'title' => __( 'New features', 'code-snippets' ),
'icon' => 'lightbulb',
],
'Improved' => [
'title' => __( 'Improvements', 'code-snippets' ),
'icon' => 'chart-line',
],
'Fixed' => [
'title' => __( 'Bug fixes', 'code-snippets' ),
'icon' => 'buddicons-replies',
],
'Other' => [
'title' => __( 'Other', 'code-snippets' ),
'icon' => 'open-folder',
],
];
$plugin_types = [
'core' => __( 'Core', 'code-snippets' ),
'pro' => __( 'Pro', 'code-snippets' ),
];
?>
<div class="csp-welcome-wrap">
<div class="csp-welcome-header">
<header>
<img width="50px"
src="<?php echo esc_url( plugins_url( 'assets/icon.svg', PLUGIN_FILE ) ); ?>"
alt="<?php esc_attr_e( 'Code Snippets Logo', 'code-snippets' ); ?>">
<h1>
<?php echo wp_kses( __( "Resources and <span>What's New</span>", 'code-snippets' ), [ 'span' => [] ] ); ?>
</h1>
</header>
<nav>
<ul>
<?php foreach ( $this->get_header_links() as $link_name => $link_info ) { ?>
<li>
<a href="<?php echo esc_url( $link_info['url'] ); ?>" target="_blank"
class="csp-link-<?php echo esc_attr( $link_name ); ?>">
<span><?php echo esc_html( $link_info['label'] ); ?></span>
<?php if ( 'discord' === $link_info['icon'] ) { ?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 127.14 96.36">
<path d="M107.7,8.07A105.15,105.15,0,0,0,81.47,0a72.06,72.06,0,0,0-3.36,6.83A97.68,97.68,0,0,0,49,6.83,72.37,72.37,0,0,0,45.64,0,105.89,105.89,0,0,0,19.39,8.09C2.79,32.65-1.71,56.6.54,80.21h0A105.73,105.73,0,0,0,32.71,96.36,77.7,77.7,0,0,0,39.6,85.25a68.42,68.42,0,0,1-10.85-5.18c.91-.66,1.8-1.34,2.66-2a75.57,75.57,0,0,0,64.32,0c.87.71,1.76,1.39,2.66,2a68.68,68.68,0,0,1-10.87,5.19,77,77,0,0,0,6.89,11.1A105.25,105.25,0,0,0,126.6,80.22h0C129.24,52.84,122.09,29.11,107.7,8.07ZM42.45,65.69C36.18,65.69,31,60,31,53s5-12.74,11.43-12.74S54,46,53.89,53,48.84,65.69,42.45,65.69Zm42.24,0C78.41,65.69,73.25,60,73.25,53s5-12.74,11.44-12.74S96.23,46,96.12,53,91.08,65.69,84.69,65.69Z" />
</svg>
<?php } else { ?>
<span class="dashicons dashicons-<?php echo esc_attr( $link_info['icon'] ); ?>"></span>
<?php } ?>
</a>
</li>
<?php } ?>
</ul>
</nav>
</div>
<section class="csp-section-changes">
<h1>📰 <?php esc_html_e( 'Latest news', 'code-snippets' ); ?></h1>
<div class="csp-cards">
<a class="csp-card" href="<?php echo esc_url( $hero['follow_url'] ); ?>" target="_blank"
title="<?php esc_attr_e( 'Read more', 'code-snippets' ); ?>">
<header>
<span class="dashicons dashicons-external"></span>
<h2><?php echo esc_html( $hero['name'] ); ?></h2>
</header>
<figure>
<div id="csp-loading-spinner" class="csp-loading-spinner"></div>
<img id="csp-changes-img"
onload="hideLoadingAnimation()"
src="<?php echo esc_url( $hero['image_url'] ); ?>"
alt="<?php esc_attr_e( 'Latest news image', 'code-snippets' ); ?>);">
</figure>
</a>
<a class="csp-card csp-changelog-wrapper" href="https://wordpress.org/plugins/code-snippets/changelog" target="_blank"
title="<?php esc_attr_e( 'Read the full changelog', 'code-snippets' ); ?>">
<header>
<span class="dashicons dashicons-external"></span>
<h2><?php esc_html_e( 'Latest changes', 'code-snippets' ); ?></h2>
</header>
<div class="csp-section-changelog">
<?php foreach ( $this->api->get_changelog() as $version => $version_changes ) { ?>
<h3><?php echo esc_html( $version ); ?></h3>
<article>
<?php
foreach ( $changelog_sections as $section_key => $section ) {
if ( empty( $version_changes[ $section_key ] ) ) {
continue;
}
?>
<h4>
<span class="dashicons dashicons-<?php echo esc_attr( $section['icon'] ); ?>"></span>
<?php echo esc_html( $section['title'] ); ?>
</h4>
<ul>
<?php
foreach ( $plugin_types as $plugin_type => $type_label ) {
if ( empty( $version_changes[ $section_key ][ $plugin_type ] ) ) {
continue;
}
foreach ( $version_changes[ $section_key ][ $plugin_type ] as $change ) {
?>
<li>
<span class="badge <?php echo esc_attr( $plugin_type ); ?>-badge">
<?php echo esc_html( $type_label ); ?>
</span>
<span><?php echo esc_html( $change ); ?></span>
</li>
<?php
}
}
?>
</ul>
<?php } ?>
</article>
<?php } ?>
</div>
</a>
</div>
</section>
<section class="csp-section-articles csp-section-links">
<h1>🛟 <?php esc_html_e( 'Helpful articles', 'code-snippets' ); ?></h1>
<div class="csp-cards">
<?php foreach ( $this->api->get_features() as $feature ) { ?>
<a class="csp-card"
href="<?php echo esc_url( $feature['follow_url'] ); ?>" target="_blank"
title="<?php esc_attr_e( 'Read more', 'code-snippets' ); ?>">
<figure>
<img src="<?php echo esc_url( $feature['image_url'] ); ?>"
alt="<?php esc_attr_e( 'Feature image', 'code-snippets' ); ?>">
</figure>
<header>
<h2><?php echo esc_html( $feature['title'] ); ?></h2>
<p class="csp-card-item-description"><?php echo esc_html( $feature['description'] ); ?></p>
</header>
<footer>
<p class="csp-card-item-category"><?php echo esc_html( $feature['category'] ); ?></p>
<span class="dashicons dashicons-external"></span>
</footer>
</a>
<?php } ?>
</div>
</section>
<section class="csp-section-links csp-section-partners">
<h1>🚀 <?php esc_html_e( 'Partners and apps', 'code-snippets' ); ?></h1>
<div class="csp-cards">
<?php foreach ( $this->api->get_partners() as $partner ) { ?>
<a class="csp-card"
href="<?php echo esc_url( $partner['follow_url'] ); ?>" target="_blank"
title="<?php esc_attr_e( 'Go to Partner', 'code-snippets' ); ?>">
<figure>
<img src="<?php echo esc_url( $partner['image_url'] ); ?>"
alt="<?php esc_attr_e( 'Partner image', 'code-snippets' ); ?>">
</figure>
<header>
<span class="dashicons dashicons-external"></span>
<h2><?php echo esc_html( $partner['title'] ); ?></h2>
</header>
</a>
<?php } ?>
</div>
</section>
</div>
<script type="text/javascript">
function hideLoadingAnimation() {
const spinner = document.getElementById<HTMLDivElement>('csp-loading-spinner')
const image = document.getElementById<HTMLDivElement>('csp-changes-img')
spinner.style.display = 'none'
image.style.display = 'block'
}
</script>