Restrict characters in comment section

Never edit the WordPress core files. Instead you should hook into the pre_comment_content, which is where the comment text from the textarea is being sanitized, before it’s inserted into the database. In the example below preg_replace is used to sanitize the comment text submitted. You should modify the function to fit your needs. function keha_filter_comment( … Read more

How do I sanitize the str_replace function in javascript variables

esc_js() is intended for escaping data for use within an HTML attribute. If you want to escape data for use within an inline script, wp_json_encode() should be sufficient. For example: var disabledDays = <?php echo wp_json_encode( $iva_disable_days ); ?>; This outputs: var disabledDays = [“4\/7\/2018″,”11\/18\/2017”]; If you check the variable in your dev tools console, … Read more

How can I apply custom sanitization to new usernames?

sanitize_user function has a sanitize_user filter. The filter gives you $username, $raw_username, $strict from the sanitize_user and expects you to return $username, according to the inline documentation: /** * Filters a sanitized username string. * * @since 2.0.1 * * @param string $username Sanitized username. * @param string $raw_username The username prior to sanitization. * … Read more

WP_Customize_Manager: How to get control ID

I think this is probably not right approach for the way the Customiser is organised. Controls and Settings are pretty much separate entities. Controls can save settings, but settings aren’t tied to a specific control. As far as I’m aware there’s nothing stopping you having multiple controls for a single setting, for example. My suggestion … Read more

HTML in category name

Thanks all @ValentinGenev i choose this option, but i’m totally newbie so i Have to study WP much more in order to follow your lead. I found this in my theme (extras.php): if ( $child_theme_support == ‘default’ ) { $categories_list = get_the_category_list(esc_html__(‘, ‘, ‘blossom-fashion-pro’)); }else{ $categories_list = get_the_category_list(esc_html__(‘ ‘, ‘blossom-fashion-pro’)); } if ($categories_list) { echo … Read more

Change user nicename without sanitize

The title is being converted to lowercase by filter sanitize_title // in wp-includes/default-filters.php add_filter( ‘sanitize_title’, ‘sanitize_title_with_dashes’, 10, 3 ); // it means => calling sanitize_title_with_dashes() in wp-includes/formatting.php Here is explanation to what can do, recommended and not recommended method Not Recommended You may remove this filter but not recommmended Because this filter is for converting … Read more

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