How to periodically scrape and cache strings from remote txt files. – My First Plugin

The Transient API may help you here. A transient is variable stored for a defined amount of time. function filemtime_remote( $url ) { $list = file_get_contents( $url , null , null , 0 , 200); $important = explode(“Last modified: “,$list)[1]; $mydate = substr($important, 0, 21); return $mydate; } The above is your current code which … Read more

Accessing data from a non-WP database/table within a page content

<?php $mydb = new wpdb(‘uid’,’passwd’,’database’,’localhost’); $mydb->show_errors(); $query = “SELECT DATE_FORMAT(col1, ‘%d-%b’) AS Pdate, DATE_FORMAT(col1, ‘%Y’) AS Pyear, col2, col3, col4, col5 AS fname FROM table ORDER BY col1 DESC LIMIT 50”; $result = $mydb->get_results($query); echo $mydb->num_rows . ‘ in table ‘; ?>

Creating a Multi-Level Associative Object Using AJAX

If you want to pass a complex value, your best path is probably to jsonify it. Something like $.post( MyAjax.ajaxurl, { action: ‘my_action’, someValue: JSON.stringify({ one: ‘Some Value One’, two: ‘Some Value Two’, three: ‘Some Value Three’, four: ‘Some Value Four’, }) } ); and then on the server side you decode the value with … Read more

RecursiveDirectoryIterator not working in admin

I think the problem is with your relative path. When you visit the /wp-admin/, it will try to locate the wp-content/themes/vac3/acf within and it doesn’t find it there. Try instead the full path with help of __DIR__ or get_template_directory() – more details in this blog post. What if you later remove the acf/ subdirectory? You might … Read more

WooCommerce Custom Product to checkout

You need first to buy WooCommerce Quick View plugin, because woocommerce lightbox plugin doesn’t work without it. Please read this: Woocommerce single product show in modal…? And if you go to the wordpress page of woocommerce lightbox plugin, you will see that is a complementary plugin.

Create a hierarchical taxonomy list in WordPress

You can use wp_list_categories() and pass in your custom taxonomy as an argument like so: $args = array( ‘taxonomy’ => ‘locations’, ‘orderby’ => ‘name’, ‘hide_empty’ => false, ‘show_count’ => false, ‘pad_counts’ => false, ‘hierarchical’ => true, ‘title_li’ => ” ); ?> <ul> <?php wp_list_categories( $args ); ?> </ul> https://developer.wordpress.org/reference/functions/wp_list_categories/