esc_url, esc_url_raw or sanitize_url?

This might be a more useful demonstration: <a href=”<?php echo esc_url( $url ); ?>>I’m printing a URL to the frontend</a> $url = sanitize_url( $_GET[‘user_inputted_data’] ); update_post_meta( $post_id, ‘that_url’, $url ); esc_url is an escaping function, sanitize_url is a sanitising function. Sanitising functions clean incoming data, e.g. removing letters from phone numbers, stripping trailing space etc. … Read more

oneOf two possible objects in WP REST API?

Aight got it, the crucial missing thing was that you have to provide this part here: ‘type’ => ‘object’ twice; once when declaring the variable’s type, and once again when defining the possibilities. Otherwise, validation fails; so a proper example would be: ‘args’ => [ ‘data’ => [ ‘type’ => ‘object’, ‘oneOf’ => [ [ … Read more

wp_set_object_terms() without accents

Just thought I’d point out, your call to remove_accent() is incorrect, you are missing the s off of accents. Example from codex: $text = “Hoy será un gran día”; echo remove_accents($text); Echo result: Hoy sera un gran dia https://codex.wordpress.org/Function_Reference/remove_accents

How to use esc_attr__() function properly to translate a variable that contains string?

If you have static text with dynamic content then you can use. printf( esc_attr___(‘static text goes here with %s’, ‘text-domain’ ), $title ); If you have only $title then no need to translate it. Just escape it. echo esc_attr( $title ); Note esc_attr, esc_attr__ and esc_attr_e used for escaping dynamic values from HTML element attributes. … Read more

Customizer sanitize_callback for input type number

Add a setting, specifying the sanitize_callback: $wp_customize->add_setting( ‘my_input’, array( ‘default’ => ‘100.00’, ‘sanitize_callback’ => ‘sanitize_float’, ) ); Add the control: $wp_customize->add_control( ‘my_input’, array( ‘label’ => ‘Please enter a number:’, ‘section’ => ‘my_section’, ‘type’ => ‘number’, ‘input_attrs’ => array( ‘min’ => ‘0.01’, ‘step’ => ‘0.01’, ‘max’ => ‘10000’, ), ) ); Create a function to perform … Read more

Data validation for inline javascript

You can use addslashes() and stripslashes() to prepare any data for database entry. These are native PHP functions, not wordpress functions, so they do not necessarily need to be hooked anywhere specific in the wordpress load to work.

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