can someone help me to code JavaScript? (wordpress ratings)

can someone help me to code JavaScript?

enter image description here

<div class="rate-bar" data-rate-value="8">     <div class="rate-dots">          <span></span>         <span></span>         <span></span>         <span></span>         <span></span>         <span></span>         <span></span>         <span></span>         <span class="active setrate">             <span class="rate-text">امتیاز <b>10</b> از 9</span>             </span><span>         </span>     </div> </div> 

demo: https://zoomfilm.info/

How to create custom backend admin menu in different languages?

So I’ve found absolutely nothing about this subject online.

What I’ve done: I successfully programmed a custom admin menu in english for my wordpress backend, according to https://webkul.com/blog/how-to-add-menu-in-wordpress-admin-panel/, so that’s all good.

What I need: If I change the language of the backend (via the user settings in the wordpress backend), every admin menu gets translated to the new (selected) language, except from my custom admin menu, which of course still appears in English. My question is: How / Where do I need to store custom admin menus in other languages, such that they also get their language changed according to the language selected for the backend ??

Potential Security Issue in Custom Taxonomy Search Functionality

I’m wishing to add some functionality to a client WordPress site that allows you to include taxonomy terms from custom post types in the WordPress search, and come across the following answer:

Include custom taxonomy term in search

This solution does work, but in the comments a user has mentioned that it’s “probably not a good idea to inject the raw publicly available search string directly into an SQL query.” and added a link for further reading. I can’t see anything in this link that relates to the specifices of the answer though.

For quick reference the code for the answer is below, would this code be a security risk? And if so what would the solution be so you can still have the functionality of being able to include taxonomy terms in the WP search without the security risk?

Many thanks

// search all taxonomies, based on: http://projects.jesseheap.com/all-projects/wordpress-plugin-tag-search-in-wordpress-23  function atom_search_where($  where){ global $  wpdb; if (is_search())     $  where .= "OR (t.name LIKE '%".get_search_query()."%' AND {$  wpdb->posts}.post_status = 'publish')"; return $  where; }  function atom_search_join($  join){ global $  wpdb; if (is_search())     $  join .= "LEFT JOIN {$  wpdb->term_relationships} tr ON {$  wpdb->posts}.ID = tr.object_id INNER JOIN {$  wpdb->term_taxonomy} tt ON tt.term_taxonomy_id=tr.term_taxonomy_id INNER JOIN {$  wpdb->terms} t ON t.term_id = tt.term_id"; return $  join; }  function atom_search_groupby($  groupby){ global $  wpdb;  // we need to group on post ID $  groupby_id = "{$  wpdb->posts}.ID"; if(!is_search() || strpos($  groupby, $  groupby_id) !== false) return $  groupby;  // groupby was empty, use ours if(!strlen(trim($  groupby))) return $  groupby_id;  // wasn't empty, append ours return $  groupby.", ".$  groupby_id; }  add_filter('posts_where','atom_search_where'); add_filter('posts_join', 'atom_search_join'); add_filter('posts_groupby', 'atom_search_groupby'); 

Reload part of checkout on changed shipping method

So I added the following action to add extra content about ‘local pickup’ to the checkout page.

add_action( 'woocommerce_review_order_before_payment', 'my_custom_action', 20 ); 

When I change the shipping method I want to ‘reload’ the action to hide/show the content in case the shipping method is local pickup.

I’m not an expert on hooks or wordpress ajax… can’t figure this thing out

How can I use a gravity form to send an e-card?

I have a WordPress website that uses Woocommerce to sell printed greeting cards. We would like to enable our customers to be able to email people a digital version of a greeting card. I would like to use gravity forms to obtain the information like email recipient, to, from and personal message..etc. I don’t know how to get Gravity forms to understand what product page the customer is being sent to the form from. I’d like to use the featured image of the product page as the image for the card that is being sent. I’d like to be able to include a link back to the original product page in the email.

I’m open to other ideas but, my employer would prefer that I use tools that we already have. I am able to do things like edit child theme functions.php. Thank you very much for any ideas on how I can create this e-card functionality.

Gutenberg Featured-Image-panel missing when user with custom role edits Custom Post Type

For a WordPress project I made a Custom Post Type in the usual manner. Also i made a custom role. I want users with that role to be able to make, edit and delete this CPT. I added the apropriate capabilities to this role. These are the caps:

'level_1' => true, // seems necessary to asign this author as a post_author by other users 'read' => true, 'view_admin_dashboard' => true, 'upload_files' => true, 'publish_{my_cpts}' => true, 'edit_{my_cpts}' => true, 'edit_others_{my_cpts}' => false, 'delete_{my_cpts}' => true, 'delete_others_{my_cpts}' => false, 'read_private_{my_cpts}' => true, 'edit_{my_cpt}' => true, 'delete_{my_cpt}' => true, 'read_{my_cpt}' => true 

I map these capabilities also in the args for adding the cpt. Upon making the CPT, I did not forget to add ‘thumbnail’ to the ‘supports’ argument. And i added theme-support for thumbnails, also for my cpt

However, i don’t want users with this role to be able to edit ordinary posts.

I think i don’t need to provide more details on this because everything works fine.

Except for the featured image panel in Gutenberg. This panel seems to display only if a user has the edit_posts capability, which my users don’t have. The panel shows for other users, it only remains hidden for users with my custom role.

For now, I made a workaround with an ACF-image field. Images uploaded with this custom field I make the featured-image in a save_post hook.

But this is a workaround, I prefer the usual panel. Any suggestions? I find this an unusual hard nut to crack.

Trying to get Authors ID

I m trying to show the user Score on a Quiz in their posts, I m adding this inside the Single.php loop:

    global $  wpdb;  $  user_id = the_author_ID(); $  table_name = "MYWP_quizresults"; $  sql = "SELECT * FROM ".$  table_name." WHERE user_id = ".intval($  user_id);  $  result = $  wpdb->get_results($  sql);     if(!empty($  result))                       {         foreach($  result as $  row){            echo "ID: ". $  row->user_id. " Name: ". $  row->user_name;     }  } 

Update post meta not working in transition_post_status

I am developing a plugin for custom post type which take the link from the title of the post and then after scraping on that link it updates all things like post title, post permalink and post_meta. Now its only updating the title and the link but not the post meta, I have tried debugging the data.

function a_new_post($  new_status, $  old_status, $  post) {      if ('publish' !== $  new_status or 'publish' === $  old_status)         return;     $  new_slug = sanitize_title($  post->post_title);     if ('aps-products' !== $  post->post_type)         return; // restrict the filter to a specific post type      $  result= getSpecs($  post->post_title);  /* ****************************************************************************** ****************************************************************************** ****************************************************************************** */ $  groups = get_aps_cat_groups(16); $  groups_data = get_aps_groups_data(); $  attrs_data = get_aps_attributes_data();  // get aps attributes data from input fields  foreach ($  groups as $  groupId) {     $  group_data = $  groups_data[$  groupId];     $  group_values = get_aps_product_attributes($  post->ID, $  groupId);      if ($  group_data['attrs']) {         if (aps_is_array($  group_data['attrs'])) {             $  first=array();             $  value='';             foreach ($  group_data['attrs'] as $  attr_id) {                 switch($  attr_id){                     case 20:                         $  value=$  result[1];                     break;                     case 21:                         $  value=$  result[12];                     break;                     case 22:                         $  value=$  result[3];                     break;                     case 24:                         $  value=$  result[13];                     break;                 }                 $  frist[$  attr_id]=$  value;             }             update_post_meta( $  post->ID, 'aps-attr-group-' .$  groupId, $  first );         }     } }    /* ****************************************************************************** ****************************************************************************** ****************************************************************************** */      $  post_update = array(         'ID'         => $  post->ID,         'post_title' => $  result[0].' '.$  result[1]     );     if (!wp_is_post_revision($  post->ID)) {         wp_update_post($  post_update);         $  new_slug = sanitize_title($  result[0].' '.$  result[1]);         if ($  post->post_name != $  new_slug) {             wp_update_post(                 array(                     'ID'        => $  post->ID,                     'post_name' => $  new_slug                  )             );         }     } }