Пример #1
0
function se_install()
{
    $se_meta = array('blog_id' => false, 'api_key' => false, 'auth_key' => false, 'version' => SE_VERSION, 'first_version' => SE_VERSION, 'new_user' => true, 'name' => '', 'email' => '', 'show_options_page_notice' => false);
    $se_options = se_get_default_options();
    update_option('se_meta', $se_meta);
    update_option('se_options', $se_options);
    se_set_global_notice();
}
Пример #2
0
 function se_option_page()
 {
     global $wpdb, $table_prefix, $wp_version;
     if ($_POST) {
         check_admin_referer('se-everything-nonce');
         $errors = $this->se_validation(array("highlight_color" => "color", "highlight_style" => "css", "exclude_categories_list" => "numeric-comma", "exclude_posts_list" => "numeric-comma"));
         if ($errors) {
             $fields = array("highlight_color" => __('Highlight Background Color', 'SearchEverything'), "highlight_style" => __('Full Highlight Style', 'SearchEverything'), "exclude_categories_list" => __('Exclude Categories', 'SearchEverything'), "exclude_posts_list" => __('Exclude some post or page IDs', 'SearchEverything'));
             include se_get_view('options_page_errors');
             return;
         }
     }
     $new_options = array('se_exclude_categories' => isset($_POST['exclude_categories']) && !empty($_POST['exclude_categories']) ? $_POST['exclude_categories'] : '', 'se_exclude_categories_list' => isset($_POST['exclude_categories_list']) && !empty($_POST['exclude_categories_list']) ? $_POST['exclude_categories_list'] : '', 'se_exclude_posts' => isset($_POST['exclude_posts']) ? $_POST['exclude_posts'] : '', 'se_exclude_posts_list' => isset($_POST['exclude_posts_list']) && !empty($_POST['exclude_posts_list']) ? $_POST['exclude_posts_list'] : '', 'se_use_page_search' => isset($_POST['search_pages']) && $_POST['search_pages'], 'se_use_comment_search' => isset($_POST['search_comments']) && $_POST['search_comments'], 'se_use_tag_search' => isset($_POST['search_tags']) && $_POST['search_tags'], 'se_use_tax_search' => isset($_POST['search_taxonomies']) && $_POST['search_taxonomies'], 'se_use_category_search' => isset($_POST['search_categories']) && $_POST['search_categories'], 'se_approved_comments_only' => isset($_POST['appvd_comments']) && $_POST['appvd_comments'], 'se_approved_pages_only' => isset($_POST['appvd_pages']) && $_POST['appvd_pages'], 'se_use_excerpt_search' => isset($_POST['search_excerpt']) && $_POST['search_excerpt'], 'se_use_draft_search' => isset($_POST['search_drafts']) && $_POST['search_drafts'], 'se_use_attachment_search' => isset($_POST['search_attachments']) && $_POST['search_attachments'], 'se_use_authors' => isset($_POST['search_authors']) && $_POST['search_authors'], 'se_use_cmt_authors' => isset($_POST['search_cmt_authors']) && $_POST['search_cmt_authors'], 'se_use_metadata_search' => isset($_POST['search_metadata']) && $_POST['search_metadata'], 'se_use_highlight' => isset($_POST['search_highlight']) && $_POST['search_highlight'], 'se_highlight_color' => isset($_POST['highlight_color']) ? $_POST['highlight_color'] : '', 'se_highlight_style' => isset($_POST['highlight_style']) ? $_POST['highlight_style'] : '', 'se_research_metabox' => array('visible_on_compose' => isset($_POST['research_metabox']) && $_POST['research_metabox'], 'external_search_enabled' => isset($_POST['research_external_results']) && $_POST['research_external_results']));
     if (isset($_POST['action']) && $_POST['action'] == "save") {
         echo "<div class=\"updated fade\" id=\"limitcatsupdatenotice\"><p>" . __('Your default search settings have been <strong>updated</strong> by Search Everything. </p><p> What are you waiting for? Go check out the new search results!', 'SearchEverything') . "</p></div>";
         se_update_options($new_options);
     }
     if (isset($_POST['action']) && $_POST['action'] == "reset") {
         echo "<div class=\"updated fade\" id=\"limitcatsupdatenotice\"><p>" . __('Your default search settings have been <strong>updated</strong> by Search Everything. </p><p> What are you waiting for? Go check out the new search results!', 'SearchEverything') . "</p></div>";
         $default_options = se_get_default_options();
         se_update_options($default_options);
     }
     $options = se_get_options();
     $meta = se_get_meta();
     //get api key if it doesn't exist
     if ($options['se_research_metabox']['external_search_enabled'] && empty($meta['api_key'])) {
         $api_key = fetch_api_key();
         $meta['api_key'] = $api_key;
         se_update_meta($meta);
     }
     if ($options['se_research_metabox']['external_search_enabled'] && !empty($meta['api_key'])) {
         se_get_prefs();
     }
     $response_messages = se_get_response_messages();
     $external_message = "";
     if (!empty($meta['api_key']) && empty($meta['sfid'])) {
         $sfid_response = get_sfid();
         if (!empty($sfid_response[0])) {
             $meta['sfid'] = $sfid_response[1];
             se_update_meta($meta);
         }
         $external_message = !empty($response_messages[$sfid_response[1]]) ? $response_messages[$sfid_response[1]] : $response_messages[SE_PREFS_STATE_FAILED];
     } elseif (!empty($meta['sfid'])) {
         $external_message = $response_messages[SE_PREFS_STATE_FOUND];
     }
     include se_get_view('options_page');
 }