/**
  *
  * @return bool
  */
 public function get_examples()
 {
     if (empty($this->messages)) {
         return false;
     }
     // check if descriptions were already filtered
     if (isset($this->messages_filtered['view_example'])) {
         return $this->messages_filtered['view_example'];
     }
     $examples = array();
     foreach ($this->messages as $message) {
         if (!empty($examples)) {
             $current_example = $message->get_example();
             // check if the view example is already applied
             foreach ($examples as $view) {
                 // skip to next message
                 if ($view['label'] == $current_example['label']) {
                     continue 2;
                 }
             }
             // no duplication, add view example
             $examples[] = $current_example;
             continue;
         }
         // view example has no value yet
         $examples[] = $message->get_example();
     }
     Types_Helper_Placeholder::replace($examples);
     $this->messages_filtered['view_example'] = $examples;
     return $examples;
 }
示例#2
0
 protected function show_data_as_container_in_meta_box($data_files)
 {
     // add container for warning messages
     $this->information = new Types_Information_Container('types-informations-container');
     // $this->information->cache_on_hook( 'edit_post' );
     // add messages
     foreach ($data_files as $data_file) {
         $this->load_data_to_table($data_file);
     }
     // outer box
     $output_meta_box = new Types_Helper_Output_Meta_Box();
     $output_meta_box->set_id($this->information->get_id());
     $output_meta_box->set_title(__('Front-end Display', 'types'));
     // $output_meta_box->set_css_class( 'types-table-in-meta-box' );
     $this->information->set_output_container($output_meta_box);
     $output_inner = $this->twig->render('/information/single.twig', array('icon' => 'dashicons dashicons-warning', 'information' => $this->information));
     // Replace Placeholders
     Types_Helper_Placeholder::replace($output_inner);
     // no "echo" because we use meta-box as output
     $this->information->render($output_inner);
 }
 /**
  * @param $post_types
  * @param $headline
  *
  * @return string
  */
 private function get_dashboard_types_table($post_types, $headline, $post_type_edit_link = true)
 {
     // documentation urls
     $documentation_urls = (include TYPES_DATA . '/documentation-urls.php');
     // add links to use analytics
     Types_Helper_Url::add_urls($documentation_urls);
     // set analytics medium
     Types_Helper_Url::set_medium('dashboard');
     /* messages */
     $messages_files = array(TYPES_DATA . '/dashboard/table/template.php', TYPES_DATA . '/dashboard/table/archive.php', TYPES_DATA . '/dashboard/table/views.php', TYPES_DATA . '/dashboard/table/forms.php');
     // add dashboard
     $rows = '';
     foreach ($post_types as $post_type) {
         $info_post_type = new Types_Information_Table('types-information-table');
         Types_Helper_Condition::set_post_type($post_type->get_name());
         Types_Helper_Placeholder::set_post_type($post_type->get_name());
         foreach ($messages_files as $message_file) {
             $this->load_data_to_table($message_file, $info_post_type);
         }
         $row = $this->get_twig()->render('/page/dashboard/table/tbody-row.twig', array('labels' => array('or' => __('Or...', 'types'), 'create_taxonomy' => __('Create taxonomy', 'types'), 'create_field_group' => __('Create field group', 'types'), 'no_archive_for' => __('No archive available for %s', 'types')), 'admin_url' => admin_url(), 'post_type' => $post_type, 'table' => $info_post_type, 'post_type_edit_link' => $post_type_edit_link));
         Types_Helper_Placeholder::replace($row);
         $rows .= $row;
     }
     // table view
     $data_thead = (require TYPES_DATA . '/dashboard/table/head.php');
     $table = $this->get_twig()->render('/page/dashboard/table.twig', array('labels' => array('headline' => $headline, 'admin' => __('WordPress admin', 'types'), 'frontend' => __('Front-end', 'types'), 'or' => __('Or...', 'types')), 'admin_url' => admin_url(), 'thead' => $data_thead, 'rows' => $rows));
     return $table;
 }