-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdetect-remote-device.php
114 lines (90 loc) · 3.08 KB
/
detect-remote-device.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
/**
* @wordpress-plugin
* Plugin Name: Detect Remote Device
* Plugin URI: https://github.com/dmhendricks/detect-remote-device
* Description: Adds additional functions and shortcodes to modify output by device type - mobile, tablet or desktop.
* Version: 0.2.0
* Stable tag: 1.0.0
* Requires at least: 4.7
* Requires PHP: 5.6
* Tested up to: 5.1.1
* Author: Daniel M. Hendricks
* Author URI: https://daniel.hn
* License: GPL-2.0
* License URI: https://opensource.org/licenses/GPL-2.0
* Text Domain: detect-remote-device
* Domain Path: /languages
* GitHub Plugin URI: dmhendricks/detect-remote-device
*/
use \CloudVerve\Detect_Remote_Device\Helpers;
ABSPATH || die();
/* Copyright 2019 Daniel M. Hendricks (https://daniel.hn/)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* Load dependencies
*/
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require( __DIR__ . '/vendor/autoload.php' );
} else {
return;
}
/**
* Initialize plugin
*/
\CloudVerve\Detect_Remote_Device\Plugin::instance( __FILE__, dirname( __FILE__ ), plugin_dir_url( __FILE__ ) );
/**
* Global Functions
*/
if( !( defined( 'DMD_DISABLE_GLOBAL_FUNCTIONS' ) && DMD_DISABLE_GLOBAL_FUNCTIONS ) ) {
// Add device_is_mobile() function; similar to wp_is_mobile(), but uses jenssegers/agent library
if( !function_exists( 'device_is_mobile' ) ) {
function device_is_mobile() {
return Helpers::device_is_mobile();
}
}
// Add device_is_phone() function
if( !function_exists( 'device_is_phone' ) ) {
function device_is_phone() {
return Helpers::device_is_phone();
}
}
// Add device_is_tablet() function
if( !function_exists( 'device_is_tablet' ) ) {
function device_is_tablet() {
return Helpers::device_is_tablet();
}
}
// Add device_is_desktop() function
if( !function_exists( 'device_is_desktop' ) ) {
function device_is_desktop() {
return Helpers::device_is_desktop();
}
}
// Add get_the_device_type() function
if( !function_exists( 'get_the_device_type' ) ) {
function get_the_device_type( $args = [ 'header' => null ] ) {
return Helpers::get_device_type( $args );
}
}
// Add get_user_agent() function
if( !function_exists( 'get_user_agent' ) ) {
function get_user_agent( $key = null ) {
return Helpers::get_user_agent( $key );
}
}
}