Skip to content

Instantly share code, notes, and snippets.

View keks55's full-sized avatar

keks55

View GitHub Profile
<?php
$start = isset($_GET['start']) ? intval( $_GET['start'] ) : 0 ;
$critery = isset($_GET['critery']) ? intval( $_GET['critery'] ) : 0 ;
$p = isset($_GET['p']) ? intval( $_GET['p'] ) : 1 ;
$list_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table_name LIMIT $start, $items_limit"), ARRAY_A);
foreach ($list_data as $v) { ?>
<tr>
<td class="t1"><?php echo $v['name'] ?></td>
<td class="t2"><?php echo $v['type'] ?></td>
<td class="t3"><?php echo $v['address'] ?></td>
@keks55
keks55 / class.database.php
Created April 8, 2018 06:22 — forked from jonashansen229/class.database.php
PHP OOP Database class using MySQLI and Singleton pattern. Only one instance of the class will be made, this requires less memory.
<?php
/*
* Mysql database class - only one connection alowed
*/
class Database {
private $_connection;
private static $_instance; //The single instance
private $_host = "HOSTt";
private $_username = "USERNAME";
private $_password = "PASSWORd";
@keks55
keks55 / testwrite_wp.php
Created April 10, 2018 07:01
If checked - write to file
function dpr_checkbox() {
global $dpr_option_name, $dpr_options;
if(is_array($dpr_options) && $dpr_options['disable'] == '1'){
echo "ON";
$file = site_url()."/"."license.txt";
$f = fopen('new.php', 'a+') or die('error open file');
for ($i=0; $i < 3; $i++){
fputs($f,"\n$i");
}
fclose($f);
@keks55
keks55 / ajaxformserialize.php
Created April 15, 2018 14:24
send wordpress ajax with form serialize
$(".mgm-ajax-form").on("submit", function(e){
e.preventDefault();
var form = $(this);
ajax$.ajax({
action: "mgm_insert_marker",
type: "post",
url: ajaxurl,
data: form.serialize(),
//_ajax_nonce: $("#_wpnonce").val(),
beforeSend: function(){
@keks55
keks55 / WP Customizer - Select
Created April 29, 2018 08:10 — forked from ajskelton/WP Customizer - Select
Add a Select field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_select_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_select',
'default' => 'value1',
) );
$wp_customize->add_control( 'themeslug_select_setting_id', array(
'type' => 'select',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Select Option' ),