Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6132659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:07:46+00:00 2026-05-23T17:07:46+00:00

This function creates an .ini file and saves it to a folder on the

  • 0

This function creates an .ini file and saves it to a folder on the server. What would I need to do to create a version that gives the user the option to save the file locally?

function wpseTest()
{
    $query = "SELECT option_name, option_value FROM wp_options where option_name like 'test|_%' escape '|' AND option_value > ''";
    global $wpdb;
    $matches = $wpdb->get_results($query);

    $mySettings = "[settings]\r\n";

    foreach ($matches as $result){
        $mySettings .= $result->option_name;
        $mySettings .= ' = ';
        $mySettings .= '"'.str_replace("\r\n", "", addslashes($result->option_value)).'"';
        $mySettings .= "\r\n";
    }
    $mySettingsFileLocation = WP_PLUGIN_DIR.'/test/test-backup.ini';
    $mySettingsFile = fopen($mySettingsFileLocation, 'w');
    fwrite($mySettingsFile, $mySettings);fclose($mySettingsFile);
    copy($mySettingsFileLocation, WP_PLUGIN_DIR.'/test/test-'.date("F-j-Y-g-i-s-a").'.ini');
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:07:47+00:00Added an answer on May 23, 2026 at 5:07 pm

    Well, if you’re just trying to let the person download, then then store it locally (call wpseTest()), and redirect them to somewhere with the appropriate headers (this can be done via iframe or a new window/tab):

    header("Content-type: application/force-download");
    header("Content-Disposition: attachment; filename=\"backup.ini\"");
    header("Content-Length: ".filesize(WP_PLUGIN_DIR.'/test/test-backup.ini'));
    readfile(WP_PLUGIN_DIR.'/test/test-backup.ini');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a function that uses a loop. This function will open
i'm referring this address for function olLiTree PHP function that creates a nested ul
Ok, I have one JavaScript that creates rows in a table like this: function
How would I create a nested list, I currently have this public function getNav($cat,$subcat){
This is a Function that does the following: Create a random Token with 8
I have this function that creates a unique number for hard-disk and CPU combination.
I want to manually have a function that creates a MIDI file according to
I've written an INI class that loads/saves/creates an INI data format, however right now
ajax tutorial on w3school at http://www.w3schools.com/ajax/ajax_database.asp In this function (function GetXmlHttpObject()), it creates a
I have this function: CREATE OR REPLACE FUNCTION CREATE_AIRSPACE_AVAILABILITY_RECORD (cur_user VARCHAR, start_time VARCHAR, start_date

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.