Tagged: ,

This topic contains 6 replies, has 3 voices, and was last updated by  Steve 2 years, 1 month ago.

  • Author
    Posts
  • #7353

    tirins007
    Participant

    Hi

    When I follow this tut: https://piklist.com/learn/doc/replacing-wordpress-post-editor/ and replace an editor for a CPT i get an error if I leave ‘scope’ => ‘post’ in field definition.

    here is my field definition

    
    piklist('field', array(
        'type' => 'editor',
        'field' => 'post_content', 
        'scope' => 'post', 
        'label' => 'Blurb',
        'description' => 'A little write-up',
        'template' => 'default',
        'options' => array( 
          'wpautop' => true,
          'media_buttons' => true,
          'shortcode_buttons' => true,
          'teeny' => false,
          'dfw' => false,
          'quicktags' => true,
          'drag_drop_upload' => true,
          'tinymce' => array(
            'resize' => true,
            'wp_autoresize_on' => false
          )
        )
    ));
    

    error’s call stack goes like this:

    
    Call Stack
    #	Time	Memory	Function	Location
    1	0.0020	414728	{main}( )	.../post.php:0
    2	0.4912	22309800	include( '/srv/www/clove/current/web/wp/wp-admin/edit-form-advanced.php' )	.../post.php:173
    3	0.5871	22905984	do_meta_boxes( )	.../edit-form-advanced.php:693
    4	0.5876	22906544	Piklist_Meta::meta_box( )	.../template.php:1045
    5	0.5876	22906920	Piklist::render( )	.../class-piklist-meta.php:312
    6	0.5885	22915568	include( '/srv/www/clove/current/web/app/themes/sage/piklist/parts/meta-boxes/piklist-person.php' )	.../class-piklist.php:507
    7	0.5924	22971824	piklist( )	.../piklist-person.php:23
    8	0.5924	22971824	Piklist_Form::render_field( )	.../class-piklist.php:2456
    9	0.5924	22975712	Piklist_Form::get_field_value( )	.../class-piklist-form.php:1660
    
  • #7355

    Jason
    Keymaster

    Hi @tirins007!

    What’s the specific error, please? Thank you for providing the call stack but it helps to have the error, too. 🙂

    Also, which version of PHP are you using?

    Thanks!

  • #7358

    tirins007
    Participant

    Sorry my bad. It actually is a notice not an error:

    Notice: Array to string conversion in /srv/www/clove/current/web/app/plugins/piklist/includes/class-piklist-form.php on line 923
    My php version is 7.0.9

  • #7359

    Jason
    Keymaster

    Gotcha. I actually just fixed this today which will be included in the next release. PHP 7 changed the order in which nested variables are evaluated. To tie you over until the next release, go to that file and change the culprit line from
    array_push($return, $object->$field['field'] ? $object->$field['field'] : $field['value']);
    to this
    array_push($return, $object->{$field['field']} ? $object->{$field['field']} : $field['value']);

    Hope this helps! 🙂

  • #7360

    tirins007
    Participant

    fixed, awesome!

  • #7366

    Jason
    Keymaster

    Great! Glad to help!

  • #7870

    Steve
    Keymaster

The topic ‘error when replacing editor and specifying scope as post’ is closed to new replies.