Advertisement
Guest User

Test 01

a guest
Oct 25th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 KB | None | 0 0
  1. <?php
  2. /*
  3.     Plugin Name: TEST PLUGIN
  4.     Description: TEST
  5.     Author: Krzysztof Kubiak
  6.     Version: 1.0
  7. */
  8. add_action('admin_init', 'Test_01_settings_init' );
  9. function Test_01_settings_init(){
  10.     register_setting( 'Test_01_settings_filed', 'Test_01_options', 'Test_01_validate' );
  11. }
  12. add_action('init', 'T01_init_method');
  13. function T01_init_method() {        
  14.     wp_enqueue_script('jquery');
  15.     wp_register_style( 'Test_01-style', plugins_url('css/style.css', __FILE__) );                
  16. }  
  17. add_action('admin_menu', 'Test_01_menu_page');
  18. function Test_01_menu_page(){
  19.     add_menu_page( 'Test_01', 'Test_01', 'manage_options', 'T01_menu_page', 'T01_add_page' );
  20.     echo my_test();
  21. }
  22. function my_test(){
  23.     echo 'Function test';
  24. }
  25. function T01_add_page() {
  26.     echo 'TEST_01_plugin';
  27. }
  28.  
  29. function Test_01_validate($input) {
  30. }  
  31.  
  32. class Test_01_shortcode_selector extends WP_Widget {
  33.     function __construct() {
  34.         parent::__construct(
  35.             'T01_widget', // Base ID
  36.             __('T01_WIDGET', 'text_domain'), // Name
  37.             array( 'description' => __( 'TEST WIDGET', 'text_domain' ), ) // Args
  38.         );
  39.     }
  40.     public function widget( $args, $instance ) {
  41.         wp_enqueue_script( 'jquery' );
  42.         echo 'Test_01:<br>';
  43.    
  44.         function test_callback() {
  45.             $whatever = 8;
  46.             echo $whatever;
  47.             die();
  48.         }
  49.         add_action( 'wp_ajax_nopriv_testaction', 'test_callback' );
  50.         add_action( 'wp_ajax_testaction', 'test_callback' );
  51. ?>
  52.         <script type="text/javascript" >
  53.             jQuery(document).ready(function($) {
  54.                 var data = {
  55.                     action: 'testaction'
  56.                 };
  57.  
  58.                 $.post(ajaxurl, data, function(ret2) {
  59.                     console.log('Got this from the server: ' + ret2);
  60.                 });
  61.             });
  62.         </script> <?php
  63.     }
  64.     public function form( $instance ) {
  65.         echo 'Widget';
  66.     }
  67.     public function update( $new_instance, $old_instance ) {
  68.         $instance = array();
  69.     }
  70. }
  71. add_action('widgets_init', 'register_Test_01_shortcode_selector');
  72. function register_Test_01_shortcode_selector() {
  73.     register_widget( 'Test_01_shortcode_selector' );
  74. }
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement