1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Wordpress Autocycler

Discussion in 'Blogging' started by 0xfefefe, Jan 2, 2009.

  1. 0xfefefe

    0xfefefe Newbie

    Joined:
    Nov 5, 2008
    Messages:
    13
    Likes Received:
    4
    I am releasing a first of my wordpress plugins.

    http://0xfefefe.info/wordpress-plugins/wordpress-autocycler/

    Please tell me what you think. I know is basic, but I have been running it for a quite a long time now :)
     
    • Thanks Thanks x 2
  2. justAIMe

    justAIMe Junior Member

    Joined:
    Mar 7, 2008
    Messages:
    152
    Likes Received:
    68
    Occupation:
    I do stuff and things
    Location:
    ohio
    Your first post and you want someone to download something? nah passs lol
     
  3. 0xfefefe

    0xfefefe Newbie

    Joined:
    Nov 5, 2008
    Messages:
    13
    Likes Received:
    4
    It seems that post counter is broken. I have post in the shit list forum already today.
     
  4. oldenstylehats

    oldenstylehats Elite Member Premium Member

    Joined:
    Apr 10, 2008
    Messages:
    1,893
    Likes Received:
    1,196
    Thanks for posting this, 0xfefefe. I don't know if I'll get around to using it anytime soon, but when I do, I'll send you a PM. I love seeing people take guys like Eli seriously and develop tools like this.

    Thanks.
     
  5. 0xfefefe

    0xfefefe Newbie

    Joined:
    Nov 5, 2008
    Messages:
    13
    Likes Received:
    4
    It is small enough to post here. I am not here to play games.


    PHP:
    /**
     * Plugin Name: WP-Autocyler
     * Plugin URI: http://www.0xfefefe.info/     
     * Description: Checks post/page expiry time and possibly sets 301 redirect, using post meta.
     * Version: 0.1a
     * License: GPLv2 
     */
     
    /**
     * Load WP-Config file if this file is called directly
     */
    if (!function_exists('add_action')) {
            include_once(
    '../../../wp-config.php');
    }

    add_action('get_header','autocycler');
    function 
    autocycler() {
            if ( 
    is_home() || is_category() || is_archive() || is_tag() ) return;

            
    $post_id url_to_postid($_SERVER['REQUEST_URI']);
            
    $post_expire get_post_meta($post_id'post_expiry'true);
            if (
    $post_expire) {
                    
    $now time(); 
                    if (
    $now $post_expire) {
                            
    $redirect_url get_post_meta($post_id'redirect_url'true);
                            
    header("HTTP/1.1 301 Moved Permanently");
                            
    header("Location: " $redirect_url);
                            exit();
                    }
            }
    }

    ?>
     
    • Thanks Thanks x 1
  6. bus4400

    bus4400 Registered Member

    Joined:
    Nov 19, 2008
    Messages:
    56
    Likes Received:
    6
    good job, thanks for your working, hope you will get more what you want
     
  7. vegemite

    vegemite Registered Member

    Joined:
    Apr 28, 2008
    Messages:
    70
    Likes Received:
    23
    what's post/page expiry time ?
     
  8. istarapol

    istarapol Junior Member

    Joined:
    Jun 3, 2008
    Messages:
    110
    Likes Received:
    228
    Occupation:
    Graphic Designer
    Location:
    Under Your Bed
    Home Page:
    actually this is helpful.
    with a bit play between a autoblog + re-writer the plugin can help
    pull in traffic to your leads like crazy

    *thanks*
     
  9. 0xfefefe

    0xfefefe Newbie

    Joined:
    Nov 5, 2008
    Messages:
    13
    Likes Received:
    4
    When you make a post to wordpress there is the option to set "Custom Fields."

    Here is an image showing this (found via goog):
    [​IMG]


    Make two custom fields - One called "post_expiry" and another called "redirect_url" (whithout the quotes, of course)

    The post_expiry field is in UNIX Epoch format - or number of seconds from 00:00:00 UTC on January 1st, 1970.
    Meaning if you wanted a post to 'expire' (meaning 301 redirect) on Tue, 13 Jan 2009 16:57:39 GMT you would put 1231865859
    as the value for this particular post's post_expiry.

    The redirect_url is a complete URL - http://www.domain.com/sub-dir/subpage/whatever


    Remember this is on a per post basis, so both post_expiry and redirect_url custom fields are required on any post (or page) that you want to expire.
     
    Last edited: Jan 3, 2009
  10. istarapol

    istarapol Junior Member

    Joined:
    Jun 3, 2008
    Messages:
    110
    Likes Received:
    228
    Occupation:
    Graphic Designer
    Location:
    Under Your Bed
    Home Page:
    hmm, tried it. works well but
    can you do it in another time format epoch format is a bit confusing ;)
     
  11. 0xfefefe

    0xfefefe Newbie

    Joined:
    Nov 5, 2008
    Messages:
    13
    Likes Received:
    4

    Now that I have released wp-autocycler, I will put some time into making it a bit more user friendly. Unfortunately, I have one other non-im related project that has priority (i still have a damn day job, if u can call it that)

    Also, PHP is not my strong point. I am a perl hacker from way back...