Skip to content

Commit

Permalink
Rename classes for 4.12
Browse files Browse the repository at this point in the history
  • Loading branch information
YahnisElsts committed Jul 24, 2022
1 parent 4525927 commit ae5789b
Show file tree
Hide file tree
Showing 36 changed files with 209 additions and 209 deletions.
2 changes: 1 addition & 1 deletion Puc/v4/Factory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
if ( !class_exists('Puc_v4_Factory', false) ):

class Puc_v4_Factory extends Puc_v4p11_Factory { }
class Puc_v4_Factory extends Puc_v4p12_Factory { }

endif;
4 changes: 2 additions & 2 deletions Puc/v4p12/Autoloader.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

if ( !class_exists('Puc_v4p11_Autoloader', false) ):
if ( !class_exists('Puc_v4p12_Autoloader', false) ):

class Puc_v4p11_Autoloader {
class Puc_v4p12_Autoloader {
private $prefix = '';
private $rootDir = '';
private $libraryDir = '';
Expand Down
16 changes: 8 additions & 8 deletions Puc/v4p12/DebugBar/Extension.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
if ( !class_exists('Puc_v4p11_DebugBar_Extension', false) ):
if ( !class_exists('Puc_v4p12_DebugBar_Extension', false) ):

class Puc_v4p11_DebugBar_Extension {
class Puc_v4p12_DebugBar_Extension {
const RESPONSE_BODY_LENGTH_LIMIT = 4000;

/** @var Puc_v4p11_UpdateChecker */
/** @var Puc_v4p12_UpdateChecker */
protected $updateChecker;
protected $panelClass = 'Puc_v4p11_DebugBar_Panel';
protected $panelClass = 'Puc_v4p12_DebugBar_Panel';

public function __construct($updateChecker, $panelClass = null) {
$this->updateChecker = $updateChecker;
Expand Down Expand Up @@ -163,11 +163,11 @@ private function getLibraryUrl($filePath) {
$absolutePath = realpath(dirname(__FILE__) . '/../../../' . ltrim($filePath, '/'));

//Where is the library located inside the WordPress directory structure?
$absolutePath = Puc_v4p11_Factory::normalizePath($absolutePath);
$absolutePath = Puc_v4p12_Factory::normalizePath($absolutePath);

$pluginDir = Puc_v4p11_Factory::normalizePath(WP_PLUGIN_DIR);
$muPluginDir = Puc_v4p11_Factory::normalizePath(WPMU_PLUGIN_DIR);
$themeDir = Puc_v4p11_Factory::normalizePath(get_theme_root());
$pluginDir = Puc_v4p12_Factory::normalizePath(WP_PLUGIN_DIR);
$muPluginDir = Puc_v4p12_Factory::normalizePath(WPMU_PLUGIN_DIR);
$themeDir = Puc_v4p12_Factory::normalizePath(get_theme_root());

if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) {
//It's part of a plugin.
Expand Down
6 changes: 3 additions & 3 deletions Puc/v4p12/DebugBar/Panel.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

if ( !class_exists('Puc_v4p11_DebugBar_Panel', false) && class_exists('Debug_Bar_Panel', false) ):
if ( !class_exists('Puc_v4p12_DebugBar_Panel', false) && class_exists('Debug_Bar_Panel', false) ):

class Puc_v4p11_DebugBar_Panel extends Debug_Bar_Panel {
/** @var Puc_v4p11_UpdateChecker */
class Puc_v4p12_DebugBar_Panel extends Debug_Bar_Panel {
/** @var Puc_v4p12_UpdateChecker */
protected $updateChecker;

private $responseBox = '<div class="puc-ajax-response" style="display: none;"></div>';
Expand Down
8 changes: 4 additions & 4 deletions Puc/v4p12/DebugBar/PluginExtension.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
if ( !class_exists('Puc_v4p11_DebugBar_PluginExtension', false) ):
if ( !class_exists('Puc_v4p12_DebugBar_PluginExtension', false) ):

class Puc_v4p11_DebugBar_PluginExtension extends Puc_v4p11_DebugBar_Extension {
/** @var Puc_v4p11_Plugin_UpdateChecker */
class Puc_v4p12_DebugBar_PluginExtension extends Puc_v4p12_DebugBar_Extension {
/** @var Puc_v4p12_Plugin_UpdateChecker */
protected $updateChecker;

public function __construct($updateChecker) {
parent::__construct($updateChecker, 'Puc_v4p11_DebugBar_PluginPanel');
parent::__construct($updateChecker, 'Puc_v4p12_DebugBar_PluginPanel');

add_action('wp_ajax_puc_v4_debug_request_info', array($this, 'ajaxRequestInfo'));
}
Expand Down
6 changes: 3 additions & 3 deletions Puc/v4p12/DebugBar/PluginPanel.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

if ( !class_exists('Puc_v4p11_DebugBar_PluginPanel', false) ):
if ( !class_exists('Puc_v4p12_DebugBar_PluginPanel', false) ):

class Puc_v4p11_DebugBar_PluginPanel extends Puc_v4p11_DebugBar_Panel {
class Puc_v4p12_DebugBar_PluginPanel extends Puc_v4p12_DebugBar_Panel {
/**
* @var Puc_v4p11_Plugin_UpdateChecker
* @var Puc_v4p12_Plugin_UpdateChecker
*/
protected $updateChecker;

Expand Down
6 changes: 3 additions & 3 deletions Puc/v4p12/DebugBar/ThemePanel.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

if ( !class_exists('Puc_v4p11_DebugBar_ThemePanel', false) ):
if ( !class_exists('Puc_v4p12_DebugBar_ThemePanel', false) ):

class Puc_v4p11_DebugBar_ThemePanel extends Puc_v4p11_DebugBar_Panel {
class Puc_v4p12_DebugBar_ThemePanel extends Puc_v4p12_DebugBar_Panel {
/**
* @var Puc_v4p11_Theme_UpdateChecker
* @var Puc_v4p12_Theme_UpdateChecker
*/
protected $updateChecker;

Expand Down
10 changes: 5 additions & 5 deletions Puc/v4p12/Factory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
if ( !class_exists('Puc_v4p11_Factory', false) ):
if ( !class_exists('Puc_v4p12_Factory', false) ):

/**
* A factory that builds update checker instances.
Expand All @@ -11,7 +11,7 @@
* At the moment it can only build instances of the UpdateChecker class. Other classes are
* intended mainly for internal use and refer directly to specific implementations.
*/
class Puc_v4p11_Factory {
class Puc_v4p12_Factory {
protected static $classVersions = array();
protected static $sorted = false;

Expand All @@ -23,7 +23,7 @@ class Puc_v4p11_Factory {
*
* @param string $fullPath Full path to the main plugin file or the theme's style.css.
* @param array $args Optional arguments. Keys should match the argument names of the buildUpdateChecker() method.
* @return Puc_v4p11_Plugin_UpdateChecker|Puc_v4p11_Theme_UpdateChecker|Puc_v4p11_Vcs_BaseChecker
* @return Puc_v4p12_Plugin_UpdateChecker|Puc_v4p12_Theme_UpdateChecker|Puc_v4p12_Vcs_BaseChecker
*/
public static function buildFromHeader($fullPath, $args = array()) {
$fullPath = self::normalizePath($fullPath);
Expand Down Expand Up @@ -54,15 +54,15 @@ public static function buildFromHeader($fullPath, $args = array()) {
* This method automatically detects if you're using it for a plugin or a theme and chooses
* the appropriate implementation for your update source (JSON file, GitHub, BitBucket, etc).
*
* @see Puc_v4p11_UpdateChecker::__construct
* @see Puc_v4p12_UpdateChecker::__construct
*
* @param string $metadataUrl The URL of the metadata file, a GitHub repository, or another supported update source.
* @param string $fullPath Full path to the main plugin file or to the theme directory.
* @param string $slug Custom slug. Defaults to the name of the main plugin file or the theme directory.
* @param int $checkPeriod How often to check for updates (in hours).
* @param string $optionName Where to store book-keeping info about update checks.
* @param string $muPluginFile The plugin filename relative to the mu-plugins directory.
* @return Puc_v4p11_Plugin_UpdateChecker|Puc_v4p11_Theme_UpdateChecker|Puc_v4p11_Vcs_BaseChecker
* @return Puc_v4p12_Plugin_UpdateChecker|Puc_v4p12_Theme_UpdateChecker|Puc_v4p12_Vcs_BaseChecker
*/
public static function buildUpdateChecker($metadataUrl, $fullPath, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
$fullPath = self::normalizePath($fullPath);
Expand Down
6 changes: 3 additions & 3 deletions Puc/v4p12/InstalledPackage.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
if ( !class_exists('Puc_v4p11_InstalledPackage', false) ):
if ( !class_exists('Puc_v4p12_InstalledPackage', false) ):

/**
* This class represents a currently installed plugin or theme.
*
* Not to be confused with the "package" field in WP update API responses that contains
* the download URL of a the new version.
*/
abstract class Puc_v4p11_InstalledPackage {
abstract class Puc_v4p12_InstalledPackage {
/**
* @var Puc_v4p11_UpdateChecker
* @var Puc_v4p12_UpdateChecker
*/
protected $updateChecker;

Expand Down
4 changes: 2 additions & 2 deletions Puc/v4p12/Metadata.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
if ( !class_exists('Puc_v4p11_Metadata', false) ):
if ( !class_exists('Puc_v4p12_Metadata', false) ):

/**
* A base container for holding information about updates and plugin metadata.
Expand All @@ -8,7 +8,7 @@
* @copyright 2016
* @access public
*/
abstract class Puc_v4p11_Metadata {
abstract class Puc_v4p12_Metadata {

/**
* Create an instance of this class from a JSON document.
Expand Down
4 changes: 2 additions & 2 deletions Puc/v4p12/OAuthSignature.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

if ( !class_exists('Puc_v4p11_OAuthSignature', false) ):
if ( !class_exists('Puc_v4p12_OAuthSignature', false) ):

/**
* A basic signature generator for zero-legged OAuth 1.0.
*/
class Puc_v4p11_OAuthSignature {
class Puc_v4p12_OAuthSignature {
private $consumerKey = '';
private $consumerSecret = '';

Expand Down
4 changes: 2 additions & 2 deletions Puc/v4p12/Plugin/Info.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
if ( !class_exists('Puc_v4p11_Plugin_Info', false) ):
if ( !class_exists('Puc_v4p12_Plugin_Info', false) ):

/**
* A container class for holding and transforming various plugin metadata.
Expand All @@ -8,7 +8,7 @@
* @copyright 2016
* @access public
*/
class Puc_v4p11_Plugin_Info extends Puc_v4p11_Metadata {
class Puc_v4p12_Plugin_Info extends Puc_v4p12_Metadata {
//Most fields map directly to the contents of the plugin's info.json file.
//See the relevant docs for a description of their meaning.
public $name;
Expand Down
10 changes: 5 additions & 5 deletions Puc/v4p12/Plugin/Package.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
if ( !class_exists('Puc_v4p11_Plugin_Package', false) ):
if ( !class_exists('Puc_v4p12_Plugin_Package', false) ):

class Puc_v4p11_Plugin_Package extends Puc_v4p11_InstalledPackage {
class Puc_v4p12_Plugin_Package extends Puc_v4p12_InstalledPackage {
/**
* @var Puc_v4p11_Plugin_UpdateChecker
* @var Puc_v4p12_Plugin_UpdateChecker
*/
protected $updateChecker;

Expand Down Expand Up @@ -170,8 +170,8 @@ public function isMuPlugin() {
$pluginPath = realpath($this->pluginAbsolutePath);
//If realpath() fails, just normalize the syntax instead.
if (($muPluginDir === false) || ($pluginPath === false)) {
$muPluginDir = Puc_v4p11_Factory::normalizePath(WPMU_PLUGIN_DIR);
$pluginPath = Puc_v4p11_Factory::normalizePath($this->pluginAbsolutePath);
$muPluginDir = Puc_v4p12_Factory::normalizePath(WPMU_PLUGIN_DIR);
$pluginPath = Puc_v4p12_Factory::normalizePath($this->pluginAbsolutePath);
}

$cachedResult = (strpos($pluginPath, $muPluginDir) === 0);
Expand Down
6 changes: 3 additions & 3 deletions Puc/v4p12/Plugin/Ui.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
if ( !class_exists('Puc_v4p11_Plugin_Ui', false) ):
if ( !class_exists('Puc_v4p12_Plugin_Ui', false) ):
/**
* Additional UI elements for plugins.
*/
class Puc_v4p11_Plugin_Ui {
class Puc_v4p12_Plugin_Ui {
private $updateChecker;
private $manualCheckErrorTransient = '';

/**
* @param Puc_v4p11_Plugin_UpdateChecker $updateChecker
* @param Puc_v4p12_Plugin_UpdateChecker $updateChecker
*/
public function __construct($updateChecker) {
$this->updateChecker = $updateChecker;
Expand Down
16 changes: 8 additions & 8 deletions Puc/v4p12/Plugin/Update.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
if ( !class_exists('Puc_v4p11_Plugin_Update', false) ):
if ( !class_exists('Puc_v4p12_Plugin_Update', false) ):

/**
* A simple container class for holding information about an available update.
Expand All @@ -8,7 +8,7 @@
* @copyright 2016
* @access public
*/
class Puc_v4p11_Plugin_Update extends Puc_v4p11_Update {
class Puc_v4p12_Plugin_Update extends Puc_v4p12_Update {
public $id = 0;
public $homepage;
public $upgrade_notice;
Expand All @@ -25,13 +25,13 @@ class Puc_v4p11_Plugin_Update extends Puc_v4p11_Update {
* Create a new instance of PluginUpdate from its JSON-encoded representation.
*
* @param string $json
* @return Puc_v4p11_Plugin_Update|null
* @return Puc_v4p12_Plugin_Update|null
*/
public static function fromJson($json){
//Since update-related information is simply a subset of the full plugin info,
//we can parse the update JSON as if it was a plugin info string, then copy over
//the parts that we care about.
$pluginInfo = Puc_v4p11_Plugin_Info::fromJson($json);
$pluginInfo = Puc_v4p12_Plugin_Info::fromJson($json);
if ( $pluginInfo !== null ) {
return self::fromPluginInfo($pluginInfo);
} else {
Expand All @@ -43,8 +43,8 @@ public static function fromJson($json){
* Create a new instance of PluginUpdate based on an instance of PluginInfo.
* Basically, this just copies a subset of fields from one object to another.
*
* @param Puc_v4p11_Plugin_Info $info
* @return Puc_v4p11_Plugin_Update
* @param Puc_v4p12_Plugin_Info $info
* @return Puc_v4p12_Plugin_Update
*/
public static function fromPluginInfo($info){
return self::fromObject($info);
Expand All @@ -53,8 +53,8 @@ public static function fromPluginInfo($info){
/**
* Create a new instance by copying the necessary fields from another object.
*
* @param StdClass|Puc_v4p11_Plugin_Info|Puc_v4p11_Plugin_Update $object The source object.
* @return Puc_v4p11_Plugin_Update The new copy.
* @param StdClass|Puc_v4p12_Plugin_Info|Puc_v4p12_Plugin_Update $object The source object.
* @return Puc_v4p12_Plugin_Update The new copy.
*/
public static function fromObject($object) {
$update = new self();
Expand Down
Loading

0 comments on commit ae5789b

Please sign in to comment.