<?php

add_action("init", function () {
  // get default post type object
  $slug = "blog";
  $post_type_object = get_post_type_object("post");

  // use slug from settings
  if ($page_for_posts = get_option("page_for_posts")) {
    if ($page = get_post($page_for_posts)) {
      $slug = $page->post_name;
    }
  }

  // redefine object
  $post_type_object->has_archive = true;
  $post_type_object->rewrite = [
    "slug" => apply_filters("inoby_post_type_post_rewrite_slug", __($slug, "inoby")), // after changing this in child theme, go to <your-site>/wp-admin/options-permalink.php and re-save permalinks
  ];
  $post_type_object->labels = apply_filters("inoby_post_type_post_labels", (array) $post_type_object->labels);

  // register post
  register_post_type("post", apply_filters("inoby_post_type_post_register", $post_type_object));
});
