php – Nested “do” and “add” Actions is possible?

I’m wondering

Questions were asked about more than one “add_action” and filter nested before and it was deemed possible.

Are nested cross actions added?

Eg.

add_action('init', function(){
   do_action('initialized');
});
function initialized(){
   // ...
}

Second question

Will a vicious circle occur like the following?

function initialized(){
   do_action('init');
}

java – How can I refactoring this nested try-with-resources?

Here’s the code I am trying to refactor. The same Http client is being used in each nested try with resource. I don’t understand the rationale behind nesting client.execute() calls.

The code tries to Post data to an endpoint if resource is missing and retries to Post to a backup endpoint if earlier call fails

public void makeSeveralApiCalls() throws Exception {
  try (final CloseableHttpClient client = HttpClients.createDefault()) {
    try (final CloseableHttpResponse response = client.execute(httpGetUri())){
      if (response.getStatusLine().getStatusCode() == 404) {
        // Resource not found, Post data to Microservice A
        try (final CloseableHttpResponse nestedResponse = client.execute(httpPostToMicroserviceA())) {
          if (resp.getStatusLine().getStatusCode() == 201) {
            LOGGER.info("Success");
          } else {
            // Microservice A could not consume data, log error response
            final String responseString = EntityUtils.toString(resp.getEntity());
            LOGGER.debug("Error response: " + responseString);
            // Try to Post to Microservice B
            try (final CloseableHttpResponse subResponse = client.execute(httpPostToMicroserviceB())) {
              if (resp.getStatusLine().getStatusCode() == 201) {
                LOGGER.info("Success");
              } else {
                // Is this exception propagated to the caller?
                throw new RuntimeException("Very bad unrecoverable state");
              }
          }
       }
    }
  }
}

Is this a valid way to call multiple executes on the same http client in a nested fashion. Is it better to separate out each client.execute() call?

postgresql – How can I model products with many-to-many ingredients and nested products?

I currently have three tables: product, ingredient, and product_ingredient (m2m relationship).

Product Ingredient relationship diagram

A product has many ingredients and nested products through product_ingredient. The nested products themselves have many ingredients and nested products.

How can I efficiently model these relationships so that a single query can select a product’s ingredients through all nested relationships?

  • The entities are read more frequently than written, so read optimized would be preferred.
  • The actual structure has foreign keys on the ingredient table which are aggregated in different ways.
  • The product ingredients should be ordered by their position int, with respect to its product_id.

magento2.3 – Nested attributes – Magento Stack Exchange

We are selling school uniforms and have about 40k of products. Our Magento 2 “categories” are basically schools we work with. We want to make a use of “layered navigation”, but facing a problem, which I describe below. The problem is quite advanced, so I will simplify it for demonstration purposes.

We want to assign some attributes to all our items and then use them for “layered navigation” filtering.

Let’s say we create a “type” attribute with multiple select values. The values would be:

“Type 1”
“Type 2”
“Type 3”
“Type 4”

Now, take an item and call it “Item A” for instance. It has a different significance for different schools, which forces us to assign different “type” values for "Item A" in different schools (categories). For example in:

“School Q” its “type” is “Type 1”.
“School X” its “type” is “Type 2” and “Type 3”.
“School Y” its “type” is “Type 1” and “Type 3”.
“School Z” its “type” is “Type 2” and “Type 4”.

Now, as you probably expect, if a customer filters by “type” and chooses “Type 1”, I want the “Item A” to be listed if the customer is in “School Q” category (page) or in “School Y” category (page).

It appears that this is not easily achievable with our current knowledge of Magento 2, so we had a little brainstorming session, but the results aren’t impressive. We figured out that since we work nearly 100 schools, we would end up with either ridiculous number of attributes per item or tens of thousands of duplicated products.

So, the question is whether there is any way of automatic filtering. Something like having this attribute called “school_type” with multiple select values of:

-   School Q: Type 1
-   School Q: Type 2
-   School Q: Type 3
-   School Q: Type 4
-   School X: Type 1
-   School X: Type 2
-   School X: Type 3
-   School X: Type 4
-   School Y: Type 1
-   School Y: Type 2
-   School Y: Type 3
-   School Y: Type 4
-   School Z: Type 1
-   School Z: Type 2
-   School Z: Type 3
-   School Z: Type 4

Then, in our instance, the “Item A” would have this attribute set to:

“School Q: Type 1”
“School X: Type 2”
“School X: Type 3”
“School Y: Type 1”
“School Y: Type 3”
“School Z: Type 2”
“School Z: Type 4”

Finally, there would be some sort of automatic filtering in place (perhaps on category level) that displayed “Item A” in the specified “types” only for the relevant schools (categories).

Please let me know if you are aware of anything that would serve the purpose in our case.

html – Why doesn’t the Gutenberg code editor allow code to be nested in sections?

I’m trying to add my own HTML code in the Gutenberg code editor, but unfortunately when trying to save the editor automatically moves the closing tag </section> to the end of the first line. What is this about ? Why can’t I nest my code this way normally ?
To illustrate the problem I attach a picture.

enter image description here

I would like the section closing tag to be at the end of all code.

Python nested import – Stack Overflow

I can’t get my mind around this problem

Let’s suppose we have a file structure

Folder
├── main_file.py
├── Subfolder
│   ├── __init__.py
│   ├── file_a.py # def foo()
│   ├── file_b.py # from file_a import foo; def bar(...use function foo())

How can I use function bar in my main_file.py without nothing going wrong, because if I only import function bar from file_b it throws me error: ‘there’s no module named file_a’

Thank you for answer

Find “np-redirect post_type parent” from real post? Breadcrumb generation on nested pages

I am trying to make a custom breadcrumb for my nested pages wordpress setup.
For that i add manually every post as a link in nested pages menu, later to be able paint all hierarchy o my custom breadcrump.

When the user go to the post, i do:

$args = array(
    'name'        => $post->post_name,
    'post_type'   => 'np-redirect',
    'post_status' => 'publish',
    'numberposts' => 1
);

$posts = get_posts($args);

To find the redirect wich is related to nested pages and works good with most part of posts wich don’t use special chars:

My test post (my-test-post)

But, when i use some special character on title, it is doing “esc_url” instead of using standard slug function that WP uses for posts:

▷ My test post (%e2%96%b7-my-test-post)

At the end i get two different slugs and i can’t make a relationship between them.

Is there any way to override “NestedPagesFormListenersNewMenuItem” from my plugin? Any other hint?

Many thanks!

query performance – Get nested procedure and sql execution oracle

In my Oracle 11g environment, I got performance issue with a procedure named : myProc().
In myProc() it’s called to others proc named myChildProcA(), myChildProcB(),myChildProcC()……( ~10 child procedures)

In Postgresql, I have some userful tool like pg_stat_user_functions, pg_stat_statements, auto_explain…
it’s provide detail information about child function excutions.
But I don’t known much about Oracle.
I tried with v$sql, sql_trace and tkprof to get statistic information but it’s not provide child procedure information.

My question :
Are there any way or tool to get elapsed executions time for child procedures in Oracle?

Conditionally open nested, product sub category menus based on is_product_category( ) – Woocommerce

I have a complex product category menu in my woo shop sidebar with lots of sub menus. When the current category is one of the parent menu items, the menu item changes style. But when the current category is one of the nested, sub categories, the menu is closed, hiding the active menu item.

How can I force the menu to open to the current sub category and inherit the active menu item styles?

javascript – How to get biggest category_id from this nested object array?

I am a begineer in reactjs. I have a doubts in loop the nested object array for finding biggest category_Id from this array. I tried but I didn’t get the result
here we can get the result from last index array but I don’t how to get the result

0:
categories: Array(19)
0: {category_id: "2", name: "Cold Mezes", parent_id: "1", status: "1", products: Array(11), …}
1: {category_id: "3", name: "Hot Mezes", parent_id: "1", status: "1", products: Array(14), …}
2: {category_id: "5", name: "Wraps", parent_id: "1", status: "1", products: Array(4), …}
3: {category_id: "8", name: "Vegetarian Dishes", parent_id: "1", status: "1", products: Array(6), …}
4: {category_id: "9", name: "Authentic Dishes", parent_id: "1", status: "1", products: Array(5), …}
5: {category_id: "10", name: "Casseroles", parent_id: "1", status: "1", products: Array(3), …}
6: {category_id: "11", name: "Sharing Platter", parent_id: "1", status: "1", products: Array(2), …}
7: {category_id: "12", name: "Salads", parent_id: "1", status: "1", products: Array(4), …}
8: {category_id: "13", name: "Kids Menu", parent_id: "1", status: "1", products: Array(6), …}
9: {category_id: "14", name: "Side Dishes", parent_id: "1", status: "1", products: Array(5), …}
10: {category_id: "16", name: "Desserts", parent_id: "1", status: "1", products: Array(19), …}
11: {category_id: "6", name: "Yougurtlu Dishes", parent_id: "1", status: "1", products: Array(3), …}
12: {category_id: "7", name: "Fish Dishes", parent_id: "1", status: "1", products: Array(6), …}
13: {category_id: "4", name: "Main Course", parent_id: "1", status: "1", products: Array(17), …}
14: {category_id: "17", name: "Pasta", parent_id: "1", status: "1", products: Array(4), …}
15: {category_id: "18", name: "Turkish Breakfast", parent_id: "1", status: "1", products: Array(5), …}
16:
   categories: Array(11)
     0: {category_id: "20", name: "Cocktails", parent_id: "19", status: "1", products: Array(12), …}
     1: {category_id: "21", name: "Mocktails", parent_id: "19", status: "1", products: Array(5), …}
     2: {category_id: "22", name: "Beers", parent_id: "19", status: "1", products: Array(11), …}
     3: {category_id: "23", name: "Hot Drinks", parent_id: "19", status: "1", products: Array(13), …}
     4: {category_id: "24", name: "Soft Drinks", parent_id: "19", status: "1", products: Array(22), …}
     5: {category_id: "25", name: "White Wines", parent_id: "19", status: "1", products: Array(14), …}
     6: {category_id: "26", name: "Red Wines", parent_id: "19", status: "1", products: Array(13), …}
     7:
       categories: Array(7)
        0:
          categories: ()
          category_id: "30"
          name: "Gin"
          parent_id: "27"
          products: (5) ({…}, {…}, {…}, {…}, {…})
          status: "1"
          __proto__: Object
        1: {category_id: "31", name: "Rum", parent_id: "27", status: "1", products: Array(4), …}
        2: {category_id: "32", name: "Whisky", parent_id: "27", status: "1", products: Array(4), …}
        3: {category_id: "33", name: "Brandy", parent_id: "27", status: "1", products: Array(3), …}
        4: {category_id: "34", name: "Tequila", parent_id: "27", status: "1", products: Array(2), …}
        5: {category_id: "35", name: "Vodka", parent_id: "27", status: "1", products: Array(3), …}
        6: {category_id: "36", name: "Liqueurs", parent_id: "27", status: "1", products: Array(11), …}
           length: 7
        __proto__: Array(0)
       category_id: "27"
       name: "Spirits"
       parent_id: "19"
       products: ()
       status: "1"
       __proto__: Object
   8: {category_id: "28", name: "Rose Wines", parent_id: "19", status: "1", products: Array(4), …}       
      length: 9
      __proto__: Array(0)
      category_id: "19"
      name: "Drinks"
      parent_id: "1"
      products: ({…})
      status: "1"
      __proto__: Object