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