WordPress Notice "Undefined Index" - wordpress

I am getting following notice in WordPress
Notice: Undefined index: _wpnonce in /var/www/vhosts/abc.biz/php/func.php on line 338
Any solution?
Thanks for help

I found the solution, have to use isset() to check _wpnonce value, before comparing it.
if ( isset($_POST['_wpnonce']) && $_POST['_wpnonce'] = '123456789' ) {}
Thanks.

Related

Fatal error within Woocommerce "wc-template-functions.php" file

I have tried to edit wc-template-functions.php in my store and did something wrong.
Now I am getting Fatal Error on 281 line.
Fatal error: Uncaught Error: Class 'Constants' not found in /home/kidsandm/oliverthedog/wp-content/plugins/woocommerce/includes/wc-template-functions.php:282 Stack trace: #0 /home/kidsandm/oliverthedog/wp-includes/class-wp-hook.php(292): wc_generator_tag('<meta name="gen...', 'xhtml') #1 /home/kidsandm/oliverthedog/wp-includes/plugin.php(212): WP_Hook->apply_filters('<meta name="gen...', Array) #2 /home/kidsandm/oliverthedog/wp-includes/general-template.php(4728): apply_filters('get_the_generat...', '<meta name="gen...', 'xhtml') #3 /home/kidsandm/oliverthedog/wp-includes/general-template.php(4650): get_the_generator('xhtml') #4 /home/kidsandm/oliverthedog/wp-includes/general-template.php(4627): the_generator('xhtml') #5 /home/kidsandm/oliverthedog/wp-includes/class-wp-hook.php(292): wp_generator('') #6 /home/kidsandm/oliverthedog/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters(NULL, Array) #7 /home/kidsandm/oliverthedog/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #8 /home/kidsandm/oliverthedog/wp-includes/gen in /home/kidsandm/oliverthedog/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 282
Before that I also had warning at the top that said:
Warning: The use statement with non-compound name 'AutomatticJetpackConstants' has no effect in /home/kidsandm/hondamarine/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 11
but I have hide that line thinking it might help.
What I have change in file?
Additional information.
I was thinking it will change the name of it on front-end as well.
// Additional information tab - shows attributes.
if ( $product && ( $product->has_attributes() || apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ) ) ) {
$tabs['additional_information'] = array(
'title' => __( 'Additional information', 'woocommerce' ),
'priority' => 20,
'callback' => 'woocommerce_product_additional_information_tab',
);
}
Line 1798.
I have tried to find a code only to replace it, and I found one but did not help.
Now, that code might not be original because I could not find it on GitHub.
Thanks a lot!
It just happened to me too, I tried to edit the code for the same reason, I searched a lot about this problem and I solved it when I downloaded the plugin in zip form and manually upload it and install it, now its working fine for me and all data still in place (categories, products, etc.)!
I had the following 2 errors:
Fatal Error: Uncaught error: Class 'Constants' not found in /Users/anastasiades/Local Sites/pisinaspa/app/public/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 282
Error: Class 'Constants' not found in /Users/anastasiades/Local Sites/pisinaspa/app/public/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 282
Steps:
1. Backup data in woocommerce
2. Download plugin here
3. On WordPress go to Plugins >> Add new >> Upload plugin
4. Choose Reinstall >> Install now
5. "Replace current with uploaded"
I recommend a good backup of the products and other data before doing this.
Peace!

How to fix "Warning: A non-numeric value encountered in" WP

On my WordPress page I use the plugin occupancy plan "https://wordpress.org/plugins/occupancyplan/" after the update to PHP 7.3 wordpress gives the following error message:
Warning: A non-numeric value encountered in
/homepages/XX/XXXXXXXXXX/htdocs/XXXXXXXXXX/wp-content/plugins/occupancyplan/occupancy_plan_classes.php
on line 4 - 38 and on line 620, 641, 657
How can I solve the problem?
it's probably a bit late but try adding this validation to every line with that error!
//fix issue with tax when it's not selected it
IF(empty ($ variable name)){
/* null */
}else{
$return = whatever was previously at the line
At the end you must to return something
}
return floatval( $return );
Good Luck!

Compilation failed while installing plugin in wordpress

I could customize wordpress theme http://www.apptha.com/demo/video-stream in localhost well .
But I am tring to upload in server get the following error.
Warning: preg_replace_callback(): Compilation failed: missing opening brace after \o at offset 18 in /home/const/public_html/apptha/wp-content/plugins/contus-video-gallery/hdflvvideoshare.php on line 545
My site is http://constantin-entertainment.info/apptha/
here Wordpress video gallery plugin is used, the error pointed line is
$pageContent = preg_replace_callback( '/\[hdvideo ([^]]*)\o]/i', 'video_shortcodeplace', $pageContent );
Please help me..!
Looks like you need to escape the backslash,
$pageContent = preg_replace_callback( '/\[hdvideo ([^]]*)\\o]/i', 'video_shortcodeplace', $pageContent );
Open \wp-content\plugins\contus-video-gallery\hdflvvideoshare.php file and find add_filter('the_content', 'videogallery_pagereplace'); and replace with the following code.
add_shortcode('videohome','video_homereplace');
add_shortcode('videomore','video_morereplace');
add_shortcode('hdvideo','video_shortcodereplace');
Replace
$pageContent = preg_replace_callback('/\[hdvideo ([^]]*)\o]/i',
'video_shortcodeplace',
$pageContent
);
with
$pageContent = preg_replace_callback('/\[hdvideo\s*.*?=(\d+)\]/i',
'video_shortcodeplace',
$pageContent
);

Wordpress Theme development: Getting Undefined index error

hello I am a wordpress theme developer. i created a theme which works fine in WP_DEBUG=False but gets undefined index error when I set WP_DEBUG=True
My theme has an options page, whenever i click on save i get these errors:
Notice: Undefined index: ang_temp in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Notice: Undefined index: ang_breadcrumbs in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Notice: Undefined index: ang_hide_social in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Notice: Undefined index: ang_hide_tw in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Notice: Undefined index: ang_hide_fb in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Notice: Undefined index: ang_hide_ms in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Notice: Undefined index: ang_hide_rss in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php:147) in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 156
Here is my themes functions.php
I don't know what I am doing wrong. I have very very little knowledge about php. Hope guys with php knowledge or wordpress theme development knowledge can help.
146. foreach ($options as $value) {
147. update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
The bit of code which is producing this error (above) is not checking whether $_REQUEST[ $value['id'] ] exists. The errors you are getting suggest that it doesn't (you will only get this notice with full error checking enabled). Other parts of your code are checking the existence of this variable before using it (so they are OK) and would suggest you should be doing the same here.
You say your theme works OK when debug is off, so this would suggest that you only need to check the existence of this variable before using it. Something like (replacing the 2 lines above):
foreach ($options as $value) {
if (isset($_REQUEST[ $value['id'] ])) {
update_option( $value['id'], $_REQUEST[ $value['id'] ] );
}
}
However, although this should prevent your 'errors' (they are only notices really), I'm unfamiliar with wordpress themes so can't say for sure whether this is expected behaviour or whether there is something underlying which is at fault.

iframe Onload Visibility

I am trying to hide an iframe until it is loaded by I keep getting an error with the following code:
jquery("some stuff">.html("<iframe frameborder='0' vspace='0' hspace='0' marginwidth='0'
allowtransparency='true' scrolling='no' marginheight='0'
style='visibility:hidden;' onload="this.style.visibility='visible';" width='600'
class='frm'></iframe>").appendTo('body');
But it returns an error "syntax error this.style.visibility".
Can anyone help ?
edit:fixed spelling but now get the error
'missing ) after argument list'
You have a typo. Should be
this.style.visibility='visible';
required exit quotes \ and \
onload=\"this.style.visibility='visible';\"

Resources