For developers¶
For plugin authors and agencies who want to read the pins on a site from their own code. Version Pin 1.0.0 has one
public function for this. It has no hooks, filters or wp-config.php constants of its own.
Read the pins¶
gorilla_version_pin_get_pins() returns the pins Version Pin enforces on the site. It is read-only: to change pins,
use the screen or WP-CLI.
if ( function_exists( 'gorilla_version_pin_get_pins' ) ) {
$pins = gorilla_version_pin_get_pins();
if ( isset( $pins['pins']['akismet/akismet.php'] ) ) {
$pin = $pins['pins']['akismet/akismet.php'];
// $pin['version'] is '5.3.7', $pin['mode'] is 'patch'.
}
}
The shape:
array(
'schema' => 1,
'pins' => array(
'akismet/akismet.php' => array(
'version' => '5.3.7',
'mode' => 'patch', // 'patch' or 'exact', as chosen.
'note' => '5.4 changes the comment form. Testing on staging first.',
'name' => 'Akismet Anti-spam: Spam Protection',
),
),
'core' => array(
'version' => '7.1.3', // '' when WordPress is not pinned.
'mode' => 'patch',
'note' => '',
),
)
pinsis keyed by plugin basename. A pinned plugin that is not installed is listed too.modeis the mode chosen on the screen. A version without a series works as an exact pin even whenmodeispatch(see Versions with no series).- On a multisite network, where nothing is enforced,
pinsis empty andcore['version']is''. - Call it after
plugins_loaded, when Version Pin has loaded.
Schema changes¶
schema is 1. If the shape ever changes in a way that could break code reading it, schema goes up, so check it
before you rely on a key.
Related¶
- Compatibility: other plugins, hosts and multisite.
- WP-CLI: change pins from the command line.