ℹ️
Welcome to the archive of the old FlatPress support forum. Browse more than a decade of FlatPress wisdom! Login is disabled.

The current FlatPress support forum is available here: forum.flatpress.org
[Feature Request] Preposting
  • I want to be able to pre-post my blog entries, ie, write today an entry that will appear only after 7 days. While the datechanger plugin can be used to change the date into future, the entry will however appear on the blog as soon as I publish it. The feature requested is the automatism that, when the day of the entry comes, and only on that day, it will appear, without needing any further action from the blog owner. So, saving entries into draft isn't a solution to my needs.
  • again I didn't test this. save as fp-plugins/scheduledposts/plugin.scheduledposts.php it is meant to work together with datechanger, so they're both sort of hack-ish, since I don't have time to really think how to do it better. Enable ScheduledPosts plugin then save a post with a future date as a DRAFT. When that date/time is reached, the post should be published [get the code from the last post]
  • Tried just now and gives this error
    Warning: Wrong parameter count for array_unshift() in plugin.scheduledposts.php on line 15

    Also, after that error I couldn't access my local installation: the page keeps loading but nothing is shown (I don't know if it's related...)
  • yes, it's array_shift, actually. fixed
    the page keeps loading but nothing is shown (I don't know if it's related...)

    yes it's probably an infinite loop, since array_unshift never returns false.
  • Even with array_shift the page doesn't load... It returns a maximum execution time!
  • Thanks, Will test as soon as I get back my machine where I have webserver installed. :)
  • Posted By: marcoverga86Even with array_shift the page doesn't load...

    the bastard returned null -.-
  • There's one thing I don't understand about this plugin... How often the drafts are checked to see if there's a post in the future? Is it possible that is this the cause that makes the plugin not working?
  • Tested and corrected some issues. I've used pastebin to show the corrections I've made, See your original code at m1d8f9fd6 (prepend with h t t p : / / flatpress . pastebin . com I'm afraid an anti-spam module prevents my reply to be posted because of too much links... The same code, with my correction at m37c6b749 Or view the diff at http://flatpress.pastebin.com/pastebin.php?diff=m37c6b749 (Note: I've set the code to be stored at pastebin for 1 month)
  • Seems that the plugin works, but there's still something wrong... When enabling the plugin it returns two types of error:
    1. Fatal error: Maximum execution time of 30 seconds exceeded in core.draft.php on line 145 2. Fatal error: Maximum execution time of 30 seconds exceeded in core.blogdb.php on line 75

    but I can't tell why sometimes is error 1 and sometimes error 2!
  • Posted By: marcoverga86Seems that the plugin works, but there's still something wrong... When enabling the plugin it returns two types of error:
    1. Fatal error: Maximum execution time of 30 seconds exceeded in core.draft.php on line 145 2. Fatal error: Maximum execution time of 30 seconds exceeded in core.blogdb.php on line 75

    but I can't tell why sometimes is error 1 and sometimes error 2!

    This just means that your code is doing an infinite loop on the while() clause of the script plugin.scheduledposts.php, so, sometimes the time limit of 30 seconds is reached when the script is at core.draft.php, and sometimes, it is when the script is at core.blogdb.php Are you trying the original version of NWM, or my version above? I'd suspect the multiple use of $arr variable in 2 different meanings is the cause, that's why I changed the $arr inside the while() block. Here, the plugin (corrected) works fine. The only little issue I see is that when the post is pushed from drafts to published, the lable (Draft) remains on the admin panel, but only administrators see that.
  • I'm working on your version...
  • @dotmg, thanks for the fix, I didn't remember draft still had the "entry" prefix in the ID. as for the var name, remember I've thrown this hack together in half an hour copy/pasting the code (after a long day) :p Anyway, you're right I've ovewritten the var in the middle of the loop. Since I don't like having to unshift back an item, I'd suggest this change while (($id = next($arr)) && etc etc) { // // blah blah // array_shift($arr); } my first post should be fixed now. have a look..
  • Not yet working. For my PHP install, next($arr) returns boolean false, as the array has only one element. I wonder if using next() requires using current() once before. FYI, I've tried resetting the array before calling next() but, no success. Secondly, on my FlatPress install (It's Vivace but I don't know where to look for its numbered version), the drafts still have the "entry" prefix in the ID indeed. So, maybe to ensure backward compatibility if it has changed to "draft" somewhen, you could process like this : $id = bdb_idfromtime('entry', $x); if (!$the_draft = draft_parse($id)) { $id = bdb_idfromtime('draft', $x); //try "draft" if "entry" has failed if (!$the_draft = draft_parse($id)) continue; }
  • On my SVN still doesn't work... Entry remains in drafts!
    Posted By: DotMG(It's Vivace but I don't know where to look for its numbered version)

    Admin Area -> Maintain -> Check for updates
  • DotMG runs 0.803. @marcoverga86, are you running svn or 0.804? I'd like to upgrade to which version you use...
  • I'm running SVN last version... You can find it here!
  • Posted By: DotMGNot yet working. For my PHP install, next($arr) returns boolean false, as the array has only one element. I wonder if using next() requires using current() once before.

    oh shat[1]. we might use list(, $x) = each($arr), then. bear with me, I'm writing from university :D
    So, maybe to ensure backward compatibility if it has changed to "draft" somewhen, you could process like this :

    yes, of course. it was called draft in an early Beta of .804. I've just forgot it was changed back to entry. You know I didn't test yada yada. btw, feel free to play with this thing, you've got the idea anyway. [1] you know, the joys of having over 9000 ways to iterate over an array
  • DON'T use SVN unless you know what you're doing. You can update to 0.804.1 btw
  • tested, working kludge code :D $t) break; // let's assume the array is ordered array_shift($list); $id = bdb_idfromtime('entry', $x); if (!$the_draft = draft_parse($id)) continue; draft_to_entry($id); // removes 'draft' from the list of categories $id_cat = array_search('draft', $the_draft['categories']); unset($the_draft['categories'][$id_cat]); $success=entry_save($the_draft, $id); } $ff = serialize($list); @io_write_file(CACHE_DIR.'scheduledposts.tmp', $ff); } add_action('init', 'plugin_scheduledposts_publish'); if (! ( basename($_SERVER['PHP_SELF']) == 'admin.php' && // must be admin area @$_GET['p'] == 'entry' && // must be right panel @$_GET['action'] == 'write' && // must be right action !(@$_POST['timestamp'] || @$_REQUEST['entry']) // must be a new entry ) ) return; function plugin_scheduledposts_check() { if ($_POST['timestamp'] > time()) { // post is in the future if (!isset($_POST['flags']['draft'])) return; $ff = @io_load_file(CACHE_DIR.'scheduledposts.tmp'); if ($ff) $arr = unserialize($ff); $arr[] = $_POST['timestamp']; sort($arr); $ff = serialize($arr); @io_write_file(CACHE_DIR.'scheduledposts.tmp', $ff); } } add_action('init', 'plugin_scheduledposts_check', 100);
  • Posted By: marcoverga86How often the drafts are checked to see if there's a post in the future?

    Every hour? or once a day? Thanks you... excellent plugin.
  • Posted By: luganoEvery hour? or once a day? Thanks you... excellent plugin.

    each time someone enters your blog
  • This discussion has been closed.
    All Discussions
    Start a New Discussion

    Howdy, Stranger!

    It looks like you're new here. If you want to get involved, click one of these buttons!

    Categories

    In this Discussion