コードに追加するのではなく、WordPress管理領域のテキストボックスを使用してGoogle APIキーを入力できるように、テキスト文字列に "$ options ['text_string ']」をwp_enqueue_scriptに設定します。wp_enqueue_scriptにテキスト文字列を追加する
wp_enqueue_script($this->plugin_slug . '-gpstracker-google-maps', '//maps.googleapis.com/maps/api/js?libraries=places&key=' . $options['text_string'] , array(), self::VERSION );
残念ながら私は運がありません。私はPHP Myadminでチェックしたので、テキスト文字列はoptionsテーブルに格納されています。
このスクリプトのこのバージョンは機能します。
wp_enqueue_script($this->plugin_slug . '-gpstracker-google-maps', '//maps.googleapis.com/maps/api/js?libraries=places&key=MyGoogleAPIKey', array(), self::VERSION);
すべての助けに感謝します。
更新
現在、私はまだ働いていないされ、これをしようとしています。
public function enqueue_scripts() {
$gpl_key = get_option('gps_plotter_options');
wp_enqueue_script($this->plugin_slug . '-gpstracker-google-maps', 'https://maps.googleapis.com/maps/api/js?' . $gpl_key . 'libraries=places', array(), self::VERSION );
}
は$オプションが動作した後の期間を加算していますか? 'wp_enqueue_script($ this-> plugin_slug。 '-gpstracker-google-maps'、 '//maps.googleapis.com/maps/api/js?libraries=places&key='。$ options ['text_string']。、配列)、self :: VERSION); ' – oompahlumpa
残念ながら、これは構文エラーを引き起こします。 – stpetedesign