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