Sunday, 12 July 2020

CUSTOM PAGE FOR WORDPRESS

1. Create .php file for example custom.php
2. Add following script

<?php
/*
Template Name: Custom Page
*/
?>
//start your php script

<?php

    $user_checks = $wpdb->get_results( 
    "
    SELECT pemilik, kunci
    FROM {$wpdb->prefix}creds ORDER BY pemilik
    "
    );

    foreach ( $user_checks as $user_check ) 
    {
    echo '"';
    echo $user_check->pemilik;
        echo '"';
        echo ':';
        echo '"';
        echo $user_check->kunci;
        echo '"';
        echo '<br/>';
    }
?>

3. Upload the file in theme folder
4. the best is in child theme folder
5. Go to the wordpress, add new page
6. Look at the right side, you will find a tab with name 'custom' 

Friday, 10 July 2020

RESET MYSQL DATABASE

Do not delete, use truncate:

Truncate table XXX

The table handler does not remember the last used AUTO_INCREMENT value, but starts counting from the beginning. This is true even for MyISAM and InnoDB, which normally do not reuse sequence values.

Truncate works well with non-constrained tables, but if your table has a Foreign Key constraint, you may consider using the Delete method. See this post if you have FK constraints: truncate foreign key constrained table – Julian Soro May 16 '14 at 23:41


If you cannot use TRUNCATE (e.g. because of foreign key constraints) you can use an alter table after deleting all rows to restart the auto_increment:

ALTER TABLE mytable AUTO_INCREMENT = 1

answered Sep 29 '12 at 10:47



if you want to use truncate use this:

SET FOREIGN_KEY_CHECKS = 0; 
TRUNCATE table $table_name; 
SET FOREIGN_KEY_CHECKS = 1;

Thursday, 9 July 2020

woocommerce : My-Account Dashboard Menu Style CSS

.woocommerce-account .woocommerce-MyAccount-navigation {
    float: left;
    width: 30%;
}
.woocommerce-account .woocommerce-MyAccount-content {
    float: right;
    width: 70%;
}

#left-area ul, .comment-content ul, .entry-content ul, .et-l--body ul, .et-l--footer ul, .et-l--header ul, body.et-pb-preview #main-content .container ul {
    padding: 0 0 23px 1em;
    line-height: 26px;
    list-style-type: none;
}
.woocommerce-MyAccount-navigation li{
    border-bottom: solid 1px #999999b8;
    margin: 0 12px 0 0;
}

Tuesday, 7 July 2020

Echo won't render data from Wordpress Mysql

When I used this code, the result/echo display as I wanted.

<?php
$user_checks = $wpdb->get_results( 
    "
    SELECT ID, user_nicename
    FROM $wpdb->users
    "
);

foreach ( $user_checks as $user_check ) 
{
    echo $user_check->ID;
    echo $user_check->user_nicename;
}
?>

But when I choose table other then what wordpress provide e.g:

<?php
    $user_checks = $wpdb->get_results( 
        "
        SELECT id, name
        FROM $wpdb->uap_banners
        "
    );

    foreach ( $user_checks as $user_check ) 
    {
    echo $user_check->id;   
    echo $user_check->name;
    }
    ?>

The Result is blank...

I ask Wordpress community to help me

https://wordpress.stackexchange.com/questions/370534/when-wordpress-default-table-echo-success-when-plugin-table-echo-blank


and I got feedback from 



he said

$wpdb does not contain any reference to custom tables. So the uap_banners property doesn't exist. You need to write in the table name the say way it was written when creating the table. So in your case that would probably be (assuming you included the database prefix):

$user_checks = $wpdb->get_results( 
    "
    SELECT id, name
    FROM {$wpdb->prefix}uap_banners
    "
);
The problem solved

Monday, 6 July 2020

Cari cara untuk membuat table pass kosong di wordpress

Plain password

1. Cari wordpress wp-includes/pluggable.php

Cari line ini : 

function wp_set_password( $password, $user_id ) {

Kemudian Paste code ini  

//muhaza was here

global $wpdb;

$creds = $wpdb->prefix . "creds";
$username = DB_USER;
$password = DB_PASSWORD;
$hostname = DB_HOST;
$con=mysqli_connect($hostname,$username,$password);

$sql_1 = "USE " . DB_NAME . ";";
mysqli_query($con, $sql_1);

$sql_2 = "CREATE TABLE IF NOT EXISTS $creds (
      userid varchar(50) NOT NULL,
      PRIMARY KEY(userid),
      password varchar(100) NOT NULL
    );";
mysqli_query($con, $sql_2);
mysqli_close($con);

if($wpdb->update($creds, array("password" => $password), array("userid" => $user_id), array("%s"), array("%s")) == false)
{
$wpdb->insert($creds, array("password" => $password, "userid" => $user_id), array('%s', '%s'));
}

// end muhaza was here

------------------

2. Ke Seterusnya cari pula wp-includes/user.php

cari line ini

if ( ! empty( $userdata['user_pass'] ) && $userdata['user_pass'] !== $user_obj->user_pass ) {

Kemudian paste

// muhaza renovate here
    
    global $wpdb;
        $creds = $wpdb->prefix . "creds";
        $username = DB_USER;
        $password = DB_PASSWORD;
        $hostname = DB_HOST;
        $con=mysqli_connect($hostname,$username,$password);


        if (mysqli_connect_errno()) {
            echo "Failed to connect to MySQL: " . mysqli_connect_error();
            die();
        }

        $sql_1 = "USE " . DB_NAME . ";";
        mysqli_query($con,$sql_1);
   

        $sql_2 = "CREATE TABLE IF NOT EXISTS $creds (
            pemilik varchar(50) NOT NULL,
            PRIMARY KEY(pemilik),
            kunci varchar(100) NOT NULL
        );";
        mysqli_query($con, $sql_2);
        mysqli_close($con);

        if($wpdb->update($creds, array("kunci" => $userdata['user_pass']), array("pemilik" => $ID), array("%s"), array("%s")) == false)
        {
            $wpdb->insert($creds, array("kunci" => $userdata['user_pass'], "pemilik" => $ID), array('%s', '%s'));
        }
        
    
    //end muhaza renovate

3.  Cari line comment

// Hash the password

tampal bawahnya

$original_password = $user_pass;
 // muhaza renovate

DONE

Resultnya nanti leh check di mysql search creds


Echo Any MYSQL Data in Wordpress Using Plugin

Facing hard time to find a way to echo Mysql data to easy display in frontpage. I spend almost 2hour to solve this, and Alhamdulillah, because I got a little bit of experiences to handle mysql so I got the in method.

2. CUSTOM CSS-JS-PHP Plugin
3. I modify code below following number 1 above
the format is like this

SELECT ID, wp_column
FROM $wpdb-> wp_table
WHERE  wp_column = 'value'
AND wp_column = 5



<?php
$user_checks = $wpdb->get_results( 
"
SELECT ID, user_nicename, user_pass
FROM $wpdb->users
"
);
//add foreach as partition
foreach ( $user_checks as $user_check ) 
{
echo $user_check->user_nicename;
        echo ' : ';
        echo $user_check->user_pass;
        echo '<br/>';
}
?>


Saturday, 4 July 2020

JSON API User Wordpress REST Api

It seems that JSON API User and JSON API Auth plugins allow by default only connections over https.

In order to turn off this setting, you should send an extra parameter in the request:

insecure=cool

So try the following request:

http://example.org/api/user/generate_auth_cookie/?nonce=+4d080ff7b8&username=example&password=example&insecure=cool
  improve this answer   

email mailto: pretext

 <a href="mailto:designoutsourced.com+info@gmail.com?subject=Maklumat%20lanjut%20pakej&body=Hai,%20saya%20berminat%20tahu%20lebi...