AI要約
説明
wpforms_form_pages_footer アクションは、フォームページアドオンで使用されるテンプレートのページ読み込みの最後にトリガーされます。
パラメーター
このアクションはパラメーターを受け付けません。
詳細情報
このアクションは、標準のWordPressのwp_footerアクションと非常によく似た方法で機能します。ページ読み込みの最後に実行されますが、wpforms_form_pages_footerアクションの場合、フォームページのテンプレートでのみ実行されます。
これは、フォームページアドオンで使用されるテンプレート用のカスタムJavaScriptがある場合に特に役立ちます。
ソース
wpforms-form-pages/src/Frontend.php
例
以下の例では、フォームページフォーム内のタイムピッカーから過去の時刻を無効にする方法を示します。
/**
* Action to be called once Form Page has completely loaded
*
* @link https://wpforms.com/developers/wpforms_form_pages_footer/
*/
function wpf_dev_form_pages_script() {
?>
<script type="text/javascript">
// Find out the current time
var now = new Date();
// Take that current time and round it up so we have an even number on the interval
now.setHours( now.getHours() + Math.round(date.getMinutes()/90) );
// Run only on form ID 999 field ID 8
window.wpforms_999_8 = window.wpforms_999_8 || {};
window.wpforms_999_8.timepicker = {
forceRoundTime: true,
// Disable any times that have passed already and return the new time selections
minTime: now.toLocaleTimeString()
};
</script>
<?php
}
add_action( 'wpforms_form_pages_footer', 'wpf_dev_form_pages_script', 30 );