| 1 |
<?php |
| 2 |
/** |
| 3 |
* Desktop Mode — built-in file-type registrations. |
| 4 |
* |
| 5 |
* Registers the seven 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 `desktop_mode_file_type_registered`. |
| 10 |
* |
| 11 |
* @package WPDesktopMode |
| 12 |
* @since 0.9.0 |
| 13 |
*/ |
| 14 |
|
| 15 |
defined( 'ABSPATH' ) || exit; |
| 16 |
|
| 17 |
/** |
| 18 |
* Registers the built-in file types (post, user, attachment, |
| 19 |
* term, comment, folder, bookmark). |
| 20 |
* |
| 21 |
* @since 0.9.0 |
| 22 |
*/ |
| 23 |
function desktop_mode_register_builtin_file_types() { |
| 24 |
$types = array( |
| 25 |
array( |
| 26 |
'type' => 'post', |
| 27 |
'label' => __( 'Post', 'desktop-mode' ), |
| 28 |
'class' => 'Desktop_Mode_Post_File', |
| 29 |
'sort' => 10, |
| 30 |
), |
| 31 |
array( |
| 32 |
'type' => 'attachment', |
| 33 |
'label' => __( 'Media', 'desktop-mode' ), |
| 34 |
'class' => 'Desktop_Mode_Attachment_File', |
| 35 |
'sort' => 20, |
| 36 |
), |
| 37 |
array( |
| 38 |
'type' => 'user', |
| 39 |
'label' => __( 'User', 'desktop-mode' ), |
| 40 |
'class' => 'Desktop_Mode_User_File', |
| 41 |
'sort' => 30, |
| 42 |
), |
| 43 |
array( |
| 44 |
'type' => 'term', |
| 45 |
'label' => __( 'Taxonomy term', 'desktop-mode' ), |
| 46 |
'class' => 'Desktop_Mode_Term_File', |
| 47 |
'sort' => 40, |
| 48 |
), |
| 49 |
array( |
| 50 |
'type' => 'comment', |
| 51 |
'label' => __( 'Comment', 'desktop-mode' ), |
| 52 |
'class' => 'Desktop_Mode_Comment_File', |
| 53 |
'sort' => 50, |
| 54 |
), |
| 55 |
array( |
| 56 |
'type' => 'bookmark', |
| 57 |
'label' => __( 'Bookmark', 'desktop-mode' ), |
| 58 |
'class' => 'Desktop_Mode_Bookmark_File', |
| 59 |
'sort' => 60, |
| 60 |
), |
| 61 |
array( |
| 62 |
'type' => 'folder', |
| 63 |
'label' => __( 'Folder', 'desktop-mode' ), |
| 64 |
'class' => 'Desktop_Mode_Folder_File', |
| 65 |
'sort' => 5, |
| 66 |
), |
| 67 |
array( |
| 68 |
'type' => 'shortcut', |
| 69 |
'label' => __( 'Plugin shortcut', 'desktop-mode' ), |
| 70 |
'class' => 'Desktop_Mode_Shortcut_File', |
| 71 |
'sort' => 1, |
| 72 |
), |
| 73 |
array( |
| 74 |
'type' => 'link', |
| 75 |
'label' => __( 'Web link', 'desktop-mode' ), |
| 76 |
'class' => 'Desktop_Mode_Link_File', |
| 77 |
'sort' => 70, |
| 78 |
), |
| 79 |
array( |
| 80 |
'type' => 'embed', |
| 81 |
'label' => __( 'Embedded web window', 'desktop-mode' ), |
| 82 |
'class' => 'Desktop_Mode_Embed_File', |
| 83 |
'sort' => 80, |
| 84 |
), |
| 85 |
); |
| 86 |
|
| 87 |
foreach ( $types as $args ) { |
| 88 |
desktop_mode_register_file_type( $args['type'], array( |
| 89 |
'label' => $args['label'], |
| 90 |
'class' => $args['class'], |
| 91 |
'sort' => $args['sort'], |
| 92 |
) ); |
| 93 |
} |
| 94 |
} |
| 95 |
add_action( 'init', 'desktop_mode_register_builtin_file_types', 5 ); |
| 96 |
|