Category Visibility

I made a number of improvements to Keith McDuffee’s Category Visibility WordPress plugin version 0.31.

My changes include a security fix, performance boost and several bug fixes.

Download

Category Visibility 0.31-mp2.0 (requires WordPress 1.5.2)
Category Visibility 0.31-mp1.1 (requires WordPress 1.5.2)

ChangeLog

From 0.31-mp1.1 to 0.31-mp2.0:

  • Makes at most 1 extra database query per page display – compared to the original 0.31 which can realistically make over a hundred
  • More efficient filtering of the category list

    From 0.31-mp1 to 0.31-mp1.1:

  • Fixed an SQL syntax error

    From 0.31 to 0.31-mp1:

  • Big reduction in number of database queries
  • Filter feeds for user levels
  • Make frontpage display the last 10 visible posts
  • Filter single view properly
  • Make archive flag not affect category view
  • Make new categories visible to all by default
  • Distinguish between level 0 users and anonymous users
  • Don’t hide Pages by mistake
  • Doesn’t break categories not visible on front page

    Darcs repository: http://tova.fena.se/darcs/category-visibility/ (not browsable, sorry)

    Other patches

    I also made some patches that depend on changes to WordPress itself. These are not merged in the darcs repository.

    Make next/previous links refer to visible posts

    When you click a link to an post not visible to you, you end up at the 404 page. This renders the get_next_post() and get_previous_post() almost useless. To fix this I planted posts_join and posts_where hooks in those function, letting them take advantage of the “visible10” patch above.

    template_functions_links_1.5.1.2_mp001_hookup.patch (Ticket #1442)

    Don’t link to archives without visible posts

    Here is a pair of patches for filtering the chronological archives links through the Category Visibility plugin. This change removes the effectively dead links to chronological archives for which you don’t have access to any of the posts.

    A prerequisit for this to work is that get_archives() has to have filter hooks for archive_join and archive_where. It also builds heavily on my previous patches, none of which has been incorporated into official CV as of now.

    category_visibility_0.31_mp006_archive_links.patch
    template_functions_general_1.5.1.2_mp001_hookup2.patch (Ticket 1368)

    403 Access Forbidden page

    It’s only sensible that when Category Visibility denies you access from a page, you should be shown an HTTP 403 Access Forbidden error message. So I implemented that. Unfortunately WordPress does not support 403 pages, so I had to make patches for that too.

    category_visibility_0.31_mp008_403_support.patch
    wp_blog_header_mp001_403_support.patch
    functions_mp001_403_support.patch

32 kommentarer till “Category Visibility”

  1. Rodney Shupe Says:

    Are all your patches available for download already merged?

  2. Administratör Says:

    No, none of this is merged upstream. I developed these for CV 0.31 and there hasn’t been another release yet. No one seems to have noticed ticket 1442 either. Come to think of it, maybe I should make a ticket over at WP for my additions to categories.php as well.

    Anyway, feel free to try’em out. Just remember to report any problems. I’ll be happy to help.

  3. jim Says:

    Hi Mattias,

    possible to add a patch such that the filter does not apply to Pages. As you know Pages are also given category but you can’t change the category assigned. So when I activate the plugin, many of my Pages which were assigned to this category which I’ve made invisible, doesn’t appear on the site.

    Any suggestions? thanks.

  4. Administratör Says:

    I’m sorry Jim, but I can’t reproduce your problem.

    And the documentation disagrees with you on Pages having categories. So how do you assign those, anyway?

    However, I do know of a rough spot that from a distance looks at least semirelated to your problem. So I’ll make a patch for that now rather than later.

    If we’re lucky that will do the trick for you. Otherwise I will need alot more information. Like what versions you are using, what patches, your CV plugin configuration, etc.

  5. Administratör Says:

    And Jim, I forgot to ask. How does Category Visibility without my patches behave in this case?

  6. jim Says:

    Hi Mattias,

    yeah I know Pages can’t assign Category, but if you look at the Edit page of a Page, and look at the preview section at the bottom, you’d see the name of the category assigned to it. And in the MySQL db, wp_post2cat table will also have a value for each entry, posts or Pages, there’ll be a category assigned to it. But like you said, we can’t “reassign” them.

    I’m using WP1.5.3 and I didn’t use the unpatch one…coz i like the functionalities you included. :)

  7. Administratör Says:

    Yeah, I can see it now. Thanks for pointing that out! Who’da thunk?

    Great to hear you like them :)

  8. Jason Says:

    Hi,
    Thanks for the excellent patches, I was very happy to see the second one ‘Make frontpage display the last 10 visible posts’.
    Unfortunately, I cannot get it to work.
    As soon as I activate it I get ‘Not Found’ appearing on all my pages.

    If I look at the database, I can see it has created the wp_cat_visibility table, but it seems unable to add data to the table.
    If I untick a few boxes, and click update, it says ‘Changes Submitted’, but all the boxes are still ticked, and the table is still empty.

    Any ideas?

    Thankyou,
    Jason

  9. Administratör Says:

    Hi Jason!
    The table being empty explains both the “Not Found” and the checked boxes. But I don’t understand why your table isn’t populated.

    Have you tried the “Make new categories visible to all by default” patches, added a new category and checked the table?

    Also, how does the unpatched plugin behave?

  10. Sarah Says:

    Hi, I wanted to filter the category off the main page so that people could click on the list and view them in the Category page, but when I activated the Plugin It seems that there are no posts in the category?
    Do you have a patch for that and how do I put it into the current plugin?

  11. Administratör Says:

    Hi Sarah!
    Yeah, that sounds a bit like a patch I have. Try out my patched plugin now available from the top of this page. It includes that patch and a bunch of others.

  12. Sarah Says:

    http://38calibre.com/x/?cat=7

    Check out the Error and my problem. ( It says there are no posts, but there are.. and gives an error )

  13. Administratör Says:

    Oh, that again :p
    I’ll fix it tomorrow or the day after that. Don’t have time to do it any sooner. Sorry.

  14. Sarah Says:

    Just let me know when.
    Also, nothing shows up on the front? oh dear.

  15. Administratör Says:

    The SQL error on the category pages is fixed now.

    I can’t reproduce the front page error, but with any luck this fix deals with that as well. Maybe we’re using different plugins so the error doesn’t show here.

  16. jl Says:

    Hi! I don’t quite understand the patches… what am i supposed to do with them? And how do they relate to the main plugin? I’m afraid I don’t really have programming skills…

  17. Administratör Says:

    Hi jl,
    Patches describe changes to files. If you want to add a feature you apply the listed patches to the files indicated by their filenames.

    On any Unixlike system you apply patches with a tool called “patch”. On Windows I don’t know. A quick search turns up this http://drupal.org/node/23409

    But hey. Tell me what changes you’re interested in and I’ll drop you an email with a zip of the patched files.

  18. jl Says:

    hey! hmmm… you mean i don’t just append the patches to the “category-visibility-0.31-mp2.php” file? you mean I have to actually “do’ something on my hosting service… this sounds very tricky.

  19. Administratör Says:

    Right. These things cannot be done in a standard WordPress 1.5.2. You have to modify WP to support them.

  20. Rick Says:

    Hey, Mattias! Thanks for your improvements on the Category Invisibility plugin. You fixed the bugs that were plaguing me in the original version and in Ryan Pope’s version (various pages not showing up at all).

    However, with your version active, I get the following error instead of a category list when attempting to access my site when using the domain name (crabbynightowl.com):

    Warning: Invalid argument supplied for foreach() in /home/schrodin/public_html/crabbynightowl/wp-includes/template-functions-category.php on line 311
    * No categories

    My Wordpress install is in the main directory of a subdomain (crabbynightowl.schrodingersat.org), and pointing to that seems not to cause any problems. Have you any ideas how to remedy this?

    Thanks for your work so far!
    Rick

  21. Richard Says:

    Thankyou very much for this patched version.
    Multiple bugs been been fixed because of this!

  22. pcdinh Says:

    Have anyone made it compatible with upcoming Wordpress 2.0 yet?

    http://wordpress.org/download/nightly/

    Thanks

    [ the link was broken so I fixed it ]

  23. Mattias Says:

    pcdinh:
    Not that I know of. I haven’t tried out WP 2.0 at all.
    Anyway, does it have an ETA yet?

    Rick:
    I reply to your post before. I’m sorry :(
    Now it was a while since I looked, but I wasn’t able to reproduce your problem on my system. I also checked the code to find out what might happen. I couldn’t figure it out, so I began suspecting the problem was with your setup.

  24. David Says:

    It was officially announced this evening: http://wordpress.org/development/2005/12/wp2/

    Unofficially, it was available a few days ago :)

  25. NetAndif Says:

    Wow! After messing around a little with the original plugin, i finally found your version, and it works perfectly with WP1.5.1+. Thanks very much.

  26. Kenny Says:

    I installed and everything works great on firefox but not within IE

    Help!

  27. Kenny Says:

    ^more info

    It shows no posts found on main page and within any category.. works perfectly fine within internet explorer

  28. Kenny Says:

    edit: (unable to delete or edit posts)

    this is not a browser issue. My login was cached and it was showing all pages.

    new visitor can nto display any categories. hidden or not. if they log in with guest or higher login they can view them normally. So weird

    I’m running on wordpress 2.0

    www,poundit.ca (this is worksafe, not a porn site)

  29. Goblin Says:

    Thanks for this update, can now see posts in the archive.

  30. steadyvibe Says:

    I am having a problem with this plugin. It doesn’t exclude the posts from my monthly archives. I belive it also is causing a problem with my next and previous page tags. When i click to page 2 (eg: http://www.steadyvibe.com/page/2/), it does not display a previous page button even thought here are pages 3 (eg: http://www.steadyvibe.com/page/3/) and 4 (eg: http://www.steadyvibe.com/page/4/) after it?

  31. Marcus Says:

    I receive this error on wordpress 2.0.2

    WordPress database error: [Table ‘wordpress.wp_cat_visibility’ doesn’t exist….

  32. Mikkelsen Says:

    Hei!

    Alt virker fint med category visibility så lenge jeg er logget inn, med en gang jeg logger ut fra WP og skal teste siden blir alt feil, frontsiden, kategorier, o.s.v. Noen tips?

Kommentera