PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / 6.2.1
پارسی دیت – Parsi Date v6.2.1
6.2.1 6.2 6.1 5.1.6 5.1.7 5.1.8 5.1.8.2 6.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.0.0-alpha 2.1 2.1.1 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0.1 2.3.0.2 2.3.1 2.3.2 2.3.3 2.3.4 3.0.1 3.0.2 3.0.3 4.0.0 4.0.1 4.0.2 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5
wp-parsidate / inc / Helper / Templates.php
wp-parsidate / inc / Helper Last commit date
Assets.php 3 weeks ago Cache.php 3 weeks ago Date.php 3 weeks ago Debug.php 3 weeks ago FeedReader.php 3 weeks ago HTML.php 3 weeks ago Helper.php 3 weeks ago JSON.php 3 weeks ago Nonce.php 3 weeks ago Notice.php 3 weeks ago Number.php 3 weeks ago NumberConverter.php 3 weeks ago Param.php 3 weeks ago Sanitizing.php 3 weeks ago Strip.php 3 weeks ago Templates.php 3 weeks ago User.php 3 weeks ago Validating.php 3 weeks ago WooCommerce.php 3 weeks ago WordPress.php 3 weeks ago
Templates.php
55 lines
1 <?php
2
3 namespace WPParsidate\Helper;
4
5 class Templates {
6 /**
7 * Load template file
8 *
9 * @param string $file Path to template file
10 * @param array $args array of args pass to template file
11 * @param bool $loadOnce Load once
12 * @param bool $echo Print template output
13 *
14 * @return false|string|void
15 */
16 public static function load( string $file, array $args = [], bool $loadOnce = false, bool $echo = true ) {
17 if ( ! $echo ) {
18 ob_start();
19 }
20
21 if ( file_exists( $file ) ) {
22 load_template( $file, $loadOnce, $args );
23 }
24
25 if ( ! $echo ) {
26 return ob_get_clean();
27 }
28 }
29
30 /**
31 * Get path of template file
32 *
33 * @param string $template
34 * @param string $dir
35 *
36 * @return string
37 */
38 public static function getPath( $template, $dir = 'plugin' ): string {
39 $path = self::pathCorrection( WP_PARSI_DIR . '/inc/Templates/' . $dir . '/' . $template );
40
41 return apply_filters( 'wp_parsidate_template_path', $path, $template, $dir );
42 }
43
44 /**
45 * Fix template path
46 *
47 * @param string $path Path of template
48 *
49 * @return string Fixed path
50 */
51 public static function pathCorrection( $path ): string {
52 return str_replace( [ '/', '\\' ], DIRECTORY_SEPARATOR, $path );
53 }
54 }
55