PHP Classes

I need a PHP class for saving file to uploads folder: Class to save PHP scripts to a file in WordPress uploads folder

Recommend this page to a friend!
  All requests RSS feed  >  I need a PHP class for saving file to...  >  Request new recommendation  >  A request is featured when there is no good recommended package on the site when it is posted. Featured requests  >  No recommendations No recommendations  

I need a PHP class for saving file to uploads folder

A request is featured when there is no good recommended package on the site when it is posted. Edit

Picture of Nermin Phelopis by Nermin Phelopis - 4 years ago (2019-10-16)

Class to save PHP scripts to a file in WordPress uploads folder

This request is clear and relevant.
This request is not clear or is not relevant.

+1

I am developing WordPress plugin. This plugin has a lot of addons it will enable and disable using the admininistration settings in WordPress.

I want to create a class to merge all PHP files which will be used by the enabled addons to be in one file with require it once time.

This file will be generated automatically with a generated id.

This file will be automatically removed and a new one is created when the settings are saved (enabled and disable addons).

This file will be made available in the uploads folder of WordPress.

Please advise on if this type of class exists or how can I develop it.

  • 1 Clarification request
  • 1. Picture of adriano ghezzi by adriano ghezzi - 4 years ago (2020-03-05) Reply

    If I well understand requirements this can be a sample solution

    definitions

    -.plugins you have a variable number of plugins each plugin have at least one file associated with it but can have more

    -configFile hold the status of plugin enabled/disabled

    -srcDir all plugin's source file are in the srcDir directory

    features

    -merge merge enabled plugin files in new one file

    -make config write a new configFile

    -enable,disable plugin enable or disable a plugin

    -load config load the configFile

    implementation

    for convention plugin source files are named plugin_1_file_1.<ext> plugn_1_file_2.<ext> plugin_2_file_1.<ext> ...and so on

    configFile contains a php array configArray $configArray[<pluginNumber]=<status>(bool)

    function makeConfig(srcDir,configFile) // generate a new configFile that contains the array $configArray=[]

    browse dir pluginSrc
     for each file
       get the index
       if not exists in configArray add it configArray[<index>]=false
     endfor
     write to config file the array
    

    function pluginEnableDisable(pluginNUmber,status,srcDir,configFile) ::makeConfig(srcDir,configFile) $configArray=require_once $configFile $configFile[pluginNumber]=status

    function mergePlugin($destinationFile,$configFile,$srcDir) open $destination file for writing browse srcDir foreach file

    get plugin number
    check if enabled in configArray
    if enabled open source file as text file
    cycle lines
      read line from source write line to destFile
    end cycle lines
    close source
    

    end cycle files

    ta add or remove plugins simply add or delete source files

    Ask clarification

    Recommend package
    : 
    :