массовое редактирование метоки
добавить в пустое поле в графе метки- это разные задачи. Может как-то конкретнее ситуацию опишите?
<?php
/*
Plugin Name: My_Word
Plugin URI: https://toster.ru/q/572856
Description: Плагин делает всякие извращения с этим словом и выводит результат в нужном месте с помощью шорткода
Version: 1.0
Author: Александр Соболев
Author URI: http://vk.com/san_jorich
License: GPL2
*/
/* Copyright 2018 SOBOLEV_ALEKSANDER (email : samigrai@mail.ru) */
function mw_options() {
global $mw_page;
add_options_page( 'My Word Options', 'My Word Options', 'manage_options', $mw_page, 'mw_option_page');
}
add_action('admin_menu', 'mw_options');
function mw_option_page(){
global $mw_page;
?><div class="wrap">
<h2>My Word Option's Page</h2>
<form method="post" enctype="multipart/form-data" action="options.php">
<?php
settings_fields('mw_options');
do_settings_sections($mw_page);
?>
<p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
</form>
</div><?php
}
function mw_option_settings() {
global $mw_page;
register_setting( 'mw_options', 'mw_options', 'mw_validate_settings' );
add_settings_section( 'mw_section', 'Основные настройки', '', $mw_page );
$mw_field_params = array(
'type' => 'text',
'id' => 'my_word',
'desc' => 'Слово для манипуляций.',
'label_for' => 'my_word'
);
add_settings_field( 'my_text_field', 'Слово', 'mw_option_display_settings', $mw_page, 'mw_section', $mw_field_params );
}
add_action( 'admin_init', 'mw_option_settings' );
function mw_option_display_settings($args) {
extract( $args );
$option_name = 'mw_options';
$o = get_option( $option_name );
switch ( $type ) {
case 'text':
$o[$id] = esc_attr( stripslashes($o[$id]) );
echo "<input class='regular-text' type='text' id='$id' name='" . $option_name . "[$id]' value='$o[$id]' />";
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
break;
}
}
function mw_validate_settings($input){foreach($input as $k => $v) {$valid_input[$k] = trim($v);} return $valid_input;}
function view_manipulations(){
$mw_option = get_option('mw_options'); $result_div='<div id="mw_option">'.$mw_option['my_word'].'</div>';return $result_div;}
add_shortcode( 'mw_option', 'view_manipulations' );
?>
<a id="viewlink" path='https://domain.com/wp-admin/upload.php?item=". $file['ID']."'>Посмотреть файл</a>
jQuery('#viewlink').on('click',function(){
var path = jQuery(this).attr('path');
swal({ title: 'Файл',html: jQuery('<div>').text('<video scr="'+path+'"></video>); }) // Может быть что угодно. Зависит от типа файла
});
function my_register_settings() {
register_setting( 'my_theme_options', 'my_options', 'my_validate_options' );
}
add_action( 'admin_init', 'my_register_settings' );
if ( ! function_exists('add_estate_post_type') ) {
// Регистрируем тип недвижиимость
function add_estate_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' => 'estate',
'with_front' => true,
'pages' => true,
'feeds' => true,
);
$args = array(
'label' => 'Объект',
'description' => 'Post Type Description',
'labels' => $labels,
'supports' => array( 'title' ),
'taxonomies' => array( 'estate' ),
'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( 'estate', $args );
}
add_action( 'init', 'add_estate_post_type', 0 );
}
// Регистрация Районов (estate_district)
function estate_district_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( 'estate_district', array( 'estate' ), $args );
}
add_action( 'init', 'estate_district_taxonomy', 0 );