-
Notifications
You must be signed in to change notification settings - Fork 1
/
tutty-metabox-framework-helper.php
38 lines (33 loc) · 1.46 KB
/
tutty-metabox-framework-helper.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
<?php if( ! defined( 'ABSPATH' ) ) { die; }
if( ! function_exists( 'tutty_locate' ) ) {
function tutty_locate() {
$dirname = wp_normalize_path( dirname( __FILE__ ) );
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
$located_plugin = ( preg_match( '#'. preg_replace( '/[^A-Za-z]/', '', $plugin_dir ) .'#', preg_replace( '/[^A-Za-z]/', '', $dirname ) ) ) ? true : false;
$directory = ( $located_plugin ) ? $plugin_dir : get_template_directory();
$directory_uri = ( $located_plugin ) ? WP_PLUGIN_URL : get_template_directory_uri();
$basename = str_replace( wp_normalize_path( $directory ), '', $dirname );
$dir = $directory . $basename;
$uri = $directory_uri . $basename;
return array(
'basename' => wp_normalize_path( $basename ),
'dir' => wp_normalize_path( $dir ),
'uri' => $uri
);
}
}
if( ! function_exists( 'tutty_get_file' ) ) {
function tutty_get_file( $file ) {
$file = TT_PATH . '/' . $file;
if( file_exists( $file ) ) {
require_once $file;
}
}
}
if( ! function_exists( 'tutty_admin_enqueue' ) ) {
function tutty_admin_enqueue() {
wp_enqueue_style( 'tutty', TT_URL . '/assets/tutty_metabox.css' );
wp_enqueue_script( 'tutty', TT_URL . '/assets/tutty_metabox.js' );
}
add_action( 'admin_enqueue_scripts', 'tutty_admin_enqueue' );
}