Media Library is not loading on grid view in admin panel

Media Library is not loading on grid view and also featured image not select any image from post and page . The progress circle keeps spinning. Due to this issue, I am not able to add any image in the post as insert image option also opens in “grid view” by default. The things I tried but not resolved my issue: Removed all plugins. Switch to twenty sixteen theme. Deleted whole wordpress installation. Installed fresh. Enabled script debug.Doesn’t show any …
Category: Web

Tool vs Python Script for Transforming Data in Mongo

We have a bunch of Mongo collections (data collected from APIs, web scraping, etc) that we need to transform to a cleaner data structure (standardized schema) on a monthly basis. Are there any good tools to help us manage this process, or would you recommend writing a Python script instead?
Category: Data Science

Make custom Wordpress comments list

i'm making a custom Wordpress template and I've made this HTML code for single comment template: <div class="comment" id="1"> <div class="useravatar" style="background-image: url('[LINK]')"></div> <div class="textbox"> <div class="dateauthor">[AUTHOR NAME] <span class="date">[DATE]</span></div> <div class="text"> [COMMENT TEXT] </div> </div> </div> But i'm getting only headache to find out how to make a loop o something else where I can use this. Is there any good example for this cases?
Category: Web

Best db table structure for users with many records

I want to allow users to have 1000+ records in my WordPress system. I was wondering is it best to have just one table for all users and their records or one table per user? Keep in mind that I could have 1000 users. A user columns for records would look like: User_client_name | User_id | User_post_id | etc... Each user might have 1000+ records in the database of their contacts. If I put all users in one table, I …
Category: Web

Custom conditional Keras metric

I am trying to create the following metric for my neural network using keras $$ s = \left\{ \begin{array}{ll} \sum_{i=1}^{n} e^{\frac{-d_i}{10}}-1 & \quad d < 0 \\ \sum_{i=1}^{n} e^{\frac{d_i}{13}}-1 & \quad d \geq 0 \end{array} \right. $$ where $d_i=y_{pred}-y_{true}$ and both $y_{pred}$ and $y_{true}$ are vectors With the following code: import keras.backend as K def score(y_true, y_pred): d=(y_pred - y_true) if d<0: return K.exp(-d/10)-1 else: return K.exp(d/13)-1 For the use of compiling my model: model.compile(loss='mse', optimizer='adam', metrics=[score]) I received the …
Category: Data Science

if is_page() is not working with wp_redirect

I have a plugin installed, which is creating user profiles on frontend. The ID of this page is 301 in backend of wordpress. If a profile site is visited, i want to append the url with a parameter. The parameter value is stored in a cookie. The code for appending the URL is working, but when i add the code to only show on this page id its not working. The code is executed in my child themes functions.php NOT …
Category: Web

Closing Paragraph Tag Missing in Wordoress

The closing P tag is stripped out of my blog posts whenever I use this code in my Functions.php file to insert an after a number of paragraphs. It leaves the unclosed. What could be wrong? // Article Ads After X Paragraphs ///////////////////////////////////// $mvp_post_inad = get_option('mvp_post_inad'); if (!empty($mvp_post_inad)) { function mvp_post_ad_insert( $text ) { if ( is_single() ) { $mvp_post_inad = get_option('mvp_post_inad'); if ($mvp_post_inad) { $ads_text = '<div class="mvp-post-ad-wrap"><span class="mvp-ad-label">' . esc_html__( 'Advertisement', 'zox-news' ) . '</span><div class="mvp-post-ad">'.do_shortcode(html_entity_decode($mvp_post_inad)).'</div></div>'; } $split_by …
Category: Web

Wordpress menu walker - help to add custom class for each submenu

I am trying to apply to my already existing menu a walker in order to add custom classes to every sub menu anchor tag. Here is my menu: wp_nav_menu(array( 'theme_location' => 'menu-top', 'container' => 'ul', 'menu_class' => 'header_nav_ul', 'menu_id' => 'header_nav_id', 'depth' => 0, )) I added the wolder and it became: wp_nav_menu(array( 'theme_location' => 'menu-top', 'container' => 'ul', 'menu_class' => 'header_nav_ul', 'menu_id' => 'header_nav_id', 'depth' => 0, 'walker' => new my_walker_nav_menu_start_el(), )) The walker function is this one: function …
Category: Web

How to deal with errors of defining data types in pandas' read_csv ()?

I have a table with 118,000 rows and 80 columns. I would like to select 8 columns from the table. I am reading the file using the pandas function pd.read_csv command as: df = pd.read_csv(filename, header=None, sep='|', usecols=[1,3,4,5,37,40,51,76]) I would like to change the data type of each column inside of read_csv using dtype={'5': np.float, '37': np.float, ....}, but this does not work. There is a message that column 5 has mixed types. The command print(df.dtypes) shows all columns of …
Topic: pandas python
Category: Data Science

Search not showing all results

EDIT: So I've done some troubleshooting and it seems my theme isn't showing woocommerce search results. The 2017 theme does so I am trying to figure out what my theme is missing. I suspect something in the functions.php file. It's something I'm leaving out, not something I've included that's interfering, because I deleted all my code out of the functions file line by line and nothing changed. I have some custom code I have used elsewhere without any trouble. I …
Category: Web

Highlight search words in excerpt

I have designed and developed a responsive Wordpress site that is almost ready for launch for a client who is an actor and producer. I have been stuck on my requirements for the search results page for three days. My EXCERPT is far too long and includes repeated text from the Home page no matter what the search is for. Under the white links to the posts and pages for the search results, I want an excerpt of no more …
Category: Web

LeNet-5 - combining feature maps in C3 layer

Famous LeNet-5 architecture looks like this: The output of layer S2 has dimension: 10x10x6 - so basically an image with 6 convultions applied to it to derive features. If each dimension was again submitted to 6 filters the resulting output would be of 10x10x36 however it is 10x10x16. Initially I stumble on it but finnaly I udnerstood that this is done be combining inputs from layer S2 and applying one kernel on it as it's explained in the article: Layer …
Category: Data Science

How to get the WooCommercer product variation image

I am building a WooCommerce theme but I’m having trouble getting the featured image to change when the user selects a product variation. I have set different featured images for each variation on the backend, and this is the function I’m using to call the product’s featured image. What should I add to this function in order to grab the variation’s featured image instead of the overall product featured image? function show_featured_image() { global $product; echo '<div class="product_fetured_image">'; echo '<div …
Category: Web

How would you describe cluster 2 from this output of a run of the EM program?

My description: Cluster 2 consists of 9511 instances, the age is around 42 (ranges between 29.7207 and 54.5257). Considering Age, Cluster 2 is very well separated from Cluster 1, with a distance of 18.9513. On the other hand, Cluster 2 and Cluster 0 are very close though, their centroids are withihn a distance of around 0.8248. What else could be added?
Category: Data Science

How can I query for posts using a date stored in post-meta?

I’m working on a games release feature for a website I’m building. So far everything is going smooth, but I’m stuck on one area. For the listings on the front end, I want it to look at the “release_date” field and only display games that have a release date >= that date. I feel the code below should work, but it doesn’t return/display anything on the front end. And if I switch it to <=, it displays everything. Any help …
Category: Web

Translate javascript with WordPress built-in localization API for static strings

I have been trying to implement the translation to a couple of strings in a .js file but nothing has worked. First try to do it like I do in php, in the .js file add this variable var __ = wp.i18n.__; and I put the strings like __( 'Hello World', 'text-domain'), but it didn't work. After looking for information about it, I found a post where they talk about passing the translated strings with wp_localize_script something like that. // …
Category: Web

Impossible to create a new WooCommerce customer using Rest API

On my website I have created a register page in react and I am using Wordpress headless with WooCommerce on it. So I was expecting to create a new user using the register page i have and as the Wordpress side is by default set to create a 'Customer" user type for any new registration. The registration is partially working. Let me explaining. To achieve the registration I have done this: On wordpress, I have installed the plugin : WP …
Category: Web

Getting below error in time and day split in R

data$eu_indicator<-as.factor(data$eu_indicator) data$hour<-hour(data$calc_created) data$day<-date(data$calc_created) #data transformation #datetime: split on date and hours error msg:::Error in hour(data$calc_created) : could not find function "hour" Error in date(data$calc_created) : unused argument (data$calc_created)
Category: Data Science

Multiple XGBoost models or just 1 for a cetain type of category?

I am building a model to predict, say house prices. Within my data I have sales and rentals. The Y variable is the price of either the sales or rentals. I also have a number of X variables to predict Y, such as number of bedrooms, bathrooms, meters squared etc. I believe that the model will firstly make a split on the variable "sales" vs "rentals" as this would reduce the loss function - RMSE - the most. Do you …
Category: Data Science

How to implement my own loss function for Prototype learning using Keras Model

I'm trying to migrate this code, "Omniglot Character Set Classification Using Prototypical Network", into Tensorflow 2.1.0 and Keras 2.3.1. My problem is about how to use euclidean distance between train data and validation data. Look at this code: def convolution_block(inputs, out_channels, name='conv'): conv = tf.layers.conv2d(inputs, out_channels, kernel_size=3, padding='SAME') conv = tf.contrib.layers.batch_norm(conv, updates_collections=None, decay=0.99, scale=True, center=True) conv = tf.nn.relu(conv) conv = tf.contrib.layers.max_pool2d(conv, 2) return conv def get_embeddings(support_set, h_dim, z_dim, reuse=False): net = convolution_block(support_set, h_dim) net = convolution_block(net, h_dim) net = convolution_block(net, …
Category: Data Science

What Non-linearities are best in Denoising RNN Autoencoders and where should the go?

I’m employing a denoising RNN autoencoder for a project relating to motion capture data. This is my first time using auto encoder architectures and I was just wondering what non-linearities should be placed in these models and where they should go. This is my model as it stands: class EncoderRNN(nn.Module): def __init__(self, input_size, hidden_size, num_layers): super(EncoderRNN, self).__init__() self.input_size = input_size self.hidden_size = hidden_size self.num_layers = num_layers self.rnn_enc = nn.RNN(input_size=input_size, hidden_size=hidden_size, num_layers=num_layers, batch_first=True) self.relu_enc = nn.ReLU() def forward(self, x): pred, hidden …
Category: Data Science

WP_Editor Shortcode Issue

I have created a front-end editor using wp_editor that functions as it should. Upon testing I have noticed that it is stripping out any shortcodes that have been inserted in the content. I have looked into this issue and found that it's the 'ob_' (output buffering) that is removing them. If I remove this output buffering then the shortcodes display fine, but it breaks the functionality I have created for the editor. How would I keep the code I am …
Category: Web

How to return the number of values that has a specific count

I would like to find how many occurrences of a specific value count a column contains. For example, based on the data frame below, I want to find how many values in the ID column are repeated twice | ID | | -------- | | 000001 | | 000001 | | 000002 | | 000002 | | 000002 | | 000003 | | 000003 | The output should look something like this Number of ID's repeated twice: 2 The ID's …
Category: Data Science

How to get sidebar widgets in leftsidebar template

I have created a custom sidebar widgets using below code : register_sidebar(array( 'id' => 'sidebar-widget-1', 'name' => 'Sidebar Widget 1', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', )); and it is showing in Appearance -> Widgets and it is also showing content on frontend using dynamic_sidebar('Sidebar Widget 1'). But I want to get content of this register_sidebar by using its id into a variable. How to get sidebar content by using its id?
Category: Web

Binary classificaiton for weather data if its class 1 or class 0 alert

I am working on weather data and it has few features that are independent variables such as severity, severity_id, urgency_id etc ... Based on these values, I would like to classify alerts into class 0 or 1. For example, below is row item from data source Alert | Severity | Sev_Id | Urg_Id | Event | Sys_Rec(Target Variable) -------------------------------------------------------------------------- dummy | Extreme | 1 | 1 | STORM | 1 dummy | Minor | 3 | 5 | RIPTIDE | …
Category: Data Science

Format meta_value

I have a request to get postmeta records with a specific meta_value. global $wpdb; $result = $wpdb->get_results ( " SELECT * FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key LIKE 'wpcomplete' " ); foreach ( $result as $page ) { echo maybe_unserialize($page->meta_value).'<br/>'; } result : {"buttons":{"3":"1951965-debutant","4":"1951965-intermediaire","5":"1951965-expert"},"course":"examen"} I just need to clean the result like that buttons : 1951965-debutant 1951965-intermediaire 1951965-expert course : examen
Category: Web

The accuracy depends on the hyper-parameter in a strongly non-monotinic way

I have a data set labelled with a binary classes. I calculated the principal components from the data, then made the PC transformation. The goal is to find an optimal number of PCs so that the binary classification accuracy is good enough. I've learned a binary classifier sklearn.linear_model.LogisticRegressionCV (default parameters) on the PC-transformed data. The number of PCs was the (hyper-)parameter and it was varied. I cannot interpret the resulting Accuracy v. #PCs graph, why is it so strange? For …
Category: Data Science

Visualizing large number of points as a 3D density map

The result of my computational simulation is a (time-dependent) system of large number (~100k) of moving points in a confined space. Each point has its own Cartesian coordinates as well as a weight (w) in the form of $(x_i,y_i,z_i;w_i)$. I'm looking for a software/app/package to create a snapshot of the 3D spatial density map of these points. (something like this). Like you see in this figure, the points are not going to be displayed individually, but only a transparent cloud …
Category: Data Science

returning the currect URL for nested posts

I have a posttype called (article) witch have a meta_key called (parents_ids). So the article can be related to multiple articles. I want to return the currect URL depending on the parent post For example: 1-If the user click on the child-article comming from parent-article-1 i want the url to be example.com/parent-article-1/child-article. 2-If the user click on the child-article comming from parent-article-2 i want to return the url example.com/parent-article-2/child-article
Category: Web

Model for predicting duration based on categorical data

I am working on a model which will allow me to predict how long it will take for a "job" to be completed, based on historical data. Each job has a handful of categorical characteristics (all independant), and some historic data might look like: JobID Manager City Design ClientType TaskDuration a1 George Brisbane BigKahuna Personal 10 a2 George Brisbane SmallKahuna Business 15 a3 George Perth BigKahuna Investor 7 Thus far, my model has been relatively basic, following these basic steps: …
Category: Data Science

How to change or add user role after getting post request data about pay?

How to change or add user role after getting post request data about pay? qiwi2.php file in theme folder: <?php include($_SERVER['DOCUMENT_ROOT'].'/wp-load.php'); $qiwi = [ "public_key" => "*", "secret_key" => "*", "successUrl" => "https://someurl/" ]; $secret_key = $qiwi['secret_key']; $sha256_hash_header = $_SERVER['HTTP_X_API_SIGNATURE_SHA256']; $entity_body = file_get_contents('php://input'); $array_body = json_decode($entity_body, 1); $amount_currency = $array_body['bill']['amount']['currency']; $amount_value = $array_body['bill']['amount']['value']; $billId = $array_body['bill']['billId']; $siteId = $array_body['bill']['siteId']; $status_value = $array_body['bill']['status']['value']; $account = $array_body['bill']['customer']['account']; $invoice_parameters = $amount_currency."|".$amount_value."|".$billId."|".$siteId."|".$status_value."|".$account; $invoice_parameters=(string) $invoice_parameters; $sha256_hash = hash_hmac('sha256', $invoice_parameters, $secret_key); if (!empty($sha256_hash_header) && strcmp($sha256_hash_header, $sha256_hash) …
Category: Web

About

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