public function display() { $this->echoOptionHeader(); // Remember the pages so as not to perform any more lookups if (!isset(self::$allPages)) { self::$allPages = get_pages(); } echo "<select name='" . esc_attr($this->getID()) . "'>"; // The default value (nothing is selected) printf("<option value='%s' %s>%s</option>", '0', selected($this->getValue(), '0', false), "— " . __("Select", TF_I18NDOMAIN) . " —"); // Print all the other pages foreach (self::$allPages as $page) { printf("<option value='%s' %s>%s</option>", esc_attr($page->ID), selected($this->getValue(), $page->ID, false), $page->post_title); } echo "</select>"; $this->echoOptionFooter(); }
public function display() { $this->echoOptionHeader(); // Remember the pages so as not to perform any more lookups if (!isset(self::$allPages)) { self::$allPages = get_pages(); } echo "<select name='" . esc_attr($this->getID()) . "'>"; // The default value (nothing is selected) printf("<option value='%s' %s>%s</option>", '0', selected($this->getValue(), '0', false), '— ' . __('Select', TF_I18NDOMAIN) . ' —'); // Print all the other pages foreach (self::$allPages as $page) { $title = $page->post_title; if (empty($title)) { $title = sprintf(__('Untitled %s', TF_I18NDOMAIN), '(ID #' . $page->ID . ')'); } printf("<option value='%s' %s>%s</option>", esc_attr($page->ID), selected($this->getValue(), $page->ID, false), $title); } echo '</select>'; $this->echoOptionFooter(); }