I don't understand why use array inside the add action hook to create custom post type using object oriented way

<?php /* Plugin Name: My Plugin Plugin URI: https://my.plugin.com Description: My plugin description Version: 1.0.0 Author: Me Author URI: https://my.website.com License: GPL2 (or whatever) */ class myClass { function __construct() { add_action( 'init', array( $this, 'create_post_type' ) ); } function create_post_type() { $name = 'Foos'; $singular_name = 'Foo'; register_post_type( $name , array( 'labels' => array( 'name' => _x( $name, 'post type general name' ), 'singular_name' => _x( $singular_name, 'post type singular name'), 'menu_name' => _x( $name, 'admin menu' ), 'name_admin_bar' …
Category: Web

Trying to add array of paths to post permalink

Am trying to add custom path to my article posttype so my article path will be www.example/parent-post-1/parent-post-2/the-actual-post i tried to add this code /** * @param $post_link * @param $id * Добавить название категории продукта к ссылке * @return array|mixed|string|string[] */ function wpa_course_post_link($post_link, $id = 0) { $post = get_post($id); if ($post instanceof WP_Post) { $parent = get_field('parents', $post->ID) ?: []; $link = ''; foreach ($parent as $post) { $link .= $post->post_name . '/'; } if ($parent) { $post_link = …
Category: Web

AJAX action through direct link

I have an existing AJAX action that's already defined by the theme I'm using. The action deletes a search item request, and I'd like to use it as a direct link - like an Unsubscribe link - emailed to the user along with the search results... Something like the following URL: https://domain.tld/wp-admin/admin-ajax.php?action=delete_saved_search_item=&search_item_id=17 but I get a 0 on the screen and a 400 Bad Request in the Headers. Basically in the JS it's defined like this: $.post(ajaxurl, { action: 'delete_saved_search_item', …
Topic: ajax Wordpress
Category: Web

Is it recommended to train a NER model using a dataset that has all tokens annotated?

I'd like to train a model to predict the constant and variable parts in log messages. For example, considering the log message: Example log 1, the trained model would be able to identify: 1 as the variable Example, log labeled as the constants. To train the model, I'm thinking of leveraging a training dataset that would have all tokens in all of the log entries annotated. For example, for a particular log entry in the dataset, we would have a …
Category: Data Science

Capping labels negatively impacts business metric

I have this deep neural network model with an integer label to predict. The label is heavily skewed so we cap the labels at some value (let's say 90 %ile). Now when we build and run the model, it performs well in general. But in online experiment shows degradation in business metrics for a fraction of users that have high value labels. If we don't cap the label, the business metrics gets skewed for users with low number of activities. …
Category: Data Science

Admin menu links just refresh the page

I'm using add_submenu_page() function to add some options to my plugin. On Linux hosting everything works like it should, on Windows hosting those 5 sub-menus have same link somehow and when I click on them page just reloads. What can be issue? Both hosts are using same PHP version. Here is the code $this->page_hooks['link1'] = add_submenu_page(__FILE__, __('link1', 'domain'), __('link1', 'domain'), $acl_table['manage_link1'], 'wp-plugin-link1', array($this, 'on_manage_link1')); $this->page_hooks['link2'] = add_submenu_page(__FILE__, __('link2', 'domain'), __('link2', 'domain'), $acl_table['manage_link2'], 'wp-plugin-link2', array($this, 'on_manage_link2')); $this->page_hooks['link3'] = add_submenu_page(__FILE__, __('link3', 'domain'), …
Category: Web

Entity recognition with context/relation

Is there a way to get a specific entity based on the context where it is found? For example: The temperature today is 35°C. Store risperidone tablet at 20°C. Both are talking about temperature. For the first sentence, I would want the temperature to be a "WeatherTemperature" entity. In the second sentence, I would want the temperature to be "DrugTemperature". What model could I use to train for this behavior?
Category: Data Science

Include results with tags relevant to the search keyword with JSON rest API v2

Wordpress doesn't natively search for tags so I need to install WP Extended Search and add post_tags as one of its parameters so whenever I search for keywords natively, posts with that tag will appear. However, when I tried searching on the wp-json REST API, that post doesn't appear. Here's an example with a post that is tagged with "technology". When I search "technology " using this json rest api url, it returns an empty array: example.com/posts?search=technology But if I …
Category: Web

What is the relationship between the accuracy and the loss in deep learning?

I have created three different models using deep learning for multi-class classification and each model gave me a different accuracy and loss value. The results of the testing model as the following: First Model: Accuracy: 98.1% Loss: 0.1882 Second Model: Accuracy: 98.5% Loss: 0.0997 Third Model: Accuracy: 99.1% Loss: 0.2544 My questions are: What is the relationship between the loss and accuracy values? Why the loss of the third model is the higher even though the accuracy is higher?
Category: Data Science

NLP Making new Predictions on Vectorized set

Vectorization techniques like TF-IDF are very common techniques for transforming text data into numerical data that can be more easily feed to ML Algorithms. Before we first train the model, each word of each document is given a number (a frequency) which depends on the whole data. How can I input to the already trained model, a new custom, unseen before sentence since the model was trained with the whole dataset vectorized? For instance, my new sentence has a different …
Topic: nlp
Category: Data Science

Draggable item in custom gutenberg block

I'm developing some custom blocks in the new Gutenberg editor experience, and I'm struggle to understand how to use some build-in components, mostly the Draggable components. What I would like to achieve is a list of items (let's say many li in a ul) and I want them to be orderable with a drag & drop feature. Here is my code: import { __ } from '@wordpress/i18n'; import { registerBlockType } from '@wordpress/blocks'; import { Draggable, Dashicon } from '@wordpress/components'; …
Category: Web

When to tune hyperparameters in deep learning

I am currently playing around with different CNN and LSTM model architectures for my multivariate time series classification problem. I can achieve validation accuracy of better than 50 %. I would like to lock down an exact architecture at some stage instead of experimenting endlessly. In order to decide this, I want to also tune my hyperparameters. Question: How do I balance the need to experiment with different models, such as standalone CNN and CNN with LSTM against hyperparameter tuning? …
Category: Data Science

How to summarize very large neural networks?

I am doing a lot of work with transfer learning at the moment (using keras and tensorflow if that is relevant). I am having a lot of issues in sufficiently summarizing the very large models. This post: How do you visualize neural network architectures? shows a lot of useful methods for visualizing architectures, and they are great for networks such VGG16, but none of them are reasonable to include in a report if the models are very large (such as …
Category: Data Science

How to Show Next, Previous, and Page Numbers with wp_link_pages

I want to modify the output of wp_link_pages. Basically what I need is to show Previous and Next buttons and current page/total number of pages. I created the Previous and Next button. Now in between them I want to add a current page and the total pages number. Here is my code wp_link_pages( array( 'before' => '<div class="page-links">' . __(''), 'after' => '</div>', 'next_or_number' => 'next', 'nextpagelink' => __('Next'), 'previouspagelink' => __('Previous'), 'pagelink' => '%', 'echo' => 1, ) ); …
Category: Web

Transitioning from a python script for data transformation to BigQuery

So I have a dataset spread over multiple and ever-growing excel files all of which looks like: email order_ID order_date [email protected] 1234 23-Mar-2021 [email protected] 1235 23-Mar-2021 [email protected] 1236 23-Mar-2021 [email protected] 1237 24-Mar-2021 [email protected] 1238 28-Mar-2021 End goal is to have two distinct datasets as: First one being Orders: (Public. For analysis, trading emails with user_IDs for anonymity and marking returning for further analyses) user_ID order_ID order_date is_returning? 1 1234 23-Mar-2021 0 2 1235 23-Mar-2021 0 2 1236 23-Mar-2021 1 1 …
Category: Data Science

Rewrite URL - insert custom variables as a directory path

I'm trying to re-write permalink structure with my own custom url in WordPress for a Divi Theme "project" I have already changed the "Divi slug" from "project" to "prodotti" so currently, the URL appears like this: http://www.example.com/prodotti/%postname%/ with my custom function function custom_post_name() { return array( 'feeds' => true, 'slug' => 'prodotti', 'with_front' => false, ); } add_filter('et_project_posttype_rewrite_args', 'custom_post_name'); I want to add to these urls a variable, that reside for each post in post_metadata, in order to build a …
Category: Web

Isolation Forest Score Function Theory

I am currently reading this paper on isolation forests. In the section about the score function, they mention the following. For context, $h(x)$ is definded as the path length of a data point traversing an iTree, and $n$ is the sample size used to grow the iTree. The difficulty in deriving such a score from $h(x)$ is that while the maximum possible height of iTree grows in the order of $n$, the average height grows in the order of $log(n)$. …
Category: Data Science

Best possible way to get all options

I need to provide a list of all options set via plugins etc to remote calls. There is a plugin WP API Options but it hardly does the job. There are two possible ways (that I know of) to get a list of all options set in the blog/site: Use $wpdb to run a query like so: $option_names = $wpdb->get_col( "SELECT DISTINCT option_name FROM $wpdb->options WHERE option_name NOT LIKE '_transient_%'" ); Use wp_load_alloptions() Which one of these two would be …
Category: Web

Woocommerce 6.5.1. checkout: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

After updating woocommerce to latest version 6.5.1. i'm unable to order products because of: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data casued by checkout.min.js screenshots here: https://i.stack.imgur.com/JAf4D.png https://i.stack.imgur.com/11Vvg.png I tried to deactivate all plugins and after deactivating one of them i managed to finish order but orded did not containt ordered product. I just got customer info without product info. Debug.log wasn't helpfull because it showed me only the warning about that one plugin. …
Category: Web

Pagination (on the static front page) shows always the same posts

I have a problem with pagination on my front page. I want to show all posts from a specific category and paginate them. Here is the code if ( is_front_page() ) { $paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : 1; $args = array( 'post_type' => 'post', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => 1, 'cat' => '4', 'page' => $paged, ); $q = new WP_Query( $args ); if ( $q->have_posts() ) { while ( $q->have_posts() ) …
Category: Web

Missing a temporary folder not fixed

I uploaded my first wordpress website on the server, but trying to add new media files, i have got the message "Missing a temporary folder", I tried the solutions on the forum: define('WP_TEMP_DIR',dirname(__FILE__).'/wp-content/temp/'); and created a 'temp' folder on 'wp-content', but the problem still happened .. how to fix that please ?? I tried by doing this : creating the folder on localhost with writable property then upload it to the server, but it still doesn't work
Category: Web

Behavioural data required to predict churn

I am trying to build a predictive churn model that will identify customers who are likely to churn. I am defining a churned user as someone who hasn't transacted within 60 days. 90% of all transactions occur within 60 days of one another so this feels reasonable. I have very limited behavioural data; however. I have a record of a user's transactions and I have access to Google Analytics (GA). GA does not, however, allow me to track the specific …
Category: Data Science

Understanding Learning Rate in depth

I am trying to understand why the learning rate does not work universally. I have two different data sets and have tested out three learning rates 0.001 ,0.01 and 0.1 . For the first data set, I was able to achieve results for all learning rates at optimization using stochastic gradient descent. For the second data set the learning rate 0.1 did not converge. I understand the logic behind it overshooting the gradients, however, I'm failing to understand why this …
Category: Data Science

Wordpress Child Category Display All Posts

I am creating a Wordpress page where all my posts in the child categories of team are displayed in a grid. I got this working with the below code. The formatting and general layout is great however it only shows the 5 most recent posts in the child category instead of all of them. In my Wordpress account I have 7 posts which should be displaying. How should I retrieve the posts so it displays them all. <ul class="faces"> <?php …
Category: Web

NLP - Simple approach to identify commonalities in text comments between people

For something we are working on, we were looking for a simple way to compare from review/feedback data against a question (for which there are multiple responses from multiple people), the following: What are the common things (things defined as phrases/sentences) they are saying (Some way to quantify the commonality too if possible). The point is to identify what seems to be areas of agreement about their review What are things that are not common (basically...what are those on-off sentences/phrases …
Category: Data Science

Get and Trim Full Post Content in WP Query

Simple task, but it isn't working: <?php $content = apply_filters( 'the_content', get_the_content() ); $contentWithoutHTML = wp_strip_all_tags($content); $pos = strpos($contentWithoutHTML, " ", 100); $contentFinal = substr($contentWithoutHTML,0,$pos ); echo $contentFinal . "..."; ?> My post is way over 100 characters long (with spaces), and yet I get strpos(): Offset not contained in string error, which leads me to believe it isn't actually pulling the entire content string. But I applied filters like I believe I should... please assist. Also sometimes even if …
Category: Web

Can we combine two models in which one was implemented in tensorflow and other one in pytorch?, to see the results of 2 models simultaneously?

To further explain my question. I am implementing 2 models. 1 is for action recognition and the 2nd is for weapon recognition. If there is a situation where a person is punching or kicking someone and carrying a weapon, my model should be able to detect the action and also a weapon, if that person is carrying any weapon in hand simultaneously. This can be useful for security purposes. So I want to combine these 2 models so that it …
Category: Data Science

Input type (MPSFloatType) and weight type (torch.FloatTensor) should be the same

I am trying to run this notebook on Apple M1 (1st gen) running MacOS 12.4, libs freeze: >pip3 freeze anyio @ file:///private/tmp/jupyterlab--anyio-20211211-70040-1yv1wmx/anyio-3.4.0 appnope==0.1.2 argon2-cffi @ file:///private/tmp/jupyterlab--argon2-cffi-20211211-70040-1er07d0/argon2-cffi-21.2.0 argon2-cffi-bindings @ file:///private/tmp/jupyterlab--argon2-cffi-bindings-20211211-70040-o64kwi/argon2-cffi-bindings-21.2.0 asttokens==2.0.5 attrs @ file:///private/tmp/jupyterlab--attrs-20211211-70040-6u3qxt/attrs-21.2.0 Babel==2.9.1 backcall @ file:///private/tmp/jupyterlab--backcall-20211211-70040-acdr42/backcall-0.2.0 beniget==0.4.1 black==21.12b0 bleach==4.1.0 certifi==2022.5.18.1 cffi==1.15.0 charset-normalizer==2.0.12 click==8.0.3 cycler==0.10.0 Cython==0.29.24 debugpy @ file:///private/tmp/jupyterlab--debugpy-20211211-70040-2j9lay/debugpy-1.5.1 decorator==5.1.0 defusedxml @ file:///private/tmp/jupyterlab--defusedxml-20211211-70040-uowur4/defusedxml-0.7.1 entrypoints @ file:///private/tmp/jupyterlab--entrypoints-20211211-70040-1r2y5g4/entrypoints-0.3 et-xmlfile==1.1.0 executing==0.8.2 finnhub-python==2.4.5 gast==0.5.2 GDAL==3.4.0 gensim==4.1.2 graphviz==0.19.1 idna==3.3 imageio==2.13.5 ipykernel==6.6.0 ipython==7.30.1 ipython-genutils==0.2.0 ipywidgets==7.6.5 jedi==0.18.1 Jinja2==3.0.3 joblib==1.1.0 json5==0.9.6 jsonschema @ file:///private/tmp/jupyterlab--jsonschema-20211211-70040-1np642r/jsonschema-4.2.1 jupyter==1.0.0 jupyter-client==7.1.0 jupyter-console==6.4.0 jupyter-core==4.9.1 …
Topic: pytorch torch
Category: Data Science

mBART training "CUDA out of memory"

I want to train a network with mBART model in google colab , but I got the message of RuntimeError: CUDA out of memory. Tried to allocate 886.00 MiB (GPU 0; 15.90 GiB total capacity; 13.32 GiB already allocated; 809.75 MiB free; 14.30 GiB reserved in total by PyTorch) I subscribed with GPU in colab. I tried to use 128 or 64 for The maximum total input sequence length. Kindly, What can I do to fix the problem?
Category: Data Science

How to get widget content in Wordpress based on it's ID?

I need to parse widget content based on it's ID. But a widget works like a function that pulls data based on it's arguments, right? So when I pull the widget data, I can only get it's arguments, not the actual output. How can I parse the widget content based on it's ID? Example code: // Update widget rounds automatically function automatize_games_rounds($instance, $widget, $args){ // Check if there is a caption if (isset($instance['caption']) && !empty($instance['caption'])) { // If there is, …
Category: Web

WP Default Feed Url Change

I would like to change wordpress feed url. After a little research I find this function (check below). function remove_feed( $feedname ) { global $wp_rewrite; if ( in_array( $feedname, $wp_rewrite->feeds ) ) { $wp_rewrite->feeds = array_diff( $wp_rewrite->feeds, array( $feedname ) ); } $hook = 'do_feed_' . $feedname; // Remove default function hook remove_all_actions( $hook ); add_action( $hook, $hook ); return $hook; } But I don't know how to use this function. Is there any one who can explain it?
Topic: rss Wordpress
Category: Web

change default RSS feed URL

I need to change the default rss url of my website: from example.com/feed to example.com/MyfeedName Update: what i tried so far is to create another Url feed but i need to remove firstexample.com/feed: add_action( 'init', function() { add_feed( 'secretfeed', 'do_feed_rss2' ); }); add_action( 'pre_get_posts', function( \WP_Query $q ) { if( $q->is_feed( 'secretfeed' ) ) add_filter( 'option_rss_use_excerpt', '__return_false' ); } ); do you have any idea how to just edit example.com/feed or how to delete it without losing rss functions?
Category: Web

Find the shared properties of cluster samples

I have a dataset which contains ~15 features. With the elbow method, I found out that the optimal number of clusters is probably four. Therefore, I applied the K-means algorithm with four clusters. Now, I would like to understand why these clusters have been formed the way they are. In other words, I would like to identify the shared properties of the points of a specific cluster. My idea is the following: Let's pretend that C1 are the coordinates of …
Category: Data Science

Trying to run WordPress on localhost?

I have installed XAMPP server and bitnami WordPress on my Ubuntu machine. I want to run a WordPress on my localhost but the following error occurs: Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. If you think this is a server error, please contact the webmaster. Error 404 localhost Apache/2.4.25 (Unix) OpenSSL/1.0.2j PHP/5.6.30 mod_perl/2.0.8-dev Perl/v5.16.3
Category: Web

About

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