Skip to content

Instantly share code, notes, and snippets.

@mmilosheski
mmilosheski / gist:0ec054737f652bca9356
Created October 1, 2015 16:31
wordpress add to database table
/// HTML PAGE TEMPLATE SHOULD HAVE THIS CODE (KEEP IN MIND THAT THE INSERT.PHP IS IN THE TEMPLATE DIR
<form action="<?php echo get_template_directory_uri(); ?>/insert.php" method="post">
Name:<input type="text" name="name"/>
<input type="submit" name="submit"/>
</form>
/// THE INSERT.PHP FILE SHOULD HAVE THIS CODE
<?php
global $wpdb
$username = $_POST['fs_username'];
$password = $_POST['fs_password'];
echo "<pre>";
var_dump("Username: ", $username, "Password: ", $password);
echo "</pre>";
$api_login_url = "https://servicesbeta.fidelitysalus.it/v3/account/login";
$login_response = wp_remote_retrieve_body(wp_remote_post( $api_login_url, array(
'method' => 'POST',
/*mile test */
function make_filename_hash($filename) {
if( isset($_REQUEST['post_id']) ) {
$post_id = (int)$_REQUEST['post_id'];
}else{
$post_id=0;
}
$info = pathinfo($filename);
$ext = empty($info['extension']) ? '' : '.' . $info['extension'];
@mmilosheski
mmilosheski / hide-prices-logged-out-show-logged-in.php
Created January 11, 2017 09:41
Removes the prices on products when customer is not logged in.. Shows prices when the customer is logged in
<?php
// Hide prices
add_filter('woocommerce_get_price_html', 'show_price_logged');
function show_price_logged($price){
if(is_user_logged_in() ) {
return $price;
} else {
add_action( 'woocommerce_single_product_summary', 'print_login_to_see', 31 );
add_action( 'woocommerce_after_shop_loop_item', 'print_login_to_see', 11 );
UPDATE wp_options SET option_value = replace(option_value, 'http://sezavino.mk', 'https://sezavino.mk') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://ivankarangelova.com','https://sezavino.mk');
UPDATE wp_posts SET post_content = replace(post_content, 'http://ivankarangelova.com', 'https://sezavino.mk');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://ivankarangelova.com','https://sezavino.mk');
/* paste this into your functions.php of the theme */
/ * Join posts and postmeta tables */
function product_search_join( $join ) {
if( ! is_search() || ! is_woocommerce() ) {
return $join;
}
global $wpdb;
/*
modifiying the general wp_query and adding the suppress filters to be off all the time
*/
add_action( '__before_loop' , 'modify_main_wp_query1' );
add_action( '__after_loop' , 'modify_main_wp_query1' );
function modify_main_wp_query1() {
global $wp_query;
SET sql_mode = '';
ALTER TABLE wp_commentmeta AUTO_INCREMENT = (highest id + 1);
ALTER TABLE wp_comments AUTO_INCREMENT = (highest id + 1);
ALTER TABLE wp_et_bloom_stats AUTO_INCREMENT = (highest id + 1);
ALTER TABLE wp_et_social_stats AUTO_INCREMENT = (highest id + 1);
ALTER TABLE wp_failed_jobs AUTO_INCREMENT = (highest id + 1);
ALTER TABLE wp_links AUTO_INCREMENT = (highest id + 1);
ALTER TABLE wp_mailchimp_carts AUTO_INCREMENT = (highest id + 1);
ALTER TABLE wp_mailster_actions AUTO_INCREMENT = (highest id + 1);
function injectScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.async = true;
script.src = src;
script.addEventListener('load', resolve);
script.addEventListener('error', () => reject('Error loading script.'));
script.addEventListener('abort', () => reject('Script loading aborted.'));
document.head.appendChild(script);
});
@mmilosheski
mmilosheski / removed-css.css
Created August 15, 2017 11:54
removed-css.css
.sponsor-logo {
position: relative;
}
.sponsor-logo a {
display: block;
position: absolute;
margin-top: -44px;
padding-left: 0!important;
}
.sponsor-logo a span {