403Webshell
Server IP : 185.252.147.100  /  Your IP : 216.73.217.33
Web Server : nginx/1.27.3
System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
User : mitr ( 1000)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/html/metal.mitrofanov.ru/wordpress/wp-content/themes/generatepress_child/inc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/html/metal.mitrofanov.ru/wordpress/wp-content/themes/generatepress_child/inc/vacancy.php
<?php

defined('ABSPATH') || exit;


add_filter('use_block_editor_for_post_type', function($current_status, $post_type)
{
    if ($post_type === 'vacancy') return false;
    return $current_status;
}, 10, 2);


add_action( 'init', function() 
{

	$labels = [
		"name" => esc_html__( "Вакансии", "custom-post-type-ui" ),
		"singular_name" => esc_html__( "Вакансия", "custom-post-type-ui" ),
		"menu_name" => esc_html__( "Вакансии", "custom-post-type-ui" ),
		"all_items" => esc_html__( "Все Вакансии", "custom-post-type-ui" ),
		"add_new" => esc_html__( "Добавить Вакансию", "custom-post-type-ui" ),
		"add_new_item" => esc_html__( "Добавить Вакансию", "custom-post-type-ui" ),
		"edit_item" => esc_html__( "Редактировать Вакансию", "custom-post-type-ui" ),
		"new_item" => esc_html__( "Новая Вакансия", "custom-post-type-ui" ),
		"view_item" => esc_html__( "Просмотр Вакансии", "custom-post-type-ui" ),
		"view_items" => esc_html__( "Просмотр Вакансии", "custom-post-type-ui" ),
		"search_items" => esc_html__( "Поиск Вакансии", "custom-post-type-ui" ),
		"not_found" => esc_html__( "Вакансий не найдено", "custom-post-type-ui" ),
		"not_found_in_trash" => esc_html__( "Вакансий не найдено в корзине", "custom-post-type-ui" ),
		"parent" => esc_html__( "Родитель Вакансия:", "custom-post-type-ui" ),
		"featured_image" => esc_html__( "Фото Вакансии", "custom-post-type-ui" ),
		"set_featured_image" => esc_html__( "Установить Фото", "custom-post-type-ui" ),
		"remove_featured_image" => esc_html__( "Удалить фото Вакансии", "custom-post-type-ui" ),
		"use_featured_image" => esc_html__( "Использовать фото для этой Вакансии", "custom-post-type-ui" ),
		"archives" => esc_html__( "Архивы Вакансий", "custom-post-type-ui" ),
		"insert_into_item" => esc_html__( "Вставить в Вакансию", "custom-post-type-ui" ),
		"uploaded_to_this_item" => esc_html__( "Загрузить в эту Вакансию", "custom-post-type-ui" ),
		"filter_items_list" => esc_html__( "Фильтровать список Вакансий", "custom-post-type-ui" ),
		"items_list_navigation" => esc_html__( "Вакансии навигация по списку", "custom-post-type-ui" ),
		"items_list" => esc_html__( "Вакансии список", "custom-post-type-ui" ),
		"attributes" => esc_html__( "Вакансии атрибуты", "custom-post-type-ui" ),
		"name_admin_bar" => esc_html__( "Вакансию", "custom-post-type-ui" ),
		"item_published" => esc_html__( "Вакансия опубликована", "custom-post-type-ui" ),
		"item_published_privately" => esc_html__( "Вакансия опубликована приватно.", "custom-post-type-ui" ),
"item_reverted_to_draft" => esc_html__( "Вакансия преобразована в черновик.", "custom-post-type-ui" ),
		"item_trashed" => esc_html__( "Вакансия удалена.", "custom-post-type-ui" ),
		"item_scheduled" => esc_html__( "Вакансия запланирована", "custom-post-type-ui" ),
		"item_updated" => esc_html__( "Вакансия обновлёна.", "custom-post-type-ui" ),
		"parent_item_colon" => esc_html__( "Родитель Вакансия:", "custom-post-type-ui" ),
	];

	$args = [
		"label" => esc_html__( "Вакансии", "custom-post-type-ui" ),
		"labels" => $labels,
		"description" => "",
		"public" => true,
		"publicly_queryable" => true,
		"show_ui" => true,
		"show_in_rest" => true,
		"rest_base" => "",
		"rest_controller_class" => "WP_REST_Posts_Controller",
		"rest_namespace" => "wp/v2",
		"has_archive" => false,
		"show_in_menu" => true,
		"show_in_nav_menus" => true,
		"delete_with_user" => false,
		"exclude_from_search" => true,
		"capability_type" => "post",
		"map_meta_cap" => true,
		"hierarchical" => false,
		"can_export" => true,
		"rewrite" => [ "slug" => "vacancy", "with_front" => false ],
		"query_var" => true,
		"menu_position" => 5,
		"menu_icon" => "dashicons-businessman",
		"supports" => [ "title" ],
		"show_in_graphql" => false,
	];

	register_post_type( "vacancy", $args );
});




add_action( 'add_meta_boxes' , function() 
{

// Add the metabox with high priority
// 	remove_meta_box( 'postimagediv', 'vacancy', 'side' ); // Remove the metabox
    // add_meta_box(
    // 'postimagediv',
    // 'Фото вакансии',
    // 'post_thumbnail_meta_box',
    // 'vacancy',
    // 'side',
    // 'high'
    // ); 

	add_meta_box(
		'reward_metabox', // ID нашего метабокса
		'Зарплата по вакансии', // заголовок
		'reward_metabox_callback', // функция, которая будет выводить поля в мета боксе
		'vacancy', // типы постов, для которых его подключим
		'side', // расположение (normal, side, advanced)
		'high' // приоритет (default, low, high, core)
	);

	add_meta_box(
		'vac_excerpt_metabox', // ID нашего метабокса
		'Описание вакансии', // заголовок
		'vac_excerpt_metabox_callback', // функция, которая будет выводить поля в мета боксе
		'vacancy', // типы постов, для которых его подключим
		'normal', // расположение (normal, side, advanced)
		'default' // приоритет (default, low, high, core)
	);
	// метабокс рубрик
	//remove_meta_box( 'generate_layout_options_meta_box', 'post', 'side' );
	// метабокс отрывка записи
	//remove_meta_box( 'postexcerpt', 'post', 'normal' ); 
});

function reward_metabox_callback( $post ) {

	$vac_reward = get_post_meta( $post->ID, 'vac_reward', true );
 
	echo '<table class="form-table">
		<tbody>
			<tr>
				<td><input type="text" id="vac_reward" name="vac_reward" value="' . esc_attr( $vac_reward ) . '" style="width: 100%;"></td>
			</tr>
		</tbody>
	</table>';
 
}

function vac_excerpt_metabox_callback( $post ) {

	$vac_excerpt = get_post_meta( $post->ID, 'vac_excerpt', true );
	echo '<textarea rows="6" cols="40" name="vac_excerpt" id="vac_excerpt" style="width: 100%;font-size: 1.2rem;line-height: 1.5">' . esc_attr( $vac_excerpt ) . '</textarea><p>Краткое описание вакансии. Не более 40 слов. Одной строкой, без переносов.</p>';

}


add_action( 'save_post', function( $post_id, $post ) 
{
 
	// проверяем, может ли текущий юзер редактировать пост
	$post_type = get_post_type_object( $post->post_type );
 
	if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
		return $post_id;
	}
 
	// ничего не делаем для автосохранений
	if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
		return $post_id;
	}
 
	// проверяем тип записи
	if( 'vacancy' !== $post->post_type ) {
		return $post_id;
	}
 
	if( isset( $_POST[ 'vac_reward' ] ) ) {
		update_post_meta( $post_id, 'vac_reward', sanitize_text_field( $_POST[ 'vac_reward' ] ) );
	} else {
		delete_post_meta( $post_id, 'vac_reward' );
	}
	if( isset( $_POST[ 'vac_excerpt' ] ) ) {
		update_post_meta( $post_id, 'vac_excerpt', sanitize_text_field($_POST[ 'vac_excerpt' ]) );
	} else {
		delete_post_meta( $post_id, 'vac_excerpt' );
	}

	return $post_id;
 
}, 10, 2);



Youez - 2016 - github.com/yon3zu
LinuXploit