Created
March 21, 2023 08:50
-
-
Save dan-zakirov/3540dfd384bc5f40b9b8f24403207b3a 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 | |
/** | |
* Plugin Name: AIR VK Import XML | |
* Plugin URI: https://example.com/plugins/air-vk-import-xml/ | |
* Description: A plugin for importing XML data from VKontakte. | |
* Version: 1.0.0 | |
* Author: Your Name | |
* Author URI: https://example.com/ | |
* Text Domain: air-vk-import-xml | |
* Domain Path: /languages/ | |
* License: GPL-2.0+ | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt | |
*/ | |
// If this file is accessed directly, exit. | |
defined( 'ABSPATH' ) or exit; | |
// Define the plugin prefix. | |
define( 'AIR_VK_IMPORT_XML_PREFIX', 'air_vk_import_xml' ); | |
// Load plugin translations. | |
add_action( 'plugins_loaded', 'air_vk_import_xml_load_translations' ); | |
function air_vk_import_xml_load_translations() { | |
load_plugin_textdomain( 'air-vk-import-xml', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); | |
} | |
// Register activation and deactivation hooks. | |
register_activation_hook( __FILE__, 'air_vk_import_xml_activate' ); | |
register_deactivation_hook( __FILE__, 'air_vk_import_xml_deactivate' ); | |
// Define activation and deactivation functions. | |
function air_vk_import_xml_activate() { | |
// Code to execute on plugin activation. | |
} | |
function air_vk_import_xml_deactivate() { | |
// Code to execute on plugin deactivation. | |
} | |
// Define the plugin logic function. | |
function air_vk_import_xml() { | |
// Code to execute the plugin's logic. | |
} | |
// Add an admin menu item for the plugin's settings and display the settings link on the plugins page. | |
add_action( 'admin_menu', 'air_vk_import_xml_add_settings_menu_item' ); | |
function air_vk_import_xml_add_settings_menu_item() { | |
$settings_page_url = add_query_arg( | |
array( | |
'page' => 'air_vk_import_xml_settings', | |
), | |
admin_url( 'options-general.php' ) | |
); | |
add_options_page( | |
__( 'AIR VK Import XML Settings', 'air-vk-import-xml' ), | |
__( 'AIR VK Import XML', 'air-vk-import-xml' ), | |
'manage_options', | |
'air_vk_import_xml_settings', | |
'air_vk_import_xml_display_settings_page' | |
); | |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), function( $links ) use ( $settings_page_url ) { | |
$settings_link = sprintf( '<a href="%s">%s</a>', esc_url( $settings_page_url ), __( 'Settings', 'air-vk-import-xml' ) ); | |
array_unshift( $links, $settings_link ); | |
return $links; | |
} ); | |
} | |
// Define the plugin's settings page. | |
function air_vk_import_xml_display_settings_page() { | |
?> | |
<div class="wrap"> | |
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1> | |
<p><?php esc_html_e( 'Configure your AIR VK Import XML plugin settings below.', 'air-vk-import-xml' ); ?></p> | |
<form method="post" action="options.php"> | |
<?php | |
settings_fields( 'air_vk_import_xml_settings' ); | |
do_settings_sections( 'air_vk_import_xml_settings' ); | |
submit_button(); | |
?> | |
</form> | |
<h2><?php esc_html_e( 'Second Section', 'air-vk-import-xml' ); ?></h2> | |
<p><?php esc_html_e( 'This is some additional text for the settings page.', 'air-vk-import-xml' ); ?></p> | |
</div> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment