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 '
'; echo '

' . __('For many people, Keypic will greatly reduce or even completely eliminate the comment and trackback spam you get on your site. If one does happen to get through, simply mark it as "spam" on the moderation screen and Keypic will learn from the mistakes. If you don\'t have an API FormID yet, you can get one at keypic.com.') . '

'; echo '

'; foreach($ms as $m): echo '

' . $messages[$m]['text'] . '

'; endforeach; echo '

(' . __('What is this?') . ')

'; if(isset( $invalid_key) && $invalid_key) { echo '

' . __('Why might my key be invalid?') . '

'; echo '

' . __('This can mean one of two things, either you copied the key wrong or that the plugin is unable to reach the Keypic servers, which is most often caused by an issue with your web host around firewalls or similar.') . '

'; } echo '

'; echo ''; echo '
'; // Form echo '
'; foreach(plugins_list() as $k => $v) { if($v['builtin'] == 1) { echo '
'; echo '

' . $v['Name'] . '

'; echo '
'; echo 'Enabled?:
'; echo keypic_get_select_enabled($k.'_enabled', $keypic_details[$k]['enabled']) . '
'; if($keypic_details[$k]['enabled'] == 1) { $WeighthEight = isset($keypic_details[$k]['WeighthEight']) ? $keypic_details[$k]['WeighthEight'] : ''; $RequestType = isset($keypic_details[$k]['RequestType']) ? $keypic_details[$k]['RequestType'] : ''; echo 'WeightHeight:
'; echo keypic_get_select_weightheight($k.'_weightheight', $WeighthEight) . '
'; echo 'RequestType:
'; echo keypic_get_select_requesttype($k.'_requesttype', $RequestType) . '
'; echo '

' . __('content preview') . '
'; echo Keypic::getIt($RequestType, $WeighthEight) . '

'; } echo '
'; echo '
'; } else { echo '
'; echo '

' . $v['Name'] . '

'; echo '
'; echo 'Enabled?:
'; echo keypic_get_select_enabled($k.'_enabled', $keypic_details[$k]['enabled']) . '
'; if($keypic_details[$k]['enabled'] == 1) { echo $v['Name'] . ' is enabled and ready to working with Keypic
'; echo '

'; echo '
'; echo '
'; echo '
'; } echo '
'; echo '
'; } } echo '

'; echo ''; echo '
'; } ?>