$value ) {
if ( isset($_POST[$nonce_form_prefix.$value]) ) {
check_admin_referer($nonce_action_prefix.$value, $nonce_form_prefix.$value);
return true;
}
}
return false;
}
if ( ! empty($_POST) ) {
$nonce_result_check = has_valid_nonce();
if ($nonce_result_check === false) {
die('Unable to save changes. Make sure you are accessing this page from the Wordpress dashboard.');
}
}
if( isset($_POST['dsq_username']) ) {
$_POST['dsq_username'] = stripslashes($_POST['dsq_username']);
}
if( isset($_POST['dsq_password']) ) {
$_POST['dsq_password'] = stripslashes($_POST['dsq_password']);
}
// Handle export function.
if( isset($_POST['export']) and DISQUS_CAN_EXPORT ) {
require_once(dirname(__FILE__) . '/export.php');
dsq_export_wp();
}
// Handle resetting.
if ( isset($_POST['reset']) ) {
foreach (dsq_options() as $opt) {
delete_option($opt);
}
unset($_POST);
dsq_reset_database();
?>
array(
'key_name' => 'dsq_user_api_key',
'min' => 64,
'max' => 64,
),
'disqus_api_key' => array(
'key_name' => 'disqus_api_key',
'min' => 64,
'max' => 64,
),
'disqus_public_key' => array(
'key_name' => 'disqus_public_key',
'min' => 64,
'max' => 64,
),
'disqus_secret_key' => array(
'key_name' => 'disqus_secret_key',
'min' => 64,
'max' => 64,
),
'disqus_partner_key' => array(
'key_name' => 'disqus_partner_key',
'min' => 64,
'max' => 64,
),
'dsq_forum' => array(
'key_name' => 'dsq_forum',
'min' => 1,
'max' => 64,
),
'disqus_forum_url' => array(
'key_name' => 'disqus_forum_url',
'min' => 1,
'max' => 64,
),
'disqus_replace' => array(
'key_name' => 'disqus_replace',
'min' => 3,
'max' => 6,
),
'dsq_username' => array(
'key_name' => 'dsq_username',
'min' => 3,
'max' => 250,
),
);
// Check keys keys and remove bad input.
foreach ( $check_fields as $key ) {
if ( isset($_POST[$key['key_name']]) ) {
// Strip tags before checking
$_POST[$key['key_name']] = trim(strip_tags($_POST[$key['key_name']]));
// Check usernames independently because they can have special characters
// or be email addresses
if ( 'dsq_username' === $key['key_name'] ) {
if ( !is_valid_dsq_username($_POST[$key['key_name']], $key['min'], $key['max']) ) {
unset($_POST[$key['key_name']]);
}
}
else {
if ( !is_valid_dsq_key($_POST[$key['key_name']], $key['min'], $key['max']) ) {
unset($_POST[$key['key_name']]);
}
}
}
}
function is_valid_dsq_username($value, $min=3, $max=250) {
if ( is_email($value) ) {
return true;
}
else {
return is_valid_dsq_key($value, $min, $max);
}
}
function is_valid_dsq_key($value, $min=1, $max=64) {
return preg_match('/^[\0-9\\:A-Za-z_-]{'.$min.','.$max.'}+$/', $value);
}
// Handle advanced options.
if ( isset($_POST['disqus_forum_url']) && isset($_POST['disqus_replace']) ) {
update_option('disqus_partner_key', isset($_POST['disqus_partner_key']) ? esc_attr( trim(stripslashes($_POST['disqus_partner_key'])) ) : '');
update_option('disqus_replace', isset($_POST['disqus_replace']) ? esc_attr( $_POST['disqus_replace'] ) : 'all');
update_option('disqus_cc_fix', isset($_POST['disqus_cc_fix']));
update_option('dsq_external_js', isset($_POST['dsq_external_js']) ? '1' : '0');
update_option('disqus_manual_sync', isset($_POST['disqus_manual_sync']));
update_option('disqus_disable_ssr', isset($_POST['disqus_disable_ssr']));
update_option('disqus_public_key', isset($_POST['disqus_public_key']) ? esc_attr( $_POST['disqus_public_key'] ) : '');
update_option('disqus_secret_key', isset($_POST['disqus_secret_key']) ? esc_attr( $_POST['disqus_secret_key'] ) : '');
// Handle SSO button uploads
if ( version_compare($wp_version, '3.5', '>=') ) {
// Use WP 3.5's new, streamlined, much-improved built-in media uploader
// Only update if a value is actually POSTed, otherwise any time the form is saved the button will be un-set
if ( $_POST['disqus_sso_button'] ) {
update_option('disqus_sso_button', isset($_POST['disqus_sso_button']) ? esc_url( $_POST['disqus_sso_button'] ) : '');
}
} else {
// WP is older than 3.5, use legacy, less-elegant media uploader
if(isset($_FILES['disqus_sso_button'])) {
dsq_image_upload_handler('disqus_sso_button');
}
}
dsq_manage_dialog(dsq_i('Your settings have been changed.'));
}
// handle disqus_active
if ( isset($_POST['active']) && isset($_GET['active']) ) {
update_option('disqus_active', ($_GET['active'] == '1' ? '1' : '0'));
}
$dsq_user_api_key = isset($_POST['dsq_user_api_key']) ? $_POST['dsq_user_api_key'] : null;
// Get installation step process (or 0 if we're already installed).
$step = @intval($_GET['step']);
if ($step > 1 && $step != 3 && $dsq_user_api_key) $step = 1;
elseif ($step == 2 && !isset($_POST['dsq_username'])) $step = 1;
$step = (dsq_is_installed()) ? 0 : ($step ? $step : 1);
// Handle installation process.
if ( 3 == $step && isset($_POST['dsq_forum']) && isset($_POST['dsq_user_api_key']) ) {
list($dsq_forum_id, $dsq_forum_url) = explode(':', $_POST['dsq_forum']);
update_option('disqus_forum_url', esc_attr( $dsq_forum_url ) );
// Output javascript in external files by default
update_option('dsq_external_js', '1');
// Output Javascript in footer by default (no effect when dsq_external_js is enabld)
update_option('disqus_cc_fix', '1');
$api_key = $dsq_api->get_forum_api_key($_POST['dsq_user_api_key'], $dsq_forum_id);
if ( !$api_key || $api_key < 0 ) {
update_option('disqus_replace', 'replace');
dsq_manage_dialog(
dsq_i('There was an error completing the installation of Disqus.')
. ' '
. dsq_i('If you are still having issues, refer to the help documentation.')
. ' '
. ''
. dsq_i('WordPress Help Page')
. '',
true);
} else {
update_option('disqus_api_key', esc_attr( $api_key ));
update_option('disqus_user_api_key', esc_attr( $_POST['dsq_user_api_key']) );
update_option('disqus_replace', 'all');
update_option('disqus_active', '1');
}
if (!empty($_POST['disqus_partner_key'])) {
$partner_key = trim(stripslashes($_POST['disqus_partner_key']));
if (!empty($partner_key)) {
update_option('disqus_partner_key', $partner_key);
}
}
}
if ( 2 == $step && isset($_POST['dsq_username']) && isset($_POST['dsq_password']) ) {
$dsq_user_api_key = $dsq_api->get_user_api_key($_POST['dsq_username'], $_POST['dsq_password']);
if ( $dsq_user_api_key < 0 || !$dsq_user_api_key ) {
$step = 1;
dsq_manage_dialog($dsq_api->get_last_error(), true);
}
if ( $step == 2 ) {
$dsq_sites = $dsq_api->get_forum_list($dsq_user_api_key);
if ( $dsq_sites < 0 ) {
$step = 1;
dsq_manage_dialog($dsq_api->get_last_error(), true);
} else if ( !$dsq_sites ) {
$step = 1;
dsq_manage_dialog(
dsq_i('There aren\'t any sites associated with this account. Maybe you want to create a site?')
. ' '
. ''
. dsq_i('Create a site')
. '',
true);
}
}
}
$show_advanced = (isset($_GET['t']) && $_GET['t'] == 'adv');
?>
- id="dsq-tab-main" rel="dsq-main">
- id="dsq-tab-advanced" rel="dsq-advanced">
>
 ); ?>)
>
Import and Export
Reset