Advertisement
JcobV01

Untitled

May 16th, 2021 (edited)
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.73 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Plugin Name:         Nazwa
  5.  * Descrioption:        Wtyczka stworzona w celu wypisywania treści w danym dniu.
  6.  * Version:             0.1.0
  7.  * Requires at least:   5.0
  8.  * Requires PHP:        7.0
  9.  * Author:              Ja
  10.  * License:             GPL v2 or later
  11.  */
  12.  
  13. /*function tctnmpp_activation(){
  14.  
  15. }
  16.  
  17. function tctnmpp_deactivation(){
  18.  
  19. }
  20.  
  21. register_activation_hook(__FILE__ 'tctnmpp_activation');
  22. register_deactivation_hook(__FILE__ 'tctnmpp_deactivation');*/
  23.  
  24.  
  25. $baza = mysqli_connect('localhost','login','haslo','baza danych');
  26.  
  27. class tctnmpp_widget extends WP_Widget {
  28.  
  29.     public function __construct(){
  30.         add_action('widgets_init', array($this, 'tctnmpp_widget_init'));
  31.         $widget_details = array(
  32.             'classname' => 'tctnmpp_widget',
  33.             'description' => 'Widget, który na razie nic nie robi'
  34.         );
  35.         parent::__construct('tctnmpp_widget', 'TCTNMPP Widget', $widget_details);
  36.     }
  37.    
  38.     public function widget($args, $instance){
  39.         extract($args);
  40.         echo $before_widget
  41.             .$before_title
  42.             .$instance['title']
  43.             .$after_title;
  44.        
  45.         baza();
  46.        
  47.  
  48.        
  49.         echo $after_widget;
  50.     }
  51.  
  52.     public function update($new_instance, $old_instance) {
  53.         return $new_instance;
  54.  
  55.     }
  56.  
  57.     public function form($instance){
  58.         $title =esc_attr($instance['title']);
  59.         ?>
  60.         <p>
  61.             <label for="<?php echo $this->get_field_id('title'); ?>">
  62.             Tytuł:
  63.                 <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>">
  64.             </label>
  65.         </p>
  66.         <?php
  67.    
  68.     }  
  69.  
  70.     public function tctnmpp_widget_init(){
  71.         register_widget('tctnmpp_widget');
  72.     }
  73.  
  74.    
  75.        
  76. }
  77.  
  78. function baza(){
  79.    
  80.     $data = date("m-d");
  81.     $czas = date("H;i");
  82.  
  83.     if($data == "05-14"){
  84.         if (mysqli_connect_errno())
  85.         {
  86.             echo "Wystąpił błąd połączenia z bazą";
  87.         }
  88.                
  89.         $wynik = mysqli_query("SELECT*FROM `Czytania`", $baza);
  90.                    
  91.         while($row = mysqli_fetch_row($wynik)){
  92.             echo $row[1]."<br>";
  93.         }
  94.     }    
  95.     else if($data == "05-15"){
  96.         if (mysqli_connect_errno())
  97.         {
  98.             echo "Wystąpił błąd połączenia z bazą";
  99.         }
  100.                
  101.         $wynik = mysqli_query("SELECT*FROM `Czytania`", $baza);
  102.                    
  103.         while($row = mysqli_fetch_row($wynik)){
  104.             echo $row[2]."<br>";
  105.         }
  106.     }
  107.  
  108.    
  109. }
  110.  
  111.  
  112. $tctnmpp_widget = new tctnmpp_widget();
  113.  
  114.  
  115.    
  116. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement