-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass-fw-extension-blog.php
90 lines (78 loc) · 2.89 KB
/
class-fw-extension-blog.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
<?php if ( ! defined( 'FW' ) ) {
die( 'Forbidden' );
}
class FW_Extension_Blog extends FW_Extension {
private $post_type = 'post';
/**
* @internal
*/
public function _init() {
if ( is_admin() ) {
add_action( 'admin_menu', array( $this, '_admin_action_rename_post_menu' ) );
add_action( 'init', array( $this, '_admin_action_change_post_labels' ), 999 );
} else {
add_action( 'init', array( $this, '_theme_action_change_post_labels' ), 999 );
}
}
/**
* Changes the labels value od the posts type: post from Post to Blog Post
* @internal
*/
public function _theme_action_change_post_labels() {
global $wp_post_types;
$p = $this->post_type;
// Someone has changed this post type, always check for that!
if ( empty ( $wp_post_types[ $p ] )
or ! is_object( $wp_post_types[ $p ] )
or empty ( $wp_post_types[ $p ]->labels )
) {
return;
}
$wp_post_types[ $p ]->labels->name = __( 'Blog', 'fw' );
$wp_post_types[ $p ]->labels->singular_name = __( 'Blog', 'fw' );
$wp_post_types[ $p ]->labels->add_new = __( 'Add blog post', 'fw' );
$wp_post_types[ $p ]->labels->add_new_item = __( 'Add new blog post', 'fw' );
$wp_post_types[ $p ]->labels->all_items = __( 'All blog posts', 'fw' );
$wp_post_types[ $p ]->labels->edit_item = __( 'Edit blog post', 'fw' );
$wp_post_types[ $p ]->labels->name_admin_bar = __( 'Blog Post', 'fw' );
$wp_post_types[ $p ]->labels->menu_name = __( 'Blog Post', 'fw' );
$wp_post_types[ $p ]->labels->new_item = __( 'New blog post', 'fw' );
$wp_post_types[ $p ]->labels->not_found = __( 'No blog posts found', 'fw' );
$wp_post_types[ $p ]->labels->not_found_in_trash = __( 'No blog posts found in trash', 'fw' );
$wp_post_types[ $p ]->labels->search_items = __( 'Search blog posts', 'fw' );
$wp_post_types[ $p ]->labels->view_item = __( 'View blog post', 'fw' );
}
/**
* Changes the labels value od the posts type: post from Post to Blog Post
* @internal
*/
public function _admin_action_change_post_labels() {
global $wp_post_types, $wp_taxonomies;
$p = $this->post_type;
// Someone has changed this post type, always check for that!
if ( empty ( $wp_post_types[ $p ] )
or ! is_object( $wp_post_types[ $p ] )
or empty ( $wp_post_types[ $p ]->labels )
) {
return;
}
$wp_post_types[ $p ]->labels->name = __( 'Blog Posts', 'fw' );
if ( empty ( $wp_taxonomies['category'] )
or ! is_object( $wp_taxonomies['category'] )
or empty ( $wp_taxonomies['category']->labels )
) {
return;
}
$wp_taxonomies['category']->labels->name = __( 'Blog Categories', 'fw' );
}
/**
* Changes the name in admin menu from Post to Blog Post
* @internal
*/
public function _admin_action_rename_post_menu() {
global $menu;
if ( isset( $menu[5] ) ) {
$menu[5][0] = __( 'Blog Posts', 'fw' );
}
}
}