Stagger Lee (@stagger-lee)

Forum Replies Created

Viewing 25 replies - 76 through 100 (of 117 total)
  • @stagger-lee

    Participant
    remove_filter( 'bbp_get_reply_content', 'bbp_make_clickable', 4);
    remove_filter( 'bbp_get_topic_content', 'bbp_make_clickable', 4); 

    @stagger-lee

    Participant

    Try to adapt this:

    add_filter( 'nav_menu_css_class', 'namespace_menu_classes', 10, 2 );
    function namespace_menu_classes( $classes , $item ){
        if ( in_array(get_post_type(), array('forum','topic','reply')) )
    	 {
            $classes = str_replace( 'current_page_parent', '', $classes );
            $classes = str_replace( 'menu-item-22902', 'current-page-parent', $classes );
        }
        return $classes;
    }

    @stagger-lee

    Participant

    You explained a bit confuse. You want parent-child menu highlightning ?
    I am afraid it is not possible that way. Your menu link is simple page with shortcode (page-id-502).

    @stagger-lee

    Participant

    Try to play with this in functions.php:
    For some buttons you will need to borrow them from TinyMCE advanced plugin and put in core folder, they dont come in the core. (emoticons, and some else, called “plugins”)

    function bbp_enable_visual_editor( $buttons = array() ) {
    	
    	$buttons['tinymce'] = array( 
    	'toolbar1' =>'bold, italic, underline, strikethrough, blockquote, alignleft, aligncenter, alignright, alignjustify, justifyfull, bullist, numlist, outdent, indent, cut, copy, paste, undo, redo, link, unlink, table, fullscreen, image, media, cleanup, help, code, hr, removeformat, sub, sup, forecolor, forecolorpicker, backcolor, backcolorpicker, charmap, visualaid, anchor, newdocument, pastetext, separator, wp_adv,wptadv,media,image',
        'toolbar2' => 'pastetext, pasteword, selectall, formatselect, fontselect, fontsizeselect, styleselect, strikethrough, outdent, indent, pastetext, removeformat, charmap, wp_more, emoticons, forecolor, wp_help,media,image', // 2nd row, if needed
        'toolbar3' => 'pastetext,pasteword,selectall,paste_as_text,preprocess,paste,media,image', // 3rd row, if needed
        'toolbar4' => 'media,image', // 4th row, if needed 
    	'plugins'  => 'anchor, code, insertdatetime, nonbreaking, print, searchreplace, table, visualblocks, visualchars, emoticons, advlist,wordpress,wplink, paste,fullscreen',
    		   ); // 4th row, if needed 
        $buttons['quicktags'] = array ('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
        return $buttons;
    }
    add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );
    add_filter('mce_buttons', 'bbp_enable_visual_editor');
    

    @stagger-lee

    Participant

    I meant more to update/upgrade bbPress to refresh it and make all patches.

    @stagger-lee

    Participant

    Yes indeed, it is flexible for any integration. But….but…but…i am so afraid of some plugins and functions in them that other forums scripts (must) have on default.

    – Quotes
    – Attachments
    – Views count
    – Unread forums/topics
    – Ignore User
    – Etc…some more.

    I mean, WP support forums for this plugins are like, developer was active like 6 months ago. It they help it is few sentences each month.
    I dont complain for this, they do it for free. Just saying it is a danger game.

    But, as long you dont update/upgrade bbPress/BuddyPress everything works i guess. There is small risk WP upgrade would ruin something.

    @stagger-lee

    Participant

    This seems to work, just tested. Adjust after need.
    Limit user upload by KB size:

    add_filter('wp_handle_upload_prefilter', 'f711_image_size_prevent');
    function f711_image_size_prevent($file) {
    
        // get filesize of upload
        $size = $file['size'];
        $size = $size / 1024; // Calculate down to KB
    
        // get imagetype of upload
        $type = $file['type'];
        $is_image = strpos($type, 'image');
    
        // set sizelimit
        $limit = 700; // Your Filesize in KB
    
        // set imagelimit
        $imagelimit = 7;
    
        // set allowed imagetype
        $imagetype = 'image/jpeg';
    
        // query how many images the current user already uploaded
        global $current_user;
        $args = array(
            'orderby'         => 'post_date',
            'order'           => 'DESC',
            'numberposts'     => -1,
            'post_type'       => 'attachment',
            'author'          => $current_user->ID,
        );
        $attachmentsbyuser = get_posts( $args );
    
        if ( ( $size > $limit ) && ($is_image !== false) ) { // check if the image is small enough
            $file['error'] = 'Image files must be smaller than '.$limit.'KB';
        } elseif ( $type != $imagetype ) { // check if image type is allowed
            $file['error'] = 'Image must be ' . $imagetype . '.';
        } elseif ( count( $attachmentsbyuser ) >= $imagelimit ) { // check if the user has exceeded the image limit
            $file['error'] = 'Image limit of ' . $imagelimit . ' is exceeded for this user.';
        }
        return $file;
    
    }

    @stagger-lee

    Participant

    Set a maximum upload count for users on a specific user role

    add_filter( 'wp_handle_upload_prefilter', 'limit_uploads_for_user_roles' );
     
    function limit_uploads_for_user_roles( $file ) {
      $user = wp_get_current_user();
      // add the role you want to limit in the array
      $limit_roles = array('contributor');
      $filtered = apply_filters( 'limit_uploads_for_roles', $limit_roles, $user );
      if ( array_intersect( $limit_roles, $user->roles ) ) {
        $upload_count = get_user_meta( $user->ID, 'upload_count', true ) ? : 0;
        $limit = apply_filters( 'limit_uploads_for_user_roles_limit', 10, $user,$upload_count, $file );
        if ( ( $upload_count + 1 ) > $limit ) {
          $file['error'] = __('Upload limit has been reached for this account!','yourtxtdomain');
        } else {
          update_user_meta( $user->ID, 'upload_count', $upload_count + 1 );
        }
      }
      return $file;
    }

    This action will fire when user delete attachment

    add_action('delete_attachment', 'decrease_limit_uploads_for_user');
    function decrease_limit_uploads_for_user( $id ) {
       $user = wp_get_current_user();
       // add the role you want to limit in the array
       $limit_roles = array('contributor');
       $filtered = apply_filters( 'limit_uploads_for_roles', $limit_roles, $user );
       if ( array_intersect( $limit_roles, $user->roles ) ) {
         $post = get_post( $id);
         if ( $post->post_author != $user->ID ) return;
         $count = get_user_meta( $user->ID, 'upload_count', true ) ? : 0;
         if ( $count ) update_user_meta( $user->ID, 'upload_count', $count - 1 );
       }
    }

    @stagger-lee

    Participant

    I just write this on trac. Needs to be restricted for users to see other attachments, they did not uploaded.

    function filter_my_attachments( $wp_query ) {
        if (is_admin() && ($wp_query->query_vars['post_type'] == 'attachment')) {
            if ( !current_user_can( 'activate_plugins' ) ) {
                global $current_user;
                $wp_query->set( 'author', $current_user->id );
            }
        }
    }
    add_filter('parse_query', 'filter_my_attachments' );
    
    add_filter( 'bbp_after_get_the_content_parse_args', 'tp_bbpress_upload_media' );
     
    function tp_bbpress_upload_media( $args ) {
    $args['media_buttons'] = true;
     
    return $args;
    }

    @stagger-lee

    Participant

    This would be managed very elegant with autosugest/autocomplete search and select field in backend.
    As ACF select field, or post objects field do it. I mean those 2 input fields in metabox for “Topic” and “Reply to” (user ?). Server limit is problem for classic select, but also huge view too. So search field with autocomplete would be prefect. It would i believe remove for long time all feature requests from users, to make it more manageable.

    @stagger-lee

    Participant

    Strange, not even changed passed. Do you have some list of blocked words here on forum ?

    @stagger-lee

    Participant

    Yes, so it is vith github and updates. I had some old code, testing something on my old website. Noticed on github changes for GD Attachments.
    Now it works very nice.

    Put this plugin in WP repository. It is very unique.

    @stagger-lee

    Participant

    @Robkk

    What is name of this option ? I cannot find it.
    I dont use plugin for visual editor, only manual code and media button is deactivated.

    Preview even doesnt work for non-admins. As I see “detach” option in images, I suspect GD bbPress Tools-Attachments is making this problem.

    In reply to: Picture

    @stagger-lee

    Participant
    function my_bbp_change_avatar_size($author_avatar, $topic_id, $size) {
        $author_avatar = '';
        if ($size == 14) {
            $size = 50;
        }
        if ($size == 80) {
            $size = 190;
        }
        $topic_id = bbp_get_topic_id( $topic_id );
        if ( !empty( $topic_id ) ) {
            if ( !bbp_is_topic_anonymous( $topic_id ) ) {
                $author_avatar = get_avatar( bbp_get_topic_author_id( $topic_id ), $size );
            } else {
                $author_avatar = get_avatar( get_post_meta( $topic_id, '_bbp_anonymous_email', true ), $size );
            }
        }
        return $author_avatar;
    }
    
    /* Add priority (default=10) and number of arguments */
    add_filter('bbp_get_topic_author_avatar', 'my_bbp_change_avatar_size', 20, 3);
    add_filter('bbp_get_reply_author_avatar', 'my_bbp_change_avatar_size', 20, 3);
    add_filter('bbp_get_current_user_avatar', 'my_bbp_change_avatar_size', 20, 3);
    /* We increased the tiny avatar size, so adjust the position */
    #bbpress-forums p.bbp-topic-meta img.avatar, #bbpress-forums ul.bbp-reply-revision-log img.avatar, #bbpress-forums ul.bbp-topic-revision-log img.avatar, #bbpress-forums div.bbp-template-notice img.avatar, #bbpress-forums .widget_display_topics img.avatar, #bbpress-forums .widget_display_replies img.avatar {
        margin-bottom: -2px;
    }
    /* Increase max-width for the big avatars */
    #bbpress-forums div.bbp-forum-author img.avatar, #bbpress-forums div.bbp-topic-author img.avatar, #bbpress-forums div.bbp-reply-author img.avatar {
    /*margin: 12px auto 0;*/
    max-width: 110px;
    }

    @stagger-lee

    Participant

    Problems with other forum scripts are (if we forget about WP integration for a moment) like this, and i have seen it more than often.

    People come to forum, relax, discussing, forget about time. But they forget about main portal too. It doesnt exist for them. I have seen many popular and crowded forums and people behind main portal lose money, time, energy to write editorials and news. Nobody is reading this, nobody “knows” about portal when they are on forum. And all try to make other forum scripts look a like something near CMS are madness, better not to go this way.

    Here you have old brother WordPress, so popular in the world. You discuss in the forum, suddenly sidebar widget display new article from portal, as it says “did you forget to read news”. Just one example of many of them.

    All is here, all exist to make bbPress (or BuddyPress) most popular forum script. To follow steps of WordPress.
    Smart core coders, wish exist, older brother WordPress is there to push bbPress in the front of other forum scripts.

    @stagger-lee

    Participant

    I am not saying all this because of me. I have now so many (tested) snippets and tweaks i can make bbPress more advanced than phpBB3 forum. I am thankfull to core guys, and I am not complaining.

    Integration (affinity better to say) with WP core is so amazing it just blow minds.

    I am saying this because of core coders guys. It is pitty lose hours, days, weeks and last nobody or very few people use bbPress.

    @stagger-lee

    Participant

    I read somwehere (or was it for BuddyPress, but it is the same logic), that you avoid new options and functions in core to reduce support. It is OK and understandable.

    I this sentence i said you can do much with only CSS and styling. To “sell” bbPress to WP beginners.
    It is very behind other forum software right now.

    WordPress has its own “demo” websites, all those nice and fancy themes around web. BbPress has it not.

    @stagger-lee

    Participant

    Old topic but. This can help. Check just if it doesnt interfere with sorting in backend and frontend for other things. Such plugins can do it sometimes and give undesired results. Watch your widgets too how they behave.

    https://wordpress.org/plugins/intuitive-custom-post-order/

    @stagger-lee

    Participant

    When you already use so much time and energy dont try to imitate Facebook. It is not worth it, and all this time can be used for something very unique for bbPress.

    @stagger-lee

    Participant

    Old topic but if it can help someone. Code is tested and still works, just formatting of code on this forum is wrong.

    add_filter('bbp_current_author_ip', 'my_anonymize_ip');
    
    function my_anonymize_ip($retval) {
    $retval = '0.0.0.0';
    return $retval;
    }

    @stagger-lee

    Participant

    A lot of work ? Looks very nice. I had to check source code to see if you are cheating. 🙂

    @stagger-lee

    Participant

    This seem to works. Or seems to work, I never know difference.

    add_filter('bbp_before_get_reply_author_role_parse_args', 'ntwb_bbpress_reply_css_role' );
    function ntwb_bbpress_reply_css_role() {
    
    	$role = strtolower( bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) ) );
    	$args['class']  = 'bbp-author-role bbp-author-role-' . $role;
    	$args['before'] = '';
    	$args['after']  = '';
    
    	return $args;
    }
    
    add_filter('bbp_before_get_topic_author_role_parse_args', 'ntwb_bbpress_topic_css_role' );
    function ntwb_bbpress_topic_css_role() {
    
    	$role = strtolower( bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) ) );
    	$args['class']  = 'bbp-author-role bbp-author-role-' . $role;
    	$args['before'] = '';
    	$args['after']  = '';
    
    	return $args;
    }

    @stagger-lee

    Participant
    add_action( 'bp_before_member_header_meta', 'devb_show_role_on_profile');
    function devb_show_role_on_profile(){
     global $wp_roles;
     
    $user_id = bp_displayed_user_id();
     
    $user = get_userdata( $user_id );
     
    $roles = $user->roles;
     
     if( !$roles)
     return ;
     
     if ( !isset( $wp_roles ) )
     $wp_roles = new WP_Roles();
     
     $named_roles = array();
     
    foreach( $roles as $role ){
     
    $named_roles [] = $wp_roles->role_names[$role];
     }
     
    if( $named_roles )
     echo '<span class="user-role activity">'. join( ', ', $named_roles ) . '</span>';
     
    }

    Showing User role on BuddyPress Profile

    @stagger-lee

    Participant

    This plugin shows all my attachment from media library in preview. Dont know why, i disabled it.

    @stagger-lee

    Participant

    I do it with this snippet. For WordPress and bbPress together. Local links are opened normally, only extern are target blank. Dont forget to change your domain line.

    // Make URL Clickable In WordPress, bbPress (plus target=”_blank”)
    add_filter( 'the_content', 'make_clickable');
    
    function autoblank($text) {
    $myurl = 'http://your-domain.com';
    $external = str_replace('href=', 'target="_blank" href=', $text);
    $external = str_replace('target="_blank" href="'.$myurl, 'href="'.$myurl, $external);
    $external = str_replace('target="_blank" href="#', 'href="#', $external);
    $external = str_replace('target = "_blank">', '>', $external);
    return $external;
    }
    add_filter('the_content', 'autoblank');
    add_filter('bbp_get_topic_content', 'autoblank',255);
    add_filter('bbp_get_reply_content', 'autoblank',255);

    Remove nofollow if you need to !

    function mtn_weekly_fix_rel_follow( $content ) {
        // Find rel="nofollow", replace with empty space.
        $content = preg_replace( '/rel="nofollow"/', ' ', $content);
        return $content;
    }
    add_filter( 'the_content', 'mtn_weekly_fix_rel_follow', 20 );
    add_filter('bbp_get_topic_content', 'mtn_weekly_fix_rel_follow',255);
    add_filter('bbp_get_reply_content', 'mtn_weekly_fix_rel_follow',255);
    
Viewing 25 replies - 76 through 100 (of 117 total)