PluginProbe
Waymark / trunk
Waymark vtrunk
1.6.5 1.6.4 1.6.2 1.6.3 1.6.0 1.5.16 trunk 1.4.3 1.5.0 1.5.1 1.5.10 1.5.11 1.5.14 1.5.15 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9
waymark / inc / Waymark_Types.php

Waymark_Types.php in Waymark trunk, at inc/Waymark_Types.php

112 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Waymark_Types {
4 private $types;
5
6 function __construct() {
7 add_action('init', array($this, 'register_types'), 0);
8 }
9
10 function register_types() {
11 $this->types = array(
12 //Map
13 'waymark_map' => array(
14 'label' => esc_html__('Map', 'waymark'),
15 'description' => '',
16 'labels' => array(
17 'name' => esc_html__('Maps', 'waymark'),
18 'singular_name' => esc_html__('Map', 'waymark'),
19 'menu_name' => esc_html__('Maps', 'waymark'),
20 'name_admin_bar' => esc_html__('Map', 'waymark'),
21 'archives' => esc_html__('Map Archives', 'waymark'),
22 'attributes' => esc_html__('Map Attributes', 'waymark'),
23 'parent_item_colon' => esc_html__('Parent Map:', 'waymark'),
24 'all_items' => esc_html__('All Maps', 'waymark'),
25 'add_new_item' => esc_html__('Add New Map', 'waymark'),
26 'add_new' => esc_html__('Add New', 'waymark'),
27 'new_item' => esc_html__('New Map', 'waymark'),
28 'edit_item' => esc_html__('Edit Map', 'waymark'),
29 'update_item' => esc_html__('Update Map', 'waymark'),
30 'view_item' => esc_html__('View Map', 'waymark'),
31 'view_items' => esc_html__('View Maps', 'waymark'),
32 'search_items' => esc_html__('Search Map', 'waymark'),
33 'not_found' => esc_html__('Not found', 'waymark'),
34 'not_found_in_trash' => esc_html__('Not found in Trash', 'waymark'),
35 'featured_image' => esc_html__('Featured Image', 'waymark'),
36 'set_featured_image' => esc_html__('Set featured image', 'waymark'),
37 'remove_featured_image' => esc_html__('Remove featured image', 'waymark'),
38 'use_featured_image' => esc_html__('Use as featured image', 'waymark'),
39 'insert_into_item' => esc_html__('Insert into Map', 'waymark'),
40 'uploaded_to_this_item' => esc_html__('Uploaded to this Map', 'waymark'),
41 'items_list' => esc_html__('Map list', 'waymark'),
42 'items_list_navigation' => esc_html__('Maps list navigation', 'waymark'),
43 'filter_items_list' => esc_html__('Filter Map list', 'waymark'),
44 ),
45 // Default - overridden below
46 'supports' => array('title'),
47 'hierarchical' => false,
48 'public' => true,
49 'show_ui' => true,
50 'show_in_menu' => false,
51 'show_in_rest' => true,
52 'rest_base' => Waymark_Config::get_setting('misc', 'permalinks', 'permalink_slug_map'),
53 'menu_position' => 5,
54 'show_in_admin_bar' => true,
55 'show_in_nav_menus' => true,
56 'can_export' => true,
57 'has_archive' => false,
58 'exclude_from_search' => false,
59 'publicly_queryable' => true,
60 'rewrite' => array(
61 'slug' => Waymark_Config::get_setting('misc', 'permalinks', 'permalink_slug_map'),
62 'with_front' => false,
63 ),
64 'capability_type' => 'post',
65 ),
66 );
67
68 // Custom post support
69 $supports = Waymark_Config::get_setting('misc', 'post', 'supports');
70 if (is_array($supports) && sizeof($supports)) {
71 // Override default supports
72 $this->types['waymark_map']['supports'] = [];
73
74 foreach ($supports as $support) {
75 $this->types['waymark_map']['supports'][] = $support;
76 }
77 }
78
79 //Show if debug
80 if (Waymark_Config::get_setting('misc', 'advanced', 'debug_mode') == true) {
81 $this->types['waymark_map']['supports'][] = 'custom-fields';
82 }
83
84 //Add Featured Image Support
85 add_theme_support('post-thumbnails', array('waymark_map'));
86
87 $types = array();
88 foreach ($this->types as $type_id => $type_data) {
89 $types[] = $type_id;
90 register_post_type($type_id, $type_data);
91 }
92
93 Waymark_Config::set_item('custom_types', $types);
94 }
95
96 function delete_posts() {
97 //For each custom type
98 foreach ($this->types as $type_id => $type_data) {
99 //Get posts
100 $posts = get_posts(array(
101 'post_type' => $type_id,
102 ));
103
104 //For each post
105 foreach ($posts as $post) {
106 //Force delete post
107 wp_delete_post($post->ID, true);
108 }
109 }
110 }
111 }
112