Whats the problem in my custom widget

My widget code-

class floridabt_show_recent extends WP_Widget {

	function floridabt_show_recent() {
		 $widget_ops = array('classname' => 'floridabt_show_recent', 'description' => esc_html__('Show your popular posts.', 'floridabt'));
		 parent::__construct('floridabt_show_recent_title', esc_html__('- Recent Posts -', 'floridabt'), $widget_ops);
		
	 }
	 
	function widget($args, $instance){
		extract($args);

		 $title = $instance['title'];
		 $postscount = $instance['posts'];
		 
		$popularpost = new WP_Query( array( 'posts_per_page' => $postscount, 'post_type' => 'post', 'order' => 'DESC','post__not_in' => get_option( 'sticky_posts' )) );
		 
		echo '<h3>'.$title.'</h3>';
		 	
		//SHOW the posts						 
			while ( $popularpost->have_posts() ) : $popularpost->the_post();
			?>				
							
				<div class="media">
				  <div class="media-left">
					  <a href="<?php the_permalink(); ?>">
						<?php the_post_thumbnail('',array('class'=>'media-object')); ?>
					  </a>
				  </div>
				  <div class="media-body">
					<h4 class="media-heading"><?php the_title(); ?></h4>
					<i class="fa fa-clock-o"></i>
					<span>
					<?php 
						the_time( 'j F Y' );
						$categories = get_the_category();
						if ( ! empty( $categories ) ) {
							echo '  <i class="fa fa-bookmark-o"></i> <a href="' . esc_url( get_category_link( $categories[0]->term_id ) ) . '">' . esc_html( $categories[0]->name ) . '</a>';
						}
					?> 
					</span>								
				  </div>
				</div>
				
			
			<?php

			endwhile;
	 }
	 
		function update($newInstance, $oldInstance){
			 $instance = $oldInstance;
			 $instance['title'] = strip_tags($newInstance['title']);
			 $instance['posts'] = $newInstance['posts'];
			 
			 return $instance;
		 }
	 
		function form($instance){
			
			$title = isset($instance['title'])? $instance['title'] : 'Recent Post\'s';
			echo '<p style="text-align:right;"><label  for="'.$this->get_field_id('title').'">' . esc_html__('Title:', 'floridabt') . '  <input style="width: 200px;" id="'.$this->get_field_id('title').'"  name="'.$this->get_field_name('title').'" type="text"  value="'.esc_attr($title).'" /></label></p>';
			
			$posts = isset($instance['posts'])? $instance['posts'] : '3';
			echo '<p style="text-align:right;"><label  for="'.$this->get_field_id('posts').'">' . esc_html__('Number of Posts:', 'floridabt') . ' <input style="width: 50px;"  id="'.$this->get_field_id('posts').'"  name="'.$this->get_field_name('posts').'" type="text"  value="'.esc_attr($posts).'" /></label></p>';
			 
			echo '<input type="hidden" id="custom_recent" name="custom_recent" value="1" />';
		 }
	 }
 
add_action('widgets_init', create_function('', 'return register_widget("floridabt_show_recent");'));

I added this

define( ‘WP_DEBUG’, true );
define( ‘WP_DEBUG_LOG’, true );
define( ‘WP_DEBUG_DISPLAY’, true );
define( ‘SCRIPT_DEBUG’, true );
define( ‘SAVEQUERIES’, true );

code in wp config file bt i didn’t find any notice or warning. Envato given me a screenshot below http://envato.d.pr/axsHbm

How can i solve this problem?

Thanks

Hi @BanyanTheme,

You need to look for the problem in your “custom-widgets.php” file. Take a look at the source of warning:
http://php.net/manual/en/migration70.deprecated.php

Thanks,
Luca

Hi, Thanks for your reply.
But how can i test this warning?
I didn’t find this warning in my server. Do you think it’s php version problem for this warning test?

It might be, yes. The way you construct your class and function will soon be deprecated, as stated in the link above. You need to make sure that the function has different name from class.

Those errors are displayed on a local server, most likely running on “WampServer”:

Thanks,
Luca

Thanks I got this warning!
It was php version problem.

But what is the new constructors and how to solve it in my code?

The only thing to change is your class or function name - they need to be different.

For example:

class floridabt_show_recent extends WP_Widget {

  function floridabt_show_recent_f() {

        echo 'function content';

  }

}

Thanks,
Luca

Thank u so much for your help.
Can i use this code-

class floridabt_show_recent extends WP_Widget {

	public function __construct()
	{
		$widget_details = array(
			'classname' => 'floridabt_show_recent',
			'description' => 'Show your recent posts.'
		);

		parent::__construct( 'floridabt_about_widget_title', '- Recent Posts -', $widget_details );

	}

}

Absolutely, this is a default construction provided in official WordPress docs :slight_smile: Make sure however to choose unique name for your widget, you can add theme name in front of it.

Thanks,
Luca

Thank you so much.
I need some more help if you don’t mind.

Problem 1:

Whats the problem in my feature image
https://banyanthemes.com/themes/test/?s=vertical

Envato message:
Once again, vertical featured image display error: http://envato.d.pr/PmBqof

Problem 2:

Once again, third party scripts/ styles don’t need to be prefixed or suffixed to avoid double loading. ref: https://github.com/grappler/wp-standard-handles
http://envato.d.pr/EMypnL

but i am not clear in ref link.

My code

// Font awesome 
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css' );

// Theme Google fonts
wp_enqueue_style( 'google-fonts', floridabt_fonts_url(), array(), null );

// Bootstrap style
wp_enqueue_style( 'bootstrapcss', get_template_directory_uri() . '/css/bootstrap.min.css' );

// CSS Animation 
wp_enqueue_style( 'animate', get_template_directory_uri() . '/css/animate.min.css' );

// Loader
wp_enqueue_style( 'fakeLoader', get_template_directory_uri() . '/css/fakeLoader.css' );

// Lightbox Gallery
wp_enqueue_style( 'jquery-fancybox', get_template_directory_uri() . '/inc/lightbox/css/jquery.fancybox.css' );    

// Main Stylesheet
wp_enqueue_style( 'floridabt-style', get_stylesheet_uri() );

// Responsive Stylesheet
wp_enqueue_style( 'floridabt-responsive', get_template_directory_uri() . '/css/responsive.css' );

// color

if( ( get_theme_mod( 'color_active' )) == 'orange') {
	wp_enqueue_style( 'floridabt-orange', get_template_directory_uri() . '/css/assets/color/orange.css');
}elseif(( get_theme_mod( 'color_active' )) == 'amber' ) {
	wp_enqueue_style( 'floridabt-amber', get_template_directory_uri() . '/css/assets/color/amber.css');
}elseif(( get_theme_mod( 'color_active' )) == 'blue' ) {
	wp_enqueue_style( 'floridabt-blue', get_template_directory_uri() . '/css/assets/color/blue.css');
}elseif(( get_theme_mod( 'color_active' )) == 'green' ) {
	wp_enqueue_style( 'floridabt-green', get_template_directory_uri() . '/css/assets/color/green.css');
}elseif(( get_theme_mod( 'color_active' )) == 'indigo' ) {
	wp_enqueue_style( 'floridabt-indigo', get_template_directory_uri() . '/css/assets/color/indigo.css');
}elseif(( get_theme_mod( 'color_active' )) == 'pink' ) {
	wp_enqueue_style( 'floridabt-pink', get_template_directory_uri() . '/css/assets/color/pink.css');
}elseif(( get_theme_mod( 'color_active' )) == 'teal' ) {
	wp_enqueue_style( 'floridabt-teal', get_template_directory_uri() . '/css/assets/color/teal.css');
}elseif(( get_theme_mod( 'color_active' )) == 'red' ) {
	wp_enqueue_style( 'floridabt-red', get_template_directory_uri() . '/css/assets/color/red.css');
}	
// end if


/*===================================================================
	Scripts
===================================================================*/	



// Include all compiled plugins (below), or include individual files as needed 
wp_enqueue_script( 'bootstrapjs', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ) , true );

// Masonry Portfolio Script
wp_enqueue_script( 'jquery-mixitup', get_template_directory_uri() . '/js/jquery.mixitup.js', array( 'jquery' ) , true );

// Counter 
wp_enqueue_script( 'waypoints', get_template_directory_uri() . '/js/waypoints-min.js', array( 'jquery' ) , true );
wp_enqueue_script( 'jquery-counterup', get_template_directory_uri() . '/js/jquery.counterup.min.js', array( 'jquery' ) , true );

// Scroll bottom to top
wp_enqueue_script( 'scrolltopcontrol', get_template_directory_uri() . '/js/scrolltopcontrol.js', array( 'jquery' ) , true );

// Stiky menu
wp_enqueue_script( 'jquery-sticky', get_template_directory_uri() . '/js/jquery.sticky.js', array( 'jquery' ) , true );

// Wow js
wp_enqueue_script( 'wow-min', get_template_directory_uri() . '/js/wow.min.js', array( 'jquery' ) , true );

// fakeLoader js 
wp_enqueue_script( 'fakeLoader-min', get_template_directory_uri() . '/js/fakeLoader.min.js', array( 'jquery' ) , true );

// Sticky sidebar
wp_enqueue_script( 'theia-sticky-sidebar', get_template_directory_uri() . '/js/theia-sticky-sidebar.js', array( 'jquery' ) , true );


// Lightbox js
wp_enqueue_script( 'jquery-fancybox-pack', get_template_directory_uri() . '/inc/lightbox/js/jquery.fancybox.pack.js', array( 'jquery' ) , true );
wp_enqueue_script( 'lightbox', get_template_directory_uri() . '/inc/lightbox/js/lightbox.js', array( 'jquery' ) , true );


// Custom script
wp_enqueue_script( 'floridabt-custom', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ) , true );

What’s the problem in my code actually i am not clear.

Thanks

  1. I’m not sure about that, to be honest. It’s difficult to tell where exactly was this screenshot taken from. Since your featured image inside single post looks sharp on both screens and mobiles, you may need to look at the other parts of your theme, like blog posts area, related posts or whatever place that uses post image thumbnails. I can’t see any signs of sidebar on the screenshot, would it be possible that the error occurs when you use “no sidebar” layout of your theme?

  2. You have used file the exact file name everywhere except for the Bootstrap - change “bootstrapjs” to “bootstrap”.

Thanks,
Luca

Thanks you so much for your help.
My demo link https://banyanthemes.com/themes/floridabt/
If any suggestions.

Thanks

One question - is the line under “Most popular services” heading that’s hiding on section hover intended to be there?

Thanks,
Luca

yes, When section hover heading line will hide.