Replace element within a list of lists with MemberQ condition

I’m trying to replace the second element within a list of ordered pairs depending on whether that ordered pair exists within another set.

shortlist = Flatten[Table[{i, j}, {i, 0, 3}, {j, 1, 2}], 1] sublist = {{0, 2}, {1, 1}, {2, 1}} 

I want to do something like this

shortlist //. x_ /; !MemberQ[sublist, x] -> {x[[1]], 0} 

where the result is


where the ‘x’ components of the list remained the same, but those that were not members of the sublist had their ‘y’ components changed to zero.

How to create templates for a custom module to show on the front end within my theme?

I’d like to create a simple plugin with a form on the front end which submits the value of 3 fields into a DB table.

For the plugin, I’ve been using this answer:

What I can’t get working now, is a template.

Within the main plugin file, I’ve added:

add_action( 'gm_virtual_pages', function( $  controller ) {      // first page     $  controller->addPage( new \WEBP\Management\Page( '/custom/page' ) )         ->setTitle( 'My First Custom Page' )         ->setTemplate( 'custom-page-form.php' ); } ); 

And my custom-page-form.php:

<?php  echo "Test Echo";  ?> <p>Test</p> <p>Echo</p>  

The title is being displayed (My First Custom Page). But not my Test Echo. How does a correct / working template file have to look like?

Cronjob not firing function within class that extends WC_Email

I’m really frustrated right now, because I just can’t seem to figure out what’s wrong here. Maybe it’s something really simple and I’m just stuck somewhere. Please help me out!

I’m working on a small plugin to add a payment reminder to WooCommerce. I added a wp_schedule_event (nd_payment_reminder) to the activation hook. This works so far.

In my main plugin file I’m including my class which looks a little like this:

class ND_Payment_Due extends WC_Email { public function __construct() {         parent::__construct();         add_action('nd_payment_reminder', array($  this, 'getOpenOrders')); }  public function getOpenOrders() {         // getting data and triggering the email } [...] } 

Whatever I try, the function getOpenOrders seems not to be started. I’ve copied this plugin from another website where I originally used it and it still works there – so I’m really confused right now.

I tested it from the functions.php – this works:

add_action('nd_payment_reminder', 'testfunction'); 

I also thought my getOpenOrders()-Function might be faulty, but even when I use another simple function from within my class it’s just not working. 🙁

Any ideas would be highly appreciated! Thanks in advance!

Bootstrap Dropdown Menus not displaying the items within the dropdown in WordPress

I am working on a child theme and have added Bootstrap just before the generic wp_enqueue_style of my theme to the functions.php as it follows:

if ( ! function_exists( 'ghostpool_enqueue_child_styles' ) ) {     function ghostpool_enqueue_child_styles() {          wp_enqueue_script( 'bootstrap_js', '', array('jquery'), NULL, true );                  wp_enqueue_style( 'bootstrap_css', '', false, NULL, 'all' );                  wp_enqueue_style( 'ghostpool-style', get_template_directory_uri() . '/style.css', array(), AARDVARK_THEME_VERSION );         wp_enqueue_style( 'ghostpool-child-style', get_stylesheet_directory_uri() . '/style.css', array( 'ghostpool-style' ), AARDVARK_THEME_VERSION );         wp_style_add_data( 'ghostpool-child-style', 'rtl', 'replace' );     } } add_action( 'wp_enqueue_scripts', 'ghostpool_enqueue_child_styles' ); 

Then I have added raw HTML in a row with 4 columns to each of the columns, as it follows:

<div class="dropdown">   <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">     CHOOSE A GENRE   </button>   <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">     <a class="dropdown-item" href="#">Action</a>     <a class="dropdown-item" href="#">Another action</a>     <a class="dropdown-item" href="#">Something else here</a>   </div> </div> 

My dropdown buttons are displaying correctly, however when I click on them, they don’t display what is inside the dropdown? Am I forgetting to add any special js in the functions.php? Am I missing something?

How to select and delete all Output cells within current Selection only?

A similar question was already here: How to select and delete all Output cells?. But I have a more specific one: I want to delete all output cells within the currently selected cells only.

For this purpose I want to add an additional menu item Cell>Delete All Output within Selection.

Probably one would have to add something to


Has anybody already made such an improvement and could he please post it here?

(The version in this case is 12.1 and it probably has to reflect the version in question. This path is for a Linux machine. On a Windows machine the paths begin at a different root but parts from Wolfram to TextRessources probably will look the same, except for the forward slashes being replaced by backward ones- /X/ might be special for Linux).

Access category within rss2_head hook?

Can I access the current category of a category feed with the rss2_head hook to add for example itunes tags?

Lets say I have I want to get acf field elements associated with this specific category.

Here is what I am trying to accomplish:

function itunes_head() {         $  category = get_the_category();         $  categories = get_category();         global $  post;         var_dump($  categories);         echo print_r($  post);         echo $  categories;         echo $  category; } add_filter( 'rss2_head', 'itunes_head' ); 

I am assuming that I somehow can retrieve the catx category here?

Unity 2D animated tiles library: IsSelected variable not working or not present within RuleTileEditor.cs

I have just tried downloading a library which will allow me to add animated tiles to unity. I have been following this tutorial:

It told me to download this library in order to work the animated tiles:

After this the tutorial told me to unzip the library and place it into my assets folder. It loaded into my assets folder and then got the following error:

Assetsd-extras-masterd-extras-master\Editor\Tiles\RuleTile\RuleTileEditor.cs(277,26): error  CS1061: 'ReorderableList' does not contain a definition for 'IsSelected' and no accessible extension  method 'IsSelected' accepting a first argument of type 'ReorderableList' could be found (are you  missing a using directive or an assembly reference?) 

Does anyone perhaps know why this error is occuring.

How to modify the output of wp_terms_checklist when used within the built-in category metabox on edit posts?

On the Edit Screen in the WP Admin there is a meta box for WP’s built-in Category taxonomy. This meta box is built using post_categories_meta_box() (/wp-admin/includes/meta-boxes.php).

This meta box uses wp_popular_terms_checklist( $ tax_name ) and wp_terms_checklist( $ tax_name ) to output the actual categories (with checkboxes) within the meta box.

wp_terms_checklist() (wp-admin/includes/template.php) uses the Walker_Category_Checklist (/wp-admin/includes/class-walker-category.checklist) to build the categories/checkboxes.

Walker_Category_Checklist inherits from Walker (wp-includes/class-wp-walker.php) just like a number of other WP walkers (Walker_Nav_Menu, Walker_Comment, Walker_Category, etc.).

When extending the Walker_Nav_Menu we can hook into the wp_edit_nav_menu_walker filter and return our custom walker. Is there a way to do this with Walker_Category_Checklist?


Update 1:

I see in wp_terms_checklist() there is:

apply_filters( 'wp_terms_checklist_args', $ args, $ post_id );

I’m thinking that I can hook into this filter, change the walker argument to a custom walker and that this may do the trick?

What is best practice for referencing data rows within stored procedures – via PK, code column or data value?

Suppose you have a table for colours with columns:

  • id = automatically incrementing integer, primary key
  • code = short code reference for the colour, unique
  • colour = human-readable name of colour, unique

Example values might be:

  • 1, BL, Blue
  • 2, GR, Green

Now imagine you have a stored procedure that, at some point, needs to reference this table. Let’s say the business logic says to obtain the colour "Green". To achieve this, you could have any of the following three WHERE clauses:

  • WHERE id = 2
  • WHERE code = GR
  • WHERE colour = Green

Now, if the system is designed such that it is agreed that a code value, once created, never changes, then, in my view, that is the best column to reference because:

  • It is an alternate key
  • It is human-readable for people who maintain the code
  • It will not be impacted when the business decides to change the colour value to ‘Sea Green’

However, if a legacy table lacks such code values, what, in your opinion, is best practice? To reference the id column, or the colour column?

If you reference the id column, the code is not readable unless you then also add comments – you shouldn’t have to comment simple things like this. It sucks figuring out what statements like WHERE id not in (1, 7, 17, 24, 56) mean.

I’m not sure how often, in reality, the id value might change – but consider if you run a script during development to insert new colours but then delete those and insert some more. If your stored procedure references the id values from that last set of colours inserted but when you create your new colours in your next environment you skip the step that inserted the colours which ended up deleted, then the id values won’t match in that next environment. Bad practice, but it can happen – a developer develops their script on a dev instance not thinking that the id values will conflict with production (which, for example, may have had additional colours created manually by the business before your colour creation script runs).

If you reference the colour column, you run the risk that if the business does ask to update the description from ‘Green’ to ‘Sea Green’, that your procedure will begin to fail.

I suppose a further solution is to implement the code column when you need it, if it isn’t there already – probably the best solution?

How do I hide the event description within template of The Events Calenar using Ultimate Member shortcode?

OK, so the goal is to hide the event description with Ultimate Member shortcode [um_loggedin].

I tried doing echo do_shortcode but it’s not working…

This is the code I used within wp-content/themes/hello-elementor/tribe-events/single-event.php:

<?php echo do_shortcode('[um_loggedout]'."Sorry, but only loggedin users are allowed to access the details".'[/um_loggedout]');?>

<?php echo do_shortcode('[um_loggedin]'.the_content().'[/um_loggedin]');?>