admin_url( 'admin-ajax.php' ), // WordPress AJAX-URL 'nonce' => wp_create_nonce( 'adventurebook_ajax_nonce' ), // Nonce zur Sicherheit 'plugin_url' => plugins_url('', ADVENTUREBOOK_PLUGIN_FILE), 'play_label' => __( '▶ Play Audio', 'adventurebook' ), 'pause_label'=> __( '⏸ Pause Audio', 'adventurebook' ), 'enable_keyboard_navigation' => get_option( 'adventurebook_enable_keyboard_navigation', 'yes'), ) ); // translate strings for JS $selected = isset($_GET['book_id']) ? intval(ab_get('book_id')) : 0;// phpcs:ignore WordPress.Security.NonceVerification.Recommended $graph = $selected ? adventurebook_generate_map_graph_for_book($selected) : ['nodes'=>[], 'edges'=>[]]; wp_localize_script('adventurebook-map', 'adventurebookMapData', [ 'graph' => $graph, 'ajax_url' => admin_url('admin-ajax.php'), 'selected' => $selected, 'edit_url' => admin_url('post.php?action=edit&post='), ]); // load media uploader for image selection wp_enqueue_media(); } add_action( 'wp_enqueue_scripts', 'adventurebook_enqueue_scripts' ); /** * this function will be called when the shortcode [adventurebook id="123"] is used * it has to load the main div of the adventurebook * the initial content will be loaded via the ajax call to get_adventurebook_page_content * * @param $atts * * @return string */ function adventurebook_shortcode( $atts ): string { $adventurebook_id = intval( $atts['id'] ); // Die ID per data-Attribut ausgeben ob_start(); ?>
location_id; } else { // try to get the page_id from the actual session $page_id = adventurebook_get_from_session( 'adventurebook_page_id_' . $adventurebook_id ); } // if there is no page_id, use the start page of the Adventurebook if ( ! $page_id ) { $page_id = get_post_meta( $adventurebook_id, '_adventurebook_start_page', true ); } return $page_id; } function adventurebook_get_from_session($key) : ? string { if (!session_id()) { session_start(); } // verify and sanitize the key and return the value from the session return isset($_SESSION[$key]) ? sanitize_text_field( wp_unslash( $_SESSION[$key] ) ) : null; }