vc-pointers-backend-editor.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. die( '-1' );
  4. }
  5. /**
  6. * Add WP ui pointers to backend editor.
  7. */
  8. function vc_add_admin_pointer() {
  9. if ( is_admin() ) {
  10. foreach ( vc_editor_post_types() as $post_type ) {
  11. add_filter( 'vc_ui-pointers-' . $post_type, 'vc_backend_editor_register_pointer' );
  12. }
  13. }
  14. }
  15. add_action( 'admin_init', 'vc_add_admin_pointer' );
  16. /**
  17. * @param $pointers
  18. * @return mixed
  19. */
  20. function vc_backend_editor_register_pointer( $pointers ) {
  21. $screen = get_current_screen();
  22. $block = false;
  23. if ( method_exists( $screen, 'is_block_editor' ) ) {
  24. if ( $screen->is_block_editor() ) {
  25. $block = true;
  26. }
  27. }
  28. if ( ! $block || 'add' === $screen->action ) {
  29. $pointers['vc_pointers_backend_editor'] = array(
  30. 'name' => 'vcPointerController',
  31. 'messages' => array(
  32. array(
  33. 'target' => '.composer-switch',
  34. 'options' => array(
  35. 'content' => sprintf( '<h3> %s </h3> <p> %s </p>', esc_html__( 'Welcome to WPBakery Page Builder', 'js_composer' ), esc_html__( 'Choose Backend or Frontend editor.', 'js_composer' ) ),
  36. 'position' => array(
  37. 'edge' => 'left',
  38. 'align' => 'center',
  39. ),
  40. 'buttonsEvent' => 'vcPointersEditorsTourEvents',
  41. ),
  42. ),
  43. array(
  44. 'target' => '#vc_templates-editor-button, #vc-templatera-editor-button',
  45. 'options' => array(
  46. 'content' => sprintf( '<h3> %s </h3> <p> %s </p>', esc_html__( 'Add Elements', 'js_composer' ), esc_html__( 'Add new element or start with a template.', 'js_composer' ) ),
  47. 'position' => array(
  48. 'edge' => 'left',
  49. 'align' => 'center',
  50. ),
  51. 'buttonsEvent' => 'vcPointersEditorsTourEvents',
  52. ),
  53. 'closeEvent' => 'shortcodes:vc_row:add',
  54. 'showEvent' => 'backendEditor.show',
  55. ),
  56. array(
  57. 'target' => '[data-vc-control="add"]:first',
  58. 'options' => array(
  59. 'content' => sprintf( '<h3> %s </h3> <p> %s </p>', esc_html__( 'Rows and Columns', 'js_composer' ), esc_html__( 'This is a row container. Divide it into columns and style it. You can add elements into columns.', 'js_composer' ) ),
  60. 'position' => array(
  61. 'edge' => 'left',
  62. 'align' => 'center',
  63. ),
  64. 'buttonsEvent' => 'vcPointersEditorsTourEvents',
  65. ),
  66. 'closeEvent' => 'click #wpb_visual_composer',
  67. 'showEvent' => 'shortcodeView:ready',
  68. ),
  69. array(
  70. 'target' => '.wpb_column_container:first .wpb_content_element:first .vc_controls-cc',
  71. 'options' => array(
  72. 'content' => sprintf( '<h3> %s </h3> <p> %s <br/><br/> %s</p>', esc_html__( 'Control Elements', 'js_composer' ), esc_html__( 'You can edit your element at any time and drag it around your layout.', 'js_composer' ), sprintf( esc_html__( 'P.S. Learn more at our %sKnowledge Base%s.', 'js_composer' ), '<a href="https://kb.wpbakery.com" target="_blank">', '</a>' ) ),
  73. 'position' => array(
  74. 'edge' => 'left',
  75. 'align' => 'center',
  76. ),
  77. 'buttonsEvent' => 'vcPointersEditorsTourEvents',
  78. ),
  79. 'showCallback' => 'vcPointersShowOnContentElementControls',
  80. 'closeEvent' => 'click #wpb_visual_composer',
  81. ),
  82. ),
  83. );
  84. }
  85. return $pointers;
  86. }