AI要約
説明
wpforms_google_drive_provider_settings_form_builder_enabled_shared_drives を使用すると、Googleアカウントの共有ドライブフォルダからディレクトリを表示できます。
パラメーター
| パラメータ | タイプ | 説明 |
|---|---|---|
$form | オブジェクト | すべてのフォーム設定とフィールドを含むWP_Postオブジェクト。 |
$is_enabled | ブール値 | Googleドライブプロバイダーで共有ドライブが有効になっているかどうかを指定するブール値。 |
ソース
wpforms-google-drive/src/Provider/Settings/FormBuilder.php
詳細情報
このフィルターを使用すると、サイトのフォームにGoogleドライブアドオンを接続する際に、共有フォルダからディレクトリを選択できます。フォームビルダーインターフェイスでGoogleドライブ連携の共有ドライブを有効または無効にするかを制御します。
例
/**
* Display shared drives in Google Picker.
*
* @link https://wpforms.com/developers/wpforms_google_drive_provider_settings_form_builder_enabled_shared_drives/
* @since {VERSION}
*
* @param bool $is_enabled Display Shared Drives directories.
* @param WP_Post $form Current form.
*/
add_filter( 'wpforms_google_drive_provider_settings_form_builder_enabled_shared_drives', '__return_true' );
上記のコードスニペットは、ウェブサイト上のすべてのフォームに機能が適用されます。特定のフォームにフィルターを適用したい場合は、以下のコードスニペットを使用してください。
function wpf_shared_google_drive_form ( $is_enabled, $form ) {
// Enable shared drives only for form ID 123
if ( $form->ID === 123 ) {
return true;
}
return $is_enabled;
}
add_filter( 'wpforms_google_drive_provider_settings_form_builder_enabled_shared_drives', 'wpf_shared_google_drive_form', 10, 2 );
上記のコードスニペットの123を実際のフォームIDに置き換えてください。フォームIDを取得する方法については、チュートリアルを参照してください。