hook-vc-iconpicker-param.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. die( '-1' );
  4. }
  5. /***
  6. * @since 4.4
  7. * Hook Vc-Iconpicker-Param.php
  8. *
  9. * Adds actions and filters for iconpicker param.
  10. * Used to:
  11. * - register/enqueue icons fonts for admin pages
  12. * - register/enqueue js for iconpicker param
  13. * - register/enqueue css for iconpicker param
  14. */
  15. // @see Vc_Base::frontCss, used to append actions when frontCss(frontend editor/and real view mode) method called
  16. // This action registers all styles(fonts) to be enqueue later
  17. add_action( 'vc_base_register_front_css', 'vc_iconpicker_base_register_css' );
  18. // @see Vc_Base::registerAdminCss, used to append action when registerAdminCss(backend editor) method called
  19. // This action registers all styles(fonts) to be enqueue later
  20. add_action( 'vc_base_register_admin_css', 'vc_iconpicker_base_register_css' );
  21. // @see Vc_Base::registerAdminJavascript, used to append action when registerAdminJavascript(backend/frontend editor) method called
  22. // This action will register needed js file, and also you can use it for localizing js.
  23. add_action( 'vc_base_register_admin_js', 'vc_iconpicker_base_register_js' );
  24. // @see Vc_Backend_Editor::printScriptsMessages (wp-content/plugins/js_composer/include/classes/editors/class-vc-backend-editor.php),
  25. // used to enqueue needed js/css files when backend editor is rendering
  26. add_action( 'vc_backend_editor_enqueue_js_css', 'vc_iconpicker_editor_jscss' );
  27. // @see Vc_Frontend_Editor::enqueueAdmin (wp-content/plugins/js_composer/include/classes/editors/class-vc-frontend-editor.php),
  28. // used to enqueue needed js/css files when frontend editor is rendering
  29. add_action( 'vc_frontend_editor_enqueue_js_css', 'vc_iconpicker_editor_jscss' );
  30. /**
  31. * This action registers all styles(fonts) to be enqueue later
  32. * @see filter 'vc_base_register_front_css' - preview/frontend-editor
  33. * filter 'vc_base_register_admin_css' - backend editor
  34. *
  35. * @since 4.4
  36. */
  37. function vc_iconpicker_base_register_css() {
  38. // Vc Icon picker fonts:
  39. wp_register_style( 'font-awesome', vc_asset_url( 'lib/bower/font-awesome/css/font-awesome.min.css' ), array(), WPB_VC_VERSION );
  40. wp_register_style( 'vc_typicons', vc_asset_url( 'css/lib/typicons/src/font/typicons.min.css' ), false, WPB_VC_VERSION );
  41. wp_register_style( 'vc_openiconic', vc_asset_url( 'css/lib/vc-open-iconic/vc_openiconic.min.css' ), false, WPB_VC_VERSION );
  42. wp_register_style( 'vc_linecons', vc_asset_url( 'css/lib/vc-linecons/vc_linecons_icons.min.css' ), false, WPB_VC_VERSION );
  43. wp_register_style( 'vc_entypo', vc_asset_url( 'css/lib/vc-entypo/vc_entypo.min.css' ), false, WPB_VC_VERSION );
  44. wp_register_style( 'vc_monosocialiconsfont', vc_asset_url( 'css/lib/monosocialiconsfont/monosocialiconsfont.min.css' ), false, WPB_VC_VERSION );
  45. wp_register_style( 'vc_material', vc_asset_url( 'css/lib/vc-material/vc_material.min.css' ), false, WPB_VC_VERSION );
  46. // Theme
  47. wp_register_style( 'vc-icon-picker-main-css', vc_asset_url( 'lib/bower/vcIconPicker/css/jquery.fonticonpicker.min.css' ), false, WPB_VC_VERSION );
  48. wp_register_style( 'vc-icon-picker-main-css-theme', vc_asset_url( 'lib/bower/vcIconPicker/themes/grey-theme/jquery.fonticonpicker.vcgrey.min.css' ), false, WPB_VC_VERSION );
  49. }
  50. /**
  51. * Register admin js for iconpicker functionality
  52. *
  53. * @since 4.4
  54. */
  55. function vc_iconpicker_base_register_js() {
  56. wp_register_script( 'vc-icon-picker', vc_asset_url( 'lib/bower/vcIconPicker/jquery.fonticonpicker.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
  57. }
  58. /**
  59. * Enqueue ALL fonts/styles for Editor(admin) mode. (to allow easy change icons)
  60. * - To append your icons fonts add action:
  61. * vc_backend_editor_enqueue_jscss and vc_frontend_editor_enqueue_jscss
  62. *
  63. * @since 4.4
  64. */
  65. function vc_iconpicker_editor_jscss() {
  66. // Enqueue js and theme css files
  67. wp_enqueue_script( 'vc-icon-picker' );
  68. wp_enqueue_style( 'vc-icon-picker-main-css' );
  69. wp_enqueue_style( 'vc-icon-picker-main-css-theme' );
  70. // Fonts
  71. wp_enqueue_style( 'font-awesome' );
  72. wp_enqueue_style( 'vc_openiconic' );
  73. wp_enqueue_style( 'vc_typicons' );
  74. wp_enqueue_style( 'vc_entypo' );
  75. wp_enqueue_style( 'vc_linecons' );
  76. wp_enqueue_style( 'vc_monosocialiconsfont' );
  77. wp_enqueue_style( 'vc_material' );
  78. }