<?php
function ihc_init(){
/*
* RUN EVERYTIME ON PUBLIC
* @param none
* @return none
*/
//========== REGISTER SOCIAL MEDIA COOKIE
if (isset($_COOKIE['ihc_register'])){
global $ihc_stored_form_values;
$data = unserialize(stripslashes($_COOKIE['ihc_register']));
if (is_array($data) && count($data)){
foreach ($data as $k=>$v){
$ihc_stored_form_values[$k] = $v;
}
}
setcookie("ihc_register", "", time()-3600, COOKIEPATH, COOKIE_DOMAIN, false);//delete the cookie
}
$restrictionOn = true;
$postid = -1;
$url = IHC_PROTOCOL . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; /// $_SERVER['SERVER_NAME']
$current_user = false;
if (!empty($_POST['ihcaction'])){
/// FORM ACTIONS : REGISTER/LOGIN/UPDATE/ RESET PASS/ DELETE LEVEL FROM ACCOUNT PAGE/CANCEL LEVEL FROM ACCOUNT PAGE/ RENEW LEVEL
ihc_init_form_action($url);
} else {
/// LOGOUT / PAY NEW LEVEL
if (!empty($_GET['ihcdologout'])){
include_once IHC_PATH . 'public/functions/logout.php';
ihc_do_logout($url);
} else if (!empty($_GET['ihcnewlevel'])){
ihc_do_pay_new_level();
}
//// UX BUILDER
if (isset($_GET['uxb_iframe']) && !empty($_GET['post_id'])){
return;
}
//// UX BUILDER
/// REDIRECT / REPLACE CONTENT
$postid = url_to_postid( $url );//getting post id
$restrictionOn = true;
if ($postid==0){
$cpt_arr = ihc_get_all_post_types();
$the_cpt = FALSE;
$post_name = FALSE;
if (count($cpt_arr)){
foreach ($cpt_arr as $cpt){
if (!empty($_GET[$cpt])){
$the_cpt = $cpt;
$post_name = $_GET[$cpt];
break;
}
}
}
if ($the_cpt && $post_name){
$cpt_id = ihc_get_post_id_by_cpt_name($the_cpt, $post_name);
if ($cpt_id){
$postid = $cpt_id;
}
} else {
//test if its homepage
$homepage = get_option('page_on_front');
if($url==get_permalink($homepage)) $postid = $homepage;
}
}
$restrictionOn = apply_filters( 'ihc_filter_restriction', $restrictionOn, $postid );
if ( !$restrictionOn ){
return;
}
ihc_if_register_url($url);//test if is register page
ihc_block_page_content($postid, $url);//block page
}
$restrictionOn = apply_filters( 'ihc_filter_restriction', $restrictionOn, $postid );
if ( !$restrictionOn ){
return;
}
//// BLOCK INDIVIDUAL PAGE
ihc_do_block_if_individual_page($postid);
/////////////BLOCK BY URL
ihc_block_url($url, $current_user, $postid);//function available in public/functions.php
/// Block Rules
ihc_check_block_rules($url, $current_user, $postid);
/// Hide ADMIN BAR
ihc_do_show_hide_admin_bar_on_public();
//echo $postid,'<br/>';
}
<?php
/*************** PUBLIC SECTION ***************/
require_once IHC_PATH . 'public/functions.php';
//SHORTCODES
require IHC_PATH . 'public/shortcodes.php';
//INIT ACTION (login, register, logout, reset_pass)
require IHC_PATH . 'public/init.php';
add_action('init', 'ihc_init', 50, 0);
//FILTERS
require IHC_PATH . 'public/filters.php';
add_filter('the_content', 'ihc_print_message', 99);
//STYLE AND SCRIPTS
add_action('wp_enqueue_scripts', 'ihc_public_head');
function ihc_public_head(){
wp_enqueue_style( 'ihc_font_style', IHC_URL . 'assets/css/font-awesome.css' );
wp_enqueue_style( 'ihc_front_end_style', IHC_URL . 'assets/css/style.css' );
wp_enqueue_style( 'ihc_templates_style', IHC_URL . 'assets/css/templates.css' );
wp_enqueue_style( 'ihc_select2_style', IHC_URL . 'assets/css/select2.min.css' );
wp_enqueue_style( 'ihc_iziModal', IHC_URL . 'assets/css/iziModal.min.css' );
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_script( 'ihc-select2', IHC_URL . 'assets/js/select2.min.js', array(), null );
wp_enqueue_script( 'ihc-jquery-ui', IHC_URL . 'assets/js/jquery-ui.min.js', array(), null );
wp_enqueue_script( 'ihc-jquery_form_module', IHC_URL . 'assets/js/jquery.form.js', array(), null );
wp_enqueue_script( 'ihc-jquery_upload_file', IHC_URL . 'assets/js/jquery.uploadfile.min.js', array(), null );
wp_enqueue_script( 'ihc-front_end_js', IHC_URL . 'assets/js/functions.js', array(), null );
wp_localize_script( 'ihc-front_end_js', 'ihc_site_url', get_site_url());
wp_localize_script( 'ihc-front_end_js', 'ihc_translated_labels', json_encode( ihcJavascriptLabels() ) );
wp_enqueue_script('ihc-jquery_upload_file-footer', IHC_URL . 'assets/js/jquery.uploadfile.min.js', array(), null, TRUE);
wp_enqueue_script( 'ihc-print-this', IHC_URL . 'assets/js/printThis.js', array(), null );
wp_enqueue_script( 'ihc_iziModal_js', IHC_URL . 'assets/js/iziModal.min.js', array(), null );
}
function ihcJavascriptLabels()
{
return array(
'delete_level' => __('Are you sure you want to delete this level?', 'ihc'),
'cancel_level' => __('Are you sure you want to cancel this level?', 'ihc'),
);
}
add_filter('wp_authenticate_user', 'ihc_authenticate_filter', 9998, 3);
function ihc_authenticate_filter($user_data=null, $username='', $password=''){
if ($user_data==null) return $user_data;
if (is_object($user_data) && !empty($user_data->roles) && in_array('pending_user', $user_data->roles)){
$errors = new WP_Error();
$errors->add('title_error', 'Pending User');
return $errors;
}
return $user_data;
}
/// CHEAT OFF MODULE
include_once IHC_PATH . 'classes/Cheat_Off.class.php';
$cheat_off = new Cheat_Off();
<form action="" method="post" class="uap-change-password-form">
<div class="uap-ap-field">
<label class="uap-ap-label"><?php _e("Тип", 'uap');?></label>
<select class="uap-public-form-control" style="display: none;" onChange="uapPType();" name="uap_type"><?php
foreach ($data['p_types'] as $k=>$v):
$selected = ($data['metas']['uap_type']==$k) ? 'selected' : '';
?>
<option value="<?php echo $k;?>" <?php echo $selected;?>><?php echo $v;?></option>
<?php
endforeach;
?></select>
</div>
<div class="radio-container">
<div class="form-radio-btn">
<input type="radio" value="<?php echo $data['metas']['uap_email'];?>" name="uap_email" id="radio1" checked>
<label for="radio1">Email</label>
</div>
<div class="form-radio-btn">
<input type="radio" value="<?php echo $data['metas']['uap_data'];?>" name="uap_data" id="radio2">
<label for="radio2">Номер</label>
</div>
</div>
<div class="uap-ap-field" id="uap_with_email" style="display: none;">
<label class="uap-ap-label"><?php _e("E-mail", 'uap');?></label>
<input class="uap-public-form-control" type="text" value="<?php echo $data['metas']['uap_email'];?>" name="uap_email" />
</div>
<div class="uap-ap-field" id="uap_with_nm" style="display: none;">
<label class="uap-ap-label"><?php _e("Номер", 'uap');?></label>
<textarea style="min-height: 100px;" class="uap-public-form-control" name="uap_data"><?php echo $data['metas']['uap_data'];?></textarea>
</div>
<div class="uap-change-password-field-wrap">
<input type="submit" value="<?php _e("Сохранить", 'uap');?>" name="save_settings" class="button button-primary button-large" />
</div>
<?php if (!empty($data['error'])) : ?>
<div><?php echo $data['error'];?></div>
<?php elseif (!empty($data['success'])) : ?>
<div><?php echo $data['success'];?></div>
<?php endif; ?>
</form>
<script>
$("radio").click(function(e){e.preventDefault();})
</script>