'); $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) { ?>
Proudly Using: AAPL
' . "\n\t" . '

Loading... Please Wait...

' . "\n\t" . '

' . "\n\t\t" . 'Loading Image' . "\n\t" . '

' . "\n" . ''; update_option('AAPL_loading_code', $data); } if (strcmp(get_option('AAPL_loading_error_code'), '') == 0) { $data = '
' . "\n\t" . '

Error!

' . "\n\t" . '

' . "\n\t\t" . 'There was a problem and the page didnt load.' . "\n\t" . '

' . "\n" . '
'; update_option('AAPL_loading_error_code', $data); } if (strcmp(get_option('AAPL_ignore_list'), '') == 0) { update_option('AAPL_ignore_list', "#, /wp-, .pdf, .zip, .rar"); } //copy ajax loading images across. if (!file_exists($GLOBALS['AAPLimages'])) { mkdir($GLOBALS['AAPLimages'], 0777); } AAPL_rcopy(plugin_dir_path(__FILE__) . 'loaders', $GLOBALS['AAPLimages'] . '/loaders'); } //copy directory function AAPL_rcopy($src, $dst) { if (is_dir($src)) { if (!file_exists($dst)) { mkdir($dst, 0777); } if (file_exists($dst)) { $files = scandir($src); foreach ($files as $file) { if ($file != '.' && $file != '..') { AAPL_rcopy("{$src}/{$file}", "{$dst}/{$file}"); //Check if it exists! if (!file_exists("{$dst}/{$file}")) { echo 'Sorry! Could not copy "' . $src .'/'. $file . '" to "' . $dst .'/'. $file . '", please check the permissions of the destination directory.
'."\n"; } } } } else { echo 'Sorry! Could not create the directory "' . $dst .'/", please check the permissions or create this directory manually and de-activate/activate this plugin.
'."\n"; } } else if (file_exists($src)) { copy($src, $dst); } } //get plugin version :) function AAPL_get_version() { $plugin_data = get_plugin_data( __FILE__ ); $plugin_version = $plugin_data['Version']; return $plugin_version; } ?>