WordPress core files and functions

WprdPress Codex

WprdPress Codex

WordPress core are primarily PHP files, also includes CSS, javascript, image and HTML files. You can explore the source code to know how WordPress works. These files control everything about WordPress. Primarily these functions are about following parts of wordpress

  • Posts, Pages and Custom content. It involves functions for creating, storing, retrieving and interacting with your content
  • Post types, metadata, and taxonomies. Functions related to cross linking of posts with tags and taxonomies and custom post types and metadata about posts
  • Themes – Supporting functions about themes.
  • Actions, filters and plugins. These functions allow extending functionality of WordPress site.
  • Users and Authors, Creating and managing access control and managing security of the website
  • Feeds, formatting and comments. Everything about feeds and managing comments

Exploring the Core

Most of the core functions are defined in files stored in /wp-includes directory of WordPress. Let me try to examine some of the core files and core functions

functions.php

It contains most commonly used WordPress functions needed.  For example date functions, integer functions etc.

current_time() returns current time and absint() returns absolute value of integer.

Options.php

This file contains functions related to setting optional values into WordPress

add_option(), update_option(), get_option(), delete_option() – These are the functions to create, save and retrieve, delete saved options.

set_transient() , get_transient() , delete_transient() —Functions to create, retrieve, and delete transients in WordPress. A transient t is an option with an expiration time. When the expiration time is hit, the transient is automatically deleted in WordPress.

Formatting.php

Functions in this file format the output in many different ways.  esc_attr(), esc_html(), esc_js(), esc_url() etc functions escape html attributes, html blocks, javascript or url in the output.

Pluggable.php

WordPress lets you override certain core functions at plugins. If no plugins defines these functions WordPress loads these functions. wp_mail(), wp_rand(), wp_get_userdata() are some of the functions that gets loaded if no pluggins define them.

Plugin.php

The plugin.php function contains WordPress Plugin API functions.

add_filter() —Hooks that the WordPress core launches to fi lter content before displaying on the screen or saving in the database.
add_action() —Hooks that the WordPress core launches at specifi c points of execution.
register_activation_hook() —Hook called when a plugin is activated.
register_deactivation_hook() —Hook called when a plugin is deactivated.
plugin_dir_url() —Returns the fi lesystem directory path for the plugin.
plugin_dir_path() —Returns the URL for the plugin.
doing_filter() and doing_action() —Returns the name of the current fi lter or action being processed.

User.php

This file contains WordPress user API functions. It includes functions such as get_users(), add_user_meta(), get_user_meta(), update_user_meta(), delete_user_meta(), wp_insert_user(), wp_update_user(), which provide functionality on user addition, deletion and meta descriptions about users.

Post.php

The file post.php contains the functions used in the post process of WordPress.

wp_insert_post() —Creates a new post
get_post() —Retrieves a single post with all post data
get_posts() —Retrieves a list of the latest posts’ matching criteria
add_post_meta() —Creates metadata (custom fi eld data) on a post
get_post_meta() —Retrieves metadata (custom fi eld data) on a post
get_post_custom() —Returns a multidimensional array with all metadata (custom fi eld) entries for a post
set_post_thumbnail() —Sets a featured image on a post
register_post_type() —Registers a custom post type in WordPress

Taxonomy.php

The taxonomy.php file contains functions needed to manage hierarchical metadat such as categories and tags.

register_taxonomy() —Register a custom taxonomy in WordPress
get_taxonomies() —Return a list of registered taxonomies
wp_insert_term() , wp_update_term() —Insert or update a taxonomy term based on arguments provided

Other important core files

  • admin-bar.php – This code handles the building and rendering of the press bar
  • atomlib.php – Atom Syndication Format PHP Library
  • author-template.php – Author Template functions for use in themes.
  • bookmark-template.php = Bookmark Template Functions for usage in Themes
  • bookmark.php – Link/Bookmark API
  • cache.php – Object Cache API
  • canonical.php – Canonical API to handle WordPress Redirecting
  • capabilities.php – WordPress Roles and Capabilities.
  • categpru=template.php – Category Template Tags and API.
  • category.php – WordPress Category API
  • comment-template.php – Comment template functions. hese functions are meant to live inside of the WordPress loop.
  • comment.php – Manages WordPress comments
  • compat.php – WordPress implementation for PHP functions either missing from older PHP versions or not included by default.
  • cron.php – WordPress cron API
  • date.php – Class for generating SQL clauses that filter a primary query according to date.
  • default-constants.php – Defines constants and global variables that can be overridden, generally in wp-config.php.
  • default-filters.php – Sets up the default filters and actions for most of the WordPress hooks.
  • default-widgets.php – Default Widgets
  • deprecated.php – Deprecated functions from past WordPress versions. You shouldn’t use these functions and look for the alternatives instead. The functions will be removed in a later version.
  • feed-atom-comments.php – Atom Feed Template for displaying Atom Comments feed
  • feed-atom.php – Atom Feed Template for displaying Atom Posts feed.
  • feed-rdf.php – RSS 1 RDF Feed Template for displaying RSS 1 Posts feed.
  • feed-rss.php – RSS 0.92 Feed Template for displaying RSS 0.92 Posts feed.
  • feed-rss2-comments.php – RSS2 Feed Template for displaying RSS2 Comments feed.
  • feed-rss2.php – RSS2 Feed Template for displaying RSS2 Posts feed.
  • feed.php – WordPress feed API
  • formatting.php – Main WordPress Formatting API.
  • functions.php – Main functions API
  • functions-wp-scripts.php – BackPress Scripts Procedural API
  • functions-wp-styles.php – BackPress Styles Procedural API
  • general-template.php  – General template tags that can go anywhere in a template.
  • http.php – Simple and uniform HTTP request API.
  • i10n.php – WordPress Translation API
  • link-template.php – WordPress Link Template Functions
  • load.php – These functions are needed to load WordPress.
  • locale.php – Date and Time Locale object
  • media-template.php – WordPress media templates.
  • media.php – WordPress API for media display.
  • meta.php – Metadata API
  • ms-blogs.php – Site/blog functions that work with the blogs table and related data.
  • ms-default-constants.php – Defines constants and global variables that can be overridden, generally in wp-config.php.
  • ms-default-filters.php – Sets up the default filters and actions for Multisite.
  • ms-deprecated.php – Deprecated functions from WordPress MU and the multisite feature. You shouldn’t use these functions and look for the alternatives instead. The functions will be removed in a later version.
  • ms-files.php = Multisite upload handler
  • ms-functions.php – Multisite WordPress API
  • ms-load.php – These functions are needed to load Multisite.
  • ms-settings.php – Used to set up and fix common variables and include the Multisite procedural and class library.
  • nav-menu-template.php – Navigation Menu template functions
  • nav-menu.php – Navigation Menu functions
  • option.php – WordPress option API
  • pluggable-deprecated.php – Deprecated pluggable functions from past WordPress versions.
  • pluggable.php – These functions can be replaced via plugins. If plugins do not redefine these functions, then these will be used instead.
  • plugin.php – The plugin API is located in this file, which allows for creating actions and filters and hooking functions, and methods. The functions or methods will then be run when the action or filter is called.
  • post-formats.php – Post format functions.
  • post-template.php – WordPress Post Template Functions.
  • post-thumbnail-template.php – WordPress Post Thumbnail Template Functions.
  • post.php – Post functions and post utility function.
  • query.php – WordPress Query API
  • revision.php – Post revision functions.
  • rewrite.php – WordPress Rewrite API
  • rss.php – MagpieRSS: a simple RSS integration tool
  • script-loader.php – WordPress scripts and styles default loader.
  • session.php – Abstract class for managing user session tokens.
  • shortcodes.php – WordPress API for creating bbcode like tags or what WordPress calls “shortcodes.” The tag and attribute parsing or regular expression code is  based on the Textpattern tag parser.
  • taxonomy.php – Taxonomy API
  • template-loader.php – Loads the correct template based on the visitor’s url
  • template.php – Template loading functions.
  • theme.php – Theme, template, and stylesheet functions.
  • update.php – A simple set of functions to check our version 1.0 update service.
  • user.php – WordPress User API
  • vars.php – Creates common globals for the rest of WordPress
  • widgets.php – API for creating dynamic sidebar without hardcoding functionality into themes. Includes both internal WordPress routines and theme use routines.
  • wp-db.php – WordPress DB Class
  • wp-diff.php – WordPress Diff bastard child of old MediaWiki Diff Formatter.

To know about any function open up the corresponding file and view the source code. Each function have an inline documentation explaining how to utilise the function correctly. Take time to explore the files inside /wp-includes directory.

Leave a Reply