WordPress.org

Ready to get started?Download WordPress

Forums

How to get plugin to show up in dashboard? (1 post)

  1. tluskie
    Member
    Posted 4 years ago #

    I've had a simple content plugin for a while, but since upgrading to 2.8.5, I can no longer see it in my dashboard.

    The custom plugin still functions just fine, and the link to "Manage" it is still in my admin navigation. However, when I click the link to manage it, the page loads with nothing on it. The "frame" of the Admin dashboard is there, but none of the form fields or anything show up any more.

    I assume that something changed between versions on how this stuff gets called into the Admin interface.

    Any thoughts? Below is the code:

    <?php
    require_once('admin.php');
    $title = __('Posts');
    $parent_file = 'most-popular.php';
    require_once('admin-header.php');
    get_currentuserinfo();
    // Resizes the given image outputting a jpeg image
    function resizeImage($referenceImage, $thumbnail, $maxWidth, $maxHeight, $thumbnailJpegQuality=100) {
    
    	$getImageResource = getImageResource($referenceImage);
    
    	// Recompute size for fitting (to be validated)
    	if( $getImageResource[1] > $getImageResource[2]) { $maxHeight = round(($getImageResource[2]/$getImageResource[1])*$maxWidth); }
    	else { $maxWidth = round(($getImageResource[1]/$getImageResource[2])*$maxHeight); }
    
    	// Create resized image
    	$thumbnailResource = imagecreatetruecolor($maxWidth,$maxHeight);
    	//$mediumResource = imagecreatetruecolor(640,480);
    	imagecopyresampled($thumbnailResource, $getImageResource[0], 0, 0, 0, 0, $maxWidth, $maxHeight, $getImageResource[1], $getImageResource[2]);
    	@ImageJpeg($thumbnailResource, $thumbnail, 100);
    	//$medium_pic = ($referenceImagesDirectory . "bolGallery/medium_" . $referenceImageName);
    	//imagecopyresized($mediumResource, $getImageResource[0], 0, 0, 0, 0, $maxWidth, $maxHeight, $getImageResource[1], $getImageResource[2]);
    	//imagejpeg($mediumResource, $medium_pic, $thumbnailJpegQuality);
    
    	// Destroy image resources
    	imagedestroy($getImageResource[0]);
    	imagedestroy($thumbnailResource);
    	//imagedestroy($mediumResource);
    }
    function getImageResource($imageFile) {
    	// Get image info
    	$imageFileInfo = getimagesize($imageFile);
    	$dataArray[1] = $imageFileInfo[0];
    	$dataArray[2] = $imageFileInfo[1];
    
    	// Create a image resource
     	if ($imageFileInfo[2] == 1) { $imageFileResource = imagecreatefromgif($imageFile); }
    	if ($imageFileInfo[2] == 2) { $imageFileResource = imagecreatefromjpeg($imageFile); }
     	if ($imageFileInfo[2] == 3) { $imageFileResource = imagecreatefrompng($imageFile); }
    	$dataArray[0] = $imageFileResource;
    
    	return $dataArray;
    }
    // Creates a jpeg image sized as you want focusing randomly at a detail of the reference image
    function imageDetailExtract($referenceImage, $thumbnail, $thumbnailWidth, $thumbnailHeight, $thumbnailJpegQuality=100) {
    
    	$getImageResource = getImageResource($referenceImage);
    	// Method to display a image detail
    	// Coders : problems with little images (To get rid of it, set those two variables to 0)
    	// Coders : could be also enhanced so as to see more details
    	$Xposition = round(rand(0, ($getImageResource[1]-$thumbnailWidth)));
    	//$Yposition = round(rand(0, ($getImageResource[2]-$thumbnailHeight)));
    	$Yposition = 15;
    
    	// Create the detail image
    	$thumbnailResource = imagecreatetruecolor($thumbnailWidth,$thumbnailHeight);
    	imagecopy($thumbnailResource, $getImageResource[0], 0, 0, $Xposition, $Yposition, $getImageResource[1], $getImageResource[2]);
    	@ImageJpeg($thumbnailResource, $thumbnail, 100);
    	chmod($thumbnail,0777);
    
    	// Destroy image resources
    	imagedestroy($getImageResource[0]);
    	imagedestroy($thumbnailResource);
    }
    
    if ($_POST["button2"] != ""){
    $results2 = mysql_query ("SELECT * FROM most_popular");
    	while ($celebs = mysql_fetch_array ($results2)){
    	$id = $celebs["id"];
    	$rank = $celebs["rank"];
    	$new_rank = $_POST[$id];
    		if($_POST[$id]!=$rank){
    		$query="UPDATE most_popular SET rank=$new_rank WHERE id='$id'";
    		mysql_query($query);
    		}
    	}
    }
    if ($_GET["remove"] != ""){
    $id = $_GET["id"];
    $sql = "DELETE FROM most_popular WHERE id = ".$id."";
    mysql_query ($sql);
    header('Location: most-popular.php');
    }
    if($_POST["Submit"]!=""){
    $title = $_POST["title"];
    $url = $_POST["url"];
    $sql = "INSERT INTO most_popular SET
              title='$title',
    		  url='$url';
    		  ";
      if (@mysql_query($sql)) {
       $flagid = mysql_insert_id();
       		// Where the file is going to be placed
    		$referenceImagesDirectory = "../most_popular/";
    
    		$large = $referenceImagesDirectory . $flagid.".jpg"; 
    
    		$_FILES['uploadedfile']['tmp_name'];  
    
    		if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $large)) {
    			//echo "The file ".  $flagid . ".jpg" . " has been uploaded";
    		$referenceImageName = $flagid.".jpg";
    		//$currentImage = "../most_popular/".$referenceImageName;
    		$medium = ($referenceImagesDirectory . "medium_" . $referenceImageName);
    		$thumbnail = ($referenceImagesDirectory . "thumbnail_" . $referenceImageName);
    		resizeImage($large, $medium, 240, 180, 100);
    		 $thumbnailWidth = 113;
    		 $thumbnailHeight = 137;
    		imageDetailExtract($medium, $thumbnail, $thumbnailWidth, $thumbnailHeight, 100);
    		chmod($medium,0777);
    		} else{
    			echo "There was an error uploading the file, please try again!";
    		}
    
       //echo "<p>Added to database: ";
      } else {
        echo("<p>Error adding client: " .
             mysql_error() . "</p>");
      }
    }
    
    $results = mysql_query ("SELECT * FROM most_popular order by id desc");
    ?>
    
    <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
      <table width="441" cellpadding="0" cellspacing="6" class="editform">
        <tr>
          <td height="30" colspan="2" bgcolor="#CCCCCC">&nbsp;Add Hot Gossip</td>
        </tr>
        <tr>
          <td>&nbsp;Title</td>
          <td><input type="text" name="title" id="title" /></td>
        </tr>
        <tr>
          <td>URL</td>
          <td><input type="text" name="url" id="url" /></td>
        </tr>
        <tr>
          <td>&nbsp;Upload</td>
          <td><input type="file" name="uploadedfile" id="uploadedfile" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input type="submit" name="Submit" id="button" value="Submit" />
          <input type="hidden" name="MAX_FILE_SIZE" value="100000" /></td>
        </tr>
      </table>
    </form>
    <p>
    
    <form id="form2" name="form2" method="post" action="">
      <table width="713" cellspacing="6">
    
    	<?
    while ($thumbs = mysql_fetch_array ($results)){
    ?>
        <tr>
          <td width="100"><a href="<?=$thumbs["url"];?>" target="_blank"><img src="../most_popular/thumbnail_<?=$thumbs["id"];?>.jpg" border="0" /></a></td>
          <td width="271">&nbsp;<a href="<?=$thumbs["url"];?>" target="_blank">
            <?=$thumbs["title"];?>
          </a></td>
          <td width="147"><div align="center"><a href="?remove=yes&id=<?=$thumbs["id"];?>">remove</a></div></td>
        </tr>
        <tr>
          <td height="1" colspan="3" bgcolor="#CCCCCC"></td>
        </tr>
        <?
    }
    ?>
      </table>
    </form>
    </p>
    <?php
     include('../admin-footer.php');
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic