Plugin Directory

Changeset 2337209


Ignore:
Timestamp:
07/08/2020 09:54:02 AM (6 years ago)
Author:
rnlab
Message:

feat: get user location config

Location:
mobile-builder/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • mobile-builder/trunk/README.txt

    r2249631 r2337209  
    4545= 1.0 =
    4646* Initial release.
     47
     48= 1.0.6 =
     49* Add wc validation in the add_to_cart function (Thanks @raaquino)
     50* Get checkout user location config
  • mobile-builder/trunk/api/class-mobile-builder-cart.php

    r2332656 r2337209  
    132132
    133133        register_rest_route( $this->namespace, 'analytic', array(
    134             'methods'             => WP_REST_Server::CREATABLE,
    135             'callback'            => array( $this, 'analytic' ),
     134            'methods'  => WP_REST_Server::CREATABLE,
     135            'callback' => array( $this, 'analytic' ),
    136136        ) );
    137137
     
    142142
    143143        $data = array(
    144             "authStatus" => false,
    145             "WooCommerce" => false,
    146             "wcfm" => class_exists( 'WCFM' ),
    147             "jwtAuthKey" => defined('MOBILE_BUILDER_JWT_SECRET_KEY'),
    148             "googleMapApiKey" => defined('MOBILE_BUILDER_GOOGLE_API_KEY'),
    149             "facebookAppId" => defined('MOBILE_BUILDER_FB_APP_ID'),
    150             "facebookAppSecret" => defined('MOBILE_BUILDER_FB_APP_SECRET'),
    151             "oneSignalId" => defined('MOBILE_BUILDER_ONESIGNAL_APP_ID'),
    152             "oneSignalApiKey" => defined('MOBILE_BUILDER_ONESIGNAL_API_KEY'),
     144            "authStatus"        => false,
     145            "WooCommerce"       => false,
     146            "wcfm"              => class_exists( 'WCFM' ),
     147            "jwtAuthKey"        => defined( 'MOBILE_BUILDER_JWT_SECRET_KEY' ),
     148            "googleMapApiKey"   => defined( 'MOBILE_BUILDER_GOOGLE_API_KEY' ),
     149            "facebookAppId"     => defined( 'MOBILE_BUILDER_FB_APP_ID' ),
     150            "facebookAppSecret" => defined( 'MOBILE_BUILDER_FB_APP_SECRET' ),
     151            "oneSignalId"       => defined( 'MOBILE_BUILDER_ONESIGNAL_APP_ID' ),
     152            "oneSignalApiKey"   => defined( 'MOBILE_BUILDER_ONESIGNAL_API_KEY' ),
    153153        );
    154154
     
    166166    public function auto_login( $request ) {
    167167
    168         $theme = $request->get_param( 'theme' );
     168        $theme    = $request->get_param( 'theme' );
    169169        $currency = $request->get_param( 'currency' );
    170170
     
    299299            $variation      = $request->get_param( 'variation' );
    300300            $cart_item_data = $request->get_param( 'cart_item_data' );
    301 
    302             $cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation, $cart_item_data );
    303 
    304             if ( ! $cart_item_key ) {
    305                 return new WP_Error( 'add_to_cart', "Can't add product item to cart.", array(
    306                     'status' => 403,
    307                 ) );
    308             }
    309 
    310             return WC()->cart->get_cart_item( $cart_item_key );
     301            $passed_validation = false;
     302
     303            $passed_validation = apply_filters('woocommerce_add_to_cart_validation', true, $product_id, $quantity);
     304
     305            if($passed_validation){
     306
     307                $cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation, $cart_item_data );
     308
     309            }
     310
     311            if (! $passed_validation || ! $cart_item_key ){
     312                //if validation failed or add to cart failed, return response from woocommerce
     313                return new WP_Error( 'add_to_cart', htmlspecialchars_decode(strip_tags(wc_print_notices(true))), array(
     314                        'status' => 403,
     315                ) );
     316            }
     317           
     318
     319            return WC()->cart->get_cart_item( $cart_item_key );
     320
    311321        } catch ( \Exception $e ) {
    312322            //do something when exception is thrown
     
    362372
    363373        if ( WC()->cart->is_empty() && ! is_customize_preview() && apply_filters( 'woocommerce_checkout_update_order_review_expired', true ) ) {
    364             return new WP_Error( 404, 'Sorry, your session has expired.' );
     374            return new WP_Error( 404, __( 'Sorry, your session has expired.', "mobile-builder" ) );
    365375        }
    366376
     
    556566            return new WP_Error(
    557567                'set_quantity_error',
    558                 'Cart item key not exist.'
     568                __( 'Cart item key not exist.', "mobile-builder" )
    559569            );
    560570        }
     
    563573            return new WP_Error(
    564574                'set_quantity_error',
    565                 'The quantity not validate'
     575                __( 'The quantity not validate', "mobile-builder" )
    566576            );
    567577        }
     
    595605            return new WP_Error(
    596606                'remove_cart_item',
    597                 'Cart item key not exist.'
     607                __( 'Cart item key not exist.', "mobile-builder" )
    598608            );
    599609        }
     
    629639            return new WP_Error(
    630640                'add_discount',
    631                 'Coupon not exist.'
     641                __( 'Coupon not exist.', "mobile-builder" )
    632642            );
    633643        }
     
    662672            return new WP_Error(
    663673                'remove_coupon',
    664                 'Coupon not exist.'
     674                __( 'Coupon not exist.', "mobile-builder" )
    665675            );
    666676        }
     
    695705
    696706        if ( ! $isLogin ) {
    697             return new WP_Error( 'mobile_builder_can_not_add_to_cart', __( 'Sorry, you need login to add to cart.', 'mobile_builder' ) );
     707            return new WP_Error( 'mobile_builder_can_not_add_to_cart', __( 'Sorry, you need login to add to cart.', 'mobile-builder' ) );
    698708        }
    699709
  • mobile-builder/trunk/includes/libraries/class-mobile-builder-public-key.php

    r2303204 r2337209  
    2121
    2222        if ( ! isset( $decodedPublicKeys['keys'] ) || count( $decodedPublicKeys['keys'] ) < 1 ) {
    23             throw new Exception( 'Invalid key format.' );
     23            throw new Exception( __('Invalid key format.', "mobile-builder") );
    2424        }
    2525
     
    2727
    2828        if ( $key === false ) {
    29             throw new UnexpectedValueException( '"kid" empty, unable to lookup correct key' );
     29            throw new UnexpectedValueException( __('"kid" empty, unable to lookup correct key', "mobile-builder") );
    3030        }
    3131
     
    3535
    3636        if ( ! isset( $publicKeyDetails['key'] ) ) {
    37             throw new Exception( 'Invalid public key details.' );
     37            throw new Exception( __('Invalid public key details.', "mobile-builder") );
    3838        }
    3939
     
    6060    private static function parseKey( array $jwk ) {
    6161        if ( empty( $jwk ) ) {
    62             throw new InvalidArgumentException( 'JWK must not be empty' );
     62            throw new InvalidArgumentException( __('JWK must not be empty', "mobile-builder") );
    6363        }
    6464        if ( ! isset( $jwk['kty'] ) ) {
    65             throw new UnexpectedValueException( 'JWK must contain a "kty" parameter' );
     65            throw new UnexpectedValueException( __('JWK must contain a "kty" parameter', "mobile-builder") );
    6666        }
    6767
     
    6969            case 'RSA':
    7070                if ( \array_key_exists( 'd', $jwk ) ) {
    71                     throw new UnexpectedValueException( 'RSA private keys are not supported' );
     71                    throw new UnexpectedValueException( __('RSA private keys are not supported', "mobile-builder") );
    7272                }
    7373                if ( ! isset( $jwk['n'] ) || ! isset( $jwk['e'] ) ) {
    74                     throw new UnexpectedValueException( 'RSA keys must contain values for both "n" and "e"' );
     74                    throw new UnexpectedValueException( __('RSA keys must contain values for both "n" and "e"', "mobile-builder") );
    7575                }
    7676
     
    7979                if ( false === $publicKey ) {
    8080                    throw new DomainException(
    81                         'OpenSSL error: ' . \openssl_error_string()
     81                        __('OpenSSL error: ', "mobile-builder") . \openssl_error_string()
    8282                    );
    8383                }
  • mobile-builder/trunk/mobile-builder.php

    r2333323 r2337209  
    1111 * Plugin URI:        https://doc-oreo.rnlab.io
    1212 * Description:       The most advanced drag & drop app builder. Create multi templates and app controls.
    13  * Version:           1.0.5
     13 * Version:           1.0.6
    1414 * Author:            Rnlab.io
    1515 * Author URI:        https://rnlab.io
  • mobile-builder/trunk/product/class-mobile-builder-product.php

    r2332301 r2337209  
    124124            $data = [];
    125125            foreach ( $response->data as $key => $item ) {
    126                 $index                   = array_search( $item['id'], array_column($gmw_locations, 'object_id') );
     126                $index                   = array_search( $item['id'], array_column( $gmw_locations, 'object_id' ) );
    127127                $item['distance_matrix'] = $distance_matrix[ $index ];
    128128                $data[]                  = $item;
     
    208208        return new WP_Error(
    209209            "product_id",
    210             "Product ID not provider.",
     210            __( "Product ID not provider.", "mobile-builder" ),
    211211            array(
    212212                'status' => 403,
     
    227227//      echo $request->get_param('lat'); die;
    228228
    229         $type  = $response->data['type'];
    230 
    231         if( $type == 'variable' ){
    232             $price_min = $object->get_variation_price();
    233             $price_max = $object->get_variation_price('max');
     229        $type = $response->data['type'];
     230
     231        if ( $type == 'variable' ) {
     232            $price_min                   = $object->get_variation_price();
     233            $price_max                   = $object->get_variation_price( 'max' );
    234234            $response->data['price_min'] = $price_min;
    235235            $response->data['price_max'] = $price_max;
     
    242242
    243243            if ( $type == 'grouped' || $type == 'variable' ) {
    244                
     244
    245245                foreach ( $woocommerce_wpml->settings['currencies_order'] as $currency ) {
    246246
  • mobile-builder/trunk/public/class-mobile-builder-public.php

    r2333323 r2337209  
    294294            if ( count( $users ) > 0 ) {
    295295                $error = new WP_Error();
    296                 $error->add( 403, "Your phone number already exist in database!", array( 'status' => 400 ) );
     296                $error->add( 403, __( "Your phone number already exist in database!", "mobile-builder" ), array( 'status' => 400 ) );
    297297
    298298                return $error;
    299299            }
    300300
    301             return new WP_REST_Response( array( "data" => "Phone number not exits!" ), 200 );
     301            return new WP_REST_Response( array( "data" => __( "Phone number not exits!", "mobile-builder" ) ), 200 );
    302302        }
    303303
     
    305305        if ( count( $users ) == 0 ) {
    306306            $error = new WP_Error();
    307             $error->add( 403, "Your phone number not exist in database!", array( 'status' => 400 ) );
     307            $error->add( 403, __( "Your phone number not exist in database!", "mobile-builder" ), array( 'status' => 400 ) );
    308308
    309309            return $error;
    310310        }
    311311
    312         return new WP_REST_Response( array( "data" => "Phone number number exist!" ), 200 );
     312        return new WP_REST_Response( array( "data" => __( "Phone number number exist!", "mobile-builder" ) ), 200 );
    313313    }
    314314
     
    331331            wp_send_json_error( new WP_Error(
    332332                404,
    333                 'Something wrong!.',
     333                __( 'Something wrong!.', "mobile-builder" ),
    334334                array(
    335335                    'status' => 403,
     
    438438        // Perform Pre Checks
    439439        if ( ! class_exists( 'WooCommerce' ) ) {
    440             $error->add( 400, __( "Failed to process payment. WooCommerce either missing or deactivated.", 'rnlab-rest-payment' ), array( 'status' => 400 ) );
     440            $error->add( 400, __( "Failed to process payment. WooCommerce either missing or deactivated.", 'mobile-builder' ), array( 'status' => 400 ) );
    441441
    442442            return $error;
    443443        }
    444444        if ( empty( $order_id ) ) {
    445             $error->add( 401, __( "Order ID 'order_id' is required.", 'rnlab-rest-payment' ), array( 'status' => 400 ) );
     445            $error->add( 401, __( "Order ID 'order_id' is required.", 'mobile-builder' ), array( 'status' => 400 ) );
    446446
    447447            return $error;
    448448        } else if ( wc_get_order( $order_id ) == false ) {
    449             $error->add( 402, __( "Order ID 'order_id' is invalid. Order does not exist.", 'rnlab-rest-payment' ), array( 'status' => 400 ) );
     449            $error->add( 402, __( "Order ID 'order_id' is invalid. Order does not exist.", 'mobile-builder' ), array( 'status' => 400 ) );
    450450
    451451            return $error;
    452452        } else if ( wc_get_order( $order_id )->get_status() !== 'pending' && wc_get_order( $order_id )->get_status() !== 'failed' ) {
    453             $error->add( 403, __( "Order status is '" . wc_get_order( $order_id )->get_status() . "', meaning it had already received a successful payment. Duplicate payments to the order is not allowed. The allow status it is either 'pending' or 'failed'. ", 'rnlab-rest-payment' ), array( 'status' => 400 ) );
     453            $error->add( 403, __( "Order status is '" . wc_get_order( $order_id )->get_status() . "', meaning it had already received a successful payment. Duplicate payments to the order is not allowed. The allow status it is either 'pending' or 'failed'. ", 'mobile-builder' ), array( 'status' => 400 ) );
    454454
    455455            return $error;
    456456        }
    457457        if ( empty( $payment_method ) ) {
    458             $error->add( 404, __( "Payment Method 'payment_method' is required.", 'rnlab-rest-payment' ), array( 'status' => 400 ) );
     458            $error->add( 404, __( "Payment Method 'payment_method' is required.", 'mobile-builder' ), array( 'status' => 400 ) );
    459459
    460460            return $error;
     
    470470
    471471            if ( empty( $gateway ) ) {
    472                 $error->add( 405, __( "Failed to process payment. WooCommerce Gateway '" . $payment_method . "' is missing.", 'rnlab-rest-payment' ), array( 'status' => 400 ) );
     472                $error->add( 405, __( "Failed to process payment. WooCommerce Gateway '" . $payment_method . "' is missing.", 'mobile-builder' ), array( 'status' => 400 ) );
    473473
    474474                return $error;
    475475            } else {
    476                 $error->add( 406, __( "Failed to process payment. WooCommerce Gateway '" . $payment_method . "' exists, but is not available.", 'rnlab-rest-payment' ), array( 'status' => 400 ) );
     476                $error->add( 406, __( "Failed to process payment. WooCommerce Gateway '" . $payment_method . "' exists, but is not available.", 'mobile-builder' ), array( 'status' => 400 ) );
    477477
    478478                return $error;
    479479            }
    480480        } else if ( ! has_filter( 'rnlab_pre_process_' . $payment_method . '_payment' ) ) {
    481             $error->add( 407, __( "Failed to process payment. WooCommerce Gateway '" . $payment_method . "' exists, but 'REST Payment - " . $payment_method . "' is not available.", 'rnlab-rest-payment' ), array( 'status' => 400 ) );
     481            $error->add( 407, __( "Failed to process payment. WooCommerce Gateway '" . $payment_method . "' exists, but 'REST Payment - " . $payment_method . "' is not available.", 'mobile-builder' ), array( 'status' => 400 ) );
    482482
    483483            return $error;
     
    496496                if ( $payment_result['result'] === "success" ) {
    497497                    $response['code']    = 200;
    498                     $response['message'] = __( "Payment Successful.", "rnlab-rest-payment" );
     498                    $response['message'] = __( "Payment Successful.", "mobile-builder" );
    499499                    $response['data']    = $payment_result;
    500500
     
    502502                    return new WP_REST_Response( $response, 200 );
    503503                } else {
    504                     return new WP_Error( 500, 'Payment Failed, Check WooCommerce Status Log for further information.', $payment_result );
     504                    return new WP_Error( 500, __( 'Payment Failed, Check WooCommerce Status Log for further information.', "mobile-builder" ), $payment_result );
    505505                }
    506506            } else {
    507                 return new WP_Error( 408, 'Payment Failed, Pre Process Failed.', $parameters['pre_process_result'] );
     507                return new WP_Error( 408, __( 'Payment Failed, Pre Process Failed.', "mobile-builder" ), $parameters['pre_process_result'] );
    508508            }
    509509
     
    526526        if ( $payment_result['result'] === "success" ) {
    527527            $response['code']     = 200;
    528             $response['message']  = __( "Your Payment was Successful", "rnlab-rest-payment" );
     528            $response['message']  = __( "Your Payment was Successful", "mobile-builder" );
    529529            $response['redirect'] = $payment_result['redirect'];
    530530        } else {
    531531            $response['code']    = 401;
    532             $response['message'] = __( "Please enter valid card details", "rnlab-rest-payment" );
     532            $response['message'] = __( "Please enter valid card details", "mobile-builder" );
    533533        }
    534534
     
    545545
    546546        if ( empty( $order_id ) ) {
    547             $error->add( 401, __( "Order ID 'order_id' is required.", 'rnlab-rest-payment' ), array( 'status' => 400 ) );
     547            $error->add( 401, __( "Order ID 'order_id' is required.", 'mobile-builder' ), array( 'status' => 400 ) );
    548548
    549549            return $error;
    550550        } else if ( wc_get_order( $order_id ) == false ) {
    551             $error->add( 402, __( "Order ID 'order_id' is invalid. Order does not exist.", 'rnlab-rest-payment' ),
     551            $error->add( 402, __( "Order ID 'order_id' is invalid. Order does not exist.", 'mobile-builder' ),
    552552                array( 'status' => 400 ) );
    553553
     
    556556
    557557        if ( empty( $stripe_source ) ) {
    558             $error->add( 404, __( "Payment source 'stripe_source' is required.", 'rnlab-rest-payment' ),
     558            $error->add( 404, __( "Payment source 'stripe_source' is required.", 'mobile-builder' ),
    559559                array( 'status' => 400 ) );
    560560
     
    577577        if ( $payment_result['result'] === "success" ) {
    578578            $response['code']    = 200;
    579             $response['message'] = __( "Your Payment was Successful", "rnlab-rest-payment" );
     579            $response['message'] = __( "Your Payment was Successful", "mobile-builder" );
    580580
    581581            // $order = wc_get_order( $order_id );
     
    588588        } else {
    589589            $response['code']    = 401;
    590             $response['message'] = __( "Please enter valid card details", "rnlab-rest-payment" );
     590            $response['message'] = __( "Please enter valid card details", "mobile-builder" );
    591591        }
    592592
     
    643643            return new WP_Error(
    644644                'user_not_login',
    645                 'Please login first.',
     645                __( 'Please login first.', "mobile-builder" ),
    646646                array(
    647647                    'status' => 403,
     
    691691            return new WP_Error(
    692692                'user_not_login',
    693                 'Please login first.',
     693                __( 'Please login first.', "mobile-builder" ),
    694694                array(
    695695                    'status' => 403,
     
    752752
    753753            $result = array(
    754                 'language'              => $default_lang,
    755                 'languages'             => $languages,
    756                 'currencies'            => $currencies,
    757                 'currency'              => $currency,
    758                 'enable_guest_checkout' => get_option( 'woocommerce_enable_guest_checkout', true ),
    759                 'timezone_string'       => get_option( 'timezone_string' ) ? get_option( 'timezone_string' ) : wc_timezone_string(),
    760                 'date_format'           => get_option( 'date_format' ),
    761                 'time_format'           => get_option( 'time_format' ),
    762                 'configs'               => maybe_unserialize( $configs ),
    763                 'default_location'      => $gmw['post_types_settings'],
    764                 'templates'             => $decode ? $templates : $templates_data,
    765             );
     754                'language'               => $default_lang,
     755                'languages'              => $languages,
     756                'currencies'             => $currencies,
     757                'currency'               => $currency,
     758                'enable_guest_checkout'  => get_option( 'woocommerce_enable_guest_checkout', true ),
     759                'timezone_string'        => get_option( 'timezone_string' ) ? get_option( 'timezone_string' ) : wc_timezone_string(),
     760                'date_format'            => get_option( 'date_format' ),
     761                'time_format'            => get_option( 'time_format' ),
     762                'configs'                => maybe_unserialize( $configs ),
     763                'default_location'       => $gmw['post_types_settings'],
     764                'templates'              => $decode ? $templates : $templates_data,
     765                'checkout_user_location' => apply_filters( 'wcfmmp_is_allow_checkout_user_location', true ),
     766        );
    766767
    767768            wp_cache_set( 'settings_' . $decode, $result, 'rnlab' );
     
    771772            return new WP_Error(
    772773                'error_setting',
    773                 'Some thing wrong.',
     774                __( 'Some thing wrong.', "mobile-builder" ),
    774775                array(
    775776                    'status' => 403,
     
    799800            return new WP_Error(
    800801                'create_token_error',
    801                 'You did not create user wp_auth_user',
     802                __( 'You did not create user wp_auth_user', "mobile-builder" ),
    802803                array(
    803804                    'status' => 403,
     
    820821
    821822        if ( empty( $user_login ) || ! is_string( $user_login ) ) {
    822             $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Enter a username or email address.' ) );
     823            $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Enter a username or email address.', "mobile-builder" ) );
    823824        } elseif ( strpos( $user_login, '@' ) ) {
    824825            $user_data = get_user_by( 'email', trim( wp_unslash( $user_login ) ) );
    825826            if ( empty( $user_data ) ) {
    826827                $errors->add( 'invalid_email',
    827                     __( '<strong>ERROR</strong>: There is no account with that username or email address.' ) );
     828                    __( '<strong>ERROR</strong>: There is no account with that username or email address.', "mobile-builder" ) );
    828829            }
    829830        } else {
     
    838839        if ( ! $user_data ) {
    839840            $errors->add( 'invalidcombo',
    840                 __( '<strong>ERROR</strong>: There is no account with that username or email address.' ) );
     841                __( '<strong>ERROR</strong>: There is no account with that username or email address.', "mobile-builder" ) );
    841842
    842843            return $errors;
     
    862863        }
    863864
    864         $message = __( 'Someone has requested a password reset for the following account:' ) . "\r\n\r\n";
     865        $message = __( 'Someone has requested a password reset for the following account:', "mobile-builder" ) . "\r\n\r\n";
    865866        /* translators: %s: site name */
    866         $message .= sprintf( __( 'Site Name: %s' ), $site_name ) . "\r\n\r\n";
     867        $message .= sprintf( __( 'Site Name: %s', "mobile-builder" ), $site_name ) . "\r\n\r\n";
    867868        /* translators: %s: user login */
    868         $message .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n\r\n";
    869         $message .= __( 'If this was a mistake, just ignore this email and nothing will happen.' ) . "\r\n\r\n";
    870         $message .= __( 'To reset your password, visit the following address:' ) . "\r\n\r\n";
     869        $message .= sprintf( __( 'Username: %s', "mobile-builder" ), $user_login ) . "\r\n\r\n";
     870        $message .= __( 'If this was a mistake, just ignore this email and nothing will happen.', "mobile-builder" ) . "\r\n\r\n";
     871        $message .= __( 'To reset your password, visit the following address:', "mobile-builder" ) . "\r\n\r\n";
    871872        $message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ),
    872873                'login' ) . ">\r\n";
    873874
    874875        /* translators: Password reset notification email subject. %s: Site title */
    875         $title = sprintf( __( '[%s] Password Reset' ), $site_name );
     876        $title = sprintf( __( '[%s] Password Reset', "mobile-builder" ), $site_name );
    876877
    877878        /**
     
    907908            return new WP_Error(
    908909                'send_email',
    909                 'Possible reason: your host may have disabled the mail() function.',
     910                __( 'Possible reason: your host may have disabled the mail() function.', "mobile-builder" ),
    910911                array(
    911912                    'status' => 403,
     
    946947            return new WP_Error(
    947948                "email",
    948                 "Your input email not valid or exist in database.",
     949                __( "Your input email not valid or exist in database.", "mobile-builder" ),
    949950                array(
    950951                    'status' => 403,
     
    957958            return new WP_Error(
    958959                "name",
    959                 "Your username exist.",
     960                __( "Your username exist.", "mobile-builder" ),
    960961                array(
    961962                    'status' => 403,
     
    964965        }
    965966
    966         return array( "message" => "success!" );
     967        return array( "message" => __( "success!", "mobile-builder" ) );
    967968    }
    968969
     
    988989            return new WP_Error(
    989990                "email",
    990                 "Your input email not valid or exist in database.",
     991                __( "Your input email not valid or exist in database.", "mobile-builder" ),
    991992                array(
    992993                    'status' => 403,
     
    9991000            return new WP_Error(
    10001001                "name",
    1001                 "Your username exist.",
     1002                __( "Your username exist.", "mobile-builder" ),
    10021003                array(
    10031004                    'status' => 403,
     
    10101011            return new WP_Error(
    10111012                "first_name",
    1012                 "First name not valid.",
     1013                __( "First name not valid.", "mobile-builder" ),
    10131014                array(
    10141015                    'status' => 403,
     
    10211022            return new WP_Error(
    10221023                "last_name",
    1023                 "Last name not valid.",
     1024                __( "Last name not valid.", "mobile-builder" ),
    10241025                array(
    10251026                    'status' => 403,
     
    10321033            return new WP_Error(
    10331034                "password",
    1034                 "Password is required.",
     1035                __( "Password is required.", "mobile-builder" ),
    10351036                array(
    10361037                    'status' => 403,
     
    10731074                return new WP_Error(
    10741075                    'number_not_validate',
    1075                     'Your phone number not validate',
     1076                    __( 'Your phone number not validate', "mobile-builder" ),
    10761077                    array(
    10771078                        'status' => 403,
     
    10921093                return new WP_Error(
    10931094                    'phone_number_exist',
    1094                     "Your phone number already exist in database!",
     1095                    __( "Your phone number already exist in database!", "mobile-builder" ),
    10951096                    array( 'status' => 400 )
    10961097                );
     
    11671168        if ( $result === false ) {
    11681169            $error = new WP_Error();
    1169             $error->add( 403, "Get Firebase user info error!", array( 'status' => 400 ) );
     1170            $error->add( 403, __( "Get Firebase user info error!", "mobile-builder" ), array( 'status' => 400 ) );
    11701171
    11711172            return $error;
     
    11771178            return new WP_Error(
    11781179                'email_not_exist',
    1179                 'User not provider email',
     1180                __( 'User not provider email', "mobile-builder" ),
    11801181                array(
    11811182                    'status' => 403,
     
    12531254                return new WP_Error(
    12541255                    'error_login_apple',
    1255                     'Wrong number of segments',
     1256                    __( 'Wrong number of segments', "mobile-builder" ),
    12561257                    array(
    12571258                        'status' => 403,
     
    12651266                return new WP_Error(
    12661267                    'error_login_apple',
    1267                     'Invalid header encoding',
     1268                    __( 'Invalid header encoding', "mobile-builder" ),
    12681269                    array(
    12691270                        'status' => 403,
     
    12751276                return new WP_Error(
    12761277                    'error_login_apple',
    1277                     '"kid" empty, unable to lookup correct key',
     1278                    __( '"kid" empty, unable to lookup correct key', "mobile-builder" ),
    12781279                    array(
    12791280                        'status' => 403,
     
    12911292                return new WP_Error(
    12921293                    'validate-user',
    1293                     'User not validate',
     1294                    __( 'User not validate', "mobile-builder" ),
    12941295                    array(
    12951296                        'status' => 403,
     
    13811382        } catch ( \Facebook\Exceptions\FacebookResponseException $e ) {
    13821383            // When Graph returns an error
    1383             echo 'Graph returned an error: ' . $e->getMessage();
     1384            echo __( 'Graph returned an error: ', "mobile-builder" ) . $e->getMessage();
    13841385            exit;
    13851386        } catch ( \Facebook\Exceptions\FacebookSDKException $e ) {
    13861387            // When validation fails or other local issues
    1387             echo 'Facebook SDK returned an error: ' . $e->getMessage();
     1388            echo __( 'Facebook SDK returned an error: ', "mobile-builder" ) . $e->getMessage();
    13881389            exit;
    13891390        }
     
    13961397            return new WP_Error(
    13971398                'email_not_exist',
    1398                 'User not provider email',
     1399                __( 'User not provider email', "mobile-builder" ),
    13991400                array(
    14001401                    'status' => 403,
     
    15111512                return new WP_Error(
    15121513                    'not_exist_firebase_server_key',
    1513                     'The MOBILE_BUILDER_FIREBASE_SERVER_KEY not define in wp-config.php',
     1514                    __( 'The MOBILE_BUILDER_FIREBASE_SERVER_KEY not define in wp-config.php', "mobile-builder" ),
    15141515                    array(
    15151516                        'status' => 403,
     
    15381539            if ( $result === false ) {
    15391540                $error = new WP_Error();
    1540                 $error->add( 403, "Get Firebase user info error!", array( 'status' => 400 ) );
     1541                $error->add( 403, __( "Get Firebase user info error!", "mobile-builder" ), array( 'status' => 400 ) );
    15411542
    15421543                return $error;
     
    15461547                return new WP_Error(
    15471548                    'not_exist_firebase_user',
    1548                     'The user not exist.',
     1549                    __( 'The user not exist.', "mobile-builder" ),
    15491550                    array(
    15501551                        'status' => 403,
     
    15631564            if ( count( $users ) == 0 ) {
    15641565                $error = new WP_Error();
    1565                 $error->add( 403, "Did not find any members matching the phone number!", array( 'status' => 400 ) );
     1566                $error->add( 403, __( "Did not find any members matching the phone number!", "mobile-builder" ), array( 'status' => 400 ) );
    15661567
    15671568                return $error;
     
    16551656                return new WP_Error(
    16561657                    'no_auth_header',
    1657                     'Authorization header not found.',
     1658                    __( 'Authorization header not found.', "mobile-builder" ),
    16581659                    array(
    16591660                        'status' => 403,
     
    16671668                return new WP_Error(
    16681669                    'token_not_validate',
    1669                     'Token not validate format.',
     1670                    __( 'Token not validate format.', "mobile-builder" ),
    16701671                    array(
    16711672                        'status' => 403,
     
    16851686                return new WP_Error(
    16861687                    'bad_iss',
    1687                     'The iss do not match with this server',
     1688                    __( 'The iss do not match with this server', "mobile-builder" ),
    16881689                    array(
    16891690                        'status' => 403,
     
    16941695                return new WP_Error(
    16951696                    'id_not_found',
    1696                     'User ID not found in the token',
     1697                    __( 'User ID not found in the token', "mobile-builder" ),
    16971698                    array(
    16981699                        'status' => 403,
     
    18341835
    18351836        if ( get_current_user_id() != $id ) {
    1836             return new WP_Error( 'mobile_builder', __( 'Sorry, you cannot change info.', 'rnlab' ), array( 'status' => rest_authorization_required_code() ) );
     1837            return new WP_Error( 'mobile_builder', __( 'Sorry, you cannot change info.', "mobile-builder" ), array( 'status' => rest_authorization_required_code() ) );
    18371838        }
    18381839
Note: See TracChangeset for help on using the changeset viewer.