allanext
Forum Replies Created
-
Forum: Plugins
In reply to: [Spectra Legacy – Gutenberg Blocks] Tab anchors not workingok just did.
I think we should keep this open till the issue is resolved.
Thank you
Forum: Plugins
In reply to: [Spectra Legacy – Gutenberg Blocks] Tab anchors not workingForum: Plugins
In reply to: [Spectra Legacy – Gutenberg Blocks] Tab anchors not workingHi @swetakumari,
Yes, I’m using “The Ultimate Addons for Gutenberg” Tabs, I’ve installed this plugin just for the Tabs!
Thank you!
Forum: Plugins
In reply to: [Spectra Legacy – Gutenberg Blocks] Tab anchors not workingSorry for getting back only now.
I’ve just created 3 anchors to each tab, as you can see if you click on the first anchor (by default open) it scrolls down (a bit too much but it can be fixed with css). If you click on the anchors 2 and 3 nothing happens, shouldn’t it scroll to the anchor and open the tab selected ?
This is the code of the page:
<!-- wp:html --> <div class="entry-content"> <a href="/test-anchor-on-tabs#anchor1">Anchor 1</a> <a href="/test-anchor-on-tabs#anchor2">Anchor 2</a> <a href="/test-anchor-on-tabs#anchor3">Anchor 3</a> </div> <!-- /wp:html --> <!-- wp:paragraph --> <p>Let's put a vertical spacer</p> <!-- /wp:paragraph --> <!-- wp:spacer {"height":286} --> <div style="height:286px" aria-hidden="true" class="wp-block-spacer"></div> <!-- /wp:spacer --> <!-- wp:uagb/tabs {"block_id":"f9e6c8ed","tabActive":2} --> <div class="wp-block-uagb-tabs uagb-block-f9e6c8ed uagb-tabs__wrap uagb-tabs__hstyle1-desktop uagb-tabs__vstyle6-tablet uagb-tabs__vstyle6-mobile" data-tab-active="0"><ul class="uagb-tabs__panel uagb-tabs__align-left"><li class="uagb-tab uagb-tabs__active"><a href="#uagb-tabs__tab0" class="uagb-tabs-list uagb-tabs__icon-position-left" data-tab="0"><span>Tab 1</span></a></li><li class="uagb-tab "><a href="#uagb-tabs__tab1" class="uagb-tabs-list uagb-tabs__icon-position-left" data-tab="1"><span>Tab 2</span></a></li><li class="uagb-tab "><a href="#uagb-tabs__tab2" class="uagb-tabs-list uagb-tabs__icon-position-left" data-tab="2"><span>Tab 3</span></a></li></ul><div class="uagb-tabs__body-wrap"><!-- wp:uagb/tabs-child {"block_id":"6b27d634","tabActive":2,"tabHeaders":["Tab 1","Tab 2","Tab 3"]} --> <div class="wp-block-uagb-tabs-child uagb-tabs__body-container uagb-tabs__inner-tab uagb-inner-tab-0" id="anchor1"><div class="uagb-blocks__6b27d634 uagb-tabs__body" aria-labelledby="uagb-tabs__tab0"><!-- wp:paragraph --> <p>Content Tab 1</p> <!-- /wp:paragraph --></div></div> <!-- /wp:uagb/tabs-child --> <!-- wp:uagb/tabs-child {"block_id":"9d8537cc","id":1,"tabActive":2,"tabHeaders":["Tab 1","Tab 2","Tab 3"]} --> <div class="wp-block-uagb-tabs-child uagb-tabs__body-container uagb-tabs__inner-tab uagb-inner-tab-1" id="anchor2"><div class="uagb-blocks__9d8537cc uagb-tabs__body" aria-labelledby="uagb-tabs__tab1"><!-- wp:paragraph --> <p><meta charset="utf-8">Content Tab 2</p> <!-- /wp:paragraph --></div></div> <!-- /wp:uagb/tabs-child --> <!-- wp:uagb/tabs-child {"block_id":"a8895db2","id":2,"tabActive":2,"tabHeaders":["Tab 1","Tab 2","Tab 3"]} --> <div class="wp-block-uagb-tabs-child uagb-tabs__body-container uagb-tabs__inner-tab uagb-inner-tab-2" id="anchor3"><div class="uagb-blocks__a8895db2 uagb-tabs__body" aria-labelledby="uagb-tabs__tab2"><!-- wp:paragraph --> <p><meta charset="utf-8">Content Tab 3</p> <!-- /wp:paragraph --></div></div> <!-- /wp:uagb/tabs-child --></div></div> <!-- /wp:uagb/tabs -->Thank you
Forum: Plugins
In reply to: [Product Attachment for WooCommerce] Doesn’t download attachmentHi Hitendra,
thanks for getting back to me. The actual permissions of the file are:
-rw-rw-r-- 1 apache apache 1216923 Aug 5 05:04 uploads/2021/07/file.pdfI’ve set the permissions to 776 as suggested but nothing happened.
if I put the url of the file:
https://site.comt/wp-content/uploads/2021/07/file.pdf
The file loads properly. Is there something in some redirect or security that get’s blocked?
Thank you,
allanextHi @joeleem0n, what is your take on this?
of course for me is fixed because I have installed the “Geo ip detection” plugin (https://wordpress.org/plugins/geoip-detect/) so the
geoip_detect2_get_info_from_current_ip()function get’s resolvedI’ve changed the function
get_geoip_data()in the filepublic/class-warehouse-popups-woocommerce-public.phpto this:
function get_geoip_data(){ if (is_admin()) { return false; } if (function_exists('geoip_detect2_get_info_from_current_ip')) { $geoInfo = geoip_detect2_get_info_from_current_ip(); $geo_country_code = $geoInfo->country->isoCode; $geo_country_name = $geoInfo->country->name; //ChromePhp::log("Country name: $geo_country_name, country code: $geo_country_code"); $obj['name'] = $geo_country_name; $obj['alpha2'] = $geo_country_code; } else { $ip = self::get_client_ip(); $cache_data = self::_wmw_get_data_from_cache( $ip ); if( $cache_data ){ $obj = json_decode( $cache_data, true ); }else{ $geoip_url = "https://api.ipgeolocationapi.com/geolocate/" . $ip; $json = self::curl_get_contents($geoip_url); $obj = json_decode( $json, true ); self::_wmw_add_data_to_cache( $json, $ip ); } } //ChromePhp::log("obj value:"); //ChromePhp::log($obj); $return_arr = array( 'name' => $obj['name'], 'country_code1' => $obj['alpha2'], 'country_code2' => $obj['alpha3'] ); return $return_arr; }and now $obj is correctly populated and the function is called 16 times instead of 900 times.
Also avoiding the
api.ipgeolocationapi.comwhich is responsible of all the slowdown of the sitethe code above is not correct..
I’m seeing again api.ipgeolocationapi.com using 90% of the time of all requests.
Also the function get_geoip_data gets called 900 times on each request, and the $obj and $json are null
@joeleem0n you need to take more seriously the geo localization before trying to implement other features
Dear @joeleem0n,
As I have a site with a lot of traffic I need to make sure these functions each time I’m updating the site; it’s a bit frustrating but it’s also a constructive approach in making this plugin more mature and stable, I hope you appreciate this.
I saw that now you implement an internal cache for each IP with the function
get_geoip_dataand then onauto_warehouse_switchyou just retrieve it from the cache:- I guess you
get_geoip_datais always called beforeauto_warehouse_switch? get_geoip_datahas been reverted in fetching the geolocation fromhttps://api.ipgeolocationapi.com/geolocate/for the first request and then adds it to its cache, this is a problem as if you receive a lot of requests from different new IPs you’ll have the same issue as mentioned at the beginning of the thread where New Relics identified 30-40sec of response time. I’m proposing a little change below that is getting tested.
I understand that you don’t want to depend on another module even if it enables you to cover multiple services (CDNs, local databases, relevant APIs) and that already have caching systems in place… so what I’m proposing at this point is just this additional case in the if else of
get_geoip_datafunction to support the “Geo ip detection” plugin:function get_geoip_data(){ if (is_admin()) { return false; } $ip = self::get_client_ip(); $cache_data = self::_wmw_get_data_from_cache( $ip ); if( $cache_data ){ $obj = json_decode( $cache_data, true ); }else if (function_exists('geoip_detect2_get_info_from_current_ip')) { $geoInfo = geoip_detect2_get_info_from_current_ip(); $geo_country_code = ($geoInfo->country->isoCode); } else{ $geoip_url = "https://api.ipgeolocationapi.com/geolocate/" . $ip; $json = self::curl_get_contents($geoip_url); $obj = json_decode( $json, true ); self::_wmw_add_data_to_cache( $json, $ip ); } $return_arr = array( 'name' => $obj['name'], 'country_code1' => $obj['alpha2'], 'country_code2' => $obj['alpha3'] ); return $return_arr; }This just because using
ipgeolocationapihas performance issues and should be left as a last resort.You should also mention this in the Installation section of the plugin that using “Geo ip detection” is supported and might give them better performances.
Please let me know.
Best@msaari thank you for the tips!
here’s an example of the code in
function.phpfor the above functionality:add_filter('query_vars', 'rlv_add_qv'); function rlv_add_qv($qv) { $qv[] = 'subjects'; $qv[] = 'geluk'; $qv[] = 'kagyu'; $qv[] = 'nyingma'; $qv[] = 'sakya'; return $qv; } add_filter('relevanssi_modify_wp_query', 'rlv_add_meta_query'); function rlv_add_meta_query($query) { //echo var_dump($query->query_vars); $subject = isset($query->query_vars['subjects']) && !empty($query->query_vars['subjects'] && $query->query_vars['subjects'] != "any"); $kagyu = isset($query->query_vars['kagyu']) && !empty($query->query_vars['kagyu']); $nyingma = isset($query->query_vars['nyingma']) && !empty($query->query_vars['nyingma']); $sakya = isset($query->query_vars['sakya']) && !empty($query->query_vars['sakya']); $geluk = isset($query->query_vars['geluk']) && !empty($query->query_vars['geluk']); if ($kagyu || $nyingma || $sakya || $geluk) { global $wpdb; if ($kagyu) { $tax_school[] = array( 'taxonomy' => 'school', 'field' => 'name', 'terms' => 'kagyu', ); } if ($geluk) { $tax_school[] = array( 'taxonomy' => 'school', 'field' => 'name', 'terms' => 'geluk', ); } if ($nyingma) { $tax_school[] = array( 'taxonomy' => 'school', 'field' => 'name', 'terms' => 'nyingma', ); } if ($sakya) { $tax_school[] = array( 'taxonomy' => 'school', 'field' => 'name', 'terms' => 'sakya', ); } if (count($tax_school) > 1) { $schools = array('relation' => 'OR'); $schools = array_merge($schools, $tax_school); } else if (count($tax_school) == 1){ $schools = $tax_school; } } $subject_val = $query->query_vars['subjects']; if ($subject_val != "any" && !($kagyu || $nyingma || $sakya || $geluk)) { $tax_query[] = array( 'taxonomy' => 'subject', 'field' => 'name', 'terms' => $subject_val, ); } else if ($subject_val != "any" && ($kagyu || $nyingma || $sakya || $geluk)) { $tax_query = array( 'relation' => 'AND', array( 'taxonomy' => 'subject', 'field' => 'name', 'terms' => $subject_val, ), $schools ); } else if ($subject_val == "any" && ($kagyu || $nyingma || $sakya || $geluk)) { $tax_query = $schools; } //echo "\nTAX QUERY: \n"; //echo '<pre>' .var_export($tax_query, true) . '</pre>'; $query->set( 'tax_query', $tax_query ) ; return $query; } add_filter( 'relevanssi_match', 'custom_field_weights' ); function custom_field_weights( $match ) { if (isset($_GET['search-book-title'])) { $only_title = $_GET['search-book-title']; $custom_field_detail = json_decode( $match->customfield_detail ); //echo '<pre>' .var_export($only_title, true) . '</pre>'; if ( null === $custom_field_detail || !(isset($custom_field_detail->book_title) || isset($custom_field_detail->book_title_english))) { $match->weight = 0; } } return $match; }Note that on the
relevanssi_matchI accessed the searchform parameters with the $_GET variable instead of the$query->query_varsThank you!
Thank you @msaari !
we are def purchasing the pro version, also considering the indexing of epubs and pdfs. And you are correct; Pods are like ACF or Toolset for creating content types, but open source.
If I understand correctly the relevanssi_match hook is for filtering the results returned by the query (eventually setting the weight to 0 to not show them?), but wouldn’t it be better to add filters to the query like this ?
In this stackoverflow there’s a full example that can be very helpful at first when trying to understand how to integrate all the parts. The second answer.
Can the taxonomy filters be integrated in the relevanssi_modify_wp_query hook as well? From your link I don’t see how to integrate the extra taxonomy arguments in the WP_Query/searchform.php
Thanks again!
Thank you @joeleem0n ! Please let us know from which version this would be available.
Best regards
Hi @joeleem0n,
check the overall improvement between PHP, MySQL and the external service by just removing those 2 API calls and using GeoIp instead:
It’s quite impressive!
Hi @joeleem0n,
from New Relic I noticed another API that was accounting for 44% of the time on external services, it geoplugin:
$geo_url = 'http://www.geoplugin.net/json.gp?ip='.$_SERVER['REMOTE_ADDR'];I’ve commented out the call and used the “Geo ip detection” plugin as above on the same file (public/class-warehouse-popups-woocommerce-public.php):
private static function auto_warehouse_switch() { global $SHIPPING_ZONES_ENABLED; $found_warehouse = false; if( isset($_SERVER['HTTP_GEOIP_COUNTRY_CODE']) ){ $geo_country_code = trim(strtoupper($_SERVER['HTTP_GEOIP_COUNTRY_CODE'])); } else{ //$geo_url = 'http://www.geoplugin.net/json.gp?ip='.$_SERVER['REMOTE_ADDR']; //$geo_json = file_get_contents( $geo_url ); //$geo_object = json_decode($geo_json, true); //$geo_country_code = trim(strtoupper($geo_object['geoplugin_countryCode'])); $geoInfo = geoip_detect2_get_info_from_current_ip(); $geo_country_code=($geoInfo->country->isoCode); //$geo_postal_code=($geoInfo->postal->code); } $alt_warehouses_list = self::get_alt_warehouses_list();Now I have page opening up in 3,4 sec instead of 14/17 seconds.
Let me know if you want me to prepare a pull request for you.
All my best and Thank you!
Allanext - I guess you