Unicode characters displaying as ? after import using WP Clone

I moved over a development site to the client's hosting server using the WP Clone plugin. It seemed to work just fine, until I noticed a bunch of odd question marks where things like em-dashes and apostrophes should be. It appears to be a unicode issue, but the only difference I can tell between the two servers is that the client-side is using utf8mb4_unicode_c and my development server is using utf8_unicode_ci. If I copy and paste a page from the …
Category: Web

How to use the Yoast SEO wpseo_canonical filter to set a canonical URL for /, /au/ & /uk/ sites in a MU environment

Our company has markets in USA, UK & Australia. We've just started using WP MU on our development server where the USA/global version is @ www.example.com, and then there are www.example.com/uk/ & www.example.com/au/. We're probably going to create an AJAX function to redirect the visitor based on their geographical location to the appropriate website, with www.example.com being the catch-all. I've come across the Yoast SEO wpseo_canonical filter which might help us set a canonical URL for all of our posts …
Category: Web

Filter Orders in Admin area, based on Custom meta

Story: I have custom role Staff for my WooCommerce shop, When a Customer create an Order, the Order is assigned a custom meta name handle_by where the value is a random value of user where role is Staff. When Staff is login and click WooCoomerce > Orders, He/She will only see Orders where handle_by is match current user id. Problem: How to filter WooCommerce > Order to only show Order where the custom meta handle_by is match with current user …
Category: Web

Insert data from .sql file in wordpress plugin

I'm creating a wordpress plugin that need to create a table and insert location data to that. There are more than 50000 locations in that INSERT query, so that in separate .sql file. I need to run that when I active the plugin. I'm creating table like below function locations_install() { global $wpdb; global $locations_db_version; $table_name = $wpdb->prefix . 'setfordslocations'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE IF NOT EXISTS $table_name ( id int(11) NOT NULL AUTO_INCREMENT, town varchar(2000) CHARACTER …
Category: Web

Custom PHP script throws critical error ONLY when editing page

I have the following script added to functions.php in my child theme: function getlatestfile() { $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('wp-content/uploads/cams/')); foreach ($iterator as $file) { if ($file->isDir()) continue; $path = $file->getPathname(); } return "<img src='https://mysite.url/" . $path . "' />"; } // register shortcode add_shortcode('getfieldimage', 'getlatestfile'); I can save the code, insert the shortcode [getfieldimage] on the page, and the page indeed displays the latest image. No complains. But when trying to edit again the page containing the shortcode, WP …
Category: Web

Type character in name and make it invisble

my website is using MyHome theme. I need to write identical names for two search fields. Here - https://komand.suvenirite.net/dava-pod-naem/?offer-type=rent And here- https://komand.suvenirite.net/prodava-offer-typesalecitygrad-sofia/?offer-type=sale Under the search field "ВИД НА ИМОТА" (the first one) The need for that is that the system gets confused if there are identical names even thought their parent fields are different, but for the client they need to appear the same. Yes, I have tried changing the structure, but of no use. The client is unbeatable. Adding …
Category: Web

Load JavaScript on specific page with @wordpress compiler

I'm new to WordPress development. I have been following a tutorial in Udemy to build my new WordPress website. As recommended by the trainer, it is useful to use npm to package the JavaScripts using "@wordpress/scripts". The npm command monitors a single index.js file, which is then compiled into WordPress friendly version. Then in functions.php I added the wp_enqueue_script() function to call the index.js from build folder. The problem: I have created multiple JavaScript files, which contain new classes with …
Category: Web

Is the number of bidirectional LSTMs in encoder-decoder model equal to the maximum length of input text/characters?

I'm confused about this aspect of RNNs while trying to learn how seq2seq encoder-decoder works at https://machinelearningmastery.com/configure-encoder-decoder-model-neural-machine-translation/. It seems to me that the number of LSTMs in the encoder would have to be the same as number of words in the text (if word embeddings are being used) or characters in the text (if char embeddings are being used). For char embeddings, each embedding would correspond to 1 LSTM in 1 direction and 1 encoder hidden state. Is this understanding …
Category: Data Science

Extending WP_Query — Optimise SQL query

I'm storing posts, a user follows in a custom table that has the columns id, post_id and user_id. To fetch posts that a user follows I have extended the WP_Query as follows: class WP_Query_Posts_User_Follows extends WP_Query { function __construct($args=array()) { if ( !empty($args['followed_by']) ) { $this->followed_by = $args['followed_by']; add_filter('posts_where', array($this, 'posts_where')); } parent::query($args); } function posts_where($where) { global $wpdb; $table = $wpdb->prefix . 'post_followed_by'; $where .= $wpdb->prepare(" AND ID IN (SELECT post_id FROM $table WHERE user_id = %d)", $this->followed_by); return …
Category: Web

ACF: Update field value based on value of another field

I have some custom posts that lists cars, motorcycles and trucks. The values in the ACF fileds are automaticaly populated and I cannot change them manually because they come from an external software. In this CPT I have 2 ACF fields (both are text fields): one called “Categroy” that can be Cars, Motorcycle, Truck. Another one called “Service”, that can be a value from 1 to 9. As you can see the “objects” can have different Categories but they maybe …
Category: Web

Custom Block Not Shown in Block Inserter

I am attempting to create a new custom block plugin in Wordpress v5.9.3. I'm following this Wordpress guide on creating a simple block. My block does not appear when I search for it in the Block Inserter, however. To try to rule out anything I may have done incorrectly I used the default Twenty Twenty Two theme and added the '01-basic' example provided in the Wordpress Gutenberg Examples to the plugins folder. Note that the basic example does not require …
Category: Web

How to calculate LFW accuracy of face recognition model?

In my research I have observed many of the face recognition algorithms propose their model accuracy interms of LFW dataset accuracy. I understood that LFW is a open source database and I did download that. I have developed my own DNN model implemented for face recognition which is similar to facenet architecture. Can anyone help with the procedure to calculate LFW accuracy of my model?
Category: Data Science

WooCommerce Base Page Featured Image Custom Theme

I have a very basic theme that is running WooCommerce beautifully so far. In my functions.php I've setup the following to support woocommerce. // // WooCommerce Hooks and Theme Overrides // remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); add_action('woocommerce_before_main_content', 'cm_theme_wrapper_start', 10); add_action('woocommerce_after_main_content', 'cm_theme_wrapper_end', 10); function cm_theme_wrapper_start() { echo ' <div class="main-content-wrapper"> <section class="layout-standard"> <section class="cards"> <div class="layout-gallery short"> <div class="background"></div> <img class="background-image" src="'; if ( has_post_thumbnail() ) { the_post_thumbnail_url('header-bg'); } else { echo get_template_directory_uri().'/images/default.jpg'; } echo '" alt="'; $image_title …
Category: Web

How to set a template with wp_insert_post

I'm trying to set my template to the Elementor Canvas when using wp_insert_post but it isn't working. It is creating the new page fine but not using the canvas. What am I doing wrong? { "action": "create_post", "post_author": "<authorID>", "post_content": "<post content>", "post_title": "Leave us a Review", "post_status": "publish", "post_type": "page", "comment_status": "closed", "post_name": "<post-name>", "page_template": "elementor_canvas" }
Category: Web

WordPress admin section appears broken

My WordPress admin area looks like the image linked below. I have tried reinstalling WordPress using the option in the Updates panel. But I cannot get it to revert. Has anybody had a similar problem and knows the solution? My guess is that it's CSS but shouldn't have to reinstall WP sorted that out? Need more rep to include this image in the post
Category: Web

Get value from an input field and pass into update_meta_data as $meta_value

I am building a woocommerce site and I have some input fields the on the product page. one is for recipient email (its for a gift car). Everything works, and the recipient email is saved on the order, but I want to be able to pass the email address to a function to update_meta_data so that I can use in other parts of the code (namely to send out a separate email to the recipient to redeem the card). here …
Category: Web

Undefined fieldId in gform.addFilter for limiting dates in datepicker - Gravity Forms

I've added support for datepicker on date fields in entry detail edit admin page of Gravity Forms. I did this by simply enqueuing the gform_datepicker_init script in admin_enqueue_scripts hook. This works perfectly as datepicker is displayed for date fields which was not available by default in entry detail edit page. My form has additional requirements and I want to limit the dates in a datepicker field. So, for that I want to take advantage of a JS filter gform_datepicker_options_pre_init provided …
Category: Web

Update number of posts when attribute changed

I have a simple block that shows the most recent posts. But I want the number of posts to be changeable. To do that, I created a simple attribute and integrate it with a range control. const onChangePosts = ( newContent ) => { setAttributes( { numberPosts: newContent } ); }; <RangeControl value={ attributes.numberPosts } onChange={ ( value ) => onChangePosts( value ) } min={ 1 } max={ 10 } /> And here I'm getting the posts: const posts = …
Category: Web

How to sample a dataframe or numpy array with a particular interval?

I have the following dataframe : A B1 B2 B3 B4 B5 B6 B7 0 0 0 0 0 0 0 0 1 444 325 479 502 630 458 588 2 1200 1255 1101 1259 1365 1400 1100 3 2092 1764 2103 2359 2245 2397 2487 4 2586 2232 2549 2597 2628 2718 2770 5 2951 2762 2924 2757 2903 2934 2963 I want to sample the columns uniformly.For examples I want to divide the interval 0 to 1 for …
Category: Data Science

Improve results using user input

I've developed a tool that retrieve the closest expressions from a database based on what the user typed. (using word embedding - a comparison is made between each expression from the database and the user input) n-result are retrieved but the closest expressions are not necessarily the most relevant one. For example, by typing : hospital machine The top results will be "dialysis machine", "medical machine", ... but I'll also find expressions like "building machine", "office machine" A user will …
Category: Data Science

Show an admin menu item in Editor role

I am new to Wordpress and would like to know how to add a specific admin menu item to the role Editor (in this case it is "User Login History"). This plugin shows its name for Administrator but not for Editor Please help
Category: Web

Decision tree to get difference in rates in two groups?

I have two sample groups of customers, each customer has 100s of features. For a single sample, i would use Decision Trees to find sub-groups that have a high churn rate. Thats easy. However, my requirement is: between two samples (below), find segment(s) such that in one sample its churn rate is high and in the other, it is low. In other words, find a sub-group which has the highest difference in churn rate. What is an appropriate algorithm to …
Category: Data Science

Import data from file larger than 15 MB

I have my blog on wordpress.com, I want it to be moved on self hosted server. I have exported data from my wordpress.com blog to XML file, However, When I went to import the data to my self hosted wordpress installation it says file must not be greater than 15MB and my file is of 2257 MB How do I go to import such a large file?
Category: Web

ResNet: Derive the gradient matrices w.r.t. W1 and W2 and backprop equation in a Residual Network

How would I go about step by step deriving stochastic gradient matrices w.r.t. W1 and W2 and backpropagation equation in a residual block that is a part of a larger ResNet network with forward propagation expressed as: $$ F(x) = \mathrm{W}_{2}^{} \mathrm{g}_{1}^{}(\mathrm{W}_{1}^{}x) $$ $$ y = \mathrm{g}_{2}^{} (F(x) + x) $$ and $$ \mathrm{g}_{1}^{}, \mathrm{g}_{2}^{} $$ are component-wise non-linear activation functions.
Category: Data Science

Is there an ai to create more samples of an instrument from a single sample?

I don't know if there is a term for this. Is there an ai to create more samples from a single sample? a sample in music is a sound that has a unique pitch. for example .sf2 files used in music applications like fl studio have multiple samples. Sometimes I want an instrument that I hear in a song, so I want to extract all the samples from that instrument. but sometimes there is only one sample of the isolated …
Topic: time-series
Category: Data Science

Getting all woocommerce products from REST API call in plugin

I am developing a plugin that extends Woocommerce and acts as a custom product filter. The part I'm having trouble with is that it's not tied to one specific site, and has to fetch the products from an external API call, which is limited by 100 results per page, and I need just under 1000 products. I would prefer to get this data with one call only, without needing some hacky loop to glue together the results of the individual …
Category: Web

Memory error - Hierarchical Dirichlet Process, HDP gensim

I am running Hierarchical Dirichlet Process, HDP using gensim in Python but as my corpus is too large it is throwing me following error: model = gensim.models.HdpModel(corpus, id2word=corpus.id2word, chunksize=50000) File "/usr/cluster/contrib/Enthought/Canopy_64/User/lib/python2.7/site-packages/gensim/models/hdpmodel.py", line 210, in __init__ self.update(corpus) File "/usr/cluster/contrib/Enthought/Canopy_64/User/lib/python2.7/site-packages/gensim/models/hdpmodel.py", line 245, in update self.update_chunk(chunk) File "/usr/cluster/contrib/Enthought/Canopy_64/User/lib/python2.7/site-packages/gensim/models/hdpmodel.py", line 313, in update_chunk self.update_lambda(ss, word_list, opt_o) File "/usr/cluster/contrib/Enthought/Canopy_64/User/lib/python2.7/site-packages/gensim/models/hdpmodel.py", line 415, in update_lambda rhot * self.m_D * sstats.m_var_beta_ss / sstats.m_chunksize MemoryError I have loaded my corpus using following statement: corpus = gensim.corpora.MalletCorpus('chunk5000K_records.mallet') And the data …
Category: Data Science

How to test plugin update through WordPress plugin updater without tagging new release in the repo

I have been searching for hours trying to find a way to test the update process for my plugin before tagging a new release in the repo. I have a function that is called using add_action( 'upgrader_process_complete', 'my_plugin_upgrade_function', 10, 2); and I can't figure out how to test this prior to release. Any help would be awesome!
Category: Web

Bert-Transformer : Why Bert transformer uses [CLS] token for classification instead of average over all tokens?

I am doing experiments on bert architecture and found out that most of the fine-tuning task takes the final hidden layer as text representation and later they pass it to other models for the further downstream task. Bert's last layer looks like this : Where we take the [CLS] token of each sentence : Image source I went through many discussion on this huggingface issue, datascience forum question, github issue Most of the data scientist gives this explanation : BERT …
Category: Data Science

Query posts and display all dates in repeater field in chronological order

I have a Custom Post Type 'Production' with 'Tourdates' as a repeaterfield (using Advanced Custom Field plugin). Tourdates have a 'Date & Time Picker 'field named 'Playdate'. I would now like to display (in a list) all Playdates of all Productions sorted chronologically. My current query displays the posts like this: 09/04/2017 (Production x) 28/12/2017 (Production y) 07/04/2017 (Production x) 11/04/2017 (Production x) 31/04/2017 (Production y) 14/04/2017 (Production y) But I'm looking to get them displayed like this: 07/04/2017 (Production …
Category: Web

Pagination not working on custom post types with rewrite slug

I've been trying to fix my pagination to work on custom post type slugs for example article/post-title/page/2 it just keeps showing the first page's results, the URL is changing but the posts remain the same My post type has rewrite slugs written like this 'rewrite' => ['slug' => 'article'], This is the query I used $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $args = [ 'numberposts' => -1, 'post_type' => $post_type, 'posts_per_page' => $post_per_page, 'post_status' => 'publish', 'paged' …
Category: Web

Error rest_post_invalid_page_number trying to call Rest API

I got the following error, trying to call all posts or alle posts from a specific post type via the REST API: /wp-json/wp/v2/posts /wp-json/wp/v2/posts?page=1 /wp-json/wp/v2/posts?page=1&per_page=1 /wp-json/wp/v2/faq The error which appears is: { "code": "rest_post_invalid_page_number", "message": "The page number requested is larger than the number of pages available.", "data": { "status": 400 } } I got two posts within the custom post type and one normal post. What causes this error?
Category: Web

About

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