Plugin Directory

Changeset 3169735


Ignore:
Timestamp:
10/16/2024 05:00:36 AM (17 months ago)
Author:
crowdaa
Message:

Version 1.10.0

Location:
crowdaa-sync
Files:
4 added
6 edited
41 copied

Legend:

Unmodified
Added
Removed
  • crowdaa-sync/tags/1.10.0/CHANGELOG

    r3150916 r3169735  
    77
    88## [Unreleased]
     9
     10## [1.10.0] - 2024-10-16
     11
     12### Changed
     13
     14- Added FR translations
     15- Updated interface for easier use
    916
    1017## [1.9.0] - 2024-09-10
  • crowdaa-sync/tags/1.10.0/README.txt

    r3150916 r3169735  
    66Requires PHP: 7.3
    77Tested up to: 5.9
    8 Stable tag: 1.9.1
     8Stable tag: 1.10.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • crowdaa-sync/tags/1.10.0/admin/class-crowdaa-sync-admin-display.php

    r3150916 r3169735  
    1414class Crowdaa_Sync_Admin_Display
    1515{
     16  private const AUTH_API_KEY = 'nQ9ZO9DEgfaOzWY44Xu2J2uaPtP92t176PpBkdqu';
    1617  /**
    1718   * Initialize the class and set its properties.
     
    112113  {
    113114    $pluginApiKey = Crowdaa_Sync_Utils::generate_plugin_api_key();
     115    $syncDomainNames = get_option('crowdaa_sync_domain_names');
    114116    $api = new Crowdaa_Sync_API();
    115117    $response = $api->http_request('POST', '/websites/crowdaa-sync/autosetup', [
     118      'action' => 'setup',
    116119      'pluginApiKey' => $pluginApiKey,
     120      'wordpressApiUrl' => preg_replace('~/$~', '', get_rest_url()),
     121      'defaultWordpressUrl' => get_site_url(),
     122      'syncDomainNames' => explode(',', $syncDomainNames),
    117123    ]);
    118124
     
    140146  }
    141147
     148  public function on_logout_unset()
     149  {
     150    $pluginApiKey = Crowdaa_Sync_Utils::get_plugin_api_key();
     151    $api = new Crowdaa_Sync_API();
     152    $api->http_request('POST', '/websites/crowdaa-sync/autosetup', [
     153      'action' => 'logout',
     154      'pluginApiKey' => $pluginApiKey,
     155      'wordpressApiUrl' => preg_replace('~/$~', '', get_rest_url()),
     156    ]);
     157  }
     158
    142159  /**
    143160   * Admin notices
     
    152169
    153170    Crowdaa_Sync_Logs::log('Parameters', 'connection_settings', 'Enabling connection...');
    154     update_option('crowdaa_user_id', '');
    155     update_option('crowdaa_auth_token', '');
    156     update_option('crowdaa_api_url', '');
    157     update_option('crowdaa_user_email', '');
    158     update_option('crowdaa_user_password', '');
    159     update_option('crowdaa_user_auth_api_key', '');
    160     if (isset($_POST['api_url'])) {
    161       update_option('crowdaa_api_url', esc_url_raw($_POST['api_url']));
    162     } else {
    163       add_action(
    164         'admin_notices',
    165         function () {
    166           self::admin_notice('error', __('Add API URL, please', CROWDAA_SYNC_PLUGIN_NAME));
    167         }
    168       );
    169       return;
    170     }
    171171    if (isset($_POST['status']) && $_POST['status'] == 'connect') {
    172       if (isset($_POST['user_auth_api_key']) && isset($_POST['user_api_key']) && isset($_POST['user_email']) && isset($_POST['user_password'])) {
     172      if (isset($_POST['api_url']) && isset($_POST['user_app_id']) && isset($_POST['user_email']) && isset($_POST['user_password'])) {
     173        update_option('crowdaa_api_url', esc_url_raw($_POST['api_url']));
    173174        $user_email = sanitize_email($_POST['user_email']);
    174175        $user_password = Crowdaa_Sync_Api::sanitize_api_password($_POST['user_password']);
    175         $user_api_key = Crowdaa_Sync_Api::sanitize_api_key($_POST['user_api_key']);
    176         $user_auth_api_key = Crowdaa_Sync_Api::sanitize_api_key($_POST['user_auth_api_key']);
     176        $user_app_id = Crowdaa_Sync_Api::sanitize_api_key($_POST['user_app_id']);
     177        $sync_domain_names = Crowdaa_Sync_Api::sanitize_sync_domain_names($_POST['sync_domain_names']);
    177178        $data = [
    178179          'email'    => $user_email,
     
    182183        $api = new Crowdaa_Sync_API();
    183184
    184         $response = $api->http_request('POST', '/auth/login', $data, ['X-Api-Key' => $user_auth_api_key]);
     185        $response = $api->http_request('POST', '/auth/login', $data, ['X-Api-Key' => self::AUTH_API_KEY]);
    185186        $err    = is_wp_error($response) ? $response->get_error_message() : null;
    186187        if (!$err) {
     
    229230          update_option('crowdaa_user_email', $user_email);
    230231          update_option('crowdaa_user_password', md5($user_password));
    231           update_option('crowdaa_user_api_key', $user_api_key);
    232           update_option('crowdaa_user_auth_api_key', $user_auth_api_key);
     232          update_option('crowdaa_user_api_key', 'appId:' . $user_app_id);
    233233          update_option('crowdaa_user_id', $json->data->userId);
    234234          update_option('crowdaa_auth_token', $json->data->authToken);
     235          update_option('crowdaa_sync_domain_names', $sync_domain_names);
    235236
    236237          $ok = $this->post_login_setup();
     
    241242            update_option('crowdaa_user_email', '');
    242243            update_option('crowdaa_user_password', '');
    243             update_option('crowdaa_user_auth_api_key', '');
     244            update_option('crowdaa_user_api_key', '');
     245            update_option('crowdaa_sync_domain_names', '');
    244246
    245247            self::admin_notice('error', __('Failed to complete login initialization process', CROWDAA_SYNC_PLUGIN_NAME));
     
    268270      return;
    269271    } else {
     272      $this->on_logout_unset();
     273
     274      update_option('crowdaa_user_id', '');
     275      update_option('crowdaa_auth_token', '');
     276      update_option('crowdaa_api_url', '');
     277      update_option('crowdaa_user_email', '');
     278      update_option('crowdaa_user_password', '');
     279      update_option('crowdaa_user_api_key', '');
     280      update_option('crowdaa_sync_domain_names', '');
     281
    270282      Crowdaa_Sync_Logs::log('Parameters', 'connection_settings', 'Connection disabled');
    271283    }
  • crowdaa-sync/tags/1.10.0/admin/class-crowdaa-sync-api.php

    r3149200 r3169735  
    10821082   * @return boolean
    10831083   */
    1084   public function update_category($cat_id, $cat_name, $cat_slug, $parent_category_id, $badges, $picture_id = false, $is_event)
     1084  public function update_category($cat_id, $cat_name, $cat_slug, $parent_category_id, $badges, $picture_id = false, $is_event = false)
    10851085  {
    10861086    $data = [
     
    12501250    return (preg_replace('/(\s|[\x00-\x1F\x7F-\xFF]|[^\x00-\xFF])/is', '', $key));
    12511251  }
     1252
     1253  public static function sanitize_sync_domain_names($input)
     1254  {
     1255    $raw_list = explode(',', $input);
     1256
     1257    $filtered_list = array_filter($raw_list, function ($value) {
     1258      $valid_regex = '/^[a-zA-Z0-9](([a-zA-Z0-9]|-)*[a-zA-Z0-9])?(\.[a-zA-Z0-9](([a-zA-Z0-9]|-)*[a-zA-Z0-9])?)*$/';
     1259      $trimmed = trim($value);
     1260      if (!$trimmed) return false;
     1261      if (!preg_match($valid_regex, $trimmed)) return false;
     1262      return true;
     1263    });
     1264
     1265    return implode(',', $filtered_list);
     1266  }
    12521267}
  • crowdaa-sync/tags/1.10.0/admin/partials/crowdaa-sync-admin-display.php

    r3149200 r3169735  
    2828    $user_email         = get_option('crowdaa_user_email');
    2929    $user_password      = get_option('crowdaa_user_password');
    30     $user_auth_api_key  = get_option('crowdaa_user_auth_api_key');
    3130    $user_api_key       = get_option('crowdaa_user_api_key');
    3231    $auth_token         = get_option('crowdaa_auth_token');
     32    $sync_domain_names  = get_option('crowdaa_sync_domain_names');
    3333    $plugin_api_key     = Crowdaa_Sync_Utils::get_plugin_api_key();
     34
     35    $is_authenticated = ($user_email && $user_password && $user_api_key && $auth_token);
     36    $user_app_id = $user_api_key ? substr($user_api_key, 6) : '';
     37
     38    $api_urls = [
     39      'https://api.aws.crowdaa.com/v1' => __('US platform', CROWDAA_SYNC_PLUGIN_NAME),
     40      'https://api-fr.aws.crowdaa.com/v1' => __('FR platform', CROWDAA_SYNC_PLUGIN_NAME),
     41    ];
     42    if (isset($_GET['api'])) {
     43      $api_urls[$_GET['api']] = $_GET['api'];
     44    }
     45    if ($api_url && !array_key_exists($api_url, $api_urls)) {
     46      $api_urls[$api_url] = $api_url;
     47    }
    3448    ?>
    3549    <div class="crowdaa-html-container">
    3650      <p>
    3751        <label class="text-label" for="api_url"><?php esc_html_e('API URL', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
    38         <input type="text" required id="api_url" name="api_url" value="<?php echo esc_attr(($api_url && $auth_token) ? $api_url : ''); ?>" />
    39       </p>
    40       <p>
    41         <label class="text-label" for="user_auth_api_key"><?php esc_html_e('Authentication API key', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
    42         <input required id="user_auth_api_key" name="user_auth_api_key" value="<?php echo esc_attr(($user_auth_api_key && $auth_token) ? $user_auth_api_key : ''); ?>" />
    43       </p>
    44       <p>
    45         <label class="text-label" for="user_api_key"><?php esc_html_e('Application API key', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
    46         <input required id="user_api_key" name="user_api_key" value="<?php echo esc_attr(($user_api_key && $auth_token) ? $user_api_key : ''); ?>" />
     52        <select <?php echo $is_authenticated ? 'disabled' : '' ?> name="api_url">
     53          <?php
     54          foreach ($api_urls as $url => $name) { ?>
     55            <option value="<?php echo esc_attr($url); ?>" <?php echo ($url === $api_url ? 'selected="selected"' : ''); ?>>
     56              <?php echo esc_html($name); ?>
     57            </option>
     58          <?php } ?>
     59        </select>
     60      </p>
     61      <p>
     62        <label class="text-label" for="user_app_id"><?php esc_html_e('App ID', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
     63        <input <?php echo $is_authenticated ? 'readonly' : '' ?> type="text" required id="user_app_id" name="user_app_id" value="<?php echo esc_attr(($user_app_id && $is_authenticated) ? $user_app_id : ''); ?>" />
    4764      </p>
    4865      <p>
    4966        <label class="text-label" for="user_email"><?php esc_html_e('Email', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
    50         <input type="text" required id="user_email" name="user_email" value="<?php echo esc_attr(($user_email && $auth_token) ? $user_email : ''); ?>" />
     67        <input <?php echo $is_authenticated ? 'readonly' : '' ?> type="text" required id="user_email" name="user_email" value="<?php echo esc_attr(($user_email && $is_authenticated) ? $user_email : ''); ?>" />
    5168      </p>
    5269      <p>
    5370        <label class="text-label" for="user_password"><?php esc_html_e('Password', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
    54         <input type="password" required id="user_password" name="user_password" value="<?php echo esc_attr(($user_password && $auth_token) ? $user_password : ''); ?>" />
     71        <input <?php echo $is_authenticated ? 'readonly' : '' ?> type="password" required id="user_password" name="user_password" value="<?php echo esc_attr(($user_password && $is_authenticated) ? $user_password : ''); ?>" />
     72      </p>
     73      <p>
     74        <?php
     75        $site_url = get_site_url();
     76        if ($site_url) {
     77          $current_domain = parse_url($site_url)['host'];
     78        } else if (isset($_SERVER['HTTP_HOST'])) {
     79          $current_domain = $_SERVER['HTTP_HOST'];
     80        } else {
     81          $current_domain = '';
     82        }
     83        ?>
     84        <label class="text-label" for="sync_domain_names"><?php esc_html_e('Domain names', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
     85        <input
     86          <?php echo $is_authenticated ? 'readonly' : '' ?>
     87          type="text"
     88          pattern="[a-zA-Z0-9](([a-zA-Z0-9]|-)*[a-zA-Z0-9])?(\.[a-zA-Z0-9](([a-zA-Z0-9]|-)*[a-zA-Z0-9])?)*( *, *[a-zA-Z0-9](([a-zA-Z0-9]|-)*[a-zA-Z0-9])?(\.[a-zA-Z0-9](([a-zA-Z0-9]|-)*[a-zA-Z0-9])?)*)*"
     89          title="<?php echo esc_attr_e('Comma-separated domain names list for your website, like example.com, www.example.com, other.subdomain.example.com', CROWDAA_SYNC_PLUGIN_NAME); ?>"
     90          id="sync_domain_names"
     91          name="sync_domain_names"
     92          value="<?php echo esc_attr(($sync_domain_names && $is_authenticated) ? $sync_domain_names : $current_domain); ?>" />
    5593      </p>
    5694      <p>
     
    62100    <?php
    63101    wp_nonce_field('crowdaa_login_data', 'crowdaa_login');
    64     if ($user_email && $user_password && $user_auth_api_key && $user_api_key) {
     102    if ($is_authenticated) {
    65103    ?>
    66104      <input type="hidden" id="status" name="status" value="disconnect" />
    67105    <?php
    68       submit_button('Disconnect from Crowdaa');
     106      submit_button(__('Disconnect from Crowdaa', CROWDAA_SYNC_PLUGIN_NAME));
    69107    } else {
    70108    ?>
    71109      <input type="hidden" id="status" name="status" value="connect" />
    72110    <?php
    73       submit_button('Connect to Crowdaa');
     111      submit_button(__('Connect to Crowdaa', CROWDAA_SYNC_PLUGIN_NAME));
    74112    }
    75113    ?>
     
    106144
    107145  <?php
    108   if ($user_email && $user_password && $user_auth_api_key && $user_api_key && $auth_token) {
     146  if ($is_authenticated) {
    109147  ?>
    110148    <hr />
  • crowdaa-sync/tags/1.10.0/crowdaa-sync.php

    r3150916 r3169735  
    1414 * Plugin URI:       
    1515 * Description:       Plugin for synchronizing WordPress site and Crowdaa CMS
    16  * Version:           1.9.1
     16 * Version:           1.10.0
    1717 * Requires at least: 5.5
    1818 * Requires PHP:      7.2
     
    3434 * Uses SemVer - https://semver.org
    3535 */
    36 define('CROWDAA_SYNC_VERSION', '1.9.1');
     36define('CROWDAA_SYNC_VERSION', '1.10.0');
    3737define('CROWDAA_SYNC_PLUGIN_DIR', __DIR__);
    3838define('CROWDAA_SYNC_PLUGIN_NAME', 'crowdaa-sync');
  • crowdaa-sync/trunk/CHANGELOG

    r3150916 r3169735  
    77
    88## [Unreleased]
     9
     10## [1.10.0] - 2024-10-16
     11
     12### Changed
     13
     14- Added FR translations
     15- Updated interface for easier use
    916
    1017## [1.9.0] - 2024-09-10
  • crowdaa-sync/trunk/README.txt

    r3150916 r3169735  
    66Requires PHP: 7.3
    77Tested up to: 5.9
    8 Stable tag: 1.9.1
     8Stable tag: 1.10.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • crowdaa-sync/trunk/admin/class-crowdaa-sync-admin-display.php

    r3150916 r3169735  
    1414class Crowdaa_Sync_Admin_Display
    1515{
     16  private const AUTH_API_KEY = 'nQ9ZO9DEgfaOzWY44Xu2J2uaPtP92t176PpBkdqu';
    1617  /**
    1718   * Initialize the class and set its properties.
     
    112113  {
    113114    $pluginApiKey = Crowdaa_Sync_Utils::generate_plugin_api_key();
     115    $syncDomainNames = get_option('crowdaa_sync_domain_names');
    114116    $api = new Crowdaa_Sync_API();
    115117    $response = $api->http_request('POST', '/websites/crowdaa-sync/autosetup', [
     118      'action' => 'setup',
    116119      'pluginApiKey' => $pluginApiKey,
     120      'wordpressApiUrl' => preg_replace('~/$~', '', get_rest_url()),
     121      'defaultWordpressUrl' => get_site_url(),
     122      'syncDomainNames' => explode(',', $syncDomainNames),
    117123    ]);
    118124
     
    140146  }
    141147
     148  public function on_logout_unset()
     149  {
     150    $pluginApiKey = Crowdaa_Sync_Utils::get_plugin_api_key();
     151    $api = new Crowdaa_Sync_API();
     152    $api->http_request('POST', '/websites/crowdaa-sync/autosetup', [
     153      'action' => 'logout',
     154      'pluginApiKey' => $pluginApiKey,
     155      'wordpressApiUrl' => preg_replace('~/$~', '', get_rest_url()),
     156    ]);
     157  }
     158
    142159  /**
    143160   * Admin notices
     
    152169
    153170    Crowdaa_Sync_Logs::log('Parameters', 'connection_settings', 'Enabling connection...');
    154     update_option('crowdaa_user_id', '');
    155     update_option('crowdaa_auth_token', '');
    156     update_option('crowdaa_api_url', '');
    157     update_option('crowdaa_user_email', '');
    158     update_option('crowdaa_user_password', '');
    159     update_option('crowdaa_user_auth_api_key', '');
    160     if (isset($_POST['api_url'])) {
    161       update_option('crowdaa_api_url', esc_url_raw($_POST['api_url']));
    162     } else {
    163       add_action(
    164         'admin_notices',
    165         function () {
    166           self::admin_notice('error', __('Add API URL, please', CROWDAA_SYNC_PLUGIN_NAME));
    167         }
    168       );
    169       return;
    170     }
    171171    if (isset($_POST['status']) && $_POST['status'] == 'connect') {
    172       if (isset($_POST['user_auth_api_key']) && isset($_POST['user_api_key']) && isset($_POST['user_email']) && isset($_POST['user_password'])) {
     172      if (isset($_POST['api_url']) && isset($_POST['user_app_id']) && isset($_POST['user_email']) && isset($_POST['user_password'])) {
     173        update_option('crowdaa_api_url', esc_url_raw($_POST['api_url']));
    173174        $user_email = sanitize_email($_POST['user_email']);
    174175        $user_password = Crowdaa_Sync_Api::sanitize_api_password($_POST['user_password']);
    175         $user_api_key = Crowdaa_Sync_Api::sanitize_api_key($_POST['user_api_key']);
    176         $user_auth_api_key = Crowdaa_Sync_Api::sanitize_api_key($_POST['user_auth_api_key']);
     176        $user_app_id = Crowdaa_Sync_Api::sanitize_api_key($_POST['user_app_id']);
     177        $sync_domain_names = Crowdaa_Sync_Api::sanitize_sync_domain_names($_POST['sync_domain_names']);
    177178        $data = [
    178179          'email'    => $user_email,
     
    182183        $api = new Crowdaa_Sync_API();
    183184
    184         $response = $api->http_request('POST', '/auth/login', $data, ['X-Api-Key' => $user_auth_api_key]);
     185        $response = $api->http_request('POST', '/auth/login', $data, ['X-Api-Key' => self::AUTH_API_KEY]);
    185186        $err    = is_wp_error($response) ? $response->get_error_message() : null;
    186187        if (!$err) {
     
    229230          update_option('crowdaa_user_email', $user_email);
    230231          update_option('crowdaa_user_password', md5($user_password));
    231           update_option('crowdaa_user_api_key', $user_api_key);
    232           update_option('crowdaa_user_auth_api_key', $user_auth_api_key);
     232          update_option('crowdaa_user_api_key', 'appId:' . $user_app_id);
    233233          update_option('crowdaa_user_id', $json->data->userId);
    234234          update_option('crowdaa_auth_token', $json->data->authToken);
     235          update_option('crowdaa_sync_domain_names', $sync_domain_names);
    235236
    236237          $ok = $this->post_login_setup();
     
    241242            update_option('crowdaa_user_email', '');
    242243            update_option('crowdaa_user_password', '');
    243             update_option('crowdaa_user_auth_api_key', '');
     244            update_option('crowdaa_user_api_key', '');
     245            update_option('crowdaa_sync_domain_names', '');
    244246
    245247            self::admin_notice('error', __('Failed to complete login initialization process', CROWDAA_SYNC_PLUGIN_NAME));
     
    268270      return;
    269271    } else {
     272      $this->on_logout_unset();
     273
     274      update_option('crowdaa_user_id', '');
     275      update_option('crowdaa_auth_token', '');
     276      update_option('crowdaa_api_url', '');
     277      update_option('crowdaa_user_email', '');
     278      update_option('crowdaa_user_password', '');
     279      update_option('crowdaa_user_api_key', '');
     280      update_option('crowdaa_sync_domain_names', '');
     281
    270282      Crowdaa_Sync_Logs::log('Parameters', 'connection_settings', 'Connection disabled');
    271283    }
  • crowdaa-sync/trunk/admin/class-crowdaa-sync-api.php

    r3149200 r3169735  
    10821082   * @return boolean
    10831083   */
    1084   public function update_category($cat_id, $cat_name, $cat_slug, $parent_category_id, $badges, $picture_id = false, $is_event)
     1084  public function update_category($cat_id, $cat_name, $cat_slug, $parent_category_id, $badges, $picture_id = false, $is_event = false)
    10851085  {
    10861086    $data = [
     
    12501250    return (preg_replace('/(\s|[\x00-\x1F\x7F-\xFF]|[^\x00-\xFF])/is', '', $key));
    12511251  }
     1252
     1253  public static function sanitize_sync_domain_names($input)
     1254  {
     1255    $raw_list = explode(',', $input);
     1256
     1257    $filtered_list = array_filter($raw_list, function ($value) {
     1258      $valid_regex = '/^[a-zA-Z0-9](([a-zA-Z0-9]|-)*[a-zA-Z0-9])?(\.[a-zA-Z0-9](([a-zA-Z0-9]|-)*[a-zA-Z0-9])?)*$/';
     1259      $trimmed = trim($value);
     1260      if (!$trimmed) return false;
     1261      if (!preg_match($valid_regex, $trimmed)) return false;
     1262      return true;
     1263    });
     1264
     1265    return implode(',', $filtered_list);
     1266  }
    12521267}
  • crowdaa-sync/trunk/admin/partials/crowdaa-sync-admin-display.php

    r3149200 r3169735  
    2828    $user_email         = get_option('crowdaa_user_email');
    2929    $user_password      = get_option('crowdaa_user_password');
    30     $user_auth_api_key  = get_option('crowdaa_user_auth_api_key');
    3130    $user_api_key       = get_option('crowdaa_user_api_key');
    3231    $auth_token         = get_option('crowdaa_auth_token');
     32    $sync_domain_names  = get_option('crowdaa_sync_domain_names');
    3333    $plugin_api_key     = Crowdaa_Sync_Utils::get_plugin_api_key();
     34
     35    $is_authenticated = ($user_email && $user_password && $user_api_key && $auth_token);
     36    $user_app_id = $user_api_key ? substr($user_api_key, 6) : '';
     37
     38    $api_urls = [
     39      'https://api.aws.crowdaa.com/v1' => __('US platform', CROWDAA_SYNC_PLUGIN_NAME),
     40      'https://api-fr.aws.crowdaa.com/v1' => __('FR platform', CROWDAA_SYNC_PLUGIN_NAME),
     41    ];
     42    if (isset($_GET['api'])) {
     43      $api_urls[$_GET['api']] = $_GET['api'];
     44    }
     45    if ($api_url && !array_key_exists($api_url, $api_urls)) {
     46      $api_urls[$api_url] = $api_url;
     47    }
    3448    ?>
    3549    <div class="crowdaa-html-container">
    3650      <p>
    3751        <label class="text-label" for="api_url"><?php esc_html_e('API URL', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
    38         <input type="text" required id="api_url" name="api_url" value="<?php echo esc_attr(($api_url && $auth_token) ? $api_url : ''); ?>" />
    39       </p>
    40       <p>
    41         <label class="text-label" for="user_auth_api_key"><?php esc_html_e('Authentication API key', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
    42         <input required id="user_auth_api_key" name="user_auth_api_key" value="<?php echo esc_attr(($user_auth_api_key && $auth_token) ? $user_auth_api_key : ''); ?>" />
    43       </p>
    44       <p>
    45         <label class="text-label" for="user_api_key"><?php esc_html_e('Application API key', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
    46         <input required id="user_api_key" name="user_api_key" value="<?php echo esc_attr(($user_api_key && $auth_token) ? $user_api_key : ''); ?>" />
     52        <select <?php echo $is_authenticated ? 'disabled' : '' ?> name="api_url">
     53          <?php
     54          foreach ($api_urls as $url => $name) { ?>
     55            <option value="<?php echo esc_attr($url); ?>" <?php echo ($url === $api_url ? 'selected="selected"' : ''); ?>>
     56              <?php echo esc_html($name); ?>
     57            </option>
     58          <?php } ?>
     59        </select>
     60      </p>
     61      <p>
     62        <label class="text-label" for="user_app_id"><?php esc_html_e('App ID', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
     63        <input <?php echo $is_authenticated ? 'readonly' : '' ?> type="text" required id="user_app_id" name="user_app_id" value="<?php echo esc_attr(($user_app_id && $is_authenticated) ? $user_app_id : ''); ?>" />
    4764      </p>
    4865      <p>
    4966        <label class="text-label" for="user_email"><?php esc_html_e('Email', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
    50         <input type="text" required id="user_email" name="user_email" value="<?php echo esc_attr(($user_email && $auth_token) ? $user_email : ''); ?>" />
     67        <input <?php echo $is_authenticated ? 'readonly' : '' ?> type="text" required id="user_email" name="user_email" value="<?php echo esc_attr(($user_email && $is_authenticated) ? $user_email : ''); ?>" />
    5168      </p>
    5269      <p>
    5370        <label class="text-label" for="user_password"><?php esc_html_e('Password', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
    54         <input type="password" required id="user_password" name="user_password" value="<?php echo esc_attr(($user_password && $auth_token) ? $user_password : ''); ?>" />
     71        <input <?php echo $is_authenticated ? 'readonly' : '' ?> type="password" required id="user_password" name="user_password" value="<?php echo esc_attr(($user_password && $is_authenticated) ? $user_password : ''); ?>" />
     72      </p>
     73      <p>
     74        <?php
     75        $site_url = get_site_url();
     76        if ($site_url) {
     77          $current_domain = parse_url($site_url)['host'];
     78        } else if (isset($_SERVER['HTTP_HOST'])) {
     79          $current_domain = $_SERVER['HTTP_HOST'];
     80        } else {
     81          $current_domain = '';
     82        }
     83        ?>
     84        <label class="text-label" for="sync_domain_names"><?php esc_html_e('Domain names', CROWDAA_SYNC_PLUGIN_NAME); ?></label>
     85        <input
     86          <?php echo $is_authenticated ? 'readonly' : '' ?>
     87          type="text"
     88          pattern="[a-zA-Z0-9](([a-zA-Z0-9]|-)*[a-zA-Z0-9])?(\.[a-zA-Z0-9](([a-zA-Z0-9]|-)*[a-zA-Z0-9])?)*( *, *[a-zA-Z0-9](([a-zA-Z0-9]|-)*[a-zA-Z0-9])?(\.[a-zA-Z0-9](([a-zA-Z0-9]|-)*[a-zA-Z0-9])?)*)*"
     89          title="<?php echo esc_attr_e('Comma-separated domain names list for your website, like example.com, www.example.com, other.subdomain.example.com', CROWDAA_SYNC_PLUGIN_NAME); ?>"
     90          id="sync_domain_names"
     91          name="sync_domain_names"
     92          value="<?php echo esc_attr(($sync_domain_names && $is_authenticated) ? $sync_domain_names : $current_domain); ?>" />
    5593      </p>
    5694      <p>
     
    62100    <?php
    63101    wp_nonce_field('crowdaa_login_data', 'crowdaa_login');
    64     if ($user_email && $user_password && $user_auth_api_key && $user_api_key) {
     102    if ($is_authenticated) {
    65103    ?>
    66104      <input type="hidden" id="status" name="status" value="disconnect" />
    67105    <?php
    68       submit_button('Disconnect from Crowdaa');
     106      submit_button(__('Disconnect from Crowdaa', CROWDAA_SYNC_PLUGIN_NAME));
    69107    } else {
    70108    ?>
    71109      <input type="hidden" id="status" name="status" value="connect" />
    72110    <?php
    73       submit_button('Connect to Crowdaa');
     111      submit_button(__('Connect to Crowdaa', CROWDAA_SYNC_PLUGIN_NAME));
    74112    }
    75113    ?>
     
    106144
    107145  <?php
    108   if ($user_email && $user_password && $user_auth_api_key && $user_api_key && $auth_token) {
     146  if ($is_authenticated) {
    109147  ?>
    110148    <hr />
  • crowdaa-sync/trunk/crowdaa-sync.php

    r3150916 r3169735  
    1414 * Plugin URI:       
    1515 * Description:       Plugin for synchronizing WordPress site and Crowdaa CMS
    16  * Version:           1.9.1
     16 * Version:           1.10.0
    1717 * Requires at least: 5.5
    1818 * Requires PHP:      7.2
     
    3434 * Uses SemVer - https://semver.org
    3535 */
    36 define('CROWDAA_SYNC_VERSION', '1.9.1');
     36define('CROWDAA_SYNC_VERSION', '1.10.0');
    3737define('CROWDAA_SYNC_PLUGIN_DIR', __DIR__);
    3838define('CROWDAA_SYNC_PLUGIN_NAME', 'crowdaa-sync');
Note: See TracChangeset for help on using the changeset viewer.