-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbanner.php
More file actions
160 lines (126 loc) · 4.83 KB
/
Copy pathbanner.php
File metadata and controls
160 lines (126 loc) · 4.83 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
<?php
/*
Plugin Name: Banner Maker
Plugin URI: http://bannermakerwp.com
Description: Create banners with many different effects
Author: fruitfulcode
Author URI: http://fruitfulcode.com
*/
global $wpdb;
$currentFile = __FILE__;
$currentFolder = dirname($currentFile);
// base prefix
define('BASE_BANNER', $wpdb->prefix . 'banner_maker');
define('BASE_SETTINGS', $wpdb->prefix . 'banner_settings');
//file folders
define('BANNER_DIR',plugin_basename( __FILE__ ));
define('BANNER_INC',$currentFolder . '/inc');
define('BANNER_SCRIPTS',$currentFolder . '/scripts');
define('BANNER_IMG',plugins_url('/img',__FILE__));
//include files
require_once BANNER_INC.'/effect.php';
require_once BANNER_INC.'/function.php';
require_once BANNER_INC.'/shortcode.php';
require_once BANNER_INC.'/file.php';
require_once 'init.php';
register_activation_hook(BANNER_DIR,'banner_install');
register_deactivation_hook(BANNER_DIR, 'banner_deactivation');
register_uninstall_hook(BANNER_DIR, 'banner_delete');
function banner_install () {
/*register function*/
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
global $wpdb;
$banner_prefs_table = BASE_BANNER;
if($wpdb->get_var("SHOW TABLES LIKE '$banner_prefs_table'") != $banner_prefs_table) {
$sql = "CREATE TABLE `" . $banner_prefs_table . "` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL default '',
`height` INT NOT NULL,
`width` INT NOT NULL,
`url` VARCHAR(255) NOT NULL default '',
`click` INT NOT NULL,
`background` VARCHAR(255) NOT NULL default '',
UNIQUE KEY id (id)
)CHARACTER SET=utf8";
dbDelta($sql);
load_default_banner ();
}
$banner_prefs_table = BASE_SETTINGS;
if($wpdb->get_var("SHOW TABLES LIKE '$banner_prefs_table'") != $banner_prefs_table) {
$sql = "CREATE TABLE `" . $banner_prefs_table . "` (
`id` INT NOT NULL,
`settings` LONGTEXT NOT NULL default '',
UNIQUE KEY id (id)
)CHARACTER SET=utf8";
dbDelta($sql);
}
}
function banner_deactivation () {
/*unregister function*/
}
function banner_delete () {
/*delete function*/
global $wpdb;
$banner_prefs_table = BASE_BANNER;
if($wpdb->get_var("SHOW TABLES LIKE '$banner_prefs_table'") == $banner_prefs_table) {
$sql = "DROP TABLE `" . $banner_prefs_table . "`";
$wpdb->query($sql);
}
unset($sql);
$banner_prefs_setting_table = BASE_SETTINGS;
if($wpdb->get_var("SHOW TABLES LIKE '$banner_prefs_setting_table'") == $banner_prefs_setting_table) {
$sql = "DROP TABLE `" . $banner_prefs_setting_table . "`";
$wpdb->query($sql);
}
}
/*Art - add pages*/
add_action('admin_menu', 'banner_add_pages');
function banner_add_pages() {
add_menu_page('bannercreator', 'Banners', 8, 'banner', 'banner_page');
}
function banner_page() {
echo "<div id='head_line'><img id='logo' src='".plugins_url('/img/banner_logo.jpg',__FILE__)."' /><h2>Banner Maker</h2></div>";
$active = getBannerPage();
if($active == "show" or !$active or $active == "delete" or $active == "copy") {
$out .= "<div id='banners_page'><table>";
$out .= '<thead><tr><td class="grid_B_1">ID</td>
<td class="grid_B_2">Name</td>
<td class="grid_B_3">Shortcode</td>
<td class="grid_B_3">Settings</td>
<td class="grid_B_1">Clicks</td>
<td class="grid_B_1">Preview</td></tr></thead>';
$out .= get_my_banners();
$out .= '</table>';
$out .= "<a class='add_banner' href='".$_SERVER["PHP_SELF"]."?page=banner&status=create'>add new banner</a></div>";
echo $out.'<div id="show_preview"></div>';
}
}
/*Art - get banners */
function get_my_banners() {
global $wpdb;
$count = 0;
$banner_prefs_table = BASE_BANNER;
$sql = "select * from $banner_prefs_table";
$check = $wpdb->get_results($sql);
foreach($check as $line){
$count++;
$prefix = ($count%2 == 0) ? 'pink' : '';
$out .= '<tr class='.$prefix.'>';
$id = '';
foreach($line as $key => $value){
if($key == "id") { $out .= '<td>'.$value.'</td>';$id = $value; }
if($key == "name") { $out .= '<td>'.$value.'</td>'; }
if($key == "click") { $click = $value; }
}
$out .= '<td>[bannermaker id="'.$id.'"]</td>';
$out .= '<td><a href="'.$_SERVER["PHP_SELF"].'?page=banner&status=edit&id='.$id.'" class="edit_but">edit</a>';
$out .= '<a href="'.$_SERVER["PHP_SELF"].'?page=banner&status=copy&id='.$id.'" class="copy_but">copy</a>';
$out .= '<a href="'.$_SERVER["PHP_SELF"].'?page=banner&status=delete&id='.$id.'" class="delete_but">delete</a></td>';
$out .= '<td><span class="click">'.$click.'</span></td>';
$out .= '<td><a class="view_but show_preview" data_id="'.$id.'">viev</a></td>';
$out .= '</tr>';
}
if(!$check) { $out = '<tr><td>-</td><td>no banners found</td><td></td><td></td><td></td><td></td></tr>'; }
return $out;
}
?>