Skip to content

Instantly share code, notes, and snippets.

View carl-alberto's full-sized avatar

Carl Alberto carl-alberto

View GitHub Profile
@carl-alberto
carl-alberto / wc-auth-net-cim-save-payment-method-default-checked.php
Last active August 27, 2015 06:19 — forked from maxrice/wc-auth-net-cim-save-payment-method-default-checked.php
WC Authorize.net CIM: On the payment form, default "securely save to account" checkbox to checked
<?php
// force the "securely save to account" checkbox to default to checked
function wc_auth_net_cim_save_payment_method_default_checked( $html, $form ) {
if ( empty( $html ) || $form->tokenization_forced() ) {
return $html;
}
return str_replace( 'type="checkbox"', 'type="checkbox" checked="checked"', $html );
}
@carl-alberto
carl-alberto / wordpress-create-user.php
Last active August 29, 2015 14:26
Create a user in WordPress from a php page/script outside of the WordPress system.
<?php
// [wp insert user « WordPress Codex](http://codex.wordpress.org/Function_Reference/wp_insert_user)
require_once "wordpress/wp-load.php";
$user_info = array(
"user_pass" => "test123",
"user_login" => "username",
"user_nicename" => "username",
"user_email" => "email@example.com",
@carl-alberto
carl-alberto / copy-file-from-url.php
Last active August 29, 2015 14:26
This simply copy a file from a url, useful when transferring a huge single zip file
<?php
$filename = "sample_filename.zip";
$file_to_be_copied = 'http://url_of_source.com/'.$filename;
$local_file_created = $_SERVER['DOCUMENT_ROOT'] . '/' . $filename;
if ( copy($file_to_be_copied, $local_file_created) ) {
echo 'Copy successfully in: ' .$local_file_created;
SELECT * FROM `stage_options` WHERE `option_name` LIKE '%wp_%';
RENAME TABLE stage_commentmeta to c2g_commentmeta;
RENAME TABLE stage_comments to c2g_comments;
RENAME TABLE stage_duplicator_packages to c2g_duplicator_packages;
RENAME TABLE stage_links to c2g_links;
RENAME TABLE stage_nf_objectmeta to c2g_nf_objectmeta;
RENAME TABLE stage_nf_objects to c2g_nf_objects;
RENAME TABLE stage_nf_relationships to c2g_nf_relationships;
RENAME TABLE stage_ninja_forms_fav_fields to c2g_ninja_forms_fav_fields;
@carl-alberto
carl-alberto / CreateWordpressUser.php
Created May 31, 2016 03:07 — forked from jawinn/CreateWordpressUser.php
Create WordPress Admin User from PHP
<?php
// ADD NEW ADMIN USER TO WORDPRESS
// ----------------------------------
// Put this file in your Wordpress root directory and run it from your browser.
// Delete it when you're done.
require_once('wp-blog-header.php');
require_once('wp-includes/registration.php');
// ----------------------------------------------------
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product')
DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
@carl-alberto
carl-alberto / functions.php
Last active July 24, 2016 18:39
Jetpack plugin carousel disable comments
<?php
function jetpack_carousel_disable_comment( $jpimages, $postid ) {
$posts = get_post( $postid );
if( $posts->post_type == 'attachment' ) {
return false;
}
return $jpimages;
@carl-alberto
carl-alberto / commands_to_add_fontawesome_via_bower.txt
Last active July 25, 2016 23:28
Commands to add fontawesome in your sage theme
//run this to download the latest fontawesome via bower
bower install --save fontawesome
//this will make sure that you have all necessary dependencies
npm install grunt-contrib-copy --save-dev
// after running the commands above, you will have this entry in your bower.json file
// "dependencies": {
// "bootstrap-sass": "3.3.6",
// "font-awesome": "fontawesome#^4.6.3"
@carl-alberto
carl-alberto / Excludes style and scripts that is uneeded in homepage
Last active July 27, 2016 08:02
Excludes style and scripts that is uneeded in homepage
if (is_front_page()) {
wp_dequeue_style( 'flick' );
wp_dequeue_style( 'mailchimpSF_main_css' );
wp_dequeue_style( 'skeleton' );
wp_dequeue_style( 'masonry' );
wp_dequeue_style( 'cff' );
wp_dequeue_script( 'datepicker' );
wp_dequeue_script( 'maxbuttons-front' );
wp_dequeue_script( 'mailchimpSF_main' );
@carl-alberto
carl-alberto / check_curl_and_openssl_if_enabled.php
Created August 4, 2016 16:43
How to check if your server has enabled CURL and OpenSSL using PHP
<?php
echo 'Curl: ', function_exists('curl_version') ? 'Enabled' : 'Disabled';
echo 'OpenSSL: ', extension_loaded('openssl') ? 'Enabled' : 'Disabled';
?>