Skip to content

Instantly share code, notes, and snippets.

View ApoGouv's full-sized avatar
🚧
work in progress

Apostolos Gouvalas ApoGouv

🚧
work in progress
View GitHub Profile
@ApoGouv
ApoGouv / wp-old-url-to-new-sql.txt
Last active September 20, 2018 07:09
WordPress MySQL change old URL to new one
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
@ApoGouv
ApoGouv / portfolio-cpt.php
Created March 27, 2018 10:20
WP - Custom Post Type - Example: 'Portfolio'
// Register Custom Post Type Portfolio
// Post Type Key: portfolio
function create_portfolio_cpt() {
$labels = array(
'name' => __( 'Portfolios', 'Post Type General Name', 'cube-cpt-portfolio' ),
'singular_name' => __( 'Portfolio', 'Post Type Singular Name', 'cube-cpt-portfolio' ),
'menu_name' => __( 'Portfolios', 'cube-cpt-portfolio' ),
'name_admin_bar' => __( 'Portfolio', 'cube-cpt-portfolio' ),
'archives' => __( 'Portfolio Archives', 'cube-cpt-portfolio' ),
@ApoGouv
ApoGouv / select-posts-and-K2-old-ID.sql
Created March 27, 2018 06:30
WP - FG Joomla to Wordpress
SELECT `p`.`ID`, `p`.`post_title`, `p`.`post_name`, `pm`.`meta_value`
FROM `wp_posts` AS `p`
LEFT JOIN `wp_postmeta` AS `pm` ON `p`.`ID` = `pm`.`post_id`
WHERE `post_type` = 'post'
AND `pm`.`meta_key` = '_fgj2wp_old_k2_id'
LIMIT 0, 100
@ApoGouv
ApoGouv / mask-theme-files.php
Created March 26, 2018 12:17
WP - Rewrites
function mask_theme_files_urls() {
$theme_name = next(explode('/themes/', get_stylesheet_directory()));
global $wp_rewrite;
$new_non_wp_rules = array(
'css/(.*)' => 'wp-content/themes/'. $theme_name . '/css/$1',
'js/(.*)' => 'wp-content/themes/'. $theme_name . '/js/$1',
'images/wordpress-urls-rewrite/(.*)' => 'wp-content/themes/'. $theme_name . '/images/wordpress-urls-rewrite/$1',
);
$wp_rewrite->non_wp_rules += $new_non_wp_rules;
@ApoGouv
ApoGouv / _price-equal-to-_sale_price.sql
Last active March 21, 2018 09:54
WordPress - WooCommerce product prices queries
/*
Update _price to be equal to _sales_price when there is a sales price set
*/
UPDATE `wp_postmeta` AS p
LEFT JOIN `wp_postmeta` AS sp ON p.post_id = sp.post_id
SET p.meta_value = sp.meta_value
WHERE p.meta_key = '_price'
AND sp.meta_key = '_sale_price'
AND sp.meta_value != ''
While in the OpenCart back-end, navigate to Customers>Customers and then open up a console and type:
$('input[name*=\'selected\']').prop('checked', true);
$('#form-customer').submit();
This will remove all customers from the current page.
(It's a quicker version of clicking to select all customers of the page and then the delete button and accept JS prompt box..)
@ApoGouv
ApoGouv / gravity-forms-notification-popup-keep-form.php
Last active September 2, 2017 11:42 — forked from anythinggraphic/gravity-forms-notification-popup-keep-form.php
Gravity Forms Notification Popup (Genesis Framework)
<?php
//* OPTIONAL STEP - Keep the form disappearing.
//* Gravity Forms notification popup instead of the page redirect or AJAX notification.
//* Props to @WilliamAlexander in the comments
//* @link https://anythinggraphic.net/gravity-forms-notification-popup
add_filter( 'gform_confirmation', 'ag_custom_confirmation', 10, 4 );
function ag_custom_confirmation( $confirmation, $form, $entry, $ajax ) {
add_filter( 'wp_footer', 'ag_overlay');
@ApoGouv
ApoGouv / compatibility.js
Created August 4, 2017 11:29 — forked from danielpataki/compatibility.js
jQuery in WordPress
/* Regular jQuery */
$('.hideable').on('click', function() {
$(this).hide();
})
/* Compatibility Mode */
jQuery('.hideable').on('click', function() {
jQuery(this).hide();
})