array('color' => 'aa0', 'text' => sprintf(__('Your FormID is empty (Get your FormID.)'), 'http://keypic.com/modules/register/')),
'key_valid' => array('color' => '4AB915', 'text' => __('This FormID is valid.')),
'key_not_valid' => array('color' => 'aaa', 'text' => __('This FormID is NOT valid.')),
);
$plugins = array
(
// Wordpress builtin plugins
'register' => array('Name' => 'Registration Form details', 'builtin' => 1),
'login' => array('Name' => 'Login Form details', 'builtin' => 1),
'comments' => array('Name' => 'Comment Form details', 'builtin' => 1),
'lostpassword' => array('Name' => 'Lostpassword Form details', 'builtin' => 1),
// Custom Plugins here
'contact_form_7' => array('Name' => 'Contact Form 7', 'builtin' => 0),
);
function keypic_admin_init()
{
global $wp_version;
// all admin functions are disabled in old versions
if(!function_exists('is_multisite') && version_compare($wp_version, '3.0', '<' ))
{
function keypic_version_warning()
{
echo "
".sprintf(__('Keypic %s requires WordPress 3.0 or higher.'), KEYPIC_VERSION) . " " . sprintf(__('Please upgrade WordPress to a current version.'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/keypic/download/') . "
";
}
add_action('admin_notices', 'keypic_version_warning');
return;
}
}
function keypic_config_page()
{
if(function_exists('add_submenu_page'))
{
add_submenu_page('plugins.php', __('Keypic Configuration'), __('Keypic Configuration'), 'manage_options', 'keypic-key-config', 'keypic_conf');
add_menu_page('custom menu title', 'Keypic', 'administrator', 'plugins.php?page=keypic-key-config', '', KEYPIC_PLUGIN_URL .'/menu-icon.png');
}
}
function keypic_plugin_action_links( $links, $file )
{
if( $file == plugin_basename( dirname(__FILE__).'/keypic.php'))
{
$links[] = ''.__('Settings').'';
}
return $links;
}
add_filter( 'plugin_action_links', 'keypic_plugin_action_links', 10, 2 );
function keypic_report_spam_and_delete_comment()
{
global $keypic_comments, $FormID;
if(!(isset($_GET['id']) || (isset($_REQUEST['action']) && 'keypic_report_spam_and_delete_comment' == $_REQUEST['action']))){return;}
$comment = $keypic_comments[$_GET['id']];
Keypic::reportSpam($comment['token']);
wp_delete_comment($_GET['id']);
wp_redirect( $_SERVER['HTTP_REFERER'] );
die();
}
add_action('admin_action_keypic_report_spam_and_delete_comment', 'keypic_report_spam_and_delete_comment');
function keypic_report_spam_and_delete_user()
{
global $FormID;
if(!(isset($_GET['id']) || (isset($_REQUEST['action']) && 'keypic_report_spam_and_delete_user' == $_REQUEST['action']))){return;}
$keypic_users = get_option('keypic_users');
$user = $keypic_users[$_GET['id']];
Keypic::reportSpam($user['token']);
wp_delete_user($_GET['id']);
wp_redirect( $_SERVER['HTTP_REFERER'] );
die();
}
add_action('admin_action_keypic_report_spam_and_delete_user', 'keypic_report_spam_and_delete_user');
function plugins_list()
{
global $plugins;
$output = array();
foreach(get_plugins() as $plugin_file => $plugin_data)
{
foreach($plugins as $k => $v)
{
if($v['builtin'] == 1)
{
$output[$k] = $v;
}
else
{
if(is_plugin_active($plugin_file))
{
if($plugin_data['Name'] == $v['Name'])
{
$output[$k] = $v;
}
}
}
}
}
return $output;
}
function keypic_conf()
{
global $keypic_details, $ms, $messages;
$FormID = isset($keypic_details['FormID']) ? $keypic_details['FormID'] : '' ;
$submit1 = isset($_POST['submit1']) ? $_POST['submit1'] : '';
if($submit1 == 'submit1')
{
$FormID = $_POST['formid'];
if(empty($FormID)){$ms[] = 'key_empty';}
else{$FormID = strtolower($FormID);}
$response = Keypic::checkFormID($FormID);
if($response['status'] == 'response'){$ms[] = 'key_valid'; $keypic_details['FormID'] = $FormID; update_option('keypic_details', $keypic_details);}
else if($response['status'] == 'error')
{
$ms[] = 'key_not_valid';
if($FormID != ''){$FormID = '';}
$keypic_details['FormID'] = $FormID;
update_option('keypic_details', $keypic_details);
}
}
else
{
if($FormID == ''){$ms[] = 'key_empty';}
}
$submit2 = isset($_POST['submit2']) ? $_POST['submit2'] : '';
if($submit2 == 'submit2')
{
foreach(plugins_list() as $k => $v)
{
$RequestType = isset($_POST[$k.'_requesttype']) ? $_POST[$k.'_requesttype'] : '';
$WeighthEight = isset($_POST[$k.'_weightheight']) ? $_POST[$k.'_weightheight'] : '';
$enabled = isset($_POST[$k.'_enabled']) ? $_POST[$k.'_enabled'] : '';
$keypic_details[$k] = array('RequestType' => $RequestType, 'WeighthEight' => $WeighthEight, 'enabled' => $enabled);
}
update_option('keypic_details', $keypic_details);
}
else
{
if($FormID == ''){$ms[] = 'key_empty';}
}
echo '' . __('Keypic Configuration') . ' - Version ' . KEYPIC_VERSION .'
';
// Form
echo '';
// Form
echo '';
}
?>