Why is my custom post type not being activated on plug-in activation?

That’s not how register_activation_hook works. register_activation_hook is called only once, when the plugin is activated. CPT’s however need to be registered on every single request, not just when the plugin is activated. This is because WP doesn’t store a list of CPT’s in the database, it’s generated at runtime by PHP code. So instead, register … Read more

Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?

You could consider using the good ol’ get_template_part( string $slug, string $name = null, array $args = array() function, which is a native WP function. Especially now as it supports the third parameter for passing data to the template file (since WP 5.5). Create a function (in your (child) theme functions.php file) that wraps around … Read more

Error – ‘create_function is deprecated’ [closed]

You no longer need to use create_function you can instead just use an anonymous function: add_action( ‘gform_preview_footer’, create_function( ”, ‘GFFormDisplay::footer_init_scripts(‘ . $form[‘id’] . ‘);’ ) ); Should be: add_action( ‘gform_preview_footer’, function() use ($form){ GFFormDisplay::footer_init_scripts($form[‘id’]); }); https://www.php.net/manual/en/functions.anonymous.php

Update a buggy installation

You have two tasks to solve here: 1. Resolve the time-out problem. 2. Update WordPress. Resolve the time-out problem These things don’t just happen because your WP is old. There must be a concrete reason. The three most common reasons are: Not enough memory. Maybe your hosting provider has limited the memory? Try adding the … Read more

wp_force_remove_style’ not found

You have an action, but not the valid callback for your action. For example, You have somewhere following line: add_action( ‘some_action’, ‘wp_force_remove_style’ ); But not have “wp_force_remove_style” function defined. You have to have a function as following: function wp_force_remove_style() { // Do you stuff. }

displaying content that includes shortcodes within an echo

If some of your comments will contain shortcodes and some won’t, there’s no harm in running them all through do_shortcode(). If the content has no shortcodes in it, it will simply be returned, and if it does contain shortcodes, they’ll be parsed and the content returned. So you should be able to change echo ‘<span>’.$comment_content.'<br>’; … Read more

Replace Woocommerce “add to cart” to be “Download” button [closed]

hook into the woocommerce hook is_purchasable add_filter(“woocommerce_is_purchasable”, function($product, $isPurchasable) { if(!$isPurchasable) return $isPurchasable; $productId = $product->get_id(); $user = wp_get_current_user(); if($user->exists() && $productId == 769) { $userId = $user->ID; $userEmail = $user->user_email; if(wc_customer_bought_product($userEmail, $userId, $productId)) { //block the purchase so the user sees read more instead of add to cart $isPurchasable = false; } } return … Read more

Deprecated: Function create_function() is deprecated [closed]

Your server runs with a PHP version that doesn’t support create_function. From the PHP manual about create function Warning This function has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0. Relying on this function is highly discouraged. If you are using PHP 5.3.0 or newer a native anonymous function should be … Read more