Строковый параметр не может быть отправлен в файл шаблона WordPressPhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Строковый параметр не может быть отправлен в файл шаблона WordPress

Сообщение Anonymous »

Этот код работает нормально:

Код: Выделить всё

   function register_custom_patterns() {
$vari = 5;
register_block_pattern(
'twentytwentyfive/asif', // The pattern slug
array(
'title'       => __( 'Test Pattern', 'twentytwentyfive' ),
'description' => __( 'A custom test pattern for the theme.', 'twentytwentyfive' ),
'content'     => file_get_contents( get_template_directory_uri() . '/patterns/asif.php?id='. $vari), // Path to your custom PHP file
)
);
}
add_action( 'init', 'register_custom_patterns' );
Но это не работает:

Код: Выделить всё

function register_custom_patterns() {
$vari = "Send me";
register_block_pattern(
'twentytwentyfive/asif', // The pattern slug
array(
'title'       => __( 'Test Pattern', 'twentytwentyfive' ),
'description' => __( 'A custom test pattern for the theme.', 'twentytwentyfive' ),
'content'     => file_get_contents( get_template_directory_uri() . '/patterns/asif.php?id='. $vari), // Path to your custom PHP file
)
);
}
add_action( 'init', 'register_custom_patterns' );
Ошибка:

Код: Выделить всё

http://localhost/asif_wp/wp-content/themes/twentytwentyfive/patterns/asif.php?id=Send me): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in C:\xampp\htdocs\asif_wp\wp-content\themes\twentytwentyfive\functions.php on line 168
Коротко:
Параметр

Код: Выделить всё

        $vari = 5;  // Working
$vari = "Show me";  //Error
Почему и как это решить?

Подробнее здесь: https://stackoverflow.com/questions/792 ... ttern-file
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»