WordPress.org

Ready to get started?Download WordPress

Forums

Auto Prune Posts
Doesn't work on WordPress multisite (23 posts)

  1. handig
    Member
    Posted 3 years ago #

    Hi,
    Tried using it. But it doesn't seem to prune the posts.

    I set it to delete after 24 hours, but it doesn't seem to delete anything.

    Is there a way to check it?

    http://wordpress.org/extend/plugins/auto-prune-posts/

  2. shofer
    Member
    Posted 3 years ago #

    hey,

    there seems to be a bug in the plugin.
    it uses a function hat only loads the last 5 posts of a category instead of load all posts.

    additionally there is a barrier so that the prune process is only triggert once a hour.

    Workarounds:

    For the major bug: (Line near 135 of file auto-prune-post.php)
    Replace
    $myposts = get_posts("category=" . $cat_i);
    with

    $args = array( 'numberposts' => -1, 'category' => $cat_id );
                $myposts = get_posts($args);

    For testing do the prune on every page hit:
    Line 127 of file auto-prune-post.php: add a new line to set $lastrun false every time (remove this line after testing)

    $lastrun = get_transient('auto-prune-posts-lastrun');
    $lastrun = false;
  3. handig
    Member
    Posted 3 years ago #

    Hey Shofer,
    Thank you very much. It solved my problem.
    Do I understand it correctly that the prune process is still only triggert once a hour?

  4. shofer
    Member
    Posted 3 years ago #

    as long as you don't have the
    $lastrun = false
    line inserted the process is only triggert once a hour.
    This line makes only sense in case of testing.
    So you don't need to wait a hour to do your next test.

  5. handig
    Member
    Posted 3 years ago #

    Oh, so if the line $lastrun = false is included it runs every time someone goes to the website (wordpress frontend) and otherwise a visit will only trigger the auto prune process if this has not happened in the last hour.

    Thank you.

  6. ramon fincken
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks Shofer for reacting to handig !

    I just saw this topic.

    As for the "bug" to only take 5 posts and once an hour, this is intentional to reduce potential serverloads.

    I am working on a new version on which the timeout is 30 minutes and it will clear all posts:

    /**
    	 * Uses transient instead of cronjob, will run on wp call in frontend.
    	 */
    	function prune() {
    		$lastrun = get_transient('auto-prune-posts-lastrun');
    
    		if (false === $lastrun) {
    			$force_delete = ($this->conf['settings']['force_delete'] == 0) ? false : true;
    
    			// Walk
    			foreach($this->conf['config'] as $cat_id => $type)
    			{
    				foreach($type as $the_type => $values)
    				{
    					$period_php = $values['period_php']; // Will be in format so strtotime can handle this [int][space][string] example: "4 day" or "5 month"
    
    					// Get all posts for this category
    					$myposts = get_posts('category=' . $cat_id.'&post_type='.$the_type.'&numberposts=-1');
    					foreach ($myposts AS $post) {
    						$post_date_plus_visibleperiod = strtotime($post->post_date . " +" . $period_php);
    						$now = strtotime("now");
    						if ($post_date_plus_visibleperiod < $now) {
    							// GOGOGO !
    							//$this->delete_post_and_attachments($post->ID,$force_delete);
    
    							// Mail admin?
    							if(!empty($this->conf['settings']['admin_email']))
    							{
    								$body = "DEMO, no post is delete DEMO Deleting post ID : ".$post->ID. "\n";
    								$body .= "Post title : ".$post->post_title. "\n";
    								$body .= "Settings (Delete or Trash) : ".( ($force_delete) ? 'Delete' : 'Trash' ). "\n";
    								wp_mail($this->conf['settings']['admin_email'],'Plugin auto prune posts notification',$body);
    							}
    						}
    					}
    				}
    			}
    			//set_transient('auto-prune-posts-lastrun', 'lastrun: '.time(), 60*30); // 60*30 = 30 minutes
    		}
    	}
  7. ryanmc
    Member
    Posted 3 years ago #

    Any word on when the new version will be released?

  8. ramon fincken
    Member
    Plugin Author

    Posted 3 years ago #

    @Ryanmc : the expectation (planning) is somewhere next week, but certainly not on Monday

  9. deenorris
    Member
    Posted 3 years ago #

    Next week was two weeks ago. Should I start editing existing code or wait a few more days?

  10. ramon fincken
    Member
    Plugin Author

    Posted 3 years ago #

    It is in trunk -> http://wordpress.org/extend/plugins/auto-prune-posts/download/, please have some patience.

    I'm away this weekend.

  11. ramon fincken
    Member
    Plugin Author

    Posted 3 years ago #

    I have just committed version 1.1:

    = 1.1 =
    Second release<br/>
    Added: Custom post type support<br>
    Added: Trash OR force delete option<br>
    Added: Mail admin if post is deleted<br>
    Changed: Init method is now every 30 seconds, all posts are checked.<br>
    Added: If you add &prune=true in your admin plugin page the plugin will run manually (force run)<br>
  12. filament72
    Member
    Posted 3 years ago #

    The upgrade seems to have messed up the WP UI using multisite, I have no other options other than dashboard which has nothing on it but news & blog. No way to get to or edit anything else and now I have a "Auto prune posts plugin updated to new version" line at the top of my site. Something is not right with the upgrade.

  13. ramon fincken
    Member
    Plugin Author

    Posted 3 years ago #

    The update notice will only show once.

  14. filament72
    Member
    Posted 3 years ago #

    I had to completely uninstall the plugin after the upgrade. It rendered the wordpress UI useless. The left menu only had options for Dashboard(which only contained wp news and wp blog) and Profile, thats it! Could no longer get to anything else within the WP UI. After uninstall all returned to normal.

  15. ramon fincken
    Member
    Plugin Author

    Posted 3 years ago #

    Is there any way you can retrieve your PHP error logs (of the day you installed and noticed the error) and sent them to me?

  16. filament72
    Member
    Posted 2 years ago #

    Sorry it took so long. I really don't have a way to access but I did for the sake of trying, install the plugin fresh to the network and same result. The upgraded version does not work well with multisite, not as in working incorrectly, but bombs out the WPUI. Not sure if that is a known issue with multisite but figured I would put it out there. The old version works fine.

  17. ramon fincken
    Member
    Plugin Author

    Posted 2 years ago #

    Hmm interesting, as the previous version compared to this one does not have lots of GUI stuff differences.

    I'll try to setup a network over here on a clean install and see what happens. If your pages are completely blank ( so white page ) I would really appreciate an error log file.

  18. filament72
    Member
    Posted 2 years ago #

    The pages are not blank the WP UI look and feel are there, its just missing any options. The left menu only has options for Dashboard(which only contained wp news and wp blog) and Profile, thats it! Could no longer get to anything else within the WP UI. After uninstall all returned to normal.

  19. ramon fincken
    Member
    Plugin Author

    Posted 2 years ago #

    Are you running PHP4 or PHP5 ?

  20. filament72
    Member
    Posted 2 years ago #

    PHP5

  21. ramon fincken
    Member
    Plugin Author

    Posted 2 years ago #

    I am currently looking into this. Looks as if this has something to do with the submenu creation by my plugin.

  22. ramon fincken
    Member
    Plugin Author

    Posted 2 years ago #

    Update: the problem lies in the is_admin() function.

  23. ramon fincken
    Member
    Plugin Author

    Posted 2 years ago #

    Stand by for the new version.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic