PluginProbe
Insert Html Snippet / 1.2.2
Insert Html Snippet v1.2.2
1.4.6 trunk 1.0 1.0.1 1.1 1.1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.4 1.4.1 1.4.2 1.4.3 All 27 releases
insert-html-snippet / admin / snippet-edit.php

snippet-edit.php in Insert Html Snippet 1.2.2, at admin/snippet-edit.php

148 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) )
3 exit;
4
5 global $wpdb;
6 global $current_user;
7 wp_get_current_user();
8
9 $xyz_ihs_snippetId = $_GET['snippetId'];
10
11 $xyz_ihs_message = '';
12 if(isset($_GET['xyz_ihs_msg'])){
13 $xyz_ihs_message = $_GET['xyz_ihs_msg'];
14 }
15 if($xyz_ihs_message == 1){
16
17 ?>
18 <div class="system_notice_area_style1" id="system_notice_area">
19 HTML Snippet successfully updated.&nbsp;&nbsp;&nbsp;<span
20 id="system_notice_area_dismiss">Dismiss</span>
21 </div>
22 <?php
23 }
24
25
26
27 $xyz_ihs_snippetId = $_GET['snippetId'];
28 if(isset($_POST) && isset($_POST['updateSubmit'])){
29
30 // echo '<pre>';
31 // print_r($_POST);
32 // die("JJJ");
33
34 if (! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'snipp-edit_'.$xyz_ihs_snippetId )) {
35 wp_nonce_ays( 'snipp-edit_'.$xyz_ihs_snippetId );
36 exit;
37 }
38
39 else {
40 $_POST = stripslashes_deep($_POST);
41 $_POST = xyz_trim_deep($_POST);
42
43
44
45 $temp_xyz_ihs_title = str_replace(' ', '', $_POST['snippetTitle']);
46 $temp_xyz_ihs_title = str_replace('-', '', $temp_xyz_ihs_title);
47
48 $xyz_ihs_title = str_replace(' ', '-', $_POST['snippetTitle']);
49 $xyz_ihs_content = $_POST['snippetContent'];
50
51 if($xyz_ihs_title != "" && $xyz_ihs_content != ""){
52
53 if(ctype_alnum($temp_xyz_ihs_title))
54 {
55 $snippet_count = $wpdb->query($wpdb->prepare( 'SELECT * FROM '.$wpdb->prefix.'xyz_ihs_short_code WHERE id!=%d AND title=%s LIMIT 0,1',$xyz_ihs_snippetId,$xyz_ihs_title)) ;
56
57 if($snippet_count == 0){
58 $xyz_shortCode = '[xyz-ihs snippet="'.$xyz_ihs_title.'"]';
59
60 $wpdb->update($wpdb->prefix.'xyz_ihs_short_code', array('title'=>$xyz_ihs_title,'content'=>$xyz_ihs_content,'short_code'=>$xyz_shortCode,), array('id'=>$xyz_ihs_snippetId));
61
62 header("Location:".admin_url('admin.php?page=insert-html-snippet-manage&action=snippet-edit&snippetId='.$xyz_ihs_snippetId.'&xyz_ihs_msg=1'));
63
64 }
65 else{
66 ?>
67 <div class="system_notice_area_style0" id="system_notice_area">
68 HTML Snippet already exists. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
69 </div>
70 <?php
71
72 }
73 }
74 else
75 {
76 ?>
77 <div class="system_notice_area_style0" id="system_notice_area">
78 HTML Snippet title can have only alphabets,numbers or hyphen. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
79 </div>
80 <?php
81
82 }
83
84
85 }else{
86 ?>
87 <div class="system_notice_area_style0" id="system_notice_area">
88 Fill all mandatory fields. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
89 </div>
90 <?php
91 }
92
93 }
94 }
95
96 global $wpdb;
97
98
99 $snippetDetails = $wpdb->get_results($wpdb->prepare( 'SELECT * FROM '.$wpdb->prefix.'xyz_ihs_short_code WHERE id=%d LIMIT 0,1',$xyz_ihs_snippetId )) ;
100 $snippetDetails = $snippetDetails[0];
101
102 ?>
103
104 <div >
105 <fieldset
106 style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;">
107 <legend>
108 <b>Edit HTML Snippet</b>
109 </legend>
110 <form name="frmmainForm" id="frmmainForm" method="post">
111 <?php wp_nonce_field( 'snipp-edit_'.$xyz_ihs_snippetId ); ?>
112 <input type="hidden" id="snippetId" name="snippetId"
113 value="<?php if(isset($_POST['snippetId'])){ echo esc_attr($_POST['snippetId']);}else{ echo esc_attr($snippetDetails->id); }?>">
114 <div>
115 <table
116 style="width: 99%; background-color: #F9F9F9; border: 1px solid #E4E4E4; border-width: 1px;margin: 0 auto">
117 <tr><td><br/>
118 <div id="shortCode"></div>
119 <br/></td></tr>
120 <tr valign="top">
121 <td style="border-bottom: none;width:20%;">&nbsp;&nbsp;&nbsp;Tracking Name&nbsp;<font color="red">*</font></td>
122 <td style="border-bottom: none;width:1px;">&nbsp;:&nbsp;</td>
123 <td><input style="width:80%;"
124 type="text" name="snippetTitle" id="snippetTitle"
125 value="<?php if(isset($_POST['snippetTitle'])){ echo esc_attr($_POST['snippetTitle']);}else{ echo esc_attr($snippetDetails->title); }?>"></td>
126 </tr>
127 <tr>
128 <td style="border-bottom: none;width:20%; ">&nbsp;&nbsp;&nbsp;HTML code &nbsp;<font color="red">*</font></td>
129 <td style="border-bottom: none;width:1px;">&nbsp;:&nbsp;</td>
130 <td >
131 <textarea name="snippetContent" style="width:80%;height:150px;"><?php if(isset($_POST['snippetContent'])){ echo esc_textarea($_POST['snippetContent']);}else{ echo esc_textarea($snippetDetails->content); }?></textarea>
132 </td>
133 </tr>
134
135 <tr>
136 <td></td><td></td>
137 <td><input class="button-primary" style="cursor: pointer;"
138 type="submit" name="updateSubmit" value="Update"></td>
139 </tr>
140 <tr><td><br/></td></tr>
141 </table>
142 </div>
143
144 </form>
145 </fieldset>
146
147 </div>
148