Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Blocks/Template...
File: AbstractPageTemplate.php
<?php
[0] Fix | Delete
namespace Automattic\WooCommerce\Blocks\Templates;
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* AbstractPageTemplate class.
[4] Fix | Delete
*
[5] Fix | Delete
* Shared logic for page templates.
[6] Fix | Delete
*
[7] Fix | Delete
* @internal
[8] Fix | Delete
*/
[9] Fix | Delete
abstract class AbstractPageTemplate extends AbstractTemplate {
[10] Fix | Delete
/**
[11] Fix | Delete
* Initialization method.
[12] Fix | Delete
*/
[13] Fix | Delete
public function init() {
[14] Fix | Delete
add_filter( 'page_template_hierarchy', array( $this, 'page_template_hierarchy' ), 1 );
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Returns the page object assigned to this template/page.
[19] Fix | Delete
*
[20] Fix | Delete
* @return \WP_Post|null Post object or null.
[21] Fix | Delete
*/
[22] Fix | Delete
abstract protected function get_placeholder_page();
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Should return true on pages/endpoints/routes where the template should be shown.
[26] Fix | Delete
*
[27] Fix | Delete
* @return boolean
[28] Fix | Delete
*/
[29] Fix | Delete
abstract protected function is_active_template();
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* When the page should be displaying the template, add it to the hierarchy.
[33] Fix | Delete
*
[34] Fix | Delete
* This places the template name e.g. `cart`, at the beginning of the template hierarchy array. The hook priority
[35] Fix | Delete
* is 1 to ensure it runs first; other consumers e.g. extensions, could therefore inject their own template instead
[36] Fix | Delete
* of this one when using the default priority of 10.
[37] Fix | Delete
*
[38] Fix | Delete
* @param array $templates Templates that match the pages_template_hierarchy.
[39] Fix | Delete
*/
[40] Fix | Delete
public function page_template_hierarchy( $templates ) {
[41] Fix | Delete
if ( $this->is_active_template() ) {
[42] Fix | Delete
array_unshift( $templates, static::SLUG );
[43] Fix | Delete
}
[44] Fix | Delete
return $templates;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Forces the page title to match the template title when this template is active.
[49] Fix | Delete
*
[50] Fix | Delete
* Only applies when hooked into `pre_get_document_title`. Most templates used for pages will not require this because
[51] Fix | Delete
* the page title should be used instead.
[52] Fix | Delete
*
[53] Fix | Delete
* @param string $title Page title.
[54] Fix | Delete
* @return string
[55] Fix | Delete
*/
[56] Fix | Delete
public function page_template_title( $title ) {
[57] Fix | Delete
if ( $this->is_active_template() && $this->get_template_title() ) {
[58] Fix | Delete
return $this->get_template_title();
[59] Fix | Delete
}
[60] Fix | Delete
return $title;
[61] Fix | Delete
}
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function