PluginProbe
Insert Html Snippet / 1.2.4
Insert Html Snippet v1.2.4
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.4, at admin/snippet-edit.php

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