Sunday, 29 November 2020

Iframe css full width

 <style>
iframe {
    position: fixed;
    background: #000;
    border: none;
    top: 0; right: 0;
    bottom: 0; left: 0;
    width: 100%;
    height: 100%;
}</style>

Saturday, 21 November 2020

DOUBLE LAYER IMAGE USING CSS WORK AS WATERMARK

.overlayer {
  height: 100%;
  width: 100%;
background-repeat: repeat;
  position: relative;
}

.overlayer:after {
  content: " ";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
height: 100%;
background-size:cover;
  background-image: url(https://dev.feqjaafar.com/wp-content/uploads/2020/11/Oyen-Ramaix300.png);
background-repeat: repeat;
  background-color: rgba(255, 255, 255, 0.4);
  background-blend-mode: lighten;
opacity:80%
}

PHP Wordpress Author Image

 <div class="author-image">
<?php
$get_author_id = get_the_author_meta('ID');
$get_author_gravatar = get_avatar_url($get_author_id, array('size' => 300));

if(has_post_thumbnail()){
    the_post_thumbnail();
} else {
    echo '<img src="'.$get_author_gravatar.'" alt="'.get_the_title().'" />';
}
?></div>

Tuesday, 17 November 2020

WORPDRESS AUTHOR IMAGE PHP

 <div class="author-image"><?php
$get_author_id = get_the_author_meta('ID');
$get_author_gravatar = get_avatar_url($get_author_id, array('size' => 300));
if(has_post_thumbnail()){
    the_post_thumbnail();
} else {
    echo '<img src="'.$get_author_gravatar.'" alt="'.get_the_title().'" />';
}
?></div>

Friday, 13 November 2020

MUHAZA CODE WP FUNCTION PHP

 <?php


function add_cors_http_header(){

    header("Access-Control-Allow-Origin: *");

}

add_action('init','add_cors_http_header');


/*********************************************************************************

Change expired date to 3hour

**********************************************************************************/


// function keep_me_logged_in_for_1_year( $expirein ) {

// return 3600; // 1 year in seconds

// }

// add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year' );



/*********************************************************************************

Redirect member to member page

**********************************************************************************/

function my_login_redirect( $redirect_to, $request, $user ) {

    //is there a user to check?

    global $user;

    if ( isset( $user->roles ) && is_array( $user->roles ) ) {

        //check for admins

        if ( in_array( 'free member', $user->roles ) ) {

            $redirect_to = '/member';

        } 

    } 

    return $redirect_to;

}


add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );


/*********************************************************************************

Change Role to Pengedar If Purchase Package 

**********************************************************************************/

    

add_action( 'woocommerce_order_status_completed', 'change_member_to_pengedar' );

function change_member_to_pengedar( $order_id ) {

//

    $order = wc_get_order( $order_id );

    $items = $order->get_items();

    $products_to_check = array( '2559','2205','2207','2209','2211','2213','2226','2227','2230','2450','2444','2235','2237','2238','2239','2240');

    foreach ( $items as $item ) {

        if ( $order->user_id > 0 && in_array( $item['product_id'], $products_to_check )) {

            $user = new WP_User( $order->user_id );

            // Change role

            $user->remove_role( 'free member' );

$user->remove_role( 'subscriber' );

            $user->add_role( 'pengedar' );

            $user->add_role( 'customer' );

            break;

        }

    }

};

################################################################################

/*********************************************************************************

Change Role to Free Member If Purchase Product

**********************************************************************************/

    

add_action( 'woocommerce_order_status_completed', 'change_customer_to_member' );

function change_customer_to_member( $order_id ) {

//

    $order = wc_get_order( $order_id );

    $items = $order->get_items();

    $products_to_check = array('2203','2204','2206','2208','2217','2210','2212','2214','2215','2216','2228','2229','2449','2303','2232','2236','2218','2219','2220','2221','2222','2223','2224','2225','2231');

    foreach ( $items as $item ) {

        if ( $order->user_id > 0 && in_array( $item['product_id'], $products_to_check )) {

            $user = new WP_User( $order->user_id );

            // Change role

$user->remove_role( 'subscriber' );

            $user->add_role( 'free member' );

            $user->add_role( 'customer' );

            break;

        }

    }

};

################################################################################

/*********************************************************************************

Empty Cart Text Change

**********************************************************************************/

remove_action( 'woocommerce_cart_is_empty', 'wc_empty_cart_message', 10 );

add_action( 'woocommerce_cart_is_empty', 'custom_empty_cart_message', 10 );


function custom_empty_cart_message() {

    $html  = '<div class="col-12 offset-md-1 col-md-10"><p class="cart-empty">';

    $html .= wp_kses_post( apply_filters( 'wc_empty_cart_message', __( 'Cart Anda Kosong. Sila Buat Pembelian.', 'woocommerce' ) ) );

    echo $html . '</p></div>';

}


//return to shop change

add_filter( 'gettext', 'change_woocommerce_return_to_shop_text', 20, 3 );

function change_woocommerce_return_to_shop_text( $translated_text, $text, $domain ) {

       switch ( $translated_text ) {

                      case 'Return to shop' :

   $translated_text = __( 'Kembali Ke List Barang', 'woocommerce' );

   break;

  }

 return $translated_text; 


}


//redirect to #id

/*

add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );

function custom_add_to_cart_redirect() { 

    return '#pagecart'; 

break;

}*/



//masukkan data dalam column setiap kali dia login

    global $wpdb;

$pokemon = $current_user->ID;

$pengedar = 'pengedar';

$free_member = 'free member';

$hq_admin = 'admin';

if(current_user_can('administrator') ) {

$wpdb->update( 'wpmt_semak', array( 'peranan' => $hq_admin), array( 'pemilik' => $pokemon ), array( '%s' ));

}

if(current_user_can('pengedar') ) {

$wpdb->update( 'wpmt_semak', array( 'peranan' => $pengedar), array( 'pemilik' => $pokemon ), array( '%s' ));

}

if( current_user_can('subscriber') || current_user_can('free member') ) {

$wpdb->update( 'wpmt_semak', array( 'peranan' => $free_member), array( 'pemilik' => $pokemon ), array( '%s' ));

}



//masukkan data dalam column setiap kali dia login


/*

//API abang alias

function trigger_the_functions() {

  if( is_page( 26620000 ) ) {


    //start triggering

$username = $_GET['txtUsername'];

    //url.php?txtUsername=nama%20saya

echo "username is " . $username;

    $email = $_GET['txtEmail'];

    $password = $_GET['txtPassword'];

    $ConfPassword = $_GET['txtConfirmPassword'];

    

    //get_header();

    global $wpdb;

    $username = $wpdb->escape($_GET['txtUsername']);

    $email = $wpdb->escape($_GET['txtEmail']);

    $password = $wpdb->escape($_GET['txtPassword']);

    $ConfPassword = $wpdb->escape($_GET['txtConfirmPassword']);


    $error = array();

    if (strpos($username, ' ') !== FALSE) {

        $error['username_space'] = "Username has Space";

    }


    if (empty($username)) {

        $error['username_empty'] = "Username is empty";

    }


    if (username_exists($username)) {

        $error['username_exists'] = "Username already exists";

    }


    if (!is_email($email)) {

        $error['email_valid'] = "Email has no valid value";

    }


    if (email_exists($email)) {

        $error['email_existence'] = "Email already exists";

    }


    if (strcmp($password, $ConfPassword) !== 0) {

        $error['password'] = "Password didn't match";

    }


    if (count($error) == 0) {

        wp_create_user($username, $password, $email);

        echo "User Created Successfully";

        exit();

    }else{

        print_r($error);

    }

    //end abang alias

       

}

}

add_action( 'wp', 'trigger_the_functions' );

*/


################################################################################

/*********************************************************************************

Extra tab

**********************************************************************************/

/**

 * @donate     https://businessbloomer.com/bloomer-armada/

 */

  

// ------------------

// 1. Register new endpoint to use for My Account page

// Note: Resave Permalinks or it will give 404 error

  

// function muhaza_add_extra_tab_endpoint() {

//     add_rewrite_endpoint( 'extra-tab', EP_ROOT | EP_PAGES );

// }

// add_action( 'init', 'muhaza_add_extra_tab_endpoint' );

// ------------------

// 2. Add new query var

// function muhaza_extra_tab_query_vars( $vars ) {

//     $vars[] = 'extra-tab';

//     return $vars;

// } 

// add_filter( 'query_vars', 'muhaza_extra_tab_query_vars', 0 );

// ------------------

// 3. Insert the new endpoint into the My Account menu

// function muhaza_add_extra_tab_link_my_account( $items ) {

//     $items['extra-tab'] = 'Extra Tab';

//     return $items;

// }  

// add_filter( 'woocommerce_account_menu_items', 'muhaza_add_extra_tab_link_my_account' );

// ------------------

// 4. Add content to the new endpoint

// function muhaza_extra_tab_content() {

// echo '<h3>Premium WooCommerce Support</h3><p>Welcome to the WooCommerce support area. As a premium customer, you can submit a ticket should you have any WooCommerce issues with your website, snippets or customization. <i>Please contact your theme/plugin developer for theme/plugin-related support.</i></p>';

// echo do_shortcode( ' /* your shortcode here */ ' );

// }

// add_action( 'woocommerce_account_extra-tab_endpoint', 'muhaza_extra_tab_content' );

// Note: add_action must follow 'woocommerce_account_{your-endpoint-slug}_endpoint' format



################################################################################

/*********************************************************************************

Custom Widget Dashboard Note

**********************************************************************************/

add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');

 

function my_custom_dashboard_widgets() {

global $wp_meta_boxes;

 

wp_add_dashboard_widget('custom_help_widget', 'Theme Support', 'custom_dashboard_help');

}

 

function custom_dashboard_help() {

echo '<p>Welcome to Custom Blog Theme! Need help? Contact the developer <a href="mailto:yourusername@gmail.com">here</a>. For WordPress Tutorials visit: <a href="https://www.wpbeginner.com" target="_blank">WPBeginner</a></p>';

}



################################################################################

/*********************************************************************************

Enable shortcodes in text widgets

**********************************************************************************/

add_filter('widget_text','do_shortcode');


################################################################################

/*********************************************************************************

test function role 8 echo get_user_role ( $current_user->ID );

**********************************************************************************/

function get_user_role($user_id) {

global $wp_roles;


$roles = array();

$user = new WP_User( $user_id );

if ( !empty( $user->roles ) && is_array( $user->roles ) ) {

foreach ( $user->roles as $role )

$roles[] .= translate_user_role( $role );

}

return implode(', ',$roles);



################################################################################

/*********************************************************************************

display total weight

**********************************************************************************/

function bbloomer_print_cart_weight() {

   $notice = 'Your cart weight is: ' . WC()->cart->get_cart_contents_weight() . get_option( 'woocommerce_weight_unit' );

   if ( is_cart() ) {

      wc_print_notice( $notice, 'notice' );

   } else {

      wc_add_notice( $notice, 'notice' );

   }

}

add_action( 'woocommerce_before_checkout_form', 'bbloomer_print_cart_weight' );

add_action( 'woocommerce_before_cart', 'bbloomer_print_cart_weight' );



################################################################################

/*********************************************************************************

Change Direction of Continue Shopping BUtton

**********************************************************************************/

add_filter( 'woocommerce_continue_shopping_redirect', 'bbloomer_change_continue_shopping' );

 

function bbloomer_change_continue_shopping() {

   return wc_get_page_permalink( 'shop' );

}


################################################################################

/*********************************************************************************

Add "Add to Cart" buttons in Divi shop pages

**********************************************************************************/

add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 20 );


################################################################################

/*********************************************************************************

modify REST api

**********************************************************************************/

add_filter( 'rest_user_query' , 'custom_rest_user_query' );

function custom_rest_user_query( $prepared_args, $request = null ) {

  unset($prepared_args['has_published_posts']);

  return $prepared_args;

}

//modify REST api

//add role on REST api

function get_user_roles($object, $field_name, $request) {

  return get_userdata($object['id'])->roles;

}


add_action('rest_api_init', function() {

  register_rest_field('user', 'roles', array(

    'get_callback' => 'get_user_roles',

    'update_callback' => null,

    'schema' => array(

      'type' => 'array'

    )

  ));

});



/** Modify url base from wp-json to 'api'*/

//function changeRestPrefix() {

//return "persadajson"; //become persadaherbs.com/persadajson/wp/v2/

//}

//add_filter( 'rest_url_prefix', 'changeRestPrefix');



################################################################################

/*********************************************************************************

PersadaHerbs_enqueue_child_styles

**********************************************************************************/

if ( ! function_exists( 'suffice_child_enqueue_child_styles' ) ) {

function PersadaHerbs_enqueue_child_styles() {

    // loading parent style

    wp_register_style(

      'parente2-style',

      get_template_directory_uri() . '/style.css'

    );


    wp_enqueue_style( 'parente2-style' );

    // loading child style

    wp_register_style(

      'childe2-style',

      get_stylesheet_directory_uri() . '/style.css'

    );

    wp_enqueue_style( 'childe2-style');

}

}

add_action( 'wp_enqueue_scripts', 'PersadaHerbs_enqueue_child_styles' );

/*********************************************************************************

PersadaHerbs_enqueue_child_styles

**********************************************************************************/


?>

Wednesday, 4 November 2020

HTACCESS FORCE SSL WWW

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]

Wednesday, 21 October 2020

Change windows drive from GPT to MBR

 Step 1. Turn off the PC and put in the Windows installation DVD or USB.

Step 2. Boot the PC from the DVD or USB.

Step 3. In Windows Setup, press "Shift + F10" to start Command Prompt.

Step 4. Enter the following command in order:

  • diskpart
  • list disk
  • select disk <disk number>
  • clean
  • convert gpt
  • exit

Step 5. Close Command Prompt.

Step 6. Continue the Windows installation.

Click to copy the command you'll need to convert MBR to GPT throughout the process:

-------

diskpart

list disk

select disk <disk number>

clean

convert gpt

exit

-----

After the conversion, the drive will appear as a single area of unallocated space. Choose the unallocated space and click Next. Windows will begin the installation without sending the same error.

Wednesday, 7 October 2020

LocalStorage Into Deep

 https://javascript.info/localstorage

Basic LocalStorage Full Code Test

PAGE 1

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input id="qweInputed" value=""><button onclick="qweclick()">Save Me</button>
    <button onclick="qweRemove()">Remove</button>
    <script>
        function qweclick() {
            var getInput = document.getElementById("qweInputed").value;
            alert(getInput + " success");
            localStorage.setItem("qweStorage"getInput);
        }

        function qweRemove() {
            alert("remove succeed");
            localStorage.removeItem("qweStorage");
        }
    </script>
</body>

</html>


PAGE 2
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="loadStorage"></div>
    <script>
        window.onload = alert(localStorage.getItem("qweStorage"));
        window.onload = document.getElementById("loadStorage").innerHTML = localStorage.getItem("qweStorage");
    </script>
</body>

</html>

Basic LocalStorage

 Without reading your code but just your scenario, I would solve by using localStorage. Here's an example, I'll use prompt() for short.

On page1:

window.onload = function() {
   var getInput = prompt("Hey type something here: ");
   localStorage.setItem("storageName",getInput);
}

On page2:

window.onload = alert(localStorage.getItem("storageName"));

You can also use cookies but localStorage allows much more spaces, and they aren't sent back to servers when you request pages.

Monday, 5 October 2020

Link List Of Wordpress Functions 👍

 👉 https://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/

👉 https://wordpress.stackexchange.com/questions/1567/best-collection-of-code-for-your-functions-php-file

Get Input Value. Add into link. Open it. Function. Onclick

  <!--/test/-->

                    <button onclick="fqweOpen()" class="woocommerce-button button woocommerce-form-login__submit">Function</button>

                    <div id="demome">Hello</div>

                    <script>

                    function fqweOpen(){

                    var qwex = document.getElementById("username").value;

                    var qwey = document.getElementById("password").value;

                    var qwez = "u=" + qwex + "&" + "p=" + qwey;

                   document.getElementById("demome").innerHTML = qwez;

                     window.open('https://www.persada.com.my/stock/apiloginasp2v2.asp?'+ qwez, "_blank");

                    }

                    </script>


Get Input Value. Add into link. Open it. Function. Onclick

window.open in Iframe - Iframe window

 

If you want to open a window within an iframe:

  1. Create the iframe with a name.

     <iframe name="theFrame"></iframe>
    
  2. Now use the script this way:

     window.open(url, "theFrame");
    
  improve this answer   

Saturday, 3 October 2020

Custom selector like jquery document.querySelector

 var query = document.querySelector.bind(document);

var queryAll = document.querySelectorAll.bind(document);
var fromId = document.getElementById.bind(document);
var fromClass = document.getElementsByClassName.bind(document);
var fromTag = document.getElementsByTagName.bind(document);

Thursday, 1 October 2020

Wordpress Functions for certain page

  1. add this on functions.php 


function sv_hide_header_footer_for_page() {

  if( is_page( 2662 ) ) {

echo '<div class="coupon-notice">Thanks for visiting! As a gift, here\'s a coupon code you can use in our shop: <code>20off</code></div>';

}

}

add_action( 'wp', 'sv_hide_header_footer_for_page' );

Wednesday, 30 September 2020

Browser API PHP get from php script

 <?php


$username = $_GET['txtUsername'];

//url.php?txtUsername=nama%20saya

echo "username is " . $username;

    $email = $_GET['txtEmail'];

    $password = $_GET['txtPassword'];

    $ConfPassword = $_GET['txtConfirmPassword'];

?>

Tuesday, 29 September 2020

Redirect Error Page HTTP to HTTPS

1. Open Cpanel 

2. Go to Error Page

3. Open any of the error and put this code

4. change the url


<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<script>location.href = 'https://korodklothing.com';</script>

</head>

<body></body>

</html>

PHP MYSQL TO JSON

https://www.opentechguides.com/how-to/article/php/100/mysql-to-json.html

<?php

// Initialize variable for database credentials
$dbhost = 'hostname';
$dbuser = 'username';
$dbpass = 'password';
$dbname = 'sakila';

//Create database connection
  $dblink = new mysqli($dbhost, $dbuser, $dbpass, $dbname);

//Check connection was successful
  if ($dblink->connect_errno) {
     printf("Failed to connect to database");
     exit();
  }

//Fetch 3 rows from actor table
  $result = $dblink->query("SELECT * FROM actor LIMIT 3");

//Initialize array variable
  $dbdata = array();

//Fetch into associative array
  while ( $row = $result->fetch_assoc())  {
	$dbdata[]=$row;
  }

//Print array in JSON format
 echo json_encode($dbdata);
 
?>

Result:


[
	{
	"actor_id":"1",
	"first_name":"PENELOPE",
	"last_name":"GUINESS",
	"last_update":"2006-02-15 04:34:33"
	},
	{	
	"actor_id":"2",
	"first_name":"NICK",
	"last_name":"WAHLBERG",
	"last_update":"2006-02-15 04:34:33"
	},
	{
	"actor_id":"3",
	"first_name":"ED",
	"last_name":"CHASE",
	"last_update":"2006-02-15 04:34:33"
	}
]

As you can see, the result is a valid JSON. You may use this in combination with Jquery/AJAX to pass database data to a web application that expects data in JSON.

Friday, 25 September 2020

Add multiple Functions.php wordpress

require_once( get_stylesheet_directory(). '/woocommerce.php' ); 

require_once( get_stylesheet_directory(). '/widget.php' ); 

Thursday, 24 September 2020

HOW TO BACKUP AND RESTORE WHATSAPP DB

  1.   Buka ko punya whatsapp folder
  2. Cari file .db di backup
  3. ganti dengan .db sedia ada, rename ikut sama

Thursday, 10 September 2020

UNBREAK DIVI CSS COLUMN

 Below is the code

@media only screen and (max-width: 980px) {
 
.two-columns .et_pb_column {
width: 50%!important;
}
 
.three-columns .et_pb_column {
width: 33.33%!important;
}
 
.four-columns .et_pb_column {
width: 25%!important;
}
}
Take the first class example three-columns, copy without dot. And paste in divi column id/class

Sunday, 6 September 2020

Wordpress Dashboard Widget. Multiple

 $helloMuhaza = 'Hello, Muhaza Nak Letak Something Sini'.' <a href="/">a</a>';


add_action( 'wp_dashboard_setup', 'muhaza_widget_001' );

function muhaza_widget_001() {

    wp_add_dashboard_widget(

        'muhaza_001_dashboard_widget',/*nama widget*/

        'Widget Muhaza 001',/*Screen Option Button*/

        'muhaza_widget_001_display'/*function*/

    );

}


function muhaza_widget_001_display() {

    echo $GLOBALS['helloMuhaza'];

}


//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

add_action( 'wp_dashboard_setup', 'muhaza_widget_002' );

function muhaza_widget_002() {

    wp_add_dashboard_widget(

        'muhaza_002_dashboard_widget',/*nama widget*/

        'Widget Muhaza 002',/*Screen Option Button*/

        'muhaza_widget_002_display'/*function dalam*/

    );

}


function muhaza_widget_002_display() {

    echo $GLOBALS['helloMuhaza'];

}


Full width IFrame

 

iframe {
position: fixed;
background: #000;
border: none;
top: 0; right: 0;
bottom: 0; left: 0;
width: 100%;
height: 100%;
}

Saturday, 5 September 2020

If current User (Role) Execute Code

<?php if( current_user_can('editor') || current_user_can('administrator') ) { 

    // Stuff here for administrators or editors

} ?>

Wednesday, 2 September 2020

WP Function Add_Action Redirect If !Not Logged In

Template Redirect → function → member only → If open page → Not Logged In → redirect to home url


 <?php

add_action('template_redirect','members_only');

function members_only(){

if( is_page('page-slug') && ! is_user_logged_in()){

wp_redirect( home_url());

die();

}

?>

Monday, 31 August 2020

Add data into wpdb Column when user login

//how to update current user role in custom user column inside wpdb.
//update must effect only the current user

global $wpdb;
$user_Tag = $current_user->ID; //ID hook
$push_status = 'customer'; // custom string

if(current_user_can('customer') ) {$wpdb->update( 'wpdb_table_name', array( 'wpdb_role_column' =>$push_status), array( 'wpdb_id_column' => $user_Tag ), array( '%s' ));
}

email mailto: pretext

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