This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function cpm_defer_parsing_of_js ( $url ) { | |
if ( FALSE === strpos( $url, '.js' ) ) return $url; | |
if ( strpos( $url, 'jquery.js' ) ) return $url; | |
return "$url' defer='defer"; | |
} | |
add_filter( 'clean_url', 'cpm_defer_parsing_of_js', 11, 1 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE wp_options SET option_value = replace(option_value, 'http://live.com', 'http://localhost/example') WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wp_posts SET guid = replace(guid, 'http://live.com','http://localhost/example'); | |
UPDATE wp_posts SET post_content = replace(post_content, 'http://live.com', 'http://localhost/example'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_thankyou', 'woo_after_checkout', 10, 1 ); | |
function woo_after_checkout( $order_id ) { | |
$order_detail = new WC_Order( $order_id ); | |
$order_detail->get_billing_email(); | |
$order_detail->get_billing_first_name(); | |
$order_detail->get_billing_last_name(); | |
$order_detail->get_billing_company(); | |
foreach ( $order_detail->get_items() as $item_id => $item ) { | |
$product = $item->get_product(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myStringToDate(str) { | |
var arr = str.split("-"); // split string at slashes to make an array | |
var yyyy = arr[2] - 0; // subtraction converts a string to a number | |
var jsmm = arr[1] - 1; // subtract 1 because stupid JavaScript month numbering | |
var dd = arr[0] - 0; // subtraction converts a string to a number | |
return new Date(yyyy, jsmm, dd); // this gets you your date | |
} | |
var from_date = myStringToDate(jQuery('#from-date').val()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-Encoding: Windows-1252'); | |
header('Content-Type: text/csv; charset=Windows-1252'); | |
header('Content-Disposition: attachment; filename='.$filename.'.csv' );//$filename as name of a file that will be downloaded | |
$output = fopen($filepath, 'w');//$filepath as path to the directory where the file will reside. | |
fputcsv($output, array('arrays of column header')); | |
fputcsv($output, $insert_array); | |
fclose($output); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$items_per_page = 2; | |
$page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1; | |
$offset = ( $page * $items_per_page ) - $items_per_page; | |
$query = 'SELECT * FROM '.$table_name; | |
$total_query = "SELECT COUNT(1) FROM (${query}) AS combined_table"; | |
$total = $wpdb->get_var( $total_query ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//triggers before checkout form is submited but order will be created. | |
add_action( 'woocommerce_checkout_update_order_meta', 'cpm_woocommerce_checkout_update', 10, 2 ); | |
function cpm_woocommerce_checkout_update($order_id, $data) { | |
/*write ur code*/ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xhost +local: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
DocumentRoot "/var/www/html/first-wordpress/sub-domani" | |
ServerName local.wordpress.com.au | |
ErrorLog "/private/var/log/apache2/wordpress-error_log" | |
CustomLog "/private/var/log/apache2/wordpress-access_log" common | |
<Directory /var/www/html/first-wordpress/sub-domani> | |
Require all granted | |
Options Includes FollowSymLinks Indexes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'save_post', 'cpm_resume_manager_save_resume', 10, 2 ); | |
function cpm_resume_manager_save_resume($post_id, $post) { | |
if ( empty( $post_id ) || empty( $post ) || empty( $_POST ) ) return; | |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; | |
if ( is_int( wp_is_post_revision( $post ) ) ) return; | |
if ( is_int( wp_is_post_autosave( $post ) ) ) return; | |
if ( $post->post_type != 'resume' ) return; | |
} |