Plugin Directory

Changeset 3438204


Ignore:
Timestamp:
01/12/2026 11:11:30 PM (6 weeks ago)
Author:
homio13
Message:

Update to version 3.1.0

Location:
calliope/trunk
Files:
5 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • calliope/trunk/calliope.php

    r3433173 r3438204  
    44Plugin URI: https://wordpress.org/plugins/calliope/
    55Description: WordPress AI Contents Generator - Automatically generate high-quality content using AI technology
    6 Version: 3.0.17
     6Version: 3.1.0
    77Author: homio13
    88Author URI: https://profiles.wordpress.org/homio13/
     
    3030use Calliope\Database\Seeds;
    3131use Calliope\Api\StripeClient;
     32use Calliope\Api\UserCertification;
     33use Calliope\Config\Config;
    3234use Calliope\Scheduler\Scheduler;
    3335
     
    7072  Migration::migration();
    7173
     74  // Firestore + Stripe無料プラン登録
     75  $email = get_option('admin_email');
     76  $uc = new UserCertification();
     77  $uc->register_plugin_user($email, Config::FREE_PLAN_PRICE_ID);
     78
    7279  // cronの登録
    7380  if (!wp_next_scheduled('calliope_cron_scheduler')) {
     
    8794
    8895  // サブスクリプションの解約
    89   $user = Utils::get_user();
    90   if (!empty($user)) {
    91     $email = $user->mail;
    92 
     96  $email = get_option('admin_email');
     97  if (!empty($email)) {
    9398    $stripe = new StripeClient();
    9499    $stripe->plan_cancel($email);
  • calliope/trunk/readme-es.txt

    r3433173 r3438204  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 3.0.17
     7Stable tag: 3.1.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    128128== Changelog ==
    129129
     130= 3.1.0 =
     131* 🚀 **Incorporación Simplificada**: Eliminado el requisito de registro/inicio de sesión - el plugin ahora usa autenticación de WordPress
     132* 🆓 **Plan Gratuito Automático**: El plan gratuito (3 artículos/mes) se activa automáticamente al instalar el plugin
     133* 🧹 **Limpieza de Código**: Eliminada la dependencia de Firebase Authentication, código simplificado
     134* 🗄️ **Base de Datos**: Eliminada la tabla calliope_user (ya no es necesaria)
     135
    130136= 3.0.17 =
    131137* 🔧 **Corrección de Errores**: Mejorado el programador para usar nombres de hooks únicos por feed para prevenir conflictos de eventos cron al procesar múltiples feeds simultáneamente
     
    269275* Política de Privacidad: https://policies.google.com/privacy
    270276
    271 = Firebase Authentication (Google Identity Toolkit) =
    272 **Propósito**: Gestiona la autenticación de usuarios y la administración de cuentas para el servicio Calliope.
    273 
    274 **Datos Enviados**: Direcciones de correo electrónico de usuarios y credenciales de autenticación.
    275 
    276 **Cuándo**: Durante operaciones de registro de usuario, inicio de sesión y restablecimiento de contraseña.
    277 
    278 **Proveedor del Servicio**: Google LLC
    279 * Términos de Servicio: https://firebase.google.com/terms
    280 * Política de Privacidad: https://firebase.google.com/support/privacy
     277= Servicio de Registro de Usuario Calliope =
     278**Propósito**: Registra el correo electrónico del administrador de WordPress para la gestión de suscripciones y seguimiento del uso del plugin.
     279
     280**Datos Enviados**: Dirección de correo electrónico del administrador de WordPress.
     281
     282**Cuándo**: Durante la activación del plugin (registro único).
     283
     284**URL del Servicio**: https://us-central1-calliope-89149.cloudfunctions.net/registerPluginUser
     285* Este servicio registra usuarios en Firestore y crea una suscripción gratuita de Stripe
    281286
    282287= Servicio Calliope Stripe Handler =
  • calliope/trunk/readme-ja.txt

    r3433173 r3438204  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 3.0.17
     7Stable tag: 3.1.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    128128== Changelog ==
    129129
     130= 3.1.0 =
     131* 🚀 **オンボーディング簡素化**: ユーザー登録/ログイン不要に - WordPress認証を使用するように変更
     132* 🆓 **無料プラン自動登録**: プラグインインストール時に無料プラン(月3記事)が自動的に有効化
     133* 🧹 **コード整理**: Firebase認証依存を削除、コードベースを簡素化
     134* 🗄️ **データベース**: calliope_userテーブルを削除(不要になったため)
     135
    130136= 3.0.17 =
    131137* 🔧 **バグ修正**: 複数フィードの同時処理時のcronイベント競合を防ぐため、フィードごとにユニークなフック名を使用するようスケジューラを改善
     
    268274* プライバシーポリシー: https://policies.google.com/privacy
    269275
    270 = Firebase Authentication (Google Identity Toolkit) =
    271 **目的**: Calliopeサービスのユーザー認証とアカウント管理。
    272 
    273 **送信データ**: ユーザーのメールアドレスと認証資格情報。
    274 
    275 **送信タイミング**: ユーザー登録、ログイン、パスワードリセット操作時。
    276 
    277 **サービス提供者**: Google LLC
    278 * 利用規約: https://firebase.google.com/terms
    279 * プライバシーポリシー: https://firebase.google.com/support/privacy
     276= Calliope ユーザー登録サービス =
     277**目的**: サブスクリプション管理とプラグイン利用追跡のためのWordPress管理者メールアドレスの登録。
     278
     279**送信データ**: WordPress管理者のメールアドレス。
     280
     281**送信タイミング**: プラグイン有効化時(1回のみ)。
     282
     283**サービスURL**: https://us-central1-calliope-89149.cloudfunctions.net/registerPluginUser
     284* このサービスはFirestoreにユーザーを登録し、無料Stripeサブスクリプションを作成します
    280285
    281286= Calliope Stripe Handler Service =
  • calliope/trunk/readme.txt

    r3433173 r3438204  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 3.0.17
     7Stable tag: 3.1.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    128128== Changelog ==
    129129
     130= 3.1.0 =
     131* 🚀 **Simplified Onboarding**: Removed user registration/login requirement - plugin now uses WordPress authentication
     132* 🆓 **Automatic Free Plan**: Free plan (3 articles/month) is automatically activated on plugin installation
     133* 🧹 **Code Cleanup**: Removed Firebase Authentication dependency, simplified codebase
     134* 🗄️ **Database**: Removed calliope_user table (no longer needed)
     135
    130136= 3.0.17 =
    131137* 🔧 **Bug Fix**: Improved scheduler to use unique hook names per feed to prevent cron event conflicts when processing multiple feeds simultaneously
     
    269275* Privacy Policy: https://policies.google.com/privacy
    270276
    271 = Firebase Authentication (Google Identity Toolkit) =
    272 **Purpose**: Manages user authentication and account management for the Calliope service.
    273 
    274 **Data Sent**: User email addresses and authentication credentials.
    275 
    276 **When**: During user registration, login, and password reset operations.
    277 
    278 **Service Provider**: Google LLC
    279 * Terms of Service: https://firebase.google.com/terms
    280 * Privacy Policy: https://firebase.google.com/support/privacy
     277= Calliope User Registration Service =
     278**Purpose**: Registers WordPress admin email for subscription management and plugin usage tracking.
     279
     280**Data Sent**: WordPress admin email address.
     281
     282**When**: During plugin activation (one-time registration).
     283
     284**Service URL**: https://us-central1-calliope-89149.cloudfunctions.net/registerPluginUser
     285* This service registers users in Firestore and creates a free Stripe subscription
    281286
    282287= Calliope Stripe Handler Service =
  • calliope/trunk/src/Admin/MenuManager.php

    r3430503 r3438204  
    1111use Calliope\Admin\Pages\FeedEditPage;
    1212use Calliope\Admin\Pages\ManualPage;
    13 use Calliope\Admin\Pages\UserCreatePage;
    14 use Calliope\Admin\Pages\UserLoginPage;
    15 use Calliope\Admin\Pages\ResetPasswordPage;
    1613use Calliope\Admin\Pages\SubscPurchasePage;
    17 use Calliope\Admin\Pages\ModePage;
    1814
    1915// Prevent direct access
     
    4339        // 管理画面に追加登録する
    4440        //=================================================
    45        
     41
    4642        //---------------------------------
    4743        // メインメニュー①
     
    5753        );
    5854
    59         if (!Utils::is_verified()) {
    60             // ユーザー登録が終わってない or サブスク未登録
    61             self::add_user_create_menu();
    62             self::add_user_login_menu();
    63             self::add_reset_password_menu();
    64             self::add_subsc_purchase_menu();
    65         } else {
    66             // ユーザー登録完了 & サブスク登録済み
    67             self::add_dashboard_menu(1);
    68             self::add_setting_menu(2);
    69             self::add_feeds_menu(3);
    70             self::add_feed_edit_menu();
    71             self::add_subsc_purchase_menu(4);
    72             self::add_manual_menu(5);
    73             self::add_mode_menu();
    74         }
    75     }
    76 
    77     /**
    78      * Add user create menu
    79      */
    80     public static function add_user_create_menu($index = null)
    81     {
    82         self::add_submenu(
    83             'calliope_user_create',
    84             Translator::__('user_registration'),
    85             Translator::__('user_registration'),
    86             'manage_options',
    87             'calliope_menu',
    88             [UserCreatePage::class, 'render'],
    89             $index
    90         );
    91     }
    92 
    93     /**
    94      * Add user login menu
    95      */
    96     public static function add_user_login_menu($index = null)
    97     {
    98         self::add_submenu(
    99             'calliope_user_login',
    100             Translator::__('login'),
    101             Translator::__('login'),
    102             'manage_options',
    103             'calliope_user_login',
    104             [UserLoginPage::class, 'render'],
    105             $index
    106         );
    107     }
    108 
    109     /**
    110      * Add reset password menu
    111      */
    112     public static function add_reset_password_menu($index = null)
    113     {
    114         self::add_submenu(
    115             'calliope_resest_password',
    116             Translator::__('password_reset'),
    117             Translator::__('password_reset'),
    118             'manage_options',
    119             'calliope_resest_password',
    120             [ResetPasswordPage::class, 'render'],
    121             $index
    122         );
     55        // 常に全メニューを表示(記事生成制限はis_verify_post_count()で別途チェック)
     56        self::add_dashboard_menu(1);
     57        self::add_setting_menu(2);
     58        self::add_feeds_menu(3);
     59        self::add_feed_edit_menu();
     60        self::add_subsc_purchase_menu(4);
     61        self::add_manual_menu(5);
    12362    }
    12463
     
    220159
    221160    /**
    222      * Add mode menu
    223      */
    224     public static function add_mode_menu($index = null)
    225     {
    226         self::add_submenu(
    227             'calliope_mode',
    228             Translator::__('mode_setting'),
    229             Translator::__('mode_setting'),
    230             'manage_options',
    231             'calliope_mode',
    232             [ModePage::class, 'render'],
    233             $index
    234         );
    235     }
    236 
    237     /**
    238161     * Add submenu page
    239162     */
  • calliope/trunk/src/Admin/Pages/DashboardPage.php

    r3431447 r3438204  
    5656
    5757        /////// メールアドレス
    58         $user = Utils::get_user();
    59         $email = $user->mail;
     58        $email = Utils::get_current_email();
    6059
    6160        /////// 記事制限
  • calliope/trunk/src/Admin/Pages/SubscPurchasePage.php

    r3430503 r3438204  
    2828
    2929        // ユーザーのメールアドレス
    30         $user = Utils::get_user();
    31         $email = $user->mail;
     30        $email = Utils::get_current_email();
    3231
    3332        $stripe = new StripeClient();
  • calliope/trunk/src/Api/UserCertification.php

    r3431946 r3438204  
    1717{
    1818    /**
    19      * Get user information
     19     * Register plugin user (Firestore + Stripe free plan)
    2020     *
    21      * @param string $uid
     21     * @param string $email
     22     * @param string $free_plan_price_id
    2223     * @return array
    2324     */
    24     public function get_user($uid)
     25    public function register_plugin_user($email, $free_plan_price_id)
    2526    {
    26         // セキュリティチェック
    27         if (!current_user_can('manage_options')) {
    28             return Utils::return_response(self::ERROR, '', '権限がありません。');
    29         }
     27        // データのサニタイゼーション
     28        $email = sanitize_email($email);
     29        $free_plan_price_id = sanitize_text_field($free_plan_price_id);
    3030
    31         // データのサニタイゼーション
    32         $uid = sanitize_text_field($uid);
    33        
    3431        // POSTする
    3532        $data = [
    36             'uid' => $uid
     33            'email' => $email,
     34            'free_plan_price_id' => $free_plan_price_id
    3735        ];
    38         $response = Utils::request_post(Utils::get_endpoint('getUser'), $data);
     36        $response = Utils::request_post(Utils::get_endpoint('registerPluginUser'), $data);
    3937
    4038        // エラー発生時
    4139        if (is_wp_error($response)) {
    42             $message = 'APIリクエストが失敗しました(get_user): ' . $response->get_error_message();
     40            $message = 'APIリクエストが失敗しました(register_plugin_user): ' . $response->get_error_message();
    4341            Logger::error($message);
    4442
     
    5654        // レスポンスのデータを処理する
    5755        if ($response_code === 200) {
    58             return Utils::return_response(self::SUCCESS, $message_code, 'ユーザー情報を取得しました。', $body);
     56            return Utils::return_response(self::SUCCESS, $message_code, 'プラグインユーザーの登録が完了しました', $body);
    5957        } else {
    60             $error_message = 'APIリクエストが失敗しました(get_user): ' . $message . '(' . $response["response"]["message"] . ')';
    61             Logger::error($error_message);
    62 
    63             return Utils::return_response(self::ERROR, $message_code, $message);
    64         }
    65     }
    66 
    67     /**
    68      * User create (alias for register)
    69      *
    70      * @param string $mail
    71      * @param string $password
    72      * @return array
    73      */
    74     public function user_create($mail, $password)
    75     {
    76         // セキュリティチェック
    77         if (!current_user_can('manage_options')) {
    78             return Utils::return_response(self::ERROR, '', '権限がありません。');
    79         }
    80 
    81         // データのサニタイゼーション
    82         $mail = sanitize_email($mail);
    83         $password = sanitize_text_field($password);
    84        
    85         // POSTする
    86         $data = [
    87             'mail' => $mail,
    88             'password' => $password
    89         ];
    90         $response = Utils::request_post(Utils::get_endpoint('addUser'), $data);
    91 
    92         // エラー発生時
    93         if (is_wp_error($response)) {
    94             $message = 'APIリクエストが失敗しました(user_create): ' . $response->get_error_message();
    95             Logger::error($message);
    96 
    97             return Utils::return_response(self::ERROR, '', $message);
    98         }
    99 
    100         // レスポンスコード
    101         $response_code = wp_remote_retrieve_response_code($response);
    102 
    103         // メッセージ
    104         $body = Utils::get_body($response);
    105         $message_code = Utils::get_object_value($body, 'message_code');
    106         $message = Utils::get_object_value($body, 'message');
    107 
    108         // レスポンスのデータを処理する
    109         if ($response_code === 200) {
    110             return Utils::return_response(self::SUCCESS, $message_code, 'ユーザーの登録が完了しました', $body);
    111         } else {
    112             $error_message = 'APIリクエストが失敗しました(user_create): ' . $message. '('. $response["response"]["message"].')';
    113             Logger::error($error_message);
    114 
    115             // 特定のエラーの場合メッセージを置き換える
    116             if($message == 'The email address is already in use by another account.'){
    117                 $message = 'すでに登録されています。ログイン画面からログインしてください。';
    118             }elseif($message == 'The password must be a string with at least 6 characters.'){
    119                 $message = 'パスワードは6文字以上で入力してください。';
    120             }
    121 
    122             return Utils::return_response(self::ERROR, $message_code, $message);
    123         }
    124     }
    125 
    126     /**
    127      * Get user ID token with email and password
    128      *
    129      * @param string $mail
    130      * @param string $password
    131      * @return array
    132      */
    133     public function get_user_id_token_with_email_password($mail, $password)
    134     {
    135         // セキュリティチェック
    136         if (!current_user_can('manage_options')) {
    137             return Utils::return_response(self::ERROR, '', '権限がありません。');
    138         }
    139 
    140         // データのサニタイゼーション
    141         $mail = sanitize_email($mail);
    142         $password = sanitize_text_field($password);
    143        
    144         // POSTする
    145         $data = [
    146             'email' => $mail,
    147             'password' => $password,
    148             'returnSecureToken' => true // ないとだめらしい
    149         ];
    150         $response = Utils::request_post(
    151             'https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=' . \Calliope\Config\Config::FIREBASE_API_KEY,
    152             $data
    153         );
    154 
    155         // エラー発生時
    156         if (is_wp_error($response)) {
    157             $message = 'APIリクエストが失敗しました(get_user_id_token_with_email_password): ' . $response->get_error_message();
    158             Logger::error($message);
    159 
    160             return Utils::return_response(self::ERROR, '', $message);
    161         }
    162 
    163         // レスポンスコード
    164         $response_code = wp_remote_retrieve_response_code($response);
    165 
    166         // メッセージ
    167         $body = Utils::get_body($response);
    168         $message_code = Utils::get_object_value($body, 'message_code');
    169         $message = Utils::get_object_value($body, 'message');
    170 
    171         // レスポンスのデータを処理する
    172         if ($response_code === 200) {
    173             return Utils::return_response(self::SUCCESS, $message_code, 'idTokenを取得しました。', $body);
    174         } else {
    175             // このAPIだけ外部APIなのでエラー処理が特殊
    176             $error = $body->error;
    177             $message = $error->message;
    178 
    179             // 特定のエラーの場合メッセージを置き換える
    180             if ($message == 'INVALID_PASSWORD') {
    181                 $message = 'パスワードが違います。再ログインしてください。';
    182             } elseif ($message == 'EMAIL_NOT_FOUND') {
    183                 $message = 'メールアドレスが存在しません。再ログインしてください。';
    184             }
    185 
    186             $error_message = 'APIリクエストが失敗しました(get_user_id_token_with_email_password): ' . $message . '(' . $response["response"]["message"] . ')';
    187             Logger::error($error);
    188 
    189             return Utils::return_response(self::ERROR, $message_code, $message);
    190         }
    191     }
    192 
    193     /**
    194      * User login
    195      *
    196      * @param string $idToken
    197      * @return array
    198      */
    199     public function user_login($idToken)
    200     {
    201         // POSTする
    202         $data = [
    203             'idToken' => $idToken,
    204         ];
    205         $response = Utils::request_post(Utils::get_endpoint('loginUser'), $data);
    206 
    207         // エラー発生時
    208         if (is_wp_error($response)) {
    209             $message = 'APIリクエストが失敗しました(user_login): ' . $response->get_error_message();
    210             Logger::error($message);
    211 
    212             return Utils::return_response(self::ERROR, '', $message);
    213         }
    214 
    215         // レスポンスコード
    216         $response_code = wp_remote_retrieve_response_code($response);
    217 
    218         // メッセージ
    219         $body = Utils::get_body($response);
    220         $message_code = Utils::get_object_value($body, 'message_code');
    221         $message = Utils::get_object_value($body, 'message');
    222 
    223         // レスポンスのデータを処理する
    224         if ($response_code === 200) {
    225             return Utils::return_response(self::SUCCESS, $message_code, 'ログインしました。', $body);
    226         } else {
    227             $error_message = 'APIリクエストが失敗しました(user_login): ' . $message . '(' . $response["response"]["message"] . ')';
    228             Logger::error($error_message);
    229 
    230             return Utils::return_response(self::ERROR, $message_code, $message);
    231         }
    232     }
    233 
    234     /**
    235      * Register user
    236      *
    237      * @param string $email
    238      * @param string $password
    239      * @return array
    240      */
    241     public function register($email, $password)
    242     {
    243         // データのサニタイゼーション
    244         $email = sanitize_email($email);
    245         $password = sanitize_text_field($password);
    246        
    247         // POSTする
    248         $data = [
    249             'email' => $email,
    250             'password' => $password
    251         ];
    252         $response = Utils::request_post(Utils::get_endpoint('registerUser'), $data);
    253 
    254         // エラー発生時
    255         if (is_wp_error($response)) {
    256             $message = 'APIリクエストが失敗しました(register_user): ' . $response->get_error_message();
    257             Logger::error($message);
    258 
    259             return Utils::return_response(self::ERROR, '', $message);
    260         }
    261 
    262         // レスポンスコード
    263         $response_code = wp_remote_retrieve_response_code($response);
    264 
    265         // メッセージ
    266         $body = Utils::get_body($response);
    267         $message_code = Utils::get_object_value($body, 'message_code');
    268         $message = Utils::get_object_value($body, 'message');
    269 
    270         // レスポンスのデータを処理する
    271         if ($response_code === 200) {
    272             return Utils::return_response(self::SUCCESS, $message_code, 'ユーザー登録が完了しました。', $body);
    273         } else {
    274             $error_message = 'APIリクエストが失敗しました(register_user): ' . $message . '(' . $response["response"]["message"] . ')';
    275             Logger::error($error_message);
    276 
    277             return Utils::return_response(self::ERROR, $message_code, $message);
    278         }
    279     }
    280 
    281     /**
    282      * Login user
    283      *
    284      * @param string $email
    285      * @param string $password
    286      * @return array
    287      */
    288     public function login($email, $password)
    289     {
    290         // データのサニタイゼーション
    291         $email = sanitize_email($email);
    292         $password = sanitize_text_field($password);
    293        
    294         // POSTする
    295         $data = [
    296             'email' => $email,
    297             'password' => $password
    298         ];
    299         $response = Utils::request_post(Utils::get_endpoint('loginUser'), $data);
    300 
    301         // エラー発生時
    302         if (is_wp_error($response)) {
    303             $message = 'APIリクエストが失敗しました(login_user): ' . $response->get_error_message();
    304             Logger::error($message);
    305 
    306             return Utils::return_response(self::ERROR, '', $message);
    307         }
    308 
    309         // レスポンスコード
    310         $response_code = wp_remote_retrieve_response_code($response);
    311 
    312         // メッセージ
    313         $body = Utils::get_body($response);
    314         $message_code = Utils::get_object_value($body, 'message_code');
    315         $message = Utils::get_object_value($body, 'message');
    316 
    317         // レスポンスのデータを処理する
    318         if ($response_code === 200) {
    319             return Utils::return_response(self::SUCCESS, $message_code, 'ログインが完了しました。', $body);
    320         } else {
    321             $error_message = 'APIリクエストが失敗しました(login_user): ' . $message . '(' . $response["response"]["message"] . ')';
    322             Logger::error($error_message);
    323 
    324             return Utils::return_response(self::ERROR, $message_code, $message);
    325         }
    326     }
    327 
    328     /**
    329      * Reset password
    330      *
    331      * @param string $mail
    332      * @return array
    333      */
    334     public function reset_password($mail)
    335     {
    336         // データのサニタイゼーション
    337         $mail = sanitize_email($mail);
    338        
    339         // POSTする
    340         $data = [
    341             'mail' => $mail,
    342             'url' => Utils::get_accessed_url_host(),
    343         ];
    344         $response = Utils::request_post(Utils::get_endpoint('resetPassword'), $data);
    345 
    346         // エラー発生時
    347         if (is_wp_error($response)) {
    348             $message = 'APIリクエストが失敗しました(reset_password): ' . $response->get_error_message();
    349             Logger::error($message);
    350 
    351             return Utils::return_response(self::ERROR, '', $message);
    352         }
    353 
    354         // レスポンスコード
    355         $response_code = wp_remote_retrieve_response_code($response);
    356 
    357         // メッセージ
    358         $body = Utils::get_body($response);
    359         $message_code = Utils::get_object_value($body, 'message_code');
    360         $message = Utils::get_object_value($body, 'message');
    361 
    362         // レスポンスのデータを処理する
    363         if ($response_code === 200) {
    364             return Utils::return_response(self::SUCCESS, $message_code, 'パスワードリセットメールを送信しました。', $body);
    365         } else {
    366             $error_message = 'APIリクエストが失敗しました(reset_password): ' . $message . '(' . $response["response"]["message"] . ')';
     58            $error_message = 'APIリクエストが失敗しました(register_plugin_user): ' . $message;
    36759            Logger::error($error_message);
    36860
  • calliope/trunk/src/Config/Config.php

    r3430922 r3438204  
    1212class Config
    1313{
    14   // firebase api key
    15   const FIREBASE_API_KEY = 'AIzaSyAfGJnyQXqjB2pNvK8VaJmZtsgcoDhQUA4';
     14  // Stripe無料プランのprice_id
     15  const FREE_PLAN_PRICE_ID = 'price_1S0QOcL0uD8lX9cYzld5Vcwd';
    1616
    1717  //テーブル名
  • calliope/trunk/src/Database/Migration.php

    r3431946 r3438204  
    6161        /// ver3.0.10
    6262        if (!self::is_exist_migrate('3.0.10')) self::mig_3_0_10();
     63        /// ver3.1.0 - Drop calliope_user table (Firebase auth removed)
     64        if (!self::is_exist_migrate('3.1.0')) self::mig_3_1_0();
    6365    }
    6466
     
    182184        global $wpdb;
    183185
    184         $wpdb->query(
    185             $wpdb->prepare(
    186                 "ALTER TABLE %1s
    187                 CHANGE is_token_verified is_coupon_code_registration tinyint(1) DEFAULT NULL COMMENT 'クーポンコード登録フラグ'",
     186        // calliope_userテーブルが存在する場合のみALTERを実行
     187        // (ver3.1.0以降、新規インストールではuser tableは作成されない)
     188        $table_exists = $wpdb->get_var(
     189            $wpdb->prepare(
     190                "SHOW TABLES LIKE %s",
    188191                Config::TABLE_USER
    189192            )
    190193        );
     194
     195        if ($table_exists) {
     196            $wpdb->query(
     197                $wpdb->prepare(
     198                    "ALTER TABLE %1s
     199                    CHANGE is_token_verified is_coupon_code_registration tinyint(1) DEFAULT NULL COMMENT 'クーポンコード登録フラグ'",
     200                    Config::TABLE_USER
     201                )
     202            );
     203        }
    191204
    192205        self::migrate_history_update('1.3.0');
     
    570583        Logger::info('migrate ver3.0.10 completed .... ');
    571584    }
     585
     586    /**
     587     * Migration version 3.1.0
     588     * Drop calliope_user table (Firebase authentication removed, using WordPress auth)
     589     */
     590    public static function mig_3_1_0()
     591    {
     592        Logger::info('migrate ver3.1.0 start .... ');
     593
     594        global $wpdb;
     595
     596        // calliope_userテーブルを削除(Firebase認証からWordPress認証に移行)
     597        $wpdb->query(
     598            $wpdb->prepare(
     599                "DROP TABLE IF EXISTS %1s",
     600                Config::TABLE_USER
     601            )
     602        );
     603
     604        self::migrate_history_update('3.1.0');
     605
     606        Logger::info('migrate ver3.1.0 completed .... ');
     607    }
    572608}
  • calliope/trunk/src/Database/Seeds.php

    r3431946 r3438204  
    2727        self::create_setting_table();
    2828        self::create_feeds_schedule_table();
    29         self::create_user_table();
    3029        self::create_migration_table();
    3130    }
     
    158157
    159158    /**
    160      * Create calliope_users table
    161      *
    162      * @return void
    163      */
    164     private static function create_user_table()
    165     {
    166         global $wpdb;
    167 
    168         $charset_collate = $wpdb->get_charset_collate();
    169 
    170         $sql = "CREATE TABLE `" . Config::TABLE_USER . "` (
    171             `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    172             `mail` varchar(255) DEFAULT NULL COMMENT 'メールアドレス',
    173             `uid` varchar(255) DEFAULT NULL COMMENT 'firebaseのuid',
    174             `is_user_created` tinyint(1) DEFAULT NULL COMMENT 'ユーザー登録フラグ',
    175             `is_token_verified` tinyint(1) DEFAULT NULL COMMENT 'クーポンコード登録フラグ',
    176             `created_at` timestamp NULL DEFAULT 0,
    177             `modified_at` timestamp NULL DEFAULT 0,
    178             PRIMARY KEY (`id`)
    179         ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
    180 
    181         require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    182         dbDelta($sql);
    183 
    184         Logger::info('users table created');
    185     }
    186 
    187     /**
    188159     * Create migrations table
    189160     *
  • calliope/trunk/src/Utils/Logger.php

    r3431946 r3438204  
    145145        $masked_message = self::maskSensitiveData($message);
    146146
    147         // ユーザー情報を取得
    148         $user = null;
     147        // ユーザー情報を取得(WordPress認証ベース)
     148        $email = null;
    149149        try {
    150             $user = Utils::get_user();
     150            $email = Utils::get_current_email();
    151151        } catch (\Exception $e) {
    152152            // ユーザー情報取得失敗時は無視
     
    156156            'site_id'        => self::getSiteId(),
    157157            'site_url'       => home_url(),
    158             'email'          => $user ? $user->mail : null,
    159             'uid'            => $user ? $user->uid : null,
     158            'email'          => $email,
     159            'uid'            => null, // Firebase認証削除により廃止
    160160            'plugin_version' => self::getPluginVersion(),
    161161            'level'          => $level,
  • calliope/trunk/src/Utils/Tracking.php

    r3431946 r3438204  
    5252    private static function get_user_email()
    5353    {
    54         $user = Utils::get_user();
    55         if ($user && !empty($user->mail)) {
    56             return $user->mail;
     54        $email = Utils::get_current_email();
     55        if (!empty($email)) {
     56            return $email;
    5757        }
    5858        return null;
  • calliope/trunk/src/Utils/Utils.php

    r3431946 r3438204  
    88}
    99
    10 use Calliope\Database\Repository\UserRepository;
    1110use Calliope\Database\Repository\SettingRepository;
    1211use Calliope\Database\Repository\FeedsScheduleRepository;
    1312use Calliope\Api\StripeClient;
    1413use Calliope\Api\Base;
    15 use Calliope\Api\Mode;
    1614
    1715/**
     
    243241
    244242    /**
    245      * Check if user is created
    246      *
    247      * @return bool
    248      */
    249     public static function check_is_user_created()
    250     {
    251         global $wpdb;
    252 
    253         $user = self::get_user();
    254 
    255         if (empty($user)) return false;
    256 
    257         return $user->is_user_created;
    258     }
    259 
    260     /**
    261      * Get user
    262      *
    263      * @return object|null
    264      */
    265     public static function get_user()
    266     {
    267         // This will be updated when we migrate the repository classes
    268         return UserRepository::get_by_id(1);
     243     * Get current user email
     244     * Uses WordPress current user or admin email as fallback
     245     *
     246     * @return string
     247     */
     248    public static function get_current_email()
     249    {
     250        if (is_user_logged_in()) {
     251            return wp_get_current_user()->user_email;
     252        }
     253        return get_option('admin_email');
    269254    }
    270255
     
    322307
    323308    /**
    324      * Check if user is verified
     309     * Check if user is verified (has active subscription)
    325310     *
    326311     * @return bool
    327312     */
    328     public static function is_verified(){
    329         global $wpdb;
    330      
    331         // ユーザー未登録の場合はfalse
    332         if(!self::check_is_user_created()){
    333           return false;
    334         }
    335      
    336         // ユーザーのメールアドレス
    337         $user = self::get_user();
    338         $email = $user->mail;
    339      
     313    public static function is_verified()
     314    {
     315        // ユーザーのメールアドレスを取得
     316        // cron実行時はis_user_logged_in()がfalseになるため、admin_emailをフォールバックとして使用
     317        $email = self::get_current_email();
     318
     319        if (empty($email)) {
     320            return false;
     321        }
     322
    340323        // サブスクの登録状況を確認する
    341324        $stripe = new StripeClient();
    342325        $s_result = $stripe->check_subscription_status($email);
    343      
     326
    344327        if ($s_result['code'] == Base::SUCCESS) {
    345           if ($s_result['data']->status == "active") {
    346             return true;
    347           }
    348         }
    349      
     328            if ($s_result['data']->status == "active") {
     329                return true;
     330            }
     331        }
     332
    350333        return false;
    351       }
     334    }
    352335
    353336    /**
     
    378361    public static function get_post_limit()
    379362    {
    380         global $wpdb;
    381 
    382363        $post_limit = '';
    383364
    384365        // ユーザーのメールアドレス
    385         $user = self::get_user();
    386 
    387         if (empty($user)) {
     366        $email = self::get_current_email();
     367
     368        if (empty($email)) {
    388369            return $post_limit;
    389370        }
    390 
    391         $email = $user->mail;
    392371
    393372        $stripe = new StripeClient();
     
    480459    /**
    481460     * Check if test mode is enabled
     461     * Note: Test mode functionality has been removed. Always returns false.
    482462     *
    483463     * @return bool
     
    485465    public static function is_test_mode()
    486466    {
    487         global $wpdb;
    488 
    489         $user = self::get_user();
    490 
    491         $md = new Mode();
    492         $result = $md->get_mode($user->uid);
    493 
    494         $mode = Mode::IS_NOT_TEST;
    495 
    496         if ($result['code'] == Base::SUCCESS) {
    497             if (!empty($result['data']->mode)) {
    498                 $mode = $result['data']->mode;
    499             }
    500         }
    501 
    502         return $mode == Mode::IS_TEST ? true : false;
     467        return false;
    503468    }
    504469
Note: See TracChangeset for help on using the changeset viewer.