samamerrifield
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Fatal Error caused my update to stopLol nice timing! I litereally stumbled on that like a minute after posting this and just finished manually updating seconds before I refreshed this page. It worked!
Ah, ok. I miss understood before. I guess it’s not really necessary anymore to have this run right after the file is uploaded since the function runs on admin_init so whenever you do anything else after uploading it refreshes the options table entry. It creates a weird little bug where if you upload a pdf but don’t do anything else it wont be recorded right away and if for some reason you’ve already added the shortcode to a page (say you deleted the PDF, refreshed, and then re-uploaded it) you’ll get an error message on that page just saying that the file is missing (part of the plugin) but again, as soon as you do anything else the bug is corrected.
Oops! There doesn’t seem to be a way to edit this. I accidentally deleted a line that wasn’t supposed to be deleted:
//loop through all entries in the options table foreach($all_pdf_entries as $entry){ if(in_array($entry['path'], $all_pdfs)){ //if the file this entry references exists record it into $real_options $id = $entry['id']; $path = prepare_pdf_path($entry['path']); $display = $entry['display']; $real_options .= $id.'|*|'.$path.'|*|'.$display.'#@#'; } }So the above function that’s supposed to run when a file is uploaded would look like this instead:
function on_upload(){ //Deal with the PDF files. All get_pdf_files() does is filter the media folder and return any PDF files it finds $all_pdfs = get_pdf_files(); $options = get_option( 'pdf-display-plugin-options' ); //if nothing has been recorded, delte this options entry and start over if($options == ''){$options = false; delete_option( 'pdf-display-plugin-options' );} if($options != false){ //create an array of pdf entries from the options table. read_pdf_options_table_entry() just splits the options entry into chunks I can use $all_pdf_entries = read_pdf_options_table_entry($options); //loop through all entries in the options table foreach($all_pdf_entries as $entry){ if(in_array($entry['path'], $all_pdfs)){ //if the file this entry references exists record it into $real_options $id = $entry['id']; $path = prepare_pdf_path($entry['path']); $display = $entry['display']; } } //re-interpret data from this loop $all_pdf_entries = read_pdf_options_table_entry( $real_options ); //gather all recorded paths $paths = gather_all_attr($all_pdf_entries, 'path'); //check to make sure each pdf file has a corresponding entry foreach($all_pdfs as $file){ if(!in_array($file, $paths)){ //If this file is not recorded, create an entry and add it to the master list //first get a valid ID number $id_records = gather_all_attr($all_pdf_entries, 'id'); //count up until you find an ID number that isn't already taken $x = 0; while(in_array($x,$id_records)){ $x++; } $id = $x; $path = prepare_pdf_path($file); $display = 'linked'; $real_options = $real_options.$id.'|*|'.$path.'|*|'.$display.'#@#'; } } update_option('pdf-display-plugin-options', $real_options); }else{ //echo $options; $option_value = ''; $id = 0; foreach($all_pdfs as $pdf){ //echo $pdf.'<br>'; $id = $id+1; $display = 'linked'; $path = prepare_pdf_path($pdf); $option_value = $option_value.$id.'|*|'.$path.'|*|'.$display.'#@#'; } add_option( 'pdf-display-plugin-options', $option_value ); } }The form and it’s process.php only runs on it’s own screen, it’s not meant to run on upload. I could (and now that you point it out, I probably should) split or copy part of the above function and make it it’s own function to run on upload because all it needs to do is update the “pdf-display-plugin-options” in the options, it doesn’t even need the “Saved_Data” or any other forms. I create (and delete) the Saved_Data file through the form because it was the easiest way I could find to change and update one specific part of the “pdf-display-plugin-options” at a time (making the PDF embed or link when you use the shortcode). The part of the plugin that handles Saved_Data and the form has it’s own page.
All it needs to do when a new PDF is uploaded is check to see if THAT pdf is recorded (which it wouldn’t be) and record it if it isn’t.
Right now that function runs on admin_init which kind of works but if I could get it to run that function with the file upload that would be better.
function build_options(){ //Deal with the PDF files $all_pdfs = get_pdf_files(); $options = get_option( 'pdf-display-plugin-options' ); if($options == ''){$options = false; delete_option( 'pdf-display-plugin-options' );} if($options != false){ $data_from_file = 'EMPTY'; $saved_data_array = array(); if(file_exists(plugin_dir_path(__FILE__)."Saved_Data")){ $data_from_file = ''; $data_file = fopen(plugin_dir_path(__FILE__)."Saved_Data", 'r'); $data_from_file = file_get_contents(plugin_dir_path(__FILE__)."Saved_Data"); fclose($data_file); unlink(plugin_dir_path(__FILE__)."Saved_Data"); } if($data_from_file != 'EMPTY'){ $saved_data_array = explode('||', $data_from_file); } $data_array = array(); foreach($saved_data_array as $data){ $parts = explode(':', $data); $data_array[str_replace('display-setting-','',$parts[0])] = $parts[1]; } //var_dump($data_array); //check validity of each entry $real_options = ""; //create an array of pdf entries from the options table $all_pdf_entries = read_pdf_options_table_entry($options); //loop through all entries in the options table foreach($all_pdf_entries as $entry){ if(in_array($entry['path'], $all_pdfs)){ //if the file this entry references exists record it into $real_options $id = $entry['id']; $path = prepare_pdf_path($entry['path']); $display = $entry['display']; //if this entry's display setting was changed if($data_array[$id] != null){ //get the new value $display = $data_array[$id]; } $real_options = $real_options.$id.'|*|'.$path.'|*|'.$display.'#@#'; } } //re-interpret data from this loop $all_pdf_entries = read_pdf_options_table_entry( $real_options ); //gather all recorded paths $paths = gather_all_attr($all_pdf_entries, 'path'); //check to make sure each pdf file has a corresponding entry foreach($all_pdfs as $file){ if(in_array($file, $paths)){ //if this file is already recorded }else{ //If this file is not recorded, create an entry and add it to the master list //first get a valid ID number $id_records = gather_all_attr($all_pdf_entries, 'id'); //count up until you find an ID number that isn't already taken $x = 0; while(in_array($x,$id_records)){ $x++; } $id = $x; $path = prepare_pdf_path($file); $display = 'linked'; $real_options = $real_options.$id.'|*|'.$path.'|*|'.$display.'#@#'; } } update_option('pdf-display-plugin-options', $real_options); }else{ echo $options; $option_value = ''; $id = 0; foreach($all_pdfs as $pdf){ //echo $pdf.'<br>'; $id = $id+1; $display = 'linked'; $path = prepare_pdf_path($pdf); $option_value = $option_value.$id.'|*|'.$path.'|*|'.$display.'#@#'; } add_option( 'pdf-display-plugin-options', $option_value ); } }Though if there’s just a way to make it refresh after the file uploads that might work fine too. I just need to add new PDF files to the options when they’re uploaded or delete them from the options when the file is deleted.
Forum: Fixing WordPress
In reply to: Firefox issueWeird! I fixed it… not sure how I fixed it, but it’s fixed!
Forum: Fixing WordPress
In reply to: Firefox issueAny ideas?
Forum: Fixing WordPress
In reply to: Firefox issueForum: Fixing WordPress
In reply to: Firefox issueIn the browser? We tried that but it didn’t work 🙁
Forum: Plugins
In reply to: [WooCommerce] Image Magnify on Mouse HoverForum: Plugins
In reply to: [WooCommerce] Image Magnify on Mouse HoverNevermind, I figured it out.
Forum: Plugins
In reply to: Is there a plugin to magnify on mouse hover?Ah! I figured it out! The tutorial kind of left out a detail. You can add this by going to your dashboard, click Appearance>Customize and scroll down to the bottom of the panel on the left side and click “Additional CSS” and add the code you want to the bottom.
I’m assuming this is probably easier without the divi theme because I tried just putting this code in our style.css and it didn’t work no matter what I did.
Forum: Plugins
In reply to: Is there a plugin to magnify on mouse hover?Sadly, the last time I tried to reach out to them with a problem like this they literally told me I’d have to figure it out myself so I kind of don’t trust their forum… plus we’d have to pay to use that, kinda not worth the money just to have someone literally say “I don’t know, you’d have to figure that out yourself.” It’s why we stopped paying.
Also, if there’s a way to do this in css/code that would be good too.
- This reply was modified 9 years, 5 months ago by samamerrifield.