Changeset 3787313 for autocontent/trunk/autocontent.php
- Timestamp:
- 11/06/2026 06:43:40 AM (3 days ago)
- File:
-
- 1 edited
-
autocontent/trunk/autocontent.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
autocontent/trunk/autocontent.php
r3787274 r3787313 5 5 * Plugin URI: https://autocontent.com/about/ 6 6 * Description: The simplest solution for automating content creation on WordPress. 7 * Version: 1.3 87 * Version: 1.39 8 8 * Requires at least: 6.5 9 9 * Requires PHP: 8.2 … … 592 592 if ($frequency === 'monthly') { 593 593 echo '<span id="current-plan-text" style="vertical-align: sub; padding">Free (Monthly Blog Posts)</span>'; 594 echo '<button id="upgrade_button" type="button" class="button button-secondary"> Upgrade</button>';594 echo '<button id="upgrade_button" type="button" class="button button-secondary">' . esc_html__('Upgrade to Premium', 'autocontent') . ' <span aria-hidden="true">→</span></button>'; 595 595 } elseif ($frequency === 'daily') { 596 596 echo esc_html('Autocontent Premium (Daily Blog Posts)'); … … 1127 1127 if (empty($keywords) || empty($subject)) { 1128 1128 autocontent_log_error_message('Keywords and subject are required. Cannot make API call'); 1129 return ;1129 return new WP_Error('autocontent_settings', __('Add a subject and at least one keyword, then click Save Changes before generating a post.', 'autocontent')); 1130 1130 } 1131 1131 // Prepare the POST data … … 1162 1162 if (is_wp_error($response)) { 1163 1163 autocontent_log_error_message('API request error: ' . $response->get_error_message()); 1164 return ;1164 return new WP_Error('autocontent_unreachable', __('Could not reach the Autocontent service. Please try again in a few minutes.', 'autocontent')); 1165 1165 } 1166 1166 … … 1222 1222 } 1223 1223 } else { 1224 // Handle errors 1224 // Handle errors: turn the API's answer into a message the user can act on. 1225 1225 autocontent_log_error_message('API request error: ' . $body); 1226 return new WP_Error('autocontent_api', autocontent_api_error_message($data)); 1226 1227 } 1227 1228 … … 1388 1389 1389 1390 // Function to hand generating post manually 1391 /** 1392 * Human-readable message for a failed generate request. 1393 */ 1394 function autocontent_api_error_message($data) { 1395 $error = is_array($data) && !empty($data['error']) ? (string) $data['error'] : ''; 1396 if (strpos($error, 'doesUserHaveEnoughCredits') !== false) { 1397 return __('You are out of WriteNow credits. Your scheduled posts will continue as normal.', 'autocontent'); 1398 } 1399 if (strpos($error, 'subscriptionInactive') !== false) { 1400 return __('Your Autocontent Premium subscription has ended. Renew at autocontent.com to keep your daily posts and WriteNow credits.', 'autocontent'); 1401 } 1402 if (strpos($error, 'isValidActivationKey') !== false || strpos($error, 'isValidWebsiteOrigin') !== false) { 1403 return __('Your activation key could not be verified for this site. Re-enter your key under Upgrade, then try again.', 'autocontent'); 1404 } 1405 if ($error !== '' && strpos($error, 'Unauthorized') === false) { 1406 return $error; 1407 } 1408 return __('Post generation failed. No credit was used. Please try again in a few minutes.', 'autocontent'); 1409 } 1410 1390 1411 function autocontent_generate_post_now_callback() { 1391 1412 autocontent_log_error_message('AJAX call: autocontent_generate_post_now_callback'); … … 1402 1423 $post_id = autocontent($callType); 1403 1424 // Check if the post was created successfully and get the post URL 1404 if (!is_wp_error($post_id)) { 1425 if (is_wp_error($post_id)) { 1426 autocontent_log_error_message('Error generating post: ' . $post_id->get_error_message()); 1427 wp_send_json_error(array('message' => $post_id->get_error_message())); 1428 } elseif (empty($post_id)) { 1429 autocontent_log_error_message('Error generating post: no post created.'); 1430 wp_send_json_error(array('message' => __('Post generation failed. Please try again in a few minutes.', 'autocontent'))); 1431 } else { 1405 1432 $post_url = get_permalink($post_id); 1433 autocontent_log_error_message("Post generated successfully. Post ID: $post_id, Post URL: $post_url"); 1406 1434 wp_send_json_success(array('post_url' => $post_url)); 1407 autocontent_log_error_message("Post generated successfully. Post ID: $post_id, Post URL: $post_url");1408 } else {1409 autocontent_log_error_message('Error generating post.');1410 wp_send_json_error('Error generating post');1411 1412 1435 } 1413 1436 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)