help needed edit file from plugin
-
i am writing a plugin and i want it to have the possibility to change its css from a textarea in the plugin section.
I am able to code the metabox, the textarea(which loads the css file) but i cannot save it, when i press the button. The code is as follows. Please help me
add_action('add_meta_boxes', 'edit_meta_box'); function edit_meta_box() { add_meta_box("edit", "Editor", 'view_edit_box', "resp_edit", "normal"); } function view_edit_box() { $file = stripslashes('style.css'); $plugin_files = get_plugin_files($file); $file = validate_file_to_edit($file, $plugin_files); $real_file = WP_PLUGIN_DIR . '/' . $file; if( isset($_POST['newcontent']) ) { $newcontent = stripslashes($_POST['newcontent']); if ( is_writeable($real_file) ) { $f = fopen($real_file, 'w+'); file_put_contents($f, $newcontent); fclose($f); } //echo $newcontent; } $content = file_get_contents($real_file ); $content = esc_textarea($content); $html1 = '<form action="" method="post"> <table class="form-table"><tbody><tr valign="top"><td> <textarea cols="85" rows="80" name="newcontent" id="newcontent1" tabindex="1">'.$content.' </textarea> </td></tr></tbody> </table> <input type="submit" name="sub" value="Update File"> </form>'; echo $html1; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘help needed edit file from plugin’ is closed to new replies.