Making WordPress.org

Changeset 1765


Ignore:
Timestamp:
07/21/2015 09:29:35 AM (9 years ago)
Author:
Otto42
Message:

Add author metabox for theme-owner override. Uses user-ID number for now, for testing. TODO Change to search for entered usernames instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r1572 r1765  
    223223}
    224224
     225
     226add_action( 'add_meta_boxes', 'wporg_themes_author_metabox_override', 10, 2 );
     227function wporg_themes_author_metabox_override( $post_type, $post ) {
     228    if ( $post_type != 'repopackage' ) {
     229        return;
     230    }
     231    if ( post_type_supports($post_type, 'author') ) {
     232        if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) {
     233            remove_meta_box( 'authordiv', null, 'normal' );
     234            add_meta_box('authordiv', __('Author'), 'wporg_themes_post_author_meta_box', null, 'normal');
     235        }
     236    }
     237}
     238
     239// Replacement for the core function post_author_meta_box
     240function wporg_themes_post_author_meta_box( $post ) {
     241    global $user_ID;
     242?>
     243<label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label>
     244<?php
     245/*
     246    wp_dropdown_users( array(
     247        'who' => 'authors',
     248        'name' => 'post_author_override',
     249        'selected' => empty($post->ID) ? $user_ID : $post->post_author,
     250        'include_selected' => true
     251    ) );
     252*/
     253    $value = empty($post->ID) ? $user_ID : $post->post_author;
     254    echo "<input type='text' name='post_author_override' value='{$value}' />";
     255}
     256
     257
    225258/* UPDATING THEME VERSIONS */
    226259
Note: See TracChangeset for help on using the changeset viewer.