Esempio n. 1
0
/**
* Activate the plugin
*/
function vmp_activate()
{
    global $wpdb;
    // create the table to record up and down votes for each individual posts
    $wpdb->query("CREATE TABLE IF NOT EXISTS " . TABLE_2 . " (\r\n\t\t\t\t\tid int(11) not null auto_increment,\r\n\t\t\t\t\tpost_id bigint(20) null,\r\n\t\t\t\t\tupvote_count int(11) not null,\r\n\t\t\t\t\tdownvote_count int(11) not null,\r\n\t\t\t\t\tprimary key (id)\r\n\t\t\t\t\t) ENGINE=INNODB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
    // create the table to record which post is set for registered user voting and which one is for open voting
    $wpdb->query("CREATE TABLE IF NOT EXISTS " . TABLE_3 . " (\r\n\t\t\t\t\tid int(11) not null auto_increment,\r\n\t\t\t\t\tpost_id bigint(20) not null,\r\n\t\t\t\t\tvote_mode tinyint(1) not null,\r\n\t\t\t\t\tprimary key (id)\r\n\t\t\t\t\t) ENGINE=INNODB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
    // create the table to record which registered user has voted for which post
    $wpdb->query("CREATE TABLE IF NOT EXISTS " . TABLE_4 . " (\r\n\t\t\t\t\tid int(11) not null auto_increment,\r\n\t\t\t\t\tuser_id bigint(20) not null,\r\n\t\t\t\t\tpost_id bigint(20) not null,\r\n\t\t\t\t\tprimary key (id)\r\n\t\t\t\t\t) ENGINE=INNODB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
    // create the table to record the positioning and orientation of voting links
    $wpdb->query("CREATE TABLE IF NOT EXISTS " . TABLE_5 . " (\r\n\t\t\t\t\tid int(11) not null auto_increment,\r\n\t\t\t\t\tposition tinyint(1) not null,\r\n\t\t\t\t\torientation tinyint(1) not null,\r\n\t\t\t\t\tprimary key (id)\r\n\t\t\t\t\t) ENGINE=INNODB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
    // create the table to record the positioning and orientation of voting links
    $wpdb->query("CREATE TABLE IF NOT EXISTS " . TABLE_6 . " (\r\n\t\t\t\t\tid int not null auto_increment,\r\n\t\t\t\t\trepeat_voting tinyint not null default 1,\r\n\t\t\t\t\tvoting_interval int not null default 120,\r\n\t\t\t\t\trow_per_page smallint not null default 5,\r\n\t\t\t\t\tmax_link smallint not null default 7,\r\n\t\t\t\t\tneighbour smallint not null default 3,\r\n\t\t\t\t\tprimary key (id)\r\n\t\t\t\t\t) ENGINE=INNODB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
    // load settings
    $settings = array();
    $settings = vmp_fetch_settings();
    define('REGISTERED_USER_REPEAT_VOTING', $settings[0]);
    define('COOKIE_EXPIRATION_TIME', $settings[1]);
    define('VMP_ROW_PER_PAGE', $settings[2]);
    define('VMP_MAX_PAGE_LINK', $settings[3]);
    define('VMP_NEIGHBOR', $settings[4]);
}
    ?>
<div id="vmp_message_panel_alt" align="center" style="display:none;">
<?php 
    echo $_SESSION['messages'];
    unset($_SESSION['messages']);
    ?>
</div>
<?php 
}
?>
<div class="main_panel" align="center">
	<?php 
$_wpnonce = wp_create_nonce('set_plugin_options');
$action = admin_url('admin.php?action=set_plugin_options_092113&_wpnonce=' . $_wpnonce);
$settings = array();
$settings = vmp_fetch_settings();
if (1 == $settings[0]) {
    $checked_1 = 'checked';
    $checked_2 = '';
} else {
    $checked_1 = '';
    $checked_2 = 'checked';
}
?>
	<form name="vmp_set_plugin_options" id="vmp_set_plugin_options" action="<?php 
echo $action;
?>
" method="post"/>
		<table class="wp-list-table widefat" cellspacing="0">
			<thead>
				<tr>