Last active
August 29, 2015 14:09
-
-
Save topwebmaster/433747c4b32150208cf7 to your computer and use it in GitHub Desktop.
Разное
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'init', 'create_team_contacts' ); | |
function create_team_contacts() { | |
register_post_type( 'team_contacts', | |
array( | |
'labels' => array( | |
'name' => 'Команда сайта', | |
'singular_name' => 'Контакт команды', | |
'add_new' => 'Добавить новый', | |
'add_new_item' => 'Добавить новый контакт', | |
'edit' => 'Редактировать', | |
'edit_item' => 'Редактировать контакт', | |
'new_item' => 'Новый контакт', | |
'view' => 'Просмотр', | |
'view_item' => 'Посмотреть контакт', | |
'search_items' => 'Поиск в контактах', | |
'not_found' => 'Контакты не найдены', | |
'not_found_in_trash' => 'В корзине контакты не найдены', | |
), | |
'public' => true, | |
'publicly_queryable' => true, | |
'exclude_from_search' => true, | |
'show_ui' => true, | |
'menu_position' => 10, | |
'supports' => array( 'title', 'thumbnail' ), | |
'taxonomies' => array( '' ), | |
//'menu_icon' => plugins_url( 'images/image.png', __FILE__ ), | |
) | |
); | |
} | |
add_action( 'admin_init', 'team_contacts_metaboxes' ); | |
function team_contacts_metaboxes() { | |
add_meta_box( 'team_contacts_meta_box', | |
'Параметры контакта', | |
'display_team_contacts_meta_box', | |
'team_contacts', 'normal', 'high' | |
); | |
} | |
function check_for_trust_id($items_id_c, $team_s_trust){//проверка существует ли ответсвенность у пользователя | |
foreach($team_s_trust as $k){ | |
if($k == $items_id_c){ | |
return "checked"; | |
} | |
} | |
} | |
function display_team_contacts_meta_box( $team_contacts ) { | |
$team_s_city = esc_html( get_post_meta( $team_contacts->ID, 'team_s_city', true ) ); | |
$team_s_email = esc_html( get_post_meta( $team_contacts->ID, 'team_s_email', true ) ); | |
$team_s_birth = esc_html( get_post_meta( $team_contacts->ID, 'team_s_birth', true ) ); | |
$team_s_phone = esc_html( get_post_meta( $team_contacts->ID, 'team_s_phone', true ) ); | |
$team_s_skype = esc_html( get_post_meta( $team_contacts->ID, 'team_s_skype', true ) ); | |
$team_s_service = esc_html( get_post_meta( $team_contacts->ID, 'team_s_service', true) ); | |
$team_s_trust = get_post_meta($team_contacts->ID, 'team_s_trust', true); //получает массив значение произвольного поля team_s_trust | |
?> | |
<table style="width:700px;"> | |
<tr> | |
<td style="width: 150px">Город</td> | |
<td><input type="text" size="40" name="team_s_city_page" value="<?php echo $team_s_city; ?>" /></td> | |
</td> | |
</tr> | |
<tr> | |
<td>Email</td> | |
<td><input type="text" size="40" name="team_s_email_page" value="<?php echo $team_s_email; ?>" /></td> | |
</td> | |
</tr> | |
<tr> | |
<td>Год рождения</td> | |
<td><input type="text" size="40" name="team_s_birth_page" value="<?php echo $team_s_birth; ?>" /></td> | |
</td> | |
</tr> | |
<tr> | |
<td>Телефон</td> | |
<td><input type="text" size="40" name="team_s_phone_page" value="<?php echo $team_s_phone; ?>" /></td> | |
</td> | |
</tr> | |
<tr> | |
<td>Скайп</td> | |
<td><input type="text" size="40" name="team_s_skype_page" value="<?php echo $team_s_skype; ?>" /></td> | |
</td> | |
</tr> | |
<tr> | |
<td>Служение на сайте</td> | |
<td><input type="text" size="40" name="team_s_service_page" value="<?php echo $team_s_service; ?>" /></td> | |
</tr> | |
</tr> | |
</table> | |
<--! !!!!!!!!!!!!!!!!!!!!!!!!! --> | |
<div class="trust"> | |
<?php | |
/** | |
* | |
* в этом блоке вывожу список ответственности в админку, за основу для пунктов ответственности беру пункты меню, | |
* так как мне надо выводить на сайте ответственного за разделы, разделы магазина, страницы. | |
* Сами чекбоксы это пункты главного меню, привязка идет к идентификаторам меню, как эти идентификаторы поймать на фронтенде? | |
* | |
* | |
* Задача в том чтобы на фронтенде в каждом разделе/категории/теге/страницы (иначе | |
* говоря независимо от того какая таксономия выбрана для текущего пункта меню, выводился отмеченный пользователь.) | |
* Списко команды сайта сделан допополнительным типом материалов, тоесть пользователь это отдельный материал - команда сайта, | |
* и никак не связан с реальными пользователя. | |
* | |
*/?> | |
<h1>Ответсвенность за:</h1> | |
<?php | |
$item_trusts = wp_get_nav_menu_items('Главное меню'); | |
foreach($item_trusts as $key => $item_trust):?> | |
<?php | |
$id = $item_trust->ID; | |
$title = $item_trust->title; | |
$checker = check_for_trust_id($id, $team_s_trust); | |
?> | |
<label for="<?=$id?>"><?=$title?></label> | |
<input type="checkbox" name="team_s_trust_checker[]" value="<?=$id?> id="<?=$id?>" <?=$checker;?>> | |
<? endforeach; ?> | |
<? //$item_trusts;?> | |
</div> | |
<?php | |
} | |
//function get_current_menu_info(){ | |
//$queried_object = get_queried_object(); | |
//$term_id = $queried_object->term_id; | |
//$taxonomy = $queried_object->taxonomy; | |
//$locations = get_nav_menu_locations(); | |
//$result = wp_get_nav_menu_items($menu->term_id); | |
//print_r($result); | |
} | |
function get_current_post_taxonomies(){ | |
global $post; | |
$taxonomy_names = get_object_taxonomies( $post ); | |
print_r( $taxonomy_names ); | |
} | |
add_action('wp_head','get_current_post_taxonomies'); | |
//function display_trust_check($current_page_id){ | |
//$item_id = wp_get_ | |
//if($current_place_id == $item_id){ | |
//} | |
//} | |
add_action( 'save_post', 'add_team_contacts_fields', 10, 8 ); | |
function add_team_contacts_fields( $team_contacts_id, $team_contacts ) { | |
if ( $team_contacts->post_type == 'team_contacts' ) { | |
if ( isset( $_POST['team_s_city_page'] ) && $_POST['team_s_city_page'] != '' ) { | |
update_post_meta( $team_contacts_id, 'team_s_city', $_POST['team_s_city_page'] ); | |
} | |
if ( isset( $_POST['team_s_email_page'] ) && $_POST['team_s_email_page'] != '' ) { | |
update_post_meta( $team_contacts_id, 'team_s_email', $_POST['team_s_email_page'] ); | |
} | |
if ( isset( $_POST['team_s_birth_page'] ) && $_POST['team_s_birth_page'] != '' ) { | |
update_post_meta( $team_contacts_id, 'team_s_birth', $_POST['team_s_birth_page'] ); | |
} | |
if ( isset( $_POST['team_s_phone_page'] ) && $_POST['team_s_phone_page'] != '' ) { | |
update_post_meta( $team_contacts_id, 'team_s_phone', $_POST['team_s_phone_page'] ); | |
} | |
if ( isset( $_POST['team_s_skype_page'] ) && $_POST['team_s_skype_page'] != '' ) { | |
update_post_meta( $team_contacts_id, 'team_s_skype', $_POST['team_s_skype_page'] ); | |
} | |
if ( isset( $_POST['team_s_service_page'] ) && $_POST['team_s_service_page'] != '' ) { | |
update_post_meta( $team_contacts_id, 'team_s_service', $_POST['team_s_service_page'] ); | |
} | |
if(isset($_POST['team_s_trust_checker'])&& $_POST['team_s_trust_checker'] != ''){ | |
update_post_meta($team_contacts_id, 'team_s_trust', $_POST['team_s_trust_checker']); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment