| 1 |
<?php |
| 2 |
global $wpdb; |
| 3 |
$_GET = stripslashes_deep($_GET); |
| 4 |
$xyz_ips_message = ''; |
| 5 |
if(isset($_GET['xyz_ips_msg'])){ |
| 6 |
$xyz_ips_message = $_GET['xyz_ips_msg']; |
| 7 |
} |
| 8 |
if($xyz_ips_message == 1){ |
| 9 |
|
| 10 |
?> |
| 11 |
<div class="system_notice_area_style1" id="system_notice_area"> |
| 12 |
PHP Snippet successfully added. <span |
| 13 |
id="system_notice_area_dismiss">Dismiss</span> |
| 14 |
</div> |
| 15 |
<?php |
| 16 |
|
| 17 |
} |
| 18 |
if($xyz_ips_message == 2){ |
| 19 |
|
| 20 |
?> |
| 21 |
<div class="system_notice_area_style0" id="system_notice_area"> |
| 22 |
PHP Snippet not found. <span |
| 23 |
id="system_notice_area_dismiss">Dismiss</span> |
| 24 |
</div> |
| 25 |
<?php |
| 26 |
|
| 27 |
} |
| 28 |
if($xyz_ips_message == 3){ |
| 29 |
|
| 30 |
?> |
| 31 |
<div class="system_notice_area_style1" id="system_notice_area"> |
| 32 |
PHP Snippet successfully deleted. <span |
| 33 |
id="system_notice_area_dismiss">Dismiss</span> |
| 34 |
</div> |
| 35 |
<?php |
| 36 |
|
| 37 |
} |
| 38 |
if($xyz_ips_message == 4){ |
| 39 |
|
| 40 |
?> |
| 41 |
<div class="system_notice_area_style1" id="system_notice_area"> |
| 42 |
PHP Snippet status successfully changed. <span |
| 43 |
id="system_notice_area_dismiss">Dismiss</span> |
| 44 |
</div> |
| 45 |
<?php |
| 46 |
|
| 47 |
} |
| 48 |
if($xyz_ips_message == 5){ |
| 49 |
|
| 50 |
?> |
| 51 |
<div class="system_notice_area_style1" id="system_notice_area"> |
| 52 |
PHP Snippet successfully updated. <span |
| 53 |
id="system_notice_area_dismiss">Dismiss</span> |
| 54 |
</div> |
| 55 |
<?php |
| 56 |
|
| 57 |
} |
| 58 |
?> |
| 59 |
|
| 60 |
|
| 61 |
<div > |
| 62 |
|
| 63 |
|
| 64 |
<form method="post"> |
| 65 |
<fieldset |
| 66 |
style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;"> |
| 67 |
<legend><h3>PHP Code Snippets</h3></legend> |
| 68 |
<?php |
| 69 |
global $wpdb; |
| 70 |
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1; |
| 71 |
$limit = get_option('xyz_ips_limit'); |
| 72 |
$offset = ( $pagenum - 1 ) * $limit; |
| 73 |
|
| 74 |
|
| 75 |
$entries = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."xyz_ips_short_code ORDER BY id DESC LIMIT $offset,$limit" ); |
| 76 |
|
| 77 |
?> |
| 78 |
<input id="submit_ips" |
| 79 |
style="cursor: pointer; margin-bottom:10px; margin-left:8px;" type="button" |
| 80 |
name="textFieldButton2" value="Add New PHP Code Snippet" |
| 81 |
onClick='document.location.href="<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-add');?>"'> |
| 82 |
<table class="widefat" style="width: 99%; margin: 0 auto; border-bottom:none;"> |
| 83 |
<thead> |
| 84 |
<tr> |
| 85 |
<th scope="col" >Tracking Name</th> |
| 86 |
<th scope="col" >Snippet Short Code</th> |
| 87 |
<th scope="col" >Status</th> |
| 88 |
<th scope="col" colspan="3" style="text-align: center;">Action</th> |
| 89 |
</tr> |
| 90 |
</thead> |
| 91 |
<tbody> |
| 92 |
<?php |
| 93 |
if( count($entries)>0 ) { |
| 94 |
$count=1; |
| 95 |
$class = ''; |
| 96 |
foreach( $entries as $entry ) { |
| 97 |
$class = ( $count % 2 == 0 ) ? ' class="alternate"' : ''; |
| 98 |
?> |
| 99 |
<tr <?php echo $class; ?>> |
| 100 |
<td id="vAlign"><?php |
| 101 |
echo esc_html($entry->title); |
| 102 |
?></td> |
| 103 |
<td id="vAlign"><?php |
| 104 |
if($entry->status == 2){echo 'NA';} |
| 105 |
else |
| 106 |
echo '[xyz-ips snippet="'.esc_html($entry->title).'"]'; |
| 107 |
?></td> |
| 108 |
<td id="vAlign"> |
| 109 |
<?php |
| 110 |
if($entry->status == 2){ |
| 111 |
echo "Inactive"; |
| 112 |
}elseif ($entry->status == 1){ |
| 113 |
echo "Active"; |
| 114 |
} |
| 115 |
|
| 116 |
?> |
| 117 |
</td> |
| 118 |
<?php |
| 119 |
if($entry->status == 2){ |
| 120 |
?> |
| 121 |
<td style="text-align: center;"><a |
| 122 |
href='<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-status&snippetId='.$entry->id.'&status=1&pageno='.$pagenum); ?>'><img |
| 123 |
id="img" title="Activate" |
| 124 |
src="<?php echo plugins_url('insert-php-code-snippet/images/activate.png')?>"> |
| 125 |
</a> |
| 126 |
</td> |
| 127 |
<?php |
| 128 |
}elseif ($entry->status == 1){ |
| 129 |
?> |
| 130 |
<td style="text-align: center;"><a |
| 131 |
href='<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-status&snippetId='.$entry->id.'&status=2&pageno='.$pagenum); ?>'><img |
| 132 |
id="img" title="Deactivate" |
| 133 |
src="<?php echo plugins_url('insert-php-code-snippet/images/pause.png')?>"> |
| 134 |
</a> |
| 135 |
</td> |
| 136 |
<?php |
| 137 |
} |
| 138 |
|
| 139 |
?> |
| 140 |
|
| 141 |
<td style="text-align: center;"><a |
| 142 |
href='<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-edit&snippetId='.$entry->id.'&pageno='.$pagenum); ?>'><img |
| 143 |
id="img" title="Edit Snippet" |
| 144 |
src="<?php echo plugins_url('insert-php-code-snippet/images/edit.png')?>"> |
| 145 |
</a> |
| 146 |
</td> |
| 147 |
<td style="text-align: center;" ><a |
| 148 |
href='<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-delete&snippetId='.$entry->id.'&pageno='.$pagenum); ?>' |
| 149 |
onclick="javascript: return confirm('Please click \'OK\' to confirm ');"><img |
| 150 |
id="img" title="Delete Snippet" |
| 151 |
src="<?php echo plugins_url('insert-php-code-snippet/images/delete.png')?>"> |
| 152 |
</a></td> |
| 153 |
</tr> |
| 154 |
<?php |
| 155 |
$count++; |
| 156 |
} |
| 157 |
} else { ?> |
| 158 |
<tr> |
| 159 |
<td colspan="6" >PHP Code Snippets not found</td> |
| 160 |
</tr> |
| 161 |
<?php } ?> |
| 162 |
</tbody> |
| 163 |
</table> |
| 164 |
|
| 165 |
<input id="submit_ips" |
| 166 |
style="cursor: pointer; margin-top:10px;margin-left:8px;" type="button" |
| 167 |
name="textFieldButton2" value="Add New PHP Code Snippet" |
| 168 |
onClick='document.location.href="<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-add');?>"'> |
| 169 |
|
| 170 |
<?php |
| 171 |
$total = $wpdb->get_var( "SELECT COUNT(`id`) FROM ".$wpdb->prefix."xyz_ips_short_code" ); |
| 172 |
$num_of_pages = ceil( $total / $limit ); |
| 173 |
|
| 174 |
$page_links = paginate_links( array( |
| 175 |
'base' => add_query_arg( 'pagenum','%#%'), |
| 176 |
'format' => '', |
| 177 |
'prev_text' => '«', |
| 178 |
'next_text' => '»', |
| 179 |
'total' => $num_of_pages, |
| 180 |
'current' => $pagenum |
| 181 |
) ); |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
if ( $page_links ) { |
| 186 |
echo '<div class="tablenav" style="width:99%"><div class="tablenav-pages" style="margin: 1em 0">' . $page_links . '</div></div>'; |
| 187 |
} |
| 188 |
|
| 189 |
?> |
| 190 |
|
| 191 |
</fieldset> |
| 192 |
|
| 193 |
</form> |
| 194 |
|
| 195 |
</div> |
| 196 |
|
| 197 |
|