Skip to content

Instantly share code, notes, and snippets.

View man4toman's full-sized avatar
:octocat:
A Bit Git!

Morteza Geransayeh man4toman

:octocat:
A Bit Git!
View GitHub Profile
@man4toman
man4toman / snippet.php
Created March 17, 2022 06:21
Add custom CSS and JavaScript to Digits plugin's page
<?php
function add_custom_assets_to_digits_page() {
wp_register_script( 'myprefix-js', '', array("jquery"), '', true );
wp_enqueue_script( 'myprefix-js' );
wp_add_inline_script( 'myprefix-js', "JS goes here");
}
add_action( 'login_enqueue_scripts', 'add_custom_assets_to_digits_page', 99);
@man4toman
man4toman / form.html
Last active March 13, 2022 23:42
Google recaptcha v3 - JavaScript
<form method="post">
<div class="g-recaptcha" data-sitekey="SITE_KEY" data-callback="verifyCaptcha"></div>
<div id="g-recaptcha-error"></div>
<input type="button" class="submit" value="Submit" />
</form>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script>
var recaptcha_response = '';
@man4toman
man4toman / check.php
Created March 13, 2022 23:21
Google recaptcha v3 - PHP
<?php
if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])){
$secret_key = 'SECERET_KEY';
$verify_captcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret_key.'&response='.$_POST['g-recaptcha-response']);
$verify_response = json_decode($verify_captcha);
if($verify_response->success){
//success
}else{
@man4toman
man4toman / code.html
Created September 30, 2021 13:02
Floated join chat button for WhatsApp
<!-- HTML code -->
<div class="joinchat_button">
<a href="https://wa.me/98xxxxxx" class="joinchat_button_open" target="_blank"></a>
</div>
<!-- CSS code -->
.joinchat_button {
right: auto;
@man4toman
man4toman / woo-tabs.php
Created April 26, 2021 21:14 — forked from heldervilela/woo-tabs.php
WooCommerce Admin Custom Product Data Tab
// First Register the Tab by hooking into the 'woocommerce_product_data_tabs' filter
add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' );
function add_my_custom_product_data_tab( $product_data_tabs ) {
$product_data_tabs['my-custom-tab'] = array(
'label' => __( 'My Custom Tab', 'woocommerce' ),
'target' => 'my_custom_product_data',
'class' => array( 'show_if_simple' ),
);
return $product_data_tabs;
}
<?php
if(!function_exists('http_build_url'))
{
// Define constants
define('HTTP_URL_REPLACE', 0x0001); // Replace every part of the first URL when there's one of the second URL
define('HTTP_URL_JOIN_PATH', 0x0002); // Join relative paths
define('HTTP_URL_JOIN_QUERY', 0x0004); // Join query strings
define('HTTP_URL_STRIP_USER', 0x0008); // Strip any user authentication information
define('HTTP_URL_STRIP_PASS', 0x0010); // Strip any password authentication information
define('HTTP_URL_STRIP_PORT', 0x0020); // Strip explicit port numbers
@man4toman
man4toman / wc-reorder-fields-checkout-page.php
Last active March 5, 2020 15:07
WooCommerce move reorder fields checkout page
<?php
add_filter( 'woocommerce_default_address_fields', 'wc_reorder_fields_checkout_page' );
function wc_reorder_fields_checkout_page( $fields ) {
// default priorities:
// 'first_name' – 10
// 'last_name' – 20
// 'company' – 30
// 'country' – 40
@man4toman
man4toman / gist:4ffa6c3d1e6598156a507cb60d6cb9f5
Created November 24, 2019 10:56
Fix RTL Stretch(full-width) row in WPBakery Page Builder(Visual Composer) - CSS solution
body.rtl .vc_row[data-vc-full-width] {
position: relative;
width: 100vw !important;
right: 50% !important;
left: auto !important;
transform: translateX(50%) !important;
padding-left: calc( (100vw - 1140px) / 2 ) !important;
padding-right: calc( (100vw - 1140px) / 2 ) !important;
}
@media(max-width:767px){
//Credit to Stoyan Stefanov
location = location
location = location
location = location.href
location = window.location
location = self.location
location = window.location.href
location = self.location.href
location = location['href']
@man4toman
man4toman / blob2utf8.sql
Created October 16, 2018 13:12
Convert blob strings to utf8
#Note: This commands convert pure blob strings to utf8, if you use this commands on mixed strings, they didn't works as expected
alter table sending_info change message message LONGTEXT CHARACTER SET latin1;
alter table sending_info change message message LONGBLOB;
alter table sending_info change message message LONGTEXT CHARACTER SET utf8;