"The Word" scripture columns on Sunday readings from America magazine. Author: America Media Version: 2.0 Author URI: https://www.americamagazine.org License: GPL2 */ // Don't call the file directly if ( !defined( 'ABSPATH' ) ) exit; /* Define */ define( 'AM_WORD_URL', plugins_url( '/' ) . plugin_basename( dirname( __FILE__ ) ) . '/' ); define( 'AM_WORD_PATH', plugin_dir_path( __FILE__ ) ); class America_Magazine_The_Word_Widget extends WP_Widget{ public function am_register_widget_styles() { wp_enqueue_style( 'america-styles', AM_WORD_URL . 'source/css/style.css' ); } public function __construct() { parent::__construct( 'america-magazine-the-word-widget','The Word: Catholic Scripture Reflections', array( 'description' => 'A widget and shortcode that displays links to the next two columns for America magazine\'s "The Word" scripture column. Place as a widget or use the shortocde [the_word].' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'amword_register_widget_styles' ) ); } public function amword_register_widget_styles() { wp_enqueue_style( 'am-the-word-style', AM_WORD_URL . 'source/css/style.css' ); } public static function output( $args ) { $template = @$args[0] ? : @$args['template']; // Update plugin version number for tracking $ver = 'v2.0'; // Start building the contents of the widget // This week $twurl = 'https://www.americamagazine.org/rest/views/theword-thisweek?utm_source=wpplugin&utm_medium=' . $ver ; $twresponse = wp_remote_get( esc_url_raw( $twurl ) ); if( is_wp_error( $twresponse ) ) { return false; // Do not render widget } else { $twapi_response = json_decode( wp_remote_retrieve_body( $twresponse ), true ); } // Next week $nwurl = 'https://www.americamagazine.org/rest/views/theword-nextweek?utm_source=wpplugin&utm_medium=' . $ver; $nwresponse = wp_remote_get( esc_url_raw( $nwurl ) ); if( is_wp_error( $nwresponse ) ) { return false; // Do not render widget } else { $nwapi_response = json_decode( wp_remote_retrieve_body( $nwresponse ), true ); } ob_start(); ?>

Go deeper into this Sunday’s Mass readings

This week

Next week


'', 'template' => 'america' ); $instance = wp_parse_args( ( array ) $instance, $defaults ); $options = array( 'america' => 'Full', 'none' => 'Simple' ); ?>