Plugin Directory

Changeset 1650593


Ignore:
Timestamp:
05/03/2017 09:25:48 PM (9 years ago)
Author:
potatomaster
Message:

Releasing version 1.2.7

Location:
publish-to-apple-news/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • publish-to-apple-news/trunk/admin/apple-actions/index/class-push.php

    r1596636 r1650593  
    155155        $this->process_errors( $errors );
    156156
    157         // Validate the data before using since it's filterable.
    158         // JSON should just be a string.
    159         // Apple News format is complex and has too many options to validate otherwise.
    160         // Let's just make sure it's not doing anything bad and is the right data type.
    161         $json = sanitize_text_field( $json );
     157        // Sanitize the data before using since it's filterable.
     158        $json = $this->sanitize_json( $json );
    162159
    163160        // Bundles should be an array of URLs
     
    387384        return array( $this->exporter->get_json(), $this->exporter->get_bundles(), $this->exporter->get_errors() );
    388385    }
     386
     387    /**
     388     * Sanitize the JSON output based on whether HTML or markdown is used.
     389     *
     390     * @access private
     391     * @param string $json
     392     * @return string
     393     * @since 1.2.7
     394     */
     395    private function sanitize_json( $json ) {
     396        // Apple News format is complex and has too many options to validate otherwise.
     397        // Let's just make sure the JSON is valid
     398        $decoded = json_decode( $json );
     399        if ( ! $decoded ) {
     400             throw new \Apple_Actions\Action_Exception( __( 'The Apple News JSON is invalid and cannot be published.', 'apple-news' ) );
     401        } else {
     402             return wp_json_encode( $decoded );
     403        }
     404    }
    389405}
  • publish-to-apple-news/trunk/admin/class-admin-apple-themes.php

    r1642765 r1650593  
    694694    private function validate_data( $data ) {
    695695        $settings = new \Apple_Exporter\Settings();
    696         $valid_settings = array_keys( $settings->all() );
     696        $default_settings = $settings->all();
    697697        $clean_settings = array();
    698698
     
    719719        foreach ( $valid_settings as $setting ) {
    720720            if ( ! isset( $data[ $setting ] ) ) {
    721                 return sprintf(
    722                     __( 'The theme was missing the required setting %s', 'apple-news' ),
    723                     $setting
    724                 );
     721                // Get the default value instead.
     722                // This ensures backwards compatiblity with theme files
     723                // when new settings are added in future plugin versions.
     724                if ( isset( $default_settings[ $setting ] ) ) {
     725                    $data[ $setting ] = $default_settings[ $setting ];
     726                } else {
     727                    return sprintf(
     728                        __( 'The theme was missing the required setting %s and no default was found', 'apple-news' ),
     729                        $setting
     730                    );
     731                }
    725732            }
    726733
  • publish-to-apple-news/trunk/apple-news.php

    r1642765 r1650593  
    1313 * Plugin URI:  http://github.com/alleyinteractive/apple-news
    1414 * Description: Export and sync posts to Apple format.
    15  * Version:     1.2.6
     15 * Version:     1.2.7
    1616 * Author:      Alley Interactive
    1717 * Author URI:  https://www.alleyinteractive.com
  • publish-to-apple-news/trunk/includes/apple-exporter/components/class-component.php

    r1642765 r1650593  
    145145
    146146    /**
     147     * Allowed HTML tags for components that support it.
     148     *
     149     * @since 1.2.7
     150     * @var array
     151     * @access public
     152     */
     153    public $allowed_html = array(
     154        'p' => array(),
     155        'strong' => array(),
     156        'b' => array(),
     157        'em' => array(),
     158        'i' => array(),
     159        'a' => array(
     160            'href' => array(),
     161        ),
     162        'ul' => array(),
     163        'ol' => array(),
     164        'li' => array(),
     165        'br' => array(),
     166        'sub' => array(),
     167        'sup' => array(),
     168        'del' => array(),
     169        's' => array(),
     170        'pre' => array(),
     171        'code' => array(),
     172        'samp' => array(),
     173        'footer' => array(),
     174        'aside' => array(),
     175        'blockquote' => array(),
     176    );
     177
     178    /**
    147179     * Constructor.
    148180     *
     
    234266     */
    235267    public function to_array() {
     268        // If HTML support is enabled, provide an extra level of validation for supported tags.
     269        if ( ! empty( $this->json['text'] ) && $this->html_enabled() ) {
     270            $this->json['text'] = wp_kses( $this->json['text'], $this->allowed_html );
     271        }
     272
    236273        return apply_filters( 'apple_news_' . $this->get_component_name() . '_json', $this->json );
    237274    }
  • publish-to-apple-news/trunk/includes/class-apple-news.php

    r1642765 r1650593  
    4040     * @access public
    4141     */
    42     public static $version = '1.2.6';
     42    public static $version = '1.2.7';
    4343
    4444    /**
  • publish-to-apple-news/trunk/readme.txt

    r1642765 r1650593  
    44Tags: publish, apple, news, iOS
    55Requires at least: 4.0
    6 Tested up to: 4.7.3
    7 Stable tag: 1.2.6
     6Tested up to: 4.7.4
     7Stable tag: 1.2.7
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl.html
     
    4545
    4646== Changelog ==
     47
     48= 1.2.7 =
     49* Fixed a bug where HTML tags were being stripped before being sent to the API.
     50* Fixed a bug where older theme files couldn't be imported if new formatting settings were added.
    4751
    4852= 1.2.6 =
Note: See TracChangeset for help on using the changeset viewer.