/* 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(); Concurso el mejor selfie - Campaña GoPRo - Revista ASIA SUR

Concurso el mejor selfie

GoPro
¿Quieres ganar una cámara GoPro Hero 4 silver?

Sigue estos pasos:

Tómate una selfie y compártela en Instagram con el hashtag #viveasiasur. La mejor foto de la semana será colocada aquí, en nuestro fanpage. Al final de la temporada escogeremos solo una. ¡Se creativo y usa todas tus vibras veraniegas!

Concursa del 19 de febrero al 8 de abril.
Elección del ganador: 15 de abril