PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.7.0.14
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.7.0.14
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / public / class-charitable-template-part.php

class-charitable-template-part.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.7.0.14, at includes/public/class-charitable-template-part.php

75 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable template part
4 *
5 * @version 1.0.0
6 * @package Charitable/Classes/Charitable_Template_Part
7 * @author David Bisset
8 * @copyright Copyright (c) 2022, WP Charitable LLC
9 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Charitable_Template_Part' ) ) :
18
19 /**
20 * Charitable_Template_Part
21 *
22 * @since 1.0.0
23 */
24 class Charitable_Template_Part {
25
26 /**
27 * @var string The template's slug.
28 */
29 private $slug;
30
31 /**
32 * @var string An optional name to be appended to the slug.
33 */
34 private $name;
35
36 /**
37 * Class constructor.
38 *
39 * @since 1.0.0
40 *
41 * @param string $slug
42 * @param string $name Optional name.
43 * @return void
44 */
45 public function __construct($slug, $name = "" ) {
46 $this->slug = $slug;
47 $this->name = $name;
48
49 new Charitable_Template( $this->get_template_names(), true, false );
50 }
51
52 /**
53 * Returns the array of template names.
54 *
55 * @since 1.0.0
56 *
57 * @return array
58 */
59 private function get_template_names() {
60 $names = array(
61 $this->slug . '.php'
62 );
63
64 /**
65 * If a name is set, add the slug-name.php combination to the start of the $names array
66 */
67 if ( strlen( $this->name ) ) {
68 array_unshift( $names, $this->slug . '-' . $this->name . '.php' );
69 }
70
71 return $names;
72 }
73 }
74
75 endif;