
WordPress
- 43 ответа
- 0 вопросов
46
Вклад в тег
...
$customizer->get_setting('blogname')->transport='postMessage';
$customizer->get_setting('blogdescription')->transport='postMessage';
...
//$wp_customize->add_setting('header_h1',array('transport'=>'postMessage'));
(function($){
var api=wp.customize;
api('blogname',function(value){value.bind(function(to){$('.site-title a').text(to);});});
api('blogdescription',function(value){value.bind(function(to){$('.site-description a').text(to);});});
...
$wp_customize->add_setting('header_h1');
add_action( 'customize_register', 'hgjghjghj' );
function hgjghjghj($wp_customize){
$wp_customize->add_panel(
'panel_main_page',
array(
'title' => 'Контент на главной странице',
'priority' => 999,
)
);
$wp_customize->add_section(
'header_h1',
array(
'panel' => 'panel_main_page',
'title' => 'Заголовок (h1) страницы',
'priority' => 0,
)
);
$wp_customize->add_setting(
'header_h1',array('transport'=>'postMessage')
);
$wp_customize->add_control(
'header_h1',
array(
'section' => 'header_h1',
'label' => 'Текст заголовка',
'type' => 'text'
)
);
}
...
api('header_h1',function(value){value.bind(function(to){$('#qweqweqwe').text(to);});});
...
//подключаем js для превью через add_action('customize_preview_init','preview_customize_enqueue');
//либо пишем калбак функцию и пишем js в ней...
echo '<div id="qweqweqwe">'.get_theme_mod('header_h1').'</div>';
if(is_singular('video')){ //Проверяет просматривается ли страница записи (поста, страницы, вложения, произвольный тип записи)
Я пытался использовать get_post_type, но там просят id типа записей. А где его взять?
global $post; //$post->ID
$post_type = get_post_type( $post->ID );
<?php session_start();#Template Name: Загрузка файлов из списка на сервер с новым именем
get_header();
if(have_posts()):
while(have_posts()):the_post();
get_template_part('VAB_template_parts/forms/VAB','FilesLoadServer');
endwhile;
endif;
get_sidebar();get_footer();
if(!function_exists('VAB_Authentication()')){function VAB_Authentication(){
$pass='session_password';//это пароль
$errorSession='';
if(isset($_POST['pass_value'],$_POST['pass_btn'])){
if($pass==$_POST['pass_value']){$_SESSION['unique_ProtecT']=true;
}else{$_SESSION['ProtecT']=false;$errorSession='<div title="'.__('Неверный пароль!','VAB').'">'.__('Неверный пароль!','VAB').'</div>';}}
if(empty($_SESSION['unique_ProtecT'])){?>
<div class="contact_message">
<div class="ProtecT">
<center>
<h4><?php echo $errorSession;printf(__('Страница для Администрации','VAB'));?></h4>
<form method="POST">
<div><?php printf(__('Введите пароль','VAB'));?>: <input type="text" name="pass_value" size="30" /> <input type="submit" value="<?php printf(__('Ввод','VAB'));?>" name="pass_btn" />
</div>
</form>
<br><a href="<?php bloginfo('url');?>"><?php printf(__('Отмена','VAB'));?></a>
</center>
</div>
</div>
<?php }}}
if(function_exists('VAB_Authentication')):VAB_Authentication();endif;
if(VABMoD('VAB_pass_session'))://если в опции есть какое-либо значение, то пароль есть значение опции
$pass=VABMoD('VAB_pass_session');
else://иначе пароль по умолчанию
$pass='session_password';
endif;
if(function_exists('VAB_Authentication')):VAB_Authentication();endif;
exit();//завершает все скрипты после... в том числе и сайдбары и футер и т.д.
if(isset($_SESSION['unique_ProtecT'])&&$_SESSION['unique_ProtecT']==true){
//скрытый контент(включая инженерную панель разумеется)
}
add_action('wp_enqueue_scripts','load_styles_scripts');
if(!function_exists('load_styles_scripts')):function load_styles_scripts(){
wp_enqueue_script('click',get_template_directory_uri().'/js/click.js',array('jquery'));//подключенный файл скрипта в котором Вы хотите использовать функцию is_admin_bar_showing
$IABS=array('IABS_Out'=>is_admin_bar_showing());
wp_localize_script('click','IABS_In',$IABS);//передаем в файл скрипта функцию
}endif;
var IABS=IABS_In.IABS_Out;
if(IABS){alert('Админ бар отображается');}
add_filter('authenticate','filter_function_name_4601');
function filter_function_name_4601($user){
if(isset($_POST['log'])){
$username=$_POST['log'];
if(isset($username)){$user=get_user_by('login',$username);$user_data=get_object_vars($user);}
if(isset($user_data)){$userId=$user_data["ID"];$u_meta=get_userdata($userId);$u_roles=$u_meta->roles;}
}
if(!empty($u_roles)&&(in_array('administrator',$u_roles,true)||in_array('editor',$u_roles,true))){//перебираем роли. которые хотим запретить
$Who=in_array('administrator',$u_roles,true)?__('Администраторам','VAB'):__('Редакторам','VAB');
wp_die($Who.' '.__('авторизация запрещена','VAB'));//пишем месседж для них
}else{
return $user;
}
}
add_filter('authenticate','filter_function_name_4601',10,3);
function filter_function_name_4601($user,$username,$password){
if($username){
if(isset($username)){$user=get_user_by('login',$username);$user_data=get_object_vars($user);}
if(isset($user_data)){$userId=$user_data["ID"];$u_meta=get_userdata($userId);$u_roles=$u_meta->roles;}
}
if(!empty($u_roles)&&(in_array('administrator',$u_roles,true)||in_array('editor',$u_roles,true))){//перебираем роли. которые хотим запретить
$Who=in_array('administrator',$u_roles,true)?__('Администраторам','VAB'):__('Редакторам','VAB');
wp_die($Who.' '.__('авторизация запрещена','VAB'));//пишем месседж для них
}else{
return $user;
}
}