{ global $wpdb; $pano_table_name = get_pano_table_name(); $text_table_name = get_pano_text_table_name(); $language_code = get_user_language(); $url = $_SERVER['HTTP_REFERER']; $parts = explode('?pano_id=', $url); $pano_id = $parts[1]; if ($pano_id == NULL) { $pano_id = 1; } // DB query joining the pano table and the pano text table $panos = $wpdb->get_results("SELECT wppt.description FROM " . $pano_table_name . " wpp " . "INNER JOIN " . $text_table_name . " wppt ON " . "wppt.pano_id = " . "'" . $pano_id . "'" . "WHERE wppt.language_code = " . $language_code, ARRAY_A); return $panos; } $pano_desc = get_pano_description(); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="./pano_info.css"> </head> <body> <div id="wrapper"> <h1><?php echo $pano_desc[0]['description']; ?> </h1> </div> </body>
function view_panos_settings_page() { $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css'; $panos = get_all_panos(); $pano_editor = WP_PLUGIN_URL . '../pano_editor/'; $game_id = $_POST['game_id']; $pano_desc = get_pano_description(); ?> <link rel="stylesheet" type="text/css" href="<?php echo $semantic; ?> "/> <h2>Choose a Pano</h2> <hr> <form id="form" method="post" enctype="multipart/form-data" action="<?php echo get_admin_url() . 'admin-post.php'; ?> "> <input type="hidden" name="action" value="create_new_spotgame" /> <div class="ui form segment new_word_form"> <div class="ui form"> <div class="field"> <label>Choose a deck:</label> <select name="panos" id="pano_id"> <option value="NA">Select a Pano</option> <?php foreach ($panos as $pano) { ?> <option value="<?php echo $pano->id; ?> "><?php echo $pano_desc; ?> </option> <?php } ?> </select> </div> </div> <p class="error" id="pano_not_selected">* Select one Pano</p> <a class="ui blue icon button" onclick="go_to_panorama()" style="padding: 7px">Create Hotspot</a> </div> </form> </div> <script> function go_to_panorama(){ var selected = document.getElementById("pano_id").value; if(user_selected_one_pano(selected)){ document.getElementById("pano_not_selected").style.display = "none"; window.location.href = "<?php echo $pano_editor; ?> " + "/?game_id=<?php echo $game_id; ?> &pano_id=" + selected; }else{ document.getElementById("pano_not_selected").style.display = "block"; } } function user_selected_one_pano(selected){ if(selected == "NA"){ return false; }else{ return true; } } </script> <?php }