Почему var_dump отображает NULL при доступе к ключу, у которого в качестве значения есть массив? - PullRequest
0 голосов
/ 27 мая 2019

Я пытаюсь пройтись по темам Wordpress, которые я установил, чтобы извлечь часть данных.Мне нужно получить доступ к $ value-> headers ["TextDomain"], но когда я пытаюсь получить доступ к $ value-> headers, я получаю ответ NULL.

Вот массив объектов Wordpress Theme, который яя пытаюсь получить данные из:

object(WP_Theme)#795 (12) {
  ["update"]=>
  bool(false)
  ["theme_root":"WP_Theme":private]=>
  string(56) "/Users/tygoss/Projects/QuickPress/prod/wp-content/themes"
  ["headers":"WP_Theme":private]=>
  array(11) {
    ["Name"]=>
    string(10) "Black Jane"
    ["ThemeURI"]=>
    string(0) ""
    ["Description"]=>
    string(187) "Black Jane is a clean SuevaFree child theme with an optional slideshow on homepage, a new header layout in addition to the five header layouts available on SuevaFree and new Google Fonts."
    ["Author"]=>
    string(16) "ThemeinProgress."
    ["AuthorURI"]=>
    string(31) "https://www.themeinprogress.com"
    ["Version"]=>
    string(5) "1.0.4"
    ["Template"]=>
    string(9) "suevafree"
    ["Status"]=>
    string(0) ""
    ["Tags"]=>
    string(302) "blog, e-commerce, photography, custom-background, custom-colors, custom-header, custom-logo, custom-menu, featured-images, flexible-header, footer-widgets, post-formats, right-sidebar, sticky-post, theme-options, threaded-comments, translation-ready, one-column, two-columns, three-columns, grid-layout"
    ["TextDomain"]=>
    string(10) "black-jane"
    ["DomainPath"]=>
    string(10) "/languages"
  }
  ["name_translated":"WP_Theme":private]=>
  NULL
  ["errors":"WP_Theme":private]=>
  NULL
  ["stylesheet":"WP_Theme":private]=>
  string(10) "black-jane"
  ["template":"WP_Theme":private]=>
  string(9) "suevafree"
}

Если я var_dump ($ value-> stylesheet), я получаю string(10) "black-jane"

Но если я var_dump ($ value-> headers), я получаюNULL

Вот мой цикл:

<code>    $all_themes = wp_get_themes();
    foreach ($all_themes as $key => $value) {
      echo '<pre>';
      var_dump($value->headers);
      echo '
';}

Не должны ли заголовки $ value-> выводить массив из 11 элементов?Почему он возвращает NULL и почему работает $ value-> stylesheet, а не $ value-headers?

1 Ответ

0 голосов
/ 28 мая 2019

$value->get("the thing from the header array") работает без нареканий!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...