-
Notifications
You must be signed in to change notification settings - Fork 0
/
leastudios-post-attachments.php
36 lines (35 loc) · 1.33 KB
/
leastudios-post-attachments.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
<?php
/*
* Plugin Name: leaStudios Post Attachments
* Plugin URI: https://adamjohnlea.com/plugins/post-attachments/
* Description: Add files to a post and allow users to download them
* Version: 1.0 alpha
* Author: Adam John Lea
* Author URI: https://adamjohnlea.com
*/
register_activation_hook( __FILE__, 'leastudios_activate' );
function leastudios_activate() {
global $wpdb;
$table_attachments = $wpdb->prefix . 'leastudios_post_attachments';
$sql_attachments = "CREATE TABLE IF NOT EXISTS $table_attachments (
id int(11) NOT NULL AUTO_INCREMENT,
file_name varchar(255) NOT NULL,
user_id int(11) NOT NULL,
post_id int(11) NOT NULL,
file_path longtext NOT NULL,
updated_at datetime NOT NULL,
uploaded_file_name varchar(255) NOT NULL,
PRIMARY KEY (id)
);";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql_attachments );
$default_headers = array('Version' => 'Version');
$plugin_data = get_file_data(__FILE__, $default_headers, 'plug-in');
update_option( 'leastudios_version', $plugin_data['Version'] );
}
if ( ! defined( 'LEASTUDIOS_PLUGIN_DIR' )) {
define( 'LEASTUDIOS_PLUGIN_DIR', plugin_dir_path(__FILE__) );
}
if ( ! defined( 'LEASTUDIOS_PLUGIN_URL' )) {
define( 'LEASTUDIOS_PLUGIN_URL', plugin_dir_url(__FILE__) );
}