PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | class/class-mainwp-bulk-post.php +344 -320 5.0 → 6.2.2 View file →
@@ -6,372 +6,396 @@
6 6 */
7 7
8 8 namespace MainWP\Dashboard;
9 9
10 +// Exit if accessed directly.
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit;
13 +}
14 +
15 +
10 16 /**
11 17 * Class MainWP_Bulk_Post
12 18 *
13 19 * @package MainWP\Dashboard
14 20 */
15 -class MainWP_Bulk_Post {
21 +class MainWP_Bulk_Post { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
16 22
17 - /**
18 - * MainWP_Bulk_Post constructor.
19 - *
20 - * Run each time the class is called.
21 - */
22 - public function __construct() {
23 - add_action( 'admin_post_mainwp_editpost', array( &$this, 'handle_edit_bulkpost' ) );
24 - add_action( 'save_post', array( &$this, 'save_bulkpost' ) );
25 - add_action( 'save_post', array( &$this, 'save_bulkpage' ) );
26 - add_action( 'init', array( &$this, 'create_post_type' ) );
27 - add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
28 - }
23 + /**
24 + * MainWP_Bulk_Post constructor.
25 + *
26 + * Run each time the class is called.
27 + */
28 + public function __construct() {
29 + add_action( 'admin_post_mainwp_editpost', array( &$this, 'handle_edit_bulkpost' ) );
30 + add_action( 'save_post', array( &$this, 'save_bulkpost' ) );
31 + add_action( 'save_post', array( &$this, 'save_bulkpage' ) );
32 + add_action( 'init', array( &$this, 'create_post_type' ) );
33 + add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) );
34 + }
29 35
30 - /**
31 - * Method handle_edit_bulkpost()
32 - *
33 - * Handle bulk post edit process.
34 - */
35 - public function handle_edit_bulkpost() {
36 36
37 - $post_id = 0;
38 - if ( isset( $_POST['post_ID'] ) ) {
39 - $post_id = (int) $_POST['post_ID'];
40 - }
37 + /**
38 + * Method get_instance().
39 + */
40 + public static function get_instance() {
41 + return new self();
42 + }
41 43
42 - if ( $post_id && isset( $_POST['select_sites_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['select_sites_nonce'] ), 'select_sites_' . $post_id ) ) {
43 - check_admin_referer( 'update-post_' . $post_id );
44 - edit_post();
44 + /**
45 + * Method handle_edit_bulkpost()
46 + *
47 + * Handle bulk post edit process.
48 + */
49 + public function handle_edit_bulkpost() {
45 50
46 - $location = admin_url( 'admin.php?page=PostBulkEdit&post_id=' . $post_id . '&message=1' );
51 + $post_id = 0;
52 + if ( isset( $_POST['post_ID'] ) ) {
53 + $post_id = (int) $_POST['post_ID'];
54 + }
47 55
48 - /**
49 - * Filter: redirect_post_location
50 - *
51 - * Filters the location for the Edit process.
52 - *
53 - * @param int $post_id Post ID.
54 - *
55 - * @since Unknown
56 - */
57 - $location = apply_filters( 'redirect_post_location', $location, $post_id );
58 - wp_safe_redirect( $location );
59 - exit();
60 - }
61 - }
56 + if ( $post_id && isset( $_POST['select_sites_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['select_sites_nonce'] ), 'select_sites_' . $post_id ) ) {
57 + check_admin_referer( 'update-post_' . $post_id );
58 + edit_post();
62 59
63 - /**
64 - * Method redirect_edit_bulkpost().
65 - *
66 - * Redirect to edit post.
67 - *
68 - * @param string $location Target URL.
69 - * @param int $post_id Post ID number.
70 - *
71 - * @return string $location Target URL.
72 - */
73 - public function redirect_edit_bulkpost( $location, $post_id ) {
74 - if ( $post_id ) {
75 - $location = admin_url( 'admin.php?page=PostBulkEdit&post_id=' . intval( $post_id ) );
76 - } else {
77 - $location = admin_url( 'admin.php?page=PostBulkAdd' );
78 - }
60 + $location = admin_url( 'admin.php?page=PostBulkEdit&post_id=' . $post_id . '&message=1' );
79 61
80 - return $location;
81 - }
62 + /**
63 + * Filter: redirect_post_location
64 + *
65 + * Filters the location for the Edit process.
66 + *
67 + * @param int $post_id Post ID.
68 + *
69 + * @since Unknown
70 + */
71 + $location = apply_filters( 'redirect_post_location', $location, $post_id );
72 + wp_safe_redirect( $location );
73 + exit();
74 + }
75 + }
82 76
83 - /**
84 - * Method redirect_edit_bulkpage().
85 - *
86 - * Redirect to edit page.
87 - *
88 - * @param string $location Target URL.
89 - * @param int $post_id Page ID number.
90 - *
91 - * @return string $location Target URL.
92 - */
93 - public function redirect_edit_bulkpage( $location, $post_id ) {
77 + /**
78 + * Method redirect_edit_bulkpost().
79 + *
80 + * Redirect to edit post.
81 + *
82 + * @param string $location Target URL.
83 + * @param int $post_id Post ID number.
84 + *
85 + * @return string $location Target URL.
86 + */
87 + public function redirect_edit_bulkpost( $location, $post_id ) {
88 + unset( $location );
89 + if ( $post_id ) {
90 + $loc = admin_url( 'admin.php?page=PostBulkEdit&post_id=' . intval( $post_id ) );
91 + } else {
92 + $loc = admin_url( 'admin.php?page=PostBulkAdd' );
93 + }
94 94
95 - if ( $post_id ) {
96 - $location = admin_url( 'admin.php?page=PageBulkEdit&post_id=' . intval( $post_id ) );
97 - } else {
98 - $location = admin_url( 'admin.php?page=PageBulkAdd' );
99 - }
95 + return $loc;
96 + }
100 97
101 - return $location;
102 - }
98 + /**
99 + * Method redirect_edit_bulkpage().
100 + *
101 + * Redirect to edit page.
102 + *
103 + * @param string $location Target URL.
104 + * @param int $post_id Page ID number.
105 + *
106 + * @return string $location Target URL.
107 + */
108 + public function redirect_edit_bulkpage( $location, $post_id ) {
109 + unset( $location );
110 + if ( $post_id ) {
111 + $loc = admin_url( 'admin.php?page=PageBulkEdit&post_id=' . intval( $post_id ) );
112 + } else {
113 + $loc = admin_url( 'admin.php?page=PageBulkAdd' );
114 + }
103 115
116 + return $loc;
117 + }
104 118
105 - /**
106 - * Method save_bulkpost().
107 - *
108 - * Save page (Bulk post custom post type).
109 - *
110 - * @param int $post_id Post ID.
111 - *
112 - * @return void
113 - *
114 - * @uses \MainWP\Dashboard\MainWP_Meta_Boxes::select_sites_handle()
115 - * @uses \MainWP\Dashboard\MainWP_Meta_Boxes::add_categories_handle()
116 - * @uses \MainWP\Dashboard\MainWP_Meta_Boxes::add_slug_handle()
117 - * @uses \MainWP\Dashboard\MainWP_Post_Page_Handler::add_sticky_handle()
118 - */
119 - public function save_bulkpost( $post_id ) {
120 - $_post = get_post( $post_id );
121 119
122 - if ( 'bulkpost' !== $_post->post_type ) {
123 - return;
124 - }
120 + /**
121 + * Method save_bulkpost().
122 + *
123 + * Save page (Bulk post custom post type).
124 + *
125 + * @param int $post_id Post ID.
126 + *
127 + * @return void
128 + *
129 + * @uses \MainWP\Dashboard\MainWP_Meta_Boxes::select_sites_handle()
130 + * @uses \MainWP\Dashboard\MainWP_Meta_Boxes::add_categories_handle()
131 + * @uses \MainWP\Dashboard\MainWP_Meta_Boxes::add_slug_handle()
132 + * @uses \MainWP\Dashboard\MainWP_Post_Page_Handler::add_sticky_handle()
133 + */
134 + public function save_bulkpost( $post_id ) {
135 + $_post = get_post( $post_id );
125 136
126 - if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['_wpnonce'] ), 'update-post_' . $post_id ) ) {
127 - return;
128 - }
137 + if ( 'bulkpost' !== $_post->post_type ) {
138 + return;
139 + }
129 140
130 - if ( ! isset( $_POST['post_type'] ) || ( 'bulkpost' !== $_POST['post_type'] ) ) {
131 - return;
132 - }
141 + if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['_wpnonce'] ), 'update-post_' . $post_id ) ) {
142 + return;
143 + }
133 144
134 - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
135 - return;
136 - }
145 + if ( ! isset( $_POST['post_type'] ) || ( 'bulkpost' !== $_POST['post_type'] ) ) {
146 + return;
147 + }
137 148
138 - if ( isset( $_POST['mainwp_wpseo_metabox_save_values'] ) && ( ! empty( $_POST['mainwp_wpseo_metabox_save_values'] ) ) ) {
139 - return;
140 - }
149 + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
150 + return;
151 + }
141 152
142 - $pid = (int) MainWP_System::instance()->metaboxes->select_sites_handle( $post_id, 'bulkpost' );
143 - MainWP_System::instance()->metaboxes->add_categories_handle( $post_id, 'bulkpost' );
144 - MainWP_System::instance()->metaboxes->add_tags_handle( $post_id, 'bulkpost' );
145 - MainWP_System::instance()->metaboxes->add_slug_handle( $post_id, 'bulkpost' );
146 - MainWP_Post_Page_Handler::add_sticky_handle( $post_id );
147 - MainWP_Post_Page_Handler::add_status_handle( $post_id );
153 + if ( isset( $_POST['mainwp_wpseo_metabox_save_values'] ) && ( ! empty( $_POST['mainwp_wpseo_metabox_save_values'] ) ) ) {
154 + return;
155 + }
148 156
149 - /**
150 - * Action: mainwp_save_bulkpost
151 - *
152 - * Fires when saving the bulk post.
153 - *
154 - * @param int $post_id Post ID.
155 - *
156 - * @since Unknown
157 - */
158 - do_action( 'mainwp_save_bulkpost', $post_id );
157 + $pid = (int) MainWP_System::instance()->metaboxes->select_sites_handle( $post_id, 'bulkpost' );
158 + MainWP_System::instance()->metaboxes->add_categories_handle( $post_id, 'bulkpost' );
159 + MainWP_System::instance()->metaboxes->add_tags_handle( $post_id, 'bulkpost' );
160 + MainWP_System::instance()->metaboxes->add_slug_handle( $post_id, 'bulkpost' );
161 + MainWP_Post_Page_Handler::add_sticky_handle( $post_id );
162 + MainWP_Post_Page_Handler::add_status_handle( $post_id );
159 163
160 - if ( $pid === $post_id ) {
161 - add_filter( 'redirect_post_location', array( $this, 'redirect_edit_bulkpost' ), 10, 2 );
162 - } else {
163 - /**
164 - * Action: mainwp_before_redirect_posting_bulkpost
165 - *
166 - * Fires before redirection to posting 'bulk post' page after post submission.
167 - *
168 - * @param object $_post Object containing post data.
169 - *
170 - * @since 4.0
171 - */
172 - do_action( 'mainwp_before_redirect_posting_bulkpost', $_post );
173 - wp_safe_redirect( get_site_url() . '/wp-admin/admin.php?page=PostingBulkPost&id=' . $post_id . '&hideall=1&posting_nonce=' . wp_create_nonce( 'posting_nonce_' . $post_id ) );
174 - die();
175 - }
176 - }
164 + /**
165 + * Action: mainwp_save_bulkpost
166 + *
167 + * Fires when saving the bulk post.
168 + *
169 + * @param int $post_id Post ID.
170 + *
171 + * @since Unknown
172 + */
173 + do_action( 'mainwp_save_bulkpost', $post_id );
177 174
178 - /**
179 - * Method save_bulkpage().
180 - *
181 - * Save page (Bulk page custom post type).
182 - *
183 - * @param int $post_id Page ID.
184 - *
185 - * @return void
186 - *
187 - * @uses \MainWP\Dashboard\MainWP_System::$metaboxes
188 - * @uses \MainWP\Dashboard\MainWP_Page::add_status_handle()
189 - */
190 - public function save_bulkpage( $post_id ) {
175 + if ( $pid === $post_id ) {
176 + add_filter( 'redirect_post_location', array( $this, 'redirect_edit_bulkpost' ), 10, 2 );
177 + } else {
178 + /**
179 + * Action: mainwp_before_redirect_posting_bulkpost
180 + *
181 + * Fires before redirection to posting 'bulk post' page after post submission.
182 + *
183 + * @param object $_post Object containing post data.
184 + *
185 + * @since 4.0
186 + */
187 + do_action( 'mainwp_before_redirect_posting_bulkpost', $_post );
188 + wp_safe_redirect( get_site_url() . '/wp-admin/admin.php?page=PostingBulkPost&id=' . $post_id . '&hideall=1&posting_nonce=' . wp_create_nonce( 'posting_nonce_' . $post_id ) );
189 + die();
190 + }
191 + }
191 192
192 - $_post = get_post( $post_id );
193 + /**
194 + * Method save_bulkpage().
195 + *
196 + * Save page (Bulk page custom post type).
197 + *
198 + * @param int $post_id Page ID.
199 + *
200 + * @return void
201 + *
202 + * @uses \MainWP\Dashboard\MainWP_System::$metaboxes
203 + * @uses \MainWP\Dashboard\MainWP_Page::add_status_handle()
204 + */
205 + public function save_bulkpage( $post_id ) {
193 206
194 - if ( 'bulkpage' !== $_post->post_type ) {
195 - return;
196 - }
207 + $_post = get_post( $post_id );
197 208
198 - if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['_wpnonce'] ), 'update-post_' . $post_id ) ) {
199 - return;
200 - }
209 + if ( 'bulkpage' !== $_post->post_type ) {
210 + return;
211 + }
201 212
202 - if ( ! isset( $_POST['post_type'] ) || ( 'bulkpage' !== $_POST['post_type'] ) ) {
203 - return;
204 - }
213 + if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['_wpnonce'] ), 'update-post_' . $post_id ) ) {
214 + return;
215 + }
205 216
206 - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
207 - return;
208 - }
217 + if ( ! isset( $_POST['post_type'] ) || ( 'bulkpage' !== $_POST['post_type'] ) ) {
218 + return;
219 + }
209 220
210 - if ( isset( $_POST['mainwp_wpseo_metabox_save_values'] ) && ( ! empty( $_POST['mainwp_wpseo_metabox_save_values'] ) ) ) {
211 - return;
212 - }
221 + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
222 + return;
223 + }
213 224
214 - $pid = (int) MainWP_System::instance()->metaboxes->select_sites_handle( $post_id, 'bulkpage' );
215 - MainWP_System::instance()->metaboxes->add_slug_handle( $post_id, 'bulkpage' );
216 - MainWP_Post_Page_Handler::add_status_handle( $post_id );
225 + if ( isset( $_POST['mainwp_wpseo_metabox_save_values'] ) && ( ! empty( $_POST['mainwp_wpseo_metabox_save_values'] ) ) ) {
226 + return;
227 + }
217 228
218 - /**
219 - * Action: mainwp_save_bulkpage
220 - *
221 - * Fires when saving the bulk page.
222 - *
223 - * @param int $post_id Post ID.
224 - *
225 - * @since Unknown
226 - */
227 - do_action( 'mainwp_save_bulkpage', $post_id );
229 + $pid = (int) MainWP_System::instance()->metaboxes->select_sites_handle( $post_id, 'bulkpage' );
230 + MainWP_System::instance()->metaboxes->add_slug_handle( $post_id, 'bulkpage' );
231 + MainWP_Post_Page_Handler::add_status_handle( $post_id );
228 232
229 - if ( $pid === $post_id ) {
230 - add_filter( 'redirect_post_location', array( $this, 'redirect_edit_bulkpage' ), 10, 2 );
231 - } else {
232 - /**
233 - * Action: mainwp_before_redirect_posting_bulkpage
234 - *
235 - * Fires before redirection to posting 'bulk page' page after post submission.
236 - *
237 - * @param object $_post Object containing post data.
238 - *
239 - * @since 4.0
240 - */
241 - do_action( 'mainwp_before_redirect_posting_bulkpage', $_post );
242 - wp_safe_redirect( get_site_url() . '/wp-admin/admin.php?page=PostingBulkPage&posting_nonce=' . wp_create_nonce( 'posting_nonce_' . $post_id ) . '&id=' . $post_id . '&hideall=1' );
243 - die();
244 - }
245 - }
233 + /**
234 + * Action: mainwp_save_bulkpage
235 + *
236 + * Fires when saving the bulk page.
237 + *
238 + * @param int $post_id Post ID.
239 + *
240 + * @since Unknown
241 + */
242 + do_action( 'mainwp_save_bulkpage', $post_id );
246 243
247 - /**
248 - * Method create_post_type()
249 - *
250 - * Register "Bulkpost" and "Bulkpage" custom post types.
251 - */
252 - public function create_post_type() {
244 + if ( $pid === $post_id ) {
245 + add_filter( 'redirect_post_location', array( $this, 'redirect_edit_bulkpage' ), 10, 2 );
246 + } else {
247 + /**
248 + * Action: mainwp_before_redirect_posting_bulkpage
249 + *
250 + * Fires before redirection to posting 'bulk page' page after post submission.
251 + *
252 + * @param object $_post Object containing post data.
253 + *
254 + * @since 4.0
255 + */
256 + do_action( 'mainwp_before_redirect_posting_bulkpage', $_post );
257 + wp_safe_redirect( get_site_url() . '/wp-admin/admin.php?page=PostingBulkPage&posting_nonce=' . wp_create_nonce( 'posting_nonce_' . $post_id ) . '&id=' . $post_id . '&hideall=1' );
258 + die();
259 + }
260 + }
253 261
254 - $queryable = true;
255 - if ( function_exists( 'is_plugin_active' ) ) {
256 - $queryable = is_plugin_active( 'mainwp-post-plus-extension/mainwp-post-plus-extension.php' ) ? true : false;
257 - }
262 + /**
263 + * Method create_post_type()
264 + *
265 + * Register "Bulkpost" and "Bulkpage" custom post types.
266 + */
267 + public function create_post_type() {
258 268
259 - $labels = array(
260 - 'name' => _x( 'Bulkpost', 'bulkpost' ),
261 - 'singular_name' => _x( 'Bulkpost', 'bulkpost' ),
262 - 'add_new' => _x( 'Add New', 'bulkpost' ),
263 - 'add_new_item' => _x( 'Add New Bulkpost', 'bulkpost' ),
264 - 'edit_item' => _x( 'Edit Bulkpost', 'bulkpost' ),
265 - 'new_item' => _x( 'New Bulkpost', 'bulkpost' ),
266 - 'view_item' => _x( 'View Bulkpost', 'bulkpost' ),
267 - 'search_items' => _x( 'Search Bulkpost', 'bulkpost' ),
268 - 'not_found' => _x( 'No bulkpost found', 'bulkpost' ),
269 - 'not_found_in_trash' => _x( 'No bulkpost found in Trash', 'bulkpost' ),
270 - 'parent_item_colon' => _x( 'Parent Bulkpost:', 'bulkpost' ),
271 - 'menu_name' => _x( 'Bulkpost', 'bulkpost' ),
272 - );
269 + $queryable = true;
270 + if ( function_exists( 'is_plugin_active' ) ) {
271 + $queryable = is_plugin_active( 'mainwp-post-plus-extension/mainwp-post-plus-extension.php' );
272 + }
273 273
274 - $args = array(
275 - 'labels' => $labels,
276 - 'hierarchical' => false,
277 - 'description' => 'description...',
278 - 'supports' => array(
279 - 'title',
280 - 'editor',
281 - 'excerpt',
282 - 'thumbnail',
283 - 'custom-fields',
284 - 'comments',
285 - 'revisions',
286 - ),
287 - 'public' => true,
288 - 'show_ui' => true,
289 - 'show_in_nav_menus' => false,
290 - 'publicly_queryable' => $queryable,
291 - 'exclude_from_search' => true,
292 - 'has_archive' => false,
293 - 'query_var' => false,
294 - 'can_export' => false,
295 - 'rewrite' => false,
296 - 'capabilities' => array(
297 - 'edit_post' => 'read',
298 - 'edit_posts' => 'read',
299 - 'edit_others_posts' => 'read',
300 - 'publish_posts' => 'read',
301 - 'read_post' => 'read',
302 - 'read_private_posts' => 'read',
303 - 'delete_post' => 'read',
304 - ),
305 - );
274 + $labels = array(
275 + 'name' => _x( 'Bulkpost', 'bulkpost', 'mainwp' ),
276 + 'singular_name' => _x( 'Bulkpost', 'bulkpost', 'mainwp' ),
277 + 'add_new' => _x( 'Add New', 'bulkpost', 'mainwp' ),
278 + 'add_new_item' => _x( 'Add New Bulkpost', 'bulkpost', 'mainwp' ),
279 + 'edit_item' => _x( 'Edit Bulkpost', 'bulkpost', 'mainwp' ),
280 + 'new_item' => _x( 'New Bulkpost', 'bulkpost', 'mainwp' ),
281 + 'view_item' => _x( 'View Bulkpost', 'bulkpost', 'mainwp' ),
282 + 'search_items' => _x( 'Search Bulkpost', 'bulkpost', 'mainwp' ),
283 + 'not_found' => _x( 'No bulkpost found', 'bulkpost', 'mainwp' ),
284 + 'not_found_in_trash' => _x( 'No bulkpost found in Trash', 'bulkpost', 'mainwp' ),
285 + 'parent_item_colon' => _x( 'Parent Bulkpost:', 'bulkpost', 'mainwp' ),
286 + 'menu_name' => _x( 'Bulkpost', 'bulkpost', 'mainwp' ),
287 + );
306 288
307 - register_post_type( 'bulkpost', $args );
289 + $args = array(
290 + 'labels' => $labels,
291 + 'hierarchical' => false,
292 + 'description' => __( 'description...', 'mainwp' ),
293 + 'supports' => array(
294 + 'title',
295 + 'editor',
296 + 'excerpt',
297 + 'thumbnail',
298 + 'custom-fields',
299 + 'comments',
300 + 'revisions',
301 + ),
302 + 'public' => true,
303 + 'show_ui' => true,
304 + 'show_in_nav_menus' => false,
305 + 'publicly_queryable' => $queryable,
306 + 'exclude_from_search' => true,
307 + 'has_archive' => false,
308 + 'query_var' => false,
309 + 'can_export' => false,
310 + 'rewrite' => false,
311 + 'capabilities' => $this->get_admin_only_capabilities(),
312 + );
308 313
309 - $labels = array(
310 - 'name' => _x( 'Bulkpage', 'bulkpage' ),
311 - 'singular_name' => _x( 'Bulkpage', 'bulkpage' ),
312 - 'add_new' => _x( 'Add New', 'bulkpage' ),
313 - 'add_new_item' => _x( 'Add New Bulkpage', 'bulkpage' ),
314 - 'edit_item' => _x( 'Edit Bulkpage', 'bulkpage' ),
315 - 'new_item' => _x( 'New Bulkpage', 'bulkpage' ),
316 - 'view_item' => _x( 'View Bulkpage', 'bulkpage' ),
317 - 'search_items' => _x( 'Search Bulkpage', 'bulkpage' ),
318 - 'not_found' => _x( 'No bulkpage found', 'bulkpage' ),
319 - 'not_found_in_trash' => _x( 'No bulkpage found in Trash', 'bulkpage' ),
320 - 'parent_item_colon' => _x( 'Parent Bulkpage:', 'bulkpage' ),
321 - 'menu_name' => _x( 'Bulkpage', 'bulkpage' ),
322 - );
314 + register_post_type( 'bulkpost', $args );
323 315
324 - $args = array(
325 - 'labels' => $labels,
326 - 'hierarchical' => false,
327 - 'description' => 'description...',
328 - 'supports' => array(
329 - 'title',
330 - 'editor',
331 - 'excerpt',
332 - 'thumbnail',
333 - 'custom-fields',
334 - 'comments',
335 - 'revisions',
336 - ),
337 - 'public' => true,
338 - 'show_ui' => true,
339 - 'show_in_nav_menus' => false,
340 - 'publicly_queryable' => $queryable,
341 - 'exclude_from_search' => true,
342 - 'has_archive' => false,
343 - 'query_var' => false,
344 - 'can_export' => false,
345 - 'rewrite' => false,
346 - 'capabilities' => array(
347 - 'edit_post' => 'read',
348 - 'edit_posts' => 'read',
349 - 'edit_others_posts' => 'read',
350 - 'publish_posts' => 'read',
351 - 'read_post' => 'read',
352 - 'read_private_posts' => 'read',
353 - 'delete_post' => 'read',
354 - ),
355 - );
316 + $labels = array(
317 + 'name' => _x( 'Bulkpage', 'bulkpage', 'mainwp' ),
318 + 'singular_name' => _x( 'Bulkpage', 'bulkpage', 'mainwp' ),
319 + 'add_new' => _x( 'Add New', 'bulkpage', 'mainwp' ),
320 + 'add_new_item' => _x( 'Add New Bulkpage', 'bulkpage', 'mainwp' ),
321 + 'edit_item' => _x( 'Edit Bulkpage', 'bulkpage', 'mainwp' ),
322 + 'new_item' => _x( 'New Bulkpage', 'bulkpage', 'mainwp' ),
323 + 'view_item' => _x( 'View Bulkpage', 'bulkpage', 'mainwp' ),
324 + 'search_items' => _x( 'Search Bulkpage', 'bulkpage', 'mainwp' ),
325 + 'not_found' => _x( 'No bulkpage found', 'bulkpage', 'mainwp' ),
326 + 'not_found_in_trash' => _x( 'No bulkpage found in Trash', 'bulkpage', 'mainwp' ),
327 + 'parent_item_colon' => _x( 'Parent Bulkpage:', 'bulkpage', 'mainwp' ),
328 + 'menu_name' => _x( 'Bulkpage', 'bulkpage', 'mainwp' ),
329 + );
356 330
357 - register_post_type( 'bulkpage', $args );
331 + $args = array(
332 + 'labels' => $labels,
333 + 'hierarchical' => false,
334 + 'description' => __( 'description...', 'mainwp' ),
335 + 'supports' => array(
336 + 'title',
337 + 'editor',
338 + 'excerpt',
339 + 'thumbnail',
340 + 'custom-fields',
341 + 'comments',
342 + 'revisions',
343 + ),
344 + 'public' => true,
345 + 'show_ui' => true,
346 + 'show_in_nav_menus' => false,
347 + 'publicly_queryable' => $queryable,
348 + 'exclude_from_search' => true,
349 + 'has_archive' => false,
350 + 'query_var' => false,
351 + 'can_export' => false,
352 + 'rewrite' => false,
353 + 'capabilities' => $this->get_admin_only_capabilities(),
354 + );
358 355
359 - do_action( 'mainwp_register_post_type' );
360 - }
356 + register_post_type( 'bulkpage', $args );
361 357
362 - /**
363 - * Method post_updated_messages()
364 - *
365 - * Render post updated message.
366 - *
367 - * @param string $messages Message to display.
368 - *
369 - * @return string $messages.
370 - */
371 - public function post_updated_messages( $messages ) {
372 - $messages['post'][98] = esc_html__( 'WordPress SEO values have been saved.', 'mainwp' );
373 - $messages['post'][99] = esc_html__( 'You have to select the sites you wish to publish to.', 'mainwp' );
358 + do_action( 'mainwp_register_post_type' );
359 + }
374 360
375 - return $messages;
376 - }
361 + /**
362 + * Get admin-only capabilities for MainWP bulk content post types.
363 + *
364 + * @return array
365 + */
366 + private function get_admin_only_capabilities() {
367 + return array(
368 + 'edit_post' => 'manage_options',
369 + 'read_post' => 'manage_options',
370 + 'delete_post' => 'manage_options',
371 + 'edit_posts' => 'manage_options',
372 + 'edit_others_posts' => 'manage_options',
373 + 'delete_posts' => 'manage_options',
374 + 'publish_posts' => 'manage_options',
375 + 'read_private_posts' => 'manage_options',
376 + 'read' => 'manage_options',
377 + 'delete_private_posts' => 'manage_options',
378 + 'delete_published_posts' => 'manage_options',
379 + 'delete_others_posts' => 'manage_options',
380 + 'edit_private_posts' => 'manage_options',
381 + 'edit_published_posts' => 'manage_options',
382 + 'create_posts' => 'manage_options',
383 + );
384 + }
385 +
386 + /**
387 + * Method post_updated_messages()
388 + *
389 + * Render post updated message.
390 + *
391 + * @param string $messages Message to display.
392 + *
393 + * @return string $messages.
394 + */
395 + public function post_updated_messages( $messages ) {
396 + $messages['post'][98] = esc_html__( 'WordPress SEO values have been saved.', 'mainwp' );
397 + $messages['post'][99] = esc_html__( 'You have to select the sites you wish to publish to.', 'mainwp' );
398 +
399 + return $messages;
400 + }
377 401 }