- create a new redis .conf file
$ cp /etc/redis.conf /etc/redis-xxx.conf- edit /etc/redis-xxx.conf, illustrated as below
...| // Show content conditionally based on course type | |
| add_shortcode( 'ld_display_course_content', 'ld_shortcode_display_course_content' ); | |
| function ld_shortcode_display_course_content( $atts , $content = null ) { | |
| global $post; | |
| if( is_admin() || !$post || !$post->post_type == 'sfwd-courses' || !isset( $atts['course_type'] ) ) { | |
| return; | |
| } | |
| $course_meta = get_post_meta($post->ID, '_sfwd-courses', true); |
| // Show personalized content to students | |
| add_shortcode( 'sv_personalize', 'nt_student_specific_content' ); | |
| function nt_student_specific_content( $atts , $content = null ) { | |
| if( !isset( $atts['values'] ) ) { | |
| return $content; | |
| } | |
| $atts['values'] = preg_replace('/\s*,\s*/', ',', $atts['values']); |
$ cp /etc/redis.conf /etc/redis-xxx.conf...| <?php | |
| // Create the stream context | |
| $context = stream_context_create(array( | |
| 'http' => array( | |
| 'timeout' => 3 // Timeout in seconds | |
| ) | |
| )); | |
| // Fetch the URL's contents |
| $fileName = 'Billing-Summary.csv'; | |
| header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | |
| header('Content-Description: File Transfer'); | |
| header("Content-type: text/csv"); | |
| header("Content-Disposition: attachment; filename={$fileName}"); | |
| header("Expires: 0"); | |
| header("Pragma: public"); | |
| $fh = @fopen( 'php://output', 'w' ); |
| /** | |
| * This function will connect wp_mail to your authenticated | |
| * SMTP server. This improves reliability of wp_mail, and | |
| * avoids many potential problems. | |
| * | |
| * Author: Chad Butler | |
| * Author URI: http://butlerblog.com | |
| * | |
| * For more information and instructions, see: | |
| * http://b.utler.co/Y3 |
| <?php | |
| $match_date = \DateTime::createFromFormat("Y-m-d H:i:s", $date_1); | |
| $match_date->setTime( 0, 0, 0 ); // reset time part, to prevent partial comparison | |
| $today = new \DateTime(); // This object represents current date/time | |
| $today->setTime( 0, 0, 0 ); // reset time part, to prevent partial comparison | |
| $diff = $today->diff( $match_date ); | |
| $diffDays = (integer)$diff->format( "%R%a" ); // Extract days count in interval |
| $csv = array_map("str_getcsv", file("file1.csv",FILE_SKIP_EMPTY_LINES)); | |
| $keys = array_shift($csv); | |
| foreach ($csv as $i=>$row) { | |
| $csv[$i] = array_combine($keys, $row); | |
| } |
| jQuery("#textbox_id").on("keypress", function(e){ | |
| var currentChar = parseInt(String.fromCharCode(e.keyCode), 10); | |
| if(!isNaN(currentChar)){ | |
| var nextValue = elem.val() + currentChar; //It's a string concatenation, not an addition | |
| if(parseInt(nextValue, 10) <= 20) return true; | |
| } | |
| return false; | |
| }); |
| <?php | |
| if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { | |
| // run Backend only code here | |
| } else { | |
| // Frontend code here, this will include the ajax calls | |
| } |