I can't add attributes to products in woocommerce. It shows this error.
select2.js:934 Uncaught Error: Option ‘ajax’ is not allowed for
Select2 when attached to a element.
it is a Conflict with WooCommerce and select2.js.
this error shows beacause woocommerce is updated i think this will solve your problem.
add_action('init', function() { define('SELECT2_NOCONFLICT', true); }, 1);
function my_acf_init()
{
acf_update_setting('select2_version', 4);
}
add_action('acf/init', 'my_acf_init');
Related
I am trying to fire a custom function when a credit card error occurs in the WooCommerce checkout flow.
I seem to be able to get standard woo errors by using but it seems that the stripe plugin does not us woocommerce_add_error
add_filter( 'woocommerce_add_error', 'my_woocommerce_add_error' );
I found the following hook in the WooCommerce Stripe documentation, but I can't seem to get it to work with add_action
wc_gateway_stripe_process_payment_error ($error, $order) – Called when
an error occurs during the process payment event.
add_action( 'wc_gateway_stripe_process_payment_error', 'test_this' );
What am I missing? Is there another filter or hook that I should be using?
As per documentation https://docs.woocommerce.com/document/stripe/ this hook take 2 params $error, $order so you have to tell it to WordPress:
add_action( 'wc_gateway_stripe_process_payment_error', 'test_this', 10, 2 );
function test_this($error, $order) {
// something
}
It's working fine on my side
The only way I could figure out how to do this is by watching for dod inserts on the dom. This is the code I used below.
Note: You should probably use mutated events these days but for some reason, I couldn't figure it out.
$(document).on('DOMNodeInserted', function(e) {
if ( $(e.target).hasClass('woocommerce-error') ) {
console.log('stripe input error');
}
});
How can I remove the "view" action from a wordpress category?
I need a PHP function to add into theme's functions.php; no jQuery please.
The code that prints that is in wp-admin/includes/class-wp-terms-list-table.php
Adding this to your theme's functions.php removes the View link:
add_filter( 'category_row_actions', function($actions,$tag) {
unset($actions['view']);
return $actions;
}, 10, 2);
you should try {$taxonomy}_row_actions action,
https://developer.wordpress.org/reference/hooks/taxonomy_row_actions-2/.
That should let you modify the links for specified taxonomy.
after creating taxonomies for a custom post type, they all show up in QuickEdit. I'm trying to hide them to use the menu for other custom fields but don't know how to do it. Appreciate for any help.
Even better, when registering the taxonomy, you can now pass this to the register_taxonomy function, as shown here:
'show_in_quick_edit' => false
This seems to be working since Wordpress 4.2.
A bit late to the party, but for future reference, you can use a filter for this since Wordpress 4.2.0: quick_edit_show_taxonomy. Much cleaner than the javascript approach :)
add_filter('quick_edit_show_taxonomy', 'listing_remove_taxonomy_from_quick_edit', 10, 3);
function remove_taxonomy_from_quick_edit($show_in_quick_edit, $taxonomy_name, $post_type) {
if ('post_type' === $post_type) {
return false;
}
return $show_in_quick_edit;
}
Hope this will work
Try doing by javascript. (I use jquery).
jQuery(document).ready(function($){'use strict';
if ($('.post-type-custom').length) {
$('.taxonomy-checklist').prev().prev().hide(); // to hide title
$('.taxonomy-checklist').hide(); //to hide box
} });
add this code to a js file (lets say customadmin.js and assume its in the js folder that is in the theme folder) and enqueue the file on admin side:
if(!function_exists('addstyle_to_admin')):
function addstyle_to_admin() {
if(is_admin()){
wp_enqueue_script('myadminpanelscript',get_template_directory_uri() . '/js/customadmin.js',array('jquery'),false,false);
}
}
add_action('admin_enqueue_scripts','addstyle_to_admin');
endif;
I've created a plugin and now want to create a widget containing a form that will submit to the page where my plugin shortcode is embedded from any wordpress page on the front end.
I assume that within my widget code I need to detect the page/post or permalink containing the shortcode and make that the action="" of my form.
Does anyone know how to do this?
I found this code for conditionally loading js/css based on found shortcode but not sure how to adapt to be used in my widget.
add_filter('the_posts', 'conditionally_add_scripts_and_styles'); // the_posts gets triggered before wp_head
function conditionally_add_scripts_and_styles($posts){
if (empty($posts)) return $posts;
$shortcode_found = false; // use this flag to see if styles and scripts need to be enqueued
foreach ($posts as $post) {
if (stripos($post->post_content, '[code]') !== false) {
$shortcode_found = true; // bingo!
break;
}
}
if ($shortcode_found) {
// enqueue here
wp_enqueue_style('my-style', '/style.css');
wp_enqueue_script('my-script', '/script.js');
}
return $posts;
}
Original post found here: http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/
Any help is greatly appreciated.
Thanks, Russ
I'm creating a new wordpress plugin, which only be displayed in posts, but to detect it's a post, I'm trying to use is_single(), but it does not work.
class myplugin{
//my plugin code here
}
function load_plugin($plugin_class, $priority = 10) {
if (class_exists($plugin_class)) {
add_action("init",
create_function('', "global \$$plugin_class; \$$plugin_class = new $plugin_class();"),
$priority);
}
}
if(is_single()){ // witout this, the plugin is displayed everywhere, but whit it it's not displayed at all
load_plugin(myplugin);
}
I even tried to see the output of is_single
echo"<script>alert('".is_single()."');</script>";
i get "undefined"
edit // witout the is_single and just loading my plugin, my plugin works on every page of wordpress.
Conditional tags, like is_single, are not available until the the wp hook has fired. You're trying to use it too early, which is why it returns undefined.
Add your function to a hook after that and do the is_single test there. There is very little overhead in this so don't worry about performance issues.