Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ivdimova
committed
Mar 21, 2014
1 parent
36f6eb0
commit 37b8f73
Showing
48 changed files
with
2,734 additions
and
2,006 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,276 @@ | ||
<?php | ||
|
||
global $se_options, $se_meta, $se_global_notice_pages; | ||
$se_options = false; | ||
$se_meta = false; | ||
|
||
$se_global_notice_pages = array('plugins.php', 'index.php', 'update-core.php'); | ||
|
||
$se_response_messages = array( | ||
SE_PREFS_STATE_NOT_ENGLISH => __('<a href="http://support.zemanta.com/customer/portal/articles/674752-which-languages-does-zemanta-support" target="_blank">Your blog is not in English</a>', 'SearchEverything'), | ||
SE_PREFS_STATE_EMPTY => __('Your blog feed is empty', 'SearchEverything'), | ||
SE_PREFS_STATE_FAILED => __('Unable to reslove URL to a source feed' , 'SearchEverything'), | ||
SE_PREFS_STATE_FOUND => __('You are connected to Zemanta network', 'SearchEverything') | ||
); | ||
|
||
function se_get_response_messages() { | ||
global $se_response_messages; | ||
return $se_response_messages; | ||
} | ||
|
||
function se_get_options() { | ||
global $se_options, $se_meta; | ||
if($se_options) { | ||
return $se_options; | ||
} | ||
|
||
$se_options = get_option('se_options', false); | ||
|
||
if(!$se_options || $se_meta['version'] !== SE_VERSION) { | ||
se_upgrade(); | ||
$se_meta = get_option('se_meta'); | ||
$se_options = get_option('se_options'); | ||
} | ||
|
||
$se_meta = new ArrayObject($se_meta); | ||
$se_options = new ArrayObject($se_options); | ||
|
||
return $se_options; | ||
} | ||
|
||
|
||
function se_get_meta() { | ||
global $se_meta; | ||
|
||
if (!$se_meta) { | ||
se_get_options(); | ||
} | ||
return $se_meta; | ||
} | ||
|
||
function se_update_meta($new_meta) { | ||
global $se_meta; | ||
|
||
$new_meta = (array) $new_meta; | ||
|
||
$r = update_option('se_meta', $new_meta); | ||
|
||
if($r && $se_meta !== false) { | ||
$se_meta->exchangeArray($new_meta); | ||
} | ||
|
||
return $r; | ||
} | ||
|
||
function se_update_options($new_options) { | ||
global $se_options; | ||
|
||
$new_options = (array) $new_options; | ||
$r = update_option('se_options', $new_options); | ||
if($r && $se_options !== false) { | ||
$se_options->exchangeArray($new_options); | ||
} | ||
|
||
return $r; | ||
} | ||
|
||
function se_set_global_notice() { | ||
$url = admin_url( 'options-general.php' ); | ||
$url = add_query_arg( array( | ||
'page' => 'extend_search', | ||
'se_global_notice' => 0, | ||
), $url ); | ||
|
||
$se_meta = get_option('se_meta', false); | ||
$se_meta['se_global_notice'] = array( | ||
'title' => 'Search everything has been updated with security fixes!', | ||
'message' => 'Search Everything has been upgraded with security updates and some exciting new features. Visit <a href="'.$url.'">settings</a> to learn more.' | ||
); | ||
se_update_meta($se_meta); | ||
} | ||
|
||
//we have to be careful, as previously version was not stored in the options! | ||
function se_upgrade() { | ||
$se_meta = get_option('se_meta', false); | ||
$version = false; | ||
|
||
if($se_meta) { | ||
$version = $se_meta['version']; | ||
} | ||
|
||
if($version) { | ||
if(version_compare($version, SE_VERSION, '<')) { | ||
call_user_func('se_migrate_' . str_replace('.', '_', $version)); | ||
se_upgrade(); | ||
} | ||
} else { | ||
//check if se_options exist | ||
$se_options = get_option('se_options', false); | ||
if($se_options) { | ||
se_migrate_7_0_1(); //existing users don't have version stored in their db | ||
} else { | ||
se_install(); | ||
} | ||
} | ||
} | ||
|
||
function se_migrate_7_0_4() { | ||
$se_meta = get_option('se_meta', false); | ||
|
||
if ($se_meta) { | ||
$se_meta['version'] = '8.0'; | ||
$se_meta['api_key'] = false; | ||
} | ||
|
||
$se_options = get_option('se_options', false); | ||
|
||
//enable external search | ||
$se_options['se_research_widget'] = array ( | ||
'visible_on_compose' => true, | ||
'external_search_enabled' => false, | ||
'notice_visible' => true, | ||
); | ||
$se_meta['show_options_page_notice'] = false; | ||
|
||
update_option('se_meta',$se_meta); | ||
update_option('se_options',$se_options); | ||
|
||
se_set_global_notice(); | ||
} | ||
|
||
function se_migrate_7_0_3() { | ||
|
||
$se_meta = get_option('se_meta', false); | ||
|
||
if ($se_meta) { | ||
$se_meta['version'] = '7.0.4'; | ||
} | ||
update_option('se_meta',$se_meta); | ||
} | ||
|
||
|
||
function se_migrate_7_0_2() { | ||
|
||
$se_meta = get_option('se_meta', false); | ||
|
||
if ($se_meta) { | ||
$se_meta['version'] = '7.0.3'; | ||
} | ||
update_option('se_meta',$se_meta); | ||
} | ||
|
||
|
||
function se_migrate_7_0_1() { | ||
$se_meta = array( | ||
'blog_id' => false, | ||
'auth_key' => false, | ||
'version' => '7.0.2', | ||
'first_version' => '7.0.1', | ||
'new_user' => false, | ||
'name' => '', | ||
'email' => '', | ||
'show_options_page_notice' => false | ||
); | ||
|
||
update_option('se_meta',$se_meta); | ||
|
||
//get options and update values to boolean | ||
$old_options = get_option('se_options', false); | ||
|
||
if($old_options) { | ||
$new_options = se_get_default_options(); | ||
|
||
$boolean_keys = array( | ||
'se_use_page_search' => false, | ||
'se_use_comment_search' => false, | ||
'se_use_tag_search' => false, | ||
'se_use_tax_search' => false, | ||
'se_use_category_search' => false, | ||
'se_approved_comments_only'=> false, | ||
'se_approved_pages_only' => false, | ||
'se_use_excerpt_search' => false, | ||
'se_use_draft_search' => false, | ||
'se_use_attachment_search' => false, | ||
'se_use_authors' => false, | ||
'se_use_cmt_authors' => false, | ||
'se_use_metadata_search' => false, | ||
'se_use_highlight' => false, | ||
); | ||
$text_keys = array( | ||
'se_exclude_categories' => '', | ||
'se_exclude_categories_list' => '', | ||
'se_exclude_posts' => '', | ||
'se_exclude_posts_list' => '', | ||
'se_highlight_color' => '', | ||
'se_highlight_style' => '' | ||
); | ||
|
||
foreach ($boolean_keys as $k) { | ||
$new_options[$k] = ('Yes' === $old_options[$k]); | ||
} | ||
foreach ($text_keys as $t) { | ||
$new_options[$t] = $old_options[$t]; | ||
} | ||
update_option('se_options',$new_options); | ||
} | ||
|
||
//moved to meta | ||
$notice = get_option('se_show_we_tried', false); | ||
if($notice) { | ||
delete_option('se_show_we_tried'); | ||
} | ||
} | ||
|
||
|
||
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(); | ||
} | ||
|
||
function se_get_default_options() { | ||
$se_options = array( | ||
'se_exclude_categories' => '', | ||
'se_exclude_categories_list' => '', | ||
'se_exclude_posts' => '', | ||
'se_exclude_posts_list' => '', | ||
'se_use_page_search' =>false, | ||
'se_use_comment_search' =>true, | ||
'se_use_tag_search' => false, | ||
'se_use_tax_search' => false, | ||
'se_use_category_search' => true, | ||
'se_approved_comments_only'=> true, | ||
'se_approved_pages_only' => false, | ||
'se_use_excerpt_search' => false, | ||
'se_use_draft_search' => false, | ||
'se_use_attachment_search' => false, | ||
'se_use_authors' => false, | ||
'se_use_cmt_authors' => false, | ||
'se_use_metadata_search' => false, | ||
'se_use_highlight' => true, | ||
'se_highlight_color' => 'orange', | ||
'se_highlight_style' => '', | ||
'se_research_metabox' => array ( | ||
'visible_on_compose' => true, | ||
'external_search_enabled' => false, | ||
'notice_visible' => true | ||
) | ||
); | ||
|
||
return $se_options; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.thanks {width:400px; } | ||
.thanks p {padding-left:20px; padding-right:20px;} | ||
.info { background: #FFFFCC; border: 1px dotted #D8D2A9; padding: 10px; color: #333; } | ||
.info a { color: #333; text-decoration: none; border-bottom: 1px dotted #333 } | ||
.info a:hover { color: #666; border-bottom: 1px dotted #666; } | ||
|
||
#se-basic-settings,#se-advanced-settings, #se-test-search, #se-info {margin-top: 20px;} | ||
#se-basic-settings .manage-column, #se-advanced-settings .manage-column {font-weight:bold;} | ||
#se-basic-settings.widefat, #se-advanced-settings.widefat,#se-test-search.widefat, #se-info.widefat {width:80%;} | ||
.se-col {width:350px;} | ||
.se-suboption label { font-size: smaller;margin-left:10px; color:#666;} | ||
|
||
#se-top-notice {width:80%; position:relative;} | ||
#se-top-notice .updated {margin:0;} |
Empty file.
Empty file.
Empty file.
Oops, something went wrong.