Web初心者です。(htmlとCSSは少し、PHPはほぼ未知レベル)
Wordpressのお問い合せフォームで、確認画面が必要になり、
ContactForm7から MW WP Formへ切り替えて作業中です。
昨日作業中は表示されていなかったはずなのですが、
作業→更新をしたところ、サイト上部に次にエラーメッセージが表示されました。
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'mwform_form_class' not found or invalid function name in /home/antrum/workshop-access.com/public_html/test2/wp-includes/class-wp-hook.php on line 286
で、該当箇所のコードは下記の通りでした。
/** * Calls the callback functions added to a filter hook. * * @since 4.7.0 * * @param mixed $value The value to filter. * @param array $args Arguments to pass to callbacks. * @return mixed The filtered value after all hooked functions are applied to it. */ public function apply_filters( $value, $args ) { if ( ! $this->callbacks ) { return $value; } $nesting_level = $this->nesting_level++; $this->iterations[ $nesting_level ] = array_keys( $this->callbacks ); $num_args = count( $args ); do { $this->current_priority[ $nesting_level ] = $priority = current( $this->iterations[ $nesting_level ] ); foreach ( $this->callbacks[ $priority ] as $the_ ) { if( ! $this->doing_action ) { $args[ 0 ] = $value; } // Avoid the array_slice if possible. if ( $the_['accepted_args'] == 0 ) { $value = call_user_func_array( $the_['function'], array() ); } elseif ( $the_['accepted_args'] >= $num_args ) { $value = call_user_func_array( $the_['function'], $args ); } else { $value = call_user_func_array( $the_['function'], array_slice( $args, 0, (int)$the_['accepted_args'] ) ); } } } while ( false !== next( $this->iterations[ $nesting_level ] ) ); unset( $this->iterations[ $nesting_level ] ); unset( $this->current_priority[ $nesting_level ] ); $this->nesting_level--; return $value; }
MW WP Formを使用するにあたり、子テーマの function.php に下記の記述をしています。
全て、諸々のWebサイトを参考にしたものなので、PHPの仕組みが分かって書いているのではありません。
<?php // Exit if accessed directly if ( !defined( 'ABSPATH' ) ) exit; // BEGIN ENQUEUE PARENT ACTION // AUTO GENERATED - Do not modify or remove comment markers above or below: if ( !function_exists( 'chld_thm_cfg_parent_css' ) ): function chld_thm_cfg_parent_css() { wp_enqueue_style( 'chld_thm_cfg_parent', trailingslashit( get_template_directory_uri() ) . 'style.css', array( ) ); } endif; add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 10 ); /*投稿画像に任意のclassを自動的に追加する方法*/ function add_class_images($content){ $my_custom_class = "test"; $add_class = str_replace('<img class="', '<img class="'.$my_custom_class.' ', $content); return $add_class; } add_filter('the_content', 'add_class_images'); wp_enqueue_script( 'yubinbango', 'https://yubinbango.github.io/yubinbango/yubinbango.js', array(), null, true );/*郵便番号自動入力*/ /*お問い合せフォームのサンクスページ*/ add_action( 'wp_footer', 'mycustom_wp_footer' ); function mycustom_wp_footer() { ?> <script type="text/javascript"> document.addEventListener( 'wpcf7mailsent', function( event ) { location = 'http://test2.workshop-access.com/thanks'; }, false ); </script> /*お問い合せフォームのサンクスページ*/ add_filter( 'wpcf7_validate_email', 'wpcf7_text_validation_filter_extend', 11, 2 ); add_filter( 'wpcf7_validate_email*', 'wpcf7_text_validation_filter_extend', 11, 2 ); <script src="https://yubinbango.github.io/yubinbango/yubinbango.js" charset="UTF-8"></script>/*郵便番号自動入力*/ // オリジナルテーマ用JS読み込み function my_scripts() { // yubinbango wp_enqueue_script( 'yubinbango', '//yubinbango.github.io/yubinbango/yubinbango.js', array(), null, true ); } add_action( 'wp_enqueue_scripts', 'my_scripts'); // MW WP Formのクラスをyubinbangoのクラスに変更する function mwform_form_class() { ?> <script> jQuery(function($) { $( '.mw_wp_form form' ).attr( 'class', 'h-adr' ); }); </script> <?php } add_action( 'wp_head', 'mwform_form_class', 10000 ); // END ENQUEUE PARENT ACTION
※コード中に/郵便番号自動入力/が2回書いてあるのは、これより前にContactForm7を使用していた際の名残です。
PHPはさっぱりなので、なぜ急にエラーが出たのかは不明です。
何をどうしたら良いか、ご教示いただけたら助かります。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。