-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive.php
140 lines (106 loc) · 3.01 KB
/
archive.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
<?php
/**
* Set up custom post type
*/
$post_type = eman_archive_info('post_type');
$cpt = eman_archive_info('cpt');
add_filter( 'wp_title', 'eman_archive_wp_title', 10, 2 );
function eman_archive_wp_title( $title, $sep )
{
return eman_archive_info('plural_title');
}
/**
* Owners have no access to settings, Subs have limited access
*/
if ( ! eman_can_view($post_type) ) {
wp_redirect( home_url('/') );
die;
}
/**
* Set up an export if requested
*/
#emanager_table_export::setup_export();
do_action('emanager_table_export/setup_export');
/**
* Change post type
*/
add_filter( 'acf/create_object/post/type', 'custom_set_post_type' );
function custom_set_post_type()
{
return get_query_var('post_type');
}
/**
* Autofill from previous
*/
get_template_part('partials/archive/function', 'autofill');
/**
* ACF form head
*/
if ( function_exists('acf_form_head') ) { # get_query_var('add') &&
acf_form_head();
}
get_header(); ?>
<div id="content">
<div class="wrap">
<?php do_action( 'before_content' ); ?>
<div id="main" role="main">
<div class="archive-nav" class="cf">
<?php if ( $obj = eman_archive_info('post_type_object') ) : ?>
<?php
if ( get_query_var('add') ) :
echo eman_button( array(
'text' => 'Back to list',
'url' => home_url('/' . $obj->has_archive . '/'),
'color' => 'default',
'classes' => 'back-list',
'icon_before' => 'arrow-left',
) );
else :
echo eman_button( array(
'text' => 'Back to dashboard',
'url' => home_url(),
'color' => 'default',
'classes' => 'back-list',
'icon_before' => 'arrow-left',
) );
endif;
if ( ! get_query_var('add') && $cpt ) :
if (
(
(eman_check_role('turner') || eman_check_role('sub'))
&& ('em_noc' != $post_type || eman_archive_info('is_pco'))
)
|| ( 'em_issue' == $post_type )
) :
$label = str_replace('NOC', 'PCO', $obj->labels->add_new_item);
echo eman_button( array(
'text' => $label,
'url' => home_url( ('settings' == $cpt['type'] ? '/settings' : '') . '/' . str_replace('em_', '', $post_type) . '/add/'),
'color' => 'success',
'classes' => 'add-new',
'icon_before' => 'plus-circle',
) );
endif;
endif;
endif; ?>
</div>
<div id="<?php echo $post_type ?>" class="em_tables">
<?php
/**
* The settings menu
*/
if ( 'settings' == $post_type || 'settings' == $cpt['type'] ) : ?>
<?php echo do_shortcode('[settings_nav]'); ?>
<?php endif; ?>
<?php if ( eman_archive_info('cpt') && get_query_var('add') ) :
require_once( get_template_directory() . '/partials/archive/add.php' );
elseif ( eman_archive_info('cpt') ) :
require_once( get_template_directory() . '/partials/archive/table.php' );
endif; ?>
</div>
</div>
<?php #get_sidebar(); ?>
<?php do_action( 'after_content' ); ?>
</div>
</div>
<?php get_footer();