###Custom Post Types
function codex_custom_init() {
$labels = array(
'name' => 'Books',
'singular_name' => 'Book',
'add_new' => 'Add New',
| <?php | |
| //----------------------------------------------------------/ | |
| // responsive images [ 1) add img-responsive class 2) remove dimensions ] | |
| //----------------------------------------------------------/ | |
| function bootstrap_responsive_images( $html ){ | |
| $classes = 'img-responsive'; // separated by spaces, e.g. 'img image-link' | |
| // check if there are already classes assigned to the anchor | |
| if ( preg_match('/<img.*? class="/', $html) ) { |
| /** | |
| * Optimize WooCommerce Scripts | |
| * Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages. | |
| */ | |
| add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 ); | |
| function child_manage_woocommerce_styles() { | |
| //remove generator meta tag | |
| remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) ); |
| <?php | |
| /** | |
| * How to integrate WordPress Core updates with your custom Plugin or Theme | |
| * | |
| * Filter the `update_plugins` transient to report your plugin as out of date. | |
| * Themes have a similar transient you can filter. | |
| */ | |
| add_filter( 'site_transient_update_plugins', 'wprp_extend_filter_update_plugins' ); | |
| add_filter( 'transient_update_plugins', 'wprp_extend_filter_update_plugins' ); | |
| function wprp_extend_filter_update_plugins( $update_plugins ) { |
| <?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'); | |
| // ---------------------------------------------------- |
###Custom Post Types
function codex_custom_init() {
$labels = array(
'name' => 'Books',
'singular_name' => 'Book',
'add_new' => 'Add New',
| <?php | |
| // hide coupon field on cart page | |
| function hide_coupon_field_on_cart( $enabled ) { | |
| if ( is_cart() ) { | |
| $enabled = false; | |
| } | |
| return $enabled; |
| <pre><?php | |
| // WordPress Multisite - Delete all revisions from all posts in a netword. | |
| // Quick hack by @mrazzari, 2014. | |
| // For context see this thread started by Kitchin at the forums: | |
| // http://wordpress.org/support/topic/deleting-post-revisions-do-not-use-the-abc-join-code-you-see-everywhere | |
| // HOWTO | |
| // This snippet is meant to be called as a standalone script. | |
| // Like http://example.com/tmp/multisite_delete_revisions.php |
| function test_wp_mail($args) | |
| { | |
| $debug = "<pre>" . var_export($args, true) . "</pre>"; | |
| wp_die($debug); | |
| } | |
| add_filter('wp_mail', 'test_wp_mail'); |
| <?php | |
| class Mobile_Detect { | |
| protected $accept; | |
| protected $userAgent; | |
| protected $isMobile = false; | |
| protected $isAndroid = null; | |
| protected $isBlackberry = null; |
| <ul class="products"> | |
| <?php | |
| $args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'product_cat' => 'camisa' ); | |
| $loop = new WP_Query( $args ); | |
| while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?> | |
| <h2>Shoes</h2> | |
| <li class="product"> | |
| <a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"> | |
| <?php | |
| woocommerce_show_product_sale_flash( $post, $product ); |