Skip to content

Commit

Permalink
Fixing the template location addition
Browse files Browse the repository at this point in the history
  • Loading branch information
krugazul committed Jan 29, 2025
1 parent bafe29e commit 4ee3835
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
10 changes: 10 additions & 0 deletions classes/class-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class Core {
*/
public $admin;

/**
* Holds the template redirect functions
* @var object \lsx_starter_plugin\classes\Templates();
*/
public $templates;

/**
* Contructor
*/
Expand Down Expand Up @@ -58,6 +64,10 @@ private function load_classes() {
require_once LSX_STARTER_PLUGIN_PATH . 'classes/class-setup.php';
$this->setup = new Setup();

// Load plugin settings related functionality.
require_once LSX_STARTER_PLUGIN_PATH . 'classes/class-templates.php';
$this->templates = new Templates( LSX_STARTER_PLUGIN_PATH );

// Load plugin admin related functionality.
/*require_once LSX_STARTER_PLUGIN_PATH . 'classes/class-admin.php';
$this->admin = new Admin();*/
Expand Down
12 changes: 10 additions & 2 deletions classes/class-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@ class Templates {
*/
public $templates = [];

/**
* The path to the
*
* @var string
*/
public $path = '';

/**
* Initialize the plugin by setting localization, filters, and administration functions.
*
* @since 1.0.0
*
* @access private
*/
public function __construct() {
public function __construct( $path ) {
$this->path = $path;
add_action( 'init', [ $this, 'register_post_type_templates' ] );
}

Expand Down Expand Up @@ -75,7 +83,7 @@ public function register_post_type_templates() {
*/
protected function get_template_content( $template ) {
ob_start();
include LSX_TO_PATH . "/templates/{$template}";
include LSX_STARTER_PLUGIN_PATH . "/templates/{$template}";
return ob_get_clean();
}
}
2 changes: 2 additions & 0 deletions templates/archive-post-type.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- wp:template-part {"slug":"header","area":"header"} /-->
<!-- wp:template-part {"slug":"footer","area":"footer"} /-->
2 changes: 2 additions & 0 deletions templates/single-post-type.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- wp:template-part {"slug":"header","area":"header"} /-->
<!-- wp:template-part {"slug":"footer","area":"footer"} /-->

0 comments on commit 4ee3835

Please sign in to comment.