-
Notifications
You must be signed in to change notification settings - Fork 62
Add Content Generation integration to WordPress Quick Draft widget #1012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
FILE: QuickDraftIntegration.php ----------------------------------------------------------------------------------------------- FOUND 7 ERRORS AND 9 WARNINGS AFFECTING 16 LINES ----------------------------------------------------------------------------------------------- 17 | ERROR | Whitespace found at end of line (Squiz.WhiteSpace.SuperfluousWhitespace.EndLine) 70 | ERROR | Whitespace found at end of line (Squiz.WhiteSpace.SuperfluousWhitespace.EndLine) 128 | ERROR | Whitespace found at end of line (Squiz.WhiteSpace.SuperfluousWhitespace.EndLine) 164 | WARNING | Array double arrow not aligned correctly; expected 1 space(s) between "'sanitize_callback'" and double arrow, but found 2. (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned) 165 | WARNING | Array double arrow not aligned correctly; expected 1 space(s) between "'validate_callback'" and double arrow, but found 2. (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned) 166 | WARNING | Array double arrow not aligned correctly; expected 7 space(s) between "'description'" and double arrow, but found 8. (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned) 179 | ERROR | Function closing brace must go on the next line following the body; found 1 blank lines before brace (PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose) 187 | WARNING | The method parameter $request is never used (Generic.CodeAnalysis.UnusedFunctionParameter.Found) 255 | ERROR | Opening parenthesis of a multi-line function call must be the last content on the line (PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket) 256 | WARNING | Array double arrow not aligned correctly; expected 2 space(s) between "'post_id'" and double arrow, but found 6. (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned) 257 | WARNING | Array double arrow not aligned correctly; expected 1 space(s) between "'edit_url'" and double arrow, but found 5. (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned) 258 | WARNING | Array double arrow not aligned correctly; expected 2 space(s) between "'content'" and double arrow, but found 6. (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned) 259 | WARNING | Array double arrow not aligned correctly; expected 4 space(s) between "'title'" and double arrow, but found 8. (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned) 260 | WARNING | Array double arrow not aligned correctly; expected 2 space(s) between "'success'" and double arrow, but found 6. (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned) 261 | ERROR | Closing parenthesis of a multi-line function call must be on a line by itself (PEAR.Functions.FunctionCallSignature.CloseBracketLine) 264 | ERROR | The closing brace for the class must go on the next line after the body (PSR2.Classes.ClassDeclaration.CloseBraceAfterBody) -----------------------------------------------------------------------------------------------
/home/runner/work/classifai/classifai/src/js/features/quick-draft/index.js Error: 11:56 error Insert `·` prettier/prettier Error: 17:3 error Unexpected console statement no-console Error: 21:2 error Unexpected console statement no-console Error: 24:46 error Insert `·` prettier/prettier Error: 35:9 error Variables should not be assigned until just prior its first reference. An early return statement may leave this variable unused @wordpress/no-unused-vars-before-return Error: 40:4 error Unexpected alert no-alert Error: 40:4 error 'alert' is not defined no-undef Error: 45:50 error Replace `·'classifai-generate-content'·` with `⏎↹↹↹'classifai-generate-content'⏎↹↹` prettier/prettier Error: 46:1 error Delete `↹↹` prettier/prettier Error: 49:26 error 'classifaiQuickDraft' is not defined no-undef Error: 51:3 error Unexpected console statement no-console Error: 58:5 error Expected property shorthand object-shorthand Error: 59:5 error Expected property shorthand object-shorthand Error: 61:6 error Replace `.then(·function` with `⏎↹↹↹.then(·function·` prettier/prettier Error: 62:4 error Replace `console.log(·'ClassifAI·Quick·Draft:·API·response·received',·response·);` with `↹console.log(⏎↹↹↹↹↹'ClassifAI·Quick·Draft:·API·response·received',⏎↹↹↹↹↹response` prettier/prettier Error: 62:4 error Unexpected console statement no-console Error: 63:4 error Insert `↹);⏎` prettier/prettier Error: 64:4 error Insert `↹` prettier/prettier Error: 65:5 error Insert `↹` prettier/prettier Error: 66:1 error Insert `↹` prettier/prettier Error: 67:5 error Insert `↹` prettier/prettier Error: 69:1 error Insert `↹` prettier/prettier Error: 70:5 error Insert `↹` prettier/prettier Error: 72:1 error Insert `↹` prettier/prettier Error: 73:1 error Insert `↹` prettier/prettier Error: 74:5 error Replace `setTimeout(·function` with `↹setTimeout(·function·` prettier/prettier Error: 75:1 error Insert `↹` prettier/prettier Error: 75:6 error 'location' is not defined no-undef Error: 76:5 error Insert `↹` prettier/prettier Error: 77:4 error Insert `↹` prettier/prettier Error: 78:1 error Replace `↹↹↹↹throw·new·Error(·response.message·||·classifaiQuickDraft.error·` with `↹↹↹↹↹throw·new·Error(⏎↹↹↹↹↹↹response.message·||·classifaiQuickDraft.error⏎↹↹↹↹↹` prettier/prettier Error: 78:42 error 'classifaiQuickDraft' is not defined no-undef Error: 79:1 error Insert `↹` prettier/prettier Error: 80:3 error Replace `}·).catch(·function` with `↹}·)⏎↹↹↹.catch(·function·` prettier/prettier Error: 81:1 error Insert `↹` prettier/prettier Error: 81:4 error Unexpected console statement no-console Error: 82:1 error Insert `↹` prettier/prettier Error: 82:4 error Unexpected alert no-alert Error: 82:4 error 'alert' is not defined no-undef Error: 82:28 error 'classifaiQuickDraft' is not defined no-undef Error: 83:3 error Replace `}·).finally(·function` with `↹}·)⏎↹↹↹.finally(·function·` prettier/prettier Error: 84:1 error Insert `↹` prettier/prettier Error: 85:1 error Insert `↹` prettier/prettier Error: 86:4 error Insert `↹` prettier/prettier Error: 86:27 error 'classifaiQuickDraft' is not defined no-undef Error: 87:1 error Insert `↹` prettier/prettier Error: 114:53 error Insert `·` prettier/prettier Error: 120:23 error Insert `·` prettier/prettier
message.className = 'notice notice-success is-dismissible'; | ||
message.innerHTML = ` | ||
<p> | ||
Draft created successfully! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a handful of strings in here that we aren't passing through translation that would be ideal to do
public function init_quick_draft_integration() { | ||
$quick_draft = new \Classifai\Features\QuickDraftIntegration(); | ||
$quick_draft->init(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I love initializing this here. Since this is tied to the Content Generation Feature, would it make more sense to initialize this in that class?
setTimeout(function() { | ||
var saveButton = $('#save-post'); | ||
if (saveButton.length && !$('#classifai-generate-content').length) { | ||
var generateButton = $('<input type="button" id="classifai-generate-content" class="button" value="<?php echo esc_js( __( 'Create Draft from Prompt Content', 'classifai' ) ); ?>" style="margin-left: 10px;" />'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're loading custom CSS, can we remove this inline style here and add it there instead?
* Register Quick Draft specific endpoints. | ||
*/ | ||
public function register_endpoints() { | ||
register_rest_route( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I almost think a better approach here would be to register a more generic endpoint in the Content Generation Feature class that allows generating content that isn't associated with a post ID (or modify our existing endpoint to support that). That way we don't end up with a very specific endpoint here
Description of the Change
This PR integrates ClassifAI's Content Generation feature with WordPress's native Quick Draft widget on the admin dashboard. Users can now generate AI-powered content directly from the Quick Draft interface, creating new draft posts with AI-generated content based on their prompts.
Key Features:
Closes #989.
How to test the Change
Enable Content Generation:
Test Quick Draft Integration:
Changelog Entry
Credits
Props @jeffpaul @faisal-alvi
Checklist: