How to run php code only for a specific widget on a page and not all widgets on that page?

I want to display extra information below the post title only for the posts widget on the home page and not the portfolio widget. I’m using WordPress’ the_title filter to do this and that works fine, but at the moment, it shows the extra info in both the portfolio and the posts widgets. I need a condition to restrict the filtering only to the posts widget. The post widget’s class name is "home-post-widget"

My current code looks like this.

function add_rating_html( $  title) {      if (in_the_loop()){         $  out = "Rating: 5";         $  title .= $  out;     }     return $  title; }  add_filter('the_title', 'add_rating_html',1);  

Any help would be most appreciated.

Rate limiter code

I am new to coding and would like a professionals response on how to properly code (Python) a rate limiter in which the webmaster asks for only 10 request per min.I have included what I have done so far:

one_min = 60

@limits(calls=10, period=one_min)

def call_api(url):

response = requests.get(url)  if response.status_code !=200:     raise Exception('API response: {}'.format(response.status_code))     return response 

I want to know if the attact on my websites were successful based on the response code from my server

My websites got attacked with a bruteforce attack and this is the log I get from my server. Just want to confirm that they didn’t got any data

 20.96.201.62 - - [20/Jul/2021:09:21:19 -0700] "POST //xmlrpc.php HTTP/1.1" 200 401 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4240.193 Safari/537.36" 

Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?

I am using the Code Snippets Plugin for WordPress to send a jQuery Ajax request but I keep receiving a

POST https://mywebsite.com/wp-admin/admin-ajax.php 400 (Bad Request)

I have tried what seems to be a thousand ways to formulate the Ajax request following examples from stackoverflow, jQuery forums, WordPress forums, and it goes on. Always with the same error.

Here is what I currently have in my Snippet editor: JavaScript code

var jq = jQuery.noConflict(); // a bunch of code to determine what day is selected on a calendar, this all works up until the ajax call jq(".c-day-content").click(function () {     console.log ("handled the day being picked quite nicely...");         day = jq(this).text();         day = day.replace(/[^0-9]/g,'');         console.log("day=" + day);     bookingStart = bookingStart.concat(day);     //query the db looking for time slots with appointments and returning this array      var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ) ?>';     console.log(ajaxurl);      jq.ajax({         url: ajaxurl,         data: {             action: "retrieveAttendees",             dateSelected: bookingStart //bookingStart is variable that has a string value         },         method: 'POST',         success: function(data, XMLHttpRequest) {             //never been able to make it to here             console.log(JSON.stringify(data));         },         error: function (XMLHttpRequest, textStatus, errorThrown) {             console.log("we failed again: " + JSON.stringify(XMLHttpRequest));             console.log("text status: " + textStatus);             console.log("errorThrown: " + errorThrown)         }     });  

Then my php handler inside the same snippet editor:

function retrieveAttendees_request() { console.log("made it to the ajax request"); // I've never made it here either if ( isset($  _REQUEST)) {     $  bookingDay = $  _REQUEST['dateSelected'];     global $  wpdb;     $  sql = $  wpdb->prepare("select apps.bookingStart, COUNT(*) as booked from wp_amelia_customer_bookings as books inner join wp_amelia_appointments as apps on books.appointmentId = apps.id where apps.bookingStart like %s'%' and apps.status = 'approved' GROUP BY books.appointmentId;", $  bookingDay);     $  result = $  wpdb->get_row($  sql, ARRAY_A);     echo json_encode($  result); }   die(); } add_action('wp_ajax_retrieveAttendees', 'retrieveAttendees_request'); add_action('wp_ajax_nopriv_retrieveAttendees', 'retrieveAttendees_request'); 

I have tried adding the dataType to the Ajax, no luck. Tried adding both dataType and ContentType, no luck. I have no clue as to why I keep getting the same POST 400 Bad Request error. I would appreciate any help and insight.

Short code to modify the user profile from the frontend

I am trying to pass a template that I found here to a short code to display on a page on the frontend.

Now now I have the following:

// profile action hook - catches form submission and acts accordingly add_action('init','profile_form_submission'); function profile_form_submission() {      /* Get user info. */     global $  current_user, $  wp_roles;     //get_currentuserinfo(); //deprecated since 3.1      /* Load the registration file. */     //require_once( ABSPATH . WPINC . '/registration.php' ); //deprecated since 3.1     $  error = array();         /* If profile was saved, update profile. */     if ( 'POST' == $  _SERVER['REQUEST_METHOD'] && !empty( $  _POST['action'] ) && $  _POST['action'] == 'update-user' ) {          /* Update user password. */         if ( !empty($  _POST['pass1'] ) && !empty( $  _POST['pass2'] ) ) {         if ( $  _POST['pass1'] == $  _POST['pass2'] )             wp_update_user( array( 'ID' => $  current_user->ID, 'user_pass' => esc_attr( $  _POST['pass1'] ) ) );         else             $  error[] = __('Las contraseñas no son iguales, por lo tanto, no fueron actualizadas.', 'profile');         }          /* Update user information. */         if ( !empty( $  _POST['url'] ) )         wp_update_user( array( 'ID' => $  current_user->ID, 'user_url' => esc_url( $  _POST['url'] ) ) );         if ( !empty( $  _POST['email'] ) ){         if (!is_email(esc_attr( $  _POST['email'] )))             $  error[] = __('Este email no es valido, pruebe otra vez.', 'profile');         elseif(email_exists(esc_attr( $  _POST['email'] )) != $  current_user->id )             $  error[] = __('Este email ya esta en uso por otro usuario, pruebe con otro.', 'profile');         else{             wp_update_user( array ('ID' => $  current_user->ID, 'user_email' => esc_attr( $  _POST['email'] )));         }         }           /* Redirect so the page will show updated info.*/       /*I am not Author of this Code- i dont know why but it worked for me after changing below line to if ( count($  error) == 0 ){ */         if ( count($  error) == 0 ) {         //action hook for plugins and extra fields saving         do_action('edit_user_profile_update', $  current_user->ID);         wp_redirect( get_permalink() );         exit;         }     } }  // shows login form (or a message, if user already logged in) function get_profile_customers_form($  redirect) {             if ( !is_user_logged_in() ) {         $  return = .__('Tienes que estar logueado para modificar esta pagina.', 'profile');             else {                 if ( count($  error) > 0 ) echo '<p class="error">' . implode("<br />", $  error) . '</p>';                 <form method="post" id="adduser" action="<?php the_permalink(); ?>">                     <p class="form-email">                         <label for="email"><?php _e('E-mail *', 'profile'); ?></label>                         <input class="text-input" name="email" type="text" id="email" value="<?php the_author_meta( 'user_email', $  current_user->ID ); ?>" />                     </p><!-- .form-email -->                     <p class="form-password">                         <label for="pass1"><?php _e('Contraseña *', 'profile'); ?> </label>                         <input class="text-input" name="pass1" type="password" id="pass1" />                     </p><!-- .form-password -->                     <p class="form-password">                         <label for="pass2"><?php _e('Confirmar *', 'profile'); ?></label>                         <input class="text-input" name="pass2" type="password" id="pass2" />                     </p><!-- .form-password -->                      <?php                          //action hook for plugin and extra fields                         do_action('edit_user_profile',$  current_user);                      ?>                     <p class="form-submit">                         <?php echo $  referer; ?>                         <input name="updateuser" type="submit" id="updateuser" class="submit button" value="<?php _e('Actualizar cuenta', 'profile'); ?>" />                         <?php wp_nonce_field( 'update-user' ) ?>                         <input name="action" type="hidden" id="action" value="update-user" />                     </p><!-- .form-submit -->                 </form><!-- #adduser -->    }  // adds a handy [profile_form_submission] shortcode to use in posts/pages add_shortcode('profile_form_submission','profile_form_submission_shortcode'); function vr_login_shortcode ($  atts,$  content=false) {   $  atts = shortcode_atts(array(     'redirect' => home_url()   ), $  atts);   return get_profile_customers_form($  atts['redirect']); } 

I don’t know how to do the part of the code that the form shows. It is from "// shows login form (or a message, if user already logged in)".

The original code that I am trying to adapt was the following:

    <?php if ( !is_user_logged_in() ) : ?>             <p class="warning">                 <?php _e('Tienes que estar logueado para modificar esta pagina.', 'profile'); ?>             </p><!-- .warning -->     <?php else : ?>         <?php if ( count($  error) > 0 ) echo '<p class="error">' . implode("<br />", $  error) . '</p>'; ?>         <form method="post" id="adduser" action="<?php the_permalink(); ?>">             <p class="form-email">                 <label for="email"><?php _e('E-mail *', '<br />', 'profile'); ?></label>                 <input class="text-input" name="email" type="text" id="email" value="<?php the_author_meta( 'user_email', $  current_user->ID ); ?>" />             </p><!-- .form-email -->             <p class="form-password">                 <label for="pass1"><?php _e('Contraseña *',"<br>", 'profile'); ?> </label>                 <input class="text-input" name="pass1" type="password" id="pass1" />             </p><!-- .form-password -->             <p class="form-password">                 <label for="pass2"><?php _e('Confirmar *',"<br>", 'profile'); ?></label>                 <input class="text-input" name="pass2" type="password" id="pass2" />             </p><!-- .form-password -->              <?php                  //action hook for plugin and extra fields                 do_action('edit_user_profile',$  current_user);              ?>             <p class="form-submit">                 <?php echo $  referer; ?>                 <input name="updateuser" type="submit" id="updateuser" class="submit button" value="<?php _e('Actualizar cuenta', 'profile'); ?>" />                 <?php wp_nonce_field( 'update-user' ) ?>                 <input name="action" type="hidden" id="action" value="update-user" />             </p><!-- .form-submit -->         </form><!-- #adduser --> 

Code snippet to display ID gives critical error

Based on this post, I added the code snippet below to my WordPress site, as to display the ID in the Posts section of each post. However, it returns "critical error". Any idea what is wrong with this code?

add_filter( 'manage_posts_columns', 'column_register_wpse_101322' ); add_filter( 'manage_posts_custom_column', 'column_display_wpse_101322', 10, 3 );  function column_register_wpse_101322( $  columns ) {     $  columns['uid'] = 'ID';     return $  columns; }  function column_display_wpse_101322( $  empty, $  column_name, $  post_id ) {     if ('uid' != $  column_name) {return $  empty;}     return "$  post_id"; } 

I want to change this matlab code to Mathematica? can you help me

my code have one matrix entry and works as QR decompose method by using Givens rotation and its outputs contain 2 matrix as Q and R I want to run this code in mathematica without using Matlink package…..can you help me by rewriting this code in mathematica Language eye is the IdentityMatrix and norm(a,b) is $ \sqrt{(a^2+b^2)}$ Thank you for HELP

function [Q,R] = my_givens_QR(A) n = size(A,1);  Q=eye(n); R=A; for j=1:n for i=n:(-1):j+1 x=R(:,j); if norm([x(i-1),x(i)])>0 c=x(i-1)/norm([x(i-1),x(i)]); s=-x(i)/norm([x(i-1),x(i)]); G=eye(n); G([i-1,i],[i-1,i])=[c,s;-s,c]; R=G'*R; Q=Q*G; end end end 

Optimize molecule distance analyzing code

I have a very large dataset (31552000 lines) of xyz coordinates in the following format

1 2 3 4 5 6  7 8 9 . . .  

I have to take a distance using the special method below.

Distance[{a_, b_, c_}, {d_, e_, f_}] :=   Sqrt[(If[Abs[a - d] >= (40/2), Abs[a - d] - 40, Abs[a - d]])^2 + (If[       Abs[b - e] >= (40/2), Abs[b - e] - 40, Abs[b - e]])^2 + (If[       Abs[c - f] >= (40/2), Abs[c - f] - 40, Abs[c - f]])^2] 

Then I import the data.

data = Partition[    Partition[ReadList["input.txt", {Real, Real, Real}], 16], 38]; 

The formatting is kind of strange. Every 16 rows is one molecule, and every 38 molecules is one timestep. I take the distance between the 16th atom of each molecule and the 5th atom of each molecule.Then I select the distances that are less than 5.55 and determine the length of the resulting list. This is repeated for each of the 29,000 timesteps.

analysis =   Flatten[    Table[     Table[      Length[       Select[        Table[         Distance[data[[r, y, 16]], data[[r, x, 5]]],         {x, 1, 38}],        # <= 5.55 &]       ],      {y, 1, 38}],     {r, 1, 29000}]    ]; 

This last section is my most computationally intensive part. For 29000 timesteps and 38 molecules, it takes 40 minutes to process fully. It also takes too much memory (16+ gigs per kernel) to parallelize. Is there any other method that will improve the performance? I have tried using compile, but I realized that Table, the biggest bottleneck, is already complied to machine code.

Below is an example of a dataset that takes my computer 2 minutes to complete with the analysis code. It is scalable to larger timesteps by changing 4000 to larger numbers.

data = Partition[   Partition[Partition[Table[RandomReal[{0, 40}], (3*16*38*4000)], 3],     16], 38]