Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: TEST PLUGIN
- Description: TEST
- Author: Krzysztof Kubiak
- Version: 1.0
- */
- add_action('admin_init', 'Test_01_settings_init' );
- function Test_01_settings_init(){
- register_setting( 'Test_01_settings_filed', 'Test_01_options', 'Test_01_validate' );
- }
- add_action('init', 'T01_init_method');
- function T01_init_method() {
- wp_enqueue_script('jquery');
- wp_register_style( 'Test_01-style', plugins_url('css/style.css', __FILE__) );
- }
- add_action('admin_menu', 'Test_01_menu_page');
- function Test_01_menu_page(){
- add_menu_page( 'Test_01', 'Test_01', 'manage_options', 'T01_menu_page', 'T01_add_page' );
- echo my_test();
- }
- function my_test(){
- echo 'Function test';
- }
- function T01_add_page() {
- echo 'TEST_01_plugin';
- }
- function Test_01_validate($input) {
- }
- class Test_01_shortcode_selector extends WP_Widget {
- function __construct() {
- parent::__construct(
- 'T01_widget', // Base ID
- __('T01_WIDGET', 'text_domain'), // Name
- array( 'description' => __( 'TEST WIDGET', 'text_domain' ), ) // Args
- );
- }
- public function widget( $args, $instance ) {
- wp_enqueue_script( 'jquery' );
- echo 'Test_01:<br>';
- function test_callback() {
- $whatever = 8;
- echo $whatever;
- die();
- }
- add_action( 'wp_ajax_nopriv_testaction', 'test_callback' );
- add_action( 'wp_ajax_testaction', 'test_callback' );
- ?>
- <script type="text/javascript" >
- jQuery(document).ready(function($) {
- var data = {
- action: 'testaction'
- };
- $.post(ajaxurl, data, function(ret2) {
- console.log('Got this from the server: ' + ret2);
- });
- });
- </script> <?php
- }
- public function form( $instance ) {
- echo 'Widget';
- }
- public function update( $new_instance, $old_instance ) {
- $instance = array();
- }
- }
- add_action('widgets_init', 'register_Test_01_shortcode_selector');
- function register_Test_01_shortcode_selector() {
- register_widget( 'Test_01_shortcode_selector' );
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement