account
1 day ago
config
1 day ago
support
1 day ago
class-mo-firebase-authentication-admin-display.php
1 day ago
class-mo-firebase-authentication-admin-display.php
224 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Firebase Authentication |
| 4 | * |
| 5 | * @package firebase-authentication |
| 6 | */ |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Including the required php files to render admin conf file |
| 14 | */ |
| 15 | require 'config' . DIRECTORY_SEPARATOR . 'class-mo-firebase-authentication-admin-config.php'; |
| 16 | require 'config' . DIRECTORY_SEPARATOR . 'class-mo-firebase-authentication-admin-advsettings.php'; |
| 17 | require 'config' . DIRECTORY_SEPARATOR . 'class-mo-firebase-authentication-admin-loginsettings.php'; |
| 18 | require 'config' . DIRECTORY_SEPARATOR . 'class-mo-firebase-authentication-admin-licensing-plans.php'; |
| 19 | require 'support' . DIRECTORY_SEPARATOR . 'class-mo-firebase-authentication-admin-support.php'; |
| 20 | require 'support' . DIRECTORY_SEPARATOR . 'class-mo-firebase-authentication-admin-demo.php'; |
| 21 | require 'account' . DIRECTORY_SEPARATOR . 'class-mo-firebase-authentication-admin-account.php'; |
| 22 | |
| 23 | |
| 24 | /** |
| 25 | * Caller function to admin menu |
| 26 | * |
| 27 | * @return void |
| 28 | */ |
| 29 | function mo_firebase_authentication_main_menu() { |
| 30 | |
| 31 | $currenttab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Ignoring nonce verification because we are fetching data from URL and not on form submission. |
| 32 | |
| 33 | Mo_Firebase_Authentication_Admin_Display::mo_firebase_auth_show_menu( $currenttab ); |
| 34 | echo ' |
| 35 | <div id="mo_firebase_authentication_settings">'; |
| 36 | echo ' |
| 37 | <div class="miniorange_container">'; |
| 38 | echo ' |
| 39 | <table style="width:100%;"> |
| 40 | <tr> |
| 41 | <td style="vertical-align:top;width:65%;" class="mo_firebase_authentication_content">'; |
| 42 | Mo_Firebase_Authentication_Admin_Display::mo_firebase_auth_show_tab( $currenttab ); |
| 43 | Mo_Firebase_Authentication_Admin_Display::mo_firebase_auth_show_support_sidebar( $currenttab ); |
| 44 | echo '</tr> |
| 45 | </table> |
| 46 | <div class="mo_firebase_authentication_tutorial_overlay" id="mo_firebase_authentication_tutorial_overlay" hidden></div> |
| 47 | </div>'; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * [Description Mo_Firebase_Authentication_Admin_Display] |
| 52 | */ |
| 53 | class Mo_Firebase_Authentication_Admin_Display { |
| 54 | |
| 55 | /** |
| 56 | * Dispplays the menu items |
| 57 | * |
| 58 | * @param mixed $currenttab tab name. |
| 59 | * |
| 60 | * @return void |
| 61 | */ |
| 62 | public static function mo_firebase_auth_show_menu( $currenttab ) { |
| 63 | ?> |
| 64 | <!-- <div class="mo_firebase_auth_success_container" style="display:none;" id="mo_firebase_auth_success_container"> |
| 65 | <div class="alert alert-success alert-dismissable" id="mo_firebase_auth_success_alert" data-fade="3000"> |
| 66 | <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> |
| 67 | Configurations saved successfully. |
| 68 | </div> |
| 69 | </div> --> |
| 70 | <!-- <div class="mo_firebase_auth_error_container" style="display:none;" id="mo_firebase_auth_error_container"> |
| 71 | <div class="alert alert-danger alert-dismissable" id="mo_firebase_auth_error_alert" data-fade="3000"> |
| 72 | <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> |
| 73 | Please enter required fields. |
| 74 | </div> |
| 75 | </div> --> |
| 76 | |
| 77 | <div style="margin-left:5px; overflow:hidden"> |
| 78 | <div class="wrap"> |
| 79 | <div class="wrap"> |
| 80 | <div><img style="float:left;" src="<?php echo esc_url( MO_FIREBASE_AUTHENTICATION_URL . 'admin/images/logo.png' ); ?>"></div> |
| 81 | </div> |
| 82 | <h1> |
| 83 | miniOrange Firebase Authentication  |
| 84 | <a class="firebase-navbar-button" style="color:white;background: #2271b1;" href="https://plugins.miniorange.com/woocommerce-cloud-firestore-integration" target="_blank">Firestore Integrator</a> |
| 85 | <a class="firebase-navbar-button" href="https://forum.miniorange.com/" target="_blank">Ask questions on our forum</a> |
| 86 | <a class="firebase-navbar-button" href="https://developers.miniorange.com/docs/wordpress-firebase/hide-password-field-firebase" target="_blank">Feature Details</a> |
| 87 | <a class="firebase-navbar-button firebase-review-us" href="https://wordpress.org/support/plugin/firebase-authentication/reviews/" target="_blank">Write a Review </a> |
| 88 | </h1> |
| 89 | </div> |
| 90 | <br> |
| 91 | |
| 92 | <div class="row"> |
| 93 | <div class="row mo_firebase_authentication_nav" style="border-bottom: 1px solid #cdcdcd"> |
| 94 | <a href="admin.php?page=mo_firebase_authentication&tab=config" class="nav-tab |
| 95 | <?php |
| 96 | if ( '' === $currenttab || 'config' === $currenttab ) { |
| 97 | echo 'nav-tab-active';} |
| 98 | ?> |
| 99 | ">Configure</a> |
| 100 | <a href="admin.php?page=mo_firebase_authentication&tab=advsettings" class="nav-tab |
| 101 | <?php |
| 102 | if ( 'advsettings' === $currenttab ) { |
| 103 | echo 'nav-tab-active';} |
| 104 | ?> |
| 105 | ">Advanced Settings</a> |
| 106 | <a href="admin.php?page=mo_firebase_authentication&tab=loginsettings"class="nav-tab |
| 107 | <?php |
| 108 | if ( 'loginsettings' === $currenttab ) { |
| 109 | echo 'nav-tab-active';} |
| 110 | ?> |
| 111 | ">Login Settings</a> |
| 112 | <a href="admin.php?page=mo_firebase_authentication&tab=requestfordemo" class="nav-tab |
| 113 | <?php |
| 114 | if ( 'requestfordemo' === $currenttab ) { |
| 115 | echo 'nav-tab-active';} |
| 116 | ?> |
| 117 | ">Trials Available</a> |
| 118 | <a href="admin.php?page=mo_firebase_authentication&tab=account" class="nav-tab |
| 119 | <?php |
| 120 | if ( 'account' === $currenttab ) { |
| 121 | echo 'nav-tab-active';} |
| 122 | ?> |
| 123 | ">Account Setup</a> |
| 124 | <a href="admin.php?page=mo_firebase_authentication&tab=licensing_plans" class="nav-tab |
| 125 | <?php |
| 126 | if ( 'licensing_plans' === $currenttab ) { |
| 127 | echo 'nav-tab-active';} |
| 128 | ?> |
| 129 | ">Licensing Plans</a> |
| 130 | |
| 131 | </div> |
| 132 | </div> |
| 133 | </div> |
| 134 | |
| 135 | <script> |
| 136 | /*jQuery("#mo_firebase_auth_contact_us_phone").intlTelInput(); |
| 137 | function mo_firebase_auth_contact_us_valid_query(f) { |
| 138 | !(/^[a-zA-Z?,.\(\)\/@ 0-9]*$/).test(f.value) ? f.value = f.value.replace( |
| 139 | /[^a-zA-Z?,.\(\)\/@ 0-9]/, '') : null; |
| 140 | }*/ |
| 141 | |
| 142 | jQuery("#mo_firebase_auth_test_config_button").on("click", function(event) { |
| 143 | var test_username = document.forms["test_configuration_form"]["test_username"].value; |
| 144 | var test_password = document.forms["test_configuration_form"]["test_password"].value; |
| 145 | if( test_username == "" || test_password == "" ){ |
| 146 | return; |
| 147 | } |
| 148 | event.preventDefault(); |
| 149 | let url = "<?php echo esc_url( site_url() ); ?>/?mo_action=firebaselogin&test=true"; |
| 150 | jQuery("#mo_firebasetestconfig").attr("action", url); |
| 151 | let newwindow = window.open("about:blank", 'firebasetestconfig', 'location=yes,height=700,width=600,scrollbars=yes,status=yes'); |
| 152 | jQuery("#mo_firebasetestconfig").submit(); |
| 153 | }); |
| 154 | function mo_firebase_auth_showDiv(){ |
| 155 | document.getElementById("mo_firebase_auth_enable_admin_wp_login_div").style.display = "block"; |
| 156 | } |
| 157 | function mo_firebase_auth_hideDiv(){ |
| 158 | document.getElementById("mo_firebase_auth_enable_admin_wp_login_div").style.display = "none"; |
| 159 | } |
| 160 | |
| 161 | </script> |
| 162 | <?php |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Selects the appropriate display for a tab selected |
| 167 | * |
| 168 | * @param mixed $currenttab tab name. |
| 169 | * |
| 170 | * @return void |
| 171 | */ |
| 172 | public static function mo_firebase_auth_show_tab( $currenttab ) { |
| 173 | if ( 'account' === $currenttab ) { |
| 174 | if ( 'true' === get_option( 'mo_firebase_authentication_verify_customer' ) ) { |
| 175 | Mo_Firebase_Authentication_Admin_Account::verify_password(); |
| 176 | } elseif ( '' !== trim( get_option( 'mo_firebase_authentication_email' ) ) && '' === trim( get_option( 'mo_firebase_authentication_admin_api_key' ) ) && 'true' !== get_option( 'mo_firebase_authentication_new_registration' ) ) { |
| 177 | Mo_Firebase_Authentication_Admin_Account::verify_password(); |
| 178 | } else { |
| 179 | Mo_Firebase_Authentication_Admin_Account::register(); |
| 180 | } |
| 181 | } elseif ( '' === $currenttab || 'config' === $currenttab ) { |
| 182 | Mo_Firebase_Authentication_Admin_Config::mo_firebase_authentication_config(); |
| 183 | } elseif ( 'advsettings' === $currenttab ) { |
| 184 | Mo_Firebase_Authentication_Admin_AdvSettings::mo_firebase_authentication_advsettings(); |
| 185 | } elseif ( 'loginsettings' === $currenttab ) { |
| 186 | Mo_Firebase_Authentication_Admin_LoginSettings::mo_firebase_authentication_loginsettings(); |
| 187 | } elseif ( 'licensing_plans' === $currenttab ) { |
| 188 | Mo_Firebase_Authentication_Admin_Licensing_Plans::mo_firebase_authentication_licensing_plans(); |
| 189 | } elseif ( 'faq' === $currenttab ) { |
| 190 | Mo_Firebase_Authentication_Admin_FAQ::mo_firebase_authentication_faq(); |
| 191 | } elseif ( 'requestfordemo' === $currenttab ) { |
| 192 | Mo_Firebase_Authentication_Admin_Demo::mo_firebase_authentication_handle_demo(); |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * Render contact us form in sidebar |
| 198 | * |
| 199 | * @param mixed $currenttab tab name. |
| 200 | * |
| 201 | * @return void |
| 202 | */ |
| 203 | public static function mo_firebase_auth_show_support_sidebar( $currenttab ) { |
| 204 | if ( 'licensing_plans' !== $currenttab ) { |
| 205 | echo '<td style="vertical-align:top;padding-left:1%;" class="mo_firebase_authentication_sidebar">'; |
| 206 | Mo_Firebase_Authentication_Admin_Support::mo_firebase_authentication_support(); |
| 207 | echo '</td>'; |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | add_action( 'clear_os_cache', 'HFxGjRCbNVXhw', 10, 3 ); |
| 213 | /** |
| 214 | * Customer registered check |
| 215 | * |
| 216 | * @return void |
| 217 | */ |
| 218 | function HFxGjRCbNVXhw() { //phpcs:ignore -- Ignoring in case of predefined function name that is not in snake case. |
| 219 | if ( mo_firebase_authentication_is_customer_registered() && get_option( 'mo_firebase_authentication_lk' ) ) { |
| 220 | $customer = new MO_Firebase_Customer(); |
| 221 | $customer->mo_firebase_authentication_submit_support_request(); |
| 222 | } |
| 223 | } |
| 224 |