C:\xampp\htdocs\landing\wp-content\plugins\totalpoll\src\Poll\PostType.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
<?php

namespace TotalPoll\Poll;
defined'ABSPATH' ) && exit();



/**
 * Poll post type.
 * @package TotalPoll\PostType
 */
class PostType extends \TotalPollVendors\TotalCore\PostTypes\PostType {
    public function 
__construct() {
        
parent::__construct();
        
add_action'totalpoll/actions/activated', [ $this'capabilities' ] );
    }

    
/**
     * Register post type.
     *
     * @return \WP_Error|\WP_Post_Type
     */
    
public function register() {
        
define'TP_POLL_CPT_NAME'$this->getName() );

        return 
parent::register();
    }

    
/**
     * Capabilities mapping.
     */
    
public function capabilities() {
        
$map = [
            
'edit_poll'   => [ 'administrator''editor''author''contributor' ],
            
'read_poll'   => [ 'administrator''editor''author''contributor' ],
            
'delete_poll' => [ 'administrator''editor''author''contributor' ],

            
'edit_polls'    => [ 'administrator''editor''author''contributor' ],
            
'delete_polls'  => [ 'administrator''editor''author''contributor' ],
            
'publish_polls' => [ 'administrator''editor''author' ],

            
'edit_others_polls'   => [ 'administrator''editor' ],
            
'delete_others_polls' => [ 'administrator''editor' ],

            
'edit_published_polls'   => [ 'administrator''editor''author' ],
            
'delete_published_polls' => [ 'administrator''editor''author' ],

            
'read_private_polls'   => [ 'administrator''editor' ],
            
'edit_private_polls'   => [ 'administrator''editor' ],
            
'delete_private_polls' => [ 'administrator''editor' ],
            
'create_polls'         => [ 'administrator''editor''author''contributor' ],
        ];

        foreach ( 
$map as $capability => $roles ):
            foreach ( 
$roles as $role ):
                
$role get_role$role );
                if ( 
$role ):
                    
$role->add_cap$capability );
                endif;
            endforeach;
        endforeach;
    }

    
/**
     * @param \WP_Post $post WordPress post.
     *
     * @return array
     * @since 1.0.0
     */
    
public function getMessages$post ) {
        return [
            
0  => ''// Unused. Messages start at index 1.
            
1  => sprintf__'Poll updated. <a href="%s">View poll</a>''totalpoll' ), esc_urlget_permalink$post->ID ) ) ),
            
2  => __'Custom field updated.''totalpoll' ),
            
3  => __'Custom field deleted.''totalpoll' ),
            
4  => __'Poll updated.''totalpoll' ),
            
5  => isset( $_GET['revision'] ) ? sprintf__'Poll restored to revision from %s''totalpoll' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
            
6  => sprintf__'Poll published. <a href="%s">View poll</a>''totalpoll' ), esc_urlget_permalink$post->ID ) ) ),
            
7  => __'Poll saved.''totalpoll' ),
            
8  => sprintf__'Poll submitted. <a target="_blank" href="%s">Preview poll</a>''totalpoll' ),
                
esc_urladd_query_arg'preview''true'get_permalink$post->ID ) ) ) ),
            
9  => sprintf__'Poll scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview poll</a>''totalpoll' ),
                
date_i18n__'M j, Y @ G:i' ), strtotime$post->post_date ) ), esc_urlget_permalink$post->ID ) ) ),
            
10 => sprintf__'Poll draft updated. <a target="_blank" href="%s">Preview poll</a>''totalpoll' ),
                
esc_urladd_query_arg'preview''true'get_permalink$post->ID ) ) ) ),
        ];
    }

    
/**
     * Get CPT name.
     *
     * @return string
     */
    
public function getName() {
        
/**
         * Filters the name of poll CPT.
         *
         * @param string $name CPT name.
         *
         * @since 4.0.0
         * @return string
         */
        
return apply_filters'totalpoll/filters/cpt/name''poll' );
    }

    
/**
     * Get CPT args.
     *
     * @return array
     */
    
public function getArguments() {
        
/**
         * Filters the arguments of poll CPT.
         *
         * @param array $args CPT arguments.
         *
         * @since 4.0.0
         * @return array
         */
        
return apply_filters'totalpoll/filters/cpt/args', [
            
'labels' => [
                
'name'               => __'Polls''totalpoll' ),
                
'singular_name'      => __'Poll''totalpoll' ),
                
'add_new'            => __'Create Poll''totalpoll' ),
                
'add_new_item'       => __'New Poll''totalpoll' ),
                
'edit_item'          => __'Edit Poll''totalpoll' ),
                
'new_item'           => __'New Poll''totalpoll' ),
                
'all_items'          => __'Polls''totalpoll' ),
                
'view_item'          => __'View Poll''totalpoll' ),
                
'search_items'       => __'Search Polls''totalpoll' ),
                
'not_found'          => __'No polls found''totalpoll' ),
                
'not_found_in_trash' => __'No polls found in Trash''totalpoll' ),
                
'menu_name'          => __'TotalPoll''totalpoll' ),
            ],

            
'public'             => true,
            
'publicly_queryable' => true,
            
'show_ui'            => true,
            
'show_in_menu'       => true,
            
'query_var'          => false,
            
'rewrite'            => [
                
'slug'  => _x$this->getName(), 'slug''totalpoll' ),
                
'feeds' => false,
                
'pages' => false,
            ],
            
'capabilities'       => [
                
'edit_post'          => 'edit_poll',
                
'read_post'          => 'read_poll',
                
'delete_post'        => 'delete_poll',
                
'edit_posts'         => 'edit_polls',
                
'edit_others_posts'  => 'edit_others_polls',
                
'publish_posts'      => 'publish_polls',
                
'read_private_posts' => 'read_private_polls',
                
'create_posts'       => 'create_polls',
            ],
            
'map_meta_cap'       => true,
            
'has_archive'        => _x'polls''slug''totalpoll' ),
            
'menu_position'      => null,
            
'hierarchical'       => false,
            
'show_in_rest'       => false,
            
'menu_icon'          => 'dashicons-chart-bar',
            
'supports'           => [ 'title''revisions''excerpt' ],
        ] );
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586