=')) {
add_action('admin_head-edit.php', array($this, 'admin_add_help'));
add_action('admin_head-post.php', array($this, 'admin_add_help'));
add_action('admin_head-post-new.php', array($this, 'admin_add_help'));
}
parent::init();
}
function enable_custom_menu_order($menu_ord) {
return true;
}
function custom_menu_order( $menu_ord ) {
$types_index = array_search('wpcf', $menu_ord);
$views_index = array_search('edit.php?post_type=view', $menu_ord);
if ($types_index !== false && $views_index !== false) {
// put the types menu above the views menu.
unset($menu_ord[$types_index]);
$menu_ord = array_values($menu_ord);
array_splice($menu_ord, $views_index, 0, 'wpcf');
}
return $menu_ord;
}
function is_embedded() {
return false;
}
function wpv_register_type_view()
{
$labels = array(
'name' => _x('Views', 'post type general name'),
'singular_name' => _x('View', 'post type singular name'),
'add_new' => _x('Add New View', 'book'),
'add_new_item' => __('Add New View', 'wpv-views'),
'edit_item' => __('Edit View', 'wpv-views'),
'new_item' => __('New View', 'wpv-views'),
'view_item' => __('View Views', 'wpv-views'),
'search_items' => __('Search Views', 'wpv-views'),
'not_found' => __('No views found', 'wpv-views'),
'not_found_in_trash' => __('No views found in Trash', 'wpv-views'),
'parent_item_colon' => '',
'menu_name' => 'Views'
);
$args = array(
'labels' => $labels,
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_menu' => false,
'query_var' => false,
'rewrite' => false,
'capability_type' => 'post',
'can_export' => false,
'has_archive' => false,
'hierarchical' => false,
//'menu_position' => 80,
'menu_icon' => WPV_URL .'/res/img/views-18.png',
'supports' => array('title','editor','author')
);
register_post_type('view',$args);
}
function admin_menu(){
add_utility_page(__('Views', 'wpv-views'), __('Views', 'wpv-views'), 'manage_options', 'edit.php?post_type=view', '', WPV_URL .'/res/img/views-18.png');
// remove the default menus and then add a Help menu
remove_submenu_page('edit.php?post_type=view', 'edit.php?post_type=view');
remove_submenu_page('edit.php?post_type=view', 'post-new.php?post_type=view');
// Add the default menus after the Help menu
add_submenu_page('edit.php?post_type=view', __('Views', 'wpv-views'), __('Views', 'wpv-views'), 'manage_options', 'edit.php?post_type=view');
add_submenu_page('edit.php?post_type=view', __('New View', 'wpv-views'), __('New View', 'wpv-views'), 'manage_options', 'post-new.php?post_type=view');
// Add the view template menus.
add_submenu_page('edit.php?post_type=view', __('View Templates', 'wpv-views'), __('View Templates', 'wpv-views'), 'manage_options', 'edit.php?post_type=view-template');
add_submenu_page('edit.php?post_type=view', __('New View Template', 'wpv-views'), __('New View Template', 'wpv-views'), 'manage_options', 'post-new.php?post_type=view-template');
// add settings menu.
add_submenu_page('edit.php?post_type=view', __('Settings', 'wpv-views'), __('Settings', 'wpv-views'), 'manage_options', 'views-settings',
array($this, 'views_settings_admin'));
// Add import export menu.
if (function_exists('wpv_admin_menu_import_export')) {
add_submenu_page('edit.php?post_type=view', __('Import/Export', 'wpv-views'), __('Import/Export', 'wpv-views'), 'manage_options', 'views-import-export',
'wpv_admin_menu_import_export');
}
add_submenu_page('edit.php?post_type=view', __('Views Subscription','wp-wiews'), __('Views Subscription','wp-wiews'), 'manage_options', WPV_FOLDER . '/menu/main.php', null, WPV_URL . '/res/img/icon16.png');
add_submenu_page('edit.php?post_type=view', __('Help', 'wpv-views'), __('Help', 'wpv-views'), 'manage_options', WPV_FOLDER . '/menu/help.php', null, WPV_URL . '/res/img/icon16.png');
}
function settings_box_load(){
add_meta_box('wpv_settings', '
' . __('View Query - Choose what content to load', 'wpv-views'), array($this, 'settings_box'), 'view', 'normal', 'high');
add_meta_box('wpv_layout', '
' . __('View Layout - Edit the layout', 'wpv-views'), 'view_layout_box', 'view', 'normal', 'high');
add_meta_box('wpv_views_help', '
' . __('Views Help', 'wpv-views'), array($this, 'view_help_box'), 'view', 'side', 'high');
//add_meta_box('wpv_css', '
' . __('CSS for view', 'wpv-views'), array($this, 'css_box'), 'view', 'normal', 'high');
global $pagenow;
if ($pagenow == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'view') {
$this->include_admin_css();
}
if ($pagenow == 'options-general.php' && isset($_GET['page']) && $_GET['page'] == WPV_FOLDER . '/menu/main.php') {
$this->include_admin_css();
}
if ($pagenow == 'options-general.php' && isset($_GET['page']) && $_GET['page'] == 'wpv-import-theme') {
$this->include_admin_css();
}
}
function hide_view_body_controls() {
global $pagenow, $post;
if (($pagenow == 'post-new.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'view') ||
($pagenow == 'post.php' && isset($_GET['action']) && $_GET['action'] == 'edit')) {
$post_type = $post->post_type;
if($pagenow == 'post.php' && $post_type != 'view') {
return;
}
// hide the post body.
?>
'.__("Create View Templates and attach them to content types to display content in complex ways. You can read more detail about View Templates on our website:",'wpv-views');
$help .= '
http://wp-types.com/user-guides/view-templates/ »
'.__("On this page you have the following options:", 'wpv-views').'
'; $help .= ''.__("Hover over the name of your View Template to get additional options:", 'wpv-views').'
'; $help .= ''.sprintf(__("If you need additional help with View Templates you can visit our support forum ».", 'wpv-views'), WPV_SUPPORT_LINK).'
'; break; case 'view-template': $help = ''.__("Use this page to create and edit View Templates. For more information about View Templates visit the user guide on our website:", 'wpv-views');
$help .= '
http://wp-types.com/user-guides/view-templates/ »
'.__("To Create a View Template", 'wpv-views').'
'; $help .= ''.sprintf(__("If you need additional help with View Templates you can visit our support forum ».", 'wpv-views'), WPV_SUPPORT_LINK).'
'; break; case 'edit-view': $help = ''.__("Use Views to filter and display lists in complex and interesting ways. Read more about Views in our user guide:",'wpv-views');
$help .= '
http://wp-types.com/user-guides/views/ »
'.__("This page gives you an overview of the Views you have created.", 'wpv-views').'
'; $help .= ''.__("It has the following options:", 'wpv-views').'
'; $help .= ''.__("If you hover over a View's name you also have these options:", 'wpv-views').'
'; $help .= ''.sprintf(__("If you need additional help with View Templates you can visit our support forum ».", 'wpv-views'), WPV_SUPPORT_LINK).'
'; break; case 'view': $help = ''.__("Use this page to create and edit your Views. You can read more about creating Views in our user guide:",'wpv-views');
$help .= '
http://wp-types.com/user-guides/views/ »
'.__("To Create a View:", 'wpv-views').'
'; $help .= ''.sprintf(__("If you need additional help with View Templates you can visit our support forum ».", 'wpv-views'), WPV_SUPPORT_LINK).'
'; break; } if ($help != '') { return $help; } else { return $contextual_help; } } // Add WPML sync options. function language_options() { global $sitepress, $post; if ($post->post_type == 'view') { list($translation, $source_id, $translated_id) = $sitepress->icl_get_metabox_states(); echo '