iframe {
position: fixed;
background: #000;
border: none;
top: 0; right: 0;
bottom: 0; left: 0;
width: 100%;
height: 100%;
}</style>
All muhaza's note in developing website. Front-end & uiux method. Real life implementation for webdesigner.
<?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
**********************************************************************************/
?>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
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:
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.
PAGE 1
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.
<!--/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
within an iframe
:Create the iframe
with a name.
<iframe name="theFrame"></iframe>
Now use the script
this way:
window.open(url, "theFrame");
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);
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' );
<?php
$username = $_GET['txtUsername'];
//url.php?txtUsername=nama%20saya
echo "username is " . $username;
$email = $_GET['txtEmail'];
$password = $_GET['txtPassword'];
$ConfPassword = $_GET['txtConfirmPassword'];
?>
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>
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); ?>
[ { "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.
require_once( get_stylesheet_directory(). '/woocommerce.php' );
require_once( get_stylesheet_directory(). '/widget.php' );
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 ; } } |
$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'];
}
iframe { | |
position: fixed; | |
background: #000; | |
border: none; | |
top: 0; right: 0; | |
bottom: 0; left: 0; | |
width: 100%; | |
height: 100%; | |
} |
<?php if( current_user_can('editor') || current_user_can('administrator') ) {
// Stuff here for administrators or editors
} ?>
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();
}
?>
//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' ));
}
<a href="mailto:designoutsourced.com+info@gmail.com?subject=Maklumat%20lanjut%20pakej&body=Hai,%20saya%20berminat%20tahu%20lebi...