-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmobileframe_main_class.php
More file actions
162 lines (145 loc) · 5.07 KB
/
mobileframe_main_class.php
File metadata and controls
162 lines (145 loc) · 5.07 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
/*
@wordpress-plugin
Plugin Name: Framework Mobilede
Author: Domisiding
Author URI: https://domisiding.de
Description: Man kann nun, ganz einfach seinen Fahrzeugbestand von Mobile.de mit einem Framework auf seiner Webseite anzeigen lassen.
Version: 1.5
Text Domain: mobileframe
License: GNU General Public License v2
*/
//////////////////////////// Schutz //////////////////////////
if ( ! defined( 'WPINC' ) ) {
die;
}
//////////////////////////// Add ////////////////////////////
add_action( 'wp_enqueue_scripts', 'mobileframe_register_plugin_styles' );
add_shortcode('mobileframe', 'mobileframe_start');
add_action('admin_menu', 'mobileframe_create_adminmenu');
add_action('mobileframe_translation', 'mobileframe_load_plugin_textdomain');
///////////////////////// Translation ///////////////////////
$plugin_header_translate = array( __('Mobilede Framework', 'mobileframe'), __('Man kann nun, ganz einfach seinen Fahrzeugbestand von Mobile.de mit einem Framework auf seiner Webseite anzeigen lassen.', 'mobileframe') );
function mobileframe_load_plugin_textdomain() {
load_plugin_textdomain( 'mobileframe', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
}
///////////////////////// Menü //////////////////////////
function mobileframe_create_adminmenu() {
add_menu_page('Mobilede Framework', 'Mobileframe', 'manage_options', __FILE__, 'mobileframe_page',plugins_url('/images/icon.png', __FILE__));
$admin_stylesheet = plugins_url( 'style/mobileframe.css', __FILE__ );
wp_register_style( 'mobileframe_admin_style', $admin_stylesheet );
wp_enqueue_style( 'mobileframe_admin_style' );
add_action( 'admin_init', 'mobileframe_settings' );
}
///////////////////////// Seite //////////////////////////
function mobileframe_page()
{
?>
<div class="wrap mobileframe_admin_wrap">
<h2 class="box_50">
Mobilede Framework
</h2>
<div class="box_100">
<p>
<?php _e('Um ihren Fahrzeugbestand auf einer Seite zu zeigen, verwenden Sie einfach folgenden Shortcode "[mobileframe].', 'mobileframe'); ?>
</p>
<form id="mobileframe_optionsform" method="post" action="options.php">
<?php settings_fields( 'mobileframe-group' ); ?>
<?php do_settings_sections( 'mobileframe-group' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row" colspan="2"><strong><?php _e('Im folgenden Bereich müssen Sie ihren Bestandslink hinterlegen', 'mobileframe'); ?></strong></th>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Bestandslink', 'mobileframe'); ?><br><span style="text_italic"><?php _e('(Die "customerID" ist in ihrem Administrationsbereich von Mobile.de)', 'mobileframe'); ?></span></th>
<td>
<input class="form_text" type="text" name="mobileframe_link" value="<?php echo get_option('mobileframe_link'); ?>" />
<?php _e('Beispiel:', 'mobileframe'); ?><span class="text_italic">https://home.mobile.de/home/index.html?partnerHead=false&colorTheme=default&customerId=xxxxxx</span>
</td>
</tr>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
<?php }
///////////////////////// Einstellungen //////////////////////////
function mobileframe_settings()
{
add_option('mobileframe_color', 'default');
add_option('mobileframe_styles',
'
#mobileframe-frame
{
margin: 0;
width: 100%;
height: 600px;
}
#mobileframe-wrapper
{
width: 100%;
padding: 10px;
background: rgba(223, 223, 223, 0.9);
}
');
register_setting( 'mobileframe-group', 'mobileframe_link' );
register_setting( 'mobileframe-group', 'mobileframe_styles' );
}
///////////////////////// Style //////////////////////////
function mobileframe_register_plugin_styles()
{
wp_register_style( 'mobileframe_style', plugins_url( 'style/mobileframe.css', __FILE__ ) ) ;
wp_enqueue_style( 'mobileframe_style' );
}
///////////////////////// Start //////////////////////////
function mobileframe_start()
{
if(get_option('mobileframe_link')&&get_option('mobileframe_link')!="")
{
$mobile_link=get_option('mobileframe_link');
}
else unset($mobile_link);
if(isset($mobile_link))
{
$url_array = parse_url ( $mobile_link );
$query_para=array();
parse_str($url_array['query'], $query_para);
$new_query="";
$para_count=0;
while(list($key,$val)=each($query_para))
{
if($para_count!=0) $new_query.="&";
$new_query.= $key."=".$val;
$para_count++;
}
$url_array['query']=$new_query;
$url_array['key']=$new_query;
$mobile_link="https://home.mobile.de/home/index.html?".$url_array['key'];
}
?>
<?php
if(isset($mobile_styles))
{
?>
<style type="text/style">
<?php
echo $mobile_styles;
?>
</style>
<?php
}
?>
<div id="mobileframe-wrapper">
<?php
if(isset($mobile_link))
{
?>
<iframe id="mobileframe-frame" src="<?php echo $mobile_link;?>"></iframe>
<?php
}
else echo "<p>Unsere Fahrzeuge, stehen Ihn bald zur Verfügung.</p>"
?>
</div>
<?php
}
?>