Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
A Bit Git!

Morteza man4toman

:octocat:
A Bit Git!
View GitHub Profile
@man4toman
man4toman / snippet.php
Created Mar 17, 2022
Add custom CSS and JavaScript to Digits plugin's page
View snippet.php
<?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 Mar 13, 2022
Google recaptcha v3 - JavaScript
View form.html
<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 Mar 13, 2022
Google recaptcha v3 - PHP
View check.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 Sep 30, 2021
Floated join chat button for WhatsApp
View code.html
<!-- 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 Apr 26, 2021 — forked from heldervilela/woo-tabs.php
WooCommerce Admin Custom Product Data Tab
View woo-tabs.php
// 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;
}
View http_build_url.php
<?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 Mar 5, 2020
WooCommerce move reorder fields checkout page
View wc-reorder-fields-checkout-page.php
<?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 Nov 24, 2019
Fix RTL Stretch(full-width) row in WPBakery Page Builder(Visual Composer) - CSS solution
View gist:4ffa6c3d1e6598156a507cb60d6cb9f5
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){
View 534-ways-to-reload-the-page-with-JavaScript.js
//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 / link-remover.php
Created Jul 5, 2019
Remove links from Topic Authors/Post Ccontent in standalone bbPress
View link-remover.php