| @@ -1,19 +1,36 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) |
| 3 | 3 | exit; |
| 4 | 4 | global $wpdb; |
| 5 | +$goback=1; | |
| 5 | 6 | $_POST = stripslashes_deep($_POST); |
| 6 | 7 | $_POST = xyz_trim_deep($_POST); |
| 7 | -if($_POST){ | |
| 8 | +$xyz_ihs_insertionLocation =''; | |
| 9 | +if(isset($_POST) && isset($_POST['addSubmit'])){ | |
| 8 | 10 | if(!isset($_REQUEST['_wpnonce'])||!wp_verify_nonce($_REQUEST['_wpnonce'],'ihs-add_')){ |
| 9 | 11 | wp_nonce_ays( 'ihs-add_' ); |
| 10 | 12 | exit; |
| 11 | 13 | } |
| 12 | - | |
| 14 | + $goback=intval($_POST['goback']); | |
| 15 | + $goback++; | |
| 13 | 16 | $temp_xyz_ihs_title = str_replace(' ', '', $_POST['snippetTitle']); |
| 14 | 17 | $temp_xyz_ihs_title = str_replace('-', '', $temp_xyz_ihs_title); |
| 15 | 18 | $xyz_ihs_title = str_replace(' ', '-', $_POST['snippetTitle']); |
| 19 | + $xyz_ihs_snippetDescription=sanitize_text_field($_POST['xyz_ihs_snippetDescription']); | |
| 20 | + $xyz_ihs_insertionMethod = intval($_POST['xyz_ihs_insertionMethod']); | |
| 21 | + $xyz_ihs_insertionLocation = intval($_POST['xyz_ihs_insertionLocation']); | |
| 22 | + | |
| 23 | + | |
| 24 | + if ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_HEADER'] || $xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_FOOTER']) { | |
| 25 | + $xyz_ihs_insertionLocationType = XYZ_IHS_INSERTION_LOCATION_TYPE['ADMIN']; | |
| 26 | + } | |
| 27 | + else if($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_HEADER'] || $xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_FOOTER']){ | |
| 28 | + $xyz_ihs_insertionLocationType = XYZ_IHS_INSERTION_LOCATION_TYPE['FRONT_END']; | |
| 29 | + } | |
| 30 | + else{ | |
| 31 | + $xyz_ihs_insertionLocationType = 0; | |
| 32 | + } | |
| 16 | 33 | $xyz_ihs_content = $_POST['snippetContent']; |
| 17 | 34 | |
| 18 | 35 | if($xyz_ihs_title != "" && $xyz_ihs_content != ""){ |
| 19 | 36 | if(ctype_alnum($temp_xyz_ihs_title)){ |
| @@ -20,16 +37,16 @@ | ||
| 20 | 37 | $snippet_count = $wpdb->query($wpdb->prepare( 'SELECT * FROM '.$wpdb->prefix.'xyz_ihs_short_code WHERE title=%s' ,$xyz_ihs_title)) ; |
| 21 | 38 | |
| 22 | 39 | if($snippet_count == 0){ |
| 23 | 40 | $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')); | |
| 41 | + $wpdb->insert($wpdb->prefix.'xyz_ihs_short_code', array('title' =>$xyz_ihs_title,'description'=>$xyz_ihs_snippetDescription,'insertionMethod' => $xyz_ihs_insertionMethod, 'insertionLocation' => $xyz_ihs_insertionLocation, 'insertionLocationType' => $xyz_ihs_insertionLocationType,'content'=>$xyz_ihs_content,'short_code'=>$xyz_shortCode,'status'=>'1'),array('%s','%s','%d','%d','%d','%s','%s','%d')); | |
| 42 | + wp_safe_redirect(admin_url('admin.php?page=insert-html-snippet-manage&xyz_ihs_msg=1')); | |
| 26 | 43 | } |
| 27 | 44 | else{ |
| 28 | 45 | ?> |
| 29 | -<div class="xyz_system_notice_area_style0" id="xyz_system_notice_area"> | |
| 46 | +<div class="xyz_ihs_system_notice_area_style0" id="xyz_ihs_system_notice_area"> | |
| 30 | 47 | HTML Snippet already exists. |
| 31 | - <span id="xyz_system_notice_area_dismiss">Dismiss</span> | |
| 48 | + <span id="xyz_ihs_system_notice_area_dismiss">Dismiss</span> | |
| 32 | 49 | </div> |
| 33 | 50 | <?php |
| 34 | 51 | } |
| 35 | 52 | } |
| @@ -34,11 +51,11 @@ | ||
| 34 | 51 | } |
| 35 | 52 | } |
| 36 | 53 | else{ |
| 37 | 54 | ?> |
| 38 | -<div class="xyz_system_notice_area_style0" id="xyz_system_notice_area"> | |
| 55 | +<div class="xyz_ihs_system_notice_area_style0" id="xyz_ihs_system_notice_area"> | |
| 39 | 56 | HTML Snippet title can have only alphabets,numbers or hyphen. |
| 40 | - <span id="xyz_system_notice_area_dismiss">Dismiss</span> | |
| 57 | + <span id="xyz_ihs_system_notice_area_dismiss">Dismiss</span> | |
| 41 | 58 | </div> |
| 42 | 59 | <?php |
| 43 | 60 | } |
| 44 | 61 | } |
| @@ -43,11 +60,11 @@ | ||
| 43 | 60 | } |
| 44 | 61 | } |
| 45 | 62 | else{ |
| 46 | 63 | ?> |
| 47 | -<div class="xyz_system_notice_area_style0" id="xyz_system_notice_area"> | |
| 64 | +<div class="xyz_ihs_system_notice_area_style0" id="xyz_ihs_system_notice_area"> | |
| 48 | 65 | Fill all mandatory fields. |
| 49 | - <span id="xyz_system_notice_area_dismiss">Dismiss</span> | |
| 66 | + <span id="xyz_ihs_system_notice_area_dismiss">Dismiss</span> | |
| 50 | 67 | </div> |
| 51 | 68 | <?php |
| 52 | 69 | } |
| 53 | 70 | |
| @@ -65,8 +82,9 @@ | ||
| 65 | 82 | <?php |
| 66 | 83 | wp_nonce_field('ihs-add_'); |
| 67 | 84 | ?> |
| 68 | 85 | <div> |
| 86 | + <input type="hidden" name="goback" value=<?php echo $goback;?>> | |
| 69 | 87 | <table |
| 70 | 88 | style="width: 99%; background-color: #F9F9F9; border: 1px solid #E4E4E4; border-width: 1px;margin: 0 auto"> |
| 71 | 89 | <tr> |
| 72 | 90 | <td> |
| @@ -77,8 +95,79 @@ | ||
| 77 | 95 | </td> |
| 78 | 96 | </tr> |
| 79 | 97 | <tr valign="top"> |
| 80 | 98 | <td style="border-bottom: none;width:20%;"> |
| 99 | + Placement Methods | |
| 100 | + <font color="red"> | |
| 101 | + * | |
| 102 | + </font> | |
| 103 | + </td> | |
| 104 | + <td style="border-bottom: none;width:1px;"> | |
| 105 | + : | |
| 106 | + </td> | |
| 107 | + <td> | |
| 108 | + <select class="xyz_ihs_uniq_select" name="xyz_ihs_insertionMethod" | |
| 109 | + id="xyz_ihs_insertionMethod"> | |
| 110 | + <option value="<?php echo XYZ_IHS_INSERTION_METHOD['AUTOMATIC']; ?>" <?php if (isset($_POST['xyz_ihs_insertionMethod']) && $_POST['xyz_ihs_insertionMethod'] == XYZ_IHS_INSERTION_METHOD['AUTOMATIC']) { | |
| 111 | + echo "selected"; | |
| 112 | + } ?>>Automatic</option> | |
| 113 | + <option value="<?php echo XYZ_IHS_INSERTION_METHOD['SHORT_CODE']; ?>" <?php if (isset($_POST['xyz_ihs_insertionMethod']) && $_POST['xyz_ihs_insertionMethod'] == XYZ_IHS_INSERTION_METHOD['SHORT_CODE']) { | |
| 114 | + echo "selected"; | |
| 115 | + } ?>>Short code (Manual)</option> | |
| 116 | + </select> | |
| 117 | + </td> | |
| 118 | + </tr> | |
| 119 | + | |
| 120 | + | |
| 121 | + <tr valign="top" id="xyz_ihs_insertionLocationTR"> | |
| 122 | + <td style="border-bottom: none;width:20%;"> | |
| 123 | + Insertion Location | |
| 124 | + <font color="red"> | |
| 125 | + * | |
| 126 | + </font> | |
| 127 | + </td> | |
| 128 | + <td style="border-bottom: none;width:1px;"> : | |
| 129 | + | |
| 130 | + </td> | |
| 131 | + <td> | |
| 132 | + <div> | |
| 133 | + <div class="xyz_ihs_insertionLocationDiv"> | |
| 134 | + <span id="xyz_ihs_insertion-location-txt">Select Insertion Location </span><span><i class="fa fa-angle-down" aria-hidden="true"></i> <i class="fa fa-angle-up" aria-hidden="true"></i></span> | |
| 135 | + | |
| 136 | + </div> | |
| 137 | + <input type="hidden" id="xyz_ihs_insertionLocation" name="xyz_ihs_insertionLocation" value="<?php echo intval($xyz_ihs_insertionLocation);?>"> | |
| 138 | + <ul id="xyz_ihs_uniq_list" class="xyz_ihs_uniq_list"> | |
| 139 | + <div class="xyz_ihs_left-column"> | |
| 140 | + | |
| 141 | + <li class="xyz_ihs_li_h2"><label>Admin</label></li> | |
| 142 | + <li class="xyz_ihs_li_option <?php echo ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_HEADER']) ? 'selected' : ''; ?>" | |
| 143 | + data-value="<?php echo XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_HEADER']; ?>"> | |
| 144 | + Run on header | |
| 145 | + </li> | |
| 146 | + <li class="xyz_ihs_li_option <?php echo ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_FOOTER']) ? 'selected' : ''; ?>" | |
| 147 | + data-value="<?php echo XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_FOOTER']; ?>"> | |
| 148 | + Run on footer | |
| 149 | + </li> | |
| 150 | + <li class="xyz_ihs_li_h2"><label>Front end</label></li> | |
| 151 | + <li class="xyz_ihs_li_option <?php echo ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_HEADER']) ? 'selected' : ''; ?>" | |
| 152 | + data-value="<?php echo XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_HEADER']; ?>"> | |
| 153 | + Run on header | |
| 154 | + </li> | |
| 155 | + <li class="xyz_ihs_li_option <?php echo ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_FOOTER']) ? 'selected' : ''; ?>" | |
| 156 | + data-value="<?php echo XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_FOOTER']; ?>"> | |
| 157 | + Run on footer | |
| 158 | + </li> | |
| 159 | + | |
| 160 | + </div> | |
| 161 | + <div class="xyz_ihs_right-column"> | |
| 162 | + | |
| 163 | + </div> | |
| 164 | +</ul> | |
| 165 | +</div> | |
| 166 | + </td> | |
| 167 | + </tr> | |
| 168 | + <tr valign="top"> | |
| 169 | + <td style="border-bottom: none;width:20%;"> | |
| 81 | 170 | Tracking Name |
| 82 | 171 | <font color="red"> |
| 83 | 172 | * |
| 84 | 173 | </font> |
| @@ -92,8 +181,22 @@ | ||
| 92 | 181 | value=" |
| 93 | 182 | <?php if(isset($_POST['snippetTitle'])){ echo esc_attr($_POST['snippetTitle']);}?>"> |
| 94 | 183 | </td> |
| 95 | 184 | </tr> |
| 185 | + <tr valign="top"> | |
| 186 | + <td style="border-bottom: none;width:20%;"> | |
| 187 | + Description | |
| 188 | + </td> | |
| 189 | + <td style="border-bottom: none;width:1px;"> | |
| 190 | + </td> | |
| 191 | + <td> | |
| 192 | + <textarea id="xyz_ihs_snippetDescription" name="xyz_ihs_snippetDescription" style="resize: both;width:80%;"><?php | |
| 193 | + if (isset($_POST['xyz_ihs_snippetDescription'])) { | |
| 194 | + echo esc_attr(sanitize_text_field($_POST['xyz_ihs_snippetDescription'])); | |
| 195 | + } | |
| 196 | + ?></textarea> | |
| 197 | + </td> | |
| 198 | + </tr> | |
| 96 | 199 | <tr> |
| 97 | 200 | <td style="border-bottom: none;width:20%; "> |
| 98 | 201 | HTML code |
| 99 | 202 | <font color="red"> |
| @@ -107,16 +210,24 @@ | ||
| 107 | 210 | <textarea name="snippetContent" style="width:80%;height:150px;"><?php if(isset($_POST['snippetContent'])){ echo esc_textarea($_POST['snippetContent']);}?></textarea> |
| 108 | 211 | </td> |
| 109 | 212 | </tr> |
| 110 | 213 | <tr> |
| 111 | - <td> | |
| 214 | + <td></td> | |
| 215 | + | |
| 216 | + | |
| 217 | + <td> | |
| 218 | + | |
| 219 | + | |
| 220 | + <input class="button-primary" style="cursor: pointer;" | |
| 221 | + type="button" name="back" value="Back" onclick=" window.history.go(-<?php echo $goback;?>);" > | |
| 112 | 222 | </td> |
| 113 | 223 | <td> |
| 114 | - </td> | |
| 115 | - <td> | |
| 116 | 224 | <input class="button-primary" style="cursor: pointer;" |
| 117 | - type="submit" name="addSubmit" value="Create"> | |
| 118 | - </td> | |
| 225 | + type="submit" name="addSubmit" value="Create" > | |
| 226 | + </td> | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 119 | 230 | </tr> |
| 120 | 231 | <tr> |
| 121 | 232 | <td> |
| 122 | 233 | <br/> |
| @@ -126,4 +237,7 @@ | ||
| 126 | 237 | </div> |
| 127 | 238 | </form> |
| 128 | 239 | </fieldset> |
| 129 | 240 | </div> |
| 241 | +<?php | |
| 242 | +require( dirname( __FILE__ ) . '/snippet-js.php' ); | |
| 243 | +?> | |