/** * @param $action * @param null $submitText */ public function displayForm($action, $submitText = null) { $bytes = wp_max_upload_size(); $size = size_format($bytes); $upload_dir = IfwPsn_Wp_Proxy_Blog::getUploadDir(); if ($submitText == null) { $submitText = __('Upload', 'ifw'); } if (!empty($upload_dir['error'])) { ?> <div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?> </p> <p><strong><?php echo $upload_dir['error']; ?> </strong></p></div><?php } else { $allowedExtensions = $this->getMimeTypes() != null ? implode(',', array_unique(array_keys($this->getMimeTypes()))) : null; $label = sprintf('Choose a file from your computer (Maximum size: %s%s)', $size, $allowedExtensions !== null ? ', ' . __('allowed extensions: ') . $allowedExtensions : ''); ?> <form enctype="multipart/form-data" id="<?php echo $this->_id; ?> -upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url($action); ?> "> <?php echo wp_nonce_field($this->_getNonceName()); ?> <p> <label for="upload-<?php echo $this->_id; ?> "><?php echo $label; ?> </label> <input type="file" id="upload-<?php echo $this->_id; ?> " name="<?php echo $this->_id; ?> " size="25" /> <input type="hidden" name="action" value="upload" /> <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?> " /> </p> <?php submit_button($submitText, 'button'); ?> </form> <?php } }
/** * @return mixed */ protected function _init() { if ($this->_module->isCustomModule()) { $uploadDir = IfwPsn_Wp_Proxy_Blog::getUploadDir(); $this->_url = $uploadDir['baseurl'] . '/' . $this->_customLocationName . '/' . $this->_pathinfo->getDirname() . '/'; } else { // built-in module $dirnamePathParts = array_reverse(explode(DIRECTORY_SEPARATOR, $this->_pathinfo->getDirnamePath())); $this->_url = plugins_url($dirnamePathParts[3]) . '/modules/' . $this->_pathinfo->getDirname() . '/'; } $this->_urlFiles = $this->_url . 'files/'; $this->_urlCss = $this->_urlFiles . 'css/'; $this->_urlJs = $this->_urlFiles . 'js/'; $this->_urlImg = $this->_urlFiles . 'img/'; $this->_version = $this->_module->getVersion(); $this->_name = $this->_module->getName(); $this->_description = $this->_module->getDescription(); $this->_textDomain = $this->_module->getTextDomain(); $this->_homepage = $this->_module->getHomepage(); }
/** * Retrieves dir to search for custom modules * @return null|string */ public function getCustomModulesLocation() { $uploadDir = IfwPsn_Wp_Proxy_Blog::getUploadDir(); $dirName = $this->getCustomModulesLocationName(); if (is_array($uploadDir) && (isset($uploadDir['error']) && empty($uploadDir['error'])) && (isset($uploadDir['basedir']) && !empty($uploadDir['basedir']))) { return $uploadDir['basedir'] . DIRECTORY_SEPARATOR . $dirName . DIRECTORY_SEPARATOR; } return null; }