-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjl-cpt-fitcase.php
112 lines (101 loc) · 2.85 KB
/
jl-cpt-fitcase.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
<?php
/*
Plugin Name: JL Fitness Case Study Custom Post Type
Plugin URI: http://jonliebold.com
Description: A plugin to create a custom post type for Case Studies specifically for fitness professionals and facilities.
Version: 1.0
Author: Jon Liebold
Author URI: http://jonliebold.com
Text Domain: jlfitcase
License: GPLv2 or later
*/
define( 'JLFITCASE__VERSION', '1.0' );
define( 'JLFITCASE__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'JLFITCASE__PLUGIN_BASEURL', plugin_dir_url( __FILE__ ) );
define( 'JLFITCASE__PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
define( 'JLFITCASE__PLUGIN_FILE', __FILE__ );
define( 'JLFITCASE__NAMESPACE', 'fitcase' );
require_once ( JLFITCASE__PLUGIN_DIR . 'class-jl-custom-post-type.php' );
function jl_fitcase_flush_rewrite() {
flush_rewrite_rules();
}
// Activation / Deactivation Hooks
register_activation_hook( __FILE__, 'jl_fitcase_flush_rewrite' );
register_deactivation_hook( __FILE__, 'jl_fitcase_flush_rewrite' );
$fitcase = new JL_CustomPostType( 'Case Study' );
$fitcase->set_post_key( 'fitcase' );
$fitcase->add_taxonomy( 'Fitness Goal', array( 'hierarchical' => true ) );
$fitcase->add_meta_box(
'Client Info',
array(
'First Name' => array(
'type' => 'text',
'attributes' => array(
'maxlength' => 16,
),
),
'Last Name' => array(
'type' => 'text',
'attributes' => array(
'maxlength' => 16,
),
'break' => true,
),
'Sex' => array(
'type' => 'select',
'select_options' => array( 'Male', 'Female', 'Other' ),
),
'Age' => array(
'type' => 'text',
'attributes' => array(
'maxlength' => 3,
//'size' => 16,
),
'break' => true,
),
'History' => array(
'type' => 'wpeditor',
'wpeditor_options' => array(
'media_buttons' => false,
'textarea_rows' => 5,
)
),
),
'Basic Client Information taken when client first signs up for services.'
); // Client Info
$fitcase->add_meta_box(
'Client Photos',
array(
'Before Photo' => array(
'type' => 'attachment',
'mimes' => array(
'image/jpeg',
'image/png',
),
),
'Current Photo' => array(
'type' => 'attachment',
'mimes' => array(
'image/jpeg',
'image/png',
),
),
)
); // Client Before/After Photos
global $upload_array;
$upload_array = $fitcase->getPostUploadLoc();
// Load Custom Admin Styles
function jl_fitcase_css() {
global $post_type;
if ( 'case_study' != $post_type ) {
return;
}
wp_enqueue_style( 'jlfitcase-admin-style', plugins_url( '_css/jl-fitcase-admin.css', __FILE__ ) );
wp_enqueue_script( 'jlfitcase-admin-script', plugins_url( '_js/jl-cpt-fitcase-admin.js', __FILE__ ), array(), '1.0',
true );
}
add_action( 'admin_enqueue_scripts', 'jl_fitcase_css' );
// Load Functions
require_once ( JLFITCASE__PLUGIN_DIR . '_inc/functions.php');
// Load Admin Options
require_once ( JLFITCASE__PLUGIN_DIR . '_inc/options.php' );