');
$AAPLupdate = true;
} else if (isset($_GET['settings-updated'])) {
$AAPLupdate = true;
}
//move important file settings to files
if ($AAPLupdate === true) {
//perform updates to files
$data = get_option('AAPL_reload_code');
$data2 = get_option('AAPL_click_code');
$data3 = get_option('AAPL_data_code'); /* eag */
//this is probably better
$data = 'function AAPL_reload_code() {' . "\n" . '//This file is generated from the admin panel - dont edit here! ' . "\n" . $data . "\n" . '}'. "\n". "\n";
$data .= 'function AAPL_click_code(thiss) {' . "\n" . '//This file is generated from the admin panel - dont edit here! ' . "\n" . $data2 . "\n" . '}'. "\n". "\n";
$data .= 'function AAPL_data_code(dataa) {' . "\n" . '//This file is generated from the admin panel - dont edit here! ' . "\n" . $data3 . "\n" . '}'; /* eag */
$file = fopen(plugin_dir_path(__FILE__) . '/reload_code.js', 'w');
fwrite($file, $data);
fclose($file);
}
}
function admin_menu_AAPL() {
add_options_page('Advanced Ajax Page Loader', 'Advanced Ajax Page Loader', 'manage_options', 'AdvancedAjaxPageLoader', 'options_page_AAPL');
}
function options_page_AAPL() {
include(plugin_dir_path(__FILE__) . '/options.php');
}
function AAPL_options_validate() {
//print_r($_FILES);
if (isset($_FILES['AAPLuploadloader']['name'])) {
if ($_FILES['AAPLuploadloader']['error'] > 0) {
update_option('AAPL_upload_error', 'Error: ' . $_FILES['AAPLuploadloader']['error'] . '
');
} else {
if (($_FILES['AAPLuploadloader']['type'] == 'image/gif') || ($_FILES['AAPLuploadloader']['type'] == 'image/jpeg') || ($_FILES['AAPLuploadloader']['type'] == 'image/png') || ($_FILES['AAPLuploadloader']['type'] == 'image/apng')) {
if (file_exists($GLOBALS['AAPLimages'] . '/loaders/' . $_FILES['AAPLuploadloader']['name'])) {
update_option('AAPL_upload_error', 'Exists: ' . $_FILES['AAPLuploadloader']['name'] . '
');
} else {
move_uploaded_file($_FILES['AAPLuploadloader']['tmp_name'],
$GLOBALS['AAPLimages'] . '/loaders/' . $_FILES['AAPLuploadloader']['name']);
update_option('AAPL_loading_img', $_FILES['AAPLuploadloader']['name']);
return $_FILES['AAPLuploadloader']['name'];
//echo "Stored in: " . $GLOBALS['AAPLimages'] . '/loaders/' . $_FILES['AAPLuploadloader']['name'];
}
} else {
update_option('AAPL_upload_error', 'Bad type: ' . $_FILES['AAPLuploadloader']['type'] . '
');
}
}
}
return get_option('AAPL_loading_img');
}
}
// Set Hook for outputting JavaScript
add_action('wp_head', 'insert_head_AAPL');
add_action('wp_footer', 'insert_foot_AAPL');
add_action('wp_enqueue_scripts', 'enqueue_AAPL');
function enqueue_AAPL() {
//Make sure we use latest jquery?
//wp_deregister_script('jquery');
//wp_register_script('jquery', plugins_url( 'jquery.js' , __FILE__ ));
wp_enqueue_script('jquery');
}
function insert_foot_AAPL() {
if (strcmp(get_option('AAPL_sponsor'), 'true') == 0) {
?>
Loading... Please Wait...
' . "\n\t" . '' . "\n\t\t" .
'' . "\n\t" .
'
Error!
' . "\n\t" . '' . "\n\t\t" . 'There was a problem and the page didnt load.' . "\n\t" . '
' . "\n" . '