// make gravity forms return to the form when submitted instead of the top of the page add_filter( 'gform_confirmation_anchor', '__return_true' ); // fix for after upgrading WP the datepicker breaks, says Please select valid arrival date, then shows full month in date field Set the date format in WP settings // fix for flexslider jumps after slides load https://github.com/woothemes/FlexSlider/issues/165 .flexslider .slides > li:first-child{ display:block; } ***************** Fix WP 4.2 adds emoji stuff to header breaks calander next month arrows add this to functions.php remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); ************* WP plugin for sending smtp authenticated emails from forms - seems to be working with gravity forms 11/30/2015 WP-SMTP-MAIL-CONFIG ************* This is most likely obsolete since new API was released http://www.idxbroker.com/support/kb/questions/334/Fancy+Menus+%28Dropdown%29+Fix+for+the+Dynamic+Wrapper+Method+-+Genesis%7B47%7DAgentPress+Theme ************ http://wordpress.org/extend/plugins/creative-clans-embed-script/ ******** Use this for excluding categories and all their children categories. $parent_cats_to_exclude = array(71,72, 483,482); foreach ( $parent_cats_to_exclude as $cat ) { $cats_to_exclude[] = $cat; $child_categories = get_categories('child_of='.$cat); foreach ( $child_categories as $child ) { $cats_to_exclude[] = $child->cat_ID; } } *********** make sidebar background go all the way down: #content .sidebar { width: 180px; float: left; background: #dadada; margin-bottom: -30000px; padding-bottom: 30000px; } #content { overflow: hidden; } ****** (goes in functions.php file) add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link','image','quote','status','video','audio' ) ); ******* Plugin 'Parameter' to allow parameters to be passed in the URL and recognized by WordPress http://www.webopius.com/content/137/using-custom-url-parameters-in-wordpress ************ if ( is_page( 'about' ) || '2' == $post->post_parent ) { // the page is "About", or the parent of the page is "About" if (is_page(3737) || '3737' == $post->post_parent ){ //using page ID instead of slug http://css-tricks.com/snippets/wordpress/if-page-is-parent-or-child/ -- if ($post->post_parent=='12') -- ***** orderby=rand for random order use with query_posts **** troubleshoot javascript console.log('here'); ** fix for gallery shortcode with simple lightbox ***** FIX for NIVo slider flashing through the images on page load. Put in theme stylesheet near the top. .nivoSlider img, .nivo-caption { display:none; } **** ***** tabbed box code
.tabbed-box{width:611px;height:359px;margin:0 auto 20px;} ul.tabs{list-style:none;float:right;position:relative;z-index:2;top:290px;right:100px;} .tabs li {display:inline-block;font-size:12px;width:75px;} .tabs li a {padding:3px 5px;text-decoration:none;} *** end tabbed box code *** javascript conflicts Using jQuery jQuery is now namespaced to avoid conflicts with other Javascript libraries such as Prototype. All your code that expects to use jQuery as $ should be wrapped in an outer context like so. (function ($) { // All your code here })(jQuery); If you don't, you may see the error Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function or similar. THIS IS BETTER; var $ = jQuery.noConflict(); add after opening script tag, helps with undefined function errors ANOTHER OPTION replace $ with jQuery like this: jQuery(blah) *** end javascript conflicts //code to add RealTech to login page // Custom WP Admin Logo function my_custom_login_logo() { echo ''; } add_action('login_head', 'my_custom_login_logo'); // changing the login page URL function put_my_url(){ return ('http://www.rtservices.net/'); // putting my URL in place of the WordPress one } add_filter('login_headerurl', 'put_my_url'); // changing the login page URL hover text function put_my_title(){ return ('RealTech Services'); // changing the title from "Powered by WordPress" to whatever you wish } add_filter('login_headertitle', 'put_my_title'); **** //exclude categories from widget, put this code in functions.php function exclude_widget_categories($args){ $exclude = "3,7"; // The IDs of the excluding categories $args["exclude"] = $exclude; return $args; } add_filter("widget_categories_args","exclude_widget_categories"); **** mobile device detection code ** ***** HIDING PASSWORD PROTECTED POSTS // Filter to hide protected posts function exclude_protected($where) { global $wpdb; return $where .= " AND {$wpdb->posts}.post_password = '' "; } // Decide where to display them function exclude_protected_action($query) { if( !is_single() && !is_page() && !is_admin() ) { add_filter( 'posts_where', 'exclude_protected' ); } } // Action to queue the filter at the right time add_action('pre_get_posts', 'exclude_protected_action'); ************ add_filter( 'shortcode_atts_gallery', 'gallery_shortcode_exclude_thumbnail', 10, 3 ); function gallery_shortcode_exclude_thumbnail( $result, $defaults, $atts ) { if ( empty( $atts['exclude'] ) ) $result['exclude'] = get_post_thumbnail_id(); return $result; } ********** // add info box in admin area add_action( 'add_meta_boxes', 'post_info_box' ); function post_info_box() { add_meta_box( 'post_info_box', __( 'Information', 'myplugin_textdomain' ), 'post_info_box_content', 'post', 'side', 'low' ); } //defining the content of the info box function post_info_box_content( $post ) { ?> your code here, can be basic html ID, "catidsand", true) ): $var1 = explode(",",$categoryvariable); query_posts(array( 'category__and' => $var1, //'category__and' => array(14,23), 'meta_key' => 'price', 'orderby' => 'meta_value_num', 'order' => 'DESC' )); include ('archive-functions.php'); ***** A way to have the Post category checkboxes keep their hierarchy regardless of which ones are selected. I needed to find this to make sure the RRE agents would select the right categories. Add the code below to the functions.php file. function taxonomy_checklist_checked_ontop_filter ($args) { $args['checked_ontop'] = false; return $args; } add_filter('wp_terms_checklist_args','taxonomy_checklist_checked_ontop_filter'); *** http://www.gravityhelp.com/clearing-default-form-field-values-with-jquery/ clearit function, no longer needed with gravity forms current feature 11/30/2015 *** use this to make a shortcode to use within the content of a page or post In functions.php file: function injectstuff_func( $atts ) { ob_start(); extract( shortcode_atts( array( 'border' => '1px solid #ff0000', 'background' => '#00ff00', ), $atts ) ); include 'inc/testimonials.php'; return ob_get_clean(); } add_shortcode( 'injectstuff', 'injectstuff_func' ); In page or post edit screen [injectstuff border="#0000ff"] Include file can contain code, wp loop, etc. Use $border in the html code to replace the default color. ***** How To Remove Images From Post Content In WordPress ]+./','', $content); echo $postOutput;?> ****** How to get single to display future posts when not logged in. Add code to functions.php in theme. /* Show future posts */ function show_future_posts($posts) { global $wp_query, $wpdb; if(is_single() && $wp_query->post_count == 0) { $posts = $wpdb->get_results($wp_query->request); } return $posts; } add_filter('the_posts', 'show_future_posts'); **** // stop comments on media function filter_media_comment_status( $open, $post_id ) { $post = get_post( $post_id ); if( $post->post_type == 'attachment' ) { return false; } return $open; } add_filter( 'comments_open', 'filter_media_comment_status', 10 , 2 ); **** //paging not working on custom query; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('showposts=4&paged='.$paged); **** //output gallery of post's attachments, exclude featured image ID ) . '"]'); ?> ***** // amy's shortcode to include php files // example shortcode [codeinc file="map.php"] // put file to include into theme's inc directory // edit $ac_path as per correct path function ac_codeinc($atts) { ob_start(); $atts = shortcode_atts( array( 'file' => 'file', ), $atts ); $file = $atts['file']; $ac_path = ABSPATH."wp-content/themes/HurricaneFranchising/inc/".$file; // Load file or, if absent. throw error if (file_exists($ac_path)) { include($ac_path); return ob_get_clean(); } else { } } add_shortcode('codeinc', 'ac_codeinc'); **** // should not be needed, WP adds jquery in wp-includes now 11/30/2015 // Load jQuery if ( !is_admin() ) { wp_deregister_script('jquery'); wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false); wp_enqueue_script('jquery'); } **** // change default sort order for archives - add to functions.php in theme directory // Runs before the posts are fetched add_filter( 'pre_get_posts' , 'my_change_order' ); // Function accepting current query function my_change_order( $query ) { // Check if the query is for an archive if($query->is_archive) // Query was for archive, then set order $query->set( 'order' , 'asc' ); $query->set( 'orderby' , 'name' ); // Return the query (else there's no more query, oops!) return $query; } ********* // this will display the db query on the screen (change $homes_query to your WP query)
request; ?>
************* (add to functions.php in theme directory) // strip white space from wp menu items to fix IE function remove_white_space($output) { $output = str_replace("\n", "", $output); return $output; } add_filter('wp_nav_menu', 'remove_white_space'); ************ // amy's shortcodes - we don't need Peter! lol - put this code in the theme's functions.php file //[templatepath] shortcode function templatepath_func( $atts ){ $themedir = get_template(); $dir = dirname($_SERVER["REQUEST_URI"]); return $dir . "/wp-content/themes/" . $themedir; } add_shortcode( 'templatepath', 'templatepath_func' ); //[templateurl] shortcode function templateurl_func( $atts ){ $themeurl = get_template_directory_uri(); return $themeurl; } add_shortcode( 'templateurl', 'templateurl_func' ); //[siteurl] shortcode function siteurl_func( $atts ){ $siteurl = get_site_url(); return $siteurl; } add_shortcode( 'siteurl', 'siteurl_func' ); *********** ******** Fix for google maps controls not showing up on responsive sites add the following to the stylesheet: .gmnoprint img { max-width:none!important; } ******* /* remove tabs, spaces, newlines, etc. (those unexplained gaps in html code caused by how WP reads it) */ /* add this code above what you want to trim */ /* yourhtml here */ ob_end_flush(); ** here is another sample //... public function compressHtml($content) { $content = preg_replace('~>\s+<~', '><', $content); $content = preg_replace('/\s\s+/', ' ', $content); $i = 0; while ($i < 5) { $content = str_replace(' ', ' ', $content); $i++; } return $content; } ** another sample Here it is used to clear whitespace from css files: ************ optimizing css I could never get this to work.... Adapted for WebsiteTips.com by Shirley Kaiser, SKDesigns skdesigns.com. 1. The cache-control and gzip compression is adapted from The Definitive Post on Gzipping your CSS by Mike Papageorge, Fiftyfoureleven.com 2. Function compress is adapted from which removes extraneous whitespace: line breaks, carriage returns, plus CSS comments. This PHP code goes at the very TOP of the PHP-enabled style sheet above EVERYTHING else. --------------------------------- */ /* initialize ob_gzhandler to send and compress data */ ob_start ("ob_gzhandler"); /* initialize compress function for whitespace removal */ ob_start("compress"); /* required header info and character set */ header("Content-type: text/css;charset: UTF-8"); /* cache control to process */ header("Cache-Control: must-revalidate"); /* duration of cached content (1 hour) */ $offset = 60 * 60 ; /* expiration header format */ $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s",time() + $offset) . " GMT"; /* send cache expiration header to broswer */ header($ExpStr); /* Begin function compress */ function compress($buffer) { /* remove comments */ $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); /* remove tabs, spaces, new lines, etc. */ $buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer); /* remove unnecessary spaces */ $buffer = str_replace('{ ', '{', $buffer); $buffer = str_replace(' }', '}', $buffer); $buffer = str_replace('; ', ';', $buffer); $buffer = str_replace(', ', ',', $buffer); $buffer = str_replace(' {', '{', $buffer); $buffer = str_replace('} ', '}', $buffer); $buffer = str_replace(': ', ':', $buffer); $buffer = str_replace(' ,', ',', $buffer); $buffer = str_replace(' ;', ';', $buffer); return $buffer; } ?> ********** REMOVING ATTACHMENTS WHEN DELETING POSTS; Add the following to functions.php & test to make sure it works: //Delete attachments when post is deleted: function delete_posts_before_delete_post($id){ $subposts = get_children(array( 'post_parent' => $id, 'post_type' => 'any', 'numberposts' => -1, 'post_status' => 'any' )); if (is_array($subposts) && count($subposts) > 0){ $uploadpath = wp_upload_dir(); foreach($subposts as $subpost){ $_wp_attached_file = get_post_meta($subpost->ID, '_wp_attached_file', true); $original = basename($_wp_attached_file); $pos = strpos(strrev($original), '.'); if (strpos($original, '.') !== false){ $ext = explode('.', strrev($original)); $ext = strrev($ext[0]); } else { $ext = explode('-', strrev($original)); $ext = strrev($ext[0]); } $pattern = $uploadpath['basedir'].'/'.dirname($_wp_attached_file).'/'.basename($original, '.'.$ext).'-[0-9]*x[0-9]*.'.$ext; $original= $uploadpath['basedir'].'/'.dirname($_wp_attached_file).'/'.basename($original, '.'.$ext).'.'.$ext; if (getimagesize($original)){ $thumbs = glob($pattern); if (is_array($thumbs) && count($thumbs) > 0){ foreach($thumbs as $thumb) unlink($thumb); } } wp_delete_attachment( $subpost->ID, true ); } } } add_action('before_delete_post', 'delete_posts_before_delete_post'); *********** //AFTER MOVING A SITE WITH BACKUPBUDDY, THE GUID FIELD STILL HAS OLD DOMAIN IN THE URL. USE THIS QUEIRY TO UPDATE DB UPDATE rtwp_posts SET guid = REPLACE(guid, 'http://www.rtsvc.net/lizzie','http://www.amivacationrental.com'); //another option using wp-cli but don't skip columns wp search-replace 'http://example.dev' 'http://example.com' --skip-columns=guid ********** // make future posts work with permalink instead of ugly url add_filter( 'post_link', 'future_permalink', 10, 3 ); function future_permalink( $permalink, $post, $leavename, $sample = false ) { /* for filter recursion (infinite loop) */ static $recursing = false; /* No post ID or in the wp-admin */ if ( empty( $post->ID ) || is_admin() ) { return $permalink; } if ( !$recursing ) { if ( isset( $post->post_status ) && ( 'future' === $post->post_status ) ) { // set the post status to publish to get the 'publish' permalink $post->post_status = 'publish'; $recursing = true; return get_permalink( $post, $leavename ) ; } } $recursing = false; return $permalink; } /* Show future posts when not logged in */ function show_future_posts($posts) { global $wp_query, $wpdb; if(is_single() && $wp_query->post_count == 0) { $posts = $wpdb->get_results($wp_query->request); } return $posts; } add_filter('the_posts', 'show_future_posts'); /* htaccess http->https redirect example. MUST go after iThemes security code and before Wordpress code */ # BEGIN http to https RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.stpeteclearwatervacationrentals.com/$1 [R=301,L] # END http to https