/** * initialize */ public function initialize() { $screen = get_current_screen(); $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts(); if ($screen->base === 'post' && !in_array($screen->id, $contact_data_post_types)) { exit; } if ($screen->base === 'post' && in_array($screen->id, $contact_data_post_types)) { $_args = apply_filters('mwform_get_inquiry_data_args-' . $screen->post_type, array()); if (!empty($_args) && is_array($_args)) { $args = array('post_type' => $screen->post_type, 'post_status' => 'publish', 'posts_per_page' => 1, 'p' => $_GET['post']); $args = array_merge($_args, $args); $permit_posts = get_posts($args); if (empty($permit_posts)) { exit; } } } $Contact_Data = new MW_WP_Form_Contact_Data(); add_action('add_meta_boxes', array($this, 'add_meta_boxes')); add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); add_action('admin_print_styles', array($this, 'admin_print_styles')); add_action('edit_form_top', array($this, 'edit_form_top')); add_action('save_post', array($Contact_Data, 'save_post')); }
/** * initialize */ public function initialize() { $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts(); if (!in_array($this->formkey, $contact_data_post_types)) { exit; } add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); }
/** * @backupStaticAttributes enabled * @group get_posts */ public function test_mwform_get_posts_投稿タイプを一つ消す() { add_filter('mwform_contact_data_post_types', function ($post_types) { unset($post_types[0]); return $post_types; }); $post_types = MW_WP_Form_Contact_Data_Setting::get_posts(); $this->assertEquals(4, count($post_types)); }
public function index() { $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts(); $form_list = array(); foreach ($contact_data_post_types as $post_type) { $post_type_object = get_post_type_object($post_type); $form_list[$post_type] = array('title' => $post_type_object->labels->singular_name, 'count' => $this->get_count($post_type), 'modified_datetime' => $this->get_modified_datetime($post_type), 'created_datetime' => $this->get_created_datetime($post_type)); } $this->assign('form_list', $form_list); $this->render('stores-inquiry-data-form-list/index'); }
/** * initialize */ public function initialize() { $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts(); if (!isset($_GET['post_type'])) { exit; } $this->post_type = $_GET['post_type']; if (!in_array($this->post_type, $contact_data_post_types)) { exit; } $CSV = new MW_WP_Form_CSV($this->post_type); $CSV->download(); add_action('pre_get_posts', array($this, 'pre_get_posts')); add_action('admin_head', array($this, 'add_columns')); add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); add_action('admin_print_styles', array($this, 'admin_print_styles')); add_action('in_admin_footer', array($this, 'add_csv_download_button')); add_filter('wp_count_posts', array($this, 'wp_count_posts'), 10, 2); }
/** * 各画面のコントローラーの呼び出し * * @param WP_Screen $screen */ public function current_screen($screen) { $contact_data_post_types = MW_WP_Form_Contact_Data_Setting::get_posts(); if ($screen->id === MWF_Config::NAME) { $validation_rules = $this->get_validation_rules(); $Controller = new MW_WP_Form_Admin_Controller($validation_rules); $Controller->initialize(); } elseif ($screen->id === 'edit-' . MWF_Config::NAME) { $Controller = new MW_WP_Form_Admin_List_Controller(); $Controller->initialize(); } elseif (MWF_Functions::is_contact_data_post_type($screen->id)) { $Controller = new MW_WP_Form_Contact_Data_Controller(); $Controller->initialize(); } elseif (preg_match('/^edit-' . MWF_Config::DBDATA . '\\d+$/', $screen->id)) { $Controller = new MW_WP_Form_Contact_Data_List_Controller(); $Controller->initialize(); } elseif ($screen->id === MWF_Config::NAME . '_page_' . MWF_Config::NAME . '-chart') { $Controller = new MW_WP_Form_Chart_Controller(); $Controller->initialize(); } }