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 function valid() { $cpt = Types_Helper_Condition::get_post_type(); if (!$cpt->has_archive && $cpt->name != 'post' && $cpt->name != 'page') { return false; } return true; }
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; }
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; }
protected function has_archive() { $cpt = Types_Helper_Condition::get_post_type(); if (!get_post_type_archive_link($cpt->name)) { return false; } return true; }
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(); }
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); } }
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; }
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(); }
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; }
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; }
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; }
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; }
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'); }
/** * @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; }
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; }