/
plg-tbr-themes.php
174 lines (142 loc) · 3.78 KB
/
plg-tbr-themes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
/**
* ThemeButler Themes
*
* Simple plugin to add the Themes post type, meta and relevant
* taxonomies.
*
* @package TBRT
* @author Chris Rault <chris@themebutler.com>
* @license GPL-2.0+
* @link https://github.com/ThemeButler/plg-tbr-themes/
* @copyright 2015 Chris Rault
*
* @wordpress-plugin
* Plugin Name: ThemeButler Themes
* Plugin URI: https://github.com/ThemeButler/plg-tbr-themes/
* Description: Simple plugin to add the Themes post type, meta and relevant taxonomies.
* Version: 1.0.0
* Author: Chris Rault
* Author URI: http://www.themebutler.com
* Text Domain: tbrt-locale
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* GitHub Plugin URI: https://github.com/ThemeButler/plg-tbr-themes/
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
} // end if
// Register taxonomies
require_once( plugin_dir_path( __FILE__ ) . 'taxonomy.php' );
// Register themes post type
add_action( 'init', 'tbr_theme_post_type' );
function tbr_theme_post_type() {
$args = array(
'public' => true,
'supports' => array( 'title', 'excerpt', 'thumbnail' ),
'menu_icon' => 'dashicons-align-left',
'label' => 'Themes',
'rewrite' => array(
'with_front'=> false
)
);
register_post_type( 'themes', $args );
}
// Register resources post type
add_action( 'init', 'tbr_resource_post_type' );
function tbr_resource_post_type() {
$args = array(
'public' => true,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ),
'menu_icon' => 'dashicons-align-left',
'label' => 'Resources',
'has_archive' => true,
'rewrite' => array(
'with_front'=> true
)
);
register_post_type( 'resources', $args );
}
// Register resource meta
add_action( 'admin_init', 'tbr_resource_post_meta' );
function tbr_resource_post_meta() {
$fields = array(
array(
'id' => 'github_slug',
'label' => 'Github slug',
'type' => 'text',
'default' => ''
),
array(
'id' => 'download_name',
'label' => 'Download name',
'type' => 'text',
'default' => ''
),
array(
'id' => 'status',
'label' => 'Status',
'type' => 'radio',
'default' => '',
'options' => array(
'0' => 'Alpha',
'1' => 'Beta',
'2' => 'Stable'
)
)
);
beans_register_post_meta( $fields, array( 'resources' ), 'beans', array( 'title' => 'Resource Info' ) );
}
// Register theme meta
add_action( 'admin_init', 'tbr_theme_post_meta' );
function tbr_theme_post_meta() {
$fields = array(
array(
'id' => 'version',
'label' => 'Version',
'type' => 'text',
'default' => ''
),
array(
'id' => 'release_date',
'label' => 'Release date',
'type' => 'text',
'default' => ''
),
array(
'id' => 'theme_screenshots',
'label' => 'Screenshots',
'type' => 'image',
'default' => '',
'multiple' => true
)
);
beans_register_post_meta( $fields, array( 'themes' ), 'beans', array( 'title' => 'Theme Info' ) );
}
// Register partners meta
add_action( 'admin_init', 'tbr_designers_meta' );
function tbr_designers_meta() {
$option = array(
array(
'id' => 'designer_url',
'label' => 'Website',
'type' => 'text',
'default' => ''
),
array(
'id' => 'designer_location',
'label' => 'Location',
'type' => 'text',
'default' => ''
),
array(
'id' => 'designer_image',
'label' => 'Photo',
'type' => 'image',
'default' => '',
'multiple' => false
)
);
beans_register_term_meta( $option, array( 'designers' ), 'beans' );
}