WordPress.org

Ready to get started?Download WordPress

Forums

Plugin stopped working (5 posts)

  1. Niels84BE
    Member
    Posted 4 years ago #

    Since I upgraded to 2.9, a plugin I wrote (for internal use) stopped working. I've been trying to look at any parameters which might have changed names, but couldn't resolve any possibility. Can anyone have a quick look, and tell why it doesn't work? I tried outputting statements to log-files in several parts, but plugin doesn't even seem to be called...

    function shorten_url() {
    
    	global $post_ID, $wpdb, $table_name;
    
    	$table_name = 'wp_5c4ujq_shorturl';
    
    	$post = get_post($post_ID);
    
    	if (get_post_meta($post_ID, "short_url") != "") {
    		return true;
    	}
    
    	$max_short = $wpdb->get_var("SELECT short FROM $table_name WHERE id = (SELECT MAX(id) FROM $table_name)");
    	$new_short = alphaincr($max_short);
    
    	add_post_meta($post_ID, "short_url", "http://nwt.rs/" . $new_short, true);
    
    	$link  = get_permalink($post_ID);
    	$title = $post->post_title;
    	$content = $post->post_excerpt;
    	$stamp = date();
    
    	$wpdb->insert($table_name, array('short' => $new_short, 'url' => $link , 'title' => $title), array('%s','%s','%s'));
    
    	$length = strlen('http://nwt.rs/' . $new_short) + strlen('Nieuw artikel: ');
    
    	if (strcmp($title, substr($title, 0, 140 - $length)) == 0) {
    		$twitter_title = $title;
    	} else {
    		$twitter_title = substr($title, 0, 140 - $length - 3) . '...';
    	}
    
    	to_twitter('Nieuw artikel: ' . $twitter_title . ' - http://nwt.rs/' . $new_short);
    	to_facebook($title, 'http://nwt.rs/' . $new_short, $content);
    
    }
    
    add_action('publish_post', 'shorten_url');

    The other functions that are called, have nothing to do with WP, and should work fine. I know code isn't all that clean, but this is for internal use only.

    All help is more than welcome !

  2. WatchCount.com
    Member
    Posted 4 years ago #

    Wait, first question: If you were to empty out the function shorten_url() and replace the contents with something simple like echoing "Hello World!" or just die() (the latter probably not recommended in this case) -- is your function even being called? If not, then something's up with the add_action hook or thereabouts. If so, then the problem is within your code.

    I guess the above is obvious; I'm just not sure if shorten_url() is even being called.

    -WCC

  3. Niels84BE
    Member
    Posted 4 years ago #

    I just tried what you suggested, and it seems the function is indeed not being called. Which is odd, since I don't think the publish_post hook has been altered in version 2.9?

  4. WatchCount.com
    Member
    Posted 4 years ago #

    Well, here's the nitty-gritty on changes to 2.9. There's also the Trac history, but I never had the time to learn about the WP bug tracking system, so I'm not sure (yet) how to dig through there.

    Hmmmm.... There was something about post types and metadata with 2.9 that is new. Maybe those changes affect the post publishing hooks?

    I still have to sink my teeth into 2.9, so sorry I'm not of too much help at this point.

    -WCC

  5. Niels84BE
    Member
    Posted 4 years ago #

    Just tried the necessary things with 2.9 beta 1, but without any success though. I still cannot understand why the plugin stopped working since the upgrade, as all functions are among the most used...

Topic Closed

This topic has been closed to new replies.

About this Topic