This file contains hidden or 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
/** | |
* Programmatically logs a user in | |
* | |
* @param string $username | |
* @return bool True if the login was successful; false if it wasn't | |
*/ | |
function programmatic_login( $username ) { | |
if ( is_user_logged_in() ) { | |
wp_logout(); |
This file contains hidden or 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 create_pages(){ | |
$awesome_page_id = get_option("awesome_page_id"); | |
if (!$awesome_page_id) { | |
//create a new page and automatically assign the page template | |
$post1 = array( | |
'post_title' => "Awesome Page!", | |
'post_content' => "", | |
'post_status' => "publish", | |
'post_type' => 'page', |
This file contains hidden or 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 print_r_reverse($in) { | |
$lines = explode("\n", trim($in)); | |
if (trim($lines[0]) != 'Array') { | |
// bottomed out to something that isn't an array | |
return $in; | |
} else { | |
// this is an array, lets parse it | |
if (preg_match("/(\s{5,})\(/", $lines[1], $match)) { | |
// this is a tested array/recursive call to this function | |
// take a set of spaces off the beginning |
This file contains hidden or 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 change_pass_frontend() { | |
require_once( ABSPATH . 'wp-includes/class-phpass.php'); | |
$old_pass = $_POST['old_pass']; | |
$new_pass = $_POST['new_pass']; | |
$user_id = $_POST['user_id']; | |
$user_data = get_userdata( $user_id ); | |
$wp_hasher = new PasswordHash(8, TRUE); | |
$password_hashed = $user_data->user_pass; | |
if($wp_hasher->CheckPassword($old_pass, $password_hashed)) { | |
wp_set_password( $new_pass, $user_id ); |
This file contains hidden or 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
{ | |
"always_show_minimap_viewport": true, | |
"bold_folder_labels": true, | |
"caret_extra_bottom": 3, | |
"caret_extra_top": 3, | |
"caret_extra_width": 2, | |
"enable_tab_scrolling": false, | |
"font_face": "Ubuntu Mono", | |
"font_options": | |
[ |
This file contains hidden or 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
add_filter('woocommerce_cart_item_subtotal','additional_shipping_cost',10,3); | |
function additional_shipping_cost($subtotal, $values, $cart_item_key) { | |
$custom_diposit_cost = get_post_meta($values['product_id'], 'deposit', true); | |
$ori_val = $values['line_total']; | |
if ($custom_diposit_cost) { | |
$total_item_cost = $ori_val-$custom_diposit_cost; | |
return woocommerce_price($total_item_cost); | |
} else { | |
return $subtotal; | |
} |
This file contains hidden or 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
add_filter ( 'woocommerce_before_cart' , 'allow_single_quantity_in_cart' ); | |
function allow_single_quantity_in_cart() { | |
global $woocommerce; | |
$cart_contents = $woocommerce->cart->get_cart(); | |
$keys = array_keys ( $cart_contents ); | |
foreach ( $keys as $key ) { | |
$woocommerce->cart->set_quantity ( $key, 1, true ); | |
} |
This file contains hidden or 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
To Enable: | |
gsettings set com.canonical.Unity always-show-menus true | |
To Disable: | |
gsettings set com.canonical.Unity always-show-menus false |
This file contains hidden or 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
ssh to server | |
cd your-repository.git | |
sudo chmod -R g+ws * | |
sudo chgrp -R yourgroup * | |
and maybe: | |
git repo-config core.sharedRepository true |
This file contains hidden or 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
jQuery(document).ready( function($) { | |
cpm_open_pointer(0); | |
function cpm_open_pointer(i) { | |
pointer = cpmPointer.pointers[i]; | |
options = $.extend( pointer.options, { | |
close: function() { | |
$.post( ajaxurl, { | |
pointer: pointer.pointer_id, | |
action: 'dismiss-wp-pointer' | |
}); |