2013-04-25 2 views
0

У меня есть php-страница, которую я написал в Wordpress, которая должна получить некоторую информацию из базы данных и отобразить ее на странице. Я пытаюсь добавить возможность обновлять информацию непосредственно со страницы, и что-то вроде бы удаляет мой первый тег формы, но не другие. Кто-нибудь когда-либо видел что-то подобное или, может быть, знал что-то, что потенциально могло бы произойти?Wordpress admin page stripping form tags

Вот PHP

function display_terms_by_brand() 
{ 
global $wpdb; 
$sql = "SELECT * FROM ".NINJA_FORMS_TERMS_TEXT; 
$terms = $wpdb->get_results($sql, ARRAY_A); 
?> 

<script type="text/javascript"> 
    jQuery(document).ready(function(){ 
     jQuery('.edit').click(function(){ 
      jQuery(this).parent().find('.edit').css('display' , 'none') 
      jQuery(this).parent().find('.save').css('display' , 'block') 
      jQuery(this).parent().siblings('span[id*=brand_text_]').children('span').toggle(); 
      jQuery(this).parent().siblings('span[id*=brand_text_]').children('textarea').toggle(); 
     }); 
    }) 
</script> 

<div id="termsHeader" style="font-weight:bold; font-size:16px; padding:10px 0; height:30px; min-width:600px;"> 
    <span style="width:10%; text-align:center; float:left; padding:0 30px;">Brand</span> 
    <span style="width:67%; text-align:center; float:left;">Text</span> 
    <span style="width:9%; text-align:center; float:right; padding:0 15px;">Edit/Save</span> 
</div> 

<div style="clear:both;"><!-- --></div> 
<hr /> 

<?php 
foreach($terms as $curr_term) { 
?> 

    <div style="width:100%; padding:20px 0; min-width:600px;" class="term"> 
     <span style="width:10%; height:50px; padding:30px; float:left; text-align:center;" id="brand_name_<?php echo $curr_term['text_id'] ?>"> 
      <?php echo $curr_term['brand_name'] ?> 
     </span> 
     <span style="width:67%; height:50px; padding:30px 10px; float:left;" id="brand_text_<?php echo $curr_term['text_id'] ?>"> 
      <span> <?php echo stripslashes($curr_term['brand_text']) ?> </span> 
      <textarea style="display:none; width:100%;"><?php echo stripslashes($curr_term['brand_text']) ?></textarea> 
     </span> 
     <span style="width:12%; height:50px; padding:30px 10px; float:right;"> 
      <form action="/wp-admin/admin.php?page=ninja-forms-extend" method="post" name="edit_<?php echo $curr_term['text_id'] ?>" id="edit_<?php echo $curr_term['text_id'] ?>"> 
       <input name="brand_name" type="hidden" value="<?php echo $curr_term['brand_name'] ?>" /> 
       <textarea name="brand_text" style="display:none;">TEST</textarea> 
       <input class="termsEditButton termsButtons edit" style="width:150px; margin:0 auto; display:block;" name="edit" type="button" value="Edit Optin Statement" /> 
       <input class="termsSaveButton termsButtons save" style="width:150px; margin:0 auto; display:none;" name="save" type="button" value="Save Optin Statement" /> 
       <input class="termsDeleteButton termsButtons delete" style="width:150px; margin:0 auto; display:block;" name="delete" type="button" value="Delete Optin Statement" /> 
      </form> 
     </span> 
    </div> 

    <div style="clear:both;"><!-- --></div> 
<?php 
} 
?> 


<hr /> 
<h2>Add New Terms text</h2> 
<form action="<?php echo $_SERVER['PHP_SELF'] ?>?page=ninja-forms-extend" method="post" name="add_new_term_text" id="add_new_term_text"> 
    <label style="float:left;width:50px;clear:left;font-weight:bold">Brand</label><input name="brand_name" type="text" size="38" />&nbsp;&nbsp;(This will be the shortcode to display the text)<br /> 
    <label style="float:left;width:50px;clear:left;font-weight:bold">Text</label><textarea name="brand_text" cols="35" rows="5"></textarea><br /> 
    <input name="submit" type="submit" value="Add New Terms Text" /> 
</form> 
<?php 
return; 
} 

и результирующий HTML для первого прохода через петлю это:

<div style="width:100%; padding:20px 0; min-width:600px;" class="term"> 
     <span style="width:10%; height:50px; padding:30px; float:left; text-align:center;" id="brand_name_1"> 
      caprizehouse   </span> 
     <span style="width:67%; height:50px; padding:30px 10px; float:left;" id="brand_text_1"> 
      <span> I certify that I am a resident of Canada over the age of 18, I agree to the <a href="http://coreg.intela.com/media/ca-prizehouse/privacypolicy.htm" class="fancylink" target="_blank">Privacy Policy</a> and <a href="http://coreg.intela.com/media/ca-prizehouse/terms.htm" class="fancylink" target="_blank">Terms and Conditions</a>, and I would like to receive the Canadian Prize House newsletter. </span> 
      <textarea style="display:none; width:100%;">I certify that I am a resident of Canada over the age of 18, I agree to the &lt;a href="http://coreg.intela.com/media/ca-prizehouse/privacypolicy.htm" class="fancylink" target="_blank"&gt;Privacy Policy&lt;/a&gt; and &lt;a href="http://coreg.intela.com/media/ca-prizehouse/terms.htm" class="fancylink" target = "_blank"&gt;Terms and Conditions&lt;/a&gt;, and I would like to receive the Canadian Prize House newsletter.</textarea> 
     </span> 
     <span style="width:12%; height:50px; padding:30px 10px; float:right;"> 

       <input name="brand_name" type="hidden" value="caprizehouse"> 
       <textarea name="brand_text" style="display:none;">TEST</textarea> 
       <input class="termsEditButton termsButtons edit" style="width:150px; margin:0 auto; display:block;" name="edit" type="button" value="Edit Optin Statement"> 
       <input class="termsSaveButton termsButtons save" style="width:150px; margin:0 auto; display:none;" name="save" type="button" value="Save Optin Statement"> 
       <input class="termsDeleteButton termsButtons delete" style="width:150px; margin:0 auto; display:block;" name="delete" type="button" value="Delete Optin Statement"> 

     </span> 
    </div> 

Обратите внимание, как отсутствует форма тега. Из двух других проходов через петлю Это HTML выход на странице:

<div style="width:100%; padding:20px 0; min-width:600px;" class="term"> 
     <span style="width:10%; height:50px; padding:30px; float:left; text-align:center;" id="brand_name_2"> 
      canadianprizes   </span> 
     <span style="width:67%; height:50px; padding:30px 10px; float:left;" id="brand_text_2"> 
      <span> I certify that I am a Canadian resident above the age of 18 years and I agree to and accept the <a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/terms.jspx"> Terms and Conditions</a>, <a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/privacy.jspx">Privacy Policy</a> and <a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/prizepolicy.jspx">Competition Rules</a>. I consent to my personal details being provided to selected clients, sponsors and affiliates and to being contacted via email, phone, SMS or mail, as described in the Privacy Policy. </span> 
      <textarea style="display:none; width:100%;">I certify that I am a Canadian resident above the age of 18 years and I agree to and accept the &lt;a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/terms.jspx"&gt; Terms and Conditions&lt;/a&gt;, &lt;a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/privacy.jspx"&gt;Privacy Policy&lt;/a&gt; and &lt;a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/prizepolicy.jspx"&gt;Competition Rules&lt;/a&gt;. I consent to my personal details being provided to selected clients, sponsors and affiliates and to being contacted via email, phone, SMS or mail, as described in the Privacy Policy.</textarea> 
     </span> 
     <span style="width:12%; height:50px; padding:30px 10px; float:right;"> 
      <form action="/wp-admin/admin.php?page=ninja-forms-extend" method="post" name="edit_2" id="edit_2"> 
       <input name="brand_name" type="hidden" value="canadianprizes"> 
       <textarea name="brand_text" style="display:none;">TEST</textarea> 
       <input class="termsEditButton termsButtons edit" style="width:150px; margin:0 auto; display:block;" name="edit" type="button" value="Edit Optin Statement"> 
       <input class="termsSaveButton termsButtons save" style="width:150px; margin:0 auto; display:none;" name="save" type="button" value="Save Optin Statement"> 
       <input class="termsDeleteButton termsButtons delete" style="width:150px; margin:0 auto; display:block;" name="delete" type="button" value="Delete Optin Statement"> 
      </form> 
     </span> 
    </div> 

Там вы увидите форму тег применяется должным образом.

+0

Может ли это быть изгоем javascript, удаляющим элемент? – AgilE

+0

Я отключил javascript в хроме, и проблема все еще сохраняется – Xenology

ответ

0

У меня была та же проблема. Оказалось, я полностью упустил из виду тот факт, что я тянул форму в форме основных опций.