Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 1,351 through 1,375 (of 32,467 total)
  • Author
    Search Results
  • #225728
    Robin W
    Moderator

    this is a temporary fix, the bbpress authors are looking at a permanent one

    if( !function_exists( 'bbpress_browser_supports_js' ) ){
    	function bbpress_browser_supports_js() {
    		echo '<script>document.body.classList.remove("no-js");</script>';
    	}
    	add_action( 'wp_footer', 'bbpress_browser_supports_js' );
    }

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use

    Code Snippets

    #225727
    Robin W
    Moderator

    @johnjamesjacoby

    as far as I understand, the issue is detailed in changeset 7190 – yes?

    so it is basically to hide the ‘generate passwword’ in form-user-passwords.php if the user’s browser does not support js or it is disabled.

    If so, at the moment all bbpress pages end up with a no-js class as bbpress sets ‘no-js’ as the default, which means that the quicktags do not display on the topic and reply forms as they need js but the css thinks it is no-js, and the visual editor does not work for the same reasons.

    At the moment you only test for js using the script technique in form-user-passwords.php viz

    <script type="text/javascript">
    	document.body.className = document.body.className.replace( 'no-js', 'js' );
    </script>

    so I would suggest 1 of 2 approaches

    1. putting this test in more generally so it runs on any bbpress page (as usefully suggested by @webcreations907) maybe by adding to the main function, or adding a filter in \includes\core\filters.php to run the script

    so something like :

    add_filter ('bbp_body_class' , bbp_test_js) ;
    function bbp_test_js ($classes) {
    ?>
    <script type="text/javascript">
    	document.body.className = document.body.className.replace( 'no-js', 'js' );
    </script>
    <?php
    return $classes ;
    }

    so that others could disable it

    2. changing the class to bbp-no-js should work, if you do this in the bbp_body_class function and the form-user-passwords.php and in css, then I can no reason why it would not work if that is the sole intention of this.

    #225721

    @robin-w – any suggestions on improvements bbPress should make?

    I was thinking of renaming no-js to bbp-no-js to try and avoid an issue with other plugins or themes already doing something with that class, but I’m not sure that solves this specific problem.

    #225719

    There is also…

    do_action( 'bbp_add_user_subscription', $user_id, $object_id, $type );

    …and…

    do_action( 'bbp_remove_user_subscription', $user_id, $object_id, $type );

    …if you need something a bit more lower-level, that isn’t tied directly to the request handler.

    #225538
    Robin W
    Moderator

    @mr18 – then suggestion is to either use this in a child theme functions file, which will not lose settings on a main theme update, or use code snippets, which does not change on a theme update.

    #225537
    lisabeavers
    Participant

    I used code snippits and the first chunk of code you gave me and it appears to have worked! Thank you!

    #225533
    webcreations907
    Participant

    @robin-w if you remove the no-js in php, then it doesn’t allow the reason for adding it which would be to test if the browser supports javascript/jquery.

    Just an example
    Say you have a slider(JS dependent) that you only want to show if the browser supports js, then adding .no-js .my-slider{display:none;} would hide the slider if the browser didn’t support it, while if the browser supports JS then the no-js would be removed by JS and the slider would be displayed. Because the only way the class was removed was with JS which would verify the browser supports JS.

    So if you remove it with PHP then there is no test and the slider is shown regardless if the browser supports JS or not. Not sure what the percentage of browser users that have it disabled, sure it’s a very very small amount.

    You can see that in theme TwentyTwentyOne in template-functions.php the theme does it the same way I mentioned above in earlier post.

    Just wanted to mention it, hopefully it gets updated shortly and a fix gets out for it.

    #225532
    Robin W
    Moderator

    2.6.8 does not fix.

    so use either

    add_filter ('bbp_body_class', 'rew_unset_no_js') ;
    
    function rew_unset_no_js($classes) {
    	if (in_array ('single-forum', $classes) || in_array ('single-topic', $classes)) {
    		if (($key = array_search('no-js', $classes)) !== false) {
    			unset($classes[$key]);
    		}
    	}
    return $classes ;
    }

    or if that doesn’t work

    add_filter ('bbp_body_class', 'rew_unset_no_js') ;
    
    function rew_unset_no_js($classes) {
    	if (($key = array_search('no-js', $classes)) !== false) {
    			unset($classes[$key]);
    		}
    return $classes ;
    }

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use

    Code Snippets

    #225530
    Robin W
    Moderator

    as far as I know this action is fired on ANY subscribe/unsubscribe

    // Do additional subscriptions actions
    	do_action( 'bbp_subscriptions_handler', $success, $user_id, $object_id, $action, $object_type );
    #225484
    webcreations907
    Participant

    That’s good, glad that worked out for you.

    You could also put it in bbpress.php in the plugin itself, then when the fix comes out and the plugin is updated it would get rid of it.

    For others looking for a solution, I tried to edit my post above but couldn’t, when I mentioned functions.php I mean the functions.php file that is within your current active WordPress theme.

    #225483
    KevinPlusPlus
    Participant

    Webcreations907,

    This code snippet added to my functions.php does then show the Text / Visual tabs and allow switching between them.

    Not sure if that’s the permanent solution, but that does get things working without modifying the plugin code itself.

    Kevin

    #225482
    webcreations907
    Participant

    When no-js is used, it’s usually removed using javascript or jquery to check if the browser supports it as some people turn it off in there browser preferences.

    Try adding the below code to your functions.php or code snippet plugin, etc.

    
    if( !function_exists( 'bbpress_browser_supports_js' ) ){
    	function bbpress_browser_supports_js() {
    		echo '<script>document.body.classList.remove("no-js");</script>';
    	}
    	add_action( 'wp_footer', 'bbpress_browser_supports_js' );
    }
    

    Make sure to clear any caches and check to see if it works for you.

    #225477
    artmuns
    Participant

    the error is when the β€˜nonce’ does not validate.

    https://codex.wordpress.org/WordPress_Nonces

    I suppose I could try using translation to make it a friendly message but would rather try and fix it.

    function my_nonce_message ($translation) {
        if ($translation === 'Are you sure you want to do this?') {
           return 'Please try again.';
        } 
    
        return $translation;
    }
     
    add_filter('gettext', 'my_nonce_message');
    #225476
    Robin W
    Moderator

    the error is when the ‘nonce’ does not validate.

    https://codex.wordpress.org/WordPress_Nonces

    not sure what you can do about it, not my speciality πŸ™‚

    #225472
    Robin W
    Moderator

    @jjj Moving the ‘no-js’ class to the bottom of the ‘bbp_body_class’ function does not fix, as the quicktags toolbar is still not shown.

    the following filter fixes, but I’m not entirely sure what the introduction of then ‘no-js’ class to the function is doing, but I can’t see that the patch has any unintended consequences as it only runs on the relevant pages.

    add_filter ('bbp_body_class', 'rew_unset_no_js') ;
    
    function rew_unset_no_js($classes) {
    	if (in_array ('single-forum', $classes) || in_array ('single-topic', $classes)) {
    		if (($key = array_search('no-js', $classes)) !== false) {
    			unset($classes[$key]);
    		}
    	}
    return $classes ;
    }

    or if that doesn’t work

    add_filter ('bbp_body_class', 'rew_unset_no_js') ;
    
    function rew_unset_no_js($classes) {
    	if (($key = array_search('no-js', $classes)) !== false) {
    			unset($classes[$key]);
    		}
    return $classes ;
    }

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use

    Code Snippets

    FOR THOSE USING BBP-STYLE-PACK – I’ll issue a revised version incorporating this shortly until fixed in bbpress.

    #225465
    Robin W
    Moderator

    ok, in my testing

    working :

    function bbp_enable_visual_editor( $args = array() ) {
        $args['tinymce'] = true;
        $args['quicktags'] = false;
        return $args;
    }
    add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );

    not working

    function bbp_enable_visual_editor( $args = array() ) {
        $args['tinymce'] = true;
        return $args;
    }
    add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );
    #225453
    TreeTrail
    Participant

    This topic has been resolved! We discovered what was causing this problem. It was not any custom code or plugin update issue. It was simply that I had changed the bbPress Forum > Visibility from “public” to “private”. Evidentially this prevents a plugin (like bbPress Toolkit) or custom code (like ours) from accessing the information.

    #225444

    Can you please post the code snippet you are using to enable the visual editor?

    In my testing, it is working OK using these snippets:

    Enable Visual Editor

    #225438

    This is a deprecated argument that only appears when WP_DEBUG is turned on.

    The debug log itself is nothing to worry about. πŸ‘

    bbPress will address this once its minimum version is (legitimately) raised to 5.5.

    Thank you for letting us know here πŸ™

    #225435

    Revisions are totally a WordPress thing. It’s weird, but sounds accurate.

    Using Gravity Forms to create new topics & replies will bypass the “freshness” hooks that bbPress expects to run normally. This means that the “branch” of topics & forums in the “tree” of that submission won’t get walked up to the root, to tell that whole branch what its most recent content is.

    Once you post something yourself normally, the tree gets walked and everything looks OK.

    The function that would normally be called is bbp_update_topic(). It includes all of the extra meta data that needs to be added – including a call to bbp_update_topic_walker() that “walks” the branch in the tree.

    Lastly, it refreshes the last_changed cache key in the bbpress_posts cache group. You could try busting that cache on your Gravity Forms submission (to see if that’s enough) but I have a feeling it won’t be, and you’ll need to find the best way to trigger the update.

    #225427

    The body class code changed, which might be causing this.

    It is not intended, so 2.6.8 should fix it.

    #225419
    KevinPlusPlus
    Participant

    Hi,

    Yes, the same thing happened to us. It looks like it is because of line 971 in common/templates.php

    $bbp_classes = array( ‘no-js’ );

    Remove the no-js and the editor will come back.

    I don’t see any way to do this without directly editing the source code for the plugin. Hopefully an oversight that can be corrected.

    Kevin

    #225413
    Alexander Agnarson
    Participant

    I just found out this issue too, and it breaks all of my pages. All pages now has a bbpress body class.

    I kind of need an urgent fix – any code that I can add to fix it for now?

    #225393
    conniefournier
    Participant

    It appears that the post_parent is no longer updating in the database for some reason. So, I am trying to fix that, and to run the bbp update programatically as well because that seems to fix it when I run it on replies in the admin panel. This is the code I am using, but it isn’t working.

    This is what I have so far. Does anything look wrong to you?

    add_action( 'gform_post_submission', 'set_post_content', 10, 2 );
    function set_post_content( $entry, $form ) {
     
        //getting post
        $post = get_post( $entry['post_id'] );
       
       //getting meta values
        $topicID = get_post_meta($post,'_bbp_topic_id',true);
        $forumID = get_post_meta($post,'_bbp_forum_id',true);
    
    $reply_data = array('post_parent'=>$topicID);
    $reply_meta = array('forum_id'=>$forumID, 'topic_id' => $topicID);
    
    bbp_update_reply($reply_data,$reply_meta);
    
    }
    #225390
    Robin W
    Moderator

    without a deep dive into your code and gravity, we’ll need to guess at answers.

    I presume you are not running any caching software?

    if not then you could tie a new reply to the action on submission.

    so if you have data, then the new_reply_handler in \includes\replies\functions.php starting at line 125 might be what you need.

    if you have $_POST data, then it might be as simple as

    add_action( 'whatever_your_actions_hook_is', 'bbp_new_reply_handler', 10 );

Viewing 25 results - 1,351 through 1,375 (of 32,467 total)
Skip to toolbar