Wordpres debug.log PHP Notice: is_singular was called

I have started to get alot of "is_singular was called" and "is_page was called" in my debug.log [31-May-2020 12:10:27 UTC] PHP Notice: is_page was called <strong>incorrectly</strong>. Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in /wp-includes/functions.php on line 5167 [31-May-2020 12:10:27 UTC] PHP Notice: is_singular was called <strong>incorrectly</strong>. Conditional query tags do not work before …
Category: Web

JS / jQuery in Elementor pages vs JS file

I have a lot of JavaScript and jQuery functions that are all working fine, but it's quite fragmented and hard to maintain as some are in Elementor HTML widgets, others in specific Pho functions annd some in an enqueued JS file. Ideally I'd like to move everything into the single JS file so it's easier to maintain, but would there be any performance implications? For example some scripts only need to run on specific pages but I assume they would …
Category: Web

How to change the full capitals font title of my WordPress Blog?

I would like to show my WordPress blog's title as "Dummit foote 4.2.4". But I am getting all capitals as "DUMMIT FOOTE 4.2.4" What should I do to change this? I do not see any editor case in my dashboard. It was mentioned that i should change something in .css but i do not even know where to find that.
Category: Web

What is the correct way to compute lift in lift charts

How is "lift" computed? i was reading about "Gain and lift charts" in data science. I picked the following example from https://www.listendata.com/2014/08/excel-template-gain-and-lift-charts.html I am clear on how the gain values are computed. Not clear about lift values are computed? (last column in table)
Category: Data Science

AJAX in plugin wp_send_json() sending html

I wrote a plugin that calls a PHP function from JQuery and the php sends a json response back to the Jquery using wp_send_json(). The functions are all called successfully, but the json request sends a lot of html to the jquery function every time. How do I make the json sent by the php function only a specific message? JQUERY: jQuery( document ).ready( function() { jQuery( 'body' ).on( 'click', '.wpm_mail_link', function( e ) { var varData = 'name:foobar&[email protected]'; jQuery.ajax({ …
Category: Web

Rewriting URL with child pages

I have a parent page with the URL example.com/the-boats And then child pages like so: the-boats/story the-boats/cast the-boats/articles etc... Many visitors type example.com/boats example.com/cast So when they do this I want to redirect them to /the-boats /the-boats/story etc... I cannot figure out how to do this. I've tried 3 strategies thus far function custom_rewrite_basic() { add_rewrite_rule('^boats/?$', 'index.php?pagename=the-boats/$matches[2]', 'top'); flush_rewrite_rules(); } add_action('init', 'custom_rewrite_basic'); and... add_filter('redirect_canonical', 'my_redirect_canonical', 10, 2); function my_redirect_canonical($redirect_url, $requested_url) { if ( $requested_url == 'https://example.com/boats') { $redirect_url = 'https://example.com/the-boats'; …
Category: Web

Why do the performance of DL models increase with the volume of data while that of ML models will flat out or even decrease?

I have read some articles and realized that many of them cited, for example, DLis better for large amount of data than ML. Typically: The performance of machine learning algorithms decreases as the number of data increases Source Another one says the performance of ML models will plateau, Source As far as I understand, the more data, the better. It helps us implement complex models without overfitting as well as the algorithms learn the data better, thus inferring decent patterns …
Topic: theory
Category: Data Science

How to load numerous files from google drive into colab

I am trying to load in 30k images (600mb) from Google drive into Google Colaboratory to further process them with Keras/PyTorch. Therefore I have first mounted my Google drive using: from google.colab import drive drive.mount('/content/gdrive') Next I have unzipped the image file using: !unzip -uq "/content/gdrive/My Drive/path.zip" -d "/content/gdrive/My Drive/path/" Counting how many files are located in the directory using: len(os.listdir(path-to-train-images)) I only find 13k images (whereas I should find 30k). According to the output of unzip, the files appear …
Category: Data Science

Exclude custom taxonomy from search results and archive pages

UPDATE: I have the following code working. It excludes the taxonomy from the search results. However, I would like this only to happen if a user is not logged in. The code below is taking effect for logged in and logged out users. How can I check if someone is logged in from the functions.php file? I've tried !is_user_logged_in() many times, and I can't seem to get it to work? Thanks for any help! add_filter( 'pre_get_posts', 'exclude_pages_search_when_logged_out' ); function exclude_pages_search_when_logged_out($query) …
Category: Web

Cannot mask WordPress page URL using .htaccess

.htaccess: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /wp_test/ RewriteRule ^index\.php$ - [L] RewriteRule ^the_image$ wp-content/uploads/2019/01/banner\.jpg [L] RewriteRule ^the_page$ sample-page [L] </IfModule> When I go to example.com/the_image it shows the correct image. However, if I go to example.com/the_page it shows the page not found page. Any work around on this?
Category: Web

WooCommerce CSV Image URL Creates Additional Images in Media Folder

I upload all images through the Media Library Drag and Drop Uploader with no problems. Every time I use a CSV file with several thousand products, I enter the image url for each product, which is located in the Media Library. Example: /wp-content/uploads/2018/08/oa901-essence-1oz.jpg As a result, the product page uses the image with the added -1 instead of the original or even a thumbnail of the original. Then when I download all of the products, the image url has the …
Category: Web

Media upload finished hook

I'm developing a plugin which uses wordpress's thickbox media library to handle media upload and selection. All is well but for the fact that I would like to automatically 'redirect' to the 'media library'-tab after I uploaded/ wordpress finished crunching the file. So basically i'm looking for a hook that's fired after the crunching of an uploaded file is finished. I can't imagine this would be such an extreme thing but I can't seem to find the right hook for …
Category: Web

wp_nav_menu() doesn't work

I'm working on a theme with custom menus, currently using WP 4.0.1. I'm registering two menus in functions.php: register_nav_menus( array( 'primary' => __( 'Main Menu', 'wsy' ), 'secondary' => __( 'Secondary Menu', 'wsy' ) ) ); Then, displaying them in my header.php file: <nav role="navigation"> <?php wp_nav_menu( array( 'theme_location' => 'primary', 'depth' => '1' ) ); ?> </nav> The problem is, when I select a specific menu from either the Menus page or the customizer, they stop showing up in …
Category: Web

Optimizing decision threshold on model with oversampled/imbalanced data

I'm working on developing a model with a highly imbalanced dataset (0.7% Minority class). To remedy the imbalance, I was going to oversample using algorithms from imbalanced-learn library. I had a workflow in mind which I wanted to share and get an opinion on if I'm heading in the right direction or maybe I missed something. Split Train/Test/Val Setup pipeline for GridSearch and optimize hyper-parameters (pipeline will only oversample training folds) Scoring metric will be AUC as training set is …
Category: Data Science

Redirect customer to login page (with other signup plugin) if user not logged in when proceeding to checkout

I use "Digits (WordPress Mobile Number Signup and Login)" for signup by email & SMS ; when non logged in user proceed to checkout , want to redirect to signup form of Digits (not usual woocommerce signup). In case already logged-in users, they should go following the next step in the checkout process as normal. appreciate if anybody help.
Category: Web

How to get same accuracy with identical models in Keras and Tensorflow?

As we all know Keras backend uses Tensorflow and so it should give out some kind of results when we provide the same parameters, hyper-parameters, weights, and biases initialization at each layer, but still, the accuracy is different. This may be because the batches of images that are fed at each step in both the models are not identical and get shuffled randomly. Is there any way in which we can make sure that the same batch of images is …
Category: Data Science

I have a plugin that applies a Google translation to my page--how does the browser know which language to display?

My site uses a plugin (Google Language Translator) to apply a Google translation of the text (see page here--the flags at the top of the page switch the language). If I change to another language, close the browser, re-open the browser, and re-open my page, the same language is displayed. How does the browser know to display in the same language as before? Is there some variable set somewhere? Perhaps a cookie, or session ID? Or perhaps some kind of …
Category: Web

Start & End Tokens in LSTM when making predictions

I see examples of LSTM sequence to sequence generation models which use start and end tokens for each sequence. I would like to understand when making predictions with this model, if I'd like to make predictions on an arbitrary sequence - is it required to include start and end tokens tokens in it?
Category: Data Science

Clusterize item set with items as vectors of features

I have to clusterize this dataset in which I have houses and water consumption in this form: $$ House1 = (x_{1},x_{2}... x_{n});\\ House2 = (y_{1},y_{2}... y_{n});\\ House3 = (z_{1},z_{2}... z_{n});\\ $$ where $x_{i}$ is the daily consumption in liters while $n$ is a fixed parameter (length of dataset). I need to cluster these houses in k clusters based on their water consumption. My question is: how can I handle data expressed in this form to feed in the clustering algorithm? …
Category: Data Science

Website not updating - no cache plugins active!

I've a problem with my WordPress website getting updated after I make changes to its code: I'm using phpStorm with auto-save, running the website on WAMP, locally. Therefore, right after I right new code, the file in which I write the code in should be updated, and the website quickly after that. Yet the website doesn't update. I'm not using any cache plugins, and in my browser, Chrome, I disabled caching. Also, it does get updated, but only after I …
Category: Web

crop video when a character appears

I don't know if this has a name I would like to know if there is an ai to cut out a character that appears in a video at a time. that is, to have an input video where many characters appear and an output video with all the frames where the character that interests me appears.
Category: Data Science

What best/correct algorithm/procedure to cluster a dataset with a lot 0's?

I'm new to statistics so sorry any major lack of knowledge in the topic, just doing a project for graduation. I'm trying to cluster a Health dataset containing Diseases(3456) and Symptoms(25) grouping them considering the number of events occurred. My concern is that a lot of the values are 0 simple because some diseases didn't show that particularly symptom, for example (I made up the values for now): So, I was wondering what was the best way to cluster this …
Category: Data Science

Wordpress Custom SQL Table with UserID Filter for results

UPDATE: I have realised that I need to use a plugin like PHP Snipping or Insert PHP to make this work, I have updated my screen shots to reflect where Im upto from my research. The code is working and outputting the right User ID but the SQL is not echoing the Table data, if you have some advice on where I might of gone wrong would be great. <?php global $wpdb; $uid = get_current_user_id(); $sql = $wpdb->prepare("SELECT * FROM …
Category: Web

Change permalink structure specific category

I have a specific category that all posts that are in that category must follow the following structure: category-name/child-category-name(if any)/post-name The other posts will remain with the current base structure defined which is %postname% What filter, hook that can change the permalink of these posts? How would it be?
Category: Web

pre_set_site_transient_update_plugins wont call on hosted webspace

I am trying to use pre_set_site_transient_update_plugins to update my plugin from a GitHub repository. For that I am using this example. On my Dev-System (MAMP for Mac Version 2.2) everything is fine. It gets the latest Version and shows me the update notification. When I publish it to my Live System wich is a hosted webspace package. I don’t get the Update Notification. Even after waiting 12 hours or using ?force-check=1 What I already did was to create a simple …
Category: Web

How to start with receipt OCR text detection

I'm thinking about an OCR system for digitalizing receipts. On the input system would take a picture of receipt and then return classified data (total_sum = Y, date = X, etc.). My question is regarding how to start. My initial thought was that I should start with detecting classes (name of the shop, receipt id etc.) on image and splitting it, then I would send parts of image OCR. My second idea is more NLP based. I would normally pass …
Topic: ocr
Category: Data Science

How to deal with address (like zip-code) for training a model?

To me it doesn't make sense to normalize it even if it is a numerical variable like Zip Code. An address should be interpreted as categorical features like "neighborhood"... ? Suppose I have geolocalisation data (latitude & longitude), the best thing to do seem to use k-means clustering and then working with cluster's label that I "encode". If the answer is : "it depends" please tell me how
Category: Data Science

wp_remote_get() returns 403 while file_get_contents() does not

We are working on a WordPress plugin and we require an API call. We are using the api: http://www.geoplugin.net/json.gp?ip=8.8.8.8 In this context: $response = wp_remote_get("http://www.geoplugin.net/json.gp?ip={$ip}", array( 'timeout' => 45, 'redirection' => 5, 'user-agent' => 'Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)', )); $dataArray = json_decode(wp_remote_retrieve_body($response)); var_dump($response); However, all we get is a 403 error saying: string(162) " 403 Forbidden nginx " The API call worked fine using this code: file_get_contents("http://www.geoplugin.net/json.gp?ip={$ip}") However, we are only allowed to use wp_remote_get() by WordPress. We have been …
Category: Web

ValueError: ('The truth value of a Series is ambiguous after applying if/else condition in Pandas data frames

I want to create a new variable for the dataframe details called lower after iterating through multiple data frames. list1 is a list of string values of a column named variable_name in the details. vars_df is another data frame with 2 columns, namely variable_name and direction. Both columns contain with string values. vars_df.shape = (19,2) Some values of variable_name in vars_df are present in list1 as well as data_set. data_set.shape = (32,107).df.shape = (96,1) The following code, which aims to …
Category: Data Science

About

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