Jelajahi Sumber

Bumped version to 0.0.28

Jannick Knudsen 4 tahun lalu
induk
melakukan
ffd57fc33b
12 mengubah file dengan 88 tambahan dan 42 penghapusan
  1. 1 1
      VERSION
  2. 1 0
      VERSIONLOG
  3. 1 1
      package.json
  4. 1 1
      plug_admin_bar.php
  5. 1 1
      plug_body.php
  6. 1 1
      plug_login.php
  7. 2 2
      plug_update_plugin.php
  8. 37 6
      plug_usermanager.php
  9. 8 9
      plug_widgets.php
  10. 30 17
      plugin.php
  11. 3 3
      pluginoptions.php
  12. 2 0
      wpplugins.php

+ 1 - 1
VERSION

@@ -1 +1 @@
-v0.0.27
+v0.0.28

+ 1 - 0
VERSIONLOG

@@ -26,3 +26,4 @@ v0.0.24
 v0.0.25
 v0.0.26
 v0.0.27
+v0.0.28

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "dagsplug",
-  "version": "0.0.27",
+  "version": "0.0.28",
   "description": "",
   "main": "script_backend.js",
   "scripts": {

+ 1 - 1
plug_admin_bar.php

@@ -2,7 +2,7 @@
 
 if (!class_exists("plug_admin_bar")) {
 	class plug_admin_bar {
-		function plug_admin_bar($ns) {
+		function __construct($ns) {
 			$this->title = __("Admin bar","dagsopt");
 			$this->pluginname = $ns->pluginname;
 			$this->file = $ns->file;

+ 1 - 1
plug_body.php

@@ -3,7 +3,7 @@
 if (!class_exists("plug_body")) {
 	class plug_body {	
 		function plug_body($ns) {
-			$this->title = __("Admin bar","dagsopt");
+			$this->title = __("Body classes","dagsopt");
 			$this->pluginname = $ns->pluginname;
 			$this->file = $ns->file;
 			$this->ns = $ns;

+ 1 - 1
plug_login.php

@@ -11,7 +11,7 @@ if (!class_exists("plug_login")) {
 		function start() {
 
 			add_filter('login_headerurl',array(&$this,'login_headerurl'));
-			add_filter('login_headertitle',array(&$this,'login_headertitle'));
+			add_filter('login_headertext',array(&$this,'login_headertitle'));
 			add_filter('login_message',array(&$this,'login_message'));
 		}
 

+ 2 - 2
plug_update_plugin.php

@@ -2,7 +2,7 @@
 
 if (!class_exists("plug_update_plugin")) {
 	class plug_update_plugin {	
-		function plug_update_plugin($ns) {
+		function __construct($ns) {
 			$this->title = __("Update plugin","dagsopt");
 
 		$this->pluginname = $ns->pluginname;
@@ -14,7 +14,7 @@ if (!class_exists("plug_update_plugin")) {
 		register_activation_hook ( plugin_basename($this->file), array (	&$this, 'activatePlugin' ) );
 		register_deactivation_hook ( plugin_basename($this->file), array ( &$this, 'deactivatePlugin' ) );
 
-		add_action($ns->pluginname.'UpdateCheck', array(&$this,'check_update'));
+		add_action($this->pluginname.'UpdateCheck', array(&$this,'check_update'));
 		add_filter( 'http_request_args', array(&$this,'updates_exclude'), 5, 2 );
 		if(isset($_REQUEST["checkforupdates"])){
 			$this->check_update();

+ 37 - 6
plug_usermanager.php

@@ -35,10 +35,32 @@ if (!class_exists("plug_usermanager")) {
 	<?php		
 	}
 
-
  	function Option($pre){
- 
+		$nonce = $_REQUEST['_wpnonce'];
+		if ( ! wp_verify_nonce( $nonce, 'filen-nonce' ) ) {
+		    // This nonce is not valid.
+		    die( __( 'Security check', 'textdomain' ) ); 
+		} else {
+		    // The nonce was valid.
+		    // Do stuff here.
+		    if(isset($_FILES) && !empty($_FILES)){
+		    	if($_FILES['filen']){
+
+
+					$upload = wp_upload_dir();
+				    $upload_dir = $upload['basedir'];
+				    $upload_dir = $upload_dir . '/assets';
+					
+
+		    		move_uploaded_file($_FILES['filen']['tmp_name'], $upload_dir."/users.csv");
+
+
+		    	}
+			}
+
+		}
 
+ 		
 	}
 
   		/*<input id="link_image" value="test">
@@ -50,10 +72,19 @@ if (!class_exists("plug_usermanager")) {
 
 	 	function admin_line($pre){
   ?>
-  		<form action="plug_usermanager_submit" method="POST" accept-charset="utf-8">
-  			<input type="file" name="filen">
-  			<input type="Submit" value="Submit">
-  		</form>
+  	<?php
+  	$nonce = wp_create_nonce( 'filen-nonce' );
+	$upload = wp_upload_dir();
+    $upload_dir = $upload['basedir'];
+    $upload_dir = $upload_dir . '/assets';
+
+    $data = file_get_contents($upload_dir."/users.csv");
+
+?>
+	<textarea><?php echo($data); ?></textarea>	
+  	 
+	<input type="file" name="filen">
+	<input type="hidden" name="_wpnonce" value="<?php echo $nonce ?>">
 
 
 	  <?php  

+ 8 - 9
plug_widgets.php

@@ -2,7 +2,7 @@
 
 if (!class_exists("plug_widgets")) {
 	class plug_widgets {	
-		function plug_widgets($ns) {
+		function __construct($ns) {
 			$this->title = __("Fancy Widgets","dagsopt");
 			$this->pluginname = $ns->pluginname;
 			$this->file = $ns->file;
@@ -11,10 +11,9 @@ if (!class_exists("plug_widgets")) {
 		function start() {
 			if(get_option($this->pluginname."_widgets") == "on"){
 
-				add_action( 'widgets_init', create_function('', 'return register_widget("DisplayPageWidget");'		));
-				add_action( 'widgets_init', create_function('', 'return register_widget("dags_subpageswidget");' 	));
-				add_action( 'widgets_init', create_function('', 'return register_widget("DisplayPageChildrenWidget");'		));
-
+				add_action( 'widgets_init', function(){ return register_widget("DisplayPageWidget"); } );
+				add_action( 'widgets_init', function(){ return register_widget("dags_subpageswidget"); } );
+				add_action( 'widgets_init', function(){ return register_widget("DisplayPageChildrenWidget"); } );
 
 			}
 
@@ -49,10 +48,10 @@ if (!class_exists("plug_widgets")) {
 
 class DisplayPageChildrenWidget extends WP_Widget
 {
-  function DisplayPageChildrenWidget()
+  function __construct()
   {
     $widget_ops = array('classname' => 'DisplayPageChildrenWidget', 'description' => 'Show Page Children Widget' );
-    $this->WP_Widget('DisplayPageChildrenWidget', 'Page Children Widget', $widget_ops);
+    parent::__construct('DisplayPageChildrenWidget', 'Page Children Widget', $widget_ops);
   }
  
   function form($instance)
@@ -136,10 +135,10 @@ class DisplayPageChildrenWidget extends WP_Widget
 
 class DisplayPageWidget extends WP_Widget
 {
-  function DisplayPageWidget()
+  function __construct()
   {
     $widget_ops = array('classname' => 'DisplayPageWidget', 'description' => 'Show Page as Widget' );
-    $this->WP_Widget('DisplayPageWidget', 'Display Page Widget', $widget_ops);
+    parent::__construct('DisplayPageWidget', 'Display Page Widget', $widget_ops);
   }
  
   function form($instance)

+ 30 - 17
plugin.php

@@ -4,15 +4,20 @@
  Plugin URI: https://git.tum.dk/tum.dk/dagsplug/
  Description: Tools 
  Author: iskedk
- Version: 0.0.27
- Date: Fri Jan 31 2014 13:19:21 GMT+0100 (CET)
+ Version: 0.0.28
+ Date: 2021-01-14
  Author URI: https://iske.dk/
  Text Domain: dagsopt
  */
 
+function wppluginspage() {
+	include_once("wpplugins.php");
+}		
+
 $wp_dagsopt = new dagsopt ( );
+
 class dagsopt {
-	var $version = "0.0.27";
+	var $version = "0.0.28";
 	var $publish_date = "2021-01-14";
 	var $pluginname;
 	var $plugintitle;
@@ -56,6 +61,12 @@ class dagsopt {
 
 		add_action( 'admin_enqueue_scripts', array(&$this, 'print_backend_scripts_styles' ));
 
+		$upload = wp_upload_dir();
+	    $upload_dir = $upload['basedir'];
+	    $upload_dir = $upload_dir . '/assets';
+	    if (! is_dir($upload_dir)) {
+	       mkdir( $upload_dir, 0700 );
+	    }
 
  		$path = dirname($this->file)."/";
 		foreach (glob($path."plug_*.php") as $filename) {
@@ -74,11 +85,12 @@ class dagsopt {
 		}
 
 
-
+		if(!function_exists('wp_get_current_user')) {
+			include(ABSPATH . "wp-includes/pluggable.php"); 
+		}
 
 		if ( current_user_can( 'manage_options' ) ) {
-		add_action( 'wp_before_admin_bar_render', array(&$this, 'mytheme_admin_bar_render' )  );
-
+			add_action( 'wp_before_admin_bar_render', array(&$this, 'mytheme_admin_bar_render' )  );
 		}
 
 
@@ -89,7 +101,7 @@ class dagsopt {
 
 		function process_post() {
 			if (!is_admin()) {
-			    echo "<!-- kommer aller aller først -->";
+			   // echo "<!-- kommer aller aller først -->";
 			  }
 		}
 
@@ -143,8 +155,8 @@ class dagsopt {
 
 
 	function plugin_admin_menu() {
-		if(function_exists("wppluginspage")){
-			add_menu_page('WP Plugins Page', 'WP Plugins', 'manage_options', 'wpplugins', wppluginspage,"");
+		if(function_exists('wppluginspage')){
+			add_menu_page('WP Plugins Page', 'WP Plugins', 'manage_options', 'wpplugins', "wppluginspage","");
 		}
 		$page = 	add_submenu_page ( 'wpplugins', __ (  $this->plugintitle ), __ ( $this->plugintitle ), 'manage_options', $this->pluginname.'-options', array ( &$this,'Option' ) );
 		add_action( 'admin_print_styles-' . $page, array(&$this,'print_backend_scripts_styles') );
@@ -174,12 +186,9 @@ class dagsopt {
 	}
 
 	function Option() {
-		if(isset($_FILES)){
-			print_r($_FILES);
-			echo("OOOOOK");			
-		}
-
+		
 		if (isset ( $_POST [ 'Submit' ] )) {
+
 			if (function_exists ( 'current_user_can' ) && ! current_user_can ( 'manage_options' )) {
 				die ( __ ( 'Cheatin&#8217; uh?' ) );
 			}
@@ -194,6 +203,7 @@ class dagsopt {
 					$this->setCron();
 			}
 
+
 					update_option ( $this->pluginname.'_last_build', date("U") );
 
 	   foreach($this->dagsopt as $plugname => $plug){
@@ -207,6 +217,8 @@ class dagsopt {
 			}
 
 		}
+		 $pluginmessage ="";
+
 			ob_end_clean ();
 			wp_redirect ( 'admin.php?page='.$this->pluginname.'-options&msg=' . urlencode ( $pluginmessage ) );
 			exit ();
@@ -221,6 +233,9 @@ class dagsopt {
 	}
 
 	function activatePlugin() {
+
+	  
+
 		$this->check_wp_config();
 	}
 	function deactivatePlugin() {
@@ -244,9 +259,7 @@ class dagsopt {
 
 
 }
-function wppluginspage() {
-	include_once("wpplugins.php");
-}
+
 
 
 

+ 3 - 3
pluginoptions.php

@@ -15,7 +15,7 @@ Version: <?php echo($this->version); ?> <?php echo($this->publish_date); ?>
 
 <?php dags_extras(); ?></pre>
 <hr>	
-		<form method="post" action="">
+		<form method="post" action="" enctype="multipart/form-data">
 		<table class="form-table">
 		 
  			
@@ -28,7 +28,7 @@ Version: <?php echo($this->version); ?> <?php echo($this->publish_date); ?>
 			 
 			$short = str_replace("plug_","",$plugname);
 			$vis = get_option($this->pluginname.'_'.$short,true);
-			if($plug->hasform && !($plug->hasform && !$vis)){
+			if(isset($plug->hasform) && !($plug->hasform && !$vis)){
 				?>
 			 <tr valign="top">
 				<td width="120"><label for="<?php echo($this->pluginname) ?>_<?php echo($short); ?>"><?php echo(!empty($plug->title) ? $plug->title : $short); ?></label></td>
@@ -125,7 +125,7 @@ Version: <?php echo($this->version); ?> <?php echo($this->publish_date); ?>
 		 foreach($this->dagsopt as $plugname => $plug){
 			$short = str_replace("plug_","",$plugname);
 			$vis = get_option($this->pluginname.'_'.$short,true);
-			if($plug->hasform && $vis){
+			if(isset($plug->hasform) && $vis){
 			?>
 			 <tr valign="top">
 				<td width="120"><label for="<?php echo($this->pluginname) ?>_<?php echo($short); ?>"><?php echo($plug->title); ?></label></td>

+ 2 - 0
wpplugins.php

@@ -0,0 +1,2 @@
+
+<h1>Plugins</h1>