Forums

using str_replace to strip [..] out of rss feed (3 posts)

  1. lindsayanng
    Member
    Posted 2 years ago #

    Can i do it? I'm not OVERLY experienced with php, but I understand enough to know what it SHOULD do (not that it can).

    On this site here: CLICK

    You see the feeds on the left. They are coming from two different blogs hosted on the same server but owned and managed separately. I used the basic RSS widget to display that content (so you know the basic functions of the RSS widget)

    So can I add a simple str_replace to remove [..][..] and replace with "read more"

    $brackets = array("[..][..]");
    $readmore = str_replace($brackets, "readmore");

    again, please forgive my ignorance.. i only know enough to make me dangerous. I would REALLY appreciate some feedback though. It'll help me learn AND help me move forward with that site

  2. lindsayanng
    Member
    Posted 2 years ago #

    anyone here with some help?

  3. lindsayanng
    Member
    Posted 2 years ago #

    Ok.. So I am almost there, but then I realized that I was working within the RSS Links widget.. NOT the RSS Widget.

    So where is the code that creates the class for the RSS Widget? Where does it get its functions from? I have sandbox installed, so its pretty basic

    Look here:

    // Widget: RSS links; to match the Sandbox style
    function widget_sandbox_rsslinks($args) {
    	extract($args);
    	$options = get_option('widget_sandbox_rsslinks');
    	$title = empty($options['title']) ? __( 'RSS Links', 'sandbox' ) : attribute_escape($options['title']);
    
    ?>
    		<?php echo $before_widget; ?>
    			<?php echo $before_title . $title . $after_title; ?>
    			<ul>
    				<li><a href="<?php bloginfo('rss2_url') ?>" title="<?php echo wp_specialchars( get_bloginfo('name'), 1 ) ?> <?php _e( 'Posts RSS feed', 'sandbox' ); ?>" rel="alternate" type="application/rss+xml"><?php _e( 'All posts', 'sandbox' ) ?></a></li>
    				<li><a href="<?php bloginfo('comments_rss2_url') ?>" title="<?php echo wp_specialchars(bloginfo('name'), 1) ?> <?php _e( 'Comments RSS feed', 'sandbox' ); ?>" rel="alternate" type="application/rss+xml"><?php _e( 'All comments', 'sandbox' ) ?></a></li>
    			</ul>
    		<?php echo $after_widget; ?>
    <?php
    }
    
    // Widget: RSS links; element controls for customizing text within Widget plugin
    function widget_sandbox_rsslinks_control() {
    	$options = $newoptions = get_option('widget_sandbox_rsslinks');
    	if ( $_POST['rsslinks-submit'] ) {
    		$newoptions['title'] = strip_tags( stripslashes( $_POST['rsslinks-title'] ) );
    	}
    	if ( $options != $newoptions ) {
    		$options = $newoptions;
    		update_option( 'widget_sandbox_rsslinks', $options );
    	}
    	$title = attribute_escape($options['title']);
    
    ?>
    	<p><label for="rsslinks-title"><?php _e( 'Title:', 'sandbox' ) ?> <input class="widefat" id="rsslinks-title" name="rsslinks-title" type="text" value="<?php echo $title; ?>" /></label></p>
    	<input type="hidden" id="rsslinks-submit" name="rsslinks-submit" value="1" />
    <?php
    }
    
    // Widgets plugin: intializes the plugin after the widgets above have passed snuff
    function sandbox_widgets_init() {
    	if ( !function_exists('register_sidebars') )
    		return;
    
    	// Formats the Sandbox widgets, adding readability-improving whitespace
    	$p = array(
    		'before_widget'  =>   "\n\t\t\t" . '<li id="%1$s" class="widget %2$s">',
    		'after_widget'   =>   "\n\t\t\t</li>\n",
    		'before_title'   =>   "\n\t\t\t\t". '<h3 class="widgettitle">',
    		'after_title'    =>   "</h3>\n"
    	);
    
    	// Table for how many? Two? This way, please.
    	register_sidebars( 5, $p );
    
    	// Finished intializing Widgets plugin, now let's load the Sandbox default widgets; first, Sandbox search widget
    	$widget_ops = array(
    		'classname'    =>  'widget_search',
    		'description'  =>  __( "A search form for your blog (Sandbox)", "sandbox" )
    	);
    
    	wp_register_sidebar_widget( 'search', __( 'Search', 'sandbox' ), 'widget_sandbox_search', $widget_ops );
    	unregister_widget_control('search'); // We're being Sandbox-specific; remove WP default
    	wp_register_widget_control( 'search', __( 'Search', 'sandbox' ), 'widget_sandbox_search_control' );
    
    	// Sandbox Meta widget
    	$widget_ops = array(
    		'classname'    =>  'widget_meta',
    		'description'  =>  __( "Log in/out and administration links (Sandbox)", "sandbox" )
    	);
    	wp_register_sidebar_widget( 'meta', __( 'Meta', 'sandbox' ), 'widget_sandbox_meta', $widget_ops );
    	unregister_widget_control('meta'); // We're being Sandbox-specific; remove WP default
    	wp_register_widget_control( 'meta', __( 'Meta', 'sandbox' ), 'wp_widget_meta_control' );
    
    	//Sandbox RSS Links widget
    	$widget_ops = array(
    		'classname'    =>  'widget_rss_links',
    		'description'  =>  __( "RSS links for both posts and comments (Sandbox)", "sandbox" )
    	);
    
    	wp_register_sidebar_widget( 'rss_links', __( 'RSS Links', 'sandbox' ), 'widget_sandbox_rsslinks', $widget_ops );
    	wp_register_widget_control( 'rss_links', __( 'RSS Links', 'sandbox' ), 'widget_sandbox_rsslinks_control' );
    }

    where in the WORLD is the regular RSS Widget?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.