PluginProbe
CBX Map for Google Map & OpenStreetMap / 1.1.5
CBX Map for Google Map & OpenStreetMap v1.1.5
trunk 1.1.10 1.1.11 1.1.12 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5
cbxgooglemap / includes / cbxgooglemap-functions.php

cbxgooglemap-functions.php in CBX Map for Google Map & OpenStreetMap 1.1.5, at includes/cbxgooglemap-functions.php

108 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // If this file is called directly, abort.
3 if (!defined('WPINC')) {
4 die;
5 }
6
7
8 /**
9 * Get the template path.
10 *
11 * @return string
12 */
13 function cbxgooglemap_template_path() {
14 return apply_filters( 'cbxgooglemap_template_path', 'cbxgooglemap/' );
15 }//end cbxgooglemap_template_path
16
17 /**
18 * Locate a template and return the path for inclusion.
19 *
20 * This is the load order:
21 *
22 * yourtheme/$template_path/$template_name
23 * yourtheme/$template_name
24 * $default_path/$template_name
25 *
26 * @param string $template_name Template name.
27 * @param string $template_path Template path. (default: '').
28 * @param string $default_path Default path. (default: '').
29 *
30 * @return string
31 */
32 function cbxgooglemap_locate_template( $template_name, $template_path = '', $default_path = '' ) {
33 if ( ! $template_path ) {
34 $template_path = cbxgooglemap_template_path();
35 }
36
37 if ( ! $default_path ) {
38 $default_path = CBXGOOGLEMAP_ROOT_PATH . 'templates/';
39 }
40
41 // Look within passed path within the theme - this is priority.
42 $template = locate_template(
43 array(
44 trailingslashit( $template_path ) . $template_name,
45 $template_name,
46 )
47 );
48
49 // Get default template/.
50 if ( ! $template ) {
51 $template = $default_path . $template_name;
52 }
53
54 // Return what we found.
55 return apply_filters( 'cbxgooglemap_locate_template', $template, $template_name, $template_path );
56 }//end function cbxgooglemap_locate_template
57
58 /**
59 * Like wc_get_template, but returns the HTML instead of outputting.
60 *
61 * @see wc_get_template
62 * @since 2.5.0
63 *
64 * @param string $template_name Template name.
65 * @param array $args Arguments. (default: array).
66 * @param string $template_path Template path. (default: '').
67 * @param string $default_path Default path. (default: '').
68 *
69 * @return string
70 */
71 function cbxgooglemap_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
72 ob_start();
73 cbxgooglemap_get_template( $template_name, $args, $template_path, $default_path );
74
75 return ob_get_clean();
76 }//end function cbxgooglemap_get_template_html
77
78 /**
79 * Get other templates (e.g. product attributes) passing attributes and including the file.
80 *
81 * @param string $template_name Template name.
82 * @param array $args Arguments. (default: array).
83 * @param string $template_path Template path. (default: '').
84 * @param string $default_path Default path. (default: '').
85 */
86 function cbxgooglemap_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
87 if ( ! empty( $args ) && is_array( $args ) ) {
88 extract( $args ); // @codingStandardsIgnoreLine
89 }
90
91 $located = cbxgooglemap_locate_template( $template_name, $template_path, $default_path );
92
93 if ( ! file_exists( $located ) ) {
94 /* translators: %s template */
95 wc_doing_it_wrong( __FUNCTION__, sprintf( __( '%s does not exist.', 'cbxgooglemap' ), '<code>' . $located . '</code>' ), '1.0.0' );
96
97 return;
98 }
99
100 // Allow 3rd party plugin filter template file from their plugin.
101 $located = apply_filters( 'cbxgooglemap_get_template', $located, $template_name, $args, $template_path, $default_path );
102
103 do_action( 'cbxgooglemap_before_template_part', $template_name, $template_path, $located, $args );
104
105 include $located;
106
107 do_action( 'cbxgooglemap_after_template_part', $template_name, $template_path, $located, $args );
108 }//end function cbxgooglemap_get_template