如何在wordpress中创建以php代码作为内容的页面

如何在wordpress中创建以php代码作为内容的页面,php,wordpress,Php,Wordpress,我正在开发一个插件,可以从管理员端获取输入,比如API键等,并将其保存为WordPress数据库中的选项。该插件还创建了一个带有默认嵌入页面代码的页面(客户将看到)(嵌入页面embed.php保存在插件目录中) 我已经把这个发给WordPress审查了。他们拒绝了。所以,现在我需要让菜单页面直接与API(存储在数据库中的API值)交互,而不嵌入页面(embed.php)。如何使用默认PHP代码创建页面(进行API调用并从API检索数据) PHP内容将是: global $options;

我正在开发一个插件,可以从管理员端获取输入,比如API键等,并将其保存为WordPress数据库中的选项。该插件还创建了一个带有默认嵌入页面代码的页面(客户将看到)(嵌入页面embed.php保存在插件目录中)

我已经把这个发给WordPress审查了。他们拒绝了。所以,现在我需要让菜单页面直接与API(存储在数据库中的API值)交互,而不嵌入页面(embed.php)。如何使用默认PHP代码创建页面(进行API调用并从API检索数据)

PHP内容将是:

global $options;
    $get_values = get_option('plugin_options');
    $api_key = $get_values['api_key'];
    $app_id = $get_values['app_id'];
    $loc_id = $get_values['loc_id'];
    $ulr = $get_values['url'];


$args = array(
    'LocationId' => $loc_id,
    'AppId' => $app_id
);



     $response = 
wp_remote_post('https://www.apiurl.com?APIKEY='."$api_key".'', $args );
    $currency = wp_remote_post( 'https://www.apiurl.com?APIKEY='."$api_key".'', $args );

$responseData =  wp_remote_get( $response );

foreach ($responseData['MenuList'] as $Item)
{
    ?>
    <table width="100%" height="auto" border="0px solid #FFFFFF">
    <tr>
    <td width="80%" class="cat"><?php
    echo $Item['Name'];
    ?></td><td width="20%" align="center" class="cat"><a target="_blank" 
href="<?php echo $ulr;?>">ORDER</a></td></tr><?php
    foreach($Item['Item'] as $Value)
    {
        ?><tr><td class="item" width="80%"><?php echo $Value['Name'];?></td><td class="item" align="center" width="20%"><b><?php echo $Value['Price'];?><?php echo $symbol;?></b></td></tr><?php
    }
    ?>
    </table><?php
}
global$options;
$get_values=get_选项(“插件_选项”);
$api_key=$get_值['api_key'];
$app_id=$get_值['app_id'];
$loc_id=$get_值['loc_id'];
$ulr=$get_值['url'];
$args=数组(
'LocationId'=>$loc\u id,
“AppId”=>$app\u id
);
$response=
可湿性粉剂远程粉剂柱('https://www.apiurl.com?APIKEY=“.$api_key”。”,$args);
$currency=wp\u remote\u post('https://www.apiurl.com?APIKEY=“.$api_key”。”,$args);
$responseData=wp\u remote\u get($response);
foreach($responseData['MenuList']作为$Item)
{
?>

我已经为envanto market制作了一个高级插件,我的插件在审查后得到wordpress的批准。这里是链接

无需为客户嵌入,您可以为此生成快捷码。若要创建菜单页,您可以单击此链接



尝试wp_insert_post函数这将通过您在wordpress中的插件创建一个页面。您可以在此函数响应中获得其他参数,如创建的页面id、slug等。

您可以创建一个包含您的内容的字符串,然后您可以在wp_insert_post()中将此sting作为内容传递


我需要为具有PHP内容的访问者创建一个页面。添加菜单页面将页面添加到管理端,如仪表板、帖子、设置等。如果我错了,请清除我。尝试wp\u insert\u post函数这将通过您在wordpress中的插件创建页面。您可以在此函数中获取其他参数,如创建的页面id、slug等ponse.wp_insert_post()可以,但主要问题是用php内容更新它。哪种类型的php内容?请解释一下?通过API调用获取数据的php代码。因此,php代码处理API调用和响应请求,页面(使用wp_insert_post创建)必须向访问者显示响应。
    <?php 
    global $options;
        $get_values = get_option('plugin_options');
        $api_key = $get_values['api_key'];
        $app_id = $get_values['app_id'];
        $loc_id = $get_values['loc_id'];
        $ulr = $get_values['url'];


    $args = array(
        'LocationId' => $loc_id,
        'AppId' => $app_id
    );



    $response = wp_remote_post('https://www.apiurl.com?APIKEY='."$api_key".'', $args );
    $currency = wp_remote_post( 'https://www.apiurl.com?APIKEY='."$api_key".'', $args );

    $responseData =  wp_remote_get( $response );

    $str = '';
    foreach ($responseData['MenuList'] as $Item)
    {
        $str .= '<table width="100%" height="auto" border="0px solid #FFFFFF">
        <tr>
        <td width="80%" class="cat">'.$Item['Name'].'</td>
        <td width="20%" align="center" class="cat">
          <a target="_blank" href="'.$ulr.'">ORDER</a>
        </td>
        </tr>';
        foreach($Item['Item'] as $Value)
        {
            $str .= '<tr>
                      <td class="item" width="80%">'.$str .=.'</td>
                      <td class="item" align="center" width="20%"><b>'.$Value['Price'].$symbol.'</b></td>
                  </tr>';
        }
        $str .= '</table>';    
    }

    // Pass this $str variable as a content
    echo $str;