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 'test funkcji';
- }
- 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 ) {
- echo 'Test_01:<br>';
- function my_action_callback() {
- global $wpdb; // this is how you get access to the database
- $whatever = 10;
- return $whatever;
- exit();
- // die(); // this is required to terminate immediately and return a proper response
- }
- add_action( 'wp_ajax_nopriv_my_action', 'my_action_callback' );
- add_action( 'wp_ajax_my_action', 'my_action_callback' );
- echo my_action_callback();
- echo my_action_callback();
- ?>
- <script type="text/javascript" >
- var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
- jQuery(document).ready(function($) {
- console.log('START');
- var data = {
- 'action': 'my_action',
- 'whatever': 1234
- };
- // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
- $.post(ajaxurl, data, function(response) {
- console.log('Got this from the server: ' + response);
- });
- });
- </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