Changeset 3351069
- Timestamp:
- 08/27/2025 10:15:40 AM (7 months ago)
- Location:
- brightedge-autopilot-page-publisher/trunk
- Files:
-
- 3 edited
-
brightedge_autopilot_page_publisher.php (modified) (1 diff)
-
includes/beapp-utilities.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
brightedge-autopilot-page-publisher/trunk/brightedge_autopilot_page_publisher.php
r3347456 r3351069 3 3 /** 4 4 * @package brightedge-autopilot-page-publisher 5 * @version 1.17. 15 * @version 1.17.3 6 6 * Plugin Name: BrightEdge Autopilot Page Publisher 7 7 * Description: Plugin to update Title, Meta Description, and H1 tag based on recommendations from the BrightEdge Platform. Also supports update of XPath elements and Schema. 8 * Version: 1.17. 18 * Version: 1.17.3 9 9 * Author: BrightEdge 10 10 * Author URI: https://www.brightedge.com/ -
brightedge-autopilot-page-publisher/trunk/includes/beapp-utilities.php
r3347456 r3351069 45 45 46 46 /** 47 * Creates a standard JSON response. 48 * 49 * @since 1.10.0 50 * @param string $status The status of the response ('success' or 'fail'). 51 * @param string $message The response message. 52 * @param string $error_code Optional error code for failed responses. 53 * @param int $http_status The HTTP status code. 54 * @param string $data_key The key of the data to be returned. 55 * @return void 56 */ 57 function beapp_send_json_response($status, $message, $error_code = '', $http_status = 200, $data_key = 'message') 58 { 59 $response_data = array( 60 'status' => $status, 61 $data_key => $message, 62 'plugin_version' => BEAPP_VERSION, 63 ); 64 65 if ('fail' === $status && ! empty($error_code)) { 66 $response_data['error_code'] = $error_code; 67 } 68 69 wp_send_json($response_data, $http_status); 70 } 71 72 /** 47 73 * Validates if user is logged in and has the required role. 48 74 * … … 51 77 function beapp_validate_user_login() 52 78 { 79 // Checks if user exists or is logged in. 53 80 $current_user = wp_get_current_user(); 54 // Checks if user exists or is logged in.55 if ($current_user->id == 0) { 56 return beapp_create_rest_response('fail', BEAPP_Response_Messages::AUTH_FAILED, BEAPP_Response_Messages::ERROR_CODE_AUTHENTICATION_FAILED, 401);81 if ($current_user->ID === 0) { 82 beapp_send_json_response('fail', BEAPP_Response_Messages::AUTH_FAILED, BEAPP_Response_Messages::ERROR_CODE_AUTHENTICATION_FAILED, 401); 83 return false; 57 84 } 85 86 // Check if user has any roles assigned 87 if (empty($current_user->roles)) { 88 beapp_send_json_response('fail', BEAPP_Response_Messages::ACCESS_RESTRICTED, BEAPP_Response_Messages::ERROR_CODE_ACCESS_DENIED, 402); 89 return false; 90 } 58 91 // User Role validation. 59 92 $current_user_role = $current_user->roles[0]; 60 93 $allowed_roles = ['editor', 'administrator']; 61 94 if (!in_array($current_user_role, $allowed_roles)) { 62 return beapp_create_rest_response('fail', BEAPP_Response_Messages::ACCESS_RESTRICTED, BEAPP_Response_Messages::ERROR_CODE_ACCESS_DENIED, 401); 63 } 64 65 return true; 95 beapp_send_json_response('fail', BEAPP_Response_Messages::ACCESS_RESTRICTED, BEAPP_Response_Messages::ERROR_CODE_ACCESS_DENIED, 401); 96 return false; 97 } 98 99 return true; 66 100 } 67 101 -
brightedge-autopilot-page-publisher/trunk/readme.txt
r3347456 r3351069 6 6 Requires at least: 5.7 7 7 Tested up to: 6.8 8 Stable tag: 1.17. 18 Stable tag: 1.17.3 9 9 Requires PHP: 7.0 10 10 Copyright: BrightEdge Technologies, Inc. … … 41 41 42 42 == Changelog == 43 ### Version 1.17.3 (2025-08-26) 44 * Fixed issues. 45 43 46 ### Version 1.17.1 (2025-08-11) 44 47
Note: See TracChangeset
for help on using the changeset viewer.