質問編集履歴
2
追加訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -55,6 +55,14 @@
|
|
55
55
|
そこにフロントページで使われているウィジェットを追加したウィジェットエリアに使用していこうと考えています。
|
56
56
|
|
57
57
|
ウィジェットエリア作成まではできましたが、画像のリンクがうまく貼れないため反映されません。
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
Demo site でいうと 以下のような画像部分です。
|
62
|
+
|
63
|
+
![イメージ説明](95632fd0a5ea7c51d7da1ea507d389b5.jpeg)
|
64
|
+
|
65
|
+
|
58
66
|
|
59
67
|
この問題を解決するため、get_template_directory_uri()をget_stylesheet_directory_uri()に関する作業を行っていますが、任意のPHPではクラスが作成されており、編集したい関数がその中にあります。
|
60
68
|
|
1
add explanation in detail
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
WordPress: クラスが作成されているPHPの中のfunction
|
1
|
+
WordPress: クラスが作成されているPHPの中のfunctionを編集したい
|
test
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
+
[知りたい事]
|
2
|
+
|
3
|
+
以下のコードの get_template_directory_uri() を子テーマで直すとしたらどのように修正したらいいでしょうか?
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
```ここに言語を入力
|
8
|
+
|
9
|
+
class shapely_Welcome{
|
10
|
+
|
11
|
+
public function shapely_welcome_style_and_scripts( $hook_suffix ) {
|
12
|
+
|
13
|
+
wp_enqueue_style( 'shapely-welcome-screen-css', get_template_directory_uri() . '/inc/admin/welcome-screen/css/welcome.css' );
|
14
|
+
|
15
|
+
wp_enqueue_script( 'shapely-welcome-screen-js', get_template_directory_uri() . '/inc/admin/welcome-screen/js/welcome.js', array( 'jquery' ) );
|
16
|
+
|
17
|
+
wp_localize_script( 'shapely-welcome-screen-js', 'shapelyWelcomeScreenObject', array(
|
18
|
+
|
19
|
+
'nr_actions_required' => absint( $this->count_actions() ),
|
20
|
+
|
21
|
+
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
22
|
+
|
23
|
+
'template_directory' => esc_url( get_template_directory_uri() ),
|
24
|
+
|
25
|
+
'no_required_actions_text' => esc_html__( 'Hooray! There are no required actions for you right now.', 'shapely' )
|
26
|
+
|
27
|
+
) );
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
}
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
1
41
|
[https://colorlib.com/shapely/](https://colorlib.com/shapely/) (Demo)
|
2
42
|
|
3
43
|
[https://github.com/puikinsh/shapely](https://github.com/puikinsh/shapely) (Code)
|
@@ -20,4 +60,60 @@
|
|
20
60
|
|
21
61
|
|
22
62
|
|
23
|
-
|
63
|
+
子テーマのfunction.phpで上記のfunctionを編集、上書きしてみましたがpublicエラーが出ました。
|
64
|
+
|
65
|
+
修正内容は以下のような感じです。
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
```ここに言語を入力
|
70
|
+
|
71
|
+
<? php
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
// 親テーマの関数をremoveする関数
|
76
|
+
|
77
|
+
function remove_shapely_welcome_style_and_scripts() {
|
78
|
+
|
79
|
+
remove_action('widgets_init', 'shapely_welcome_style_and_scripts');
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
// 上記の関数をWordPressのinitに登録
|
86
|
+
|
87
|
+
add_action('init','remove_shapely_welcome_style_and_scripts');
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
class shapely_Welcome {
|
92
|
+
|
93
|
+
public function shapely_welcome_style_and_scripts_child( $hook_suffix ) {
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
wp_enqueue_style( 'shapely-welcome-screen-css', get_stylesheet_directory_uri() . '/inc/admin/welcome-screen/css/welcome.css' );
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
...<修正内容部分>
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
// 親テーマの後に実行
|
112
|
+
|
113
|
+
add_action( 'after_setup_theme', 'shapely_welcome_style_and_scripts_child', 20 );
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
?>
|
118
|
+
|
119
|
+
```
|