WordPress.org

Ready to get started?Download WordPress

Forums

Adminimize
[resolved] "invalid post type" error with dropdown menu? (10 posts)

  1. speedyp
    Member
    Posted 1 year ago #

    Hey - I love this plugin & want to use it on a multisite, but I've hit a major problem. I'm using a function which gives a dropdown category menu when a user selects new post. This makes them choose a category BEFRORE the post is created. The problem is that adminimize is causing an "invalid post type" error. I disabled all other plugins & I've tried all different settings but result is the same.

    PLEASE PLEASE PLEASE take a look at the code I'm using in functions.php and give me an idea why adminimize hates it... thanks!

    '//ADD DROPDOWN MENU TO CHOOSE NEW POST CATEGORY (CHOOSE THE CAT ID’S YOU WANT TO APPEAR)
    add_filter( 'load-post-new.php', 'wpse14403_load_post_new' );
    function wpse14403_load_post_new()
    {
    $post_type = 'post';
    if ( isset( $_REQUEST['post_type'] ) ) {
    $post_type = $_REQUEST['post_type'];
    }
    // Only do this for posts
    if ( 'post' != $post_type ) {
    return;
    }
    if ( array_key_exists( 'category_id', $_REQUEST ) ) {
    add_action( 'wp_insert_post', 'wpse14403_wp_insert_post' );
    return;
    }
    // Show intermediate screen
    extract( $GLOBALS );
    $post_type_object = get_post_type_object( $post_type );
    $title = $post_type_object->labels->add_new_item;
    include( ABSPATH . 'wp-admin/admin-header.php' );
    $dropdown = wp_dropdown_categories( array(
    'orderby' => 'name',
    'include' => '3, 4',
    'name' => 'category_id[]',
    'hide_empty' => false,
    'echo' => false,
    ) );
    $category_label = __( 'Create New' );
    $continue_label = __( 'Continue' );
    echo <<<HTML
    <div class="wrap">
    <h2>{$title}</h2>
    <form method="get">
    <table class="orange">
    <tbody>
    <tr valign="top">
    <th scope="row">{$category_label}</th>
    <td>{$dropdown}</td>
    </tr>
    <tr>
    <td></td>
    <th><input name="continue" type="submit" class="button-primary" value="{$continue_label}" /></th>
    </tbody>
    </table>
    <input type="hidden" name="post_type" value="{$post_type}" />
    </form>
    </div>
    HTML;
    include( ABSPATH . 'wp-admin/admin-footer.php' );
    exit();
    }
    // This function will only be called when creating an empty post,
    // via get_default_post_to_edit(), called in post-new.php
    function wpse14403_wp_insert_post( $post_id )
    {
    wp_set_post_categories( $post_id, $_REQUEST['category_id'] );
    }'

    http://wordpress.org/extend/plugins/adminimize/

  2. speedyp
    Member
    Posted 1 year ago #

    UPDATE / MORE INFO. On further investigation, I changed a bit of my code towards the end from hidden to text. This reveals an input field that is usually hidden and automatically filled with the post type "post". The adminimize plugin appears to prevent this from happening, even though I have not set it to hide anything? All settings are unchecked..

    <input type="text" name="post_type" value="{$post_type}" />

    Any ideas on this?

  3. Frank
    Member
    Plugin Author

    Posted 1 year ago #

    What is the error message? Is the invalid post type message from WP or PHP error. PLease set WP_DEBUG to TRUE and read the errors.

  4. speedyp
    Member
    Posted 1 year ago #

    Hey Frank - the error message is simply "invalid post type". It appears in a small white box, but I'm not familiar enough with wp or php to say what is generating the message.

    I just started trying debug mode for first time & I'm scared :O

    Really hope we can get this sorted - I've put a ton of work into this & am depending on your plugin to make life simple for my multisite users. I'll get back to you if I can find any more info
    Thanks

  5. Frank
    Member
    Plugin Author

    Posted 1 year ago #

    Can you send me your plugin or theme with your source, that I check this on my dev install?

  6. speedyp
    Member
    Posted 1 year ago #

    Here's a debug list generated when trying to create a new post from my dropdown menu. I'm surprised at the number of errors as everything normally works very well. Maybe it will give you a clue where the problem lies?

    Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /home/speedyp/public_html/wp-includes/functions.php on line 2758

    Notice: wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /home/speedyp/public_html/wp-includes/functions.php on line 2758

    Notice: Undefined variable: my_menu in /home/speedyp/public_html/wp-content/themes/solution/includes/core-additions.php on line 68

    Notice: Use of undefined constant THEMENAME - assumed 'THEMENAME' in /home/speedyp/public_html/wp-content/themes/solution/admin/ttpanel/theme-options.php on line 1494

    Notice: Use of undefined constant THEMENAME - assumed 'THEMENAME' in /home/speedyp/public_html/wp-content/themes/solution/admin/ttpanel/theme-options.php on line 1495

    Notice: Use of undefined constant THEMENAME - assumed 'THEMENAME' in /home/speedyp/public_html/wp-content/themes/solution/admin/ttpanel/theme-options.php on line 1506

    Notice: Use of undefined constant THEMENAME - assumed 'THEMENAME' in /home/speedyp/public_html/wp-content/themes/solution/admin/ttpanel/theme-options.php on line 1507

    Notice: Use of undefined constant THEMENAME - assumed 'THEMENAME' in /home/speedyp/public_html/wp-content/themes/solution/admin/ttpanel/theme-options.php on line 1522

    Notice: Use of undefined constant THEMENAME - assumed 'THEMENAME' in /home/speedyp/public_html/wp-content/themes/solution/admin/ttpanel/theme-options.php on line 1523

    Notice: Use of undefined constant THEMENAME - assumed 'THEMENAME' in /home/speedyp/public_html/wp-content/themes/solution/admin/ttpanel/theme-options.php on line 1538

    Notice: Use of undefined constant THEMENAME - assumed 'THEMENAME' in /home/speedyp/public_html/wp-content/themes/solution/admin/ttpanel/theme-options.php on line 1539

    Notice: Undefined index: action in /home/speedyp/public_html/wp-content/themes/solution/admin/ttpanel/ttpanel.php on line 46

    Notice: Undefined index: action in /home/speedyp/public_html/wp-content/themes/solution/admin/ttpanel/ttpanel.php on line 53

    Notice: Trying to get property of non-object in /home/speedyp/public_html/wp-admin/includes/template.php on line 871

    Notice: Trying to get property of non-object in /home/speedyp/public_html/wp-admin/includes/template.php on line 871

    Notice: Undefined index: page in /home/speedyp/public_html/wp-content/themes/solution/admin/ttpanel/ttpanel.php on line 9

    Invalid post type

  7. speedyp
    Member
    Posted 1 year ago #

    Delighted to send you anything that might help, or just give you site access if that's easier - how could we do that in a non public way??
    Cheers

  8. Frank
    Member
    Plugin Author

    Posted 1 year ago #

  9. speedyp
    Member
    Posted 1 year ago #

    Email sent - thanks :)

  10. speedyp
    Member
    Posted 1 year ago #

    FANTASTIC SUPPORT - THANKS

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic