Cheat Sheets Wordpress WordPress Developer Super Cheat Sheet There sure is a lot you need to remember when working with WordPress theme files. From the names of basic template files to functions and how the WordPress Loop works, it’s next to impossible to remember every PHP tag or even how to define a new theme. Theme Files These are the basic files that every theme should include: style.css  – This is your theme’s stylesheet file. index.php  – This is the main body template for your theme. Its job is to bring together all the information in the other theme files using template tags. header.php  – This file contains the header information that appears with the   section of your site, stuff like metadata and the link to your stylesheet. sidebar.php  – Everything in you sidebar goes in this file, like widgets, categories, additional menus, search form, etc. footer.php  – This file contains your footer information, such as copyright details, widgets, and social icons. single.php  – This file displays just one post. page.php  – When you create a page on your site, this is the template responsible. comments.php  – This file is responsible for displaying comments. 404.php  – When visitors try to visit a page on your site that doesn’t exist, this file will general an error page. functions.php  – This file is where you can place special functions. We always recommend creating a child theme rather than edit this file directly. archive.php  – Display an archive with this file so visitors to your site can go way back when and read your Hello World! post. search.php  – Help your visitors search your site with this page. searchform.php  – Display a search form for your visitors with this template file. Defining a New Theme Your stylesheet doesn’t just contain styling information for your theme – it also holds details about your theme that are displayed in the  Appearance > Themes  section of your WordPress admin. The following is an example of the first few lines of the stylesheet for the default Twenty Sixteen theme: /* Theme Name: Twenty Sixteen Theme URI: https://wordpress.org/themes/twentysixteen/ Author: the WordPress team Author URI: https://wordpress.org/ Description: Twenty Sixteen is a modernized take on an ever-popular WordPress layout — the horizontal masthead with an optional right sidebar that works perfectly for blogs and websites. It has custom color options with beautiful default color schemes, a harmonious fluid grid using a mobile-first approach, and impeccable polish in every detail. Twenty Sixteen will make your WordPress look beautiful everywhere. Version: 1.2 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Tags: black, blue, gray, red, white, yellow, dark, light, one-column, two-columns, right-sidebar, fixed-layout, responsive-layout, accessibility-ready, custom-background, custom-colors, custom-header, custom-menu, editor-style, featured-images, flexible-header, microformats, post-formats, rtl-language-support, sticky-post, threaded-comments, translation-ready Text Domain: twentysixteen This theme, like WordPress, is licensed under the GPL. Use it to make something cool, have fun, and share what you've learned with others. */ view raw twenty-sixteen-theme-definition  hosted with ❤ by  GitHub This information goes at the top of your  stylesheet.css  file. Template Include Tags Template include tags are used within one template file (for example index.php) to include (or call) the HTML and PHP found in another template file (for example header.php). While PHP has its own built-in include() statement to do this, these WordPress-specific tags make life much easier:  – Includes the header.php file  – Includes the sidebar.php file  – Includes the footer.php file  – Includes your comments Template Header/Bloginfo Tags These are functions you’ll find in your theme’s header.php file, though you’ll also find them in other theme files:  – The title of your site, or blog name  – Your site’s URL  – Link to your themes’s stylesheet file  – Location of your site’s theme file  – Displays the tagline of your blog as set in  Settings > General .  – Link to your site’s atom URL  – RSS feed URL for your site  – Pingback URL for your site  – WordPress version number  – The HTML version your site is using  – The root URL for your site  – Location of your stylesheet folder  – Title of a specific page Template Tags These tags can be used across all of your template files, such as index.php or page.php, making it easy to display specific information anywhere you want on your site:  – Displays the content of a post  – Displays the excerpt used in posts  – Title of the specific post  – Link of a specific post  – Category of a specific post  – Author of a specific post  – ID of a specific post  – Edit link for a post  – URL of the next page  – URL of the previous page  – Lists all links in blogroll  – Lists all pages  – List archive for the site  – Lists all categories  – Displays the built-in calendar  – Displays register link  – Displays login/logout link only to registered users The Loop The Loop is the default mechanism in WordPress for displaying all of your posts. Exactly how many posts are retrieved is determined by the number of posts you’ve chosen to display in the “Reading” settings in your WordPress dashboard. Within the Loop, WordPress loops through each post retrieved for the current page one at a time and formats it according to your theme’s instructions. You can use the Loop to do a lot of useful stuff, like: Display post titles and excerpts on your homepage; Display the content and comments on a single post; Display the content on an individual page using template tags; and Display data from custom post types and custom fields. view raw wordpress-loop  hosted with ❤ by  GitHub The Loop can display lots of different element for each post. Some of the most common template tags used in themes (according to the WordPress Theme Handbook) are: next_post_link()  – A link to the post published chronologically after the current post previous_post_link()  – A link to the post published chronologically before the current post the_category()  – The category or categories associated with the post or page being viewed the_author()  – The author of the post or page the_content()  – The main content for a post or page the_excerpt()  – The first 55 words of a post’s main content followed by an ellipsis (…) or read more link that goes to the full post. You may also use the “Excerpt” field of a post to customize the length of a particular excerpt. the_ID()  – The ID for the post or page the_meta()  – The custom fields associated with the post or page the_shortlink()  – A link to the page or post using the URL of the site and the ID of the post or page the_tags()  – The tag or tags associated with the post the_title()  – The title of the post or page the_time()  – The time or date for the post or page. This can be customized using standard php date function formatting. You can also use conditional tags, such as: is_home()  – Returns true if the current page is the homepage is_admin()  – Returns true if an administrator is logged in and visiting the site is_single()  – Returns true if the page is currently displaying a single post is_page()  – Returns true if the page is currently displaying a single page is_page_template()  – Can be used to determine if a page is using a specific template, for example:  is_page_template('about-page.php') is_category()  – Returns true if page or post has the specified category, for example  is_category('news') is_tag()  – Returns true if a page or post has the specified tag is_author()  – Returns true if a specific author is logged in and visiting the site is_search()  – Returns true if the current page is a search results page is_404()  – Returns true if the current page does not exist has_excerpt()  – Returns true if the post or page has an excerpt Wordpress Cheat sheet Theme Headers  style.css style.css Headers /** * Theme Name: My theme (required) * Template: The name of the parent theme. E.g. Twenty Seventeen * Description: A short description of the theme. * * Theme URI: Subject URL. E.g. http://wordpress.org/themes/twenty * Author: Kama * Author URI: https://wp-kama.com * * Tags: black, brown, orange * Text Domain: Subject translation domain. E.g. twentythirteen * * License: License. E.g. GNU General Public License v2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.html * * Version: 1.0 */ .htaccess code # BEGIN WordPress # The directives (lines) between "BEGIN WordPress" and "END WordPress" are # dynamically generated, and should only be modified via WordPress filters. # Any changes to the directives between these markers will be overwritten. RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress mod_rewrite_rules save_mod_rewrite_rules() insert_with_markers() WP_Rewrite::mod_rewrite_rules() Theme Files  (include) Theme files include functions header.php. file.php. Search form searchform.php. Comments form comments.php. sidebar.php. footer.php.   get_template_directory() The path to the parent theme (not child). No trailing /. get_stylesheet_directory() Theme Path (where parent/child style.css). No trailing /. get_parent_theme_file_path() File path of parent theme (not child). get_theme_file_path() File path of parent/child theme. load_template() Includes file (require_once). locate_template() Finds/Includes parent/child theme file.   get_template_directory_uri() URL of parent theme (not child). No trailing /. get_stylesheet_directory_uri() Theme URL (child theme if it exists). No trailing /. get_theme_root_uri() URL of the theme's DIR. No trailing /. get_stylesheet_uri() URL of the theme's style.css file. get_theme_file_uri() URL of the parent/child theme file. get_parent_theme_file_uri() URL of the parent theme file. Theme Files  (hierarchy)   /themes/THEME/ Theme Files Hierarchy style .css Theme styles file (required) index .php Any page without a template file (required) front-page .php Front (Home) page home .php Posts page (or Home page) functions .php A special file for php functions (code) 404 .php Page  "not found" comments .php Comments  Template (part) header .php Site Header  Template (part) searchform .php Search Form  Template (part) sidebar .php Sidebar  Template (part) footer .php Site Footer  Template (part) single .php Post page  post_type = post single-POST_TYPE .php Post page  post_type = POST_TYPE single-POST_TYPE-POST_NAME .php Post page with  POST_NAME and POST_TYPE singular .php Post of  any post type page .php Page  post_type = page page-POST_NAME .php Page  post_name = POST_NAME page-ID .php Page  ID = ID attachment .php Any  attachment  page image .php Image  attachment  page archive .php Page of  any archive archive-POST_TYPE .php Page of  post type archive search .php Search  page category .php Any  Category  page category-SLUG .php Category page with  slug = SLUG category-ID .php Category page with  term_id = id tag .php Any  Tag  page tag-SLUG .php Tag page with  slug = SLUG tag-ID .php Tag page with  term_id = id taxonomy .php Any  custom taxonomy element  page taxonomy-TAXONOMY .php Page of any term of TAXONOMY taxonomy taxonomy-TAXONOMY-SLUG .php Page of SLUG term of TAXONOMY taxonomy author .php Page of  Author posts A post template from any file: Site name. Short description of the site. Theme URL:  get_template_directory() . Same as template_url. Theme URL:  get_stylesheet_directory_uri() . Theme file style.css URL:  get_stylesheet_uri() . The site's encoding: UTF-8. Content-Type of the page: text/html. Site locale (language): RU. WordPress version: 5.5.3. URL of the feed: /feed. URL of the comments feed: /comments/feed. E-mail of Admin.   Notification URL to the xmlrpc.php file. RDF/RSS 1.0 feed URL (/feed/rfd). RSS 0.92 feed URL (/feed/rss). Atom feed URL (/feed/atom). Home page URL. Alias  home_url() . Admin panel URL. Alias  site_url() . Comment Loop comment_ID() Displays the ID of the current comment. comments_popup_link() Displays link to the comment popup. comment_text() Displays the text of the comment. comment_author() Displays the comment author name. comments_link() Displays a URL to the post comment form. comment_reply_link() Displays a link that allows you to reply to comments. comment_time() Displays the comment publishing time. comment_author_link() Displays the comment author's name as a link. comment_author_url() Displays comment author URL (sets when commenting). comment_author_url_link() Displays comment author link (A tag). comment_author_email_link() Displays comment author email as a mailto link. edit_comment_link() Displays edit comment link. The Loop The Loop 3 ways to Create Loop in WordPress in_the_loop() Checks if the WordPress loop is active. have_posts() Checks if there are posts for the loop. the_post() Sets the next post in the loop and global $post. setup_postdata() Sets global $post. the_ID() Displays the ID of the current post. the_title() Displays current post title. the_title_attribute() Displays post title for html tag attribute. the_content() Displays post content. the_excerpt() Displays the excerpt (quote) of the post, with [...] at the end. the_excerpt_rss() Displays the excerpt (quote) (for RSS). get_permalink() Gets post URL. the_permalink() Displays post URL. comments_number() Displays post's number of comments. edit_post_link() Displays edit post link (A html tag).   the_date() Displays/retrieves post publication date. get_the_date() Gets the post creation date. the_time() Displays post publication date. get_post_time() Gets time (date) of post publication. the_modified_date() Displays time (date) when post was changed.   the_post_thumbnail() Displays html code of post thumbnail image. get_post_thumbnail_id() Gets the post thumbnail ID. has_post_thumbnail() Whether or not the post has a thumbnail. Conditional tag. the_post_thumbnail_url() Displays the URL of the post thumbnail. the_attachment_link() Displays the link (A tag) of the attachment or the attachment page. get_attachment_link() Gets the URL to the attachment page. wp_get_attachment_link() Gets the link (A tag) of the attachment or the attachment page.   the_tags() Displays links to the post tags. the_category() Displays post categories as links. the_taxonomies() Displays links to the post terms. in_category() Checks if the post belongs to a category. sticky_class() Displays a "sticky" class if it is a sticky post. is_sticky() Checks if the post is sticky to the home page. the_meta() Displays post meta-fields in
  • list. get_post_format() Gets the post format: quote, status, video, audio.   the_author() Displays post's author name. get_the_author() Gets post's author name (display_name). the_author_link() Displays link (A tag) to the site of post's author. get_the_author_link() Gets link (A tag) to the site of post's author. the_author_posts() Displays the total number of posts written by the author. the_author_posts_link() Displays link (A tag) to the post author's archive page . the_author_meta() Displays specified meta-field of the post author (wp user). get_the_author_meta() Gets specified meta-field of the post author (wp user). the_modified_author() Displays the name of the author who last modified the post. No posts. No posts. No posts. 5, 'offset' => 1, 'category' => 1 ]); if( $myposts ){ foreach( $myposts as $post ){ setup_postdata( $post ); ?> 5, 'orderby' => 'comment_count', ] ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); ?> WP CLI Core : # Download WordPress wp core download --locale=ru_RU # Generate wp-config.php: wp core config --dbname=NAME --dbuser=USER --dbpass=PASS --dbprefix=wp_ # Create DB (based on wp-config.php) wp db create # Install WP to created DB wp core install --url=example.com --title=Example --admin_user=supervisor \ --admin_email=info@example.com --admin_password=strongpassword Post : # List posts: wp post list # Edit post: wp post edit 1 # Post update: wp post update 1 --post_title="Your New title..." # Create posts: wp post create --post_status=publish --post_title="Second Post" --edit Post meta : # See all metas of post 18: wp post meta list 18 # Get post meta value: wp post meta get 18 meta_name # Delete post meta by key: wp post meta delete 18 meta_name DB : # Create DB dump wp db export - --add-drop-table --default-character-set=utf8mb4 | gzip > ./db-dump-$(date +%Y-%m-%d-%H%M%S).sql.gz # Insert data from DB dump to DB wp db import db_backup-2022-01-20.sql # Login WordPress db: wp db cli # Run SQL Query: wp db query "SELECT user_login, ID FROM wp_users;" # Optimize db: wp db optimize Update : # Update WordPress wp core update # Update all plugins: wp plugin update --all Themes  &  Plugins # List plugins: wp plugin list # Search plugin: wp plugin search yoast # Install plugin: wp plugin install yoast # List installed themes: wp theme list # Install theme: wp theme install twentyone # Activate theme: wp theme activate twentyone Plugin Headers Plugin Headers readme.txt file admin_url( 'admin-ajax.php' ) ] ); wp_script_add_data( 'my-script', 'conditional', 'lt IE 9' ); wp_style_add_data( 'my-style', 'conditional', 'lt IE 9' ) wp_add_inline_script( 'my-scripts', 'alert("Hello!");' ); wp_add_inline_style( 'my-style', ' .mycolor{ background: #fff; } '); wp_deregister_script( 'my-script' ); wp_deregister_style( 'my-style' ); } Hooks Functions How hooks work in WordPress Hooks execution order add_action() Hangs a function on an event. remove_action() Deletes a function from the event. did_action() Gets a number of how many times the event was performed. do_action() Creates an event. do_action_ref_array() Creates an event. Arguments are passed in an array. has_action() Checks whether a function is hung on the event. current_action() Gets the name of the current event. doing_action() Checks if the event is being processed at the moment. remove_all_actions() Deletes all functions attached to the event.   add_filter() Hangs a function on a filter. remove_filter() Deletes a function from the filter. apply_filters() Creates a filter. apply_filters_ref_array() Creates a filter. Arguments are passed in an array. has_filter() Checks whether the function is hung on the filter. current_filter() Gets the name of the current filter. doing_filter() Checks if the filter is currently being processed. remove_all_filters() Deletes all functions attached to the filter. function my_filter_function( $str ){ return 'Hello '. $str; } // Let's attach a function to the filter add_filter( 'my_filter', 'my_filter_function' ); // Call the filter echo apply_filters( 'my_filter', 'John' ); //> Hello John // Create a function for the event function my_action_function( $text ){ echo 'The my_action event has been triggered just now.'; } // Let's attach the function to the my_action event add_action( 'my_action', 'my_action_function' ); // Action call do_action( 'my_action' ); //> The my_action event has been triggered just now. Localization (translation) Localization Functions Translations in WordPress __() Gets string translation. _e() Outputs a string translation. _n() Gets a string translation after a number.   esc_attr__() Gets string translation + esc_attr(). esc_attr_e() Outputs the string translation + esc_attr(). esc_html__() Gets the string translation + esc_html(). esc_html_e() Outputs the string translation + esc_html().   _x() Gets the string translation for context. _ex() Outputs the string translation for the context. _nx() Gets a string translation after a number for the context.   date_i18n() Gets the translated date. Localization for date().   determine_locale() Gets the locale of the site suitable for the current query. get_locale() Gets the locale of the site. E.g. en_US. get_user_locale() Gets the user's locale. switch_to_locale() Switches the user's locale. is_locale_switched() Checks if switch_to_locale() was used.   load_plugin_textdomain() Loads .mo file  from plugin folder . load_muplugin_textdomain() Loads .mo file  from plugin's MU folder . load_theme_textdomain() Loads the .mo file  from the theme folder . load_child_theme_textdomain() Loads the .mo file  from the child theme folder . load_textdomain() Loads the specified .mo file  from any folder . is_textdomain_loaded() Checks if the .mo file is loaded. unload_textdomain() Unloads (removes) the loaded .mo file. Conditional tags  (post types and queries) if( is_single() ){ // single post type page } wp_doing_ajax() Works for an AJAX request in WordPress. wp_doing_cron() Works for WordPress cron requests. is_ssl() Works for HTTPS (SSL). is_front_page() Home page. is_home() Posts page (or Home page). is_single() Page of post of any type except: attachment and page. is_singular() Page of post of any type. is_page() The page of a Static page. is_page_template() Whether or not a template file is used for the page. is_attachment() Attachment page. is_search() Search result page. is_archive() Archive page: category, tag, author, date. is_category() Category page. is_tag() Tag page. is_tax() Page of custom taxonomy. is_post_type_archive() Page of custom post type archive. is_author() Page of author posts archive. is_date() Archive page by date. is_year() Archive page by Year. is_month() Archive page by Month. is_day() Archive page by Day. is_time() Archive page by an hour, minute, second. is_paged() Pagination page. is_404() "Not found" page. is_preview() Post preview page. is_feed() Feed page. is_admin() Admin panel. is_network_admin() Administration panel "Network management" of Multisite sites. is_blog_admin() Section of the admin panel of a separate site in Multisite. is_user_admin() The "User" section of the admin panel in Multisite. is_customize_preview() Page of customizer in the admin area. is_robots() Query to the robots.txt file. is_embed() Page of embedding post. is_comment_feed() Comments feed page. is_trackback() Page of pings (trackback). Conditional tags  (others) All Conditional Tags if( is_user_logged_in() ){ // user is authorized } is_user_logged_in() Checks if the user is logged in. have_comments() Checks if there are comments to be displayed on the page. comments_open() Checks if comments are opened. has_category() Checks if the post is in at least one category. has_tag() Checks if the post is in at least one tag. has_term() Checks if the post is in at least one taxonomy term. has_excerpt() Checks if the post has an excerpt (quote, short description). is_nav_menu() Checks if there is a menu by ID, slug or name. has_nav_menu() Checks if registered menu area have an attached menu. has_shortcode() Checks if content contains the specified shortcode. shortcode_exists() Checks if the specified shortcode is registered. in_category() Checks if the post are in a category. in_the_loop() Checks if we are inside a WP Loop. is_main_query() Checks if we are in the main WP Loop. is_active_sidebar() Checks if there is at least one widget in the widgets area. is_child_theme() Checks if a child theme being used. is_dynamic_sidebar() Checks if theme sidebars are enabled and they has at least one widget. is_local_attachment() Checks if the given URL is an attachment page. is_multisite() Checks if the multisite mode is turned on. is_new_day() Checks if the current date differs from the previous (in the loop). is_post_type_hierarchical() Checks if the post type is hierarchical (tree-like). is_taxonomy_hierarchical() Checks if the taxonomy is hierarchical (tree-like). is_sticky() Checks if the post is sticky (be shown on front page). pings_open() Checks if the post is allowed to receive pings. post_exists() Checks if there is a post with a specified title (post_title). taxonomy_exists() Checks if the specified taxonomy exist. post_password_required() Checks if the post is password protected and it is correct. term_exists() Checks if the taxonomy element exist (return the term ID). cat_is_ancestor_of() Checks if the category is child of another one (all nesting levels). term_is_ancestor_of() Checks if the term is child of another one (all nesting levels). wp_attachment_is() Checks if the attachment is an image, audio or video. wp_attachment_is_image() Checks if the attachment (post) is a image . is_header_video_active() Checks if the header video should be shown on the page. has_custom_header() Checks if the picture/video is set for the theme header. wp_is_mobile() Checks if the site is viewed on a mobile device. wp_is_post_autosave() Checks if the post is an auto-save. wp_is_post_revision() Checks if the post is a revision. Template Tags All Template Tags home_url() Gets the URL of the homepage. site_url() Gets the URL of the admin panel. wp_get_document_title() Gets the page title for . the_archive_title() Outputs the title of the archive page: tag, category, date. single_term_title() Outputs/Gets the title of the term page. single_post_title() Outputs/Gets title of a post page. single_cat_title() Outputs/Gets title of a category/tag page. body_class() Outputs css classes for the <body> tag. wp_body_open() Triggers the  wp_body_open  hook. Use is after <body> tag. wp_head() Triggers the  wp_head  hook. Use it in header.php file. wp_footer() Triggers the  wp_footer  hook. Use it in footer.php file. wp_list_categories() Outputs list of categories as links. wp_dropdown_categories() Outputs a dropdown list of categories/terms. wp_list_comments() Outputs/Gets post comments. comment_form() Outputs comment form. wp_tag_cloud() Outputs/Gets tag cloud. register_sidebar() Registers a widget panel. register_sidebars() Registers a widget panels (several at once). wp_nav_menu() Outputs a custom menu created in the admin panel. register_nav_menu() Registers a single menu location (area). register_nav_menus() Registers multiple menu locations (areas). wp_get_attachment_image() Gets image IMG tag. wp_get_attachment_image_src() Gets image data: URL/Width/Height. wp_get_attachment_image_url() Gets image URL by it's ID. category_description() Gets category description. term_description() Gets term description. get_the_term_list() Outputs a list of post terms as links. get_avatar() Gets image of the user avatar (<img> tag). next_post_link() Displays a link to the next most recent post (by date). previous_post_link() Displays a link to the previous most recent post (by date). get_post_type_archive_link() Gets the URL for the post type archive page. wp_link_pages() Outputs pagination for multi-page post <!--nextpage-->. the_post_navigation() Outputs links to next/previous posts (as HTML block). wp_get_archives() Outputs links to date archives pages: days, months, years. wp_login_form() Outputs login form HTML code. edit_tag_link() Outputs a link to edit the current tag. edit_term_link() Outputs a link to edit the current term. Formatting Formatting absint() Convert a value to non-negative integer. antispambot() Converts all email characters to HTML entities. force_balance_tags() Fixes HTML tags: not closed, wrong syntax. links_add_target() Adds a target attr with the specified value to A tags. make_clickable() Changes links like  http://site.com ,  www.site.com  to HTML link. normalize_whitespace() Replaces all line breaks (EOL) with  \n , removes extra spaces. number_format_i18n() Corrects integer or decimal number format to fit localisation. size_format() Changes bytes to format: 500 B, 63 KB, 9 MB, 2 GB, 1 TB. set_url_scheme() Fixs URL protocol. If set "relative" domain will be removed. wp_rel_nofollow() Adds  rel="nofollow"  to all  <a> . Internal links are skipped. trailingslashit() Adds a slash (/) to the end of string (URL/path). untrailingslashit() Removes closing slash (/) at the end of a string. user_trailingslashit() Adds or removes a slash (/) at the end. Depends on WP permalink settings. wp_trim_words() Trims text to the specified number of words. wpautop() Replaces double newline (\n\n) with HTML  <p>...</p>  and single with  <br> . wptexturize() Changes some characters in the text:  (tm)  >>  ™  etc. zeroise() Add leading zeros when necessary:  10  >>  0010 . Escaping on output Escaping on output esc_attr() Cleans for use in HTML tag attribute. esc_html() Cleans for displaying text on the screen. esc_url() Cleans for use in the  src= ,  url= , etc. attributes. esc_textarea() Cleans for use in  <textarea>  value. wp_strip_all_tags() Removes all HTML tags. wp_kses() Removes all HTML tags. esc_js() Prepares string for display in JS. esc_sql() Cleans the string, leaving only the specified HTML tags. Sanitize on input Sanitize on input sanitize_text_field() Cleans string, leaving only clean text: without HTML, extra spaces, etc. sanitize_textarea_field() Cleans string for textarea (when saving to the database). sanitize_key() Cleans string to use it as a key/ID. sanitize_url() Cleans string to use it for redirects or to store it in the DB. sanitize_html_class() Cleans the text for use in the HTML attribute "class". sanitize_email() Cleans string, leaving only the permissible characters for an email. sanitize_file_name() Cleans the file name, replacing " " with "_" and removing impermissible characters. sanitize_title_with_dashes() Cleans title, replacing " " with "-". sanitize_mime_type() Removes all characters except "-+**.a-zA-Z0-9/." - allowed in MIME type.