Checking the count within a foreach loop

You can achieve this very easily, just count the array with the terms. Also if I could suggest something more, I’d check for WP_Error a bit earlier, outside the foreach loop, instead of checking every single term, especially that you’re not using the $term_link variable anywhere. Just checking if get_the_terms() returns an array should be … Read more

Why is the ‘Gutenberg’ Plugin generating an ‘Inconsistent File Permissions’ error when other Plugins, with the same permissions, do not?

If you originally installed via FTP/Cpanel/CLI the directory and files may have a different “owner” belonging to “different group” than those installed via WordPress. One possible solution: If you have server access try deactivating Guttenberg and rename its plugin directory to something else. Then reinstall the plugin through WordPress – if this works your Dashboard … Read more

JavaScript in a PHP plugin

So the question and answer you linked to is still valid, the only part that changes is the AJAX part. Specifically, there are now 2 options: Admin AJAX API: A legacy API, most tutorials will use this, but it’s much harder to secure, and provides little to no help. If it isn’t implemented right you … Read more

How to update mu-plugin

First, please check this out: https://codex.wordpress.org/Must_Use_Plugins In most cases mu plugins consist of a singular php file in that directory. In that case you could just replace the file. In any case, there is neither a process for installation nor uninstallation, you simply drop files in that dir or delete them from it. It’s as … Read more

archive_template override when no posts exist

One way to accomplish this may be to use the pre_get_posts to conditionally add the single_template and archive_template filters. namespace StackExchange\WordPress; /** * Add filters for `single_template`, and `archive_template` for the tutorial and * dashboard archives. */ function pre_get_posts( $query ) { if( is_singular() ) { $post_type = get_post_type(); if ( ‘tutorial’ === $post_type || … Read more

populating a form field with output from a custom plugin function

You can pre-populate a field with gform_field_value_$parameter_name hook, where $parameter_name is the name of the field/parameter. So, for example if you added that to your code: add_filter(‘gform_field_value_invoice_numb’, ‘my_func’); function my_func( $value ) { return do_shortcode(‘[ABC_form_number length=”13″ char=”num” case=”false”]’); } (Note: Allow field to be populated dynamically option needs to be enabled)