Reply To: Trying to stop JS to add in-line CSS for the .orig class

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Trying to stop JS to add in-line CSS for the .orig class Reply To: Trying to stop JS to add in-line CSS for the .orig class

#4450
Ernest Marcinko
Ernest Marcinko
Keymaster

Hi!

I highly discourage you to do direct modifications to the search query or javascript codes.

There are filter and actions hooks available + a template files to do such modifications safely.

1. The inline CSS is a result of CSS and JS animations, they are mandatory. If I were you I would take a different approach and instead of touching the code, create CSS with higher specificity. For example:

input.orig {
   width: 200px !important;
}

The !important modifier will override the inline CSS, that’s the only option you can use here. I know it’s nasty to use it, but in this case it’s more redundant – because if your friend decides to update the search plugin, all your modifications are gone. However the custom CSS always stays.

2. Meta fields are stored in the post meta table, but there is a much better way of getting that information than modifying the code. If you haven’t heard of WordPress Plugin API yet, I HIGHLY recommend learning about it. It’s the standard and best way to communicate with a plugin, without touching it’s code.

In WordPress plugin developement there is something called a “filter”. A filter is an entrance point for a function. Filters are placed to various point of the plugin code by developers (like me) to make data manipulation easier for other developers (like you).
You can create a function and attach it to a “filter” point. Your function will accept the parameters defined by the filter. For example you can modify any post content by creating a function and attaching it to the filter called “the_content”.

My plugin also has “filter” points available. You can see the list in the filters.txt file in the main plugin directory. For example usage take a look at this: https://wp-dreams.com/knowledge-base/numbering-the-results/

Based on that example you can construct the desired code, something like:

add_filter( 'asp_results', 'asp_get_a_custom_field', 1, 1 );
 
function asp_get_a_custom_field( $results ) {
  foreach ($results as $k=>$v) {
    // Let's get the meta and store it in the $r->my_meta variable
    $results[$k]->my_meta  = get_post_meta( $results[$k]->id, 'clx_event_city', true )
  }
 
  return $results;
}

After that, the my_meta will store the clx_event_city meta value.

Good luck with coding!

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)