Remove 0 count tags with SQL.


 

SQL that can be used to delete WordPress terms by count:


Don't forget to backup before making changes.

Blogspot import limits



I haven't spent a lot of time engaged in the nuances of Google BlogSpot usage, I have however, stumbled onto measures put in place to limit the number of imports one can perform in a day, an unfortunate lesson to learn at this time, luckily the blog affected is not mission critical.

The plan was to export posts, perform a mass find/replace then import changes, but that did not work out as planned which led to a content purge, followed by the import no longer working as expected. Warnings would have been helpful, but that may be a bit too much to ask since each attempt after would claim itself a success but fail to produce the goods. 

My final attempt did return a response which brought me  here: 

https://support.google.com/blogger/thread/34774222/sorry-but-you-have-exceeded-the-maximum-number-of-imports-please-try-again-later?hl=en&msgid=34817302

Lesson learned so far: BlogSpot import is super duper finicky 😕


AH00534: apache2: Configuration error: No MPM loaded



Not too long ago a number of changes were applied to a local Apache2 server to fix a problem with HTTP2 support. All seem well until a recent reboot which resulted in the Apache2 failure.

The TL/DR solution was to simply disable then enable the PHP modules in use. In this scenario it is PHP7.4

sudo a2dismod php7.4

sudo a2enmod php7.4

sudo systemctl restart apache2

 

You can read more about the solution here:

https://www.linuxquestions.org/questions/linux-newbie-8/apache2-ah00111-config-variable-%24%7Bapache_run_dir%7D-is-not-defined-4175635791/

 

 

WORDPRESS: Custom query to RSS feed.


Had a need to create RSS feeds for several lists. Seemed a simple enough task at the time. All that was left to do was structure some kind of request thingy and move on to the next task.

Initially I thought I could get away with some variation of the following example:

https://domain.com/?s=&post__in=["12345","123"]&feed=rss2 // does not work

As it turns out, extended search parameters, such as post__in, tag__in, etc. do not behave as expected in a query string.

"Well duh." I thought, then turned to the internet for ideas. "Yo homie, you got some sauce for me?"

The internet responded immediately, and after sifting through all the "use this" and "use that" plugin suggestions, I found something I could work with and probed deeper.

"A custom rss feed will need to be registered," said a number of the candidates probed. "This new feed will reference a method that handles business, which includes overriding the WP_Query object then passing the results to a template."

A custom template was also suggested. But, I did not want to do that, and settled on the recipe that extended existing assets. A variation of the solution was finally embedded into the plugin. Should work in a custom theme as well.

Below a crude feed registration and handler example:

public function create_feed()
{
        global $wp_rewrite;
        $name = 'custom-rss';
        if ( ! in_array( $name, $wp_rewrite->feeds ) ) {
            $wp_rewrite->feeds[] = $name;
            flush_rewrite_rules( FALSE );
        }
        add_feed( $name, function(){$this->render_feed();} );
}
add_action( 'init', array( $this, 'create_feed'));

public function render_feed()
{
        global $wp_query;
        $id = $_REQUEST["id"];
        $args = array_merge(
                $wp_query->query,
                array('post__in' => $id)
        );
        query_posts($args);
        include('wp-includes/feed-rss2.php');
}

Link example:

https://domain.com/feed/playlist/?id%5B%5D=3296&id%5B%5D=3096&id%5B%5D=2853&id%5B%5D=747

Create and append to content with a bit of jQuery (What? I like jQuery):

let param = { id: ["3296","3096","2853","747"]};

jQuery("<div />",{ class: "text-center" })
.append(
jQuery("<a />", {
"href": glob_obj.site_url + "/feed/playlist/?" + jQuery.param(param) ,
"title": elem.title + " rss feed",
"target": "_blank"
})
.append(
jQuery("<img />", {
"src": glob_obj.site_url + "/wp-includes/images/rss-2x.png",
"vspace":"12"
})           
)
)
.appendTo( jQuery('#' + elem.id) );

Feed solution adopted from here:
https://raphaelhertzog.com/2011/01/07/howto-create-custom-rss-feeds-with-wordpress/

WORDPRESS: Get your plugin version number 'n things



A quick and dirty "get plugin version number" example, borrowed from these guys: https://wordpress.stackexchange.com/questions/18268/i-want-to-get-a-plugin-version-number-dynamically

A method like this will always be available. Unlike the admin only get_plugin_data() (https://codex.wordpress.org/Function_Reference/get_plugin_data)

function get_fi_mi_plugin_version(){
if(preg_match('/version:[\s\t]+?([0-9.]+)/i',file_get_contents( __FILE__ ), $v)){
return $v[1];
}
return "";
}

Naturally, your regex '/version:[\s\t]+?([0-9.]+)/i' may vary. Depends on how your header comments are laid out. I typically do this:

/*
Plugin Name: WP Plugin
Plugin URI: somewhere.com
Description: Something something plugin header
Version: 6.6.6
Author: some idiot
Author URI: somewhere.com
License: Creative Commons 'n things
*/




goBloggerCrawler Blogger Web Crawler in Go

Go-based web crawler used to efficiently extract structured data (titles, video URLs, and tags) from Google Blogger sites using concurrent p...