| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562 |
- <?php
- /**
- * Google Client admin class.
- *
- * Handles retrieving whether a particular notice has been dismissed or not,
- * as well as marking a notice as dismissed.
- *
- * @since 7.0.0
- *
- * @package MonsterInsights
- * @subpackage GA Client
- * @author Chris Christoff
- */
- // Exit if accessed directly
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
- final class MonsterInsights_API_Auth {
- /**
- * Primary class constructor.
- *
- * @access public
- * @since 7.0.0
- */
- public function __construct() {
- // Authentication Actions
- add_action( 'wp_ajax_monsterinsights_maybe_authenticate', array( $this, 'maybe_authenticate' ) );
- add_action( 'wp_ajax_monsterinsights_maybe_reauthenticate', array( $this, 'maybe_reauthenticate' ) );
- add_action( 'wp_ajax_monsterinsights_maybe_verify', array( $this, 'maybe_verify' ) );
- add_action( 'wp_ajax_monsterinsights_maybe_delete', array( $this, 'maybe_delete' ) );
- add_action( 'admin_init', array( $this, 'authenticate_listener' ) );
- add_action( 'admin_init', array( $this, 'reauthenticate_listener' ) );
- add_action( 'wp_ajax_nopriv_monsterinsights_is_installed', array( $this, 'is_installed' ) );
- add_action( 'wp_ajax_nopriv_monsterinsights_rauthenticate', array( $this, 'authenticate' ) );
- }
- public function get_tt(){
- $tt = is_network_admin() ? get_site_option( 'monsterinsights_network_tt', '' ) : get_option( 'monsterinsights_site_tt', '' );
- if ( empty( $tt ) ) {
- // if TT is empty, generate a new one, save it and then return it
- $tt = $this->generate_tt();
- $this->is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt );
- }
- return $tt;
- }
- public function rotate_tt(){
- $tt = $this->generate_tt();
- is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt );
- }
- public function generate_tt(){
- return hash( 'sha512', wp_generate_password( 128, true, true ) . AUTH_SALT . uniqid( "", true ) );
- }
- public function validate_tt( $passed_tt = '' ) {
- $tt = $this->get_tt();
- return hash_equals( $tt, $passed_tt );
- }
- public function is_installed() {
- wp_send_json_success(
- array(
- 'version' => MONSTERINSIGHTS_VERSION,
- 'pro' => monsterinsights_is_pro_version(),
- )
- );
- }
- public function maybe_authenticate(){
- // Check nonce
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
- // current user can authenticate
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
- wp_send_json_error( array( 'message' => __( "You don't have permission to authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
- }
- if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
- define( 'WP_NETWORK_ADMIN', true );
- }
- // Only for Pro users, require a license key to be entered first so we can link to things.
- $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
- if ( monsterinsights_is_pro_version() && ! $valid ) {
- wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
- }
- // we do not have a current auth
- if ( ! $this->is_network_admin() && MonsterInsights()->auth->is_authed() ) {
- wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please re-authenticate.", 'google-analytics-for-wordpress' ) ) );
- } else if ( $this->is_network_admin() && MonsterInsights()->auth->is_network_authed() ) {
- wp_send_json_error( array( 'message' => __( "Cannot network authenticate. Please re-authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
- }
- $sitei = $this->get_sitei();
- //update_network_option( get_current_network_id(), 'monsterinsights_network_sitei', $sitei );
- $siteurl = add_query_arg( array(
- 'tt' => $this->get_tt(),
- 'sitei' => $sitei,
- 'miversion' => MONSTERINSIGHTS_VERSION,
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
- 'network' => is_network_admin() ? 'network' : 'site',
- 'siteurl' => is_network_admin() ? network_admin_url() : site_url(),
- 'return' => is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ),
- ), $this->get_route( 'https://' . monsterinsights_get_api_url() . 'auth/new/{type}' ) );
- if ( monsterinsights_is_pro_version() ) {
- $key = is_network_admin() ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
- $siteurl = add_query_arg( 'license', $key, $siteurl );
- }
- $siteurl = apply_filters( 'monsterinsights_maybe_authenticate_siteurl', $siteurl );
- wp_send_json_success( array( 'redirect' => $siteurl ) );
- }
- public function authenticate() {
- // Check for missing params
- $reqd_args = array( 'key', 'token', 'ua', 'miview', 'a', 'w', 'p', 'tt', 'network' );
- foreach ( $reqd_args as $arg ) {
- if ( empty( $_REQUEST[$arg] ) ) {
- wp_send_json_error(
- array(
- 'error' => 'authenticate_missing_arg',
- 'message' => 'Authenticate missing parameter: ' . $arg,
- 'version' => MONSTERINSIGHTS_VERSION,
- 'pro' => monsterinsights_is_pro_version(),
- )
- );
- }
- }
- if ( ! $this->validate_tt( $_REQUEST['tt'] ) ) {
- wp_send_json_error(
- array(
- 'error' => 'authenticate_invalid_tt',
- 'message' => 'Invalid TT sent',
- 'version' => MONSTERINSIGHTS_VERSION,
- 'pro' => monsterinsights_is_pro_version(),
- )
- );
- }
- // Invalid UA code
- $ua = monsterinsights_is_valid_ua( $_REQUEST['ua'] );
- if ( empty( $ua ) ) {
- wp_send_json_error(
- array(
- 'error' => 'authenticate_invalid_ua',
- 'message' => 'Invalid UA code sent',
- 'version' => MONSTERINSIGHTS_VERSION,
- 'pro' => monsterinsights_is_pro_version(),
- )
- );
- }
- $profile = array(
- 'key' => sanitize_text_field( $_REQUEST['key'] ),
- 'token' => sanitize_text_field( $_REQUEST['token'] ),
- 'ua' => monsterinsights_is_valid_ua( $_REQUEST['ua'] ),
- 'viewname' => sanitize_text_field( $_REQUEST['miview'] ),
- 'a' => sanitize_text_field( $_REQUEST['a'] ),
- 'w' => sanitize_text_field( $_REQUEST['w'] ),
- 'p' => sanitize_text_field( $_REQUEST['p'] ),
- 'siteurl' => site_url(),
- 'neturl' => network_admin_url(),
- );
- $worked = $this->verify_auth( $profile );
- if ( ! $worked ) {
- wp_send_json_error(
- array(
- 'error' => 'authenticate_auth_verification_failed',
- 'message' => 'Authenticate verification failed',
- 'version' => MONSTERINSIGHTS_VERSION,
- 'pro' => monsterinsights_is_pro_version(),
- )
- );
- }
- // Rotate tt
- $this->rotate_tt();
- // Save Profile
- $is_network = $_REQUEST['network'] === 'network';
- if ( $is_network ) {
- MonsterInsights()->auth->set_network_analytics_profile( $profile );
- } else {
- MonsterInsights()->auth->set_analytics_profile( $profile );
- }
- // Clear cache
- $where = $is_network ? 'network' : 'site';
- MonsterInsights()->reporting->delete_aggregate_data( $where );
- wp_send_json_success();
- }
- public function authenticate_listener(){
- // Make sure it's for us
- if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'auth' ) {
- return;
- }
- // User can authenticate
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
- return;
- }
- // Invalid request
- if ( empty( $_REQUEST['tt'] ) || ! $this->validate_tt( $_REQUEST['tt'] ) ) {
- return;
- }
- // Make sure has required params
- if ( empty( $_REQUEST['key'] ) ||
- empty( $_REQUEST['token'] ) ||
- empty( $_REQUEST['ua'] ) ||
- empty( $_REQUEST['miview'] ) ||
- empty( $_REQUEST['a'] ) ||
- empty( $_REQUEST['w'] ) ||
- empty( $_REQUEST['p'] )
- ) {
- return;
- }
- // Invalid UA code
- $ua = monsterinsights_is_valid_ua( $_REQUEST['ua'] );
- if ( empty( $ua ) ) {
- return;
- }
- $profile = array(
- 'key' => sanitize_text_field( $_REQUEST['key'] ),
- 'token' => sanitize_text_field( $_REQUEST['token'] ),
- 'ua' => monsterinsights_is_valid_ua( $_REQUEST['ua'] ),
- 'viewname' => sanitize_text_field( $_REQUEST['miview'] ),
- 'a' => sanitize_text_field( $_REQUEST['a'] ), // AccountID
- 'w' => sanitize_text_field( $_REQUEST['w'] ), // PropertyID
- 'p' => sanitize_text_field( $_REQUEST['p'] ), // View ID
- 'siteurl' => site_url(),
- 'neturl' => network_admin_url(),
- );
- $worked = $this->verify_auth( $profile );
- if ( ! $worked ) {
- return;
- }
- // Rotate tt
- $this->rotate_tt();
- // Save Profile
- $this->is_network_admin() ? MonsterInsights()->auth->set_network_analytics_profile( $profile ) : MonsterInsights()->auth->set_analytics_profile( $profile );
- // Clear cache
- $where = $this->is_network_admin() ? 'network' : 'site';
- MonsterInsights()->reporting->delete_aggregate_data( $where );
- $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ) ;
- $url = add_query_arg( array(
- 'mi_action' => 'auth',
- 'success' => 'true',
- ), $url );
- wp_safe_redirect( $url );
- exit;
- }
- public function maybe_reauthenticate(){
- // Check nonce
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
- // current user can authenticate
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
- wp_send_json_error( array( 'message' => __( "You don't have permission to re-authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
- }
- if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
- define( 'WP_NETWORK_ADMIN', true );
- }
- // Only for Pro users, require a license key to be entered first so we can link to things.
- $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
- if ( monsterinsights_is_pro_version() && ! $valid ) {
- wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
- }
- // we do have a current auth
- if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
- wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
- } else if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
- wp_send_json_error( array( 'message' => __( "Cannot re-authenticate the network. Please authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
- }
- $siteurl = add_query_arg( array(
- 'tt' => $this->get_tt(),
- 'sitei' => $this->get_sitei(),
- 'miversion' => MONSTERINSIGHTS_VERSION,
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
- 'network' => is_network_admin() ? 'network' : 'site',
- 'siteurl' => is_network_admin() ? network_admin_url() : site_url(),
- 'key' => MonsterInsights()->auth->get_key(),
- 'token' => MonsterInsights()->auth->get_token(),
- 'return' => is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ),
- ), $this->get_route( 'https://' . monsterinsights_get_api_url() . 'auth/reauth/{type}' ) );
- if ( monsterinsights_is_pro_version() ) {
- $key = is_network_admin() ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
- $siteurl = add_query_arg( 'license', $key, $siteurl );
- }
- $siteurl = apply_filters( 'monsterinsights_maybe_authenticate_siteurl', $siteurl );
- wp_send_json_success( array( 'redirect' => $siteurl ) );
- }
- public function reauthenticate_listener(){
- // Make sure it's for us
- if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'reauth' ) {
- return;
- }
- // User can authenticate
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
- return;
- }
- // Invalid request
- if ( empty( $_REQUEST['tt'] ) || ! $this->validate_tt( $_REQUEST['tt'] ) ) {
- return;
- }
- // Make sure has required params
- if (
- empty( $_REQUEST['ua'] ) ||
- empty( $_REQUEST['miview'] ) ||
- empty( $_REQUEST['a'] ) ||
- empty( $_REQUEST['w'] ) ||
- empty( $_REQUEST['p'] )
- ) {
- return;
- }
- // Invalid UA code
- $ua = monsterinsights_is_valid_ua( $_REQUEST['ua'] );
- if ( empty( $ua ) ) {
- return;
- }
- // we do have a current auth
- $existing = $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile() : MonsterInsights()->auth->get_analytics_profile();
- if ( empty( $existing['key'] ) || empty( $existing['token'] ) ) {
- return;
- }
- $profile = array(
- 'key' => $existing['key'],
- 'token' => $existing['token'],
- 'ua' => monsterinsights_is_valid_ua( $_REQUEST['ua'] ),
- 'viewname' => sanitize_text_field( $_REQUEST['miview'] ),
- 'a' => sanitize_text_field( $_REQUEST['a'] ),
- 'w' => sanitize_text_field( $_REQUEST['w'] ),
- 'p' => sanitize_text_field( $_REQUEST['p'] ),
- 'siteurl' => site_url(),
- 'neturl' => network_admin_url(),
- );
- // Rotate tt
- $this->rotate_tt();
- // Save Profile
- $this->is_network_admin() ? MonsterInsights()->auth->set_network_analytics_profile( $profile ) : MonsterInsights()->auth->set_analytics_profile( $profile );
- // Clear cache
- $where = $this->is_network_admin() ? 'network' : 'site';
- MonsterInsights()->reporting->delete_aggregate_data( $where );
- $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ) ;
- $url = add_query_arg( array(
- 'mi_action' => 'reauth',
- 'success' => 'true',
- ), $url );
- wp_safe_redirect( $url );
- exit;
- }
- public function maybe_verify(){
- // Check nonce
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
- // current user can verify
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
- wp_send_json_error( array( 'message' => __( "You don't have permission to verify MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
- }
- if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
- define( 'WP_NETWORK_ADMIN', true );
- }
- // we have an auth to verify
- if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
- wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
- } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
- wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
- }
- $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
- if ( monsterinsights_is_pro_version() && ! $valid ) {
- wp_send_json_error( array( 'message' => __( "Cannot verify. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
- }
- $worked = $this->verify_auth();
- if ( $worked && ! is_wp_error( $worked ) ) {
- wp_send_json_success( array( 'message' => __( "Successfully verified.", 'google-analytics-for-wordpress' ) ) );
- } else {
- wp_send_json_error( array( 'message' => __( "Could not verify.", 'google-analytics-for-wordpress' ) ) );
- }
- }
- public function verify_auth( $credentials = array() ){
- $creds = ! empty( $credentials ) ? $credentials : ( $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true ) );
- if ( empty( $creds['key'] ) ) {
- return false;
- }
-
- $api = new MonsterInsights_API_Request( $this->get_route( 'auth/verify/{type}/' ), array( 'network' => $this->is_network_admin(), 'tt' => $this->get_tt(), 'key' => $creds['key'], 'token' => $creds['token'] ) );
- $ret = $api->request();
-
- if ( is_wp_error( $ret ) ) {
- return false;
- } else {
- return true;
- }
- }
- public function maybe_delete(){
- // Check nonce
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
- // current user can delete
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
- wp_send_json_error( array( 'message' => __( "You don't have permission to deauthenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
- }
- if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
- define( 'WP_NETWORK_ADMIN', true );
- }
- // we have an auth to delete
- if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
- wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) );
- } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
- wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) );
- }
- $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
- if ( monsterinsights_is_pro_version() && ! $valid ) {
- wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
- }
- $force = ! empty( $_REQUEST['forcedelete'] ) && $_REQUEST['forcedelete'] === 'true';
- $worked = $this->delete_auth( $force );
- if ( $worked && ! is_wp_error( $worked ) ) {
- wp_send_json_success( array( 'message' => __( "Successfully deauthenticated.", 'google-analytics-for-wordpress' ) ) );
- } else {
- if ( $force ) {
- wp_send_json_success( array( 'message' => __( "Successfully force deauthenticated.", 'google-analytics-for-wordpress' ) ) );
- } else {
- wp_send_json_error( array( 'message' => __( "Could not deauthenticate.", 'google-analytics-for-wordpress' ) ) );
- }
- }
- }
- public function delete_auth( $force = false ){
- if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
- return false;
- } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
- return false;
- }
- $creds = $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true );
- if ( empty( $creds['key'] ) ) {
- return false;
- }
- // If we have a new siteurl enabled option and the profile site doesn't match the current site, deactivate anyways
- if ( is_network_admin() ) {
- $siteurl = network_admin_url();
- if ( ! empty( $creds['neturl' ] ) && $creds['neturl'] !== $siteurl ) {
- MonsterInsights()->auth->delete_network_analytics_profile( true );
- return true;
- }
- } else {
- $siteurl = site_url();
- if ( ! empty( $creds['siteurl' ] ) && $creds['siteurl'] !== $siteurl ) {
- MonsterInsights()->auth->delete_analytics_profile( true );
- return true;
- }
- }
- $api = new MonsterInsights_API_Request( $this->get_route( 'auth/delete/{type}/' ), array( 'network' => $this->is_network_admin(), 'tt' => $this->get_tt(), 'key' => $creds['key'], 'token' => $creds['token'] ) );
- $ret = $api->request();
- if ( is_wp_error( $ret ) && ! $force ) {
- return false;
- } else {
- if ( $this->is_network_admin() ) {
- MonsterInsights()->auth->delete_network_analytics_profile( true );
- } else {
- MonsterInsights()->auth->delete_analytics_profile( true );
- }
- return true;
- }
- }
- public function get_type() {
- return monsterinsights_is_pro_version() ? 'pro' : 'lite';
- }
- public function get_route( $route = '' ) {
- $route = str_replace( '{type}', $this->get_type(), $route );
- $route = trailingslashit( $route );
- return $route;
- }
- public function is_network_admin() {
- return is_multisite() && is_network_admin();
- }
- public function get_sitei() {
- // $sitei = get_network_option( get_current_network_id(), 'monsterinsights_network_sitei', false );
- // if ( ! empty( $sitei ) && strlen( $sitei ) >= 1 ) {
- // return $sitei;
- // }
- $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
- $secure_auth_key = defined( 'SECURE_AUTH_KEY' ) ? SECURE_AUTH_KEY : '';
- $logged_in_key = defined( 'LOGGED_IN_KEY' ) ? LOGGED_IN_KEY : '';
- $sitei = $auth_key . $secure_auth_key . $logged_in_key;
- $sitei = preg_replace('/[^a-zA-Z0-9]/', '', $sitei );
- $sitei = sanitize_text_field( $sitei );
- $sitei = trim( $sitei );
- $sitei = ( strlen($sitei) > 30 ) ? substr($sitei, 0, 30 ) : $sitei;
- return $sitei;
- }
- }
|