/* 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

Marzo 2015
3625

[AS 178] Playas

Nuestras cámaras estuvieron captando los mejores momentos del verano por las…

Marzo 2015
6144

[AS 177] Tanto movimiento

Te mostramos toda la movida de los mejores eventos de Lima…

Marzo 2015
1065

[AS 177] Tennis Open, Asia 2015

Se llevó a cabo la segunda fecha del campeonato “KIA Tennis…

Marzo 2015
911

[AS 177] XIX Interplayas de Fútbol 7, Copa Barbacci motors

La segunda fecha del XIX Torneo Interplayas de Fútbol 7 tuvo…

Marzo 2015
987

[AS 177] Las 200 funciones de Toc Toc

La exitosa comedia dirigida por Juan Carlos Fisher regresó a la…

Marzo 2015
2161

[AS 177] Experiencia Citigold

Playa el Golf, en Asia, fue el escenario del “Citigold World…

Marzo 2015
988

[AS 177] El Audi R8 vivió el preestreno de la película “Cincuenta Sombras de Grey”

El pasado miércoles 11 de febrero Audi, la reconocida marca de…

Marzo 2015
2404

[AS 177] Luau en Poseidón

El Club Náutico de Playa Poseidón festejó el tradicional Luau de…

Marzo 2015
1432

[AS 177] Arte en Ancón

El pasado viernes 13 los asistentes al Yacht Club de Ancón…

Marzo 2015
1316

[AS 177] Reunión por la amistad

La Asociación de deportistas ‘Los Acuanautas’ realizó una fraternal celebración para…

Marzo 2015
2377

[AS 177] Lanchada en Ancón

El pasado sábado 14 de febrero, se realizó el Boat Fest…

Marzo 2015
3807

[AS 177] Carnavales en Nikita

Las fiestas en la discoteca Nikita no paran. El pasado viernes…

Página 10 de 122« Primera...89101112...203040...Última »