| @@ -12,16 +12,19 @@ | ||
| 12 | 12 | } |
| 13 | 13 | if($xyz_ihs_message == 1){ |
| 14 | 14 | |
| 15 | 15 | ?> |
| 16 | -<div class="xyz_system_notice_area_style1" id="xyz_system_notice_area"> | |
| 16 | +<!-- <div class="xyz_ihs_system_notice_area_style1" id="xyz_ihs_system_notice_area"> | |
| 17 | 17 | HTML Snippet successfully updated. <span |
| 18 | -id="xyz_system_notice_area_dismiss">Dismiss</span> | |
| 18 | +id="xyz_ihs_system_notice_area_dismiss">Dismiss</span> | |
| 19 | +</div> --> | |
| 20 | + <div class="notice notice-success is-dismissible"> | |
| 21 | + <p><strong>HTML Snippet successfully updated. </strong></p> | |
| 19 | 22 | </div> |
| 20 | 23 | <?php |
| 21 | 24 | } |
| 22 | 25 | |
| 23 | -if($_GET['goback']) | |
| 26 | +if(isset($_GET['goback'])) | |
| 24 | 27 | $goback= intval($_GET['goback']); |
| 25 | 28 | |
| 26 | 29 | |
| 27 | 30 | $xyz_ihs_snippetId = intval($_GET['snippetId']); |
| @@ -41,10 +44,23 @@ | ||
| 41 | 44 | $temp_xyz_ihs_title = str_replace(' ', '', $_POST['snippetTitle']); |
| 42 | 45 | $temp_xyz_ihs_title = str_replace('-', '', $temp_xyz_ihs_title); |
| 43 | 46 | |
| 44 | 47 | $xyz_ihs_title = str_replace(' ', '-', $_POST['snippetTitle']); |
| 48 | + $xyz_ihs_snippetDescription=sanitize_text_field($_POST['xyz_ihs_snippetDescription']); | |
| 45 | 49 | $xyz_ihs_content = $_POST['snippetContent']; |
| 50 | + $xyz_ihs_insertionMethod = intval($_POST['xyz_ihs_insertionMethod']); | |
| 51 | + $xyz_ihs_insertionLocation = intval($_POST['xyz_ihs_insertionLocation']); | |
| 46 | 52 | |
| 53 | +if ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_HEADER'] || $xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_FOOTER']) { | |
| 54 | + $xyz_ihs_insertionLocationType = XYZ_IHS_INSERTION_LOCATION_TYPE['ADMIN']; | |
| 55 | +} | |
| 56 | +else if($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_HEADER'] || $xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_FOOTER']){ | |
| 57 | + $xyz_ihs_insertionLocationType = XYZ_IHS_INSERTION_LOCATION_TYPE['FRONT_END']; | |
| 58 | +} | |
| 59 | +else{ | |
| 60 | + $xyz_ihs_insertionLocationType = 0; | |
| 61 | +} | |
| 62 | + | |
| 47 | 63 | if($xyz_ihs_title != "" && $xyz_ihs_content != ""){ |
| 48 | 64 | |
| 49 | 65 | if(ctype_alnum($temp_xyz_ihs_title)) |
| 50 | 66 | { |
| @@ -52,17 +68,17 @@ | ||
| 52 | 68 | |
| 53 | 69 | if($snippet_count == 0){ |
| 54 | 70 | $xyz_shortCode = '[xyz-ihs snippet="'.$xyz_ihs_title.'"]'; |
| 55 | 71 | |
| 56 | - $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)); | |
| 72 | + $wpdb->update($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,), array('id'=>$xyz_ihs_snippetId)); | |
| 57 | 73 | |
| 58 | - header("Location:".admin_url('admin.php?page=insert-html-snippet-manage&action=snippet-edit&snippetId='.$xyz_ihs_snippetId.'&xyz_ihs_msg=1'.'&goback='.$goback)); | |
| 74 | + wp_safe_redirect(admin_url('admin.php?page=insert-html-snippet-manage&action=snippet-edit&snippetId='.$xyz_ihs_snippetId.'&xyz_ihs_msg=1'.'&goback='.$goback)); | |
| 59 | 75 | |
| 60 | 76 | } |
| 61 | 77 | else{ |
| 62 | 78 | ?> |
| 63 | - <div class="xyz_system_notice_area_style0" id="xyz_system_notice_area"> | |
| 64 | - HTML Snippet already exists. <span id="xyz_system_notice_area_dismiss">Dismiss</span> | |
| 79 | + <div class="xyz_ihs_system_notice_area_style0" id="xyz_ihs_system_notice_area"> | |
| 80 | + HTML Snippet already exists. <span id="xyz_ihs_system_notice_area_dismiss">Dismiss</span> | |
| 65 | 81 | </div> |
| 66 | 82 | <?php |
| 67 | 83 | |
| 68 | 84 | } |
| @@ -69,10 +85,10 @@ | ||
| 69 | 85 | } |
| 70 | 86 | else |
| 71 | 87 | { |
| 72 | 88 | ?> |
| 73 | - <div class="xyz_system_notice_area_style0" id="xyz_system_notice_area"> | |
| 74 | - HTML Snippet title can have only alphabets,numbers or hyphen. <span id="xyz_system_notice_area_dismiss">Dismiss</span> | |
| 89 | + <div class="xyz_ihs_system_notice_area_style0" id="xyz_ihs_system_notice_area"> | |
| 90 | + HTML Snippet title can have only alphabets,numbers or hyphen. <span id="xyz_ihs_system_notice_area_dismiss">Dismiss</span> | |
| 75 | 91 | </div> |
| 76 | 92 | <?php |
| 77 | 93 | |
| 78 | 94 | } |
| @@ -79,10 +95,10 @@ | ||
| 79 | 95 | |
| 80 | 96 | |
| 81 | 97 | }else{ |
| 82 | 98 | ?> |
| 83 | - <div class="xyz_system_notice_area_style0" id="xyz_system_notice_area"> | |
| 84 | - Fill all mandatory fields. <span id="xyz_system_notice_area_dismiss">Dismiss</span> | |
| 99 | + <div class="xyz_ihs_system_notice_area_style0" id="xyz_ihs_system_notice_area"> | |
| 100 | + Fill all mandatory fields. <span id="xyz_ihs_system_notice_area_dismiss">Dismiss</span> | |
| 85 | 101 | </div> |
| 86 | 102 | <?php |
| 87 | 103 | } |
| 88 | 104 | |
| @@ -94,8 +110,10 @@ | ||
| 94 | 110 | |
| 95 | 111 | $snippetDetails = $wpdb->get_results($wpdb->prepare( 'SELECT * FROM '.$wpdb->prefix.'xyz_ihs_short_code WHERE id=%d LIMIT 0,1',$xyz_ihs_snippetId )) ; |
| 96 | 112 | $snippetDetails = $snippetDetails[0]; |
| 97 | 113 | |
| 114 | +$xyz_ihs_insertionMethod = $snippetDetails->insertionMethod; | |
| 115 | +$xyz_ihs_insertionLocation = $snippetDetails->insertionLocation; | |
| 98 | 116 | ?> |
| 99 | 117 | |
| 100 | 118 | <div > |
| 101 | 119 | <fieldset |
| @@ -121,8 +139,91 @@ | ||
| 121 | 139 | <td><input style="width:80%;" |
| 122 | 140 | type="text" name="snippetTitle" id="snippetTitle" |
| 123 | 141 | value="<?php if(isset($_POST['snippetTitle'])){ echo esc_attr($_POST['snippetTitle']);}else{ echo esc_attr($snippetDetails->title); }?>"></td> |
| 124 | 142 | </tr> |
| 143 | + <tr valign="top"> | |
| 144 | + <td style="border-bottom: none;width:20%;"> Description </td> | |
| 145 | + <td style="border-bottom: none;width:1px;"> : </td> | |
| 146 | + <td> | |
| 147 | + <textarea id="xyz_ihs_snippetDescription" name="xyz_ihs_snippetDescription" style="resize: both;width:80%;"><?php | |
| 148 | + if(isset($_POST['xyz_ihs_snippetDescription'])){ echo esc_attr($_POST['xyz_ihs_snippetDescription']);}else{ echo esc_attr($snippetDetails->description); } ?></textarea> | |
| 149 | + </td> | |
| 150 | + </tr> | |
| 151 | + <tr valign="top"> | |
| 152 | + <td style="border-bottom: none;width:20%;"> | |
| 153 | + Placement Methods | |
| 154 | + <font color="red"> | |
| 155 | + * | |
| 156 | + </font> | |
| 157 | + </td> | |
| 158 | + <td style="border-bottom: none;width:1px;"> | |
| 159 | + : | |
| 160 | + </td> | |
| 161 | + <td> | |
| 162 | + <select class="xyz_ihs_uniq_select" name="xyz_ihs_insertionMethod" | |
| 163 | + id="xyz_ihs_insertionMethod"> | |
| 164 | + <option value="<?php echo XYZ_IHS_INSERTION_METHOD['AUTOMATIC']; ?>" <?php if ($xyz_ihs_insertionMethod == XYZ_IHS_INSERTION_METHOD['AUTOMATIC']) { | |
| 165 | + echo "selected"; | |
| 166 | + } ?>>Automatic</option> | |
| 167 | + <option value="<?php echo XYZ_IHS_INSERTION_METHOD['SHORT_CODE']; ?>" <?php if ($xyz_ihs_insertionMethod == XYZ_IHS_INSERTION_METHOD['SHORT_CODE']) { | |
| 168 | + echo "selected"; | |
| 169 | + } ?>>Short code (Manual)</option> | |
| 170 | + | |
| 171 | + </select> | |
| 172 | + </td> | |
| 173 | + </tr> | |
| 174 | + | |
| 175 | + | |
| 176 | + <tr valign="top" id="xyz_ihs_insertionLocationTR"> | |
| 177 | + <td style="border-bottom: none;width:20%;"> | |
| 178 | + Insertion Location | |
| 179 | + <font color="red"> | |
| 180 | + * | |
| 181 | + </font> | |
| 182 | + </td> | |
| 183 | + <td style="border-bottom: none;width:1px;"> | |
| 184 | + : | |
| 185 | + </td> | |
| 186 | + <td> | |
| 187 | + <div> | |
| 188 | + <div class="xyz_ihs_insertionLocationDiv"> | |
| 189 | + <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> | |
| 190 | + | |
| 191 | + </div> | |
| 192 | + <input type="hidden" id="xyz_ihs_insertionLocation" name="xyz_ihs_insertionLocation" value="<?php echo $xyz_ihs_insertionLocation;?>"> | |
| 193 | + <ul id="xyz_ihs_uniq_list" class="xyz_ihs_uniq_list"> | |
| 194 | + <div class="xyz_ihs_left-column"> | |
| 195 | + | |
| 196 | + <li class="xyz_ihs_li_h2"><label>Admin</label></li> | |
| 197 | + <li class="xyz_ihs_li_option <?php echo ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_HEADER']) ? 'selected' : ''; ?>" | |
| 198 | + data-value="<?php echo XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_HEADER']; ?>"> | |
| 199 | + Run on header | |
| 200 | + </li> | |
| 201 | + <li class="xyz_ihs_li_option <?php echo ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_FOOTER']) ? 'selected' : ''; ?>" | |
| 202 | + data-value="<?php echo XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_FOOTER']; ?>"> | |
| 203 | + Run on footer | |
| 204 | + </li> | |
| 205 | + | |
| 206 | + <li class="xyz_ihs_li_h2"><label>Front end</label></li> | |
| 207 | + | |
| 208 | + <li class="xyz_ihs_li_option <?php echo ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_HEADER']) ? 'selected' : ''; ?>" | |
| 209 | + data-value="<?php echo XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_HEADER']; ?>"> | |
| 210 | + Run on header | |
| 211 | + </li> | |
| 212 | + <li class="xyz_ihs_li_option <?php echo ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_FOOTER']) ? 'selected' : ''; ?>" | |
| 213 | + data-value="<?php echo XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_FOOTER']; ?>"> | |
| 214 | + Run on footer | |
| 215 | + </li> | |
| 216 | + | |
| 217 | + </div> | |
| 218 | + <div class="xyz_ihs_right-column"> | |
| 219 | + | |
| 220 | + </div> | |
| 221 | +</ul> | |
| 222 | +</div> | |
| 223 | + | |
| 224 | + </td> | |
| 225 | + </tr> | |
| 125 | 226 | <tr> |
| 126 | 227 | <td style="border-bottom: none;width:20%; "> HTML code <font color="red">*</font></td> |
| 127 | 228 | <td style="border-bottom: none;width:1px;"> : </td> |
| 128 | 229 | <td > |
| @@ -135,9 +236,9 @@ | ||
| 135 | 236 | <td> |
| 136 | 237 | |
| 137 | 238 | |
| 138 | 239 | <input class="button-primary" style="cursor: pointer;" |
| 139 | - type="button" name="back" onclick=" window.history.go(-<?php echo $goback;?>);" value="back" > | |
| 240 | + type="button" name="back" onclick=" window.history.go(-<?php echo $goback;?>);" value="Back" > | |
| 140 | 241 | </td> |
| 141 | 242 | <td><input class="button-primary" style="cursor: pointer;" type="submit" name="updateSubmit" value="Update"></td> |
| 142 | 243 | |
| 143 | 244 | </tr> |
| @@ -148,4 +249,7 @@ | ||
| 148 | 249 | </form> |
| 149 | 250 | </fieldset> |
| 150 | 251 | |
| 151 | 252 | </div> |
| 253 | +<?php | |
| 254 | +require( dirname( __FILE__ ) . '/snippet-js.php' ); | |
| 255 | +?> | |