How to add nonce tag to inline script for CSP

Is it possible to add nonce tag to inline scripts for wordpress sites using ? I have used a filter script_loader_tag + function for adding tags before but it adds nonce tag only to with src tag. Unfortunately I cant add nonce tag to inline javascript automatically :( So I need a script for some filter which would add nonce tag automatically to tag.
Category: Web

How do I add <div> tags to entire comments, not just their text

Thanks to some wonderful help here at stack exchange, I have built a comment section with a dropdown menu that adds comment_meta to the comments. I currently have a working filter that uses GET to trigger an if statement to query based on this comment_meta info. The thing I don't like is that it refreshes the page each time you click a button. I'm looking for a way to filter without having the page refresh. I think I need Javascript …
Category: Web

list category posts under its item in menu

When adding category to Menu, I need it to list all the item that belong to that category in separate UL automatically. like this http://i.stack.imgur.com/ulOOS.jpg Of course I can do that manually, but I'm look for a way to add a filter, maybe, to the wp page menu function, but Im not sure how its can be done. I'm using thematic child theme Thank you.
Category: Web

how to filter upper and lower case characters in Auto tag link code?

Question: How to filter uppercase and lowercase when the word 'tag' is written in lowercase? and vice versa, how to filter the word 'tag' which is written in capital letters? Here's the code I got from a plugin that hasn't been updated in a few years. function auto_link_tags($content){ //$post_id = get_the_ID(); $post_tags = get_the_tags(); if ($post_tags) { $i = 0; foreach($post_tags as $tag) { $tags[$i] = &quot;~&lt;(?:a\\s.*?&lt;/a&gt;|[^&gt;]+&gt;)(*SKIP)(*FAIL)|\\b(?:\\b(&quot; . $tag-&gt;name . &quot;)\\b(?=[^&gt;]*(&lt;|$)))\\b~i&quot;; $tag_url = get_tag_link($tag-&gt;term_id); $tag_html[$i] = '&lt;a href=&quot;' . $tag_url …
Category: Web

How to replace username with email address in users table

I have a custom built site that does not use usernames and everything requires use of their email address. The username is auto generated and looks bad in the table. I know there are filters and actions to work with custom columns within the users table but I have been looking for a way to replace the username with the email address. I know I can unset the username using manage_users_columns filter but I then loose the row actions. Is …
Category: Web

Dropdown Select Post Filter

I would like to display the posts when I click on an item with the dropdown select Currently, my select is OK, all my terms are displayed and all posts too. I just want to know of it's possible to filter This is my dropdown select : &lt;select name="soins-taxonomy"&gt; &lt;option value="all"&gt;Tout afficher&lt;/option&gt; &lt;?php // Get the taxonomy's terms $terms = get_terms( array( 'taxonomy' =&gt; 'location', 'hide_empty' =&gt; false, 'exclude' =&gt; 1 ) ); // Check if any term exists if …
Category: Web

Jet filter redirection to single post template

I am using the jet filter plugin to filter posts, After applying a filter, I want the &quot;apply filter button&quot; to redirect me to single post template of filtered post ( not on archive page for where the posts listing is shown ) Any one can help me with code?
Category: Web

How to reset/remove added filters 'posts_join' and 'posts_orderby' after the loop is completed?

I am sorting results appear on the category archive page using these filters: posts_join and posts_orderby. There is a widget, which displays recent posts. I am using default recent posts widget of WordPress. But it's not showing any result. When I investigated I found that the applied filters are getting applied to this query. So, I tried remove the filters using the following code: remove_filter('posts_join', 'my_filter_join'); remove_filter('posts_orderby', 'my_filter_orderby'); But still it does not work. I also tried to put the …
Category: Web

Add Featured Image and Title to wp_nav_menu items

I like this solution from Ahmad M, a lot, but how do I add images in addition to titles, instead of replacing titles? (Sorry, I'm still pretty new to PHP and Stackexchange). Pulling Featured Images in to a WordPress Menu I mostly figured it out. I'm using Ahmad M's filter but needed to add ".$menu_object->title" to the thumbnail so now it looks like: $menu_object-&gt;title = has_post_thumbnail($menu_object-&gt;object_id) ? get_the_post_thumbnail($menu_object-&gt;object_id, 'full') . $menu_object-&gt;title . : $menu_object-&gt;title; Now my challenge is that I …
Category: Web

Add Dropdown menu using "add_filter => wp_nav_menu_items"

My project: Wordpress, Woocommerce, Bootstrap 4, bs4navwalker My problem: Custom dropdown item added by WP filter. I have one navbar, 3 differents menus inside (using bs4navwalker), a badge for the cart and a search form. See code. I'm using a filter (add_filter( 'wp_nav_menu_items',) to add login, logout and myaccount details in my navbar, everything is ok, but i'd like to add these items inside a dropdown. The filter just creates one or two more items to the 'user' menu. I …
Category: Web

How can i filter wordpress users by custom feild?

I'm displaying users (authors) on a page. how can I add a filter based on user custom feilds? &lt;?php // THE USER QUERY ARGS $args = [ 'role' =&gt; 'author', 'number' =&gt; -1, ]; // THE USER QUERY $user_query = new WP_User_Query($args); // THE TOTAL SUBSCRIBERS NUMBER echo '&lt;h3 class=&quot;font-weight-bold&quot;&gt;Total Listed Shops: ' . $user_query-&gt;get_total() . '&lt;/h3&gt;'; echo '&lt;hr&gt;'; // THE USER LOOP if (!empty($user_query-&gt;get_results())) { foreach ($user_query-&gt;get_results() as $user) { // ACF PREFIX &amp; FIELD DATA FROM USER PROFILE …
Category: Web

Fatal error: Uncaught Error: Class 'WP_Block_Styles_Registry'

I am having some issues determining the solution to this problem below. The website was sent to our team to fix. Turned on error reporting in wp-config.php: define('WP_DEBUG', true); WordPress version: 5.3.2PHP version: 7.2 WordPress Theme: Grow Pro Fatal error: Uncaught Error: Class 'WP_Block_Styles_Registry' not found in /home/website/public_html/clientsite.com/wp-includes/script- loader.php:2902 Stack trace: #0 /home/website/public_html/clientsite.com/wp-includes/class-wp- hook.php(288): enqueue_block_styles_assets('') #1 /home/website/public_html/clientsite.com/wp-includes/class-wp- hook.php(312): WP_Hook-&gt;apply_filters(NULL, Array) #2 /home/website/public_html/clientsite.com/wp-includes/plugin.php(478): WP_Hook-&gt;do_action(Array) #3 /home/website/public_html/clientsite.com/wp-includes/script- loader.php(2856): do_action('enqueue_block_a...') #4 /home/website/public_html/clientsite.com/wp-includes/class-wp- hook.php(288): wp_common_block_scripts_and_styles('') #5 /home/website/public_html/clientsite.com/wp-includes/class-wp- hook.php(312): WP_Hook-&gt;apply_filters(NULL, Array) #6 /home/website/public_html/clientsite.com/wp-includes/plugin.php(478): WP_Hook-&gt;do_action(Array) #7 …
Category: Web

Filter wp_mail based on content type

I can current filter the content type of the wp_mail function: add_filter( 'wp_mail_content_type', function( $content_type ) { return 'text/html'; }); And I can filter the message content add_filter( 'wp_mail', function( $args ) { $args['message'] = 'Filtered text here'; return $args; }); But how can I only do the latter conditionally? I only want to filter the message when the content type == text/plain. I'm guessing there is a super-simple solution to this, but I haven't worked it out yet.
Category: Web

How to add numeric slug for child page in WordPress 5.9?

I am trying to configure WordPress 5.9 to allow numeric slugs for child pages. Drawing from the 2015 answer to a similar question I took the up-to-date code of wp_unique_post_slug, removed || preg_match( &quot;@^($wp_rewrite-&gt;pagination_base)?\d+$@&quot;, $slug ) and then added it as the following hook to my theme's functions.php. But for some reason, I just get a critical error: &quot;Allowed memory size exhausted&quot;. What can I do to allow numeric slugs for child pages? add_filter( 'wp_unique_post_slug', function ( $slug, $post_ID, $post_status, …
Category: Web

change attachment custom field onChange event

The form is in post creating window. Ajax is posting values, but the values doenst renews. Where can be problem ? Ajax &lt;script&gt; function dynamic_Select(field, aid, value) { console.log(field, aid,value); jQuery.ajax({ type: "POST", url: ajaxurl, data:{ field: field, aid: aid, value: value, }, error: function(){alert('Error!')}, success: function(){alert(value)} }); } &lt;/script&gt; functions.php add_action('wp_ajax_dynselect', 'update_dynamic_select'); add_filter("attachment_fields_to_save", " update_dynamic_select", null , 2); function update_dynamic_select($field, $aid, $value) { update_post_meta($aid, $field, $value); } HTML: &lt;select aid="104" name="_image_matmenys" onchange="dynamic_Select(this.getAttribute('name'), this.getAttribute('aid') ,this.value)"&gt; &lt;option value="10x10"&gt;10x10&lt;/option&gt; &lt;option value="20x20" selected="selected"&gt;20x20&lt;/option&gt; …
Category: Web

filter single_cat_title avoiding the breadcrumbs

I'm developing a simple plug in and I need to filter single_cat_title in category page adding some html in every category page. Just doing this: function subtitleCategory ($title) { return $title."&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=\"container_24\"&gt;&lt;h2 id=\"category-subtitle\"&gt;TEST1&lt;/h2&gt;&lt;/div&gt;"; } add_filter('single_cat_title', 'subtitleCategory'); I get what I need. But I noticed that this filter also apply to the breadcrumbs (there is a call in breadcrumbs.php) and this means twice in the same page (not what I need). Do you know if there is a condition that can …
Category: Web

WordPress Reset password Strength set to medium

I have been looking for an answer for a few days digging through hooks and actions. I just cane seem to find a way to turn down the strength on the reset password page not sure if its through woo-commerce or WP I have tried the following add_filter( 'woocommerce_min_password_strength', 'reduce_woocommerce_min_strength_requirement' ); function reduce_woocommerce_min_strength_requirement( $strength ) { return 2; } add_filter( 'wc_password_strength_meter_params', 'reduce_strength_meter_settings' ); function reduce_strength_meter_settings( $data ) { return array_merge( $data, array( 'min_password_strength' =&gt; 2, 'i18n_password_hint' =&gt; 'Change Hint here' …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.