Last active
June 20, 2019 12:26
-
-
Save amorkovin/ef8c32958d9702544732ac7f79bec6e3 to your computer and use it in GitHub Desktop.
Плагин WordPress заготовка начала
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 | |
/* | |
Plugin Name: Morkovin TOC Category | |
Description: Выводит содержания в рубриках | |
Author: Andrey Morkovin | |
Version: 1.1 | |
*/ | |
require 'mpurl-admin.php'; | |
А теперь в файле mpurl-admin.php пишу следующее. | |
<?php | |
namespace morkovinParcerUrl\mpurlAdmin; | |
add_action('admin_menu', '\morkovinParcerUrl\mpurlAdmin\plugin_create_menu'); | |
function plugin_create_menu() { | |
add_options_page('Парсер URL', 'Парсер URL', 'administrator', 'mpurl', '\morkovinParcerUrl\mpurlAdmin\admin_settings_page'); | |
add_action( 'admin_init', '\morkovinParcerUrl\mpurlAdmin\plugin_register_mysettings' ); | |
} | |
function plugin_register_mysettings() { | |
register_setting( 'morkovin_tc-settings-group', 'morkovin_tc_block_name' ); | |
register_setting( 'morkovin_tc-settings-group', 'morkovin_tc_min_count_title' ); | |
} | |
//Страница админки | |
function admin_settings_page() | |
{ ?> | |
<div class="wrap"> | |
<h2>Прасер URL</h2> | |
<form method="post" action="options.php"> | |
<?php settings_fields( 'morkovin_tc-settings-group' ); ?> | |
<table class="form-table"> | |
<tr valign="top"> | |
<th scope="row">ID рубрик, которые не нужно парсить (через запятую)</th> | |
<td><input type="text" name="morkovin_tc_block_name" value="<?php echo get_option('morkovin_tc_block_name'); ?>" /></td> | |
</tr> | |
<tr valign="top"> | |
<th scope="row">Минимальное количество h2</th> | |
<td><input type="text" name="morkovin_tc_min_count_title" value="<?php echo get_option('morkovin_tc_min_count_title'); ?>" /></td> | |
</tr> | |
</table> | |
<p class="submit"> | |
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> | |
</p> | |
</form> | |
</div><?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment