Skip to content

Instantly share code, notes, and snippets.

View mahdiyazdani's full-sized avatar
:bowtie:
Still Rocking!

Mahdi Yazdani mahdiyazdani

:bowtie:
Still Rocking!
View GitHub Profile
@mahdiyazdani
mahdiyazdani / add-shortcode-to-text-widget.php
Created October 16, 2016 17:41
Adding Shortcodes to Widgets
<?php
add_filter( 'widget_text', 'do_shortcode' );
@mahdiyazdani
mahdiyazdani / redirect-new-registered-user-to-specific-page.php
Created October 16, 2016 17:42
Redirect New Registered Users to a Specific Page
<?php
function my_registration_redirect(){
return home_url( '/finished/' );
}
add_filter( 'registration_redirect', 'my_registration_redirect' );
@mahdiyazdani
mahdiyazdani / remove-wordpress-version-number.php
Created October 16, 2016 17:43
Remove the WordPress Version Number
<?php
remove_action('wp_head', 'wp_generator');
@mahdiyazdani
mahdiyazdani / hide-wordpress-update-message.php
Created October 16, 2016 17:44
Hide the WordPress Update Message
<?php
// Hide WordPress Update
function my_hide_update() {
remove_action('admin_notices', 'update_nag', 3);
}
add_action('admin_menu','my_hide_update');
@mahdiyazdani
mahdiyazdani / remove-comments-url.php
Created October 16, 2016 17:45
Remove the Comment URL Field
<?php
function my_remove_comment_fields($fields) {
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields','my_remove_comment_fields');
@mahdiyazdani
mahdiyazdani / show-limit-results-on-search-results-page.php
Last active October 16, 2016 17:47
Show X Results on the Search Results Page
<?php
function my_limit_posts_per_search_page() {
if ( is_search() ):
set_query_var('posts_per_archive_page', 20);
endif;
}
add_filter('pre_get_posts', 'my_limit_posts_per_search_page');
@mahdiyazdani
mahdiyazdani / redirect-to-post-if-search-results-return-one-post.php
Created October 16, 2016 17:50
Redirect To Post If Search Results Return One Post
<?php
function my_redirect_single_post() {
if (is_search()) {
global $wp_query;
if ($wp_query->post_count == 1 && $wp_query->max_num_pages == 1) {
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
exit;
}
}
<?php
// Copies woocommerce orders and users over from source to target.
// I use this on my local machine - loading both db's up there side by side
// could easily adjust the connect strings to connect elsewhere if needed.
// will change order ids
// My use case for this is when I've got a staging/test version of a site with new posts/products/pages etc, that needs
// to go live without the loss of any orders placed on the site site since we copied it to the staging site.
@mahdiyazdani
mahdiyazdani / hypermarket-handy-css-classes.css
Last active January 4, 2017 02:02
Hypermarket handy CSS classes
.img-circle { border-radius: 50%; }
.img-rounded { border-radius: 6px; }
.opacity-75 {
opacity: 0.75;
filter: alpha(opacity=75)
}
.opacity-50 {
opacity: 0.5;
filter: alpha(opacity=50)
@mahdiyazdani
mahdiyazdani / hypermarket-mailchimp-newsletter-form.html
Created January 4, 2017 18:07
Hypermarket MailChimp Newsletter Form
<input type="email" name="EMAIL" class="form-control" placeholder="Your email address" required />
<button type="submit"><i class="material-icons send"></i></button>