• defined( 'ABSPATH' ) || exit; contains the absolute path to the WordPress root directory. If php run directly, it exits.

$this

  • Refers to the current object instance
  • Used for non-static properties and methods
  • Only available inside object context

self::

  • Refers to the class itself
  • Used for static properties and methods
  • Does NOT require an object

  • add_action( 'init', array( $post_types, 'register_post_types' ) ) is a callable reference that means:

When the init hook fires, call $post_types->register_post_types()

  • load_plugin_textdomain() is a WordPress function that tells WordPress:

Here’s the folder and text domain for my plugin translations — load them now.”

  • It basically activates your plugin’s translations so all __() and _e() strings can be displayed in the user’s language.

dirname( plugin_basename( __FILE__ ) ) . '/languages' → relative path to translations

Let’s break it down:

  1. __FILE__ → full path of the current PHP file
    Example: /var/www/html/wp-content/plugins/rt-movie-db/rt-movie-db.php

  2. plugin_basename(__FILE__) → plugin folder + main file relative to /wp-content/plugins/ rt-movie-db/rt-movie-db.php

  3. dirname(...) → just the folder name rt-movie-db

  4. dirname(...) . '/languages' → folder where .mo files live rt-movie-db/languages


Translation

Code:

echo __( 'Watch Movie', 'rt-movie-db' );
echo _x( 'Movies', 'post type general name', 'rt-movie-db' );

.po file snippet (French):

msgid "Watch Movie"
msgstr "Regarder le film"

msgctxt "post type general name"
msgid "Movies"
msgstr "Films"

WordPress will output:

Regarder le film
Films

  • COmmon labels
KeyPurpose
nameGeneral plural name for the taxonomy
singular_nameSingular name
search_itemsText for search box in admin
all_itemsLabel for “All terms” view
parent_itemLabel for parent term (hierarchical only)
edit_itemLabel when editing a term
add_new_itemLabel when adding a new term
new_item_nameLabel for “New term name”
menu_nameLabel shown in the admin menu
  • Common args:
KeyPurpose
hierarchicaltrue = like categories, false = like tags
labelsthe $labels array
show_uishow admin UI for taxonomy
show_admin_columnshow column in post list table
query_varenable URL query variable for taxonomy
rewritearray for URL slugs
show_in_restenable Gutenberg / REST API support
publicwhether taxonomy is publicly queryable
capabilitiespermissions for editing terms
update_count_callbackfunction to update term counts (for non-hierarchical)