Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Blocks/Domain
File: Package.php
<?php
[0] Fix | Delete
namespace Automattic\WooCommerce\Blocks\Domain;
[1] Fix | Delete
[2] Fix | Delete
use Automattic\WooCommerce\Blocks\Options;
[3] Fix | Delete
use Automattic\WooCommerce\Blocks\Domain\Services\FeatureGating;
[4] Fix | Delete
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Main package class.
[8] Fix | Delete
*
[9] Fix | Delete
* Returns information about the package and handles init.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 2.5.0
[12] Fix | Delete
*/
[13] Fix | Delete
class Package {
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* Holds the current version of the blocks plugin.
[17] Fix | Delete
*
[18] Fix | Delete
* @var string
[19] Fix | Delete
*/
[20] Fix | Delete
private $version;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Holds the main path to the blocks plugin directory.
[24] Fix | Delete
*
[25] Fix | Delete
* @var string
[26] Fix | Delete
*/
[27] Fix | Delete
private $path;
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Holds locally the plugin_dir_url to avoid recomputing it.
[31] Fix | Delete
*
[32] Fix | Delete
* @var string
[33] Fix | Delete
*/
[34] Fix | Delete
private $plugin_dir_url;
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Holds the feature gating class instance.
[38] Fix | Delete
*
[39] Fix | Delete
* @var FeatureGating
[40] Fix | Delete
*/
[41] Fix | Delete
private $feature_gating;
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Constructor
[45] Fix | Delete
*
[46] Fix | Delete
* @param string $version Version of the plugin.
[47] Fix | Delete
* @param string $plugin_path Path to the main plugin file.
[48] Fix | Delete
* @param FeatureGating $deprecated Deprecated Feature gating class.
[49] Fix | Delete
*/
[50] Fix | Delete
public function __construct( $version, $plugin_path, $deprecated = null ) {
[51] Fix | Delete
if ( null !== $deprecated ) {
[52] Fix | Delete
wc_deprecated_argument( 'FeatureGating', '9.6', 'FeatureGating class is deprecated, please use wp_get_environment_type() instead.' );
[53] Fix | Delete
$this->feature_gating = new FeatureGating();
[54] Fix | Delete
}
[55] Fix | Delete
$this->version = $version;
[56] Fix | Delete
$this->path = $plugin_path;
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Returns the version of WooCommerce Blocks.
[61] Fix | Delete
*
[62] Fix | Delete
* Note: since Blocks was merged into WooCommerce Core, the version of
[63] Fix | Delete
* WC Blocks doesn't update anymore. Use
[64] Fix | Delete
* `Constants::get_constant( 'WC_VERSION' )` when possible to get the
[65] Fix | Delete
* WooCommerce Core version.
[66] Fix | Delete
*
[67] Fix | Delete
* @return string
[68] Fix | Delete
*/
[69] Fix | Delete
public function get_version() {
[70] Fix | Delete
return $this->version;
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Returns the version of WooCommerce Blocks stored in the database.
[75] Fix | Delete
*
[76] Fix | Delete
* @return string
[77] Fix | Delete
*/
[78] Fix | Delete
public function get_version_stored_on_db() {
[79] Fix | Delete
return get_option( Options::WC_BLOCK_VERSION, '' );
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
/**
[83] Fix | Delete
* Sets the version of WooCommerce Blocks in the database.
[84] Fix | Delete
* This is useful during the first installation or after the upgrade process.
[85] Fix | Delete
*/
[86] Fix | Delete
public function set_version_stored_on_db() {
[87] Fix | Delete
update_option( Options::WC_BLOCK_VERSION, $this->get_version() );
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* Returns the path to the plugin directory.
[92] Fix | Delete
*
[93] Fix | Delete
* @param string $relative_path If provided, the relative path will be
[94] Fix | Delete
* appended to the plugin path.
[95] Fix | Delete
*
[96] Fix | Delete
* @return string
[97] Fix | Delete
*/
[98] Fix | Delete
public function get_path( $relative_path = '' ) {
[99] Fix | Delete
return trailingslashit( $this->path ) . $relative_path;
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* Returns the url to the blocks plugin directory.
[104] Fix | Delete
*
[105] Fix | Delete
* @param string $relative_url If provided, the relative url will be
[106] Fix | Delete
* appended to the plugin url.
[107] Fix | Delete
*
[108] Fix | Delete
* @return string
[109] Fix | Delete
*/
[110] Fix | Delete
public function get_url( $relative_url = '' ) {
[111] Fix | Delete
if ( ! $this->plugin_dir_url ) {
[112] Fix | Delete
// Append index.php so WP does not return the parent directory.
[113] Fix | Delete
$this->plugin_dir_url = plugin_dir_url( $this->path . '/index.php' );
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
return $this->plugin_dir_url . $relative_url;
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* Returns an instance of the FeatureGating class.
[121] Fix | Delete
*
[122] Fix | Delete
* @return FeatureGating
[123] Fix | Delete
*/
[124] Fix | Delete
public function feature() {
[125] Fix | Delete
return $this->feature_gating;
[126] Fix | Delete
}
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function