WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/29/2015 12:57:35 PM (4 years ago)
Author:
obenland
Message:

Introducing Site Icon, favicon management for WordPress.

This v1 marries Jetpack's Site Icon module with the Media Modal, reusing code
from the Custom Header admin. For now, the core-provided icons will be limited
to a favicon, an iOS app icon, and a Windows tile icon, leaving .ico support
and additional icons to plugins to add.

Props obenland, tyxla, flixos90, jancbeck, markjaquith, scruffian.
See #16434.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/options-general.php

    r32974 r32994  
    124124<td><input name="blogdescription" type="text" id="blogdescription" aria-describedby="tagline-description" value="<?php form_option('blogdescription'); ?>" class="regular-text" />
    125125<p class="description" id="tagline-description"><?php _e( 'In a few words, explain what this site is about.' ) ?></p></td>
     126</tr>
     127<tr>
     128<th scope="row"><label for="site_icon"><?php _e( 'Site Icon' ); ?></label></th>
     129<td>
     130    <?php
     131    $upload_url = admin_url( 'options-general.php?page=site-icon' );
     132    $update_url = esc_url( add_query_arg( array(
     133        'page'   => 'site-icon',
     134        'action' => 'crop_site_icon',
     135    ), wp_nonce_url( admin_url( 'options-general.php' ), 'crop-site-icon' ) ) );
     136
     137    wp_enqueue_media();
     138    wp_enqueue_script( 'site-icon' );
     139
     140    if ( has_site_icon() ) :
     141        $remove_url = add_query_arg( array(
     142            'action' => 'remove_site_icon',
     143        ), wp_nonce_url( admin_url( 'options-general.php' ), 'remove-site-icon' ) );
     144    ?>
     145
     146    <img class="avatar avatar-150" src="<?php site_icon_url( null, 150 ); ?>" height="150" width="150" />
     147    <p class="hide-if-no-js">
     148        <label class="screen-reader-text" for="choose-from-library-link"><?php _e( 'Choose an image from your media library:' ); ?></label>
     149        <button type="button" id="choose-from-library-link" class="button" data-update-link="<?php echo esc_attr( $update_url ); ?>" data-choose="<?php esc_attr_e( 'Choose a Site Icon' ); ?>" data-update="<?php esc_attr_e( 'Set as Site Icon' ); ?>"><?php _e( 'Update Site Icon' ); ?></button>
     150        <a href="<?php echo esc_url( $remove_url ); ?>"><?php _e( 'Remove Site Icon' ); ?></a>
     151    </p>
     152    <p class="hide-if-js">
     153        <a href="<?php echo esc_url( $upload_url ); ?>" class="button"><?php _e( 'Update Site Icon' ); ?></a>
     154        <a href="<?php echo esc_url( $remove_url ); ?>"><?php _e( 'Remove Site Icon' ); ?></a>
     155    </p>
     156
     157    <?php else : ?>
     158
     159    <p class="hide-if-no-js">
     160        <label class="screen-reader-text" for="choose-from-library-link"><?php _e( 'Choose an image from your media library:' ); ?></label>
     161        <button type="button" id="choose-from-library-link" class="button" data-update-link="<?php echo esc_attr( $update_url ); ?>" data-choose="<?php esc_attr_e( 'Choose a Site Icon' ); ?>" data-update="<?php esc_attr_e( 'Set as Site Icon' ); ?>"><?php _e( 'Choose Image' ); ?></button>
     162    </p>
     163    <a class="button hide-if-js" href="<?php echo esc_url( $upload_url ); ?>"><?php _e( 'Add a Site Icon' ); ?></a>
     164
     165    <?php endif; ?>
     166    <p class="description"><?php _e( 'Site Icon creates a favicon and app icons for your site.' ) ?></p>
     167</td>
    126168</tr>
    127169<?php if ( !is_multisite() ) { ?>
Note: See TracChangeset for help on using the changeset viewer.