# charitable/1.8.13/includes/public/class-charitable-template-part.php

Charitable – Donation &amp; Fundraising Platform (Donation Forms, Recurring Donations &amp; Fundraising Campaigns), version 1.8.13. 75 lines.

- Page: https://pluginprobe.com/plugins/charitable/1.8.13/code/includes/public/class-charitable-template-part.php
- Raw: https://pluginprobe.com/plugins/charitable/1.8.13/raw/includes/public/class-charitable-template-part.php
- Modified: 2023-11-01T16:41:02+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/charitable/1.8.13/code/includes/public/class-charitable-template-part.php#L10-L20`.

```php
<?php
/**
 * Charitable template part
 *
 * @version		1.0.0
 * @package		Charitable/Classes/Charitable_Template_Part
 * @author 		David Bisset
 * @copyright 	Copyright (c) 2023, WP Charitable LLC
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! class_exists( 'Charitable_Template_Part' ) ) :

/**
 * Charitable_Template_Part
 *
 * @since   1.0.0
 */
class Charitable_Template_Part {

	/**
	 * @var 	string 			The template's slug.
	 */
	private $slug;

	/**
	 * @var 	string 			An optional name to be appended to the slug.
	 */
	private $name;

	/**
	 * Class constructor.
	 *
	 * @since   1.0.0
	 *
	 * @param 	string $slug
	 * @param 	string $name 	Optional name.
	 * @return 	void
	 */
	public function __construct($slug, $name = "" ) {
		$this->slug = $slug;
		$this->name = $name;

		new Charitable_Template( $this->get_template_names(), true, false );
	}

	/**
	 * Returns the array of template names.
	 *
	 * @since   1.0.0
	 *
	 * @return 	array
	 */
	private function get_template_names() {
		$names = array(
			$this->slug . '.php'
		);

		/**
		 * If a name is set, add the slug-name.php combination to the start of the $names array
		 */
		if ( strlen( $this->name ) ) {
			array_unshift( $names, $this->slug . '-' . $this->name . '.php' );
		}

		return $names;
	}
}

endif;
```
