'clanfront_applicant', 'post_status' => 'publish', 'posts_per_page' => 1, 'fields' => 'ids', 'meta_key' => 'clanfront_app_status', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- a small inbox. 'meta_value' => 'new', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- a small inbox. ) ); return (int) $q->found_posts; } add_action( 'admin_menu', function () { add_menu_page( 'Clanfront', 'Clanfront', 'edit_posts', CLANFRONT_MENU, '', 'dashicons-shield', 26 ); add_submenu_page( CLANFRONT_MENU, 'Clanfront settings', 'Settings', 'manage_options', 'clanfront-settings', 'clanfront_render_settings', 20 ); }, 9 ); // Menu order: Matches & events, News, Members, Medals, Games, Hall of Shame, History, Tournaments, Gallery, Game servers, Applications (with a count), Settings, Getting started. add_action( 'admin_menu', function () { global $submenu; if ( empty( $submenu[ CLANFRONT_MENU ] ) ) { return; } $wanted = array( CLANFRONT_MENU, 'edit.php?post_type=clanfront_news', 'edit.php?post_type=clanfront_member', 'edit.php?post_type=clanfront_award', 'edit.php?post_type=clanfront_game', 'edit.php?post_type=clanfront_shame', 'edit.php?post_type=clanfront_milestone', 'edit.php?post_type=clanfront_tourney', 'edit.php?post_type=clanfront_media', 'edit.php?post_type=clanfront_server', 'edit.php?post_type=clanfront_applicant', 'clanfront-settings', 'clanfront-guide', ); $by_slug = array(); foreach ( $submenu[ CLANFRONT_MENU ] as $item ) { $by_slug[ $item[2] ] = $item; } $items = array(); foreach ( $wanted as $slug ) { if ( isset( $by_slug[ $slug ] ) ) { $item = $by_slug[ $slug ]; if ( 'edit.php?post_type=clanfront_applicant' === $slug ) { $n = clanfront_new_application_count(); if ( $n ) { $item[0] .= ' ' . (int) $n . ''; } } $items[] = $item; } } $submenu[ CLANFRONT_MENU ] = $items; // phpcs:ignore WordPress.WP.GlobalVariablesOverride }, 999 ); /* ---------- Settings ---------- */ add_action( 'admin_init', function () { register_setting( 'clanfront_settings_group', 'clanfront_settings', array( 'sanitize_callback' => 'clanfront_sanitize_settings' ) ); } ); function clanfront_sanitize_settings( $in ) { $out = clanfront_default_settings(); $in = is_array( $in ) ? $in : array(); $text = array( 'clan_name', 'tagline', 'join_label', 'twitch_client_id', 'twitch_client_secret', 'support_label' ); $urls = array( 'logo', 'hero_image', 'hero_video', 'application_url', 'discord_invite', 'instagram', 'x', 'youtube_channel', 'tiktok', 'twitch_channel', 'support_url' ); $emails = array( 'email', 'application_email' ); $checks = array( 'recruiting', 'show_tournaments', 'twitch_videos' ); foreach ( $out as $key => $default ) { $v = isset( $in[ $key ] ) ? $in[ $key ] : ''; if ( ! is_scalar( $v ) ) { $v = ''; } $v = trim( (string) $v, " \n\r\t\v\x00" ); if ( 'min_age' === $key ) { $out[ $key ] = min( 99, absint( $v ) ); } elseif ( in_array( $key, $emails, true ) ) { $out[ $key ] = sanitize_email( $v ); } elseif ( 'color' === $key ) { $color = sanitize_hex_color( $v ); $out[ $key ] = $color ? $color : $default; } elseif ( 'layout' === $key ) { $out[ $key ] = 'full' === $v ? 'full' : 'centered'; } elseif ( in_array( $key, $checks, true ) ) { $out[ $key ] = '1' === $v ? '1' : '0'; } elseif ( 'discord_server_id' === $key ) { $out[ $key ] = preg_match( '/^\d{15,25}$/', $v ) ? $v : ''; } elseif ( in_array( $key, clanfront_textarea_keys(), true ) ) { $out[ $key ] = sanitize_textarea_field( $v ); } elseif ( in_array( $key, $text, true ) ) { $out[ $key ] = sanitize_text_field( $v ); } elseif ( in_array( $key, $urls, true ) ) { $out[ $key ] = clanfront_clean_url( $v ); } else { $out[ $key ] = sanitize_text_field( $v ); } } if ( '' === $out['clan_name'] ) { $defaults = clanfront_default_settings(); $out['clan_name'] = $defaults['clan_name']; } // A changed Twitch key or channel must not keep using old saved answers. clanfront_twitch_clear_cache(); return $out; } add_action( 'admin_enqueue_scripts', function ( $hook ) { $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; $own_post = $screen && 0 === strpos( (string) $screen->post_type, 'clanfront_' ); $own_page = false !== strpos( $hook, 'clanfront' ); if ( $own_post || $own_page ) { wp_enqueue_style( 'clanfront-admin', CLANFRONT_URL . 'assets/admin.css', array(), CLANFRONT_VERSION ); wp_enqueue_script( 'clanfront-admin', CLANFRONT_URL . 'assets/admin.js', array( 'jquery' ), CLANFRONT_VERSION, true ); } if ( false !== strpos( $hook, 'clanfront-settings' ) ) { wp_enqueue_media(); } if ( 'widgets.php' === $hook ) { wp_enqueue_script( 'clanfront-widgets-fix', CLANFRONT_URL . 'assets/widgets-fix.js', array( 'wp-dom-ready', 'wp-plugins' ), CLANFRONT_VERSION, true ); } } ); /** Ready-made accent colours offered next to the colour pickers: name => #rrggbb. */ function clanfront_color_presets() { return array( 'Blaze orange' => '#ff6a00', 'Ember red' => '#e5383b', 'Blood red' => '#b5121b', 'Hot pink' => '#e0457b', 'Violet' => '#7c5cff', 'Cobalt blue' => '#3d6bff', 'Ice blue' => '#2fb4ff', 'Teal' => '#14b8a6', 'Toxic green' => '#39e75f', 'Olive drab' => '#8a9a3b', 'Gold' => '#f2c230', 'Desert sand' => '#d2a86b', 'Steel grey' => '#9aa3ad', 'Arctic white' => '#e9e8ee', ); } /** A row of clickable colour swatches that fill in the colour picker with this id. */ function clanfront_color_swatches( $target_id ) { echo '
' . esc_html( $help ) . '
' : '' ); } function clanfront_settings_textarea( $key, $label, $rows = 4, $help = '', $placeholder = '' ) { $s = clanfront_settings(); printf( '' . esc_html( $help ) . '
' : '' ); } function clanfront_settings_check( $key, $label, $help = '' ) { $s = clanfront_settings(); printf( '' . esc_html( $help ) . '
' : '' ); } function clanfront_games_datalist() { echo ''; } function clanfront_member_box( $post ) { wp_nonce_field( 'clanfront_save', 'clanfront_nonce' ); $active = get_post_meta( $post->ID, 'clanfront_active', true ); if ( '' === $active ) { $active = '1'; } ?>Their own colour for the line under their picture on hover, and on their profile page. Click a ready-made colour or pick any colour; that switches off "Use the clan colour" for you.
Untick to hide someone without deleting them. The order on the roster follows Order under Page Attributes: lower numbers first, so give leaders 1, 2, 3.
The large text box above is the member's bio. Set the picture in the Member picture box on the right; a square image works best.
ID, 'clanfront_kind', true ); $kind = $kind ? $kind : 'match'; $res = (string) get_post_meta( $post->ID, 'clanfront_result', true ); ?>Fill in after the match. Only played matches with a result count towards the win/loss record.
Shown on the event page: map, lineup, how to join, anything useful.
| %s | %s |
|---|---|
| Received | %s |
Only you and other admins see this. Answers cannot be edited. To remove someone's data, move the application to the Bin and delete it permanently.
Clanfront is set up. An example clan, members, matches and pages are ready. Start with Settings and the Getting started guide, then view the site.