functions.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. function uhp24_styles() {
  3. wp_enqueue_style(
  4. 'uhp-style',
  5. get_stylesheet_uri(),
  6. [],
  7. wp_get_theme()->get( 'Version' )
  8. );
  9. }
  10. add_action( 'wp_enqueue_scripts', 'uhp24_styles' );
  11. /***********************************************************
  12. ######################## Editor ############################
  13. ************************************************************/
  14. add_action( 'enqueue_block_assets', 'uhp24_block_styles', 5 );
  15. function uhp24_block_styles(){
  16. wp_enqueue_style('uhp24-css', get_stylesheet_directory_uri() . '/style.css');
  17. }
  18. add_filter( 'should_load_remote_block_patterns', 'uhp24_disable_remote_patterns' );
  19. function uhp24_disable_remote_patterns() {
  20. return false;
  21. }
  22. /***********************************************************
  23. ###################### BrowserSync #########################
  24. ************************************************************/
  25. function add_cors_http_header(){
  26. header('Access-Control-Allow-Origin: https://uhp.ovid:333');
  27. header('Access-Control-Allow-Credentials: true');
  28. header('Access-Control-Allow-Headers: X-WP-Nonce', false );
  29. }
  30. add_action('init','add_cors_http_header');
  31. function uhp24_browsersync_save() {
  32. $args = [
  33. 'blocking' => false,
  34. 'sslverify' => false
  35. ];
  36. $request = wp_remote_get('https://uhp.ovid:333/__browser_sync__?method=reload', $args);
  37. }
  38. add_action('rest_after_insert_page', 'uhp24_browsersync_save', 10, 3);
  39. add_action('rest_after_insert_post', 'uhp24_browsersync_save', 10, 3);
  40. add_action('save_post', 'uhp24_browsersync_save', 10, 3);
  41. add_action('customize_save_after', 'uhp24_browsersync_save', 10, 3);
  42. add_action('wp_update_nav_menu', 'uhp24_browsersync_save', 10, 3);
  43. add_action('updated_option', 'uhp24_browsersync_save', 10, 3);