strpos (): аргумент № 1 ($ haystack) должен быть из строки типа, массив, приведенный < /p>
< /blockquote>
Код, от которого я получаю ошибку, является следующим: < /p>
Код: Выделить всё
// woocommerce field
if ( $field === '_gallery_images' ) {
// set the image prefix if there is one
$prefix = '';
if ( $tmp_field['prefix'] !== '' ) {
$prefix = $tmp_field['prefix'];
}
// if value is not an array, try to create one
// this may be due to comma separated urls or space separated
if ( ! is_array( $our_value ) ) {
// if we have comma separated URL's, create an array
if ( strpos( $our_value, ',' ) !== false ) {
$array = explode( ',', $our_value );
if ( is_array( $array ) ) {
$our_value = $array;
}
}
// if we have space separated URL's, create an array
// This next line is generating the error
if ( strpos( $our_value, ' ' ) !== false ) {
$array = explode( ' ', $our_value );
if ( is_array( $array ) ) {
$our_value = $array;
}
}
// if we have newline separated URL's, create an array
if ( strpos( $our_value, "\n" ) !== false ) {
$array = explode( "\n", $our_value );
if ( is_array( $array ) ) {
$our_value = $array;
}
}
}
< /code>
Он получает это значение от API и пытается взорвать URL -адреса SEP: < /p>
11104_105-b.jpg, 11104_105.jpg, 11104_105-c.jpg, 11104_105-d.jpg
< /code>
Я обновил сообщение с разделом полного кода, извините.if ( strpos( $our_value, ' ' ) !== false ) {
Вот полный журнал об ошибке
Код: Выделить всё
PHP Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given in /home2/miriamcoelho/public_html/wp-content/plugins/wpgetapi-api-to-posts/includes/class-wpgetapi-api-to-posts-importer.php:1703Stack
trace:#0 /home2/miriamcoelho/public_html/wp-content/plugins/wpgetapi-api-to-posts/includes/class-wpgetapi-api-to-posts-importer.php(1703): strpos(Array, ' ')
#1 /home2/miriamcoelho/public_html/wp-content/plugins/wpgetapi-api-to-posts/includes/class-wpgetapi-api-to-posts-importer.php(808): WPGetAPI_API_To_Posts_Importer->map_fields_and_add_data(Array, Array)
#2 /home2/miriamcoelho/public_html/wp-content/plugins/wpgetapi-api-to-posts/includes/class-wpgetapi-api-to-posts-importer.php(1065): WPGetAPI_API_To_Posts_Importer->create_posts(Array, Array, Array, '1207067011')
#3 /home2/miriamcoelho/public_html/wp-content/plugins/wpgetapi-api-to-posts/includes/class-wpgetapi-api-to-posts-importer.php(956): WPGetAPI_API_To_Posts_Importer->maybe_add_delete_posts_ajax(Array, '1207067011', Array)
#4 /home2/miriamcoelho/public_html/wp-includes/class-wp-hook.php(324): WPGetAPI_API_To_Posts_Importer->run_post_creator_ajax('')
#5 /home2/miriamcoelho/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#6 /home2/miriamcoelho/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#7 /home2/miriamcoelho/public_html/wp-admin/admin-ajax.php(192): do_action('wp_ajax_wpgetap...')
#8 {main}thrown in /home2/miriamcoelho/public_html/wp-content/plugins/wpgetapi-api-to-posts/includes/class-wpgetapi-api-to-posts-importer.php on line 1703
Подробнее здесь: https://stackoverflow.com/questions/796 ... rray-given