0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TCDのWordPressテーマ venus のトップロゴをsvgに

Last updated at Posted at 2019-11-08

TCD の WordPress テーマ venus のトップロゴを svgに

概要

トップ以外のロゴはメディアから選ぶようになっているので、svg対応pluginなど入れればそのまま対応できるのだが、トップロゴはTCD特製アップローダ(&エディタ)で設定するようになっているので.svg 拡張子が通過しない。ので通過するようにカスタマイズ1する。

戦略

  • アップローダに通過させるファイルの拡張子を見ているところがあるので、そこにsvgを追加する。
  • サイズを見てどうこうしているところをすっ飛ばす。

修正する

他に修正しているかもしれないので行番号は参考程度に。

バージョンなど

Theme Name:VENUS
Theme URI:
Description:WordPressテーマ「VENUS」
Author:Design Plus
Author URI:http://design-plus1.com/tcd-w/
Version:2.5

修正ファイル

venus_tcd038/functions/header-logo.php

修正箇所


diff --git a/venus_tcd038/functions/header-logo.php b/venus_tcd038/functions/header-logo.php
index f21d631..cd62ecd 100755
--- a/venus_tcd038/functions/header-logo.php
+++ b/venus_tcd038/functions/header-logo.php
@@ -68,7 +68,7 @@ function dp_logo_exists($only_resized = false){
 	//リサイズが指定されている場合はリサイズされたものがあるか検索
 	if($only_resized){
 		foreach(scandir($dir) as $file){
-			if(preg_match("/logo-resized\.(jpe?g|png|gif)$/i", $file)){
+			if(preg_match("/logo-resized\.(jpe?g|png|gif|svg)$/i", $file)){
 				return $dir.DIRECTORY_SEPARATOR.$file;
 			}	
 		}
@@ -76,7 +76,7 @@ function dp_logo_exists($only_resized = false){
 	}
 	//オリジナルのファイルが存在するか否かを返す
 	foreach(scandir($dir) as $file){
-		if(preg_match("/logo\.(jpe?g|png|gif)$/i", $file)){
+		if(preg_match("/logo\.(jpe?g|png|gif|svg)$/i", $file)){
 			return $dir.DIRECTORY_SEPARATOR.$file;
 		}
 	}
@@ -94,7 +94,7 @@ function dp_logo_info($only_resized = false, $fix_width = 0, $fix_height = 0){
 	$file = dp_logo_exists($only_resized);
 	if($file){
 		$size = @getimagesize($file);
-		if($size){
+//		if($size){
 			$dp_logo_info = array(
 				'name' => basename($file),
 				'url' => dp_logo_baseurl().'/'.basename($file),
@@ -119,10 +119,11 @@ function dp_logo_info($only_resized = false, $fix_width = 0, $fix_height = 0){
 			}
 
 			return $dp_logo_info;
-		}else{
-			return false;
-		}
-		return $size;
+//		}else{
+      
+//			return false;
+//		}
+//		return $size;
 	}else{
 		false;
 	}
@@ -283,7 +284,7 @@ function _dp_upload_logo(){
 	}
 	//拡張子を調べる
 	$ext = array();
-	if(!preg_match("/(png|gif|jpe?g)$/i", $_FILES['dp_image']['name'], $ext)){
+	if(!preg_match("/(svg|png|gif|jpe?g)$/i", $_FILES['dp_image']['name'], $ext)){
 		$dp_upload_error = array(
 			'error' => true,
 			'message' => __('Uploaded file type is not allowed. Allowed file types are PNG, JPG and GIF.')
@@ -293,7 +294,7 @@ function _dp_upload_logo(){
 	//既存のファイルを削除する
 	$existing_files = scandir($dir);
 	foreach($existing_files as $file){
-		if(preg_match("/logo(-resized)?\.(png|gif|jpe?g)$/i", $file)){
+		if(preg_match("/logo(-resized)?\.(svg|png|gif|jpe?g)$/i", $file)){
 			//ファイルが存在した場合は削除する
 			if(!@unlink($dir.DIRECTORY_SEPARATOR.$file)){
 				$dp_upload_error = array(
@@ -327,7 +328,7 @@ function _dp_delete_image(){
 		if(wp_verify_nonce($_REQUEST['_wpnonce'], 'dp_delete_image_'.get_current_user_id())){
 			$dir = dp_logo_basedir();
 			foreach(scandir($dir) as $file){
-				if(preg_match("/logo(-resized)?\.(png|gif|jpe?g)/i", $file)){
+				if(preg_match("/logo(-resized)?\.(svg|png|gif|jpe?g)/i", $file)){
 					if(!@unlink($dir.DIRECTORY_SEPARATOR.$file)){
 						add_action('admin_notices', '_dp_delete_message_error');
 						return;
@@ -380,7 +381,7 @@ function _dp_resize_logo(){
 		return $dp_resize_message;
 	}
 	// 保存ファイル名を決める
-	$path = preg_replace("/logo\.(png|gif|jpe?g)$/i", "logo-resized.$1", $info['path']);
+	$path = preg_replace("/logo\.(svg|png|gif|jpe?g)$/i", "logo-resized.$1", $info['path']);
 	// 3.5以前と以降で処理を分岐
 	try{
 		// 3.5以降はwp_get_image_editorが存在する
@@ -502,4 +503,4 @@ function _dp_get_upload_err_msg($error_code){
 		return  __('Upload failed. Sorry, but reasons cannot be detected.', 'tcd-w');
 		break;
 	}
-}
\ No newline at end of file
+}
  1. ただしテーマにアップデートがあった場合は再度修正しなくてはならない。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?