【问题标题】:Division by zero error in WordPress ThemeWordPress主题中除以零错误
【发布时间】:2011-10-03 19:12:53
【问题描述】:

我最近购买了一个 WordPress 主题,该主题可以展示精美的照片画廊,并且在主页上出现以下错误。

警告:第 36 行 /home/content/21/4913121/html/studios/wp-content/themes/dt-chocolate/front-gal.php 中除以零

警告:第 48 行 /home/content/21/4913121/html/studios/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';

【问题讨论】:

  • 要求退款。 Wordpress 主题要花钱?!
  • $w 预设为“默认”预期大小,因为如果未设置 $size,则未设置 $w,这会导致部分问题。
  • Themeforest 主题很吓人:“将 CHMOD 777 设置为文件夹“your_site/wp-content/themes/dt-chocolate/cache” 2) 必须创建文件夹“your_site/wp-content/uploads”并且CHMOD 设置为 777" 是的,对。你好,黑客,请黑我。
  • 我自己不是 Themeforest 的粉丝,但我丈夫喜欢他们的设计。它们确实有一些图形精美的主题,但绝对缺乏说明、功能和安全性。

标签: php wordpress


【解决方案1】:

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

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

和/或

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

但这些值可能不应该为零,因此可能还有其他问题。也许您的图片不是代码可读的格式……或者您还没有上传任何图片

【讨论】:

  • 谢谢伊恩。我也有同样的想法,但是在添加图像后,该站点可以正常工作,但是在图像加载时仍然首先显示错误消息。将尝试此添加。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多