WordPress.org

Ready to get started?Download WordPress

Forums

Trying to identify plugin (28 posts)

  1. RaynerApe
    Member
    Posted 9 years ago #

    There's a plugin at Coldforged.org, in the sidebar on the top, telling the user how many new items (posts and comments) have been published, and uses a cookie to track the user's last visit. I am not sure if this is publicly available plugin or a personal hack (the webmaster there is very talented, but doesn't openly give his email or I would have asked personally) so if anyone knows if it is, please help me put this on my website as well. Thanks in advance.

  2. Minna
    Member
    Posted 9 years ago #

    There is Alex King's Since Last Visit. I'm using a JavaScript-less one but can't remember how to get it off his site... I think I had to search for it in the archives.

  3. RaynerApe
    Member
    Posted 9 years ago #

    Thank you. I tried to install this script, but I started getting errors after I started adding the first lines of code. it says:

    Step 3.

    Add this line within the <head> tags of your index.php and wp-comments-popup.php pages.

    <?php require(bloginfo('url;').'/wp-content/plugins/wp-last-visit.php?type=js'); ?>

    Kubrik doesn't have head in index.php so I tried putting it in the header.php file... then errors started coming out.

  4. RaynerApe
    Member
    Posted 9 years ago #

    ?ŸÑ€?¸?¼?°Ñ‚?¸?²?½?¸ ? ?°?·?¼?¸Ñ??»?¸ Ñ? RaynerApe
    Warning: main(/wp-content/plugins/wp-last-visit.php?type=js): failed to open stream: No such file or directory in c:\program files\easyphp1-7\www\wordpress\wp-content\themes\default\header.php on line 5

    Fatal error: main(): Failed opening required '/wp-content/plugins/wp-last-visit.php?type=js' (include_path='.;C:\Program Files\EasyPHP1-7\php\pear\') in c:\program files\easyphp1-7\www\wordpress\wp-content\themes\default\header.php on line 5

  5. Minna
    Member
    Posted 9 years ago #

    What if you tried the non-JS one (that's a link to the zip file). I've got that working on my WP1.5 site (don't remember if I ever got the JS version working...)

  6. RaynerApe
    Member
    Posted 9 years ago #

    Ah you found it - many thanks. But I guess I will be requiring your help a little more here, because I have near zero PHP skills. While I don't ask for verbose step by step explanation - I guess I need some hints how to format these commands. The readme with the plugin says:

    /*---------------------------------

    include this code in your main page
    this must appear before any HTML has been sent

    ---------------------------------*/

    // include functions in my-hacks.php or index.php and wp-comments-popup.php
    require_once("wp-last_visit.php");

    // set lastvisit cookie
    ak_set_last_visit_cookie();

    /*---------------------------------

    this functions should be called outside the posts loop:

    ---------------------------------*/

    // show # new posts/comments banner
    ak_since_last_visit();

    /*---------------------------------

    these functions should be called within the posts loop:

    ---------------------------------*/

    // show indicator if post is new
    ak_new_post();

    // show indicator if comment(s) are new
    ak_new_comments();

    /*---------------------------------

    this functions should be called within the posts comments loop:

    ---------------------------------*/

    // show indicator if a comment is new on main page
    ak_new_comment();

    // show indicator if a comment is new in comments pop-up page
    ak_new_comment_popup();

  7. Minna
    Member
    Posted 9 years ago #

    Yup, I remember being quite baffled about the readme. I'll check my files to see where I've put the code bits... Be patient, it's going to take a while to write the reply :)

  8. Minna
    Member
    Posted 9 years ago #

    I have require_once("wp-last_visit.php"); in myhacks.php. If you don't use myhacks.php, you can put it in header.php (before the next one -- ak_set_last_visit_cookie)

    I have this in my header.php:
    <?php // set lastvisit cookie
    ak_set_last_visit_cookie(); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    so the ak_set_last_visit_cookie() goes before everything (keep your doctype intact)

    If you don't use popup comments you don't need to put that "require" bit in there.

    <?php ak_since_last_visit(); ?> could go in sidebar, for example

    <?php ak_new_post(); ?> I have in my post's metadata (date and things), you can put it anywhere inside the if(have_posts()) loop (in index.php/Main template)

    <?php ak_new_comments();?> is next to my Comments link inside the post loop, just like the previous code

    I assume <?php ak_new_comment(); ?> would go somewhere inside the commentlist (for example before "Comment by" or whatever there is), but I don't use it so I can't be sure of its function.

    Hope this helps :)

  9. RaynerApe
    Member
    Posted 9 years ago #

    Okay I did it. I had to <?php ?> each function, without any other changes. It went perfectly clean. I also tested it and noticed it shows a new sign even for the admin and also it doesn't seem to disappear immediately after the topic is checked - what is the algorithm used, if you know it, and when will "new" posts and comments lose their status?

  10. Minna
    Member
    Posted 9 years ago #

    I assume it compares the cookie timestamp to the post/comment timestamps and if post/comment stamps are newer it shows the sign. I don't know how often the cookie is set but it's something like 'on every visit' so you'd have to close the page and come back later. The interval could be longer than that, though. You can see the last set cookie in the message so you can do some research on that :)

    Edit It could be on hour intervals... I haven't explored the world of cookies

  11. RaynerApe
    Member
    Posted 9 years ago #

    I ask because I am not sure if all is set well and if I won't run into "permanent new" status... you know, the usual paranoia from someone who's not very content with hacking PHP code.

  12. Minna
    Member
    Posted 9 years ago #

    I'm sure it's alright. That feature of not losing the New signs right away is the way it should work. Think if you lost all the new signs the instant you browsed to a site and there had been loads of new comments and posts. Not good. :) Check it again tomorrow (or later today -- depending on the current time of day) and I'm sure it'll work well.

  13. RaynerApe
    Member
    Posted 9 years ago #

    Thanks a lot for your help. This is one of my favourite plugins - the second I saw it on Coldforge.org I knew this is what I need for visitors who come rarely.

  14. davincim
    Member
    Posted 9 years ago #

    I'm glad this was posted because I was trying just a few days ago and got baffled myself.

    After uploading this plugin to my plugins directory, it won't even show in my plugin panel. Any ideas as to why that's happening? Thinking maybe it didn't require such activation (unusual though) I went ahead and inserted:

    <?php ak_since_last_visit(); ?>
    <?php ak_new_post(); ?>

    in my sidebar just to see what it would do. All I got was this error:

    "Fatal error: Call to undefined function: ak_since_last_visit() in /hsphere/local/home/galen5/familywebwatch.com/blog_test/wp-content/themes/Blix/sidebar.php on line 44"

    So obviously I'm missing something. :(

    Minna - you seem to have whittled this stuff down pretty well. Does that mean users need only put the code they're interested in where they want and still have it work?

  15. Minna
    Member
    Posted 9 years ago #

    Actually, I think it's not a plugin. I have it in my blog root. I have no idea where it says where to put the file, though... I must've seen it somewhere. Maybe with the instructions for the JS version...

    Did you remember that require_once bit as the first thing on your page (header.php) -- or in myhacks.php?

    There are some restrictions as to where to put the code bits. You see them in the read me.

  16. davincim
    Member
    Posted 9 years ago #

    Thanks, Minna. I'll try putting it in the blog root to see if that helps. :)

  17. davincim
    Member
    Posted 9 years ago #

    Okay, I'm back at this again.

    I believe I've put everything where it should be.

    - the index.php has this in it:

    <?php if (have_posts()) : ?>
    <?php // show indicator if post is new
    ak_new_post(); ?>

    <?php // show indicator if comment(s) are new
    ak_new_comments(); ?>

    - header.php has this at the very beginning of the document:

    <?php // set lastvisit cookie
    ak_set_last_visit_cookie(); ?>

    - and sidebar.php has:

    <?php // show # new posts/comments banner
    ak_since_last_visit(); ?>
    <?php ak_new_post(); ?>

    I've placed the "wp-last_visit_no_js" here: http://www.familywebwatch.com/blog_test/wp-last_visit_no_js
    - the folder containing the images ("ak-img") also resides in the folder above.

    So when I access my blog I get this error message:

    Fatal error: Call to undefined function: ak_set_last_visit_cookie() in /hsphere/local/home/galen5/familywebwatch.com/blog_test/
    wp-content/themes/Blix/header.php on line 2

    Can you find anything screwy here?

  18. RaynerApe
    Member
    Posted 9 years ago #

    How about removing those // comments from the <?php ?> codes? I haven't put any, and it works for me.

  19. Minna
    Member
    Posted 9 years ago #

    davincim, where do you have the <?php require_once("wp-last_visit.php"); ?>?

  20. davincim
    Member
    Posted 9 years ago #

    Thanks you two!

    @RaynerApe - I removed them; looked kind of weird anyway. :)

    @Minna - Good call. I missed that one, but adding it didn't make the error go away unfortunately. I added it near the top of my index.php:

    <?php if (have_posts()) : ?>
    <!-- since last visit -->
    <?php require_once("wp-last_visit.php"); ?>

    <?php ak_new_post(); ?>

    <?php ak_new_comments(); ?>
    <!-- end -->

    The instructions say to also put it in the wp-comments-popup.php (a.k.a. comments-popup.php for v1.5, right?), but I don't use popups for my comments. Does that mean it should go in my comments.php?

    I should also correct something I said earlier. I said "wp-last_visit_no_js" was placed in the blog root. I should have said "wp-last_visit.php".

    Btw, the file has this in there:


    // Modified by Dougal Campbell <URL:http://dougal.gunters.org/> 20030911
    // replaced mysql_*() calls with ezSQL calls
    // modified cookie code to derive info from $siteurl
    // renamed cookies with 'wp' instead of 'b2'
    //
    // include this file or paste the functions into your page

    // set $path and $domain as appropriate to your server. In most cases,
    // you'll want $path to match your WordPress install directory. If your
    // site is accessible by multiple subdomain names, like "example.com"
    // and "www.example.com", then set $domain to ".example.com"

    // By default, we'll try to derive them from the site url defined
    // in the Base Settings options:
    $urlinfo = parse_url($siteurl);

    $path = $urlinfo['path'];
    $domain = $urlinfo['host'];

    Am I at the point of needing to spell it out for this to work, or do you think it knows where to look for the information it's seeking (i.e. path, domain)?

    Again thanks for helping me. I feel we're close to fixing it (crosses fingers).

  21. Minna
    Member
    Posted 9 years ago #

    I have <?php require_once("wp-last_visit.php"); ?> in myhacks.php (without the <? stuff because myhacks is in a big php tag block, at least mine is) and I assume it (myhacks.php) gets run first. You need to put that (<?php require_once("wp-last_visit.php"); ?>) as the very first thing on your page. That is either in myhacks.php or in header.php as the first thing (before setting the cookie), thus:
    <?php
    require_once("wp-last_visit.php");
    // set lastvisit cookie
    ak_set_last_visit_cookie();
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    (doctype/html is there for just as an example, don't replace yours)

    As you don't use popup comments you don't have to worry about putting require_once in any comment related templates. If the comment page was a separate html block (as is the case for popups), you'd need it.

    So, one more try :) (don't get me wrong, I'm up for lots more) The require_once doesn't go as the first thing in the Loop, but the whole page. Even before doctype and setting the cookie (see example above).

    If even that doesn't help, you could try putting the domain name manually. I didn't even notice that bit...

    Yes, hopefully it'll start working. I'm determined to get it working! :) (Hopefully my reply makes any sense, it's a bit long -- if I'm blabbing something no one understands, tell me)

  22. davincim
    Member
    Posted 9 years ago #

    Ohmygosh, Minna! It worked...well, almost. Your instruction to include

    <?php
    require_once("wp-last_visit.php");
    // set lastvisit cookie
    ak_set_last_visit_cookie();
    ?>

    all together I think it was did the trick (sorry I missed that earlier). My sidebar now says:

    0 new posts and 0 comments since your last visit on April 4, 2005 @ 1:35 pm

    Now that we're in to the homestretch, I need just a little more help to make sure I can get the images showing. Here's my code for the index: http://www.pastebin.com/267060

    I've placed the indicators just below <?php if (have_posts()) : ?>. I'm guessing they need to be moved somewhere closer to the post title, so should I put them next to, say, <h2><a href="<?php the_permalink() ?>" title="Permalink to: <?php the_title(); ?>"><?php the_title(); ?></a></h2> (around line 58 I think)?

    Also, if I'm not mistaken, I figured I should have the image I want it to call as the only image in the ak-img directory. Is that right?

    And lastly, to test I sent a post to see what would happen. The text in my sidebar didn't change. I suppose that's because my blog figures if I'm there when it was posted, then it's not really new. So is the trick to deleting the cookie?

    Minna, you've been amazingly helpful. I appreciate your endurance. :)

  23. Minna
    Member
    Posted 9 years ago #

    Is this double Loop intentional (or not double *loop* but anyway):
    <?php if (have_posts()) : ?>
    <!-- since last visit -->
    <?php ak_new_post(); ?>
    <?php ak_new_comments(); ?>
    <!-- end -->
    <?php while (have_posts()) : the_post(); ?>

    or did you add it based on my instructions? If you did, then you can take it away and put the ak_new_post() and ak_new_comments() somewhere in the post's information. The place you suggested for new post indicator (h2) is good and the other should be somewhere close to the link to comments (near <?php comments_popup_link('Add comment', '1 comment', '% comments', 'commentlink', ''); ?>).

    What else... oh, the image. I've changed the code a bit because I put the image in a different folder, but in several functions (in wp-last_visit.php) you can see an img tag in the function call after $html. There you can see what image it's looking for and change the name/path the way you want it to be.

    Hmm... the 0 posts 0 comments is baffling me now. *picks up her magnifying glass*

  24. davincim
    Member
    Posted 9 years ago #

    Minna - with your help I got it to work! [leaves keyboard to do a victory dance...]

    I had to fiddle a little bit with the placement, but got the images where I want them PLUS the text at the top of my sidebar is reading 1 post and 2 comments, blah blah.

    If I could ask just one more thing (pretty pretty please :) ), I can't get it to behave correctly on the post page. Look at this first:

    http://familywebwatch.com/blog_test/2005/04/04/another-new-post/#comments

    The first and only comment says it's from site admin and so on, and just before the gravatar there's "NEW" in text. I've outlined the path to the image just like all the other functions, but this one's being stubborn (okay, okay, it's not; most likely it's me).

    Do you have any ideas for that one?

    I really could NOT have done this without you, Minna. Thank you so much. ;)

  25. davincim
    Member
    Posted 9 years ago #

    Hmmm, I think something's broke. Whenever I clicked on my pages in my top nav bar ("Contact", "Archive", etc.) I get the following message:

    Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/galen5/familywebwatch.com/blog/wp-content/themes/Blix/contact.php:7) in /hsphere/local/home/galen5/familywebwatch.com/blog/wp-last_visit.php on line 55

    If I read the first sentence correctly, then line 7 of contact.php is: <?php get_header(); ?>

    And line 55 of wp-last_visit.php is: );

    My site is: http://familywebwatch.com/blog/

    Any thoughts as to why this is happening?

  26. Kafkaesqui

    Posted 9 years ago #

  27. davincim
    Member
    Posted 9 years ago #

    Thanks for that, Kaf. Armed with that information, I searched through my files and didn't find any extra space. The only file I'm suspcious of is the plug-in itself (which isn't something you activate, btw; it's sitting in my blog root).

    Anyway, that file starts out with this:

    <?
    // WP Since Last Visit
    // version 1.3, 2004-01-16
    //
    // Copyright (c) 2002-2004 Alex King
    // http://www.alexking.org/software/wordpress/
    //
    // This is an add-on to WordPress weblog / news publishing tool
    //

    I guess I was anticipating a <?php at the beginning. I tried it with that modification and it still didn't change anything.

    Any other ideas are welcome. :)

  28. davincim
    Member
    Posted 9 years ago #

    Can anyone suggest a solution to my header problem?

    As you might have seen above, I modified the header.php with:

    <?php
    require_once("wp-last_visit.php");
    // set lastvisit cookie
    ak_set_last_visit_cookie();
    ?>

    Could that have anything to do with it?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.