We are using WP Bakery Page Builder on for a client website. The plugin works fine, but sometimes the settings in Role Manager, for what post types the composer should be on just resets.
We are researching the possibility to hack the settings programmatically to set it to On be default.
Just wanted to check if anyone else have noticed this issue.
This is a bug in older versions. The developers posted a fix for it here:
https://codecanyon.net/item/visual-composer-page-builder-for-wordpress/242431/comments?utf8=%E2%9C%93&term=add_custom_post_type_here&from_buyers_and_authors_only=0
<?php
/*
You can set the post type for which the editor should be
available by adding the following code to functions.php:
*/
add_action( 'vc_before_init', 'Use_wpBakery' );
function Use_wpBakery() {
$vc_list = array('page','capabilities','add_custom_post_type_here');
vc_set_default_editor_post_types($vc_list);
vc_editor_set_post_types($vc_list);
}
Edit: Updated link to dev comment.
Just found this on another thread, which recommended adding this to your theme's custom code:
<script>$vc_list = array( ‘page’, ‘post’ ); vc_editor_set_post_types( $vc_list );
</script>
Related
I developing a custom theme. I have an issue on checkout page. When I click on 'Place order' button the URL of checkout page changing from http://localhost/sitename/checkout to look like http://localhost/sitename/checkout/order-received/390/?key=wc_order_DvIkeeaIUoNFI if payment-method is 'Cash on delivery' or http://localhost/sitename/checkout/order-pay/391/?key=wc_order_2TbWibkoOZcxz&order=391 if I choose Internet acquiring payment-method.
But on that pages displayed content of checkout page. I think that endpoints don't work.
Here is what I did to fix that issue:
Checked endpoints in WooCommerce -> Settings -> Advanced
Created new checkout page and deleted old
Checked Chrome DevTools Console for JS errors
Turned off all plugins except for WooCommerce. Issue still exists.
Checked it on another test-site with Storefront theme. Everything works.
Checked all default Woocommerce hooks in my custom checkout templates. There are available.
Create web.configfile in site's directory with code which provides on https://woocommerce.com/document/woocommerce-endpoints-2-1/
Trying to redirect with this code:
<?php
add_action( 'template_redirect', 'woo_custom_redirect_after_purchase' );
function woo_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && !empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( home_url('/thank-you') );
exit;
}
if ( is_checkout() && !empty( $wp->query_vars['order-pay'] ) ) {
wp_redirect( 'https://secure.wayforpay.com/pay' );
exit;
}
}
?>
As for me it's bad solution. Because if payment-method is 'Cash on delivery' on thank you page it is not possible to get order data, and if method is 'Internet acquiring' I need to get and transfer order data to acquiring system, but I have a plugin which should do it without my participation. And plugin working on another test-site.
This issue is very popular among junior Wordpress-developers, but there is few information about solving this problem.
I think that endpoints works incorrect, but I don't know how to fix it.
I will be very grateful if you share your own experience in solving the problem or tell me what to look for.
Updated
In addition I compared requests and responds in Chrome->DevTools->Network between site with Storefront theme and my site. They are the same, but on my site the redirect is not happening.
I fixed it.
Main issue consist in that my woocommerce doesn't do shortcodes from Console->Pages, so I activated checkout template via page-checkout.php where I get template part form-checkout.php (get_template_part( 'woocommerce/checkout/form-checkout' );).
To fix a bug I replaced this string with echo do_shortcode(['woocommerce_checkout']);.
Very simple solution that I spent almost 3 days searching for, but even better I learned how wordpress works
I have installed the AVADA theme's plugin Fusion Builder. System status is all ok.
but when I'm going to add a new page. It is not showing the 'use fusion builder' option.
I am done with updating the wordpress and all other plugins.
I have also tried making Fusion builder auto activation on. Still its not working.
Make sure Fusion Builder is enabled in Fusion Builder > Settings. Under Post Types, check the box next to the post types (post, page, etc.) with which you want to use Fusion Builder.
It seems that the Gutenberge Block editor may be the resons for your problem. The following code will de-register the block editor to re-solve the issue.
Please add the script to the functions.php : after_setup_theme action hook
add_action( 'after_setup_theme', 'tristup_setup' );
function tristup_setup()
{
add_filter('use_block_editor_for_post', '__return_false', 10);
// disable for post types
add_filter('use_block_editor_for_post_type', '__return_false', 10);
}
hope this will solve your problem.
I have developed a custom wordpress plugin, many users have started using it, but now I have updates available for the plugin and want to display a message to the users who have older versions of the plugin on there site.
How can I modify the code of my plugin so that once I make updates to it, it should trigger a message to the users on the plugin dashboard that there are updates to available to your plugin.
Here is a scenario:
Say a user has version 1.0 of my plugin and the place where I host the plugin has version 1.2, how can I notify the user on his plugins page that my plugin has an updated version??
Although user3042036 answer is great, and very comprehensive, I thought I would entend his / her answer with a open source solution.
This is what you are looking for: WordPress Plugin Update Notifier
First, good practice is to create a constant for your current plugin version, and create an activation and deactivation hook for your plugin. This allows you to check things like version numbers, and do some general initialization.
define ( 'MY_PLUGIN_VERSION', '2.0.0');
register_activation_hook(__FILE__, 'my_plugin_activation'));
register_deactivation_hook(__FILE__, 'my_plugin_deactivation'));
function my_plugin_activation() {
// Initialize some stuff for my_plugin
}
function my_plugin_deactivation() {
// Welp, I've been deactivated - are there some things I should clean up?
}
Here is an example of a typical update function:
function my_plugin_activation() {
$version = get_option( 'my_plugin_version' );
if( version_compare($version, '2.0.0', '<')) {
// Do some special things when we update to 2.0.0.
}
update_option( 'my_plugin_version', MY_PLUGIN_VERSION );
return MY_PLUGIN_VERSION;
}
There is no hook for when your plugin is updated. You, as a plugin
author, have to manually check the plugin version. First, you want to
create a simple function which will tell you if your plugin is up to
date:
function my_plugin_is_current_version(){
$version = get_option( 'my_plugin_version' );
return version_compare($version, MY_PLUGIN_VERSION, '=') ? true : false;
}
Then, test if your plugin is up to date, and call your update function (or in this case we call the same function as we would if the plugin was updated!):
if ( !my_plugin_is_current_version() ) my_plugin_activation();
Testing the update process from one version to the next is not all that complicated, though it is kinda cumbersome. Maybe someone has a better way, if so please tell me!
You can’t really see any errors when you activate a plugin, so the first step is to create a very simple hook to store plugin activation errors. In this case, we store these errors in error_activation.html in the plugin folder
add_action('activated_plugin', 'my_plugin_activation_error');
my_plugin_activation_error() {
file_put_contents( plugin_dir_path(__FILE__) . '/error_activation.html', ob_get_contents());
}
I'm trying to develop my first plugin for wordpress. I noticed that other plugins I have installed on my wordpress have a link to the plugin setting page right from the plguin page list of plugins.
so right under my plugin's name I see:
Deactivate
but for some of my other plugins I also see a
Settings
link that will take the user right to the settings page of that plugin.
How can I tell wordpress I want such a link for my plugin?
I use this hook to add my settings page:
add_action('admin_menu', 'my_plugin_admin_add_page');
thanks
Please add the following code to the plugin file.
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'my_plugin_settings' );
function my_plugin_settings( $settings ) {
$settings[] = 'Settings';
return $settings;
}
I am writing a custom widget for my own WordPress theme.
From WordPress 3.5 there is a new Media Uploader instead of the old ThickBox.
My widget used to work fine on WordPress versions older than 3.5, but now the new media uploader prevent the old working behavior.
I added a check in the costructor for the presence of wp_enqueue_media function:
if( function_exists( 'wp_enqueue_media' ) ) {
wp_enqueue_media();
}
but when this part of cose is executed javascript throw an error in the console stopping Js engine:
Uncaught TypeError: Cannot read property 'id' of undefined load-scripts.php:69
I removed all the widget code and reduced it to bare bones... the error is caused by wp_enqueue_media() calls, but I cannot get my head around why and how to fix it.
I also read Wordpress 3.5 custom media upload for your theme options, but there is no mention to this issue
Can anyone point me in the right direction? Is there any documentation available for the the WordPress 3.5 Media Uploader?
It's too late for you now, but might be helpful for other people. I managed to make it work using
add_action( 'admin_enqueue_scripts', 'wp_enqueue_media' );
Hope it helps!
The problem you are experiencing is because you probably put your custom jquery in the header and you didn't registered wordpress jquery. If multiple jquery are defined you will get that error.
My sugestion is you should either remove your jquery script or remove the one from wordpress
function remove_jquery() {
wp_deregister_script('jquery');
//wp_register_script('jquery', ("//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"), false);
}
if(!is_admin()){add_action('init', 'remove_jquery');}
I suggest you use the jquery wordpress provides you, if not, the proper way to enqueue it is to deregister the default one an register your jquery. Just remove the comments from the remove_jquery function.
Also, the above code should go in functions.php
Cheers.
From codex [1], the function wp_enqueue_media( $args ) should be called from 'admin_equeue_scripts' action hook. or later.
Example:
function enqueue_media() {
if( function_exists( 'wp_enqueue_media' ) ) {
wp_enqueue_media();
}
}
add_action('admin_enqueue_scripts', 'enqueue_media');
Hope it helped.
[1]. https://codex.wordpress.org/Function_Reference/wp_enqueue_media
To debug, you need to get the non-minified versions of the js sent to the browser. See the docs:
SCRIPT_DEBUG
SCRIPT_DEBUG is a related constant that will force WordPress to use the "dev" versions of core CSS and Javascript files rather than the minified versions that are normally loaded. This is useful when you are testing modifications to any built-in .js or .css files. Default is false.
define('SCRIPT_DEBUG', true);