[知りたい事]
以下のコードの get_template_directory_uri() を子テーマで直すとしたらどのように修正したらいいでしょうか?
class shapely_Welcome{ public function shapely_welcome_style_and_scripts( $hook_suffix ) { wp_enqueue_style( 'shapely-welcome-screen-css', get_template_directory_uri() . '/inc/admin/welcome-screen/css/welcome.css' ); wp_enqueue_script( 'shapely-welcome-screen-js', get_template_directory_uri() . '/inc/admin/welcome-screen/js/welcome.js', array( 'jquery' ) ); wp_localize_script( 'shapely-welcome-screen-js', 'shapelyWelcomeScreenObject', array( 'nr_actions_required' => absint( $this->count_actions() ), 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), 'template_directory' => esc_url( get_template_directory_uri() ), 'no_required_actions_text' => esc_html__( 'Hooray! There are no required actions for you right now.', 'shapely' ) ) ); } }
https://colorlib.com/shapely/ (Demo)
https://github.com/puikinsh/shapely (Code)
上のリンクのテンプレートをベースにサイトを作ろうと考えています。(子テーマ使用)
ただし、Home, About, News, Products等のページを作り、それぞれにフロントページのデザインを使用していきたいと思っています。
現状はウィジェットエリアを必要なページ分追加して、
そこにフロントページで使われているウィジェットを追加したウィジェットエリアに使用していこうと考えています。
ウィジェットエリア作成まではできましたが、画像のリンクがうまく貼れないため反映されません。
この問題を解決するため、get_template_directory_uri()をget_stylesheet_directory_uri()に関する作業を行っていますが、任意のPHPではクラスが作成されており、編集したい関数がその中にあります。
子テーマのfunction.phpで上記のfunctionを編集、上書きしてみましたがpublicエラーが出ました。
修正内容は以下のような感じです。
<? php // 親テーマの関数をremoveする関数 function remove_shapely_welcome_style_and_scripts() { remove_action('widgets_init', 'shapely_welcome_style_and_scripts'); } // 上記の関数をWordPressのinitに登録 add_action('init','remove_shapely_welcome_style_and_scripts'); class shapely_Welcome { public function shapely_welcome_style_and_scripts_child( $hook_suffix ) { wp_enqueue_style( 'shapely-welcome-screen-css', get_stylesheet_directory_uri() . '/inc/admin/welcome-screen/css/welcome.css' ); ...<修正内容部分> } } // 親テーマの後に実行 add_action( 'after_setup_theme', 'shapely_welcome_style_and_scripts_child', 20 ); ?>
回答1件
あなたの回答
tips
プレビュー