當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ThemeHelper::stripslashesPOST方法代碼示例

本文整理匯總了PHP中ThemeHelper::stripslashesPOST方法的典型用法代碼示例。如果您正苦於以下問題:PHP ThemeHelper::stripslashesPOST方法的具體用法?PHP ThemeHelper::stripslashesPOST怎麽用?PHP ThemeHelper::stripslashesPOST使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ThemeHelper的用法示例。


在下文中一共展示了ThemeHelper::stripslashesPOST方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPostOption

 static function getPostOption($prefix = null)
 {
     if (!is_null($prefix)) {
         $prefix = '_' . $prefix . '_';
     }
     $option = array();
     foreach ($_POST as $key => $value) {
         if (preg_match('/^' . THEME_OPTION_PREFIX . $prefix . '/', $key, $result)) {
             $index = preg_replace('/^' . THEME_OPTION_PREFIX . '_/', '', $key);
             $option[$index] = $value;
         }
     }
     $option = ThemeHelper::stripslashesPOST($option);
     return $option;
 }
開發者ID:phanhoanglong2610,項目名稱:anc_gvn,代碼行數:15,代碼來源:Theme.Helper.class.php

示例2: addComment

 function addComment()
 {
     global $wpdb;
     $Validation = new ThemeValidation();
     $response = array('error' => 0, 'info' => null, 'changeURL' => '');
     $data = array('author' => null, 'email' => null, 'url' => null, 'comment' => null, 'comment_post_ID' => 0, 'comment_parent' => 0);
     foreach ($data as $index => $value) {
         if (array_key_exists($index, $_POST)) {
             $data[$index] = $_POST[$index];
         }
     }
     if (!is_user_logged_in()) {
         if ($Validation->isEmpty($data['author']) && get_option('require_name_email') == 1) {
             $response['error'] = 1;
             $response['info'][] = array('fieldId' => 'author', 'message' => esc_html__('Please enter your name.', THEME_DOMAIN));
         }
         if (!$Validation->isEmailAddress($data['email']) && get_option('require_name_email') == 1) {
             $response['error'] = 1;
             $response['info'][] = array('fieldId' => 'email', 'message' => esc_html__('Please enter valid e-mail address.', THEME_DOMAIN));
         }
         if (!$Validation->isURL($data['url'], true)) {
             $response['error'] = 1;
             $response['info'][] = array('fieldId' => 'url', 'message' => esc_html__('Please enter valid URL address.', THEME_DOMAIN));
         }
     }
     if ($Validation->isEmpty($data['comment'])) {
         $response['error'] = 1;
         $response['info'][] = array('fieldId' => 'comment', 'message' => esc_html__('Please enter your message.', THEME_DOMAIN));
     }
     if ($response['error'] == 1) {
         $this->createResponse($response);
     }
     $data = ThemeHelper::stripslashesPOST($data);
     $insertData = array('comment_post_ID' => (int) $data['comment_post_ID'], 'comment_content' => $data['comment'], 'comment_parent' => (int) $data['comment_parent'], 'comment_date' => current_time('mysql'), 'comment_approved' => $this->comment_moderation);
     if (!is_user_logged_in()) {
         $insertData['comment_author'] = $data['author'];
         $insertData['comment_author_url'] = ThemeHelper::addProtocolName($data['url']);
         $insertData['comment_author_email'] = $data['email'];
     } else {
         $user = wp_get_current_user();
         $insertData['comment_author'] = $user->display_name;
         $insertData['comment_author_email'] = $user->user_email;
     }
     $commentId = wp_insert_comment($insertData);
     if ($commentId) {
         query_posts('p=' . (int) $data['comment_post_ID'] . '&post_type=post');
         if (have_posts()) {
             the_post();
             if ((int) $data['comment_parent'] == 0 || $this->thread_comments == 0) {
                 $query = 'select count(*) as count from ' . $wpdb->comments . ' where comment_approved=1 and comment_post_ID=' . (int) get_the_ID() . ($this->thread_comments == 1 ? ' and comment_parent=0' : null);
                 $parent = $wpdb->get_row($query);
                 if ($this->comments_per_page > 0) {
                     $_GET['cpage'] = ceil($parent->count / $this->comments_per_page);
                 } else {
                     $_GET['cpage'] = 1;
                 }
                 $response['changeURL'] = '#cpage-' . $_GET['cpage'];
             } else {
                 $_GET['cpage'] = (int) $_POST['cpage'];
             }
             $response['cpage'] = (int) $_GET['cpage'];
             $response['commentId'] = (int) $commentId;
             ob_start();
             comments_template();
             $response['html'] = ob_get_contents();
             ob_end_clean();
         }
         $response['comment_id'] = $commentId;
         $response['error'] = 0;
         $response['info'][] = array('fieldId' => 'submit', 'message' => esc_html__('Your comment has been added.', THEME_DOMAIN));
     } else {
         $response['error'] = 1;
         $response['info'][] = array('fieldId' => 'submit', 'message' => esc_html__('Your comment could not be added.', THEME_DOMAIN));
     }
     $this->createResponse($response);
 }
開發者ID:phanhoanglong2610,項目名稱:anc_gvn,代碼行數:76,代碼來源:Theme.Comment.class.php


注:本文中的ThemeHelper::stripslashesPOST方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。