<?php
/*
Plugin Name: My Custom Login Redirect
Plugin URI: https://toster.ru/q/573536
Description: Плагин редиректа авторизации Wordpress-сайта
Version: 1.0
Author: Александр Соболев
Author URI: http://vk.com/san_jorich
License: GPL2
*/
/* Copyright 2018 SOBOLEV_ALEKSANDER (email : samigrai@mail.ru) */
function my_login_redirect( $url, $request, $user ){
if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
if( $user->has_cap( 'administrator') or $user->has_cap( 'author')) { $url = admin_url(); }
else { wp_redirect( home_url() ); }
}
}
add_filter('login_redirect', 'my_login_redirect', 10, 3 );
?>
wp_localize_script( 'ae_client_profilepage', 'forms_url', plugins_url('forms/clients/', __FILE__) );
в главном файле плагина, и в JS это стало работать через jQuery('#profile-page').empty().load(forms_url+'main_filter.php');
направить поток на физический выход ?
<?php
/*
Plugin Name: My Click Counter
Plugin URI: http://александрсоболев.рф
Description: Плагин-виджет, реализующий счетчик кликов
Author: Александр Соболев
Version: 1.1
Author URI: http://александрсоболев.рф
*/
function js_includer() { wp_register_script('my_click_counter', plugins_url('js/my_click_counter.js', __FILE__)); wp_enqueue_script('my_click_counter'); wp_localize_script( 'my_click_counter', 'ajaxurl', admin_url('admin-ajax.php') );}
function register_my_counter() { register_setting( 'my_click_counter', 'counter', 'intval' ); }
function count_plus(){$all_options = get_option('my_click_counter'); $count = intval($all_options['counter']); $new_val= ++$count;update_option( 'my_click_counter', $new_val ); wp_send_json($new_val); }
function show_counter(){get_option('my_click_counter'); $count = intval($all_options['counter']); $counter_div='<div id="my_counter_accept">Тест счечика.</div><div id="my_click_counter">'.$counter_div.'</div>';return $counter_div;} add_shortcode( 'show_counter', 'show_counter' );
add_action( 'admin_enqueue_scripts', 'js_includer' ); add_action( 'wp_enqueue_scripts', 'js_includer' ); add_action( 'admin_init', 'register_my_counter' ); add_action( 'wp_ajax_count_plus','count_plus' ); add_action( 'wp_ajax_nopriv_count_plus','count_plus' );
?>
jQuery(document).ready(function(){
jQuery('#my_counter_accept').on('click',function(){
jQuery.ajax({ type: "POST", url: ajaxurl, dataType: 'json', data: { action: 'count_plus'}, beforeSend: function(){jQuery('#my_counter_accept').remove(); }, success: function(new_val) { jQuery('#my_click_counter').append(new_val); console.log('Счетчик '+new_val); } });
})
});
<?php
/*
Plugin Name: Shipbuilding Post
Plugin URI: http://александрсоболев.рф/
Description: Плагин реализующий каталог кораблей на сайте
Version: 1.0
Author: Александр Соболев
Author URI: http://vk.com/san_jorich
License: GPL2
*/
/* Copyright 2018 SOBOLEV_ALEKSANDER (email : samigrai@mail.ru) */
function add_shipbuilding_post_type() {
$labels = array(
'name' => 'Корабли', // Склонение судно - коварная вещь :))
'singular_name' => 'Корабли',
'menu_name' => 'Каталог кораблей',
'name_admin_bar' => 'Каталог кораблей',
'archives' => 'Архив',
'attributes' => 'Аттрибуты',
'parent_item_colon' => 'Главный Корабль',
'all_items' => 'Все корабли',
'add_new_item' => 'Доавить новый',
'add_new' => 'Добавить корабль',
'new_item' => 'Новый корабль',
'edit_item' => 'Редактировать корабль',
'update_item' => 'Обновить корабль',
'view_item' => 'Смотреть корабль',
'view_items' => 'Смотреть корабли',
'search_items' => 'Найти',
'not_found' => 'Не найдено',
'not_found_in_trash' => 'В корзине не найдено',
'featured_image' => 'Featured Image',
'set_featured_image' => 'Установить фото корабля',
'remove_featured_image' => 'Удалить фото',
'use_featured_image' => 'Использовать в качестве фото анкеты',
'insert_into_item' => 'Добавить к анкете',
'uploaded_to_this_item' => 'Добавить к этому кораблю',
'items_list' => 'Список кораблей',
'items_list_navigation' => 'Items list navigation',
'filter_items_list' => 'Фильтр кораблей',
);
$rewrite = array(
'slug' => 'shipbuilding',
'with_front' => true,
'pages' => true,
'feeds' => true,
);
$args = array(
'label' => 'Корабли',
'description' => 'Корабли',
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions', 'custom-fields'),
'taxonomies' => array( 'ship_types' ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'query_var' => 'post_type',
'rewrite' => $rewrite,
'capability_type' => 'page',
);
register_post_type( 'shipbuilding', $args );
}
add_action( 'init', 'add_shipbuilding_post_type', 0 );
// Регистрация типов кораблей (estate_type)
function ship_types_taxonomy() {
$labels = array(
'name' => 'Тип',
'singular_name' => 'Тип корабля',
'menu_name' => 'Тип корабля',
'all_items' => 'Все типы',
'parent_item' => 'Родительский тип',
'parent_item_colon' => 'Parent Item:',
'new_item_name' => 'Название нового типа',
'add_new_item' => 'Добавить тип корабля',
'edit_item' => 'Редактировать тип',
'update_item' => 'Обновить тип',
'view_item' => 'Смотреть тип',
'separate_items_with_commas' => 'Добавление через запятую',
'add_or_remove_items' => 'Добавить или удалить тип',
'choose_from_most_used' => 'Выбрать из наиболее популярных',
'popular_items' => 'Популярные типы кораблей',
'search_items' => 'Найти тип',
'not_found' => 'Тип не найден',
'no_terms' => 'Типов нет.',
'items_list' => 'Список типов кораблей',
'items_list_navigation' => 'Items list navigation',
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_quick_edit' => true,
'meta_box_cb' => false,
);
register_taxonomy( 'ship_type', array( 'shipbuilding' ), $args );
}
add_action( 'init', 'ship_types_taxonomy', 0 );
?>