How to make elements not editable in visual editor

I have bootstrap grid in some pages, which I've made visibale in the editor by styling in editor styles. Is there a way to make the column div not removable in visual editor, kind of like how you can't delete a table cell with a backspace. So that when a client deletes the text in a div and keeps pressing the backspace it wont delete the div itself? However I do want the code to be editable when you switch …
Category: Web

Add new users to "add new user" page on admin's dashboard

I understand there's a lot of similar questions, but all of them show how to update the wp_usermeta table in the database, whereas I want to use wp_update_user() to update a particular field (nickname <-> user_nicename) in the wp_users table. Here is my snippet, (which I have collected from other similar questions) it appends the new field to the "add new user" page, but it doesn't save the information in the database with wp_update_user(). P.S.: I also would like to …
Category: Web

I want to display latest post in marquee

<?php /* Plugin Name: Breaking News */ function rif_breaking_news(){ ?> <div class="breaking_news_box" style="background: none repeat scroll 0 0 #2E8B57;bottom: 0;color: #CCCCCC;direction: ltr;height: 32px;left: 0;min-width: 600px;position: fixed;width: 100%;z-index: 99935;" id="breaking_news"> <b class="breaking_head">Latest News:</b> <ul style="margin:4px;"> <marquee behavior="scroll" direction="left" scrollamount="3" scrolldelay="60" onmouseover="this.stop()" onmouseout="this.start()"> <?php $latest = get_posts('numberposts=5'.'&offset='.'&cat=13'); foreach( $latest as $post ): ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>     <?php endforeach; ?> </marquee> </ul> </div> <?php } add_action('wp_footer','rif_breaking_news'); function rif_css_fileLink(){ echo '<link rel="stylesheet" type="text/css" href="'.plugin_dir_url(__FILE__).'css/style.css" >'; } add_action('wp_head','rif_css_fileLink'); ?>
Category: Web

Variational AutoEncoder giving negative loss

I'm learning about variational autoencoders and I've implemented a simple example in keras, model summary below. I've copied the loss function from one of Francois Chollet's blog posts and I'm getting really really negative losses. What am I missing here? Model: "model_1" __________________________________________________________________________________________________ Layer (type) Output Shape Param # Connected to ================================================================================================== input_1 (InputLayer) [(None, 224)] 0 __________________________________________________________________________________________________ encoding_flatten (Flatten) (None, 224) 0 input_1[0][0] __________________________________________________________________________________________________ encoding_layer_2 (Dense) (None, 256) 57600 encoding_flatten[0][0] __________________________________________________________________________________________________ encoding_layer_3 (Dense) (None, 128) 32896 encoding_layer_2[0][0] __________________________________________________________________________________________________ encoding_layer_4 …
Category: Data Science

WordPress PNG compression issue

I'm having issues with images getting badly compressed when uploaded to my site. It's not an issue with photographs, but is very noticeable for images with solid blocks of colour and text. I've uploaded a PNG with a solid grey background overlaid with white text, and it's being badly compressed when WordPress resizes it to the various alternative sizes. Original image Large featured image size Unfortunately I don't have enough reputation to post more than 2 links, but you can …
Category: Web

What to do if your adversarial validation show different distributions for an NLP problem?

I was trying to figure out if the test set from a competition is similar to the train set. This was done in a NLP competition, in which I had two columns, tweet and type, and I needed to predict the type of crime the tweet was reporting. So I decided to check if the train set is too different from the test set. This is what I've done so far: # drop the target column from the training data …
Category: Data Science

Turning multiple binary columns into categorical (with less columns) with Python Pandas

I want to turn these categories into values of categorical columns. The values in each category are the current binary columns present in the data frame. We have : A11, A12.. is a detail of A1 so if the value in A11 ==1 it will necessarily imply having A1==1 but the inverse is not valid. Respecting the following conditions : maximaum of existing types is 4 if A11==1 value of type1 should be equal to 'A11' and we ignore 'A1' …
Category: Data Science

Get featured image and additional posts thumbnail Wordpress REST API

I want to use the REST API of wordpress to build a new version of a custom theme. I'm able to get the json response of a particular category, but I need to find a way to obtain also the featured image or the second post thumbnail registered using a plugin, so I can use them in the layout. Is this possible without using a plugin? here is the code I'm using for testing: <script> (function($){ $(document).ready(function(){ $.getJSON('https://localhost/wordpress/wp-json/wp/v2/posts?category_name=portfolio&per_page=50&_embed', function(response){ console.log(response); …
Category: Web

How to output child block attributes on a parent block

I have a custom Gutenberg block that contains a list of InnerBlocks (all the same known block), and I am trying to output the title attribute from each of those blocks in a list on the parent block. I'm trying to get values from the innerblocks and add them to an array attribute on the parent block, This is a simplified version of the parent block edit.js const Edit = ( props ) => { const { attributes: { childValuesArray …
Category: Web

Fast AI Lesson 4 - MNIST. Confused about multiplying weights by pixels?

I’m on lesson 4 of the Fast AI "Deep Learning for Coders" course, and have been back through the same lesson a few times now but I don’t think I’m quite getting a few things. I want to have an understanding of what’s going on before moving on. This lesson is on MNIST - and Jeremy is recognising 3s vs 7s. So he has 12000 images (ignoring mini-batches) of about 800 pixels each, and his tensor has a shape of …
Category: Data Science

List only child categories a post is in, of a specific parent category in wordpress

I am building a quotes website and i have 2 main categories like Topic & Authors Every quote will have Author name and topic name and those are sub categories of Topic & Author. AND my question is i want to display only Author categories that is a sub category of a Authors category please help me... Topic - Love - Life - Friends etc Authors - Author1 - Author2 - Author3
Category: Web

Why is 10000 used as the denominator in Positional Encodings in the Transformer Model?

I was working through the All you need is Attention paper, and while the motivation of positional encodings makes sense and the other stackexchange answers filled me in on the motivations of the structure of it, I still don't understand why $1/10000$ was used as the scaling factor for the $pos$ of a word. Why was this number chosen?
Category: Data Science

Per Page Permalink Structure for Page Post Type

I am trying to Re-Write Page URL's so that they END with .htm I was able to do this using... /* Add .htm extension to Page URL Links */ add_action('init', 'htm_page_permalink', -1); function htm_page_permalink() { global $wp_rewrite; if ( !strpos($wp_rewrite->get_page_permastruct(), '.htm')){ $wp_rewrite->page_structure = $wp_rewrite->page_structure . '.htm'; } } /* Remove the trailing slash/ on Pages */ add_filter('user_trailingslashit', 'no_page_slash',66,2); function no_page_slash($string, $type){ global $wp_rewrite; if ($wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes==true && $type == 'page'){ return untrailingslashit($string); }else{ return $string; } } But then …
Category: Web

Naives Bayes Text Classifier Confidence Score

I am experimenting with building a text classifier using Naive Bayes which has been pretty successful on my test data. One thing i am looking to incorporate is handling text that does not fit into any predefined category that I trained the model on. Does anyone have some thoughts on how to do this? I was thinking of trying to calculate the confidence score for each document, and if < 80 % confidence, for example, it should label the data …
Category: Data Science

How to allow certain PHP functions when using sanitize_callback in the word press customizer

Hi I am making my own theme in WordPress and setting up some customizer options and I have one for the text in my footer but I would like to still use <? echo date('Y');?> in the footer to dynamically change the date so I don't have to keep going in and doing it manually but the sanitizer call-back obviously blocks it is there a way to still be able use that php function in the sanitizer here is my …
Category: Web

Dataset with Multiple Choice Questions for fine tuning

I hope it's allowed to ask here, but I am looking for a dataset (the format is not that important) that is similar to SQuAD, but it also contains false answers to the questions. I wanna use it to fine tune GPT-3, and all I find is either MC questions based on a text, but with no distractors, or classical quizzes that have no context before each question. I have a code that generates distractors, and I can just plug …
Category: Data Science

Firing a function AFTER redirect

I am using a function that redirects the user to a custom page, rather than wp-login in the event of errors. In my case I am using the Http Referer function to send the user back to the same page because I have the login form in a modal. How can I execute a function on the redirected page, so that the page automatically opens the modal? This is the code for the redirect in the event of an error: …
Category: Web

Display if author page is author page of current user

in my multi author website I have a button that users can upload their avatars. I need to display this button in author page. I can do it. I added this button to author page. The problem is that author can see this button in other author's page too . That's why I need to display this button in author page of current user. I am so sorry I have no any reference code. I have no any idea how …
Category: Web

Fine Tuning BERT for text summarization

I was trying to follow this notebook to fine-tune BERT for the text summarization task. Everything was good till I come to this instruction in section Evaluation to evaluate my model: model = EncoderDecoderModel.from_pretrained("checkpoint-500") An error appears: OSError: checkpoint-500 is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models' If this is a private repository, make sure to pass a token having permission to this repo with use_auth_token or log in with huggingface-cli login and …
Category: Data Science

How do I add <div> tags to entire comments, not just their text

Thanks to some wonderful help here at stack exchange, I have built a comment section with a dropdown menu that adds comment_meta to the comments. I currently have a working filter that uses GET to trigger an if statement to query based on this comment_meta info. The thing I don't like is that it refreshes the page each time you click a button. I'm looking for a way to filter without having the page refresh. I think I need Javascript …
Category: Web

Limit Salesforce objects and fields in Tableau Desktop

In connecting Salesforce to Tableau Desktop it brings in every single object as a table. Within each table/object it brings in every single field. The issue is there are many standard objects my org doesn't use. Within each object there are even more fields which we don't need. Is there a way when connecting Salesforce to Tableau Desktop to do data analysis to only show certain objects/tables, and within those, pick which fields to display. My hope is to have …
Topic: tableau
Category: Data Science

Color name prediction

Given data: R G B Color 0 0 0 Black 255 255 255 White 255 0 0 Red 0 255 0 Lime 0 0 255 Blue 255 255 0 Yellow 0 255 255 Cyan_Aqua ... Can we predict the color given an RGB input? For example, 224, 255, 255=light_cyan The goal is to generate logical names and not random names. For instance, if the data contains "green", a closest match with lighter hue, would be named "light green". If yes, …
Topic: weka
Category: Data Science

How to make my wordpress site Multi-region

I have a website that I want to make multi-region. In this case I want some pages of the website to be different on each region, also the menu should be different. For example. I want a website that will be available in Colombia, Mexico and Costa Rica. I want that when you enter the URL: mysite.com/co/ it shows you the Colombian version of the homepage, the menu for the colombian site and even somepages can be the same, let's …
Category: Web

How to use text as an input for a neural network - regression problem? How many likes/claps an article will get

I am trying to predict the number of likes an article or a post will get using a NN. I have a dataframe with ~70,000 rows and 2 columns: &quot;text&quot; (predictor - strings of text) and &quot;likes&quot; (target - continuous int variable). I've been reading on the approaches that are taken in NLP problems, but I feel somewhat lost as to what the input for the NN should look like. Here is what I did so far: Text cleaning: removing …
Category: Data Science

delete duplicates wp_postmeta

I'm looking to cleanup wp_postmeta. I've found dozens of duplicate entries. I've spend about 8 hours looking through topics and trying code and plugins to no avail. The most useful article on the subject I found is this. However the article is from 5 years ago and I'm not sure that the suggested code leaves at least 1 entry from each duplicate. Also the plugin that is suggested (Cleanup Duplicate Meta) is exactly what I need, but it hasn't been …
Category: Web

Find highest reward for epsilon-greedy bandit program

I started to learn reinforcement learning, the first example is handling bandit program using epsilon-greedy method, In this example, there are three bandit machines used, the output is the mean value for all bandit machines and cumulative average with respect to the epsilon value The code - class Bandit: def __init__(self, m): self.m = m self.mean = 0 self.N = 0 def pull(self): return np.random.randn() + self.m def update(self, x): self.N += 1 self.mean = (1 - 1.0/self.N)*self.mean + 1.0/self.N*x …
Category: Data Science

Confusion with L2 Regularization in Back-propagation

In a very simple language, this is L2 regularization $\hspace{3cm}$$Loss_R$ = $Loss_N + \sum w_i^2$ $Loss_N$ - Loss without regularization $Loss_R$ - Loss with regularization When implementing [Ref], we simply add the derivative of the new penaty to the current delta weight, $\hspace{3cm}$$dw = dw_N + constant*w$ $dw_N$ - Weight delta without regularization What I think - L2 regularization is achieved with the last step only i.e. the weight is penalized. My question is - Why do we then add …
Category: Data Science

A clear visualization of a two-way ANOVA

To provide a full yet simple picture of a 3-level, one-way ANOVA, I use the following visualization where variation within each group (the filled circles) and variation between the groups (black arrows) are simple to be understood. But I'm wondering if it could be possible to extend the current visualization to a 2 x 3 two-way ANOVA (adding another way with two groups to the current visualization)? (Note: the dashed vertical lines denote each group's mean)
Category: Data Science

Why is WordPress rewriting absolute URLs on staging site to include staging prefix when we manually point them at the live site?

Edited for clarity and to display steps we take to reproduce the issue. Question What would cause absolute URLs on our staging site to prepend the staging site's subdomain to them when saved in the editor? Summary We write pages manually in HTML and CSS on a staging site hosted on SiteGround, save our changes, then test them. However, when we save our work in the editor, they all prepend the staging subdomain we are writing on to each of …
Category: Web

Change separators in HTML <title></title> tags

I'm using WP 4.7.3 and a custom template set (mh-magazine). By default, WP sets a title tag like "Page title" - "Blog title". Now all I want to achieve is to replace "-" into a pipe symbol for layout reasons. So the processed HTMl should look like: My page title | My blog title I thought that this is easy to achieve, but I see I need some help since I'm not an expert in PHP or WP.
Category: Web

Translate a Constant while appeasing WordPress PHPCS

The following works but isn't up to snuff with PHP Code Sniffer WordPress coding standards &lt;?php esc_html_e( ADDRESS, 'wprig' ); ?&gt; Linter yells at me with: [WordPress.WP.I18n.NonSingularStringLiteralText] The $text arg must be a single string literal, not "ADDRESS". The following, for aforementioned error, also don't work: &lt;?php esc_html_e( (string)ADDRESS, 'wprig' ); ?&gt; &lt;?php esc_html_e( strval(ADDRESS), 'wprig' ); ?&gt; &lt;?php esc_attr_e( ADDRESS, 'wprig' ); ?&gt; I know constants can be exploited so it is needed. Any way to make this work …
Category: Web

Wordpress WooCommerce programmatically set EU VAT when creating an order in PHP

I am really struggling and I really hope that you can help me with this questions. So the question I am struggling with is: How can I add the EU VAT with a checkmark in the order? Currently I only get a big red cross in the EU VAT column in the wordpress dashboard. What am I missing? Screenshot of the order with a big red cross (Check the fifth column) https://imgur.com/a/Oox4k5k The code I made an endpoint in PHP …
Category: Web

404 in gutenberg autosave of a Custom Post Type with custom rest_namespace

I'm having some troubles with CPTs defined with custom rest_namespace at register_post_type. I keep getting an 404 error at the console. The error shows that the namespace is not being changed in autosave route. WP default namespace: wp/v2 Custom namespace defined: ek/v1 I dug into the core classes to find how Wordpress handle custom namespace. The WP_REST_Autosaves_Controler define the namespace using get_post_type_object at the __construct method: ... $post_type_object = get_post_type_object( $parent_post_type ); .... $this-&gt;namespace = ! empty( $post_type_object-&gt;rest_namespace ) ? …
Category: Web

Overriding woocommerce payment with a token-based payment method

The project I am working is to create a platform,where every items posted can be exchanged for 1 token, instead of paying prices. To do this, I`ve tried YITH /SUMO /Woocommerce reward points plugins, and Dokan as the multi-vendor plugin. Here are the problems I encountered: Among all the reward points plugins, SUMO reward point is closest to my needs, as it provide payment gateway using award points. However,in each reward points plugins I tried,points-payment is just a converted version …
Category: Web

Wordpress plugin not finding Composer Autoloader

When I try to use Autoload in my Wordpress plugin I get an unexpected error: not finding Warning: require(/home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/../phpunit/phpunit/src/Framework/Assert/Functions.php): failed to open stream: No such file or directory in /home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/autoload_real.php on line 55 Fatal error: require(): Failed opening required '/home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/../phpunit/phpunit/src/Framework/Assert/Functions.php' (include_path='.:/usr/share/php') in /home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/autoload_real.php on line 55 I've uploaded the files via SFTP Called require_once(&quot;vendor/autoload.php&quot;); in the plugin entry file (it works) *The autoload.php file contains require_once DIR . '/composer/autoload_real.php';
Category: Web

Does high accuracy metrics with small (but equally sampled) dataset means a good model?

I have been training my CNN with 200 images per class for a classification problem. There problem is a binary classification one. And with the amount of test data ( 25 per class) I am getting good accuracy, precision and recall values. Does that mean my model is actually good?
Category: Data Science

About

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