/**
  *
  * @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;
 }
Esempio n. 2
0
 private function __construct()
 {
     if (!isset($_GET['wpcf-post-type'])) {
         return;
     }
     Types_Helper_Placeholder::set_post_type($_GET['wpcf-post-type']);
     Types_Helper_Condition::set_post_type($_GET['wpcf-post-type']);
     $this->prepare();
 }
Esempio n. 3
0
 public static function set_post_type($posttype = false)
 {
     if (!$posttype) {
         global $typenow;
         $posttype = isset($typenow) && !empty($typenow) ? $typenow : false;
     }
     if ($posttype) {
         self::$post_type = get_post_type_object($posttype);
     }
 }
 private function __construct()
 {
     if (!isset($_GET['group_id'])) {
         return;
     }
     $post_types = get_post_meta($_GET['group_id'], '_wp_types_group_post_types', 'string');
     $post_types = explode(',', $post_types);
     $post_types = array_values(array_filter($post_types));
     if (count($post_types) != 1 || $post_types[0] == 'all') {
         return;
     }
     Types_Helper_Placeholder::set_post_type($post_types[0]);
     Types_Helper_Condition::set_post_type($post_types[0]);
     $this->prepare();
 }
Esempio n. 5
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);
 }
Esempio n. 6
0
 /**
  * Description Set & Get
  * @param $description
  */
 public function set_description($description)
 {
     if (!is_array($description)) {
         $this->description = array(array('type' => 'paragraph', 'content' => $description));
         return;
     }
     // @todo Remove once placeholder replace comes before Twig rendering
     foreach ($description as &$element) {
         if (isset($element['target'])) {
             switch ($element['target']) {
                 case '%POST-PERMALINK%':
                     $element['target'] = Types_Helper_Placeholder::get_permalink();
                     break;
                 case '%POST-ARCHIVE-PERMALINK%':
                     $element['target'] = Types_Helper_Placeholder::get_archive_permalink();
                     break;
             }
         }
     }
     $this->description = $description;
 }
 /**
  * @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;
 }
Esempio n. 8
0
 public static function get_archive_permalink()
 {
     if (self::$archive_link !== null) {
         return self::$archive_link;
     }
     // cpt edit page
     if (isset($_GET['wpcf-post-type'])) {
         $query = new WP_Query('post_type=' . $_GET['wpcf-post-type'] . '&post_status=publish&posts_per_page=1');
         if ($query->have_posts()) {
             self::$archive_link = get_post_type_archive_link($_GET['wpcf-post-type']);
             return self::$archive_link;
         }
         self::$archive_link = false;
         return self::$archive_link;
     }
     if (!is_object(self::$post_type)) {
         self::set_post_type();
     }
     $query = new WP_Query('post_type=' . self::$post_type->name . '&post_status=publish&posts_per_page=1');
     if ($query->have_posts()) {
         self::$archive_link = get_post_type_archive_link(self::$post_type->name);
         return self::$archive_link;
     }
     self::$archive_link = false;
     return self::$archive_link;
 }