Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Contributor contactashish13

    (@rozroz)

    @vegroland please provide an annotated screenshot of where you want the source displayed. Please also paste the entire shortcode you are using so that we can confirm our code snippet will work for you.

    Thread Starter vegroland

    (@vegroland)

    Hello,

    here is the image: https://ibb.co/hcXyZjw

    Now I’am using this hook:

    add_filter( 'feedzy_author_name', 'feedzy_author_name', 10, 3 );
    function feedzy_author_name( $authorName, $feedURL, $item ) {
    	$source		= '';
    	if ( strpos( strtolower( $feedURL ), 'https://www.lavanguardia.com/mvc/feed/rss/home' ) !== false ) {
    		$source	= 'La Vanguardia';
    	}
    	if ( strpos( strtolower( $feedURL ), 'https://ep00.epimg.net/rss/tags/ultimas_noticias.xml' ) !== false ) {
    		$source	= 'El País';
    	}
    	if ( strpos( strtolower( $feedURL ), 'https://estaticos.elmundo.es/elmundo/rss/portada.xml' ) !== false ) {
    		$source	= 'El Mundo';
    	}
    	if ( strpos( strtolower( $feedURL ), 'https://www.europapress.es/rss/rss.aspx' ) !== false ) {
    		$source	= 'Europa Press';
    	}
    	$authorName=$source;
    	return $authorName . ' ' . $source;
    }
    

    $authorName=$source; is used to hide the author.

    With this shortcode:
    [feedzy-rss feeds=”ultimas-noticias” max=”12″ offset=”0″ feed_title=”yes” sort=”date_desc” target=”_blank” title=”140″ meta=”time, tz=source, author” multiple_meta=”source” summary=”yes” summarylength=”140″ thumb=”yes” default=”https://buscarnoticias.es/wp-content/uploads/2020/03/buscarnoticias_favicon.jpg” size=”80″ ]

    Thank you!

    Plugin Contributor contactashish13

    (@rozroz)

    @vegroland I’m confused. Your original post stated that the hook does not work. In the screenshot, it seems that it is working. Can you please clarify the discrepancy and restate the problem so that we can help you better?

    Thread Starter vegroland

    (@vegroland)

    @rozroz no, it doesn’t.
    Please read carefully the hook and see the screenshot.

    On some items the source appears, but most of them not.
    If they appear, then it’s not what is set in the hook.
    You can check it always here: https://buscarnoticias.es/ (“últimas noticias” accordion)

    In the hook is written that e.g:
    from the https://ep00.epimg.net/rss/tags/ultimas_noticias.xml feed it has to be appear “El País” instead of “(últimas noticias | EL PAíS)
    (at the bottom of the screenshot)

    And from different other feeds (there are more) e.g “https://www.europapress.es/rss/rss.aspx” not appear the source name, despite they are set. (first item on the screenshot)

    Thank you to have a look on it!

    • This reply was modified 4 years, 8 months ago by vegroland.
    Plugin Contributor contactashish13

    (@rozroz)

    @vegroland in your case the code snippet will be different as you are using multiple URLs. Use the one below and change it as you wish:

    
    add_filter( 'feedzy_author_name', 'feedzy_author_name', 10, 3 );
    function feedzy_author_name( $authorName, $feedURL, $item ) {
    	$source		= '';
    	if ( is_array( $feedURL ) ) {
    		// if feedURL is multiple urls.
    		foreach ( $feedURL as $feed ) {
    			if ( strpos( strtolower( $feed ), 'https://www.lavanguardia.com/mvc/feed/rss/home' ) !== false ) {
    				$source	= 'La Vanguardia';
    			}
    			if ( strpos( strtolower( $feed ), 'https://ep00.epimg.net/rss/tags/ultimas_noticias.xml' ) !== false ) {
    				$source	= 'El País';
    			}
    			if ( strpos( strtolower( $feed ), 'https://estaticos.elmundo.es/elmundo/rss/portada.xml' ) !== false ) {
    				$source	= 'El Mundo';
    			}
    			if ( strpos( strtolower( $feed ), 'https://www.europapress.es/rss/rss.aspx' ) !== false ) {
    				$source	= 'Europa Press';
    			}
    		}
    	} else {
    		// if feedURL is a single url.
    	}
    	return $source;
    }
    
    Thread Starter vegroland

    (@vegroland)

    Thank you very much @rozroz !

    Yes, now it appears.
    But unfortunately now the source is the same by every feed item.

    What mistake I did?

    Plugin Contributor contactashish13

    (@rozroz)

    @vegroland have you used the exact same code snippet or have you made changes to it?

    Thread Starter vegroland

    (@vegroland)

    @rozroz ,

    of course, without any change.
    The only what I made (to try something after seeing that it doesn’t appear 100% good) is that I changed the feed url to the category’s feed url, where the same feed url is, one by one.

    Both result is the same. It shows up, but only one source name from the whole list.

    This is the entire code that I’m using in the child theme’s function.php:

    <?php
    add_action( 'wp_enqueue_scripts', 'magbook_enqueue_styles' );
    function magbook_enqueue_styles() {
    	wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    /*FEEDZY*/
    
    /*Decrease the cache to the minimum value supported viz. 1 minute*/
    add_filter( 'feedzy_get_short_code_attributes_filter', 'feedzy_get_short_code_attributes_filter', 99, 1 );
    function feedzy_get_short_code_attributes_filter( $atts ) {
    $atts['refresh'] = '1_mins';
    return $atts;
    }
    
    /*Display the name of the website as the source of the feeds*/
    add_filter( 'feedzy_author_name', 'feedzy_author_name', 10, 3 );
    function feedzy_author_name( $authorName, $feedURL, $item ) {
    	$source		= '';
    	
    	if ( is_array( $feedURL ) ) {
    		// if feedURL is multiple urls.
    		foreach ( $feedURL as $feed ) {
    			if ( strpos( strtolower( $feed ), 'la-vanguardia' ) !== false ) {
    				$source	= 'La Vanguardia';
    			}
    			if ( strpos( strtolower( $feed ), 'el-pais' ) !== false ) {
    				$source	= 'El País';
    			}
    			if ( strpos( strtolower( $feed ), 'el-mundo' ) !== false ) {
    				$source	= 'El Mundo';
    			}
    			 if ( strpos( strtolower( $feed ), 'rtve' ) !== false ) {
    				$source	= 'RTVE.es';
    			}
    			 if ( strpos( strtolower( $feed ), 'europapress' ) !== false ) {
    				$source	= 'Europa Press';
    			}
    			 if ( strpos( strtolower( $feed ), 'abc-es' ) !== false ) {
    				$source	= 'ABC';
    			}
    			 if ( strpos( strtolower( $feed ), 'el-periodico' ) !== false ) {
    				$source	= 'El Periódico';
    			}
    			 if ( strpos( strtolower( $feed ), 'la-razon' ) !== false ) {
    				$source	= 'La Razón';
    			}
    			 if ( strpos( strtolower( $feed ), 'expansion' ) !== false ) {
    				$source	= 'Expansión';
    			}
    		}
    	} else {
    		// if feedURL is a single url.
    	}
    	
    	return $source;
    }
    ?>

    This is the shortcode that is used:
    [feedzy-rss feeds="ultimas-noticias" max="12" offset="0" feed_title="no" sort="date_desc" target="_blank" title="140" meta="time, tz=no, author" multiple_meta="" summary="yes" summarylength="140" thumb="yes" default="https://buscarnoticias.es/wp-content/uploads/2020/03/buscarnoticias_favicon.jpg" size="80" ]

    And these are feed urls that are used int the category “ultimas-noticias”:

    https://www.europapress.es/rss/rss.aspx,
    https://ep00.epimg.net/rss/tags/ultimas_noticias.xml,
    https://estaticos.elmundo.es/elmundo/rss/portada.xml,
    https://www.lavanguardia.com/mvc/feed/rss/home,
    https://api2.rtve.es/rss/temas_noticias.xml,
    https://www.abc.es/rss/feeds/abc_ultima.xml,
    https://www.elperiodico.com/es/rss/rss_portada.xml,
    https://www.la-razon.com/rss/latest/?contentType=NWS,
    https://e00-expansion.uecdn.es/rss/portada.xml,
    Plugin Contributor contactashish13

    (@rozroz)

    @vegroland You can try this modified snippet:

    
    function feedzy_author_name( $authorName, $feedURL, $item ) {
    	$source		= '';
    	
    	if ( is_array( $feedURL ) ) {
    		// if feedURL is multiple urls.
    		foreach ( $feedURL as $feed ) {
    			if ( strpos( strtolower( $feed ), 'la-vanguardia' ) !== false ) {
    				$source	= 'La Vanguardia';
    			} elseif ( strpos( strtolower( $feed ), 'el-pais' ) !== false ) {
    				$source	= 'El País';
    			} elseif ( strpos( strtolower( $feed ), 'el-mundo' ) !== false ) {
    				$source	= 'El Mundo';
    			} elseif ( strpos( strtolower( $feed ), 'rtve' ) !== false ) {
    				$source	= 'RTVE.es';
    			} elseif ( strpos( strtolower( $feed ), 'europapress' ) !== false ) {
    				$source	= 'Europa Press';
    			} elseif ( strpos( strtolower( $feed ), 'abc-es' ) !== false ) {
    				$source	= 'ABC';
    			} elseif ( strpos( strtolower( $feed ), 'el-periodico' ) !== false ) {
    				$source	= 'El Periódico';
    			} elseif ( strpos( strtolower( $feed ), 'la-razon' ) !== false ) {
    				$source	= 'La Razón';
    			} elseif ( strpos( strtolower( $feed ), 'expansion' ) !== false ) {
    				$source	= 'Expansión';
    			}
    		}
    	} else {
    		// if feedURL is a single url.
    	}
    	
    	return $source;
    }
    
    Thread Starter vegroland

    (@vegroland)

    @rozroz, no, unfortunately it doesn’t work. :-/
    There are showing only one feed source name (the last one in the code: Expansión) or in a lot of feeds nothing at all.

    Plugin Contributor contactashish13

    (@rozroz)

    @vegroland you should be using the same url name in the filter as you have used in the shortcode. For example, if you are using https://www.lavanguardia.com/mvc/feed/rss/home then the if clause should read if ( strpos( strtolower( $feed ), 'lavanguardia' ) !== false ) { not if ( strpos( strtolower( $feed ), 'la-vanguardia' ) !== false ) {. Also, you may need to add more if conditions to add support for other URLs.

    Thread Starter vegroland

    (@vegroland)

    @rozroz, I don’t undertand it, the category’s feed urls are ok…

    This is the capture of the categories and I use the slug, as link: https://ibb.co/D9qMxBh

    As you can see all url is exactly as the slug.

    So, if I forget it, and use the original feed url in every condition, it would be this:

    add_filter( 'feedzy_author_name', 'feedzy_author_name', 10, 3 );
    function feedzy_author_name( $authorName, $feedURL, $item ) {
    	$source		= '';
    	
    	if ( is_array( $feedURL ) ) {
    		// if feedURL is multiple urls.
    		foreach ( $feedURL as $feed ) {
    			if ( strpos( strtolower( $feed ), 'https://www.lavanguardia.com/mvc/feed/rss/home' ) !== false ) {
    				$source	= 'La Vanguardia';
    			} elseif ( strpos( strtolower( $feed ), 'https://ep00.epimg.net/rss/tags/ultimas_noticias.xml' ) !== false ) {
    				$source	= 'El País';
    			} elseif ( strpos( strtolower( $feed ), 'https://estaticos.elmundo.es/elmundo/rss/portada.xml' ) !== false ) {
    				$source	= 'El Mundo';
    			} elseif ( strpos( strtolower( $feed ), 'https://api2.rtve.es/rss/temas_noticias.xml' ) !== false ) {
    				$source	= 'RTVE.es';
    			} elseif ( strpos( strtolower( $feed ), 'https://www.europapress.es/rss/rss.aspx' ) !== false ) {
    				$source	= 'Europa Press';
    			} elseif ( strpos( strtolower( $feed ), 'https://www.abc.es/rss/feeds/abc_ultima.xml' ) !== false ) {
    				$source	= 'ABC';
    			} elseif ( strpos( strtolower( $feed ), 'https://www.elperiodico.com/es/rss/rss_portada.xml' ) !== false ) {
    				$source	= 'El Periódico';
    			} elseif ( strpos( strtolower( $feed ), 'https://www.la-razon.com/rss/latest/?contentType=NWS' ) !== false ) {
    				$source	= 'La Razón';
    			} elseif ( strpos( strtolower( $feed ), 'https://e00-expansion.uecdn.es/rss/portada.xml' ) !== false ) {
    				$source	= 'Expansión';
    			}
    		}
    	} else {
    		// if feedURL is a single url.
    	}
    	
    	return $source;
    }

    Now this is used, but it’s the same. Doesn’t work well.

    Thread Starter vegroland

    (@vegroland)

    Hello @rozroz, any oher idea?

    Plugin Contributor contactashish13

    (@rozroz)

    @vegroland I feel we are talking about multiple implementations. Let’s clear the board and start afresh. Can you please provide the following?

    1. the full shortcode you are using. If you are using a category, please provide all the URLs as well.
    2. the exact filter you have added
    3. a screenshot and a url of the resultant page
    Thread Starter vegroland

    (@vegroland)

    @rozroz, yes but still working bad. So I still waiting for the working solution.

    Everything what you asked for are above, but I made a new test site with test feed category.
    Here are the details:

    Full shortcode:
    [feedzy-rss feeds="test" max="12" offset="0" feed_title="no" sort="date_desc" target="_blank" title="140" meta="time, tz=no, author" multiple_meta="" summary="yes" summarylength="140" thumb="yes" default="https://buscarnoticias.es/wp-content/uploads/2020/03/buscarnoticias_favicon.jpg" size="80" ]

    Feed category name: Test

    Feed category URLs:

    https://www.europapress.es/rss/rss.aspx,
    https://ep00.epimg.net/rss/tags/ultimas_noticias.xml,
    https://estaticos.elmundo.es/elmundo/rss/portada.xml,
    https://www.lavanguardia.com/mvc/feed/rss/home,
    https://api2.rtve.es/rss/temas_noticias.xml,
    https://www.abc.es/rss/feeds/abc_ultima.xml,
    https://www.elperiodico.com/es/rss/rss_portada.xml,
    https://e00-expansion.uecdn.es/rss/portada.xml

    The filter I’m using:

    add_filter( 'feedzy_author_name', 'feedzy_author_name', 10, 3 );
    function feedzy_author_name( $authorName, $feedURL, $item ) {
    	$source		= '';
    	
    	if ( is_array( $feedURL ) ) {
    		// if feedURL is multiple urls.
    		foreach ( $feedURL as $feed ) {
    			if ( strpos( strtolower( $feed ), 'https://www.lavanguardia.com/mvc/feed/rss/home' ) !== false ) {
    				$source	= 'La Vanguardia';
    			} elseif ( strpos( strtolower( $feed ), 'https://ep00.epimg.net/rss/tags/ultimas_noticias.xml' ) !== false ) {
    				$source	= 'El País';
    			} elseif ( strpos( strtolower( $feed ), 'https://estaticos.elmundo.es/elmundo/rss/portada.xml' ) !== false ) {
    				$source	= 'El Mundo';
    			} elseif ( strpos( strtolower( $feed ), 'https://api2.rtve.es/rss/temas_noticias.xml' ) !== false ) {
    				$source	= 'RTVE.es';
    			} elseif ( strpos( strtolower( $feed ), 'https://www.europapress.es/rss/rss.aspx' ) !== false ) {
    				$source	= 'Europa Press';
    			} elseif ( strpos( strtolower( $feed ), 'https://www.abc.es/rss/feeds/abc_ultima.xml' ) !== false ) {
    				$source	= 'ABC';
    			} elseif ( strpos( strtolower( $feed ), 'https://www.elperiodico.com/es/rss/rss_portada.xml' ) !== false ) {
    				$source	= 'El Periódico';
    			} elseif ( strpos( strtolower( $feed ), 'https://e00-expansion.uecdn.es/rss/portada.xml' ) !== false ) {
    				$source	= 'Expansión';
    			}
    		}
    	} else {
    		// if feedURL is a single url.
    	}
    	
    	return $source;
    }

    I don’t know if it counts or not, but here is the entire content of the funtions.php and the list of filters:

    <?php
    add_action( 'wp_enqueue_scripts', 'magbook_enqueue_styles' );
    function magbook_enqueue_styles() {
    	wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    /*FEEDZY*/
    
    /*Decrease the cache to the minimum value supported viz. 1 minute*/
    add_filter( 'feedzy_get_short_code_attributes_filter', 'feedzy_get_short_code_attributes_filter', 99, 1 );
    function feedzy_get_short_code_attributes_filter( $atts ) {
    $atts['refresh'] = '1_mins';
    return $atts;
    }
    /*Display the name of the website as the source of the feeds*/
    
    add_filter( 'feedzy_author_name', 'feedzy_author_name', 10, 3 );
    function feedzy_author_name( $authorName, $feedURL, $item ) {
    	$source		= '';
    	
    	if ( is_array( $feedURL ) ) {
    		// if feedURL is multiple urls.
    		foreach ( $feedURL as $feed ) {
    			if ( strpos( strtolower( $feed ), 'https://www.lavanguardia.com/mvc/feed/rss/home' ) !== false ) {
    				$source	= 'La Vanguardia';
    			} elseif ( strpos( strtolower( $feed ), 'https://ep00.epimg.net/rss/tags/ultimas_noticias.xml' ) !== false ) {
    				$source	= 'El País';
    			} elseif ( strpos( strtolower( $feed ), 'https://estaticos.elmundo.es/elmundo/rss/portada.xml' ) !== false ) {
    				$source	= 'El Mundo';
    			} elseif ( strpos( strtolower( $feed ), 'https://api2.rtve.es/rss/temas_noticias.xml' ) !== false ) {
    				$source	= 'RTVE.es';
    			} elseif ( strpos( strtolower( $feed ), 'https://www.europapress.es/rss/rss.aspx' ) !== false ) {
    				$source	= 'Europa Press';
    			} elseif ( strpos( strtolower( $feed ), 'https://www.abc.es/rss/feeds/abc_ultima.xml' ) !== false ) {
    				$source	= 'ABC';
    			} elseif ( strpos( strtolower( $feed ), 'https://www.elperiodico.com/es/rss/rss_portada.xml' ) !== false ) {
    				$source	= 'El Periódico';
    			} elseif ( strpos( strtolower( $feed ), 'https://e00-expansion.uecdn.es/rss/portada.xml' ) !== false ) {
    				$source	= 'Expansión';
    			}
    		}
    	} else {
    		// if feedURL is a single url.
    	}
    	
    	return $source;
    }/*Override and force to show default image when it's blank*/
    add_filter('feedzy_thumb_output', 'feedzy_thumb_output', 10, 4 );
    		function feedzy_thumb_output($contentThumb, $feedURL, $sizes, $item){
    			if ( strpos( $contentThumb, 'https://www.elmundo.es/rss/index.xml' ) !== false ) {
    				$contentThumb = '<img src="https://buscarnoticias.es/wp-content/uploads/2020/03/buscarnoticias_favicon.jpg">';
    			}
    			return $contentThumb;
    		}
    ?>

    Screenshot of the page: https://ibb.co/Dg2Zyz3

    URL of the page: https://buscarnoticias.es/test-feedzy/

    Thank you!

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Source name’ is closed to new replies.