Make WordPress Core

Ticket #16434: 16434.diff

File 16434.diff, 6.3 KB (added by jorbin, 13 years ago)
  • wp-includes/functions.php

     
    17751775                'png' => 'image/png',
    17761776                'bmp' => 'image/bmp',
    17771777                'tif|tiff' => 'image/tiff',
    1778                 'ico' => 'image/x-icon',
     1778                'ico' => 'image/vnd.microsoft.icon',
    17791779                'asf|asx|wax|wmv|wmx' => 'video/asf',
    17801780                'avi' => 'video/avi',
    17811781                'divx' => 'video/divx',
  • wp-includes/general-template.php

     
    15871587}
    15881588
    15891589/**
     1590 * Convenience function that echoes the HTML for the site's favicon icon.
     1591 * By default, automatically included in the header via the 'wp_head' action, which can be removed by themes if a custom favicon is desired.
     1592 *
     1593 * @uses generate_site_favicon_html() to do the actual heavy lifting
     1594 */
     1595function site_favicon(){
     1596        echo generate_site_favicon_html();
     1597}
     1598add_action( 'wp_head', 'site_favicon' );
     1599add_action( 'admin_head', 'site_favicon' );
     1600
     1601/**
     1602 * Return the HTML for the site's favicon icon, if such has been defined.
     1603 *
     1604 * @uses get_site_favicon_uri();
     1605 *
     1606 * Includes the conditional tag wrapper for an IE (.ico) version.
     1607 */
     1608function generate_site_favicon_html() {
     1609        $ie_favicon_uri = get_site_favicon_uri( 'ico' );
     1610        $favicon_uri = get_site_favicon_uri();
     1611
     1612        $content = "";
     1613        if (! is_wp_error( $ie_favicon_uri ) && ! is_wp_error( $favicon_uri ) ){
     1614
     1615                $content .= <<<FAVICON_HTML
     1616<!--Favicon (via 'wp_head' action) -->
     1617<!--[if IE]>
     1618<link rel="shortcut icon" href="{$ie_favicon_uri}" />
     1619<![endif]-->
     1620<!--[if !IE]>-->
     1621<link href="{$favicon_uri}" rel="icon" type="image/png" />
     1622<!--<![endif]-->
     1623FAVICON_HTML;
     1624    }
     1625        return $content;
     1626}
     1627
     1628/**
     1629 * Returns the URI for the site's favicon based on the option set in  Admin > Settings > General.
     1630 *
     1631 * @param string $format png|ico default 'png'. Use 'ico' for serving up an IE-compatible ICO file
     1632 * @return mixed WP_Error | fully qualified URI
     1633 */
     1634function get_site_favicon_uri( $format = 'png' ){
     1635        /** @TODO provide error checking for validity of $format and $size */
     1636        //return site_url( '/wp-content/uploads/2012/02/wp-favicon_' . $size . 'x' . $size . '.' . $format );
     1637        $error = null;
     1638
     1639        $favicon_basename = get_option ( 'sitefavicon' );
     1640        if ( ! empty( $favicon_basename ) ) {
     1641                $favicon_fullname = $favicon_basename . '-' . $format;
     1642               
     1643                $posts = get_posts( array( 'name' => $favicon_fullname, 'post_type' => 'attachment' ) );
     1644                if ( $posts[0] ){
     1645                        $favicon_file = wp_get_attachment_url( $posts[0]->ID );
     1646                                return $favicon_file ;
     1647                } else {
     1648                        $error = new WP_Error( 'attachment_missing', __( "Favicon file '$favicon_fullname' not found." ) );
     1649                }
     1650        } else {
     1651                $error = new WP_Error( 'no_icon', __( "No favicon file provided." ) );
     1652        }
     1653
     1654        // We get here because of an error condition
     1655        /** @TODO default to the theme's favicon **/
     1656        return $error;
     1657}
     1658
     1659/**
    15901660 * Display the links to the general feeds.
    15911661 *
    15921662 * @since 2.8.0
  • wp-includes/script-loader.php

     
    8888
    8989        $scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), false, 1 );
    9090
     91        $scripts->add( 'wp-favicon', "/wp-admin/js/wp-favicon$suffix.js", array('jquery'), false, 1 );
     92
    9193        $scripts->add( 'prototype', '/wp-includes/js/prototype.js', array(), '1.6.1');
    9294
    9395        $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), false, 1 );
  • wp-admin/js/wp-favicon.dev.js

     
     1(function($){
     2    $('#faviconfile').change(function(){
     3        // check the file extention
     4        if (! $.inArray( $(this).val().split('.').pop().toLowerCase() , /* valid file extentions */ ['gif','png','jpg','jpeg'] ) )
     5            $('#favicon-invalid-filetype').show();
     6        else
     7        {
     8            $('#faviconupload').submit();
     9        }
     10    });
     11
     12})(jQuery);
  • wp-admin/js/wp-favicon.js

     
     1(function($){
     2    $('#faviconfile').change(function(){
     3        // check the file extention
     4        if (! $.inArray( $(this).val().split('.').pop().toLowerCase() , /* valid file extentions */ ['gif','png','jpg','jpeg'] ) )
     5            $('#favicon-invalid-filetype').show();
     6        else
     7        {
     8            $('#faviconupload').submit();
     9        }
     10    });
     11
     12})(jQuery);
  • wp-admin/options-general.php

     
    8181        '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    8282);
    8383
     84wp_enqueue_script('wp-favicon');
     85
    8486include('./admin-header.php');
    8587?>
    8688
     
    8890<?php screen_icon(); ?>
    8991<h2><?php echo esc_html( $title ); ?></h2>
    9092
     93<form action="<?php echo admin_url('favicon-upload.php')?>" method="post" enctype="multipart/form-data" id="faviconupload">
     94        <input type="hidden" name="action" value="wp_upload_favicon" />
     95
     96        <table class="form-table">
     97                <tr valign="top">
     98                        <th scope="row"><label for="sitefavicon"><?php _e('Favicon') ?></label></th>
     99                        <td>
     100                                <?php //echo generate_media_thumbnail_link( 'options-general-favicon', 0,  __( 'Upload favicon image' ) ); ?>
     101                                <input class="button" name="avatarfile" type="file" id="faviconfile" size="20" />
     102                                <p class="submit no-js hide-if-js"><input type="submit" name="Submit" value="Upload Image &raquo;" id="faviconsubmit" /></p>
     103                                <span class="description no-js"><?php _e('Click to upload your own custom icon ("favicon") for your blog. You\'ll be able to crop and scale it once it\'s uploaded.') ?></span>
     104                        </td>
     105                </tr>
     106        </table>
     107</form>
     108
     109
    91110<form method="post" action="options.php">
    92111<?php settings_fields('general'); ?>
    93112