Create a new WordPress admin user in the database via Cpanel phpmyadmin

INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'demo', MD5('demo'), 'Your Name', 'test@yourdomain.com', 'http://www.test.com/', '2011-06-07 00:00:00', '', '0', 'Your Name');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');

 

Advertisements

Woocomerce Add Additional Fee at checkout page in Radio Button+Select Options

FOR RADIO BUTTON

/**
* @snippet Dynamic Radio Buttons Fees - WooCommerce Checkout
* @how-to Watch tutorial @ https://businessbloomer.com/?p=19055
* @sourcecode https://businessbloomer.com/?p=79316
* @author Rodolfo Melogli
* @compatible WooCommerce 3.5.1
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/// Part 1
// Display Radio Buttons
// Uses woocommerce_form_field()add_action( 'woocommerce_review_order_before_payment', 'bbloomer_checkout_radio_choice' );

function bbloomer_checkout_radio_choice() {

$chosen = WC()->session->get('radio_chosen');
$chosen = empty( $chosen ) ? WC()->checkout->get_value('radio_choice') : $chosen;
$chosen = empty( $chosen ) ? 'no_option' : $chosen;

$args = array(
'type' => 'radio',
'class' => array( 'form-row-wide' ),
'options' => array(
'no_option' => 'No Option',
'option_1' => 'Option 1 ($10)',
'option_2' => 'Option 2 ($30)',
),
'default' => $chosen
);

echo '

';
echo '

Customize Your Order!

';
woocommerce_form_field( 'radio_choice', $args, $chosen );
echo '

';

}

// Part 2
// Add Fee and Calculate Total
// Based on session's "radio_chosen"

#2 Calculate New Total

add_action( 'woocommerce_cart_calculate_fees', 'bbloomer_checkout_radio_choice_fee', 20, 1 );

function bbloomer_checkout_radio_choice_fee( $cart ) {

if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;

$radio = WC()->session->get( 'radio_chosen' );

if ( "option_1" == $radio ) {
$fee = 10;
} elseif ( "option_2" == $radio ) {
$fee = 30;
}

$cart->add_fee( __('Option Fee', 'woocommerce'), $fee );

}

// Part 3
// Refresh Checkout if Radio Changes
// Uses jQuery

add_action( 'wp_footer', 'bbloomer_checkout_radio_choice_refresh' );

function bbloomer_checkout_radio_choice_refresh() {
if ( ! is_checkout() ) return;
?>

echo json_encode( $radio );
}
die();
}

FOR SELECT OPTION

/////////////////////////
/**
* @snippet Dynamic Radio Buttons Fees - WooCommerce Checkout
* @how-to Watch tutorial @ https://businessbloomer.com/?p=19055
* @sourcecode https://businessbloomer.com/?p=79316
* @author Rodolfo Melogli
* @compatible WooCommerce 3.5.1
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/

// Part 1
// Display Radio Buttons
// Uses woocommerce_form_field()

add_action( 'woocommerce_before_order_notes', 'bbloomer_checkout_radio_choice' );

function bbloomer_checkout_radio_choice() {

$chosen = WC()->session->get('radio_chosen');
$chosen = empty( $chosen ) ? WC()->checkout->get_value('radio_choice') : $chosen;
$chosen = empty( $chosen ) ? 'no_option' : $chosen;

$args = array(
'type' => 'select',
'class' => array( 'form-row-wide' ),
'options' => array(
'no_option' => 'No Option',
'option_1' => 'Option 1 ($10)',
'option_2' => 'Option 2 ($30)',
),
'default' => $chosen
);

echo '

';
echo '

Customize Your Order!

';
woocommerce_form_field( 'radio_choice', $args, $chosen );
echo '

';

}

// Part 2
// Add Fee and Calculate Total
// Based on session's "radio_chosen"

#2 Calculate New Total

add_action( 'woocommerce_cart_calculate_fees', 'bbloomer_checkout_radio_choice_fee', 20, 1 );

function bbloomer_checkout_radio_choice_fee( $cart ) {

if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;

$radio = WC()->session->get( 'radio_chosen' );

if ( "option_1" == $radio ) {
$fee = 10;
} elseif ( "option_2" == $radio ) {
$fee = 30;
}

$cart->add_fee( __('Shipping Charges', 'woocommerce'), $fee );

}

// Part 3
// Refresh Checkout if Radio Changes
// Uses jQuery

add_action( 'wp_footer', 'bbloomer_checkout_radio_choice_refresh' );

function bbloomer_checkout_radio_choice_refresh() {
if ( ! is_checkout() ) return;
?>

jQuery( function($){
$('form.checkout').on('change', 'select[name=radio_choice]', function(e){
e.preventDefault();
var p = $(this).val();
$.ajax({
type: 'POST',
url: wc_checkout_params.ajax_url,
data: {
'action': 'woo_get_ajax_data',
'radio': p,
},
success: function (result) {
$('body').trigger('update_checkout');
}
});
});
});

echo json_encode( $radio );
}
die();
}

unzip file, delete files and sub directories via PHP

// assuming file.zip is in the same directory as the executing script.
$file = ‘file.zip’;

// get the absolute path to $file
$path = pathinfo(realpath($file), PATHINFO_DIRNAME);

$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
// extract it to the path we determined above
$zip->extractTo($path);
$zip->close();
echo “WOOT! $file extracted to $path”;
} else {
echo “Doh! I couldn’t open $file”;
}

// delete al files including sub directory

function deleteAll($str) {
//It it’s a file.
if (is_file($str)) {
//Attempt to delete it.
return unlink($str);
}
//If it’s a directory.
elseif (is_dir($str)) {
//Get a list of the files in this directory.
$scan = glob(rtrim($str,’/’).’/*’);
//Loop through the list of files.
foreach($scan as $index=>$path) {
//Call our recursive function.
deleteAll($path);
}
//Remove the directory itself.
return @rmdir($str);
}
}

//call our function
deleteAll(‘temporary_files’);

Disable YOAST from specific page

add_action(‘wp_head’, ‘remove_all_wpseo_og’, 1);
function remove_all_wpseo_og() {
remove_action( ‘wpseo_head’, array( $GLOBALS[‘wpseo_og’], ‘opengraph’ ), 30 );
}

 

 

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

 

add_action(‘template_redirect’,’remove_wpseo’);

function remove_wpseo(){
if (is_page(4)) {
global $wpseo_front;
if(defined($wpseo_front)){
remove_action(‘wp_head’,array($wpseo_front,’head’),1);
}
else {
$wp_thing = WPSEO_Frontend::get_instance();
remove_action(‘wp_head’,array($wp_thing,’head’),1);
}
}
}

 

 

where 4 is page id