This repository has been archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
functions.php
115 lines (102 loc) · 2.09 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
if( !defined( 'ABSPATH' ) )
{
exit;
}
/**
* Getting Plugin Template
*
* @since 1.0.0
*/
if( defined( 'FBFPI_FOLDER' ) )
{
function locate_fbfpi_template( $template_names, $load = FALSE, $require_once = TRUE )
{
$located = locate_template( $template_names, $load, $require_once );
if( '' == $located )
{
foreach( ( array ) $template_names as $template_name )
{
if( !$template_name )
{
continue;
}
if( file_exists( FBFPI_FOLDER . '/templates/' . $template_name ) )
{
$located = FBFPI_FOLDER . '/templates/' . $template_name;
break;
}
}
}
if( $load && '' != $located )
{
load_template( $located, $require_once );
}
return $located;
}
function fbfpi_get_url_var( $name )
{
$strURL = $_SERVER[ 'REQUEST_URI' ];
$arrVals = explode( '/', $strURL );
$found = 0;
foreach( $arrVals as $index => $value )
{
if( $value == $name )
{
$found = $index;
}
}
$place = $found + 1;
return $arrVals[ $place ];
}
}
/**
* Debugging helper function
*/
if( !function_exists( 'p' ) ){
function p( $var, $return = FALSE )
{
$content = '<pre>';
$content.= print_r( $var, TRUE );
$content.= '</pre>';
if( !$return ){
echo $content;
}
return $content;
}
}
function fpfpi_get_asset_url( $name, $mode = '', $force = false ) {
$urlpath = 'assets/';
$can_min = true;
switch ( $mode ) {
case 'css':
$urlpath .= 'dist/css/' . $name . '.css';
break;
case 'js':
$urlpath .= 'dist/js/' . $name . '.js';
break;
case 'png':
case 'gif':
case 'svg':
$urlpath .= 'dist/img/' . $name . '.' . $mode;
$can_min = false;
break;
case 'vendor-css':
$urlpath .= 'vendor/' . $name . '.css';
break;
case 'vendor-js':
$urlpath .= 'vendor/' . $name . '.js';
break;
default:
return '';
}
if ( $can_min && ! $force ) {
if ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) {
$urlpath = explode( '.', $urlpath );
array_splice( $urlpath, count( $urlpath ) - 1, 0, 'min' );
$urlpath = implode( '.', $urlpath );
}
}
$file = FBFPI_URLPATH.$urlpath;
return FBFPI_URLPATH.$urlpath;
}