tsu_newsletter_block.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // Register Newsletter Custom Post Type
  3. require 'tsu_newsletter_custom_post.php';
  4. // Create Endpoint for Ajax Request with email data from Newsletter
  5. require 'tsu_newsletter_create_api_endpoint.php';
  6. // i18n strings
  7. function lang_strings() {
  8. do_action('wpml_register_single_string', 'aiac', 'Wprowadź poprawny adres e-mail.', 'Wprowadź poprawny adres e-mail.', false, 'pl');
  9. do_action('wpml_register_single_string', 'aiac', 'Adres e-mail...', 'Adres e-mail...', false, 'pl');
  10. do_action('wpml_register_single_string', 'aiac', 'ZAPISUJĘ SIĘ', 'ZAPISUJĘ SIĘ', false, 'pl');
  11. do_action('wpml_register_single_string', 'aiac', 'Nie udało się nawiązać połączenia.', 'Nie udało się nawiązać połączenia.', false, 'pl');
  12. }
  13. add_action('init', 'lang_strings');
  14. // Register Custom Block Category
  15. add_filter( 'block_categories_all', function($categories) {
  16. // Set Category Slug
  17. $new_slug = 'tsu-category';
  18. // Set Category Title
  19. $new_title = 'To się uda';
  20. $has_category = false;
  21. foreach($categories as $category) {
  22. if($category === [ 'slug' => $new_slug, 'title' => $new_title]) {
  23. $has_category = true;
  24. }
  25. }
  26. if(!$has_category) {
  27. $categories[] = array(
  28. 'slug' => $new_slug,
  29. 'title' => $new_title
  30. );
  31. };
  32. return $categories;
  33. });
  34. // Register Newsletter Custom Block
  35. add_action( 'init', 'add_newsletter_block' );
  36. function add_newsletter_block() {
  37. register_block_type( __DIR__ . '/build' );
  38. }