Forum Replies Created

Viewing 15 replies - 16 through 30 (of 42 total)
  • widget-logic
    http://wordpress.org/extend/plugins/widget-logic/
    use a conditional like:
    is_page(“Page Z”);
    and the widget will only show on Page Z
    awesome plugin.

    Forum: Plugins
    In reply to: Curl crashing my site

    One of the most useful tools in the toolbox is phpinfo. Create a php file on the server (I usually call it phpinfo.php) and put the following line in it.
    <?php phpinfo(); ?>
    Pull it up with your browser, and it will tell you somewhere in the gobbledy-gook that short tags are disabled. If you don’t feel like looking for it, just change that one line in phpinfo.php to:
    <? phpinfo(); ?>
    and watch it break.
    Why would a plugin author write using short tags? I could see doing it if you were writing stuff that was always in your control, but if you are writing a plugin for distribution, where you can’t be certain of the enviroment it is going to be deployed on, why would you just assume that it was going to be enabled?

    Forum: Plugins
    In reply to: Feed ads by region

    Shouldn’t be to hard. Couldn’t find a wordpress function to get a visitor’s IP address, but there is a straight PHP predefined variable that should help.
    $_SERVER[‘REMOTE_ADDR’];
    You would have to check it against a list of what IP blocks are assigned to different countries.
    I got the idea from this rather defunct looking plug-in:
    http://wordpress.org/extend/plugins/show-visitor-ip-address/
    You might be able to start there and modify it to suit your needs.

    I had the same problem. I found some doc somewhere which says “If you put a stable tag in the readme.txt in the trunk, then the rest of the readme.txt in the trunk is ignored, and the readme.txt in the tags directory specified is used instead.” What it didn’t say is that the version number displayed on your download link is also taken from the specified tags directory, but from the version: XX line in your main php file. Change it on line 7 here:
    http://plugins.trac.wordpress.org/browser/todo-espaco-online-links-felipe/tags/0.3/teo-links.php?rev=379014
    And I bet it will change the download link button label.(give it about 15 minutes for the servers to update, maybe less depending on when the next cron job is scheduled)

    Seems to be working here:

    http://sidneyharrell.com/jqueryproblem.html

    Only problem I can see is if you hover on the child, and then go straight to the parent, the parents comment link doesn’t appear right away. You have to mouse out and then mouse back in. Weird. But the comment link of the parent doesn’t appear when you are hovering on the child, only the child’s comment link.

    I found this cool program called Tidy to clean up the html.
    tidy -im jqueryproblem.html
    -i for pretty printing and -m for modify in place.
    It gave me a bunch of warnings for problems with the html. Maybe one of them was keeping the jquery code from working.
    I noticed Chrome kept bugging me if I wanted to translate the page from Portugese. Are you from Brazil? I was listening to, I think it was the “Lately in JavaScript” podcast and one of the hosts is from Brazil. It’s a small world, after all.

    It’s probably some security software running on your system. Apache starts a service listening on port 80, and mysql starts a service listening on port 3306. I would expect some dialog box to open up asking you to allow a program to run as administrator after you try to start WAMP.

    Can you post a bigger sample of the html code? The sample you posted only has one level, and I need to see how you nested the comments.

    Wow, that is a hard problem. because the child is a part of the parent, when you are hovering on the child, you are also hovering on the parent. You could try the .parents selector.

    jQuery(document).ready(function(){
       jQuery(".comment-autor-meta .comment-responder").hide();
       jQuery(".commentlist li").hover(
          function() {
             jQuery(this).children("div.comentario").children("div.comment-autor-meta").children("div.comment-responder").stop(false, true).slideDown();
             jQuery(this).parents('li').children("div.comentario").children("div.comment-autor-meta").children("div.comment-responder").hide();
          },
          function() {
             jQuery(this).children("div.comentario").children("div.comment-autor-meta").children("div.comment-responder").stop(false, true).slideUp();
          }
       );
    });

    If you use children() instead of find() it will only go down one level. Since the hidden div is three levels below, use three calls to children.

    jQuery(document).ready(function(){
       jQuery(".comment-autor-meta .comment-responder").hide();
       jQuery(".commentlist li").hover(
          function() {
             jQuery(this).children("div.comentario").children("div.comment-autor-meta").children("div.comment-responder").stop(false, true).slideDown();
          },
          function() {
             jQuery(this).children("div.comentario").children("div.comment-autor-meta").children("div.comment-responder").stop(false, true).slideUp();
          }
       );
    });

    Basically, just change the greater than in the sql command to less than, and the order by ascending date to order by descending date. But I changed all the next to previous.

    function get_previous_post_by_author($link="%link &raquo;", $title="%title") {
            global $wpdb, $post;
            $post_categories = wp_get_post_categories( $post->ID );
            $previous_date=$post->post_date;
            do {
                $previous = $wpdb->get_row($wpdb->prepare("SELECT ID, post_title, post_date FROM $wpdb->posts WHERE post_type='post' AND post_status='publish' AND post_author='".$post->post_author."' AND post_date < '".$previous_date."' ORDER BY post_date DESC LIMIT 1;"));
                $previous_categories = wp_get_post_categories( $previous->ID );
                $previous_date=$previous->post_date;
                foreach($post_categories as $pc){
                    foreach($previous_categories as $nc){
                        if($pc>1&&$pc==$nc) {
                            $match=$previous;
                        }
                    }
                }
    
            } while(!$match && $previous);
            if($match) {
                    $title = preg_replace('/%title/',$match->post_title, $title);
                    echo preg_replace('/%link/', '<a href="'.get_permalink($match->ID).'" rel="previous">'.$title.'</a>', $link);
            }
    }

    Ok, I did some testing and got it figured out:

    <script type="text/javascript">
    jQuery(document).ready(function(){
       jQuery(".comment-autor-meta .comment-responder").hide();
       jQuery(".commentlist li").hover(
          function() {
             jQuery(this).find(".comment-autor-meta .comment-responder").stop(false, true).slideDown();
          },
          function() {
             jQuery(this).find(".comment-autor-meta .comment-responder").stop(false, true).slideUp();
          }
       );
    });
    </script>

    You might want to play around with the effects and pick something you like. I did slideUp and slideDown cause I didn’t like the way the link just popped in and out, and the stop calls are to prevent effect que buildup.

    Ok, I got it figured out. There were 3 problems with my previous code.
    1. I used $post->id when I was supposed to use $post->ID. It wasn’t picking up the array of catagory IDs, so of course wasn’t making any matches.
    2. I modified the test for a catagory match to exclude catagory 1, which is shared by all posts.
    3. The line to pull the post data out of the database only pulled the post ID and title, not the post_date, so it was going into an infinite loop.
    Here’s the updated code:

    function get_next_post_by_author($link="%link &raquo;", $title="%title") {
            global $wpdb, $post;
            $post_categories = wp_get_post_categories( $post->ID );
            $next_date=$post->post_date;
            do {
                $next = $wpdb->get_row($wpdb->prepare("SELECT ID, post_title, post_date FROM $wpdb->posts WHERE post_type='post' AND post_status='publish' AND post_author='".$post->post_author."' AND post_date > '".$next_date."' ORDER BY post_date ASC LIMIT 1;"));
                $next_categories = wp_get_post_categories( $next->ID );
                $next_date=$next->post_date;
                foreach($post_categories as $pc){
                    foreach($next_categories as $nc){
                        if($pc>1&&$pc==$nc) {
                            $match=$next;
                        }
                    }
                }
    
            } while(!$match && $next);
            if($match) {
                    $title = preg_replace('/%title/',$match->post_title, $title);
                    echo preg_replace('/%link/', '<a href="'.get_permalink($match->ID).'" rel="next">'.$title.'</a>', $link);
            }
    }

    I did a little testing on it, and it looks like it works now, but let me know if it works for you.

    I think this should work:

    <script type="text/javascript">
    $(document).ready(function(){
       $(".comment-autor-meta .comment-responder").hide();
       $(".commentlist li").hover(
          function() {
             this.find(".comment-autor-meta .comment-responder").show();
          },
          function() {
             this.find(".comment-autor-meta .comment-responder").hide();
          }
       );
    });
    </script>

    If someone can tell me why not, then I welcome the opportunity to learn something new! I’ve only been in javascript for a couple of months, so I know I have a lot to learn.

    It is either being placed in the header.php file or in the template file. To find out create an empty file in your theme directory and call it noad.php Add the following lines to it:

    <?php
    /*
    * Template Name: No Ad
    */
    get_header();
    ?>

    Switch the page that you are interested in to the No Ad template and load the page. It should only load the header. If you can see the ad, then the ad is being placed in the header.php file. If not, then open up the template file that the page was using before.(and switch back to that template) Assuming that the page is using the default template for pages, it would be page.php in your theme directory.
    Find the code that is placing the ad and wrap it so:

    <?php if(!is_page('The title of the No Ad Page')) { ?>
    // The code placing the ad...
    <?php } ?>

    If it is not the No Ad page, then the ads will be displayed. If it is the No Ad page, then the ad code will be skipped. There’s a great plugin that does the same for widgets called widget logic.

    All set up and running as a cron job every 15 minutes. The final script (the hostname has been changed to protect the innocent)

    <?php
    $host = 'imaginedc.net';
    $Request = "HEAD /uptime.html HTTP/1.0\r\nUser-Agent: Sidney Harrell\r\nHost: $host\r\n\r\n";
    $OkResults = array("200\D+OK", "200\D+Document\s+Follows", "302", "301");
    $port = 80;
    $Socket = @fsockopen($host, $port, $error_number, $error);
    if (is_resource($Socket))
          {
                 if ($Request != "") { fputs($Socket, $Request); }
                 if (!feof($Socket)) {
                    $Response = fgets($Socket, 4096);
                 } else echo('socket empty');
    
                 $Result = "Failed Bad Code\n";
                 $Error  = $Response;
    
                 foreach($OkResults as $exp_result) {
                    if (preg_match("/$exp_result/",$Response)) {
                       $Error = "";
                       $Result = "Ok";
                    }
                 }
             fclose($Socket);
          }
          else
    	  {
              $Result = "Failed to open socket\n".$error_number."\n".$error."\n";
    		  $Error = ((!$error) ? "Time out" : $error);
    	  }
    if ('Ok'==$Result) {
        mail('sidney@imaginedc.net', 'Server OK', 'Server still online');
    } else {
        mail('sidney@imaginedc.net', 'SERVER DOWN', 'DANGER!DANGER!DANGER! Server OFFLINE!');
    }
    ?>

Viewing 15 replies - 16 through 30 (of 42 total)