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]

email mailto: pretext

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