Plugin Directory

Changeset 3351069


Ignore:
Timestamp:
08/27/2025 10:15:40 AM (7 months ago)
Author:
bealoktiwari
Message:

1.17.3: Added fixes.

Location:
brightedge-autopilot-page-publisher/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • brightedge-autopilot-page-publisher/trunk/brightedge_autopilot_page_publisher.php

    r3347456 r3351069  
    33/**
    44 * @package brightedge-autopilot-page-publisher
    5  * @version 1.17.1
     5 * @version 1.17.3
    66 * Plugin Name: BrightEdge Autopilot Page Publisher
    77 * 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.1
     8 * Version: 1.17.3
    99 * Author: BrightEdge
    1010 * Author URI: https://www.brightedge.com/
  • brightedge-autopilot-page-publisher/trunk/includes/beapp-utilities.php

    r3347456 r3351069  
    4545
    4646/**
     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 */
     57function 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/**
    4773 * Validates if user is logged in and has the required role.
    4874 *
     
    5177function beapp_validate_user_login()
    5278{
     79  // Checks if user exists or is logged in.
    5380  $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;
    5784  }
     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    }
    5891  // User Role validation.
    5992  $current_user_role = $current_user->roles[0];
    6093  $allowed_roles = ['editor', 'administrator'];
    6194  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;
    66100}
    67101
  • brightedge-autopilot-page-publisher/trunk/readme.txt

    r3347456 r3351069  
    66Requires at least: 5.7
    77Tested up to: 6.8
    8 Stable tag: 1.17.1
     8Stable tag: 1.17.3
    99Requires PHP: 7.0
    1010Copyright: BrightEdge Technologies, Inc.
     
    4141
    4242== Changelog ==
     43### Version 1.17.3 (2025-08-26)
     44* Fixed issues.
     45
    4346### Version 1.17.1 (2025-08-11)
    4447
Note: See TracChangeset for help on using the changeset viewer.