| 1 |
<?php |
| 2 |
|
| 3 |
// If this file is called directly, abort. |
| 4 |
if ( ! defined( 'WPINC' ) ) { |
| 5 |
die; |
| 6 |
} |
| 7 |
|
| 8 |
|
| 9 |
/** |
| 10 |
* Register wpLingua Translation CPT |
| 11 |
* |
| 12 |
* @return void |
| 13 |
*/ |
| 14 |
function wplng_register_post_type_translation() { |
| 15 |
register_post_type( |
| 16 |
'wplng_translation', |
| 17 |
array( |
| 18 |
'labels' => array( |
| 19 |
'name' => __( 'Translations', 'wplingua' ), |
| 20 |
'singular_name' => __( 'Translation', 'wplingua' ), |
| 21 |
'all_items' => __( 'All translations', 'wplingua' ), |
| 22 |
'edit_item' => __( 'Edit translation', 'wplingua' ), |
| 23 |
'menu_name' => __( 'Translations', 'wplingua' ), |
| 24 |
), |
| 25 |
'public' => false, |
| 26 |
'publicly_queryable' => false, |
| 27 |
'show_ui' => true, |
| 28 |
'exclude_from_search' => true, |
| 29 |
'show_in_nav_menus' => false, |
| 30 |
'show_in_menu' => false, |
| 31 |
'has_archive' => false, |
| 32 |
'rewrite' => false, |
| 33 |
'menu_icon' => 'dashicons-translation', |
| 34 |
'supports' => array( |
| 35 |
'title', |
| 36 |
), |
| 37 |
'capability_type' => 'post', |
| 38 |
'capabilities' => array( |
| 39 |
'create_posts' => false, |
| 40 |
), |
| 41 |
'map_meta_cap' => true, |
| 42 |
) |
| 43 |
); |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
/** |
| 48 |
* Remove quick edit on wpLingua translations list |
| 49 |
* |
| 50 |
* @param array $actions |
| 51 |
* @param object $post |
| 52 |
* @return array |
| 53 |
*/ |
| 54 |
function wplng_translation_remove_quick_edit( $actions, $post ) { |
| 55 |
|
| 56 |
if ( $post->post_type != 'wplng_translation' ) { |
| 57 |
return $actions; |
| 58 |
} |
| 59 |
|
| 60 |
unset( $actions['view'] ); |
| 61 |
unset( $actions['inline hide-if-no-js'] ); |
| 62 |
|
| 63 |
return $actions; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
/** |
| 68 |
* Display 100 translations by default in admin area |
| 69 |
* |
| 70 |
* @param mixed $result |
| 71 |
* @return mixed |
| 72 |
*/ |
| 73 |
function wplng_translation_per_page( $result ) { |
| 74 |
if ( false === $result ) { |
| 75 |
$result = '100'; |
| 76 |
} |
| 77 |
|
| 78 |
return $result; |
| 79 |
} |
| 80 |
|