This repository has been archived by the owner. It is now read-only.
Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ece/functions.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
79 lines (63 sloc)
2.6 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function ece_scripts() { | |
wp_enqueue_style( 'ece-style', get_stylesheet_directory_uri() . '/css/ece.css'); | |
wp_enqueue_script('ece-custom', get_stylesheet_directory_uri().'/js/custom.js', array('jquery', 'cs')); | |
wp_localize_script( 'ece-custom', 'ece_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'siteurl' => site_url() ) ); | |
} | |
add_action( 'wp_enqueue_scripts', 'ece_scripts'); | |
function ece_get_courses( $discipline ){ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL,"http://web2.uconn.edu/ece/preadvising/pread_course.php"); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, 'discipline='.$discipline); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$courses = curl_exec($ch); | |
curl_close ($ch); | |
return json_decode($courses); | |
} | |
function ajax_ece_discipline_courses(){ | |
$discipline = $_POST['discipline']; | |
$courses = ece_get_courses( urlencode($discipline) ); | |
echo wp_json_encode( $courses ); | |
wp_die(); | |
} | |
add_action( 'wp_ajax_ece_discipline_courses', 'ajax_ece_discipline_courses' ); | |
add_action('wp_ajax_nopriv_ece_discipline_courses', 'ajax_ece_discipline_courses'); | |
function ece_get_course_info( $discipline, $course ){ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL,"http://web2.uconn.edu/ece/preadvising/pread_course.php"); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, 'course='.$course.'&discipline='.$discipline); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$courses = curl_exec($ch); | |
curl_close ($ch); | |
return json_decode($courses); | |
} | |
function ajax_ece_course_info(){ | |
$discipline = $_POST['discipline']; | |
$course = $_POST['course']; | |
$courseInfo = ece_get_course_info( urlencode($discipline), urlencode($course) ); | |
echo wp_json_encode( $courseInfo ); | |
wp_die(); | |
} | |
add_action( 'wp_ajax_ece_course_info', 'ajax_ece_course_info' ); | |
add_action('wp_ajax_nopriv_ece_course_info', 'ajax_ece_course_info'); | |
function ece_get_major_info( $major ){ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL,"http://web2.uconn.edu/ece/preadvising/pread_major.php"); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, 'major='.$major); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$info = curl_exec($ch); | |
curl_close ($ch); | |
return json_decode($info); | |
} | |
function ajax_ece_major_info(){ | |
$major = $_POST['major']; | |
$majorInfo = ece_get_major_info( urlencode($major) ); | |
echo wp_json_encode( $majorInfo ); | |
wp_die(); | |
} | |
add_action( 'wp_ajax_ece_major_info', 'ajax_ece_major_info' ); | |
add_action('wp_ajax_nopriv_ece_major_info', 'ajax_ece_major_info'); | |
?> |