wo-xml饲料管理中的Wordpress按钮不起作用

时间:2016-10-24 08:21:47

标签: javascript php jquery wordpress

问题出现在插件'woocommerce xml feeds'中的wordpress管理控制台中。有按钮添加类别的参数。点击它时,此按钮不执行任何操作。

我试图联系插件的作者,他只告诉我检查调试控制台,但没有什么。他还告诉我,这个按钮的功能取决于jQuery。

这是按钮元素:

<span class="btn btn-danger btn-sm add-param" data-par="80">Přidat parametr</span>

上下文的整个PHP文件:

<?php
/**
 *
 * @package   woo_xml_feeds      
 * @author    Vladislav Musilek
 * @license   GPL-2.0+
 * @link      http://musilda.cz
 * @copyright 2014 Vladislav Musilek
 *
 * Version 1.0.0
 *  
 */


if(isset($_POST['update'])){

  //Save Heureka.sk Shipping values
  $this->save_heureka_delivery($name = 'woo_heureka_delivery');

  //Save Heureka.cz CPC value
  $this->save_single_option('heureka-cpc','heureka-cpc');




/**
 * Save Heureka category
 */  
  $heureka_assing_categories = get_option('woo_heureka_assing_categories');
    if(empty($heureka_assing_categories)){ $heureka_assing_categories = array(); }


  $heureka_excluded_categories = get_option( 'woo_heureka_excluded_categories');
    if(empty($heureka_excluded_categories)){ $heureka_excluded_categories = array(); }


  $heureka_categories_cpc = get_option( 'woo_heureka_categories_cpc');
    if(empty($heureka_categories_cpc)){ $heureka_categories_cpc = array(); }  



    foreach($_POST['termid'] as $key => $item){


    if(!empty($_POST['heurekaid'])){
    if(!empty($_POST['heurekaid'][$key])){
      $heureka_assing_categories[$_POST['termid'][$key]] = $_POST['heurekaid'][$key];
    }else{
      if(!empty($heureka_assing_categories[$_POST['termid'][$key]])){
         unset($heureka_assing_categories[$_POST['termid'][$key]]);
      }
    }
    }

    if(!empty($_POST['excluded'][$key])){
      $heureka_excluded_categories[$_POST['termid'][$key]] = $_POST['termid'][$key];
    }else{
      if(!empty($heureka_excluded_categories[$_POST['termid'][$key]])){
         unset($heureka_excluded_categories[$_POST['termid'][$key]]);
      }
    }


        if(!empty($_POST['termvar'][$key])){
          $heureka_categories_cpc[$_POST['termid'][$key]] = $_POST['category_cpc'][$key];
        }else{
          if(!empty($heureka_categories_cpc[$_POST['termid'][$key]])){
            unset($heureka_categories_cpc[$_POST['termid'][$key]]);
          }
        }




    }


  update_option( 'woo_heureka_assing_categories', $heureka_assing_categories );
  update_option( 'woo_heureka_excluded_categories', $heureka_excluded_categories );
  update_option( 'woo_heureka_categories_cpc', $heureka_categories_cpc );




  //Parametry pro kategorie
  $cat_params = get_option( 'woo_heureka_cat_params');
  if(empty($cat_params)){ $cat_params = array(); }

    foreach($_POST['termvar'] as $key => $item){

      $cat_params[$item]['term_id'] = $item;

      $cat_params[$item]['parametry'] = array();

      if(!empty($_POST['nazev_parametru_'.$item])){
        foreach($_POST['nazev_parametru_'.$item] as $lit => $var){

          $cat_params[$item]['parametry'][$lit]['nazev_parametru']   = $_POST['nazev_parametru_'.$item][$lit];
          $cat_params[$item]['parametry'][$lit]['hodnota_parametru'] = $_POST['hodnota_parametru_'.$item][$lit];

        }
      }
    }

  update_option( 'woo_heureka_cat_params', $cat_params );


  if(isset($_GET['catoffset'])){
    wp_redirect(admin_url().'admin.php?page=heureka-cz&catoffset='.$_GET['catoffset']);
  }else{
    wp_redirect(admin_url().'admin.php?page=heureka-cz');
  }

} 






$cat_params = get_option( 'woo_heureka_cat_params');
//Get heureka cz categories 
$heureka_categories          = get_option( 'woo_heureka_categories');
$heureka_assing_categories   = get_option( 'woo_heureka_assing_categories');
$heureka_excluded_categories = get_option( 'woo_heureka_excluded_categories');
$heureka_categories_cpc      = get_option( 'woo_heureka_categories_cpc');



$catTerms = get_terms('product_cat', array('hide_empty' => 0, 'orderby' => 'ASC')); 
$cat_list = custom_taxonomy_walker('product_cat');

$use_select2 = get_option( 'woo_xml_feed_use_select2' );

/**
 * Cat pagging
 *
 */  
$limit = 50;
if(isset($_GET['catoffset'])){
  $catstart = (($_GET['catoffset'] * $limit) - $limit)+1;
  $catend = $_GET['catoffset'] * $limit;
}else{ 
  $catstart = 1;
  $catend = $limit; 
} 

$i = 1;
$ii = 1;


?>




<div class="wrap">
    <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
<form method="post" action="">  


<?php
  //Include Heureka CPC table
  include('modules/heureka_cz_cpc.php');


  //Include Heureka Shipping table
  include('modules/heureka_cz_shipping.php');


  //Display category setting paggination
  echo tax_pagination($cat_list, 50); 


  ?>

<!-- Heureka kategorie -->
<div class="t-col-12">
    <div class="toret-box box-info">
      <div class="box-header">
        <h3 class="box-title"><?php _e('Přiřazení kategorií','woo-xml-feeds'); ?></h3>
      </div>
      <div class="box-body">
      <p><?php _e('Zde můžete přiřadit všechny kategorie ve vašem obchodu, k jednotlivým kategoriím Heuréky. Pokud máte v eshopu větší množství kategorií, buďte prosím trpěliví, načtení může chvíli trvat. Po rozkliknutí výběru Heuréka kategorie, můžete do řádku zapsat počáteční písmena hledané kategorie a použít našeptávač.','woo-xml-feeds'); ?></p>

      <p><?php _e('Pokud nechcete zobrazovat zboží z určité kategorie v XML feedu, zaškrtněte "Vyloučit kategorii".','woo-xml-feeds'); ?></p>


        <table class="table-bordered">
          <tr>
            <th><?php _e('Vyloučit kategorii', 'woo-xml-feeds'); ?></th>
            <th><?php _e('Kategorie obchodu', 'woo-xml-feeds'); ?></th>
            <th><?php _e('Kategorie na Heuréce', 'woo-xml-feeds'); ?></th>
            <th><?php _e('CPC kategorie', 'woo-xml-feeds'); ?></th>
          </tr>
   <?php 

   $catTerms = explode(',',$cat_list);
   $aa = 0; 
   foreach($catTerms as $c_item) : 
   if(!empty($c_item) && $i >= $catstart){
   if($i > $catend){ break; }
   ?>
    <tr>
        <td class="td_center"><input class="icheck_red" type="checkbox" name="excluded[<?php echo $aa; ?>]" <?php if(!empty($heureka_excluded_categories[$c_item])){ echo 'checked="checked"'; } ?> value="<?php echo $c_item; ?>" ></td>
        <td>
          <?php
          $aa++;
          $catTerm = get_term_by( 'id', $c_item, 'product_cat' );
          if(!empty($catTerm->parent)){
          $p_name = get_term_by( 'id', $catTerm->parent, 'product_cat' );
          echo $p_name->name.' >> ';

          } 

          ?> <?php echo $catTerm->name; ?>
          <input type="hidden" name="termid[]" value="<?php echo $catTerm->term_id; ?>" />
        </td>
        <td>
        <?php 
          if(!empty($use_select2) && $use_select2 == 'no'){}else{ 
        ?>
          <script>
            jQuery(document).ready(function() { jQuery("#heureka<?php echo $i; ?>").select2(); });
          </script>
        <?php } ?>  
        <style>#s2id_heureka<?php echo $i; ?>{min-width:800px;}</style>
          <select name="heurekaid[]" id="heureka<?php echo $i; ?>">
          <option value="default"></option>
            <?php
              foreach($heureka_categories as $key => $item){ 
              if(!empty($item['category_fullname'])){
              ?> 
            <option <?php if(!empty($heureka_assing_categories[$catTerm->term_id]) && $heureka_assing_categories[$catTerm->term_id]==$key){ echo 'selected="selected"'; }; ?>value="<?php echo $key; ?>"><?php echo $item['category_fullname']; ?></option>  
            <?php  }
            }
            ?>
          </select>
        </td>
        <td><input type="text" name="category_cpc[]" value="<?php if(!empty($heureka_categories_cpc[$c_item])){ echo $heureka_categories_cpc[$c_item]; } ?>" style="width:40px;" /></td>
    </tr>
   <?php 
   }
   $i++;
   endforeach; 
   ?> 
   </table>

      </div>
    </div>
  </div>

  <!-- Heureka kategorie parametry -->
  <div class="t-col-12">
    <div class="toret-box box-info">
      <div class="box-header">
        <h3 class="box-title"><?php _e('Vlastní parametry pro kategorie','woo-xml-feeds'); ?></h3>
      </div>
      <div class="box-body">
        <table class="table-bordered">
          <tr>
            <th><?php _e('Kategorie eshop', 'woo-xml-feeds'); ?></th>
            <th style="width:80%;"><?php _e('Vlastní parametry', 'woo-xml-feeds'); ?></th>
          </tr>
   <?php 
   $catTerms = explode(',',$cat_list);
   foreach($catTerms as $c_item) : 
   if(!empty($c_item) && $ii >= $catstart){
   if($ii > $catend){ break; }
   ?>
    <tr>
        <td>
          <?php
          $catTerm = get_term_by( 'id', $c_item, 'product_cat' );
          if(!empty($catTerm->parent)){
          $p_name = get_term_by( 'id', $catTerm->parent, 'product_cat' );
          echo $p_name->name.' >> ';

          } 

          ?> <?php echo $catTerm->name; ?>
          <input type="hidden" name="termvar[<?php echo $catTerm->term_id; ?>]" value="<?php echo $catTerm->term_id; ?>" />
        </td>
        <td class="category_params">
          <?php 
            if(!empty($cat_params[$catTerm->term_id]['parametry'])){
              foreach($cat_params[$catTerm->term_id]['parametry'] as $lit => $var){ ?>
                 <fieldset>
                  <input type="text" name="nazev_parametru_<?php echo $catTerm->term_id; ?>[]" placeholder="Název parametru" value="<?php echo $var['nazev_parametru']; ?>" />
                  <input type="text" name="hodnota_parametru_<?php echo $catTerm->term_id; ?>[]" placeholder="Hodnota parametru" value="<?php echo $var['hodnota_parametru']; ?>"/>
                  <span class="btn btn-danger btn-sm remove-param"><i class="fa fa-times"></i></span>
                 </fieldset>
            <?php }
            }
          ?>
          <div class="clear"></div>
          <span class="btn btn-danger btn-sm add-param"data-par="<?php echo $catTerm->term_id; ?>">Přidat parametr</span>
        </td>
    </tr>
   <?php 

   }
   $ii++;
   endforeach; 
   ?> 
        </table>
      <input type="hidden" name="update" value="ok" />
      <input type="submit" class="btn btn-lg btn-warning" value="<?php _e('Uložit nastavení','woo-xml-feeds'); ?>" />
      </div>
    </div>
  </div>       


</form>


</div>

我真的试图谷歌它我发现类似的问题,一些简单的建议,切换到默认主题或将define('CONCATENATE_SCRIPTS', false);放到wp-config.php。没有运气这些。

0 个答案:

没有答案