PluginProbe
Name Directory / 1.11
Name Directory v1.11
1.34.1 1.34.0 trunk 1.10 1.11 1.11.1 1.11.2 1.11.3 1.11.4 1.11.5 1.11.6 1.12 1.13 1.13.1 1.13.2 1.13.3 1.13.4 1.13.5 1.13.6 1.13.7 1.14 1.14.1 1.14.2 1.15 1.15.1 All 91 releases
name-directory / install.php

install.php in Name Directory 1.11, at install.php

171 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /* Protection! */
3 if (! function_exists('add_action'))
4 {
5 echo 'Nothing to See here. Move along now people.';
6 exit;
7 }
8
9 /**
10 * Delta the Directory table
11 */
12 function name_directory_install_list()
13 {
14 global $wpdb;
15 global $name_directory_table_directory;
16 global $name_directory_db_version;
17
18 $installed_ver = get_option( "jal_db_version" );
19
20 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
21
22 $sql = "CREATE TABLE $name_directory_table_directory (
23 id INT( 11 ) NOT NULL AUTO_INCREMENT,
24 name VARCHAR( 255 ) NOT NULL,
25 show_title BOOLEAN NULL,
26 show_description BOOLEAN NULL DEFAULT 1,
27 show_submit_form BOOLEAN NULL,
28 show_submitter_name BOOLEAN NULL,
29 show_line_between_names BOOLEAN NULL,
30 show_search_form BOOLEAN NULL,
31 show_all_names_on_index BOOLEAN NULL DEFAULT 1,
32 show_all_index_letters BOOLEAN NULL DEFAULT 1,
33 jump_to_search_results BOOLEAN NULL DEFAULT 0,
34 nr_columns INT( 1 ) NULL,
35 nr_most_recent INT(5) NULL DEFAULT 0,
36 nr_words_description INT(5) NULL DEFAULT 0,
37 description TEXT NOT NULL,
38 name_term VARCHAR( 255 ) NOT NULL,
39 UNIQUE KEY id (id),
40 PRIMARY KEY (id)
41 );";
42
43 dbDelta($sql);
44
45 if($installed_ver != $name_directory_db_version)
46 {
47 $sql = "CREATE TABLE $name_directory_table_directory (
48 id INT( 11 ) NOT NULL AUTO_INCREMENT,
49 name VARCHAR( 255 ) NOT NULL,
50 show_title BOOLEAN NULL,
51 show_description BOOLEAN NULL DEFAULT 1,
52 show_submit_form BOOLEAN NULL,
53 show_submitter_name BOOLEAN NULL,
54 show_line_between_names BOOLEAN NULL,
55 show_search_form BOOLEAN NULL,
56 show_all_names_on_index BOOLEAN NULL DEFAULT 1,
57 show_all_index_letters BOOLEAN NULL DEFAULT 1,
58 jump_to_search_results BOOLEAN NULL DEFAULT 0,
59 nr_columns INT( 1 ) NULL,
60 nr_most_recent INT(5) NULL DEFAULT 0,
61 nr_words_description INT(5) NULL DEFAULT 0,
62 description TEXT NOT NULL,
63 name_term VARCHAR( 255 ) NOT NULL,
64 UNIQUE KEY id (id),
65 PRIMARY KEY (id)
66 );";
67
68 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
69 dbDelta( $sql );
70
71 $convert_dirs = "UPDATE $name_directory_table_directory SET `show_all_names_on_index`=1 WHERE `show_all_names_on_index` IS NULL;";
72 $wpdb->query($convert_dirs);
73
74 update_option("name_directory_db_version", $name_directory_db_version);
75 }
76 }
77
78 /**
79 * Delta the Directory Names table
80 */
81 function name_directory_install_names()
82 {
83 global $name_directory_table_directory_name;
84 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
85
86 $sqlnames = "CREATE TABLE $name_directory_table_directory_name (
87 id INT( 11 ) NOT NULL AUTO_INCREMENT,
88 directory INT( 11 ) NOT NULL ,
89 name VARCHAR( 255 ) NOT NULL ,
90 letter VARCHAR( 1 ) NOT NULL ,
91 description TEXT NULL ,
92 published BOOL NOT NULL ,
93 submitted_by VARCHAR( 255 ) NULL,
94 UNIQUE KEY id (id),
95 PRIMARY KEY (id)
96 );";
97 dbDelta($sqlnames);
98 }
99
100
101 /**
102 * Convert tables to UTF8
103 */
104 function name_directory_convert_to_utf8()
105 {
106 global $wpdb;
107 global $name_directory_table_directory;
108 global $name_directory_table_directory_name;
109
110 $convert_dirs = "ALTER TABLE $name_directory_table_directory CONVERT TO CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';";
111 $wpdb->query($convert_dirs);
112
113 $convert_names = "ALTER TABLE $name_directory_table_directory_name CONVERT TO CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';";
114 $wpdb->query($convert_names);
115 }
116
117
118 /**
119 * Install some sample data on first install
120 */
121 function name_directory_install_data()
122 {
123 global $wpdb;
124 global $name_directory_table_directory;
125 global $name_directory_table_directory_name;
126
127 // Only insert sample data when there is no data
128 $wpdb->query(sprintf("SELECT * FROM " . $name_directory_table_directory));
129 if($wpdb->num_rows === 0)
130 {
131 $wpdb->insert($name_directory_table_directory, array(
132 'id' => 1,
133 'name' => 'Bird names',
134 'show_title' => 1,
135 'show_description' => 1,
136 'show_submit_form' => 1,
137 'show_submitter_name' => 0,
138 'show_line_between_names' => 1,
139 'show_line_between_names' => 1,
140 'show_search_form' => 1,
141 'show_all_names_on_index' => 1,
142 'jump_to_search_results' => 0,
143 'nr_most_recent' => 0,
144 'nr_words_description' => 0,
145 'description' => 'Cool budgie names',
146 'name_term' => ''
147 ));
148 $wpdb->insert($name_directory_table_directory_name, array(
149 'directory' => 1,
150 'name' => 'Navi',
151 'letter' => 'N',
152 'description' => 'Navi is a good aviator and navigator. A very strong and big budgie, almost English',
153 'published' => 1
154 ));
155 $wpdb->insert($name_directory_table_directory_name, array(
156 'directory' => 1,
157 'name' => 'Mister',
158 'letter' => 'M',
159 'description' => 'Mister is a name which can only be assigned to a typical English Budgie. Big, strong and stringent.',
160 'published' => 1
161 ));
162 $wpdb->insert($name_directory_table_directory_name, array(
163 'directory' => 1,
164 'name' => 'Isa',
165 'letter' => 'I',
166 'description' => 'Isa is a direct descent of Mister. As a fullblood daughter she is also a typical English Budgie.',
167 'published' => 1
168 ));
169 }
170 }
171