| @@ -6,8 +6,14 @@ | ||
| 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 |
| @@ -265,26 +271,26 @@ | ||
| 265 | 271 | $queryable = is_plugin_active( 'mainwp-post-plus-extension/mainwp-post-plus-extension.php' ); |
| 266 | 272 | } |
| 267 | 273 | |
| 268 | 274 | $labels = array( |
| 269 | - 'name' => _x( 'Bulkpost', 'bulkpost' ), | |
| 270 | - 'singular_name' => _x( 'Bulkpost', 'bulkpost' ), | |
| 271 | - 'add_new' => _x( 'Add New', 'bulkpost' ), | |
| 272 | - 'add_new_item' => _x( 'Add New Bulkpost', 'bulkpost' ), | |
| 273 | - 'edit_item' => _x( 'Edit Bulkpost', 'bulkpost' ), | |
| 274 | - 'new_item' => _x( 'New Bulkpost', 'bulkpost' ), | |
| 275 | - 'view_item' => _x( 'View Bulkpost', 'bulkpost' ), | |
| 276 | - 'search_items' => _x( 'Search Bulkpost', 'bulkpost' ), | |
| 277 | - 'not_found' => _x( 'No bulkpost found', 'bulkpost' ), | |
| 278 | - 'not_found_in_trash' => _x( 'No bulkpost found in Trash', 'bulkpost' ), | |
| 279 | - 'parent_item_colon' => _x( 'Parent Bulkpost:', 'bulkpost' ), | |
| 280 | - 'menu_name' => _x( 'Bulkpost', 'bulkpost' ), | |
| 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' ), | |
| 281 | 287 | ); |
| 282 | 288 | |
| 283 | 289 | $args = array( |
| 284 | 290 | 'labels' => $labels, |
| 285 | 291 | 'hierarchical' => false, |
| 286 | - 'description' => 'description...', | |
| 292 | + 'description' => __( 'description...', 'mainwp' ), | |
| 287 | 293 | 'supports' => array( |
| 288 | 294 | 'title', |
| 289 | 295 | 'editor', |
| 290 | 296 | 'excerpt', |
| @@ -301,40 +307,32 @@ | ||
| 301 | 307 | 'has_archive' => false, |
| 302 | 308 | 'query_var' => false, |
| 303 | 309 | 'can_export' => false, |
| 304 | 310 | 'rewrite' => false, |
| 305 | - 'capabilities' => array( | |
| 306 | - 'edit_post' => 'read', | |
| 307 | - 'edit_posts' => 'read', | |
| 308 | - 'edit_others_posts' => 'read', | |
| 309 | - 'publish_posts' => 'read', | |
| 310 | - 'read_post' => 'read', | |
| 311 | - 'read_private_posts' => 'read', | |
| 312 | - 'delete_post' => 'read', | |
| 313 | - ), | |
| 311 | + 'capabilities' => $this->get_admin_only_capabilities(), | |
| 314 | 312 | ); |
| 315 | 313 | |
| 316 | 314 | register_post_type( 'bulkpost', $args ); |
| 317 | 315 | |
| 318 | 316 | $labels = array( |
| 319 | - 'name' => _x( 'Bulkpage', 'bulkpage' ), | |
| 320 | - 'singular_name' => _x( 'Bulkpage', 'bulkpage' ), | |
| 321 | - 'add_new' => _x( 'Add New', 'bulkpage' ), | |
| 322 | - 'add_new_item' => _x( 'Add New Bulkpage', 'bulkpage' ), | |
| 323 | - 'edit_item' => _x( 'Edit Bulkpage', 'bulkpage' ), | |
| 324 | - 'new_item' => _x( 'New Bulkpage', 'bulkpage' ), | |
| 325 | - 'view_item' => _x( 'View Bulkpage', 'bulkpage' ), | |
| 326 | - 'search_items' => _x( 'Search Bulkpage', 'bulkpage' ), | |
| 327 | - 'not_found' => _x( 'No bulkpage found', 'bulkpage' ), | |
| 328 | - 'not_found_in_trash' => _x( 'No bulkpage found in Trash', 'bulkpage' ), | |
| 329 | - 'parent_item_colon' => _x( 'Parent Bulkpage:', 'bulkpage' ), | |
| 330 | - 'menu_name' => _x( 'Bulkpage', 'bulkpage' ), | |
| 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' ), | |
| 331 | 329 | ); |
| 332 | 330 | |
| 333 | 331 | $args = array( |
| 334 | 332 | 'labels' => $labels, |
| 335 | 333 | 'hierarchical' => false, |
| 336 | - 'description' => 'description...', | |
| 334 | + 'description' => __( 'description...', 'mainwp' ), | |
| 337 | 335 | 'supports' => array( |
| 338 | 336 | 'title', |
| 339 | 337 | 'editor', |
| 340 | 338 | 'excerpt', |
| @@ -351,22 +349,39 @@ | ||
| 351 | 349 | 'has_archive' => false, |
| 352 | 350 | 'query_var' => false, |
| 353 | 351 | 'can_export' => false, |
| 354 | 352 | 'rewrite' => false, |
| 355 | - 'capabilities' => array( | |
| 356 | - 'edit_post' => 'read', | |
| 357 | - 'edit_posts' => 'read', | |
| 358 | - 'edit_others_posts' => 'read', | |
| 359 | - 'publish_posts' => 'read', | |
| 360 | - 'read_post' => 'read', | |
| 361 | - 'read_private_posts' => 'read', | |
| 362 | - 'delete_post' => 'read', | |
| 363 | - ), | |
| 353 | + 'capabilities' => $this->get_admin_only_capabilities(), | |
| 364 | 354 | ); |
| 365 | 355 | |
| 366 | 356 | register_post_type( 'bulkpage', $args ); |
| 367 | 357 | |
| 368 | 358 | do_action( 'mainwp_register_post_type' ); |
| 359 | + } | |
| 360 | + | |
| 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 | + ); | |
| 369 | 384 | } |
| 370 | 385 | |
| 371 | 386 | /** |
| 372 | 387 | * Method post_updated_messages() |