0

私は wordpress サイトで作業しており、関数の値を配列内の値に割り当てる必要がありますが、エラーが発生し続けます。customFields 配列では、get_option('contact_email', 'no one') の値をヘルパー テキストに挿入する必要があります。以下のコード スニペットでは、{CONTACT_EMAIL} を get_option 値に置き換える必要がありますが、わかりません。

...

    var $customFields = array(
        array(
            "name"          => "ContactPerson-name",
            "title"         => "Contact Name",
            "description"   => "Enter the first and last name of the page contact. If left blank, the site default of {CONTACT_PERSON} will be used.",
            "type"          => "textinput",
            "scope"         =>  array( "page" ),
            "capability"    => "edit_pages"
        ),
        array(
            "name"          => "ContactPerson-email",
            "title"         => "Contact Email",
            "description"   => "Enter the email address of the page contact. If left blank, the site default of {CONTACT_EMAIL} will be used.",
            "type"          => "textinput",
            "scope"         =>  array( "page" ),
            "capability"    => "edit_pages"
        ),

        array(
            "name"          => "ContactPerson-phone",
            "title"         => "Contact Phone (XXX) XXX-XXXX",
            "description"   => "Enter the phone number of the page contact. If left blank, the site default of {CONTACT_PHONE} will be used.",
            "type"          => "textinput",
            "scope"         =>  array( "page" ),
            "capability"    => "edit_pages"
        ),

        array(
            "name"          => "ContactPerson-address",
            "title"         => "Contact Room Number & Building",
            "description"   => "Enter the room number and building of the page contact. Click <a href=\"http://www.engin.umich.edu/buildingabbreviations\">here</a> for building abbreviations. If left blank, the site default of {CONTACT_ADDRESS} will be used.",
            "type"          => "textinput",
            "scope"         =>  array( "page" ),
            "capability"    => "edit_pages"
        ),

...

...

テキストを閉じて関数を連結しようとしましたが、文字列の置換を試みましたが、何も機能していないようです。誰でも提供できるヘルプをありがとう。

4

1 に答える 1

2

ブルートフォースメソッドが機能します...

$customFields = array(
    array(
        "name"          => "ContactPerson-name",
        "title"         => "Contact Name",
        "description"   => "... of {CONTACT_PERSON} will be used...",
        "type"          => "textinput",
        "scope"         =>  array( "page" ),
        "capability"    => "edit_pages"
    )
);

$contact_person = get_option('contact_person');

foreach($customFields as &$field)
{
    $field['description'] = str_replace("{CONTACT_PERSON}", $contact_person, $field['description']);
}

unset($field);
于 2013-06-27T12:43:05.727 に答える