WordPress: Creating Theme Options in Admin

These are the WP functions in the Settings API:

Register Setting

register_setting( string $option_group, string $option_name, array $args = array() )

$option_group (string) (Required) A settings group name. Should correspond to a whitelisted option key name. Default whitelisted option key names include “general,” “discussion,” and “reading,” among others.

$option_name (string) (Required) The name of an option to sanitize and save.

$args (array) (Optional) Data used to describe the setting when registered.

  • ‘type’
    (string) The type of data associated with this setting. Valid values are ‘string’, ‘boolean’, ‘integer’, and ‘number’.
  • ‘description’
    (string) A description of the data attached to this setting.
  • ‘sanitize_callback’
    (callable) A callback function that sanitizes the option’s value.
  • ‘show_in_rest’
    (bool) Whether data associated with this setting should be included in the REST API.
  • ‘default’
    (mixed) Default value when calling get_option().

Default value: array()

add_settings_field( $id, $title, $callback, $page, $section, $args )

$id(string) (required) String for use in the ‘id’ attribute of tags.Default: None

$title(string) (required) Title of the field.Default: None

$callback(callback) (required) Function that fills the field with the desired inputs as part of the larger form. Passed a single argument, the $args array. Name and id of the input should match the $id given to this function. The function should echo its output.Default: None

$page(string) (required) The menu page on which to display this field. Should match $menu_slug from add_theme_page() or from do_settings_sections().Default: None

$section(string) (optional) The section of the settings page in which to show the box (default or a section you added with add_settings_section(), look at the page in the source to see what the existing ones are.)Default: default

$args(array) (optional) Additional arguments that are passed to the $callback function. The ‘label_for’ key/value pair can be used to format the field title like so: <label for=”value”>$title</label>.Default: array()

add_settings_section( $id, $title, $callback, $page )

$id(string) (required) String for use in the ‘id’ attribute of tags.Default: None

$title(string) (required) Title of the section.Default: None

$callback(string) (required) Function that fills the section with the desired content. The function should echo its output.Default: None

$page(string) (required) The menu page on which to display this section. Should match $menu_slug from Function Reference/add theme page if you are adding a section to an ‘Appearance’ page, or Function Reference/add options page if you are adding a section to a ‘Settings’ page.Default: None

settings_fields( $option_group )

$option_group(string) (required) A settings group name. This should match the group name used in register_setting().Default: None

do_settings_sections( $page )

$page(string) (required) The slug name of the page whose settings sections you want to output. This should match the page name used in add_settings_section().

do_settings_fields( $page, $section )

$page(string) (required) Slug title of the admin page whose settings fields you want to show. This should match the page name used in add_settings_section().Default: None

$section(string) (required) Slug title of the settings section whose fields you want to show. This should match the section ID used in add_settings_section().Default: None

PHP: Removing an Element From an Array during foreach

foreach – What does it do?

The foreach control structure is a simple way of traversing (or iterating through) every element of an array or object. It has two control structures, namely:

foreach( $array as $a )

and

foreach( $array as $key=>$value )

In the first you have a variable $a which is given the value of the first element of the array, followed by each subsequent element as the array is traversed. In the second, you’ve still got the value ($value) but also the key of the array($key). This is real useful.

I just wondered what happens if you remove an element from an array whilst traversing an array using foreach?

So I wrote this routine:

$rdrr = array("a" => "apple", "b" => "banana", "c" => "cherry", "d"=>"date");
foreach( $rdrr as $key=>$value ) {
	  if( $key == "b" ) unset( $rdrr["c"] );
	  echo "$key : $value";
}
print_r ( $rdrr );

We have an array $rdrr and start to traverse it with the foreach, but when we’re at element ‘b’, we remove element ‘c’. Question is, does the foreach still traverse to ‘c’ or go straight to ‘d’?

Answer

a : apple
b : banana
c : cherry
d : date
Array ( [a] => apple [b] => banana [d] => date ) 

So, no, although the element is removed from the array (as can be seen from print_r), the foreach cycles through each element in the array as it was before the loop.

Automagic WEBP images for osCommerce

You want to optimise your site for Google and when checking Page Speed Insights you’re penalized for not Serving images in next-gen formats.

What this basically means is that you’re not serving images in webp format. The problem with this, is that not all browsers support webp. Every one will support jpg, png, gif, bmp so it seems unfair to be penalized for not using a webp. But that’s Google for you, and if you want to rank in their search queries (who doesn’t?) it makes good sense to follow their guidelines.

So, this is what we did for a clients osCommerce webstore.

Does the Browser Support webp?

At the time of writing, Chrome does, Opera does, Firefox does, Safari does not, nor does Edge. Detecting browsers is not always reliable, but there is a work around. The http_accept header will contain the text “image/webp” if the browser supports webp. So we will use this to determine using the strpos function. We’ll use this to define a constant as true or false. So in the osCommerce file catalog/includes/configure.php add the following to the end (just before the closing ?> tag)

 /* webp support */
	if( strpos ( $_SERVER['HTTP_ACCEPT'], 'image/webp' ) !== false ) {
		define( 'WEBPSUPPORTED', true );
	} else {	
		define( 'WEBPSUPPORTED', false );
	}
	define( 'WEBPIMAGEQUALITY', 65 ); // Sets image quality for WEBP conversion
	define( 'WEBPFORCECREATE', false); // Set to true if you want to force recreation of webpimages. Used if you change quality setting etc.

What this does is check to see if the text ‘image/webp’ is in the header, if so, set the constant WEBPSUPPORTED to true, or else set it to false. We can use this constant throughout the program to determine whether to present a webp or the default file. There are two other constants, WEBPIMAGEQUALITY which determines the quality level of the created image, and WEBPFORCECREATE which is used to create a new webp image even if one already exists. The reason for this is you may want to change the quality level and hence rewrite the already created webps. If so, then set this to true.

Create a webp image.

PHP can actually create PHP images on the fly, so we’re going to make use of this very feature. What we’ll do is when the osCommerce function tep_image is called, if the browser supports webp we will create a webp image and serve that image instead. However, in order to reduce server loading, if the image has already been created, then don’t recreate it, just change the requested image to the webp image.

In catalog/includes/functions/html_output.php, find function tep_image and add in $src = webpconvert( $src ); so it looks something like.

 // The HTML image wrapper function
  function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '', $responsive = true, $bootstrap_css = '') {
    if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
      return false;
    }
	
	$src = webpconvert( $src ); // Convert to webp (see function for details)

Now add the function webpconvert to the end of the file (before the closing ?> tag)

  function webpconvert( $image ) {
	  
	  $imageInfo = pathinfo( $image );
	  
	  // If the browser doesn't support webp or if it can't be found then just return the image
	  if( WEBPSUPPORTED == false || !file_exists( $image )) return $image;
	  
	  $webpFilename = substr( $image, 0, -1-strlen( $imageInfo['extension'] )) . '.webp';
	  
	  // If the webp image has already been created then exit now
	  // Unless a force create is set.
	  
	  if( file_exists( $webpFilename ) && WEBPFORCECREATE == false ) return $webpFilename;
	  
	  // Create the webp image
	  $resource = imagecreatefromstring( file_get_contents( $image ) );
	  
	  // If the resource can't be created, return with the original file
	  if( !$resource ) {
		  return $image;
	  }
	  
	  $webpimage = imagewebp( $resource, $webpFilename, WEBPIMAGEQUALITY );
	  imagedestroy( $resource );
	  
	  // Make sure that if the image wasn't created then return the original.
	  if( $webpimage ) {
		  return $webpimage;
	  }
	  else {		  
		  return $image;
	  }
  }

Discovered Issues

The code works a treat and converts the jpg and png files admirably on the fly. One issue is that the program execution moves on before the image has been converted and saved. This means that on first page load the webp image is asked for but is not found. A refresh or another visit to that page results in the image now displaying correctly.

Another, more serious error is that we occasionally got a fatal error:

PHP Fatal error: Paletter image not supported by webp

Which turned out to be happening only with one png image. The image file would be created and then the fatal error would stop program execution. So a webp file is in existence but is zero bytes long. As a result the program would no longer crash but the image would not be found either. We suspect this is some issue with that particular png image.

A bit of an oddball is that we discovered that Edge does in fact display webp images, but the http header suggests it does not. No real workaround for this at this time.

Other Uses

In some modules we don’t use the tep_image wrapper and instead either display the image directly, or use it in css as a background image. To be able to use webp we can just call the function directly. For example:

<div style="
  border:10px solid #ccc; 
  border-radius:25px; 
  background:url(<?php echo webpconvert( DIR_WS_IMAGES.'image.jpg'); ?>); 
  background-size:contain; 
  background-repeat:no-repeat; 
  font-size:1.5em; text-align:center;">

Contents

</div>

Next we’ll be doing something for WordPress. Watch this space,

Finder – A PHP Utility for Finding a Text String in a Complex Directory Structure

I was having to re-engineer some (open source!) source code which had an extremely complicated directory structure with hundreds of files. These files are called through various plugins and class functions. To make the change I wanted involved trying to track down a particular variable which appeared at numerous points throughout. It’s almost as though the authors didn’t want you to be able to make any changes!

What was needed was a utility to be able to search for the text string throughout the entire directory structure. It would be handy to be able to view the file as well to be able to confirm this is the file I needed to edit. So the “finder” utility was born. There’s probably more out there but, hey, its fun writing your own.

Warning

The finder utility will allow you to view any file downstream of there the utility is placed in the directory. This is clearly a security issue, so it should only be used as a utility and then removed or disabled – the options to be able to do that are contained within the utility itself.

I’ve included an IP check as a basic level of authentication.

Program Structure

There are 3 files:

  • finder.php
  • finder_getsource.php
  • prettify.css

finder.php is the main file. finder_getsource.php retrieves the file contents of the file and is displayed after an AJAX call to the file from finder.php

prettify.css is the css file for the Google Code Prettifier.

Installation

You’ll need to edit finder.php to add in the IP address of where you want to access the utility from. Its a basic level of security.

finder.php

<?php
/// Disable this program:
// die('This programme is disabled');

if( $_GET['action'] == 'disable' ) {
	$file = file_get_contents( 'finder.php' );
	$file = str_replace( "// die('This programme is disabled');", "die('This programme is disabled');", $file);
	file_put_contents( 'finder.php', $file );
	header('Location: finder.php');
}

if( $_GET['action'] == 'remove' ) {
	unlink( 'finder_getsource.php' );
	unlink( 'prettify.css' );
	unlink( 'finder.php' );
	die('Where to now?');
}

/*
	File: 	finder.php
	By:		toneus www.toneus.co.uk
	Rev:	1.0 
	
	History:	Made on 9 August 2019
	
	Description: 
	This utility finds all the files and directories downstream of its location
	and searches for a searchterm within those files.
	
	It returns a list of the files containing the search term. You can also view (but not edit) the file.
	
	Useful for where you may need to find where a variable is used in a complex filesystem without having to download
	and open every file.
	
	How It Works:
	
	The DirectoryIterator php class is used to traverse the directory structure.
	
	Every file is opened and if the search term is found the path is outputted.
	
	We could've stored the contents of every file to make for easy viewing but the memory required could become huge.
	So instead we read the file once, and store the path if the search text is found.
	
	If the user wants to view the file (by clicking on the outputted result), we then do an AJAX call to finder_getsource.php 
	with the path and that will return the file contents which will be displayed in a hideable DIV element.
	
	NOTES!
	
	**********************************************
	* The idea is this is used as a utility.	 *
	* But if it is kept on the server and is	 *
	* found, it can be used to read the contents *
	* of potentially every file on the server.	 *
	* So some sort of access requirement should	 *
	* be added.									 *
	**********************************************
	
	
*/

/* 
	One method of access control is to allow access only from certain IP addresses.
	It's basic but is perfectly acceptable for our needs.
*/

// Define a list of allowable IP addresses. 
	$iplist[] = "123.45.678.900"; // Put your IP address in here

	
	
// Is this file being called from an allowable IP?
	if( !in_array( $_SERVER['REMOTE_ADDR'], $iplist ) ) 
die( '<span style="color:red; font-weight: bold;">No can do.</span>. 
Access Restriction is set up. You\'ll need to edit this file to fix.' );
	
	if($_GET) {
		$_GET['searchTerm'] ? $searchTerm = $_GET['searchTerm'] : false;
		$_GET['caseSensitive'] ? $caseSensitive = true : $caseSensitive = false;
	}
?>

<!doctype html>
<html>
	<head>
		<title>Finder</title>
		<style>
			body {
				font-family: "sergoe UI", Arial, sans-serif;
			}
			#resultdiv {
				border: 1px solid #123;
				background-color: #def;
				color: #123;
				font-family: courier;
			}
			button, .entry {
				cursor: pointer;
			}
			
			.entry:hover {
				background-color: #faa;
			}
			
			#codeWindow {
				position: fixed;
				top: 10vh;
				left: 10vh;
				height: 80vh;
				width: 80vw;
				background-color: #fff;
				visibility: hidden;
				box-shadow: 0px 0px 25px 30px;
				overflow: scroll;
				font-family: courier;
				padding: 5px;
			}
			.title {
				background-color: #000;
				color: #fff;
				position: fixed;
			}
			
			#warning {
				border: 1px solid red;
				font-size: 2em;
				padding: 2em;
			}
			
			#warning-close {
				display: flex;
				justify-content: center;
				align-content: center;
				float: right;
				height:2rem;
				width: 2rem;
				cursor: pointer;
				background-color:#eee;
				border:1px solid black;
			}
			
		</style>
		
		<link rel="stylesheet" href="prettify.css" />
		
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
		<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?autorun=true"></script>
		<script>
		
			function viewCode( id ) {
				var path = $('#' + id).html();
				$.ajax( {
					url: "finder_getsource.php",
					data: {path: path }
				})
				.done(function( html ) {
					$('#codeWindow').html( html );
					$('#codeWindow').css('visibility','visible');
					PR.prettyPrint();
				});
			}
			
			function hideWarning() {
				$('#warning').css('display','none');
				sessionStorage.setItem('displayWarning', "no");
			}
			
			$( document ).ready( function() {
				if( sessionStorage.getItem('displayWarning') == "no" ) hideWarning();
			});
			
		</script>
				
				
				

				
	<head>
	<body>
		<h1>Finder</h1>
		<div id="warning">
		<div id="warning-close" onclick="hideWarning();">X</div>
			<p>⚠ This programme is a useful utility for finding a search term within any file downstream of this file location.</p>
			<p>However, it is a security risk as it allows the files to be read. Eg config files could be read and exploited.</p>
			<p>Basic protection is offered by means of IP validation.</p>
			<p>You can <a href="<?php echo $_SERVER['PHP_SELF'] . '?action=disable';?>">Disable</a>
			or <a href="<?php echo $_SERVER['PHP_SELF'] . '?action=remove';?>">Remove</a> it if required.
		</div>
		<form>
			<input type="text" placeholder="SearchTerm" name="searchTerm" value="<?php echo $searchTerm ? $searchTerm : ""; ?>" /> 
			<input type="checkbox" name="caseSensitive" <?php echo $caseSensitive ? "checked" : ""; ?> /> Case Sensitive Search <br/>
			<p><button type="submit">Search</button> 
			<button type="reset" onclick="window.location.assign('<?php echo $_SERVER['PHP_SELF']; ?>');">Reset</button></p>
		</form>
	
<?php

// If $searchTerm is set then let's go.

	if( $searchTerm ) {

		echo '<p>Looking for <b>' . htmlspecialchars($searchTerm) . '</b></p>';
?>

		<div id="resultdiv">
		
<?php 
		$cnt = 1; 
		function fillArrayWithFileNodes( DirectoryIterator $dir ) {
			global $searchTerm, $caseSensitive, $cnt;
			$data = array();
			foreach ( $dir as $node ) {
				if ( $node->isDir() && !$node->isDot() ) {
					$data[$node->getFilename()] = fillArrayWithFileNodes( new DirectoryIterator( $node->getPathname() ) );
				}
				else if ( $node->isFile() )	{
					$file = $node->getFilename();
					$path = $node->getPathname();
					$data[] = $file;
					$check = file_get_contents( $path );
					if( lookForString( $check, $searchTerm, $caseSensitive ) ) {
						echo '<div id="entry'. $cnt . '" class="entry" onclick="viewCode(\'entry' . $cnt . '\');">' . $path . "</div>";
						$cnt++;
					}

				}
			}
			return $data;
		}
		
		function lookForString ( $check, $searchTerm, $caseSensitive = false ) {
			if( $caseSensitive ) {
				$found = strpos ( $check, $searchTerm );
			} else {
				$found = stripos ( $check, $searchTerm );
			}
			
			if( $found === false ) return false; else return true;
		
		}
		
		$fileData = fillArrayWithFileNodes( new DirectoryIterator( dirname(__FILE__) ) );		

	}
?>
	</div>
	<p>END</p>
	<div id="codeWindow" onclick="$(this).css('visibility','hidden');">
	</div>
	</body>
</html>

finder_getsource.php

<?php

/* 
	
	finder_getsource.php

	This is the AJAX handler for finder.php.
	
	A GET request is made with path=PATH/AND/FILENAME
	
	This utility returns the formatted contents of the file.
	
*/



if( $path = $_GET['path'] ) { // Make sure its a valid call
	
	if( file_exists( $path ) ) { // Make sure the file exists
		
		$info = pathinfo( $path ); // Retrieve info on the file
		
	
		$code = file_get_contents( $path ); // Get the file contents
		
		// Code Prettifier will take care of php, js and html extensions, otherwise remove html
		if( $info['extension'] != 'js' || $info['extension'] != 'html' || $info['extension'] != 'php') {
			$code = htmlspecialchars( $code ); // Convert into html entities
		}
		
		echo '<div class="title">' . $path . '</div> <div> </div><pre class="prettyprint">' . $code . '</pre>'; // Put the path as a title and format the file as code
	

		
	} else echo "Error (No such File)";
	
} else echo "Error (Bad Request)";
		

prettify.css

/**
 * @license
 * Copyright (C) 2015 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* Pretty printing styles. Used with prettify.js. */


/* SPAN elements with the classes below are added by prettyprint. */
.pln { color: #000 }  /* plain text */

@media screen {
  .str { color: #080 }  /* string content */
  .kwd { color: #008 }  /* a keyword */
  .com { color: #800 }  /* a comment */
  .typ { color: #606 }  /* a type name */
  .lit { color: #066 }  /* a literal value */
  /* punctuation, lisp open bracket, lisp close bracket */
  .pun, .opn, .clo { color: #660 }
  .tag { color: #008 }  /* a markup tag name */
  .atn { color: #606 }  /* a markup attribute name */
  .atv { color: #080 }  /* a markup attribute value */
  .dec, .var { color: #606 }  /* a declaration; a variable name */
  .fun { color: red }  /* a function name */
}

/* Use higher contrast and text-weight for printable form. */
@media print, projection {
  .str { color: #060 }
  .kwd { color: #006; font-weight: bold }
  .com { color: #600; font-style: italic }
  .typ { color: #404; font-weight: bold }
  .lit { color: #044 }
  .pun, .opn, .clo { color: #440 }
  .tag { color: #006; font-weight: bold }
  .atn { color: #404 }
  .atv { color: #060 }
}

/* Put a border around prettyprinted code snippets. */
pre.prettyprint { padding: 2px; border: 1px solid #888 }

/* Specify class=linenums on a pre to get line numbering */
ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L5,
li.L6,
li.L7,
li.L8 { list-style-type: none }
/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9 { background: #eee }

WordPress Function Reference

I found the WordPress Function reference pretty difficult to navigate so I created a programme to crawl it. References in a full list here, click on titles to link to the WP website.

add_network_option()

Function: Add a new network option.

add_new_user_to_blog()

Function: Adds a newly created user to the appropriate blog

add_object_page()

Function: Add a top-level menu page in the ‘objects’ section.

add_option()

Function: Add a new option.

add_options_page()

Function: Add submenu page to the Settings main menu.

add_option_update_handler()

Function: Register a setting and its sanitization callback

add_option_whitelist()

Function: Adds an array of options to the options whitelist.

add_pages_page()

Function: Add submenu page to the Pages main menu.

add_permastruct()

Function: Add permalink structure.

add_ping()

Function: Add a URL to those already pinged.

add_plugins_page()

Function: Add submenu page to the Plugins main menu.

add_posts_page()

Function: Add submenu page to the Posts main menu.

add_post_meta()

Function: Adds a meta field to the given post.

add_post_type_support()

Function: Register support of certain features for a post type.

add_query_arg()

Function: Retrieves a modified URL query string.

add_rewrite_endpoint()

Function: Add an endpoint, like /trackback/.

add_rewrite_rule()

Function: Adds a rewrite rule that transforms a URL structure to a set of query vars.

add_rewrite_tag()

Function: Add a new rewrite tag (like %postname%).

add_role()

Function: Add role, if it does not exist.

add_screen_option()

Function: Register and configure an admin screen option

add_settings_error()

Function: Register a settings error to be displayed to the user

add_settings_field()

Function: Add a new field to a section of a settings page

add_settings_section()

Function: Add a new section to a settings page.

add_shortcode()

Function: Adds a new shortcode.

add_site_meta()

Function: Adds metadata to a site.

add_site_option()

Function: Add a new option for the current network.

add_submenu_page()

Function: Add a submenu page.

add_term_meta()

Function: Adds metadata to a term.

add_theme_page()

Function: Add submenu page to the Appearance main menu.

add_theme_support()

Function: Registers theme support for a given feature.

add_thickbox()

Function: Enqueues the default ThickBox js and css.

add_user()

Function: Creates a new user from the “Users” form using $_POST information.

add_users_page()

Function: Add submenu page to the Users/Profile main menu.

add_user_meta()

Function: Adds meta data to a user.

add_user_to_blog()

Function: Adds a user to a blog.

add_utility_page()

Function: Add a top-level menu page in the ‘utility’ section.

adjacent_image_link()

Function: Displays next or previous image link that has the same post parent.

adjacent_posts_rel_link()

Function: Displays the relational links for the posts adjacent to the current post.

adjacent_posts_rel_link_wp_head()

Function: Displays relational links for the posts adjacent to the current post for single post pages.

adjacent_post_link()

Function: Displays the adjacent post link.

admin_color_scheme_picker()

Function: Display the default admin color scheme picker (Used in user-edit.php)

admin_created_user_email()

Function:

admin_created_user_subject()

Function:

admin_url()

Function: Retrieves the URL to the admin area for the current site.

allowed_http_request_hosts()

Function: Whitelists allowed redirect hosts for safe HTTP requests as well.

allowed_tags()

Function: Display all of the allowed tags in HTML format with attributes.

allow_subdirectory_install()

Function: Allow subdirectory installation.

allow_subdomain_install()

Function: Allow subdomain installation

antispambot()

Function: Converts email addresses characters to HTML entities to block spam bots.

apache_mod_loaded()

Function: Does the specified module exist in the Apache config?

apply_filters()

Function: Call the functions added to a filter hook.

apply_filters_deprecated()

Function: Fires functions attached to a deprecated filter hook.

apply_filters_ref_array()

Function: Execute functions hooked on a specific filter hook, specifying arguments in an array.

array_replace_recursive()

Function: PHP-agnostic version of {@link array_replace_recursive()}.

atom_enclosure()

Function: Display the atom enclosure for the current post.

atom_site_icon()

Function: Displays Site Icon in atom feeds.

attachment_id3_data_meta_box()

Function: Display fields for ID3 data

attachment_submitbox_metadata()

Function: Displays non-editable attachment metadata in the publish meta box.

attachment_submit_meta_box()

Function: Display attachment submit form fields.

attachment_url_to_postid()

Function: Tries to convert an attachment URL into a post ID.

attribute_escape()

Function: Escaping for HTML attributes.

author_can()

Function: Whether the author of the supplied post has a specific capability.

auth_redirect()

Function: Checks if a user is logged in, if not it redirects them to the login page.

automatic_feed_links()

Function: Enable/disable automatic general feed link outputting.

avoid_blog_page_permalink_collision()

Function: Avoids a collision between a site slug and a permalink slug.

background_color()

Function: Display background color value.

background_image()

Function: Display background image path.

backslashit()

Function: Adds backslashes before letters and before a number at the start of a string.

balanceTags()

Function: Balances tags if forced to, or if the ‘use_balanceTags’ option is set to true.

before_last_bar()

Function: Remove last item on a pipe-delimited string.

block_version()

Function: Returns the current version of the block format that the content string is using.

bloginfo()

Function: Displays information about the current site.

bloginfo_rss()

Function: Display RSS container for the bloginfo function.

body_class()

Function: Displays the class names for the body element.

bool_from_yn()

Function: Whether input is yes or no.

build_dropdown_script_block_core_categories()

Function: Generates the inline script for a categories dropdown field.

build_query()

Function: Build URL query based on an associative and, or indexed array.

bulk_edit_posts()

Function: Process the post data for the bulk editing of posts.

cache_javascript_headers()

Function: Set the headers for caching for 10 days with JavaScript content type.

cache_users()

Function: Retrieve info for user lists to prevent multiple queries by get_userdata()

calendar_week_mod()

Function: Get number of days since the start of the week.

cancel_comment_reply_link()

Function: Display HTML content for cancel comment reply link.

can_edit_network()

Function: Whether or not we can edit this network from this page.

capital_P_dangit()

Function: Forever eliminate “Wordpress” from the planet (or at least the little bit we can influence).

category_description()

Function: Retrieve category description.

category_exists()

Function: Check whether a category exists.

cat_is_ancestor_of()

Function: Check if a category is an ancestor of another category.

checked()

Function: Outputs the html checked attribute.

check_admin_referer()

Function: Makes sure that a user was referred from another admin page.

check_ajax_referer()

Function: Verifies the Ajax request to prevent processing requests external of the blog.

check_and_publish_future_post()

Function: Publish future post and make sure post ID has future post status.

check_column()

Function: Check column matches criteria.

check_comment()

Function: Check whether a comment passes internal checks to be allowed to add.

check_comment_flood_db()

Function: Hooks WP’s native database-based comment-flood check.

check_import_new_users()

Function: Checks if the current user has permissions to import new users.

check_password_reset_key()

Function: Retrieves a user row based on password reset key and login

check_theme_switched()

Function: Checks if a theme has been changed and runs ‘after_switch_theme’ hook on the next WP load.

check_upload_mimes()

Function: Check an array of MIME types against a whitelist.

check_upload_size()

Function: Determine if uploaded file exceeds space quota.

choose_primary_blog()

Function: Handles the display of choosing a user’s primary site.

clean_attachment_cache()

Function: Will clean the attachment in the cache.

clean_blog_cache()

Function: Clean the blog cache

clean_bookmark_cache()

Function: Deletes the bookmark cache.

clean_category_cache()

Function: Remove the category cache data based on ID.

clean_comment_cache()

Function: Removes a comment from the object cache.

clean_network_cache()

Function: Removes a network from the object cache.

clean_object_term_cache()

Function: Removes the taxonomy relationship to terms from the cache.

clean_page_cache()

Function: Will clean the page in the cache.

clean_post_cache()

Function: Will clean the post in the cache.

clean_pre()

Function: Accepts matches array from preg_replace_callback in wpautop() or a string.

clean_site_details_cache()

Function: Cleans the site details cache for a site.

clean_taxonomy_cache()

Function: Clean the caches for a taxonomy.

clean_term_cache()

Function: Will remove all of the term ids from the cache.

clean_url()

Function: Checks and cleans a URL.

clean_user_cache()

Function: Clean all user caches

clear_global_post_cache()

Function: Deprecated functionality to clear the global post cache.

codepress_footer_js()

Function: Adds JavaScript required to make CodePress work on the theme/plugin editors.

codepress_get_lang()

Function: Determines the language to use for CodePress syntax highlighting.

comments_link()

Function: Display the link to the current post comments.

comments_link_feed()

Function: Outputs the link to the comments for the current post in an xml safe way

comments_number()

Function: Display the language string for the number of comments the current post has.

comments_open()

Function: Determines whether the current post is open for comments.

comments_popup_link()

Function: Displays the link to the comments for the current post ID.

comments_popup_script()

Function: Display the JS popup script to show a comment.

comments_rss()

Function: Return link to the post RSS feed.

comments_rss_link()

Function: Print RSS comment feed link.

comments_template()

Function: Load the comment template specified in $file.

comment_author()

Function: Displays the author of the current comment.

comment_author_email()

Function: Display the email of the author of the current global $comment.

comment_author_email_link()

Function: Display the html email link to the author of the current comment.

comment_author_IP()

Function: Display the IP address of the author of the current comment.

comment_author_link()

Function: Display the html link to the url of the author of the current comment.

comment_author_rss()

Function: Display the current comment author in the feed.

comment_author_url()

Function: Display the url of the author of the current comment.

comment_author_url_link()

Function: Displays the HTML link of the url of the author of the current comment.

comment_class()

Function: Generates semantic classes for each comment element.

comment_date()

Function: Display the comment date of the current comment.

comment_excerpt()

Function: Display the excerpt of the current comment.

comment_exists()

Function: Determine if a comment exists based on author and date.

comment_footer_die()

Function: Display error message at bottom of comments.

comment_form()

Function: Outputs a complete commenting form for use within a template.

comment_form_title()

Function: Display text based on comment reply status.

comment_guid()

Function: Display the feed GUID for the current comment.

comment_ID()

Function: Display the comment id of the current comment.

comment_id_fields()

Function: Output hidden input HTML for replying to comments.

comment_link()

Function: Display the link to the comments.

comment_reply_link()

Function: Displays the HTML content for reply to comment link.

comment_text()

Function: Display the text of the current comment.

comment_text_rss()

Function: Display the current comment content for use in the feeds.

comment_time()

Function: Display the comment time of the current comment.

comment_type()

Function: Display the comment type of the current comment.

compression_test()

Function: Test support for compressing JavaScript from PHP

confirm_another_blog_signup()

Function: Confirm a new site signup.

confirm_blog_signup()

Function: New site signup confirmation

confirm_delete_users()

Function:

confirm_user_signup()

Function: New user signup confirmation

content_url()

Function: Retrieves the URL to the content directory.

convert_chars()

Function: Converts lone & characters into `&` (a.k.a. `&`)

convert_invalid_entities()

Function: Converts invalid Unicode references range to valid range.

convert_smilies()

Function: Convert text equivalent of smilies to images.

convert_to_screen()

Function: Convert a screen string to a screen object

copy_dir()

Function: Copies a directory from one location to another via the WordPress Filesystem Abstraction.

core_update_footer()

Function:

core_upgrade_preamble()

Function: Display upgrade WordPress for downloading latest or upgrading automatically form.

count_many_users_posts()

Function: Number of posts written by a list of users.

count_users()

Function: Count number of users who have each of the user roles.

count_user_posts()

Function: Number of posts user has written.

create_empty_blog()

Function: Create an empty blog.

create_initial_post_types()

Function: Creates the initial post types when ‘init’ action is fired.

create_initial_rest_routes()

Function: Registers default REST API routes.

create_initial_taxonomies()

Function: Creates the initial taxonomies.

create_user()

Function: An alias of wp_create_user().

current_action()

Function: Retrieve the name of the current action.

current_filter()

Function: Retrieve the name of the current filter or action.

current_theme_info()

Function: Retrieves information on the current active theme.

current_theme_supports()

Function: Checks a theme’s support for a given feature.

current_time()

Function: Retrieve the current time based on specified type.

current_user_can()

Function: Whether the current user has a specific capability.

current_user_can_for_blog()

Function: Whether the current user has a specific capability for a given site.

customize_themes_print_templates()

Function: Print JS templates for the theme-browsing UI in the Customizer.

dashboard_browser_nag_class()

Function:

dashboard_php_nag_class()

Function: Adds an additional class to the PHP nag if the current version is insecure.

date_i18n()

Function: Retrieve the date in localized format, based on a sum of Unix timestamp and timezone offset in seconds.

dbDelta()

Function: Modifies the database based on specified SQL statements.

deactivate_plugins()

Function: Deactivate a single plugin or multiple plugins.

deactivate_sitewide_plugin()

Function: Deprecated functionality for deactivating a network-only plugin.

dead_db()

Function: Load custom DB error or display WordPress DB error.

debug_fclose()

Function: Close the debugging file handle.

debug_fopen()

Function: Open the file handle for debugging.

debug_fwrite()

Function: Write contents to the file used for debugging.

default_password_nag()

Function:

default_password_nag_edit_user()

Function:

default_password_nag_handler()

Function:

default_topic_count_scale()

Function: Default topic count scaling for tag links.

default_topic_count_text()

Function: Old callback for tag link tooltips.

delete_all_user_settings()

Function: Delete the user settings of the current user.

delete_blog_option()

Function: Removes option by name for a given blog id. Prevents removal of protected WordPress options.

delete_comment_meta()

Function: Remove metadata matching criteria from a comment.

delete_expired_transients()

Function: Deletes all expired transients.

delete_get_calendar_cache()

Function: Purge the cached results of get_calendar.

delete_meta()

Function: Delete post meta data by meta ID.

delete_metadata()

Function: Delete metadata for the specified object.

delete_metadata_by_mid()

Function: Delete meta data by meta ID

delete_network_option()

Function: Removes a network option by name.

delete_option()

Function: Removes option by name. Prevents removal of protected WordPress options.

delete_plugins()

Function: Remove directory and files of a plugin for a list of plugins.

delete_post_meta()

Function: Remove metadata matching criteria from a post.

delete_post_meta_by_key()

Function: Delete everything from post meta matching meta key.

delete_post_thumbnail()

Function: Removes the thumbnail (featured image) from the given post.

delete_site_meta()

Function: Removes metadata matching criteria from a site.

delete_site_meta_by_key()

Function: Deletes everything from site meta matching meta key.

delete_site_option()

Function: Removes a option by name for the current network.

delete_site_transient()

Function: Delete a site transient.

delete_term_meta()

Function: Removes metadata matching criteria from a term.

delete_theme()

Function: Remove a theme

delete_transient()

Function: Delete a transient.

delete_usermeta()

Function: Remove user meta data.

delete_users_add_js()

Function:

delete_user_meta()

Function: Remove metadata matching criteria from a user.

delete_user_option()

Function: Delete user option with global blog capability.

delete_user_setting()

Function: Delete user interface settings.

deslash()

Function: Filters for content to remove unnecessary slashes.

determine_locale()

Function: Determine the current locale desired for the request.

did_action()

Function: Retrieve the number of times an action is fired.

disabled()

Function: Outputs the html disabled attribute.

discover_pingback_server_uri()

Function: Finds a pingback server URI based on the given URL.

dismissed_updates()

Function:

dismiss_core_update()

Function:

display_header()

Function: Display installation header.

display_header_text()

Function: Whether to display the header text.

display_plugins_table()

Function: Display plugin content based on plugin list.

display_setup_form()

Function: Display installer setup form.

display_space_usage()

Function: Displays the amount of disk space used by the current site. Not used in core.

display_theme()

Function: Prints a theme on the Install Themes pages.

display_themes()

Function: Display theme content based on theme list.

documentation_link()

Function: Unused Admin function.

doing_action()

Function: Retrieve the name of an action currently being processed.

doing_filter()

Function: Retrieve the name of a filter currently being processed.

dolly_css()

Function:

domain_exists()

Function: Checks whether a site name is already taken.

download_url()

Function: Downloads a URL to a local temporary file using the WordPress HTTP API.

do_accordion_sections()

Function: Meta Box Accordion Template Function

do_action()

Function: Execute functions hooked on a specific action hook.

do_action_deprecated()

Function: Fires functions attached to a deprecated action hook.

do_action_ref_array()

Function: Execute functions hooked on a specific action hook, specifying arguments in an array.

do_activate_header()

Function: Adds an action hook specific to this page.

do_all_pings()

Function: Perform all pingbacks, enclosures, trackbacks, and send to pingback services.

do_blocks()

Function: Parses dynamic blocks out of `post_content` and re-renders them.

do_block_editor_incompatible_meta_box()

Function: Function that renders a “fake” meta box with an information message, shown on the block editor, when an incompatible meta box is found.

do_core_upgrade()

Function: Upgrade WordPress core display.

do_dismiss_core_update()

Function:

do_enclose()

Function: Check content for video and audio links to add as enclosures.

do_feed()

Function: Load the feed template from the use of an action hook.

do_feed_atom()

Function: Load either Atom comment feed or Atom posts feed.

do_feed_rdf()

Function: Load the RDF RSS 0.91 Feed template.

do_feed_rss()

Function: Load the RSS 1.0 Feed Template.

do_feed_rss2()

Function: Load either the RSS2 comment feed or the RSS2 posts feed.

do_meta_boxes()

Function: Meta-Box template function

do_robots()

Function: Display the robots.txt file content.

do_settings_fields()

Function: Print out the settings fields for a particular settings section.

do_settings_sections()

Function: Prints out all settings sections added to a particular settings page

do_shortcode()

Function: Search content for shortcodes and filter shortcodes through their hooks.

do_shortcodes_in_html_tags()

Function: Search only inside HTML elements for shortcodes and process them.

do_shortcode_tag()

Function: Regular Expression callable for do_shortcode() for calling shortcode hook.

do_signup_header()

Function: Prints signup_header via wp_head

do_trackbacks()

Function: Perform trackbacks.

do_undismiss_core_update()

Function:

dropdown_categories()

Function: Legacy function used to generate the categories checklist control.

dropdown_cats()

Function: Deprecated method for generating a drop-down of categories.

dropdown_link_categories()

Function: Legacy function used to generate a link categories checklist control.

drop_index()

Function: Drops a specified index from a table.

dynamic_sidebar()

Function: Display dynamic sidebar.

edit_bookmark_link()

Function: Displays the edit bookmark link anchor content.

edit_comment()

Function: Update a comment with values provided in $_POST.

edit_comment_link()

Function: Displays the edit comment link with formatting.

edit_form_image_editor()

Function: Displays the image and editor in the post editor

edit_link()

Function: Updates or inserts a link using values provided in $_POST.

edit_post()

Function: Update an existing post with values provided in $_POST.

edit_post_link()

Function: Displays the edit post link for post.

edit_tag_link()

Function: Displays or retrieves the edit link for a tag with formatting.

edit_term_link()

Function: Displays or retrieves the edit term link with formatting.

edit_user()

Function: Edit user settings based on contents of $_POST

email_exists()

Function: Determines whether the given email exists.

endElement()

Function: XML callback function that is called at the end of a XML tag.

enqueue_comment_hotkeys_js()

Function:

enqueue_embed_scripts()

Function: Enqueue embed iframe default CSS and JS & fire do_action(‘enqueue_embed_scripts’)

ent2ncr()

Function: Converts named entities into numbered entities.

esc_attr()

Function: Escaping for HTML attributes.

esc_attr_e()

Function: Display translated text that has been escaped for safe use in an attribute.

esc_attr_x()

Function: Translate string with gettext context, and escapes it for safe use in an attribute.

esc_attr__()

Function: Retrieve the translation of $text and escapes it for safe use in an attribute.

esc_html()

Function: Escaping for HTML blocks.

esc_html_e()

Function: Display translated text that has been escaped for safe use in HTML output.

esc_html_x()

Function: Translate string with gettext context, and escapes it for safe use in HTML output.

esc_html__()

Function: Retrieve the translation of $text and escapes it for safe use in HTML output.

esc_js()

Function: Escape single quotes, htmlspecialchar ” &, and fix line endings.

esc_sql()

Function: Escapes data for use in a MySQL query.

esc_textarea()

Function: Escaping for textarea values.

esc_url()

Function: Checks and cleans a URL.

esc_url_raw()

Function: Performs esc_url() for database usage.

excerpt_remove_blocks()

Function: Parses blocks out of a content string, and renders those appropriate for the excerpt.

export_add_js()

Function: Display JavaScript on the page.

export_date_options()

Function: Create the date options fields for exporting a given post type.

export_wp()

Function: Generates the WXR export file for download.

extract_from_markers()

Function: Extracts strings from between the BEGIN and END markers in the .htaccess file.

favorite_actions()

Function: Favorite actions were deprecated in version 3.2. Use the admin bar instead.

feed_content_type()

Function: Return the content type for specified feed type.

feed_links()

Function: Display the links to the general feeds.

feed_links_extra()

Function: Display the links to the extra feeds such as category feeds.

fetch_feed()

Function: Build SimplePie object based on RSS or Atom feed from URL.

fetch_rss()

Function: Build Magpie object based on RSS from URL.

file_is_displayable_image()

Function: Validate that file is suitable for displaying within a web page.

file_is_valid_image()

Function: Validate that file is an image.

filter_default_option()

Function: Filter the default value for the option.

filter_SSL()

Function: Formats a URL to use https.

find_core_auto_update()

Function: Gets the best available (and enabled) Auto-Update for WordPress Core.

find_core_update()

Function:

find_posts_div()

Function: Outputs the modal window used for attaching media to posts or pages in the media-listing screen.

fix_import_form_size()

Function: Get the remaining upload space for this site.

fix_phpmailer_messageid()

Function: Correct From host on outgoing mail to match the site domain

floated_admin_avatar()

Function: Add avatars to relevant places in admin, or try to.

flush_rewrite_rules()

Function: Remove rewrite rules and then recreate rewrite rules.

force_balance_tags()

Function: Balances tags of string using a modified stack.

force_ssl_admin()

Function: Whether to force SSL used for the Administration Screens.

force_ssl_content()

Function: Whether to force SSL on content.

force_ssl_login()

Function: Whether SSL login should be forced.

format_code_lang()

Function: Returns the language for a language code.

format_for_editor()

Function: Formats text for the editor.

format_to_edit()

Function: Acts on text which is about to be edited.

format_to_post()

Function: Formerly used to escape strings before inserting into the DB.

form_option()

Function: Print option value after sanitizing for forms.

funky_javascript_callback()

Function: Callback used to change %uXXXX to &#YYY; syntax

funky_javascript_fix()

Function: Fixes JavaScript bugs in browsers.

gallery_shortcode()

Function: Builds the Gallery shortcode output.

gd_edit_image_support()

Function: Check if the installed version of GD supports particular image type

generate_postdata()

Function: Generates post data.

generate_random_password()

Function: Generates a random password.

generic_ping()

Function: Sends pings to all of the ping site services.

get_404_template()

Function: Retrieve path of 404 template in current or parent template.

get_active_blog_for_user()

Function: Get one of a user’s active blogs

get_adjacent_post()

Function: Retrieves the adjacent post.

get_adjacent_post_link()

Function: Retrieves the adjacent post link.

get_adjacent_post_rel_link()

Function: Retrieves the adjacent post relational link.

get_admin_page_parent()

Function:

get_admin_page_title()

Function:

get_admin_url()

Function: Retrieves the URL to the admin area for a given site.

get_admin_users_for_domain()

Function: Get the admin for a domain/path combination.

get_alloptions()

Function: Retrieve all autoload options, or all options if no autoloaded ones exist.

get_alloptions_110()

Function: Retrieve all options as it was for 1.2.

get_allowed_http_origins()

Function: Retrieve list of allowed HTTP origins.

get_allowed_mime_types()

Function: Retrieve list of allowed mime types and file extensions.

get_allowed_themes()

Function: Get the allowed themes for the current site.

get_all_category_ids()

Function: Retrieves all category IDs.

get_all_page_ids()

Function: Get a list of page IDs.

get_all_post_type_supports()

Function: Get all the post type features

get_all_user_settings()

Function: Retrieve all user interface settings.

get_ancestors()

Function: Get an array of ancestor IDs for a given object.

get_approved_comments()

Function: Retrieve the approved comments for post $post_id.

get_archives()

Function: Retrieves a list of archives.

get_archives_link()

Function: Retrieve archive link content based on predefined or custom code.

get_archive_template()

Function: Retrieve path of archive template in current or parent template.

get_attached_file()

Function: Retrieve attached file path based on attachment ID.

get_attached_media()

Function: Retrieves media attached to the passed post.

get_attachment_fields_to_edit()

Function: Retrieves the attachment fields to edit form fields.

get_attachment_icon()

Function: Retrieve HTML content of icon attachment image element.

get_attachment_icon_src()

Function: Retrieve icon URL and Path.

get_attachment_innerHTML()

Function: Retrieve HTML content of image element.

get_attachment_link()

Function: Retrieves the permalink for an attachment.

get_attachment_taxonomies()

Function: Retrieves taxonomies attached to given the attachment.

get_attachment_template()

Function: Retrieve path of attachment template in current or parent template.

get_author_feed_link()

Function: Retrieves the feed link for a given author.

get_author_link()

Function: Returns or Prints link to the author’s posts.

get_author_name()

Function: Retrieve the specified author’s preferred display name.

get_author_posts_url()

Function: Retrieve the URL to the author page for the user with the ID provided.

get_author_rss_link()

Function: Print/Return link to author RSS feed.

get_author_template()

Function: Retrieve path of author template in current or parent template.

get_author_user_ids()

Function: Get all user IDs.

get_autotoggle()

Function: Gets the auto_toggle setting.

get_available_languages()

Function: Get all available languages based on the presence of *.mo files in a given directory.

get_available_post_mime_types()

Function: Get all available post MIME types for a given post type.

get_available_post_statuses()

Function: Get all the possible statuses for a post_type

get_avatar()

Function: Retrieve the avatar `` tag for a user, email address, MD5 hash, comment, or post.

get_avatar_data()

Function: Retrieves default data about the avatar.

get_avatar_url()

Function: Retrieves the avatar URL.

get_background_color()

Function: Retrieve value for custom background color.

get_background_image()

Function: Retrieve background image for custom background.

get_block_categories()

Function: Returns all the block categories that will be shown in the block editor.

get_block_editor_server_block_settings()

Function: Prepares server-registered blocks for the block editor.

get_blogaddress_by_domain()

Function: Get a full blog URL, given a domain and a path.

get_blogaddress_by_id()

Function: Get a full blog URL, given a blog id.

get_blogaddress_by_name()

Function: Get a full blog URL, given a blog name.

get_bloginfo()

Function: Retrieves information about the current site.

get_bloginfo_rss()

Function: RSS container for the bloginfo function.

get_blogs_of_user()

Function: Get the sites a user belongs to.

get_blog_count()

Function: The number of active sites on your installation.

get_blog_details()

Function: Retrieve the details for a blog from the blogs table and blog options.

get_blog_id_from_url()

Function: Get a blog’s numeric ID from its URL.

get_blog_list()

Function: Deprecated functionality to retrieve a list of all sites.

get_blog_option()

Function: Retrieve option value for a given blog id based on name of option.

get_blog_permalink()

Function: Get the permalink for a post on another blog.

get_blog_post()

Function: Get a blog post from any site on the network.

get_blog_status()

Function: Get a blog details field.

get_body_class()

Function: Retrieve the classes for the body element as an array.

get_bookmark()

Function: Retrieve Bookmark data

get_bookmarks()

Function: Retrieves the list of bookmarks

get_bookmark_field()

Function: Retrieve single bookmark data item or field.

get_boundary_post()

Function: Retrieves the boundary post.

get_boundary_post_rel_link()

Function: Get boundary post relational link.

get_broken_themes()

Function: Retrieves a list of broken themes.

get_calendar()

Function: Display calendar with days that have posts as links.

get_cancel_comment_reply_link()

Function: Retrieve HTML content for cancel comment reply link.

get_categories()

Function: Retrieve list of category objects.

get_category()

Function: Retrieves category data given a category ID or category object.

get_category_by_path()

Function: Retrieve category based on URL containing the category slug.

get_category_by_slug()

Function: Retrieve category object by category slug.

get_category_children()

Function: Retrieve category children list separated before and after the term IDs.

get_category_feed_link()

Function: Retrieves the feed link for a category.

get_category_link()

Function: Retrieve category link URL.

get_category_parents()

Function: Retrieve category parents with separator.

get_category_rss_link()

Function: Print/Return link to category RSS2 feed.

get_category_template()

Function: Retrieve path of category template in current or parent template.

get_category_to_edit()

Function: Get category object for given ID and ‘edit’ filter context.

get_catname()

Function: Retrieve the category name by the category ID.

get_cat_ID()

Function: Retrieve the ID of a category from its name.

get_cat_name()

Function: Retrieve the name of a category from its ID.

get_children()

Function: Retrieve all children of the post parent ID.

get_clean_basedomain()

Function: Get base domain of network.

get_cli_args()

Function: Returns value of command line params.

get_column_headers()

Function: Get the column headers for a screen

get_comment()

Function: Retrieves comment data given a comment ID or comment object.

get_commentdata()

Function: Retrieve an array of comment data about comment $comment_ID.

get_comments()

Function: Retrieve a list of comments.

get_comments_link()

Function: Retrieves the link to the current post comments.

get_comments_number()

Function: Retrieves the amount of comments a post has.

get_comments_number_text()

Function: Display the language string for the number of comments the current post has.

get_comments_pagenum_link()

Function: Retrieves the comments page number link.

get_comments_popup_template()

Function: Retrieve path of comment popup template in current or parent template.

get_comment_author()

Function: Retrieve the author of the current comment.

get_comment_author_email()

Function: Retrieve the email of the author of the current comment.

get_comment_author_email_link()

Function: Return the html email link to the author of the current comment.

get_comment_author_IP()

Function: Retrieve the IP address of the author of the current comment.

get_comment_author_link()

Function: Retrieve the HTML link to the URL of the author of the current comment.

get_comment_author_rss()

Function: Retrieve the current comment author for use in the feeds.

get_comment_author_url()

Function: Retrieve the url of the author of the current comment.

get_comment_author_url_link()

Function: Retrieves the HTML link of the url of the author of the current comment.

get_comment_class()

Function: Returns the classes for the comment div as an array.

get_comment_count()

Function: The amount of comments in a post or total comments.

get_comment_date()

Function: Retrieve the comment date of the current comment.

get_comment_excerpt()

Function: Retrieve the excerpt of the current comment.

get_comment_guid()

Function: Retrieve the feed GUID for the current comment.

get_comment_ID()

Function: Retrieve the comment id of the current comment.

get_comment_id_fields()

Function: Retrieve hidden input HTML for replying to comments.

get_comment_link()

Function: Retrieve the link to a given comment.

get_comment_meta()

Function: Retrieve comment meta field for a comment.

get_comment_pages_count()

Function: Calculate the total number of comment pages.

get_comment_reply_link()

Function: Retrieve HTML content for reply to comment link.

get_comment_statuses()

Function: Retrieve all of the WordPress supported comment statuses.

get_comment_text()

Function: Retrieve the text of the current comment.

get_comment_time()

Function: Retrieve the comment time of the current comment.

get_comment_to_edit()

Function: Returns a WP_Comment object based on comment ID.

get_comment_type()

Function: Retrieve the comment type of the current comment.

get_compat_media_markup()

Function:

get_core_checksums()

Function: Gets and caches the checksums for the given version of WordPress.

get_core_updates()

Function: Get available core updates.

get_currentuserinfo()

Function: Populate global variables with information about the currently logged in user.

get_current_blog_id()

Function: Retrieve the current site ID.

get_current_network_id()

Function: Retrieves the current network ID.

get_current_screen()

Function: Get the current screen object

get_current_site()

Function: Get the current network.

get_current_site_name()

Function: This deprecated function formerly set the site_name property of the $current_site object.

get_current_theme()

Function: Retrieve current theme name.

get_current_user_id()

Function: Get the current user’s ID

get_custom_header()

Function: Get the header image data.

get_custom_header_markup()

Function: Retrieve the markup for a custom header.

get_custom_logo()

Function: Returns a custom logo, linked to home.

get_dashboard_blog()

Function: Get the “dashboard blog”, the blog where users without a blog edit their profile data.

get_dashboard_url()

Function: Retrieves the URL to the user’s dashboard.

get_date_from_gmt()

Function: Converts a GMT date into the correct format for the blog.

get_date_template()

Function: Retrieve path of date template in current or parent template.

get_day_link()

Function: Retrieves the permalink for the day archives with year and month.

get_default_comment_status()

Function: Gets the default comment status for a post type.

get_default_feed()

Function: Retrieve the default feed.

get_default_link_to_edit()

Function: Retrieves the default link for editing.

get_default_page_to_edit()

Function: Gets the default page information to use.

get_default_post_to_edit()

Function: Default post information to use when populating the “Write Post” form.

get_delete_post_link()

Function: Retrieves the delete posts link for post.

get_dirsize()

Function: Get the size of a directory.

get_dropins()

Function: Check the wp-content directory and retrieve all drop-ins with any plugin data.

get_dynamic_block_names()

Function: Returns an array of the names of all registered dynamic block types.

get_editable_authors()

Function: Gets author users who can edit posts.

get_editable_roles()

Function: Fetch a filtered list of user roles that the current user is allowed to edit.

get_editable_user_ids()

Function: Gets the IDs of any users who can edit posts.

get_editor_stylesheets()

Function: Retrieve any registered editor stylesheets

get_edit_bookmark_link()

Function: Displays the edit bookmark link.

get_edit_comment_link()

Function: Retrieves the edit comment link.

get_edit_post_link()

Function: Retrieves the edit post link for post.

get_edit_profile_url()

Function: Retrieves the URL to the user’s profile editor.

get_edit_tag_link()

Function: Retrieves the edit link for a tag.

get_edit_term_link()

Function: Retrieves the URL for editing a given term.

get_edit_user_link()

Function: Retrieves the edit user link.

get_embed_template()

Function: Retrieves an embed template path in the current or parent template.

get_enclosed()

Function: Retrieve enclosures already enclosed for a post.

get_extended()

Function: Get extended entry info ( Continue reading “WordPress Function Reference”

Application Programming Interface using JSON

I was asked to develop an Application Programming Interface (API) that would allow a remote user to send a request to a remote server, which then performs some actions or lookups and returns an answer.

The simplest way to do this was to use JavaScript Object Notation, or JSON.

What the local site does is send a JSON request using JavaScript to the API. This uses a PHP script to interpret the request, perform security validations and send back the answer. The local device therefore needs to be able to interpret the answer.

Examples are best in this situation: UPS Runtime API. This is entirely in html and JavaScript. TBH jQuery is probably a better choice but just in case there were issues here the example is pure JS.