Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Just the other day i came with the same error array_map(): Argument #2 should be an array.For some reasons my posted categories are still in json format and so php can’t parse them.
    Note: I’m working with a c# client app, so it’s out of context. I did some modification in /lib/endpoints/class-wp-rest-posts-controller.php Line No around 938 the function handle_terms as:


    protected function handle_terms( $post_id, $request ) {
    $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
    foreach ( $taxonomies as $taxonomy ) {
    $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;

    if ( ! isset( $request[ $base ] ) ) {
    continue;
    }
    $arr = $request[ $base ];
    if (!is_array($arr)) {
    $arr = json_decode($request[ $base ]);
    }
    $terms = array_map( 'absint', $arr);
    $result = wp_set_object_terms( $post_id, $terms, $taxonomy->name );
    if ( is_wp_error( $result ) ) {
    return $result;
    }
    }
    }

    * Just json decoding the $result[base] if not it’s an php array.*

    i got the same issue. i had to delete the jet pack plugin through ftp to unblock the port 80.

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