Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Added tranformation warning indicator column #898

Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions css/instant-articles-index-column.css
@@ -0,0 +1,16 @@
span.instant-articles-col-status {
border-radius: 5px;
width: 10px;
height: 10px;
display: block;
}
span.error {
background: red;
}
span.ok {
background: green;
}
span.warning {
background: orange;
}

57 changes: 57 additions & 0 deletions facebook-instant-articles.php
Expand Up @@ -280,6 +280,14 @@ function instant_articles_register_scripts() {
IA_PLUGIN_VERSION,
false
);
wp_register_style(
'instant-articles-index-column',
plugins_url( '/css/instant-articles-index-column.css', __FILE__ ),
null,
IA_PLUGIN_VERSION,
false
);


wp_register_script(
'instant-articles-meta-box',
Expand Down Expand Up @@ -329,6 +337,7 @@ function instant_articles_enqueue_scripts() {
wp_enqueue_style( 'instant-articles-settings-wizard' );
wp_enqueue_style( 'instant-articles-settings' );
wp_enqueue_style( 'instant-articles-wizard' );
wp_enqueue_style( 'instant-articles-index-column' );

wp_enqueue_script( 'instant-articles-meta-box' );
wp_enqueue_script( 'instant-articles-option-ads' );
Expand Down Expand Up @@ -439,4 +448,52 @@ function invalidate_all_posts_transformation_info_cache( $option ) {
}
add_action( 'updated_option', 'invalidate_all_posts_transformation_info_cache', 10, 1 );

function fbia_indicator_column_heading( $columns ) {
$publishing_settings = Instant_Articles_Option_Publishing::get_option_decoded();
$display_warning_column = $publishing_settings[ 'display_warning_column' ];

if( "1" === $display_warning_column ) {
$columns[ 'FBIA' ] = "<span title='Facebook Instant Article Distribution Status' class='fbia-col-heading'>FB IA Status</span>";
}
return $columns;
}
add_filter( 'manage_posts_columns', 'fbia_indicator_column_heading' );

function fbia_indication_column( $column_name, $post_ID ) {
$publishing_settings = Instant_Articles_Option_Publishing::get_option_decoded();
$display_warning_column = $publishing_settings[ 'display_warning_column' ];

if( "1" === $display_warning_column ) {
$red_light = '<span title="Instant article is empty after transformation." class="instant-articles-col-status error"></span>';

$yellow_light = '<span title="Instant article has warnings after transformation." class="instant-articles-col-status warning"></span>';

$green_light = '<span title="Instant article transformed successfully." class="instant-articles-col-status ok"></span>';

if ( $column_name === "FBIA" ) {
$post = get_post( $post_ID );
$instant_articles_post = new \Instant_Articles_Post( $post );

$is_empty = $instant_articles_post->is_empty_after_transformation();
if ( true === $is_empty ) {
echo wp_kses_post( $red_light );
return;
}

$has_warnings = $instant_articles_post->has_warnings_after_transformation();
if ( true === $has_warnings ) {
echo wp_kses_post( $yellow_light );
return;
}

echo wp_kses_post( $green_light );

return;
}
}
}
add_action( 'manage_posts_custom_column', 'fbia_indication_column', 10, 2 );



}
8 changes: 8 additions & 0 deletions wizard/class-instant-articles-option-publishing.php
Expand Up @@ -55,6 +55,14 @@ class Instant_Articles_Option_Publishing extends Instant_Articles_Option {
'checkbox_label' => 'Publish articles containing warnings',
),

'display_warning_column' => array(
'label' => 'FB IA Status column',
'description' => 'With this option enabled, a column will be added to post indexes to quickly see whether an article transformation failed, succeeded, or had warnings.',
'render' => 'checkbox',
'default' => false,
'checkbox_label' => 'Enable column "FB IA Status"',
),

'likes_on_media' => array(
'label' => 'Likes',
'description' => 'With this option enabled, any image or video will have the like action enabled by default.',
Expand Down