WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

PclZip::add() public WP 1.0

Function : add($p_filelist, $p_add_dir="", $p_remove_dir="") add($p_filelist, $p_option, $p_option_value, ...) Description : This method supports two synopsis. The first one is historical. This methods add the list of files in an existing archive. If a file with the same name already exists, it is added at the end of the archive, the first one is still present. If the archive does not exist, it is created. Parameters : $p_filelist : An array containing file or directory names, or a string containing one filename or one directory name, or a string containing a list of filenames and/or directory names separated by spaces. $p_add_dir : A path to add before the real path of the archived file, in order to have it memorized in the archive. $p_remove_dir : A path to remove from the real path of the file to archive, in order to have a shorter path memorized in the archive. When $p_add_dir and $p_remove_dir are set, $p_remove_dir is removed first, before $p_add_dir is added. Options : PCLZIP_OPT_ADD_PATH : PCLZIP_OPT_REMOVE_PATH : PCLZIP_OPT_REMOVE_ALL_PATH : PCLZIP_OPT_COMMENT : PCLZIP_OPT_ADD_COMMENT : PCLZIP_OPT_PREPEND_COMMENT : PCLZIP_CB_PRE_ADD : PCLZIP_CB_POST_ADD : Return Values :
0 on failure, The list of the added files, with a status of the add action. (see PclZip::listContent() for list entry format)

Это метод класса: PclZip{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

$PclZip = new PclZip();
$PclZip->add( $p_filelist );

Код PclZip::add() WP 5.5.1

wp-admin/includes/class-pclzip.php
<?php
function add($p_filelist)
{
  $v_result=1;

  // ----- Reset the error handler
  $this->privErrorReset();

  // ----- Set default values
  $v_options = array();
  $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;

  // ----- Look for variable options arguments
  $v_size = func_num_args();

  // ----- Look for arguments
  if ($v_size > 1) {
    // ----- Get the arguments
    $v_arg_list = func_get_args();

    // ----- Remove form the options list the first argument
    array_shift($v_arg_list);
    $v_size--;

    // ----- Look for first arg
    if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {

      // ----- Parse the options
      $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
                                          array (PCLZIP_OPT_REMOVE_PATH => 'optional',
                                                 PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
                                                 PCLZIP_OPT_ADD_PATH => 'optional',
                                                 PCLZIP_CB_PRE_ADD => 'optional',
                                                 PCLZIP_CB_POST_ADD => 'optional',
                                                 PCLZIP_OPT_NO_COMPRESSION => 'optional',
                                                 PCLZIP_OPT_COMMENT => 'optional',
                                                 PCLZIP_OPT_ADD_COMMENT => 'optional',
                                                 PCLZIP_OPT_PREPEND_COMMENT => 'optional',
                                                 PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
                                                 PCLZIP_OPT_TEMP_FILE_ON => 'optional',
                                                 PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
                                                 //, PCLZIP_OPT_CRYPT => 'optional'
												   ));
      if ($v_result != 1) {
        return 0;
      }
    }

    // ----- Look for 2 args
    // Here we need to support the first historic synopsis of the
    // method.
    else {

      // ----- Get the first argument
      $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];

      // ----- Look for the optional second argument
      if ($v_size == 2) {
        $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
      }
      else if ($v_size > 2) {
        // ----- Error log
        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");

        // ----- Return
        return 0;
      }
    }
  }

  // ----- Look for default option values
  $this->privOptionDefaultThreshold($v_options);

  // ----- Init
  $v_string_list = array();
  $v_att_list = array();
  $v_filedescr_list = array();
  $p_result_list = array();

  // ----- Look if the $p_filelist is really an array
  if (is_array($p_filelist)) {

    // ----- Look if the first element is also an array
    //       This will mean that this is a file description entry
    if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
      $v_att_list = $p_filelist;
    }

    // ----- The list is a list of string names
    else {
      $v_string_list = $p_filelist;
    }
  }

  // ----- Look if the $p_filelist is a string
  else if (is_string($p_filelist)) {
    // ----- Create a list from the string
    $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
  }

  // ----- Invalid variable type for $p_filelist
  else {
    PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
    return 0;
  }

  // ----- Reformat the string list
  if (sizeof($v_string_list) != 0) {
    foreach ($v_string_list as $v_string) {
      $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
    }
  }

  // ----- For each file in the list check the attributes
  $v_supported_attributes
  = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
           ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
           ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
           ,PCLZIP_ATT_FILE_MTIME => 'optional'
           ,PCLZIP_ATT_FILE_CONTENT => 'optional'
           ,PCLZIP_ATT_FILE_COMMENT => 'optional'
						);
  foreach ($v_att_list as $v_entry) {
    $v_result = $this->privFileDescrParseAtt($v_entry,
                                             $v_filedescr_list[],
                                             $v_options,
                                             $v_supported_attributes);
    if ($v_result != 1) {
      return 0;
    }
  }

  // ----- Expand the filelist (expand directories)
  $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
  if ($v_result != 1) {
    return 0;
  }

  // ----- Call the create fct
  $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
  if ($v_result != 1) {
    return 0;
  }

  // ----- Return
  return $p_result_list;
}