Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Add custom post type php error touch_time #7451
    mindmantra
    Participant

    Had same problem. Investigated a lot and came to conclusion to replacing the $pagenow comparison with ‘1’ would work without any issue.

    So <?php touch_time(($action == 'edit'), ($pagenow != 'post-new.php'), 4); ?>
    would become
    <?php touch_time(($action == 'edit'), 1, 4); ?>

    reason to put $pagenow check (only on post-new.php?) is beyond my understanding.

    @steve or @kevin may put some light into this!

    mindmantra
    Participant

    Hi, Had the same issue.

    The culprit is touch_time args passed in piklist\parts\meta-boxes\submitdiv.php line 218
    touch_time(($action == 'edit'), ($pagenow != 'post-new.php'), 4)

    This metabox is extending and “replacing” the post_submit_meta_box from wp-admin\includes\meta-boxes.php. If I’m not wrong this is only available in custom-post-types set by piklist function to add support for custom post statuses.

    Here’s the core issue, while original metabox in wp-admin sets touch_time( ( $action === 'edit' ), 1 ); replaced one in custom metabox by piklist tries to be smart to see if it’s NOT(?) on post-new.php page (are the datetime form fields are for-post or for-comments).

    Here’s the actual function being called touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) from ‘wp-admin\includes\template.php:684’. <b>$for_post</b> argument is tricky one. If it’s set for false then it forces touch_time to retrieve date for comment instead of post. (see line:700 $post_date = ($for_post) ? $post->post_date : get_comment()->comment_date;). <b><–this causes non-object error</b>

    What I’m not sure why check for ‘not equal’ where it should check for equal? This is causing touch_time getting second argument as false when on post-new.php thus calling get_comment() function on post context.

    Replacing != with == in touch_time() of piklist submitdiv.php solved the issue for me.

Viewing 2 posts - 1 through 2 (of 2 total)