Definition:
function favorite_actions( $screen = null ) {}
Parameters
- $screen
Defined filters
- favorite_actions
apply_filters( 'favorite_actions', $actions, $screen )
Source code
function favorite_actions( $screen = null ) { $default_action = false; if ( is_string($screen) ) $screen = convert_to_screen($screen); if ( $screen->is_user ) return; if ( isset($screen->post_type) ) { $post_type_object = get_post_type_object($screen->post_type); if ( 'add' != $screen->action ) $default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->cap->edit_posts)); else $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts)); } if ( !$default_action ) { if ( $screen->is_network ) { $default_action = array('sites.php' => array( __('Sites'), 'manage_sites')); } else { switch ( $screen->id ) { case 'upload': $default_action = array('media-new.php' => array(__('New Media'), 'upload_files')); break; case 'media': $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files')); break; case 'link-manager': case 'link': if ( 'add' != $screen->action ) $default_action = array('link-add.php' => array(__('New Link'), 'manage_links')); else $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links')); break; case 'users': $default_action = array('user-new.php' => array(__('New User'), 'create_users')); break; case 'user': $default_action = array('users.php' => array(__('Edit Users'), 'edit_users')); break; case 'plugins': $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins')); break; case 'plugin-install': $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins')); break; case 'themes': $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes')); break; case 'theme-install': $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes')); break; default: $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts')); break; } } } if ( !$screen->is_network ) { $actions = array( 'post-new.php' => array(__('New Post'), 'edit_posts'), 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'), 'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'), 'media-new.php' => array(__('Upload'), 'upload_files'), 'edit-comments.php' => array(__('Comments'), 'moderate_comments') ); } else { $actions = array( 'sites.php' => array( __('Sites'), 'manage_sites'), 'users.php' => array( __('Users'), 'manage_network_users') ); } $default_key = array_keys($default_action); $default_key = $default_key[0]; if ( isset($actions[$default_key]) ) unset($actions[$default_key]); $actions = array_merge($default_action, $actions); $actions = apply_filters( 'favorite_actions', $actions, $screen ); $allowed_actions = array(); foreach ( $actions as $action => $data ) { if ( current_user_can($data[1]) ) $allowed_actions[$action] = $data[0]; } if ( empty($allowed_actions) ) return; $first = array_keys($allowed_actions); $first = $first[0]; echo '<div id="favorite-actions">'; echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>'; echo '<div id="favorite-inside">'; array_shift($allowed_actions); foreach ( $allowed_actions as $action => $label) { echo "<div class='favorite-action'><a href='$action'>"; echo $label; echo "</a></div>\n"; } echo "</div></div>\n"; }
1050
No comments yet... Be the first to leave a reply!