| 1676 | | $enqueue = false; |
| 1677 | | |
| | 1674 | /* |
| | 1675 | * Register feature pointers |
| | 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 | $registered_pointers = apply_filters( 'wp_pointers', array( |
| | 1681 | 'index.php' => array( 'wp330-toolbar', 'wp330-flyout-menus' ), |
| | 1682 | 'post-new.php' => 'wp330-media-uploader', |
| | 1683 | 'themes.php' => 'wp330-saving-widgets' |
| | 1684 | ) ); |
| | 1685 | |
| | 1686 | // Get screen related pointers |
| | 1687 | $pointers = empty( $registered_pointers[$hook_suffix] ) ? array() : (array) $registered_pointers[$hook_suffix]; |
| | 1688 | if ( ! empty( $registered_pointers['all'] ) ) |
| | 1689 | $pointers = array_merge( $pointers, (array) $registered_pointers['all'] ) ; |
| | 1690 | |
| | 1691 | // No pointers for this screen |
| | 1692 | if ( empty( $pointers ) ) |
| | 1693 | return; |
| | 1694 | |
| | 1695 | // Get dismissed pointers |
| 1685 | | if ( $enqueue ) { |
| 1686 | | wp_enqueue_style( 'wp-pointer' ); |
| 1687 | | wp_enqueue_script( 'wp-pointer' ); |
| 1688 | | } |
| | 1701 | // Pointers were already shown |
| | 1702 | if ( empty( $pointers ) ) |
| | 1703 | return; |
| | 1704 | |
| | 1705 | // Init pointers print functions |
| | 1706 | foreach ( $pointers as $pointer ) |
| | 1707 | add_action( 'admin_print_footer_scripts', '_wp_pointer_print_' . str_replace( '-', '_', $pointer ) ); |
| | 1708 | |
| | 1709 | // Add pointers script and style to queue |
| | 1710 | wp_enqueue_style( 'wp-pointer' ); |
| | 1711 | wp_enqueue_script( 'wp-pointer' ); |
| | 1712 | |
| 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>'; |
| | 1716 | /** |
| | 1717 | * Print the pointer javascript data. |
| | 1718 | * |
| | 1719 | * @since 3.3.0 |
| | 1720 | * |
| | 1721 | * @param string $pointer_id The pointer ID |
| | 1722 | * @param string $selector The HTML elements, on which the pointer should be attached |
| | 1723 | * @param string $content The pointer content |
| | 1724 | * @param array|string $position The pointer position, see wp-pointer.dev.js |
| | 1725 | */ |
| | 1726 | function _wp_pointer_print_js_data( $pointer_id, $selector, $content, $position ) { |
| | 1727 | if ( empty( $pointer_id ) || empty( $selector ) || empty( $content ) ) |
| | 1728 | return; |
| | 1730 | // Set arrow and pointer position |
| | 1731 | $_position = ''; |
| | 1732 | if ( is_string( $position ) ) |
| | 1733 | $_position = "position: '{$position}',"; |
| | 1734 | elseif( is_array( $position ) ) { |
| | 1735 | if ( ! empty( $position['edge'] ) && ! empty( $position['align'] ) ) { |
| | 1736 | $_position = "position: { edge: '{$position['edge']}', align: '{$position['align']}' },"; |
| | 1737 | } elseif ( ! empty( $position['edge'] ) ) { |
| | 1738 | $_position = "position: { edge: '{$position['edge']}' },"; |
| | 1739 | } elseif ( ! empty( $position['align'] ) ) { |
| | 1740 | $_position = "position: { align: '{$position['align']}' },"; |
| | 1741 | } |
| | 1742 | } |
| | 1762 | |
| | 1763 | /** |
| | 1764 | * Print 'New Feature: Toolbar' for 3.3.0. |
| | 1765 | * |
| | 1766 | * @since 3.3.0 |
| | 1767 | */ |
| | 1768 | function _wp_pointer_print_wp330_toolbar() { |
| | 1769 | $content = '<h3>' . esc_js( __( 'New Feature: Toolbar' ) ). '</h3>'; |
| | 1770 | $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>'; |
| | 1771 | |
| | 1772 | if ( is_multisite() && is_super_admin() ) |
| | 1773 | $content .= '<p>' .esc_js( __( 'Network Admin is now located in the My Sites menu.' ) ) . '</p>'; |
| | 1774 | |
| | 1775 | $position['edge'] = 'top'; |
| | 1776 | $position['align'] = 'right'; |
| | 1777 | |
| | 1778 | _wp_pointer_print_js_data( 'wp330-toolbar', '#wpadminbar', $content, $position ); |
| | 1779 | } |
| | 1780 | |
| | 1781 | /** |
| | 1782 | * Print 'New Feature: Flyout Menus' for 3.3.0. |
| | 1783 | * |
| | 1784 | * @since 3.3.0 |
| | 1785 | */ |
| | 1786 | function _wp_pointer_print_wp330_flyout_menus() { |
| | 1787 | $content = '<h3>' . esc_js( __( 'New Feature: Flyout Menus' ) ) . '</h3>'; |
| | 1788 | $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>'; |
| | 1789 | |
| | 1790 | $position['edge'] = 'left'; |
| | 1791 | $position['align'] = 'center'; |
| | 1792 | |
| | 1793 | _wp_pointer_print_js_data( 'wp330-flyout-menus', '#menu-users', $content, $position ); |
| | 1794 | } |
| | 1795 | |
| | 1796 | /** |
| | 1797 | * Print 'Updated Media Uploader' for 3.3.0. |
| | 1798 | * |
| | 1799 | * @since 3.3.0 |
| | 1800 | */ |
| | 1801 | function _wp_pointer_print_wp330_media_uploader() { |
| | 1802 | $content = '<h3>' . esc_js( __( 'Updated Media Uploader' ) ) . '</h3>'; |
| | 1803 | $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>'; |
| | 1804 | |
| | 1805 | $position['edge'] = 'left'; |
| | 1806 | $position['align'] = 'center'; |
| | 1807 | |
| | 1808 | _wp_pointer_print_js_data( 'wp330-media-uploader', '#content-add_media', $content, $position ); |
| | 1809 | } |
| | 1810 | |
| | 1811 | /** |
| | 1812 | * Print 'New Feature: Saving Widgets' for 3.3.0. |
| | 1813 | * |
| | 1814 | * @since 3.3.0 |
| | 1815 | */ |
| | 1816 | function _wp_pointer_print_wp330_saving_widgets() { |
| | 1817 | $content = '<h3>' . esc_js( __( 'New Feature: Saving Widgets' ) ) . '</h3>'; |
| | 1818 | $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>'; |
| | 1819 | |
| | 1820 | $position['edge'] = 'top'; |
| | 1821 | $position['align'] = 'left'; |
| | 1822 | |
| | 1823 | _wp_pointer_print_js_data( 'wp330-saving-widgets', '#message2', $content, $position ); |
| | 1824 | } |