Last active
December 17, 2015 03:48
-
-
Save tenman/5545822 to your computer and use it in GitHub Desktop.
Quick Fix Raindrops Theme for ver 1.113
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
/** | |
* Management of uninstall and install. | |
* | |
* | |
* | |
* ver 1.114 Theme data automatic change is supported at the time of site change. | |
*/ | |
if ( ! function_exists( "raindrops_install_navigation" ) ) { | |
function raindrops_install_navigation( ) { | |
$install = get_option( 'raindrops_theme_settings' ); | |
$upload_dir = wp_upload_dir(); | |
if ( $install == false or !array_key_exists( 'install', $install ) ) { | |
$install['current_stylesheet_dir_url'] = get_stylesheet_directory_uri(); | |
$install['current_upload_base_url'] = $upload_dir['baseurl']; | |
//add_action( 'admin_notices', create_function(null, 'echo raindrops_first_only_msg( 1 );' ) ); | |
$install['install'] = true; | |
update_option( 'raindrops_theme_settings', $install ); | |
} else { | |
if( isset( $install['current_stylesheet_dir_url'] ) and get_stylesheet_directory_uri() !== $install['current_stylesheet_dir_url'] ){ | |
$install['_raindrops_indv_css'] = str_replace( $install['current_stylesheet_dir_url'], | |
get_stylesheet_directory_uri(), | |
$install['_raindrops_indv_css'] | |
); | |
$install['old_stylesheet_dir_url'] = $install['current_stylesheet_dir_url']; | |
$install['current_stylesheet_dir_url'] = get_stylesheet_directory_uri(); | |
update_option( 'raindrops_theme_settings', $install ); | |
}elseif( ! isset( $install['current_stylesheet_dir_url'] ) ){ | |
$install['current_stylesheet_dir_url'] = get_stylesheet_directory_uri(); | |
update_option( 'raindrops_theme_settings', $install ); | |
} | |
if( isset( $install['current_upload_base_url'] ) and $upload_dir !== $install['current_upload_base_url'] ){ | |
$install['_raindrops_indv_css'] = str_replace( $install['current_upload_base_url'], | |
$upload_dir['baseurl'], | |
$install['_raindrops_indv_css'] | |
); | |
$install['old_upload_base_url'] = $install['current_upload_base_url']; | |
$install['current_upload_base_url'] = $upload_dir['baseurl']; | |
update_option( 'raindrops_theme_settings', $install ); | |
}elseif( ! isset( $install['current_upload_base_url'] ) ){ | |
$install['current_upload_base_url'] = $upload_dir['baseurl']; | |
update_option( 'raindrops_theme_settings', $install ); | |
} | |
add_action( 'switch_theme', create_function(null, 'delete_option( "raindrops_theme_settings" );' ) ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
問題点
WordPress Theme Raindrops ver 1.113 を利用して、WEBサイトの変更を行った場合、移転前のテーマオプションの設定が引き継がれない。
サイトの移転に関して、一般的に行われるURL等の文字列置換を行った場合のRaindropsの挙動
テーマデータは、シリアライズして保存されているため、URL等文字列置換を行った場合、データが壊れ、結果としてデフォルトデザインでインストールされる事があります
対応
ユーザーが、このような問題を考慮して、適切な対応をとる事は、困難で、Raindrops で適切な処理が必要と判断します。
Raindropsのインストールの時点で、インストールされたサイトのテーマディレクトリURLとアップロードディレクトリのURLをテーマで使用するデータベーステーブルに格納し、サイトの移転を行った場合に、保存されているサイトのテーマディレクトリURLと、比較して、異なる場合は、テーマが自動的に、スタイルシート内のURLを書き換えるように、変更しました。
このコードの使い方
functions.php の、raindrops_install_navigation関数を上記のものと置き換えて、Raindropsを再インストールしてください。
なを、この変更は、Raindropsの次回のアップデートに含まれる予定です。