-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_posts_config.php
More file actions
118 lines (108 loc) · 3.64 KB
/
custom_posts_config.php
File metadata and controls
118 lines (108 loc) · 3.64 KB
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
<?php
/**
* Cards
*/
if ( ! function_exists( 'am_cp_cfg' ) ) {
function am_cp_cfg()
{
$slug_name = "fraction-card";
$tax_name = "cards-category";
return [
'card_slug' => $slug_name,
'card_label' => ucfirst( str_replace( "-", " ", $slug_name ) ),
'card_tax_slug' => $tax_name,
'card_tax_label' => ucfirst( str_replace( "-", " ", $tax_name ) ),
];
}
}
$labels = [
'name' => __( 'Cards' ),
'singular_name' => __( 'Card' ),
'add_new' => __( 'Add new' ),
'add_new_item' => 'Add new ' . am_cp_cfg()[ 'card_label' ],
'edit_item' => 'Edit ' . am_cp_cfg()[ 'card_label' ],
'new_item' => 'New ' . am_cp_cfg()[ 'card_label' ],
'view_item' => 'View ' . am_cp_cfg()[ 'card_label' ],
'search_items' => 'Search ' . am_cp_cfg()[ 'card_label' ],
'not_found' => am_cp_cfg()[ 'card_label' ] . ' not found',
'not_found_in_trash' => 'Empty basket ' . am_cp_cfg()[ 'card_label' ],
'parent_item_colon' => '',
'menu_name' => 'Cards'
];
$args = [
'labels' => $labels,
'public' => true,
'menu_icon' => 'dashicons-tickets-alt',
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => [ 'slug' => am_cp_cfg()[ 'card_slug' ] ],
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'menu_position' => null,
'taxonomies' => [ 'category', 'post_tag' ],
'supports' => [
'title',
'editor',
'author',
'thumbnail',
'excerpt',
'comments',
'custom-fields',
'page-attributes'
]
];
if ( class_exists( 'GenerateCPosts' ) ) {
$new_post = new GenerateCPosts( am_cp_cfg()[ 'card_slug' ], $labels, $args );
$new_post->run( 65 );
$new_post->taxonomy( am_cp_cfg()[ 'card_tax_slug' ], am_cp_cfg()[ 'card_tax_label' ], am_cp_cfg()[ 'card_slug' ] . '-cat' );
$new_post->createField('img','fractionimage', 'url');
// $new_post->addContextualHelp('Some Contextual text');
// $new_post->postFormatSupport();
}
// Column Label
add_filter( "manage_" . am_cp_cfg()[ 'card_slug' ] . "_posts_columns", 'aa_func_20160211020209', 30, 1 );
function aa_func_20160211020209( $columns )
{
$columns[ am_cp_cfg()[ 'card_tax_slug' ] . '_info' ] = am_cp_cfg()[ 'card_tax_label' ];
return $columns;
}
add_filter( "manage_edit-" . am_cp_cfg()[ 'card_slug' ] . "_sortable_columns", 'aa_func_20170725030730', 31, 1 );
function aa_func_20170725030730( $columns )
{
$columns[ am_cp_cfg()[ 'card_tax_slug' ] . '_info' ] = am_cp_cfg()[ 'card_tax_slug' ];
return $columns;
}
add_filter( "manage_" . am_cp_cfg()[ 'card_slug' ] . "_posts_custom_column", 'aa_func_20160011020038', 32, 2 );
function aa_func_20160011020038( $column, $post_id )
{
if ( am_cp_cfg()[ 'card_tax_slug' ] . '_info' === $column ) {
$events_tags = get_the_terms( $post_id, am_cp_cfg()[ 'card_tax_slug' ] );
if ( is_array( $events_tags ) ) {
echo "<ul class='list-inline'>";
foreach ( $events_tags as $events_tag ) {
$tag_id = $events_tag->term_id;
$image_data = get_option('taxonomy_'.$tag_id);
$tag_name = $events_tag->name;
$tag_slug = $events_tag->slug;
$link = "?post_type=" . am_cp_cfg()[ 'card_slug' ] . "&" . am_cp_cfg()[ 'card_tax_slug' ] . "={$tag_slug}";
$img = null;
if($image_data) {
$img = "<img src='{$image_data['url']}'>";
}
?>
<li class="fraction-category-item">
<a href="<?php echo $link ?>">
<?php echo $img . $tag_name ?> ( <i class='fa fa-tag'></i><?php echo $tag_id ?> )
</a>
</li>
<?php
}
echo "</ul>";
} else {
echo "Without any Category";
}
}
}