function js_includer(){
wp_enqueue_script('js_functions', plugin_dir_url( __FILE__ ). '/js/functions.js');
wp_localize_script( 'js_functions', 'ajaxurl', admin_url( 'admin-ajax.php' ) );
}
add_action( 'admin_enqueue_scripts', 'js_includer' );
<?php
/*
Plugin Name: My Custom Pagination
Description: Плагин кастомной пагинации.
Author: Александр Соболев
Author URI: https://александрсоболев.рф
*/
// Подключение CSS - если захотите поменять стиль кнопочки и инпута
function cp_css_includer() {
wp_enqueue_style( 'cp_css_includer', plugin_dir_url( __FILE__ ). '/css/cp_style.css', false );
}
add_action( 'wp_head', 'cp_css_includer' );
// Подключение JS
function cp_js_includer(){
wp_enqueue_script('jquery');
wp_enqueue_script('cp_js_functions', plugin_dir_url( __FILE__ ). '/js/cp_functions.js');
wp_localize_script( 'cp_js_functions', 'ajaxurl', admin_url( 'admin-ajax.php' ) );
}
add_action( 'wp_enqueue_scripts', 'cp_js_includer' );
// Создаем форму и шот-код
function cp_form(){
return'<div class="cp"><form><input id="pc_input" type="text" placeholder="Куда пойдем ?"> <p id="pc_accept"></p></form></div>';
}
add_shortcode( 'cp_form', 'cp_form' );
?>
jQuery(document).ready(function() {
jQuery("#pc_accept").on("click",function(){
var _url_ = jQuery('#pc_input').val();
var url = "http://domen.ru/page/"+ _url_; // <- Тут " поменять домен "
window.location.href = url;
});
});
.cp {background: #f0fff6;}
.cp input {
width: 100%;
height: 42px;
padding-left: 10px;
border: 2px solid #7BA7AB;
border-radius: 2px;
outline: none;
background: #f0fff6;;
color: black;
}
.cp p {
position: absolute;
top: 0;
right: 0px;
width: 42px;
height: 42px;
border: none;
background: #7BA7AB;
border-radius: 0 5px 5px 0;
cursor: pointer;
}
.cp p:before {
padding-bottom: 4px;
padding-left: 4px;
content: "\f1b0";
font-family: FontAwesome;
font-size: 30px;
color: white;
}
<?php echo do_shortcode('[cp_form]'); ?>
function plugin_user_option_settings() {
global $plugin_option_page; // Страница опций
/* Cекция пользователей */
add_settings_section( 'plugin_user_section', 'Пользователи плагина', '', $plugin_option_page );
$plugin_users_field_params = array(
'type' => 'text', //может быть чекбоксы, селекты и т.д., взависимости от ТЗ
'id' => 'plugin_users',
'desc' => 'Пользователи с допуском к UI плагина. Укажите ID, или Ник',
'label_for' => 'Пользователи с допуском',
);
add_settings_field( 'plugin_user_section_', 'Пользователи системы', 'plugin_user_option_settings', $plugin_option_page, 'plugin_user_section', $plugin_users_field_params );
}
add_action( 'admin_init', 'now_open_option_settings' );
// Код написан в качестве примера. Нужны правки и доработки
add_settings_section( 'now_open_section_widgetcontent', 'Содержание Виджетов', '', $now_open_page );
$now_open_field_params = array(
'type' => 'textarea',
'id' => 'now_open_opentxt',
'desc' => 'Например: "Мы Ждем Вас по адресу: Красная пл., 1. Добро пожаловать! "',
'label_for' => 'Виджет "Рабочее время"',
);
add_settings_field( 'txt', 'Ваше приветствие ', 'now_open_option_display_settings', $now_open_page, 'now_open_section_widgetcontent', $now_open_field_params );
switch ( $type ) {
case 'textarea':
$o[$id] = esc_attr( stripslashes($o[$id]) );
echo "<textarea class='code large-text' cols='50' rows='5' type='text' id='$id' name='" . $option_name . "[$id]'>$o[$id]</textarea>";
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
break;
}