From 5b3d2138496679fb90b834ea802d4f9648e14b20 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Tue, 14 Apr 2015 17:53:25 +1000 Subject: [PATCH] Allow underscore in equation variable names --- includes/libraries/class-eqeos.php | 2 +- includes/sp-core-functions.php | 35 ++++++++++++++++-------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/includes/libraries/class-eqeos.php b/includes/libraries/class-eqeos.php index 90b2fdb5..9c3c6260 100644 --- a/includes/libraries/class-eqeos.php +++ b/includes/libraries/class-eqeos.php @@ -350,7 +350,7 @@ class eqEOS { preg_replace("/\s/", "", $infix); //Find all the variables that were passed and replaces them - while((preg_match('/(.){0,1}[&$]([a-zA-Z]+)(.){0,1}/', $infix, $match)) != 0) { + while((preg_match('/(.){0,1}[&$]([a-zA-Z_]+)(.){0,1}/', $infix, $match)) != 0) { //remove notices by defining if undefined. if(!isset($match[3])) { diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index a295f1ad..7693fdf2 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -509,6 +509,7 @@ if ( !function_exists( 'sp_dropdown_taxonomies' ) ) { 'placeholder' => null, 'chosen' => false, 'parent' => 0, + 'include_children' => true, ); $args = array_merge( $defaults, $args ); if ( ! $args['taxonomy'] ) return false; @@ -568,25 +569,27 @@ if ( !function_exists( 'sp_dropdown_taxonomies' ) ) { printf( '', $this_value, $selected_prop, $term->name ); - $term_children = get_term_children( $term->term_id, $args['taxonomy'] ); + if ( $args['include_children'] ): + $term_children = get_term_children( $term->term_id, $args['taxonomy'] ); - foreach ( $term_children as $term_child_id ): - $term_child = get_term_by( 'id', $term_child_id, $args['taxonomy'] ); + foreach ( $term_children as $term_child_id ): + $term_child = get_term_by( 'id', $term_child_id, $args['taxonomy'] ); - if ( $args['values'] == 'term_id' ): - $this_value = $term_child->term_id; - else: - $this_value = $term_child->slug; - endif; + if ( $args['values'] == 'term_id' ): + $this_value = $term_child->term_id; + else: + $this_value = $term_child->slug; + endif; - if ( strpos( $property, 'multiple' ) !== false ): - $selected_prop = in_array( $this_value, $selected ) ? 'selected' : ''; - else: - $selected_prop = selected( $this_value, $selected, false ); - endif; + if ( strpos( $property, 'multiple' ) !== false ): + $selected_prop = in_array( $this_value, $selected ) ? 'selected' : ''; + else: + $selected_prop = selected( $this_value, $selected, false ); + endif; - printf( '', $this_value, $selected_prop, '— ' . $term_child->name ); - endforeach; + printf( '', $this_value, $selected_prop, '— ' . $term_child->name ); + endforeach; + endif; endforeach; print( '' ); return true; @@ -1009,7 +1012,7 @@ if ( !function_exists( 'sp_get_eos_safe_slug' ) ) { $title = sp_numbers_to_words( $title ); // Remove all other non-alphabet characters - $title = preg_replace( "/[^a-z]/", '', $title ); + $title = preg_replace( "/[^a-z_]/", '', $title ); // Convert post ID to words if title is empty if ( $title == '' ):