Scheduling an event inside plugin class is not working

wp_schedule_single_event is not firing. I wrote a function that is posting to external API, if it failed I schedule the same posting function to run 5 seconds later in cases of timeouts. Here's the simplified code of the function: class MyPlugin { public function post( $fields, $type ) { // Posting to external API logic, if it failed I schedule the same function to run in 5 seconds. wp_schedule_single_event( time() + 5, 'post', array( $fields, $type ) ); return; } …
Category: Web

check for duplicate user meta data before updating

I have added the ability for a social security number to be added for users. This field can be edited on the individual users screen but the data is saved to the usermeta table. When editing a new user, I want to check if that number is being used somewhere else for another user as duplicates should not be allowed. My initial code is: function save_cust_user_profile_fields( $user_id ) { if ( isset($_POST['social_number']) ) { update_user_meta( $user_id, 'social_number', intval($_POST['social_number'])); } } …
Category: Web

Fetch a single row from a custom table for to a given ID

When I want to get a single row from a custom table of my WordPress database by providing a username through a function call, it does not work. When I mention the username in the where clause of the query, however, it works. Why is that? I am using the following code: function gettingonly($phl) { global $wpdb; $mylink = $wpdb->get_row(" SELECT * FROM $wpdb->wp_philosophy_philosopher WHERE philosopher=%s", $phl ); if ($mylink) { print "<input type='text' value='" . $mylink->philosopher . "'> <input …
Category: Web

add_menu_page() with different name for first submenu item

The add_menu_page documentation says to pass the menu title as the second parameter: add_menu_page('Page Title', 'Menu Title', ...); When adding more pages later via add_submenu_page, the main page becomes the first entry in the submenu: However, I want the first item in the list to have a different name (but still point to the same page), the way Wordpress itself does it: How could I accomplish that in my plugin?
Category: Web

CycleGAN: Both losses from discriminator and generator drop fast, after 100 epochs outputs blurred original image

I'm trying to train a 3D Cycle-GAN on medical image synthesis, more specifically CT to MR. Currently I'm using a 3-Layer Discriminator and a 6 layer UNetGenerator borrowed from the official CycleGAN codes. Same lambda A, B of 10 and .5 of identity. The discriminator loss drops to around 0 in the first few epochs, and the total loss for generator drops to around 1 as well. The generator continues to ouput blurred original input image. During my debugging I …
Category: Data Science

Remove parent from custom post type

I've created a new custom post type with WordPress. However, the slug adds the post to a parent, like so: http://example.com/UNNCESSARY-PARENT/post-title However, I'd like it to create: http://example.com/post-title Is this possible? This is how I've registered the post type: function create_films() { register_post_type( 'films', array( 'labels' => array( 'name' => 'Films' , 'singular_name' => 'Films' ), 'public' => true, 'has_archive' => false, 'taxonomies' => array('category', 'post_tag') ) ); } add_action( 'init', 'create_films' ); And this is the documentation.
Category: Web

Why do we need convolutions over volume in convolutional neural networks for image recognition?

In convolutional neural networks, we make convolutions of three channels (red, green, blue) with a filter of dimensions $k\times k\times 3$, like in the picture: Each filter consists of adjustable weights, and can learn to detect primitive features, like edges. The filter can be different for each channel: one for R, another for G, yet another for B. My question is: Why do we need separate filters for each channel? If there's an edge, it will appear on each channel …
Category: Data Science

Model building with neural networks

Assume the existence of a collection of physical parameters and a collection of output variables which may depend on the physical parameters. An example in the training dataset consists of a vector with the actual measurement of the physical parameters, and another vector with the output values which were measured. To my understanding, I can train a neural network such as a MLP to learn the mapping from the measured input parameters to the measured output values. If a model …
Category: Data Science

is_wp_error is missing error

I am getting the following error in the code snippet below---and pointing to the line that references the $result[ 'body' ] assignment. The is_wp_error should have caught the error. ?????????????? Fatal error: Cannot use object of type WP_Error as array $result = wp_remote_post( ..... ) ); if( is_wp_error( $result ) ): $display = 'Error Message'; else: $display = $result[ 'body' ]; endif;
Category: Web

Python DataScience Library vs SQL

I am working on a project where there is a necessity to store considerable data. I was wondering what is the difference between using SQL and the datascience library in python. I intend to use SQL from its python based libraries too or use a csv file to store info if I am going to use "datascience". I am leaning very much towards "datascience" as I find the following advantages: It is subjectively very easy to use for me. I …
Category: Data Science

Splitting Subject Data in train, validation and test set for 3D Human Pose Estimation for better accuracy

This is a 3D Human Pose Estimation problem. There are totally 15 normal subjects in train set, 7 normal subjects in validation set and 7 normal subjects in test set. There are 7 impaired subjects totally. This is a density plot without adding those impaired subjects where train, validation and test split density, count and proportion plots can be observed. The density plots show the distribution of subjects inside train, validation and test sets, while the count shows the number …
Category: Data Science

How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?

I added the following to my functions.php: add_action('pre_get_posts', 'keyl_get_emp_posts'); function keyl_get_emp_posts($query) { if ($query->is_main_query()) $query->set('post_type', 'employee'); } and so far it's effectively filtering out the search results. The default widgets Recent Posts and Recent Comments aren't budging, though. What gives?
Category: Web

Alternative methods for novelty detection and correlations

Hey mates I have the following project: Imagine having two datasets A and B. Each dataset consits of 101 time series with the same lenght and identical time stamps. The two datasets where taken from the same experiment, therefore the data structure is identical. From the 101 time series there is one particulary signal that is of interest in both datasets. Lets call that signal X(t)_101. Now we have the following case that the signal X(t)_101 from dataset A (good …
Category: Data Science

How to add separator between default and custom panels in WordPress customizer?

I have implemented theme options using WordPress customizer with a mix of native WordPress customizer fields and Kirki framework. This works great. Now, I wonder if it is possible to add a separator between my theme options and default WordPress customizer options. Something similar to the attached image. Guess, this can be achieved by overriding custom CSS. But a native and cleaner approach is what I am looking for.
Category: Web

I keep getting an error message in R while using twitteR

here is what I am doing: tweets=searchTwitter("walmart",n=3000, lang="en",since="2021-01-08",until="2021-01-10") And this is my error message: Warning message: In doRppAPICall("search/tweets", n, params = params, retryOnRateLimit = retryOnRateLimit, : 3000 tweets were requested but the API can only return 0 Any help would be appreciated.
Topic: twitter api r
Category: Data Science

Woocommerce checkout page - custom field checkbox value into email

I've added a checkbox to the checkout page: add_action('woocommerce_after_order_notes', 'client_already_field'); function client_already_field( $checkout ) { echo '<div id="client-already-field"><h3>'.__('CLIENT ALREADY? ').'</h3>'; woocommerce_form_field( 'client_already_checkbox_yes', array( 'type' => 'checkbox', 'class' => array('input-checkbox-yes'), 'label' => __('YES!'), 'required' => false, ), $checkout->get_value( 'client_already_checkbox_yes' )); echo '</div>'; } And saved it to order meta (both of these functions worked): //1 add_action('woocommerce_checkout_update_order_meta', 'client_already_order_meta_yes'); function client_already_order_meta_yes( $order_id ) { if ($_POST['client_already_checkbox_yes']) update_post_meta( $order_id, 'Client Already:Yes', esc_attr($_POST['client_already_checkbox_yes'])); } // 2 function client_already_order_meta_yes( $order_id ) { if( !empty( $_POST['client_already_checkbox_yes'] ) …
Category: Web

Low accuracy on the test set

I have a dataset with 16 features and 32 class labels, which shows the following behavior: Neural network classification: high accuracy on train 100%, but low accuracy on the test set 3% (almost like random classification). If I make the network less flexible (reduce the number of neurons or hidden layers), then the train and test accuracy become about 10%. Gradient boosting tree classification: exactly same behavior. Flexible model results in 100% accuracy over train, but random accuracy on the …
Category: Data Science

How to load jquery ui autocomplete combobox?

I have tried below script to load jQuery UI Autocomplete in theme. But it doesn't load their related scripts. How should I call it to work. wp_enqueue_script('jquery-ui-autocomplete'); I think below scripts are jQuery UI related scripts for autocomplete but it's doesn't load. <script type='text/javascript' src='http://localhost/wordpress/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.10.2'></script> <script type='text/javascript' src='http://localhost/wordpress/wp-includes/js/jquery/ui/jquery.ui.widget.min.js?ver=1.10.2'></script> <script type='text/javascript' src='http://localhost/wordpress/wp-includes/js/jquery/ui/jquery.ui.position.min.js?ver=1.10.2'></script> <script type='text/javascript' src='http://localhost/wordpress/wp-includes/js/jquery/ui/jquery.ui.menu.min.js?ver=1.10.2'></script> <script type='text/javascript' src='http://localhost/wordpress/wp-includes/js/jquery/ui/jquery.ui.autocomplete.min.js?ver=1.10.2'></script>
Category: Web

How to change parameters in LSTM for multivariate binary classification time series?

https://machinelearningmastery.com/multivariate-time-series-forecasting-lstms-keras/ I am trying to follow this tutorial's code with a slightly different dataset, where the predictor is a 0 or 1: presence or absence of something. My data is continuous time series data, and I have other continuous variables that are inputs. For the most part, sans column numbers and names, my code is almost identical to the one in that tutorial. However, my predicted values show up like this on the plot: And upon changing the "Dense" line …
Category: Data Science

Custom success message after user is registered

I am using this code as a custom signup form. Is there any chance to create a success message for it? <?php /* ** Template Name: Custom Register Page */ get_header(); global $wpdb, $user_ID; if (isset($_POST['user_registeration'])) { //registration_validation($_POST['username'], $_POST['useremail']); global $reg_errors; $reg_errors = new WP_Error; $username=$_POST['username']; $useremail=$_POST['useremail']; $password=$_POST['password']; if(empty( $username ) || empty( $useremail ) || empty($password)) { $reg_errors->add('field', 'Required form field is missing'); } if ( 6 > strlen( $username ) ) { $reg_errors->add('username_length', 'Username too short. At least …
Category: Web

Does it make sense to build a ROC for a decision tree where there are multiple threshold you can adjust?

I understand building a ROC curve when the output is a probability, say, from a logistic regression model. You can build a ROC curve by varying the cutoff threshold. But what about decision trees of the form: if attribute_1 > x: decision = positive else: if attribute_2 < y: decision = position else: decision = negative You can adjust the cutoff for both attributes and all will affect your confusion matrix. Does it make sense to build a ROC curves …
Category: Data Science

custom css for admin only

I need custom CSS for admin. So if user is not logged in or is anything else but admin there is one CSS, and for admin only different CSS. I tried this code in functions.php: function wpa66834_role_admin_body_class( $classes ) { global $current_user; foreach( $current_user->roles as $role ) $classes .= ' role-' . $role; return trim( $classes ); } add_filter( 'admin_body_class', 'wpa66834_role_admin_body_class' ); and in custom CSS field: #targetElement { display: none; } .role-administrator #targetElement { display: visible; } But it …
Topic: php css Wordpress
Category: Web

Is there a way to forecast a time series multiple linear regression using externally made dummy variables?

This question concerns question 4h of this textbook exercise. It asks to make future predictions based on a chosen TSLM model which involves an endogenously (if i'm using this right) made dummy variable based off certain time points. My main code is as follows The main problem I've encountered is that when I use forecast() on my model, it gives an error message: This is very confusing because shouldn't my modified data already include the dummy variables? Hence, the model …
Category: Data Science

404 on CSS and JS only on Homepage

I had to use a backup of the website and on restoration the Homepage has 404's to all JS/CSS files Every other page is accessible and does not experience the issue I've checked the permalinks, I've checked file permissions but the problem persists https://onemoresong.com.au Does the HTAccess need to be altered or this issues with the DB?
Category: Web

Why fourier transform extrapolation goes to extreme on edges but not in the middle, how to fix it

Why fourier transform extrapolation goes to extreme on edges but not in the middle, how to fix it with python """ Code to create the Fuorier trasfrom """ data_FT = dataset_ex_df[['Date', 'GS']] close_fft = np.fft.fft(np.asarray(data_FT['GS'].tolist())) fft_df = pd.DataFrame({'fft':close_fft}) fft_df['absolute'] = fft_df['fft'].apply(lambda x: np.abs(x)) fft_df['angle'] = fft_df['fft'].apply(lambda x: np.angle(x)) plt.figure(figsize=(14, 7), dpi=100) fft_list = np.asarray(fft_df['fft'].tolist()) for num_ in [3, 6, 9, 100]: fft_list_m10= np.copy(fft_list); fft_list_m10[num_:-num_]=0 plt.plot(np.fft.ifft(fft_list_m10), label='Fourier transform with {} components'.format(num_)) plt.plot(data_FT['GS'], label='Real') plt.xlabel('Days') plt.ylabel('USD') plt.title('Figure 3: Goldman Sachs (close) stock …
Category: Data Science

Check If Answer is Correct by Similarity

I am new to data science and machine learning. Let's say that I have a question, and some correct answers for that question (for example, 10 correct answers). Is there a way to get a new answer as input, and "calculate" whether it is right? If you can recommend some readings, that would be great.
Category: Data Science

$wpdb->query() vs. $wpdb->get_results() vs. phpMyAdmin

I have this code: $query = "SELECT * FROM $wpdb->posts INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id INNER JOIN $wpdb->term_relationships ON $wpdb->posts.ID = $wpdb->term_relationships.object_id WHERE ((post_type = 'projects') OR (post_type = 'post_cost_codes'));"; $results = $wpdb->query($query); // Takes 1.5 seconds I also tried this: $query = "SELECT * FROM $wpdb->posts INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id INNER JOIN $wpdb->term_relationships ON $wpdb->posts.ID = $wpdb->term_relationships.object_id WHERE ((post_type = 'projects') OR (post_type = 'post_cost_codes'));"; $results = $wpdb->get_results($query); // Still takes 1.5 seconds But …
Category: Web

mysql - Delete keyword with link from wordpress post database

I have a problem and if anyone can help thanks in advance. I want to remove some stuffed keyword with link from my wordpress post table example of link <a href="http://example.com/keyword/">keyword</a> I have some posts since 2011 and it`s quite hard to edit all those posts to remove the links.... I wonder if i can use this code UPDATE wp_posts SET post_content = replace(post_content, '<a href="example.com/keyword/">keyword</a>', '' ) ; Any help is most welcome Regards Daniel
Category: Web

show a specific metabox dependent on the page template

For a few days I am trying to show a specific metabox dependent on the page template. I can do it but my problem is when I have selected a page template and hit the update button then the metabox does not show. metabox is showing when I reload the page. Actually, I want when I will hit the update button then the metabox will be shown. please help me. Note: I use CMB2 for meta boxes. I tried this …
Category: Web

How to send form values from the script in functions.php and not from the form on my website?

I have a form on my website and depending on if the user check paypal or wire-transfer the form action should always go to functions.php where I have this simple check at the end of the file: if ( isset( $_POST['submitted'] ) && isset( $_POST['post_nonce_field'] ) && wp_verify_nonce( $_POST['post_nonce_field'], 'post_nonce' ) ) { // CODE AFTER SUBMIT HERE } So, my question is how do I do some stuff using an if condition in my functions.php before posting the form …
Category: Web

Display post in order of ACF checkbox?

I have a custom post type called ‘Skateboards’. Within the custom post type of ‘Skateboards’ , I added three checkboxes (filed type checkbox) with a field name of ‘skateboard_performance’ associated to the ’Skateboards’ custom post type via ACF. The values of the three check boxes are ‘Platinum’ , ‘Gold’ and ‘Silver ’. What I am trying to accomplish is to display the ‘Skateboards’ post type in order of ‘Platinum’ , ‘Gold’ and ‘Silver’. So all of the Skateboards posts marked …
Category: Web

IsolationForest Decision Function vs. Anomaly Prediction Question

I'm currently working on an unsupervised anomaly detection project, and for it I'm using IsolationForest through scikit-learn. My question is, why/how is it possible for the model to predict something to be an anomaly when it is within the decision function space for inliers? I've attached my results here: Could the size of the decision function space be due to my input dimension vs this 2 dimensional projection? I also made a quick plot of anomaly score vs. prediction (0 …
Category: Data Science

About

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