vc-pointers-frontend-editor.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. die( '-1' );
  4. }
  5. /**
  6. * Add WP ui pointers to backend editor.
  7. */
  8. function vc_frontend_editor_pointer() {
  9. vc_is_frontend_editor() && add_filter( 'vc-ui-pointers', 'vc_frontend_editor_register_pointer' );
  10. }
  11. add_action( 'admin_init', 'vc_frontend_editor_pointer' );
  12. /**
  13. * @param $pointers
  14. * @return mixed
  15. */
  16. function vc_frontend_editor_register_pointer( $pointers ) {
  17. global $post;
  18. if ( is_object( $post ) && ! strlen( $post->post_content ) ) {
  19. $pointers['vc_pointers_frontend_editor'] = array(
  20. 'name' => 'vcPointerController',
  21. 'messages' => array(
  22. array(
  23. 'target' => '#vc_add-new-element',
  24. 'options' => array(
  25. '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' ) ),
  26. 'position' => array(
  27. 'edge' => 'top',
  28. 'align' => 'left',
  29. ),
  30. 'buttonsEvent' => 'vcPointersEditorsTourEvents',
  31. ),
  32. 'closeEvent' => 'shortcodes:add',
  33. ),
  34. array(
  35. 'target' => '.vc_controls-out-tl:first',
  36. 'options' => array(
  37. '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' ) ),
  38. 'position' => array(
  39. 'edge' => 'left',
  40. 'align' => 'center',
  41. ),
  42. 'buttonsEvent' => 'vcPointersEditorsTourEvents',
  43. ),
  44. 'closeCallback' => 'vcPointersCloseInIFrame',
  45. 'showCallback' => 'vcPointersSetInIFrame',
  46. ),
  47. array(
  48. 'target' => '.vc_controls-cc:first',
  49. 'options' => array(
  50. '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>' ) ),
  51. 'position' => array(
  52. 'edge' => 'left',
  53. 'align' => 'center',
  54. ),
  55. 'buttonsEvent' => 'vcPointersEditorsTourEvents',
  56. ),
  57. 'closeCallback' => 'vcPointersCloseInIFrame',
  58. 'showCallback' => 'vcPointersSetInIFrame',
  59. ),
  60. ),
  61. );
  62. }
  63. return $pointers;
  64. }
  65. function vc_page_editable_enqueue_pointer_scripts() {
  66. if ( vc_is_page_editable() ) {
  67. wp_enqueue_style( 'wp-pointer' );
  68. wp_enqueue_script( 'wp-pointer' );
  69. }
  70. }
  71. add_action( 'wp_enqueue_scripts', 'vc_page_editable_enqueue_pointer_scripts' );