Upload folder via GUI - includes

This commit is contained in:
Git Manager GUI
2026-05-11 09:17:15 +02:00
parent 85cb7ef400
commit 4c4e87c565
8 changed files with 477 additions and 0 deletions

60
includes/metaboxes.php Normal file
View File

@@ -0,0 +1,60 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
add_action( 'add_meta_boxes', 'mcn_add_metaboxes' );
function mcn_add_metaboxes() {
add_meta_box(
'mcn_news_options',
'⛏ News-Einstellungen',
'mcn_render_metabox',
'mc_news',
'side',
'high'
);
}
function mcn_render_metabox( $post ) {
wp_nonce_field( 'mcn_save_meta', 'mcn_nonce' );
$pinned = get_post_meta( $post->ID, '_mcn_pinned', true );
$badge = get_post_meta( $post->ID, '_mcn_badge', true );
$server_ip = get_post_meta( $post->ID, '_mcn_server_ip', true );
?>
<p>
<label><strong>📌 Angepinnt (immer oben)</strong></label><br>
<input type="checkbox" name="mcn_pinned" value="1" <?php checked( $pinned, '1' ); ?>>
<span>Diese News oben anzeigen</span>
</p>
<hr>
<p>
<label><strong>🏷️ Badge / Label</strong></label><br>
<select name="mcn_badge" style="width:100%">
<option value=""> Kein Badge </option>
<?php
$badges = [ 'NEU', 'WICHTIG', 'HOT', 'BETA', 'LIVE', 'BALD' ];
foreach ( $badges as $b ) {
printf( '<option value="%s" %s>%s</option>', $b, selected( $badge, $b, false ), $b );
}
?>
</select>
</p>
<hr>
<p>
<label><strong>🖥️ Server-IP (optional)</strong></label><br>
<input type="text" name="mcn_server_ip" value="<?php echo esc_attr( $server_ip ); ?>"
placeholder="play.deinserver.de" style="width:100%">
<small>Wird in der News-Karte angezeigt</small>
</p>
<?php
}
add_action( 'save_post_mc_news', 'mcn_save_metabox' );
function mcn_save_metabox( $post_id ) {
if ( ! isset( $_POST['mcn_nonce'] ) || ! wp_verify_nonce( $_POST['mcn_nonce'], 'mcn_save_meta' ) ) return;
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
if ( ! current_user_can( 'edit_post', $post_id ) ) return;
update_post_meta( $post_id, '_mcn_pinned', isset( $_POST['mcn_pinned'] ) ? '1' : '' );
update_post_meta( $post_id, '_mcn_badge', sanitize_text_field( $_POST['mcn_badge'] ?? '' ) );
update_post_meta( $post_id, '_mcn_server_ip', sanitize_text_field( $_POST['mcn_server_ip'] ?? '' ) );
}