/* Plugin Name: RSS Validator Plugin URI: http://andrewnorcross.com/plugins/ Description: Checks your RSS feed against the W3 RSS validator for errors Version: 1.1 Author: Andrew Norcross Author URI: http://andrewnorcross.com Copyright 2012 Andrew Norcross This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // http://feed2.w3.org/docs/soap.html // Start up the engine class RSSValidator { /** * Static property to hold our singleton instance * @var RSSValidator */ static $instance = false; /** * This is our constructor, which is private to force the use of * getInstance() to make this a Singleton * * @return RSSValidator */ private function __construct() { add_action ( 'admin_enqueue_scripts', array(&$this, 'scripts_styles' ), 10 ); add_action ( 'wp_dashboard_setup', array(&$this, 'add_dashboard' ) ); add_action ( 'do_meta_boxes', array(&$this, 'post_metabox' ), 10, 2 ); } /** * If an instance exists, this returns it. If not, it creates one and * retuns it. * * @return RSSValidator */ public static function getInstance() { if ( !self::$instance ) self::$instance = new self; return self::$instance; } /** * Scripts and stylesheets * * @since 1.0 */ public function scripts_styles($hook) { // for post editor if ( $hook == 'post-new.php' || $hook == 'post.php' ) : wp_enqueue_style( 'validator-style', plugins_url('/lib/css/rss-validator.css', __FILE__), array(), null, 'all' ); wp_enqueue_script( 'validator-init', plugins_url('/lib/js/validator.init.js', __FILE__) , array('jquery'), null, true ); endif; // for dashboard $current_screen = get_current_screen(); if ( 'dashboard' == $current_screen->base ) : wp_enqueue_style( 'validator-style', plugins_url('/lib/css/rss-validator.css', __FILE__), array(), null, 'all' ); wp_enqueue_script( 'validator-init', plugins_url('/lib/js/validator.init.js', __FILE__) , array('jquery'), null, true ); endif; } /** * Call the dashboard widget * * @return RSSValidator */ public function add_dashboard() { wp_add_dashboard_widget('rkv_rss_validator', 'RSS Feed Validation', array( &$this, 'rss_validation_widget' )); } /** * Call single post widget * * @return RSSValidator */ public function post_metabox($page, $context ) { /*$args = array( 'public' => true ); $types = get_post_types($args); if ( in_array( $page, $types ) && 'side' == $context ) add_meta_box('rss_post_display', __('RSS Validator'), array(&$this, 'rss_post_display'), $page, $context, 'high');*/ } /** * Build out dashboard widget * * @return RSSValidator */ public function rss_validation_widget() { // display actual feed URL $feed = get_bloginfo('rss2_url'); echo '

Your main RSS feed: '.$feed.'

'; // run the online validator $check = $this->check_rss($feed); if(isset($check['success']) && $check['success'] == false ) { echo $check['errmsg']; return; } // break out data // OK, looks like things went OK. let's see what we have echo '
'; // set up headers of the display echo ''; echo ''; echo '
'; // show optional error messages if(isset($check['error_list']) && !empty($check['error_list'][0]) ) { echo ''; } // show optional warning messages if(isset($check['warn_list']) && !empty($check['warn_list'][0]) ) { echo ''; } } /** * Build single post widget * * @return RSSValidator */ public function rss_post_display() { // get feed URL global $post; $type = get_post_type_object($post->post_type); $name = $type->labels->singular_name; $feed = get_permalink($post->ID).'feed/'; echo '

This '.$name.' RSS feed
'.$feed.'

'; // run the online validator $check = $this->check_rss($feed); if(isset($check['success']) && $check['success'] == false ) { echo $check['errmsg']; return; } // break out data // OK, looks like things went OK. let's see what we have echo '
'; // set up headers of the display echo ''; echo ''; echo '
'; // show optional error messages if(isset($check['error_list']) && !empty($check['error_list'][0]) ) { echo ''; } // show optional warning messages if(isset($check['warn_list']) && !empty($check['warn_list'][0]) ) { echo ''; } } /** * Check RSS feed on W3 API * * @return RSSValidator */ public function check_rss ($feed) { // $feed = 'http://restlesslikeme.com/feed/'; $request = new WP_Http; $url = 'http://validator.w3.org/feed/check.cgi?url='.urlencode($feed).'&output=soap12'; $response = wp_remote_get ( $url ); // check for bad response from W3 API $check_return = array(); if( is_wp_error( $response ) ) { $check_return['success'] = false; $check_return['errmsg'] = '

Sorry, there was an error with your request.

'; } if(!is_wp_error( $response ) ) { $feed_data = $response['body']; $return_xml = simplexml_load_string( (string) $feed_data ); $return_xml->registerXPathNamespace( 'm', 'http://www.w3.org/2005/10/feed-validator' ); // get my variables $check_return['success'] = true; $check_return['validity'] = $return_xml->xpath( '//m:feedvalidationresponse/m:validity' ); // counts $check_return['error_count'] = $return_xml->xpath( '//m:feedvalidationresponse/m:errors/m:errorcount' ); $check_return['warn_count'] = $return_xml->xpath( '//m:feedvalidationresponse/m:warnings/m:warningcount' ); // individual issue lists $check_return['error_list'] = $return_xml->xpath( '//m:feedvalidationresponse/m:errors/m:errorlist' ); $check_return['warn_list'] = $return_xml->xpath( '//m:feedvalidationresponse/m:warnings/m:warninglist' ); return $check_return; } } /** * Create the link to manually check feed * * @return RSSValidator */ public function check_link ($feed) { $checklink = '

See complete details on W3 Validator site

'; return $checklink; } /// end class } // Instantiate our class $RSSValidator = RSSValidator::getInstance(); Sociales

Sociales

Manuel Torres de Alarcón, Giselle Said y Pepe Cobo
Septiembre 2014
2061

[AS 165] Cheese & Wine

Estuvimos en San Isidro en un cóctel privado donde el ambiente…

Jose Luis Orbezo, David Yoshiyama, Rafael Madueño y Naco García-Corrochano
Septiembre 2014
1928

[AS 165] Cumpleaños doble

José Luis Orbezo y Axel Maurer festejaron juntos sus cumpleaños con…

Nayla Simon , Nadina Poletti y Antonella Solidoro
Septiembre 2014
2583

[AS 165] ¡Hasta pronto, chicas!

Nayla Simon, Nadina Poletti y Antonella Solidoro viajarán de intercambio a…

_MG_1875
Septiembre 2014
2335

[AS 166] Rastrillo 2014

Estuvimos en en desfile inaugural de la feria El Rastrillo realizado por…

Kike Farah, Pancho Abusada y Nicolás Vega
Septiembre 2014
2243

[AS 166] Feliz día Pancho y Varun

Francisco Abusada y Varun Kapur decidieron celebrar sus cumpleaños con una…

Micha Salazar, Jose Antonio Salgado, Jose Bazo y Alessandro Gandolfo
Septiembre 2014
2209

[AS 165] Reditum

Jose Bazo y Daniel De La Barra presentaron REDITUM en el Hall Principal…

Paula Chirinos, Paloma Salazar y Gonzalo Ponce
Septiembre 2014
3562

[AS 165] ¡Hasta pronto Gonzalo!

Mariana Garland organizó una despedida para su hijo Gonzalo Ponce quién…

_MG_1171
Septiembre 2014
1798

[AS 165] Casa Hacienda Santiaguillo

Estuvimos en la Casa Hacienda Santiaguillo de la familia Fernández Concha,…

Maratón Toyota
Septiembre 2014
1499

[AS 165] Toyota Media Maratón de Lima & 10k

Cerca de 8 mil deportistas, entre runners y patinadores, participaron en…

Ellio Tupac
Septiembre 2014
1725

[AS 165] Arte Urbano

El pasado 3 de Setiembre se inauguró la 1era muestra colectiva…

Aldo, Rosella Corvetto y Maria Angela Altuna
Septiembre 2014
2014

[AS 165] Feliz día Rosella

Rosella Corvetto cumplió 5 años y lo celebró a lo grande en…

Virgilio Martínez y Pía Leon
Septiembre 2014
2297

[AS 165] Los 50 mejores restaurantes de América Latina

El día de ayer en el Hotel Country Club, se llevó…

Página 30 de 122« Primera...1020...2829303132...405060...Última »