Skip to content

Instantly share code, notes, and snippets.

View melvinstanly's full-sized avatar
🌪️
Fast and Furious

Melvin Stanly melvinstanly

🌪️
Fast and Furious
View GitHub Profile
@melvinstanly
melvinstanly / get-included-files.php
Created March 21, 2019 07:07
Get all php files added using include or require
<?php
$included_files = get_included_files();
foreach ($included_files as $filename) {
if( strpos( $filename, 'file_name') !== false ){ //Check if filename
echo $filename.'<br>';
}
}
<?php
if( is_wc_endpoint_url( 'order-received' ) ){
//To check if thank you page
}
if(is_checkout()){
// Check if in checkout page
}
@melvinstanly
melvinstanly / outlook.txt
Created May 23, 2019 11:42
Outlook version and conditional rule
Outlook Conditionall rules
<!--[if gte mso 9]>
<style type="text/css">
/* Your Outlook-specific CSS goes here. */
</style>
<![endif]-->
@melvinstanly
melvinstanly / tinymce-basic.php
Last active May 27, 2019 12:49
Setup a tinymce editor for a textarea
<?php
$settings = array(
'textarea_name' => 'c_name',
'quicktags' => array( 'buttons' => 'em,strong,link' ),
'tinymce' => array(
'theme_advanced_buttons1' => 'bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,undo,redo,separator',
'theme_advanced_buttons2' => '',
),
'editor_css' => '<style>#wp-excerpt-editor-container .wp-editor-area{height:175px; width:100%;}</style>',
);
<?php
// Get all posts of a custom post type and list a specific meta value from the posts
public function section_above_applicant_listings(){
global $wpdb;
$key = 'thjmf_applicant_job_relation';
$post_type = 'thjmf_applicants';
$query = "
SELECT DISTINCT($wpdb->postmeta.meta_value)
<?php
// function for user capability check
function is_user_capable(){
$capable = false;
$user = wp_get_current_user();
$allowed_roles = array('editor', 'administrator');
if( array_intersect($allowed_roles, $user->roles ) ) {
$capable = true;
}
@melvinstanly
melvinstanly / flex.txt
Last active July 26, 2021 10:57
CSS Flex issues
If wrapper has flex applied and children is in the following structure
col1 col2 col3
And you want to break col3 to a new line, then apply flex-wrap:wrap to the wrapper and flex-basis:100% to the child who
should igonre the parent flex style (Here col3).
If still the childs are arranged as rows, then add width to other childs except which should ignore the flex style ( Here Col1 and Col 2)
@melvinstanly
melvinstanly / woo-email-status.php
Created November 14, 2019 10:01
wocommerce email status
<?php
// Code to find the type of email send
// if $email variable is available, then use,
if ( $email->id == 'cancelled_order' ) {}
if ( $email->id == 'customer_completed_order' ) {}
if ( $email->id == 'customer_invoice' ) {}
if ( $email->id == 'customer_new_account' ) {}
if ( $email->id == 'customer_note' ) {}
if ( $email->id == 'customer_on_hold_order' ) {}
<?php
/* Function : Skip wepo options for WPC WooCommerce Bundle plugin
Plugin : Extra product options (Themehigh), WPC Product Bundle
*/
function unset_file_upload_for_child_products( $skip, $cart_item_data, $product_id, $variation_id ){
if( isset( $cart_item_data['woosb_parent_id']) ){
return true;
}
return $skip;
@melvinstanly
melvinstanly / export-customer-usermeta.php
Created December 27, 2019 12:56
Add usermeta fields to customer Export (Skyverge)
<?php
// Functionality : Add usermeta fields to exported csv when exporting customers using WooCommerce Customer/Order/Coupon Export
plugin (Skyverge)
add_filter( 'wc_customer_order_csv_export_customer_headers', 'melvin_order_csv_export_customer_headers', 10, 2 );
add_filter( 'wc_customer_order_csv_export_customer_row', 'melvin_order_csv_export_customer_row', 10, 4 );
function setup_checkout_usermeta_fields(){
// Replace the below array with checkout field names that is set as usermeta