programing

주의: /var/www/html/mytheme/wp-includes/formating에서의 배열에서 문자열로의 변환.1025행의 php

bestprogram 2023. 4. 2. 12:00

주의: /var/www/html/mytheme/wp-includes/formating에서의 배열에서 문자열로의 변환.1025행의 php

스크립트를 사용하여 메타박스 파일에 사용자 지정 필드 ID 대신 변수를 추가하려고 합니다.

커스텀 필드를 변경할 수 있도록 redox 프레임워크에 몇 가지 옵션을 추가했습니다.

<?php
/*global from framework*/
global $redux;
/*custom fields options retrieved from redux framework*/
$custom_videourl = $redux['mytheme_videourl'];
$custom_duration = $redux['mytheme_duration'];
$custom_description = $redux['mytheme_desc'];
$fields = array(
    array(
     'label' => __( 'MP4/FLV & Youtube Url', 'framework' ),
     'desc' => __( 'Here you can add videos with mp4 format', 'framework' ),
     'id' => $custom_videourl,
     'type' => 'text'
    ),
    array(
     'label' => __( 'Video Duration', 'framework' ),
     'desc' => __( 'Example: 5:20', 'framework' ),
     'id' => $custom_duration,
     'type' => 'text'
    ),
    array(
     'label' => __( 'Video Description', 'framework' ),
     'id' => $custom_description,
     'desc' => __( 'Here you can write a description', 'framework' ),
     'type' => 'editor'
    )
);
$my_metaboxes = new custom_add_meta_box( 'mytheme_metaboxes', __( 'Video - Additional Information', 'framework' ), $fields, 'post', true );

그러나 위의 예에서는 Notice를 받았습니다. /var/www/html/mytheme/wp-includes/formating에서의 배열에서 문자열로의 변환.1025행의 php

따라서 변수 메타박스 없이 커스텀필드를 추가하면 다음과 같이 정상적으로 동작합니다.

$fields = array(
    array(
     'label' => __( 'MP4/FLV & Youtube Url', 'framework' ),
     'desc' => __( 'Here you can add videos with mp4 format', 'framework' ),
     'id' => 'mytheme_videourl',
     'type' => 'text'
    ),
    array(
     'label' => __( 'Video Duration', 'framework' ),
     'desc' => __( 'Example: 5:20', 'framework' ),
     'id' => 'mytheme_duration',
     'type' => 'text'
    ),
    array(
     'label' => __( 'Video Description', 'framework' ),
     'id' => 'mytheme_desc',
     'desc' => __( 'Here you can write a description', 'framework' ),
     'type' => 'editor'
    )
);
$my_metaboxes = new custom_add_meta_box( 'mytheme_metaboxes', __( 'Video - Additional Information', 'framework' ), $fields, 'post', true );

print_r을 사용해 봤지만 메타박스는 저장되지 않습니다.첫 번째 코드를 작동시킬 수 있는 방법이 있나요?사용자 지정 필드 ID 대신 변수를 사용하시겠습니까?

redux 변수 중 하나에 문자열이 아닌 배열이 포함되어 있을 가능성이 높습니다.어떤 데이터인지 파악하여 실제로 찾고 있는 데이터가 어디에 있는지 파악하기만 하면 됩니다.

이를 디버깅할 수 있는1가지 방법은 redux 변수 3개를 모두 문자열로 명시적으로 변환하는 것입니다.(예:'id' => implode("***", $custom_videourl)어느 어레이(또는 복수의 어레이)를 특정하면, 실제로 필요한 데이터에 액세스 하는 방법을 알 수 있을 것입니다.

이 방법으로 문제가 해결되지 않으면 wp-config.php 파일에 다음을 추가할 것을 권장합니다.define( 'WP_DEBUG_LOG', true );

디버깅 로그가 생성됩니다.그런 다음 로그아웃할 수 있습니다(예:error_log( print_r( $custom_videourl )보통 debug.log 파일을 wp-content 폴더에 저장합니다.

언급URL : https://stackoverflow.com/questions/43077537/notice-array-to-string-conversion-in-var-www-html-mytheme-wp-includes-formatti