Jannick Knudsen 4 years ago
parent
commit
562afe8cab
4 changed files with 32 additions and 107 deletions
  1. 0 104
      plug_usermanager.php
  2. 29 1
      plugin.php
  3. 2 2
      pluginoptions.php
  4. 1 0
      style_backend.css

+ 0 - 104
plug_usermanager.php

@@ -1,104 +0,0 @@
-<?php
-
-if (!class_exists("plug_usermanager")) {
-	class plug_usermanager {	
-		function plug_usermanager($ns) {
-			$this->title = __("plug_usermanager","dagsopt");
-			$this->pluginname = $ns->pluginname;
-			$this->file = $ns->file;
-			$this->ns = $ns;
-
-		}
-		function start() {
-//			register_setting("section", "demo-file", array(&this,"handle_file_upload"));
-		
-		}
-
-		function handle_file_upload($option)
-		{
-		  	if(!empty($_FILES["demo-file"]["tmp_name"]))
-		    {
-		        $urls = wp_handle_upload($_FILES["demo-file"], array('test_form' => FALSE));
-		        $temp = $urls["url"];
-		        return $temp;   
-		    }
-
-		    return $option;
-		}
-
-		 
-
-
-	function help(){
-		?>
-		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">
-  		<img src="" id="background_image">
-
-		<a id="upload_image_button" href="#"><?php _e('Set image', 'dagsopt'); ?></a>
-		*/	
-
-
-	 	function admin_line($pre){
-  ?>
-  	<?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  
-}	
-}
-
-global $plug_usermanager;
-$plug_usermanager = new plug_usermanager($this);		
-	$this->dagsopt['plug_usermanager'] = $plug_usermanager;
-	
-}
-
-
-
-
-
-

+ 29 - 1
plugin.php

@@ -156,9 +156,13 @@ class dagsopt {
 
 	function plugin_admin_menu() {
 		if(function_exists('wppluginspage')){
-			add_menu_page('WP Plugins Page', 'WP Plugins', 'manage_options', 'wpplugins', "wppluginspage","");
+			add_menu_page('Dags Plugins', 'Dags 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') );
 	}
 	function SettingsLink( $links, $file ) {
@@ -215,13 +219,34 @@ class dagsopt {
 			if($vis && method_exists($plug,'Option')){
 			   $plug->Option($setname);
 			}
+		}
+		 $pluginmessage ="";
 
+			ob_end_clean ();
+			wp_redirect ( 'admin.php?page='.$this->pluginname.'-options&msg=' . urlencode ( $pluginmessage ) );
+			exit ();
 		}
+
+
+		if(isset( $_POST['Updateras'])){
 		 $pluginmessage ="";
 
+
+		foreach($this->dagsopt as $plugname => $plug){
+			$short = str_replace("plug_","",$plugname);
+			$setname = $this->pluginname.'_'.$short;
+			$vis = get_option($setname,true);
+			//update_option ($setname, $_POST[$setname] );
+
+			if($vis && method_exists($plug,'Updateras')){
+			   		 $pluginmessage .= $plug->Updateras($setname);
+			}
+		}
+
 			ob_end_clean ();
 			wp_redirect ( 'admin.php?page='.$this->pluginname.'-options&msg=' . urlencode ( $pluginmessage ) );
 			exit ();
+
 		}
 
 		include_once ('pluginoptions.php');
@@ -239,6 +264,9 @@ class dagsopt {
 		$this->check_wp_config();
 	}
 	function deactivatePlugin() {
+		delete_option($this->pluginname.'_last_build');
+		delete_option($this->pluginname.'_last_build');
+
 		wp_clear_scheduled_hook ( $this->pluginname.'CronHook' );
 	}
 

+ 2 - 2
pluginoptions.php

@@ -31,7 +31,7 @@ Version: <?php echo($this->version); ?> <?php echo($this->publish_date); ?>
 			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>
+				<td width="120"><label for="<?php echo($this->pluginname) ?>_<?php echo($short); ?>"><?php echo(!empty($plug->title) ? $plug->title : $short); ?></label> <?php echo($short);?></td>
 				<td width="30">
 					<input name="<?php echo($this->pluginname) ?>_<?php echo($short); ?>" type="checkbox" id="<?php echo($this->pluginname) ?>_<?php echo($short); ?>" <?php if($vis) echo 'checked'; ?> />
 				</td>
@@ -45,7 +45,7 @@ Version: <?php echo($this->version); ?> <?php echo($this->publish_date); ?>
 			}else{
 			?>
 			 <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>
+				<td width="120"><label for="<?php echo($this->pluginname) ?>_<?php echo($short); ?>"><?php echo(!empty($plug->title) ? $plug->title : $short); ?></label> ::<?php echo($short);?></td>
 				<td width="30">
 					<input name="<?php echo($this->pluginname) ?>_<?php echo($short); ?>" type="checkbox" id="<?php echo($this->pluginname) ?>_<?php echo($short); ?>" <?php if($vis) echo 'checked'; ?> />
 				</td>

+ 1 - 0
style_backend.css

@@ -1,6 +1,7 @@
 
 
 body {
+	background-color: #ff00ff;
 }