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

116 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 global $wpdb;
4 global $current_user;
5 get_currentuserinfo();
6
7 $xyz_ihs_snippetId = $_GET['snippetId'];
8
9 if(isset($_POST) && isset($_POST['updateSubmit'])){
10
11 // echo '<pre>';
12 // print_r($_POST);
13 // die("JJJ");
14 $_POST = stripslashes_deep($_POST);
15 $_POST = xyz_trim_deep($_POST);
16
17 $xyz_ihs_snippetId = $_GET['snippetId'];
18 $xyz_ihs_title = str_replace(' ', '-', $_POST['snippetTitle']);
19 $xyz_ihs_content = $_POST['snippetContent'];
20
21 if($xyz_ihs_title != "" && $xyz_ihs_content != ""){
22
23 if(ctype_alnum($xyz_ihs_title))
24 {
25 $snippet_count = $wpdb->query( 'SELECT * FROM '.$wpdb->prefix.'xyz_ihs_short_code WHERE id!="'.$xyz_ihs_snippetId.'" AND title="'.$xyz_ihs_title.'" LIMIT 0,1' ) ;
26
27 if($snippet_count == 0){
28 $xyz_shortCode = '[xyz-ihs snippet="'.$xyz_ihs_title.'"]';
29
30 $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));
31
32 header("Location:".admin_url('admin.php?page=insert-html-snippet-manage&msg=5'));
33
34 }else{
35 ?>
36 <div class="system_notice_area_style0" id="system_notice_area">
37 HTML Snippet already exists. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
38 </div>
39 <?php
40
41 }
42 }
43 else
44 {
45 ?>
46 <div class="system_notice_area_style0" id="system_notice_area">
47 HTML Snippet title must be alphanumeric. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
48 </div>
49 <?php
50
51 }
52
53
54 }else{
55 ?>
56 <div class="system_notice_area_style0" id="system_notice_area">
57 Fill all mandatory fields. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
58 </div>
59 <?php
60 }
61
62 }
63
64
65 global $wpdb;
66
67
68 $snippetDetails = $wpdb->get_results( 'SELECT * FROM '.$wpdb->prefix.'xyz_ihs_short_code WHERE id="'.$xyz_ihs_snippetId.'" LIMIT 0,1' ) ;
69 $snippetDetails = $snippetDetails[0];
70
71 ?>
72
73 <div >
74 <fieldset
75 style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;">
76 <legend>
77 <b>Edit HTML Snippet</b>
78 </legend>
79 <form name="frmmainForm" id="frmmainForm" method="post">
80 <input type="hidden" id="snippetId" name="snippetId"
81 value="<?php if(isset($_POST['snippetId'])){ echo esc_attr($_POST['snippetId']);}else{ echo esc_attr($snippetDetails->id); }?>">
82 <div>
83 <table
84 style="width: 99%; background-color: #F9F9F9; border: 1px solid #E4E4E4; border-width: 1px;margin: 0 auto">
85 <tr><td><br/>
86 <div id="shortCode"></div>
87 <br/></td></tr>
88 <tr valign="top">
89 <td style="border-bottom: none;width:20%;">&nbsp;&nbsp;&nbsp;Tracking Name&nbsp;<font color="red">*</font></td>
90 <td style="border-bottom: none;width:1px;">&nbsp;:&nbsp;</td>
91 <td><input style="width:80%;"
92 type="text" name="snippetTitle" id="snippetTitle"
93 value="<?php if(isset($_POST['snippetTitle'])){ echo esc_attr($_POST['snippetTitle']);}else{ echo esc_attr($snippetDetails->title); }?>"></td>
94 </tr>
95 <tr>
96 <td style="border-bottom: none;width:20%; ">&nbsp;&nbsp;&nbsp;HTML code &nbsp;<font color="red">*</font></td>
97 <td style="border-bottom: none;width:1px;">&nbsp;:&nbsp;</td>
98 <td >
99 <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>
100 </td>
101 </tr>
102
103 <tr>
104 <td></td><td></td>
105 <td><input class="button-primary" style="cursor: pointer;"
106 type="submit" name="updateSubmit" value="Update"></td>
107 </tr>
108 <tr><td><br/></td></tr>
109 </table>
110 </div>
111
112 </form>
113 </fieldset>
114
115 </div>
116