質問編集履歴
2
追加訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -27,6 +27,10 @@
|
|
27
27
|
現状はウィジェットエリアを必要なページ分追加して、
|
28
28
|
そこにフロントページで使われているウィジェットを追加したウィジェットエリアに使用していこうと考えています。
|
29
29
|
ウィジェットエリア作成まではできましたが、画像のリンクがうまく貼れないため反映されません。
|
30
|
+
|
31
|
+
Demo site でいうと 以下のような画像部分です。
|
32
|
+

|
33
|
+
|
30
34
|
この問題を解決するため、get_template_directory_uri()をget_stylesheet_directory_uri()に関する作業を行っていますが、任意のPHPではクラスが作成されており、編集したい関数がその中にあります。
|
31
35
|
|
32
36
|
子テーマのfunction.phpで上記のfunctionを編集、上書きしてみましたがpublicエラーが出ました。
|
1
add explanation in detail
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
WordPress: クラスが作成されているPHPの中のfunction
|
1
|
+
WordPress: クラスが作成されているPHPの中のfunctionを編集したい
|
body
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
[知りたい事]
|
2
|
+
以下のコードの get_template_directory_uri() を子テーマで直すとしたらどのように修正したらいいでしょうか?
|
3
|
+
|
4
|
+
```ここに言語を入力
|
5
|
+
class shapely_Welcome{
|
6
|
+
public function shapely_welcome_style_and_scripts( $hook_suffix ) {
|
7
|
+
wp_enqueue_style( 'shapely-welcome-screen-css', get_template_directory_uri() . '/inc/admin/welcome-screen/css/welcome.css' );
|
8
|
+
wp_enqueue_script( 'shapely-welcome-screen-js', get_template_directory_uri() . '/inc/admin/welcome-screen/js/welcome.js', array( 'jquery' ) );
|
9
|
+
wp_localize_script( 'shapely-welcome-screen-js', 'shapelyWelcomeScreenObject', array(
|
10
|
+
'nr_actions_required' => absint( $this->count_actions() ),
|
11
|
+
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
12
|
+
'template_directory' => esc_url( get_template_directory_uri() ),
|
13
|
+
'no_required_actions_text' => esc_html__( 'Hooray! There are no required actions for you right now.', 'shapely' )
|
14
|
+
) );
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
```
|
19
|
+
|
20
|
+
|
1
21
|
[https://colorlib.com/shapely/](https://colorlib.com/shapely/) (Demo)
|
2
22
|
[https://github.com/puikinsh/shapely](https://github.com/puikinsh/shapely) (Code)
|
3
23
|
|
@@ -9,4 +29,32 @@
|
|
9
29
|
ウィジェットエリア作成まではできましたが、画像のリンクがうまく貼れないため反映されません。
|
10
30
|
この問題を解決するため、get_template_directory_uri()をget_stylesheet_directory_uri()に関する作業を行っていますが、任意のPHPではクラスが作成されており、編集したい関数がその中にあります。
|
11
31
|
|
12
|
-
|
32
|
+
子テーマのfunction.phpで上記のfunctionを編集、上書きしてみましたがpublicエラーが出ました。
|
33
|
+
修正内容は以下のような感じです。
|
34
|
+
|
35
|
+
```ここに言語を入力
|
36
|
+
<? php
|
37
|
+
|
38
|
+
// 親テーマの関数をremoveする関数
|
39
|
+
function remove_shapely_welcome_style_and_scripts() {
|
40
|
+
remove_action('widgets_init', 'shapely_welcome_style_and_scripts');
|
41
|
+
}
|
42
|
+
|
43
|
+
// 上記の関数をWordPressのinitに登録
|
44
|
+
add_action('init','remove_shapely_welcome_style_and_scripts');
|
45
|
+
|
46
|
+
class shapely_Welcome {
|
47
|
+
public function shapely_welcome_style_and_scripts_child( $hook_suffix ) {
|
48
|
+
|
49
|
+
wp_enqueue_style( 'shapely-welcome-screen-css', get_stylesheet_directory_uri() . '/inc/admin/welcome-screen/css/welcome.css' );
|
50
|
+
|
51
|
+
...<修正内容部分>
|
52
|
+
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
// 親テーマの後に実行
|
57
|
+
add_action( 'after_setup_theme', 'shapely_welcome_style_and_scripts_child', 20 );
|
58
|
+
|
59
|
+
?>
|
60
|
+
```
|