WordPress.org

Ready to get started?Download WordPress

Forums

Fatal Error (3 posts)

  1. rtica3
    Member
    Posted 1 year ago #

    Hello,

    I am coming up with this message in the sidebar of our site:

    http://fullcircle-pr.com/news/

    Fatal error: Using $this when not in object context in /nfs/c01/h06/mnt/709/domains/fullcircle-pr.com/html/wp-includes/default-widgets.php on line 537

    I have tried to look in the php widgets file, but honestly I'm not sure what I'm looking for... also tried to find an answer on the forums but most are specific to a certain widget.

    There is an active "connect" widget which seems to be the search field (I think this is where the error is?). This is the php for the widgets file:

    <?php
    // SOCIAL WIDGET
    class Socialwidget extends WP_Widget {
    
    	function Socialwidget() {
    		$widget_ops = array('classname' => 'social_widget', 'description' => __('Link to your RSS feed and social media accounts.'));
    		$this->WP_Widget('social_networks', 'Prosto → Connect', $widget_ops, $control_ops);
    	}
    
    	function widget( $args, $instance ) {
    		extract($args);
    		$title = apply_filters('widget_title', $instance['title']);
    		$descr = $instance['descr'];
    
    		$networks['Twitter'] = $instance['twitter'];
    		$networks['Email'] = $instance['email'];
    		$networks['Facebook'] = $instance['facebook'];
    		$networks['RSS'] = $instance['rss'];
    
    		$display = $instance['display'];
    
    ?>
    
    <?php
    			echo $before_title;
    		  if (empty( $title) ) { echo $title_page->post_title;}
    		  else { echo $title; }
    		echo $after_title;
    		?>
    
    <p><?php echo $descr; ?></p>
    
    <ul class="connect">
    
    <?php foreach(array("Twitter") as $network) : ?>
    <?php if (!empty($networks[$network])) : ?>
    
    <li><a>" target="_blank" class="<?php echo strtolower($network); ?>"><span><?php echo $network; ?></span></a></li>
    <?php endif; ?>
    <?php endforeach; ?>
    <?php foreach(array("Email") as $network) : ?>
    <?php if (!empty($networks[$network])) : ?>
    
    <li><a>"  class="<?php echo strtolower($network); ?>"><span><?php echo $network; ?></span></a></li>
    <?php endif; ?>
    <?php endforeach; ?>
    <?php foreach(array("Facebook") as $network) : ?>
    <?php if (!empty($networks[$network])) : ?>
    
    <li><a>" target="_blank" class="<?php echo strtolower($network); ?>"><span><?php echo $network; ?></span></a></li>
    <?php endif; ?>
    <?php endforeach; ?>
    <?php if (empty($networks['RSS'])) : ?>
    
    <li><a>" target="_blank" class="rss"><span>rss</span></a></li>
    <?php else : ?>
    
    <li><a>" target="_blank" class="rss"><span>rss</span></a></li>
    <?php endif; ?>	
    
    		<?php
    
    	}
    
    	function update( $new_instance, $old_instance ) {
    		$instance = $old_instance;
    		$instance['title'] = strip_tags($new_instance['title']);
    		$instance['descr'] = $new_instance['descr'];
    		$instance['rss'] = $new_instance['rss'];
    		$instance['twitter'] = $new_instance['twitter'];
    		$instance['facebook'] = $new_instance['facebook'];
    		$instance['email'] = $new_instance['email'];
    
    		$instance['display'] = $new_instance['display'];
    
    		return $instance;
    	}
    
    	function form( $instance ) {
    		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '', 'descr' => '' ) );
    		$title = strip_tags($instance['title']);
    		$descr = strip_tags($instance['descr']);
    		$rss = $instance['rss'];
    		$twitter = $instance['twitter'];
    		$facebook = $instance['facebook'];
    		$email = $instance['email'];	
    
    		$display = $instance['display'];		
    
    		$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>
    
        	<p><label for="<?php echo $this->get_field_id('descr'); ?>"><?php _e('Description:'); ?></label>
        	<input class="widefat" id="<?php echo $this->get_field_id('descr'); ?>" name="<?php echo $this->get_field_name('descr'); ?>" type="text" value="<?php echo esc_attr($descr); ?>" />
       		 </p>
    
    		<p><label for="<?php echo $this->get_field_id('rss'); ?>"><?php _e('RSS URL: (leave empty for default feed)'); ?></label>
    		<input class="widefat" id="<?php echo $this->get_field_id('rss'); ?>" name="<?php echo $this->get_field_name('rss'); ?>" type="text" value="<?php echo esc_attr($rss); ?>" /></p>
    
    		<p><label for="<?php echo $this->get_field_id('facebook'); ?>"><?php _e('Facebook URL:'); ?></label>
    		<input class="widefat" id="<?php echo $this->get_field_id('facebook'); ?>" name="<?php echo $this->get_field_name('facebook'); ?>" type="text" value="<?php echo esc_attr($facebook); ?>" /></p>
    
    		<p><label for="<?php echo $this->get_field_id('twitter'); ?>"><?php _e('Twitter URL:'); ?></label>
    		<input class="widefat" id="<?php echo $this->get_field_id('twitter'); ?>" name="<?php echo $this->get_field_name('twitter'); ?>" type="text" value="<?php echo esc_attr($twitter); ?>" /></p>
    
    		<p><label for="<?php echo $this->get_field_id('email'); ?>"><?php _e('Email:'); ?></label>
    		<input class="widefat" id="<?php echo $this->get_field_id('flickr'); ?>" name="<?php echo $this->get_field_name('email'); ?>" type="text" value="<?php echo esc_attr($email); ?>" /></p>
    
    <?php
    	}
    }
    
    add_action('widgets_init', create_function('', 'return register_widget("Socialwidget");'));
    
    // RECENT POSTS WIDGET
    function show_recent(){
    	if ( !function_exists('register_sidebar_widget') )
    		return;
    
    	function widget_gsearch($args) {
    		extract($args);
    
    		$options = get_option('custom_recent');
    		$title = $options['title'];
    		$posts = $options['posts'];
    		$category = $options['category'];
    
    		//GET the posts
    		global $post;
    		$myposts = get_posts('numberposts='.$posts.'&offset=0&cat='.$category);
    
    		echo $before_widget . $before_title . $title . $after_title;
    ?>
    
    <ul>
    	<?php	//SHOW the posts
    		foreach($myposts as $post){
    			setup_postdata($post);
    			$preview = strip_tags(stripslashes($post->post_content));
    			?>
    
    <li><a>"><?php echo substr($preview, 0, 80); ?>...</a></li>
    			<?php
    		} ?> </ul>
     <?php
    		echo $after_widget;
    	}
    
    	function widget_control() {
    
    		$options = get_option('custom_recent');
    		if ( !is_array($options) )
    			$options = array('title'=>'Recent News', 'posts'=>3);
    		if ( $_POST['custom_recent'] ) {
    
    			$options['title'] = strip_tags(stripslashes($_POST['custom_recent_title']));
    			$options['category'] = strip_tags(stripslashes($_POST['custom_recent_category']));
    			$options['posts'] = strip_tags(stripslashes($_POST['custom_recent_number']));
    			update_option('custom_recent', $options);
    		}
    
    		$title = htmlspecialchars($options['title'], ENT_QUOTES);
    		$category = htmlspecialchars($options['category'], ENT_QUOTES);
    		$posts = htmlspecialchars($options['posts'], ENT_QUOTES);
    
    		echo '<p style="text-align:right;"><label for="custom_recent_title">' . __('Title:') . ' <input style="width: 200px;" id="custom_recent_title" name="custom_recent_title" type="text" value="'.$title.'" /></label></p>';
    
    		?>
           <p style="text-align:right;"><label for="custom_recent_category"><?php _e('Category:'); ?></label>
        	<?php wp_dropdown_categories(array('selected' => $category, 'name' => 'custom_recent_category', 'show_option_none' => __('None'), 'sort_column'=> 'menu_order, post_title'));?>
       		 </p>
    
    		<?php echo '<p style="text-align:right;"><label for="custom_recent_number">' . __('Number of Posts:', 'widgets') . ' <input style="width: 50px;" id="custom_recent_number" name="custom_recent_number" type="text" value="'.$posts.'" /></label></p>';
    
    		echo '<input type="hidden" id="custom_recent" name="custom_recent" value="1" />';
    
    	}
    
    	register_sidebar_widget(array('Prosto → Recent News', 'widgets'), 'widget_gsearch');
    	register_widget_control(array('Prosto → Recent News', 'widgets'), 'widget_control', 255, 100);
    
    }
    
    add_action('widgets_init', 'show_recent');
    
    /**
     * ************************************* Flickr Widget
     */
    function prosto_flickr_widget($args) {
    	$settings = get_option("widget_flickrwidget");
    
    	$id = $settings['id'];
    	$number = $settings['number'];
    
    	echo $args['before_widget'];
    ?>
    
    	<h3 class="widgettitle">Photos on <span>flick<span>r</span></span></h3>
    	<div class="box">
    
    		<script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?count=<?php echo $number; ?>&display=latest&size=s&layout=x&source=user&user=<?php echo $id; ?>"></script>        
    
    	</div>
    
    <?php
    	echo $args['after_widget'];
    }
    
    function prosto_flickr_widget_admin() {
    	$settings = get_option("widget_flickrwidget");
    
    	// check if anything's been sent
    	if (isset($_POST['update_flickr'])) {
    		$settings['id'] = strip_tags(stripslashes($_POST['flickr_id']));
    		$settings['number'] = strip_tags(stripslashes($_POST['flickr_number']));
    
    		update_option("widget_flickrwidget",$settings);
    	}
    
    	echo '<p>
    			<label for="flickr_id">Flickr ID (<a href="http://www.idgettr.com">idGettr</a>):
    			<input id="flickr_id" name="flickr_id" type="text" class="widefat" value="'.$settings['id'].'" /></label></p>';
    	echo '<p>
    			<label for="flickr_number">Number of photos:
    			<input id="flickr_number" name="flickr_number" type="text" class="widefat" value="'.$settings['number'].'" /></label></p>';
    	echo '<input type="hidden" id="update_flickr" name="update_flickr" value="1" />';
    
    }
    wp_register_sidebar_widget( 'flickr-widget', $themename.' → Flickr', 'prosto_flickr_widget', array('description' => 'Pulls in images from your Flickr account.'));
    register_widget_control('flickr-widget', 'prosto_flickr_widget_admin', 400, 200);
    
    function widget_Twidget_init() {
    
    	if ( !function_exists('register_sidebar_widget') )
    		return;
    
    	function widget_Twidget($args) {
    
    		extract($args);
    
    		$options = get_option('widget_Twidget');
    		$account = $options['account'];  // Your Twitter account name
    		$title = $options['title'];  // Title in sidebar for widget
    		$show = $options['show'];  // # of Updates to show
    		$follow = $options['follow'];  // # of Updates to show
    
            // Output
    		echo $before_widget ;
    
    		?>
    
    		<div id="twitter">
    		    <h3><?php echo $title; ?></h3>
    			<div class="twitter-top"><!----></div>
    			<ul id="twitter_update_list">
    <li></li>
    			<?php hosted_twitter_script('',$account,$show); ?>
    			<div class="website">
    			<div class="follow-text"><a>/" title="<?php echo $follow; ?>"><?php echo $follow; ?></a></div>
    			</div>
    		</div>
    
    		<?php
    
    		// echo widget closing tag
    		echo $after_widget;
    	}
    
    	// Settings form
    	function widget_Twidget_control() {
    
    		// Get options
    		$options = get_option('widget_Twidget');
    		// options exist? if not set defaults
    		if ( !is_array($options) )
    			$options = array('account'=>'prosto', 'title'=>'Twitter Updates', 'show'=>'3', 'follow'=>'Follow us on Twitter');
    
            // form posted?
    		if ( $_POST['Twitter-submit'] ) {
    
    			// Remember to sanitize and format use input appropriately.
    			$options['account'] = strip_tags(stripslashes($_POST['Twitter-account']));
    			$options['title'] = strip_tags(stripslashes($_POST['Twitter-title']));
    			$options['show'] = strip_tags(stripslashes($_POST['Twitter-show']));
    			$options['follow'] = strip_tags(stripslashes($_POST['Twitter-follow']));
    			update_option('widget_Twidget', $options);
    		}
    
    		// Get options for form fields to show
    		$account = htmlspecialchars($options['account'], ENT_QUOTES);
    		$title = htmlspecialchars($options['title'], ENT_QUOTES);
    		$show = htmlspecialchars($options['show'], ENT_QUOTES);
    		$follow = htmlspecialchars($options['follow'], ENT_QUOTES);
    
    		// The form fields
    		echo '<p style="text-align:right;">
    				<label for="Twitter-account">' . __('Account:') . '
    				<input style="width: 200px;" id="Twitter-account" name="Twitter-account" type="text" value="'.$account.'" />
    				</label></p>';
    		echo '<p style="text-align:right;">
    				<label for="Twitter-title">' . __('Title:') . '
    				<input style="width: 200px;" id="Twitter-title" name="Twitter-title" type="text" value="'.$title.'" />
    				</label></p>';
    		echo '<p style="text-align:right;">
    				<label for="Twitter-show">' . __('Show:') . '
    				<input style="width: 200px;" id="Twitter-show" name="Twitter-show" type="text" value="'.$show.'" />
    				</label></p>';
    		echo '<p style="text-align:right;">
    				<label for="Twitter-follow">' . __('Follow us:') . '
    				<input style="width: 200px;" id="Twitter-follow" name="Twitter-follow" type="text" value="'.$follow.'" />
    				</label></p>';
    		echo '<input type="hidden" id="Twitter-submit" name="Twitter-submit" value="1" />';
    	}
    
    	// Register widget for use
    	register_sidebar_widget(array('Prosto → Twitter', 'widgets'), 'widget_Twidget');
    
    	// Register settings for use, 300x200 pixel form
    	register_widget_control(array('Prosto → Twitter', 'widgets'), 'widget_Twidget_control', 300, 200);
    }
    
    // Run code and init
    add_action('widgets_init', 'widget_Twidget_init');
    
    function hosted_twitter_script($u_id,$username,$limit) {
    ?>
    <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    
        function twitterCallback2(twitters) {
          var statusHTML = [];
          for (var i=0; i<twitters.length; i++){
            var username = twitters[i].user.screen_name;
            var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
              return '<a href="'+url+'">'+url+'</a>';
            }).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
              return  reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
            });
            statusHTML.push('
    <li><span>'+status+'</span> <a href="http://twitter.com/'+username+'/statuses/'+twitters[i].id+'">'+relative_time(twitters[i].created_at)+'</a></li>
    ');
          }
          document.getElementById('twitter_update_list<?php echo $u_id; ?>').innerHTML = statusHTML.join('');
        }
    
        function relative_time(time_value) {
          var values = time_value.split(" ");
          time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
          var parsed_date = Date.parse(time_value);
          var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
          var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
          delta = delta + (relative_to.getTimezoneOffset() * 60);
    
          if (delta < 60) {
            return 'less than a minute ago';
          } else if(delta < 120) {
            return 'about a minute ago';
          } else if(delta < (60*60)) {
            return (parseInt(delta / 60)).toString() + ' minutes ago';
          } else if(delta < (120*60)) {
            return 'about an hour ago';
          } else if(delta < (24*60*60)) {
            return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
          } else if(delta < (48*60*60)) {
            return '1 day ago';
          } else {
            return (parseInt(delta / 86400)).toString() + ' days ago';
          }
        }
    //-->!]]>
    </script>
    <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/<?php echo $username; ?>.json?callback=twitterCallback2&count=<?php echo $limit; ?>"></script>
    <?php
    
    }
    
    ?>

    If anyone can help that would be AWESOME!

    Thanks!

  2. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 1 year ago #

    Where is the file you listed from? Your theme? A Plugin?

    What widget is in the sidebar? Can you temporarily change to the default theme & ensure the same widget (if available) is in the sidebar? - does the issue go away? If so the issue is with the theme you need to get support from your theme vendor as commercial themes are not supported here.

    If the issue does not appear to be theme related I is likely to be plugin related. To test for this deactivate all plugins & if the issue goes away reactivate them one-by-one until the issue reappears. This will enable you to identify the plugin causing the issue.

  3. rtica3
    Member
    Posted 1 year ago #

    Thank you very much for your response. The file was from my theme. From using firebug it looks like the error is within that search field area, but as far as I can tell I don't have any plugins that would be related to the search field. Sorry, I use Joomla more than wordpress and am not too great at php - I didn't build this site, I am just jumping in trying to edit it so it is hard for me to troubleshoot.

    I will try your suggestions and see if some trial and error will help.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic