Example #1
0
    public function bbp_head()
    {
        if (d4p_bbt_o('include_always') == 1 || d4p_is_bbpress()) {
            ?>
<script type="text/javascript">
            /* <![CDATA[ */
            var gdbbPressToolsInit = {
                quote_method: "<?php 
            echo d4p_bbt_o('quote_method');
            ?>
",
                quote_wrote: "<?php 
            echo __("wrote", "gd-bbpress-tools");
            ?>
",
                bbpress_version: <?php 
            echo d4p_bbpress_version();
            ?>
,
                wp_editor: <?php 
            echo d4p_bbpress_version() > 20 ? bbp_use_wp_editor() ? 1 : 0 : 0;
            ?>
            };
            /* ]]> */
        </script><?php 
        }
    }
    ?>

					<?php 
    do_action('bbp_theme_before_reply_form_content');
    ?>

					<?php 
    bbp_the_content(array('context' => 'reply'));
    ?>

					<?php 
    do_action('bbp_theme_after_reply_form_content');
    ?>

					<?php 
    if (!(bbp_use_wp_editor() || current_user_can('unfiltered_html'))) {
        ?>

						<p class="form-allowed-tags">
							<label><?php 
        esc_html_e('You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes:', 'monsoon');
        ?>
</label><br />
							<code><?php 
        bbp_allowed_tags();
        ?>
</code>
						</p>

					<?php 
    }
Example #3
0
/**
 * Return a textarea or TinyMCE if enabled
 *
 * @since bbPress (r3586)
 *
 * @param array $args
 *
 * @uses apply_filter() To filter args and output
 * @uses wp_parse_pargs() To compare args
 * @uses bbp_use_wp_editor() To see if WP editor is in use
 * @uses bbp_is_edit() To see if we are editing something
 * @uses wp_editor() To output the WordPress editor
 *
 * @return string HTML from output buffer 
 */
function bbp_get_the_content($args = array())
{
    // Default arguments
    $defaults = array('context' => 'topic', 'before' => '<div class="bbp-the-content-wrapper">', 'after' => '</div>', 'wpautop' => true, 'media_buttons' => false, 'textarea_rows' => '6', 'tabindex' => bbp_get_tab_index(), 'editor_class' => 'bbp-the-content', 'tinymce' => true, 'quicktags' => true);
    $r = bbp_parse_args($args, $defaults, 'get_the_content');
    extract($r);
    // Assume we are not editing
    $post_content = '';
    // Start an output buffor
    ob_start();
    // Output something before the editor
    if (!empty($before)) {
        echo $before;
    }
    // Get sanitized content
    if (bbp_is_edit()) {
        $post_content = call_user_func('bbp_get_form_' . $context . '_content');
    }
    // Use TinyMCE if available
    if (bbp_use_wp_editor()) {
        $settings = array('wpautop' => $wpautop, 'media_buttons' => $media_buttons, 'textarea_rows' => $textarea_rows, 'tabindex' => $tabindex, 'editor_class' => $editor_class, 'tinymce' => $tinymce, 'quicktags' => $quicktags);
        wp_editor(htmlspecialchars_decode($post_content, ENT_QUOTES), 'bbp_' . $context . '_content', $settings);
        // Fallback to normal textarea
    } else {
        ?>

			<textarea id="bbp_<?php 
        echo $context;
        ?>
_content" class="<?php 
        echo $editor_class;
        ?>
" name="bbp_<?php 
        echo $context;
        ?>
_content" cols="60" rows="<?php 
        echo $textarea_rows;
        ?>
" tabindex="<?php 
        echo $tabindex;
        ?>
"><?php 
        echo $post_content;
        ?>
</textarea>

		<?php 
    }
    // Output something after the editor
    if (!empty($after)) {
        echo $after;
    }
    // Put the output into a usable variable
    $output = ob_get_contents();
    // Flush the output buffer
    ob_end_clean();
    return apply_filters('bbp_get_the_content', $output, $args, $post_content);
}
Example #4
0
/**
 * Return a textarea or TinyMCE if enabled
 *
 * @since bbPress (r3586)
 *
 * @param array $args
 *
 * @uses apply_filter() To filter args and output
 * @uses wp_parse_pargs() To compare args
 * @uses bbp_use_wp_editor() To see if WP editor is in use
 * @uses bbp_is_edit() To see if we are editing something
 * @uses wp_editor() To output the WordPress editor
 *
 * @return string HTML from output buffer
 */
function bbp_get_the_content($args = array())
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('context' => 'topic', 'before' => '<div class="bbp-the-content-wrapper">', 'after' => '</div>', 'wpautop' => true, 'media_buttons' => false, 'textarea_rows' => '12', 'tabindex' => bbp_get_tab_index(), 'tabfocus_elements' => 'bbp_topic_title,bbp_topic_tags', 'editor_class' => 'bbp-the-content', 'tinymce' => false, 'teeny' => true, 'quicktags' => true, 'dfw' => false), 'get_the_content');
    // If using tinymce, remove our escaping and trust tinymce
    if (bbp_use_wp_editor() && false !== $r['tinymce']) {
        remove_filter('bbp_get_form_forum_content', 'esc_textarea');
        remove_filter('bbp_get_form_topic_content', 'esc_textarea');
        remove_filter('bbp_get_form_reply_content', 'esc_textarea');
    }
    // Assume we are not editing
    $post_content = call_user_func('bbp_get_form_' . $r['context'] . '_content');
    // Start an output buffor
    ob_start();
    // Output something before the editor
    if (!empty($r['before'])) {
        echo $r['before'];
    }
    // Use TinyMCE if available
    if (bbp_use_wp_editor()) {
        // Enable additional TinyMCE plugins before outputting the editor
        add_filter('tiny_mce_plugins', 'bbp_get_tiny_mce_plugins');
        add_filter('teeny_mce_plugins', 'bbp_get_tiny_mce_plugins');
        add_filter('teeny_mce_buttons', 'bbp_get_teeny_mce_buttons');
        add_filter('quicktags_settings', 'bbp_get_quicktags_settings');
        // Output the editor
        wp_editor($post_content, 'bbp_' . $r['context'] . '_content', array('wpautop' => $r['wpautop'], 'media_buttons' => $r['media_buttons'], 'textarea_rows' => $r['textarea_rows'], 'tabindex' => $r['tabindex'], 'tabfocus_elements' => $r['tabfocus_elements'], 'editor_class' => $r['editor_class'], 'tinymce' => $r['tinymce'], 'teeny' => $r['teeny'], 'quicktags' => $r['quicktags'], 'dfw' => $r['dfw']));
        // Remove additional TinyMCE plugins after outputting the editor
        remove_filter('tiny_mce_plugins', 'bbp_get_tiny_mce_plugins');
        remove_filter('teeny_mce_plugins', 'bbp_get_tiny_mce_plugins');
        remove_filter('teeny_mce_buttons', 'bbp_get_teeny_mce_buttons');
        remove_filter('quicktags_settings', 'bbp_get_quicktags_settings');
        /**
         * Fallback to normal textarea.
         *
         * Note that we do not use esc_textarea() here to prevent double
         * escaping the editable output, mucking up existing content.
         */
    } else {
        ?>

			<textarea id="bbp_<?php 
        echo esc_attr($r['context']);
        ?>
_content" class="<?php 
        echo esc_attr($r['editor_class']);
        ?>
" name="bbp_<?php 
        echo esc_attr($r['context']);
        ?>
_content" cols="60" rows="<?php 
        echo esc_attr($r['textarea_rows']);
        ?>
" tabindex="<?php 
        echo esc_attr($r['tabindex']);
        ?>
"><?php 
        echo $post_content;
        ?>
</textarea>

		<?php 
    }
    // Output something after the editor
    if (!empty($r['after'])) {
        echo $r['after'];
    }
    // Put the output into a usable variable
    $output = ob_get_clean();
    return apply_filters('bbp_get_the_content', $output, $args, $post_content);
}
 /**
  * Enqueue the required Javascript files
  *
  * @since bbPress (r3732)
  *
  * @uses bbp_is_single_forum() To check if it's the forum page
  * @uses bbp_is_single_topic() To check if it's the topic page
  * @uses bbp_thread_replies() To check if threaded replies are enabled
  * @uses bbp_is_single_user_edit() To check if it's the profile edit page
  * @uses wp_enqueue_script() To enqueue the scripts
  */
 public function enqueue_scripts()
 {
     // Setup scripts array
     $scripts = array();
     // Always pull in jQuery for TinyMCE shortcode usage
     if (bbp_use_wp_editor()) {
         $scripts['bbpress-editor'] = array('file' => 'js/editor.js', 'dependencies' => array('jquery'));
     }
     // Forum-specific scripts
     if (bbp_is_single_forum()) {
         $scripts['bbpress-forum'] = array('file' => 'js/forum.js', 'dependencies' => array('jquery'));
     }
     // Topic-specific scripts
     if (bbp_is_single_topic()) {
         // Topic favorite/unsubscribe
         $scripts['bbpress-topic'] = array('file' => 'js/topic.js', 'dependencies' => array('jquery'));
         // Hierarchical replies
         if (bbp_thread_replies()) {
             $scripts['bbpress-reply'] = array('file' => 'js/reply.js', 'dependencies' => array('jquery'));
         }
     }
     // User Profile edit
     if (bbp_is_single_user_edit()) {
         $scripts['bbpress-user'] = array('file' => 'js/user.js', 'dependencies' => array('user-query'));
     }
     // Filter the scripts
     $scripts = apply_filters('bbp_default_scripts', $scripts);
     // Enqueue the scripts
     foreach ($scripts as $handle => $attributes) {
         bbp_enqueue_script($handle, $attributes['file'], $attributes['dependencies'], $this->version, 'screen');
     }
 }
        /**
         * Put some scripts in the header, like AJAX url for wp-lists
         *
         * @since bbPress (r3732)
         *
         * @uses bbp_is_single_topic() To check if it's the topic page
         * @uses admin_url() To get the admin url
         * @uses bbp_is_single_user_edit() To check if it's the profile edit page
         */
        public function head_scripts()
        {
            // Bail if no extra JS is needed
            if (!bbp_is_single_user_edit() && !bbp_use_wp_editor()) {
                return;
            }
            ?>

		<script type="text/javascript">
			/* <![CDATA[ */
			<?php 
            if (bbp_is_single_user_edit()) {
                ?>
			if ( window.location.hash === '#password' ) {
				document.getElementById('pass1').focus();
			}
			<?php 
            }
            ?>

			<?php 
            if (bbp_use_wp_editor()) {
                ?>
			jQuery(document).ready( function() {

				/* Use backticks instead of <code> for the Code button in the editor */
				if ( typeof( edButtons ) !== 'undefined' ) {
					edButtons[110] = new QTags.TagButton( 'code', 'code', '`', '`', 'c' );
					QTags._buttonsInit();
				}

				/* Tab from topic title */
				jQuery( '#bbp_topic_title' ).bind( 'keydown.editor-focus', function(e) {
					if ( e.which !== 9 )
						return;

					if ( !e.ctrlKey && !e.altKey && !e.shiftKey ) {
						if ( typeof( tinymce ) !== 'undefined' ) {
							if ( ! tinymce.activeEditor.isHidden() ) {
								var editor = tinymce.activeEditor.editorContainer;
								jQuery( '#' + editor + ' td.mceToolbar > a' ).focus();
							} else {
								jQuery( 'textarea.bbp-the-content' ).focus();
							}
						} else {
							jQuery( 'textarea.bbp-the-content' ).focus();
						}

						e.preventDefault();
					}
				});

				/* Shift + tab from topic tags */
				jQuery( '#bbp_topic_tags' ).bind( 'keydown.editor-focus', function(e) {
					if ( e.which !== 9 )
						return;

					if ( e.shiftKey && !e.ctrlKey && !e.altKey ) {
						if ( typeof( tinymce ) !== 'undefined' ) {
							if ( ! tinymce.activeEditor.isHidden() ) {
								var editor = tinymce.activeEditor.editorContainer;
								jQuery( '#' + editor + ' td.mceToolbar > a' ).focus();
							} else {
								jQuery( 'textarea.bbp-the-content' ).focus();
							}
						} else {
							jQuery( 'textarea.bbp-the-content' ).focus();
						}

						e.preventDefault();
					}
				});
			});
			<?php 
            }
            ?>
			/* ]]> */
		</script>

	<?php 
        }
Example #7
0
/**
 * Use the WordPress editor setting field
 *
 * @since 2.1.0 bbPress (r3586)
 *
 * @uses checked() To display the checked attribute
 */
function bbp_admin_setting_callback_use_wp_editor()
{
    ?>

	<input name="_bbp_use_wp_editor" id="_bbp_use_wp_editor" type="checkbox" value="1" <?php 
    checked(bbp_use_wp_editor(true));
    bbp_maybe_admin_setting_disabled('_bbp_use_wp_editor');
    ?>
 />
	<label for="_bbp_use_wp_editor"><?php 
    esc_html_e('Add toolbar & buttons to textareas to help with HTML formatting', 'bbpress');
    ?>
</label>

<?php 
}
Example #8
0
/**
 * Use the WordPress editor setting field
 *
 * @since bbPress (r3586)
 *
 * @uses checked() To display the checked attribute
 */
function bbp_admin_setting_callback_use_wp_editor()
{
    ?>

	<input id="_bbp_use_wp_editor" name="_bbp_use_wp_editor" type="checkbox" id="_bbp_use_wp_editor" value="1" <?php 
    checked(bbp_use_wp_editor(true));
    ?>
 />
	<label for="_bbp_use_wp_editor"><?php 
    _e('Use the fancy WordPress editor to create and edit topics and replies', 'bbpress');
    ?>
</label>

<?php 
}
 /**
  * Load localizations for topic script
  *
  * These localizations require information that may not be loaded even by init.
  *
  * @since bbPress (r3732)
  *
  * @uses bbp_is_single_forum() To check if it's the forum page
  * @uses bbp_is_single_topic() To check if it's the topic page
  * @uses is_user_logged_in() To check if user is logged in
  * @uses bbp_get_current_user_id() To get the current user id
  * @uses bbp_get_forum_id() To get the forum id
  * @uses bbp_get_topic_id() To get the topic id
  * @uses bbp_get_favorites_permalink() To get the favorites permalink
  * @uses bbp_is_user_favorite() To check if the topic is in user's favorites
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
  * @uses bbp_is_user_subscribed() To check if the user is subscribed to topic
  * @uses bbp_get_topic_permalink() To get the topic permalink
  * @uses wp_localize_script() To localize the script
  */
 public function localize_topic_script()
 {
     // Single forum
     if (bbp_is_single_forum() || bbp_use_wp_editor()) {
         wp_localize_script('bbpress-forum', 'bbpForumJS', array('bbp_ajaxurl' => bbp_get_ajax_url(), 'generic_ajax_error' => __('Something went wrong. Refresh your browser and try again.', 'bbpress'), 'is_user_logged_in' => is_user_logged_in(), 'subs_nonce' => wp_create_nonce('toggle-subscription_' . get_the_ID())));
         // Single topic
         //} elseif ( (bbp_is_single_topic()) || (bbp_use_wp_editor()) ) {
     }
     if (bbp_is_single_topic() || bbp_use_wp_editor()) {
         wp_localize_script('bbpress-topic', 'bbpTopicJS', array('bbp_ajaxurl' => bbp_get_ajax_url(), 'generic_ajax_error' => __('Something went wrong. Refresh your browser and try again.', 'bbpress'), 'is_user_logged_in' => is_user_logged_in(), 'fav_nonce' => wp_create_nonce('toggle-favorite_' . get_the_ID()), 'subs_nonce' => wp_create_nonce('toggle-subscription_' . get_the_ID())));
     }
 }
Example #10
0
/**
 * Добавляет код в шапку сайта
 * 1. JS-переменная arreatData с нужными для цитирования данными
 */
function arreat_head()
{
    global $wp_version;
    $vars = array('wp_version' => intval(substr(str_replace('.', '', $wp_version), 0, 2)), 'wp_editor' => bbp_use_wp_editor() ? 1 : 0);
    echo '<script type="text/javascript">' . '/* <![CDATA[ */' . 'var arreatData = ' . json_encode($vars) . '/* ]]> */' . '</script>';
}