在WordPress主题中由零误差划分

我最近买了一个WordPress主题,用来做一个精美的画廊展示照片,并且它已经在主页上发现了以下错误。

警告:在第36行的/home/content/21/4913121/html/stsudios/wp-content/themes/dt-chocolate/front-gal.php中用零分区

警告:在48行/home/content/21/4913121/html/stsudios/wp-content/themes/dt-chocolate/front-gal.php上划分零

以下是通过第50行的代码 - 带/**/的行是故障行。 任何帮助表示赞赏!

<?php

global $postgallery;
$show = $postgallery->get_post_option('show');
$arr = $postgallery->get_post_option('show_'.$show);
$arr = explode(",", $arr);
$arr = (array)$arr;

//$myterms = get_terms('dt_gallery_cat');
$myterms = apply_filters( 'taxonomy-images-get-terms', '', array('taxonomy'=> 'dt_gallery_cat'));

$images = array();

global $term, $h;

foreach ($myterms as $term)
{

   if ($show == "all")
   {

   }
   elseif ($show == "only")
   {
      if ( !in_array( $term->term_id, $arr ) )
         continue;
   }
   elseif ($show == "except")
   {
      if ( in_array( $term->term_id, $arr ) )
         continue;
   }

   $term->pic = wp_get_attachment_image_src( $term->image_id, 'full' );

   $k = $term->pic[1] / $term->pic[2];

   /**/$term->pic = $term->pic[0];/**/

   $size = taxonomy_get_size( $term->term_id );
   if ($size == "s")
      $w = 220;
   if ($size == "m")
      $w = 460;
   if ($size == "l")
      $w = 700;

   /**/$h = ceil($w / $k);/**/

   $term->pic = get_template_directory_uri().'/thumb.php?src='.$term->pic.'&amp;w='.$w.'&amp;h='.$h.'&amp;zc=1';

如果你添加一些代码来检查这些值是否为零,它应该停止这样做,但可能会有更大的问题。

if ( $term->pic[1] == 0 || $term->pic[2] == 0 ) return

和/或

$h = ( $w > 0 && $k > 0 ) ? ceil($w / $k) : 0;

这些值可能不应该是零,所以有可能出现其他问题。 也许你的图像没有可以被代码读取的格式......或者你还没有上传任何图像

链接地址: http://www.djcxy.com/p/11897.html

上一篇: Division by zero error in WordPress Theme

下一篇: Warning: Division By Zero Working on PHP and MySQL