Creating directory and file using native wordpress file system

I am creating directory and a css file using conventional php method. Here it is $upload_dir = wp_upload_dir(); $dirpath = $upload_dir[‘basedir’] . ‘/dynamic/’; $filepath = $dirpath. ‘dynamic.css’; if( !file_exists($filepath) ){ mkdir($dirpath); $fh = fopen($filepath, “w”); fclose($fh); } But I want to use native wp filesystem .I have tried if(!$wp_filesystem->is_dir( $dirpath) { $wp_filesystem->mkdir( $dirpath); } Now … Read more

What is the best way to move a plugin´s subdirectory+files to wp-content/uploads-directory?

I am developer of the plugin Leaflet Maps Marker (http://www.mapsmarker.com – “Pin, organize & show your favorite places through OpenStreetMap, OGD Vienna or any custom WMTS-map”) and have one question: the plugin contains about 100 marker icons from Maps Icons Collection (mapicons.nicolasmollet.com) which can be used to mark your favorite places. These icons are stored … Read more

how to change max file upload size WordPress 4.9.8 [closed]

Closed. This question is off-topic. It is not currently accepting answers. Closed 3 years ago. Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question? Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS … Read more

Using wp_filesystem in Plugins to store customizer settings

I try to fix my plugin with the answers i got here: Using wp_filesystem in Plugins Background i wrote a theme (https://github.com/bassjobsen/jamedo-bootstrap-start-theme) and a plugin (https://github.com/bassjobsen/wp-less-to-css) now i want to integrate the plugin in the theme. The plugin wrote a CSS file to a folder. Write files with native PHP function is not secure as … Read more

Convert PHP readfile to WP_Filesystem

In the script below, I need to convert the readfile to the WP_filesytem equivalent. However, I can’t find same in Codex. Any help much appreciated. This script saves the settings.ini file to the user’s desktop/pc. WP_Filesystem(); global $wp_filesystem; $mySettingsFileLocation = WP_PLUGIN_DIR.’/my-settings/settings.ini’; if ( ! $wp_filesystem->put_contents( $mySettingsFileLocation, $mySettings, 0644) ) { return true; } // Define … Read more

Why cant the WP Filesystem API read googlefonts.json?

I’ve inherited a site built with a theme by Highgrade (southcentral) which is built using the Redux framework. I’m seeing the following error in the frontend and admin panel: Warning: Invalid argument supplied for foreach() in /Volumes/Data/Users/me/Sites/reference360.eu/wordpress/wp-content/themes/southcentral/highgrade/framework/inc/fields/typography/field_typography.php on line 772 I’ve tried altering permissions and ownership on googlefonts.json but to no avail. The problem seems … Read more

What to use , set_transient, set_option or file system? [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago. Improve this question I have a shortcode that can parse page contents. For example you give it a link … Read more

$wp_filesystem returns NULL. What are the dependencies?

I need to obtain a reference to the $wp_filesystem object. In the test below, the var_dump($wp_filesystem) returns NULL. What additional files are required in order to properly set up $wp_filesystem? I was expecting that since its called in file.php, loading that file would be sufficient to load the object. <?php require(‘../../../wp-blog-header.php’); require(‘../../../wp-admin/includes/file.php’); $mytest = somefunction(); … Read more