I'm getting a notice and a warning when I try to delete a post or update something:
Notice: Undefined index: vsw_noncename in /mysite/wp-content/plugins/video-sidebar-widgets/class-postmetavideowidget.php on line 296
Warning: Cannot modify header information - headers already sent by (output started at /mysite/wp-content/plugins/video-sidebar-widgets/class-postmetavideowidget.php:296) in /mysite/wp-includes/pluggable.php on line 881
¿Any hints about this? I have tried to fix the Header Information issue by removing spaces in the file as the codex says but without results, so, probably is another thing.
I'm using wordpress 3.4.2, the plugin version is 5.3 (latest) and a custom theme (checked with Theme-Check and no issues found)
Thank you for your help
The plugin has a bug - it is not checking to make sure that the nonce field exists in the $_POST. Many types of actions that call save_post will not have this field, as it is only added on the post editor (line 154 of the plugin).
You should check to make sure that the nonce field exists before validating it. If it does not exist, just return from the function.
To correct it change line 296-297 to read:
if ( !isset($_POST['vsw_noncename']) || !wp_verify_nonce( $_POST['vsw_noncename'], plugin_basename( __FILE__ ) ) )
return;
Related
I am working with WooCommerce for the first time and I am currently implementing WC filters on the shop page. The filters show up but are not functional, and the console is throwing the following errors:
ERROR 1: woocommerce_shared_settings filter in Blocks is deprecated. See https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/docs/contributors/block-assets.md
ERROR 2: deprecated.min.js?ver=932d8bb37da8bbb396a7a3f754345e08:2 select control in #wordpress/data-controls is deprecated since version 5.7. Please use built-in resolveSelect control in #wordpress/data instead.
The errors disappear when I remove the filters.
I have located the file where the deprecated code exists. I also read the WC docs about how to fix the issue and it presented this code:
use Automattic\WooCommerce\Blocks\Package;
use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry;
Package::container()->get( AssetDataRegistry::class )->add( $key, $value )
It doesn't say where to put this code, though. Where should I put it to solve this issue?
I have the same problem.
Which is the file you located?
Here also says you have to add, on the "client side", this code:
wc.wcSettings.getSetting( 'key' );
We would like to add a custom function of a shortcode in wp_include/functions.php.
This is the function:
function url_id() {
$apiUrl = 'https:exampleurl.api.com/exemple123';
$response = wp_remote_get($apiUrl);
return wp_remote_retrieve_body($response);
}
add_shortcode('session_id', 'url_id');
But we were getting this error:
There has been a critical error on this website.
Learn more about troubleshooting WordPress.
After reading some more troubleshooting documentation we added these two lines in wp-config:
define( 'WP_DEBUG', true );
define( 'WP_CACHE', true );
And after that we are getting this error:
Fatal error: Uncaught Error: Call to undefined function add_shortcode() in /home/c1624672c/public_html/woo/wp-includes/functions.php:18 Stack trace: #0 /home/c1624672c/public_html/woo/wp-settings.php(111): require() #1 /home/c1624672c/public_html/woo/wp-config.php(104): require_once('/home/c1624672c...') #2 /home/c1624672c/public_html/woo/wp-load.php(50): require_once('/home/c1624672c...') #3 /home/c1624672c/public_html/woo/wp-blog-header.php(13): require_once('/home/c1624672c...') #4 /home/c1624672c/public_html/woo/index.php(17): require('/home/c1624672c...') #5 {main} thrown in /home/c1624672c/public_html/woo/wp-includes/functions.php on line 18
There has been a critical error on this website. Learn more about troubleshooting WordPress.
If you want to add custom shortcodes to your website, that can be done via a custom plugin, or in your theme (as I suspect you're trying to do).
Instead of editing wp-includes/functions.php, add your code to wp-content/themes/<name-of-your-theme>/functions.php.
You should never edit the core files of WordPress, which includes all files in /wp-admin and /wp-includes. When you upgrade WordPress in the future, these files will be overwritten, and you'll lose any changes you've made.
The error message occurs because you're attempting to use the add_shortcode() function before WordPress has fully loaded, and defined all available functions.
Please change the shortcode parameter session_id because session_id predefined function in wordpress see the blow or your code
add_shortcode('session_id', 'url_id');
But right code will be work when you change the session_id.
I have been trying to associate CUSTOM data to each of my WP POSTS using the following piece of code :
if($condition === true){
if ( ! update_post_meta ($post_id, '_someData', $someVariable) ) {
add_post_meta($post_id, '_someData', $someVariable);
}
}
However, seems like the META VALUE is RESET to default i.e. Zero OR Blank. Our WordPress website has around 40 plugins, and I think one of these WordPress plugins, is coming in my way of doing things. All of my logic works fine, on a demo WordPres website. Is there a way for me to have total control to set the META Value for a given POST ? Also, is there a way where I can be notified that the META Key is about to change and then I can decide whether OR not to change the Meta Value ?
Any pointers or reference URL's can be of great help. Thanks !
You only need to call update_post_meta in either scenario. Calling add_post_meta() is not necessary and could be causing this problem.
From the codex:
The function update_post_meta() updates the value of an existing meta key (custom field) for the specified post.
This may be used in place of add_post_meta() function. The first thing this function will do is make sure that $meta_key already exists on $post_id. If it does not, add_post_meta($post_id, $meta_key, $meta_value) is called instead and its result is returned.
I am getting the white screen of death with my Wordpress site and I have narrowed it down to a .php file in my Woocommerce includes file. The error is as follows:
PHP Fatal error: Call to a member function get_formatted_name() on a non-object in /home2/hatchchi/public_html/wp-content/plugins/woocommerce/includes/wc-deprecated-functions.php on line 63
Here is what line 63 includes:
function woocommerce_get_formatted_product_name( $product ) {
_deprecated_function( __FUNCTION__, '2.1', 'WC_Product::get_formatted_name()' );
return $product->get_formatted_name();
}
I tried removing the file, the line of code and replacing the Woocommerce plugin manually via FTP but nothing fixed it.
What would be causing this sort of error? What is the solution?
By best to narrow these sort of things down is to try deactivating all other plugins and trying a default WordPress theme to see if that solves your issue.
I got two problems.
Problem 1:
I have translated mailchimp's pot file into two languages. The .mo has been tested to be working.
But WP fails to show the ajax returns for other languages for the mailchimp form and/or widget for mailchimp list subscribe form.
I got around this by modifying the mailchimp.php like following:
$textdomain = 'mailchimp_i18n'; #line 57 to start
if (defined('WPLANG'))
$lang=WPLANG;
$locale = apply_filters( 'plugin_locale', $lang, $textdomain);
How did I figure out?
In place of this $lang variable, default mailchimp.php has get_locale() defined in l10n.php of wp-includes.
When I placed a print_r($locale) before modifying as above. It shows the correct language set at wp-config's WPLANG. But when the mailchimp form is submitted it gets just default en_US!
*Where does it get the en_US, when I haven't set it?*
I found it very weird, line 48-49 of l10n.php for definition of get_locale() contains:
if ( empty( $locale ) )
$locale = 'en_US';
Which, I think gets $locale as empty while in my case was called from the form. Which is very unlikely! But it happens in four instances of my testing.
What my modification at mailchimp.php gets me to?
I can now get the other language (ie Arabic) strings to my mailchimp form responses. But as its detected from WPLANG, I cannot switch to English in site's English mode.
Problem 2:
To switch languages on the fly. I used qtrans_getLanguage() in place of get_locale() in the mailchimp.php's code part. Thus, it becomes:
$locale = apply_filters( 'plugin_locale', qtrans_getLanguage(), $textdomain);
If I print_r($locale) after this line. It shows current language. But not when the form is submitted. The form's response always shows it as (en)!.
Now, problem1 is very unlikely to happen and is unusual. But for problem2 I definitely think there is a smart work around. Why would the qTranslate report wrong while called from the Ajax of that form?
Also, I do not want to modify core plugin files. Currently, I had to modify mailchimp.js to manually match and replace common strings(And I hate it!).
Solved it by following this and this
But as mailchip.js has this 'ajax_url' I searched in the mailchimp plugin where this URL is generated from. Its generated at line number 96 in mailchimp.php
'ajax_url' => trailingslashit(home_url().'/'. qtrans_getLanguage()),
I just added the '/'. qtrans_getLanguage() part.