public function valid()
 {
     $post_type = Types_Helper_Condition::get_post_type();
     // false if we have no post type
     if (!isset($post_type->name)) {
         return false;
     }
     // query a post
     $query = new WP_Query('post_type=' . $post_type->name . '&posts_per_page=1');
     if ($query->have_posts()) {
         $post = $query->posts[0];
         // for the case no post created yet (post fields group edit page / post type edit page)
     } else {
         $post = new stdClass();
         $post->ID = -1;
         $post->post_type = $post_type->name;
     }
     if (!function_exists('wpcf_admin_post_get_post_groups_fields')) {
         include_once WPCF_EMBEDDED_ABSPATH . '/includes/fields-post.php';
     }
     $fields = wpcf_admin_post_get_post_groups_fields($post);
     if (isset($fields) && is_array($fields) && !empty($fields)) {
         return true;
     }
     return false;
 }
 public static function get_forms_of_post_type()
 {
     $cpt = Types_Helper_Condition::get_post_type();
     if (isset(self::$forms_per_post_type[$cpt->name])) {
         return self::$forms_per_post_type[$cpt->name];
     }
     return false;
 }
示例#3
0
 public function get_archive()
 {
     $post_type = Types_Helper_Condition::get_post_type();
     if ($post_type->name == 'post' || $post_type->name == 'page') {
         return false;
     }
     return $this->archive;
 }
示例#4
0
 public function valid()
 {
     $cpt = Types_Helper_Condition::get_post_type();
     if (!$cpt->has_archive && $cpt->name != 'post' && $cpt->name != 'page') {
         return false;
     }
     return true;
 }
示例#5
0
 protected function has_archive()
 {
     $cpt = Types_Helper_Condition::get_post_type();
     if (!get_post_type_archive_link($cpt->name)) {
         return false;
     }
     return true;
 }
示例#6
0
 public function get_archive($force = false)
 {
     $post_type = Types_Helper_Condition::get_post_type();
     if (!$force) {
         $allowed_columns = apply_filters('types_information_table_columns', array_fill_keys(array('template', 'archive', 'views', 'forms'), ''), $post_type->name);
         if (!isset($allowed_columns['archive'])) {
             return false;
         }
     }
     return $this->archive;
 }
 private function valid_per_post_type()
 {
     $cpt = Types_Helper_Condition::get_post_type();
     $wpv_options = get_option('wpv_options', array());
     if (empty($wpv_options) || !isset($wpv_options['views_template_for_' . $cpt->name]) || !get_post_type($wpv_options['views_template_for_' . $cpt->name])) {
         return false;
     }
     $title = get_the_title($wpv_options['views_template_for_' . $cpt->name]);
     self::$template_id = $wpv_options['views_template_for_' . $cpt->name];
     self::$template_name = $title;
     return true;
 }
 public function valid()
 {
     if (!defined('WPDDL_GENERAL_OPTIONS')) {
         return false;
     }
     $cpt = Types_Helper_Condition::get_post_type();
     $layouts = get_option(WPDDL_GENERAL_OPTIONS, array());
     if (!array_key_exists('layouts_cpt_' . $cpt->name, $layouts)) {
         return false;
     }
     self::$layout_id = $layouts['layouts_cpt_' . $cpt->name];
     return true;
 }
 public function valid()
 {
     $post_type = Types_Helper_Condition::get_post_type();
     $query = new WP_Query('post_type=' . $post_type->name . '&posts_per_page=1');
     if ($query->have_posts()) {
         if (!function_exists('wpcf_admin_post_get_post_groups_fields')) {
             include_once WPCF_EMBEDDED_ABSPATH . '/includes/fields-post.php';
         }
         $fields = wpcf_admin_post_get_post_groups_fields($query->posts[0]);
     }
     if (isset($fields) && is_array($fields) && !empty($fields)) {
         return true;
     }
     return false;
 }
示例#10
0
 public function valid()
 {
     if (self::$template_id !== null && self::$template_id !== false) {
         return true;
     }
     // if views not active
     if (!defined('WPV_VERSION') || !function_exists('wpv_has_wordpress_archive')) {
         return false;
     }
     $cpt = Types_Helper_Condition::get_post_type();
     $archive = $cpt->name == 'post' ? wpv_has_wordpress_archive() : wpv_has_wordpress_archive('post', $cpt->name);
     if (!$archive && $archive === 0) {
         return false;
     }
     self::$template_id = $archive;
     return true;
 }
示例#11
0
 private function valid_per_post_type()
 {
     $cpt = Types_Helper_Condition::get_post_type();
     global $wpdb;
     $layouts_per_post_type = $wpdb->get_results("SELECT meta_value, post_id FROM {$wpdb->postmeta} WHERE meta_key = '_ddl_post_types_was_batched'");
     foreach ($layouts_per_post_type as $setting) {
         $setting->meta_value = unserialize($setting->meta_value);
         if (is_array($setting->meta_value) && in_array($cpt->name, $setting->meta_value)) {
             if (get_post_status($setting->post_id) == 'trash') {
                 continue;
             }
             $title = get_the_title($setting->post_id);
             self::$layout_id = $setting->post_id;
             self::$layout_name = $title;
             return true;
         }
     }
     return false;
 }
示例#12
0
 public function __construct()
 {
     $cpt = Types_Helper_Condition::get_post_type();
     $this->templates = array('single-' . $cpt->name . '.php', 'archive-' . $cpt->name . '.php', 'single.php', 'archive.php', 'index.php');
 }
 protected function thead_views_template_archive_views_forms()
 {
     $thead_data = (require TYPES_DATA . '/information/table/question-marks.php');
     $views = array();
     $post_type = Types_Helper_Condition::get_post_type();
     $allowed_columns = apply_filters('types_information_table_columns', array_fill_keys(array('template', 'archive', 'views', 'forms'), ''), $post_type->name);
     foreach ($thead_data as $key => $column) {
         if (!array_key_exists($key, $allowed_columns)) {
             unset($thead_data[$key]);
         }
     }
     foreach ($thead_data as $data) {
         $views[] = $this->twig->render('/information/table/thead-cell.twig', $data);
     }
     return $views;
 }
示例#14
0
 protected function thead_views_template_archive_views_forms()
 {
     $thead_data = (require TYPES_DATA . '/information/table/question-marks.php');
     $views = array();
     $post_type = Types_Helper_Condition::get_post_type();
     if ($post_type->name == 'post' || $post_type->name == 'page') {
         unset($thead_data['archive']);
     }
     foreach ($thead_data as $data) {
         $views[] = $this->twig->render('/information/table/thead-cell.twig', $data);
     }
     return $views;
 }