Not Sure Which Fiels To Edit to Clean Up Validation Errors
-
i’m building my first wordpress site: https://www.goldcoastchamber.com/wordpress/
and i ran the validator (click here) but i have no idea where to find the lines of code that the validator says i need to fix!?
for example, the very first error says i need to check line 59
# <li id="execphp-3" class="widget widget_execphp"><h2>Upcoming Events</h2>
but where the heck do i find this text? on line 59 of what file?i even downloaded all the files in my remote wordpress folder to dreamweaver, then used the Find tool, and found nothing that resembles it.
please advise how i interpret the validator. thanks!
-
Several involve execphp or something you’ve put in an execphp widget maybe, at least a couple involve ‘fut_posts’– maybe ‘future posts’? You can tell by the class attributes on most of them. in other words, the problems are generated by widgets. Look in
wp-content/plugins
or take a good look at any PHP that you’ve placed in a widget.You have a li element outside a ul element.
alright, so regarding the li element outside the ul, do i need to edit something in the content of the widget?
<?php //display 5 posts for category ID 3 $taxonomy = 'category'; $taxargs ='include=3'; $terms = get_terms( $taxonomy, $taxargs ); foreach( $terms as $term ) { $args=array( 'category__in' => array($term->term_id), 'showposts'=> 5, 'caller_get_posts'=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { echo ''; while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> <?php endwhile; } //if ($my_query) wp_reset_query(); // Restore global post data stomped by the_post(). } //foreach ?>
or edit something in the PHP file that creates the widget?
<?php /* Yada yada yada... */ class PHP_Code_Widget extends WP_Widget { function PHP_Code_Widget() { $widget_ops = array('classname' => 'widget_execphp', 'description' => __('Arbitrary text, HTML, or PHP Code')); $control_ops = array('width' => 400, 'height' => 350); $this->WP_Widget('execphp', __('PHP Code'), $widget_ops, $control_ops); } function widget( $args, $instance ) { extract($args); $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance ); $text = apply_filters( 'widget_execphp', $instance['text'], $instance ); echo $before_widget; if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ob_start(); eval('?>'.$text); $text = ob_get_contents(); ob_end_clean(); ?> <div class="execphpwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div> <?php echo $after_widget; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); if ( current_user_can('unfiltered_html') ) $instance['text'] = $new_instance['text']; else $instance['text'] = stripslashes( wp_filter_post_kses( $new_instance['text'] ) ); $instance['filter'] = isset($new_instance['filter']); return $instance; } function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) ); $title = strip_tags($instance['title']); $text = format_to_edit($instance['text']); ?> <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p> <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea> <p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs.'); ?></label></p> <?php } } add_action('widgets_init', create_function('', 'return register_widget("PHP_Code_Widget");'));
anybody? please advise this is over my head. thanks!
I’d start by looking at the end of your header.php file and the beginning of your sidebar.php file. My guess is the beginning of the sidebar.php, but it’s hard to tell without seeing the contents of the file.
well my sidebar.php file is completely empty because in the theme i’m using, has a sidebar on the right. and i didnt want any sidebar on the right.
thoughts???
Are you saying that you deleted some things from sidebar.php because this file was loading as well as the dynamic widgets? Are you sure you didn’t delete something that the theme needs?
I’d drag all of my widgets out of the sidebar(s) so that none of them show up, then get the site valid. Then start adding widgets back one by one.
By the way, if you click the ‘show source’ checkbox on the validator page, its a lot easier to find the bad code.
i deleted everything from my sidebar.php file. the file exists but its completely empty of code. here’s a list of all the files in my theme:
* 404 Template (404.php)
* Archives (archive.php)
* Comments (comments.php)
* Footer (footer.php)
* Header (header.php)
* Main Index Template (index.php)
* Page Template (page.php)
* Search Form (searchform.php)
* Search Results (search.php)
* Sidebar (sidebar.php)
* Single Post (single.php)
* Theme Functions (functions.php)the file exists but its completely empty of code.
Ok, but that doesn’t tell me whether you deleted something your shouldn’t have.
Did you do what I suggested with the widgets?
Its hard to know what is in those files but chances are the problem is in header.php, index.php, page.php, single.php, or footer.php. If it is showing up on all pages then header.php and footer.php are the ones to focus on.
so apparently my future calendar plugin widget is causing the second validation error: https://validator.w3.org/check?uri=http%3A%2F%2Fwww.goldcoastchamber.com%2Fwordpress%2F&charset=(detect+automatically)&doctype=Inline&ss=1&outline=1&group=0&verbose=1&user-agent=W3C_Validator%2F1.654
below is the code for this plugin. any idea how to fix this error? thanks!
<?php /* Plugin Name: Future Calendar Plugin URI: https://anthologyoi.com/wordpress/plugins/future-posts-calendar-plugin.html Description: A simple plugin that utalizes a modified get_calendar function that shows what dates have a future post scheduled in a calendar format, and makes it easy to change the current timestamp. Temperature Functionality and some tweaks by Flavio Jarabeck (www.InternetDrops.com.br) Author: Aaron Harun Version: 1.0 Author URI: https://anthologyoi.com/ */ /*Uncomment the following line if you want to have the calendar appear on the dashboard.*/ //add_action('activity_box_end', 'get_future_calendar_html'); if (strpos($_SERVER['PHP_SELF'], 'post')){ if($wp_version < 2.5){ add_action('dbx_post_sidebar', 'get_future_calendar_html',2); }else{ add_action('submitpost_box', 'get_future_calendar_html'); } add_action('admin_head', 'fcal_javascript'); } // This gets called at the plugins_loaded action function widget_fut_posts_init() { // Check for the required API functions if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') ) return; // This saves options and prints the widget's config form. function widget_fut_posts_control() { $options = $newoptions = get_option('widget_fut_posts'); if ( $_POST['fut_posts-submit'] ) { $newoptions['title'] = strip_tags(stripslashes($_POST['fut_posts-title'])); } if ( $options != $newoptions ) { $options = $newoptions; update_option('widget_fut_posts', $options); } ?> <div style="text-align:right"> <label for="fut_posts-title" style="line-height:35px;display:block;"><?php _e('Widget title:', 'widgets'); ?> <input type="text" id="fut_posts-title" name="fut_posts-title" value="<?php echo wp_specialchars($options['title'], true); ?>" /></label> <input type="hidden" name="fut_posts-submit" id="fut_posts-submit" value="1" /> </div> <?php } // This prints the widget function widget_fut_posts($args) { extract($args); $defaults = array('title' => 'Future Posts'); $options = (array) get_option('widget_fut_posts'); foreach ( $defaults as $key => $value ) if ( !isset($options[$key]) ) $options[$key] = $defaults[$key]; echo $before_widget . $before_title . $options['title'] . $after_title; fcal_get_future_posts(0); echo $after_widget; } register_sidebar_widget('Future Posts', 'widget_fut_posts'); register_widget_control('Future Posts', 'widget_fut_posts_control'); } // Delay plugin execution to ensure Dynamic Sidebar has a chance to load first add_action('widgets_init', 'widget_fut_posts_init'); function future_post_sidebar(){ $title = __('Future Post','fcal'); echo '<div>' . '<h3>' . $title . '</h3>'; fcal_get_future_posts(); echo '</div>'; } function fcal_javascript(){ echo ' <script type="text/javascript"> function fcal_set_date(day,month,year){ if(day > 0 && month <= 12 && month >= 0 && year > 0){ document.getElementById("jj").value = day; document.getElementById("aa").value = year; document.getElementsByName("mm")[0].selectedIndex = month; } } </script> '; } function get_future_calendar_html(){ global $wp_version; if($wp_version < 2.5){ echo '<fieldset id="future_cal" class="dbx-box side-info">'; echo '<h3 class="dbx-handle">'.__('Future Post Dates','fcal').'</h3>'; echo '<div class="dbx-content">'; fcal_get_future_posts(); echo '</div></fieldset>'; }else{ echo '<div class="inside">'; echo '<p><strong>'.__('Future Post Dates','fcal').'</strong></p>'; fcal_get_future_posts(); echo '</div>'; } } function fcal_get_future_posts($onclick = 1){ global $wpdb, $wp_locale; $thisyear = gmdate('Y', current_time('timestamp')); $thismonth = gmdate('m', current_time('timestamp')); // Quick check. If we have no posts at all, abort! if ( !$posts ) { $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'future' ORDER BY post_date DESC LIMIT 1"); if ( !$gotsome ){ get_future_calendar($thismonth,$thisyear,$onclick); return; } } get_future_calendar($thismonth,$thisyear,$onclick); //Technically thismonth is really nextmonth, but no reason to be technical about it //But if thismonth is 12 then we need to reset it, and add a year otherwise we will be checking // out the 13th month of this year. if($thismonth == 12){ $thismonth = 0; $thisyear +=1; } // Get months this year and next with at least one post $future = $wpdb->get_results("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year FROM $wpdb->posts WHERE post_date >'$thisyear-".($thismonth+1)."-01' AND post_type = 'post' AND post_status = 'future' ORDER BY post_date ASC"); foreach($future as $now){ get_future_calendar($now->month,$now->year); } } // Calendar Output... function get_future_calendar( $thismonth ='', $thisyear='', $onclick=1, $initial=true ) { global $wpdb, $timedifference, $wp_locale; $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); // week_begins = 0 stands for Sunday $week_begins = intval(get_option('start_of_week')); $add_hours = intval(get_option('gmt_offset')); $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours)); echo '<table class="wp-calendar"> <caption><em>' . $wp_locale->get_month($thismonth) . ' ' . $thisyear . '</em></caption> <thead> <tr>'; $myweek = array(); for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); } foreach ( $myweek as $wd ) { $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>"; } echo ' </tr> </thead> <tbody> <tr>'; // Get days with posts $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' AND YEAR(post_date) = '$thisyear' AND post_type = 'post' AND post_status = 'future' AND post_date > '" . current_time('mysql') . '\'', ARRAY_N); if ( $dayswithposts ) { foreach ( $dayswithposts as $daywith ) { $daywithpost[] = $daywith[0]; } } else { $daywithpost = array(); } if ( strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') ) $ak_title_separator = "\n"; else $ak_title_separator = ', '; $ak_titles_for_day = array(); //sets the Density Thermometer $ak_posts_for_day = array(); $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " ."FROM $wpdb->posts " ."WHERE YEAR(post_date) = '$thisyear' " ."AND MONTH(post_date) = '$thismonth' " ."AND post_date > '".current_time('mysql')."' " ."AND post_type = 'post' AND post_status = 'future'" ); if ( $ak_post_titles ) { foreach ( $ak_post_titles as $ak_post_title ) { if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one $ak_titles_for_day["$ak_post_title->dom"] = str_replace('"', '"', wptexturize($ak_post_title->post_title)); else $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . str_replace('"', '"', wptexturize($ak_post_title->post_title)); $ak_posts_for_day["$ak_post_title->dom"] +=1; } } // See how much we should pad in the beginning $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); if ( 0 != $pad ) { echo "\n\t\t".'<td colspan="'.$pad.'" class="pad"> </td>'; } //Determines the Density Thermometer colors $thermo = Array( "#286EA0", "#7AFFDE", "#2FEEFF", "#108BFF", "#0E72FF" ); $daysinmonth = intval(date('t', $unixmonth)); for ( $day = 1; $day <= $daysinmonth; ++$day ) { if ( isset($newrow) && $newrow ) echo "\n\t</tr>\n\t<tr>\n\t\t"; $newrow = false; if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) ) echo '<td style="font-weight:bold;">'; else echo '<td>'; if($onclick == 1){ $onclick1 = 'onclick="fcal_set_date('.$day.','.($thismonth-1).','.$thisyear.')"'; } // any posts on that day? if ( in_array($day, $daywithpost) ) { //Outputs the Density Thermometer along with the day... echo '<span style="background-color:'.($ak_posts_for_day[$day]<=Count($thermo) ? $thermo[$ak_posts_for_day[$day]-1] : $thermo[Count($thermo)-1]).';" title="'.$ak_titles_for_day[$day].' '.$onclick1.'" >'.$day.''; } else { echo '<span '.$onclick1.' >'.$day.'</span>'; } echo '</td>'; if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) $newrow = true; } $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); if ( $pad != 0 && $pad != 7 ) echo "\n\t\t".'<td class="pad" colspan="'.$pad.'"> </td>'; echo "\n\t</tr>\n\t</tbody>\n\t</table>"; } ?>
Its not the widget. Look up to lines 58-59.
# <li class="page_item page-item-16"><a href="https://www.goldcoastchamber.com/wordpress/?page_id=16" title="Contact Us">Contact Us</a></li> # </ul> # <li id="execphp-4" class="widget widget_execphp"><h2>Upcoming Events</h2> # <div class="execphpwidget"> <p><a href="https://www.goldcoastchamber.com/wordpress/?p=128" rel="bookmark" title="Permanent Link to Holiday Bash12/3/09">Holiday Bash<br />12/3/09</a></p> # </div>
See the closing
ul
tag? Its followed by an openingli
but there is no opening tag for the list itself. There should probably be a<ul> just before that
li. I'm guessing the error occurs where the dynamic sidebars are called. Look for
function_exists(‘dynamic_sidebar’)or
dynamic_sidebar` in your .php files. I’d put it header.php or footer.php but it doesn’t have to be in those.It should look something like this from the Codex:
<ul id="sidebar"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> <li>{static sidebar item 1}</li> <li>{static sidebar item 2}</li> <?php endif; ?> </ul>
I’m thinking that the
<ul
stuff is missing.ok, making some progress now. i found “function_exists(‘dynamic_sidebar’)” in my header.php file. the whole div that its a part of is mentioned below. but it looks to me like the ul is properly opened and closed…right?
<div id="leftside"> <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Main Sidebar') ) : else : ?> <h2 class="hide">Main menu:</h2> <ul class="page"> <?php if (is_page()) { $highlight = "page_item"; } else {$highlight = "page_item current_page_item"; } ?> <li class="<?php echo $highlight; ?>"><a href="<?php bloginfo('url'); ?>">Home</a></li> <?php wp_list_pages('sort_column=menu_order&depth=1&title_li='); ?> </ul> <?php endif; ?> </div>
… ul is properly opened and closed…right?
No, its not. The dynamic sidebar is actually called inside the
if
‘s conditional, which is confusing. That is, the sidebar is called here: ‘if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(‘Main Sidebar’) )’. That part isn’t wrapped in a<ul>
at all. Rewrite it like this:<div id="content-main"> <div id="leftside"> <?php if ( function_exists('dynamic_sidebar') ) { ?> <ul> <?php dynamic_sidebar('Main Sidebar') ) ?> </ul> <?php } else { ?> <h2 class="hide">Main menu:</h2> <ul class="page"> <?php if (is_page()) { $highlight = "page_item"; } else {$highlight = "page_item current_page_item"; } ?> <li class="<?php echo $highlight; ?>"><a href="<?php bloginfo('url'); ?>">Home</a></li> <?php wp_list_pages('sort_column=menu_order&depth=1&title_li='); ?> </ul> } </div>
Add a class to that ul if you need to target the sidebar.
hmmm. i made the changes but now i have 5 errors and 4 warnings in the validator instead of just the 4 errors i had before.
i pasted it in exactly as you detailed above. i’m not sure if i should add a class??? i’m really lost right now. please help. thanks for your patience!
You’ve got a fatal error on the site. My mistake. There is an extra ‘)’ in this line:
<?php dynamic_sidebar('Main Sidebar') ) ?>
. It should be<?php dynamic_sidebar('Main Sidebar') ?>
- The topic ‘Not Sure Which Fiels To Edit to Clean Up Validation Errors’ is closed to new replies.