| 1 |
<?php |
| 2 |
/** |
| 3 |
* OpenStation — built-in file-type registrations. |
| 4 |
* |
| 5 |
* Registers the file types that ship with the plugin |
| 6 |
* through the same public API third-party plugins use. Hooked on |
| 7 |
* `init` priority 5 so the types land in the registry before the |
| 8 |
* shell config is built and before any third-party plugin that |
| 9 |
* wants to react via `openstation_file_type_registered`. |
| 10 |
* |
| 11 |
* @package OpenStation |
| 12 |
*/ |
| 13 |
|
| 14 |
defined( 'ABSPATH' ) || exit; |
| 15 |
|
| 16 |
/** |
| 17 |
* Registers the built-in file types (post, attachment, user, |
| 18 |
* term, comment, bookmark, folder, shortcut, link, embed). |
| 19 |
*/ |
| 20 |
function openstation_register_builtin_file_types() { |
| 21 |
$types = array( |
| 22 |
array( |
| 23 |
'type' => 'post', |
| 24 |
'label' => __( 'Post', 'desktop-mode' ), |
| 25 |
'class' => 'OpenStation_Post_File', |
| 26 |
'sort' => 10, |
| 27 |
), |
| 28 |
array( |
| 29 |
'type' => 'attachment', |
| 30 |
'label' => __( 'Media', 'desktop-mode' ), |
| 31 |
'class' => 'OpenStation_Attachment_File', |
| 32 |
'sort' => 20, |
| 33 |
), |
| 34 |
array( |
| 35 |
'type' => 'upload', |
| 36 |
'label' => __( 'Uploaded file', 'desktop-mode' ), |
| 37 |
'class' => 'OpenStation_Upload_File', |
| 38 |
'sort' => 25, |
| 39 |
), |
| 40 |
array( |
| 41 |
'type' => 'user', |
| 42 |
'label' => __( 'User', 'desktop-mode' ), |
| 43 |
'class' => 'OpenStation_User_File', |
| 44 |
'sort' => 30, |
| 45 |
), |
| 46 |
array( |
| 47 |
'type' => 'term', |
| 48 |
'label' => __( 'Taxonomy term', 'desktop-mode' ), |
| 49 |
'class' => 'OpenStation_Term_File', |
| 50 |
'sort' => 40, |
| 51 |
), |
| 52 |
array( |
| 53 |
'type' => 'comment', |
| 54 |
'label' => __( 'Comment', 'desktop-mode' ), |
| 55 |
'class' => 'OpenStation_Comment_File', |
| 56 |
'sort' => 50, |
| 57 |
), |
| 58 |
array( |
| 59 |
'type' => 'bookmark', |
| 60 |
'label' => __( 'Bookmark', 'desktop-mode' ), |
| 61 |
'class' => 'OpenStation_Bookmark_File', |
| 62 |
'sort' => 60, |
| 63 |
), |
| 64 |
array( |
| 65 |
'type' => 'folder', |
| 66 |
'label' => __( 'Folder', 'desktop-mode' ), |
| 67 |
'class' => 'OpenStation_Folder_File', |
| 68 |
'sort' => 5, |
| 69 |
), |
| 70 |
array( |
| 71 |
'type' => 'shortcut', |
| 72 |
'label' => __( 'Plugin shortcut', 'desktop-mode' ), |
| 73 |
'class' => 'OpenStation_Shortcut_File', |
| 74 |
'sort' => 1, |
| 75 |
), |
| 76 |
array( |
| 77 |
'type' => 'link', |
| 78 |
'label' => __( 'Web link', 'desktop-mode' ), |
| 79 |
'class' => 'OpenStation_Link_File', |
| 80 |
'sort' => 70, |
| 81 |
), |
| 82 |
array( |
| 83 |
'type' => 'embed', |
| 84 |
'label' => __( 'Embedded web window', 'desktop-mode' ), |
| 85 |
'class' => 'OpenStation_Embed_File', |
| 86 |
'sort' => 80, |
| 87 |
), |
| 88 |
); |
| 89 |
|
| 90 |
foreach ( $types as $args ) { |
| 91 |
openstation_register_file_type( |
| 92 |
$args['type'], |
| 93 |
array( |
| 94 |
'label' => $args['label'], |
| 95 |
'class' => $args['class'], |
| 96 |
'sort' => $args['sort'], |
| 97 |
) |
| 98 |
); |
| 99 |
} |
| 100 |
} |
| 101 |
add_action( 'init', 'openstation_register_builtin_file_types', 5 ); |
| 102 |
|