6

The root of your problem is not object oriented programming, but a fundamental misunderstanding about how PHP handles requests. If this were a Java or a Node application for example, you would start the application on the server, and it would recieve requests, and respond. It's a continuous active program. As a result, you can store things in memory and ...


3

I'm posting this answer because the accepted answer is slightly misleading, as it implies that you cannot use the trademarked name at all. While not 100% wrong, it's also not 100% right. It is correct that unless you are WooCommerce, you can't call your plugin "WooCommerce Cool Add-on". But you can call it "Cool Add-on for WooCommerce." See "Why can’t I ...


2

From the Plugin Developer FAQ For example, if you submit “WooCommerce Tango Salsa Add-on” that would make your slug woocommerce-tango-salsa-add-on by default. If you don’t work for WooCommerce, we would just change that to woo-tango-salsa-add-on for you. It appears that the policy is, if you don't work for WooCommerce, you aren't supposed to use "...


2

Well, as you can see in the contributed example to the WordPress Reference, it is not that add_settings_field magically knows about a setting being true or false, and it is not limited to checkboxes (boolean flags): Instead, the function signature states clearly that the $callback parameter it is required. And the introduction says: The $callback ...


2

In my opinion, a best practice would be to clean everything on uninstallation. It's also mentioned as a best practice in the docs: When your plugin is uninstalled, you’ll want to clear out any plugin options and/or settings specific to to the plugin, and/or other database entities such as tables. However, if you're struggling to decide what's best for ...


2

This just means they moved the component. Replace this part: const { PanelBody, SelectControl, ServerSideRender, TextControl, ToggleControl, } = wp.components; with const { serverSideRender } = wp; const { PanelBody, SelectControl, TextControl, ToggleControl, } = wp.components; Unless they've changed anything else about the component, the ...


2

Checking the action hooks API reference, "activated_plugin" is an Advanced hook. It operates outside the normal loop which would permit you to do what you want. A better way would be to add_action('admin_footer_text'), as illustrated in this WPBeginner article. However, if you only want this to show when a particular plugin is activated, you can add the ...


2

Thanks to a colleague at codeable I was able to solve this by saving the product after setting the sale price: $editedProduct->save(); Simple as that. If only I'd known that 6 hours ago!


1

The component is still functional, the issue is due to how it was pulled out into its own package. It is no longer uppercase and in order to use it in JSX, you will need to alias it: const { serverSideRender: ServerSideRender } = wp; See this issue for more details.


1

I did some research on the subject. The answer is that there is no consistent policy from Automattic on this. I have been personally threatened by Automattic for using "WordPress", but not "WooCommerce". Specifically, they are not defending "WooCommerce" on their own controlled marketplace: https://wordpress.org/plugins/jilt-for-woocommerce/ https://...


1

It's not the right way to delete tables from the database when you deactivate the plugin because there are many reasons that users can deactivate the plugin, but you can use an alternate way register_uninstall_hook for more information you may check the documentation for removing tables from database. Hope this may help to you!


1

From your comment: Those htaccess changes don't happen as a result of an add_action. Perhaps they should? Yes, they should. And here's why insert_with_markers() calls switch_to_locale() which uses $GLOBALS['wp_locale_switcher'] (or $wp_locale_switcher) which is initialized in wp-settings.php, but only after WordPress runs the setup_theme hook. And ...


1

So, I want to find some solution where I can set only the composer.json file inside the plugin folder and after the plugin activation to pull and install the required SDK. That's not how it works. Composer is a CLI tool that's meant to be ran via CLI, and wasn't designed to run in a browser request context. If you achieve it, most PHP developers will ...


1

So I found the answer to the question. Using parse_str($_POST['form_data'], $form_data); in my function allows me to call all the field values as $name = $form_data["wpcf-lead-name"]; Now my new function looks like this. function mail_and_cookie_function() { check_ajax_referer( 'aj-demo-nonce', 'nonce' ); parse_str($_POST['form_data'], $...


1

You should rename your function to set_lead_cookie_and_mail and change it in the add_action() as well. It looks like your action set_lead_cookie_and_mail in your ajax call is never reached, does it even exist?


1

I find a solution. Just need use filter hook 'site_transient_update_plugins' So that work add_filter( 'site_transient_update_plugins', array( &$this, 'check_for_update' ) ); add_filter( 'plugins_api', array( &$this, 'plugin_api_call' ), 10, 3 );


1

The idea of template_include is to intercept the normal template procedure and replace the template with another one based on some conditions. What you are doing now is to redirect to another url which would, through the normal template procedure, produce the template you want. You can get your desired outcome by simply let template_include do what it is ...


1

This was a bit tricky to solve your problem. the template_include filter executed after the main query processed the current request. If you can filter the current request (query_vars) and update it accordingly then WordPress will display any post/page you wanted to... Simply filter the query_vars with the request filter. Check the following snippet. But ...


1

Advanced Custom Fields (ACF) is a way to go. The plugin offers plenty of fields, conditions, and the documentation is top-notch. For your specific needs you might want to use the Tab field with left aligned positioning, and limit the display of this field to your custom post type. It is ridiculously easy.


1

Yes, there is a function in WP for that: wp_check_post_lock() Give it the post ID and it will return the user ID that is currently editing the post OR false if no one is editing the post (i.e. it is not locked). $is_locked = wp_check_post_lock( $post_id ); if ( false === $is_locked ) { // Post $post_id is not not locked for editing } else { //...


Only top voted, non community-wiki answers of a minimum length are eligible