Skip to:
Content

bbPress.org

Changeset 4607


Ignore:
Timestamp:
12/20/2012 01:40:53 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Filter the TinyMCE quicktags buttons to remove buttons that users cannot use.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/common/template-tags.php

    r4606 r4607  
    16901690
    16911691            // Enable additional TinyMCE plugins before outputting the editor
    1692             add_filter( 'tiny_mce_plugins',  'bbp_get_tiny_mce_plugins'  );
    1693             add_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins'  );
    1694             add_filter( 'teeny_mce_buttons', 'bbp_get_teeny_mce_buttons' );
     1692            add_filter( 'tiny_mce_plugins',   'bbp_get_tiny_mce_plugins'   );
     1693            add_filter( 'teeny_mce_plugins',  'bbp_get_tiny_mce_plugins'   );
     1694            add_filter( 'teeny_mce_buttons',  'bbp_get_teeny_mce_buttons'  );
     1695            add_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' );
    16951696
    16961697            // Output the editor
     
    17091710
    17101711            // Remove additional TinyMCE plugins after outputting the editor
    1711             remove_filter( 'tiny_mce_plugins',  'bbp_get_tiny_mce_plugins'  );
    1712             remove_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins'  );
    1713             remove_filter( 'teeny_mce_buttons', 'bbp_get_teeny_mce_buttons' );
     1712            remove_filter( 'tiny_mce_plugins',   'bbp_get_tiny_mce_plugins'   );
     1713            remove_filter( 'teeny_mce_plugins',  'bbp_get_tiny_mce_plugins'   );
     1714            remove_filter( 'teeny_mce_buttons',  'bbp_get_teeny_mce_buttons'  );
     1715            remove_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' );
    17141716
    17151717        /**
     
    17651767
    17661768/**
    1767  * Edit TinyMCE buttons to match allowedtags
     1769 * Edit TeenyMCE buttons to match allowedtags
    17681770 *
    17691771 * @since bbPress (r4605)
     
    17871789
    17881790    return apply_filters( 'bbp_get_teeny_mce_buttons', $buttons );
     1791}
     1792
     1793/**
     1794 * Edit TinyMCE quicktags buttons to match allowedtags
     1795 *
     1796 * @since bbPress (r4606)
     1797 *
     1798 * @param array $buttons
     1799 * @see quicktags_settings
     1800 * @return array Quicktags settings
     1801 */
     1802function bbp_get_quicktags_settings( $settings = array() ) {
     1803
     1804    // Get buttons out of settings
     1805    $buttons_array = explode( ',', $settings['buttons'] );
     1806
     1807    // Diff the ones we don't want out
     1808    $buttons = array_diff( $buttons_array, array(
     1809        'ins',
     1810        'img',
     1811        'more',
     1812        'spell'
     1813    ) );
     1814
     1815    // Put them back into a string in the $settings array
     1816    $settings['buttons'] = implode( ',', $buttons );
     1817
     1818    return apply_filters( 'bbp_get_quicktags_settings', $settings );
    17891819}
    17901820
Note: See TracChangeset for help on using the changeset viewer.