1

現在、プラグインGoogle Calendar Eventsを使用しています。ユーザーが表示しているフィードを (選択ドロップダウン メニューから) 選択し、選択したフィードをカレンダーに自動的に表示する機能を追加したいと考えています。誰もこれを行う方法を知っていますか?

ショートコードを使用して表示するフィードを選択できることは知っていますが、フィードごとに個別のページを作成して、それらへのリンクを作成したくはありません (10 以上のフィードがあり、定期的に 1 つが追加および削除されます。そのため、個々のフィードごとに手動でカレンダーを作成することは現実的ではありません)。

このコードをプラグインの gce-script.js ファイルに追加しました。

    function changeFeeds(){
    var values = jQuery("#gce-view-feed").val();
    jQuery("#result").replaceWith(values);
}

jQuery("option").click(function(){
    location.reload();
});

jQuery("select").change(changeFeeds);
changeFeeds();

...ID「gce-view-feed」は選択メニューの ID で、ID「result」は結果を表示する場所です。これはうまく機能しますが、その結果をプラグインに渡して使用するにはどうすればよいですか?

フィード ID は、PHP 変数 $feed_ids によって定義されます。変数を編集するのに最適な場所は、google-calendar-events.php ファイルの次のコード行だと思います。

//Check that any feeds have been added
        if ( is_array( $options ) && ! empty( $options ) ) {
            extract( shortcode_atts( array(
                'id' => '',
                'type' => 'grid',
                'title' => null,
                'max' => 0,
                'order' => 'asc'
            ), $atts ) );

            $no_feeds_exist = true;
            $feed_ids = array();

            if ( '' != $id ) {
                //Break comma delimited list of feed ids into array
                $feed_ids = explode( ',', str_replace( ' ', '', $id ) );

                //Check each id is an integer, if not, remove it from the array
                foreach ( $feed_ids as $key => $feed_id ) {
                    if ( 0 == absint( $feed_id ) )
                        unset( $feed_ids[$key] );
                }

                //If at least one of the feed ids entered exists, set no_feeds_exist to false
                foreach ( $feed_ids as $feed_id ) {
                    if ( isset($options[$feed_id] ) )
                        $no_feeds_exist = false;
                }
            } else {
                foreach ( $options as $feed ) {
                    $feed_ids[] = $feed['id'];
                }

                $no_feeds_exist = false;
            }

しかし、jQuery の値を $feed_ids 変数に渡す方法がわかりません。これを行う方法はありますか?そうでない場合、オプションを動的に選択して PHP 変数に渡す別の方法はありますか?

4

0 に答える 0