save_post vs post_updated

OK, so let’s start with Codex: save_post is an action triggered whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email. The data for the post is stored in $_POST, $_GET or the global $post_data, depending on how the post was edited. … Read more

Create table in database when activating plugin

I think you’re missing a comma after product_categoy_url varchar(500) NOT NULL then if still not working, be aware that register_activation_hook( __FILE__, ‘gg_create_table’); will work only if placed in the main plugin file, not in an included file. To execute the activation function from a different file you’ve to define in the main file: define(‘MY_PLUGIN_PATH’,__FILE__); than … Read more

When is is_admin() available?

When is is_admin() available? Pretty much everywhere. The only example I can think of where it wouldn’t be available, is super early in files such as wp-config.php, and some drop-ins. But by the time an mu-plugin, a theme, or a plugin is loaded it’s present. Now, it would work to wrap the inner workings of … Read more

Show Specific Footer Widget for Specific Pages

There are several ways you can achieve this: A. Use CSS to hide and show widgets based on which page you are on. This is fine as a workaround, but it isn’t really solving your problem, especially if you have lots of pages/widgets. B. Call a different widget area in your template file with conditional … Read more

wp_embed_register_handler to embed html files

Fixing the regex pattern To match an url of the type: https://coptic-treasures.com/ {Some string with a mix of a-z letters and hyphen}/{Some number}.html like this example: https://coptic-treasures.com/html-test-filed/02.html you can try this kind of pattern: ‘#https://coptic-treasures.com/([a-z-]+)/([0-9]+)\.html$#i’ and then you have to update the iframe output accordingly: … src=”https://coptic-treasures.com/%1$s/%2$s.html” … with the corresponding matches. Demo Here’s a … Read more

Include a Gutenberg Block in a PHP file

You need to use Custom Post Type for blocks. What it does is you can register your own post template with predefined blocks in it. Which I believe is what you are looking for. Here’s example of that – function myplugin_register_book_post_type() { $args = array( ‘public’ => true, ‘label’ => ‘Books’, ‘show_in_rest’ => true, ‘template’ … Read more