-
Notifications
You must be signed in to change notification settings - Fork 0
/
da-gifts.php
96 lines (84 loc) · 3.19 KB
/
da-gifts.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
<?php
/*
Plugin Name: Dating Theme Gifts Extended
Plugin URI: http://coderspress.com
Description: Extended set of gift images for Premiumpress - Dating Theme
Version: 2015.0819
Revision Date: 19th August 2015
Author: sMarty
Author URI: http://coderspress.com
WP_Requires: 3.8.1
WP_Compatible: 4.3
License: http://creativecommons.org/licenses/GPL/2.0
*/
add_action( 'init', 'dag_plugin_updater' );
function dag_plugin_updater() {
if ( is_admin() ) {
include_once( dirname( __FILE__ ) . '/updater.php' );
$config = array(
'slug' => plugin_basename( __FILE__ ),
'proper_folder_name' => 'da-gifts',
'api_url' => 'https://api.github.com/repos/CodersPress/da-gifts',
'raw_url' => 'https://raw.github.com/CodersPress/da-gifts/master',
'github_url' => 'https://github.com/CodersPress/da-gifts',
'zip_url' => 'https://github.com/CodersPress/da-gifts/zipball/master',
'sslverify' => true,
'access_token' => '2251a69f71a70ab9368c4dcf706554f23e493e2e',
);
new WP_DAG_UPDATER( $config );
}
}
/* Version - only used for first time install */
define ( 'DA_GIFTS_DB_VERSION', '1' );
function da_gifts_add_admin_menu() {
add_menu_page( 'Dating Gifts', 'DA Gifts Extented', 'manage_options', 'da-gifts-settings', 'da_gifts_admin' );
add_action('admin_init', 'register_dag_settings');
}
function register_dag_settings() {
register_setting("dag-settings-group", "dag_memberShipOnly");
register_setting("dag-settings-group", "dag_displayBox_Height");
}
add_action( 'admin_menu', 'da_gifts_add_admin_menu' );
function da_gifts_activate() {
global $wpdb;
if (get_site_option('da-gifts-db-version') == '') { // if first install load images and create DB table
if ( !empty($wpdb->charset) )
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
$sql[] = "CREATE TABLE {$wpdb->base_prefix}da_gifts (
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
gift_name varchar(100) NOT NULL,
gift_image varchar(100) NOT NULL,
count bigint(20) NOT NULL DEFAULT '0',
KEY gift_name (gift_name)
) {$charset_collate};";
require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
dbDelta($sql);
if ($handle = opendir( dirname( __FILE__ ) . '/includes/images/') ) {
while (false !== ($imagefile = readdir($handle))) {
if (imagefile != 'admin' && imagefile != '' && $imagefile != '.' && imagefile != '..') {
$imagename = explode(".", $imagefile);
if ( $imagename[0] != 'admin' && $imagename[0] != '' ){
$insert = $wpdb->prepare( "INSERT INTO " . $wpdb->base_prefix . "da_gifts ( gift_name, gift_image ) VALUES ( %s, %s )", $imagename[0], $imagefile );
$results = $wpdb->query( $insert );
}
}
}
}
closedir($handle);
}
/* Version Set to 1 so we don't install DB again */
update_site_option( 'da-gifts-db-version', DA_GIFTS_DB_VERSION );
$option = array(
"dag_memberShipOnly" => "yes",
"dag_displayBox_Height" => "395",
);
foreach($option as $key => $value) {
if (get_option($key) == NULL) {
update_option($key, $value);
}
}
return;
}
register_activation_hook( __FILE__, 'da_gifts_activate' );
require( dirname( __FILE__ ) . '/includes/da-gifts-admin.php' );
?>