| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) |
| 3 |
exit; |
| 4 |
global $wpdb; |
| 5 |
$goback=1; |
| 6 |
$_POST = stripslashes_deep($_POST); |
| 7 |
$_POST = xyz_trim_deep($_POST); |
| 8 |
if(isset($_POST) && isset($_POST['addSubmit'])){ |
| 9 |
if(!isset($_REQUEST['_wpnonce'])||!wp_verify_nonce($_REQUEST['_wpnonce'],'ihs-add_')){ |
| 10 |
wp_nonce_ays( 'ihs-add_' ); |
| 11 |
exit; |
| 12 |
} |
| 13 |
$goback=intval($_POST['goback']); |
| 14 |
$goback++; |
| 15 |
$temp_xyz_ihs_title = str_replace(' ', '', $_POST['snippetTitle']); |
| 16 |
$temp_xyz_ihs_title = str_replace('-', '', $temp_xyz_ihs_title); |
| 17 |
$xyz_ihs_title = str_replace(' ', '-', $_POST['snippetTitle']); |
| 18 |
$xyz_ihs_content = $_POST['snippetContent']; |
| 19 |
|
| 20 |
if($xyz_ihs_title != "" && $xyz_ihs_content != ""){ |
| 21 |
if(ctype_alnum($temp_xyz_ihs_title)){ |
| 22 |
$snippet_count = $wpdb->query($wpdb->prepare( 'SELECT * FROM '.$wpdb->prefix.'xyz_ihs_short_code WHERE title=%s' ,$xyz_ihs_title)) ; |
| 23 |
|
| 24 |
if($snippet_count == 0){ |
| 25 |
$xyz_shortCode = '[xyz-ihs snippet="'.$xyz_ihs_title.'"]'; |
| 26 |
$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')); |
| 27 |
header("Location:".admin_url('admin.php?page=insert-html-snippet-manage&xyz_ihs_msg=1')); |
| 28 |
} |
| 29 |
else{ |
| 30 |
?> |
| 31 |
<div class="xyz_system_notice_area_style0" id="xyz_system_notice_area"> |
| 32 |
HTML Snippet already exists. |
| 33 |
<span id="xyz_system_notice_area_dismiss">Dismiss</span> |
| 34 |
</div> |
| 35 |
<?php |
| 36 |
} |
| 37 |
} |
| 38 |
else{ |
| 39 |
?> |
| 40 |
<div class="xyz_system_notice_area_style0" id="xyz_system_notice_area"> |
| 41 |
HTML Snippet title can have only alphabets,numbers or hyphen. |
| 42 |
<span id="xyz_system_notice_area_dismiss">Dismiss</span> |
| 43 |
</div> |
| 44 |
<?php |
| 45 |
} |
| 46 |
} |
| 47 |
else{ |
| 48 |
?> |
| 49 |
<div class="xyz_system_notice_area_style0" id="xyz_system_notice_area"> |
| 50 |
Fill all mandatory fields. |
| 51 |
<span id="xyz_system_notice_area_dismiss">Dismiss</span> |
| 52 |
</div> |
| 53 |
<?php |
| 54 |
} |
| 55 |
|
| 56 |
} |
| 57 |
?> |
| 58 |
<div > |
| 59 |
<fieldset |
| 60 |
style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;"> |
| 61 |
<legend> |
| 62 |
<b> |
| 63 |
Add HTML Snippet |
| 64 |
</b> |
| 65 |
</legend> |
| 66 |
<form name="frmmainForm" id="frmmainForm" method="post"> |
| 67 |
<?php |
| 68 |
wp_nonce_field('ihs-add_'); |
| 69 |
?> |
| 70 |
<div> |
| 71 |
<input type="hidden" name="goback" value=<?php echo $goback;?>> |
| 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></td> |
| 115 |
|
| 116 |
|
| 117 |
<td> |
| 118 |
|
| 119 |
|
| 120 |
<input class="button-primary" style="cursor: pointer;" |
| 121 |
type="button" name="back" value="Back" onclick=" window.history.go(-<?php echo $goback;?>);" > |
| 122 |
</td> |
| 123 |
<td> |
| 124 |
<input class="button-primary" style="cursor: pointer;" |
| 125 |
type="submit" name="addSubmit" value="Create" > |
| 126 |
</td> |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
</tr> |
| 131 |
<tr> |
| 132 |
<td> |
| 133 |
<br/> |
| 134 |
</td> |
| 135 |
</tr> |
| 136 |
</table> |
| 137 |
</div> |
| 138 |
</form> |
| 139 |
</fieldset> |
| 140 |
</div> |
| 141 |
|