tagging – Inconsistent behavior when adding new hierarchical tags in Digikam

Whenever I create a new hierarchical tag in Digikam (right-mouse click on image -> Assign Tag -> Add New Tag) then all hierarchy levels are applied to the image. For instance, if I have the hierarchy Tag 1 / Tag 2 and add a new tag Tag 1 / Tag 2 / Tag 3 to an image, then all tags Tag 1 / Tag 2 / Tag 3 are applied to the image.

In contrast, when I add an existing hierarchical tag to an image, then only the bottom level is applied. Picking the example from above up, when I add Tag 3 to an existing image, then only Tag 3 is applied but not Tag 1 / Tag 2.

I find this a bit inconsistent, as I now have some images with the full hierarchy and some with the bottom level only.

Is there some way to standardize the behavior of Digikam?

c++ – using-declaration or typedef for iterator tags?

In C++, using and typedef are mostly equivalent and both declare a type alias. But they have reverse order of arguments:

typedef original new_name;
using new_name = original;

The typedef can get very difficult to read for more complex types. For example, the meaning of typedef unsigned uint might not be immediately apparent. C’s notation for function pointers is famously inscrutable: typedef void (*FuncType)(int a, int b). This syntactic mess also means you can’t use a typedef template. Unfortunately, typedef also has very subtle interactions with linkage (which I don’t understand and thus can’t explain here, sorry).

The type alias with using is generally easier to read and is just a type alias, without other subtle effects. It composes well with templates. It was introduced as part of the big language modernization in C++11. Modern C++ greatly prefers this form, see also T.43 in the C++ Core Guidelines. The using keyword is also used for other constructs that bring something into scope, e.g. namespace aliases or using-declarations for unqualified lookup (argument-dependent lookup).

The syntax used for declaring type aliases does not interact or interfere with member functions.

So you can continue to use typedef without any ill effects. However, the C++ community would thank you if you don’t use that C-ism and use the more easier to read using keyword.

plugin development – Conditional query tags do not work before the query is run. Before then, they always return false

I’m coding a plugin. When it’s loaded I check is_single() which returns the following error:

_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );

Where can I find the WP initializing process documentation?

How can I solve this issue?

schema – How to design database for monitoring the time trends of article tags?

My purpose is to monitor which tags increase/decrease rapidly last week on different bulletin boards. Or which tag do new appear. The current table schema of articles is as follows:

article_id e.g. 123
tags e.g. apple,orange
article_created_at e.g. 2021/5/7 01:23
borad_name e.g. database
author e.g. some_person

My current idea is to calculate the amount of each tag by board weekly. But I want to survey other solutions to reduce the development time. Is it ok to choose a time-series database engine or other possible solution? Thanks for your time.

workflow – Using Google Location History to add GPS tags to Lightroom photos?

I import photos through Lightroom, and I’d like to tag them with GPS coordinates, can someone suggest a good workflow for this?

Years ago, I used to get GPS tracks from my Google Location History, then run a tool to automatically apply tags to these photos, but those scripts are likely obsolete.

ruby – When copying between documents nokogiri strips attribute namespace if it differs from tag’s

I try to copy a node from one document to another. If attribute namespace differs from the tag’s, it is stripped in the final document, so I need to restore the namespace.

Since this functionality is essential for me, I made a test, that ensures Nokogiri works exactly this way.

But probably I’m doing something wrong?

require 'nokogiri'

class TestNokogiriCornerCase
  describe "Nokogiri" do
    before do
      @xml_text_src = <<-TESTXML
        <p1:a xmlns:p1="ns1" xmlns:p2="ns2">
          <p1:b p2:c="d">
        </p1:a>
        TESTXML
      @xml_text_dest = <<-TESTXML
        <p1:a xmlns:p1="ns1" xmlns:p2="ns2">
        </p1:a>
        TESTXML
      @xml_doc_src = Nokogiri::XML @xml_text_src
      @xml_doc_dest = Nokogiri::XML @xml_text_dest
    end
    it "should not (probably) but loses attribute namespace" do
      ns = {'p1': "ns1", 'p2': "ns2"}
      node_dest = @xml_doc_dest.xpath("//p1:a", ns)(0)
      node_to_insert = @xml_doc_src.xpath("//p1:b", ns)(0)
      node_dest.add_child node_to_insert
      assert_equal @xml_doc_dest.xpath("/p1:a/p1:b", 
                                       ns)(0).attribute('c').to_s,
        "d", "check attribute with stripped ns"
      assert_nil @xml_doc_dest.xpath("/p1:a/p1:b", 
                                       ns)(0).attribute_with_ns('c', 'ns2'),
        "check attribute with ns"
      node_dest.xpath("//*/@c").each do |node|
        node.parent("p2:c") = node.to_s
        node.remove
      end
      assert_equal @xml_doc_dest.xpath("/p1:a/p1:b", 
                                       ns)(0).attribute_with_ns('c', 'ns2').to_s, 
        "d", "check namespace restored"
    end
  end
end

theme customizer – How to remove html tags from output with json_encode in WordPress? I want to show only plain text

I’ve been on trial and error for a few days, researching a lot, but I can’t solve this problem.

objective: this function generates schema output for data structured in JSON.

the problem: the texts are being delivered with html <p> tags, n etc, and I think that Google is not integrating my structured FAQ data because of this.

Output example:

"@type": "Question",
                    "name": "<p>What are the best destinations for my trip?</p>n",

the solution: I need to remove the <p> and </p> tags and show only plain text.

I tried using strip_tags and it worked partially:
"name": "'.strip_tags(apply_filters('the_content', $faq('question'))).'",

partially because I was able to remove the tags with this “solution”, but in contrast the JSON became invalid because added blank space and line breaks. Validation error message from JSONLint:
Expecting ‘STRING’, ‘NUMBER’, ‘NULL’, ‘TRUE’, ‘FALSE’, ‘{‘, ‘(‘, got ‘undefined’

this is the complete function code:

     public function render_schema()
{
  $faqs = $this->render_faqs();
  
    if (!$faqs)
    {
        return;
    }
    $schema = '
    <script type="application/ld+json">
    {
        "@context": "https://schema.org",
        "@type": "FAQPage",
        "mainEntity": (';

    $comma = '';

    foreach ($faqs as $faq)
      
    {
        $schema .= ' 
                ' . $comma . ' {
                    "@type": "Question",
                    "name": '.json_encode(apply_filters('the_content', $faq('question'))).',
                    
                    "acceptedAnswer": {
                        "@type": "Answer",
                        "text": ' . json_encode(apply_filters('the_content', $faq('reply'))) . '
                    }
                }
                ';

        $comma = ',';

    }
    $schema .= '
        )
    }
    </script>';

    return $schema;
}