| | 9 | add_action( 'media_buttons', 'media_buttons' ); |
| | 10 | |
| | 11 | add_filter( 'async_upload_image', 'get_media_item', 10, 2 ); |
| | 12 | add_filter( 'async_upload_audio', 'get_media_item', 10, 2 ); |
| | 13 | add_filter( 'async_upload_video', 'get_media_item', 10, 2 ); |
| | 14 | add_filter( 'async_upload_file', 'get_media_item', 10, 2 ); |
| | 15 | |
| | 16 | add_action( 'media_upload_image', 'wp_media_upload_handler' ); |
| | 17 | add_action( 'media_upload_audio', 'wp_media_upload_handler' ); |
| | 18 | add_action( 'media_upload_video', 'wp_media_upload_handler' ); |
| | 19 | add_action( 'media_upload_file', 'wp_media_upload_handler' ); |
| | 20 | |
| | 21 | add_filter( 'media_upload_gallery', 'media_upload_iframe' ); |
| | 22 | add_filter( 'media_upload_library', 'media_upload_iframe' ); |
| | 23 | |
| | 24 | add_filter( 'media_upload_tabs', 'update_gallery_tab'); |
| | 25 | add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 ); |
| | 26 | |
| | 27 | |
| 1419 | | function media_upload_type_form($type = 'file', $errors = null, $id = null) { |
| 1420 | | |
| 1421 | | media_upload_header(); |
| 1422 | | |
| 1423 | | $post_id = isset( $_REQUEST['post_id'] )? intval( $_REQUEST['post_id'] ) : 0; |
| 1424 | | |
| 1425 | | $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); |
| 1426 | | $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); |
| 1427 | | $form_class = 'media-upload-form type-form validate'; |
| 1428 | | |
| 1429 | | if ( get_user_setting('uploader') ) |
| 1430 | | $form_class .= ' html-uploader'; |
| 1431 | | ?> |
| 1432 | | |
| 1433 | | <form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form"> |
| 1434 | | <?php submit_button( '', 'hidden', 'save', false ); ?> |
| 1435 | | <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
| 1436 | | <?php wp_nonce_field('media-form'); ?> |
| 1437 | | |
| 1438 | | <h3 class="media-title"><?php _e('Add media files from your computer'); ?></h3> |
| 1439 | | |
| 1440 | | <?php media_upload_form( $errors ); ?> |
| 1441 | | |
| 1442 | | <script type="text/javascript"> |
| 1443 | | //<![CDATA[ |
| 1444 | | jQuery(function($){ |
| 1445 | | var preloaded = $(".media-item.preloaded"); |
| 1446 | | if ( preloaded.length > 0 ) { |
| 1447 | | preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); |
| 1448 | | } |
| 1449 | | updateMediaForm(); |
| 1450 | | }); |
| 1451 | | //]]> |
| 1452 | | </script> |
| 1453 | | <div id="media-items"><?php |
| 1454 | | |
| 1455 | | if ( $id ) { |
| 1456 | | if ( !is_wp_error($id) ) { |
| 1457 | | add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); |
| 1458 | | echo get_media_items( $id, $errors ); |
| 1459 | | } else { |
| 1460 | | echo '<div id="media-upload-error">'.esc_html($id->get_error_message()).'</div></div>'; |
| 1461 | | exit; |
| 1462 | | } |
| | 1450 | function media_upload_type_form($type = 'image', $errors = null, $id = null) { |
| | 1451 | media_upload_form_html( $type, $errors, $id); |
| 1518 | | if ( f.title.value ) { |
| 1519 | | title = f.title.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); |
| 1520 | | title = ' title="'+title+'"'; |
| | 1554 | <p id="media-search" class="search-box"> |
| | 1555 | <label class="screen-reader-text" for="media-search-input"><?php _e('Search Media');?>:</label> |
| | 1556 | <input type="search" id="media-search-input" name="s" value="<?php the_search_query(); ?>" /> |
| | 1557 | <?php submit_button( __( 'Search Media' ), 'button', '', false ); ?> |
| | 1558 | </p> |
| | 1559 | |
| | 1560 | <ul class="subsubsub"> |
| | 1561 | <?php |
| | 1562 | $type_links = array(); |
| | 1563 | $_num_posts = (array) wp_count_attachments(); |
| | 1564 | $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); |
| | 1565 | foreach ( $matches as $_type => $reals ) |
| | 1566 | foreach ( $reals as $real ) |
| | 1567 | if ( isset($num_posts[$_type]) ) |
| | 1568 | $num_posts[$_type] += $_num_posts[$real]; |
| | 1569 | else |
| | 1570 | $num_posts[$_type] = $_num_posts[$real]; |
| | 1571 | // If available type specified by media button clicked, filter by that type |
| | 1572 | if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) { |
| | 1573 | $_GET['post_mime_type'] = $type; |
| | 1574 | list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); |
| 1522 | | |
| 1523 | | if ( f.alt.value ) |
| 1524 | | alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); |
| 1525 | | |
| 1526 | | <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?> |
| 1527 | | if ( f.caption.value ) { |
| 1528 | | caption = f.caption.value.replace(/\r\n|\r/g, '\n'); |
| 1529 | | caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){ |
| 1530 | | return a.replace(/[\r\n\t]+/, ' '); |
| 1531 | | }); |
| 1532 | | |
| 1533 | | caption = caption.replace(/\s*\n\s*/g, '<br />'); |
| | 1576 | if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' ) |
| | 1577 | $class = ' class="current"'; |
| | 1578 | else |
| | 1579 | $class = ''; |
| | 1580 | $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false))) . "'$class>".__('All Types')."</a>"; |
| | 1581 | foreach ( $post_mime_types as $mime_type => $label ) { |
| | 1582 | $class = ''; |
| | 1583 | |
| | 1584 | if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) ) |
| | 1585 | continue; |
| | 1586 | |
| | 1587 | if ( isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) |
| | 1588 | $class = ' class="current"'; |
| | 1589 | |
| | 1590 | $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false))) . "'$class>" . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), "<span id='$mime_type-counter'>" . number_format_i18n( $num_posts[$mime_type] ) . '</span>') . '</a>'; |
| 1535 | | <?php } ?> |
| 1536 | | |
| 1537 | | cls = caption ? '' : ' class="'+t.align+'"'; |
| 1538 | | |
| 1539 | | html = '<img alt="'+alt+'" src="'+f.src.value+'"'+title+cls+' width="'+t.width+'" height="'+t.height+'" />'; |
| 1540 | | |
| 1541 | | if ( f.url.value ) { |
| 1542 | | url = f.url.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); |
| 1543 | | html = '<a href="'+url+'">'+html+'</a>'; |
| | 1592 | echo implode(' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>'; |
| | 1593 | unset($type_links); |
| | 1594 | ?> |
| | 1595 | </ul> |
| | 1596 | |
| | 1597 | <div class="tablenav"> |
| | 1598 | |
| | 1599 | <?php |
| | 1600 | $page_links = paginate_links( array( |
| | 1601 | 'base' => add_query_arg( 'paged', '%#%' ), |
| | 1602 | 'format' => '', |
| | 1603 | 'prev_text' => __('«'), |
| | 1604 | 'next_text' => __('»'), |
| | 1605 | 'total' => ceil($wp_query->found_posts / 10), |
| | 1606 | 'current' => $_GET['paged'] |
| | 1607 | )); |
| | 1608 | |
| | 1609 | if ( $page_links ) |
| | 1610 | echo "<div class='tablenav-pages'>$page_links</div>"; |
| | 1611 | ?> |
| | 1612 | |
| | 1613 | <div class="alignleft actions"> |
| | 1614 | <?php |
| | 1615 | |
| | 1616 | $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; |
| | 1617 | |
| | 1618 | $arc_result = $wpdb->get_results( $arc_query ); |
| | 1619 | |
| | 1620 | $month_count = count($arc_result); |
| | 1621 | |
| | 1622 | if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> |
| | 1623 | <select name='m'> |
| | 1624 | <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option> |
| | 1625 | <?php |
| | 1626 | foreach ($arc_result as $arc_row) { |
| | 1627 | if ( $arc_row->yyear == 0 ) |
| | 1628 | continue; |
| | 1629 | $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); |
| | 1630 | |
| | 1631 | if ( isset($_GET['m']) && ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) ) |
| | 1632 | $default = ' selected="selected"'; |
| | 1633 | else |
| | 1634 | $default = ''; |
| | 1635 | |
| | 1636 | echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>"; |
| | 1637 | echo esc_html( $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear" ); |
| | 1638 | echo "</option>\n"; |
| 1554 | | resetImageData : function() { |
| 1555 | | var t = addExtImage; |
| | 1674 | <table class="widefat" cellspacing="0"> |
| | 1675 | <thead><tr> |
| | 1676 | <th><?php _e('Media'); ?></th> |
| | 1677 | <th class="order-head"><?php _e('Order'); ?></th> |
| | 1678 | <th class="actions-head"><?php _e('Actions'); ?></th> |
| | 1679 | </tr></thead> |
| | 1680 | </table> |
| | 1681 | <div id="media-items"> |
| | 1682 | <?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?> |
| | 1683 | <?php echo get_media_items($post_id, $errors); ?> |
| | 1684 | </div> |
| | 1685 | |
| | 1686 | <p class="ml-submit"> |
| | 1687 | <?php submit_button( __( 'Save all changes' ), 'button savebutton', 'save', false, array( 'id' => 'save-all', 'style' => 'display: none;' ) ); ?> |
| | 1688 | <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
| | 1689 | <input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" /> |
| | 1690 | <input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" /> |
| | 1691 | </p> |
| | 1692 | |
| | 1693 | <div id="gallery-settings" style="display:none;"> |
| | 1694 | <div class="title"><?php _e('Gallery Settings'); ?></div> |
| | 1695 | <table id="basic" class="describe"><tbody> |
| | 1696 | <tr> |
| | 1697 | <th scope="row" class="label"> |
| | 1698 | <label> |
| | 1699 | <span class="alignleft"><?php _e('Link thumbnails to:'); ?></span> |
| | 1700 | </label> |
| | 1701 | </th> |
| | 1702 | <td class="field"> |
| | 1703 | <input type="radio" name="linkto" id="linkto-file" value="file" /> |
| | 1704 | <label for="linkto-file" class="radio"><?php _e('Image File'); ?></label> |
| | 1705 | |
| | 1706 | <input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" /> |
| | 1707 | <label for="linkto-post" class="radio"><?php _e('Attachment Page'); ?></label> |
| | 1708 | </td> |
| | 1709 | </tr> |
| | 1710 | |
| | 1711 | <tr> |
| | 1712 | <th scope="row" class="label"> |
| | 1713 | <label> |
| | 1714 | <span class="alignleft"><?php _e('Order images by:'); ?></span> |
| | 1715 | </label> |
| | 1716 | </th> |
| | 1717 | <td class="field"> |
| | 1718 | <select id="orderby" name="orderby"> |
| | 1719 | <option value="menu_order" selected="selected"><?php _e('Menu order'); ?></option> |
| | 1720 | <option value="title"><?php _e('Title'); ?></option> |
| | 1721 | <option value="post_date"><?php _e('Date/Time'); ?></option> |
| | 1722 | <option value="rand"><?php _e('Random'); ?></option> |
| | 1723 | </select> |
| | 1724 | </td> |
| | 1725 | </tr> |
| | 1726 | |
| | 1727 | <tr> |
| | 1728 | <th scope="row" class="label"> |
| | 1729 | <label> |
| | 1730 | <span class="alignleft"><?php _e('Order:'); ?></span> |
| | 1731 | </label> |
| | 1732 | </th> |
| | 1733 | <td class="field"> |
| | 1734 | <input type="radio" checked="checked" name="order" id="order-asc" value="asc" /> |
| | 1735 | <label for="order-asc" class="radio"><?php _e('Ascending'); ?></label> |
| | 1736 | |
| | 1737 | <input type="radio" name="order" id="order-desc" value="desc" /> |
| | 1738 | <label for="order-desc" class="radio"><?php _e('Descending'); ?></label> |
| | 1739 | </td> |
| | 1740 | </tr> |
| | 1741 | |
| | 1742 | <tr> |
| | 1743 | <th scope="row" class="label"> |
| | 1744 | <label> |
| | 1745 | <span class="alignleft"><?php _e('Gallery columns:'); ?></span> |
| | 1746 | </label> |
| | 1747 | </th> |
| | 1748 | <td class="field"> |
| | 1749 | <select id="columns" name="columns"> |
| | 1750 | <option value="1">1</option> |
| | 1751 | <option value="2">2</option> |
| | 1752 | <option value="3" selected="selected">3</option> |
| | 1753 | <option value="4">4</option> |
| | 1754 | <option value="5">5</option> |
| | 1755 | <option value="6">6</option> |
| | 1756 | <option value="7">7</option> |
| | 1757 | <option value="8">8</option> |
| | 1758 | <option value="9">9</option> |
| | 1759 | </select> |
| | 1760 | </td> |
| | 1761 | </tr> |
| | 1762 | </tbody></table> |
| | 1763 | |
| | 1764 | <p class="ml-submit"> |
| | 1765 | <input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e( 'Insert gallery' ); ?>" /> |
| | 1766 | <input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e( 'Update gallery settings' ); ?>" /> |
| | 1767 | </p> |
| | 1768 | </div> |
| | 1769 | </form> |
| | 1807 | }); |
| | 1808 | //]]> |
| | 1809 | </script> |
| | 1810 | <?php } elseif ( $type == 'url' ) { ?> |
| | 1811 | <script type="text/javascript"> |
| | 1812 | //<![CDATA[ |
| | 1813 | var addExtImage = { |
| | 1814 | |
| | 1815 | width : '', |
| | 1816 | height : '', |
| | 1817 | align : 'alignnone', |
| | 1818 | |
| | 1819 | insert : function() { |
| | 1820 | var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = ''; |
| | 1821 | |
| | 1822 | if ( '' == f.src.value || '' == t.width ) |
| | 1823 | return false; |
| | 1824 | |
| | 1825 | if ( f.title.value ) { |
| | 1826 | title = f.title.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); |
| | 1827 | title = ' title="'+title+'"'; |
| | 1828 | } |
| | 1829 | |
| | 1830 | if ( f.alt.value ) |
| | 1831 | alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); |
| | 1832 | |
| | 1833 | <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?> |
| | 1834 | if ( f.caption.value ) { |
| | 1835 | caption = f.caption.value.replace(/\r\n|\r/g, '\n'); |
| | 1836 | caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){ |
| | 1837 | return a.replace(/[\r\n\t]+/, ' '); |
| | 1838 | }); |
| | 1839 | |
| | 1840 | caption = caption.replace(/\s*\n\s*/g, '<br />'); |
| | 1841 | } |
| | 1842 | <?php } ?> |
| | 1843 | |
| | 1844 | cls = caption ? '' : ' class="'+t.align+'"'; |
| | 1845 | |
| | 1846 | html = '<img alt="'+alt+'" src="'+f.src.value+'"'+title+cls+' width="'+t.width+'" height="'+t.height+'" />'; |
| | 1847 | |
| | 1848 | if ( f.url.value ) { |
| | 1849 | url = f.url.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); |
| | 1850 | html = '<a href="'+url+'">'+html+'</a>'; |
| | 1851 | } |
| | 1852 | |
| | 1853 | if ( caption ) |
| | 1854 | html = '[caption id="" align="'+t.align+'" width="'+t.width+'"]'+html+caption+'[/caption]'; |
| | 1855 | |
| | 1856 | var win = window.dialogArguments || opener || parent || top; |
| | 1857 | win.send_to_editor(html); |
| | 1858 | return false; |
| | 1859 | }, |
| | 1860 | |
| | 1861 | resetImageData : function() { |
| | 1862 | var t = addExtImage; |
| | 1863 | |
| | 1864 | t.width = t.height = ''; |
| | 1865 | document.getElementById('go_button').style.color = '#bbb'; |
| | 1866 | if ( ! document.forms[0].src.value ) |
| | 1867 | document.getElementById('status_img').innerHTML = '*'; |
| | 1868 | else document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/no.png' ) ); ?>" alt="" />'; |
| | 1869 | }, |
| | 1870 | |
| | 1871 | updateImageData : function() { |
| | 1872 | var t = addExtImage; |
| | 1873 | |
| | 1874 | t.width = t.preloadImg.width; |
| | 1875 | t.height = t.preloadImg.height; |
| | 1876 | document.getElementById('go_button').style.color = '#333'; |
| | 1877 | document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/yes.png' ) ); ?>" alt="" />'; |
| | 1878 | }, |
| | 1879 | |
| | 1880 | getImageData : function() { |
| | 1881 | if ( jQuery('table.describe').hasClass('not-image') ) |
| | 1882 | return; |
| | 1883 | |
| | 1884 | var t = addExtImage, src = document.forms[0].src.value; |
| | 1885 | |
| | 1886 | if ( ! src ) { |
| | 1887 | t.resetImageData(); |
| | 1888 | return false; |
| | 1889 | } |
| | 1890 | |
| | 1891 | document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />'; |
| | 1892 | t.preloadImg = new Image(); |
| | 1893 | t.preloadImg.onload = t.updateImageData; |
| | 1894 | t.preloadImg.onerror = t.resetImageData; |
| | 1895 | t.preloadImg.src = src; |
| | 1896 | } |
| 1640 | | }); |
| 1641 | | --> |
| 1642 | | </script> |
| 1643 | | <div id="sort-buttons" class="hide-if-no-js"> |
| 1644 | | <span> |
| 1645 | | <?php _e('All Tabs:'); ?> |
| 1646 | | <a href="#" id="showall"><?php _e('Show'); ?></a> |
| 1647 | | <a href="#" id="hideall" style="display:none;"><?php _e('Hide'); ?></a> |
| 1648 | | </span> |
| 1649 | | <?php _e('Sort Order:'); ?> |
| 1650 | | <a href="#" id="asc"><?php _e('Ascending'); ?></a> | |
| 1651 | | <a href="#" id="desc"><?php _e('Descending'); ?></a> | |
| 1652 | | <a href="#" id="clear"><?php _ex('Clear', 'verb'); ?></a> |
| 1653 | | </div> |
| 1654 | | <form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="gallery-form"> |
| 1655 | | <?php wp_nonce_field('media-form'); ?> |
| 1656 | | <?php //media_upload_form( $errors ); ?> |
| 1657 | | <table class="widefat" cellspacing="0"> |
| 1658 | | <thead><tr> |
| 1659 | | <th><?php _e('Media'); ?></th> |
| 1660 | | <th class="order-head"><?php _e('Order'); ?></th> |
| 1661 | | <th class="actions-head"><?php _e('Actions'); ?></th> |
| 1662 | | </tr></thead> |
| 1663 | | </table> |
| 1664 | | <div id="media-items"> |
| 1665 | | <?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?> |
| 1666 | | <?php echo get_media_items($post_id, $errors); ?> |
| 1667 | | </div> |
| 1668 | | |
| 1669 | | <p class="ml-submit"> |
| 1670 | | <?php submit_button( __( 'Save all changes' ), 'button savebutton', 'save', false, array( 'id' => 'save-all', 'style' => 'display: none;' ) ); ?> |
| 1671 | | <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
| 1672 | | <input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" /> |
| 1673 | | <input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" /> |
| 1674 | | </p> |
| 1675 | | |
| 1676 | | <div id="gallery-settings" style="display:none;"> |
| 1677 | | <div class="title"><?php _e('Gallery Settings'); ?></div> |
| 1678 | | <table id="basic" class="describe"><tbody> |
| 1679 | | <tr> |
| 1680 | | <th scope="row" class="label"> |
| 1681 | | <label> |
| 1682 | | <span class="alignleft"><?php _e('Link thumbnails to:'); ?></span> |
| 1683 | | </label> |
| 1684 | | </th> |
| 1685 | | <td class="field"> |
| 1686 | | <input type="radio" name="linkto" id="linkto-file" value="file" /> |
| 1687 | | <label for="linkto-file" class="radio"><?php _e('Image File'); ?></label> |
| 1688 | | |
| 1689 | | <input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" /> |
| 1690 | | <label for="linkto-post" class="radio"><?php _e('Attachment Page'); ?></label> |
| 1691 | | </td> |
| 1692 | | </tr> |
| 1693 | | |
| 1694 | | <tr> |
| 1695 | | <th scope="row" class="label"> |
| 1696 | | <label> |
| 1697 | | <span class="alignleft"><?php _e('Order images by:'); ?></span> |
| 1698 | | </label> |
| 1699 | | </th> |
| 1700 | | <td class="field"> |
| 1701 | | <select id="orderby" name="orderby"> |
| 1702 | | <option value="menu_order" selected="selected"><?php _e('Menu order'); ?></option> |
| 1703 | | <option value="title"><?php _e('Title'); ?></option> |
| 1704 | | <option value="post_date"><?php _e('Date/Time'); ?></option> |
| 1705 | | <option value="rand"><?php _e('Random'); ?></option> |
| 1706 | | </select> |
| 1707 | | </td> |
| 1708 | | </tr> |
| 1709 | | |
| 1710 | | <tr> |
| 1711 | | <th scope="row" class="label"> |
| 1712 | | <label> |
| 1713 | | <span class="alignleft"><?php _e('Order:'); ?></span> |
| 1714 | | </label> |
| 1715 | | </th> |
| 1716 | | <td class="field"> |
| 1717 | | <input type="radio" checked="checked" name="order" id="order-asc" value="asc" /> |
| 1718 | | <label for="order-asc" class="radio"><?php _e('Ascending'); ?></label> |
| 1719 | | |
| 1720 | | <input type="radio" name="order" id="order-desc" value="desc" /> |
| 1721 | | <label for="order-desc" class="radio"><?php _e('Descending'); ?></label> |
| 1722 | | </td> |
| 1723 | | </tr> |
| 1724 | | |
| 1725 | | <tr> |
| 1726 | | <th scope="row" class="label"> |
| 1727 | | <label> |
| 1728 | | <span class="alignleft"><?php _e('Gallery columns:'); ?></span> |
| 1729 | | </label> |
| 1730 | | </th> |
| 1731 | | <td class="field"> |
| 1732 | | <select id="columns" name="columns"> |
| 1733 | | <option value="1">1</option> |
| 1734 | | <option value="2">2</option> |
| 1735 | | <option value="3" selected="selected">3</option> |
| 1736 | | <option value="4">4</option> |
| 1737 | | <option value="5">5</option> |
| 1738 | | <option value="6">6</option> |
| 1739 | | <option value="7">7</option> |
| 1740 | | <option value="8">8</option> |
| 1741 | | <option value="9">9</option> |
| 1742 | | </select> |
| 1743 | | </td> |
| 1744 | | </tr> |
| 1745 | | </tbody></table> |
| 1746 | | |
| 1747 | | <p class="ml-submit"> |
| 1748 | | <input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e( 'Insert gallery' ); ?>" /> |
| 1749 | | <input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e( 'Update gallery settings' ); ?>" /> |
| 1750 | | </p> |
| 1751 | | </div> |
| 1752 | | </form> |
| | 1898 | |
| | 1899 | jQuery(document).ready( function($) { |
| | 1900 | $('.media-types input').click( function() { |
| | 1901 | $('table.describe').toggleClass('not-image', $('#not-image').prop('checked') ); |
| | 1902 | }); |
| | 1903 | }); |
| | 1904 | |
| | 1905 | //]]> |
| | 1906 | </script> |
| 1759 | | * @since 2.5.0 |
| 1760 | | * |
| 1761 | | * @param unknown_type $errors |
| 1762 | | */ |
| 1763 | | function media_upload_library_form($errors) { |
| 1764 | | global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types; |
| 1765 | | |
| 1766 | | media_upload_header(); |
| 1767 | | |
| 1768 | | $post_id = intval($_REQUEST['post_id']); |
| 1769 | | |
| 1770 | | $form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id"); |
| 1771 | | $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); |
| 1772 | | $form_class = 'media-upload-form validate'; |
| 1773 | | |
| 1774 | | if ( get_user_setting('uploader') ) |
| 1775 | | $form_class .= ' html-uploader'; |
| 1776 | | |
| 1777 | | $_GET['paged'] = isset( $_GET['paged'] ) ? intval($_GET['paged']) : 0; |
| 1778 | | if ( $_GET['paged'] < 1 ) |
| 1779 | | $_GET['paged'] = 1; |
| 1780 | | $start = ( $_GET['paged'] - 1 ) * 10; |
| 1781 | | if ( $start < 1 ) |
| 1782 | | $start = 0; |
| 1783 | | add_filter( 'post_limits', create_function( '$a', "return 'LIMIT $start, 10';" ) ); |
| 1784 | | |
| 1785 | | list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); |
| 1786 | | |
| 1787 | | ?> |
| 1788 | | |
| 1789 | | <form id="filter" action="" method="get"> |
| 1790 | | <input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" /> |
| 1791 | | <input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" /> |
| 1792 | | <input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" /> |
| 1793 | | <input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" /> |
| 1794 | | <input type="hidden" name="context" value="<?php echo isset( $_GET['context'] ) ? esc_attr( $_GET['context'] ) : ''; ?>" /> |
| 1795 | | |
| 1796 | | <p id="media-search" class="search-box"> |
| 1797 | | <label class="screen-reader-text" for="media-search-input"><?php _e('Search Media');?>:</label> |
| 1798 | | <input type="search" id="media-search-input" name="s" value="<?php the_search_query(); ?>" /> |
| 1799 | | <?php submit_button( __( 'Search Media' ), 'button', '', false ); ?> |
| 1800 | | </p> |
| 1801 | | |
| 1802 | | <ul class="subsubsub"> |
| 1803 | | <?php |
| 1804 | | $type_links = array(); |
| 1805 | | $_num_posts = (array) wp_count_attachments(); |
| 1806 | | $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); |
| 1807 | | foreach ( $matches as $_type => $reals ) |
| 1808 | | foreach ( $reals as $real ) |
| 1809 | | if ( isset($num_posts[$_type]) ) |
| 1810 | | $num_posts[$_type] += $_num_posts[$real]; |
| 1811 | | else |
| 1812 | | $num_posts[$_type] = $_num_posts[$real]; |
| 1813 | | // If available type specified by media button clicked, filter by that type |
| 1814 | | if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) { |
| 1815 | | $_GET['post_mime_type'] = $type; |
| 1816 | | list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); |
| 1817 | | } |
| 1818 | | if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' ) |
| 1819 | | $class = ' class="current"'; |
| 1820 | | else |
| 1821 | | $class = ''; |
| 1822 | | $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false))) . "'$class>".__('All Types')."</a>"; |
| 1823 | | foreach ( $post_mime_types as $mime_type => $label ) { |
| 1824 | | $class = ''; |
| 1825 | | |
| 1826 | | if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) ) |
| 1827 | | continue; |
| 1828 | | |
| 1829 | | if ( isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) |
| 1830 | | $class = ' class="current"'; |
| 1831 | | |
| 1832 | | $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false))) . "'$class>" . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), "<span id='$mime_type-counter'>" . number_format_i18n( $num_posts[$mime_type] ) . '</span>') . '</a>'; |
| 1833 | | } |
| 1834 | | echo implode(' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>'; |
| 1835 | | unset($type_links); |
| 1836 | | ?> |
| 1837 | | </ul> |
| 1838 | | |
| 1839 | | <div class="tablenav"> |
| 1840 | | |
| 1841 | | <?php |
| 1842 | | $page_links = paginate_links( array( |
| 1843 | | 'base' => add_query_arg( 'paged', '%#%' ), |
| 1844 | | 'format' => '', |
| 1845 | | 'prev_text' => __('«'), |
| 1846 | | 'next_text' => __('»'), |
| 1847 | | 'total' => ceil($wp_query->found_posts / 10), |
| 1848 | | 'current' => $_GET['paged'] |
| 1849 | | )); |
| 1850 | | |
| 1851 | | if ( $page_links ) |
| 1852 | | echo "<div class='tablenav-pages'>$page_links</div>"; |
| 1853 | | ?> |
| 1854 | | |
| 1855 | | <div class="alignleft actions"> |
| 1856 | | <?php |
| 1857 | | |
| 1858 | | $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; |
| 1859 | | |
| 1860 | | $arc_result = $wpdb->get_results( $arc_query ); |
| 1861 | | |
| 1862 | | $month_count = count($arc_result); |
| 1863 | | |
| 1864 | | if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> |
| 1865 | | <select name='m'> |
| 1866 | | <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option> |
| 1867 | | <?php |
| 1868 | | foreach ($arc_result as $arc_row) { |
| 1869 | | if ( $arc_row->yyear == 0 ) |
| 1870 | | continue; |
| 1871 | | $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); |
| 1872 | | |
| 1873 | | if ( isset($_GET['m']) && ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) ) |
| 1874 | | $default = ' selected="selected"'; |
| 1875 | | else |
| 1876 | | $default = ''; |
| 1877 | | |
| 1878 | | echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>"; |
| 1879 | | echo esc_html( $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear" ); |
| 1880 | | echo "</option>\n"; |
| 1881 | | } |
| 1882 | | ?> |
| 1883 | | </select> |
| 1884 | | <?php } ?> |
| 1885 | | |
| 1886 | | <?php submit_button( __( 'Filter »' ), 'secondary', 'post-query-submit', false ); ?> |
| 1887 | | |
| 1888 | | </div> |
| 1889 | | |
| 1890 | | <br class="clear" /> |
| 1891 | | </div> |
| 1892 | | </form> |
| 1893 | | |
| 1894 | | <form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="library-form"> |
| 1895 | | |
| 1896 | | <?php wp_nonce_field('media-form'); ?> |
| 1897 | | <?php //media_upload_form( $errors ); ?> |
| 1898 | | |
| 1899 | | <script type="text/javascript"> |
| 1900 | | <!-- |
| 1901 | | jQuery(function($){ |
| 1902 | | var preloaded = $(".media-item.preloaded"); |
| 1903 | | if ( preloaded.length > 0 ) { |
| 1904 | | preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); |
| 1905 | | updateMediaForm(); |
| 1906 | | } |
| 1907 | | }); |
| 1908 | | --> |
| 1909 | | </script> |
| 1910 | | |
| 1911 | | <div id="media-items"> |
| 1912 | | <?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?> |
| 1913 | | <?php echo get_media_items(null, $errors); ?> |
| 1914 | | </div> |
| 1915 | | <p class="ml-submit"> |
| 1916 | | <?php submit_button( __( 'Save all changes' ), 'button savebutton', 'save', false ); ?> |
| 1917 | | <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
| 1918 | | </p> |
| 1919 | | </form> |
| 1920 | | <?php |
| 1921 | | } |
| 1922 | | |
| 1923 | | /** |
| 1924 | | * {@internal Missing Short Description}} |
| 1925 | | * |
| 2108 | | add_filter( 'media_upload_gallery', 'media_upload_gallery' ); |
| 2109 | | add_filter( 'media_upload_library', 'media_upload_library' ); |
| | 2110 | <?php media_upload_form(); ?> |
| | 2111 | |
| | 2112 | <?php wp_nonce_field('media-form'); ?> |
| | 2113 | |
| | 2114 | <?php if ( $inline !== false ) { ?> |
| | 2115 | |
| | 2116 | <div id="media-items" class="hide-if-no-js"></div> |
| | 2117 | <input type="hidden" name="post_id" id="post_id" value="0" /> |
| | 2118 | |
| | 2119 | <script type="text/javascript"> |
| | 2120 | jQuery(function($){ |
| | 2121 | var preloaded = $(".media-item.preloaded"); |
| | 2122 | if ( preloaded.length > 0 ) { |
| | 2123 | preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); |
| | 2124 | } |
| | 2125 | updateMediaForm(); |
| | 2126 | post_id = 0; |
| | 2127 | shortform = 1; |
| | 2128 | }); |
| | 2129 | </script> |
| | 2130 | |
| | 2131 | <?php } else { ?> |
| | 2132 | |
| | 2133 | <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
| | 2134 | <div id="media-items"> |
| | 2135 | |
| | 2136 | <?php |
| | 2137 | if ( $id ) { |
| | 2138 | if ( !is_wp_error($id) ) { |
| | 2139 | add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); |
| | 2140 | echo get_media_items( $id, $errors ); |
| | 2141 | } else { |
| | 2142 | echo '<div id="media-upload-error">'.esc_html($id->get_error_message()).'</div></div>'; |
| | 2143 | exit; |
| | 2144 | } |
| | 2145 | } |
| | 2146 | ?> |
| | 2147 | |
| | 2148 | </div> |
| | 2149 | <p class="savebutton ml-submit"> |
| | 2150 | <?php submit_button( __( 'Save all changes' ), 'button', 'save', false ); ?> |
| | 2151 | </p> |
| | 2152 | </form> |
| | 2153 | |
| | 2154 | <script type="text/javascript"> |
| | 2155 | //<![CDATA[ |
| | 2156 | jQuery(function($){ |
| | 2157 | var preloaded = $(".media-item.preloaded"); |
| | 2158 | if ( preloaded.length > 0 ) { |
| | 2159 | preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); |
| | 2160 | } |
| | 2161 | updateMediaForm(); |
| | 2162 | }); |
| | 2163 | //]]> |
| | 2164 | </script> |
| | 2165 | |
| | 2166 | <?php }; ?> |
| | 2167 | |
| | 2168 | <?php submit_button( __( 'Save all changes' ), 'button savebutton hidden', 'save' ); ?> |
| | 2169 | <?php |
| | 2170 | } |
| | 2171 | No newline at end of file |