├── README.md
├── add-custom-current-menu-item-class.php
├── add-media-url-column-with-size-link.php
├── admin-edit-list-view-open-new-window.php
├── disable-core-wp-lazy-load.php
├── disable-wp-core-sitemaps.php
├── dns-prefetch-control.txt
├── update-jquery-version-remove-jquery-migrate.php
├── woocommerce-archive-pages-remove-add-to-cart-buttons.php
├── woocommerce-replace-variable-price-range
├── wordpress-append-media-timestamp.php
├── wp-add-child-theme-custom-style-sheet.php
├── wp-boilerplate-site-specific-plugin.php
├── wp-dashboard-redirect.php
├── wp-insert-header-footer-php-html-homepage-sitewide.php
├── wp-public-post-preview-duration.php
└── wp-youtube-oembed-mod.php
/README.md:
--------------------------------------------------------------------------------
1 | # WordPress Snippets
2 | A collection of awesome WordPress Code Snippets you can use to optimize your WP website
3 | - curated by: Joe Campbell (@heyJoeCampbell) https://twitter.com/heyjoecampbell
4 |
--------------------------------------------------------------------------------
/add-custom-current-menu-item-class.php:
--------------------------------------------------------------------------------
1 | url == $homepage_url ) return $classes;
22 |
23 | if ( strstr( $current_url, $item->url) ) {
24 | // Add the 'parent_url' class - change to desire class
25 | $classes[] = 'parent_url';
26 | }
27 |
28 | return $classes;
29 | }
30 |
31 | function current_url() {
32 | // Protocol
33 | $url = ( 'on' == $_SERVER['HTTPS'] ) ? 'https://' : 'http://';
34 |
35 | $url .= $_SERVER['SERVER_NAME'];
36 |
37 | // Port
38 | $url .= ( '80' == $_SERVER['SERVER_PORT'] ) ? '' : ':' . $_SERVER['SERVER_PORT'];
39 |
40 | $url .= $_SERVER['REQUEST_URI'];
41 |
42 | return trailingslashit( $url );
43 | }
44 |
--------------------------------------------------------------------------------
/add-media-url-column-with-size-link.php:
--------------------------------------------------------------------------------
1 |
2 | '.$mediaLink.'';
17 | }
18 | add_filter( 'manage_media_columns', 'muc_column' );
19 | add_action( 'manage_media_custom_column', 'muc_value', 10, 2 );
20 |
--------------------------------------------------------------------------------
/admin-edit-list-view-open-new-window.php:
--------------------------------------------------------------------------------
1 | ID).'" target="_blank">View';
8 | return $actions;
9 | }
10 | add_filter( 'page_row_actions', 'change_post_row_actions', 10, 2 );
11 |
--------------------------------------------------------------------------------
/disable-core-wp-lazy-load.php:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
22 | ';}
23 | add_action( 'wp_head', 'add_dns_prefetch', 0 );
24 |
--------------------------------------------------------------------------------
/update-jquery-version-remove-jquery-migrate.php:
--------------------------------------------------------------------------------
1 | registered['jquery'] ) ) {
21 | $jquery_dependencies = $scripts->registered['jquery']->deps;
22 | $scripts->registered['jquery']->deps = array_diff( $jquery_dependencies, array( 'jquery-migrate' ) );
23 | }
24 | }
25 | add_action( 'wp_default_scripts', 'cedaro_dequeue_jquery_migrate' );
26 |
--------------------------------------------------------------------------------
/woocommerce-archive-pages-remove-add-to-cart-buttons.php:
--------------------------------------------------------------------------------
1 | get_variation_price( 'min', true ),
13 | $v_product->get_variation_price( 'max', true ) );
14 | $prod_price = $prod_prices[0]!==$prod_prices[1] ? sprintf(__('%1$s +', 'woocommerce'),
15 | wc_price( $prod_prices[0] ) ) : wc_price( $prod_prices[0] );
16 |
17 | // Regular Price
18 | $regular_prices = array( $v_product->get_variation_regular_price( 'min', true ),
19 | $v_product->get_variation_regular_price( 'max', true ) );
20 | sort( $regular_prices );
21 | $regular_price = $regular_prices[0]!==$regular_prices[1] ? sprintf(__('%1$s +','woocommerce')
22 | , wc_price( $regular_prices[0] ) ) : wc_price( $regular_prices[0] );
23 |
24 | if ( $prod_price !== $regular_price ) {
25 | $prod_price = ''.$regular_price.$v_product->get_price_suffix() . ' ' .
26 | $prod_price . $v_product->get_price_suffix() . '';
27 | }
28 | return $prod_price;
29 | }
30 |
--------------------------------------------------------------------------------
/wordpress-append-media-timestamp.php:
--------------------------------------------------------------------------------
1 | > date("YmdGs")
12 | $append = apply_filters('usp_file_append_random', true, $filename, $random);
13 |
14 | if (!$append) return $filename;
15 |
16 | $info = pathinfo($filename);
17 | $ext = (isset($info['extension']) && !empty($info['extension'])) ? '.'. $info['extension'] : '';
18 | $name = basename($filename, $ext) .'-'. $timestamp;
19 |
20 | return $name . $ext;
21 |
22 | }
23 | add_filter('sanitize_file_name', 'append_media_timestamp', 10);
24 |
--------------------------------------------------------------------------------
/wp-add-child-theme-custom-style-sheet.php:
--------------------------------------------------------------------------------
1 | @heyJoeCampbell
8 | */
9 |
10 |
11 | // REPLACE with your snippets - Happy Coding
12 |
13 |
14 | // THE END
15 |
--------------------------------------------------------------------------------
/wp-dashboard-redirect.php:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
19 |
20 |
21 |
29 |
30 |
31 |