Making WordPress.org

Changeset 7174


Ignore:
Timestamp:
04/28/2018 10:23:54 AM (9 years ago)
Author:
ocean90
Message:

Rosetta: Add a list of sites without a locale association to the locale associations screen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/rosetta/inc/admin/network/class-locale-associations-view.php

    r6558 r7174  
    3838                <div class="wrap">
    3939                        <h1><?php echo esc_html( $this->get_title() ); ?></h1>
    40 
     40                        <p><?php _e( 'Manage the locale association for localized sites. Without an association the site&#8217;s front end is not available.', 'rosetta' ); ?></p>
     41                        <p><a href="#add-new-associations"><?php _e( 'Add New Association', 'rosetta' ); ?></a> | <a  href="#existing-associations"><?php _e( 'Existing Associations', 'rosetta' ); ?></a> | <a href="#sites-without-locale-association"><?php _e( 'Sites Without Locale Association', 'rosetta' ); ?></a></p>
     42                        <hr/>
    4143                        <?php
    4244                        $this->render_message();
    4345                        $this->render_form();
    4446                        $this->render_table();
     47                        $this->render_sites_without_locale();
    4548                        ?>
    4649                </div>
    … …  
    103106        private function render_form() {
    104107                ?>
    105                 <h2><?php _e( 'Add New Association', 'rosetta' ); ?></h2>
     108                <h2 id="add-new-associations"><?php _e( 'Add New Association', 'rosetta' ); ?> <a href="#wpbody-content"><small>&uarr;</small></a></h2>
    106109                <form action="" method="post">
    107110                        <?php wp_nonce_field( 'add-association' ); ?>
    … …  
    110113                        <p>
    111114                                <label for="locale"><?php _e( 'Locale:', 'rosetta' ); ?></label>
    112                                 <input type="text" id="locale" name="locale" />
     115                                <input type="text" id="locale" name="locale" class="code" />
    113116
    114117                                <label for="subdomain"><?php _e( 'Subdomain:', 'rosetta' ); ?></label>
    115                                 <input type="text" id="subdomain" name="subdomain" />
     118                                <input type="text" id="subdomain" name="subdomain" class="code" />
    116119                        </p>
    117120
    118                         <p>
     121                        <p class="submit">
    119122                                <input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Add New Association', 'rosetta' ); ?>" />
    120123                        </p>
    … …  
    128131        private function render_table() {
    129132                ?>
    130                 <h2><?php _e( 'Existing Associations', 'rosetta' ); ?></h2>
     133                <h2 id="existing-associations"><?php _e( 'Existing Associations', 'rosetta' ); ?> <a href="#wpbody-content"><small>&uarr;</small></a></h2>
    131134                <table class="widefat striped">
    132135                        <thead>
    … …  
    182185                <?php
    183186        }
     187
     188        /**
     189         * Renders a list of sites without a locale association.
     190         */
     191        public function render_sites_without_locale() {
     192                ?>
     193                <h2 id="sites-without-locale-association"><?php _e( 'Sites Without Locale Association', 'rosetta' ); ?> <a href="#wpbody-content"><small>&uarr;</small></a></h2>
     194                <?php
     195                $domains_with_locale = wp_list_pluck( $this->page->get_associations(), 'subdomain' );
     196                array_walk( $domains_with_locale, function( &$domain ) {
     197                        $domain = "$domain.wordpress.org";
     198                } );
     199
     200                $sites = get_sites( [
     201                        'network_id'     => get_current_network_id(),
     202                        'path'           => '/',
     203                        'number'         => '', // All.
     204                        'domain__not_in' => $domains_with_locale
     205                ] );
     206
     207                if ( $sites ) {
     208                        echo '<ul>';
     209                        foreach ( $sites as $site ) {
     210                                printf(
     211                                        '<li><a href="%s">%s (%s)</a></li>',
     212                                        esc_url( $site->home ),
     213                                        esc_html( $site->blogname ),
     214                                        esc_html( $site->domain . $site->path )
     215                                );
     216                        }
     217                        echo '</ul>';
     218                } else {
     219                        echo '&mdash;';
     220                }
     221        }
    184222}
Note: See TracChangeset for help on using the changeset viewer.