PluginProbe
Insert Html Snippet / 1.3.2
Insert Html Snippet v1.3.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.3.2, at admin/snippet-edit.php

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