help w/ modifying a wordpress plugin...

Discussion in 'PHP' started by sweetpea69, May 19, 2014.

  1. #1
    So for the past week i've been tirelessly screwing around w/ eBay Feeds for Wordpress and keep coming up with ERRORS. I know little about PHP, so hoping the modifications are fairly straight forward. Anyways, the plugin is just a simple RSS feed, that plugs in my affiliate id so it simplifies the task. I've just been CSS'in what I can, but looking for a more permanent solution.

    1) So the plugin pulls in the eBay title, image, and description. But the latter 2, I don't need. Simple as just deleting some of the code? Seems unnecessary to pull in items I don't need...

    2)....and I only need the first 9 characters of the title, anyway to put a filter on that? Opposed to using the images, I was looking to just CSS the "title" into something fancy ;)

    So here's the PHP i'm thinking you need... and if not, here's the full code just in case.

    <?php
    /*
    Plugin Name:  Ebay Feeds for WordPress
    Plugin URI:   http://winwar.co.uk/plugins/ebay-feeds-wordpress/
    Description:  Parser of ebay RSS feeds to display on Wordpress posts, widgets and pages.
    Version:      1.2
    Author:       Winwar Media
    Author URI:   http://winwar.co.uk/
    
    */
    
    define("EBFW_PLUGIN_NAME","eBay Feeds For WordPress");
    define("EBFW_PLUGIN_TAGLINE","Parser of ebay RSS feeds to display on Wordpress posts, widgets and pages.");
    define("EBFW_PLUGIN_URL","http://bloggingdojo.com/wordpress-plugins/ebay-feeds-for-wordpress/");
    define("EBFW_EXTEND_URL","http://wordpress.org/extend/plugins/ebay-feeds-for-wordpress/");
    define("EBFW_AUTHOR_TWITTER","rhyswynne");
    define("EBFW_DONATE_LINK","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=F852ZPEANV7C6");
    
    register_activation_hook(__FILE__,'ebay_feeds_for_wordpress_install');
    
    function ebay_feeds_for_wordpress($url = "", $num = "") {
    $link = get_option("ebay-feeds-for-wordpress-link");
    $blank = get_option("ebay-feeds-for-wordpress-link-open-blank");
    $nofollow = get_option("ebay-feeds-for-wordpress-nofollow-links");
    if ($url == "")
    {
    $url = get_option('ebay-feeds-for-wordpress-default');
    }
    
    if ($num == "")
    {
    $num = get_option('ebay-feeds-for-wordpress-default-number');
    }
    
    
    include_once(ABSPATH . WPINC . '/rss.php');
    
    $rss = fetch_feed($url);
    $rss->enable_order_by_date(false);
    
    if (!is_wp_error($rss))
    {
     
        $rss_items = $rss->get_items(0, $num);
    }
    echo "<div class='ebayfeed'>";
    
    if ($rss_items)
    {
    foreach ($rss_items as $item ) {
     
        echo "<h4 class='ebayfeedtitle'><a ";
     
        if ($blank == "1")
        {
            echo "target='_blank' ";
        }
     
        if ($nofollow == "1")
        {
            echo " rel='nofollow' ";
        }
         echo "href='".$item->get_permalink()."'  class='ebayfeedlink'>".$item->get_title()."</a></h4>";
        if ($blank == "1")
     
    {
        echo $item->get_description();
        } else {
            $newdescription = str_replace('target="_blank"', '', $item->get_description());
            echo $newdescription;
        }
    
     
        }
    }
    echo "</div>";
    if ($link == 1)
    {
        echo "<a href='http://bloggingdojo.com/wordpress-plugins/ebay-feeds-for-wordpress/'>eBay Feeds for WordPress</a> by <a href='http://www.bloggingdojo.com'>The Blogging Dojo</a><br/><br/>";
    }
    }
    
    if ( is_admin() ){ // admin actions
    
      add_action('admin_menu', 'ebay_feeds_for_wordpress_menus');
      add_action( 'admin_init', 'ebay_feeds_for_wordpress_options_process' );
      add_action( 'admin_init', 'ebay_feeds_for_wordpress_add_admin_stylesheet' );
    
    }
    
    function ebay_feeds_for_wordpress_add_admin_stylesheet() {
            wp_register_style( 'ebay-feeds-for-wordpress-style', plugins_url('ebay-feeds-for-wordpress-admin.css', __FILE__) );
            wp_enqueue_style( 'ebay-feeds-for-wordpress-style' );
    }
    
    function ebay_feeds_for_wordpress_menus() {
    
      add_options_page('eBay Feeds Options', 'ebay Feeds For Wordpress', 8, 'ebayfeedforwordpressoptions', 'ebay_feeds_for_wordpress_options');
    
    }
    
    function ebay_feeds_for_wordpress_options() {
    ?>
    Code (markup):
    Hope it's as easy as I think? lol. Thanks. Oh, and heres an EXAMPLE of what it outputs.
     
    Solved! View solution.
    sweetpea69, May 19, 2014 IP
  2. #2
    What you could do is just remove the if/else with $item->get_description(); it seems, and if you add a substr($item->get_title(), 0, 9) to the $item->get_title() it should truncate to 9 characters
     
    PoPSiCLe, May 19, 2014 IP
    sweetpea69 likes this.
  3. sweetpea69

    sweetpea69 Active Member

    Messages:
    490
    Likes Received:
    79
    Best Answers:
    0
    Trophy Points:
    63
    #3
    You're going to need to hold my hand through this lol. It just keeps spitting errors whatever I delete.... never mind, was looking at the wrong section. Thank you very much.
     
    Last edited: May 19, 2014
    sweetpea69, May 19, 2014 IP