| 1676 | | $enqueue = false; |
| 1677 | | |
| | 1674 | /* |
| | 1675 | * Pointers to show |
| | 1676 | * Format: |
| | 1677 | * array( hook_suffix => pointer_id ) |
| | 1678 | * You can use 'all' as hook_suffix to diplay the pointer on all screens. |
| | 1679 | */ |
| | 1680 | $pointers = apply_filters( 'wp_pointers', array( |
| | 1681 | 'index.php' => array( |
| | 1682 | 'wp330-toolbar', |
| | 1683 | 'wp330-flyout-menus' |
| | 1684 | ), |
| | 1685 | 'post-new.php' => 'wp330-media-uploader', |
| | 1686 | 'themes.php' => 'wp330-saving-widgets', |
| | 1687 | 'all' => '' |
| | 1688 | ) ); |
| | 1689 | |
| | 1690 | // Get screen relevant pointers |
| | 1691 | $pointers = array_merge( (array) $pointers[$hook_suffix], (array) $pointers['all'] ) ; |
| | 1692 | |
| | 1693 | // No pointers to show |
| | 1694 | if ( empty( $pointers ) ) |
| | 1695 | return; |
| | 1696 | |
| | 1697 | // Get pointers which are dismissed |
| 1685 | | if ( $enqueue ) { |
| 1686 | | wp_enqueue_style( 'wp-pointer' ); |
| 1687 | | wp_enqueue_script( 'wp-pointer' ); |
| 1688 | | } |
| | 1703 | // All pointers were already shown |
| | 1704 | if ( empty( $pointers ) ) |
| | 1705 | return; |
| | 1706 | |
| | 1707 | // Print pointers |
| | 1708 | foreach ( $pointers as $pointer ) |
| | 1709 | add_action( 'admin_print_footer_scripts', '_wp_pointer_print_' . str_replace( '-', '_', $pointer ) ); |
| | 1710 | |
| | 1711 | // Load pointers script and style |
| | 1712 | wp_enqueue_style( 'wp-pointer' ); |
| | 1713 | wp_enqueue_script( 'wp-pointer' ); |
| | 1714 | |
| 1692 | | function _wp_pointer_print_admin_bar() { |
| 1693 | | $pointer_content = '<h3>' . 'The admin bar has been updated in WordPress 3.3.' . '</h3>'; |
| 1694 | | $pointer_content .= '<p>' . sprintf( 'Have some feedback? Visit the <a href="%s">forum</a>.', 'http://wordpress.org/support/forum/alphabeta' ) . '</p>'; |
| 1695 | | $pointer_content .= '<p>' . 'P.S. You are looking at a new admin pointer.' . '</p>'; |
| | 1718 | /** |
| | 1719 | * Print the pointer javascript data. |
| | 1720 | * |
| | 1721 | * @since 3.3.0 |
| | 1722 | * |
| | 1723 | * @param string $pointer_id The pointer ID |
| | 1724 | * @param string $selector The HTML elements, on which the pointer should be attached. |
| | 1725 | * @param string $content The pointer content |
| | 1726 | * @param array|string $position The pointer position. Defaults to edge = top and align = center |
| | 1727 | */ |
| | 1728 | function _wp_pointer_javascript( $pointer_id, $selector, $content, $position ) { |
| | 1729 | if ( empty( $pointer_id ) || empty( $selector ) || empty( $content ) ) |
| | 1730 | return; |
| | 1732 | /* TODO: Match wp-pointers.js defaults */ |
| | 1733 | $_position = ''; |
| | 1734 | if ( is_string( $position ) ) |
| | 1735 | $_position = "position: '{$position}',"; |
| | 1736 | elseif( is_array( $position ) ) { |
| | 1737 | if ( ! empty( $position['edge'] ) && ! empty( $position['align'] ) ) { |
| | 1738 | $_position = "position: { edge: '{$position['edge']}', align: '{$position['align']}' },"; |
| | 1739 | } elseif ( ! empty( $position['edge'] ) ) { |
| | 1740 | $_position = "position: { edge: '{$position['edge']}' },"; |
| | 1741 | } elseif ( ! empty( $position['align'] ) ) { |
| | 1742 | $_position = "position: { align: '{$position['align']}' },"; |
| | 1743 | } |
| | 1744 | } |
| | 1745 | |
| | 1746 | |
| | 1766 | |
| | 1767 | |
| | 1768 | /** |
| | 1769 | * Print 'New Feature: Toolbar' for 3.3.0. |
| | 1770 | * |
| | 1771 | * @since 3.3.0 |
| | 1772 | */ |
| | 1773 | function _wp_pointer_print_wp330_toolbar() { |
| | 1774 | $content = '<h3>' . esc_js( __( 'New Feature: Toolbar' ) ). '</h3>'; |
| | 1775 | $content .= '<p>' . esc_js( __( "We've combined the admin bar and the old Dashboard header into one persistent toolbar. Hover over the toolbar items to see what's new." ) ) . '</p>'; |
| | 1776 | |
| | 1777 | if ( is_multisite() && is_super_admin() ) |
| | 1778 | $content .= '<p>' .esc_js( __( 'Network Admin is now located in the My Sites menu.' ) ) . '</p>'; |
| | 1779 | |
| | 1780 | $position['align'] = 'right'; |
| | 1781 | $position['edge'] = 'top'; |
| | 1782 | |
| | 1783 | _wp_pointer_javascript( 'wp330-toolbar', '#wpadminbar', $content, $position ); |
| | 1784 | } |
| | 1785 | |
| | 1786 | /** |
| | 1787 | * Print 'New Feature: Flyout Menus' for 3.3.0. |
| | 1788 | * |
| | 1789 | * @since 3.3.0 |
| | 1790 | */ |
| | 1791 | function _wp_pointer_print_wp330_flyout_menus() { |
| | 1792 | $content = '<h3>' . esc_js( __( 'New Feature: Flyout Menus' ) ) . '</h3>'; |
| | 1793 | $content .= '<p>' . esc_js( __( 'Instead of clicking to open and close navigation sections, just hover over a menu item and the submenu will "fly out" to the side, allowing single-click access to any screen.' ) ) . '</p>'; |
| | 1794 | |
| | 1795 | $position['edge'] = 'left'; |
| | 1796 | $position['align'] = 'bottom'; |
| | 1797 | |
| | 1798 | _wp_pointer_javascript( 'wp330-flyout-menus', '#adminmenu', $content, $position ); |
| | 1799 | } |
| | 1800 | |
| | 1801 | /** |
| | 1802 | * Print 'Updated Media Uploader' for 3.3.0. |
| | 1803 | * |
| | 1804 | * @since 3.3.0 |
| | 1805 | */ |
| | 1806 | function _wp_pointer_print_wp330_media_uploader() { |
| | 1807 | $content = '<h3>' . esc_js( __( 'Updated Media Uploader' ) ) . '</h3>'; |
| | 1808 | $content .= '<p>' . esc_js( __( 'The single media icon now launches the uploader for all file types, and the new drag and drop interface makes uploading a breeze.' ) ) . '</p>'; |
| | 1809 | |
| | 1810 | $position['align'] = 'right'; |
| | 1811 | $position['edge'] = 'top'; |
| | 1812 | |
| | 1813 | _wp_pointer_javascript( 'wp330-media-uploader', '#content-add_media', $content, $position ); |
| | 1814 | } |
| | 1815 | |
| | 1816 | /** |
| | 1817 | * Print 'New Feature: Saving Widgets' for 3.3.0. |
| | 1818 | * |
| | 1819 | * @since 3.3.0 |
| | 1820 | */ |
| | 1821 | function _wp_pointer_print_wp330_saving_widgets() { |
| | 1822 | $content = '<h3>' . esc_js( __( 'New Feature: Saving Widgets' ) ) . '</h3>'; |
| | 1823 | $content .= '<p>' . esc_js( __( "If you change your mind and revert to your previous theme, we'll put the widgets back the way you had them." ) ) . '</p>'; |
| | 1824 | |
| | 1825 | $position['align'] = 'left'; |
| | 1826 | $position['edge'] = 'top'; |
| | 1827 | |
| | 1828 | _wp_pointer_javascript( 'wp330-saving-widgets', '#message2', $content, $position ); |
| | 1829 | } |