gpt4 book ai didi

php - 在第 1025 行通知 : Array to string conversion in/var/www/html/mytheme/wp-includes/formatting. php

转载 作者:可可西里 更新时间:2023-10-31 22:50:21 24 4
gpt4 key购买 nike

我正在尝试使用 this script 在我的 metaboxes 文件中添加变量而不是自定义字段 ID

我在 redux 框架中添加了一些选项以提供更改自定义字段的可能性。

<?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 );

但在上面的示例中,我得到了 注意:第 1025 行/var/www/html/mytheme/wp-includes/formatting.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,但 metaboxes 无法保存。有没有办法让第一个代码工作?使用变量而不是自定义字段 ID?

最佳答案

您的 redux 变量之一似乎很可能包含数组而不是字符串。知道这一点后,您只需要弄清楚它是哪一个,并弄清楚您要查找的实际数据在哪里。

调试它的一种方法是将所有三个 redux 变量显式转换为字符串。 (例如 'id' => implode("***", $custom_videourl))。然后,一旦您弄清楚哪一个(或多个)是数组,您可能就会知道如何访问您真正想要的数据。

如果这不适合您,我建议将其添加到您的 wp-config.php 文件中:define( 'WP_DEBUG_LOG', true );

这将为您创建一个调试日志。然后您可以注销它(例如 error_log( print_r( $custom_videourl ) );我相信它通常将 debug.log 文件存储在 wp-content 文件夹中。

关于php - 在第 1025 行通知 : Array to string conversion in/var/www/html/mytheme/wp-includes/formatting. php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43077537/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com