Skip to content

Commit

Permalink
Merge pull request #6 from camayak/bug/5
Browse files Browse the repository at this point in the history
bug/5 - add javascript function to show camayak notice in block editors.
  • Loading branch information
edwardmsmith authored May 16, 2024
2 parents 2fc3947 + e973caf commit b43c4f3
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions camayak-admin-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,24 @@ function admin_post_notices( ) {

$cmyk_org_slug = get_post_meta( $post_ID, $this->org_field_name, true );
if ( ! empty( $cmyk_org_slug ) ) {
$camayak_url = 'https://' . $cmyk_org_slug . '.camayak.com/#/packages/' . $cmyk_package_uuid;
$camayak_link_text = 'Edit this assignment in Camayak';
$message = 'This post is being produced and archived in Camayak. <a href="' . $camayak_url . '">' . $camayak_link_text . '</a>';
// display a warning message with link to assignment overview page in Camayak
echo '<div class="error"><p style="height: 20px; line-height: 20px"><img src="';
echo plugins_url( 'images/camayak_icon.png', __FILE__ );
echo '" style="float: left; margin-right: 8px" alt="" />This post is being produced and archived in Camayak. <a href="';
echo 'https://' . $cmyk_org_slug . '.camayak.com/#/packages/' . $cmyk_package_uuid;;
echo '">Click here to edit this assignment in Camayak</a></p></div>';
echo '" style="float: left; margin-right: 8px" alt="" />' . $message . '</p></div>';
echo '<script>';
echo ' ( function( wp ) {';
echo ' wp.data.dispatch("core/notices").createNotice(';
echo ' "error", "This post is being produced and archived in Camayak.",';
echo ' {';
echo ' isDismissible: false,';
echo ' actions: [{url: "' . $camayak_url . '", label: "' . $camayak_link_text . '",},],';
echo ' }';
echo ' );';
echo ' } )( window.wp );';
echo '</script>';

// hide these custom fields from the UI to prevent tampering
add_filter( 'is_protected_meta', array( $this, 'is_protected_meta' ), 1, 2 );
Expand All @@ -45,4 +57,4 @@ function admin_post_notices( ) {
}
}
}
}
}

0 comments on commit b43c4f3

Please sign in to comment.