function get_pano_description()
{
    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;
}
function panno_uninstall()
{
    global $wpdb;
    // Get all the table names
    $pano_table_name = get_pano_table_name();
    $pano_text_table_name = get_pano_text_table_name();
    $quest_table_name = get_quest_table_name();
    $quest_text_table_name = get_quest_text_table_name();
    $mission_table_name = get_mission_table_name();
    $mission_text_table_name = get_mission_text_table_name();
    $hotspot_table_name = get_hotspot_table_name();
    $progress_table_name = get_user_progress_table_name();
    $skill_progress_table_name = get_user_skill_progress_table_name();
    $skill_bonus_pts_table_name = get_user_skill_bonus_pts_table_name();
    $type_table_name = get_type_table_name();
    $prereq_table_name = get_prereq_table_name();
    $activation_code_table_name = get_activation_code_table_name();
    $ads_table_name = get_ads_table_name();
    $ads_text_table_name = get_ads_text_table_name();
    $domain_table_name = get_domain_table_name();
    $tool_table_name = get_tool_table_name();
    // Drop all the tables
    $wpdb->query("DROP TABLE IF EXISTS {$pano_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$pano_text_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$quest_text_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$quest_text_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$mission_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$mission_text_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$hotspot_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$progress_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$skill_progress_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$skill_bonus_pts_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$type_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$prereq_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$activation_code_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$ads_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$ads_text_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$domain_table_name}");
    $wpdb->query("DROP TABLE IF EXISTS {$tool_table_name}");
    echo "bbbbbbbbb";
    // Update the db version to 0 so the next time the plugin is run it will reinstall
    update_option("panno_db_version", PANO_DB_VERSION);
}
Пример #3
0
function pano_install()
{
    global $wpdb;
    $installed_ver = get_option("pano_db_version");
    $table_name = get_pano_table_name();
    if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name || $installed_ver != pano_DB_VERSION) {
        // Create tables
        $pano_sql = build_pano_sql();
        $pano_text_sql = build_pano_text_sql();
        $quest_sql = build_quest_sql();
        $quest_text_sql = build_quest_text_sql();
        $mission_sql = build_mission_sql();
        $mission_text_sql = build_mission_text_sql();
        $progress_sql = build_user_progress_sql();
        $skill_progress_sql = build_user_skill_progress_table_sql();
        $skill_bonus_pts_sql = build_user_skill_bonus_pts_table_sql();
        $hotspot_sql = build_hotspot_sql();
        $type_sql = build_type_sql();
        $prereq_sql = build_prereq_sql();
        $activation_sql = build_activation_code_sql();
        $tool_sql = build_tools_sql();
        $school_sql = build_school_sql();
        $domain_sql = build_domains_sql();
        $prereq_item_sql = build_prereq_item_sql();
        $ads_sql = build_ads_sql();
        $ads_text_sql = build_ads_text_sql();
        $points_info_sql = build_points_info_sql();
        $wallet_sql = build_wallet_sql();
        $purchases_sql = build_purchases_sql();
        $item_types_sql = build_item_types_sql();
        $items_sql = build_items_sql();
        $line_items_sql = build_line_items_sql();
        $points_initial_sql = build_points_initial_bonus_sql();
        $hotspot_completed_sql = build_hotspot_completed_sql();
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        // Run the sql for the database
        dbDelta($pano_sql);
        dbDelta($pano_text_sql);
        dbDelta($quest_sql);
        dbDelta($quest_text_sql);
        dbDelta($mission_sql);
        dbDelta($mission_text_sql);
        dbDelta($progress_sql);
        dbDelta($skill_progress_sql);
        dbDelta($skill_bonus_pts_sql);
        dbDelta($hotspot_sql);
        dbDelta($type_sql);
        dbDelta($prereq_sql);
        dbDelta($activation_sql);
        dbDelta($tool_sql);
        dbDelta($school_sql);
        dbDelta($domain_sql);
        dbDelta($prereq_item_sql);
        dbDelta($ads_sql);
        dbDelta($ads_text_sql);
        dbDelta($points_info_sql);
        dbDelta($wallet_sql);
        dbDelta($purchases_sql);
        dbDelta($item_types_sql);
        dbDelta($items_sql);
        dbDelta($line_items_sql);
        dbDelta($points_initial_sql);
        dbDelta($hotspot_completed_sql);
        update_option("pano_db_version", PANO_DB_VERSION);
        // create_first_row();
    }
}
function delete_pano($pano_id)
{
    global $wpdb;
    $pano_table_name = get_pano_table_name();
    $text_table_name = get_pano_text_table_name();
    $wpdb->delete($pano_table_name, array('id' => $pano_id));
    $wpdb->delete($text_table_name, array('pano_id' => $pano_id));
}
function get_pano_description()
{
    global $wpdb;
    $pano_table_name = get_pano_table_name();
    $text_table_name = get_pano_text_table_name();
    $language_code = get_user_language();
    // DB query joining the pano table and the pano text table
    $panos = $wpdb->get_results("SELECT wpp.id, wppt.description FROM " . $pano_table_name . " wpp " . "INNER JOIN " . $text_table_name . " wppt ON " . "wppt.pano_id = wpp.id " . "WHERE wppt.language_code = " . $language_code, ARRAY_A);
    return $panos;
}
Пример #6
0
function build_pano_sql()
{
    $table_name = get_pano_table_name();
    $sql = 'CREATE TABLE ' . $table_name . ' (
      `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
      `pano_xml` text NOT NULL,
      PRIMARY KEY (`id`)
    );';
    return $sql;
}