pages.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. die( '-1' );
  4. }
  5. /**
  6. * @since 4.5
  7. */
  8. function vc_page_css_enqueue() {
  9. wp_enqueue_style( 'vc_page-css', vc_asset_url( 'css/js_composer_settings.min.css' ), array(), WPB_VC_VERSION );
  10. }
  11. /**
  12. * Build group page objects.
  13. *
  14. * @param $slug
  15. * @param $title
  16. * @param $tab
  17. *
  18. * @return Vc_Pages_Group
  19. * @since 4.5
  20. *
  21. */
  22. function vc_pages_group_build( $slug, $title, $tab = '' ) {
  23. $vc_page_welcome_tabs = vc_get_page_welcome_tabs();
  24. require_once vc_path_dir( 'CORE_DIR', 'class-vc-page.php' );
  25. require_once vc_path_dir( 'CORE_DIR', 'class-vc-pages-group.php' );
  26. // Create page.
  27. if ( ! strlen( $tab ) ) {
  28. $tab = $slug;
  29. }
  30. $page = new Vc_Page();
  31. $page->setSlug( $tab )->setTitle( $title )->setTemplatePath( 'pages/' . $slug . '/' . $tab . '.php' );
  32. // Create page group to stick with other in template.
  33. $pages_group = new Vc_Pages_Group();
  34. $pages_group->setSlug( $slug )->setPages( $vc_page_welcome_tabs )->setActivePage( $page )->setTemplatePath( 'pages/vc-welcome/index.php' );
  35. return $pages_group;
  36. }
  37. /**
  38. * @since 4.5
  39. */
  40. function vc_menu_page_build() {
  41. if ( vc_user_access()->wpAny( 'manage_options' )->part( 'settings' )->can( 'vc-general-tab' )->get() ) {
  42. define( 'VC_PAGE_MAIN_SLUG', 'vc-general' );
  43. } else {
  44. define( 'VC_PAGE_MAIN_SLUG', 'vc-welcome' );
  45. }
  46. add_menu_page( esc_html__( 'WPBakery Page Builder', 'js_composer' ), esc_html__( 'WPBakery Page Builder', 'js_composer' ), 'edit_posts', VC_PAGE_MAIN_SLUG, null, vc_asset_url( 'vc/logo/wpb-logo-white_32.svg' ), 76 );
  47. do_action( 'vc_menu_page_build' );
  48. }
  49. function vc_network_menu_page_build() {
  50. if ( ! vc_is_network_plugin() ) {
  51. return;
  52. }
  53. if ( vc_user_access()->wpAny( 'manage_options' )->part( 'settings' )->can( 'vc-general-tab' )->get() && ! is_main_site() ) {
  54. define( 'VC_PAGE_MAIN_SLUG', 'vc-general' );
  55. } else {
  56. define( 'VC_PAGE_MAIN_SLUG', 'vc-welcome' );
  57. }
  58. add_menu_page( esc_html__( 'WPBakery Page Builder', 'js_composer' ), esc_html__( 'WPBakery Page Builder', 'js_composer' ), 'exist', VC_PAGE_MAIN_SLUG, null, vc_asset_url( 'vc/logo/wpb-logo-white_32.svg' ), 76 );
  59. do_action( 'vc_network_menu_page_build' );
  60. }
  61. add_action( 'admin_menu', 'vc_menu_page_build' );
  62. add_action( 'network_admin_menu', 'vc_network_menu_page_build' );