Change filename during upload

If you want to use the above sanitize_file_name filter, you could try this: function make_filename_hash($filename) { if( isset($_REQUEST[‘post_id’]) ) { $post_id = (int)$_REQUEST[‘post_id’]; }else{ $post_id=0; } $info = pathinfo($filename); $ext = empty($info[‘extension’]) ? ” : ‘.’ . $info[‘extension’]; $name = basename($filename, $ext); if($post_id>0){ return $post_id.”_”.$name . $ext; }else{ return $name . $ext; } } add_filter(‘sanitize_file_name’, … Read more

How to sanitize user input?

I am not sure if this helpful or not. As s_ha_dum said, you should post how you are processing the submitted data and sending to db. But for starters, you might look at escaping the outputted data in the form: <input style=”width:100%” type=”text” name=”dataHow to sanitize user input?” id=”title” value=”<?php $title = get_option(‘data_test’); echo esc_attr($title[‘title’]); … Read more

Echo JavaScript Safely

What you’re asking for is impossible, there is no such thing as a safe javascript entry box. Even if we strip out extra script and style tags, it’s pointless, as the javascript code itself is inherently dangerous, and can create any elements it wants using DOM construction, e.g.: var s = jQuery( ‘script’, { ‘src’: … Read more

Cannot get ‘sanitize_callback’ to work for rest parameters

You’re not getting the TESTING because your playlist argument should actually be in the args array like so: (reindented for brevity) register_rest_route( SoundSystem::$rest_namespace, ‘/playlist/new’, array( ‘methods’ => WP_REST_Server::CREATABLE, ‘callback’ => array( __class__, ‘rest_add_playlist’ ), ‘permission_callback’ => function () { return is_user_logged_in(); }, ‘args’ => array( ‘playlist’ => array( ‘description’ => __( ‘JSPF playlist data’, ‘soundsystem’ … Read more

vs WordPress Security

In the articles case, $title is an arbitrary value, as such it should be escaped via html, but, if it was gotten from a WordPress core function it is probably safe, but you should check anyway For example, get_the_title() can contain html markup and is not escaped by default. Eitherway post and page titles should … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)