WordPress.org

Plugin Directory

Changeset 1558569


Ignore:
Timestamp:
12/20/16 19:25:20 (8 months ago)
Author:
potatomaster
Message:

Releasing version 1.2.0 of Apple News

Location:
publish-to-apple-news
Files:
7 added
1 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • publish-to-apple-news/trunk/README.md

    r1485664 r1558569  
    11#Publish to Apple News 
    22 
    3 ##Installation 
     3The Publish to Apple News plugin enables your WordPress blog content to be published to your Apple News channel. 
    44 
    5 Installing the Publish to Apple News plugin is similar to the process of 
    6 installing other WordPress plugins. Simply perform these steps: 
     5* Convert your WordPress content into Apple News format automatically. 
     6* Create a custom design for your Apple News content with no programming knowledge required. 
     7* Automatically or manually publish posts from WordPress to Apple News. 
     8* Control individual posts with options to publish, update, or delete. 
     9* Publish individual posts or in bulk. 
     10* Handles image galleries and popular embeds like YouTube and Vimeo that are supported by Apple News. 
     11* Automatically adjust advertisement settings. 
    712 
    8 1. Download the Publish to Apple News plugin. 
    9 2. Upload the entire “publish-to-apple-news” folder to the “./wp-content/plugins” directory 
    10    on your web server. 
    11 3. Activate the Publish to Apple News plugin using the “Plugins” menu in 
    12    WordPress. 
     13To enable content from your WordPress blog to be published to your Apple News channel, you must obtain and enter Apple News API credentials from Apple. 
    1314 
    14 Once activated, the "Apple News" menu should appear in your WordPress Admin 
    15 panel. 
     15Please see the [Apple Developer](https://developer.apple.com/) and [Apple News Publisher documentation](https://developer.apple.com/news-publisher/) and terms on Apple's website for complete information. 
    1616 
    17 NEW IN 1.1.6: More descriptive errors messages to allow for easier troubleshooting, 
    18 especially for those without access to the News Preview tool. 
     17#Wiki 
    1918 
    20 NEW IN 1.1.4: We've made some improvements to the default template built into the plugin. 
    21 Although it won't override your current settings, we strongly recommend placing the 
    22 Cover image at the top of the Component Order settings for the best experience. 
    23  
    24 BREAKING CHANGE IN 1.1: Please note the "Options" page has been merged into a single 
    25 page for setting sections, preview and pull quotes when pushing content to Apple News. 
    26 This both adds functionality and streamlines the workflow. 
    27  
    28 ### Troubleshooting: Resolving Image Issues 
    29  
    30 Until recently, Apple News required all images to be bundled with the API request. 
    31 Some hosts do not support [allow_url_fopen](http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen), which is required for this functionality to work. 
    32 Apple News now supports remote images so if you are experiencing any errors with images, 
    33 please go to Settings > Apple News and set Use Remote Images to 'yes' under Advanced Settings. 
    34 Please note that in order for this to work, your images must be publicly accessible which 
    35 is the case for most sites. However, if you're testing on a local development site, your 
    36 images are likely not accessible and therefore you should set this to 'no'. 
    37  
    38  
    39 ###Troubleshooting: Resolving Potential Permissions Issues 
    40  
    41 In most cases, the Publish to Apple News plugin should function immediately once 
    42 installed. However, in some cases the default permissions WordPress has set for 
    43 the plugin directory may be too restrictive to allow plugins to function 
    44 properly. If you encounter errors, you may need to modify the permissions of 
    45 both the “./apple-export/workspace” and the  “./apple-export/workspace/tmp” 
    46 directories. In most cases, setting permissions for these two directories to 
    47 “775” will enable plugins to function properly. For additional information and 
    48 detailed instructions for setting WordPress directory permissions, please see 
    49 [this WordPress technical post](http://codex.wordpress.org/Changing_File_Permissions). 
    50  
    51 ##Configuration 
    52  
    53 Once the Publish to Apple News plugin has been installed and activated, the next 
    54 step is configuration. To begin, choose *Settings > Apple News* from the 
    55 WordPress Admin panel. 
    56  
    57 ###Publishing your WordPress Site to Apple News 
    58  
    59 This plugin is not responsible for setting up or managing your News Publisher 
    60 channel with Apple, nor does using this plugin guarantee that Apple News will 
    61 accept your content. Some information and links to documentation are provided 
    62 here to point you in the right direction for this process. Please see the Apple 
    63 Developer and Apple News Publisher documentation and terms on Apple’s website 
    64 for complete information. 
    65  
    66 To enable content from your WordPress blog to be published to your Apple News 
    67 channel, you must obtain and enter your Apple News API credentials from Apple to 
    68 enable your WordPress content to be published to Apple News. 
    69  
    70 To obtain these credentials, click the “Apple News documentation” link at the 
    71 top of the “API Settings” subsection of *Settings > Apple News*. This link will 
    72 direct you to instructions for obtaining your credentials. Once you receive them 
    73 from Apple, enter your private API Key, Secret, and Channel settings into the 
    74 “Apple News API” fields. Once entered, you can begin publishing WordPress site 
    75 content to Apple News. 
    76  
    77 ###General (Site-wide) Settings 
    78  
    79 Once your WordPress site has been linked to your Apple News channel, your next 
    80 step is to configure site-wide general settings that determine how your content 
    81 will be published to Apple News. You may want to review these site-wide settings 
    82 on occasion. 
    83  
    84 ####Choosing How Content is Published to Apple News 
    85  
    86 The most important setting is the “Automatically Publish to Apple News” setting, 
    87 located at the bottom of the “Apple News API” subsection of *Settings > Apple 
    88 News*. 
    89  
    90 By default, this option is set to **Yes**, so that whenever you publish or 
    91 update an article on your own WordPress site, the article will also be 
    92 automatically pushed to your Apple News channel, without any additional action 
    93 or customization on your part. In most cases, this setting is recommended. 
    94  
    95 If you would instead prefer more granular control over which content is posted 
    96 to your Apple News channel, set “Automatically Publish…” to **No**. With this 
    97 setting, new content posted to your site will *not* be automatically pushed to 
    98 your Apple News channel. In this case, you will need to manually push any posts 
    99 you create, or later modify, to Apple News (this process is described in 
    100 “Per-Post Settings” below). 
    101  
    102 ####Set Default Formatting 
    103  
    104 The “Formatting” subsection of *Settings > Apple News* provides options that 
    105 determine the general appearance for how posts in Apple News should appear. 
    106 These settings are relatively detailed, giving you a higher level of control 
    107 over how your content should appear. Note that if you do not apply specific 
    108 preferences, the default settings have been designed so that your content will 
    109 have a consistent, professional appearance. 
    110  
    111 ####Advanced Settings 
    112  
    113 Advanced settings allow you to set custom content height settings. In most 
    114 cases, the default settings will provide the best results. However, you can also 
    115 enter custom values if desired (values are typographical point sizes). To return 
    116 to the default values, simply clear any values entered into these fields. 
    117  
    118 ##Usage 
    119  
    120 Once the above steps are completed, you’re ready to publish content to Apple 
    121 News. If you’ve chosen to automatically publish your blog content to Apple News, 
    122 all posts created and updated from this time forward will automatically be 
    123 pushed to your Apple News channel. If you’ve disabled Automatic Publishing to 
    124 Apple News, the following section describes the tools you’ll use to manually 
    125 publish selected posts from your WordPress site to Apple News. 
    126  
    127 In addition, no matter which Automatic Publishing option you’ve selected, this 
    128 section describes how you can override general settings for any specific post as 
    129 desired. 
    130  
    131 ###The “Apple News” Admin Panel Menu 
    132  
    133 The “Apple News” menu (not to be confused with the site-wide *Settings > Apple 
    134 News* described in the previous section) provides important tools and settings 
    135 for specific posts. 
    136  
    137 ####Controlling Individual Posts 
    138  
    139 The top section of the “Apple News” pane provides a dashboard-like view that 
    140 displays each post you’ve published on your WordPress blog, as well as whether 
    141 each post has been published to your Apple News channel, and if so, the date of 
    142 the latest update. In addition, individual and bulk controls give you granular 
    143 control over each post. 
    144  
    145 As described above, if you’ve chosen to automatically publish content to Apple 
    146 News, each new post that you publish (or later update) on your own WordPress 
    147 site will also be automatically pushed to your Apple News channel. In this case, 
    148 your primary use of these settings will likely be to override any posts you 
    149 choose not to publish to Apple News. 
    150  
    151 On the other hand, if you’ve chosen *not* to automatically publish your content 
    152 to Apple News, you will likely use these settings much more frequently. These 
    153 settings will be the tool you’ll use each time you wish to initially publish — 
    154 or later update — WordPress posts to Apple News. 
    155  
    156 ####Individual Controls 
    157  
    158 To publish a single post to your Apple News channel (or perform other actions), 
    159 locate the desired post in the list of your locally published content, and hover 
    160 your mouse immediately below the post’s title. This will display a contextual 
    161 menu, presenting the following choices: “Download” and “Publish”. In 
    162 addition, for posts already published to Apple News, two more choices will be 
    163 displayed: “Delete from Apple News” and “Copy News URL“. 
    164  
    165 Choosing “Publish” will take you to a screen where you can select the sections to publish 
    166 to, set the article as a preview, and optionally add a Pull Quote for the selected 
    167 post. In addition to entering a pull quote, you can choose to place it at the 
    168 top, middle, or bottom of the selected post. Click the button at the bottom to push the 
    169 current version of the selected post to Apple News 
    170  
    171 Choosing “Delete from Apple News” will permanently remove the post from 
    172 Apple News. You can override either choice at any future time (e.g., a post 
    173 deleted from Apple News can later be published once again if desired). Note that 
    174 once a post has been deleted from Apple News, no further updates will 
    175 automatically be published to Apple News, regardless of whether you’ve enabled 
    176 “Automatically Publish to Apple News” in your general settings. 
    177  
    178 The “Download” option will generate a JSON document describing the selected post to your 
    179 browser’s default Downloads location. 
    180  
    181 ####Bulk Publishing Controls 
    182  
    183 Bulk actions can be particularly helpful for pushing older content to your Apple 
    184 News channel. This is because Automatic Publishing only takes effect on content 
    185 created or modified after the Publish to Apple News plugin has been installed. 
    186 Therefore, to push a number of pre-existing posts to Apple News, Bulk Publishing 
    187 can save significant time and redundant steps. 
    188  
    189 *Warning: Using Bulk Publishing for a large number of pre-existing posts at one 
    190 time may require significant processing time and server resources. It is 
    191 recommended that you test this feature with smaller batches of pre-existing 
    192 posts first.* 
    193  
    194 You can choose to publish several posts to your Apple News channel at once, 
    195 using the *Bulk Actions* control located at the top left of this section. Simply 
    196 check any number of desired posts, then select “publish” from the Bulk Actions 
    197 menu. This will open a page displaying the posts you’ve selected, and the status 
    198 of each post as it is pushed to Apple News. Note that while bulk publishing 
    199 actions are in progress, you should not close your browser window or navigate 
    200 away from this page. Doing so will halt the bulk action in progress. 
    201  
    202 Bulk publishing will use the default section for your channel unless you have previously 
    203 set the channel via the Apple News meta box on the post edit screen. 
    204  
    205  
    206 ###Tips 
    207  
    208 In general, little effort should be required to prepare your content itself for 
    209 publishing to Apple News once you’ve configured this plugin to your desired 
    210 settings. Even so, these simple tips will help your content look its best: 
    211  
    212 ####Controlling Image Placement 
    213  
    214 By default, images inserted in your content will be placed inline, and will 
    215 follow WordPress placement rules. You may find your images will be presented 
    216 better within Apple News if you take the time to set the appearance of each 
    217 image. To do this, in the WordPress text editor, click on an image, which will 
    218 display a contextual alignment menu. This will provide you with a series of 
    219 simple granular controls, allowing you to determine more precisely where each 
    220 image will be displayed when your post appears in Apple News. 
    221  
    222 The featured image on your post will automatically be used as the Apple News cover 
    223 image. If no featured image is found, the first available image in the post will be used 
    224 as the cover and will be automatically removed from the body in order to avoid duplication. 
    225  
    226 Note that images smaller than the body width (~1024px) will always be aligned. 
    227 If you want to display an image without alignment, make sure it’s big enough. 
    228  
    229 ####Banners 
    230  
    231 You may also select an image to appear as a banner at the top of your post. To 
    232 do this, choose a [featured image](https://en.support.wordpress.com/featured-images/) 
    233 by clicking on the “Set Featured Image” link when creating or updating a post. 
    234 The image will displayed full width at the top of the selected post. 
    235  
    236 ####Image Galleries 
    237  
    238 You can add image galleries the same way you do in WordPress, by using the “Add 
    239 Media” button in the WordPress editor. Once there, navigate to “Create Gallery” 
    240 and choose any images you want. Once done, choose to use “Full Size” images 
    241 instead of thumbnails. By default, galleries will be shown as a horizontal 
    242 slide; if desired, you can change this to “Mosaic” style in the plugin settings. 
    243  
    244 ####Advertisement 
    245  
    246 While this plugin is not responsible for managing advertising options for your 
    247 Apple News channel, it does provide simple settings to help you prepare your 
    248 content for this. Please see the Apple News Publisher and iAds documentation and 
    249 terms on Apple’s website for more information about advertising options on Apple 
    250 News. 
    251  
    252 By default, your exported posts should be ready to include advertising content 
    253 somewhere in the middle of your content. If you don’t want your WordPress 
    254 content to be prepared in this way, simply set the “Advertisement” option in the 
    255 plugin settings to **No**. 
    256  
    257 # For developers 
    258 If you are a developer, feel free to keep reading if you want to contribute. Publish to Apple News WordPress plugin works only on the admin-side so no `public/` folder. 
    259  
    260 ## Coding standards 
    261 PHP code must follow WordPress [Coding 
    262 Standards](https://codex.wordpress.org/WordPress_Coding_Standards). 
    263  
    264 Using [EditorConfig](http://editorconfig.org) is recommended so files always 
    265 use the same formatting. 
    266  
    267 ## Requirements 
    268 In order to work with the plugin, you'll need a webserver such as Apache with 
    269 PHP 5.3.6+ and MySQL 5+. 
    270  
    271 It's recommended to create a symbolic link for better code organization. 
    272  
    273 1. `git clone ssh://... apple-export` 
    274 2. `cd apple-export` 
    275 3. `ln -s /home/my-user/my-projects/wppl /var/www/my-wp-installation/wp-content/plugins/apple-export` 
    276  
    277 Make sure `/home/my-user` has execute permissions or WordPress might not show it 
    278 as a plugin. You can do so by doing `chmod o+x /home/my-user`. 
    279  
    280 ### PHP Configuration 
    281 Make sure PHP's `memory_limit` setting is big enough, or set to -1, as the 
    282 plugin might work with big images. Also make sure PHP's upload limit is big enough. 
    283  
    284 ## Running tests 
    285 You'll need PHPUnit v4.5+ to run tests. Initially you'll need to set up the 
    286 test environment, you can do so by running 
    287  
    288     bin/install-wp-tests.sh <db-name> <db-user> <db-pass> [db-host] [wp-version] 
    289  
    290 For example 
    291  
    292     bin/install-wp-tests.sh wp_test root '' localhost latest 
    293  
    294 That script will download latest wordpress as well as latest wordpress' tests so 
    295 `/tests/bootstrap.php` can load them. 
    296  
    297 You'll also need to set up your API credentials using your system's 
    298 environmental variables. For UNIX systems (OS X, Linux, etc) you can simply edit 
    299 the `~/.profile` file, adding your variables as follows: 
    300  
    301     export WP_PLUGIN_KEY=my-api-key 
    302     export WP_PLUGIN_SECRET=my-api-secret 
    303     export WP_PLUGIN_CHANNEL=my-api-channel 
    304  
    305 Once updated, reload it using `source ~/.profile`. Test it out by doing `echo 
    306 $WP_PLUGIN_KEY`, it should display your key in the terminal. 
    307  
    308 Now you can simply use the `phpunit` command to run the tests. 
     19Please visit our [wiki](https://github.com/alleyinteractive/apple-news/wiki) for detailed [installation instructions](https://github.com/alleyinteractive/apple-news/wiki/Installation) as well as [configuration](https://github.com/alleyinteractive/apple-news/wiki/Configuration) and [usage instructions](https://github.com/alleyinteractive/apple-news/wiki/Usage), [troubleshooting information](https://github.com/alleyinteractive/apple-news/wiki/Usage#troubleshooting) and [details about contributing](https://github.com/alleyinteractive/apple-news/wiki/Contributing). 
  • publish-to-apple-news/trunk/admin/apple-actions/class-action.php

    r1305768 r1558569  
    2828 
    2929} 
    30  
    31 class Action_Exception extends \Exception {} 
  • publish-to-apple-news/trunk/admin/apple-actions/class-api-action.php

    r1305768 r1558569  
    44 
    55require_once plugin_dir_path( __FILE__ ) . 'class-action.php'; 
     6require_once plugin_dir_path( __FILE__ ) . 'class-action-exception.php'; 
    67require_once plugin_dir_path( __FILE__ ) . '../../includes/apple-push-api/autoload.php'; 
    78 
  • publish-to-apple-news/trunk/admin/apple-actions/index/class-export.php

    r1485664 r1558569  
    44 
    55require_once plugin_dir_path( __FILE__ ) . '../class-action.php'; 
     6require_once plugin_dir_path( __FILE__ ) . '../class-action-exception.php'; 
    67require_once plugin_dir_path( __FILE__ ) . '../../../includes/apple-exporter/autoload.php'; 
    78 
     
    2728     * @param int $id 
    2829     */ 
    29     function __construct( $settings, $id ) { 
     30    function __construct( $settings, $id = null ) { 
    3031        parent::__construct( $settings ); 
    3132        $this->id = $id; 
     
    6768        $post_thumb = wp_get_attachment_url( get_post_thumbnail_id( $this->id ) ) ?: null; 
    6869 
    69         // Get the author 
    70         $author = ucfirst( get_the_author_meta( 'display_name', $post->post_author ) ); 
    71  
    72         // Set the default date format 
    73         $date_format = 'M j, Y | g:i A'; 
    74  
    75         // Check for a custom byline format 
    76         $byline_format = $this->get_setting( 'byline_format' ); 
    77         if ( ! empty( $byline_format ) ) { 
    78             // Find and replace the author format placeholder name with a temporary placeholder 
    79             // This is because some bylines could contain hashtags! 
    80             $temp_byline_placeholder = 'AUTHOR' . time(); 
    81             $byline = str_replace( '#author#', $temp_byline_placeholder, $byline_format ); 
    82  
    83             // Attempt to parse the date format from the remaining string 
    84             $matches = array(); 
    85             preg_match( '/#(.*?)#/', $byline, $matches ); 
    86             if ( ! empty( $matches[1] ) ) { 
    87                 // Set the date using the custom format 
    88                 $byline = str_replace( $matches[0], date( $matches[1], strtotime( $post->post_date ) ), $byline ); 
    89             } 
    90  
    91             // Replace the temporary placeholder with the actual byline 
    92             $byline = str_replace( $temp_byline_placeholder, $author, $byline ); 
    93  
    94         } else { 
    95             // Use the default format 
    96             $byline = sprintf( 
    97                 'by %1$s | %2$s', 
    98                 $author, 
    99                 date( $date_format, strtotime( $post->post_date ) ) 
    100             ); 
    101         } 
     70        // Build the byline 
     71        $byline = $this->format_byline( $post ); 
    10272 
    10373        // Filter each of our items before passing into the exporter class. 
     
    12999 
    130100    /** 
     101     * Formats the byline 
     102     * 
     103     * @since 1.2.0 
     104     * @param WP_Post $post 
     105     * @param string $author 
     106     * @param string $date 
     107     * @return string 
     108     * @access public 
     109     */ 
     110    public function format_byline( $post, $author = '', $date = '' ) { 
     111        // Get the author 
     112        if ( empty( $author ) ) { 
     113            $author = ucfirst( get_the_author_meta( 'display_name', $post->post_author ) ); 
     114        } 
     115 
     116        // Get the date 
     117        if ( empty( $date ) && ! empty( $post->post_date ) ) { 
     118            $date = $post->post_date; 
     119        } 
     120 
     121        // Set the default date format 
     122        $date_format = 'M j, Y | g:i A'; 
     123 
     124        // Check for a custom byline format 
     125        $byline_format = $this->get_setting( 'byline_format' ); 
     126        if ( ! empty( $byline_format ) ) { 
     127            // Find and replace the author format placeholder name with a temporary placeholder 
     128            // This is because some bylines could contain hashtags! 
     129            $temp_byline_placeholder = 'AUTHOR' . time(); 
     130            $byline = str_replace( '#author#', $temp_byline_placeholder, $byline_format ); 
     131 
     132            // Attempt to parse the date format from the remaining string 
     133            $matches = array(); 
     134            preg_match( '/#(.*?)#/', $byline, $matches ); 
     135            if ( ! empty( $matches[1] ) && ! empty( $date ) ) { 
     136                // Set the date using the custom format 
     137                $byline = str_replace( $matches[0], date( $matches[1], strtotime( $date ) ), $byline ); 
     138            } 
     139 
     140            // Replace the temporary placeholder with the actual byline 
     141            $byline = str_replace( $temp_byline_placeholder, $author, $byline ); 
     142 
     143        } else { 
     144            // Use the default format 
     145            $byline = sprintf( 
     146                'by %1$s | %2$s', 
     147                $author, 
     148                date( $date_format, strtotime( $date ) ) 
     149            ); 
     150        } 
     151 
     152        return $byline; 
     153    } 
     154 
     155    /** 
    131156     * Loads settings for the Exporter_Content from the WordPress post metadata. 
    132157     * 
  • publish-to-apple-news/trunk/admin/apple-actions/index/class-push.php

    r1485664 r1558569  
    137137        list( $json, $bundles, $errors ) = $this->generate_article(); 
    138138 
    139         // If there were errors, decide how to proceed based on the component alert settings 
    140         if ( ! empty( $errors[0]['component_errors'] ) ) { 
    141             // Build an list of the components that caused errors 
    142             $component_names = implode( ', ', $errors[0]['component_errors'] ); 
    143  
    144             // Decide if we need to handle this 
    145             $component_alerts = $this->get_setting( 'component_alerts' ); 
    146  
    147             if ( 'warn' === $component_alerts ) { 
    148                 $alert_message = sprintf( 
    149                     __( 'The following components are unsupported by Apple News and were removed: %s', 'apple-news' ), 
    150                     $component_names 
    151                 ); 
    152  
    153                 if ( empty( $user_id ) ) { 
    154                     $user_id = get_current_user_id(); 
    155                 } 
    156  
    157                 \Admin_Apple_Notice::error( $alert_message, $user_id ); 
    158             } elseif ( 'fail' === $component_alerts ) { 
    159                 $alert_message = sprintf( 
    160                     __( 'The following components are unsupported by Apple News and prevented publishing: %s', 'apple-news' ), 
    161                     $component_names 
    162                 ); 
    163  
    164                 // Remove the pending designation if it exists 
    165                 delete_post_meta( $this->id, 'apple_news_api_pending' ); 
    166  
    167                 // Remove the async in progress flag 
    168                 delete_post_meta( $this->id, 'apple_news_api_async_in_progress' ); 
    169  
    170                 $this->clean_workspace(); 
    171  
    172                 throw new \Apple_Actions\Action_Exception( $alert_message ); 
    173             } 
    174         } 
     139        // Process errors 
     140        $this->process_errors( $errors ); 
    175141 
    176142        // Validate the data before using since it's filterable. 
     
    263229 
    264230    /** 
     231     * Processes errors, halts publishing if needed. 
     232     * 
     233     * @param array $errors 
     234     * @access private 
     235     */ 
     236    private function process_errors( $errors ) { 
     237        // Get the current alert settings 
     238        $component_alerts = $this->get_setting( 'component_alerts' ); 
     239        $json_alerts = $this->get_setting( 'json_alerts' ); 
     240 
     241        // Initialize the alert message 
     242        $alert_message = ''; 
     243 
     244        // Get the current user id 
     245        if ( empty( $user_id ) ) { 
     246            $user_id = get_current_user_id(); 
     247        } 
     248 
     249        // Build the component alert error message, if required 
     250        if ( ! empty( $errors[0]['component_errors'] ) ) { 
     251            // Build an list of the components that caused errors 
     252            $component_names = implode( ', ', $errors[0]['component_errors'] ); 
     253 
     254            if ( 'warn' === $component_alerts ) { 
     255                $alert_message .= sprintf( 
     256                    __( 'The following components are unsupported by Apple News and were removed: %s', 'apple-news' ), 
     257                    $component_names 
     258                ); 
     259            } elseif ( 'fail' === $component_alerts ) { 
     260                $alert_message .= sprintf( 
     261                    __( 'The following components are unsupported by Apple News and prevented publishing: %s', 'apple-news' ), 
     262                    $component_names 
     263                ); 
     264            } 
     265        } 
     266 
     267        // Check for JSON errors 
     268        if ( ! empty( $errors[0]['json_errors'] ) ) { 
     269            if ( ! empty( $alert_message ) ) { 
     270                $alert_message .= '|'; 
     271            } 
     272 
     273            // Merge all errors into a single message 
     274            $json_errors = implode( ', ', $errors[0]['json_errors'] ); 
     275 
     276            // Add these to the message 
     277            if ( 'warn' === $json_alerts ) { 
     278                $alert_message .= sprintf( 
     279                    __( 'The following JSON errors were detected: %s', 'apple-news' ), 
     280                    $json_errors 
     281                ); 
     282            } elseif ( 'fail' === $json_alerts ) { 
     283                $alert_message .= sprintf( 
     284                    __( 'The following JSON errors were detected and prevented publishing: %s', 'apple-news' ), 
     285                    $json_errors 
     286                ); 
     287            } 
     288        } 
     289 
     290        // See if we found any errors 
     291        if ( empty( $alert_message ) ) { 
     292            return; 
     293        } 
     294 
     295        // Proceed based on component alert settings 
     296        if ( ( 'fail' === $component_alerts && ! empty( $errors[0]['component_errors'] ) ) 
     297            || ( 'fail' === $json_alerts && ! empty( $errors[0]['json_errors'] ) ) ) { 
     298            // Remove the pending designation if it exists 
     299            delete_post_meta( $this->id, 'apple_news_api_pending' ); 
     300 
     301            // Remove the async in progress flag 
     302            delete_post_meta( $this->id, 'apple_news_api_async_in_progress' ); 
     303 
     304            // Clean the workspace 
     305            $this->clean_workspace(); 
     306 
     307            // Throw an exception 
     308            throw new \Apple_Actions\Action_Exception( $alert_message ); 
     309        } else if ( ( 'warn' === $component_alerts && ! empty( $errors[0]['component_errors'] ) ) 
     310            || ( 'warn' === $json_alerts && ! empty( $errors[0]['json_errors'] ) ) ) { 
     311                \Admin_Apple_Notice::error( $alert_message, $user_id ); 
     312        } 
     313    } 
     314 
     315    /** 
    265316     * Clean up the workspace. 
    266317     * 
  • publish-to-apple-news/trunk/admin/class-admin-apple-notice.php

    r1485664 r1558569  
    11<?php 
     2 
     3use \Apple_News as Apple_News; 
     4 
    25/** 
    36 * This class manages admin notices. 
     
    136139    private static function show_notice( $message, $type ) { 
    137140        // Format messages a little nicer 
     141        $message = str_replace( '|', '<br />', $message ); 
    138142        $message_array = explode( ':', $message ); 
    139143        if ( 2 === count( $message_array ) ) { 
     
    151155            } 
    152156        } 
     157 
     158        // Add the support tagline to errors 
     159        if ( 'error' === $type ) { 
     160            $message .= Apple_News::get_support_info(); 
     161        } 
    153162        ?> 
    154163        <div class="notice <?php echo esc_attr( $type ) ?> is-dismissible"> 
  • publish-to-apple-news/trunk/admin/class-admin-apple-settings.php

    r1399547 r1558569  
    153153            '../assets/css/settings.css', array() ); 
    154154 
     155        wp_enqueue_script( 'iris' ); 
    155156        wp_enqueue_script( 'apple-news-select2-js', plugin_dir_url( __FILE__ ) . 
    156157            '../vendor/select2/select2.full.min.js', array( 'jquery' ) ); 
    157158        wp_enqueue_script( 'apple-news-settings-js', plugin_dir_url( __FILE__ ) . 
    158             '../assets/js/settings.js', array( 'jquery', 'jquery-ui-draggable', 'jquery-ui-sortable', 'apple-news-select2-js' ) 
     159            '../assets/js/settings.js', array( 'jquery', 'jquery-ui-draggable', 'jquery-ui-sortable', 'apple-news-select2-js', 'iris' ) 
    159160        ); 
     161 
     162        wp_localize_script( 'apple-news-settings-js', 'appleNewsSettings', array( 
     163            'fontNotice' => __( 'Font preview is only available on macOS', 'apple-news' ), 
     164        ) ); 
    160165    } 
    161166 
  • publish-to-apple-news/trunk/admin/partials/page_options.php

    r1399547 r1558569  
    1 <div class="wrap"> 
    2     <form method="post" action=""> 
     1<div class="wrap apple-news-settings"> 
     2    <form method="post" action="" id="apple-news-settings-form"> 
    33        <?php wp_nonce_field( 'apple_news_options', 'apple_news_options' ); ?> 
    44        <input type="hidden" name="action" value="apple_news_options" /> 
    55        <?php foreach ( $sections as $section ): ?> 
    6         <h3><?php echo esc_html( $section->name() ); ?></h3> 
    7         <?php echo wp_kses_post( $section->get_section_info() ); ?> 
    8         <table class="form-table apple-news"> 
    9             <?php foreach ( $section->groups() as $group ): ?> 
    10             <?php do_action( 'apple_news_before_setting_group', $group ); ?> 
    11             <tr> 
    12                 <th scope="row"><?php echo esc_html( $group['label'] ); ?></th> 
    13                 <td> 
    14                     <fieldset> 
    15                         <?php foreach ( $group['settings'] as $setting_name => $setting_meta ): ?> 
    16                         <?php do_action( 'apple_news_before_setting', $setting_name, $setting_meta ); ?> 
    17                         <label class="setting-container"> 
    18                             <?php if ( ! empty( $setting_meta['label'] ) ): ?> 
    19                                 <span class="label-name"><?php echo esc_html( $setting_meta['label'] ); ?></span> 
     6            <?php $section->before_section() ?> 
     7            <h3><?php echo esc_html( $section->name() ); ?></h3> 
     8            <?php echo wp_kses_post( $section->get_section_info() ); ?> 
     9            <table class="form-table apple-news"> 
     10                <?php foreach ( $section->groups() as $group ): ?> 
     11                <?php do_action( 'apple_news_before_setting_group', $group ); ?> 
     12                <tr> 
     13                    <th scope="row"><?php echo esc_html( $group['label'] ); ?></th> 
     14                    <td> 
     15                        <fieldset> 
     16                            <?php foreach ( $group['settings'] as $setting_name => $setting_meta ): ?> 
     17                            <?php do_action( 'apple_news_before_setting', $setting_name, $setting_meta ); ?> 
     18                            <label class="setting-container"> 
     19                                <?php if ( ! empty( $setting_meta['label'] ) ): ?> 
     20                                    <span class="label-name"><?php echo esc_html( $setting_meta['label'] ); ?></span> 
     21                                <?php endif; ?> 
     22                                <?php 
     23                                    echo wp_kses( 
     24                                        $section->render_field( 
     25                                            array( 
     26                                                $setting_name, 
     27                                                $setting_meta['default'], 
     28                                                $setting_meta['callback'] 
     29                                            ) 
     30                                        ), 
     31                                        Admin_Apple_Settings_Section::$allowed_html 
     32                                    ); 
     33                                ?> 
     34                            </label> 
     35                            <?php do_action( 'apple_news_after_setting', $setting_name, $setting_meta ); ?> 
     36                            <br /> 
     37                            <?php endforeach; ?> 
     38 
     39                            <?php if ( $group['description'] ): ?> 
     40                                <p class="description"><?php echo '(' . wp_kses_post( $group['description'] ) . ')'; ?></p> 
    2041                            <?php endif; ?> 
    21                             <?php 
    22                                 echo wp_kses( 
    23                                     $section->render_field( 
    24                                         array( 
    25                                             $setting_name, 
    26                                             $setting_meta['default'], 
    27                                             $setting_meta['callback'] 
    28                                         ) 
    29                                     ), 
    30                                     Admin_Apple_Settings_Section::$allowed_html 
    31                                 ); 
    32                             ?> 
    33                         </label> 
    34                         <?php do_action( 'apple_news_after_setting', $setting_name, $setting_meta ); ?> 
    35                         <br /> 
    36                         <?php endforeach; ?> 
    37  
    38                         <?php if ( $group['description'] ): ?> 
    39                             <p class="description"><?php echo '(' . wp_kses_post( $group['description'] ) . ')'; ?></p> 
    40                         <?php endif; ?> 
    41                     </fieldset> 
    42                 </td> 
    43             </tr> 
    44             <?php do_action( 'apple_news_after_setting_group', $group ); ?> 
    45             <?php endforeach; ?> 
    46         </table> 
     42                        </fieldset> 
     43                    </td> 
     44                </tr> 
     45                <?php do_action( 'apple_news_after_setting_group', $group ); ?> 
     46                <?php endforeach; ?> 
     47            </table> 
     48            <?php $section->after_section() ?> 
    4749        <?php endforeach; ?> 
    4850 
  • publish-to-apple-news/trunk/admin/settings/class-admin-apple-settings-section-advanced.php

    r1416428 r1558569  
    4747                'description' => __( 'If a post has a component that is unsupported by Apple News, choose "none" to generate no alert, "warn" to provide an admin warning notice, or "fail" to generate a notice and stop publishing.', 'apple-news' ), 
    4848            ), 
     49            'json_alerts' => array( 
     50                'label'   => __( 'JSON Alerts', 'apple-news' ), 
     51                'type'    => array( 'none', 'warn', 'fail' ), 
     52                'description' => __( 'If a post has invalid JSON that may cause display issues in Apple News, choose "none" to generate no alert, "warn" to provide an admin warning notice, or "fail" to generate a notice and stop publishing.', 'apple-news' ), 
     53            ), 
    4954            'use_remote_images' => array( 
    5055                'label'   => __( 'Use Remote Images?', 'apple-news' ), 
     
    6267            'alerts' => array( 
    6368                'label'       => __( 'Alerts', 'apple-news' ), 
    64                 'settings'    => array( 'component_alerts' ), 
     69                'settings'    => array( 'component_alerts', 'json_alerts' ), 
    6570            ), 
    6671            'images' => array( 
  • publish-to-apple-news/trunk/admin/settings/class-admin-apple-settings-section-formatting.php

    r1445129 r1558569  
    6060            ), 
    6161            'initial_dropcap' => array( 
    62                 'label'   => __( 'Use initial dropcap', 'apple-news' ), 
     62                'label'   => __( 'Use initial drop cap', 'apple-news' ), 
    6363                'type'    => array( 'yes', 'no' ), 
    6464            ), 
     
    6868            ), 
    6969            'dropcap_color' => array( 
    70                 'label'   => __( 'Dropcap font color', 'apple-news' ), 
     70                'label'   => __( 'Drop cap font color', 'apple-news' ), 
    7171                'type'    => 'color', 
    7272            ), 
     
    8686                'label'             => __( 'Byline format', 'apple-news' ), 
    8787                'type'              => 'text', 
    88                 'description' => __( 'Set the byline format. Two tokens can be present, #author# to denote the location of the author name and a <a href="http://php.net/manual/en/function.date.php" target="blank">PHP date format</a> string also encapsulated by #. The default format is "by #author# | #M j, Y | g:i A#".', 'apple-news' ), 
     88                'description' => __( 'Set the byline format. Two tokens can be present, #author# to denote the location of the author name and a <a href="http://php.net/manual/en/function.date.php" target="blank">PHP date format</a> string also encapsulated by #. The default format is "by #author# | #M j, Y | g:i A#". Note that byline format updates only preview on save.', 'apple-news' ), 
    8989                'size'              => 40, 
    9090                'required'      => false, 
     
    186186            ), 
    187187            'dropcap' => array( 
    188                 'label'       => __( 'Dropcap', 'apple-news' ), 
     188                'label'       => __( 'Drop Cap', 'apple-news' ), 
    189189                'settings'    => array( 'dropcap_font', 'initial_dropcap', 'dropcap_color' ), 
    190190            ), 
    191191            'byline' => array( 
    192192                'label'       => __( 'Byline', 'apple-news' ), 
    193                 'description' => __( "The byline displays the article's author and date", 'apple-news' ), 
     193                'description' => __( "The byline displays the article's author and publish date", 'apple-news' ), 
    194194                'settings'    => array( 'byline_font', 'byline_size', 'byline_color', 'byline_format' ), 
    195195            ), 
     
    234234     */ 
    235235    public function get_section_info() { 
    236         return __( 'Configuration for the visual appearance of the generated articles', 'apple-news' ); 
     236        return __( 'Configuration for the visual appearance of the generated articles. Updates to these settings will not change the appearance of any articles previously published to your channel in Apple News unless you republish them.', 'apple-news' ); 
     237    } 
     238 
     239    /** 
     240     * HTML to display before the section. 
     241     * 
     242     * @return string 
     243     * @access public 
     244     */ 
     245    public function before_section() { 
     246        ?> 
     247        <div id="apple-news-formatting"> 
     248            <div class="apple-news-settings-left"> 
     249        <?php 
     250    } 
     251 
     252    /** 
     253     * HTML to display after the section. 
     254     * 
     255     * @return string 
     256     * @access public 
     257     */ 
     258    public function after_section() { 
     259        ?> 
     260            </div> 
     261            <div class="apple-news-settings-preview"> 
     262                <?php 
     263                    // Build sample content 
     264                    $settings = new Admin_Apple_Settings(); 
     265 
     266                    $title = sprintf( 
     267                        '<h1 class="apple-news-title apple-news-component apple-news-meta-component">%s</h1>', 
     268                        __( 'Sample Article', 'apple-news' ) 
     269                    ); 
     270 
     271                    $cover = sprintf( 
     272                        '<div class="apple-news-cover apple-news-meta-component">%s</div>', 
     273                        __( 'Cover', 'apple-news' ) 
     274                    ); 
     275 
     276                    // Build the byline 
     277                    $author = __( 'John Doe', 'apple-news' ); 
     278                    $date = date( 'M j, Y g:i A' ); 
     279                    $export = new Apple_Actions\Index\Export( $settings->fetch_settings() ); 
     280                    $byline = sprintf( 
     281                        '<div class="apple-news-byline apple-news-component apple-news-meta-component">%s</div>', 
     282                        $export->format_byline( null, $author, $date ) 
     283                    ); 
     284 
     285                    // Get the order of the top components 
     286                    $component_order = self::get_value( 'meta_component_order' ); 
     287                    foreach ( $component_order as $component ) { 
     288                        echo wp_kses( $$component, self::$allowed_html ); 
     289                    } 
     290                ?> 
     291                <div class="apple-news-component"> 
     292                <p><span class="apple-news-dropcap">L</span>orem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sagittis, <a href="#">augue vitae iaculis euismod</a>, libero nulla pellentesque quam, non venenatis massa odio id dolor.</p> 
     293                <p>Praesent eget odio vel sapien scelerisque euismod. Phasellus eros sapien, rutrum ac nibh nec, tristique commodo neque.</p> 
     294                <?php printf( 
     295                        '<div class="apple-news-image">%s</div>', 
     296                        esc_html__( 'Image', 'apple-news' ) 
     297                    ); 
     298                ?> 
     299                <p>Maecenas tortor dui, pellentesque ac ullamcorper quis, malesuada sit amet turpis. Nunc in tellus et justo dapibus sollicitudin.</p> 
     300                <h2>Quisque efficitur</h2> 
     301                <p>Quisque efficitur sit amet ex et venenatis. Morbi nisi nisi, ornare id iaculis eget, pulvinar ac dolor.</p> 
     302                <p>In eu la cus porttitor, pellentesque diam et, tristique elit. Mauris justo odio, efficitur sit amet aliquet id, aliquam placerat turpis.</p> 
     303                <div class="apple-news-pull-quote">Lorem ipsum dolor sit amet.</div> 
     304                <p>Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque ipsum mi, sagittis eget sodales et, volutpat at felis.</p> 
     305                </div> 
     306            </div> 
     307        </div> 
     308        <?php 
    237309    } 
    238310 
     
    248320            <?php 
    249321                // Get the current order 
    250                 $component_order = self::get_value( 'meta_component_order' ) ?: array( 'cover', 'title', 'byline' ); 
     322                $component_order = self::get_value( 'meta_component_order' ); 
    251323                if ( ! empty( $component_order ) && is_array( $component_order ) ) { 
    252324                    foreach ( $component_order as $component_name ) { 
  • publish-to-apple-news/trunk/admin/settings/class-admin-apple-settings-section.php

    r1413349 r1558569  
    335335     * @var Settings 
    336336     * @access protected 
    337      */ 
    338     protected $base_settings; 
     337     * @static 
     338     */ 
     339    protected static $base_settings; 
    339340 
    340341    /** 
     
    365366            'name' => array(), 
    366367            'multiple' => array(), 
     368            'id' => array(), 
    367369        ), 
    368370        'option' => array( 
     
    379381            'required' => array(), 
    380382            'size' => array(), 
     383            'id' => array(), 
    381384        ), 
    382385        'br' => array(), 
     
    389392            'target' => array(), 
    390393        ), 
     394        'div' => array( 
     395            'class' => array(), 
     396        ), 
     397        'h1' => array( 
     398            'class' => array(), 
     399        ), 
     400        'h2' => array( 
     401            'class' => array(), 
     402        ), 
     403        'h3' => array( 
     404            'class' => array(), 
     405        ), 
     406        'h4' => array( 
     407            'class' => array(), 
     408        ), 
     409        'h5' => array( 
     410            'class' => array(), 
     411        ), 
     412        'h6' => array( 
     413            'class' => array(), 
     414        ), 
    391415    ); 
    392416 
     
    399423        $this->page             = $page; 
    400424        $base_settings          = new \Apple_Exporter\Settings; 
    401         $this->base_settings    = $base_settings->all(); 
     425        self::$base_settings    = $base_settings->all(); 
    402426        $this->settings         = apply_filters( 'apple_news_section_settings', $this->settings, $page ); 
    403427        $this->groups           = apply_filters( 'apple_news_section_groups', $this->groups, $page ); 
     
    431455            foreach ( $info['settings'] as $name ) { 
    432456                $settings[ $name ] = $this->settings[ $name ]; 
    433                 $settings[ $name ]['default'] = $this->get_default_for( $name ); 
     457                $settings[ $name ]['default'] = self::get_default_for( $name ); 
    434458                $settings[ $name ]['callback'] = ( ! empty( $this->settings[ $name ]['callback'] ) ) ? $this->settings[ $name ]['callback'] : ''; 
    435459            } 
     
    472496        $type  = $this->get_type_for( $name ); 
    473497        $settings = get_option( self::$option_name ); 
    474         $value = self::get_value( $name, $settings ) ?: $default_value; 
     498        $value = self::get_value( $name, $settings ); 
    475499        $field = null; 
    476500 
     
    494518            // Use select2 only when there is a considerable ammount of options available 
    495519            if ( count( $type ) > 10 ) { 
    496                 $field = '<select class="select2" name="%s' . $multiple_name . '" ' . $multiple_attr . '>'; 
     520                $field = '<select class="select2 standard" id="%s" name="%s' . $multiple_name . '" ' . $multiple_attr . '>'; 
    497521            } else { 
    498                 $field = '<select name="%s' . $multiple_name . '" ' . $multiple_attr . '>'; 
     522                $field = '<select id="%s" name="%s' . $multiple_name . '" ' . $multiple_attr . '>'; 
    499523            } 
    500524 
     
    513537            $field .= '</select>'; 
    514538        } else if ( 'font' == $type ) { 
    515             $field = '<select class="select2" name="%s">'; 
     539            $field = '<select class="select2 font" id="%s" name="%s">'; 
    516540            foreach ( self::$fonts as $option ) { 
    517541                $field .= "<option value='" . esc_attr( $option ) . "'"; 
     
    539563            $field .= '</select>'; 
    540564        } else if ( 'integer' == $type ) { 
    541             $field = '<input type="number" name="%s" value="%s" size="%s" %s>'; 
     565            $field = '<input type="number" id="%s" name="%s" value="%s" size="%s" %s>'; 
    542566        } else if ( 'float' == $type ) { 
    543             $field = '<input class="input-float" placeholder="' . esc_attr( $default_value ) . '" type="text" step="any" name="%s" value="%s" size="%s">'; 
     567            $field = '<input class="input-float" placeholder="' . esc_attr( $default_value ) . '" type="text" step="any" id="%s" name="%s" value="%s" size="%s">'; 
    544568        } else if ( 'color' == $type ) { 
    545             $field = '<input type="color" name="%s" value="%s" %s>'; 
     569            $field = '<input type="text" id="%s" name="%s" value="%s" class="apple-news-color-picker" %s>'; 
    546570        } else if ( 'password' == $type ) { 
    547             $field = '<input type="password" name="%s" value="%s" size="%s" %s>'; 
     571            $field = '<input type="password" id="%s" name="%s" value="%s" size="%s" %s>'; 
    548572        } else { 
    549573            // If nothing else matches, it's a string. 
    550             $field = '<input type="text" name="%s" value="%s" size="%s" %s>'; 
     574            $field = '<input type="text" id="%s" name="%s" value="%s" size="%s" %s>'; 
    551575        } 
    552576 
     
    561585            return sprintf( 
    562586                $field, 
     587                esc_attr( $name ), 
    563588                esc_attr( $name ) 
    564589            ); 
     
    567592                $field, 
    568593                esc_attr( $name ), 
     594                esc_attr( $name ), 
    569595                esc_attr( $value ), 
    570596                intval( $size ), 
     
    637663     * @return string 
    638664     * @access protected 
    639      */ 
    640     protected function get_default_for( $name ) { 
    641         return isset( $this->base_settings[ $name ] ) ? $this->base_settings[ $name ] : ''; 
     665     * @static 
     666     */ 
     667    protected static function get_default_for( $name ) { 
     668        return isset( self::$base_settings[ $name ] ) ? self::$base_settings[ $name ] : ''; 
    642669    } 
    643670 
     
    650677    public function get_section_info() { 
    651678        return ''; 
     679    } 
     680 
     681    /** 
     682     * HTML to display before the section. 
     683     * 
     684     * @return string 
     685     * @access public 
     686     */ 
     687    public function before_section() { 
     688        echo ''; 
     689    } 
     690 
     691    /** 
     692     * HTML to display after the section. 
     693     * 
     694     * @return string 
     695     * @access public 
     696     */ 
     697    public function after_section() { 
     698        echo ''; 
    652699    } 
    653700 
     
    674721            $saved_settings = get_option( self::$option_name ); 
    675722        } 
    676         return ( ! empty( $saved_settings[ $key ] ) ) ? $saved_settings[ $key ] : ''; 
     723        return ( isset( $saved_settings[ $key ] ) ) ? $saved_settings[ $key ] : self::get_default_for( $key ); 
    677724    } 
    678725 
  • publish-to-apple-news/trunk/apple-news.php

    r1512066 r1558569  
    1313 * Plugin URI:  http://github.com/alleyinteractive/apple-news 
    1414 * Description: Export and sync posts to Apple format. 
    15  * Version:     1.1.9 
     15 * Version:     1.2.0 
    1616 * Author:      Alley Interactive 
    1717 * Author URI:  https://www.alleyinteractive.com 
  • publish-to-apple-news/trunk/assets/css/settings.css

    r1380662 r1558569  
    5252    background-color: #EAF2FA; 
    5353} 
     54 
     55.font-notice { 
     56    font-size: 10px; 
     57} 
     58 
     59.apple-news-settings-left { 
     60    max-width: 600px; 
     61    float: left; 
     62} 
     63 
     64.apple-news-settings-preview { 
     65    width: 320px; 
     66    float: left; 
     67    background-color: #FFF; 
     68    display: none; 
     69} 
     70 
     71.apple-news-settings-preview a { 
     72    text-decoration: none; 
     73} 
     74 
     75.apple-news-settings h3 { 
     76    clear: both; 
     77} 
     78 
     79@media only screen and (min-width: 1172px) { 
     80    .apple-news-settings-preview { 
     81        margin: 50px 0px 0px 50px; 
     82    } 
     83} 
     84 
     85@media only screen and (max-width: 1172px) { 
     86    .apple-news-settings-preview { 
     87        margin: 10px 0px; 
     88    } 
     89} 
     90 
     91.apple-news-settings-preview { 
     92    padding-bottom: 50px; 
     93} 
     94 
     95.apple-news-cover, 
     96.apple-news-image { 
     97    text-align: center; 
     98    vertical-align: middle; 
     99    background-color: #333; 
     100    color: #FFF; 
     101    font-size: 24px; 
     102} 
     103 
     104.apple-news-cover { 
     105    width: 320px; 
     106    height: 240px; 
     107    line-height: 240px; 
     108} 
     109 
     110.apple-news-image { 
     111    width: 100%; 
     112    height: 200px; 
     113    line-height: 200px; 
     114} 
     115 
     116.apple-news-settings-preview p, 
     117.apple-news-settings-preview div { 
     118    padding: 0px; 
     119    margin: 0px; 
     120} 
     121 
     122.apple-news-dropcap-enabled { 
     123    float: left; 
     124    padding-top: 7px; 
     125    padding-right: 10px; 
     126    padding-left: 5px; 
     127} 
     128 
     129.wrap .apple-news-title { 
     130    margin-top: 20px; 
     131} 
     132 
     133.apple-news-settings-preview div.apple-news-byline { 
     134    margin-bottom: 20px; 
     135} 
     136 
     137.apple-news-settings-preview div.apple-news-pull-quote { 
     138    margin: 20px 0px; 
     139    padding: 10px 0px; 
     140} 
     141 
     142.apple-news-title.title-cover-byline, 
     143.apple-news-title.byline-title-cover, 
     144.apple-news-cover.title-byline-cover, 
     145.apple-news-cover.byline-title-cover { 
     146    margin-bottom: 20px; 
     147} 
     148 
     149.apple-news-settings-preview div.apple-news-byline.title-byline-cover, 
     150.apple-news-settings-preview div.apple-news-byline.byline-cover-title { 
     151    margin-bottom: 30px; 
     152} 
     153 
     154.apple-news-byline.title-cover-byline, 
     155.apple-news-byline.byline-title-cover, 
     156.apple-news-byline.byline-cover-title, 
     157.apple-news-byline.cover-byline-title { 
     158    margin-top: 10px; 
     159} 
  • publish-to-apple-news/trunk/assets/js/settings.js

    r1380662 r1558569  
    11(function ($) { 
    22 
     3    var componentKey = ''; 
     4 
    35    $(document).ready(function () { 
    4         $( '.select2' ).select2(); 
     6        appleNewsSelectInit(); 
    57        appleNewsSettingsSortInit( '#meta-component-order-sort', 'meta_component_order' ); 
     8        appleNewsColorPickerInit(); 
     9        appleNewsPreviewInit(); 
    610    }); 
     11 
     12    function appleNewsFontSelectTemplate( font ) { 
     13        var $fontOption = $( '<span>' ) 
     14            .attr( 'style', 'font-family: ' + font.text ) 
     15            .text( font.text ); 
     16 
     17        return $fontOption; 
     18    } 
     19 
     20    function appleNewsSelectInit() { 
     21        // Only show fonts on Macs since they're system fonts 
     22        if ( appleNewsSupportsMacFeatures() ) { 
     23            $( '.select2.standard' ).select2(); 
     24            $( '.select2.font' ).select2({ 
     25                templateResult: appleNewsFontSelectTemplate, 
     26                templateSelection: appleNewsFontSelectTemplate 
     27            }); 
     28        } else { 
     29            $( '.select2' ).select2(); 
     30            $( 'span.select2' ).after( 
     31                $( '<div>' ) 
     32                    .addClass( 'font-notice' ) 
     33                    .text( appleNewsSettings.fontNotice ) 
     34            ) 
     35        } 
     36    } 
    737 
    838    function appleNewsSettingsSortInit( selector, key ) { 
     
    3565            } ); 
    3666        } 
     67 
     68        // Update the preview 
     69        appleNewsUpdatePreview(); 
     70    } 
     71 
     72    function appleNewsColorPickerInit() { 
     73        $( '.apple-news-color-picker' ).iris({ 
     74            palettes: true, 
     75            width: 320, 
     76            change: appleNewsUpdatePreview 
     77        }); 
     78 
     79        $( '.apple-news-color-picker' ).on( 'click', function() { 
     80            $( '.apple-news-color-picker' ).iris( 'hide' ); 
     81            $( this ).iris( 'show' ); 
     82        }); 
     83    } 
     84 
     85    function appleNewsSupportsMacFeatures() { 
     86        if ( 'MacIntel' === navigator.platform ) { 
     87            return true; 
     88        } else { 
     89            return false; 
     90        } 
     91    } 
     92 
     93    function appleNewsPreviewInit() { 
     94        // Do an initial update 
     95        appleNewsUpdatePreview(); 
     96 
     97        // Check that we are fully compatible 
     98        if ( ! appleNewsSupportsMacFeatures() ) { 
     99            $( '.apple-news-settings-preview' ).prepend( 
     100                $( '<div>' ) 
     101                    .addClass( 'font-notice' ) 
     102                    .text( appleNewsSettings.fontNotice ) 
     103            ) 
     104        } 
     105 
     106        // Ensure all further updates also affect the preview 
     107        $( '#apple-news-settings-form :input' ).on( 'change', appleNewsUpdatePreview ); 
     108 
     109        // Show the preview 
     110        $( '.apple-news-settings-preview' ).show(); 
     111    } 
     112 
     113    function appleNewsUpdatePreview() { 
     114        // Create a map of the form values to the preview elements 
     115        // Layout spacing 
     116        appleNewsSetCSS( '.apple-news-component', 'layout_margin', 'padding-left', 'px', .3 ); 
     117        appleNewsSetCSS( '.apple-news-component', 'layout_margin', 'padding-right', 'px', .3 ); 
     118 
     119        // Body 
     120        appleNewsSetCSS( '.apple-news-settings-preview p', 'body_font', 'font-family', null, null ); 
     121        appleNewsSetCSS( '.apple-news-settings-preview p', 'body_size', 'font-size', 'px', null ); 
     122        appleNewsSetCSS( '.apple-news-settings-preview p', 'body_color', 'color', null, null ); 
     123        appleNewsSetCSS( '.apple-news-settings-preview a', 'body_link_color', 'color', null, null ); 
     124        appleNewsSetCSS( '.apple-news-settings-preview', 'body_background_color', 'background-color', null, null ); 
     125        appleNewsSetCSS( '.apple-news-settings-preview p', 'body_orientation', 'text-align', null, null ); 
     126 
     127        // Dropcap 
     128        appleNewsSetCSS( '.apple-news-settings-preview .apple-news-dropcap', 'dropcap_color', 'color', null, null ); 
     129        appleNewsSetCSS( '.apple-news-settings-preview .apple-news-dropcap', 'dropcap_font', 'font-family', null, null ); 
     130        var bodySize = $( '#body_size' ).val(); 
     131        var bodyLineHeight = $( '#body_line_height' ).val(); 
     132        var dropcapSize = bodySize; 
     133        var dropcapLineHeight = bodyLineHeight; 
     134 
     135        if ( 'yes' === $( '#initial_dropcap' ).val() ) { 
     136            dropcapSize = bodySize * 5; 
     137            dropcapLineHeight = bodySize * 3.5; 
     138            $( '.apple-news-settings-preview .apple-news-dropcap' ).addClass( 'apple-news-dropcap-enabled' ); 
     139        } else { 
     140            $( '.apple-news-settings-preview .apple-news-dropcap' ).removeClass( 'apple-news-dropcap-enabled' ); 
     141        } 
     142        $( '.apple-news-settings-preview .apple-news-dropcap' ).css( 'font-size', dropcapSize + 'px' ); 
     143        $( '.apple-news-settings-preview .apple-news-dropcap' ).css( 'line-height', dropcapLineHeight + 'px' ); 
     144 
     145        // Byline 
     146        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-byline', 'byline_font', 'font-family', null, null ); 
     147        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-byline', 'byline_size', 'font-size', 'px', null ); 
     148        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-byline', 'byline_color', 'color', null, null ); 
     149 
     150        // Headings 
     151        appleNewsSetCSS( '.apple-news-settings-preview :header', 'header_font', 'font-family', null, null ); 
     152        appleNewsSetCSS( '.apple-news-settings-preview :header', 'header_color', 'color', null, null ); 
     153        appleNewsSetCSS( '.apple-news-settings-preview h1', 'header1_size', 'font-size', 'px', .75 ); 
     154        appleNewsSetCSS( '.apple-news-settings-preview h2', 'header2_size', 'font-size', 'px', .75 ); 
     155        appleNewsSetCSS( '.apple-news-settings-preview h3', 'header3_size', 'font-size', 'px', .75 ); 
     156        appleNewsSetCSS( '.apple-news-settings-preview h4', 'header4_size', 'font-size', 'px', .75 ); 
     157        appleNewsSetCSS( '.apple-news-settings-preview h5', 'header5_size', 'font-size', 'px', .75 ); 
     158        appleNewsSetCSS( '.apple-news-settings-preview h6', 'header6_size', 'font-size', 'px', .75 ); 
     159 
     160        // Pull quote 
     161        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-pull-quote', 'pullquote_font', 'font-family', null, null ); 
     162        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-pull-quote', 'pullquote_size', 'font-size', 'px', .75 ); 
     163        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-pull-quote', 'pullquote_color', 'color', null, null ); 
     164        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-pull-quote', 'pullquote_transform', 'text-transform', null, null ); 
     165        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-pull-quote', 'pullquote_border_color', 'border-top-color', null, null ); 
     166        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-pull-quote', 'pullquote_border_style', 'border-top-style', null, null ); 
     167        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-pull-quote', 'pullquote_border_width', 'border-top-width', 'px', null ); 
     168        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-pull-quote', 'pullquote_border_color', 'border-bottom-color', null, null ); 
     169        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-pull-quote', 'pullquote_border_style', 'border-bottom-style', null, null ); 
     170        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-pull-quote', 'pullquote_border_width', 'border-bottom-width', 'px', null ); 
     171 
     172        // Component order 
     173        var componentOrder = $( '#meta-component-order-sort' ).sortable( 'toArray' ); 
     174        if ( '' !== componentKey ) { 
     175            $( '.apple-news-meta-component' ).removeClass( componentKey ); 
     176            componentKey = ''; 
     177        } 
     178 
     179        $.each( componentOrder.reverse(), function( index, value ) { 
     180            // Remove the component 
     181            var $detached = $( '.apple-news-' + value ).detach(); 
     182 
     183            // Build the component key. 
     184            // Used for targeting certain styles in the preview that differ on component order. 
     185            componentKey = value + '-' + componentKey; 
     186 
     187            // Add back at the beginning 
     188            $( '.apple-news-settings-preview' ).prepend( $detached ); 
     189        } ); 
     190 
     191        if ( '' !== componentKey ) { 
     192            componentKey = componentKey.substring( 0, componentKey.length - 1 ); 
     193            $( '.apple-news-meta-component' ).addClass( componentKey ); 
     194        } 
     195 
     196        // Line heights 
     197        appleNewsSetCSS( '.apple-news-settings-preview p', 'body_line_height', 'line-height', 'px', null ); 
     198        appleNewsSetCSS( '.apple-news-settings-preview p', 'body_line_height', 'margin-bottom', 'px', null ); 
     199        appleNewsSetCSS( '.apple-news-image', 'body_line_height', 'margin-bottom', 'px', null ); 
     200        appleNewsSetCSS( '.apple-news-settings-preview :header', 'header_line_height', 'line-height', 'px', null ); 
     201        appleNewsSetCSS( '.apple-news-settings-preview div.apple-news-pull-quote', 'pullquote_line_height', 'line-height', 'px', .75 ); 
     202    } 
     203 
     204    function appleNewsSetCSS( displayElement, formElement, property, units, scale ) { 
     205        // Get the form value 
     206        var value = $( '#' + formElement ).val(); 
     207 
     208        // If the value is 'none', make it empty 
     209        if ( 'none' === value ) { 
     210            value = ''; 
     211        } 
     212 
     213        // Some values need to be scaled 
     214        if ( scale && value ) { 
     215            value = parseInt( value ) * scale; 
     216        } 
     217 
     218        // Add units if set and we got a value 
     219        if ( units && value ) { 
     220            value = value + units; 
     221        } 
     222 
     223        $( displayElement ).css( property, value ); 
    37224    } 
    38225 
  • publish-to-apple-news/trunk/includes/apple-exporter/class-exporter.php

    r1445129 r1558569  
    192192        $json = apply_filters( 'apple_news_generate_json', $json, $this->content_id() ); 
    193193 
    194         return json_encode( $json ); 
     194        $json = json_encode( $json ); 
     195 
     196        // Check the JSON for unicode errors. 
     197        // For now, we'll assume that multiple unicode characters in sequence 
     198        // containing the  (\u00C2) indicate a problem as that has been the 
     199        // most common indication of the issue. 
     200        preg_match_all( '/(\\\u[0-9a-fA-F]{4}){2,}/', $json, $matches ); 
     201        if ( ! empty( $matches[0] ) ) { 
     202            // Get a unique list of character sequences 
     203            $character_sequences = array_unique( $matches[0] ); 
     204            foreach ( $character_sequences as &$sequence ) { 
     205                // Convert back to a display format 
     206                $sequence = json_decode( '{ "value":"' . $sequence . '"}' ); 
     207                $sequence = $sequence->value; 
     208            } 
     209 
     210            $this->workspace->log_error( 'json_errors', sprintf( 
     211                __( 'Invalid unicode character sequences were found that could cause display issues on Apple News: %s', 'apple-news' ), 
     212                implode( ', ', $character_sequences ) 
     213            ) ); 
     214        } 
     215 
     216        return $json; 
    195217    } 
    196218 
  • publish-to-apple-news/trunk/includes/apple-exporter/class-settings.php

    r1485664 r1558569  
    3232        'body_size'                     => 18, 
    3333        'body_color'                    => '#4f4f4f', 
    34         'body_link_color'               => '#428BCA', 
    35         'body_background_color'   => '#FAFAFA', 
     34        'body_link_color'               => '#428bca', 
     35        'body_background_color'   => '#fafafa', 
    3636        'body_orientation'              => 'left', 
    3737        'body_line_height'              => 24, 
     
    5858        'pullquote_font'                => 'AvenirNext-Bold', 
    5959        'pullquote_size'                => 48, 
    60         'pullquote_color'               => '#53585F', 
    61         'pullquote_border_color'    => '#53585F', 
     60        'pullquote_color'               => '#53585f', 
     61        'pullquote_border_color'    => '#53585f', 
    6262        'pullquote_border_style'    => 'solid', 
    6363        'pullquote_border_width'    => '3', 
     
    6666 
    6767        'component_alerts'              => 'none', 
     68        'json_alerts'                           => 'warn', 
    6869 
    6970        'use_remote_images'             => 'no', 
  • publish-to-apple-news/trunk/includes/class-apple-news.php

    r1512066 r1558569  
    3434 
    3535    /** 
     36     * Link to support for the plugin on WordPress.org. 
     37     * 
     38     * @var string 
     39     * @access public 
     40     */ 
     41    public static $wordpress_org_support_url = 'https://wordpress.org/support/plugin/publish-to-apple-news'; 
     42 
     43    /** 
     44     * Link to support for the plugin on github. 
     45     * 
     46     * @var string 
     47     * @access public 
     48     */ 
     49    public static $github_support_url = 'https://github.com/alleyinteractive/apple-news/issues'; 
     50 
     51    /** 
    3652     * Plugin version. 
    3753     * 
    3854     * @var string 
    39      * @access protected 
     55     * @access public 
    4056     */ 
    41     protected $version = '1.1.9'; 
     57    public static $version = '1.2.0'; 
    4258 
    4359    /** 
     
    87103        return $migrated_settings; 
    88104    } 
     105 
     106    /** 
     107     * Displays support information for the plugin. 
     108     * 
     109     * @var string $format 
     110     * @var boolean $with_padding 
     111     * @return string 
     112     * @access public 
     113     */ 
     114    public static function get_support_info( $format = 'html', $with_padding = true ) { 
     115        $support_info = sprintf( 
     116            __( 'If you need assistance with this issue, please reach out for support on <a href="%s">WordPress.org</a> or <a href="%s">github</a>.', 'apple-news' ), 
     117            esc_url( self::$wordpress_org_support_url ), 
     118            esc_url( self::$github_support_url ) 
     119        ); 
     120 
     121        if ( 'text' === $format ) { 
     122            $support_info = strip_tags( $support_info ); 
     123        } 
     124 
     125        if ( $with_padding ) { 
     126            if ( 'text' === $format ) { 
     127                $support_info = "\n\n" . $support_info; 
     128            } else { 
     129                $support_info = '<br /><br />' . $support_info; 
     130            } 
     131        } 
     132 
     133        return $support_info; 
     134    } 
    89135} 
  • publish-to-apple-news/trunk/readme.txt

    r1556766 r1558569  
    55Requires at least: 4.0 
    66Tested up to: 4.7 
    7 Stable tag: 1.1.9 
     7Stable tag: 1.2.0 
    88License: GPLv3 or later 
    99License URI: http://www.gnu.org/licenses/gpl.html 
     
    1717**Features include:** 
    1818 
    19 * **Convert Your WordPress content into Apple News Format content.** 
    20 * **Configure Your Apple News Channel Credentials for Upload.** 
    21 * **Automatically or Manually Publish Posts from WP to Apple News.** 
    22 * **Control Individual Posts with Options to Publish, Update, or Delete.** 
    23 * **Use Bulk Publishing Controls.** 
    24 * **Handle Banners and Image Galleries.** 
    25 * **Toggle Advertisements On or Off.** 
     19* Convert your WordPress content into Apple News format automatically. 
     20* Create a custom design for your Apple News content with no programming knowledge required. 
     21* Automatically or manually publish posts from WordPress to Apple News. 
     22* Control individual posts with options to publish, update, or delete. 
     23* Publish individual posts or in bulk. 
     24* Handles image galleries and popular embeds like YouTube and Vimeo that are supported by Apple News. 
     25* Automatically adjust advertisement settings. 
    2626 
    2727To enable content from your WordPress blog to be published to your Apple News channel, you must obtain and enter Apple News API credentials from Apple. 
    2828 
    29 Please see the Apple Developer and Apple News Publisher documentation and terms on Apple’s website for complete information. 
    30  
     29Please see the [Apple Developer](https://developer.apple.com/) and [Apple News Publisher documentation](https://developer.apple.com/news-publisher/) and terms on Apple's website for complete information. 
    3130 
    3231== Installation == 
    3332 
    34 Installing the Publish to Apple News plugin is similar to the process of installing other WordPress plugins. Simply perform these steps: 
    35  
    36 1. Download the Publish to Apple News plugin. 
    37 1. Upload the entire “publish-to-apple-news” folder to the “./wp-content/plugins” directory on your web server. 
    38 1. Activate the Publish to Apple News plugin using the “Plugins” menu in WordPress. 
    39  
    40 Once activated, the "Apple News" menu should appear in your WordPress Admin panel. 
    41  
    42 NEW IN 1.1.6: More descriptive errors messages to allow for easier troubleshooting, especially for those without access to the News Preview tool. 
    43  
    44 NEW IN 1.1.4: We've made some improvements to the default template built into the plugin. Although it won't override your current settings, we strongly recommend placing the Cover image at the top of the Component Order settings for the best experience. 
    45  
    46 BREAKING CHANGE IN 1.1: Please note the "Options" page has been merged into a single page for setting sections, preview and pull quotes when pushing content to Apple News. This both adds functionality and streamlines the workflow. 
    47  
    48 Please read this for more information: http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen 
    49  
    50 = Troubleshooting: Resolving Image Issues = 
    51  
    52 Until recently, Apple News required all images to be bundled with the API request. Some hosts do not support allow_url_fopen, which is required for this functionality to work. Apple News now supports remote images so if you are experiencing any errors with images, please go to Settings > Apple News and set Use Remote Images to 'yes' under Advanced Settings. Please note that in order for this to work, your images must be publicly accessible which is the case for most sites. However, if you're testing on a local development site, your images are likely not accessible and therefore you should set this to 'no'. 
    53  
    54 = Troubleshooting: Resolving Potential Permissions Issues = 
    55  
    56 In most cases, the Publish to Apple News plugin should function immediately once installed. However, in some cases the default permissions WordPress has set for the plugin directory may be too restrictive to allow plugins to function properly. If you encounter errors, you may need to modify the permissions of both the “./apple-export/workspace” and the “./apple-export/workspace/tmp” directories. In most cases, setting permissions for these two directories to “775” will enable plugins to function properly. For additional information and detailed instructions for setting WordPress directory permissions, please see this WordPress technical post. 
    57  
    58 = Configuration = 
    59  
    60 Once the Publish to Apple News plugin has been installed and activated, the next step is configuration. To begin, choose Settings > Apple News from the WordPress Admin panel. 
    61  
    62 = Publishing your WordPress Site to Apple News = 
    63  
    64 This plugin is not responsible for setting up or managing your News Publisher channel with Apple, nor does using this plugin guarantee that Apple News will accept your content. Some information and links to documentation are provided here to point you in the right direction for this process. Please see the Apple Developer and Apple News Publisher documentation and terms on Apple’s website for complete information. 
    65  
    66 To enable content from your WordPress blog to be published to your Apple News channel, you must obtain and enter your Apple News API credentials from Apple to enable your WordPress content to be published to Apple News. 
    67  
    68 To obtain these credentials, click the “Apple News documentation” link at the top of the “API Settings” subsection of Settings > Apple News. This link will direct you to instructions for obtaining your credentials. Once you receive them from Apple, enter your private API Key, Secret, and Channel settings into the “Apple News API” fields. Once entered, you can begin publishing WordPress site content to Apple News. 
    69  
    70 = General (Site-wide) Settings = 
    71  
    72 Once your WordPress site has been linked to your Apple News channel, your next step is to configure site-wide general settings that determine how your content will be published to Apple News. You may want to review these site-wide settings on occasion. 
    73  
    74 **Choosing How Content is Published to Apple News** 
    75  
    76 The most important setting is the “Automatically Publish to Apple News” setting, located at the bottom of the “Apple News API” subsection of Settings > Apple News. 
    77  
    78 By default, this option is set to Yes, so that whenever you publish or update an article on your own WordPress site, the article will also be automatically pushed to your Apple News channel, without any additional action or customization on your part. In most cases, this setting is recommended. 
    79  
    80 If you would instead prefer more granular control over which content is posted to your Apple News channel, set “Automatically Publish…” to No. With this setting, new content posted to your site will not be automatically pushed to your Apple News channel. In this case, you will need to manually push any posts you create, or later modify, to Apple News (this process is described in “Per-Post Settings” below). 
    81  
    82 **Set Default Formatting** 
    83  
    84 The “Formatting” subsection of Settings > Apple News provides options that determine the general appearance for how posts in Apple News should appear. These settings are relatively detailed, giving you a higher level of control over how your content should appear. Note that if you do not apply specific preferences, the default settings have been designed so that your content will have a consistent, professional appearance. 
    85  
    86 **Advanced Settings** 
    87  
    88 Advanced settings allow you to set custom content height settings. In most cases, the default settings will provide the best results. However, you can also enter custom values if desired (values are typographical point sizes). To return to the default values, simply clear any values entered into these fields. 
    89  
    90 = Usage = 
    91  
    92 Once the above steps are completed, you’re ready to publish content to Apple News. If you’ve chosen to automatically publish your blog content to Apple News, all posts created and updated from this time forward will automatically be pushed to your Apple News channel. If you’ve disabled Automatic Publishing to Apple News, the following section describes the tools you’ll use to manually publish selected posts from your WordPress site to Apple News. 
    93  
    94 In addition, no matter which Automatic Publishing option you’ve selected, this section describes how you can override general settings for any specific post as desired. 
    95  
    96 **The “Apple News” Admin Panel Menu** 
    97  
    98 The “Apple News” menu (not to be confused with the site-wide Settings > Apple News described in the previous section) provides important tools and settings for specific posts. 
    99  
    100 **Controlling Individual Posts** 
    101  
    102 The top section of the “Apple News” pane provides a dashboard-like view that displays each post you’ve published on your WordPress blog, as well as whether each post has been published to your Apple News channel, and if so, the date of the latest update. In addition, individual and bulk controls give you granular control over each post. 
    103  
    104 As described above, if you’ve chosen to automatically publish content to Apple News, each new post that you publish (or later update) on your own WordPress site will also be automatically pushed to your Apple News channel. In this case, your primary use of these settings will likely be to override any posts you choose not to publish to Apple News. 
    105  
    106 On the other hand, if you’ve chosen not to automatically publish your content to Apple News, you will likely use these settings much more frequently. These settings will be the tool you’ll use each time you wish to initially publish — or later update — WordPress posts to Apple News. 
    107  
    108 **Individual Controls** 
    109  
    110 To publish a single post to your Apple News channel (or perform other actions), locate the desired post in the list of your locally published content, and hover your mouse immediately below the post’s title. This will display a contextual menu, presenting the following choices: “Download” and “Publish”. In addition, for posts already published to Apple News, two more choices will be displayed: “Delete from Apple News” and “Copy News URL“. 
    111  
    112 Choosing “Publish” will take you to a screen where you can select the sections to publish to, set the article as a preview, and optionally add a Pull Quote for the selected post. In addition to entering a pull quote, you can choose to place it at the top, middle, or bottom of the selected post. Click the button at the bottom to push the current version of the selected post to Apple News 
    113  
    114 Choosing “Delete from Apple News” will permanently remove the post from Apple News. You can override either choice at any future time (e.g., a post deleted from Apple News can later be published once again if desired). Note that once a post has been deleted from Apple News, no further updates will automatically be published to Apple News, regardless of whether you’ve enabled “Automatically Publish to Apple News” in your general settings. 
    115  
    116 The “Download” option will generate a JSON document describing the selected post to your browser’s default Downloads location. 
    117  
    118 **Bulk Publishing Controls** 
    119  
    120 Bulk actions can be particularly helpful for pushing older content to your Apple News channel. This is because Automatic Publishing only takes effect on content created or modified after the Publish to Apple News plugin has been installed. Therefore, to push a number of pre-existing posts to Apple News, Bulk Publishing can save significant time and redundant steps. 
    121  
    122 Warning: Using Bulk Publishing for a large number of pre-existing posts at one time may require significant processing time and server resources. It is recommended that you test this feature with smaller batches of pre-existing posts first. 
    123  
    124 You can choose to publish several posts to your Apple News channel at once, using the Bulk Actions control located at the top left of this section. Simply check any number of desired posts, then select “publish” from the Bulk Actions menu. This will open a page displaying the posts you’ve selected, and the status of each post as it is pushed to Apple News. Note that while bulk publishing actions are in progress, you should not close your browser window or navigate away from this page. Doing so will halt the bulk action in progress. 
    125  
    126 Bulk publishing will use the default section for your channel unless you have previously set the channel via the Apple News meta box on the post edit screen. 
    127  
    128 = Tips = 
    129  
    130 In general, little effort should be required to prepare your content itself for publishing to Apple News once you’ve configured this plugin to your desired settings. Even so, these simple tips will help your content look its best: 
    131  
    132 **Controlling Image Placement** 
    133  
    134 By default, images inserted in your content will be placed inline, and will follow WordPress placement rules. You may find your images will be presented better within Apple News if you take the time to set the appearance of each image. To do this, in the WordPress text editor, click on an image, which will display a contextual alignment menu. This will provide you with a series of simple granular controls, allowing you to determine more precisely where each image will be displayed when your post appears in Apple News. 
    135  
    136 The featured image on your post will automatically be used as the Apple News cover image. If no featured image is found, the first available image in the post will be used as the cover and will be automatically removed from the body in order to avoid duplication. 
    137  
    138 Note that images smaller than the body width (~1024px) will always be aligned. If you want to display an image without alignment, make sure it’s big enough. 
    139  
    140 **Banners** 
    141  
    142 You may also select an image to appear as a banner at the top of your post. To do this, choose a featured image by clicking on the “Set Featured Image” link when creating or updating a post. The image will displayed full width at the top of the selected post. 
    143  
    144 **Image Galleries** 
    145  
    146 You can add image galleries the same way you do in WordPress, by using the “Add Media” button in the WordPress editor. Once there, navigate to “Create Gallery” and choose any images you want. Once done, choose to use “Full Size” images instead of thumbnails. By default, galleries will be shown as a horizontal slide; if desired, you can change this to “Mosaic” style in the plugin settings. 
    147  
    148 **Advertisement** 
    149  
    150 While this plugin is not responsible for managing advertising options for your Apple News channel, it does provide simple settings to help you prepare your content for this. Please see the Apple News Publisher and iAds documentation and terms on Apple’s website for more information about advertising options on Apple News. 
    151  
    152 By default, your exported posts should be ready to include advertising content somewhere in the middle of your content. If you don’t want your WordPress content to be prepared in this way, simply set the “Advertisement” option in the plugin settings to No. 
    153  
     33Please visit our [wiki](https://github.com/alleyinteractive/apple-news/wiki) for detailed [installation instructions](https://github.com/alleyinteractive/apple-news/wiki/Installation) as well as [configuration](https://github.com/alleyinteractive/apple-news/wiki/Configuration) and [usage instructions](https://github.com/alleyinteractive/apple-news/wiki/Usage), [troubleshooting information](https://github.com/alleyinteractive/apple-news/wiki/Usage#troubleshooting) and a full list of [action and filter hooks](https://github.com/alleyinteractive/apple-news/wiki/action-and-filter-hooks). 
    15434 
    15535== Frequently Asked Questions == 
    15636 
    157 = What does the Publish To Apple News Plugin Do? = 
    158  
    159 The Publish to Apple News plugin enables your WordPress blog content to be published to your Apple News channel. 
     37Please visit our [wiki](https://github.com/alleyinteractive/apple-news/wiki) for detailed [installation instructions](https://github.com/alleyinteractive/apple-news/wiki/Installation) as well as [configuration](https://github.com/alleyinteractive/apple-news/wiki/Configuration) and [usage instructions](https://github.com/alleyinteractive/apple-news/wiki/Usage), [troubleshooting information](https://github.com/alleyinteractive/apple-news/wiki/Usage#troubleshooting) and a full list of [action and filter hooks](https://github.com/alleyinteractive/apple-news/wiki/action-and-filter-hooks). 
    16038 
    16139== Screenshots == 
    16240 
    163 1. 
     411. Manage all of your posts in Apple News from your WordPress dashboard 
     422. Create a custom design for your Apple News posts with no programming knowledge required. 
     433. Publish posts in bulk 
     444. Manage posts in Apple News right from the post edit screen 
    16445 
    16546== Changelog == 
     47 
     48= 1.2.0 = 
     49* Added a live preview of the font being selected (macOS only). 
     50* Added a live preview of formatting settings (font preview in macOS only). 
     51* Switched to the native WordPress color picker for greater browser compatibility. 
     52* Added a framework for JSON validation and validation for unicode character sequences that are symptomatic of display issues that have been witnessed, though not reproduced, in Apple News. 
     53* Broke out Action_Exception into its own class file for cleanliness. 
     54* Added direct support links to every error message. 
     55* Added better formatting of multiple error messages. 
     56* Added unit tests for the Apple_News and Admin_Apple_Notice classes. 
     57* Added new unit tests for Push. 
    16658 
    16759= 1.1.9 = 
     
    278170== Developers == 
    279171 
    280 If you are a developer, feel free to keep reading if you want to contribute. Publish to Apple News WordPress plugin works only on the admin-side so no public/ folder. 
    281  
    282 = Coding standards = 
    283  
    284 PHP code must follow WordPress Coding Standards. 
    285  
    286 Using EditorConfig is recommended so files always use the same formatting. 
    287  
    288 = Requirements = 
    289  
    290 In order to work with the plugin, you'll need a webserver such as Apache with PHP 5.3.6+ and MySQL 5+. 
    291  
    292 It's recommended to create a symbolic link for better code organization. 
    293  
    294 git clone ssh://... apple-export 
    295 cd apple-export 
    296 ln -s /home/my-user/my-projects/wppl /var/www/my-wp-installation/wp-content/plugins/apple-export 
    297 Make sure /home/my-user has execute permissions or WordPress might not show it as a plugin. You can do so by doing chmod o+x /home/my-user. 
    298  
    299 = PHP Configuration = 
    300  
    301 Make sure PHP's memory_limit setting is big enough, or set to -1, as the plugin might work with big images. Also make sure PHP's upload limit is big enough. 
    302  
    303 = Running tests = 
    304  
    305 You'll need PHPUnit v4.5+ to run tests. Initially you'll need to set up the test environment, you can do so by running 
    306  
    307 bin/install-wp-tests.sh <db-name> <db-user> <db-pass> [db-host] [wp-version] 
    308 For example 
    309  
    310 bin/install-wp-tests.sh wp_test root '' localhost latest 
    311 That script will download latest wordpress as well as latest wordpress' tests so /tests/bootstrap.php can load them. 
    312  
    313 You'll also need to set up your API credentials using your system's environmental variables. For UNIX systems (OS X, Linux, etc) you can simply edit the ~/.profile file, adding your variables as follows: 
    314  
    315 export WP_PLUGIN_KEY=my-api-key 
    316 export WP_PLUGIN_SECRET=my-api-secret 
    317 export WP_PLUGIN_CHANNEL=my-api-channel 
    318 Once updated, reload it using source ~/.profile. Test it out by doing echo $WP_PLUGIN_KEY, it should display your key in the terminal. 
    319  
    320 Now you can simply use the phpunit command to run the tests. 
    321  
     172Please visit us on [github](https://github.com/alleyinteractive/apple-news) to [submit issues](https://github.com/alleyinteractive/apple-news/issues), [pull requests](https://github.com/alleyinteractive/apple-news/pulls) or [read our wiki page about contributing](https://github.com/alleyinteractive/apple-news/wiki/contributing). 
  • publish-to-apple-news/trunk/tests/admin/apple-actions/index/test-class-push.php

    r1485664 r1558569  
    1111 
    1212    private $original_user_id; 
    13  
    14     private $component_message = 'The following components are unsupported by Apple News and were removed: iframe'; 
    1513 
    1614    public function setup() { 
     
    203201    public function testComponentErrorsWarn() { 
    204202        $this->settings->set( 'component_alerts', 'warn' ); 
     203        $this->settings->set( 'json_alerts', 'none' ); 
    205204 
    206205        $response = $this->dummy_response(); 
     
    227226 
    228227        $component_notice = end( $notices ); 
    229         $this->assertEquals( $this->component_message, $component_notice['message'] ); 
     228        $this->assertEquals( 'The following components are unsupported by Apple News and were removed: iframe', $component_notice['message'] ); 
    230229 
    231230        // The post was still sent to Apple News 
     
    237236    } 
    238237 
    239     /** 
    240      * @expectedException \Apple_Actions\Action_Exception 
    241      */ 
    242238    public function testComponentErrorsFail() { 
    243239        $this->settings->set( 'component_alerts', 'fail' ); 
     240        $this->settings->set( 'json_alerts', 'none' ); 
    244241 
    245242        $response = $this->dummy_response(); 
     
    255252        $post_id = $this->factory->post->create( array( 
    256253            'post_content' => '<p><iframe width="460" height="460" src="http://unsupportedservice.com/embed.html?video=1232345&autoplay=0" frameborder="0" allowfullscreen></iframe></p>', 
     254        ) ); 
     255 
     256        $action = new Push( $this->settings, $post_id ); 
     257        $action->set_api( $api->reveal() ); 
     258 
     259        try { 
     260            $action->perform(); 
     261        } catch ( Action_Exception $e ) { 
     262 
     263            // An admin error notice was created 
     264            $notices = get_user_meta( $user_id, 'apple_news_notice', true ); 
     265            $this->assertNotEmpty( $notices ); 
     266 
     267            $component_notice = end( $notices ); 
     268            $this->assertEquals( 'The following components are unsupported by Apple News and prevented publishing: iframe', $e->getMessage() ); 
     269 
     270            // The post was not sent to Apple News 
     271            $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_id', true ) ); 
     272            $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_created_at', true ) ); 
     273            $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_modified_at', true ) ); 
     274            $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_share_url', true ) ); 
     275            $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_deleted', true ) ); 
     276        } 
     277    } 
     278 
     279    public function testJSONErrorsWarn() { 
     280        $this->settings->set( 'component_alerts', 'none' ); 
     281        $this->settings->set( 'json_alerts', 'warn' ); 
     282 
     283        $response = $this->dummy_response(); 
     284        $api = $this->prophet->prophesize( '\Apple_Push_API\API' ); 
     285        $api->post_article_to_channel( Argument::cetera() ) 
     286            ->willReturn( $response ) 
     287            ->shouldBeCalled(); 
     288 
     289        // We need to create an iframe, so run as administrator 
     290        $user_id = $this->set_admin(); 
     291 
     292        // Create post 
     293        $post_id = $this->factory->post->create( array( 
     294            'post_content' => 'ÂÂîî', 
    257295        ) ); 
    258296 
     
    266304 
    267305        $component_notice = end( $notices ); 
    268         $this->assertEquals( $this->component_message, $component_notice['message'] ); 
    269  
    270         // The post was not sent to Apple News 
    271         $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_id', true ) ); 
    272         $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_created_at', true ) ); 
    273         $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_modified_at', true ) ); 
    274         $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_share_url', true ) ); 
    275         $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_deleted', true ) ); 
     306        $this->assertEquals( 'The following JSON errors were detected: Invalid unicode character sequences were found that could cause display issues on Apple News: ÂÂîî', $component_notice['message'] ); 
     307 
     308        // The post was still sent to Apple News 
     309        $this->assertEquals( $response->data->id, get_post_meta( $post_id, 'apple_news_api_id', true ) ); 
     310        $this->assertEquals( $response->data->createdAt, get_post_meta( $post_id, 'apple_news_api_created_at', true ) ); 
     311        $this->assertEquals( $response->data->modifiedAt, get_post_meta( $post_id, 'apple_news_api_modified_at', true ) ); 
     312        $this->assertEquals( $response->data->shareUrl, get_post_meta( $post_id, 'apple_news_api_share_url', true ) ); 
     313        $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_deleted', true ) ); 
     314    } 
     315 
     316    public function testJSONErrorsFail() { 
     317        $this->settings->set( 'component_alerts', 'none' ); 
     318        $this->settings->set( 'json_alerts', 'fail' ); 
     319 
     320        $response = $this->dummy_response(); 
     321        $api = $this->prophet->prophesize( '\Apple_Push_API\API' ); 
     322        $api->post_article_to_channel( Argument::cetera() ) 
     323            ->willReturn( $response ) 
     324            ->shouldNotBeCalled(); 
     325 
     326        // We need to create an iframe, so run as administrator 
     327        $user_id = $this->set_admin(); 
     328 
     329        // Create post 
     330        $post_id = $this->factory->post->create( array( 
     331            'post_content' => 'ÂÂîî', 
     332        ) ); 
     333 
     334        $action = new Push( $this->settings, $post_id ); 
     335        $action->set_api( $api->reveal() ); 
     336 
     337        try { 
     338            $action->perform(); 
     339        } catch ( Action_Exception $e ) { 
     340            // An admin error notice was created 
     341            $notices = get_user_meta( $user_id, 'apple_news_notice', true ); 
     342            $this->assertNotEmpty( $notices ); 
     343 
     344            $component_notice = end( $notices ); 
     345            $this->assertEquals( 'The following JSON errors were detected and prevented publishing: Invalid unicode character sequences were found that could cause display issues on Apple News: ÂÂîî', $e->getMessage() ); 
     346 
     347            // The post was not sent to Apple News 
     348            $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_id', true ) ); 
     349            $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_created_at', true ) ); 
     350            $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_modified_at', true ) ); 
     351            $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_share_url', true ) ); 
     352            $this->assertEquals( null, get_post_meta( $post_id, 'apple_news_api_deleted', true ) ); 
     353        } 
    276354    } 
    277355 
Note: See TracChangeset for help on using the changeset viewer.